diff --git a/client/fetch/index.d.ts b/client/fetch/index.d.ts index fddf1ee..b65b1df 100644 --- a/client/fetch/index.d.ts +++ b/client/fetch/index.d.ts @@ -1,5 +1,5 @@ export = clientFetch; -declare function clientFetch(url: string, options?: import("../../package-shared/types").FetchApiOptions, csrf?: boolean): Promise; +declare function clientFetch(url: string, options?: import("../../package-shared/types").FetchApiOptions, contentType?: "json" | "text" | "html" | "blob" | "file"): Promise; declare namespace clientFetch { export { clientFetch as fetchApi }; } diff --git a/package-shared/functions/api/query/get.d.ts b/package-shared/functions/api/query/get.d.ts new file mode 100644 index 0000000..44265cd --- /dev/null +++ b/package-shared/functions/api/query/get.d.ts @@ -0,0 +1,8 @@ +declare function _exports({ query, dbFullName, queryValues, tableName, dbSchema, }: { + query: string; + queryValues?: (string | number)[]; + dbFullName: string; + tableName?: string; + dbSchema?: import("../../../types").DSQL_DatabaseSchemaType; +}): Promise; +export = _exports; diff --git a/package-shared/functions/api/query/post.d.ts b/package-shared/functions/api/query/post.d.ts new file mode 100644 index 0000000..c2f3f6c --- /dev/null +++ b/package-shared/functions/api/query/post.d.ts @@ -0,0 +1,8 @@ +declare function _exports({ query, dbFullName, queryValues, tableName, dbSchema, }: { + query: any; + queryValues?: (string | number)[]; + dbFullName: string; + tableName?: string; + dbSchema?: import("../../../types").DSQL_DatabaseSchemaType; +}): Promise; +export = _exports; diff --git a/package-shared/functions/api/social-login/githubLogin.d.ts b/package-shared/functions/api/social-login/githubLogin.d.ts new file mode 100644 index 0000000..cb8276f --- /dev/null +++ b/package-shared/functions/api/social-login/githubLogin.d.ts @@ -0,0 +1,135 @@ +declare namespace _exports { + export { GithubUserPayload }; +} +declare function _exports({ code, clientId, clientSecret }: { + code: string; + clientId: string; + clientSecret: string; +}): Promise; +export = _exports; +type GithubUserPayload = { + /** + * - Full name merged eg. "JohnDoe" + */ + login: string; + /** + * - github user id + */ + id: number; + /** + * - Some other id + */ + node_id: string; + /** + * - profile picture + */ + avatar_url: string; + /** + * - some other id + */ + gravatar_id: string; + /** + * - Github user URL + */ + url: string; + /** + * - User html URL - whatever that means + */ + html_url: string; + /** + * - Followers URL + */ + followers_url: string; + /** + * - Following URL + */ + following_url: string; + /** + * - Gists URL + */ + gists_url: string; + /** + * - Starred URL + */ + starred_url: string; + /** + * - Subscriptions URL + */ + subscriptions_url: string; + /** + * - Organizations URL + */ + organizations_url: string; + /** + * - Repositories URL + */ + repos_url: string; + /** + * - Received Events URL + */ + received_events_url: string; + /** + * - Common value => "User" + */ + type: string; + /** + * - Is site admin or not? Boolean + */ + site_admin: boolean; + /** + * - More like "username" + */ + name: string; + /** + * - User company + */ + company: string; + /** + * - User blog URL + */ + blog: string; + /** + * - User Location + */ + location: string; + /** + * - User Email + */ + email: string; + /** + * - Is user hireable + */ + hireable: string; + /** + * - User bio + */ + bio: string; + /** + * - User twitter username + */ + twitter_username: string; + /** + * - Number of public repositories + */ + public_repos: number; + /** + * - Number of public gists + */ + public_gists: number; + /** + * - Number of followers + */ + followers: number; + /** + * - Number of following + */ + following: number; + /** + * - Date created + */ + created_at: string; + /** + * - Date updated + */ + updated_at: string; +}; diff --git a/package-shared/functions/api/social-login/handleSocialDb.d.ts b/package-shared/functions/api/social-login/handleSocialDb.d.ts new file mode 100644 index 0000000..ff1bae8 --- /dev/null +++ b/package-shared/functions/api/social-login/handleSocialDb.d.ts @@ -0,0 +1,19 @@ +declare namespace _exports { + export { FunctionReturn }; +} +declare const _exports: import("../../../types").HandleSocialDbFunction; +export = _exports; +type FunctionReturn = { + /** + * - Did the operation complete successfully or not? + */ + success: boolean; + /** + * - User payload object: or "null" + */ + user: { + id: number; + first_name: string; + last_name: string; + } | null; +}; diff --git a/package-shared/functions/api/users/api-create-user.d.ts b/package-shared/functions/api/users/api-create-user.d.ts new file mode 100644 index 0000000..18e5985 --- /dev/null +++ b/package-shared/functions/api/users/api-create-user.d.ts @@ -0,0 +1,2 @@ +declare const _exports: import("../../../types").APICreateUserFunction; +export = _exports; diff --git a/package-shared/functions/api/users/api-login.d.ts b/package-shared/functions/api/users/api-login.d.ts new file mode 100644 index 0000000..747fc57 --- /dev/null +++ b/package-shared/functions/api/users/api-login.d.ts @@ -0,0 +1,2 @@ +declare const _exports: import("../../../types").APILoginFunction; +export = _exports; diff --git a/package-shared/functions/api/users/api-reauth-user.d.ts b/package-shared/functions/api/users/api-reauth-user.d.ts new file mode 100644 index 0000000..0c6d928 --- /dev/null +++ b/package-shared/functions/api/users/api-reauth-user.d.ts @@ -0,0 +1,9 @@ +declare function _exports({ existingUser, database, userId, additionalFields, }: { + existingUser: { + [x: string]: any; + }; + database: string; + userId?: string | number; + additionalFields?: string[]; +}): Promise; +export = _exports; diff --git a/package-shared/functions/api/users/api-send-email-code.d.ts b/package-shared/functions/api/users/api-send-email-code.d.ts new file mode 100644 index 0000000..84f3daa --- /dev/null +++ b/package-shared/functions/api/users/api-send-email-code.d.ts @@ -0,0 +1,15 @@ +declare function _exports({ email, database, email_login_field, mail_domain, mail_port, sender, mail_username, mail_password, html, }: { + email: string; + database: string; + email_login_field?: string; + mail_domain?: string; + mail_port?: number; + sender?: string; + mail_username?: string; + mail_password?: string; + html: string; +}): Promise<{ + success: boolean; + msg?: string; +}>; +export = _exports; diff --git a/package-shared/functions/api/users/api-update-user.d.ts b/package-shared/functions/api/users/api-update-user.d.ts new file mode 100644 index 0000000..ce42a55 --- /dev/null +++ b/package-shared/functions/api/users/api-update-user.d.ts @@ -0,0 +1,12 @@ +declare function _exports({ payload, dbFullName }: { + payload: { + id: string | number; + } & { + [x: string]: (string | number | null | undefined); + }; + dbFullName: string; +}): Promise<{ + success: boolean; + payload: any; +}>; +export = _exports; diff --git a/package-shared/functions/api/users/social/api-github-login.d.ts b/package-shared/functions/api/users/social/api-github-login.d.ts new file mode 100644 index 0000000..975fccb --- /dev/null +++ b/package-shared/functions/api/users/social/api-github-login.d.ts @@ -0,0 +1,13 @@ +declare function _exports({ code, clientId, clientSecret, database, additionalFields, res, email, userId, }: { + code?: string; + clientId?: string; + clientSecret?: string; + database?: string; + additionalFields?: { + [x: string]: any; + }; + res?: any; + email?: string; + userId?: string | number; +}): Promise; +export = _exports; diff --git a/package-shared/functions/api/users/social/api-google-login.d.ts b/package-shared/functions/api/users/social/api-google-login.d.ts new file mode 100644 index 0000000..95a7eb3 --- /dev/null +++ b/package-shared/functions/api/users/social/api-google-login.d.ts @@ -0,0 +1,2 @@ +declare const _exports: import("../../../../types").APIGoogleLoginFunction; +export = _exports; diff --git a/package-shared/functions/backend/addAdminUserOnLogin.d.ts b/package-shared/functions/backend/addAdminUserOnLogin.d.ts new file mode 100644 index 0000000..9f84e83 --- /dev/null +++ b/package-shared/functions/backend/addAdminUserOnLogin.d.ts @@ -0,0 +1,10 @@ +declare function _exports({ query, user }: { + query: { + invite: number; + database_access: string; + priviledge: string; + email: string; + }; + user: import("../../types").UserType; +}): Promise; +export = _exports; diff --git a/package-shared/functions/backend/addMariadbUser.d.ts b/package-shared/functions/backend/addMariadbUser.d.ts new file mode 100644 index 0000000..c843885 --- /dev/null +++ b/package-shared/functions/backend/addMariadbUser.d.ts @@ -0,0 +1,4 @@ +declare function _exports({ userId }: { + userId: number | string; +}): Promise; +export = _exports; diff --git a/package-shared/functions/backend/addUsersTableToDb.d.ts b/package-shared/functions/backend/addUsersTableToDb.d.ts new file mode 100644 index 0000000..2751d4e --- /dev/null +++ b/package-shared/functions/backend/addUsersTableToDb.d.ts @@ -0,0 +1,5 @@ +declare function _exports({ userId, database }: { + userId: number; + database: string; +}): Promise; +export = _exports; diff --git a/package-shared/functions/backend/cookies/get-auth-cookie-names.d.ts b/package-shared/functions/backend/cookies/get-auth-cookie-names.d.ts new file mode 100644 index 0000000..d3f9c17 --- /dev/null +++ b/package-shared/functions/backend/cookies/get-auth-cookie-names.d.ts @@ -0,0 +1,5 @@ +declare function _exports(): { + keyCookieName: string; + csrfCookieName: string; +}; +export = _exports; diff --git a/package-shared/functions/backend/db/runQuery.d.ts b/package-shared/functions/backend/db/runQuery.d.ts new file mode 100644 index 0000000..4f1cc05 --- /dev/null +++ b/package-shared/functions/backend/db/runQuery.d.ts @@ -0,0 +1,30 @@ +export = runQuery; +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** + * Run DSQL users queries + * ============================================================================== + * @param {object} params - An object containing the function parameters. + * @param {string} params.dbFullName - Database full name. Eg. "datasquire_user_2_test" + * @param {string | any} params.query - Query string or object + * @param {boolean} [params.readOnly] - Is this operation read only? + * @param {boolean} [params.local] - Is this operation read only? + * @param {import("../../../types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema + * @param {(string | number)[]} [params.queryValuesArray] - An optional array of query values if "?" is used in the query string + * @param {string} [params.tableName] - Table Name + * + * @return {Promise} + */ +declare function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, local, }: { + dbFullName: string; + query: string | any; + readOnly?: boolean; + local?: boolean; + dbSchema?: import("../../../types").DSQL_DatabaseSchemaType; + queryValuesArray?: (string | number)[]; + tableName?: string; +}): Promise; diff --git a/package-shared/functions/backend/grabUserSchemaData.d.ts b/package-shared/functions/backend/grabUserSchemaData.d.ts new file mode 100644 index 0000000..51258f6 --- /dev/null +++ b/package-shared/functions/backend/grabUserSchemaData.d.ts @@ -0,0 +1,15 @@ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** + * ============================================================================== + * @param {Object} params + * @param {string | number} params.userId + * @returns {import("../../types").DSQL_DatabaseSchemaType[] | null} + */ +export default function grabUserSchemaData({ userId }: { + userId: string | number; +}): import("../../types").DSQL_DatabaseSchemaType[] | null; diff --git a/package-shared/functions/backend/handleNodemailer.d.ts b/package-shared/functions/backend/handleNodemailer.d.ts new file mode 100644 index 0000000..b812686 --- /dev/null +++ b/package-shared/functions/backend/handleNodemailer.d.ts @@ -0,0 +1,8 @@ +declare function _exports({ to, subject, text, html, alias, }: { + to?: string; + subject?: string; + text?: string; + html?: string; + alias?: string | null; +}): Promise; +export = _exports; diff --git a/package-shared/functions/backend/httpsRequest.d.ts b/package-shared/functions/backend/httpsRequest.d.ts new file mode 100644 index 0000000..1c67f8c --- /dev/null +++ b/package-shared/functions/backend/httpsRequest.d.ts @@ -0,0 +1,11 @@ +declare function _exports({ url, method, hostname, path, headers, body, port, scheme, }: { + scheme?: string; + url?: string; + method?: string; + hostname?: string; + path?: string; + port?: number | string; + headers?: object; + body?: object; +}): Promise; +export = _exports; diff --git a/package-shared/functions/backend/setUserSchemaData.d.ts b/package-shared/functions/backend/setUserSchemaData.d.ts new file mode 100644 index 0000000..ba7aa5e --- /dev/null +++ b/package-shared/functions/backend/setUserSchemaData.d.ts @@ -0,0 +1,17 @@ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** ****************************************************************************** */ +/** + * ============================================================================== + * @param {Object} params + * @param {string | number} params.userId + * @param {import("../../types").DSQL_DatabaseSchemaType[]} params.schemaData + * @returns {boolean} + */ +export default function setUserSchemaData({ userId, schemaData }: { + userId: string | number; + schemaData: import("../../types").DSQL_DatabaseSchemaType[]; +}): boolean; diff --git a/package-shared/functions/dsql/decrypt.d.ts b/package-shared/functions/dsql/decrypt.d.ts new file mode 100644 index 0000000..1ade814 --- /dev/null +++ b/package-shared/functions/dsql/decrypt.d.ts @@ -0,0 +1,13 @@ +export = decrypt; +/** + * @param {object} param0 + * @param {string} param0.encryptedString + * @param {string} [param0.encryptionKey] + * @param {string} [param0.encryptionSalt] + * @returns + */ +declare function decrypt({ encryptedString, encryptionKey, encryptionSalt }: { + encryptedString: string; + encryptionKey?: string; + encryptionSalt?: string; +}): string; diff --git a/package-shared/functions/dsql/encrypt.d.ts b/package-shared/functions/dsql/encrypt.d.ts new file mode 100644 index 0000000..85beae8 --- /dev/null +++ b/package-shared/functions/dsql/encrypt.d.ts @@ -0,0 +1,14 @@ +export = encrypt; +/** + * + * @param {object} param0 + * @param {string} param0.data + * @param {string} [param0.encryptionKey] + * @param {string} [param0.encryptionSalt] + * @returns {string | null} + */ +declare function encrypt({ data, encryptionKey, encryptionSalt }: { + data: string; + encryptionKey?: string; + encryptionSalt?: string; +}): string | null; diff --git a/package-shared/functions/dsql/sql/sql-generator.d.ts b/package-shared/functions/dsql/sql/sql-generator.d.ts index 5ab8338..dc6ab9b 100644 --- a/package-shared/functions/dsql/sql/sql-generator.d.ts +++ b/package-shared/functions/dsql/sql/sql-generator.d.ts @@ -2,9 +2,7 @@ export = sqlGenerator; declare function sqlGenerator(Param0: { genObject?: import("../../../types").ServerQueryParam; tableName: string; -}): - | { - string: string; - values: string[]; - } - | undefined; +}): { + string: string; + values: string[]; +} | undefined; diff --git a/package-shared/functions/dsql/sql/sql-insert-generator.d.ts b/package-shared/functions/dsql/sql/sql-insert-generator.d.ts index 1f3d34c..c256cbc 100644 --- a/package-shared/functions/dsql/sql/sql-insert-generator.d.ts +++ b/package-shared/functions/dsql/sql/sql-insert-generator.d.ts @@ -1,6 +1,6 @@ export = sqlInsertGenerator; /** - * @typedef {object} SQLINsertGenReturn + * @typedef {object} SQLInsertGenReturn * @property {string} query * @property {string[]} values */ @@ -9,16 +9,16 @@ export = sqlInsertGenerator; * @param {any[]} param0.data * @param {string} param0.tableName * - * @return {SQLINsertGenReturn | undefined} + * @return {SQLInsertGenReturn | undefined} */ declare function sqlInsertGenerator({ tableName, data }: { data: any[]; tableName: string; -}): SQLINsertGenReturn | undefined; +}): SQLInsertGenReturn | undefined; declare namespace sqlInsertGenerator { - export { SQLINsertGenReturn }; + export { SQLInsertGenReturn }; } -type SQLINsertGenReturn = { +type SQLInsertGenReturn = { query: string; values: string[]; }; diff --git a/package-shared/shell/createDbFromSchema.d.ts b/package-shared/shell/createDbFromSchema.d.ts new file mode 100644 index 0000000..5bb17b5 --- /dev/null +++ b/package-shared/shell/createDbFromSchema.d.ts @@ -0,0 +1,14 @@ +export = createDbFromSchema; +/** + * Create database from Schema Function + * ============================================================================== + * @param {object} params - Single object params + * @param {number|string|null} [params.userId] - User ID or null + * @param {string} [params.targetDatabase] - User Database full name + * @param {import("../types").DSQL_DatabaseSchemaType[]} [params.dbSchemaData] + */ +declare function createDbFromSchema({ userId, targetDatabase, dbSchemaData }: { + userId?: number | string | null; + targetDatabase?: string; + dbSchemaData?: import("../types").DSQL_DatabaseSchemaType[]; +}): Promise; diff --git a/package-shared/shell/utils/createTable.d.ts b/package-shared/shell/utils/createTable.d.ts new file mode 100644 index 0000000..f7c2deb --- /dev/null +++ b/package-shared/shell/utils/createTable.d.ts @@ -0,0 +1,10 @@ +declare function _exports({ dbFullName, tableName, tableInfoArray, dbSchema, clone, tableSchema, recordedDbEntry, }: { + dbFullName: string; + tableName: string; + tableInfoArray: any[]; + dbSchema?: import("../../types").DSQL_DatabaseSchemaType[]; + tableSchema?: import("../../types").DSQL_TableSchemaType; + recordedDbEntry?: any; + clone?: boolean; +}): Promise; +export = _exports; diff --git a/package-shared/shell/utils/dbHandler.d.ts b/package-shared/shell/utils/dbHandler.d.ts new file mode 100644 index 0000000..b6e4b6b --- /dev/null +++ b/package-shared/shell/utils/dbHandler.d.ts @@ -0,0 +1,6 @@ +declare function _exports({ query, values, database }: { + query: string; + values?: string[] | object; + database?: string; +}): Promise; +export = _exports; diff --git a/package-shared/shell/utils/generateColumnDescription.d.ts b/package-shared/shell/utils/generateColumnDescription.d.ts new file mode 100644 index 0000000..97fec49 --- /dev/null +++ b/package-shared/shell/utils/generateColumnDescription.d.ts @@ -0,0 +1,8 @@ +declare function _exports({ columnData, primaryKeySet, }: { + columnData: import("../../types").DSQL_FieldSchemaType; + primaryKeySet?: boolean; +}): { + fieldEntryText: string; + newPrimaryKeySet: boolean; +}; +export = _exports; diff --git a/package-shared/shell/utils/noDatabaseDbHandler.d.ts b/package-shared/shell/utils/noDatabaseDbHandler.d.ts new file mode 100644 index 0000000..4cea1af --- /dev/null +++ b/package-shared/shell/utils/noDatabaseDbHandler.d.ts @@ -0,0 +1,2 @@ +declare function _exports(queryString: string): Promise; +export = _exports; diff --git a/package-shared/shell/utils/supplementTable.d.ts b/package-shared/shell/utils/supplementTable.d.ts new file mode 100644 index 0000000..aadf5c6 --- /dev/null +++ b/package-shared/shell/utils/supplementTable.d.ts @@ -0,0 +1,4 @@ +declare function _exports({ tableInfoArray }: { + tableInfoArray: import("../../types").DSQL_FieldSchemaType[]; +}): import("../../types").DSQL_FieldSchemaType[]; +export = _exports; diff --git a/package-shared/shell/utils/updateTable.d.ts b/package-shared/shell/utils/updateTable.d.ts new file mode 100644 index 0000000..68e6cf7 --- /dev/null +++ b/package-shared/shell/utils/updateTable.d.ts @@ -0,0 +1,15 @@ +declare function _exports({ dbFullName, tableName, tableInfoArray, userId, dbSchema, tableIndexes, tableSchema, clone, childDb, tableIndex, tableNameFull, recordedDbEntry, }: { + dbFullName: string; + tableName: string; + tableSchema: import("../../types").DSQL_TableSchemaType; + tableNameFull?: string; + tableInfoArray: import("../../types").DSQL_FieldSchemaType[]; + userId?: number | string | null; + dbSchema: import("../../types").DSQL_DatabaseSchemaType[]; + tableIndexes?: import("../../types").DSQL_IndexSchemaType[]; + clone?: boolean; + tableIndex?: number; + childDb?: boolean; + recordedDbEntry?: any; +}): Promise; +export = _exports; diff --git a/package-shared/shell/utils/varDatabaseDbHandler.d.ts b/package-shared/shell/utils/varDatabaseDbHandler.d.ts new file mode 100644 index 0000000..d21b4c2 --- /dev/null +++ b/package-shared/shell/utils/varDatabaseDbHandler.d.ts @@ -0,0 +1,7 @@ +declare function _exports({ queryString, queryValuesArray, database, tableSchema, }: { + queryString: string; + queryValuesArray?: string[]; + database?: string; + tableSchema?: import("../../types").DSQL_TableSchemaType; +}): Promise; +export = _exports; diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index 8f454bf..77c873b 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -1,14 +1,6 @@ -import type { IncomingMessage, ServerResponse } from "http"; - +import type { ServerResponse } from "http"; import { Editor } from "tinymce"; export type DSQL_DatabaseFullName = string; - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// - export interface DSQL_DatabaseSchemaType { dbName: string; dbSlug: string; @@ -21,13 +13,9 @@ export interface DSQL_DatabaseSchemaType { childDatabaseDbFullName?: string; updateData?: boolean; } - export interface DSQL_ChildrenDatabaseObject { dbFullName: string; } - -//////////////////////////////////////// - export interface DSQL_TableSchemaType { tableName: string; tableFullName: string; @@ -41,15 +29,11 @@ export interface DSQL_TableSchemaType { childTableDbFullName?: string; tableNameOld?: string; } - export interface DSQL_ChildrenTablesType { dbNameFull: string; tableName: string; tableNameFull?: string; } - -//////////////////////////////////////// - export interface DSQL_FieldSchemaType { fieldName?: string; originName?: string; @@ -82,7 +66,6 @@ export interface DSQL_FieldSchemaType { onDeleteLiteral?: string; cssFiles?: string[]; } - export interface DSQL_ForeignKeyType { foreignKeyName?: string; destinationTableName?: string; @@ -91,9 +74,6 @@ export interface DSQL_ForeignKeyType { cascadeDelete?: boolean; cascadeUpdate?: boolean; } - -//////////////////////////////////////// - export interface DSQL_IndexSchemaType { indexName?: string; indexType?: string; @@ -101,12 +81,10 @@ export interface DSQL_IndexSchemaType { alias?: string; newTempIndex?: boolean; } - export interface DSQL_IndexTableFieldType { value: string; dataType: string; } - export interface DSQL_MYSQL_SHOW_INDEXES_Type { Key_name: string; Table: string; @@ -117,9 +95,6 @@ export interface DSQL_MYSQL_SHOW_INDEXES_Type { Index_comment: string; Comment: string; } - -//////////////////////////////////////// - export interface DSQL_MYSQL_SHOW_COLUMNS_Type { Field: string; Type: string; @@ -128,17 +103,11 @@ export interface DSQL_MYSQL_SHOW_COLUMNS_Type { Default: string; Extra: string; } - -//////////////////////////////////////// - export interface DSQL_MYSQL_FOREIGN_KEYS_Type { CONSTRAINT_NAME: string; CONSTRAINT_SCHEMA: string; TABLE_NAME: string; } - -//////////////////////////////////////// - export interface DSQL_MYSQL_user_databases_Type { id: number; user_id: number; @@ -161,7 +130,6 @@ export interface DSQL_MYSQL_user_databases_Type { last_name?: string; email?: string; } - export interface PackageUserLoginRequestBody { encryptionKey: string; payload: any; @@ -175,7 +143,6 @@ export interface PackageUserLoginRequestBody { dbSchema?: DSQL_DatabaseSchemaType; skipPassword?: boolean; } - export interface PackageUserLoginLocalBody { payload: any; additionalFields?: string[]; @@ -187,33 +154,16 @@ export interface PackageUserLoginLocalBody { dbSchema?: DSQL_DatabaseSchemaType; skipPassword?: boolean; } - -type Request = IncomingMessage; - -type Response = ServerResponse; - -type ImageInputFileToBase64FunctionReturn = { - imageBase64: string; - imageBase64Full: string; - imageName: string; - imageSize: number; -}; - export interface GetReqQueryObject { db: string; query: string; queryValues?: string; tableName?: string; } - -type SerializeQueryFnType = (param0: SerializeQueryParams) => string; - +export type SerializeQueryFnType = (param0: SerializeQueryParams) => string; export interface SerializeQueryParams { query: any; } - -// @ts-check - export type DATASQUIREL_LoggedInUser = { id?: number; first_name: string; @@ -253,28 +203,24 @@ export type DATASQUIREL_LoggedInUser = { } & { [key: string]: any; }; - export interface AuthenticatedUser { success: boolean; payload: DATASQUIREL_LoggedInUser | null; msg?: string; userId?: number; } - export interface SuccessUserObject { id: number; first_name: string; last_name: string; email: string; } - export interface AddUserFunctionReturn { success: boolean; payload?: SuccessUserObject | null; msg?: string; sqlResult?: any; } - export interface GoogleIdentityPromptNotification { getMomentType: () => string; getDismissedReason: () => string; @@ -286,7 +232,6 @@ export interface GoogleIdentityPromptNotification { isNotDisplayed: () => boolean; isSkippedMoment: () => boolean; } - export type UserDataPayload = { first_name: string; last_name: string; @@ -296,7 +241,6 @@ export type UserDataPayload = { } & { [key: string]: any; }; - export interface GetUserFunctionReturn { success: boolean; payload: { @@ -312,7 +256,6 @@ export interface GetUserFunctionReturn { verification_status: [number]; } | null; } - export interface ReauthUserFunctionReturn { success: boolean; payload: DATASQUIREL_LoggedInUser | null; @@ -320,12 +263,10 @@ export interface ReauthUserFunctionReturn { userId?: number; token?: string; } - export interface UpdateUserFunctionReturn { success: boolean; payload?: Object[] | string; } - export interface GetReturn { success: boolean; payload?: any; @@ -333,21 +274,16 @@ export interface GetReturn { error?: string; schema?: DSQL_TableSchemaType; } - export interface GetSchemaRequestQuery { database?: string; table?: string; field?: string; user_id?: string | number; } - export interface GetSchemaAPICredentialsParam { key: string; } - -export type GetSchemaAPIParam = GetSchemaRequestQuery & - GetSchemaAPICredentialsParam; - +export type GetSchemaAPIParam = GetSchemaRequestQuery & GetSchemaAPICredentialsParam; export interface PostReturn { success: boolean; payload?: Object[] | string | PostInsertReturn; @@ -355,7 +291,6 @@ export interface PostReturn { error?: any; schema?: DSQL_TableSchemaType; } - export interface PostDataPayload { action: "insert" | "update" | "delete"; table: string; @@ -366,20 +301,17 @@ export interface PostDataPayload { duplicateColumnValue?: string; update?: boolean; } - export interface LocalPostReturn { success: boolean; payload?: any; msg?: string; error?: string; } - export interface LocalPostQueryObject { query: string | PostDataPayload; tableName?: string; queryValues?: string[]; } - export interface PostInsertReturn { fieldCount: number; affectedRows: number; @@ -390,7 +322,6 @@ export interface PostInsertReturn { protocol41: boolean; changedRows: number; } - export interface UserType { id: number; stripe_id?: string; @@ -410,61 +341,47 @@ export interface UserType { csrf_k: string; logged_in_status: boolean; } - export interface ApiKeyDef { name: string; scope: string; date_created: string; apiKeyPayload: string; } - export interface MetricsType { dbCount: number; tablesCount: number; mediaCount: number; apiKeysCount: number; } - export interface DashboardContextType { user?: UserType; databases?: DSQL_MYSQL_user_databases_Type[]; - setTargetDatabase?: React.Dispatch< - React.SetStateAction - >; + setTargetDatabase?: React.Dispatch>; targetDatabase?: DSQL_MYSQL_user_databases_Type; metrics?: MetricsType; } - export interface AddDbContextType { user?: UserType; databases?: DSQL_MYSQL_user_databases_Type[]; dbImage?: string | null | ImageObjectType; - setDbImage?: React.Dispatch< - React.SetStateAction - >; + setDbImage?: React.Dispatch>; query?: any; duplicateDb?: DSQL_MYSQL_user_databases_Type; } - export interface EditDbContextType { user?: UserType; database?: DSQL_MYSQL_user_databases_Type; dbImage?: string | null | ImageObjectType; - setDbImage?: React.Dispatch< - React.SetStateAction - >; + setDbImage?: React.Dispatch>; } - export interface RichTextEditorsRefArray { fieldName: string; ref: React.MutableRefObject; } - export interface JSONTextEditorsRefArray { fieldName: string; ref: React.MutableRefObject; } - export interface TableEntriesContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; @@ -483,7 +400,6 @@ export interface TableEntriesContextType { searchTerm: React.MutableRefObject; entriesCount: number; } - export interface AddEntryContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; @@ -495,7 +411,6 @@ export interface AddEntryContextType { duplicateEntry?: any; confirmedDelegetedUser: any; } - export interface UserDatabasesContextType { user: UserType; users: any[]; @@ -503,14 +418,12 @@ export interface UserDatabasesContextType { setTargetUser: React.Dispatch>; databases: DSQL_MYSQL_user_databases_Type[]; } - export interface SettingsPageContextType { user: UserType; image: any; setImage: React.Dispatch>; activeUser: any; } - export interface MediaFolderPageContextType { user: UserType; media: any[]; @@ -521,53 +434,39 @@ export interface MediaFolderPageContextType { staticHost: string; folder: string; } - export interface TablesContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; tables: MYSQL_user_database_tables_table_def[]; targetTable: MYSQL_user_database_tables_table_def | null; - setTargetTable: React.Dispatch< - React.SetStateAction - >; + setTargetTable: React.Dispatch>; query: any; confirmedDelegetedUser: any; } - export interface EditTableContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; table: DSQL_TableSchemaType; tableFields: DSQL_FieldSchemaType[]; - setTableFields: React.Dispatch< - React.SetStateAction - >; + setTableFields: React.Dispatch>; targetField: DSQL_FieldSchemaType | null; - setTargetField: React.Dispatch< - React.SetStateAction - >; + setTargetField: React.Dispatch>; pageRefresh: number; setPageRefresh: React.Dispatch>; - refreshFieldsListRef: React.MutableRefObject< - React.Dispatch> | undefined - >; + refreshFieldsListRef: React.MutableRefObject> | undefined>; dbSchemaData: DSQL_DatabaseSchemaType[]; query: any; confirmedDelegetedUser: any; } - export interface SingleDatabaseContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; tables: MYSQL_user_database_tables_table_def[]; targetTable: MYSQL_user_database_tables_table_def | null; - setTargetTable: React.Dispatch< - React.SetStateAction - >; + setTargetTable: React.Dispatch>; query: any; confirmedDelegetedUser: any; } - export interface ApiKeysContextType { user: UserType; apiKeys: any[]; @@ -577,7 +476,6 @@ export interface ApiKeysContextType { newApiKey: any | null; setNewApiKey: React.Dispatch>; } - export interface LoginFormContextType { user?: UserType | null; loading: boolean; @@ -585,20 +483,17 @@ export interface LoginFormContextType { alert: string | boolean; setAlert: React.Dispatch>; } - export interface CreateAccountContextType { user?: UserType | null; query: CreateAccountQueryType; invitingUser: any; } - export interface CreateAccountQueryType { invite?: number; database_access?: string; priviledge?: string; email?: string; } - export interface DocsAsidePageObject { id: number; title: string; @@ -606,38 +501,30 @@ export interface DocsAsidePageObject { parent_id?: number; level?: number; } - export interface AllUserUsersContextType { user: UserType; users: MYSQL_delegated_users_table_def[]; targetUser: MYSQL_user_users_table_def | null; - setTargetUser: React.Dispatch< - React.SetStateAction - >; + setTargetUser: React.Dispatch>; databases: DSQL_MYSQL_user_databases_Type[]; pendingInvitations: MYSQL_invitations_table_def[]; pendingInvitationsReceived: any[]; adminUsers: any[]; invitedAccounts: any[]; } - export interface AddSocialLoginContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; query: any; socialLogins: SocialLoginObjectType[]; } - export interface DelegatedDbContextType { user: UserType; users: MYSQL_user_users_table_def[]; targetUser: MYSQL_user_users_table_def | null; - setTargetUser: React.Dispatch< - React.SetStateAction - >; + setTargetUser: React.Dispatch>; database: DSQL_MYSQL_user_databases_Type; } - export interface AddUserUserContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; @@ -645,21 +532,17 @@ export interface AddUserUserContextType { query: any; confirmedDelegetedUser: any; } - export interface UserUsersContextType { user: UserType; users: MYSQL_user_users_table_def[]; targetUser: MYSQL_user_users_table_def; - setTargetUser: React.Dispatch< - React.SetStateAction - >; + setTargetUser: React.Dispatch>; database: DSQL_MYSQL_user_databases_Type; table: DSQL_TableSchemaType; dbSchemaData: DSQL_DatabaseSchemaType[]; query: any; confirmedDelegetedUser: any; } - export interface DatabaseSingleUserContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; @@ -669,77 +552,57 @@ export interface DatabaseSingleUserContextType { query: any; confirmedDelegetedUser: any; } - export interface SingleUserUserContextType { user: UserType; singleUser: MYSQL_user_users_table_def; } - export interface AddUserContextType { user: UserType; users: MYSQL_delegated_users_table_def[]; databases: DSQL_MYSQL_user_databases_Type[]; query: any; } - export interface MediaContextType { user: UserType; media: MYSQL_user_media_table_def[]; targetMedia: MYSQL_user_media_table_def | null; - setTargetMedia: React.Dispatch< - React.SetStateAction - >; + setTargetMedia: React.Dispatch>; folders: string[]; staticHost: string; } - export interface MediaSubFolderContextType { user: UserType; media: MYSQL_user_media_table_def[]; targetMedia: MYSQL_user_media_table_def | null; - setTargetMedia: React.Dispatch< - React.SetStateAction - >; + setTargetMedia: React.Dispatch>; folders: string[]; query: any; folder: string; staticHost: string; } - export interface FieldsContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; table: DSQL_TableSchemaType; dbSchemaData: DSQL_DatabaseSchemaType[]; targetField: DSQL_FieldSchemaType | null; - setTargetField: React.Dispatch< - React.SetStateAction - >; - refreshFieldsListRef: React.MutableRefObject< - React.Dispatch> | undefined - >; + setTargetField: React.Dispatch>; + refreshFieldsListRef: React.MutableRefObject> | undefined>; tableFields: DSQL_FieldSchemaType[]; - setTableFields: React.Dispatch< - React.SetStateAction - >; + setTableFields: React.Dispatch>; updateTableAfterFieldsUpdateFunction: () => void; query: any; confirmedDelegetedUser: any; } - export interface SingleTableContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; table: DSQL_TableSchemaType; tableRecord: MYSQL_user_database_tables_table_def; tableFields: DSQL_FieldSchemaType[]; - setTableFields: React.Dispatch< - React.SetStateAction - >; + setTableFields: React.Dispatch>; tableIndexes: DSQL_IndexSchemaType[]; - setTableIndexes: React.Dispatch< - React.SetStateAction - >; + setTableIndexes: React.Dispatch>; dbSchemaData: DSQL_DatabaseSchemaType[]; entries: any[]; targetEntry: any; @@ -749,16 +612,11 @@ export interface SingleTableContextType { query: any; confirmedDelegetedUser: any; targetField: DSQL_FieldSchemaType | null; - setTargetField: React.Dispatch< - React.SetStateAction - >; - refreshFieldsListRef: React.MutableRefObject< - React.Dispatch> - >; + setTargetField: React.Dispatch>; + refreshFieldsListRef: React.MutableRefObject>>; updateTableAfterFieldsUpdateFunction: () => void; entriesCount: number; } - export interface SingleEntryContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; @@ -774,25 +632,20 @@ export interface SingleEntryContextType { prevEntry: any; nextEntry: any; } - export interface UserSchemaContextType { user: UserType; dbSchemaData: DSQL_DatabaseSchemaType[]; } - export interface ConnectContextType { user: UserType; query: any; mariadbUserCred: MariaDBUserCredType; mariadbUsers: MYSQL_mariadb_users_table_def[]; targetMariadbUser: MYSQL_mariadb_users_table_def | null; - setTargetMariadbUser: React.Dispatch< - React.SetStateAction - >; + setTargetMariadbUser: React.Dispatch>; refresh: number; setRefresh: React.Dispatch>; } - export interface MYSQL_mariadb_users_table_def { id?: number; user_id?: number; @@ -808,43 +661,31 @@ export interface MYSQL_mariadb_users_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export interface DbContextType { user?: UserType; databases?: DSQL_MYSQL_user_databases_Type[]; targetDatabase?: DSQL_MYSQL_user_databases_Type; - setTargetDatabase?: React.Dispatch< - React.SetStateAction - >; + setTargetDatabase?: React.Dispatch>; } - export interface MariaDBUserCredType { mariadb_user?: string; mariadb_host?: string; mariadb_pass?: string; } - export interface AddTableContextType { user: UserType; dbSchemaData: DSQL_DatabaseSchemaType[]; database: DSQL_MYSQL_user_databases_Type; tables: DSQL_TableSchemaType[]; tableFields: DSQL_FieldSchemaType[]; - setTableFields: React.Dispatch< - React.SetStateAction - >; + setTableFields: React.Dispatch>; targetField: DSQL_FieldSchemaType | null; - setTargetField: React.Dispatch< - React.SetStateAction - >; + setTargetField: React.Dispatch>; pageRefresh: number | null; setPageRefresh: React.Dispatch>; - refreshFieldsListRef: React.MutableRefObject< - React.Dispatch> - >; + refreshFieldsListRef: React.MutableRefObject>>; query: any; } - export interface DbSchemaContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; @@ -853,7 +694,6 @@ export interface DbSchemaContextType { dbSchemaData: DSQL_DatabaseSchemaType[]; tables: any[]; } - export interface DbShellContextType { user?: UserType; database?: DSQL_MYSQL_user_databases_Type; @@ -862,14 +702,12 @@ export interface DbShellContextType { dbSchemaData?: DSQL_DatabaseSchemaType[]; tables?: any[]; } - export interface DbConnectContextType { user: UserType; database: DSQL_MYSQL_user_databases_Type; targetDbSchema: DSQL_DatabaseSchemaType; query: any; } - export interface ImageObjectType { imageName?: string; mimeType?: string; @@ -878,7 +716,6 @@ export interface ImageObjectType { imageBase64?: string; imageBase64Full?: string; } - export interface FileObjectType { fileName?: string; private?: boolean; @@ -887,7 +724,6 @@ export interface FileObjectType { fileBase64?: string; fileBase64Full?: string; } - export interface SocialLoginObjectType { platform?: string; paradigm?: string; @@ -898,7 +734,6 @@ export interface SocialLoginObjectType { domain2?: string; domain3?: string; } - export interface DbConnectType { url: string; key: string; @@ -908,7 +743,6 @@ export interface DbConnectType { remoteDbs?: DSQL_DatabaseSchemaType[]; targetDb?: DSQL_DatabaseSchemaType; } - export interface MYSQL_MediaType { id?: number; user_id?: number; @@ -922,20 +756,17 @@ export interface MYSQL_MediaType { size?: string; private?: string; } - export interface UserFileObject { title?: string; path?: string; data?: string; } - export interface UserFileObject2 { type?: string; name?: string; root?: string; content?: UserFileObject2[]; } - export interface MYSQL_user_users_table_def { id?: number; user_id?: number; @@ -973,7 +804,6 @@ export interface MYSQL_user_users_table_def { inviteeEmail?: string; inviteeImage?: string; } - export interface MYSQL_user_database_tables_table_def { id?: number; user_id?: number; @@ -992,7 +822,6 @@ export interface MYSQL_user_database_tables_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export interface MYSQL_user_media_table_def { id?: number; user_id?: number; @@ -1014,7 +843,6 @@ export interface MYSQL_user_media_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export interface MYSQL_delegated_users_table_def { id?: number; user_id?: number; @@ -1028,7 +856,6 @@ export interface MYSQL_delegated_users_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export interface MYSQL_invitations_table_def { id?: number; inviting_user_id?: number; @@ -1044,7 +871,6 @@ export interface MYSQL_invitations_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export interface MYSQL_docs_pages_table_def { id?: number; title?: string; @@ -1062,7 +888,6 @@ export interface MYSQL_docs_pages_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export interface MYSQL_delegated_user_tables_table_def { id?: number; delegated_user_id?: number; @@ -1077,7 +902,6 @@ export interface MYSQL_delegated_user_tables_table_def { date_updated_code?: number; date_updated_timestamp?: string; } - export type ApiKeyObject = { user_id: string | number; full_access?: boolean; @@ -1086,7 +910,6 @@ export type ApiKeyObject = { target_database?: string; target_table?: string; }; - export type AddApiKeyRequestBody = { api_key_name: string; api_key_slug: string; @@ -1094,55 +917,34 @@ export type AddApiKeyRequestBody = { target_database?: string; target_table?: string; }; - -export type CheckApiCredentialsFn = ( - param: CheckApiCredentialsFnParam -) => ApiKeyObject | null | undefined; +export type CheckApiCredentialsFn = (param: CheckApiCredentialsFnParam) => ApiKeyObject | null | undefined; export type CheckApiCredentialsFnParam = { key?: string; database?: string; table?: string; user_id?: string | number; }; - -export type FetchApiFn = ( - url: string, - options?: FetchApiOptions, - contentType?: "json" | "text" | "html" | "blob" | "file" -) => Promise; - +export type FetchApiFn = (url: string, options?: FetchApiOptions, contentType?: "json" | "text" | "html" | "blob" | "file") => Promise; export type FetchApiOptions = RequestInit & { - method: - | "POST" - | "GET" - | "DELETE" - | "PUT" - | "PATCH" - | "post" - | "get" - | "delete" - | "put" - | "patch"; + method: "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "post" | "get" | "delete" | "put" | "patch"; body?: object | string; headers?: FetchHeader; - query?: { [key: string]: any }; + query?: { + [key: string]: any; + }; }; - export type AuthCsrfHeaderName = "x-csrf-auth"; - type FetchHeader = HeadersInit & { [key in AuthCsrfHeaderName]?: string | null; } & { [key: string]: any; }; - export type FetchApiReturn = { success: boolean; payload: any; msg?: string; [key: string]: any; }; - export type ServerQueryParam = { selectFields?: string[]; query?: ServerQueryQueryObject; @@ -1160,17 +962,16 @@ export type ServerQueryParam = { } & { [key: string]: any; }; - -export type ServerQueryQueryObject = - { - [key in keyof T]: { - value: string | string[]; - operator?: "AND" | "OR"; - equality?: "EQUAL" | "LIKE"; - tableName?: string; - }; +export type ServerQueryQueryObject = { + [key in keyof T]: { + value: string | string[]; + operator?: "AND" | "OR"; + equality?: "EQUAL" | "LIKE"; + tableName?: string; }; - +}; export type FetchDataParams = { path: string; method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"; @@ -1178,32 +979,23 @@ export type FetchDataParams = { query?: AuthFetchQuery; tableName?: string; }; - export type AuthFetchQuery = ServerQueryParam & { [key: string]: any; }; - -export type ServerQueryParamsJoin< - Table extends string = string, - Field extends object = { [key: string]: any } -> = { +export type ServerQueryParamsJoin = { joinType: "INNER JOIN" | "JOIN" | "LEFT JOIN" | "RIGHT JOIN"; tableName: Table; - match?: - | ServerQueryParamsJoinMatchObject - | ServerQueryParamsJoinMatchObject[]; - selectFields?: ( - | keyof Field - | { - field: keyof Field; - alias?: string; - } - )[]; + match?: ServerQueryParamsJoinMatchObject | ServerQueryParamsJoinMatchObject[]; + selectFields?: (keyof Field | { + field: keyof Field; + alias?: string; + })[]; }; - -export type ServerQueryParamsJoinMatchObject< - Field extends object = { [key: string]: any } -> = { +export type ServerQueryParamsJoinMatchObject = { /** Field name from the **Root Table** */ source: string | ServerQueryParamsJoinMatchSourceTargetObject; /** Field name from the **Join Table** */ @@ -1211,22 +1003,17 @@ export type ServerQueryParamsJoinMatchObject< /** A literal value: No source and target Needed! */ targetLiteral?: string; }; - export type ServerQueryParamsJoinMatchSourceTargetObject = { tableName: string; fieldName: string; }; - export type SqlGeneratorFn = (Param0: { genObject?: ServerQueryParam; tableName: string; -}) => - | { - string: string; - values: string[]; - } - | undefined; - +}) => { + string: string; + values: string[]; +} | undefined; export type ApiConnectBody = { url: string; key: string; @@ -1235,7 +1022,6 @@ export type ApiConnectBody = { type: "pull" | "push"; user_id?: string | number; }; - export type SuUserType = { email: string; password: string; @@ -1243,7 +1029,6 @@ export type SuUserType = { logged_in_status: boolean; date: number; }; - export type MariadbRemoteServerObject = { host: string; port: number; @@ -1251,13 +1036,11 @@ export type MariadbRemoteServerObject = { loadBalanced?: boolean; users?: MariadbRemoteServerUserObject[]; }; - export type MariadbRemoteServerUserObject = { name: string; password: string; host: string; }; - export type APILoginFunctionParams = { encryptionKey: string; email: string; @@ -1278,21 +1061,14 @@ export type APILoginFunctionReturn = { payload?: DATASQUIREL_LoggedInUser | null; userId?: number | string; }; -export type APILoginFunction = ( - params: APILoginFunctionParams -) => Promise; - +export type APILoginFunction = (params: APILoginFunctionParams) => Promise; export type APICreateUserFunctionParams = { encryptionKey: string; payload: any; database: string; userId?: string | number; }; - -export type APICreateUserFunction = ( - params: APICreateUserFunctionParams -) => Promise; - +export type APICreateUserFunction = (params: APICreateUserFunctionParams) => Promise; /** * API Get User Function */ @@ -1301,11 +1077,7 @@ export type APIGetUserFunctionParams = { dbFullName: string; userId: string | number; }; - -export type APIGetUserFunction = ( - params: APIGetUserFunctionParams -) => Promise; - +export type APIGetUserFunction = (params: APIGetUserFunctionParams) => Promise; /** * API Google Login Function */ @@ -1314,18 +1086,15 @@ export type APIGoogleLoginFunctionParams = { token: string; database: string; userId: string | number; - additionalFields?: { [key: string]: any }; + additionalFields?: { + [key: string]: any; + }; res: any; }; - export type APIGoogleLoginFunctionReturn = { dsqlUserId?: number | string; } & HandleSocialDbFunctionReturn; - -export type APIGoogleLoginFunction = ( - params: APIGoogleLoginFunctionParams -) => Promise; - +export type APIGoogleLoginFunction = (params: APIGoogleLoginFunctionParams) => Promise; /** * Handle Social DB Function */ @@ -1340,7 +1109,6 @@ export type HandleSocialDbFunctionParams = { supEmail?: string; additionalFields?: object; }; - export type HandleSocialDbFunctionReturn = { success: boolean; user?: null; @@ -1352,7 +1120,6 @@ export type HandleSocialDbFunctionReturn = { newUser?: any; error?: any; } | null; - /** * Handle Social User Auth on Datasquirel Database * ============================================================================== @@ -1366,13 +1133,13 @@ export type HandleSocialDbFunctionReturn = { * * @returns {Promise} - Response object */ -export type HandleSocialDbFunction = ( - params: HandleSocialDbFunctionParams -) => Promise; - +export type HandleSocialDbFunction = (params: HandleSocialDbFunctionParams) => Promise; export type ApiReauthUserReturn = { success: boolean; - payload?: { [key: string]: any } | null; + payload?: { + [key: string]: any; + } | null; msg?: string; userId?: string | number; }; +export {}; diff --git a/package-shared/types/index.ts b/package-shared/types/index.ts index 8f454bf..0b2714c 100644 --- a/package-shared/types/index.ts +++ b/package-shared/types/index.ts @@ -206,7 +206,7 @@ export interface GetReqQueryObject { tableName?: string; } -type SerializeQueryFnType = (param0: SerializeQueryParams) => string; +export type SerializeQueryFnType = (param0: SerializeQueryParams) => string; export interface SerializeQueryParams { query: any; diff --git a/package-shared/utils/backend/global-db/LOCAL_DB_HANDLER.d.ts b/package-shared/utils/backend/global-db/LOCAL_DB_HANDLER.d.ts new file mode 100644 index 0000000..631b49a --- /dev/null +++ b/package-shared/utils/backend/global-db/LOCAL_DB_HANDLER.d.ts @@ -0,0 +1,10 @@ +export = LOCAL_DB_HANDLER; +/** + * DSQL user read-only DB handler + * @param {object} params + * @param {string} params.paradigm + * @param {string} params.database + * @param {string} params.queryString + * @param {string[]} [params.queryValues] + */ +declare function LOCAL_DB_HANDLER(...args: any[]): Promise; diff --git a/package-shared/utils/backend/global-db/NO_DB_HANDLER.d.ts b/package-shared/utils/backend/global-db/NO_DB_HANDLER.d.ts new file mode 100644 index 0000000..32ba1da --- /dev/null +++ b/package-shared/utils/backend/global-db/NO_DB_HANDLER.d.ts @@ -0,0 +1,12 @@ +export = NO_DB_HANDLER; +/** + * DSQL user read-only DB handler + * @param {object} params + * @param {string} params.paradigm + * @param {string} params.database + * @param {string} params.queryString + * @param {string[]} [params.queryValues] + */ declare function NO_DB_HANDLER(...args: any[]): Promise | { + success: boolean; + error: any; +}; diff --git a/package-shared/utils/camelJoinedtoCamelSpace.d.ts b/package-shared/utils/camelJoinedtoCamelSpace.d.ts new file mode 100644 index 0000000..809740c --- /dev/null +++ b/package-shared/utils/camelJoinedtoCamelSpace.d.ts @@ -0,0 +1,12 @@ +export = camelJoinedtoCamelSpace; +/** + * Convert Camel Joined Text to Camel Spaced Text + * ============================================================================== + * @description this function takes a camel cased text without spaces, and returns + * a camel-case-spaced text + * + * @param {string} text - text string without spaces + * + * @returns {string | null} + */ +declare function camelJoinedtoCamelSpace(text: string): string | null; diff --git a/package-shared/utils/ejson.d.ts b/package-shared/utils/ejson.d.ts new file mode 100644 index 0000000..be44f6a --- /dev/null +++ b/package-shared/utils/ejson.d.ts @@ -0,0 +1,19 @@ +/** + * + * @param {string | null | number} string + * @param {(this: any, key: string, value: any) => any} [reviver] + * @returns {Object | Object[] | undefined} + */ +export function parse(string: string | null | number, reviver?: (this: any, key: string, value: any) => any): { + [x: string]: any; +} | { + [x: string]: any; +}[] | undefined; +/** + * + * @param {any} value + * @param {((this: any, key: string, value: any) => any) | null} [replacer] + * @param { string | number } [space] + * @returns {string | undefined} + */ +export function stringify(value: any, replacer?: ((this: any, key: string, value: any) => any) | null, space?: string | number): string | undefined; diff --git a/package.json b/package.json index 9f7d748..581a047 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dsql-dump": "./engine/dump.js" }, "scripts": { - "compile": "tsc --declaration --allowJs --emitDeclarationOnly --resolveJsonModule index.js", + "compile": "find . -name \"*.d.ts\" -type f -not -path \"./node_modules/*\" -delete && tsc --declaration --allowJs --emitDeclarationOnly --resolveJsonModule index.js", "compile:full": "rm -rf dist && tsc --declaration --allowJs --outDir dist --emitDeclarationOnly --resolveJsonModule index.js && cat ./dist/index.d.ts > ./index.d.ts" }, "repository": { diff --git a/publish.sh b/publish.sh index 145a31d..2e7085f 100755 --- a/publish.sh +++ b/publish.sh @@ -6,4 +6,5 @@ else msg="$1" fi -npm run compile && git add . && git commit -m "$msg" && git push && npm publish +npm run compile +git add . && git commit -m "$msg" && git push && npm publish diff --git a/users/add-user.d.ts b/users/add-user.d.ts index ddaad75..78353c0 100644 --- a/users/add-user.d.ts +++ b/users/add-user.d.ts @@ -1,28 +1,28 @@ export = addUser; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** * Add User to Database - * ============================================================================== + * ============================================ * @async * - * @param {object} props - Single object passed - * @param {string} props.key - FULL ACCESS API Key - * @param {string} props.database - Database Name - * @param {import("../package-shared/types").UserDataPayload} props.payload - User Data Payload - * @param {string} props.encryptionKey - * @param {string} [props.encryptionSalt] + * @param {object} param - Single object passed + * @param {string} param.key - FULL ACCESS API Key + * @param {string} param.database - Database Name + * @param {import("../package-shared/types").UserDataPayload} param.payload - User Data Payload + * @param {string} param.encryptionKey + * @param {string} [param.encryptionSalt] + * @param {string | number} [param.user_id] + * @param {string | number} param.apiUserId + * @param {boolean} [param.useLocal] * * @returns { Promise } */ -declare function addUser({ key, payload, database, encryptionKey, encryptionSalt, }: { +declare function addUser({ key, payload, database, encryptionKey, user_id, useLocal, apiUserId, }: { key: string; database: string; payload: import("../package-shared/types").UserDataPayload; encryptionKey: string; encryptionSalt?: string; + user_id?: string | number; + apiUserId: string | number; + useLocal?: boolean; }): Promise; diff --git a/users/login-user.d.ts b/users/login-user.d.ts index d9d0031..2d301a8 100644 --- a/users/login-user.d.ts +++ b/users/login-user.d.ts @@ -1,10 +1,4 @@ export = loginUser; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** * Login A user * ============================================================================== @@ -26,10 +20,13 @@ export = loginUser; * @param {string} [params.email_login_code] - Email login 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.user_id] - User ID + * @param {boolean} [params.skipPassword] + * @param {boolean} [params.useLocal] * * @returns { Promise} */ -declare function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, }: { +declare function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, useLocal, }: { key: string; database: string; payload: { @@ -45,5 +42,8 @@ declare function loginUser({ key, payload, database, additionalFields, response, email_login_code?: string; temp_code_field?: string; token?: boolean; + user_id?: boolean; + skipPassword?: boolean; + useLocal?: boolean; }): Promise; import http = require("http"); diff --git a/users/reauth-user.d.ts b/users/reauth-user.d.ts index 2766e3c..22adde0 100644 --- a/users/reauth-user.d.ts +++ b/users/reauth-user.d.ts @@ -21,10 +21,11 @@ export = reauthUser; * @param {String} params.encryptionSalt - Encryption Salt * @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 {boolean} [params.user_id] - User ID * * @returns { Promise } */ -declare function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, token, }: { +declare function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, token, user_id, }: { key: string; database: string; response: http.ServerResponse; @@ -34,5 +35,6 @@ declare function reauthUser({ key, database, response, request, level, encryptio encryptionSalt: string; additionalFields?: string[]; token?: string; + user_id?: boolean; }): Promise; import http = require("http"); diff --git a/users/send-email-code.d.ts b/users/send-email-code.d.ts index a691831..e877a24 100644 --- a/users/send-email-code.d.ts +++ b/users/send-email-code.d.ts @@ -23,10 +23,11 @@ export = sendEmailCode; * @param {string} [params.mail_password] * @param {number} [params.mail_port] * @param {string} [params.sender] + * @param {boolean} [params.user_id] - User ID * * @returns { Promise} */ -declare function sendEmailCode({ key, email, database, encryptionKey, encryptionSalt, temp_code_field, mail_domain, mail_password, mail_username, mail_port, sender, }: { +declare function sendEmailCode({ key, email, database, encryptionKey, encryptionSalt, temp_code_field, mail_domain, mail_password, mail_username, mail_port, sender, user_id, }: { key: string; database: string; email: string; @@ -39,5 +40,6 @@ declare function sendEmailCode({ key, email, database, encryptionKey, encryption mail_password?: string; mail_port?: number; sender?: string; + user_id?: boolean; }): Promise; import http = require("http"); diff --git a/users/social/github-auth.d.ts b/users/social/github-auth.d.ts index 23a6a8d..cfb13a6 100644 --- a/users/social/github-auth.d.ts +++ b/users/social/github-auth.d.ts @@ -29,10 +29,11 @@ export = githubAuth; * @param {string} params.encryptionKey - Encryption key * @param {string} params.encryptionSalt - Encryption salt * @param {object} [params.additionalFields] - Additional Fields to be added to the user object + * @param {boolean} [params.user_id] - User ID * * @returns { Promise } */ -declare function githubAuth({ key, code, email, database, clientId, clientSecret, response, encryptionKey, encryptionSalt, additionalFields, }: { +declare function githubAuth({ key, code, email, database, clientId, clientSecret, response, encryptionKey, encryptionSalt, additionalFields, user_id, }: { key: string; code: string; email: string | null; @@ -43,6 +44,7 @@ declare function githubAuth({ key, code, email, database, clientId, clientSecret encryptionKey: string; encryptionSalt: string; additionalFields?: object; + user_id?: boolean; }): Promise; declare namespace githubAuth { export { FunctionReturn }; diff --git a/users/social/google-auth.d.ts b/users/social/google-auth.d.ts index 41a7bc2..c8ef006 100644 --- a/users/social/google-auth.d.ts +++ b/users/social/google-auth.d.ts @@ -27,10 +27,13 @@ export = googleAuth; * @param {string} params.encryptionKey - Encryption key * @param {string} params.encryptionSalt - Encryption salt * @param {object} [params.additionalFields] - Additional Fields to be added to the user object + * @param {boolean} [params.user_id] - User ID + * @param {string | number} [params.apiUserID] - Required for Local + * @param {boolean} [params.useLocal] - Whether to use a remote database instead of API * * @returns { Promise } */ -declare function googleAuth({ key, token, database, clientId, response, encryptionKey, encryptionSalt, additionalFields, }: { +declare function googleAuth({ key, token, database, clientId, response, encryptionKey, encryptionSalt, additionalFields, user_id, apiUserID, useLocal, }: { key: string; token: string; database: string; @@ -39,6 +42,9 @@ declare function googleAuth({ key, token, database, clientId, response, encrypti encryptionKey: string; encryptionSalt: string; additionalFields?: object; + user_id?: boolean; + apiUserID?: string | number; + useLocal?: boolean; }): Promise; declare namespace googleAuth { export { FunctionReturn }; diff --git a/users/update-user.d.ts b/users/update-user.d.ts index 6efa0b6..1c4b091 100644 --- a/users/update-user.d.ts +++ b/users/update-user.d.ts @@ -1,24 +1,17 @@ export = updateUser; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** - * ============================================================================== - * Main Function - * ============================================================================== + * # Update User * @async * * @param {object} params - API Key * @param {String} params.key - API Key * @param {String} params.database - Target Database * @param {{ id: number } & Object.} params.payload - User Object: ID is required + * @param {boolean} [params.user_id] - User ID * * @returns { Promise} */ -declare function updateUser({ key, payload, database }: { +declare function updateUser({ key, payload, database, user_id }: { key: string; database: string; payload: { @@ -26,4 +19,5 @@ declare function updateUser({ key, payload, database }: { } & { [x: string]: any; }; + user_id?: boolean; }): Promise; diff --git a/utils/delete-file.d.ts b/utils/delete-file.d.ts index 4334e7a..1cb7cbe 100644 --- a/utils/delete-file.d.ts +++ b/utils/delete-file.d.ts @@ -1,36 +1,30 @@ -export = uploadImage; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ +export = deleteFile; /** * @typedef {Object} FunctionReturn * @property {boolean} success - Did the function run successfully? * @property {{ * urlPath: string, * urlThumbnailPath: string - * }} payload - Payload containing the url for the image and its thumbnail + * } | null} payload - Payload containing the url for the image and its thumbnail * @property {string} [msg] - An optional message */ /** - * ============================================================================== - * Main Function - * ============================================================================== + * # Delete File via API * @async * * @param {Object} params - Single Param object containing params * @param {String} params.key - *FULL ACCESS API Key * @param { string } params.url - File URL + * @param { string | number } [params.user_id] * * @returns { Promise } - Image Url */ -declare function uploadImage({ key, url }: { +declare function deleteFile({ key, url, user_id }: { key: string; url: string; + user_id?: string | number; }): Promise; -declare namespace uploadImage { +declare namespace deleteFile { export { FunctionReturn }; } type FunctionReturn = { @@ -44,7 +38,7 @@ type FunctionReturn = { payload: { urlPath: string; urlThumbnailPath: string; - }; + } | null; /** * - An optional message */ diff --git a/utils/get-schema.d.ts b/utils/get-schema.d.ts index 4966f89..6e44e6b 100644 --- a/utils/get-schema.d.ts +++ b/utils/get-schema.d.ts @@ -1,10 +1,4 @@ export = getSchema; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** * @typedef {Object} GetSchemaReturn * @property {boolean} success - Did the function run successfully? @@ -16,7 +10,7 @@ export = getSchema; * * @returns { Promise } - Return Object */ -declare function getSchema({ key, database, field, table }: import("../package-shared/types").GetSchemaAPIParam): Promise; +declare function getSchema({ key, database, field, table, user_id }: import("../package-shared/types").GetSchemaAPIParam): Promise; declare namespace getSchema { export { GetSchemaReturn }; } diff --git a/utils/get.d.ts b/utils/get.d.ts index 3b27b80..2fe526c 100644 --- a/utils/get.d.ts +++ b/utils/get.d.ts @@ -1,10 +1,4 @@ export = get; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** * Make a get request to Datasquirel API * ============================================================================== @@ -16,21 +10,17 @@ export = get; * @param {string} params.query - SQL Query * @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders * @param {string} [params.tableName] - Name of the table to query + * @param {boolean} [params.useLocal] - Whether to use a remote database instead of API + * @param {boolean} [params.user_id] - User ID * * @returns { Promise } - Return Object */ -declare function get({ - key, - db, - query, - queryValues, - tableName, - useLocal, -}: { +declare function get({ key, db, query, queryValues, tableName, useLocal, user_id, }: { key?: string; db?: string; query: string; queryValues?: string[]; tableName?: string; useLocal?: boolean; + user_id?: boolean; }): Promise; diff --git a/utils/post.d.ts b/utils/post.d.ts index 94d48e4..2377d8c 100644 --- a/utils/post.d.ts +++ b/utils/post.d.ts @@ -1,13 +1,6 @@ export = post; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** - * Make a post request to Datasquirel API - * ============================================================================== + * # Make a post request to Datasquirel API * @async * * @param {Object} params - Single object passed @@ -16,21 +9,17 @@ export = post; * @param {import("../package-shared/types").PostDataPayload | string} params.query - SQL query String or Request Object * @param {any[]} [params.queryValues] - Query Values if using "?" placeholders * @param {string} [params.tableName] - Name of the table to query + * @param {boolean} [params.useLocal] - Whether to use a remote database instead of API + * @param {boolean} [params.user_id] - User ID * * @returns { Promise } - Return Object */ -declare function post({ - key, - query, - queryValues, - database, - tableName, - useLocal, -}: { +declare function post({ key, query, queryValues, database, tableName, useLocal, user_id, }: { key?: string; database?: string; query: import("../package-shared/types").PostDataPayload | string; queryValues?: any[]; tableName?: string; useLocal?: boolean; + user_id?: boolean; }): Promise; diff --git a/utils/upload-file.d.ts b/utils/upload-file.d.ts index bc470ca..2971671 100644 --- a/utils/upload-file.d.ts +++ b/utils/upload-file.d.ts @@ -1,10 +1,4 @@ export = uploadImage; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** * @typedef {Object} FunctionReturn * @property {boolean} success - Did the function run successfully? @@ -14,9 +8,7 @@ export = uploadImage; * @property {string} [msg] - An optional message */ /** - * ============================================================================== - * Main Function - * ============================================================================== + * # Upload File via API * @async * * @param {Object} params - Single Param object containing params @@ -26,12 +18,13 @@ export = uploadImage; * fileName: string, * mimeType?: string, * folder?: string, - * isPrivate?: boolean, + * isPrivate?: boolean * }} params.payload - Image Data Eg. + * @param {boolean} [params.user_id] - User ID * * @returns { Promise } - Return Object */ -declare function uploadImage({ key, payload }: { +declare function uploadImage({ key, payload, user_id }: { key: string; payload: { fileData: string; @@ -40,6 +33,7 @@ declare function uploadImage({ key, payload }: { folder?: string; isPrivate?: boolean; }; + user_id?: boolean; }): Promise; declare namespace uploadImage { export { FunctionReturn }; diff --git a/utils/upload-image.d.ts b/utils/upload-image.d.ts index 980cf23..6227082 100644 --- a/utils/upload-image.d.ts +++ b/utils/upload-image.d.ts @@ -1,10 +1,4 @@ export = uploadImage; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ /** * @typedef {Object} FunctionReturn * @property {boolean} success - Did the function run successfully? @@ -15,9 +9,7 @@ export = uploadImage; * @property {string} [msg] - An optional message */ /** - * ============================================================================== - * Main Function - * ============================================================================== + * # Upload Image via API * @async * * @param {Object} params - Single Param object containing params @@ -30,10 +22,11 @@ export = uploadImage; * folder?: string, * isPrivate?: boolean, * }} params.payload - Image Data Eg. + * @param {boolean} [params.user_id] - User ID * * @returns { Promise } - Return Object */ -declare function uploadImage({ key, payload }: { +declare function uploadImage({ key, payload, user_id }: { key: string; payload: { imageData: string; @@ -43,6 +36,7 @@ declare function uploadImage({ key, payload }: { folder?: string; isPrivate?: boolean; }; + user_id?: boolean; }): Promise; declare namespace uploadImage { export { FunctionReturn };