@prisma-next/framework-components
Advanced tools
| 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-4tPB4m_G.d.mts.map |
| {"version":3,"file":"codec-types-4tPB4m_G.d.mts","names":[],"sources":["../src/shared/codec-descriptor.ts","../src/shared/codec.ts","../src/shared/codec-types.ts"],"mappings":";;;;;;;;;;;;;;UA+BiB,gBAAgB;;WAEtB;;WAEA,iBAAiB;;WAEjB;;WAEA,OAAO;;WAEP,cAAc,iBAAiB;;WAE/B;;WAEA,WAAW,QAAQ,MAAM;;WAEzB,oBAAoB,QAAQ;;WAE5B,mBAAmB,QAAQ;;;;;;;;;;;WAW3B,sBAAsB,OAAO,WAAW;;WAExC,UAAU,QAAQ,OAAO,KAAK,yBAAyB;;;;;;;KAStD,qBAAqB;;;;;;;;uBASX,oBAAoB,2BAA2B,gBAAgB;oBACjE;oBACA,iBAAiB;oBACjB;WACT,OAAO;oBAEE,cAAc,iBAAiB;;MAG7C;;EAKJ,SAAS,QAAQ,UAAU;;EAG3B,kBAAkB,QAAQ;;EAG1B,iBAAiB,QAAQ;;EAGzB,oBAAoB,OAAO,WAAW;;;;WAK7B,QACP,QAAQ,WACN,KAAK,yBAAyB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;UC7E1C,MACf,4BACA,yBAAyB,wBAAwB,cACjD,iBACA;;WAGS,IAAI;;WAEJ,gBAAgB;;EAEzB,OAAO,OAAO,QAAQ,KAAK,mBAAmB,QAAQ;;EAEtD,OAAO,MAAM,OAAO,KAAK,mBAAmB,QAAQ;;EAEpD,WAAW,OAAO,SAAS;;EAE3B,WAAW,MAAM,YAAY;;;;;;;uBAQT,UACpB,4BACA,yBAAyB,wBAAwB,cACjD,iBACA,6BACW,MAAM,IAAI,SAAS,OAAO;WAMT,YAAY;;;;cAAZ,YAAY;MAEpC,MAAM;WAID,OAAO,OAAO,QAAQ,KAAK,mBAAmB,QAAQ;WACtD,OAAO,MAAM,OAAO,KAAK,mBAAmB,QAAQ;WACpD,WAAW,OAAO,SAAS;WAC3B,WAAW,MAAM,YAAY;;;;KCzE5B;;;;;;;;;;;;UAaK;WACN;WACA,aAAa;WACb;;;;;;;;;;;;;UAcM;WACN,SAAS;;;;;;;;;;UAWH;EACf,IAAI,aAAa;EACjB,eAAe;EACf,QAAQ,YAAY,aAAa,0BAA0B,YAAY;EACvE,oBAAoB,YAAY,QAAQ;;EAExC,oBAAoB,YAAY,QAAQ;;EAExC,uBACE,YACA,OAAO,WACP;;;;;;;;;;EAWF,eAAe,aAAa;;;;;;;;;;;;;;;UAgBb,sBAAsB;EACrC,YAAY,KAAK,WAAW;EAC5B,UAAU,qBAAqB,eAAe,iBAAiB;;cAGpD,kBAAkB;;;;;;;;UAcd;WACN;;;;;UAMM;WACN,KAAK;;;;;cAMH,kBAAkB"} |
| import { r as CodecLookup } from "./codec-types-4tPB4m_G.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-T3r8La7q.d.mts.map |
| {"version":3,"file":"emission-types-T3r8La7q.d.mts","names":[],"sources":["../src/control/emission-types.ts"],"mappings":";;;;UAIiB;WACN,4BAA4B,cAAc;;UAGpC;WACN,mBAAmB,cAAc;WACjC,eAAe;;UAGT;WACN;EAET,oBAAoB,UAAU,UAAU;EAExC,yBAAyB,mBAAmB,OAAO;EAEnD;EAEA,qBAAqB,UAAU;EAE/B;EAEA,mBAAmB,0BAA0B;EAE7C,wBACE,mBACA,mBACA,OAAO,mBACP,UAAU,WACT;;;;;;;EAQH,sBACE,mBACA,mBACA,OAAO,mBACP,UAAU;aACE,wBAAwB;aAAsB;;EAE5D,uBAAuB,UAAU,UAAU,cAAc"} |
| import { r as CodecLookup } from "./codec-types-4tPB4m_G.mjs"; | ||
| import { ColumnDefault, ExecutionMutationDefaultPhases } from "@prisma-next/contract/types"; | ||
| import { Type } from "arktype"; | ||
| //#region src/shared/option-descriptor.d.ts | ||
| /** | ||
| * An enumerated-value parameter: the author supplies one of `values`, spelled | ||
| * as a bare token in PSL and a string literal in TypeScript. Shared by the | ||
| * extension-block parameter vocabulary (`PslBlockParamOption`) and the helper | ||
| * argument vocabulary (`AuthoringArgumentDescriptor`) so the option concept is | ||
| * declared once. See ADR 239. | ||
| */ | ||
| interface AuthoringOption { | ||
| readonly kind: 'option'; | ||
| readonly values: readonly string[]; | ||
| } | ||
| //#endregion | ||
| //#region src/shared/psl-extension-block.d.ts | ||
| 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 extends AuthoringOption { | ||
| 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; | ||
| }; | ||
| /** | ||
| * Selects among `cases` by the value of the referenced argument: the resolved | ||
| * value must be one of the case keys, and the node resolves to that case's | ||
| * recursively resolved template. An absent argument resolves to `undefined`, | ||
| * which the enclosing object template omits entirely. | ||
| * | ||
| * Case coverage is validated against the referenced option argument's | ||
| * `values` at pack-registration time, so the runtime miss-throw is an | ||
| * assertion for type-bypassing callers, not a user-facing diagnostic. | ||
| * | ||
| * Must not be used in the `codecId`/`nullable`/`id`/`unique` positions of a | ||
| * preset output: the type-level `ResolveTemplateValue` does not implement | ||
| * select, and those fields feed TS builder-state inference. See ADR 239. | ||
| */ | ||
| interface AuthoringSelectRef { | ||
| readonly kind: 'select'; | ||
| readonly index: number; | ||
| readonly path?: readonly string[]; | ||
| readonly cases: Readonly<Record<string, AuthoringTemplateValue>>; | ||
| } | ||
| type AuthoringTemplateValue = string | number | boolean | null | AuthoringArgRef | AuthoringSelectRef | 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>; | ||
| } | AuthoringOption); | ||
| 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 { PslExtensionBlockParamOption as $, instantiateAuthoringFieldPreset as A, resolveEnumCodecId as B, AuthoringTypeConstructorDescriptor as C, classifyEnumMemberType as D, assertNoCrossRegistryCollisions as E, isAuthoringModelAttributeDescriptor as F, PslBlockParamRef as G, PslBlockParam as H, isAuthoringPslBlockDescriptor as I, PslExtensionBlock as J, PslBlockParamValue as K, isAuthoringTypeConstructorDescriptor as L, isAuthoringArgRef as M, isAuthoringEntityTypeDescriptor as N, hasRegisteredFieldNamespace as O, isAuthoringFieldPresetDescriptor as P, PslExtensionBlockParamList as Q, mergeAuthoringNamespaces as R, AuthoringTemplateValue as S, AuthoringTypeNamespace as T, PslBlockParamList as U, validateAuthoringHelperArguments as V, PslBlockParamOption as W, PslExtensionBlockAttributeArg as X, PslExtensionBlockAttribute as Y, PslExtensionBlockParamBare as Z, AuthoringModelAttributeLoweringOutput as _, AuthoringDiagnosticSink as a, AuthoringOption as at, AuthoringSelectRef as b, AuthoringEntityTypeFactoryOutput as c, AuthoringFieldNamespace as d, PslExtensionBlockParamRef as et, AuthoringFieldPresetDescriptor as f, AuthoringModelAttributeDescriptorNamespace as g, AuthoringModelAttributeDescriptor as h, AuthoringContributions as i, PslSpan as it, instantiateAuthoringTypeConstructor as j, instantiateAuthoringEntityType as k, AuthoringEntityTypeNamespace as l, AuthoringModelAttributeContext as m, AuthoringArgumentDescriptor as n, PslExtensionBlockParamValue as nt, AuthoringEntityContext as o, AuthoringFieldPresetOutput as p, PslDiagnosticCode as q, AuthoringColumnDefaultTemplate as r, PslPosition as rt, AuthoringEntityTypeDescriptor as s, AuthoringArgRef as t, PslExtensionBlockParamScalarValue as tt, AuthoringEntityTypeTemplateOutput as u, AuthoringPslBlockDescriptor as v, AuthoringTypeConstructorEntityRef as w, AuthoringStorageTypeTemplate as x, AuthoringPslBlockDescriptorNamespace as y, resolveAuthoringTemplateValue as z }; | ||
| //# sourceMappingURL=framework-authoring-Bv5QKca9.d.mts.map |
| {"version":3,"file":"framework-authoring-Bv5QKca9.d.mts","names":[],"sources":["../src/shared/option-descriptor.ts","../src/shared/psl-extension-block.ts","../src/shared/framework-authoring.ts"],"mappings":";;;;;;;;;;;UAOiB;WACN;WACA;;;;UCKM;WACN;WACA;WACA;;UAGM;WACN,OAAO;WACP,KAAK;;KAGJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;iBA6Tc,gCACd,eAAe,wBACf,gBAAgB,yBAChB,sBAAqB,8BACrB,oBAAmB,sCACnB,0BAAyB;iBAyKX,8BACd,UAAU,oCACV;iBAgIc,iCACd,oBACA,sBAAsB,2CACtB;iBAyHc,oCACd,YAAY,oCACZ;WAES;WACA;WACA,aAAa;;iBAKR,+BAA+B,mBAC7C,oBACA,YAAY,+BACZ,0BACA,KAAK,yBACJ;iBA2Ba,gCACd,YAAY,gCACZ;WAES;aACE;aACA;aACA,aAAa;;WAEf;WACA,UAAU;WACV,oBAAoB;WACpB;WACA"} |
| import { n as runtimeError } from "./runtime-error-BA9d7XjZ.mjs"; | ||
| import { blindCast } from "@prisma-next/utils/casts"; | ||
| import { isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue } from "@prisma-next/contract/types"; | ||
| import { ifDefined } from "@prisma-next/utils/defined"; | ||
| //#region src/shared/framework-authoring.ts | ||
| /** | ||
| * 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`. | ||
| */ | ||
| function classifyEnumMemberType(block) { | ||
| let sawText = false; | ||
| let sawInt = false; | ||
| for (const paramValue of Object.values(block.parameters)) { | ||
| if (paramValue.kind === "bare") { | ||
| sawText = true; | ||
| continue; | ||
| } | ||
| if (paramValue.kind !== "value") return null; | ||
| let jsonValue; | ||
| try { | ||
| jsonValue = JSON.parse(paramValue.raw); | ||
| } catch { | ||
| return null; | ||
| } | ||
| if (typeof jsonValue === "string") sawText = true; | ||
| else if (typeof jsonValue === "number" && Number.isInteger(jsonValue)) sawInt = true; | ||
| else return null; | ||
| } | ||
| if (sawText && sawInt) return null; | ||
| if (sawText) return "text"; | ||
| if (sawInt) return "int"; | ||
| return 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. | ||
| */ | ||
| function resolveEnumCodecId(block, ctx) { | ||
| const sourceId = ctx.sourceId ?? "unknown"; | ||
| const typeAttr = block.blockAttributes.find((a) => a.name === "type"); | ||
| if (typeAttr === void 0) { | ||
| const inferredKind = classifyEnumMemberType(block); | ||
| if (inferredKind === null || ctx.enumInferenceCodecs === void 0) { | ||
| ctx.diagnostics?.push({ | ||
| code: "PSL_ENUM_CANNOT_INFER_TYPE", | ||
| message: `cannot infer @@type for enum "${block.name}"; add an explicit @@type(...)`, | ||
| sourceId, | ||
| span: block.span | ||
| }); | ||
| return; | ||
| } | ||
| return { | ||
| codecId: ctx.enumInferenceCodecs[inferredKind], | ||
| codecSpan: block.span | ||
| }; | ||
| } | ||
| const rawCodecArg = typeAttr.args[0]?.value; | ||
| const codecId = rawCodecArg?.startsWith("\"") && rawCodecArg.endsWith("\"") && rawCodecArg.length >= 2 ? rawCodecArg.slice(1, -1) : void 0; | ||
| if (codecId === void 0) { | ||
| ctx.diagnostics?.push({ | ||
| code: "PSL_ENUM_MISSING_TYPE", | ||
| message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`, | ||
| sourceId, | ||
| span: typeAttr.span | ||
| }); | ||
| return; | ||
| } | ||
| return { | ||
| codecId, | ||
| codecSpan: typeAttr.args[0]?.span ?? typeAttr.span | ||
| }; | ||
| } | ||
| function isAuthoringArgRef(value) { | ||
| if (typeof value !== "object" || value === null || value.kind !== "arg") return false; | ||
| const { index, path } = value; | ||
| if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false; | ||
| if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false; | ||
| return true; | ||
| } | ||
| function isAuthoringSelectRef(value) { | ||
| if (!isAuthoringTemplateRecord(value) || value["kind"] !== "select") return false; | ||
| const index = value["index"]; | ||
| const path = value["path"]; | ||
| const cases = value["cases"]; | ||
| if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false; | ||
| if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false; | ||
| return typeof cases === "object" && cases !== null && !Array.isArray(cases); | ||
| } | ||
| function isAuthoringTemplateRecord(value) { | ||
| return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| } | ||
| function readTemplateArgumentValue(args, index, path) { | ||
| let value = args[index]; | ||
| for (const segment of path ?? []) { | ||
| if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) return; | ||
| value = value[segment]; | ||
| } | ||
| return value; | ||
| } | ||
| function isAuthoringTypeConstructorDescriptor(value) { | ||
| return "kind" in value && value.kind === "typeConstructor"; | ||
| } | ||
| function isAuthoringFieldPresetDescriptor(value) { | ||
| return "kind" in value && value.kind === "fieldPreset"; | ||
| } | ||
| function isAuthoringEntityTypeDescriptor(value) { | ||
| return "kind" in value && value.kind === "entity"; | ||
| } | ||
| function isAuthoringPslBlockDescriptor(value) { | ||
| return "kind" in value && value.kind === "pslBlock"; | ||
| } | ||
| function isAuthoringModelAttributeDescriptor(value) { | ||
| return "kind" in value && value.kind === "modelAttribute"; | ||
| } | ||
| /** | ||
| * 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`). | ||
| */ | ||
| function hasRegisteredFieldNamespace(contributions, namespace) { | ||
| if (contributions?.field === void 0 || !Object.hasOwn(contributions.field, namespace)) return false; | ||
| const value = contributions.field[namespace]; | ||
| return value !== void 0 && !isAuthoringFieldPresetDescriptor(value); | ||
| } | ||
| function isCopyableNamespaceObject(value) { | ||
| if (typeof value !== "object" || value === null || Array.isArray(value)) return false; | ||
| const proto = Object.getPrototypeOf(value); | ||
| return proto === Object.prototype || proto === null; | ||
| } | ||
| /** | ||
| * Deep structural check run only at the composition boundary (the merge and | ||
| * collect walkers) to classify a raw namespace-tree node as a leaf descriptor. | ||
| * A node counts as a leaf iff its `kind` matches `descriptorKind` AND it | ||
| * carries that kind's required fields. | ||
| * | ||
| * This is boundary validation over `unknown`, NOT a type-predicate: the four | ||
| * exported `isAuthoring*Descriptor` predicates deliberately narrow on `kind` | ||
| * alone and trust the static types. The walkers, by contrast, also receive | ||
| * type-bypassing packs (`as unknown as never` in tests, untyped JS at runtime) | ||
| * whose descriptor-shaped-but-incomplete nodes must be rejected rather than | ||
| * silently treated as sub-namespaces — so the well-formedness check lives here. | ||
| */ | ||
| function isWellFormedDescriptor(value, descriptorKind) { | ||
| if (typeof value !== "object" || value === null) return false; | ||
| if (!("kind" in value) || value.kind !== descriptorKind) return false; | ||
| switch (descriptorKind) { | ||
| case "typeConstructor": | ||
| case "fieldPreset": { | ||
| if (!("output" in value)) return false; | ||
| const output = value.output; | ||
| return typeof output === "object" && output !== null; | ||
| } | ||
| case "entity": { | ||
| if (!("discriminator" in value) || typeof value.discriminator !== "string") return false; | ||
| if (value.discriminator.length === 0) return false; | ||
| if (!("output" in value)) return false; | ||
| const output = value.output; | ||
| if (typeof output !== "object" || output === null) return false; | ||
| const factory = "factory" in output ? output.factory : void 0; | ||
| const template = "template" in output ? output.template : void 0; | ||
| return typeof factory === "function" || template !== void 0; | ||
| } | ||
| case "pslBlock": { | ||
| if (!("keyword" in value) || typeof value.keyword !== "string" || value.keyword.length === 0) return false; | ||
| if (!("discriminator" in value) || typeof value.discriminator !== "string" || value.discriminator.length === 0) return false; | ||
| if (!("name" in value)) return false; | ||
| const name = value.name; | ||
| if (typeof name !== "object" || name === null) return false; | ||
| if (!("required" in name) || typeof name.required !== "boolean") return false; | ||
| if (!("parameters" in value)) return false; | ||
| const parameters = value.parameters; | ||
| return typeof parameters === "object" && parameters !== null && !Array.isArray(parameters); | ||
| } | ||
| case "modelAttribute": | ||
| if (!("attribute" in value) || typeof value.attribute !== "string" || value.attribute.length === 0) return false; | ||
| if (!("spec" in value)) return false; | ||
| return "lower" in value && typeof value.lower === "function"; | ||
| default: return false; | ||
| } | ||
| } | ||
| function deepCopyNamespace(source, descriptorKind) { | ||
| const copy = {}; | ||
| for (const [key, value] of Object.entries(source)) copy[key] = isCopyableNamespaceObject(value) && !isWellFormedDescriptor(value, descriptorKind) ? deepCopyNamespace(value, descriptorKind) : value; | ||
| return copy; | ||
| } | ||
| /** | ||
| * 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. | ||
| */ | ||
| function mergeAuthoringNamespaces(target, source, path, descriptorKind, label) { | ||
| const assertSafePath = (currentPath) => { | ||
| const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype"); | ||
| if (blockedSegment) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`); | ||
| }; | ||
| for (const [key, sourceValue] of Object.entries(source)) { | ||
| const currentPath = [...path, key]; | ||
| assertSafePath(currentPath); | ||
| const hasExistingValue = Object.hasOwn(target, key); | ||
| const existingValue = hasExistingValue ? target[key] : void 0; | ||
| if (!hasExistingValue) { | ||
| target[key] = isCopyableNamespaceObject(sourceValue) && !isWellFormedDescriptor(sourceValue, descriptorKind) ? deepCopyNamespace(sourceValue, descriptorKind) : sourceValue; | ||
| continue; | ||
| } | ||
| const existingIsLeaf = isWellFormedDescriptor(existingValue, descriptorKind); | ||
| const sourceIsLeaf = isWellFormedDescriptor(sourceValue, descriptorKind); | ||
| if (existingIsLeaf || sourceIsLeaf) throw new Error(`Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`); | ||
| if (!isCopyableNamespaceObject(existingValue) || !isCopyableNamespaceObject(sourceValue)) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`); | ||
| mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, descriptorKind, label); | ||
| } | ||
| } | ||
| function collectDescriptorPaths(namespace, isLeaf, path = []) { | ||
| const paths = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isLeaf(value)) { | ||
| paths.push(currentPath.join(".")); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath)); | ||
| } | ||
| return paths; | ||
| } | ||
| function collectDescriptorEntries(namespace, isLeaf, descriptorKind, label, path = []) { | ||
| const entries = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isLeaf(value)) { | ||
| if (!isWellFormedDescriptor(value, descriptorKind)) throw new Error(`Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| if (value.discriminator.length > 0) entries.push({ | ||
| path: currentPath.join("."), | ||
| discriminator: value.discriminator | ||
| }); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) { | ||
| const record = blindCast(value); | ||
| if ((record["kind"] !== void 0 || record["keyword"] !== void 0 || record["discriminator"] !== void 0) && !isLeaf(value)) { | ||
| const hasKind = record["kind"] === "pslBlock"; | ||
| const hasKeyword = typeof record["keyword"] === "string"; | ||
| const hasDiscriminator = typeof record["discriminator"] === "string"; | ||
| if (hasKind || hasKeyword && hasDiscriminator) throw new Error(`Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| } | ||
| entries.push(...collectDescriptorEntries(value, isLeaf, descriptorKind, label, currentPath)); | ||
| } | ||
| } | ||
| return entries; | ||
| } | ||
| /** | ||
| * Throws when two or more entries in the same namespace share a key. A | ||
| * duplicate key makes dispatch ambiguous — the caller's lookup dispatches by | ||
| * this key, so one entry would silently shadow the other. Catch duplicates | ||
| * before building any dispatch map. | ||
| * | ||
| * `label` (e.g. `'pslBlock'`, `'entityType'`) names which namespace the | ||
| * duplicate was found in and is carried in the structured error metadata; | ||
| * the key itself is always called `key` in both the message and the | ||
| * metadata, since what it semantically represents (a discriminator for | ||
| * `entityType`, the parser's dispatch keyword for `pslBlock`) is the | ||
| * caller's concern, not this function's. | ||
| */ | ||
| function assertUniqueDiscriminators(entries, label) { | ||
| const seen = /* @__PURE__ */ new Map(); | ||
| for (const { path, discriminator: key } of entries) { | ||
| const existing = seen.get(key); | ||
| if (existing !== void 0) throw runtimeError("RUNTIME.DUPLICATE_AUTHORING_DISCRIMINATOR", `Duplicate ${label} key "${key}" registered at both "${existing}" and "${path}". Each ${label} contribution must use a unique key.`, { | ||
| label, | ||
| key, | ||
| existingPath: existing, | ||
| path | ||
| }); | ||
| seen.set(key, path); | ||
| } | ||
| } | ||
| function collectPslBlockDescriptorEntries(namespace, path = []) { | ||
| const entries = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isAuthoringPslBlockDescriptor(value)) { | ||
| if (!isWellFormedDescriptor(value, "pslBlock")) throw new Error(`Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push({ | ||
| path: currentPath.join("."), | ||
| discriminator: value.discriminator, | ||
| keyword: value.keyword | ||
| }); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) { | ||
| const record = blindCast(value); | ||
| const hasKind = record["kind"] === "pslBlock"; | ||
| const hasKeyword = typeof record["keyword"] === "string"; | ||
| const hasDiscriminator = typeof record["discriminator"] === "string"; | ||
| if (hasKind || hasKeyword && hasDiscriminator) throw new Error(`Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push(...collectPslBlockDescriptorEntries(value, currentPath)); | ||
| } | ||
| } | ||
| return entries; | ||
| } | ||
| /** | ||
| * Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory | ||
| * with the same discriminator. An `entityTypes` factory may stand alone (e.g. | ||
| * `enum`, reachable from the TypeScript builder without any PSL block). | ||
| * | ||
| * Uniqueness for pslBlock entries is keyed on **keyword**, not discriminator: | ||
| * several keywords (e.g. `policy_select`/`policy_insert`) may legitimately | ||
| * share one discriminator, routing to the same `entityTypes` factory and the | ||
| * same `entries[discriminator]` slot — that N:1 shape is exactly what lets | ||
| * one entity kind be authored through several PSL keywords. What must stay | ||
| * unique is the keyword itself, since that's what the parser dispatches on. | ||
| */ | ||
| function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) { | ||
| const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace); | ||
| const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entity", "entityType"); | ||
| assertUniqueDiscriminators(blockEntries.map((entry) => ({ | ||
| path: entry.path, | ||
| discriminator: entry.keyword | ||
| })), "pslBlock"); | ||
| assertUniqueDiscriminators(entityEntries, "entityType"); | ||
| const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator)); | ||
| for (const block of blockEntries) if (!entityDiscriminators.has(block.discriminator)) throw new Error(`Incomplete extension contribution: pslBlock helper "${block.path}" registers discriminator "${block.discriminator}" but no entityType contribution shares that discriminator. An extension-contributed PSL block requires a matching entityType factory so the parsed AST node can lower to an IR class instance; add an entityType helper with discriminator "${block.discriminator}".`); | ||
| } | ||
| function collectModelAttributeEntries(namespace, path = []) { | ||
| const entries = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isAuthoringModelAttributeDescriptor(value)) { | ||
| if (!isWellFormedDescriptor(value, "modelAttribute")) throw new Error(`Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push({ | ||
| path: currentPath.join("."), | ||
| discriminator: value.attribute | ||
| }); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) { | ||
| const record = blindCast(value); | ||
| if (typeof record["attribute"] === "string" && "spec" in record) throw new Error(`Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push(...collectModelAttributeEntries(value, currentPath)); | ||
| } | ||
| } | ||
| return entries; | ||
| } | ||
| /** | ||
| * Throws when two modelAttribute contributions — at any paths, even | ||
| * different ones — claim the same bare `@@` attribute name. The family | ||
| * interpreter dispatches by attribute name, not by registration path, so | ||
| * two descriptors claiming the same name would have one silently shadow | ||
| * the other. | ||
| */ | ||
| function assertUniqueModelAttributeNames(entries) { | ||
| const seen = /* @__PURE__ */ new Map(); | ||
| for (const { path, discriminator: attribute } of entries) { | ||
| const existing = seen.get(attribute); | ||
| if (existing !== void 0) throw new Error(`Duplicate modelAttribute "${attribute}" registered at both "${existing}" and "${path}". Each modelAttribute contribution must claim a unique attribute name.`); | ||
| seen.set(attribute, path); | ||
| } | ||
| } | ||
| function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) { | ||
| const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor)); | ||
| const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor)); | ||
| const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor)); | ||
| const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes."; | ||
| for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw new Error(`Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`); | ||
| for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw new Error(`Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`); | ||
| assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace); | ||
| assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace)); | ||
| assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace); | ||
| } | ||
| function collectDescriptorNodes(namespace, isLeaf, path = []) { | ||
| const nodes = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isLeaf(value)) { | ||
| nodes.push([currentPath.join("."), value]); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) nodes.push(...collectDescriptorNodes(value, isLeaf, currentPath)); | ||
| } | ||
| return nodes; | ||
| } | ||
| function collectSelectRefs(value, found) { | ||
| if (typeof value !== "object" || value === null) return; | ||
| if (isAuthoringSelectRef(value)) { | ||
| found.push(value); | ||
| for (const caseTemplate of Object.values(value.cases)) collectSelectRefs(caseTemplate, found); | ||
| return; | ||
| } | ||
| if (isAuthoringArgRef(value)) { | ||
| collectSelectRefs(value.default, found); | ||
| return; | ||
| } | ||
| if (Array.isArray(value)) { | ||
| for (const entry of value) collectSelectRefs(entry, found); | ||
| return; | ||
| } | ||
| for (const entry of Object.values(value)) collectSelectRefs(entry, found); | ||
| } | ||
| function validateSelectRefsAgainstArgs(label, helperPath, args, templateRoot) { | ||
| const selects = []; | ||
| collectSelectRefs(templateRoot, selects); | ||
| for (const select of selects) { | ||
| const position = `#${select.index + 1}`; | ||
| let descriptor = args?.[select.index]; | ||
| if (descriptor === void 0) throw new Error(`Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`); | ||
| for (const segment of select.path ?? []) { | ||
| descriptor = descriptor.kind === "object" ? descriptor.properties[segment] : void 0; | ||
| if (descriptor === void 0) throw new Error(`Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join(".")}", which does not resolve to a declared argument property.`); | ||
| } | ||
| if (descriptor.kind !== "option") throw new Error(`Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`); | ||
| const argumentLabel = descriptor.name !== void 0 ? `"${descriptor.name}"` : position; | ||
| const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value)); | ||
| if (missing.length > 0) throw new Error(`Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(", ")}] but the select template has no case for: ${missing.join(", ")}.`); | ||
| const values = descriptor.values; | ||
| const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key)); | ||
| if (unreachable.length > 0) throw new Error(`Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(", ")}. Allowed values: [${values.join(", ")}].`); | ||
| } | ||
| } | ||
| /** | ||
| * Every `select` template node must target an option argument whose `values` | ||
| * exactly cover the node's `cases` — a legal token with no case and a case no | ||
| * token can reach are both declaration bugs, caught here at pack-registration | ||
| * time rather than at first resolution. | ||
| */ | ||
| function assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace) { | ||
| for (const [helperPath, descriptor] of collectDescriptorNodes(fieldNamespace, isAuthoringFieldPresetDescriptor)) validateSelectRefsAgainstArgs("field", helperPath, descriptor.args, descriptor.output); | ||
| for (const [helperPath, descriptor] of collectDescriptorNodes(typeNamespace, isAuthoringTypeConstructorDescriptor)) validateSelectRefsAgainstArgs("type", helperPath, descriptor.args, descriptor.output); | ||
| for (const [helperPath, descriptor] of collectDescriptorNodes(entityTypeNamespace, isAuthoringEntityTypeDescriptor)) if ("template" in descriptor.output) validateSelectRefsAgainstArgs("entityType", helperPath, descriptor.args, descriptor.output.template); | ||
| } | ||
| function resolveAuthoringTemplateValue(template, args) { | ||
| if (template === void 0) return; | ||
| if (isAuthoringArgRef(template)) { | ||
| const value = readTemplateArgumentValue(args, template.index, template.path); | ||
| if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args); | ||
| return value; | ||
| } | ||
| if (isAuthoringSelectRef(template)) { | ||
| const value = readTemplateArgumentValue(args, template.index, template.path); | ||
| if (value === void 0) return; | ||
| if (typeof value !== "string" || !Object.hasOwn(template.cases, value)) throw new Error(`Authoring template select has no case for value "${String(value)}"`); | ||
| return resolveAuthoringTemplateValue(template.cases[value], args); | ||
| } | ||
| if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args)); | ||
| if (typeof template === "object" && template !== null) { | ||
| const resolved = {}; | ||
| for (const [key, value] of Object.entries(template)) { | ||
| const resolvedValue = resolveAuthoringTemplateValue(value, args); | ||
| if (resolvedValue !== void 0) resolved[key] = resolvedValue; | ||
| } | ||
| return resolved; | ||
| } | ||
| return template; | ||
| } | ||
| function validateAuthoringArgument(descriptor, value, path) { | ||
| if (value === void 0) { | ||
| if (descriptor.optional) return; | ||
| throw new Error(`Missing required authoring helper argument at ${path}`); | ||
| } | ||
| if (descriptor.kind === "string") { | ||
| if (typeof value !== "string") throw new Error(`Authoring helper argument at ${path} must be a string`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "boolean") { | ||
| if (typeof value !== "boolean") throw new Error(`Authoring helper argument at ${path} must be a boolean`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "stringArray") { | ||
| if (!Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an array of strings`); | ||
| for (const entry of value) if (typeof entry !== "string") throw new Error(`Authoring helper argument at ${path} must be an array of strings`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "object") { | ||
| if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an object`); | ||
| const input = value; | ||
| const expectedKeys = new Set(Object.keys(descriptor.properties)); | ||
| for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw new Error(`Authoring helper argument at ${path} contains unknown property "${key}"`); | ||
| for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "option") { | ||
| if (typeof value !== "string" || !descriptor.values.includes(value)) throw new Error(`Authoring helper argument at ${path} must be one of: ${descriptor.values.join(", ")}`); | ||
| return; | ||
| } | ||
| if (typeof value !== "number" || Number.isNaN(value)) throw new Error(`Authoring helper argument at ${path} must be a number`); | ||
| if (descriptor.integer && !Number.isInteger(value)) throw new Error(`Authoring helper argument at ${path} must be an integer`); | ||
| if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw new Error(`Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`); | ||
| if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw new Error(`Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`); | ||
| } | ||
| function validateAuthoringHelperArguments(helperPath, descriptors, args) { | ||
| const expected = descriptors ?? []; | ||
| const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0); | ||
| if (args.length < minimumArgs || args.length > expected.length) throw new Error(`${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`); | ||
| expected.forEach((descriptor, index) => { | ||
| validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`); | ||
| }); | ||
| } | ||
| function resolveAuthoringStorageTypeTemplate(template, args) { | ||
| const nativeType = resolveAuthoringTemplateValue(template.nativeType, args); | ||
| if (typeof nativeType !== "string") throw new Error(`Resolved authoring nativeType must be a string for codec "${template.codecId}", received ${String(nativeType)}`); | ||
| const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args); | ||
| if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw new Error(`Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`); | ||
| const normalizedTypeParams = typeParams !== void 0 && Object.keys(typeParams).length === 0 ? void 0 : typeParams; | ||
| return { | ||
| codecId: template.codecId, | ||
| nativeType, | ||
| ...ifDefined("typeParams", normalizedTypeParams) | ||
| }; | ||
| } | ||
| function resolveAuthoringColumnDefaultTemplate(template, args) { | ||
| if (template.kind === "literal") { | ||
| const value = resolveAuthoringTemplateValue(template.value, args); | ||
| if (value === void 0) throw new Error("Resolved authoring literal default must not be undefined"); | ||
| if (!isColumnDefaultLiteralInputValue(value)) throw new Error(`Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`); | ||
| return { | ||
| kind: "literal", | ||
| value | ||
| }; | ||
| } | ||
| const expression = resolveAuthoringTemplateValue(template.expression, args); | ||
| if (expression === void 0 || typeof expression === "object" && expression !== null) throw new Error(`Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`); | ||
| return { | ||
| kind: "function", | ||
| expression: String(expression) | ||
| }; | ||
| } | ||
| function resolveExecutionMutationDefaultPhase(phase, template, args) { | ||
| const value = resolveAuthoringTemplateValue(template, args); | ||
| if (value === void 0) return; | ||
| if (!isExecutionMutationDefaultValue(value)) throw new Error(`Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`); | ||
| return value; | ||
| } | ||
| function resolveAuthoringExecutionDefaultsTemplate(template, args) { | ||
| const phases = { | ||
| ...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0), | ||
| ...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0) | ||
| }; | ||
| return Object.keys(phases).length === 0 ? void 0 : phases; | ||
| } | ||
| function instantiateAuthoringTypeConstructor(descriptor, args) { | ||
| return resolveAuthoringStorageTypeTemplate(descriptor.output, args); | ||
| } | ||
| function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) { | ||
| if ("factory" in descriptor.output) { | ||
| const input = args[0]; | ||
| return blindCast(descriptor.output.factory)(input, ctx); | ||
| } | ||
| validateAuthoringHelperArguments(helperPath, descriptor.args, args); | ||
| return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args)); | ||
| } | ||
| function instantiateAuthoringFieldPreset(descriptor, args) { | ||
| return { | ||
| descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args), | ||
| nullable: descriptor.output.nullable ?? false, | ||
| ...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0), | ||
| ...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0), | ||
| id: descriptor.output.id ?? false, | ||
| unique: descriptor.output.unique ?? false | ||
| }; | ||
| } | ||
| //#endregion | ||
| export { instantiateAuthoringFieldPreset as a, isAuthoringEntityTypeDescriptor as c, isAuthoringPslBlockDescriptor as d, isAuthoringTypeConstructorDescriptor as f, validateAuthoringHelperArguments as g, resolveEnumCodecId as h, instantiateAuthoringEntityType as i, isAuthoringFieldPresetDescriptor as l, resolveAuthoringTemplateValue as m, classifyEnumMemberType as n, instantiateAuthoringTypeConstructor as o, mergeAuthoringNamespaces as p, hasRegisteredFieldNamespace as r, isAuthoringArgRef as s, assertNoCrossRegistryCollisions as t, isAuthoringModelAttributeDescriptor as u }; | ||
| //# sourceMappingURL=framework-authoring-Rn5Cr8fF.mjs.map |
Sorry, the diff of this file is too big to display
| import { f as AnyCodecDescriptor } from "./codec-types-4tPB4m_G.mjs"; | ||
| import { i as AuthoringContributions } from "./framework-authoring-Bv5QKca9.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-B8P4PTgH.d.mts.map |
| {"version":3,"file":"framework-components-B8P4PTgH.d.mts","names":[],"sources":["../src/shared/mutation-default-types.ts","../src/shared/framework-components.ts"],"mappings":";;;;;UAMU;WACC;WACA;WACA;;UAGM;WACN,OAAO;WACP,KAAK;;UAGC;WACN;WACA;WACA;WACA,OAAO;WACP,O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KAGT,iBACV,mCACA,qCACE,yBAAyB;WAClB,UAAU;;KAGT,cACV,mCACA,qCACE,sBAAsB;WACf,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6BJ,kBAAkB,0BAA0B,kCACnD;;WAEC,UAAU;;WAGV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,iBAAiB,0BAA0B,kCAClD;;WAEC,UAAU;;WAGV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6BJ,oBAAoB,0BAA0B,kCACrD;;WAEC,UAAU;;WAGV,UAAU;;;KAIT,+BAA+B,0BAA0B,4BACjE,iBAAiB,WAAW,aAC5B,kBAAkB,WAAW,aAC7B,iBAAiB,WAAW,aAC5B,oBAAoB,WAAW;UAElB,eAAe;WACrB,UAAU;;UAGJ,eAAe,0BAA0B;WAC/C,UAAU;WACV,UAAU;;UAGJ,gBAAgB,0BAA0B;WAChD,UAAU;WACV,UAAU;;UAGJ,eAAe,0BAA0B;WAC/C,UAAU;WACV,UAAU;;UAGJ,kBAAkB,0BAA0B;WAClD,UAAU;WACV,UAAU"} |
| import { r as CodecLookup } from "./codec-types-4tPB4m_G.mjs"; | ||
| import { J as PslExtensionBlock, it as PslSpan, q as PslDiagnosticCode, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-Bv5QKca9.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-BevxxqLP.d.mts.map |
| {"version":3,"file":"psl-ast-BevxxqLP.d.mts","names":[],"sources":["../src/control/psl-ast.ts"],"mappings":";;;UA0BiB;WACN,MAAM;WACN;WACA;WACA,MAAM;;UAGA;WACN;WACA;;UAGM;WACN;WACA;;KAGC,kBAAkB,0BAA0B;KAE5C;UAEK;WACN;WACA;WACA,MAAM;;UAGA;WACN;WACA;WACA;WACA,MAAM;;KAGL,uBAAuB,iCAAiC;UAEnD;WACN;WACA;WACA,eAAe;WACf,MAAM;;UAGA;WACN;WACA,QAAQ;WACR;WACA,eAAe;WACf,MAAM;;KAGL;KAEA,oBAAoB;UAEf;WACN;WACA;;WAEA;;WAEA;;;;;;;;;WASA;WACA,kBAAkB;WAClB;WACA;WACA;WACA,qBAAqB;WACrB,MAAM;;UAGA;WACN;WACA;WACA,MAAM;;UAGA;WACN;WACA;WACA,MAAM;;KAGL,oBAAoB;UAEf;WACN;WACA;WACA,iBAAiB;WACjB,qBAAqB;WACrB,MAAM;;;;;;;;WAQN;;;;;;;UAQM;WACN;WACA;WACA,iBAAiB;WACjB,qBAAqB;WACrB,MAAM;;UAGA;WACN;WACA;;;;;;WAMA;WACA,kBAAkB;WAClB,qBAAqB;WACrB,MAAM;;UAGA;WACN;WACA,uBAAuB;WACvB,MAAM;;;;;;;;;;;;;;cAeJ;;KAGD,oBAAoB,WAAW,mBAAmB;;;;;;;;;;;;UAa7C;WACN;WACA;;WAEA,SAAS,SAAS,eAAe,SAAS,eAAe;;WAEzD,iBAAiB;;WAEjB,yBAAyB;WACzB,MAAM;;;iBAwCD,iBAAiB;WACtB;WACA;WACA,SAAS,SAAS,eAAe,SAAS,eAAe;WACzD,MAAM;IACb;;;;;;iBASY,wBACd,iBAAiB,YACjB,yBAAyB,oBACzB,0BAA0B,sBACzB,SAAS,eAAe,SAAS,eAAe;UAiClC;WACN;WACA;WACA,qBAAqB;WACrB,QAAQ;WACR,MAAM;;;;;;iBAOD,cAAc,KAAK,0BAA0B;;;;iBAW7C,sBAAsB,KAAK,0BAA0B;;;;;;;;;;;cAmBxD,uBAAuB;;;;;;;;;iBAUpB,4BAA4B,IAAI,wBAAwB;UAgBvD;WACN;WACA;;;;;;;;;;;;;;;;WAgBA,sBAAsB;;;;;;;;;WAStB,cAAc;;UAGR;WACN,KAAK;WACL,sBAAsB;WACtB"} |
| import { n as runtimeError } from "./runtime-error-BA9d7XjZ.mjs"; | ||
| import { blindCast } from "@prisma-next/utils/casts"; | ||
| //#region src/shared/resolve-codec.ts | ||
| const CONTRACT_CODEC_DESCRIPTOR_MISSING = "CONTRACT.CODEC_DESCRIPTOR_MISSING"; | ||
| /** | ||
| * Look up a descriptor for `ref.codecId` using `descriptorFor`; throw | ||
| * `code` if none is found. Each plane names its own error path: the control | ||
| * plane resolves contract-stack descriptors (`CONTRACT.*`), the execution | ||
| * plane resolves at query time (`RUNTIME.*`). | ||
| */ | ||
| function resolveCodecDescriptorOrThrow(descriptorFor, ref, code) { | ||
| const descriptor = descriptorFor(ref.codecId); | ||
| if (!descriptor) throw runtimeError(code, `No codec descriptor registered for codecId '${ref.codecId}'.`, { codecId: ref.codecId }); | ||
| return descriptor; | ||
| } | ||
| /** | ||
| * Validates `ref.typeParams` against `descriptor.paramsSchema`. | ||
| * | ||
| * Parameterized codecs that omit `typeParams` have it normalized to `{}` before | ||
| * validation (mirrors `ast-codec-resolver.ts` semantics). Throws | ||
| * `RUNTIME.TYPE_PARAMS_INVALID` when the validator returns a `Promise` or | ||
| * reports issues. | ||
| */ | ||
| function validateCodecTypeParams(descriptor, ref) { | ||
| const normalized = descriptor.isParameterized && ref.typeParams === void 0 ? { | ||
| ...ref, | ||
| typeParams: {} | ||
| } : ref; | ||
| const result = blindCast(descriptor.paramsSchema["~standard"].validate(normalized.typeParams)); | ||
| if (result instanceof Promise) throw runtimeError("RUNTIME.TYPE_PARAMS_INVALID", `paramsSchema for codec '${ref.codecId}' returned a Promise; runtime validation requires a synchronous Standard Schema validator.`, { | ||
| codecId: ref.codecId, | ||
| typeParams: ref.typeParams | ||
| }); | ||
| if ("issues" in result && result.issues) { | ||
| const messages = result.issues.map((issue) => issue.message).join("; "); | ||
| throw runtimeError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid typeParams for codec '${ref.codecId}': ${messages}`, { | ||
| codecId: ref.codecId, | ||
| typeParams: ref.typeParams | ||
| }); | ||
| } | ||
| return blindCast(result).value; | ||
| } | ||
| /** | ||
| * Resolves a `Codec` instance: validates `ref.typeParams` via | ||
| * {@link validateCodecTypeParams} then calls `descriptor.factory(validated)(ctx)`. | ||
| * | ||
| * The descriptor's `factory` is typed against its own `P`; the registry erases | ||
| * `P` to `any`, so the factory is narrowed to `(params: unknown) => (ctx) => Codec` | ||
| * at the call boundary. The `paramsSchema` validates the input above before we | ||
| * forward it, so the narrowing is safe by construction. | ||
| */ | ||
| function materializeCodec(descriptor, ref, ctx) { | ||
| const validated = validateCodecTypeParams(descriptor, ref); | ||
| return blindCast(descriptor.factory)(validated)(ctx); | ||
| } | ||
| //#endregion | ||
| export { validateCodecTypeParams as i, materializeCodec as n, resolveCodecDescriptorOrThrow as r, CONTRACT_CODEC_DESCRIPTOR_MISSING as t }; | ||
| //# sourceMappingURL=resolve-codec-CHARBCXP.mjs.map |
| {"version":3,"file":"resolve-codec-CHARBCXP.mjs","names":[],"sources":["../src/shared/resolve-codec.ts"],"sourcesContent":["import { blindCast } from '@prisma-next/utils/casts';\nimport type { Codec } from './codec';\nimport type { AnyCodecDescriptor } from './codec-descriptor';\nimport type { CodecInstanceContext, CodecRef } from './codec-types';\nimport { runtimeError } from './runtime-error';\n\nexport const CONTRACT_CODEC_DESCRIPTOR_MISSING = 'CONTRACT.CODEC_DESCRIPTOR_MISSING' as const;\n\n/**\n * Look up a descriptor for `ref.codecId` using `descriptorFor`; throw\n * `code` if none is found. Each plane names its own error path: the control\n * plane resolves contract-stack descriptors (`CONTRACT.*`), the execution\n * plane resolves at query time (`RUNTIME.*`).\n */\nexport function resolveCodecDescriptorOrThrow(\n descriptorFor: (codecId: string) => AnyCodecDescriptor | undefined,\n ref: CodecRef,\n code: 'CONTRACT.CODEC_DESCRIPTOR_MISSING' | 'RUNTIME.CODEC_DESCRIPTOR_MISSING',\n): AnyCodecDescriptor {\n const descriptor = descriptorFor(ref.codecId);\n if (!descriptor) {\n throw runtimeError(code, `No codec descriptor registered for codecId '${ref.codecId}'.`, {\n codecId: ref.codecId,\n });\n }\n return descriptor;\n}\n\n/**\n * Validates `ref.typeParams` against `descriptor.paramsSchema`.\n *\n * Parameterized codecs that omit `typeParams` have it normalized to `{}` before\n * validation (mirrors `ast-codec-resolver.ts` semantics). Throws\n * `RUNTIME.TYPE_PARAMS_INVALID` when the validator returns a `Promise` or\n * reports issues.\n */\nexport function validateCodecTypeParams(descriptor: AnyCodecDescriptor, ref: CodecRef): unknown {\n const normalized =\n descriptor.isParameterized && ref.typeParams === undefined ? { ...ref, typeParams: {} } : ref;\n\n const result = blindCast<\n { value: unknown } | { issues: ReadonlyArray<{ message: string }> } | Promise<unknown>,\n 'Standard Schema validate returns unknown; the spec guarantees this union shape'\n >(descriptor.paramsSchema['~standard'].validate(normalized.typeParams));\n\n if (result instanceof Promise) {\n throw runtimeError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `paramsSchema for codec '${ref.codecId}' returned a Promise; runtime validation requires a synchronous Standard Schema validator.`,\n { codecId: ref.codecId, typeParams: ref.typeParams },\n );\n }\n\n if ('issues' in result && result.issues) {\n const messages = result.issues.map((issue) => issue.message).join('; ');\n throw runtimeError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid typeParams for codec '${ref.codecId}': ${messages}`,\n { codecId: ref.codecId, typeParams: ref.typeParams },\n );\n }\n\n return blindCast<{ value: unknown }, 'issues guard above rules out the issues branch'>(result)\n .value;\n}\n\n/**\n * Resolves a `Codec` instance: validates `ref.typeParams` via\n * {@link validateCodecTypeParams} then calls `descriptor.factory(validated)(ctx)`.\n *\n * The descriptor's `factory` is typed against its own `P`; the registry erases\n * `P` to `any`, so the factory is narrowed to `(params: unknown) => (ctx) => Codec`\n * at the call boundary. The `paramsSchema` validates the input above before we\n * forward it, so the narrowing is safe by construction.\n */\nexport function materializeCodec(\n descriptor: AnyCodecDescriptor,\n ref: CodecRef,\n ctx: CodecInstanceContext,\n): Codec {\n const validated = validateCodecTypeParams(descriptor, ref);\n return blindCast<\n (params: unknown) => (ctx: CodecInstanceContext) => Codec,\n 'registry erases P to any; paramsSchema validates input before forwarding'\n >(descriptor.factory)(validated)(ctx);\n}\n"],"mappings":";;;AAMA,MAAa,oCAAoC;;;;;;;AAQjD,SAAgB,8BACd,eACA,KACA,MACoB;CACpB,MAAM,aAAa,cAAc,IAAI,OAAO;CAC5C,IAAI,CAAC,YACH,MAAM,aAAa,MAAM,+CAA+C,IAAI,QAAQ,KAAK,EACvF,SAAS,IAAI,QACf,CAAC;CAEH,OAAO;AACT;;;;;;;;;AAUA,SAAgB,wBAAwB,YAAgC,KAAwB;CAC9F,MAAM,aACJ,WAAW,mBAAmB,IAAI,eAAe,KAAA,IAAY;EAAE,GAAG;EAAK,YAAY,CAAC;CAAE,IAAI;CAE5F,MAAM,SAAS,UAGb,WAAW,aAAa,YAAY,CAAC,SAAS,WAAW,UAAU,CAAC;CAEtE,IAAI,kBAAkB,SACpB,MAAM,aACJ,+BACA,2BAA2B,IAAI,QAAQ,6FACvC;EAAE,SAAS,IAAI;EAAS,YAAY,IAAI;CAAW,CACrD;CAGF,IAAI,YAAY,UAAU,OAAO,QAAQ;EACvC,MAAM,WAAW,OAAO,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI;EACtE,MAAM,aACJ,+BACA,iCAAiC,IAAI,QAAQ,KAAK,YAClD;GAAE,SAAS,IAAI;GAAS,YAAY,IAAI;EAAW,CACrD;CACF;CAEA,OAAO,UAAgF,MAAM,CAAC,CAC3F;AACL;;;;;;;;;;AAWA,SAAgB,iBACd,YACA,KACA,KACO;CACP,MAAM,YAAY,wBAAwB,YAAY,GAAG;CACzD,OAAO,UAGL,WAAW,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG;AACtC"} |
| //#region src/shared/runtime-error.ts | ||
| /** | ||
| * Type guard for the runtime-error envelope produced by `runtimeError`. | ||
| * | ||
| * Prefer this over duck-typing on `error.code` directly so consumers stay | ||
| * insulated from the envelope's internal shape. | ||
| */ | ||
| function isRuntimeError(error) { | ||
| return error instanceof Error && "code" in error && typeof error.code === "string" && "category" in error && "severity" in error; | ||
| } | ||
| function runtimeError(code, message, details) { | ||
| const error = Object.assign(new Error(message), { | ||
| code, | ||
| category: resolveCategory(code), | ||
| severity: "error", | ||
| ...details !== void 0 ? { details } : {} | ||
| }); | ||
| Object.defineProperty(error, "name", { | ||
| value: "RuntimeError", | ||
| configurable: true | ||
| }); | ||
| return error; | ||
| } | ||
| function resolveCategory(code) { | ||
| const prefix = code.split(".")[0] ?? "RUNTIME"; | ||
| switch (prefix) { | ||
| case "PLAN": | ||
| case "CONTRACT": | ||
| case "LINT": | ||
| case "BUDGET": | ||
| case "DRIVER": | ||
| case "MIGRATION": | ||
| case "ORM": return prefix; | ||
| default: return "RUNTIME"; | ||
| } | ||
| } | ||
| //#endregion | ||
| export { runtimeError as n, isRuntimeError as t }; | ||
| //# sourceMappingURL=runtime-error-BA9d7XjZ.mjs.map |
| {"version":3,"file":"runtime-error-BA9d7XjZ.mjs","names":[],"sources":["../src/shared/runtime-error.ts"],"sourcesContent":["export interface RuntimeErrorEnvelope extends Error {\n readonly code: string;\n readonly category:\n | 'PLAN'\n | 'CONTRACT'\n | 'LINT'\n | 'BUDGET'\n | 'RUNTIME'\n | 'DRIVER'\n | 'MIGRATION'\n | 'ORM';\n readonly severity: 'error';\n readonly details?: Record<string, unknown>;\n}\n\n/**\n * Type guard for the runtime-error envelope produced by `runtimeError`.\n *\n * Prefer this over duck-typing on `error.code` directly so consumers stay\n * insulated from the envelope's internal shape.\n */\nexport function isRuntimeError(error: unknown): error is RuntimeErrorEnvelope {\n return (\n error instanceof Error &&\n 'code' in error &&\n typeof (error as { code?: unknown }).code === 'string' &&\n 'category' in error &&\n 'severity' in error\n );\n}\n\nexport function runtimeError(\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): RuntimeErrorEnvelope {\n const error = Object.assign(new Error(message), {\n code,\n category: resolveCategory(code),\n severity: 'error' as const,\n ...(details !== undefined ? { details } : {}),\n });\n Object.defineProperty(error, 'name', { value: 'RuntimeError', configurable: true });\n return error;\n}\n\nfunction resolveCategory(code: string): RuntimeErrorEnvelope['category'] {\n const prefix = code.split('.')[0] ?? 'RUNTIME';\n switch (prefix) {\n case 'PLAN':\n case 'CONTRACT':\n case 'LINT':\n case 'BUDGET':\n case 'DRIVER':\n case 'MIGRATION':\n case 'ORM':\n return prefix;\n default:\n return 'RUNTIME';\n }\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,eAAe,OAA+C;CAC5E,OACE,iBAAiB,SACjB,UAAU,SACV,OAAQ,MAA6B,SAAS,YAC9C,cAAc,SACd,cAAc;AAElB;AAEA,SAAgB,aACd,MACA,SACA,SACsB;CACtB,MAAM,QAAQ,OAAO,OAAO,IAAI,MAAM,OAAO,GAAG;EAC9C;EACA,UAAU,gBAAgB,IAAI;EAC9B,UAAU;EACV,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;CAC7C,CAAC;CACD,OAAO,eAAe,OAAO,QAAQ;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClF,OAAO;AACT;AAEA,SAAS,gBAAgB,MAAgD;CACvE,MAAM,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC,MAAM;CACrC,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,OACH,OAAO;EACT,SACE,OAAO;CACX;AACF"} |
| import type { DiffableNode, SchemaDiffIssue } from './schema-diff'; | ||
| const PATH_DELIMITER = ' '; | ||
| function pathKey(path: readonly string[]): string { | ||
| return path.join(PATH_DELIMITER); | ||
| } | ||
| /** | ||
| * Whether an issue's op builds its subject up (create or alter) rather than | ||
| * only tearing it down. The differ sets `expected` on every create (`not-found`) | ||
| * and alter (`not-equal`) issue and leaves it absent on a pure drop | ||
| * (`not-expected`). This is the single signal the ordering law reads for edge | ||
| * direction — never `reason`. | ||
| */ | ||
| function buildsUp(issue: SchemaDiffIssue): boolean { | ||
| return issue.expected !== undefined; | ||
| } | ||
| /** | ||
| * The nearest strict-ancestor bucket of `path` — the surviving parent entity a | ||
| * child is contained by. Walks the path's proper prefixes from longest to | ||
| * shortest and returns the first prefix that maps to a bucket; a gap (a prefix | ||
| * with no bucket) is skipped so containment always attaches to the closest real | ||
| * parent. | ||
| * | ||
| * Returns a list because a path prefix can be shared by two siblings of | ||
| * different `nodeKind` (a role and a namespace named alike); linking the child | ||
| * to every candidate over-constrains safely (the extra edge points at a same- | ||
| * direction op and never forms a cycle, since a parent never depends on its | ||
| * child) rather than risk picking the wrong one. | ||
| */ | ||
| function nearestAncestors<T>( | ||
| path: readonly string[], | ||
| byPath: ReadonlyMap<string, readonly T[]>, | ||
| ): readonly T[] { | ||
| for (let end = path.length - 1; end >= 1; end -= 1) { | ||
| const bucket = byPath.get(pathKey(path.slice(0, end))); | ||
| if (bucket !== undefined) return bucket; | ||
| } | ||
| return []; | ||
| } | ||
| /** | ||
| * Orders schema-diff issues so that every dependency's op precedes its | ||
| * dependent on the way up and follows it on the way down, breaking ties | ||
| * deterministically by path. | ||
| * | ||
| * Edges come from two sources: | ||
| * - **`dependsOn` cross-links** — the resolved issue-to-issue paths the differ | ||
| * mirrors onto each issue (a node's declared structural prerequisites). A | ||
| * path that resolves to no issue in this list is skipped (the dependency is | ||
| * satisfied by reality); a path shared by two same-id/different-kind siblings | ||
| * links to every match, over-constraining safely. | ||
| * - **containment** — every issue depends on its nearest strict-ancestor issue | ||
| * (a child entity on the parent entity that owns it). Subtree coalescing has | ||
| * already removed the descendants of a whole create/drop, so this only links | ||
| * the parent/child pairs that legitimately survive together. | ||
| * | ||
| * The ordering law reads each dependent's presence for direction: an issue that | ||
| * builds up (`expected` present — a create or alter) needs its dependency | ||
| * first; a pure drop needs its dependent removed first, so the edge reverses. | ||
| * The graph is a DAG by construction (dependencies point from dependents to | ||
| * their prerequisites, and prerequisites never point back), so a cycle is a | ||
| * derivation or authoring bug: the topological sort asserts acyclicity and | ||
| * throws, naming the issues it could not place. | ||
| */ | ||
| export function orderIssuesByDependencies<TNode extends DiffableNode = DiffableNode>( | ||
| issues: readonly SchemaDiffIssue<TNode>[], | ||
| ): readonly SchemaDiffIssue<TNode>[] { | ||
| if (issues.length <= 1) return issues; | ||
| // Work with node records rather than parallel arrays indexed by number, so no | ||
| // step needs an unchecked array-index read. | ||
| type OrderNode = { | ||
| readonly issue: SchemaDiffIssue<TNode>; | ||
| /** Path key, used as the deterministic tiebreak among ready nodes. */ | ||
| readonly key: string; | ||
| /** Whether this issue builds up (create/alter) — the ordering law's direction signal. */ | ||
| readonly buildsUp: boolean; | ||
| /** Nodes that must be emitted after this one. */ | ||
| readonly outgoing: Set<OrderNode>; | ||
| inDegree: number; | ||
| }; | ||
| const nodes: OrderNode[] = issues.map((issue) => ({ | ||
| issue, | ||
| key: pathKey(issue.path), | ||
| buildsUp: buildsUp(issue), | ||
| outgoing: new Set<OrderNode>(), | ||
| inDegree: 0, | ||
| })); | ||
| const nodesByPath = new Map<string, OrderNode[]>(); | ||
| for (const node of nodes) { | ||
| const bucket = nodesByPath.get(node.key); | ||
| if (bucket === undefined) nodesByPath.set(node.key, [node]); | ||
| else bucket.push(node); | ||
| } | ||
| const addEdge = (before: OrderNode, after: OrderNode): void => { | ||
| if (before.outgoing.has(after)) return; | ||
| before.outgoing.add(after); | ||
| after.inDegree += 1; | ||
| }; | ||
| // `dependent` requires `dependency` to exist. Up (dependent builds up): the | ||
| // dependency's op runs first; down (a pure drop): the dependent's op runs | ||
| // first, so the edge reverses. | ||
| const addDependency = (dependent: OrderNode, dependency: OrderNode): void => { | ||
| if (dependent === dependency) return; | ||
| if (dependent.buildsUp) addEdge(dependency, dependent); | ||
| else addEdge(dependent, dependency); | ||
| }; | ||
| for (const node of nodes) { | ||
| for (const targetPath of node.issue.dependsOn ?? []) { | ||
| for (const target of nodesByPath.get(pathKey(targetPath)) ?? []) { | ||
| addDependency(node, target); | ||
| } | ||
| } | ||
| for (const ancestor of nearestAncestors(node.issue.path, nodesByPath)) { | ||
| addDependency(node, ancestor); | ||
| } | ||
| } | ||
| const ready: OrderNode[] = nodes.filter((node) => node.inDegree === 0); | ||
| const order: OrderNode[] = []; | ||
| while (ready.length > 0) { | ||
| // Kahn's algorithm: emit the ready node with the smallest path key, so | ||
| // independent issues come out in a stable, deterministic order. | ||
| let best: OrderNode | undefined; | ||
| for (const candidate of ready) { | ||
| if (best === undefined || candidate.key < best.key) best = candidate; | ||
| } | ||
| if (best === undefined) break; | ||
| ready.splice(ready.indexOf(best), 1); | ||
| order.push(best); | ||
| for (const next of best.outgoing) { | ||
| next.inDegree -= 1; | ||
| if (next.inDegree === 0) ready.push(next); | ||
| } | ||
| } | ||
| if (order.length !== nodes.length) { | ||
| const placed = new Set(order); | ||
| const unresolved = nodes | ||
| .filter((node) => !placed.has(node)) | ||
| .map((node) => node.issue.path.join('/')); | ||
| throw new Error( | ||
| `orderIssuesByDependencies: dependency cycle among schema-diff issues (unresolved: ${unresolved.join(', ')})`, | ||
| ); | ||
| } | ||
| return order.map((node) => node.issue); | ||
| } |
| /** | ||
| * An enumerated-value parameter: the author supplies one of `values`, spelled | ||
| * as a bare token in PSL and a string literal in TypeScript. Shared by the | ||
| * extension-block parameter vocabulary (`PslBlockParamOption`) and the helper | ||
| * argument vocabulary (`AuthoringArgumentDescriptor`) so the option concept is | ||
| * declared once. See ADR 239. | ||
| */ | ||
| export interface AuthoringOption { | ||
| readonly kind: 'option'; | ||
| readonly values: readonly string[]; | ||
| } |
@@ -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-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 }; | ||
| import { $ as PslExtensionBlockParamOption, A as instantiateAuthoringFieldPreset, B as resolveEnumCodecId, C as AuthoringTypeConstructorDescriptor, D as classifyEnumMemberType, E as assertNoCrossRegistryCollisions, F as isAuthoringModelAttributeDescriptor, G as PslBlockParamRef, H as PslBlockParam, I as isAuthoringPslBlockDescriptor, J as PslExtensionBlock, K as PslBlockParamValue, L as isAuthoringTypeConstructorDescriptor, M as isAuthoringArgRef, N as isAuthoringEntityTypeDescriptor, O as hasRegisteredFieldNamespace, P as isAuthoringFieldPresetDescriptor, Q as PslExtensionBlockParamList, R as mergeAuthoringNamespaces, S as AuthoringTemplateValue, T as AuthoringTypeNamespace, U as PslBlockParamList, V as validateAuthoringHelperArguments, W as PslBlockParamOption, _ as AuthoringModelAttributeLoweringOutput, a as AuthoringDiagnosticSink, at as AuthoringOption, b as AuthoringSelectRef, c as AuthoringEntityTypeFactoryOutput, d as AuthoringFieldNamespace, et as PslExtensionBlockParamRef, f as AuthoringFieldPresetDescriptor, g as AuthoringModelAttributeDescriptorNamespace, h as AuthoringModelAttributeDescriptor, i as AuthoringContributions, j as instantiateAuthoringTypeConstructor, k as instantiateAuthoringEntityType, l as AuthoringEntityTypeNamespace, m as AuthoringModelAttributeContext, n as AuthoringArgumentDescriptor, nt as PslExtensionBlockParamValue, o as AuthoringEntityContext, p as AuthoringFieldPresetOutput, r as AuthoringColumnDefaultTemplate, s as AuthoringEntityTypeDescriptor, t as AuthoringArgRef, tt as PslExtensionBlockParamScalarValue, u as AuthoringEntityTypeTemplateOutput, v as AuthoringPslBlockDescriptor, w as AuthoringTypeConstructorEntityRef, x as AuthoringStorageTypeTemplate, y as AuthoringPslBlockDescriptorNamespace, z as resolveAuthoringTemplateValue } from "./framework-authoring-Bv5QKca9.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 AuthoringOption, type AuthoringPslBlockDescriptor, type AuthoringPslBlockDescriptorNamespace, type AuthoringSelectRef, 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 instantiateAuthoringFieldPreset, c as isAuthoringEntityTypeDescriptor, d as isAuthoringPslBlockDescriptor, f as isAuthoringTypeConstructorDescriptor, g as validateAuthoringHelperArguments, h as resolveEnumCodecId, i as instantiateAuthoringEntityType, l as isAuthoringFieldPresetDescriptor, m as resolveAuthoringTemplateValue, n as classifyEnumMemberType, o as instantiateAuthoringTypeConstructor, p as mergeAuthoringNamespaces, r as hasRegisteredFieldNamespace, s as isAuthoringArgRef, t as assertNoCrossRegistryCollisions, u as isAuthoringModelAttributeDescriptor } from "./framework-authoring-Bz_vaNZw.mjs"; | ||
| import { a as instantiateAuthoringFieldPreset, c as isAuthoringEntityTypeDescriptor, d as isAuthoringPslBlockDescriptor, f as isAuthoringTypeConstructorDescriptor, g as validateAuthoringHelperArguments, h as resolveEnumCodecId, i as instantiateAuthoringEntityType, l as isAuthoringFieldPresetDescriptor, m as resolveAuthoringTemplateValue, n as classifyEnumMemberType, o as instantiateAuthoringTypeConstructor, p as mergeAuthoringNamespaces, r as hasRegisteredFieldNamespace, s as isAuthoringArgRef, t as assertNoCrossRegistryCollisions, u as isAuthoringModelAttributeDescriptor } from "./framework-authoring-Rn5Cr8fF.mjs"; | ||
| export { assertNoCrossRegistryCollisions, classifyEnumMemberType, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, mergeAuthoringNamespaces, resolveAuthoringTemplateValue, resolveEnumCodecId, validateAuthoringHelperArguments }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"capabilities-Cupq4-1-.d.mts","names":[],"sources":["../src/shared/capabilities.ts"],"mappings":";;AAWA;;;;AAAoD;AA0DpD;;KA1DY,gBAAA,GAAmB,MAAM,SAAS,MAAA;;;;;;;;;;;;;;;;;AA6DtB;iBAHR,uBAAA,CACd,IAAA,EAAM,MAAA,SAAe,MAAA,oBACrB,YAAA,EAAc,aAAA;EAAA,SAAyB,YAAA;AAAA,KACtC,MAAA,SAAe,MAAA"} | ||
| {"version":3,"file":"capabilities-Cupq4-1-.d.mts","names":[],"sources":["../src/shared/capabilities.ts"],"mappings":";;;;;;;;;KAWY,mBAAmB,eAAe;;;;;;;;;;;;;;;;;;iBA0D9B,wBACd,MAAM,eAAe,0BACrB,cAAc;WAAyB;KACtC,eAAe"} |
+1
-2
@@ -1,4 +0,3 @@ | ||
| 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 { 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-4tPB4m_G.mjs"; | ||
| import { JsonValue, ValueSetRef } from "@prisma-next/contract/types"; | ||
| //#region src/shared/column-spec.d.ts | ||
@@ -5,0 +4,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"codec.d.mts","names":[],"sources":["../src/shared/column-spec.ts","../src/shared/render-ts-literal.ts","../src/shared/resolve-codec.ts"],"mappings":";;;;;;;;;;;KAmBY,oBAAA;EAAA,SACD,OAAA,EAAS,QAAA;EAAA,SACT,UAAA;EAAA,SACA,UAAA,GAAa,MAAA;EAAA,SACb,OAAA;EAUA;;;AAAqB;AAUhC;;;;EAVW,SADA,QAAA,GAAW,WAAA;EAAA,SACX,SAAA,GAAY,SAAA;AAAA;;AAaN;AAQjB;;;;;KAXY,SAAA;EAAA,SACD,UAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;AAAA;;;;;;UAQM,UAAA,cAAwB,MAAA,uCAC/B,oBAAA;EAAA,SACC,YAAA,GAAe,GAAA,EAAK,oBAAA,KAAyB,CAAA;EAAA,SAC7C,UAAA,EAAY,CAAA;AAAA;;;AAAC;AAQxB;;iBAAgB,MAAA,cAAoB,MAAA,+BAClC,YAAA,GAAe,GAAA,EAAK,oBAAA,KAAyB,CAAA,EAC7C,OAAA,UACA,UAAA,EAAY,CAAA,EACZ,UAAA,WACC,UAAA,CAAW,CAAA,EAAG,CAAA;;;;;;KAeL,eAAA,WAA0B,eAAA,aAEjC,IAAA,YACA,UAAA,UAAoB,kBAAA,CAAmB,CAAA;;;;KAMhC,qBAAA,WAAgC,eAAA,aAEvC,IAAA,YACA,UAAA,CAAW,UAAA,CAAW,UAAA,CAAW,CAAA,eAAgB,kBAAA,CAAmB,CAAA;;;;KAMpE,kBAAA,WAA6B,eAAA,SAChC,UAAA,CAAW,CAAA,wBAAyB,MAAA,oBAChC,UAAA,CAAW,CAAA;;;;;;AAtFjB;;;;;;;;;;iBCJgB,eAAA,CAAgB,KAAgB,EAAT,SAAS;;;cCTnC,iCAAA;AFab;;;;;;AAAA,iBELgB,6BAAA,CACd,aAAA,GAAgB,OAAA,aAAoB,kBAAA,cACpC,GAAA,EAAK,QAAA,EACL,IAAA,6EACC,kBAAA;;;;;;;;;iBAkBa,uBAAA,CAAwB,UAAA,EAAY,kBAAA,EAAoB,GAAA,EAAK,QAAQ;;;;;;AFHrD;AAUhC;;;iBEgCgB,gBAAA,CACd,UAAA,EAAY,kBAAA,EACZ,GAAA,EAAK,QAAA,EACL,GAAA,EAAK,oBAAA,GACJ,KAAA"} | ||
| {"version":3,"file":"codec.d.mts","names":[],"sources":["../src/shared/column-spec.ts","../src/shared/render-ts-literal.ts","../src/shared/resolve-codec.ts"],"mappings":";;;;;;;;;;KAmBY,qBAAqB;WACtB,SAAS;WACT;WACA,aAAa;WACb;;;;;;;;;WASA,WAAW;WACX,YAAY;;;;;;;;;KAUX;WACD;WACA;WACA;;;;;;;UAQM,WAAW,GAAG,UAAU,6CAC/B;WACC,eAAe,KAAK,yBAAyB;WAC7C,YAAY;;;;;;;iBAQP,OAAO,GAAG,UAAU,qCAClC,eAAe,KAAK,yBAAyB,GAC7C,iBACA,YAAY,GACZ,qBACC,WAAW,GAAG;;;;;;KAeL,gBAAgB,UAAU,4BAEjC,gBACA,oBAAoB,mBAAmB;;;;KAMhC,sBAAsB,UAAU,4BAEvC,gBACA,WAAW,WAAW,WAAW,gBAAgB,mBAAmB;;;;KAMpE,mBAAmB,UAAU,wBAChC,WAAW,yBAAyB,0BAChC,WAAW;;;;;;;;;;;;;;;;iBC1FD,gBAAgB,OAAO;;;cCT1B;;;;;;;iBAQG,8BACd,gBAAgB,oBAAoB,gCACpC,KAAK,UACL,iFACC;;;;;;;;;iBAkBa,wBAAwB,YAAY,oBAAoB,KAAK;;;;;;;;;;iBAuC7D,iBACd,YAAY,oBACZ,KAAK,UACL,KAAK,uBACJ"} |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { i as validateCodecTypeParams, n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-D8EPZosv.mjs"; | ||
| import { i as validateCodecTypeParams, n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-CHARBCXP.mjs"; | ||
| //#region src/shared/codec.ts | ||
@@ -3,0 +3,0 @@ /** |
| 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-D1rRo9Oa.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-B8P4PTgH.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,1 +0,1 @@ | ||
| {"version":3,"file":"control.d.mts","names":[],"sources":["../src/control/contract-serializer.ts","../src/control/schema-diff.ts","../src/control/control-operation-results.ts","../src/control/control-instances.ts","../src/control/control-migration-types.ts","../src/control/control-spaces.ts","../src/control/control-stack.ts","../src/control/control-descriptors.ts","../src/control/control-operation-preview.ts","../src/control/control-schema-view.ts","../src/control/control-capabilities.ts","../src/control/schema-verifier.ts","../src/control/verifier-disposition.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;UAAiB,kBAAA;EAYsD;;;;;;;;;;;EAArE,mBAAA,WAA8B,SAAA,GAAY,SAAA,EAAW,IAAA,YAAgB,CAAA;EAAhB;;;;;;;;;EAWrD,iBAAA,CAAkB,QAAA,EAAU,SAAA,GAAY,UAAA;EAkBN;AAAA;;;;AC1DpC;;ED0DoC,SATzB,mBAAA,GAAsB,sBAAA;ECjDc;;;;;;;EAAA,SD0DpC,WAAA,GAAc,WAAA;AAAA;;;UC1DR,eAAA,eAA8B,YAAA,GAAe,YAAA;;WAEnD,IAAA;;WAEA,MAAA,EAAQ,wBAAA;;WAER,QAAA,GAAW,KAAA;;WAEX,MAAA,GAAS,KAAA;AAAA;;;;ADSpB;;;;;;;;;;;UCQiB,YAAA;EAAA,SACN,EAAA;EAAA,SACA,QAAA;EACT,SAAA,CAAU,KAAA,EAAO,YAAA;EACjB,QAAA,aAAqB,YAAY;AAAA;;;;;;;;;;iBAmDnB,WAAA,CACd,QAAA,EAAU,YAAA,EACV,MAAA,EAAQ,YAAA,YACE,eAAA;;ADzBwB;;;;AC1DpC;;;;;;cAgKa,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AA,EAAQ,OAAO;AAAA;;;;;;;UAST,kBAAA;EAAA,SACN,EAAA;EAAA,SACA,MAAA,WAAiB,eAAe;AAAA;;;KCtC/B,kBAAA;AAAA,KAEA,eAAA,GAAkB,kBAAkB;;;;;;;;;;;;AZehD;;;;;KYGY,qBAAA;;;;;;;;;;iBAiBI,sBAAA,CACd,aAAA,EAAe,aAAA,EACf,QAAA,EAAU,qBAAA,GACT,eAAA"} | ||
| {"version":3,"file":"control.d.mts","names":[],"sources":["../src/control/contract-serializer.ts","../src/control/schema-diff.ts","../src/control/control-operation-results.ts","../src/control/control-instances.ts","../src/control/control-migration-types.ts","../src/control/control-spaces.ts","../src/control/control-stack.ts","../src/control/control-descriptors.ts","../src/control/control-operation-preview.ts","../src/control/control-schema-view.ts","../src/control/control-capabilities.ts","../src/control/order-issues-by-dependencies.ts","../src/control/schema-verifier.ts","../src/control/verifier-disposition.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmBiB,mBAAmB;;;;;;;;;;;;EAYlC,oBAAoB,UAAU,YAAY,WAAW,gBAAgB;;;;;;;;;;EAWrE,kBAAkB,UAAU,YAAY;;;;;;;;WAS/B,sBAAsB;;;;;;;;WAStB,cAAc;;;;;;;;;;;KCrDb;WAAoC;WAA2B;;UAE1D,gBAAgB,cAAc,eAAe;;WAEnD;;WAEA,WAAW;;WAEX,SAAS;;;;;;;;WAQT;;;;;;;;;;;;;;;;KAiBC;;;;;;;iBAQI,aAAa,OAAO,kBAAkB;;;;;;;;;;;;;;;UAyBrC;WACN;WACA;;;;;;;WAOA,qBAAqB;EAC9B,UAAU,OAAO;EACjB,qBAAqB;;;;;;;;;;;iBAiDP,YACd,UAAU,cACV,QAAQ,wBACE;;;;;;;;;;;;cAiIC,WAAW,cAAc,eAAe;WAC1C,iBAAiB,gBAAgB;cAE9B,iBAAiB,gBAAgB;;EAK7C,OAAO,OAAO,OAAO,gBAAgB,qBAAqB,WAAW;;;;cC/Q1D;cACA;cACA;cACA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;;;;;;;;;;;;;;;UCpDX,eAAe,WAAW;EACzC,aAAa,SAAS,oBAAoB,WAAW,WAAW;;;;;;;;UASjD,oBAAoB,WAAW;WACrC,UAAU;WACV,QAAQ;;;;;;;;UASF;WACN;WACA,iBAAiB;;;;KCtChB;KAEA,kBAAkB;;;;;;;;;;;;;;;;;KAkBlB;;;;;;;;;;iBAiBI,uBACd,eAAe,eACf,UAAU,wBACT"} |
+177
-11
@@ -1,4 +0,4 @@ | ||
| import { n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-D8EPZosv.mjs"; | ||
| import { n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-CHARBCXP.mjs"; | ||
| import { t as mergeCapabilityMatrices } from "./capabilities-BnRAFKP5.mjs"; | ||
| import { p as mergeAuthoringNamespaces, t as assertNoCrossRegistryCollisions } from "./framework-authoring-Bz_vaNZw.mjs"; | ||
| import { p as mergeAuthoringNamespaces, t as assertNoCrossRegistryCollisions } from "./framework-authoring-Rn5Cr8fF.mjs"; | ||
| import { blindCast } from "@prisma-next/utils/casts"; | ||
@@ -23,6 +23,6 @@ //#region src/control/control-capabilities.ts | ||
| //#region src/control/control-operation-results.ts | ||
| const VERIFY_CODE_MARKER_MISSING = "PN-RUN-3001"; | ||
| const VERIFY_CODE_HASH_MISMATCH = "PN-RUN-3002"; | ||
| const VERIFY_CODE_TARGET_MISMATCH = "PN-RUN-3003"; | ||
| const VERIFY_CODE_SCHEMA_FAILURE = "PN-RUN-3010"; | ||
| const VERIFY_CODE_MARKER_MISSING = "CONTRACT.MARKER_MISSING"; | ||
| const VERIFY_CODE_HASH_MISMATCH = "CONTRACT.MARKER_MISMATCH"; | ||
| const VERIFY_CODE_TARGET_MISMATCH = "CONTRACT.TARGET_MISMATCH"; | ||
| const VERIFY_CODE_SCHEMA_FAILURE = "CONTRACT.SCHEMA_VERIFICATION_FAILED"; | ||
| //#endregion | ||
@@ -335,3 +335,126 @@ //#region src/control/control-schema-view.ts | ||
| //#endregion | ||
| //#region src/control/order-issues-by-dependencies.ts | ||
| const PATH_DELIMITER = " "; | ||
| function pathKey(path) { | ||
| return path.join(PATH_DELIMITER); | ||
| } | ||
| /** | ||
| * Whether an issue's op builds its subject up (create or alter) rather than | ||
| * only tearing it down. The differ sets `expected` on every create (`not-found`) | ||
| * and alter (`not-equal`) issue and leaves it absent on a pure drop | ||
| * (`not-expected`). This is the single signal the ordering law reads for edge | ||
| * direction — never `reason`. | ||
| */ | ||
| function buildsUp(issue) { | ||
| return issue.expected !== void 0; | ||
| } | ||
| /** | ||
| * The nearest strict-ancestor bucket of `path` — the surviving parent entity a | ||
| * child is contained by. Walks the path's proper prefixes from longest to | ||
| * shortest and returns the first prefix that maps to a bucket; a gap (a prefix | ||
| * with no bucket) is skipped so containment always attaches to the closest real | ||
| * parent. | ||
| * | ||
| * Returns a list because a path prefix can be shared by two siblings of | ||
| * different `nodeKind` (a role and a namespace named alike); linking the child | ||
| * to every candidate over-constrains safely (the extra edge points at a same- | ||
| * direction op and never forms a cycle, since a parent never depends on its | ||
| * child) rather than risk picking the wrong one. | ||
| */ | ||
| function nearestAncestors(path, byPath) { | ||
| for (let end = path.length - 1; end >= 1; end -= 1) { | ||
| const bucket = byPath.get(pathKey(path.slice(0, end))); | ||
| if (bucket !== void 0) return bucket; | ||
| } | ||
| return []; | ||
| } | ||
| /** | ||
| * Orders schema-diff issues so that every dependency's op precedes its | ||
| * dependent on the way up and follows it on the way down, breaking ties | ||
| * deterministically by path. | ||
| * | ||
| * Edges come from two sources: | ||
| * - **`dependsOn` cross-links** — the resolved issue-to-issue paths the differ | ||
| * mirrors onto each issue (a node's declared structural prerequisites). A | ||
| * path that resolves to no issue in this list is skipped (the dependency is | ||
| * satisfied by reality); a path shared by two same-id/different-kind siblings | ||
| * links to every match, over-constraining safely. | ||
| * - **containment** — every issue depends on its nearest strict-ancestor issue | ||
| * (a child entity on the parent entity that owns it). Subtree coalescing has | ||
| * already removed the descendants of a whole create/drop, so this only links | ||
| * the parent/child pairs that legitimately survive together. | ||
| * | ||
| * The ordering law reads each dependent's presence for direction: an issue that | ||
| * builds up (`expected` present — a create or alter) needs its dependency | ||
| * first; a pure drop needs its dependent removed first, so the edge reverses. | ||
| * The graph is a DAG by construction (dependencies point from dependents to | ||
| * their prerequisites, and prerequisites never point back), so a cycle is a | ||
| * derivation or authoring bug: the topological sort asserts acyclicity and | ||
| * throws, naming the issues it could not place. | ||
| */ | ||
| function orderIssuesByDependencies(issues) { | ||
| if (issues.length <= 1) return issues; | ||
| const nodes = issues.map((issue) => ({ | ||
| issue, | ||
| key: pathKey(issue.path), | ||
| buildsUp: buildsUp(issue), | ||
| outgoing: /* @__PURE__ */ new Set(), | ||
| inDegree: 0 | ||
| })); | ||
| const nodesByPath = /* @__PURE__ */ new Map(); | ||
| for (const node of nodes) { | ||
| const bucket = nodesByPath.get(node.key); | ||
| if (bucket === void 0) nodesByPath.set(node.key, [node]); | ||
| else bucket.push(node); | ||
| } | ||
| const addEdge = (before, after) => { | ||
| if (before.outgoing.has(after)) return; | ||
| before.outgoing.add(after); | ||
| after.inDegree += 1; | ||
| }; | ||
| const addDependency = (dependent, dependency) => { | ||
| if (dependent === dependency) return; | ||
| if (dependent.buildsUp) addEdge(dependency, dependent); | ||
| else addEdge(dependent, dependency); | ||
| }; | ||
| for (const node of nodes) { | ||
| for (const targetPath of node.issue.dependsOn ?? []) for (const target of nodesByPath.get(pathKey(targetPath)) ?? []) addDependency(node, target); | ||
| for (const ancestor of nearestAncestors(node.issue.path, nodesByPath)) addDependency(node, ancestor); | ||
| } | ||
| const ready = nodes.filter((node) => node.inDegree === 0); | ||
| const order = []; | ||
| while (ready.length > 0) { | ||
| let best; | ||
| for (const candidate of ready) if (best === void 0 || candidate.key < best.key) best = candidate; | ||
| if (best === void 0) break; | ||
| ready.splice(ready.indexOf(best), 1); | ||
| order.push(best); | ||
| for (const next of best.outgoing) { | ||
| next.inDegree -= 1; | ||
| if (next.inDegree === 0) ready.push(next); | ||
| } | ||
| } | ||
| if (order.length !== nodes.length) { | ||
| const placed = new Set(order); | ||
| const unresolved = nodes.filter((node) => !placed.has(node)).map((node) => node.issue.path.join("/")); | ||
| throw new Error(`orderIssuesByDependencies: dependency cycle among schema-diff issues (unresolved: ${unresolved.join(", ")})`); | ||
| } | ||
| return order.map((node) => node.issue); | ||
| } | ||
| //#endregion | ||
| //#region src/control/schema-diff.ts | ||
| /** | ||
| * The outcome an issue represents, discriminated by presence rather than any | ||
| * stored field — the single source of truth every consumer reads. An issue | ||
| * always carries at least one side by construction; neither is a malformed | ||
| * issue and throws. | ||
| */ | ||
| function issueOutcome(issue) { | ||
| const hasExpected = issue.expected !== void 0; | ||
| const hasActual = issue.actual !== void 0; | ||
| if (hasExpected && hasActual) return "not-equal"; | ||
| if (hasExpected) return "not-found"; | ||
| if (hasActual) return "not-expected"; | ||
| throw new Error(`issueOutcome: issue at "${issue.path.join("/")}" carries neither an expected nor an actual node`); | ||
| } | ||
| /** Delimiter joining `nodeKind` and `id` into one sibling-map key. Every `nodeKind` is a code-defined literal (kebab-case-style), so a null character can never appear in one. */ | ||
@@ -351,3 +474,2 @@ const SIBLING_KEY_DELIMITER = "\0"; | ||
| path, | ||
| reason: "not-found", | ||
| expected: node | ||
@@ -360,3 +482,2 @@ }, ...node.children().flatMap((c) => emitMissingSubtree(c, path))]; | ||
| path, | ||
| reason: "not-expected", | ||
| actual: node | ||
@@ -375,4 +496,50 @@ }, ...node.children().flatMap((c) => emitExtraSubtree(c, path))]; | ||
| function diffSchemas(expected, actual) { | ||
| return diffPair(expected, actual, []); | ||
| return mirrorDependsOnOntoIssues(diffPair(expected, actual, [])); | ||
| } | ||
| function schemaNodeRefKey(ref) { | ||
| return ref.map((step) => step.id).join(SIBLING_KEY_DELIMITER); | ||
| } | ||
| function issuePathKey(path) { | ||
| return path.join(SIBLING_KEY_DELIMITER); | ||
| } | ||
| function terminalNodeKind(issue) { | ||
| return (issue.expected ?? issue.actual)?.nodeKind; | ||
| } | ||
| /** | ||
| * Copies each issue's node's `dependsOn` refs onto the issue itself, as | ||
| * issue-to-issue path references. A ref is kept only when some emitted issue | ||
| * sits at that exact path AND that issue's node `nodeKind` matches the ref's | ||
| * last step — otherwise the ref is dropped (its target either didn't | ||
| * change, or was never part of either tree; either way the dependency is | ||
| * satisfied by reality, not by an operation this diff will produce). | ||
| * | ||
| * The path index is a multimap: two siblings may share an `id` under | ||
| * different `nodeKind`s (a role and a namespace named alike), so an id-path | ||
| * alone is ambiguous. The ref's terminal `nodeKind` disambiguates — the ref | ||
| * resolves only against a same-path issue whose own node carries that kind. | ||
| */ | ||
| function mirrorDependsOnOntoIssues(issues) { | ||
| const issuesByPath = /* @__PURE__ */ new Map(); | ||
| for (const issue of issues) { | ||
| const key = issuePathKey(issue.path); | ||
| const bucket = issuesByPath.get(key); | ||
| if (bucket === void 0) issuesByPath.set(key, [issue]); | ||
| else bucket.push(issue); | ||
| } | ||
| return issues.map((issue) => { | ||
| const refs = (issue.expected ?? issue.actual)?.dependsOn; | ||
| if (refs === void 0 || refs.length === 0) return issue; | ||
| const dependsOn = refs.flatMap((ref) => { | ||
| const lastStep = ref[ref.length - 1]; | ||
| if (lastStep === void 0) return []; | ||
| if (!(issuesByPath.get(schemaNodeRefKey(ref)) ?? []).some((c) => terminalNodeKind(c) === lastStep.nodeKind)) return []; | ||
| return [ref.map((step) => step.id)]; | ||
| }); | ||
| if (dependsOn.length === 0) return issue; | ||
| return { | ||
| ...issue, | ||
| dependsOn | ||
| }; | ||
| }); | ||
| } | ||
| function diffPair(expected, actual, parentPath) { | ||
@@ -383,3 +550,2 @@ const path = [...parentPath, expected.id]; | ||
| path, | ||
| reason: "not-equal", | ||
| expected, | ||
@@ -454,4 +620,4 @@ actual | ||
| //#endregion | ||
| export { APP_SPACE_ID, SchemaDiff, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, assembleAuthoringContributions, assembleControlMutationDefaults, assembleScalarTypeDescriptors, assertUniqueCodecOwner, buildExtensionLoadOrder, createControlStack, diffSchemas, dispositionForCategory, extractCodecLookup, extractCodecTypeImports, extractComponentIds, extractQueryOperationTypeImports, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView }; | ||
| export { APP_SPACE_ID, SchemaDiff, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, assembleAuthoringContributions, assembleControlMutationDefaults, assembleScalarTypeDescriptors, assertUniqueCodecOwner, buildExtensionLoadOrder, createControlStack, diffSchemas, dispositionForCategory, extractCodecLookup, extractCodecTypeImports, extractComponentIds, extractQueryOperationTypeImports, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView, issueOutcome, orderIssuesByDependencies }; | ||
| //# sourceMappingURL=control.mjs.map |
| import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs"; | ||
| import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-BQMFUNQO.mjs"; | ||
| import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-T3r8La7q.mjs"; | ||
| export type { EmissionSpi, GenerateContractTypesOptions, TypesImportSpec, ValidationContext }; |
@@ -1,3 +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-D1rRo9Oa.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-B8P4PTgH.mjs"; | ||
| //#region src/execution/execution-instances.d.ts | ||
@@ -67,9 +66,3 @@ interface RuntimeFamilyInstance<TFamilyId extends string> extends FamilyInstance<TFamilyId> {} | ||
| //#region src/execution/execution-requirements.d.ts | ||
| declare function assertRuntimeContractRequirementsSatisfied<TFamilyId extends string, TTargetId extends string>({ | ||
| contract, | ||
| family, | ||
| target, | ||
| adapter, | ||
| extensionPacks | ||
| }: { | ||
| declare function assertRuntimeContractRequirementsSatisfied<TFamilyId extends string, TTargetId extends string>({ contract, family, target, adapter, extensionPacks }: { | ||
| readonly contract: { | ||
@@ -76,0 +69,0 @@ readonly target: string; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution/execution-instances.ts","../src/execution/execution-stack.ts","../src/execution/execution-descriptors.ts","../src/execution/execution-requirements.ts"],"mappings":";;;UAQiB,qBAAA,mCACP,cAAc,CAAC,SAAA;AAAA,UAER,qBAAA,6DACP,cAAA,CAAe,SAAA,EAAW,SAAA;AAAA,UAEnB,sBAAA,6DACP,eAAA,CAAgB,SAAA,EAAW,SAAA;AAAA,UAEpB,qBAAA,6DACP,cAAA,CAAe,SAAA,EAAW,SAAA;AAAA,UAEnB,wBAAA,6DACP,iBAAA,CAAkB,SAAA,EAAW,SAAA;;;UCRtB,cAAA,8EAGU,sBAAA,CAAuB,SAAA,EAAW,SAAA,IAAa,sBAAA,CACtE,SAAA,EACA,SAAA,2BAEsB,qBAAA,CAAsB,SAAA,EAAW,SAAA,IAAa,qBAAA,CACpE,SAAA,EACA,SAAA,8BAEyB,wBAAA,CACzB,SAAA,EACA,SAAA,IACE,wBAAA,CAAyB,SAAA,EAAW,SAAA;EAAA,SAE/B,MAAA,EAAQ,uBAAA,CAAwB,SAAA,EAAW,SAAA;EAAA,SAC3C,OAAA,EAAS,wBAAA,CAAyB,SAAA,E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AA,CAAO,KAAA,EAAO,cAAA,CAAe,SAAA,EAAW,SAAA,IAAa,gBAAA;AAAA;AAAA,UAGtC,uBAAA,oGAIS,qBAAA,CAAsB,SAAA,EAAW,SAAA,IAAa,qBAAA,CACpE,SAAA,EACA,SAAA,WAEM,gBAAA,CAAiB,SAAA,EAAW,SAAA;EACpC,MAAA,CAAO,OAAA,GAAU,cAAA,GAAiB,eAAA;AAAA;AAAA,UAGnB,0BAAA,gFAGY,wBAAA,CACzB,SAAA,EACA,SAAA,IACE,wBAAA,CAAyB,SAAA,EAAW,SAAA,WAChC,mBAAA,CAAoB,SAAA,EAAW,SAAA;EACvC,MAAA,IAAU,kBAAA;AAAA;;;iBCrEI,0CAAA;EAId,QAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;EACA;AAAA;EAAA,SAES,QAAA;IAAA,SAAqB,MAAA;IAAA,SAAyB,cAAA,GAAiB,MAAA;EAAA;EAAA,SAC/D,MAAA,EAAQ,uBAAA,CAAwB,SAAA;EAAA,SAChC,MAAA,EAAQ,uBAAA,CAAwB,SAAA,EAAW,SAAA;EAAA,SAC3C,OAAA,EAAS,wBAAA,CAAyB,SAAA,EAAW,SAAA;EAAA,SAC7C,cAAA,WAAyB,0BAAA,CAA2B,SAAA,EAAW,SAAA;AAAA"} | ||
| {"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution/execution-instances.ts","../src/execution/execution-stack.ts","../src/execution/execution-descriptors.ts","../src/execution/execution-requirements.ts"],"mappings":";;UAQiB,sBAAsB,kCAC7B,eAAe;UAER,sBAAsB,0BAA0B,kCACvD,eAAe,WAAW;UAEnB,uBAAuB,0BAA0B,kCACxD,gBAAgB,WAAW;UAEpB,sBAAsB,0BAA0B,kCACvD,eAAe,WAAW;UAEnB,yBAAyB,0BAA0B,kCAC1D,kBAAkB,WAAW;;;UCRtB,eACf,0BACA,0BACA,yBAAyB,uBAAuB,WAAW,aAAa,uBACtE,WACA,YAEF,wBAAwB,sBAAsB,WAAW,aAA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,WAAW;aAC7C,QAAQ,wBAAwB,WAAW;aAC3C,yBAAyB,2BAA2B,WAAW;MACtE;;UAGW,wBACf,0BACA,0BACA,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,oBAEM,iBAAiB,WAAW;EACpC,UAAU;;UAGK,yBACf,0BACA,0BACA,yBAAyB,uBAAuB,WAAW,aAAa,uBACtE,WACA,oBAEM,kBAAkB,WAAW;;;;;;;;EAQrC,OAAO,OAAO,eAAe,WAAW,aAAa;;UAGtC,wBACf,0BACA,0BACA,uBACA,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,oBAEM,iBAAiB,WAAW;EACpC,OAAO,UAAU,iBAAiB;;UAGnB,2BACf,0BACA,0BACA,2BAA2B,yBACzB,WACA,aACE,yBAAyB,WAAW,oBAChC,oBAAoB,WAAW;EACvC,UAAU;;;;iBCrEI,2CACd,0BACA,4BAEA,UACA,QACA,QACA,SACA;WAES;aAAqB;aAAyB,iBAAiB;;WAC/D,QAAQ,wBAAwB;WAChC,QAAQ,wBAAwB,WAAW;WAC3C,SAAS,yBAAyB,WAAW;WAC7C,yBAAyB,2BAA2B,WAAW"} |
+3
-4
| import { ApplicationDomain, StorageBase, StorageNamespace } from "@prisma-next/contract/types"; | ||
| import { isPlainRecord } from "@prisma-next/contract/is-plain-record"; | ||
| import { Type } from "arktype"; | ||
| //#region src/ir/ir-node.d.ts | ||
@@ -264,4 +263,4 @@ /** | ||
| */ | ||
| type SingleNamespaceView<TEntries, TBuiltinKinds extends string> = { readonly [K in TBuiltinKinds]-?: K extends keyof TEntries ? NonNullable<TEntries[K]> : Record<string, never> } & { | ||
| readonly entries: { readonly [K in Exclude<keyof TEntries, TBuiltinKinds | number | symbol> as string extends K ? never : K]: TEntries[K] }; | ||
| type SingleNamespaceView<TEntries, TBuiltinKinds extends string> = { readonly [K in TBuiltinKinds]-?: K extends keyof TEntries ? NonNullable<TEntries[K]> : Record<string, never>; } & { | ||
| readonly entries: { readonly [K in Exclude<keyof TEntries, TBuiltinKinds | number | symbol> as string extends K ? never : K]: TEntries[K]; }; | ||
| }; | ||
@@ -283,3 +282,3 @@ /** The `entries` shape of one namespace in a storage map. */ | ||
| readonly namespaces: object; | ||
| }, TBuiltinKinds extends string> = { readonly [Ns in keyof TStorage['namespaces']]: SingleNamespaceView<EntriesOf<TStorage['namespaces'][Ns]>, TBuiltinKinds> }; | ||
| }, TBuiltinKinds extends string> = { readonly [Ns in keyof TStorage['namespaces']]: SingleNamespaceView<EntriesOf<TStorage['namespaces'][Ns]>, TBuiltinKinds>; }; | ||
| /** | ||
@@ -286,0 +285,0 @@ * Projects one namespace's `entries` into the view shape: each built-in kind |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"ir.d.mts","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/storage.ts","../src/ir/contract-view.ts","../src/ir/domain.ts","../src/ir/entity-kind.ts","../src/ir/storage-type.ts"],"mappings":";;;;;;;;;;AAyCA;;;;AACe;AAGf;;;;AACwB;AAYxB;;;;;;;;;;;;;;AAAwD;;;;AChCxD;;;;AAA0D;AAkC1D;;UDnBiB,MAAA;EAAA,SACN,IAAI;AAAA;AAAA,uBAGO,UAAA,YAAsB,MAAM;EAAA,kBAC9B,IAAI;AAAA;;;;;;;;;;iBAYR,UAAA,WAAqB,MAAA,EAAQ,IAAA,EAAM,CAAA,GAAI,CAAA;;;;;;AAjBvD;;;;AACe;AAGf;;;;AACwB;AAYxB;;;;;;;;;;cChCa,oBAAA;;;;ADgC2C;;;;AChCxD;;;;AAA0D;AAkC1D;;;;;;;;;;;;;;;;;;;;UAAiB,SAAA,SAAkB,MAAA,EAAQ,gBAAA;EAAA,SAChC,IAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;EAUjB;;;;;;EAAA,SAHzB,SAAA;AAAA;AAAA,uBAGW,aAAA,SAAsB,UAAA,YAAsB,SAAA;EAAA,kBAC9C,EAAA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A,CAC7C,SAAA,CAAU,QAAA,eAAuB,EAAA,IACjC,aAAA;;;;;;;iBAUY,mBAAA,QACd,OAAA,EAAS,QAAA,CAAS,MAAA,oBAClB,YAAA,sBACC,KAAA;AFHiB;AAGpB;;;;;;AAHoB,iBE+BJ,wBAAA,QACd,OAAA,EAAS,OAAA,EACT,YAAA,sBACC,KAAK;;;;;;iBAiBQ,uBAAA,OACd,OAAA,EAAS,OAAA,EACT,YAAA,sBACC,IAAI;;;;;;AHlFP;;;;iBI/BiB,wBAAA,CACf,MAAA,EAAQ,IAAA,CAAK,iBAAA,kBACZ,SAAA,CAAU,gBAAA;;;UCTI,oBAAA;EAAA,SACN,IAAA;EAAA,SAEA,MAAA,EAAQ,IAAA;EAAA,SACR,SAAA,GAAY,KAAA,EAAO,KAAA,KAAU,IAAA;AAAA;AAAA,KAG5B,uBAAA,GAA0B,oBAAoB;;;ALgC3C;AAGf;;;;AACwB;AAYxB;;;;iBKlCgB,wBAAA,CACd,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA,sBAC1C,KAAA,EAAO,WAAA,SAAoB,uBAAA,GAC3B,SAAA,oBACA,IAAA,YACC,MAAA,SAAe,QAAA,CAAS,MAAA;;;;;;;ALY3B;;;;AACe;AAGf;;;;AACwB;AAYxB;;;;UMtCiB,WAAA,SAAoB,MAAM;EAAA,SAChC,IAAI;AAAA"} | ||
| {"version":3,"file":"ir.d.mts","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/storage.ts","../src/ir/contract-view.ts","../src/ir/domain.ts","../src/ir/entity-kind.ts","../src/ir/storage-type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAyCiB;WACN;;uBAGW,sBAAsB;oBACxB;;;;;;;;;;;iBAYJ,WAAW,UAAU,QAAQ,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;cChC1C;;;;;;;;;;;;;;;;;;;;;;;;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BAAoB;WAC1B"} |
@@ -1,5 +0,4 @@ | ||
| 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"; | ||
| import { r as CodecLookup } from "./codec-types-4tPB4m_G.mjs"; | ||
| import { $ as PslExtensionBlockParamOption, G as PslBlockParamRef, H as PslBlockParam, J as PslExtensionBlock, K as PslBlockParamValue, Q as PslExtensionBlockParamList, U as PslBlockParamList, W as PslBlockParamOption, X as PslExtensionBlockAttributeArg, Y as PslExtensionBlockAttribute, Z as PslExtensionBlockParamBare, et as PslExtensionBlockParamRef, it as PslSpan, nt as PslExtensionBlockParamValue, q as PslDiagnosticCode, rt as PslPosition, tt as PslExtensionBlockParamScalarValue, v as AuthoringPslBlockDescriptor, y as AuthoringPslBlockDescriptorNamespace } from "./framework-authoring-Bv5QKca9.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-BevxxqLP.mjs"; | ||
| //#region src/control/psl-extension-block-validator.d.ts | ||
@@ -6,0 +5,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"psl-ast.d.mts","names":[],"sources":["../src/control/psl-extension-block-validator.ts"],"mappings":";;;;;;;;;;;;;UA2EiB,kCAAA;EAAA,SACN,cAAA,EAAgB,YAAA;EAAA,SAChB,aAAA,WAAwB,YAAY;AAAA;;;;;;;;;;;;;;;;;iBAmB/B,sBAAA,CACd,IAAA,EAAM,iBAAA,EACN,UAAA,EAAY,2BAAA,EACZ,QAAA,UACA,WAAA,EAAa,WAAA,EACb,MAAA,GAAS,kCAAA,YACC,aAAA"} | ||
| {"version":3,"file":"psl-ast.d.mts","names":[],"sources":["../src/control/psl-extension-block-validator.ts"],"mappings":";;;;;;;;;;;;UA2EiB;WACN,gBAAgB;WAChB,wBAAwB;;;;;;;;;;;;;;;;;;iBAmBnB,uBACd,MAAM,mBACN,YAAY,6BACZ,kBACA,aAAa,aACb,SAAS,8CACC"} |
@@ -1,4 +0,3 @@ | ||
| import { t as CodecCallContext } from "./codec-types-e32YHT3D.mjs"; | ||
| import { t as CodecCallContext } from "./codec-types-4tPB4m_G.mjs"; | ||
| import { PlanMeta } from "@prisma-next/contract/types"; | ||
| //#region src/annotations.d.ts | ||
@@ -208,3 +207,3 @@ /** | ||
| */ | ||
| type ValidAnnotations<K extends OperationKind, As extends readonly AnnotationValue<unknown, OperationKind>[]> = { readonly [I in keyof As]: As[I] extends AnnotationValue<infer P, infer Kinds> ? K extends Kinds ? AnnotationValue<P, Kinds> : never : never }; | ||
| type ValidAnnotations<K extends OperationKind, As extends readonly AnnotationValue<unknown, OperationKind>[]> = { readonly [I in keyof As]: As[I] extends AnnotationValue<infer P, infer Kinds> ? K extends Kinds ? AnnotationValue<P, Kinds> : never : never; }; | ||
| /** | ||
@@ -624,3 +623,3 @@ * Runtime applicability gate. Throws `RUNTIME.ANNOTATION_INAPPLICABLE` if | ||
| readonly code: string; | ||
| readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME'; | ||
| readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME' | 'DRIVER' | 'MIGRATION' | 'ORM'; | ||
| readonly severity: 'error'; | ||
@@ -627,0 +626,0 @@ readonly details?: Record<string, unknown>; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/annotations.ts","../src/execution/async-iterable-result.ts","../src/execution/query-plan.ts","../src/execution/runtime-middleware.ts","../src/execution/before-execute-chain.ts","../src/shared/runtime-error.ts","../src/execution/runtime-error.ts","../src/execution/race-against-abort.ts","../src/execution/run-with-middleware.ts","../src/execution/runtime-core.ts","../src/meta-builder.ts"],"mappings":";;;;;;;;AAmBA;;;;AAAyB;AAazB;;;;;;;;KAbY,aAAA;;;;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AA4C1C;UU5CiB,WAAA,WAAsB,aAAA;EACrC,QAAA,kBAA0B,aAAA,EACxB,UAAA,EAAY,CAAA,SAAU,KAAA,GAAQ,eAAA,CAAgB,CAAA,EAAG,KAAA;AAAA;;;;;;;;;;;UAcpC,eAAA,WAA0B,aAAA,UAAuB,WAAA,CAAY,CAAA;EAAA,SACnE,WAAA,EAAa,WAAA,SAAoB,eAAA,UAAyB,aAAA;AAAA;;;;;;;;;;iBA0CrD,iBAAA,WAA4B,aAAA,EAC1C,IAAA,EAAM,CAAA,EACN,YAAA,WACC,eAAA,CAAgB,CAAA"} | ||
| {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/annotations.ts","../src/execution/async-iterable-result.ts","../src/execution/query-plan.ts","../src/execution/runtime-middleware.ts","../src/execution/before-execute-chain.ts","../src/shared/runtime-error.ts","../src/execution/runtime-error.ts","../src/execution/race-against-abort.ts","../src/execution/run-with-middleware.ts","../src/execution/runtime-core.ts","../src/meta-builder.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;KAmBY;;;;;;;;;;;;UAaK,gBAAgB,SAAS,cAAc;WAC7C;WACA;WACA,OAAO;WACP,cAAc,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4CpB,iBAAiB,SAAS,cAAc;GACtD,OAAO,UAAU,gBAAgB,SAAS;WAClC;WACA,cAAc,YAAY;EACnC,KAAK;aACM;eAAiB,cAAc;;MACtC;;;;;;;;;;;;;;;;;;;;;;;;UAyBW,wBAAwB,cAAc;WAC5C;WACA,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwClB,iBAAiB,mBAAmB,cAAc,eAChE,SAAS,wBAAwB,WAC9B,iBAAiB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6FnB,iBACV,UAAU,eACV,oBAAoB,yBAAyB,gCAEnC,WAAW,KAAK,GAAG,WAAW,sBAA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B,KAAK;cAEZ,SAAS,mBAAmB;;;;;;YAU9B,iBAAiB,MAAM,QAAQ,QAAQ,QAAQ;;;;;;;;;;;;;;qBAiBtC,MAAM,MAAM,OAAO,KAAK,mBAAmB,QAAQ,QAAQ;;;;;;;;;;;qBAY3D,UAAU,MAAM,QAAQ,cAAc;WAEhD,SAAS;EAElB,QAAQ,KACN,MAAM;aAAmB,OAAO;KAChC,UAAU,wBACT,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UC5ER,YAAY,UAAU;EACrC,SAAS,GAAG,cAAc,eACxB,YAAY,UAAU,QAAQ,gBAAgB,GAAG;;;;;;;;;;;;UAcpC,gBAAgB,UAAU,uBAAuB,YAAY;WACnE,aAAa,oBAAoB,yBAAyB;;;;;;;;;;;iBA0CrD,kBAAkB,UAAU,eAC1C,MAAM,GACN,uBACC,gBAAgB"} |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { n as runtimeError, t as isRuntimeError } from "./runtime-error-B2gWOtgH.mjs"; | ||
| import { n as runtimeError, t as isRuntimeError } from "./runtime-error-BA9d7XjZ.mjs"; | ||
| //#region src/execution/runtime-error.ts | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types-import-spec-DRKzrJ20.d.mts","names":[],"sources":["../src/shared/types-import-spec.ts"],"mappings":";;AAIA;;;UAAiB,eAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA;EAAA,SACA,KAAA;AAAA"} | ||
| {"version":3,"file":"types-import-spec-DRKzrJ20.d.mts","names":[],"sources":["../src/shared/types-import-spec.ts"],"mappings":";;;;;UAIiB;WACN;WACA;WACA"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils/canonicalize-json.ts"],"mappings":";;AAmBA;;;;iBAAgB,gBAAA,CAAiB,KAAc"} | ||
| {"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils/canonicalize-json.ts"],"mappings":";;;;;;iBAmBgB,iBAAiB"} |
+8
-8
| { | ||
| "name": "@prisma-next/framework-components", | ||
| "version": "0.15.0", | ||
| "version": "0.16.0-dev.1", | ||
| "license": "Apache-2.0", | ||
@@ -9,6 +9,6 @@ "type": "module", | ||
| "dependencies": { | ||
| "@prisma-next/contract": "0.15.0", | ||
| "@prisma-next/operations": "0.15.0", | ||
| "@prisma-next/ts-render": "0.15.0", | ||
| "@prisma-next/utils": "0.15.0", | ||
| "@prisma-next/contract": "0.16.0-dev.1", | ||
| "@prisma-next/operations": "0.16.0-dev.1", | ||
| "@prisma-next/ts-render": "0.16.0-dev.1", | ||
| "@prisma-next/utils": "0.16.0-dev.1", | ||
| "@standard-schema/spec": "^1.1.0", | ||
@@ -18,5 +18,5 @@ "arktype": "^2.2.2" | ||
| "devDependencies": { | ||
| "@prisma-next/tsconfig": "0.15.0", | ||
| "@prisma-next/tsdown": "0.15.0", | ||
| "tsdown": "0.22.3", | ||
| "@prisma-next/tsconfig": "0.16.0-dev.1", | ||
| "@prisma-next/tsdown": "0.16.0-dev.1", | ||
| "tsdown": "0.22.8", | ||
| "typescript": "5.9.3", | ||
@@ -23,0 +23,0 @@ "vitest": "4.1.10" |
| import type { SchemaDiffIssue } from './schema-diff'; | ||
| export const VERIFY_CODE_MARKER_MISSING = 'PN-RUN-3001'; | ||
| export const VERIFY_CODE_HASH_MISMATCH = 'PN-RUN-3002'; | ||
| export const VERIFY_CODE_TARGET_MISMATCH = 'PN-RUN-3003'; | ||
| export const VERIFY_CODE_SCHEMA_FAILURE = 'PN-RUN-3010'; | ||
| export const VERIFY_CODE_MARKER_MISSING = 'CONTRACT.MARKER_MISSING'; | ||
| export const VERIFY_CODE_HASH_MISMATCH = 'CONTRACT.MARKER_MISMATCH'; | ||
| export const VERIFY_CODE_TARGET_MISMATCH = 'CONTRACT.TARGET_MISMATCH'; | ||
| export const VERIFY_CODE_SCHEMA_FAILURE = 'CONTRACT.SCHEMA_VERIFICATION_FAILED'; | ||
@@ -42,16 +42,2 @@ export interface OperationContext { | ||
| /** | ||
| * The three ways an actual state can fail an expectation: it contains a node | ||
| * that was not expected, lacks a node that was expected, or holds a node that | ||
| * is not equal to the expected one. Expected is the desired side and actual the | ||
| * current side of whatever comparison produced the issue — contract-vs-database, | ||
| * or contract-vs-contract in an offline plan — so the vocabulary is | ||
| * comparison-relative and never ambiguous about a base. | ||
| * | ||
| * The failure reason is a structural characteristic carried as a declared | ||
| * field: consumers filter on `reason`, never by enumerating kind strings or | ||
| * family-invented node codes. | ||
| */ | ||
| export type ExpectationFailureReason = 'not-expected' | 'not-found' | 'not-equal'; | ||
| /** | ||
| * The issue-based schema-verify result. `ok` derives from the FAILURE list | ||
@@ -58,0 +44,0 @@ * only: a verify passes exactly when `schema.issues` is empty, post |
@@ -1,2 +0,9 @@ | ||
| import type { ExpectationFailureReason } from './control-operation-results'; | ||
| /** | ||
| * A root-anchored chain of `(nodeKind, id)` steps identifying a node in a | ||
| * schema tree — the same vocabulary the differ pairs siblings with. Used by | ||
| * `DiffableNode.dependsOn` to name a node's structural prerequisites without | ||
| * holding a reference to the node itself (the target may live on the other | ||
| * diff side, or not exist at all). | ||
| */ | ||
| export type SchemaNodeRef = readonly { readonly nodeKind: string; readonly id: string }[]; | ||
@@ -6,11 +13,50 @@ export interface SchemaDiffIssue<TNode extends DiffableNode = DiffableNode> { | ||
| readonly path: readonly string[]; | ||
| /** Why the actual state fails the expectation. Consumers filter on this field. */ | ||
| readonly reason: ExpectationFailureReason; | ||
| /** The expected (desired-side) node, when available. Absent for `not-expected` issues. */ | ||
| /** The expected (desired-side) node, when available. Absent for a drop. */ | ||
| readonly expected?: TNode; | ||
| /** The actual (current-side) node, when available. Absent for `not-found` issues. */ | ||
| /** The actual (current-side) node, when available. Absent for a create. */ | ||
| readonly actual?: TNode; | ||
| /** | ||
| * Paths of the other in-diff issues this issue depends on. Mirrored by | ||
| * `diffSchemas` from the node's own `dependsOn` refs: a ref resolves to a | ||
| * path only when some emitted issue sits at that exact path with a | ||
| * matching `nodeKind` — a ref whose target produced no issue is dropped | ||
| * (the dependency is satisfied by reality). | ||
| */ | ||
| readonly dependsOn?: readonly (readonly string[])[]; | ||
| } | ||
| /** | ||
| * The three ways an actual state can fail an expectation: it lacks a node that | ||
| * was expected (`not-found`), holds a node that was not expected | ||
| * (`not-expected`), or holds a node not equal to the expected one | ||
| * (`not-equal`). Expected is the desired side, actual the current side, of | ||
| * whatever comparison produced the issue (contract-vs-database, or | ||
| * contract-vs-contract in an offline plan), so the vocabulary is | ||
| * comparison-relative and never ambiguous about a base — and reads cleanly for | ||
| * both the planner and `db verify`. | ||
| * | ||
| * This is the RETURN TYPE of the derived {@link issueOutcome} helper, not a | ||
| * stored field: presence is the single source of truth, and the outcome is | ||
| * computed from it on demand. | ||
| */ | ||
| export type ExpectationFailureReason = 'not-found' | 'not-expected' | 'not-equal'; | ||
| /** | ||
| * The outcome an issue represents, discriminated by presence rather than any | ||
| * stored field — the single source of truth every consumer reads. An issue | ||
| * always carries at least one side by construction; neither is a malformed | ||
| * issue and throws. | ||
| */ | ||
| export function issueOutcome(issue: SchemaDiffIssue): ExpectationFailureReason { | ||
| const hasExpected = issue.expected !== undefined; | ||
| const hasActual = issue.actual !== undefined; | ||
| if (hasExpected && hasActual) return 'not-equal'; | ||
| if (hasExpected) return 'not-found'; | ||
| if (hasActual) return 'not-expected'; | ||
| throw new Error( | ||
| `issueOutcome: issue at "${issue.path.join('/')}" carries neither an expected nor an actual node`, | ||
| ); | ||
| } | ||
| /** | ||
| * A node in the schema tree. Every node in the tree implements this interface. | ||
@@ -32,2 +78,9 @@ * | ||
| readonly nodeKind: string; | ||
| /** | ||
| * The nodes this node structurally depends on — resolved references to the | ||
| * prerequisites that must exist before it. Stamped by the derivation that | ||
| * holds the parent context; both the expected and the actual derivation | ||
| * stamp it by the same structural rules. Never compared by `isEqualTo`. | ||
| */ | ||
| readonly dependsOn?: readonly SchemaNodeRef[]; | ||
| isEqualTo(other: DiffableNode): boolean; | ||
@@ -57,3 +110,2 @@ children(): readonly DiffableNode[]; | ||
| path, | ||
| reason: 'not-found', | ||
| expected: node, | ||
@@ -70,3 +122,2 @@ }, | ||
| path, | ||
| reason: 'not-expected', | ||
| actual: node, | ||
@@ -91,5 +142,58 @@ }, | ||
| ): readonly SchemaDiffIssue[] { | ||
| return diffPair(expected, actual, []); | ||
| return mirrorDependsOnOntoIssues(diffPair(expected, actual, [])); | ||
| } | ||
| function schemaNodeRefKey(ref: SchemaNodeRef): string { | ||
| return ref.map((step) => step.id).join(SIBLING_KEY_DELIMITER); | ||
| } | ||
| function issuePathKey(path: readonly string[]): string { | ||
| return path.join(SIBLING_KEY_DELIMITER); | ||
| } | ||
| function terminalNodeKind(issue: SchemaDiffIssue): string | undefined { | ||
| return (issue.expected ?? issue.actual)?.nodeKind; | ||
| } | ||
| /** | ||
| * Copies each issue's node's `dependsOn` refs onto the issue itself, as | ||
| * issue-to-issue path references. A ref is kept only when some emitted issue | ||
| * sits at that exact path AND that issue's node `nodeKind` matches the ref's | ||
| * last step — otherwise the ref is dropped (its target either didn't | ||
| * change, or was never part of either tree; either way the dependency is | ||
| * satisfied by reality, not by an operation this diff will produce). | ||
| * | ||
| * The path index is a multimap: two siblings may share an `id` under | ||
| * different `nodeKind`s (a role and a namespace named alike), so an id-path | ||
| * alone is ambiguous. The ref's terminal `nodeKind` disambiguates — the ref | ||
| * resolves only against a same-path issue whose own node carries that kind. | ||
| */ | ||
| function mirrorDependsOnOntoIssues(issues: readonly SchemaDiffIssue[]): readonly SchemaDiffIssue[] { | ||
| const issuesByPath = new Map<string, SchemaDiffIssue[]>(); | ||
| for (const issue of issues) { | ||
| const key = issuePathKey(issue.path); | ||
| const bucket = issuesByPath.get(key); | ||
| if (bucket === undefined) issuesByPath.set(key, [issue]); | ||
| else bucket.push(issue); | ||
| } | ||
| return issues.map((issue) => { | ||
| const node = issue.expected ?? issue.actual; | ||
| const refs = node?.dependsOn; | ||
| if (refs === undefined || refs.length === 0) return issue; | ||
| const dependsOn = refs.flatMap((ref) => { | ||
| const lastStep = ref[ref.length - 1]; | ||
| if (lastStep === undefined) return []; | ||
| const candidates = issuesByPath.get(schemaNodeRefKey(ref)) ?? []; | ||
| const resolved = candidates.some((c) => terminalNodeKind(c) === lastStep.nodeKind); | ||
| if (!resolved) return []; | ||
| return [ref.map((step) => step.id)]; | ||
| }); | ||
| if (dependsOn.length === 0) return issue; | ||
| return { ...issue, dependsOn }; | ||
| }); | ||
| } | ||
| function diffPair( | ||
@@ -105,3 +209,2 @@ expected: DiffableNode, | ||
| path, | ||
| reason: 'not-equal', | ||
| expected, | ||
@@ -108,0 +211,0 @@ actual, |
@@ -21,2 +21,3 @@ export type { | ||
| AuthoringPslBlockDescriptorNamespace, | ||
| AuthoringSelectRef, | ||
| AuthoringStorageTypeTemplate, | ||
@@ -46,2 +47,3 @@ AuthoringTemplateValue, | ||
| } from '../shared/framework-authoring'; | ||
| export type { AuthoringOption } from '../shared/option-descriptor'; | ||
| export type { | ||
@@ -48,0 +50,0 @@ PslBlockParam, |
@@ -63,3 +63,2 @@ export type { ImportRequirement } from '@prisma-next/ts-render'; | ||
| EmitContractResult, | ||
| ExpectationFailureReason, | ||
| IntrospectSchemaResult, | ||
@@ -107,5 +106,11 @@ OperationContext, | ||
| } from '../control/control-stack'; | ||
| export type { DiffableNode, SchemaDiffIssue } from '../control/schema-diff'; | ||
| export { diffSchemas, SchemaDiff } from '../control/schema-diff'; | ||
| export { orderIssuesByDependencies } from '../control/order-issues-by-dependencies'; | ||
| export type { | ||
| DiffableNode, | ||
| ExpectationFailureReason, | ||
| SchemaDiffIssue, | ||
| SchemaNodeRef, | ||
| } from '../control/schema-diff'; | ||
| export { diffSchemas, issueOutcome, SchemaDiff } from '../control/schema-diff'; | ||
| export type { | ||
| SchemaVerifier, | ||
@@ -112,0 +117,0 @@ SchemaVerifyOptions, |
@@ -14,2 +14,3 @@ import type { | ||
| import type { CodecLookup } from './codec-types'; | ||
| import type { AuthoringOption } from './option-descriptor'; | ||
| import type { PslBlockParam, PslExtensionBlock, PslSpan } from './psl-extension-block'; | ||
@@ -27,2 +28,23 @@ import { runtimeError } from './runtime-error'; | ||
| /** | ||
| * Selects among `cases` by the value of the referenced argument: the resolved | ||
| * value must be one of the case keys, and the node resolves to that case's | ||
| * recursively resolved template. An absent argument resolves to `undefined`, | ||
| * which the enclosing object template omits entirely. | ||
| * | ||
| * Case coverage is validated against the referenced option argument's | ||
| * `values` at pack-registration time, so the runtime miss-throw is an | ||
| * assertion for type-bypassing callers, not a user-facing diagnostic. | ||
| * | ||
| * Must not be used in the `codecId`/`nullable`/`id`/`unique` positions of a | ||
| * preset output: the type-level `ResolveTemplateValue` does not implement | ||
| * select, and those fields feed TS builder-state inference. See ADR 239. | ||
| */ | ||
| export interface AuthoringSelectRef { | ||
| readonly kind: 'select'; | ||
| readonly index: number; | ||
| readonly path?: readonly string[]; | ||
| readonly cases: Readonly<Record<string, AuthoringTemplateValue>>; | ||
| } | ||
| export type AuthoringTemplateValue = | ||
@@ -34,2 +56,3 @@ | string | ||
| | AuthoringArgRef | ||
| | AuthoringSelectRef | ||
| | readonly AuthoringTemplateValue[] | ||
@@ -58,2 +81,3 @@ | { readonly [key: string]: AuthoringTemplateValue }; | ||
| } | ||
| | AuthoringOption | ||
| ); | ||
@@ -489,2 +513,18 @@ | ||
| function isAuthoringSelectRef(value: unknown): value is AuthoringSelectRef { | ||
| if (!isAuthoringTemplateRecord(value) || value['kind'] !== 'select') { | ||
| return false; | ||
| } | ||
| const index = value['index']; | ||
| const path = value['path']; | ||
| const cases = value['cases']; | ||
| if (typeof index !== 'number' || !Number.isInteger(index) || index < 0) { | ||
| return false; | ||
| } | ||
| if (path !== undefined && (!Array.isArray(path) || path.some((s) => typeof s !== 'string'))) { | ||
| return false; | ||
| } | ||
| return typeof cases === 'object' && cases !== null && !Array.isArray(cases); | ||
| } | ||
| function isAuthoringTemplateRecord(value: unknown): value is Record<string, unknown> { | ||
@@ -494,2 +534,17 @@ return typeof value === 'object' && value !== null && !Array.isArray(value); | ||
| function readTemplateArgumentValue( | ||
| args: readonly unknown[], | ||
| index: number, | ||
| path: readonly string[] | undefined, | ||
| ): unknown { | ||
| let value = args[index]; | ||
| for (const segment of path ?? []) { | ||
| if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) { | ||
| return undefined; | ||
| } | ||
| value = value[segment]; | ||
| } | ||
| return value; | ||
| } | ||
| export function isAuthoringTypeConstructorDescriptor( | ||
@@ -1017,4 +1072,136 @@ value: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace, | ||
| assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace)); | ||
| assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace); | ||
| } | ||
| function collectDescriptorNodes<D>( | ||
| namespace: AuthoringNamespaceTree<D>, | ||
| isLeaf: (value: D | AuthoringNamespaceTree<D>) => value is D, | ||
| path: readonly string[] = [], | ||
| ): [string, D][] { | ||
| const nodes: [string, D][] = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isLeaf(value)) { | ||
| nodes.push([currentPath.join('.'), value]); | ||
| continue; | ||
| } | ||
| if (typeof value === 'object' && value !== null && !Array.isArray(value)) { | ||
| nodes.push(...collectDescriptorNodes(value, isLeaf, currentPath)); | ||
| } | ||
| } | ||
| return nodes; | ||
| } | ||
| function collectSelectRefs(value: unknown, found: AuthoringSelectRef[]): void { | ||
| if (typeof value !== 'object' || value === null) { | ||
| return; | ||
| } | ||
| if (isAuthoringSelectRef(value)) { | ||
| found.push(value); | ||
| for (const caseTemplate of Object.values(value.cases)) { | ||
| collectSelectRefs(caseTemplate, found); | ||
| } | ||
| return; | ||
| } | ||
| if (isAuthoringArgRef(value)) { | ||
| collectSelectRefs(value.default, found); | ||
| return; | ||
| } | ||
| if (Array.isArray(value)) { | ||
| for (const entry of value) { | ||
| collectSelectRefs(entry, found); | ||
| } | ||
| return; | ||
| } | ||
| for (const entry of Object.values(value)) { | ||
| collectSelectRefs(entry, found); | ||
| } | ||
| } | ||
| function validateSelectRefsAgainstArgs( | ||
| label: string, | ||
| helperPath: string, | ||
| args: readonly AuthoringArgumentDescriptor[] | undefined, | ||
| templateRoot: unknown, | ||
| ): void { | ||
| const selects: AuthoringSelectRef[] = []; | ||
| collectSelectRefs(templateRoot, selects); | ||
| for (const select of selects) { | ||
| const position = `#${select.index + 1}`; | ||
| let descriptor: AuthoringArgumentDescriptor | undefined = args?.[select.index]; | ||
| if (descriptor === undefined) { | ||
| throw new Error( | ||
| `Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`, | ||
| ); | ||
| } | ||
| for (const segment of select.path ?? []) { | ||
| descriptor = descriptor.kind === 'object' ? descriptor.properties[segment] : undefined; | ||
| if (descriptor === undefined) { | ||
| throw new Error( | ||
| `Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join('.')}", which does not resolve to a declared argument property.`, | ||
| ); | ||
| } | ||
| } | ||
| if (descriptor.kind !== 'option') { | ||
| throw new Error( | ||
| `Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`, | ||
| ); | ||
| } | ||
| const argumentLabel = descriptor.name !== undefined ? `"${descriptor.name}"` : position; | ||
| const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value)); | ||
| if (missing.length > 0) { | ||
| throw new Error( | ||
| `Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(', ')}] but the select template has no case for: ${missing.join(', ')}.`, | ||
| ); | ||
| } | ||
| const values = descriptor.values; | ||
| const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key)); | ||
| if (unreachable.length > 0) { | ||
| throw new Error( | ||
| `Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(', ')}. Allowed values: [${values.join(', ')}].`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| /** | ||
| * Every `select` template node must target an option argument whose `values` | ||
| * exactly cover the node's `cases` — a legal token with no case and a case no | ||
| * token can reach are both declaration bugs, caught here at pack-registration | ||
| * time rather than at first resolution. | ||
| */ | ||
| function assertSelectTemplatesMatchOptionArgs( | ||
| typeNamespace: AuthoringTypeNamespace, | ||
| fieldNamespace: AuthoringFieldNamespace, | ||
| entityTypeNamespace: AuthoringEntityTypeNamespace, | ||
| ): void { | ||
| for (const [helperPath, descriptor] of collectDescriptorNodes( | ||
| fieldNamespace, | ||
| isAuthoringFieldPresetDescriptor, | ||
| )) { | ||
| validateSelectRefsAgainstArgs('field', helperPath, descriptor.args, descriptor.output); | ||
| } | ||
| for (const [helperPath, descriptor] of collectDescriptorNodes( | ||
| typeNamespace, | ||
| isAuthoringTypeConstructorDescriptor, | ||
| )) { | ||
| validateSelectRefsAgainstArgs('type', helperPath, descriptor.args, descriptor.output); | ||
| } | ||
| for (const [helperPath, descriptor] of collectDescriptorNodes( | ||
| entityTypeNamespace, | ||
| isAuthoringEntityTypeDescriptor, | ||
| )) { | ||
| if ('template' in descriptor.output) { | ||
| validateSelectRefsAgainstArgs( | ||
| 'entityType', | ||
| helperPath, | ||
| descriptor.args, | ||
| descriptor.output.template, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| export function resolveAuthoringTemplateValue( | ||
@@ -1028,12 +1215,4 @@ template: AuthoringTemplateValue | undefined, | ||
| if (isAuthoringArgRef(template)) { | ||
| let value = args[template.index]; | ||
| const value = readTemplateArgumentValue(args, template.index, template.path); | ||
| for (const segment of template.path ?? []) { | ||
| if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) { | ||
| value = undefined; | ||
| break; | ||
| } | ||
| value = (value as Record<string, unknown>)[segment]; | ||
| } | ||
| if (value === undefined && template.default !== undefined) { | ||
@@ -1045,2 +1224,13 @@ return resolveAuthoringTemplateValue(template.default, args); | ||
| } | ||
| if (isAuthoringSelectRef(template)) { | ||
| const value = readTemplateArgumentValue(args, template.index, template.path); | ||
| if (value === undefined) { | ||
| return undefined; | ||
| } | ||
| if (typeof value !== 'string' || !Object.hasOwn(template.cases, value)) { | ||
| throw new Error(`Authoring template select has no case for value "${String(value)}"`); | ||
| } | ||
| return resolveAuthoringTemplateValue(template.cases[value], args); | ||
| } | ||
| if (Array.isArray(template)) { | ||
@@ -1121,2 +1311,11 @@ return template.map((value) => resolveAuthoringTemplateValue(value, args)); | ||
| if (descriptor.kind === 'option') { | ||
| if (typeof value !== 'string' || !descriptor.values.includes(value)) { | ||
| throw new Error( | ||
| `Authoring helper argument at ${path} must be one of: ${descriptor.values.join(', ')}`, | ||
| ); | ||
| } | ||
| return; | ||
| } | ||
| if (typeof value !== 'number' || Number.isNaN(value)) { | ||
@@ -1185,2 +1384,4 @@ throw new Error(`Authoring helper argument at ${path} must be a number`); | ||
| } | ||
| const normalizedTypeParams = | ||
| typeParams !== undefined && Object.keys(typeParams).length === 0 ? undefined : typeParams; | ||
@@ -1190,3 +1391,3 @@ return { | ||
| nativeType, | ||
| ...ifDefined('typeParams', typeParams), | ||
| ...ifDefined('typeParams', normalizedTypeParams), | ||
| }; | ||
@@ -1231,4 +1432,7 @@ } | ||
| args: readonly unknown[], | ||
| ): ExecutionMutationDefaultValue { | ||
| ): ExecutionMutationDefaultValue | undefined { | ||
| const value = resolveAuthoringTemplateValue(template, args); | ||
| if (value === undefined) { | ||
| return undefined; | ||
| } | ||
| if (!isExecutionMutationDefaultValue(value)) { | ||
@@ -1245,4 +1449,4 @@ throw new Error( | ||
| args: readonly unknown[], | ||
| ): ExecutionMutationDefaultPhases { | ||
| return { | ||
| ): ExecutionMutationDefaultPhases | undefined { | ||
| const phases: ExecutionMutationDefaultPhases = { | ||
| ...ifDefined( | ||
@@ -1261,2 +1465,3 @@ 'onCreate', | ||
| }; | ||
| return Object.keys(phases).length === 0 ? undefined : phases; | ||
| } | ||
@@ -1263,0 +1468,0 @@ |
@@ -13,2 +13,4 @@ /** | ||
| import type { AuthoringOption } from './option-descriptor'; | ||
| export interface PslPosition { | ||
@@ -150,5 +152,3 @@ readonly offset: number; | ||
| export interface PslBlockParamOption { | ||
| readonly kind: 'option'; | ||
| readonly values: readonly string[]; | ||
| export interface PslBlockParamOption extends AuthoringOption { | ||
| readonly required?: boolean; | ||
@@ -155,0 +155,0 @@ } |
| export interface RuntimeErrorEnvelope extends Error { | ||
| readonly code: string; | ||
| readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME'; | ||
| readonly category: | ||
| | 'PLAN' | ||
| | 'CONTRACT' | ||
| | 'LINT' | ||
| | 'BUDGET' | ||
| | 'RUNTIME' | ||
| | 'DRIVER' | ||
| | 'MIGRATION' | ||
| | 'ORM'; | ||
| readonly severity: 'error'; | ||
@@ -46,2 +54,5 @@ readonly details?: Record<string, unknown>; | ||
| case 'BUDGET': | ||
| case 'DRIVER': | ||
| case 'MIGRATION': | ||
| case 'ORM': | ||
| return prefix; | ||
@@ -48,0 +59,0 @@ default: |
| 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;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,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-e32YHT3D.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-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 { n as runtimeError } from "./runtime-error-B2gWOtgH.mjs"; | ||
| import { blindCast } from "@prisma-next/utils/casts"; | ||
| import { isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue } from "@prisma-next/contract/types"; | ||
| import { ifDefined } from "@prisma-next/utils/defined"; | ||
| //#region src/shared/framework-authoring.ts | ||
| /** | ||
| * 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`. | ||
| */ | ||
| function classifyEnumMemberType(block) { | ||
| let sawText = false; | ||
| let sawInt = false; | ||
| for (const paramValue of Object.values(block.parameters)) { | ||
| if (paramValue.kind === "bare") { | ||
| sawText = true; | ||
| continue; | ||
| } | ||
| if (paramValue.kind !== "value") return null; | ||
| let jsonValue; | ||
| try { | ||
| jsonValue = JSON.parse(paramValue.raw); | ||
| } catch { | ||
| return null; | ||
| } | ||
| if (typeof jsonValue === "string") sawText = true; | ||
| else if (typeof jsonValue === "number" && Number.isInteger(jsonValue)) sawInt = true; | ||
| else return null; | ||
| } | ||
| if (sawText && sawInt) return null; | ||
| if (sawText) return "text"; | ||
| if (sawInt) return "int"; | ||
| return 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. | ||
| */ | ||
| function resolveEnumCodecId(block, ctx) { | ||
| const sourceId = ctx.sourceId ?? "unknown"; | ||
| const typeAttr = block.blockAttributes.find((a) => a.name === "type"); | ||
| if (typeAttr === void 0) { | ||
| const inferredKind = classifyEnumMemberType(block); | ||
| if (inferredKind === null || ctx.enumInferenceCodecs === void 0) { | ||
| ctx.diagnostics?.push({ | ||
| code: "PSL_ENUM_CANNOT_INFER_TYPE", | ||
| message: `cannot infer @@type for enum "${block.name}"; add an explicit @@type(...)`, | ||
| sourceId, | ||
| span: block.span | ||
| }); | ||
| return; | ||
| } | ||
| return { | ||
| codecId: ctx.enumInferenceCodecs[inferredKind], | ||
| codecSpan: block.span | ||
| }; | ||
| } | ||
| const rawCodecArg = typeAttr.args[0]?.value; | ||
| const codecId = rawCodecArg?.startsWith("\"") && rawCodecArg.endsWith("\"") && rawCodecArg.length >= 2 ? rawCodecArg.slice(1, -1) : void 0; | ||
| if (codecId === void 0) { | ||
| ctx.diagnostics?.push({ | ||
| code: "PSL_ENUM_MISSING_TYPE", | ||
| message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`, | ||
| sourceId, | ||
| span: typeAttr.span | ||
| }); | ||
| return; | ||
| } | ||
| return { | ||
| codecId, | ||
| codecSpan: typeAttr.args[0]?.span ?? typeAttr.span | ||
| }; | ||
| } | ||
| function isAuthoringArgRef(value) { | ||
| if (typeof value !== "object" || value === null || value.kind !== "arg") return false; | ||
| const { index, path } = value; | ||
| if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false; | ||
| if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false; | ||
| return true; | ||
| } | ||
| function isAuthoringTemplateRecord(value) { | ||
| return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| } | ||
| function isAuthoringTypeConstructorDescriptor(value) { | ||
| return "kind" in value && value.kind === "typeConstructor"; | ||
| } | ||
| function isAuthoringFieldPresetDescriptor(value) { | ||
| return "kind" in value && value.kind === "fieldPreset"; | ||
| } | ||
| function isAuthoringEntityTypeDescriptor(value) { | ||
| return "kind" in value && value.kind === "entity"; | ||
| } | ||
| function isAuthoringPslBlockDescriptor(value) { | ||
| return "kind" in value && value.kind === "pslBlock"; | ||
| } | ||
| function isAuthoringModelAttributeDescriptor(value) { | ||
| return "kind" in value && value.kind === "modelAttribute"; | ||
| } | ||
| /** | ||
| * 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`). | ||
| */ | ||
| function hasRegisteredFieldNamespace(contributions, namespace) { | ||
| if (contributions?.field === void 0 || !Object.hasOwn(contributions.field, namespace)) return false; | ||
| const value = contributions.field[namespace]; | ||
| return value !== void 0 && !isAuthoringFieldPresetDescriptor(value); | ||
| } | ||
| function isCopyableNamespaceObject(value) { | ||
| if (typeof value !== "object" || value === null || Array.isArray(value)) return false; | ||
| const proto = Object.getPrototypeOf(value); | ||
| return proto === Object.prototype || proto === null; | ||
| } | ||
| /** | ||
| * Deep structural check run only at the composition boundary (the merge and | ||
| * collect walkers) to classify a raw namespace-tree node as a leaf descriptor. | ||
| * A node counts as a leaf iff its `kind` matches `descriptorKind` AND it | ||
| * carries that kind's required fields. | ||
| * | ||
| * This is boundary validation over `unknown`, NOT a type-predicate: the four | ||
| * exported `isAuthoring*Descriptor` predicates deliberately narrow on `kind` | ||
| * alone and trust the static types. The walkers, by contrast, also receive | ||
| * type-bypassing packs (`as unknown as never` in tests, untyped JS at runtime) | ||
| * whose descriptor-shaped-but-incomplete nodes must be rejected rather than | ||
| * silently treated as sub-namespaces — so the well-formedness check lives here. | ||
| */ | ||
| function isWellFormedDescriptor(value, descriptorKind) { | ||
| if (typeof value !== "object" || value === null) return false; | ||
| if (!("kind" in value) || value.kind !== descriptorKind) return false; | ||
| switch (descriptorKind) { | ||
| case "typeConstructor": | ||
| case "fieldPreset": { | ||
| if (!("output" in value)) return false; | ||
| const output = value.output; | ||
| return typeof output === "object" && output !== null; | ||
| } | ||
| case "entity": { | ||
| if (!("discriminator" in value) || typeof value.discriminator !== "string") return false; | ||
| if (value.discriminator.length === 0) return false; | ||
| if (!("output" in value)) return false; | ||
| const output = value.output; | ||
| if (typeof output !== "object" || output === null) return false; | ||
| const factory = "factory" in output ? output.factory : void 0; | ||
| const template = "template" in output ? output.template : void 0; | ||
| return typeof factory === "function" || template !== void 0; | ||
| } | ||
| case "pslBlock": { | ||
| if (!("keyword" in value) || typeof value.keyword !== "string" || value.keyword.length === 0) return false; | ||
| if (!("discriminator" in value) || typeof value.discriminator !== "string" || value.discriminator.length === 0) return false; | ||
| if (!("name" in value)) return false; | ||
| const name = value.name; | ||
| if (typeof name !== "object" || name === null) return false; | ||
| if (!("required" in name) || typeof name.required !== "boolean") return false; | ||
| if (!("parameters" in value)) return false; | ||
| const parameters = value.parameters; | ||
| return typeof parameters === "object" && parameters !== null && !Array.isArray(parameters); | ||
| } | ||
| case "modelAttribute": | ||
| if (!("attribute" in value) || typeof value.attribute !== "string" || value.attribute.length === 0) return false; | ||
| if (!("spec" in value)) return false; | ||
| return "lower" in value && typeof value.lower === "function"; | ||
| default: return false; | ||
| } | ||
| } | ||
| function deepCopyNamespace(source, descriptorKind) { | ||
| const copy = {}; | ||
| for (const [key, value] of Object.entries(source)) copy[key] = isCopyableNamespaceObject(value) && !isWellFormedDescriptor(value, descriptorKind) ? deepCopyNamespace(value, descriptorKind) : value; | ||
| return copy; | ||
| } | ||
| /** | ||
| * 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. | ||
| */ | ||
| function mergeAuthoringNamespaces(target, source, path, descriptorKind, label) { | ||
| const assertSafePath = (currentPath) => { | ||
| const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype"); | ||
| if (blockedSegment) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`); | ||
| }; | ||
| for (const [key, sourceValue] of Object.entries(source)) { | ||
| const currentPath = [...path, key]; | ||
| assertSafePath(currentPath); | ||
| const hasExistingValue = Object.hasOwn(target, key); | ||
| const existingValue = hasExistingValue ? target[key] : void 0; | ||
| if (!hasExistingValue) { | ||
| target[key] = isCopyableNamespaceObject(sourceValue) && !isWellFormedDescriptor(sourceValue, descriptorKind) ? deepCopyNamespace(sourceValue, descriptorKind) : sourceValue; | ||
| continue; | ||
| } | ||
| const existingIsLeaf = isWellFormedDescriptor(existingValue, descriptorKind); | ||
| const sourceIsLeaf = isWellFormedDescriptor(sourceValue, descriptorKind); | ||
| if (existingIsLeaf || sourceIsLeaf) throw new Error(`Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`); | ||
| if (!isCopyableNamespaceObject(existingValue) || !isCopyableNamespaceObject(sourceValue)) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`); | ||
| mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, descriptorKind, label); | ||
| } | ||
| } | ||
| function collectDescriptorPaths(namespace, isLeaf, path = []) { | ||
| const paths = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isLeaf(value)) { | ||
| paths.push(currentPath.join(".")); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath)); | ||
| } | ||
| return paths; | ||
| } | ||
| function collectDescriptorEntries(namespace, isLeaf, descriptorKind, label, path = []) { | ||
| const entries = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isLeaf(value)) { | ||
| if (!isWellFormedDescriptor(value, descriptorKind)) throw new Error(`Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| if (value.discriminator.length > 0) entries.push({ | ||
| path: currentPath.join("."), | ||
| discriminator: value.discriminator | ||
| }); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) { | ||
| const record = blindCast(value); | ||
| if ((record["kind"] !== void 0 || record["keyword"] !== void 0 || record["discriminator"] !== void 0) && !isLeaf(value)) { | ||
| const hasKind = record["kind"] === "pslBlock"; | ||
| const hasKeyword = typeof record["keyword"] === "string"; | ||
| const hasDiscriminator = typeof record["discriminator"] === "string"; | ||
| if (hasKind || hasKeyword && hasDiscriminator) throw new Error(`Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| } | ||
| entries.push(...collectDescriptorEntries(value, isLeaf, descriptorKind, label, currentPath)); | ||
| } | ||
| } | ||
| return entries; | ||
| } | ||
| /** | ||
| * Throws when two or more entries in the same namespace share a key. A | ||
| * duplicate key makes dispatch ambiguous — the caller's lookup dispatches by | ||
| * this key, so one entry would silently shadow the other. Catch duplicates | ||
| * before building any dispatch map. | ||
| * | ||
| * `label` (e.g. `'pslBlock'`, `'entityType'`) names which namespace the | ||
| * duplicate was found in and is carried in the structured error metadata; | ||
| * the key itself is always called `key` in both the message and the | ||
| * metadata, since what it semantically represents (a discriminator for | ||
| * `entityType`, the parser's dispatch keyword for `pslBlock`) is the | ||
| * caller's concern, not this function's. | ||
| */ | ||
| function assertUniqueDiscriminators(entries, label) { | ||
| const seen = /* @__PURE__ */ new Map(); | ||
| for (const { path, discriminator: key } of entries) { | ||
| const existing = seen.get(key); | ||
| if (existing !== void 0) throw runtimeError("RUNTIME.DUPLICATE_AUTHORING_DISCRIMINATOR", `Duplicate ${label} key "${key}" registered at both "${existing}" and "${path}". Each ${label} contribution must use a unique key.`, { | ||
| label, | ||
| key, | ||
| existingPath: existing, | ||
| path | ||
| }); | ||
| seen.set(key, path); | ||
| } | ||
| } | ||
| function collectPslBlockDescriptorEntries(namespace, path = []) { | ||
| const entries = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isAuthoringPslBlockDescriptor(value)) { | ||
| if (!isWellFormedDescriptor(value, "pslBlock")) throw new Error(`Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push({ | ||
| path: currentPath.join("."), | ||
| discriminator: value.discriminator, | ||
| keyword: value.keyword | ||
| }); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) { | ||
| const record = blindCast(value); | ||
| const hasKind = record["kind"] === "pslBlock"; | ||
| const hasKeyword = typeof record["keyword"] === "string"; | ||
| const hasDiscriminator = typeof record["discriminator"] === "string"; | ||
| if (hasKind || hasKeyword && hasDiscriminator) throw new Error(`Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push(...collectPslBlockDescriptorEntries(value, currentPath)); | ||
| } | ||
| } | ||
| return entries; | ||
| } | ||
| /** | ||
| * Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory | ||
| * with the same discriminator. An `entityTypes` factory may stand alone (e.g. | ||
| * `enum`, reachable from the TypeScript builder without any PSL block). | ||
| * | ||
| * Uniqueness for pslBlock entries is keyed on **keyword**, not discriminator: | ||
| * several keywords (e.g. `policy_select`/`policy_insert`) may legitimately | ||
| * share one discriminator, routing to the same `entityTypes` factory and the | ||
| * same `entries[discriminator]` slot — that N:1 shape is exactly what lets | ||
| * one entity kind be authored through several PSL keywords. What must stay | ||
| * unique is the keyword itself, since that's what the parser dispatches on. | ||
| */ | ||
| function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) { | ||
| const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace); | ||
| const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entity", "entityType"); | ||
| assertUniqueDiscriminators(blockEntries.map((entry) => ({ | ||
| path: entry.path, | ||
| discriminator: entry.keyword | ||
| })), "pslBlock"); | ||
| assertUniqueDiscriminators(entityEntries, "entityType"); | ||
| const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator)); | ||
| for (const block of blockEntries) if (!entityDiscriminators.has(block.discriminator)) throw new Error(`Incomplete extension contribution: pslBlock helper "${block.path}" registers discriminator "${block.discriminator}" but no entityType contribution shares that discriminator. An extension-contributed PSL block requires a matching entityType factory so the parsed AST node can lower to an IR class instance; add an entityType helper with discriminator "${block.discriminator}".`); | ||
| } | ||
| function collectModelAttributeEntries(namespace, path = []) { | ||
| const entries = []; | ||
| for (const [key, value] of Object.entries(namespace)) { | ||
| const currentPath = [...path, key]; | ||
| if (isAuthoringModelAttributeDescriptor(value)) { | ||
| if (!isWellFormedDescriptor(value, "modelAttribute")) throw new Error(`Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push({ | ||
| path: currentPath.join("."), | ||
| discriminator: value.attribute | ||
| }); | ||
| continue; | ||
| } | ||
| if (typeof value === "object" && value !== null && !Array.isArray(value)) { | ||
| const record = blindCast(value); | ||
| if (typeof record["attribute"] === "string" && "spec" in record) throw new Error(`Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`); | ||
| entries.push(...collectModelAttributeEntries(value, currentPath)); | ||
| } | ||
| } | ||
| return entries; | ||
| } | ||
| /** | ||
| * Throws when two modelAttribute contributions — at any paths, even | ||
| * different ones — claim the same bare `@@` attribute name. The family | ||
| * interpreter dispatches by attribute name, not by registration path, so | ||
| * two descriptors claiming the same name would have one silently shadow | ||
| * the other. | ||
| */ | ||
| function assertUniqueModelAttributeNames(entries) { | ||
| const seen = /* @__PURE__ */ new Map(); | ||
| for (const { path, discriminator: attribute } of entries) { | ||
| const existing = seen.get(attribute); | ||
| if (existing !== void 0) throw new Error(`Duplicate modelAttribute "${attribute}" registered at both "${existing}" and "${path}". Each modelAttribute contribution must claim a unique attribute name.`); | ||
| seen.set(attribute, path); | ||
| } | ||
| } | ||
| function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) { | ||
| const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor)); | ||
| const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor)); | ||
| const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor)); | ||
| const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes."; | ||
| for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw new Error(`Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`); | ||
| for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw new Error(`Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`); | ||
| assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace); | ||
| assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace)); | ||
| } | ||
| function resolveAuthoringTemplateValue(template, args) { | ||
| if (template === void 0) return; | ||
| if (isAuthoringArgRef(template)) { | ||
| let value = args[template.index]; | ||
| for (const segment of template.path ?? []) { | ||
| if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) { | ||
| value = void 0; | ||
| break; | ||
| } | ||
| value = value[segment]; | ||
| } | ||
| if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args); | ||
| return value; | ||
| } | ||
| if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args)); | ||
| if (typeof template === "object" && template !== null) { | ||
| const resolved = {}; | ||
| for (const [key, value] of Object.entries(template)) { | ||
| const resolvedValue = resolveAuthoringTemplateValue(value, args); | ||
| if (resolvedValue !== void 0) resolved[key] = resolvedValue; | ||
| } | ||
| return resolved; | ||
| } | ||
| return template; | ||
| } | ||
| function validateAuthoringArgument(descriptor, value, path) { | ||
| if (value === void 0) { | ||
| if (descriptor.optional) return; | ||
| throw new Error(`Missing required authoring helper argument at ${path}`); | ||
| } | ||
| if (descriptor.kind === "string") { | ||
| if (typeof value !== "string") throw new Error(`Authoring helper argument at ${path} must be a string`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "boolean") { | ||
| if (typeof value !== "boolean") throw new Error(`Authoring helper argument at ${path} must be a boolean`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "stringArray") { | ||
| if (!Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an array of strings`); | ||
| for (const entry of value) if (typeof entry !== "string") throw new Error(`Authoring helper argument at ${path} must be an array of strings`); | ||
| return; | ||
| } | ||
| if (descriptor.kind === "object") { | ||
| if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an object`); | ||
| const input = value; | ||
| const expectedKeys = new Set(Object.keys(descriptor.properties)); | ||
| for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw new Error(`Authoring helper argument at ${path} contains unknown property "${key}"`); | ||
| for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`); | ||
| return; | ||
| } | ||
| if (typeof value !== "number" || Number.isNaN(value)) throw new Error(`Authoring helper argument at ${path} must be a number`); | ||
| if (descriptor.integer && !Number.isInteger(value)) throw new Error(`Authoring helper argument at ${path} must be an integer`); | ||
| if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw new Error(`Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`); | ||
| if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw new Error(`Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`); | ||
| } | ||
| function validateAuthoringHelperArguments(helperPath, descriptors, args) { | ||
| const expected = descriptors ?? []; | ||
| const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0); | ||
| if (args.length < minimumArgs || args.length > expected.length) throw new Error(`${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`); | ||
| expected.forEach((descriptor, index) => { | ||
| validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`); | ||
| }); | ||
| } | ||
| function resolveAuthoringStorageTypeTemplate(template, args) { | ||
| const nativeType = resolveAuthoringTemplateValue(template.nativeType, args); | ||
| if (typeof nativeType !== "string") throw new Error(`Resolved authoring nativeType must be a string for codec "${template.codecId}", received ${String(nativeType)}`); | ||
| const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args); | ||
| if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw new Error(`Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`); | ||
| return { | ||
| codecId: template.codecId, | ||
| nativeType, | ||
| ...ifDefined("typeParams", typeParams) | ||
| }; | ||
| } | ||
| function resolveAuthoringColumnDefaultTemplate(template, args) { | ||
| if (template.kind === "literal") { | ||
| const value = resolveAuthoringTemplateValue(template.value, args); | ||
| if (value === void 0) throw new Error("Resolved authoring literal default must not be undefined"); | ||
| if (!isColumnDefaultLiteralInputValue(value)) throw new Error(`Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`); | ||
| return { | ||
| kind: "literal", | ||
| value | ||
| }; | ||
| } | ||
| const expression = resolveAuthoringTemplateValue(template.expression, args); | ||
| if (expression === void 0 || typeof expression === "object" && expression !== null) throw new Error(`Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`); | ||
| return { | ||
| kind: "function", | ||
| expression: String(expression) | ||
| }; | ||
| } | ||
| function resolveExecutionMutationDefaultPhase(phase, template, args) { | ||
| const value = resolveAuthoringTemplateValue(template, args); | ||
| if (!isExecutionMutationDefaultValue(value)) throw new Error(`Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`); | ||
| return value; | ||
| } | ||
| function resolveAuthoringExecutionDefaultsTemplate(template, args) { | ||
| return { | ||
| ...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0), | ||
| ...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0) | ||
| }; | ||
| } | ||
| function instantiateAuthoringTypeConstructor(descriptor, args) { | ||
| return resolveAuthoringStorageTypeTemplate(descriptor.output, args); | ||
| } | ||
| function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) { | ||
| if ("factory" in descriptor.output) { | ||
| const input = args[0]; | ||
| return blindCast(descriptor.output.factory)(input, ctx); | ||
| } | ||
| validateAuthoringHelperArguments(helperPath, descriptor.args, args); | ||
| return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args)); | ||
| } | ||
| function instantiateAuthoringFieldPreset(descriptor, args) { | ||
| return { | ||
| descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args), | ||
| nullable: descriptor.output.nullable ?? false, | ||
| ...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0), | ||
| ...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0), | ||
| id: descriptor.output.id ?? false, | ||
| unique: descriptor.output.unique ?? false | ||
| }; | ||
| } | ||
| //#endregion | ||
| export { instantiateAuthoringFieldPreset as a, isAuthoringEntityTypeDescriptor as c, isAuthoringPslBlockDescriptor as d, isAuthoringTypeConstructorDescriptor as f, validateAuthoringHelperArguments as g, resolveEnumCodecId as h, instantiateAuthoringEntityType as i, isAuthoringFieldPresetDescriptor as l, resolveAuthoringTemplateValue as m, classifyEnumMemberType as n, instantiateAuthoringTypeConstructor as o, mergeAuthoringNamespaces as p, hasRegisteredFieldNamespace as r, isAuthoringArgRef as s, assertNoCrossRegistryCollisions as t, isAuthoringModelAttributeDescriptor as u }; | ||
| //# sourceMappingURL=framework-authoring-Bz_vaNZw.mjs.map |
Sorry, the diff of this file is too big to display
| 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,SACA,QAAA;AAAA;AAAA,UAGM,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA,EAAI,aAAa;EAAA,SACjB,QAAA;AAAA;;;;;;AAiDa;AAQxB;;;;;;;;AAEwB;AAOxB;;;KA7CY,2BAAA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A,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;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,UAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,GAAA,EAAK,cAAc;AAAA;AAAA,UAGb,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,GAAO,UAAA;EAAA,SACP,IAAA,GAAO,QAAA,CAAS,MAAA;AAAA;AAAA,UAGV,8BAAA;EAAA,SACN,QAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,aAAA;AAAA;AAAA,KAGC,mBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,YAAA,EAAc,aAAA;AAAA;EAAA,SACxC,IAAA;EAAA,SAA4B,SAAA,EAAW,6BAA6B;AAAA;AAAA,KAEvE,oBAAA;EAAA,SACG,EAAA;EAAA,SAAmB,KAAA,EAAO,mBAAA;AAAA;EAAA,SAC1B,EAAA;EAAA,SAAoB,UAAA,EAAY,gBAAgB;AAAA;AAAA,UAE9C,kCAAA;EAAA,SACN,EAAA;EAnBO;;;AAA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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,K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AA0B,iBAAA,KACzB,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA,SAAe,iBAAA;AAAA,UAiClC,cAAA;EAAA,SACN,IAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA,WAAqB,YAAA;EAAA,SACrB,KAAA,GAAQ,aAAA;EAAA,SACR,IAAA,EAAM,OAAA;AAAA;;;;AA5JO;iBAmKR,aAAA,CAAc,GAAA,EAAK,cAAA,YAA0B,QAAQ;;;;iBAWrD,qBAAA,CAAsB,GAAA,EAAK,cAAA,YAA0B,gBAAgB;;;;;;;;;;;cAmBxE,qBAAA,EAAuB,WAAW;;;AAnLvB;AAGxB;;;;;iBA0LgB,2BAAA,CAA4B,EAAA,EAAI,YAAA,YAAwB,iBAAiB;AAAA,UAgBxE,qBAAA;EAAA,SACN,MAAA;EAAA,SACA,QAAA;EAzMa;AAAA;AAexB;;;;AAAyC;AAGzC;;;;;;;;EAlBwB,SAyNb,mBAAA,GAAsB,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"} |
| import { n as runtimeError } from "./runtime-error-B2gWOtgH.mjs"; | ||
| import { blindCast } from "@prisma-next/utils/casts"; | ||
| //#region src/shared/resolve-codec.ts | ||
| const CONTRACT_CODEC_DESCRIPTOR_MISSING = "CONTRACT.CODEC_DESCRIPTOR_MISSING"; | ||
| /** | ||
| * Look up a descriptor for `ref.codecId` using `descriptorFor`; throw | ||
| * `code` if none is found. Each plane names its own error path: the control | ||
| * plane resolves contract-stack descriptors (`CONTRACT.*`), the execution | ||
| * plane resolves at query time (`RUNTIME.*`). | ||
| */ | ||
| function resolveCodecDescriptorOrThrow(descriptorFor, ref, code) { | ||
| const descriptor = descriptorFor(ref.codecId); | ||
| if (!descriptor) throw runtimeError(code, `No codec descriptor registered for codecId '${ref.codecId}'.`, { codecId: ref.codecId }); | ||
| return descriptor; | ||
| } | ||
| /** | ||
| * Validates `ref.typeParams` against `descriptor.paramsSchema`. | ||
| * | ||
| * Parameterized codecs that omit `typeParams` have it normalized to `{}` before | ||
| * validation (mirrors `ast-codec-resolver.ts` semantics). Throws | ||
| * `RUNTIME.TYPE_PARAMS_INVALID` when the validator returns a `Promise` or | ||
| * reports issues. | ||
| */ | ||
| function validateCodecTypeParams(descriptor, ref) { | ||
| const normalized = descriptor.isParameterized && ref.typeParams === void 0 ? { | ||
| ...ref, | ||
| typeParams: {} | ||
| } : ref; | ||
| const result = blindCast(descriptor.paramsSchema["~standard"].validate(normalized.typeParams)); | ||
| if (result instanceof Promise) throw runtimeError("RUNTIME.TYPE_PARAMS_INVALID", `paramsSchema for codec '${ref.codecId}' returned a Promise; runtime validation requires a synchronous Standard Schema validator.`, { | ||
| codecId: ref.codecId, | ||
| typeParams: ref.typeParams | ||
| }); | ||
| if ("issues" in result && result.issues) { | ||
| const messages = result.issues.map((issue) => issue.message).join("; "); | ||
| throw runtimeError("RUNTIME.TYPE_PARAMS_INVALID", `Invalid typeParams for codec '${ref.codecId}': ${messages}`, { | ||
| codecId: ref.codecId, | ||
| typeParams: ref.typeParams | ||
| }); | ||
| } | ||
| return blindCast(result).value; | ||
| } | ||
| /** | ||
| * Resolves a `Codec` instance: validates `ref.typeParams` via | ||
| * {@link validateCodecTypeParams} then calls `descriptor.factory(validated)(ctx)`. | ||
| * | ||
| * The descriptor's `factory` is typed against its own `P`; the registry erases | ||
| * `P` to `any`, so the factory is narrowed to `(params: unknown) => (ctx) => Codec` | ||
| * at the call boundary. The `paramsSchema` validates the input above before we | ||
| * forward it, so the narrowing is safe by construction. | ||
| */ | ||
| function materializeCodec(descriptor, ref, ctx) { | ||
| const validated = validateCodecTypeParams(descriptor, ref); | ||
| return blindCast(descriptor.factory)(validated)(ctx); | ||
| } | ||
| //#endregion | ||
| export { validateCodecTypeParams as i, materializeCodec as n, resolveCodecDescriptorOrThrow as r, CONTRACT_CODEC_DESCRIPTOR_MISSING as t }; | ||
| //# sourceMappingURL=resolve-codec-D8EPZosv.mjs.map |
| {"version":3,"file":"resolve-codec-D8EPZosv.mjs","names":[],"sources":["../src/shared/resolve-codec.ts"],"sourcesContent":["import { blindCast } from '@prisma-next/utils/casts';\nimport type { Codec } from './codec';\nimport type { AnyCodecDescriptor } from './codec-descriptor';\nimport type { CodecInstanceContext, CodecRef } from './codec-types';\nimport { runtimeError } from './runtime-error';\n\nexport const CONTRACT_CODEC_DESCRIPTOR_MISSING = 'CONTRACT.CODEC_DESCRIPTOR_MISSING' as const;\n\n/**\n * Look up a descriptor for `ref.codecId` using `descriptorFor`; throw\n * `code` if none is found. Each plane names its own error path: the control\n * plane resolves contract-stack descriptors (`CONTRACT.*`), the execution\n * plane resolves at query time (`RUNTIME.*`).\n */\nexport function resolveCodecDescriptorOrThrow(\n descriptorFor: (codecId: string) => AnyCodecDescriptor | undefined,\n ref: CodecRef,\n code: 'CONTRACT.CODEC_DESCRIPTOR_MISSING' | 'RUNTIME.CODEC_DESCRIPTOR_MISSING',\n): AnyCodecDescriptor {\n const descriptor = descriptorFor(ref.codecId);\n if (!descriptor) {\n throw runtimeError(code, `No codec descriptor registered for codecId '${ref.codecId}'.`, {\n codecId: ref.codecId,\n });\n }\n return descriptor;\n}\n\n/**\n * Validates `ref.typeParams` against `descriptor.paramsSchema`.\n *\n * Parameterized codecs that omit `typeParams` have it normalized to `{}` before\n * validation (mirrors `ast-codec-resolver.ts` semantics). Throws\n * `RUNTIME.TYPE_PARAMS_INVALID` when the validator returns a `Promise` or\n * reports issues.\n */\nexport function validateCodecTypeParams(descriptor: AnyCodecDescriptor, ref: CodecRef): unknown {\n const normalized =\n descriptor.isParameterized && ref.typeParams === undefined ? { ...ref, typeParams: {} } : ref;\n\n const result = blindCast<\n { value: unknown } | { issues: ReadonlyArray<{ message: string }> } | Promise<unknown>,\n 'Standard Schema validate returns unknown; the spec guarantees this union shape'\n >(descriptor.paramsSchema['~standard'].validate(normalized.typeParams));\n\n if (result instanceof Promise) {\n throw runtimeError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `paramsSchema for codec '${ref.codecId}' returned a Promise; runtime validation requires a synchronous Standard Schema validator.`,\n { codecId: ref.codecId, typeParams: ref.typeParams },\n );\n }\n\n if ('issues' in result && result.issues) {\n const messages = result.issues.map((issue) => issue.message).join('; ');\n throw runtimeError(\n 'RUNTIME.TYPE_PARAMS_INVALID',\n `Invalid typeParams for codec '${ref.codecId}': ${messages}`,\n { codecId: ref.codecId, typeParams: ref.typeParams },\n );\n }\n\n return blindCast<{ value: unknown }, 'issues guard above rules out the issues branch'>(result)\n .value;\n}\n\n/**\n * Resolves a `Codec` instance: validates `ref.typeParams` via\n * {@link validateCodecTypeParams} then calls `descriptor.factory(validated)(ctx)`.\n *\n * The descriptor's `factory` is typed against its own `P`; the registry erases\n * `P` to `any`, so the factory is narrowed to `(params: unknown) => (ctx) => Codec`\n * at the call boundary. The `paramsSchema` validates the input above before we\n * forward it, so the narrowing is safe by construction.\n */\nexport function materializeCodec(\n descriptor: AnyCodecDescriptor,\n ref: CodecRef,\n ctx: CodecInstanceContext,\n): Codec {\n const validated = validateCodecTypeParams(descriptor, ref);\n return blindCast<\n (params: unknown) => (ctx: CodecInstanceContext) => Codec,\n 'registry erases P to any; paramsSchema validates input before forwarding'\n >(descriptor.factory)(validated)(ctx);\n}\n"],"mappings":";;;AAMA,MAAa,oCAAoC;;;;;;;AAQjD,SAAgB,8BACd,eACA,KACA,MACoB;CACpB,MAAM,aAAa,cAAc,IAAI,OAAO;CAC5C,IAAI,CAAC,YACH,MAAM,aAAa,MAAM,+CAA+C,IAAI,QAAQ,KAAK,EACvF,SAAS,IAAI,QACf,CAAC;CAEH,OAAO;AACT;;;;;;;;;AAUA,SAAgB,wBAAwB,YAAgC,KAAwB;CAC9F,MAAM,aACJ,WAAW,mBAAmB,IAAI,eAAe,KAAA,IAAY;EAAE,GAAG;EAAK,YAAY,CAAC;CAAE,IAAI;CAE5F,MAAM,SAAS,UAGb,WAAW,aAAa,YAAY,CAAC,SAAS,WAAW,UAAU,CAAC;CAEtE,IAAI,kBAAkB,SACpB,MAAM,aACJ,+BACA,2BAA2B,IAAI,QAAQ,6FACvC;EAAE,SAAS,IAAI;EAAS,YAAY,IAAI;CAAW,CACrD;CAGF,IAAI,YAAY,UAAU,OAAO,QAAQ;EACvC,MAAM,WAAW,OAAO,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI;EACtE,MAAM,aACJ,+BACA,iCAAiC,IAAI,QAAQ,KAAK,YAClD;GAAE,SAAS,IAAI;GAAS,YAAY,IAAI;EAAW,CACrD;CACF;CAEA,OAAO,UAAgF,MAAM,CAAC,CAC3F;AACL;;;;;;;;;;AAWA,SAAgB,iBACd,YACA,KACA,KACO;CACP,MAAM,YAAY,wBAAwB,YAAY,GAAG;CACzD,OAAO,UAGL,WAAW,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG;AACtC"} |
| //#region src/shared/runtime-error.ts | ||
| /** | ||
| * Type guard for the runtime-error envelope produced by `runtimeError`. | ||
| * | ||
| * Prefer this over duck-typing on `error.code` directly so consumers stay | ||
| * insulated from the envelope's internal shape. | ||
| */ | ||
| function isRuntimeError(error) { | ||
| return error instanceof Error && "code" in error && typeof error.code === "string" && "category" in error && "severity" in error; | ||
| } | ||
| function runtimeError(code, message, details) { | ||
| const error = Object.assign(new Error(message), { | ||
| code, | ||
| category: resolveCategory(code), | ||
| severity: "error", | ||
| ...details !== void 0 ? { details } : {} | ||
| }); | ||
| Object.defineProperty(error, "name", { | ||
| value: "RuntimeError", | ||
| configurable: true | ||
| }); | ||
| return error; | ||
| } | ||
| function resolveCategory(code) { | ||
| const prefix = code.split(".")[0] ?? "RUNTIME"; | ||
| switch (prefix) { | ||
| case "PLAN": | ||
| case "CONTRACT": | ||
| case "LINT": | ||
| case "BUDGET": return prefix; | ||
| default: return "RUNTIME"; | ||
| } | ||
| } | ||
| //#endregion | ||
| export { runtimeError as n, isRuntimeError as t }; | ||
| //# sourceMappingURL=runtime-error-B2gWOtgH.mjs.map |
| {"version":3,"file":"runtime-error-B2gWOtgH.mjs","names":[],"sources":["../src/shared/runtime-error.ts"],"sourcesContent":["export interface RuntimeErrorEnvelope extends Error {\n readonly code: string;\n readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME';\n readonly severity: 'error';\n readonly details?: Record<string, unknown>;\n}\n\n/**\n * Type guard for the runtime-error envelope produced by `runtimeError`.\n *\n * Prefer this over duck-typing on `error.code` directly so consumers stay\n * insulated from the envelope's internal shape.\n */\nexport function isRuntimeError(error: unknown): error is RuntimeErrorEnvelope {\n return (\n error instanceof Error &&\n 'code' in error &&\n typeof (error as { code?: unknown }).code === 'string' &&\n 'category' in error &&\n 'severity' in error\n );\n}\n\nexport function runtimeError(\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): RuntimeErrorEnvelope {\n const error = Object.assign(new Error(message), {\n code,\n category: resolveCategory(code),\n severity: 'error' as const,\n ...(details !== undefined ? { details } : {}),\n });\n Object.defineProperty(error, 'name', { value: 'RuntimeError', configurable: true });\n return error;\n}\n\nfunction resolveCategory(code: string): RuntimeErrorEnvelope['category'] {\n const prefix = code.split('.')[0] ?? 'RUNTIME';\n switch (prefix) {\n case 'PLAN':\n case 'CONTRACT':\n case 'LINT':\n case 'BUDGET':\n return prefix;\n default:\n return 'RUNTIME';\n }\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,eAAe,OAA+C;CAC5E,OACE,iBAAiB,SACjB,UAAU,SACV,OAAQ,MAA6B,SAAS,YAC9C,cAAc,SACd,cAAc;AAElB;AAEA,SAAgB,aACd,MACA,SACA,SACsB;CACtB,MAAM,QAAQ,OAAO,OAAO,IAAI,MAAM,OAAO,GAAG;EAC9C;EACA,UAAU,gBAAgB,IAAI;EAC9B,UAAU;EACV,GAAI,YAAY,KAAA,IAAY,EAAE,QAAQ,IAAI,CAAC;CAC7C,CAAC;CACD,OAAO,eAAe,OAAO,QAAQ;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClF,OAAO;AACT;AAEA,SAAS,gBAAgB,MAAgD;CACvE,MAAM,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC,MAAM;CACrC,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;EACT,SACE,OAAO;CACX;AACF"} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1109254
3.69%124
1.64%10779
6.93%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed