Update Types
This commit is contained in:
parent
2f93b6a311
commit
bf903d3524
2
.gitignore
vendored
2
.gitignore
vendored
@ -141,3 +141,5 @@ test/
|
|||||||
|
|
||||||
# NPM
|
# NPM
|
||||||
# .npmrc
|
# .npmrc
|
||||||
|
|
||||||
|
/dump
|
||||||
|
@ -22,7 +22,7 @@ const updateApiSchemaFromLocalDb = require("../query/update-api-schema-from-loca
|
|||||||
* ==============================================================================
|
* ==============================================================================
|
||||||
*
|
*
|
||||||
* @param {object} params - Single object passed
|
* @param {object} params - Single object passed
|
||||||
* @param {DSQL_DatabaseSchemaType | undefined} params.dbSchema - Database Schema Object
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Database Schema Object
|
||||||
*
|
*
|
||||||
* @returns {Promise<*>} new user auth object payload
|
* @returns {Promise<*>} new user auth object payload
|
||||||
*/
|
*/
|
||||||
@ -33,7 +33,7 @@ module.exports = async function addUsersTableToDb({ dbSchema }) {
|
|||||||
* @description Initialize
|
* @description Initialize
|
||||||
*/
|
*/
|
||||||
const database = process.env.DSQL_DB_NAME || "";
|
const database = process.env.DSQL_DB_NAME || "";
|
||||||
/** @type {DSQL_TableSchemaType} */
|
/** @type {import("@/package-shared/types").DSQL_TableSchemaType} */
|
||||||
const userPreset = require("./data/presets/users.json");
|
const userPreset = require("./data/presets/users.json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -29,7 +29,7 @@ const runQuery = require("./utils/runQuery");
|
|||||||
*
|
*
|
||||||
* @param {Object} params - Single object passed
|
* @param {Object} params - Single object passed
|
||||||
* @param {LocalQueryObject} params.options - SQL Query
|
* @param {LocalQueryObject} params.options - SQL Query
|
||||||
* @param {DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
|
||||||
*
|
*
|
||||||
* @returns { Promise<LocalGetReturn> } - Return Object
|
* @returns { Promise<LocalGetReturn> } - Return Object
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +24,7 @@ const runQuery = require("./utils/runQuery");
|
|||||||
*
|
*
|
||||||
* @param {Object} params - Single object passed
|
* @param {Object} params - Single object passed
|
||||||
* @param {LocalPostQueryObject} params.options - SQL Query
|
* @param {LocalPostQueryObject} params.options - SQL Query
|
||||||
* @param {DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
|
||||||
*
|
*
|
||||||
* @returns { Promise<LocalPostReturn> } - Return Object
|
* @returns { Promise<LocalPostReturn> } - Return Object
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@ const updateDbEntry = require("./updateDbEntry");
|
|||||||
* @param {string} params.dbFullName - Database full name
|
* @param {string} params.dbFullName - Database full name
|
||||||
* @param {string} params.tableName - Table name
|
* @param {string} params.tableName - Table name
|
||||||
* @param {*} params.data - Data to add
|
* @param {*} params.data - Data to add
|
||||||
* @param {DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {import("@/package-shared/types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||||
* @param {string} [params.duplicateColumnName] - Duplicate column name
|
* @param {string} [params.duplicateColumnName] - Duplicate column name
|
||||||
* @param {string} [params.duplicateColumnValue] - Duplicate column value
|
* @param {string} [params.duplicateColumnValue] - Duplicate column value
|
||||||
* @param {boolean} [params.update] - Update this row if it exists
|
* @param {boolean} [params.update] - Update this row if it exists
|
||||||
|
@ -19,7 +19,7 @@ const dbHandler = require("../../engine/utils/dbHandler");
|
|||||||
* "Read only" or "Full Access"? Defaults to "Read Only"
|
* "Read only" or "Full Access"? Defaults to "Read Only"
|
||||||
* @param {string} params.dbFullName - Database full name
|
* @param {string} params.dbFullName - Database full name
|
||||||
* @param {string} params.tableName - Table name
|
* @param {string} params.tableName - Table name
|
||||||
* @param {DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {import("@/package-shared/types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||||
* @param {string} params.identifierColumnName - Update row identifier column name
|
* @param {string} params.identifierColumnName - Update row identifier column name
|
||||||
* @param {string|number} params.identifierValue - Update row identifier column value
|
* @param {string|number} params.identifierValue - Update row identifier column value
|
||||||
*
|
*
|
||||||
|
@ -31,7 +31,7 @@ const varDatabaseDbHandler = require("../../engine/utils/varDatabaseDbHandler");
|
|||||||
* @param {string} params.dbFullName - Database full name. Eg. "datasquire_user_2_test"
|
* @param {string} params.dbFullName - Database full name. Eg. "datasquire_user_2_test"
|
||||||
* @param {*} params.query - Query string or object
|
* @param {*} params.query - Query string or object
|
||||||
* @param {boolean} [params.readOnly] - Is this operation read only?
|
* @param {boolean} [params.readOnly] - Is this operation read only?
|
||||||
* @param {DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema
|
||||||
* @param {string[]} [params.queryValuesArray] - An optional array of query values if "?" is used in the query string
|
* @param {string[]} [params.queryValuesArray] - An optional array of query values if "?" is used in the query string
|
||||||
* @param {string} [params.tableName] - Table Name
|
* @param {string} [params.tableName] - Table Name
|
||||||
*
|
*
|
||||||
|
@ -21,7 +21,7 @@ const dbHandler = require("../../engine/utils/dbHandler");
|
|||||||
* @param {string} params.dbFullName - Database full name
|
* @param {string} params.dbFullName - Database full name
|
||||||
* @param {string} params.tableName - Table name
|
* @param {string} params.tableName - Table name
|
||||||
* @param {*} params.data - Data to add
|
* @param {*} params.data - Data to add
|
||||||
* @param {DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {import("@/package-shared/types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||||
* @param {string} params.identifierColumnName - Update row identifier column name
|
* @param {string} params.identifierColumnName - Update row identifier column name
|
||||||
* @param {string | number} params.identifierValue - Update row identifier column value
|
* @param {string | number} params.identifierValue - Update row identifier column value
|
||||||
* @param {string} params.encryptionKey - Encryption key
|
* @param {string} params.encryptionKey - Encryption key
|
||||||
|
@ -20,8 +20,8 @@ const runQuery = require("../query/utils/runQuery");
|
|||||||
* @async
|
* @async
|
||||||
*
|
*
|
||||||
* @param {Object} params - Single object passed
|
* @param {Object} params - Single object passed
|
||||||
* @param {UserDataPayload} params.payload - SQL Query
|
* @param {import("@/package-shared/types").UserDataPayload} params.payload - SQL Query
|
||||||
* @param {DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
||||||
* @param {string} [params.encryptionKey]
|
* @param {string} [params.encryptionKey]
|
||||||
* @param {string} [params.encryptionSalt]
|
* @param {string} [params.encryptionSalt]
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
|||||||
* @param {string} params.clientId
|
* @param {string} params.clientId
|
||||||
* @param {string} params.clientSecret
|
* @param {string} params.clientSecret
|
||||||
* @param {object} [params.additionalFields]
|
* @param {object} [params.additionalFields]
|
||||||
* @param {DSQL_DatabaseSchemaType} params.dbSchema
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType} params.dbSchema
|
||||||
*/
|
*/
|
||||||
async function localGithubAuth({
|
async function localGithubAuth({
|
||||||
res,
|
res,
|
||||||
|
@ -44,7 +44,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
|||||||
* @param {string} params.clientId - Google client id
|
* @param {string} params.clientId - Google client id
|
||||||
* @param {http.ServerResponse} params.response - HTTPS response object
|
* @param {http.ServerResponse} params.response - HTTPS response object
|
||||||
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
|
* @param {object} [params.additionalFields] - Additional Fields to be added to the user object
|
||||||
* @param {DSQL_DatabaseSchemaType} [params.dbSchema] - Database Schema
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database Schema
|
||||||
*
|
*
|
||||||
* @returns { Promise<FunctionReturn> }
|
* @returns { Promise<FunctionReturn> }
|
||||||
*/
|
*/
|
||||||
|
@ -74,7 +74,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
|||||||
* res: http.ServerResponse,
|
* res: http.ServerResponse,
|
||||||
* supEmail?: string | null,
|
* supEmail?: string | null,
|
||||||
* additionalFields?: object,
|
* additionalFields?: object,
|
||||||
* dbSchema: DSQL_DatabaseSchemaType | undefined
|
* dbSchema: import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined
|
||||||
* }} params - function parameters inside an object
|
* }} params - function parameters inside an object
|
||||||
*
|
*
|
||||||
* @returns {Promise<FunctionReturn>} - Response object
|
* @returns {Promise<FunctionReturn>} - Response object
|
||||||
|
@ -17,7 +17,7 @@ const updateDbEntry = require("../query/utils/updateDbEntry");
|
|||||||
*
|
*
|
||||||
* @param {Object} params - Single object passed
|
* @param {Object} params - Single object passed
|
||||||
* @param {*} params.payload - SQL Query
|
* @param {*} params.payload - SQL Query
|
||||||
* @param {DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
* @param {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
||||||
*
|
*
|
||||||
* @returns { Promise<LocalPostReturn> } - Return Object
|
* @returns { Promise<LocalPostReturn> } - Return Object
|
||||||
*/
|
*/
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {string} DSQL_DatabaseFullName - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_DatabaseSchemaType
|
|
||||||
* @property {string} dbName - Database Full name with spaces => "New Database"
|
|
||||||
* @property {string} dbSlug - Database Slug => "new_database"
|
|
||||||
* @property {string} dbFullName - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
|
||||||
* @property {string} [dbDescription] - Database brief description
|
|
||||||
* @property {string} [dbImage] - Database image - Defaults to "/images/default.png"
|
|
||||||
* @property {DSQL_TableSchemaType[]} tables - List of database tables
|
|
||||||
* @property {DSQL_ChildrenDatabaseObject[]} [childrenDatabases] - List of children databases for current database which is parent
|
|
||||||
* @property {boolean} [childDatabase] - If current database is a child of a different parent database
|
|
||||||
* @property {string} [childDatabaseDbFullName] - Parent database full name => "datasquirel_user_7_new_database"
|
|
||||||
* @property {boolean} [updateData] - Should the child database data update when the parent database data is updated?
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_ChildrenDatabaseObject
|
|
||||||
* @property {string} dbFullName - Database Full name => "datasquirel_user_4_db_name"
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_TableSchemaType
|
|
||||||
* @property {string} tableName - Table slug (blog_posts)
|
|
||||||
* @property {string} tableFullName - Table full name with spaces => "Blog Posts"
|
|
||||||
* @property {string} [tableDescription] - Brief description of table
|
|
||||||
* @property {DSQL_FieldSchemaType[]} fields - List of table Fields
|
|
||||||
* @property {DSQL_IndexSchemaType[]} [indexes] - List of table indexes, if available
|
|
||||||
* @property {DSQL_ChildrenTablesType[]} [childrenTables] - List of children tables
|
|
||||||
* @property {boolean} [childTable] -If current table is a child clone
|
|
||||||
* @property {boolean} [updateData] -If the current table data updates with the parent table
|
|
||||||
* @property {string} [childTableName] - Table slug of parent table => "blog_posts"
|
|
||||||
* @property {string} [childTableDbFullName] - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
|
||||||
* @property {string} [tableNameOld] - Old table name, incase of renaming table
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_ChildrenTablesType
|
|
||||||
* @property {string} dbNameFull - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
|
||||||
* @property {string} tableName - Table slug => "blog_posts"
|
|
||||||
* @property {string} [tableNameFull]
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_FieldSchemaType
|
|
||||||
* @property {string} [fieldName] - Field Name(slug) => "long_description"
|
|
||||||
* @property {string} [originName] - Field origin name(optional)
|
|
||||||
* @property {boolean} [updatedField] - Has this field been renamed?
|
|
||||||
* @property {string} [dataType] - Field Data type => "BIGIN" | "LONGTEXT" | "VARCHAR(***)" | ...
|
|
||||||
* @property {boolean} [nullValue] - Is this a null value or not?
|
|
||||||
* @property {boolean} [notNullValue] - Is this NOT a null value?
|
|
||||||
* @property {boolean} [primaryKey] - Is this the primary key for table?
|
|
||||||
* @property {boolean} [encrypted] - Is this field value encrypted?
|
|
||||||
* @property {boolean} [autoIncrement] - Does this table primary key increment automatically?
|
|
||||||
* @property {string|number} [defaultValue] - Value of field by default
|
|
||||||
* @property {string} [defaultValueLiteral] - SQL key word which generates value automatically => "CURRENT_TIMESTAMP"
|
|
||||||
* @property {DSQL_ForeignKeyType} [foreignKey] - Field foreign key reference object
|
|
||||||
* @property {boolean} [richText] - Rich text field
|
|
||||||
* @property {boolean} [json]
|
|
||||||
* @property {boolean} [yaml]
|
|
||||||
* @property {boolean} [html]
|
|
||||||
* @property {boolean} [css]
|
|
||||||
* @property {boolean} [javascript]
|
|
||||||
* @property {boolean} [shell]
|
|
||||||
* @property {boolean} [newTempField]
|
|
||||||
* @property {boolean} [defaultField]
|
|
||||||
* @property {boolean} [plainText]
|
|
||||||
* @property {boolean} [unique]
|
|
||||||
* @property {string} [pattern]
|
|
||||||
* @property {string} [patternFlags]
|
|
||||||
* @property {string} [onUpdate]
|
|
||||||
* @property {string} [onUpdateLiteral]
|
|
||||||
* @property {string} [onDelete]
|
|
||||||
* @property {string} [onDeleteLiteral]
|
|
||||||
* @property {string[]} [cssFiles]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_ForeignKeyType
|
|
||||||
* @property {string} [foreignKeyName] - Unique Name of foreign key
|
|
||||||
* @property {string} [destinationTableName] - Reference table name(slug) => "blog_posts"
|
|
||||||
* @property {string} [destinationTableColumnName] - Reference column name(slug) => "id"
|
|
||||||
* @property {string} [destinationTableColumnType] - Reference table field type => "BIGINT" | "VARCHAR(***)" | ...
|
|
||||||
* @property {boolean} [cascadeDelete] - Does the reference table entry delete when this key is deleted?
|
|
||||||
* @property {boolean} [cascadeUpdate] - Does the reference table entry update when this key is updated?
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_IndexSchemaType
|
|
||||||
* @property {string} [indexName] - Unique Name of index => "blog_text_index"
|
|
||||||
* @property {string} [indexType] - "regular" or "fullText"
|
|
||||||
* @property {DSQL_IndexTableFieldType[]} [indexTableFields] - List of Index table fields
|
|
||||||
* @property {string} [alias] - List of Index table fields
|
|
||||||
* @property {boolean} [newTempIndex]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_IndexTableFieldType
|
|
||||||
* @property {string} value - Table Field Name
|
|
||||||
* @property {string} dataType - Table Field data type "VARCHAR(***)" | "BIGINT" | ...
|
|
||||||
*/
|
|
@ -1,37 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
const http = require("http");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {http.IncomingMessage} Request
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {http.ServerResponse} Response
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {{
|
|
||||||
* imageBase64: string,
|
|
||||||
* imageBase64Full: string,
|
|
||||||
* imageName: string,
|
|
||||||
* imageSize: number,
|
|
||||||
* }} ImageInputFileToBase64FunctionReturn
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} GetReqQueryObject
|
|
||||||
* @property {string} db
|
|
||||||
* @property {string} query
|
|
||||||
* @property {string} [queryValues]
|
|
||||||
* @property {string} [tableName]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {(param0: SerializeQueryParams) => string} SerializeQueryFnType
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} SerializeQueryParams
|
|
||||||
* @property {any} query
|
|
||||||
*/
|
|
317
package-shared/types/index.d.ts
vendored
Normal file
317
package-shared/types/index.d.ts
vendored
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
import http from "http";
|
||||||
|
|
||||||
|
type DSQL_DatabaseFullName = string;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_DatabaseSchemaType {
|
||||||
|
dbName: string;
|
||||||
|
dbSlug: string;
|
||||||
|
dbFullName: string;
|
||||||
|
dbDescription?: string;
|
||||||
|
dbImage?: string;
|
||||||
|
tables: DSQL_TableSchemaType[];
|
||||||
|
childrenDatabases?: DSQL_ChildrenDatabaseObject[];
|
||||||
|
childDatabase?: boolean;
|
||||||
|
childDatabaseDbFullName?: string;
|
||||||
|
updateData?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DSQL_ChildrenDatabaseObject {
|
||||||
|
dbFullName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_TableSchemaType {
|
||||||
|
tableName: string;
|
||||||
|
tableFullName: string;
|
||||||
|
tableDescription?: string;
|
||||||
|
fields: DSQL_FieldSchemaType[];
|
||||||
|
indexes?: DSQL_IndexSchemaType[];
|
||||||
|
childrenTables?: DSQL_ChildrenTablesType[];
|
||||||
|
childTable?: boolean;
|
||||||
|
updateData?: boolean;
|
||||||
|
childTableName?: string;
|
||||||
|
childTableDbFullName?: string;
|
||||||
|
tableNameOld?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DSQL_ChildrenTablesType {
|
||||||
|
dbNameFull: string;
|
||||||
|
tableName: string;
|
||||||
|
tableNameFull?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_FieldSchemaType {
|
||||||
|
fieldName?: string;
|
||||||
|
originName?: string;
|
||||||
|
updatedField?: boolean;
|
||||||
|
dataType?: string;
|
||||||
|
nullValue?: boolean;
|
||||||
|
notNullValue?: boolean;
|
||||||
|
primaryKey?: boolean;
|
||||||
|
encrypted?: boolean;
|
||||||
|
autoIncrement?: boolean;
|
||||||
|
defaultValue?: string | number;
|
||||||
|
defaultValueLiteral?: string;
|
||||||
|
foreignKey?: DSQL_ForeignKeyType;
|
||||||
|
richText?: boolean;
|
||||||
|
json?: boolean;
|
||||||
|
yaml?: boolean;
|
||||||
|
html?: boolean;
|
||||||
|
css?: boolean;
|
||||||
|
javascript?: boolean;
|
||||||
|
shell?: boolean;
|
||||||
|
newTempField?: boolean;
|
||||||
|
defaultField?: boolean;
|
||||||
|
plainText?: boolean;
|
||||||
|
unique?: boolean;
|
||||||
|
pattern?: string;
|
||||||
|
patternFlags?: string;
|
||||||
|
onUpdate?: string;
|
||||||
|
onUpdateLiteral?: string;
|
||||||
|
onDelete?: string;
|
||||||
|
onDeleteLiteral?: string;
|
||||||
|
cssFiles?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DSQL_ForeignKeyType {
|
||||||
|
foreignKeyName?: string;
|
||||||
|
destinationTableName?: string;
|
||||||
|
destinationTableColumnName?: string;
|
||||||
|
destinationTableColumnType?: string;
|
||||||
|
cascadeDelete?: boolean;
|
||||||
|
cascadeUpdate?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_IndexSchemaType {
|
||||||
|
indexName?: string;
|
||||||
|
indexType?: string;
|
||||||
|
indexTableFields?: DSQL_IndexTableFieldType[];
|
||||||
|
alias?: string;
|
||||||
|
newTempIndex?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DSQL_IndexTableFieldType {
|
||||||
|
value: string;
|
||||||
|
dataType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DSQL_MYSQL_SHOW_INDEXES_Type {
|
||||||
|
Key_name: string;
|
||||||
|
Table: string;
|
||||||
|
Column_name: string;
|
||||||
|
Collation: string;
|
||||||
|
Index_type: string;
|
||||||
|
Cardinality: string;
|
||||||
|
Index_comment: string;
|
||||||
|
Comment: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_MYSQL_SHOW_COLUMNS_Type {
|
||||||
|
Field: string;
|
||||||
|
Type: string;
|
||||||
|
Null: string;
|
||||||
|
Key: string;
|
||||||
|
Default: string;
|
||||||
|
Extra: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_MYSQL_FOREIGN_KEYS_Type {
|
||||||
|
CONSTRAINT_NAME: string;
|
||||||
|
CONSTRAINT_SCHEMA: string;
|
||||||
|
TABLE_NAME: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
interface DSQL_MYSQL_user_databases_Type {
|
||||||
|
user_id: number;
|
||||||
|
db_full_name: string;
|
||||||
|
db_name: string;
|
||||||
|
db_slug: string;
|
||||||
|
db_image: string;
|
||||||
|
db_description: string;
|
||||||
|
active_clone: number;
|
||||||
|
active_clone_parent_db: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PackageUserLoginRequestBody {
|
||||||
|
encryptionKey: string;
|
||||||
|
payload: any;
|
||||||
|
database: string;
|
||||||
|
additionalFields?: string[];
|
||||||
|
email_login?: boolean;
|
||||||
|
email_login_code?: string;
|
||||||
|
email_login_field?: string;
|
||||||
|
token?: boolean;
|
||||||
|
social?: boolean;
|
||||||
|
dbSchema?: DSQL_DatabaseSchemaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PackageUserLoginLocalBody {
|
||||||
|
payload: any;
|
||||||
|
additionalFields?: string[];
|
||||||
|
email_login?: boolean;
|
||||||
|
email_login_code?: string;
|
||||||
|
email_login_field?: string;
|
||||||
|
token?: boolean;
|
||||||
|
social?: boolean;
|
||||||
|
dbSchema?: DSQL_DatabaseSchemaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Request = http.IncomingMessage;
|
||||||
|
|
||||||
|
type Response = http.ServerResponse;
|
||||||
|
|
||||||
|
type ImageInputFileToBase64FunctionReturn = {
|
||||||
|
imageBase64: string;
|
||||||
|
imageBase64Full: string;
|
||||||
|
imageName: string;
|
||||||
|
imageSize: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface GetReqQueryObject {
|
||||||
|
db: string;
|
||||||
|
query: string;
|
||||||
|
queryValues?: string;
|
||||||
|
tableName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type SerializeQueryFnType = (param0: SerializeQueryParams) => string;
|
||||||
|
|
||||||
|
interface SerializeQueryParams {
|
||||||
|
query: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
interface DATASQUIREL_LoggedInUser {
|
||||||
|
id?: number;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
phone?: string;
|
||||||
|
user_type?: string;
|
||||||
|
username?: string;
|
||||||
|
password: string;
|
||||||
|
image?: string;
|
||||||
|
image_thumbnail?: string;
|
||||||
|
address?: string;
|
||||||
|
city?: string;
|
||||||
|
state?: string;
|
||||||
|
country?: string;
|
||||||
|
zip_code?: string;
|
||||||
|
social_login?: number;
|
||||||
|
social_platform?: string;
|
||||||
|
social_id?: string;
|
||||||
|
more_user_data?: string;
|
||||||
|
verification_status?: number;
|
||||||
|
loan_officer_id?: number;
|
||||||
|
is_admin?: number;
|
||||||
|
admin_level?: number;
|
||||||
|
admin_permissions?: string;
|
||||||
|
uuid: string;
|
||||||
|
temp_login_code?: string;
|
||||||
|
date_created?: string;
|
||||||
|
date_created_code?: number;
|
||||||
|
date_created_timestamp?: string;
|
||||||
|
date_updated?: string;
|
||||||
|
date_updated_code?: number;
|
||||||
|
date_updated_timestamp?: string;
|
||||||
|
csrf_k?: string;
|
||||||
|
logged_in_status?: boolean;
|
||||||
|
date?: number;
|
||||||
|
more_data?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AuthenticatedUser {
|
||||||
|
success: boolean;
|
||||||
|
payload: DATASQUIREL_LoggedInUser | null;
|
||||||
|
msg?: string;
|
||||||
|
userId?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SuccessUserObject {
|
||||||
|
id: number;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AddUserFunctionReturn {
|
||||||
|
success: boolean;
|
||||||
|
payload?: SuccessUserObject | null;
|
||||||
|
msg?: string;
|
||||||
|
sqlResult?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GoogleIdentityPromptNotification {
|
||||||
|
getMomentType: () => string;
|
||||||
|
getDismissedReason: () => string;
|
||||||
|
getNotDisplayedReason: () => string;
|
||||||
|
getSkippedReason: () => string;
|
||||||
|
isDismissedMoment: () => boolean;
|
||||||
|
isDisplayMoment: () => boolean;
|
||||||
|
isDisplayed: () => boolean;
|
||||||
|
isNotDisplayed: () => boolean;
|
||||||
|
isSkippedMoment: () => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserDataPayload {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
username: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetUserFunctionReturn {
|
||||||
|
success: boolean;
|
||||||
|
payload: {
|
||||||
|
id: number;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
username: string;
|
||||||
|
email: string;
|
||||||
|
phone: string;
|
||||||
|
social_id: [string];
|
||||||
|
image: string;
|
||||||
|
image_thumbnail: string;
|
||||||
|
verification_status: [number];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ReauthUserFunctionReturn {
|
||||||
|
success: boolean;
|
||||||
|
payload: DATASQUIREL_LoggedInUser | null;
|
||||||
|
msg?: string;
|
||||||
|
userId?: number;
|
||||||
|
token?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UpdateUserFunctionReturn {
|
||||||
|
success: boolean;
|
||||||
|
payload?: Object[] | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GetReturn {
|
||||||
|
success: boolean;
|
||||||
|
payload?: any;
|
||||||
|
msg?: string;
|
||||||
|
error?: string;
|
||||||
|
schema?: DSQL_TableSchemaType;
|
||||||
|
}
|
355
package-shared/types/index.js
Normal file
355
package-shared/types/index.js
Normal file
@ -0,0 +1,355 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {string} DSQL_DatabaseFullName - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_DatabaseSchemaType
|
||||||
|
* @property {string} dbName - Database Full name with spaces => "New Database"
|
||||||
|
* @property {string} dbSlug - Database Slug => "new_database"
|
||||||
|
* @property {string} dbFullName - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
||||||
|
* @property {string} [dbDescription] - Database brief description
|
||||||
|
* @property {string} [dbImage] - Database image - Defaults to "/images/default.png"
|
||||||
|
* @property {DSQL_TableSchemaType[]} tables - List of database tables
|
||||||
|
* @property {DSQL_ChildrenDatabaseObject[]} [childrenDatabases] - List of children databases for current database which is parent
|
||||||
|
* @property {boolean} [childDatabase] - If current database is a child of a different parent database
|
||||||
|
* @property {string} [childDatabaseDbFullName] - Parent database full name => "datasquirel_user_7_new_database"
|
||||||
|
* @property {boolean} [updateData] - Should the child database data update when the parent database data is updated?
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_ChildrenDatabaseObject
|
||||||
|
* @property {string} dbFullName - Database Full name => "datasquirel_user_4_db_name"
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_TableSchemaType
|
||||||
|
* @property {string} tableName - Table slug (blog_posts)
|
||||||
|
* @property {string} tableFullName - Table full name with spaces => "Blog Posts"
|
||||||
|
* @property {string} [tableDescription] - Brief description of table
|
||||||
|
* @property {DSQL_FieldSchemaType[]} fields - List of table Fields
|
||||||
|
* @property {DSQL_IndexSchemaType[]} [indexes] - List of table indexes, if available
|
||||||
|
* @property {DSQL_ChildrenTablesType[]} [childrenTables] - List of children tables
|
||||||
|
* @property {boolean} [childTable] -If current table is a child clone
|
||||||
|
* @property {boolean} [updateData] -If the current table data updates with the parent table
|
||||||
|
* @property {string} [childTableName] - Table slug of parent table => "blog_posts"
|
||||||
|
* @property {string} [childTableDbFullName] - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
||||||
|
* @property {string} [tableNameOld] - Old table name, incase of renaming table
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_ChildrenTablesType
|
||||||
|
* @property {string} dbNameFull - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
||||||
|
* @property {string} tableName - Table slug => "blog_posts"
|
||||||
|
* @property {string} [tableNameFull]
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_FieldSchemaType
|
||||||
|
* @property {string} [fieldName] - Field Name(slug) => "long_description"
|
||||||
|
* @property {string} [originName] - Field origin name(optional)
|
||||||
|
* @property {boolean} [updatedField] - Has this field been renamed?
|
||||||
|
* @property {string} [dataType] - Field Data type => "BIGIN" | "LONGTEXT" | "VARCHAR(***)" | ...
|
||||||
|
* @property {boolean} [nullValue] - Is this a null value or not?
|
||||||
|
* @property {boolean} [notNullValue] - Is this NOT a null value?
|
||||||
|
* @property {boolean} [primaryKey] - Is this the primary key for table?
|
||||||
|
* @property {boolean} [encrypted] - Is this field value encrypted?
|
||||||
|
* @property {boolean} [autoIncrement] - Does this table primary key increment automatically?
|
||||||
|
* @property {string|number} [defaultValue] - Value of field by default
|
||||||
|
* @property {string} [defaultValueLiteral] - SQL key word which generates value automatically => "CURRENT_TIMESTAMP"
|
||||||
|
* @property {DSQL_ForeignKeyType} [foreignKey] - Field foreign key reference object
|
||||||
|
* @property {boolean} [richText] - Rich text field
|
||||||
|
* @property {boolean} [json]
|
||||||
|
* @property {boolean} [yaml]
|
||||||
|
* @property {boolean} [html]
|
||||||
|
* @property {boolean} [css]
|
||||||
|
* @property {boolean} [javascript]
|
||||||
|
* @property {boolean} [shell]
|
||||||
|
* @property {boolean} [newTempField]
|
||||||
|
* @property {boolean} [defaultField]
|
||||||
|
* @property {boolean} [plainText]
|
||||||
|
* @property {boolean} [unique]
|
||||||
|
* @property {string} [pattern]
|
||||||
|
* @property {string} [patternFlags]
|
||||||
|
* @property {string} [onUpdate]
|
||||||
|
* @property {string} [onUpdateLiteral]
|
||||||
|
* @property {string} [onDelete]
|
||||||
|
* @property {string} [onDeleteLiteral]
|
||||||
|
* @property {string[]} [cssFiles]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_ForeignKeyType
|
||||||
|
* @property {string} [foreignKeyName] - Unique Name of foreign key
|
||||||
|
* @property {string} [destinationTableName] - Reference table name(slug) => "blog_posts"
|
||||||
|
* @property {string} [destinationTableColumnName] - Reference column name(slug) => "id"
|
||||||
|
* @property {string} [destinationTableColumnType] - Reference table field type => "BIGINT" | "VARCHAR(***)" | ...
|
||||||
|
* @property {boolean} [cascadeDelete] - Does the reference table entry delete when this key is deleted?
|
||||||
|
* @property {boolean} [cascadeUpdate] - Does the reference table entry update when this key is updated?
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_IndexSchemaType
|
||||||
|
* @property {string} [indexName] - Unique Name of index => "blog_text_index"
|
||||||
|
* @property {string} [indexType] - "regular" or "fullText"
|
||||||
|
* @property {DSQL_IndexTableFieldType[]} [indexTableFields] - List of Index table fields
|
||||||
|
* @property {string} [alias] - List of Index table fields
|
||||||
|
* @property {boolean} [newTempIndex]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_IndexTableFieldType
|
||||||
|
* @property {string} value - Table Field Name
|
||||||
|
* @property {string} dataType - Table Field data type "VARCHAR(***)" | "BIGINT" | ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_MYSQL_SHOW_INDEXES_Type
|
||||||
|
* @property {string} Key_name - MYSQL Index Name
|
||||||
|
* @property {string} Table - Table Name(slug)
|
||||||
|
* @property {string} Column_name
|
||||||
|
* @property {string} Collation
|
||||||
|
* @property {string} Index_type - "FULL_TEXT" | ...
|
||||||
|
* @property {string} Cardinality
|
||||||
|
* @property {string} Index_comment
|
||||||
|
* @property {string} Comment
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_MYSQL_SHOW_COLUMNS_Type
|
||||||
|
* @property {string} Field - Field Name as represented in MSQL database
|
||||||
|
* @property {string} Type - varchar(***) | tinyint | bigint | ...
|
||||||
|
* @property {string} Null
|
||||||
|
* @property {string} Key
|
||||||
|
* @property {string} Default
|
||||||
|
* @property {string} Extra
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_MYSQL_FOREIGN_KEYS_Type
|
||||||
|
* @property {string} CONSTRAINT_NAME - Constraint Name => "PRIMARY" | "MUL" | null | ...
|
||||||
|
* @property {string} CONSTRAINT_SCHEMA - Database name
|
||||||
|
* @property {string} TABLE_NAME - Table name
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DSQL_MYSQL_user_databases_Type
|
||||||
|
* @property {number} user_id - User Id
|
||||||
|
* @property {string} db_full_name - Database full name => eg. (dataasquirel_user_2_new_database)
|
||||||
|
* @property {string} db_name - Database name with spaces => eg. (New Database)
|
||||||
|
* @property {string} db_slug - Database slug => eg. (new_database)
|
||||||
|
* @property {string} db_image - Database image path
|
||||||
|
* @property {string} db_description - Database description
|
||||||
|
* @property {number} active_clone - is Database active clone => 0 or 1
|
||||||
|
* @property {string} active_clone_parent_db - Database parent db full name => eg. "datasquirel_user_7_wexculture"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} PackageUserLoginRequestBody
|
||||||
|
* @property {string} encryptionKey
|
||||||
|
* @property {any} payload
|
||||||
|
* @property {string} database
|
||||||
|
* @property {string[]} [additionalFields]
|
||||||
|
* @property {boolean} [email_login]
|
||||||
|
* @property {string} [email_login_code]
|
||||||
|
* @property {string} [email_login_field]
|
||||||
|
* @property {boolean} [token]
|
||||||
|
* @property {boolean} [social]
|
||||||
|
* @property {DSQL_DatabaseSchemaType} [dbSchema]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} PackageUserLoginLocalBody
|
||||||
|
* @property {any} payload
|
||||||
|
* @property {string[]} [additionalFields]
|
||||||
|
* @property {boolean} [email_login]
|
||||||
|
* @property {string} [email_login_code]
|
||||||
|
* @property {string} [email_login_field]
|
||||||
|
* @property {boolean} [token]
|
||||||
|
* @property {boolean} [social]
|
||||||
|
* @property {DSQL_DatabaseSchemaType} [dbSchema]
|
||||||
|
*/
|
||||||
|
|
||||||
|
const http = require("http");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {http.IncomingMessage} Request
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {http.ServerResponse} Response
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* imageBase64: string,
|
||||||
|
* imageBase64Full: string,
|
||||||
|
* imageName: string,
|
||||||
|
* imageSize: number,
|
||||||
|
* }} ImageInputFileToBase64FunctionReturn
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} GetReqQueryObject
|
||||||
|
* @property {string} db
|
||||||
|
* @property {string} query
|
||||||
|
* @property {string} [queryValues]
|
||||||
|
* @property {string} [tableName]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {(param0: SerializeQueryParams) => string} SerializeQueryFnType
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} SerializeQueryParams
|
||||||
|
* @property {any} query
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} DATASQUIREL_LoggedInUser
|
||||||
|
* @property {number} [id]
|
||||||
|
* @property {string} first_name
|
||||||
|
* @property {string} last_name
|
||||||
|
* @property {string} email
|
||||||
|
* @property {string} [phone]
|
||||||
|
* @property {string} [user_type]
|
||||||
|
* @property {string} [username]
|
||||||
|
* @property {string} password
|
||||||
|
* @property {string} [image]
|
||||||
|
* @property {string} [image_thumbnail]
|
||||||
|
* @property {string} [address]
|
||||||
|
* @property {string} [city]
|
||||||
|
* @property {string} [state]
|
||||||
|
* @property {string} [country]
|
||||||
|
* @property {string} [zip_code]
|
||||||
|
* @property {number} [social_login]
|
||||||
|
* @property {string?} [social_platform]
|
||||||
|
* @property {string?} [social_id]
|
||||||
|
* @property {string} [more_user_data]
|
||||||
|
* @property {number} [verification_status]
|
||||||
|
* @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} [csrf_k] - CSRF key
|
||||||
|
* @property {boolean} [logged_in_status]
|
||||||
|
* @property {number} [date]
|
||||||
|
* @property {any} [more_data]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} AuthenticatedUser
|
||||||
|
* @property {boolean} success - Did the function run successfully?
|
||||||
|
* @property {DATASQUIREL_LoggedInUser | null} payload - Payload of the response
|
||||||
|
* @property {string} [msg] - An optional message
|
||||||
|
* @property {number} [userId] - An optional message
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} SuccessUserObject
|
||||||
|
* @property {number} id
|
||||||
|
* @property {string} first_name
|
||||||
|
* @property {string} last_name
|
||||||
|
* @property {string} email
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} AddUserFunctionReturn
|
||||||
|
* @property {boolean} success - Did the function run successfully?
|
||||||
|
* @property {SuccessUserObject | null} [payload] - Payload
|
||||||
|
* @property {string} [msg]
|
||||||
|
* @property {any} [sqlResult]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} GoogleIdentityPromptNotification
|
||||||
|
* @property {function(): string} getMomentType - Notification moment type
|
||||||
|
* @property {function(): string} getDismissedReason - Notification get Dismissed Reason
|
||||||
|
* @property {function(): string} getNotDisplayedReason - Notification get Not Displayed Reason
|
||||||
|
* @property {function(): string} getSkippedReason - Notification get Skipped Reason
|
||||||
|
* @property {function(): boolean} isDismissedMoment - Notification is Dismissed Moment
|
||||||
|
* @property {function(): boolean} isDisplayMoment - Notification is Display Moment
|
||||||
|
* @property {function(): boolean} isDisplayed - Notification is Displayed
|
||||||
|
* @property {function(): boolean} isNotDisplayed - Notification is Not Displayed
|
||||||
|
* @property {function(): boolean} isSkippedMoment - Notification is Skipped Moment
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} UserDataPayload
|
||||||
|
* @property {string} first_name - First Name *Required
|
||||||
|
* @property {string} last_name - Last Name *Required
|
||||||
|
* @property {string} email - Email *Required
|
||||||
|
* @property {string} password - Password *Required
|
||||||
|
* @property {string?} username - Username (Optional)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} GetUserFunctionReturn
|
||||||
|
* @property {boolean} success - Did the function run successfully?
|
||||||
|
* @property {{
|
||||||
|
* id: number,
|
||||||
|
* first_name: string,
|
||||||
|
* last_name: string,
|
||||||
|
* username: string,
|
||||||
|
* email: string,
|
||||||
|
* phone: string,
|
||||||
|
* social_id: [string],
|
||||||
|
* image: string,
|
||||||
|
* image_thumbnail: string,
|
||||||
|
* verification_status: [number],
|
||||||
|
* }} payload - Payload
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} ReauthUserFunctionReturn
|
||||||
|
* @property {boolean} success - Did the function run successfully?
|
||||||
|
* @property {DATASQUIREL_LoggedInUser | null} payload - Payload
|
||||||
|
* @property {string} [msg] - Response Message
|
||||||
|
* @property {number} [userId] - user ID
|
||||||
|
* @property {string} [token] - new Token
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} UpdateUserFunctionReturn
|
||||||
|
* @property {boolean} success - Did the function run successfully?
|
||||||
|
* @property {(Object[]|string)} [payload=[]] - Payload
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} GetReturn
|
||||||
|
* @property {boolean} success - Did the function run successfully?
|
||||||
|
* @property {*} [payload] - GET request results
|
||||||
|
* @property {string} [msg] - Message
|
||||||
|
* @property {string} [error] - Error Message
|
||||||
|
* @property {DSQL_TableSchemaType} [schema] - Error Message
|
||||||
|
*/
|
@ -1,48 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_MYSQL_SHOW_INDEXES_Type
|
|
||||||
* @property {string} Key_name - MYSQL Index Name
|
|
||||||
* @property {string} Table - Table Name(slug)
|
|
||||||
* @property {string} Column_name
|
|
||||||
* @property {string} Collation
|
|
||||||
* @property {string} Index_type - "FULL_TEXT" | ...
|
|
||||||
* @property {string} Cardinality
|
|
||||||
* @property {string} Index_comment
|
|
||||||
* @property {string} Comment
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_MYSQL_SHOW_COLUMNS_Type
|
|
||||||
* @property {string} Field - Field Name as represented in MSQL database
|
|
||||||
* @property {string} Type - varchar(***) | tinyint | bigint | ...
|
|
||||||
* @property {string} Null
|
|
||||||
* @property {string} Key
|
|
||||||
* @property {string} Default
|
|
||||||
* @property {string} Extra
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_MYSQL_FOREIGN_KEYS_Type
|
|
||||||
* @property {string} CONSTRAINT_NAME - Constraint Name => "PRIMARY" | "MUL" | null | ...
|
|
||||||
* @property {string} CONSTRAINT_SCHEMA - Database name
|
|
||||||
* @property {string} TABLE_NAME - Table name
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DSQL_MYSQL_user_databases_Type
|
|
||||||
* @property {number} user_id - User Id
|
|
||||||
* @property {string} db_full_name - Database full name => eg. (dataasquirel_user_2_new_database)
|
|
||||||
* @property {string} db_name - Database name with spaces => eg. (New Database)
|
|
||||||
* @property {string} db_slug - Database slug => eg. (new_database)
|
|
||||||
* @property {string} db_image - Database image path
|
|
||||||
* @property {string} db_description - Database description
|
|
||||||
* @property {number} active_clone - is Database active clone => 0 or 1
|
|
||||||
* @property {string} active_clone_parent_db - Database parent db full name => eg. "datasquirel_user_7_wexculture"
|
|
||||||
*/
|
|
@ -1,38 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} PackageUserLoginRequestBody
|
|
||||||
* @property {string} encryptionKey
|
|
||||||
* @property {any} payload
|
|
||||||
* @property {string} database
|
|
||||||
* @property {string[]} [additionalFields]
|
|
||||||
* @property {boolean} [email_login]
|
|
||||||
* @property {string} [email_login_code]
|
|
||||||
* @property {string} [email_login_field]
|
|
||||||
* @property {boolean} [token]
|
|
||||||
* @property {boolean} [social]
|
|
||||||
* @property {DSQL_DatabaseSchemaType} [dbSchema]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} PackageUserLoginLocalBody
|
|
||||||
* @property {any} payload
|
|
||||||
* @property {string[]} [additionalFields]
|
|
||||||
* @property {boolean} [email_login]
|
|
||||||
* @property {string} [email_login_code]
|
|
||||||
* @property {string} [email_login_field]
|
|
||||||
* @property {boolean} [token]
|
|
||||||
* @property {boolean} [social]
|
|
||||||
* @property {DSQL_DatabaseSchemaType} [dbSchema]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} GetReturn
|
|
||||||
* @property {boolean} success - Did the function run successfully?
|
|
||||||
* @property {*} [payload] - GET request results
|
|
||||||
* @property {string} [msg] - Message
|
|
||||||
* @property {string} [error] - Error Message
|
|
||||||
* @property {DSQL_TableSchemaType} [schema] - Error Message
|
|
||||||
*
|
|
||||||
* @exports GetReturn
|
|
||||||
*/
|
|
@ -1,119 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} DATASQUIREL_LoggedInUser
|
|
||||||
* @property {number} [id]
|
|
||||||
* @property {string} first_name
|
|
||||||
* @property {string} last_name
|
|
||||||
* @property {string} email
|
|
||||||
* @property {string} [phone]
|
|
||||||
* @property {string} [user_type]
|
|
||||||
* @property {string} [username]
|
|
||||||
* @property {string} password
|
|
||||||
* @property {string} [image]
|
|
||||||
* @property {string} [image_thumbnail]
|
|
||||||
* @property {string} [address]
|
|
||||||
* @property {string} [city]
|
|
||||||
* @property {string} [state]
|
|
||||||
* @property {string} [country]
|
|
||||||
* @property {string} [zip_code]
|
|
||||||
* @property {number} [social_login]
|
|
||||||
* @property {string?} [social_platform]
|
|
||||||
* @property {string?} [social_id]
|
|
||||||
* @property {string} [more_user_data]
|
|
||||||
* @property {number} [verification_status]
|
|
||||||
* @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} [csrf_k] - CSRF key
|
|
||||||
* @property {boolean} [logged_in_status]
|
|
||||||
* @property {number} [date]
|
|
||||||
* @property {any} [more_data]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} AuthenticatedUser
|
|
||||||
* @property {boolean} success - Did the function run successfully?
|
|
||||||
* @property {DATASQUIREL_LoggedInUser | null} payload - Payload of the response
|
|
||||||
* @property {string} [msg] - An optional message
|
|
||||||
* @property {number} [userId] - An optional message
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} SuccessUserObject
|
|
||||||
* @property {number} id
|
|
||||||
* @property {string} first_name
|
|
||||||
* @property {string} last_name
|
|
||||||
* @property {string} email
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} AddUserFunctionReturn
|
|
||||||
* @property {boolean} success - Did the function run successfully?
|
|
||||||
* @property {SuccessUserObject | null} [payload] - Payload
|
|
||||||
* @property {string} [msg]
|
|
||||||
* @property {any} [sqlResult]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} GoogleIdentityPromptNotification
|
|
||||||
* @property {function(): string} getMomentType - Notification moment type
|
|
||||||
* @property {function(): string} getDismissedReason - Notification get Dismissed Reason
|
|
||||||
* @property {function(): string} getNotDisplayedReason - Notification get Not Displayed Reason
|
|
||||||
* @property {function(): string} getSkippedReason - Notification get Skipped Reason
|
|
||||||
* @property {function(): boolean} isDismissedMoment - Notification is Dismissed Moment
|
|
||||||
* @property {function(): boolean} isDisplayMoment - Notification is Display Moment
|
|
||||||
* @property {function(): boolean} isDisplayed - Notification is Displayed
|
|
||||||
* @property {function(): boolean} isNotDisplayed - Notification is Not Displayed
|
|
||||||
* @property {function(): boolean} isSkippedMoment - Notification is Skipped Moment
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} UserDataPayload
|
|
||||||
* @property {string} first_name - First Name *Required
|
|
||||||
* @property {string} last_name - Last Name *Required
|
|
||||||
* @property {string} email - Email *Required
|
|
||||||
* @property {string} password - Password *Required
|
|
||||||
* @property {string?} username - Username (Optional)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} GetUserFunctionReturn
|
|
||||||
* @property {boolean} success - Did the function run successfully?
|
|
||||||
* @property {{
|
|
||||||
* id: number,
|
|
||||||
* first_name: string,
|
|
||||||
* last_name: string,
|
|
||||||
* username: string,
|
|
||||||
* email: string,
|
|
||||||
* phone: string,
|
|
||||||
* social_id: [string],
|
|
||||||
* image: string,
|
|
||||||
* image_thumbnail: string,
|
|
||||||
* verification_status: [number],
|
|
||||||
* }} payload - Payload
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} ReauthUserFunctionReturn
|
|
||||||
* @property {boolean} success - Did the function run successfully?
|
|
||||||
* @property {DATASQUIREL_LoggedInUser | null} payload - Payload
|
|
||||||
* @property {string} [msg] - Response Message
|
|
||||||
* @property {number} [userId] - user ID
|
|
||||||
* @property {string} [token] - new Token
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} UpdateUserFunctionReturn
|
|
||||||
* @property {boolean} success - Did the function run successfully?
|
|
||||||
* @property {(Object[]|string)} [payload=[]] - Payload
|
|
||||||
*/
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "datasquirel",
|
"name": "datasquirel",
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"skipLibCheck": true,
|
// "skipLibCheck": true,
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
@ -18,6 +18,9 @@
|
|||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
"emitDeclarationOnly": true,
|
||||||
|
"declaration": true,
|
||||||
|
"outDir": "./dump/tsc",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"name": "next"
|
"name": "next"
|
||||||
|
@ -26,11 +26,11 @@ const localAddUser = require("../engine/user/add-user");
|
|||||||
* @param {object} props - Single object passed
|
* @param {object} props - Single object passed
|
||||||
* @param {string} props.key - FULL ACCESS API Key
|
* @param {string} props.key - FULL ACCESS API Key
|
||||||
* @param {string} props.database - Database Name
|
* @param {string} props.database - Database Name
|
||||||
* @param {UserDataPayload} props.payload - User Data Payload
|
* @param {import("@/package-shared/types").UserDataPayload} props.payload - User Data Payload
|
||||||
* @param {string} props.encryptionKey
|
* @param {string} props.encryptionKey
|
||||||
* @param {string} [props.encryptionSalt]
|
* @param {string} [props.encryptionSalt]
|
||||||
*
|
*
|
||||||
* @returns { Promise<AddUserFunctionReturn> }
|
* @returns { Promise<import("@/package-shared/types").AddUserFunctionReturn> }
|
||||||
*/
|
*/
|
||||||
async function addUser({
|
async function addUser({
|
||||||
key,
|
key,
|
||||||
@ -64,7 +64,7 @@ async function addUser({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -41,7 +41,7 @@ const loginLocalUser = require("../engine/user/login-user");
|
|||||||
* @param {string} [params.temp_code_field] - Database table field name for temporary code
|
* @param {string} [params.temp_code_field] - Database table field name for temporary code
|
||||||
* @param {boolean} [params.token] - Send access key as part of response body?
|
* @param {boolean} [params.token] - Send access key as part of response body?
|
||||||
*
|
*
|
||||||
* @returns { Promise<AuthenticatedUser>}
|
* @returns { Promise<import("@/package-shared/types").AuthenticatedUser>}
|
||||||
*/
|
*/
|
||||||
async function loginUser({
|
async function loginUser({
|
||||||
key,
|
key,
|
||||||
@ -126,7 +126,7 @@ async function loginUser({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -154,10 +154,10 @@ async function loginUser({
|
|||||||
*
|
*
|
||||||
* @description make a request to datasquirel.com
|
* @description make a request to datasquirel.com
|
||||||
*
|
*
|
||||||
* @type {{ success: boolean, payload: DATASQUIREL_LoggedInUser | null, userId?: number, msg?: string }}
|
* @type {{ success: boolean, payload: import("@/package-shared/types").DATASQUIREL_LoggedInUser | null, userId?: number, msg?: string }}
|
||||||
*/
|
*/
|
||||||
httpResponse = await new Promise((resolve, reject) => {
|
httpResponse = await new Promise((resolve, reject) => {
|
||||||
/** @type {PackageUserLoginRequestBody} */
|
/** @type {import("@/package-shared/types").PackageUserLoginRequestBody} */
|
||||||
const reqPayload = {
|
const reqPayload = {
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
payload,
|
payload,
|
||||||
|
@ -38,7 +38,7 @@ const localReauthUser = require("../engine/user/reauth-user");
|
|||||||
* @param {string[]} [params.additionalFields] - Additional Fields to be added to the user object
|
* @param {string[]} [params.additionalFields] - Additional Fields to be added to the user object
|
||||||
* @param {string} [params.token] - access token to use instead of getting from cookie header
|
* @param {string} [params.token] - access token to use instead of getting from cookie header
|
||||||
*
|
*
|
||||||
* @returns { Promise<ReauthUserFunctionReturn> }
|
* @returns { Promise<import("@/package-shared/types").ReauthUserFunctionReturn> }
|
||||||
*/
|
*/
|
||||||
async function reauthUser({
|
async function reauthUser({
|
||||||
key,
|
key,
|
||||||
@ -103,7 +103,7 @@ async function reauthUser({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -114,7 +114,7 @@ async function sendEmailCode({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -143,7 +143,7 @@ async function sendEmailCode({
|
|||||||
*
|
*
|
||||||
* @description make a request to datasquirel.com
|
* @description make a request to datasquirel.com
|
||||||
*
|
*
|
||||||
* @type {{ success: boolean, payload: DATASQUIREL_LoggedInUser | null, userId?: number, msg?: string }}
|
* @type {{ success: boolean, payload: import("@/package-shared/types").DATASQUIREL_LoggedInUser | null, userId?: number, msg?: string }}
|
||||||
*/
|
*/
|
||||||
httpResponse = await new Promise((resolve, reject) => {
|
httpResponse = await new Promise((resolve, reject) => {
|
||||||
const reqPayload = JSON.stringify({
|
const reqPayload = JSON.stringify({
|
||||||
|
@ -154,7 +154,7 @@ async function githubAuth({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -150,7 +150,7 @@ async function googleAuth({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -179,7 +179,7 @@ async function googleAuth({
|
|||||||
* Make https request
|
* Make https request
|
||||||
*
|
*
|
||||||
* @description make a request to datasquirel.com
|
* @description make a request to datasquirel.com
|
||||||
* @type {{ success: boolean, user: DATASQUIREL_LoggedInUser | null, msg?: string, dsqlUserId?: number } | null } - Https response object
|
* @type {{ success: boolean, user: import("@/package-shared/types").DATASQUIREL_LoggedInUser | null, msg?: string, dsqlUserId?: number } | null } - Https response object
|
||||||
*/
|
*/
|
||||||
httpResponse = await new Promise((resolve, reject) => {
|
httpResponse = await new Promise((resolve, reject) => {
|
||||||
const reqPayload = JSON.stringify({
|
const reqPayload = JSON.stringify({
|
||||||
|
@ -29,7 +29,7 @@ const localUpdateUser = require("../engine/user/update-user");
|
|||||||
* @param {String} params.database - Target Database
|
* @param {String} params.database - Target Database
|
||||||
* @param {{ id: number } & Object.<string, *>} params.payload - User Object: ID is required
|
* @param {{ id: number } & Object.<string, *>} params.payload - User Object: ID is required
|
||||||
*
|
*
|
||||||
* @returns { Promise<UpdateUserFunctionReturn>}
|
* @returns { Promise<import("@/package-shared/types").UpdateUserFunctionReturn>}
|
||||||
*/
|
*/
|
||||||
async function updateUser({ key, payload, database }) {
|
async function updateUser({ key, payload, database }) {
|
||||||
/**
|
/**
|
||||||
@ -57,7 +57,7 @@ async function updateUser({ key, payload, database }) {
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -30,7 +30,7 @@ const parseCookies = require("../utils/functions/parseCookies");
|
|||||||
* @param {string} params.database - Database Name
|
* @param {string} params.database - Database Name
|
||||||
* @param {string} [params.token] - access token to use instead of getting from cookie header
|
* @param {string} [params.token] - access token to use instead of getting from cookie header
|
||||||
*
|
*
|
||||||
* @returns { AuthenticatedUser }
|
* @returns { import("@/package-shared/types").AuthenticatedUser }
|
||||||
*/
|
*/
|
||||||
function userAuth({
|
function userAuth({
|
||||||
request,
|
request,
|
||||||
|
@ -27,7 +27,7 @@ const decrypt = require("../functions/decrypt");
|
|||||||
* @param {("deep" | "normal")?} [params.level] - Optional. "Deep" value indicates an extra layer of security
|
* @param {("deep" | "normal")?} [params.level] - Optional. "Deep" value indicates an extra layer of security
|
||||||
* @param {string} params.database - Database Name
|
* @param {string} params.database - Database Name
|
||||||
*
|
*
|
||||||
* @returns { DATASQUIREL_LoggedInUser | null}
|
* @returns { import("@/package-shared/types").DATASQUIREL_LoggedInUser | null}
|
||||||
*/
|
*/
|
||||||
function validateToken({ token, encryptionKey, encryptionSalt }) {
|
function validateToken({ token, encryptionKey, encryptionSalt }) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
/** @type {import("@/package-shared/types/general.td").SerializeQueryFnType} */
|
/** @type {import("@/package-shared/types").SerializeQueryFnType} */
|
||||||
function serializeQuery({ query }) {
|
function serializeQuery({ query }) {
|
||||||
let str = "?";
|
let str = "?";
|
||||||
const keys = Object.keys(query);
|
const keys = Object.keys(query);
|
||||||
|
@ -18,7 +18,7 @@ const https = require("https");
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} GetSchemaReturn
|
* @typedef {Object} GetSchemaReturn
|
||||||
* @property {boolean} success - Did the function run successfully?
|
* @property {boolean} success - Did the function run successfully?
|
||||||
* @property {DSQL_DatabaseSchemaType | null} payload - Response payload
|
* @property {import("@/package-shared/types").DSQL_DatabaseSchemaType | null} payload - Response payload
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@ const serializeQuery = require("./functions/serialize-query");
|
|||||||
* @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders
|
* @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders
|
||||||
* @param {string} [params.tableName] - Name of the table to query
|
* @param {string} [params.tableName] - Name of the table to query
|
||||||
*
|
*
|
||||||
* @returns { Promise<GetReturn> } - Return Object
|
* @returns { Promise<import("@/package-shared/types").GetReturn> } - Return Object
|
||||||
*/
|
*/
|
||||||
async function get({ key, db, query, queryValues, tableName }) {
|
async function get({ key, db, query, queryValues, tableName }) {
|
||||||
const scheme = process.env.DSQL_HTTP_SCHEME;
|
const scheme = process.env.DSQL_HTTP_SCHEME;
|
||||||
@ -59,7 +59,7 @@ async function get({ key, db, query, queryValues, tableName }) {
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -86,7 +86,7 @@ async function get({ key, db, query, queryValues, tableName }) {
|
|||||||
* @description make a request to datasquirel.com
|
* @description make a request to datasquirel.com
|
||||||
*/
|
*/
|
||||||
const httpResponse = await new Promise((resolve, reject) => {
|
const httpResponse = await new Promise((resolve, reject) => {
|
||||||
/** @type {import("@/package-shared/types/general.td").GetReqQueryObject} */
|
/** @type {import("@/package-shared/types").GetReqQueryObject} */
|
||||||
const queryObject = {
|
const queryObject = {
|
||||||
db: String(db),
|
db: String(db),
|
||||||
query: String(
|
query: String(
|
||||||
|
@ -78,7 +78,7 @@ async function post({ key, query, queryValues, database, tableName }) {
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("@/package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user