@zenstackhq/runtime 3.0.0-alpha.10 → 3.0.0-alpha.12
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/{contract-BiU0iYAh.d.cts → contract-BEAyf7Es.d.cts} +60 -41
- package/dist/{contract-BiU0iYAh.d.ts → contract-BEAyf7Es.d.ts} +60 -41
- package/dist/index.cjs +20 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -1
- package/dist/plugins/policy.d.cts +1 -1
- package/dist/plugins/policy.d.ts +1 -1
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientConstructor } from './contract-
|
|
2
|
-
export {
|
|
1
|
+
import { C as ClientConstructor } from './contract-BEAyf7Es.cjs';
|
|
2
|
+
export { H as AggregateArgs, K as AggregateResult, B as BatchResult, h as BooleanFilter, g as BytesFilter, c as ClientContract, d as ClientOptions, E as CountArgs, G as CountResult, t as CreateArgs, v as CreateManyAndReturnArgs, u as CreateManyArgs, D as DateTimeFilter, z as DeleteArgs, A as DeleteManyArgs, F as FindArgs, r as FindFirstArgs, q as FindManyArgs, s as FindUniqueArgs, L as GroupByArgs, P as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, j as NullsOrder, N as NumberFilter, l as OmitInput, O as OrderBy, m as SelectIncludeOmit, n as SelectInput, p as SelectSubset, S as SimplifiedModelResult, i as SortOrder, f as StringFilter, o as Subset, T as ToKysely, U as UpdateArgs, x as UpdateManyAndReturnArgs, w as UpdateManyArgs, y as UpsertArgs, W as WhereInput, k as WhereUniqueInput, e as definePlugin } from './contract-BEAyf7Es.cjs';
|
|
3
3
|
import 'decimal.js';
|
|
4
4
|
import '@zenstackhq/sdk/schema';
|
|
5
5
|
import 'kysely';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientConstructor } from './contract-
|
|
2
|
-
export {
|
|
1
|
+
import { C as ClientConstructor } from './contract-BEAyf7Es.js';
|
|
2
|
+
export { H as AggregateArgs, K as AggregateResult, B as BatchResult, h as BooleanFilter, g as BytesFilter, c as ClientContract, d as ClientOptions, E as CountArgs, G as CountResult, t as CreateArgs, v as CreateManyAndReturnArgs, u as CreateManyArgs, D as DateTimeFilter, z as DeleteArgs, A as DeleteManyArgs, F as FindArgs, r as FindFirstArgs, q as FindManyArgs, s as FindUniqueArgs, L as GroupByArgs, P as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, j as NullsOrder, N as NumberFilter, l as OmitInput, O as OrderBy, m as SelectIncludeOmit, n as SelectInput, p as SelectSubset, S as SimplifiedModelResult, i as SortOrder, f as StringFilter, o as Subset, T as ToKysely, U as UpdateArgs, x as UpdateManyAndReturnArgs, w as UpdateManyArgs, y as UpsertArgs, W as WhereInput, k as WhereUniqueInput, e as definePlugin } from './contract-BEAyf7Es.js';
|
|
3
3
|
import 'decimal.js';
|
|
4
4
|
import '@zenstackhq/sdk/schema';
|
|
5
5
|
import 'kysely';
|
package/dist/index.js
CHANGED
|
@@ -2529,13 +2529,13 @@ var BaseOperationHandler = class {
|
|
|
2529
2529
|
inMemoryDistinct = distinct;
|
|
2530
2530
|
}
|
|
2531
2531
|
}
|
|
2532
|
-
if (args
|
|
2533
|
-
query = this.buildFieldSelection(model, query, args
|
|
2532
|
+
if (args && "select" in args && args.select) {
|
|
2533
|
+
query = this.buildFieldSelection(model, query, args.select, model);
|
|
2534
2534
|
} else {
|
|
2535
2535
|
query = this.buildSelectAllScalarFields(model, query, args?.omit);
|
|
2536
2536
|
}
|
|
2537
|
-
if (args
|
|
2538
|
-
query = this.buildFieldSelection(model, query, args
|
|
2537
|
+
if (args && "include" in args && args.include) {
|
|
2538
|
+
query = this.buildFieldSelection(model, query, args.include, model);
|
|
2539
2539
|
}
|
|
2540
2540
|
if (args?.cursor) {
|
|
2541
2541
|
query = this.buildCursorFilter(model, query, args.cursor, args.orderBy, negateOrderBy);
|
|
@@ -3542,7 +3542,7 @@ ${parameters.map((p) => inspect(p)).join("\n")}`;
|
|
|
3542
3542
|
}, {});
|
|
3543
3543
|
}
|
|
3544
3544
|
trimResult(data, args) {
|
|
3545
|
-
if (!args.select) {
|
|
3545
|
+
if (!("select" in args) || !args.select) {
|
|
3546
3546
|
return data;
|
|
3547
3547
|
}
|
|
3548
3548
|
return Object.keys(args.select).reduce((acc, field) => {
|
|
@@ -3552,9 +3552,9 @@ ${parameters.map((p) => inspect(p)).join("\n")}`;
|
|
|
3552
3552
|
}
|
|
3553
3553
|
needReturnRelations(model, args) {
|
|
3554
3554
|
let returnRelation = false;
|
|
3555
|
-
if (args.include) {
|
|
3555
|
+
if ("include" in args && args.include) {
|
|
3556
3556
|
returnRelation = Object.keys(args.include).length > 0;
|
|
3557
|
-
} else if (args.select) {
|
|
3557
|
+
} else if ("select" in args && args.select) {
|
|
3558
3558
|
returnRelation = Object.entries(args.select).some(([K, v]) => {
|
|
3559
3559
|
const fieldDef = this.requireField(model, K);
|
|
3560
3560
|
return fieldDef.relation && v;
|
|
@@ -3823,8 +3823,8 @@ var FindOperationHandler = class extends BaseOperationHandler {
|
|
|
3823
3823
|
__name(this, "FindOperationHandler");
|
|
3824
3824
|
}
|
|
3825
3825
|
async handle(operation, args, validateArgs = true) {
|
|
3826
|
-
const
|
|
3827
|
-
const parsedArgs = validateArgs ? this.inputValidator.validateFindArgs(this.model, operation === "findUnique",
|
|
3826
|
+
const normalizedArgs = this.normalizeArgs(args);
|
|
3827
|
+
const parsedArgs = validateArgs ? this.inputValidator.validateFindArgs(this.model, operation === "findUnique", normalizedArgs) : normalizedArgs;
|
|
3828
3828
|
const result = await this.read(this.client.$qb, this.model, parsedArgs);
|
|
3829
3829
|
const finalResult = operation === "findMany" ? result : result[0] ?? null;
|
|
3830
3830
|
return finalResult;
|
|
@@ -4635,8 +4635,8 @@ var InputValidator = class {
|
|
|
4635
4635
|
return this.refineForSelectIncludeMutuallyExclusive(schema);
|
|
4636
4636
|
}
|
|
4637
4637
|
makeUpdateDataSchema(model, withoutFields = [], withoutRelationFields = false) {
|
|
4638
|
-
const
|
|
4639
|
-
const
|
|
4638
|
+
const uncheckedVariantFields = {};
|
|
4639
|
+
const checkedVariantFields = {};
|
|
4640
4640
|
const modelDef = requireModel(this.schema, model);
|
|
4641
4641
|
const hasRelation = Object.entries(modelDef.fields).some(([key, value]) => value.relation && !withoutFields.includes(key));
|
|
4642
4642
|
Object.keys(modelDef.fields).forEach((field) => {
|
|
@@ -4661,7 +4661,10 @@ var InputValidator = class {
|
|
|
4661
4661
|
if (fieldDef.optional && !fieldDef.array) {
|
|
4662
4662
|
fieldSchema = fieldSchema.nullable();
|
|
4663
4663
|
}
|
|
4664
|
-
|
|
4664
|
+
checkedVariantFields[field] = fieldSchema;
|
|
4665
|
+
if (fieldDef.array || !fieldDef.relation.references) {
|
|
4666
|
+
uncheckedVariantFields[field] = fieldSchema;
|
|
4667
|
+
}
|
|
4665
4668
|
} else {
|
|
4666
4669
|
let fieldSchema = this.makePrimitiveSchema(fieldDef.type).optional();
|
|
4667
4670
|
if (this.isNumericField(fieldDef)) {
|
|
@@ -4688,18 +4691,18 @@ var InputValidator = class {
|
|
|
4688
4691
|
if (fieldDef.optional) {
|
|
4689
4692
|
fieldSchema = fieldSchema.nullable();
|
|
4690
4693
|
}
|
|
4691
|
-
|
|
4694
|
+
uncheckedVariantFields[field] = fieldSchema;
|
|
4692
4695
|
if (!fieldDef.foreignKeyFor) {
|
|
4693
|
-
|
|
4696
|
+
checkedVariantFields[field] = fieldSchema;
|
|
4694
4697
|
}
|
|
4695
4698
|
}
|
|
4696
4699
|
});
|
|
4697
4700
|
if (!hasRelation) {
|
|
4698
|
-
return z.object(
|
|
4701
|
+
return z.object(uncheckedVariantFields).strict();
|
|
4699
4702
|
} else {
|
|
4700
4703
|
return z.union([
|
|
4701
|
-
z.object(
|
|
4702
|
-
z.object(
|
|
4704
|
+
z.object(uncheckedVariantFields).strict(),
|
|
4705
|
+
z.object(checkedVariantFields).strict()
|
|
4703
4706
|
]);
|
|
4704
4707
|
}
|
|
4705
4708
|
}
|