Updates
This commit is contained in:
parent
71a8431de5
commit
ab13c68c8e
@ -16,7 +16,7 @@ function encryptReserPasswordUrl({ email, encryptionKey, encryptionSalt, }) {
|
|||||||
encryptionKey,
|
encryptionKey,
|
||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
});
|
});
|
||||||
const defaultUrlOrigin = `https://datasquirel.com`;
|
const defaultUrlOrigin = `https://www.datasquirel.com`;
|
||||||
let urlOrigin = process.env.DSQL_HOST || defaultUrlOrigin;
|
let urlOrigin = process.env.DSQL_HOST || defaultUrlOrigin;
|
||||||
const url = `${defaultUrlOrigin}`;
|
const url = `${defaultUrlOrigin}`;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ function addDbEntry(_a) {
|
|||||||
function grabQueryValuesString(arr) {
|
function grabQueryValuesString(arr) {
|
||||||
return arr
|
return arr
|
||||||
.map((v, i) => {
|
.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 v;
|
||||||
}
|
}
|
||||||
return "?";
|
return "?";
|
||||||
@ -131,7 +131,7 @@ function addDbEntry(_a) {
|
|||||||
}
|
}
|
||||||
function grabFinalQueryValuesArr(arr) {
|
function grabFinalQueryValuesArr(arr) {
|
||||||
return 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));
|
.map((v) => String(v));
|
||||||
}
|
}
|
||||||
if (newData) {
|
if (newData) {
|
||||||
|
@ -6,5 +6,5 @@ interface SQLDeleteGenReturn {
|
|||||||
/**
|
/**
|
||||||
* # SQL Delete Generator
|
* # 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 {};
|
export {};
|
||||||
|
@ -8,7 +8,7 @@ const sql_equality_parser_1 = __importDefault(require("../../../utils/sql-equali
|
|||||||
/**
|
/**
|
||||||
* # SQL Delete Generator
|
* # SQL Delete Generator
|
||||||
*/
|
*/
|
||||||
function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, }) {
|
function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, deleteKeyValuesOperator, }) {
|
||||||
const finalDbName = dbFullName ? `${dbFullName}.` : "";
|
const finalDbName = dbFullName ? `${dbFullName}.` : "";
|
||||||
try {
|
try {
|
||||||
let queryStr = `DELETE FROM ${finalDbName}${tableName}`;
|
let queryStr = `DELETE FROM ${finalDbName}${tableName}`;
|
||||||
@ -41,7 +41,9 @@ function sqlDeleteGenerator({ tableName, deleteKeyValues, dbFullName, data, }) {
|
|||||||
queryArr.push(parsedValue);
|
queryArr.push(parsedValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
queryStr += ` WHERE ${deleteBatch.join(" AND ")}`;
|
if (deleteBatch.length) {
|
||||||
|
queryStr += ` WHERE ${deleteBatch.join(` ${deleteKeyValuesOperator || "AND"} `)}`;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
query: queryStr,
|
query: queryStr,
|
||||||
values: queryArr,
|
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;
|
tableName: string;
|
||||||
deleteKeyValues?: SQLDeleteData<T>[];
|
deleteKeyValues?: SQLDeleteData<T>[];
|
||||||
|
deleteKeyValuesOperator?: "AND" | "OR";
|
||||||
dbFullName?: string;
|
dbFullName?: string;
|
||||||
data?: any;
|
data?: any;
|
||||||
};
|
};
|
||||||
@ -1251,6 +1252,7 @@ export type DsqlCrudParam<T extends {
|
|||||||
batchData?: T[];
|
batchData?: T[];
|
||||||
deleteData?: T;
|
deleteData?: T;
|
||||||
deleteKeyValues?: SQLDeleteData[];
|
deleteKeyValues?: SQLDeleteData[];
|
||||||
|
deleteKeyValuesOperator?: "AND" | "OR";
|
||||||
targetId?: string | number;
|
targetId?: string | number;
|
||||||
targetValue?: string | number;
|
targetValue?: string | number;
|
||||||
targetField?: keyof T;
|
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"));
|
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, 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 finalData = (sanitize ? sanitize({ data }) : data);
|
||||||
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
const finalBatchData = (sanitize ? sanitize({ batchData }) : batchData);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -60,6 +60,7 @@ function dsqlCrud(params) {
|
|||||||
tableName: table,
|
tableName: table,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
deleteKeyValues,
|
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));
|
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 {
|
return {
|
||||||
|
@ -43,6 +43,9 @@ function dataTypeConstructor(dataType, limit, decimal) {
|
|||||||
if (finalType == "VARCHAR") {
|
if (finalType == "VARCHAR") {
|
||||||
return (finalType += `(${limit || 250})`);
|
return (finalType += `(${limit || 250})`);
|
||||||
}
|
}
|
||||||
|
if (finalType == "VECTOR") {
|
||||||
|
return (finalType += `(${limit || 120})`);
|
||||||
|
}
|
||||||
if (finalType == "DECIMAL" ||
|
if (finalType == "DECIMAL" ||
|
||||||
finalType == "FLOAT" ||
|
finalType == "FLOAT" ||
|
||||||
finalType == "DOUBLE") {
|
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"]
|
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
||||||
: undefined;
|
: undefined;
|
||||||
return {
|
return {
|
||||||
host: remoteHost || localHost || "datasquirel.com",
|
host: remoteHost || localHost || "www.datasquirel.com",
|
||||||
port: remoteHostPort || localHostPort || 443,
|
port: remoteHostPort || localHostPort || 443,
|
||||||
scheme: (scheme === null || scheme === void 0 ? void 0 : scheme.match(/^http$/i)) ? http_1.default : https_1.default,
|
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),
|
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;
|
exports.default = grabDSQLRemoteURLs;
|
||||||
function grabDSQLRemoteURLs() {
|
function grabDSQLRemoteURLs() {
|
||||||
const communityTarballURL = "https://static.datasquirel.com/images/user-images/user-2/dsql/distro/dsql-community.tar.xz";
|
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 communityTarballShortURL = "https://www.datasquirel.com/api/media/dsql-community";
|
||||||
const installScriptURL = "https://datasquirel.com/api/media/install";
|
const installScriptURL = "https://www.datasquirel.com/api/media/install";
|
||||||
const updateScriptURL = "https://datasquirel.com/api/media/update";
|
const updateScriptURL = "https://www.datasquirel.com/api/media/update";
|
||||||
return {
|
return {
|
||||||
communityTarballURL,
|
communityTarballURL,
|
||||||
communityTarballShortURL,
|
communityTarballShortURL,
|
||||||
|
@ -28,7 +28,7 @@ export default function encryptReserPasswordUrl({
|
|||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
});
|
});
|
||||||
|
|
||||||
const defaultUrlOrigin = `https://datasquirel.com`;
|
const defaultUrlOrigin = `https://www.datasquirel.com`;
|
||||||
let urlOrigin = process.env.DSQL_HOST || defaultUrlOrigin;
|
let urlOrigin = process.env.DSQL_HOST || defaultUrlOrigin;
|
||||||
|
|
||||||
const url = `${defaultUrlOrigin}`;
|
const url = `${defaultUrlOrigin}`;
|
||||||
|
@ -179,7 +179,7 @@ export default async function addDbEntry<
|
|||||||
function grabQueryValuesString(arr: (string | number)[]) {
|
function grabQueryValuesString(arr: (string | number)[]) {
|
||||||
return arr
|
return arr
|
||||||
.map((v, i) => {
|
.map((v, i) => {
|
||||||
if (v.toString().match(/VEC_FromText/i)) {
|
if (v?.toString().match(/VEC_FromText/i)) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
return "?";
|
return "?";
|
||||||
@ -189,7 +189,7 @@ export default async function addDbEntry<
|
|||||||
|
|
||||||
function grabFinalQueryValuesArr(arr: (string | number)[]) {
|
function grabFinalQueryValuesArr(arr: (string | number)[]) {
|
||||||
return arr
|
return arr
|
||||||
.filter((v) => !v.toString().match(/VEC_FromText/i))
|
.filter((v) => !v?.toString().match(/VEC_FromText/i))
|
||||||
.map((v) => String(v));
|
.map((v) => String(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ export default function sqlDeleteGenerator({
|
|||||||
deleteKeyValues,
|
deleteKeyValues,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
data,
|
data,
|
||||||
|
deleteKeyValuesOperator,
|
||||||
}: SQLDeleteGeneratorParams): SQLDeleteGenReturn | undefined {
|
}: SQLDeleteGeneratorParams): SQLDeleteGenReturn | undefined {
|
||||||
const finalDbName = dbFullName ? `${dbFullName}.` : "";
|
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 {
|
return {
|
||||||
query: queryStr,
|
query: queryStr,
|
||||||
|
@ -1442,6 +1442,7 @@ export type SQLDeleteGeneratorParams<
|
|||||||
> = {
|
> = {
|
||||||
tableName: string;
|
tableName: string;
|
||||||
deleteKeyValues?: SQLDeleteData<T>[];
|
deleteKeyValues?: SQLDeleteData<T>[];
|
||||||
|
deleteKeyValuesOperator?: "AND" | "OR";
|
||||||
dbFullName?: string;
|
dbFullName?: string;
|
||||||
data?: any;
|
data?: any;
|
||||||
};
|
};
|
||||||
@ -1464,6 +1465,7 @@ export type DsqlCrudParam<
|
|||||||
batchData?: T[];
|
batchData?: T[];
|
||||||
deleteData?: T;
|
deleteData?: T;
|
||||||
deleteKeyValues?: SQLDeleteData[];
|
deleteKeyValues?: SQLDeleteData[];
|
||||||
|
deleteKeyValuesOperator?: "AND" | "OR";
|
||||||
targetId?: string | number;
|
targetId?: string | number;
|
||||||
targetValue?: string | number;
|
targetValue?: string | number;
|
||||||
targetField?: keyof T;
|
targetField?: keyof T;
|
||||||
|
@ -27,6 +27,7 @@ export default async function dsqlCrud<
|
|||||||
deleteKeyValues,
|
deleteKeyValues,
|
||||||
debug,
|
debug,
|
||||||
tableSchema,
|
tableSchema,
|
||||||
|
deleteKeyValuesOperator,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const finalData = (sanitize ? sanitize({ data }) : data) as T;
|
const finalData = (sanitize ? sanitize({ data }) : data) as T;
|
||||||
@ -77,6 +78,7 @@ export default async function dsqlCrud<
|
|||||||
tableName: table,
|
tableName: table,
|
||||||
dbFullName,
|
dbFullName,
|
||||||
deleteKeyValues,
|
deleteKeyValues,
|
||||||
|
deleteKeyValuesOperator,
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = (await connDbHandler(
|
const res = (await connDbHandler(
|
||||||
|
@ -15,6 +15,10 @@ export default function dataTypeConstructor(
|
|||||||
return (finalType += `(${limit || 250})`);
|
return (finalType += `(${limit || 250})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (finalType == "VECTOR") {
|
||||||
|
return (finalType += `(${limit || 120})`);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
finalType == "DECIMAL" ||
|
finalType == "DECIMAL" ||
|
||||||
finalType == "FLOAT" ||
|
finalType == "FLOAT" ||
|
||||||
|
@ -42,7 +42,7 @@ export default function grabHostNames(param?: Param): GrabHostNamesReturn {
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
host: remoteHost || localHost || "datasquirel.com",
|
host: remoteHost || localHost || "www.datasquirel.com",
|
||||||
port: remoteHostPort || localHostPort || 443,
|
port: remoteHostPort || localHostPort || 443,
|
||||||
scheme: scheme?.match(/^http$/i) ? http : https,
|
scheme: scheme?.match(/^http$/i) ? http : https,
|
||||||
user_id: param?.userId || String(finalEnv["DSQL_API_USER_ID"] || 0),
|
user_id: param?.userId || String(finalEnv["DSQL_API_USER_ID"] || 0),
|
||||||
|
@ -2,10 +2,10 @@ export default function grabDSQLRemoteURLs() {
|
|||||||
const communityTarballURL =
|
const communityTarballURL =
|
||||||
"https://static.datasquirel.com/images/user-images/user-2/dsql/distro/dsql-community.tar.xz";
|
"https://static.datasquirel.com/images/user-images/user-2/dsql/distro/dsql-community.tar.xz";
|
||||||
const communityTarballShortURL =
|
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 installScriptURL = "https://www.datasquirel.com/api/media/install";
|
||||||
const updateScriptURL = "https://datasquirel.com/api/media/update";
|
const updateScriptURL = "https://www.datasquirel.com/api/media/update";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
communityTarballURL,
|
communityTarballURL,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.1.4",
|
"version": "5.1.5",
|
||||||
"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