Updates
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
export type ExportMariaDBDatabaseParam = {
|
||||
dbFullName: string;
|
||||
targetFilePath: string;
|
||||
mariadbUser?: string;
|
||||
mariadbHost?: string;
|
||||
mariadbPass?: string;
|
||||
};
|
||||
export default function exportMariadbDatabase({ dbFullName, targetFilePath, mariadbHost, mariadbPass, mariadbUser, }: ExportMariaDBDatabaseParam): string | Buffer<ArrayBufferLike>;
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
|
||||
*/
|
||||
export default function DB_HANDLER(...args: any[]): Promise<any>;
|
||||
@@ -0,0 +1,10 @@
|
||||
type Param = {
|
||||
paradigm: "Full Access" | "FA" | "Read Only";
|
||||
queryString: string;
|
||||
queryValues?: string[];
|
||||
};
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function DSQL_USER_DB_HANDLER({ paradigm, queryString, queryValues, }: Param): Promise<any>;
|
||||
export {};
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function LOCAL_DB_HANDLER(...args: any[]): Promise<any>;
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function NO_DB_HANDLER(...args: any[]): Promise<unknown> | {
|
||||
success: boolean;
|
||||
error: any;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* # Root DB handler
|
||||
*/
|
||||
export default function ROOT_DB_HANDLER(...args: any[]): Promise<unknown> | {
|
||||
success: boolean;
|
||||
error: any;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
type Return = string | (import("tls").SecureContextOptions & {
|
||||
rejectUnauthorized?: boolean | undefined;
|
||||
}) | undefined;
|
||||
/**
|
||||
* # Grall SSL
|
||||
*/
|
||||
export default function grabDbSSL(): Return;
|
||||
export {};
|
||||
@@ -0,0 +1,8 @@
|
||||
export type ExportMariaDBDatabaseParam = {
|
||||
dbFullName: string;
|
||||
targetFilePath: string;
|
||||
mariadbUser?: string;
|
||||
mariadbHost?: string;
|
||||
mariadbPass?: string;
|
||||
};
|
||||
export default function importMariadbDatabase({ dbFullName, targetFilePath, mariadbHost, mariadbPass, mariadbUser, }: ExportMariaDBDatabaseParam): Promise<string | Buffer<ArrayBufferLike>>;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { DATASQUIREL_LoggedInUser, UserType } from "../../../types";
|
||||
type Param = {
|
||||
user?: DATASQUIREL_LoggedInUser | UserType;
|
||||
userId?: string | number | null;
|
||||
appDir?: string;
|
||||
};
|
||||
export default function grabDirNames(param?: Param): {
|
||||
appDir: string;
|
||||
schemasDir: string;
|
||||
userDirPath: string | undefined;
|
||||
mainShemaJSONFilePath: string;
|
||||
mainDbTypeDefFile: string;
|
||||
tempDirName: string;
|
||||
defaultTableFieldsJSONFilePath: string;
|
||||
usersSchemaDir: string;
|
||||
userSchemaMainJSONFilePath: string | undefined;
|
||||
userPrivateMediaDir: string | undefined;
|
||||
userPrivateExportsDir: string | undefined;
|
||||
userPrivateSQLExportsDir: string | undefined;
|
||||
userPrivateTempSQLExportsDir: string | undefined;
|
||||
userPrivateTempJSONSchemaFilePath: string | undefined;
|
||||
userPrivateDbExportZipFileName: string;
|
||||
userPrivateDbExportZipFilePath: string | undefined;
|
||||
userPrivateDbImportZipFileName: string;
|
||||
userPrivateDbImportZipFilePath: string | undefined;
|
||||
dbNginxLoadBalancerConfigFile: string;
|
||||
dockerComposeFile: string;
|
||||
testDockerComposeFile: string;
|
||||
extraDockerComposeFile: string;
|
||||
siteSetupFile: string;
|
||||
envFile: string;
|
||||
testEnvFile: string;
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,6 @@
|
||||
type Param = {
|
||||
str: string;
|
||||
userId: string | number;
|
||||
};
|
||||
export default function replaceDatasquirelDbName({ str, userId, }: Param): string;
|
||||
export {};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { IncomingMessage } from "http";
|
||||
/**
|
||||
* Parse request cookies
|
||||
* ===================================================
|
||||
*
|
||||
* @description This function takes in a request object and
|
||||
* returns the cookies as a JS object
|
||||
*/
|
||||
export default function parseCookies({ request, cookieString, }: {
|
||||
request?: IncomingMessage & {
|
||||
[s: string]: any;
|
||||
};
|
||||
cookieString?: string;
|
||||
}): {
|
||||
[s: string]: string;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export default function camelJoinedtoCamelSpace(text: string): string | null;
|
||||
@@ -0,0 +1,6 @@
|
||||
type Param = {
|
||||
dbContext?: "Master" | "Dsql User";
|
||||
dbFullName?: string;
|
||||
};
|
||||
export default function checkIfIsMaster({ dbContext, dbFullName }: Param): boolean;
|
||||
export {};
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
declare const consoleColors: {
|
||||
Reset: string;
|
||||
Bright: string;
|
||||
Dim: string;
|
||||
Underscore: string;
|
||||
Blink: string;
|
||||
Reverse: string;
|
||||
Hidden: string;
|
||||
FgBlack: string;
|
||||
FgRed: string;
|
||||
FgGreen: string;
|
||||
FgYellow: string;
|
||||
FgBlue: string;
|
||||
FgMagenta: string;
|
||||
FgCyan: string;
|
||||
FgWhite: string;
|
||||
FgGray: string;
|
||||
BgBlack: string;
|
||||
BgRed: string;
|
||||
BgGreen: string;
|
||||
BgYellow: string;
|
||||
BgBlue: string;
|
||||
BgMagenta: string;
|
||||
BgCyan: string;
|
||||
BgWhite: string;
|
||||
BgGray: string;
|
||||
};
|
||||
export default consoleColors;
|
||||
export declare const ccol: {
|
||||
Reset: string;
|
||||
Bright: string;
|
||||
Dim: string;
|
||||
Underscore: string;
|
||||
Blink: string;
|
||||
Reverse: string;
|
||||
Hidden: string;
|
||||
FgBlack: string;
|
||||
FgRed: string;
|
||||
FgGreen: string;
|
||||
FgYellow: string;
|
||||
FgBlue: string;
|
||||
FgMagenta: string;
|
||||
FgCyan: string;
|
||||
FgWhite: string;
|
||||
FgGray: string;
|
||||
BgBlack: string;
|
||||
BgRed: string;
|
||||
BgGreen: string;
|
||||
BgYellow: string;
|
||||
BgBlue: string;
|
||||
BgMagenta: string;
|
||||
BgCyan: string;
|
||||
BgWhite: string;
|
||||
BgGray: string;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||
import { DsqlCrudParam, PostReturn } from "../../types";
|
||||
export default function dsqlCrud<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ action, data, table, targetId, query, sanitize, debug, }: DsqlCrudParam<T>): Promise<(PostReturn & {
|
||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||
}) | null>;
|
||||
@@ -0,0 +1,21 @@
|
||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||
import { DsqlMethodCrudParam, ServerQueryParam } from "../../types";
|
||||
export type APIDataCrudQuery = ServerQueryParam & {
|
||||
page?: number;
|
||||
};
|
||||
export type CRUDResponseObject<P extends any = any> = {
|
||||
success: boolean;
|
||||
payload?: P;
|
||||
msg?: string;
|
||||
error?: string;
|
||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||
};
|
||||
export default function dsqlMethodCrud<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}, P extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ method, tableName, addUser, user, extraData, transformData, existingData, body, query, targetId, sanitize, transformQuery, debug, }: DsqlMethodCrudParam<T>): Promise<CRUDResponseObject<P>>;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ServerlessMysql } from "serverless-mysql";
|
||||
type QueryObject = {
|
||||
query: string;
|
||||
values?: (string | number | undefined)[];
|
||||
};
|
||||
type Return<ReturnType = any> = ReturnType | null;
|
||||
/**
|
||||
* # Run Query From MySQL Connection
|
||||
* @description Run a query from a pre-existing MySQL/Mariadb Connection
|
||||
* setup with `serverless-mysql` npm module
|
||||
*/
|
||||
export default function connDbHandler<ReturnType = any>(
|
||||
/**
|
||||
* ServerlessMySQL Connection Object
|
||||
*/
|
||||
conn?: ServerlessMysql,
|
||||
/**
|
||||
* String Or `QueryObject` Array
|
||||
*/
|
||||
query?: QueryObject["query"] | QueryObject[],
|
||||
/**
|
||||
* Array of Values to Sanitize and Inject
|
||||
*/
|
||||
values?: QueryObject["values"]): Promise<Return<ReturnType>>;
|
||||
export {};
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* # Convert Serialized Query back to object
|
||||
*/
|
||||
export default function deserializeQuery(query: string | {
|
||||
[s: string]: any;
|
||||
}): {
|
||||
[s: string]: any;
|
||||
};
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* # EJSON parse string
|
||||
*/
|
||||
declare function parse(string: string | null | number, reviver?: (this: any, key: string, value: any) => any): {
|
||||
[s: string]: any;
|
||||
} | {
|
||||
[s: string]: any;
|
||||
}[] | undefined;
|
||||
/**
|
||||
* # EJSON stringify object
|
||||
*/
|
||||
declare function stringify(value: any, replacer?: ((this: any, key: string, value: any) => any) | null, space?: string | number): string | undefined;
|
||||
declare const EJSON: {
|
||||
parse: typeof parse;
|
||||
stringify: typeof stringify;
|
||||
};
|
||||
export default EJSON;
|
||||
+1
@@ -0,0 +1 @@
|
||||
export default function emptyDirectory(dir: string): void;
|
||||
@@ -0,0 +1,6 @@
|
||||
import mysql from "mysql";
|
||||
/**
|
||||
* # End MYSQL Connection
|
||||
*/
|
||||
declare function endConnection(connection: mysql.Connection): void;
|
||||
export default endConnection;
|
||||
@@ -0,0 +1,21 @@
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/**
|
||||
* # Generate SQL text for Field
|
||||
*/
|
||||
export default function generateColumnDescription({ columnData, primaryKeySet, }: {
|
||||
columnData: import("../types").DSQL_FieldSchemaType;
|
||||
primaryKeySet?: boolean;
|
||||
}): {
|
||||
fieldEntryText: string;
|
||||
newPrimaryKeySet: boolean;
|
||||
};
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
/** ****************************************************************************** */
|
||||
@@ -0,0 +1 @@
|
||||
export default function grabCookieExpiryDate(): string;
|
||||
@@ -0,0 +1,9 @@
|
||||
type Param = {
|
||||
dbName: string;
|
||||
userId?: string | number;
|
||||
};
|
||||
/**
|
||||
* # Grab Database Full Name
|
||||
*/
|
||||
export default function grabDbFullName({ dbName, userId }: Param): string;
|
||||
export {};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ServerlessMysql } from "serverless-mysql";
|
||||
type Param = {
|
||||
/**
|
||||
* Read Only?
|
||||
*/
|
||||
ro?: boolean;
|
||||
/**
|
||||
* Full Access?
|
||||
*/
|
||||
fa?: boolean;
|
||||
/**
|
||||
* No Database Connection
|
||||
*/
|
||||
noDb?: boolean;
|
||||
/**
|
||||
* Is this a local connection?
|
||||
*/
|
||||
local?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnection(param?: Param): ServerlessMysql;
|
||||
export {};
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import https from "https";
|
||||
import http from "http";
|
||||
type GrabHostNamesReturn = {
|
||||
host: string;
|
||||
port: number | string;
|
||||
scheme: typeof http | typeof https;
|
||||
user_id: string | number;
|
||||
};
|
||||
type Param = {
|
||||
userId?: string | number;
|
||||
env?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* # Grab Names For Query
|
||||
*/
|
||||
export default function grabHostNames(param?: Param): GrabHostNamesReturn;
|
||||
export {};
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
export type GrabEncryptionKeysParam = {
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
apiKey?: string;
|
||||
algorithm?: string;
|
||||
bufferAllocSize?: number;
|
||||
};
|
||||
/**
|
||||
* # Grab Encryption Keys
|
||||
* @description Grab Required Encryption Keys
|
||||
*/
|
||||
export default function grabKeys(param?: GrabEncryptionKeysParam): {
|
||||
key: string | undefined;
|
||||
keyLen: number;
|
||||
salt: string | undefined;
|
||||
apiKey: string | undefined;
|
||||
algorithm: string;
|
||||
bufferAllocSize: number;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import { ApiGetQueryObject } from "../types";
|
||||
type Param<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}> = {
|
||||
query: string | ApiGetQueryObject<T>;
|
||||
values?: (string | number)[];
|
||||
};
|
||||
export default function apiGetGrabQueryAndValues<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ query, values }: Param<T>): {
|
||||
query: string;
|
||||
values: (string | number)[] | undefined;
|
||||
valuesString: string | undefined;
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,25 @@
|
||||
declare const LogTypes: readonly ["error", "warning"];
|
||||
type Param = {
|
||||
/**
|
||||
* data to be logged.
|
||||
*/
|
||||
log: any;
|
||||
/**
|
||||
* Log Title. Could be name of function or name of variable
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* Label for the log
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Log type. `error` or `warning` or default
|
||||
*/
|
||||
type?: (typeof LogTypes)[number];
|
||||
/**
|
||||
* Whether to add a time stamp
|
||||
*/
|
||||
addTime?: boolean;
|
||||
};
|
||||
export default function debugLog({ log, label, title, type, addTime }: Param): void;
|
||||
export {};
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* # Get Number from any input
|
||||
* @example
|
||||
* numberfy("123") // 123
|
||||
* numberfy("123.456") // 123
|
||||
* numberfy("123.456", 2) // 123.46
|
||||
* numberfy("123.456", 0) // 123
|
||||
* numberfy("123.456", 3) // 123.456
|
||||
*/
|
||||
export default function numberfy(num: any, decimals?: number): number;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export default function parseEnv(/** Env File Path */ envPath: string): {
|
||||
[k: string]: string;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { CookieObject } from "../types";
|
||||
/**
|
||||
* # Serialize Cookies
|
||||
* @description Convert cookie object to string array
|
||||
*/
|
||||
export default function serializeCookies({ cookies, }: {
|
||||
cookies: CookieObject[];
|
||||
}): string[];
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* # Serialize Query
|
||||
*/
|
||||
export default function serializeQuery(query: any): string;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* # Slug to Camel case Title
|
||||
*/
|
||||
export default function slugToCamelTitle(text: String): string | null;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* # Return the slug of a string
|
||||
*
|
||||
* @example
|
||||
* slugify("Hello World") // "hello-world"
|
||||
* slugify("Yes!") // "yes"
|
||||
* slugify("Hello!!! World!") // "hello-world"
|
||||
*/
|
||||
export default function slugify(str: string): string;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* # Trim SQL
|
||||
* @description Remove Returns and miltiple spaces from SQL Query
|
||||
*/
|
||||
export default function trimSql(sql: string): string;
|
||||
Reference in New Issue
Block a user