From a07b57584e23752e8c22080fc2ff1a695d2bf50c Mon Sep 17 00:00:00 2001 From: Pankaj Kumar Bind Date: Sun, 22 Jun 2025 20:21:44 +0530 Subject: [PATCH] Resolve compilation errors in table-related classes --- src/tables/table.ts | 5 ++--- src/tables/tablesApiClient.ts | 18 ++++++++++++------ src/tables/tablesRestApiClient.ts | 19 ++++++++++++++----- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/tables/table.ts b/src/tables/table.ts index 9fac694..c8f1b86 100644 --- a/src/tables/table.ts +++ b/src/tables/table.ts @@ -72,8 +72,8 @@ export default class Table { async update(updateQuery: string): Promise { await this.tablesApiClient.updateTable(this.name, this.integration,updateQuery); } -} + /** * Insert data into this table. * @param {string} select - SELECT query to insert data from. * @throws {MindsDbError} - Something went wrong inserting data into the table. @@ -81,5 +81,4 @@ export default class Table { async insert(select: string): Promise { await this.tablesApiClient.insertTable(this.name, this.integration, select); } -} - +} \ No newline at end of file diff --git a/src/tables/tablesApiClient.ts b/src/tables/tablesApiClient.ts index c7b260b..64fa625 100644 --- a/src/tables/tablesApiClient.ts +++ b/src/tables/tablesApiClient.ts @@ -41,6 +41,14 @@ export default abstract class TablesApiClient { */ abstract deleteTable(name: string, integration: string): Promise; + /** + * Removes a table from its integration. + * @param {string} name - Name of the table to be removed. + * @param {string} integration - Name of the integration the table to be removed is a part of. + * @throws {MindsDbError} - Something went wrong removing the table. + */ + abstract removeTable(name: string, integration: string): Promise; + /** * Updates a table from its integration. * @param {string} name - Name of the table to be updated. @@ -84,11 +92,9 @@ export default abstract class TablesApiClient { * * @param filePath - The local path to the file that needs to be uploaded. * @param fileName - The name that the file should have on the remote server after the upload. - * - * @returns A promise that resolves when the file has been successfully uploaded. - * The promise does not return any value upon success. - * - * @throws {Error} - If there is an error during the file upload process, the promise is rejected with an error message. + * * @returns A promise that resolves when the file has been successfully uploaded. + * The promise does not return any value upon success. + * * @throws {Error} - If there is an error during the file upload process, the promise is rejected with an error message. */ abstract uploadFile(filePath: string, fileName: string, original_file_name?: string): Promise; -} +} \ No newline at end of file diff --git a/src/tables/tablesRestApiClient.ts b/src/tables/tablesRestApiClient.ts index e6a4544..d8fedff 100644 --- a/src/tables/tablesRestApiClient.ts +++ b/src/tables/tablesRestApiClient.ts @@ -108,6 +108,17 @@ export default class TablesRestApiClient extends TablesApiClient { } + /** + * Removes a table from its integration. + * @param {string} name - Name of the table to be removed. + * @param {string} integration - Name of the integration the table to be removed is a part of. + * @throws {MindsDbError} - Something went wrong removing the table. + */ + override async removeTable(name: string, integration: string): Promise { + await this.deleteTable(name, integration); + } + + /** * Updates a table from its integration. * @param {string} name - Name of the table to be updated. @@ -149,8 +160,7 @@ export default class TablesRestApiClient extends TablesApiClient { * @throws {MindsDbError} - Something went wrong deleting the data from the table. */ override async deleteFromTable(name: string, integration: string, select?: string): Promise { - /** - If select parameter is not passed then entire data from the table is deleted. + /** If select parameter is not passed then entire data from the table is deleted. */ const sqlQuery = select ?? `DELETE FROM TABLE ${mysql.escapeId( integration @@ -214,8 +224,7 @@ export default class TablesRestApiClient extends TablesApiClient { * @param {string} fileName - The desired name for the file once it is uploaded. * @param {string} [original_file_name] - (Optional) The original name of the file before renaming. This is typically * used for logging, tracking, or maintaining the original file's identity. - * - * @returns {Promise} A promise that resolves when the file upload is complete. If the upload fails, + * * @returns {Promise} A promise that resolves when the file upload is complete. If the upload fails, * an error will be thrown. * * @throws {Error} If there is an issue with the upload, such as network errors, permission issues, or invalid file paths. @@ -257,4 +266,4 @@ export default class TablesRestApiClient extends TablesApiClient { } -} +} \ No newline at end of file