Updates
This commit is contained in:
+8
@@ -56,6 +56,14 @@ declare const DataTypes: readonly [{
|
||||
readonly name: "LONGTEXT";
|
||||
readonly value: "0-255";
|
||||
readonly description: "LONGTEXT is just text with max length 4,294,967,295";
|
||||
}, {
|
||||
readonly title: "OPTIONS";
|
||||
readonly name: "ENUM";
|
||||
readonly description: "String options to be selected from";
|
||||
}, {
|
||||
readonly title: "BOOLEAN";
|
||||
readonly name: "BOOLEAN";
|
||||
readonly description: "True or False. Represented in the database as 0 or 1";
|
||||
}, {
|
||||
readonly title: "DECIMAL";
|
||||
readonly name: "DECIMAL";
|
||||
|
||||
+10
@@ -69,6 +69,16 @@ const DataTypes = [
|
||||
value: "0-255",
|
||||
description: "LONGTEXT is just text with max length 4,294,967,295",
|
||||
},
|
||||
{
|
||||
title: "OPTIONS",
|
||||
name: "ENUM",
|
||||
description: "String options to be selected from",
|
||||
},
|
||||
{
|
||||
title: "BOOLEAN",
|
||||
name: "BOOLEAN",
|
||||
description: "True or False. Represented in the database as 0 or 1",
|
||||
},
|
||||
{
|
||||
title: "DECIMAL",
|
||||
name: "DECIMAL",
|
||||
|
||||
+10
@@ -68,6 +68,16 @@ const DataTypes = [
|
||||
value: "0-255",
|
||||
description: "LONGTEXT is just text with max length 4,294,967,295",
|
||||
},
|
||||
{
|
||||
title: "OPTIONS",
|
||||
name: "ENUM",
|
||||
description: "String options to be selected from",
|
||||
},
|
||||
{
|
||||
title: "BOOLEAN",
|
||||
name: "BOOLEAN",
|
||||
description: "True or False. Represented in the database as 0 or 1",
|
||||
},
|
||||
{
|
||||
title: "DECIMAL",
|
||||
name: "DECIMAL",
|
||||
|
||||
+1
@@ -8,4 +8,5 @@ export declare const AppNames: {
|
||||
readonly WebsocketPathname: "dsql-websocket";
|
||||
readonly ReverseProxyForwardURLHeaderName: "x-original-uri";
|
||||
readonly PrivateAPIAuthHeaderName: "x-api-auth-key";
|
||||
readonly StaticProxyForwardURLHeaderName: "x-media-path";
|
||||
};
|
||||
|
||||
+1
@@ -11,4 +11,5 @@ exports.AppNames = {
|
||||
WebsocketPathname: "dsql-websocket",
|
||||
ReverseProxyForwardURLHeaderName: "x-original-uri",
|
||||
PrivateAPIAuthHeaderName: "x-api-auth-key",
|
||||
StaticProxyForwardURLHeaderName: "x-media-path",
|
||||
};
|
||||
|
||||
@@ -4,4 +4,6 @@ export declare const LocalStorageDict: {
|
||||
CSRF: string;
|
||||
CurrentQueue: string;
|
||||
DiskUsage: string;
|
||||
MarkdownEditorDefaultSideBySide: string;
|
||||
MarkdownEditorDefaultPreview: string;
|
||||
};
|
||||
|
||||
@@ -11,4 +11,6 @@ exports.LocalStorageDict = {
|
||||
CSRF: (0, get_csrf_header_name_1.default)(),
|
||||
CurrentQueue: "current_queue",
|
||||
DiskUsage: "disk_usage",
|
||||
MarkdownEditorDefaultSideBySide: "markdown_editor_default_side_by_side",
|
||||
MarkdownEditorDefaultPreview: "markdown_editor_default_preview",
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ function handleSocialDb(_a) {
|
||||
var _b;
|
||||
try {
|
||||
const finalDbName = database;
|
||||
const MAX_IMAGE_STRING_LENGTH = 350;
|
||||
const existingSocialUserQUery = `SELECT * FROM users WHERE email = ? AND social_login='1' AND social_platform = ? `;
|
||||
const existingSocialUserValues = [email, social_platform];
|
||||
if (debug) {
|
||||
@@ -103,6 +104,12 @@ function handleSocialDb(_a) {
|
||||
password: socialHashedPassword,
|
||||
};
|
||||
Object.keys(payload).forEach((key) => {
|
||||
if (key.match(/image/)) {
|
||||
const imageString = payload[key];
|
||||
if (!imageString ||
|
||||
imageString.length > MAX_IMAGE_STRING_LENGTH)
|
||||
return;
|
||||
}
|
||||
data[key] = payload[key];
|
||||
});
|
||||
const newUser = yield (0, addDbEntry_1.default)({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DSQL_TableSchemaType } from "../../types";
|
||||
type Param = {
|
||||
unparsedResults: any[];
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
tableSchema?: DSQL_TableSchemaType;
|
||||
};
|
||||
/**
|
||||
* Parse Database results
|
||||
@@ -9,5 +10,5 @@ type Param = {
|
||||
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
||||
* fields
|
||||
*/
|
||||
export default function parseDbResults({ unparsedResults, tableSchema, }: Param): Promise<any[] | null>;
|
||||
export default function parseDbResults({ unparsedResults, tableSchema, }: Param): any[] | null;
|
||||
export {};
|
||||
|
||||
+27
-56
@@ -1,14 +1,4 @@
|
||||
"use strict";
|
||||
// @ts-check
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
@@ -23,54 +13,35 @@ const default_fields_regexp_1 = __importDefault(require("../dsql/default-fields-
|
||||
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
||||
* fields
|
||||
*/
|
||||
function parseDbResults(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ unparsedResults, tableSchema, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/
|
||||
let parsedResults = [];
|
||||
try {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/
|
||||
for (let pr = 0; pr < unparsedResults.length; pr++) {
|
||||
let result = unparsedResults[pr];
|
||||
let resultFieldNames = Object.keys(result);
|
||||
for (let i = 0; i < resultFieldNames.length; i++) {
|
||||
const resultFieldName = resultFieldNames[i];
|
||||
let resultFieldSchema = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields[i];
|
||||
if (resultFieldName === null || resultFieldName === void 0 ? void 0 : resultFieldName.match(default_fields_regexp_1.default)) {
|
||||
continue;
|
||||
}
|
||||
let value = result[resultFieldName];
|
||||
if (typeof value !== "number" && !value) {
|
||||
// parsedResults.push(result);
|
||||
continue;
|
||||
}
|
||||
if (resultFieldSchema === null || resultFieldSchema === void 0 ? void 0 : resultFieldSchema.encrypted) {
|
||||
if (value === null || value === void 0 ? void 0 : value.match(/./)) {
|
||||
result[resultFieldName] = (0, decrypt_1.default)({
|
||||
encryptedString: value,
|
||||
});
|
||||
}
|
||||
function parseDbResults({ unparsedResults, tableSchema, }) {
|
||||
let parsedResults = [];
|
||||
try {
|
||||
for (let pr = 0; pr < unparsedResults.length; pr++) {
|
||||
let result = unparsedResults[pr];
|
||||
let resultFieldNames = Object.keys(result);
|
||||
for (let i = 0; i < resultFieldNames.length; i++) {
|
||||
const resultFieldName = resultFieldNames[i];
|
||||
let resultFieldSchema = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields.find((fld) => fld.fieldName == resultFieldName);
|
||||
if (resultFieldName === null || resultFieldName === void 0 ? void 0 : resultFieldName.match(default_fields_regexp_1.default)) {
|
||||
continue;
|
||||
}
|
||||
let value = result[resultFieldName];
|
||||
if (typeof value !== "number" && !value) {
|
||||
continue;
|
||||
}
|
||||
if (resultFieldSchema === null || resultFieldSchema === void 0 ? void 0 : resultFieldSchema.encrypted) {
|
||||
if (value === null || value === void 0 ? void 0 : value.match(/./)) {
|
||||
result[resultFieldName] = (0, decrypt_1.default)({
|
||||
encryptedString: value,
|
||||
});
|
||||
}
|
||||
}
|
||||
parsedResults.push(result);
|
||||
}
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/
|
||||
return parsedResults;
|
||||
parsedResults.push(result);
|
||||
}
|
||||
catch ( /** @type {any} */error) {
|
||||
console.log("ERROR in parseDbResults Function =>", error.message);
|
||||
return unparsedResults;
|
||||
}
|
||||
});
|
||||
return parsedResults;
|
||||
}
|
||||
catch (error) {
|
||||
return unparsedResults;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ export default function dbGrabUserResource<T extends {
|
||||
error: any;
|
||||
msg: string | undefined;
|
||||
};
|
||||
count: number | undefined;
|
||||
count: number | null;
|
||||
}>;
|
||||
|
||||
@@ -34,7 +34,7 @@ function dbGrabUserResource(params) {
|
||||
error: result === null || result === void 0 ? void 0 : result.error,
|
||||
msg: result === null || result === void 0 ? void 0 : result.msg,
|
||||
},
|
||||
count: typeof (result === null || result === void 0 ? void 0 : result.count) == "number" ? result.count : undefined,
|
||||
count: typeof (result === null || result === void 0 ? void 0 : result.count) == "number" ? result.count : null,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,11 +10,18 @@ const data_type_parser_1 = __importDefault(require("../../utils/db/schema/data-t
|
||||
* # Generate Table Column Description
|
||||
*/
|
||||
function generateColumnDescription({ columnData, primaryKeySet, }) {
|
||||
const { fieldName, dataType, nullValue, primaryKey, autoIncrement, defaultValue, defaultValueLiteral, onUpdateLiteral, notNullValue, unique, } = columnData;
|
||||
const { fieldName, dataType, nullValue, primaryKey, autoIncrement, defaultValue, defaultValueLiteral, onUpdateLiteral, notNullValue, unique, options, } = columnData;
|
||||
let fieldEntryText = "";
|
||||
const finalDataTypeObject = (0, data_type_parser_1.default)(dataType);
|
||||
const finalDataType = (0, data_type_constructor_1.default)(finalDataTypeObject.type, finalDataTypeObject.limit, finalDataTypeObject.decimal);
|
||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
||||
if (finalDataType.match(/enum/i) && (options === null || options === void 0 ? void 0 : options[0])) {
|
||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}(${options
|
||||
.map((opt) => `'${opt}'`)
|
||||
.join(",")})`;
|
||||
}
|
||||
else {
|
||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
||||
}
|
||||
if (nullValue) {
|
||||
fieldEntryText += " DEFAULT NULL";
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -91,6 +91,7 @@ export type DSQL_DATASQUIREL_USER_DATABASES = {
|
||||
db_full_name?: string;
|
||||
db_image?: string;
|
||||
db_description?: string;
|
||||
db_long_description?: string;
|
||||
remote_connected?: number;
|
||||
remote_connection_type?: string;
|
||||
remote_db_full_name?: string;
|
||||
@@ -118,6 +119,7 @@ export type DSQL_DATASQUIREL_USER_DATABASE_TABLES = {
|
||||
table_name?: string;
|
||||
table_slug?: string;
|
||||
table_description?: string;
|
||||
table_long_description?: string;
|
||||
child_table?: number;
|
||||
child_table_parent_database_schema_id?: number;
|
||||
child_table_parent_table_schema_id?: number;
|
||||
|
||||
Vendored
+31
-1
@@ -65,6 +65,9 @@ export declare const TextFieldTypesArray: readonly [{
|
||||
}, {
|
||||
readonly title: "Rich Text";
|
||||
readonly value: "richText";
|
||||
}, {
|
||||
readonly title: "Markdown";
|
||||
readonly value: "markdown";
|
||||
}, {
|
||||
readonly title: "JSON";
|
||||
readonly value: "json";
|
||||
@@ -90,6 +93,7 @@ export declare const TextFieldTypesArray: readonly [{
|
||||
export type DSQL_FieldSchemaType = {
|
||||
id?: number | string;
|
||||
fieldName?: string;
|
||||
fieldDescription?: string;
|
||||
originName?: string;
|
||||
updatedField?: boolean;
|
||||
dataType?: string;
|
||||
@@ -1259,6 +1263,7 @@ export type DsqlCrudParam<T extends {
|
||||
countOnly?: boolean;
|
||||
dbFullName?: string;
|
||||
dbName?: string;
|
||||
tableSchema?: DSQL_TableSchemaType;
|
||||
};
|
||||
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
||||
export interface MariaDBUser {
|
||||
@@ -1707,6 +1712,17 @@ export type SiteConfigMain = {
|
||||
sharp_image_quality?: SiteConfigMainValue;
|
||||
max_backups?: SiteConfigMainValue;
|
||||
max_disk_usage?: SiteConfigMainValue;
|
||||
api_keys?: SiteConfigMainAPIKeysObject;
|
||||
target_ai?: AIOptionsObject;
|
||||
};
|
||||
export type SiteConfigMainAPIKeysObject = {
|
||||
[k: string]: SiteConfigMainAPIKeysObjectInfo;
|
||||
};
|
||||
export type SiteConfigMainAPIKeysObjectInfo = {
|
||||
key?: string;
|
||||
id?: string;
|
||||
model?: string;
|
||||
custom_model?: string;
|
||||
};
|
||||
export type SiteConfigMainValue = {
|
||||
value: number | null;
|
||||
@@ -2051,8 +2067,22 @@ export interface GiteaTreeResTree {
|
||||
sha: string;
|
||||
url: string;
|
||||
}
|
||||
export declare const OpsActions: readonly ["exit", "test", "restart-web-app", "restart-db", "restart-all", "clear"];
|
||||
export declare const OpsActions: readonly ["exit", "test", "restart-web-app", "restart-web-app-container", "restart-db", "restart-all", "clear"];
|
||||
export type OpsObject = {
|
||||
action: (typeof OpsActions)[number];
|
||||
};
|
||||
export declare const AIOptions: AIOptionsObject[];
|
||||
export type AIOptionsObject = {
|
||||
name?: string;
|
||||
title?: string;
|
||||
models?: string[];
|
||||
targetModel?: string;
|
||||
customModel?: string;
|
||||
apiKey?: string;
|
||||
baseUrl?: string;
|
||||
};
|
||||
export type AIComponentProps = {
|
||||
targetAI: AIOptionsObject;
|
||||
context: any[];
|
||||
};
|
||||
export {};
|
||||
|
||||
Vendored
+54
-1
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OpsActions = exports.TimeParadigms = exports.UserAPIAuthActions = exports.UserAPIParadigms = exports.TargetMediaParadigms = exports.EnvKeys = exports.AppVersions = exports.APIParadigms = exports.UserSQLPermissions = exports.SQLPermissions = exports.InvitedUserSelectFields = exports.DelegatedUserSelectFields = exports.UserSelectFields = exports.IndexTypes = exports.DefaultSQLValuesLiteral = exports.CurrentlyEditedFieldActions = exports.VideoMimeTypes = exports.FileMimeTypes = exports.ImageMimeTypes = exports.MediaTypes = exports.DockerComposeServices = exports.DatasquirelWindowEvents = exports.WebSocketEvents = exports.QueueJobTypes = exports.SignUpParadigms = exports.UserTypes = exports.QueryFields = exports.DsqlCrudActions = exports.DataCrudRequestMethodsLowerCase = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = exports.UsersOmitedFields = void 0;
|
||||
exports.AIOptions = exports.OpsActions = exports.TimeParadigms = exports.UserAPIAuthActions = exports.UserAPIParadigms = exports.TargetMediaParadigms = exports.EnvKeys = exports.AppVersions = exports.APIParadigms = exports.UserSQLPermissions = exports.SQLPermissions = exports.InvitedUserSelectFields = exports.DelegatedUserSelectFields = exports.UserSelectFields = exports.IndexTypes = exports.DefaultSQLValuesLiteral = exports.CurrentlyEditedFieldActions = exports.VideoMimeTypes = exports.FileMimeTypes = exports.ImageMimeTypes = exports.MediaTypes = exports.DockerComposeServices = exports.DatasquirelWindowEvents = exports.WebSocketEvents = exports.QueueJobTypes = exports.SignUpParadigms = exports.UserTypes = exports.QueryFields = exports.DsqlCrudActions = exports.DataCrudRequestMethodsLowerCase = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = exports.UsersOmitedFields = void 0;
|
||||
exports.UsersOmitedFields = [
|
||||
"password",
|
||||
"social_id",
|
||||
@@ -15,6 +15,7 @@ exports.UsersOmitedFields = [
|
||||
exports.TextFieldTypesArray = [
|
||||
{ title: "Plain Text", value: "plain" },
|
||||
{ title: "Rich Text", value: "richText" },
|
||||
{ title: "Markdown", value: "markdown" },
|
||||
{ title: "JSON", value: "json" },
|
||||
{ title: "YAML", value: "yaml" },
|
||||
{ title: "HTML", value: "html" },
|
||||
@@ -447,7 +448,59 @@ exports.OpsActions = [
|
||||
"exit",
|
||||
"test",
|
||||
"restart-web-app",
|
||||
"restart-web-app-container",
|
||||
"restart-db",
|
||||
"restart-all",
|
||||
"clear",
|
||||
];
|
||||
exports.AIOptions = [
|
||||
{
|
||||
name: "openai",
|
||||
title: "Open AI",
|
||||
models: [
|
||||
"gpt-4.1",
|
||||
"gpt-4o",
|
||||
"gpt-4o-audio",
|
||||
"04-mini",
|
||||
"o3",
|
||||
"o3-pro",
|
||||
"o3-mini",
|
||||
"o1",
|
||||
"o1-mini",
|
||||
"o1-pro",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "xai",
|
||||
title: "X-AI",
|
||||
baseUrl: "https://api.x.ai/v1",
|
||||
models: [
|
||||
"grok-4-0709",
|
||||
"grok-3",
|
||||
"grok-3-mini",
|
||||
"grok-3-fast",
|
||||
"grok-3-mini-fast",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "anthropic",
|
||||
models: [
|
||||
"claude-opus-4-0",
|
||||
"claude-sonnet-4-0",
|
||||
"claude-3-7-sonnet-latest",
|
||||
"claude-3-5-sonnet-latest",
|
||||
"claude-3-5-haiku-latest",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "gemini",
|
||||
models: [
|
||||
"gemini-2.5-pro",
|
||||
"gemini-2.5-flash",
|
||||
"gemini-2.5-flash-lite",
|
||||
"gemini-2.5-flash-preview-tts",
|
||||
"gemini-2.5-pro-preview-tts",
|
||||
"gemini-2.0-flash",
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export default function checkArrayDepth(arr: any[] | any[][] | any[][][] | any, depth: number): boolean;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = checkArrayDepth;
|
||||
function checkArrayDepth(arr, depth) {
|
||||
if (!Array.isArray(arr))
|
||||
return false;
|
||||
if (depth === 1)
|
||||
return true;
|
||||
return arr.every((item) => checkArrayDepth(item, depth - 1));
|
||||
}
|
||||
+1
-1
@@ -3,4 +3,4 @@ export default function <T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ table, query, count, countOnly, dbFullName, }: Omit<DsqlCrudParam<T>, "action" | "data" | "sanitize">): Promise<APIResponseObject>;
|
||||
}>({ table, query, count, countOnly, dbFullName, tableSchema, }: Omit<DsqlCrudParam<T>, "action" | "data" | "sanitize">): Promise<APIResponseObject>;
|
||||
|
||||
+18
-4
@@ -15,8 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||
const conn_db_handler_1 = __importDefault(require("../db/conn-db-handler"));
|
||||
const check_array_depth_1 = __importDefault(require("../check-array-depth"));
|
||||
const parseDbResults_1 = __importDefault(require("../../functions/backend/parseDbResults"));
|
||||
function default_1(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ table, query, count, countOnly, dbFullName, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ table, query, count, countOnly, dbFullName, tableSchema, }) {
|
||||
var _b, _c, _d, _e;
|
||||
let queryObject;
|
||||
queryObject = (0, sql_generator_1.default)({
|
||||
@@ -53,12 +55,24 @@ function default_1(_a) {
|
||||
];
|
||||
}
|
||||
const res = yield (0, conn_db_handler_1.default)(undefined, connQueries);
|
||||
const parsedRes = (0, check_array_depth_1.default)(res, 2)
|
||||
? (0, parseDbResults_1.default)({ unparsedResults: res[0], tableSchema })
|
||||
: res[0];
|
||||
const parsedBatchRes = (0, check_array_depth_1.default)(res, 3)
|
||||
? res.map((_r) => {
|
||||
return (0, parseDbResults_1.default)({ unparsedResults: _r[0], tableSchema });
|
||||
})
|
||||
: res;
|
||||
const isSuccess = Array.isArray(res) && Array.isArray(res[0]);
|
||||
return {
|
||||
success: isSuccess,
|
||||
payload: isSuccess ? (countOnly ? null : res[0]) : null,
|
||||
batchPayload: isSuccess ? (countOnly ? null : res) : null,
|
||||
error: isSuccess ? undefined : res === null || res === void 0 ? void 0 : res.error,
|
||||
payload: isSuccess ? (countOnly ? null : parsedRes) : null,
|
||||
batchPayload: isSuccess ? (countOnly ? null : parsedBatchRes) : null,
|
||||
error: isSuccess
|
||||
? undefined
|
||||
: typeof res == "object" && !Array.isArray(res)
|
||||
? res === null || res === void 0 ? void 0 : res.error
|
||||
: undefined,
|
||||
errors: res === null || res === void 0 ? void 0 : res.errors,
|
||||
queryObject: {
|
||||
sql: queryObject === null || queryObject === void 0 ? void 0 : queryObject.string,
|
||||
|
||||
+3
-1
@@ -20,7 +20,7 @@ const addDbEntry_1 = __importDefault(require("../../functions/backend/db/addDbEn
|
||||
const updateDbEntry_1 = __importDefault(require("../../functions/backend/db/updateDbEntry"));
|
||||
function dsqlCrud(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, } = params;
|
||||
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, tableSchema, } = params;
|
||||
const finalData = (sanitize ? sanitize({ data }) : data);
|
||||
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
||||
switch (action) {
|
||||
@@ -35,6 +35,7 @@ function dsqlCrud(params) {
|
||||
tableName: table,
|
||||
dbFullName,
|
||||
debug,
|
||||
tableSchema,
|
||||
});
|
||||
return INSERT_RESULT;
|
||||
case "update":
|
||||
@@ -46,6 +47,7 @@ function dsqlCrud(params) {
|
||||
identifierColumnName: (targetField || "id"),
|
||||
identifierValue: String(targetValue || targetId),
|
||||
debug,
|
||||
tableSchema,
|
||||
});
|
||||
return UPDATE_RESULT;
|
||||
case "delete":
|
||||
|
||||
@@ -16,6 +16,8 @@ function grabTextFieldType(field, nullReturn) {
|
||||
return "javascript";
|
||||
if (field.shell)
|
||||
return "shell";
|
||||
if (field.markdown)
|
||||
return "markdown";
|
||||
if (nullReturn)
|
||||
return undefined;
|
||||
return "plain";
|
||||
|
||||
+8
-7
@@ -68,13 +68,14 @@ function default_1({ currentDbSchema, currentTableSchema, currentTableSchemaInde
|
||||
/**
|
||||
* Handle scenario where this table is a child of another
|
||||
*/
|
||||
if (currentTableSchema.childTable &&
|
||||
currentTableSchema.childTableDbId &&
|
||||
currentTableSchema.childTableDbId) {
|
||||
const targetParentDatabase = (0, grab_required_database_schemas_1.grabPrimaryRequiredDbSchema)({
|
||||
dbId: currentTableSchema.childTableDbId,
|
||||
userId,
|
||||
});
|
||||
if (currentTableSchema.childTable && currentTableSchema.childTableDbId) {
|
||||
const isParentDbCurrentDb = currentTableSchema.childTableDbId == newCurrentDbSchema.id;
|
||||
const targetParentDatabase = isParentDbCurrentDb
|
||||
? newCurrentDbSchema
|
||||
: (0, grab_required_database_schemas_1.grabPrimaryRequiredDbSchema)({
|
||||
dbId: currentTableSchema.childTableDbId,
|
||||
userId,
|
||||
});
|
||||
const targetParentDatabaseTableIndex = targetParentDatabase === null || targetParentDatabase === void 0 ? void 0 : targetParentDatabase.tables.findIndex((tbl) => tbl.id == currentTableSchema.childTableId);
|
||||
const targetParentDatabaseTable = typeof targetParentDatabaseTableIndex == "number"
|
||||
? targetParentDatabaseTableIndex < 0
|
||||
|
||||
@@ -32,5 +32,7 @@ function setTextFieldType(field, type) {
|
||||
return Object.assign(Object.assign({}, newField), { javascript: true });
|
||||
if (type == "code")
|
||||
return Object.assign(Object.assign({}, newField), { code: true });
|
||||
if (type == "markdown")
|
||||
return Object.assign(Object.assign({}, newField), { markdown: true });
|
||||
return Object.assign({}, newField);
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@ export default function grabDockerResourceIPNumbers(): {
|
||||
readonly replica_1: 37;
|
||||
readonly replica_2: 38;
|
||||
readonly web_app_post_db_setup: 71;
|
||||
readonly static: 77;
|
||||
};
|
||||
|
||||
@@ -14,5 +14,6 @@ function grabDockerResourceIPNumbers() {
|
||||
replica_1: 37,
|
||||
replica_2: 38,
|
||||
web_app_post_db_setup: 71,
|
||||
static: 77,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { AIOptionsObject, SiteConfig } from "../types";
|
||||
type Params = {
|
||||
userConfig?: SiteConfig | null;
|
||||
};
|
||||
export type GrabUserAIConfigReturn = {};
|
||||
export default function grabUserAIInfo({ userConfig: passedConfig, }: Params): AIOptionsObject | undefined;
|
||||
export {};
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabUserAIInfo;
|
||||
const types_1 = require("../types");
|
||||
function grabUserAIInfo({ userConfig: passedConfig, }) {
|
||||
const userConfig = passedConfig
|
||||
? passedConfig
|
||||
: undefined;
|
||||
if (!userConfig)
|
||||
return undefined;
|
||||
const targetAI = userConfig === null || userConfig === void 0 ? void 0 : userConfig.main.target_ai;
|
||||
if (!(targetAI === null || targetAI === void 0 ? void 0 : targetAI.name) || !(userConfig === null || userConfig === void 0 ? void 0 : userConfig.main.api_keys))
|
||||
return undefined;
|
||||
const targetAIAPIKey = userConfig.main.api_keys[targetAI.name].key;
|
||||
if (!targetAIAPIKey)
|
||||
return undefined;
|
||||
const targetAIOption = types_1.AIOptions.find((aiOpt) => aiOpt.name == targetAI.name);
|
||||
targetAI.apiKey = targetAIAPIKey;
|
||||
if (targetAIOption === null || targetAIOption === void 0 ? void 0 : targetAIOption.baseUrl) {
|
||||
targetAI.baseUrl = targetAIOption.baseUrl;
|
||||
}
|
||||
return targetAI;
|
||||
}
|
||||
Reference in New Issue
Block a user