@prisma-next/framework-components 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/authoring.d.mts +2 -2
  2. package/dist/authoring.mjs +1 -1
  3. package/dist/{codec-DCQAerzB.d.mts → codec-types-yY3eSmi0.d.mts} +90 -67
  4. package/dist/codec-types-yY3eSmi0.d.mts.map +1 -0
  5. package/dist/codec.d.mts +31 -2
  6. package/dist/codec.d.mts.map +1 -1
  7. package/dist/codec.mjs +2 -1
  8. package/dist/codec.mjs.map +1 -1
  9. package/dist/components.d.mts +1 -1
  10. package/dist/control.d.mts +13 -25
  11. package/dist/control.d.mts.map +1 -1
  12. package/dist/control.mjs +12 -2
  13. package/dist/control.mjs.map +1 -1
  14. package/dist/{emission-types-vfpSTe63.d.mts → emission-types-C561PwcN.d.mts} +4 -4
  15. package/dist/emission-types-C561PwcN.d.mts.map +1 -0
  16. package/dist/emission.d.mts +1 -1
  17. package/dist/execution.d.mts +1 -1
  18. package/dist/{framework-authoring-R0TYCkvG.d.mts → framework-authoring-CJC4jwGo.d.mts} +121 -9
  19. package/dist/framework-authoring-CJC4jwGo.d.mts.map +1 -0
  20. package/dist/{framework-authoring-CnwPJCO4.mjs → framework-authoring-Dv5F3EFC.mjs} +51 -24
  21. package/dist/framework-authoring-Dv5F3EFC.mjs.map +1 -0
  22. package/dist/{framework-components-DDQXmW0b.d.mts → framework-components-5hA9ij1v.d.mts} +3 -3
  23. package/dist/{framework-components-DDQXmW0b.d.mts.map → framework-components-5hA9ij1v.d.mts.map} +1 -1
  24. package/dist/ir.d.mts +34 -4
  25. package/dist/ir.d.mts.map +1 -1
  26. package/dist/ir.mjs +51 -6
  27. package/dist/ir.mjs.map +1 -1
  28. package/dist/{psl-ast-Cn50B-UG.d.mts → psl-ast-B-C_9dWr.d.mts} +11 -37
  29. package/dist/psl-ast-B-C_9dWr.d.mts.map +1 -0
  30. package/dist/psl-ast.d.mts +4 -4
  31. package/dist/psl-ast.mjs +18 -32
  32. package/dist/psl-ast.mjs.map +1 -1
  33. package/dist/resolve-codec-D8EPZosv.mjs +59 -0
  34. package/dist/resolve-codec-D8EPZosv.mjs.map +1 -0
  35. package/dist/runtime-error-B2gWOtgH.mjs +37 -0
  36. package/dist/runtime-error-B2gWOtgH.mjs.map +1 -0
  37. package/dist/runtime.d.mts +12 -10
  38. package/dist/runtime.d.mts.map +1 -1
  39. package/dist/runtime.mjs +1 -33
  40. package/dist/runtime.mjs.map +1 -1
  41. package/package.json +7 -7
  42. package/src/control/control-migration-types.ts +5 -22
  43. package/src/control/control-stack.ts +28 -3
  44. package/src/control/emission-types.ts +3 -3
  45. package/src/control/psl-ast.ts +10 -61
  46. package/src/control/psl-extension-block-validator.ts +11 -9
  47. package/src/execution/runtime-error.ts +5 -55
  48. package/src/exports/authoring.ts +1 -0
  49. package/src/exports/codec.ts +7 -0
  50. package/src/exports/control.ts +0 -1
  51. package/src/exports/ir.ts +3 -1
  52. package/src/ir/entity-kind.ts +54 -0
  53. package/src/ir/storage.ts +32 -6
  54. package/src/shared/codec-descriptor.ts +5 -0
  55. package/src/shared/codec-types.ts +21 -1
  56. package/src/shared/framework-authoring.ts +118 -35
  57. package/src/shared/psl-extension-block.ts +85 -5
  58. package/src/shared/resolve-codec.ts +86 -0
  59. package/src/shared/runtime-error.ts +50 -0
  60. package/dist/codec-DCQAerzB.d.mts.map +0 -1
  61. package/dist/emission-types-vfpSTe63.d.mts.map +0 -1
  62. package/dist/framework-authoring-CnwPJCO4.mjs.map +0 -1
  63. package/dist/framework-authoring-R0TYCkvG.d.mts.map +0 -1
  64. package/dist/psl-ast-Cn50B-UG.d.mts.map +0 -1
package/dist/control.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { c as isAuthoringFieldPresetDescriptor, d as mergeAuthoringNamespaces, l as isAuthoringPslBlockDescriptor, s as isAuthoringEntityTypeDescriptor, t as assertNoCrossRegistryCollisions, u as isAuthoringTypeConstructorDescriptor } from "./framework-authoring-CnwPJCO4.mjs";
1
+ import { n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-D8EPZosv.mjs";
2
+ import { c as isAuthoringFieldPresetDescriptor, d as mergeAuthoringNamespaces, l as isAuthoringPslBlockDescriptor, s as isAuthoringEntityTypeDescriptor, t as assertNoCrossRegistryCollisions, u as isAuthoringTypeConstructorDescriptor } from "./framework-authoring-Dv5F3EFC.mjs";
2
3
  import { blindCast } from "@prisma-next/utils/casts";
3
4
  //#region src/control/control-capabilities.ts
4
5
  function hasMigrations(target) {
@@ -167,9 +168,11 @@ function assembleControlMutationDefaults(descriptors) {
167
168
  }
168
169
  function extractCodecLookup(descriptors) {
169
170
  const byId = /* @__PURE__ */ new Map();
171
+ const descriptorsById = /* @__PURE__ */ new Map();
170
172
  const targetTypesById = /* @__PURE__ */ new Map();
171
173
  const metaById = /* @__PURE__ */ new Map();
172
174
  const renderersById = /* @__PURE__ */ new Map();
175
+ const inputRenderersById = /* @__PURE__ */ new Map();
173
176
  const owners = /* @__PURE__ */ new Map();
174
177
  for (const descriptor of descriptors) {
175
178
  const codecTypes = descriptor.types?.codecTypes;
@@ -183,9 +186,11 @@ function extractCodecLookup(descriptors) {
183
186
  entityOwnershipLabel: "codec descriptor provider"
184
187
  });
185
188
  owners.set(codecDescriptor.codecId, descriptorId);
189
+ descriptorsById.set(codecDescriptor.codecId, codecDescriptor);
186
190
  if (Array.isArray(codecDescriptor.targetTypes)) targetTypesById.set(codecDescriptor.codecId, codecDescriptor.targetTypes);
187
191
  if (codecDescriptor.meta !== void 0) metaById.set(codecDescriptor.codecId, codecDescriptor.meta);
188
192
  if (typeof codecDescriptor.renderOutputType === "function") renderersById.set(codecDescriptor.codecId, codecDescriptor.renderOutputType);
193
+ if (typeof codecDescriptor.renderInputType === "function") inputRenderersById.set(codecDescriptor.codecId, codecDescriptor.renderInputType);
189
194
  if (!byId.has(codecDescriptor.codecId)) if (codecDescriptor.isParameterized) try {
190
195
  const representative = codecDescriptor.factory({})({ name: `<lookup:${codecDescriptor.codecId}>` });
191
196
  byId.set(codecDescriptor.codecId, representative);
@@ -198,9 +203,14 @@ function extractCodecLookup(descriptors) {
198
203
  }
199
204
  return {
200
205
  get: (id) => byId.get(id),
206
+ forCodecRef(ref) {
207
+ return materializeCodec(resolveCodecDescriptorOrThrow((id) => descriptorsById.get(id), ref, CONTRACT_CODEC_DESCRIPTOR_MISSING), ref, { name: `<ref:${ref.codecId}>` });
208
+ },
209
+ forColumn: () => void 0,
201
210
  targetTypesFor: (id) => targetTypesById.get(id),
202
211
  metaFor: (id) => metaById.get(id),
203
- renderOutputTypeFor: (id, params) => renderersById.get(id)?.(params)
212
+ renderOutputTypeFor: (id, params) => renderersById.get(id)?.(params),
213
+ renderInputTypeFor: (id, params) => inputRenderersById.get(id)?.(params)
204
214
  };
205
215
  }
206
216
  function readDeclaredDependencyIds(descriptor) {
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":[],"sources":["../src/control/control-capabilities.ts","../src/control/control-result-types.ts","../src/control/control-schema-view.ts","../src/control/control-spaces.ts","../src/control/control-stack.ts","../src/control/verifier-disposition.ts"],"sourcesContent":["import type { ControlTargetDescriptor } from './control-descriptors';\nimport type { ControlFamilyInstance } from './control-instances';\nimport type { MigrationPlanOperation, TargetMigrationsCapability } from './control-migration-types';\nimport type { OperationPreview } from './control-operation-preview';\nimport type { CoreSchemaView } from './control-schema-view';\nimport type { PslDocumentAst } from './psl-ast';\n\nexport interface MigratableTargetDescriptor<\n TFamilyId extends string,\n TTargetId extends string,\n TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<\n TFamilyId,\n unknown\n >,\n> extends ControlTargetDescriptor<TFamilyId, TTargetId> {\n readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;\n}\n\nexport function hasMigrations<TFamilyId extends string, TTargetId extends string>(\n target: ControlTargetDescriptor<TFamilyId, TTargetId>,\n): target is MigratableTargetDescriptor<TFamilyId, TTargetId> {\n return 'migrations' in target && !!(target as Record<string, unknown>)['migrations'];\n}\n\nexport interface SchemaViewCapable<TSchemaIR = unknown> {\n toSchemaView(schema: TSchemaIR): CoreSchemaView;\n}\n\nexport function hasSchemaView<TFamilyId extends string, TSchemaIR>(\n instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,\n): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaViewCapable<TSchemaIR> {\n return (\n 'toSchemaView' in instance &&\n typeof (instance as Record<string, unknown>)['toSchemaView'] === 'function'\n );\n}\n\n/**\n * Capability declaring that a family can infer a PSL contract AST from its\n * opaque introspected schema IR. Consumed by `prisma-next contract infer`.\n */\nexport interface PslContractInferCapable<TSchemaIR = unknown> {\n inferPslContract(schemaIR: TSchemaIR): PslDocumentAst;\n}\n\nexport function hasPslContractInfer<TFamilyId extends string, TSchemaIR>(\n instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,\n): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & PslContractInferCapable<TSchemaIR> {\n return (\n 'inferPslContract' in instance &&\n typeof (instance as Record<string, unknown>)['inferPslContract'] === 'function'\n );\n}\n\n/**\n * Capability declaring that a family can render a textual preview of migration\n * operations for the CLI's \"DDL preview\" output. SQL families emit\n * `language: 'sql'` statements; Mongo families emit `language: 'mongodb-shell'`.\n */\nexport interface OperationPreviewCapable {\n toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;\n}\n\nexport function hasOperationPreview<TFamilyId extends string, TSchemaIR>(\n instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,\n): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & OperationPreviewCapable {\n return (\n 'toOperationPreview' in instance &&\n typeof (instance as Record<string, unknown>)['toOperationPreview'] === 'function'\n );\n}\n","export const VERIFY_CODE_MARKER_MISSING = 'PN-RUN-3001';\nexport const VERIFY_CODE_HASH_MISMATCH = 'PN-RUN-3002';\nexport const VERIFY_CODE_TARGET_MISMATCH = 'PN-RUN-3003';\nexport const VERIFY_CODE_SCHEMA_FAILURE = 'PN-RUN-3010';\n\nexport interface OperationContext {\n readonly contractPath?: string;\n readonly configPath?: string;\n readonly meta?: Readonly<Record<string, unknown>>;\n}\n\nexport interface VerifyDatabaseResult {\n readonly ok: boolean;\n readonly code?: string;\n readonly summary: string;\n readonly contract: {\n readonly storageHash: string;\n readonly profileHash?: string;\n };\n readonly marker?: {\n readonly storageHash?: string;\n readonly profileHash?: string;\n };\n readonly target: {\n readonly expected: string;\n readonly actual?: string;\n };\n readonly missingCodecs?: readonly string[];\n readonly codecCoverageSkipped?: boolean;\n readonly meta?: {\n readonly configPath?: string;\n readonly contractPath: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport interface BaseSchemaIssue {\n readonly kind:\n | 'missing_schema'\n | 'missing_table'\n | 'missing_column'\n | 'extra_table'\n | 'extra_column'\n | 'extra_primary_key'\n | 'extra_foreign_key'\n | 'extra_unique_constraint'\n | 'extra_index'\n | 'extra_validator'\n | 'type_mismatch'\n | 'type_missing'\n | 'type_values_mismatch'\n | 'nullability_mismatch'\n | 'primary_key_mismatch'\n | 'foreign_key_mismatch'\n | 'unique_constraint_mismatch'\n | 'index_mismatch'\n | 'default_missing'\n | 'default_mismatch'\n | 'extra_default'\n | 'check_missing'\n | 'check_removed'\n | 'check_mismatch';\n readonly table?: string;\n /**\n * Namespace coordinate of the issue's subject (e.g. the schema a SQL\n * table lives in). Populated by family verifiers that have the\n * coordinate in scope when constructing the issue; absent for issues\n * whose family has no namespace concept (e.g. Mongo collections) or\n * whose subject isn't in any contract namespace (e.g. an extra-table\n * issue raised for a table that exists in the live DB but not in the\n * contract).\n *\n * Downstream planners trust this field as the authoritative subject\n * coordinate and do not re-derive it by name lookup. A finer-grained\n * structural split between framework-shared and family-specific issue\n * fields is tracked under a follow-up ticket.\n */\n readonly namespaceId?: string;\n readonly column?: string;\n readonly indexOrConstraint?: string;\n readonly typeName?: string;\n readonly expected?: string;\n readonly actual?: string;\n readonly message: string;\n}\n\nexport interface EnumValuesChangedIssue {\n readonly kind: 'enum_values_changed';\n /**\n * Namespace coordinate of the enum type that changed values. Populated by\n * family verifiers that have the coordinate in scope when constructing the\n * issue. Downstream planners trust this field as the authoritative subject\n * coordinate and do not re-derive it by name lookup.\n */\n readonly namespaceId: string;\n readonly typeName: string;\n readonly addedValues: readonly string[];\n readonly removedValues: readonly string[];\n readonly message: string;\n}\n\nexport type SchemaIssue = BaseSchemaIssue | EnumValuesChangedIssue;\n\nexport interface SchemaVerificationNode {\n readonly status: 'pass' | 'warn' | 'fail';\n readonly kind: string;\n readonly name: string;\n readonly contractPath: string;\n readonly code: string;\n readonly message: string;\n readonly expected: unknown;\n readonly actual: unknown;\n readonly children: readonly SchemaVerificationNode[];\n}\n\nexport interface VerifyDatabaseSchemaResult {\n readonly ok: boolean;\n readonly code?: string;\n readonly summary: string;\n readonly contract: {\n readonly storageHash: string;\n readonly profileHash?: string;\n };\n readonly target: {\n readonly expected: string;\n readonly actual?: string;\n };\n readonly schema: {\n readonly issues: readonly SchemaIssue[];\n readonly root: SchemaVerificationNode;\n readonly counts: {\n readonly pass: number;\n readonly warn: number;\n readonly fail: number;\n readonly totalNodes: number;\n };\n };\n readonly meta?: {\n readonly configPath?: string;\n readonly contractPath?: string;\n readonly strict: boolean;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport interface EmitContractResult {\n readonly contractJson: string;\n readonly contractDts: string;\n readonly storageHash: string;\n readonly executionHash?: string;\n readonly profileHash: string;\n}\n\nexport interface IntrospectSchemaResult<TSchemaIR> {\n readonly ok: true;\n readonly summary: string;\n readonly target: {\n readonly familyId: string;\n readonly id: string;\n };\n readonly schema: TSchemaIR;\n readonly meta?: {\n readonly configPath?: string;\n readonly dbUrl?: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport interface SignDatabaseResult {\n readonly ok: boolean;\n readonly summary: string;\n readonly contract: {\n readonly storageHash: string;\n readonly profileHash?: string;\n };\n readonly target: {\n readonly expected: string;\n readonly actual?: string;\n };\n readonly marker: {\n readonly created: boolean;\n readonly updated: boolean;\n readonly previous?: {\n readonly storageHash?: string;\n readonly profileHash?: string;\n };\n };\n readonly meta?: {\n readonly configPath?: string;\n readonly contractPath: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n","/**\n * Core schema view types for family-agnostic schema visualization.\n *\n * These types provide a minimal, generic, tree-shaped representation of schemas\n * across families, designed for CLI visualization and lightweight tooling.\n *\n * Families can optionally project their family-specific Schema IR into this\n * core view via the `toSchemaView` method on `FamilyInstance`.\n */\n\nexport type SchemaViewNodeKind =\n | 'root'\n | 'namespace'\n | 'collection'\n | 'entity'\n | 'field'\n | 'index'\n | 'dependency';\n\nexport interface SchemaTreeVisitor<R> {\n visit(node: SchemaTreeNode): R;\n}\n\nexport interface SchemaTreeNodeOptions {\n readonly kind: SchemaViewNodeKind;\n readonly id: string;\n readonly label: string;\n readonly meta?: Record<string, unknown>;\n readonly children?: readonly SchemaTreeNode[];\n}\n\nexport class SchemaTreeNode {\n readonly kind: SchemaViewNodeKind;\n readonly id: string;\n readonly label: string;\n readonly meta?: Record<string, unknown>;\n readonly children?: readonly SchemaTreeNode[];\n\n constructor(options: SchemaTreeNodeOptions) {\n this.kind = options.kind;\n this.id = options.id;\n this.label = options.label;\n if (options.meta !== undefined) this.meta = options.meta;\n if (options.children !== undefined) this.children = options.children;\n Object.freeze(this);\n }\n\n accept<R>(visitor: SchemaTreeVisitor<R>): R {\n return visitor.visit(this);\n }\n}\n\n/**\n * Core schema view providing a family-agnostic tree representation of a schema.\n * Used by CLI and cross-family tooling for visualization.\n */\nexport interface CoreSchemaView {\n readonly root: SchemaTreeNode;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { MigrationMetadata, MigrationPlanOperation } from './control-migration-types';\n\n/**\n * Canonical control-plane identifiers for contract spaces.\n *\n * A contract space is the disjoint `(contract.json, migration-graph)` unit\n * the per-space planner / runner / verifier (project: extension contract\n * spaces, TML-2397) operates on. The application owns one well-known\n * space — the value below — and each loaded extension that contributes\n * schema owns a uniquely-named space.\n *\n * Lives in `framework-components/control` so every layer that has to\n * reason about space identity (the migration tooling, the SQL runtime's\n * marker reader, target-side statement builders, target-side adapters)\n * can import a single value rather than duplicating the literal. Raw\n * `'app'` string literals in framework / target / runtime / adapter\n * source code are forbidden and policed by\n * `scripts/lint-app-space-id.mjs` (wired into `pnpm lint:deps`).\n *\n * @see specs/framework-mechanism.spec.md § 3 — Layout convention (γ).\n */\nexport const APP_SPACE_ID = 'app' as const;\n\n/**\n * Head ref for a contract space — the `(hash, invariants)` tuple\n * a runner targets when applying that space's migration graph. Identical\n * in shape to the on-disk `migrations/<space-id>/refs/head.json` the\n * framework writes per loaded extension, and to the app-space\n * `<projectRoot>/refs/head.json`. Family-agnostic: SQL, Mongo, and any\n * future family share the same head-ref shape.\n *\n * @see specs/framework-mechanism.spec.md § 1.\n */\nexport interface ContractSpaceHeadRef {\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\n/**\n * Canonical structural shape of a migration package — the unit a planner\n * produces and a runner consumes: a directory name, the metadata\n * envelope, and the operation list.\n *\n * In-memory by default. Readers in `@prisma-next/migration-tools`\n * (`readMigrationPackage` / `readMigrationsDir`) return the augmented\n * {@link import('@prisma-next/migration-tools/package').OnDiskMigrationPackage}\n * variant which adds `dirPath`; everything else operates against the\n * canonical shape so the same value flows through pre-emission\n * authoring, on-disk loading, and runner execution without conversion.\n *\n * @see specs/framework-mechanism.spec.md § 1.\n */\nexport interface MigrationPackage {\n readonly dirName: string;\n readonly metadata: MigrationMetadata;\n readonly ops: readonly MigrationPlanOperation[];\n}\n\n/**\n * Canonical structural shape of a contract space — one disjoint\n * `(contractJson, migration-graph)` unit the per-space planner / runner\n * / verifier operates on. The application owns one well-known space\n * ({@link APP_SPACE_ID}); each loaded extension that contributes schema\n * owns a uniquely-named space. Whether a value is the app's space or an\n * extension's space is a control-plane concern; the type carries no\n * such distinction.\n *\n * Generic over the contract so each family pins a typed contract value\n * at consumption time. The SQL family specialises to\n * `ContractSpace<Contract<SqlStorage>>` at the descriptor surface;\n * Mongo's symmetrical `ContractSpace<Contract<MongoStorage>>` will land\n * with that family.\n *\n * @see specs/framework-mechanism.spec.md § 1.\n */\nexport interface ContractSpace<TContract extends Contract = Contract> {\n readonly contractJson: TContract;\n readonly migrations: readonly MigrationPackage[];\n readonly headRef: ContractSpaceHeadRef;\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport type { Codec } from '../shared/codec';\nimport type { CodecLookup, CodecMeta } from '../shared/codec-types';\nimport type {\n AuthoringContributions,\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringPslBlockDescriptorNamespace,\n AuthoringTypeNamespace,\n} from '../shared/framework-authoring';\nimport {\n assertNoCrossRegistryCollisions,\n isAuthoringEntityTypeDescriptor,\n isAuthoringFieldPresetDescriptor,\n isAuthoringPslBlockDescriptor,\n isAuthoringTypeConstructorDescriptor,\n mergeAuthoringNamespaces,\n} from '../shared/framework-authoring';\nimport type { ComponentMetadata } from '../shared/framework-components';\nimport type {\n ControlMutationDefaultEntry,\n ControlMutationDefaults,\n MutationDefaultGeneratorDescriptor,\n} from '../shared/mutation-default-types';\nimport type { TypesImportSpec } from '../shared/types-import-spec';\nimport type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from './control-descriptors';\n\nexport interface AssembledAuthoringContributions {\n readonly field: AuthoringFieldNamespace;\n readonly type: AuthoringTypeNamespace;\n readonly entityTypes: AuthoringEntityTypeNamespace;\n readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;\n}\n\nexport interface ControlStack<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> {\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter?: ControlAdapterDescriptor<TFamilyId, TTargetId> | undefined;\n readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;\n readonly extensionPacks: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];\n\n readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;\n readonly queryOperationTypeImports: ReadonlyArray<TypesImportSpec>;\n readonly extensionIds: ReadonlyArray<string>;\n readonly codecLookup: CodecLookup;\n readonly authoringContributions: AssembledAuthoringContributions;\n readonly scalarTypeDescriptors: ReadonlyMap<string, string>;\n readonly controlMutationDefaults: ControlMutationDefaults;\n}\n\nexport interface CreateControlStackInput<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> {\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter?: ControlAdapterDescriptor<TFamilyId, TTargetId> | undefined;\n readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;\n readonly extensionPacks?:\n | ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>>\n | undefined;\n}\n\nfunction addUniqueId(ids: string[], seen: Set<string>, id: string): void {\n if (!seen.has(id)) {\n ids.push(id);\n seen.add(id);\n }\n}\n\nexport function assertUniqueCodecOwner(options: {\n readonly codecId: string;\n readonly owners: Map<string, string>;\n readonly descriptorId: string;\n readonly entityLabel: string;\n readonly entityOwnershipLabel: string;\n}): void {\n const existingOwner = options.owners.get(options.codecId);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate ${options.entityLabel} for codecId \"${options.codecId}\". ` +\n `Descriptor \"${options.descriptorId}\" conflicts with \"${existingOwner}\". ` +\n `Each codecId can only have one ${options.entityOwnershipLabel}.`,\n );\n }\n}\n\nexport function extractCodecTypeImports(\n descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>,\n): ReadonlyArray<TypesImportSpec> {\n const imports: TypesImportSpec[] = [];\n\n for (const descriptor of descriptors) {\n const codecTypes = descriptor.types?.codecTypes;\n if (codecTypes?.import) {\n imports.push(codecTypes.import);\n }\n if (codecTypes?.typeImports) {\n imports.push(...codecTypes.typeImports);\n }\n }\n\n return imports;\n}\n\nexport function extractQueryOperationTypeImports(\n descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>,\n): ReadonlyArray<TypesImportSpec> {\n const imports: TypesImportSpec[] = [];\n\n for (const descriptor of descriptors) {\n const queryOperationTypes = descriptor.types?.queryOperationTypes;\n if (queryOperationTypes?.import) {\n imports.push(queryOperationTypes.import);\n }\n }\n\n return imports;\n}\n\nexport function extractComponentIds(\n family: { readonly id: string },\n target: { readonly id: string },\n adapter: { readonly id: string } | undefined,\n extensions: ReadonlyArray<{ readonly id: string }>,\n): ReadonlyArray<string> {\n const ids: string[] = [];\n const seen = new Set<string>();\n\n addUniqueId(ids, seen, family.id);\n addUniqueId(ids, seen, target.id);\n if (adapter) {\n addUniqueId(ids, seen, adapter.id);\n }\n\n for (const ext of extensions) {\n addUniqueId(ids, seen, ext.id);\n }\n\n return ids;\n}\n\nexport function assembleAuthoringContributions(\n descriptors: ReadonlyArray<{ readonly authoring?: AuthoringContributions }>,\n): AssembledAuthoringContributions {\n const field = {} as Record<string, unknown>;\n const type = {} as Record<string, unknown>;\n const entityTypes = {} as Record<string, unknown>;\n const pslBlockDescriptors: Record<string, unknown> = {};\n\n for (const descriptor of descriptors) {\n if (descriptor.authoring?.field) {\n mergeAuthoringNamespaces(\n field,\n descriptor.authoring.field,\n [],\n isAuthoringFieldPresetDescriptor,\n 'field',\n );\n }\n if (descriptor.authoring?.type) {\n mergeAuthoringNamespaces(\n type,\n descriptor.authoring.type,\n [],\n isAuthoringTypeConstructorDescriptor,\n 'type',\n );\n }\n if (descriptor.authoring?.entityTypes) {\n mergeAuthoringNamespaces(\n entityTypes,\n descriptor.authoring.entityTypes,\n [],\n isAuthoringEntityTypeDescriptor,\n 'entity',\n );\n }\n if (descriptor.authoring?.pslBlockDescriptors) {\n mergeAuthoringNamespaces(\n pslBlockDescriptors,\n descriptor.authoring.pslBlockDescriptors,\n [],\n isAuthoringPslBlockDescriptor,\n 'pslBlock',\n );\n }\n }\n\n const fieldNamespace = field as AuthoringFieldNamespace;\n const typeNamespace = type as AuthoringTypeNamespace;\n const entityTypeNamespace = entityTypes as AuthoringEntityTypeNamespace;\n const pslBlockDescriptorNamespace = blindCast<\n AuthoringPslBlockDescriptorNamespace,\n 'merge target accumulator narrows to typed namespace post-merge'\n >(pslBlockDescriptors);\n assertNoCrossRegistryCollisions(\n typeNamespace,\n fieldNamespace,\n entityTypeNamespace,\n pslBlockDescriptorNamespace,\n );\n\n return {\n field: fieldNamespace,\n type: typeNamespace,\n entityTypes: entityTypeNamespace,\n pslBlockDescriptors: pslBlockDescriptorNamespace,\n };\n}\n\nexport function assembleScalarTypeDescriptors(\n descriptors: ReadonlyArray<\n Pick<ComponentMetadata, 'scalarTypeDescriptors'> & { readonly id?: string }\n >,\n): ReadonlyMap<string, string> {\n const result = new Map<string, string>();\n const owners = new Map<string, string>();\n\n for (const descriptor of descriptors) {\n const descriptorMap = descriptor.scalarTypeDescriptors;\n if (!descriptorMap) continue;\n const descriptorId = descriptor.id ?? '<unknown>';\n for (const [typeName, codecId] of descriptorMap) {\n const existingOwner = owners.get(typeName);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate scalar type descriptor \"${typeName}\". ` +\n `Descriptor \"${descriptorId}\" conflicts with \"${existingOwner}\".`,\n );\n }\n result.set(typeName, codecId);\n owners.set(typeName, descriptorId);\n }\n }\n\n return result;\n}\n\nexport function assembleControlMutationDefaults(\n descriptors: ReadonlyArray<\n Pick<ComponentMetadata, 'controlMutationDefaults'> & { readonly id?: string }\n >,\n): ControlMutationDefaults {\n const defaultFunctionRegistry = new Map<string, ControlMutationDefaultEntry>();\n const functionOwners = new Map<string, string>();\n const generatorMap = new Map<string, MutationDefaultGeneratorDescriptor>();\n const generatorOwners = new Map<string, string>();\n\n for (const descriptor of descriptors) {\n const contributions = descriptor.controlMutationDefaults;\n if (!contributions) continue;\n const descriptorId = descriptor.id ?? '<unknown>';\n\n for (const generatorDescriptor of contributions.generatorDescriptors) {\n const existingOwner = generatorOwners.get(generatorDescriptor.id);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate mutation default generator id \"${generatorDescriptor.id}\". ` +\n `Descriptor \"${descriptorId}\" conflicts with \"${existingOwner}\".`,\n );\n }\n generatorMap.set(generatorDescriptor.id, generatorDescriptor);\n generatorOwners.set(generatorDescriptor.id, descriptorId);\n }\n\n for (const [functionName, handler] of contributions.defaultFunctionRegistry) {\n const existingOwner = functionOwners.get(functionName);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate mutation default function \"${functionName}\". ` +\n `Descriptor \"${descriptorId}\" conflicts with \"${existingOwner}\".`,\n );\n }\n defaultFunctionRegistry.set(functionName, handler);\n functionOwners.set(functionName, descriptorId);\n }\n }\n\n return {\n defaultFunctionRegistry,\n generatorDescriptors: Array.from(generatorMap.values()),\n };\n}\n\nexport function extractCodecLookup(\n descriptors: ReadonlyArray<Pick<ComponentMetadata & { id: string }, 'types' | 'id'>>,\n): CodecLookup {\n const byId = new Map<string, Codec>();\n const targetTypesById = new Map<string, readonly string[]>();\n const metaById = new Map<string, CodecMeta>();\n const renderersById = new Map<string, (params: Record<string, unknown>) => string | undefined>();\n const owners = new Map<string, string>();\n for (const descriptor of descriptors) {\n const codecTypes = descriptor.types?.codecTypes;\n const descriptorId = descriptor.id;\n // Descriptor-side metadata is the single source of truth for `targetTypes` / `meta` / `renderOutputType`. Every contributor ships a `codecDescriptors` list on `types.codecTypes`.\n for (const codecDescriptor of codecTypes?.codecDescriptors ?? []) {\n assertUniqueCodecOwner({\n codecId: codecDescriptor.codecId,\n owners,\n descriptorId,\n entityLabel: 'codec descriptor',\n entityOwnershipLabel: 'codec descriptor provider',\n });\n owners.set(codecDescriptor.codecId, descriptorId);\n if (Array.isArray(codecDescriptor.targetTypes)) {\n targetTypesById.set(codecDescriptor.codecId, codecDescriptor.targetTypes);\n }\n if (codecDescriptor.meta !== undefined) {\n metaById.set(codecDescriptor.codecId, codecDescriptor.meta);\n }\n if (typeof codecDescriptor.renderOutputType === 'function') {\n renderersById.set(codecDescriptor.codecId, codecDescriptor.renderOutputType);\n }\n // Materialize a representative `Codec` instance for `byId.get()` so consumers reading the lookup's instance side (e.g. SQL renderer's cast-policy lookup, or the contract emitter's literal-default `encodeJson` resolver) keep finding the codec.\n //\n // Two cohorts:\n // - Non-parameterized descriptors: factory must succeed; any throw is a real bug and we let it propagate (no silent try/catch).\n // - Parameterized descriptors: try with empty params. Many parameterized codecs treat params as advisory (e.g. `pg/timestamptz@1` whose precision is rendered into the `nativeType` only and never read by the runtime codec), so an empty-params construction yields a usable representative for id-keyed lookups (e.g. emit-time literal-default encoding). Codecs whose factory genuinely requires params (e.g. `pg/vector@1` threading `length` into the runtime codec) will throw; for those, per-column instances are materialized at runtime by `buildContractCodecRegistry` and the id-keyed lookup miss is correct (the column-aware path resolves them).\n if (!byId.has(codecDescriptor.codecId)) {\n if (codecDescriptor.isParameterized) {\n try {\n const representative = codecDescriptor.factory({} as never)({\n name: `<lookup:${codecDescriptor.codecId}>`,\n } as Parameters<ReturnType<typeof codecDescriptor.factory>>[0]);\n byId.set(codecDescriptor.codecId, representative);\n } catch {\n // Factory requires concrete params; skip representative materialization. Per-column instances are built at runtime; id-keyed lookup miss is the correct outcome here.\n }\n } else {\n const representative = codecDescriptor.factory(undefined as never)({\n name: `<lookup:${codecDescriptor.codecId}>`,\n } as Parameters<ReturnType<typeof codecDescriptor.factory>>[0]);\n byId.set(codecDescriptor.codecId, representative);\n }\n }\n }\n }\n return {\n get: (id) => byId.get(id),\n targetTypesFor: (id) => targetTypesById.get(id),\n metaFor: (id) => metaById.get(id),\n renderOutputTypeFor: (id, params) => renderersById.get(id)?.(params),\n };\n}\n\nexport function validateScalarTypeCodecIds(\n scalarTypeDescriptors: ReadonlyMap<string, string>,\n codecLookup: CodecLookup,\n): string[] {\n const errors: string[] = [];\n for (const [typeName, codecId] of scalarTypeDescriptors) {\n if (!codecLookup.get(codecId)) {\n errors.push(\n `Scalar type \"${typeName}\" references codec \"${codecId}\" which is not registered by any component.`,\n );\n }\n }\n return errors;\n}\n\ninterface DependencyDeclaringDescriptor {\n readonly id: string;\n readonly contractSpace?: {\n readonly contractJson?: {\n readonly extensionPacks?: Readonly<Record<string, unknown>>;\n };\n };\n}\n\nfunction readDeclaredDependencyIds(descriptor: DependencyDeclaringDescriptor): readonly string[] {\n const packs = descriptor.contractSpace?.contractJson?.extensionPacks;\n if (packs === null || typeof packs !== 'object') return [];\n return Object.keys(packs);\n}\n\n/**\n * Builds a dependency-respecting load order for the given extension descriptors\n * using Kahn's topological sort algorithm. Dependencies (packs declared in\n * `contractSpace.contractJson.extensionPacks`) are placed before the extensions\n * that depend on them.\n *\n * Throws if the dependency graph contains a cycle, with an error message that\n * names every extension involved in the cycle.\n *\n * Throws if any extension declares a dependency on a pack ID that is not present\n * in the provided list — add the missing pack to the `extensionPacks` list to\n * resolve the error.\n */\n\nexport function buildExtensionLoadOrder(\n extensions: ReadonlyArray<DependencyDeclaringDescriptor>,\n): readonly string[] {\n if (extensions.length === 0) return [];\n\n const idSet = new Set(extensions.map((e) => e.id));\n const inDegree = new Map<string, number>();\n const dependents = new Map<string, string[]>();\n\n for (const ext of extensions) {\n if (!inDegree.has(ext.id)) inDegree.set(ext.id, 0);\n if (!dependents.has(ext.id)) dependents.set(ext.id, []);\n }\n\n for (const ext of extensions) {\n for (const depId of readDeclaredDependencyIds(ext)) {\n if (!idSet.has(depId)) {\n throw new Error(\n `Extension \"${ext.id}\" declares a dependency on \"${depId}\", but \"${depId}\" is not in the provided extension set. Add the missing space to extensionPacks.`,\n );\n }\n inDegree.set(ext.id, (inDegree.get(ext.id) ?? 0) + 1);\n const list = dependents.get(depId);\n if (list !== undefined) list.push(ext.id);\n }\n }\n\n const queue: string[] = [];\n for (const [id, deg] of inDegree) {\n if (deg === 0) queue.push(id);\n }\n queue.sort();\n\n const result: string[] = [];\n while (queue.length > 0) {\n const id = queue.shift();\n if (id === undefined) break;\n result.push(id);\n const children = dependents.get(id) ?? [];\n children.sort();\n for (const childId of children) {\n const newDeg = (inDegree.get(childId) ?? 1) - 1;\n inDegree.set(childId, newDeg);\n if (newDeg === 0) queue.push(childId);\n }\n }\n\n if (result.length < extensions.length) {\n const cycleMembers = extensions\n .map((e) => e.id)\n .filter((id) => !result.includes(id))\n .sort();\n throw new Error(\n `Extension dependency cycle detected. Cycle members: ${cycleMembers.map((id) => `\"${id}\"`).join(', ')}.`,\n );\n }\n\n return result;\n}\n\nexport function createControlStack<TFamilyId extends string, TTargetId extends string>(\n input: CreateControlStackInput<TFamilyId, TTargetId>,\n): ControlStack<TFamilyId, TTargetId> {\n const { family, target, adapter, driver, extensionPacks = [] } = input;\n\n const orderedIds = buildExtensionLoadOrder(extensionPacks);\n const extensionById = new Map(extensionPacks.map((ext) => [ext.id, ext]));\n const orderedExtensionPacks = orderedIds\n .map((id) => extensionById.get(id))\n .filter((ext): ext is ControlExtensionDescriptor<TFamilyId, TTargetId> => ext !== undefined);\n\n const allDescriptors = [family, target, ...(adapter ? [adapter] : []), ...orderedExtensionPacks];\n\n const codecLookup = extractCodecLookup(allDescriptors);\n const scalarTypeDescriptors = assembleScalarTypeDescriptors(allDescriptors);\n\n return {\n family,\n target,\n adapter,\n driver,\n extensionPacks: orderedExtensionPacks,\n\n codecTypeImports: extractCodecTypeImports(allDescriptors),\n queryOperationTypeImports: extractQueryOperationTypeImports(allDescriptors),\n extensionIds: extractComponentIds(family, target, adapter, orderedExtensionPacks),\n codecLookup,\n authoringContributions: assembleAuthoringContributions(allDescriptors),\n scalarTypeDescriptors,\n controlMutationDefaults: assembleControlMutationDefaults(allDescriptors),\n };\n}\n","import type { ControlPolicy } from '@prisma-next/contract/types';\nimport type { SchemaVerificationNode } from './control-result-types';\n\nexport type VerificationStatus = SchemaVerificationNode['status'];\n\nexport type VerifierOutcome = VerificationStatus | 'suppress';\n\n/**\n * Target-neutral classification of a verifier finding, abstracted away from any\n * one storage model's vocabulary. Each family classifies its own concrete issue\n * kinds into these categories; the framework only grades the category against a\n * control policy.\n *\n * - `declaredMissing` — a declared object/element is absent from the database.\n * - `declaredIncompatible` — a declared object/element exists but its shape diverges.\n * - `valueDrift` — the value set of an existing type drifted (e.g. enum values).\n * - `extraNestedElement` — an undeclared element nested inside a declared object\n * (a SQL column, a document field).\n * - `extraAuxiliary` — an undeclared auxiliary attached to a declared object\n * (a SQL constraint/index, a Mongo index/validator).\n * - `extraTopLevelObject` — an undeclared top-level object (a SQL table, a\n * Mongo collection).\n */\nexport type VerifierIssueCategory =\n | 'declaredMissing'\n | 'declaredIncompatible'\n | 'valueDrift'\n | 'extraNestedElement'\n | 'extraAuxiliary'\n | 'extraTopLevelObject';\n\n/**\n * Grades a target-neutral issue category against a control policy.\n *\n * - `observed` warns on everything.\n * - `tolerated` suppresses only an extra nested element (everything else fails).\n * - `external` suppresses every extra category and value drift (existence and\n * declared-shape divergences still fail).\n * - `managed` (and any other) fails.\n */\nexport function dispositionForCategory(\n controlPolicy: ControlPolicy,\n category: VerifierIssueCategory,\n): VerifierOutcome {\n if (controlPolicy === 'observed') {\n return 'warn';\n }\n if (controlPolicy === 'tolerated' && category === 'extraNestedElement') {\n return 'suppress';\n }\n if (controlPolicy === 'external') {\n if (\n category === 'extraNestedElement' ||\n category === 'extraAuxiliary' ||\n category === 'extraTopLevelObject' ||\n category === 'valueDrift'\n ) {\n return 'suppress';\n }\n }\n return 'fail';\n}\n"],"mappings":";;;AAkBA,SAAgB,cACd,QAC4D;CAC5D,OAAO,gBAAgB,UAAU,CAAC,CAAE,OAAmC;AACzE;AAMA,SAAgB,cACd,UACwF;CACxF,OACE,kBAAkB,YAClB,OAAQ,SAAqC,oBAAoB;AAErE;AAUA,SAAgB,oBACd,UAC8F;CAC9F,OACE,sBAAsB,YACtB,OAAQ,S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EAC1E,cAAc,oBAAoB,QAAQ,QAAQ,SAAS,qBAAqB;EAChF;EACA,wBAAwB,+BAA+B,cAAc;EACrE;EACA,yBAAyB,gCAAgC,cAAc;CACzE;AACF;;;;;;;;;;;;ACncA,SAAgB,uBACd,eACA,UACiB;CACjB,IAAI,kBAAkB,YACpB,OAAO;CAET,IAAI,kBAAkB,eAAe,aAAa,sBAChD,OAAO;CAET,IAAI,kBAAkB;MAElB,aAAa,wBACb,aAAa,oBACb,aAAa,yBACb,aAAa,cAEb,OAAO;CAAA;CAGX,OAAO;AACT"}
1
+ {"version":3,"file":"control.mjs","names":[],"sources":["../src/control/control-capabilities.ts","../src/control/control-result-types.ts","../src/control/control-schema-view.ts","../src/control/control-spaces.ts","../src/control/control-stack.ts","../src/control/verifier-disposition.ts"],"sourcesContent":["import type { ControlTargetDescriptor } from './control-descriptors';\nimport type { ControlFamilyInstance } from './control-instances';\nimport type { MigrationPlanOperation, TargetMigrationsCapability } from './control-migration-types';\nimport type { OperationPreview } from './control-operation-preview';\nimport type { CoreSchemaView } from './control-schema-view';\nimport type { PslDocumentAst } from './psl-ast';\n\nexport interface MigratableTargetDescriptor<\n TFamilyId extends string,\n TTargetId extends string,\n TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<\n TFamilyId,\n unknown\n >,\n> extends ControlTargetDescriptor<TFamilyId, TTargetId> {\n readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;\n}\n\nexport function hasMigrations<TFamilyId extends string, TTargetId extends string>(\n target: ControlTargetDescriptor<TFamilyId, TTargetId>,\n): target is MigratableTargetDescriptor<TFamilyId, TTargetId> {\n return 'migrations' in target && !!(target as Record<string, unknown>)['migrations'];\n}\n\nexport interface SchemaViewCapable<TSchemaIR = unknown> {\n toSchemaView(schema: TSchemaIR): CoreSchemaView;\n}\n\nexport function hasSchemaView<TFamilyId extends string, TSchemaIR>(\n instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,\n): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaViewCapable<TSchemaIR> {\n return (\n 'toSchemaView' in instance &&\n typeof (instance as Record<string, unknown>)['toSchemaView'] === 'function'\n );\n}\n\n/**\n * Capability declaring that a family can infer a PSL contract AST from its\n * opaque introspected schema IR. Consumed by `prisma-next contract infer`.\n */\nexport interface PslContractInferCapable<TSchemaIR = unknown> {\n inferPslContract(schemaIR: TSchemaIR): PslDocumentAst;\n}\n\nexport function hasPslContractInfer<TFamilyId extends string, TSchemaIR>(\n instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,\n): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & PslContractInferCapable<TSchemaIR> {\n return (\n 'inferPslContract' in instance &&\n typeof (instance as Record<string, unknown>)['inferPslContract'] === 'function'\n );\n}\n\n/**\n * Capability declaring that a family can render a textual preview of migration\n * operations for the CLI's \"DDL preview\" output. SQL families emit\n * `language: 'sql'` statements; Mongo families emit `language: 'mongodb-shell'`.\n */\nexport interface OperationPreviewCapable {\n toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;\n}\n\nexport function hasOperationPreview<TFamilyId extends string, TSchemaIR>(\n instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,\n): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & OperationPreviewCapable {\n return (\n 'toOperationPreview' in instance &&\n typeof (instance as Record<string, unknown>)['toOperationPreview'] === 'function'\n );\n}\n","export const VERIFY_CODE_MARKER_MISSING = 'PN-RUN-3001';\nexport const VERIFY_CODE_HASH_MISMATCH = 'PN-RUN-3002';\nexport const VERIFY_CODE_TARGET_MISMATCH = 'PN-RUN-3003';\nexport const VERIFY_CODE_SCHEMA_FAILURE = 'PN-RUN-3010';\n\nexport interface OperationContext {\n readonly contractPath?: string;\n readonly configPath?: string;\n readonly meta?: Readonly<Record<string, unknown>>;\n}\n\nexport interface VerifyDatabaseResult {\n readonly ok: boolean;\n readonly code?: string;\n readonly summary: string;\n readonly contract: {\n readonly storageHash: string;\n readonly profileHash?: string;\n };\n readonly marker?: {\n readonly storageHash?: string;\n readonly profileHash?: string;\n };\n readonly target: {\n readonly expected: string;\n readonly actual?: string;\n };\n readonly missingCodecs?: readonly string[];\n readonly codecCoverageSkipped?: boolean;\n readonly meta?: {\n readonly configPath?: string;\n readonly contractPath: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport interface BaseSchemaIssue {\n readonly kind:\n | 'missing_schema'\n | 'missing_table'\n | 'missing_column'\n | 'extra_table'\n | 'extra_column'\n | 'extra_primary_key'\n | 'extra_foreign_key'\n | 'extra_unique_constraint'\n | 'extra_index'\n | 'extra_validator'\n | 'type_mismatch'\n | 'type_missing'\n | 'type_values_mismatch'\n | 'nullability_mismatch'\n | 'primary_key_mismatch'\n | 'foreign_key_mismatch'\n | 'unique_constraint_mismatch'\n | 'index_mismatch'\n | 'default_missing'\n | 'default_mismatch'\n | 'extra_default'\n | 'check_missing'\n | 'check_removed'\n | 'check_mismatch';\n readonly table?: string;\n /**\n * Namespace coordinate of the issue's subject (e.g. the schema a SQL\n * table lives in). Populated by family verifiers that have the\n * coordinate in scope when constructing the issue; absent for issues\n * whose family has no namespace concept (e.g. Mongo collections) or\n * whose subject isn't in any contract namespace (e.g. an extra-table\n * issue raised for a table that exists in the live DB but not in the\n * contract).\n *\n * Downstream planners trust this field as the authoritative subject\n * coordinate and do not re-derive it by name lookup. A finer-grained\n * structural split between framework-shared and family-specific issue\n * fields is tracked under a follow-up ticket.\n */\n readonly namespaceId?: string;\n readonly column?: string;\n readonly indexOrConstraint?: string;\n readonly typeName?: string;\n readonly expected?: string;\n readonly actual?: string;\n readonly message: string;\n}\n\nexport interface EnumValuesChangedIssue {\n readonly kind: 'enum_values_changed';\n /**\n * Namespace coordinate of the enum type that changed values. Populated by\n * family verifiers that have the coordinate in scope when constructing the\n * issue. Downstream planners trust this field as the authoritative subject\n * coordinate and do not re-derive it by name lookup.\n */\n readonly namespaceId: string;\n readonly typeName: string;\n readonly addedValues: readonly string[];\n readonly removedValues: readonly string[];\n readonly message: string;\n}\n\nexport type SchemaIssue = BaseSchemaIssue | EnumValuesChangedIssue;\n\nexport interface SchemaVerificationNode {\n readonly status: 'pass' | 'warn' | 'fail';\n readonly kind: string;\n readonly name: string;\n readonly contractPath: string;\n readonly code: string;\n readonly message: string;\n readonly expected: unknown;\n readonly actual: unknown;\n readonly children: readonly SchemaVerificationNode[];\n}\n\nexport interface VerifyDatabaseSchemaResult {\n readonly ok: boolean;\n readonly code?: string;\n readonly summary: string;\n readonly contract: {\n readonly storageHash: string;\n readonly profileHash?: string;\n };\n readonly target: {\n readonly expected: string;\n readonly actual?: string;\n };\n readonly schema: {\n readonly issues: readonly SchemaIssue[];\n readonly root: SchemaVerificationNode;\n readonly counts: {\n readonly pass: number;\n readonly warn: number;\n readonly fail: number;\n readonly totalNodes: number;\n };\n };\n readonly meta?: {\n readonly configPath?: string;\n readonly contractPath?: string;\n readonly strict: boolean;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport interface EmitContractResult {\n readonly contractJson: string;\n readonly contractDts: string;\n readonly storageHash: string;\n readonly executionHash?: string;\n readonly profileHash: string;\n}\n\nexport interface IntrospectSchemaResult<TSchemaIR> {\n readonly ok: true;\n readonly summary: string;\n readonly target: {\n readonly familyId: string;\n readonly id: string;\n };\n readonly schema: TSchemaIR;\n readonly meta?: {\n readonly configPath?: string;\n readonly dbUrl?: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport interface SignDatabaseResult {\n readonly ok: boolean;\n readonly summary: string;\n readonly contract: {\n readonly storageHash: string;\n readonly profileHash?: string;\n };\n readonly target: {\n readonly expected: string;\n readonly actual?: string;\n };\n readonly marker: {\n readonly created: boolean;\n readonly updated: boolean;\n readonly previous?: {\n readonly storageHash?: string;\n readonly profileHash?: string;\n };\n };\n readonly meta?: {\n readonly configPath?: string;\n readonly contractPath: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n","/**\n * Core schema view types for family-agnostic schema visualization.\n *\n * These types provide a minimal, generic, tree-shaped representation of schemas\n * across families, designed for CLI visualization and lightweight tooling.\n *\n * Families can optionally project their family-specific Schema IR into this\n * core view via the `toSchemaView` method on `FamilyInstance`.\n */\n\nexport type SchemaViewNodeKind =\n | 'root'\n | 'namespace'\n | 'collection'\n | 'entity'\n | 'field'\n | 'index'\n | 'dependency';\n\nexport interface SchemaTreeVisitor<R> {\n visit(node: SchemaTreeNode): R;\n}\n\nexport interface SchemaTreeNodeOptions {\n readonly kind: SchemaViewNodeKind;\n readonly id: string;\n readonly label: string;\n readonly meta?: Record<string, unknown>;\n readonly children?: readonly SchemaTreeNode[];\n}\n\nexport class SchemaTreeNode {\n readonly kind: SchemaViewNodeKind;\n readonly id: string;\n readonly label: string;\n readonly meta?: Record<string, unknown>;\n readonly children?: readonly SchemaTreeNode[];\n\n constructor(options: SchemaTreeNodeOptions) {\n this.kind = options.kind;\n this.id = options.id;\n this.label = options.label;\n if (options.meta !== undefined) this.meta = options.meta;\n if (options.children !== undefined) this.children = options.children;\n Object.freeze(this);\n }\n\n accept<R>(visitor: SchemaTreeVisitor<R>): R {\n return visitor.visit(this);\n }\n}\n\n/**\n * Core schema view providing a family-agnostic tree representation of a schema.\n * Used by CLI and cross-family tooling for visualization.\n */\nexport interface CoreSchemaView {\n readonly root: SchemaTreeNode;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { MigrationMetadata, MigrationPlanOperation } from './control-migration-types';\n\n/**\n * Canonical control-plane identifiers for contract spaces.\n *\n * A contract space is the disjoint `(contract.json, migration-graph)` unit\n * the per-space planner / runner / verifier (project: extension contract\n * spaces, TML-2397) operates on. The application owns one well-known\n * space — the value below — and each loaded extension that contributes\n * schema owns a uniquely-named space.\n *\n * Lives in `framework-components/control` so every layer that has to\n * reason about space identity (the migration tooling, the SQL runtime's\n * marker reader, target-side statement builders, target-side adapters)\n * can import a single value rather than duplicating the literal. Raw\n * `'app'` string literals in framework / target / runtime / adapter\n * source code are forbidden and policed by\n * `scripts/lint-app-space-id.mjs` (wired into `pnpm lint:deps`).\n *\n * @see specs/framework-mechanism.spec.md § 3 — Layout convention (γ).\n */\nexport const APP_SPACE_ID = 'app' as const;\n\n/**\n * Head ref for a contract space — the `(hash, invariants)` tuple\n * a runner targets when applying that space's migration graph. Identical\n * in shape to the on-disk `migrations/<space-id>/refs/head.json` the\n * framework writes per loaded extension, and to the app-space\n * `<projectRoot>/refs/head.json`. Family-agnostic: SQL, Mongo, and any\n * future family share the same head-ref shape.\n *\n * @see specs/framework-mechanism.spec.md § 1.\n */\nexport interface ContractSpaceHeadRef {\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\n/**\n * Canonical structural shape of a migration package — the unit a planner\n * produces and a runner consumes: a directory name, the metadata\n * envelope, and the operation list.\n *\n * In-memory by default. Readers in `@prisma-next/migration-tools`\n * (`readMigrationPackage` / `readMigrationsDir`) return the augmented\n * {@link import('@prisma-next/migration-tools/package').OnDiskMigrationPackage}\n * variant which adds `dirPath`; everything else operates against the\n * canonical shape so the same value flows through pre-emission\n * authoring, on-disk loading, and runner execution without conversion.\n *\n * @see specs/framework-mechanism.spec.md § 1.\n */\nexport interface MigrationPackage {\n readonly dirName: string;\n readonly metadata: MigrationMetadata;\n readonly ops: readonly MigrationPlanOperation[];\n}\n\n/**\n * Canonical structural shape of a contract space — one disjoint\n * `(contractJson, migration-graph)` unit the per-space planner / runner\n * / verifier operates on. The application owns one well-known space\n * ({@link APP_SPACE_ID}); each loaded extension that contributes schema\n * owns a uniquely-named space. Whether a value is the app's space or an\n * extension's space is a control-plane concern; the type carries no\n * such distinction.\n *\n * Generic over the contract so each family pins a typed contract value\n * at consumption time. The SQL family specialises to\n * `ContractSpace<Contract<SqlStorage>>` at the descriptor surface;\n * Mongo's symmetrical `ContractSpace<Contract<MongoStorage>>` will land\n * with that family.\n *\n * @see specs/framework-mechanism.spec.md § 1.\n */\nexport interface ContractSpace<TContract extends Contract = Contract> {\n readonly contractJson: TContract;\n readonly migrations: readonly MigrationPackage[];\n readonly headRef: ContractSpaceHeadRef;\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport type { Codec } from '../shared/codec';\nimport type { AnyCodecDescriptor } from '../shared/codec-descriptor';\nimport type { CodecLookup, CodecMeta, CodecRef, CodecRegistry } from '../shared/codec-types';\nimport type {\n AuthoringContributions,\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringPslBlockDescriptorNamespace,\n AuthoringTypeNamespace,\n} from '../shared/framework-authoring';\nimport {\n assertNoCrossRegistryCollisions,\n isAuthoringEntityTypeDescriptor,\n isAuthoringFieldPresetDescriptor,\n isAuthoringPslBlockDescriptor,\n isAuthoringTypeConstructorDescriptor,\n mergeAuthoringNamespaces,\n} from '../shared/framework-authoring';\nimport type { ComponentMetadata } from '../shared/framework-components';\nimport type {\n ControlMutationDefaultEntry,\n ControlMutationDefaults,\n MutationDefaultGeneratorDescriptor,\n} from '../shared/mutation-default-types';\nimport {\n CONTRACT_CODEC_DESCRIPTOR_MISSING,\n materializeCodec,\n resolveCodecDescriptorOrThrow,\n} from '../shared/resolve-codec';\nimport type { TypesImportSpec } from '../shared/types-import-spec';\nimport type {\n ControlAdapterDescriptor,\n ControlDriverDescriptor,\n ControlExtensionDescriptor,\n ControlFamilyDescriptor,\n ControlTargetDescriptor,\n} from './control-descriptors';\n\nexport interface AssembledAuthoringContributions {\n readonly field: AuthoringFieldNamespace;\n readonly type: AuthoringTypeNamespace;\n readonly entityTypes: AuthoringEntityTypeNamespace;\n readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;\n}\n\nexport interface ControlStack<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> {\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter?: ControlAdapterDescriptor<TFamilyId, TTargetId> | undefined;\n readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;\n readonly extensionPacks: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];\n\n readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;\n readonly queryOperationTypeImports: ReadonlyArray<TypesImportSpec>;\n readonly extensionIds: ReadonlyArray<string>;\n readonly codecLookup: CodecRegistry;\n readonly authoringContributions: AssembledAuthoringContributions;\n readonly scalarTypeDescriptors: ReadonlyMap<string, string>;\n readonly controlMutationDefaults: ControlMutationDefaults;\n}\n\nexport interface CreateControlStackInput<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> {\n readonly family: ControlFamilyDescriptor<TFamilyId>;\n readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter?: ControlAdapterDescriptor<TFamilyId, TTargetId> | undefined;\n readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;\n readonly extensionPacks?:\n | ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>>\n | undefined;\n}\n\nfunction addUniqueId(ids: string[], seen: Set<string>, id: string): void {\n if (!seen.has(id)) {\n ids.push(id);\n seen.add(id);\n }\n}\n\nexport function assertUniqueCodecOwner(options: {\n readonly codecId: string;\n readonly owners: Map<string, string>;\n readonly descriptorId: string;\n readonly entityLabel: string;\n readonly entityOwnershipLabel: string;\n}): void {\n const existingOwner = options.owners.get(options.codecId);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate ${options.entityLabel} for codecId \"${options.codecId}\". ` +\n `Descriptor \"${options.descriptorId}\" conflicts with \"${existingOwner}\". ` +\n `Each codecId can only have one ${options.entityOwnershipLabel}.`,\n );\n }\n}\n\nexport function extractCodecTypeImports(\n descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>,\n): ReadonlyArray<TypesImportSpec> {\n const imports: TypesImportSpec[] = [];\n\n for (const descriptor of descriptors) {\n const codecTypes = descriptor.types?.codecTypes;\n if (codecTypes?.import) {\n imports.push(codecTypes.import);\n }\n if (codecTypes?.typeImports) {\n imports.push(...codecTypes.typeImports);\n }\n }\n\n return imports;\n}\n\nexport function extractQueryOperationTypeImports(\n descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>,\n): ReadonlyArray<TypesImportSpec> {\n const imports: TypesImportSpec[] = [];\n\n for (const descriptor of descriptors) {\n const queryOperationTypes = descriptor.types?.queryOperationTypes;\n if (queryOperationTypes?.import) {\n imports.push(queryOperationTypes.import);\n }\n }\n\n return imports;\n}\n\nexport function extractComponentIds(\n family: { readonly id: string },\n target: { readonly id: string },\n adapter: { readonly id: string } | undefined,\n extensions: ReadonlyArray<{ readonly id: string }>,\n): ReadonlyArray<string> {\n const ids: string[] = [];\n const seen = new Set<string>();\n\n addUniqueId(ids, seen, family.id);\n addUniqueId(ids, seen, target.id);\n if (adapter) {\n addUniqueId(ids, seen, adapter.id);\n }\n\n for (const ext of extensions) {\n addUniqueId(ids, seen, ext.id);\n }\n\n return ids;\n}\n\nexport function assembleAuthoringContributions(\n descriptors: ReadonlyArray<{ readonly authoring?: AuthoringContributions }>,\n): AssembledAuthoringContributions {\n const field = {} as Record<string, unknown>;\n const type = {} as Record<string, unknown>;\n const entityTypes = {} as Record<string, unknown>;\n const pslBlockDescriptors: Record<string, unknown> = {};\n\n for (const descriptor of descriptors) {\n if (descriptor.authoring?.field) {\n mergeAuthoringNamespaces(\n field,\n descriptor.authoring.field,\n [],\n isAuthoringFieldPresetDescriptor,\n 'field',\n );\n }\n if (descriptor.authoring?.type) {\n mergeAuthoringNamespaces(\n type,\n descriptor.authoring.type,\n [],\n isAuthoringTypeConstructorDescriptor,\n 'type',\n );\n }\n if (descriptor.authoring?.entityTypes) {\n mergeAuthoringNamespaces(\n entityTypes,\n descriptor.authoring.entityTypes,\n [],\n isAuthoringEntityTypeDescriptor,\n 'entity',\n );\n }\n if (descriptor.authoring?.pslBlockDescriptors) {\n mergeAuthoringNamespaces(\n pslBlockDescriptors,\n descriptor.authoring.pslBlockDescriptors,\n [],\n isAuthoringPslBlockDescriptor,\n 'pslBlock',\n );\n }\n }\n\n const fieldNamespace = field as AuthoringFieldNamespace;\n const typeNamespace = type as AuthoringTypeNamespace;\n const entityTypeNamespace = entityTypes as AuthoringEntityTypeNamespace;\n const pslBlockDescriptorNamespace = blindCast<\n AuthoringPslBlockDescriptorNamespace,\n 'merge target accumulator narrows to typed namespace post-merge'\n >(pslBlockDescriptors);\n assertNoCrossRegistryCollisions(\n typeNamespace,\n fieldNamespace,\n entityTypeNamespace,\n pslBlockDescriptorNamespace,\n );\n\n return {\n field: fieldNamespace,\n type: typeNamespace,\n entityTypes: entityTypeNamespace,\n pslBlockDescriptors: pslBlockDescriptorNamespace,\n };\n}\n\nexport function assembleScalarTypeDescriptors(\n descriptors: ReadonlyArray<\n Pick<ComponentMetadata, 'scalarTypeDescriptors'> & { readonly id?: string }\n >,\n): ReadonlyMap<string, string> {\n const result = new Map<string, string>();\n const owners = new Map<string, string>();\n\n for (const descriptor of descriptors) {\n const descriptorMap = descriptor.scalarTypeDescriptors;\n if (!descriptorMap) continue;\n const descriptorId = descriptor.id ?? '<unknown>';\n for (const [typeName, codecId] of descriptorMap) {\n const existingOwner = owners.get(typeName);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate scalar type descriptor \"${typeName}\". ` +\n `Descriptor \"${descriptorId}\" conflicts with \"${existingOwner}\".`,\n );\n }\n result.set(typeName, codecId);\n owners.set(typeName, descriptorId);\n }\n }\n\n return result;\n}\n\nexport function assembleControlMutationDefaults(\n descriptors: ReadonlyArray<\n Pick<ComponentMetadata, 'controlMutationDefaults'> & { readonly id?: string }\n >,\n): ControlMutationDefaults {\n const defaultFunctionRegistry = new Map<string, ControlMutationDefaultEntry>();\n const functionOwners = new Map<string, string>();\n const generatorMap = new Map<string, MutationDefaultGeneratorDescriptor>();\n const generatorOwners = new Map<string, string>();\n\n for (const descriptor of descriptors) {\n const contributions = descriptor.controlMutationDefaults;\n if (!contributions) continue;\n const descriptorId = descriptor.id ?? '<unknown>';\n\n for (const generatorDescriptor of contributions.generatorDescriptors) {\n const existingOwner = generatorOwners.get(generatorDescriptor.id);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate mutation default generator id \"${generatorDescriptor.id}\". ` +\n `Descriptor \"${descriptorId}\" conflicts with \"${existingOwner}\".`,\n );\n }\n generatorMap.set(generatorDescriptor.id, generatorDescriptor);\n generatorOwners.set(generatorDescriptor.id, descriptorId);\n }\n\n for (const [functionName, handler] of contributions.defaultFunctionRegistry) {\n const existingOwner = functionOwners.get(functionName);\n if (existingOwner !== undefined) {\n throw new Error(\n `Duplicate mutation default function \"${functionName}\". ` +\n `Descriptor \"${descriptorId}\" conflicts with \"${existingOwner}\".`,\n );\n }\n defaultFunctionRegistry.set(functionName, handler);\n functionOwners.set(functionName, descriptorId);\n }\n }\n\n return {\n defaultFunctionRegistry,\n generatorDescriptors: Array.from(generatorMap.values()),\n };\n}\n\nexport function extractCodecLookup(\n descriptors: ReadonlyArray<Pick<ComponentMetadata & { id: string }, 'types' | 'id'>>,\n): CodecRegistry {\n const byId = new Map<string, Codec>();\n const descriptorsById = new Map<string, AnyCodecDescriptor>();\n const targetTypesById = new Map<string, readonly string[]>();\n const metaById = new Map<string, CodecMeta>();\n const renderersById = new Map<string, (params: Record<string, unknown>) => string | undefined>();\n const inputRenderersById = new Map<\n string,\n (params: Record<string, unknown>) => string | undefined\n >();\n const owners = new Map<string, string>();\n for (const descriptor of descriptors) {\n const codecTypes = descriptor.types?.codecTypes;\n const descriptorId = descriptor.id;\n // Descriptor-side metadata is the single source of truth for `targetTypes` / `meta` / `renderOutputType`. Every contributor ships a `codecDescriptors` list on `types.codecTypes`.\n for (const codecDescriptor of codecTypes?.codecDescriptors ?? []) {\n assertUniqueCodecOwner({\n codecId: codecDescriptor.codecId,\n owners,\n descriptorId,\n entityLabel: 'codec descriptor',\n entityOwnershipLabel: 'codec descriptor provider',\n });\n owners.set(codecDescriptor.codecId, descriptorId);\n descriptorsById.set(codecDescriptor.codecId, codecDescriptor);\n if (Array.isArray(codecDescriptor.targetTypes)) {\n targetTypesById.set(codecDescriptor.codecId, codecDescriptor.targetTypes);\n }\n if (codecDescriptor.meta !== undefined) {\n metaById.set(codecDescriptor.codecId, codecDescriptor.meta);\n }\n if (typeof codecDescriptor.renderOutputType === 'function') {\n renderersById.set(codecDescriptor.codecId, codecDescriptor.renderOutputType);\n }\n if (typeof codecDescriptor.renderInputType === 'function') {\n inputRenderersById.set(codecDescriptor.codecId, codecDescriptor.renderInputType);\n }\n // Materialize a representative `Codec` instance for `byId.get()` so consumers reading the lookup's instance side (e.g. SQL renderer's cast-policy lookup, or the contract emitter's literal-default `encodeJson` resolver) keep finding the codec.\n //\n // Two cohorts:\n // - Non-parameterized descriptors: factory must succeed; any throw is a real bug and we let it propagate (no silent try/catch).\n // - Parameterized descriptors: try with empty params. Many parameterized codecs treat params as advisory (e.g. `pg/timestamptz@1` whose precision is rendered into the `nativeType` only and never read by the runtime codec), so an empty-params construction yields a usable representative for id-keyed lookups (e.g. emit-time literal-default encoding). Codecs whose factory genuinely requires params (e.g. `pg/vector@1` threading `length` into the runtime codec) will throw; for those, per-column instances are materialized at runtime by `buildContractCodecRegistry` and the id-keyed lookup miss is correct (the column-aware path resolves them).\n if (!byId.has(codecDescriptor.codecId)) {\n if (codecDescriptor.isParameterized) {\n try {\n const representative = codecDescriptor.factory({} as never)({\n name: `<lookup:${codecDescriptor.codecId}>`,\n } as Parameters<ReturnType<typeof codecDescriptor.factory>>[0]);\n byId.set(codecDescriptor.codecId, representative);\n } catch {\n // Factory requires concrete params; skip representative materialization. Per-column instances are built at runtime; id-keyed lookup miss is the correct outcome here.\n }\n } else {\n const representative = codecDescriptor.factory(undefined as never)({\n name: `<lookup:${codecDescriptor.codecId}>`,\n } as Parameters<ReturnType<typeof codecDescriptor.factory>>[0]);\n byId.set(codecDescriptor.codecId, representative);\n }\n }\n }\n }\n return {\n get: (id) => byId.get(id),\n forCodecRef(ref: CodecRef) {\n const d = resolveCodecDescriptorOrThrow(\n (id) => descriptorsById.get(id),\n ref,\n CONTRACT_CODEC_DESCRIPTOR_MISSING,\n );\n return materializeCodec(d, ref, { name: `<ref:${ref.codecId}>` });\n },\n forColumn: () => undefined,\n targetTypesFor: (id) => targetTypesById.get(id),\n metaFor: (id) => metaById.get(id),\n renderOutputTypeFor: (id, params) => renderersById.get(id)?.(params),\n renderInputTypeFor: (id, params) => inputRenderersById.get(id)?.(params),\n };\n}\n\nexport function validateScalarTypeCodecIds(\n scalarTypeDescriptors: ReadonlyMap<string, string>,\n codecLookup: CodecLookup,\n): string[] {\n const errors: string[] = [];\n for (const [typeName, codecId] of scalarTypeDescriptors) {\n if (!codecLookup.get(codecId)) {\n errors.push(\n `Scalar type \"${typeName}\" references codec \"${codecId}\" which is not registered by any component.`,\n );\n }\n }\n return errors;\n}\n\ninterface DependencyDeclaringDescriptor {\n readonly id: string;\n readonly contractSpace?: {\n readonly contractJson?: {\n readonly extensionPacks?: Readonly<Record<string, unknown>>;\n };\n };\n}\n\nfunction readDeclaredDependencyIds(descriptor: DependencyDeclaringDescriptor): readonly string[] {\n const packs = descriptor.contractSpace?.contractJson?.extensionPacks;\n if (packs === null || typeof packs !== 'object') return [];\n return Object.keys(packs);\n}\n\n/**\n * Builds a dependency-respecting load order for the given extension descriptors\n * using Kahn's topological sort algorithm. Dependencies (packs declared in\n * `contractSpace.contractJson.extensionPacks`) are placed before the extensions\n * that depend on them.\n *\n * Throws if the dependency graph contains a cycle, with an error message that\n * names every extension involved in the cycle.\n *\n * Throws if any extension declares a dependency on a pack ID that is not present\n * in the provided list — add the missing pack to the `extensionPacks` list to\n * resolve the error.\n */\n\nexport function buildExtensionLoadOrder(\n extensions: ReadonlyArray<DependencyDeclaringDescriptor>,\n): readonly string[] {\n if (extensions.length === 0) return [];\n\n const idSet = new Set(extensions.map((e) => e.id));\n const inDegree = new Map<string, number>();\n const dependents = new Map<string, string[]>();\n\n for (const ext of extensions) {\n if (!inDegree.has(ext.id)) inDegree.set(ext.id, 0);\n if (!dependents.has(ext.id)) dependents.set(ext.id, []);\n }\n\n for (const ext of extensions) {\n for (const depId of readDeclaredDependencyIds(ext)) {\n if (!idSet.has(depId)) {\n throw new Error(\n `Extension \"${ext.id}\" declares a dependency on \"${depId}\", but \"${depId}\" is not in the provided extension set. Add the missing space to extensionPacks.`,\n );\n }\n inDegree.set(ext.id, (inDegree.get(ext.id) ?? 0) + 1);\n const list = dependents.get(depId);\n if (list !== undefined) list.push(ext.id);\n }\n }\n\n const queue: string[] = [];\n for (const [id, deg] of inDegree) {\n if (deg === 0) queue.push(id);\n }\n queue.sort();\n\n const result: string[] = [];\n while (queue.length > 0) {\n const id = queue.shift();\n if (id === undefined) break;\n result.push(id);\n const children = dependents.get(id) ?? [];\n children.sort();\n for (const childId of children) {\n const newDeg = (inDegree.get(childId) ?? 1) - 1;\n inDegree.set(childId, newDeg);\n if (newDeg === 0) queue.push(childId);\n }\n }\n\n if (result.length < extensions.length) {\n const cycleMembers = extensions\n .map((e) => e.id)\n .filter((id) => !result.includes(id))\n .sort();\n throw new Error(\n `Extension dependency cycle detected. Cycle members: ${cycleMembers.map((id) => `\"${id}\"`).join(', ')}.`,\n );\n }\n\n return result;\n}\n\nexport function createControlStack<TFamilyId extends string, TTargetId extends string>(\n input: CreateControlStackInput<TFamilyId, TTargetId>,\n): ControlStack<TFamilyId, TTargetId> {\n const { family, target, adapter, driver, extensionPacks = [] } = input;\n\n const orderedIds = buildExtensionLoadOrder(extensionPacks);\n const extensionById = new Map(extensionPacks.map((ext) => [ext.id, ext]));\n const orderedExtensionPacks = orderedIds\n .map((id) => extensionById.get(id))\n .filter((ext): ext is ControlExtensionDescriptor<TFamilyId, TTargetId> => ext !== undefined);\n\n const allDescriptors = [family, target, ...(adapter ? [adapter] : []), ...orderedExtensionPacks];\n\n const codecLookup = extractCodecLookup(allDescriptors);\n const scalarTypeDescriptors = assembleScalarTypeDescriptors(allDescriptors);\n\n return {\n family,\n target,\n adapter,\n driver,\n extensionPacks: orderedExtensionPacks,\n\n codecTypeImports: extractCodecTypeImports(allDescriptors),\n queryOperationTypeImports: extractQueryOperationTypeImports(allDescriptors),\n extensionIds: extractComponentIds(family, target, adapter, orderedExtensionPacks),\n codecLookup,\n authoringContributions: assembleAuthoringContributions(allDescriptors),\n scalarTypeDescriptors,\n controlMutationDefaults: assembleControlMutationDefaults(allDescriptors),\n };\n}\n","import type { ControlPolicy } from '@prisma-next/contract/types';\nimport type { SchemaVerificationNode } from './control-result-types';\n\nexport type VerificationStatus = SchemaVerificationNode['status'];\n\nexport type VerifierOutcome = VerificationStatus | 'suppress';\n\n/**\n * Target-neutral classification of a verifier finding, abstracted away from any\n * one storage model's vocabulary. Each family classifies its own concrete issue\n * kinds into these categories; the framework only grades the category against a\n * control policy.\n *\n * - `declaredMissing` — a declared object/element is absent from the database.\n * - `declaredIncompatible` — a declared object/element exists but its shape diverges.\n * - `valueDrift` — the value set of an existing type drifted (e.g. enum values).\n * - `extraNestedElement` — an undeclared element nested inside a declared object\n * (a SQL column, a document field).\n * - `extraAuxiliary` — an undeclared auxiliary attached to a declared object\n * (a SQL constraint/index, a Mongo index/validator).\n * - `extraTopLevelObject` — an undeclared top-level object (a SQL table, a\n * Mongo collection).\n */\nexport type VerifierIssueCategory =\n | 'declaredMissing'\n | 'declaredIncompatible'\n | 'valueDrift'\n | 'extraNestedElement'\n | 'extraAuxiliary'\n | 'extraTopLevelObject';\n\n/**\n * Grades a target-neutral issue category against a control policy.\n *\n * - `observed` warns on everything.\n * - `tolerated` suppresses only an extra nested element (everything else fails).\n * - `external` suppresses every extra category and value drift (existence and\n * declared-shape divergences still fail).\n * - `managed` (and any other) fails.\n */\nexport function dispositionForCategory(\n controlPolicy: ControlPolicy,\n category: VerifierIssueCategory,\n): VerifierOutcome {\n if (controlPolicy === 'observed') {\n return 'warn';\n }\n if (controlPolicy === 'tolerated' && category === 'extraNestedElement') {\n return 'suppress';\n }\n if (controlPolicy === 'external') {\n if (\n category === 'extraNestedElement' ||\n category === 'extraAuxiliary' ||\n category === 'extra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C,CACpC,KAAK;EACR,MAAM,IAAI,MACR,uDAAuD,aAAa,KAAK,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,EACxG;CACF;CAEA,OAAO;AACT;AAEA,SAAgB,mBACd,OACoC;CACpC,MAAM,EAAE,QAAQ,QAAQ,SAAS,QAAQ,iBAAiB,CAAC,MAAM;CAEjE,MAAM,aAAa,wBAAwB,cAAc;CACzD,MAAM,gBAAgB,IAAI,IAAI,eAAe,KAAK,QAAQ,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;CACxE,MAAM,wBAAwB,WAC3B,KAAK,OAAO,cAAc,IAAI,EAAE,CAAC,CAAC,CAClC,QAAQ,QAAiE,QAAQ,KAAA,CAAS;CAE7F,MAAM,iBAAiB;EAAC;EAAQ;EAAQ,GAAI,UAAU,CAAC,OAAO,IAAI,CAAC;EAAI,GAAG;CAAqB;CAE/F,MAAM,cAAc,mBAAmB,cAAc;CACrD,MAAM,wBAAwB,8BAA8B,cAAc;CAE1E,OAAO;EACL;EACA;EACA;EACA;EACA,gBAAgB;EAEhB,kBAAkB,wBAAwB,cAAc;EACxD,2BAA2B,iCAAiC,cAAc;EAC1E,cAAc,oBAAoB,QAAQ,QAAQ,SAAS,qBAAqB;EAChF;EACA,wBAAwB,+BAA+B,cAAc;EACrE;EACA,yBAAyB,gCAAgC,cAAc;CACzE;AACF;;;;;;;;;;;;AC5dA,SAAgB,uBACd,eACA,UACiB;CACjB,IAAI,kBAAkB,YACpB,OAAO;CAET,IAAI,kBAAkB,eAAe,aAAa,sBAChD,OAAO;CAET,IAAI,kBAAkB;MAElB,aAAa,wBACb,aAAa,oBACb,aAAa,yBACb,aAAa,cAEb,OAAO;CAAA;CAGX,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
1
  import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
2
- import { Contract, ContractModel } from "@prisma-next/contract/types";
2
+ import { Contract, ContractModelBase } from "@prisma-next/contract/types";
3
3
 
4
4
  //#region src/control/emission-types.d.ts
5
5
  interface GenerateContractTypesOptions {
@@ -12,7 +12,7 @@ interface ValidationContext {
12
12
  interface EmissionSpi {
13
13
  readonly id: string;
14
14
  generateStorageType(contract: Contract, storageHashTypeName: string): string;
15
- generateModelStorageType(modelName: string, model: ContractModel): string;
15
+ generateModelStorageType(modelName: string, model: ContractModelBase): string;
16
16
  getFamilyImports(): string[];
17
17
  getFamilyTypeAliases(options?: GenerateContractTypesOptions): string;
18
18
  getTypeMapsExpression(): string;
@@ -31,8 +31,8 @@ interface EmissionSpi {
31
31
  *
32
32
  * Returns `undefined` when the field has no resolvable typeParams.
33
33
  */
34
- resolveFieldTypeParams?(modelName: string, fieldName: string, model: ContractModel, contract: Contract): Record<string, unknown> | undefined;
34
+ resolveFieldTypeParams?(modelName: string, fieldName: string, model: ContractModelBase, contract: Contract): Record<string, unknown> | undefined;
35
35
  }
36
36
  //#endregion
37
37
  export { GenerateContractTypesOptions as n, ValidationContext as r, EmissionSpi as t };
38
- //# sourceMappingURL=emission-types-vfpSTe63.d.mts.map
38
+ //# sourceMappingURL=emission-types-C561PwcN.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emission-types-C561PwcN.d.mts","names":[],"sources":["../src/control/emission-types.ts"],"mappings":";;;;UAGiB,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;EAjBjB;;;;;;;;;;AACS;AAGvC;;;EA6BE,sBAAA,EACE,SAAA,UACA,SAAA,UACA,KAAA,EAAO,iBAAA,EACP,QAAA,EAAU,QAAA,GACT,MAAA;AAAA"}
@@ -1,3 +1,3 @@
1
1
  import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
2
- import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-vfpSTe63.mjs";
2
+ import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-C561PwcN.mjs";
3
3
  export type { EmissionSpi, GenerateContractTypesOptions, TypesImportSpec, ValidationContext };
@@ -1,4 +1,4 @@
1
- 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-DDQXmW0b.mjs";
1
+ 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-5hA9ij1v.mjs";
2
2
 
3
3
  //#region src/execution/execution-instances.d.ts
4
4
  interface RuntimeFamilyInstance<TFamilyId extends string> extends FamilyInstance<TFamilyId> {}
@@ -1,3 +1,4 @@
1
+ import { r as CodecLookup } from "./codec-types-yY3eSmi0.mjs";
1
2
  import { ColumnDefault, ExecutionMutationDefaultPhases } from "@prisma-next/contract/types";
2
3
  import { Type } from "arktype";
3
4
 
@@ -23,6 +24,20 @@ interface PslSpan {
23
24
  readonly end: PslPosition;
24
25
  }
25
26
  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'
27
+ /**
28
+ * A qualified name (e.g. a dotted type or attribute reference) is structurally
29
+ * invalid, such as an over-qualified or trailing-separator name.
30
+ */
31
+ | 'PSL_INVALID_QUALIFIED_NAME'
32
+ /**
33
+ * A reserved declaration keyword (`model`/`enum`/`namespace`/`type`) that
34
+ * committed the declaration kind on the keyword alone but is missing its name
35
+ * and/or opening brace. The recursive-descent parser produces a best-effort
36
+ * typed node for the malformed header and reports this code rather than
37
+ * `PSL_UNSUPPORTED_TOP_LEVEL_BLOCK`, which is reserved for a genuinely unknown
38
+ * top-level keyword.
39
+ */
40
+ | 'PSL_INVALID_DECLARATION'
26
41
  /**
27
42
  * A malformed line inside an extension-contributed top-level block body, or
28
43
  * a structurally invalid element inside a `list` parameter value.
@@ -34,6 +49,21 @@ type PslDiagnosticCode = 'PSL_UNTERMINATED_BLOCK' | 'PSL_UNSUPPORTED_TOP_LEVEL_B
34
49
  * extension-block parse errors their own code.
35
50
  */
36
51
  | 'PSL_INVALID_EXTENSION_BLOCK_MEMBER'
52
+ /**
53
+ * A malformed JS-like object literal `{ key: value, … }` in value/argument
54
+ * position — a field missing its `:`, a field missing its value, or an
55
+ * unterminated `{`. The recursive-descent parser still produces a best-effort
56
+ * `ObjectLiteralExpr` node (preserving the lossless round-trip) and reports
57
+ * this code anchored on the offending token.
58
+ */
59
+ | 'PSL_INVALID_OBJECT_LITERAL'
60
+ /**
61
+ * A string literal with no closing quote — the tokenizer stops the literal at
62
+ * a newline or at EOF when no terminating `"` is found, and the
63
+ * recursive-descent parser still consumes the token (preserving the lossless
64
+ * round-trip) but reports this code anchored on the string token's span.
65
+ */
66
+ | 'PSL_UNTERMINATED_STRING'
37
67
  /**
38
68
  * An unknown parameter key in an extension-contributed block — a key present
39
69
  * in the source block but absent from the descriptor's `parameters` map.
@@ -58,7 +88,16 @@ type PslDiagnosticCode = 'PSL_UNTERMINATED_BLOCK' | 'PSL_UNSUPPORTED_TOP_LEVEL_B
58
88
  * A `ref`-kind parameter identifier does not resolve to a declared entity of
59
89
  * the required `refKind` within the declared scope.
60
90
  */
61
- | 'PSL_EXTENSION_UNRESOLVED_REF';
91
+ | 'PSL_EXTENSION_UNRESOLVED_REF'
92
+ /**
93
+ * A parameter key appears more than once in an extension block body.
94
+ * The first occurrence is kept; subsequent occurrences emit this diagnostic.
95
+ */
96
+ | 'PSL_EXTENSION_DUPLICATE_PARAMETER'
97
+ /**
98
+ * A `@@`-prefixed block-attribute line inside an extension block has invalid syntax.
99
+ */
100
+ | 'PSL_INVALID_EXTENSION_BLOCK_ATTRIBUTE';
62
101
  /**
63
102
  * Descriptor vocabulary for a single parameter on a declared block.
64
103
  *
@@ -96,19 +135,22 @@ interface PslBlockParamList {
96
135
  /**
97
136
  * The parsed representation of a single parameter value on a uniform
98
137
  * extension-block AST node. Mirrors the `PslBlockParam` descriptor
99
- * vocabulary:
138
+ * vocabulary, plus `bare` for keyonly entries:
100
139
  *
101
140
  * - `ref` → `PslExtensionBlockParamRef` — a raw identifier string
102
141
  * (resolution runs in the validator, not the parser).
103
- * - `value` → `PslExtensionBlockParamValue` — a raw PSL literal string
142
+ * - `value` → `PslExtensionBlockParamScalarValue` — a raw PSL literal string
104
143
  * (codec validation runs in the validator).
105
144
  * - `option` → `PslExtensionBlockParamOption` — the chosen token.
106
145
  * - `list` → `PslExtensionBlockParamList` — ordered list of the above.
146
+ * - `bare` → `PslExtensionBlockParamBare` — a bare identifier line with no
147
+ * `= value` (e.g. `Low` in an enum block). The name is the key in
148
+ * `parameters`; the interpreting consumer decides the default value.
107
149
  *
108
150
  * These shapes are intentionally minimal. The validator and lowering refine
109
151
  * and consume them; the generic framework parser produces them.
110
152
  */
111
- type PslExtensionBlockParamValue = PslExtensionBlockParamRef | PslExtensionBlockParamScalarValue | PslExtensionBlockParamOption | PslExtensionBlockParamList;
153
+ type PslExtensionBlockParamValue = PslExtensionBlockParamRef | PslExtensionBlockParamScalarValue | PslExtensionBlockParamOption | PslExtensionBlockParamList | PslExtensionBlockParamBare;
112
154
  interface PslExtensionBlockParamRef {
113
155
  readonly kind: 'ref';
114
156
  readonly identifier: string;
@@ -129,6 +171,35 @@ interface PslExtensionBlockParamList {
129
171
  readonly items: readonly PslExtensionBlockParamValue[];
130
172
  readonly span: PslSpan;
131
173
  }
174
+ /**
175
+ * A bare identifier line inside an extension block — a key with no `= value`.
176
+ * Emitted when a line matches `/^[A-Za-z_]\w*$/` with no assignment. The
177
+ * consumer decides what default value (if any) to apply.
178
+ */
179
+ interface PslExtensionBlockParamBare {
180
+ readonly kind: 'bare';
181
+ readonly span: PslSpan;
182
+ }
183
+ /**
184
+ * A positional argument on a block attribute, e.g. the `"pg/text@1"` in
185
+ * `@@type("pg/text@1")`.
186
+ */
187
+ interface PslExtensionBlockAttributeArg {
188
+ readonly kind: 'positional';
189
+ readonly value: string;
190
+ readonly span: PslSpan;
191
+ }
192
+ /**
193
+ * A `@@`-prefixed block-level attribute parsed inside an extension block,
194
+ * e.g. `@@type("pg/text@1")`. Block attributes are captured generically
195
+ * — the parser does not validate attribute names or argument shapes; that
196
+ * is a concern of the block's interpreter.
197
+ */
198
+ interface PslExtensionBlockAttribute {
199
+ readonly name: string;
200
+ readonly args: readonly PslExtensionBlockAttributeArg[];
201
+ readonly span: PslSpan;
202
+ }
132
203
  /**
133
204
  * Base shape for a uniform extension-contributed top-level PSL block
134
205
  * node, as produced by the generic framework parser and consumed by the
@@ -142,13 +213,19 @@ interface PslExtensionBlockParamList {
142
213
  * parameter names from the descriptor; values are the parsed parameter
143
214
  * representations. Only parameters present in the source are included
144
215
  * — absence of a required parameter is a validator concern, not a
145
- * parser concern.
216
+ * parser concern. Insertion order is preserved; the first occurrence of a
217
+ * duplicate key is retained and subsequent occurrences emit
218
+ * `PSL_EXTENSION_DUPLICATE_PARAMETER`.
219
+ * - `blockAttributes` are `@@`-prefixed attribute lines inside the block, in
220
+ * declaration order. Captured generically — names and args are not validated
221
+ * by the parser.
146
222
  * - `span` covers the full block from keyword to closing brace.
147
223
  */
148
224
  interface PslExtensionBlock {
149
225
  readonly kind: string;
150
226
  readonly name: string;
151
227
  readonly parameters: Record<string, PslExtensionBlockParamValue>;
228
+ readonly blockAttributes: readonly PslExtensionBlockAttribute[];
152
229
  readonly span: PslSpan;
153
230
  }
154
231
  //#endregion
@@ -228,9 +305,29 @@ type AuthoringFieldNamespace = {
228
305
  * discover what the factory actually needs to read (codec lookup,
229
306
  * namespace registry, …).
230
307
  */
308
+ /**
309
+ * A write-only sink that a factory may push authoring-time diagnostics into.
310
+ * The concrete type pushed must be structurally compatible with whatever the
311
+ * consumer accumulates (typically `ContractSourceDiagnostic[]`); the framework
312
+ * layer deliberately does not depend on that concrete type.
313
+ */
314
+ interface AuthoringDiagnosticSink {
315
+ push(d: {
316
+ readonly code: string;
317
+ readonly message: string;
318
+ readonly sourceId: string;
319
+ readonly span?: unknown;
320
+ }): void;
321
+ }
231
322
  interface AuthoringEntityContext {
232
323
  readonly family: string;
233
324
  readonly target: string;
325
+ /** Codec registry available to factories that need to validate or decode values. */
326
+ readonly codecLookup?: CodecLookup;
327
+ /** Source file identifier threaded into diagnostics emitted by the factory. */
328
+ readonly sourceId?: string;
329
+ /** Push channel for authoring-time diagnostics emitted by the factory. */
330
+ readonly diagnostics?: AuthoringDiagnosticSink;
234
331
  }
235
332
  interface AuthoringEntityTypeTemplateOutput {
236
333
  readonly template: AuthoringTemplateValue;
@@ -300,6 +397,21 @@ interface AuthoringPslBlockDescriptor {
300
397
  readonly required: boolean;
301
398
  };
302
399
  readonly parameters: Record<string, PslBlockParam>;
400
+ /**
401
+ * When `true`, the block body accepts a variadic tail of parameters beyond
402
+ * the declared set. The block body may contain: fields (model-style),
403
+ * `key = value` parameters, and `@@` attributes. With `variadicParameters`,
404
+ * bare identifiers (keys without a `= value`) and undeclared `key = value`
405
+ * pairs flow into the variadic tail — their semantics belong to the
406
+ * lowering, not the parser.
407
+ *
408
+ * A key that IS declared in `parameters` must still be supplied as
409
+ * `key = value`; a bare occurrence of a declared key is a diagnostic.
410
+ *
411
+ * When `false` (default), the validator emits `PSL_EXTENSION_UNKNOWN_PARAMETER`
412
+ * for keys absent from `parameters`.
413
+ */
414
+ readonly variadicParameters?: boolean;
303
415
  }
304
416
  type AuthoringPslBlockDescriptorNamespace = {
305
417
  readonly [name: string]: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace;
@@ -337,7 +449,7 @@ declare function isAuthoringPslBlockDescriptor(value: unknown): value is Authori
337
449
  declare function hasRegisteredFieldNamespace(contributions: AuthoringContributions | undefined, namespace: string): boolean;
338
450
  /**
339
451
  * Merges `source` into `target` recursively at the descriptor-namespace
340
- * level. `leafGuard` decides which values are descriptors (terminal
452
+ * level. `isLeafDescriptor` decides which values are descriptors (terminal
341
453
  * merge points; same-path registrations across components are reported
342
454
  * as duplicates) versus sub-namespaces (recursion targets).
343
455
  *
@@ -353,7 +465,7 @@ declare function hasRegisteredFieldNamespace(contributions: AuthoringContributio
353
465
  * cross-registry detection runs separately via
354
466
  * `assertNoCrossRegistryCollisions` after merging completes.
355
467
  */
356
- declare function mergeAuthoringNamespaces(target: Record<string, unknown>, source: Record<string, unknown>, path: readonly string[], leafGuard: (value: unknown) => boolean, label: string): void;
468
+ declare function mergeAuthoringNamespaces(target: Record<string, unknown>, source: Record<string, unknown>, path: readonly string[], isLeafDescriptor: (value: unknown) => boolean, label: string): void;
357
469
  declare function assertNoCrossRegistryCollisions(typeNamespace: AuthoringTypeNamespace, fieldNamespace: AuthoringFieldNamespace, entityTypeNamespace?: AuthoringEntityTypeNamespace, pslBlockNamespace?: AuthoringPslBlockDescriptorNamespace): void;
358
470
  declare function resolveAuthoringTemplateValue(template: AuthoringTemplateValue, args: readonly unknown[]): unknown;
359
471
  declare function validateAuthoringHelperArguments(helperPath: string, descriptors: readonly AuthoringArgumentDescriptor[] | undefined, args: readonly unknown[]): void;
@@ -376,5 +488,5 @@ declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPrese
376
488
  readonly unique: boolean;
377
489
  };
378
490
  //#endregion
379
- export { resolveAuthoringTemplateValue as A, PslExtensionBlockParamOption as B, instantiateAuthoringTypeConstructor as C, isAuthoringPslBlockDescriptor as D, isAuthoringFieldPresetDescriptor as E, PslBlockParamRef as F, PslSpan as G, PslExtensionBlockParamScalarValue as H, PslBlockParamValue as I, PslDiagnosticCode as L, PslBlockParam as M, PslBlockParamList as N, isAuthoringTypeConstructorDescriptor as O, PslBlockParamOption as P, PslExtensionBlock as R, instantiateAuthoringFieldPreset as S, isAuthoringEntityTypeDescriptor as T, PslExtensionBlockParamValue as U, PslExtensionBlockParamRef as V, PslPosition as W, AuthoringTypeConstructorDescriptor as _, AuthoringEntityContext as a, hasRegisteredFieldNamespace as b, AuthoringEntityTypeNamespace as c, AuthoringFieldPresetDescriptor as d, AuthoringFieldPresetOutput as f, AuthoringTemplateValue as g, AuthoringStorageTypeTemplate as h, AuthoringContributions as i, validateAuthoringHelperArguments as j, mergeAuthoringNamespaces as k, AuthoringEntityTypeTemplateOutput as l, AuthoringPslBlockDescriptorNamespace as m, AuthoringArgumentDescriptor as n, AuthoringEntityTypeDescriptor as o, AuthoringPslBlockDescriptor as p, AuthoringColumnDefaultTemplate as r, AuthoringEntityTypeFactoryOutput as s, AuthoringArgRef as t, AuthoringFieldNamespace as u, AuthoringTypeNamespace as v, isAuthoringArgRef as w, instantiateAuthoringEntityType as x, assertNoCrossRegistryCollisions as y, PslExtensionBlockParamList as z };
380
- //# sourceMappingURL=framework-authoring-R0TYCkvG.d.mts.map
491
+ export { mergeAuthoringNamespaces as A, PslExtensionBlockAttribute as B, instantiateAuthoringFieldPreset as C, isAuthoringFieldPresetDescriptor as D, isAuthoringEntityTypeDescriptor as E, PslBlockParamOption as F, PslExtensionBlockParamRef as G, PslExtensionBlockParamBare as H, PslBlockParamRef as I, PslPosition as J, PslExtensionBlockParamScalarValue as K, PslBlockParamValue as L, validateAuthoringHelperArguments as M, PslBlockParam as N, isAuthoringPslBlockDescriptor as O, PslBlockParamList as P, PslDiagnosticCode as R, instantiateAuthoringEntityType as S, isAuthoringArgRef as T, PslExtensionBlockParamList as U, PslExtensionBlockAttributeArg as V, PslExtensionBlockParamOption as W, PslSpan as Y, AuthoringTemplateValue as _, AuthoringDiagnosticSink as a, assertNoCrossRegistryCollisions as b, AuthoringEntityTypeFactoryOutput as c, AuthoringFieldNamespace as d, AuthoringFieldPresetDescriptor as f, AuthoringStorageTypeTemplate as g, AuthoringPslBlockDescriptorNamespace as h, AuthoringContributions as i, resolveAuthoringTemplateValue as j, isAuthoringTypeConstructorDescriptor as k, AuthoringEntityTypeNamespace as l, AuthoringPslBlockDescriptor as m, AuthoringArgumentDescriptor as n, AuthoringEntityContext as o, AuthoringFieldPresetOutput as p, PslExtensionBlockParamValue as q, AuthoringColumnDefaultTemplate as r, AuthoringEntityTypeDescriptor as s, AuthoringArgRef as t, AuthoringEntityTypeTemplateOutput as u, AuthoringTypeConstructorDescriptor as v, instantiateAuthoringTypeConstructor as w, hasRegisteredFieldNamespace as x, AuthoringTypeNamespace as y, PslExtensionBlock as z };
492
+ //# sourceMappingURL=framework-authoring-CJC4jwGo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-authoring-CJC4jwGo.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;AAA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