@prisma-next/sql-runtime 0.3.0-pr.98.4 → 0.3.0-pr.99.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.
@@ -66,6 +66,75 @@ function lowerSqlPlan(context, queryPlan) {
66
66
  // src/sql-context.ts
67
67
  import { createOperationRegistry } from "@prisma-next/operations";
68
68
  import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
69
+ import { type as arktype } from "arktype";
70
+ function runtimeTypeParamsInvalid(message, details) {
71
+ const error = new Error(message);
72
+ Object.defineProperty(error, "name", { value: "RuntimeError", configurable: true });
73
+ return Object.assign(error, {
74
+ code: "RUNTIME.TYPE_PARAMS_INVALID",
75
+ category: "RUNTIME",
76
+ severity: "error",
77
+ details
78
+ });
79
+ }
80
+ function validateTypeParams(typeParams, codecDescriptor, context) {
81
+ const result = codecDescriptor.paramsSchema(typeParams);
82
+ if (result instanceof arktype.errors) {
83
+ const messages = result.map((p) => p.message).join("; ");
84
+ const locationInfo = context.typeName ? `type '${context.typeName}'` : `column '${context.tableName}.${context.columnName}'`;
85
+ throw runtimeTypeParamsInvalid(
86
+ `Invalid typeParams for ${locationInfo} (codecId: ${codecDescriptor.codecId}): ${messages}`,
87
+ { ...context, codecId: codecDescriptor.codecId, typeParams }
88
+ );
89
+ }
90
+ return result;
91
+ }
92
+ function collectParameterizedCodecDescriptors(extensionInstances) {
93
+ const descriptors = /* @__PURE__ */ new Map();
94
+ for (const extInstance of extensionInstances) {
95
+ const paramCodecs = extInstance.parameterizedCodecs?.();
96
+ if (paramCodecs) {
97
+ for (const descriptor of paramCodecs) {
98
+ descriptors.set(descriptor.codecId, descriptor);
99
+ }
100
+ }
101
+ }
102
+ return descriptors;
103
+ }
104
+ function initializeTypeHelpers(storageTypes, codecDescriptors) {
105
+ const helpers = {};
106
+ if (!storageTypes) {
107
+ return helpers;
108
+ }
109
+ for (const [typeName, typeInstance] of Object.entries(storageTypes)) {
110
+ const descriptor = codecDescriptors.get(typeInstance.codecId);
111
+ if (descriptor) {
112
+ const validatedParams = validateTypeParams(typeInstance.typeParams, descriptor, {
113
+ typeName
114
+ });
115
+ if (descriptor.init) {
116
+ helpers[typeName] = descriptor.init(validatedParams);
117
+ } else {
118
+ helpers[typeName] = typeInstance;
119
+ }
120
+ } else {
121
+ helpers[typeName] = typeInstance;
122
+ }
123
+ }
124
+ return helpers;
125
+ }
126
+ function validateColumnTypeParams(storage, codecDescriptors) {
127
+ for (const [tableName, table] of Object.entries(storage.tables)) {
128
+ for (const [columnName, column] of Object.entries(table.columns)) {
129
+ if (column.typeParams) {
130
+ const descriptor = codecDescriptors.get(column.codecId);
131
+ if (descriptor) {
132
+ validateTypeParams(column.typeParams, descriptor, { tableName, columnName });
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
69
138
  function createRuntimeContext(options) {
70
139
  const { contract, adapter: adapterDescriptor, extensionPacks } = options;
71
140
  const adapterInstance = adapterDescriptor.create();
@@ -75,8 +144,10 @@ function createRuntimeContext(options) {
75
144
  for (const codec of adapterCodecs.values()) {
76
145
  codecRegistry.register(codec);
77
146
  }
147
+ const extensionInstances = [];
78
148
  for (const extDescriptor of extensionPacks ?? []) {
79
149
  const extInstance = extDescriptor.create();
150
+ extensionInstances.push(extInstance);
80
151
  const extCodecs = extInstance.codecs?.();
81
152
  if (extCodecs) {
82
153
  for (const codec of extCodecs.values()) {
@@ -90,11 +161,17 @@ function createRuntimeContext(options) {
90
161
  }
91
162
  }
92
163
  }
164
+ const parameterizedCodecDescriptors = collectParameterizedCodecDescriptors(extensionInstances);
165
+ if (parameterizedCodecDescriptors.size > 0) {
166
+ validateColumnTypeParams(contract.storage, parameterizedCodecDescriptors);
167
+ }
168
+ const types = initializeTypeHelpers(contract.storage.types, parameterizedCodecDescriptors);
93
169
  return {
94
170
  contract,
95
171
  adapter: adapterInstance,
96
172
  operations: operationRegistry,
97
- codecs: codecRegistry
173
+ codecs: codecRegistry,
174
+ types
98
175
  };
99
176
  }
100
177
 
@@ -452,4 +529,4 @@ export {
452
529
  budgets,
453
530
  lints
454
531
  };
455
- //# sourceMappingURL=chunk-C6I3V3DM.js.map
532
+ //# sourceMappingURL=chunk-WCKDI2MU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../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","../src/exports/index.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, StorageTypeInstance } 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 {\n QueryLaneContext,\n TypeHelperRegistry,\n} from '@prisma-next/sql-relational-core/query-lane-context';\nimport type { Type } from 'arktype';\nimport { type as arktype } from 'arktype';\n\n// ============================================================================\n// Runtime Parameterized Codec Descriptor Types\n// ============================================================================\n\n/**\n * Runtime parameterized codec descriptor.\n * Provides validation schema and optional init hook for codecs that support type parameters.\n * Used at runtime to validate typeParams and create type helpers.\n */\nexport interface RuntimeParameterizedCodecDescriptor<\n TParams = Record<string, unknown>,\n THelper = unknown,\n> {\n /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */\n readonly codecId: string;\n\n /**\n * Arktype schema for validating typeParams.\n * The schema is used to validate both storage.types entries and inline column typeParams.\n */\n readonly paramsSchema: Type<TParams>;\n\n /**\n * Optional init hook called during runtime context creation.\n * Receives validated params and returns a helper object to be stored in context.types.\n * If not provided, the validated params are stored directly.\n */\n readonly init?: (params: TParams) => THelper;\n}\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 * Returns parameterized codec descriptors for type validation and helper creation.\n * Uses unknown for type parameters to allow any concrete descriptor types.\n */\n // biome-ignore lint/suspicious/noExplicitAny: needed for covariance with concrete descriptor types\n parameterizedCodecs?(): ReadonlyArray<RuntimeParameterizedCodecDescriptor<any, any>>;\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 type { TypeHelperRegistry };\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 * Initialized type helpers from storage.types.\n * Each entry corresponds to a named type instance in the contract's storage.types.\n * The value is the result of calling the codec's init hook (if provided)\n * or the validated typeParams (if no init hook).\n */\n readonly types?: TypeHelperRegistry;\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// Runtime Error Types and Helpers\n// ============================================================================\n\n/**\n * Structured error thrown by the SQL runtime.\n *\n * Aligns with the repository's error envelope convention:\n * - `code`: Stable error code for programmatic handling (e.g., `RUNTIME.TYPE_PARAMS_INVALID`)\n * - `category`: Error source category (`RUNTIME`)\n * - `severity`: Error severity level (`error`)\n * - `details`: Optional structured details for debugging\n *\n * @example\n * ```typescript\n * try {\n * createRuntimeContext({ ... });\n * } catch (e) {\n * if ((e as RuntimeError).code === 'RUNTIME.TYPE_PARAMS_INVALID') {\n * console.error('Invalid type parameters:', (e as RuntimeError).details);\n * }\n * }\n * ```\n */\nexport interface RuntimeError extends Error {\n /** Stable error code for programmatic handling (e.g., `RUNTIME.TYPE_PARAMS_INVALID`) */\n readonly code: string;\n /** Error source category */\n readonly category: 'RUNTIME';\n /** Error severity level */\n readonly severity: 'error';\n /** Optional structured details for debugging */\n readonly details?: Record<string, unknown>;\n}\n\n/**\n * Creates a RuntimeError for invalid type parameters.\n *\n * Error code: `RUNTIME.TYPE_PARAMS_INVALID`\n *\n * Thrown when:\n * - `storage.types` entries have typeParams that fail codec schema validation\n * - Column inline typeParams fail codec schema validation\n *\n * @internal\n */\nfunction runtimeTypeParamsInvalid(\n message: string,\n details?: Record<string, unknown>,\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n Object.defineProperty(error, 'name', { value: 'RuntimeError', configurable: true });\n return Object.assign(error, {\n code: 'RUNTIME.TYPE_PARAMS_INVALID',\n category: 'RUNTIME' as const,\n severity: 'error' as const,\n details,\n });\n}\n\n// ============================================================================\n// Parameterized Type Validation\n// ============================================================================\n\n/**\n * Validates typeParams against the codec's paramsSchema.\n * @throws RuntimeError with code RUNTIME.TYPE_PARAMS_INVALID if validation fails\n */\nfunction validateTypeParams(\n typeParams: Record<string, unknown>,\n codecDescriptor: RuntimeParameterizedCodecDescriptor,\n context: { typeName?: string; tableName?: string; columnName?: string },\n): Record<string, unknown> {\n const result = codecDescriptor.paramsSchema(typeParams);\n if (result instanceof arktype.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n const locationInfo = context.typeName\n ? `type '${context.typeName}'`\n : `column '${context.tableName}.${context.columnName}'`;\n throw runtimeTypeParamsInvalid(\n `Invalid typeParams for ${locationInfo} (codecId: ${codecDescriptor.codecId}): ${messages}`,\n { ...context, codecId: codecDescriptor.codecId, typeParams },\n );\n }\n return result as Record<string, unknown>;\n}\n\n/**\n * Collects parameterized codec descriptors from extension instances.\n * Returns a map of codecId → descriptor for quick lookup.\n */\nfunction collectParameterizedCodecDescriptors(\n extensionInstances: ReadonlyArray<SqlRuntimeExtensionInstance<string>>,\n): Map<string, RuntimeParameterizedCodecDescriptor> {\n const descriptors = new Map<string, RuntimeParameterizedCodecDescriptor>();\n\n for (const extInstance of extensionInstances) {\n const paramCodecs = extInstance.parameterizedCodecs?.();\n if (paramCodecs) {\n for (const descriptor of paramCodecs) {\n descriptors.set(descriptor.codecId, descriptor);\n }\n }\n }\n\n return descriptors;\n}\n\n/**\n * Initializes type helpers from storage.types using codec descriptors.\n *\n * For each named type instance in `storage.types`:\n * - If a codec descriptor exists with an `init` hook: calls the hook and stores the result\n * - Otherwise: stores the full type instance metadata directly (codecId, nativeType, typeParams)\n *\n * This matches the typing in `ExtractSchemaTypes<Contract>` which extracts\n * `Contract['storage']['types']` directly, ensuring runtime values match static types\n * when no init hook transforms the value.\n */\nfunction initializeTypeHelpers(\n storageTypes: Record<string, StorageTypeInstance> | undefined,\n codecDescriptors: Map<string, RuntimeParameterizedCodecDescriptor>,\n): TypeHelperRegistry {\n const helpers: TypeHelperRegistry = {};\n\n if (!storageTypes) {\n return helpers;\n }\n\n for (const [typeName, typeInstance] of Object.entries(storageTypes)) {\n const descriptor = codecDescriptors.get(typeInstance.codecId);\n\n if (descriptor) {\n // Validate typeParams against the codec's schema\n const validatedParams = validateTypeParams(typeInstance.typeParams, descriptor, {\n typeName,\n });\n\n // Call init hook if provided, otherwise store full type instance\n if (descriptor.init) {\n helpers[typeName] = descriptor.init(validatedParams);\n } else {\n // No init hook: expose full type instance metadata (matches contract typing)\n helpers[typeName] = typeInstance;\n }\n } else {\n // No descriptor found: expose full type instance (no validation possible)\n helpers[typeName] = typeInstance;\n }\n }\n\n return helpers;\n}\n\n/**\n * Validates inline column typeParams across all tables.\n * @throws RuntimeError with code RUNTIME.TYPE_PARAMS_INVALID if validation fails\n */\nfunction validateColumnTypeParams(\n storage: SqlStorage,\n codecDescriptors: Map<string, RuntimeParameterizedCodecDescriptor>,\n): void {\n for (const [tableName, table] of Object.entries(storage.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n if (column.typeParams) {\n const descriptor = codecDescriptors.get(column.codecId);\n if (descriptor) {\n validateTypeParams(column.typeParams, descriptor, { tableName, columnName });\n }\n }\n }\n }\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 * - Types registry (initialized helpers from storage.types)\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 collect their contributions\n const extensionInstances: SqlRuntimeExtensionInstance<TTargetId>[] = [];\n\n for (const extDescriptor of extensionPacks ?? []) {\n const extInstance = extDescriptor.create();\n extensionInstances.push(extInstance);\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 // Collect parameterized codec descriptors from extensions\n const parameterizedCodecDescriptors = collectParameterizedCodecDescriptors(extensionInstances);\n\n // Validate column typeParams if any descriptors are registered\n if (parameterizedCodecDescriptors.size > 0) {\n validateColumnTypeParams(contract.storage, parameterizedCodecDescriptors);\n }\n\n // Initialize type helpers from storage.types\n const types = initializeTypeHelpers(contract.storage.types, parameterizedCodecDescriptors);\n\n return {\n contract,\n adapter: adapterInstance,\n operations: operationRegistry,\n codecs: codecRegistry,\n types,\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 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","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 {\n CreateRuntimeContextOptions,\n RuntimeContext,\n RuntimeParameterizedCodecDescriptor,\n SqlRuntimeAdapterInstance,\n SqlRuntimeExtensionDescriptor,\n SqlRuntimeExtensionInstance,\n TypeHelperRegistry,\n} 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"],"mappings":";AAAA,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,QAAI,CAAC,SAAS,IAAI,OAAO,GAAG;AAC1B,YAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,YAAM,QAAQ,MAAM,CAAC,KAAK;AAC1B,YAAM,SAAS,MAAM,CAAC,KAAK;AAC3B,oBAAc,KAAK,EAAE,OAAO,QAAQ,QAAQ,CAAC;AAAA,IAC/C;AAAA,EACF;AAEA,MAAI,cAA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AS;AAAA,IAClC;AAGA,UAAM,iBAAqC,eAAe,IAAI,IAC1D,aAAa,KAAK,SAAS,IAAI,IAC/B;AAEJ,UAAM,WAAW,iBACf,MACoC;AACpC,YAAM,gBAAgB,aAAa,gBAAgB,KAAK,aAAa;AACrE,YAAM,wBAA4C;AAAA,QAChD,GAAG;AAAA,QACH,QAAQ;AAAA,MACV;AAEA,YAAM,eAAe,KAAK,KAAK,QAAQ,qBAAqB;AAE5D,uBAAiB,UAAU,cAAc;AACvC,cAAM,aAAa;AAAA,UACjB;AAAA,UACA;AAAA,UACA,KAAK;AAAA,QACP;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAEA,WAAO,IAAI,oBAAoB,SAAS,IAAI,CAAC;AAAA,EAC/C;AAAA,EAEA,YAA0C;AACxC,WAAO,KAAK,KAAK,UAAU;AAAA,EAC7B;AAAA,EAEA,aAAgC;AAC9B,WAAO,KAAK,KAAK,WAAW;AAAA,EAC9B;AAAA,EAEA,QAAuB;AACrB,WAAO,KAAK,KAAK,MAAM;AAAA,EACzB;AACF;AAEO,SAAS,cACd,SACS;AACT,SAAO,IAAI,eAAe,OAAO;AACnC;;;AI7JA,SAAS,SAAS,aAAa;","names":["projection","runtimeError","runtimeError"]}
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  validateCodecRegistryCompleteness,
12
12
  validateContractCodecMappings,
13
13
  writeContractMarker
14
- } from "./chunk-C6I3V3DM.js";
14
+ } from "./chunk-WCKDI2MU.js";
15
15
  import "./chunk-7D4SUZUM.js";
16
16
  export {
17
17
  budgets,
@@ -2,7 +2,7 @@ export type { AfterExecuteResult, BudgetsOptions, LintsOptions, Log, Plugin, Plu
2
2
  export { budgets, lints } from '@prisma-next/runtime-executor';
3
3
  export { extractCodecIds, validateCodecRegistryCompleteness, validateContractCodecMappings, } from '../codecs/validation';
4
4
  export { lowerSqlPlan } from '../lower-sql-plan';
5
- export type { CreateRuntimeContextOptions, RuntimeContext, SqlRuntimeAdapterInstance, SqlRuntimeExtensionDescriptor, SqlRuntimeExtensionInstance, } from '../sql-context';
5
+ export type { CreateRuntimeContextOptions, RuntimeContext, RuntimeParameterizedCodecDescriptor, SqlRuntimeAdapterInstance, SqlRuntimeExtensionDescriptor, SqlRuntimeExtensionInstance, TypeHelperRegistry, } from '../sql-context';
6
6
  export { createRuntimeContext } from '../sql-context';
7
7
  export type { SqlStatement } from '../sql-marker';
8
8
  export { ensureSchemaStatement, ensureTableStatement, readContractMarker, writeContractMarker, } from '../sql-marker';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,GAAG,EACH,MAAM,EACN,aAAa,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EACV,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,GAAG,EACH,MAAM,EACN,aAAa,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EACV,2BAA2B,EAC3B,cAAc,EACd,mCAAmC,EACnC,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
@@ -2,7 +2,28 @@ import type { RuntimeAdapterDescriptor, RuntimeAdapterInstance, RuntimeExtension
2
2
  import type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
3
3
  import type { SqlOperationSignature } from '@prisma-next/sql-operations';
4
4
  import type { Adapter, CodecRegistry, LoweredStatement, QueryAst } from '@prisma-next/sql-relational-core/ast';
5
- import type { QueryLaneContext } from '@prisma-next/sql-relational-core/query-lane-context';
5
+ import type { QueryLaneContext, TypeHelperRegistry } from '@prisma-next/sql-relational-core/query-lane-context';
6
+ import type { Type } from 'arktype';
7
+ /**
8
+ * Runtime parameterized codec descriptor.
9
+ * Provides validation schema and optional init hook for codecs that support type parameters.
10
+ * Used at runtime to validate typeParams and create type helpers.
11
+ */
12
+ export interface RuntimeParameterizedCodecDescriptor<TParams = Record<string, unknown>, THelper = unknown> {
13
+ /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */
14
+ readonly codecId: string;
15
+ /**
16
+ * Arktype schema for validating typeParams.
17
+ * The schema is used to validate both storage.types entries and inline column typeParams.
18
+ */
19
+ readonly paramsSchema: Type<TParams>;
20
+ /**
21
+ * Optional init hook called during runtime context creation.
22
+ * Receives validated params and returns a helper object to be stored in context.types.
23
+ * If not provided, the validated params are stored directly.
24
+ */
25
+ readonly init?: (params: TParams) => THelper;
26
+ }
6
27
  /**
7
28
  * SQL runtime extension instance.
8
29
  * Extends the framework RuntimeExtensionInstance with SQL-specific hooks
@@ -15,6 +36,11 @@ export interface SqlRuntimeExtensionInstance<TTargetId extends string> extends R
15
36
  codecs?(): CodecRegistry;
16
37
  /** Returns operations to register in the runtime context. */
17
38
  operations?(): ReadonlyArray<SqlOperationSignature>;
39
+ /**
40
+ * Returns parameterized codec descriptors for type validation and helper creation.
41
+ * Uses unknown for type parameters to allow any concrete descriptor types.
42
+ */
43
+ parameterizedCodecs?(): ReadonlyArray<RuntimeParameterizedCodecDescriptor<any, any>>;
18
44
  }
19
45
  /**
20
46
  * SQL runtime extension descriptor.
@@ -33,8 +59,16 @@ export interface SqlRuntimeExtensionDescriptor<TTargetId extends string> extends
33
59
  * @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
34
60
  */
35
61
  export type SqlRuntimeAdapterInstance<TTargetId extends string = string> = RuntimeAdapterInstance<'sql', TTargetId> & Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
62
+ export type { TypeHelperRegistry };
36
63
  export interface RuntimeContext<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> extends QueryLaneContext<TContract> {
37
64
  readonly adapter: Adapter<QueryAst, TContract, LoweredStatement> | Adapter<QueryAst, SqlContract<SqlStorage>, LoweredStatement>;
65
+ /**
66
+ * Initialized type helpers from storage.types.
67
+ * Each entry corresponds to a named type instance in the contract's storage.types.
68
+ * The value is the result of calling the codec's init hook (if provided)
69
+ * or the validated typeParams (if no init hook).
70
+ */
71
+ readonly types?: TypeHelperRegistry;
38
72
  }
39
73
  /**
40
74
  * Descriptor-first options for creating a SQL runtime context.
@@ -49,6 +83,36 @@ export interface CreateRuntimeContextOptions<TContract extends SqlContract<SqlSt
49
83
  readonly adapter: RuntimeAdapterDescriptor<'sql', TTargetId, SqlRuntimeAdapterInstance<TTargetId>>;
50
84
  readonly extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<TTargetId>>;
51
85
  }
86
+ /**
87
+ * Structured error thrown by the SQL runtime.
88
+ *
89
+ * Aligns with the repository's error envelope convention:
90
+ * - `code`: Stable error code for programmatic handling (e.g., `RUNTIME.TYPE_PARAMS_INVALID`)
91
+ * - `category`: Error source category (`RUNTIME`)
92
+ * - `severity`: Error severity level (`error`)
93
+ * - `details`: Optional structured details for debugging
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * try {
98
+ * createRuntimeContext({ ... });
99
+ * } catch (e) {
100
+ * if ((e as RuntimeError).code === 'RUNTIME.TYPE_PARAMS_INVALID') {
101
+ * console.error('Invalid type parameters:', (e as RuntimeError).details);
102
+ * }
103
+ * }
104
+ * ```
105
+ */
106
+ export interface RuntimeError extends Error {
107
+ /** Stable error code for programmatic handling (e.g., `RUNTIME.TYPE_PARAMS_INVALID`) */
108
+ readonly code: string;
109
+ /** Error source category */
110
+ readonly category: 'RUNTIME';
111
+ /** Error severity level */
112
+ readonly severity: 'error';
113
+ /** Optional structured details for debugging */
114
+ readonly details?: Record<string, unknown>;
115
+ }
52
116
  /**
53
117
  * Creates a SQL runtime context from descriptor-first composition.
54
118
  *
@@ -57,6 +121,7 @@ export interface CreateRuntimeContextOptions<TContract extends SqlContract<SqlSt
57
121
  * - The adapter instance (created from descriptor)
58
122
  * - Codec registry (populated from adapter + extension instances)
59
123
  * - Operation registry (populated from extension instances)
124
+ * - Types registry (initialized helpers from storage.types)
60
125
  *
61
126
  * @param options - Descriptor-first composition options
62
127
  * @returns RuntimeContext with registries wired from all components
@@ -1 +1 @@
1
- {"version":3,"file":"sql-context.d.ts","sourceRoot":"","sources":["../../src/sql-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACT,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAM5F;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B,CAAC,SAAS,SAAS,MAAM,CACnE,SAAQ,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC;IAClD,yDAAyD;IACzD,MAAM,CAAC,IAAI,aAAa,CAAC;IACzB,6DAA6D;IAC7D,UAAU,CAAC,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;CACrD;AAED;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B,CAAC,SAAS,SAAS,MAAM,CACrE,SAAQ,0BAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAC5F,MAAM,IAAI,2BAA2B,CAAC,SAAS,CAAC,CAAC;CAClD;AAMD;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IAAI,sBAAsB,CAC/F,KAAK,EACL,SAAS,CACV,GACC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC;A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E,MAAM,CAAC;IACtB,4BAA4B;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AA6ID;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,SAAS,WAAW,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,EACnE,SAAS,SAAS,MAAM,GAAG,MAAM,EACjC,OAAO,EAAE,2BAA2B,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAyDvF"}
@@ -26,7 +26,7 @@ import {
26
26
  ensureSchemaStatement,
27
27
  ensureTableStatement,
28
28
  writeContractMarker
29
- } from "../chunk-C6I3V3DM.js";
29
+ } from "../chunk-WCKDI2MU.js";
30
30
  import {
31
31
  __commonJS,
32
32
  __require,
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-runtime",
3
- "version": "0.3.0-pr.98.4",
3
+ "version": "0.3.0-pr.99.2",
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.3.0-pr.98.4",
9
- "@prisma-next/core-execution-plane": "0.3.0-pr.98.4",
10
- "@prisma-next/operations": "0.3.0-pr.98.4",
11
- "@prisma-next/runtime-executor": "0.3.0-pr.98.4",
12
- "@prisma-next/sql-contract": "0.3.0-pr.98.4",
13
- "@prisma-next/sql-operations": "0.3.0-pr.98.4",
14
- "@prisma-next/sql-relational-core": "0.3.0-pr.98.4"
8
+ "arktype": "^2.1.26",
9
+ "@prisma-next/contract": "0.3.0-pr.99.2",
10
+ "@prisma-next/core-execution-plane": "0.3.0-pr.99.2",
11
+ "@prisma-next/operations": "0.3.0-pr.99.2",
12
+ "@prisma-next/runtime-executor": "0.3.0-pr.99.2",
13
+ "@prisma-next/sql-contract": "0.3.0-pr.99.2",
14
+ "@prisma-next/sql-operations": "0.3.0-pr.99.2",
15
+ "@prisma-next/sql-relational-core": "0.3.0-pr.99.2"
15
16
  },
16
17
  "devDependencies": {
17
18
  "@types/pg": "8.16.0",
@@ -16,9 +16,11 @@ export { lowerSqlPlan } from '../lower-sql-plan';
16
16
  export type {
17
17
  CreateRuntimeContextOptions,
18
18
  RuntimeContext,
19
+ RuntimeParameterizedCodecDescriptor,
19
20
  SqlRuntimeAdapterInstance,
20
21
  SqlRuntimeExtensionDescriptor,
21
22
  SqlRuntimeExtensionInstance,
23
+ TypeHelperRegistry,
22
24
  } from '../sql-context';
23
25
  export { createRuntimeContext } from '../sql-context';
24
26
  export type { SqlStatement } from '../sql-marker';