Updates
This commit is contained in:
parent
1f375fe94f
commit
9ca64cf25e
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -22,6 +22,7 @@ import dbHandler from "./package-shared/functions/backend/dbHandler";
|
||||
import httpsRequest from "./package-shared/functions/backend/httpsRequest";
|
||||
import handleNodemailer from "./package-shared/functions/backend/handleNodemailer";
|
||||
import grabDSQLConnection from "./package-shared/utils/grab-dsql-connection";
|
||||
import grabDSQLConnectionConfig from "./package-shared/utils/grab-dsql-connection-config";
|
||||
/**
|
||||
* Main Export
|
||||
*/
|
||||
@ -136,6 +137,7 @@ declare const datasquirel: {
|
||||
httpsRequest: typeof httpsRequest;
|
||||
httpRequest: typeof httpsRequest;
|
||||
grabDSQLConnection: typeof grabDSQLConnection;
|
||||
grabDSQLConnectionConfig: typeof grabDSQLConnectionConfig;
|
||||
};
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -28,6 +28,7 @@ const dbHandler_1 = __importDefault(require("./package-shared/functions/backend/
|
||||
const httpsRequest_1 = __importDefault(require("./package-shared/functions/backend/httpsRequest"));
|
||||
const handleNodemailer_1 = __importDefault(require("./package-shared/functions/backend/handleNodemailer"));
|
||||
const grab_dsql_connection_1 = __importDefault(require("./package-shared/utils/grab-dsql-connection"));
|
||||
const grab_dsql_connection_config_1 = __importDefault(require("./package-shared/utils/grab-dsql-connection-config"));
|
||||
/**
|
||||
* API Functions Object
|
||||
*/
|
||||
@ -78,6 +79,7 @@ const datasquirel = {
|
||||
httpsRequest: httpsRequest_1.default,
|
||||
httpRequest: httpsRequest_1.default,
|
||||
grabDSQLConnection: grab_dsql_connection_1.default,
|
||||
grabDSQLConnectionConfig: grab_dsql_connection_config_1.default,
|
||||
},
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
|
15
dist/package-shared/types/index.d.ts
vendored
15
dist/package-shared/types/index.d.ts
vendored
@ -5,6 +5,7 @@ import type sharp from "sharp";
|
||||
import type DataTypes from "../data/data-types";
|
||||
import type { IncomingMessage, ServerResponse } from "http";
|
||||
import type { CookieNames } from "../dict/cookie-names";
|
||||
import { ConnectionConfig } from "mariadb";
|
||||
export type DSQL_DatabaseFullName = string;
|
||||
export type DSQL_DATASQUIREL_USER_BACKUPS_JOIN = DSQL_DATASQUIREL_BACKUPS & {
|
||||
[k in (typeof UserSelectFields)[number]["alias"]]?: string;
|
||||
@ -2085,4 +2086,18 @@ export type AIComponentProps = {
|
||||
targetAI: AIOptionsObject;
|
||||
context: any[];
|
||||
};
|
||||
export type DsqlConnectionParam = {
|
||||
/**
|
||||
* No Database Connection
|
||||
*/
|
||||
noDb?: boolean;
|
||||
/**
|
||||
* Database Name
|
||||
*/
|
||||
database?: string;
|
||||
/**
|
||||
* Debug
|
||||
*/
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
export {};
|
||||
|
6
dist/package-shared/utils/grab-dsql-connection-config.d.ts
vendored
Normal file
6
dist/package-shared/utils/grab-dsql-connection-config.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import { ConnectionConfig } from "mariadb";
|
||||
import { DsqlConnectionParam } from "../types";
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnectionConfig(param?: DsqlConnectionParam): ConnectionConfig;
|
18
dist/package-shared/utils/grab-dsql-connection-config.js
vendored
Normal file
18
dist/package-shared/utils/grab-dsql-connection-config.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDSQLConnectionConfig;
|
||||
const grabDbSSL_1 = __importDefault(require("./backend/grabDbSSL"));
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
function grabDSQLConnectionConfig(param) {
|
||||
const CONN_TIMEOUT = 10000;
|
||||
const config = Object.assign({ host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, database: (param === null || param === void 0 ? void 0 : param.database) ||
|
||||
((param === null || param === void 0 ? void 0 : param.noDb) ? undefined : process.env.DSQL_DB_NAME), port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined, charset: "utf8mb4", ssl: (0, grabDbSSL_1.default)(), bigIntAsNumber: true, supportBigNumbers: true, bigNumberStrings: false, dateStrings: true, metaAsArray: true, socketTimeout: CONN_TIMEOUT, connectTimeout: CONN_TIMEOUT, compress: true }, param === null || param === void 0 ? void 0 : param.config);
|
||||
return config;
|
||||
}
|
@ -1,20 +1,6 @@
|
||||
import { Connection, ConnectionConfig } from "mariadb";
|
||||
type Param = {
|
||||
/**
|
||||
* No Database Connection
|
||||
*/
|
||||
noDb?: boolean;
|
||||
/**
|
||||
* Database Name
|
||||
*/
|
||||
database?: string;
|
||||
/**
|
||||
* Debug
|
||||
*/
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
import { Connection } from "mariadb";
|
||||
import { DsqlConnectionParam } from "../types";
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnection(param?: Param): Promise<Connection>;
|
||||
export {};
|
||||
export default function grabDSQLConnection(param?: DsqlConnectionParam): Promise<Connection>;
|
||||
|
@ -14,17 +14,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDSQLConnection;
|
||||
const mariadb_1 = __importDefault(require("mariadb"));
|
||||
const grabDbSSL_1 = __importDefault(require("./backend/grabDbSSL"));
|
||||
const grab_dsql_connection_config_1 = __importDefault(require("./grab-dsql-connection-config"));
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
function grabDSQLConnection(param) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const CONN_TIMEOUT = 10000;
|
||||
const config = Object.assign({ host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, database: (param === null || param === void 0 ? void 0 : param.database) ||
|
||||
((param === null || param === void 0 ? void 0 : param.noDb) ? undefined : process.env.DSQL_DB_NAME), port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined, charset: "utf8mb4", ssl: (0, grabDbSSL_1.default)(), bigIntAsNumber: true, supportBigNumbers: true, bigNumberStrings: false, dateStrings: true, metaAsArray: true, socketTimeout: CONN_TIMEOUT, connectTimeout: CONN_TIMEOUT, compress: true }, param === null || param === void 0 ? void 0 : param.config);
|
||||
const config = (0, grab_dsql_connection_config_1.default)(param);
|
||||
try {
|
||||
return yield mariadb_1.default.createConnection(config);
|
||||
}
|
||||
@ -32,77 +28,5 @@ function grabDSQLConnection(param) {
|
||||
console.log(`Error Grabbing DSQL Connection =>`, config);
|
||||
throw error;
|
||||
}
|
||||
// if (global.DSQL_USE_LOCAL || param?.local) {
|
||||
// return (
|
||||
// global.DSQL_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: param?.noDb ? undefined : process.env.DSQL_DB_NAME,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// if (param?.ro) {
|
||||
// return (
|
||||
// global.DSQL_READ_ONLY_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_READ_ONLY_USERNAME,
|
||||
// password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// if (param?.fa) {
|
||||
// return (
|
||||
// global.DSQL_FULL_ACCESS_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
|
||||
// password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// return (
|
||||
// global.DSQL_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: param?.noDb ? undefined : process.env.DSQL_DB_NAME,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
});
|
||||
}
|
||||
|
2
index.ts
2
index.ts
@ -29,6 +29,7 @@ import dbHandler from "./package-shared/functions/backend/dbHandler";
|
||||
import httpsRequest from "./package-shared/functions/backend/httpsRequest";
|
||||
import handleNodemailer from "./package-shared/functions/backend/handleNodemailer";
|
||||
import grabDSQLConnection from "./package-shared/utils/grab-dsql-connection";
|
||||
import grabDSQLConnectionConfig from "./package-shared/utils/grab-dsql-connection-config";
|
||||
|
||||
/**
|
||||
* API Functions Object
|
||||
@ -82,6 +83,7 @@ const datasquirel = {
|
||||
httpsRequest,
|
||||
httpRequest: httpsRequest,
|
||||
grabDSQLConnection,
|
||||
grabDSQLConnectionConfig,
|
||||
},
|
||||
/**
|
||||
* Run Crud actions `get`, `insert`, `update`, `delete`
|
||||
|
@ -22,6 +22,7 @@ import type sharp from "sharp";
|
||||
import type DataTypes from "../data/data-types";
|
||||
import type { IncomingMessage, ServerResponse } from "http";
|
||||
import type { CookieNames } from "../dict/cookie-names";
|
||||
import { ConnectionConfig } from "mariadb";
|
||||
|
||||
export type DSQL_DatabaseFullName = string;
|
||||
|
||||
@ -2722,3 +2723,18 @@ export type AIComponentProps = {
|
||||
targetAI: AIOptionsObject;
|
||||
context: any[];
|
||||
};
|
||||
|
||||
export type DsqlConnectionParam = {
|
||||
/**
|
||||
* No Database Connection
|
||||
*/
|
||||
noDb?: boolean;
|
||||
/**
|
||||
* Database Name
|
||||
*/
|
||||
database?: string;
|
||||
/**
|
||||
* Debug
|
||||
*/
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
|
37
package-shared/utils/grab-dsql-connection-config.ts
Normal file
37
package-shared/utils/grab-dsql-connection-config.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { ConnectionConfig } from "mariadb";
|
||||
import grabDbSSL from "./backend/grabDbSSL";
|
||||
import { DsqlConnectionParam } from "../types";
|
||||
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnectionConfig(
|
||||
param?: DsqlConnectionParam
|
||||
): ConnectionConfig {
|
||||
const CONN_TIMEOUT = 10000;
|
||||
|
||||
const config: ConnectionConfig = {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
user: process.env.DSQL_DB_USERNAME,
|
||||
password: process.env.DSQL_DB_PASSWORD,
|
||||
database:
|
||||
param?.database ||
|
||||
(param?.noDb ? undefined : process.env.DSQL_DB_NAME),
|
||||
port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined,
|
||||
charset: "utf8mb4",
|
||||
ssl: grabDbSSL(),
|
||||
bigIntAsNumber: true,
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: false,
|
||||
dateStrings: true,
|
||||
metaAsArray: true,
|
||||
socketTimeout: CONN_TIMEOUT,
|
||||
connectTimeout: CONN_TIMEOUT,
|
||||
compress: true,
|
||||
...param?.config,
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
@ -1,51 +1,15 @@
|
||||
import mariadb, { Connection, ConnectionConfig } from "mariadb";
|
||||
import grabDbSSL from "./backend/grabDbSSL";
|
||||
|
||||
type Param = {
|
||||
/**
|
||||
* No Database Connection
|
||||
*/
|
||||
noDb?: boolean;
|
||||
/**
|
||||
* Database Name
|
||||
*/
|
||||
database?: string;
|
||||
/**
|
||||
* Debug
|
||||
*/
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
import { DsqlConnectionParam } from "../types";
|
||||
import grabDSQLConnectionConfig from "./grab-dsql-connection-config";
|
||||
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default async function grabDSQLConnection(
|
||||
param?: Param
|
||||
param?: DsqlConnectionParam
|
||||
): Promise<Connection> {
|
||||
const CONN_TIMEOUT = 10000;
|
||||
|
||||
const config: ConnectionConfig = {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
user: process.env.DSQL_DB_USERNAME,
|
||||
password: process.env.DSQL_DB_PASSWORD,
|
||||
database:
|
||||
param?.database ||
|
||||
(param?.noDb ? undefined : process.env.DSQL_DB_NAME),
|
||||
port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined,
|
||||
charset: "utf8mb4",
|
||||
ssl: grabDbSSL(),
|
||||
bigIntAsNumber: true,
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: false,
|
||||
dateStrings: true,
|
||||
metaAsArray: true,
|
||||
socketTimeout: CONN_TIMEOUT,
|
||||
connectTimeout: CONN_TIMEOUT,
|
||||
compress: true,
|
||||
...param?.config,
|
||||
};
|
||||
const config = grabDSQLConnectionConfig(param);
|
||||
|
||||
try {
|
||||
return await mariadb.createConnection(config);
|
||||
@ -53,80 +17,4 @@ export default async function grabDSQLConnection(
|
||||
console.log(`Error Grabbing DSQL Connection =>`, config);
|
||||
throw error;
|
||||
}
|
||||
|
||||
// if (global.DSQL_USE_LOCAL || param?.local) {
|
||||
// return (
|
||||
// global.DSQL_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: param?.noDb ? undefined : process.env.DSQL_DB_NAME,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
|
||||
// if (param?.ro) {
|
||||
// return (
|
||||
// global.DSQL_READ_ONLY_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_READ_ONLY_USERNAME,
|
||||
// password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
|
||||
// if (param?.fa) {
|
||||
// return (
|
||||
// global.DSQL_FULL_ACCESS_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
|
||||
// password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
|
||||
// return (
|
||||
// global.DSQL_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: param?.noDb ? undefined : process.env.DSQL_DB_NAME,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "5.1.2",
|
||||
"version": "5.1.3",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
Loading…
Reference in New Issue
Block a user