@prisma-next/extension-arktype-json 0.11.0-dev.9 → 0.12.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"arktype-json-codec-BRSKEodM.d.mts","names":[],"sources":["../src/core/arktype-json-codec.ts"],"mappings":";;;;;;AAqCA;AAAA,cARa,qBAAA;;cAGA,wBAAA;;AAcX;;KATU,qBAAA;EAWe;;AA8G3B;EA9G2B,SAPhB,UAAA;EAqHuB;;;EAAA,SAjHvB,MAAA;AAAA;AAAA,KAGN,iBAAA,KAAsB,KAAA;EAAA,SAChB,UAAA;AAAA;AAAA,cA6GE,qBAAA,oBAAyC,SAAA,QAC7C,qBAAA,kCAEE,SAAA,EACT,SAAA;EAAA,iBAImB,MAAA;cADjB,UAAA,EAAY,qBAAA,EACK,MAAA,EAAQ,iBAAA;EAKrB,MAAA,CAAO,KAAA,EAAO,SAAA,EAAW,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAIlD,MAAA,CAAO,IAAA,WAAe,SAAA,EAAW,IAAA,EAAM,gBAAA,GAAmB,OAAA,CAAQ,SAAA;EAIxE,UAAA,CAAW,KAAA,EAAO,SAAA,GAAY,SAAA;EAI9B,UAAA,CAAW,IAAA,EAAM,SAAA,GAAY,SAAA;AAAA;AAAA,cAYlB,qBAAA,SAA8B,mBAAA,CAAoB,qBAAA;EAAA,SAC3C,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,IAAA;IAAA;;;;;;;;WACA,YAAA,EAAc,gBAAA,CAAiB,qBAAA;EACxC,gBAAA,CAAiB,MAAA,EAAQ,qBAAA;EAGzB,OAAA,CACP,MAAA,EAAQ,qBAAA,IACN,GAAA,EAAK,oBAAA,KAAyB,qBAAA;AAAA;;;;;;;;iBA2BpB,iBAAA,WAA4B,IAAA,UAAA,CAC1C,MAAA,EAAQ,CAAA,GACP,UAAA,CAAW,qBAAA,CAAsB,CA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AAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"arktype-json-codec-BjUHsoD5.mjs","names":[],"sources":["../src/core/arktype-json-codec.ts"],"sourcesContent":["/**\n * Arktype-json codec (TML-2357).\n *\n * Spec § Case 3: method-level generic over `S extends Type<unknown>`. The schema's TypeScript-level inferred type `S['infer']` is only available at the column-author site (where the user passes their typed schema), not at the descriptor's factory site (where only the serialized IR is available). This drives the shape:\n *\n * 1. {@link ArktypeJsonCodecClass} extends {@link CodecImpl} and is generic over `TInferred` — the application-level JS type the schema validates to. The constructor takes both the descriptor (for `id` proxy) and the rehydrated arktype `Type` (closure-captured so encode/decode/encodeJson/decodeJson can validate through it). 2. {@link ArktypeJsonDescriptor} extends {@link CodecDescriptorImpl} over {@link\n * ArktypeJsonTypeParams}. Factory rehydrates the schema from `params.jsonIr` and returns `(ctx) => new ArktypeJsonCodecClass<unknown>(this, schema)` — `S` is erased to `unknown` because the descriptor only sees IR. The runtime path through `descriptor.factory(params)` always exists (e.g. for `family.deserializeContract` re-materialization); it just loses the typed inferred shape. 3. {@link arktypeJsonColumn} is the column-author\n * surface with the method-level generic over `S extends Type<unknown>`. It bypasses `descriptor.factory` because `S` is only available here, instead constructing the typed codec directly so `S['infer']` flows through `codecFactory`'s return into the column site's resolved output type. Eager serialization at this call site captures `expression` (for the emit-path renderer) and `jsonIr` (for runtime rehydration).\n *\n * `satisfies ColumnHelperFor<ArktypeJsonDescriptor>` (coarse) is applied — the typeParams shape is verified. `ColumnHelperForStrict` is intentionally skipped: the descriptor's factory return is `ArktypeJsonCodecClass<unknown>` while the helper produces `ArktypeJsonCodecClass<S['infer']>`, and `Codec`'s `TInput` is invariant (used contravariantly in `encode`, covariantly in `decode`/`encodeJson`/`decodeJson`). Strict\n * assignment fails by design; the explicit `expectTypeOf` tests in `test/arktype-json-codec.types.test-d.ts` cover the literal-preservation property the strict variant would otherwise enforce.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnSpec,\n column,\n} from '@prisma-next/framework-components/codec';\nimport { isRuntimeError, runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { ArkErrors, ark, type Type, type } from 'arktype';\n\n/** Codec id for arktype-backed JSON columns. Library-bound, not target-bound. */\nexport const ARKTYPE_JSON_CODEC_ID = 'arktype/json@1' as const;\n\n/** Native storage type backing the codec. JSONB on Postgres; binary, indexable. */\nexport const ARKTYPE_JSON_NATIVE_TYPE = 'jsonb' as const;\n\n/**\n * Eagerly serialized typeParams for the arktype-json column. Carried in the contract IR; the runtime descriptor's factory rehydrates `jsonIr` and the emitter consumes `expression`.\n */\nexport type ArktypeJsonTypeParams = {\n /**\n * Arktype's TypeScript-source-like rendering of the schema. Read by `renderOutputType` to emit the column's TS type into `contract.d.ts`. Stable across the serialize/rehydrate cycle: the rehydrated schema's `expression` matches the source schema's.\n */\n readonly expression: string;\n /**\n * Arktype's internal IR for the schema. Lossless; the rehydration source. Schema-shape — `ark.schema(jsonIr)` reconstructs a callable `Type`-like structurally identical to the original `type(definition)` output.\n */\n readonly jsonIr: object;\n};\n\ntype ArktypeSchemaLike = ((value: unknown) => unknown) & {\n readonly expression: string;\n};\n\nfunction isArktypeSchemaLike(value: unknown): value is ArktypeSchemaLike {\n if (typeof value !== 'function') return false;\n const expression = (value as { readonly expression?: unknown }).expression;\n return typeof expression === 'string';\n}\n\nfunction validateSchema<TInferred>(schema: ArktypeSchemaLike, value: unknown): TInferred {\n const result = schema(value);\n if (result instanceof ArkErrors) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n `arktype-json schema validation failed (decode): ${result.summary}`,\n { codecId: ARKTYPE_JSON_CODEC_ID, issues: result.summary },\n );\n }\n return result as TInferred;\n}\n\nfunction serializeWire<TInferred>(value: TInferred): string {\n const wire: string | undefined = JSON.stringify(value);\n if (typeof wire !== 'string') {\n throw new Error(\n `arktype-json value is not representable as JSON (codecId: ${ARKTYPE_JSON_CODEC_ID})`,\n );\n }\n return wire;\n}\n\nfunction serializeJson<TInferred>(value: TInferred): JsonValue {\n // The stringify → parse round-trip both validates JSON-representability\n // (matching `serializeWire`) and produces a deep-cloned `JsonValue` that\n // strips class prototypes / `toJSON` side effects, so callers reading\n // the in-memory `JsonValue` see exactly the shape that would round-trip\n // through the database.\n return JSON.parse(serializeWire(value)) as JsonValue;\n}\n\nfunction parseJsonText(wire: string): JsonValue | undefined {\n try {\n return JSON.parse(wire) as JsonValue;\n } catch {\n return undefined;\n }\n}\n\nfunction decodeWireValue<TInferred>(\n schema: ArktypeSchemaLike,\n wire: string | JsonValue,\n): TInferred {\n if (typeof wire !== 'string') return validateSchema<TInferred>(schema, wire);\n\n // Try the wire as the literal value first. Under `pg` + `jsonb` (the\n // documented native type), wire arrives already-parsed: a JSON object\n // surfaces as a JS object, a JSON string surfaces as a JS string. For\n // string columns that means the wire IS the user's value — including\n // strings whose literal characters happen to start and end with `\"`.\n // A `\"…\"`-shape unwrap heuristic would silently truncate them (the\n // 7-char `\"hello\"` would decode to the 5-char `hello`).\n //\n // Fall back to JSON.parse only when schema validation rejects the raw\n // wire: that path covers object/array shapes received as raw JSON\n // text (legacy `json` text-OID adapters, or any code path that hands\n // us un-pre-parsed JSON).\n try {\n return validateSchema<TInferred>(schema, wire);\n } catch (error) {\n if (!isRuntimeError(error) || error.code !== 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED') {\n throw error;\n }\n const parsed = parseJsonText(wire);\n if (parsed === undefined) {\n throw error;\n }\n return validateSchema<TInferred>(schema, parsed);\n }\n}\n\nfunction rehydrateSchema(jsonIr: object): ArktypeSchemaLike {\n let rehydrated: unknown;\n try {\n rehydrated = ark.schema(jsonIr);\n } catch (error) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n /* c8 ignore next — the `String(error)` fallback covers throws of non-Error values; arktype only throws Error subclasses, so this branch is defensive only. */\n `Failed to rehydrate arktype schema from contract IR: ${error instanceof Error ? error.message : String(error)}`,\n { codecId: ARKTYPE_JSON_CODEC_ID, jsonIr },\n );\n }\n /* c8 ignore start — defensive: ark.schema either throws (handled above) or returns a callable Type with `expression: string`. The structural guard is kept so a future ark internal change can't silently slip a non-callable past us. */\n if (!isArktypeSchemaLike(rehydrated)) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n `Rehydrated arktype schema does not have the expected callable + 'expression: string' shape (codecId: ${ARKTYPE_JSON_CODEC_ID})`,\n { codecId: ARKTYPE_JSON_CODEC_ID, jsonIr },\n );\n }\n /* c8 ignore stop */\n return rehydrated;\n}\n\nfunction renderArktypeJsonOutputType(params: ArktypeJsonTypeParams): string {\n const expression = params.expression.trim();\n return expression.length > 0 ? expression : 'unknown';\n}\n\nexport class ArktypeJsonCodecClass<TInferred> extends CodecImpl<\n typeof ARKTYPE_JSON_CODEC_ID,\n readonly ['equality'],\n string | JsonValue,\n TInferred\n> {\n constructor(\n descriptor: ArktypeJsonDescriptor,\n private readonly schema: ArktypeSchemaLike,\n ) {\n super(descriptor);\n }\n\n async encode(value: TInferred, _ctx: CodecCallContext): Promise<string> {\n return serializeWire(value);\n }\n\n async decode(wire: string | JsonValue, _ctx: CodecCallContext): Promise<TInferred> {\n return decodeWireValue<TInferred>(this.schema, wire);\n }\n\n encodeJson(value: TInferred): JsonValue {\n return serializeJson(value);\n }\n\n decodeJson(json: JsonValue): TInferred {\n return validateSchema<TInferred>(this.schema, json);\n }\n}\n\nconst arktypeJsonParamsSchema = type({\n expression: 'string',\n jsonIr: 'object',\n}) satisfies StandardSchemaV1<ArktypeJsonTypeParams>;\n\nconst ARKTYPE_JSON_META = { db: { sql: { postgres: { nativeType: 'jsonb' } } } } as const;\n\nexport class ArktypeJsonDescriptor extends CodecDescriptorImpl<ArktypeJsonTypeParams> {\n override readonly codecId = ARKTYPE_JSON_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = [ARKTYPE_JSON_NATIVE_TYPE] as const;\n override readonly meta = ARKTYPE_JSON_META;\n override readonly paramsSchema: StandardSchemaV1<ArktypeJsonTypeParams> = arktypeJsonParamsSchema;\n override renderOutputType(params: ArktypeJsonTypeParams): string {\n return renderArktypeJsonOutputType(params);\n }\n override factory(\n params: ArktypeJsonTypeParams,\n ): (ctx: CodecInstanceContext) => ArktypeJsonCodecClass<unknown> {\n const schema = rehydrateSchema(params.jsonIr);\n const rehydratedExpression = (schema as { readonly expression?: unknown }).expression;\n if (typeof rehydratedExpression === 'string' && rehydratedExpression !== params.expression) {\n throw runtimeError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `arktype-json: typeParams.expression (${params.expression}) does not match the rehydrated schema's expression (${rehydratedExpression}). The contract was likely emitted against a different arktype version or hand-edited; re-run \\`pnpm emit\\` to regenerate.`,\n {\n codecId: ARKTYPE_JSON_CODEC_ID,\n serializedExpression: params.expression,\n rehydratedExpression,\n },\n );\n }\n return () => new ArktypeJsonCodecClass<unknown>(this, schema);\n }\n}\n\nexport const arktypeJsonDescriptor = new ArktypeJsonDescriptor();\n\n/**\n * Per-codec column helper for `arktype/json@1`. Method-level generic over `S extends Type<unknown>` so the column site preserves the schema's inferred TS type in the resolved codec (`ArktypeJsonCodecClass<S['infer']>`). Bypasses `descriptor.factory` because `S` is only available at the column-author site; constructs the typed codec directly with the closure-captured schema.\n *\n * Eager serialization at this call site captures `expression` (for the emit-path renderer) and `jsonIr` (for runtime rehydration via the descriptor's factory).\n *\n * @throws {Error} if the schema doesn't expose `expression` and `json` fields (i.e. is not an arktype `Type`). Validates the schema shape at the call site so configuration errors surface during contract authoring, not at runtime.\n */\nexport function arktypeJsonColumn<S extends Type<unknown>>(\n schema: S,\n): ColumnSpec<ArktypeJsonCodecClass<S['infer']>, ArktypeJsonTypeParams> {\n if (!isArktypeSchemaLike(schema)) {\n throw new Error(\n typeof schema !== 'function'\n ? 'arktypeJsonColumn(schema) expects a callable arktype Type.'\n : 'arktypeJsonColumn(schema) expects an arktype Type (missing `expression: string`).',\n );\n }\n const jsonIr: unknown = (schema as { readonly json?: unknown }).json;\n if (jsonIr === null || typeof jsonIr !== 'object') {\n throw new Error('arktypeJsonColumn(schema) expects an arktype Type (missing `json` IR).');\n }\n const params: ArktypeJsonTypeParams = { expression: schema.expression, jsonIr };\n return column(\n (_ctx: CodecInstanceContext) =>\n new ArktypeJsonCodecClass<S['infer']>(arktypeJsonDescriptor, schema),\n arktypeJsonDescriptor.codecId,\n params,\n ARKTYPE_JSON_NATIVE_TYPE,\n );\n}\n\narktypeJsonColumn satisfies ColumnHelperFor<ArktypeJsonDescriptor>;\n// Note: `ColumnHelperForStrict` is intentionally not applied — `Codec` is invariant in `TInput` (encode contravariant, decode covariant), so `ArktypeJsonCodecClass<S['infer']>` is not assignable to `ArktypeJsonCodecClass<unknown>` (the descriptor.factory return). `expectTypeOf` tests cover the literal-preservation property strict satisfies would otherwise enforce.\n\n/**\n * Codec instance returned by `arktypeJsonColumn(schema).codecFactory(ctx)` and by `arktypeJsonDescriptor.factory(typeParams)(ctx)`. The `TInferred` slot carries the arktype schema's inferred output type at the column-author site; descriptor-side factories erase to `unknown`.\n */\nexport type ArktypeJsonCodec<TInferred> = ArktypeJsonCodecClass<TInferred>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = [arktypeJsonDescriptor];\n"],"mappings":";;;;;AA6BA,MAAa,wBAAwB;;AAGrC,MAAa,2BAA2B;AAoBxC,SAAS,oBAAoB,OAA4C;CACvE,IAAI,OAAO,UAAU,YAAY,OAAO;CAExC,OAAO,OADa,MAA4C,eACnC;;AAG/B,SAAS,eAA0B,QAA2B,OAA2B;CACvF,MAAM,SAAS,OAAO,MAAM;CAC5B,IAAI,kBAAkB,WACpB,MAAM,aACJ,yCACA,mDAAmD,OAAO,WAC1D;EAAE,SAAS;EAAuB,QAAQ,OAAO;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B"}
1
+ {"version":3,"file":"arktype-json-codec-BjUHsoD5.mjs","names":[],"sources":["../src/core/arktype-json-codec.ts"],"sourcesContent":["/**\n * Arktype-json codec (TML-2357).\n *\n * Spec § Case 3: method-level generic over `S extends Type<unknown>`. The schema's TypeScript-level inferred type `S['infer']` is only available at the column-author site (where the user passes their typed schema), not at the descriptor's factory site (where only the serialized IR is available). This drives the shape:\n *\n * 1. {@link ArktypeJsonCodecClass} extends {@link CodecImpl} and is generic over `TInferred` — the application-level JS type the schema validates to. The constructor takes both the descriptor (for `id` proxy) and the rehydrated arktype `Type` (closure-captured so encode/decode/encodeJson/decodeJson can validate through it). 2. {@link ArktypeJsonDescriptor} extends {@link CodecDescriptorImpl} over {@link\n * ArktypeJsonTypeParams}. Factory rehydrates the schema from `params.jsonIr` and returns `(ctx) => new ArktypeJsonCodecClass<unknown>(this, schema)` — `S` is erased to `unknown` because the descriptor only sees IR. The runtime path through `descriptor.factory(params)` always exists (e.g. for `family.deserializeContract` re-materialization); it just loses the typed inferred shape. 3. {@link arktypeJsonColumn} is the column-author\n * surface with the method-level generic over `S extends Type<unknown>`. It bypasses `descriptor.factory` because `S` is only available here, instead constructing the typed codec directly so `S['infer']` flows through `codecFactory`'s return into the column site's resolved output type. Eager serialization at this call site captures `expression` (for the emit-path renderer) and `jsonIr` (for runtime rehydration).\n *\n * `satisfies ColumnHelperFor<ArktypeJsonDescriptor>` (coarse) is applied — the typeParams shape is verified. `ColumnHelperForStrict` is intentionally skipped: the descriptor's factory return is `ArktypeJsonCodecClass<unknown>` while the helper produces `ArktypeJsonCodecClass<S['infer']>`, and `Codec`'s `TInput` is invariant (used contravariantly in `encode`, covariantly in `decode`/`encodeJson`/`decodeJson`). Strict\n * assignment fails by design; the explicit `expectTypeOf` tests in `test/arktype-json-codec.types.test-d.ts` cover the literal-preservation property the strict variant would otherwise enforce.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport {\n type AnyCodecDescriptor,\n type CodecCallContext,\n CodecDescriptorImpl,\n CodecImpl,\n type CodecInstanceContext,\n type ColumnHelperFor,\n type ColumnSpec,\n column,\n} from '@prisma-next/framework-components/codec';\nimport { isRuntimeError, runtimeError } from '@prisma-next/framework-components/runtime';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { ArkErrors, ark, type Type, type } from 'arktype';\n\n/** Codec id for arktype-backed JSON columns. Library-bound, not target-bound. */\nexport const ARKTYPE_JSON_CODEC_ID = 'arktype/json@1' as const;\n\n/** Native storage type backing the codec. JSONB on Postgres; binary, indexable. */\nexport const ARKTYPE_JSON_NATIVE_TYPE = 'jsonb' as const;\n\n/**\n * Eagerly serialized typeParams for the arktype-json column. Carried in the contract IR; the runtime descriptor's factory rehydrates `jsonIr` and the emitter consumes `expression`.\n */\nexport type ArktypeJsonTypeParams = {\n /**\n * Arktype's TypeScript-source-like rendering of the schema. Read by `renderOutputType` to emit the column's TS type into `contract.d.ts`. Stable across the serialize/rehydrate cycle: the rehydrated schema's `expression` matches the source schema's.\n */\n readonly expression: string;\n /**\n * Arktype's internal IR for the schema. Lossless; the rehydration source. Schema-shape — `ark.schema(jsonIr)` reconstructs a callable `Type`-like structurally identical to the original `type(definition)` output.\n */\n readonly jsonIr: object;\n};\n\ntype ArktypeSchemaLike = ((value: unknown) => unknown) & {\n readonly expression: string;\n};\n\nfunction isArktypeSchemaLike(value: unknown): value is ArktypeSchemaLike {\n if (typeof value !== 'function') return false;\n const expression = (value as { readonly expression?: unknown }).expression;\n return typeof expression === 'string';\n}\n\nfunction validateSchema<TInferred>(schema: ArktypeSchemaLike, value: unknown): TInferred {\n const result = schema(value);\n if (result instanceof ArkErrors) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n `arktype-json schema validation failed (decode): ${result.summary}`,\n { codecId: ARKTYPE_JSON_CODEC_ID, issues: result.summary },\n );\n }\n return result as TInferred;\n}\n\nfunction serializeWire<TInferred>(value: TInferred): string {\n const wire: string | undefined = JSON.stringify(value);\n if (typeof wire !== 'string') {\n throw new Error(\n `arktype-json value is not representable as JSON (codecId: ${ARKTYPE_JSON_CODEC_ID})`,\n );\n }\n return wire;\n}\n\nfunction serializeJson<TInferred>(value: TInferred): JsonValue {\n // The stringify → parse round-trip both validates JSON-representability\n // (matching `serializeWire`) and produces a deep-cloned `JsonValue` that\n // strips class prototypes / `toJSON` side effects, so callers reading\n // the in-memory `JsonValue` see exactly the shape that would round-trip\n // through the database.\n return JSON.parse(serializeWire(value)) as JsonValue;\n}\n\nfunction parseJsonText(wire: string): JsonValue | undefined {\n try {\n return JSON.parse(wire) as JsonValue;\n } catch {\n return undefined;\n }\n}\n\nfunction decodeWireValue<TInferred>(\n schema: ArktypeSchemaLike,\n wire: string | JsonValue,\n): TInferred {\n if (typeof wire !== 'string') return validateSchema<TInferred>(schema, wire);\n\n // Try the wire as the literal value first. Under `pg` + `jsonb` (the\n // documented native type), wire arrives already-parsed: a JSON object\n // surfaces as a JS object, a JSON string surfaces as a JS string. For\n // string columns that means the wire IS the user's value — including\n // strings whose literal characters happen to start and end with `\"`.\n // A `\"…\"`-shape unwrap heuristic would silently truncate them (the\n // 7-char `\"hello\"` would decode to the 5-char `hello`).\n //\n // Fall back to JSON.parse only when schema validation rejects the raw\n // wire: that path covers object/array shapes received as raw JSON\n // text (legacy `json` text-OID adapters, or any code path that hands\n // us un-pre-parsed JSON).\n try {\n return validateSchema<TInferred>(schema, wire);\n } catch (error) {\n if (!isRuntimeError(error) || error.code !== 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED') {\n throw error;\n }\n const parsed = parseJsonText(wire);\n if (parsed === undefined) {\n throw error;\n }\n return validateSchema<TInferred>(schema, parsed);\n }\n}\n\nfunction rehydrateSchema(jsonIr: object): ArktypeSchemaLike {\n let rehydrated: unknown;\n try {\n rehydrated = ark.schema(jsonIr);\n } catch (error) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n /* c8 ignore next — the `String(error)` fallback covers throws of non-Error values; arktype only throws Error subclasses, so this branch is defensive only. */\n `Failed to rehydrate arktype schema from contract IR: ${error instanceof Error ? error.message : String(error)}`,\n { codecId: ARKTYPE_JSON_CODEC_ID, jsonIr },\n );\n }\n /* c8 ignore start — defensive: ark.schema either throws (handled above) or returns a callable Type with `expression: string`. The structural guard is kept so a future ark internal change can't silently slip a non-callable past us. */\n if (!isArktypeSchemaLike(rehydrated)) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n `Rehydrated arktype schema does not have the expected callable + 'expression: string' shape (codecId: ${ARKTYPE_JSON_CODEC_ID})`,\n { codecId: ARKTYPE_JSON_CODEC_ID, jsonIr },\n );\n }\n /* c8 ignore stop */\n return rehydrated;\n}\n\nfunction renderArktypeJsonOutputType(params: ArktypeJsonTypeParams): string {\n const expression = params.expression.trim();\n return expression.length > 0 ? expression : 'unknown';\n}\n\nexport class ArktypeJsonCodecClass<TInferred> extends CodecImpl<\n typeof ARKTYPE_JSON_CODEC_ID,\n readonly ['equality'],\n string | JsonValue,\n TInferred\n> {\n constructor(\n descriptor: ArktypeJsonDescriptor,\n private readonly schema: ArktypeSchemaLike,\n ) {\n super(descriptor);\n }\n\n async encode(value: TInferred, _ctx: CodecCallContext): Promise<string> {\n return serializeWire(value);\n }\n\n async decode(wire: string | JsonValue, _ctx: CodecCallContext): Promise<TInferred> {\n return decodeWireValue<TInferred>(this.schema, wire);\n }\n\n encodeJson(value: TInferred): JsonValue {\n return serializeJson(value);\n }\n\n decodeJson(json: JsonValue): TInferred {\n return validateSchema<TInferred>(this.schema, json);\n }\n}\n\nconst arktypeJsonParamsSchema = type({\n expression: 'string',\n jsonIr: 'object',\n}) satisfies StandardSchemaV1<ArktypeJsonTypeParams>;\n\nconst ARKTYPE_JSON_META = { db: { sql: { postgres: { nativeType: 'jsonb' } } } } as const;\n\nexport class ArktypeJsonDescriptor extends CodecDescriptorImpl<ArktypeJsonTypeParams> {\n override readonly codecId = ARKTYPE_JSON_CODEC_ID;\n override readonly traits = ['equality'] as const;\n override readonly targetTypes = [ARKTYPE_JSON_NATIVE_TYPE] as const;\n override readonly meta = ARKTYPE_JSON_META;\n override readonly paramsSchema: StandardSchemaV1<ArktypeJsonTypeParams> = arktypeJsonParamsSchema;\n override renderOutputType(params: ArktypeJsonTypeParams): string {\n return renderArktypeJsonOutputType(params);\n }\n override factory(\n params: ArktypeJsonTypeParams,\n ): (ctx: CodecInstanceContext) => ArktypeJsonCodecClass<unknown> {\n const schema = rehydrateSchema(params.jsonIr);\n const rehydratedExpression = (schema as { readonly expression?: unknown }).expression;\n if (typeof rehydratedExpression === 'string' && rehydratedExpression !== params.expression) {\n throw runtimeError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `arktype-json: typeParams.expression (${params.expression}) does not match the rehydrated schema's expression (${rehydratedExpression}). The contract was likely emitted against a different arktype version or hand-edited; re-run \\`pnpm emit\\` to regenerate.`,\n {\n codecId: ARKTYPE_JSON_CODEC_ID,\n serializedExpression: params.expression,\n rehydratedExpression,\n },\n );\n }\n return () => new ArktypeJsonCodecClass<unknown>(this, schema);\n }\n}\n\nexport const arktypeJsonDescriptor = new ArktypeJsonDescriptor();\n\n/**\n * Per-codec column helper for `arktype/json@1`. Method-level generic over `S extends Type<unknown>` so the column site preserves the schema's inferred TS type in the resolved codec (`ArktypeJsonCodecClass<S['infer']>`). Bypasses `descriptor.factory` because `S` is only available at the column-author site; constructs the typed codec directly with the closure-captured schema.\n *\n * Eager serialization at this call site captures `expression` (for the emit-path renderer) and `jsonIr` (for runtime rehydration via the descriptor's factory).\n *\n * @throws {Error} if the schema doesn't expose `expression` and `json` fields (i.e. is not an arktype `Type`). Validates the schema shape at the call site so configuration errors surface during contract authoring, not at runtime.\n */\nexport function arktypeJsonColumn<S extends Type<unknown>>(\n schema: S,\n): ColumnSpec<ArktypeJsonCodecClass<S['infer']>, ArktypeJsonTypeParams> {\n if (!isArktypeSchemaLike(schema)) {\n throw new Error(\n typeof schema !== 'function'\n ? 'arktypeJsonColumn(schema) expects a callable arktype Type.'\n : 'arktypeJsonColumn(schema) expects an arktype Type (missing `expression: string`).',\n );\n }\n const jsonIr: unknown = (schema as { readonly json?: unknown }).json;\n if (jsonIr === null || typeof jsonIr !== 'object') {\n throw new Error('arktypeJsonColumn(schema) expects an arktype Type (missing `json` IR).');\n }\n const params: ArktypeJsonTypeParams = { expression: schema.expression, jsonIr };\n return column(\n (_ctx: CodecInstanceContext) =>\n new ArktypeJsonCodecClass<S['infer']>(arktypeJsonDescriptor, schema),\n arktypeJsonDescriptor.codecId,\n params,\n ARKTYPE_JSON_NATIVE_TYPE,\n );\n}\n\narktypeJsonColumn satisfies ColumnHelperFor<ArktypeJsonDescriptor>;\n// Note: `ColumnHelperForStrict` is intentionally not applied — `Codec` is invariant in `TInput` (encode contravariant, decode covariant), so `ArktypeJsonCodecClass<S['infer']>` is not assignable to `ArktypeJsonCodecClass<unknown>` (the descriptor.factory return). `expectTypeOf` tests cover the literal-preservation property strict satisfies would otherwise enforce.\n\n/**\n * Codec instance returned by `arktypeJsonColumn(schema).codecFactory(ctx)` and by `arktypeJsonDescriptor.factory(typeParams)(ctx)`. The `TInferred` slot carries the arktype schema's inferred output type at the column-author site; descriptor-side factories erase to `unknown`.\n */\nexport type ArktypeJsonCodec<TInferred> = ArktypeJsonCodecClass<TInferred>;\n\nexport const codecDescriptors: readonly AnyCodecDescriptor[] = [arktypeJsonDescriptor];\n"],"mappings":";;;;;AA6BA,MAAa,wBAAwB;;AAGrC,MAAa,2BAA2B;AAoBxC,SAAS,oBAAoB,OAA4C;CACvE,IAAI,OAAO,UAAU,YAAY,OAAO;CAExC,OAAO,OADa,MAA4C,eACnC;AAC/B;AAEA,SAAS,eAA0B,QAA2B,OAA2B;CACvF,MAAM,SAAS,OAAO,KAAK;CAC3B,IAAI,kBAAkB,WACpB,MAAM,aACJ,yCACA,mDAAmD,OAAO,WAC1D;EAAE,SAAS;EAAuB,QAAQ,OAAO;CAAQ,CAC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,uBAAuB,MAAM,GACrE,sBAAsB,SACtB,QACA,wBACF;AACF;AAUA,MAAa,mBAAkD,CAAC,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types-DY2DS594.d.mts","names":[],"sources":["../src/types/codec-types.ts"],"mappings":";;AAiBA;;;;;;;;;;;;;;;KAAY,UAAA;EAAA,SACD,gBAAA;IAAA,SACE,KAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"codec-types-DY2DS594.d.mts","names":[],"sources":["../src/types/codec-types.ts"],"mappings":";;AAiBA;;;;;;;;;AAImB;;;;;;KAJP,UAAA;EAAA,SACD,gBAAA;IAAA,SACE,KAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"codecs.d.mts","names":[],"sources":["../src/core/registry.ts"],"mappings":";;;;;;;AASA;;cAAa,wBAAA,EAA0B,uBAAA"}
1
+ {"version":3,"file":"codecs.d.mts","names":[],"sources":["../src/core/registry.ts"],"mappings":";;;;;;;AASA;;cAAa,wBAAA,EAA0B,uBACS"}
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cA0Ba,8BAAA,EAAgC,6BAAA"}
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;cA0Ba,8BAAA,EAAgC,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":["/**\n * Control-plane extension descriptor for arktype-json.\n *\n * Composes pack metadata and the control-plane hooks into the migration-\n * plane shape the framework's control stack consumes. Lives at the\n * control-plane entrypoint so `src/core/**` stays free of migration-plane\n * imports (per `.cursor/rules/multi-plane-entrypoints.mdc`).\n *\n * Unlike pgvector, arktype-json has no database extension to install\n * (`jsonb` is a built-in Postgres type), no contract space, no query\n * operations, and the only control-plane hook is the identity\n * `expandNativeType` (jsonb is dimension-free; the schema in typeParams\n * affects runtime validation only, never DDL).\n */\n\nimport type {\n CodecControlHooks,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { ARKTYPE_JSON_CODEC_ID } from '../core/arktype-json-codec';\nimport { arktypeJsonPackMeta } from '../core/pack-meta';\n\nconst arktypeJsonControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType }) => nativeType,\n};\n\nexport const arktypeJsonExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...arktypeJsonPackMeta,\n types: {\n ...arktypeJsonPackMeta.types,\n codecTypes: {\n ...arktypeJsonPackMeta.types.codecTypes,\n controlPlaneHooks: {\n [ARKTYPE_JSON_CODEC_ID]: arktypeJsonControlPlaneHooks,\n },\n },\n },\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport default arktypeJsonExtensionDescriptor;\n"],"mappings":";;;AAsBA,MAAM,+BAAkD,EACtD,mBAAmB,EAAE,iBAAiB,YACvC;AAED,MAAa,iCAA4E;CACvF,GAAG;CACH,OAAO;EACL,GAAG,oBAAoB;EACvB,YAAY;GACV,GAAG,oBAAoB,MAAM;GAC7B,mBAAmB,GAChB,wBAAwB,8BAC1B;GACF;EACF;CACD,eAAe;EACb,UAAU;EACV,UAAU;EACX;CACF"}
1
+ {"version":3,"file":"control.mjs","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":["/**\n * Control-plane extension descriptor for arktype-json.\n *\n * Composes pack metadata and the control-plane hooks into the migration-\n * plane shape the framework's control stack consumes. Lives at the\n * control-plane entrypoint so `src/core/**` stays free of migration-plane\n * imports (per `.cursor/rules/multi-plane-entrypoints.mdc`).\n *\n * Unlike pgvector, arktype-json has no database extension to install\n * (`jsonb` is a built-in Postgres type), no contract space, no query\n * operations, and the only control-plane hook is the identity\n * `expandNativeType` (jsonb is dimension-free; the schema in typeParams\n * affects runtime validation only, never DDL).\n */\n\nimport type {\n CodecControlHooks,\n SqlControlExtensionDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { ARKTYPE_JSON_CODEC_ID } from '../core/arktype-json-codec';\nimport { arktypeJsonPackMeta } from '../core/pack-meta';\n\nconst arktypeJsonControlPlaneHooks: CodecControlHooks = {\n expandNativeType: ({ nativeType }) => nativeType,\n};\n\nexport const arktypeJsonExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'> = {\n ...arktypeJsonPackMeta,\n types: {\n ...arktypeJsonPackMeta.types,\n codecTypes: {\n ...arktypeJsonPackMeta.types.codecTypes,\n controlPlaneHooks: {\n [ARKTYPE_JSON_CODEC_ID]: arktypeJsonControlPlaneHooks,\n },\n },\n },\n create: () => ({\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n }),\n};\n\nexport default arktypeJsonExtensionDescriptor;\n"],"mappings":";;;AAsBA,MAAM,+BAAkD,EACtD,mBAAmB,EAAE,iBAAiB,WACxC;AAEA,MAAa,iCAA4E;CACvF,GAAG;CACH,OAAO;EACL,GAAG,oBAAoB;EACvB,YAAY;GACV,GAAG,oBAAoB,MAAM;GAC7B,mBAAmB,GAChB,wBAAwB,6BAC3B;EACF;CACF;CACA,eAAe;EACb,UAAU;EACV,UAAU;CACZ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"pack-meta-DA3cXkds.mjs","names":[],"sources":["../src/core/pack-meta.ts"],"sourcesContent":["/**\n * arktype-json pack metadata.\n *\n * The pack metadata is the framework-composition entry point: control-stack assembly reads `types.codecTypes.import` to thread the type-side imports into emitted `contract.d.ts`, and `types.storage` declares the codec id's storage backing (`jsonb` on Postgres).\n *\n * Per TML-2357 runtime materialization flows through the unified descriptor map (`arktypeJsonDescriptor`) and the emit path consults `descriptorFor('arktype/json@1').renderOutputType` directly — no per-library \"emit-only Codec\" stub.\n */\n\nimport type { CodecTypes } from '../types/codec-types';\nimport { ARKTYPE_JSON_CODEC_ID } from './arktype-json-codec';\nimport { arktypeJsonCodecRegistry } from './registry';\n\nconst arktypeJsonPackMetaBase = {\n kind: 'extension',\n id: 'arktype-json',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {},\n types: {\n codecTypes: {\n codecDescriptors: Array.from(arktypeJsonCodecRegistry.values()),\n import: {\n package: '@prisma-next/extension-arktype-json/codec-types',\n named: 'CodecTypes',\n alias: 'ArktypeJsonTypes',\n },\n },\n storage: [\n {\n typeId: ARKTYPE_JSON_CODEC_ID,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n nativeType: 'jsonb',\n },\n ],\n },\n} as const;\n\n/**\n * Public pack metadata. The phantom `__codecTypes` field threads the codec-types map's literal type into the pack ref so contract-builder generics can pick it up; it is never accessed at runtime.\n */\nexport const arktypeJsonPackMeta: typeof arktypeJsonPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = arktypeJsonPackMetaBase;\n"],"mappings":";;;;;AA0CA,MAAa,sBAET;CA/BF,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EAAE;CAChB,OAAO;EACL,YAAY;GACV,kBAAkB,MAAM,KAAK,yBAAyB,QAAQ,CAAC;GAC/D,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACF;EACD,SAAS,CACP;GACE,QAAQ;GACR,UAAU;GACV,UAAU;GACV,YAAY;GACb,CACF;EACF;CAQC"}
1
+ {"version":3,"file":"pack-meta-DA3cXkds.mjs","names":[],"sources":["../src/core/pack-meta.ts"],"sourcesContent":["/**\n * arktype-json pack metadata.\n *\n * The pack metadata is the framework-composition entry point: control-stack assembly reads `types.codecTypes.import` to thread the type-side imports into emitted `contract.d.ts`, and `types.storage` declares the codec id's storage backing (`jsonb` on Postgres).\n *\n * Per TML-2357 runtime materialization flows through the unified descriptor map (`arktypeJsonDescriptor`) and the emit path consults `descriptorFor('arktype/json@1').renderOutputType` directly — no per-library \"emit-only Codec\" stub.\n */\n\nimport type { CodecTypes } from '../types/codec-types';\nimport { ARKTYPE_JSON_CODEC_ID } from './arktype-json-codec';\nimport { arktypeJsonCodecRegistry } from './registry';\n\nconst arktypeJsonPackMetaBase = {\n kind: 'extension',\n id: 'arktype-json',\n familyId: 'sql',\n targetId: 'postgres',\n version: '0.0.1',\n capabilities: {},\n types: {\n codecTypes: {\n codecDescriptors: Array.from(arktypeJsonCodecRegistry.values()),\n import: {\n package: '@prisma-next/extension-arktype-json/codec-types',\n named: 'CodecTypes',\n alias: 'ArktypeJsonTypes',\n },\n },\n storage: [\n {\n typeId: ARKTYPE_JSON_CODEC_ID,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n nativeType: 'jsonb',\n },\n ],\n },\n} as const;\n\n/**\n * Public pack metadata. The phantom `__codecTypes` field threads the codec-types map's literal type into the pack ref so contract-builder generics can pick it up; it is never accessed at runtime.\n */\nexport const arktypeJsonPackMeta: typeof arktypeJsonPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = arktypeJsonPackMetaBase;\n"],"mappings":";;;;;AA0CA,MAAa,sBAET;CA/BF,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,CAAC;CACf,OAAO;EACL,YAAY;GACV,kBAAkB,MAAM,KAAK,yBAAyB,OAAO,CAAC;GAC9D,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;GACT;EACF;EACA,SAAS,CACP;GACE,QAAQ;GACR,UAAU;GACV,UAAU;GACV,YAAY;EACd,CACF;CACF;AAQE"}
@@ -1 +1 @@
1
- {"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/pack-meta.ts"],"mappings":";;;;cAYM,uBAAA;EAAA;;;;;;;;iCAyBI,0CAAA,CAAA,eAAA;MAAA;;;;;;;;;;;;;;;;;cAKG,mBAAA,SAA4B,uBAAA;EAAA,SAC9B,YAAA,GAAe,UAAA;AAAA"}
1
+ {"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/pack-meta.ts"],"mappings":";;;;cAYM,uBAAA;EAAA;;;;;;;;iCAyBI,0CAAA,CAAA,eAAA;MAAA;;;;;;;;;;;;;;;;;cAKG,mBAAA,SAA4B,uBAAA;EAAA,SAC9B,YAAA,GAAe,UAAU;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"registry-CkZprj2g.mjs","names":[],"sources":["../src/core/registry.ts"],"sourcesContent":["import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './arktype-json-codec';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/extension-arktype-json`.\n *\n * Public consumer surface for the arktype-json codec set. Currently a single entry (`arktype/json@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.\n */\nexport const arktypeJsonCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n"],"mappings":";;;;;;;;AASA,MAAa,2BACX,6BAA6B,iBAAiB"}
1
+ {"version":3,"file":"registry-CkZprj2g.mjs","names":[],"sources":["../src/core/registry.ts"],"sourcesContent":["import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { codecDescriptors } from './arktype-json-codec';\n\n/**\n * Registry of every codec descriptor shipped by `@prisma-next/extension-arktype-json`.\n *\n * Public consumer surface for the arktype-json codec set. Currently a single entry (`arktype/json@1`); the registry shape stays consistent with the other codec-shipping packages so consumers don't need to special-case extensions. See ADR 208.\n */\nexport const arktypeJsonCodecRegistry: CodecDescriptorRegistry =\n buildCodecDescriptorRegistry(codecDescriptors);\n"],"mappings":";;;;;;;;AASA,MAAa,2BACX,6BAA6B,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"mappings":";;;cAYa,4BAAA,EAA8B,6BAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"mappings":";;;cAYa,4BAAA,EAA8B,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["/**\n * Runtime-plane extension descriptor for arktype-json.\n *\n * Registers `arktypeJsonCodec` (the unified `CodecDescriptor`) through the SQL runtime's `codecs:` slot. Per TML-2357 the dedicated parameterized-codec slot retired — the unified descriptor map dispatches every codec id, parameterized or not.\n *\n * Lives at the runtime-plane entrypoint so `src/core/**` stays free of runtime-plane imports (per `.cursor/rules/multi-plane-entrypoints.mdc`).\n */\n\nimport type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';\nimport { arktypeJsonPackMeta } from '../core/pack-meta';\nimport { arktypeJsonCodecRegistry } from '../core/registry';\n\nexport const arktypeJsonRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {\n kind: 'extension' as const,\n id: arktypeJsonPackMeta.id,\n version: arktypeJsonPackMeta.version,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n types: {\n codecTypes: {\n codecDescriptors: Array.from(arktypeJsonCodecRegistry.values()),\n },\n },\n codecs: () => Array.from(arktypeJsonCodecRegistry.values()),\n create() {\n return {\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n };\n },\n};\n\nexport default arktypeJsonRuntimeDescriptor;\n"],"mappings":";;;AAYA,MAAa,+BAA0E;CACrF,MAAM;CACN,IAAI,oBAAoB;CACxB,SAAS,oBAAoB;CAC7B,UAAU;CACV,UAAU;CACV,OAAO,EACL,YAAY,EACV,kBAAkB,MAAM,KAAK,yBAAyB,QAAQ,CAAC,EAChE,EACF;CACD,cAAc,MAAM,KAAK,yBAAyB,QAAQ,CAAC;CAC3D,SAAS;EACP,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["/**\n * Runtime-plane extension descriptor for arktype-json.\n *\n * Registers `arktypeJsonCodec` (the unified `CodecDescriptor`) through the SQL runtime's `codecs:` slot. Per TML-2357 the dedicated parameterized-codec slot retired — the unified descriptor map dispatches every codec id, parameterized or not.\n *\n * Lives at the runtime-plane entrypoint so `src/core/**` stays free of runtime-plane imports (per `.cursor/rules/multi-plane-entrypoints.mdc`).\n */\n\nimport type { SqlRuntimeExtensionDescriptor } from '@prisma-next/sql-runtime';\nimport { arktypeJsonPackMeta } from '../core/pack-meta';\nimport { arktypeJsonCodecRegistry } from '../core/registry';\n\nexport const arktypeJsonRuntimeDescriptor: SqlRuntimeExtensionDescriptor<'postgres'> = {\n kind: 'extension' as const,\n id: arktypeJsonPackMeta.id,\n version: arktypeJsonPackMeta.version,\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n types: {\n codecTypes: {\n codecDescriptors: Array.from(arktypeJsonCodecRegistry.values()),\n },\n },\n codecs: () => Array.from(arktypeJsonCodecRegistry.values()),\n create() {\n return {\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n };\n },\n};\n\nexport default arktypeJsonRuntimeDescriptor;\n"],"mappings":";;;AAYA,MAAa,+BAA0E;CACrF,MAAM;CACN,IAAI,oBAAoB;CACxB,SAAS,oBAAoB;CAC7B,UAAU;CACV,UAAU;CACV,OAAO,EACL,YAAY,EACV,kBAAkB,MAAM,KAAK,yBAAyB,OAAO,CAAC,EAChE,EACF;CACA,cAAc,MAAM,KAAK,yBAAyB,OAAO,CAAC;CAC1D,SAAS;EACP,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
package/package.json CHANGED
@@ -1,28 +1,36 @@
1
1
  {
2
2
  "name": "@prisma-next/extension-arktype-json",
3
- "version": "0.11.0-dev.9",
3
+ "version": "0.12.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@prisma-next/contract": "0.11.0-dev.9",
9
- "@prisma-next/contract-authoring": "0.11.0-dev.9",
10
- "@prisma-next/family-sql": "0.11.0-dev.9",
11
- "@prisma-next/framework-components": "0.11.0-dev.9",
12
- "@prisma-next/sql-relational-core": "0.11.0-dev.9",
13
- "@prisma-next/sql-runtime": "0.11.0-dev.9",
8
+ "@prisma-next/contract": "0.12.0",
9
+ "@prisma-next/contract-authoring": "0.12.0",
10
+ "@prisma-next/family-sql": "0.12.0",
11
+ "@prisma-next/framework-components": "0.12.0",
12
+ "@prisma-next/sql-relational-core": "0.12.0",
13
+ "@prisma-next/sql-runtime": "0.12.0",
14
14
  "@standard-schema/spec": "^1.1.0",
15
15
  "arktype": "~2.2.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@prisma-next/sql-contract": "0.11.0-dev.9",
19
- "@prisma-next/test-utils": "0.11.0-dev.9",
20
- "@prisma-next/tsconfig": "0.11.0-dev.9",
21
- "@prisma-next/tsdown": "0.11.0-dev.9",
18
+ "@prisma-next/sql-contract": "0.12.0",
19
+ "@prisma-next/test-utils": "0.12.0",
20
+ "@prisma-next/tsconfig": "0.12.0",
21
+ "@prisma-next/tsdown": "0.12.0",
22
22
  "tsdown": "0.22.0",
23
23
  "typescript": "5.9.3",
24
24
  "vitest": "4.1.6"
25
25
  },
26
+ "peerDependencies": {
27
+ "typescript": ">=5.9"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "typescript": {
31
+ "optional": true
32
+ }
33
+ },
26
34
  "files": [
27
35
  "dist",
28
36
  "src"
@@ -36,6 +44,9 @@
36
44
  "./runtime": "./dist/runtime.mjs",
37
45
  "./package.json": "./package.json"
38
46
  },
47
+ "engines": {
48
+ "node": ">=24"
49
+ },
39
50
  "repository": {
40
51
  "type": "git",
41
52
  "url": "https://github.com/prisma/prisma-next.git",