@prisma-next/sql-runtime 0.1.0-pr.39.2 → 0.1.0-pr.41.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MarkerStatement, RuntimeTelemetryEvent, RuntimeVerifyOptions, Plugin, Log } from '@prisma-next/runtime-executor';
1
+ import { MarkerStatement, AsyncIterableResult, RuntimeTelemetryEvent, RuntimeVerifyOptions, Plugin, Log } from '@prisma-next/runtime-executor';
2
2
  export { AfterExecuteResult, BudgetsOptions, LintsOptions, Log, Plugin, PluginContext, RuntimeTelemetryEvent, RuntimeVerifyOptions, TelemetryOutcome, budgets, lints } from '@prisma-next/runtime-executor';
3
3
  import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
4
4
  import { CodecRegistry, Adapter, QueryAst, LoweredStatement, SelectAst, SqlDriver } from '@prisma-next/sql-relational-core/ast';
@@ -69,7 +69,7 @@ interface RuntimeOptions<TContract extends SqlContract<SqlStorage> = SqlContract
69
69
  readonly log?: Log;
70
70
  }
71
71
  interface Runtime {
72
- execute<Row = Record<string, unknown>>(plan: ExecutionPlan<Row> | SqlQueryPlan<Row>): AsyncIterable<Row>;
72
+ execute<Row = Record<string, unknown>>(plan: ExecutionPlan<Row> | SqlQueryPlan<Row>): AsyncIterableResult<Row>;
73
73
  telemetry(): RuntimeTelemetryEvent | null;
74
74
  close(): Promise<void>;
75
75
  operations(): OperationRegistry;
package/dist/index.js CHANGED
@@ -182,7 +182,7 @@ function writeContractMarker(input) {
182
182
  }
183
183
 
184
184
  // src/sql-runtime.ts
185
- import { createRuntimeCore } from "@prisma-next/runtime-executor";
185
+ import { AsyncIterableResult, createRuntimeCore } from "@prisma-next/runtime-executor";
186
186
 
187
187
  // src/codecs/decoding.ts
188
188
  function resolveRowCodec(alias, plan, registry) {
@@ -422,7 +422,7 @@ var SqlRuntimeImpl = class {
422
422
  yield decodedRow;
423
423
  }
424
424
  };
425
- return iterator(this);
425
+ return new AsyncIterableResult(iterator(this));
426
426
  }
427
427
  telemetry() {
428
428
  return this.core.telemetry();
package/dist/index.js.map CHANGED
@@ -1 +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 extractCodecIds,\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 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 { 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.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"],"mappings":";AAQA,SAAS,SAAS,aAAa;;;ACR/B,SAAS,oBAAoB;AAItB,SAAS,gBAAgB,UAAgD;AAC9E,QAAM,WAAW,oBAAI,IAAY;AAEjC,aAAW,SAAS,OAAO,OAAO,SAAS,QAAQ,MAAM,GAAG;AAC1D,eAAW,UAAU,OAAO,OAAO,MAAM,OAAO,GAAG;AACjD,YAAM,UAAU,OAAO;AACvB,eAAS,IAAI,OAAO;AAAA,IACtB;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,2BAA2B,UAAwD;AAC1F,QAAM,WAAW,oBAAI,IAAoB;AAEzC,aAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,SAAS,QAAQ,MAAM,GAAG;AACxE,eAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,MAAM,OAAO,GAAG;AAChE,YAAM,UAAU,OAAO;AACvB,YAAM,MAAM,GAAG,SAAS,IAAI,UAAU;AACtC,eAAS,IAAI,KAAK,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,8BACd,UACA,UACM;AACN,QAAM,WAAW,2BAA2B,QAAQ;AACpD,QAAM,gBAA2E,CAAC;AAElF,aAAW,CAAC,KAAK,OA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AACT,SAAO,IAAI,eAAe,OAAO;AACnC;","names":["projection","runtimeError","runtimeError"]}
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 extractCodecIds,\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 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 { 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 { 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 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 ): 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","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"],"mappings":";AAQA,SAAS,SAAS,aAAa;;;ACR/B,SAAS,oBAAoB;AAItB,SAAS,gBAAgB,UAAgD;AAC9E,QAAM,WAAW,oBAAI,IAAY;AAEjC,aAAW,SAAS,OAAO,OAAO,SAAS,QAAQ,MAAM,GAAG;AAC1D,eAAW,UAAU,OAAO,OAAO,MAAM,OAAO,GAAG;AACjD,YAAM,UAAU,OAAO;AACvB,eAAS,IAAI,OAAO;AAAA,IACtB;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,2BAA2B,UAAwD;AAC1F,QAAM,WAAW,oBAAI,IAAoB;AAEzC,aAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,SAAS,QAAQ,MAAM,GAAG;AACxE,eAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,MAAM,OAAO,GAAG;AAChE,YAAM,UAAU,OAAO;AACvB,YAAM,MAAM,GAAG,SAAS,IAAI,UAAU;AACtC,eAAS,IAAI,KAAK,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,8BACd,UACA,UACM;AACN,QAAM,WAAW,2BAA2B,QAAQ;AACpD,QAAM,gBAA2E,CAAC;AAElF,aAAW,CAAC,KAAK,OAAO,KAAK,SAAS,QAAQ,GAAG;AAC/C,Q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SAAO,IAAI,eAAe,OAAO;AACnC;","names":["projection","runtimeError","runtimeError"]}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-runtime",
3
- "version": "0.1.0-pr.39.2",
3
+ "version": "0.1.0-pr.41.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "SQL runtime implementation for Prisma Next",
7
7
  "dependencies": {
8
- "@prisma-next/contract": "0.1.0-pr.39.2",
9
- "@prisma-next/runtime-executor": "0.1.0-pr.39.2",
10
- "@prisma-next/sql-contract": "0.1.0-pr.39.2",
11
- "@prisma-next/sql-operations": "0.1.0-pr.39.2",
12
- "@prisma-next/sql-relational-core": "0.1.0-pr.39.2",
13
- "@prisma-next/operations": "0.1.0-pr.39.2"
8
+ "@prisma-next/contract": "0.1.0-pr.41.1",
9
+ "@prisma-next/operations": "0.1.0-pr.41.1",
10
+ "@prisma-next/runtime-executor": "0.1.0-pr.41.1",
11
+ "@prisma-next/sql-contract": "0.1.0-pr.41.1",
12
+ "@prisma-next/sql-operations": "0.1.0-pr.41.1",
13
+ "@prisma-next/sql-relational-core": "0.1.0-pr.41.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/pg": "^8.11.10",