Update types
This commit is contained in:
@@ -22,7 +22,7 @@ const updateApiSchemaFromLocalDb = require("../query/update-api-schema-from-loca
|
||||
* ==============================================================================
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ module.exports = async function addUsersTableToDb({ dbSchema }) {
|
||||
* @description Initialize
|
||||
*/
|
||||
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");
|
||||
|
||||
try {
|
||||
|
||||
@@ -27,7 +27,7 @@ const updateTable = require("./utils/updateTable");
|
||||
* 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
|
||||
*
|
||||
* @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) {
|
||||
try {
|
||||
@@ -42,7 +42,7 @@ async function createDbFromSchema(dbSchema) {
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
if (!database) {
|
||||
@@ -262,11 +262,11 @@ async function createDbFromSchema(dbSchema) {
|
||||
*/
|
||||
await varDatabaseDbHandler({
|
||||
queryString: `CREATE${
|
||||
indexType.match(/fullText/i)
|
||||
indexType?.match(/fullText/i)
|
||||
? " FULLTEXT"
|
||||
: ""
|
||||
} INDEX \`${alias}\` ON ${tableName}(${indexTableFields
|
||||
.map((nm) => nm.value)
|
||||
?.map((nm) => nm.value)
|
||||
.map((nm) => `\`${nm}\``)
|
||||
.join(
|
||||
","
|
||||
|
||||
@@ -17,7 +17,7 @@ const supplementTable = require("./supplementTable");
|
||||
* @param {string} param0.tableName
|
||||
* @param {any[]} param0.tableInfoArray
|
||||
* @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
|
||||
*/
|
||||
module.exports = async function createTable({
|
||||
|
||||
@@ -65,7 +65,7 @@ const connection = mysql.createConnection({
|
||||
* @param {object} params - Single Param object containing params
|
||||
* @param {string} params.query - Query String
|
||||
* @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.tableName] - Target Table Name
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Generate SQL text for Field
|
||||
* ==============================================================================
|
||||
* @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)
|
||||
*
|
||||
* @returns {{fieldEntryText: string, newPrimaryKeySet: boolean}}
|
||||
|
||||
@@ -14,7 +14,7 @@ const defaultFieldsRegexp = require("./defaultFieldsRegexp");
|
||||
* @param {object} params - Single object params
|
||||
* @param {*[]} params.unparsedResults - Array of data objects containing Fields(keys)
|
||||
* 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>}
|
||||
*/
|
||||
module.exports = async function parseDbResults({
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_FieldSchemaType[]} param0.tableInfoArray
|
||||
* @param {DSQL_FieldSchemaType[]} param0.tableInfoArray
|
||||
* @returns
|
||||
*/
|
||||
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 {string} params.dbFullName - Database full name => "datasquirel_user_4394_db_name"
|
||||
* @param {string} params.tableName - Table Name(slug)
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_FieldSchemaType[]} params.tableInfoArray - Table Info Array
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType[]} params.dbSchema - Single post
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_IndexSchemaType[]} [params.tableIndexes] - Table Indexes
|
||||
* @param {DSQL_FieldSchemaType[]} params.tableInfoArray - Table Info Array
|
||||
* @param {DSQL_DatabaseSchemaType[]} params.dbSchema - Single post
|
||||
* @param {DSQL_IndexSchemaType[]} [params.tableIndexes] - Table Indexes
|
||||
* @param {boolean} [params.clone] - Is this a newly cloned table?
|
||||
* @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
|
||||
*/
|
||||
if (existingEntry[0].updatedField) {
|
||||
updatedColumnsArray.push(existingEntry[0].fieldName);
|
||||
updatedColumnsArray.push(
|
||||
String(existingEntry[0].fieldName)
|
||||
);
|
||||
|
||||
const renameColumn = await varDatabaseDbHandler({
|
||||
queryString: `ALTER TABLE ${tableName} RENAME COLUMN \`${existingEntry[0].originName}\` TO \`${existingEntry[0].fieldName}\``,
|
||||
@@ -293,9 +295,9 @@ module.exports = async function updateTable({
|
||||
*/
|
||||
await varDatabaseDbHandler({
|
||||
queryString: `CREATE${
|
||||
indexType.match(/fullText/i) ? " FULLTEXT" : ""
|
||||
indexType?.match(/fullText/i) ? " FULLTEXT" : ""
|
||||
} INDEX \`${alias}\` ON ${tableName}(${indexTableFields
|
||||
.map((nm) => nm.value)
|
||||
?.map((nm) => nm.value)
|
||||
.map((nm) => `\`${nm}\``)
|
||||
.join(",")}) COMMENT 'schema_index'`,
|
||||
database: dbFullName,
|
||||
@@ -375,7 +377,7 @@ module.exports = async function updateTable({
|
||||
/**
|
||||
* @description Skip default fields
|
||||
*/
|
||||
if (fieldName.match(/^id$|^date_/)) continue;
|
||||
if (fieldName?.match(/^id$|^date_/)) continue;
|
||||
/**
|
||||
* @description Skip columns that have been updated recently
|
||||
*/
|
||||
@@ -424,7 +426,7 @@ module.exports = async function updateTable({
|
||||
if (
|
||||
Field === fieldName &&
|
||||
!isColumnReordered &&
|
||||
dataType.toUpperCase() === Type.toUpperCase()
|
||||
dataType?.toUpperCase() === Type.toUpperCase()
|
||||
) {
|
||||
updateText += `MODIFY COLUMN ${fieldEntryText}`;
|
||||
// continue;
|
||||
|
||||
@@ -24,7 +24,7 @@ const dbHandler = require("./dbHandler");
|
||||
* @property {string} queryString - SQL string
|
||||
* @property {string[]} [queryValuesArray] - Values Array
|
||||
* @property {string} database - Database name
|
||||
* @property {import("@/package-shared/types/database-schema.td").DSQL_TableSchemaType} [tableSchema] - Table schema
|
||||
* @property {DSQL_TableSchemaType} [tableSchema] - Table schema
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ const runQuery = require("./utils/runQuery");
|
||||
*
|
||||
* @param {Object} params - Single object passed
|
||||
* @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
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ const runQuery = require("./utils/runQuery");
|
||||
*
|
||||
* @param {Object} params - Single object passed
|
||||
* @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
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ const updateDbEntry = require("./updateDbEntry");
|
||||
* @param {string} params.dbFullName - Database full name
|
||||
* @param {string} params.tableName - Table name
|
||||
* @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.duplicateColumnValue] - Duplicate column value
|
||||
* @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"
|
||||
* @param {string} params.dbFullName - Database full 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|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 {*} params.query - Query string or object
|
||||
* @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.tableName] - Table Name
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ const dbHandler = require("../../engine/utils/dbHandler");
|
||||
* @param {string} params.dbFullName - Database full name
|
||||
* @param {string} params.tableName - Table name
|
||||
* @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 | number} params.identifierValue - Update row identifier column value
|
||||
* @param {string} params.encryptionKey - Encryption key
|
||||
|
||||
@@ -21,7 +21,7 @@ const runQuery = require("../query/utils/runQuery");
|
||||
*
|
||||
* @param {Object} params - Single object passed
|
||||
* @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.encryptionSalt]
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@ const varDatabaseDbHandler = require("../engine/utils/varDatabaseDbHandler");
|
||||
* @param {object} param0
|
||||
* @param {number} param0.userId
|
||||
* @param {string[]} param0.fields
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||
* @param {DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||
* @returns
|
||||
*/
|
||||
async function getLocalUser({ userId, fields, dbSchema }) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const varDatabaseDbHandler = require("../engine/utils/varDatabaseDbHandler");
|
||||
* @param {object} param0
|
||||
* @param {*} param0.existingUser
|
||||
* @param {string[]} [param0.additionalFields]
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||
* @param {DSQL_DatabaseSchemaType | undefined} [param0.dbSchema]
|
||||
* @returns
|
||||
*/
|
||||
async function localReauthUser({ existingUser, additionalFields, dbSchema }) {
|
||||
|
||||
@@ -10,7 +10,7 @@ const path = require("path");
|
||||
*
|
||||
* @param {object} param0
|
||||
* @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.mail_domain]
|
||||
* @param {string} [param0.mail_username]
|
||||
|
||||
@@ -36,7 +36,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
* @param {string} params.clientId
|
||||
* @param {string} params.clientSecret
|
||||
* @param {object} [params.additionalFields]
|
||||
* @param {import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType} params.dbSchema
|
||||
* @param {DSQL_DatabaseSchemaType} params.dbSchema
|
||||
*/
|
||||
async function localGithubAuth({
|
||||
res,
|
||||
|
||||
@@ -44,7 +44,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
* @param {string} params.clientId - Google client id
|
||||
* @param {http.ServerResponse} params.response - HTTPS response 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> }
|
||||
*/
|
||||
|
||||
@@ -74,7 +74,7 @@ const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
* res: http.ServerResponse,
|
||||
* supEmail?: string | null,
|
||||
* additionalFields?: object,
|
||||
* dbSchema: import("@/package-shared/types/database-schema.td").DSQL_DatabaseSchemaType | undefined
|
||||
* dbSchema: DSQL_DatabaseSchemaType | undefined
|
||||
* }} params - function parameters inside an object
|
||||
*
|
||||
* @returns {Promise<FunctionReturn>} - Response object
|
||||
|
||||
@@ -17,7 +17,7 @@ const updateDbEntry = require("../query/utils/updateDbEntry");
|
||||
*
|
||||
* @param {Object} params - Single object passed
|
||||
* @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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user