@zenstackhq/runtime 3.0.0-alpha.25 → 3.0.0-alpha.26

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClientConstructor } from './contract-BOWN0dwS.cjs';
2
- export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-BOWN0dwS.cjs';
1
+ import { C as ClientConstructor } from './contract-BF6mvhVn.cjs';
2
+ export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-BF6mvhVn.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-BOWN0dwS.js';
2
- export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-BOWN0dwS.js';
1
+ import { C as ClientConstructor } from './contract-BF6mvhVn.js';
2
+ export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-BF6mvhVn.js';
3
3
  import 'decimal.js';
4
4
  import '@zenstackhq/sdk/schema';
5
5
  import 'kysely';
package/dist/index.js CHANGED
@@ -4471,8 +4471,7 @@ var InputValidator = class {
4471
4471
  }
4472
4472
  validateFindArgs(model, unique, args) {
4473
4473
  return this.validate(model, "find", {
4474
- unique,
4475
- collection: true
4474
+ unique
4476
4475
  }, (model2, options) => this.makeFindSchema(model2, options), args);
4477
4476
  }
4478
4477
  validateCreateArgs(model, args) {
@@ -4540,12 +4539,12 @@ var InputValidator = class {
4540
4539
  fields["select"] = this.makeSelectSchema(model).optional();
4541
4540
  fields["include"] = this.makeIncludeSchema(model).optional();
4542
4541
  fields["omit"] = this.makeOmitSchema(model).optional();
4543
- fields["distinct"] = this.makeDistinctSchema(model).optional();
4544
- fields["cursor"] = this.makeCursorSchema(model).optional();
4545
- if (options.collection) {
4542
+ if (!options.unique) {
4546
4543
  fields["skip"] = this.makeSkipSchema().optional();
4547
4544
  fields["take"] = this.makeTakeSchema().optional();
4548
4545
  fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false), true).optional();
4546
+ fields["cursor"] = this.makeCursorSchema(model).optional();
4547
+ fields["distinct"] = this.makeDistinctSchema(model).optional();
4549
4548
  }
4550
4549
  let result = z.strictObject(fields);
4551
4550
  result = this.refineForSelectIncludeMutuallyExclusive(result);
@@ -4851,13 +4850,7 @@ var InputValidator = class {
4851
4850
  for (const field of Object.keys(modelDef.fields)) {
4852
4851
  const fieldDef = requireField(this.schema, model, field);
4853
4852
  if (fieldDef.relation) {
4854
- fields[field] = z.union([
4855
- z.literal(true),
4856
- z.strictObject({
4857
- select: z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
4858
- include: z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional()
4859
- })
4860
- ]).optional();
4853
+ fields[field] = this.makeRelationSelectIncludeSchema(fieldDef).optional();
4861
4854
  } else {
4862
4855
  fields[field] = z.boolean().optional();
4863
4856
  }
@@ -4881,6 +4874,28 @@ var InputValidator = class {
4881
4874
  }
4882
4875
  return z.strictObject(fields);
4883
4876
  }
4877
+ makeRelationSelectIncludeSchema(fieldDef) {
4878
+ return z.union([
4879
+ z.boolean(),
4880
+ z.strictObject({
4881
+ ...fieldDef.array || fieldDef.optional ? {
4882
+ // to-many relations and optional to-one relations are filterable
4883
+ where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional()
4884
+ } : {},
4885
+ select: z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
4886
+ include: z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional(),
4887
+ omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional(),
4888
+ ...fieldDef.array ? {
4889
+ // to-many relations can be ordered, skipped, taken, and cursor-located
4890
+ orderBy: z.lazy(() => this.makeOrderBySchema(fieldDef.type, true, false)).optional(),
4891
+ skip: this.makeSkipSchema().optional(),
4892
+ take: this.makeTakeSchema().optional(),
4893
+ cursor: this.makeCursorSchema(fieldDef.type).optional(),
4894
+ distinct: this.makeDistinctSchema(fieldDef.type).optional()
4895
+ } : {}
4896
+ })
4897
+ ]);
4898
+ }
4884
4899
  makeOmitSchema(model) {
4885
4900
  const modelDef = requireModel(this.schema, model);
4886
4901
  const fields = {};
@@ -4898,19 +4913,7 @@ var InputValidator = class {
4898
4913
  for (const field of Object.keys(modelDef.fields)) {
4899
4914
  const fieldDef = requireField(this.schema, model, field);
4900
4915
  if (fieldDef.relation) {
4901
- fields[field] = z.union([
4902
- z.literal(true),
4903
- z.strictObject({
4904
- select: z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
4905
- include: z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional(),
4906
- omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional(),
4907
- where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional(),
4908
- orderBy: z.lazy(() => this.makeOrderBySchema(fieldDef.type, true, false)).optional(),
4909
- skip: this.makeSkipSchema().optional(),
4910
- take: this.makeTakeSchema().optional(),
4911
- distinct: this.makeDistinctSchema(fieldDef.type).optional()
4912
- })
4913
- ]).optional();
4916
+ fields[field] = this.makeRelationSelectIncludeSchema(fieldDef).optional();
4914
4917
  }
4915
4918
  }
4916
4919
  return z.strictObject(fields);