This commit is contained in:
Benjamin Toby 2025-08-02 17:14:46 +01:00
parent 9ca64cf25e
commit 71a8431de5
24 changed files with 164 additions and 48 deletions

View File

@ -4,7 +4,7 @@ declare const DataTypes: readonly [{
readonly value: "0-255"; readonly value: "0-255";
readonly argument: true; readonly argument: true;
readonly description: "Varchar is simply letters and numbers within the range 0 - 255"; readonly description: "Varchar is simply letters and numbers within the range 0 - 255";
readonly maxValue: 255; readonly maxValue: 2000;
}, { }, {
readonly title: "TINYINT"; readonly title: "TINYINT";
readonly name: "TINYINT"; readonly name: "TINYINT";
@ -91,5 +91,10 @@ declare const DataTypes: readonly [{
readonly title: "TIMESTAMP"; readonly title: "TIMESTAMP";
readonly name: "TIMESTAMP"; readonly name: "TIMESTAMP";
readonly description: "Time Stamp"; readonly description: "Time Stamp";
}, {
readonly title: "VECTOR";
readonly name: "VECTOR";
readonly description: "Vector Field for vector-based applications";
readonly maxValue: 2147483647;
}]; }];
export default DataTypes; export default DataTypes;

View File

@ -7,7 +7,7 @@ const DataTypes = [
value: "0-255", value: "0-255",
argument: true, argument: true,
description: "Varchar is simply letters and numbers within the range 0 - 255", description: "Varchar is simply letters and numbers within the range 0 - 255",
maxValue: 255, maxValue: 2000,
}, },
{ {
title: "TINYINT", title: "TINYINT",
@ -111,5 +111,11 @@ const DataTypes = [
name: "TIMESTAMP", name: "TIMESTAMP",
description: "Time Stamp", description: "Time Stamp",
}, },
{
title: "VECTOR",
name: "VECTOR",
description: "Vector Field for vector-based applications",
maxValue: 2147483647,
},
]; ];
exports.default = DataTypes; exports.default = DataTypes;

View File

@ -6,7 +6,7 @@ const DataTypes = [
argument: true, argument: true,
description: description:
"Varchar is simply letters and numbers within the range 0 - 255", "Varchar is simply letters and numbers within the range 0 - 255",
maxValue: 255, maxValue: 2000,
}, },
{ {
title: "TINYINT", title: "TINYINT",
@ -110,6 +110,12 @@ const DataTypes = [
name: "TIMESTAMP", name: "TIMESTAMP",
description: "Time Stamp", description: "Time Stamp",
}, },
{
title: "VECTOR",
name: "VECTOR",
description: "Vector Field for vector-based applications",
maxValue: 2147483647,
},
] as const; ] as const;
export default DataTypes; export default DataTypes;

View File

@ -72,6 +72,7 @@ function addDbEntry(_a) {
} }
} }
function generateQuery(data) { function generateQuery(data) {
var _a, _b;
const dataKeys = Object.keys(data); const dataKeys = Object.keys(data);
let insertKeysArray = []; let insertKeysArray = [];
let insertValuesArray = []; let insertValuesArray = [];
@ -79,6 +80,9 @@ function addDbEntry(_a) {
try { try {
const dataKey = dataKeys[i]; const dataKey = dataKeys[i];
let value = data[dataKey]; let value = data[dataKey];
const targetFieldSchema = tableSchema
? (_a = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields) === null || _a === void 0 ? void 0 : _a.find((field) => field.fieldName === dataKey)
: null;
const parsedValue = (0, grab_parsed_value_1.default)({ const parsedValue = (0, grab_parsed_value_1.default)({
dataKey, dataKey,
encryptionKey, encryptionKey,
@ -89,7 +93,10 @@ function addDbEntry(_a) {
if (typeof parsedValue == "undefined") if (typeof parsedValue == "undefined")
continue; continue;
insertKeysArray.push("`" + dataKey + "`"); insertKeysArray.push("`" + dataKey + "`");
if (typeof parsedValue == "number") { if ((_b = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _b === void 0 ? void 0 : _b.match(/vector/i)) {
insertValuesArray.push(`VEC_FromText('${parsedValue}')`);
}
else if (typeof parsedValue == "number") {
insertValuesArray.push(String(parsedValue)); insertValuesArray.push(String(parsedValue));
} }
else { else {
@ -112,16 +119,32 @@ function addDbEntry(_a) {
const queryValuesArray = insertValuesArray; const queryValuesArray = insertValuesArray;
return { queryValuesArray, insertValuesArray, insertKeysArray }; return { queryValuesArray, insertValuesArray, insertKeysArray };
} }
function grabQueryValuesString(arr) {
return arr
.map((v, i) => {
if (v.toString().match(/VEC_FromText/i)) {
return v;
}
return "?";
})
.join(",");
}
function grabFinalQueryValuesArr(arr) {
return arr
.filter((v) => !v.toString().match(/VEC_FromText/i))
.map((v) => String(v));
}
if (newData) { if (newData) {
const { insertKeysArray, insertValuesArray, queryValuesArray } = generateQuery(newData); const { insertKeysArray, insertValuesArray, queryValuesArray } = generateQuery(newData);
const query = `INSERT INTO ${isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`}\`${tableName}\` (${insertKeysArray.join(",")}) VALUES (${insertValuesArray.map(() => "?").join(",")})`; const query = `INSERT INTO ${isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`}\`${tableName}\` (${insertKeysArray.join(",")}) VALUES (${grabQueryValuesString(insertValuesArray)})`;
const newInsert = yield (0, conn_db_handler_1.default)(null, query, queryValuesArray, debug); const finalQueryValues = grabFinalQueryValuesArr(queryValuesArray);
const newInsert = yield (0, conn_db_handler_1.default)(null, query, finalQueryValues, debug);
return { return {
success: Boolean(newInsert === null || newInsert === void 0 ? void 0 : newInsert.insertId), success: Boolean(newInsert === null || newInsert === void 0 ? void 0 : newInsert.insertId),
payload: newInsert, payload: newInsert,
queryObject: { queryObject: {
sql: query, sql: query,
params: queryValuesArray, params: finalQueryValues,
}, },
}; };
} }
@ -139,11 +162,10 @@ function addDbEntry(_a) {
batchQueryValuesArray.push(queryValuesArray); batchQueryValuesArray.push(queryValuesArray);
} }
const query = `INSERT INTO ${isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`}\`${tableName}\` (${batchInsertKeysArray === null || batchInsertKeysArray === void 0 ? void 0 : batchInsertKeysArray.join(",")}) VALUES ${batchInsertValuesArray const query = `INSERT INTO ${isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`}\`${tableName}\` (${batchInsertKeysArray === null || batchInsertKeysArray === void 0 ? void 0 : batchInsertKeysArray.join(",")}) VALUES ${batchInsertValuesArray
.map((vl) => `(${vl.map(() => "?").join(",")})`) .map((vl) => `(${grabQueryValuesString(vl)})`)
.join(",")}`; .join(",")}`;
console.log("query", query); const finalQueryValues = grabFinalQueryValuesArr(batchQueryValuesArray.flat());
console.log("batchQueryValuesArray", batchQueryValuesArray); const newInsert = yield (0, conn_db_handler_1.default)(null, query, finalQueryValues, debug);
const newInsert = yield (0, conn_db_handler_1.default)(null, query, batchQueryValuesArray.flat(), debug);
if (debug) { if (debug) {
(0, debug_log_1.default)({ (0, debug_log_1.default)({
log: newInsert, log: newInsert,
@ -156,7 +178,7 @@ function addDbEntry(_a) {
payload: newInsert, payload: newInsert,
queryObject: { queryObject: {
sql: query, sql: query,
params: batchQueryValuesArray.flat(), params: finalQueryValues,
}, },
}; };
} }

View File

@ -14,11 +14,8 @@ const encrypt_1 = __importDefault(require("../../dsql/encrypt"));
function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, dataKey, }) { function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, dataKey, }) {
var _a, _b; var _a, _b;
let newValue = value; let newValue = value;
const targetFieldSchemaArray = tableSchema const targetFieldSchema = tableSchema
? (_a = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields) === null || _a === void 0 ? void 0 : _a.filter((field) => field.fieldName === dataKey) ? (_a = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields) === null || _a === void 0 ? void 0 : _a.find((field) => field.fieldName === dataKey)
: null;
const targetFieldSchema = targetFieldSchemaArray && targetFieldSchemaArray[0]
? targetFieldSchemaArray[0]
: null; : null;
if (typeof newValue == "undefined") if (typeof newValue == "undefined")
return; return;

View File

@ -24,6 +24,7 @@ const grab_parsed_value_1 = __importDefault(require("./grab-parsed-value"));
*/ */
function updateDbEntry(_a) { function updateDbEntry(_a) {
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, }) { return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, }) {
var _b, _c;
/** /**
* Check if data is valid * Check if data is valid
*/ */
@ -54,6 +55,9 @@ function updateDbEntry(_a) {
try { try {
const dataKey = dataKeys[i]; const dataKey = dataKeys[i];
let value = newData[dataKey]; let value = newData[dataKey];
const targetFieldSchema = tableSchema
? (_b = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields) === null || _b === void 0 ? void 0 : _b.find((field) => field.fieldName === dataKey)
: null;
const parsedValue = (0, grab_parsed_value_1.default)({ const parsedValue = (0, grab_parsed_value_1.default)({
dataKey, dataKey,
encryptionKey, encryptionKey,
@ -63,7 +67,12 @@ function updateDbEntry(_a) {
}); });
if (typeof parsedValue == "undefined") if (typeof parsedValue == "undefined")
continue; continue;
if ((_c = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _c === void 0 ? void 0 : _c.match(/vector/i)) {
updateKeyValueArray.push(`\`${dataKey}\`=VEC_FromText(?)`);
}
else {
updateKeyValueArray.push(`\`${dataKey}\`=?`); updateKeyValueArray.push(`\`${dataKey}\`=?`);
}
if (typeof parsedValue == "number") { if (typeof parsedValue == "number") {
updateValues.push(String(parsedValue)); updateValues.push(String(parsedValue));
} }

View File

@ -36,6 +36,9 @@ function parseDbResults({ unparsedResults, tableSchema, }) {
}); });
} }
} }
if (value && typeof value == "object") {
result[resultFieldName] = "";
}
} }
parsedResults.push(result); parsedResults.push(result);
} }

View File

@ -43,7 +43,11 @@ function handleIndexescreateDbFromSchema(_a) {
* @description Create new index if determined that it * @description Create new index if determined that it
* doesn't exist in MYSQL db * doesn't exist in MYSQL db
*/ */
const queryString = `CREATE${indexType == "full_text" ? " FULLTEXT" : ""} INDEX \`${alias}\` ON \`${dbFullName}\`.\`${tableName}\`(${indexTableFields === null || indexTableFields === void 0 ? void 0 : indexTableFields.map((nm) => nm.value).map((nm) => `\`${nm}\``).join(",")}) COMMENT '${(0, grab_dsql_schema_index_comment_1.default)()} ${indexName}'`; const queryString = `CREATE${indexType == "full_text"
? " FULLTEXT"
: indexType == "vector"
? " VECTOR"
: ""} INDEX \`${alias}\` ON \`${dbFullName}\`.\`${tableName}\`(${indexTableFields === null || indexTableFields === void 0 ? void 0 : indexTableFields.map((nm) => nm.value).map((nm) => `\`${nm}\``).join(",")}) COMMENT '${(0, grab_dsql_schema_index_comment_1.default)()} ${indexName}'`;
const addIndex = yield (0, dbHandler_1.default)({ query: queryString }); const addIndex = yield (0, dbHandler_1.default)({ query: queryString });
} }
} }

View File

@ -1521,6 +1521,7 @@ export type MediaUploadDataType = ImageObjectType & FileObjectType & {
privateFolder?: boolean; privateFolder?: boolean;
overwrite?: boolean; overwrite?: boolean;
updatedMediaRecord?: DSQL_DATASQUIREL_USER_MEDIA; updatedMediaRecord?: DSQL_DATASQUIREL_USER_MEDIA;
existingMediaRecord?: DSQL_DATASQUIREL_USER_MEDIA;
existingMediaRecordId?: number; existingMediaRecordId?: number;
}; };
export declare const ImageMimeTypes: (keyof sharp.FormatEnum)[]; export declare const ImageMimeTypes: (keyof sharp.FormatEnum)[];
@ -1569,7 +1570,7 @@ export type DefaultEntryType = {
} & { } & {
[k: string]: string | number | null; [k: string]: string | number | null;
}; };
export declare const IndexTypes: readonly ["regular", "full_text"]; export declare const IndexTypes: readonly ["regular", "full_text", "vector"];
export type LoginUserParam = { export type LoginUserParam = {
apiKey?: string; apiKey?: string;
database: string; database: string;
@ -1812,6 +1813,10 @@ export type AddMediaAPIBody = {
useDefault?: boolean; useDefault?: boolean;
update?: boolean; update?: boolean;
}; };
export type ReplaceMediaAPIBody = {
mediaId: number;
media: MediaUploadDataType;
};
export declare const TargetMediaParadigms: readonly ["info", "preview"]; export declare const TargetMediaParadigms: readonly ["info", "preview"];
export type TargetMediaDataType = { export type TargetMediaDataType = {
media: DSQL_DATASQUIREL_USER_MEDIA; media: DSQL_DATASQUIREL_USER_MEDIA;

View File

@ -186,7 +186,7 @@ exports.DefaultSQLValuesLiteral = [
dataType: "UUID", dataType: "UUID",
}, },
]; ];
exports.IndexTypes = ["regular", "full_text"]; exports.IndexTypes = ["regular", "full_text", "vector"];
exports.UserSelectFields = [ exports.UserSelectFields = [
{ {
field: "first_name", field: "first_name",

View File

@ -4,6 +4,7 @@ export declare const DataTypesWithTwoNumbers: (typeof DataTypes)[number]["name"]
type Return = { type Return = {
type: (typeof DataTypes)[number]["name"]; type: (typeof DataTypes)[number]["name"];
limit?: number; limit?: number;
defaultNumber?: number;
decimal?: number; decimal?: number;
}; };
export default function dataTypeParser(dataType?: string): Return; export default function dataTypeParser(dataType?: string): Return;

View File

@ -11,6 +11,7 @@ exports.DataTypesWithNumbers = [
"DOUBLE", "DOUBLE",
"FLOAT", "FLOAT",
"VARCHAR", "VARCHAR",
"VECTOR",
]; ];
exports.DataTypesWithTwoNumbers = [ exports.DataTypesWithTwoNumbers = [
"DECIMAL", "DECIMAL",
@ -21,7 +22,7 @@ function dataTypeParser(dataType) {
if (!dataType) { if (!dataType) {
return { return {
type: "VARCHAR", type: "VARCHAR",
limit: 250, defaultNumber: 250,
}; };
} }
const dataTypeArray = dataType.split("("); const dataTypeArray = dataType.split("(");
@ -43,5 +44,6 @@ function dataTypeParser(dataType) {
return { return {
type, type,
limit: number ? (0, numberfy_1.default)(number) : undefined, limit: number ? (0, numberfy_1.default)(number) : undefined,
defaultNumber: type == "VECTOR" ? 120 : 10,
}; };
} }

View File

@ -1,4 +1,4 @@
declare const APIParadigms: readonly ["crud", "media", "schema"]; import { APIParadigms } from "../types";
type Params = { type Params = {
version?: string; version?: string;
paradigm?: (typeof APIParadigms)[number]; paradigm?: (typeof APIParadigms)[number];

View File

@ -1,7 +1,6 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.default = grabAPIBasePath; exports.default = grabAPIBasePath;
const APIParadigms = ["crud", "media", "schema"];
function grabAPIBasePath({ version, paradigm }) { function grabAPIBasePath({ version, paradigm }) {
let basePath = `/api/v${version || "1"}`; let basePath = `/api/v${version || "1"}`;
if (paradigm) { if (paradigm) {

View File

@ -6,7 +6,7 @@ const DataTypes = [
argument: true, argument: true,
description: description:
"Varchar is simply letters and numbers within the range 0 - 255", "Varchar is simply letters and numbers within the range 0 - 255",
maxValue: 255, maxValue: 2000,
}, },
{ {
title: "TINYINT", title: "TINYINT",
@ -110,6 +110,12 @@ const DataTypes = [
name: "TIMESTAMP", name: "TIMESTAMP",
description: "Time Stamp", description: "Time Stamp",
}, },
{
title: "VECTOR",
name: "VECTOR",
description: "Vector Field for vector-based applications",
maxValue: 2147483647,
},
] as const; ] as const;
export default DataTypes; export default DataTypes;

View File

@ -118,13 +118,19 @@ export default async function addDbEntry<
const dataKeys = Object.keys(data); const dataKeys = Object.keys(data);
let insertKeysArray = []; let insertKeysArray = [];
let insertValuesArray = []; let insertValuesArray: (string | number)[] = [];
for (let i = 0; i < dataKeys.length; i++) { for (let i = 0; i < dataKeys.length; i++) {
try { try {
const dataKey = dataKeys[i]; const dataKey = dataKeys[i];
let value = data[dataKey]; let value = data[dataKey];
const targetFieldSchema = tableSchema
? tableSchema?.fields?.find(
(field) => field.fieldName === dataKey
)
: null;
const parsedValue = grabParsedValue({ const parsedValue = grabParsedValue({
dataKey, dataKey,
encryptionKey, encryptionKey,
@ -137,7 +143,9 @@ export default async function addDbEntry<
insertKeysArray.push("`" + dataKey + "`"); insertKeysArray.push("`" + dataKey + "`");
if (typeof parsedValue == "number") { if (targetFieldSchema?.dataType?.match(/vector/i)) {
insertValuesArray.push(`VEC_FromText('${parsedValue}')`);
} else if (typeof parsedValue == "number") {
insertValuesArray.push(String(parsedValue)); insertValuesArray.push(String(parsedValue));
} else { } else {
insertValuesArray.push(parsedValue); insertValuesArray.push(parsedValue);
@ -163,11 +171,28 @@ export default async function addDbEntry<
insertKeysArray.push("`date_updated_code`"); insertKeysArray.push("`date_updated_code`");
insertValuesArray.push(Date.now()); insertValuesArray.push(Date.now());
const queryValuesArray = insertValuesArray; const queryValuesArray = insertValuesArray as (string | number)[];
return { queryValuesArray, insertValuesArray, insertKeysArray }; return { queryValuesArray, insertValuesArray, insertKeysArray };
} }
function grabQueryValuesString(arr: (string | number)[]) {
return arr
.map((v, i) => {
if (v.toString().match(/VEC_FromText/i)) {
return v;
}
return "?";
})
.join(",");
}
function grabFinalQueryValuesArr(arr: (string | number)[]) {
return arr
.filter((v) => !v.toString().match(/VEC_FromText/i))
.map((v) => String(v));
}
if (newData) { if (newData) {
const { insertKeysArray, insertValuesArray, queryValuesArray } = const { insertKeysArray, insertValuesArray, queryValuesArray } =
generateQuery(newData); generateQuery(newData);
@ -176,12 +201,14 @@ export default async function addDbEntry<
isMaster && !dbFullName ? "" : `\`${dbFullName}\`.` isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`
}\`${tableName}\` (${insertKeysArray.join( }\`${tableName}\` (${insertKeysArray.join(
"," ","
)}) VALUES (${insertValuesArray.map(() => "?").join(",")})`; )}) VALUES (${grabQueryValuesString(insertValuesArray)})`;
const finalQueryValues = grabFinalQueryValuesArr(queryValuesArray);
const newInsert = await connDbHandler( const newInsert = await connDbHandler(
null, null,
query, query,
queryValuesArray, finalQueryValues,
debug debug
); );
@ -190,7 +217,7 @@ export default async function addDbEntry<
payload: newInsert, payload: newInsert,
queryObject: { queryObject: {
sql: query, sql: query,
params: queryValuesArray, params: finalQueryValues,
}, },
}; };
} else if (newBatchData) { } else if (newBatchData) {
@ -216,16 +243,17 @@ export default async function addDbEntry<
}\`${tableName}\` (${batchInsertKeysArray?.join( }\`${tableName}\` (${batchInsertKeysArray?.join(
"," ","
)}) VALUES ${batchInsertValuesArray )}) VALUES ${batchInsertValuesArray
.map((vl) => `(${vl.map(() => "?").join(",")})`) .map((vl) => `(${grabQueryValuesString(vl)})`)
.join(",")}`; .join(",")}`;
console.log("query", query); const finalQueryValues = grabFinalQueryValuesArr(
console.log("batchQueryValuesArray", batchQueryValuesArray); batchQueryValuesArray.flat()
);
const newInsert = await connDbHandler( const newInsert = await connDbHandler(
null, null,
query, query,
batchQueryValuesArray.flat(), finalQueryValues,
debug debug
); );
@ -242,7 +270,7 @@ export default async function addDbEntry<
payload: newInsert, payload: newInsert,
queryObject: { queryObject: {
sql: query, sql: query,
params: batchQueryValuesArray.flat(), params: finalQueryValues,
}, },
}; };
} else { } else {

View File

@ -25,12 +25,8 @@ export default function grabParsedValue({
}: Param): any { }: Param): any {
let newValue = value; let newValue = value;
const targetFieldSchemaArray = tableSchema const targetFieldSchema = tableSchema
? tableSchema?.fields?.filter((field) => field.fieldName === dataKey) ? tableSchema?.fields?.find((field) => field.fieldName === dataKey)
: null;
const targetFieldSchema =
targetFieldSchemaArray && targetFieldSchemaArray[0]
? targetFieldSchemaArray[0]
: null; : null;
if (typeof newValue == "undefined") return; if (typeof newValue == "undefined") return;

View File

@ -80,6 +80,12 @@ export default async function updateDbEntry<
const dataKey = dataKeys[i]; const dataKey = dataKeys[i];
let value = newData[dataKey]; let value = newData[dataKey];
const targetFieldSchema = tableSchema
? tableSchema?.fields?.find(
(field) => field.fieldName === dataKey
)
: null;
const parsedValue = grabParsedValue({ const parsedValue = grabParsedValue({
dataKey, dataKey,
encryptionKey, encryptionKey,
@ -90,7 +96,11 @@ export default async function updateDbEntry<
if (typeof parsedValue == "undefined") continue; if (typeof parsedValue == "undefined") continue;
if (targetFieldSchema?.dataType?.match(/vector/i)) {
updateKeyValueArray.push(`\`${dataKey}\`=VEC_FromText(?)`);
} else {
updateKeyValueArray.push(`\`${dataKey}\`=?`); updateKeyValueArray.push(`\`${dataKey}\`=?`);
}
if (typeof parsedValue == "number") { if (typeof parsedValue == "number") {
updateValues.push(String(parsedValue)); updateValues.push(String(parsedValue));

View File

@ -49,6 +49,10 @@ export default function parseDbResults({
}); });
} }
} }
if (value && typeof value == "object") {
result[resultFieldName] = "";
}
} }
parsedResults.push(result); parsedResults.push(result);

View File

@ -47,7 +47,11 @@ export default async function handleIndexescreateDbFromSchema({
* doesn't exist in MYSQL db * doesn't exist in MYSQL db
*/ */
const queryString = `CREATE${ const queryString = `CREATE${
indexType == "full_text" ? " FULLTEXT" : "" indexType == "full_text"
? " FULLTEXT"
: indexType == "vector"
? " VECTOR"
: ""
} INDEX \`${alias}\` ON \`${dbFullName}\`.\`${tableName}\`(${indexTableFields } INDEX \`${alias}\` ON \`${dbFullName}\`.\`${tableName}\`(${indexTableFields
?.map((nm) => nm.value) ?.map((nm) => nm.value)
.map((nm) => `\`${nm}\``) .map((nm) => `\`${nm}\``)

View File

@ -1813,6 +1813,7 @@ export type MediaUploadDataType = ImageObjectType &
privateFolder?: boolean; privateFolder?: boolean;
overwrite?: boolean; overwrite?: boolean;
updatedMediaRecord?: DSQL_DATASQUIREL_USER_MEDIA; updatedMediaRecord?: DSQL_DATASQUIREL_USER_MEDIA;
existingMediaRecord?: DSQL_DATASQUIREL_USER_MEDIA;
existingMediaRecordId?: number; existingMediaRecordId?: number;
}; };
@ -1921,7 +1922,7 @@ export type DefaultEntryType = {
[k: string]: string | number | null; [k: string]: string | number | null;
}; };
export const IndexTypes = ["regular", "full_text"] as const; export const IndexTypes = ["regular", "full_text", "vector"] as const;
export type LoginUserParam = { export type LoginUserParam = {
apiKey?: string; apiKey?: string;
@ -2344,6 +2345,11 @@ export type AddMediaAPIBody = {
update?: boolean; update?: boolean;
}; };
export type ReplaceMediaAPIBody = {
mediaId: number;
media: MediaUploadDataType;
};
export const TargetMediaParadigms = ["info", "preview"] as const; export const TargetMediaParadigms = ["info", "preview"] as const;
export type TargetMediaDataType = { export type TargetMediaDataType = {

View File

@ -6,6 +6,7 @@ export const DataTypesWithNumbers: (typeof DataTypes)[number]["name"][] = [
"DOUBLE", "DOUBLE",
"FLOAT", "FLOAT",
"VARCHAR", "VARCHAR",
"VECTOR",
]; ];
export const DataTypesWithTwoNumbers: (typeof DataTypes)[number]["name"][] = [ export const DataTypesWithTwoNumbers: (typeof DataTypes)[number]["name"][] = [
@ -17,6 +18,7 @@ export const DataTypesWithTwoNumbers: (typeof DataTypes)[number]["name"][] = [
type Return = { type Return = {
type: (typeof DataTypes)[number]["name"]; type: (typeof DataTypes)[number]["name"];
limit?: number; limit?: number;
defaultNumber?: number;
decimal?: number; decimal?: number;
}; };
@ -24,7 +26,7 @@ export default function dataTypeParser(dataType?: string): Return {
if (!dataType) { if (!dataType) {
return { return {
type: "VARCHAR", type: "VARCHAR",
limit: 250, defaultNumber: 250,
}; };
} }
@ -50,5 +52,6 @@ export default function dataTypeParser(dataType?: string): Return {
return { return {
type, type,
limit: number ? numberfy(number) : undefined, limit: number ? numberfy(number) : undefined,
defaultNumber: type == "VECTOR" ? 120 : 10,
}; };
} }

View File

@ -1,4 +1,4 @@
const APIParadigms = ["crud", "media", "schema"] as const; import { APIParadigms } from "../types";
type Params = { type Params = {
version?: string; version?: string;

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "5.1.3", "version": "5.1.4",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {