turbine-orm 0.81.0 → 0.90.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.
- package/README.md +26 -25
- package/dist/checkout.d.ts +27 -2
- package/dist/checkout.js +75 -4
- package/dist/cjs/checkout.d.ts +27 -2
- package/dist/cjs/checkout.js +76 -3
- package/dist/cjs/cli/code-first-tags.d.ts +62 -0
- package/dist/cjs/cli/code-first-tags.js +124 -0
- package/dist/cjs/cli/compile-query.js +9 -0
- package/dist/cjs/cli/config.d.ts +35 -6
- package/dist/cjs/cli/config.js +17 -1
- package/dist/cjs/cli/destructive.d.ts +7 -4
- package/dist/cjs/cli/destructive.js +224 -20
- package/dist/cjs/cli/error-catalog.js +36 -0
- package/dist/cjs/cli/error-text.d.ts +15 -0
- package/dist/cjs/cli/error-text.js +40 -0
- package/dist/cjs/cli/index.d.ts +62 -4
- package/dist/cjs/cli/index.js +568 -108
- package/dist/cjs/cli/local-server-guard.d.ts +53 -0
- package/dist/cjs/cli/local-server-guard.js +119 -0
- package/dist/cjs/cli/local-server-output.d.ts +41 -0
- package/dist/cjs/cli/local-server-output.js +103 -0
- package/dist/cjs/cli/mcp.d.ts +8 -0
- package/dist/cjs/cli/mcp.js +121 -32
- package/dist/cjs/cli/migrate.d.ts +113 -5
- package/dist/cjs/cli/migrate.js +270 -21
- package/dist/cjs/cli/observe.d.ts +6 -1
- package/dist/cjs/cli/observe.js +85 -55
- package/dist/cjs/cli/pii-predicate-guard.d.ts +43 -23
- package/dist/cjs/cli/pii-predicate-guard.js +98 -37
- package/dist/cjs/cli/prisma-resolve.js +17 -13
- package/dist/cjs/cli/prisma-schema.js +12 -4
- package/dist/cjs/cli/studio-ui.generated.js +1 -1
- package/dist/cjs/cli/studio.d.ts +14 -2
- package/dist/cjs/cli/studio.js +244 -69
- package/dist/cjs/cli/ui.d.ts +1 -1
- package/dist/cjs/client.d.ts +558 -85
- package/dist/cjs/client.js +1270 -395
- package/dist/cjs/connection-guard.d.ts +13 -0
- package/dist/cjs/connection-guard.js +28 -0
- package/dist/cjs/connection-url.d.ts +51 -16
- package/dist/cjs/connection-url.js +67 -34
- package/dist/cjs/diagnostics.d.ts +81 -0
- package/dist/cjs/diagnostics.js +147 -0
- package/dist/cjs/dialect.d.ts +449 -20
- package/dist/cjs/dialect.js +117 -76
- package/dist/cjs/engine-config.d.ts +7 -6
- package/dist/cjs/errors.d.ts +126 -6
- package/dist/cjs/errors.js +256 -13
- package/dist/cjs/generate.d.ts +57 -7
- package/dist/cjs/generate.js +635 -279
- package/dist/cjs/global-filters-config.d.ts +59 -0
- package/dist/cjs/global-filters-config.js +367 -0
- package/dist/cjs/index.d.ts +9 -4
- package/dist/cjs/index.js +10 -2
- package/dist/cjs/introspect.d.ts +31 -6
- package/dist/cjs/introspect.js +108 -50
- package/dist/cjs/log-codes.d.ts +12 -0
- package/dist/cjs/log-codes.js +77 -0
- package/dist/cjs/logger.d.ts +87 -0
- package/dist/cjs/logger.js +98 -0
- package/dist/cjs/mssql.d.ts +8 -5
- package/dist/cjs/mssql.js +352 -65
- package/dist/cjs/mysql.d.ts +3 -5
- package/dist/cjs/mysql.js +420 -70
- package/dist/cjs/nested-write.d.ts +3 -0
- package/dist/cjs/nested-write.js +179 -114
- package/dist/cjs/pipeline-submittable.d.ts +12 -0
- package/dist/cjs/pipeline-submittable.js +118 -44
- package/dist/cjs/pipeline.js +21 -26
- package/dist/cjs/powdb-introspect.d.ts +5 -2
- package/dist/cjs/powdb-introspect.js +20 -15
- package/dist/cjs/powdb-shared.d.ts +36 -5
- package/dist/cjs/powdb-shared.js +67 -8
- package/dist/cjs/powdb.d.ts +4 -0
- package/dist/cjs/powdb.js +183 -51
- package/dist/cjs/powql.d.ts +394 -51
- package/dist/cjs/powql.js +1829 -284
- package/dist/cjs/prisma-compat.d.ts +23 -15
- package/dist/cjs/prisma-compat.js +507 -372
- package/dist/cjs/query/aggregates.d.ts +17 -1
- package/dist/cjs/query/aggregates.js +261 -29
- package/dist/cjs/query/batched-loader.d.ts +25 -6
- package/dist/cjs/query/batched-loader.js +103 -20
- package/dist/cjs/query/builder.d.ts +325 -184
- package/dist/cjs/query/builder.js +1452 -490
- package/dist/cjs/query/column-ref.d.ts +61 -0
- package/dist/cjs/query/column-ref.js +73 -0
- package/dist/cjs/query/compound-unique.d.ts +21 -0
- package/dist/cjs/query/compound-unique.js +98 -18
- package/dist/cjs/query/deferred.d.ts +53 -16
- package/dist/cjs/query/expr.d.ts +217 -0
- package/dist/cjs/query/expr.js +859 -0
- package/dist/cjs/query/filters.d.ts +155 -53
- package/dist/cjs/query/filters.js +613 -76
- package/dist/cjs/query/index.d.ts +2 -0
- package/dist/cjs/query/index.js +7 -1
- package/dist/cjs/query/json-value.d.ts +43 -0
- package/dist/cjs/query/json-value.js +59 -0
- package/dist/cjs/query/normalize-args.d.ts +87 -0
- package/dist/cjs/query/normalize-args.js +527 -0
- package/dist/cjs/query/option-surface.d.ts +16 -4
- package/dist/cjs/query/option-surface.js +57 -14
- package/dist/cjs/query/relation-names.d.ts +14 -0
- package/dist/cjs/query/relation-names.js +77 -18
- package/dist/cjs/query/relations.d.ts +30 -3
- package/dist/cjs/query/relations.js +219 -63
- package/dist/cjs/query/row-lock.d.ts +49 -0
- package/dist/cjs/query/row-lock.js +138 -0
- package/dist/cjs/query/sql-comment.d.ts +161 -0
- package/dist/cjs/query/sql-comment.js +381 -0
- package/dist/cjs/query/stream-idle.d.ts +132 -0
- package/dist/cjs/query/stream-idle.js +212 -0
- package/dist/cjs/query/table-client.d.ts +101 -0
- package/dist/cjs/query/table-client.js +74 -0
- package/dist/cjs/query/types.d.ts +677 -298
- package/dist/cjs/query/utils.d.ts +105 -6
- package/dist/cjs/query/utils.js +426 -19
- package/dist/cjs/query/warn-registry.d.ts +18 -0
- package/dist/cjs/query/warn-registry.js +18 -0
- package/dist/cjs/query/where-compile.d.ts +138 -14
- package/dist/cjs/query/where-compile.js +513 -29
- package/dist/cjs/query/where.d.ts +159 -59
- package/dist/cjs/query/where.js +716 -246
- package/dist/cjs/query/writes.d.ts +112 -50
- package/dist/cjs/query/writes.js +1498 -200
- package/dist/cjs/query-events.d.ts +4 -2
- package/dist/cjs/query-events.js +3 -1
- package/dist/cjs/realtime.d.ts +7 -3
- package/dist/cjs/realtime.js +13 -2
- package/dist/cjs/schema-builder.d.ts +55 -4
- package/dist/cjs/schema-builder.js +382 -18
- package/dist/cjs/schema-metadata.d.ts +21 -1
- package/dist/cjs/schema-metadata.js +29 -7
- package/dist/cjs/schema-sql.d.ts +75 -5
- package/dist/cjs/schema-sql.js +497 -45
- package/dist/cjs/schema.d.ts +26 -5
- package/dist/cjs/schema.js +110 -13
- package/dist/cjs/sql-placeholders.d.ts +56 -0
- package/dist/cjs/sql-placeholders.js +204 -0
- package/dist/cjs/sqlite.d.ts +75 -20
- package/dist/cjs/sqlite.js +593 -95
- package/dist/cjs/supplied-pool-types.d.ts +48 -0
- package/dist/cjs/supplied-pool-types.js +256 -0
- package/dist/cjs/transaction-control.d.ts +51 -0
- package/dist/cjs/transaction-control.js +316 -0
- package/dist/cjs/transaction-state.d.ts +342 -0
- package/dist/cjs/transaction-state.js +707 -0
- package/dist/cjs/typed-sql.d.ts +37 -3
- package/dist/cjs/typed-sql.js +102 -8
- package/dist/cli/code-first-tags.d.ts +62 -0
- package/dist/cli/code-first-tags.js +120 -0
- package/dist/cli/compile-query.js +9 -0
- package/dist/cli/config.d.ts +35 -6
- package/dist/cli/config.js +16 -1
- package/dist/cli/destructive.d.ts +7 -4
- package/dist/cli/destructive.js +224 -20
- package/dist/cli/error-catalog.js +36 -0
- package/dist/cli/error-text.d.ts +15 -0
- package/dist/cli/error-text.js +37 -0
- package/dist/cli/index.d.ts +62 -4
- package/dist/cli/index.js +569 -112
- package/dist/cli/local-server-guard.d.ts +53 -0
- package/dist/cli/local-server-guard.js +113 -0
- package/dist/cli/local-server-output.d.ts +41 -0
- package/dist/cli/local-server-output.js +98 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +121 -34
- package/dist/cli/migrate.d.ts +113 -5
- package/dist/cli/migrate.js +261 -21
- package/dist/cli/observe.d.ts +6 -1
- package/dist/cli/observe.js +84 -54
- package/dist/cli/pii-predicate-guard.d.ts +43 -23
- package/dist/cli/pii-predicate-guard.js +100 -35
- package/dist/cli/prisma-resolve.js +15 -11
- package/dist/cli/prisma-schema.js +12 -4
- package/dist/cli/studio-ui.generated.js +1 -1
- package/dist/cli/studio.d.ts +14 -2
- package/dist/cli/studio.js +246 -71
- package/dist/cli/ui.d.ts +1 -1
- package/dist/client.d.ts +558 -85
- package/dist/client.js +1275 -400
- package/dist/connection-guard.d.ts +13 -0
- package/dist/connection-guard.js +27 -0
- package/dist/connection-url.d.ts +51 -16
- package/dist/connection-url.js +63 -34
- package/dist/diagnostics.d.ts +81 -0
- package/dist/diagnostics.js +144 -0
- package/dist/dialect.d.ts +449 -20
- package/dist/dialect.js +115 -43
- package/dist/engine-config.d.ts +7 -6
- package/dist/errors.d.ts +126 -6
- package/dist/errors.js +252 -12
- package/dist/generate.d.ts +57 -7
- package/dist/generate.js +635 -281
- package/dist/global-filters-config.d.ts +59 -0
- package/dist/global-filters-config.js +361 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +4 -2
- package/dist/introspect.d.ts +31 -6
- package/dist/introspect.js +106 -50
- package/dist/log-codes.d.ts +12 -0
- package/dist/log-codes.js +74 -0
- package/dist/logger.d.ts +87 -0
- package/dist/logger.js +93 -0
- package/dist/mssql.d.ts +8 -5
- package/dist/mssql.js +354 -67
- package/dist/mysql.d.ts +3 -5
- package/dist/mysql.js +423 -73
- package/dist/nested-write.d.ts +3 -0
- package/dist/nested-write.js +177 -112
- package/dist/pipeline-submittable.d.ts +12 -0
- package/dist/pipeline-submittable.js +117 -44
- package/dist/pipeline.js +21 -26
- package/dist/powdb-introspect.d.ts +5 -2
- package/dist/powdb-introspect.js +21 -16
- package/dist/powdb-shared.d.ts +36 -5
- package/dist/powdb-shared.js +65 -8
- package/dist/powdb.d.ts +4 -0
- package/dist/powdb.js +183 -51
- package/dist/powql.d.ts +394 -51
- package/dist/powql.js +1836 -291
- package/dist/prisma-compat.d.ts +23 -15
- package/dist/prisma-compat.js +508 -373
- package/dist/query/aggregates.d.ts +17 -1
- package/dist/query/aggregates.js +263 -32
- package/dist/query/batched-loader.d.ts +25 -6
- package/dist/query/batched-loader.js +101 -21
- package/dist/query/builder.d.ts +325 -184
- package/dist/query/builder.js +1458 -495
- package/dist/query/column-ref.d.ts +61 -0
- package/dist/query/column-ref.js +66 -0
- package/dist/query/compound-unique.d.ts +21 -0
- package/dist/query/compound-unique.js +97 -19
- package/dist/query/deferred.d.ts +53 -16
- package/dist/query/expr.d.ts +217 -0
- package/dist/query/expr.js +848 -0
- package/dist/query/filters.d.ts +155 -53
- package/dist/query/filters.js +597 -72
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.js +4 -0
- package/dist/query/json-value.d.ts +43 -0
- package/dist/query/json-value.js +54 -0
- package/dist/query/normalize-args.d.ts +87 -0
- package/dist/query/normalize-args.js +517 -0
- package/dist/query/option-surface.d.ts +16 -4
- package/dist/query/option-surface.js +56 -13
- package/dist/query/relation-names.d.ts +14 -0
- package/dist/query/relation-names.js +77 -19
- package/dist/query/relations.d.ts +30 -3
- package/dist/query/relations.js +220 -67
- package/dist/query/row-lock.d.ts +49 -0
- package/dist/query/row-lock.js +131 -0
- package/dist/query/sql-comment.d.ts +161 -0
- package/dist/query/sql-comment.js +374 -0
- package/dist/query/stream-idle.d.ts +132 -0
- package/dist/query/stream-idle.js +203 -0
- package/dist/query/table-client.d.ts +101 -0
- package/dist/query/table-client.js +70 -0
- package/dist/query/types.d.ts +677 -298
- package/dist/query/utils.d.ts +105 -6
- package/dist/query/utils.js +414 -18
- package/dist/query/warn-registry.d.ts +18 -0
- package/dist/query/warn-registry.js +18 -0
- package/dist/query/where-compile.d.ts +138 -14
- package/dist/query/where-compile.js +508 -31
- package/dist/query/where.d.ts +159 -59
- package/dist/query/where.js +711 -248
- package/dist/query/writes.d.ts +112 -50
- package/dist/query/writes.js +1496 -202
- package/dist/query-events.d.ts +4 -2
- package/dist/query-events.js +3 -1
- package/dist/realtime.d.ts +7 -3
- package/dist/realtime.js +13 -2
- package/dist/schema-builder.d.ts +55 -4
- package/dist/schema-builder.js +381 -18
- package/dist/schema-metadata.d.ts +21 -1
- package/dist/schema-metadata.js +28 -7
- package/dist/schema-sql.d.ts +75 -5
- package/dist/schema-sql.js +494 -44
- package/dist/schema.d.ts +26 -5
- package/dist/schema.js +109 -13
- package/dist/sql-placeholders.d.ts +56 -0
- package/dist/sql-placeholders.js +200 -0
- package/dist/sqlite.d.ts +75 -20
- package/dist/sqlite.js +597 -99
- package/dist/supplied-pool-types.d.ts +48 -0
- package/dist/supplied-pool-types.js +247 -0
- package/dist/transaction-control.d.ts +51 -0
- package/dist/transaction-control.js +311 -0
- package/dist/transaction-state.d.ts +342 -0
- package/dist/transaction-state.js +696 -0
- package/dist/typed-sql.d.ts +37 -3
- package/dist/typed-sql.js +100 -8
- package/package.json +7 -4
- package/skills/turbine-orm/SKILL.md +56 -6
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* live here, next to the declarations they enforce, so a new privilege option
|
|
8
8
|
* or direction-bearing shape has one obvious place to be wired in.
|
|
9
9
|
*/
|
|
10
|
+
import type { ColumnRef } from './column-ref.js';
|
|
11
|
+
import type { EXCLUDED_REF, SQL_EXPR } from './expr.js';
|
|
10
12
|
/**
|
|
11
13
|
* The value that unlocks a PRIVILEGE option: `skipGlobalFilters`,
|
|
12
14
|
* `includePii`, `allowFullTableScan`.
|
|
@@ -153,53 +155,47 @@ export type OrderDirection = 'asc' | 'desc';
|
|
|
153
155
|
* a distinct PowQL code path.
|
|
154
156
|
*/
|
|
155
157
|
export type RelationLoadStrategy = 'join' | 'batched' | 'auto' | 'flatten';
|
|
158
|
+
export type { ColumnRef } from './column-ref.js';
|
|
156
159
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* Accepted by `equals`, `not`, `gt`, `gte`, `lt`, and `lte`. The referenced
|
|
166
|
-
* field resolves through the table's columnMap (camelCase accepted, same as a
|
|
167
|
-
* where key) and compiles to a quoted identifier: NO parameter is bound.
|
|
168
|
-
* An unknown referenced field throws {@link ValidationError} (E003).
|
|
169
|
-
*
|
|
170
|
-
* Notes:
|
|
171
|
-
* - `mode: 'insensitive'` cannot be combined with a column reference: it
|
|
172
|
-
* throws E003 (use `client.sql` for `lower(a) = lower(b)`).
|
|
173
|
-
* - On json/jsonb columns `equals` routes to the JSONB containment filter
|
|
174
|
-
* first, so `{ equals: { col } }` there is treated as a JSON value, not a
|
|
175
|
-
* column reference.
|
|
176
|
-
*
|
|
177
|
-
* `F` narrows the referenced name to the table's field names when the
|
|
178
|
-
* surrounding {@link WhereClause} knows the entity type.
|
|
160
|
+
* Operator object for advanced where filtering.
|
|
161
|
+
*
|
|
162
|
+
* Every value operand is checked against the column before any SQL is built:
|
|
163
|
+
* on a non-JSON column it must be a string, number, bigint, boolean, Date or
|
|
164
|
+
* Buffer (or `null` for `equals` / `not`), `in` / `notIn` take an array of
|
|
165
|
+
* those, and the LIKE operators take a string. An object at a value position
|
|
166
|
+
* throws `ValidationError` (E003) instead of being bound, so a request body
|
|
167
|
+
* cannot turn a value into an operator.
|
|
179
168
|
*/
|
|
180
|
-
export interface ColumnRef<F extends string = string> {
|
|
181
|
-
col: F;
|
|
182
|
-
}
|
|
183
|
-
/** Operator object for advanced where filtering */
|
|
184
169
|
export interface WhereOperator<V = unknown, F extends string = string> {
|
|
185
170
|
/**
|
|
186
171
|
* Explicit equality: `{ equals: value }` → `column = $n`.
|
|
187
172
|
* `{ equals: null }` → `column IS NULL`.
|
|
188
|
-
* `{ equals:
|
|
173
|
+
* `{ equals: col('otherField') }` → `column = "other_field"` ({@link ColumnRef}).
|
|
189
174
|
* On json/jsonb columns `equals` routes to the JSONB containment filter
|
|
190
175
|
* ({@link JsonFilter}) instead.
|
|
191
176
|
*/
|
|
192
|
-
equals?: V | ColumnRef<F> | null;
|
|
193
|
-
gt?: V | ColumnRef<F
|
|
194
|
-
gte?: V | ColumnRef<F
|
|
195
|
-
lt?: V | ColumnRef<F
|
|
196
|
-
lte?: V | ColumnRef<F
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
177
|
+
equals?: V | ColumnRef<F> | null | undefined;
|
|
178
|
+
gt?: V | ColumnRef<F> | undefined;
|
|
179
|
+
gte?: V | ColumnRef<F> | undefined;
|
|
180
|
+
lt?: V | ColumnRef<F> | undefined;
|
|
181
|
+
lte?: V | ColumnRef<F> | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* `{ not: value }` → `column != $n`, `{ not: null }` → `column IS NOT NULL`,
|
|
184
|
+
* `{ not: col('other') }` → `column != "other"`.
|
|
185
|
+
*
|
|
186
|
+
* An operator object negates the whole inner filter, as in Prisma:
|
|
187
|
+
* `{ not: { contains: 'x' } }` → `NOT (column LIKE '%x%')`. The inner object
|
|
188
|
+
* inherits this object's `mode` unless it sets its own. SQL three-valued
|
|
189
|
+
* logic applies: a row whose column is NULL matches neither the inner filter
|
|
190
|
+
* nor its negation. Add `{ OR: [{ col: { not: ... } }, { col: null }] }` to
|
|
191
|
+
* keep NULL rows.
|
|
192
|
+
*/
|
|
193
|
+
not?: V | ColumnRef<F> | WhereOperator<V, F> | null | undefined;
|
|
194
|
+
in?: V[] | undefined;
|
|
195
|
+
notIn?: V[] | undefined;
|
|
196
|
+
contains?: string | undefined;
|
|
197
|
+
startsWith?: string | undefined;
|
|
198
|
+
endsWith?: string | undefined;
|
|
203
199
|
/**
|
|
204
200
|
* `'insensitive'` makes the comparison case-insensitive on a string column:
|
|
205
201
|
* `contains` / `startsWith` / `endsWith` use ILIKE (or the dialect's
|
|
@@ -207,19 +203,22 @@ export interface WhereOperator<V = unknown, F extends string = string> {
|
|
|
207
203
|
* case on both sides (`LOWER(...)`). A `mode` beside a non-string operand
|
|
208
204
|
* throws `ValidationError` (E003).
|
|
209
205
|
*/
|
|
210
|
-
mode?: 'default' | 'insensitive';
|
|
206
|
+
mode?: 'default' | 'insensitive' | undefined;
|
|
211
207
|
}
|
|
212
208
|
/**
|
|
213
209
|
* A where value can be:
|
|
214
210
|
* - A plain value (equality: column = $N)
|
|
215
211
|
* - null (column IS NULL)
|
|
216
212
|
* - An operator object ({ gt: 5, lte: 10 })
|
|
217
|
-
* - A JSONB filter object ({ contains, equals, path, hasKey })
|
|
213
|
+
* - A JSONB filter object ({ contains, equals, path, hasKey }), on a column
|
|
214
|
+
* whose type is not a plain scalar (json columns are typed `unknown`)
|
|
218
215
|
* - An array filter object ({ has, hasEvery, hasSome, isEmpty })
|
|
219
216
|
* - A text search filter object ({ search, config? })
|
|
220
217
|
* - A vector distance filter object ({ distance: { to, metric, lt } }) for pgvector columns
|
|
221
218
|
*/
|
|
222
|
-
export type WhereValue<V = unknown, F extends string = string> = (V extends Array<infer U> ? TypedRelationFilter<U> : V extends Date ? V : V extends object ? V | TypedToOneFilter<V> | WhereClause<V> : V) | WhereOperator<V, F> | JsonFilter | ArrayFilter | TextSearchFilter | VectorFilter | null;
|
|
219
|
+
export type WhereValue<V = unknown, F extends string = string> = (V extends Array<infer U> ? TypedRelationFilter<U> : V extends Date ? V : V extends object ? V | TypedToOneFilter<V> | WhereClause<V> : V) | WhereOperator<V, F> | ([V] extends [ScalarWhereType] ? never : JsonFilter) | ArrayFilter | TextSearchFilter | VectorFilter | null;
|
|
220
|
+
/** Column value types that are never JSON documents. */
|
|
221
|
+
type ScalarWhereType = string | number | bigint | boolean | Date | null | undefined;
|
|
223
222
|
/**
|
|
224
223
|
* Relation filter on a to-many relation property.
|
|
225
224
|
*
|
|
@@ -228,9 +227,9 @@ export type WhereValue<V = unknown, F extends string = string> = (V extends Arra
|
|
|
228
227
|
* It defaults to `{}` so the legacy single-generic spelling still works.
|
|
229
228
|
*/
|
|
230
229
|
export interface TypedRelationFilter<U, UR extends object = {}> {
|
|
231
|
-
some?: WhereClause<U, UR
|
|
232
|
-
every?: WhereClause<U, UR
|
|
233
|
-
none?: WhereClause<U, UR
|
|
230
|
+
some?: WhereClause<U, UR> | undefined;
|
|
231
|
+
every?: WhereClause<U, UR> | undefined;
|
|
232
|
+
none?: WhereClause<U, UR> | undefined;
|
|
234
233
|
}
|
|
235
234
|
/**
|
|
236
235
|
* Relation filter on a to-one relation property. A bare object on a to-one
|
|
@@ -239,8 +238,8 @@ export interface TypedRelationFilter<U, UR extends object = {}> {
|
|
|
239
238
|
* `VR` is the target entity's own relations map (see {@link TypedRelationFilter}).
|
|
240
239
|
*/
|
|
241
240
|
export interface TypedToOneFilter<V, VR extends object = {}> {
|
|
242
|
-
is?: WhereClause<V, VR
|
|
243
|
-
isNot?: WhereClause<V, VR
|
|
241
|
+
is?: WhereClause<V, VR> | undefined;
|
|
242
|
+
isNot?: WhereClause<V, VR> | undefined;
|
|
244
243
|
}
|
|
245
244
|
/**
|
|
246
245
|
* The where-value accepted on a RELATION key, derived from the generated
|
|
@@ -275,23 +274,23 @@ type RelationWhereValue<Rel> = Rel extends RelationDescriptor<infer Target, infe
|
|
|
275
274
|
export type WhereClause<T, R extends object = {}> = [keyof R] extends [never] ? LooseWhereClause<T> : StrictWhereClause<T, R>;
|
|
276
275
|
/** The historical, index-signature-carrying where clause. See {@link WhereClause}. */
|
|
277
276
|
export type LooseWhereClause<T> = {
|
|
278
|
-
[K in keyof T]?: WhereValue<T[K], Extract<keyof T, string
|
|
277
|
+
[K in keyof T]?: WhereValue<T[K], Extract<keyof T, string>> | undefined;
|
|
279
278
|
} & {
|
|
280
|
-
OR?: LooseWhereClause<T>[];
|
|
281
|
-
AND?: LooseWhereClause<T>[];
|
|
282
|
-
NOT?: LooseWhereClause<T
|
|
279
|
+
OR?: LooseWhereClause<T>[] | undefined;
|
|
280
|
+
AND?: LooseWhereClause<T>[] | undefined;
|
|
281
|
+
NOT?: LooseWhereClause<T> | undefined;
|
|
283
282
|
/** Relation filters, keyed by relation name, value is { some, every, none } */
|
|
284
283
|
[relationName: string]: unknown;
|
|
285
284
|
};
|
|
286
285
|
/** Key-checked where clause: column keys from `T`, relation keys from `R`, no index signature. */
|
|
287
286
|
type StrictWhereClause<T, R extends object> = {
|
|
288
|
-
[K in keyof T]?: WhereValue<T[K], Extract<keyof T, string
|
|
287
|
+
[K in keyof T]?: WhereValue<T[K], Extract<keyof T, string>> | undefined;
|
|
289
288
|
} & {
|
|
290
|
-
[K in keyof R]?: RelationWhereValue<R[K]
|
|
289
|
+
[K in keyof R]?: RelationWhereValue<R[K]> | undefined;
|
|
291
290
|
} & {
|
|
292
|
-
OR?: WhereClause<T, R>[];
|
|
293
|
-
AND?: WhereClause<T, R>[];
|
|
294
|
-
NOT?: WhereClause<T, R
|
|
291
|
+
OR?: WhereClause<T, R>[] | undefined;
|
|
292
|
+
AND?: WhereClause<T, R>[] | undefined;
|
|
293
|
+
NOT?: WhereClause<T, R> | undefined;
|
|
295
294
|
};
|
|
296
295
|
/**
|
|
297
296
|
* Client-level automatic WHERE filters, keyed by table accessor (the name used
|
|
@@ -301,10 +300,22 @@ type StrictWhereClause<T, R extends object> = {
|
|
|
301
300
|
* multi-tenancy. A function value is evaluated at query-build time (per query),
|
|
302
301
|
* so a closure over per-request state (e.g. the current tenant id) enables
|
|
303
302
|
* request-scoped filters. `create`/`createMany` are never filtered.
|
|
303
|
+
*
|
|
304
|
+
* Fail closed: a filter that resolves to `undefined`, or holds `undefined` at
|
|
305
|
+
* any depth (`{ tenantId: undefined }` when the tenant context is missing),
|
|
306
|
+
* throws `ValidationError` (E003) instead of being dropped. Return `null` or
|
|
307
|
+
* `{}` to apply no filter on purpose, or pass `skipGlobalFilters: UNSAFE`.
|
|
304
308
|
*/
|
|
305
309
|
export type GlobalFilters = {
|
|
306
|
-
[tableAccessor: string]:
|
|
310
|
+
[tableAccessor: string]: GlobalFilter<any>;
|
|
307
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* One table's global filter: a where clause over that table, or a function
|
|
314
|
+
* returning one per query. `null` applies no filter on purpose. A generated
|
|
315
|
+
* client types its `globalFilters` config with this per table, so a
|
|
316
|
+
* misspelled table or column is a compile error.
|
|
317
|
+
*/
|
|
318
|
+
export type GlobalFilter<T, R extends object = {}> = WhereClause<T, R> | null | (() => WhereClause<T, R> | null);
|
|
308
319
|
/**
|
|
309
320
|
* Per-query opt-out of the configured {@link GlobalFilters}. {@link UNSAFE}
|
|
310
321
|
* skips the global filter on the query's own table AND on every relation target
|
|
@@ -348,12 +359,12 @@ export interface WithClause {
|
|
|
348
359
|
* `WithResult` inference.
|
|
349
360
|
*/
|
|
350
361
|
export type TypedWithClause<R extends object = {}> = [keyof R] extends [never] ? WithClause : {
|
|
351
|
-
[K in keyof R]?: true | WithOptions<RelationRelations<R[K]> & object, RelationTarget<R[K]
|
|
362
|
+
[K in keyof R]?: true | WithOptions<RelationRelations<R[K]> & object, RelationTarget<R[K]>> | undefined;
|
|
352
363
|
} & {
|
|
353
364
|
/** Reserved: correlated relation counts. `true` counts all to-many relations. */
|
|
354
365
|
_count?: true | {
|
|
355
366
|
[K in keyof R]?: true;
|
|
356
|
-
};
|
|
367
|
+
} | undefined;
|
|
357
368
|
};
|
|
358
369
|
/**
|
|
359
370
|
* Options for an included relation.
|
|
@@ -397,9 +408,9 @@ export type WithWhere<NestedT, NestedR extends object> = [unknown] extends [Nest
|
|
|
397
408
|
export type TypedOrderByObject<T, R extends object> = [unknown] extends [T] ? OrderByObject : [
|
|
398
409
|
keyof R
|
|
399
410
|
] extends [never] ? OrderByObject : {
|
|
400
|
-
[K in keyof T]?: OrderDirection | OrderBySpec | JsonPathOrderBy | VectorOrderBy;
|
|
411
|
+
[K in keyof T]?: OrderDirection | OrderBySpec | JsonPathOrderBy | VectorOrderBy | undefined;
|
|
401
412
|
} & {
|
|
402
|
-
[K in keyof R]?: RelationOrderBy | RelationPickOrderBy;
|
|
413
|
+
[K in keyof R]?: RelationOrderBy | RelationPickOrderBy | undefined;
|
|
403
414
|
};
|
|
404
415
|
/** {@link TypedOrderByObject}, single or Prisma-style array. */
|
|
405
416
|
export type TypedOrderByClause<T, R extends object> = TypedOrderByObject<T, R> | TypedOrderByObject<T, R>[];
|
|
@@ -425,20 +436,27 @@ export type WithFieldFlags<NestedT> = [unknown] extends [NestedT] ? Record<strin
|
|
|
425
436
|
* matters.
|
|
426
437
|
*/
|
|
427
438
|
export interface WithOptions<NestedR extends object = Record<never, never>, NestedT = unknown> {
|
|
428
|
-
with?: TypedWithClause<NestedR
|
|
439
|
+
with?: TypedWithClause<NestedR> | undefined;
|
|
429
440
|
/** Filter the related rows. Keys are checked against the relation target when it is known (see {@link WithWhere}). */
|
|
430
|
-
where?: WithWhere<NestedT, NestedR
|
|
441
|
+
where?: WithWhere<NestedT, NestedR> | undefined;
|
|
431
442
|
/**
|
|
432
443
|
* Order the related rows. Accepts a single object (`{ a: 'asc', b: 'desc' }`)
|
|
433
444
|
* or a Prisma-style array of objects (`[{ a: 'asc' }, { b: 'desc' }]`, whose
|
|
434
445
|
* element order is the authoritative multi-key sort precedence).
|
|
435
446
|
*/
|
|
436
|
-
orderBy?: TypedOrderByClause<NestedT, NestedR
|
|
437
|
-
|
|
447
|
+
orderBy?: TypedOrderByClause<NestedT, NestedR> | undefined;
|
|
448
|
+
/** Keep at most this many of each parent's related rows. */
|
|
449
|
+
limit?: number | undefined;
|
|
450
|
+
/** Skip this many of each parent's related rows. To-many relations only; refused on a to-one relation. */
|
|
451
|
+
offset?: number | undefined;
|
|
452
|
+
/** Prisma's spelling of `limit`, folded into it at the args seam. */
|
|
453
|
+
take?: number | undefined;
|
|
454
|
+
/** Prisma's spelling of `offset`, folded into it at the args seam. */
|
|
455
|
+
skip?: number | undefined;
|
|
438
456
|
/** Only include these fields from the relation. Key-checked against the target when it is known. */
|
|
439
|
-
select?: WithFieldFlags<NestedT
|
|
457
|
+
select?: WithFieldFlags<NestedT> | undefined;
|
|
440
458
|
/** Exclude these fields from the relation. Key-checked against the target when it is known. */
|
|
441
|
-
omit?: WithFieldFlags<NestedT
|
|
459
|
+
omit?: WithFieldFlags<NestedT> | undefined;
|
|
442
460
|
}
|
|
443
461
|
/**
|
|
444
462
|
* A relation descriptor used by generated `*Relations` interfaces to make deep
|
|
@@ -474,18 +492,47 @@ export interface WithOptions<NestedR extends object = Record<never, never>, Nest
|
|
|
474
492
|
* @typeParam Cardinality - `'many'` (array) or `'one'` (single object | null).
|
|
475
493
|
* @typeParam Relations - The target entity's own `*Relations` interface, or
|
|
476
494
|
* `{}` if the target has no relations of its own.
|
|
495
|
+
* @typeParam Kind - The relation kind (`'belongsTo'`, `'hasOne'`, ...).
|
|
496
|
+
* The write input types use it: a belongsTo takes the
|
|
497
|
+
* to-one nested write operations. Optional:
|
|
498
|
+
* the default (any kind) keeps the to-many write
|
|
499
|
+
* shape, and a descriptor written with three
|
|
500
|
+
* arguments still accepts a generated one.
|
|
501
|
+
* @typeParam Nullable - `false` for a belongsTo whose foreign key is NOT
|
|
502
|
+
* NULL: the row always points at a target, so a loaded
|
|
503
|
+
* relation is never null. A `where` on the relation
|
|
504
|
+
* (`with: { author: { where } }`) brings `| null` back.
|
|
505
|
+
* A global filter on the target table can also hide
|
|
506
|
+
* the row it points at; the type does not see global
|
|
507
|
+
* filters, so a client that filters a parent table
|
|
508
|
+
* should treat that relation as nullable. Defaults to
|
|
509
|
+
* `boolean`, which reads as nullable.
|
|
477
510
|
*/
|
|
478
|
-
export interface RelationDescriptor<Target, Cardinality extends 'one' | 'many', Relations extends object = {}> {
|
|
511
|
+
export interface RelationDescriptor<Target, Cardinality extends 'one' | 'many', Relations extends object = {}, Kind extends RelationKind | undefined = RelationKind | undefined, Nullable extends boolean = boolean> {
|
|
479
512
|
readonly __target?: Target;
|
|
480
513
|
readonly __cardinality?: Cardinality;
|
|
481
514
|
readonly __relations?: Relations;
|
|
515
|
+
readonly __kind?: Kind;
|
|
516
|
+
readonly __nullable?: Nullable;
|
|
482
517
|
}
|
|
518
|
+
/** The relation kinds a {@link RelationDescriptor} can carry. */
|
|
519
|
+
export type RelationKind = 'hasMany' | 'hasOne' | 'belongsTo' | 'manyToMany';
|
|
483
520
|
/** Extract the target entity from a relation descriptor or bare relation type. */
|
|
484
|
-
type RelationTarget<Rel> = Rel extends RelationDescriptor<infer Target, infer _C, infer _R> ? Target : Rel extends Array<infer Item> ? Item : Rel extends infer One | null ? One : Rel;
|
|
521
|
+
type RelationTarget<Rel> = Rel extends RelationDescriptor<infer Target, infer _C, infer _R, infer _K, infer _N> ? Target : Rel extends Array<infer Item> ? Item : Rel extends infer One | null ? One : Rel;
|
|
485
522
|
/** Extract the target's relations map from a relation descriptor (or `{}` for bare types). */
|
|
486
|
-
type RelationRelations<Rel> = Rel extends RelationDescriptor<infer _T, infer _C, infer R> ? R : {};
|
|
487
|
-
/**
|
|
488
|
-
type
|
|
523
|
+
type RelationRelations<Rel> = Rel extends RelationDescriptor<infer _T, infer _C, infer R, infer _K, infer _N> ? R : {};
|
|
524
|
+
/** Whether a relation descriptor is a belongsTo (the to-one nested write operations apply). */
|
|
525
|
+
type IsBelongsTo<Rel> = Rel extends RelationDescriptor<infer _T, infer _C, infer _R, infer K, infer _N> ? [K] extends ['belongsTo'] ? true : false : false;
|
|
526
|
+
/**
|
|
527
|
+
* Project the target type into its runtime shape: an array for a to-many
|
|
528
|
+
* relation, the row for a to-one relation that cannot be null (see
|
|
529
|
+
* {@link RelationDescriptor} `Nullable`), and `row | null` otherwise. `Opt` is
|
|
530
|
+
* the relation's `with` value: a `where` on a to-one relation can match
|
|
531
|
+
* nothing, so it keeps `| null`.
|
|
532
|
+
*/
|
|
533
|
+
type ApplyCardinality<Rel, Resolved, Opt = true> = Rel extends RelationDescriptor<infer _T, infer Cardinality, infer _R, infer _K, infer Nullable> ? Cardinality extends 'many' ? Resolved[] : [Nullable] extends [false] ? [Opt] extends [{
|
|
534
|
+
where: object;
|
|
535
|
+
}] ? Resolved | null : Resolved : Resolved | null : Rel extends Array<infer _Item> ? Resolved[] : Resolved | null;
|
|
489
536
|
/**
|
|
490
537
|
* Compute the result type when relations are included via `with`.
|
|
491
538
|
*
|
|
@@ -520,27 +567,42 @@ export type WithResult<T, R extends object, W> = [keyof R] extends [never] ? T :
|
|
|
520
567
|
_count: infer C;
|
|
521
568
|
} ? // `_count` requested, add the typed count object alongside any relations.
|
|
522
569
|
WithRelationAdditions<T, R, W> & {
|
|
523
|
-
_count: CountResult<C>;
|
|
570
|
+
_count: CountResult<C, R>;
|
|
524
571
|
} : WithRelationAdditions<T, R, W> : T;
|
|
525
572
|
/**
|
|
526
573
|
* The relation additions grafted onto `T` by a `with` clause (the `_count`
|
|
527
|
-
* reserved key is handled separately by {@link WithResult}).
|
|
528
|
-
*
|
|
574
|
+
* reserved key is handled separately by {@link WithResult}). A relation
|
|
575
|
+
* named by an optional key is grafted as an optional property: the type
|
|
576
|
+
* cannot know whether the value at runtime includes it.
|
|
529
577
|
*/
|
|
530
578
|
type WithRelationAdditions<T, R extends object, W> = [keyof W & keyof R] extends [never] ? T : T & {
|
|
531
|
-
[K in keyof W
|
|
532
|
-
with
|
|
533
|
-
} ?
|
|
579
|
+
[K in keyof W as K extends keyof R ? K : never]: K extends keyof R ? W[K] extends true ? ApplyCardinality<R[K], RelationTarget<R[K]>> : ApplyCardinality<R[K], ShapeRelated<RelationTarget<R[K]>, W[K] extends {
|
|
580
|
+
with: infer NestedW extends object;
|
|
581
|
+
} ? WithResult<RelationTarget<R[K]>, RelationRelations<R[K]> & object, NestedW> : RelationTarget<R[K]>, W[K]>, W[K]> : never;
|
|
534
582
|
};
|
|
583
|
+
/**
|
|
584
|
+
* Apply a relation's `select` / `omit` to its loaded row: the selected (or not
|
|
585
|
+
* omitted) target columns, plus every relation its nested `with` added.
|
|
586
|
+
*/
|
|
587
|
+
type ShapeRelated<Target, Loaded, Opt> = [Opt] extends [{
|
|
588
|
+
select: infer S extends Record<string, boolean>;
|
|
589
|
+
}] ? Pick<Loaded, Extract<keyof Loaded, Extract<keyof Target, TrueKeys<S>> | Exclude<keyof Loaded, keyof Target>>> : [Opt] extends [{
|
|
590
|
+
omit: infer O extends Record<string, boolean>;
|
|
591
|
+
}] ? Omit<Loaded, Extract<keyof Target, TrueKeys<O>>> : Loaded;
|
|
535
592
|
/**
|
|
536
593
|
* Compute the shape of the `_count` object on a result row. `_count: true`
|
|
537
|
-
* counts every to-many relation
|
|
538
|
-
*
|
|
539
|
-
* `{ [K in selected]: number }`.
|
|
594
|
+
* counts every to-many relation of the table; the record form
|
|
595
|
+
* (`_count: { posts: true }`) yields `{ [K in selected]: number }`.
|
|
540
596
|
*/
|
|
541
|
-
type CountResult<C> = C extends true ? Record<string, number> :
|
|
597
|
+
type CountResult<C, R = {}> = C extends true ? [ToManyKeys<R>] extends [never] ? Record<string, number> : {
|
|
598
|
+
[K in ToManyKeys<R>]: number;
|
|
599
|
+
} : C extends object ? {
|
|
542
600
|
[K in keyof C]: number;
|
|
543
601
|
} : Record<string, number>;
|
|
602
|
+
/** The to-many relation names of a relations map. */
|
|
603
|
+
type ToManyKeys<R> = {
|
|
604
|
+
[K in keyof R]: R[K] extends RelationDescriptor<infer _T, infer C, infer _R, infer _K, infer _N> ? C extends 'many' ? K : never : never;
|
|
605
|
+
}[keyof R];
|
|
544
606
|
/**
|
|
545
607
|
* Key-validating companion for an inferred `select` / `omit` flag map.
|
|
546
608
|
*
|
|
@@ -563,6 +625,16 @@ type CountResult<C> = C extends true ? Record<string, number> : C extends object
|
|
|
563
625
|
export type FieldFlags<T, S> = S extends object ? string extends keyof S ? S : {
|
|
564
626
|
[K in keyof S]: K extends keyof T ? boolean : never;
|
|
565
627
|
} : S;
|
|
628
|
+
/**
|
|
629
|
+
* The `select` / `omit` parameter type. `S` is the inference site and
|
|
630
|
+
* {@link FieldFlags} rejects an unknown key. While an editor completes an
|
|
631
|
+
* empty `{}`, `S` is still its default `undefined`; that branch is the
|
|
632
|
+
* entity's fields, so they are what the editor offers. (The index signature
|
|
633
|
+
* keeps the branch assignable to the open flag map the builder reads.)
|
|
634
|
+
*/
|
|
635
|
+
export type FlagsArg<T, S> = ([S] extends [undefined] ? {
|
|
636
|
+
[K in keyof T]?: boolean;
|
|
637
|
+
} & Record<string, boolean> : S & FieldFlags<T, S>) | undefined;
|
|
566
638
|
/** Extract keys from a boolean record where the value is `true`. */
|
|
567
639
|
type TrueKeys<S extends Record<string, boolean>> = {
|
|
568
640
|
[K in keyof S]: S[K] extends true ? K : never;
|
|
@@ -585,28 +657,57 @@ export type FieldResult<T, S extends Record<string, boolean> | undefined, O exte
|
|
|
585
657
|
* preserving exact type equality with the pre-narrowing era.
|
|
586
658
|
*/
|
|
587
659
|
export type QueryResult<T, R extends object, W, S extends Record<string, boolean> | undefined, O extends Record<string, boolean> | undefined> = S extends undefined ? O extends undefined ? WithResult<T, R, W> : O extends Record<string, boolean> ? Omit<WithResult<T, R, W>, Exclude<Extract<keyof T, TrueKeys<O>>, keyof W>> : WithResult<T, R, W> : S extends Record<string, boolean> ? Pick<WithResult<T, R, W>, Extract<keyof T, TrueKeys<S>> | Exclude<keyof WithResult<T, R, W>, keyof T> | Extract<keyof W, keyof WithResult<T, R, W>>> : WithResult<T, R, W>;
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
660
|
+
/**
|
|
661
|
+
* Row-lock strength for a locking read, PostgreSQL's four (`FOR UPDATE`,
|
|
662
|
+
* `FOR NO KEY UPDATE`, `FOR SHARE`, `FOR KEY SHARE`). MySQL has `'update'` and
|
|
663
|
+
* `'share'` only; SQLite, SQL Server and PowDB have none and refuse `lock`
|
|
664
|
+
* with `UnsupportedFeatureError` (E017).
|
|
665
|
+
*/
|
|
666
|
+
export type RowLockMode = 'update' | 'noKeyUpdate' | 'share' | 'keyShare';
|
|
667
|
+
/**
|
|
668
|
+
* The `lock` read option: a {@link RowLockMode}, or the mode plus ONE wait
|
|
669
|
+
* policy. `noWait` fails at once with `LockNotAvailableError` when a row is
|
|
670
|
+
* locked by another transaction; `skipLocked` leaves such rows out of the
|
|
671
|
+
* result, so a page can come back short (the queue-claim pattern).
|
|
672
|
+
*/
|
|
673
|
+
export type RowLock = RowLockMode | {
|
|
674
|
+
mode: RowLockMode;
|
|
675
|
+
noWait?: true | undefined;
|
|
676
|
+
skipLocked?: undefined;
|
|
677
|
+
} | {
|
|
678
|
+
mode: RowLockMode;
|
|
679
|
+
skipLocked?: true | undefined;
|
|
680
|
+
noWait?: undefined;
|
|
681
|
+
};
|
|
682
|
+
export interface FindUniqueArgs<T, R extends object = {}, W extends TypedWithClause<R> = TypedWithClause<R>, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined, U = unknown> {
|
|
683
|
+
/**
|
|
684
|
+
* Row selector. Keys are checked against `T` and `R` (see {@link WhereClause}).
|
|
685
|
+
* `U` is the table's unique-key type (the generated `XWhereUnique`): when it
|
|
686
|
+
* is known, the selector must name one unique key or compound selector, and
|
|
687
|
+
* may add further filters beside it.
|
|
688
|
+
*/
|
|
689
|
+
where: U & WhereClause<T, R>;
|
|
591
690
|
/** Only return these fields. Keys are checked against `T` (see {@link FieldFlags}). */
|
|
592
|
-
select?:
|
|
691
|
+
select?: FlagsArg<T, S>;
|
|
593
692
|
/** Exclude these fields. Keys are checked against `T` (see {@link FieldFlags}). */
|
|
594
|
-
omit?:
|
|
595
|
-
with?: W;
|
|
693
|
+
omit?: FlagsArg<T, O>;
|
|
694
|
+
with?: (W & TypedWithClause<R>) | undefined;
|
|
596
695
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
597
|
-
timeout?: number;
|
|
696
|
+
timeout?: number | undefined;
|
|
598
697
|
/** Override the client's relation-loading strategy for this query. See {@link RelationLoadStrategy}. */
|
|
599
|
-
relationLoadStrategy?: RelationLoadStrategy;
|
|
698
|
+
relationLoadStrategy?: RelationLoadStrategy | undefined;
|
|
600
699
|
/** Override the client's {@link TurbineConfig.stableRelationOrder} for this query. */
|
|
601
|
-
stableRelationOrder?: boolean;
|
|
700
|
+
stableRelationOrder?: boolean | undefined;
|
|
602
701
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
603
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
702
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
604
703
|
/** Include PII-tagged columns (`includePii: UNSAFE`). See {@link FindManyArgs.includePii}. */
|
|
605
|
-
includePii?: Unsafe;
|
|
704
|
+
includePii?: Unsafe | undefined;
|
|
606
705
|
/** Plan this query with its real parameter values. See {@link FindManyArgs.forceCustomPlan}. */
|
|
607
|
-
forceCustomPlan?: boolean;
|
|
706
|
+
forceCustomPlan?: boolean | undefined;
|
|
608
707
|
/** Override the relation JSON wire encoding for this query. See {@link FindManyArgs.jsonEncoding}. */
|
|
609
|
-
jsonEncoding?: JsonEncoding;
|
|
708
|
+
jsonEncoding?: JsonEncoding | undefined;
|
|
709
|
+
/** Lock the returned row until the transaction ends. See {@link FindManyArgs.lock}. */
|
|
710
|
+
lock?: RowLock | undefined;
|
|
610
711
|
}
|
|
611
712
|
/**
|
|
612
713
|
* How a nested relation's rows are encoded on the wire.
|
|
@@ -624,23 +725,23 @@ export interface FindUniqueArgs<T, R extends object = {}, W extends TypedWithCla
|
|
|
624
725
|
export type JsonEncoding = 'object' | 'positional';
|
|
625
726
|
export interface FindManyArgs<T, R extends object = {}, W extends TypedWithClause<R> = TypedWithClause<R>, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined> {
|
|
626
727
|
/** Row filter. Keys are checked against `T` and `R` (see {@link WhereClause}). */
|
|
627
|
-
where?: WhereClause<T, R
|
|
728
|
+
where?: WhereClause<T, R> | undefined;
|
|
628
729
|
/** Only return these fields. Keys are checked against `T` (see {@link FieldFlags}). */
|
|
629
|
-
select?:
|
|
730
|
+
select?: FlagsArg<T, S>;
|
|
630
731
|
/** Exclude these fields. Keys are checked against `T` (see {@link FieldFlags}). */
|
|
631
|
-
omit?:
|
|
632
|
-
orderBy?: TypedOrderByClause<T, R
|
|
633
|
-
limit?: number;
|
|
634
|
-
offset?: number;
|
|
635
|
-
with?: W;
|
|
732
|
+
omit?: FlagsArg<T, O>;
|
|
733
|
+
orderBy?: TypedOrderByClause<T, R> | undefined;
|
|
734
|
+
limit?: number | undefined;
|
|
735
|
+
offset?: number | undefined;
|
|
736
|
+
with?: (W & TypedWithClause<R>) | undefined;
|
|
636
737
|
/** Cursor-based pagination: start after this row */
|
|
637
|
-
cursor?: Partial<T
|
|
738
|
+
cursor?: Partial<T> | undefined;
|
|
638
739
|
/**
|
|
639
740
|
* Prisma's spelling of {@link FindManyArgs.limit}. Folded into `limit` before
|
|
640
741
|
* anything reads it; passing both with different values is a
|
|
641
742
|
* `ValidationError`.
|
|
642
743
|
*/
|
|
643
|
-
take?: number;
|
|
744
|
+
take?: number | undefined;
|
|
644
745
|
/**
|
|
645
746
|
* Prisma's spelling of {@link FindManyArgs.offset}. Folded into `offset`
|
|
646
747
|
* before anything reads it; passing both with different values is a
|
|
@@ -650,13 +751,13 @@ export interface FindManyArgs<T, R extends object = {}, W extends TypedWithClaus
|
|
|
650
751
|
* not, so the Prisma pair `{ take, skip }` silently returned the first page
|
|
651
752
|
* however far the caller thought they had paged.
|
|
652
753
|
*/
|
|
653
|
-
skip?: number;
|
|
754
|
+
skip?: number | undefined;
|
|
654
755
|
/** De-duplicate results by specified fields */
|
|
655
|
-
distinct?: (keyof T & string)[];
|
|
756
|
+
distinct?: (keyof T & string)[] | undefined;
|
|
656
757
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
657
|
-
timeout?: number;
|
|
758
|
+
timeout?: number | undefined;
|
|
658
759
|
/** Override the client's relation-loading strategy for this query. See {@link RelationLoadStrategy}. */
|
|
659
|
-
relationLoadStrategy?: RelationLoadStrategy;
|
|
760
|
+
relationLoadStrategy?: RelationLoadStrategy | undefined;
|
|
660
761
|
/**
|
|
661
762
|
* Override the client's {@link TurbineConfig.stableRelationOrder} for this
|
|
662
763
|
* query. When `true`, every to-many `with` relation that has no explicit
|
|
@@ -665,33 +766,36 @@ export interface FindManyArgs<T, R extends object = {}, W extends TypedWithClaus
|
|
|
665
766
|
* per-relation `orderBy` always wins. Off by default; when off the emitted SQL
|
|
666
767
|
* is byte-identical to before.
|
|
667
768
|
*/
|
|
668
|
-
stableRelationOrder?: boolean;
|
|
769
|
+
stableRelationOrder?: boolean | undefined;
|
|
669
770
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
670
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
771
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
671
772
|
/**
|
|
672
773
|
* Per-call override of the unbounded-findMany warning. Pass `false` when
|
|
673
774
|
* this call intentionally reads the full table (the config-level
|
|
674
775
|
* `warnOnUnlimited` stays in effect for every other call); pass `true` to
|
|
675
776
|
* force the warning even when it is disabled in config.
|
|
676
777
|
*/
|
|
677
|
-
warnOnUnlimited?: boolean;
|
|
778
|
+
warnOnUnlimited?: boolean | undefined;
|
|
678
779
|
/**
|
|
679
780
|
* Include PII-tagged columns (`defineSchema` `pii: true`) in the result.
|
|
680
781
|
*
|
|
681
|
-
* PII columns are EXCLUDED from default projections
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
782
|
+
* PII columns are EXCLUDED from default projections, and this flag is the
|
|
783
|
+
* only way to read one. With it, every PII column comes back at the top
|
|
784
|
+
* level AND at every nested `with` level of this query, and a `select` may
|
|
785
|
+
* name one. Without it, a `select` naming a PII column throws (E003): `select`
|
|
786
|
+
* can arrive in request data, so naming a column is not an opt-in. Schemas
|
|
787
|
+
* with no PII-tagged columns are unaffected (the emitted SQL is
|
|
788
|
+
* byte-identical either way).
|
|
686
789
|
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
790
|
+
* Filtering or sorting on a PII column (`where`, `orderBy`) is always
|
|
791
|
+
* allowed, since it returns no PII value. Grouping by one, or `_min` / `_max`
|
|
792
|
+
* over one, needs the same flag on {@link GroupByArgs} / {@link AggregateArgs}.
|
|
689
793
|
*
|
|
690
794
|
* PRIVILEGE OPTION: unlocked by the {@link UNSAFE} sentinel only
|
|
691
795
|
* (`includePii: UNSAFE`). A literal `true` throws (E003), because a request
|
|
692
796
|
* body spread into these args must not be able to unlock the PII projection.
|
|
693
797
|
*/
|
|
694
|
-
includePii?: Unsafe;
|
|
798
|
+
includePii?: Unsafe | undefined;
|
|
695
799
|
/**
|
|
696
800
|
* Plan THIS query with its actual parameter values, every execution.
|
|
697
801
|
* PostgreSQL only (see the refusal below).
|
|
@@ -823,7 +927,7 @@ export interface FindManyArgs<T, R extends object = {}, W extends TypedWithClaus
|
|
|
823
927
|
* so silently accepting the flag would report a guarantee that was never
|
|
824
928
|
* made. Omitting it (or `false`) is accepted everywhere.
|
|
825
929
|
*/
|
|
826
|
-
forceCustomPlan?: boolean;
|
|
930
|
+
forceCustomPlan?: boolean | undefined;
|
|
827
931
|
/**
|
|
828
932
|
* Override {@link TurbineConfig.jsonEncoding} for this query: how a `with`
|
|
829
933
|
* clause's relation rows are encoded on the wire.
|
|
@@ -854,9 +958,24 @@ export interface FindManyArgs<T, R extends object = {}, W extends TypedWithClaus
|
|
|
854
958
|
* A value that is neither `'object'` nor `'positional'` throws
|
|
855
959
|
* {@link ValidationError} (E003) rather than being ignored.
|
|
856
960
|
*/
|
|
857
|
-
jsonEncoding?: JsonEncoding;
|
|
961
|
+
jsonEncoding?: JsonEncoding | undefined;
|
|
962
|
+
/**
|
|
963
|
+
* Lock the returned rows of THIS table until the transaction ends
|
|
964
|
+
* (`SELECT ... FOR UPDATE OF "t"` and friends, see {@link RowLock}).
|
|
965
|
+
*
|
|
966
|
+
* Only inside a transaction: outside one the lock is released before the
|
|
967
|
+
* call returns, so the read is refused (E003). Rows loaded through `with`
|
|
968
|
+
* are read, not locked, on every relation strategy; to lock them, run a
|
|
969
|
+
* second locking read on that table. Cannot be combined with `distinct`.
|
|
970
|
+
*/
|
|
971
|
+
lock?: RowLock | undefined;
|
|
858
972
|
}
|
|
859
|
-
|
|
973
|
+
/**
|
|
974
|
+
* Streaming reads take the {@link FindManyArgs} surface minus `lock`: a cursor
|
|
975
|
+
* holds its rows across many fetches, so page with `findMany` inside the
|
|
976
|
+
* transaction instead.
|
|
977
|
+
*/
|
|
978
|
+
export interface FindManyStreamArgs<T, R extends object = {}, W extends TypedWithClause<R> = TypedWithClause<R>, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined> extends Omit<FindManyArgs<T, R, W, S, O>, 'lock'> {
|
|
860
979
|
/**
|
|
861
980
|
* Number of rows to fetch per internal FETCH batch (default: 1000).
|
|
862
981
|
*
|
|
@@ -868,39 +987,143 @@ export interface FindManyStreamArgs<T, R extends object = {}, W extends TypedWit
|
|
|
868
987
|
* cursor overhead entirely (no BEGIN / DECLARE / CLOSE / COMMIT) by
|
|
869
988
|
* using a speculative `SELECT ... LIMIT batchSize+1` first.
|
|
870
989
|
*/
|
|
871
|
-
batchSize?: number;
|
|
990
|
+
batchSize?: number | undefined;
|
|
991
|
+
/**
|
|
992
|
+
* Close this stream's cursor and release its connection once the consumer
|
|
993
|
+
* has asked for nothing for this many milliseconds (no row from
|
|
994
|
+
* `findManyStream`, no batch from `findManyStreamBatches`). Overrides the
|
|
995
|
+
* client's `streamIdleTimeoutMs` (default 300000, five minutes). `0`
|
|
996
|
+
* disables it for this call.
|
|
997
|
+
*
|
|
998
|
+
* Only a stream that holds a connection between pulls is watched: one that
|
|
999
|
+
* fit in a single batch holds nothing, and one inside `$transaction` rides
|
|
1000
|
+
* the caller's connection, which the transaction's own timeout bounds. On
|
|
1001
|
+
* expiry Turbine logs `stream-idle-timeout` and the next pull, if one comes,
|
|
1002
|
+
* throws `TimeoutError` (E002). Time Turbine spends fetching does not count.
|
|
1003
|
+
* A whole number of milliseconds (E003 otherwise).
|
|
1004
|
+
*/
|
|
1005
|
+
idleTimeoutMs?: number | undefined;
|
|
872
1006
|
}
|
|
873
|
-
export interface CreateArgs<T, R extends object = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined> {
|
|
1007
|
+
export interface CreateArgs<T, R extends object = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined, D = never> {
|
|
874
1008
|
/**
|
|
875
1009
|
* Row data. On typed clients, relation names additionally accept nested
|
|
876
1010
|
* write ops ({@link NestedCreateOp}): `create` / `connect` / `connectOrCreate`.
|
|
1011
|
+
* A generated client passes its `XCreateInput` as `D`, which requires the
|
|
1012
|
+
* columns the table requires. `never` (the default) means
|
|
1013
|
+
* `CreateDataInput<T, R>`; a defaulted `D = CreateDataInput<T, R>` makes the
|
|
1014
|
+
* builder's own `CreateArgs` conversions fail to typecheck.
|
|
877
1015
|
*/
|
|
878
|
-
data: CreateDataInput<T, R
|
|
1016
|
+
data: [D] extends [never] ? CreateDataInput<T, R> : D;
|
|
879
1017
|
/**
|
|
880
1018
|
* Return only these fields of the written row, instead of the whole row.
|
|
881
1019
|
* Keys are checked against `T` (see {@link FieldFlags}) and follow the read
|
|
882
1020
|
* rules: an unknown name throws E003, a `select` must name at least one field,
|
|
883
1021
|
* and it cannot be combined with `omit`. Narrows the `RETURNING` list itself,
|
|
884
1022
|
* so the unselected columns never cross the wire, which is the point on a
|
|
885
|
-
* table with a large JSON or text column.
|
|
886
|
-
*
|
|
1023
|
+
* table with a large JSON or text column. A write never returns a PII-tagged
|
|
1024
|
+
* column: naming one here throws (E003), so read the row back with
|
|
1025
|
+
* `includePii: UNSAFE` instead.
|
|
887
1026
|
*/
|
|
888
|
-
select?:
|
|
1027
|
+
select?: FlagsArg<T, S>;
|
|
889
1028
|
/**
|
|
890
1029
|
* Return the written row without these fields. Same rules as `select`;
|
|
891
1030
|
* PII-tagged columns stay excluded, as they are from every default write
|
|
892
1031
|
* return.
|
|
893
1032
|
*/
|
|
894
|
-
omit?:
|
|
1033
|
+
omit?: FlagsArg<T, O>;
|
|
895
1034
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
896
|
-
timeout?: number;
|
|
1035
|
+
timeout?: number | undefined;
|
|
897
1036
|
}
|
|
898
|
-
export interface CreateManyArgs<T> {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1037
|
+
export interface CreateManyArgs<T, D = OptionalInput<T>, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined> {
|
|
1038
|
+
/** The rows. A generated client passes its `XCreate` as `D`. */
|
|
1039
|
+
data: D[];
|
|
1040
|
+
/** Skip rows that conflict on ANY unique constraint (ON CONFLICT DO NOTHING). */
|
|
1041
|
+
skipDuplicates?: boolean | undefined;
|
|
1042
|
+
/**
|
|
1043
|
+
* Conflict handling on ONE named unique key: skip the conflicting rows, or
|
|
1044
|
+
* update them. Cannot be combined with `skipDuplicates`. See
|
|
1045
|
+
* {@link CreateManyOnConflict}.
|
|
1046
|
+
*/
|
|
1047
|
+
onConflict?: CreateManyOnConflict<T> | undefined;
|
|
1048
|
+
/**
|
|
1049
|
+
* Return only these fields of the written rows. Same rules as `create()`:
|
|
1050
|
+
* a PII-tagged column is never returned, and naming one throws (E003).
|
|
1051
|
+
*/
|
|
1052
|
+
select?: FlagsArg<T, S>;
|
|
1053
|
+
/** Return the written rows without these fields. Same rules as `select`. */
|
|
1054
|
+
omit?: FlagsArg<T, O>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Opt out of configured {@link GlobalFilters} on the conflict-UPDATE of
|
|
1057
|
+
* `onConflict` (inserts are never filtered). See {@link SkipGlobalFilters}.
|
|
1058
|
+
*/
|
|
1059
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
902
1060
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
903
|
-
timeout?: number;
|
|
1061
|
+
timeout?: number | undefined;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* The columns of the primary key, or of one non-partial unique constraint or
|
|
1065
|
+
* index, in any order. A `createMany` conflict target.
|
|
1066
|
+
*/
|
|
1067
|
+
export type ConflictTarget<T> = readonly [keyof T & string, ...(keyof T & string)[]];
|
|
1068
|
+
/**
|
|
1069
|
+
* `createMany({ onConflict })`: what to do with a row whose `target` key
|
|
1070
|
+
* already exists.
|
|
1071
|
+
*
|
|
1072
|
+
* - `{ target, ignore: true }` skips it (it is not returned). A conflict on a
|
|
1073
|
+
* DIFFERENT unique key still raises `UniqueConstraintError`.
|
|
1074
|
+
* - `{ target, update }` updates the existing row. `update` is a field list
|
|
1075
|
+
* (each listed column takes the incoming row's value) or a per-column
|
|
1076
|
+
* {@link ConflictUpdateData} object. `where` limits the update to existing
|
|
1077
|
+
* rows that match it; a row it excludes is left alone and not returned.
|
|
1078
|
+
*
|
|
1079
|
+
* The result holds the rows inserted or updated, in no guaranteed order.
|
|
1080
|
+
*/
|
|
1081
|
+
export type CreateManyOnConflict<T> = {
|
|
1082
|
+
target: ConflictTarget<T>;
|
|
1083
|
+
ignore: true;
|
|
1084
|
+
update?: undefined;
|
|
1085
|
+
where?: undefined;
|
|
1086
|
+
} | {
|
|
1087
|
+
target: ConflictTarget<T>;
|
|
1088
|
+
update: readonly (keyof T & string)[] | ConflictUpdateData<T>;
|
|
1089
|
+
where?: WhereClause<T> | undefined;
|
|
1090
|
+
ignore?: undefined;
|
|
1091
|
+
};
|
|
1092
|
+
/**
|
|
1093
|
+
* The per-column update of a `createMany` conflict. A plain value is the same
|
|
1094
|
+
* for every row; an atomic operator, a {@link SqlExpr}, `col(...)` (the
|
|
1095
|
+
* existing row) and `expr.excluded(...)` (the incoming row) are per row.
|
|
1096
|
+
*/
|
|
1097
|
+
export type ConflictUpdateData<T> = {
|
|
1098
|
+
[K in keyof T]?: T[K] | UpdateOperatorInput<T[K]> | SqlExpr<T[K]> | ColumnRef | ExcludedRef | undefined;
|
|
1099
|
+
};
|
|
1100
|
+
/** The node kinds an update expression is built from (see {@link SqlExpr}). */
|
|
1101
|
+
export type SqlExprKind = 'add' | 'sub' | 'mul' | 'div' | 'coalesce' | 'greatest' | 'least' | 'case' | 'now' | 'excluded';
|
|
1102
|
+
/** Carries the phantom result type of a {@link SqlExpr}. Type-level only. */
|
|
1103
|
+
declare const SQL_EXPR_RESULT: unique symbol;
|
|
1104
|
+
/**
|
|
1105
|
+
* A SQL expression in update data, built only by the `expr` constructors
|
|
1106
|
+
* (`expr.add`, `expr.greatest`, `expr.now`, ...). `V` is the expression's
|
|
1107
|
+
* result type, so an expression typechecks only against a column it can be
|
|
1108
|
+
* stored in. The node is frozen and branded: a look-alike plain object (what
|
|
1109
|
+
* `JSON.parse` produces) is a value, never SQL.
|
|
1110
|
+
*/
|
|
1111
|
+
export interface SqlExpr<V = unknown> {
|
|
1112
|
+
readonly [SQL_EXPR]: true;
|
|
1113
|
+
readonly kind: SqlExprKind;
|
|
1114
|
+
readonly args: readonly unknown[];
|
|
1115
|
+
/** Phantom: the result type. Never present at run time. */
|
|
1116
|
+
readonly [SQL_EXPR_RESULT]?: V;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* `expr.excluded(field)`: the incoming row's value for `field` inside an
|
|
1120
|
+
* upsert's update or a `createMany` `onConflict.update` (PostgreSQL's
|
|
1121
|
+
* `EXCLUDED."c"`). Refused (E003) anywhere else.
|
|
1122
|
+
*/
|
|
1123
|
+
export interface ExcludedRef<F extends string = string> extends SqlExpr<never> {
|
|
1124
|
+
readonly [EXCLUDED_REF]: true;
|
|
1125
|
+
readonly kind: 'excluded';
|
|
1126
|
+
readonly field: F;
|
|
904
1127
|
}
|
|
905
1128
|
/**
|
|
906
1129
|
* Atomic update operators for a field.
|
|
@@ -926,13 +1149,49 @@ export type UpdateOperatorInput<V> = {
|
|
|
926
1149
|
divide: number;
|
|
927
1150
|
} : never);
|
|
928
1151
|
/**
|
|
929
|
-
* Update data
|
|
930
|
-
*
|
|
1152
|
+
* Update data: each field takes a plain value, an atomic operator object, a
|
|
1153
|
+
* {@link SqlExpr} whose result fits the column, or `col(...)` to copy another
|
|
1154
|
+
* column of the same row. Back-compatible with `Partial<T>`: plain values
|
|
1155
|
+
* still typecheck unchanged.
|
|
931
1156
|
*/
|
|
932
1157
|
export type UpdateInput<T> = {
|
|
933
|
-
[K in keyof T]?: T[K] | UpdateOperatorInput<T[K]
|
|
1158
|
+
[K in keyof T]?: T[K] | UpdateOperatorInput<T[K]> | SqlExpr<T[K]> | ColumnRef | undefined;
|
|
934
1159
|
};
|
|
935
|
-
|
|
1160
|
+
/**
|
|
1161
|
+
* `Partial<T>` that also admits an explicit `undefined` per key, which every
|
|
1162
|
+
* write path treats as "leave this column out". Spelled out so a consumer
|
|
1163
|
+
* compiling with `exactOptionalPropertyTypes` can pass `{ name: maybeName }`.
|
|
1164
|
+
*/
|
|
1165
|
+
export type OptionalInput<T> = {
|
|
1166
|
+
[K in keyof T]?: T[K] | undefined;
|
|
1167
|
+
};
|
|
1168
|
+
/**
|
|
1169
|
+
* The write and lookup input types one table's accessor uses. A generated
|
|
1170
|
+
* client passes its per-table `XInputs` interface as the third type argument
|
|
1171
|
+
* of `QueryInterface`; untyped clients get {@link DefaultInputTypes}.
|
|
1172
|
+
*/
|
|
1173
|
+
export interface TableInputTypes {
|
|
1174
|
+
/** `create()` data, nested relation writes included. */
|
|
1175
|
+
create: object;
|
|
1176
|
+
/** One row of `createMany()` data, and `upsert()`'s `create`. */
|
|
1177
|
+
createMany: object;
|
|
1178
|
+
/** `update()` data, nested relation writes included. */
|
|
1179
|
+
update: object;
|
|
1180
|
+
/** `updateMany()` data, and `upsert()`'s `update`. */
|
|
1181
|
+
updateMany: object;
|
|
1182
|
+
/** The unique-key selector for `findUnique` / `upsert` (`unknown` when unknown). */
|
|
1183
|
+
whereUnique: unknown;
|
|
1184
|
+
}
|
|
1185
|
+
/** The {@link TableInputTypes} an accessor uses when no generated input types are supplied. */
|
|
1186
|
+
export interface DefaultInputTypes<T, R extends object = {}> extends TableInputTypes {
|
|
1187
|
+
/** `never` selects {@link CreateArgs}' own default, `CreateDataInput<T, R>`. */
|
|
1188
|
+
create: never;
|
|
1189
|
+
createMany: OptionalInput<T>;
|
|
1190
|
+
update: UpdateDataInput<T, R>;
|
|
1191
|
+
updateMany: UpdateInput<T>;
|
|
1192
|
+
whereUnique: unknown;
|
|
1193
|
+
}
|
|
1194
|
+
export interface UpdateArgs<T, R extends object = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined, D = UpdateDataInput<T, R>> {
|
|
936
1195
|
/** Row selector. Keys are checked against `T` and `R` (see {@link WhereClause}). */
|
|
937
1196
|
where: WhereClause<T, R>;
|
|
938
1197
|
/**
|
|
@@ -940,25 +1199,26 @@ export interface UpdateArgs<T, R extends object = {}, S extends Record<string, b
|
|
|
940
1199
|
* write ops ({@link NestedUpdateOp}): `create` / `connect` / `connectOrCreate`
|
|
941
1200
|
* / `disconnect` / `set` / `delete` / `update` / `upsert`.
|
|
942
1201
|
*/
|
|
943
|
-
data:
|
|
1202
|
+
data: D;
|
|
944
1203
|
/**
|
|
945
1204
|
* Return only these fields of the updated row, instead of the whole row.
|
|
946
1205
|
* Keys are checked against `T` (see {@link FieldFlags}) and follow the read
|
|
947
1206
|
* rules: an unknown name throws E003, a `select` must name at least one field,
|
|
948
1207
|
* and it cannot be combined with `omit`. Narrows the `RETURNING` list itself,
|
|
949
1208
|
* so the unselected columns never cross the wire, which is the point on a
|
|
950
|
-
* table with a large JSON or text column.
|
|
951
|
-
*
|
|
1209
|
+
* table with a large JSON or text column. A write never returns a PII-tagged
|
|
1210
|
+
* column: naming one here throws (E003), so read the row back with
|
|
1211
|
+
* `includePii: UNSAFE` instead.
|
|
952
1212
|
*/
|
|
953
|
-
select?:
|
|
1213
|
+
select?: FlagsArg<T, S>;
|
|
954
1214
|
/**
|
|
955
1215
|
* Return the updated row without these fields. Same rules as `select`;
|
|
956
1216
|
* PII-tagged columns stay excluded, as they are from every default write
|
|
957
1217
|
* return.
|
|
958
1218
|
*/
|
|
959
|
-
omit?:
|
|
1219
|
+
omit?: FlagsArg<T, O>;
|
|
960
1220
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
961
|
-
timeout?: number;
|
|
1221
|
+
timeout?: number | undefined;
|
|
962
1222
|
/**
|
|
963
1223
|
* Opt in to running this mutation when `where` resolves to an empty
|
|
964
1224
|
* predicate (e.g. `{}` or `{ id: undefined }`). Default `false`, an
|
|
@@ -971,7 +1231,7 @@ export interface UpdateArgs<T, R extends object = {}, S extends Record<string, b
|
|
|
971
1231
|
* last thing standing between a spread request body and an unconditional
|
|
972
1232
|
* `UPDATE` / `DELETE` over the whole table.
|
|
973
1233
|
*/
|
|
974
|
-
allowFullTableScan?: Unsafe;
|
|
1234
|
+
allowFullTableScan?: Unsafe | undefined;
|
|
975
1235
|
/**
|
|
976
1236
|
* Optimistic locking, prevents lost updates in concurrent scenarios.
|
|
977
1237
|
* Specify the version field and its expected value. The update adds a
|
|
@@ -992,19 +1252,19 @@ export interface UpdateArgs<T, R extends object = {}, S extends Record<string, b
|
|
|
992
1252
|
optimisticLock?: {
|
|
993
1253
|
field: keyof T & string;
|
|
994
1254
|
expected: number;
|
|
995
|
-
};
|
|
1255
|
+
} | undefined;
|
|
996
1256
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
997
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1257
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
998
1258
|
}
|
|
999
|
-
export interface UpdateManyArgs<T, R extends object = {}
|
|
1259
|
+
export interface UpdateManyArgs<T, R extends object = {}, D = UpdateInput<T>> {
|
|
1000
1260
|
where: WhereClause<T, R>;
|
|
1001
|
-
data:
|
|
1261
|
+
data: D;
|
|
1002
1262
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1003
|
-
timeout?: number;
|
|
1263
|
+
timeout?: number | undefined;
|
|
1004
1264
|
/** See {@link UpdateArgs.allowFullTableScan}. */
|
|
1005
|
-
allowFullTableScan?: Unsafe;
|
|
1265
|
+
allowFullTableScan?: Unsafe | undefined;
|
|
1006
1266
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1007
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1267
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1008
1268
|
}
|
|
1009
1269
|
export interface DeleteArgs<T, R extends object = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined> {
|
|
1010
1270
|
where: WhereClause<T, R>;
|
|
@@ -1014,63 +1274,66 @@ export interface DeleteArgs<T, R extends object = {}, S extends Record<string, b
|
|
|
1014
1274
|
* rules: an unknown name throws E003, a `select` must name at least one field,
|
|
1015
1275
|
* and it cannot be combined with `omit`. Narrows the `RETURNING` list itself,
|
|
1016
1276
|
* so the unselected columns never cross the wire, which is the point on a
|
|
1017
|
-
* table with a large JSON or text column.
|
|
1018
|
-
*
|
|
1277
|
+
* table with a large JSON or text column. A write never returns a PII-tagged
|
|
1278
|
+
* column: naming one here throws (E003), so read the row back with
|
|
1279
|
+
* `includePii: UNSAFE` instead.
|
|
1019
1280
|
*/
|
|
1020
|
-
select?:
|
|
1281
|
+
select?: FlagsArg<T, S>;
|
|
1021
1282
|
/**
|
|
1022
1283
|
* Return the deleted row without these fields. Same rules as `select`;
|
|
1023
1284
|
* PII-tagged columns stay excluded, as they are from every default write
|
|
1024
1285
|
* return.
|
|
1025
1286
|
*/
|
|
1026
|
-
omit?:
|
|
1287
|
+
omit?: FlagsArg<T, O>;
|
|
1027
1288
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1028
|
-
timeout?: number;
|
|
1289
|
+
timeout?: number | undefined;
|
|
1029
1290
|
/** See {@link UpdateArgs.allowFullTableScan}. */
|
|
1030
|
-
allowFullTableScan?: Unsafe;
|
|
1291
|
+
allowFullTableScan?: Unsafe | undefined;
|
|
1031
1292
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1032
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1293
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1033
1294
|
}
|
|
1034
1295
|
export interface DeleteManyArgs<T, R extends object = {}> {
|
|
1035
1296
|
where: WhereClause<T, R>;
|
|
1036
1297
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1037
|
-
timeout?: number;
|
|
1298
|
+
timeout?: number | undefined;
|
|
1038
1299
|
/** See {@link UpdateArgs.allowFullTableScan}. */
|
|
1039
|
-
allowFullTableScan?: Unsafe;
|
|
1300
|
+
allowFullTableScan?: Unsafe | undefined;
|
|
1040
1301
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1041
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1302
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1042
1303
|
}
|
|
1043
|
-
export interface UpsertArgs<T, R extends object = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined
|
|
1044
|
-
|
|
1304
|
+
export interface UpsertArgs<T, R extends object = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined, U = unknown, C = OptionalInput<T>, D = UpdateInput<T>> {
|
|
1305
|
+
/** The row to update. A generated client passes its `XWhereUnique` as `U`, so this names a unique key. */
|
|
1306
|
+
where: U & WhereClause<T, R>;
|
|
1045
1307
|
/**
|
|
1046
1308
|
* Return only these fields of the inserted or updated row, instead of the whole row.
|
|
1047
1309
|
* Keys are checked against `T` (see {@link FieldFlags}) and follow the read
|
|
1048
1310
|
* rules: an unknown name throws E003, a `select` must name at least one field,
|
|
1049
1311
|
* and it cannot be combined with `omit`. Narrows the `RETURNING` list itself,
|
|
1050
1312
|
* so the unselected columns never cross the wire, which is the point on a
|
|
1051
|
-
* table with a large JSON or text column.
|
|
1052
|
-
*
|
|
1313
|
+
* table with a large JSON or text column. A write never returns a PII-tagged
|
|
1314
|
+
* column: naming one here throws (E003), so read the row back with
|
|
1315
|
+
* `includePii: UNSAFE` instead.
|
|
1053
1316
|
*/
|
|
1054
|
-
select?:
|
|
1317
|
+
select?: FlagsArg<T, S>;
|
|
1055
1318
|
/**
|
|
1056
1319
|
* Return the inserted or updated row without these fields. Same rules as `select`;
|
|
1057
1320
|
* PII-tagged columns stay excluded, as they are from every default write
|
|
1058
1321
|
* return.
|
|
1059
1322
|
*/
|
|
1060
|
-
omit?:
|
|
1323
|
+
omit?: FlagsArg<T, O>;
|
|
1061
1324
|
/** The row to insert when `where` matches nothing. Plain values only: there is no stored value to operate on yet. */
|
|
1062
|
-
create:
|
|
1325
|
+
create: C;
|
|
1063
1326
|
/**
|
|
1064
1327
|
* Applied to the existing row on conflict. Each field takes a plain value or
|
|
1065
1328
|
* the same atomic {@link UpdateOperatorInput} `update()` takes, so
|
|
1066
1329
|
* `count: { increment: 1 }` adds to the stored value instead of overwriting
|
|
1067
1330
|
* it. Scalar fields only: nested relation writes are not part of an upsert.
|
|
1068
1331
|
*/
|
|
1069
|
-
update:
|
|
1332
|
+
update: D;
|
|
1070
1333
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1071
|
-
timeout?: number;
|
|
1334
|
+
timeout?: number | undefined;
|
|
1072
1335
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1073
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1336
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1074
1337
|
}
|
|
1075
1338
|
/** `connectOrCreate` op: connect to the row matching `where`, or create it. */
|
|
1076
1339
|
export interface ConnectOrCreateOp<T, TR extends object = {}> {
|
|
@@ -1079,13 +1342,13 @@ export interface ConnectOrCreateOp<T, TR extends object = {}> {
|
|
|
1079
1342
|
}
|
|
1080
1343
|
/** Nested write ops valid inside `create()` data for a relation field. */
|
|
1081
1344
|
export interface NestedCreateOp<T, TR extends object = {}> {
|
|
1082
|
-
create?: CreateDataInput<T, TR> | CreateDataInput<T, TR>[];
|
|
1083
|
-
connect?: Partial<T> | Partial<T>[];
|
|
1084
|
-
connectOrCreate?: ConnectOrCreateOp<T, TR> | ConnectOrCreateOp<T, TR>[];
|
|
1345
|
+
create?: CreateDataInput<T, TR> | CreateDataInput<T, TR>[] | undefined;
|
|
1346
|
+
connect?: Partial<T> | Partial<T>[] | undefined;
|
|
1347
|
+
connectOrCreate?: ConnectOrCreateOp<T, TR> | ConnectOrCreateOp<T, TR>[] | undefined;
|
|
1085
1348
|
}
|
|
1086
1349
|
/** A nested `update` op item: update the related row(s) matching `where`. `where` is optional for belongsTo relations (derived from the parent's FK). */
|
|
1087
1350
|
export interface NestedUpdateOpItem<T, TR extends object = {}> {
|
|
1088
|
-
where?: Partial<T
|
|
1351
|
+
where?: Partial<T> | undefined;
|
|
1089
1352
|
data: UpdateDataInput<T, TR>;
|
|
1090
1353
|
}
|
|
1091
1354
|
/** A nested `upsert` op item: update the row matching `where` or create it. */
|
|
@@ -1094,16 +1357,41 @@ export interface NestedUpsertOpItem<T, TR extends object = {}> {
|
|
|
1094
1357
|
create: CreateDataInput<T, TR>;
|
|
1095
1358
|
update: UpdateDataInput<T, TR>;
|
|
1096
1359
|
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Nested write ops for a belongsTo relation inside `create()` data. The row
|
|
1362
|
+
* points at ONE target, so each op takes a single object.
|
|
1363
|
+
*/
|
|
1364
|
+
export interface NestedToOneCreateOp<T, TR extends object = {}> {
|
|
1365
|
+
create?: CreateDataInput<T, TR> | undefined;
|
|
1366
|
+
connect?: Partial<T> | undefined;
|
|
1367
|
+
connectOrCreate?: ConnectOrCreateOp<T, TR> | undefined;
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Nested write ops for a belongsTo relation inside `update()` data, with
|
|
1371
|
+
* Prisma's to-one rules: single objects, no `set`, and `disconnect` /
|
|
1372
|
+
* `delete` take `true` (or `{}`) for the connected row, `false` for a no-op,
|
|
1373
|
+
* or a filter the connected row must match. At most one of create, connect,
|
|
1374
|
+
* connectOrCreate, disconnect and delete per write (refused at runtime).
|
|
1375
|
+
*/
|
|
1376
|
+
export interface NestedToOneUpdateOp<T, TR extends object = {}> extends NestedToOneCreateOp<T, TR> {
|
|
1377
|
+
disconnect?: boolean | Partial<T> | undefined;
|
|
1378
|
+
delete?: boolean | Partial<T> | undefined;
|
|
1379
|
+
/** Update the row this record points at. */
|
|
1380
|
+
update?: {
|
|
1381
|
+
data: UpdateDataInput<T, TR>;
|
|
1382
|
+
} | undefined;
|
|
1383
|
+
upsert?: NestedUpsertOpItem<T, TR> | undefined;
|
|
1384
|
+
}
|
|
1097
1385
|
/** Nested write ops valid inside `update()` data for a relation field. */
|
|
1098
1386
|
export interface NestedUpdateOp<T, TR extends object = {}> {
|
|
1099
|
-
create?: CreateDataInput<T, TR> | CreateDataInput<T, TR>[];
|
|
1100
|
-
connect?: Partial<T> | Partial<T>[];
|
|
1101
|
-
connectOrCreate?: ConnectOrCreateOp<T, TR> | ConnectOrCreateOp<T, TR>[];
|
|
1102
|
-
disconnect?: Partial<T> | Partial<T>[];
|
|
1103
|
-
set?: Partial<T>[];
|
|
1104
|
-
delete?: Partial<T> | Partial<T>[];
|
|
1105
|
-
update?: NestedUpdateOpItem<T, TR> | NestedUpdateOpItem<T, TR>[];
|
|
1106
|
-
upsert?: NestedUpsertOpItem<T, TR> | NestedUpsertOpItem<T, TR>[];
|
|
1387
|
+
create?: CreateDataInput<T, TR> | CreateDataInput<T, TR>[] | undefined;
|
|
1388
|
+
connect?: Partial<T> | Partial<T>[] | undefined;
|
|
1389
|
+
connectOrCreate?: ConnectOrCreateOp<T, TR> | ConnectOrCreateOp<T, TR>[] | undefined;
|
|
1390
|
+
disconnect?: Partial<T> | Partial<T>[] | undefined;
|
|
1391
|
+
set?: Partial<T>[] | undefined;
|
|
1392
|
+
delete?: Partial<T> | Partial<T>[] | undefined;
|
|
1393
|
+
update?: NestedUpdateOpItem<T, TR> | NestedUpdateOpItem<T, TR>[] | undefined;
|
|
1394
|
+
upsert?: NestedUpsertOpItem<T, TR> | NestedUpsertOpItem<T, TR>[] | undefined;
|
|
1107
1395
|
}
|
|
1108
1396
|
/**
|
|
1109
1397
|
* `create()` data input. When the relations map `R` is known (typed clients),
|
|
@@ -1111,8 +1399,8 @@ export interface NestedUpdateOp<T, TR extends object = {}> {
|
|
|
1111
1399
|
* relation's target entity, recursively, via the target's own relations map.
|
|
1112
1400
|
* When `R` is `{}` (untyped escape hatch) this collapses to plain `Partial<T>`.
|
|
1113
1401
|
*/
|
|
1114
|
-
export type CreateDataInput<T, R extends object = {}> = [keyof R] extends [never] ?
|
|
1115
|
-
[K in keyof R]?: NestedCreateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object>;
|
|
1402
|
+
export type CreateDataInput<T, R extends object = {}> = [keyof R] extends [never] ? OptionalInput<T> : OptionalInput<T> & {
|
|
1403
|
+
[K in keyof R]?: IsBelongsTo<R[K]> extends true ? NestedToOneCreateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object> : NestedCreateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object>;
|
|
1116
1404
|
};
|
|
1117
1405
|
/**
|
|
1118
1406
|
* `update()` data input. Like {@link CreateDataInput} but relation fields
|
|
@@ -1121,16 +1409,16 @@ export type CreateDataInput<T, R extends object = {}> = [keyof R] extends [never
|
|
|
1121
1409
|
* accept atomic {@link UpdateOperatorInput} objects.
|
|
1122
1410
|
*/
|
|
1123
1411
|
export type UpdateDataInput<T, R extends object = {}> = [keyof R] extends [never] ? UpdateInput<T> : UpdateInput<T> & {
|
|
1124
|
-
[K in keyof R]?: NestedUpdateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object>;
|
|
1412
|
+
[K in keyof R]?: IsBelongsTo<R[K]> extends true ? NestedToOneUpdateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object> : NestedUpdateOp<RelationTarget<R[K]> & object, RelationRelations<R[K]> & object>;
|
|
1125
1413
|
};
|
|
1126
1414
|
export interface CountArgs<T, R extends object = {}> {
|
|
1127
|
-
where?: WhereClause<T, R
|
|
1415
|
+
where?: WhereClause<T, R> | undefined;
|
|
1128
1416
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1129
|
-
timeout?: number;
|
|
1417
|
+
timeout?: number | undefined;
|
|
1130
1418
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1131
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1419
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1132
1420
|
/** Plan this query with its real parameter values. See {@link FindManyArgs.forceCustomPlan}. */
|
|
1133
|
-
forceCustomPlan?: boolean;
|
|
1421
|
+
forceCustomPlan?: boolean | undefined;
|
|
1134
1422
|
}
|
|
1135
1423
|
/**
|
|
1136
1424
|
* Comparison operators usable inside a `having` aggregate filter. A bare value
|
|
@@ -1143,14 +1431,14 @@ export interface CountArgs<T, R extends object = {}> {
|
|
|
1143
1431
|
* `MIN("title") > 'm'` is as valid as `MIN("views") > 10`).
|
|
1144
1432
|
*/
|
|
1145
1433
|
export interface HavingComparisonOperator<V = number> {
|
|
1146
|
-
equals?: V;
|
|
1147
|
-
not?: V;
|
|
1148
|
-
gt?: V;
|
|
1149
|
-
gte?: V;
|
|
1150
|
-
lt?: V;
|
|
1151
|
-
lte?: V;
|
|
1152
|
-
in?: V[];
|
|
1153
|
-
notIn?: V[];
|
|
1434
|
+
equals?: V | undefined;
|
|
1435
|
+
not?: V | undefined;
|
|
1436
|
+
gt?: V | undefined;
|
|
1437
|
+
gte?: V | undefined;
|
|
1438
|
+
lt?: V | undefined;
|
|
1439
|
+
lte?: V | undefined;
|
|
1440
|
+
in?: V[] | undefined;
|
|
1441
|
+
notIn?: V[] | undefined;
|
|
1154
1442
|
}
|
|
1155
1443
|
/** The number-operand spelling, kept as the historical public name. */
|
|
1156
1444
|
export type HavingNumericOperator = HavingComparisonOperator<number>;
|
|
@@ -1164,11 +1452,11 @@ export type HavingFilter<V = number> = V | HavingComparisonOperator<V>;
|
|
|
1164
1452
|
* viewCount: { _sum: { gt: 100 }, _avg: { lte: 50 } }
|
|
1165
1453
|
*/
|
|
1166
1454
|
export interface HavingAggregateFilter<V = unknown> {
|
|
1167
|
-
_sum?: HavingFilter;
|
|
1168
|
-
_avg?: HavingFilter;
|
|
1169
|
-
_min?: HavingFilter<V
|
|
1170
|
-
_max?: HavingFilter<V
|
|
1171
|
-
_count?: HavingFilter;
|
|
1455
|
+
_sum?: HavingFilter | undefined;
|
|
1456
|
+
_avg?: HavingFilter | undefined;
|
|
1457
|
+
_min?: HavingFilter<V> | undefined;
|
|
1458
|
+
_max?: HavingFilter<V> | undefined;
|
|
1459
|
+
_count?: HavingFilter | undefined;
|
|
1172
1460
|
}
|
|
1173
1461
|
/**
|
|
1174
1462
|
* One field entry of a {@link HavingClause}. Following Prisma, a field accepts
|
|
@@ -1203,12 +1491,12 @@ export type HavingFieldFilter<V = unknown> = (HavingAggregateFilter<V> & WhereOp
|
|
|
1203
1491
|
*/
|
|
1204
1492
|
export type HavingClause<T> = {
|
|
1205
1493
|
/** Filter on `COUNT(*)` for the whole group. */
|
|
1206
|
-
_count?: HavingFilter;
|
|
1207
|
-
AND?: HavingClause<T> | HavingClause<T>[];
|
|
1208
|
-
OR?: HavingClause<T>[];
|
|
1209
|
-
NOT?: HavingClause<T> | HavingClause<T>[];
|
|
1494
|
+
_count?: HavingFilter | undefined;
|
|
1495
|
+
AND?: HavingClause<T> | HavingClause<T>[] | undefined;
|
|
1496
|
+
OR?: HavingClause<T>[] | undefined;
|
|
1497
|
+
NOT?: HavingClause<T> | HavingClause<T>[] | undefined;
|
|
1210
1498
|
} & {
|
|
1211
|
-
[K in keyof T & string]?: HavingFieldFilter<T[K]
|
|
1499
|
+
[K in keyof T & string]?: HavingFieldFilter<T[K]> | undefined;
|
|
1212
1500
|
};
|
|
1213
1501
|
/**
|
|
1214
1502
|
* A JSON-path group key in {@link GroupByArgs.by}: groups by the value
|
|
@@ -1224,7 +1512,7 @@ export interface JsonPathGroupKey {
|
|
|
1224
1512
|
/** JSON path into the column (each element a key or array index). Bound as one text[] param. */
|
|
1225
1513
|
path: (string | number)[];
|
|
1226
1514
|
/** Result key for the group value. Defaults to the last path segment. */
|
|
1227
|
-
alias?: string;
|
|
1515
|
+
alias?: string | undefined;
|
|
1228
1516
|
}
|
|
1229
1517
|
/**
|
|
1230
1518
|
* A JSON-path aggregate target inside `_sum` / `_avg` / `_min` / `_max` of
|
|
@@ -1244,7 +1532,7 @@ export interface JsonPathAggregateTarget {
|
|
|
1244
1532
|
/** JSON path into the column (each element a key or array index). Bound as one text[] param. */
|
|
1245
1533
|
path: (string | number)[];
|
|
1246
1534
|
/** Comparison/aggregation kind. `_sum`/`_avg` are always numeric; `_min`/`_max` default to text. */
|
|
1247
|
-
type?: 'numeric' | 'text';
|
|
1535
|
+
type?: 'numeric' | 'text' | undefined;
|
|
1248
1536
|
}
|
|
1249
1537
|
/**
|
|
1250
1538
|
* Per-aggregate spec map for `_sum` / `_avg` / `_min` / `_max` in
|
|
@@ -1295,27 +1583,27 @@ export type GroupByAggregateOrderBy = Record<string, OrderDirection | OrderBySpe
|
|
|
1295
1583
|
*/
|
|
1296
1584
|
export interface GroupByOrderBy {
|
|
1297
1585
|
/** Order by the group's row count (requires `_count` to be selected). */
|
|
1298
|
-
_count?: OrderDirection | OrderBySpec;
|
|
1586
|
+
_count?: OrderDirection | OrderBySpec | undefined;
|
|
1299
1587
|
/** Order by a requested `_sum` aggregate, keyed by its field/alias. */
|
|
1300
|
-
_sum?: GroupByAggregateOrderBy;
|
|
1588
|
+
_sum?: GroupByAggregateOrderBy | undefined;
|
|
1301
1589
|
/** Order by a requested `_avg` aggregate, keyed by its field/alias. */
|
|
1302
|
-
_avg?: GroupByAggregateOrderBy;
|
|
1590
|
+
_avg?: GroupByAggregateOrderBy | undefined;
|
|
1303
1591
|
/** Order by a requested `_min` aggregate, keyed by its field/alias. */
|
|
1304
|
-
_min?: GroupByAggregateOrderBy;
|
|
1592
|
+
_min?: GroupByAggregateOrderBy | undefined;
|
|
1305
1593
|
/** Order by a requested `_max` aggregate, keyed by its field/alias. */
|
|
1306
|
-
_max?: GroupByAggregateOrderBy;
|
|
1594
|
+
_max?: GroupByAggregateOrderBy | undefined;
|
|
1307
1595
|
/** A by-column field name or JSON group-key alias → direction or sort spec. */
|
|
1308
1596
|
[key: string]: OrderDirection | OrderBySpec | GroupByAggregateOrderBy | undefined;
|
|
1309
1597
|
}
|
|
1310
1598
|
export interface GroupByArgs<T, R extends object = {}> {
|
|
1311
1599
|
/** Group keys: plain column field names and/or JSON-path keys ({@link JsonPathGroupKey}). */
|
|
1312
1600
|
by: ((keyof T & string) | JsonPathGroupKey)[];
|
|
1313
|
-
where?: WhereClause<T, R
|
|
1601
|
+
where?: WhereClause<T, R> | undefined;
|
|
1314
1602
|
/**
|
|
1315
1603
|
* PostgreSQL only: group over one representative row per column combination
|
|
1316
1604
|
* (`SELECT DISTINCT ON … ORDER BY …` row source). See {@link GroupByDistinctOn}.
|
|
1317
1605
|
*/
|
|
1318
|
-
distinctOn?: GroupByDistinctOn<T
|
|
1606
|
+
distinctOn?: GroupByDistinctOn<T> | undefined;
|
|
1319
1607
|
/**
|
|
1320
1608
|
* Count each group. `true` (or omitted) → `_count: number` (COUNT(*)). The
|
|
1321
1609
|
* record form counts per selection: the reserved `_all: true` key → COUNT(*),
|
|
@@ -1325,17 +1613,19 @@ export interface GroupByArgs<T, R extends object = {}> {
|
|
|
1325
1613
|
*/
|
|
1326
1614
|
_count?: true | ({
|
|
1327
1615
|
_all?: true;
|
|
1328
|
-
} & Partial<Record<keyof T & string, boolean>>);
|
|
1616
|
+
} & Partial<Record<keyof T & string, boolean>>) | undefined;
|
|
1329
1617
|
/** Sum of numeric fields (or JSON paths: see {@link JsonPathAggregateTarget}) in each group */
|
|
1330
|
-
_sum?: GroupByAggregateSpec<T
|
|
1618
|
+
_sum?: GroupByAggregateSpec<T> | undefined;
|
|
1331
1619
|
/** Average of numeric fields (or JSON paths) in each group */
|
|
1332
|
-
_avg?: GroupByAggregateSpec<T
|
|
1620
|
+
_avg?: GroupByAggregateSpec<T> | undefined;
|
|
1333
1621
|
/** Minimum value of fields (or JSON paths) in each group */
|
|
1334
|
-
_min?: GroupByAggregateSpec<T
|
|
1622
|
+
_min?: GroupByAggregateSpec<T> | undefined;
|
|
1335
1623
|
/** Maximum value of fields (or JSON paths) in each group */
|
|
1336
|
-
_max?: GroupByAggregateSpec<T
|
|
1624
|
+
_max?: GroupByAggregateSpec<T> | undefined;
|
|
1625
|
+
/** Percentiles of fields in each group (PostgreSQL only). See {@link PercentileSpec}. */
|
|
1626
|
+
_percentile?: Partial<Record<keyof T & string, PercentileSpec>> | undefined;
|
|
1337
1627
|
/** Filter whole groups by their aggregate values (SQL HAVING). JSON-path aggregates key by their alias. */
|
|
1338
|
-
having?: HavingClause<T
|
|
1628
|
+
having?: HavingClause<T> | undefined;
|
|
1339
1629
|
/**
|
|
1340
1630
|
* Order the result groups. Keys may be any column the groupBy result actually
|
|
1341
1631
|
* contains: a plain by-column field name, a JSON group-key alias (explicit
|
|
@@ -1347,34 +1637,34 @@ export interface GroupByArgs<T, R extends object = {}> {
|
|
|
1347
1637
|
* Accepts a single object or a Prisma-style array of objects
|
|
1348
1638
|
* (`[{ region: 'asc' }, { _count: 'desc' }]`, array order authoritative).
|
|
1349
1639
|
*/
|
|
1350
|
-
orderBy?: GroupByOrderBy | GroupByOrderBy[];
|
|
1640
|
+
orderBy?: GroupByOrderBy | GroupByOrderBy[] | undefined;
|
|
1351
1641
|
/**
|
|
1352
1642
|
* Cap the number of result groups (`LIMIT`, applied after `ORDER BY`). Useful
|
|
1353
1643
|
* for "top N groups" queries; pair with `orderBy` for a deterministic set.
|
|
1354
1644
|
*/
|
|
1355
|
-
limit?: number;
|
|
1645
|
+
limit?: number | undefined;
|
|
1356
1646
|
/**
|
|
1357
1647
|
* Skip this many result groups (`OFFSET`, applied after `ORDER BY`). Paginates
|
|
1358
1648
|
* grouped results; combine with `limit` and a deterministic `orderBy`.
|
|
1359
1649
|
*/
|
|
1360
|
-
offset?: number;
|
|
1650
|
+
offset?: number | undefined;
|
|
1361
1651
|
/**
|
|
1362
1652
|
* Opt in to grouping on / aggregating PII-tagged (`defineSchema` `pii: true`)
|
|
1363
|
-
* columns. A PII column in `by`, and `_min` / `_max` over a
|
|
1364
|
-
* STORED VALUES, so without this they throw
|
|
1365
|
-
* `_count` (a count, not a value), `_sum` / `_avg`,
|
|
1366
|
-
* `having` on PII columns stay allowed.
|
|
1653
|
+
* columns. A PII column in `by`, and `_min` / `_max` / `_percentile` over a
|
|
1654
|
+
* PII column, return STORED VALUES, so without this they throw
|
|
1655
|
+
* `ValidationError` (E003). `_count` (a count, not a value), `_sum` / `_avg`,
|
|
1656
|
+
* and `where` / `orderBy` / `having` on PII columns stay allowed.
|
|
1367
1657
|
*
|
|
1368
1658
|
* PRIVILEGE OPTION: unlocked by the {@link UNSAFE} sentinel only. See
|
|
1369
1659
|
* {@link FindManyArgs.includePii}.
|
|
1370
1660
|
*/
|
|
1371
|
-
includePii?: Unsafe;
|
|
1661
|
+
includePii?: Unsafe | undefined;
|
|
1372
1662
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1373
|
-
timeout?: number;
|
|
1663
|
+
timeout?: number | undefined;
|
|
1374
1664
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1375
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1665
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1376
1666
|
/** Plan this query with its real parameter values. See {@link FindManyArgs.forceCustomPlan}. */
|
|
1377
|
-
forceCustomPlan?: boolean;
|
|
1667
|
+
forceCustomPlan?: boolean | undefined;
|
|
1378
1668
|
}
|
|
1379
1669
|
/** The by-key union of a groupBy args type (array element type of `by`). */
|
|
1380
1670
|
type GroupByKeys<A> = A extends {
|
|
@@ -1427,7 +1717,7 @@ type GroupByMinMaxPart<T, A, Key extends '_min' | '_max'> = A extends {
|
|
|
1427
1717
|
*/
|
|
1428
1718
|
export type GroupByResult<T, A> = {
|
|
1429
1719
|
[K in GroupByFieldKeys<T, A>]: T[K];
|
|
1430
|
-
} & GroupByCountPart<A> & GroupBySumAvgPart<A, '_sum'> & GroupBySumAvgPart<A, '_avg'> & GroupByMinMaxPart<T, A, '_min'> & GroupByMinMaxPart<T, A, '_max'>;
|
|
1720
|
+
} & GroupByCountPart<A> & GroupBySumAvgPart<A, '_sum'> & GroupBySumAvgPart<A, '_avg'> & GroupByMinMaxPart<T, A, '_min'> & GroupByMinMaxPart<T, A, '_max'> & PercentilePart<T, A>;
|
|
1431
1721
|
/**
|
|
1432
1722
|
* The `_count` block on a groupBy result row. Scalar `_count: true` (or an
|
|
1433
1723
|
* omitted `_count`, which still selects COUNT(*) by default) yields a plain
|
|
@@ -1450,7 +1740,7 @@ type GroupByCountPart<A> = A extends {
|
|
|
1450
1740
|
};
|
|
1451
1741
|
/** Arguments for the standalone aggregate method */
|
|
1452
1742
|
export interface AggregateArgs<T, R extends object = {}> {
|
|
1453
|
-
where?: WhereClause<T, R
|
|
1743
|
+
where?: WhereClause<T, R> | undefined;
|
|
1454
1744
|
/**
|
|
1455
1745
|
* Count rows. `true` → `_count: number` (COUNT(*)). The record form counts per
|
|
1456
1746
|
* selection: the reserved `_all: true` key → COUNT(*), and each entity field
|
|
@@ -1459,32 +1749,46 @@ export interface AggregateArgs<T, R extends object = {}> {
|
|
|
1459
1749
|
*/
|
|
1460
1750
|
_count?: true | ({
|
|
1461
1751
|
_all?: true;
|
|
1462
|
-
} & Partial<Record<keyof T & string, boolean>>);
|
|
1752
|
+
} & Partial<Record<keyof T & string, boolean>>) | undefined;
|
|
1463
1753
|
/** Sum of numeric fields */
|
|
1464
|
-
_sum?: Partial<Record<keyof T & string, boolean
|
|
1754
|
+
_sum?: Partial<Record<keyof T & string, boolean>> | undefined;
|
|
1465
1755
|
/** Average of numeric fields */
|
|
1466
|
-
_avg?: Partial<Record<keyof T & string, boolean
|
|
1756
|
+
_avg?: Partial<Record<keyof T & string, boolean>> | undefined;
|
|
1467
1757
|
/** Minimum value of fields */
|
|
1468
|
-
_min?: Partial<Record<keyof T & string, boolean
|
|
1758
|
+
_min?: Partial<Record<keyof T & string, boolean>> | undefined;
|
|
1469
1759
|
/** Maximum value of fields */
|
|
1470
|
-
_max?: Partial<Record<keyof T & string, boolean
|
|
1760
|
+
_max?: Partial<Record<keyof T & string, boolean>> | undefined;
|
|
1761
|
+
/**
|
|
1762
|
+
* Percentiles of fields (PostgreSQL only; other engines throw E017).
|
|
1763
|
+
*
|
|
1764
|
+
* ```ts
|
|
1765
|
+
* const s = await db.requests.aggregate({
|
|
1766
|
+
* _percentile: { latencyMs: { p: [0.5, 0.95, 0.99] }, statusCode: { p: 0.5, method: 'disc' } },
|
|
1767
|
+
* });
|
|
1768
|
+
* s._percentile.latencyMs; // number[] | null
|
|
1769
|
+
* s._percentile.statusCode; // number | null
|
|
1770
|
+
* ```
|
|
1771
|
+
*
|
|
1772
|
+
* See {@link PercentileSpec}.
|
|
1773
|
+
*/
|
|
1774
|
+
_percentile?: Partial<Record<keyof T & string, PercentileSpec>> | undefined;
|
|
1471
1775
|
/**
|
|
1472
1776
|
* Opt in to aggregating PII-tagged (`defineSchema` `pii: true`) columns.
|
|
1473
|
-
* `_min` / `_max` return a STORED VALUE
|
|
1474
|
-
*
|
|
1475
|
-
* and `_sum` / `_avg` (a computed
|
|
1476
|
-
* `where` filters on PII columns.
|
|
1777
|
+
* `_min` / `_max` / `_percentile` return a STORED VALUE (or one that equals a
|
|
1778
|
+
* stored value), so without this they throw `ValidationError` (E003) on a PII
|
|
1779
|
+
* column. `_count` (a count, not a value) and `_sum` / `_avg` (a computed
|
|
1780
|
+
* total over many rows) stay allowed, as do `where` filters on PII columns.
|
|
1477
1781
|
*
|
|
1478
1782
|
* PRIVILEGE OPTION: unlocked by the {@link UNSAFE} sentinel only. See
|
|
1479
1783
|
* {@link FindManyArgs.includePii}.
|
|
1480
1784
|
*/
|
|
1481
|
-
includePii?: Unsafe;
|
|
1785
|
+
includePii?: Unsafe | undefined;
|
|
1482
1786
|
/** Query timeout in milliseconds. Rejects with an error if exceeded. */
|
|
1483
|
-
timeout?: number;
|
|
1787
|
+
timeout?: number | undefined;
|
|
1484
1788
|
/** Opt out of configured {@link GlobalFilters}. See {@link SkipGlobalFilters}. */
|
|
1485
|
-
skipGlobalFilters?: SkipGlobalFilters;
|
|
1789
|
+
skipGlobalFilters?: SkipGlobalFilters | undefined;
|
|
1486
1790
|
/** Plan this query with its real parameter values. See {@link FindManyArgs.forceCustomPlan}. */
|
|
1487
|
-
forceCustomPlan?: boolean;
|
|
1791
|
+
forceCustomPlan?: boolean | undefined;
|
|
1488
1792
|
}
|
|
1489
1793
|
/**
|
|
1490
1794
|
* Result type for aggregate queries.
|
|
@@ -1502,29 +1806,101 @@ export interface AggregateResult<T> {
|
|
|
1502
1806
|
_avg?: Partial<Record<keyof T & string, number | string | null>>;
|
|
1503
1807
|
_min?: Partial<Record<keyof T & string, unknown>>;
|
|
1504
1808
|
_max?: Partial<Record<keyof T & string, unknown>>;
|
|
1809
|
+
_percentile?: Partial<Record<keyof T & string, unknown>>;
|
|
1505
1810
|
}
|
|
1811
|
+
/**
|
|
1812
|
+
* The result of `aggregate(args)`, derived from the args: only the blocks the
|
|
1813
|
+
* call requested are present, each keyed by exactly the requested fields.
|
|
1814
|
+
* `_sum` / `_avg` follow {@link AggregateResult}'s number-or-string rule;
|
|
1815
|
+
* `_min` / `_max` carry the column's own type, or `null` over zero rows;
|
|
1816
|
+
* `_percentile` follows {@link PercentileSpec}.
|
|
1817
|
+
*/
|
|
1818
|
+
export type AggregateResultOf<T, A> = AggregateCountPart<A> & GroupBySumAvgPart<A, '_sum'> & GroupBySumAvgPart<A, '_avg'> & AggregateMinMaxPart<T, A, '_min'> & AggregateMinMaxPart<T, A, '_max'> & PercentilePart<T, A>;
|
|
1819
|
+
/**
|
|
1820
|
+
* One `_percentile` entry: which fractions of a column to compute.
|
|
1821
|
+
*
|
|
1822
|
+
* - `p`: a fraction in [0, 1], or a non-empty array of them. The result
|
|
1823
|
+
* mirrors the shape: a scalar for a number, an array (in the same order)
|
|
1824
|
+
* for an array. A fraction outside [0, 1], `NaN` or `[]` throws E003.
|
|
1825
|
+
* - `method`: `'cont'` (the default, `percentile_cont`) interpolates between
|
|
1826
|
+
* the two nearest values, so it needs a numeric or interval column. It
|
|
1827
|
+
* returns a `number` (a numeric or int8 column included), or an interval
|
|
1828
|
+
* read the way the column reads. `'cont'` on a date/time column throws E003.
|
|
1829
|
+
* `'disc'` (`percentile_disc`) returns an actual stored value of the
|
|
1830
|
+
* column, so it works on any sortable column and carries the column's own
|
|
1831
|
+
* type.
|
|
1832
|
+
*
|
|
1833
|
+
* Over zero rows the result is `null` (the whole array in the array form).
|
|
1834
|
+
* Both methods need `includePii: UNSAFE` on a PII-tagged column.
|
|
1835
|
+
*/
|
|
1836
|
+
export interface PercentileSpec {
|
|
1837
|
+
p: number | readonly number[];
|
|
1838
|
+
method?: PercentileMethod | undefined;
|
|
1839
|
+
}
|
|
1840
|
+
/** `'cont'` interpolates (`percentile_cont`); `'disc'` returns a stored value (`percentile_disc`). */
|
|
1841
|
+
export type PercentileMethod = 'cont' | 'disc';
|
|
1842
|
+
/** One percentile value: the column's own type for `disc`; for `cont` a number, or an interval as the column reads. */
|
|
1843
|
+
type PercentileScalar<T, K, Spec> = K extends keyof T ? Spec extends {
|
|
1844
|
+
method: 'disc';
|
|
1845
|
+
} ? NonNullable<T[K]> : [NonNullable<T[K]>] extends [number] ? number : number | NonNullable<T[K]> : unknown;
|
|
1846
|
+
/** A scalar `p` yields one value, an array `p` yields an array, `null` over zero rows. */
|
|
1847
|
+
type PercentileValue<T, K, Spec> = Spec extends {
|
|
1848
|
+
p: infer P;
|
|
1849
|
+
} ? P extends readonly number[] ? PercentileScalar<T, K, Spec>[] | null : PercentileScalar<T, K, Spec> | null : unknown;
|
|
1850
|
+
/** The `_percentile` block of an aggregate or groupBy result, present only when requested. */
|
|
1851
|
+
type PercentilePart<T, A> = A extends {
|
|
1852
|
+
_percentile: infer S;
|
|
1853
|
+
} ? [S] extends [object] ? {
|
|
1854
|
+
_percentile: {
|
|
1855
|
+
[K in keyof S & string]: PercentileValue<T, K, S[K]>;
|
|
1856
|
+
};
|
|
1857
|
+
} : unknown : unknown;
|
|
1858
|
+
type AggregateCountPart<A> = A extends {
|
|
1859
|
+
_count: infer C;
|
|
1860
|
+
} ? C extends true ? {
|
|
1861
|
+
_count: number;
|
|
1862
|
+
} : [C] extends [object] ? {
|
|
1863
|
+
_count: {
|
|
1864
|
+
[K in keyof C & string]: number;
|
|
1865
|
+
};
|
|
1866
|
+
} : unknown : unknown;
|
|
1867
|
+
type AggregateMinMaxPart<T, A, Key extends '_min' | '_max'> = A extends {
|
|
1868
|
+
[P in Key]: infer S;
|
|
1869
|
+
} ? [S] extends [object] ? {
|
|
1870
|
+
[P in Key]: {
|
|
1871
|
+
[K in keyof S & string]: (K extends keyof T ? T[K] : unknown) | null;
|
|
1872
|
+
};
|
|
1873
|
+
} : unknown : unknown;
|
|
1506
1874
|
/** Relation filter operators for where clauses */
|
|
1507
1875
|
export interface RelationFilter {
|
|
1508
|
-
some?: Record<string, unknown
|
|
1509
|
-
every?: Record<string, unknown
|
|
1510
|
-
none?: Record<string, unknown
|
|
1876
|
+
some?: Record<string, unknown> | undefined;
|
|
1877
|
+
every?: Record<string, unknown> | undefined;
|
|
1878
|
+
none?: Record<string, unknown> | undefined;
|
|
1511
1879
|
/** To-one relation match (bare objects on to-one keys are implicit `is`). */
|
|
1512
|
-
is?: Record<string, unknown
|
|
1513
|
-
isNot?: Record<string, unknown
|
|
1880
|
+
is?: Record<string, unknown> | undefined;
|
|
1881
|
+
isNot?: Record<string, unknown> | undefined;
|
|
1514
1882
|
}
|
|
1515
1883
|
/**
|
|
1516
1884
|
* JSONB query operators for where clauses.
|
|
1517
1885
|
*
|
|
1518
|
-
*
|
|
1519
|
-
*
|
|
1520
|
-
* the
|
|
1886
|
+
* `{ path, equals }` compares the JSON VALUE at `path`, typed:
|
|
1887
|
+
* - PostgreSQL: `(col #> path)::jsonb = $v::jsonb`, so `equals: 7` matches a
|
|
1888
|
+
* JSON number 7 and not the string `"7"`, `equals: null` matches a JSON
|
|
1889
|
+
* null (not a missing key), and arrays and objects compare as JSON.
|
|
1890
|
+
* - SQLite: `json_extract` keeps numbers and strings apart; `equals` with a
|
|
1891
|
+
* boolean, null, array or object throws `UnsupportedFeatureError` (E017),
|
|
1892
|
+
* because SQLite extracts JSON booleans as 1 / 0 and null, arrays and
|
|
1893
|
+
* objects have no comparable form there.
|
|
1894
|
+
* - MySQL and SQL Server compare the extracted TEXT, so `equals: 7` also
|
|
1895
|
+
* matches `"7"`; null, arrays and objects throw E017.
|
|
1896
|
+
*
|
|
1897
|
+
* PowDB (`turbine-orm/powdb`) evaluates `->` path filters with full type
|
|
1898
|
+
* knowledge:
|
|
1521
1899
|
* - `{ path, equals: null }` matches JSON null OR a MISSING key on PowDB
|
|
1522
|
-
* (compiles to `is null`)
|
|
1523
|
-
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1526
|
-
* matches `equals: 7` against the string `"7"`). Range ops (`gt`/`lt`/…)
|
|
1527
|
-
* still coerce int/float numerically.
|
|
1900
|
+
* (compiles to `is null`); PostgreSQL matches JSON null only.
|
|
1901
|
+
* - equality is TYPE-STRICT: `{ path, equals: 7 }` matches a stored JSON int
|
|
1902
|
+
* `7` but not `7.0` or the JSON string `"7"`. Range ops (`gt`/`lt`/…) still
|
|
1903
|
+
* coerce int/float numerically.
|
|
1528
1904
|
* - a digit-only path segment (`path: ['tags', '0']`) is an ARRAY INDEX on
|
|
1529
1905
|
* both PowDB and the SQL engines (a json object key that is literally `"0"`
|
|
1530
1906
|
* is likewise addressed by index).
|
|
@@ -1534,28 +1910,32 @@ export interface RelationFilter {
|
|
|
1534
1910
|
*/
|
|
1535
1911
|
export interface JsonFilter {
|
|
1536
1912
|
/**
|
|
1537
|
-
* Access nested path
|
|
1913
|
+
* Access a nested path (`#>` / `#>>` on Postgres, `->` on PowDB). A
|
|
1538
1914
|
* digit-only segment (`'0'`) is treated as an array index on every engine.
|
|
1539
1915
|
*/
|
|
1540
|
-
path?: string[];
|
|
1541
|
-
/**
|
|
1542
|
-
|
|
1916
|
+
path?: string[] | undefined;
|
|
1917
|
+
/**
|
|
1918
|
+
* With `path`: the JSON value at the path equals this value (typed on
|
|
1919
|
+
* PostgreSQL, see {@link JsonFilter}). Without `path`: containment,
|
|
1920
|
+
* `column @> value::jsonb` (E017 on PowDB).
|
|
1921
|
+
*/
|
|
1922
|
+
equals?: unknown | undefined;
|
|
1543
1923
|
/** Containment check: `column @> value::jsonb`. Unsupported on PowDB (E017: PowQL has no containment operator). */
|
|
1544
|
-
contains?: unknown;
|
|
1924
|
+
contains?: unknown | undefined;
|
|
1545
1925
|
/** Key existence check: `column ? key`. */
|
|
1546
|
-
hasKey?: string;
|
|
1926
|
+
hasKey?: string | undefined;
|
|
1547
1927
|
/**
|
|
1548
1928
|
* Greater-than comparison of the value at `path` (required). Numbers cast
|
|
1549
1929
|
* the extracted text to numeric, `(col #>> path)::numeric > $n`, while
|
|
1550
1930
|
* strings compare as text.
|
|
1551
1931
|
*/
|
|
1552
|
-
gt?: number | string;
|
|
1932
|
+
gt?: number | string | undefined;
|
|
1553
1933
|
/** Greater-than-or-equal comparison of the value at `path` (required). See {@link JsonFilter.gt}. */
|
|
1554
|
-
gte?: number | string;
|
|
1934
|
+
gte?: number | string | undefined;
|
|
1555
1935
|
/** Less-than comparison of the value at `path` (required). See {@link JsonFilter.gt}. */
|
|
1556
|
-
lt?: number | string;
|
|
1936
|
+
lt?: number | string | undefined;
|
|
1557
1937
|
/** Less-than-or-equal comparison of the value at `path` (required). See {@link JsonFilter.gt}. */
|
|
1558
|
-
lte?: number | string;
|
|
1938
|
+
lte?: number | string | undefined;
|
|
1559
1939
|
/**
|
|
1560
1940
|
* Substring match against the TEXT at `path` (required): `col #>> path LIKE
|
|
1561
1941
|
* '%value%'`. This is Prisma's `string_contains`.
|
|
@@ -1564,35 +1944,35 @@ export interface JsonFilter {
|
|
|
1564
1944
|
* whole-document containment (`@>`) and means something entirely different.
|
|
1565
1945
|
* The operand is LIKE-escaped, so `%` and `_` match literally.
|
|
1566
1946
|
*/
|
|
1567
|
-
stringContains?: string;
|
|
1947
|
+
stringContains?: string | undefined;
|
|
1568
1948
|
/** Prefix match against the text at `path` (required). Prisma's `string_starts_with`. See {@link JsonFilter.stringContains}. */
|
|
1569
|
-
stringStartsWith?: string;
|
|
1949
|
+
stringStartsWith?: string | undefined;
|
|
1570
1950
|
/** Suffix match against the text at `path` (required). Prisma's `string_ends_with`. See {@link JsonFilter.stringContains}. */
|
|
1571
|
-
stringEndsWith?: string;
|
|
1951
|
+
stringEndsWith?: string | undefined;
|
|
1572
1952
|
/**
|
|
1573
1953
|
* Case-insensitive matching for the substring operators above (ILIKE on
|
|
1574
1954
|
* PostgreSQL, the dialect's equivalent elsewhere). Has no effect on
|
|
1575
1955
|
* `equals` / `contains` / `hasKey` / the range operators.
|
|
1576
1956
|
*/
|
|
1577
|
-
mode?: 'default' | 'insensitive';
|
|
1957
|
+
mode?: 'default' | 'insensitive' | undefined;
|
|
1578
1958
|
}
|
|
1579
1959
|
/** Array query operators for where clauses */
|
|
1580
1960
|
export interface ArrayFilter {
|
|
1581
1961
|
/** Check if array contains a single value: value = ANY(column) */
|
|
1582
|
-
has?: unknown;
|
|
1962
|
+
has?: unknown | undefined;
|
|
1583
1963
|
/** Check if array contains ALL values: column @> ARRAY[...] */
|
|
1584
|
-
hasEvery?: unknown[];
|
|
1964
|
+
hasEvery?: unknown[] | undefined;
|
|
1585
1965
|
/** Check if array has ANY of the values: column && ARRAY[...] */
|
|
1586
|
-
hasSome?: unknown[];
|
|
1966
|
+
hasSome?: unknown[] | undefined;
|
|
1587
1967
|
/** Check if array is empty: array_length(column, 1) IS NULL */
|
|
1588
|
-
isEmpty?: boolean;
|
|
1968
|
+
isEmpty?: boolean | undefined;
|
|
1589
1969
|
}
|
|
1590
1970
|
/** Full-text search filter using PostgreSQL to_tsvector / to_tsquery */
|
|
1591
1971
|
export interface TextSearchFilter {
|
|
1592
1972
|
/** The search query string passed to to_tsquery */
|
|
1593
1973
|
search: string;
|
|
1594
1974
|
/** PostgreSQL text search configuration name (defaults to 'english') */
|
|
1595
|
-
config?: string;
|
|
1975
|
+
config?: string | undefined;
|
|
1596
1976
|
}
|
|
1597
1977
|
/**
|
|
1598
1978
|
* Vector distance metric. Maps to a pgvector distance operator:
|
|
@@ -1623,13 +2003,13 @@ export interface VectorDistanceFilter {
|
|
|
1623
2003
|
/** Distance metric → operator. */
|
|
1624
2004
|
metric: VectorMetric;
|
|
1625
2005
|
/** distance < threshold */
|
|
1626
|
-
lt?: number;
|
|
2006
|
+
lt?: number | undefined;
|
|
1627
2007
|
/** distance <= threshold */
|
|
1628
|
-
lte?: number;
|
|
2008
|
+
lte?: number | undefined;
|
|
1629
2009
|
/** distance > threshold */
|
|
1630
|
-
gt?: number;
|
|
2010
|
+
gt?: number | undefined;
|
|
1631
2011
|
/** distance >= threshold */
|
|
1632
|
-
gte?: number;
|
|
2012
|
+
gte?: number | undefined;
|
|
1633
2013
|
}
|
|
1634
2014
|
/** Vector query operators for where clauses (pgvector). */
|
|
1635
2015
|
export interface VectorFilter {
|
|
@@ -1651,7 +2031,7 @@ export interface VectorOrderByDistance {
|
|
|
1651
2031
|
to: number[];
|
|
1652
2032
|
metric: VectorMetric;
|
|
1653
2033
|
/** Sort direction for the computed distance. Defaults to `'asc'` (nearest first). */
|
|
1654
|
-
direction?: OrderDirection;
|
|
2034
|
+
direction?: OrderDirection | undefined;
|
|
1655
2035
|
}
|
|
1656
2036
|
/** Per-column orderBy value: a plain direction or a vector-distance ordering. */
|
|
1657
2037
|
export interface VectorOrderBy {
|
|
@@ -1667,7 +2047,7 @@ export interface VectorOrderBy {
|
|
|
1667
2047
|
*/
|
|
1668
2048
|
export interface OrderBySpec {
|
|
1669
2049
|
sort: OrderDirection;
|
|
1670
|
-
nulls?: 'first' | 'last';
|
|
2050
|
+
nulls?: 'first' | 'last' | undefined;
|
|
1671
2051
|
}
|
|
1672
2052
|
/**
|
|
1673
2053
|
* Ordering by a JSON path on a json/jsonb column of the SAME table:
|
|
@@ -1689,9 +2069,9 @@ export interface JsonPathOrderBy {
|
|
|
1689
2069
|
/** JSON path into the column (each element a key or array index). Bound as one text[] param. */
|
|
1690
2070
|
path: (string | number)[];
|
|
1691
2071
|
/** Sort direction. Defaults to `'asc'`. */
|
|
1692
|
-
direction?: OrderDirection;
|
|
2072
|
+
direction?: OrderDirection | undefined;
|
|
1693
2073
|
/** Comparison kind for the extracted value. Defaults to `'text'`; `'numeric'` adds a numeric cast. */
|
|
1694
|
-
type?: 'numeric' | 'text';
|
|
2074
|
+
type?: 'numeric' | 'text' | undefined;
|
|
1695
2075
|
/**
|
|
1696
2076
|
* NULLS placement (PostgreSQL / SQLite only: see {@link OrderBySpec}).
|
|
1697
2077
|
* Rows whose document lacks the path extract to NULL and sort LAST in BOTH
|
|
@@ -1699,7 +2079,7 @@ export interface JsonPathOrderBy {
|
|
|
1699
2079
|
* contract, so ordering is predictable across drivers); set `nulls` to
|
|
1700
2080
|
* override on PostgreSQL / SQLite.
|
|
1701
2081
|
*/
|
|
1702
|
-
nulls?: 'first' | 'last';
|
|
2082
|
+
nulls?: 'first' | 'last' | undefined;
|
|
1703
2083
|
}
|
|
1704
2084
|
/**
|
|
1705
2085
|
* Ordering by a relation, keyed by the relation name in an {@link OrderByClause}:
|
|
@@ -1757,7 +2137,7 @@ export type RelationPickBy = string | {
|
|
|
1757
2137
|
*/
|
|
1758
2138
|
path: (string | number)[];
|
|
1759
2139
|
/** Comparison kind for the extracted value. Defaults to `'text'`. */
|
|
1760
|
-
type?: 'numeric' | 'text';
|
|
2140
|
+
type?: 'numeric' | 'text' | undefined;
|
|
1761
2141
|
};
|
|
1762
2142
|
/**
|
|
1763
2143
|
* Pick-row relation ordering: order a parent query by a value read from ONE
|
|
@@ -1791,12 +2171,12 @@ export interface RelationPickOrderBy {
|
|
|
1791
2171
|
/** Inner ORDER BY choosing the row (required for determinism). */
|
|
1792
2172
|
orderBy: Record<string, OrderDirection | OrderBySpec | JsonPathOrderBy>;
|
|
1793
2173
|
/** Optional filter on the candidate rows before picking. */
|
|
1794
|
-
where?: Record<string, unknown
|
|
2174
|
+
where?: Record<string, unknown> | undefined;
|
|
1795
2175
|
};
|
|
1796
2176
|
/** The value on the picked row to order the parents by. */
|
|
1797
2177
|
by: RelationPickBy;
|
|
1798
2178
|
/** Sort direction for the parents. Defaults to `'asc'`. */
|
|
1799
|
-
direction?: OrderDirection;
|
|
2179
|
+
direction?: OrderDirection | undefined;
|
|
1800
2180
|
/**
|
|
1801
2181
|
* NULLS placement (PostgreSQL / SQLite only: see {@link OrderBySpec}).
|
|
1802
2182
|
*
|
|
@@ -1806,7 +2186,7 @@ export interface RelationPickOrderBy {
|
|
|
1806
2186
|
* NULLS FIRST, which would put every childless parent at the top of a
|
|
1807
2187
|
* "highest first" sort). Set `nulls` explicitly to override.
|
|
1808
2188
|
*/
|
|
1809
|
-
nulls?: 'first' | 'last';
|
|
2189
|
+
nulls?: 'first' | 'last' | undefined;
|
|
1810
2190
|
/**
|
|
1811
2191
|
* Physical plan for the pick. `'subquery'` (default) compiles a correlated
|
|
1812
2192
|
* scalar subquery in ORDER BY. `'lateral'` (PostgreSQL only, E017 elsewhere)
|
|
@@ -1817,7 +2197,7 @@ export interface RelationPickOrderBy {
|
|
|
1817
2197
|
* engines, `distinct`, nested `with` orderBy, a parent column literally named
|
|
1818
2198
|
* `__turbine_pick`) throw.
|
|
1819
2199
|
*/
|
|
1820
|
-
plan?: 'subquery' | 'lateral';
|
|
2200
|
+
plan?: 'subquery' | 'lateral' | undefined;
|
|
1821
2201
|
}
|
|
1822
2202
|
/**
|
|
1823
2203
|
* A single orderBy object: maps each key to one of:
|
|
@@ -1839,4 +2219,3 @@ export type OrderByObject = Record<string, OrderDirection | OrderBySpec | JsonPa
|
|
|
1839
2219
|
* param-collect, and cache-fingerprint paths stay in lockstep.
|
|
1840
2220
|
*/
|
|
1841
2221
|
export type OrderByClause = OrderByObject | OrderByObject[];
|
|
1842
|
-
export {};
|