This commit is contained in:
Benjamin Toby 2025-08-04 08:20:32 +01:00
parent 71a8431de5
commit ab13c68c8e
18 changed files with 41 additions and 20 deletions

View File

@ -16,7 +16,7 @@ function encryptReserPasswordUrl({ email, encryptionKey, encryptionSalt, }) {
encryptionKey,
encryptionSalt,
});
const defaultUrlOrigin = `https://datasquirel.com`;
const defaultUrlOrigin = `https://www.datasquirel.com`;
let urlOrigin = process.env.DSQL_HOST || defaultUrlOrigin;
const url = `${defaultUrlOrigin}`;
}

View File

@ -122,7 +122,7 @@ function addDbEntry(_a) {
function grabQueryValuesString(arr) {
return arr
.map((v, i) => {
if (v.toString().match(/VEC_FromText/i)) {
if (v === null || v === void 0 ? void 0 : v.toString().match(/VEC_FromText/i)) {
return v;
}
return "?";
@ -131,7 +131,7 @@ function addDbEntry(_a) {
}
function grabFinalQueryValuesArr(arr) {
return arr
.filter((v) => !v.toString().match(/VEC_FromText/i))
.filter((v) => !(v === null || v === void 0 ? void 0 : v.toString().match(/VEC_FromText/i)))
.map((v) => String(v));
}
if (newData) {

View File

@ -6,5 +6,5 @@ interface SQLDeleteGenReturn {
/**
* # SQL Delete Generator
*/
export default function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, }: SQLDeleteGeneratorParams): SQLDeleteGenReturn | undefined;
export default function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, deleteKeyValuesOperator, }: SQLDeleteGeneratorParams): SQLDeleteGenReturn | undefined;
export {};

View File

@ -8,7 +8,7 @@ const sql_equality_parser_1 = __importDefault(require("../../../utils/sql-equali
/**
* # SQL Delete Generator
*/
function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, }) {
function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, deleteKeyValuesOperator, }) {
const finalDbName = dbFullName ? `${dbFullName}.` : "";
try {
let queryStr = `DELETE FROM ${finalDbName}${tableName}`;
@ -41,7 +41,9 @@ function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, }) {
queryArr.push(parsedValue);
});
}
queryStr += ` WHERE ${deleteBatch.join(" AND ")}`;
if (deleteBatch.length) {
queryStr += ` WHERE ${deleteBatch.join(` ${deleteKeyValuesOperator || "AND"} `)}`;
}
return {
query: queryStr,
values: queryArr,

View File

@ -1228,6 +1228,7 @@ export type SQLDeleteGeneratorParams<T extends {
}> = {
tableName: string;
deleteKeyValues?: SQLDeleteData<T>[];
deleteKeyValuesOperator?: "AND" | "OR";
dbFullName?: string;
data?: any;
};
@ -1251,6 +1252,7 @@ export type DsqlCrudParam<T extends {
batchData?: T[];
deleteData?: T;
deleteKeyValues?: SQLDeleteData[];
deleteKeyValuesOperator?: "AND" | "OR";
targetId?: string | number;
targetValue?: string | number;
targetField?: keyof T;

View File

@ -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, tableSchema, } = params;
const { action, data, table, targetValue, sanitize, targetField, targetId, dbFullName, deleteData, batchData, deleteKeyValues, debug, tableSchema, deleteKeyValuesOperator, } = params;
const finalData = (sanitize ? sanitize({ data }) : data);
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
switch (action) {
@ -60,6 +60,7 @@ function dsqlCrud(params) {
tableName: table,
dbFullName,
deleteKeyValues,
deleteKeyValuesOperator,
});
const res = (yield (0, conn_db_handler_1.default)(undefined, deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.query, deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.values));
return {

View File

@ -43,6 +43,9 @@ function dataTypeConstructor(dataType, limit, decimal) {
if (finalType == "VARCHAR") {
return (finalType += `(${limit || 250})`);
}
if (finalType == "VECTOR") {
return (finalType += `(${limit || 120})`);
}
if (finalType == "DECIMAL" ||
finalType == "FLOAT" ||
finalType == "DOUBLE") {

View File

@ -28,7 +28,7 @@ function grabHostNames(param) {
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
: undefined;
return {
host: remoteHost || localHost || "datasquirel.com",
host: remoteHost || localHost || "www.datasquirel.com",
port: remoteHostPort || localHostPort || 443,
scheme: (scheme === null || scheme === void 0 ? void 0 : scheme.match(/^http$/i)) ? http_1.default : https_1.default,
user_id: (param === null || param === void 0 ? void 0 : param.userId) || String(finalEnv["DSQL_API_USER_ID"] || 0),

View File

@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.default = grabDSQLRemoteURLs;
function grabDSQLRemoteURLs() {
const communityTarballURL = "https://static.datasquirel.com/images/user-images/user-2/dsql/distro/dsql-community.tar.xz";
const communityTarballShortURL = "https://datasquirel.com/api/media/dsql-community";
const installScriptURL = "https://datasquirel.com/api/media/install";
const updateScriptURL = "https://datasquirel.com/api/media/update";
const communityTarballShortURL = "https://www.datasquirel.com/api/media/dsql-community";
const installScriptURL = "https://www.datasquirel.com/api/media/install";
const updateScriptURL = "https://www.datasquirel.com/api/media/update";
return {
communityTarballURL,
communityTarballShortURL,

View File

@ -28,7 +28,7 @@ export default function encryptReserPasswordUrl({
encryptionSalt,
});
const defaultUrlOrigin = `https://datasquirel.com`;
const defaultUrlOrigin = `https://www.datasquirel.com`;
let urlOrigin = process.env.DSQL_HOST || defaultUrlOrigin;
const url = `${defaultUrlOrigin}`;

View File

@ -179,7 +179,7 @@ export default async function addDbEntry<
function grabQueryValuesString(arr: (string | number)[]) {
return arr
.map((v, i) => {
if (v.toString().match(/VEC_FromText/i)) {
if (v?.toString().match(/VEC_FromText/i)) {
return v;
}
return "?";
@ -189,7 +189,7 @@ export default async function addDbEntry<
function grabFinalQueryValuesArr(arr: (string | number)[]) {
return arr
.filter((v) => !v.toString().match(/VEC_FromText/i))
.filter((v) => !v?.toString().match(/VEC_FromText/i))
.map((v) => String(v));
}

View File

@ -14,6 +14,7 @@ export default function sqlDeleteGenerator({
deleteKeyValues,
dbFullName,
data,
deleteKeyValuesOperator,
}: SQLDeleteGeneratorParams): SQLDeleteGenReturn | undefined {
const finalDbName = dbFullName ? `${dbFullName}.` : "";
@ -54,7 +55,11 @@ export default function sqlDeleteGenerator({
});
}
queryStr += ` WHERE ${deleteBatch.join(" AND ")}`;
if (deleteBatch.length) {
queryStr += ` WHERE ${deleteBatch.join(
` ${deleteKeyValuesOperator || "AND"} `
)}`;
}
return {
query: queryStr,

View File

@ -1442,6 +1442,7 @@ export type SQLDeleteGeneratorParams<
> = {
tableName: string;
deleteKeyValues?: SQLDeleteData<T>[];
deleteKeyValuesOperator?: "AND" | "OR";
dbFullName?: string;
data?: any;
};
@ -1464,6 +1465,7 @@ export type DsqlCrudParam<
batchData?: T[];
deleteData?: T;
deleteKeyValues?: SQLDeleteData[];
deleteKeyValuesOperator?: "AND" | "OR";
targetId?: string | number;
targetValue?: string | number;
targetField?: keyof T;

View File

@ -27,6 +27,7 @@ export default async function dsqlCrud<
deleteKeyValues,
debug,
tableSchema,
deleteKeyValuesOperator,
} = params;
const finalData = (sanitize ? sanitize({ data }) : data) as T;
@ -77,6 +78,7 @@ export default async function dsqlCrud<
tableName: table,
dbFullName,
deleteKeyValues,
deleteKeyValuesOperator,
});
const res = (await connDbHandler(

View File

@ -15,6 +15,10 @@ export default function dataTypeConstructor(
return (finalType += `(${limit || 250})`);
}
if (finalType == "VECTOR") {
return (finalType += `(${limit || 120})`);
}
if (
finalType == "DECIMAL" ||
finalType == "FLOAT" ||

View File

@ -42,7 +42,7 @@ export default function grabHostNames(param?: Param): GrabHostNamesReturn {
: undefined;
return {
host: remoteHost || localHost || "datasquirel.com",
host: remoteHost || localHost || "www.datasquirel.com",
port: remoteHostPort || localHostPort || 443,
scheme: scheme?.match(/^http$/i) ? http : https,
user_id: param?.userId || String(finalEnv["DSQL_API_USER_ID"] || 0),

View File

@ -2,10 +2,10 @@ export default function grabDSQLRemoteURLs() {
const communityTarballURL =
"https://static.datasquirel.com/images/user-images/user-2/dsql/distro/dsql-community.tar.xz";
const communityTarballShortURL =
"https://datasquirel.com/api/media/dsql-community";
"https://www.datasquirel.com/api/media/dsql-community";
const installScriptURL = "https://datasquirel.com/api/media/install";
const updateScriptURL = "https://datasquirel.com/api/media/update";
const installScriptURL = "https://www.datasquirel.com/api/media/install";
const updateScriptURL = "https://www.datasquirel.com/api/media/update";
return {
communityTarballURL,

View File

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