From fdb1501588c0b995cffe8bc7ef930e8e56cf8f92 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Wed, 23 Oct 2024 06:55:53 +0100 Subject: [PATCH] Update types --- engine/dsql.js | 1 + package-shared/types/index.d.ts | 29 ++++++++++++++++ package-shared/types/index.js | 61 ++++++++++++++++++++++++++------- package.json | 2 +- 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/engine/dsql.js b/engine/dsql.js index f94e33e..543d81f 100644 --- a/engine/dsql.js +++ b/engine/dsql.js @@ -68,6 +68,7 @@ async function run() { process.exit(); } + /** @type {import("../package-shared/types").DSQL_DatabaseSchemaType} */ // @ts-ignore let fetchedDbSchemaObject = dbSchemaDataResponse.payload; if (DSQL_DB_NAME) fetchedDbSchemaObject.dbFullName = DSQL_DB_NAME; diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index d7229c1..e911139 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -327,3 +327,32 @@ interface GetSchemaAPICredentialsParam { } type GetSchemaAPIParam = GetSchemaRequestQuery & GetSchemaAPICredentialsParam; + +interface PostReturn { + success: boolean; + payload?: Object[] | string; +} + +interface PostDataPayload { + action: "insert" | "update" | "delete"; + table: string; + data?: object; + identifierColumnName?: string; + identifierValue?: string; + duplicateColumnName?: string; + duplicateColumnValue?: string; + update?: boolean; +} + +interface LocalPostReturn { + success: boolean; + payload?: any; + msg?: string; + error?: string; +} + +interface LocalPostQueryObject { + query: string | PostDataPayload; + tableName?: string; + queryValues?: string[]; +} diff --git a/package-shared/types/index.js b/package-shared/types/index.js index f98e8f0..9c64efd 100644 --- a/package-shared/types/index.js +++ b/package-shared/types/index.js @@ -245,22 +245,22 @@ const http = require("http"); * @property {string} [country] * @property {string} [zip_code] * @property {number} [social_login] - * @property {string?} [social_platform] - * @property {string?} [social_id] + * @property {string} [social_platform] + * @property {string} [social_id] * @property {string} [more_user_data] * @property {number} [verification_status] - * @property {number?} [loan_officer_id] + * @property {number} [loan_officer_id] * @property {number} [is_admin] * @property {number} [admin_level] * @property {string} [admin_permissions] - * @property {string?} uuid - * @property {string?} [temp_login_code] - * @property {string?} [date_created] - * @property {number?} [date_created_code] - * @property {string?} [date_created_timestamp] - * @property {string?} [date_updated] - * @property {number?} [date_updated_code] - * @property {string?} [date_updated_timestamp] + * @property {string} uuid + * @property {string} [temp_login_code] + * @property {string} [date_created] + * @property {number} [date_created_code] + * @property {string} [date_created_timestamp] + * @property {string} [date_updated] + * @property {number} [date_updated_code] + * @property {string} [date_updated_timestamp] * @property {string} [csrf_k] - CSRF key * @property {boolean} [logged_in_status] * @property {number} [date] @@ -310,7 +310,7 @@ const http = require("http"); * @property {string} last_name - Last Name *Required * @property {string} email - Email *Required * @property {string} password - Password *Required - * @property {string?} username - Username (Optional) + * @property {string} username - Username (Optional) */ /** @@ -369,3 +369,40 @@ const http = require("http"); /** * @typedef {GetSchemaRequestQuery & GetSchemaAPICredentialsParam} GetSchemaAPIParam */ + +/** + * @typedef {Object} PostReturn + * @property {boolean} success - Did the function run successfully? + * @property {(Object[]|string)} [payload=[]] - The Y Coordinate + */ + +/** + * @typedef {object} PostDataPayload + * @property {"insert" | "update" | "delete"} action - The target action to take + * @property {string} table - Table name(slug) eg "blog_posts" + * @property {object} [data] - Table insert payload object => This must have keys that match + * table fields + * @property {string} [identifierColumnName] - Table identifier field name => eg. "id" OR "email" + * @property {string} [identifierValue] - Corresponding value of the selected field name => This + * checks identifies a the target row for "update" or "delete". Not needed for "insert" + * @property {string} [duplicateColumnName] - Duplicate column name to check for + * @property {string} [duplicateColumnValue] - Duplicate column value to match. If no "update" param + * provided, function will return null + * @property {boolean} [update] - Should the "insert" action update the existing entry if indeed + * the entry with "duplicateColumnValue" exists? + */ + +/** + * @typedef {Object} LocalPostReturn + * @property {boolean} success - Did the function run successfully? + * @property {*} [payload] - GET request results + * @property {string} [msg] - Message + * @property {string} [error] - Error Message + */ + +/** + * @typedef {Object} LocalPostQueryObject + * @property {PostDataPayload | string} query - Table Name + * @property {string} [tableName] - Table Name + * @property {string[]} [queryValues] - GET request results + */ diff --git a/package.json b/package.json index 77bb25a..d4e0135 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "2.3.1", + "version": "2.3.2", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {