@zenstackhq/orm 3.8.0-beta.2 → 3.8.0-beta.3
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 +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +12 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -3240,6 +3240,11 @@ declare class ZodSchemaFactory<in out Schema extends SchemaDef, in out Options e
|
|
|
3240
3240
|
private makeSelectSchema;
|
|
3241
3241
|
private makeCountSelectionSchema;
|
|
3242
3242
|
private makeRelationSelectIncludeSchema;
|
|
3243
|
+
/**
|
|
3244
|
+
* Determines whether a field is configured to be omitted at the schema or client-options level
|
|
3245
|
+
* (query-level omit is excluded as it's mutually exclusive with `select`).
|
|
3246
|
+
*/
|
|
3247
|
+
private isFieldOmittedByConfig;
|
|
3243
3248
|
private makeOmitSchema;
|
|
3244
3249
|
private addExtResultFields;
|
|
3245
3250
|
private makeIncludeSchema;
|
package/dist/index.d.mts
CHANGED
|
@@ -3240,6 +3240,11 @@ declare class ZodSchemaFactory<in out Schema extends SchemaDef, in out Options e
|
|
|
3240
3240
|
private makeSelectSchema;
|
|
3241
3241
|
private makeCountSelectionSchema;
|
|
3242
3242
|
private makeRelationSelectIncludeSchema;
|
|
3243
|
+
/**
|
|
3244
|
+
* Determines whether a field is configured to be omitted at the schema or client-options level
|
|
3245
|
+
* (query-level omit is excluded as it's mutually exclusive with `select`).
|
|
3246
|
+
*/
|
|
3247
|
+
private isFieldOmittedByConfig;
|
|
3243
3248
|
private makeOmitSchema;
|
|
3244
3249
|
private addExtResultFields;
|
|
3245
3250
|
private makeIncludeSchema;
|
package/dist/index.mjs
CHANGED
|
@@ -1832,7 +1832,7 @@ var PostgresCrudDialect = class PostgresCrudDialect extends LateralJoinDialectBa
|
|
|
1832
1832
|
return this.eb.fn("trim", [expression, sql.lit("\"")]);
|
|
1833
1833
|
}
|
|
1834
1834
|
buildArrayLength(array) {
|
|
1835
|
-
return this.eb.fn("array_length", [array]);
|
|
1835
|
+
return this.eb.fn("array_length", [array, sql.lit(1)]);
|
|
1836
1836
|
}
|
|
1837
1837
|
buildArrayValue(values, elemType) {
|
|
1838
1838
|
const arr = sql`ARRAY[${sql.join(values, sql.raw(","))}]`;
|
|
@@ -2837,7 +2837,8 @@ var ZodSchemaFactory = class {
|
|
|
2837
2837
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2838
2838
|
if (!this.shouldIncludeRelations(options)) continue;
|
|
2839
2839
|
if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
|
|
2840
|
-
} else fields[field] = z.
|
|
2840
|
+
} else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z.literal(false).optional();
|
|
2841
|
+
else fields[field] = z.boolean().optional();
|
|
2841
2842
|
if (this.shouldIncludeRelations(options)) {
|
|
2842
2843
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2843
2844
|
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
@@ -2883,6 +2884,15 @@ var ZodSchemaFactory = class {
|
|
|
2883
2884
|
this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
|
|
2884
2885
|
return result;
|
|
2885
2886
|
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Determines whether a field is configured to be omitted at the schema or client-options level
|
|
2889
|
+
* (query-level omit is excluded as it's mutually exclusive with `select`).
|
|
2890
|
+
*/
|
|
2891
|
+
isFieldOmittedByConfig(model, field) {
|
|
2892
|
+
const omitConfig = this.options.omit?.[lowerCaseFirst(model)] ?? this.options.omit?.[model];
|
|
2893
|
+
if (omitConfig && typeof omitConfig[field] === "boolean") return omitConfig[field];
|
|
2894
|
+
return !!requireField(this.schema, model, field).omit;
|
|
2895
|
+
}
|
|
2886
2896
|
makeOmitSchema(model) {
|
|
2887
2897
|
const fields = {};
|
|
2888
2898
|
for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
|