@zenstackhq/orm 3.9.7-beta.1 → 3.9.8
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/constants-BQEq4CBi.mjs +161 -0
- package/dist/constants-BQEq4CBi.mjs.map +1 -0
- package/dist/constants-CcJSpq4B.cjs +244 -0
- package/dist/constants-CcJSpq4B.cjs.map +1 -0
- package/dist/constants-RUWhnVl4.d.mts +129 -0
- package/dist/constants-lRwcp6Hv.d.cts +129 -0
- package/dist/constants.cjs +11 -0
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +2 -0
- package/dist/index.cjs +147 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -129
- package/dist/index.d.mts +1 -129
- package/dist/index.mjs +118 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonArray, JsonNull, JsonNullClass, JsonNullValues, JsonObject, JsonValue } from "./common-types.cjs";
|
|
2
|
+
import { a as CoreCreateOperations, c as CoreReadOperations, d as FilterPropertyToKind, f as LOGICAL_COMBINATORS, i as AllWriteOperations, l as CoreUpdateOperations, n as AllCrudOperations, o as CoreCrudOperations, p as TRANSACTION_UNSUPPORTED_METHODS, r as AllReadOperations, s as CoreDeleteOperations, t as AggregateOperators, u as CoreWriteOperations } from "./constants-lRwcp6Hv.cjs";
|
|
2
3
|
import * as _$kysely from "kysely";
|
|
3
4
|
import { AddColumnNode, AddConstraintNode, AddIndexNode, AddValueNode, AggregateFunctionNode, AliasNode, AliasableExpression, AlterColumnNode, AlterTableNode, AlterTypeNode, AndNode, BinaryOperationNode, CaseNode, CastNode, CheckConstraintNode, CollateNode, ColumnDefinitionNode, ColumnNode, ColumnUpdateNode, CommonTableExpressionNameNode, CommonTableExpressionNode, CreateIndexNode, CreateSchemaNode, CreateTableNode, CreateTypeNode, CreateViewNode, DataTypeNode, DefaultInsertValueNode, DefaultValueNode, DeleteQueryNode, Dialect, DropColumnNode, DropConstraintNode, DropIndexNode, DropSchemaNode, DropTableNode, DropTypeNode, DropViewNode, ExplainNode, Expression, ExpressionBuilder, ExpressionWrapper, FetchNode, ForeignKeyConstraintNode, FromNode, FunctionNode, Generated, GeneratedNode, GroupByItemNode, GroupByNode, HavingNode, IdentifierNode, InsertQueryNode, JSONOperatorChainNode, JSONPathLegNode, JSONPathNode, JSONReferenceNode, JoinNode, Kysely, KyselyConfig, LimitNode, ListNode, MatchedNode, MergeQueryNode, ModifyColumnNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, OnNode, OperandExpression, OperationNode, OperationNodeVisitor, OperatorNode, OrActionNode, OrNode, OrderByItemNode, OrderByNode, OutputNode, OverNode, ParensNode, PartitionByItemNode, PartitionByNode, PrimaryKeyConstraintNode, PrimitiveValueListNode, QueryId, QueryResult, RawNode, ReferenceNode, ReferencesNode, RefreshMaterializedViewNode, RenameColumnNode, RenameConstraintNode, RenameValueNode, ReturningNode, RootOperationNode, SchemableIdentifierNode, SelectAllNode, SelectModifierNode, SelectQueryBuilder, SelectQueryNode, SelectionNode, SetOperationNode, SqlBool, TableNode, TopNode, TupleNode, UnaryOperationNode, UniqueConstraintNode, UnknownRow, UpdateQueryNode, UsingNode, ValueListNode, ValueNode, ValuesNode, WhenNode, WhereNode, WithNode } from "kysely";
|
|
4
5
|
import * as _$_zenstackhq_schema0 from "@zenstackhq/schema";
|
|
@@ -162,61 +163,6 @@ type _NoExtraObject<T extends object, Shape, Keys extends PropertyKey = _ObjectK
|
|
|
162
163
|
*/
|
|
163
164
|
type NoExtraProperties<T, Shape> = unknown extends Shape ? unknown : T extends _ExactLeaf ? T : T extends readonly (infer Item)[] ? [_ArrayItem<Shape>] extends [never] ? never : NoExtraProperties<Item, _ArrayItem<Shape>>[] : T extends object ? _NoExtraObject<T, Shape> : T;
|
|
164
165
|
//#endregion
|
|
165
|
-
//#region src/client/constants.d.ts
|
|
166
|
-
/**
|
|
167
|
-
* Client API methods that are not supported in transactions.
|
|
168
|
-
*/
|
|
169
|
-
declare const TRANSACTION_UNSUPPORTED_METHODS: readonly ["$transaction", "$connect", "$disconnect", "$use"];
|
|
170
|
-
/**
|
|
171
|
-
* Logical combinators used in filters.
|
|
172
|
-
*/
|
|
173
|
-
declare const LOGICAL_COMBINATORS: readonly ["AND", "OR", "NOT"];
|
|
174
|
-
/**
|
|
175
|
-
* Aggregation operators.
|
|
176
|
-
*/
|
|
177
|
-
declare const AggregateOperators: readonly ["_count", "_sum", "_avg", "_min", "_max"];
|
|
178
|
-
type AggregateOperators = (typeof AggregateOperators)[number];
|
|
179
|
-
/**
|
|
180
|
-
* Mapping of filter operators to their corresponding filter kind categories.
|
|
181
|
-
*/
|
|
182
|
-
declare const FILTER_PROPERTY_TO_KIND: {
|
|
183
|
-
readonly equals: "Equality";
|
|
184
|
-
readonly not: "Equality";
|
|
185
|
-
readonly in: "Equality";
|
|
186
|
-
readonly notIn: "Equality";
|
|
187
|
-
readonly lt: "Range";
|
|
188
|
-
readonly lte: "Range";
|
|
189
|
-
readonly gt: "Range";
|
|
190
|
-
readonly gte: "Range";
|
|
191
|
-
readonly between: "Range";
|
|
192
|
-
readonly contains: "Like";
|
|
193
|
-
readonly startsWith: "Like";
|
|
194
|
-
readonly endsWith: "Like";
|
|
195
|
-
readonly mode: "Like";
|
|
196
|
-
readonly is: "Relation";
|
|
197
|
-
readonly isNot: "Relation";
|
|
198
|
-
readonly some: "Relation";
|
|
199
|
-
readonly every: "Relation";
|
|
200
|
-
readonly none: "Relation";
|
|
201
|
-
readonly path: "Json";
|
|
202
|
-
readonly string_contains: "Json";
|
|
203
|
-
readonly string_starts_with: "Json";
|
|
204
|
-
readonly string_ends_with: "Json";
|
|
205
|
-
readonly array_contains: "Json";
|
|
206
|
-
readonly array_starts_with: "Json";
|
|
207
|
-
readonly array_ends_with: "Json";
|
|
208
|
-
readonly fuzzy: "Fuzzy";
|
|
209
|
-
readonly fts: "FullText";
|
|
210
|
-
readonly has: "List";
|
|
211
|
-
readonly hasEvery: "List";
|
|
212
|
-
readonly hasSome: "List";
|
|
213
|
-
readonly isEmpty: "List";
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Mapping of filter operators to their corresponding filter kind categories.
|
|
217
|
-
*/
|
|
218
|
-
type FilterPropertyToKind = typeof FILTER_PROPERTY_TO_KIND;
|
|
219
|
-
//#endregion
|
|
220
166
|
//#region src/client/query-builder.d.ts
|
|
221
167
|
type ToKyselySchema<Schema extends SchemaDef> = { [Model in GetModels<Schema>]: ToKyselyTable<Schema, Model> };
|
|
222
168
|
type ToKysely<Schema extends SchemaDef> = Kysely<ToKyselySchema<Schema>>;
|
|
@@ -1043,80 +989,6 @@ declare class InputValidator<Schema extends SchemaDef> {
|
|
|
1043
989
|
private validate;
|
|
1044
990
|
}
|
|
1045
991
|
//#endregion
|
|
1046
|
-
//#region src/client/crud/operations/base.d.ts
|
|
1047
|
-
/**
|
|
1048
|
-
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1049
|
-
*/
|
|
1050
|
-
declare const CoreCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists"];
|
|
1051
|
-
/**
|
|
1052
|
-
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1053
|
-
*/
|
|
1054
|
-
type CoreCrudOperations = (typeof CoreCrudOperations)[number];
|
|
1055
|
-
/**
|
|
1056
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1057
|
-
*/
|
|
1058
|
-
declare const CoreReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists"];
|
|
1059
|
-
/**
|
|
1060
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1061
|
-
*/
|
|
1062
|
-
type CoreReadOperations = (typeof CoreReadOperations)[number];
|
|
1063
|
-
/**
|
|
1064
|
-
* List of core write operations.
|
|
1065
|
-
*/
|
|
1066
|
-
declare const CoreWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
1067
|
-
/**
|
|
1068
|
-
* List of core write operations.
|
|
1069
|
-
*/
|
|
1070
|
-
type CoreWriteOperations = (typeof CoreWriteOperations)[number];
|
|
1071
|
-
/**
|
|
1072
|
-
* List of core create operations.
|
|
1073
|
-
*/
|
|
1074
|
-
declare const CoreCreateOperations: readonly ["create", "createMany", "createManyAndReturn", "upsert"];
|
|
1075
|
-
/**
|
|
1076
|
-
* List of core create operations.
|
|
1077
|
-
*/
|
|
1078
|
-
type CoreCreateOperations = (typeof CoreCreateOperations)[number];
|
|
1079
|
-
/**
|
|
1080
|
-
* List of core update operations.
|
|
1081
|
-
*/
|
|
1082
|
-
declare const CoreUpdateOperations: readonly ["update", "updateMany", "updateManyAndReturn", "upsert"];
|
|
1083
|
-
/**
|
|
1084
|
-
* List of core update operations.
|
|
1085
|
-
*/
|
|
1086
|
-
type CoreUpdateOperations = (typeof CoreUpdateOperations)[number];
|
|
1087
|
-
/**
|
|
1088
|
-
* List of core delete operations.
|
|
1089
|
-
*/
|
|
1090
|
-
declare const CoreDeleteOperations: readonly ["delete", "deleteMany"];
|
|
1091
|
-
/**
|
|
1092
|
-
* List of core delete operations.
|
|
1093
|
-
*/
|
|
1094
|
-
type CoreDeleteOperations = (typeof CoreDeleteOperations)[number];
|
|
1095
|
-
/**
|
|
1096
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
1097
|
-
*/
|
|
1098
|
-
declare const AllCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1099
|
-
/**
|
|
1100
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
1101
|
-
*/
|
|
1102
|
-
type AllCrudOperations = (typeof AllCrudOperations)[number];
|
|
1103
|
-
/**
|
|
1104
|
-
* List of all read operations, including 'orThrow' variants.
|
|
1105
|
-
*/
|
|
1106
|
-
declare const AllReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1107
|
-
/**
|
|
1108
|
-
* List of all read operations, including 'orThrow' variants.
|
|
1109
|
-
*/
|
|
1110
|
-
type AllReadOperations = (typeof AllReadOperations)[number];
|
|
1111
|
-
/**
|
|
1112
|
-
* List of all write operations - simply an alias of CoreWriteOperations.
|
|
1113
|
-
*/
|
|
1114
|
-
declare const AllWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
1115
|
-
/**
|
|
1116
|
-
* List of all write operations - simply an alias of CoreWriteOperations.
|
|
1117
|
-
*/
|
|
1118
|
-
type AllWriteOperations = CoreWriteOperations;
|
|
1119
|
-
//#endregion
|
|
1120
992
|
//#region src/client/type-utils.d.ts
|
|
1121
993
|
/**
|
|
1122
994
|
* Checks if a model has any required Unsupported fields (non-optional, no default).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonArray, JsonNull, JsonNullClass, JsonNullValues, JsonObject, JsonValue } from "./common-types.mjs";
|
|
2
|
+
import { a as CoreCreateOperations, c as CoreReadOperations, d as FilterPropertyToKind, f as LOGICAL_COMBINATORS, i as AllWriteOperations, l as CoreUpdateOperations, n as AllCrudOperations, o as CoreCrudOperations, p as TRANSACTION_UNSUPPORTED_METHODS, r as AllReadOperations, s as CoreDeleteOperations, t as AggregateOperators, u as CoreWriteOperations } from "./constants-RUWhnVl4.mjs";
|
|
2
3
|
import * as _$kysely from "kysely";
|
|
3
4
|
import { AddColumnNode, AddConstraintNode, AddIndexNode, AddValueNode, AggregateFunctionNode, AliasNode, AliasableExpression, AlterColumnNode, AlterTableNode, AlterTypeNode, AndNode, BinaryOperationNode, CaseNode, CastNode, CheckConstraintNode, CollateNode, ColumnDefinitionNode, ColumnNode, ColumnUpdateNode, CommonTableExpressionNameNode, CommonTableExpressionNode, CreateIndexNode, CreateSchemaNode, CreateTableNode, CreateTypeNode, CreateViewNode, DataTypeNode, DefaultInsertValueNode, DefaultValueNode, DeleteQueryNode, Dialect, DropColumnNode, DropConstraintNode, DropIndexNode, DropSchemaNode, DropTableNode, DropTypeNode, DropViewNode, ExplainNode, Expression, ExpressionBuilder, ExpressionWrapper, FetchNode, ForeignKeyConstraintNode, FromNode, FunctionNode, Generated, GeneratedNode, GroupByItemNode, GroupByNode, HavingNode, IdentifierNode, InsertQueryNode, JSONOperatorChainNode, JSONPathLegNode, JSONPathNode, JSONReferenceNode, JoinNode, Kysely, KyselyConfig, LimitNode, ListNode, MatchedNode, MergeQueryNode, ModifyColumnNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, OnNode, OperandExpression, OperationNode, OperationNodeVisitor, OperatorNode, OrActionNode, OrNode, OrderByItemNode, OrderByNode, OutputNode, OverNode, ParensNode, PartitionByItemNode, PartitionByNode, PrimaryKeyConstraintNode, PrimitiveValueListNode, QueryId, QueryResult, RawNode, ReferenceNode, ReferencesNode, RefreshMaterializedViewNode, RenameColumnNode, RenameConstraintNode, RenameValueNode, ReturningNode, RootOperationNode, SchemableIdentifierNode, SelectAllNode, SelectModifierNode, SelectQueryBuilder, SelectQueryNode, SelectionNode, SetOperationNode, SqlBool, TableNode, TopNode, TupleNode, UnaryOperationNode, UniqueConstraintNode, UnknownRow, UpdateQueryNode, UsingNode, ValueListNode, ValueNode, ValuesNode, WhenNode, WhereNode, WithNode } from "kysely";
|
|
4
5
|
import { ZodType, z } from "zod";
|
|
@@ -162,61 +163,6 @@ type _NoExtraObject<T extends object, Shape, Keys extends PropertyKey = _ObjectK
|
|
|
162
163
|
*/
|
|
163
164
|
type NoExtraProperties<T, Shape> = unknown extends Shape ? unknown : T extends _ExactLeaf ? T : T extends readonly (infer Item)[] ? [_ArrayItem<Shape>] extends [never] ? never : NoExtraProperties<Item, _ArrayItem<Shape>>[] : T extends object ? _NoExtraObject<T, Shape> : T;
|
|
164
165
|
//#endregion
|
|
165
|
-
//#region src/client/constants.d.ts
|
|
166
|
-
/**
|
|
167
|
-
* Client API methods that are not supported in transactions.
|
|
168
|
-
*/
|
|
169
|
-
declare const TRANSACTION_UNSUPPORTED_METHODS: readonly ["$transaction", "$connect", "$disconnect", "$use"];
|
|
170
|
-
/**
|
|
171
|
-
* Logical combinators used in filters.
|
|
172
|
-
*/
|
|
173
|
-
declare const LOGICAL_COMBINATORS: readonly ["AND", "OR", "NOT"];
|
|
174
|
-
/**
|
|
175
|
-
* Aggregation operators.
|
|
176
|
-
*/
|
|
177
|
-
declare const AggregateOperators: readonly ["_count", "_sum", "_avg", "_min", "_max"];
|
|
178
|
-
type AggregateOperators = (typeof AggregateOperators)[number];
|
|
179
|
-
/**
|
|
180
|
-
* Mapping of filter operators to their corresponding filter kind categories.
|
|
181
|
-
*/
|
|
182
|
-
declare const FILTER_PROPERTY_TO_KIND: {
|
|
183
|
-
readonly equals: "Equality";
|
|
184
|
-
readonly not: "Equality";
|
|
185
|
-
readonly in: "Equality";
|
|
186
|
-
readonly notIn: "Equality";
|
|
187
|
-
readonly lt: "Range";
|
|
188
|
-
readonly lte: "Range";
|
|
189
|
-
readonly gt: "Range";
|
|
190
|
-
readonly gte: "Range";
|
|
191
|
-
readonly between: "Range";
|
|
192
|
-
readonly contains: "Like";
|
|
193
|
-
readonly startsWith: "Like";
|
|
194
|
-
readonly endsWith: "Like";
|
|
195
|
-
readonly mode: "Like";
|
|
196
|
-
readonly is: "Relation";
|
|
197
|
-
readonly isNot: "Relation";
|
|
198
|
-
readonly some: "Relation";
|
|
199
|
-
readonly every: "Relation";
|
|
200
|
-
readonly none: "Relation";
|
|
201
|
-
readonly path: "Json";
|
|
202
|
-
readonly string_contains: "Json";
|
|
203
|
-
readonly string_starts_with: "Json";
|
|
204
|
-
readonly string_ends_with: "Json";
|
|
205
|
-
readonly array_contains: "Json";
|
|
206
|
-
readonly array_starts_with: "Json";
|
|
207
|
-
readonly array_ends_with: "Json";
|
|
208
|
-
readonly fuzzy: "Fuzzy";
|
|
209
|
-
readonly fts: "FullText";
|
|
210
|
-
readonly has: "List";
|
|
211
|
-
readonly hasEvery: "List";
|
|
212
|
-
readonly hasSome: "List";
|
|
213
|
-
readonly isEmpty: "List";
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Mapping of filter operators to their corresponding filter kind categories.
|
|
217
|
-
*/
|
|
218
|
-
type FilterPropertyToKind = typeof FILTER_PROPERTY_TO_KIND;
|
|
219
|
-
//#endregion
|
|
220
166
|
//#region src/client/query-builder.d.ts
|
|
221
167
|
type ToKyselySchema<Schema extends SchemaDef> = { [Model in GetModels<Schema>]: ToKyselyTable<Schema, Model> };
|
|
222
168
|
type ToKysely<Schema extends SchemaDef> = Kysely<ToKyselySchema<Schema>>;
|
|
@@ -1043,80 +989,6 @@ declare class InputValidator<Schema extends SchemaDef> {
|
|
|
1043
989
|
private validate;
|
|
1044
990
|
}
|
|
1045
991
|
//#endregion
|
|
1046
|
-
//#region src/client/crud/operations/base.d.ts
|
|
1047
|
-
/**
|
|
1048
|
-
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1049
|
-
*/
|
|
1050
|
-
declare const CoreCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists"];
|
|
1051
|
-
/**
|
|
1052
|
-
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1053
|
-
*/
|
|
1054
|
-
type CoreCrudOperations = (typeof CoreCrudOperations)[number];
|
|
1055
|
-
/**
|
|
1056
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1057
|
-
*/
|
|
1058
|
-
declare const CoreReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists"];
|
|
1059
|
-
/**
|
|
1060
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1061
|
-
*/
|
|
1062
|
-
type CoreReadOperations = (typeof CoreReadOperations)[number];
|
|
1063
|
-
/**
|
|
1064
|
-
* List of core write operations.
|
|
1065
|
-
*/
|
|
1066
|
-
declare const CoreWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
1067
|
-
/**
|
|
1068
|
-
* List of core write operations.
|
|
1069
|
-
*/
|
|
1070
|
-
type CoreWriteOperations = (typeof CoreWriteOperations)[number];
|
|
1071
|
-
/**
|
|
1072
|
-
* List of core create operations.
|
|
1073
|
-
*/
|
|
1074
|
-
declare const CoreCreateOperations: readonly ["create", "createMany", "createManyAndReturn", "upsert"];
|
|
1075
|
-
/**
|
|
1076
|
-
* List of core create operations.
|
|
1077
|
-
*/
|
|
1078
|
-
type CoreCreateOperations = (typeof CoreCreateOperations)[number];
|
|
1079
|
-
/**
|
|
1080
|
-
* List of core update operations.
|
|
1081
|
-
*/
|
|
1082
|
-
declare const CoreUpdateOperations: readonly ["update", "updateMany", "updateManyAndReturn", "upsert"];
|
|
1083
|
-
/**
|
|
1084
|
-
* List of core update operations.
|
|
1085
|
-
*/
|
|
1086
|
-
type CoreUpdateOperations = (typeof CoreUpdateOperations)[number];
|
|
1087
|
-
/**
|
|
1088
|
-
* List of core delete operations.
|
|
1089
|
-
*/
|
|
1090
|
-
declare const CoreDeleteOperations: readonly ["delete", "deleteMany"];
|
|
1091
|
-
/**
|
|
1092
|
-
* List of core delete operations.
|
|
1093
|
-
*/
|
|
1094
|
-
type CoreDeleteOperations = (typeof CoreDeleteOperations)[number];
|
|
1095
|
-
/**
|
|
1096
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
1097
|
-
*/
|
|
1098
|
-
declare const AllCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1099
|
-
/**
|
|
1100
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
1101
|
-
*/
|
|
1102
|
-
type AllCrudOperations = (typeof AllCrudOperations)[number];
|
|
1103
|
-
/**
|
|
1104
|
-
* List of all read operations, including 'orThrow' variants.
|
|
1105
|
-
*/
|
|
1106
|
-
declare const AllReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1107
|
-
/**
|
|
1108
|
-
* List of all read operations, including 'orThrow' variants.
|
|
1109
|
-
*/
|
|
1110
|
-
type AllReadOperations = (typeof AllReadOperations)[number];
|
|
1111
|
-
/**
|
|
1112
|
-
* List of all write operations - simply an alias of CoreWriteOperations.
|
|
1113
|
-
*/
|
|
1114
|
-
declare const AllWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
1115
|
-
/**
|
|
1116
|
-
* List of all write operations - simply an alias of CoreWriteOperations.
|
|
1117
|
-
*/
|
|
1118
|
-
type AllWriteOperations = CoreWriteOperations;
|
|
1119
|
-
//#endregion
|
|
1120
992
|
//#region src/client/type-utils.d.ts
|
|
1121
993
|
/**
|
|
1122
994
|
* Checks if a model has any required Unsupported fields (non-optional, no default).
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
|
+
import { a as CoreCreateOperations, c as CoreReadOperations, d as DELEGATE_JOINED_FIELD_PREFIX, f as FILTER_PROPERTY_TO_KIND, i as AllWriteOperations, l as CoreUpdateOperations, m as NUMERIC_FIELD_TYPES, n as AllCrudOperations, o as CoreCrudOperations, p as LOGICAL_COMBINATORS, r as AllReadOperations, s as CoreDeleteOperations, t as AggregateOperators, u as CoreWriteOperations } from "./constants-BQEq4CBi.mjs";
|
|
2
3
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "./common-types.mjs";
|
|
3
4
|
import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
4
5
|
import { AliasNode, AndNode, ColumnNode, ColumnUpdateNode, CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor, DeleteQueryNode, ExpressionWrapper, FromNode, IdentifierNode, InsertQueryNode, Kysely, Log, OperationNodeTransformer, OperationNodeVisitor, PrimitiveValueListNode, RawNode, ReferenceNode, ReturningNode, SelectAllNode, SelectionNode, SingleConnectionProvider, TableNode, Transaction, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode, WhereNode, createQueryId, expressionBuilder, sql } from "kysely";
|
|
@@ -541,75 +542,6 @@ function tmpAlias(name) {
|
|
|
541
542
|
else return name;
|
|
542
543
|
}
|
|
543
544
|
//#endregion
|
|
544
|
-
//#region src/client/constants.ts
|
|
545
|
-
/**
|
|
546
|
-
* The types of fields that are numeric.
|
|
547
|
-
*/
|
|
548
|
-
const NUMERIC_FIELD_TYPES = [
|
|
549
|
-
"Int",
|
|
550
|
-
"Float",
|
|
551
|
-
"BigInt",
|
|
552
|
-
"Decimal"
|
|
553
|
-
];
|
|
554
|
-
/**
|
|
555
|
-
* Prefix for JSON field used to store joined delegate rows.
|
|
556
|
-
*/
|
|
557
|
-
const DELEGATE_JOINED_FIELD_PREFIX = "$delegate$";
|
|
558
|
-
/**
|
|
559
|
-
* Logical combinators used in filters.
|
|
560
|
-
*/
|
|
561
|
-
const LOGICAL_COMBINATORS = [
|
|
562
|
-
"AND",
|
|
563
|
-
"OR",
|
|
564
|
-
"NOT"
|
|
565
|
-
];
|
|
566
|
-
/**
|
|
567
|
-
* Aggregation operators.
|
|
568
|
-
*/
|
|
569
|
-
const AggregateOperators = [
|
|
570
|
-
"_count",
|
|
571
|
-
"_sum",
|
|
572
|
-
"_avg",
|
|
573
|
-
"_min",
|
|
574
|
-
"_max"
|
|
575
|
-
];
|
|
576
|
-
/**
|
|
577
|
-
* Mapping of filter operators to their corresponding filter kind categories.
|
|
578
|
-
*/
|
|
579
|
-
const FILTER_PROPERTY_TO_KIND = {
|
|
580
|
-
equals: "Equality",
|
|
581
|
-
not: "Equality",
|
|
582
|
-
in: "Equality",
|
|
583
|
-
notIn: "Equality",
|
|
584
|
-
lt: "Range",
|
|
585
|
-
lte: "Range",
|
|
586
|
-
gt: "Range",
|
|
587
|
-
gte: "Range",
|
|
588
|
-
between: "Range",
|
|
589
|
-
contains: "Like",
|
|
590
|
-
startsWith: "Like",
|
|
591
|
-
endsWith: "Like",
|
|
592
|
-
mode: "Like",
|
|
593
|
-
is: "Relation",
|
|
594
|
-
isNot: "Relation",
|
|
595
|
-
some: "Relation",
|
|
596
|
-
every: "Relation",
|
|
597
|
-
none: "Relation",
|
|
598
|
-
path: "Json",
|
|
599
|
-
string_contains: "Json",
|
|
600
|
-
string_starts_with: "Json",
|
|
601
|
-
string_ends_with: "Json",
|
|
602
|
-
array_contains: "Json",
|
|
603
|
-
array_starts_with: "Json",
|
|
604
|
-
array_ends_with: "Json",
|
|
605
|
-
fuzzy: "Fuzzy",
|
|
606
|
-
fts: "FullText",
|
|
607
|
-
has: "List",
|
|
608
|
-
hasEvery: "List",
|
|
609
|
-
hasSome: "List",
|
|
610
|
-
isEmpty: "List"
|
|
611
|
-
};
|
|
612
|
-
//#endregion
|
|
613
545
|
//#region src/client/contract.ts
|
|
614
546
|
/**
|
|
615
547
|
* Transaction isolation levels.
|
|
@@ -2031,7 +1963,11 @@ var PostgresCrudDialect = class PostgresCrudDialect extends LateralJoinDialectBa
|
|
|
2031
1963
|
if (columnResolved.sqlType === "uuid" && (op === "=" || op === "!=")) {
|
|
2032
1964
|
const value = valueNode.value;
|
|
2033
1965
|
if (typeof value === "string" && PostgresCrudDialect.uuidFormatRegex.test(value)) return this.eb(left, op, right);
|
|
2034
|
-
else
|
|
1966
|
+
else if (op === "=") return this.eb.lit(false);
|
|
1967
|
+
else {
|
|
1968
|
+
const column = valueNode === rightNode ? left : right;
|
|
1969
|
+
return this.eb(column, "is not", null);
|
|
1970
|
+
}
|
|
2035
1971
|
}
|
|
2036
1972
|
}
|
|
2037
1973
|
getStringCasingBehavior() {
|
|
@@ -4279,94 +4215,13 @@ var InputValidator = class {
|
|
|
4279
4215
|
//#endregion
|
|
4280
4216
|
//#region src/client/crud/operations/base.ts
|
|
4281
4217
|
/**
|
|
4282
|
-
*
|
|
4283
|
-
*/
|
|
4284
|
-
const CoreCrudOperations = [
|
|
4285
|
-
"findMany",
|
|
4286
|
-
"findUnique",
|
|
4287
|
-
"findFirst",
|
|
4288
|
-
"create",
|
|
4289
|
-
"createMany",
|
|
4290
|
-
"createManyAndReturn",
|
|
4291
|
-
"update",
|
|
4292
|
-
"updateMany",
|
|
4293
|
-
"updateManyAndReturn",
|
|
4294
|
-
"upsert",
|
|
4295
|
-
"delete",
|
|
4296
|
-
"deleteMany",
|
|
4297
|
-
"count",
|
|
4298
|
-
"aggregate",
|
|
4299
|
-
"groupBy",
|
|
4300
|
-
"exists"
|
|
4301
|
-
];
|
|
4302
|
-
/**
|
|
4303
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
4304
|
-
*/
|
|
4305
|
-
const CoreReadOperations = [
|
|
4306
|
-
"findMany",
|
|
4307
|
-
"findUnique",
|
|
4308
|
-
"findFirst",
|
|
4309
|
-
"count",
|
|
4310
|
-
"aggregate",
|
|
4311
|
-
"groupBy",
|
|
4312
|
-
"exists"
|
|
4313
|
-
];
|
|
4314
|
-
/**
|
|
4315
|
-
* List of core write operations.
|
|
4316
|
-
*/
|
|
4317
|
-
const CoreWriteOperations = [
|
|
4318
|
-
"create",
|
|
4319
|
-
"createMany",
|
|
4320
|
-
"createManyAndReturn",
|
|
4321
|
-
"update",
|
|
4322
|
-
"updateMany",
|
|
4323
|
-
"updateManyAndReturn",
|
|
4324
|
-
"upsert",
|
|
4325
|
-
"delete",
|
|
4326
|
-
"deleteMany"
|
|
4327
|
-
];
|
|
4328
|
-
/**
|
|
4329
|
-
* List of core create operations.
|
|
4330
|
-
*/
|
|
4331
|
-
const CoreCreateOperations = [
|
|
4332
|
-
"create",
|
|
4333
|
-
"createMany",
|
|
4334
|
-
"createManyAndReturn",
|
|
4335
|
-
"upsert"
|
|
4336
|
-
];
|
|
4337
|
-
/**
|
|
4338
|
-
* List of core update operations.
|
|
4339
|
-
*/
|
|
4340
|
-
const CoreUpdateOperations = [
|
|
4341
|
-
"update",
|
|
4342
|
-
"updateMany",
|
|
4343
|
-
"updateManyAndReturn",
|
|
4344
|
-
"upsert"
|
|
4345
|
-
];
|
|
4346
|
-
/**
|
|
4347
|
-
* List of core delete operations.
|
|
4348
|
-
*/
|
|
4349
|
-
const CoreDeleteOperations = ["delete", "deleteMany"];
|
|
4350
|
-
/**
|
|
4351
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
4352
|
-
*/
|
|
4353
|
-
const AllCrudOperations = [
|
|
4354
|
-
...CoreCrudOperations,
|
|
4355
|
-
"findUniqueOrThrow",
|
|
4356
|
-
"findFirstOrThrow"
|
|
4357
|
-
];
|
|
4358
|
-
/**
|
|
4359
|
-
* List of all read operations, including 'orThrow' variants.
|
|
4218
|
+
* Maximum number of rows identified by id in a single statement during cascade delete simulation.
|
|
4360
4219
|
*/
|
|
4361
|
-
const
|
|
4362
|
-
...CoreReadOperations,
|
|
4363
|
-
"findUniqueOrThrow",
|
|
4364
|
-
"findFirstOrThrow"
|
|
4365
|
-
];
|
|
4220
|
+
const DELETE_ID_BATCH_SIZE = 1e3;
|
|
4366
4221
|
/**
|
|
4367
|
-
*
|
|
4222
|
+
* Same as `DELETE_ID_BATCH_SIZE`, for compound ids, which are matched with one `OR` branch per row.
|
|
4368
4223
|
*/
|
|
4369
|
-
const
|
|
4224
|
+
const DELETE_COMPOUND_ID_BATCH_SIZE = 100;
|
|
4370
4225
|
var BaseOperationHandler = class {
|
|
4371
4226
|
dialect;
|
|
4372
4227
|
constructor(client, model, inputValidator) {
|
|
@@ -5301,37 +5156,130 @@ var BaseOperationHandler = class {
|
|
|
5301
5156
|
normalizeRelationManipulationInput(model, data) {
|
|
5302
5157
|
return enumerate(data).map((item) => flattenCompoundUniqueFilters(this.schema, model, item));
|
|
5303
5158
|
}
|
|
5304
|
-
async delete(kysely, model, where, limit, filterModel, fieldsToReturn) {
|
|
5159
|
+
async delete(kysely, model, where, limit, filterModel, fieldsToReturn, visited) {
|
|
5305
5160
|
filterModel ??= model;
|
|
5161
|
+
visited ??= /* @__PURE__ */ new Set();
|
|
5306
5162
|
const modelDef = this.requireModel(model);
|
|
5307
5163
|
if (modelDef.baseModel) {
|
|
5308
5164
|
if (limit !== void 0) throw createNotSupportedError("Deleting with a limit is not supported for polymorphic models");
|
|
5309
|
-
return this.processBaseModelDelete(kysely, modelDef.baseModel, where, limit, filterModel);
|
|
5165
|
+
return this.processBaseModelDelete(kysely, modelDef.baseModel, where, limit, filterModel, visited);
|
|
5310
5166
|
}
|
|
5167
|
+
const cascadeRelations = this.getDelegateCascadeRelations(model, filterModel);
|
|
5168
|
+
if (cascadeRelations.length === 0) return this.executeDelete(kysely, model, where, limit, filterModel, fieldsToReturn);
|
|
5169
|
+
if (!modelDef.isDelegate) {
|
|
5170
|
+
if (limit !== void 0) throw createNotSupportedError("Deleting with a limit is not supported for polymorphic models");
|
|
5171
|
+
for (const { fieldDef } of cascadeRelations) await this.delete(kysely, fieldDef.type, { [fieldDef.relation.opposite]: where }, void 0, void 0, void 0, visited);
|
|
5172
|
+
return this.executeDelete(kysely, model, where, limit, filterModel, fieldsToReturn);
|
|
5173
|
+
}
|
|
5174
|
+
const discriminator = getDiscriminatorField(this.schema, model);
|
|
5175
|
+
const deletedRows = await this.read(kysely, filterModel, {
|
|
5176
|
+
where,
|
|
5177
|
+
select: {
|
|
5178
|
+
...this.makeIdSelect(filterModel),
|
|
5179
|
+
[discriminator]: true
|
|
5180
|
+
},
|
|
5181
|
+
...limit !== void 0 ? { take: limit } : {}
|
|
5182
|
+
});
|
|
5183
|
+
deletedRows.forEach((row) => visited.add(this.makeVisitedKey(model, row)));
|
|
5184
|
+
for (const { fieldDef, discriminatorValue } of cascadeRelations) {
|
|
5185
|
+
const parentRows = discriminatorValue === void 0 ? deletedRows : deletedRows.filter((row) => row[discriminator] === discriminatorValue);
|
|
5186
|
+
for (const batch of this.batchRows(model, parentRows)) {
|
|
5187
|
+
const childModel = fieldDef.type;
|
|
5188
|
+
const pendingRows = (await this.read(kysely, childModel, {
|
|
5189
|
+
where: this.makeChildFilter(model, fieldDef, batch),
|
|
5190
|
+
select: this.makeIdSelect(childModel)
|
|
5191
|
+
})).filter((row) => {
|
|
5192
|
+
const key = this.makeVisitedKey(childModel, row);
|
|
5193
|
+
if (visited.has(key)) return false;
|
|
5194
|
+
visited.add(key);
|
|
5195
|
+
return true;
|
|
5196
|
+
});
|
|
5197
|
+
for (const childBatch of this.batchRows(childModel, pendingRows)) await this.delete(kysely, childModel, this.makeIdsFilter(childModel, childBatch), void 0, void 0, void 0, visited);
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
let numAffectedRows = 0n;
|
|
5201
|
+
const rows = [];
|
|
5202
|
+
for (const batch of this.batchRows(model, deletedRows)) {
|
|
5203
|
+
const result = await this.executeDelete(kysely, model, this.makeIdsFilter(model, batch), void 0, model, fieldsToReturn);
|
|
5204
|
+
numAffectedRows += result.numAffectedRows ?? 0n;
|
|
5205
|
+
rows.push(...result.rows);
|
|
5206
|
+
}
|
|
5207
|
+
return {
|
|
5208
|
+
numAffectedRows,
|
|
5209
|
+
rows
|
|
5210
|
+
};
|
|
5211
|
+
}
|
|
5212
|
+
async executeDelete(kysely, model, where, limit, filterModel, fieldsToReturn) {
|
|
5213
|
+
const modelDef = this.requireModel(model);
|
|
5311
5214
|
fieldsToReturn = fieldsToReturn ?? requireIdFields(this.schema, model);
|
|
5312
5215
|
let needIdFilter = false;
|
|
5313
5216
|
if (limit !== void 0 && !this.dialect.supportsDeleteWithLimit) needIdFilter = true;
|
|
5314
5217
|
if (modelDef.isDelegate || modelDef.baseModel) needIdFilter = true;
|
|
5315
5218
|
const deleteFilter = needIdFilter ? (eb) => eb(eb.refTuple(...this.buildIdFieldRefs(kysely, model)), "in", eb.selectFrom(this.dialect.buildSelectModel(filterModel, filterModel).where(() => this.dialect.buildFilter(filterModel, filterModel, where)).select(this.buildIdFieldRefs(kysely, filterModel)).$if(limit !== void 0, (qb) => qb.limit(limit)).as("$sub")).selectAll()) : () => this.dialect.buildFilter(model, model, where);
|
|
5316
|
-
await this.processDelegateRelationDelete(kysely, modelDef, where, limit);
|
|
5317
5219
|
const query = kysely.deleteFrom(model).where(deleteFilter).$if(this.dialect.supportsReturning, (qb) => qb.returning(fieldsToReturn)).$if(limit !== void 0 && this.dialect.supportsDeleteWithLimit, (qb) => qb.limit(limit)).modifyEnd(this.makeContextComment({
|
|
5318
5220
|
model,
|
|
5319
5221
|
operation: "delete"
|
|
5320
5222
|
}));
|
|
5321
5223
|
return this.executeQuery(kysely, query, "delete");
|
|
5322
5224
|
}
|
|
5323
|
-
|
|
5324
|
-
|
|
5225
|
+
/**
|
|
5226
|
+
* Gets the relations whose deletion must be simulated when deleting from the given model: relations
|
|
5227
|
+
* pointing to a model that extends a delegate model, with cascade delete on the opposite side. For a
|
|
5228
|
+
* delegate model, this includes relations declared on its sub models, because deleting a base row
|
|
5229
|
+
* cascades to the sub model rows in the database. `discriminatorValue` is set for a sub model relation:
|
|
5230
|
+
* it is the base model's discriminator value of the rows the relation can belong to.
|
|
5231
|
+
*/
|
|
5232
|
+
getDelegateCascadeRelations(model, filterModel = model) {
|
|
5233
|
+
const modelDef = this.requireModel(model);
|
|
5234
|
+
const filterDiscriminatorValue = filterModel === model ? void 0 : this.getDiscriminatorValueBelow(model, filterModel);
|
|
5235
|
+
const candidates = Object.values(modelDef.fields).map((fieldDef) => ({
|
|
5236
|
+
fieldDef,
|
|
5237
|
+
discriminatorValue: void 0
|
|
5238
|
+
}));
|
|
5239
|
+
if (modelDef.isDelegate) for (const subModel of getDelegateDescendantModels(this.schema, model)) {
|
|
5240
|
+
const discriminatorValue = this.getDiscriminatorValueBelow(model, subModel.name);
|
|
5241
|
+
if (filterDiscriminatorValue !== void 0 && discriminatorValue !== filterDiscriminatorValue) continue;
|
|
5242
|
+
for (const fieldDef of Object.values(subModel.fields)) if (!fieldDef.originModel) candidates.push({
|
|
5243
|
+
fieldDef,
|
|
5244
|
+
discriminatorValue
|
|
5245
|
+
});
|
|
5246
|
+
}
|
|
5247
|
+
return candidates.filter(({ fieldDef }) => {
|
|
5248
|
+
if (!fieldDef.relation?.opposite) return false;
|
|
5325
5249
|
const oppositeModelDef = this.requireModel(fieldDef.type);
|
|
5326
5250
|
const oppositeRelation = this.requireField(fieldDef.type, fieldDef.relation.opposite);
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
await this.delete(kysely, fieldDef.type, { [fieldDef.relation.opposite]: where }, void 0);
|
|
5330
|
-
}
|
|
5331
|
-
}
|
|
5251
|
+
return !!oppositeModelDef.baseModel && oppositeRelation.relation?.onDelete === "Cascade";
|
|
5252
|
+
});
|
|
5332
5253
|
}
|
|
5333
|
-
|
|
5334
|
-
|
|
5254
|
+
getDiscriminatorValueBelow(model, subModel) {
|
|
5255
|
+
let ancestor = this.requireModel(subModel);
|
|
5256
|
+
while (ancestor.baseModel !== model) ancestor = this.requireModel(ancestor.baseModel);
|
|
5257
|
+
return getDelegateDiscriminatorValue(this.schema, ancestor.name);
|
|
5258
|
+
}
|
|
5259
|
+
makeVisitedKey(model, row) {
|
|
5260
|
+
let root = model;
|
|
5261
|
+
for (let base = this.requireModel(root).baseModel; base; base = this.requireModel(root).baseModel) root = base;
|
|
5262
|
+
return JSON.stringify([root, ...this.requireModel(model).idFields.map((f) => row[f])]);
|
|
5263
|
+
}
|
|
5264
|
+
makeChildFilter(model, fieldDef, parentRows) {
|
|
5265
|
+
const opposite = fieldDef.relation.opposite;
|
|
5266
|
+
const { fields, references } = this.requireField(fieldDef.type, opposite).relation ?? {};
|
|
5267
|
+
const idFields = this.requireModel(model).idFields;
|
|
5268
|
+
if (!fields || !references || !references.every((f) => idFields.includes(f))) return { [opposite]: this.makeIdsFilter(model, parentRows) };
|
|
5269
|
+
if (fields.length === 1) return { [fields[0]]: { in: parentRows.map((row) => row[references[0]]) } };
|
|
5270
|
+
return { OR: parentRows.map((row) => Object.fromEntries(fields.map((f, i) => [f, row[references[i]]]))) };
|
|
5271
|
+
}
|
|
5272
|
+
makeIdsFilter(model, rows) {
|
|
5273
|
+
const idFields = this.requireModel(model).idFields;
|
|
5274
|
+
if (idFields.length === 1) return { [idFields[0]]: { in: rows.map((row) => row[idFields[0]]) } };
|
|
5275
|
+
return { OR: rows.map((row) => Object.fromEntries(idFields.map((f) => [f, row[f]]))) };
|
|
5276
|
+
}
|
|
5277
|
+
*batchRows(model, rows) {
|
|
5278
|
+
const size = this.requireModel(model).idFields.length === 1 ? DELETE_ID_BATCH_SIZE : DELETE_COMPOUND_ID_BATCH_SIZE;
|
|
5279
|
+
for (let i = 0; i < rows.length; i += size) yield rows.slice(i, i + size);
|
|
5280
|
+
}
|
|
5281
|
+
async processBaseModelDelete(kysely, model, where, limit, filterModel, visited) {
|
|
5282
|
+
return this.delete(kysely, model, where, limit, filterModel, void 0, visited);
|
|
5335
5283
|
}
|
|
5336
5284
|
makeIdSelect(model) {
|
|
5337
5285
|
return this.requireModel(model).idFields.reduce((acc, f) => {
|
|
@@ -5634,14 +5582,8 @@ var DeleteOperationHandler = class extends BaseOperationHandler {
|
|
|
5634
5582
|
});
|
|
5635
5583
|
}
|
|
5636
5584
|
needsNestedDelete() {
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
for (const fieldDef of Object.values(modelDef.fields)) if (fieldDef.relation?.opposite) {
|
|
5640
|
-
const oppositeModelDef = this.requireModel(fieldDef.type);
|
|
5641
|
-
const oppositeRelation = this.requireField(fieldDef.type, fieldDef.relation.opposite);
|
|
5642
|
-
if (oppositeModelDef.baseModel && oppositeRelation.relation?.onDelete === "Cascade") return true;
|
|
5643
|
-
}
|
|
5644
|
-
return false;
|
|
5585
|
+
if (this.requireModel(this.model).baseModel) return true;
|
|
5586
|
+
return this.getDelegateCascadeRelations(this.model).length > 0;
|
|
5645
5587
|
}
|
|
5646
5588
|
};
|
|
5647
5589
|
//#endregion
|
|
@@ -7300,7 +7242,7 @@ var ResultProcessor = class {
|
|
|
7300
7242
|
else if (key.startsWith("$delegate$")) {
|
|
7301
7243
|
if (value) {
|
|
7302
7244
|
const subRow = this.dialect.transformOutput(value, "Json", false);
|
|
7303
|
-
const subModel = key.slice(
|
|
7245
|
+
const subModel = key.slice(DELEGATE_JOINED_FIELD_PREFIX.length);
|
|
7304
7246
|
const idValues = getIdValues(this.schema, subModel, subRow);
|
|
7305
7247
|
if (Object.values(idValues).some((v) => v === null || v === void 0)) {
|
|
7306
7248
|
delete data[key];
|