@cadenza.io/service 2.17.0 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5731,6 +5731,41 @@ function defaultOperationIntentDescription(operation, tableName) {
|
|
|
5731
5731
|
function isExplicitSqlLiteral(value) {
|
|
5732
5732
|
return /^'.*'::[a-z_][a-z0-9_]*(\[\])?$/i.test(value.trim());
|
|
5733
5733
|
}
|
|
5734
|
+
function isExplicitSqlExpression(value) {
|
|
5735
|
+
const trimmed = value.trim();
|
|
5736
|
+
if (!trimmed) {
|
|
5737
|
+
return false;
|
|
5738
|
+
}
|
|
5739
|
+
if (isExplicitSqlLiteral(trimmed)) {
|
|
5740
|
+
return true;
|
|
5741
|
+
}
|
|
5742
|
+
if (/^'.*'$/.test(trimmed)) {
|
|
5743
|
+
return true;
|
|
5744
|
+
}
|
|
5745
|
+
if (/^[a-z_][a-z0-9_]*\([^)]*\)$/i.test(trimmed)) {
|
|
5746
|
+
return true;
|
|
5747
|
+
}
|
|
5748
|
+
return /^(current_timestamp|current_date|current_time)$/i.test(trimmed);
|
|
5749
|
+
}
|
|
5750
|
+
function serializeFieldDefaultForSql(value, field) {
|
|
5751
|
+
if (value === void 0 || value === null) {
|
|
5752
|
+
return "NULL";
|
|
5753
|
+
}
|
|
5754
|
+
if (typeof value === "number") {
|
|
5755
|
+
return String(value);
|
|
5756
|
+
}
|
|
5757
|
+
if (typeof value === "boolean") {
|
|
5758
|
+
return value ? "TRUE" : "FALSE";
|
|
5759
|
+
}
|
|
5760
|
+
const stringValue = String(value);
|
|
5761
|
+
if (isExplicitSqlExpression(stringValue)) {
|
|
5762
|
+
return stringValue;
|
|
5763
|
+
}
|
|
5764
|
+
if (field?.type === "jsonb") {
|
|
5765
|
+
return `'${JSON.stringify(value).replace(/'/g, "''")}'::jsonb`;
|
|
5766
|
+
}
|
|
5767
|
+
return `'${stringValue.replace(/'/g, "''")}'`;
|
|
5768
|
+
}
|
|
5734
5769
|
function serializeInitialDataValueForSql(value, field) {
|
|
5735
5770
|
if (value === void 0 || value === null) {
|
|
5736
5771
|
return "NULL";
|
|
@@ -5749,7 +5784,7 @@ function serializeInitialDataValueForSql(value, field) {
|
|
|
5749
5784
|
return `'${jsonString.replace(/'/g, "''")}'::jsonb`;
|
|
5750
5785
|
}
|
|
5751
5786
|
const stringValue = String(value);
|
|
5752
|
-
if (
|
|
5787
|
+
if (isExplicitSqlExpression(stringValue)) {
|
|
5753
5788
|
return stringValue;
|
|
5754
5789
|
}
|
|
5755
5790
|
return `'${stringValue.replace(/'/g, "''")}'`;
|
|
@@ -6790,7 +6825,7 @@ var DatabaseController = class _DatabaseController {
|
|
|
6790
6825
|
if (field.primary) definition += " PRIMARY KEY";
|
|
6791
6826
|
if (field.unique) definition += " UNIQUE";
|
|
6792
6827
|
if (field.default !== void 0) {
|
|
6793
|
-
definition += ` DEFAULT ${field.default
|
|
6828
|
+
definition += ` DEFAULT ${serializeFieldDefaultForSql(field.default, field)}`;
|
|
6794
6829
|
}
|
|
6795
6830
|
if (field.required && !field.nullable) definition += " NOT NULL";
|
|
6796
6831
|
if (field.nullable) definition += " NULL";
|
|
@@ -7047,12 +7082,9 @@ var DatabaseController = class _DatabaseController {
|
|
|
7047
7082
|
schema
|
|
7048
7083
|
);
|
|
7049
7084
|
for (const intent of intents) {
|
|
7050
|
-
if (registration.intentNames.has(intent.name)) {
|
|
7051
|
-
|
|
7052
|
-
`Duplicate auto/custom intent '${intent.name}' detected while generating ${op} task for table '${tableName}' in actor '${registration.actorName}'`
|
|
7053
|
-
);
|
|
7085
|
+
if (!registration.intentNames.has(intent.name)) {
|
|
7086
|
+
registration.intentNames.add(intent.name);
|
|
7054
7087
|
}
|
|
7055
|
-
registration.intentNames.add(intent.name);
|
|
7056
7088
|
CadenzaService.defineIntent({
|
|
7057
7089
|
name: intent.name,
|
|
7058
7090
|
description: intent.description,
|