From 4aa65011e36cf27d5ed057c01b8c02dc1a16d70a Mon Sep 17 00:00:00 2001 From: Tben Date: Sun, 13 Aug 2023 14:56:56 +0100 Subject: [PATCH] Update Types --- client/media/imageInputFileToBase64.js | 2 +- client/media/imageInputToBase64.js | 2 +- client/media/inputFileToBase64.js | 4 ++-- engine/dump.js | 2 +- engine/engine/addUsersTableToDb.js | 2 +- engine/engine/createDbFromSchema.js | 2 +- engine/engine/utils/dbHandler.js | 2 +- engine/engine/utils/noDatabaseDbHandler.js | 2 +- engine/engine/utils/parseDbResults.js | 2 +- engine/engine/utils/updateTable.js | 10 ++++----- .../utils/varReadOnlyDatabaseDbHandler.js | 2 +- engine/query/get.js | 4 ++-- engine/query/post.js | 4 ++-- .../query/update-api-schema-from-local-db.js | 2 +- engine/query/utils/addDbEntry.js | 2 +- engine/query/utils/runQuery.js | 2 +- engine/query/utils/updateDbEntry.js | 2 +- engine/user/add-user.js | 2 +- engine/user/login-user.js | 2 +- engine/user/reauth-user.js | 2 +- engine/user/social/github-auth.js | 2 +- engine/user/social/utils/githubLogin.js | 2 +- engine/user/social/utils/handleSocialDb.js | 2 +- engine/user/update-user.js | 2 +- functions/decrypt.js | 2 +- functions/encrypt.js | 2 +- package-lock.json | 22 +++++++++++++++++-- package.json | 5 ++++- utils/delete-file.js | 2 +- utils/upload-file.js | 2 +- utils/upload-image.js | 2 +- 31 files changed, 60 insertions(+), 39 deletions(-) diff --git a/client/media/imageInputFileToBase64.js b/client/media/imageInputFileToBase64.js index b3808a2..508c807 100644 --- a/client/media/imageInputFileToBase64.js +++ b/client/media/imageInputFileToBase64.js @@ -94,7 +94,7 @@ module.exports = async function imageInputFileToBase64({ imageInputFile, maxWidt imageName: imageName, imageSize: imageSize, }; - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Image Processing Error! =>", error.message); return { diff --git a/client/media/imageInputToBase64.js b/client/media/imageInputToBase64.js index 23bd2bf..3932fea 100644 --- a/client/media/imageInputToBase64.js +++ b/client/media/imageInputToBase64.js @@ -85,7 +85,7 @@ module.exports = async function imageInputToBase64({ imageInput, maxWidth, mimeT imageBase64Full: imageDataBase64, imageName: imageName, }; - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Image Processing Error! =>", error.message); return { diff --git a/client/media/inputFileToBase64.js b/client/media/inputFileToBase64.js index 3b1dcb4..af97614 100644 --- a/client/media/inputFileToBase64.js +++ b/client/media/inputFileToBase64.js @@ -58,7 +58,7 @@ module.exports = async function inputFileToBase64({ inputFile, allowedRegex }) { reader.onload = function () { resolve(reader.result); }; - reader.onerror = function (error) { + reader.onerror = function (/** @type {*} */ error) { console.log("Error: ", error.message); }; }); @@ -78,7 +78,7 @@ module.exports = async function inputFileToBase64({ inputFile, allowedRegex }) { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("File Processing Error! =>", error.message); return { diff --git a/engine/dump.js b/engine/dump.js index 3448ba9..68eacd4 100644 --- a/engine/dump.js +++ b/engine/dump.js @@ -48,6 +48,6 @@ try { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// -} catch (error) { +} catch (/** @type {*} */ error) { console.log("Dump Error: ", error.message); } diff --git a/engine/engine/addUsersTableToDb.js b/engine/engine/addUsersTableToDb.js index 6ba4b03..1d7ced6 100644 --- a/engine/engine/addUsersTableToDb.js +++ b/engine/engine/addUsersTableToDb.js @@ -67,7 +67,7 @@ module.exports = async function addUsersTableToDb({ dbSchema }) { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log(error.message); } }; diff --git a/engine/engine/createDbFromSchema.js b/engine/engine/createDbFromSchema.js index fd41144..e16be31 100644 --- a/engine/engine/createDbFromSchema.js +++ b/engine/engine/createDbFromSchema.js @@ -243,7 +243,7 @@ async function createDbFromSchema(dbSchema) { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in createDbFromSchema => ", error.message); } } diff --git a/engine/engine/utils/dbHandler.js b/engine/engine/utils/dbHandler.js index a4a45a3..d98dd18 100644 --- a/engine/engine/utils/dbHandler.js +++ b/engine/engine/utils/dbHandler.js @@ -113,7 +113,7 @@ module.exports = async function dbHandler({ query, values, database }) { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("DB handler error:", error.message); results = null; diff --git a/engine/engine/utils/noDatabaseDbHandler.js b/engine/engine/utils/noDatabaseDbHandler.js index ee5efcd..1b747d4 100644 --- a/engine/engine/utils/noDatabaseDbHandler.js +++ b/engine/engine/utils/noDatabaseDbHandler.js @@ -72,7 +72,7 @@ module.exports = async function noDatabaseDbHandler({ query, values }) { //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("ERROR in noDatabaseDbHandler =>", error.message); } diff --git a/engine/engine/utils/parseDbResults.js b/engine/engine/utils/parseDbResults.js index 6b4608c..c402036 100644 --- a/engine/engine/utils/parseDbResults.js +++ b/engine/engine/utils/parseDbResults.js @@ -67,7 +67,7 @@ module.exports = async function parseDbResults({ unparsedResults, tableSchema }) * @description Declare "results" variable */ return parsedResults; - } catch (error) { + } catch (/** @type {*} */ error) { console.log("ERROR in parseDbResults Function =>", error.message); return unparsedResults; } diff --git a/engine/engine/utils/updateTable.js b/engine/engine/utils/updateTable.js index 20c57fa..7b8d622 100644 --- a/engine/engine/utils/updateTable.js +++ b/engine/engine/utils/updateTable.js @@ -79,7 +79,7 @@ module.exports = async function updateTable({ dbFullName, tableName, tableInfoAr //////////////////////////////////////// /** - * @type {DSQL_MYSQL_SHOW_INDEXES_Type[] | null} + * @type {*} * @description All indexes from MYSQL db */ const allExistingIndexes = await varDatabaseDbHandler({ @@ -88,7 +88,7 @@ module.exports = async function updateTable({ dbFullName, tableName, tableInfoAr }); /** - * @type {DSQL_MYSQL_SHOW_COLUMNS_Type[] | null} + * @type {*} * @description All columns from MYSQL db */ const allExistingColumns = await varDatabaseDbHandler({ @@ -158,7 +158,7 @@ module.exports = async function updateTable({ dbFullName, tableName, tableInfoAr upToDateTableFieldsArray = userSchemaData[targetDbIndex].tables[targetTableIndex].fields; fs.writeFileSync(schemaPath, JSON.stringify(userSchemaData), "utf8"); - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in updating Table =>", error.message); } @@ -261,7 +261,7 @@ module.exports = async function updateTable({ dbFullName, tableName, tableInfoAr /** * @description All MSQL Foreign Keys - * @type {DSQL_MYSQL_FOREIGN_KEYS_Type[] | null} + * @type {*} */ const allForeignKeys = await varDatabaseDbHandler({ queryString: `SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = '${dbFullName}' AND TABLE_NAME='${tableName}' AND CONSTRAINT_TYPE='FOREIGN KEY'`, @@ -443,7 +443,7 @@ module.exports = async function updateTable({ dbFullName, tableName, tableInfoAr //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log('Error in "updateTable" function =>', error.message); return "Error in Updating Table"; diff --git a/engine/engine/utils/varReadOnlyDatabaseDbHandler.js b/engine/engine/utils/varReadOnlyDatabaseDbHandler.js index 7d7b750..b444895 100644 --- a/engine/engine/utils/varReadOnlyDatabaseDbHandler.js +++ b/engine/engine/utils/varReadOnlyDatabaseDbHandler.js @@ -30,7 +30,7 @@ module.exports = async function varReadOnlyDatabaseDbHandler({ queryString, data results = await dbHandler({ query: queryString, values: queryValuesArray, database: database }); //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// console.log("\x1b[31mvarReadOnlyDatabaseDbHandler ERROR\x1b[0m =>", database, error.message); diff --git a/engine/query/get.js b/engine/query/get.js index 96d31fe..24a5338 100644 --- a/engine/query/get.js +++ b/engine/query/get.js @@ -69,7 +69,7 @@ async function localGet({ options, dbSchema }) { return { success: true, payload: results }; //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// console.log("Error in local get Request =>", error.message); @@ -78,7 +78,7 @@ async function localGet({ options, dbSchema }) { } //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// console.log("Error in local get Request =>", error.message); diff --git a/engine/query/post.js b/engine/query/post.js index 0bdb361..671a96e 100644 --- a/engine/query/post.js +++ b/engine/query/post.js @@ -72,7 +72,7 @@ async function localPost({ options, dbSchema }) { }; //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// return { @@ -83,7 +83,7 @@ async function localPost({ options, dbSchema }) { } //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// console.log("Error in local post Request =>", error.message); diff --git a/engine/query/update-api-schema-from-local-db.js b/engine/query/update-api-schema-from-local-db.js index 9fff28c..07d8131 100644 --- a/engine/query/update-api-schema-from-local-db.js +++ b/engine/query/update-api-schema-from-local-db.js @@ -127,7 +127,7 @@ async function updateApiSchemaFromLocalDb() { /** ********************************************** */ return httpResponse; - } catch (error) { + } catch (/** @type {*} */ error) { return { success: false, payload: null, diff --git a/engine/query/utils/addDbEntry.js b/engine/query/utils/addDbEntry.js index 63fee79..c4d95be 100644 --- a/engine/query/utils/addDbEntry.js +++ b/engine/query/utils/addDbEntry.js @@ -101,7 +101,7 @@ async function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, ta } insertValuesArray.push(value); - } catch (error) { + } catch (/** @type {*} */ error) { console.log("DSQL: Error in parsing data keys =>", error.message); continue; } diff --git a/engine/query/utils/runQuery.js b/engine/query/utils/runQuery.js index 4d26e54..0b078e1 100644 --- a/engine/query/utils/runQuery.js +++ b/engine/query/utils/runQuery.js @@ -127,7 +127,7 @@ async function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArra //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in Running Query =>", error.message); result = null; error = error.message; diff --git a/engine/query/utils/updateDbEntry.js b/engine/query/utils/updateDbEntry.js index 1f1f977..3d8ee2b 100644 --- a/engine/query/utils/updateDbEntry.js +++ b/engine/query/utils/updateDbEntry.js @@ -96,7 +96,7 @@ async function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// //////////////////////////////////////// diff --git a/engine/user/add-user.js b/engine/user/add-user.js index b69bba7..3863dd6 100644 --- a/engine/user/add-user.js +++ b/engine/user/add-user.js @@ -135,7 +135,7 @@ async function localAddUser({ payload, dbSchema }) { } //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// console.log("Error in local add-user Request =>", error.message); diff --git a/engine/user/login-user.js b/engine/user/login-user.js index 814b09a..bf60f73 100644 --- a/engine/user/login-user.js +++ b/engine/user/login-user.js @@ -134,7 +134,7 @@ async function loginLocalUser({ payload, additionalFields, dbSchema }) { }; //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in local login-user Request =>", error.message); return { success: false, diff --git a/engine/user/reauth-user.js b/engine/user/reauth-user.js index 2bd962b..4428a9b 100644 --- a/engine/user/reauth-user.js +++ b/engine/user/reauth-user.js @@ -93,7 +93,7 @@ async function localReauthUser({ existingUser, additionalFields, dbSchema }) { //////////////////////////////////////// //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in local login-user Request =>", error.message); return { success: false, diff --git a/engine/user/social/github-auth.js b/engine/user/social/github-auth.js index 12d8ad7..b302681 100644 --- a/engine/user/social/github-auth.js +++ b/engine/user/social/github-auth.js @@ -119,7 +119,7 @@ async function localGithubAuth({ res, code, email, clientId, clientSecret, addit return { ...loggedInGithubUser, dsqlUserId: "0" }; //////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("localGithubAuth error", error.message); return { success: false, msg: "Failed!" }; diff --git a/engine/user/social/utils/githubLogin.js b/engine/user/social/utils/githubLogin.js index a01cd28..6ef06b2 100644 --- a/engine/user/social/utils/githubLogin.js +++ b/engine/user/social/utils/githubLogin.js @@ -136,7 +136,7 @@ async function githubLogin({ code, clientId, clientSecret }) { //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// diff --git a/engine/user/social/utils/handleSocialDb.js b/engine/user/social/utils/handleSocialDb.js index f9b46e3..2c5de6e 100644 --- a/engine/user/social/utils/handleSocialDb.js +++ b/engine/user/social/utils/handleSocialDb.js @@ -258,7 +258,7 @@ async function handleSocialDb({ social_id, email, social_platform, payload, res, //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// - } catch (error) { + } catch (/** @type {*} */ error) { console.log("ERROR in 'handleSocialDb.js' backend function =>", error.message); return { diff --git a/engine/user/update-user.js b/engine/user/update-user.js index 5b20dc3..51128cb 100644 --- a/engine/user/update-user.js +++ b/engine/user/update-user.js @@ -72,7 +72,7 @@ async function localUpdateUser({ payload, dbSchema }) { success: true, payload: updateUser, }; - } catch (error) { + } catch (/** @type {*} */ error) { //////////////////////////////////////// console.log("Error in local add-user Request =>", error.message); diff --git a/functions/decrypt.js b/functions/decrypt.js index 4317066..294452d 100644 --- a/functions/decrypt.js +++ b/functions/decrypt.js @@ -37,7 +37,7 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => { let decrypted = decipher.update(encryptedString, "hex", "utf8"); decrypted += decipher.final("utf8"); return decrypted; - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in decrypting =>", error.message); return encryptedString; } diff --git a/functions/encrypt.js b/functions/encrypt.js index 7a95893..5c3fc6e 100644 --- a/functions/encrypt.js +++ b/functions/encrypt.js @@ -36,7 +36,7 @@ const encrypt = ({ data, encryptionKey, encryptionSalt }) => { let encrypted = cipher.update(data, "utf8", "hex"); encrypted += cipher.final("hex"); return encrypted; - } catch (error) { + } catch (/** @type {*} */ error) { console.log("Error in encrypting =>", error.message); return data; } diff --git a/package-lock.json b/package-lock.json index 3d80500..155781a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "datasquirel", - "version": "1.6.8", + "version": "1.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "datasquirel", - "version": "1.6.8", + "version": "1.7.0", "license": "ISC", "dependencies": { "dotenv": "^16.3.1", @@ -16,8 +16,26 @@ "bin": { "dsql-dump": "engine/dump.js", "dsql-watch": "engine/dsql.js" + }, + "devDependencies": { + "@types/mysql": "^2.15.21" } }, + "node_modules/@types/mysql": { + "version": "2.15.21", + "resolved": "https://registry.npmjs.org/@types/mysql/-/mysql-2.15.21.tgz", + "integrity": "sha512-NPotx5CVful7yB+qZbWtXL2fA4e7aEHkihHLjklc6ID8aq7bhguHgeIoC1EmSNTAuCgI6ZXrjt2ZSaXnYX0EUg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "20.4.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.10.tgz", + "integrity": "sha512-vwzFiiy8Rn6E0MtA13/Cxxgpan/N6UeNYR9oUu6kuJWxu6zCk98trcDp8CBhbtaeuq9SykCmXkFr2lWLoPcvLg==", + "dev": true + }, "node_modules/agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", diff --git a/package.json b/package.json index 9fd9ade..a5d482e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.7.0", + "version": "1.7.1", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": { @@ -29,5 +29,8 @@ "dotenv": "^16.3.1", "google-auth-library": "^9.0.0", "mysql": "^2.18.1" + }, + "devDependencies": { + "@types/mysql": "^2.15.21" } } diff --git a/utils/delete-file.js b/utils/delete-file.js index 27b97f9..4f69250 100644 --- a/utils/delete-file.js +++ b/utils/delete-file.js @@ -88,7 +88,7 @@ async function uploadImage({ key, url }) { /** ********************************************** */ return httpResponse; - } catch (error) { + } catch (/** @type {*} */ error) { /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ diff --git a/utils/upload-file.js b/utils/upload-file.js index 17cee84..1ba01dd 100644 --- a/utils/upload-file.js +++ b/utils/upload-file.js @@ -93,7 +93,7 @@ async function uploadImage({ key, payload }) { /** ********************************************** */ return httpResponse; - } catch (error) { + } catch (/** @type {*} */ error) { /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ diff --git a/utils/upload-image.js b/utils/upload-image.js index 0c480ac..25964ca 100644 --- a/utils/upload-image.js +++ b/utils/upload-image.js @@ -95,7 +95,7 @@ async function uploadImage({ key, payload }) { /** ********************************************** */ return httpResponse; - } catch (error) { + } catch (/** @type {*} */ error) { /** ********************************************** */ /** ********************************************** */ /** ********************************************** */