🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/framework-components

Package Overview
Dependencies
Maintainers
4
Versions
509
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/framework-components - npm Package Compare versions

Comparing version
0.14.0-dev.76
to
0.14.0-dev.77
+236
dist/codec-types-e32YHT3D.d.mts
import { JsonValue } from "@prisma-next/contract/types";
import { StandardSchemaV1 } from "@standard-schema/spec";
//#region src/shared/codec-descriptor.d.ts
/**
* Unified codec descriptor. Every codec in the framework registers through this shape — non-parameterized codecs use `P = void` and a constant factory that returns the same shared codec instance for every column; parameterized codecs use a non-empty `P` and a curried higher-order factory that returns a per-instance codec.
*
* The descriptor is the codec-id-keyed source of truth for static metadata (`traits`, `targetTypes`, `meta`) and registration concerns (`paramsSchema` for JSON-boundary validation; optional `renderOutputType` for the `contract.d.ts` emit path). The runtime `Codec` instance returned by `factory(params)(ctx)` carries only the conversion behavior.
*
* Whether a codec id "is parameterized" stops being a registration-time distinction — it's a property of `P` on the descriptor. The descriptor map indexes every descriptor by `codecId`; both `descriptorFor(codecId)` and `forColumn(table, column)` resolve through the same map without branching on parameterization.
*
* @template P - The shape of the params accepted by the factory (`void` for non-parameterized codecs; a record like `{ length: number }` for parameterized codecs).
*
* Codec-registry-unification project § Decision.
*/
interface CodecDescriptor<P = void> {
/** The codec ID this descriptor applies to (e.g. `pg/vector@1`, `pg/text@1`). */
readonly codecId: string;
/** Semantic traits for operator gating (e.g. equality, order, numeric). */
readonly traits: readonly CodecTrait[];
/** Database-native type names this codec handles (e.g. `['timestamptz']`). */
readonly targetTypes: readonly string[];
/** Optional family-specific metadata (e.g. SQL-side `db.sql.postgres.nativeType`). */
readonly meta?: CodecMeta;
/** Standard Schema validator for the factory's params. Validates JSON-sourced params at the contract boundary (PSL → IR; `contract.json` → runtime). For non-parameterized codecs (`P = void`), the schema validates `void`/`undefined` — the framework supplies no params at the call boundary. */
readonly paramsSchema: StandardSchemaV1<P>;
/** Whether this descriptor is parameterized — i.e. its `paramsSchema` is something other than the singleton `voidParamsSchema`. Consumers that need to gate column-aware dispatch read this directly rather than threading a free-floating `(codecId) => boolean` callback. */
readonly isParameterized: boolean;
/** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Optional; absent renderers cause `CodecLookup.metaFor` to fall back to the codec's static `meta`. Non-parameterized codecs typically omit it. */
readonly metaFor?: (params: P) => CodecMeta | undefined;
/** Emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for given params (e.g. `Vector<1536>`). Optional; absent renderers cause the emitter to fall back to the codec's base output type. Non-parameterized codecs typically omit it. */
readonly renderOutputType?: (params: P) => string | undefined;
/** Emit-path string renderer for the `contract.d.ts` *input* position (create/update values). Returns the TypeScript input type expression for given params. Optional; absent renderers fall back to the codec's base input type. A codec supplies this when its write type is narrower than the generic codec input — e.g. an enum whose input should be the literal member union, not `string`. */
readonly renderInputType?: (params: P) => string | undefined;
/**
* Given one stored (codec-encoded) value, return the TypeScript literal type to print for it
* (e.g. `'low'`, `1`), or `undefined` if this codec's output isn't literal-expressible (e.g. a
* Date-output codec).
*
* `value` is the `encodeJson` form stored in the value set. `side` selects which type to print:
* `output` = the read/SELECT type; `input` = the create/update type. Most codecs render the same
* literal for both, but a codec whose read and write types differ can render per side. Called once
* per permitted value; the caller joins the results with `|`.
*/
readonly renderValueLiteral?: (value: JsonValue, side: 'output' | 'input') => string | undefined;
/** The curried higher-order codec. For non-parameterized codecs, the factory is constant — every call returns the same shared codec instance. For parameterized codecs, the factory is called once per `storage.types` instance (or once per inline-`typeParams` column), with `ctx` carrying the column set the resulting codec serves. */
readonly factory: (params: P) => (ctx: CodecInstanceContext) => Codec;
}
/**
* Variance-erased {@link CodecDescriptor} alias. `CodecDescriptor<P>` is invariant in `P` (the `factory` and `renderOutputType` slots use `P` contravariantly), so `CodecDescriptor<P>` does not extend `CodecDescriptor<unknown>` for specific `P`. Heterogeneous descriptor collections — e.g. `SqlStaticContributions.codecs:` returning a list that mixes parameterized and non-parameterized descriptors — type against this alias and narrow per codec id at the consumer.
*
* Codec-registry-unification spec § Decision: every codec resolves through one descriptor map; reads are non-branching.
*/
type AnyCodecDescriptor = CodecDescriptor<any>;
/**
* Abstract base class for concrete codec descriptors.
*
* Codec authors extend this class with their typed `TParams` and declare `codecId`, `traits`, `targetTypes`, `paramsSchema`, the curried `factory(params)`, and (optionally) `renderOutputType`.
*
* Implements the {@link CodecDescriptor} interface so a concrete subclass instance is directly usable wherever the framework expects a `CodecDescriptor<P>`.
*/
declare abstract class CodecDescriptorImpl<TParams = void> implements CodecDescriptor<TParams> {
abstract readonly codecId: string;
abstract readonly traits: readonly CodecTrait[];
abstract readonly targetTypes: readonly string[];
readonly meta?: CodecMeta;
abstract readonly paramsSchema: StandardSchemaV1<TParams>;
/** Boolean derived from `paramsSchema`: `true` whenever the schema is not the singleton `voidParamsSchema`. */
get isParameterized(): boolean;
/** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Non-parameterized codecs typically omit it. */
metaFor?(params: TParams): CodecMeta | undefined;
/** Optional emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for the given params (e.g. `Vector<1536>`). Non-parameterized codecs typically omit it. */
renderOutputType?(params: TParams): string | undefined;
/** Optional emit-path string renderer for the `contract.d.ts` input position. Returns the TypeScript input type expression for the given params; supplied when the write type is narrower than the generic codec input (e.g. an enum's literal member union). */
renderInputType?(params: TParams): string | undefined;
/** Optional emit-path renderer for a single stored value. See {@link CodecDescriptor.renderValueLiteral}. */
renderValueLiteral?(value: JsonValue, side: 'output' | 'input'): string | undefined;
/**
* Materialize a curried codec factory for the given params. Concrete subclasses override with a typed return type (e.g. `factory<N>(params: { length: N }): (ctx) => VectorCodec<N>`); per-codec helpers read the typed return at the *direct* call site, which is what preserves method-level generics. Type extraction (e.g. `ReturnType<D['factory']>`) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.
*/
abstract factory(params: TParams): (ctx: CodecInstanceContext) => Codec<string, readonly CodecTrait[], unknown, unknown>;
}
//#endregion
//#region src/shared/codec.d.ts
/**
* A codec is the contract between an application value and its driver-wire and JSON representations.
*
* The author's mental model is two JS-side types — `TInput` (the application JS type) and `TWire` (the database driver wire format) — plus a target-defined `JsonValue`. The codec translates `TInput` to `TWire` on writes and back on ordinary reads, and to/from the target's JSON representation for contract artifacts and database-produced JSON values.
*
* Three representations participate:
* - **Input** (`TInput`): the JS type at the application boundary.
* - **Wire** (`TWire`): the format exchanged with the database driver.
* - **JSON** (`JsonValue`): the target-defined JSON-safe form used in contract artifacts. It uses the exact scalar shape the target produces inside JSON values, which can differ from the ordinary wire format.
*
* The runtime instance carries only its `id` (the descriptor's `codecId`, set by the factory) and the four conversion methods. Static metadata (`traits`, `targetTypes`, `meta`) and the build-time `renderOutputType` renderer live on the {@link CodecDescriptor} keyed by `codecId` — the read-surface single source of truth. Consumers that need them resolve through `descriptorFor(codecId)`.
*
* Codec methods split into two groups:
*
* - **Query-time** methods (`encode`, `decode`) run per row/parameter at the IO boundary; they are required and Promise-returning. The per-family codec factory accepts sync or async author functions and lifts sync ones to Promise-shaped methods automatically.
* - **JSON** methods (`encodeJson`, `decodeJson`) run when the contract is serialized or loaded. Runtimes may also use `decodeJson` for values embedded in database-produced JSON results. They stay synchronous so contract validation and client construction are synchronous.
*
* Target-family codec interfaces extend this base; family-specific concerns (e.g. the SQL `column?` per-call context) layer on through the `CodecCallContext` extension pattern.
*/
interface Codec<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown> {
/** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). The factory sets this to the descriptor's `codecId`; consumers use it as a back-reference for descriptor lookups and for decode-error diagnostics. */
readonly id: Id;
/** Phantom carrier for the `TTraits` generic; type-only, undefined at runtime. Runtime traits live on {@link CodecDescriptor.traits}. Implemented as a string-key phantom (`__codecTraits`) rather than `unique symbol` so bundlers that split `.d.ts` chunks do not strand symbol identity on chunk-private paths (the same `TS2742` family that the public re-export of `CodecTypes` works around). */
readonly __codecTraits?: TTraits;
/** Converts a JS value to the wire format expected by the database driver. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(value) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */
encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;
/** Converts a wire value from the database driver into the JS application type. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(wire) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */
decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;
/** Converts a JS value to the target-defined JSON representation used for contract serialization. This must match the scalar shape produced by the target inside JSON values. Synchronous; called during contract emission. */
encodeJson(value: TInput): JsonValue;
/** Converts the target-defined JSON representation back to the JS input type. Synchronous; called during contract loading via `family.deserializeContract` and may be called by runtimes for embedded JSON values. */
decodeJson(json: JsonValue): TInput;
}
/**
* Abstract base class for concrete codec implementations.
*
* Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override all four abstract conversion methods: `encode`, `decode`, `encodeJson`, and `decodeJson`. The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.
*/
declare abstract class CodecImpl<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown> implements Codec<Id, TTraits, TWire, TInput> {
readonly descriptor: CodecDescriptor<any>;
/**
* Variance-erased descriptor reference. Concrete codec subclasses receive the typed descriptor in their own constructors and forward it via `super(descriptor)`; the variance erasure lives at this base because the abstract surface can't carry the concrete `TParams`.
*/
constructor(descriptor: CodecDescriptor<any>);
get id(): Id;
abstract encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;
abstract decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;
abstract encodeJson(value: TInput): JsonValue;
abstract decodeJson(json: JsonValue): TInput;
}
//#endregion
//#region src/shared/codec-types.d.ts
type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
/**
* Serializable codec identity carried by every codec-bearing AST node.
*
* `(codecId, typeParams?)` is the single fact the runtime needs to materialize a codec via `descriptorFor(codecId).factory(typeParams)(ctx)`. The pair is content-keyed: two refs with the same `codecId` and structurally equal `typeParams` (regardless of object key ordering) resolve to the same memoized {@link Codec} instance.
*
* `typeParams` is `JsonValue`-constrained so the ref survives JSON serialization (relevant for AST-embedded migration ops). Non-parameterized codecs leave `typeParams` undefined; the descriptor's `paramsSchema` validates the value at the JSON boundary.
*
* `many` marks a scalar-array (list-typed) column. When `true`, the encode/decode paths map the element codec over the JS array rather than applying the codec to the whole value. The element codec id is `codecId`; the driver owns the array wire framing (`{…}`) in both directions. Absent for scalar columns.
*
* Family-agnostic by design — both SQL and Mongo AST nodes carry `codec: CodecRef | undefined`, and the resolver is the only dispatch path that survives serialization.
*/
interface CodecRef {
readonly codecId: string;
readonly typeParams?: JsonValue;
readonly many?: boolean;
}
/**
* Per-call context the runtime threads to every `codec.encode` / `codec.decode` invocation for a single `runtime.execute()` call.
*
* The framework-level shape is family-agnostic and carries one field:
*
* - `signal?: AbortSignal` — per-query cancellation. The runtime returns a `RUNTIME.ABORTED` envelope when the signal aborts; codec authors who forward `signal` to their underlying SDK get true cancellation of in-flight network calls.
*
* Family layers extend this base with their own shape-of-call metadata: the SQL family adds `column?: SqlColumnRef` via `SqlCodecCallContext` (see `@prisma-next/sql-relational-core`). Mongo currently uses this framework type unchanged. Column metadata is intentionally **not** on the framework type — it is a SQL-family concept rooted in SQL's `(table, column)` addressing model and would not generalise to other families.
*
* The interface is named explicitly (not inlined) so future framework fields and family extensions can land additively without breaking codec author signatures.
*/
interface CodecCallContext {
readonly signal?: AbortSignal;
}
/**
* Codec-id-keyed read surface threaded into emit and authoring paths.
*
* - `get(id)` returns a representative {@link Codec} instance for the codec id (used by `family.deserializeContract` for `decodeJson` of literal column defaults). For parameterized codecs whose factory requires concrete params, this may return `undefined` — use `CodecRegistry.forCodecRef` instead.
* - `targetTypesFor(id)` exposes the codec-id-keyed `targetTypes` metadata the runtime instance no longer carries (TML-2357). Returns the same array `CodecDescriptor.targetTypes` would; for Mongo (whose registration doesn't yet resolve through the unified descriptor map — TML-2324) the family-side assembly populates this directly from the contributor's codec metadata.
* - `metaFor(id, typeParams)` exposes the codec-id-keyed `meta` (e.g. SQL-side `db.sql.postgres.nativeType`) the runtime instance no longer carries. `typeParams` is optional: when given and the codec descriptor implements a params-aware `metaFor`, the descriptor computes its meta from those params (e.g. a native enum's per-instance Postgres type name); otherwise (or when `typeParams` is omitted) the codec's static `meta` is returned.
* - `renderOutputTypeFor(id, params)` exposes the codec-id-keyed `renderOutputType` renderer the runtime instance no longer carries. Returns `undefined` when the codec doesn't render a custom type or when the codec id is unknown.
*/
interface CodecLookup {
get(id: string): Codec | undefined;
targetTypesFor(id: string): readonly string[] | undefined;
metaFor(id: string, typeParams?: Record<string, unknown> | JsonValue): CodecMeta | undefined;
renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;
/** Codec-id-keyed `renderInputType` renderer for the `contract.d.ts` input position. Optional so existing lookups need not provide it; returns `undefined` when the codec renders no custom input type or the id is unknown. */
renderInputTypeFor?(id: string, params: Record<string, unknown>): string | undefined;
/** Codec-id-keyed `renderValueLiteral` renderer for the emit path (`side`: `output` = read type, `input` = create/update type). Optional so existing lookups need not provide it; returns `undefined` when the codec's output isn't literal-expressible or the id is unknown. */
renderValueLiteralFor?(id: string, value: JsonValue, side: 'output' | 'input'): string | undefined;
/**
* Codec-id-keyed descriptor accessor. Returns the full registered
* {@link AnyCodecDescriptor} for `id`, or `undefined` if no descriptor is
* registered. Optional so existing lookups need not provide it; a consumer
* that needs more than the derived per-id readers above — e.g. an
* authoring-time hook a target-specific descriptor exposes but this
* framework interface does not model generically — fetches the descriptor
* itself and narrows it with its own structural predicate.
*/
descriptorFor?(id: string): AnyCodecDescriptor | undefined;
}
/**
* Full codec registry — the read surface of {@link CodecLookup} plus codec resolution by ref or
* column coordinate. Built once by `extractCodecLookup` and passed by reference to adapters and
* other consumers that need to materialise codecs at runtime.
*
* - `forCodecRef(ref)` materialises a codec from a {@link CodecRef}. Throws
* `RUNTIME.CODEC_DESCRIPTOR_MISSING` for unknown ids and `RUNTIME.TYPE_PARAMS_INVALID` on param
* schema rejection.
* - `forColumn(namespaceId, table, column)` returns the codec for a specific column coordinate, or
* `undefined` when no column-to-codec mapping is present. This registry is contract-free so it
* always returns `undefined` — the method exists so the object structurally satisfies the SQL
* `ContractCodecRegistry` interface.
*/
interface CodecRegistry extends CodecLookup {
forCodecRef(ref: CodecRef): Codec;
forColumn(namespaceId: string, table: string, column: string): Codec | undefined;
}
declare const emptyCodecLookup: CodecLookup;
/**
* Family-agnostic per-instance context supplied by the framework when applying a higher-order codec factory. Allows stateful codecs (e.g. column-scoped encryption) to derive per-instance state from the materialization site.
*
* - `name` — the family-agnostic instance identity. For SQL, the runtime populates this as the `storage.types` instance name (e.g. `Embedding1536`) for typeRef-shaped columns, an inline-column sentinel (`<col:Document.embedding>`) for inline-`typeParams` columns, a shared codec-id sentinel (`<codec:pg/text@1>`) for non-parameterized codec ids, or the canonical cache key (`<codecId>:<canonicalizeJson(typeParams)>`) for ad-hoc refs the contract walk did not pre-populate. Other families pick the analogous identity for their materialization sites.
*
* Family-specific extensions (e.g. {@link import('@prisma-next/sql-relational-core/ast').SqlCodecInstanceContext} in the SQL layer) augment this base with domain-shaped column-set metadata. Codec authors target the base when they don't read family-specific metadata; they target the family extension when they do.
*/
interface CodecInstanceContext {
readonly name: string;
}
/**
* Family-agnostic codec metadata. Family-specific extensions augment the base `db.<family>.<target>` block with native-type information; the base shape is an empty object so non-relational codecs can carry no metadata.
*/
interface CodecMeta {
readonly db?: Record<string, unknown>;
}
/**
* Standard Schema validator for `void` params. Accepts only `undefined` (or absent input); rejects any other value so a contract that tries to thread `typeParams` through a non-parameterized codec id fails fast at the JSON boundary instead of silently coercing the value away. Used by the framework-supplied non-parameterized descriptor synthesizer.
*/
declare const voidParamsSchema: StandardSchemaV1<void>;
//#endregion
export { CodecRef as a, emptyCodecLookup as c, CodecImpl as d, AnyCodecDescriptor as f, CodecMeta as i, voidParamsSchema as l, CodecDescriptorImpl as m, CodecInstanceContext as n, CodecRegistry as o, CodecDescriptor as p, CodecLookup as r, CodecTrait as s, CodecCallContext as t, Codec as u };
//# sourceMappingURL=codec-types-e32YHT3D.d.mts.map
{"version":3,"file":"codec-types-e32YHT3D.d.mts","names":[],"sources":["../src/shared/codec-descriptor.ts","../src/shared/codec.ts","../src/shared/codec-types.ts"],"mappings":";;;;;;;;;;;;;;;UA+BiB,eAAA;EAMN;EAAA,SAJA,OAAA;EAMO;EAAA,SAJP,MAAA,WAAiB,UAAA;EAMH;EAAA,SAJd,WAAA;EAMA;EAAA,SAJA,IAAA,GAAO,SAAA;EAMY;EAAA,SAJnB,YAAA,EAAc,gBAAA,CAAiB,CAAA;EAIN;EAAA,SAFzB,eAAA;EAI4B;EAAA,SAF5B,OAAA,IAAW,MAAA,EAAQ,CAAA,KAAM,SAAA;EAIzB;EAAA,SAFA,gBAAA,IAAoB,MAAA,EAAQ,CAAA;EAET;EAAA,SAAnB,eAAA,IAAmB,MAAA,EAAQ,CAAA;EAWE;;;;;;;;;;EAAA,SAA7B,kBAAA,IAAsB,KAAA,EAAO,SAAA,EAAW,IAAA;EAWvC;EAAA,SATD,OAAA,GAAU,MAAA,EAAQ,CAAA,MAAO,GAAA,EAAK,oBAAA,KAAyB,KAAA;AAAA;;AASlB;AAShD;;;KATY,kBAAA,GAAqB,eAAe;;;;;;;;uBAS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from "./types-import-spec-DRKzrJ20.mjs";
import { Contract, ContractModelBase, JsonValue } from "@prisma-next/contract/types";
//#region src/control/emission-types.d.ts
interface GenerateContractTypesOptions {
readonly queryOperationTypeImports?: ReadonlyArray<TypesImportSpec>;
}
interface ValidationContext {
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
readonly extensionIds?: ReadonlyArray<string>;
}
interface EmissionSpi {
readonly id: string;
generateStorageType(contract: Contract, storageHashTypeName: string): string;
generateModelStorageType(modelName: string, model: ContractModelBase): string;
getFamilyImports(): string[];
getFamilyTypeAliases(options?: GenerateContractTypesOptions): string;
getTypeMapsExpression(): string;
getContractWrapper(contractBaseName: string, typeMapsName: string): string;
resolveFieldTypeParams?(modelName: string, fieldName: string, model: ContractModelBase, contract: Contract): Record<string, unknown> | undefined;
/**
* Resolves a field's permitted values (codec-encoded) plus the codec that types them, or
* `undefined` for a field with no restricted value set. The framework renders the values into a TS
* literal union through the codec seam. Each family decides where the values live — a value set in
* its own storage plane, or another family-owned source.
*/
resolveFieldValueSet?(modelName: string, fieldName: string, model: ContractModelBase, contract: Contract): {
readonly encodedValues: readonly JsonValue[];
readonly codecId: string;
} | undefined;
getStorageTypeExports?(contract: Contract, codecLookup?: CodecLookup): string | undefined;
}
//#endregion
export { GenerateContractTypesOptions as n, ValidationContext as r, EmissionSpi as t };
//# sourceMappingURL=emission-types-BQMFUNQO.d.mts.map
{"version":3,"file":"emission-types-BQMFUNQO.d.mts","names":[],"sources":["../src/control/emission-types.ts"],"mappings":";;;;;UAIiB,4BAAA;EAAA,SACN,yBAAA,GAA4B,aAAa,CAAC,eAAA;AAAA;AAAA,UAGpC,iBAAA;EAAA,SACN,gBAAA,GAAmB,aAAA,CAAc,eAAA;EAAA,SACjC,YAAA,GAAe,aAAA;AAAA;AAAA,UAGT,WAAA;EAAA,SACN,EAAA;EAET,mBAAA,CAAoB,QAAA,EAAU,QAAA,EAAU,mBAAA;EAExC,wBAAA,CAAyB,SAAA,UAAmB,KAAA,EAAO,iBAAA;EAEnD,gBAAA;EAEA,oBAAA,CAAqB,OAAA,GAAU,4BAAA;EAE/B,qBAAA;EAEA,kBAAA,CAAmB,gBAAA,UAA0B,YAAA;EAE7C,sBAAA,EACE,SAAA,UACA,SAAA,UACA,KAAA,EAAO,iBAAA,EACP,QAAA,EAAU,QAAA,GACT,MAAA;EAvBqB;;;;;;EA+BxB,oBAAA,EACE,SAAA,UACA,SAAA,UACA,KAAA,EAAO,iBAAA,EACP,QAAA,EAAU,QAAA;IAAA,SACE,aAAA,WAAwB,SAAA;IAAA,SAAsB,OAAA;EAAA;EAE5D,qBAAA,EAAuB,QAAA,EAAU,QAAA,EAAU,WAAA,GAAc,WAAA;AAAA"}
import { r as CodecLookup } from "./codec-types-e32YHT3D.mjs";
import { ColumnDefault, ExecutionMutationDefaultPhases } from "@prisma-next/contract/types";
import { Type } from "arktype";
//#region src/shared/psl-extension-block.d.ts
/**
* Shape-only types for the PSL source-position primitives, diagnostic
* codes, extension-block descriptor vocabulary, and the uniform
* extension-block AST node base.
*
* These live in the shared plane so an extension's authoring descriptor
* (`AuthoringPslBlockDescriptor` in `framework-authoring`) can reference
* them without crossing the shared → migration-plane boundary. The
* migration-plane `psl-ast.ts` re-exports everything here for consumers
* that import PSL AST types from the control entrypoint.
*/
interface PslPosition {
readonly offset: number;
readonly line: number;
readonly column: number;
}
interface PslSpan {
readonly start: PslPosition;
readonly end: PslPosition;
}
type PslDiagnosticCode = 'PSL_UNTERMINATED_BLOCK' | 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK' | 'PSL_INVALID_NAMESPACE_BLOCK' | 'PSL_INVALID_ATTRIBUTE_SYNTAX' | 'PSL_INVALID_MODEL_MEMBER' | 'PSL_UNSUPPORTED_MODEL_ATTRIBUTE' | 'PSL_UNSUPPORTED_FIELD_ATTRIBUTE' | 'PSL_INVALID_RELATION_ATTRIBUTE' | 'PSL_INVALID_REFERENTIAL_ACTION' | 'PSL_INVALID_DEFAULT_VALUE' | 'PSL_INVALID_ENUM_MEMBER' | 'PSL_INVALID_TYPES_MEMBER' | 'PSL_INVALID_QUALIFIED_TYPE'
/**
* A qualified name (e.g. a dotted type or attribute reference) is structurally
* invalid, such as an over-qualified or trailing-separator name.
*/
| 'PSL_INVALID_QUALIFIED_NAME'
/**
* A reserved declaration keyword (`model`/`enum`/`namespace`/`type`) that
* committed the declaration kind on the keyword alone but is missing its name
* and/or opening brace. The recursive-descent parser produces a best-effort
* typed node for the malformed header and reports this code rather than
* `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK`, which is reserved for a genuinely unknown
* top-level keyword.
*/
| 'PSL_INVALID_DECLARATION'
/**
* A malformed line inside an extension-contributed top-level block body, or
* a structurally invalid element inside a `list` parameter value.
*
* Replaces the overloaded `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK` code that the
* generic framework parser previously used for these two parse-error sites
* inside extension blocks — keeping `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK` for
* its original meaning (an unknown keyword at the top level) and giving
* extension-block parse errors their own code.
*/
| 'PSL_INVALID_EXTENSION_BLOCK_MEMBER'
/**
* A malformed JS-like object literal `{ key: value, … }` in value/argument
* position — a field missing its `:`, a field missing its value, or an
* unterminated `{`. The recursive-descent parser still produces a best-effort
* `ObjectLiteralExpr` node (preserving the lossless round-trip) and reports
* this code anchored on the offending token.
*/
| 'PSL_INVALID_OBJECT_LITERAL'
/**
* A string literal with no closing quote — the tokenizer stops the literal at
* a newline or at EOF when no terminating `"` is found, and the
* recursive-descent parser still consumes the token (preserving the lossless
* round-trip) but reports this code anchored on the string token's span.
*/
| 'PSL_UNTERMINATED_STRING'
/**
* An unknown parameter key in an extension-contributed block — a key present
* in the source block but absent from the descriptor's `parameters` map.
*/
| 'PSL_EXTENSION_UNKNOWN_PARAMETER'
/**
* A required parameter declared in the descriptor is absent from the parsed block.
*/
| 'PSL_EXTENSION_MISSING_REQUIRED_PARAMETER'
/**
* An `option`-kind parameter value is not one of the allowed tokens listed
* in the descriptor's `values` array.
*/
| 'PSL_EXTENSION_OPTION_OUT_OF_SET'
/**
* A `value`-kind parameter's raw text is not a valid JSON literal, or the
* parsed JSON value was rejected by the codec's `decodeJson` method, or the
* codec id is not registered in the lookup.
*/
| 'PSL_EXTENSION_INVALID_VALUE'
/**
* A `ref`-kind parameter identifier does not resolve to a declared entity of
* the required `refKind` within the declared scope.
*/
| 'PSL_EXTENSION_UNRESOLVED_REF'
/**
* A parameter key appears more than once in an extension block body.
* The first occurrence is kept; subsequent occurrences emit this diagnostic.
*/
| 'PSL_EXTENSION_DUPLICATE_PARAMETER'
/**
* A `@@`-prefixed block-attribute line inside an extension block has invalid syntax.
*/
| 'PSL_INVALID_EXTENSION_BLOCK_ATTRIBUTE'
/**
* Duplicate scopes are top level, namespace body, or block fields; diagnostics
* are first-wins and anchored on later name spans.
*/
| 'PSL_DUPLICATE_DECLARATION';
/**
* Descriptor vocabulary for a single parameter on a declared block.
*
* Four kinds:
* - `ref` — the parameter value is an identifier that must resolve to a
* declared entity of `refKind` within the declared `scope`.
* - `value` — the parameter value is a PSL literal parsed and printed
* through the codec identified by `codecId`.
* - `option` — the parameter value is one of the literal tokens in `values`.
* Not a codec; not persisted data. A closed authoring-time constraint only.
* - `list` — a bracketed list whose elements each match the `of` descriptor.
*/
type PslBlockParam = PslBlockParamRef | PslBlockParamValue | PslBlockParamOption | PslBlockParamList;
interface PslBlockParamRef {
readonly kind: 'ref';
readonly refKind: string;
readonly scope: 'same-namespace' | 'same-space' | 'cross-space';
readonly required?: boolean;
}
interface PslBlockParamValue {
readonly kind: 'value';
readonly codecId: string;
readonly required?: boolean;
}
interface PslBlockParamOption {
readonly kind: 'option';
readonly values: readonly string[];
readonly required?: boolean;
}
interface PslBlockParamList {
readonly kind: 'list';
readonly of: PslBlockParam;
readonly required?: boolean;
}
/**
* The parsed representation of a single parameter value on a uniform
* extension-block AST node. Mirrors the `PslBlockParam` descriptor
* vocabulary, plus `bare` for keyonly entries:
*
* - `ref` → `PslExtensionBlockParamRef` — a raw identifier string
* (resolution runs in the validator, not the parser).
* - `value` → `PslExtensionBlockParamScalarValue` — a raw PSL literal string
* (codec validation runs in the validator).
* - `option` → `PslExtensionBlockParamOption` — the chosen token.
* - `list` → `PslExtensionBlockParamList` — ordered list of the above.
* - `bare` → `PslExtensionBlockParamBare` — a bare identifier line with no
* `= value` (e.g. `Low` in an enum block). The name is the key in
* `parameters`; the interpreting consumer decides the default value.
*
* These shapes are intentionally minimal. The validator and lowering refine
* and consume them; the generic framework parser produces them.
*/
type PslExtensionBlockParamValue = PslExtensionBlockParamRef | PslExtensionBlockParamScalarValue | PslExtensionBlockParamOption | PslExtensionBlockParamList | PslExtensionBlockParamBare;
interface PslExtensionBlockParamRef {
readonly kind: 'ref';
readonly identifier: string;
readonly span: PslSpan;
}
interface PslExtensionBlockParamScalarValue {
readonly kind: 'value';
readonly raw: string;
readonly span: PslSpan;
}
interface PslExtensionBlockParamOption {
readonly kind: 'option';
readonly token: string;
readonly span: PslSpan;
}
interface PslExtensionBlockParamList {
readonly kind: 'list';
readonly items: readonly PslExtensionBlockParamValue[];
readonly span: PslSpan;
}
/**
* A bare identifier line inside an extension block — a key with no `= value`.
* Emitted when a line matches `/^[A-Za-z_]\w*$/` with no assignment. The
* consumer decides what default value (if any) to apply.
*/
interface PslExtensionBlockParamBare {
readonly kind: 'bare';
readonly span: PslSpan;
}
/**
* A positional argument on a block attribute, e.g. the `"pg/text@1"` in
* `@@type("pg/text@1")`.
*/
interface PslExtensionBlockAttributeArg {
readonly kind: 'positional';
readonly value: string;
readonly span: PslSpan;
}
/**
* A `@@`-prefixed block-level attribute parsed inside an extension block,
* e.g. `@@type("pg/text@1")`. Block attributes are captured generically
* — the parser does not validate attribute names or argument shapes; that
* is a concern of the block's interpreter.
*/
interface PslExtensionBlockAttribute {
readonly name: string;
readonly args: readonly PslExtensionBlockAttributeArg[];
readonly span: PslSpan;
}
/**
* Base shape for a uniform extension-contributed top-level PSL block
* node, as produced by the generic framework parser and consumed by the
* validator, printer, and lowering factory.
*
* - `kind` is the routing discriminant, equal to the descriptor's
* `discriminator`. The framework parser sets this to
* `descriptor.discriminator` for every block it parses. Several keywords
* may share one discriminator (e.g. `policy_select`/`policy_insert` both
* route to `kind: 'policy'`) — `kind` identifies the entity/storage kind,
* not the source syntax.
* - `keyword` is the source PSL keyword the block was declared with
* (`policy_select`, `policy_insert`, …) — the parse-dispatch identity.
* Distinct from `kind` precisely when a discriminator is shared by more
* than one keyword; a lowering factory that contributes several keywords
* under one discriminator reads `keyword` to tell its blocks apart, and
* the printer re-emits each block under its own `keyword` regardless of
* how many other keywords share its `kind`.
* - `name` is the block's declared name (the identifier after the keyword).
* - `parameters` is the descriptor-driven parameter map. Keys are
* parameter names from the descriptor; values are the parsed parameter
* representations. Only parameters present in the source are included
* — absence of a required parameter is a validator concern, not a
* parser concern. Insertion order is preserved; the first occurrence of a
* duplicate key is retained and subsequent occurrences emit
* `PSL_EXTENSION_DUPLICATE_PARAMETER`.
* - `blockAttributes` are `@@`-prefixed attribute lines inside the block, in
* declaration order. Captured generically — names and args are not validated
* by the parser.
* - `span` covers the full block from keyword to closing brace.
*/
interface PslExtensionBlock {
readonly kind: string;
/**
* The block's parse identity — the source PSL keyword it was declared
* with. `kind`/`discriminator` is its storage identity; several keywords
* can share one. E.g. the five `policy_*` keywords all lower to the
* `policy` entity kind.
*/
readonly keyword: string;
readonly name: string;
readonly parameters: Record<string, PslExtensionBlockParamValue>;
readonly blockAttributes: readonly PslExtensionBlockAttribute[];
readonly span: PslSpan;
}
//#endregion
//#region src/shared/framework-authoring.d.ts
type AuthoringArgRef = {
readonly kind: 'arg';
readonly index: number;
readonly path?: readonly string[];
readonly default?: AuthoringTemplateValue;
};
type AuthoringTemplateValue = string | number | boolean | null | AuthoringArgRef | readonly AuthoringTemplateValue[] | {
readonly [key: string]: AuthoringTemplateValue;
};
interface AuthoringArgumentDescriptorCommon {
readonly name?: string;
readonly optional?: boolean;
}
type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon & ({
readonly kind: 'string';
} | {
readonly kind: 'boolean';
} | {
readonly kind: 'number';
readonly integer?: boolean;
readonly minimum?: number;
readonly maximum?: number;
} | {
readonly kind: 'stringArray';
} | {
readonly kind: 'object';
readonly properties: Record<string, AuthoringArgumentDescriptor>;
});
interface AuthoringStorageTypeTemplate {
readonly codecId: string;
/**
* Optional so a type constructor whose {@link AuthoringTypeConstructorDescriptor.entityRefArg}
* names another entity can omit this template entirely — its output for
* that case is derived by the codec at `codecId`, not by resolving a
* literal here. Every other consumer of this shape (field presets, plain
* type constructors) always supplies it.
*/
readonly nativeType?: AuthoringTemplateValue;
readonly typeParams?: Record<string, AuthoringTemplateValue>;
}
/**
* Declares that one positional argument of a
* {@link AuthoringTypeConstructorDescriptor} call names another entity
* parsed from the same document, rather than carrying a literal value (e.g.
* `pg.enum(AalLevel)` naming a `native_enum` entity). `index` is the
* argument's position in the call; `entityKind` is the entries-slot
* discriminator the interpreter looks the named entity up under (the same
* shape {@link AuthoringEntityTypeFactoryOutput.factory} output is collected
* into, keyed by discriminator then block name).
*
* The interpreter resolves the named argument to the entity instance
* generically, driven only by this declaration — it has no target-specific
* knowledge of which type constructors carry one. Converting the resolved
* entity into the constructor's params is a separate, codec-owned concern:
* the codec descriptor registered for `output.codecId` supplies that
* conversion, not this framework type.
*/
interface AuthoringTypeConstructorEntityRef {
readonly index: number;
readonly entityKind: string;
}
interface AuthoringTypeConstructorDescriptor {
readonly kind: 'typeConstructor';
readonly args?: readonly AuthoringArgumentDescriptor[];
readonly output: AuthoringStorageTypeTemplate;
/** Present when one of this constructor's positional arguments names another document-local entity instead of carrying a literal value. Absent for ordinary literal-argument constructors. */
readonly entityRefArg?: AuthoringTypeConstructorEntityRef;
}
interface AuthoringColumnDefaultTemplateLiteral {
readonly kind: 'literal';
readonly value: AuthoringTemplateValue;
}
interface AuthoringColumnDefaultTemplateFunction {
readonly kind: 'function';
readonly expression: AuthoringTemplateValue;
}
type AuthoringColumnDefaultTemplate = AuthoringColumnDefaultTemplateLiteral | AuthoringColumnDefaultTemplateFunction;
interface AuthoringExecutionDefaultsTemplate {
readonly onCreate?: AuthoringTemplateValue;
readonly onUpdate?: AuthoringTemplateValue;
}
interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {
readonly nullable?: boolean;
readonly default?: AuthoringColumnDefaultTemplate;
readonly executionDefaults?: AuthoringExecutionDefaultsTemplate;
readonly id?: boolean;
readonly unique?: boolean;
}
interface AuthoringFieldPresetDescriptor {
readonly kind: 'fieldPreset';
readonly args?: readonly AuthoringArgumentDescriptor[];
readonly output: AuthoringFieldPresetOutput;
}
type AuthoringTypeNamespace = {
readonly [name: string]: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace;
};
type AuthoringFieldNamespace = {
readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;
};
/**
* Context surfaced to entity-type factories at call time. Currently a
* placeholder — sharpened as concrete consumers (enum, namespace, …)
* discover what the factory actually needs to read (codec lookup,
* namespace registry, …).
*/
/**
* A write-only sink that a factory may push authoring-time diagnostics into.
* The concrete type pushed must be structurally compatible with whatever the
* consumer accumulates (typically `ContractSourceDiagnostic[]`); the framework
* layer deliberately does not depend on that concrete type.
*/
interface AuthoringDiagnosticSink {
push(d: {
readonly code: string;
readonly message: string;
readonly sourceId: string;
readonly span?: unknown;
}): void;
}
interface AuthoringEntityContext {
readonly family: string;
readonly target: string;
/** Codec registry available to factories that need to validate or decode values. */
readonly codecLookup?: CodecLookup;
/** Source file identifier threaded into diagnostics emitted by the factory. */
readonly sourceId?: string;
/** Push channel for authoring-time diagnostics emitted by the factory. */
readonly diagnostics?: AuthoringDiagnosticSink;
/**
* The target's default codec ids for an `enum` block that omits `@@type`.
* `text` is used when every member is a bare name or a string value;
* `int` is used when every member is an integer value. Every target pack
* populates this so `@@type` omission can be inferred consistently.
*/
readonly enumInferenceCodecs?: {
readonly text: string;
readonly int: string;
};
}
/**
* Classifies an `enum` block's members (before codec decoding, which needs
* the codec chosen first) into which default codec an omitted `@@type`
* should resolve to:
*
* - every member is `bare`, or a `value` whose raw JSON is a string → `'text'`
* - every member is a `value` whose raw JSON is an integer → `'int'`
* - anything else (float, bigint, boolean, mixed, or a `ref`/`option`/`list`
* parameter) → `null`, meaning the caller must require an explicit `@@type`.
*/
declare function classifyEnumMemberType(block: PslExtensionBlock): 'text' | 'int' | null;
/**
* Resolves the codec id for an `enum` block. When `@@type` is absent, the codec
* is inferred from the members via {@link classifyEnumMemberType}; otherwise the
* explicit `@@type("codec")` argument is parsed. Pushes the appropriate
* diagnostic and returns `undefined` when neither yields a codec. `codecSpan` is
* the span downstream codec-validation diagnostics should anchor to. Shared by
* every family's enum factory so inference and the explicit path stay identical.
*/
declare function resolveEnumCodecId(block: PslExtensionBlock, ctx: AuthoringEntityContext): {
readonly codecId: string;
readonly codecSpan: PslSpan;
} | undefined;
interface AuthoringEntityTypeTemplateOutput {
readonly template: AuthoringTemplateValue;
}
/**
* Default `Input = never` is load-bearing for pack-bag-driven type
* narrowing. Factory parameter positions are contravariant, so a pack
* literal declaring `factory: (input: DemoEntityInput) => DemoEntity`
* is only assignable to the base descriptor's factory shape if the
* base's input is `never` (the bottom of the contravariant position).
* The concrete input/output types are recovered at the helper-derivation
* site via `EntityHelperFunction<Descriptor>`'s conditional inference,
* which reads them from the pack's `as const` literal factory signature
* — the base widening does not erase the literal because `satisfies`
* does not widen the declared type.
*/
interface AuthoringEntityTypeFactoryOutput<Input = never, Output = unknown> {
readonly factory: (input: Input, ctx: AuthoringEntityContext) => Output;
}
interface AuthoringEntityTypeDescriptor<Input = never, Output = unknown> {
readonly kind: 'entity';
readonly discriminator: string;
readonly args?: readonly AuthoringArgumentDescriptor[];
readonly output: AuthoringEntityTypeTemplateOutput | AuthoringEntityTypeFactoryOutput<Input, Output>;
/**
* arktype schema fragment for one entry whose envelope `kind` matches
* this descriptor's {@link discriminator}. The family validator composes
* contributed fragments into the per-namespace entry schema at
* validator construction time so the structural check covers
* pack-introduced kinds without the family core hard-coding the schema.
*
* Hydration uses {@link AuthoringEntityTypeFactoryOutput.factory}
* directly — the wire shape conforms structurally to the factory's
* `Input` after `validatorSchema` validates it.
*/
readonly validatorSchema?: Type<unknown>;
}
type AuthoringEntityTypeNamespace = {
readonly [name: string]: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace;
};
/**
* Declarative descriptor for an extension-contributed top-level PSL block.
*
* An extension registers one of these per keyword it contributes. The
* framework owns the generic parser, validator, and printer — no
* parsing or printing code runs from the extension.
*
* - `keyword` is the PSL top-level identifier this descriptor claims
* (`policy_select`, `role`, …).
* - `discriminator` is the routing key used by the printer dispatch and
* the `entityTypes` lowering factory lookup. Convention:
* `<target-or-family>-<kind>` (`postgres-policy-select`).
* - `name.required` declares whether the block must have a name token
* after the keyword. Currently always `true` — anonymous blocks are
* not part of the closed-grammar premise — but the field is explicit
* so the type can evolve without a breaking change.
* - `parameters` maps parameter names to their value-kind descriptors
* (`ref` / `value` / `option` / `list`). The generic parser and
* validator interpret these; the extension supplies no parser or
* printer function.
*/
interface AuthoringPslBlockDescriptor {
readonly kind: 'pslBlock';
readonly keyword: string;
readonly discriminator: string;
readonly name: {
readonly required: boolean;
};
readonly parameters: Record<string, PslBlockParam>;
/**
* When `true`, the block body accepts a variadic tail of parameters beyond
* the declared set. The block body may contain: fields (model-style),
* `key = value` parameters, and `@@` attributes. With `variadicParameters`,
* bare identifiers (keys without a `= value`) and undeclared `key = value`
* pairs flow into the variadic tail — their semantics belong to the
* lowering, not the parser.
*
* A key that IS declared in `parameters` must still be supplied as
* `key = value`; a bare occurrence of a declared key is a diagnostic.
*
* When `false` (default), the validator emits `PSL_EXTENSION_UNKNOWN_PARAMETER`
* for keys absent from `parameters`.
*/
readonly variadicParameters?: boolean;
/**
* Declares that the model named by the block's ref parameter `parameter`
* must carry the bare `@@` model attribute `attribute`. The family
* interpreter enforces this generically over the whole parsed document —
* declaration order of the block and the model does not matter — and
* emits `PSL_EXTENSION_TARGET_MODEL_MISSING_ATTRIBUTE` naming the block
* and the model when the attribute is absent. A parameter that is
* missing or does not resolve to a model is not this rule's concern
* (missing-parameter and unresolved-ref diagnostics own those cases).
*/
readonly requiresModelAttribute?: {
readonly parameter: string;
readonly attribute: string;
};
}
type AuthoringPslBlockDescriptorNamespace = {
readonly [name: string]: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace;
};
/**
* Context surfaced to a model-attribute lowering at call time: the entity
* context shared with entity-type factories, plus the declaring model's
* name, its mapped storage name (the name of the storage object the model
* maps to; which kind of object that is belongs to the family, not the
* framework), and the namespace id the lowered entity should be filed
* under.
*/
interface AuthoringModelAttributeContext extends AuthoringEntityContext {
readonly modelName: string;
readonly storageName: string;
readonly namespaceId: string;
}
/**
* What a model-attribute lowering returns when it produces an entity: `key`
* is the identity the entity is stored under within its `entries` slot
* (`entries[attribute][key]`); `entity` is the value stored there. A
* lowering that instead pushed a diagnostic through
* {@link AuthoringModelAttributeContext.diagnostics} returns `undefined` —
* the same convention {@link AuthoringEntityTypeFactoryOutput} uses.
*/
interface AuthoringModelAttributeLoweringOutput {
readonly key: string;
readonly entity: unknown;
}
/**
* Declarative descriptor for an extension-contributed `@@` model attribute.
*
* An extension registers one of these per bare attribute name it
* contributes. The framework owns the generic consult in the interpreter's
* model-attribute loop; the contribution supplies only `spec` and `lower`.
*
* - `attribute` is the bare `@@` attribute name this descriptor claims and,
* by the one-string rule, the `entries` slot its lowered entities are
* grouped under (`entries[attribute][key]`).
* - `spec` is opaque to the framework core: an ADR-231 attribute-spec kit
* `AttributeSpec<Out>` value (`modelAttribute(name, {...})` from
* `@prisma-next/psl-parser`). Framework core does not depend on
* psl-parser and never inspects this field; the family interpreter,
* which does depend on psl-parser, parses the attribute's arguments
* against it.
* - `lower` receives the parsed arguments and the declaring model's
* context, and returns the entity to file into `entries`, or `undefined`
* after pushing a diagnostic via `ctx.diagnostics`.
*
* `Out` defaults to `never` — not `unknown` — for the same contravariance
* reason documented on {@link AuthoringEntityTypeFactoryOutput}: a concrete
* pack literal's narrower `lower(parsed: ConcreteOut, ctx)` is only
* assignable to this base shape when the base parameter is the bottom type.
*/
interface AuthoringModelAttributeDescriptor<Out = never> {
readonly kind: 'modelAttribute';
readonly attribute: string;
readonly spec: unknown;
readonly lower: (parsed: Out, ctx: AuthoringModelAttributeContext) => AuthoringModelAttributeLoweringOutput | undefined;
}
type AuthoringModelAttributeDescriptorNamespace = {
readonly [name: string]: AuthoringModelAttributeDescriptor | AuthoringModelAttributeDescriptorNamespace;
};
interface AuthoringContributions {
readonly type?: AuthoringTypeNamespace;
readonly field?: AuthoringFieldNamespace;
readonly entityTypes?: AuthoringEntityTypeNamespace;
/**
* Registry of declarative block descriptors this contribution registers,
* keyed by arbitrary path segments. Each leaf is an
* {@link AuthoringPslBlockDescriptor} that claims a PSL top-level keyword.
* The framework owns the generic parser, validator, and printer; the
* contribution supplies only these declarative descriptors.
*
* Contrast with the parsed block nodes themselves, which live in a
* namespace's `entries` under their discriminator key; this field holds the
* registry of descriptors that teach the parser how to read those blocks.
*/
readonly pslBlockDescriptors?: AuthoringPslBlockDescriptorNamespace;
/**
* Registry of declarative `@@` model attribute descriptors this
* contribution registers, keyed by arbitrary path segments. Each leaf is
* an {@link AuthoringModelAttributeDescriptor} that claims a bare model
* attribute name. The framework owns the generic consult in the family
* interpreter's model-attribute loop; the contribution supplies only the
* declarative spec and the lowering.
*/
readonly modelAttributes?: AuthoringModelAttributeDescriptorNamespace;
}
declare function isAuthoringArgRef(value: unknown): value is AuthoringArgRef;
declare function isAuthoringTypeConstructorDescriptor(value: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace): value is AuthoringTypeConstructorDescriptor;
declare function isAuthoringFieldPresetDescriptor(value: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace): value is AuthoringFieldPresetDescriptor;
declare function isAuthoringEntityTypeDescriptor(value: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace): value is AuthoringEntityTypeDescriptor;
declare function isAuthoringPslBlockDescriptor(value: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace): value is AuthoringPslBlockDescriptor;
declare function isAuthoringModelAttributeDescriptor(value: AuthoringModelAttributeDescriptor | AuthoringModelAttributeDescriptorNamespace): value is AuthoringModelAttributeDescriptor;
/**
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
*
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
* registration must NOT be treated as a "namespace" with sub-paths. Callers
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
*/
declare function hasRegisteredFieldNamespace(contributions: AuthoringContributions | undefined, namespace: string): boolean;
/**
* Merges `source` into `target` recursively at the descriptor-namespace
* level. `descriptorKind` is the `kind` value ('typeConstructor',
* 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
* (terminal merge point; same-path registrations across components are
* reported as duplicates) as opposed to a sub-namespace (recursion target).
*
* Path segments are validated against prototype-pollution names
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
* recognized leaf nor a plain object — e.g. a malformed descriptor
* where the canonical leaf guard rejected it for missing `output` —
* is reported as an invalid contribution rather than recursed into,
* which would either silently mangle state or infinite-loop on
* primitive properties.
*
* Within-registry duplicate detection is this walker's job;
* cross-registry detection runs separately via
* `assertNoCrossRegistryCollisions` after merging completes.
*/
declare function mergeAuthoringNamespaces(target: Record<string, unknown>, source: Record<string, unknown>, path: readonly string[], descriptorKind: string, label: string): void;
declare function assertNoCrossRegistryCollisions(typeNamespace: AuthoringTypeNamespace, fieldNamespace: AuthoringFieldNamespace, entityTypeNamespace?: AuthoringEntityTypeNamespace, pslBlockNamespace?: AuthoringPslBlockDescriptorNamespace, modelAttributeNamespace?: AuthoringModelAttributeDescriptorNamespace): void;
declare function resolveAuthoringTemplateValue(template: AuthoringTemplateValue | undefined, args: readonly unknown[]): unknown;
declare function validateAuthoringHelperArguments(helperPath: string, descriptors: readonly AuthoringArgumentDescriptor[] | undefined, args: readonly unknown[]): void;
declare function instantiateAuthoringTypeConstructor(descriptor: AuthoringTypeConstructorDescriptor, args: readonly unknown[]): {
readonly codecId: string;
readonly nativeType: string;
readonly typeParams?: Record<string, unknown>;
};
declare function instantiateAuthoringEntityType<TOutput = unknown>(helperPath: string, descriptor: AuthoringEntityTypeDescriptor, args: readonly unknown[], ctx: AuthoringEntityContext): TOutput;
declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPresetDescriptor, args: readonly unknown[]): {
readonly descriptor: {
readonly codecId: string;
readonly nativeType: string;
readonly typeParams?: Record<string, unknown>;
};
readonly nullable: boolean;
readonly default?: ColumnDefault;
readonly executionDefaults?: ExecutionMutationDefaultPhases;
readonly id: boolean;
readonly unique: boolean;
};
//#endregion
export { PslExtensionBlockParamRef as $, instantiateAuthoringTypeConstructor as A, validateAuthoringHelperArguments as B, AuthoringTypeConstructorEntityRef as C, hasRegisteredFieldNamespace as D, classifyEnumMemberType as E, isAuthoringPslBlockDescriptor as F, PslBlockParamValue as G, PslBlockParamList as H, isAuthoringTypeConstructorDescriptor as I, PslExtensionBlockAttribute as J, PslDiagnosticCode as K, mergeAuthoringNamespaces as L, isAuthoringEntityTypeDescriptor as M, isAuthoringFieldPresetDescriptor as N, instantiateAuthoringEntityType as O, isAuthoringModelAttributeDescriptor as P, PslExtensionBlockParamOption as Q, resolveAuthoringTemplateValue as R, AuthoringTypeConstructorDescriptor as S, assertNoCrossRegistryCollisions as T, PslBlockParamOption as U, PslBlockParam as V, PslBlockParamRef as W, PslExtensionBlockParamBare as X, PslExtensionBlockAttributeArg as Y, PslExtensionBlockParamList as Z, AuthoringModelAttributeLoweringOutput as _, AuthoringDiagnosticSink as a, AuthoringStorageTypeTemplate as b, AuthoringEntityTypeFactoryOutput as c, AuthoringFieldNamespace as d, PslExtensionBlockParamScalarValue as et, AuthoringFieldPresetDescriptor as f, AuthoringModelAttributeDescriptorNamespace as g, AuthoringModelAttributeDescriptor as h, AuthoringContributions as i, isAuthoringArgRef as j, instantiateAuthoringFieldPreset as k, AuthoringEntityTypeNamespace as l, AuthoringModelAttributeContext as m, AuthoringArgumentDescriptor as n, PslPosition as nt, AuthoringEntityContext as o, AuthoringFieldPresetOutput as p, PslExtensionBlock as q, AuthoringColumnDefaultTemplate as r, PslSpan as rt, AuthoringEntityTypeDescriptor as s, AuthoringArgRef as t, PslExtensionBlockParamValue as tt, AuthoringEntityTypeTemplateOutput as u, AuthoringPslBlockDescriptor as v, AuthoringTypeNamespace as w, AuthoringTemplateValue as x, AuthoringPslBlockDescriptorNamespace as y, resolveEnumCodecId as z };
//# sourceMappingURL=framework-authoring-DEadmUb3.d.mts.map
{"version":3,"file":"framework-authoring-DEadmUb3.d.mts","names":[],"sources":["../src/shared/psl-extension-block.ts","../src/shared/framework-authoring.ts"],"mappings":";;;;;;;;;;AAYA;;;;;;UAAiB,WAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,OAAA;EAAA,SACN,KAAA,EAAO,WAAA;EAAA,SACP,GAAA,EAAK,WAAW;AAAA;AAAA,KAGf,iBAAA;;;AAHe;AAG3B;;;;AAA6B;AA0G7B;;;;;;;;;;;;;;AAIqB;AAErB;;;;;;;;;;AAOA;;;;;;AAAA;;AAGmB;AAGnB;;;;;;;;AAGmB;AAGnB;;;;;;;;;AAGmB;AAqBnB;;;AArBmB;;;;;;;;;;;;;AA0BW;;;;;;;;;;AAKN;AAGxB;;;KA9DY,aAAA,GACR,gBAAA,GACA,kBAAA,GACA,mBAAA,GACA,iBAAA;AAAA,UAEa,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA;EAAA,SACA,QAAA;AAAA;AAAA,UAGM,kBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA;AAAA,UAGM,mBAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA;EAAA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A,SACE,OAAA;IAAA,SACA,UAAA;IAAA,SACA,UAAA,GAAa,MAAA;EAAA;EAAA,SAEf,QAAA;EAAA,SACA,OAAA,GAAU,aAAA;EAAA,SACV,iBAAA,GAAoB,8BAAA;EAAA,SACpB,EAAA;EAAA,SACA,MAAA;AAAA"}
import { f as AnyCodecDescriptor } from "./codec-types-e32YHT3D.mjs";
import { i as AuthoringContributions } from "./framework-authoring-DEadmUb3.mjs";
import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
import { ColumnDefault, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
//#region src/shared/mutation-default-types.d.ts
interface SourcePosition {
readonly offset: number;
readonly line: number;
readonly column: number;
}
interface SourceSpan {
readonly start: SourcePosition;
readonly end: SourcePosition;
}
interface SourceDiagnostic {
readonly code: string;
readonly message: string;
readonly sourceId?: string;
readonly span?: SourceSpan;
readonly data?: Readonly<Record<string, unknown>>;
}
interface DefaultFunctionLoweringContext {
readonly sourceId: string;
readonly modelName: string;
readonly fieldName: string;
readonly columnCodecId?: string;
}
type LoweredDefaultValue = {
readonly kind: 'storage';
readonly defaultValue: ColumnDefault;
} | {
readonly kind: 'execution';
readonly generated: ExecutionMutationDefaultValue;
};
type LoweredDefaultResult = {
readonly ok: true;
readonly value: LoweredDefaultValue;
} | {
readonly ok: false;
readonly diagnostic: SourceDiagnostic;
};
interface MutationDefaultGeneratorDescriptor {
readonly id: string;
/**
* Codec ids the generator is compatible with when the codec choice
* and the generator choice are made independently by the contract
* author. Set when the registry-coherence check is meaningful
* (the codec and the generator can be paired arbitrarily by the
* caller); omitted when the generator is only reachable through a
* descriptor that co-registers a fixed codec, so coherence is
* structural and the list would be tautological.
*/
readonly applicableCodecIds?: readonly string[];
readonly resolveGeneratedColumnDescriptor?: (input: {
readonly generated: ExecutionMutationDefaultValue;
}) => {
readonly codecId: string;
readonly nativeType: string;
readonly typeRef?: string;
readonly typeParams?: Record<string, unknown>;
} | undefined;
/**
* Construct the `onCreate`/`onUpdate` phases value owned by this
* generator. Authoring layers (PSL `temporal.updatedAt()`, TS field presets) call
* this instead of building the literal inline so PSL/TS-authored
* contracts stay byte-equivalent for any future params-bearing generator.
*/
readonly buildPhases?: (args?: Record<string, unknown>) => ExecutionMutationDefaultPhases;
}
interface TypedDefaultFunctionCall {
readonly fn: string;
readonly span: SourceSpan;
readonly args: Readonly<Record<string, unknown>>;
}
interface ControlMutationDefaultEntry {
readonly signature?: unknown;
readonly lower: (input: {
readonly call: TypedDefaultFunctionCall;
readonly context: DefaultFunctionLoweringContext;
}) => LoweredDefaultResult;
readonly usageSignatures?: readonly string[];
}
type ControlMutationDefaultRegistry = ReadonlyMap<string, ControlMutationDefaultEntry>;
interface ControlMutationDefaults {
readonly defaultFunctionRegistry: ControlMutationDefaultRegistry;
readonly generatorDescriptors: readonly MutationDefaultGeneratorDescriptor[];
}
//#endregion
//#region src/shared/framework-components.d.ts
/**
* Declarative fields that describe component metadata.
*/
interface ComponentMetadata {
/** Component version (semver) */
readonly version: string;
/**
* Capabilities this component provides.
*
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`); keep these declarations in sync. Targets are identifiers/descriptors and typically do not declare capabilities.
*/
readonly capabilities?: Record<string, unknown>;
/** Type imports for contract.d.ts generation */
readonly types?: {
readonly codecTypes?: {
/**
* Base codec types import spec. Optional: adapters typically provide this, extensions usually don't.
*/
readonly import?: TypesImportSpec;
/**
* Additional type-only imports for parameterized codec branded types.
*
* These imports are included in generated `contract.d.ts` but are NOT treated as codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
*
* Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`
*/
readonly typeImports?: ReadonlyArray<TypesImportSpec>;
/**
* Optional control-plane hooks keyed by codecId. Used by family-specific planners/verifiers to handle storage types.
*/
readonly controlPlaneHooks?: Record<string, unknown>;
/**
* Codec descriptors contributed by this component. Source of truth for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`, `renderOutputType`) consumed by `extractCodecLookup`, and used to materialize representative `Codec` instances for codec-dispatched type rendering during emission.
*/
readonly codecDescriptors?: ReadonlyArray<AnyCodecDescriptor>;
};
readonly queryOperationTypes?: {
readonly import: TypesImportSpec;
};
readonly storage?: ReadonlyArray<{
readonly typeId: string;
readonly familyId: string;
readonly targetId: string;
readonly nativeType?: string;
}>;
};
/**
* Optional pure-data authoring contributions exposed by this component.
*
* These contributions are safe to include on pack refs and descriptors because they contain only declarative metadata. Higher-level authoring packages may project them into concrete helper functions for TS-first workflows.
*/
readonly authoring?: AuthoringContributions;
/**
* Scalar type name to codec ID mapping contributed by this component. Assembled by `createControlStack` with duplicate detection.
*/
readonly scalarTypeDescriptors?: ReadonlyMap<string, string>;
/**
* Mutation default function handlers and generator descriptors contributed by this component. Assembled by `createControlStack` with duplicate detection.
*/
readonly controlMutationDefaults?: ControlMutationDefaults;
}
/**
* Base descriptor for any framework component.
*
* All component descriptors share these fundamental properties that identify the component and provide its metadata. This interface is extended by specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
*
* @template Kind - Discriminator literal identifying the component type. Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension', but the type accepts any string to allow ecosystem extensions.
*
* @example
* ```ts
* // All descriptors have these properties
* descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)
* descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')
* descriptor.version // Component version (semver)
* ```
*/
interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {
/** Discriminator identifying the component type */
readonly kind: Kind;
/** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */
readonly id: string;
}
interface ContractComponentRequirementsCheckInput {
readonly contract: {
readonly target: string;
readonly targetFamily?: string | undefined;
readonly extensionPacks?: Record<string, unknown> | undefined;
};
readonly expectedTargetFamily?: string | undefined;
readonly expectedTargetId?: string | undefined;
readonly providedComponentIds: Iterable<string>;
}
interface ContractComponentRequirementsCheckResult {
readonly familyMismatch?: {
readonly expected: string;
readonly actual: string;
} | undefined;
readonly targetMismatch?: {
readonly expected: string;
readonly actual: string;
} | undefined;
readonly missingExtensionPackIds: readonly string[];
}
declare function checkContractComponentRequirements(input: ContractComponentRequirementsCheckInput): ContractComponentRequirementsCheckResult;
/**
* Descriptor for a family component.
*
* A "family" represents a category of data sources with shared semantics (e.g., SQL databases, document stores). Families define:
* - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
* - Contract structure (tables vs collections, columns vs fields)
* - Type system and codecs
*
* Families are the top-level grouping. Each family contains multiple targets (e.g., SQL family contains Postgres, MySQL, SQLite targets).
*
* Extended by plane-specific descriptors:
* - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations
* - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods
*
* @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')
*
* @example
* ```ts
* import sql from '@prisma-next/family-sql/control';
*
* sql.kind // 'family'
* sql.familyId // 'sql'
* sql.id // 'sql'
* ```
*/
interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {
/** The family identifier (e.g., 'sql', 'document') */
readonly familyId: TFamilyId;
}
/**
* Descriptor for a target component.
*
* A "target" represents a specific database or data store within a family (e.g., Postgres, MySQL, MongoDB). Targets define:
* - Native type mappings (e.g., Postgres int4 → TypeScript number)
* - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
*
* Targets are bound to a family and provide the target-specific implementation details that adapters and drivers use.
*
* Extended by plane-specific descriptors:
* - `ControlTargetDescriptor` - adds optional `migrations` capability
* - `RuntimeTargetDescriptor` - adds runtime factory method
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')
*
* @example
* ```ts
* import postgres from '@prisma-next/target-postgres/control';
*
* postgres.kind // 'target'
* postgres.familyId // 'sql'
* postgres.targetId // 'postgres'
* ```
*/
interface TargetDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'target'> {
/** The family this target belongs to */
readonly familyId: TFamilyId;
/** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
readonly targetId: TTargetId;
}
/**
* Base shape for any pack reference. Pack refs are pure JSON-friendly objects safe to import in authoring flows.
*/
interface PackRefBase<Kind extends string, TFamilyId extends string> extends ComponentMetadata {
readonly kind: Kind;
readonly id: string;
readonly familyId: TFamilyId;
readonly targetId?: string;
readonly authoring?: AuthoringContributions;
}
type FamilyPackRef<TFamilyId extends string = string> = PackRefBase<'family', TFamilyId>;
type TargetPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'target', TFamilyId> & {
readonly targetId: TTargetId; /** The namespace a bare (un-namespaced) entity name resolves to for this target (e.g. Postgres `'public'`). */
readonly defaultNamespaceId: string;
};
type AdapterPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'adapter', TFamilyId> & {
readonly targetId: TTargetId;
};
type ExtensionPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'extension', TFamilyId> & {
readonly targetId: TTargetId;
};
type DriverPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'driver', TFamilyId> & {
readonly targetId: TTargetId;
};
/**
* Descriptor for an adapter component.
*
* An "adapter" provides the protocol and dialect implementation for a target. Adapters handle:
* - SQL/query generation (lowering AST to target-specific syntax)
* - Codec registration (encoding/decoding between JS and wire types)
* - Type mappings and coercions
*
* Adapters are bound to a specific family+target combination and work with any compatible driver for that target.
*
* Extended by plane-specific descriptors:
* - `ControlAdapterDescriptor` - control-plane factory
* - `RuntimeAdapterDescriptor` - runtime factory
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier
*
* @example
* ```ts
* import postgresAdapter from '@prisma-next/adapter-postgres/control';
*
* postgresAdapter.kind // 'adapter'
* postgresAdapter.familyId // 'sql'
* postgresAdapter.targetId // 'postgres'
* ```
*/
interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'adapter'> {
/** The family this adapter belongs to */
readonly familyId: TFamilyId;
/** The target this adapter is designed for */
readonly targetId: TTargetId;
}
/**
* Descriptor for a driver component.
*
* A "driver" provides the connection and execution layer for a target. Drivers handle:
* - Connection management (pooling, timeouts, retries)
* - Query execution (sending SQL/commands, receiving results)
* - Transaction management
* - Wire protocol communication
*
* Drivers are bound to a specific family+target and work with any compatible adapter. Multiple drivers can exist for the same target (e.g., node-postgres vs postgres.js for Postgres).
*
* Extended by plane-specific descriptors:
* - `ControlDriverDescriptor` - creates driver from connection URL
* - `RuntimeDriverDescriptor` - creates driver with runtime options
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier
*
* @example
* ```ts
* import postgresDriver from '@prisma-next/driver-postgres/control';
*
* postgresDriver.kind // 'driver'
* postgresDriver.familyId // 'sql'
* postgresDriver.targetId // 'postgres'
* ```
*/
interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'driver'> {
/** The family this driver belongs to */
readonly familyId: TFamilyId;
/** The target this driver connects to */
readonly targetId: TTargetId;
}
/**
* Descriptor for an extension component.
*
* An "extension" adds optional capabilities to a target. Extensions can provide:
* - Additional operations (e.g., vector similarity search with pgvector)
* - Custom types and codecs (e.g., vector type)
* - Extended query capabilities
*
* Extensions are bound to a specific family+target and are registered in the config alongside the core components. Multiple extensions can be used together.
*
* Extended by plane-specific descriptors:
* - `ControlExtensionDescriptor` - control-plane extension factory
* - `RuntimeExtensionDescriptor` - runtime extension factory
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier
*
* @example
* ```ts
* import pgvector from '@prisma-next/extension-pgvector/control';
*
* pgvector.kind // 'extension'
* pgvector.familyId // 'sql'
* pgvector.targetId // 'postgres'
* ```
*/
interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'extension'> {
/** The family this extension belongs to */
readonly familyId: TFamilyId;
/** The target this extension is designed for */
readonly targetId: TTargetId;
}
/** Components bound to a specific family+target combination. */
type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> = TargetDescriptor<TFamilyId, TTargetId> | AdapterDescriptor<TFamilyId, TTargetId> | DriverDescriptor<TFamilyId, TTargetId> | ExtensionDescriptor<TFamilyId, TTargetId>;
interface FamilyInstance<TFamilyId extends string> {
readonly familyId: TFamilyId;
}
interface TargetInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
interface DriverInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
//#endregion
export { SourceDiagnostic as A, ControlMutationDefaultEntry as C, LoweredDefaultResult as D, DefaultFunctionLoweringContext as E, TypedDefaultFunctionCall as M, LoweredDefaultValue as O, checkContractComponentRequirements as S, ControlMutationDefaults as T, PackRefBase as _, ComponentMetadata as a, TargetInstance as b, DriverDescriptor as c, ExtensionDescriptor as d, ExtensionInstance as f, FamilyPackRef as g, FamilyInstance as h, ComponentDescriptor as i, SourceSpan as j, MutationDefaultGeneratorDescriptor as k, DriverInstance as l, FamilyDescriptor as m, AdapterInstance as n, ContractComponentRequirementsCheckInput as o, ExtensionPackRef as p, AdapterPackRef as r, ContractComponentRequirementsCheckResult as s, AdapterDescriptor as t, DriverPackRef as u, TargetBoundComponentDescriptor as v, ControlMutationDefaultRegistry as w, TargetPackRef as x, TargetDescriptor as y };
//# sourceMappingURL=framework-components-D1rRo9Oa.d.mts.map
{"version":3,"file":"framework-components-D1rRo9Oa.d.mts","names":[],"sources":["../src/shared/mutation-default-types.ts","../src/shared/framework-components.ts"],"mappings":";;;;;;UAMU,cAAA;EAAA,SACC,MAAA;EAAA,SACA,IAAA;EA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AlJO;EAAA,SAoJN,QAAA,EAAU,SAAA;EApJY;EAAA,SAuJtB,QAAA,EAAU,SAAA;AAAA;;;;;AArJS;AA4B9B;;;;;;;;;;;;;;;;AAM8B;AAM9B;;;;UA0IiB,mBAAA,6DACP,mBAAA;EArIa;EAAA,SAuIZ,QAAA,EAAU,SAAA;EA5IM;EAAA,SA+IhB,QAAA,EAAU,SAAA;AAAA;;KAIT,8BAAA,uDACR,gBAAA,CAAiB,SAAA,EAAW,SAAA,IAC5B,iBAAA,CAAkB,SAAA,EAAW,SAAA,IAC7B,gBAAA,CAAiB,SAAA,EAAW,SAAA,IAC5B,mBAAA,CAAoB,SAAA,EAAW,SAAA;AAAA,UAElB,cAAA;EAAA,SACN,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,eAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,iBAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA"}
import { r as CodecLookup } from "./codec-types-e32YHT3D.mjs";
import { K as PslDiagnosticCode, q as PslExtensionBlock, rt as PslSpan, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-DEadmUb3.mjs";
//#region src/control/psl-ast.d.ts
interface PslDiagnostic {
readonly code: PslDiagnosticCode;
readonly message: string;
readonly sourceId: string;
readonly span: PslSpan;
}
interface PslDefaultFunctionValue {
readonly kind: 'function';
readonly name: 'autoincrement' | 'now';
}
interface PslDefaultLiteralValue {
readonly kind: 'literal';
readonly value: string | number | boolean;
}
type PslDefaultValue = PslDefaultFunctionValue | PslDefaultLiteralValue;
type PslAttributeTarget = 'field' | 'model' | 'enum' | 'namedType';
interface PslAttributePositionalArgument {
readonly kind: 'positional';
readonly value: string;
readonly span: PslSpan;
}
interface PslAttributeNamedArgument {
readonly kind: 'named';
readonly name: string;
readonly value: string;
readonly span: PslSpan;
}
type PslAttributeArgument = PslAttributePositionalArgument | PslAttributeNamedArgument;
interface PslTypeConstructorCall {
readonly kind: 'typeConstructor';
readonly path: readonly string[];
readonly args: readonly PslAttributeArgument[];
readonly span: PslSpan;
}
interface PslAttribute {
readonly kind: 'attribute';
readonly target: PslAttributeTarget;
readonly name: string;
readonly args: readonly PslAttributeArgument[];
readonly span: PslSpan;
}
type PslReferentialAction = string;
type PslFieldAttribute = PslAttribute;
interface PslField {
readonly kind: 'field';
readonly name: string;
/** Unqualified type name, e.g. `"User"` for both `User`, `auth.User`, and `supabase:auth.User`. */
readonly typeName: string;
/** Namespace qualifier from a dot-qualified type reference, e.g. `"auth"` for `auth.User` or `supabase:auth.User`. Absent for unqualified types. */
readonly typeNamespaceId?: string;
/**
* Contract-space qualifier from a colon-prefix type reference, e.g. `"supabase"` for
* `supabase:auth.User` or `supabase:User`. Absent for local (same-space) type references.
*
* When present, the field references a model from a different contract space. The namespace
* (`typeNamespaceId`) and model name (`typeName`) identify the target within that space.
* Physical table resolution against the extension contract is deferred to the aggregate stage (M3).
*/
readonly typeContractSpaceId?: string;
readonly typeConstructor?: PslTypeConstructorCall;
readonly optional: boolean;
readonly list: boolean;
readonly typeRef?: string;
readonly attributes: readonly PslFieldAttribute[];
readonly span: PslSpan;
}
interface PslUniqueConstraint {
readonly kind: 'unique';
readonly fields: readonly string[];
readonly span: PslSpan;
}
interface PslIndexConstraint {
readonly kind: 'index';
readonly fields: readonly string[];
readonly span: PslSpan;
}
type PslModelAttribute = PslAttribute;
interface PslModel {
readonly kind: 'model';
readonly name: string;
readonly fields: readonly PslField[];
readonly attributes: readonly PslModelAttribute[];
readonly span: PslSpan;
/**
* Optional leading comment line emitted above the `model` keyword by the
* printer. Producers (e.g. `sqlSchemaIrToPslAst`) attach introspection
* advisories such as "// WARNING: This table has no primary key in the
* database" here. The parser leaves this field unset; round-tripping a
* parsed schema does not re-attach comments.
*/
readonly comment?: string;
}
/**
* A reusable group of fields embedded in a model (a `type Name { … }` block) —
* e.g. a MongoDB embedded document or a Postgres composite type. Unlike
* {@link PslModel} it has no storage or identity of its own.
*/
interface PslCompositeType {
readonly kind: 'compositeType';
readonly name: string;
readonly fields: readonly PslField[];
readonly attributes: readonly PslAttribute[];
readonly span: PslSpan;
}
interface PslNamedTypeDeclaration {
readonly kind: 'namedType';
readonly name: string;
/**
* Parser invariant: exactly one of `baseType` and `typeConstructor` is set.
* Expressing this as a discriminated union trips TypeScript narrowing when
* the declaration flows through helpers that accept the full union.
*/
readonly baseType?: string;
readonly typeConstructor?: PslTypeConstructorCall;
readonly attributes: readonly PslAttribute[];
readonly span: PslSpan;
}
interface PslTypesBlock {
readonly kind: 'types';
readonly declarations: readonly PslNamedTypeDeclaration[];
readonly span: PslSpan;
}
/**
* Name of the synthesised namespace bucket the framework parser uses for
* top-level declarations that appear outside any `namespace { … }` block.
* The double-underscore decoration signals that the identifier is parser-
* synthesised and never appears in user-authored PSL source — writing
* `namespace __unspecified__ { … }` is a parse error.
*
* Distinct from the IR sentinel `__unbound__`: the PSL bucket describes
* syntactic absence at the parser layer; the IR sentinel describes a late-
* bound storage slot at the IR layer. Per-target interpreters decide how
* (or whether) to map the PSL bucket to the IR sentinel.
*/
declare const UNSPECIFIED_PSL_NAMESPACE_ID = "__unspecified__";
/** A value in {@link PslNamespace.entries}: a built-in entity node or an extension-contributed {@link PslExtensionBlock}. */
type PslNamespaceEntry = PslModel | PslCompositeType | PslExtensionBlock;
/**
* A namespace block, or the parser's synthesised `__unspecified__` bucket for
* declarations outside any `namespace { … }`. Same-name blocks reopen-merge;
* `span` points at the first opening.
*
* Entities are stored canonically (ADR 224) in `entries[kind][name]`, where
* `kind` is the PSL keyword for built-ins or the block discriminator for
* extension kinds, e.g. `entries['policy']['ReadPosts']` (the discriminator,
* not the PSL keyword — a `policy_select` block lands under `'policy'` per
* ADR 225).
*/
interface PslNamespace {
readonly kind: 'namespace';
readonly name: string;
/** Canonical store: a frozen container of frozen per-kind maps. The accessors below derive from it. */
readonly entries: Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
/** Built-in models, from `entries['model']`. Extension kinds: {@link namespacePslExtensionBlocks}. */
readonly models: readonly PslModel[];
/** Built-in composite types, from `entries['compositeType']`. */
readonly compositeTypes: readonly PslCompositeType[];
readonly span: PslSpan;
}
/** Constructs a {@link PslNamespace}. Use this, never a namespace literal — the accessors must derive from `entries`. */
declare function makePslNamespace(init: {
readonly kind: 'namespace';
readonly name: string;
readonly entries: Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
readonly span: PslSpan;
}): PslNamespace;
/**
* Builds the frozen `entries[kind][name]` container from per-kind arrays.
* Built-ins key on their PSL keyword; extension blocks key on their `kind`
* discriminator. Call this rather than hand-building the literal.
*/
declare function makePslNamespaceEntries(models: readonly PslModel[], compositeTypes: readonly PslCompositeType[], extensionBlocks: readonly PslExtensionBlock[]): Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
interface PslDocumentAst {
readonly kind: 'document';
readonly sourceId: string;
readonly namespaces: readonly PslNamespace[];
readonly types?: PslTypesBlock;
readonly span: PslSpan;
}
/**
* Returns all models from every namespace in document order. Convenience
* for consumers that don't (yet) need namespace-awareness.
*/
declare function flatPslModels(ast: PslDocumentAst): readonly PslModel[];
/**
* Returns all composite types from every namespace in document order.
*/
declare function flatPslCompositeTypes(ast: PslDocumentAst): readonly PslCompositeType[];
/**
* The set of `entries` kind keys that the framework parser reserves for
* built-in PSL entity kinds. Any own-enumerable key on `PslNamespace.entries`
* that is **not** in this set was contributed by an extension-block descriptor.
*
* Built-in keys match the PSL keyword used on each block type:
* `'model'`, `'compositeType'`. The `'enum'` keyword is claimed by the
* extension-block grammar via a registered descriptor, so `entries['enum']`
* holds `PslExtensionBlock` nodes and is returned by `namespacePslExtensionBlocks`.
*/
declare const BUILTIN_PSL_KIND_KEYS: ReadonlySet<string>;
/**
* Returns all extension-contributed blocks in the given namespace, in
* insertion order (the order the parser encountered them in the source).
*
* Reads from `namespace.entries`, skipping the built-in kind keys
* (`'model'`, `'compositeType'`). All remaining kind maps contain
* only `PslExtensionBlock` nodes by construction (see `makePslNamespaceEntries`).
*/
declare function namespacePslExtensionBlocks(ns: PslNamespace): readonly PslExtensionBlock[];
interface ParsePslDocumentInput {
readonly schema: string;
readonly sourceId: string;
/**
* Registry of declarative block descriptors, keyed by arbitrary path
* segments with {@link AuthoringPslBlockDescriptor} leaves. The registry
* teaches the parser which top-level keywords belong to extension
* contributions: when the parser encounters an unknown keyword, it looks
* it up here and, when found, reads the block generically into a
* {@link PslExtensionBlock} node. Absent or undefined means no extension
* blocks are registered and any unknown keyword yields
* `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK`.
*
* Contrast with the parsed block nodes themselves, which live in
* {@link PslNamespace.entries} under their discriminator key (read them with
* {@link namespacePslExtensionBlocks}); this field holds the registry of
* descriptors that teach the parser how to read those blocks.
*/
readonly pslBlockDescriptors?: AuthoringPslBlockDescriptorNamespace;
/**
* Codec lookup for validating `value`-kind extension block parameters.
* When provided alongside `pslBlockDescriptors`, the generic validator runs
* over every parsed extension block after the full AST is assembled,
* appending any diagnostics to the parse result. Absent or undefined means
* no codec validation runs; `ref` resolution still runs when namespace
* context is available (built from the assembled namespaces).
*/
readonly codecLookup?: CodecLookup;
}
interface ParsePslDocumentResult {
readonly ast: PslDocumentAst;
readonly diagnostics: readonly PslDiagnostic[];
readonly ok: boolean;
}
//#endregion
export { makePslNamespace as A, PslReferentialAction as C, UNSPECIFIED_PSL_NAMESPACE_ID as D, PslUniqueConstraint as E, namespacePslExtensionBlocks as M, flatPslCompositeTypes as O, PslNamespaceEntry as S, PslTypesBlock as T, PslIndexConstraint as _, PslAttributeArgument as a, PslNamedTypeDeclaration as b, PslAttributeTarget as c, PslDefaultLiteralValue as d, PslDefaultValue as f, PslFieldAttribute as g, PslField as h, PslAttribute as i, makePslNamespaceEntries as j, flatPslModels as k, PslCompositeType as l, PslDocumentAst as m, ParsePslDocumentInput as n, PslAttributeNamedArgument as o, PslDiagnostic as p, ParsePslDocumentResult as r, PslAttributePositionalArgument as s, BUILTIN_PSL_KIND_KEYS as t, PslDefaultFunctionValue as u, PslModel as v, PslTypeConstructorCall as w, PslNamespace as x, PslModelAttribute as y };
//# sourceMappingURL=psl-ast-jgAyMeUx.d.mts.map
{"version":3,"file":"psl-ast-jgAyMeUx.d.mts","names":[],"sources":["../src/control/psl-ast.ts"],"mappings":";;;;UA0BiB,aAAA;EAAA,SACN,IAAA,EAAM,iBAAA;EAAA,SACN,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,EAAM,OAAO;AAAA;AAAA,UAGP,uBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAI;AAAA;AAAA,UAGE,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAK;AAAA;AAAA,KAGJ,eAAA,GAAkB,uBAAA,GAA0B,sBAAsB;AAAA,KAElE,kBAAA;AAAA,UAEK,8BAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA,EAAM,OAAO;AAAA;AAAA,UAGP,yBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA,EAAM,OAAO;AAAA;AAAA,KAGZ,oBAAA,GAAuB,8BAAA,GAAiC,yBAAyB;AAAA,UAE5E,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA,WAAe,oBAAA;EAAA,SACf,IAAA,EAAM,OAAO;AAAA;AAAA,UAGP,YAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA,EAAQ,kBAAA;EAAA,SACR,IAAA;EAAA,SACA,IAAA,WAAe,oBAAA;EAAA,SACf,IAAA,EAAM,OAAA;AAAA;AAAA,KAGL,oBAAA;AAA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AAsB,oCAAA;EAvMU;;;AAAoC;AAa/E;;;;EAb2C,SAgNhC,WAAA,GAAc,WAAW;AAAA;AAAA,UAGnB,sBAAA;EAAA,SACN,GAAA,EAAK,cAAA;EAAA,SACL,WAAA,WAAsB,aAAa;EAAA,SACnC,EAAA;AAAA"}
+1
-1

@@ -1,2 +0,2 @@

import { $ as PslExtensionBlockParamRef, A as instantiateAuthoringTypeConstructor, B as validateAuthoringHelperArguments, C as AuthoringTypeConstructorEntityRef, D as hasRegisteredFieldNamespace, E as classifyEnumMemberType, F as isAuthoringPslBlockDescriptor, G as PslBlockParamValue, H as PslBlockParamList, I as isAuthoringTypeConstructorDescriptor, L as mergeAuthoringNamespaces, M as isAuthoringEntityTypeDescriptor, N as isAuthoringFieldPresetDescriptor, O as instantiateAuthoringEntityType, P as isAuthoringModelAttributeDescriptor, Q as PslExtensionBlockParamOption, R as resolveAuthoringTemplateValue, S as AuthoringTypeConstructorDescriptor, T as assertNoCrossRegistryCollisions, U as PslBlockParamOption, V as PslBlockParam, W as PslBlockParamRef, Z as PslExtensionBlockParamList, _ as AuthoringModelAttributeLoweringOutput, a as AuthoringDiagnosticSink, b as AuthoringStorageTypeTemplate, c as AuthoringEntityTypeFactoryOutput, d as AuthoringFieldNamespace, et as PslExtensionBlockParamScalarValue, f as AuthoringFieldPresetDescriptor, g as AuthoringModelAttributeDescriptorNamespace, h as AuthoringModelAttributeDescriptor, i as AuthoringContributions, j as isAuthoringArgRef, k as instantiateAuthoringFieldPreset, l as AuthoringEntityTypeNamespace, m as AuthoringModelAttributeContext, n as AuthoringArgumentDescriptor, o as AuthoringEntityContext, p as AuthoringFieldPresetOutput, q as PslExtensionBlock, r as AuthoringColumnDefaultTemplate, s as AuthoringEntityTypeDescriptor, t as AuthoringArgRef, tt as PslExtensionBlockParamValue, u as AuthoringEntityTypeTemplateOutput, v as AuthoringPslBlockDescriptor, w as AuthoringTypeNamespace, x as AuthoringTemplateValue, y as AuthoringPslBlockDescriptorNamespace, z as resolveEnumCodecId } from "./framework-authoring-CEbpeygb.mjs";
import { $ as PslExtensionBlockParamRef, A as instantiateAuthoringTypeConstructor, B as validateAuthoringHelperArguments, C as AuthoringTypeConstructorEntityRef, D as hasRegisteredFieldNamespace, E as classifyEnumMemberType, F as isAuthoringPslBlockDescriptor, G as PslBlockParamValue, H as PslBlockParamList, I as isAuthoringTypeConstructorDescriptor, L as mergeAuthoringNamespaces, M as isAuthoringEntityTypeDescriptor, N as isAuthoringFieldPresetDescriptor, O as instantiateAuthoringEntityType, P as isAuthoringModelAttributeDescriptor, Q as PslExtensionBlockParamOption, R as resolveAuthoringTemplateValue, S as AuthoringTypeConstructorDescriptor, T as assertNoCrossRegistryCollisions, U as PslBlockParamOption, V as PslBlockParam, W as PslBlockParamRef, Z as PslExtensionBlockParamList, _ as AuthoringModelAttributeLoweringOutput, a as AuthoringDiagnosticSink, b as AuthoringStorageTypeTemplate, c as AuthoringEntityTypeFactoryOutput, d as AuthoringFieldNamespace, et as PslExtensionBlockParamScalarValue, f as AuthoringFieldPresetDescriptor, g as AuthoringModelAttributeDescriptorNamespace, h as AuthoringModelAttributeDescriptor, i as AuthoringContributions, j as isAuthoringArgRef, k as instantiateAuthoringFieldPreset, l as AuthoringEntityTypeNamespace, m as AuthoringModelAttributeContext, n as AuthoringArgumentDescriptor, o as AuthoringEntityContext, p as AuthoringFieldPresetOutput, q as PslExtensionBlock, r as AuthoringColumnDefaultTemplate, s as AuthoringEntityTypeDescriptor, t as AuthoringArgRef, tt as PslExtensionBlockParamValue, u as AuthoringEntityTypeTemplateOutput, v as AuthoringPslBlockDescriptor, w as AuthoringTypeNamespace, x as AuthoringTemplateValue, y as AuthoringPslBlockDescriptorNamespace, z as resolveEnumCodecId } from "./framework-authoring-DEadmUb3.mjs";
export { type AuthoringArgRef, type AuthoringArgumentDescriptor, type AuthoringColumnDefaultTemplate, type AuthoringContributions, type AuthoringDiagnosticSink, type AuthoringEntityContext, type AuthoringEntityTypeDescriptor, type AuthoringEntityTypeFactoryOutput, type AuthoringEntityTypeNamespace, type AuthoringEntityTypeTemplateOutput, type AuthoringFieldNamespace, type AuthoringFieldPresetDescriptor, type AuthoringFieldPresetOutput, type AuthoringModelAttributeContext, type AuthoringModelAttributeDescriptor, type AuthoringModelAttributeDescriptorNamespace, type AuthoringModelAttributeLoweringOutput, type AuthoringPslBlockDescriptor, type AuthoringPslBlockDescriptorNamespace, type AuthoringStorageTypeTemplate, type AuthoringTemplateValue, type AuthoringTypeConstructorDescriptor, type AuthoringTypeConstructorEntityRef, type AuthoringTypeNamespace, type PslBlockParam, type PslBlockParamList, type PslBlockParamOption, type PslBlockParamRef, type PslBlockParamValue, type PslExtensionBlock, type PslExtensionBlockParamList, type PslExtensionBlockParamOption, type PslExtensionBlockParamRef, type PslExtensionBlockParamScalarValue, type PslExtensionBlockParamValue, assertNoCrossRegistryCollisions, classifyEnumMemberType, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, mergeAuthoringNamespaces, resolveAuthoringTemplateValue, resolveEnumCodecId, validateAuthoringHelperArguments };

@@ -1,2 +0,2 @@

import { a as CodecRef, c as emptyCodecLookup, d as CodecImpl, f as AnyCodecDescriptor, i as CodecMeta, l as voidParamsSchema, m as CodecDescriptorImpl, n as CodecInstanceContext, o as CodecRegistry, p as CodecDescriptor, r as CodecLookup, s as CodecTrait, t as CodecCallContext, u as Codec } from "./codec-types-BH2f2dg1.mjs";
import { a as CodecRef, c as emptyCodecLookup, d as CodecImpl, f as AnyCodecDescriptor, i as CodecMeta, l as voidParamsSchema, m as CodecDescriptorImpl, n as CodecInstanceContext, o as CodecRegistry, p as CodecDescriptor, r as CodecLookup, s as CodecTrait, t as CodecCallContext, u as Codec } from "./codec-types-e32YHT3D.mjs";
import { JsonValue, ValueSetRef } from "@prisma-next/contract/types";

@@ -3,0 +3,0 @@

@@ -6,3 +6,3 @@ import { i as validateCodecTypeParams, n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-D8EPZosv.mjs";

*
* Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override `encode`/`decode` (and optionally `encodeJson`/`decodeJson`). The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.
* Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override all four abstract conversion methods: `encode`, `decode`, `encodeJson`, and `decodeJson`. The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.
*/

@@ -9,0 +9,0 @@ var CodecImpl = class {

@@ -1,1 +0,1 @@

{"version":3,"file":"codec.mjs","names":[],"sources":["../src/shared/codec.ts","../src/shared/codec-types.ts","../src/shared/codec-descriptor.ts","../src/shared/column-spec.ts","../src/shared/render-ts-literal.ts"],"sourcesContent":["/**\n * Codec interface (consumer surface) and abstract `CodecImpl` base (codec-author surface).\n *\n * Consumers depend on the {@link Codec} interface — it describes the runtime instance returned by a descriptor's curried factory and is what the framework threads through emit, validate, and execute paths.\n *\n * Codec authors `extend` the {@link CodecImpl} abstract class to declare a typed runtime codec instance. The class carries a variance-erased descriptor reference (`CodecDescriptor<any>`); `id` proxies through the descriptor so one source of truth governs both metadata reads and aliasing semantics (alias subclasses inherit the descriptor's id automatically).\n *\n * Class generic shape: `Id`, `TTraits`, `TWire`, `TInput`. Method generics on the codec subclass's own surface (e.g. arktype-json's schema generic, pgvector's dimension generic) flow through the subclass's constructor and propagate via the descriptor's typed `factory(params)` return at *direct* call sites.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { CodecDescriptor } from './codec-descriptor';\nimport type { CodecCallContext, CodecTrait } from './codec-types';\n\n/**\n * A codec is the contract between an application value and its on-wire and on-contract-disk representations.\n *\n * The author's mental model is two JS-side types — `TInput` (the application JS type) and `TWire` (the database driver wire format) — plus `JsonValue` for build-time contract artifacts. The codec translates `TInput` to `TWire` on writes and back on reads, and to/from `JsonValue` during contract emission and loading.\n *\n * Three representations participate:\n * - **Input** (`TInput`): the JS type at the application boundary.\n * - **Wire** (`TWire`): the format exchanged with the database driver.\n * - **JSON** (`JsonValue`): a JSON-safe form used in contract artifacts.\n *\n * The runtime instance carries only its `id` (the descriptor's `codecId`, set by the factory) and the four conversion methods. Static metadata (`traits`, `targetTypes`, `meta`) and the build-time `renderOutputType` renderer live on the {@link CodecDescriptor} keyed by `codecId` — the read-surface single source of truth. Consumers that need them resolve through `descriptorFor(codecId)`.\n *\n * Codec methods split into two groups:\n *\n * - **Query-time** methods (`encode`, `decode`) run per row/parameter at the IO boundary; they are required and Promise-returning. The per-family codec factory accepts sync or async author functions and lifts sync ones to Promise-shaped methods automatically.\n * - **Build-time** methods (`encodeJson`, `decodeJson`) run when the contract is serialized or loaded. They stay synchronous so contract validation and client construction are synchronous.\n *\n * Target-family codec interfaces extend this base; family-specific concerns (e.g. the SQL `column?` per-call context) layer on through the `CodecCallContext` extension pattern.\n */\nexport interface Codec<\n Id extends string = string,\n TTraits extends readonly CodecTrait[] = readonly CodecTrait[],\n TWire = unknown,\n TInput = unknown,\n> {\n /** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). The factory sets this to the descriptor's `codecId`; consumers use it as a back-reference for descriptor lookups and for decode-error diagnostics. */\n readonly id: Id;\n /** Phantom carrier for the `TTraits` generic; type-only, undefined at runtime. Runtime traits live on {@link CodecDescriptor.traits}. Implemented as a string-key phantom (`__codecTraits`) rather than `unique symbol` so bundlers that split `.d.ts` chunks do not strand symbol identity on chunk-private paths (the same `TS2742` family that the public re-export of `CodecTypes` works around). */\n readonly __codecTraits?: TTraits;\n /** Converts a JS value to the wire format expected by the database driver. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(value) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */\n encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;\n /** Converts a wire value from the database driver into the JS application type. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(wire) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */\n decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;\n /** Converts a JS value to a JSON-safe representation for contract serialization. Synchronous; called during contract emission. */\n encodeJson(value: TInput): JsonValue;\n /** Converts a JSON representation back to the JS input type. Synchronous; called during contract loading via `family.deserializeContract`. */\n decodeJson(json: JsonValue): TInput;\n}\n\n/**\n * Abstract base class for concrete codec implementations.\n *\n * Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override `encode`/`decode` (and optionally `encodeJson`/`decodeJson`). The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.\n */\nexport abstract class CodecImpl<\n Id extends string = string,\n TTraits extends readonly CodecTrait[] = readonly CodecTrait[],\n TWire = unknown,\n TInput = unknown,\n> implements Codec<Id, TTraits, TWire, TInput>\n{\n /**\n * Variance-erased descriptor reference. Concrete codec subclasses receive the typed descriptor in their own constructors and forward it via `super(descriptor)`; the variance erasure lives at this base because the abstract surface can't carry the concrete `TParams`.\n */\n // biome-ignore lint/suspicious/noExplicitAny: variance-erased descriptor reference; subclasses retain typed access via their own state\n constructor(public readonly descriptor: CodecDescriptor<any>) {}\n\n get id(): Id {\n return this.descriptor.codecId as Id;\n }\n\n abstract encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;\n abstract decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;\n abstract encodeJson(value: TInput): JsonValue;\n abstract decodeJson(json: JsonValue): TInput;\n}\n","import type { JsonValue } from '@prisma-next/contract/types';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Codec } from './codec';\nimport type { AnyCodecDescriptor } from './codec-descriptor';\n\nexport type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';\n\n/**\n * Serializable codec identity carried by every codec-bearing AST node.\n *\n * `(codecId, typeParams?)` is the single fact the runtime needs to materialize a codec via `descriptorFor(codecId).factory(typeParams)(ctx)`. The pair is content-keyed: two refs with the same `codecId` and structurally equal `typeParams` (regardless of object key ordering) resolve to the same memoized {@link Codec} instance.\n *\n * `typeParams` is `JsonValue`-constrained so the ref survives JSON serialization (relevant for AST-embedded migration ops). Non-parameterized codecs leave `typeParams` undefined; the descriptor's `paramsSchema` validates the value at the JSON boundary.\n *\n * `many` marks a scalar-array (list-typed) column. When `true`, the encode/decode paths map the element codec over the JS array rather than applying the codec to the whole value. The element codec id is `codecId`; the driver owns the array wire framing (`{…}`) in both directions. Absent for scalar columns.\n *\n * Family-agnostic by design — both SQL and Mongo AST nodes carry `codec: CodecRef | undefined`, and the resolver is the only dispatch path that survives serialization.\n */\nexport interface CodecRef {\n readonly codecId: string;\n readonly typeParams?: JsonValue;\n readonly many?: boolean;\n}\n\n/**\n * Per-call context the runtime threads to every `codec.encode` / `codec.decode` invocation for a single `runtime.execute()` call.\n *\n * The framework-level shape is family-agnostic and carries one field:\n *\n * - `signal?: AbortSignal` — per-query cancellation. The runtime returns a `RUNTIME.ABORTED` envelope when the signal aborts; codec authors who forward `signal` to their underlying SDK get true cancellation of in-flight network calls.\n *\n * Family layers extend this base with their own shape-of-call metadata: the SQL family adds `column?: SqlColumnRef` via `SqlCodecCallContext` (see `@prisma-next/sql-relational-core`). Mongo currently uses this framework type unchanged. Column metadata is intentionally **not** on the framework type — it is a SQL-family concept rooted in SQL's `(table, column)` addressing model and would not generalise to other families.\n *\n * The interface is named explicitly (not inlined) so future framework fields and family extensions can land additively without breaking codec author signatures.\n */\nexport interface CodecCallContext {\n readonly signal?: AbortSignal;\n}\n\n/**\n * Codec-id-keyed read surface threaded into emit and authoring paths.\n *\n * - `get(id)` returns a representative {@link Codec} instance for the codec id (used by `family.deserializeContract` for `decodeJson` of literal column defaults). For parameterized codecs whose factory requires concrete params, this may return `undefined` — use `CodecRegistry.forCodecRef` instead.\n * - `targetTypesFor(id)` exposes the codec-id-keyed `targetTypes` metadata the runtime instance no longer carries (TML-2357). Returns the same array `CodecDescriptor.targetTypes` would; for Mongo (whose registration doesn't yet resolve through the unified descriptor map — TML-2324) the family-side assembly populates this directly from the contributor's codec metadata.\n * - `metaFor(id, typeParams)` exposes the codec-id-keyed `meta` (e.g. SQL-side `db.sql.postgres.nativeType`) the runtime instance no longer carries. `typeParams` is optional: when given and the codec descriptor implements a params-aware `metaFor`, the descriptor computes its meta from those params (e.g. a native enum's per-instance Postgres type name); otherwise (or when `typeParams` is omitted) the codec's static `meta` is returned.\n * - `renderOutputTypeFor(id, params)` exposes the codec-id-keyed `renderOutputType` renderer the runtime instance no longer carries. Returns `undefined` when the codec doesn't render a custom type or when the codec id is unknown.\n */\nexport interface CodecLookup {\n get(id: string): Codec | undefined;\n targetTypesFor(id: string): readonly string[] | undefined;\n metaFor(id: string, typeParams?: Record<string, unknown> | JsonValue): CodecMeta | undefined;\n renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;\n /** Codec-id-keyed `renderInputType` renderer for the `contract.d.ts` input position. Optional so existing lookups need not provide it; returns `undefined` when the codec renders no custom input type or the id is unknown. */\n renderInputTypeFor?(id: string, params: Record<string, unknown>): string | undefined;\n /** Codec-id-keyed `renderValueLiteral` renderer for the emit path (`side`: `output` = read type, `input` = create/update type). Optional so existing lookups need not provide it; returns `undefined` when the codec's output isn't literal-expressible or the id is unknown. */\n renderValueLiteralFor?(\n id: string,\n value: JsonValue,\n side: 'output' | 'input',\n ): string | undefined;\n /**\n * Codec-id-keyed descriptor accessor. Returns the full registered\n * {@link AnyCodecDescriptor} for `id`, or `undefined` if no descriptor is\n * registered. Optional so existing lookups need not provide it; a consumer\n * that needs more than the derived per-id readers above — e.g. an\n * authoring-time hook a target-specific descriptor exposes but this\n * framework interface does not model generically — fetches the descriptor\n * itself and narrows it with its own structural predicate.\n */\n descriptorFor?(id: string): AnyCodecDescriptor | undefined;\n}\n\n/**\n * Full codec registry — the read surface of {@link CodecLookup} plus codec resolution by ref or\n * column coordinate. Built once by `extractCodecLookup` and passed by reference to adapters and\n * other consumers that need to materialise codecs at runtime.\n *\n * - `forCodecRef(ref)` materialises a codec from a {@link CodecRef}. Throws\n * `RUNTIME.CODEC_DESCRIPTOR_MISSING` for unknown ids and `RUNTIME.TYPE_PARAMS_INVALID` on param\n * schema rejection.\n * - `forColumn(namespaceId, table, column)` returns the codec for a specific column coordinate, or\n * `undefined` when no column-to-codec mapping is present. This registry is contract-free so it\n * always returns `undefined` — the method exists so the object structurally satisfies the SQL\n * `ContractCodecRegistry` interface.\n */\nexport interface CodecRegistry extends CodecLookup {\n forCodecRef(ref: CodecRef): Codec;\n forColumn(namespaceId: string, table: string, column: string): Codec | undefined;\n}\n\nexport const emptyCodecLookup: CodecLookup = {\n get: () => undefined,\n targetTypesFor: () => undefined,\n metaFor: () => undefined,\n renderOutputTypeFor: () => undefined,\n};\n\n/**\n * Family-agnostic per-instance context supplied by the framework when applying a higher-order codec factory. Allows stateful codecs (e.g. column-scoped encryption) to derive per-instance state from the materialization site.\n *\n * - `name` — the family-agnostic instance identity. For SQL, the runtime populates this as the `storage.types` instance name (e.g. `Embedding1536`) for typeRef-shaped columns, an inline-column sentinel (`<col:Document.embedding>`) for inline-`typeParams` columns, a shared codec-id sentinel (`<codec:pg/text@1>`) for non-parameterized codec ids, or the canonical cache key (`<codecId>:<canonicalizeJson(typeParams)>`) for ad-hoc refs the contract walk did not pre-populate. Other families pick the analogous identity for their materialization sites.\n *\n * Family-specific extensions (e.g. {@link import('@prisma-next/sql-relational-core/ast').SqlCodecInstanceContext} in the SQL layer) augment this base with domain-shaped column-set metadata. Codec authors target the base when they don't read family-specific metadata; they target the family extension when they do.\n */\nexport interface CodecInstanceContext {\n readonly name: string;\n}\n\n/**\n * Family-agnostic codec metadata. Family-specific extensions augment the base `db.<family>.<target>` block with native-type information; the base shape is an empty object so non-relational codecs can carry no metadata.\n */\nexport interface CodecMeta {\n readonly db?: Record<string, unknown>;\n}\n\n/**\n * Standard Schema validator for `void` params. Accepts only `undefined` (or absent input); rejects any other value so a contract that tries to thread `typeParams` through a non-parameterized codec id fails fast at the JSON boundary instead of silently coercing the value away. Used by the framework-supplied non-parameterized descriptor synthesizer.\n */\nexport const voidParamsSchema: StandardSchemaV1<void> = {\n '~standard': {\n version: 1,\n vendor: 'prisma-next',\n validate: (input) =>\n input === undefined\n ? { value: undefined }\n : {\n issues: [\n {\n message: 'unexpected typeParams for non-parameterized codec (void params expected)',\n },\n ],\n },\n },\n};\n","/**\n * Codec descriptor interface (consumer surface) and abstract `CodecDescriptorImpl` base (codec-author surface).\n *\n * Consumers depend on the {@link CodecDescriptor} interface — it is the codec-id-keyed source of truth for static metadata (`traits`, `targetTypes`, `meta`) and registration concerns (`paramsSchema`; optional `renderOutputType`). The runtime `Codec` instance returned by `factory(params)(ctx)` carries only the conversion behavior.\n *\n * Codec authors `extend` the {@link CodecDescriptorImpl} abstract class to declare their codec id, traits, target types, params schema, the `factory(params)` that materializes a typed `Codec<...>`, and (optionally) a `renderOutputType(params)` for the emit path.\n *\n * The factory's method-level generic is the load-bearing piece for literal preservation: per-codec column helpers invoke `descriptor.factory(...)` *directly*, and the direct call binds the generic at its call site. Type extraction (`ReturnType<D['factory']>`, structural matching) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Codec } from './codec';\nimport {\n type CodecInstanceContext,\n type CodecMeta,\n type CodecTrait,\n voidParamsSchema,\n} from './codec-types';\n\n/**\n * Unified codec descriptor. Every codec in the framework registers through this shape — non-parameterized codecs use `P = void` and a constant factory that returns the same shared codec instance for every column; parameterized codecs use a non-empty `P` and a curried higher-order factory that returns a per-instance codec.\n *\n * The descriptor is the codec-id-keyed source of truth for static metadata (`traits`, `targetTypes`, `meta`) and registration concerns (`paramsSchema` for JSON-boundary validation; optional `renderOutputType` for the `contract.d.ts` emit path). The runtime `Codec` instance returned by `factory(params)(ctx)` carries only the conversion behavior.\n *\n * Whether a codec id \"is parameterized\" stops being a registration-time distinction — it's a property of `P` on the descriptor. The descriptor map indexes every descriptor by `codecId`; both `descriptorFor(codecId)` and `forColumn(table, column)` resolve through the same map without branching on parameterization.\n *\n * @template P - The shape of the params accepted by the factory (`void` for non-parameterized codecs; a record like `{ length: number }` for parameterized codecs).\n *\n * Codec-registry-unification project § Decision.\n */\nexport interface CodecDescriptor<P = void> {\n /** The codec ID this descriptor applies to (e.g. `pg/vector@1`, `pg/text@1`). */\n readonly codecId: string;\n /** Semantic traits for operator gating (e.g. equality, order, numeric). */\n readonly traits: readonly CodecTrait[];\n /** Database-native type names this codec handles (e.g. `['timestamptz']`). */\n readonly targetTypes: readonly string[];\n /** Optional family-specific metadata (e.g. SQL-side `db.sql.postgres.nativeType`). */\n readonly meta?: CodecMeta;\n /** Standard Schema validator for the factory's params. Validates JSON-sourced params at the contract boundary (PSL → IR; `contract.json` → runtime). For non-parameterized codecs (`P = void`), the schema validates `void`/`undefined` — the framework supplies no params at the call boundary. */\n readonly paramsSchema: StandardSchemaV1<P>;\n /** Whether this descriptor is parameterized — i.e. its `paramsSchema` is something other than the singleton `voidParamsSchema`. Consumers that need to gate column-aware dispatch read this directly rather than threading a free-floating `(codecId) => boolean` callback. */\n readonly isParameterized: boolean;\n /** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Optional; absent renderers cause `CodecLookup.metaFor` to fall back to the codec's static `meta`. Non-parameterized codecs typically omit it. */\n readonly metaFor?: (params: P) => CodecMeta | undefined;\n /** Emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for given params (e.g. `Vector<1536>`). Optional; absent renderers cause the emitter to fall back to the codec's base output type. Non-parameterized codecs typically omit it. */\n readonly renderOutputType?: (params: P) => string | undefined;\n /** Emit-path string renderer for the `contract.d.ts` *input* position (create/update values). Returns the TypeScript input type expression for given params. Optional; absent renderers fall back to the codec's base input type. A codec supplies this when its write type is narrower than the generic codec input — e.g. an enum whose input should be the literal member union, not `string`. */\n readonly renderInputType?: (params: P) => string | undefined;\n /**\n * Given one stored (codec-encoded) value, return the TypeScript literal type to print for it\n * (e.g. `'low'`, `1`), or `undefined` if this codec's output isn't literal-expressible (e.g. a\n * Date-output codec).\n *\n * `value` is the `encodeJson` form stored in the value set. `side` selects which type to print:\n * `output` = the read/SELECT type; `input` = the create/update type. Most codecs render the same\n * literal for both, but a codec whose read and write types differ can render per side. Called once\n * per permitted value; the caller joins the results with `|`.\n */\n readonly renderValueLiteral?: (value: JsonValue, side: 'output' | 'input') => string | undefined;\n /** The curried higher-order codec. For non-parameterized codecs, the factory is constant — every call returns the same shared codec instance. For parameterized codecs, the factory is called once per `storage.types` instance (or once per inline-`typeParams` column), with `ctx` carrying the column set the resulting codec serves. */\n readonly factory: (params: P) => (ctx: CodecInstanceContext) => Codec;\n}\n\n/**\n * Variance-erased {@link CodecDescriptor} alias. `CodecDescriptor<P>` is invariant in `P` (the `factory` and `renderOutputType` slots use `P` contravariantly), so `CodecDescriptor<P>` does not extend `CodecDescriptor<unknown>` for specific `P`. Heterogeneous descriptor collections — e.g. `SqlStaticContributions.codecs:` returning a list that mixes parameterized and non-parameterized descriptors — type against this alias and narrow per codec id at the consumer.\n *\n * Codec-registry-unification spec § Decision: every codec resolves through one descriptor map; reads are non-branching.\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure for heterogeneous descriptor collections\nexport type AnyCodecDescriptor = CodecDescriptor<any>;\n\n/**\n * Abstract base class for concrete codec descriptors.\n *\n * Codec authors extend this class with their typed `TParams` and declare `codecId`, `traits`, `targetTypes`, `paramsSchema`, the curried `factory(params)`, and (optionally) `renderOutputType`.\n *\n * Implements the {@link CodecDescriptor} interface so a concrete subclass instance is directly usable wherever the framework expects a `CodecDescriptor<P>`.\n */\nexport abstract class CodecDescriptorImpl<TParams = void> implements CodecDescriptor<TParams> {\n abstract readonly codecId: string;\n abstract readonly traits: readonly CodecTrait[];\n abstract readonly targetTypes: readonly string[];\n readonly meta?: CodecMeta;\n\n abstract readonly paramsSchema: StandardSchemaV1<TParams>;\n\n /** Boolean derived from `paramsSchema`: `true` whenever the schema is not the singleton `voidParamsSchema`. */\n get isParameterized(): boolean {\n return this.paramsSchema !== voidParamsSchema;\n }\n\n /** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Non-parameterized codecs typically omit it. */\n metaFor?(params: TParams): CodecMeta | undefined;\n\n /** Optional emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for the given params (e.g. `Vector<1536>`). Non-parameterized codecs typically omit it. */\n renderOutputType?(params: TParams): string | undefined;\n\n /** Optional emit-path string renderer for the `contract.d.ts` input position. Returns the TypeScript input type expression for the given params; supplied when the write type is narrower than the generic codec input (e.g. an enum's literal member union). */\n renderInputType?(params: TParams): string | undefined;\n\n /** Optional emit-path renderer for a single stored value. See {@link CodecDescriptor.renderValueLiteral}. */\n renderValueLiteral?(value: JsonValue, side: 'output' | 'input'): string | undefined;\n\n /**\n * Materialize a curried codec factory for the given params. Concrete subclasses override with a typed return type (e.g. `factory<N>(params: { length: N }): (ctx) => VectorCodec<N>`); per-codec helpers read the typed return at the *direct* call site, which is what preserves method-level generics. Type extraction (e.g. `ReturnType<D['factory']>`) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.\n */\n abstract factory(\n params: TParams,\n ): (ctx: CodecInstanceContext) => Codec<string, readonly CodecTrait[], unknown, unknown>;\n}\n","/**\n * `column()` packager + `ColumnSpec<R, P>` shape + `ColumnHelperFor<D>` variants for tying per-codec column helpers to their descriptor.\n *\n * `ColumnSpec<R, P>` extends {@link ColumnTypeDescriptor} so it remains a drop-in for contract authoring sites that consume `ColumnTypeDescriptor` shapes — both types live at the framework-components layer so the `extends` clause is real (no structural mirror).\n *\n * `column()` is a trivial, non-polymorphic packager. Generic over `R` (the codec instance type returned by the descriptor's curried factory) and `P` (the typeParams record). The framework does NOT try to infer `R` and `P` from a descriptor — that path is the variance trap. Per-codec helpers absorb the descriptor relationship instead and tie themselves to their descriptor via `satisfies ColumnHelperFor<D>` or `satisfies ColumnHelperForStrict<D>`.\n */\n\nimport type { ValueSetRef } from '@prisma-next/contract/types';\nimport type { CodecDescriptor } from './codec-descriptor';\nimport type { CodecInstanceContext } from './codec-types';\n\n/**\n * Authored column-type descriptor — the data shape an authoring site (PSL or TypeScript builders) attaches to a column to identify its codec and its native database type.\n *\n * Lives at the framework-components layer alongside the codec types so codec-author packages (e.g. column-spec / `column()` packagers) can extend it directly without crossing layer boundaries.\n *\n * @template TCodecId Narrowed codec id literal for sites that thread a specific codec id through the type system.\n */\nexport type ColumnTypeDescriptor<TCodecId extends string = string> = {\n readonly codecId: TCodecId;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown> | undefined;\n readonly typeRef?: string;\n /**\n * Storage-plane value-set ref, set by an authoring path that resolves a\n * field's type against a value-set-deriving entity (e.g. a PSL entity-ref\n * type constructor like `pg.enum(Ref)`, or a TS `enumType` handle).\n * Threaded straight onto the storage node this descriptor builds, where it\n * drives value-set → codec typing. Every codec's own descriptor leaves this\n * unset.\n */\n readonly valueSet?: ValueSetRef;\n readonly entityRef?: EntityRef;\n};\n\n/**\n * Late-resolved pack-entity reference — a field on the type descriptor it is\n * declared on: `entityKind`/`entityName` identify a pack entity whose final\n * placement depends on data not yet known when the descriptor carrying this\n * reference is built — e.g. an owning namespace resolved only once the\n * surrounding structure is assembled.\n */\nexport type EntityRef = {\n readonly entityKind: string;\n readonly entityName: string;\n readonly entity: unknown;\n};\n\n/**\n * Column spec carrying the codec factory closure alongside the {@link ColumnTypeDescriptor} fields. Codec authors return a `ColumnSpec` from per-codec column helpers; the runtime materializes the codec instance by calling `codecFactory(ctx)` once it knows the column's `CodecInstanceContext`.\n *\n * Extends {@link ColumnTypeDescriptor} so `ColumnSpec` instances flow directly into contract-authoring sites that consume the descriptor shape — no structural mirroring required.\n */\nexport interface ColumnSpec<R, P extends Record<string, unknown> | undefined>\n extends ColumnTypeDescriptor {\n readonly codecFactory: (ctx: CodecInstanceContext) => R;\n readonly typeParams: P;\n}\n\n/**\n * Trivial column packager. Per-codec helpers call this directly with the result of `descriptor.factory(params)` — direct method invocation binds the descriptor's method-level generic at the call site and the literal flows through `R`.\n *\n * `nativeType` is the column's database-native type spelling — the value the postgres adapter's migration planner, the SQL renderer's cast policy, and the contract's `meta.db.<family>.<target>.nativeType` slot read. Per-codec helpers pass the literal native-type string for their codec (e.g. `'text'`, `'int4'`, `'character varying'`); for codecs whose native-type spelling depends on parameters (none today; reserved for future shapes), the helper computes the rendered string before calling `column`. The framework does not derive the value from `codecId` — that mapping is target-specific and lives at the helper.\n */\nexport function column<R, P extends Record<string, unknown> | undefined>(\n codecFactory: (ctx: CodecInstanceContext) => R,\n codecId: string,\n typeParams: P,\n nativeType: string,\n): ColumnSpec<R, P> {\n return {\n codecFactory,\n codecId,\n typeParams,\n nativeType,\n };\n}\n\n/**\n * Coarse `satisfies` shape — checks the helper's typeParams record matches the descriptor's factory params. Catches \"wrong typeParams shape\" wiring mistakes; does NOT catch \"wrong descriptor's factory\" mistakes (the codec slot is left as `unknown`).\n *\n * Use when the codec's `ReturnType<factory>` is unstable (e.g. heavily overloaded factories where extraction widens too much).\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure — `CodecDescriptor<P>` is invariant in P, so concrete subclasses do not extend `CodecDescriptor<unknown>`; matches the existing `AnyCodecDescriptor` pattern\nexport type ColumnHelperFor<D extends CodecDescriptor<any>> = (\n // biome-ignore lint/suspicious/noExplicitAny: helper signature is the verification subject; satisfies clauses can't narrow this without circular inference\n ...args: any[]\n) => ColumnSpec<unknown, ColumnHelperParams<D>>;\n\n/**\n * Strict `satisfies` shape — also checks the helper's codec is at least the *base* codec instance type the descriptor's factory returns. `ReturnType<ReturnType<D['factory']>>` widens method generics to their constraint, so this only sanity-checks the wiring at the base type level. Literal preservation comes from the direct `descriptor.factory(...)` call inside the helper, not from `satisfies`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure — `CodecDescriptor<P>` is invariant in P, so concrete subclasses do not extend `CodecDescriptor<unknown>`; matches the existing `AnyCodecDescriptor` pattern\nexport type ColumnHelperForStrict<D extends CodecDescriptor<any>> = (\n // biome-ignore lint/suspicious/noExplicitAny: helper signature is the verification subject; satisfies clauses can't narrow this without circular inference\n ...args: any[]\n) => ColumnSpec<ReturnType<ReturnType<D['factory']>>, ColumnHelperParams<D>>;\n\n/**\n * Coerce a descriptor's `factory` first parameter into the typeParams shape `ColumnSpec` accepts. Non-parameterized descriptors (factory with no params, or `params: void`) collapse to `undefined`; parameterized descriptors keep the params record shape.\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure — see above\ntype ColumnHelperParams<D extends CodecDescriptor<any>> =\n Parameters<D['factory']>[0] extends Record<string, unknown>\n ? Parameters<D['factory']>[0]\n : undefined;\n","import type { JsonValue } from '@prisma-next/contract/types';\n\n/**\n * Renders a codec-encoded value as a TypeScript literal (e.g. `'low'`, `1`, `true`), or `undefined`\n * when the value isn't literal-expressible (objects, arrays, null).\n *\n * Valid **only for identity codecs** whose `encodeJson` output equals their decoded output type\n * (text, int, float, bool). A non-identity codec (e.g. one that encodes to an int but decodes to a\n * string literal) must NOT use this: it has to `decodeJson` first, then render, in its own\n * `renderValueLiteral`.\n *\n * String values are fully escaped for a single-quoted `.d.ts` literal: backslash, single quote, and\n * every character a raw single-quoted TS literal cannot contain — newline, carriage return, and the\n * U+2028/U+2029 line/paragraph separators (which JS also treats as line terminators).\n */\nexport function renderTsLiteral(value: JsonValue): string | undefined {\n if (typeof value === 'string') {\n const escaped = value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n return `'${escaped}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AA0DA,IAAsB,YAAtB,MAMA;CAK8B;;;;CAA5B,YAAY,YAAkD;EAAlC,KAAA,aAAA;CAAmC;CAE/D,IAAI,KAAS;EACX,OAAO,KAAK,WAAW;CACzB;AAMF;;;ACWA,MAAa,mBAAgC;CAC3C,WAAW,KAAA;CACX,sBAAsB,KAAA;CACtB,eAAe,KAAA;CACf,2BAA2B,KAAA;AAC7B;;;;AAuBA,MAAa,mBAA2C,EACtD,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,UACT,UAAU,KAAA,IACN,EAAE,OAAO,KAAA,EAAU,IACnB,EACE,QAAQ,CACN,EACE,SAAS,2EACX,CACF,EACF;AACR,EACF;;;;;;;;;;ACrDA,IAAsB,sBAAtB,MAA8F;CAI5F;;CAKA,IAAI,kBAA2B;EAC7B,OAAO,KAAK,iBAAiB;CAC/B;AAoBF;;;;;;;;AC9CA,SAAgB,OACd,cACA,SACA,YACA,YACkB;CAClB,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;;;;;;;;;;;;;AC9DA,SAAgB,gBAAgB,OAAsC;CACpE,IAAI,OAAO,UAAU,UAQnB,OAAO,IAPS,MACb,QAAQ,OAAO,MAAM,CAAC,CACtB,QAAQ,MAAM,KAAK,CAAC,CACpB,QAAQ,OAAO,KAAK,CAAC,CACrB,QAAQ,OAAO,KAAK,CAAC,CACrB,QAAQ,WAAW,SAAS,CAAC,CAC7B,QAAQ,WAAW,SACL,EAAE;CAErB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;AAGvB"}
{"version":3,"file":"codec.mjs","names":[],"sources":["../src/shared/codec.ts","../src/shared/codec-types.ts","../src/shared/codec-descriptor.ts","../src/shared/column-spec.ts","../src/shared/render-ts-literal.ts"],"sourcesContent":["/**\n * Codec interface (consumer surface) and abstract `CodecImpl` base (codec-author surface).\n *\n * Consumers depend on the {@link Codec} interface — it describes the runtime instance returned by a descriptor's curried factory and is what the framework threads through emit, validate, and execute paths.\n *\n * Codec authors `extend` the {@link CodecImpl} abstract class to declare a typed runtime codec instance. The class carries a variance-erased descriptor reference (`CodecDescriptor<any>`); `id` proxies through the descriptor so one source of truth governs both metadata reads and aliasing semantics (alias subclasses inherit the descriptor's id automatically).\n *\n * Class generic shape: `Id`, `TTraits`, `TWire`, `TInput`. Method generics on the codec subclass's own surface (e.g. arktype-json's schema generic, pgvector's dimension generic) flow through the subclass's constructor and propagate via the descriptor's typed `factory(params)` return at *direct* call sites.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { CodecDescriptor } from './codec-descriptor';\nimport type { CodecCallContext, CodecTrait } from './codec-types';\n\n/**\n * A codec is the contract between an application value and its driver-wire and JSON representations.\n *\n * The author's mental model is two JS-side types — `TInput` (the application JS type) and `TWire` (the database driver wire format) — plus a target-defined `JsonValue`. The codec translates `TInput` to `TWire` on writes and back on ordinary reads, and to/from the target's JSON representation for contract artifacts and database-produced JSON values.\n *\n * Three representations participate:\n * - **Input** (`TInput`): the JS type at the application boundary.\n * - **Wire** (`TWire`): the format exchanged with the database driver.\n * - **JSON** (`JsonValue`): the target-defined JSON-safe form used in contract artifacts. It uses the exact scalar shape the target produces inside JSON values, which can differ from the ordinary wire format.\n *\n * The runtime instance carries only its `id` (the descriptor's `codecId`, set by the factory) and the four conversion methods. Static metadata (`traits`, `targetTypes`, `meta`) and the build-time `renderOutputType` renderer live on the {@link CodecDescriptor} keyed by `codecId` — the read-surface single source of truth. Consumers that need them resolve through `descriptorFor(codecId)`.\n *\n * Codec methods split into two groups:\n *\n * - **Query-time** methods (`encode`, `decode`) run per row/parameter at the IO boundary; they are required and Promise-returning. The per-family codec factory accepts sync or async author functions and lifts sync ones to Promise-shaped methods automatically.\n * - **JSON** methods (`encodeJson`, `decodeJson`) run when the contract is serialized or loaded. Runtimes may also use `decodeJson` for values embedded in database-produced JSON results. They stay synchronous so contract validation and client construction are synchronous.\n *\n * Target-family codec interfaces extend this base; family-specific concerns (e.g. the SQL `column?` per-call context) layer on through the `CodecCallContext` extension pattern.\n */\nexport interface Codec<\n Id extends string = string,\n TTraits extends readonly CodecTrait[] = readonly CodecTrait[],\n TWire = unknown,\n TInput = unknown,\n> {\n /** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). The factory sets this to the descriptor's `codecId`; consumers use it as a back-reference for descriptor lookups and for decode-error diagnostics. */\n readonly id: Id;\n /** Phantom carrier for the `TTraits` generic; type-only, undefined at runtime. Runtime traits live on {@link CodecDescriptor.traits}. Implemented as a string-key phantom (`__codecTraits`) rather than `unique symbol` so bundlers that split `.d.ts` chunks do not strand symbol identity on chunk-private paths (the same `TS2742` family that the public re-export of `CodecTypes` works around). */\n readonly __codecTraits?: TTraits;\n /** Converts a JS value to the wire format expected by the database driver. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(value) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */\n encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;\n /** Converts a wire value from the database driver into the JS application type. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(wire) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */\n decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;\n /** Converts a JS value to the target-defined JSON representation used for contract serialization. This must match the scalar shape produced by the target inside JSON values. Synchronous; called during contract emission. */\n encodeJson(value: TInput): JsonValue;\n /** Converts the target-defined JSON representation back to the JS input type. Synchronous; called during contract loading via `family.deserializeContract` and may be called by runtimes for embedded JSON values. */\n decodeJson(json: JsonValue): TInput;\n}\n\n/**\n * Abstract base class for concrete codec implementations.\n *\n * Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override all four abstract conversion methods: `encode`, `decode`, `encodeJson`, and `decodeJson`. The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.\n */\nexport abstract class CodecImpl<\n Id extends string = string,\n TTraits extends readonly CodecTrait[] = readonly CodecTrait[],\n TWire = unknown,\n TInput = unknown,\n> implements Codec<Id, TTraits, TWire, TInput>\n{\n /**\n * Variance-erased descriptor reference. Concrete codec subclasses receive the typed descriptor in their own constructors and forward it via `super(descriptor)`; the variance erasure lives at this base because the abstract surface can't carry the concrete `TParams`.\n */\n // biome-ignore lint/suspicious/noExplicitAny: variance-erased descriptor reference; subclasses retain typed access via their own state\n constructor(public readonly descriptor: CodecDescriptor<any>) {}\n\n get id(): Id {\n return this.descriptor.codecId as Id;\n }\n\n abstract encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;\n abstract decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;\n abstract encodeJson(value: TInput): JsonValue;\n abstract decodeJson(json: JsonValue): TInput;\n}\n","import type { JsonValue } from '@prisma-next/contract/types';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Codec } from './codec';\nimport type { AnyCodecDescriptor } from './codec-descriptor';\n\nexport type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';\n\n/**\n * Serializable codec identity carried by every codec-bearing AST node.\n *\n * `(codecId, typeParams?)` is the single fact the runtime needs to materialize a codec via `descriptorFor(codecId).factory(typeParams)(ctx)`. The pair is content-keyed: two refs with the same `codecId` and structurally equal `typeParams` (regardless of object key ordering) resolve to the same memoized {@link Codec} instance.\n *\n * `typeParams` is `JsonValue`-constrained so the ref survives JSON serialization (relevant for AST-embedded migration ops). Non-parameterized codecs leave `typeParams` undefined; the descriptor's `paramsSchema` validates the value at the JSON boundary.\n *\n * `many` marks a scalar-array (list-typed) column. When `true`, the encode/decode paths map the element codec over the JS array rather than applying the codec to the whole value. The element codec id is `codecId`; the driver owns the array wire framing (`{…}`) in both directions. Absent for scalar columns.\n *\n * Family-agnostic by design — both SQL and Mongo AST nodes carry `codec: CodecRef | undefined`, and the resolver is the only dispatch path that survives serialization.\n */\nexport interface CodecRef {\n readonly codecId: string;\n readonly typeParams?: JsonValue;\n readonly many?: boolean;\n}\n\n/**\n * Per-call context the runtime threads to every `codec.encode` / `codec.decode` invocation for a single `runtime.execute()` call.\n *\n * The framework-level shape is family-agnostic and carries one field:\n *\n * - `signal?: AbortSignal` — per-query cancellation. The runtime returns a `RUNTIME.ABORTED` envelope when the signal aborts; codec authors who forward `signal` to their underlying SDK get true cancellation of in-flight network calls.\n *\n * Family layers extend this base with their own shape-of-call metadata: the SQL family adds `column?: SqlColumnRef` via `SqlCodecCallContext` (see `@prisma-next/sql-relational-core`). Mongo currently uses this framework type unchanged. Column metadata is intentionally **not** on the framework type — it is a SQL-family concept rooted in SQL's `(table, column)` addressing model and would not generalise to other families.\n *\n * The interface is named explicitly (not inlined) so future framework fields and family extensions can land additively without breaking codec author signatures.\n */\nexport interface CodecCallContext {\n readonly signal?: AbortSignal;\n}\n\n/**\n * Codec-id-keyed read surface threaded into emit and authoring paths.\n *\n * - `get(id)` returns a representative {@link Codec} instance for the codec id (used by `family.deserializeContract` for `decodeJson` of literal column defaults). For parameterized codecs whose factory requires concrete params, this may return `undefined` — use `CodecRegistry.forCodecRef` instead.\n * - `targetTypesFor(id)` exposes the codec-id-keyed `targetTypes` metadata the runtime instance no longer carries (TML-2357). Returns the same array `CodecDescriptor.targetTypes` would; for Mongo (whose registration doesn't yet resolve through the unified descriptor map — TML-2324) the family-side assembly populates this directly from the contributor's codec metadata.\n * - `metaFor(id, typeParams)` exposes the codec-id-keyed `meta` (e.g. SQL-side `db.sql.postgres.nativeType`) the runtime instance no longer carries. `typeParams` is optional: when given and the codec descriptor implements a params-aware `metaFor`, the descriptor computes its meta from those params (e.g. a native enum's per-instance Postgres type name); otherwise (or when `typeParams` is omitted) the codec's static `meta` is returned.\n * - `renderOutputTypeFor(id, params)` exposes the codec-id-keyed `renderOutputType` renderer the runtime instance no longer carries. Returns `undefined` when the codec doesn't render a custom type or when the codec id is unknown.\n */\nexport interface CodecLookup {\n get(id: string): Codec | undefined;\n targetTypesFor(id: string): readonly string[] | undefined;\n metaFor(id: string, typeParams?: Record<string, unknown> | JsonValue): CodecMeta | undefined;\n renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;\n /** Codec-id-keyed `renderInputType` renderer for the `contract.d.ts` input position. Optional so existing lookups need not provide it; returns `undefined` when the codec renders no custom input type or the id is unknown. */\n renderInputTypeFor?(id: string, params: Record<string, unknown>): string | undefined;\n /** Codec-id-keyed `renderValueLiteral` renderer for the emit path (`side`: `output` = read type, `input` = create/update type). Optional so existing lookups need not provide it; returns `undefined` when the codec's output isn't literal-expressible or the id is unknown. */\n renderValueLiteralFor?(\n id: string,\n value: JsonValue,\n side: 'output' | 'input',\n ): string | undefined;\n /**\n * Codec-id-keyed descriptor accessor. Returns the full registered\n * {@link AnyCodecDescriptor} for `id`, or `undefined` if no descriptor is\n * registered. Optional so existing lookups need not provide it; a consumer\n * that needs more than the derived per-id readers above — e.g. an\n * authoring-time hook a target-specific descriptor exposes but this\n * framework interface does not model generically — fetches the descriptor\n * itself and narrows it with its own structural predicate.\n */\n descriptorFor?(id: string): AnyCodecDescriptor | undefined;\n}\n\n/**\n * Full codec registry — the read surface of {@link CodecLookup} plus codec resolution by ref or\n * column coordinate. Built once by `extractCodecLookup` and passed by reference to adapters and\n * other consumers that need to materialise codecs at runtime.\n *\n * - `forCodecRef(ref)` materialises a codec from a {@link CodecRef}. Throws\n * `RUNTIME.CODEC_DESCRIPTOR_MISSING` for unknown ids and `RUNTIME.TYPE_PARAMS_INVALID` on param\n * schema rejection.\n * - `forColumn(namespaceId, table, column)` returns the codec for a specific column coordinate, or\n * `undefined` when no column-to-codec mapping is present. This registry is contract-free so it\n * always returns `undefined` — the method exists so the object structurally satisfies the SQL\n * `ContractCodecRegistry` interface.\n */\nexport interface CodecRegistry extends CodecLookup {\n forCodecRef(ref: CodecRef): Codec;\n forColumn(namespaceId: string, table: string, column: string): Codec | undefined;\n}\n\nexport const emptyCodecLookup: CodecLookup = {\n get: () => undefined,\n targetTypesFor: () => undefined,\n metaFor: () => undefined,\n renderOutputTypeFor: () => undefined,\n};\n\n/**\n * Family-agnostic per-instance context supplied by the framework when applying a higher-order codec factory. Allows stateful codecs (e.g. column-scoped encryption) to derive per-instance state from the materialization site.\n *\n * - `name` — the family-agnostic instance identity. For SQL, the runtime populates this as the `storage.types` instance name (e.g. `Embedding1536`) for typeRef-shaped columns, an inline-column sentinel (`<col:Document.embedding>`) for inline-`typeParams` columns, a shared codec-id sentinel (`<codec:pg/text@1>`) for non-parameterized codec ids, or the canonical cache key (`<codecId>:<canonicalizeJson(typeParams)>`) for ad-hoc refs the contract walk did not pre-populate. Other families pick the analogous identity for their materialization sites.\n *\n * Family-specific extensions (e.g. {@link import('@prisma-next/sql-relational-core/ast').SqlCodecInstanceContext} in the SQL layer) augment this base with domain-shaped column-set metadata. Codec authors target the base when they don't read family-specific metadata; they target the family extension when they do.\n */\nexport interface CodecInstanceContext {\n readonly name: string;\n}\n\n/**\n * Family-agnostic codec metadata. Family-specific extensions augment the base `db.<family>.<target>` block with native-type information; the base shape is an empty object so non-relational codecs can carry no metadata.\n */\nexport interface CodecMeta {\n readonly db?: Record<string, unknown>;\n}\n\n/**\n * Standard Schema validator for `void` params. Accepts only `undefined` (or absent input); rejects any other value so a contract that tries to thread `typeParams` through a non-parameterized codec id fails fast at the JSON boundary instead of silently coercing the value away. Used by the framework-supplied non-parameterized descriptor synthesizer.\n */\nexport const voidParamsSchema: StandardSchemaV1<void> = {\n '~standard': {\n version: 1,\n vendor: 'prisma-next',\n validate: (input) =>\n input === undefined\n ? { value: undefined }\n : {\n issues: [\n {\n message: 'unexpected typeParams for non-parameterized codec (void params expected)',\n },\n ],\n },\n },\n};\n","/**\n * Codec descriptor interface (consumer surface) and abstract `CodecDescriptorImpl` base (codec-author surface).\n *\n * Consumers depend on the {@link CodecDescriptor} interface — it is the codec-id-keyed source of truth for static metadata (`traits`, `targetTypes`, `meta`) and registration concerns (`paramsSchema`; optional `renderOutputType`). The runtime `Codec` instance returned by `factory(params)(ctx)` carries only the conversion behavior.\n *\n * Codec authors `extend` the {@link CodecDescriptorImpl} abstract class to declare their codec id, traits, target types, params schema, the `factory(params)` that materializes a typed `Codec<...>`, and (optionally) a `renderOutputType(params)` for the emit path.\n *\n * The factory's method-level generic is the load-bearing piece for literal preservation: per-codec column helpers invoke `descriptor.factory(...)` *directly*, and the direct call binds the generic at its call site. Type extraction (`ReturnType<D['factory']>`, structural matching) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.\n */\n\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Codec } from './codec';\nimport {\n type CodecInstanceContext,\n type CodecMeta,\n type CodecTrait,\n voidParamsSchema,\n} from './codec-types';\n\n/**\n * Unified codec descriptor. Every codec in the framework registers through this shape — non-parameterized codecs use `P = void` and a constant factory that returns the same shared codec instance for every column; parameterized codecs use a non-empty `P` and a curried higher-order factory that returns a per-instance codec.\n *\n * The descriptor is the codec-id-keyed source of truth for static metadata (`traits`, `targetTypes`, `meta`) and registration concerns (`paramsSchema` for JSON-boundary validation; optional `renderOutputType` for the `contract.d.ts` emit path). The runtime `Codec` instance returned by `factory(params)(ctx)` carries only the conversion behavior.\n *\n * Whether a codec id \"is parameterized\" stops being a registration-time distinction — it's a property of `P` on the descriptor. The descriptor map indexes every descriptor by `codecId`; both `descriptorFor(codecId)` and `forColumn(table, column)` resolve through the same map without branching on parameterization.\n *\n * @template P - The shape of the params accepted by the factory (`void` for non-parameterized codecs; a record like `{ length: number }` for parameterized codecs).\n *\n * Codec-registry-unification project § Decision.\n */\nexport interface CodecDescriptor<P = void> {\n /** The codec ID this descriptor applies to (e.g. `pg/vector@1`, `pg/text@1`). */\n readonly codecId: string;\n /** Semantic traits for operator gating (e.g. equality, order, numeric). */\n readonly traits: readonly CodecTrait[];\n /** Database-native type names this codec handles (e.g. `['timestamptz']`). */\n readonly targetTypes: readonly string[];\n /** Optional family-specific metadata (e.g. SQL-side `db.sql.postgres.nativeType`). */\n readonly meta?: CodecMeta;\n /** Standard Schema validator for the factory's params. Validates JSON-sourced params at the contract boundary (PSL → IR; `contract.json` → runtime). For non-parameterized codecs (`P = void`), the schema validates `void`/`undefined` — the framework supplies no params at the call boundary. */\n readonly paramsSchema: StandardSchemaV1<P>;\n /** Whether this descriptor is parameterized — i.e. its `paramsSchema` is something other than the singleton `voidParamsSchema`. Consumers that need to gate column-aware dispatch read this directly rather than threading a free-floating `(codecId) => boolean` callback. */\n readonly isParameterized: boolean;\n /** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Optional; absent renderers cause `CodecLookup.metaFor` to fall back to the codec's static `meta`. Non-parameterized codecs typically omit it. */\n readonly metaFor?: (params: P) => CodecMeta | undefined;\n /** Emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for given params (e.g. `Vector<1536>`). Optional; absent renderers cause the emitter to fall back to the codec's base output type. Non-parameterized codecs typically omit it. */\n readonly renderOutputType?: (params: P) => string | undefined;\n /** Emit-path string renderer for the `contract.d.ts` *input* position (create/update values). Returns the TypeScript input type expression for given params. Optional; absent renderers fall back to the codec's base input type. A codec supplies this when its write type is narrower than the generic codec input — e.g. an enum whose input should be the literal member union, not `string`. */\n readonly renderInputType?: (params: P) => string | undefined;\n /**\n * Given one stored (codec-encoded) value, return the TypeScript literal type to print for it\n * (e.g. `'low'`, `1`), or `undefined` if this codec's output isn't literal-expressible (e.g. a\n * Date-output codec).\n *\n * `value` is the `encodeJson` form stored in the value set. `side` selects which type to print:\n * `output` = the read/SELECT type; `input` = the create/update type. Most codecs render the same\n * literal for both, but a codec whose read and write types differ can render per side. Called once\n * per permitted value; the caller joins the results with `|`.\n */\n readonly renderValueLiteral?: (value: JsonValue, side: 'output' | 'input') => string | undefined;\n /** The curried higher-order codec. For non-parameterized codecs, the factory is constant — every call returns the same shared codec instance. For parameterized codecs, the factory is called once per `storage.types` instance (or once per inline-`typeParams` column), with `ctx` carrying the column set the resulting codec serves. */\n readonly factory: (params: P) => (ctx: CodecInstanceContext) => Codec;\n}\n\n/**\n * Variance-erased {@link CodecDescriptor} alias. `CodecDescriptor<P>` is invariant in `P` (the `factory` and `renderOutputType` slots use `P` contravariantly), so `CodecDescriptor<P>` does not extend `CodecDescriptor<unknown>` for specific `P`. Heterogeneous descriptor collections — e.g. `SqlStaticContributions.codecs:` returning a list that mixes parameterized and non-parameterized descriptors — type against this alias and narrow per codec id at the consumer.\n *\n * Codec-registry-unification spec § Decision: every codec resolves through one descriptor map; reads are non-branching.\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure for heterogeneous descriptor collections\nexport type AnyCodecDescriptor = CodecDescriptor<any>;\n\n/**\n * Abstract base class for concrete codec descriptors.\n *\n * Codec authors extend this class with their typed `TParams` and declare `codecId`, `traits`, `targetTypes`, `paramsSchema`, the curried `factory(params)`, and (optionally) `renderOutputType`.\n *\n * Implements the {@link CodecDescriptor} interface so a concrete subclass instance is directly usable wherever the framework expects a `CodecDescriptor<P>`.\n */\nexport abstract class CodecDescriptorImpl<TParams = void> implements CodecDescriptor<TParams> {\n abstract readonly codecId: string;\n abstract readonly traits: readonly CodecTrait[];\n abstract readonly targetTypes: readonly string[];\n readonly meta?: CodecMeta;\n\n abstract readonly paramsSchema: StandardSchemaV1<TParams>;\n\n /** Boolean derived from `paramsSchema`: `true` whenever the schema is not the singleton `voidParamsSchema`. */\n get isParameterized(): boolean {\n return this.paramsSchema !== voidParamsSchema;\n }\n\n /** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Non-parameterized codecs typically omit it. */\n metaFor?(params: TParams): CodecMeta | undefined;\n\n /** Optional emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for the given params (e.g. `Vector<1536>`). Non-parameterized codecs typically omit it. */\n renderOutputType?(params: TParams): string | undefined;\n\n /** Optional emit-path string renderer for the `contract.d.ts` input position. Returns the TypeScript input type expression for the given params; supplied when the write type is narrower than the generic codec input (e.g. an enum's literal member union). */\n renderInputType?(params: TParams): string | undefined;\n\n /** Optional emit-path renderer for a single stored value. See {@link CodecDescriptor.renderValueLiteral}. */\n renderValueLiteral?(value: JsonValue, side: 'output' | 'input'): string | undefined;\n\n /**\n * Materialize a curried codec factory for the given params. Concrete subclasses override with a typed return type (e.g. `factory<N>(params: { length: N }): (ctx) => VectorCodec<N>`); per-codec helpers read the typed return at the *direct* call site, which is what preserves method-level generics. Type extraction (e.g. `ReturnType<D['factory']>`) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.\n */\n abstract factory(\n params: TParams,\n ): (ctx: CodecInstanceContext) => Codec<string, readonly CodecTrait[], unknown, unknown>;\n}\n","/**\n * `column()` packager + `ColumnSpec<R, P>` shape + `ColumnHelperFor<D>` variants for tying per-codec column helpers to their descriptor.\n *\n * `ColumnSpec<R, P>` extends {@link ColumnTypeDescriptor} so it remains a drop-in for contract authoring sites that consume `ColumnTypeDescriptor` shapes — both types live at the framework-components layer so the `extends` clause is real (no structural mirror).\n *\n * `column()` is a trivial, non-polymorphic packager. Generic over `R` (the codec instance type returned by the descriptor's curried factory) and `P` (the typeParams record). The framework does NOT try to infer `R` and `P` from a descriptor — that path is the variance trap. Per-codec helpers absorb the descriptor relationship instead and tie themselves to their descriptor via `satisfies ColumnHelperFor<D>` or `satisfies ColumnHelperForStrict<D>`.\n */\n\nimport type { ValueSetRef } from '@prisma-next/contract/types';\nimport type { CodecDescriptor } from './codec-descriptor';\nimport type { CodecInstanceContext } from './codec-types';\n\n/**\n * Authored column-type descriptor — the data shape an authoring site (PSL or TypeScript builders) attaches to a column to identify its codec and its native database type.\n *\n * Lives at the framework-components layer alongside the codec types so codec-author packages (e.g. column-spec / `column()` packagers) can extend it directly without crossing layer boundaries.\n *\n * @template TCodecId Narrowed codec id literal for sites that thread a specific codec id through the type system.\n */\nexport type ColumnTypeDescriptor<TCodecId extends string = string> = {\n readonly codecId: TCodecId;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown> | undefined;\n readonly typeRef?: string;\n /**\n * Storage-plane value-set ref, set by an authoring path that resolves a\n * field's type against a value-set-deriving entity (e.g. a PSL entity-ref\n * type constructor like `pg.enum(Ref)`, or a TS `enumType` handle).\n * Threaded straight onto the storage node this descriptor builds, where it\n * drives value-set → codec typing. Every codec's own descriptor leaves this\n * unset.\n */\n readonly valueSet?: ValueSetRef;\n readonly entityRef?: EntityRef;\n};\n\n/**\n * Late-resolved pack-entity reference — a field on the type descriptor it is\n * declared on: `entityKind`/`entityName` identify a pack entity whose final\n * placement depends on data not yet known when the descriptor carrying this\n * reference is built — e.g. an owning namespace resolved only once the\n * surrounding structure is assembled.\n */\nexport type EntityRef = {\n readonly entityKind: string;\n readonly entityName: string;\n readonly entity: unknown;\n};\n\n/**\n * Column spec carrying the codec factory closure alongside the {@link ColumnTypeDescriptor} fields. Codec authors return a `ColumnSpec` from per-codec column helpers; the runtime materializes the codec instance by calling `codecFactory(ctx)` once it knows the column's `CodecInstanceContext`.\n *\n * Extends {@link ColumnTypeDescriptor} so `ColumnSpec` instances flow directly into contract-authoring sites that consume the descriptor shape — no structural mirroring required.\n */\nexport interface ColumnSpec<R, P extends Record<string, unknown> | undefined>\n extends ColumnTypeDescriptor {\n readonly codecFactory: (ctx: CodecInstanceContext) => R;\n readonly typeParams: P;\n}\n\n/**\n * Trivial column packager. Per-codec helpers call this directly with the result of `descriptor.factory(params)` — direct method invocation binds the descriptor's method-level generic at the call site and the literal flows through `R`.\n *\n * `nativeType` is the column's database-native type spelling — the value the postgres adapter's migration planner, the SQL renderer's cast policy, and the contract's `meta.db.<family>.<target>.nativeType` slot read. Per-codec helpers pass the literal native-type string for their codec (e.g. `'text'`, `'int4'`, `'character varying'`); for codecs whose native-type spelling depends on parameters (none today; reserved for future shapes), the helper computes the rendered string before calling `column`. The framework does not derive the value from `codecId` — that mapping is target-specific and lives at the helper.\n */\nexport function column<R, P extends Record<string, unknown> | undefined>(\n codecFactory: (ctx: CodecInstanceContext) => R,\n codecId: string,\n typeParams: P,\n nativeType: string,\n): ColumnSpec<R, P> {\n return {\n codecFactory,\n codecId,\n typeParams,\n nativeType,\n };\n}\n\n/**\n * Coarse `satisfies` shape — checks the helper's typeParams record matches the descriptor's factory params. Catches \"wrong typeParams shape\" wiring mistakes; does NOT catch \"wrong descriptor's factory\" mistakes (the codec slot is left as `unknown`).\n *\n * Use when the codec's `ReturnType<factory>` is unstable (e.g. heavily overloaded factories where extraction widens too much).\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure — `CodecDescriptor<P>` is invariant in P, so concrete subclasses do not extend `CodecDescriptor<unknown>`; matches the existing `AnyCodecDescriptor` pattern\nexport type ColumnHelperFor<D extends CodecDescriptor<any>> = (\n // biome-ignore lint/suspicious/noExplicitAny: helper signature is the verification subject; satisfies clauses can't narrow this without circular inference\n ...args: any[]\n) => ColumnSpec<unknown, ColumnHelperParams<D>>;\n\n/**\n * Strict `satisfies` shape — also checks the helper's codec is at least the *base* codec instance type the descriptor's factory returns. `ReturnType<ReturnType<D['factory']>>` widens method generics to their constraint, so this only sanity-checks the wiring at the base type level. Literal preservation comes from the direct `descriptor.factory(...)` call inside the helper, not from `satisfies`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure — `CodecDescriptor<P>` is invariant in P, so concrete subclasses do not extend `CodecDescriptor<unknown>`; matches the existing `AnyCodecDescriptor` pattern\nexport type ColumnHelperForStrict<D extends CodecDescriptor<any>> = (\n // biome-ignore lint/suspicious/noExplicitAny: helper signature is the verification subject; satisfies clauses can't narrow this without circular inference\n ...args: any[]\n) => ColumnSpec<ReturnType<ReturnType<D['factory']>>, ColumnHelperParams<D>>;\n\n/**\n * Coerce a descriptor's `factory` first parameter into the typeParams shape `ColumnSpec` accepts. Non-parameterized descriptors (factory with no params, or `params: void`) collapse to `undefined`; parameterized descriptors keep the params record shape.\n */\n// biome-ignore lint/suspicious/noExplicitAny: variance erasure — see above\ntype ColumnHelperParams<D extends CodecDescriptor<any>> =\n Parameters<D['factory']>[0] extends Record<string, unknown>\n ? Parameters<D['factory']>[0]\n : undefined;\n","import type { JsonValue } from '@prisma-next/contract/types';\n\n/**\n * Renders a codec-encoded value as a TypeScript literal (e.g. `'low'`, `1`, `true`), or `undefined`\n * when the value isn't literal-expressible (objects, arrays, null).\n *\n * Valid **only for identity codecs** whose `encodeJson` output equals their decoded output type\n * (text, int, float, bool). A non-identity codec (e.g. one that encodes to an int but decodes to a\n * string literal) must NOT use this: it has to `decodeJson` first, then render, in its own\n * `renderValueLiteral`.\n *\n * String values are fully escaped for a single-quoted `.d.ts` literal: backslash, single quote, and\n * every character a raw single-quoted TS literal cannot contain — newline, carriage return, and the\n * U+2028/U+2029 line/paragraph separators (which JS also treats as line terminators).\n */\nexport function renderTsLiteral(value: JsonValue): string | undefined {\n if (typeof value === 'string') {\n const escaped = value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n return `'${escaped}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AA0DA,IAAsB,YAAtB,MAMA;CAK8B;;;;CAA5B,YAAY,YAAkD;EAAlC,KAAA,aAAA;CAAmC;CAE/D,IAAI,KAAS;EACX,OAAO,KAAK,WAAW;CACzB;AAMF;;;ACWA,MAAa,mBAAgC;CAC3C,WAAW,KAAA;CACX,sBAAsB,KAAA;CACtB,eAAe,KAAA;CACf,2BAA2B,KAAA;AAC7B;;;;AAuBA,MAAa,mBAA2C,EACtD,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,UACT,UAAU,KAAA,IACN,EAAE,OAAO,KAAA,EAAU,IACnB,EACE,QAAQ,CACN,EACE,SAAS,2EACX,CACF,EACF;AACR,EACF;;;;;;;;;;ACrDA,IAAsB,sBAAtB,MAA8F;CAI5F;;CAKA,IAAI,kBAA2B;EAC7B,OAAO,KAAK,iBAAiB;CAC/B;AAoBF;;;;;;;;AC9CA,SAAgB,OACd,cACA,SACA,YACA,YACkB;CAClB,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;;;;;;;;;;;;;AC9DA,SAAgB,gBAAgB,OAAsC;CACpE,IAAI,OAAO,UAAU,UAQnB,OAAO,IAPS,MACb,QAAQ,OAAO,MAAM,CAAC,CACtB,QAAQ,MAAM,KAAK,CAAC,CACpB,QAAQ,OAAO,KAAK,CAAC,CACrB,QAAQ,OAAO,KAAK,CAAC,CACrB,QAAQ,WAAW,SAAS,CAAC,CAC7B,QAAQ,WAAW,SACL,EAAE;CAErB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;AAGvB"}
import { n as mergeCapabilityMatrices, t as CapabilityMatrix } from "./capabilities-Cupq4-1-.mjs";
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-Co9FzZij.mjs";
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-D1rRo9Oa.mjs";
export { type AdapterDescriptor, type AdapterInstance, type AdapterPackRef, type CapabilityMatrix, type ComponentDescriptor, type ComponentMetadata, type ContractComponentRequirementsCheckInput, type ContractComponentRequirementsCheckResult, type DriverDescriptor, type DriverInstance, type DriverPackRef, type ExtensionDescriptor, type ExtensionInstance, type ExtensionPackRef, type FamilyDescriptor, type FamilyInstance, type FamilyPackRef, type PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, checkContractComponentRequirements, mergeCapabilityMatrices };

@@ -1,8 +0,8 @@

import { o as CodecRegistry } from "./codec-types-BH2f2dg1.mjs";
import { d as AuthoringFieldNamespace, g as AuthoringModelAttributeDescriptorNamespace, i as AuthoringContributions, l as AuthoringEntityTypeNamespace, w as AuthoringTypeNamespace, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-CEbpeygb.mjs";
import { o as CodecRegistry } from "./codec-types-e32YHT3D.mjs";
import { d as AuthoringFieldNamespace, g as AuthoringModelAttributeDescriptorNamespace, i as AuthoringContributions, l as AuthoringEntityTypeNamespace, w as AuthoringTypeNamespace, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-DEadmUb3.mjs";
import { t as CapabilityMatrix } from "./capabilities-Cupq4-1-.mjs";
import { A as SourceDiagnostic, C as ControlMutationDefaultEntry, D as LoweredDefaultResult, E as DefaultFunctionLoweringContext, M as TypedDefaultFunctionCall, O as LoweredDefaultValue, T as ControlMutationDefaults, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, j as SourceSpan, k as MutationDefaultGeneratorDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, w as ControlMutationDefaultRegistry, y as TargetDescriptor } from "./framework-components-Co9FzZij.mjs";
import { A as SourceDiagnostic, C as ControlMutationDefaultEntry, D as LoweredDefaultResult, E as DefaultFunctionLoweringContext, M as TypedDefaultFunctionCall, O as LoweredDefaultValue, T as ControlMutationDefaults, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, j as SourceSpan, k as MutationDefaultGeneratorDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, w as ControlMutationDefaultRegistry, y as TargetDescriptor } from "./framework-components-D1rRo9Oa.mjs";
import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
import { t as EmissionSpi } from "./emission-types-BryrMZg9.mjs";
import { m as PslDocumentAst } from "./psl-ast-BEdlyUwY.mjs";
import { t as EmissionSpi } from "./emission-types-BQMFUNQO.mjs";
import { m as PslDocumentAst } from "./psl-ast-jgAyMeUx.mjs";
import { Contract, ContractMarkerRecord, ControlPolicy, LedgerEntryRecord } from "@prisma-next/contract/types";

@@ -9,0 +9,0 @@ import { ImportRequirement, ImportRequirement as ImportRequirement$1 } from "@prisma-next/ts-render";

import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-BryrMZg9.mjs";
import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-BQMFUNQO.mjs";
export type { EmissionSpi, GenerateContractTypesOptions, TypesImportSpec, ValidationContext };

@@ -1,2 +0,2 @@

import { b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, y as TargetDescriptor } from "./framework-components-Co9FzZij.mjs";
import { b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, y as TargetDescriptor } from "./framework-components-D1rRo9Oa.mjs";

@@ -3,0 +3,0 @@ //#region src/execution/execution-instances.d.ts

@@ -1,4 +0,4 @@

import { r as CodecLookup } from "./codec-types-BH2f2dg1.mjs";
import { $ as PslExtensionBlockParamRef, G as PslBlockParamValue, H as PslBlockParamList, J as PslExtensionBlockAttribute, K as PslDiagnosticCode, Q as PslExtensionBlockParamOption, U as PslBlockParamOption, V as PslBlockParam, W as PslBlockParamRef, X as PslExtensionBlockParamBare, Y as PslExtensionBlockAttributeArg, Z as PslExtensionBlockParamList, et as PslExtensionBlockParamScalarValue, nt as PslPosition, q as PslExtensionBlock, rt as PslSpan, tt as PslExtensionBlockParamValue, v as AuthoringPslBlockDescriptor, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-CEbpeygb.mjs";
import { A as makePslNamespace, C as PslReferentialAction, D as UNSPECIFIED_PSL_NAMESPACE_ID, E as PslUniqueConstraint, M as namespacePslExtensionBlocks, O as flatPslCompositeTypes, S as PslNamespaceEntry, T as PslTypesBlock, _ as PslIndexConstraint, a as PslAttributeArgument, b as PslNamedTypeDeclaration, c as PslAttributeTarget, d as PslDefaultLiteralValue, f as PslDefaultValue, g as PslFieldAttribute, h as PslField, i as PslAttribute, j as makePslNamespaceEntries, k as flatPslModels, l as PslCompositeType, m as PslDocumentAst, n as ParsePslDocumentInput, o as PslAttributeNamedArgument, p as PslDiagnostic, r as ParsePslDocumentResult, s as PslAttributePositionalArgument, t as BUILTIN_PSL_KIND_KEYS, u as PslDefaultFunctionValue, v as PslModel, w as PslTypeConstructorCall, x as PslNamespace, y as PslModelAttribute } from "./psl-ast-BEdlyUwY.mjs";
import { r as CodecLookup } from "./codec-types-e32YHT3D.mjs";
import { $ as PslExtensionBlockParamRef, G as PslBlockParamValue, H as PslBlockParamList, J as PslExtensionBlockAttribute, K as PslDiagnosticCode, Q as PslExtensionBlockParamOption, U as PslBlockParamOption, V as PslBlockParam, W as PslBlockParamRef, X as PslExtensionBlockParamBare, Y as PslExtensionBlockAttributeArg, Z as PslExtensionBlockParamList, et as PslExtensionBlockParamScalarValue, nt as PslPosition, q as PslExtensionBlock, rt as PslSpan, tt as PslExtensionBlockParamValue, v as AuthoringPslBlockDescriptor, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-DEadmUb3.mjs";
import { A as makePslNamespace, C as PslReferentialAction, D as UNSPECIFIED_PSL_NAMESPACE_ID, E as PslUniqueConstraint, M as namespacePslExtensionBlocks, O as flatPslCompositeTypes, S as PslNamespaceEntry, T as PslTypesBlock, _ as PslIndexConstraint, a as PslAttributeArgument, b as PslNamedTypeDeclaration, c as PslAttributeTarget, d as PslDefaultLiteralValue, f as PslDefaultValue, g as PslFieldAttribute, h as PslField, i as PslAttribute, j as makePslNamespaceEntries, k as flatPslModels, l as PslCompositeType, m as PslDocumentAst, n as ParsePslDocumentInput, o as PslAttributeNamedArgument, p as PslDiagnostic, r as ParsePslDocumentResult, s as PslAttributePositionalArgument, t as BUILTIN_PSL_KIND_KEYS, u as PslDefaultFunctionValue, v as PslModel, w as PslTypeConstructorCall, x as PslNamespace, y as PslModelAttribute } from "./psl-ast-jgAyMeUx.mjs";

@@ -5,0 +5,0 @@ //#region src/control/psl-extension-block-validator.d.ts

@@ -1,2 +0,2 @@

import { t as CodecCallContext } from "./codec-types-BH2f2dg1.mjs";
import { t as CodecCallContext } from "./codec-types-e32YHT3D.mjs";
import { PlanMeta } from "@prisma-next/contract/types";

@@ -3,0 +3,0 @@

{
"name": "@prisma-next/framework-components",
"version": "0.14.0-dev.76",
"version": "0.14.0-dev.77",
"license": "Apache-2.0",

@@ -9,6 +9,6 @@ "type": "module",

"dependencies": {
"@prisma-next/contract": "0.14.0-dev.76",
"@prisma-next/operations": "0.14.0-dev.76",
"@prisma-next/ts-render": "0.14.0-dev.76",
"@prisma-next/utils": "0.14.0-dev.76",
"@prisma-next/contract": "0.14.0-dev.77",
"@prisma-next/operations": "0.14.0-dev.77",
"@prisma-next/ts-render": "0.14.0-dev.77",
"@prisma-next/utils": "0.14.0-dev.77",
"@standard-schema/spec": "^1.1.0",

@@ -18,4 +18,4 @@ "arktype": "^2.2.2"

"devDependencies": {
"@prisma-next/tsconfig": "0.14.0-dev.76",
"@prisma-next/tsdown": "0.14.0-dev.76",
"@prisma-next/tsconfig": "0.14.0-dev.77",
"@prisma-next/tsdown": "0.14.0-dev.77",
"tsdown": "0.22.3",

@@ -22,0 +22,0 @@ "typescript": "5.9.3",

@@ -16,5 +16,5 @@ /**

/**
* A codec is the contract between an application value and its on-wire and on-contract-disk representations.
* A codec is the contract between an application value and its driver-wire and JSON representations.
*
* The author's mental model is two JS-side types — `TInput` (the application JS type) and `TWire` (the database driver wire format) — plus `JsonValue` for build-time contract artifacts. The codec translates `TInput` to `TWire` on writes and back on reads, and to/from `JsonValue` during contract emission and loading.
* The author's mental model is two JS-side types — `TInput` (the application JS type) and `TWire` (the database driver wire format) — plus a target-defined `JsonValue`. The codec translates `TInput` to `TWire` on writes and back on ordinary reads, and to/from the target's JSON representation for contract artifacts and database-produced JSON values.
*

@@ -24,3 +24,3 @@ * Three representations participate:

* - **Wire** (`TWire`): the format exchanged with the database driver.
* - **JSON** (`JsonValue`): a JSON-safe form used in contract artifacts.
* - **JSON** (`JsonValue`): the target-defined JSON-safe form used in contract artifacts. It uses the exact scalar shape the target produces inside JSON values, which can differ from the ordinary wire format.
*

@@ -32,3 +32,3 @@ * The runtime instance carries only its `id` (the descriptor's `codecId`, set by the factory) and the four conversion methods. Static metadata (`traits`, `targetTypes`, `meta`) and the build-time `renderOutputType` renderer live on the {@link CodecDescriptor} keyed by `codecId` — the read-surface single source of truth. Consumers that need them resolve through `descriptorFor(codecId)`.

* - **Query-time** methods (`encode`, `decode`) run per row/parameter at the IO boundary; they are required and Promise-returning. The per-family codec factory accepts sync or async author functions and lifts sync ones to Promise-shaped methods automatically.
* - **Build-time** methods (`encodeJson`, `decodeJson`) run when the contract is serialized or loaded. They stay synchronous so contract validation and client construction are synchronous.
* - **JSON** methods (`encodeJson`, `decodeJson`) run when the contract is serialized or loaded. Runtimes may also use `decodeJson` for values embedded in database-produced JSON results. They stay synchronous so contract validation and client construction are synchronous.
*

@@ -51,5 +51,5 @@ * Target-family codec interfaces extend this base; family-specific concerns (e.g. the SQL `column?` per-call context) layer on through the `CodecCallContext` extension pattern.

decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;
/** Converts a JS value to a JSON-safe representation for contract serialization. Synchronous; called during contract emission. */
/** Converts a JS value to the target-defined JSON representation used for contract serialization. This must match the scalar shape produced by the target inside JSON values. Synchronous; called during contract emission. */
encodeJson(value: TInput): JsonValue;
/** Converts a JSON representation back to the JS input type. Synchronous; called during contract loading via `family.deserializeContract`. */
/** Converts the target-defined JSON representation back to the JS input type. Synchronous; called during contract loading via `family.deserializeContract` and may be called by runtimes for embedded JSON values. */
decodeJson(json: JsonValue): TInput;

@@ -61,3 +61,3 @@ }

*
* Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override `encode`/`decode` (and optionally `encodeJson`/`decodeJson`). The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.
* Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override all four abstract conversion methods: `encode`, `decode`, `encodeJson`, and `decodeJson`. The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.
*/

@@ -64,0 +64,0 @@ export abstract class CodecImpl<

import { JsonValue } from "@prisma-next/contract/types";
import { StandardSchemaV1 } from "@standard-schema/spec";
//#region src/shared/codec-descriptor.d.ts
/**
* Unified codec descriptor. Every codec in the framework registers through this shape — non-parameterized codecs use `P = void` and a constant factory that returns the same shared codec instance for every column; parameterized codecs use a non-empty `P` and a curried higher-order factory that returns a per-instance codec.
*
* The descriptor is the codec-id-keyed source of truth for static metadata (`traits`, `targetTypes`, `meta`) and registration concerns (`paramsSchema` for JSON-boundary validation; optional `renderOutputType` for the `contract.d.ts` emit path). The runtime `Codec` instance returned by `factory(params)(ctx)` carries only the conversion behavior.
*
* Whether a codec id "is parameterized" stops being a registration-time distinction — it's a property of `P` on the descriptor. The descriptor map indexes every descriptor by `codecId`; both `descriptorFor(codecId)` and `forColumn(table, column)` resolve through the same map without branching on parameterization.
*
* @template P - The shape of the params accepted by the factory (`void` for non-parameterized codecs; a record like `{ length: number }` for parameterized codecs).
*
* Codec-registry-unification project § Decision.
*/
interface CodecDescriptor<P = void> {
/** The codec ID this descriptor applies to (e.g. `pg/vector@1`, `pg/text@1`). */
readonly codecId: string;
/** Semantic traits for operator gating (e.g. equality, order, numeric). */
readonly traits: readonly CodecTrait[];
/** Database-native type names this codec handles (e.g. `['timestamptz']`). */
readonly targetTypes: readonly string[];
/** Optional family-specific metadata (e.g. SQL-side `db.sql.postgres.nativeType`). */
readonly meta?: CodecMeta;
/** Standard Schema validator for the factory's params. Validates JSON-sourced params at the contract boundary (PSL → IR; `contract.json` → runtime). For non-parameterized codecs (`P = void`), the schema validates `void`/`undefined` — the framework supplies no params at the call boundary. */
readonly paramsSchema: StandardSchemaV1<P>;
/** Whether this descriptor is parameterized — i.e. its `paramsSchema` is something other than the singleton `voidParamsSchema`. Consumers that need to gate column-aware dispatch read this directly rather than threading a free-floating `(codecId) => boolean` callback. */
readonly isParameterized: boolean;
/** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Optional; absent renderers cause `CodecLookup.metaFor` to fall back to the codec's static `meta`. Non-parameterized codecs typically omit it. */
readonly metaFor?: (params: P) => CodecMeta | undefined;
/** Emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for given params (e.g. `Vector<1536>`). Optional; absent renderers cause the emitter to fall back to the codec's base output type. Non-parameterized codecs typically omit it. */
readonly renderOutputType?: (params: P) => string | undefined;
/** Emit-path string renderer for the `contract.d.ts` *input* position (create/update values). Returns the TypeScript input type expression for given params. Optional; absent renderers fall back to the codec's base input type. A codec supplies this when its write type is narrower than the generic codec input — e.g. an enum whose input should be the literal member union, not `string`. */
readonly renderInputType?: (params: P) => string | undefined;
/**
* Given one stored (codec-encoded) value, return the TypeScript literal type to print for it
* (e.g. `'low'`, `1`), or `undefined` if this codec's output isn't literal-expressible (e.g. a
* Date-output codec).
*
* `value` is the `encodeJson` form stored in the value set. `side` selects which type to print:
* `output` = the read/SELECT type; `input` = the create/update type. Most codecs render the same
* literal for both, but a codec whose read and write types differ can render per side. Called once
* per permitted value; the caller joins the results with `|`.
*/
readonly renderValueLiteral?: (value: JsonValue, side: 'output' | 'input') => string | undefined;
/** The curried higher-order codec. For non-parameterized codecs, the factory is constant — every call returns the same shared codec instance. For parameterized codecs, the factory is called once per `storage.types` instance (or once per inline-`typeParams` column), with `ctx` carrying the column set the resulting codec serves. */
readonly factory: (params: P) => (ctx: CodecInstanceContext) => Codec;
}
/**
* Variance-erased {@link CodecDescriptor} alias. `CodecDescriptor<P>` is invariant in `P` (the `factory` and `renderOutputType` slots use `P` contravariantly), so `CodecDescriptor<P>` does not extend `CodecDescriptor<unknown>` for specific `P`. Heterogeneous descriptor collections — e.g. `SqlStaticContributions.codecs:` returning a list that mixes parameterized and non-parameterized descriptors — type against this alias and narrow per codec id at the consumer.
*
* Codec-registry-unification spec § Decision: every codec resolves through one descriptor map; reads are non-branching.
*/
type AnyCodecDescriptor = CodecDescriptor<any>;
/**
* Abstract base class for concrete codec descriptors.
*
* Codec authors extend this class with their typed `TParams` and declare `codecId`, `traits`, `targetTypes`, `paramsSchema`, the curried `factory(params)`, and (optionally) `renderOutputType`.
*
* Implements the {@link CodecDescriptor} interface so a concrete subclass instance is directly usable wherever the framework expects a `CodecDescriptor<P>`.
*/
declare abstract class CodecDescriptorImpl<TParams = void> implements CodecDescriptor<TParams> {
abstract readonly codecId: string;
abstract readonly traits: readonly CodecTrait[];
abstract readonly targetTypes: readonly string[];
readonly meta?: CodecMeta;
abstract readonly paramsSchema: StandardSchemaV1<TParams>;
/** Boolean derived from `paramsSchema`: `true` whenever the schema is not the singleton `voidParamsSchema`. */
get isParameterized(): boolean;
/** Optional params-aware metadata renderer. Computes this codec instance's `CodecMeta` from its `typeParams` (e.g. a per-instance identifier derived from an enum's declared member set). Non-parameterized codecs typically omit it. */
metaFor?(params: TParams): CodecMeta | undefined;
/** Optional emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for the given params (e.g. `Vector<1536>`). Non-parameterized codecs typically omit it. */
renderOutputType?(params: TParams): string | undefined;
/** Optional emit-path string renderer for the `contract.d.ts` input position. Returns the TypeScript input type expression for the given params; supplied when the write type is narrower than the generic codec input (e.g. an enum's literal member union). */
renderInputType?(params: TParams): string | undefined;
/** Optional emit-path renderer for a single stored value. See {@link CodecDescriptor.renderValueLiteral}. */
renderValueLiteral?(value: JsonValue, side: 'output' | 'input'): string | undefined;
/**
* Materialize a curried codec factory for the given params. Concrete subclasses override with a typed return type (e.g. `factory<N>(params: { length: N }): (ctx) => VectorCodec<N>`); per-codec helpers read the typed return at the *direct* call site, which is what preserves method-level generics. Type extraction (e.g. `ReturnType<D['factory']>`) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.
*/
abstract factory(params: TParams): (ctx: CodecInstanceContext) => Codec<string, readonly CodecTrait[], unknown, unknown>;
}
//#endregion
//#region src/shared/codec.d.ts
/**
* A codec is the contract between an application value and its on-wire and on-contract-disk representations.
*
* The author's mental model is two JS-side types — `TInput` (the application JS type) and `TWire` (the database driver wire format) — plus `JsonValue` for build-time contract artifacts. The codec translates `TInput` to `TWire` on writes and back on reads, and to/from `JsonValue` during contract emission and loading.
*
* Three representations participate:
* - **Input** (`TInput`): the JS type at the application boundary.
* - **Wire** (`TWire`): the format exchanged with the database driver.
* - **JSON** (`JsonValue`): a JSON-safe form used in contract artifacts.
*
* The runtime instance carries only its `id` (the descriptor's `codecId`, set by the factory) and the four conversion methods. Static metadata (`traits`, `targetTypes`, `meta`) and the build-time `renderOutputType` renderer live on the {@link CodecDescriptor} keyed by `codecId` — the read-surface single source of truth. Consumers that need them resolve through `descriptorFor(codecId)`.
*
* Codec methods split into two groups:
*
* - **Query-time** methods (`encode`, `decode`) run per row/parameter at the IO boundary; they are required and Promise-returning. The per-family codec factory accepts sync or async author functions and lifts sync ones to Promise-shaped methods automatically.
* - **Build-time** methods (`encodeJson`, `decodeJson`) run when the contract is serialized or loaded. They stay synchronous so contract validation and client construction are synchronous.
*
* Target-family codec interfaces extend this base; family-specific concerns (e.g. the SQL `column?` per-call context) layer on through the `CodecCallContext` extension pattern.
*/
interface Codec<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown> {
/** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). The factory sets this to the descriptor's `codecId`; consumers use it as a back-reference for descriptor lookups and for decode-error diagnostics. */
readonly id: Id;
/** Phantom carrier for the `TTraits` generic; type-only, undefined at runtime. Runtime traits live on {@link CodecDescriptor.traits}. Implemented as a string-key phantom (`__codecTraits`) rather than `unique symbol` so bundlers that split `.d.ts` chunks do not strand symbol identity on chunk-private paths (the same `TS2742` family that the public re-export of `CodecTypes` works around). */
readonly __codecTraits?: TTraits;
/** Converts a JS value to the wire format expected by the database driver. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(value) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */
encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;
/** Converts a wire value from the database driver into the JS application type. Always Promise-returning at the boundary. The {@link CodecCallContext} is supplied by the runtime on every call (allocated once per `runtime.execute()`); family layers may narrow the ctx to extend it (e.g. SQL adds `column`). Author-side single-arg `(wire) => …` functions remain legal via TypeScript's bivariance for trailing parameters. */
decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;
/** Converts a JS value to a JSON-safe representation for contract serialization. Synchronous; called during contract emission. */
encodeJson(value: TInput): JsonValue;
/** Converts a JSON representation back to the JS input type. Synchronous; called during contract loading via `family.deserializeContract`. */
decodeJson(json: JsonValue): TInput;
}
/**
* Abstract base class for concrete codec implementations.
*
* Codec authors extend this class with their typed `Id`, `TTraits`, `TWire`, `TInput` and override `encode`/`decode` (and optionally `encodeJson`/`decodeJson`). The runtime instance carries only its `id` (proxied through the descriptor so alias subclasses inherit the descriptor's id automatically) and the conversion methods — static metadata lives on the {@link CodecDescriptor}.
*/
declare abstract class CodecImpl<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown> implements Codec<Id, TTraits, TWire, TInput> {
readonly descriptor: CodecDescriptor<any>;
/**
* Variance-erased descriptor reference. Concrete codec subclasses receive the typed descriptor in their own constructors and forward it via `super(descriptor)`; the variance erasure lives at this base because the abstract surface can't carry the concrete `TParams`.
*/
constructor(descriptor: CodecDescriptor<any>);
get id(): Id;
abstract encode(value: TInput, ctx: CodecCallContext): Promise<TWire>;
abstract decode(wire: TWire, ctx: CodecCallContext): Promise<TInput>;
abstract encodeJson(value: TInput): JsonValue;
abstract decodeJson(json: JsonValue): TInput;
}
//#endregion
//#region src/shared/codec-types.d.ts
type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
/**
* Serializable codec identity carried by every codec-bearing AST node.
*
* `(codecId, typeParams?)` is the single fact the runtime needs to materialize a codec via `descriptorFor(codecId).factory(typeParams)(ctx)`. The pair is content-keyed: two refs with the same `codecId` and structurally equal `typeParams` (regardless of object key ordering) resolve to the same memoized {@link Codec} instance.
*
* `typeParams` is `JsonValue`-constrained so the ref survives JSON serialization (relevant for AST-embedded migration ops). Non-parameterized codecs leave `typeParams` undefined; the descriptor's `paramsSchema` validates the value at the JSON boundary.
*
* `many` marks a scalar-array (list-typed) column. When `true`, the encode/decode paths map the element codec over the JS array rather than applying the codec to the whole value. The element codec id is `codecId`; the driver owns the array wire framing (`{…}`) in both directions. Absent for scalar columns.
*
* Family-agnostic by design — both SQL and Mongo AST nodes carry `codec: CodecRef | undefined`, and the resolver is the only dispatch path that survives serialization.
*/
interface CodecRef {
readonly codecId: string;
readonly typeParams?: JsonValue;
readonly many?: boolean;
}
/**
* Per-call context the runtime threads to every `codec.encode` / `codec.decode` invocation for a single `runtime.execute()` call.
*
* The framework-level shape is family-agnostic and carries one field:
*
* - `signal?: AbortSignal` — per-query cancellation. The runtime returns a `RUNTIME.ABORTED` envelope when the signal aborts; codec authors who forward `signal` to their underlying SDK get true cancellation of in-flight network calls.
*
* Family layers extend this base with their own shape-of-call metadata: the SQL family adds `column?: SqlColumnRef` via `SqlCodecCallContext` (see `@prisma-next/sql-relational-core`). Mongo currently uses this framework type unchanged. Column metadata is intentionally **not** on the framework type — it is a SQL-family concept rooted in SQL's `(table, column)` addressing model and would not generalise to other families.
*
* The interface is named explicitly (not inlined) so future framework fields and family extensions can land additively without breaking codec author signatures.
*/
interface CodecCallContext {
readonly signal?: AbortSignal;
}
/**
* Codec-id-keyed read surface threaded into emit and authoring paths.
*
* - `get(id)` returns a representative {@link Codec} instance for the codec id (used by `family.deserializeContract` for `decodeJson` of literal column defaults). For parameterized codecs whose factory requires concrete params, this may return `undefined` — use `CodecRegistry.forCodecRef` instead.
* - `targetTypesFor(id)` exposes the codec-id-keyed `targetTypes` metadata the runtime instance no longer carries (TML-2357). Returns the same array `CodecDescriptor.targetTypes` would; for Mongo (whose registration doesn't yet resolve through the unified descriptor map — TML-2324) the family-side assembly populates this directly from the contributor's codec metadata.
* - `metaFor(id, typeParams)` exposes the codec-id-keyed `meta` (e.g. SQL-side `db.sql.postgres.nativeType`) the runtime instance no longer carries. `typeParams` is optional: when given and the codec descriptor implements a params-aware `metaFor`, the descriptor computes its meta from those params (e.g. a native enum's per-instance Postgres type name); otherwise (or when `typeParams` is omitted) the codec's static `meta` is returned.
* - `renderOutputTypeFor(id, params)` exposes the codec-id-keyed `renderOutputType` renderer the runtime instance no longer carries. Returns `undefined` when the codec doesn't render a custom type or when the codec id is unknown.
*/
interface CodecLookup {
get(id: string): Codec | undefined;
targetTypesFor(id: string): readonly string[] | undefined;
metaFor(id: string, typeParams?: Record<string, unknown> | JsonValue): CodecMeta | undefined;
renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;
/** Codec-id-keyed `renderInputType` renderer for the `contract.d.ts` input position. Optional so existing lookups need not provide it; returns `undefined` when the codec renders no custom input type or the id is unknown. */
renderInputTypeFor?(id: string, params: Record<string, unknown>): string | undefined;
/** Codec-id-keyed `renderValueLiteral` renderer for the emit path (`side`: `output` = read type, `input` = create/update type). Optional so existing lookups need not provide it; returns `undefined` when the codec's output isn't literal-expressible or the id is unknown. */
renderValueLiteralFor?(id: string, value: JsonValue, side: 'output' | 'input'): string | undefined;
/**
* Codec-id-keyed descriptor accessor. Returns the full registered
* {@link AnyCodecDescriptor} for `id`, or `undefined` if no descriptor is
* registered. Optional so existing lookups need not provide it; a consumer
* that needs more than the derived per-id readers above — e.g. an
* authoring-time hook a target-specific descriptor exposes but this
* framework interface does not model generically — fetches the descriptor
* itself and narrows it with its own structural predicate.
*/
descriptorFor?(id: string): AnyCodecDescriptor | undefined;
}
/**
* Full codec registry — the read surface of {@link CodecLookup} plus codec resolution by ref or
* column coordinate. Built once by `extractCodecLookup` and passed by reference to adapters and
* other consumers that need to materialise codecs at runtime.
*
* - `forCodecRef(ref)` materialises a codec from a {@link CodecRef}. Throws
* `RUNTIME.CODEC_DESCRIPTOR_MISSING` for unknown ids and `RUNTIME.TYPE_PARAMS_INVALID` on param
* schema rejection.
* - `forColumn(namespaceId, table, column)` returns the codec for a specific column coordinate, or
* `undefined` when no column-to-codec mapping is present. This registry is contract-free so it
* always returns `undefined` — the method exists so the object structurally satisfies the SQL
* `ContractCodecRegistry` interface.
*/
interface CodecRegistry extends CodecLookup {
forCodecRef(ref: CodecRef): Codec;
forColumn(namespaceId: string, table: string, column: string): Codec | undefined;
}
declare const emptyCodecLookup: CodecLookup;
/**
* Family-agnostic per-instance context supplied by the framework when applying a higher-order codec factory. Allows stateful codecs (e.g. column-scoped encryption) to derive per-instance state from the materialization site.
*
* - `name` — the family-agnostic instance identity. For SQL, the runtime populates this as the `storage.types` instance name (e.g. `Embedding1536`) for typeRef-shaped columns, an inline-column sentinel (`<col:Document.embedding>`) for inline-`typeParams` columns, a shared codec-id sentinel (`<codec:pg/text@1>`) for non-parameterized codec ids, or the canonical cache key (`<codecId>:<canonicalizeJson(typeParams)>`) for ad-hoc refs the contract walk did not pre-populate. Other families pick the analogous identity for their materialization sites.
*
* Family-specific extensions (e.g. {@link import('@prisma-next/sql-relational-core/ast').SqlCodecInstanceContext} in the SQL layer) augment this base with domain-shaped column-set metadata. Codec authors target the base when they don't read family-specific metadata; they target the family extension when they do.
*/
interface CodecInstanceContext {
readonly name: string;
}
/**
* Family-agnostic codec metadata. Family-specific extensions augment the base `db.<family>.<target>` block with native-type information; the base shape is an empty object so non-relational codecs can carry no metadata.
*/
interface CodecMeta {
readonly db?: Record<string, unknown>;
}
/**
* Standard Schema validator for `void` params. Accepts only `undefined` (or absent input); rejects any other value so a contract that tries to thread `typeParams` through a non-parameterized codec id fails fast at the JSON boundary instead of silently coercing the value away. Used by the framework-supplied non-parameterized descriptor synthesizer.
*/
declare const voidParamsSchema: StandardSchemaV1<void>;
//#endregion
export { CodecRef as a, emptyCodecLookup as c, CodecImpl as d, AnyCodecDescriptor as f, CodecMeta as i, voidParamsSchema as l, CodecDescriptorImpl as m, CodecInstanceContext as n, CodecRegistry as o, CodecDescriptor as p, CodecLookup as r, CodecTrait as s, CodecCallContext as t, Codec as u };
//# sourceMappingURL=codec-types-BH2f2dg1.d.mts.map
{"version":3,"file":"codec-types-BH2f2dg1.d.mts","names":[],"sources":["../src/shared/codec-descriptor.ts","../src/shared/codec.ts","../src/shared/codec-types.ts"],"mappings":";;;;;;;;;;;;;;;UA+BiB,eAAA;EAMN;EAAA,SAJA,OAAA;EAMO;EAAA,SAJP,MAAA,WAAiB,UAAA;EAMH;EAAA,SAJd,WAAA;EAMA;EAAA,SAJA,IAAA,GAAO,SAAA;EAMY;EAAA,SAJnB,YAAA,EAAc,gBAAA,CAAiB,CAAA;EAIN;EAAA,SAFzB,eAAA;EAI4B;EAAA,SAF5B,OAAA,IAAW,MAAA,EAAQ,CAAA,KAAM,SAAA;EAIzB;EAAA,SAFA,gBAAA,IAAoB,MAAA,EAAQ,CAAA;EAET;EAAA,SAAnB,eAAA,IAAmB,MAAA,EAAQ,CAAA;EAWE;;;;;;;;;;EAAA,SAA7B,kBAAA,IAAsB,KAAA,EAAO,SAAA,EAAW,IAAA;EAWvC;EAAA,SATD,OAAA,GAAU,MAAA,EAAQ,CAAA,MAAO,GAAA,EAAK,oBAAA,KAAyB,KAAA;AAAA;;AASlB;AAShD;;;KATY,kBAAA,GAAqB,eAAe;;;;;;;;uBAS1B,mBAAA,4BAA+C,eAAA,CAAgB,OAAA;EAAA,kBACjE,OAAA;EAAA,kBACA,MAAA,WAAiB,UAAA;EAAA,kBACjB,WAAA;EAAA,SACT,IAAA,GAAO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AAmB,OAAA,CAAQ,MAAA;EAAA,SACpD,UAAA,CAAW,KAAA,EAAO,MAAA,GAAS,SAAA;EAAA,SAC3B,UAAA,CAAW,IAAA,EAAM,SAAA,GAAY,MAAA;AAAA;;;KCzE5B,UAAA;;;;;;;;;;;;UAaK,QAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA,GAAa,SAAS;EAAA,SACtB,IAAA;AAAA;;;;;;;;;;;;UAcM,gBAAA;EAAA,SACN,MAAA,GAAS,WAAW;AAAA;;;;;;;;;UAWd,WAAA;EACf,GAAA,CAAI,EAAA,WAAa,KAAA;EACjB,cAAA,CAAe,EAAA;EACf,OAAA,CAAQ,EAAA,UAAY,UAAA,GAAa,MAAA,oBAA0B,SAAA,GAAY,SAAA;EACvE,mBAAA,CAAoB,EAAA,UAAY,MAAA,EAAQ,MAAA;EFWrB;EETnB,kBAAA,EAAoB,EAAA,UAAY,MAAA,EAAQ,MAAA;EFSN;EEPlC,qBAAA,EACE,EAAA,UACA,KAAA,EAAO,SAAA,EACP,IAAA;EFImE;AAAA;AASvE;;;;AAAgD;AAShD;;EEXE,aAAA,EAAe,EAAA,WAAa,kBAAA;AAAA;;;;;;;;;;;;;;UAgBb,aAAA,SAAsB,WAAA;EACrC,WAAA,CAAY,GAAA,EAAK,QAAA,GAAW,KAAA;EAC5B,SAAA,CAAU,WAAA,UAAqB,KAAA,UAAe,MAAA,WAAiB,KAAA;AAAA;AAAA,cAGpD,gBAAA,EAAkB,WAK9B;;;;;;;;UASgB,oBAAA;EAAA,SACN,IAAI;AAAA;;;;UAME,SAAA;EAAA,SACN,EAAA,GAAK,MAAM;AAAA;;;;cAMT,gBAAA,EAAkB,gBAAgB"}
import { r as CodecLookup } from "./codec-types-BH2f2dg1.mjs";
import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
import { Contract, ContractModelBase, JsonValue } from "@prisma-next/contract/types";
//#region src/control/emission-types.d.ts
interface GenerateContractTypesOptions {
readonly queryOperationTypeImports?: ReadonlyArray<TypesImportSpec>;
}
interface ValidationContext {
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
readonly extensionIds?: ReadonlyArray<string>;
}
interface EmissionSpi {
readonly id: string;
generateStorageType(contract: Contract, storageHashTypeName: string): string;
generateModelStorageType(modelName: string, model: ContractModelBase): string;
getFamilyImports(): string[];
getFamilyTypeAliases(options?: GenerateContractTypesOptions): string;
getTypeMapsExpression(): string;
getContractWrapper(contractBaseName: string, typeMapsName: string): string;
resolveFieldTypeParams?(modelName: string, fieldName: string, model: ContractModelBase, contract: Contract): Record<string, unknown> | undefined;
/**
* Resolves a field's permitted values (codec-encoded) plus the codec that types them, or
* `undefined` for a field with no restricted value set. The framework renders the values into a TS
* literal union through the codec seam. Each family decides where the values live — a value set in
* its own storage plane, or another family-owned source.
*/
resolveFieldValueSet?(modelName: string, fieldName: string, model: ContractModelBase, contract: Contract): {
readonly encodedValues: readonly JsonValue[];
readonly codecId: string;
} | undefined;
getStorageTypeExports?(contract: Contract, codecLookup?: CodecLookup): string | undefined;
}
//#endregion
export { GenerateContractTypesOptions as n, ValidationContext as r, EmissionSpi as t };
//# sourceMappingURL=emission-types-BryrMZg9.d.mts.map
{"version":3,"file":"emission-types-BryrMZg9.d.mts","names":[],"sources":["../src/control/emission-types.ts"],"mappings":";;;;;UAIiB,4BAAA;EAAA,SACN,yBAAA,GAA4B,aAAa,CAAC,eAAA;AAAA;AAAA,UAGpC,iBAAA;EAAA,SACN,gBAAA,GAAmB,aAAA,CAAc,eAAA;EAAA,SACjC,YAAA,GAAe,aAAA;AAAA;AAAA,UAGT,WAAA;EAAA,SACN,EAAA;EAET,mBAAA,CAAoB,QAAA,EAAU,QAAA,EAAU,mBAAA;EAExC,wBAAA,CAAyB,SAAA,UAAmB,KAAA,EAAO,iBAAA;EAEnD,gBAAA;EAEA,oBAAA,CAAqB,OAAA,GAAU,4BAAA;EAE/B,qBAAA;EAEA,kBAAA,CAAmB,gBAAA,UAA0B,YAAA;EAE7C,sBAAA,EACE,SAAA,UACA,SAAA,UACA,KAAA,EAAO,iBAAA,EACP,QAAA,EAAU,QAAA,GACT,MAAA;EAvBqB;;;;;;EA+BxB,oBAAA,EACE,SAAA,UACA,SAAA,UACA,KAAA,EAAO,iBAAA,EACP,QAAA,EAAU,QAAA;IAAA,SACE,aAAA,WAAwB,SAAA;IAAA,SAAsB,OAAA;EAAA;EAE5D,qBAAA,EAAuB,QAAA,EAAU,QAAA,EAAU,WAAA,GAAc,WAAA;AAAA"}
import { r as CodecLookup } from "./codec-types-BH2f2dg1.mjs";
import { ColumnDefault, ExecutionMutationDefaultPhases } from "@prisma-next/contract/types";
import { Type } from "arktype";
//#region src/shared/psl-extension-block.d.ts
/**
* Shape-only types for the PSL source-position primitives, diagnostic
* codes, extension-block descriptor vocabulary, and the uniform
* extension-block AST node base.
*
* These live in the shared plane so an extension's authoring descriptor
* (`AuthoringPslBlockDescriptor` in `framework-authoring`) can reference
* them without crossing the shared → migration-plane boundary. The
* migration-plane `psl-ast.ts` re-exports everything here for consumers
* that import PSL AST types from the control entrypoint.
*/
interface PslPosition {
readonly offset: number;
readonly line: number;
readonly column: number;
}
interface PslSpan {
readonly start: PslPosition;
readonly end: PslPosition;
}
type PslDiagnosticCode = 'PSL_UNTERMINATED_BLOCK' | 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK' | 'PSL_INVALID_NAMESPACE_BLOCK' | 'PSL_INVALID_ATTRIBUTE_SYNTAX' | 'PSL_INVALID_MODEL_MEMBER' | 'PSL_UNSUPPORTED_MODEL_ATTRIBUTE' | 'PSL_UNSUPPORTED_FIELD_ATTRIBUTE' | 'PSL_INVALID_RELATION_ATTRIBUTE' | 'PSL_INVALID_REFERENTIAL_ACTION' | 'PSL_INVALID_DEFAULT_VALUE' | 'PSL_INVALID_ENUM_MEMBER' | 'PSL_INVALID_TYPES_MEMBER' | 'PSL_INVALID_QUALIFIED_TYPE'
/**
* A qualified name (e.g. a dotted type or attribute reference) is structurally
* invalid, such as an over-qualified or trailing-separator name.
*/
| 'PSL_INVALID_QUALIFIED_NAME'
/**
* A reserved declaration keyword (`model`/`enum`/`namespace`/`type`) that
* committed the declaration kind on the keyword alone but is missing its name
* and/or opening brace. The recursive-descent parser produces a best-effort
* typed node for the malformed header and reports this code rather than
* `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK`, which is reserved for a genuinely unknown
* top-level keyword.
*/
| 'PSL_INVALID_DECLARATION'
/**
* A malformed line inside an extension-contributed top-level block body, or
* a structurally invalid element inside a `list` parameter value.
*
* Replaces the overloaded `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK` code that the
* generic framework parser previously used for these two parse-error sites
* inside extension blocks — keeping `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK` for
* its original meaning (an unknown keyword at the top level) and giving
* extension-block parse errors their own code.
*/
| 'PSL_INVALID_EXTENSION_BLOCK_MEMBER'
/**
* A malformed JS-like object literal `{ key: value, … }` in value/argument
* position — a field missing its `:`, a field missing its value, or an
* unterminated `{`. The recursive-descent parser still produces a best-effort
* `ObjectLiteralExpr` node (preserving the lossless round-trip) and reports
* this code anchored on the offending token.
*/
| 'PSL_INVALID_OBJECT_LITERAL'
/**
* A string literal with no closing quote — the tokenizer stops the literal at
* a newline or at EOF when no terminating `"` is found, and the
* recursive-descent parser still consumes the token (preserving the lossless
* round-trip) but reports this code anchored on the string token's span.
*/
| 'PSL_UNTERMINATED_STRING'
/**
* An unknown parameter key in an extension-contributed block — a key present
* in the source block but absent from the descriptor's `parameters` map.
*/
| 'PSL_EXTENSION_UNKNOWN_PARAMETER'
/**
* A required parameter declared in the descriptor is absent from the parsed block.
*/
| 'PSL_EXTENSION_MISSING_REQUIRED_PARAMETER'
/**
* An `option`-kind parameter value is not one of the allowed tokens listed
* in the descriptor's `values` array.
*/
| 'PSL_EXTENSION_OPTION_OUT_OF_SET'
/**
* A `value`-kind parameter's raw text is not a valid JSON literal, or the
* parsed JSON value was rejected by the codec's `decodeJson` method, or the
* codec id is not registered in the lookup.
*/
| 'PSL_EXTENSION_INVALID_VALUE'
/**
* A `ref`-kind parameter identifier does not resolve to a declared entity of
* the required `refKind` within the declared scope.
*/
| 'PSL_EXTENSION_UNRESOLVED_REF'
/**
* A parameter key appears more than once in an extension block body.
* The first occurrence is kept; subsequent occurrences emit this diagnostic.
*/
| 'PSL_EXTENSION_DUPLICATE_PARAMETER'
/**
* A `@@`-prefixed block-attribute line inside an extension block has invalid syntax.
*/
| 'PSL_INVALID_EXTENSION_BLOCK_ATTRIBUTE'
/**
* Duplicate scopes are top level, namespace body, or block fields; diagnostics
* are first-wins and anchored on later name spans.
*/
| 'PSL_DUPLICATE_DECLARATION';
/**
* Descriptor vocabulary for a single parameter on a declared block.
*
* Four kinds:
* - `ref` — the parameter value is an identifier that must resolve to a
* declared entity of `refKind` within the declared `scope`.
* - `value` — the parameter value is a PSL literal parsed and printed
* through the codec identified by `codecId`.
* - `option` — the parameter value is one of the literal tokens in `values`.
* Not a codec; not persisted data. A closed authoring-time constraint only.
* - `list` — a bracketed list whose elements each match the `of` descriptor.
*/
type PslBlockParam = PslBlockParamRef | PslBlockParamValue | PslBlockParamOption | PslBlockParamList;
interface PslBlockParamRef {
readonly kind: 'ref';
readonly refKind: string;
readonly scope: 'same-namespace' | 'same-space' | 'cross-space';
readonly required?: boolean;
}
interface PslBlockParamValue {
readonly kind: 'value';
readonly codecId: string;
readonly required?: boolean;
}
interface PslBlockParamOption {
readonly kind: 'option';
readonly values: readonly string[];
readonly required?: boolean;
}
interface PslBlockParamList {
readonly kind: 'list';
readonly of: PslBlockParam;
readonly required?: boolean;
}
/**
* The parsed representation of a single parameter value on a uniform
* extension-block AST node. Mirrors the `PslBlockParam` descriptor
* vocabulary, plus `bare` for keyonly entries:
*
* - `ref` → `PslExtensionBlockParamRef` — a raw identifier string
* (resolution runs in the validator, not the parser).
* - `value` → `PslExtensionBlockParamScalarValue` — a raw PSL literal string
* (codec validation runs in the validator).
* - `option` → `PslExtensionBlockParamOption` — the chosen token.
* - `list` → `PslExtensionBlockParamList` — ordered list of the above.
* - `bare` → `PslExtensionBlockParamBare` — a bare identifier line with no
* `= value` (e.g. `Low` in an enum block). The name is the key in
* `parameters`; the interpreting consumer decides the default value.
*
* These shapes are intentionally minimal. The validator and lowering refine
* and consume them; the generic framework parser produces them.
*/
type PslExtensionBlockParamValue = PslExtensionBlockParamRef | PslExtensionBlockParamScalarValue | PslExtensionBlockParamOption | PslExtensionBlockParamList | PslExtensionBlockParamBare;
interface PslExtensionBlockParamRef {
readonly kind: 'ref';
readonly identifier: string;
readonly span: PslSpan;
}
interface PslExtensionBlockParamScalarValue {
readonly kind: 'value';
readonly raw: string;
readonly span: PslSpan;
}
interface PslExtensionBlockParamOption {
readonly kind: 'option';
readonly token: string;
readonly span: PslSpan;
}
interface PslExtensionBlockParamList {
readonly kind: 'list';
readonly items: readonly PslExtensionBlockParamValue[];
readonly span: PslSpan;
}
/**
* A bare identifier line inside an extension block — a key with no `= value`.
* Emitted when a line matches `/^[A-Za-z_]\w*$/` with no assignment. The
* consumer decides what default value (if any) to apply.
*/
interface PslExtensionBlockParamBare {
readonly kind: 'bare';
readonly span: PslSpan;
}
/**
* A positional argument on a block attribute, e.g. the `"pg/text@1"` in
* `@@type("pg/text@1")`.
*/
interface PslExtensionBlockAttributeArg {
readonly kind: 'positional';
readonly value: string;
readonly span: PslSpan;
}
/**
* A `@@`-prefixed block-level attribute parsed inside an extension block,
* e.g. `@@type("pg/text@1")`. Block attributes are captured generically
* — the parser does not validate attribute names or argument shapes; that
* is a concern of the block's interpreter.
*/
interface PslExtensionBlockAttribute {
readonly name: string;
readonly args: readonly PslExtensionBlockAttributeArg[];
readonly span: PslSpan;
}
/**
* Base shape for a uniform extension-contributed top-level PSL block
* node, as produced by the generic framework parser and consumed by the
* validator, printer, and lowering factory.
*
* - `kind` is the routing discriminant, equal to the descriptor's
* `discriminator`. The framework parser sets this to
* `descriptor.discriminator` for every block it parses. Several keywords
* may share one discriminator (e.g. `policy_select`/`policy_insert` both
* route to `kind: 'policy'`) — `kind` identifies the entity/storage kind,
* not the source syntax.
* - `keyword` is the source PSL keyword the block was declared with
* (`policy_select`, `policy_insert`, …) — the parse-dispatch identity.
* Distinct from `kind` precisely when a discriminator is shared by more
* than one keyword; a lowering factory that contributes several keywords
* under one discriminator reads `keyword` to tell its blocks apart, and
* the printer re-emits each block under its own `keyword` regardless of
* how many other keywords share its `kind`.
* - `name` is the block's declared name (the identifier after the keyword).
* - `parameters` is the descriptor-driven parameter map. Keys are
* parameter names from the descriptor; values are the parsed parameter
* representations. Only parameters present in the source are included
* — absence of a required parameter is a validator concern, not a
* parser concern. Insertion order is preserved; the first occurrence of a
* duplicate key is retained and subsequent occurrences emit
* `PSL_EXTENSION_DUPLICATE_PARAMETER`.
* - `blockAttributes` are `@@`-prefixed attribute lines inside the block, in
* declaration order. Captured generically — names and args are not validated
* by the parser.
* - `span` covers the full block from keyword to closing brace.
*/
interface PslExtensionBlock {
readonly kind: string;
/**
* The block's parse identity — the source PSL keyword it was declared
* with. `kind`/`discriminator` is its storage identity; several keywords
* can share one. E.g. the five `policy_*` keywords all lower to the
* `policy` entity kind.
*/
readonly keyword: string;
readonly name: string;
readonly parameters: Record<string, PslExtensionBlockParamValue>;
readonly blockAttributes: readonly PslExtensionBlockAttribute[];
readonly span: PslSpan;
}
//#endregion
//#region src/shared/framework-authoring.d.ts
type AuthoringArgRef = {
readonly kind: 'arg';
readonly index: number;
readonly path?: readonly string[];
readonly default?: AuthoringTemplateValue;
};
type AuthoringTemplateValue = string | number | boolean | null | AuthoringArgRef | readonly AuthoringTemplateValue[] | {
readonly [key: string]: AuthoringTemplateValue;
};
interface AuthoringArgumentDescriptorCommon {
readonly name?: string;
readonly optional?: boolean;
}
type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon & ({
readonly kind: 'string';
} | {
readonly kind: 'boolean';
} | {
readonly kind: 'number';
readonly integer?: boolean;
readonly minimum?: number;
readonly maximum?: number;
} | {
readonly kind: 'stringArray';
} | {
readonly kind: 'object';
readonly properties: Record<string, AuthoringArgumentDescriptor>;
});
interface AuthoringStorageTypeTemplate {
readonly codecId: string;
/**
* Optional so a type constructor whose {@link AuthoringTypeConstructorDescriptor.entityRefArg}
* names another entity can omit this template entirely — its output for
* that case is derived by the codec at `codecId`, not by resolving a
* literal here. Every other consumer of this shape (field presets, plain
* type constructors) always supplies it.
*/
readonly nativeType?: AuthoringTemplateValue;
readonly typeParams?: Record<string, AuthoringTemplateValue>;
}
/**
* Declares that one positional argument of a
* {@link AuthoringTypeConstructorDescriptor} call names another entity
* parsed from the same document, rather than carrying a literal value (e.g.
* `pg.enum(AalLevel)` naming a `native_enum` entity). `index` is the
* argument's position in the call; `entityKind` is the entries-slot
* discriminator the interpreter looks the named entity up under (the same
* shape {@link AuthoringEntityTypeFactoryOutput.factory} output is collected
* into, keyed by discriminator then block name).
*
* The interpreter resolves the named argument to the entity instance
* generically, driven only by this declaration — it has no target-specific
* knowledge of which type constructors carry one. Converting the resolved
* entity into the constructor's params is a separate, codec-owned concern:
* the codec descriptor registered for `output.codecId` supplies that
* conversion, not this framework type.
*/
interface AuthoringTypeConstructorEntityRef {
readonly index: number;
readonly entityKind: string;
}
interface AuthoringTypeConstructorDescriptor {
readonly kind: 'typeConstructor';
readonly args?: readonly AuthoringArgumentDescriptor[];
readonly output: AuthoringStorageTypeTemplate;
/** Present when one of this constructor's positional arguments names another document-local entity instead of carrying a literal value. Absent for ordinary literal-argument constructors. */
readonly entityRefArg?: AuthoringTypeConstructorEntityRef;
}
interface AuthoringColumnDefaultTemplateLiteral {
readonly kind: 'literal';
readonly value: AuthoringTemplateValue;
}
interface AuthoringColumnDefaultTemplateFunction {
readonly kind: 'function';
readonly expression: AuthoringTemplateValue;
}
type AuthoringColumnDefaultTemplate = AuthoringColumnDefaultTemplateLiteral | AuthoringColumnDefaultTemplateFunction;
interface AuthoringExecutionDefaultsTemplate {
readonly onCreate?: AuthoringTemplateValue;
readonly onUpdate?: AuthoringTemplateValue;
}
interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {
readonly nullable?: boolean;
readonly default?: AuthoringColumnDefaultTemplate;
readonly executionDefaults?: AuthoringExecutionDefaultsTemplate;
readonly id?: boolean;
readonly unique?: boolean;
}
interface AuthoringFieldPresetDescriptor {
readonly kind: 'fieldPreset';
readonly args?: readonly AuthoringArgumentDescriptor[];
readonly output: AuthoringFieldPresetOutput;
}
type AuthoringTypeNamespace = {
readonly [name: string]: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace;
};
type AuthoringFieldNamespace = {
readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;
};
/**
* Context surfaced to entity-type factories at call time. Currently a
* placeholder — sharpened as concrete consumers (enum, namespace, …)
* discover what the factory actually needs to read (codec lookup,
* namespace registry, …).
*/
/**
* A write-only sink that a factory may push authoring-time diagnostics into.
* The concrete type pushed must be structurally compatible with whatever the
* consumer accumulates (typically `ContractSourceDiagnostic[]`); the framework
* layer deliberately does not depend on that concrete type.
*/
interface AuthoringDiagnosticSink {
push(d: {
readonly code: string;
readonly message: string;
readonly sourceId: string;
readonly span?: unknown;
}): void;
}
interface AuthoringEntityContext {
readonly family: string;
readonly target: string;
/** Codec registry available to factories that need to validate or decode values. */
readonly codecLookup?: CodecLookup;
/** Source file identifier threaded into diagnostics emitted by the factory. */
readonly sourceId?: string;
/** Push channel for authoring-time diagnostics emitted by the factory. */
readonly diagnostics?: AuthoringDiagnosticSink;
/**
* The target's default codec ids for an `enum` block that omits `@@type`.
* `text` is used when every member is a bare name or a string value;
* `int` is used when every member is an integer value. Every target pack
* populates this so `@@type` omission can be inferred consistently.
*/
readonly enumInferenceCodecs?: {
readonly text: string;
readonly int: string;
};
}
/**
* Classifies an `enum` block's members (before codec decoding, which needs
* the codec chosen first) into which default codec an omitted `@@type`
* should resolve to:
*
* - every member is `bare`, or a `value` whose raw JSON is a string → `'text'`
* - every member is a `value` whose raw JSON is an integer → `'int'`
* - anything else (float, bigint, boolean, mixed, or a `ref`/`option`/`list`
* parameter) → `null`, meaning the caller must require an explicit `@@type`.
*/
declare function classifyEnumMemberType(block: PslExtensionBlock): 'text' | 'int' | null;
/**
* Resolves the codec id for an `enum` block. When `@@type` is absent, the codec
* is inferred from the members via {@link classifyEnumMemberType}; otherwise the
* explicit `@@type("codec")` argument is parsed. Pushes the appropriate
* diagnostic and returns `undefined` when neither yields a codec. `codecSpan` is
* the span downstream codec-validation diagnostics should anchor to. Shared by
* every family's enum factory so inference and the explicit path stay identical.
*/
declare function resolveEnumCodecId(block: PslExtensionBlock, ctx: AuthoringEntityContext): {
readonly codecId: string;
readonly codecSpan: PslSpan;
} | undefined;
interface AuthoringEntityTypeTemplateOutput {
readonly template: AuthoringTemplateValue;
}
/**
* Default `Input = never` is load-bearing for pack-bag-driven type
* narrowing. Factory parameter positions are contravariant, so a pack
* literal declaring `factory: (input: DemoEntityInput) => DemoEntity`
* is only assignable to the base descriptor's factory shape if the
* base's input is `never` (the bottom of the contravariant position).
* The concrete input/output types are recovered at the helper-derivation
* site via `EntityHelperFunction<Descriptor>`'s conditional inference,
* which reads them from the pack's `as const` literal factory signature
* — the base widening does not erase the literal because `satisfies`
* does not widen the declared type.
*/
interface AuthoringEntityTypeFactoryOutput<Input = never, Output = unknown> {
readonly factory: (input: Input, ctx: AuthoringEntityContext) => Output;
}
interface AuthoringEntityTypeDescriptor<Input = never, Output = unknown> {
readonly kind: 'entity';
readonly discriminator: string;
readonly args?: readonly AuthoringArgumentDescriptor[];
readonly output: AuthoringEntityTypeTemplateOutput | AuthoringEntityTypeFactoryOutput<Input, Output>;
/**
* arktype schema fragment for one entry whose envelope `kind` matches
* this descriptor's {@link discriminator}. The family validator composes
* contributed fragments into the per-namespace entry schema at
* validator construction time so the structural check covers
* pack-introduced kinds without the family core hard-coding the schema.
*
* Hydration uses {@link AuthoringEntityTypeFactoryOutput.factory}
* directly — the wire shape conforms structurally to the factory's
* `Input` after `validatorSchema` validates it.
*/
readonly validatorSchema?: Type<unknown>;
}
type AuthoringEntityTypeNamespace = {
readonly [name: string]: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace;
};
/**
* Declarative descriptor for an extension-contributed top-level PSL block.
*
* An extension registers one of these per keyword it contributes. The
* framework owns the generic parser, validator, and printer — no
* parsing or printing code runs from the extension.
*
* - `keyword` is the PSL top-level identifier this descriptor claims
* (`policy_select`, `role`, …).
* - `discriminator` is the routing key used by the printer dispatch and
* the `entityTypes` lowering factory lookup. Convention:
* `<target-or-family>-<kind>` (`postgres-policy-select`).
* - `name.required` declares whether the block must have a name token
* after the keyword. Currently always `true` — anonymous blocks are
* not part of the closed-grammar premise — but the field is explicit
* so the type can evolve without a breaking change.
* - `parameters` maps parameter names to their value-kind descriptors
* (`ref` / `value` / `option` / `list`). The generic parser and
* validator interpret these; the extension supplies no parser or
* printer function.
*/
interface AuthoringPslBlockDescriptor {
readonly kind: 'pslBlock';
readonly keyword: string;
readonly discriminator: string;
readonly name: {
readonly required: boolean;
};
readonly parameters: Record<string, PslBlockParam>;
/**
* When `true`, the block body accepts a variadic tail of parameters beyond
* the declared set. The block body may contain: fields (model-style),
* `key = value` parameters, and `@@` attributes. With `variadicParameters`,
* bare identifiers (keys without a `= value`) and undeclared `key = value`
* pairs flow into the variadic tail — their semantics belong to the
* lowering, not the parser.
*
* A key that IS declared in `parameters` must still be supplied as
* `key = value`; a bare occurrence of a declared key is a diagnostic.
*
* When `false` (default), the validator emits `PSL_EXTENSION_UNKNOWN_PARAMETER`
* for keys absent from `parameters`.
*/
readonly variadicParameters?: boolean;
/**
* Declares that the model named by the block's ref parameter `parameter`
* must carry the bare `@@` model attribute `attribute`. The family
* interpreter enforces this generically over the whole parsed document —
* declaration order of the block and the model does not matter — and
* emits `PSL_EXTENSION_TARGET_MODEL_MISSING_ATTRIBUTE` naming the block
* and the model when the attribute is absent. A parameter that is
* missing or does not resolve to a model is not this rule's concern
* (missing-parameter and unresolved-ref diagnostics own those cases).
*/
readonly requiresModelAttribute?: {
readonly parameter: string;
readonly attribute: string;
};
}
type AuthoringPslBlockDescriptorNamespace = {
readonly [name: string]: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace;
};
/**
* Context surfaced to a model-attribute lowering at call time: the entity
* context shared with entity-type factories, plus the declaring model's
* name, its mapped storage name (the name of the storage object the model
* maps to; which kind of object that is belongs to the family, not the
* framework), and the namespace id the lowered entity should be filed
* under.
*/
interface AuthoringModelAttributeContext extends AuthoringEntityContext {
readonly modelName: string;
readonly storageName: string;
readonly namespaceId: string;
}
/**
* What a model-attribute lowering returns when it produces an entity: `key`
* is the identity the entity is stored under within its `entries` slot
* (`entries[attribute][key]`); `entity` is the value stored there. A
* lowering that instead pushed a diagnostic through
* {@link AuthoringModelAttributeContext.diagnostics} returns `undefined` —
* the same convention {@link AuthoringEntityTypeFactoryOutput} uses.
*/
interface AuthoringModelAttributeLoweringOutput {
readonly key: string;
readonly entity: unknown;
}
/**
* Declarative descriptor for an extension-contributed `@@` model attribute.
*
* An extension registers one of these per bare attribute name it
* contributes. The framework owns the generic consult in the interpreter's
* model-attribute loop; the contribution supplies only `spec` and `lower`.
*
* - `attribute` is the bare `@@` attribute name this descriptor claims and,
* by the one-string rule, the `entries` slot its lowered entities are
* grouped under (`entries[attribute][key]`).
* - `spec` is opaque to the framework core: an ADR-231 attribute-spec kit
* `AttributeSpec<Out>` value (`modelAttribute(name, {...})` from
* `@prisma-next/psl-parser`). Framework core does not depend on
* psl-parser and never inspects this field; the family interpreter,
* which does depend on psl-parser, parses the attribute's arguments
* against it.
* - `lower` receives the parsed arguments and the declaring model's
* context, and returns the entity to file into `entries`, or `undefined`
* after pushing a diagnostic via `ctx.diagnostics`.
*
* `Out` defaults to `never` — not `unknown` — for the same contravariance
* reason documented on {@link AuthoringEntityTypeFactoryOutput}: a concrete
* pack literal's narrower `lower(parsed: ConcreteOut, ctx)` is only
* assignable to this base shape when the base parameter is the bottom type.
*/
interface AuthoringModelAttributeDescriptor<Out = never> {
readonly kind: 'modelAttribute';
readonly attribute: string;
readonly spec: unknown;
readonly lower: (parsed: Out, ctx: AuthoringModelAttributeContext) => AuthoringModelAttributeLoweringOutput | undefined;
}
type AuthoringModelAttributeDescriptorNamespace = {
readonly [name: string]: AuthoringModelAttributeDescriptor | AuthoringModelAttributeDescriptorNamespace;
};
interface AuthoringContributions {
readonly type?: AuthoringTypeNamespace;
readonly field?: AuthoringFieldNamespace;
readonly entityTypes?: AuthoringEntityTypeNamespace;
/**
* Registry of declarative block descriptors this contribution registers,
* keyed by arbitrary path segments. Each leaf is an
* {@link AuthoringPslBlockDescriptor} that claims a PSL top-level keyword.
* The framework owns the generic parser, validator, and printer; the
* contribution supplies only these declarative descriptors.
*
* Contrast with the parsed block nodes themselves, which live in a
* namespace's `entries` under their discriminator key; this field holds the
* registry of descriptors that teach the parser how to read those blocks.
*/
readonly pslBlockDescriptors?: AuthoringPslBlockDescriptorNamespace;
/**
* Registry of declarative `@@` model attribute descriptors this
* contribution registers, keyed by arbitrary path segments. Each leaf is
* an {@link AuthoringModelAttributeDescriptor} that claims a bare model
* attribute name. The framework owns the generic consult in the family
* interpreter's model-attribute loop; the contribution supplies only the
* declarative spec and the lowering.
*/
readonly modelAttributes?: AuthoringModelAttributeDescriptorNamespace;
}
declare function isAuthoringArgRef(value: unknown): value is AuthoringArgRef;
declare function isAuthoringTypeConstructorDescriptor(value: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace): value is AuthoringTypeConstructorDescriptor;
declare function isAuthoringFieldPresetDescriptor(value: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace): value is AuthoringFieldPresetDescriptor;
declare function isAuthoringEntityTypeDescriptor(value: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace): value is AuthoringEntityTypeDescriptor;
declare function isAuthoringPslBlockDescriptor(value: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace): value is AuthoringPslBlockDescriptor;
declare function isAuthoringModelAttributeDescriptor(value: AuthoringModelAttributeDescriptor | AuthoringModelAttributeDescriptorNamespace): value is AuthoringModelAttributeDescriptor;
/**
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
*
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
* registration must NOT be treated as a "namespace" with sub-paths. Callers
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
*/
declare function hasRegisteredFieldNamespace(contributions: AuthoringContributions | undefined, namespace: string): boolean;
/**
* Merges `source` into `target` recursively at the descriptor-namespace
* level. `descriptorKind` is the `kind` value ('typeConstructor',
* 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
* (terminal merge point; same-path registrations across components are
* reported as duplicates) as opposed to a sub-namespace (recursion target).
*
* Path segments are validated against prototype-pollution names
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
* recognized leaf nor a plain object — e.g. a malformed descriptor
* where the canonical leaf guard rejected it for missing `output` —
* is reported as an invalid contribution rather than recursed into,
* which would either silently mangle state or infinite-loop on
* primitive properties.
*
* Within-registry duplicate detection is this walker's job;
* cross-registry detection runs separately via
* `assertNoCrossRegistryCollisions` after merging completes.
*/
declare function mergeAuthoringNamespaces(target: Record<string, unknown>, source: Record<string, unknown>, path: readonly string[], descriptorKind: string, label: string): void;
declare function assertNoCrossRegistryCollisions(typeNamespace: AuthoringTypeNamespace, fieldNamespace: AuthoringFieldNamespace, entityTypeNamespace?: AuthoringEntityTypeNamespace, pslBlockNamespace?: AuthoringPslBlockDescriptorNamespace, modelAttributeNamespace?: AuthoringModelAttributeDescriptorNamespace): void;
declare function resolveAuthoringTemplateValue(template: AuthoringTemplateValue | undefined, args: readonly unknown[]): unknown;
declare function validateAuthoringHelperArguments(helperPath: string, descriptors: readonly AuthoringArgumentDescriptor[] | undefined, args: readonly unknown[]): void;
declare function instantiateAuthoringTypeConstructor(descriptor: AuthoringTypeConstructorDescriptor, args: readonly unknown[]): {
readonly codecId: string;
readonly nativeType: string;
readonly typeParams?: Record<string, unknown>;
};
declare function instantiateAuthoringEntityType<TOutput = unknown>(helperPath: string, descriptor: AuthoringEntityTypeDescriptor, args: readonly unknown[], ctx: AuthoringEntityContext): TOutput;
declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPresetDescriptor, args: readonly unknown[]): {
readonly descriptor: {
readonly codecId: string;
readonly nativeType: string;
readonly typeParams?: Record<string, unknown>;
};
readonly nullable: boolean;
readonly default?: ColumnDefault;
readonly executionDefaults?: ExecutionMutationDefaultPhases;
readonly id: boolean;
readonly unique: boolean;
};
//#endregion
export { PslExtensionBlockParamRef as $, instantiateAuthoringTypeConstructor as A, validateAuthoringHelperArguments as B, AuthoringTypeConstructorEntityRef as C, hasRegisteredFieldNamespace as D, classifyEnumMemberType as E, isAuthoringPslBlockDescriptor as F, PslBlockParamValue as G, PslBlockParamList as H, isAuthoringTypeConstructorDescriptor as I, PslExtensionBlockAttribute as J, PslDiagnosticCode as K, mergeAuthoringNamespaces as L, isAuthoringEntityTypeDescriptor as M, isAuthoringFieldPresetDescriptor as N, instantiateAuthoringEntityType as O, isAuthoringModelAttributeDescriptor as P, PslExtensionBlockParamOption as Q, resolveAuthoringTemplateValue as R, AuthoringTypeConstructorDescriptor as S, assertNoCrossRegistryCollisions as T, PslBlockParamOption as U, PslBlockParam as V, PslBlockParamRef as W, PslExtensionBlockParamBare as X, PslExtensionBlockAttributeArg as Y, PslExtensionBlockParamList as Z, AuthoringModelAttributeLoweringOutput as _, AuthoringDiagnosticSink as a, AuthoringStorageTypeTemplate as b, AuthoringEntityTypeFactoryOutput as c, AuthoringFieldNamespace as d, PslExtensionBlockParamScalarValue as et, AuthoringFieldPresetDescriptor as f, AuthoringModelAttributeDescriptorNamespace as g, AuthoringModelAttributeDescriptor as h, AuthoringContributions as i, isAuthoringArgRef as j, instantiateAuthoringFieldPreset as k, AuthoringEntityTypeNamespace as l, AuthoringModelAttributeContext as m, AuthoringArgumentDescriptor as n, PslPosition as nt, AuthoringEntityContext as o, AuthoringFieldPresetOutput as p, PslExtensionBlock as q, AuthoringColumnDefaultTemplate as r, PslSpan as rt, AuthoringEntityTypeDescriptor as s, AuthoringArgRef as t, PslExtensionBlockParamValue as tt, AuthoringEntityTypeTemplateOutput as u, AuthoringPslBlockDescriptor as v, AuthoringTypeNamespace as w, AuthoringTemplateValue as x, AuthoringPslBlockDescriptorNamespace as y, resolveEnumCodecId as z };
//# sourceMappingURL=framework-authoring-CEbpeygb.d.mts.map
{"version":3,"file":"framework-authoring-CEbpeygb.d.mts","names":[],"sources":["../src/shared/psl-extension-block.ts","../src/shared/framework-authoring.ts"],"mappings":";;;;;;;;;;AAYA;;;;;;UAAiB,WAAA;EAAA,SACN,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,OAAA;EAAA,SACN,KAAA,EAAO,WAAA;EAAA,SACP,GAAA,EAAK,WAAW;AAAA;AAAA,KAGf,iBAAA;;;AAHe;AAG3B;;;;AAA6B;AA0G7B;;;;;;;;;;;;;;AAIqB;AAErB;;;;;;;;;;AAOA;;;;;;AAAA;;AAGmB;AAGnB;;;;;;;;AAGmB;AAGnB;;;;;;;;;AAGmB;AAqBnB;;;AArBmB;;;;;;;;;;;;;AA0BW;;;;;;;;;;AAKN;AAGxB;;;KA9DY,aAAA,GACR,gBAAA,GACA,kBAAA,GACA,mBAAA,GACA,iBAAA;AAAA,UAEa,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA;EAAA,SACA,QAAA;AAAA;AAAA,UAGM,kBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA;AAAA,UAGM,mBAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA;EAAA,SACA,QAAA;AAAA;AAAA,UAGM,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA,EAAI,aAAa;EAAA,SACjB,QAAA;AAAA;;;;;;AAiDa;AAQxB;;;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GAAoB,8BAAA;EAAA,SACpB,EAAA;EAAA,SACA,MAAA;AAAA"}
import { f as AnyCodecDescriptor } from "./codec-types-BH2f2dg1.mjs";
import { i as AuthoringContributions } from "./framework-authoring-CEbpeygb.mjs";
import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
import { ColumnDefault, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
//#region src/shared/mutation-default-types.d.ts
interface SourcePosition {
readonly offset: number;
readonly line: number;
readonly column: number;
}
interface SourceSpan {
readonly start: SourcePosition;
readonly end: SourcePosition;
}
interface SourceDiagnostic {
readonly code: string;
readonly message: string;
readonly sourceId?: string;
readonly span?: SourceSpan;
readonly data?: Readonly<Record<string, unknown>>;
}
interface DefaultFunctionLoweringContext {
readonly sourceId: string;
readonly modelName: string;
readonly fieldName: string;
readonly columnCodecId?: string;
}
type LoweredDefaultValue = {
readonly kind: 'storage';
readonly defaultValue: ColumnDefault;
} | {
readonly kind: 'execution';
readonly generated: ExecutionMutationDefaultValue;
};
type LoweredDefaultResult = {
readonly ok: true;
readonly value: LoweredDefaultValue;
} | {
readonly ok: false;
readonly diagnostic: SourceDiagnostic;
};
interface MutationDefaultGeneratorDescriptor {
readonly id: string;
/**
* Codec ids the generator is compatible with when the codec choice
* and the generator choice are made independently by the contract
* author. Set when the registry-coherence check is meaningful
* (the codec and the generator can be paired arbitrarily by the
* caller); omitted when the generator is only reachable through a
* descriptor that co-registers a fixed codec, so coherence is
* structural and the list would be tautological.
*/
readonly applicableCodecIds?: readonly string[];
readonly resolveGeneratedColumnDescriptor?: (input: {
readonly generated: ExecutionMutationDefaultValue;
}) => {
readonly codecId: string;
readonly nativeType: string;
readonly typeRef?: string;
readonly typeParams?: Record<string, unknown>;
} | undefined;
/**
* Construct the `onCreate`/`onUpdate` phases value owned by this
* generator. Authoring layers (PSL `temporal.updatedAt()`, TS field presets) call
* this instead of building the literal inline so PSL/TS-authored
* contracts stay byte-equivalent for any future params-bearing generator.
*/
readonly buildPhases?: (args?: Record<string, unknown>) => ExecutionMutationDefaultPhases;
}
interface TypedDefaultFunctionCall {
readonly fn: string;
readonly span: SourceSpan;
readonly args: Readonly<Record<string, unknown>>;
}
interface ControlMutationDefaultEntry {
readonly signature?: unknown;
readonly lower: (input: {
readonly call: TypedDefaultFunctionCall;
readonly context: DefaultFunctionLoweringContext;
}) => LoweredDefaultResult;
readonly usageSignatures?: readonly string[];
}
type ControlMutationDefaultRegistry = ReadonlyMap<string, ControlMutationDefaultEntry>;
interface ControlMutationDefaults {
readonly defaultFunctionRegistry: ControlMutationDefaultRegistry;
readonly generatorDescriptors: readonly MutationDefaultGeneratorDescriptor[];
}
//#endregion
//#region src/shared/framework-components.d.ts
/**
* Declarative fields that describe component metadata.
*/
interface ComponentMetadata {
/** Component version (semver) */
readonly version: string;
/**
* Capabilities this component provides.
*
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`); keep these declarations in sync. Targets are identifiers/descriptors and typically do not declare capabilities.
*/
readonly capabilities?: Record<string, unknown>;
/** Type imports for contract.d.ts generation */
readonly types?: {
readonly codecTypes?: {
/**
* Base codec types import spec. Optional: adapters typically provide this, extensions usually don't.
*/
readonly import?: TypesImportSpec;
/**
* Additional type-only imports for parameterized codec branded types.
*
* These imports are included in generated `contract.d.ts` but are NOT treated as codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
*
* Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`
*/
readonly typeImports?: ReadonlyArray<TypesImportSpec>;
/**
* Optional control-plane hooks keyed by codecId. Used by family-specific planners/verifiers to handle storage types.
*/
readonly controlPlaneHooks?: Record<string, unknown>;
/**
* Codec descriptors contributed by this component. Source of truth for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`, `renderOutputType`) consumed by `extractCodecLookup`, and used to materialize representative `Codec` instances for codec-dispatched type rendering during emission.
*/
readonly codecDescriptors?: ReadonlyArray<AnyCodecDescriptor>;
};
readonly queryOperationTypes?: {
readonly import: TypesImportSpec;
};
readonly storage?: ReadonlyArray<{
readonly typeId: string;
readonly familyId: string;
readonly targetId: string;
readonly nativeType?: string;
}>;
};
/**
* Optional pure-data authoring contributions exposed by this component.
*
* These contributions are safe to include on pack refs and descriptors because they contain only declarative metadata. Higher-level authoring packages may project them into concrete helper functions for TS-first workflows.
*/
readonly authoring?: AuthoringContributions;
/**
* Scalar type name to codec ID mapping contributed by this component. Assembled by `createControlStack` with duplicate detection.
*/
readonly scalarTypeDescriptors?: ReadonlyMap<string, string>;
/**
* Mutation default function handlers and generator descriptors contributed by this component. Assembled by `createControlStack` with duplicate detection.
*/
readonly controlMutationDefaults?: ControlMutationDefaults;
}
/**
* Base descriptor for any framework component.
*
* All component descriptors share these fundamental properties that identify the component and provide its metadata. This interface is extended by specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
*
* @template Kind - Discriminator literal identifying the component type. Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension', but the type accepts any string to allow ecosystem extensions.
*
* @example
* ```ts
* // All descriptors have these properties
* descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)
* descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')
* descriptor.version // Component version (semver)
* ```
*/
interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {
/** Discriminator identifying the component type */
readonly kind: Kind;
/** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */
readonly id: string;
}
interface ContractComponentRequirementsCheckInput {
readonly contract: {
readonly target: string;
readonly targetFamily?: string | undefined;
readonly extensionPacks?: Record<string, unknown> | undefined;
};
readonly expectedTargetFamily?: string | undefined;
readonly expectedTargetId?: string | undefined;
readonly providedComponentIds: Iterable<string>;
}
interface ContractComponentRequirementsCheckResult {
readonly familyMismatch?: {
readonly expected: string;
readonly actual: string;
} | undefined;
readonly targetMismatch?: {
readonly expected: string;
readonly actual: string;
} | undefined;
readonly missingExtensionPackIds: readonly string[];
}
declare function checkContractComponentRequirements(input: ContractComponentRequirementsCheckInput): ContractComponentRequirementsCheckResult;
/**
* Descriptor for a family component.
*
* A "family" represents a category of data sources with shared semantics (e.g., SQL databases, document stores). Families define:
* - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
* - Contract structure (tables vs collections, columns vs fields)
* - Type system and codecs
*
* Families are the top-level grouping. Each family contains multiple targets (e.g., SQL family contains Postgres, MySQL, SQLite targets).
*
* Extended by plane-specific descriptors:
* - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations
* - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods
*
* @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')
*
* @example
* ```ts
* import sql from '@prisma-next/family-sql/control';
*
* sql.kind // 'family'
* sql.familyId // 'sql'
* sql.id // 'sql'
* ```
*/
interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {
/** The family identifier (e.g., 'sql', 'document') */
readonly familyId: TFamilyId;
}
/**
* Descriptor for a target component.
*
* A "target" represents a specific database or data store within a family (e.g., Postgres, MySQL, MongoDB). Targets define:
* - Native type mappings (e.g., Postgres int4 → TypeScript number)
* - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
*
* Targets are bound to a family and provide the target-specific implementation details that adapters and drivers use.
*
* Extended by plane-specific descriptors:
* - `ControlTargetDescriptor` - adds optional `migrations` capability
* - `RuntimeTargetDescriptor` - adds runtime factory method
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')
*
* @example
* ```ts
* import postgres from '@prisma-next/target-postgres/control';
*
* postgres.kind // 'target'
* postgres.familyId // 'sql'
* postgres.targetId // 'postgres'
* ```
*/
interface TargetDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'target'> {
/** The family this target belongs to */
readonly familyId: TFamilyId;
/** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */
readonly targetId: TTargetId;
}
/**
* Base shape for any pack reference. Pack refs are pure JSON-friendly objects safe to import in authoring flows.
*/
interface PackRefBase<Kind extends string, TFamilyId extends string> extends ComponentMetadata {
readonly kind: Kind;
readonly id: string;
readonly familyId: TFamilyId;
readonly targetId?: string;
readonly authoring?: AuthoringContributions;
}
type FamilyPackRef<TFamilyId extends string = string> = PackRefBase<'family', TFamilyId>;
type TargetPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'target', TFamilyId> & {
readonly targetId: TTargetId; /** The namespace a bare (un-namespaced) entity name resolves to for this target (e.g. Postgres `'public'`). */
readonly defaultNamespaceId: string;
};
type AdapterPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'adapter', TFamilyId> & {
readonly targetId: TTargetId;
};
type ExtensionPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'extension', TFamilyId> & {
readonly targetId: TTargetId;
};
type DriverPackRef<TFamilyId extends string = string, TTargetId extends string = string> = PackRefBase<'driver', TFamilyId> & {
readonly targetId: TTargetId;
};
/**
* Descriptor for an adapter component.
*
* An "adapter" provides the protocol and dialect implementation for a target. Adapters handle:
* - SQL/query generation (lowering AST to target-specific syntax)
* - Codec registration (encoding/decoding between JS and wire types)
* - Type mappings and coercions
*
* Adapters are bound to a specific family+target combination and work with any compatible driver for that target.
*
* Extended by plane-specific descriptors:
* - `ControlAdapterDescriptor` - control-plane factory
* - `RuntimeAdapterDescriptor` - runtime factory
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier
*
* @example
* ```ts
* import postgresAdapter from '@prisma-next/adapter-postgres/control';
*
* postgresAdapter.kind // 'adapter'
* postgresAdapter.familyId // 'sql'
* postgresAdapter.targetId // 'postgres'
* ```
*/
interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'adapter'> {
/** The family this adapter belongs to */
readonly familyId: TFamilyId;
/** The target this adapter is designed for */
readonly targetId: TTargetId;
}
/**
* Descriptor for a driver component.
*
* A "driver" provides the connection and execution layer for a target. Drivers handle:
* - Connection management (pooling, timeouts, retries)
* - Query execution (sending SQL/commands, receiving results)
* - Transaction management
* - Wire protocol communication
*
* Drivers are bound to a specific family+target and work with any compatible adapter. Multiple drivers can exist for the same target (e.g., node-postgres vs postgres.js for Postgres).
*
* Extended by plane-specific descriptors:
* - `ControlDriverDescriptor` - creates driver from connection URL
* - `RuntimeDriverDescriptor` - creates driver with runtime options
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier
*
* @example
* ```ts
* import postgresDriver from '@prisma-next/driver-postgres/control';
*
* postgresDriver.kind // 'driver'
* postgresDriver.familyId // 'sql'
* postgresDriver.targetId // 'postgres'
* ```
*/
interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'driver'> {
/** The family this driver belongs to */
readonly familyId: TFamilyId;
/** The target this driver connects to */
readonly targetId: TTargetId;
}
/**
* Descriptor for an extension component.
*
* An "extension" adds optional capabilities to a target. Extensions can provide:
* - Additional operations (e.g., vector similarity search with pgvector)
* - Custom types and codecs (e.g., vector type)
* - Extended query capabilities
*
* Extensions are bound to a specific family+target and are registered in the config alongside the core components. Multiple extensions can be used together.
*
* Extended by plane-specific descriptors:
* - `ControlExtensionDescriptor` - control-plane extension factory
* - `RuntimeExtensionDescriptor` - runtime extension factory
*
* @template TFamilyId - Literal type for the family identifier
* @template TTargetId - Literal type for the target identifier
*
* @example
* ```ts
* import pgvector from '@prisma-next/extension-pgvector/control';
*
* pgvector.kind // 'extension'
* pgvector.familyId // 'sql'
* pgvector.targetId // 'postgres'
* ```
*/
interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string> extends ComponentDescriptor<'extension'> {
/** The family this extension belongs to */
readonly familyId: TFamilyId;
/** The target this extension is designed for */
readonly targetId: TTargetId;
}
/** Components bound to a specific family+target combination. */
type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> = TargetDescriptor<TFamilyId, TTargetId> | AdapterDescriptor<TFamilyId, TTargetId> | DriverDescriptor<TFamilyId, TTargetId> | ExtensionDescriptor<TFamilyId, TTargetId>;
interface FamilyInstance<TFamilyId extends string> {
readonly familyId: TFamilyId;
}
interface TargetInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
interface DriverInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {
readonly familyId: TFamilyId;
readonly targetId: TTargetId;
}
//#endregion
export { SourceDiagnostic as A, ControlMutationDefaultEntry as C, LoweredDefaultResult as D, DefaultFunctionLoweringContext as E, TypedDefaultFunctionCall as M, LoweredDefaultValue as O, checkContractComponentRequirements as S, ControlMutationDefaults as T, PackRefBase as _, ComponentMetadata as a, TargetInstance as b, DriverDescriptor as c, ExtensionDescriptor as d, ExtensionInstance as f, FamilyPackRef as g, FamilyInstance as h, ComponentDescriptor as i, SourceSpan as j, MutationDefaultGeneratorDescriptor as k, DriverInstance as l, FamilyDescriptor as m, AdapterInstance as n, ContractComponentRequirementsCheckInput as o, ExtensionPackRef as p, AdapterPackRef as r, ContractComponentRequirementsCheckResult as s, AdapterDescriptor as t, DriverPackRef as u, TargetBoundComponentDescriptor as v, ControlMutationDefaultRegistry as w, TargetPackRef as x, TargetDescriptor as y };
//# sourceMappingURL=framework-components-Co9FzZij.d.mts.map
{"version":3,"file":"framework-components-Co9FzZij.d.mts","names":[],"sources":["../src/shared/mutation-default-types.ts","../src/shared/framework-components.ts"],"mappings":";;;;;;UAMU,cAAA;EAAA,SACC,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,UAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,GAAA,EAAK,cAAc;AAAA;AAAA,UAGb,gBAAA;EAAA,SACN,I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;;;UA0IiB,mBAAA,6DACP,mBAAA;EArIa;EAAA,SAuIZ,QAAA,EAAU,SAAA;EA5IM;EAAA,SA+IhB,QAAA,EAAU,SAAA;AAAA;;KAIT,8BAAA,uDACR,gBAAA,CAAiB,SAAA,EAAW,SAAA,IAC5B,iBAAA,CAAkB,SAAA,EAAW,SAAA,IAC7B,gBAAA,CAAiB,SAAA,EAAW,SAAA,IAC5B,mBAAA,CAAoB,SAAA,EAAW,SAAA;AAAA,UAElB,cAAA;EAAA,SACN,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,eAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA;AAAA,UAGb,iBAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAS;AAAA"}
import { r as CodecLookup } from "./codec-types-BH2f2dg1.mjs";
import { K as PslDiagnosticCode, q as PslExtensionBlock, rt as PslSpan, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-CEbpeygb.mjs";
//#region src/control/psl-ast.d.ts
interface PslDiagnostic {
readonly code: PslDiagnosticCode;
readonly message: string;
readonly sourceId: string;
readonly span: PslSpan;
}
interface PslDefaultFunctionValue {
readonly kind: 'function';
readonly name: 'autoincrement' | 'now';
}
interface PslDefaultLiteralValue {
readonly kind: 'literal';
readonly value: string | number | boolean;
}
type PslDefaultValue = PslDefaultFunctionValue | PslDefaultLiteralValue;
type PslAttributeTarget = 'field' | 'model' | 'enum' | 'namedType';
interface PslAttributePositionalArgument {
readonly kind: 'positional';
readonly value: string;
readonly span: PslSpan;
}
interface PslAttributeNamedArgument {
readonly kind: 'named';
readonly name: string;
readonly value: string;
readonly span: PslSpan;
}
type PslAttributeArgument = PslAttributePositionalArgument | PslAttributeNamedArgument;
interface PslTypeConstructorCall {
readonly kind: 'typeConstructor';
readonly path: readonly string[];
readonly args: readonly PslAttributeArgument[];
readonly span: PslSpan;
}
interface PslAttribute {
readonly kind: 'attribute';
readonly target: PslAttributeTarget;
readonly name: string;
readonly args: readonly PslAttributeArgument[];
readonly span: PslSpan;
}
type PslReferentialAction = string;
type PslFieldAttribute = PslAttribute;
interface PslField {
readonly kind: 'field';
readonly name: string;
/** Unqualified type name, e.g. `"User"` for both `User`, `auth.User`, and `supabase:auth.User`. */
readonly typeName: string;
/** Namespace qualifier from a dot-qualified type reference, e.g. `"auth"` for `auth.User` or `supabase:auth.User`. Absent for unqualified types. */
readonly typeNamespaceId?: string;
/**
* Contract-space qualifier from a colon-prefix type reference, e.g. `"supabase"` for
* `supabase:auth.User` or `supabase:User`. Absent for local (same-space) type references.
*
* When present, the field references a model from a different contract space. The namespace
* (`typeNamespaceId`) and model name (`typeName`) identify the target within that space.
* Physical table resolution against the extension contract is deferred to the aggregate stage (M3).
*/
readonly typeContractSpaceId?: string;
readonly typeConstructor?: PslTypeConstructorCall;
readonly optional: boolean;
readonly list: boolean;
readonly typeRef?: string;
readonly attributes: readonly PslFieldAttribute[];
readonly span: PslSpan;
}
interface PslUniqueConstraint {
readonly kind: 'unique';
readonly fields: readonly string[];
readonly span: PslSpan;
}
interface PslIndexConstraint {
readonly kind: 'index';
readonly fields: readonly string[];
readonly span: PslSpan;
}
type PslModelAttribute = PslAttribute;
interface PslModel {
readonly kind: 'model';
readonly name: string;
readonly fields: readonly PslField[];
readonly attributes: readonly PslModelAttribute[];
readonly span: PslSpan;
/**
* Optional leading comment line emitted above the `model` keyword by the
* printer. Producers (e.g. `sqlSchemaIrToPslAst`) attach introspection
* advisories such as "// WARNING: This table has no primary key in the
* database" here. The parser leaves this field unset; round-tripping a
* parsed schema does not re-attach comments.
*/
readonly comment?: string;
}
/**
* A reusable group of fields embedded in a model (a `type Name { … }` block) —
* e.g. a MongoDB embedded document or a Postgres composite type. Unlike
* {@link PslModel} it has no storage or identity of its own.
*/
interface PslCompositeType {
readonly kind: 'compositeType';
readonly name: string;
readonly fields: readonly PslField[];
readonly attributes: readonly PslAttribute[];
readonly span: PslSpan;
}
interface PslNamedTypeDeclaration {
readonly kind: 'namedType';
readonly name: string;
/**
* Parser invariant: exactly one of `baseType` and `typeConstructor` is set.
* Expressing this as a discriminated union trips TypeScript narrowing when
* the declaration flows through helpers that accept the full union.
*/
readonly baseType?: string;
readonly typeConstructor?: PslTypeConstructorCall;
readonly attributes: readonly PslAttribute[];
readonly span: PslSpan;
}
interface PslTypesBlock {
readonly kind: 'types';
readonly declarations: readonly PslNamedTypeDeclaration[];
readonly span: PslSpan;
}
/**
* Name of the synthesised namespace bucket the framework parser uses for
* top-level declarations that appear outside any `namespace { … }` block.
* The double-underscore decoration signals that the identifier is parser-
* synthesised and never appears in user-authored PSL source — writing
* `namespace __unspecified__ { … }` is a parse error.
*
* Distinct from the IR sentinel `__unbound__`: the PSL bucket describes
* syntactic absence at the parser layer; the IR sentinel describes a late-
* bound storage slot at the IR layer. Per-target interpreters decide how
* (or whether) to map the PSL bucket to the IR sentinel.
*/
declare const UNSPECIFIED_PSL_NAMESPACE_ID = "__unspecified__";
/** A value in {@link PslNamespace.entries}: a built-in entity node or an extension-contributed {@link PslExtensionBlock}. */
type PslNamespaceEntry = PslModel | PslCompositeType | PslExtensionBlock;
/**
* A namespace block, or the parser's synthesised `__unspecified__` bucket for
* declarations outside any `namespace { … }`. Same-name blocks reopen-merge;
* `span` points at the first opening.
*
* Entities are stored canonically (ADR 224) in `entries[kind][name]`, where
* `kind` is the PSL keyword for built-ins or the block discriminator for
* extension kinds, e.g. `entries['policy']['ReadPosts']` (the discriminator,
* not the PSL keyword — a `policy_select` block lands under `'policy'` per
* ADR 225).
*/
interface PslNamespace {
readonly kind: 'namespace';
readonly name: string;
/** Canonical store: a frozen container of frozen per-kind maps. The accessors below derive from it. */
readonly entries: Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
/** Built-in models, from `entries['model']`. Extension kinds: {@link namespacePslExtensionBlocks}. */
readonly models: readonly PslModel[];
/** Built-in composite types, from `entries['compositeType']`. */
readonly compositeTypes: readonly PslCompositeType[];
readonly span: PslSpan;
}
/** Constructs a {@link PslNamespace}. Use this, never a namespace literal — the accessors must derive from `entries`. */
declare function makePslNamespace(init: {
readonly kind: 'namespace';
readonly name: string;
readonly entries: Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
readonly span: PslSpan;
}): PslNamespace;
/**
* Builds the frozen `entries[kind][name]` container from per-kind arrays.
* Built-ins key on their PSL keyword; extension blocks key on their `kind`
* discriminator. Call this rather than hand-building the literal.
*/
declare function makePslNamespaceEntries(models: readonly PslModel[], compositeTypes: readonly PslCompositeType[], extensionBlocks: readonly PslExtensionBlock[]): Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
interface PslDocumentAst {
readonly kind: 'document';
readonly sourceId: string;
readonly namespaces: readonly PslNamespace[];
readonly types?: PslTypesBlock;
readonly span: PslSpan;
}
/**
* Returns all models from every namespace in document order. Convenience
* for consumers that don't (yet) need namespace-awareness.
*/
declare function flatPslModels(ast: PslDocumentAst): readonly PslModel[];
/**
* Returns all composite types from every namespace in document order.
*/
declare function flatPslCompositeTypes(ast: PslDocumentAst): readonly PslCompositeType[];
/**
* The set of `entries` kind keys that the framework parser reserves for
* built-in PSL entity kinds. Any own-enumerable key on `PslNamespace.entries`
* that is **not** in this set was contributed by an extension-block descriptor.
*
* Built-in keys match the PSL keyword used on each block type:
* `'model'`, `'compositeType'`. The `'enum'` keyword is claimed by the
* extension-block grammar via a registered descriptor, so `entries['enum']`
* holds `PslExtensionBlock` nodes and is returned by `namespacePslExtensionBlocks`.
*/
declare const BUILTIN_PSL_KIND_KEYS: ReadonlySet<string>;
/**
* Returns all extension-contributed blocks in the given namespace, in
* insertion order (the order the parser encountered them in the source).
*
* Reads from `namespace.entries`, skipping the built-in kind keys
* (`'model'`, `'compositeType'`). All remaining kind maps contain
* only `PslExtensionBlock` nodes by construction (see `makePslNamespaceEntries`).
*/
declare function namespacePslExtensionBlocks(ns: PslNamespace): readonly PslExtensionBlock[];
interface ParsePslDocumentInput {
readonly schema: string;
readonly sourceId: string;
/**
* Registry of declarative block descriptors, keyed by arbitrary path
* segments with {@link AuthoringPslBlockDescriptor} leaves. The registry
* teaches the parser which top-level keywords belong to extension
* contributions: when the parser encounters an unknown keyword, it looks
* it up here and, when found, reads the block generically into a
* {@link PslExtensionBlock} node. Absent or undefined means no extension
* blocks are registered and any unknown keyword yields
* `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK`.
*
* Contrast with the parsed block nodes themselves, which live in
* {@link PslNamespace.entries} under their discriminator key (read them with
* {@link namespacePslExtensionBlocks}); this field holds the registry of
* descriptors that teach the parser how to read those blocks.
*/
readonly pslBlockDescriptors?: AuthoringPslBlockDescriptorNamespace;
/**
* Codec lookup for validating `value`-kind extension block parameters.
* When provided alongside `pslBlockDescriptors`, the generic validator runs
* over every parsed extension block after the full AST is assembled,
* appending any diagnostics to the parse result. Absent or undefined means
* no codec validation runs; `ref` resolution still runs when namespace
* context is available (built from the assembled namespaces).
*/
readonly codecLookup?: CodecLookup;
}
interface ParsePslDocumentResult {
readonly ast: PslDocumentAst;
readonly diagnostics: readonly PslDiagnostic[];
readonly ok: boolean;
}
//#endregion
export { makePslNamespace as A, PslReferentialAction as C, UNSPECIFIED_PSL_NAMESPACE_ID as D, PslUniqueConstraint as E, namespacePslExtensionBlocks as M, flatPslCompositeTypes as O, PslNamespaceEntry as S, PslTypesBlock as T, PslIndexConstraint as _, PslAttributeArgument as a, PslNamedTypeDeclaration as b, PslAttributeTarget as c, PslDefaultLiteralValue as d, PslDefaultValue as f, PslFieldAttribute as g, PslField as h, PslAttribute as i, makePslNamespaceEntries as j, flatPslModels as k, PslCompositeType as l, PslDocumentAst as m, ParsePslDocumentInput as n, PslAttributeNamedArgument as o, PslDiagnostic as p, ParsePslDocumentResult as r, PslAttributePositionalArgument as s, BUILTIN_PSL_KIND_KEYS as t, PslDefaultFunctionValue as u, PslModel as v, PslTypeConstructorCall as w, PslNamespace as x, PslModelAttribute as y };
//# sourceMappingURL=psl-ast-BEdlyUwY.d.mts.map
{"version":3,"file":"psl-ast-BEdlyUwY.d.mts","names":[],"sources":["../src/control/psl-ast.ts"],"mappings":";;;;UA0BiB,aAAA;EAAA,SACN,IAAA,EAAM,iBAAA;EAAA,SACN,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,EAAM,OAAO;AAAA;AAAA,UAGP,uBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAI;AAAA;AAAA,UAGE,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAK;AAAA;AAAA,KAGJ,eAAA,GAAkB,uBAAA,GAA0B,sBAAsB;AAAA,KAElE,kBAAA;AAAA,UAEK,8BAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA,EAAM,OAAO;AAAA;AAAA,UAGP,yBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA,EAAM,OAAO;AAAA;AAAA,KAGZ,oBAAA,GAAuB,8BAAA,GAAiC,yBAAyB;AAAA,UAE5E,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA,WAAe,oBAAA;EAAA,SACf,IAAA,EAAM,OAAO;AAAA;AAAA,UAGP,YAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA,EAAQ,kBAAA;EAAA,SACR,IAAA;EAAA,SACA,IAAA,WAAe,oBAAA;EAAA,SACf,IAAA,EAAM,OAAA;AAAA;AAAA,KAGL,oBAAA;AAAA,KAEA,iBAAA,GAAoB,YAAY;AAAA,UAE3B,QAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EA5BA;EAAA,SA8BA,QAAA;EA5BA;EAAA,SA8BA,eAA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