@zenstackhq/orm 3.4.0-beta.1 → 3.4.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 +358 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1594 -1373
- package/dist/index.d.ts +1594 -1373
- package/dist/index.js +358 -111
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -644,13 +644,50 @@ var LOGICAL_COMBINATORS = [
|
|
|
644
644
|
"OR",
|
|
645
645
|
"NOT"
|
|
646
646
|
];
|
|
647
|
-
var
|
|
647
|
+
var AggregateOperators = [
|
|
648
648
|
"_count",
|
|
649
649
|
"_sum",
|
|
650
650
|
"_avg",
|
|
651
651
|
"_min",
|
|
652
652
|
"_max"
|
|
653
653
|
];
|
|
654
|
+
var FILTER_PROPERTY_TO_KIND = {
|
|
655
|
+
// Equality operators
|
|
656
|
+
equals: "Equality",
|
|
657
|
+
not: "Equality",
|
|
658
|
+
in: "Equality",
|
|
659
|
+
notIn: "Equality",
|
|
660
|
+
// Range operators
|
|
661
|
+
lt: "Range",
|
|
662
|
+
lte: "Range",
|
|
663
|
+
gt: "Range",
|
|
664
|
+
gte: "Range",
|
|
665
|
+
between: "Range",
|
|
666
|
+
// Like operators
|
|
667
|
+
contains: "Like",
|
|
668
|
+
startsWith: "Like",
|
|
669
|
+
endsWith: "Like",
|
|
670
|
+
mode: "Like",
|
|
671
|
+
// Relation operators
|
|
672
|
+
is: "Relation",
|
|
673
|
+
isNot: "Relation",
|
|
674
|
+
some: "Relation",
|
|
675
|
+
every: "Relation",
|
|
676
|
+
none: "Relation",
|
|
677
|
+
// Json operators
|
|
678
|
+
path: "Json",
|
|
679
|
+
string_contains: "Json",
|
|
680
|
+
string_starts_with: "Json",
|
|
681
|
+
string_ends_with: "Json",
|
|
682
|
+
array_contains: "Json",
|
|
683
|
+
array_starts_with: "Json",
|
|
684
|
+
array_ends_with: "Json",
|
|
685
|
+
// List operators
|
|
686
|
+
has: "List",
|
|
687
|
+
hasEvery: "List",
|
|
688
|
+
hasSome: "List",
|
|
689
|
+
isEmpty: "List"
|
|
690
|
+
};
|
|
654
691
|
|
|
655
692
|
// src/client/contract.ts
|
|
656
693
|
var TransactionIsolationLevel = /* @__PURE__ */ function(TransactionIsolationLevel2) {
|
|
@@ -1213,7 +1250,7 @@ var BaseCrudDialect = class {
|
|
|
1213
1250
|
this.eb(lhs, ">=", start),
|
|
1214
1251
|
this.eb(lhs, "<=", end)
|
|
1215
1252
|
]);
|
|
1216
|
-
}).with("not", () => this.eb.not(recurse(value))).with(import_ts_pattern2.P.union(...
|
|
1253
|
+
}).with("not", () => this.eb.not(recurse(value))).with(import_ts_pattern2.P.union(...AggregateOperators), (op2) => {
|
|
1217
1254
|
const innerResult = this.buildStandardFilter(type, value, aggregate(this.eb, lhs, op2), getRhs, recurse, throwIfInvalid);
|
|
1218
1255
|
consumedKeys.push(...innerResult.consumedKeys);
|
|
1219
1256
|
return this.and(...innerResult.conditions);
|
|
@@ -5025,6 +5062,9 @@ var InputValidator = class {
|
|
|
5025
5062
|
}
|
|
5026
5063
|
client;
|
|
5027
5064
|
schemaCache = /* @__PURE__ */ new Map();
|
|
5065
|
+
allFilterKinds = [
|
|
5066
|
+
...new Set(Object.values(FILTER_PROPERTY_TO_KIND))
|
|
5067
|
+
];
|
|
5028
5068
|
constructor(client) {
|
|
5029
5069
|
this.client = client;
|
|
5030
5070
|
}
|
|
@@ -5296,6 +5336,10 @@ var InputValidator = class {
|
|
|
5296
5336
|
}
|
|
5297
5337
|
makeWhereSchema(model, unique, withoutRelationFields = false, withAggregations = false) {
|
|
5298
5338
|
const modelDef = requireModel(this.schema, model);
|
|
5339
|
+
const uniqueFieldNames = unique ? getUniqueFields(this.schema, model).filter((uf) => (
|
|
5340
|
+
// single-field unique
|
|
5341
|
+
"def" in uf
|
|
5342
|
+
)).map((uf) => uf.name) : void 0;
|
|
5299
5343
|
const fields = {};
|
|
5300
5344
|
for (const field of Object.keys(modelDef.fields)) {
|
|
5301
5345
|
const fieldDef = requireField(this.schema, model, field);
|
|
@@ -5304,38 +5348,44 @@ var InputValidator = class {
|
|
|
5304
5348
|
if (withoutRelationFields) {
|
|
5305
5349
|
continue;
|
|
5306
5350
|
}
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
fieldSchema = import_zod2.z.union([
|
|
5311
|
-
fieldSchema,
|
|
5312
|
-
import_zod2.z.strictObject({
|
|
5313
|
-
some: fieldSchema.optional(),
|
|
5314
|
-
every: fieldSchema.optional(),
|
|
5315
|
-
none: fieldSchema.optional()
|
|
5316
|
-
})
|
|
5317
|
-
]);
|
|
5351
|
+
const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
|
|
5352
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) {
|
|
5353
|
+
fieldSchema = import_zod2.z.never();
|
|
5318
5354
|
} else {
|
|
5319
|
-
fieldSchema = import_zod2.z.
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5355
|
+
fieldSchema = import_zod2.z.lazy(() => this.makeWhereSchema(fieldDef.type, false).optional());
|
|
5356
|
+
fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
|
|
5357
|
+
if (fieldDef.array) {
|
|
5358
|
+
fieldSchema = import_zod2.z.union([
|
|
5359
|
+
fieldSchema,
|
|
5360
|
+
import_zod2.z.strictObject({
|
|
5361
|
+
some: fieldSchema.optional(),
|
|
5362
|
+
every: fieldSchema.optional(),
|
|
5363
|
+
none: fieldSchema.optional()
|
|
5364
|
+
})
|
|
5365
|
+
]);
|
|
5366
|
+
} else {
|
|
5367
|
+
fieldSchema = import_zod2.z.union([
|
|
5368
|
+
fieldSchema,
|
|
5369
|
+
import_zod2.z.strictObject({
|
|
5370
|
+
is: fieldSchema.optional(),
|
|
5371
|
+
isNot: fieldSchema.optional()
|
|
5372
|
+
})
|
|
5373
|
+
]);
|
|
5374
|
+
}
|
|
5326
5375
|
}
|
|
5327
5376
|
} else {
|
|
5377
|
+
const ignoreSlicing = !!uniqueFieldNames?.includes(field);
|
|
5328
5378
|
const enumDef = getEnum(this.schema, fieldDef.type);
|
|
5329
5379
|
if (enumDef) {
|
|
5330
5380
|
if (Object.keys(enumDef.values).length > 0) {
|
|
5331
|
-
fieldSchema = this.makeEnumFilterSchema(
|
|
5381
|
+
fieldSchema = this.makeEnumFilterSchema(model, fieldDef, withAggregations, ignoreSlicing);
|
|
5332
5382
|
}
|
|
5333
5383
|
} else if (fieldDef.array) {
|
|
5334
|
-
fieldSchema = this.makeArrayFilterSchema(fieldDef
|
|
5384
|
+
fieldSchema = this.makeArrayFilterSchema(model, fieldDef);
|
|
5335
5385
|
} else if (this.isTypeDefType(fieldDef.type)) {
|
|
5336
|
-
fieldSchema = this.makeTypedJsonFilterSchema(
|
|
5386
|
+
fieldSchema = this.makeTypedJsonFilterSchema(model, fieldDef);
|
|
5337
5387
|
} else {
|
|
5338
|
-
fieldSchema = this.makePrimitiveFilterSchema(
|
|
5388
|
+
fieldSchema = this.makePrimitiveFilterSchema(model, fieldDef, withAggregations, ignoreSlicing);
|
|
5339
5389
|
}
|
|
5340
5390
|
}
|
|
5341
5391
|
if (fieldSchema) {
|
|
@@ -5352,12 +5402,12 @@ var InputValidator = class {
|
|
|
5352
5402
|
const enumDef = getEnum(this.schema, def.type);
|
|
5353
5403
|
if (enumDef) {
|
|
5354
5404
|
if (Object.keys(enumDef.values).length > 0) {
|
|
5355
|
-
fieldSchema = this.makeEnumFilterSchema(
|
|
5405
|
+
fieldSchema = this.makeEnumFilterSchema(model, def, false, true);
|
|
5356
5406
|
} else {
|
|
5357
5407
|
fieldSchema = import_zod2.z.never();
|
|
5358
5408
|
}
|
|
5359
5409
|
} else {
|
|
5360
|
-
fieldSchema = this.makePrimitiveFilterSchema(
|
|
5410
|
+
fieldSchema = this.makePrimitiveFilterSchema(model, def, false, true);
|
|
5361
5411
|
}
|
|
5362
5412
|
return [
|
|
5363
5413
|
key,
|
|
@@ -5392,7 +5442,11 @@ var InputValidator = class {
|
|
|
5392
5442
|
}
|
|
5393
5443
|
return result;
|
|
5394
5444
|
}
|
|
5395
|
-
makeTypedJsonFilterSchema(
|
|
5445
|
+
makeTypedJsonFilterSchema(contextModel, fieldInfo) {
|
|
5446
|
+
const field = fieldInfo.name;
|
|
5447
|
+
const type = fieldInfo.type;
|
|
5448
|
+
const optional = !!fieldInfo.optional;
|
|
5449
|
+
const array = !!fieldInfo.array;
|
|
5396
5450
|
const typeDef = getTypeDef(this.schema, type);
|
|
5397
5451
|
(0, import_common_helpers9.invariant)(typeDef, `Type definition "${type}" not found in schema`);
|
|
5398
5452
|
const candidates = [];
|
|
@@ -5400,21 +5454,26 @@ var InputValidator = class {
|
|
|
5400
5454
|
const fieldSchemas = {};
|
|
5401
5455
|
for (const [fieldName, fieldDef] of Object.entries(typeDef.fields)) {
|
|
5402
5456
|
if (this.isTypeDefType(fieldDef.type)) {
|
|
5403
|
-
fieldSchemas[fieldName] = this.makeTypedJsonFilterSchema(
|
|
5457
|
+
fieldSchemas[fieldName] = this.makeTypedJsonFilterSchema(contextModel, fieldDef).optional();
|
|
5404
5458
|
} else {
|
|
5405
5459
|
const enumDef = getEnum(this.schema, fieldDef.type);
|
|
5406
5460
|
if (enumDef) {
|
|
5407
|
-
fieldSchemas[fieldName] = this.makeEnumFilterSchema(
|
|
5461
|
+
fieldSchemas[fieldName] = this.makeEnumFilterSchema(contextModel, fieldDef, false).optional();
|
|
5408
5462
|
} else if (fieldDef.array) {
|
|
5409
|
-
fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef
|
|
5463
|
+
fieldSchemas[fieldName] = this.makeArrayFilterSchema(contextModel, fieldDef).optional();
|
|
5410
5464
|
} else {
|
|
5411
|
-
fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(
|
|
5465
|
+
fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(contextModel, fieldDef, false).optional();
|
|
5412
5466
|
}
|
|
5413
5467
|
}
|
|
5414
5468
|
}
|
|
5415
5469
|
candidates.push(import_zod2.z.strictObject(fieldSchemas));
|
|
5416
5470
|
}
|
|
5417
|
-
const recursiveSchema = import_zod2.z.lazy(() => this.makeTypedJsonFilterSchema(
|
|
5471
|
+
const recursiveSchema = import_zod2.z.lazy(() => this.makeTypedJsonFilterSchema(contextModel, {
|
|
5472
|
+
name: field,
|
|
5473
|
+
type,
|
|
5474
|
+
optional,
|
|
5475
|
+
array: false
|
|
5476
|
+
})).optional();
|
|
5418
5477
|
if (array) {
|
|
5419
5478
|
candidates.push(import_zod2.z.strictObject({
|
|
5420
5479
|
some: recursiveSchema,
|
|
@@ -5427,7 +5486,7 @@ var InputValidator = class {
|
|
|
5427
5486
|
isNot: recursiveSchema
|
|
5428
5487
|
}));
|
|
5429
5488
|
}
|
|
5430
|
-
candidates.push(this.makeJsonFilterSchema(optional));
|
|
5489
|
+
candidates.push(this.makeJsonFilterSchema(contextModel, field, optional));
|
|
5431
5490
|
if (optional) {
|
|
5432
5491
|
candidates.push(import_zod2.z.null());
|
|
5433
5492
|
}
|
|
@@ -5436,14 +5495,18 @@ var InputValidator = class {
|
|
|
5436
5495
|
isTypeDefType(type) {
|
|
5437
5496
|
return this.schema.typeDefs && type in this.schema.typeDefs;
|
|
5438
5497
|
}
|
|
5439
|
-
makeEnumFilterSchema(
|
|
5498
|
+
makeEnumFilterSchema(model, fieldInfo, withAggregations, ignoreSlicing = false) {
|
|
5499
|
+
const enumName = fieldInfo.type;
|
|
5500
|
+
const optional = !!fieldInfo.optional;
|
|
5501
|
+
const array = !!fieldInfo.array;
|
|
5440
5502
|
const enumDef = getEnum(this.schema, enumName);
|
|
5441
5503
|
(0, import_common_helpers9.invariant)(enumDef, `Enum "${enumName}" not found in schema`);
|
|
5442
5504
|
const baseSchema = import_zod2.z.enum(Object.keys(enumDef.values));
|
|
5443
5505
|
if (array) {
|
|
5444
|
-
return this.internalMakeArrayFilterSchema(baseSchema);
|
|
5506
|
+
return this.internalMakeArrayFilterSchema(model, fieldInfo.name, baseSchema);
|
|
5445
5507
|
}
|
|
5446
|
-
const
|
|
5508
|
+
const allowedFilterKinds = ignoreSlicing ? void 0 : this.getEffectiveFilterKinds(model, fieldInfo.name);
|
|
5509
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => import_zod2.z.lazy(() => this.makeEnumFilterSchema(model, fieldInfo, withAggregations)), [
|
|
5447
5510
|
"equals",
|
|
5448
5511
|
"in",
|
|
5449
5512
|
"notIn",
|
|
@@ -5452,26 +5515,29 @@ var InputValidator = class {
|
|
|
5452
5515
|
"_count",
|
|
5453
5516
|
"_min",
|
|
5454
5517
|
"_max"
|
|
5455
|
-
] : void 0);
|
|
5456
|
-
return
|
|
5457
|
-
this.nullableIf(baseSchema, optional),
|
|
5458
|
-
import_zod2.z.strictObject(components)
|
|
5459
|
-
]);
|
|
5518
|
+
] : void 0, allowedFilterKinds);
|
|
5519
|
+
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
5460
5520
|
}
|
|
5461
|
-
makeArrayFilterSchema(
|
|
5462
|
-
return this.internalMakeArrayFilterSchema(this.makeScalarSchema(type));
|
|
5521
|
+
makeArrayFilterSchema(model, fieldInfo) {
|
|
5522
|
+
return this.internalMakeArrayFilterSchema(model, fieldInfo.name, this.makeScalarSchema(fieldInfo.type));
|
|
5463
5523
|
}
|
|
5464
|
-
internalMakeArrayFilterSchema(elementSchema) {
|
|
5465
|
-
|
|
5524
|
+
internalMakeArrayFilterSchema(contextModel, field, elementSchema) {
|
|
5525
|
+
const allowedFilterKinds = this.getEffectiveFilterKinds(contextModel, field);
|
|
5526
|
+
const operators = {
|
|
5466
5527
|
equals: elementSchema.array().optional(),
|
|
5467
5528
|
has: elementSchema.optional(),
|
|
5468
5529
|
hasEvery: elementSchema.array().optional(),
|
|
5469
5530
|
hasSome: elementSchema.array().optional(),
|
|
5470
5531
|
isEmpty: import_zod2.z.boolean().optional()
|
|
5471
|
-
}
|
|
5532
|
+
};
|
|
5533
|
+
const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
|
|
5534
|
+
return import_zod2.z.strictObject(filteredOperators);
|
|
5472
5535
|
}
|
|
5473
|
-
makePrimitiveFilterSchema(
|
|
5474
|
-
|
|
5536
|
+
makePrimitiveFilterSchema(contextModel, fieldInfo, withAggregations, ignoreSlicing = false) {
|
|
5537
|
+
const allowedFilterKinds = ignoreSlicing ? void 0 : this.getEffectiveFilterKinds(contextModel, fieldInfo.name);
|
|
5538
|
+
const type = fieldInfo.type;
|
|
5539
|
+
const optional = !!fieldInfo.optional;
|
|
5540
|
+
return (0, import_ts_pattern14.match)(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)).with(import_ts_pattern14.P.union("Int", "Float", "Decimal", "BigInt"), (type2) => this.makeNumberFilterSchema(this.makeScalarSchema(type2), optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(contextModel, fieldInfo.name, optional)).with("Unsupported", () => import_zod2.z.never()).exhaustive();
|
|
5475
5541
|
}
|
|
5476
5542
|
makeJsonValueSchema(nullable, forFilter) {
|
|
5477
5543
|
const options = [
|
|
@@ -5503,7 +5569,11 @@ var InputValidator = class {
|
|
|
5503
5569
|
]);
|
|
5504
5570
|
return this.nullableIf(schema, nullable);
|
|
5505
5571
|
}
|
|
5506
|
-
makeJsonFilterSchema(optional) {
|
|
5572
|
+
makeJsonFilterSchema(contextModel, field, optional) {
|
|
5573
|
+
const allowedFilterKinds = this.getEffectiveFilterKinds(contextModel, field);
|
|
5574
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) {
|
|
5575
|
+
return import_zod2.z.never();
|
|
5576
|
+
}
|
|
5507
5577
|
const valueSchema = this.makeJsonValueSchema(optional, true);
|
|
5508
5578
|
return import_zod2.z.strictObject({
|
|
5509
5579
|
path: import_zod2.z.string().optional(),
|
|
@@ -5518,31 +5588,28 @@ var InputValidator = class {
|
|
|
5518
5588
|
array_ends_with: valueSchema.optional()
|
|
5519
5589
|
});
|
|
5520
5590
|
}
|
|
5521
|
-
makeDateTimeFilterSchema(optional, withAggregations) {
|
|
5591
|
+
makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
5522
5592
|
return this.makeCommonPrimitiveFilterSchema(import_zod2.z.union([
|
|
5523
5593
|
import_zod2.z.iso.datetime(),
|
|
5524
5594
|
import_zod2.z.date()
|
|
5525
|
-
]), optional, () => import_zod2.z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations)), withAggregations ? [
|
|
5595
|
+
]), optional, () => import_zod2.z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
5526
5596
|
"_count",
|
|
5527
5597
|
"_min",
|
|
5528
5598
|
"_max"
|
|
5529
|
-
] : void 0);
|
|
5599
|
+
] : void 0, allowedFilterKinds);
|
|
5530
5600
|
}
|
|
5531
|
-
makeBooleanFilterSchema(optional, withAggregations) {
|
|
5532
|
-
const components = this.makeCommonPrimitiveFilterComponents(import_zod2.z.boolean(), optional, () => import_zod2.z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations)), [
|
|
5601
|
+
makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
5602
|
+
const components = this.makeCommonPrimitiveFilterComponents(import_zod2.z.boolean(), optional, () => import_zod2.z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), [
|
|
5533
5603
|
"equals",
|
|
5534
5604
|
"not"
|
|
5535
5605
|
], withAggregations ? [
|
|
5536
5606
|
"_count",
|
|
5537
5607
|
"_min",
|
|
5538
5608
|
"_max"
|
|
5539
|
-
] : void 0);
|
|
5540
|
-
return import_zod2.z.
|
|
5541
|
-
this.nullableIf(import_zod2.z.boolean(), optional),
|
|
5542
|
-
import_zod2.z.strictObject(components)
|
|
5543
|
-
]);
|
|
5609
|
+
] : void 0, allowedFilterKinds);
|
|
5610
|
+
return this.createUnionFilterSchema(import_zod2.z.boolean(), optional, components, allowedFilterKinds);
|
|
5544
5611
|
}
|
|
5545
|
-
makeBytesFilterSchema(optional, withAggregations) {
|
|
5612
|
+
makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
5546
5613
|
const baseSchema = import_zod2.z.instanceof(Uint8Array);
|
|
5547
5614
|
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => import_zod2.z.instanceof(Uint8Array), [
|
|
5548
5615
|
"equals",
|
|
@@ -5553,17 +5620,13 @@ var InputValidator = class {
|
|
|
5553
5620
|
"_count",
|
|
5554
5621
|
"_min",
|
|
5555
5622
|
"_max"
|
|
5556
|
-
] : void 0);
|
|
5557
|
-
return
|
|
5558
|
-
this.nullableIf(baseSchema, optional),
|
|
5559
|
-
import_zod2.z.strictObject(components)
|
|
5560
|
-
]);
|
|
5623
|
+
] : void 0, allowedFilterKinds);
|
|
5624
|
+
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
5561
5625
|
}
|
|
5562
|
-
makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, supportedOperators = void 0, withAggregations = void 0) {
|
|
5563
|
-
const commonAggSchema = /* @__PURE__ */ __name(() => this.makeCommonPrimitiveFilterSchema(baseSchema, false, makeThis, void 0).optional(), "commonAggSchema");
|
|
5626
|
+
makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, supportedOperators = void 0, withAggregations = void 0, allowedFilterKinds = void 0) {
|
|
5627
|
+
const commonAggSchema = /* @__PURE__ */ __name(() => this.makeCommonPrimitiveFilterSchema(baseSchema, false, makeThis, void 0, allowedFilterKinds).optional(), "commonAggSchema");
|
|
5564
5628
|
let result = {
|
|
5565
5629
|
equals: this.nullableIf(baseSchema.optional(), optional),
|
|
5566
|
-
notEquals: this.nullableIf(baseSchema.optional(), optional),
|
|
5567
5630
|
in: baseSchema.array().optional(),
|
|
5568
5631
|
notIn: baseSchema.array().optional(),
|
|
5569
5632
|
lt: baseSchema.optional(),
|
|
@@ -5573,7 +5636,7 @@ var InputValidator = class {
|
|
|
5573
5636
|
between: baseSchema.array().length(2).optional(),
|
|
5574
5637
|
not: makeThis().optional(),
|
|
5575
5638
|
...withAggregations?.includes("_count") ? {
|
|
5576
|
-
_count: this.makeNumberFilterSchema(import_zod2.z.number().int(), false, false).optional()
|
|
5639
|
+
_count: this.makeNumberFilterSchema(import_zod2.z.number().int(), false, false, void 0).optional()
|
|
5577
5640
|
} : {},
|
|
5578
5641
|
...withAggregations?.includes("_avg") ? {
|
|
5579
5642
|
_avg: commonAggSchema()
|
|
@@ -5595,40 +5658,42 @@ var InputValidator = class {
|
|
|
5595
5658
|
];
|
|
5596
5659
|
result = extractFields(result, keys);
|
|
5597
5660
|
}
|
|
5661
|
+
result = this.trimFilterOperators(result, allowedFilterKinds);
|
|
5598
5662
|
return result;
|
|
5599
5663
|
}
|
|
5600
|
-
makeCommonPrimitiveFilterSchema(baseSchema, optional, makeThis, withAggregations = void 0) {
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
import_zod2.z.strictObject(this.makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, void 0, withAggregations))
|
|
5604
|
-
]);
|
|
5664
|
+
makeCommonPrimitiveFilterSchema(baseSchema, optional, makeThis, withAggregations = void 0, allowedFilterKinds = void 0) {
|
|
5665
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, void 0, withAggregations, allowedFilterKinds);
|
|
5666
|
+
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
5605
5667
|
}
|
|
5606
|
-
makeNumberFilterSchema(baseSchema, optional, withAggregations) {
|
|
5607
|
-
return this.makeCommonPrimitiveFilterSchema(baseSchema, optional, () => import_zod2.z.lazy(() => this.makeNumberFilterSchema(baseSchema, optional, withAggregations)), withAggregations ? [
|
|
5668
|
+
makeNumberFilterSchema(baseSchema, optional, withAggregations, allowedFilterKinds) {
|
|
5669
|
+
return this.makeCommonPrimitiveFilterSchema(baseSchema, optional, () => import_zod2.z.lazy(() => this.makeNumberFilterSchema(baseSchema, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
5608
5670
|
"_count",
|
|
5609
5671
|
"_avg",
|
|
5610
5672
|
"_sum",
|
|
5611
5673
|
"_min",
|
|
5612
5674
|
"_max"
|
|
5613
|
-
] : void 0);
|
|
5675
|
+
] : void 0, allowedFilterKinds);
|
|
5614
5676
|
}
|
|
5615
|
-
makeStringFilterSchema(optional, withAggregations) {
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5677
|
+
makeStringFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
5678
|
+
const baseComponents = this.makeCommonPrimitiveFilterComponents(import_zod2.z.string(), optional, () => import_zod2.z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)), void 0, withAggregations ? [
|
|
5679
|
+
"_count",
|
|
5680
|
+
"_min",
|
|
5681
|
+
"_max"
|
|
5682
|
+
] : void 0, allowedFilterKinds);
|
|
5683
|
+
const stringSpecificOperators = {
|
|
5684
|
+
startsWith: import_zod2.z.string().optional(),
|
|
5685
|
+
endsWith: import_zod2.z.string().optional(),
|
|
5686
|
+
contains: import_zod2.z.string().optional(),
|
|
5687
|
+
...this.providerSupportsCaseSensitivity ? {
|
|
5688
|
+
mode: this.makeStringModeSchema().optional()
|
|
5689
|
+
} : {}
|
|
5690
|
+
};
|
|
5691
|
+
const filteredStringOperators = this.trimFilterOperators(stringSpecificOperators, allowedFilterKinds);
|
|
5692
|
+
const allComponents = {
|
|
5693
|
+
...baseComponents,
|
|
5694
|
+
...filteredStringOperators
|
|
5695
|
+
};
|
|
5696
|
+
return this.createUnionFilterSchema(import_zod2.z.string(), optional, allComponents, allowedFilterKinds);
|
|
5632
5697
|
}
|
|
5633
5698
|
makeStringModeSchema() {
|
|
5634
5699
|
return import_zod2.z.union([
|
|
@@ -5642,7 +5707,9 @@ var InputValidator = class {
|
|
|
5642
5707
|
for (const field of Object.keys(modelDef.fields)) {
|
|
5643
5708
|
const fieldDef = requireField(this.schema, model, field);
|
|
5644
5709
|
if (fieldDef.relation) {
|
|
5645
|
-
|
|
5710
|
+
if (this.isModelAllowed(fieldDef.type)) {
|
|
5711
|
+
fields[field] = this.makeRelationSelectIncludeSchema(model, field).optional();
|
|
5712
|
+
}
|
|
5646
5713
|
} else {
|
|
5647
5714
|
fields[field] = import_zod2.z.boolean().optional();
|
|
5648
5715
|
}
|
|
@@ -5722,7 +5789,9 @@ var InputValidator = class {
|
|
|
5722
5789
|
for (const field of Object.keys(modelDef.fields)) {
|
|
5723
5790
|
const fieldDef = requireField(this.schema, model, field);
|
|
5724
5791
|
if (fieldDef.relation) {
|
|
5725
|
-
|
|
5792
|
+
if (this.isModelAllowed(fieldDef.type)) {
|
|
5793
|
+
fields[field] = this.makeRelationSelectIncludeSchema(model, field).optional();
|
|
5794
|
+
}
|
|
5726
5795
|
}
|
|
5727
5796
|
}
|
|
5728
5797
|
const _countSchema = this.makeCountSelectionSchema(model);
|
|
@@ -5838,6 +5907,9 @@ var InputValidator = class {
|
|
|
5838
5907
|
if (withoutRelationFields) {
|
|
5839
5908
|
return;
|
|
5840
5909
|
}
|
|
5910
|
+
if (!this.isModelAllowed(fieldDef.type)) {
|
|
5911
|
+
return;
|
|
5912
|
+
}
|
|
5841
5913
|
const excludeFields = [];
|
|
5842
5914
|
const oppositeField = fieldDef.relation.opposite;
|
|
5843
5915
|
if (oppositeField) {
|
|
@@ -6065,6 +6137,9 @@ var InputValidator = class {
|
|
|
6065
6137
|
if (withoutRelationFields) {
|
|
6066
6138
|
return;
|
|
6067
6139
|
}
|
|
6140
|
+
if (!this.isModelAllowed(fieldDef.type)) {
|
|
6141
|
+
return;
|
|
6142
|
+
}
|
|
6068
6143
|
const excludeFields = [];
|
|
6069
6144
|
const oppositeField = fieldDef.relation.opposite;
|
|
6070
6145
|
if (oppositeField) {
|
|
@@ -6240,7 +6315,7 @@ var InputValidator = class {
|
|
|
6240
6315
|
] : value.by;
|
|
6241
6316
|
if (value.having && typeof value.having === "object") {
|
|
6242
6317
|
for (const [key, val] of Object.entries(value.having)) {
|
|
6243
|
-
if (
|
|
6318
|
+
if (AggregateOperators.includes(key)) {
|
|
6244
6319
|
continue;
|
|
6245
6320
|
}
|
|
6246
6321
|
if (bys.includes(key)) {
|
|
@@ -6260,7 +6335,7 @@ var InputValidator = class {
|
|
|
6260
6335
|
const bys = typeof value.by === "string" ? [
|
|
6261
6336
|
value.by
|
|
6262
6337
|
] : value.by;
|
|
6263
|
-
if (value.orderBy && Object.keys(value.orderBy).filter((f) => !
|
|
6338
|
+
if (value.orderBy && Object.keys(value.orderBy).filter((f) => !AggregateOperators.includes(f)).some((key) => !bys.includes(key))) {
|
|
6264
6339
|
return false;
|
|
6265
6340
|
} else {
|
|
6266
6341
|
return true;
|
|
@@ -6270,7 +6345,7 @@ var InputValidator = class {
|
|
|
6270
6345
|
}
|
|
6271
6346
|
onlyAggregationFields(val) {
|
|
6272
6347
|
for (const [key, value] of Object.entries(val)) {
|
|
6273
|
-
if (
|
|
6348
|
+
if (AggregateOperators.includes(key)) {
|
|
6274
6349
|
continue;
|
|
6275
6350
|
}
|
|
6276
6351
|
if (LOGICAL_COMBINATORS.includes(key)) {
|
|
@@ -6355,6 +6430,108 @@ var InputValidator = class {
|
|
|
6355
6430
|
get providerSupportsCaseSensitivity() {
|
|
6356
6431
|
return this.schema.provider.type === "postgresql";
|
|
6357
6432
|
}
|
|
6433
|
+
/**
|
|
6434
|
+
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
6435
|
+
* Respects the precedence: field-level > model-level $all > global $all.
|
|
6436
|
+
*/
|
|
6437
|
+
getEffectiveFilterKinds(model, field) {
|
|
6438
|
+
if (!model) {
|
|
6439
|
+
return void 0;
|
|
6440
|
+
}
|
|
6441
|
+
const slicing = this.options.slicing;
|
|
6442
|
+
if (!slicing?.models) {
|
|
6443
|
+
return void 0;
|
|
6444
|
+
}
|
|
6445
|
+
const modelConfig = slicing.models[model];
|
|
6446
|
+
if (modelConfig?.fields) {
|
|
6447
|
+
const fieldConfig = modelConfig.fields[field];
|
|
6448
|
+
if (fieldConfig) {
|
|
6449
|
+
return this.computeFilterKinds(fieldConfig.includedFilterKinds, fieldConfig.excludedFilterKinds);
|
|
6450
|
+
}
|
|
6451
|
+
const allFieldsConfig = modelConfig.fields.$all;
|
|
6452
|
+
if (allFieldsConfig) {
|
|
6453
|
+
return this.computeFilterKinds(allFieldsConfig.includedFilterKinds, allFieldsConfig.excludedFilterKinds);
|
|
6454
|
+
}
|
|
6455
|
+
}
|
|
6456
|
+
const allModelsConfig = slicing.models.$all;
|
|
6457
|
+
if (allModelsConfig?.fields) {
|
|
6458
|
+
if (allModelsConfig.fields.$all) {
|
|
6459
|
+
return this.computeFilterKinds(allModelsConfig.fields.$all.includedFilterKinds, allModelsConfig.fields.$all.excludedFilterKinds);
|
|
6460
|
+
}
|
|
6461
|
+
}
|
|
6462
|
+
return void 0;
|
|
6463
|
+
}
|
|
6464
|
+
/**
|
|
6465
|
+
* Computes the effective set of filter kinds based on inclusion and exclusion lists.
|
|
6466
|
+
*/
|
|
6467
|
+
computeFilterKinds(included, excluded) {
|
|
6468
|
+
let result;
|
|
6469
|
+
if (included !== void 0) {
|
|
6470
|
+
result = [
|
|
6471
|
+
...included
|
|
6472
|
+
];
|
|
6473
|
+
}
|
|
6474
|
+
if (excluded !== void 0) {
|
|
6475
|
+
if (!result) {
|
|
6476
|
+
result = [
|
|
6477
|
+
...this.allFilterKinds
|
|
6478
|
+
];
|
|
6479
|
+
}
|
|
6480
|
+
for (const kind of excluded) {
|
|
6481
|
+
result = result.filter((k) => k !== kind);
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
return result;
|
|
6485
|
+
}
|
|
6486
|
+
/**
|
|
6487
|
+
* Filters operators based on allowed filter kinds.
|
|
6488
|
+
*/
|
|
6489
|
+
trimFilterOperators(operators, allowedKinds) {
|
|
6490
|
+
if (!allowedKinds) {
|
|
6491
|
+
return operators;
|
|
6492
|
+
}
|
|
6493
|
+
return Object.fromEntries(Object.entries(operators).filter(([key, _]) => {
|
|
6494
|
+
return !(key in FILTER_PROPERTY_TO_KIND) || allowedKinds.includes(FILTER_PROPERTY_TO_KIND[key]);
|
|
6495
|
+
}));
|
|
6496
|
+
}
|
|
6497
|
+
createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
|
|
6498
|
+
if (Object.keys(components).length === 0) {
|
|
6499
|
+
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) {
|
|
6500
|
+
return this.nullableIf(valueSchema, optional);
|
|
6501
|
+
}
|
|
6502
|
+
return import_zod2.z.never();
|
|
6503
|
+
}
|
|
6504
|
+
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) {
|
|
6505
|
+
return import_zod2.z.union([
|
|
6506
|
+
this.nullableIf(valueSchema, optional),
|
|
6507
|
+
import_zod2.z.strictObject(components)
|
|
6508
|
+
]);
|
|
6509
|
+
} else {
|
|
6510
|
+
return import_zod2.z.strictObject(components);
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6513
|
+
/**
|
|
6514
|
+
* Checks if a model is included in the slicing configuration.
|
|
6515
|
+
* Returns true if the model is allowed, false if it's excluded.
|
|
6516
|
+
*/
|
|
6517
|
+
isModelAllowed(targetModel) {
|
|
6518
|
+
const slicing = this.options.slicing;
|
|
6519
|
+
if (!slicing) {
|
|
6520
|
+
return true;
|
|
6521
|
+
}
|
|
6522
|
+
const { includedModels, excludedModels } = slicing;
|
|
6523
|
+
if (includedModels !== void 0) {
|
|
6524
|
+
if (!includedModels.includes(targetModel)) {
|
|
6525
|
+
return false;
|
|
6526
|
+
}
|
|
6527
|
+
}
|
|
6528
|
+
if (excludedModels !== void 0) {
|
|
6529
|
+
if (excludedModels.includes(targetModel)) {
|
|
6530
|
+
return false;
|
|
6531
|
+
}
|
|
6532
|
+
}
|
|
6533
|
+
return true;
|
|
6534
|
+
}
|
|
6358
6535
|
};
|
|
6359
6536
|
_ts_decorate([
|
|
6360
6537
|
cache(),
|
|
@@ -6404,9 +6581,8 @@ _ts_decorate([
|
|
|
6404
6581
|
cache(),
|
|
6405
6582
|
_ts_metadata("design:type", Function),
|
|
6406
6583
|
_ts_metadata("design:paramtypes", [
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
Boolean
|
|
6584
|
+
Object,
|
|
6585
|
+
typeof FieldInfo === "undefined" ? Object : FieldInfo
|
|
6410
6586
|
]),
|
|
6411
6587
|
_ts_metadata("design:returntype", void 0)
|
|
6412
6588
|
], InputValidator.prototype, "makeTypedJsonFilterSchema", null);
|
|
@@ -6414,8 +6590,8 @@ _ts_decorate([
|
|
|
6414
6590
|
cache(),
|
|
6415
6591
|
_ts_metadata("design:type", Function),
|
|
6416
6592
|
_ts_metadata("design:paramtypes", [
|
|
6417
|
-
|
|
6418
|
-
|
|
6593
|
+
Object,
|
|
6594
|
+
typeof FieldInfo === "undefined" ? Object : FieldInfo,
|
|
6419
6595
|
Boolean,
|
|
6420
6596
|
Boolean
|
|
6421
6597
|
]),
|
|
@@ -6425,7 +6601,8 @@ _ts_decorate([
|
|
|
6425
6601
|
cache(),
|
|
6426
6602
|
_ts_metadata("design:type", Function),
|
|
6427
6603
|
_ts_metadata("design:paramtypes", [
|
|
6428
|
-
|
|
6604
|
+
Object,
|
|
6605
|
+
typeof FieldInfo === "undefined" ? Object : FieldInfo
|
|
6429
6606
|
]),
|
|
6430
6607
|
_ts_metadata("design:returntype", void 0)
|
|
6431
6608
|
], InputValidator.prototype, "makeArrayFilterSchema", null);
|
|
@@ -6433,9 +6610,10 @@ _ts_decorate([
|
|
|
6433
6610
|
cache(),
|
|
6434
6611
|
_ts_metadata("design:type", Function),
|
|
6435
6612
|
_ts_metadata("design:paramtypes", [
|
|
6436
|
-
|
|
6613
|
+
Object,
|
|
6614
|
+
typeof FieldInfo === "undefined" ? Object : FieldInfo,
|
|
6437
6615
|
Boolean,
|
|
6438
|
-
|
|
6616
|
+
void 0
|
|
6439
6617
|
]),
|
|
6440
6618
|
_ts_metadata("design:returntype", void 0)
|
|
6441
6619
|
], InputValidator.prototype, "makePrimitiveFilterSchema", null);
|
|
@@ -6443,6 +6621,8 @@ _ts_decorate([
|
|
|
6443
6621
|
cache(),
|
|
6444
6622
|
_ts_metadata("design:type", Function),
|
|
6445
6623
|
_ts_metadata("design:paramtypes", [
|
|
6624
|
+
Object,
|
|
6625
|
+
String,
|
|
6446
6626
|
Boolean
|
|
6447
6627
|
]),
|
|
6448
6628
|
_ts_metadata("design:returntype", void 0)
|
|
@@ -6452,7 +6632,8 @@ _ts_decorate([
|
|
|
6452
6632
|
_ts_metadata("design:type", Function),
|
|
6453
6633
|
_ts_metadata("design:paramtypes", [
|
|
6454
6634
|
Boolean,
|
|
6455
|
-
Boolean
|
|
6635
|
+
Boolean,
|
|
6636
|
+
Object
|
|
6456
6637
|
]),
|
|
6457
6638
|
_ts_metadata("design:returntype", typeof import_zod2.ZodType === "undefined" ? Object : import_zod2.ZodType)
|
|
6458
6639
|
], InputValidator.prototype, "makeDateTimeFilterSchema", null);
|
|
@@ -6461,7 +6642,8 @@ _ts_decorate([
|
|
|
6461
6642
|
_ts_metadata("design:type", Function),
|
|
6462
6643
|
_ts_metadata("design:paramtypes", [
|
|
6463
6644
|
Boolean,
|
|
6464
|
-
Boolean
|
|
6645
|
+
Boolean,
|
|
6646
|
+
Object
|
|
6465
6647
|
]),
|
|
6466
6648
|
_ts_metadata("design:returntype", typeof import_zod2.ZodType === "undefined" ? Object : import_zod2.ZodType)
|
|
6467
6649
|
], InputValidator.prototype, "makeBooleanFilterSchema", null);
|
|
@@ -6470,7 +6652,8 @@ _ts_decorate([
|
|
|
6470
6652
|
_ts_metadata("design:type", Function),
|
|
6471
6653
|
_ts_metadata("design:paramtypes", [
|
|
6472
6654
|
Boolean,
|
|
6473
|
-
Boolean
|
|
6655
|
+
Boolean,
|
|
6656
|
+
Object
|
|
6474
6657
|
]),
|
|
6475
6658
|
_ts_metadata("design:returntype", typeof import_zod2.ZodType === "undefined" ? Object : import_zod2.ZodType)
|
|
6476
6659
|
], InputValidator.prototype, "makeBytesFilterSchema", null);
|
|
@@ -8744,6 +8927,9 @@ var ClientImpl = class _ClientImpl {
|
|
|
8744
8927
|
}
|
|
8745
8928
|
get $procs() {
|
|
8746
8929
|
return Object.keys(this.$schema.procedures ?? {}).reduce((acc, name) => {
|
|
8930
|
+
if (!isProcedureIncluded(this.$options, name)) {
|
|
8931
|
+
return acc;
|
|
8932
|
+
}
|
|
8747
8933
|
acc[name] = (input) => this.handleProc(name, input);
|
|
8748
8934
|
return acc;
|
|
8749
8935
|
}, {});
|
|
@@ -8913,6 +9099,9 @@ function createClientProxy(client) {
|
|
|
8913
9099
|
if (typeof prop === "string") {
|
|
8914
9100
|
const model = Object.keys(client.$schema.models).find((m) => m.toLowerCase() === prop.toLowerCase());
|
|
8915
9101
|
if (model) {
|
|
9102
|
+
if (!isModelIncluded(client.$options, model)) {
|
|
9103
|
+
return void 0;
|
|
9104
|
+
}
|
|
8916
9105
|
return createModelCrudHandler(client, model, client.inputValidator, resultProcessor);
|
|
8917
9106
|
}
|
|
8918
9107
|
}
|
|
@@ -8921,6 +9110,44 @@ function createClientProxy(client) {
|
|
|
8921
9110
|
});
|
|
8922
9111
|
}
|
|
8923
9112
|
__name(createClientProxy, "createClientProxy");
|
|
9113
|
+
function isModelIncluded(options, model) {
|
|
9114
|
+
const slicing = options.slicing;
|
|
9115
|
+
if (!slicing) {
|
|
9116
|
+
return true;
|
|
9117
|
+
}
|
|
9118
|
+
const { includedModels, excludedModels } = slicing;
|
|
9119
|
+
if (includedModels !== void 0) {
|
|
9120
|
+
if (!includedModels.includes(model)) {
|
|
9121
|
+
return false;
|
|
9122
|
+
}
|
|
9123
|
+
}
|
|
9124
|
+
if (excludedModels && excludedModels.length > 0) {
|
|
9125
|
+
if (excludedModels.includes(model)) {
|
|
9126
|
+
return false;
|
|
9127
|
+
}
|
|
9128
|
+
}
|
|
9129
|
+
return true;
|
|
9130
|
+
}
|
|
9131
|
+
__name(isModelIncluded, "isModelIncluded");
|
|
9132
|
+
function isProcedureIncluded(options, procedureName) {
|
|
9133
|
+
const slicing = options.slicing;
|
|
9134
|
+
if (!slicing) {
|
|
9135
|
+
return true;
|
|
9136
|
+
}
|
|
9137
|
+
const { includedProcedures, excludedProcedures } = slicing;
|
|
9138
|
+
if (includedProcedures !== void 0) {
|
|
9139
|
+
if (!includedProcedures.includes(procedureName)) {
|
|
9140
|
+
return false;
|
|
9141
|
+
}
|
|
9142
|
+
}
|
|
9143
|
+
if (excludedProcedures && excludedProcedures.length > 0) {
|
|
9144
|
+
if (excludedProcedures.includes(procedureName)) {
|
|
9145
|
+
return false;
|
|
9146
|
+
}
|
|
9147
|
+
}
|
|
9148
|
+
return true;
|
|
9149
|
+
}
|
|
9150
|
+
__name(isProcedureIncluded, "isProcedureIncluded");
|
|
8924
9151
|
function createModelCrudHandler(client, model, inputValidator, resultProcessor) {
|
|
8925
9152
|
const createPromise = /* @__PURE__ */ __name((operation, nominalOperation, args, handler, postProcess = false, throwIfNoResult = false) => {
|
|
8926
9153
|
return createZenStackPromise(async (txClient) => {
|
|
@@ -8962,7 +9189,7 @@ function createModelCrudHandler(client, model, inputValidator, resultProcessor)
|
|
|
8962
9189
|
return proceed(args);
|
|
8963
9190
|
});
|
|
8964
9191
|
}, "createPromise");
|
|
8965
|
-
|
|
9192
|
+
const operations = {
|
|
8966
9193
|
findUnique: /* @__PURE__ */ __name((args) => {
|
|
8967
9194
|
return createPromise("findUnique", "findUnique", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
8968
9195
|
}, "findUnique"),
|
|
@@ -9024,6 +9251,26 @@ function createModelCrudHandler(client, model, inputValidator, resultProcessor)
|
|
|
9024
9251
|
return createPromise("exists", "exists", args, new ExistsOperationHandler(client, model, inputValidator), false);
|
|
9025
9252
|
}, "exists")
|
|
9026
9253
|
};
|
|
9254
|
+
const slicing = client.$options.slicing;
|
|
9255
|
+
if (slicing?.models) {
|
|
9256
|
+
const modelSlicing = slicing.models[model];
|
|
9257
|
+
const allSlicing = slicing.models.$all;
|
|
9258
|
+
const includedOperations = modelSlicing?.includedOperations ?? allSlicing?.includedOperations;
|
|
9259
|
+
const excludedOperations = modelSlicing?.excludedOperations ?? allSlicing?.excludedOperations;
|
|
9260
|
+
if (includedOperations !== void 0) {
|
|
9261
|
+
for (const key of Object.keys(operations)) {
|
|
9262
|
+
if (!includedOperations.includes(key)) {
|
|
9263
|
+
delete operations[key];
|
|
9264
|
+
}
|
|
9265
|
+
}
|
|
9266
|
+
}
|
|
9267
|
+
if (excludedOperations && excludedOperations.length > 0) {
|
|
9268
|
+
for (const operation of excludedOperations) {
|
|
9269
|
+
delete operations[operation];
|
|
9270
|
+
}
|
|
9271
|
+
}
|
|
9272
|
+
}
|
|
9273
|
+
return operations;
|
|
9027
9274
|
}
|
|
9028
9275
|
__name(createModelCrudHandler, "createModelCrudHandler");
|
|
9029
9276
|
|