joist-core 2.3.0-next.99 → 2.4.0

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.
Files changed (131) hide show
  1. package/build/EntityManager.cjs +1 -1
  2. package/build/EntityManager.cjs.map +1 -1
  3. package/build/EntityManager.d.cts +9 -8
  4. package/build/EntityManager.d.cts.map +1 -1
  5. package/build/EntityManager.d.mts +9 -8
  6. package/build/EntityManager.d.mts.map +1 -1
  7. package/build/EntityManager.js +1 -1
  8. package/build/EntityManager.js.map +1 -1
  9. package/build/dataloaders/findCountDataLoader.cjs +2 -0
  10. package/build/dataloaders/findCountDataLoader.cjs.map +1 -1
  11. package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
  12. package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
  13. package/build/dataloaders/findCountDataLoader.js +2 -0
  14. package/build/dataloaders/findCountDataLoader.js.map +1 -1
  15. package/build/dataloaders/findDataLoader.cjs +1 -0
  16. package/build/dataloaders/findDataLoader.cjs.map +1 -1
  17. package/build/dataloaders/findDataLoader.d.cts.map +1 -1
  18. package/build/dataloaders/findDataLoader.d.mts.map +1 -1
  19. package/build/dataloaders/findDataLoader.js +2 -1
  20. package/build/dataloaders/findDataLoader.js.map +1 -1
  21. package/build/dataloaders/findIdsDataLoader.cjs +2 -0
  22. package/build/dataloaders/findIdsDataLoader.cjs.map +1 -1
  23. package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
  24. package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
  25. package/build/dataloaders/findIdsDataLoader.js +2 -0
  26. package/build/dataloaders/findIdsDataLoader.js.map +1 -1
  27. package/build/dataloaders/findPaginatedDataLoader.cjs +2 -0
  28. package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
  29. package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
  30. package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
  31. package/build/dataloaders/findPaginatedDataLoader.js +2 -0
  32. package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
  33. package/build/index.cjs +6 -3
  34. package/build/index.cjs.map +1 -1
  35. package/build/index.d.cts +6 -4
  36. package/build/index.d.cts.map +1 -1
  37. package/build/index.d.mts +6 -4
  38. package/build/index.d.mts.map +1 -1
  39. package/build/index.js +6 -5
  40. package/build/index.js.map +1 -1
  41. package/build/keys.cjs +6 -1
  42. package/build/keys.cjs.map +1 -1
  43. package/build/keys.d.cts +3 -1
  44. package/build/keys.d.cts.map +1 -1
  45. package/build/keys.d.mts +3 -1
  46. package/build/keys.d.mts.map +1 -1
  47. package/build/keys.js +6 -2
  48. package/build/keys.js.map +1 -1
  49. package/build/queries/find/QueryParser.cjs +1 -2
  50. package/build/queries/find/QueryParser.cjs.map +1 -1
  51. package/build/queries/find/QueryParser.d.cts.map +1 -1
  52. package/build/queries/find/QueryParser.d.mts.map +1 -1
  53. package/build/queries/find/QueryParser.js +2 -3
  54. package/build/queries/find/QueryParser.js.map +1 -1
  55. package/build/queries/find/QueryVisitor.cjs +17 -0
  56. package/build/queries/find/QueryVisitor.cjs.map +1 -1
  57. package/build/queries/find/QueryVisitor.d.cts +3 -1
  58. package/build/queries/find/QueryVisitor.d.cts.map +1 -1
  59. package/build/queries/find/QueryVisitor.d.mts +3 -1
  60. package/build/queries/find/QueryVisitor.d.mts.map +1 -1
  61. package/build/queries/find/QueryVisitor.js +17 -1
  62. package/build/queries/find/QueryVisitor.js.map +1 -1
  63. package/build/queries/sql/Expr.cjs +18 -1
  64. package/build/queries/sql/Expr.cjs.map +1 -1
  65. package/build/queries/sql/Expr.d.cts +13 -3
  66. package/build/queries/sql/Expr.d.cts.map +1 -1
  67. package/build/queries/sql/Expr.d.mts +13 -3
  68. package/build/queries/sql/Expr.d.mts.map +1 -1
  69. package/build/queries/sql/Expr.js +18 -2
  70. package/build/queries/sql/Expr.js.map +1 -1
  71. package/build/queries/sql/JoinTree.cjs +72 -0
  72. package/build/queries/sql/JoinTree.cjs.map +1 -0
  73. package/build/queries/sql/JoinTree.d.cts +107 -0
  74. package/build/queries/sql/JoinTree.d.cts.map +1 -0
  75. package/build/queries/sql/JoinTree.d.mts +107 -0
  76. package/build/queries/sql/JoinTree.d.mts.map +1 -0
  77. package/build/queries/sql/JoinTree.js +71 -0
  78. package/build/queries/sql/JoinTree.js.map +1 -0
  79. package/build/queries/sql/Tables.cjs +103 -6
  80. package/build/queries/sql/Tables.cjs.map +1 -1
  81. package/build/queries/sql/Tables.d.cts +72 -13
  82. package/build/queries/sql/Tables.d.cts.map +1 -1
  83. package/build/queries/sql/Tables.d.mts +72 -13
  84. package/build/queries/sql/Tables.d.mts.map +1 -1
  85. package/build/queries/sql/Tables.js +101 -10
  86. package/build/queries/sql/Tables.js.map +1 -1
  87. package/build/queries/sql/custom.cjs +52 -0
  88. package/build/queries/sql/custom.cjs.map +1 -0
  89. package/build/queries/sql/custom.d.cts +85 -0
  90. package/build/queries/sql/custom.d.cts.map +1 -0
  91. package/build/queries/sql/custom.d.mts +85 -0
  92. package/build/queries/sql/custom.d.mts.map +1 -0
  93. package/build/queries/sql/custom.js +49 -0
  94. package/build/queries/sql/custom.js.map +1 -0
  95. package/build/queries/sql/execute.cjs +68 -28
  96. package/build/queries/sql/execute.cjs.map +1 -1
  97. package/build/queries/sql/execute.d.cts +110 -11
  98. package/build/queries/sql/execute.d.cts.map +1 -1
  99. package/build/queries/sql/execute.d.mts +110 -11
  100. package/build/queries/sql/execute.d.mts.map +1 -1
  101. package/build/queries/sql/execute.js +69 -29
  102. package/build/queries/sql/execute.js.map +1 -1
  103. package/build/queries/sql/expressions/types.d.cts +5 -5
  104. package/build/queries/sql/expressions/types.d.cts.map +1 -1
  105. package/build/queries/sql/expressions/types.d.mts +5 -5
  106. package/build/queries/sql/expressions/types.d.mts.map +1 -1
  107. package/build/queries/sql/keywords.cjs +1 -1
  108. package/build/queries/sql/keywords.cjs.map +1 -1
  109. package/build/queries/sql/keywords.d.cts +1 -1
  110. package/build/queries/sql/keywords.d.mts +1 -1
  111. package/build/queries/sql/keywords.js +1 -1
  112. package/build/queries/sql/keywords.js.map +1 -1
  113. package/build/queries/sql/query.cjs +100 -38
  114. package/build/queries/sql/query.cjs.map +1 -1
  115. package/build/queries/sql/query.d.cts +96 -46
  116. package/build/queries/sql/query.d.cts.map +1 -1
  117. package/build/queries/sql/query.d.mts +96 -46
  118. package/build/queries/sql/query.d.mts.map +1 -1
  119. package/build/queries/sql/query.js +102 -40
  120. package/build/queries/sql/query.js.map +1 -1
  121. package/build/queries/valueFilters.cjs +28 -36
  122. package/build/queries/valueFilters.cjs.map +1 -1
  123. package/build/queries/valueFilters.d.cts +2 -4
  124. package/build/queries/valueFilters.d.cts.map +1 -1
  125. package/build/queries/valueFilters.d.mts +2 -4
  126. package/build/queries/valueFilters.d.mts.map +1 -1
  127. package/build/queries/valueFilters.js +29 -36
  128. package/build/queries/valueFilters.js.map +1 -1
  129. package/build/serde/serde.cjs.map +1 -1
  130. package/build/serde/serde.js.map +1 -1
  131. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
1
  import { ColumnsOf, TypeMapEntry } from "../../typeMap.cjs";
2
2
  import { SqlCondition } from "../conditions.cjs";
3
- import { CheckReadQuery, CheckScope, CheckSetQuery, EntityHydrator, NameOf, Plan, Query, QueryJoins, QueryRow, ReadQueryRow, SetOperand, SetOperation, SetQuery, Subquery, WithInput, entityQueryBrand, subqueryBrand } from "./query.cjs";
4
- import { ExprBrand, ExprLike, exprBrand } from "./Expr.cjs";
3
+ import { CustomColumnInputs, CustomColumnValue, CustomColumnsOf, CustomTableFor } from "./custom.cjs";
5
4
  import { TableFor, tableMgmt } from "./Tables.cjs";
5
+ import { CheckReadQuery, CheckScope, CheckSetQuery, EntityHydrator, NameOf, Plan, Query, QueryJoinInput, QueryRow, ReadQueryRow, SetOperand, SetOperation, SetQuery, Subquery, WithInput, entityQueryBrand, subqueryBrand } from "./query.cjs";
6
+ import { ExprBrand, ExprLike, exprBrand } from "./Expr.cjs";
6
7
  import { DriverQueryResult } from "../../drivers/Driver.cjs";
7
8
  import { IdOf } from "../../EntityManager.cjs";
8
9
  import { Entity } from "../../Entity.cjs";
@@ -35,7 +36,7 @@ type InsertStatement<T extends Entity, R extends MutationReturning | undefined =
35
36
  /** CTEs to add to a `WITH` before the INSERT; see `Clauses.with`. */
36
37
  readonly with?: WithInput;
37
38
  } & NoMutationReadClauses & ({
38
- readonly values: InsertValues<T> | readonly InsertValues<T>[];
39
+ readonly values: readonly InsertValues<T>[];
39
40
  readonly from?: never;
40
41
  } | {
41
42
  readonly from: Q & CheckInsertSource<T, Q>;
@@ -70,7 +71,7 @@ type MutationStatement<T extends Entity, R extends MutationReturning | undefined
70
71
  /** Inference starts with the literal POJO; CheckMutation checks its target and every supplied key. */
71
72
  type MutationInput = ({
72
73
  readonly insert: TableFor<Entity>;
73
- readonly values: object | readonly object[];
74
+ readonly values: readonly object[];
74
75
  readonly from?: never;
75
76
  } | {
76
77
  readonly insert: TableFor<Entity>;
@@ -81,6 +82,19 @@ type MutationInput = ({
81
82
  readonly set: object;
82
83
  } | {
83
84
  readonly delete: TableFor<Entity>;
85
+ } | {
86
+ readonly insert: CustomTableFor;
87
+ readonly values: readonly object[];
88
+ readonly from?: never;
89
+ } | {
90
+ readonly insert: CustomTableFor;
91
+ readonly from: SetOperand;
92
+ readonly values?: never;
93
+ } | {
94
+ readonly update: CustomTableFor;
95
+ readonly set: object;
96
+ } | {
97
+ readonly delete: CustomTableFor;
84
98
  }) & {
85
99
  readonly returning?: MutationReturning;
86
100
  readonly with?: WithInput;
@@ -90,12 +104,12 @@ type MutationRow<M> = M extends {
90
104
  readonly returning?: infer R;
91
105
  } ? R extends MutationReturning ? R extends ExprLike<unknown> ? QueryRow<R> : { -readonly [K in keyof QueryRow<R>]: QueryRow<R>[K]; } : never : never;
92
106
  /** Checks nonliteral statements as well as fresh literals without widening their inferred result. */
93
- type CheckMutation<M> = M extends unknown ? TargetEntity<M> extends (infer T extends Entity) ? TypeMapEntry<T, "supportsEmExecute"> extends true ? { readonly [K in keyof M]: K extends MutationClause<M> ? unknown : never; } & {
107
+ type CheckMutation<M> = M extends unknown ? [CustomColumnsOf<TargetTable<M>>] extends [never] ? TargetEntity<M> extends (infer T extends Entity) ? TypeMapEntry<T, "supportsEmExecute"> extends true ? { readonly [K in keyof M]: K extends MutationClause<M> ? unknown : never; } & {
94
108
  readonly returning?: M extends {
95
109
  readonly returning?: infer R;
96
110
  } ? CheckReturning<R, NameOf<TargetTable<M>>> : never;
97
111
  } & ((M extends {
98
- readonly values: infer V;
112
+ readonly values: infer V extends readonly unknown[];
99
113
  } ? {
100
114
  readonly values: CheckValues<T, V>;
101
115
  } : never) | (M extends {
@@ -108,7 +122,7 @@ type CheckMutation<M> = M extends unknown ? TargetEntity<M> extends (infer T ext
108
122
  readonly set: CheckAssignments<V, UpdateValues<T>, NameOf<TargetTable<M>>>;
109
123
  } : never) | (M extends {
110
124
  readonly delete: unknown;
111
- } ? unknown : never)) : "SQL mutations require a supported non-inherited target and regenerated metadata" : never : never;
125
+ } ? unknown : never)) : "SQL mutations require a supported non-inherited target and regenerated metadata" : never : CheckCustomMutation<M> : never;
112
126
  /** Classifies mutation roots before EntityManager applies write permissions, including malformed roots. */
113
127
  declare function isMutation(arg: unknown): boolean;
114
128
  /**
@@ -119,12 +133,21 @@ declare function isMutation(arg: unknown): boolean;
119
133
  declare function parseStatement(arg: unknown): Plan | undefined;
120
134
  /** Retains native counts even when no rows return, and propagates decoding failures after execution. */
121
135
  declare function decodeStatementResult(em: EntityHydrator, plan: Plan, result: DriverQueryResult): ExecuteResult<unknown>;
136
+ /** An entity table whose generated metadata permits direct SQL mutations. */
122
137
  type MutationTarget<T extends Entity> = TableFor<T> & (TypeMapEntry<T, "supportsEmExecute"> extends true ? unknown : never);
138
+ /** Shared filtering and full-table consent clauses for UPDATE and DELETE. */
123
139
  type MutationFilter = {
124
- readonly where?: SqlCondition | ExprLike<boolean>;
140
+ /**
141
+ * An `{ and: [...] }` or `{ or: [...] }` group, a boolean expression, or a bare condition such as `a.age.gte(18)`.
142
+ *
143
+ * Arrays are shorthand for `{ and: [...] }`; undefined conditions are pruned.
144
+ */
145
+ readonly where?: SqlCondition | ExprLike<boolean> | readonly (SqlCondition | undefined)[];
146
+ /** Allows a supplied where to be undefined or fully pruned; unnecessary when where is omitted. */
125
147
  readonly allowAll?: boolean;
126
148
  readonly softDeletes?: "include" | "exclude";
127
149
  };
150
+ /** Read-only query clauses that mutations explicitly reject. */
128
151
  type NoMutationReadClauses = Partial<Record<"select" | "join" | "groupBy" | "having" | "orderBy" | "limit" | "offset" | "distinct" | "pruneJoins" | "as" | "union" | "unionAll" | "intersect" | "intersectAll" | "except" | "exceptAll" | "ctes" | "using" | "onConflict", never>>;
129
152
  /** Column keys allowed in INSERT, i.e. Book's optional `id` and required `authorId`. */
130
153
  type InsertKey<T> = { [K in keyof ColumnsOf<T>]: ColumnsOf<T>[K] extends {
@@ -144,31 +167,105 @@ type DomainValue<T, K extends keyof ColumnsOf<T>> = K extends "id" ? IdOf<T> : C
144
167
  } ? IdOf<U> : ColumnsOf<T>[K] extends {
145
168
  type: infer V;
146
169
  } ? V : never;
170
+ /** A modeled column's domain value with SQL nullability applied. */
147
171
  type SqlValue<T, K extends keyof ColumnsOf<T>> = DomainValue<T, K> | (ColumnsOf<T>[K] extends {
148
172
  nullable: true;
149
173
  } ? null : never);
174
+ /** A modeled-column value, entity reference, or SQL expression that produces one. */
150
175
  type Assignment<T, K extends keyof ColumnsOf<T>> = SqlValue<T, K> | ExprLike<SqlValue<T, K>> | (K extends "id" ? never : ColumnsOf<T>[K] extends {
151
176
  entity: infer U;
152
177
  } ? U : never);
178
+ /** A custom column's declared value with SQL nullability applied. */
179
+ type CustomSqlValue<I> = CustomColumnValue<I> | (I extends {
180
+ nullable: true;
181
+ } ? null : never);
182
+ /** A custom-column value or SQL expression that produces one. */
183
+ type CustomAssignment<I> = CustomSqlValue<I> | ExprLike<CustomSqlValue<I>>;
184
+ /** Custom-column keys accepted by INSERT, excluding generated columns. */
185
+ type CustomInsertKey<C extends CustomColumnInputs> = { [K in keyof C]: C[K] extends {
186
+ generated: true;
187
+ } ? never : K; }[keyof C];
188
+ /** Custom-column keys each INSERT row must supply because they have no default and are not nullable. */
189
+ type CustomRequiredInsertKey<C extends CustomColumnInputs> = { [K in CustomInsertKey<C>]: C[K] extends {
190
+ nullable: true;
191
+ } | {
192
+ hasDefault: true;
193
+ } ? never : K; }[CustomInsertKey<C>];
194
+ /** Custom-column keys accepted by UPDATE, excluding generated columns and the physical primary key. */
195
+ type CustomUpdateKey<C extends CustomColumnInputs> = { [K in keyof C]: C[K] extends {
196
+ generated: true;
197
+ } ? never : K extends "id" ? never : C[K] extends {
198
+ columnName: "id";
199
+ } ? never : K; }[keyof C];
200
+ /** Values accepted by INSERT for a custom table's declared columns. */
201
+ type CustomInsertValues<C extends CustomColumnInputs> = { [K in CustomRequiredInsertKey<C>]: CustomAssignment<C[K]>; } & { [K in Exclude<CustomInsertKey<C>, CustomRequiredInsertKey<C>>]?: CustomAssignment<C[K]> | undefined; };
202
+ /** Assignments accepted by UPDATE for a custom table's writable columns. */
203
+ type CustomUpdateValues<C extends CustomColumnInputs> = { [K in CustomUpdateKey<C>]?: CustomAssignment<C[K]> | undefined; };
204
+ /** Named row shape that an INSERT SELECT source must produce for a custom table. */
205
+ type CustomInsertSourceRow<C extends CustomColumnInputs> = { [K in CustomRequiredInsertKey<C>]: CustomSqlValue<C[K]>; } & { [K in Exclude<CustomInsertKey<C>, CustomRequiredInsertKey<C>>]?: CustomSqlValue<C[K]>; };
206
+ /** Named row shape that an entity INSERT SELECT source must produce. */
153
207
  type InsertSourceRow<T> = { [K in RequiredInsertKey<T>]: SqlValue<T, K>; } & { [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: SqlValue<T, K>; };
208
+ /** Named expression projection accepted from an entity INSERT SELECT source. */
154
209
  type InsertProjection<T> = { [K in RequiredInsertKey<T>]: ExprLike<SqlValue<T, K>>; } & { [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: ExprLike<SqlValue<T, K>>; };
210
+ /** Collects the keys from every member of a union instead of only their shared keys. */
155
211
  type UnionKeys<V> = V extends unknown ? keyof V : never;
156
212
  /** Collects every alternative before scope checking; a valid branch cannot hide an unrelated alias. */
157
213
  type UnionValue<V, K extends PropertyKey> = V extends unknown ? (K extends keyof V ? V[K] : never) : never;
214
+ /** Extracts the source names carried by a SQL expression. */
158
215
  type ExprSource<V> = V extends {
159
216
  readonly [exprBrand]: ExprBrand<unknown, infer Src>;
160
217
  } ? Src : never;
218
+ /** Rejects expressions that reference tables outside the statement's allowed scope. */
161
219
  type CheckExprScope<V, Scope> = string extends ExprSource<V> ? unknown : [Exclude<ExprSource<V>, Scope>] extends [never] ? unknown : "Expression source is not in the statement scope";
220
+ /** Extracts each expression from a scalar or named RETURNING projection. */
162
221
  type ReturningExpr<R> = R extends ExprLike<unknown> ? R : R extends undefined ? never : R[keyof R];
222
+ /** Detects an empty named RETURNING projection. */
163
223
  type EmptyReturning<R> = R extends object ? (keyof R extends never ? true : false) : false;
224
+ /** Rejects empty RETURNING objects and expressions outside the target scope. */
164
225
  type CheckReturning<R, Scope> = true extends EmptyReturning<R> ? never : CheckExprScope<ReturningExpr<R>, Scope>;
226
+ /** Validates assignment keys, values, and expression sources without distributing union inputs. */
165
227
  type CheckAssignments<V, Allowed, Scope> = [Exclude<UnionKeys<V>, keyof Allowed>] extends [never] ? Allowed & { [K in UnionKeys<V>]?: CheckExprScope<UnionValue<V, K>, Scope>; } : "SQL assignments have unknown target fields";
166
- type CheckValues<T extends Entity, V> = ([Extract<V, readonly unknown[]>] extends [never] ? never : readonly CheckAssignments<Extract<V, readonly unknown[]>[number], InsertValues<T>, never>[]) | ([Exclude<V, readonly unknown[]>] extends [never] ? never : CheckAssignments<Exclude<V, readonly unknown[]>, InsertValues<T>, never>);
228
+ /** Checks every entity INSERT row in a readonly collection against writable columns. */
229
+ type CheckValues<T extends Entity, V extends readonly unknown[]> = readonly CheckAssignments<V[number], InsertValues<T>, never>[];
230
+ /**
231
+ * Checks a custom-table mutation against its declared primitive columns.
232
+ *
233
+ * Only clauses for the selected operation are allowed, and `softDeletes` is rejected because there is no entity
234
+ * policy. Assignments use declaration keys and honor nullability, defaults, and generated columns. INSERT VALUES
235
+ * cannot read the target row, while UPDATE SET and RETURNING can. INSERT SELECT must be a valid named read with all
236
+ * required columns and compatible declared value types; runtime checks also compare its SQL codecs and nullability.
237
+ */
238
+ type CheckCustomMutation<M> = { readonly [K in keyof M]: K extends MutationClause<M> ? (K extends "softDeletes" ? never : unknown) : never; } & {
239
+ readonly returning?: M extends {
240
+ readonly returning?: infer R;
241
+ } ? CheckReturning<R, NameOf<TargetTable<M>>> : never;
242
+ } & ((M extends {
243
+ readonly values: infer V extends readonly unknown[];
244
+ } ? {
245
+ readonly values: CheckCustomValues<CustomColumnsOf<TargetTable<M>>, V>;
246
+ } : never) | (M extends {
247
+ readonly from: infer Q extends SetOperand;
248
+ } ? {
249
+ readonly from: CheckCustomInsertSource<CustomColumnsOf<TargetTable<M>>, Q>;
250
+ } : never) | (M extends {
251
+ readonly set: infer V;
252
+ } ? {
253
+ readonly set: CheckAssignments<V, CustomUpdateValues<CustomColumnsOf<TargetTable<M>>>, NameOf<TargetTable<M>>>;
254
+ } : never) | (M extends {
255
+ readonly delete: unknown;
256
+ } ? unknown : never));
257
+ /** Checks every custom INSERT row in a readonly collection against declared writable columns. */
258
+ type CheckCustomValues<C extends CustomColumnInputs, V extends readonly unknown[]> = readonly CheckAssignments<V[number], CustomInsertValues<C>, never>[];
259
+ /** Checks a custom INSERT SELECT's named outputs, required columns, values, and read source. */
260
+ type CheckCustomInsertSource<C extends CustomColumnInputs, Q> = SetOperand extends Q ? "INSERT source type lost its select keys; use `satisfies Query` or `satisfies SetQuery` instead of a type annotation" : ReadQueryRow<Q> extends CustomInsertSourceRow<C> ? Exclude<UnionKeys<ReadQueryRow<Q>>, CustomInsertKey<C>> extends never ? CheckReadQuery<Q> & CheckSourceScope<Q> & (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown) : "INSERT SELECT has unknown target fields" : "INSERT SELECT requires compatible values for all SQL-required fields";
261
+ /** Checks every SELECT expression against the tables visible within its read-query branch. */
167
262
  type CheckSourceScope<Q> = Q extends {
168
263
  readonly select: infer S;
169
264
  readonly from: infer F;
170
- } ? CheckScope<S, F, "join" extends keyof Q ? Extract<Q[keyof Q & "join"], QueryJoins> : []> : { [K in keyof Q]: K extends SetOperation ? Q[K] extends readonly unknown[] ? { [I in keyof Q[K]]: CheckSourceScope<Q[K][I]>; } : unknown : unknown; };
171
- type CheckInsertSource<T, Q extends SetOperand> = SetOperand extends Q ? "INSERT source was typed too generically; retain its named output fields" : ReadQueryRow<Q> extends InsertSourceRow<T> ? Exclude<UnionKeys<ReadQueryRow<Q>>, InsertKey<T>> extends never ? CheckReadQuery<Q> & CheckSourceScope<Q> & (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown) : "INSERT SELECT has unknown target fields" : "INSERT SELECT requires compatible values for all SQL-required fields";
265
+ } ? CheckScope<S, F, "join" extends keyof Q ? Extract<Q[keyof Q & "join"], QueryJoinInput> : []> : { [K in keyof Q]: K extends SetOperation ? Q[K] extends readonly unknown[] ? { [I in keyof Q[K]]: CheckSourceScope<Q[K][I]>; } : unknown : unknown; };
266
+ /** Checks an entity INSERT SELECT's named outputs, required columns, values, and read source. */
267
+ type CheckInsertSource<T, Q extends SetOperand> = SetOperand extends Q ? "INSERT source type lost its select keys; use `satisfies Query` or `satisfies SetQuery` instead of a type annotation" : ReadQueryRow<Q> extends InsertSourceRow<T> ? Exclude<UnionKeys<ReadQueryRow<Q>>, InsertKey<T>> extends never ? CheckReadQuery<Q> & CheckSourceScope<Q> & (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown) : "INSERT SELECT has unknown target fields" : "INSERT SELECT requires compatible values for all SQL-required fields";
268
+ /** Extracts the entity type from any mutation target clause. */
172
269
  type TargetEntity<M> = M extends {
173
270
  readonly insert: TableFor<infer T>;
174
271
  } | {
@@ -176,6 +273,7 @@ type TargetEntity<M> = M extends {
176
273
  } | {
177
274
  readonly delete: TableFor<infer T>;
178
275
  } ? T : never;
276
+ /** Extracts the table handle from any mutation target clause. */
179
277
  type TargetTable<M> = M extends {
180
278
  readonly insert: infer A;
181
279
  } | {
@@ -183,6 +281,7 @@ type TargetTable<M> = M extends {
183
281
  } | {
184
282
  readonly delete: infer A;
185
283
  } ? A : never;
284
+ /** Clauses permitted by the selected INSERT, UPDATE, or DELETE operation. */
186
285
  type MutationClause<M> = "returning" | "with" | (M extends {
187
286
  readonly insert: unknown;
188
287
  } ? "insert" | (M extends {
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.cts","names":[],"sources":["../../../src/queries/sql/execute.ts"],"mappings":";;;;;;;;;;UA4CiB,cAAc;EAC7B;EACA,MAAM;;;KAII,qBAAqB,oBAAoB,SAAS,eAAe;YACjE;YACA;YACA;;;KAIA,aAAa,UAAU,aAChC,KAAK,kBAAkB,KAAK,WAAW,GAAG,WAE1C,KAAK,QAAQ,UAAU,IAAI,kBAAkB,OAAO,WAAW,GAAG;;KAIzD,aAAa,UAAU,aAChC,KAAK,UAAU,MAAM,WAAW,GAAG;;KAI1B,gBACV,UAAU,QACV,UAAU,gCAAgC,+BAC1C,UAAU,aAAa,MAAM,iBAAiB,UAAU,SAAS,gBAAgB;WAExE,QAAQ,eAAe;WACvB,YAAY;WACZ;WACA;WACA;WACA;WACA;WACA;;WAEA,OAAO;IACd;WAEa,QAAQ,aAAa,cAAc,aAAa;WAAe;;WAC/D,MAAM,IAAI,kBAAkB,GAAG;WAAa;;;KAIjD,gBACV,UAAU,QACV,UAAU,gCAAgC;WAEjC,QAAQ,eAAe;WACvB,KAAK,aAAa;WAClB,YAAY;WACZ;WACA;WACA;WACA;;WAEA,OAAO;IACd,iBACF;;K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;KAKhE,iBAAiB,KAAK;WAAqB,cAAc;WAAY,YAAY;IAClF,WAAW,GAAG,wBAAwB,IAAI,QAAQ,QAAQ,aAAa,2BAEpE,WAAW,IAAI,UAAU,eACtB,EAAE,mCACG,WAAW,EAAE,KAAK,iBAAiB,EAAE,GAAG;;KAMlD,kBAAkB,GAAG,UAAU,cAAc,mBAAmB,4HAEjE,aAAa,WAAW,gBAAgB,KACtC,QAAQ,UAAU,aAAa,KAAK,UAAU,oBAC5C,eAAe,KACb,iBAAiB,MAChB,UAAU,kBAAkB,gBAAgB,cAAc;;KAKhE,aAAa,KAAK;WACR,QAAQ,eAAe;;WACvB,QAAQ,eAAe;;WACvB,QAAQ,eAAe;IAClC;;KAIC,YAAY,KAAK;WACP,cAAc;;WACd,cAAc;;WACd,cAAc;IACzB;;KAIC,eAAe,6BAGf;WAAqB;gBACN;WAAqB;iEACO;WAAqB"}
@@ -1,8 +1,9 @@
1
1
  import { ColumnsOf, TypeMapEntry } from "../../typeMap.mjs";
2
2
  import { SqlCondition } from "../conditions.mjs";
3
- import { CheckReadQuery, CheckScope, CheckSetQuery, EntityHydrator, NameOf, Plan, Query, QueryJoins, QueryRow, ReadQueryRow, SetOperand, SetOperation, SetQuery, Subquery, WithInput, entityQueryBrand, subqueryBrand } from "./query.mjs";
4
- import { ExprBrand, ExprLike, exprBrand } from "./Expr.mjs";
3
+ import { CustomColumnInputs, CustomColumnValue, CustomColumnsOf, CustomTableFor } from "./custom.mjs";
5
4
  import { TableFor, tableMgmt } from "./Tables.mjs";
5
+ import { CheckReadQuery, CheckScope, CheckSetQuery, EntityHydrator, NameOf, Plan, Query, QueryJoinInput, QueryRow, ReadQueryRow, SetOperand, SetOperation, SetQuery, Subquery, WithInput, entityQueryBrand, subqueryBrand } from "./query.mjs";
6
+ import { ExprBrand, ExprLike, exprBrand } from "./Expr.mjs";
6
7
  import { DriverQueryResult } from "../../drivers/Driver.mjs";
7
8
  import { IdOf } from "../../EntityManager.mjs";
8
9
  import { Entity } from "../../Entity.mjs";
@@ -35,7 +36,7 @@ type InsertStatement<T extends Entity, R extends MutationReturning | undefined =
35
36
  /** CTEs to add to a `WITH` before the INSERT; see `Clauses.with`. */
36
37
  readonly with?: WithInput;
37
38
  } & NoMutationReadClauses & ({
38
- readonly values: InsertValues<T> | readonly InsertValues<T>[];
39
+ readonly values: readonly InsertValues<T>[];
39
40
  readonly from?: never;
40
41
  } | {
41
42
  readonly from: Q & CheckInsertSource<T, Q>;
@@ -70,7 +71,7 @@ type MutationStatement<T extends Entity, R extends MutationReturning | undefined
70
71
  /** Inference starts with the literal POJO; CheckMutation checks its target and every supplied key. */
71
72
  type MutationInput = ({
72
73
  readonly insert: TableFor<Entity>;
73
- readonly values: object | readonly object[];
74
+ readonly values: readonly object[];
74
75
  readonly from?: never;
75
76
  } | {
76
77
  readonly insert: TableFor<Entity>;
@@ -81,6 +82,19 @@ type MutationInput = ({
81
82
  readonly set: object;
82
83
  } | {
83
84
  readonly delete: TableFor<Entity>;
85
+ } | {
86
+ readonly insert: CustomTableFor;
87
+ readonly values: readonly object[];
88
+ readonly from?: never;
89
+ } | {
90
+ readonly insert: CustomTableFor;
91
+ readonly from: SetOperand;
92
+ readonly values?: never;
93
+ } | {
94
+ readonly update: CustomTableFor;
95
+ readonly set: object;
96
+ } | {
97
+ readonly delete: CustomTableFor;
84
98
  }) & {
85
99
  readonly returning?: MutationReturning;
86
100
  readonly with?: WithInput;
@@ -90,12 +104,12 @@ type MutationRow<M> = M extends {
90
104
  readonly returning?: infer R;
91
105
  } ? R extends MutationReturning ? R extends ExprLike<unknown> ? QueryRow<R> : { -readonly [K in keyof QueryRow<R>]: QueryRow<R>[K]; } : never : never;
92
106
  /** Checks nonliteral statements as well as fresh literals without widening their inferred result. */
93
- type CheckMutation<M> = M extends unknown ? TargetEntity<M> extends (infer T extends Entity) ? TypeMapEntry<T, "supportsEmExecute"> extends true ? { readonly [K in keyof M]: K extends MutationClause<M> ? unknown : never; } & {
107
+ type CheckMutation<M> = M extends unknown ? [CustomColumnsOf<TargetTable<M>>] extends [never] ? TargetEntity<M> extends (infer T extends Entity) ? TypeMapEntry<T, "supportsEmExecute"> extends true ? { readonly [K in keyof M]: K extends MutationClause<M> ? unknown : never; } & {
94
108
  readonly returning?: M extends {
95
109
  readonly returning?: infer R;
96
110
  } ? CheckReturning<R, NameOf<TargetTable<M>>> : never;
97
111
  } & ((M extends {
98
- readonly values: infer V;
112
+ readonly values: infer V extends readonly unknown[];
99
113
  } ? {
100
114
  readonly values: CheckValues<T, V>;
101
115
  } : never) | (M extends {
@@ -108,7 +122,7 @@ type CheckMutation<M> = M extends unknown ? TargetEntity<M> extends (infer T ext
108
122
  readonly set: CheckAssignments<V, UpdateValues<T>, NameOf<TargetTable<M>>>;
109
123
  } : never) | (M extends {
110
124
  readonly delete: unknown;
111
- } ? unknown : never)) : "SQL mutations require a supported non-inherited target and regenerated metadata" : never : never;
125
+ } ? unknown : never)) : "SQL mutations require a supported non-inherited target and regenerated metadata" : never : CheckCustomMutation<M> : never;
112
126
  /** Classifies mutation roots before EntityManager applies write permissions, including malformed roots. */
113
127
  declare function isMutation(arg: unknown): boolean;
114
128
  /**
@@ -119,12 +133,21 @@ declare function isMutation(arg: unknown): boolean;
119
133
  declare function parseStatement(arg: unknown): Plan | undefined;
120
134
  /** Retains native counts even when no rows return, and propagates decoding failures after execution. */
121
135
  declare function decodeStatementResult(em: EntityHydrator, plan: Plan, result: DriverQueryResult): ExecuteResult<unknown>;
136
+ /** An entity table whose generated metadata permits direct SQL mutations. */
122
137
  type MutationTarget<T extends Entity> = TableFor<T> & (TypeMapEntry<T, "supportsEmExecute"> extends true ? unknown : never);
138
+ /** Shared filtering and full-table consent clauses for UPDATE and DELETE. */
123
139
  type MutationFilter = {
124
- readonly where?: SqlCondition | ExprLike<boolean>;
140
+ /**
141
+ * An `{ and: [...] }` or `{ or: [...] }` group, a boolean expression, or a bare condition such as `a.age.gte(18)`.
142
+ *
143
+ * Arrays are shorthand for `{ and: [...] }`; undefined conditions are pruned.
144
+ */
145
+ readonly where?: SqlCondition | ExprLike<boolean> | readonly (SqlCondition | undefined)[];
146
+ /** Allows a supplied where to be undefined or fully pruned; unnecessary when where is omitted. */
125
147
  readonly allowAll?: boolean;
126
148
  readonly softDeletes?: "include" | "exclude";
127
149
  };
150
+ /** Read-only query clauses that mutations explicitly reject. */
128
151
  type NoMutationReadClauses = Partial<Record<"select" | "join" | "groupBy" | "having" | "orderBy" | "limit" | "offset" | "distinct" | "pruneJoins" | "as" | "union" | "unionAll" | "intersect" | "intersectAll" | "except" | "exceptAll" | "ctes" | "using" | "onConflict", never>>;
129
152
  /** Column keys allowed in INSERT, i.e. Book's optional `id` and required `authorId`. */
130
153
  type InsertKey<T> = { [K in keyof ColumnsOf<T>]: ColumnsOf<T>[K] extends {
@@ -144,31 +167,105 @@ type DomainValue<T, K extends keyof ColumnsOf<T>> = K extends "id" ? IdOf<T> : C
144
167
  } ? IdOf<U> : ColumnsOf<T>[K] extends {
145
168
  type: infer V;
146
169
  } ? V : never;
170
+ /** A modeled column's domain value with SQL nullability applied. */
147
171
  type SqlValue<T, K extends keyof ColumnsOf<T>> = DomainValue<T, K> | (ColumnsOf<T>[K] extends {
148
172
  nullable: true;
149
173
  } ? null : never);
174
+ /** A modeled-column value, entity reference, or SQL expression that produces one. */
150
175
  type Assignment<T, K extends keyof ColumnsOf<T>> = SqlValue<T, K> | ExprLike<SqlValue<T, K>> | (K extends "id" ? never : ColumnsOf<T>[K] extends {
151
176
  entity: infer U;
152
177
  } ? U : never);
178
+ /** A custom column's declared value with SQL nullability applied. */
179
+ type CustomSqlValue<I> = CustomColumnValue<I> | (I extends {
180
+ nullable: true;
181
+ } ? null : never);
182
+ /** A custom-column value or SQL expression that produces one. */
183
+ type CustomAssignment<I> = CustomSqlValue<I> | ExprLike<CustomSqlValue<I>>;
184
+ /** Custom-column keys accepted by INSERT, excluding generated columns. */
185
+ type CustomInsertKey<C extends CustomColumnInputs> = { [K in keyof C]: C[K] extends {
186
+ generated: true;
187
+ } ? never : K; }[keyof C];
188
+ /** Custom-column keys each INSERT row must supply because they have no default and are not nullable. */
189
+ type CustomRequiredInsertKey<C extends CustomColumnInputs> = { [K in CustomInsertKey<C>]: C[K] extends {
190
+ nullable: true;
191
+ } | {
192
+ hasDefault: true;
193
+ } ? never : K; }[CustomInsertKey<C>];
194
+ /** Custom-column keys accepted by UPDATE, excluding generated columns and the physical primary key. */
195
+ type CustomUpdateKey<C extends CustomColumnInputs> = { [K in keyof C]: C[K] extends {
196
+ generated: true;
197
+ } ? never : K extends "id" ? never : C[K] extends {
198
+ columnName: "id";
199
+ } ? never : K; }[keyof C];
200
+ /** Values accepted by INSERT for a custom table's declared columns. */
201
+ type CustomInsertValues<C extends CustomColumnInputs> = { [K in CustomRequiredInsertKey<C>]: CustomAssignment<C[K]>; } & { [K in Exclude<CustomInsertKey<C>, CustomRequiredInsertKey<C>>]?: CustomAssignment<C[K]> | undefined; };
202
+ /** Assignments accepted by UPDATE for a custom table's writable columns. */
203
+ type CustomUpdateValues<C extends CustomColumnInputs> = { [K in CustomUpdateKey<C>]?: CustomAssignment<C[K]> | undefined; };
204
+ /** Named row shape that an INSERT SELECT source must produce for a custom table. */
205
+ type CustomInsertSourceRow<C extends CustomColumnInputs> = { [K in CustomRequiredInsertKey<C>]: CustomSqlValue<C[K]>; } & { [K in Exclude<CustomInsertKey<C>, CustomRequiredInsertKey<C>>]?: CustomSqlValue<C[K]>; };
206
+ /** Named row shape that an entity INSERT SELECT source must produce. */
153
207
  type InsertSourceRow<T> = { [K in RequiredInsertKey<T>]: SqlValue<T, K>; } & { [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: SqlValue<T, K>; };
208
+ /** Named expression projection accepted from an entity INSERT SELECT source. */
154
209
  type InsertProjection<T> = { [K in RequiredInsertKey<T>]: ExprLike<SqlValue<T, K>>; } & { [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: ExprLike<SqlValue<T, K>>; };
210
+ /** Collects the keys from every member of a union instead of only their shared keys. */
155
211
  type UnionKeys<V> = V extends unknown ? keyof V : never;
156
212
  /** Collects every alternative before scope checking; a valid branch cannot hide an unrelated alias. */
157
213
  type UnionValue<V, K extends PropertyKey> = V extends unknown ? (K extends keyof V ? V[K] : never) : never;
214
+ /** Extracts the source names carried by a SQL expression. */
158
215
  type ExprSource<V> = V extends {
159
216
  readonly [exprBrand]: ExprBrand<unknown, infer Src>;
160
217
  } ? Src : never;
218
+ /** Rejects expressions that reference tables outside the statement's allowed scope. */
161
219
  type CheckExprScope<V, Scope> = string extends ExprSource<V> ? unknown : [Exclude<ExprSource<V>, Scope>] extends [never] ? unknown : "Expression source is not in the statement scope";
220
+ /** Extracts each expression from a scalar or named RETURNING projection. */
162
221
  type ReturningExpr<R> = R extends ExprLike<unknown> ? R : R extends undefined ? never : R[keyof R];
222
+ /** Detects an empty named RETURNING projection. */
163
223
  type EmptyReturning<R> = R extends object ? (keyof R extends never ? true : false) : false;
224
+ /** Rejects empty RETURNING objects and expressions outside the target scope. */
164
225
  type CheckReturning<R, Scope> = true extends EmptyReturning<R> ? never : CheckExprScope<ReturningExpr<R>, Scope>;
226
+ /** Validates assignment keys, values, and expression sources without distributing union inputs. */
165
227
  type CheckAssignments<V, Allowed, Scope> = [Exclude<UnionKeys<V>, keyof Allowed>] extends [never] ? Allowed & { [K in UnionKeys<V>]?: CheckExprScope<UnionValue<V, K>, Scope>; } : "SQL assignments have unknown target fields";
166
- type CheckValues<T extends Entity, V> = ([Extract<V, readonly unknown[]>] extends [never] ? never : readonly CheckAssignments<Extract<V, readonly unknown[]>[number], InsertValues<T>, never>[]) | ([Exclude<V, readonly unknown[]>] extends [never] ? never : CheckAssignments<Exclude<V, readonly unknown[]>, InsertValues<T>, never>);
228
+ /** Checks every entity INSERT row in a readonly collection against writable columns. */
229
+ type CheckValues<T extends Entity, V extends readonly unknown[]> = readonly CheckAssignments<V[number], InsertValues<T>, never>[];
230
+ /**
231
+ * Checks a custom-table mutation against its declared primitive columns.
232
+ *
233
+ * Only clauses for the selected operation are allowed, and `softDeletes` is rejected because there is no entity
234
+ * policy. Assignments use declaration keys and honor nullability, defaults, and generated columns. INSERT VALUES
235
+ * cannot read the target row, while UPDATE SET and RETURNING can. INSERT SELECT must be a valid named read with all
236
+ * required columns and compatible declared value types; runtime checks also compare its SQL codecs and nullability.
237
+ */
238
+ type CheckCustomMutation<M> = { readonly [K in keyof M]: K extends MutationClause<M> ? (K extends "softDeletes" ? never : unknown) : never; } & {
239
+ readonly returning?: M extends {
240
+ readonly returning?: infer R;
241
+ } ? CheckReturning<R, NameOf<TargetTable<M>>> : never;
242
+ } & ((M extends {
243
+ readonly values: infer V extends readonly unknown[];
244
+ } ? {
245
+ readonly values: CheckCustomValues<CustomColumnsOf<TargetTable<M>>, V>;
246
+ } : never) | (M extends {
247
+ readonly from: infer Q extends SetOperand;
248
+ } ? {
249
+ readonly from: CheckCustomInsertSource<CustomColumnsOf<TargetTable<M>>, Q>;
250
+ } : never) | (M extends {
251
+ readonly set: infer V;
252
+ } ? {
253
+ readonly set: CheckAssignments<V, CustomUpdateValues<CustomColumnsOf<TargetTable<M>>>, NameOf<TargetTable<M>>>;
254
+ } : never) | (M extends {
255
+ readonly delete: unknown;
256
+ } ? unknown : never));
257
+ /** Checks every custom INSERT row in a readonly collection against declared writable columns. */
258
+ type CheckCustomValues<C extends CustomColumnInputs, V extends readonly unknown[]> = readonly CheckAssignments<V[number], CustomInsertValues<C>, never>[];
259
+ /** Checks a custom INSERT SELECT's named outputs, required columns, values, and read source. */
260
+ type CheckCustomInsertSource<C extends CustomColumnInputs, Q> = SetOperand extends Q ? "INSERT source type lost its select keys; use `satisfies Query` or `satisfies SetQuery` instead of a type annotation" : ReadQueryRow<Q> extends CustomInsertSourceRow<C> ? Exclude<UnionKeys<ReadQueryRow<Q>>, CustomInsertKey<C>> extends never ? CheckReadQuery<Q> & CheckSourceScope<Q> & (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown) : "INSERT SELECT has unknown target fields" : "INSERT SELECT requires compatible values for all SQL-required fields";
261
+ /** Checks every SELECT expression against the tables visible within its read-query branch. */
167
262
  type CheckSourceScope<Q> = Q extends {
168
263
  readonly select: infer S;
169
264
  readonly from: infer F;
170
- } ? CheckScope<S, F, "join" extends keyof Q ? Extract<Q[keyof Q & "join"], QueryJoins> : []> : { [K in keyof Q]: K extends SetOperation ? Q[K] extends readonly unknown[] ? { [I in keyof Q[K]]: CheckSourceScope<Q[K][I]>; } : unknown : unknown; };
171
- type CheckInsertSource<T, Q extends SetOperand> = SetOperand extends Q ? "INSERT source was typed too generically; retain its named output fields" : ReadQueryRow<Q> extends InsertSourceRow<T> ? Exclude<UnionKeys<ReadQueryRow<Q>>, InsertKey<T>> extends never ? CheckReadQuery<Q> & CheckSourceScope<Q> & (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown) : "INSERT SELECT has unknown target fields" : "INSERT SELECT requires compatible values for all SQL-required fields";
265
+ } ? CheckScope<S, F, "join" extends keyof Q ? Extract<Q[keyof Q & "join"], QueryJoinInput> : []> : { [K in keyof Q]: K extends SetOperation ? Q[K] extends readonly unknown[] ? { [I in keyof Q[K]]: CheckSourceScope<Q[K][I]>; } : unknown : unknown; };
266
+ /** Checks an entity INSERT SELECT's named outputs, required columns, values, and read source. */
267
+ type CheckInsertSource<T, Q extends SetOperand> = SetOperand extends Q ? "INSERT source type lost its select keys; use `satisfies Query` or `satisfies SetQuery` instead of a type annotation" : ReadQueryRow<Q> extends InsertSourceRow<T> ? Exclude<UnionKeys<ReadQueryRow<Q>>, InsertKey<T>> extends never ? CheckReadQuery<Q> & CheckSourceScope<Q> & (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown) : "INSERT SELECT has unknown target fields" : "INSERT SELECT requires compatible values for all SQL-required fields";
268
+ /** Extracts the entity type from any mutation target clause. */
172
269
  type TargetEntity<M> = M extends {
173
270
  readonly insert: TableFor<infer T>;
174
271
  } | {
@@ -176,6 +273,7 @@ type TargetEntity<M> = M extends {
176
273
  } | {
177
274
  readonly delete: TableFor<infer T>;
178
275
  } ? T : never;
276
+ /** Extracts the table handle from any mutation target clause. */
179
277
  type TargetTable<M> = M extends {
180
278
  readonly insert: infer A;
181
279
  } | {
@@ -183,6 +281,7 @@ type TargetTable<M> = M extends {
183
281
  } | {
184
282
  readonly delete: infer A;
185
283
  } ? A : never;
284
+ /** Clauses permitted by the selected INSERT, UPDATE, or DELETE operation. */
186
285
  type MutationClause<M> = "returning" | "with" | (M extends {
187
286
  readonly insert: unknown;
188
287
  } ? "insert" | (M extends {
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.mts","names":[],"sources":["../../../src/queries/sql/execute.ts"],"mappings":";;;;;;;;;;UA4CiB,cAAc;EAC7B;EACA,MAAM;;;KAII,qBAAqB,oBAAoB,SAAS,eAAe;YACjE;YACA;YACA;;;KAIA,aAAa,UAAU,aAChC,KAAK,kBAAkB,KAAK,WAAW,GAAG,WAE1C,KAAK,QAAQ,UAAU,IAAI,kBAAkB,OAAO,WAAW,GAAG;;KAIzD,aAAa,UAAU,aAChC,KAAK,UAAU,MAAM,WAAW,GAAG;;KAI1B,gBACV,UAAU,QACV,UAAU,gCAAgC,+BAC1C,UAAU,aAAa,MAAM,iBAAiB,UAAU,SAAS,gBAAgB;WAExE,QAAQ,eAAe;WACvB,YAAY;WACZ;WACA;WACA;WACA;WACA;WACA;;WAEA,OAAO;IACd;WAEa,QAAQ,aAAa,cAAc,aAAa;WAAe;;WAC/D,MAAM,IAAI,kBAAkB,GAAG;WAAa;;;KAIjD,gBACV,UAAU,QACV,UAAU,gCAAgC;WAEjC,QAAQ,eAAe;WACvB,KAAK,aAAa;WAClB,YAAY;WACZ;WACA;WACA;WACA;;WAEA,OAAO;IACd,iBACF;;KAGU,gBACV,UAAU,QACV,UAAU,gCAAgC;WAEjC,QAAQ,eAAe;WACvB,YAAY;WACZ;WACA;WACA;WACA;WACA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