Updates
This commit is contained in:
parent
a429436939
commit
8ac8b8eb51
18
dist/index.d.ts
vendored
18
dist/index.d.ts
vendored
@ -1,16 +1,9 @@
|
|||||||
import type { Connection } from "mariadb";
|
|
||||||
declare global {
|
declare global {
|
||||||
var DSQL_DB_CONN: Connection | undefined;
|
|
||||||
var DSQL_READ_ONLY_DB_CONN: Connection | undefined;
|
|
||||||
var DSQL_FULL_ACCESS_DB_CONN: Connection | undefined;
|
|
||||||
var DSQL_USE_LOCAL: boolean | undefined;
|
|
||||||
var ERROR_CALLBACK: ErrorCallback | undefined;
|
var ERROR_CALLBACK: ErrorCallback | undefined;
|
||||||
}
|
}
|
||||||
import get from "./package-shared/actions/get";
|
import get from "./package-shared/actions/get";
|
||||||
import post from "./package-shared/actions/post";
|
import post from "./package-shared/actions/post";
|
||||||
import getSchema from "./package-shared/actions/get-schema";
|
import getSchema from "./package-shared/actions/get-schema";
|
||||||
import createUser from "./package-shared/actions/users/add-user";
|
|
||||||
import updateUser from "./package-shared/actions/users/update-user";
|
|
||||||
import sqlGenerator from "./package-shared/functions/dsql/sql/sql-generator";
|
import sqlGenerator from "./package-shared/functions/dsql/sql/sql-generator";
|
||||||
import sqlInsertGenerator from "./package-shared/functions/dsql/sql/sql-insert-generator";
|
import sqlInsertGenerator from "./package-shared/functions/dsql/sql/sql-insert-generator";
|
||||||
import sqlDeleteGenerator from "./package-shared/functions/dsql/sql/sql-delete-generator";
|
import sqlDeleteGenerator from "./package-shared/functions/dsql/sql/sql-delete-generator";
|
||||||
@ -27,6 +20,7 @@ import { ErrorCallback } from "./package-shared/types";
|
|||||||
import parseEnv from "./package-shared/utils/parse-env";
|
import parseEnv from "./package-shared/utils/parse-env";
|
||||||
import dbHandler from "./package-shared/functions/backend/dbHandler";
|
import dbHandler from "./package-shared/functions/backend/dbHandler";
|
||||||
import httpsRequest from "./package-shared/functions/backend/httpsRequest";
|
import httpsRequest from "./package-shared/functions/backend/httpsRequest";
|
||||||
|
import handleNodemailer from "./package-shared/functions/backend/handleNodemailer";
|
||||||
/**
|
/**
|
||||||
* Main Export
|
* Main Export
|
||||||
*/
|
*/
|
||||||
@ -51,9 +45,9 @@ declare const datasquirel: {
|
|||||||
auth: {
|
auth: {
|
||||||
login: typeof import("./package-shared/actions/users/login-user").default;
|
login: typeof import("./package-shared/actions/users/login-user").default;
|
||||||
get: typeof import("./package-shared/actions/users/get-user").default;
|
get: typeof import("./package-shared/actions/users/get-user").default;
|
||||||
signup: typeof createUser;
|
signup: typeof import("./package-shared/actions/users/add-user").default;
|
||||||
sendEmailCode: typeof import("./package-shared/actions/users/send-email-code").default;
|
sendEmailCode: typeof import("./package-shared/actions/users/send-email-code").default;
|
||||||
update: typeof updateUser;
|
update: typeof import("./package-shared/actions/users/update-user").default;
|
||||||
resetPassword: typeof import("./package-shared/actions/users/reset-password").default;
|
resetPassword: typeof import("./package-shared/actions/users/reset-password").default;
|
||||||
googleLogin: typeof import("./package-shared/actions/users/social/google-auth").default;
|
googleLogin: typeof import("./package-shared/actions/users/social/google-auth").default;
|
||||||
logout: typeof import("./package-shared/actions/users/logout-user").default;
|
logout: typeof import("./package-shared/actions/users/logout-user").default;
|
||||||
@ -155,5 +149,11 @@ declare const datasquirel: {
|
|||||||
* General Database Handler
|
* General Database Handler
|
||||||
*/
|
*/
|
||||||
dbHandler: typeof dbHandler;
|
dbHandler: typeof dbHandler;
|
||||||
|
/**
|
||||||
|
* Handle Mail
|
||||||
|
*/
|
||||||
|
mail: {
|
||||||
|
mailer: typeof handleNodemailer;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
export default datasquirel;
|
export default datasquirel;
|
||||||
|
28
dist/index.js
vendored
28
dist/index.js
vendored
@ -26,27 +26,7 @@ const local_user_1 = __importDefault(require("./package-shared/api/user/local-us
|
|||||||
const media_1 = __importDefault(require("./package-shared/api/media"));
|
const media_1 = __importDefault(require("./package-shared/api/media"));
|
||||||
const dbHandler_1 = __importDefault(require("./package-shared/functions/backend/dbHandler"));
|
const dbHandler_1 = __importDefault(require("./package-shared/functions/backend/dbHandler"));
|
||||||
const httpsRequest_1 = __importDefault(require("./package-shared/functions/backend/httpsRequest"));
|
const httpsRequest_1 = __importDefault(require("./package-shared/functions/backend/httpsRequest"));
|
||||||
/**
|
const handleNodemailer_1 = __importDefault(require("./package-shared/functions/backend/handleNodemailer"));
|
||||||
* User Functions Object
|
|
||||||
*/
|
|
||||||
// const user = {
|
|
||||||
// createUser: createUser,
|
|
||||||
// deleteUser,
|
|
||||||
// loginUser: loginUser,
|
|
||||||
// sendEmailCode: sendEmailCode,
|
|
||||||
// logoutUser: logoutUser,
|
|
||||||
// userAuth: userAuth,
|
|
||||||
// reAuthUser: reAuthUser,
|
|
||||||
// updateUser: updateUser,
|
|
||||||
// getUser: getUser,
|
|
||||||
// getToken: getToken,
|
|
||||||
// validateToken: validateToken,
|
|
||||||
// validateTempEmailCode,
|
|
||||||
// social: {
|
|
||||||
// loginWithGoogle: loginWithGoogle,
|
|
||||||
// loginWithGithub: loginWithGithub,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
/**
|
/**
|
||||||
* API Functions Object
|
* API Functions Object
|
||||||
*/
|
*/
|
||||||
@ -111,5 +91,11 @@ const datasquirel = {
|
|||||||
* General Database Handler
|
* General Database Handler
|
||||||
*/
|
*/
|
||||||
dbHandler: dbHandler_1.default,
|
dbHandler: dbHandler_1.default,
|
||||||
|
/**
|
||||||
|
* Handle Mail
|
||||||
|
*/
|
||||||
|
mail: {
|
||||||
|
mailer: handleNodemailer_1.default,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
exports.default = datasquirel;
|
exports.default = datasquirel;
|
||||||
|
8
dist/package-shared/data/data-types.d.ts
vendored
8
dist/package-shared/data/data-types.d.ts
vendored
@ -56,6 +56,14 @@ declare const DataTypes: readonly [{
|
|||||||
readonly name: "LONGTEXT";
|
readonly name: "LONGTEXT";
|
||||||
readonly value: "0-255";
|
readonly value: "0-255";
|
||||||
readonly description: "LONGTEXT is just text with max length 4,294,967,295";
|
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 title: "DECIMAL";
|
||||||
readonly name: "DECIMAL";
|
readonly name: "DECIMAL";
|
||||||
|
10
dist/package-shared/data/data-types.js
vendored
10
dist/package-shared/data/data-types.js
vendored
@ -69,6 +69,16 @@ const DataTypes = [
|
|||||||
value: "0-255",
|
value: "0-255",
|
||||||
description: "LONGTEXT is just text with max length 4,294,967,295",
|
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",
|
title: "DECIMAL",
|
||||||
name: "DECIMAL",
|
name: "DECIMAL",
|
||||||
|
10
dist/package-shared/data/data-types.ts
vendored
10
dist/package-shared/data/data-types.ts
vendored
@ -68,6 +68,16 @@ const DataTypes = [
|
|||||||
value: "0-255",
|
value: "0-255",
|
||||||
description: "LONGTEXT is just text with max length 4,294,967,295",
|
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",
|
title: "DECIMAL",
|
||||||
name: "DECIMAL",
|
name: "DECIMAL",
|
||||||
|
1
dist/package-shared/dict/app-names.d.ts
vendored
1
dist/package-shared/dict/app-names.d.ts
vendored
@ -8,4 +8,5 @@ export declare const AppNames: {
|
|||||||
readonly WebsocketPathname: "dsql-websocket";
|
readonly WebsocketPathname: "dsql-websocket";
|
||||||
readonly ReverseProxyForwardURLHeaderName: "x-original-uri";
|
readonly ReverseProxyForwardURLHeaderName: "x-original-uri";
|
||||||
readonly PrivateAPIAuthHeaderName: "x-api-auth-key";
|
readonly PrivateAPIAuthHeaderName: "x-api-auth-key";
|
||||||
|
readonly StaticProxyForwardURLHeaderName: "x-media-path";
|
||||||
};
|
};
|
||||||
|
1
dist/package-shared/dict/app-names.js
vendored
1
dist/package-shared/dict/app-names.js
vendored
@ -11,4 +11,5 @@ exports.AppNames = {
|
|||||||
WebsocketPathname: "dsql-websocket",
|
WebsocketPathname: "dsql-websocket",
|
||||||
ReverseProxyForwardURLHeaderName: "x-original-uri",
|
ReverseProxyForwardURLHeaderName: "x-original-uri",
|
||||||
PrivateAPIAuthHeaderName: "x-api-auth-key",
|
PrivateAPIAuthHeaderName: "x-api-auth-key",
|
||||||
|
StaticProxyForwardURLHeaderName: "x-media-path",
|
||||||
};
|
};
|
||||||
|
@ -4,4 +4,6 @@ export declare const LocalStorageDict: {
|
|||||||
CSRF: string;
|
CSRF: string;
|
||||||
CurrentQueue: string;
|
CurrentQueue: string;
|
||||||
DiskUsage: string;
|
DiskUsage: string;
|
||||||
|
MarkdownEditorDefaultSideBySide: string;
|
||||||
|
MarkdownEditorDefaultPreview: string;
|
||||||
};
|
};
|
||||||
|
@ -11,4 +11,6 @@ exports.LocalStorageDict = {
|
|||||||
CSRF: (0, get_csrf_header_name_1.default)(),
|
CSRF: (0, get_csrf_header_name_1.default)(),
|
||||||
CurrentQueue: "current_queue",
|
CurrentQueue: "current_queue",
|
||||||
DiskUsage: "disk_usage",
|
DiskUsage: "disk_usage",
|
||||||
|
MarkdownEditorDefaultSideBySide: "markdown_editor_default_side_by_side",
|
||||||
|
MarkdownEditorDefaultPreview: "markdown_editor_default_preview",
|
||||||
};
|
};
|
||||||
|
@ -27,6 +27,7 @@ function handleSocialDb(_a) {
|
|||||||
var _b;
|
var _b;
|
||||||
try {
|
try {
|
||||||
const finalDbName = database;
|
const finalDbName = database;
|
||||||
|
const MAX_IMAGE_STRING_LENGTH = 350;
|
||||||
const existingSocialUserQUery = `SELECT * FROM users WHERE email = ? AND social_login='1' AND social_platform = ? `;
|
const existingSocialUserQUery = `SELECT * FROM users WHERE email = ? AND social_login='1' AND social_platform = ? `;
|
||||||
const existingSocialUserValues = [email, social_platform];
|
const existingSocialUserValues = [email, social_platform];
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -103,6 +104,12 @@ function handleSocialDb(_a) {
|
|||||||
password: socialHashedPassword,
|
password: socialHashedPassword,
|
||||||
};
|
};
|
||||||
Object.keys(payload).forEach((key) => {
|
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];
|
data[key] = payload[key];
|
||||||
});
|
});
|
||||||
const newUser = yield (0, addDbEntry_1.default)({
|
const newUser = yield (0, addDbEntry_1.default)({
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import { DSQL_TableSchemaType } from "../../types";
|
||||||
type Param = {
|
type Param = {
|
||||||
unparsedResults: any[];
|
unparsedResults: any[];
|
||||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
tableSchema?: DSQL_TableSchemaType;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Parse Database results
|
* Parse Database results
|
||||||
@ -9,5 +10,5 @@ type Param = {
|
|||||||
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
||||||
* fields
|
* fields
|
||||||
*/
|
*/
|
||||||
export default function parseDbResults({ unparsedResults, tableSchema, }: Param): Promise<any[] | null>;
|
export default function parseDbResults({ unparsedResults, tableSchema, }: Param): any[] | null;
|
||||||
export {};
|
export {};
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
"use strict";
|
"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) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
@ -23,32 +13,20 @@ const default_fields_regexp_1 = __importDefault(require("../dsql/default-fields-
|
|||||||
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
||||||
* fields
|
* fields
|
||||||
*/
|
*/
|
||||||
function parseDbResults(_a) {
|
function parseDbResults({ unparsedResults, tableSchema, }) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ unparsedResults, tableSchema, }) {
|
|
||||||
/**
|
|
||||||
* Declare variables
|
|
||||||
*
|
|
||||||
* @description Declare "results" variable
|
|
||||||
*/
|
|
||||||
let parsedResults = [];
|
let parsedResults = [];
|
||||||
try {
|
try {
|
||||||
/**
|
|
||||||
* Declare variables
|
|
||||||
*
|
|
||||||
* @description Declare "results" variable
|
|
||||||
*/
|
|
||||||
for (let pr = 0; pr < unparsedResults.length; pr++) {
|
for (let pr = 0; pr < unparsedResults.length; pr++) {
|
||||||
let result = unparsedResults[pr];
|
let result = unparsedResults[pr];
|
||||||
let resultFieldNames = Object.keys(result);
|
let resultFieldNames = Object.keys(result);
|
||||||
for (let i = 0; i < resultFieldNames.length; i++) {
|
for (let i = 0; i < resultFieldNames.length; i++) {
|
||||||
const resultFieldName = resultFieldNames[i];
|
const resultFieldName = resultFieldNames[i];
|
||||||
let resultFieldSchema = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields[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)) {
|
if (resultFieldName === null || resultFieldName === void 0 ? void 0 : resultFieldName.match(default_fields_regexp_1.default)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let value = result[resultFieldName];
|
let value = result[resultFieldName];
|
||||||
if (typeof value !== "number" && !value) {
|
if (typeof value !== "number" && !value) {
|
||||||
// parsedResults.push(result);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (resultFieldSchema === null || resultFieldSchema === void 0 ? void 0 : resultFieldSchema.encrypted) {
|
if (resultFieldSchema === null || resultFieldSchema === void 0 ? void 0 : resultFieldSchema.encrypted) {
|
||||||
@ -61,16 +39,9 @@ function parseDbResults(_a) {
|
|||||||
}
|
}
|
||||||
parsedResults.push(result);
|
parsedResults.push(result);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Declare variables
|
|
||||||
*
|
|
||||||
* @description Declare "results" variable
|
|
||||||
*/
|
|
||||||
return parsedResults;
|
return parsedResults;
|
||||||
}
|
}
|
||||||
catch ( /** @type {any} */error) {
|
catch (error) {
|
||||||
console.log("ERROR in parseDbResults Function =>", error.message);
|
|
||||||
return unparsedResults;
|
return unparsedResults;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@ export default function dbGrabUserResource<T extends {
|
|||||||
error: any;
|
error: any;
|
||||||
msg: string | undefined;
|
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,
|
error: result === null || result === void 0 ? void 0 : result.error,
|
||||||
msg: result === null || result === void 0 ? void 0 : result.msg,
|
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
|
* # Generate Table Column Description
|
||||||
*/
|
*/
|
||||||
function generateColumnDescription({ columnData, primaryKeySet, }) {
|
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 = "";
|
let fieldEntryText = "";
|
||||||
const finalDataTypeObject = (0, data_type_parser_1.default)(dataType);
|
const finalDataTypeObject = (0, data_type_parser_1.default)(dataType);
|
||||||
const finalDataType = (0, data_type_constructor_1.default)(finalDataTypeObject.type, finalDataTypeObject.limit, finalDataTypeObject.decimal);
|
const finalDataType = (0, data_type_constructor_1.default)(finalDataTypeObject.type, finalDataTypeObject.limit, finalDataTypeObject.decimal);
|
||||||
|
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}`;
|
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
||||||
|
}
|
||||||
if (nullValue) {
|
if (nullValue) {
|
||||||
fieldEntryText += " DEFAULT NULL";
|
fieldEntryText += " DEFAULT NULL";
|
||||||
}
|
}
|
||||||
|
2
dist/package-shared/types/dsql.d.ts
vendored
2
dist/package-shared/types/dsql.d.ts
vendored
@ -91,6 +91,7 @@ export type DSQL_DATASQUIREL_USER_DATABASES = {
|
|||||||
db_full_name?: string;
|
db_full_name?: string;
|
||||||
db_image?: string;
|
db_image?: string;
|
||||||
db_description?: string;
|
db_description?: string;
|
||||||
|
db_long_description?: string;
|
||||||
remote_connected?: number;
|
remote_connected?: number;
|
||||||
remote_connection_type?: string;
|
remote_connection_type?: string;
|
||||||
remote_db_full_name?: string;
|
remote_db_full_name?: string;
|
||||||
@ -118,6 +119,7 @@ export type DSQL_DATASQUIREL_USER_DATABASE_TABLES = {
|
|||||||
table_name?: string;
|
table_name?: string;
|
||||||
table_slug?: string;
|
table_slug?: string;
|
||||||
table_description?: string;
|
table_description?: string;
|
||||||
|
table_long_description?: string;
|
||||||
child_table?: number;
|
child_table?: number;
|
||||||
child_table_parent_database_schema_id?: number;
|
child_table_parent_database_schema_id?: number;
|
||||||
child_table_parent_table_schema_id?: number;
|
child_table_parent_table_schema_id?: number;
|
||||||
|
32
dist/package-shared/types/index.d.ts
vendored
32
dist/package-shared/types/index.d.ts
vendored
@ -65,6 +65,9 @@ export declare const TextFieldTypesArray: readonly [{
|
|||||||
}, {
|
}, {
|
||||||
readonly title: "Rich Text";
|
readonly title: "Rich Text";
|
||||||
readonly value: "richText";
|
readonly value: "richText";
|
||||||
|
}, {
|
||||||
|
readonly title: "Markdown";
|
||||||
|
readonly value: "markdown";
|
||||||
}, {
|
}, {
|
||||||
readonly title: "JSON";
|
readonly title: "JSON";
|
||||||
readonly value: "json";
|
readonly value: "json";
|
||||||
@ -90,6 +93,7 @@ export declare const TextFieldTypesArray: readonly [{
|
|||||||
export type DSQL_FieldSchemaType = {
|
export type DSQL_FieldSchemaType = {
|
||||||
id?: number | string;
|
id?: number | string;
|
||||||
fieldName?: string;
|
fieldName?: string;
|
||||||
|
fieldDescription?: string;
|
||||||
originName?: string;
|
originName?: string;
|
||||||
updatedField?: boolean;
|
updatedField?: boolean;
|
||||||
dataType?: string;
|
dataType?: string;
|
||||||
@ -1259,6 +1263,7 @@ export type DsqlCrudParam<T extends {
|
|||||||
countOnly?: boolean;
|
countOnly?: boolean;
|
||||||
dbFullName?: string;
|
dbFullName?: string;
|
||||||
dbName?: string;
|
dbName?: string;
|
||||||
|
tableSchema?: DSQL_TableSchemaType;
|
||||||
};
|
};
|
||||||
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
||||||
export interface MariaDBUser {
|
export interface MariaDBUser {
|
||||||
@ -1707,6 +1712,17 @@ export type SiteConfigMain = {
|
|||||||
sharp_image_quality?: SiteConfigMainValue;
|
sharp_image_quality?: SiteConfigMainValue;
|
||||||
max_backups?: SiteConfigMainValue;
|
max_backups?: SiteConfigMainValue;
|
||||||
max_disk_usage?: 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 = {
|
export type SiteConfigMainValue = {
|
||||||
value: number | null;
|
value: number | null;
|
||||||
@ -2051,8 +2067,22 @@ export interface GiteaTreeResTree {
|
|||||||
sha: string;
|
sha: string;
|
||||||
url: 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 = {
|
export type OpsObject = {
|
||||||
action: (typeof OpsActions)[number];
|
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 {};
|
export {};
|
||||||
|
55
dist/package-shared/types/index.js
vendored
55
dist/package-shared/types/index.js
vendored
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
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 = [
|
exports.UsersOmitedFields = [
|
||||||
"password",
|
"password",
|
||||||
"social_id",
|
"social_id",
|
||||||
@ -15,6 +15,7 @@ exports.UsersOmitedFields = [
|
|||||||
exports.TextFieldTypesArray = [
|
exports.TextFieldTypesArray = [
|
||||||
{ title: "Plain Text", value: "plain" },
|
{ title: "Plain Text", value: "plain" },
|
||||||
{ title: "Rich Text", value: "richText" },
|
{ title: "Rich Text", value: "richText" },
|
||||||
|
{ title: "Markdown", value: "markdown" },
|
||||||
{ title: "JSON", value: "json" },
|
{ title: "JSON", value: "json" },
|
||||||
{ title: "YAML", value: "yaml" },
|
{ title: "YAML", value: "yaml" },
|
||||||
{ title: "HTML", value: "html" },
|
{ title: "HTML", value: "html" },
|
||||||
@ -447,7 +448,59 @@ exports.OpsActions = [
|
|||||||
"exit",
|
"exit",
|
||||||
"test",
|
"test",
|
||||||
"restart-web-app",
|
"restart-web-app",
|
||||||
|
"restart-web-app-container",
|
||||||
"restart-db",
|
"restart-db",
|
||||||
"restart-all",
|
"restart-all",
|
||||||
"clear",
|
"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",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
1
dist/package-shared/utils/check-array-depth.d.ts
vendored
Normal file
1
dist/package-shared/utils/check-array-depth.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function checkArrayDepth(arr: any[] | any[][] | any[][][] | any, depth: number): boolean;
|
10
dist/package-shared/utils/check-array-depth.js
vendored
Normal file
10
dist/package-shared/utils/check-array-depth.js
vendored
Normal file
@ -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));
|
||||||
|
}
|
@ -3,4 +3,4 @@ export default function <T extends {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
} = {
|
} = {
|
||||||
[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>;
|
||||||
|
@ -15,8 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
exports.default = default_1;
|
exports.default = default_1;
|
||||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||||
const conn_db_handler_1 = __importDefault(require("../db/conn-db-handler"));
|
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) {
|
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;
|
var _b, _c, _d, _e;
|
||||||
let queryObject;
|
let queryObject;
|
||||||
queryObject = (0, sql_generator_1.default)({
|
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 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]);
|
const isSuccess = Array.isArray(res) && Array.isArray(res[0]);
|
||||||
return {
|
return {
|
||||||
success: isSuccess,
|
success: isSuccess,
|
||||||
payload: isSuccess ? (countOnly ? null : res[0]) : null,
|
payload: isSuccess ? (countOnly ? null : parsedRes) : null,
|
||||||
batchPayload: isSuccess ? (countOnly ? null : res) : null,
|
batchPayload: isSuccess ? (countOnly ? null : parsedBatchRes) : null,
|
||||||
error: isSuccess ? undefined : res === null || res === void 0 ? void 0 : res.error,
|
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,
|
errors: res === null || res === void 0 ? void 0 : res.errors,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: queryObject === null || queryObject === void 0 ? void 0 : queryObject.string,
|
sql: queryObject === null || queryObject === void 0 ? void 0 : queryObject.string,
|
||||||
|
@ -20,7 +20,7 @@ const addDbEntry_1 = __importDefault(require("../../functions/backend/db/addDbEn
|
|||||||
const updateDbEntry_1 = __importDefault(require("../../functions/backend/db/updateDbEntry"));
|
const updateDbEntry_1 = __importDefault(require("../../functions/backend/db/updateDbEntry"));
|
||||||
function dsqlCrud(params) {
|
function dsqlCrud(params) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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 finalData = (sanitize ? sanitize({ data }) : data);
|
||||||
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -35,6 +35,7 @@ function dsqlCrud(params) {
|
|||||||
tableName: table,
|
tableName: table,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
debug,
|
debug,
|
||||||
|
tableSchema,
|
||||||
});
|
});
|
||||||
return INSERT_RESULT;
|
return INSERT_RESULT;
|
||||||
case "update":
|
case "update":
|
||||||
@ -46,6 +47,7 @@ function dsqlCrud(params) {
|
|||||||
identifierColumnName: (targetField || "id"),
|
identifierColumnName: (targetField || "id"),
|
||||||
identifierValue: String(targetValue || targetId),
|
identifierValue: String(targetValue || targetId),
|
||||||
debug,
|
debug,
|
||||||
|
tableSchema,
|
||||||
});
|
});
|
||||||
return UPDATE_RESULT;
|
return UPDATE_RESULT;
|
||||||
case "delete":
|
case "delete":
|
||||||
|
@ -16,6 +16,8 @@ function grabTextFieldType(field, nullReturn) {
|
|||||||
return "javascript";
|
return "javascript";
|
||||||
if (field.shell)
|
if (field.shell)
|
||||||
return "shell";
|
return "shell";
|
||||||
|
if (field.markdown)
|
||||||
|
return "markdown";
|
||||||
if (nullReturn)
|
if (nullReturn)
|
||||||
return undefined;
|
return undefined;
|
||||||
return "plain";
|
return "plain";
|
||||||
|
@ -68,10 +68,11 @@ function default_1({ currentDbSchema, currentTableSchema, currentTableSchemaInde
|
|||||||
/**
|
/**
|
||||||
* Handle scenario where this table is a child of another
|
* Handle scenario where this table is a child of another
|
||||||
*/
|
*/
|
||||||
if (currentTableSchema.childTable &&
|
if (currentTableSchema.childTable && currentTableSchema.childTableDbId) {
|
||||||
currentTableSchema.childTableDbId &&
|
const isParentDbCurrentDb = currentTableSchema.childTableDbId == newCurrentDbSchema.id;
|
||||||
currentTableSchema.childTableDbId) {
|
const targetParentDatabase = isParentDbCurrentDb
|
||||||
const targetParentDatabase = (0, grab_required_database_schemas_1.grabPrimaryRequiredDbSchema)({
|
? newCurrentDbSchema
|
||||||
|
: (0, grab_required_database_schemas_1.grabPrimaryRequiredDbSchema)({
|
||||||
dbId: currentTableSchema.childTableDbId,
|
dbId: currentTableSchema.childTableDbId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
@ -32,5 +32,7 @@ function setTextFieldType(field, type) {
|
|||||||
return Object.assign(Object.assign({}, newField), { javascript: true });
|
return Object.assign(Object.assign({}, newField), { javascript: true });
|
||||||
if (type == "code")
|
if (type == "code")
|
||||||
return Object.assign(Object.assign({}, newField), { code: true });
|
return Object.assign(Object.assign({}, newField), { code: true });
|
||||||
|
if (type == "markdown")
|
||||||
|
return Object.assign(Object.assign({}, newField), { markdown: true });
|
||||||
return Object.assign({}, newField);
|
return Object.assign({}, newField);
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,5 @@ export default function grabDockerResourceIPNumbers(): {
|
|||||||
readonly replica_1: 37;
|
readonly replica_1: 37;
|
||||||
readonly replica_2: 38;
|
readonly replica_2: 38;
|
||||||
readonly web_app_post_db_setup: 71;
|
readonly web_app_post_db_setup: 71;
|
||||||
|
readonly static: 77;
|
||||||
};
|
};
|
||||||
|
@ -14,5 +14,6 @@ function grabDockerResourceIPNumbers() {
|
|||||||
replica_1: 37,
|
replica_1: 37,
|
||||||
replica_2: 38,
|
replica_2: 38,
|
||||||
web_app_post_db_setup: 71,
|
web_app_post_db_setup: 71,
|
||||||
|
static: 77,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
7
dist/package-shared/utils/grab-user-ai-info.d.ts
vendored
Normal file
7
dist/package-shared/utils/grab-user-ai-info.d.ts
vendored
Normal file
@ -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
dist/package-shared/utils/grab-user-ai-info.js
vendored
Normal file
23
dist/package-shared/utils/grab-user-ai-info.js
vendored
Normal file
@ -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;
|
||||||
|
}
|
38
index.ts
38
index.ts
@ -1,10 +1,4 @@
|
|||||||
import type { Connection } from "mariadb";
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
var DSQL_DB_CONN: Connection | undefined;
|
|
||||||
var DSQL_READ_ONLY_DB_CONN: Connection | undefined;
|
|
||||||
var DSQL_FULL_ACCESS_DB_CONN: Connection | undefined;
|
|
||||||
var DSQL_USE_LOCAL: boolean | undefined;
|
|
||||||
var ERROR_CALLBACK: ErrorCallback | undefined;
|
var ERROR_CALLBACK: ErrorCallback | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12,9 +6,6 @@ import get from "./package-shared/actions/get";
|
|||||||
import post from "./package-shared/actions/post";
|
import post from "./package-shared/actions/post";
|
||||||
import getSchema from "./package-shared/actions/get-schema";
|
import getSchema from "./package-shared/actions/get-schema";
|
||||||
|
|
||||||
import createUser from "./package-shared/actions/users/add-user";
|
|
||||||
import updateUser from "./package-shared/actions/users/update-user";
|
|
||||||
|
|
||||||
import datasquirelClient from "./client";
|
import datasquirelClient from "./client";
|
||||||
import sqlGenerator from "./package-shared/functions/dsql/sql/sql-generator";
|
import sqlGenerator from "./package-shared/functions/dsql/sql/sql-generator";
|
||||||
import sqlInsertGenerator from "./package-shared/functions/dsql/sql/sql-insert-generator";
|
import sqlInsertGenerator from "./package-shared/functions/dsql/sql/sql-insert-generator";
|
||||||
@ -36,28 +27,7 @@ import localUser from "./package-shared/api/user/local-user";
|
|||||||
import media from "./package-shared/api/media";
|
import media from "./package-shared/api/media";
|
||||||
import dbHandler from "./package-shared/functions/backend/dbHandler";
|
import dbHandler from "./package-shared/functions/backend/dbHandler";
|
||||||
import httpsRequest from "./package-shared/functions/backend/httpsRequest";
|
import httpsRequest from "./package-shared/functions/backend/httpsRequest";
|
||||||
|
import handleNodemailer from "./package-shared/functions/backend/handleNodemailer";
|
||||||
/**
|
|
||||||
* User Functions Object
|
|
||||||
*/
|
|
||||||
// const user = {
|
|
||||||
// createUser: createUser,
|
|
||||||
// deleteUser,
|
|
||||||
// loginUser: loginUser,
|
|
||||||
// sendEmailCode: sendEmailCode,
|
|
||||||
// logoutUser: logoutUser,
|
|
||||||
// userAuth: userAuth,
|
|
||||||
// reAuthUser: reAuthUser,
|
|
||||||
// updateUser: updateUser,
|
|
||||||
// getUser: getUser,
|
|
||||||
// getToken: getToken,
|
|
||||||
// validateToken: validateToken,
|
|
||||||
// validateTempEmailCode,
|
|
||||||
// social: {
|
|
||||||
// loginWithGoogle: loginWithGoogle,
|
|
||||||
// loginWithGithub: loginWithGithub,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API Functions Object
|
* API Functions Object
|
||||||
@ -125,6 +95,12 @@ const datasquirel = {
|
|||||||
* General Database Handler
|
* General Database Handler
|
||||||
*/
|
*/
|
||||||
dbHandler,
|
dbHandler,
|
||||||
|
/**
|
||||||
|
* Handle Mail
|
||||||
|
*/
|
||||||
|
mail: {
|
||||||
|
mailer: handleNodemailer,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default datasquirel;
|
export default datasquirel;
|
||||||
|
@ -68,6 +68,16 @@ const DataTypes = [
|
|||||||
value: "0-255",
|
value: "0-255",
|
||||||
description: "LONGTEXT is just text with max length 4,294,967,295",
|
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",
|
title: "DECIMAL",
|
||||||
name: "DECIMAL",
|
name: "DECIMAL",
|
||||||
|
@ -8,4 +8,5 @@ export const AppNames = {
|
|||||||
WebsocketPathname: "dsql-websocket",
|
WebsocketPathname: "dsql-websocket",
|
||||||
ReverseProxyForwardURLHeaderName: "x-original-uri",
|
ReverseProxyForwardURLHeaderName: "x-original-uri",
|
||||||
PrivateAPIAuthHeaderName: "x-api-auth-key",
|
PrivateAPIAuthHeaderName: "x-api-auth-key",
|
||||||
|
StaticProxyForwardURLHeaderName: "x-media-path",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -6,4 +6,6 @@ export const LocalStorageDict = {
|
|||||||
CSRF: getCsrfHeaderName(),
|
CSRF: getCsrfHeaderName(),
|
||||||
CurrentQueue: "current_queue",
|
CurrentQueue: "current_queue",
|
||||||
DiskUsage: "disk_usage",
|
DiskUsage: "disk_usage",
|
||||||
|
MarkdownEditorDefaultSideBySide: "markdown_editor_default_side_by_side",
|
||||||
|
MarkdownEditorDefaultPreview: "markdown_editor_default_preview",
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,7 @@ export default async function handleSocialDb({
|
|||||||
}: HandleSocialDbFunctionParams): Promise<APIResponseObject> {
|
}: HandleSocialDbFunctionParams): Promise<APIResponseObject> {
|
||||||
try {
|
try {
|
||||||
const finalDbName = database;
|
const finalDbName = database;
|
||||||
|
const MAX_IMAGE_STRING_LENGTH = 350;
|
||||||
|
|
||||||
const existingSocialUserQUery = `SELECT * FROM users WHERE email = ? AND social_login='1' AND social_platform = ? `;
|
const existingSocialUserQUery = `SELECT * FROM users WHERE email = ? AND social_login='1' AND social_platform = ? `;
|
||||||
const existingSocialUserValues = [email, social_platform];
|
const existingSocialUserValues = [email, social_platform];
|
||||||
@ -127,6 +128,14 @@ export default async function handleSocialDb({
|
|||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(payload).forEach((key) => {
|
Object.keys(payload).forEach((key) => {
|
||||||
|
if (key.match(/image/)) {
|
||||||
|
const imageString = payload[key] as string | undefined;
|
||||||
|
if (
|
||||||
|
!imageString ||
|
||||||
|
imageString.length > MAX_IMAGE_STRING_LENGTH
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
}
|
||||||
data[key] = payload[key];
|
data[key] = payload[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
// @ts-check
|
import { DSQL_TableSchemaType } from "../../types";
|
||||||
|
|
||||||
import decrypt from "../dsql/decrypt";
|
import decrypt from "../dsql/decrypt";
|
||||||
import defaultFieldsRegexp from "../dsql/default-fields-regexp";
|
import defaultFieldsRegexp from "../dsql/default-fields-regexp";
|
||||||
|
|
||||||
type Param = {
|
type Param = {
|
||||||
unparsedResults: any[];
|
unparsedResults: any[];
|
||||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
tableSchema?: DSQL_TableSchemaType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,23 +14,13 @@ type Param = {
|
|||||||
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
* function, decrypts encrypted fields, and returns an updated array with no encrypted
|
||||||
* fields
|
* fields
|
||||||
*/
|
*/
|
||||||
export default async function parseDbResults({
|
export default function parseDbResults({
|
||||||
unparsedResults,
|
unparsedResults,
|
||||||
tableSchema,
|
tableSchema,
|
||||||
}: Param): Promise<any[] | null> {
|
}: Param): any[] | null {
|
||||||
/**
|
|
||||||
* Declare variables
|
|
||||||
*
|
|
||||||
* @description Declare "results" variable
|
|
||||||
*/
|
|
||||||
let parsedResults = [];
|
let parsedResults = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/**
|
|
||||||
* Declare variables
|
|
||||||
*
|
|
||||||
* @description Declare "results" variable
|
|
||||||
*/
|
|
||||||
for (let pr = 0; pr < unparsedResults.length; pr++) {
|
for (let pr = 0; pr < unparsedResults.length; pr++) {
|
||||||
let result = unparsedResults[pr];
|
let result = unparsedResults[pr];
|
||||||
|
|
||||||
@ -39,7 +28,9 @@ export default async function parseDbResults({
|
|||||||
|
|
||||||
for (let i = 0; i < resultFieldNames.length; i++) {
|
for (let i = 0; i < resultFieldNames.length; i++) {
|
||||||
const resultFieldName = resultFieldNames[i];
|
const resultFieldName = resultFieldNames[i];
|
||||||
let resultFieldSchema = tableSchema?.fields[i];
|
let resultFieldSchema = tableSchema?.fields.find(
|
||||||
|
(fld) => fld.fieldName == resultFieldName
|
||||||
|
);
|
||||||
|
|
||||||
if (resultFieldName?.match(defaultFieldsRegexp)) {
|
if (resultFieldName?.match(defaultFieldsRegexp)) {
|
||||||
continue;
|
continue;
|
||||||
@ -48,7 +39,6 @@ export default async function parseDbResults({
|
|||||||
let value = result[resultFieldName];
|
let value = result[resultFieldName];
|
||||||
|
|
||||||
if (typeof value !== "number" && !value) {
|
if (typeof value !== "number" && !value) {
|
||||||
// parsedResults.push(result);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,14 +54,8 @@ export default async function parseDbResults({
|
|||||||
parsedResults.push(result);
|
parsedResults.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Declare variables
|
|
||||||
*
|
|
||||||
* @description Declare "results" variable
|
|
||||||
*/
|
|
||||||
return parsedResults;
|
return parsedResults;
|
||||||
} catch (/** @type {any} */ error: any) {
|
} catch (error: any) {
|
||||||
console.log("ERROR in parseDbResults Function =>", error.message);
|
|
||||||
return unparsedResults;
|
return unparsedResults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,6 @@ export default async function dbGrabUserResource<
|
|||||||
error: result?.error,
|
error: result?.error,
|
||||||
msg: result?.msg,
|
msg: result?.msg,
|
||||||
},
|
},
|
||||||
count: typeof result?.count == "number" ? result.count : undefined,
|
count: typeof result?.count == "number" ? result.count : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ export default function generateColumnDescription({
|
|||||||
onUpdateLiteral,
|
onUpdateLiteral,
|
||||||
notNullValue,
|
notNullValue,
|
||||||
unique,
|
unique,
|
||||||
|
options,
|
||||||
} = columnData;
|
} = columnData;
|
||||||
|
|
||||||
let fieldEntryText = "";
|
let fieldEntryText = "";
|
||||||
@ -41,7 +42,13 @@ export default function generateColumnDescription({
|
|||||||
finalDataTypeObject.decimal
|
finalDataTypeObject.decimal
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (finalDataType.match(/enum/i) && options?.[0]) {
|
||||||
|
fieldEntryText += `\`${fieldName}\` ${finalDataType}(${options
|
||||||
|
.map((opt) => `'${opt}'`)
|
||||||
|
.join(",")})`;
|
||||||
|
} else {
|
||||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (nullValue) {
|
if (nullValue) {
|
||||||
fieldEntryText += " DEFAULT NULL";
|
fieldEntryText += " DEFAULT NULL";
|
||||||
|
@ -118,6 +118,7 @@ export type DSQL_DATASQUIREL_USER_DATABASES = {
|
|||||||
db_full_name?: string;
|
db_full_name?: string;
|
||||||
db_image?: string;
|
db_image?: string;
|
||||||
db_description?: string;
|
db_description?: string;
|
||||||
|
db_long_description?: string;
|
||||||
remote_connected?: number;
|
remote_connected?: number;
|
||||||
remote_connection_type?: string;
|
remote_connection_type?: string;
|
||||||
remote_db_full_name?: string;
|
remote_db_full_name?: string;
|
||||||
@ -146,6 +147,7 @@ export type DSQL_DATASQUIREL_USER_DATABASE_TABLES = {
|
|||||||
table_name?: string;
|
table_name?: string;
|
||||||
table_slug?: string;
|
table_slug?: string;
|
||||||
table_description?: string;
|
table_description?: string;
|
||||||
|
table_long_description?: string;
|
||||||
child_table?: number;
|
child_table?: number;
|
||||||
child_table_parent_database_schema_id?: number;
|
child_table_parent_database_schema_id?: number;
|
||||||
child_table_parent_table_schema_id?: number;
|
child_table_parent_table_schema_id?: number;
|
||||||
|
@ -107,6 +107,7 @@ export interface DSQL_ChildrenTablesType {
|
|||||||
export const TextFieldTypesArray = [
|
export const TextFieldTypesArray = [
|
||||||
{ title: "Plain Text", value: "plain" },
|
{ title: "Plain Text", value: "plain" },
|
||||||
{ title: "Rich Text", value: "richText" },
|
{ title: "Rich Text", value: "richText" },
|
||||||
|
{ title: "Markdown", value: "markdown" },
|
||||||
{ title: "JSON", value: "json" },
|
{ title: "JSON", value: "json" },
|
||||||
{ title: "YAML", value: "yaml" },
|
{ title: "YAML", value: "yaml" },
|
||||||
{ title: "HTML", value: "html" },
|
{ title: "HTML", value: "html" },
|
||||||
@ -119,6 +120,7 @@ export const TextFieldTypesArray = [
|
|||||||
export type DSQL_FieldSchemaType = {
|
export type DSQL_FieldSchemaType = {
|
||||||
id?: number | string;
|
id?: number | string;
|
||||||
fieldName?: string;
|
fieldName?: string;
|
||||||
|
fieldDescription?: string;
|
||||||
originName?: string;
|
originName?: string;
|
||||||
updatedField?: boolean;
|
updatedField?: boolean;
|
||||||
dataType?: string;
|
dataType?: string;
|
||||||
@ -1471,6 +1473,7 @@ export type DsqlCrudParam<
|
|||||||
countOnly?: boolean;
|
countOnly?: boolean;
|
||||||
dbFullName?: string;
|
dbFullName?: string;
|
||||||
dbName?: string;
|
dbName?: string;
|
||||||
|
tableSchema?: DSQL_TableSchemaType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
export type ErrorCallback = (title: string, error: Error, data?: any) => void;
|
||||||
@ -2137,6 +2140,19 @@ export type SiteConfigMain = {
|
|||||||
sharp_image_quality?: SiteConfigMainValue;
|
sharp_image_quality?: SiteConfigMainValue;
|
||||||
max_backups?: SiteConfigMainValue;
|
max_backups?: SiteConfigMainValue;
|
||||||
max_disk_usage?: 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 = {
|
export type SiteConfigMainValue = {
|
||||||
@ -2629,6 +2645,7 @@ export const OpsActions = [
|
|||||||
"exit",
|
"exit",
|
||||||
"test",
|
"test",
|
||||||
"restart-web-app",
|
"restart-web-app",
|
||||||
|
"restart-web-app-container",
|
||||||
"restart-db",
|
"restart-db",
|
||||||
"restart-all",
|
"restart-all",
|
||||||
"clear",
|
"clear",
|
||||||
@ -2637,3 +2654,70 @@ export const OpsActions = [
|
|||||||
export type OpsObject = {
|
export type OpsObject = {
|
||||||
action: (typeof OpsActions)[number];
|
action: (typeof OpsActions)[number];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const AIOptions: AIOptionsObject[] = [
|
||||||
|
{
|
||||||
|
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",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export type AIOptionsObject = {
|
||||||
|
name?: string;
|
||||||
|
title?: string;
|
||||||
|
models?: string[];
|
||||||
|
targetModel?: string;
|
||||||
|
customModel?: string;
|
||||||
|
apiKey?: string;
|
||||||
|
baseUrl?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AIComponentProps = {
|
||||||
|
targetAI: AIOptionsObject;
|
||||||
|
context: any[];
|
||||||
|
};
|
||||||
|
8
package-shared/utils/check-array-depth.ts
Normal file
8
package-shared/utils/check-array-depth.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export default function checkArrayDepth(
|
||||||
|
arr: any[] | any[][] | any[][][] | any,
|
||||||
|
depth: number
|
||||||
|
): boolean {
|
||||||
|
if (!Array.isArray(arr)) return false;
|
||||||
|
if (depth === 1) return true;
|
||||||
|
return arr.every((item) => checkArrayDepth(item, depth - 1));
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||||
import { APIResponseObject, DsqlCrudParam } from "../../types";
|
import { APIResponseObject, DsqlCrudParam } from "../../types";
|
||||||
import connDbHandler, { ConnDBHandlerQueryObject } from "../db/conn-db-handler";
|
import connDbHandler, { ConnDBHandlerQueryObject } from "../db/conn-db-handler";
|
||||||
|
import checkArrayDepth from "../check-array-depth";
|
||||||
|
import parseDbResults from "../../functions/backend/parseDbResults";
|
||||||
|
|
||||||
export default async function <
|
export default async function <
|
||||||
T extends { [key: string]: any } = { [key: string]: any }
|
T extends { [key: string]: any } = { [key: string]: any }
|
||||||
@ -10,6 +12,7 @@ export default async function <
|
|||||||
count,
|
count,
|
||||||
countOnly,
|
countOnly,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
|
tableSchema,
|
||||||
}: Omit<
|
}: Omit<
|
||||||
DsqlCrudParam<T>,
|
DsqlCrudParam<T>,
|
||||||
"action" | "data" | "sanitize"
|
"action" | "data" | "sanitize"
|
||||||
@ -55,13 +58,26 @@ export default async function <
|
|||||||
|
|
||||||
const res = await connDbHandler(undefined, connQueries);
|
const res = await connDbHandler(undefined, connQueries);
|
||||||
|
|
||||||
|
const parsedRes = checkArrayDepth(res, 2)
|
||||||
|
? parseDbResults({ unparsedResults: res[0], tableSchema })
|
||||||
|
: res[0];
|
||||||
|
const parsedBatchRes = checkArrayDepth(res, 3)
|
||||||
|
? res.map((_r: any[][]) => {
|
||||||
|
return parseDbResults({ unparsedResults: _r[0], tableSchema });
|
||||||
|
})
|
||||||
|
: res;
|
||||||
|
|
||||||
const isSuccess = Array.isArray(res) && Array.isArray(res[0]);
|
const isSuccess = Array.isArray(res) && Array.isArray(res[0]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: isSuccess,
|
success: isSuccess,
|
||||||
payload: isSuccess ? (countOnly ? null : res[0]) : null,
|
payload: isSuccess ? (countOnly ? null : parsedRes) : null,
|
||||||
batchPayload: isSuccess ? (countOnly ? null : res) : null,
|
batchPayload: isSuccess ? (countOnly ? null : parsedBatchRes) : null,
|
||||||
error: isSuccess ? undefined : res?.error,
|
error: isSuccess
|
||||||
|
? undefined
|
||||||
|
: typeof res == "object" && !Array.isArray(res)
|
||||||
|
? res?.error
|
||||||
|
: undefined,
|
||||||
errors: res?.errors,
|
errors: res?.errors,
|
||||||
queryObject: {
|
queryObject: {
|
||||||
sql: queryObject?.string,
|
sql: queryObject?.string,
|
||||||
|
@ -26,6 +26,7 @@ export default async function dsqlCrud<
|
|||||||
batchData,
|
batchData,
|
||||||
deleteKeyValues,
|
deleteKeyValues,
|
||||||
debug,
|
debug,
|
||||||
|
tableSchema,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const finalData = (sanitize ? sanitize({ data }) : data) as T;
|
const finalData = (sanitize ? sanitize({ data }) : data) as T;
|
||||||
@ -47,6 +48,7 @@ export default async function dsqlCrud<
|
|||||||
tableName: table,
|
tableName: table,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
debug,
|
debug,
|
||||||
|
tableSchema,
|
||||||
});
|
});
|
||||||
return INSERT_RESULT;
|
return INSERT_RESULT;
|
||||||
|
|
||||||
@ -60,6 +62,7 @@ export default async function dsqlCrud<
|
|||||||
identifierColumnName: (targetField || "id") as string,
|
identifierColumnName: (targetField || "id") as string,
|
||||||
identifierValue: String(targetValue || targetId),
|
identifierValue: String(targetValue || targetId),
|
||||||
debug,
|
debug,
|
||||||
|
tableSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
return UPDATE_RESULT;
|
return UPDATE_RESULT;
|
||||||
|
@ -11,6 +11,7 @@ export default function grabTextFieldType(
|
|||||||
if (field.css) return "css";
|
if (field.css) return "css";
|
||||||
if (field.javascript) return "javascript";
|
if (field.javascript) return "javascript";
|
||||||
if (field.shell) return "shell";
|
if (field.shell) return "shell";
|
||||||
|
if (field.markdown) return "markdown";
|
||||||
if (nullReturn) return undefined;
|
if (nullReturn) return undefined;
|
||||||
return "plain";
|
return "plain";
|
||||||
}
|
}
|
||||||
|
@ -122,12 +122,13 @@ export default function ({
|
|||||||
/**
|
/**
|
||||||
* Handle scenario where this table is a child of another
|
* Handle scenario where this table is a child of another
|
||||||
*/
|
*/
|
||||||
if (
|
if (currentTableSchema.childTable && currentTableSchema.childTableDbId) {
|
||||||
currentTableSchema.childTable &&
|
const isParentDbCurrentDb =
|
||||||
currentTableSchema.childTableDbId &&
|
currentTableSchema.childTableDbId == newCurrentDbSchema.id;
|
||||||
currentTableSchema.childTableDbId
|
|
||||||
) {
|
const targetParentDatabase = isParentDbCurrentDb
|
||||||
const targetParentDatabase = grabPrimaryRequiredDbSchema({
|
? newCurrentDbSchema
|
||||||
|
: grabPrimaryRequiredDbSchema({
|
||||||
dbId: currentTableSchema.childTableDbId,
|
dbId: currentTableSchema.childTableDbId,
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
@ -26,6 +26,7 @@ export default function setTextFieldType(
|
|||||||
if (type == "yaml") return { ...newField, yaml: true };
|
if (type == "yaml") return { ...newField, yaml: true };
|
||||||
if (type == "javascript") return { ...newField, javascript: true };
|
if (type == "javascript") return { ...newField, javascript: true };
|
||||||
if (type == "code") return { ...newField, code: true };
|
if (type == "code") return { ...newField, code: true };
|
||||||
|
if (type == "markdown") return { ...newField, markdown: true };
|
||||||
|
|
||||||
return { ...newField };
|
return { ...newField };
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,6 @@ export default function grabDockerResourceIPNumbers() {
|
|||||||
replica_1: 37,
|
replica_1: 37,
|
||||||
replica_2: 38,
|
replica_2: 38,
|
||||||
web_app_post_db_setup: 71,
|
web_app_post_db_setup: 71,
|
||||||
|
static: 77,
|
||||||
} as const;
|
} as const;
|
||||||
}
|
}
|
||||||
|
37
package-shared/utils/grab-user-ai-info.ts
Normal file
37
package-shared/utils/grab-user-ai-info.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { AIOptions, AIOptionsObject, SiteConfig } from "../types";
|
||||||
|
|
||||||
|
type Params = {
|
||||||
|
userConfig?: SiteConfig | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GrabUserAIConfigReturn = {};
|
||||||
|
|
||||||
|
export default function grabUserAIInfo({
|
||||||
|
userConfig: passedConfig,
|
||||||
|
}: Params): AIOptionsObject | undefined {
|
||||||
|
const userConfig: SiteConfig | undefined = passedConfig
|
||||||
|
? passedConfig
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (!userConfig) return undefined;
|
||||||
|
|
||||||
|
const targetAI = userConfig?.main.target_ai;
|
||||||
|
|
||||||
|
if (!targetAI?.name || !userConfig?.main.api_keys) return undefined;
|
||||||
|
|
||||||
|
const targetAIAPIKey = userConfig.main.api_keys[targetAI.name].key;
|
||||||
|
|
||||||
|
if (!targetAIAPIKey) return undefined;
|
||||||
|
|
||||||
|
const targetAIOption = AIOptions.find(
|
||||||
|
(aiOpt) => aiOpt.name == targetAI.name
|
||||||
|
);
|
||||||
|
|
||||||
|
targetAI.apiKey = targetAIAPIKey;
|
||||||
|
|
||||||
|
if (targetAIOption?.baseUrl) {
|
||||||
|
targetAI.baseUrl = targetAIOption.baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetAI;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.1.0",
|
"version": "5.1.1",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user