@prisma-next/sql-runtime 0.0.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.
- package/README.md +90 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +456 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @prisma-next/sql-runtime
|
|
2
|
+
|
|
3
|
+
SQL runtime implementation for Prisma Next.
|
|
4
|
+
|
|
5
|
+
## Package Classification
|
|
6
|
+
|
|
7
|
+
- **Domain**: sql
|
|
8
|
+
- **Layer**: runtime
|
|
9
|
+
- **Plane**: runtime
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
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.
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
|
|
17
|
+
Execute SQL query Plans with deterministic verification, guardrails, and feedback. Provide a unified execution surface that works across all SQL query lanes (DSL, ORM, Raw SQL).
|
|
18
|
+
|
|
19
|
+
## Responsibilities
|
|
20
|
+
|
|
21
|
+
- **SQL Context Creation**: Create runtime contexts with SQL contracts, adapters, and codecs
|
|
22
|
+
- **SQL Marker Management**: Provide SQL statements for reading/writing contract markers
|
|
23
|
+
- **Codec Encoding/Decoding**: Encode parameters and decode rows using SQL codec registries
|
|
24
|
+
- **Codec Validation**: Validate that codec registries contain all required codecs
|
|
25
|
+
- **SQL Family Adapter**: Implement `RuntimeFamilyAdapter` for SQL contracts
|
|
26
|
+
- **SQL Runtime**: Compose runtime-executor with SQL-specific logic
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
|
|
30
|
+
- `@prisma-next/runtime-executor` - Target-neutral execution engine
|
|
31
|
+
- `@prisma-next/sql-contract` - SQL contract types
|
|
32
|
+
- `@prisma-next/sql-target` - SQL family interfaces (legacy transitional package)
|
|
33
|
+
- `@prisma-next/operations` - Operation registry
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { createRuntime, createRuntimeContext } from '@prisma-next/sql-runtime';
|
|
39
|
+
import { createPostgresAdapter } from '@prisma-next/adapter-postgres';
|
|
40
|
+
import { createPostgresDriver } from '@prisma-next/driver-postgres/runtime';
|
|
41
|
+
|
|
42
|
+
const contract = validateContract<Contract>(contractJson);
|
|
43
|
+
const adapter = createPostgresAdapter();
|
|
44
|
+
|
|
45
|
+
const context = createRuntimeContext({
|
|
46
|
+
contract,
|
|
47
|
+
adapter,
|
|
48
|
+
extensions: [pgVector()],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const runtime = createRuntime({
|
|
52
|
+
adapter,
|
|
53
|
+
driver: createPostgresDriver({ connectionString: process.env.DATABASE_URL }),
|
|
54
|
+
verify: { mode: 'onFirstUse', requireMarker: false },
|
|
55
|
+
context,
|
|
56
|
+
plugins: [budgets(), lints()],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
for await (const row of runtime.execute(plan)) {
|
|
60
|
+
console.log(row);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Exports
|
|
65
|
+
|
|
66
|
+
- `createRuntime` - Create a SQL runtime instance
|
|
67
|
+
- `createRuntimeContext` - Create a SQL runtime context
|
|
68
|
+
- `RuntimeContext`, `Extension` - Context types
|
|
69
|
+
- `budgets`, `lints` - SQL-compatible plugins (re-exported from runtime-executor)
|
|
70
|
+
- `readContractMarker`, `writeContractMarker` - SQL marker statements
|
|
71
|
+
- `encodeParams`, `decodeRow` - Codec encoding/decoding utilities
|
|
72
|
+
- `validateCodecRegistryCompleteness` - Codec validation
|
|
73
|
+
|
|
74
|
+
## Architecture
|
|
75
|
+
|
|
76
|
+
The SQL runtime composes runtime-executor with SQL-specific implementations:
|
|
77
|
+
|
|
78
|
+
1. **SqlFamilyAdapter**: Implements `RuntimeFamilyAdapter` for SQL contracts
|
|
79
|
+
2. **SqlRuntime**: Wraps `RuntimeCore` and adds SQL-specific encoding/decoding
|
|
80
|
+
3. **SqlContext**: Creates contexts with SQL contracts, adapters, and codecs
|
|
81
|
+
4. **SqlMarker**: Provides SQL statements for marker management
|
|
82
|
+
|
|
83
|
+
## Testing
|
|
84
|
+
|
|
85
|
+
Unit tests verify:
|
|
86
|
+
- Context creation with extensions
|
|
87
|
+
- Codec encoding/decoding
|
|
88
|
+
- Codec validation
|
|
89
|
+
- Marker statement generation
|
|
90
|
+
- Runtime execution with SQL adapters
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { MarkerStatement, RuntimeTelemetryEvent, RuntimeVerifyOptions, Plugin, Log } from '@prisma-next/runtime-executor';
|
|
2
|
+
export { AfterExecuteResult, BudgetsOptions, LintsOptions, Log, Plugin, PluginContext, RuntimeTelemetryEvent, RuntimeVerifyOptions, TelemetryOutcome, budgets, lints } from '@prisma-next/runtime-executor';
|
|
3
|
+
import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
4
|
+
import { CodecRegistry, Adapter, QueryAst, LoweredStatement, SelectAst, SqlDriver } from '@prisma-next/sql-relational-core/ast';
|
|
5
|
+
import { ExecutionPlan } from '@prisma-next/contract/types';
|
|
6
|
+
import { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';
|
|
7
|
+
import { OperationSignature, OperationRegistry } from '@prisma-next/operations';
|
|
8
|
+
import { QueryLaneContext } from '@prisma-next/sql-relational-core/query-lane-context';
|
|
9
|
+
|
|
10
|
+
declare function extractTypeIds(contract: SqlContract<SqlStorage>): Set<string>;
|
|
11
|
+
declare function validateContractCodecMappings(registry: CodecRegistry, contract: SqlContract<SqlStorage>): void;
|
|
12
|
+
declare function validateCodecRegistryCompleteness(registry: CodecRegistry, contract: SqlContract<SqlStorage>): void;
|
|
13
|
+
|
|
14
|
+
interface SqlLoweringSpec {
|
|
15
|
+
readonly targetFamily: 'sql';
|
|
16
|
+
readonly strategy: 'infix' | 'function';
|
|
17
|
+
readonly template: string;
|
|
18
|
+
}
|
|
19
|
+
interface SqlOperationSignature extends OperationSignature {
|
|
20
|
+
readonly lowering: SqlLoweringSpec;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface RuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> extends QueryLaneContext<TContract> {
|
|
24
|
+
readonly adapter: Adapter<QueryAst, TContract, LoweredStatement> | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
25
|
+
}
|
|
26
|
+
interface Extension {
|
|
27
|
+
codecs?(): CodecRegistry;
|
|
28
|
+
operations?(): ReadonlyArray<SqlOperationSignature>;
|
|
29
|
+
}
|
|
30
|
+
interface CreateRuntimeContextOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> {
|
|
31
|
+
readonly contract: TContract;
|
|
32
|
+
readonly adapter: Adapter<QueryAst, TContract, LoweredStatement> | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
33
|
+
readonly extensions?: ReadonlyArray<Extension>;
|
|
34
|
+
}
|
|
35
|
+
declare function createRuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>>(options: CreateRuntimeContextOptions<TContract>): RuntimeContext<TContract>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Lowers a SQL query plan to an executable Plan by calling the adapter's lower method.
|
|
39
|
+
*
|
|
40
|
+
* This function is responsible for converting a lane-produced SqlQueryPlan (which contains
|
|
41
|
+
* AST and params but no SQL) into a fully executable Plan (which includes SQL string).
|
|
42
|
+
*
|
|
43
|
+
* @param context - Runtime context containing the adapter
|
|
44
|
+
* @param queryPlan - SQL query plan from a lane (contains AST, params, meta, but no SQL)
|
|
45
|
+
* @returns Fully executable Plan with SQL string
|
|
46
|
+
*/
|
|
47
|
+
declare function lowerSqlPlan<Row>(context: RuntimeContext, queryPlan: SqlQueryPlan<Row>): ExecutionPlan<Row>;
|
|
48
|
+
|
|
49
|
+
interface SqlStatement {
|
|
50
|
+
readonly sql: string;
|
|
51
|
+
readonly params: readonly unknown[];
|
|
52
|
+
}
|
|
53
|
+
interface WriteMarkerInput {
|
|
54
|
+
readonly coreHash: string;
|
|
55
|
+
readonly profileHash: string;
|
|
56
|
+
readonly contractJson?: unknown;
|
|
57
|
+
readonly canonicalVersion?: number;
|
|
58
|
+
readonly appTag?: string;
|
|
59
|
+
readonly meta?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
declare const ensureSchemaStatement: SqlStatement;
|
|
62
|
+
declare const ensureTableStatement: SqlStatement;
|
|
63
|
+
declare function readContractMarker(): MarkerStatement;
|
|
64
|
+
interface WriteContractMarkerStatements {
|
|
65
|
+
readonly insert: SqlStatement;
|
|
66
|
+
readonly update: SqlStatement;
|
|
67
|
+
}
|
|
68
|
+
declare function writeContractMarker(input: WriteMarkerInput): WriteContractMarkerStatements;
|
|
69
|
+
|
|
70
|
+
interface RuntimeOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> {
|
|
71
|
+
readonly adapter: Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>;
|
|
72
|
+
readonly driver: SqlDriver;
|
|
73
|
+
readonly verify: RuntimeVerifyOptions;
|
|
74
|
+
readonly context: RuntimeContext<TContract>;
|
|
75
|
+
readonly plugins?: readonly Plugin<TContract, Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>, SqlDriver>[];
|
|
76
|
+
readonly mode?: 'strict' | 'permissive';
|
|
77
|
+
readonly log?: Log;
|
|
78
|
+
}
|
|
79
|
+
interface Runtime {
|
|
80
|
+
execute<Row = Record<string, unknown>>(plan: ExecutionPlan<Row> | SqlQueryPlan<Row>): AsyncIterable<Row>;
|
|
81
|
+
telemetry(): RuntimeTelemetryEvent | null;
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
operations(): OperationRegistry;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare function createRuntime<TContract extends SqlContract<SqlStorage>>(options: RuntimeOptions<TContract>): Runtime;
|
|
87
|
+
|
|
88
|
+
export { type Extension, type Runtime, type RuntimeContext, type RuntimeOptions, type SqlStatement, createRuntime, createRuntimeContext, ensureSchemaStatement, ensureTableStatement, extractTypeIds, lowerSqlPlan, readContractMarker, validateCodecRegistryCompleteness, validateContractCodecMappings, writeContractMarker };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
// src/exports/index.ts
|
|
2
|
+
import { budgets, lints } from "@prisma-next/runtime-executor";
|
|
3
|
+
|
|
4
|
+
// src/codecs/validation.ts
|
|
5
|
+
import { runtimeError } from "@prisma-next/runtime-executor";
|
|
6
|
+
function extractTypeIds(contract) {
|
|
7
|
+
const typeIds = /* @__PURE__ */ new Set();
|
|
8
|
+
for (const table of Object.values(contract.storage.tables)) {
|
|
9
|
+
for (const column of Object.values(table.columns)) {
|
|
10
|
+
if (column.type) {
|
|
11
|
+
typeIds.add(column.type);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return typeIds;
|
|
16
|
+
}
|
|
17
|
+
function extractTypeIdsFromColumns(contract) {
|
|
18
|
+
const typeIds = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const [tableName, table] of Object.entries(contract.storage.tables)) {
|
|
20
|
+
for (const [columnName, column] of Object.entries(table.columns)) {
|
|
21
|
+
if (column.type) {
|
|
22
|
+
const key = `${tableName}.${columnName}`;
|
|
23
|
+
typeIds.set(key, column.type);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return typeIds;
|
|
28
|
+
}
|
|
29
|
+
function validateContractCodecMappings(registry, contract) {
|
|
30
|
+
const typeIds = extractTypeIdsFromColumns(contract);
|
|
31
|
+
const invalidCodecs = [];
|
|
32
|
+
for (const [key, typeId] of typeIds.entries()) {
|
|
33
|
+
if (!registry.has(typeId)) {
|
|
34
|
+
const parts = key.split(".");
|
|
35
|
+
const table = parts[0] ?? "";
|
|
36
|
+
const column = parts[1] ?? "";
|
|
37
|
+
invalidCodecs.push({ table, column, typeId });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (invalidCodecs.length > 0) {
|
|
41
|
+
const details = {
|
|
42
|
+
contractTarget: contract.target,
|
|
43
|
+
invalidCodecs
|
|
44
|
+
};
|
|
45
|
+
throw runtimeError(
|
|
46
|
+
"RUNTIME.CODEC_MISSING",
|
|
47
|
+
`Missing codec implementations for column typeIds: ${invalidCodecs.map((c) => `${c.table}.${c.column} (${c.typeId})`).join(", ")}`,
|
|
48
|
+
details
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function validateCodecRegistryCompleteness(registry, contract) {
|
|
53
|
+
validateContractCodecMappings(registry, contract);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/lower-sql-plan.ts
|
|
57
|
+
function lowerSqlPlan(context, queryPlan) {
|
|
58
|
+
const lowered = context.adapter.lower(queryPlan.ast, {
|
|
59
|
+
contract: context.contract,
|
|
60
|
+
params: queryPlan.params
|
|
61
|
+
});
|
|
62
|
+
const body = lowered.body;
|
|
63
|
+
return Object.freeze({
|
|
64
|
+
sql: body.sql,
|
|
65
|
+
params: body.params ?? queryPlan.params,
|
|
66
|
+
ast: queryPlan.ast,
|
|
67
|
+
meta: queryPlan.meta
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/sql-context.ts
|
|
72
|
+
import { createOperationRegistry } from "@prisma-next/operations";
|
|
73
|
+
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
74
|
+
function createRuntimeContext(options) {
|
|
75
|
+
const { contract, adapter, extensions } = options;
|
|
76
|
+
const codecRegistry = createCodecRegistry();
|
|
77
|
+
const operationRegistry = createOperationRegistry();
|
|
78
|
+
const allExtensions = [
|
|
79
|
+
{
|
|
80
|
+
codecs: () => adapter.profile.codecs()
|
|
81
|
+
},
|
|
82
|
+
...extensions ?? []
|
|
83
|
+
];
|
|
84
|
+
for (const extension of allExtensions) {
|
|
85
|
+
const extensionCodecs = extension.codecs?.();
|
|
86
|
+
if (extensionCodecs) {
|
|
87
|
+
for (const codec of extensionCodecs.values()) {
|
|
88
|
+
codecRegistry.register(codec);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const extensionOperations = extension.operations?.();
|
|
92
|
+
if (extensionOperations) {
|
|
93
|
+
for (const operation of extensionOperations) {
|
|
94
|
+
operationRegistry.register(operation);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
contract,
|
|
100
|
+
adapter,
|
|
101
|
+
operations: operationRegistry,
|
|
102
|
+
codecs: codecRegistry
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/sql-marker.ts
|
|
107
|
+
var ensureSchemaStatement = {
|
|
108
|
+
sql: "create schema if not exists prisma_contract",
|
|
109
|
+
params: []
|
|
110
|
+
};
|
|
111
|
+
var ensureTableStatement = {
|
|
112
|
+
sql: `create table if not exists prisma_contract.marker (
|
|
113
|
+
id smallint primary key default 1,
|
|
114
|
+
core_hash text not null,
|
|
115
|
+
profile_hash text not null,
|
|
116
|
+
contract_json jsonb,
|
|
117
|
+
canonical_version int,
|
|
118
|
+
updated_at timestamptz not null default now(),
|
|
119
|
+
app_tag text,
|
|
120
|
+
meta jsonb not null default '{}'
|
|
121
|
+
)`,
|
|
122
|
+
params: []
|
|
123
|
+
};
|
|
124
|
+
function readContractMarker() {
|
|
125
|
+
return {
|
|
126
|
+
sql: `select
|
|
127
|
+
core_hash,
|
|
128
|
+
profile_hash,
|
|
129
|
+
contract_json,
|
|
130
|
+
canonical_version,
|
|
131
|
+
updated_at,
|
|
132
|
+
app_tag,
|
|
133
|
+
meta
|
|
134
|
+
from prisma_contract.marker
|
|
135
|
+
where id = $1`,
|
|
136
|
+
params: [1]
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function writeContractMarker(input) {
|
|
140
|
+
const baseParams = [
|
|
141
|
+
1,
|
|
142
|
+
input.coreHash,
|
|
143
|
+
input.profileHash,
|
|
144
|
+
input.contractJson ?? null,
|
|
145
|
+
input.canonicalVersion ?? null,
|
|
146
|
+
input.appTag ?? null,
|
|
147
|
+
JSON.stringify(input.meta ?? {})
|
|
148
|
+
];
|
|
149
|
+
const insert = {
|
|
150
|
+
sql: `insert into prisma_contract.marker (
|
|
151
|
+
id,
|
|
152
|
+
core_hash,
|
|
153
|
+
profile_hash,
|
|
154
|
+
contract_json,
|
|
155
|
+
canonical_version,
|
|
156
|
+
updated_at,
|
|
157
|
+
app_tag,
|
|
158
|
+
meta
|
|
159
|
+
) values (
|
|
160
|
+
$1,
|
|
161
|
+
$2,
|
|
162
|
+
$3,
|
|
163
|
+
$4::jsonb,
|
|
164
|
+
$5,
|
|
165
|
+
now(),
|
|
166
|
+
$6,
|
|
167
|
+
$7::jsonb
|
|
168
|
+
)`,
|
|
169
|
+
params: baseParams
|
|
170
|
+
};
|
|
171
|
+
const update = {
|
|
172
|
+
sql: `update prisma_contract.marker set
|
|
173
|
+
core_hash = $2,
|
|
174
|
+
profile_hash = $3,
|
|
175
|
+
contract_json = $4::jsonb,
|
|
176
|
+
canonical_version = $5,
|
|
177
|
+
updated_at = now(),
|
|
178
|
+
app_tag = $6,
|
|
179
|
+
meta = $7::jsonb
|
|
180
|
+
where id = $1`,
|
|
181
|
+
params: baseParams
|
|
182
|
+
};
|
|
183
|
+
return { insert, update };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/sql-runtime.ts
|
|
187
|
+
import { createRuntimeCore } from "@prisma-next/runtime-executor";
|
|
188
|
+
|
|
189
|
+
// src/codecs/decoding.ts
|
|
190
|
+
function resolveRowCodec(alias, plan, registry) {
|
|
191
|
+
const planCodecId = plan.meta.annotations?.codecs?.[alias];
|
|
192
|
+
if (planCodecId) {
|
|
193
|
+
const codec = registry.get(planCodecId);
|
|
194
|
+
if (codec) {
|
|
195
|
+
return codec;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (plan.meta.projectionTypes) {
|
|
199
|
+
const typeId = plan.meta.projectionTypes[alias];
|
|
200
|
+
if (typeId) {
|
|
201
|
+
const codec = registry.get(typeId);
|
|
202
|
+
if (codec) {
|
|
203
|
+
return codec;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
function decodeRow(row, plan, registry) {
|
|
210
|
+
const decoded = {};
|
|
211
|
+
let aliases;
|
|
212
|
+
const projection = plan.meta.projection;
|
|
213
|
+
if (projection && !Array.isArray(projection)) {
|
|
214
|
+
aliases = Object.keys(projection);
|
|
215
|
+
} else if (projection && Array.isArray(projection)) {
|
|
216
|
+
aliases = projection;
|
|
217
|
+
} else {
|
|
218
|
+
aliases = Object.keys(row);
|
|
219
|
+
}
|
|
220
|
+
for (const alias of aliases) {
|
|
221
|
+
const wireValue = row[alias];
|
|
222
|
+
const projection2 = plan.meta.projection;
|
|
223
|
+
const projectionValue = projection2 && typeof projection2 === "object" && !Array.isArray(projection2) ? projection2[alias] : void 0;
|
|
224
|
+
if (typeof projectionValue === "string" && projectionValue.startsWith("include:")) {
|
|
225
|
+
if (wireValue === null || wireValue === void 0) {
|
|
226
|
+
decoded[alias] = [];
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
let parsed;
|
|
231
|
+
if (typeof wireValue === "string") {
|
|
232
|
+
parsed = JSON.parse(wireValue);
|
|
233
|
+
} else if (Array.isArray(wireValue)) {
|
|
234
|
+
parsed = wireValue;
|
|
235
|
+
} else {
|
|
236
|
+
parsed = JSON.parse(String(wireValue));
|
|
237
|
+
}
|
|
238
|
+
if (!Array.isArray(parsed)) {
|
|
239
|
+
throw new Error(`Expected array for include alias '${alias}', got ${typeof parsed}`);
|
|
240
|
+
}
|
|
241
|
+
decoded[alias] = parsed;
|
|
242
|
+
} catch (error) {
|
|
243
|
+
const decodeError = new Error(
|
|
244
|
+
`Failed to parse JSON array for include alias '${alias}': ${error instanceof Error ? error.message : String(error)}`
|
|
245
|
+
);
|
|
246
|
+
decodeError.code = "RUNTIME.DECODE_FAILED";
|
|
247
|
+
decodeError.category = "RUNTIME";
|
|
248
|
+
decodeError.severity = "error";
|
|
249
|
+
decodeError.details = {
|
|
250
|
+
alias,
|
|
251
|
+
wirePreview: typeof wireValue === "string" && wireValue.length > 100 ? `${wireValue.substring(0, 100)}...` : String(wireValue).substring(0, 100)
|
|
252
|
+
};
|
|
253
|
+
throw decodeError;
|
|
254
|
+
}
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (wireValue === null || wireValue === void 0) {
|
|
258
|
+
decoded[alias] = wireValue;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const codec = resolveRowCodec(alias, plan, registry);
|
|
262
|
+
if (!codec) {
|
|
263
|
+
decoded[alias] = wireValue;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
decoded[alias] = codec.decode(wireValue);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
const decodeError = new Error(
|
|
270
|
+
`Failed to decode row alias '${alias}' with codec '${codec.id}': ${error instanceof Error ? error.message : String(error)}`
|
|
271
|
+
);
|
|
272
|
+
decodeError.code = "RUNTIME.DECODE_FAILED";
|
|
273
|
+
decodeError.category = "RUNTIME";
|
|
274
|
+
decodeError.severity = "error";
|
|
275
|
+
decodeError.details = {
|
|
276
|
+
alias,
|
|
277
|
+
codec: codec.id,
|
|
278
|
+
wirePreview: typeof wireValue === "string" && wireValue.length > 100 ? `${wireValue.substring(0, 100)}...` : String(wireValue).substring(0, 100)
|
|
279
|
+
};
|
|
280
|
+
throw decodeError;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return decoded;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/codecs/encoding.ts
|
|
287
|
+
function resolveParamCodec(paramDescriptor, plan, registry) {
|
|
288
|
+
const paramName = paramDescriptor.name ?? `param_${paramDescriptor.index ?? 0}`;
|
|
289
|
+
const planCodecId = plan.meta.annotations?.codecs?.[paramName];
|
|
290
|
+
if (planCodecId) {
|
|
291
|
+
const codec = registry.get(planCodecId);
|
|
292
|
+
if (codec) {
|
|
293
|
+
return codec;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (paramDescriptor.type) {
|
|
297
|
+
const codec = registry.get(paramDescriptor.type);
|
|
298
|
+
if (codec) {
|
|
299
|
+
return codec;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
function encodeParam(value, paramDescriptor, plan, registry) {
|
|
305
|
+
if (value === null || value === void 0) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
const codec = resolveParamCodec(paramDescriptor, plan, registry);
|
|
309
|
+
if (!codec) {
|
|
310
|
+
return value;
|
|
311
|
+
}
|
|
312
|
+
if (codec.encode) {
|
|
313
|
+
try {
|
|
314
|
+
return codec.encode(value);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
throw new Error(
|
|
317
|
+
`Failed to encode parameter ${paramDescriptor.name ?? paramDescriptor.index}: ${error instanceof Error ? error.message : String(error)}`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return value;
|
|
322
|
+
}
|
|
323
|
+
function encodeParams(plan, registry) {
|
|
324
|
+
if (plan.params.length === 0) {
|
|
325
|
+
return plan.params;
|
|
326
|
+
}
|
|
327
|
+
const encoded = [];
|
|
328
|
+
for (let i = 0; i < plan.params.length; i++) {
|
|
329
|
+
const paramValue = plan.params[i];
|
|
330
|
+
const paramDescriptor = plan.meta.paramDescriptors[i];
|
|
331
|
+
if (paramDescriptor) {
|
|
332
|
+
encoded.push(encodeParam(paramValue, paramDescriptor, plan, registry));
|
|
333
|
+
} else {
|
|
334
|
+
encoded.push(paramValue);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return Object.freeze(encoded);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/sql-family-adapter.ts
|
|
341
|
+
import { runtimeError as runtimeError2 } from "@prisma-next/runtime-executor";
|
|
342
|
+
var SqlMarkerReader = class {
|
|
343
|
+
readMarkerStatement() {
|
|
344
|
+
return readContractMarker();
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var SqlFamilyAdapter = class {
|
|
348
|
+
contract;
|
|
349
|
+
markerReader;
|
|
350
|
+
constructor(contract) {
|
|
351
|
+
this.contract = contract;
|
|
352
|
+
this.markerReader = new SqlMarkerReader();
|
|
353
|
+
}
|
|
354
|
+
validatePlan(plan, contract) {
|
|
355
|
+
if (plan.meta.target !== contract.target) {
|
|
356
|
+
throw runtimeError2("PLAN.TARGET_MISMATCH", "Plan target does not match runtime target", {
|
|
357
|
+
planTarget: plan.meta.target,
|
|
358
|
+
runtimeTarget: contract.target
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (plan.meta.coreHash !== contract.coreHash) {
|
|
362
|
+
throw runtimeError2("PLAN.HASH_MISMATCH", "Plan core hash does not match runtime contract", {
|
|
363
|
+
planCoreHash: plan.meta.coreHash,
|
|
364
|
+
runtimeCoreHash: contract.coreHash
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// src/sql-runtime.ts
|
|
371
|
+
var SqlRuntimeImpl = class {
|
|
372
|
+
core;
|
|
373
|
+
contract;
|
|
374
|
+
context;
|
|
375
|
+
codecRegistry;
|
|
376
|
+
codecRegistryValidated;
|
|
377
|
+
constructor(options) {
|
|
378
|
+
const { context, driver, verify, plugins, mode, log } = options;
|
|
379
|
+
this.contract = context.contract;
|
|
380
|
+
this.context = context;
|
|
381
|
+
this.codecRegistry = context.codecs;
|
|
382
|
+
this.codecRegistryValidated = false;
|
|
383
|
+
const familyAdapter = new SqlFamilyAdapter(context.contract);
|
|
384
|
+
const coreOptions = {
|
|
385
|
+
familyAdapter,
|
|
386
|
+
driver,
|
|
387
|
+
verify,
|
|
388
|
+
plugins,
|
|
389
|
+
...mode !== void 0 ? { mode } : {},
|
|
390
|
+
...log !== void 0 ? { log } : {},
|
|
391
|
+
operationRegistry: context.operations
|
|
392
|
+
};
|
|
393
|
+
this.core = createRuntimeCore(coreOptions);
|
|
394
|
+
if (verify.mode === "startup") {
|
|
395
|
+
validateCodecRegistryCompleteness(this.codecRegistry, context.contract);
|
|
396
|
+
this.codecRegistryValidated = true;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
ensureCodecRegistryValidated(contract) {
|
|
400
|
+
if (!this.codecRegistryValidated) {
|
|
401
|
+
validateCodecRegistryCompleteness(this.codecRegistry, contract);
|
|
402
|
+
this.codecRegistryValidated = true;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
execute(plan) {
|
|
406
|
+
this.ensureCodecRegistryValidated(this.contract);
|
|
407
|
+
const isSqlQueryPlan = (p) => {
|
|
408
|
+
return "ast" in p && !("sql" in p);
|
|
409
|
+
};
|
|
410
|
+
const executablePlan = isSqlQueryPlan(plan) ? lowerSqlPlan(this.context, plan) : plan;
|
|
411
|
+
const iterator = async function* (self) {
|
|
412
|
+
const encodedParams = encodeParams(executablePlan, self.codecRegistry);
|
|
413
|
+
const planWithEncodedParams = {
|
|
414
|
+
...executablePlan,
|
|
415
|
+
params: encodedParams
|
|
416
|
+
};
|
|
417
|
+
const coreIterator = self.core.execute(planWithEncodedParams);
|
|
418
|
+
for await (const rawRow of coreIterator) {
|
|
419
|
+
const decodedRow = decodeRow(
|
|
420
|
+
rawRow,
|
|
421
|
+
executablePlan,
|
|
422
|
+
self.codecRegistry
|
|
423
|
+
);
|
|
424
|
+
yield decodedRow;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
return iterator(this);
|
|
428
|
+
}
|
|
429
|
+
telemetry() {
|
|
430
|
+
return this.core.telemetry();
|
|
431
|
+
}
|
|
432
|
+
operations() {
|
|
433
|
+
return this.core.operations();
|
|
434
|
+
}
|
|
435
|
+
close() {
|
|
436
|
+
return this.core.close();
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
function createRuntime(options) {
|
|
440
|
+
return new SqlRuntimeImpl(options);
|
|
441
|
+
}
|
|
442
|
+
export {
|
|
443
|
+
budgets,
|
|
444
|
+
createRuntime,
|
|
445
|
+
createRuntimeContext,
|
|
446
|
+
ensureSchemaStatement,
|
|
447
|
+
ensureTableStatement,
|
|
448
|
+
extractTypeIds,
|
|
449
|
+
lints,
|
|
450
|
+
lowerSqlPlan,
|
|
451
|
+
readContractMarker,
|
|
452
|
+
validateCodecRegistryCompleteness,
|
|
453
|
+
validateContractCodecMappings,
|
|
454
|
+
writeContractMarker
|
|
455
|
+
};
|
|
456
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/exports/index.ts","../src/codecs/validation.ts","../src/lower-sql-plan.ts","../src/sql-context.ts","../src/sql-marker.ts","../src/sql-runtime.ts","../src/codecs/decoding.ts","../src/codecs/encoding.ts","../src/sql-family-adapter.ts"],"sourcesContent":["export type {\n AfterExecuteResult,\n BudgetsOptions,\n LintsOptions,\n Log,\n Plugin,\n PluginContext,\n} from '@prisma-next/runtime-executor';\nexport { budgets, lints } from '@prisma-next/runtime-executor';\nexport {\n extractTypeIds,\n validateCodecRegistryCompleteness,\n validateContractCodecMappings,\n} from '../codecs/validation';\nexport { lowerSqlPlan } from '../lower-sql-plan';\nexport type { Extension, RuntimeContext } from '../sql-context';\nexport { createRuntimeContext } from '../sql-context';\nexport type { SqlStatement } from '../sql-marker';\nexport {\n ensureSchemaStatement,\n ensureTableStatement,\n readContractMarker,\n writeContractMarker,\n} from '../sql-marker';\nexport type {\n Runtime,\n RuntimeOptions,\n RuntimeTelemetryEvent,\n RuntimeVerifyOptions,\n TelemetryOutcome,\n} from '../sql-runtime';\nexport { createRuntime } from '../sql-runtime';\n","import { runtimeError } from '@prisma-next/runtime-executor';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { CodecRegistry } from '@prisma-next/sql-relational-core/ast';\n\nexport function extractTypeIds(contract: SqlContract<SqlStorage>): Set<string> {\n const typeIds = new Set<string>();\n\n for (const table of Object.values(contract.storage.tables)) {\n for (const column of Object.values(table.columns)) {\n if (column.type) {\n typeIds.add(column.type);\n }\n }\n }\n\n return typeIds;\n}\n\nfunction extractTypeIdsFromColumns(contract: SqlContract<SqlStorage>): Map<string, string> {\n const typeIds = new Map<string, string>();\n\n for (const [tableName, table] of Object.entries(contract.storage.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n if (column.type) {\n const key = `${tableName}.${columnName}`;\n typeIds.set(key, column.type);\n }\n }\n }\n\n return typeIds;\n}\n\nexport function validateContractCodecMappings(\n registry: CodecRegistry,\n contract: SqlContract<SqlStorage>,\n): void {\n const typeIds = extractTypeIdsFromColumns(contract);\n const invalidCodecs: Array<{ table: string; column: string; typeId: string }> = [];\n\n for (const [key, typeId] of typeIds.entries()) {\n if (!registry.has(typeId)) {\n const parts = key.split('.');\n const table = parts[0] ?? '';\n const column = parts[1] ?? '';\n invalidCodecs.push({ table, column, typeId });\n }\n }\n\n if (invalidCodecs.length > 0) {\n const details: Record<string, unknown> = {\n contractTarget: contract.target,\n invalidCodecs,\n };\n\n throw runtimeError(\n 'RUNTIME.CODEC_MISSING',\n `Missing codec implementations for column typeIds: ${invalidCodecs.map((c) => `${c.table}.${c.column} (${c.typeId})`).join(', ')}`,\n details,\n );\n }\n}\n\nexport function validateCodecRegistryCompleteness(\n registry: CodecRegistry,\n contract: SqlContract<SqlStorage>,\n): void {\n validateContractCodecMappings(registry, contract);\n}\n","import type { ExecutionPlan } from '@prisma-next/contract/types';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type { RuntimeContext } from './sql-context';\n\n/**\n * Lowers a SQL query plan to an executable Plan by calling the adapter's lower method.\n *\n * This function is responsible for converting a lane-produced SqlQueryPlan (which contains\n * AST and params but no SQL) into a fully executable Plan (which includes SQL string).\n *\n * @param context - Runtime context containing the adapter\n * @param queryPlan - SQL query plan from a lane (contains AST, params, meta, but no SQL)\n * @returns Fully executable Plan with SQL string\n */\nexport function lowerSqlPlan<Row>(\n context: RuntimeContext,\n queryPlan: SqlQueryPlan<Row>,\n): ExecutionPlan<Row> {\n const lowered = context.adapter.lower(queryPlan.ast, {\n contract: context.contract,\n params: queryPlan.params,\n });\n\n const body = lowered.body;\n\n return Object.freeze({\n sql: body.sql,\n params: body.params ?? queryPlan.params,\n ast: queryPlan.ast,\n meta: queryPlan.meta,\n });\n}\n","import { createOperationRegistry } from '@prisma-next/operations';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlOperationSignature } from '@prisma-next/sql-operations';\nimport type {\n Adapter,\n CodecRegistry,\n LoweredStatement,\n QueryAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport type { QueryLaneContext } from '@prisma-next/sql-relational-core/query-lane-context';\n\nexport interface RuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>>\n extends QueryLaneContext<TContract> {\n readonly adapter:\n | Adapter<QueryAst, TContract, LoweredStatement>\n | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;\n}\n\nexport interface Extension {\n codecs?(): CodecRegistry;\n operations?(): ReadonlyArray<SqlOperationSignature>;\n}\n\nexport interface CreateRuntimeContextOptions<\n TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n> {\n readonly contract: TContract;\n readonly adapter:\n | Adapter<QueryAst, TContract, LoweredStatement>\n | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;\n readonly extensions?: ReadonlyArray<Extension>;\n}\n\nexport function createRuntimeContext<\n TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n>(options: CreateRuntimeContextOptions<TContract>): RuntimeContext<TContract> {\n const { contract, adapter, extensions } = options;\n\n const codecRegistry = createCodecRegistry();\n const operationRegistry = createOperationRegistry();\n\n const allExtensions: ReadonlyArray<Extension> = [\n {\n codecs: () => adapter.profile.codecs(),\n },\n ...(extensions ?? []),\n ];\n\n for (const extension of allExtensions) {\n const extensionCodecs = extension.codecs?.();\n if (extensionCodecs) {\n for (const codec of extensionCodecs.values()) {\n codecRegistry.register(codec);\n }\n }\n\n const extensionOperations = extension.operations?.();\n if (extensionOperations) {\n for (const operation of extensionOperations) {\n operationRegistry.register(operation);\n }\n }\n }\n\n return {\n contract,\n adapter,\n operations: operationRegistry,\n codecs: codecRegistry,\n };\n}\n","import type { MarkerStatement } from '@prisma-next/runtime-executor';\n\nexport interface SqlStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n}\n\nexport interface WriteMarkerInput {\n readonly coreHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number;\n readonly appTag?: string;\n readonly meta?: Record<string, unknown>;\n}\n\nexport const ensureSchemaStatement: SqlStatement = {\n sql: 'create schema if not exists prisma_contract',\n params: [],\n};\n\nexport const ensureTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.marker (\n id smallint primary key default 1,\n core_hash text not null,\n profile_hash text not null,\n contract_json jsonb,\n canonical_version int,\n updated_at timestamptz not null default now(),\n app_tag text,\n meta jsonb not null default '{}'\n )`,\n params: [],\n};\n\nexport function readContractMarker(): MarkerStatement {\n return {\n sql: `select\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta\n from prisma_contract.marker\n where id = $1`,\n params: [1],\n };\n}\n\nexport interface WriteContractMarkerStatements {\n readonly insert: SqlStatement;\n readonly update: SqlStatement;\n}\n\nexport function writeContractMarker(input: WriteMarkerInput): WriteContractMarkerStatements {\n const baseParams: readonly unknown[] = [\n 1,\n input.coreHash,\n input.profileHash,\n input.contractJson ?? null,\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n JSON.stringify(input.meta ?? {}),\n ];\n\n const insert: SqlStatement = {\n sql: `insert into prisma_contract.marker (\n id,\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta\n ) values (\n $1,\n $2,\n $3,\n $4::jsonb,\n $5,\n now(),\n $6,\n $7::jsonb\n )`,\n params: baseParams,\n };\n\n const update: SqlStatement = {\n sql: `update prisma_contract.marker set\n core_hash = $2,\n profile_hash = $3,\n contract_json = $4::jsonb,\n canonical_version = $5,\n updated_at = now(),\n app_tag = $6,\n meta = $7::jsonb\n where id = $1`,\n params: baseParams,\n };\n\n return { insert, update };\n}\n","import type { ExecutionPlan } from '@prisma-next/contract/types';\nimport type { OperationRegistry } from '@prisma-next/operations';\nimport type {\n Log,\n Plugin,\n RuntimeCore,\n RuntimeCoreOptions,\n RuntimeTelemetryEvent,\n RuntimeVerifyOptions,\n TelemetryOutcome,\n} from '@prisma-next/runtime-executor';\nimport { createRuntimeCore } from '@prisma-next/runtime-executor';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type {\n Adapter,\n CodecRegistry,\n LoweredStatement,\n SelectAst,\n SqlDriver,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport { decodeRow } from './codecs/decoding';\nimport { encodeParams } from './codecs/encoding';\nimport { validateCodecRegistryCompleteness } from './codecs/validation';\nimport { lowerSqlPlan } from './lower-sql-plan';\nimport type { RuntimeContext } from './sql-context';\nimport { SqlFamilyAdapter } from './sql-family-adapter';\n\nexport interface RuntimeOptions<\n TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n> {\n readonly adapter: Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>;\n readonly driver: SqlDriver;\n readonly verify: RuntimeVerifyOptions;\n readonly context: RuntimeContext<TContract>;\n readonly plugins?: readonly Plugin<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >[];\n readonly mode?: 'strict' | 'permissive';\n readonly log?: Log;\n}\n\nexport interface Runtime {\n execute<Row = Record<string, unknown>>(\n plan: ExecutionPlan<Row> | SqlQueryPlan<Row>,\n ): AsyncIterable<Row>;\n telemetry(): RuntimeTelemetryEvent | null;\n close(): Promise<void>;\n operations(): OperationRegistry;\n}\n\nexport type { RuntimeTelemetryEvent, RuntimeVerifyOptions, TelemetryOutcome };\n\nclass SqlRuntimeImpl<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>>\n implements Runtime\n{\n private readonly core: RuntimeCore<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >;\n private readonly contract: TContract;\n private readonly context: RuntimeContext<TContract>;\n private readonly codecRegistry: CodecRegistry;\n private codecRegistryValidated: boolean;\n\n constructor(options: RuntimeOptions<TContract>) {\n const { context, driver, verify, plugins, mode, log } = options;\n this.contract = context.contract;\n this.context = context;\n this.codecRegistry = context.codecs;\n this.codecRegistryValidated = false;\n\n const familyAdapter = new SqlFamilyAdapter(context.contract);\n\n const coreOptions: RuntimeCoreOptions<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n > = {\n familyAdapter,\n driver,\n verify,\n plugins: plugins as readonly Plugin<\n TContract,\n Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>,\n SqlDriver\n >[],\n ...(mode !== undefined ? { mode } : {}),\n ...(log !== undefined ? { log } : {}),\n operationRegistry: context.operations,\n };\n\n this.core = createRuntimeCore(coreOptions);\n\n if (verify.mode === 'startup') {\n validateCodecRegistryCompleteness(this.codecRegistry, context.contract);\n this.codecRegistryValidated = true;\n }\n }\n\n private ensureCodecRegistryValidated(contract: SqlContract<SqlStorage>): void {\n if (!this.codecRegistryValidated) {\n validateCodecRegistryCompleteness(this.codecRegistry, contract);\n this.codecRegistryValidated = true;\n }\n }\n\n execute<Row = Record<string, unknown>>(\n plan: ExecutionPlan<Row> | SqlQueryPlan<Row>,\n ): AsyncIterable<Row> {\n this.ensureCodecRegistryValidated(this.contract);\n\n // Check if plan is SqlQueryPlan (has ast but no sql)\n const isSqlQueryPlan = (p: ExecutionPlan<Row> | SqlQueryPlan<Row>): p is SqlQueryPlan<Row> => {\n return 'ast' in p && !('sql' in p);\n };\n\n // Lower SqlQueryPlan to Plan if needed\n const executablePlan: ExecutionPlan<Row> = isSqlQueryPlan(plan)\n ? lowerSqlPlan(this.context, plan)\n : plan;\n\n const iterator = async function* (\n self: SqlRuntimeImpl<TContract>,\n ): AsyncGenerator<Row, void, unknown> {\n const encodedParams = encodeParams(executablePlan, self.codecRegistry);\n const planWithEncodedParams: ExecutionPlan<Row> = {\n ...executablePlan,\n params: encodedParams,\n };\n\n const coreIterator = self.core.execute(planWithEncodedParams);\n\n for await (const rawRow of coreIterator) {\n const decodedRow = decodeRow(\n rawRow as Record<string, unknown>,\n executablePlan,\n self.codecRegistry,\n );\n yield decodedRow as Row;\n }\n };\n\n return iterator(this);\n }\n\n telemetry(): RuntimeTelemetryEvent | null {\n return this.core.telemetry();\n }\n\n operations(): OperationRegistry {\n return this.core.operations();\n }\n\n close(): Promise<void> {\n return this.core.close();\n }\n}\n\nexport function createRuntime<TContract extends SqlContract<SqlStorage>>(\n options: RuntimeOptions<TContract>,\n): Runtime {\n return new SqlRuntimeImpl(options);\n}\n","import type { ExecutionPlan } from '@prisma-next/contract/types';\nimport type { Codec, CodecRegistry } from '@prisma-next/sql-relational-core/ast';\n\nfunction resolveRowCodec(\n alias: string,\n plan: ExecutionPlan,\n registry: CodecRegistry,\n): Codec | null {\n const planCodecId = plan.meta.annotations?.codecs?.[alias] as string | undefined;\n if (planCodecId) {\n const codec = registry.get(planCodecId);\n if (codec) {\n return codec;\n }\n }\n\n if (plan.meta.projectionTypes) {\n const typeId = plan.meta.projectionTypes[alias];\n if (typeId) {\n const codec = registry.get(typeId);\n if (codec) {\n return codec;\n }\n }\n }\n\n return null;\n}\n\nexport function decodeRow(\n row: Record<string, unknown>,\n plan: ExecutionPlan,\n registry: CodecRegistry,\n): Record<string, unknown> {\n const decoded: Record<string, unknown> = {};\n\n let aliases: readonly string[];\n const projection = plan.meta.projection;\n if (projection && !Array.isArray(projection)) {\n aliases = Object.keys(projection);\n } else if (projection && Array.isArray(projection)) {\n aliases = projection;\n } else {\n aliases = Object.keys(row);\n }\n\n for (const alias of aliases) {\n const wireValue = row[alias];\n\n const projection = plan.meta.projection;\n const projectionValue =\n projection && typeof projection === 'object' && !Array.isArray(projection)\n ? (projection as Record<string, string>)[alias]\n : undefined;\n\n if (typeof projectionValue === 'string' && projectionValue.startsWith('include:')) {\n if (wireValue === null || wireValue === undefined) {\n decoded[alias] = [];\n continue;\n }\n\n try {\n let parsed: unknown;\n if (typeof wireValue === 'string') {\n parsed = JSON.parse(wireValue);\n } else if (Array.isArray(wireValue)) {\n parsed = wireValue;\n } else {\n parsed = JSON.parse(String(wireValue));\n }\n\n if (!Array.isArray(parsed)) {\n throw new Error(`Expected array for include alias '${alias}', got ${typeof parsed}`);\n }\n\n decoded[alias] = parsed;\n } catch (error) {\n const decodeError = new Error(\n `Failed to parse JSON array for include alias '${alias}': ${error instanceof Error ? error.message : String(error)}`,\n ) as Error & {\n code: string;\n category: string;\n severity: string;\n details?: Record<string, unknown>;\n };\n decodeError.code = 'RUNTIME.DECODE_FAILED';\n decodeError.category = 'RUNTIME';\n decodeError.severity = 'error';\n decodeError.details = {\n alias,\n wirePreview:\n typeof wireValue === 'string' && wireValue.length > 100\n ? `${wireValue.substring(0, 100)}...`\n : String(wireValue).substring(0, 100),\n };\n throw decodeError;\n }\n continue;\n }\n\n if (wireValue === null || wireValue === undefined) {\n decoded[alias] = wireValue;\n continue;\n }\n\n const codec = resolveRowCodec(alias, plan, registry);\n\n if (!codec) {\n decoded[alias] = wireValue;\n continue;\n }\n\n try {\n decoded[alias] = codec.decode(wireValue);\n } catch (error) {\n const decodeError = new Error(\n `Failed to decode row alias '${alias}' with codec '${codec.id}': ${error instanceof Error ? error.message : String(error)}`,\n ) as Error & {\n code: string;\n category: string;\n severity: string;\n details?: Record<string, unknown>;\n };\n decodeError.code = 'RUNTIME.DECODE_FAILED';\n decodeError.category = 'RUNTIME';\n decodeError.severity = 'error';\n decodeError.details = {\n alias,\n codec: codec.id,\n wirePreview:\n typeof wireValue === 'string' && wireValue.length > 100\n ? `${wireValue.substring(0, 100)}...`\n : String(wireValue).substring(0, 100),\n };\n throw decodeError;\n }\n }\n\n return decoded;\n}\n","import type { ExecutionPlan, ParamDescriptor } from '@prisma-next/contract/types';\nimport type { Codec, CodecRegistry } from '@prisma-next/sql-relational-core/ast';\n\nfunction resolveParamCodec(\n paramDescriptor: ParamDescriptor,\n plan: ExecutionPlan,\n registry: CodecRegistry,\n): Codec | null {\n const paramName = paramDescriptor.name ?? `param_${paramDescriptor.index ?? 0}`;\n\n const planCodecId = plan.meta.annotations?.codecs?.[paramName] as string | undefined;\n if (planCodecId) {\n const codec = registry.get(planCodecId);\n if (codec) {\n return codec;\n }\n }\n\n if (paramDescriptor.type) {\n const codec = registry.get(paramDescriptor.type);\n if (codec) {\n return codec;\n }\n }\n\n return null;\n}\n\nexport function encodeParam(\n value: unknown,\n paramDescriptor: ParamDescriptor,\n plan: ExecutionPlan,\n registry: CodecRegistry,\n): unknown {\n if (value === null || value === undefined) {\n return null;\n }\n\n const codec = resolveParamCodec(paramDescriptor, plan, registry);\n if (!codec) {\n return value;\n }\n\n if (codec.encode) {\n try {\n return codec.encode(value);\n } catch (error) {\n throw new Error(\n `Failed to encode parameter ${paramDescriptor.name ?? paramDescriptor.index}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n return value;\n}\n\nexport function encodeParams(plan: ExecutionPlan, registry: CodecRegistry): readonly unknown[] {\n if (plan.params.length === 0) {\n return plan.params;\n }\n\n const encoded: unknown[] = [];\n\n for (let i = 0; i < plan.params.length; i++) {\n const paramValue = plan.params[i];\n const paramDescriptor = plan.meta.paramDescriptors[i];\n\n if (paramDescriptor) {\n encoded.push(encodeParam(paramValue, paramDescriptor, plan, registry));\n } else {\n encoded.push(paramValue);\n }\n }\n\n return Object.freeze(encoded);\n}\n","import type { ExecutionPlan } from '@prisma-next/contract/types';\nimport type {\n MarkerReader,\n MarkerStatement,\n RuntimeFamilyAdapter,\n} from '@prisma-next/runtime-executor';\nimport { runtimeError } from '@prisma-next/runtime-executor';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { readContractMarker } from './sql-marker';\n\nclass SqlMarkerReader implements MarkerReader {\n readMarkerStatement(): MarkerStatement {\n return readContractMarker();\n }\n}\n\nexport class SqlFamilyAdapter<TContract extends SqlContract<SqlStorage>>\n implements RuntimeFamilyAdapter<TContract>\n{\n readonly contract: TContract;\n readonly markerReader: MarkerReader;\n\n constructor(contract: TContract) {\n this.contract = contract;\n this.markerReader = new SqlMarkerReader();\n }\n\n validatePlan(plan: ExecutionPlan, contract: TContract): void {\n if (plan.meta.target !== contract.target) {\n throw runtimeError('PLAN.TARGET_MISMATCH', 'Plan target does not match runtime target', {\n planTarget: plan.meta.target,\n runtimeTarget: contract.target,\n });\n }\n\n if (plan.meta.coreHash !== contract.coreHash) {\n throw runtimeError('PLAN.HASH_MISMATCH', 'Plan core hash does not match runtime contract', {\n planCoreHash: plan.meta.coreHash,\n runtimeCoreHash: contract.coreHash,\n });\n }\n }\n}\n"],"mappings":";AAQA,SAAS,SAAS,aAAa;;;ACR/B,SAAS,oBAAoB;AAItB,SAAS,eAAe,UAAgD;AAC7E,QAAM,UAAU,oBAAI,IAAY;AAEhC,aAAW,SAAS,OAAO,OAAO,SAAS,QAAQ,MAAM,GAAG;AAC1D,eAAW,UAAU,OAAO,OAAO,MAAM,OAAO,GAAG;AACjD,U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AEJ,UAAM,WAAW,iBACf,MACoC;AACpC,YAAM,gBAAgB,aAAa,gBAAgB,KAAK,aAAa;AACrE,YAAM,wBAA4C;AAAA,QAChD,GAAG;AAAA,QACH,QAAQ;AAAA,MACV;AAEA,YAAM,eAAe,KAAK,KAAK,QAAQ,qBAAqB;AAE5D,uBAAiB,UAAU,cAAc;AACvC,cAAM,aAAa;AAAA,UACjB;AAAA,UACA;AAAA,UACA,KAAK;AAAA,QACP;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAEA,WAAO,SAAS,IAAI;AAAA,EACtB;AAAA,EAEA,YAA0C;AACxC,WAAO,KAAK,KAAK,UAAU;AAAA,EAC7B;AAAA,EAEA,aAAgC;AAC9B,WAAO,KAAK,KAAK,WAAW;AAAA,EAC9B;AAAA,EAEA,QAAuB;AACrB,WAAO,KAAK,KAAK,MAAM;AAAA,EACzB;AACF;AAEO,SAAS,cACd,SACS;AACT,SAAO,IAAI,eAAe,OAAO;AACnC;","names":["projection","runtimeError","runtimeError"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prisma-next/sql-runtime",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "SQL runtime implementation for Prisma Next",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@prisma-next/contract": "0.0.1",
|
|
9
|
+
"@prisma-next/operations": "0.0.1",
|
|
10
|
+
"@prisma-next/runtime-executor": "0.0.1",
|
|
11
|
+
"@prisma-next/sql-contract": "0.0.1",
|
|
12
|
+
"@prisma-next/sql-relational-core": "0.0.1"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@prisma/dev": "^0.1.1",
|
|
16
|
+
"@types/pg": "^8.11.10",
|
|
17
|
+
"pg": "^8.11.5",
|
|
18
|
+
"tsup": "^8.3.0",
|
|
19
|
+
"typescript": "^5.9.3",
|
|
20
|
+
"vitest": "^2.1.1",
|
|
21
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
22
|
+
"@prisma-next/driver-postgres": "0.0.1"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./test/utils": {
|
|
33
|
+
"types": "./test/utils.ts",
|
|
34
|
+
"import": "./test/utils.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup --config tsup.config.ts",
|
|
39
|
+
"test": "vitest run --passWithNoTests",
|
|
40
|
+
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
41
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
42
|
+
"lint": "biome check . --config-path ../../../biome.json --error-on-warnings",
|
|
43
|
+
"clean": "node ../../../scripts/clean.mjs"
|
|
44
|
+
}
|
|
45
|
+
}
|