@prisma-next/sql-runtime 0.3.0-pr.93.5 → 0.3.0-pr.94.2

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 (142) hide show
  1. package/dist/exports-BI-iW86w.mjs +402 -0
  2. package/dist/exports-BI-iW86w.mjs.map +1 -0
  3. package/dist/index-Bycr1UG5.d.mts +130 -0
  4. package/dist/index-Bycr1UG5.d.mts.map +1 -0
  5. package/dist/index.d.mts +2 -0
  6. package/dist/index.mjs +3 -0
  7. package/dist/test/utils.d.mts +63 -0
  8. package/dist/test/utils.d.mts.map +1 -0
  9. package/dist/test/utils.mjs +184 -0
  10. package/dist/test/utils.mjs.map +1 -0
  11. package/package.json +22 -20
  12. package/dist/accelerate-EEKAFGN3-P6A6XJWJ.js +0 -137863
  13. package/dist/accelerate-EEKAFGN3-P6A6XJWJ.js.map +0 -1
  14. package/dist/amcheck-24VY6X5V.js +0 -13
  15. package/dist/amcheck-24VY6X5V.js.map +0 -1
  16. package/dist/bloom-VS74NLHT.js +0 -13
  17. package/dist/bloom-VS74NLHT.js.map +0 -1
  18. package/dist/btree_gin-WBC4EAAI.js +0 -13
  19. package/dist/btree_gin-WBC4EAAI.js.map +0 -1
  20. package/dist/btree_gist-UNC6QD3M.js +0 -13
  21. package/dist/btree_gist-UNC6QD3M.js.map +0 -1
  22. package/dist/chunk-3KTOEDFX.js +0 -49
  23. package/dist/chunk-3KTOEDFX.js.map +0 -1
  24. package/dist/chunk-47DZBRQC.js +0 -1280
  25. package/dist/chunk-47DZBRQC.js.map +0 -1
  26. package/dist/chunk-52N6AFZM.js +0 -133
  27. package/dist/chunk-52N6AFZM.js.map +0 -1
  28. package/dist/chunk-7D4SUZUM.js +0 -38
  29. package/dist/chunk-7D4SUZUM.js.map +0 -1
  30. package/dist/chunk-C6I3V3DM.js +0 -455
  31. package/dist/chunk-C6I3V3DM.js.map +0 -1
  32. package/dist/chunk-ECWIHLAT.js +0 -37
  33. package/dist/chunk-ECWIHLAT.js.map +0 -1
  34. package/dist/chunk-EI626SDC.js +0 -105
  35. package/dist/chunk-EI626SDC.js.map +0 -1
  36. package/dist/chunk-UKKOYUGL.js +0 -578
  37. package/dist/chunk-UKKOYUGL.js.map +0 -1
  38. package/dist/chunk-XPLNMXQV.js +0 -1537
  39. package/dist/chunk-XPLNMXQV.js.map +0 -1
  40. package/dist/citext-T7MXGUY7.js +0 -13
  41. package/dist/citext-T7MXGUY7.js.map +0 -1
  42. package/dist/client-5FENX6AW.js +0 -299
  43. package/dist/client-5FENX6AW.js.map +0 -1
  44. package/dist/codecs/decoding.d.ts +0 -4
  45. package/dist/codecs/decoding.d.ts.map +0 -1
  46. package/dist/codecs/encoding.d.ts +0 -5
  47. package/dist/codecs/encoding.d.ts.map +0 -1
  48. package/dist/codecs/validation.d.ts +0 -6
  49. package/dist/codecs/validation.d.ts.map +0 -1
  50. package/dist/cube-TFDQBZCI.js +0 -13
  51. package/dist/cube-TFDQBZCI.js.map +0 -1
  52. package/dist/dict_int-AEUOPGWP.js +0 -13
  53. package/dist/dict_int-AEUOPGWP.js.map +0 -1
  54. package/dist/dict_xsyn-DAAYX3FL.js +0 -13
  55. package/dist/dict_xsyn-DAAYX3FL.js.map +0 -1
  56. package/dist/dist-AQ3LWXOX.js +0 -570
  57. package/dist/dist-AQ3LWXOX.js.map +0 -1
  58. package/dist/dist-LBVX6BJW.js +0 -189
  59. package/dist/dist-LBVX6BJW.js.map +0 -1
  60. package/dist/dist-WLKUVDN2.js +0 -5127
  61. package/dist/dist-WLKUVDN2.js.map +0 -1
  62. package/dist/earthdistance-KIGTF4LE.js +0 -13
  63. package/dist/earthdistance-KIGTF4LE.js.map +0 -1
  64. package/dist/exports/index.d.ts +0 -11
  65. package/dist/exports/index.d.ts.map +0 -1
  66. package/dist/file_fdw-5N55UP6I.js +0 -13
  67. package/dist/file_fdw-5N55UP6I.js.map +0 -1
  68. package/dist/fuzzystrmatch-KN3YWBFP.js +0 -13
  69. package/dist/fuzzystrmatch-KN3YWBFP.js.map +0 -1
  70. package/dist/hstore-YX726NKN.js +0 -13
  71. package/dist/hstore-YX726NKN.js.map +0 -1
  72. package/dist/http-exception-FZY2H4OF.js +0 -8
  73. package/dist/http-exception-FZY2H4OF.js.map +0 -1
  74. package/dist/index.d.ts +0 -2
  75. package/dist/index.d.ts.map +0 -1
  76. package/dist/index.js +0 -30
  77. package/dist/index.js.map +0 -1
  78. package/dist/intarray-NKVXNO2D.js +0 -13
  79. package/dist/intarray-NKVXNO2D.js.map +0 -1
  80. package/dist/isn-FTEMJGEV.js +0 -13
  81. package/dist/isn-FTEMJGEV.js.map +0 -1
  82. package/dist/lo-DB7L4NGI.js +0 -13
  83. package/dist/lo-DB7L4NGI.js.map +0 -1
  84. package/dist/logger-WQ7SHNDD.js +0 -68
  85. package/dist/logger-WQ7SHNDD.js.map +0 -1
  86. package/dist/lower-sql-plan.d.ts +0 -15
  87. package/dist/lower-sql-plan.d.ts.map +0 -1
  88. package/dist/ltree-Z32TZT6W.js +0 -13
  89. package/dist/ltree-Z32TZT6W.js.map +0 -1
  90. package/dist/nodefs-NM46ACH7.js +0 -31
  91. package/dist/nodefs-NM46ACH7.js.map +0 -1
  92. package/dist/opfs-ahp-NJO33LVZ.js +0 -332
  93. package/dist/opfs-ahp-NJO33LVZ.js.map +0 -1
  94. package/dist/pageinspect-YP3IZR4X.js +0 -13
  95. package/dist/pageinspect-YP3IZR4X.js.map +0 -1
  96. package/dist/pg_buffercache-7TD5J2FB.js +0 -13
  97. package/dist/pg_buffercache-7TD5J2FB.js.map +0 -1
  98. package/dist/pg_dump-SG4KYBUB.js +0 -2492
  99. package/dist/pg_dump-SG4KYBUB.js.map +0 -1
  100. package/dist/pg_freespacemap-DZDNCPZK.js +0 -13
  101. package/dist/pg_freespacemap-DZDNCPZK.js.map +0 -1
  102. package/dist/pg_surgery-J2MUEWEP.js +0 -13
  103. package/dist/pg_surgery-J2MUEWEP.js.map +0 -1
  104. package/dist/pg_trgm-7VNQOYS6.js +0 -13
  105. package/dist/pg_trgm-7VNQOYS6.js.map +0 -1
  106. package/dist/pg_visibility-TTSIPHFL.js +0 -13
  107. package/dist/pg_visibility-TTSIPHFL.js.map +0 -1
  108. package/dist/pg_walinspect-KPFHSHRJ.js +0 -13
  109. package/dist/pg_walinspect-KPFHSHRJ.js.map +0 -1
  110. package/dist/proxy-signals-GUDAMDHV.js +0 -39
  111. package/dist/proxy-signals-GUDAMDHV.js.map +0 -1
  112. package/dist/seg-IYVDLE4O.js +0 -13
  113. package/dist/seg-IYVDLE4O.js.map +0 -1
  114. package/dist/sql-context.d.ts +0 -65
  115. package/dist/sql-context.d.ts.map +0 -1
  116. package/dist/sql-family-adapter.d.ts +0 -10
  117. package/dist/sql-family-adapter.d.ts.map +0 -1
  118. package/dist/sql-marker.d.ts +0 -22
  119. package/dist/sql-marker.d.ts.map +0 -1
  120. package/dist/sql-runtime.d.ts +0 -25
  121. package/dist/sql-runtime.d.ts.map +0 -1
  122. package/dist/tablefunc-EF4RCS7S.js +0 -13
  123. package/dist/tablefunc-EF4RCS7S.js.map +0 -1
  124. package/dist/tcn-3VT5BQYW.js +0 -13
  125. package/dist/tcn-3VT5BQYW.js.map +0 -1
  126. package/dist/test/utils.js +0 -24635
  127. package/dist/test/utils.js.map +0 -1
  128. package/dist/tiny-CW6F4GX6.js +0 -10
  129. package/dist/tiny-CW6F4GX6.js.map +0 -1
  130. package/dist/tsm_system_rows-ES7KNUQH.js +0 -13
  131. package/dist/tsm_system_rows-ES7KNUQH.js.map +0 -1
  132. package/dist/tsm_system_time-76WEIMBG.js +0 -13
  133. package/dist/tsm_system_time-76WEIMBG.js.map +0 -1
  134. package/dist/unaccent-7RYF3R64.js +0 -13
  135. package/dist/unaccent-7RYF3R64.js.map +0 -1
  136. package/dist/utility-Q5A254LJ-J4HTKZPT.js +0 -347
  137. package/dist/utility-Q5A254LJ-J4HTKZPT.js.map +0 -1
  138. package/dist/uuid_ossp-4ETE4FPE.js +0 -13
  139. package/dist/uuid_ossp-4ETE4FPE.js.map +0 -1
  140. package/dist/vector-74GPNV7V.js +0 -13
  141. package/dist/vector-74GPNV7V.js.map +0 -1
  142. package/test/tsconfig.json +0 -4
@@ -0,0 +1,402 @@
1
+ import { AsyncIterableResult, budgets, createRuntimeCore, lints, runtimeError } from "@prisma-next/runtime-executor";
2
+ import { createOperationRegistry } from "@prisma-next/operations";
3
+ import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
4
+
5
+ //#region src/codecs/validation.ts
6
+ function extractCodecIds(contract) {
7
+ const codecIds = /* @__PURE__ */ new Set();
8
+ for (const table of Object.values(contract.storage.tables)) for (const column of Object.values(table.columns)) {
9
+ const codecId = column.codecId;
10
+ codecIds.add(codecId);
11
+ }
12
+ return codecIds;
13
+ }
14
+ function extractCodecIdsFromColumns(contract) {
15
+ const codecIds = /* @__PURE__ */ new Map();
16
+ for (const [tableName, table] of Object.entries(contract.storage.tables)) for (const [columnName, column] of Object.entries(table.columns)) {
17
+ const codecId = column.codecId;
18
+ const key = `${tableName}.${columnName}`;
19
+ codecIds.set(key, codecId);
20
+ }
21
+ return codecIds;
22
+ }
23
+ function validateContractCodecMappings(registry, contract) {
24
+ const codecIds = extractCodecIdsFromColumns(contract);
25
+ const invalidCodecs = [];
26
+ for (const [key, codecId] of codecIds.entries()) if (!registry.has(codecId)) {
27
+ const parts = key.split(".");
28
+ const table = parts[0] ?? "";
29
+ const column = parts[1] ?? "";
30
+ invalidCodecs.push({
31
+ table,
32
+ column,
33
+ codecId
34
+ });
35
+ }
36
+ if (invalidCodecs.length > 0) {
37
+ const details = {
38
+ contractTarget: contract.target,
39
+ invalidCodecs
40
+ };
41
+ throw runtimeError("RUNTIME.CODEC_MISSING", `Missing codec implementations for column codecIds: ${invalidCodecs.map((c) => `${c.table}.${c.column} (${c.codecId})`).join(", ")}`, details);
42
+ }
43
+ }
44
+ function validateCodecRegistryCompleteness(registry, contract) {
45
+ validateContractCodecMappings(registry, contract);
46
+ }
47
+
48
+ //#endregion
49
+ //#region src/lower-sql-plan.ts
50
+ /**
51
+ * Lowers a SQL query plan to an executable Plan by calling the adapter's lower method.
52
+ *
53
+ * This function is responsible for converting a lane-produced SqlQueryPlan (which contains
54
+ * AST and params but no SQL) into a fully executable Plan (which includes SQL string).
55
+ *
56
+ * @param context - Runtime context containing the adapter
57
+ * @param queryPlan - SQL query plan from a lane (contains AST, params, meta, but no SQL)
58
+ * @returns Fully executable Plan with SQL string
59
+ */
60
+ function lowerSqlPlan(context, queryPlan) {
61
+ const body = context.adapter.lower(queryPlan.ast, {
62
+ contract: context.contract,
63
+ params: queryPlan.params
64
+ }).body;
65
+ return Object.freeze({
66
+ sql: body.sql,
67
+ params: body.params ?? queryPlan.params,
68
+ ast: queryPlan.ast,
69
+ meta: queryPlan.meta
70
+ });
71
+ }
72
+
73
+ //#endregion
74
+ //#region src/sql-context.ts
75
+ /**
76
+ * Creates a SQL runtime context from descriptor-first composition.
77
+ *
78
+ * The context includes:
79
+ * - The validated contract
80
+ * - The adapter instance (created from descriptor)
81
+ * - Codec registry (populated from adapter + extension instances)
82
+ * - Operation registry (populated from extension instances)
83
+ *
84
+ * @param options - Descriptor-first composition options
85
+ * @returns RuntimeContext with registries wired from all components
86
+ */
87
+ function createRuntimeContext(options) {
88
+ const { contract, adapter: adapterDescriptor, extensionPacks } = options;
89
+ const adapterInstance = adapterDescriptor.create();
90
+ const codecRegistry = createCodecRegistry();
91
+ const operationRegistry = createOperationRegistry();
92
+ const adapterCodecs = adapterInstance.profile.codecs();
93
+ for (const codec$1 of adapterCodecs.values()) codecRegistry.register(codec$1);
94
+ for (const extDescriptor of extensionPacks ?? []) {
95
+ const extInstance = extDescriptor.create();
96
+ const extCodecs = extInstance.codecs?.();
97
+ if (extCodecs) for (const codec$1 of extCodecs.values()) codecRegistry.register(codec$1);
98
+ const extOperations = extInstance.operations?.();
99
+ if (extOperations) for (const operation of extOperations) operationRegistry.register(operation);
100
+ }
101
+ return {
102
+ contract,
103
+ adapter: adapterInstance,
104
+ operations: operationRegistry,
105
+ codecs: codecRegistry
106
+ };
107
+ }
108
+
109
+ //#endregion
110
+ //#region src/sql-marker.ts
111
+ const ensureSchemaStatement = {
112
+ sql: "create schema if not exists prisma_contract",
113
+ params: []
114
+ };
115
+ const ensureTableStatement = {
116
+ sql: `create table if not exists prisma_contract.marker (
117
+ id smallint primary key default 1,
118
+ core_hash text not null,
119
+ profile_hash text not null,
120
+ contract_json jsonb,
121
+ canonical_version int,
122
+ updated_at timestamptz not null default now(),
123
+ app_tag text,
124
+ meta jsonb not null default '{}'
125
+ )`,
126
+ params: []
127
+ };
128
+ function readContractMarker() {
129
+ return {
130
+ sql: `select
131
+ core_hash,
132
+ profile_hash,
133
+ contract_json,
134
+ canonical_version,
135
+ updated_at,
136
+ app_tag,
137
+ meta
138
+ from prisma_contract.marker
139
+ where id = $1`,
140
+ params: [1]
141
+ };
142
+ }
143
+ function writeContractMarker(input) {
144
+ const baseParams = [
145
+ 1,
146
+ input.coreHash,
147
+ input.profileHash,
148
+ input.contractJson ?? null,
149
+ input.canonicalVersion ?? null,
150
+ input.appTag ?? null,
151
+ JSON.stringify(input.meta ?? {})
152
+ ];
153
+ return {
154
+ insert: {
155
+ sql: `insert into prisma_contract.marker (
156
+ id,
157
+ core_hash,
158
+ profile_hash,
159
+ contract_json,
160
+ canonical_version,
161
+ updated_at,
162
+ app_tag,
163
+ meta
164
+ ) values (
165
+ $1,
166
+ $2,
167
+ $3,
168
+ $4::jsonb,
169
+ $5,
170
+ now(),
171
+ $6,
172
+ $7::jsonb
173
+ )`,
174
+ params: baseParams
175
+ },
176
+ update: {
177
+ sql: `update prisma_contract.marker set
178
+ core_hash = $2,
179
+ profile_hash = $3,
180
+ contract_json = $4::jsonb,
181
+ canonical_version = $5,
182
+ updated_at = now(),
183
+ app_tag = $6,
184
+ meta = $7::jsonb
185
+ where id = $1`,
186
+ params: baseParams
187
+ }
188
+ };
189
+ }
190
+
191
+ //#endregion
192
+ //#region src/codecs/decoding.ts
193
+ function resolveRowCodec(alias, plan, registry) {
194
+ const planCodecId = plan.meta.annotations?.codecs?.[alias];
195
+ if (planCodecId) {
196
+ const codec$1 = registry.get(planCodecId);
197
+ if (codec$1) return codec$1;
198
+ }
199
+ if (plan.meta.projectionTypes) {
200
+ const typeId = plan.meta.projectionTypes[alias];
201
+ if (typeId) {
202
+ const codec$1 = registry.get(typeId);
203
+ if (codec$1) return codec$1;
204
+ }
205
+ }
206
+ return null;
207
+ }
208
+ function decodeRow(row, plan, registry) {
209
+ const decoded = {};
210
+ let aliases;
211
+ const projection = plan.meta.projection;
212
+ if (projection && !Array.isArray(projection)) aliases = Object.keys(projection);
213
+ else if (projection && Array.isArray(projection)) aliases = projection;
214
+ else aliases = Object.keys(row);
215
+ for (const alias of aliases) {
216
+ const wireValue = row[alias];
217
+ const projection$1 = plan.meta.projection;
218
+ const projectionValue = projection$1 && typeof projection$1 === "object" && !Array.isArray(projection$1) ? projection$1[alias] : void 0;
219
+ if (typeof projectionValue === "string" && projectionValue.startsWith("include:")) {
220
+ if (wireValue === null || wireValue === void 0) {
221
+ decoded[alias] = [];
222
+ continue;
223
+ }
224
+ try {
225
+ let parsed;
226
+ if (typeof wireValue === "string") parsed = JSON.parse(wireValue);
227
+ else if (Array.isArray(wireValue)) parsed = wireValue;
228
+ else parsed = JSON.parse(String(wireValue));
229
+ if (!Array.isArray(parsed)) throw new Error(`Expected array for include alias '${alias}', got ${typeof parsed}`);
230
+ decoded[alias] = parsed;
231
+ } catch (error) {
232
+ const decodeError = /* @__PURE__ */ new Error(`Failed to parse JSON array for include alias '${alias}': ${error instanceof Error ? error.message : String(error)}`);
233
+ decodeError.code = "RUNTIME.DECODE_FAILED";
234
+ decodeError.category = "RUNTIME";
235
+ decodeError.severity = "error";
236
+ decodeError.details = {
237
+ alias,
238
+ wirePreview: typeof wireValue === "string" && wireValue.length > 100 ? `${wireValue.substring(0, 100)}...` : String(wireValue).substring(0, 100)
239
+ };
240
+ throw decodeError;
241
+ }
242
+ continue;
243
+ }
244
+ if (wireValue === null || wireValue === void 0) {
245
+ decoded[alias] = wireValue;
246
+ continue;
247
+ }
248
+ const codec$1 = resolveRowCodec(alias, plan, registry);
249
+ if (!codec$1) {
250
+ decoded[alias] = wireValue;
251
+ continue;
252
+ }
253
+ try {
254
+ decoded[alias] = codec$1.decode(wireValue);
255
+ } catch (error) {
256
+ const decodeError = /* @__PURE__ */ new Error(`Failed to decode row alias '${alias}' with codec '${codec$1.id}': ${error instanceof Error ? error.message : String(error)}`);
257
+ decodeError.code = "RUNTIME.DECODE_FAILED";
258
+ decodeError.category = "RUNTIME";
259
+ decodeError.severity = "error";
260
+ decodeError.details = {
261
+ alias,
262
+ codec: codec$1.id,
263
+ wirePreview: typeof wireValue === "string" && wireValue.length > 100 ? `${wireValue.substring(0, 100)}...` : String(wireValue).substring(0, 100)
264
+ };
265
+ throw decodeError;
266
+ }
267
+ }
268
+ return decoded;
269
+ }
270
+
271
+ //#endregion
272
+ //#region src/codecs/encoding.ts
273
+ function resolveParamCodec(paramDescriptor, plan, registry) {
274
+ const paramName = paramDescriptor.name ?? `param_${paramDescriptor.index ?? 0}`;
275
+ const planCodecId = plan.meta.annotations?.codecs?.[paramName];
276
+ if (planCodecId) {
277
+ const codec$1 = registry.get(planCodecId);
278
+ if (codec$1) return codec$1;
279
+ }
280
+ if (paramDescriptor.codecId) {
281
+ const codec$1 = registry.get(paramDescriptor.codecId);
282
+ if (codec$1) return codec$1;
283
+ }
284
+ return null;
285
+ }
286
+ function encodeParam(value, paramDescriptor, plan, registry) {
287
+ if (value === null || value === void 0) return null;
288
+ const codec$1 = resolveParamCodec(paramDescriptor, plan, registry);
289
+ if (!codec$1) return value;
290
+ if (codec$1.encode) try {
291
+ return codec$1.encode(value);
292
+ } catch (error) {
293
+ throw new Error(`Failed to encode parameter ${paramDescriptor.name ?? paramDescriptor.index}: ${error instanceof Error ? error.message : String(error)}`);
294
+ }
295
+ return value;
296
+ }
297
+ function encodeParams(plan, registry) {
298
+ if (plan.params.length === 0) return plan.params;
299
+ const encoded = [];
300
+ for (let i = 0; i < plan.params.length; i++) {
301
+ const paramValue = plan.params[i];
302
+ const paramDescriptor = plan.meta.paramDescriptors[i];
303
+ if (paramDescriptor) encoded.push(encodeParam(paramValue, paramDescriptor, plan, registry));
304
+ else encoded.push(paramValue);
305
+ }
306
+ return Object.freeze(encoded);
307
+ }
308
+
309
+ //#endregion
310
+ //#region src/sql-family-adapter.ts
311
+ var SqlMarkerReader = class {
312
+ readMarkerStatement() {
313
+ return readContractMarker();
314
+ }
315
+ };
316
+ var SqlFamilyAdapter = class {
317
+ contract;
318
+ markerReader;
319
+ constructor(contract) {
320
+ this.contract = contract;
321
+ this.markerReader = new SqlMarkerReader();
322
+ }
323
+ validatePlan(plan, contract) {
324
+ if (plan.meta.target !== contract.target) throw runtimeError("PLAN.TARGET_MISMATCH", "Plan target does not match runtime target", {
325
+ planTarget: plan.meta.target,
326
+ runtimeTarget: contract.target
327
+ });
328
+ if (plan.meta.coreHash !== contract.coreHash) throw runtimeError("PLAN.HASH_MISMATCH", "Plan core hash does not match runtime contract", {
329
+ planCoreHash: plan.meta.coreHash,
330
+ runtimeCoreHash: contract.coreHash
331
+ });
332
+ }
333
+ };
334
+
335
+ //#endregion
336
+ //#region src/sql-runtime.ts
337
+ var SqlRuntimeImpl = class {
338
+ core;
339
+ contract;
340
+ context;
341
+ codecRegistry;
342
+ codecRegistryValidated;
343
+ constructor(options) {
344
+ const { context, driver, verify, plugins, mode, log } = options;
345
+ this.contract = context.contract;
346
+ this.context = context;
347
+ this.codecRegistry = context.codecs;
348
+ this.codecRegistryValidated = false;
349
+ this.core = createRuntimeCore({
350
+ familyAdapter: new SqlFamilyAdapter(context.contract),
351
+ driver,
352
+ verify,
353
+ plugins,
354
+ ...mode !== void 0 ? { mode } : {},
355
+ ...log !== void 0 ? { log } : {},
356
+ operationRegistry: context.operations
357
+ });
358
+ if (verify.mode === "startup") {
359
+ validateCodecRegistryCompleteness(this.codecRegistry, context.contract);
360
+ this.codecRegistryValidated = true;
361
+ }
362
+ }
363
+ ensureCodecRegistryValidated(contract) {
364
+ if (!this.codecRegistryValidated) {
365
+ validateCodecRegistryCompleteness(this.codecRegistry, contract);
366
+ this.codecRegistryValidated = true;
367
+ }
368
+ }
369
+ execute(plan) {
370
+ this.ensureCodecRegistryValidated(this.contract);
371
+ const isSqlQueryPlan = (p) => {
372
+ return "ast" in p && !("sql" in p);
373
+ };
374
+ const executablePlan = isSqlQueryPlan(plan) ? lowerSqlPlan(this.context, plan) : plan;
375
+ const iterator = async function* (self) {
376
+ const encodedParams = encodeParams(executablePlan, self.codecRegistry);
377
+ const planWithEncodedParams = {
378
+ ...executablePlan,
379
+ params: encodedParams
380
+ };
381
+ const coreIterator = self.core.execute(planWithEncodedParams);
382
+ for await (const rawRow of coreIterator) yield decodeRow(rawRow, executablePlan, self.codecRegistry);
383
+ };
384
+ return new AsyncIterableResult(iterator(this));
385
+ }
386
+ telemetry() {
387
+ return this.core.telemetry();
388
+ }
389
+ operations() {
390
+ return this.core.operations();
391
+ }
392
+ close() {
393
+ return this.core.close();
394
+ }
395
+ };
396
+ function createRuntime(options) {
397
+ return new SqlRuntimeImpl(options);
398
+ }
399
+
400
+ //#endregion
401
+ export { ensureTableStatement as a, createRuntimeContext as c, validateCodecRegistryCompleteness as d, validateContractCodecMappings as f, ensureSchemaStatement as i, lowerSqlPlan as l, lints as n, readContractMarker as o, createRuntime as r, writeContractMarker as s, budgets as t, extractCodecIds as u };
402
+ //# sourceMappingURL=exports-BI-iW86w.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-BI-iW86w.mjs","names":["invalidCodecs: Array<{ table: string; column: string; codecId: string }>","details: Record<string, unknown>","codec","ensureSchemaStatement: SqlStatement","ensureTableStatement: SqlStatement","baseParams: readonly unknown[]","codec","decoded: Record<string, unknown>","aliases: readonly string[]","projection","parsed: unknown","codec","encoded: unknown[]","executablePlan: ExecutionPlan<Row>","planWithEncodedParams: ExecutionPlan<Row>"],"sources":["../src/codecs/validation.ts","../src/lower-sql-plan.ts","../src/sql-context.ts","../src/sql-marker.ts","../src/codecs/decoding.ts","../src/codecs/encoding.ts","../src/sql-family-adapter.ts","../src/sql-runtime.ts"],"sourcesContent":["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 extractCodecIds(contract: SqlContract<SqlStorage>): Set<string> {\n const codecIds = new Set<string>();\n\n for (const table of Object.values(contract.storage.tables)) {\n for (const column of Object.values(table.columns)) {\n const codecId = column.codecId;\n codecIds.add(codecId);\n }\n }\n\n return codecIds;\n}\n\nfunction extractCodecIdsFromColumns(contract: SqlContract<SqlStorage>): Map<string, string> {\n const codecIds = 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 const codecId = column.codecId;\n const key = `${tableName}.${columnName}`;\n codecIds.set(key, codecId);\n }\n }\n\n return codecIds;\n}\n\nexport function validateContractCodecMappings(\n registry: CodecRegistry,\n contract: SqlContract<SqlStorage>,\n): void {\n const codecIds = extractCodecIdsFromColumns(contract);\n const invalidCodecs: Array<{ table: string; column: string; codecId: string }> = [];\n\n for (const [key, codecId] of codecIds.entries()) {\n if (!registry.has(codecId)) {\n const parts = key.split('.');\n const table = parts[0] ?? '';\n const column = parts[1] ?? '';\n invalidCodecs.push({ table, column, codecId });\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 codecIds: ${invalidCodecs.map((c) => `${c.table}.${c.column} (${c.codecId})`).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 type {\n RuntimeAdapterDescriptor,\n RuntimeAdapterInstance,\n RuntimeExtensionDescriptor,\n RuntimeExtensionInstance,\n RuntimeTargetDescriptor,\n} from '@prisma-next/core-execution-plane/types';\nimport { 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\n// ============================================================================\n// SQL Runtime Extension Types\n// ============================================================================\n\n/**\n * SQL runtime extension instance.\n * Extends the framework RuntimeExtensionInstance with SQL-specific hooks\n * for contributing codecs and operations to the runtime context.\n *\n * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')\n */\nexport interface SqlRuntimeExtensionInstance<TTargetId extends string>\n extends RuntimeExtensionInstance<'sql', TTargetId> {\n /** Returns codecs to register in the runtime context. */\n codecs?(): CodecRegistry;\n /** Returns operations to register in the runtime context. */\n operations?(): ReadonlyArray<SqlOperationSignature>;\n}\n\n/**\n * SQL runtime extension descriptor.\n * Extends the framework RuntimeExtensionDescriptor with SQL-specific instance type.\n *\n * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')\n */\nexport interface SqlRuntimeExtensionDescriptor<TTargetId extends string>\n extends RuntimeExtensionDescriptor<'sql', TTargetId, SqlRuntimeExtensionInstance<TTargetId>> {\n create(): SqlRuntimeExtensionInstance<TTargetId>;\n}\n\n// ============================================================================\n// SQL Runtime Adapter Instance\n// ============================================================================\n\n/**\n * SQL runtime adapter instance interface.\n * Combines RuntimeAdapterInstance identity with SQL Adapter behavior.\n * The instance IS an Adapter (via intersection), not HAS an adapter property.\n *\n * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')\n */\nexport type SqlRuntimeAdapterInstance<TTargetId extends string = string> = RuntimeAdapterInstance<\n 'sql',\n TTargetId\n> &\n Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;\n\n// ============================================================================\n// SQL Runtime Context\n// ============================================================================\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\n/**\n * Descriptor-first options for creating a SQL runtime context.\n * Takes the same framework composition as control-plane: target, adapter, extensionPacks.\n *\n * @template TContract - The SQL contract type\n * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')\n */\nexport interface CreateRuntimeContextOptions<\n TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n TTargetId extends string = string,\n> {\n readonly contract: TContract;\n readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;\n readonly adapter: RuntimeAdapterDescriptor<\n 'sql',\n TTargetId,\n SqlRuntimeAdapterInstance<TTargetId>\n >;\n readonly extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<TTargetId>>;\n}\n\n/**\n * Creates a SQL runtime context from descriptor-first composition.\n *\n * The context includes:\n * - The validated contract\n * - The adapter instance (created from descriptor)\n * - Codec registry (populated from adapter + extension instances)\n * - Operation registry (populated from extension instances)\n *\n * @param options - Descriptor-first composition options\n * @returns RuntimeContext with registries wired from all components\n */\nexport function createRuntimeContext<\n TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n TTargetId extends string = string,\n>(options: CreateRuntimeContextOptions<TContract, TTargetId>): RuntimeContext<TContract> {\n const { contract, adapter: adapterDescriptor, extensionPacks } = options;\n\n // Create adapter instance from descriptor\n // The adapter instance IS an Adapter (via intersection)\n const adapterInstance = adapterDescriptor.create();\n\n // Create registries\n const codecRegistry = createCodecRegistry();\n const operationRegistry = createOperationRegistry();\n\n // Register adapter codecs (adapter instance has profile.codecs())\n const adapterCodecs = adapterInstance.profile.codecs();\n for (const codec of adapterCodecs.values()) {\n codecRegistry.register(codec);\n }\n\n // Create extension instances and register their codecs/operations\n for (const extDescriptor of extensionPacks ?? []) {\n const extInstance = extDescriptor.create();\n\n const extCodecs = extInstance.codecs?.();\n if (extCodecs) {\n for (const codec of extCodecs.values()) {\n codecRegistry.register(codec);\n }\n }\n\n const extOperations = extInstance.operations?.();\n if (extOperations) {\n for (const operation of extOperations) {\n operationRegistry.register(operation);\n }\n }\n }\n\n return {\n contract,\n adapter: adapterInstance,\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 { 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.codecId) {\n const codec = registry.get(paramDescriptor.codecId);\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","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 { AsyncIterableResult, 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 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 ): AsyncIterableResult<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 ): AsyncIterableResult<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 new AsyncIterableResult(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"],"mappings":";;;;;AAIA,SAAgB,gBAAgB,UAAgD;CAC9E,MAAM,2BAAW,IAAI,KAAa;AAElC,MAAK,MAAM,SAAS,OAAO,OAAO,SAAS,QAAQ,OAAO,CACxD,MAAK,MAAM,UAAU,OAAO,OAAO,MAAM,QAAQ,EAAE;EACjD,MAAM,UAAU,OAAO;AACvB,WAAS,IAAI,QAAQ;;AAIzB,QAAO;;AAGT,SAAS,2BAA2B,UAAwD;CAC1F,MAAM,2BAAW,IAAI,KAAqB;AAE1C,MAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,SAAS,QAAQ,OAAO,CACtE,MAAK,MAAM,CAAC,YAAY,WAAW,OAAO,QAAQ,MAAM,QAAQ,EAAE;EAChE,MAAM,UAAU,OAAO;EACvB,MAAM,MAAM,GAAG,UAAU,GAAG;AAC5B,WAAS,IAAI,KAAK,QAAQ;;AAI9B,QAAO;;AAGT,SAAgB,8BACd,UACA,UACM;CACN,MAAM,WAAW,2BAA2B,SAAS;CACrD,MAAMA,gBAA2E,EAAE;AAEnF,MAAK,MAAM,CAAC,KAAK,YAAY,SAAS,SAAS,CAC7C,KAAI,CAAC,SAAS,IAAI,QAAQ,EAAE;EAC1B,MAAM,QAAQ,IAAI,MAAM,IAAI;EAC5B,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,SAAS,MAAM,MAAM;AAC3B,gBAAc,KAAK;GAAE;GAAO;GAAQ;GAAS,CAAC;;AAIlD,KAAI,cAAc,SAAS,GAAG;EAC5B,MAAMC,UAAmC;GACvC,gBAAgB,SAAS;GACzB;GACD;AAED,QAAM,aACJ,yBACA,sDAAsD,cAAc,KAAK,MAAM,GAAG,E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f,MACoC;GACpC,MAAM,gBAAgB,aAAa,gBAAgB,KAAK,cAAc;GACtE,MAAMC,wBAA4C;IAChD,GAAG;IACH,QAAQ;IACT;GAED,MAAM,eAAe,KAAK,KAAK,QAAQ,sBAAsB;AAE7D,cAAW,MAAM,UAAU,aAMzB,OALmB,UACjB,QACA,gBACA,KAAK,cACN;;AAKL,SAAO,IAAI,oBAAoB,SAAS,KAAK,CAAC;;CAGhD,YAA0C;AACxC,SAAO,KAAK,KAAK,WAAW;;CAG9B,aAAgC;AAC9B,SAAO,KAAK,KAAK,YAAY;;CAG/B,QAAuB;AACrB,SAAO,KAAK,KAAK,OAAO;;;AAI5B,SAAgB,cACd,SACS;AACT,QAAO,IAAI,eAAe,QAAQ"}
@@ -0,0 +1,130 @@
1
+ import { AfterExecuteResult, AsyncIterableResult, BudgetsOptions, LintsOptions, Log, Log as Log$1, MarkerStatement, Plugin, Plugin as Plugin$1, PluginContext, RuntimeTelemetryEvent, RuntimeVerifyOptions, TelemetryOutcome, budgets, lints } from "@prisma-next/runtime-executor";
2
+ import { OperationRegistry } from "@prisma-next/operations";
3
+ import { Adapter, CodecRegistry, LoweredStatement, QueryAst, SelectAst, SqlDriver } from "@prisma-next/sql-relational-core/ast";
4
+ import { SqlContract, SqlStorage } from "@prisma-next/sql-contract/types";
5
+ import { ExecutionPlan } from "@prisma-next/contract/types";
6
+ import { SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
7
+ import { RuntimeAdapterDescriptor, RuntimeAdapterInstance, RuntimeExtensionDescriptor, RuntimeExtensionInstance, RuntimeTargetDescriptor } from "@prisma-next/core-execution-plane/types";
8
+ import { SqlOperationSignature } from "@prisma-next/sql-operations";
9
+ import { QueryLaneContext } from "@prisma-next/sql-relational-core/query-lane-context";
10
+
11
+ //#region src/codecs/validation.d.ts
12
+ declare function extractCodecIds(contract: SqlContract<SqlStorage>): Set<string>;
13
+ declare function validateContractCodecMappings(registry: CodecRegistry, contract: SqlContract<SqlStorage>): void;
14
+ declare function validateCodecRegistryCompleteness(registry: CodecRegistry, contract: SqlContract<SqlStorage>): void;
15
+ //#endregion
16
+ //#region src/sql-context.d.ts
17
+ /**
18
+ * SQL runtime extension instance.
19
+ * Extends the framework RuntimeExtensionInstance with SQL-specific hooks
20
+ * for contributing codecs and operations to the runtime context.
21
+ *
22
+ * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
23
+ */
24
+ interface SqlRuntimeExtensionInstance<TTargetId extends string> extends RuntimeExtensionInstance<'sql', TTargetId> {
25
+ /** Returns codecs to register in the runtime context. */
26
+ codecs?(): CodecRegistry;
27
+ /** Returns operations to register in the runtime context. */
28
+ operations?(): ReadonlyArray<SqlOperationSignature>;
29
+ }
30
+ /**
31
+ * SQL runtime extension descriptor.
32
+ * Extends the framework RuntimeExtensionDescriptor with SQL-specific instance type.
33
+ *
34
+ * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
35
+ */
36
+ interface SqlRuntimeExtensionDescriptor<TTargetId extends string> extends RuntimeExtensionDescriptor<'sql', TTargetId, SqlRuntimeExtensionInstance<TTargetId>> {
37
+ create(): SqlRuntimeExtensionInstance<TTargetId>;
38
+ }
39
+ /**
40
+ * SQL runtime adapter instance interface.
41
+ * Combines RuntimeAdapterInstance identity with SQL Adapter behavior.
42
+ * The instance IS an Adapter (via intersection), not HAS an adapter property.
43
+ *
44
+ * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
45
+ */
46
+ type SqlRuntimeAdapterInstance<TTargetId extends string = string> = RuntimeAdapterInstance<'sql', TTargetId> & Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
47
+ interface RuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> extends QueryLaneContext<TContract> {
48
+ readonly adapter: Adapter<QueryAst, TContract, LoweredStatement> | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
49
+ }
50
+ /**
51
+ * Descriptor-first options for creating a SQL runtime context.
52
+ * Takes the same framework composition as control-plane: target, adapter, extensionPacks.
53
+ *
54
+ * @template TContract - The SQL contract type
55
+ * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
56
+ */
57
+ interface CreateRuntimeContextOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>, TTargetId extends string = string> {
58
+ readonly contract: TContract;
59
+ readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;
60
+ readonly adapter: RuntimeAdapterDescriptor<'sql', TTargetId, SqlRuntimeAdapterInstance<TTargetId>>;
61
+ readonly extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<TTargetId>>;
62
+ }
63
+ /**
64
+ * Creates a SQL runtime context from descriptor-first composition.
65
+ *
66
+ * The context includes:
67
+ * - The validated contract
68
+ * - The adapter instance (created from descriptor)
69
+ * - Codec registry (populated from adapter + extension instances)
70
+ * - Operation registry (populated from extension instances)
71
+ *
72
+ * @param options - Descriptor-first composition options
73
+ * @returns RuntimeContext with registries wired from all components
74
+ */
75
+ declare function createRuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>, TTargetId extends string = string>(options: CreateRuntimeContextOptions<TContract, TTargetId>): RuntimeContext<TContract>;
76
+ //#endregion
77
+ //#region src/lower-sql-plan.d.ts
78
+ /**
79
+ * Lowers a SQL query plan to an executable Plan by calling the adapter's lower method.
80
+ *
81
+ * This function is responsible for converting a lane-produced SqlQueryPlan (which contains
82
+ * AST and params but no SQL) into a fully executable Plan (which includes SQL string).
83
+ *
84
+ * @param context - Runtime context containing the adapter
85
+ * @param queryPlan - SQL query plan from a lane (contains AST, params, meta, but no SQL)
86
+ * @returns Fully executable Plan with SQL string
87
+ */
88
+ declare function lowerSqlPlan<Row>(context: RuntimeContext, queryPlan: SqlQueryPlan<Row>): ExecutionPlan<Row>;
89
+ //#endregion
90
+ //#region src/sql-marker.d.ts
91
+ interface SqlStatement {
92
+ readonly sql: string;
93
+ readonly params: readonly unknown[];
94
+ }
95
+ interface WriteMarkerInput {
96
+ readonly coreHash: string;
97
+ readonly profileHash: string;
98
+ readonly contractJson?: unknown;
99
+ readonly canonicalVersion?: number;
100
+ readonly appTag?: string;
101
+ readonly meta?: Record<string, unknown>;
102
+ }
103
+ declare const ensureSchemaStatement: SqlStatement;
104
+ declare const ensureTableStatement: SqlStatement;
105
+ declare function readContractMarker(): MarkerStatement;
106
+ interface WriteContractMarkerStatements {
107
+ readonly insert: SqlStatement;
108
+ readonly update: SqlStatement;
109
+ }
110
+ declare function writeContractMarker(input: WriteMarkerInput): WriteContractMarkerStatements;
111
+ //#endregion
112
+ //#region src/sql-runtime.d.ts
113
+ interface RuntimeOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> {
114
+ readonly driver: SqlDriver;
115
+ readonly verify: RuntimeVerifyOptions;
116
+ readonly context: RuntimeContext<TContract>;
117
+ readonly plugins?: readonly Plugin<TContract, Adapter<SelectAst, SqlContract<SqlStorage>, LoweredStatement>, SqlDriver>[];
118
+ readonly mode?: 'strict' | 'permissive';
119
+ readonly log?: Log;
120
+ }
121
+ interface Runtime {
122
+ execute<Row = Record<string, unknown>>(plan: ExecutionPlan<Row> | SqlQueryPlan<Row>): AsyncIterableResult<Row>;
123
+ telemetry(): RuntimeTelemetryEvent | null;
124
+ close(): Promise<void>;
125
+ operations(): OperationRegistry;
126
+ }
127
+ declare function createRuntime<TContract extends SqlContract<SqlStorage>>(options: RuntimeOptions<TContract>): Runtime;
128
+ //#endregion
129
+ export { SqlRuntimeAdapterInstance as C, extractCodecIds as D, createRuntimeContext as E, validateCodecRegistryCompleteness as O, RuntimeContext as S, SqlRuntimeExtensionInstance as T, ensureTableStatement as _, Plugin$1 as a, lowerSqlPlan as b, lints as c, RuntimeTelemetryEvent as d, RuntimeVerifyOptions as f, ensureSchemaStatement as g, SqlStatement as h, Log$1 as i, validateContractCodecMappings as k, Runtime as l, createRuntime as m, BudgetsOptions as n, PluginContext as o, TelemetryOutcome as p, LintsOptions as r, budgets as s, AfterExecuteResult as t, RuntimeOptions as u, readContractMarker as v, SqlRuntimeExtensionDescriptor as w, CreateRuntimeContextOptions as x, writeContractMarker as y };
130
+ //# sourceMappingURL=index-Bycr1UG5.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Bycr1UG5.d.mts","names":[],"sources":["../src/codecs/validation.ts","../src/sql-context.ts","../src/lower-sql-plan.ts","../src/sql-marker.ts","../src/sql-runtime.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;iBAIgB,eAAA,WAA0B,YAAY,cAAc;iBA2BpD,6BAAA,WACJ,yBACA,YAAY;iBA4BR,iCAAA,WACJ,yBACA,YAAY;;;;;;;;;AA3DxB;AAAsD,UC0BrC,2BD1BqC,CAAA,kBAAA,MAAA,CAAA,SC2B5C,wBD3B4C,CAAA,KAAA,EC2BZ,SD3BY,CAAA,CAAA;EAAZ;EAA0B,MAAA,GAAA,EC6BvD,aD7BuD;EAAG;EA2BvD,UAAA,GAAA,ECIC,aDJD,CCIe,qBDJc,CAAA;;;;;AA8B7C;;;AAEY,UCnBK,6BDmBL,CAAA,kBAAA,MAAA,CAAA,SClBF,0BDkBE,CAAA,KAAA,EClBgC,SDkBhC,EClB2C,2BDkB3C,CClBuE,SDkBvE,CAAA,CAAA,CAAA;EAAW,MAAA,EAAA,ECjBX,2BDiBW,CCjBiB,SDiBjB,CAAA;;;;ACjCvB;;;;;AACU,KA6BE,yBA7BF,CAAA,kBAAA,MAAA,GAAA,MAAA,CAAA,GA6BiE,sBA7BjE,CAAA,KAAA,EA+BR,SA/BQ,CAAA,GAiCR,OAjCQ,CAiCA,QAjCA,EAiCU,WAjCV,CAiCsB,UAjCtB,CAAA,EAiCmC,gBAjCnC,CAAA;AAAwB,UAuCjB,cAvCiB,CAAA,kBAuCgB,WAvChB,CAuC4B,UAvC5B,CAAA,GAuC0C,WAvC1C,CAuCsD,UAvCtD,CAAA,CAAA,SAwCxB,gBAxCwB,CAwCP,SAxCO,CAAA,CAAA;EAajB,SAAA,OAAA,EA6BX,OA7BW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ExtensionInstance, _ as ensureTableStatement, a as Plugin, b as lowerSqlPlan, c as lints, d as RuntimeTelemetryEvent, f as RuntimeVerifyOptions, g as ensureSchemaStatement, h as SqlStatement, i as Log, k as validateContractCodecMappings, l as Runtime, m as createRuntime, n as BudgetsOptions, o as PluginContext, p as TelemetryOutcome, r as LintsOptions, s as budgets, t as AfterExecuteResult, u as RuntimeOptions, v as readContractMarker, w as SqlRuntimeExtensionDescriptor, x as CreateRuntimeContextOptions, y as writeContractMarker } from "./index-Bycr1UG5.mjs";
2
+ export { AfterExecuteResult, BudgetsOptions, CreateRuntimeContextOptions, LintsOptions, Log, Plugin, PluginContext, Runtime, RuntimeContext, RuntimeOptions, RuntimeTelemetryEvent, RuntimeVerifyOptions, SqlRuntimeAdapterInstance, SqlRuntimeExtensionDescriptor, SqlRuntimeExtensionInstance, SqlStatement, TelemetryOutcome, budgets, createRuntime, createRuntimeContext, ensureSchemaStatement, ensureTableStatement, extractCodecIds, lints, lowerSqlPlan, readContractMarker, validateCodecRegistryCompleteness, validateContractCodecMappings, writeContractMarker };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { a as ensureTableStatement, c as createRuntimeContext, d as validateCodecRegistryCompleteness, f as validateContractCodecMappings, i as ensureSchemaStatement, l as lowerSqlPlan, n as lints, o as readContractMarker, r as createRuntime, s as writeContractMarker, t as budgets, u as extractCodecIds } from "./exports-BI-iW86w.mjs";
2
+
3
+ export { budgets, createRuntime, createRuntimeContext, ensureSchemaStatement, ensureTableStatement, extractCodecIds, lints, lowerSqlPlan, readContractMarker, validateCodecRegistryCompleteness, validateContractCodecMappings, writeContractMarker };