From 0da68e30b854c6f0c19deea1cd98b5636133a38e Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 19 Feb 2026 04:52:04 +0100 Subject: [PATCH] Updates --- .../handle-unique-constraints.js | 28 ----------- dist/package-shared/types/dsql.d.ts | 3 +- dist/package-shared/types/index.d.ts | 45 +++++++++++++++++- .../handle-unique-constraints.ts | 31 ------------ package-shared/types/dsql.ts | 6 ++- package-shared/types/index.ts | 47 ++++++++++++++++++- package.json | 2 +- 7 files changed, 97 insertions(+), 65 deletions(-) diff --git a/dist/package-shared/shell/createDbFromSchema/handle-unique-constraints.js b/dist/package-shared/shell/createDbFromSchema/handle-unique-constraints.js index 81ccc37..6e456e2 100644 --- a/dist/package-shared/shell/createDbFromSchema/handle-unique-constraints.js +++ b/dist/package-shared/shell/createDbFromSchema/handle-unique-constraints.js @@ -23,34 +23,6 @@ const app_data_1 = __importDefault(require("../../data/app-data")); */ function handleUniqueConstraintsCreateDbFromSchema(_a) { 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 */ diff --git a/dist/package-shared/types/dsql.d.ts b/dist/package-shared/types/dsql.d.ts index 604ead7..5c98d74 100644 --- a/dist/package-shared/types/dsql.d.ts +++ b/dist/package-shared/types/dsql.d.ts @@ -35,7 +35,7 @@ export type DSQL_DATASQUIREL_API_KEYS = { name?: string; slug?: string; key?: string; - scope?: "readOnly" | "fullAccess"; + scope?: "readOnly" | "fullAccess" | "media"; all_dbs?: 0 | 1; media_only?: 0 | 1; csrf?: string; @@ -373,3 +373,4 @@ export type DSQL_DATASQUIREL_USER_PRIVATE_MEDIA_KEYS = { date_updated_code?: number; 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; diff --git a/dist/package-shared/types/index.d.ts b/dist/package-shared/types/index.d.ts index 9d04a3c..4465f50 100644 --- a/dist/package-shared/types/index.d.ts +++ b/dist/package-shared/types/index.d.ts @@ -54,10 +54,35 @@ export interface DSQL_TableSchemaType { indexes?: DSQL_IndexSchemaType[]; uniqueConstraints?: DSQL_UniqueConstraintSchemaType[]; childrenTables?: DSQL_ChildrenTablesType[]; + /** + * Whether this is a child table + */ childTable?: boolean; updateData?: boolean; + /** + * ID of the parent table + */ 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; + /** + * ID of the Database of parent table + */ childTableDbId?: string | number; collation?: (typeof MariaDBCollations)[number]; isVector?: boolean; @@ -839,6 +864,7 @@ export type ApiKeyObject = { sign?: string; date_code?: number; error?: string; + media_only?: boolean; }; export type AddApiKeyRequestBody = { api_key: DSQL_DATASQUIREL_API_KEYS; @@ -1486,7 +1512,7 @@ export type PagePropsType = { mediaCurrentFolder?: string | null; appData?: DsqlAppData | null; staticHost?: string | null; - folders?: string[] | null; + folders?: LocalFolderType[] | null; activeClonedTable?: boolean | null; tableEntries?: DefaultEntryType[] | null; tableEntriesCount?: number | null; @@ -1520,6 +1546,11 @@ export type PagePropsType = { docsObject?: DocsServerProps | null; docsPages?: DocsLinkType[] | null; docsPageEditURL?: string | null; + isFolderPrivate?: boolean; +}; +export type LocalFolderType = { + name: string; + isPrivate: boolean; }; export type ResponseQueryObject = { sql?: string; @@ -1969,6 +2000,7 @@ export type AddMediaAPIBody = { export type ReplaceMediaAPIBody = { mediaId: number; media: MediaUploadDataType; + is_media_folder_private: boolean; }; export declare const TargetMediaParadigms: readonly ["info", "preview"]; export type TargetMediaDataType = { @@ -2504,3 +2536,14 @@ export type SQLInsertGenParams = { tableName: 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; +}; diff --git a/package-shared/shell/createDbFromSchema/handle-unique-constraints.ts b/package-shared/shell/createDbFromSchema/handle-unique-constraints.ts index 3e811e0..bc7ce9e 100644 --- a/package-shared/shell/createDbFromSchema/handle-unique-constraints.ts +++ b/package-shared/shell/createDbFromSchema/handle-unique-constraints.ts @@ -24,37 +24,6 @@ export default async function handleUniqueConstraintsCreateDbFromSchema({ tableName, tableUniqueConstraints, }: 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 */ diff --git a/package-shared/types/dsql.ts b/package-shared/types/dsql.ts index fa9f51a..876e7f1 100644 --- a/package-shared/types/dsql.ts +++ b/package-shared/types/dsql.ts @@ -59,7 +59,7 @@ export type DSQL_DATASQUIREL_API_KEYS = { name?: string; slug?: string; key?: string; - scope?: "readOnly" | "fullAccess"; + scope?: "readOnly" | "fullAccess" | "media"; all_dbs?: 0 | 1; media_only?: 0 | 1; csrf?: string; @@ -415,4 +415,6 @@ export type DSQL_DATASQUIREL_USER_PRIVATE_MEDIA_KEYS = { date_updated?: string; date_updated_code?: number; date_updated_timestamp?: string; -} \ No newline at end of file +} + +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 \ No newline at end of file diff --git a/package-shared/types/index.ts b/package-shared/types/index.ts index 7637e08..e731839 100644 --- a/package-shared/types/index.ts +++ b/package-shared/types/index.ts @@ -101,10 +101,35 @@ export interface DSQL_TableSchemaType { indexes?: DSQL_IndexSchemaType[]; uniqueConstraints?: DSQL_UniqueConstraintSchemaType[]; childrenTables?: DSQL_ChildrenTablesType[]; + /** + * Whether this is a child table + */ childTable?: boolean; updateData?: boolean; + /** + * ID of the parent table + */ 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; + /** + * ID of the Database of parent table + */ childTableDbId?: string | number; collation?: (typeof MariaDBCollations)[number]; isVector?: boolean; @@ -991,6 +1016,7 @@ export type ApiKeyObject = { sign?: string; date_code?: number; error?: string; + media_only?: boolean; }; export type AddApiKeyRequestBody = { @@ -1732,7 +1758,7 @@ export type PagePropsType = { mediaCurrentFolder?: string | null; appData?: DsqlAppData | null; staticHost?: string | null; - folders?: string[] | null; + folders?: LocalFolderType[] | null; activeClonedTable?: boolean | null; tableEntries?: DefaultEntryType[] | null; tableEntriesCount?: number | null; @@ -1766,6 +1792,12 @@ export type PagePropsType = { docsObject?: DocsServerProps | null; docsPages?: DocsLinkType[] | null; docsPageEditURL?: string | null; + isFolderPrivate?: boolean; +}; + +export type LocalFolderType = { + name: string; + isPrivate: boolean; }; export type ResponseQueryObject = { @@ -2535,6 +2567,7 @@ export type AddMediaAPIBody = { export type ReplaceMediaAPIBody = { mediaId: number; media: MediaUploadDataType; + is_media_folder_private: boolean; }; export const TargetMediaParadigms = ["info", "preview"] as const; @@ -3200,3 +3233,15 @@ export type SQLInsertGenParams = { tableName: 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; +}; diff --git a/package.json b/package.json index 80fc0c3..bf71719 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "5.7.51", + "version": "5.7.52", "description": "Cloud-based SQL data management tool", "main": "dist/index.js", "bin": {