Update types
This commit is contained in:
parent
5d395fe3b5
commit
59c6f6dd40
@ -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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Database Schema Object
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_TableSchemaType} */
|
/** @type {DSQL_TableSchemaType} */
|
||||||
const userPreset = require("./data/presets/users.json");
|
const userPreset = require("./data/presets/users.json");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -27,7 +27,7 @@ const updateTable = require("./utils/updateTable");
|
|||||||
* runs the "dsql create" command. `NOTE`: there must be a "dsql.schema.json" file
|
* runs the "dsql create" command. `NOTE`: there must be a "dsql.schema.json" file
|
||||||
* in the root of the project for this function to work
|
* in the root of the project for this function to work
|
||||||
*
|
*
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} dbSchema - An array of database schema objects
|
* @param {DSQL_DatabaseSchemaType | undefined} dbSchema - An array of database schema objects
|
||||||
*/
|
*/
|
||||||
async function createDbFromSchema(dbSchema) {
|
async function createDbFromSchema(dbSchema) {
|
||||||
try {
|
try {
|
||||||
@ -42,7 +42,7 @@ async function createDbFromSchema(dbSchema) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < dbSchema.length; i++) {
|
for (let i = 0; i < dbSchema.length; i++) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
const database = dbSchema[i];
|
const database = dbSchema[i];
|
||||||
|
|
||||||
if (!database) {
|
if (!database) {
|
||||||
@ -262,11 +262,11 @@ async function createDbFromSchema(dbSchema) {
|
|||||||
*/
|
*/
|
||||||
await varDatabaseDbHandler({
|
await varDatabaseDbHandler({
|
||||||
queryString: `CREATE${
|
queryString: `CREATE${
|
||||||
indexType.match(/fullText/i)
|
indexType?.match(/fullText/i)
|
||||||
? " FULLTEXT"
|
? " FULLTEXT"
|
||||||
: ""
|
: ""
|
||||||
} INDEX \`${alias}\` ON ${tableName}(${indexTableFields
|
} INDEX \`${alias}\` ON ${tableName}(${indexTableFields
|
||||||
.map((nm) => nm.value)
|
?.map((nm) => nm.value)
|
||||||
.map((nm) => `\`${nm}\``)
|
.map((nm) => `\`${nm}\``)
|
||||||
.join(
|
.join(
|
||||||
","
|
","
|
||||||
|
@ -17,7 +17,7 @@ const supplementTable = require("./supplementTable");
|
|||||||
* @param {string} param0.tableName
|
* @param {string} param0.tableName
|
||||||
* @param {any[]} param0.tableInfoArray
|
* @param {any[]} param0.tableInfoArray
|
||||||
* @param {(params: import("./varDatabaseDbHandler").VarDbHandlerParam)=>any} param0.varDatabaseDbHandler
|
* @param {(params: import("./varDatabaseDbHandler").VarDbHandlerParam)=>any} param0.varDatabaseDbHandler
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType} [param0.dbSchema]
|
* @param {DSQL_DatabaseSchemaType} [param0.dbSchema]
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
module.exports = async function createTable({
|
module.exports = async function createTable({
|
||||||
|
@ -65,7 +65,7 @@ const connection = mysql.createConnection({
|
|||||||
* @param {object} params - Single Param object containing params
|
* @param {object} params - Single Param object containing params
|
||||||
* @param {string} params.query - Query String
|
* @param {string} params.query - Query String
|
||||||
* @param {(string | number)[]} [params.values] - Values
|
* @param {(string | number)[]} [params.values] - Values
|
||||||
* @param {import("../../../package-shared/types/database-schema.td").DSQL_DatabaseSchemaType} [params.dbSchema] - Database Schema
|
* @param {DSQL_DatabaseSchemaType} [params.dbSchema] - Database Schema
|
||||||
* @param {string} [params.database] - Target Database
|
* @param {string} [params.database] - Target Database
|
||||||
* @param {string} [params.tableName] - Target Table Name
|
* @param {string} [params.tableName] - Target Table Name
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* Generate SQL text for Field
|
* Generate SQL text for Field
|
||||||
* ==============================================================================
|
* ==============================================================================
|
||||||
* @param {object} params - Single object params
|
* @param {object} params - Single object params
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_FieldSchemaType} params.columnData - Field object
|
* @param {DSQL_FieldSchemaType} params.columnData - Field object
|
||||||
* @param {boolean} [params.primaryKeySet] - Table Name(slug)
|
* @param {boolean} [params.primaryKeySet] - Table Name(slug)
|
||||||
*
|
*
|
||||||
* @returns {{fieldEntryText: string, newPrimaryKeySet: boolean}}
|
* @returns {{fieldEntryText: string, newPrimaryKeySet: boolean}}
|
||||||
|
@ -14,7 +14,7 @@ const defaultFieldsRegexp = require("./defaultFieldsRegexp");
|
|||||||
* @param {object} params - Single object params
|
* @param {object} params - Single object params
|
||||||
* @param {*[]} params.unparsedResults - Array of data objects containing Fields(keys)
|
* @param {*[]} params.unparsedResults - Array of data objects containing Fields(keys)
|
||||||
* and corresponding values of the fields(values)
|
* and corresponding values of the fields(values)
|
||||||
* @param {import("../../../package-shared/types/database-schema.td").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||||
* @returns {Promise<object[]|null>}
|
* @returns {Promise<object[]|null>}
|
||||||
*/
|
*/
|
||||||
module.exports = async function parseDbResults({
|
module.exports = async function parseDbResults({
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {object} param0
|
* @param {object} param0
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_FieldSchemaType[]} param0.tableInfoArray
|
* @param {DSQL_FieldSchemaType[]} param0.tableInfoArray
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
module.exports = function supplementTable({ tableInfoArray }) {
|
module.exports = function supplementTable({ tableInfoArray }) {
|
||||||
|
@ -31,9 +31,9 @@ const schemaPath = path.resolve(process.cwd(), "dsql.schema.json");
|
|||||||
* @param {object} params - Single object params
|
* @param {object} params - Single object params
|
||||||
* @param {string} params.dbFullName - Database full name => "datasquirel_user_4394_db_name"
|
* @param {string} params.dbFullName - Database full name => "datasquirel_user_4394_db_name"
|
||||||
* @param {string} params.tableName - Table Name(slug)
|
* @param {string} params.tableName - Table Name(slug)
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_FieldSchemaType[]} params.tableInfoArray - Table Info Array
|
* @param {DSQL_FieldSchemaType[]} params.tableInfoArray - Table Info Array
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType[]} params.dbSchema - Single post
|
* @param {DSQL_DatabaseSchemaType[]} params.dbSchema - Single post
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_IndexSchemaType[]} [params.tableIndexes] - Table Indexes
|
* @param {DSQL_IndexSchemaType[]} [params.tableIndexes] - Table Indexes
|
||||||
* @param {boolean} [params.clone] - Is this a newly cloned table?
|
* @param {boolean} [params.clone] - Is this a newly cloned table?
|
||||||
* @param {number} [params.tableIndex] - The number index of the table in the dbSchema array
|
* @param {number} [params.tableIndex] - The number index of the table in the dbSchema array
|
||||||
*
|
*
|
||||||
@ -141,7 +141,9 @@ module.exports = async function updateTable({
|
|||||||
* @description Check if Field name has been updated
|
* @description Check if Field name has been updated
|
||||||
*/
|
*/
|
||||||
if (existingEntry[0].updatedField) {
|
if (existingEntry[0].updatedField) {
|
||||||
updatedColumnsArray.push(existingEntry[0].fieldName);
|
updatedColumnsArray.push(
|
||||||
|
String(existingEntry[0].fieldName)
|
||||||
|
);
|
||||||
|
|
||||||
const renameColumn = await varDatabaseDbHandler({
|
const renameColumn = await varDatabaseDbHandler({
|
||||||
queryString: `ALTER TABLE ${tableName} RENAME COLUMN \`${existingEntry[0].originName}\` TO \`${existingEntry[0].fieldName}\``,
|
queryString: `ALTER TABLE ${tableName} RENAME COLUMN \`${existingEntry[0].originName}\` TO \`${existingEntry[0].fieldName}\``,
|
||||||
@ -293,9 +295,9 @@ module.exports = async function updateTable({
|
|||||||
*/
|
*/
|
||||||
await varDatabaseDbHandler({
|
await varDatabaseDbHandler({
|
||||||
queryString: `CREATE${
|
queryString: `CREATE${
|
||||||
indexType.match(/fullText/i) ? " FULLTEXT" : ""
|
indexType?.match(/fullText/i) ? " FULLTEXT" : ""
|
||||||
} INDEX \`${alias}\` ON ${tableName}(${indexTableFields
|
} INDEX \`${alias}\` ON ${tableName}(${indexTableFields
|
||||||
.map((nm) => nm.value)
|
?.map((nm) => nm.value)
|
||||||
.map((nm) => `\`${nm}\``)
|
.map((nm) => `\`${nm}\``)
|
||||||
.join(",")}) COMMENT 'schema_index'`,
|
.join(",")}) COMMENT 'schema_index'`,
|
||||||
database: dbFullName,
|
database: dbFullName,
|
||||||
@ -375,7 +377,7 @@ module.exports = async function updateTable({
|
|||||||
/**
|
/**
|
||||||
* @description Skip default fields
|
* @description Skip default fields
|
||||||
*/
|
*/
|
||||||
if (fieldName.match(/^id$|^date_/)) continue;
|
if (fieldName?.match(/^id$|^date_/)) continue;
|
||||||
/**
|
/**
|
||||||
* @description Skip columns that have been updated recently
|
* @description Skip columns that have been updated recently
|
||||||
*/
|
*/
|
||||||
@ -424,7 +426,7 @@ module.exports = async function updateTable({
|
|||||||
if (
|
if (
|
||||||
Field === fieldName &&
|
Field === fieldName &&
|
||||||
!isColumnReordered &&
|
!isColumnReordered &&
|
||||||
dataType.toUpperCase() === Type.toUpperCase()
|
dataType?.toUpperCase() === Type.toUpperCase()
|
||||||
) {
|
) {
|
||||||
updateText += `MODIFY COLUMN ${fieldEntryText}`;
|
updateText += `MODIFY COLUMN ${fieldEntryText}`;
|
||||||
// continue;
|
// continue;
|
||||||
|
@ -24,7 +24,7 @@ const dbHandler = require("./dbHandler");
|
|||||||
* @property {string} queryString - SQL string
|
* @property {string} queryString - SQL string
|
||||||
* @property {string[]} [queryValuesArray] - Values Array
|
* @property {string[]} [queryValuesArray] - Values Array
|
||||||
* @property {string} database - Database name
|
* @property {string} database - Database name
|
||||||
* @property {import("@/package-shared/types/database-schema.td").DSQL_TableSchemaType} [tableSchema] - Table schema
|
* @property {DSQL_TableSchemaType} [tableSchema] - Table schema
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [params.dbSchema] - Name of the table to query
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
* @param {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
|
||||||
|
@ -21,7 +21,7 @@ const runQuery = require("../query/utils/runQuery");
|
|||||||
*
|
*
|
||||||
* @param {Object} params - Single object passed
|
* @param {Object} params - Single object passed
|
||||||
* @param {import("@/types/user.td").UserDataPayload} params.payload - SQL Query
|
* @param {import("@/types/user.td").UserDataPayload} params.payload - SQL Query
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
* @param {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]
|
||||||
*
|
*
|
||||||
|
@ -7,7 +7,7 @@ const varDatabaseDbHandler = require("../engine/utils/varDatabaseDbHandler");
|
|||||||
* @param {object} param0
|
* @param {object} param0
|
||||||
* @param {number} param0.userId
|
* @param {number} param0.userId
|
||||||
* @param {string[]} param0.fields
|
* @param {string[]} param0.fields
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
* @param {DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function getLocalUser({ userId, fields, dbSchema }) {
|
async function getLocalUser({ userId, fields, dbSchema }) {
|
||||||
|
@ -7,7 +7,7 @@ const varDatabaseDbHandler = require("../engine/utils/varDatabaseDbHandler");
|
|||||||
* @param {object} param0
|
* @param {object} param0
|
||||||
* @param {*} param0.existingUser
|
* @param {*} param0.existingUser
|
||||||
* @param {string[]} [param0.additionalFields]
|
* @param {string[]} [param0.additionalFields]
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
* @param {DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function localReauthUser({ existingUser, additionalFields, dbSchema }) {
|
async function localReauthUser({ existingUser, additionalFields, dbSchema }) {
|
||||||
|
@ -10,7 +10,7 @@ const path = require("path");
|
|||||||
*
|
*
|
||||||
* @param {object} param0
|
* @param {object} param0
|
||||||
* @param {string} param0.email
|
* @param {string} param0.email
|
||||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
* @param {DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||||
* @param {string} param0.email_login_field
|
* @param {string} param0.email_login_field
|
||||||
* @param {string} [param0.mail_domain]
|
* @param {string} [param0.mail_domain]
|
||||||
* @param {string} [param0.mail_username]
|
* @param {string} [param0.mail_username]
|
||||||
|
@ -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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType} params.dbSchema
|
* @param {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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType} [params.dbSchema] - Database Schema
|
* @param {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: import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined
|
* dbSchema: 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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
* @param {DSQL_DatabaseSchemaType | undefined} params.dbSchema - Name of the table to query
|
||||||
*
|
*
|
||||||
* @returns { Promise<LocalPostReturn> } - Return Object
|
* @returns { Promise<LocalPostReturn> } - Return Object
|
||||||
*/
|
*/
|
||||||
|
@ -31,6 +31,7 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => {
|
|||||||
|
|
||||||
let key = scryptSync(encryptionKey, encryptionSalt, 24);
|
let key = scryptSync(encryptionKey, encryptionSalt, 24);
|
||||||
let iv = Buffer.alloc(16, 0);
|
let iv = Buffer.alloc(16, 0);
|
||||||
|
// @ts-ignore
|
||||||
const decipher = createDecipheriv(algorithm, key, iv);
|
const decipher = createDecipheriv(algorithm, key, iv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -30,6 +30,7 @@ const encrypt = ({ data, encryptionKey, encryptionSalt }) => {
|
|||||||
|
|
||||||
let key = scryptSync(password, encryptionSalt, 24);
|
let key = scryptSync(password, encryptionSalt, 24);
|
||||||
let iv = Buffer.alloc(16, 0);
|
let iv = Buffer.alloc(16, 0);
|
||||||
|
// @ts-ignore
|
||||||
const cipher = createCipheriv(algorithm, key, iv);
|
const cipher = createCipheriv(algorithm, key, iv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -16,9 +16,15 @@
|
|||||||
* @property {string} [dbDescription] - Database brief description
|
* @property {string} [dbDescription] - Database brief description
|
||||||
* @property {string} [dbImage] - Database image - Defaults to "/images/default.png"
|
* @property {string} [dbImage] - Database image - Defaults to "/images/default.png"
|
||||||
* @property {DSQL_TableSchemaType[]} tables - List of database tables
|
* @property {DSQL_TableSchemaType[]} tables - List of database tables
|
||||||
* @property {{ dbFullName: string }[]} [childrenDatabases] - List of children databases for current database which is parent
|
* @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 {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 {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"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
@ -32,6 +38,7 @@
|
|||||||
* @property {DSQL_IndexSchemaType[]} [indexes] - List of table indexes, if available
|
* @property {DSQL_IndexSchemaType[]} [indexes] - List of table indexes, if available
|
||||||
* @property {DSQL_ChildrenTablesType[]} [childrenTables] - List of children tables
|
* @property {DSQL_ChildrenTablesType[]} [childrenTables] - List of children tables
|
||||||
* @property {boolean} [childTable] -If current table is a child clone
|
* @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} [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} [childTableDbFullName] - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
||||||
* @property {string} [tableNameOld] - Old table name, incase of renaming table
|
* @property {string} [tableNameOld] - Old table name, incase of renaming table
|
||||||
@ -41,16 +48,17 @@
|
|||||||
* @typedef {object} DSQL_ChildrenTablesType
|
* @typedef {object} DSQL_ChildrenTablesType
|
||||||
* @property {string} dbNameFull - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
* @property {string} dbNameFull - Database full name(slug) including datasquirel data => "datasquirel_user_7_new_database"
|
||||||
* @property {string} tableName - Table slug => "blog_posts"
|
* @property {string} tableName - Table slug => "blog_posts"
|
||||||
|
* @property {string} [tableNameFull]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} DSQL_FieldSchemaType
|
* @typedef {object} DSQL_FieldSchemaType
|
||||||
* @property {string} fieldName - Field Name(slug) => "long_description"
|
* @property {string} [fieldName] - Field Name(slug) => "long_description"
|
||||||
* @property {string} [originName] - Field origin name(optional)
|
* @property {string} [originName] - Field origin name(optional)
|
||||||
* @property {boolean} [updatedField] - Has this field been renamed?
|
* @property {boolean} [updatedField] - Has this field been renamed?
|
||||||
* @property {string} dataType - Field Data type => "BIGIN" | "LONGTEXT" | "VARCHAR(***)" | ...
|
* @property {string} [dataType] - Field Data type => "BIGIN" | "LONGTEXT" | "VARCHAR(***)" | ...
|
||||||
* @property {boolean} [nullValue] - Is this a null value or not?
|
* @property {boolean} [nullValue] - Is this a null value or not?
|
||||||
* @property {boolean} [notNullValue] - Is this NOT a null value?
|
* @property {boolean} [notNullValue] - Is this NOT a null value?
|
||||||
* @property {boolean} [primaryKey] - Is this the primary key for table?
|
* @property {boolean} [primaryKey] - Is this the primary key for table?
|
||||||
@ -60,16 +68,31 @@
|
|||||||
* @property {string} [defaultValueLiteral] - SQL key word which generates value automatically => "CURRENT_TIMESTAMP"
|
* @property {string} [defaultValueLiteral] - SQL key word which generates value automatically => "CURRENT_TIMESTAMP"
|
||||||
* @property {DSQL_ForeignKeyType} [foreignKey] - Field foreign key reference object
|
* @property {DSQL_ForeignKeyType} [foreignKey] - Field foreign key reference object
|
||||||
* @property {boolean} [richText] - Rich text field
|
* @property {boolean} [richText] - Rich text field
|
||||||
* @property {string | RegExp} [pattern] - Field pattern for validation. Can be a string or a regular expression. Example: "^[a-zA-Z0-9_]*$"
|
* @property {boolean} [json]
|
||||||
* @property {string} [patternFlags] - Field pattern flags for validation. Example: "i"
|
* @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
|
* @typedef {object} DSQL_ForeignKeyType
|
||||||
* @property {string} foreignKeyName - Unique Name of foreign key
|
* @property {string} [foreignKeyName] - Unique Name of foreign key
|
||||||
* @property {string} destinationTableName - Reference table name(slug) => "blog_posts"
|
* @property {string} [destinationTableName] - Reference table name(slug) => "blog_posts"
|
||||||
* @property {string} destinationTableColumnName - Reference column name(slug) => "id"
|
* @property {string} [destinationTableColumnName] - Reference column name(slug) => "id"
|
||||||
* @property {string} destinationTableColumnType - Reference table field type => "BIGINT" | "VARCHAR(***)" | ...
|
* @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} [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?
|
* @property {boolean} [cascadeUpdate] - Does the reference table entry update when this key is updated?
|
||||||
*/
|
*/
|
||||||
@ -78,10 +101,11 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} DSQL_IndexSchemaType
|
* @typedef {object} DSQL_IndexSchemaType
|
||||||
* @property {string} indexName - Unique Name of index => "blog_text_index"
|
* @property {string} [indexName] - Unique Name of index => "blog_text_index"
|
||||||
* @property {string} indexType - "regular" or "fullText"
|
* @property {string} [indexType] - "regular" or "fullText"
|
||||||
* @property {DSQL_IndexTableFieldType[]} indexTableFields - List of Index table fields
|
* @property {DSQL_IndexTableFieldType[]} [indexTableFields] - List of Index table fields
|
||||||
* @property {string} [alias] - List of Index table fields
|
* @property {string} [alias] - List of Index table fields
|
||||||
|
* @property {boolean} [newTempIndex]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +113,3 @@
|
|||||||
* @property {string} value - Table Field Name
|
* @property {string} value - Table Field Name
|
||||||
* @property {string} dataType - Table Field data type "VARCHAR(***)" | "BIGINT" | ...
|
* @property {string} dataType - Table Field data type "VARCHAR(***)" | "BIGINT" | ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
exports.DSQL_TableSchemaType = DSQL_TableSchemaType;
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* @property {string} [email_login_field]
|
* @property {string} [email_login_field]
|
||||||
* @property {boolean} [token]
|
* @property {boolean} [token]
|
||||||
* @property {boolean} [social]
|
* @property {boolean} [social]
|
||||||
* @property {import("./database-schema.td").DSQL_DatabaseSchemaType} [dbSchema]
|
* @property {DSQL_DatabaseSchemaType} [dbSchema]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,5 +23,14 @@
|
|||||||
* @property {string} [email_login_field]
|
* @property {string} [email_login_field]
|
||||||
* @property {boolean} [token]
|
* @property {boolean} [token]
|
||||||
* @property {boolean} [social]
|
* @property {boolean} [social]
|
||||||
* @property {import("./database-schema.td").DSQL_DatabaseSchemaType} [dbSchema]
|
* @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
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "datasquirel",
|
"name": "datasquirel",
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -64,7 +64,7 @@ async function addUser({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -83,7 +83,7 @@ async function getUser({ key, userId, database, fields }) {
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -126,7 +126,7 @@ async function loginUser({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -103,7 +103,7 @@ async function reauthUser({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -154,7 +154,7 @@ async function githubAuth({
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined | undefined} */
|
/** @type {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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType[] | import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | null} payload - Response payload
|
* @property {DSQL_DatabaseSchemaType | null} payload - Response payload
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
10
utils/get.js
10
utils/get.js
@ -18,14 +18,6 @@ const localGet = require("../engine/query/get");
|
|||||||
/** ****************************************************************************** */
|
/** ****************************************************************************** */
|
||||||
/** ****************************************************************************** */
|
/** ****************************************************************************** */
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a get request to Datasquirel API
|
* Make a get request to Datasquirel API
|
||||||
* ==============================================================================
|
* ==============================================================================
|
||||||
@ -66,7 +58,7 @@ async function get({ key, db, query, queryValues, tableName }) {
|
|||||||
DSQL_PASS?.match(/./) &&
|
DSQL_PASS?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -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 {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {DSQL_DatabaseSchemaType | undefined} */
|
||||||
let dbSchema;
|
let dbSchema;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user