@prisma-next/sql-runtime 0.3.0-dev.33 → 0.3.0-dev.36
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 +115 -24
- package/dist/exports-C8hi0N-a.mjs +622 -0
- package/dist/exports-C8hi0N-a.mjs.map +1 -0
- package/dist/index-SlQIrV_t.d.mts +131 -0
- package/dist/index-SlQIrV_t.d.mts.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3 -0
- package/dist/test/utils.d.mts +82 -0
- package/dist/test/utils.d.mts.map +1 -0
- package/dist/test/utils.mjs +212 -0
- package/dist/test/utils.mjs.map +1 -0
- package/package.json +26 -20
- package/src/codecs/decoding.ts +84 -3
- package/src/codecs/encoding.ts +15 -2
- package/src/codecs/json-schema-validation.ts +61 -0
- package/src/exports/index.ts +9 -4
- package/src/lower-sql-plan.ts +8 -8
- package/src/sql-context.ts +286 -245
- package/src/sql-family-adapter.ts +9 -5
- package/src/sql-marker.ts +2 -2
- package/src/sql-runtime.ts +89 -23
- package/test/async-iterable-result.test.ts +42 -34
- package/test/context.types.test-d.ts +12 -14
- package/test/execution-stack.test.ts +166 -0
- package/test/json-schema-validation.test.ts +653 -0
- package/test/parameterized-types.test.ts +182 -196
- package/test/sql-context.test.ts +292 -117
- package/test/sql-family-adapter.test.ts +7 -6
- package/test/sql-runtime.test.ts +117 -31
- package/test/utils.ts +76 -50
- package/dist/accelerate-EEKAFGN3-P6A6XJWJ.js +0 -137863
- package/dist/accelerate-EEKAFGN3-P6A6XJWJ.js.map +0 -1
- package/dist/amcheck-24VY6X5V.js +0 -13
- package/dist/amcheck-24VY6X5V.js.map +0 -1
- package/dist/bloom-VS74NLHT.js +0 -13
- package/dist/bloom-VS74NLHT.js.map +0 -1
- package/dist/btree_gin-WBC4EAAI.js +0 -13
- package/dist/btree_gin-WBC4EAAI.js.map +0 -1
- package/dist/btree_gist-UNC6QD3M.js +0 -13
- package/dist/btree_gist-UNC6QD3M.js.map +0 -1
- package/dist/chunk-3KTOEDFX.js +0 -49
- package/dist/chunk-3KTOEDFX.js.map +0 -1
- package/dist/chunk-47DZBRQC.js +0 -1280
- package/dist/chunk-47DZBRQC.js.map +0 -1
- package/dist/chunk-52N6AFZM.js +0 -133
- package/dist/chunk-52N6AFZM.js.map +0 -1
- package/dist/chunk-7D4SUZUM.js +0 -38
- package/dist/chunk-7D4SUZUM.js.map +0 -1
- package/dist/chunk-APA6GHYY.js +0 -537
- package/dist/chunk-APA6GHYY.js.map +0 -1
- package/dist/chunk-ECWIHLAT.js +0 -37
- package/dist/chunk-ECWIHLAT.js.map +0 -1
- package/dist/chunk-EI626SDC.js +0 -105
- package/dist/chunk-EI626SDC.js.map +0 -1
- package/dist/chunk-UKKOYUGL.js +0 -578
- package/dist/chunk-UKKOYUGL.js.map +0 -1
- package/dist/chunk-XPLNMXQV.js +0 -1537
- package/dist/chunk-XPLNMXQV.js.map +0 -1
- package/dist/citext-T7MXGUY7.js +0 -13
- package/dist/citext-T7MXGUY7.js.map +0 -1
- package/dist/client-5FENX6AW.js +0 -299
- package/dist/client-5FENX6AW.js.map +0 -1
- package/dist/cube-TFDQBZCI.js +0 -13
- package/dist/cube-TFDQBZCI.js.map +0 -1
- package/dist/dict_int-AEUOPGWP.js +0 -13
- package/dist/dict_int-AEUOPGWP.js.map +0 -1
- package/dist/dict_xsyn-DAAYX3FL.js +0 -13
- package/dist/dict_xsyn-DAAYX3FL.js.map +0 -1
- package/dist/dist-AQ3LWXOX.js +0 -570
- package/dist/dist-AQ3LWXOX.js.map +0 -1
- package/dist/dist-LBVX6BJW.js +0 -189
- package/dist/dist-LBVX6BJW.js.map +0 -1
- package/dist/dist-WLKUVDN2.js +0 -5127
- package/dist/dist-WLKUVDN2.js.map +0 -1
- package/dist/earthdistance-KIGTF4LE.js +0 -13
- package/dist/earthdistance-KIGTF4LE.js.map +0 -1
- package/dist/file_fdw-5N55UP6I.js +0 -13
- package/dist/file_fdw-5N55UP6I.js.map +0 -1
- package/dist/fuzzystrmatch-KN3YWBFP.js +0 -13
- package/dist/fuzzystrmatch-KN3YWBFP.js.map +0 -1
- package/dist/hstore-YX726NKN.js +0 -13
- package/dist/hstore-YX726NKN.js.map +0 -1
- package/dist/http-exception-FZY2H4OF.js +0 -8
- package/dist/http-exception-FZY2H4OF.js.map +0 -1
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/intarray-NKVXNO2D.js +0 -13
- package/dist/intarray-NKVXNO2D.js.map +0 -1
- package/dist/isn-FTEMJGEV.js +0 -13
- package/dist/isn-FTEMJGEV.js.map +0 -1
- package/dist/lo-DB7L4NGI.js +0 -13
- package/dist/lo-DB7L4NGI.js.map +0 -1
- package/dist/logger-WQ7SHNDD.js +0 -68
- package/dist/logger-WQ7SHNDD.js.map +0 -1
- package/dist/ltree-Z32TZT6W.js +0 -13
- package/dist/ltree-Z32TZT6W.js.map +0 -1
- package/dist/nodefs-NM46ACH7.js +0 -31
- package/dist/nodefs-NM46ACH7.js.map +0 -1
- package/dist/opfs-ahp-NJO33LVZ.js +0 -332
- package/dist/opfs-ahp-NJO33LVZ.js.map +0 -1
- package/dist/pageinspect-YP3IZR4X.js +0 -13
- package/dist/pageinspect-YP3IZR4X.js.map +0 -1
- package/dist/pg_buffercache-7TD5J2FB.js +0 -13
- package/dist/pg_buffercache-7TD5J2FB.js.map +0 -1
- package/dist/pg_dump-SG4KYBUB.js +0 -2492
- package/dist/pg_dump-SG4KYBUB.js.map +0 -1
- package/dist/pg_freespacemap-DZDNCPZK.js +0 -13
- package/dist/pg_freespacemap-DZDNCPZK.js.map +0 -1
- package/dist/pg_surgery-J2MUEWEP.js +0 -13
- package/dist/pg_surgery-J2MUEWEP.js.map +0 -1
- package/dist/pg_trgm-7VNQOYS6.js +0 -13
- package/dist/pg_trgm-7VNQOYS6.js.map +0 -1
- package/dist/pg_visibility-TTSIPHFL.js +0 -13
- package/dist/pg_visibility-TTSIPHFL.js.map +0 -1
- package/dist/pg_walinspect-KPFHSHRJ.js +0 -13
- package/dist/pg_walinspect-KPFHSHRJ.js.map +0 -1
- package/dist/proxy-signals-GUDAMDHV.js +0 -39
- package/dist/proxy-signals-GUDAMDHV.js.map +0 -1
- package/dist/seg-IYVDLE4O.js +0 -13
- package/dist/seg-IYVDLE4O.js.map +0 -1
- package/dist/src/codecs/decoding.d.ts +0 -4
- package/dist/src/codecs/decoding.d.ts.map +0 -1
- package/dist/src/codecs/encoding.d.ts +0 -5
- package/dist/src/codecs/encoding.d.ts.map +0 -1
- package/dist/src/codecs/validation.d.ts +0 -6
- package/dist/src/codecs/validation.d.ts.map +0 -1
- package/dist/src/exports/index.d.ts +0 -11
- package/dist/src/exports/index.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/lower-sql-plan.d.ts +0 -15
- package/dist/src/lower-sql-plan.d.ts.map +0 -1
- package/dist/src/sql-context.d.ts +0 -130
- package/dist/src/sql-context.d.ts.map +0 -1
- package/dist/src/sql-family-adapter.d.ts +0 -10
- package/dist/src/sql-family-adapter.d.ts.map +0 -1
- package/dist/src/sql-marker.d.ts +0 -22
- package/dist/src/sql-marker.d.ts.map +0 -1
- package/dist/src/sql-runtime.d.ts +0 -25
- package/dist/src/sql-runtime.d.ts.map +0 -1
- package/dist/tablefunc-EF4RCS7S.js +0 -13
- package/dist/tablefunc-EF4RCS7S.js.map +0 -1
- package/dist/tcn-3VT5BQYW.js +0 -13
- package/dist/tcn-3VT5BQYW.js.map +0 -1
- package/dist/test/utils.d.ts +0 -60
- package/dist/test/utils.d.ts.map +0 -1
- package/dist/test/utils.js +0 -24635
- package/dist/test/utils.js.map +0 -1
- package/dist/tiny-CW6F4GX6.js +0 -10
- package/dist/tiny-CW6F4GX6.js.map +0 -1
- package/dist/tsm_system_rows-ES7KNUQH.js +0 -13
- package/dist/tsm_system_rows-ES7KNUQH.js.map +0 -1
- package/dist/tsm_system_time-76WEIMBG.js +0 -13
- package/dist/tsm_system_time-76WEIMBG.js.map +0 -1
- package/dist/unaccent-7RYF3R64.js +0 -13
- package/dist/unaccent-7RYF3R64.js.map +0 -1
- package/dist/utility-Q5A254LJ-J4HTKZPT.js +0 -347
- package/dist/utility-Q5A254LJ-J4HTKZPT.js.map +0 -1
- package/dist/uuid_ossp-4ETE4FPE.js +0 -13
- package/dist/uuid_ossp-4ETE4FPE.js.map +0 -1
- package/dist/vector-74GPNV7V.js +0 -13
- package/dist/vector-74GPNV7V.js.map +0 -1
- package/src/index.ts +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ SQL runtime implementation for Prisma Next.
|
|
|
10
10
|
|
|
11
11
|
## Overview
|
|
12
12
|
|
|
13
|
-
The SQL runtime package implements the SQL family runtime by composing `@prisma-next/runtime-executor` with SQL-specific adapters, drivers, and codecs. It provides the public runtime API for SQL-based databases
|
|
13
|
+
The SQL runtime package implements the SQL family runtime by composing `@prisma-next/runtime-executor` with SQL-specific adapters, drivers, and codecs. It provides the public runtime API for SQL-based databases, including descriptor-based static context derivation via `SqlStaticContributions` and execution-plane composition via `ExecutionStack`.
|
|
14
14
|
|
|
15
15
|
## Purpose
|
|
16
16
|
|
|
@@ -18,6 +18,8 @@ Execute SQL query Plans with deterministic verification, guardrails, and feedbac
|
|
|
18
18
|
|
|
19
19
|
## Responsibilities
|
|
20
20
|
|
|
21
|
+
- **Execution Stack Composition**: Compose runtime descriptors into a reusable `ExecutionStack`
|
|
22
|
+
- **Descriptor-Based Static Context Derivation**: Build `ExecutionContext` from `SqlStaticContributions` on descriptors without instantiation
|
|
21
23
|
- **SQL Context Creation**: Create runtime contexts with SQL contracts, adapters, and codecs
|
|
22
24
|
- **SQL Marker Management**: Provide SQL statements for reading/writing contract markers
|
|
23
25
|
- **Codec Encoding/Decoding**: Encode parameters and decode rows using SQL codec registries
|
|
@@ -27,6 +29,7 @@ Execute SQL query Plans with deterministic verification, guardrails, and feedbac
|
|
|
27
29
|
|
|
28
30
|
## Dependencies
|
|
29
31
|
|
|
32
|
+
- `@prisma-next/core-execution-plane` - Runtime component descriptor types
|
|
30
33
|
- `@prisma-next/runtime-executor` - Target-neutral execution engine
|
|
31
34
|
- `@prisma-next/sql-contract` - SQL contract types (via `@prisma-next/sql-contract/types`)
|
|
32
35
|
- `@prisma-next/operations` - Operation registry
|
|
@@ -34,25 +37,33 @@ Execute SQL query Plans with deterministic verification, guardrails, and feedbac
|
|
|
34
37
|
## Usage
|
|
35
38
|
|
|
36
39
|
```typescript
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
+
import postgresAdapter from '@prisma-next/adapter-postgres/runtime';
|
|
41
|
+
import postgresDriver from '@prisma-next/driver-postgres/runtime';
|
|
42
|
+
import pgvector from '@prisma-next/extension-pgvector/runtime';
|
|
43
|
+
import postgresTarget from '@prisma-next/target-postgres/runtime';
|
|
44
|
+
import { instantiateExecutionStack } from '@prisma-next/core-execution-plane/stack';
|
|
45
|
+
import { createExecutionContext, createRuntime, createSqlExecutionStack } from '@prisma-next/sql-runtime';
|
|
40
46
|
|
|
41
47
|
const contract = validateContract<Contract>(contractJson);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
extensions: [pgVector()],
|
|
48
|
+
const stack = createSqlExecutionStack({
|
|
49
|
+
target: postgresTarget,
|
|
50
|
+
adapter: postgresAdapter,
|
|
51
|
+
driver: postgresDriver,
|
|
52
|
+
extensionPacks: [pgvector],
|
|
48
53
|
});
|
|
49
54
|
|
|
55
|
+
// Static context (no instantiation needed)
|
|
56
|
+
const context = createExecutionContext({ contract, stack });
|
|
57
|
+
|
|
58
|
+
// Dynamic runtime
|
|
59
|
+
const stackInstance = instantiateExecutionStack(stack);
|
|
60
|
+
const driver = stack.driver.create({ connect: { connectionString: process.env.DATABASE_URL } });
|
|
50
61
|
const runtime = createRuntime({
|
|
51
|
-
|
|
52
|
-
driver: createPostgresDriver({ connectionString: process.env.DATABASE_URL }),
|
|
53
|
-
verify: { mode: 'onFirstUse', requireMarker: false },
|
|
62
|
+
stackInstance,
|
|
54
63
|
context,
|
|
55
|
-
|
|
64
|
+
driver,
|
|
65
|
+
verify: { mode: 'onFirstUse', requireMarker: false },
|
|
66
|
+
plugins: [budgets()],
|
|
56
67
|
});
|
|
57
68
|
|
|
58
69
|
for await (const row of runtime.execute(plan)) {
|
|
@@ -62,22 +73,102 @@ for await (const row of runtime.execute(plan)) {
|
|
|
62
73
|
|
|
63
74
|
## Exports
|
|
64
75
|
|
|
76
|
+
### Runtime
|
|
77
|
+
|
|
65
78
|
- `createRuntime` - Create a SQL runtime instance
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
68
|
-
- `
|
|
69
|
-
- `
|
|
70
|
-
|
|
79
|
+
- `Runtime` - Runtime instance type
|
|
80
|
+
- `CreateRuntimeOptions` - Options for `createRuntime`
|
|
81
|
+
- `RuntimeVerifyOptions` - Verification mode configuration
|
|
82
|
+
- `RuntimeTelemetryEvent`, `TelemetryOutcome` - Telemetry event types
|
|
83
|
+
|
|
84
|
+
### Context
|
|
85
|
+
|
|
86
|
+
- `createExecutionContext` - Create an execution context from contract + descriptors-only stack
|
|
87
|
+
- `createSqlExecutionStack` - SQL-specific stack factory that preserves descriptor types
|
|
88
|
+
- `ExecutionContext` - Context type for SQL operations
|
|
89
|
+
- `TypeHelperRegistry` - Registry for type helper lookup
|
|
90
|
+
|
|
91
|
+
### Descriptors & Stack
|
|
92
|
+
|
|
93
|
+
- `SqlStaticContributions` - Interface for descriptor-level static contributions (codecs, operations, parameterized codecs)
|
|
94
|
+
- `SqlRuntimeTargetDescriptor`, `SqlRuntimeAdapterDescriptor`, `SqlRuntimeExtensionDescriptor` - Structural descriptor types requiring `SqlStaticContributions`
|
|
95
|
+
- `SqlRuntimeAdapterInstance`, `SqlRuntimeDriverInstance`, `SqlRuntimeExtensionInstance` - Instance types
|
|
96
|
+
- `SqlExecutionStack` - Descriptors-only stack type for static context creation
|
|
97
|
+
- `SqlExecutionStackWithDriver` - Descriptor stack including driver for runtime instantiation
|
|
98
|
+
- `RuntimeParameterizedCodecDescriptor` - Parameterized codec descriptor type
|
|
99
|
+
|
|
100
|
+
### Codecs
|
|
101
|
+
|
|
71
102
|
- `validateCodecRegistryCompleteness` - Codec validation
|
|
103
|
+
- `extractCodecIds` - Extract codec IDs from a contract
|
|
104
|
+
- `validateContractCodecMappings` - Validate contract codec mappings against registry
|
|
105
|
+
|
|
106
|
+
### SQL Marker
|
|
107
|
+
|
|
108
|
+
- `readContractMarker`, `writeContractMarker` - SQL marker statements
|
|
109
|
+
- `ensureSchemaStatement`, `ensureTableStatement` - DDL statements for marker table setup
|
|
110
|
+
- `SqlStatement` - SQL statement type
|
|
111
|
+
|
|
112
|
+
### Plan Lowering
|
|
113
|
+
|
|
114
|
+
- `lowerSqlPlan` - SQL plan lowering via adapter
|
|
115
|
+
|
|
116
|
+
### Plugins (re-exported from `@prisma-next/runtime-executor`)
|
|
117
|
+
|
|
118
|
+
- `budgets`, `lints` - SQL-compatible plugins
|
|
119
|
+
- `BudgetsOptions`, `LintsOptions` - Plugin option types
|
|
120
|
+
- `Plugin`, `PluginContext` - Plugin interface types
|
|
121
|
+
- `AfterExecuteResult` - Plugin hook result type
|
|
122
|
+
- `Log` - Log entry type
|
|
72
123
|
|
|
73
124
|
## Architecture
|
|
74
125
|
|
|
75
|
-
The SQL runtime composes runtime-executor with SQL-specific implementations
|
|
126
|
+
The SQL runtime composes runtime-executor with SQL-specific implementations. Descriptors implement `SqlStaticContributions` so `ExecutionContext` can be derived from the descriptors-only stack without instantiation.
|
|
127
|
+
|
|
128
|
+
1. **ExecutionStack**: Descriptors-only stack (from `@prisma-next/core-execution-plane`)
|
|
129
|
+
2. **SqlStaticContributions**: Codecs, operation signatures, and parameterized codecs contributed by each descriptor
|
|
130
|
+
3. **ExecutionContext**: Built from contract + stack descriptors (no instantiation)
|
|
131
|
+
4. **ExecutionStackInstance**: Instantiated components used at runtime for execution
|
|
132
|
+
5. **SqlRuntime**: Wraps `RuntimeCore` and adds SQL-specific encoding/decoding
|
|
133
|
+
6. **SqlMarker**: Provides SQL statements for marker management
|
|
134
|
+
|
|
135
|
+
```mermaid
|
|
136
|
+
flowchart LR
|
|
137
|
+
Stack[ExecutionStack] --> Context[ExecutionContext]
|
|
138
|
+
Stack --> StackI[ExecutionStackInstance]
|
|
139
|
+
Stack --> DriverDesc[Driver Descriptor]
|
|
140
|
+
Stack --> AdapterDesc[Adapter Descriptor]
|
|
141
|
+
Stack --> Packs[Extension Packs]
|
|
142
|
+
Context --> Runtime[SqlRuntime]
|
|
143
|
+
Runtime --> Core[RuntimeCore]
|
|
144
|
+
DriverDesc --> DriverInst[Driver Instance]
|
|
145
|
+
AdapterDesc --> AdapterInst[Adapter Instance]
|
|
146
|
+
Runtime --> DriverInst
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Related Subsystems
|
|
150
|
+
|
|
151
|
+
- **[Query Lanes](../../../../docs/architecture%20docs/subsystems/3.%20Query%20Lanes.md)** — Lane authoring and plan building
|
|
152
|
+
- **[Runtime & Plugin Framework](../../../../docs/architecture%20docs/subsystems/4.%20Runtime%20&%20Plugin%20Framework.md)** — Runtime execution pipeline
|
|
153
|
+
- **[Adapters & Targets](../../../../docs/architecture%20docs/subsystems/5.%20Adapters%20&%20Targets.md)** — Adapter and driver responsibilities
|
|
154
|
+
|
|
155
|
+
## Related ADRs
|
|
156
|
+
|
|
157
|
+
- [ADR 152 - Execution Plane Descriptors and Instances](../../../../docs/architecture%20docs/adrs/ADR%20152%20-%20Execution%20Plane%20Descriptors%20and%20Instances.md)
|
|
158
|
+
|
|
159
|
+
## Error Codes
|
|
160
|
+
|
|
161
|
+
The SQL runtime uses stable error codes for programmatic error handling:
|
|
162
|
+
|
|
163
|
+
- `RUNTIME.CONTRACT_FAMILY_MISMATCH` — Contract target family differs from runtime family
|
|
164
|
+
- `RUNTIME.CONTRACT_TARGET_MISMATCH` — Contract target differs from stack target descriptor
|
|
165
|
+
- `RUNTIME.MISSING_EXTENSION_PACK` — Contract requires an extension pack not provided in stack
|
|
166
|
+
- `RUNTIME.DUPLICATE_PARAMETERIZED_CODEC` — Multiple extensions registered same parameterized codec
|
|
167
|
+
- `RUNTIME.TYPE_PARAMS_INVALID` — Type parameters fail codec schema validation
|
|
168
|
+
- `RUNTIME.CODEC_MISSING` — Required codec not found in registry
|
|
169
|
+
- `RUNTIME.DECODE_FAILED` — Row decoding failed
|
|
76
170
|
|
|
77
|
-
|
|
78
|
-
2. **SqlRuntime**: Wraps `RuntimeCore` and adds SQL-specific encoding/decoding
|
|
79
|
-
3. **SqlContext**: Creates contexts with SQL contracts, adapters, and codecs
|
|
80
|
-
4. **SqlMarker**: Provides SQL statements for marker management
|
|
171
|
+
All errors follow the repo's error envelope convention with `code`, `category`, `severity`, and optional `details`.
|
|
81
172
|
|
|
82
173
|
## Testing
|
|
83
174
|
|