@zenstackhq/runtime 3.0.0-alpha.26 → 3.0.0-alpha.28
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-BF6mvhVn.d.cts → contract-cndmlzV3.d.cts} +15 -17
- package/dist/{contract-BF6mvhVn.d.ts → contract-cndmlzV3.d.ts} +15 -17
- package/dist/index.cjs +111 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +111 -156
- package/dist/index.js.map +1 -1
- package/dist/plugins/policy/index.cjs +59 -24
- package/dist/plugins/policy/index.cjs.map +1 -1
- package/dist/plugins/policy/index.d.cts +1 -1
- package/dist/plugins/policy/index.d.ts +1 -1
- package/dist/plugins/policy/index.js +59 -24
- package/dist/plugins/policy/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -201,12 +201,6 @@ type SelectIncludeOmit<Schema extends SchemaDef, Model extends GetModels<Schema>
|
|
|
201
201
|
include?: IncludeInput<Schema, Model>;
|
|
202
202
|
omit?: OmitInput<Schema, Model>;
|
|
203
203
|
};
|
|
204
|
-
type Distinct<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
205
|
-
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
206
|
-
};
|
|
207
|
-
type Cursor<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
208
|
-
cursor?: WhereUniqueInput<Schema, Model>;
|
|
209
|
-
};
|
|
210
204
|
type SelectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean = true, AllowRelation extends boolean = true> = {
|
|
211
205
|
[Key in NonRelationFields<Schema, Model>]?: true;
|
|
212
206
|
} & (AllowRelation extends true ? IncludeInput<Schema, Model> : {}) & // relation fields
|
|
@@ -255,13 +249,18 @@ type GetRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Fiel
|
|
|
255
249
|
type OppositeRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>> = FT extends GetModels<Schema> ? GetRelation<Schema, Model, Field> extends RelationInfo ? GetRelation<Schema, Model, Field>['opposite'] extends GetModelFields<Schema, FT> ? Schema['models'][FT]['fields'][GetRelation<Schema, Model, Field>['opposite']]['relation'] : never : never : never;
|
|
256
250
|
type OppositeRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Opposite = OppositeRelation<Schema, Model, Field>> = Opposite extends RelationInfo ? (Opposite['fields'] extends string[] ? Opposite['fields'] : []) : [];
|
|
257
251
|
type OppositeRelationAndFK<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>, Relation = GetModelField<Schema, Model, Field>['relation'], Opposite = Relation extends RelationInfo ? Relation['opposite'] : never> = FT extends GetModels<Schema> ? Opposite extends GetModelFields<Schema, FT> ? Opposite | OppositeRelationFields<Schema, Model, Field>[number] : never : never;
|
|
258
|
-
type
|
|
252
|
+
type FilterArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
253
|
+
where?: WhereInput<Schema, Model>;
|
|
254
|
+
};
|
|
255
|
+
type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
259
256
|
skip?: number;
|
|
260
257
|
take?: number;
|
|
261
258
|
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
cursor?: WhereUniqueInput<Schema, Model>;
|
|
260
|
+
};
|
|
261
|
+
type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Collection extends boolean, AllowFilter extends boolean = true> = ProviderSupportsDistinct<Schema> extends true ? (Collection extends true ? SortAndTakeArgs<Schema, Model> & {
|
|
262
|
+
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
263
|
+
} : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection> : (Collection extends true ? SortAndTakeArgs<Schema, Model> : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection>;
|
|
265
264
|
type FindManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
|
|
266
265
|
type FindFirstArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, false>;
|
|
267
266
|
type FindUniqueArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
@@ -513,7 +512,8 @@ type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Sc
|
|
|
513
512
|
type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
514
513
|
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: true;
|
|
515
514
|
} extends never ? false : true;
|
|
516
|
-
type ProviderSupportsCaseSensitivity<Schema extends SchemaDef> = Schema['provider'] extends 'postgresql' ? true : false;
|
|
515
|
+
type ProviderSupportsCaseSensitivity<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
516
|
+
type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
517
517
|
|
|
518
518
|
type AuthType<Schema extends SchemaDef> = string extends GetModels<Schema> ? Record<string, unknown> : Schema['authType'] extends GetModels<Schema> ? Partial<ModelResult<Schema, Schema['authType']>> : never;
|
|
519
519
|
|
|
@@ -532,7 +532,9 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
532
532
|
constructor(schema: Schema, options: ClientOptions<Schema>);
|
|
533
533
|
transformPrimitive(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
534
534
|
buildSelectModel(eb: ExpressionBuilder<any, any>, model: string): SelectQueryBuilder<any, any, {}>;
|
|
535
|
+
buildFilterSortTake(model: GetModels<Schema>, args: FindArgs<Schema, GetModels<Schema>, true>, query: SelectQueryBuilder<any, any, {}>): SelectQueryBuilder<any, any, {}>;
|
|
535
536
|
buildFilter(eb: ExpressionBuilder<any, any>, model: string, modelAlias: string, where: boolean | object | undefined): Expression<SqlBool>;
|
|
537
|
+
private buildCursorFilter;
|
|
536
538
|
private isLogicalCombinator;
|
|
537
539
|
protected buildCompositeFilter(eb: ExpressionBuilder<any, any>, model: string, modelAlias: string, key: (typeof LOGICAL_COMBINATORS)[number], payload: any): Expression<SqlBool>;
|
|
538
540
|
private buildRelationFilter;
|
|
@@ -602,8 +604,8 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
602
604
|
abstract get supportInsertWithDefault(): boolean;
|
|
603
605
|
}
|
|
604
606
|
|
|
605
|
-
type
|
|
606
|
-
type AllCrudOperation =
|
|
607
|
+
type CoreCrudOperation = 'findMany' | 'findUnique' | 'findFirst' | 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
608
|
+
type AllCrudOperation = CoreCrudOperation | 'findUniqueOrThrow' | 'findFirstOrThrow';
|
|
607
609
|
|
|
608
610
|
/**
|
|
609
611
|
* ZenStack runtime plugin.
|
|
@@ -775,10 +777,6 @@ type ClientOptions<Schema extends SchemaDef> = {
|
|
|
775
777
|
* Logging configuration.
|
|
776
778
|
*/
|
|
777
779
|
log?: KyselyConfig['log'];
|
|
778
|
-
/**
|
|
779
|
-
* Debug mode.
|
|
780
|
-
*/
|
|
781
|
-
debug?: boolean;
|
|
782
780
|
} & (HasComputedFields<Schema> extends true ? {
|
|
783
781
|
/**
|
|
784
782
|
* Computed field definitions.
|
|
@@ -201,12 +201,6 @@ type SelectIncludeOmit<Schema extends SchemaDef, Model extends GetModels<Schema>
|
|
|
201
201
|
include?: IncludeInput<Schema, Model>;
|
|
202
202
|
omit?: OmitInput<Schema, Model>;
|
|
203
203
|
};
|
|
204
|
-
type Distinct<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
205
|
-
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
206
|
-
};
|
|
207
|
-
type Cursor<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
208
|
-
cursor?: WhereUniqueInput<Schema, Model>;
|
|
209
|
-
};
|
|
210
204
|
type SelectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean = true, AllowRelation extends boolean = true> = {
|
|
211
205
|
[Key in NonRelationFields<Schema, Model>]?: true;
|
|
212
206
|
} & (AllowRelation extends true ? IncludeInput<Schema, Model> : {}) & // relation fields
|
|
@@ -255,13 +249,18 @@ type GetRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Fiel
|
|
|
255
249
|
type OppositeRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>> = FT extends GetModels<Schema> ? GetRelation<Schema, Model, Field> extends RelationInfo ? GetRelation<Schema, Model, Field>['opposite'] extends GetModelFields<Schema, FT> ? Schema['models'][FT]['fields'][GetRelation<Schema, Model, Field>['opposite']]['relation'] : never : never : never;
|
|
256
250
|
type OppositeRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Opposite = OppositeRelation<Schema, Model, Field>> = Opposite extends RelationInfo ? (Opposite['fields'] extends string[] ? Opposite['fields'] : []) : [];
|
|
257
251
|
type OppositeRelationAndFK<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>, Relation = GetModelField<Schema, Model, Field>['relation'], Opposite = Relation extends RelationInfo ? Relation['opposite'] : never> = FT extends GetModels<Schema> ? Opposite extends GetModelFields<Schema, FT> ? Opposite | OppositeRelationFields<Schema, Model, Field>[number] : never : never;
|
|
258
|
-
type
|
|
252
|
+
type FilterArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
253
|
+
where?: WhereInput<Schema, Model>;
|
|
254
|
+
};
|
|
255
|
+
type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
259
256
|
skip?: number;
|
|
260
257
|
take?: number;
|
|
261
258
|
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
cursor?: WhereUniqueInput<Schema, Model>;
|
|
260
|
+
};
|
|
261
|
+
type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Collection extends boolean, AllowFilter extends boolean = true> = ProviderSupportsDistinct<Schema> extends true ? (Collection extends true ? SortAndTakeArgs<Schema, Model> & {
|
|
262
|
+
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
263
|
+
} : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection> : (Collection extends true ? SortAndTakeArgs<Schema, Model> : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection>;
|
|
265
264
|
type FindManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
|
|
266
265
|
type FindFirstArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, false>;
|
|
267
266
|
type FindUniqueArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
@@ -513,7 +512,8 @@ type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Sc
|
|
|
513
512
|
type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
514
513
|
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: true;
|
|
515
514
|
} extends never ? false : true;
|
|
516
|
-
type ProviderSupportsCaseSensitivity<Schema extends SchemaDef> = Schema['provider'] extends 'postgresql' ? true : false;
|
|
515
|
+
type ProviderSupportsCaseSensitivity<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
516
|
+
type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
517
517
|
|
|
518
518
|
type AuthType<Schema extends SchemaDef> = string extends GetModels<Schema> ? Record<string, unknown> : Schema['authType'] extends GetModels<Schema> ? Partial<ModelResult<Schema, Schema['authType']>> : never;
|
|
519
519
|
|
|
@@ -532,7 +532,9 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
532
532
|
constructor(schema: Schema, options: ClientOptions<Schema>);
|
|
533
533
|
transformPrimitive(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
534
534
|
buildSelectModel(eb: ExpressionBuilder<any, any>, model: string): SelectQueryBuilder<any, any, {}>;
|
|
535
|
+
buildFilterSortTake(model: GetModels<Schema>, args: FindArgs<Schema, GetModels<Schema>, true>, query: SelectQueryBuilder<any, any, {}>): SelectQueryBuilder<any, any, {}>;
|
|
535
536
|
buildFilter(eb: ExpressionBuilder<any, any>, model: string, modelAlias: string, where: boolean | object | undefined): Expression<SqlBool>;
|
|
537
|
+
private buildCursorFilter;
|
|
536
538
|
private isLogicalCombinator;
|
|
537
539
|
protected buildCompositeFilter(eb: ExpressionBuilder<any, any>, model: string, modelAlias: string, key: (typeof LOGICAL_COMBINATORS)[number], payload: any): Expression<SqlBool>;
|
|
538
540
|
private buildRelationFilter;
|
|
@@ -602,8 +604,8 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
602
604
|
abstract get supportInsertWithDefault(): boolean;
|
|
603
605
|
}
|
|
604
606
|
|
|
605
|
-
type
|
|
606
|
-
type AllCrudOperation =
|
|
607
|
+
type CoreCrudOperation = 'findMany' | 'findUnique' | 'findFirst' | 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy';
|
|
608
|
+
type AllCrudOperation = CoreCrudOperation | 'findUniqueOrThrow' | 'findFirstOrThrow';
|
|
607
609
|
|
|
608
610
|
/**
|
|
609
611
|
* ZenStack runtime plugin.
|
|
@@ -775,10 +777,6 @@ type ClientOptions<Schema extends SchemaDef> = {
|
|
|
775
777
|
* Logging configuration.
|
|
776
778
|
*/
|
|
777
779
|
log?: KyselyConfig['log'];
|
|
778
|
-
/**
|
|
779
|
-
* Debug mode.
|
|
780
|
-
*/
|
|
781
|
-
debug?: boolean;
|
|
782
780
|
} & (HasComputedFields<Schema> extends true ? {
|
|
783
781
|
/**
|
|
784
782
|
* Computed field definitions.
|
package/dist/index.cjs
CHANGED
|
@@ -414,16 +414,6 @@ function ensureArray(value) {
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
__name(ensureArray, "ensureArray");
|
|
417
|
-
function safeJSONStringify(value) {
|
|
418
|
-
return JSON.stringify(value, (_, v) => {
|
|
419
|
-
if (typeof v === "bigint") {
|
|
420
|
-
return v.toString();
|
|
421
|
-
} else {
|
|
422
|
-
return v;
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
__name(safeJSONStringify, "safeJSONStringify");
|
|
427
417
|
function extractIdFields(entity, schema, model) {
|
|
428
418
|
const idFields = getIdFields(schema, model);
|
|
429
419
|
return extractFields(entity, idFields);
|
|
@@ -465,7 +455,6 @@ var import_cuid2 = require("@paralleldrive/cuid2");
|
|
|
465
455
|
var import_common_helpers8 = require("@zenstackhq/common-helpers");
|
|
466
456
|
var import_kysely8 = require("kysely");
|
|
467
457
|
var import_nanoid = require("nanoid");
|
|
468
|
-
var import_node_util = require("util");
|
|
469
458
|
var import_ts_pattern9 = require("ts-pattern");
|
|
470
459
|
var import_ulid = require("ulid");
|
|
471
460
|
var uuid = __toESM(require("uuid"), 1);
|
|
@@ -560,6 +549,33 @@ var BaseCrudDialect = class {
|
|
|
560
549
|
}
|
|
561
550
|
return result;
|
|
562
551
|
}
|
|
552
|
+
buildFilterSortTake(model, args, query) {
|
|
553
|
+
let result = query;
|
|
554
|
+
if (args.where) {
|
|
555
|
+
result = result.where((eb) => this.buildFilter(eb, model, model, args?.where));
|
|
556
|
+
}
|
|
557
|
+
let negateOrderBy = false;
|
|
558
|
+
const skip = args.skip;
|
|
559
|
+
let take = args.take;
|
|
560
|
+
if (take !== void 0 && take < 0) {
|
|
561
|
+
negateOrderBy = true;
|
|
562
|
+
take = -take;
|
|
563
|
+
}
|
|
564
|
+
result = this.buildSkipTake(result, skip, take);
|
|
565
|
+
result = this.buildOrderBy(result, model, model, args.orderBy, skip !== void 0 || take !== void 0, negateOrderBy);
|
|
566
|
+
if ("distinct" in args && args.distinct) {
|
|
567
|
+
const distinct = ensureArray(args.distinct);
|
|
568
|
+
if (this.supportsDistinctOn) {
|
|
569
|
+
result = result.distinctOn(distinct.map((f) => import_kysely.sql.ref(`${model}.${f}`)));
|
|
570
|
+
} else {
|
|
571
|
+
throw new QueryError(`"distinct" is not supported by "${this.schema.provider.type}" provider`);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (args.cursor) {
|
|
575
|
+
result = this.buildCursorFilter(model, result, args.cursor, args.orderBy, negateOrderBy);
|
|
576
|
+
}
|
|
577
|
+
return result;
|
|
578
|
+
}
|
|
563
579
|
buildFilter(eb, model, modelAlias, where) {
|
|
564
580
|
if (where === true || where === void 0) {
|
|
565
581
|
return this.true(eb);
|
|
@@ -597,6 +613,26 @@ var BaseCrudDialect = class {
|
|
|
597
613
|
}
|
|
598
614
|
return result;
|
|
599
615
|
}
|
|
616
|
+
buildCursorFilter(model, query, cursor, orderBy, negateOrderBy) {
|
|
617
|
+
const _orderBy = orderBy ?? makeDefaultOrderBy(this.schema, model);
|
|
618
|
+
const orderByItems = ensureArray(_orderBy).flatMap((obj) => Object.entries(obj));
|
|
619
|
+
const eb = (0, import_kysely.expressionBuilder)();
|
|
620
|
+
const cursorFilter = this.buildFilter(eb, model, model, cursor);
|
|
621
|
+
let result = query;
|
|
622
|
+
const filters = [];
|
|
623
|
+
for (let i = orderByItems.length - 1; i >= 0; i--) {
|
|
624
|
+
const andFilters = [];
|
|
625
|
+
for (let j = 0; j <= i; j++) {
|
|
626
|
+
const [field, order] = orderByItems[j];
|
|
627
|
+
const _order = negateOrderBy ? order === "asc" ? "desc" : "asc" : order;
|
|
628
|
+
const op = j === i ? _order === "asc" ? ">=" : "<=" : "=";
|
|
629
|
+
andFilters.push(eb(eb.ref(`${model}.${field}`), op, eb.selectFrom(model).select(`${model}.${field}`).where(cursorFilter)));
|
|
630
|
+
}
|
|
631
|
+
filters.push(eb.and(andFilters));
|
|
632
|
+
}
|
|
633
|
+
result = result.where((eb2) => eb2.or(filters));
|
|
634
|
+
return result;
|
|
635
|
+
}
|
|
600
636
|
isLogicalCombinator(key) {
|
|
601
637
|
return LOGICAL_COMBINATORS.includes(key);
|
|
602
638
|
}
|
|
@@ -1123,18 +1159,7 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
|
|
|
1123
1159
|
let subQuery = this.buildSelectModel(eb, relationModel);
|
|
1124
1160
|
subQuery = this.buildSelectAllFields(relationModel, subQuery, typeof payload === "object" ? payload?.omit : void 0);
|
|
1125
1161
|
if (payload && typeof payload === "object") {
|
|
1126
|
-
|
|
1127
|
-
subQuery = subQuery.where((eb2) => this.buildFilter(eb2, relationModel, relationModel, payload.where));
|
|
1128
|
-
}
|
|
1129
|
-
const skip = payload.skip;
|
|
1130
|
-
let take = payload.take;
|
|
1131
|
-
let negateOrderBy = false;
|
|
1132
|
-
if (take !== void 0 && take < 0) {
|
|
1133
|
-
negateOrderBy = true;
|
|
1134
|
-
take = -take;
|
|
1135
|
-
}
|
|
1136
|
-
subQuery = this.buildSkipTake(subQuery, skip, take);
|
|
1137
|
-
subQuery = this.buildOrderBy(subQuery, relationModel, relationModel, payload.orderBy, skip !== void 0 || take !== void 0, negateOrderBy);
|
|
1162
|
+
subQuery = this.buildFilterSortTake(relationModel, payload, subQuery);
|
|
1138
1163
|
}
|
|
1139
1164
|
const m2m = getManyToManyRelation(this.schema, model, relationField);
|
|
1140
1165
|
if (m2m) {
|
|
@@ -1297,18 +1322,7 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
|
|
|
1297
1322
|
let subQuery = this.buildSelectModel(eb, relationModel);
|
|
1298
1323
|
subQuery = this.buildSelectAllFields(relationModel, subQuery, typeof payload === "object" ? payload?.omit : void 0);
|
|
1299
1324
|
if (payload && typeof payload === "object") {
|
|
1300
|
-
|
|
1301
|
-
subQuery = subQuery.where((eb2) => this.buildFilter(eb2, relationModel, relationModel, payload.where));
|
|
1302
|
-
}
|
|
1303
|
-
const skip = payload.skip;
|
|
1304
|
-
let take = payload.take;
|
|
1305
|
-
let negateOrderBy = false;
|
|
1306
|
-
if (take !== void 0 && take < 0) {
|
|
1307
|
-
negateOrderBy = true;
|
|
1308
|
-
take = -take;
|
|
1309
|
-
}
|
|
1310
|
-
subQuery = this.buildSkipTake(subQuery, skip, take);
|
|
1311
|
-
subQuery = this.buildOrderBy(subQuery, relationModel, relationModel, payload.orderBy, skip !== void 0 || take !== void 0, negateOrderBy);
|
|
1325
|
+
subQuery = this.buildFilterSortTake(relationModel, payload, subQuery);
|
|
1312
1326
|
}
|
|
1313
1327
|
const m2m = getManyToManyRelation(this.schema, model, relationField);
|
|
1314
1328
|
if (m2m) {
|
|
@@ -2750,27 +2764,8 @@ var BaseOperationHandler = class {
|
|
|
2750
2764
|
}
|
|
2751
2765
|
async read(kysely, model, args) {
|
|
2752
2766
|
let query = this.dialect.buildSelectModel((0, import_kysely8.expressionBuilder)(), model);
|
|
2753
|
-
if (args
|
|
2754
|
-
query =
|
|
2755
|
-
}
|
|
2756
|
-
let negateOrderBy = false;
|
|
2757
|
-
const skip = args?.skip;
|
|
2758
|
-
let take = args?.take;
|
|
2759
|
-
if (take !== void 0 && take < 0) {
|
|
2760
|
-
negateOrderBy = true;
|
|
2761
|
-
take = -take;
|
|
2762
|
-
}
|
|
2763
|
-
query = this.dialect.buildSkipTake(query, skip, take);
|
|
2764
|
-
query = this.dialect.buildOrderBy(query, model, model, args?.orderBy, skip !== void 0 || take !== void 0, negateOrderBy);
|
|
2765
|
-
let inMemoryDistinct = void 0;
|
|
2766
|
-
if (args?.distinct) {
|
|
2767
|
-
const distinct = ensureArray(args.distinct);
|
|
2768
|
-
if (this.dialect.supportsDistinctOn) {
|
|
2769
|
-
query = query.distinctOn(distinct.map((f) => import_kysely8.sql.ref(`${model}.${f}`)));
|
|
2770
|
-
} else {
|
|
2771
|
-
inMemoryDistinct = distinct;
|
|
2772
|
-
query = distinct.reduce((acc, field) => acc.select((eb) => this.dialect.fieldRef(model, field, eb).as(`$distinct$${field}`)), query);
|
|
2773
|
-
}
|
|
2767
|
+
if (args) {
|
|
2768
|
+
query = this.dialect.buildFilterSortTake(model, args, query);
|
|
2774
2769
|
}
|
|
2775
2770
|
if (args && "select" in args && args.select) {
|
|
2776
2771
|
query = this.buildFieldSelection(model, query, args.select, model);
|
|
@@ -2780,9 +2775,6 @@ var BaseOperationHandler = class {
|
|
|
2780
2775
|
if (args && "include" in args && args.include) {
|
|
2781
2776
|
query = this.buildFieldSelection(model, query, args.include, model);
|
|
2782
2777
|
}
|
|
2783
|
-
if (args?.cursor) {
|
|
2784
|
-
query = this.buildCursorFilter(model, query, args.cursor, args.orderBy, negateOrderBy);
|
|
2785
|
-
}
|
|
2786
2778
|
query = query.modifyEnd(this.makeContextComment({
|
|
2787
2779
|
model,
|
|
2788
2780
|
operation: "read"
|
|
@@ -2796,28 +2788,9 @@ var BaseOperationHandler = class {
|
|
|
2796
2788
|
const r = await kysely.getExecutor().executeQuery(compiled, queryId);
|
|
2797
2789
|
result = r.rows;
|
|
2798
2790
|
} catch (err) {
|
|
2799
|
-
|
|
2800
|
-
if (this.options.debug) {
|
|
2801
|
-
message += `, parameters:
|
|
2802
|
-
${compiled.parameters.map((p) => (0, import_node_util.inspect)(p)).join("\n")}`;
|
|
2803
|
-
}
|
|
2791
|
+
const message = `Failed to execute query: ${err}, sql: ${compiled.sql}`;
|
|
2804
2792
|
throw new QueryError(message, err);
|
|
2805
2793
|
}
|
|
2806
|
-
if (inMemoryDistinct) {
|
|
2807
|
-
const distinctResult = [];
|
|
2808
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2809
|
-
for (const r of result) {
|
|
2810
|
-
const key = safeJSONStringify(inMemoryDistinct.map((f) => r[`$distinct$${f}`]));
|
|
2811
|
-
if (!seen.has(key)) {
|
|
2812
|
-
distinctResult.push(r);
|
|
2813
|
-
seen.add(key);
|
|
2814
|
-
}
|
|
2815
|
-
}
|
|
2816
|
-
result = distinctResult;
|
|
2817
|
-
for (const r of result) {
|
|
2818
|
-
Object.keys(r).filter((k) => k.startsWith("$distinct$")).forEach((k) => delete r[k]);
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
2794
|
return result;
|
|
2822
2795
|
}
|
|
2823
2796
|
async readUnique(kysely, model, args) {
|
|
@@ -2856,28 +2829,6 @@ ${compiled.parameters.map((p) => (0, import_node_util.inspect)(p)).join("\n")}`;
|
|
|
2856
2829
|
buildCountSelection(query, model, parentAlias, payload) {
|
|
2857
2830
|
return query.select((eb) => this.dialect.buildCountJson(model, eb, parentAlias, payload).as("_count"));
|
|
2858
2831
|
}
|
|
2859
|
-
buildCursorFilter(model, query, cursor, orderBy, negateOrderBy) {
|
|
2860
|
-
if (!orderBy) {
|
|
2861
|
-
orderBy = makeDefaultOrderBy(this.schema, model);
|
|
2862
|
-
}
|
|
2863
|
-
const orderByItems = ensureArray(orderBy).flatMap((obj) => Object.entries(obj));
|
|
2864
|
-
const eb = (0, import_kysely8.expressionBuilder)();
|
|
2865
|
-
const cursorFilter = this.dialect.buildFilter(eb, model, model, cursor);
|
|
2866
|
-
let result = query;
|
|
2867
|
-
const filters = [];
|
|
2868
|
-
for (let i = orderByItems.length - 1; i >= 0; i--) {
|
|
2869
|
-
const andFilters = [];
|
|
2870
|
-
for (let j = 0; j <= i; j++) {
|
|
2871
|
-
const [field, order] = orderByItems[j];
|
|
2872
|
-
const _order = negateOrderBy ? order === "asc" ? "desc" : "asc" : order;
|
|
2873
|
-
const op = j === i ? _order === "asc" ? ">=" : "<=" : "=";
|
|
2874
|
-
andFilters.push(eb(eb.ref(`${model}.${field}`), op, eb.selectFrom(model).select(`${model}.${field}`).where(cursorFilter)));
|
|
2875
|
-
}
|
|
2876
|
-
filters.push(eb.and(andFilters));
|
|
2877
|
-
}
|
|
2878
|
-
result = result.where((eb2) => eb2.or(filters));
|
|
2879
|
-
return result;
|
|
2880
|
-
}
|
|
2881
2832
|
async create(kysely, model, data, fromRelation, creatingForDelegate = false) {
|
|
2882
2833
|
const modelDef = this.requireModel(model);
|
|
2883
2834
|
if (modelDef.isDelegate && !creatingForDelegate) {
|
|
@@ -4910,25 +4861,28 @@ var InputValidator = class {
|
|
|
4910
4861
|
return import_zod.z.strictObject(fields);
|
|
4911
4862
|
}
|
|
4912
4863
|
makeRelationSelectIncludeSchema(fieldDef) {
|
|
4864
|
+
let objSchema = import_zod.z.strictObject({
|
|
4865
|
+
...fieldDef.array || fieldDef.optional ? {
|
|
4866
|
+
// to-many relations and optional to-one relations are filterable
|
|
4867
|
+
where: import_zod.z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional()
|
|
4868
|
+
} : {},
|
|
4869
|
+
select: import_zod.z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
|
|
4870
|
+
include: import_zod.z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional(),
|
|
4871
|
+
omit: import_zod.z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional(),
|
|
4872
|
+
...fieldDef.array ? {
|
|
4873
|
+
// to-many relations can be ordered, skipped, taken, and cursor-located
|
|
4874
|
+
orderBy: import_zod.z.lazy(() => this.makeOrderBySchema(fieldDef.type, true, false)).optional(),
|
|
4875
|
+
skip: this.makeSkipSchema().optional(),
|
|
4876
|
+
take: this.makeTakeSchema().optional(),
|
|
4877
|
+
cursor: this.makeCursorSchema(fieldDef.type).optional(),
|
|
4878
|
+
distinct: this.makeDistinctSchema(fieldDef.type).optional()
|
|
4879
|
+
} : {}
|
|
4880
|
+
});
|
|
4881
|
+
objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
|
|
4882
|
+
objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
|
|
4913
4883
|
return import_zod.z.union([
|
|
4914
4884
|
import_zod.z.boolean(),
|
|
4915
|
-
|
|
4916
|
-
...fieldDef.array || fieldDef.optional ? {
|
|
4917
|
-
// to-many relations and optional to-one relations are filterable
|
|
4918
|
-
where: import_zod.z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional()
|
|
4919
|
-
} : {},
|
|
4920
|
-
select: import_zod.z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
|
|
4921
|
-
include: import_zod.z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional(),
|
|
4922
|
-
omit: import_zod.z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional(),
|
|
4923
|
-
...fieldDef.array ? {
|
|
4924
|
-
// to-many relations can be ordered, skipped, taken, and cursor-located
|
|
4925
|
-
orderBy: import_zod.z.lazy(() => this.makeOrderBySchema(fieldDef.type, true, false)).optional(),
|
|
4926
|
-
skip: this.makeSkipSchema().optional(),
|
|
4927
|
-
take: this.makeTakeSchema().optional(),
|
|
4928
|
-
cursor: this.makeCursorSchema(fieldDef.type).optional(),
|
|
4929
|
-
distinct: this.makeDistinctSchema(fieldDef.type).optional()
|
|
4930
|
-
} : {}
|
|
4931
|
-
})
|
|
4885
|
+
objSchema
|
|
4932
4886
|
]);
|
|
4933
4887
|
}
|
|
4934
4888
|
makeOmitSchema(model) {
|
|
@@ -5017,7 +4971,7 @@ var InputValidator = class {
|
|
|
5017
4971
|
// #region Create
|
|
5018
4972
|
makeCreateSchema(model) {
|
|
5019
4973
|
const dataSchema = this.makeCreateDataSchema(model, false);
|
|
5020
|
-
const schema = import_zod.z.
|
|
4974
|
+
const schema = import_zod.z.strictObject({
|
|
5021
4975
|
data: dataSchema,
|
|
5022
4976
|
select: this.makeSelectSchema(model).optional(),
|
|
5023
4977
|
include: this.makeIncludeSchema(model).optional(),
|
|
@@ -5030,10 +4984,10 @@ var InputValidator = class {
|
|
|
5030
4984
|
}
|
|
5031
4985
|
makeCreateManyAndReturnSchema(model) {
|
|
5032
4986
|
const base = this.makeCreateManyDataSchema(model, []);
|
|
5033
|
-
const result = base.
|
|
4987
|
+
const result = base.extend({
|
|
5034
4988
|
select: this.makeSelectSchema(model).optional(),
|
|
5035
4989
|
omit: this.makeOmitSchema(model).optional()
|
|
5036
|
-
})
|
|
4990
|
+
});
|
|
5037
4991
|
return this.refineForSelectOmitMutuallyExclusive(result).optional();
|
|
5038
4992
|
}
|
|
5039
4993
|
makeCreateDataSchema(model, canBeArray, withoutFields = [], withoutRelationFields = false) {
|
|
@@ -5198,13 +5152,13 @@ var InputValidator = class {
|
|
|
5198
5152
|
makeConnectOrCreateDataSchema(model, canBeArray, withoutFields) {
|
|
5199
5153
|
const whereSchema = this.makeWhereSchema(model, true);
|
|
5200
5154
|
const createSchema = this.makeCreateDataSchema(model, false, withoutFields);
|
|
5201
|
-
return this.orArray(import_zod.z.
|
|
5155
|
+
return this.orArray(import_zod.z.strictObject({
|
|
5202
5156
|
where: whereSchema,
|
|
5203
5157
|
create: createSchema
|
|
5204
5158
|
}), canBeArray);
|
|
5205
5159
|
}
|
|
5206
5160
|
makeCreateManyDataSchema(model, withoutFields) {
|
|
5207
|
-
return import_zod.z.
|
|
5161
|
+
return import_zod.z.strictObject({
|
|
5208
5162
|
data: this.makeCreateDataSchema(model, true, withoutFields, true),
|
|
5209
5163
|
skipDuplicates: import_zod.z.boolean().optional()
|
|
5210
5164
|
});
|
|
@@ -5212,7 +5166,7 @@ var InputValidator = class {
|
|
|
5212
5166
|
// #endregion
|
|
5213
5167
|
// #region Update
|
|
5214
5168
|
makeUpdateSchema(model) {
|
|
5215
|
-
const schema = import_zod.z.
|
|
5169
|
+
const schema = import_zod.z.strictObject({
|
|
5216
5170
|
where: this.makeWhereSchema(model, true),
|
|
5217
5171
|
data: this.makeUpdateDataSchema(model),
|
|
5218
5172
|
select: this.makeSelectSchema(model).optional(),
|
|
@@ -5222,7 +5176,7 @@ var InputValidator = class {
|
|
|
5222
5176
|
return this.refineForSelectIncludeMutuallyExclusive(schema);
|
|
5223
5177
|
}
|
|
5224
5178
|
makeUpdateManySchema(model) {
|
|
5225
|
-
return import_zod.z.
|
|
5179
|
+
return import_zod.z.strictObject({
|
|
5226
5180
|
where: this.makeWhereSchema(model, false).optional(),
|
|
5227
5181
|
data: this.makeUpdateDataSchema(model, [], true),
|
|
5228
5182
|
limit: import_zod.z.int().nonnegative().optional()
|
|
@@ -5230,14 +5184,14 @@ var InputValidator = class {
|
|
|
5230
5184
|
}
|
|
5231
5185
|
makeUpdateManyAndReturnSchema(model) {
|
|
5232
5186
|
const base = this.makeUpdateManySchema(model);
|
|
5233
|
-
const result = base.
|
|
5187
|
+
const result = base.extend({
|
|
5234
5188
|
select: this.makeSelectSchema(model).optional(),
|
|
5235
5189
|
omit: this.makeOmitSchema(model).optional()
|
|
5236
|
-
})
|
|
5190
|
+
});
|
|
5237
5191
|
return this.refineForSelectOmitMutuallyExclusive(result);
|
|
5238
5192
|
}
|
|
5239
5193
|
makeUpsertSchema(model) {
|
|
5240
|
-
const schema = import_zod.z.
|
|
5194
|
+
const schema = import_zod.z.strictObject({
|
|
5241
5195
|
where: this.makeWhereSchema(model, true),
|
|
5242
5196
|
create: this.makeCreateDataSchema(model, false),
|
|
5243
5197
|
update: this.makeUpdateDataSchema(model),
|
|
@@ -5322,7 +5276,7 @@ var InputValidator = class {
|
|
|
5322
5276
|
// #endregion
|
|
5323
5277
|
// #region Delete
|
|
5324
5278
|
makeDeleteSchema(model) {
|
|
5325
|
-
const schema = import_zod.z.
|
|
5279
|
+
const schema = import_zod.z.strictObject({
|
|
5326
5280
|
where: this.makeWhereSchema(model, true),
|
|
5327
5281
|
select: this.makeSelectSchema(model).optional(),
|
|
5328
5282
|
include: this.makeIncludeSchema(model).optional()
|
|
@@ -5350,7 +5304,7 @@ var InputValidator = class {
|
|
|
5350
5304
|
const modelDef = requireModel(this.schema, model);
|
|
5351
5305
|
return import_zod.z.union([
|
|
5352
5306
|
import_zod.z.literal(true),
|
|
5353
|
-
import_zod.z.
|
|
5307
|
+
import_zod.z.strictObject({
|
|
5354
5308
|
_all: import_zod.z.literal(true).optional(),
|
|
5355
5309
|
...Object.keys(modelDef.fields).reduce((acc, field) => {
|
|
5356
5310
|
acc[field] = import_zod.z.literal(true).optional();
|
|
@@ -5397,7 +5351,7 @@ var InputValidator = class {
|
|
|
5397
5351
|
makeGroupBySchema(model) {
|
|
5398
5352
|
const modelDef = requireModel(this.schema, model);
|
|
5399
5353
|
const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation);
|
|
5400
|
-
let schema = import_zod.z.
|
|
5354
|
+
let schema = import_zod.z.strictObject({
|
|
5401
5355
|
where: this.makeWhereSchema(model, false).optional(),
|
|
5402
5356
|
orderBy: this.orArray(this.makeOrderBySchema(model, false, true), true).optional(),
|
|
5403
5357
|
by: this.orArray(import_zod.z.enum(nonRelationFields), true),
|
|
@@ -5674,7 +5628,6 @@ __name(performanceNow, "performanceNow");
|
|
|
5674
5628
|
// src/client/executor/zenstack-query-executor.ts
|
|
5675
5629
|
var import_kysely13 = require("kysely");
|
|
5676
5630
|
var import_nanoid2 = require("nanoid");
|
|
5677
|
-
var import_node_util2 = require("util");
|
|
5678
5631
|
var import_ts_pattern16 = require("ts-pattern");
|
|
5679
5632
|
|
|
5680
5633
|
// src/client/executor/name-mapper.ts
|
|
@@ -5982,11 +5935,7 @@ var ZenStackQueryExecutor = class _ZenStackQueryExecutor extends import_kysely13
|
|
|
5982
5935
|
};
|
|
5983
5936
|
});
|
|
5984
5937
|
} catch (err) {
|
|
5985
|
-
|
|
5986
|
-
if (this.options.debug) {
|
|
5987
|
-
message += `, parameters:
|
|
5988
|
-
${compiled.parameters.map((p) => (0, import_node_util2.inspect)(p)).join("\n")}`;
|
|
5989
|
-
}
|
|
5938
|
+
const message = `Failed to execute query: ${err}, sql: ${compiled.sql}`;
|
|
5990
5939
|
throw new QueryError(message, err);
|
|
5991
5940
|
}
|
|
5992
5941
|
}
|
|
@@ -6443,6 +6392,9 @@ var SchemaDbPusher = class {
|
|
|
6443
6392
|
if (this.isAutoIncrement(fieldDef) && this.schema.provider.type === "postgresql") {
|
|
6444
6393
|
return "serial";
|
|
6445
6394
|
}
|
|
6395
|
+
if (this.isCustomType(fieldDef.type)) {
|
|
6396
|
+
return "jsonb";
|
|
6397
|
+
}
|
|
6446
6398
|
const type = fieldDef.type;
|
|
6447
6399
|
const result = (0, import_ts_pattern18.match)(type).with("String", () => "text").with("Boolean", () => "boolean").with("Int", () => "integer").with("Float", () => "real").with("BigInt", () => "bigint").with("Decimal", () => "decimal").with("DateTime", () => "timestamp").with("Bytes", () => this.schema.provider.type === "postgresql" ? "bytea" : "blob").with("Json", () => "jsonb").otherwise(() => {
|
|
6448
6400
|
throw new Error(`Unsupported field type: ${type}`);
|
|
@@ -6453,6 +6405,9 @@ var SchemaDbPusher = class {
|
|
|
6453
6405
|
return result;
|
|
6454
6406
|
}
|
|
6455
6407
|
}
|
|
6408
|
+
isCustomType(type) {
|
|
6409
|
+
return this.schema.typeDefs && Object.values(this.schema.typeDefs).some((def) => def.name === type);
|
|
6410
|
+
}
|
|
6456
6411
|
isAutoIncrement(fieldDef) {
|
|
6457
6412
|
return fieldDef.default && ExpressionUtils.isCall(fieldDef.default) && fieldDef.default.function === "autoincrement";
|
|
6458
6413
|
}
|
|
@@ -6903,7 +6858,7 @@ function createClientProxy(client) {
|
|
|
6903
6858
|
}
|
|
6904
6859
|
__name(createClientProxy, "createClientProxy");
|
|
6905
6860
|
function createModelCrudHandler(client, model, inputValidator, resultProcessor) {
|
|
6906
|
-
const createPromise = /* @__PURE__ */ __name((operation, args, handler, postProcess = false, throwIfNoResult = false) => {
|
|
6861
|
+
const createPromise = /* @__PURE__ */ __name((operation, nominalOperation, args, handler, postProcess = false, throwIfNoResult = false) => {
|
|
6907
6862
|
return createZenStackPromise(async (txClient) => {
|
|
6908
6863
|
let proceed = /* @__PURE__ */ __name(async (_args) => {
|
|
6909
6864
|
const _handler = txClient ? handler.withClient(txClient) : handler;
|
|
@@ -6929,7 +6884,7 @@ function createModelCrudHandler(client, model, inputValidator, resultProcessor)
|
|
|
6929
6884
|
proceed = /* @__PURE__ */ __name((_args) => onQuery({
|
|
6930
6885
|
client,
|
|
6931
6886
|
model,
|
|
6932
|
-
operation,
|
|
6887
|
+
operation: nominalOperation,
|
|
6933
6888
|
// reflect the latest override if provided
|
|
6934
6889
|
args: _args,
|
|
6935
6890
|
// ensure inner overrides are propagated to the previous proceed
|
|
@@ -6942,55 +6897,55 @@ function createModelCrudHandler(client, model, inputValidator, resultProcessor)
|
|
|
6942
6897
|
}, "createPromise");
|
|
6943
6898
|
return {
|
|
6944
6899
|
findUnique: /* @__PURE__ */ __name((args) => {
|
|
6945
|
-
return createPromise("findUnique", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
6900
|
+
return createPromise("findUnique", "findUnique", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
6946
6901
|
}, "findUnique"),
|
|
6947
6902
|
findUniqueOrThrow: /* @__PURE__ */ __name((args) => {
|
|
6948
|
-
return createPromise("findUnique", args, new FindOperationHandler(client, model, inputValidator), true, true);
|
|
6903
|
+
return createPromise("findUnique", "findUniqueOrThrow", args, new FindOperationHandler(client, model, inputValidator), true, true);
|
|
6949
6904
|
}, "findUniqueOrThrow"),
|
|
6950
6905
|
findFirst: /* @__PURE__ */ __name((args) => {
|
|
6951
|
-
return createPromise("findFirst", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
6906
|
+
return createPromise("findFirst", "findFirst", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
6952
6907
|
}, "findFirst"),
|
|
6953
6908
|
findFirstOrThrow: /* @__PURE__ */ __name((args) => {
|
|
6954
|
-
return createPromise("findFirst", args, new FindOperationHandler(client, model, inputValidator), true, true);
|
|
6909
|
+
return createPromise("findFirst", "findFirstOrThrow", args, new FindOperationHandler(client, model, inputValidator), true, true);
|
|
6955
6910
|
}, "findFirstOrThrow"),
|
|
6956
6911
|
findMany: /* @__PURE__ */ __name((args) => {
|
|
6957
|
-
return createPromise("findMany", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
6912
|
+
return createPromise("findMany", "findMany", args, new FindOperationHandler(client, model, inputValidator), true);
|
|
6958
6913
|
}, "findMany"),
|
|
6959
6914
|
create: /* @__PURE__ */ __name((args) => {
|
|
6960
|
-
return createPromise("create", args, new CreateOperationHandler(client, model, inputValidator), true);
|
|
6915
|
+
return createPromise("create", "create", args, new CreateOperationHandler(client, model, inputValidator), true);
|
|
6961
6916
|
}, "create"),
|
|
6962
6917
|
createMany: /* @__PURE__ */ __name((args) => {
|
|
6963
|
-
return createPromise("createMany", args, new CreateOperationHandler(client, model, inputValidator), false);
|
|
6918
|
+
return createPromise("createMany", "createMany", args, new CreateOperationHandler(client, model, inputValidator), false);
|
|
6964
6919
|
}, "createMany"),
|
|
6965
6920
|
createManyAndReturn: /* @__PURE__ */ __name((args) => {
|
|
6966
|
-
return createPromise("createManyAndReturn", args, new CreateOperationHandler(client, model, inputValidator), true);
|
|
6921
|
+
return createPromise("createManyAndReturn", "createManyAndReturn", args, new CreateOperationHandler(client, model, inputValidator), true);
|
|
6967
6922
|
}, "createManyAndReturn"),
|
|
6968
6923
|
update: /* @__PURE__ */ __name((args) => {
|
|
6969
|
-
return createPromise("update", args, new UpdateOperationHandler(client, model, inputValidator), true);
|
|
6924
|
+
return createPromise("update", "update", args, new UpdateOperationHandler(client, model, inputValidator), true);
|
|
6970
6925
|
}, "update"),
|
|
6971
6926
|
updateMany: /* @__PURE__ */ __name((args) => {
|
|
6972
|
-
return createPromise("updateMany", args, new UpdateOperationHandler(client, model, inputValidator), false);
|
|
6927
|
+
return createPromise("updateMany", "updateMany", args, new UpdateOperationHandler(client, model, inputValidator), false);
|
|
6973
6928
|
}, "updateMany"),
|
|
6974
6929
|
updateManyAndReturn: /* @__PURE__ */ __name((args) => {
|
|
6975
|
-
return createPromise("updateManyAndReturn", args, new UpdateOperationHandler(client, model, inputValidator), true);
|
|
6930
|
+
return createPromise("updateManyAndReturn", "updateManyAndReturn", args, new UpdateOperationHandler(client, model, inputValidator), true);
|
|
6976
6931
|
}, "updateManyAndReturn"),
|
|
6977
6932
|
upsert: /* @__PURE__ */ __name((args) => {
|
|
6978
|
-
return createPromise("upsert", args, new UpdateOperationHandler(client, model, inputValidator), true);
|
|
6933
|
+
return createPromise("upsert", "upsert", args, new UpdateOperationHandler(client, model, inputValidator), true);
|
|
6979
6934
|
}, "upsert"),
|
|
6980
6935
|
delete: /* @__PURE__ */ __name((args) => {
|
|
6981
|
-
return createPromise("delete", args, new DeleteOperationHandler(client, model, inputValidator), true);
|
|
6936
|
+
return createPromise("delete", "delete", args, new DeleteOperationHandler(client, model, inputValidator), true);
|
|
6982
6937
|
}, "delete"),
|
|
6983
6938
|
deleteMany: /* @__PURE__ */ __name((args) => {
|
|
6984
|
-
return createPromise("deleteMany", args, new DeleteOperationHandler(client, model, inputValidator), false);
|
|
6939
|
+
return createPromise("deleteMany", "deleteMany", args, new DeleteOperationHandler(client, model, inputValidator), false);
|
|
6985
6940
|
}, "deleteMany"),
|
|
6986
6941
|
count: /* @__PURE__ */ __name((args) => {
|
|
6987
|
-
return createPromise("count", args, new CountOperationHandler(client, model, inputValidator), false);
|
|
6942
|
+
return createPromise("count", "count", args, new CountOperationHandler(client, model, inputValidator), false);
|
|
6988
6943
|
}, "count"),
|
|
6989
6944
|
aggregate: /* @__PURE__ */ __name((args) => {
|
|
6990
|
-
return createPromise("aggregate", args, new AggregateOperationHandler(client, model, inputValidator), false);
|
|
6945
|
+
return createPromise("aggregate", "aggregate", args, new AggregateOperationHandler(client, model, inputValidator), false);
|
|
6991
6946
|
}, "aggregate"),
|
|
6992
6947
|
groupBy: /* @__PURE__ */ __name((args) => {
|
|
6993
|
-
return createPromise("groupBy", args, new GroupByOperationHandler(client, model, inputValidator), true);
|
|
6948
|
+
return createPromise("groupBy", "groupBy", args, new GroupByOperationHandler(client, model, inputValidator), true);
|
|
6994
6949
|
}, "groupBy")
|
|
6995
6950
|
};
|
|
6996
6951
|
}
|