@zenstackhq/runtime 3.0.0-beta.12 → 3.0.0-beta.13
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.cjs +13 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -16
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -90,7 +90,6 @@ __export(query_utils_exports, {
|
|
|
90
90
|
requireField: () => requireField,
|
|
91
91
|
requireIdFields: () => requireIdFields,
|
|
92
92
|
requireModel: () => requireModel,
|
|
93
|
-
safeJSONStringify: () => safeJSONStringify,
|
|
94
93
|
stripAlias: () => stripAlias
|
|
95
94
|
});
|
|
96
95
|
var import_common_helpers = require("@zenstackhq/common-helpers");
|
|
@@ -205,10 +204,11 @@ var InputValidationError = class extends ZenStackError {
|
|
|
205
204
|
static {
|
|
206
205
|
__name(this, "InputValidationError");
|
|
207
206
|
}
|
|
208
|
-
|
|
207
|
+
model;
|
|
208
|
+
constructor(model, message, cause) {
|
|
209
209
|
super(message, {
|
|
210
210
|
cause
|
|
211
|
-
});
|
|
211
|
+
}), this.model = model;
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
var QueryError = class extends ZenStackError {
|
|
@@ -230,8 +230,9 @@ var NotFoundError = class extends ZenStackError {
|
|
|
230
230
|
static {
|
|
231
231
|
__name(this, "NotFoundError");
|
|
232
232
|
}
|
|
233
|
+
model;
|
|
233
234
|
constructor(model, details) {
|
|
234
|
-
super(`Entity not found for model "${model}"${details ? `: ${details}` : ""}`);
|
|
235
|
+
super(`Entity not found for model "${model}"${details ? `: ${details}` : ""}`), this.model = model;
|
|
235
236
|
}
|
|
236
237
|
};
|
|
237
238
|
var RejectedByPolicyReason = /* @__PURE__ */ function(RejectedByPolicyReason2) {
|
|
@@ -545,16 +546,6 @@ function ensureArray(value) {
|
|
|
545
546
|
}
|
|
546
547
|
}
|
|
547
548
|
__name(ensureArray, "ensureArray");
|
|
548
|
-
function safeJSONStringify(value) {
|
|
549
|
-
return JSON.stringify(value, (_, v) => {
|
|
550
|
-
if (typeof v === "bigint") {
|
|
551
|
-
return v.toString();
|
|
552
|
-
} else {
|
|
553
|
-
return v;
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
__name(safeJSONStringify, "safeJSONStringify");
|
|
558
549
|
function extractIdFields(entity, schema, model) {
|
|
559
550
|
const idFields = requireIdFields(schema, model);
|
|
560
551
|
return extractFields(entity, idFields);
|
|
@@ -1415,7 +1406,7 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
|
|
|
1415
1406
|
}
|
|
1416
1407
|
}
|
|
1417
1408
|
transformOutputBytes(value) {
|
|
1418
|
-
return Buffer.isBuffer(value) ? Uint8Array.from(value) : value;
|
|
1409
|
+
return Buffer.isBuffer(value) ? Uint8Array.from(value) : typeof value === "string" && value.startsWith("\\x") ? Uint8Array.from(Buffer.from(value.slice(2), "hex")) : value;
|
|
1419
1410
|
}
|
|
1420
1411
|
buildRelationSelection(query, model, relationField, parentAlias, payload) {
|
|
1421
1412
|
const relationResultName = `${parentAlias}$${relationField}`;
|
|
@@ -4137,7 +4128,7 @@ var InputValidator = class {
|
|
|
4137
4128
|
}
|
|
4138
4129
|
const { error, data } = schema.safeParse(args);
|
|
4139
4130
|
if (error) {
|
|
4140
|
-
throw new InputValidationError(`Invalid ${operation} args for model "${model}": ${formatError(error)}`, error);
|
|
4131
|
+
throw new InputValidationError(model, `Invalid ${operation} args for model "${model}": ${formatError(error)}`, error);
|
|
4141
4132
|
}
|
|
4142
4133
|
return data;
|
|
4143
4134
|
}
|
|
@@ -6292,9 +6283,15 @@ var SchemaDbPusher = class {
|
|
|
6292
6283
|
table = table.addForeignKeyConstraint(`fk_${model}_${fieldName}`, fieldDef.relation.fields.map((f) => this.getColumnName(modelDef.fields[f])), this.getTableName(relationModelDef), fieldDef.relation.references.map((f) => this.getColumnName(relationModelDef.fields[f])), (cb) => {
|
|
6293
6284
|
if (fieldDef.relation?.onDelete) {
|
|
6294
6285
|
cb = cb.onDelete(this.mapCascadeAction(fieldDef.relation.onDelete));
|
|
6286
|
+
} else if (fieldDef.optional) {
|
|
6287
|
+
cb = cb.onDelete("set null");
|
|
6288
|
+
} else {
|
|
6289
|
+
cb = cb.onDelete("restrict");
|
|
6295
6290
|
}
|
|
6296
6291
|
if (fieldDef.relation?.onUpdate) {
|
|
6297
6292
|
cb = cb.onUpdate(this.mapCascadeAction(fieldDef.relation.onUpdate));
|
|
6293
|
+
} else {
|
|
6294
|
+
cb = cb.onUpdate("cascade");
|
|
6298
6295
|
}
|
|
6299
6296
|
return cb;
|
|
6300
6297
|
});
|