@prisma-next/extension-arktype-json 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # `@prisma-next/extension-arktype-json`
2
+
3
+ Per-library JSON-with-schema column factory for Prisma Next, built on
4
+ [arktype](https://arktype.io). Ships the `arktypeJson(schema)` column-author
5
+ helper and the `arktype/json@1` codec descriptor.
6
+
7
+ ## What it does
8
+
9
+ Given an arktype `Type`, `arktypeJson(schema)` produces a column descriptor
10
+ that:
11
+
12
+ - Stores values as `jsonb` on Postgres.
13
+ - Eagerly serializes `schema.expression` (TypeScript-source-like rendering)
14
+ and `schema.json` (arktype's internal IR) into `typeParams`. The IR is the
15
+ lossless rehydration source; the expression is the emit-path renderer's
16
+ input.
17
+ - At runtime, the framework's unified codec descriptor map rehydrates the
18
+ schema via `ark.schema(typeParams.jsonIr)` and returns a `Codec` whose
19
+ `decode` validates wire payloads via the rehydrated schema. Validation
20
+ failures throw `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED`.
21
+ - The emitter renders the column's TS type as the schema's `expression`
22
+ (e.g. `{ name: string; price: number }`).
23
+
24
+ ## Why a per-library extension
25
+
26
+ The unified `CodecDescriptor` model routes JSON-with-schema through per-
27
+ library extension packages: arktype-json now, future zod / valibot
28
+ extensions when each has a clean serialize / rehydrate story. The Postgres
29
+ adapter retains only the storage-level `jsonColumn` / `jsonbColumn`
30
+ descriptors (untyped raw JSON). See [ADR 208 — Higher-order codecs for parameterized types](../../../docs/architecture%20docs/adrs/ADR%20208%20-%20Higher-order%20codecs%20for%20parameterized%20types.md).
31
+
32
+ ## Usage
33
+
34
+ ```ts
35
+ import { type } from 'arktype';
36
+ import { arktypeJson } from '@prisma-next/extension-arktype-json/column-types';
37
+ import { defineContract, field, model } from '@prisma-next/sql-contract-ts/contract-builder';
38
+
39
+ const ProductSchema = type({ name: 'string', price: 'number', 'description?': 'string' });
40
+
41
+ const contract = defineContract({ /* ... */ }, ({ field, model }) => ({
42
+ models: {
43
+ Product: model('Product', {
44
+ fields: {
45
+ id: field.id.uuidv4(),
46
+ spec: field.column(arktypeJson(ProductSchema)),
47
+ // ^? Type<{ name: string; price: number; description?: string }>
48
+ },
49
+ }).sql({ table: 'product' }),
50
+ },
51
+ }));
52
+ ```
53
+
54
+ In the emitted `contract.d.ts`, `Product.spec` resolves to
55
+ `{ name: string; price: number; description?: string }` — the schema's
56
+ expression renders directly into the field type.
57
+
58
+ ## Pack registration
59
+
60
+ Add the runtime descriptor to your runtime stack and the control descriptor
61
+ to your `prisma-next.config.ts` `extensionPacks`:
62
+
63
+ ```ts
64
+ import arktypeJsonPack from '@prisma-next/extension-arktype-json/pack';
65
+ import arktypeJsonRuntime from '@prisma-next/extension-arktype-json/runtime';
66
+
67
+ // prisma-next.config.ts
68
+ export default {
69
+ extensionPacks: { arktypeJson: arktypeJsonPack },
70
+ // ...
71
+ };
72
+
73
+ // runtime
74
+ const stack = createSqlExecutionStack({
75
+ target: postgresTarget,
76
+ adapter: postgresAdapter,
77
+ extensionPacks: [arktypeJsonRuntime],
78
+ });
79
+ ```
80
+
81
+ ## Notes
82
+
83
+ - The codec is library-bound (`arktype/json@1`), not target-bound. Other
84
+ schema libraries ship as parallel extensions (`zod/json@1`,
85
+ `valibot/json@1`) when their serialize/rehydrate stories materialize.
86
+ - `decode` validates internally and throws on rejection; the framework's
87
+ `JsonSchemaValidatorRegistry` is not consulted for arktype-json columns
88
+ (no `'json-validator'` trait + per-instance `validate` extraction). The
89
+ one-path "validate inside `decode`" matches the spec's Case J pinning.
90
+ - For untyped raw JSON columns, use `jsonColumn` / `jsonbColumn` from
91
+ `@prisma-next/adapter-postgres/column-types` instead.
@@ -0,0 +1,224 @@
1
+ import { runtimeError } from "@prisma-next/framework-components/runtime";
2
+ import { codec } from "@prisma-next/sql-relational-core/ast";
3
+ import { ArkErrors, ark, type } from "arktype";
4
+
5
+ //#region src/core/arktype-json-codec.ts
6
+ /** Codec id for arktype-backed JSON columns. Library-bound, not target-bound. */
7
+ const ARKTYPE_JSON_CODEC_ID = "arktype/json@1";
8
+ /** Native storage type backing the codec. JSONB on Postgres; binary, indexable. */
9
+ const ARKTYPE_JSON_NATIVE_TYPE = "jsonb";
10
+ /**
11
+ * Type predicate for `ArktypeSchemaLike`. Lets the column-author
12
+ * factory narrow `unknown` schemas to the structural shape the codec
13
+ * depends on after the explicit field guards run, so the descriptor
14
+ * builder doesn't fall back to a `as unknown as` cast.
15
+ */
16
+ function isArktypeSchemaLike(value) {
17
+ if (typeof value !== "function") return false;
18
+ return typeof value.expression === "string";
19
+ }
20
+ /**
21
+ * Build the curried factory for a rehydrated arktype schema. The factory's
22
+ * returned codec carries the schema in its closure; `decode` validates
23
+ * wire payloads via `schema(parsed)`, throwing
24
+ * `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED` on rejection.
25
+ *
26
+ * Encode is `JSON.stringify` — the schema validates the input shape only
27
+ * at the read boundary (decode), matching the JSON-validator philosophy:
28
+ * the payload may have been written by any source (this writer, a
29
+ * previous version of the schema, a manual SQL `INSERT`); validate when
30
+ * reading, not when writing.
31
+ *
32
+ * Author bodies are sync; main's `codec({...})` factory promise-lifts
33
+ * `encode`/`decode` into the framework-required `Promise<…>` boundary
34
+ * shape (per ADR 204).
35
+ */
36
+ function arktypeJsonCodecForSchema(schema) {
37
+ function validateSchema(value) {
38
+ const result = schema(value);
39
+ if (result instanceof ArkErrors) throw runtimeError("RUNTIME.JSON_SCHEMA_VALIDATION_FAILED", `arktype-json schema validation failed (decode): ${result.summary}`, {
40
+ codecId: ARKTYPE_JSON_CODEC_ID,
41
+ issues: result.summary
42
+ });
43
+ return result;
44
+ }
45
+ function serializeToJsonSafe(value) {
46
+ const wire = JSON.stringify(value);
47
+ if (typeof wire !== "string") throw runtimeError("RUNTIME.JSON_SCHEMA_VALIDATION_FAILED", `arktype-json value is not representable as JSON (codecId: ${ARKTYPE_JSON_CODEC_ID})`, { codecId: ARKTYPE_JSON_CODEC_ID });
48
+ const json = JSON.parse(wire);
49
+ validateSchema(json);
50
+ return {
51
+ wire,
52
+ json
53
+ };
54
+ }
55
+ return (_ctx) => codec({
56
+ typeId: ARKTYPE_JSON_CODEC_ID,
57
+ targetTypes: [ARKTYPE_JSON_NATIVE_TYPE],
58
+ traits: ["equality"],
59
+ encode: (value) => serializeToJsonSafe(value).wire,
60
+ decode: (wire) => validateSchema(JSON.parse(wire)),
61
+ encodeJson: (value) => serializeToJsonSafe(value).json,
62
+ decodeJson: (json) => validateSchema(json)
63
+ });
64
+ }
65
+ /**
66
+ * Curried column-author factory for arktype-validated JSON columns.
67
+ *
68
+ * Usage:
69
+ *
70
+ * ```ts
71
+ * import { type } from 'arktype';
72
+ * import { arktypeJson } from '@prisma-next/extension-arktype-json/column-types';
73
+ *
74
+ * const ProductSchema = type({ name: 'string', price: 'number' });
75
+ *
76
+ * const Product = {
77
+ * columns: {
78
+ * id: textCodec,
79
+ * settings: arktypeJson(ProductSchema),
80
+ * // ^? ColumnTypeDescriptor with type :: (ctx) => Codec<…, { name: string; price: number }>
81
+ * },
82
+ * };
83
+ * ```
84
+ *
85
+ * The schema's inferred output flows through `S['infer']` so the no-emit
86
+ * `FieldOutputType` resolver produces the precise TS type at the column
87
+ * site. Eager serialization at this call site captures `expression` (for
88
+ * the emit-path renderer) and `jsonIr` (for runtime rehydration).
89
+ *
90
+ * @throws {Error} if the schema doesn't expose `expression` and `json`
91
+ * fields (i.e. is not an arktype `Type`). The factory validates the
92
+ * schema shape at the call site so configuration errors surface during
93
+ * contract authoring, not at runtime.
94
+ */
95
+ function arktypeJson(schema) {
96
+ if (!isArktypeSchemaLike(schema)) throw new Error(typeof schema !== "function" ? "arktypeJson(schema) expects a callable arktype Type." : "arktypeJson(schema) expects an arktype Type (missing `expression: string`).");
97
+ const jsonIr = schema.json;
98
+ if (jsonIr === null || typeof jsonIr !== "object") throw new Error("arktypeJson(schema) expects an arktype Type (missing `json` IR).");
99
+ return {
100
+ codecId: ARKTYPE_JSON_CODEC_ID,
101
+ nativeType: ARKTYPE_JSON_NATIVE_TYPE,
102
+ typeParams: {
103
+ expression: schema.expression,
104
+ jsonIr
105
+ },
106
+ type: arktypeJsonCodecForSchema(schema)
107
+ };
108
+ }
109
+ /**
110
+ * Standard Schema validator for the descriptor's typeParams. Asserts the
111
+ * shape `{ expression: string; jsonIr: object }` at the contract IR
112
+ * boundary; deeper IR-shape validation happens implicitly when
113
+ * `ark.schema(jsonIr)` reparses (corrupt IR throws there).
114
+ *
115
+ * Eats its own dog food: the validator is itself an arktype schema.
116
+ */
117
+ const arktypeJsonParamsSchema = type({
118
+ expression: "string",
119
+ jsonIr: "object"
120
+ });
121
+ /**
122
+ * Rehydrate an arktype schema from the serialized IR. Throws a clean
123
+ * error if the IR is corrupt — the "corruption-of-contract.json" case.
124
+ */
125
+ function rehydrateSchema(jsonIr) {
126
+ try {
127
+ return ark.schema(jsonIr);
128
+ } catch (error) {
129
+ throw runtimeError("RUNTIME.JSON_SCHEMA_VALIDATION_FAILED", `Failed to rehydrate arktype schema from contract IR: ${error instanceof Error ? error.message : String(error)}`, {
130
+ codecId: ARKTYPE_JSON_CODEC_ID,
131
+ jsonIr
132
+ });
133
+ }
134
+ }
135
+ /**
136
+ * Render the emit-path TS type for an arktype-json column. Reads the
137
+ * eagerly-extracted `expression` directly — the round-trip stability
138
+ * guarantee (rehydrated schema's `expression` matches the source's)
139
+ * means the rendered output is consistent across serialize/rehydrate.
140
+ */
141
+ function renderArktypeJsonOutputType(params) {
142
+ const expression = params.expression.trim();
143
+ return expression.length > 0 ? expression : "unknown";
144
+ }
145
+ /**
146
+ * Build a permissive `renderOutputType` that accepts the framework's
147
+ * generic typeParams shape and dispatches to the type-narrow renderer
148
+ * once the input is structurally an `ArktypeJsonTypeParams`.
149
+ */
150
+ function renderArktypeJsonOutputTypeFromUnknownParams(typeParams) {
151
+ const expression = typeParams["expression"];
152
+ const jsonIr = typeParams["jsonIr"];
153
+ if (typeof expression !== "string" || jsonIr === null || typeof jsonIr !== "object") return;
154
+ return renderArktypeJsonOutputType({
155
+ expression,
156
+ jsonIr
157
+ });
158
+ }
159
+ /**
160
+ * Emit-only `Codec` instance for `arktype/json@1`. Threaded through the
161
+ * pack-meta's `codecInstances` array so the emitter's `CodecLookup` can
162
+ * find a `renderOutputType` for the codec id (the emitter consults the
163
+ * codec-id-keyed `CodecLookup` at the framework boundary; the unified
164
+ * descriptor's `renderOutputType` is the long-term home for the renderer
165
+ * but the emit-path glue still routes through `CodecLookup`).
166
+ *
167
+ * All conversion methods are sentinels that throw if invoked — runtime
168
+ * materialization always goes through `arktypeJsonCodec.factory`'s
169
+ * curried `(params) => (ctx) => Codec`, never through this instance.
170
+ * `encodeJson`/`decodeJson` throw alongside `encode`/`decode` so a
171
+ * mistaken contract-load that resolved to this stub fails fast at the
172
+ * JSON boundary instead of silently returning unvalidated payloads. A
173
+ * future cleanup could route the emit path through the descriptor map
174
+ * directly and retire this shim.
175
+ */
176
+ const ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR = "arktype-json codec instances must be materialized via the descriptor factory; this is an emit-only stub";
177
+ const arktypeJsonEmitCodec = {
178
+ id: ARKTYPE_JSON_CODEC_ID,
179
+ targetTypes: [ARKTYPE_JSON_NATIVE_TYPE],
180
+ traits: ["equality"],
181
+ encode: () => Promise.reject(new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR)),
182
+ decode: () => Promise.reject(new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR)),
183
+ encodeJson: () => {
184
+ throw new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR);
185
+ },
186
+ decodeJson: () => {
187
+ throw new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR);
188
+ },
189
+ renderOutputType: renderArktypeJsonOutputTypeFromUnknownParams
190
+ };
191
+ /**
192
+ * Framework-registration descriptor for the arktype-json codec. Registered
193
+ * through the SQL runtime's `parameterizedCodecs:` slot. `sql-runtime`'s
194
+ * `initializeTypeHelpers` (and per-column walk in
195
+ * `buildContractCodecRegistry`) calls `arktypeJsonCodec.factory(typeParams)
196
+ * (ctx)` once per `storage.types` instance (or once per inline-typeParams
197
+ * column) to materialize the resolved codec carrying the rehydrated
198
+ * schema.
199
+ *
200
+ * Per Phase B of codec-registry-unification, `descriptorFor('arktype/json@1')`
201
+ * returns this descriptor and its `traits`/`targetTypes` are the codec-id-
202
+ * keyed source of truth — no parallel placeholder on the legacy `codecs:`
203
+ * slot is needed (the runtime descriptor ships `codecs: () => createCodecRegistry()`
204
+ * — empty).
205
+ */
206
+ const arktypeJsonCodec = {
207
+ codecId: ARKTYPE_JSON_CODEC_ID,
208
+ traits: ["equality"],
209
+ targetTypes: [ARKTYPE_JSON_NATIVE_TYPE],
210
+ paramsSchema: arktypeJsonParamsSchema,
211
+ renderOutputType: renderArktypeJsonOutputType,
212
+ factory: (params) => {
213
+ const schema = rehydrateSchema(params.jsonIr);
214
+ /* c8 ignore start — defensive parity check; not exercised by typical contracts */
215
+ const rehydratedExpression = schema.expression;
216
+ if (typeof rehydratedExpression === "string" && rehydratedExpression !== params.expression) console.warn(`[arktype-json] typeParams.expression (${params.expression}) does not match rehydrated schema expression (${rehydratedExpression}); contract.json may be stale relative to the runtime schema.`);
217
+ /* c8 ignore stop */
218
+ return arktypeJsonCodecForSchema(schema);
219
+ }
220
+ };
221
+
222
+ //#endregion
223
+ export { arktypeJsonEmitCodec as a, arktypeJsonCodec as i, ARKTYPE_JSON_NATIVE_TYPE as n, arktypeJson as r, ARKTYPE_JSON_CODEC_ID as t };
224
+ //# sourceMappingURL=arktype-json-codec-BbiBmtTK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arktype-json-codec-BbiBmtTK.mjs","names":["wire: string | undefined","jsonIr: unknown","arktypeJsonEmitCodec: Codec<\n typeof ARKTYPE_JSON_CODEC_ID,\n readonly ['equality'],\n string,\n unknown\n>","arktypeJsonCodec: CodecDescriptor<ArktypeJsonTypeParams>"],"sources":["../src/core/arktype-json-codec.ts"],"sourcesContent":["/**\n * Single source of truth for the arktype-json `arktype/json@1` codec.\n *\n * Ships the per-library JSON-with-schema column factory (`arktypeJson`) and\n * the framework-registration descriptor (`arktypeJsonCodec`). The two\n * surfaces share one serialize/rehydrate pipeline keyed on arktype's\n * internal IR.\n *\n * **Serialization** (column-author site, eager):\n *\n * - `expression`: `schema.expression` — arktype's TypeScript-source-like\n * rendering used by the emit-path `renderOutputType` to produce the\n * column's TS type in `contract.d.ts`.\n * - `jsonIr`: `schema.json` — arktype's internal IR. Lossless; the\n * rehydration source consumed by `ark.schema(jsonIr)` at runtime.\n *\n * The pair is sufficient: `expression` round-trips with the rehydrated\n * schema (`ark.schema(jsonIr).expression === expression`) so the emit-path\n * output is stable across serialize/rehydrate.\n *\n * **Rehydration** (runtime, on factory invocation): `ark.schema(typeParams.jsonIr)`\n * returns a callable `Type`-like with `~standard`. The returned codec's\n * `decode` body validates wire payloads through the rehydrated schema and\n * throws `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED` on rejection — no separate\n * validator-registry consultation.\n *\n * See the codec-registry-unification spec § Case J (JSON-with-schema).\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { ColumnTypeDescriptor } from '@prisma-next/contract-authoring';\nimport type {\n Codec,\n CodecDescriptor,\n CodecInstanceContext,\n} from '@prisma-next/framework-components/codec';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport { codec } from '@prisma-next/sql-relational-core/ast';\nimport { ArkErrors, ark, type Type, type } from 'arktype';\n\n// ── Constants ────────────────────────────────────────────────────────────\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// ── typeParams shape ─────────────────────────────────────────────────────\n\n/**\n * Eagerly serialized typeParams for the arktype-json column. Carried in\n * the contract IR; the runtime descriptor's factory rehydrates `jsonIr`\n * and the emitter consumes `expression`.\n */\nexport type ArktypeJsonTypeParams = {\n /**\n * Arktype's TypeScript-source-like rendering of the schema. Read by\n * `renderOutputType` to emit the column's TS type into `contract.d.ts`.\n * Stable across the serialize/rehydrate cycle: the rehydrated schema's\n * `expression` matches the source schema's.\n */\n readonly expression: string;\n /**\n * Arktype's internal IR for the schema. Lossless; the rehydration\n * source. Schema-shape — `ark.schema(jsonIr)` reconstructs a callable\n * `Type`-like structurally identical to the original `type(definition)`\n * output.\n */\n readonly jsonIr: object;\n};\n\n// ── Curried higher-order codec factory ───────────────────────────────────\n\n/**\n * Codec instance returned by `arktypeJson(schema)(ctx)` and by\n * `arktypeJsonCodec.factory(typeParams)(ctx)`. The `TInferred` slot\n * carries the arktype schema's inferred output type.\n */\nexport type ArktypeJsonCodec<TInferred> = Codec<\n typeof ARKTYPE_JSON_CODEC_ID,\n readonly ['equality'],\n string,\n TInferred\n>;\n\n/**\n * Structural narrow of arktype's `Type` — the surface our codec depends\n * on: a callable validator that returns `inferOut | ArkErrors`, plus the\n * `expression` string for emit-path rendering.\n *\n * Avoids depending on the precise generics of arktype's `Type<t, $>` so\n * schemas built in any scope (the default `Ark` from `type(...)` AND the\n * minimal scope from `ark.schema(...)`) satisfy the same contract.\n */\ntype ArktypeSchemaLike = ((value: unknown) => unknown) & {\n readonly expression: string;\n};\n\n/**\n * Type predicate for `ArktypeSchemaLike`. Lets the column-author\n * factory narrow `unknown` schemas to the structural shape the codec\n * depends on after the explicit field guards run, so the descriptor\n * builder doesn't fall back to a `as unknown as` cast.\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\n/**\n * Build the curried factory for a rehydrated arktype schema. The factory's\n * returned codec carries the schema in its closure; `decode` validates\n * wire payloads via `schema(parsed)`, throwing\n * `RUNTIME.JSON_SCHEMA_VALIDATION_FAILED` on rejection.\n *\n * Encode is `JSON.stringify` — the schema validates the input shape only\n * at the read boundary (decode), matching the JSON-validator philosophy:\n * the payload may have been written by any source (this writer, a\n * previous version of the schema, a manual SQL `INSERT`); validate when\n * reading, not when writing.\n *\n * Author bodies are sync; main's `codec({...})` factory promise-lifts\n * `encode`/`decode` into the framework-required `Promise<…>` boundary\n * shape (per ADR 204).\n */\nfunction arktypeJsonCodecForSchema<TInferred>(\n schema: ArktypeSchemaLike,\n): (ctx: CodecInstanceContext) => ArktypeJsonCodec<TInferred> {\n // Shared schema check used by both `decode` (wire → JS) and\n // `decodeJson` (JsonValue → JS). Either entry point must reject\n // payloads that don't match the schema; without the shared validator,\n // any caller that hands parsed JSON straight to the codec would bypass\n // schema enforcement and return unchecked data.\n function validateSchema(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 // arktype's call-result is `inferOut | ArkErrors`; the ArkErrors\n // branch is excluded above. The cast threads the caller-supplied\n // generic onto the structurally-typed validation output.\n return result as TInferred;\n }\n\n // Derive both `encode` (wire string) and `encodeJson` (JsonValue)\n // outputs from the same `JSON.stringify` → `JSON.parse` round-trip,\n // then validate the normalized payload through the schema. Without\n // this normalization, a non-JSON-safe runtime value (e.g. a class\n // instance, a function field on a narrowed type) could slip through\n // `encodeJson` unchanged while `encode` silently dropped or\n // transformed it — producing wire payloads the codec's own decode\n // path would later reject. The serialize/parse round-trip also\n // produces the JSON-safe shape required by the contract IR's\n // `JsonValue` surface, so `encodeJson` no longer needs a blind cast.\n function serializeToJsonSafe(value: TInferred): { wire: string; json: JsonValue } {\n // `JSON.stringify` returns `string | undefined` — `undefined`\n // happens when the input is `undefined` itself or contains only\n // unserializable values (functions, symbols). Reject explicitly so\n // the caller sees the schema-failure code rather than a downstream\n // `JSON.parse(undefined)` SyntaxError.\n const wire: string | undefined = JSON.stringify(value);\n if (typeof wire !== 'string') {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\n `arktype-json value is not representable as JSON (codecId: ${ARKTYPE_JSON_CODEC_ID})`,\n { codecId: ARKTYPE_JSON_CODEC_ID },\n );\n }\n const json = JSON.parse(wire) as JsonValue;\n // Validate the normalized payload — the round-trip strips\n // class-prototype shape and arktype-narrowed fields, and the\n // schema must still accept the result. Run validation and discard\n // its return value (we keep `json` as the JsonValue, not the\n // schema's `inferOut` which already matches `TInferred`).\n validateSchema(json);\n return { wire, json };\n }\n\n return (_ctx) =>\n codec<typeof ARKTYPE_JSON_CODEC_ID, readonly ['equality'], string, TInferred>({\n typeId: ARKTYPE_JSON_CODEC_ID,\n targetTypes: [ARKTYPE_JSON_NATIVE_TYPE],\n traits: ['equality'] as const,\n encode: (value: TInferred): string => serializeToJsonSafe(value).wire,\n decode: (wire: string): TInferred => validateSchema(JSON.parse(wire)),\n encodeJson: (value: TInferred): JsonValue => serializeToJsonSafe(value).json,\n decodeJson: (json: JsonValue) => validateSchema(json),\n }) as ArktypeJsonCodec<TInferred>;\n}\n\n// ── Column-author surface ────────────────────────────────────────────────\n\n/**\n * Curried column-author factory for arktype-validated JSON columns.\n *\n * Usage:\n *\n * ```ts\n * import { type } from 'arktype';\n * import { arktypeJson } from '@prisma-next/extension-arktype-json/column-types';\n *\n * const ProductSchema = type({ name: 'string', price: 'number' });\n *\n * const Product = {\n * columns: {\n * id: textCodec,\n * settings: arktypeJson(ProductSchema),\n * // ^? ColumnTypeDescriptor with type :: (ctx) => Codec<…, { name: string; price: number }>\n * },\n * };\n * ```\n *\n * The schema's inferred output flows through `S['infer']` so the no-emit\n * `FieldOutputType` resolver produces the precise TS type at the column\n * site. Eager serialization at this call site captures `expression` (for\n * the emit-path renderer) and `jsonIr` (for runtime rehydration).\n *\n * @throws {Error} if the schema doesn't expose `expression` and `json`\n * fields (i.e. is not an arktype `Type`). The factory validates the\n * schema shape at the call site so configuration errors surface during\n * contract authoring, not at runtime.\n */\nexport function arktypeJson<S extends Type<unknown>>(\n schema: S,\n): ColumnTypeDescriptor & {\n readonly codecId: typeof ARKTYPE_JSON_CODEC_ID;\n readonly nativeType: typeof ARKTYPE_JSON_NATIVE_TYPE;\n readonly typeParams: ArktypeJsonTypeParams;\n readonly type: (ctx: CodecInstanceContext) => ArktypeJsonCodec<S['infer']>;\n} {\n // Reject non-callable / non-arktype-shaped lookalikes before any\n // property reads. An object shaped like `{ expression, json }` would\n // otherwise pass the field checks and only explode on the first\n // `decode`/`decodeJson` call, defeating the early authoring-time\n // guard this factory provides. The `isArktypeSchemaLike` predicate\n // narrows `schema` so the descriptor builder hands the typed shape\n // straight to the curried factory — no `as unknown as` cast.\n if (!isArktypeSchemaLike(schema)) {\n throw new Error(\n typeof schema !== 'function'\n ? 'arktypeJson(schema) expects a callable arktype Type.'\n : 'arktypeJson(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('arktypeJson(schema) expects an arktype Type (missing `json` IR).');\n }\n return {\n codecId: ARKTYPE_JSON_CODEC_ID,\n nativeType: ARKTYPE_JSON_NATIVE_TYPE,\n typeParams: { expression: schema.expression, jsonIr },\n type: arktypeJsonCodecForSchema<S['infer']>(schema),\n } as const;\n}\n\n// ── Framework-registration descriptor ────────────────────────────────────\n\n/**\n * Standard Schema validator for the descriptor's typeParams. Asserts the\n * shape `{ expression: string; jsonIr: object }` at the contract IR\n * boundary; deeper IR-shape validation happens implicitly when\n * `ark.schema(jsonIr)` reparses (corrupt IR throws there).\n *\n * Eats its own dog food: the validator is itself an arktype schema.\n */\nconst arktypeJsonParamsSchema = type({\n expression: 'string',\n jsonIr: 'object',\n});\n\n/**\n * Rehydrate an arktype schema from the serialized IR. Throws a clean\n * error if the IR is corrupt — the \"corruption-of-contract.json\" case.\n */\nfunction rehydrateSchema(jsonIr: object): ArktypeSchemaLike {\n try {\n return ark.schema(jsonIr) as unknown as ArktypeSchemaLike;\n } catch (error) {\n throw runtimeError(\n 'RUNTIME.JSON_SCHEMA_VALIDATION_FAILED',\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}\n\n/**\n * Render the emit-path TS type for an arktype-json column. Reads the\n * eagerly-extracted `expression` directly — the round-trip stability\n * guarantee (rehydrated schema's `expression` matches the source's)\n * means the rendered output is consistent across serialize/rehydrate.\n */\nfunction renderArktypeJsonOutputType(params: ArktypeJsonTypeParams): string {\n const expression = params.expression.trim();\n return expression.length > 0 ? expression : 'unknown';\n}\n\n/**\n * Build a permissive `renderOutputType` that accepts the framework's\n * generic typeParams shape and dispatches to the type-narrow renderer\n * once the input is structurally an `ArktypeJsonTypeParams`.\n */\nfunction renderArktypeJsonOutputTypeFromUnknownParams(\n typeParams: Record<string, unknown>,\n): string | undefined {\n const expression = typeParams['expression'];\n const jsonIr = typeParams['jsonIr'];\n if (typeof expression !== 'string' || jsonIr === null || typeof jsonIr !== 'object') {\n return undefined;\n }\n return renderArktypeJsonOutputType({ expression, jsonIr });\n}\n\n/**\n * Emit-only `Codec` instance for `arktype/json@1`. Threaded through the\n * pack-meta's `codecInstances` array so the emitter's `CodecLookup` can\n * find a `renderOutputType` for the codec id (the emitter consults the\n * codec-id-keyed `CodecLookup` at the framework boundary; the unified\n * descriptor's `renderOutputType` is the long-term home for the renderer\n * but the emit-path glue still routes through `CodecLookup`).\n *\n * All conversion methods are sentinels that throw if invoked — runtime\n * materialization always goes through `arktypeJsonCodec.factory`'s\n * curried `(params) => (ctx) => Codec`, never through this instance.\n * `encodeJson`/`decodeJson` throw alongside `encode`/`decode` so a\n * mistaken contract-load that resolved to this stub fails fast at the\n * JSON boundary instead of silently returning unvalidated payloads. A\n * future cleanup could route the emit path through the descriptor map\n * directly and retire this shim.\n */\nconst ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR =\n 'arktype-json codec instances must be materialized via the descriptor factory; this is an emit-only stub';\n\nexport const arktypeJsonEmitCodec: Codec<\n typeof ARKTYPE_JSON_CODEC_ID,\n readonly ['equality'],\n string,\n unknown\n> = {\n id: ARKTYPE_JSON_CODEC_ID,\n targetTypes: [ARKTYPE_JSON_NATIVE_TYPE],\n traits: ['equality'] as const,\n encode: () => Promise.reject(new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR)),\n decode: () => Promise.reject(new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR)),\n encodeJson: () => {\n throw new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR);\n },\n decodeJson: () => {\n throw new Error(ARKTYPE_JSON_RUNTIME_DISPATCH_ERROR);\n },\n renderOutputType: renderArktypeJsonOutputTypeFromUnknownParams,\n};\n\n/**\n * Framework-registration descriptor for the arktype-json codec. Registered\n * through the SQL runtime's `parameterizedCodecs:` slot. `sql-runtime`'s\n * `initializeTypeHelpers` (and per-column walk in\n * `buildContractCodecRegistry`) calls `arktypeJsonCodec.factory(typeParams)\n * (ctx)` once per `storage.types` instance (or once per inline-typeParams\n * column) to materialize the resolved codec carrying the rehydrated\n * schema.\n *\n * Per Phase B of codec-registry-unification, `descriptorFor('arktype/json@1')`\n * returns this descriptor and its `traits`/`targetTypes` are the codec-id-\n * keyed source of truth — no parallel placeholder on the legacy `codecs:`\n * slot is needed (the runtime descriptor ships `codecs: () => createCodecRegistry()`\n * — empty).\n */\nexport const arktypeJsonCodec: CodecDescriptor<ArktypeJsonTypeParams> = {\n codecId: ARKTYPE_JSON_CODEC_ID,\n traits: ['equality'] as const,\n targetTypes: [ARKTYPE_JSON_NATIVE_TYPE] as const,\n paramsSchema: arktypeJsonParamsSchema,\n renderOutputType: renderArktypeJsonOutputType,\n factory: (params) => {\n const schema = rehydrateSchema(params.jsonIr);\n /* c8 ignore start — defensive parity check; not exercised by typical contracts */\n // The rehydrated schema's `expression` should match the serialized\n // one; diverging means contract.json was hand-edited out from under\n // the emit-path renderer. Surface as a soft warning at materialization\n // time so the caller knows their emit output may not match the\n // runtime schema. The runtime keeps using the schema rehydrated from\n // `jsonIr` — that's the lossless source — so the worst case is an\n // emit-vs-runtime divergence at a single column, not a runtime\n // failure.\n const rehydratedExpression = (schema as { readonly expression?: unknown }).expression;\n if (typeof rehydratedExpression === 'string' && rehydratedExpression !== params.expression) {\n console.warn(\n `[arktype-json] typeParams.expression (${params.expression}) does not match rehydrated schema expression (${rehydratedExpression}); contract.json may be stale relative to the runtime schema.`,\n );\n }\n /* c8 ignore stop */\n return arktypeJsonCodecForSchema<unknown>(schema);\n },\n};\n"],"mappings":"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"}
@@ -0,0 +1,92 @@
1
+ import { Type } from "arktype";
2
+ import { ColumnTypeDescriptor } from "@prisma-next/contract-authoring";
3
+ import { Codec, CodecDescriptor, CodecInstanceContext } from "@prisma-next/framework-components/codec";
4
+
5
+ //#region src/core/arktype-json-codec.d.ts
6
+
7
+ /** Codec id for arktype-backed JSON columns. Library-bound, not target-bound. */
8
+ declare const ARKTYPE_JSON_CODEC_ID: "arktype/json@1";
9
+ /** Native storage type backing the codec. JSONB on Postgres; binary, indexable. */
10
+ declare const ARKTYPE_JSON_NATIVE_TYPE: "jsonb";
11
+ /**
12
+ * Eagerly serialized typeParams for the arktype-json column. Carried in
13
+ * the contract IR; the runtime descriptor's factory rehydrates `jsonIr`
14
+ * and the emitter consumes `expression`.
15
+ */
16
+ type ArktypeJsonTypeParams = {
17
+ /**
18
+ * Arktype's TypeScript-source-like rendering of the schema. Read by
19
+ * `renderOutputType` to emit the column's TS type into `contract.d.ts`.
20
+ * Stable across the serialize/rehydrate cycle: the rehydrated schema's
21
+ * `expression` matches the source schema's.
22
+ */
23
+ readonly expression: string;
24
+ /**
25
+ * Arktype's internal IR for the schema. Lossless; the rehydration
26
+ * source. Schema-shape — `ark.schema(jsonIr)` reconstructs a callable
27
+ * `Type`-like structurally identical to the original `type(definition)`
28
+ * output.
29
+ */
30
+ readonly jsonIr: object;
31
+ };
32
+ /**
33
+ * Codec instance returned by `arktypeJson(schema)(ctx)` and by
34
+ * `arktypeJsonCodec.factory(typeParams)(ctx)`. The `TInferred` slot
35
+ * carries the arktype schema's inferred output type.
36
+ */
37
+ type ArktypeJsonCodec<TInferred> = Codec<typeof ARKTYPE_JSON_CODEC_ID, readonly ['equality'], string, TInferred>;
38
+ /**
39
+ * Curried column-author factory for arktype-validated JSON columns.
40
+ *
41
+ * Usage:
42
+ *
43
+ * ```ts
44
+ * import { type } from 'arktype';
45
+ * import { arktypeJson } from '@prisma-next/extension-arktype-json/column-types';
46
+ *
47
+ * const ProductSchema = type({ name: 'string', price: 'number' });
48
+ *
49
+ * const Product = {
50
+ * columns: {
51
+ * id: textCodec,
52
+ * settings: arktypeJson(ProductSchema),
53
+ * // ^? ColumnTypeDescriptor with type :: (ctx) => Codec<…, { name: string; price: number }>
54
+ * },
55
+ * };
56
+ * ```
57
+ *
58
+ * The schema's inferred output flows through `S['infer']` so the no-emit
59
+ * `FieldOutputType` resolver produces the precise TS type at the column
60
+ * site. Eager serialization at this call site captures `expression` (for
61
+ * the emit-path renderer) and `jsonIr` (for runtime rehydration).
62
+ *
63
+ * @throws {Error} if the schema doesn't expose `expression` and `json`
64
+ * fields (i.e. is not an arktype `Type`). The factory validates the
65
+ * schema shape at the call site so configuration errors surface during
66
+ * contract authoring, not at runtime.
67
+ */
68
+ declare function arktypeJson<S extends Type<unknown>>(schema: S): ColumnTypeDescriptor & {
69
+ readonly codecId: typeof ARKTYPE_JSON_CODEC_ID;
70
+ readonly nativeType: typeof ARKTYPE_JSON_NATIVE_TYPE;
71
+ readonly typeParams: ArktypeJsonTypeParams;
72
+ readonly type: (ctx: CodecInstanceContext) => ArktypeJsonCodec<S['infer']>;
73
+ };
74
+ /**
75
+ * Framework-registration descriptor for the arktype-json codec. Registered
76
+ * through the SQL runtime's `parameterizedCodecs:` slot. `sql-runtime`'s
77
+ * `initializeTypeHelpers` (and per-column walk in
78
+ * `buildContractCodecRegistry`) calls `arktypeJsonCodec.factory(typeParams)
79
+ * (ctx)` once per `storage.types` instance (or once per inline-typeParams
80
+ * column) to materialize the resolved codec carrying the rehydrated
81
+ * schema.
82
+ *
83
+ * Per Phase B of codec-registry-unification, `descriptorFor('arktype/json@1')`
84
+ * returns this descriptor and its `traits`/`targetTypes` are the codec-id-
85
+ * keyed source of truth — no parallel placeholder on the legacy `codecs:`
86
+ * slot is needed (the runtime descriptor ships `codecs: () => createCodecRegistry()`
87
+ * — empty).
88
+ */
89
+ declare const arktypeJsonCodec: CodecDescriptor<ArktypeJsonTypeParams>;
90
+ //#endregion
91
+ export { arktypeJson as a, ArktypeJsonTypeParams as i, ARKTYPE_JSON_NATIVE_TYPE as n, arktypeJsonCodec as o, ArktypeJsonCodec as r, ARKTYPE_JSON_CODEC_ID as t };
92
+ //# sourceMappingURL=arktype-json-codec-yNv1hzBm.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arktype-json-codec-yNv1hzBm.d.mts","names":[],"sources":["../src/core/arktype-json-codec.ts"],"sourcesContent":[],"mappings":";;;;;;;cA2Ca;;cAGA;;;;;;KASD,qBAAA;;;;;;;;;;;;;;;;;;;;;KAwBA,8BAA8B,aACjC,sDAGP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiJc,sBAAsB,uBAC5B,IACP;2BACwB;8BACG;uBACP;uBACA,yBAAyB,iBAAiB;;;;;;;;;;;;;;;;;cA6IpD,kBAAkB,gBAAgB"}
@@ -0,0 +1,27 @@
1
+ //#region src/types/codec-types.d.ts
2
+ /**
3
+ * Codec type definitions for the arktype-json extension.
4
+ *
5
+ * Type-only export consumed by emitted `contract.d.ts` to power
6
+ * `CodecTypes['arktype/json@1']['output']` lookups. The shape mirrors the
7
+ * codec the curried factory returns at runtime so the emit and no-emit
8
+ * paths stay structurally aligned.
9
+ *
10
+ * The output type is intentionally `unknown` — the precise inference is
11
+ * column-site-local (the no-emit `FieldOutputType` resolver reads the
12
+ * factory's return type from the column descriptor's `type` slot, which
13
+ * carries `(ctx) => Codec<…, S['infer']>`). The emit path renders the
14
+ * descriptor's `expression` as the column's TS type (per the descriptor's
15
+ * `renderOutputType`); the codec-id-keyed `CodecTypes` map is the
16
+ * fallback for sites without a column descriptor in scope.
17
+ */
18
+ type CodecTypes = {
19
+ readonly 'arktype/json@1': {
20
+ readonly input: unknown;
21
+ readonly output: unknown;
22
+ readonly traits: 'equality';
23
+ };
24
+ };
25
+ //#endregion
26
+ export { CodecTypes as t };
27
+ //# sourceMappingURL=codec-types-CH37Yc0C.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec-types-CH37Yc0C.d.mts","names":[],"sources":["../src/types/codec-types.ts"],"sourcesContent":[],"mappings":";;AAiBA;;;;;;;;;;;;;;;KAAY,UAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as CodecTypes } from "./codec-types-CH37Yc0C.mjs";
2
+ export { type CodecTypes };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ import { i as ArktypeJsonTypeParams, n as ARKTYPE_JSON_NATIVE_TYPE, o as arktypeJsonCodec, r as ArktypeJsonCodec, t as ARKTYPE_JSON_CODEC_ID } from "./arktype-json-codec-yNv1hzBm.mjs";
2
+ export { ARKTYPE_JSON_CODEC_ID, ARKTYPE_JSON_NATIVE_TYPE, type ArktypeJsonCodec, type ArktypeJsonTypeParams, arktypeJsonCodec };
@@ -0,0 +1,3 @@
1
+ import { i as arktypeJsonCodec, n as ARKTYPE_JSON_NATIVE_TYPE, t as ARKTYPE_JSON_CODEC_ID } from "./arktype-json-codec-BbiBmtTK.mjs";
2
+
3
+ export { ARKTYPE_JSON_CODEC_ID, ARKTYPE_JSON_NATIVE_TYPE, arktypeJsonCodec };
@@ -0,0 +1,2 @@
1
+ import { a as arktypeJson, i as ArktypeJsonTypeParams, r as ArktypeJsonCodec } from "./arktype-json-codec-yNv1hzBm.mjs";
2
+ export { type ArktypeJsonCodec, type ArktypeJsonTypeParams, arktypeJson };
@@ -0,0 +1,3 @@
1
+ import { r as arktypeJson } from "./arktype-json-codec-BbiBmtTK.mjs";
2
+
3
+ export { arktypeJson };
@@ -0,0 +1,8 @@
1
+ import { SqlControlExtensionDescriptor } from "@prisma-next/family-sql/control";
2
+
3
+ //#region src/exports/control.d.ts
4
+
5
+ declare const arktypeJsonExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>;
6
+ //#endregion
7
+ export { arktypeJsonExtensionDescriptor, arktypeJsonExtensionDescriptor as default };
8
+ //# sourceMappingURL=control.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":[],"mappings":";;;;cA0Ba,gCAAgC"}
@@ -0,0 +1,24 @@
1
+ import { t as ARKTYPE_JSON_CODEC_ID } from "./arktype-json-codec-BbiBmtTK.mjs";
2
+ import { t as arktypeJsonPackMeta } from "./pack-meta-DycetSQB.mjs";
3
+
4
+ //#region src/exports/control.ts
5
+ const arktypeJsonControlPlaneHooks = { expandNativeType: ({ nativeType }) => nativeType };
6
+ const arktypeJsonExtensionDescriptor = {
7
+ ...arktypeJsonPackMeta,
8
+ types: {
9
+ ...arktypeJsonPackMeta.types,
10
+ codecTypes: {
11
+ ...arktypeJsonPackMeta.types.codecTypes,
12
+ controlPlaneHooks: { [ARKTYPE_JSON_CODEC_ID]: arktypeJsonControlPlaneHooks }
13
+ }
14
+ },
15
+ create: () => ({
16
+ familyId: "sql",
17
+ targetId: "postgres"
18
+ })
19
+ };
20
+ var control_default = arktypeJsonExtensionDescriptor;
21
+
22
+ //#endregion
23
+ export { arktypeJsonExtensionDescriptor, control_default as default };
24
+ //# sourceMappingURL=control.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.mjs","names":["arktypeJsonControlPlaneHooks: CodecControlHooks","arktypeJsonExtensionDescriptor: SqlControlExtensionDescriptor<'postgres'>"],"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 `databaseDependencies`, no\n * query 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,MAAMA,+BAAkD,EACtD,mBAAmB,EAAE,iBAAiB,YACvC;AAED,MAAaC,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;AAED,sBAAe"}
@@ -0,0 +1,37 @@
1
+ import { a as arktypeJsonEmitCodec, t as ARKTYPE_JSON_CODEC_ID } from "./arktype-json-codec-BbiBmtTK.mjs";
2
+
3
+ //#region src/core/pack-meta.ts
4
+ const arktypeJsonPackMetaBase = {
5
+ kind: "extension",
6
+ id: "arktype-json",
7
+ familyId: "sql",
8
+ targetId: "postgres",
9
+ version: "0.0.1",
10
+ capabilities: {},
11
+ types: {
12
+ codecTypes: {
13
+ codecInstances: [arktypeJsonEmitCodec],
14
+ import: {
15
+ package: "@prisma-next/extension-arktype-json/codec-types",
16
+ named: "CodecTypes",
17
+ alias: "ArktypeJsonTypes"
18
+ }
19
+ },
20
+ storage: [{
21
+ typeId: ARKTYPE_JSON_CODEC_ID,
22
+ familyId: "sql",
23
+ targetId: "postgres",
24
+ nativeType: "jsonb"
25
+ }]
26
+ }
27
+ };
28
+ /**
29
+ * Public pack metadata. The phantom `__codecTypes` field threads the
30
+ * codec-types map's literal type into the pack ref so contract-builder
31
+ * generics can pick it up; it is never accessed at runtime.
32
+ */
33
+ const arktypeJsonPackMeta = arktypeJsonPackMetaBase;
34
+
35
+ //#endregion
36
+ export { arktypeJsonPackMeta as t };
37
+ //# sourceMappingURL=pack-meta-DycetSQB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack-meta-DycetSQB.mjs","names":["arktypeJsonPackMeta: typeof arktypeJsonPackMetaBase & {\n readonly __codecTypes?: CodecTypes;\n}"],"sources":["../src/core/pack-meta.ts"],"sourcesContent":["/**\n * arktype-json pack metadata.\n *\n * The pack metadata is the framework-composition entry point: control-\n * stack assembly reads `types.codecTypes.import` to thread the type-side\n * imports into emitted `contract.d.ts`, and `types.storage` declares the\n * codec id's storage backing (`jsonb` on Postgres).\n *\n * Per Phase B of codec-registry-unification, runtime materialization\n * flows through the unified descriptor map (`arktypeJsonCodec`\n * parameterized descriptor), not through the legacy runtime codec\n * lookup. This metadata still carries an emit-only `Codec` instance\n * (`arktypeJsonEmitCodec`) under `codecInstances` so the framework\n * emitter's codec-id-keyed `CodecLookup` can resolve `renderOutputType`\n * at emit time — that shim retires when the emit path consults the\n * descriptor map directly (TML-2357). Control-stack consumers read\n * codec metadata from `descriptorFor('arktype/json@1')`.\n */\n\nimport type { CodecTypes } from '../types/codec-types';\nimport { ARKTYPE_JSON_CODEC_ID, arktypeJsonEmitCodec } from './arktype-json-codec';\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 // The emitter's `CodecLookup` is the codec-id-keyed source of\n // truth for `renderOutputType` at the framework emit-path\n // boundary. We thread an emit-only `Codec` instance carrying the\n // `renderOutputType` here so the lookup resolves; runtime\n // materialization goes through the unified descriptor's\n // `factory: (P) => (CodecInstanceContext) => Codec`, never through this shim.\n codecInstances: [arktypeJsonEmitCodec],\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\n * codec-types map's literal type into the pack ref so contract-builder\n * 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":";;;AAsBA,MAAM,0BAA0B;CAC9B,MAAM;CACN,IAAI;CACJ,UAAU;CACV,UAAU;CACV,SAAS;CACT,cAAc,EAAE;CAChB,OAAO;EACL,YAAY;GAOV,gBAAgB,CAAC,qBAAqB;GACtC,QAAQ;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACR;GACF;EACD,SAAS,CACP;GACE,QAAQ;GACR,UAAU;GACV,UAAU;GACV,YAAY;GACb,CACF;EACF;CACF;;;;;;AAOD,MAAaA,sBAET"}
@@ -0,0 +1,40 @@
1
+ import { t as CodecTypes } from "./codec-types-CH37Yc0C.mjs";
2
+ import * as _prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
3
+
4
+ //#region src/core/pack-meta.d.ts
5
+
6
+ declare const arktypeJsonPackMetaBase: {
7
+ readonly kind: "extension";
8
+ readonly id: "arktype-json";
9
+ readonly familyId: "sql";
10
+ readonly targetId: "postgres";
11
+ readonly version: "0.0.1";
12
+ readonly capabilities: {};
13
+ readonly types: {
14
+ readonly codecTypes: {
15
+ readonly codecInstances: readonly [_prisma_next_framework_components_codec0.Codec<"arktype/json@1", readonly ["equality"], string, unknown>];
16
+ readonly import: {
17
+ readonly package: "@prisma-next/extension-arktype-json/codec-types";
18
+ readonly named: "CodecTypes";
19
+ readonly alias: "ArktypeJsonTypes";
20
+ };
21
+ };
22
+ readonly storage: readonly [{
23
+ readonly typeId: "arktype/json@1";
24
+ readonly familyId: "sql";
25
+ readonly targetId: "postgres";
26
+ readonly nativeType: "jsonb";
27
+ }];
28
+ };
29
+ };
30
+ /**
31
+ * Public pack metadata. The phantom `__codecTypes` field threads the
32
+ * codec-types map's literal type into the pack ref so contract-builder
33
+ * generics can pick it up; it is never accessed at runtime.
34
+ */
35
+ declare const arktypeJsonPackMeta: typeof arktypeJsonPackMetaBase & {
36
+ readonly __codecTypes?: CodecTypes;
37
+ };
38
+ //#endregion
39
+ export { arktypeJsonPackMeta, arktypeJsonPackMeta as default };
40
+ //# sourceMappingURL=pack.d.mts.map