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
package/dist/query/where.d.ts
CHANGED
|
@@ -10,14 +10,17 @@
|
|
|
10
10
|
* instance (built once in its constructor) exposing exactly the class-resident
|
|
11
11
|
* primitives this module needs. See builder.ts for the thin delegating methods.
|
|
12
12
|
*/
|
|
13
|
+
import { type ResolvedDiagnostics } from '../diagnostics.js';
|
|
13
14
|
import type { Dialect } from '../dialect.js';
|
|
14
15
|
import { ValidationError } from '../errors.js';
|
|
16
|
+
import { type TurbineLogger } from '../logger.js';
|
|
15
17
|
import type { PgCompatQueryResult } from '../pg-types.js';
|
|
16
18
|
import type { RelationDef, SchemaMetadata, TableMetadata } from '../schema.js';
|
|
17
19
|
import type { TemporalInfinityReading } from './deferred.js';
|
|
18
20
|
import type { ArrayFilter, ColumnRef, GlobalFilters, JsonEncoding, JsonFilter, JsonPathOrderBy, ResolvedSkipGlobalFilters, TextSearchFilter, VectorFilter, WhereClause, WhereOperator } from './types.js';
|
|
19
21
|
import { type SqlCacheEntry } from './utils.js';
|
|
20
22
|
import { type WhereHost, type WhereRecord } from './where-compile.js';
|
|
23
|
+
export { assertJsonFilterKeys } from './filters.js';
|
|
21
24
|
/**
|
|
22
25
|
* The privacy-preserving view of a {@link QueryInterface} instance passed as the
|
|
23
26
|
* first argument to every function in this module. Built once as an object
|
|
@@ -51,6 +54,14 @@ export interface BuilderCtx {
|
|
|
51
54
|
* default.
|
|
52
55
|
*/
|
|
53
56
|
readonly temporalInfinity?: TemporalInfinityReading;
|
|
57
|
+
/**
|
|
58
|
+
* The owning client's resolved `diagnostics`. Resolved once, at client
|
|
59
|
+
* construction; the modules never read the environment. Read through
|
|
60
|
+
* {@link adviceLogger}.
|
|
61
|
+
*/
|
|
62
|
+
readonly diagnostics?: ResolvedDiagnostics;
|
|
63
|
+
/** The owning client's logger. Read through {@link adviceLogger}. */
|
|
64
|
+
readonly logger?: TurbineLogger;
|
|
54
65
|
readonly crossSchemaTypeColumns: Set<string>;
|
|
55
66
|
/**
|
|
56
67
|
* The active query's `skipGlobalFilters` opt-out. A live getter/setter over
|
|
@@ -158,6 +169,16 @@ export interface BuilderCtx {
|
|
|
158
169
|
*/
|
|
159
170
|
paginationValue(value: unknown, arg?: string): number;
|
|
160
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Where per-query advice goes for this context: the client's logger when its
|
|
174
|
+
* `diagnostics.advice` is on, else `undefined`. A site calls this first and
|
|
175
|
+
* builds its message only on a logger.
|
|
176
|
+
*
|
|
177
|
+
* A context without the client's diagnostics (one built by hand) resolves
|
|
178
|
+
* them here; every context a QueryInterface builds carries them, so on a query
|
|
179
|
+
* path this never reads the environment.
|
|
180
|
+
*/
|
|
181
|
+
export declare function adviceLogger(qi: Pick<BuilderCtx, 'diagnostics' | 'logger'>): TurbineLogger | undefined;
|
|
161
182
|
/**
|
|
162
183
|
* Column-reference resolution context threaded into
|
|
163
184
|
* {@link QueryInterface.buildOperatorClauses} / `collectOperatorParams`: the
|
|
@@ -177,6 +198,12 @@ interface ColumnRefContext {
|
|
|
177
198
|
* from here instead, the one value both sides pass identically.
|
|
178
199
|
*/
|
|
179
200
|
rawColumn: string;
|
|
201
|
+
/**
|
|
202
|
+
* The column's type token, which decides what its operands may be (see
|
|
203
|
+
* `operandColumnKind`). Resolved by the caller from the same source its
|
|
204
|
+
* classification used, identically on the build and collect side.
|
|
205
|
+
*/
|
|
206
|
+
pgType: string;
|
|
180
207
|
}
|
|
181
208
|
/**
|
|
182
209
|
* A table-scoped WHERE compilation context for a sub-where that is NOT the
|
|
@@ -219,10 +246,11 @@ interface WhereScope {
|
|
|
219
246
|
export declare function fingerprintWhere(qi: BuilderCtx, where: Record<string, unknown>, depth?: number): string;
|
|
220
247
|
/**
|
|
221
248
|
* Fingerprint the present branches of a normalized relation filter, in the
|
|
222
|
-
* fixed order some→every→none→is→isNot. A
|
|
223
|
-
* `<branch>(null)`; a present branch recurses through
|
|
249
|
+
* fixed order some→every→none→is→isNot. A present branch recurses through
|
|
224
250
|
* {@link fingerprintRelFilter} so the FULL inner shape is captured (two
|
|
225
|
-
* different sub-wheres must never collide on one cached SQL text).
|
|
251
|
+
* different sub-wheres must never collide on one cached SQL text). `is: null`
|
|
252
|
+
* and `isNot: null` tokenize as `<branch>(null)`; the where walk refuses any
|
|
253
|
+
* other non-object value before this runs.
|
|
226
254
|
*/
|
|
227
255
|
export declare function fingerprintRelationParts(qi: BuilderCtx, relDef: RelationDef, filterObj: WhereRecord, depth?: number): string[];
|
|
228
256
|
/**
|
|
@@ -235,11 +263,12 @@ export declare function fingerprintRelFilter(qi: BuilderCtx, targetTable: string
|
|
|
235
263
|
/**
|
|
236
264
|
* Walk a where clause and push ONLY values into `params`, in the EXACT same
|
|
237
265
|
* order that `buildWhereClause` pushes them. Used on cache hit to fill params
|
|
238
|
-
* without rebuilding SQL.
|
|
266
|
+
* without rebuilding SQL. Returns whether the clause compiles to a condition,
|
|
267
|
+
* i.e. whether `buildWhereClause` returns non-null for it.
|
|
239
268
|
*
|
|
240
269
|
* @internal Exposed as package-private for testing.
|
|
241
270
|
*/
|
|
242
|
-
export declare function collectWhereParams(qi: BuilderCtx, where: Record<string, unknown>, params: unknown[], depth?: number):
|
|
271
|
+
export declare function collectWhereParams(qi: BuilderCtx, where: Record<string, unknown>, params: unknown[], depth?: number): boolean;
|
|
243
272
|
/**
|
|
244
273
|
* Push a scalar WHERE value's params, mirroring {@link buildScalarClause}'s
|
|
245
274
|
* emissions exactly. Both resolve the value's shape via the shared
|
|
@@ -259,14 +288,18 @@ export declare function collectScalarParams(qi: BuilderCtx, key: string, value:
|
|
|
259
288
|
* the gf calls are no-ops, so this stays byte-identical to the pre-0.28 path.
|
|
260
289
|
* Shared by every collect site that mirrors buildRelationFilter
|
|
261
290
|
* (collectWhereParams, collectRelFilterParams, collectAliasWhereParams).
|
|
291
|
+
* Returns whether {@link buildRelationFilter} emits a clause for it.
|
|
262
292
|
*/
|
|
263
|
-
export declare function collectRelationFilterParams(qi: BuilderCtx, relDef: RelationDef, filterObj: Record<string, unknown>, params: unknown[], depth?: number):
|
|
264
|
-
|
|
293
|
+
export declare function collectRelationFilterParams(qi: BuilderCtx, relDef: RelationDef, filterObj: Record<string, unknown>, params: unknown[], depth?: number): boolean;
|
|
294
|
+
/** Collect a relation sub-where's params; returns whether it compiles to a condition. */
|
|
295
|
+
export declare function collectRelFilterParams(qi: BuilderCtx, targetTable: string, subWhere: Record<string, unknown>, params: unknown[], depth?: number): boolean;
|
|
265
296
|
/**
|
|
266
297
|
* Collect params from operator clauses. Mirrors buildOperatorClauses:
|
|
267
298
|
* {@link ColumnRef} values compile into the SQL text, so they push NOTHING -
|
|
268
299
|
* but they re-run the same validation (unknown ref / insensitive mode) so a
|
|
269
|
-
* warmed cache can never skip a check the build path enforces.
|
|
300
|
+
* warmed cache can never skip a check the build path enforces. The operand
|
|
301
|
+
* validation ({@link assertOperatorOperands}) runs here too, for the same
|
|
302
|
+
* reason.
|
|
270
303
|
*/
|
|
271
304
|
export declare function collectOperatorParams(qi: BuilderCtx, column: string, op: WhereOperator, params: unknown[], refCtx?: ColumnRefContext): void;
|
|
272
305
|
/**
|
|
@@ -277,7 +310,7 @@ export declare function collectOperatorParams(qi: BuilderCtx, column: string, op
|
|
|
277
310
|
*/
|
|
278
311
|
export declare function collectJsonFilterParams(qi: BuilderCtx, filter: JsonFilter, params: unknown[], column: string): void;
|
|
279
312
|
/** Collect params from array filter. Mirrors buildArrayFilterClauses. */
|
|
280
|
-
export declare function collectArrayFilterParams(qi: BuilderCtx, filter: ArrayFilter, params: unknown[]): void;
|
|
313
|
+
export declare function collectArrayFilterParams(qi: BuilderCtx, filter: ArrayFilter, params: unknown[], column: string): void;
|
|
281
314
|
/**
|
|
282
315
|
* Collect params for a vector distance WHERE filter. Mirrors
|
|
283
316
|
* {@link buildVectorFilterClauses}: the `$n::vector` query vector first, then
|
|
@@ -295,16 +328,24 @@ export declare function buildWhere<T extends object>(qi: BuilderCtx, where: Wher
|
|
|
295
328
|
* THE global-filter resolution rule, with no dependency on a `BuilderCtx`.
|
|
296
329
|
*
|
|
297
330
|
* Split out from {@link resolveGlobalFilter} so `PowqlInterface` can consume
|
|
298
|
-
* the SAME rule rather than a transcription of it
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
331
|
+
* the SAME rule rather than a transcription of it: a rule written twice is how
|
|
332
|
+
* two engines come to disagree. A function filter is evaluated PER BUILD so
|
|
333
|
+
* per-request tenancy works, and `skip` is honoured in both its whole-query and
|
|
334
|
+
* per-table forms.
|
|
335
|
+
*
|
|
336
|
+
* FAIL CLOSED. A filter that resolves to `undefined`, or to an object holding
|
|
337
|
+
* an `undefined` anywhere inside it, throws {@link ValidationError} (E003). A
|
|
338
|
+
* missing tenant context is exactly what produces `{ tenantId: undefined }`,
|
|
339
|
+
* and treating that as "no filter" read and wrote every tenant's rows. The
|
|
340
|
+
* explicit values `null` and `{}` still mean "no filter for this call": neither
|
|
341
|
+
* is what a missing value produces.
|
|
342
|
+
*
|
|
343
|
+
* A `skipGlobalFilters` list names tables by table name or client accessor,
|
|
344
|
+
* the two spellings `globalFilters` keys take. With `tables` (the schema's
|
|
345
|
+
* table map), an entry that names no table is refused (E003): it would skip
|
|
346
|
+
* nothing, so the caller who meant to lift a filter would silently keep it.
|
|
306
347
|
*/
|
|
307
|
-
export declare function resolveGlobalFilterFrom(filters: GlobalFilters | undefined, table: string, skip: ResolvedSkipGlobalFilters | undefined): Record<string, unknown> | null;
|
|
348
|
+
export declare function resolveGlobalFilterFrom(filters: GlobalFilters | undefined, table: string, skip: ResolvedSkipGlobalFilters | undefined, tables?: Readonly<Record<string, unknown>>): Record<string, unknown> | null;
|
|
308
349
|
/**
|
|
309
350
|
* Resolve the configured global filter for `table`, evaluating a function
|
|
310
351
|
* filter, honoring the active query's `skipGlobalFilters`. Returns `null` when
|
|
@@ -317,6 +358,13 @@ export declare function resolveGlobalFilter(qi: BuilderCtx, table: string, skip?
|
|
|
317
358
|
* reference, so fingerprints/SQL stay byte-identical to the pre-0.28 path.
|
|
318
359
|
*/
|
|
319
360
|
export declare function mergeGlobalFilter(qi: BuilderCtx, userWhere: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
361
|
+
/**
|
|
362
|
+
* Apply `table`'s global filter as a relation target: `apply(gf)` with the
|
|
363
|
+
* table on the stack, or `none` when no filter applies or the table's filter
|
|
364
|
+
* is already being compiled further out (see {@link filtersBeingApplied}).
|
|
365
|
+
* Every target application goes through here, build and collect alike.
|
|
366
|
+
*/
|
|
367
|
+
export declare function withTargetGlobalFilter<T>(qi: BuilderCtx, table: string, none: T, apply: (gf: Record<string, unknown>) => T): T;
|
|
320
368
|
/**
|
|
321
369
|
* SQL clause for `targetTable`'s global filter rendered against `alias`
|
|
322
370
|
* (relation subqueries, `_count`, relation `orderBy`). Pushes its params to
|
|
@@ -347,15 +395,24 @@ export declare function collectTargetGlobalFilterExists(qi: BuilderCtx, targetTa
|
|
|
347
395
|
*/
|
|
348
396
|
export declare function globalFilterCacheSegment(qi: BuilderCtx): string;
|
|
349
397
|
/**
|
|
350
|
-
* True when the USER-supplied `where` compiles to no
|
|
351
|
-
* `{ id: undefined }`, `{ OR: [{ a: undefined }] }`, …)
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
398
|
+
* True when the USER-supplied `where` narrows no row: it compiles to no
|
|
399
|
+
* predicate (`{}`, `{ id: undefined }`, `{ OR: [{ a: undefined }] }`, …), or
|
|
400
|
+
* to one that is TRUE for every row (`{ NOT: { OR: [] } }`,
|
|
401
|
+
* `{ id: { notIn: [] } }`, and on a NOT NULL column `{ email: { contains: '' } }`
|
|
402
|
+
* or `{ id: { not: null } }`, see {@link foldWhere}). Either way a mutation
|
|
403
|
+
* guarded by it would write every row. It reads the compiled emptiness, NOT
|
|
404
|
+
* the fingerprint (which is non-empty for an all-undefined `OR`/`AND`), and it
|
|
405
|
+
* ignores any configured global filter, so a global filter never lets an
|
|
406
|
+
* unguarded mass mutation through.
|
|
356
407
|
*/
|
|
357
408
|
export declare function userPredicateIsEmpty(qi: BuilderCtx, userWhere: Record<string, unknown>): boolean;
|
|
358
409
|
export declare function assertMutationHasPredicate(qi: BuilderCtx, operation: 'update' | 'updateMany' | 'delete' | 'deleteMany', whereSql: string, allowFullTableScan: boolean | undefined): void;
|
|
410
|
+
/**
|
|
411
|
+
* The mass-mutation refusal, one text for every engine. "Empty" covers a where
|
|
412
|
+
* that is always true (see {@link userPredicateIsEmpty}), which writes every
|
|
413
|
+
* row just the same.
|
|
414
|
+
*/
|
|
415
|
+
export declare function emptyMutationWhereMessage(operation: string, table: string): string;
|
|
359
416
|
/**
|
|
360
417
|
* Build the inner WHERE expression (without the WHERE keyword).
|
|
361
418
|
* Returns null if no conditions exist.
|
|
@@ -440,9 +497,10 @@ export declare function buildScopedScalarClause(qi: BuilderCtx, scope: WhereScop
|
|
|
440
497
|
* Cache-hit param-collect mirror of {@link buildScopedWhere}: pushes the exact
|
|
441
498
|
* same params in the exact same order (driven by the same {@link walkWhere}),
|
|
442
499
|
* without rebuilding SQL. Serves both {@link collectRelFilterParams} and
|
|
443
|
-
* {@link collectAliasWhereParams}.
|
|
500
|
+
* {@link collectAliasWhereParams}. Returns whether the clause compiles to a
|
|
501
|
+
* condition (`buildScopedWhere` non-null).
|
|
444
502
|
*/
|
|
445
|
-
export declare function collectScopedWhereParams(qi: BuilderCtx, scope: WhereScope, where: Record<string, unknown>, params: unknown[], depth?: number):
|
|
503
|
+
export declare function collectScopedWhereParams(qi: BuilderCtx, scope: WhereScope, where: Record<string, unknown>, params: unknown[], depth?: number): boolean;
|
|
446
504
|
/** Param-collect mirror of {@link buildScopedScalarClause}. */
|
|
447
505
|
export declare function collectScopedScalarParams(qi: BuilderCtx, scope: WhereScope, field: string, value: unknown, params: unknown[]): void;
|
|
448
506
|
/**
|
|
@@ -513,9 +571,41 @@ export declare function pgTypeForColumn(_qi: BuilderCtx, meta: TableMetadata, co
|
|
|
513
571
|
* SQL-template cache is unaffected, and it is applied on the cache-hit
|
|
514
572
|
* param-collect path as well as the build path.
|
|
515
573
|
*
|
|
574
|
+
* On MySQL a number, bigint or boolean compared with a text column binds as
|
|
575
|
+
* text ({@link textComparedOperand}), and so does each such element of a list.
|
|
576
|
+
*
|
|
516
577
|
* `timestamptz` and every non-temporal column are returned by identity.
|
|
517
578
|
*/
|
|
518
579
|
export declare function coerceWhereOperand(qi: BuilderCtx, meta: TableMetadata, column: string, value: unknown): unknown;
|
|
580
|
+
/**
|
|
581
|
+
* Column types MySQL compares with a NUMBER numerically, converting each
|
|
582
|
+
* stored text to a number: `'0zz' = 0` and `'abc' = 0` are both true, and a
|
|
583
|
+
* boolean is the number 1 or 0 there. A request body that carries `0` or
|
|
584
|
+
* `false` where a token string belongs would match the first row whose token
|
|
585
|
+
* does not start with a digit. Exported so the write path's re-read keys use
|
|
586
|
+
* this one list rather than a copy.
|
|
587
|
+
*/
|
|
588
|
+
export declare const TEXT_COMPARED_TYPES: ReadonlySet<string>;
|
|
589
|
+
/**
|
|
590
|
+
* A value bound against a column of `columnType`, as MySQL must receive it to
|
|
591
|
+
* compare it as the value it is: a number or bigint becomes its decimal text
|
|
592
|
+
* and a boolean `'1'` / `'0'` (what MySQL stores when a boolean is written to
|
|
593
|
+
* a text column), so the comparison is text with text. Every other engine,
|
|
594
|
+
* value and column type is returned unchanged. THE rule for every value Turbine
|
|
595
|
+
* binds against a column on MySQL: the where compiler applies it to each
|
|
596
|
+
* operand, and the writes apply it to the keys they re-read a row by.
|
|
597
|
+
*/
|
|
598
|
+
export declare function textComparedOperand(qi: Pick<BuilderCtx, 'dialect'>, columnType: string | undefined, value: unknown): unknown;
|
|
599
|
+
/**
|
|
600
|
+
* Whether a `Date` bound against `dbType` gets the zone-less UTC rewrite (the
|
|
601
|
+
* write path's gate). A `date` column takes the UTC date part on every SQL
|
|
602
|
+
* engine: the write path stores `YYYY-MM-DD` there, and a full timestamp
|
|
603
|
+
* compared with that text matches nothing. A zone-less `timestamp` is
|
|
604
|
+
* rewritten on PostgreSQL only, because MySQL reads a zone-less literal in the
|
|
605
|
+
* session time zone. `utcTimestamps: false` turns both off. Time-of-day
|
|
606
|
+
* columns always rewrite.
|
|
607
|
+
*/
|
|
608
|
+
export declare function utcDateTimeRewrite(qi: BuilderCtx, dbType: string | undefined): boolean;
|
|
519
609
|
/**
|
|
520
610
|
* The Postgres enum type name for a column, when the schema knows one.
|
|
521
611
|
*
|
|
@@ -526,10 +616,10 @@ export declare function coerceWhereOperand(qi: BuilderCtx, meta: TableMetadata,
|
|
|
526
616
|
* value as text and Postgres refuses the implicit text→enum coercion
|
|
527
617
|
* ("column X is of type Y but expression is of type text").
|
|
528
618
|
*
|
|
529
|
-
* Postgres-only by construction: gated on the
|
|
530
|
-
* `
|
|
531
|
-
* produces them, `defineSchema` and the other engines leave it
|
|
532
|
-
* SQLite/MySQL/MSSQL/PowDB output is byte-identical.
|
|
619
|
+
* Postgres-only by construction: gated on the engine having named enum types
|
|
620
|
+
* (`namedEnumTypes`) AND on `schema.enums` having entries (only PG
|
|
621
|
+
* introspection produces them, `defineSchema` and the other engines leave it
|
|
622
|
+
* empty), so SQLite/MySQL/MSSQL/PowDB output is byte-identical.
|
|
533
623
|
*/
|
|
534
624
|
export declare function enumTypeForColumn(qi: BuilderCtx, column: string): string | null;
|
|
535
625
|
/**
|
|
@@ -540,14 +630,13 @@ export declare function enumTypeForColumn(qi: BuilderCtx, column: string): strin
|
|
|
540
630
|
export declare function enumCastSuffix(qi: BuilderCtx, column: string): string;
|
|
541
631
|
/**
|
|
542
632
|
* Equality-fallthrough guard shared by every SQL-build path AND every
|
|
543
|
-
* cache-hit param-collect path
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* columns (object equality).
|
|
633
|
+
* cache-hit param-collect path: a bare value must fit its column
|
|
634
|
+
* ({@link assertEqualityOperand}). A plain object literal that matched no
|
|
635
|
+
* known filter shape on a non-JSON column is almost always a misspelled
|
|
636
|
+
* operator (`startWith` for `startsWith`), and binding it as `col = $1` would
|
|
637
|
+
* silently return wrong rows. Objects on json/jsonb columns are JSON values.
|
|
549
638
|
*/
|
|
550
|
-
export declare function assertBindableEqualityValue(
|
|
639
|
+
export declare function assertBindableEqualityValue(_qi: BuilderCtx, rawColumn: string, value: unknown, columnPgType: string, table: string): void;
|
|
551
640
|
/**
|
|
552
641
|
* Build the user-supplied `where` filter of a relation `with` clause against
|
|
553
642
|
* the relation's table alias. Supports the same scalar surface as the
|
|
@@ -560,7 +649,7 @@ export declare function assertBindableEqualityValue(qi: BuilderCtx, rawColumn: s
|
|
|
560
649
|
*/
|
|
561
650
|
export declare function buildAliasWhere(qi: BuilderCtx, targetTable: string, targetMeta: TableMetadata, alias: string, where: Record<string, unknown>, params: unknown[]): string | null;
|
|
562
651
|
/** Mirrors {@link buildAliasWhere} param-push order for the cache-hit collect path. */
|
|
563
|
-
export declare function collectAliasWhereParams(qi: BuilderCtx, targetTable: string, targetMeta: TableMetadata, where: Record<string, unknown>, params: unknown[]):
|
|
652
|
+
export declare function collectAliasWhereParams(qi: BuilderCtx, targetTable: string, targetMeta: TableMetadata, where: Record<string, unknown>, params: unknown[]): boolean;
|
|
564
653
|
/**
|
|
565
654
|
* Value-invariant, shape-aware fingerprint for a relation `with` clause's
|
|
566
655
|
* `where` filter. Must distinguish every SQL shape {@link buildAliasWhere}
|
|
@@ -587,9 +676,12 @@ export declare function columnRefSql(qi: BuilderCtx, ref: ColumnRef, ctx: Column
|
|
|
587
676
|
* Each operator key becomes its own clause, all ANDed together.
|
|
588
677
|
*
|
|
589
678
|
* `equals`/`not`/`gt`/`gte`/`lt`/`lte` also accept a {@link ColumnRef}
|
|
590
|
-
* (`
|
|
679
|
+
* (`col('otherField')`) which compiles to a column-to-column comparison
|
|
591
680
|
* against `refCtx`: no param bound, so `collectOperatorParams` mirrors by
|
|
592
681
|
* pushing nothing and the referenced name lives in the fingerprint.
|
|
682
|
+
*
|
|
683
|
+
* `not` also accepts an operator object, compiled as `NOT (<inner clauses>)`
|
|
684
|
+
* (see {@link WhereOperator.not}).
|
|
593
685
|
*/
|
|
594
686
|
export declare function buildOperatorClauses(qi: BuilderCtx, column: string, op: WhereOperator, params: unknown[], refCtx?: ColumnRefContext): string[];
|
|
595
687
|
/**
|
|
@@ -602,9 +694,8 @@ export declare function buildOperatorClauses(qi: BuilderCtx, column: string, op:
|
|
|
602
694
|
*/
|
|
603
695
|
export declare function requireFullTextSearch(qi: BuilderCtx): void;
|
|
604
696
|
/**
|
|
605
|
-
* Gate the pathless JSON
|
|
606
|
-
*
|
|
607
|
-
* {@link Dialect.supportsJsonContains}.
|
|
697
|
+
* Gate the pathless JSON filters, `contains` (containment) and `equals`
|
|
698
|
+
* (whole-document equality), on {@link Dialect.supportsJsonContains}.
|
|
608
699
|
*
|
|
609
700
|
* The engine this exists for is SQLite, whose emulation compares a decoded
|
|
610
701
|
* `json_each.value` against a param bound as JSON TEXT and therefore matched
|
|
@@ -666,22 +757,6 @@ export declare function getColumnPgType(qi: BuilderCtx, column: string): string;
|
|
|
666
757
|
* E.g. '_text' → 'text', '_int4' → 'integer'
|
|
667
758
|
*/
|
|
668
759
|
export declare function getArrayElementType(_qi: BuilderCtx, pgType: string): string;
|
|
669
|
-
/**
|
|
670
|
-
* Refuse a {@link JsonFilter} carrying a key that is not a JSON operator, and
|
|
671
|
-
* refuse a filter that selects a `path` but never compares it.
|
|
672
|
-
*
|
|
673
|
-
* Both shapes used to compile to NOTHING. `buildJsonFilterClauses` only ever
|
|
674
|
-
* emitted a clause for a key it recognized, so `{ path: ['title'],
|
|
675
|
-
* string_contains: 'x' }`, the Prisma spelling, and an easy typo besides -
|
|
676
|
-
* produced an empty clause list, the predicate vanished, and the query
|
|
677
|
-
* returned EVERY row. Inside an `AND` it silently dropped that conjunct, so a
|
|
678
|
-
* tenant scope written this way widened to the whole table. The equivalent
|
|
679
|
-
* typo on a scalar column has always thrown; this closes the inconsistency.
|
|
680
|
-
*
|
|
681
|
-
* Called from both the SQL-build path and the cache-hit param-collect path, so
|
|
682
|
-
* a warmed SQL cache cannot skip the check.
|
|
683
|
-
*/
|
|
684
|
-
export declare function assertJsonFilterKeys(filter: JsonFilter, column: string): void;
|
|
685
760
|
/**
|
|
686
761
|
* Validate and enumerate the substring comparisons on a JSON filter, in the
|
|
687
762
|
* fixed {@link JSON_STRING_OPERATORS} order. Shared by the build and collect
|
|
@@ -697,6 +772,25 @@ export declare function jsonRangeEntries(_qi: BuilderCtx, filter: JsonFilter, co
|
|
|
697
772
|
sqlOp: string;
|
|
698
773
|
value: number | string;
|
|
699
774
|
}[];
|
|
775
|
+
/**
|
|
776
|
+
* The bound operand of `{ path, equals }`, shared by the build and collect
|
|
777
|
+
* paths so both bind (and refuse) identically.
|
|
778
|
+
*
|
|
779
|
+
* PostgreSQL compares JSON to JSON, so the operand is its JSON text: `5`,
|
|
780
|
+
* `"5"`, `null`, `[1,2]` and `{"a":1}` each match only that JSON value at the
|
|
781
|
+
* path (numbers compare numerically, so `5` also matches `5.0`). A Date is the
|
|
782
|
+
* ISO string JSON would store, and a bigint is a JSON number.
|
|
783
|
+
*
|
|
784
|
+
* MySQL and SQL Server compare typed through `Dialect.buildJsonPathEquals`
|
|
785
|
+
* and never reach this function. SQLite compares the value its path
|
|
786
|
+
* extraction returns, so only a value with a text form can match: a string,
|
|
787
|
+
* number, boolean, bigint or Date.
|
|
788
|
+
* There a number and a numeric string match the same rows, except on SQLite,
|
|
789
|
+
* whose extraction returns typed values: a number binds as a number there, and
|
|
790
|
+
* a boolean is refused because SQLite reads `true` and `1` alike. `null`,
|
|
791
|
+
* objects and arrays matched no row on those engines and are refused (E017).
|
|
792
|
+
*/
|
|
793
|
+
export declare function jsonPathEqualsOperand(qi: BuilderCtx, value: unknown, column: string): unknown;
|
|
700
794
|
/**
|
|
701
795
|
* Build SQL clauses for JSONB filter operators on a column.
|
|
702
796
|
* Supports: path, equals, contains, hasKey, gt, gte, lt, lte.
|
|
@@ -716,6 +810,13 @@ export declare function buildJsonFilterClauses(qi: BuilderCtx, column: string, f
|
|
|
716
810
|
* params) and fail at runtime with the engine's bad-JSON-path error. The
|
|
717
811
|
* encoded path stays a bound parameter, never spliced into SQL text, so
|
|
718
812
|
* the build/collect param mirrors stay in lockstep and injection-safe.
|
|
813
|
+
*
|
|
814
|
+
* A key segment is written as a JSON string literal (`JSON.stringify`), the
|
|
815
|
+
* form the engines' JSONPath grammars read a quoted key in: a backslash, a
|
|
816
|
+
* quote and a control character are each escaped. Escaping only the quote
|
|
817
|
+
* read a key holding a backslash as an escape sequence, so the key `a\b` was
|
|
818
|
+
* looked up as a different key and matched nothing, a key ending in a
|
|
819
|
+
* backslash was a bad path, and MySQL refused a key holding a newline.
|
|
719
820
|
*/
|
|
720
821
|
export declare function jsonPathParam(qi: BuilderCtx, path: readonly (string | number)[], nativeForm?: unknown): unknown;
|
|
721
822
|
/**
|
|
@@ -776,4 +877,3 @@ export declare function buildTextSearchClause(qi: BuilderCtx, column: string, fi
|
|
|
776
877
|
* Uses pre-computed Map for O(1) lookup instead of linear scan.
|
|
777
878
|
*/
|
|
778
879
|
export declare function getColumnArrayType(qi: BuilderCtx, column: string): string;
|
|
779
|
-
export {};
|