@prisma-next/sql-contract
Advanced tools
| import { t as SqlNode } from "./sql-node-V214WXQD.mjs"; | ||
| import { t as StorageTable } from "./storage-table-Bj1ZN1P7.mjs"; | ||
| import { t as StorageValueSet } from "./storage-value-set-D-jww77l.mjs"; | ||
| import { Namespace, NamespaceBase, Storage, StorageType } from "@prisma-next/framework-components/ir"; | ||
| import { StorageHashBase } from "@prisma-next/contract/types"; | ||
| import { AuthoringContributions } from "@prisma-next/framework-components/authoring"; | ||
| //#region src/ir/storage-type-instance.d.ts | ||
| /** | ||
| * Sentinel kind for the legacy codec-triple shape persisted under | ||
| * `SqlStorage.types`. Plain JSON-clean object literals carry this | ||
| * discriminator so the polymorphic slot dispatch can route them down | ||
| * the codec path while target-specific IR class instances (e.g. the | ||
| * Postgres enum class) keep their own narrower `kind` literal. | ||
| */ | ||
| declare const CODEC_INSTANCE_KIND: "codec-instance"; | ||
| /** | ||
| * Structural sub-interface of {@link StorageType} for codec-typed entries | ||
| * in `SqlStorage.types`. These are plain object literals — there is no | ||
| * runtime IR class, the JSON envelope round-trips through the slot | ||
| * unchanged. The `kind: 'codec-instance'` discriminator is the dispatch | ||
| * key that distinguishes codec-typed entries from any class-instance | ||
| * kinds a target pack contributes to the polymorphic slot. | ||
| */ | ||
| interface StorageTypeInstance extends StorageType { | ||
| readonly kind: typeof CODEC_INSTANCE_KIND; | ||
| readonly codecId: string; | ||
| readonly nativeType: string; | ||
| readonly typeParams: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Construction-time input for a codec-triple entry. Symmetric with the | ||
| * structural runtime shape minus the `kind` discriminator — callers may | ||
| * omit `kind`; the helper {@link toStorageTypeInstance} stamps it on. | ||
| * `typeParams` may be omitted on input; the constructor normalises a | ||
| * missing value to `{}` so the in-memory shape is always present. | ||
| */ | ||
| interface StorageTypeInstanceInput { | ||
| readonly codecId: string; | ||
| readonly nativeType: string; | ||
| readonly typeParams?: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Stamp the codec-instance `kind` discriminator on a caller-supplied | ||
| * codec triple. Idempotent: input that already carries the discriminator | ||
| * passes through unchanged. Missing `typeParams` is normalised to `{}`. | ||
| */ | ||
| declare function toStorageTypeInstance(input: StorageTypeInstanceInput): StorageTypeInstance; | ||
| /** | ||
| * Type-guard for codec-typed entries on the polymorphic | ||
| * `SqlStorage.types` slot. Distinguishes `StorageTypeInstance` from | ||
| * any class-instance kinds a target pack contributes. | ||
| */ | ||
| declare function isStorageTypeInstance(value: unknown): value is StorageTypeInstance; | ||
| //#endregion | ||
| //#region src/ir/sql-storage.d.ts | ||
| /** | ||
| * Polymorphic value type for document-scoped `SqlStorage.types` entries | ||
| * (codec aliases / parameterised native type registrations). | ||
| * | ||
| * Postgres native enum registrations live under the postgres-specific | ||
| * `entries.type` slot on `PostgresSchema` (target layer), not here. | ||
| */ | ||
| type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput; | ||
| interface SqlNamespaceInput { | ||
| readonly id: string; | ||
| readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>; | ||
| } | ||
| /** | ||
| * Target-supplied factory that materializes a `Namespace` from a SQL | ||
| * `SqlNamespaceInput` (used to populate `SqlStorage.namespaces`). | ||
| */ | ||
| type SqlNamespaceFactory = (input: SqlNamespaceInput) => Namespace; | ||
| /** | ||
| * SQL-family extension of the framework `AuthoringContributions`. SQL target | ||
| * packs add a `createNamespace` factory so the PSL/TS authoring paths can | ||
| * materialize namespaces (and merge lowered extension-block entities) without | ||
| * each consumer re-specifying it. The factory is SQL-specific, so it lives here | ||
| * rather than on the framework `AuthoringContributions` base. | ||
| */ | ||
| interface SqlAuthoringContributions extends AuthoringContributions { | ||
| readonly createNamespace?: SqlNamespaceFactory; | ||
| } | ||
| /** | ||
| * Narrows framework `AuthoringContributions` to the SQL-family shape by testing | ||
| * for the SQL-specific `createNamespace` capability. | ||
| */ | ||
| declare function isSqlAuthoringContributions(authoring: AuthoringContributions | undefined): authoring is SqlAuthoringContributions; | ||
| interface SqlStorageInput<THash extends string = string> { | ||
| readonly storageHash: StorageHashBase<THash>; | ||
| readonly types?: Record<string, SqlStorageTypeEntry>; | ||
| readonly namespaces: Readonly<Record<string, SqlNamespaceBase>>; | ||
| } | ||
| /** | ||
| * SQL Contract IR root node for the `storage` field. | ||
| * | ||
| * Single concrete family-shared class — both Postgres and SQLite | ||
| * consume this class today. Per-target storage subclasses are | ||
| * introduced when each target's namespace shape earns its | ||
| * target-specific concretion (target-specific derived fields, | ||
| * target-specific storage extensions). | ||
| * | ||
| * Honours the framework `Storage` interface: every SQL IR carries a | ||
| * `namespaces` map keyed by namespace id. Callers must supply fully | ||
| * constructed `Namespace` instances — construction discipline lives | ||
| * in the authoring builders and deserializer hydration paths. | ||
| * | ||
| * The constructor normalises optional `types` into class instances. | ||
| * `types` is polymorphic per Decision 18 Option B: codec-triple inputs | ||
| * are stamped with `kind: 'codec-instance'`; hydration of raw JSON | ||
| * class-instance entries (carrying their narrower `kind` literal) is | ||
| * the per-target serializer's responsibility (so the family base does | ||
| * not import target-specific subclasses). | ||
| */ | ||
| /** | ||
| * The typed `entries` shape for SQL family namespaces. The open dictionary | ||
| * is intersected with optional known-kind maps so that `ns.entries.table` | ||
| * and `ns.entries.valueSet` resolve without a cast, while unknown pack- | ||
| * contributed kinds remain valid (the `Record` part allows any string key). | ||
| */ | ||
| type SqlNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & { | ||
| readonly table?: Readonly<Record<string, StorageTable>>; | ||
| readonly valueSet?: Readonly<Record<string, StorageValueSet>>; | ||
| }; | ||
| /** | ||
| * Structural interface for SQL family namespaces. Generated `.d.ts` contract | ||
| * types satisfy this structurally (no prototype methods). The runtime | ||
| * abstract class `SqlNamespaceBase` extends this. | ||
| * | ||
| * `qualifyTable` and `isUnbound` are optional so JSON-shaped contract types | ||
| * (which carry no methods) are accepted where `SqlNamespace` is required. | ||
| * Hydrated `SqlNamespaceBase` instances always have both. | ||
| */ | ||
| interface SqlNamespace { | ||
| readonly kind: string; | ||
| readonly id: string; | ||
| readonly entries: SqlNamespaceEntries; | ||
| readonly isUnbound?: boolean; | ||
| qualifyTable?(tableName: string): string; | ||
| } | ||
| /** | ||
| * Abstract SQL family namespace base class. Target concretions (`PostgresSchema`, | ||
| * `SqliteDatabase`, …) extend this — it is never instantiated directly. | ||
| * `entries` is the open ADR 224 dictionary: `entries[entityKind][entityName]` | ||
| * addresses any entity. | ||
| */ | ||
| declare abstract class SqlNamespaceBase extends NamespaceBase implements SqlNamespace { | ||
| abstract readonly id: string; | ||
| abstract readonly entries: SqlNamespaceEntries; | ||
| abstract qualifyTable(tableName: string): string; | ||
| } | ||
| /** | ||
| * Realm-safe guard for hydrated `SqlNamespaceBase` concretions. Checks | ||
| * `qualifyTable` structurally instead of `instanceof NamespaceBase`, so it | ||
| * survives duplicate-module boundaries (e.g. dist e2e where the target and | ||
| * the family carry separate copies of `@prisma-next/framework-components`). | ||
| * | ||
| * Every concrete `SqlNamespaceBase` subclass (`PostgresSchema`, `SqliteDatabase`, | ||
| * `TestSqlNamespace`, …) implements `qualifyTable`. Raw `SqlNamespaceInput` | ||
| * objects (`{ id, entries }`) do not. | ||
| */ | ||
| declare function isMaterializedSqlNamespace(x: unknown): x is SqlNamespaceBase; | ||
| declare class SqlStorage<THash extends string = string> extends SqlNode implements Storage { | ||
| readonly storageHash: StorageHashBase<THash>; | ||
| readonly namespaces: Readonly<Record<string, SqlNamespace>>; | ||
| readonly types?: Readonly<Record<string, StorageTypeInstance>>; | ||
| constructor(input: SqlStorageInput<THash>); | ||
| } | ||
| //#endregion | ||
| export { SqlNamespaceFactory as a, SqlStorageInput as c, isSqlAuthoringContributions as d, CODEC_INSTANCE_KIND as f, toStorageTypeInstance as g, isStorageTypeInstance as h, SqlNamespaceEntries as i, SqlStorageTypeEntry as l, StorageTypeInstanceInput as m, SqlNamespace as n, SqlNamespaceInput as o, StorageTypeInstance as p, SqlNamespaceBase as r, SqlStorage as s, SqlAuthoringContributions as t, isMaterializedSqlNamespace as u }; | ||
| //# sourceMappingURL=sql-storage-Dt5ipcRl.d.mts.map |
| {"version":3,"file":"sql-storage-Dt5ipcRl.d.mts","names":[],"sources":["../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts"],"mappings":";;;;;;;;;;;;;;;cASa,mBAAA;;;;AAA+C;AAU5D;;;;UAAiB,mBAAA,SAA4B,WAAA;EAAA,SAClC,IAAA,SAAa,mBAAA;EAAA,SACb,OAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA,EAAY,MAAA;AAAA;;;;;;;AAAM;UAUZ,wBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;;;AAAA;iBAQd,qBAAA,CAAsB,KAAA,EAAO,wBAAA,GAA2B,mBAAmB;;;;;;iBAc3E,qBAAA,CAAsB,KAAA,YAAiB,KAAA,IAAS,mBAAmB;;;;AAjDnF;;;;AAA4D;AAU5D;KCOY,mBAAA,GAAsB,mBAAA,GAAsB,wBAAwB;AAAA,UAE/D,iBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;AAAA;;;;;KAOzC,mBAAA,IAAuB,KAAA,EAAO,iBAAA,KAAsB,SAAS;;;;;;ADd5C;AAU7B;UCaiB,yBAAA,SAAkC,sBAAsB;EAAA,SAC9D,eAAA,GAAkB,mBAAA;AAAA;;;;;iBAOb,2BAAA,CACd,SAAA,EAAW,sBAAA,eACV,SAAA,IAAa,yBAAyB;AAAA,UAOxB,eAAA;EAAA,SACN,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,KAAA,GAAQ,MAAA,SAAe,mBAAA;EAAA,SACvB,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,gBAAA;AAAA;;;;;ADtB4C;AAc3F;;;;;;;;AAAmF;;;;AChCnF;;;;AAAgF;AAEhF;;;;;AAFgF,KAsEpE,mBAAA,GAAsB,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;EAAA,SACxD,KAAA,GAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAChC,QAAA,GAAW,QAAA,CAAS,MAAA,SAAe,eAAA;AAAA;;;;;;;;AApEa;AAO3D;UAyEiB,YAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA;EAAA,SACA,OAAA,EAAS,mBAAmB;EAAA,SAC5B,SAAA;EACT,YAAA,EAAc,SAAA;AAAA;AA9EyD;AASzE;;;;;AATyE,uBAuFnD,gBAAA,SAAyB,aAAA,YAAyB,YAAA;EAAA,kBAC3C,EAAA;EAAA,kBACA,OAAA,EAAS,mBAAA;EAAA,SAE3B,YAAA,CAAa,SAAA;AAAA;;;;;;;;;AAxEiB;AAOzC;iBA8EgB,0BAAA,CAA2B,CAAA,YAAa,CAAA,IAAK,gBAAgB;AAAA,cAKhE,UAAA,wCAAkD,OAAA,YAAmB,OAAA;EAAA,SACvE,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAC5B,KAAA,GAAQ,QAAA,CAAS,MAAA,SAAe,mBAAA;cAErC,KAAA,EAAO,eAAA,CAAgB,KAAA;AAAA"} |
@@ -1,2 +0,2 @@ | ||
| import { s as SqlStorage } from "./sql-storage-BRB55sCP.mjs"; | ||
| import { s as SqlStorage } from "./sql-storage-Dt5ipcRl.mjs"; | ||
| import { DefaultNamespaceEntries, NamespacedEntities, SingleNamespaceView } from "@prisma-next/framework-components/ir"; | ||
@@ -3,0 +3,0 @@ import { Contract } from "@prisma-next/contract/types"; |
@@ -1,2 +0,2 @@ | ||
| import { s as SqlStorage } from "./sql-storage-BRB55sCP.mjs"; | ||
| import { s as SqlStorage } from "./sql-storage-Dt5ipcRl.mjs"; | ||
| import { a as IndexTypeRegistry } from "./index-types-Czsyu7Iw.mjs"; | ||
@@ -3,0 +3,0 @@ import { Contract } from "@prisma-next/contract/types"; |
| import { t as StorageTable } from "./storage-table-Bj1ZN1P7.mjs"; | ||
| import { s as SqlStorage } from "./sql-storage-BRB55sCP.mjs"; | ||
| import { s as SqlStorage } from "./sql-storage-Dt5ipcRl.mjs"; | ||
@@ -4,0 +4,0 @@ //#region src/resolve-storage-table.d.ts |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types-KiOT4SAV.mjs","names":[],"sources":["../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts","../src/types.ts"],"sourcesContent":["import type { StorageType } from '@prisma-next/framework-components/ir';\n\n/**\n * Sentinel kind for the legacy codec-triple shape persisted under\n * `SqlStorage.types`. Plain JSON-clean object literals carry this\n * discriminator so the polymorphic slot dispatch can route them down\n * the codec path while target-specific IR class instances (e.g. the\n * Postgres enum class) keep their own narrower `kind` literal.\n */\nexport const CODEC_INSTANCE_KIND = 'codec-instance' as const;\n\n/**\n * Structural sub-interface of {@link StorageType} for codec-typed entries\n * in `SqlStorage.types`. These are plain object literals — there is no\n * runtime IR class, the JSON envelope round-trips through the slot\n * unchanged. The `kind: 'codec-instance'` discriminator is the dispatch\n * key that distinguishes codec-typed entries from any class-instance\n * kinds a target pack contributes to the polymorphic slot.\n */\nexport interface StorageTypeInstance extends StorageType {\n readonly kind: typeof CODEC_INSTANCE_KIND;\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n}\n\n/**\n * Construction-time input for a codec-triple entry. Symmetric with the\n * structural runtime shape minus the `kind` discriminator — callers may\n * omit `kind`; the helper {@link toStorageTypeInstance} stamps it on.\n * `typeParams` may be omitted on input; the constructor normalises a\n * missing value to `{}` so the in-memory shape is always present.\n */\nexport interface StorageTypeInstanceInput {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n}\n\n/**\n * Stamp the codec-instance `kind` discriminator on a caller-supplied\n * codec triple. Idempotent: input that already carries the discriminator\n * passes through unchanged. Missing `typeParams` is normalised to `{}`.\n */\nexport function toStorageTypeInstance(input: StorageTypeInstanceInput): StorageTypeInstance {\n return {\n kind: CODEC_INSTANCE_KIND,\n codecId: input.codecId,\n nativeType: input.nativeType,\n typeParams: input.typeParams ?? {},\n };\n}\n\n/**\n * Type-guard for codec-typed entries on the polymorphic\n * `SqlStorage.types` slot. Distinguishes `StorageTypeInstance` from\n * any class-instance kinds a target pack contributes.\n */\nexport function isStorageTypeInstance(value: unknown): value is StorageTypeInstance {\n if (typeof value !== 'object' || value === null) return false;\n return (value as { kind?: unknown }).kind === CODEC_INSTANCE_KIND;\n}\n","import type { StorageHashBase } from '@prisma-next/contract/types';\nimport type { AuthoringContributions } from '@prisma-next/framework-components/authoring';\nimport {\n freezeNode,\n isPlainRecord,\n type Namespace,\n NamespaceBase,\n type Storage,\n} from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\nimport type { StorageTable } from './storage-table';\nimport {\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './storage-type-instance';\nimport type { StorageValueSet } from './storage-value-set';\n\n/**\n * Polymorphic value type for document-scoped `SqlStorage.types` entries\n * (codec aliases / parameterised native type registrations).\n *\n * Postgres native enum registrations live under the postgres-specific\n * `entries.type` slot on `PostgresSchema` (target layer), not here.\n */\nexport type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput;\n\nexport interface SqlNamespaceInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Target-supplied factory that materializes a `Namespace` from a SQL\n * `SqlNamespaceInput` (used to populate `SqlStorage.namespaces`).\n */\nexport type SqlNamespaceFactory = (input: SqlNamespaceInput) => Namespace;\n\n/**\n * SQL-family extension of the framework `AuthoringContributions`. SQL target\n * packs add a `createNamespace` factory so the PSL/TS authoring paths can\n * materialize namespaces (and merge lowered extension-block entities) without\n * each consumer re-specifying it. The factory is SQL-specific, so it lives here\n * rather than on the framework `AuthoringContributions` base.\n */\nexport interface SqlAuthoringContributions extends AuthoringContributions {\n readonly createNamespace?: SqlNamespaceFactory;\n}\n\n/**\n * Narrows framework `AuthoringContributions` to the SQL-family shape by testing\n * for the SQL-specific `createNamespace` capability.\n */\nexport function isSqlAuthoringContributions(\n authoring: AuthoringContributions | undefined,\n): authoring is SqlAuthoringContributions {\n if (authoring === undefined || !Object.hasOwn(authoring, 'createNamespace')) {\n return false;\n }\n return typeof Reflect.get(authoring, 'createNamespace') === 'function';\n}\n\nexport interface SqlStorageInput<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly types?: Record<string, SqlStorageTypeEntry>;\n readonly namespaces: Readonly<Record<string, SqlNamespaceBase>>;\n}\n\n/**\n * SQL Contract IR root node for the `storage` field.\n *\n * Single concrete family-shared class — both Postgres and SQLite\n * consume this class today. Per-target storage subclasses are\n * introduced when each target's namespace shape earns its\n * target-specific concretion (target-specific derived fields,\n * target-specific storage extensions).\n *\n * Honours the framework `Storage` interface: every SQL IR carries a\n * `namespaces` map keyed by namespace id. Callers must supply fully\n * constructed `Namespace` instances — construction discipline lives\n * in the authoring builders and deserializer hydration paths.\n *\n * The constructor normalises optional `types` into class instances.\n * `types` is polymorphic per Decision 18 Option B: codec-triple inputs\n * are stamped with `kind: 'codec-instance'`; hydration of raw JSON\n * class-instance entries (carrying their narrower `kind` literal) is\n * the per-target serializer's responsibility (so the family base does\n * not import target-specific subclasses).\n */\n/**\n * The typed `entries` shape for SQL family namespaces. The open dictionary\n * is intersected with optional known-kind maps so that `ns.entries.table`\n * and `ns.entries.valueSet` resolve without a cast, while unknown pack-\n * contributed kinds remain valid (the `Record` part allows any string key).\n */\nexport type SqlNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & {\n readonly table?: Readonly<Record<string, StorageTable>>;\n readonly valueSet?: Readonly<Record<string, StorageValueSet>>;\n};\n\n/**\n * Structural interface for SQL family namespaces. Generated `.d.ts` contract\n * types satisfy this structurally (no prototype methods). The runtime\n * abstract class `SqlNamespaceBase` extends this.\n *\n * `qualifyTable` is optional so JSON-shaped contract types (which carry no\n * methods) are accepted where `SqlNamespace` is required. Hydrated\n * `SqlNamespaceBase` instances always have it.\n */\nexport interface SqlNamespace {\n readonly kind: string;\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n qualifyTable?(tableName: string): string;\n}\n\n/**\n * Abstract SQL family namespace base class. Target concretions (`PostgresSchema`,\n * `SqliteDatabase`, …) extend this — it is never instantiated directly.\n * `entries` is the open ADR 224 dictionary: `entries[entityKind][entityName]`\n * addresses any entity.\n */\nexport abstract class SqlNamespaceBase extends NamespaceBase implements SqlNamespace {\n abstract override readonly id: string;\n abstract override readonly entries: SqlNamespaceEntries;\n\n abstract qualifyTable(tableName: string): string;\n}\n\n/**\n * Realm-safe guard for hydrated `SqlNamespaceBase` concretions. Checks\n * `qualifyTable` structurally instead of `instanceof NamespaceBase`, so it\n * survives duplicate-module boundaries (e.g. dist e2e where the target and\n * the family carry separate copies of `@prisma-next/framework-components`).\n *\n * Every concrete `SqlNamespaceBase` subclass (`PostgresSchema`, `SqliteDatabase`,\n * `TestSqlNamespace`, …) implements `qualifyTable`. Raw `SqlNamespaceInput`\n * objects (`{ id, entries }`) do not.\n */\nexport function isMaterializedSqlNamespace(x: unknown): x is SqlNamespaceBase {\n if (typeof x !== 'object' || x === null || !('qualifyTable' in x)) return false;\n return typeof x.qualifyTable === 'function';\n}\n\nexport class SqlStorage<THash extends string = string> extends SqlNode implements Storage {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, SqlNamespace>>;\n declare readonly types?: Readonly<Record<string, StorageTypeInstance>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\n this.namespaces = Object.freeze(input.namespaces);\n if (input.types !== undefined) {\n this.types = Object.freeze(\n Object.fromEntries(\n Object.entries(input.types).map(([name, ti]) => [name, normaliseTypeEntry(name, ti)]),\n ),\n );\n }\n freezeNode(this);\n }\n}\n\n/**\n * Strict polymorphic-slot dispatch for `SqlStorage.types` entries.\n * Every entry must carry a `kind: 'codec-instance'` discriminator or\n * be an already-constructed `StorageTypeInstance`. Untagged or\n * unrecognised inputs throw a diagnostic naming the entry and its\n * `kind`, so format drift surfaces loudly at the deserializer\n * boundary instead of slipping past the seam and corrupting\n * downstream IR walks.\n *\n * Codec-triple authors that have an untagged shape on hand can call\n * `toStorageTypeInstance(...)` (which stamps the `'codec-instance'`\n * discriminator) before constructing `SqlStorage`. On-disk reads\n * cross `familyInstance.deserializeContract` first; the structural\n * arktype schema rejects untagged entries earlier, so this throw\n * only fires for in-memory authoring bugs.\n */\nfunction normaliseTypeEntry(name: string, entry: SqlStorageTypeEntry): StorageTypeInstance {\n if (isStorageTypeInstance(entry)) {\n // Normalise on-disk objects that omit `typeParams` (the canonical on-disk\n // form strips empty typeParams to keep JSON compact). The in-memory invariant\n // is always `typeParams: {}` when empty — never `undefined`. Only create a\n // new object when necessary to preserve identity-equality for callers that\n // hold a reference to an already-correct in-memory entry.\n if ('typeParams' in entry) {\n return entry;\n }\n return toStorageTypeInstance(entry);\n }\n const rawKind = isPlainRecord(entry) ? entry['kind'] : undefined;\n const kindDescription =\n rawKind === undefined\n ? 'missing `kind` discriminator'\n : `unrecognised \\`kind\\` discriminator ${JSON.stringify(rawKind)}`;\n throw new Error(\n `storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify('codec-instance')}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`,\n );\n}\n","import type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { ControlDriverInstance } from '@prisma-next/framework-components/control';\nimport type { ReferentialAction } from './ir/foreign-key';\n\nexport interface SqlControlDriverInstance<T extends string = string>\n extends ControlDriverInstance<'sql', T> {\n query<Row = Record<string, unknown>>(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ readonly rows: Row[] }>;\n}\n\nexport { CheckConstraint, type CheckConstraintInput } from './ir/check-constraint';\nexport {\n ForeignKey,\n type ForeignKeyInput,\n type ReferentialAction,\n} from './ir/foreign-key';\nexport {\n ForeignKeyReference,\n type ForeignKeyReferenceInput,\n} from './ir/foreign-key-reference';\nexport { PrimaryKey, type PrimaryKeyInput } from './ir/primary-key';\nexport { Index, type IndexInput } from './ir/sql-index';\nexport { SqlNode } from './ir/sql-node';\nexport {\n isMaterializedSqlNamespace,\n isSqlAuthoringContributions,\n type SqlAuthoringContributions,\n type SqlNamespace,\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceFactory,\n type SqlNamespaceInput,\n SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n} from './ir/sql-storage';\nexport { StorageColumn, type StorageColumnInput } from './ir/storage-column';\nexport { StorageTable, type StorageTableInput } from './ir/storage-table';\nexport {\n CODEC_INSTANCE_KIND,\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './ir/storage-type-instance';\nexport {\n isStorageValueSet,\n StorageValueSet,\n type StorageValueSetInput,\n} from './ir/storage-value-set';\nexport {\n UniqueConstraint,\n type UniqueConstraintInput,\n} from './ir/unique-constraint';\n\nexport type ForeignKeyOptions = {\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\nexport type SqlModelFieldStorage = {\n readonly column: string;\n readonly codecId?: string;\n readonly nullable?: boolean;\n};\n\nexport type SqlModelStorage = {\n readonly table: string;\n readonly namespaceId: string;\n readonly fields: Record<string, SqlModelFieldStorage>;\n};\n\nexport const DEFAULT_FK_CONSTRAINT = true;\nexport const DEFAULT_FK_INDEX = true;\n\nexport function applyFkDefaults(\n fk: { constraint?: boolean | undefined; index?: boolean | undefined },\n overrideDefaults?: { constraint?: boolean | undefined; index?: boolean | undefined },\n): { constraint: boolean; index: boolean } {\n return {\n constraint: fk.constraint ?? overrideDefaults?.constraint ?? DEFAULT_FK_CONSTRAINT,\n index: fk.index ?? overrideDefaults?.index ?? DEFAULT_FK_INDEX,\n };\n}\n\n// Field-type maps nested by namespace coordinate: `[namespaceId][model][field]`.\n// Shared by the output and input field-type maps and their extractors.\nexport type NamespacedFieldTypeMap = Record<string, Record<string, Record<string, unknown>>>;\n\nexport type NamespacedStorageColumnTypeMap = Record<\n string,\n Record<string, Record<string, unknown>>\n>;\n\nexport type TypeMaps<\n TCodecTypes extends Record<string, { output: unknown }> = Record<string, never>,\n TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,\n TFieldOutputTypes extends NamespacedFieldTypeMap = Record<string, never>,\n TFieldInputTypes extends NamespacedFieldTypeMap = Record<string, never>,\n TStorageColumnTypes extends NamespacedStorageColumnTypeMap = Record<string, never>,\n TStorageColumnInputTypes extends NamespacedStorageColumnTypeMap = Record<string, never>,\n> = {\n readonly codecTypes: TCodecTypes;\n readonly queryOperationTypes: TQueryOperationTypes;\n readonly fieldOutputTypes: TFieldOutputTypes;\n readonly fieldInputTypes: TFieldInputTypes;\n readonly storageColumnTypes: TStorageColumnTypes;\n readonly storageColumnInputTypes: TStorageColumnInputTypes;\n};\n\nexport type CodecTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly codecTypes: infer C }\n ? C extends Record<string, { output: unknown }>\n ? C\n : Record<string, never>\n : Record<string, never>;\n\n/**\n * Dispatch hint identifying the first-argument target of an operation.\n *\n * Used by ORM column helpers to decide whether an operation is reachable on a\n * field. Names a concrete codec identity, a set of capability traits the\n * field's codec must carry, or targets list-typed (`many`) fields. Element\n * capability gating for list ops travels in `elementTraits`.\n */\nexport type QueryOperationSelfSpec =\n | { readonly codecId: string; readonly traits?: never; readonly many?: never }\n | { readonly traits: readonly CodecTrait[]; readonly codecId?: never; readonly many?: never }\n | {\n readonly many: true;\n readonly elementTraits?: readonly CodecTrait[];\n readonly codecId?: never;\n readonly traits?: never;\n };\n\n/**\n * Structural shape an operation's impl must return: any value carrying a\n * codec-exact `returnType` descriptor. `Expression<T>` (from\n * `@prisma-next/sql-relational-core/expression`, with `T extends ScopeField`)\n * extends this. Trait-targeted returns are deliberately excluded — predicate\n * detection and result decoding both depend on knowing the concrete return\n * codec.\n */\nexport type QueryOperationReturn = {\n readonly returnType: { readonly codecId: string; readonly nullable: boolean };\n};\n\nexport type QueryOperationTypeEntry = {\n readonly self?: QueryOperationSelfSpec;\n readonly impl: (...args: never[]) => QueryOperationReturn;\n};\n\nexport type SqlQueryOperationTypes<\n _CT extends Record<string, { readonly input: unknown; readonly output: unknown }>,\n T extends Record<string, QueryOperationTypeEntry>,\n> = T;\n\nexport type QueryOperationTypesBase = Record<string, QueryOperationTypeEntry>;\n\nexport type QueryOperationTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly queryOperationTypes: infer Q }\n ? Q extends Record<string, unknown>\n ? Q\n : Record<string, never>\n : Record<string, never>;\n\nexport type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';\n\nexport type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & {\n readonly [K in TypeMapsPhantomKey]?: TTypeMaps;\n};\n\nexport type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T\n ? NonNullable<T[TypeMapsPhantomKey & keyof T]>\n : never;\n\nexport type FieldOutputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldOutputTypes: infer F }\n ? F extends NamespacedFieldTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type FieldInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldInputTypes: infer F }\n ? F extends NamespacedFieldTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type StorageColumnTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly storageColumnTypes: infer F }\n ? F extends NamespacedStorageColumnTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type StorageColumnInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly storageColumnInputTypes: infer F }\n ? F extends NamespacedStorageColumnTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractStorageColumnTypes<T> = StorageColumnTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractStorageColumnInputTypes<T> = StorageColumnInputTypesOf<\n ExtractTypeMapsFromContract<T>\n>;\n\nexport type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractCodecTypes<TContract>\n : CodecTypesOf<TTypeMaps>;\n"],"mappings":";;;;;;;;;;AASA,MAAa,sBAAsB;;;;;;AAmCnC,SAAgB,sBAAsB,OAAsD;CAC1F,OAAO;EACL,MAAM;EACN,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,YAAY,MAAM,cAAc,CAAC;CACnC;AACF;;;;;;AAOA,SAAgB,sBAAsB,OAA8C;CAClF,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAQ,MAA6B,SAAS;AAChD;;;;;;;ACPA,SAAgB,4BACd,WACwC;CACxC,IAAI,cAAc,KAAA,KAAa,CAAC,OAAO,OAAO,WAAW,iBAAiB,GACxE,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,WAAW,iBAAiB,MAAM;AAC9D;;;;;;;AA8DA,IAAsB,mBAAtB,cAA+C,cAAsC,CAKrF;;;;;;;;;;;AAYA,SAAgB,2BAA2B,GAAmC;CAC5E,IAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,EAAE,kBAAkB,IAAI,OAAO;CAC1E,OAAO,OAAO,EAAE,iBAAiB;AACnC;AAEA,IAAa,aAAb,cAA+D,QAA2B;CACxF;CACA;CAGA,YAAY,OAA+B;EACzC,MAAM;EACN,KAAK,cAAc,MAAM;EACzB,KAAK,aAAa,OAAO,OAAO,MAAM,UAAU;EAChD,IAAI,MAAM,UAAU,KAAA,GAClB,KAAK,QAAQ,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,mBAAmB,MAAM,EAAE,CAAC,CAAC,CACtF,CACF;EAEF,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAS,mBAAmB,MAAc,OAAiD;CACzF,IAAI,sBAAsB,KAAK,GAAG;EAMhC,IAAI,gBAAgB,OAClB,OAAO;EAET,OAAO,sBAAsB,KAAK;CACpC;CACA,MAAM,UAAU,cAAc,KAAK,IAAI,MAAM,UAAU,KAAA;CACvD,MAAM,kBACJ,YAAY,KAAA,IACR,iCACA,uCAAuC,KAAK,UAAU,OAAO;CACnE,MAAM,IAAI,MACR,iBAAiB,KAAK,UAAU,IAAI,EAAE,QAAQ,gBAAgB,aAAa,KAAK,UAAU,gBAAgB,EAAE,gGAC9G;AACF;;;AC9HA,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,SAAgB,gBACd,IACA,kBACyC;CACzC,OAAO;EACL,YAAY,GAAG,cAAc,kBAAkB,cAAA;EAC/C,OAAO,GAAG,SAAS,kBAAkB,SAAA;CACvC;AACF"} | ||
| {"version":3,"file":"types-KiOT4SAV.mjs","names":[],"sources":["../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts","../src/types.ts"],"sourcesContent":["import type { StorageType } from '@prisma-next/framework-components/ir';\n\n/**\n * Sentinel kind for the legacy codec-triple shape persisted under\n * `SqlStorage.types`. Plain JSON-clean object literals carry this\n * discriminator so the polymorphic slot dispatch can route them down\n * the codec path while target-specific IR class instances (e.g. the\n * Postgres enum class) keep their own narrower `kind` literal.\n */\nexport const CODEC_INSTANCE_KIND = 'codec-instance' as const;\n\n/**\n * Structural sub-interface of {@link StorageType} for codec-typed entries\n * in `SqlStorage.types`. These are plain object literals — there is no\n * runtime IR class, the JSON envelope round-trips through the slot\n * unchanged. The `kind: 'codec-instance'` discriminator is the dispatch\n * key that distinguishes codec-typed entries from any class-instance\n * kinds a target pack contributes to the polymorphic slot.\n */\nexport interface StorageTypeInstance extends StorageType {\n readonly kind: typeof CODEC_INSTANCE_KIND;\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams: Record<string, unknown>;\n}\n\n/**\n * Construction-time input for a codec-triple entry. Symmetric with the\n * structural runtime shape minus the `kind` discriminator — callers may\n * omit `kind`; the helper {@link toStorageTypeInstance} stamps it on.\n * `typeParams` may be omitted on input; the constructor normalises a\n * missing value to `{}` so the in-memory shape is always present.\n */\nexport interface StorageTypeInstanceInput {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n}\n\n/**\n * Stamp the codec-instance `kind` discriminator on a caller-supplied\n * codec triple. Idempotent: input that already carries the discriminator\n * passes through unchanged. Missing `typeParams` is normalised to `{}`.\n */\nexport function toStorageTypeInstance(input: StorageTypeInstanceInput): StorageTypeInstance {\n return {\n kind: CODEC_INSTANCE_KIND,\n codecId: input.codecId,\n nativeType: input.nativeType,\n typeParams: input.typeParams ?? {},\n };\n}\n\n/**\n * Type-guard for codec-typed entries on the polymorphic\n * `SqlStorage.types` slot. Distinguishes `StorageTypeInstance` from\n * any class-instance kinds a target pack contributes.\n */\nexport function isStorageTypeInstance(value: unknown): value is StorageTypeInstance {\n if (typeof value !== 'object' || value === null) return false;\n return (value as { kind?: unknown }).kind === CODEC_INSTANCE_KIND;\n}\n","import type { StorageHashBase } from '@prisma-next/contract/types';\nimport type { AuthoringContributions } from '@prisma-next/framework-components/authoring';\nimport {\n freezeNode,\n isPlainRecord,\n type Namespace,\n NamespaceBase,\n type Storage,\n} from '@prisma-next/framework-components/ir';\nimport { SqlNode } from './sql-node';\nimport type { StorageTable } from './storage-table';\nimport {\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './storage-type-instance';\nimport type { StorageValueSet } from './storage-value-set';\n\n/**\n * Polymorphic value type for document-scoped `SqlStorage.types` entries\n * (codec aliases / parameterised native type registrations).\n *\n * Postgres native enum registrations live under the postgres-specific\n * `entries.type` slot on `PostgresSchema` (target layer), not here.\n */\nexport type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput;\n\nexport interface SqlNamespaceInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Target-supplied factory that materializes a `Namespace` from a SQL\n * `SqlNamespaceInput` (used to populate `SqlStorage.namespaces`).\n */\nexport type SqlNamespaceFactory = (input: SqlNamespaceInput) => Namespace;\n\n/**\n * SQL-family extension of the framework `AuthoringContributions`. SQL target\n * packs add a `createNamespace` factory so the PSL/TS authoring paths can\n * materialize namespaces (and merge lowered extension-block entities) without\n * each consumer re-specifying it. The factory is SQL-specific, so it lives here\n * rather than on the framework `AuthoringContributions` base.\n */\nexport interface SqlAuthoringContributions extends AuthoringContributions {\n readonly createNamespace?: SqlNamespaceFactory;\n}\n\n/**\n * Narrows framework `AuthoringContributions` to the SQL-family shape by testing\n * for the SQL-specific `createNamespace` capability.\n */\nexport function isSqlAuthoringContributions(\n authoring: AuthoringContributions | undefined,\n): authoring is SqlAuthoringContributions {\n if (authoring === undefined || !Object.hasOwn(authoring, 'createNamespace')) {\n return false;\n }\n return typeof Reflect.get(authoring, 'createNamespace') === 'function';\n}\n\nexport interface SqlStorageInput<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly types?: Record<string, SqlStorageTypeEntry>;\n readonly namespaces: Readonly<Record<string, SqlNamespaceBase>>;\n}\n\n/**\n * SQL Contract IR root node for the `storage` field.\n *\n * Single concrete family-shared class — both Postgres and SQLite\n * consume this class today. Per-target storage subclasses are\n * introduced when each target's namespace shape earns its\n * target-specific concretion (target-specific derived fields,\n * target-specific storage extensions).\n *\n * Honours the framework `Storage` interface: every SQL IR carries a\n * `namespaces` map keyed by namespace id. Callers must supply fully\n * constructed `Namespace` instances — construction discipline lives\n * in the authoring builders and deserializer hydration paths.\n *\n * The constructor normalises optional `types` into class instances.\n * `types` is polymorphic per Decision 18 Option B: codec-triple inputs\n * are stamped with `kind: 'codec-instance'`; hydration of raw JSON\n * class-instance entries (carrying their narrower `kind` literal) is\n * the per-target serializer's responsibility (so the family base does\n * not import target-specific subclasses).\n */\n/**\n * The typed `entries` shape for SQL family namespaces. The open dictionary\n * is intersected with optional known-kind maps so that `ns.entries.table`\n * and `ns.entries.valueSet` resolve without a cast, while unknown pack-\n * contributed kinds remain valid (the `Record` part allows any string key).\n */\nexport type SqlNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & {\n readonly table?: Readonly<Record<string, StorageTable>>;\n readonly valueSet?: Readonly<Record<string, StorageValueSet>>;\n};\n\n/**\n * Structural interface for SQL family namespaces. Generated `.d.ts` contract\n * types satisfy this structurally (no prototype methods). The runtime\n * abstract class `SqlNamespaceBase` extends this.\n *\n * `qualifyTable` and `isUnbound` are optional so JSON-shaped contract types\n * (which carry no methods) are accepted where `SqlNamespace` is required.\n * Hydrated `SqlNamespaceBase` instances always have both.\n */\nexport interface SqlNamespace {\n readonly kind: string;\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n readonly isUnbound?: boolean;\n qualifyTable?(tableName: string): string;\n}\n\n/**\n * Abstract SQL family namespace base class. Target concretions (`PostgresSchema`,\n * `SqliteDatabase`, …) extend this — it is never instantiated directly.\n * `entries` is the open ADR 224 dictionary: `entries[entityKind][entityName]`\n * addresses any entity.\n */\nexport abstract class SqlNamespaceBase extends NamespaceBase implements SqlNamespace {\n abstract override readonly id: string;\n abstract override readonly entries: SqlNamespaceEntries;\n\n abstract qualifyTable(tableName: string): string;\n}\n\n/**\n * Realm-safe guard for hydrated `SqlNamespaceBase` concretions. Checks\n * `qualifyTable` structurally instead of `instanceof NamespaceBase`, so it\n * survives duplicate-module boundaries (e.g. dist e2e where the target and\n * the family carry separate copies of `@prisma-next/framework-components`).\n *\n * Every concrete `SqlNamespaceBase` subclass (`PostgresSchema`, `SqliteDatabase`,\n * `TestSqlNamespace`, …) implements `qualifyTable`. Raw `SqlNamespaceInput`\n * objects (`{ id, entries }`) do not.\n */\nexport function isMaterializedSqlNamespace(x: unknown): x is SqlNamespaceBase {\n if (typeof x !== 'object' || x === null || !('qualifyTable' in x)) return false;\n return typeof x.qualifyTable === 'function';\n}\n\nexport class SqlStorage<THash extends string = string> extends SqlNode implements Storage {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, SqlNamespace>>;\n declare readonly types?: Readonly<Record<string, StorageTypeInstance>>;\n\n constructor(input: SqlStorageInput<THash>) {\n super();\n this.storageHash = input.storageHash;\n this.namespaces = Object.freeze(input.namespaces);\n if (input.types !== undefined) {\n this.types = Object.freeze(\n Object.fromEntries(\n Object.entries(input.types).map(([name, ti]) => [name, normaliseTypeEntry(name, ti)]),\n ),\n );\n }\n freezeNode(this);\n }\n}\n\n/**\n * Strict polymorphic-slot dispatch for `SqlStorage.types` entries.\n * Every entry must carry a `kind: 'codec-instance'` discriminator or\n * be an already-constructed `StorageTypeInstance`. Untagged or\n * unrecognised inputs throw a diagnostic naming the entry and its\n * `kind`, so format drift surfaces loudly at the deserializer\n * boundary instead of slipping past the seam and corrupting\n * downstream IR walks.\n *\n * Codec-triple authors that have an untagged shape on hand can call\n * `toStorageTypeInstance(...)` (which stamps the `'codec-instance'`\n * discriminator) before constructing `SqlStorage`. On-disk reads\n * cross `familyInstance.deserializeContract` first; the structural\n * arktype schema rejects untagged entries earlier, so this throw\n * only fires for in-memory authoring bugs.\n */\nfunction normaliseTypeEntry(name: string, entry: SqlStorageTypeEntry): StorageTypeInstance {\n if (isStorageTypeInstance(entry)) {\n // Normalise on-disk objects that omit `typeParams` (the canonical on-disk\n // form strips empty typeParams to keep JSON compact). The in-memory invariant\n // is always `typeParams: {}` when empty — never `undefined`. Only create a\n // new object when necessary to preserve identity-equality for callers that\n // hold a reference to an already-correct in-memory entry.\n if ('typeParams' in entry) {\n return entry;\n }\n return toStorageTypeInstance(entry);\n }\n const rawKind = isPlainRecord(entry) ? entry['kind'] : undefined;\n const kindDescription =\n rawKind === undefined\n ? 'missing `kind` discriminator'\n : `unrecognised \\`kind\\` discriminator ${JSON.stringify(rawKind)}`;\n throw new Error(\n `storage.types[${JSON.stringify(name)}] has ${kindDescription}; expected ${JSON.stringify('codec-instance')}. Untagged codec triples should be wrapped with toStorageTypeInstance(...) before construction.`,\n );\n}\n","import type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { ControlDriverInstance } from '@prisma-next/framework-components/control';\nimport type { ReferentialAction } from './ir/foreign-key';\n\nexport interface SqlControlDriverInstance<T extends string = string>\n extends ControlDriverInstance<'sql', T> {\n query<Row = Record<string, unknown>>(\n sql: string,\n params?: readonly unknown[],\n ): Promise<{ readonly rows: Row[] }>;\n}\n\nexport { CheckConstraint, type CheckConstraintInput } from './ir/check-constraint';\nexport {\n ForeignKey,\n type ForeignKeyInput,\n type ReferentialAction,\n} from './ir/foreign-key';\nexport {\n ForeignKeyReference,\n type ForeignKeyReferenceInput,\n} from './ir/foreign-key-reference';\nexport { PrimaryKey, type PrimaryKeyInput } from './ir/primary-key';\nexport { Index, type IndexInput } from './ir/sql-index';\nexport { SqlNode } from './ir/sql-node';\nexport {\n isMaterializedSqlNamespace,\n isSqlAuthoringContributions,\n type SqlAuthoringContributions,\n type SqlNamespace,\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceFactory,\n type SqlNamespaceInput,\n SqlStorage,\n type SqlStorageInput,\n type SqlStorageTypeEntry,\n} from './ir/sql-storage';\nexport { StorageColumn, type StorageColumnInput } from './ir/storage-column';\nexport { StorageTable, type StorageTableInput } from './ir/storage-table';\nexport {\n CODEC_INSTANCE_KIND,\n isStorageTypeInstance,\n type StorageTypeInstance,\n type StorageTypeInstanceInput,\n toStorageTypeInstance,\n} from './ir/storage-type-instance';\nexport {\n isStorageValueSet,\n StorageValueSet,\n type StorageValueSetInput,\n} from './ir/storage-value-set';\nexport {\n UniqueConstraint,\n type UniqueConstraintInput,\n} from './ir/unique-constraint';\n\nexport type ForeignKeyOptions = {\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\nexport type SqlModelFieldStorage = {\n readonly column: string;\n readonly codecId?: string;\n readonly nullable?: boolean;\n};\n\nexport type SqlModelStorage = {\n readonly table: string;\n readonly namespaceId: string;\n readonly fields: Record<string, SqlModelFieldStorage>;\n};\n\nexport const DEFAULT_FK_CONSTRAINT = true;\nexport const DEFAULT_FK_INDEX = true;\n\nexport function applyFkDefaults(\n fk: { constraint?: boolean | undefined; index?: boolean | undefined },\n overrideDefaults?: { constraint?: boolean | undefined; index?: boolean | undefined },\n): { constraint: boolean; index: boolean } {\n return {\n constraint: fk.constraint ?? overrideDefaults?.constraint ?? DEFAULT_FK_CONSTRAINT,\n index: fk.index ?? overrideDefaults?.index ?? DEFAULT_FK_INDEX,\n };\n}\n\n// Field-type maps nested by namespace coordinate: `[namespaceId][model][field]`.\n// Shared by the output and input field-type maps and their extractors.\nexport type NamespacedFieldTypeMap = Record<string, Record<string, Record<string, unknown>>>;\n\nexport type NamespacedStorageColumnTypeMap = Record<\n string,\n Record<string, Record<string, unknown>>\n>;\n\nexport type TypeMaps<\n TCodecTypes extends Record<string, { output: unknown }> = Record<string, never>,\n TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,\n TFieldOutputTypes extends NamespacedFieldTypeMap = Record<string, never>,\n TFieldInputTypes extends NamespacedFieldTypeMap = Record<string, never>,\n TStorageColumnTypes extends NamespacedStorageColumnTypeMap = Record<string, never>,\n TStorageColumnInputTypes extends NamespacedStorageColumnTypeMap = Record<string, never>,\n> = {\n readonly codecTypes: TCodecTypes;\n readonly queryOperationTypes: TQueryOperationTypes;\n readonly fieldOutputTypes: TFieldOutputTypes;\n readonly fieldInputTypes: TFieldInputTypes;\n readonly storageColumnTypes: TStorageColumnTypes;\n readonly storageColumnInputTypes: TStorageColumnInputTypes;\n};\n\nexport type CodecTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly codecTypes: infer C }\n ? C extends Record<string, { output: unknown }>\n ? C\n : Record<string, never>\n : Record<string, never>;\n\n/**\n * Dispatch hint identifying the first-argument target of an operation.\n *\n * Used by ORM column helpers to decide whether an operation is reachable on a\n * field. Names a concrete codec identity, a set of capability traits the\n * field's codec must carry, or targets list-typed (`many`) fields. Element\n * capability gating for list ops travels in `elementTraits`.\n */\nexport type QueryOperationSelfSpec =\n | { readonly codecId: string; readonly traits?: never; readonly many?: never }\n | { readonly traits: readonly CodecTrait[]; readonly codecId?: never; readonly many?: never }\n | {\n readonly many: true;\n readonly elementTraits?: readonly CodecTrait[];\n readonly codecId?: never;\n readonly traits?: never;\n };\n\n/**\n * Structural shape an operation's impl must return: any value carrying a\n * codec-exact `returnType` descriptor. `Expression<T>` (from\n * `@prisma-next/sql-relational-core/expression`, with `T extends ScopeField`)\n * extends this. Trait-targeted returns are deliberately excluded — predicate\n * detection and result decoding both depend on knowing the concrete return\n * codec.\n */\nexport type QueryOperationReturn = {\n readonly returnType: { readonly codecId: string; readonly nullable: boolean };\n};\n\nexport type QueryOperationTypeEntry = {\n readonly self?: QueryOperationSelfSpec;\n readonly impl: (...args: never[]) => QueryOperationReturn;\n};\n\nexport type SqlQueryOperationTypes<\n _CT extends Record<string, { readonly input: unknown; readonly output: unknown }>,\n T extends Record<string, QueryOperationTypeEntry>,\n> = T;\n\nexport type QueryOperationTypesBase = Record<string, QueryOperationTypeEntry>;\n\nexport type QueryOperationTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly queryOperationTypes: infer Q }\n ? Q extends Record<string, unknown>\n ? Q\n : Record<string, never>\n : Record<string, never>;\n\nexport type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';\n\nexport type ContractWithTypeMaps<TContract, TTypeMaps> = TContract & {\n readonly [K in TypeMapsPhantomKey]?: TTypeMaps;\n};\n\nexport type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T\n ? NonNullable<T[TypeMapsPhantomKey & keyof T]>\n : never;\n\nexport type FieldOutputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldOutputTypes: infer F }\n ? F extends NamespacedFieldTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type FieldInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly fieldInputTypes: infer F }\n ? F extends NamespacedFieldTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type StorageColumnTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly storageColumnTypes: infer F }\n ? F extends NamespacedStorageColumnTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type StorageColumnInputTypesOf<T> = [T] extends [never]\n ? Record<string, never>\n : T extends { readonly storageColumnInputTypes: infer F }\n ? F extends NamespacedStorageColumnTypeMap\n ? F\n : Record<string, never>\n : Record<string, never>;\n\nexport type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractQueryOperationTypes<T> = QueryOperationTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldOutputTypes<T> = FieldOutputTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractFieldInputTypes<T> = FieldInputTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractStorageColumnTypes<T> = StorageColumnTypesOf<ExtractTypeMapsFromContract<T>>;\nexport type ExtractStorageColumnInputTypes<T> = StorageColumnInputTypesOf<\n ExtractTypeMapsFromContract<T>\n>;\n\nexport type ResolveCodecTypes<TContract, TTypeMaps> = [TTypeMaps] extends [never]\n ? ExtractCodecTypes<TContract>\n : CodecTypesOf<TTypeMaps>;\n"],"mappings":";;;;;;;;;;AASA,MAAa,sBAAsB;;;;;;AAmCnC,SAAgB,sBAAsB,OAAsD;CAC1F,OAAO;EACL,MAAM;EACN,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,YAAY,MAAM,cAAc,CAAC;CACnC;AACF;;;;;;AAOA,SAAgB,sBAAsB,OAA8C;CAClF,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAQ,MAA6B,SAAS;AAChD;;;;;;;ACPA,SAAgB,4BACd,WACwC;CACxC,IAAI,cAAc,KAAA,KAAa,CAAC,OAAO,OAAO,WAAW,iBAAiB,GACxE,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,WAAW,iBAAiB,MAAM;AAC9D;;;;;;;AA+DA,IAAsB,mBAAtB,cAA+C,cAAsC,CAKrF;;;;;;;;;;;AAYA,SAAgB,2BAA2B,GAAmC;CAC5E,IAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,EAAE,kBAAkB,IAAI,OAAO;CAC1E,OAAO,OAAO,EAAE,iBAAiB;AACnC;AAEA,IAAa,aAAb,cAA+D,QAA2B;CACxF;CACA;CAGA,YAAY,OAA+B;EACzC,MAAM;EACN,KAAK,cAAc,MAAM;EACzB,KAAK,aAAa,OAAO,OAAO,MAAM,UAAU;EAChD,IAAI,MAAM,UAAU,KAAA,GAClB,KAAK,QAAQ,OAAO,OAClB,OAAO,YACL,OAAO,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,mBAAmB,MAAM,EAAE,CAAC,CAAC,CACtF,CACF;EAEF,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAS,mBAAmB,MAAc,OAAiD;CACzF,IAAI,sBAAsB,KAAK,GAAG;EAMhC,IAAI,gBAAgB,OAClB,OAAO;EAET,OAAO,sBAAsB,KAAK;CACpC;CACA,MAAM,UAAU,cAAc,KAAK,IAAI,MAAM,UAAU,KAAA;CACvD,MAAM,kBACJ,YAAY,KAAA,IACR,iCACA,uCAAuC,KAAK,UAAU,OAAO;CACnE,MAAM,IAAI,MACR,iBAAiB,KAAK,UAAU,IAAI,EAAE,QAAQ,gBAAgB,aAAa,KAAK,UAAU,gBAAgB,EAAE,gGAC9G;AACF;;;AC/HA,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,SAAgB,gBACd,IACA,kBACyC;CACzC,OAAO;EACL,YAAY,GAAG,cAAc,kBAAkB,cAAA;EAC/C,OAAO,GAAG,SAAS,kBAAkB,SAAA;CACvC;AACF"} |
+1
-1
| import { t as SqlNode } from "./sql-node-V214WXQD.mjs"; | ||
| import { a as StorageColumn, c as IndexInput, d as CheckConstraint, f as CheckConstraintInput, i as UniqueConstraintInput, l as PrimaryKey, n as StorageTableInput, o as StorageColumnInput, r as UniqueConstraint, s as Index, t as StorageTable, u as PrimaryKeyInput } from "./storage-table-Bj1ZN1P7.mjs"; | ||
| import { a as ForeignKeyReferenceInput, i as ForeignKeyReference, n as ForeignKeyInput, r as ReferentialAction, t as ForeignKey } from "./foreign-key-DM1UTydh.mjs"; | ||
| import { a as SqlNamespaceFactory, c as SqlStorageInput, d as isSqlAuthoringContributions, f as CODEC_INSTANCE_KIND, g as toStorageTypeInstance, h as isStorageTypeInstance, i as SqlNamespaceEntries, l as SqlStorageTypeEntry, m as StorageTypeInstanceInput, n as SqlNamespace, o as SqlNamespaceInput, p as StorageTypeInstance, r as SqlNamespaceBase, s as SqlStorage, t as SqlAuthoringContributions, u as isMaterializedSqlNamespace } from "./sql-storage-BRB55sCP.mjs"; | ||
| import { a as SqlNamespaceFactory, c as SqlStorageInput, d as isSqlAuthoringContributions, f as CODEC_INSTANCE_KIND, g as toStorageTypeInstance, h as isStorageTypeInstance, i as SqlNamespaceEntries, l as SqlStorageTypeEntry, m as StorageTypeInstanceInput, n as SqlNamespace, o as SqlNamespaceInput, p as StorageTypeInstance, r as SqlNamespaceBase, s as SqlStorage, t as SqlAuthoringContributions, u as isMaterializedSqlNamespace } from "./sql-storage-Dt5ipcRl.mjs"; | ||
| import { n as StorageValueSetInput, r as isStorageValueSet, t as StorageValueSet } from "./storage-value-set-D-jww77l.mjs"; | ||
@@ -6,0 +6,0 @@ import { A as TypeMapsPhantomKey, C as SqlControlDriverInstance, D as StorageColumnInputTypesOf, E as SqlQueryOperationTypes, O as StorageColumnTypesOf, S as ResolveCodecTypes, T as SqlModelStorage, _ as QueryOperationReturn, a as ExtractCodecTypes, b as QueryOperationTypesBase, c as ExtractQueryOperationTypes, d as ExtractTypeMapsFromContract, f as FieldInputTypesOf, g as NamespacedStorageColumnTypeMap, h as NamespacedFieldTypeMap, i as DEFAULT_FK_INDEX, j as applyFkDefaults, k as TypeMaps, l as ExtractStorageColumnInputTypes, m as ForeignKeyOptions, n as ContractWithTypeMaps, o as ExtractFieldInputTypes, p as FieldOutputTypesOf, r as DEFAULT_FK_CONSTRAINT, s as ExtractFieldOutputTypes, t as CodecTypesOf, u as ExtractStorageColumnTypes, v as QueryOperationSelfSpec, w as SqlModelFieldStorage, x as QueryOperationTypesOf, y as QueryOperationTypeEntry } from "./types-zBvpNCmg.mjs"; |
| import { i as UniqueConstraintInput, u as PrimaryKeyInput } from "./storage-table-Bj1ZN1P7.mjs"; | ||
| import { n as ForeignKeyInput, r as ReferentialAction } from "./foreign-key-DM1UTydh.mjs"; | ||
| import { s as SqlStorage } from "./sql-storage-BRB55sCP.mjs"; | ||
| import { s as SqlStorage } from "./sql-storage-Dt5ipcRl.mjs"; | ||
| import { AnyEntityKindDescriptor } from "@prisma-next/framework-components/ir"; | ||
@@ -5,0 +5,0 @@ import { Type } from "arktype"; |
+7
-7
| { | ||
| "name": "@prisma-next/sql-contract", | ||
| "version": "0.14.0-dev.57", | ||
| "version": "0.14.0-dev.58", | ||
| "license": "Apache-2.0", | ||
@@ -9,11 +9,11 @@ "type": "module", | ||
| "dependencies": { | ||
| "@prisma-next/contract": "0.14.0-dev.57", | ||
| "@prisma-next/framework-components": "0.14.0-dev.57", | ||
| "@prisma-next/utils": "0.14.0-dev.57", | ||
| "@prisma-next/contract": "0.14.0-dev.58", | ||
| "@prisma-next/framework-components": "0.14.0-dev.58", | ||
| "@prisma-next/utils": "0.14.0-dev.58", | ||
| "arktype": "^2.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@prisma-next/test-utils": "0.14.0-dev.57", | ||
| "@prisma-next/tsconfig": "0.14.0-dev.57", | ||
| "@prisma-next/tsdown": "0.14.0-dev.57", | ||
| "@prisma-next/test-utils": "0.14.0-dev.58", | ||
| "@prisma-next/tsconfig": "0.14.0-dev.58", | ||
| "@prisma-next/tsdown": "0.14.0-dev.58", | ||
| "tsdown": "0.22.1", | ||
@@ -20,0 +20,0 @@ "typescript": "5.9.3", |
@@ -107,5 +107,5 @@ import type { StorageHashBase } from '@prisma-next/contract/types'; | ||
| * | ||
| * `qualifyTable` is optional so JSON-shaped contract types (which carry no | ||
| * methods) are accepted where `SqlNamespace` is required. Hydrated | ||
| * `SqlNamespaceBase` instances always have it. | ||
| * `qualifyTable` and `isUnbound` are optional so JSON-shaped contract types | ||
| * (which carry no methods) are accepted where `SqlNamespace` is required. | ||
| * Hydrated `SqlNamespaceBase` instances always have both. | ||
| */ | ||
@@ -116,2 +116,3 @@ export interface SqlNamespace { | ||
| readonly entries: SqlNamespaceEntries; | ||
| readonly isUnbound?: boolean; | ||
| qualifyTable?(tableName: string): string; | ||
@@ -118,0 +119,0 @@ } |
| import { t as SqlNode } from "./sql-node-V214WXQD.mjs"; | ||
| import { t as StorageTable } from "./storage-table-Bj1ZN1P7.mjs"; | ||
| import { t as StorageValueSet } from "./storage-value-set-D-jww77l.mjs"; | ||
| import { Namespace, NamespaceBase, Storage, StorageType } from "@prisma-next/framework-components/ir"; | ||
| import { StorageHashBase } from "@prisma-next/contract/types"; | ||
| import { AuthoringContributions } from "@prisma-next/framework-components/authoring"; | ||
| //#region src/ir/storage-type-instance.d.ts | ||
| /** | ||
| * Sentinel kind for the legacy codec-triple shape persisted under | ||
| * `SqlStorage.types`. Plain JSON-clean object literals carry this | ||
| * discriminator so the polymorphic slot dispatch can route them down | ||
| * the codec path while target-specific IR class instances (e.g. the | ||
| * Postgres enum class) keep their own narrower `kind` literal. | ||
| */ | ||
| declare const CODEC_INSTANCE_KIND: "codec-instance"; | ||
| /** | ||
| * Structural sub-interface of {@link StorageType} for codec-typed entries | ||
| * in `SqlStorage.types`. These are plain object literals — there is no | ||
| * runtime IR class, the JSON envelope round-trips through the slot | ||
| * unchanged. The `kind: 'codec-instance'` discriminator is the dispatch | ||
| * key that distinguishes codec-typed entries from any class-instance | ||
| * kinds a target pack contributes to the polymorphic slot. | ||
| */ | ||
| interface StorageTypeInstance extends StorageType { | ||
| readonly kind: typeof CODEC_INSTANCE_KIND; | ||
| readonly codecId: string; | ||
| readonly nativeType: string; | ||
| readonly typeParams: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Construction-time input for a codec-triple entry. Symmetric with the | ||
| * structural runtime shape minus the `kind` discriminator — callers may | ||
| * omit `kind`; the helper {@link toStorageTypeInstance} stamps it on. | ||
| * `typeParams` may be omitted on input; the constructor normalises a | ||
| * missing value to `{}` so the in-memory shape is always present. | ||
| */ | ||
| interface StorageTypeInstanceInput { | ||
| readonly codecId: string; | ||
| readonly nativeType: string; | ||
| readonly typeParams?: Record<string, unknown>; | ||
| } | ||
| /** | ||
| * Stamp the codec-instance `kind` discriminator on a caller-supplied | ||
| * codec triple. Idempotent: input that already carries the discriminator | ||
| * passes through unchanged. Missing `typeParams` is normalised to `{}`. | ||
| */ | ||
| declare function toStorageTypeInstance(input: StorageTypeInstanceInput): StorageTypeInstance; | ||
| /** | ||
| * Type-guard for codec-typed entries on the polymorphic | ||
| * `SqlStorage.types` slot. Distinguishes `StorageTypeInstance` from | ||
| * any class-instance kinds a target pack contributes. | ||
| */ | ||
| declare function isStorageTypeInstance(value: unknown): value is StorageTypeInstance; | ||
| //#endregion | ||
| //#region src/ir/sql-storage.d.ts | ||
| /** | ||
| * Polymorphic value type for document-scoped `SqlStorage.types` entries | ||
| * (codec aliases / parameterised native type registrations). | ||
| * | ||
| * Postgres native enum registrations live under the postgres-specific | ||
| * `entries.type` slot on `PostgresSchema` (target layer), not here. | ||
| */ | ||
| type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput; | ||
| interface SqlNamespaceInput { | ||
| readonly id: string; | ||
| readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>; | ||
| } | ||
| /** | ||
| * Target-supplied factory that materializes a `Namespace` from a SQL | ||
| * `SqlNamespaceInput` (used to populate `SqlStorage.namespaces`). | ||
| */ | ||
| type SqlNamespaceFactory = (input: SqlNamespaceInput) => Namespace; | ||
| /** | ||
| * SQL-family extension of the framework `AuthoringContributions`. SQL target | ||
| * packs add a `createNamespace` factory so the PSL/TS authoring paths can | ||
| * materialize namespaces (and merge lowered extension-block entities) without | ||
| * each consumer re-specifying it. The factory is SQL-specific, so it lives here | ||
| * rather than on the framework `AuthoringContributions` base. | ||
| */ | ||
| interface SqlAuthoringContributions extends AuthoringContributions { | ||
| readonly createNamespace?: SqlNamespaceFactory; | ||
| } | ||
| /** | ||
| * Narrows framework `AuthoringContributions` to the SQL-family shape by testing | ||
| * for the SQL-specific `createNamespace` capability. | ||
| */ | ||
| declare function isSqlAuthoringContributions(authoring: AuthoringContributions | undefined): authoring is SqlAuthoringContributions; | ||
| interface SqlStorageInput<THash extends string = string> { | ||
| readonly storageHash: StorageHashBase<THash>; | ||
| readonly types?: Record<string, SqlStorageTypeEntry>; | ||
| readonly namespaces: Readonly<Record<string, SqlNamespaceBase>>; | ||
| } | ||
| /** | ||
| * SQL Contract IR root node for the `storage` field. | ||
| * | ||
| * Single concrete family-shared class — both Postgres and SQLite | ||
| * consume this class today. Per-target storage subclasses are | ||
| * introduced when each target's namespace shape earns its | ||
| * target-specific concretion (target-specific derived fields, | ||
| * target-specific storage extensions). | ||
| * | ||
| * Honours the framework `Storage` interface: every SQL IR carries a | ||
| * `namespaces` map keyed by namespace id. Callers must supply fully | ||
| * constructed `Namespace` instances — construction discipline lives | ||
| * in the authoring builders and deserializer hydration paths. | ||
| * | ||
| * The constructor normalises optional `types` into class instances. | ||
| * `types` is polymorphic per Decision 18 Option B: codec-triple inputs | ||
| * are stamped with `kind: 'codec-instance'`; hydration of raw JSON | ||
| * class-instance entries (carrying their narrower `kind` literal) is | ||
| * the per-target serializer's responsibility (so the family base does | ||
| * not import target-specific subclasses). | ||
| */ | ||
| /** | ||
| * The typed `entries` shape for SQL family namespaces. The open dictionary | ||
| * is intersected with optional known-kind maps so that `ns.entries.table` | ||
| * and `ns.entries.valueSet` resolve without a cast, while unknown pack- | ||
| * contributed kinds remain valid (the `Record` part allows any string key). | ||
| */ | ||
| type SqlNamespaceEntries = Readonly<Record<string, Readonly<Record<string, unknown>>>> & { | ||
| readonly table?: Readonly<Record<string, StorageTable>>; | ||
| readonly valueSet?: Readonly<Record<string, StorageValueSet>>; | ||
| }; | ||
| /** | ||
| * Structural interface for SQL family namespaces. Generated `.d.ts` contract | ||
| * types satisfy this structurally (no prototype methods). The runtime | ||
| * abstract class `SqlNamespaceBase` extends this. | ||
| * | ||
| * `qualifyTable` is optional so JSON-shaped contract types (which carry no | ||
| * methods) are accepted where `SqlNamespace` is required. Hydrated | ||
| * `SqlNamespaceBase` instances always have it. | ||
| */ | ||
| interface SqlNamespace { | ||
| readonly kind: string; | ||
| readonly id: string; | ||
| readonly entries: SqlNamespaceEntries; | ||
| qualifyTable?(tableName: string): string; | ||
| } | ||
| /** | ||
| * Abstract SQL family namespace base class. Target concretions (`PostgresSchema`, | ||
| * `SqliteDatabase`, …) extend this — it is never instantiated directly. | ||
| * `entries` is the open ADR 224 dictionary: `entries[entityKind][entityName]` | ||
| * addresses any entity. | ||
| */ | ||
| declare abstract class SqlNamespaceBase extends NamespaceBase implements SqlNamespace { | ||
| abstract readonly id: string; | ||
| abstract readonly entries: SqlNamespaceEntries; | ||
| abstract qualifyTable(tableName: string): string; | ||
| } | ||
| /** | ||
| * Realm-safe guard for hydrated `SqlNamespaceBase` concretions. Checks | ||
| * `qualifyTable` structurally instead of `instanceof NamespaceBase`, so it | ||
| * survives duplicate-module boundaries (e.g. dist e2e where the target and | ||
| * the family carry separate copies of `@prisma-next/framework-components`). | ||
| * | ||
| * Every concrete `SqlNamespaceBase` subclass (`PostgresSchema`, `SqliteDatabase`, | ||
| * `TestSqlNamespace`, …) implements `qualifyTable`. Raw `SqlNamespaceInput` | ||
| * objects (`{ id, entries }`) do not. | ||
| */ | ||
| declare function isMaterializedSqlNamespace(x: unknown): x is SqlNamespaceBase; | ||
| declare class SqlStorage<THash extends string = string> extends SqlNode implements Storage { | ||
| readonly storageHash: StorageHashBase<THash>; | ||
| readonly namespaces: Readonly<Record<string, SqlNamespace>>; | ||
| readonly types?: Readonly<Record<string, StorageTypeInstance>>; | ||
| constructor(input: SqlStorageInput<THash>); | ||
| } | ||
| //#endregion | ||
| export { SqlNamespaceFactory as a, SqlStorageInput as c, isSqlAuthoringContributions as d, CODEC_INSTANCE_KIND as f, toStorageTypeInstance as g, isStorageTypeInstance as h, SqlNamespaceEntries as i, SqlStorageTypeEntry as l, StorageTypeInstanceInput as m, SqlNamespace as n, SqlNamespaceInput as o, StorageTypeInstance as p, SqlNamespaceBase as r, SqlStorage as s, SqlAuthoringContributions as t, isMaterializedSqlNamespace as u }; | ||
| //# sourceMappingURL=sql-storage-BRB55sCP.d.mts.map |
| {"version":3,"file":"sql-storage-BRB55sCP.d.mts","names":[],"sources":["../src/ir/storage-type-instance.ts","../src/ir/sql-storage.ts"],"mappings":";;;;;;;;;;;;;;;cASa,mBAAA;;;;AAA+C;AAU5D;;;;UAAiB,mBAAA,SAA4B,WAAA;EAAA,SAClC,IAAA,SAAa,mBAAA;EAAA,SACb,OAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA,EAAY,MAAA;AAAA;;;;;;;AAAM;UAUZ,wBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;;;AAAA;iBAQd,qBAAA,CAAsB,KAAA,EAAO,wBAAA,GAA2B,mBAAmB;;;;;;iBAc3E,qBAAA,CAAsB,KAAA,YAAiB,KAAA,IAAS,mBAAmB;;;;AAjDnF;;;;AAA4D;AAU5D;KCOY,mBAAA,GAAsB,mBAAA,GAAsB,wBAAwB;AAAA,UAE/D,iBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;AAAA;;;;;KAOzC,mBAAA,IAAuB,KAAA,EAAO,iBAAA,KAAsB,SAAS;;;;;;ADd5C;AAU7B;UCaiB,yBAAA,SAAkC,sBAAsB;EAAA,SAC9D,eAAA,GAAkB,mBAAA;AAAA;;;;;iBAOb,2BAAA,CACd,SAAA,EAAW,sBAAA,eACV,SAAA,IAAa,yBAAyB;AAAA,UAOxB,eAAA;EAAA,SACN,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,KAAA,GAAQ,MAAA,SAAe,mBAAA;EAAA,SACvB,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,gBAAA;AAAA;;;;;ADtB4C;AAc3F;;;;;;;;AAAmF;;;;AChCnF;;;;AAAgF;AAEhF;;;;;AAFgF,KAsEpE,mBAAA,GAAsB,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;EAAA,SACxD,KAAA,GAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAChC,QAAA,GAAW,QAAA,CAAS,MAAA,SAAe,eAAA;AAAA;;;;;;;;AApEa;AAO3D;UAyEiB,YAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA;EAAA,SACA,OAAA,EAAS,mBAAmB;EACrC,YAAA,EAAc,SAAA;AAAA;;AA7EyD;AASzE;;;;uBA6EsB,gBAAA,SAAyB,aAAA,YAAyB,YAAA;EAAA,kBAC3C,EAAA;EAAA,kBACA,OAAA,EAAS,mBAAA;EAAA,SAE3B,YAAA,CAAa,SAAA;AAAA;AAzExB;;;;;;;;;AAEyC;AAFzC,iBAsFgB,0BAAA,CAA2B,CAAA,YAAa,CAAA,IAAK,gBAAgB;AAAA,cAKhE,UAAA,wCAAkD,OAAA,YAAmB,OAAA;EAAA,SACvE,WAAA,EAAa,eAAA,CAAgB,KAAA;EAAA,SAC7B,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAC5B,KAAA,GAAQ,QAAA,CAAS,MAAA,SAAe,mBAAA;cAErC,KAAA,EAAO,eAAA,CAAgB,KAAA;AAAA"} |
384769
0.04%3984
0.03%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed