@prisma-next/sql-relational-core 0.5.0-dev.9 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +59 -25
  2. package/dist/codec-types-BUfBna4G.d.mts +107 -0
  3. package/dist/codec-types-BUfBna4G.d.mts.map +1 -0
  4. package/dist/{errors-D3xmG4h-.mjs → errors-BF7W5uUd.mjs} +2 -2
  5. package/dist/{errors-D3xmG4h-.mjs.map → errors-BF7W5uUd.mjs.map} +1 -1
  6. package/dist/{errors-CDvhnH7P.d.mts → errors-BgNpVAT8.d.mts} +2 -2
  7. package/dist/errors-BgNpVAT8.d.mts.map +1 -0
  8. package/dist/exports/ast.d.mts +189 -112
  9. package/dist/exports/ast.d.mts.map +1 -1
  10. package/dist/exports/ast.mjs +207 -1322
  11. package/dist/exports/ast.mjs.map +1 -1
  12. package/dist/exports/codec-descriptor-registry.d.mts +18 -0
  13. package/dist/exports/codec-descriptor-registry.d.mts.map +1 -0
  14. package/dist/exports/codec-descriptor-registry.mjs +40 -0
  15. package/dist/exports/codec-descriptor-registry.mjs.map +1 -0
  16. package/dist/exports/errors.d.mts +1 -4
  17. package/dist/exports/errors.mjs +2 -3
  18. package/dist/exports/expression.d.mts +84 -0
  19. package/dist/exports/expression.d.mts.map +1 -0
  20. package/dist/exports/expression.mjs +62 -0
  21. package/dist/exports/expression.mjs.map +1 -0
  22. package/dist/exports/middleware.d.mts +2 -0
  23. package/dist/exports/middleware.mjs +2 -0
  24. package/dist/exports/plan.d.mts +3 -3
  25. package/dist/exports/plan.mjs +27 -10
  26. package/dist/exports/plan.mjs.map +1 -1
  27. package/dist/exports/query-lane-context.d.mts +2 -3
  28. package/dist/exports/query-lane-context.mjs +1 -1
  29. package/dist/exports/types.d.mts +2 -4
  30. package/dist/exports/types.mjs +1 -1
  31. package/dist/index.d.mts +12 -12
  32. package/dist/index.mjs +8 -5
  33. package/dist/middleware-D2Wv9QIf.mjs +82 -0
  34. package/dist/middleware-D2Wv9QIf.mjs.map +1 -0
  35. package/dist/middleware-USDeR8p1.d.mts +121 -0
  36. package/dist/middleware-USDeR8p1.d.mts.map +1 -0
  37. package/dist/plan-DFpOIsKB.d.mts +44 -0
  38. package/dist/plan-DFpOIsKB.d.mts.map +1 -0
  39. package/dist/query-lane-context-C2tLZGp4.d.mts +72 -0
  40. package/dist/query-lane-context-C2tLZGp4.d.mts.map +1 -0
  41. package/dist/{sql-execution-plan-DY0WvJOW.d.mts → sql-execution-plan-ffz8TSfr.d.mts} +2 -3
  42. package/dist/sql-execution-plan-ffz8TSfr.d.mts.map +1 -0
  43. package/dist/{types-C3Hg-CVz.d.mts → types-BZcKgaYA.d.mts} +61 -24
  44. package/dist/types-BZcKgaYA.d.mts.map +1 -0
  45. package/dist/types-CK9ZJ6OU.mjs +1112 -0
  46. package/dist/types-CK9ZJ6OU.mjs.map +1 -0
  47. package/dist/{types-B5XsBeaT.d.mts → types-CL18G37a.d.mts} +3 -4
  48. package/dist/types-CL18G37a.d.mts.map +1 -0
  49. package/dist/{types-CG3u534i.d.mts → types-D6Pk1DTr.d.mts} +11 -13
  50. package/dist/types-D6Pk1DTr.d.mts.map +1 -0
  51. package/dist/util-DWmhUCEO.mjs +34 -0
  52. package/dist/util-DWmhUCEO.mjs.map +1 -0
  53. package/package.json +16 -13
  54. package/src/ast/adapter-types.ts +13 -16
  55. package/src/ast/codec-types.ts +87 -419
  56. package/src/ast/sql-codec-helpers.ts +79 -0
  57. package/src/ast/sql-codecs.ts +285 -125
  58. package/src/ast/types.ts +222 -173
  59. package/src/ast/util.ts +23 -0
  60. package/src/ast/validate-param-refs.ts +39 -0
  61. package/src/codec-descriptor-registry.ts +52 -0
  62. package/src/exports/ast.ts +2 -0
  63. package/src/exports/codec-descriptor-registry.ts +1 -0
  64. package/src/exports/expression.ts +1 -0
  65. package/src/exports/middleware.ts +8 -0
  66. package/src/expression.ts +134 -0
  67. package/src/index.ts +2 -0
  68. package/src/middleware/param-ref-mutator.ts +230 -0
  69. package/src/plan.ts +32 -16
  70. package/src/query-lane-context.ts +35 -55
  71. package/src/types.ts +1 -3
  72. package/dist/codec-types-B2Xdq0Wr.d.mts +0 -167
  73. package/dist/codec-types-B2Xdq0Wr.d.mts.map +0 -1
  74. package/dist/errors-CDvhnH7P.d.mts.map +0 -1
  75. package/dist/plan-CRPxW2Jj.d.mts +0 -32
  76. package/dist/plan-CRPxW2Jj.d.mts.map +0 -1
  77. package/dist/query-lane-context-DDRW5NBG.d.mts +0 -89
  78. package/dist/query-lane-context-DDRW5NBG.d.mts.map +0 -1
  79. package/dist/sql-execution-plan-DY0WvJOW.d.mts.map +0 -1
  80. package/dist/types-B5XsBeaT.d.mts.map +0 -1
  81. package/dist/types-C3Hg-CVz.d.mts.map +0 -1
  82. package/dist/types-CG3u534i.d.mts.map +0 -1
package/README.md CHANGED
@@ -89,37 +89,71 @@ flowchart TD
89
89
 
90
90
  ### Plan Helpers (`plan.ts`)
91
91
  - Defines `SqlQueryPlan<Row>` interface for SQL query plans produced by lanes before lowering
92
- - Provides `augmentDescriptorWithColumnMeta(descriptors, columnMeta)` helper to update ParamDescriptor with `codecId` and `nativeType` from column metadata
92
+ - Per [ADR 205](../../../../docs/architecture%20docs/adrs/ADR%20205%20-%20Execution%20metadata%20lives%20on%20AST.md), codec IDs travel on `ProjectionItem.codecId` (output) and `ParamRef.codecId` (parameters) on the AST itself, not on plan-level descriptor lists
93
93
 
94
- ### Codec Factory (`ast/codec-types.ts` via `exports/ast.ts`)
94
+ ### Codec authoring (class form)
95
95
 
96
- - `codec({...})` is the SQL-side factory for constructing `Codec` values. It accepts `encode` and `decode` author functions in **either sync or async form** with no annotations; the constructed codec exposes Promise-returning query-time methods regardless of which form was used. `encode` may be omitted (identity default); `decode` is required.
97
- - Build-time methods (`encodeJson`, `decodeJson`, `renderOutputType?`) are synchronous and pass through unchanged.
98
- - This is the only public entry point for SQL codecs. There is no separate `codecSync` / `codecAsync` factory and no per-codec async marker on the resulting value.
96
+ Codec authors extend the framework `CodecImpl` (and pair the codec with a `CodecDescriptorImpl` registration) per [ADR 208 Higher-order codecs for parameterized types](../../../../docs/architecture%20docs/adrs/ADR%20208%20-%20Higher-order%20codecs%20for%20parameterized%20types.md). Each codec class declares the four conversion methods (`encode`, `decode`, `encodeJson`, `decodeJson`); the descriptor class declares static metadata (`codecId`, `traits`, `targetTypes`, `meta`, `paramsSchema`, optional `renderOutputType`) and a `factory` returning a per-instance codec.
97
+
98
+ - Query-time methods (`encode` / `decode`) are typed as `Promise<…>`-returning at the public boundary; sync method bodies are accepted via TypeScript bivariance and the runtime always awaits.
99
+ - Build-time methods (`encodeJson` / `decodeJson` / `renderOutputType?`) stay synchronous so contract validation and client construction stay synchronous.
100
+ - Both `encode` and `decode` must be implemented — there is no identity-default fallback.
101
+
102
+ ```ts
103
+ // Non-parameterized codec (P = void) — see packages/3-targets/3-targets/postgres/src/core/codecs.ts
104
+ // for the production form.
105
+ import {
106
+ CodecDescriptorImpl,
107
+ CodecImpl,
108
+ voidParamsSchema,
109
+ type CodecCallContext,
110
+ type CodecInstanceContext,
111
+ } from '@prisma-next/framework-components/codec';
112
+
113
+ class PgTextCodec extends CodecImpl<'pg/text@1', readonly ['equality'], string, string> {
114
+ override readonly id = 'pg/text@1';
115
+ override readonly traits = ['equality'] as const;
116
+ encode(v: string, _ctx: CodecCallContext): Promise<string> { return Promise.resolve(v); }
117
+ decode(w: string, _ctx: CodecCallContext): Promise<string> { return Promise.resolve(w); }
118
+ encodeJson(v: string) { return v; }
119
+ decodeJson(j: unknown) { return j as string; }
120
+ }
121
+
122
+ class PgTextDescriptor extends CodecDescriptorImpl<void> {
123
+ override readonly codecId = 'pg/text@1';
124
+ override readonly traits = ['equality'] as const;
125
+ override readonly targetTypes = ['text'] as const;
126
+ override readonly paramsSchema = voidParamsSchema;
127
+ override readonly factory = () => (_ctx: CodecInstanceContext) => new PgTextCodec();
128
+ }
129
+ ```
130
+
131
+ #### Codec call context (`ctx`)
132
+
133
+ Codecs receive a second `ctx` options argument; you may ignore it. The runtime allocates one `SqlCodecCallContext` per `runtime.execute(plan, { signal })` call and threads the same reference to every codec dispatch site as a non-optional argument — when no `signal` is supplied the runtime still threads an empty `{}`, never `undefined`. The internal `Codec` interface declares the parameter as required (`encode(value, ctx: SqlCodecCallContext)` / `decode(wire, ctx: SqlCodecCallContext)`); single-arg method bodies continue to compile via TypeScript's bivariance for trailing parameters, so codec ergonomics are unchanged.
134
+
135
+ - **`ctx.signal`** — the same `AbortSignal` reference at every codec call in one execute. Forward it to network SDKs so aborted queries stop talking to the underlying service.
136
+ - **`ctx.column`** (decode-side only) — `{ table, name }` for cells the runtime can resolve to a single column ref; `undefined` for aggregate aliases, computed projections, and other unresolvable cells. Encode-side `ctx.column` is always `undefined` (encode-time column enrichment is the middleware's domain).
99
137
 
100
138
  ```ts
101
- // Sync authoring:
102
- const textCodec = codec({
103
- typeId: 'pg/text@1',
104
- targetTypes: ['text'],
105
- encode: (v: string) => v,
106
- decode: (w: string) => w,
107
- encodeJson: (v: string) => v,
108
- decodeJson: (j: string) => j as string,
109
- });
110
-
111
- // Async authoring (e.g. KMS-backed encryption): same factory, same shape.
112
- const secretCodec = codec({
113
- typeId: 'pg/secret@1',
114
- targetTypes: ['text'],
115
- encode: async (v: string) => encrypt(v, await getKey()),
116
- decode: async (w: string) => decrypt(w, await getKey()),
117
- encodeJson: (v: string) => v,
118
- decodeJson: (j: string) => j as string,
119
- });
139
+ // Forward ctx.signal to a network call so aborted queries stop the SDK.
140
+ class PgKmsSecretCodec extends CodecImpl<'pg/kms-secret@1', readonly [], string, string> {
141
+ override readonly id = 'pg/kms-secret@1';
142
+ override readonly traits = [] as const;
143
+ override async encode(v: string, ctx: SqlCodecCallContext): Promise<string> {
144
+ return kms.encrypt({ plaintext: v }, { signal: ctx.signal });
145
+ }
146
+ override async decode(w: string, ctx: SqlCodecCallContext): Promise<string> {
147
+ return kms.decrypt({ ciphertext: w }, { signal: ctx.signal });
148
+ }
149
+ encodeJson(v: string) { return v; }
150
+ decodeJson(j: unknown) { return j as string; }
151
+ }
120
152
  ```
121
153
 
122
- See [ADR 204 Single-Path Async Codec Runtime](../../../../docs/architecture%20docs/adrs/ADR%20204%20-%20Single-Path%20Async%20Codec%20Runtime.md).
154
+ Codec bodies that ignore `ctx.signal` complete in the background (cooperative cancellation); aborts still surface to the caller as `RUNTIME.ABORTED` with `details.phase ∈ { 'encode', 'decode', 'stream' }`.
155
+
156
+ See [ADR 204 — Single-Path Async Codec Runtime](../../../../docs/architecture%20docs/adrs/ADR%20204%20-%20Single-Path%20Async%20Codec%20Runtime.md) and [ADR 207 — Codec call context: per-query `AbortSignal` and column metadata](../../../../docs/architecture%20docs/adrs/ADR%20207%20-%20Codec%20call%20context%20per-query%20AbortSignal%20and%20column%20metadata.md).
123
157
 
124
158
  ### AST Surface (`ast/*` via `exports/ast.ts`)
125
159
  - Query roots: `SelectAst`, `InsertAst`, `UpdateAst`, `DeleteAst`
@@ -0,0 +1,107 @@
1
+ import { Codec, CodecCallContext, CodecCallContext as CodecCallContext$1, CodecDescriptor, CodecDescriptor as CodecDescriptor$1, CodecInstanceContext, CodecTrait, CodecTrait as CodecTrait$1 } from "@prisma-next/framework-components/codec";
2
+
3
+ //#region src/ast/codec-types.d.ts
4
+ /**
5
+ * SQL-family addressing of a single column. The decode site populates a `SqlColumnRef` whenever it can resolve the cell to a single underlying `(table, column)` (the typical case for projected columns from a single-table source); cells the runtime cannot resolve (aggregate aliases, include aggregate fields, computed projections without a simple ref) get `column = undefined`.
6
+ *
7
+ * The shape is a structural projection of the runtime's `ColumnRef` so the SQL decode site can reuse the resolution it already performs for `RUNTIME.DECODE_FAILED` envelope construction without allocating twice per cell.
8
+ */
9
+ interface SqlColumnRef {
10
+ readonly table: string;
11
+ readonly name: string;
12
+ }
13
+ /**
14
+ * SQL-family per-call context. Extends the framework {@link CodecCallContext} (which carries `signal` only) with `column?: SqlColumnRef`, populated on **decode** call sites that can resolve a single underlying column ref. Encode call sites currently leave `column` undefined (encode-time column context is the middleware's domain).
15
+ *
16
+ * SQL codec authors writing codec methods observe this type via {@link SqlCodec}. The framework codec dispatch surface (and Mongo) sees only the base `CodecCallContext`.
17
+ */
18
+ interface SqlCodecCallContext extends CodecCallContext {
19
+ readonly column?: SqlColumnRef;
20
+ }
21
+ /**
22
+ * SQL-family per-instance context. Extends the framework {@link CodecInstanceContext} (`name` only) with `usedAt`, the set of `(table, column)` pairs the resolved codec serves.
23
+ *
24
+ * - For `typeRef` columns sharing one named `storage.types` instance, the array lists every referencing column — a column-scoped stateful codec (e.g. encryption) can derive aggregated per-instance state across all the columns sharing the named instance.
25
+ * - For inline-`typeParams` columns, the array has exactly one entry — the column that owns the inline params.
26
+ * - For shared non-parameterized codecs, the array carries one representative entry (the column that triggered materialization); the codec is shared across every column with that codec id, so the `usedAt` is informational only.
27
+ *
28
+ * SQL extensions consuming `usedAt` (e.g. column-scoped state derivation) type their factory parameter as `SqlCodecInstanceContext`. Extensions that don't read `usedAt` type their factory parameter as the family-agnostic {@link CodecInstanceContext} — a `SqlCodecInstanceContext` is structurally assignable to the base.
29
+ */
30
+ interface SqlCodecInstanceContext extends CodecInstanceContext {
31
+ readonly usedAt: ReadonlyArray<{
32
+ readonly table: string;
33
+ readonly column: string;
34
+ }>;
35
+ }
36
+ /**
37
+ * Codec metadata for database-specific type information. Used for schema introspection and verification.
38
+ */
39
+ interface CodecMeta {
40
+ readonly db?: {
41
+ readonly sql?: {
42
+ readonly postgres?: {
43
+ readonly nativeType: string;
44
+ };
45
+ };
46
+ };
47
+ }
48
+ /**
49
+ * SQL codec — extends the framework codec base by narrowing the per-call context to the SQL-family {@link SqlCodecCallContext} (adds `column?: SqlColumnRef`). TypeScript treats method-syntax declarations bivariantly, so the SQL narrowing is structurally compatible with the framework {@link BaseCodec} super-interface.
50
+ *
51
+ * Codec-id-keyed static metadata (`traits`, `targetTypes`, `meta`, `paramsSchema`, `renderOutputType`) lives on the unified {@link import('@prisma-next/framework-components/codec').CodecDescriptor} — the codec instance itself only carries `id` plus the four conversion methods.
52
+ *
53
+ * See `Codec` in `@prisma-next/framework-components/codec` for the codec contract that this interface extends.
54
+ */
55
+ interface Codec$1<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown> extends Codec<Id, TTraits, TWire, TInput> {
56
+ encode(value: TInput, ctx: SqlCodecCallContext): Promise<TWire>;
57
+ decode(wire: TWire, ctx: SqlCodecCallContext): Promise<TInput>;
58
+ }
59
+ /**
60
+ * Contract-bound codec registry.
61
+ *
62
+ * The dispatch interface for encode/decode at runtime: built once at `ExecutionContext` construction time by walking the contract's `storage.tables[].columns[]` and resolving each column through its descriptor's factory (per-instance for parameterized columns; the cached shared codec for non-parameterized columns). The dispatch path calls `forColumn(table, column).encode/decode(...)` and doesn't know whether the codec
63
+ * is parameterized.
64
+ *
65
+ * `forCodecId(codecId)` is the refs-less fallback. Every column-bound `ParamRef` carries `refs: { table; column }` and the builder-pipeline `validateParamRefRefs` pass enforces refs on every parameterized `ParamRef` before encode runs, so this fallback is only reached for non-parameterized codec ids.
66
+ */
67
+ interface ContractCodecRegistry {
68
+ /**
69
+ * Resolve the codec for `(table, column)`. Returns the per-instance parameterized codec for parameterized columns, the shared codec for non-parameterized columns, or `undefined` if the column is unknown or the codec isn't registered.
70
+ */
71
+ forColumn(table: string, column: string): Codec$1 | undefined;
72
+ /**
73
+ * Resolve a codec by id. For non-parameterized codecs this returns the canonical shared instance materialized once at context construction; for parameterized codecs it returns the column-resolved instance when a single column declares the codec id, or the `factory(undefined)` representative when the descriptor's factory is parameter-tolerant. Used by refs-less call sites; the validator pass guarantees the call site's
74
+ * `codecId` is non-parameterized (or parameter-tolerant) at this boundary.
75
+ */
76
+ forCodecId(codecId: string): Codec$1 | undefined;
77
+ }
78
+ /**
79
+ * Variance-erased descriptor type used for heterogeneous storage in collection containers and on the unified contributor `codecs:` slot. The descriptor's `factory` and `renderOutputType` are contravariant in `P`, so descriptors with different params shapes are not in a subtype relationship; collecting them into one container needs an explicit variance erasure rather than `CodecDescriptor<unknown>` (which is the
80
+ * narrowest, not the widest, of the family).
81
+ */
82
+ type AnyCodecDescriptor = CodecDescriptor<any>;
83
+ type DescriptorResolvedCodec<D> = D extends CodecDescriptor<infer _P> ? ReturnType<ReturnType<D['factory']>> : never;
84
+ type DescriptorCodecId<D> = D extends AnyCodecDescriptor ? D['codecId'] : never;
85
+ type DescriptorCodecInput<D> = DescriptorResolvedCodec<D> extends Codec<string, readonly CodecTrait[], unknown, infer In> ? In : never;
86
+ /**
87
+ * Resolve the trait union for a descriptor `D`.
88
+ *
89
+ * Reads `traits` directly off the descriptor — concrete descriptor classes declare `override readonly traits = [...] as const`, which preserves the literal trait tuple at the descriptor type. Reading from the resolved codec instance (`CodecImpl<…, TTraits, …>`) would lose the literal because `Codec` carries `TTraits` only on its optional phantom slot (`readonly __codecTraits?: TTraits`); codecs extending `CodecImpl`
90
+ * have no required structural site that pins `TTraits`, so a descriptor-keyed extractor reading from the codec instance would widen to the broad `CodecTrait` union.
91
+ */
92
+ type DescriptorCodecTraits<D> = D extends {
93
+ readonly traits: infer TTraits extends readonly CodecTrait[];
94
+ } ? TTraits[number] & CodecTrait : never;
95
+ /**
96
+ * Project a record of {@link AnyCodecDescriptor}s keyed by scalar name onto the codec-id-keyed `CodecTypes` shape consumed by emit and no-emit type pipelines (`{ readonly [codecId]: { input; output; traits } }`).
97
+ *
98
+ * Canonical extractor for the descriptor-keyed type pipeline; the legacy instance-keyed extractor and its `mkCodec`-bound builder retired alongside the carrier deletion.
99
+ */
100
+ type ExtractCodecTypes<ScalarNames extends { readonly [K in keyof ScalarNames]: AnyCodecDescriptor } = Record<never, never>> = { readonly [K in keyof ScalarNames as DescriptorCodecId<ScalarNames[K]>]: {
101
+ readonly input: DescriptorCodecInput<ScalarNames[K]>;
102
+ readonly output: DescriptorCodecInput<ScalarNames[K]>;
103
+ readonly traits: DescriptorCodecTraits<ScalarNames[K]>;
104
+ } };
105
+ //#endregion
106
+ export { CodecMeta as a, DescriptorCodecId as c, ExtractCodecTypes as d, SqlCodecCallContext as f, CodecDescriptor$1 as i, DescriptorCodecInput as l, SqlColumnRef as m, Codec$1 as n, CodecTrait$1 as o, SqlCodecInstanceContext as p, CodecCallContext$1 as r, ContractCodecRegistry as s, AnyCodecDescriptor as t, DescriptorCodecTraits as u };
107
+ //# sourceMappingURL=codec-types-BUfBna4G.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-types-BUfBna4G.d.mts","names":[],"sources":["../src/ast/codec-types.ts"],"mappings":";;;;AAmBA;;;;UAAiB,YAAA;EAAA,SACN,KAAA;EAAA,SACA,IAAA;AAAA;;;;;;UAQM,mBAAA,SAA4B,gBAAA;EAAA,SAClC,MAAA,GAAS,YAAA;AAAA;;;;;;;;;;UAYH,uBAAA,SAAgC,oBAAA;EAAA,SACtC,MAAA,EAAQ,aAAA;IAAA,SAAyB,KAAA;IAAA,SAAwB,MAAA;EAAA;AAAA;;;;UAMnD,SAAA;EAAA,SACN,EAAA;IAAA,SACE,GAAA;MAAA,SACE,QAAA;QAAA,SACE,UAAA;MAAA;IAAA;EAAA;AAAA;;;;;;;;UAaA,OAAA,sDAEU,UAAA,cAAwB,UAAA,+CAGzC,KAAA,CAAU,EAAA,EAAI,OAAA,EAAS,KAAA,EAAO,MAAA;EACtC,MAAA,CAAO,KAAA,EAAO,MAAA,EAAQ,GAAA,EAAK,mBAAA,GAAsB,OAAA,CAAQ,KAAA;EACzD,MAAA,CAAO,IAAA,EAAM,KAAA,EAAO,GAAA,EAAK,mBAAA,GAAsB,OAAA,CAAQ,MAAA;AAAA;;;;;;;;;UAWxC,qBAAA;EAbO;;;EAiBtB,SAAA,CAAU,KAAA,UAAe,MAAA,WAAiB,OAAA;EAhB5B;;;;EAsBd,UAAA,CAAW,OAAA,WAAkB,OAAA;AAAA;;;;;KAQnB,kBAAA,GAAqB,eAAA;AAAA,KAE5B,uBAAA,MACH,CAAA,SAAU,eAAA,aAA4B,UAAA,CAAW,UAAA,CAAW,CAAA;AAAA,KAElD,iBAAA,MAAuB,CAAA,SAAU,kBAAA,GAAqB,CAAA;AAAA,KAEtD,oBAAA,MACV,uBAAA,CAAwB,CAAA,UAAW,KAAA,kBAA2B,UAAA,yBAC1D,EAAA;;AA3BN;;;;;KAoCY,qBAAA,MAA2B,CAAA;EAAA,SAC5B,MAAA,iCAAuC,UAAA;AAAA,IAE9C,OAAA,WAAkB,UAAA;;;;;;KAQV,iBAAA,4CAEa,WAAA,GAAc,kBAAA,KACjC,MAAA,yCAEiB,WAAA,IAAe,iBAAA,CAAkB,WAAA,CAAY,CAAA;EAAA,SACvD,KAAA,EAAO,oBAAA,CAAqB,WAAA,CAAY,CAAA;EAAA,SACxC,MAAA,EAAQ,oBAAA,CAAqB,WAAA,CAAY,CAAA;EAAA,SACzC,MAAA,EAAQ,qBAAA,CAAsB,WAAA,CAAY,CAAA;AAAA"}
@@ -29,7 +29,7 @@ function planUnsupported(message, details, hints, docs) {
29
29
  docs
30
30
  });
31
31
  }
32
-
33
32
  //#endregion
34
33
  export { planUnsupported as n, planInvalid as t };
35
- //# sourceMappingURL=errors-D3xmG4h-.mjs.map
34
+
35
+ //# sourceMappingURL=errors-BF7W5uUd.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-D3xmG4h-.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { RuntimeError } from './types';\n\nexport function planInvalid(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.INVALID',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n\nexport function planUnsupported(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.UNSUPPORTED',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n"],"mappings":";AAEA,SAAgB,YACd,SACA,SACA,OACA,MACc;CACd,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAEhC,QAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;AAEF,QAAO,OAAO,OAAO,OAAO;EAC1B,MAAM;EACN,UAAU;EACV,UAAU;EACV;EACA;EACA;EACD,CAAC;;AAGJ,SAAgB,gBACd,SACA,SACA,OACA,MACc;CACd,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAEhC,QAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;AAEF,QAAO,OAAO,OAAO,OAAO;EAC1B,MAAM;EACN,UAAU;EACV,UAAU;EACV;EACA;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"errors-BF7W5uUd.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { RuntimeError } from './types';\n\nexport function planInvalid(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.INVALID',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n\nexport function planUnsupported(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.UNSUPPORTED',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n"],"mappings":";AAEA,SAAgB,YACd,SACA,SACA,OACA,MACc;CACd,MAAM,QAAQ,IAAI,MAAM,QAAQ;CAEhC,OAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;CAEF,OAAO,OAAO,OAAO,OAAO;EAC1B,MAAM;EACN,UAAU;EACV,UAAU;EACV;EACA;EACA;EACD,CAAC;;AAGJ,SAAgB,gBACd,SACA,SACA,OACA,MACc;CACd,MAAM,QAAQ,IAAI,MAAM,QAAQ;CAEhC,OAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;CAEF,OAAO,OAAO,OAAO,OAAO;EAC1B,MAAM;EACN,UAAU;EACV,UAAU;EACV;EACA;EACA;EACD,CAAC"}
@@ -1,8 +1,8 @@
1
- import { y as RuntimeError } from "./types-CG3u534i.mjs";
1
+ import { y as RuntimeError } from "./types-D6Pk1DTr.mjs";
2
2
 
3
3
  //#region src/errors.d.ts
4
4
  declare function planInvalid(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
5
5
  declare function planUnsupported(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
6
6
  //#endregion
7
7
  export { planUnsupported as n, planInvalid as t };
8
- //# sourceMappingURL=errors-CDvhnH7P.d.mts.map
8
+ //# sourceMappingURL=errors-BgNpVAT8.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BgNpVAT8.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;;iBAEgB,WAAA,CACd,OAAA,UACA,OAAA,GAAU,MAAA,mBACV,KAAA,sBACA,IAAA,uBACC,YAAA;AAAA,iBAkBa,eAAA,CACd,OAAA,UACA,OAAA,GAAU,MAAA,mBACV,KAAA,sBACA,IAAA,uBACC,YAAA"}
@@ -1,46 +1,11 @@
1
- import { a as CodecMeta, c as CodecTrait, d as ExtractDataTypes, f as codec, i as CodecInput, l as CodecTraits, m as defineCodecs, n as CodecDefBuilder, o as CodecParamsDescriptor, p as createCodecRegistry, r as CodecId, s as CodecRegistry, t as Codec, u as ExtractCodecTypes } from "../codec-types-B2Xdq0Wr.mjs";
2
- import { $ as ToWhereExpr, A as InsertOnConflict, B as NotExpr, C as ExistsExpr, D as ExpressionSource, E as ExpressionRewriter, F as JsonObjectEntry, G as ParamRef, H as OperationExpr, I as JsonObjectExpr, J as SelectAst, K as ProjectionExpr, L as ListExpression, M as JoinAst, N as JoinOnExpr, O as IdentifierRef, P as JsonArrayAggExpr, Q as TableSource, R as LiteralExpr, S as EqColJoinOn, T as ExpressionFolder, U as OrExpr, V as NullCheckExpr, W as OrderByItem, X as SubqueryExpr, Y as SelectAstOptions, Z as TableRef, _ as DeleteAst, a as AndExpr, at as whereExprKinds, b as DoNothingConflictAction, c as AnyInsertOnConflictAction, d as AnyQueryAst, et as UpdateAst, f as AstRewriter, g as DefaultValueExpr, h as ColumnRef, i as AggregateOpFn, it as queryAstKinds, j as InsertValue, k as InsertAst, l as AnyInsertValue, m as BinaryOp, n as AggregateExpr, nt as isQueryAst, o as AnyExpression, p as BinaryExpr, q as ProjectionItem, r as AggregateFn, rt as isWhereExpr, s as AnyFromSource, t as AggregateCountFn, tt as WhereArg, u as AnyOperationArg, v as DerivedTableSource, w as ExprVisitor, x as DoUpdateSetConflictAction, y as Direction, z as LoweredStatement } from "../types-C3Hg-CVz.mjs";
1
+ import { $ as TableRef, A as InsertOnConflict, B as NotExpr, C as ExistsExpr, D as ExpressionSource, E as ExpressionRewriter, F as JsonObjectEntry, G as ParamRef, H as OperationExpr, I as JsonObjectExpr, J as ProjectionItem, K as ParamRefBindingRefs, L as ListExpression, M as JoinAst, N as JoinOnExpr, O as IdentifierRef, P as JsonArrayAggExpr, Q as SubqueryExpr, R as LiteralExpr, S as EqColJoinOn, T as ExpressionFolder, U as OrExpr, V as NullCheckExpr, W as OrderByItem, X as SelectAst, Y as RawSqlExpr, Z as SelectAstOptions, _ as DeleteAst, a as AndExpr, at as isWhereExpr, b as DoNothingConflictAction, c as AnyInsertOnConflictAction, d as AnyQueryAst, et as TableSource, f as AstRewriter, g as DefaultValueExpr, h as ColumnRef, i as AggregateOpFn, it as isQueryAst, j as InsertValue, k as InsertAst, l as AnyInsertValue, m as BinaryOp, n as AggregateExpr, nt as UpdateAst, o as AnyExpression, ot as queryAstKinds, p as BinaryExpr, q as ProjectionExpr, r as AggregateFn, rt as WhereArg, s as AnyFromSource, st as whereExprKinds, t as AggregateCountFn, tt as ToWhereExpr, u as AnyOperationArg, v as DerivedTableSource, w as ExprVisitor, x as DoUpdateSetConflictAction, y as Direction, z as LoweredStatement } from "../types-BZcKgaYA.mjs";
2
+ import { a as CodecMeta, c as DescriptorCodecId, d as ExtractCodecTypes, f as SqlCodecCallContext, i as CodecDescriptor, l as DescriptorCodecInput, m as SqlColumnRef, n as Codec, o as CodecTrait, p as SqlCodecInstanceContext, r as CodecCallContext, s as ContractCodecRegistry, t as AnyCodecDescriptor, u as DescriptorCodecTraits } from "../codec-types-BUfBna4G.mjs";
3
+ import { n as CodecDescriptorRegistry } from "../query-lane-context-C2tLZGp4.mjs";
4
+ import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
5
+ import { CodecCallContext as CodecCallContext$1, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
6
+ import { ContractMarkerRecord, JsonValue } from "@prisma-next/contract/types";
7
+ import { StandardSchemaV1 } from "@standard-schema/spec";
3
8
 
4
- //#region src/ast/adapter-types.d.ts
5
- type AdapterTarget = string;
6
- interface MarkerStatement {
7
- readonly sql: string;
8
- readonly params: readonly unknown[];
9
- }
10
- interface AdapterProfile<TTarget extends AdapterTarget = AdapterTarget> {
11
- readonly id: string;
12
- readonly target: TTarget;
13
- readonly capabilities: Record<string, unknown>;
14
- /**
15
- * Returns the adapter's default codec registry.
16
- * The registry contains codecs provided by the adapter for converting
17
- * between wire types and JavaScript types.
18
- */
19
- codecs(): CodecRegistry;
20
- /**
21
- * Returns the SQL statement to read the contract marker from the database.
22
- * Each adapter provides target-specific SQL (e.g. schema-qualified table names,
23
- * parameter placeholder style).
24
- */
25
- readMarkerStatement(): MarkerStatement;
26
- }
27
- interface LowererContext<TContract = unknown> {
28
- readonly contract: TContract;
29
- readonly params?: readonly unknown[];
30
- }
31
- type Lowerer<Ast = unknown, TContract = unknown, TBody = LoweredStatement> = (ast: Ast, context: LowererContext<TContract>) => TBody;
32
- /**
33
- * Lowers a query AST into a target-specific executable body (typically
34
- * `LoweredStatement` for SQL adapters). The `lower` method returns the body
35
- * directly; per-statement metadata, when needed, lives on the body itself
36
- * (e.g. `LoweredStatement.annotations`). Adapter-level metadata such as the
37
- * profile id is reachable via `profile.id` for callers that genuinely need it.
38
- */
39
- interface Adapter<Ast = unknown, TContract = unknown, TBody = LoweredStatement> {
40
- readonly profile: AdapterProfile;
41
- lower(ast: Ast, context: LowererContext<TContract>): TBody;
42
- }
43
- //#endregion
44
9
  //#region src/ast/driver-types.d.ts
45
10
  interface SqlExecuteRequest {
46
11
  readonly sql: string;
@@ -105,86 +70,198 @@ interface SqlQueryable {
105
70
  query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<SqlQueryResult<Row>>;
106
71
  }
107
72
  //#endregion
108
- //#region src/ast/sql-codecs.d.ts
73
+ //#region src/ast/adapter-types.d.ts
74
+ type AdapterTarget = string;
75
+ interface MarkerStatement {
76
+ readonly sql: string;
77
+ readonly params: readonly unknown[];
78
+ }
79
+ /**
80
+ * Outcome of an adapter's marker read. `no-table` means the marker storage itself is absent (e.g. attaching to a database that was never `db init`'d); `absent` means the storage exists but holds no row for the requested space; `present` carries the parsed record. Callers distinguish these so runtime telemetry and `requireMarker` policy can react to each case appropriately.
81
+ */
82
+ type MarkerReadResult = {
83
+ readonly kind: 'present';
84
+ readonly record: ContractMarkerRecord;
85
+ } | {
86
+ readonly kind: 'absent';
87
+ } | {
88
+ readonly kind: 'no-table';
89
+ };
90
+ interface AdapterProfile<TTarget extends AdapterTarget = AdapterTarget> {
91
+ readonly id: string;
92
+ readonly target: TTarget;
93
+ readonly capabilities: Record<string, unknown>;
94
+ /**
95
+ * Reads the contract marker via the supplied queryable. The adapter owns the full flow — probing for the marker storage, issuing the read, and decoding the row — so callers receive a tagged result rather than a raw driver error when the marker storage is absent.
96
+ */
97
+ readMarker(queryable: SqlQueryable): Promise<MarkerReadResult>;
98
+ }
99
+ interface LowererContext<TContract = unknown> {
100
+ readonly contract: TContract;
101
+ readonly params?: readonly unknown[];
102
+ }
103
+ type Lowerer<Ast = unknown, TContract = unknown, TBody = LoweredStatement> = (ast: Ast, context: LowererContext<TContract>) => TBody;
104
+ /**
105
+ * Lowers a query AST into a target-specific executable body (typically `LoweredStatement` for SQL adapters). The `lower` method returns the body directly; per-statement metadata, when needed, lives on the body itself (e.g. `LoweredStatement.annotations`). Adapter-level metadata such as the profile id is reachable via `profile.id` for callers that genuinely need it.
106
+ */
107
+ interface Adapter<Ast = unknown, TContract = unknown, TBody = LoweredStatement> {
108
+ readonly profile: AdapterProfile;
109
+ lower(ast: Ast, context: LowererContext<TContract>): TBody;
110
+ }
111
+ //#endregion
112
+ //#region src/ast/sql-codec-helpers.d.ts
109
113
  declare const SQL_CHAR_CODEC_ID: "sql/char@1";
110
114
  declare const SQL_VARCHAR_CODEC_ID: "sql/varchar@1";
111
115
  declare const SQL_INT_CODEC_ID: "sql/int@1";
112
116
  declare const SQL_FLOAT_CODEC_ID: "sql/float@1";
113
117
  declare const SQL_TEXT_CODEC_ID: "sql/text@1";
114
118
  declare const SQL_TIMESTAMP_CODEC_ID: "sql/timestamp@1";
115
- declare const codecs: CodecDefBuilder<{
116
- char: Codec<"sql/char@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
117
- varchar: Codec<"sql/varchar@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
118
- int: Codec<"sql/int@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
119
- float: Codec<"sql/float@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
120
- text: Codec<"sql/text@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
121
- } & Record<"timestamp", Codec<"sql/timestamp@1", readonly ["equality", "order"], string, string, {
122
- precision?: number;
123
- }, unknown>>>;
124
- declare const sqlCodecDefinitions: {
125
- readonly char: {
126
- readonly typeId: "sql/char@1";
127
- readonly scalar: "char";
128
- readonly codec: Codec<"sql/char@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
129
- readonly input: string;
130
- readonly output: string;
131
- readonly jsType: string;
132
- };
133
- readonly varchar: {
134
- readonly typeId: "sql/varchar@1";
135
- readonly scalar: "varchar";
136
- readonly codec: Codec<"sql/varchar@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
137
- readonly input: string;
138
- readonly output: string;
139
- readonly jsType: string;
140
- };
141
- readonly int: {
142
- readonly typeId: "sql/int@1";
143
- readonly scalar: "int";
144
- readonly codec: Codec<"sql/int@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
145
- readonly input: number;
146
- readonly output: number;
147
- readonly jsType: number;
148
- };
149
- readonly float: {
150
- readonly typeId: "sql/float@1";
151
- readonly scalar: "float";
152
- readonly codec: Codec<"sql/float@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
153
- readonly input: number;
154
- readonly output: number;
155
- readonly jsType: number;
156
- };
157
- readonly text: {
158
- readonly typeId: "sql/text@1";
159
- readonly scalar: "text";
160
- readonly codec: Codec<"sql/text@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
161
- readonly input: string;
162
- readonly output: string;
163
- readonly jsType: string;
164
- };
165
- readonly timestamp: {
166
- readonly typeId: "sql/timestamp@1";
167
- readonly scalar: "timestamp";
168
- readonly codec: Codec<"sql/timestamp@1", readonly ["equality", "order"], string, string, {
169
- precision?: number;
170
- }, unknown>;
171
- readonly input: string;
172
- readonly output: string;
173
- readonly jsType: string;
174
- };
119
+ declare const sqlCharEncode: (value: string) => string;
120
+ declare const sqlCharDecode: (wire: string) => string;
121
+ declare const sqlCharRenderOutputType: (typeParams: {
122
+ readonly length?: number;
123
+ }) => string | undefined;
124
+ declare const sqlVarcharEncode: (value: string) => string;
125
+ declare const sqlVarcharDecode: (wire: string) => string;
126
+ declare const sqlVarcharRenderOutputType: (typeParams: {
127
+ readonly length?: number;
128
+ }) => string | undefined;
129
+ declare const sqlIntEncode: (value: number) => number;
130
+ declare const sqlIntDecode: (wire: number) => number;
131
+ declare const sqlFloatEncode: (value: number) => number;
132
+ declare const sqlFloatDecode: (wire: number) => number;
133
+ declare const sqlTextEncode: (value: string) => string;
134
+ declare const sqlTextDecode: (wire: string) => string;
135
+ declare const sqlTimestampEncode: (value: Date) => Date;
136
+ declare const sqlTimestampDecode: (wire: Date) => Date;
137
+ declare const sqlTimestampEncodeJson: (value: Date) => JsonValue;
138
+ declare const sqlTimestampDecodeJson: (json: JsonValue) => Date;
139
+ declare const sqlTimestampRenderOutputType: (typeParams: {
140
+ readonly precision?: number;
141
+ }) => string;
142
+ //#endregion
143
+ //#region src/ast/sql-codecs.d.ts
144
+ type LengthParams = {
145
+ readonly length?: number;
175
146
  };
176
- declare const sqlDataTypes: {
177
- readonly char: "sql/char@1";
178
- readonly varchar: "sql/varchar@1";
179
- readonly int: "sql/int@1";
180
- readonly float: "sql/float@1";
181
- readonly text: "sql/text@1";
182
- readonly timestamp: "sql/timestamp@1";
147
+ type PrecisionParams = {
148
+ readonly precision?: number;
183
149
  };
184
- type SqlCodecTypes = typeof codecs.CodecTypes;
150
+ declare class SqlTextCodec extends CodecImpl<typeof SQL_TEXT_CODEC_ID, readonly ['equality', 'order', 'textual'], string, string> {
151
+ encode(value: string, _ctx: CodecCallContext$1): Promise<string>;
152
+ decode(wire: string, _ctx: CodecCallContext$1): Promise<string>;
153
+ encodeJson(value: string): JsonValue;
154
+ decodeJson(json: JsonValue): string;
155
+ }
156
+ declare class SqlTextDescriptor extends CodecDescriptorImpl<void> {
157
+ readonly codecId: "sql/text@1";
158
+ readonly traits: readonly ["equality", "order", "textual"];
159
+ readonly targetTypes: readonly ["text"];
160
+ readonly paramsSchema: StandardSchemaV1<void>;
161
+ factory(): (ctx: CodecInstanceContext) => SqlTextCodec;
162
+ }
163
+ declare const sqlTextDescriptor: SqlTextDescriptor;
164
+ declare const sqlTextColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqlTextCodec, undefined>;
165
+ declare class SqlIntCodec extends CodecImpl<typeof SQL_INT_CODEC_ID, readonly ['equality', 'order', 'numeric'], number, number> {
166
+ encode(value: number, _ctx: CodecCallContext$1): Promise<number>;
167
+ decode(wire: number, _ctx: CodecCallContext$1): Promise<number>;
168
+ encodeJson(value: number): JsonValue;
169
+ decodeJson(json: JsonValue): number;
170
+ }
171
+ declare class SqlIntDescriptor extends CodecDescriptorImpl<void> {
172
+ readonly codecId: "sql/int@1";
173
+ readonly traits: readonly ["equality", "order", "numeric"];
174
+ readonly targetTypes: readonly ["int"];
175
+ readonly paramsSchema: StandardSchemaV1<void>;
176
+ factory(): (ctx: CodecInstanceContext) => SqlIntCodec;
177
+ }
178
+ declare const sqlIntDescriptor: SqlIntDescriptor;
179
+ declare const sqlIntColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqlIntCodec, undefined>;
180
+ declare class SqlFloatCodec extends CodecImpl<typeof SQL_FLOAT_CODEC_ID, readonly ['equality', 'order', 'numeric'], number, number> {
181
+ encode(value: number, _ctx: CodecCallContext$1): Promise<number>;
182
+ decode(wire: number, _ctx: CodecCallContext$1): Promise<number>;
183
+ encodeJson(value: number): JsonValue;
184
+ decodeJson(json: JsonValue): number;
185
+ }
186
+ declare class SqlFloatDescriptor extends CodecDescriptorImpl<void> {
187
+ readonly codecId: "sql/float@1";
188
+ readonly traits: readonly ["equality", "order", "numeric"];
189
+ readonly targetTypes: readonly ["float"];
190
+ readonly paramsSchema: StandardSchemaV1<void>;
191
+ factory(): (ctx: CodecInstanceContext) => SqlFloatCodec;
192
+ }
193
+ declare const sqlFloatDescriptor: SqlFloatDescriptor;
194
+ declare const sqlFloatColumn: () => _$_prisma_next_framework_components_codec0.ColumnSpec<SqlFloatCodec, undefined>;
195
+ declare class SqlCharCodec extends CodecImpl<typeof SQL_CHAR_CODEC_ID, readonly ['equality', 'order', 'textual'], string, string> {
196
+ encode(value: string, _ctx: CodecCallContext$1): Promise<string>;
197
+ decode(wire: string, _ctx: CodecCallContext$1): Promise<string>;
198
+ encodeJson(value: string): JsonValue;
199
+ decodeJson(json: JsonValue): string;
200
+ }
201
+ declare class SqlCharDescriptor extends CodecDescriptorImpl<LengthParams> {
202
+ readonly codecId: "sql/char@1";
203
+ readonly traits: readonly ["equality", "order", "textual"];
204
+ readonly targetTypes: readonly ["char"];
205
+ readonly paramsSchema: StandardSchemaV1<LengthParams>;
206
+ renderOutputType(params: LengthParams): string | undefined;
207
+ factory(_params: LengthParams): (ctx: CodecInstanceContext) => SqlCharCodec;
208
+ }
209
+ declare const sqlCharDescriptor: SqlCharDescriptor;
210
+ declare const sqlCharColumn: (params?: LengthParams) => _$_prisma_next_framework_components_codec0.ColumnSpec<SqlCharCodec, LengthParams>;
211
+ declare class SqlVarcharCodec extends CodecImpl<typeof SQL_VARCHAR_CODEC_ID, readonly ['equality', 'order', 'textual'], string, string> {
212
+ encode(value: string, _ctx: CodecCallContext$1): Promise<string>;
213
+ decode(wire: string, _ctx: CodecCallContext$1): Promise<string>;
214
+ encodeJson(value: string): JsonValue;
215
+ decodeJson(json: JsonValue): string;
216
+ }
217
+ declare class SqlVarcharDescriptor extends CodecDescriptorImpl<LengthParams> {
218
+ readonly codecId: "sql/varchar@1";
219
+ readonly traits: readonly ["equality", "order", "textual"];
220
+ readonly targetTypes: readonly ["varchar"];
221
+ readonly paramsSchema: StandardSchemaV1<LengthParams>;
222
+ renderOutputType(params: LengthParams): string | undefined;
223
+ factory(_params: LengthParams): (ctx: CodecInstanceContext) => SqlVarcharCodec;
224
+ }
225
+ declare const sqlVarcharDescriptor: SqlVarcharDescriptor;
226
+ declare const sqlVarcharColumn: (params?: LengthParams) => _$_prisma_next_framework_components_codec0.ColumnSpec<SqlVarcharCodec, LengthParams>;
227
+ declare class SqlTimestampCodec extends CodecImpl<typeof SQL_TIMESTAMP_CODEC_ID, readonly ['equality', 'order'], Date, Date> {
228
+ encode(value: Date, _ctx: CodecCallContext$1): Promise<Date>;
229
+ decode(wire: Date, _ctx: CodecCallContext$1): Promise<Date>;
230
+ encodeJson(value: Date): JsonValue;
231
+ decodeJson(json: JsonValue): Date;
232
+ }
233
+ declare class SqlTimestampDescriptor extends CodecDescriptorImpl<PrecisionParams> {
234
+ readonly codecId: "sql/timestamp@1";
235
+ readonly traits: readonly ["equality", "order"];
236
+ readonly targetTypes: readonly ["timestamp"];
237
+ readonly paramsSchema: StandardSchemaV1<PrecisionParams>;
238
+ renderOutputType(params: PrecisionParams): string | undefined;
239
+ factory(_params: PrecisionParams): (ctx: CodecInstanceContext) => SqlTimestampCodec;
240
+ }
241
+ declare const sqlTimestampDescriptor: SqlTimestampDescriptor;
242
+ declare const sqlTimestampColumn: (params?: PrecisionParams) => _$_prisma_next_framework_components_codec0.ColumnSpec<SqlTimestampCodec, PrecisionParams>;
185
243
  //#endregion
186
244
  //#region src/ast/util.d.ts
187
245
  declare function compact<T extends Record<string, unknown>>(o: T): T;
246
+ /**
247
+ * Walks an AST's parameter references in first-encounter order and dedupes
248
+ * by ParamRef identity. The single canonical helper used by every consumer
249
+ * that aligns `plan.params` with metadata-by-index — the SQL builder lane,
250
+ * the SQL ORM client, the SQL runtime encoder, and the Postgres renderer's
251
+ * `$N` index map — so the four walks cannot drift in dedupe semantics.
252
+ *
253
+ * SQLite's `?`-placeholder renderer intentionally does NOT use this helper
254
+ * because it needs one params entry per occurrence in the SQL.
255
+ */
256
+ declare function collectOrderedParamRefs(ast: AnyQueryAst): ReadonlyArray<ParamRef>;
257
+ //#endregion
258
+ //#region src/ast/validate-param-refs.d.ts
259
+ /**
260
+ * Validate that every parameterized-codec `ParamRef` in `plan` carries `refs`. Throws `RUNTIME.PARAM_REF_REFS_REQUIRED` (a runtime envelope) naming the codec id and the binding label when the invariant is violated. Returns the plan unchanged on success — callers that prefer a side-effecting assertion can ignore the return value.
261
+ *
262
+ * The `registry` is consulted via `descriptorFor(codecId).isParameterized` — `true` whenever the descriptor's `paramsSchema` is not the singleton `voidParamsSchema`.
263
+ */
264
+ declare function validateParamRefRefs(plan: AnyQueryAst, registry: CodecDescriptorRegistry): void;
188
265
  //#endregion
189
- export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyQueryAst, AstRewriter, BinaryExpr, BinaryOp, Codec, CodecDefBuilder, CodecId, CodecInput, CodecMeta, CodecParamsDescriptor, CodecRegistry, CodecTrait, CodecTraits, ColumnRef, DefaultValueExpr, DeleteAst, DerivedTableSource, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, ExprVisitor, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, ExtractDataTypes, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, ListExpression, LiteralExpr, LoweredStatement, Lowerer, LowererContext, MarkerStatement, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, ProjectionExpr, ProjectionItem, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SelectAstOptions, SqlCodecTypes, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlQueryResult, SqlQueryable, SqlTransaction, SubqueryExpr, TableRef, TableSource, ToWhereExpr, UpdateAst, WhereArg, codec, compact, createCodecRegistry, defineCodecs, isQueryAst, isWhereExpr, queryAstKinds, sqlCodecDefinitions, sqlDataTypes, whereExprKinds };
266
+ export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyQueryAst, AstRewriter, BinaryExpr, BinaryOp, Codec, CodecCallContext, CodecDescriptor, CodecMeta, CodecTrait, ColumnRef, ContractCodecRegistry, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, ExprVisitor, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, ListExpression, LiteralExpr, LoweredStatement, Lowerer, LowererContext, MarkerReadResult, MarkerStatement, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, ParamRefBindingRefs, ProjectionExpr, ProjectionItem, RawSqlExpr, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SelectAstOptions, SqlCharCodec, SqlCharDescriptor, SqlCodecCallContext, SqlCodecInstanceContext, SqlColumnRef, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableRef, TableSource, ToWhereExpr, UpdateAst, WhereArg, collectOrderedParamRefs, compact, isQueryAst, isWhereExpr, queryAstKinds, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType, validateParamRefRefs, whereExprKinds };
190
267
  //# sourceMappingURL=ast.d.mts.map