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
|
@@ -5,15 +5,29 @@
|
|
|
5
5
|
* compiler. Kept out of builder.ts so the class file stays about SQL assembly
|
|
6
6
|
* and execution rather than filter-shape bookkeeping.
|
|
7
7
|
*/
|
|
8
|
-
import type { ArrayFilter,
|
|
8
|
+
import type { ArrayFilter, JsonFilter, JsonPathOrderBy, OrderBySpec, OrderDirection, RelationPickOrderBy, TextSearchFilter, VectorFilter, VectorOrderBy, WhereOperator } from './types.js';
|
|
9
9
|
import { type ColumnNameSource } from './utils.js';
|
|
10
10
|
/** Check if a value is a where operator object (has at least one known operator key) */
|
|
11
11
|
export declare function isWhereOperator(value: unknown): value is WhereOperator;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Class instances
|
|
16
|
-
*
|
|
13
|
+
* THE plain-object test for argument trees: an object literal (or a
|
|
14
|
+
* prototype-less object), never an array, Date, Buffer, typed array or other
|
|
15
|
+
* class instance. Class instances are values a driver binds (a Decimal, an
|
|
16
|
+
* interval wrapper), so no walker over caller arguments may descend into one.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* `target[key] = value`, always as an OWN property. A plain assignment of the
|
|
21
|
+
* key `__proto__` replaces the object's prototype instead, so a caller key
|
|
22
|
+
* spelled that way (`JSON.parse` produces it as an ordinary own key) would
|
|
23
|
+
* vanish from a rebuilt argument object rather than reach the check that
|
|
24
|
+
* refuses it, and a filter would silently stop filtering.
|
|
25
|
+
*/
|
|
26
|
+
export declare function setOwn(target: Record<string, unknown>, key: string, value: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* {@link isPlainRecord} read at an equality fallthrough: a plain object that
|
|
29
|
+
* matched no known filter shape is a misspelled operator, while a class
|
|
30
|
+
* instance (Buffer for bytea, a Decimal wrapper) is a legitimate bind value.
|
|
17
31
|
*/
|
|
18
32
|
export declare function isUnmatchedPlainObject(value: unknown): boolean;
|
|
19
33
|
/**
|
|
@@ -26,50 +40,104 @@ export declare const COLUMN_REF_OPERATORS: Set<string>;
|
|
|
26
40
|
* THE relation-filter wrappers: the keys whose body is a clause against the
|
|
27
41
|
* relation's TARGET table rather than against this one.
|
|
28
42
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* `RELATION_QUANTIFIERS`
|
|
36
|
-
* `k === 'is' || k === 'isNot'` tests, which is the copy most likely to drift
|
|
37
|
-
* because half of it does not read as a list and a grep for the list does not
|
|
38
|
-
* find it.
|
|
39
|
-
*
|
|
40
|
-
* The failure mode is not cosmetic: a wrapper the SQL compiler treats as a
|
|
41
|
-
* relation filter but a WALKER does not is a wrapper whose body reaches the
|
|
42
|
-
* builder unwalked. That is precisely the operand-position channel this
|
|
43
|
-
* release closed elsewhere.
|
|
43
|
+
* Everything that walks a where clause has to agree about them: a wrapper the
|
|
44
|
+
* SQL compiler treats as a relation filter but a walker does not is a wrapper
|
|
45
|
+
* whose body reaches the builder unwalked. The SQL walk (`walkWhere` in
|
|
46
|
+
* where-compile.ts), the bare to-one normalization (`normalizeRelationFilter`
|
|
47
|
+
* in where.ts) and the PII predicate guard (`cli/pii-predicate-guard.ts`) all
|
|
48
|
+
* read this list. `prisma-compat.ts` still carries its own copy
|
|
49
|
+
* (`RELATION_QUANTIFIERS` plus inline `is` / `isNot` tests).
|
|
44
50
|
*
|
|
45
51
|
* `query/` is the right home rather than `cli/` because the direction of the
|
|
46
52
|
* dependency is fixed: `cli/` and the prisma-compat shim may import from the
|
|
47
53
|
* query path, and the query path may never import from `cli/`
|
|
48
54
|
* (`scripts/check-import-cycles.mjs`).
|
|
49
|
-
*
|
|
50
|
-
* ## STATUS: a landing spot, not yet a deduplication. Read this before trusting it.
|
|
51
|
-
*
|
|
52
|
-
* NOTHING IMPORTS THIS YET. The three copies listed above are all still in
|
|
53
|
-
* place and still hand-synced; declaring the canonical home did not by itself
|
|
54
|
-
* move any of them onto it. It is kept, rather than deleted as unused, because
|
|
55
|
-
* `cli/pii-predicate-guard.ts` names this module as where its own copy wants to
|
|
56
|
-
* go, and deleting the destination is the one change that makes converging
|
|
57
|
-
* harder. Wiring the copies up is a separate change: each one sits on a
|
|
58
|
-
* different walk, so each has to be re-tested on its own.
|
|
59
|
-
*
|
|
60
|
-
* So do not read this constant as evidence that the walkers agree. The comment
|
|
61
|
-
* on each copy is still the only thing holding them in step.
|
|
62
55
|
*/
|
|
63
56
|
export declare const RELATION_FILTER_WRAPPERS: readonly ["some", "none", "every", "is", "isNot"];
|
|
64
57
|
/** {@link RELATION_FILTER_WRAPPERS} as a membership set, for the walkers. */
|
|
65
58
|
export declare const RELATION_FILTER_WRAPPER_SET: ReadonlySet<string>;
|
|
59
|
+
export { isColumnRef } from './column-ref.js';
|
|
60
|
+
/**
|
|
61
|
+
* `value` without its `undefined`-valued keys, one level deep. Returns the
|
|
62
|
+
* input BY REFERENCE when there are none, so the common path allocates
|
|
63
|
+
* nothing. Symbol-keyed properties (internal brands) survive a copy.
|
|
64
|
+
*
|
|
65
|
+
* This is the where walkers' backstop only. The args seam
|
|
66
|
+
* (`pruneUndefinedArgs` in normalize-args.ts) is the authority on `undefined`:
|
|
67
|
+
* it removes undefined keys at every where position and objects that became
|
|
68
|
+
* empty because of them. The walkers see what the seam missed (internal
|
|
69
|
+
* callers below it), skip a key whose value is `undefined`, and never look
|
|
70
|
+
* inside a value, so a JSON operand is data however it is shaped.
|
|
71
|
+
*/
|
|
72
|
+
export declare function dropUndefinedKeys(value: Record<string, unknown>): Record<string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* What a column's type allows at a value position. Decided from the column's
|
|
75
|
+
* type token: json/jsonb take JSON values, an array column (`_text`) takes
|
|
76
|
+
* arrays, a pgvector column takes a number array, and everything else takes a
|
|
77
|
+
* scalar.
|
|
78
|
+
*/
|
|
79
|
+
export type OperandColumnKind = 'scalar' | 'array' | 'vector' | 'json';
|
|
80
|
+
/** {@link OperandColumnKind} for a column type token (case-insensitive). */
|
|
81
|
+
export declare function operandColumnKind(columnType: string | undefined): OperandColumnKind;
|
|
82
|
+
/** Short, value-free description of an operand for an error message. */
|
|
83
|
+
export declare function describeOperand(value: unknown): string;
|
|
84
|
+
/**
|
|
85
|
+
* Where an operand sits, for the refusal message and for the column kind it is
|
|
86
|
+
* checked against. `column` is the label the message prints (the column name,
|
|
87
|
+
* or the expression a groupBy JSON key compiles to).
|
|
88
|
+
*/
|
|
89
|
+
export interface OperandContext {
|
|
90
|
+
column: string;
|
|
91
|
+
table: string;
|
|
92
|
+
kind: OperandColumnKind;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Validate every operand of an operator object against its column, and throw
|
|
96
|
+
* {@link ValidationError} (E003) naming the column, the operator, what was
|
|
97
|
+
* received and what is accepted.
|
|
98
|
+
*
|
|
99
|
+
* An operator object must state at least one comparison. One made only of
|
|
100
|
+
* `mode` (or of operators whose value is `undefined`) compares nothing, so it
|
|
101
|
+
* is refused rather than compiled to no predicate: inside a relation filter
|
|
102
|
+
* that silence turned `deleteMany` into a delete of every row. The args seam
|
|
103
|
+
* removes the object when `undefined` emptied it, so Prisma's optional-search
|
|
104
|
+
* idiom (`{ contains: q, mode: 'insensitive' }` with `q` undefined) still
|
|
105
|
+
* reads as "no filter".
|
|
106
|
+
*
|
|
107
|
+
* Called by the SQL build AND the cache-hit param collect with the same
|
|
108
|
+
* arguments, so a warmed template can never bind an operand the cold build
|
|
109
|
+
* refuses. Recurses into a `not` operator object, bounded by `depth`. Runs on
|
|
110
|
+
* every operator object of every query, so it reads only the keys present and
|
|
111
|
+
* builds a message only when it throws.
|
|
112
|
+
*/
|
|
113
|
+
export declare function assertOperatorOperands(op: Record<string, unknown>, ctx: OperandContext, depth?: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* On a JSON column `not` takes a JSON VALUE (`not: { a: 1 }` compares
|
|
116
|
+
* documents), so `not: { contains: {...} }` was compared as the literal document
|
|
117
|
+
* `{"contains": ...}` and matched nearly every row, while the same spelling on a
|
|
118
|
+
* text column negates the filter. An object made only of filter-operator keys
|
|
119
|
+
* is therefore refused, except `not: { equals: X }`, which negates the
|
|
120
|
+
* whole-document equality. A literal document with such keys stays expressible.
|
|
121
|
+
* Every engine runs it (PowDB too), so the spelling means one thing everywhere.
|
|
122
|
+
*/
|
|
123
|
+
export declare function assertJsonNotOperand(value: unknown, ctx: OperandContext): void;
|
|
124
|
+
/**
|
|
125
|
+
* Validate a BARE value (implicit equality, `{ id: 5 }`) against its column.
|
|
126
|
+
* Shared by the build and collect paths of every where scope.
|
|
127
|
+
*/
|
|
128
|
+
export declare function assertEqualityOperand(value: unknown, ctx: OperandContext): void;
|
|
66
129
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `
|
|
70
|
-
*
|
|
130
|
+
* One `cursor` field's value, checked and unwrapped. A cursor value is the
|
|
131
|
+
* value the last row holds in that column, so it takes the bare-equality rule
|
|
132
|
+
* (`{ equals: v }` is the same as `v`); an operator object, a list on a scalar
|
|
133
|
+
* column or a column reference is refused (E003) in terms of cursors, not
|
|
134
|
+
* filters. NULL is a row's value only in a column that can hold it: in a NOT
|
|
135
|
+
* NULL column (the primary key included) no row has it, so it is refused
|
|
136
|
+
* rather than placing the page nowhere. Shared by every engine's cursor path.
|
|
71
137
|
*/
|
|
72
|
-
export declare function
|
|
138
|
+
export declare function cursorFieldValue(field: string, written: unknown, ctx: OperandContext & {
|
|
139
|
+
nullable: boolean;
|
|
140
|
+
}): unknown;
|
|
73
141
|
/**
|
|
74
142
|
* Fingerprint the SHAPE of a where-operator object. Null-valued `equals` /
|
|
75
143
|
* `not` compile to parameterless `IS NULL` / `IS NOT NULL` (different SQL, no
|
|
@@ -77,22 +145,16 @@ export declare function isColumnRef(value: unknown): value is ColumnRef;
|
|
|
77
145
|
* warmed by `{ not: 5 }` would serve `{ not: null }` with a desynced param list.
|
|
78
146
|
*
|
|
79
147
|
* Column references ({@link ColumnRef}) compile the referenced column into the
|
|
80
|
-
* SQL TEXT (no param bound), so the referenced field name is part of the
|
|
81
|
-
|
|
82
|
-
*
|
|
148
|
+
* SQL TEXT (no param bound), so the referenced field name is part of the
|
|
149
|
+
* shape: `{ equals: col('a') }` and `{ equals: col('b') }` must never share a
|
|
150
|
+
* cache entry. The name is JSON-encoded so exotic field names cannot collide
|
|
83
151
|
* with other fingerprint tokens.
|
|
152
|
+
*
|
|
153
|
+
* A `not` operator object compiles to `NOT (<inner>)`, so its whole inner shape
|
|
154
|
+
* is part of the token, with the inner object's EFFECTIVE mode (its own, else
|
|
155
|
+
* the inherited one). Keys holding `undefined` are skipped, as the builders skip them.
|
|
84
156
|
*/
|
|
85
|
-
export declare function fingerprintOperatorShape(value: WhereOperator): string;
|
|
86
|
-
/**
|
|
87
|
-
* Guard for the value of an `equals` operator reaching the plain-equality
|
|
88
|
-
* operator path. A plain object literal can only legitimately be an equality
|
|
89
|
-
* value on a json/jsonb column, and those route to the JSONB filter branch
|
|
90
|
-
* BEFORE the operator branch, so any plain object that reaches here is a
|
|
91
|
-
* mistake (e.g. `{ equals: { foo: 1 } }` on a text column). Shared by the
|
|
92
|
-
* SQL-build path and the cache-hit param-collect path so a warmed cache can
|
|
93
|
-
* never skip the check.
|
|
94
|
-
*/
|
|
95
|
-
export declare function assertBindableEqualsOperand(value: unknown, column: string): void;
|
|
157
|
+
export declare function fingerprintOperatorShape(value: WhereOperator, inheritedMode?: unknown, depth?: number): string;
|
|
96
158
|
/**
|
|
97
159
|
* Object keys in sorted order, mirroring the canonical order used by every
|
|
98
160
|
* cache fingerprint. The SQL-build and cache-hit param-collect paths MUST
|
|
@@ -373,8 +435,11 @@ export declare function dedupeOrderEntries(meta: ColumnNameSource | undefined, e
|
|
|
373
435
|
* has a meaning that degrades as the list grows (every added column makes the
|
|
374
436
|
* result strictly less distinct, converging on the plain query), so a long list
|
|
375
437
|
* is self-limiting in a way a long sort is not.
|
|
438
|
+
*
|
|
439
|
+
* Every element must be a field name: anything else (an `undefined` hole, a
|
|
440
|
+
* number) is E003 here, the first place either caller reads the list.
|
|
376
441
|
*/
|
|
377
|
-
export declare function dedupeColumnList(meta: ColumnNameSource | undefined, columns: readonly string[]): {
|
|
442
|
+
export declare function dedupeColumnList(meta: ColumnNameSource | undefined, columns: readonly string[], label?: string): {
|
|
378
443
|
columns: string[];
|
|
379
444
|
dropped: DroppedTerm[];
|
|
380
445
|
} | null;
|
|
@@ -395,3 +460,40 @@ export declare function normalizeOrderBy(value: OrderDirection | OrderBySpec): {
|
|
|
395
460
|
* never overwritten while an empty one still gets the synthesized PK order.
|
|
396
461
|
*/
|
|
397
462
|
export declare function isEmptyOrderBy(orderBy: unknown): boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Refuse a {@link JsonFilter} carrying a key that is not a JSON operator, and
|
|
465
|
+
* refuse a filter that selects a `path` but never compares it.
|
|
466
|
+
*
|
|
467
|
+
* Both shapes used to compile to NOTHING. `buildJsonFilterClauses` only ever
|
|
468
|
+
* emitted a clause for a key it recognized, so `{ path: ['title'],
|
|
469
|
+
* string_contains: 'x' }`, the Prisma spelling, and an easy typo besides -
|
|
470
|
+
* produced an empty clause list, the predicate vanished, and the query
|
|
471
|
+
* returned EVERY row. Inside an `AND` it silently dropped that conjunct, so a
|
|
472
|
+
* tenant scope written this way widened to the whole table. The equivalent
|
|
473
|
+
* typo on a scalar column has always thrown; this closes the inconsistency.
|
|
474
|
+
*
|
|
475
|
+
* Called from both the SQL-build path and the cache-hit param-collect path, so
|
|
476
|
+
* a warmed SQL cache cannot skip the check.
|
|
477
|
+
*/
|
|
478
|
+
export declare function assertJsonFilterKeys(filter: JsonFilter, column: string): void;
|
|
479
|
+
/**
|
|
480
|
+
* Whether {@link findUndefinedPath} would find anything, without building the
|
|
481
|
+
* path strings. Same walk, same leaves, same plain-object rule, same depth bound.
|
|
482
|
+
*/
|
|
483
|
+
export declare function holdsUndefinedValue(value: unknown, depth: number): boolean;
|
|
484
|
+
/**
|
|
485
|
+
* The key path of the first `undefined` inside a where object (a global filter),
|
|
486
|
+
* or `null`.
|
|
487
|
+
* Walks plain objects and arrays; values of any other kind (Dates, Buffers,
|
|
488
|
+
* column references) are leaves. Key NAMES only, never values, so the path is
|
|
489
|
+
* safe in an error message.
|
|
490
|
+
*/
|
|
491
|
+
export declare function findUndefinedPath(value: unknown, path: string, depth: number): string | null;
|
|
492
|
+
/**
|
|
493
|
+
* Refuse an {@link ArrayFilter} that would compile to less than it says: a key
|
|
494
|
+
* that is not an array operator (it would be dropped, so `{ has: 'a', hsa: 'b' }`
|
|
495
|
+
* filtered on `has` alone), an `isEmpty` that is not a boolean (it compiled to
|
|
496
|
+
* nothing), or no comparison at all. Called by the SQL build and the cache-hit
|
|
497
|
+
* param collect alike.
|
|
498
|
+
*/
|
|
499
|
+
export declare function assertArrayFilter(filter: ArrayFilter, column: string): void;
|