Updates
This commit is contained in:
parent
f91aff421c
commit
c88fb13375
@ -10,5 +10,5 @@ type Param = {
|
|||||||
* # Update DB Function
|
* # Update DB Function
|
||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
export default function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, dataKey, }: Param): any;
|
export default function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, dataKey, }: Param): string | number | undefined;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@ -17,10 +17,17 @@ function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, da
|
|||||||
const targetFieldSchema = tableSchema
|
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)
|
? (_a = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.fields) === null || _a === void 0 ? void 0 : _a.find((field) => field.fieldName === dataKey)
|
||||||
: null;
|
: null;
|
||||||
if (typeof newValue == "undefined")
|
if (typeof newValue == "undefined") {
|
||||||
return;
|
return;
|
||||||
if (typeof newValue == "object" && !newValue)
|
}
|
||||||
newValue = null;
|
if (typeof newValue !== "string" &&
|
||||||
|
typeof newValue !== "number" &&
|
||||||
|
!newValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof newValue == "object" && !newValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const htmlRegex = /<[^>]+>/g;
|
const htmlRegex = /<[^>]+>/g;
|
||||||
if ((targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.richText) || String(newValue).match(htmlRegex)) {
|
if ((targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.richText) || String(newValue).match(htmlRegex)) {
|
||||||
newValue = (0, sanitize_html_1.default)(newValue, sanitizeHtmlOptions_1.default);
|
newValue = (0, sanitize_html_1.default)(newValue, sanitizeHtmlOptions_1.default);
|
||||||
@ -31,25 +38,26 @@ function grabParsedValue({ value, tableSchema, encryptionKey, encryptionSalt, da
|
|||||||
newValue = "";
|
newValue = "";
|
||||||
}
|
}
|
||||||
if (targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.encrypted) {
|
if (targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.encrypted) {
|
||||||
newValue = (0, encrypt_1.default)({
|
newValue =
|
||||||
data: newValue,
|
(0, encrypt_1.default)({
|
||||||
encryptionKey,
|
data: newValue.toString(),
|
||||||
encryptionSalt,
|
encryptionKey,
|
||||||
});
|
encryptionSalt,
|
||||||
|
}) || undefined;
|
||||||
}
|
}
|
||||||
if (typeof newValue === "object") {
|
if (typeof newValue === "object") {
|
||||||
newValue = JSON.stringify(newValue);
|
newValue = JSON.stringify(newValue);
|
||||||
}
|
}
|
||||||
if (targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.pattern) {
|
if (targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.pattern) {
|
||||||
const pattern = new RegExp(targetFieldSchema.pattern, targetFieldSchema.patternFlags || "");
|
const pattern = new RegExp(targetFieldSchema.pattern, targetFieldSchema.patternFlags || "");
|
||||||
if (!pattern.test(newValue)) {
|
if (typeof newValue == "string" && !pattern.test(newValue)) {
|
||||||
console.log("DSQL: Pattern not matched =>", newValue);
|
console.log("DSQL: Pattern not matched =>", newValue);
|
||||||
newValue = "";
|
newValue = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof newValue === "string" &&
|
if (typeof newValue === "string" &&
|
||||||
(newValue.match(/^null$/i) || !newValue.match(/./i))) {
|
(newValue.match(/^null$/i) || !newValue.match(/./i))) {
|
||||||
newValue = null;
|
newValue = undefined;
|
||||||
}
|
}
|
||||||
if (typeof newValue === "boolean" ||
|
if (typeof newValue === "boolean" ||
|
||||||
((_c = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _c === void 0 ? void 0 : _c.match(/boolean/i))) {
|
((_c = targetFieldSchema === null || targetFieldSchema === void 0 ? void 0 : targetFieldSchema.dataType) === null || _c === void 0 ? void 0 : _c.match(/boolean/i))) {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ type Param<T extends {
|
|||||||
};
|
};
|
||||||
type Return = {
|
type Return = {
|
||||||
string: string;
|
string: string;
|
||||||
values: string[];
|
values: (string | number)[];
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* # SQL Query Generator
|
* # SQL Query Generator
|
||||||
|
|||||||
2
dist/package-shared/types/index.d.ts
vendored
2
dist/package-shared/types/index.d.ts
vendored
@ -1438,7 +1438,7 @@ export type PagePropsType = {
|
|||||||
};
|
};
|
||||||
export type ResponseQueryObject = {
|
export type ResponseQueryObject = {
|
||||||
sql?: string;
|
sql?: string;
|
||||||
params?: string[];
|
params?: (string | number)[];
|
||||||
};
|
};
|
||||||
export type APIResponseObject<T extends any = any> = {
|
export type APIResponseObject<T extends any = any> = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
|
|||||||
@ -22,15 +22,26 @@ export default function grabParsedValue({
|
|||||||
encryptionKey,
|
encryptionKey,
|
||||||
encryptionSalt,
|
encryptionSalt,
|
||||||
dataKey,
|
dataKey,
|
||||||
}: Param): any {
|
}: Param): string | number | undefined {
|
||||||
let newValue = value;
|
let newValue = value as string | number | undefined;
|
||||||
|
|
||||||
const targetFieldSchema = tableSchema
|
const targetFieldSchema = tableSchema
|
||||||
? tableSchema?.fields?.find((field) => field.fieldName === dataKey)
|
? tableSchema?.fields?.find((field) => field.fieldName === dataKey)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (typeof newValue == "undefined") return;
|
if (typeof newValue == "undefined") {
|
||||||
if (typeof newValue == "object" && !newValue) newValue = null;
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
typeof newValue !== "string" &&
|
||||||
|
typeof newValue !== "number" &&
|
||||||
|
!newValue
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof newValue == "object" && !newValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const htmlRegex = /<[^>]+>/g;
|
const htmlRegex = /<[^>]+>/g;
|
||||||
|
|
||||||
@ -47,11 +58,12 @@ export default function grabParsedValue({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (targetFieldSchema?.encrypted) {
|
if (targetFieldSchema?.encrypted) {
|
||||||
newValue = encrypt({
|
newValue =
|
||||||
data: newValue,
|
encrypt({
|
||||||
encryptionKey,
|
data: newValue.toString(),
|
||||||
encryptionSalt,
|
encryptionKey,
|
||||||
});
|
encryptionSalt,
|
||||||
|
}) || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof newValue === "object") {
|
if (typeof newValue === "object") {
|
||||||
@ -63,7 +75,8 @@ export default function grabParsedValue({
|
|||||||
targetFieldSchema.pattern,
|
targetFieldSchema.pattern,
|
||||||
targetFieldSchema.patternFlags || ""
|
targetFieldSchema.patternFlags || ""
|
||||||
);
|
);
|
||||||
if (!pattern.test(newValue)) {
|
|
||||||
|
if (typeof newValue == "string" && !pattern.test(newValue)) {
|
||||||
console.log("DSQL: Pattern not matched =>", newValue);
|
console.log("DSQL: Pattern not matched =>", newValue);
|
||||||
newValue = "";
|
newValue = "";
|
||||||
}
|
}
|
||||||
@ -73,7 +86,7 @@ export default function grabParsedValue({
|
|||||||
typeof newValue === "string" &&
|
typeof newValue === "string" &&
|
||||||
(newValue.match(/^null$/i) || !newValue.match(/./i))
|
(newValue.match(/^null$/i) || !newValue.match(/./i))
|
||||||
) {
|
) {
|
||||||
newValue = null;
|
newValue = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -16,7 +16,7 @@ type Param<T extends { [key: string]: any } = { [key: string]: any }> = {
|
|||||||
|
|
||||||
type Return = {
|
type Return = {
|
||||||
string: string;
|
string: string;
|
||||||
values: string[];
|
values: (string | number)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1673,7 +1673,7 @@ export type PagePropsType = {
|
|||||||
|
|
||||||
export type ResponseQueryObject = {
|
export type ResponseQueryObject = {
|
||||||
sql?: string;
|
sql?: string;
|
||||||
params?: string[];
|
params?: (string | number)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type APIResponseObject<T extends any = any> = {
|
export type APIResponseObject<T extends any = any> = {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.5.2",
|
"version": "5.5.3",
|
||||||
"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