Updates
This commit is contained in:
parent
71a8431de5
commit
ab13c68c8e
@ -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}`;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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 {};
|
||||
|
@ -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,
|
||||
|
2
dist/package-shared/types/index.d.ts
vendored
2
dist/package-shared/types/index.d.ts
vendored
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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") {
|
||||
|
2
dist/package-shared/utils/grab-host-names.js
vendored
2
dist/package-shared/utils/grab-host-names.js
vendored
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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}`;
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -15,6 +15,10 @@ export default function dataTypeConstructor(
|
||||
return (finalType += `(${limit || 250})`);
|
||||
}
|
||||
|
||||
if (finalType == "VECTOR") {
|
||||
return (finalType += `(${limit || 120})`);
|
||||
}
|
||||
|
||||
if (
|
||||
finalType == "DECIMAL" ||
|
||||
finalType == "FLOAT" ||
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user