Updates
This commit is contained in:
@@ -25,8 +25,11 @@ export default function grabDirNames(param?: Param): {
|
||||
userPrivateDbImportZipFilePath: string | undefined;
|
||||
dbNginxLoadBalancerConfigFile: string;
|
||||
dockerComposeFile: string;
|
||||
dockerComposeFileAlt: string;
|
||||
testDockerComposeFile: string;
|
||||
testDockerComposeFileAlt: string;
|
||||
extraDockerComposeFile: string;
|
||||
extraDockerComposeFileAlt: string;
|
||||
siteSetupFile: string;
|
||||
envFile: string;
|
||||
testEnvFile: string;
|
||||
|
||||
@@ -52,9 +52,12 @@ function grabDirNames(param) {
|
||||
? path_1.default.join(userPrivateSQLExportsDir, userPrivateDbImportZipFileName)
|
||||
: undefined;
|
||||
const dbNginxLoadBalancerConfigFile = path_1.default.join(appDir, "docker/services/mariadb/load-balancer/config/template/nginx.conf");
|
||||
const dockerComposeFile = path_1.default.join(appDir, "docker-compose.yml");
|
||||
let dockerComposeFile = path_1.default.join(appDir, "docker-compose.yml");
|
||||
let dockerComposeFileAlt = path_1.default.join(appDir, "docker-compose.yaml");
|
||||
const testDockerComposeFile = path_1.default.join(appDir, "test.docker-compose.yml");
|
||||
const testDockerComposeFileAlt = path_1.default.join(appDir, "test.docker-compose.yaml");
|
||||
const extraDockerComposeFile = path_1.default.join(appDir, "extra.docker-compose.yml");
|
||||
const extraDockerComposeFileAlt = path_1.default.join(appDir, "extra.docker-compose.yaml");
|
||||
const siteSetupFile = path_1.default.join(appDir, "site-setup.json");
|
||||
const envFile = path_1.default.join(appDir, ".env");
|
||||
const testEnvFile = path_1.default.join(appDir, "test.env");
|
||||
@@ -79,8 +82,11 @@ function grabDirNames(param) {
|
||||
userPrivateDbImportZipFilePath,
|
||||
dbNginxLoadBalancerConfigFile,
|
||||
dockerComposeFile,
|
||||
dockerComposeFileAlt,
|
||||
testDockerComposeFile,
|
||||
testDockerComposeFileAlt,
|
||||
extraDockerComposeFile,
|
||||
extraDockerComposeFileAlt,
|
||||
siteSetupFile,
|
||||
envFile,
|
||||
testEnvFile,
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ export default function dsqlCrud<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ action, data, table, targetValue, query, sanitize, debug, targetField, targetId, }: DsqlCrudParam<T>): Promise<(PostReturn & {
|
||||
}>({ action, data, table, targetValue, query, sanitize, debug, targetField, targetId, count, }: DsqlCrudParam<T>): Promise<(PostReturn & {
|
||||
queryObject?: ReturnType<Awaited<typeof sqlGenerator>>;
|
||||
count?: number;
|
||||
}) | null>;
|
||||
|
||||
+32
-9
@@ -13,11 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = dsqlCrud;
|
||||
const get_1 = __importDefault(require("../../actions/get"));
|
||||
const post_1 = __importDefault(require("../../actions/post"));
|
||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||
const conn_db_handler_1 = __importDefault(require("../db/conn-db-handler"));
|
||||
function dsqlCrud(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetValue, query, sanitize, debug, targetField, targetId, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ action, data, table, targetValue, query, sanitize, debug, targetField, targetId, count, }) {
|
||||
var _b, _c;
|
||||
const finalData = sanitize ? sanitize(data) : data;
|
||||
let queryObject;
|
||||
switch (action) {
|
||||
@@ -26,13 +27,35 @@ function dsqlCrud(_a) {
|
||||
tableName: table,
|
||||
genObject: query,
|
||||
});
|
||||
const GET_RES = yield (0, get_1.default)({
|
||||
query: (queryObject === null || queryObject === void 0 ? void 0 : queryObject.string) || "",
|
||||
queryValues: (queryObject === null || queryObject === void 0 ? void 0 : queryObject.values) || [],
|
||||
debug,
|
||||
forceLocal: true,
|
||||
});
|
||||
return Object.assign(Object.assign({}, GET_RES), { queryObject });
|
||||
const DB_CONN = global.DSQL_READ_ONLY_DB_CONN || global.DSQL_DB_CONN;
|
||||
const connQueries = [
|
||||
{
|
||||
query: queryObject === null || queryObject === void 0 ? void 0 : queryObject.string,
|
||||
values: (queryObject === null || queryObject === void 0 ? void 0 : queryObject.values) || [],
|
||||
},
|
||||
];
|
||||
if (count) {
|
||||
const countQueryObject = (0, sql_generator_1.default)({
|
||||
tableName: table,
|
||||
genObject: query,
|
||||
count: true,
|
||||
});
|
||||
connQueries.push({
|
||||
query: countQueryObject.string,
|
||||
values: countQueryObject.values,
|
||||
});
|
||||
}
|
||||
const res = yield (0, conn_db_handler_1.default)(DB_CONN, connQueries);
|
||||
const isSuccess = Array.isArray(res) && Array.isArray(res[0]);
|
||||
return {
|
||||
success: isSuccess,
|
||||
payload: isSuccess ? res[0] : null,
|
||||
error: isSuccess ? undefined : res === null || res === void 0 ? void 0 : res.error,
|
||||
queryObject,
|
||||
count: isSuccess && ((_c = (_b = res[1]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c["COUNT(*)"])
|
||||
? res[1][0]["COUNT(*)"]
|
||||
: undefined,
|
||||
};
|
||||
case "insert":
|
||||
return yield (0, post_1.default)({
|
||||
query: {
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
import { ServerlessMysql } from "serverless-mysql";
|
||||
type QueryObject = {
|
||||
export type ConnDBHandlerQueryObject = {
|
||||
query: string;
|
||||
values?: (string | number | undefined)[];
|
||||
};
|
||||
@@ -17,11 +17,11 @@ export default function connDbHandler<ReturnType = any>(
|
||||
*/
|
||||
conn?: ServerlessMysql,
|
||||
/**
|
||||
* String Or `QueryObject` Array
|
||||
* String Or `ConnDBHandlerQueryObject` Array
|
||||
*/
|
||||
query?: QueryObject["query"] | QueryObject[],
|
||||
query?: ConnDBHandlerQueryObject["query"] | ConnDBHandlerQueryObject[],
|
||||
/**
|
||||
* Array of Values to Sanitize and Inject
|
||||
*/
|
||||
values?: QueryObject["values"], debug?: boolean): Promise<Return<ReturnType>>;
|
||||
values?: ConnDBHandlerQueryObject["values"], debug?: boolean): Promise<Return<ReturnType>>;
|
||||
export {};
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ function connDbHandler(
|
||||
*/
|
||||
conn,
|
||||
/**
|
||||
* String Or `QueryObject` Array
|
||||
* String Or `ConnDBHandlerQueryObject` Array
|
||||
*/
|
||||
query,
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user