This commit is contained in:
Benjamin Toby 2026-02-19 04:52:04 +01:00
parent 0a1993494d
commit 0da68e30b8
7 changed files with 97 additions and 65 deletions

View File

@ -23,34 +23,6 @@ const app_data_1 = __importDefault(require("../../data/app-data"));
*/ */
function handleUniqueConstraintsCreateDbFromSchema(_a) { function handleUniqueConstraintsCreateDbFromSchema(_a) {
return __awaiter(this, arguments, void 0, function* ({ dbFullName, tableName, tableUniqueConstraints, }) { return __awaiter(this, arguments, void 0, function* ({ dbFullName, tableName, tableUniqueConstraints, }) {
/**
* # Delete All Existing Unique Constraints
*/
// const allExistingUniqueConstraints = (await dbHandler({
// query: `SHOW INDEXES FROM \`${dbFullName}\`.\`${tableName}\` WHERE Index_comment LIKE '%${AppData["UniqueConstraintComment"]}%'`,
// })) as DSQL_MYSQL_SHOW_INDEXES_Type[] | null;
// if (allExistingUniqueConstraints?.[0]) {
// for (let f = 0; f < allExistingUniqueConstraints.length; f++) {
// const { Key_name } = allExistingUniqueConstraints[f];
// try {
// const existingKeyInSchema = tableUniqueConstraints?.find(
// (indexObject) => indexObject.alias === Key_name
// );
// if (!existingKeyInSchema)
// throw new Error(
// `This Index(${Key_name}) Has been Deleted!`
// );
// } catch (error) {
// /**
// * @description Drop Index: This happens when the MYSQL index is not
// * present in the datasquirel DB schema
// */
// await dbHandler({
// query: `ALTER TABLE \`${dbFullName}\`.\`${tableName}\` DROP INDEX \`${Key_name}\``,
// });
// }
// }
// }
/** /**
* # Re-Add New Constraints * # Re-Add New Constraints
*/ */

View File

@ -35,7 +35,7 @@ export type DSQL_DATASQUIREL_API_KEYS = {
name?: string; name?: string;
slug?: string; slug?: string;
key?: string; key?: string;
scope?: "readOnly" | "fullAccess"; scope?: "readOnly" | "fullAccess" | "media";
all_dbs?: 0 | 1; all_dbs?: 0 | 1;
media_only?: 0 | 1; media_only?: 0 | 1;
csrf?: string; csrf?: string;
@ -373,3 +373,4 @@ export type DSQL_DATASQUIREL_USER_PRIVATE_MEDIA_KEYS = {
date_updated_code?: number; date_updated_code?: number;
date_updated_timestamp?: string; date_updated_timestamp?: string;
}; };
export type DSQL_DATASQUIREL_ALL_TYPEDEFS = DSQL_DATASQUIREL_USERS & DSQL_DATASQUIREL_API_KEYS & DSQL_DATASQUIREL_API_KEYS_SCOPED_RESOURCES & DSQL_DATASQUIREL_INVITATIONS & DSQL_DATASQUIREL_USER_DATABASES & DSQL_DATASQUIREL_USER_DATABASE_TABLES & DSQL_DATASQUIREL_USER_MEDIA & DSQL_DATASQUIREL_USER_PRIVATE_FOLDERS & DSQL_DATASQUIREL_DELEGATED_USERS & DSQL_DATASQUIREL_DELEGATED_RESOURCES & DSQL_DATASQUIREL_MARIADB_USER_PRIVILEGES & DSQL_DATASQUIREL_UNSUBSCRIBES & DSQL_DATASQUIREL_NOTIFICATIONS & DSQL_DATASQUIREL_DELETED_API_KEYS & DSQL_DATASQUIREL_SERVERS & DSQL_DATASQUIREL_PROCESS_QUEUE & DSQL_DATASQUIREL_BACKUPS & DSQL_DATASQUIREL_MARIADB_USERS & DSQL_DATASQUIREL_MARIADB_USER_DATABASES & DSQL_DATASQUIREL_MARIADB_USER_TABLES & DSQL_DATASQUIREL_USER_PRIVATE_MEDIA_KEYS;

View File

@ -54,10 +54,35 @@ export interface DSQL_TableSchemaType {
indexes?: DSQL_IndexSchemaType[]; indexes?: DSQL_IndexSchemaType[];
uniqueConstraints?: DSQL_UniqueConstraintSchemaType[]; uniqueConstraints?: DSQL_UniqueConstraintSchemaType[];
childrenTables?: DSQL_ChildrenTablesType[]; childrenTables?: DSQL_ChildrenTablesType[];
/**
* Whether this is a child table
*/
childTable?: boolean; childTable?: boolean;
updateData?: boolean; updateData?: boolean;
/**
* ID of the parent table
*/
childTableId?: string | number; childTableId?: string | number;
/**
* ID of the parent table
*/
parentTableId?: string | number;
/**
* ID of the Database of parent table
*/
parentTableDbId?: string | number;
/**
* Name of the Database of parent table
*/
parentTableDbName?: string;
/**
* Name of the parent table
*/
parentTableName?: string;
tableNameOld?: string; tableNameOld?: string;
/**
* ID of the Database of parent table
*/
childTableDbId?: string | number; childTableDbId?: string | number;
collation?: (typeof MariaDBCollations)[number]; collation?: (typeof MariaDBCollations)[number];
isVector?: boolean; isVector?: boolean;
@ -839,6 +864,7 @@ export type ApiKeyObject = {
sign?: string; sign?: string;
date_code?: number; date_code?: number;
error?: string; error?: string;
media_only?: boolean;
}; };
export type AddApiKeyRequestBody = { export type AddApiKeyRequestBody = {
api_key: DSQL_DATASQUIREL_API_KEYS; api_key: DSQL_DATASQUIREL_API_KEYS;
@ -1486,7 +1512,7 @@ export type PagePropsType = {
mediaCurrentFolder?: string | null; mediaCurrentFolder?: string | null;
appData?: DsqlAppData | null; appData?: DsqlAppData | null;
staticHost?: string | null; staticHost?: string | null;
folders?: string[] | null; folders?: LocalFolderType[] | null;
activeClonedTable?: boolean | null; activeClonedTable?: boolean | null;
tableEntries?: DefaultEntryType[] | null; tableEntries?: DefaultEntryType[] | null;
tableEntriesCount?: number | null; tableEntriesCount?: number | null;
@ -1520,6 +1546,11 @@ export type PagePropsType = {
docsObject?: DocsServerProps | null; docsObject?: DocsServerProps | null;
docsPages?: DocsLinkType[] | null; docsPages?: DocsLinkType[] | null;
docsPageEditURL?: string | null; docsPageEditURL?: string | null;
isFolderPrivate?: boolean;
};
export type LocalFolderType = {
name: string;
isPrivate: boolean;
}; };
export type ResponseQueryObject = { export type ResponseQueryObject = {
sql?: string; sql?: string;
@ -1969,6 +2000,7 @@ export type AddMediaAPIBody = {
export type ReplaceMediaAPIBody = { export type ReplaceMediaAPIBody = {
mediaId: number; mediaId: number;
media: MediaUploadDataType; media: MediaUploadDataType;
is_media_folder_private: boolean;
}; };
export declare const TargetMediaParadigms: readonly ["info", "preview"]; export declare const TargetMediaParadigms: readonly ["info", "preview"];
export type TargetMediaDataType = { export type TargetMediaDataType = {
@ -2504,3 +2536,14 @@ export type SQLInsertGenParams = {
tableName: string; tableName: string;
dbFullName?: string; dbFullName?: string;
}; };
export type APIReqParams = {
media_id?: number;
is_folder_private?: boolean;
is_file_private?: boolean;
raw_media?: MediaUploadDataType[];
media_type?: "video" | "image" | "file";
is_media_folder_private?: boolean;
folder?: string;
is_media_private?: boolean;
force_update_media?: boolean;
};

View File

@ -24,37 +24,6 @@ export default async function handleUniqueConstraintsCreateDbFromSchema({
tableName, tableName,
tableUniqueConstraints, tableUniqueConstraints,
}: Param) { }: Param) {
/**
* # Delete All Existing Unique Constraints
*/
// const allExistingUniqueConstraints = (await dbHandler({
// query: `SHOW INDEXES FROM \`${dbFullName}\`.\`${tableName}\` WHERE Index_comment LIKE '%${AppData["UniqueConstraintComment"]}%'`,
// })) as DSQL_MYSQL_SHOW_INDEXES_Type[] | null;
// if (allExistingUniqueConstraints?.[0]) {
// for (let f = 0; f < allExistingUniqueConstraints.length; f++) {
// const { Key_name } = allExistingUniqueConstraints[f];
// try {
// const existingKeyInSchema = tableUniqueConstraints?.find(
// (indexObject) => indexObject.alias === Key_name
// );
// if (!existingKeyInSchema)
// throw new Error(
// `This Index(${Key_name}) Has been Deleted!`
// );
// } catch (error) {
// /**
// * @description Drop Index: This happens when the MYSQL index is not
// * present in the datasquirel DB schema
// */
// await dbHandler({
// query: `ALTER TABLE \`${dbFullName}\`.\`${tableName}\` DROP INDEX \`${Key_name}\``,
// });
// }
// }
// }
/** /**
* # Re-Add New Constraints * # Re-Add New Constraints
*/ */

View File

@ -59,7 +59,7 @@ export type DSQL_DATASQUIREL_API_KEYS = {
name?: string; name?: string;
slug?: string; slug?: string;
key?: string; key?: string;
scope?: "readOnly" | "fullAccess"; scope?: "readOnly" | "fullAccess" | "media";
all_dbs?: 0 | 1; all_dbs?: 0 | 1;
media_only?: 0 | 1; media_only?: 0 | 1;
csrf?: string; csrf?: string;
@ -415,4 +415,6 @@ export type DSQL_DATASQUIREL_USER_PRIVATE_MEDIA_KEYS = {
date_updated?: string; date_updated?: string;
date_updated_code?: number; date_updated_code?: number;
date_updated_timestamp?: string; date_updated_timestamp?: string;
} }
export type DSQL_DATASQUIREL_ALL_TYPEDEFS = DSQL_DATASQUIREL_USERS & DSQL_DATASQUIREL_API_KEYS & DSQL_DATASQUIREL_API_KEYS_SCOPED_RESOURCES & DSQL_DATASQUIREL_INVITATIONS & DSQL_DATASQUIREL_USER_DATABASES & DSQL_DATASQUIREL_USER_DATABASE_TABLES & DSQL_DATASQUIREL_USER_MEDIA & DSQL_DATASQUIREL_USER_PRIVATE_FOLDERS & DSQL_DATASQUIREL_DELEGATED_USERS & DSQL_DATASQUIREL_DELEGATED_RESOURCES & DSQL_DATASQUIREL_MARIADB_USER_PRIVILEGES & DSQL_DATASQUIREL_UNSUBSCRIBES & DSQL_DATASQUIREL_NOTIFICATIONS & DSQL_DATASQUIREL_DELETED_API_KEYS & DSQL_DATASQUIREL_SERVERS & DSQL_DATASQUIREL_PROCESS_QUEUE & DSQL_DATASQUIREL_BACKUPS & DSQL_DATASQUIREL_MARIADB_USERS & DSQL_DATASQUIREL_MARIADB_USER_DATABASES & DSQL_DATASQUIREL_MARIADB_USER_TABLES & DSQL_DATASQUIREL_USER_PRIVATE_MEDIA_KEYS

View File

@ -101,10 +101,35 @@ export interface DSQL_TableSchemaType {
indexes?: DSQL_IndexSchemaType[]; indexes?: DSQL_IndexSchemaType[];
uniqueConstraints?: DSQL_UniqueConstraintSchemaType[]; uniqueConstraints?: DSQL_UniqueConstraintSchemaType[];
childrenTables?: DSQL_ChildrenTablesType[]; childrenTables?: DSQL_ChildrenTablesType[];
/**
* Whether this is a child table
*/
childTable?: boolean; childTable?: boolean;
updateData?: boolean; updateData?: boolean;
/**
* ID of the parent table
*/
childTableId?: string | number; childTableId?: string | number;
/**
* ID of the parent table
*/
parentTableId?: string | number;
/**
* ID of the Database of parent table
*/
parentTableDbId?: string | number;
/**
* Name of the Database of parent table
*/
parentTableDbName?: string;
/**
* Name of the parent table
*/
parentTableName?: string;
tableNameOld?: string; tableNameOld?: string;
/**
* ID of the Database of parent table
*/
childTableDbId?: string | number; childTableDbId?: string | number;
collation?: (typeof MariaDBCollations)[number]; collation?: (typeof MariaDBCollations)[number];
isVector?: boolean; isVector?: boolean;
@ -991,6 +1016,7 @@ export type ApiKeyObject = {
sign?: string; sign?: string;
date_code?: number; date_code?: number;
error?: string; error?: string;
media_only?: boolean;
}; };
export type AddApiKeyRequestBody = { export type AddApiKeyRequestBody = {
@ -1732,7 +1758,7 @@ export type PagePropsType = {
mediaCurrentFolder?: string | null; mediaCurrentFolder?: string | null;
appData?: DsqlAppData | null; appData?: DsqlAppData | null;
staticHost?: string | null; staticHost?: string | null;
folders?: string[] | null; folders?: LocalFolderType[] | null;
activeClonedTable?: boolean | null; activeClonedTable?: boolean | null;
tableEntries?: DefaultEntryType[] | null; tableEntries?: DefaultEntryType[] | null;
tableEntriesCount?: number | null; tableEntriesCount?: number | null;
@ -1766,6 +1792,12 @@ export type PagePropsType = {
docsObject?: DocsServerProps | null; docsObject?: DocsServerProps | null;
docsPages?: DocsLinkType[] | null; docsPages?: DocsLinkType[] | null;
docsPageEditURL?: string | null; docsPageEditURL?: string | null;
isFolderPrivate?: boolean;
};
export type LocalFolderType = {
name: string;
isPrivate: boolean;
}; };
export type ResponseQueryObject = { export type ResponseQueryObject = {
@ -2535,6 +2567,7 @@ export type AddMediaAPIBody = {
export type ReplaceMediaAPIBody = { export type ReplaceMediaAPIBody = {
mediaId: number; mediaId: number;
media: MediaUploadDataType; media: MediaUploadDataType;
is_media_folder_private: boolean;
}; };
export const TargetMediaParadigms = ["info", "preview"] as const; export const TargetMediaParadigms = ["info", "preview"] as const;
@ -3200,3 +3233,15 @@ export type SQLInsertGenParams = {
tableName: string; tableName: string;
dbFullName?: string; dbFullName?: string;
}; };
export type APIReqParams = {
media_id?: number;
is_folder_private?: boolean;
is_file_private?: boolean;
raw_media?: MediaUploadDataType[];
media_type?: "video" | "image" | "file";
is_media_folder_private?: boolean;
folder?: string;
is_media_private?: boolean;
force_update_media?: boolean;
};

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "5.7.51", "version": "5.7.52",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {