Updates
This commit is contained in:
+2
-3
@@ -24,7 +24,7 @@ const deleteDbEntry_1 = __importDefault(require("../../functions/backend/db/dele
|
||||
function dsqlCrud(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, tableSchema, deleteKeyValuesOperator, dbConfig, query, } = params;
|
||||
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, tableSchema, deleteKeyValuesOperator, dbConfig, query, onDuplicate, } = params;
|
||||
const finalData = (sanitize ? sanitize({ data }) : data);
|
||||
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
||||
const queryObject = query
|
||||
@@ -46,8 +46,6 @@ function dsqlCrud(params) {
|
||||
switch (action) {
|
||||
case "get":
|
||||
return yield (0, crud_get_1.default)(params);
|
||||
// case "batch-get":
|
||||
// return await dsqlCrudBatchGet(params);
|
||||
case "insert":
|
||||
const INSERT_RESULT = yield (0, addDbEntry_1.default)({
|
||||
data: finalData,
|
||||
@@ -57,6 +55,7 @@ function dsqlCrud(params) {
|
||||
debug,
|
||||
tableSchema,
|
||||
dbConfig,
|
||||
onDuplicate,
|
||||
});
|
||||
return INSERT_RESULT;
|
||||
case "update":
|
||||
|
||||
+4
@@ -45,6 +45,9 @@ function default_1({ currentDbSchema, currentTableSchema, currentTableSchemaInde
|
||||
if (targetChildTableParentDatabaseTable === null || targetChildTableParentDatabaseTable === void 0 ? void 0 : targetChildTableParentDatabaseTable.childTable) {
|
||||
targetChildTableParentDatabase.tables[targetChildTableParentDatabaseTableIndex].fields = [...currentTableSchema.fields];
|
||||
targetChildTableParentDatabase.tables[targetChildTableParentDatabaseTableIndex].indexes = [...(currentTableSchema.indexes || [])];
|
||||
targetChildTableParentDatabase.tables[targetChildTableParentDatabaseTableIndex].uniqueConstraints = [
|
||||
...(currentTableSchema.uniqueConstraints || []),
|
||||
];
|
||||
(0, grab_required_database_schemas_1.writeUpdatedDbSchema)({
|
||||
dbSchema: targetChildTableParentDatabase,
|
||||
userId,
|
||||
@@ -133,6 +136,7 @@ function default_1({ currentDbSchema, currentTableSchema, currentTableSchemaInde
|
||||
targetParentDatabaseTable.fields;
|
||||
newCurrentDbSchema.tables[currentTableSchemaIndex].indexes =
|
||||
targetParentDatabaseTable.indexes;
|
||||
newCurrentDbSchema.tables[currentTableSchemaIndex].uniqueConstraints = targetParentDatabaseTable.uniqueConstraints;
|
||||
(0, grab_required_database_schemas_1.writeUpdatedDbSchema)({ dbSchema: targetParentDatabase, userId });
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
type Param = {
|
||||
type: "foreign_key" | "index" | "user";
|
||||
type: "foreign_key" | "index" | "user" | "unique_constraint";
|
||||
userId?: string | number;
|
||||
addDate?: boolean;
|
||||
};
|
||||
|
||||
+5
-1
@@ -7,6 +7,8 @@ exports.default = grabSQLKeyName;
|
||||
*/
|
||||
function grabSQLKeyName({ type, userId, addDate }) {
|
||||
let prefixParadigm = (() => {
|
||||
if (type == "unique_constraint")
|
||||
return "unq";
|
||||
if (type == "foreign_key")
|
||||
return "fk";
|
||||
if (type == "index")
|
||||
@@ -15,12 +17,14 @@ function grabSQLKeyName({ type, userId, addDate }) {
|
||||
return "user";
|
||||
return null;
|
||||
})();
|
||||
const uuid = crypto.randomUUID();
|
||||
const uidPrefx = uuid.split("-")[0];
|
||||
let key = `dsql`;
|
||||
if (prefixParadigm)
|
||||
key += `_${prefixParadigm}`;
|
||||
if (userId)
|
||||
key += `_${userId}`;
|
||||
if (addDate)
|
||||
key += `_${Date.now()}`;
|
||||
key += `_${uidPrefx}`;
|
||||
return key;
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,5 +1,15 @@
|
||||
export default function parseEnv(
|
||||
/** The file path to the env. Eg. /app/.env */ envFile: string): {
|
||||
DSQL_APP_DIR: string | undefined;
|
||||
DSQL_DATA_DIR: string | undefined;
|
||||
DSQL_USER_DB_PREFIX: string | undefined;
|
||||
DSQL_USER_ID: string | undefined;
|
||||
DSQL_DB_NAME: string | undefined;
|
||||
DSQL_DB_HOST: string | undefined;
|
||||
DSQL_DB_USERNAME: string | undefined;
|
||||
DSQL_DB_PASSWORD: string | undefined;
|
||||
DSQL_ENCRYPTION_PASSWORD: string | undefined;
|
||||
DSQL_ENCRYPTION_SALT: string | undefined;
|
||||
DSQL_HOST: string | undefined;
|
||||
NEXT_PUBLIC_DSQL_HOST: string | undefined;
|
||||
DSQL_STATIC_HOST: string | undefined;
|
||||
@@ -13,19 +23,14 @@ export default function parseEnv(
|
||||
NEXT_PUBLIC_DSQL_REMOTE_SQL_HOST: string | undefined;
|
||||
DSQL_DB_TARGET_IP_ADDRESS: string | undefined;
|
||||
NEXT_PUBLIC_VERSION: string | undefined;
|
||||
DSQL_USER_DB_PREFIX: string | undefined;
|
||||
DSQL_USER_DELEGATED_DB_COOKIE_PREFIX: string | undefined;
|
||||
DSQL_NETWORK_IP_PREFIX: string | undefined;
|
||||
DSQL_NETWORK_GATEWAY: string | undefined;
|
||||
DSQL_NETWORK_SUBNET: string | undefined;
|
||||
DSQL_MARIADB_MASTER_HOST: string | undefined;
|
||||
DSQL_DB_HOST: string | undefined;
|
||||
DSQL_WEB_APP_HOST: string | undefined;
|
||||
DSQL_DB_USERNAME: string | undefined;
|
||||
DSQL_DB_PASSWORD: string | undefined;
|
||||
DSQL_MARIADB_ROOT_PASSWORD: string | undefined;
|
||||
DSQL_REPLICATION_USER_PASSWORD: string | undefined;
|
||||
DSQL_DB_NAME: string | undefined;
|
||||
DSQL_MARIADB_REPLICATION_PASSWORD: string | undefined;
|
||||
DSQL_MAXSCALE_PASSWORD: string | undefined;
|
||||
DSQL_DB_READ_ONLY_USERNAME: string | undefined;
|
||||
@@ -33,8 +38,6 @@ export default function parseEnv(
|
||||
DSQL_DB_FULL_ACCESS_USERNAME: string | undefined;
|
||||
DSQL_DB_FULL_ACCESS_PASSWORD: string | undefined;
|
||||
DSQL_DB_EXPOSED_PORT: string | undefined;
|
||||
DSQL_ENCRYPTION_PASSWORD: string | undefined;
|
||||
DSQL_ENCRYPTION_SALT: string | undefined;
|
||||
DSQL_SU_USER_ID: string | undefined;
|
||||
DSQL_SU_USER_UUID: string | undefined;
|
||||
DSQL_SU_EMAIL: string | undefined;
|
||||
@@ -47,7 +50,6 @@ export default function parseEnv(
|
||||
DSQL_MAIL_PASSWORD: string | undefined;
|
||||
DSQL_TINY_MCE_API_KEY: string | undefined;
|
||||
DSQL_GITHUB_ID: string | undefined;
|
||||
DSQL_USER_ID: string | undefined;
|
||||
DSQL_GITHUB_SECRET: string | undefined;
|
||||
DSQL_GITHUB_WEBHOOK_SECRET: string | undefined;
|
||||
DSQL_GITHUB_WEBHOOK_URL: string | undefined;
|
||||
@@ -62,8 +64,6 @@ export default function parseEnv(
|
||||
DSQL_VOLUME_DB_SSL: string | undefined;
|
||||
DSQL_USER_LOGIN_KEYS_PATH: string | undefined;
|
||||
DSQL_API_KEYS_PATH: string | undefined;
|
||||
DSQL_APP_DIR: string | undefined;
|
||||
DSQL_DATA_DIR: string | undefined;
|
||||
DSQL_CONTACT_EMAIL: string | undefined;
|
||||
DSQL_SSL_DIR: string | undefined;
|
||||
DSQL_DEPLOYMENT_NAME: string | undefined;
|
||||
|
||||
Reference in New Issue
Block a user