@prisma-next/sql-contract-ts
Advanced tools
| import { blindCast } from "@prisma-next/utils/casts"; | ||
| import { ifDefined } from "@prisma-next/utils/defined"; | ||
| import { computeExecutionHash, computeProfileHash, computeStorageHash } from "@prisma-next/contract/hashing"; | ||
| import { asNamespaceId, coreHash, crossRef } from "@prisma-next/contract/types"; | ||
| import { mergeCapabilityMatrices } from "@prisma-next/contract-authoring"; | ||
| import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring"; | ||
| import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir"; | ||
| import { sqlContractCanonicalizationHooks } from "@prisma-next/sql-contract/canonicalization-hooks"; | ||
| import { tableEntityKind, valueSetEntityKind } from "@prisma-next/sql-contract/entity-kinds"; | ||
| import { validateIndexTypes } from "@prisma-next/sql-contract/index-type-validation"; | ||
| import { createIndexTypeRegistry } from "@prisma-next/sql-contract/index-types"; | ||
| import { SqlStorage, applyFkDefaults, toStorageTypeInstance } from "@prisma-next/sql-contract/types"; | ||
| import { validateStorageSemantics } from "@prisma-next/sql-contract/validators"; | ||
| import { deriveValueSetFromEntity } from "@prisma-next/sql-contract/value-set-derivation-hook"; | ||
| //#region src/build-contract.ts | ||
| function encodeViaCodec(value, codecId, codecLookup) { | ||
| const codec = codecLookup?.get(codecId); | ||
| if (codec) return codec.encodeJson(value); | ||
| return blindCast(value); | ||
| } | ||
| function encodeColumnDefault(defaultInput, codecId, codecLookup, many = false) { | ||
| if (defaultInput.kind === "function") return { | ||
| kind: "function", | ||
| expression: defaultInput.expression | ||
| }; | ||
| if (many) { | ||
| if (!Array.isArray(defaultInput.value)) throw new Error(`Literal default on a list column must be an array; received ${typeof defaultInput.value}. A scalar default on a list field must be rejected at the authoring surface.`); | ||
| return { | ||
| kind: "literal", | ||
| value: defaultInput.value.map((element) => encodeViaCodec(element, codecId, codecLookup)) | ||
| }; | ||
| } | ||
| return { | ||
| kind: "literal", | ||
| value: encodeViaCodec(defaultInput.value, codecId, codecLookup) | ||
| }; | ||
| } | ||
| function assertStorageSemantics(definition, contract) { | ||
| const semanticErrors = validateStorageSemantics(contract.storage); | ||
| if (semanticErrors.length > 0) throw new Error(`Contract semantic validation failed: ${semanticErrors.join("; ")}`); | ||
| const indexTypeRegistry = createIndexTypeRegistry(); | ||
| const packsToRegister = [definition.target, ...Object.values(definition.extensionPacks ?? {})]; | ||
| for (const pack of packsToRegister) { | ||
| const registration = pack.indexTypes; | ||
| if (registration === void 0) continue; | ||
| if (typeof registration !== "object" || registration === null || !Array.isArray(registration.entries)) throw new Error(`Pack "${pack.id ?? "<unknown>"}" declares "indexTypes" but its value is not an IndexTypeRegistration (expected an object with an "entries" array; got ${typeof registration}).`); | ||
| for (const entry of registration.entries) indexTypeRegistry.register(entry); | ||
| } | ||
| validateIndexTypes(contract, indexTypeRegistry); | ||
| } | ||
| function assertKnownTargetModel(modelsByName, modelsByCoordinate, sourceModelName, targetModelName, targetNamespaceId, context) { | ||
| const targetModel = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? modelsByCoordinate.get(`${targetNamespaceId}:${targetModelName}`) : modelsByName.get(targetModelName); | ||
| if (!targetModel) { | ||
| const qualified = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? `${targetNamespaceId}.${targetModelName}` : targetModelName; | ||
| throw new Error(`${context} on model "${sourceModelName}" references unknown model "${qualified}"`); | ||
| } | ||
| return targetModel; | ||
| } | ||
| function assertTargetTableMatches(sourceModelName, targetModel, referencedTableName, context) { | ||
| if (targetModel.tableName !== referencedTableName) throw new Error(`${context} on model "${sourceModelName}" references table "${referencedTableName}" but model "${targetModel.modelName}" maps to "${targetModel.tableName}"`); | ||
| } | ||
| function isValueObjectField(field) { | ||
| return "valueObjectName" in field; | ||
| } | ||
| /** | ||
| * Resolves a deferred entity-ref column descriptor (e.g. a `pg.enum(handle)` | ||
| * column) against the field's now-known owning namespace: attaches the | ||
| * storage `valueSet` ref the collected entity's derived value-set is stored | ||
| * under. `nativeType` / `typeParams.typeName` stay bare here — schema | ||
| * qualification (e.g. `auth.aal_level`) is a target concern applied in the | ||
| * next step, `qualifyColumnDescriptor`. A descriptor with no `entityRef` (the | ||
| * ordinary case) passes through unchanged. | ||
| */ | ||
| function resolveEntityRefDescriptor(descriptor, namespaceId) { | ||
| const entityRef = descriptor.entityRef; | ||
| if (entityRef === void 0) return descriptor; | ||
| return { | ||
| ...descriptor, | ||
| valueSet: { | ||
| plane: "storage", | ||
| entityKind: "valueSet", | ||
| namespaceId, | ||
| entityName: entityRef.entityName | ||
| } | ||
| }; | ||
| } | ||
| /** | ||
| * Structural check for a target that contributes a `qualifyColumnType` hook | ||
| * on its authoring contributions. Duck-typed (mirroring | ||
| * `contract-psl`'s `hasColumnFromEntityHook`) so the SQL family stays blind | ||
| * to the target's qualification logic and no framework/family interface has | ||
| * to name the hook. | ||
| */ | ||
| function hasColumnTypeQualifier(authoring) { | ||
| return "qualifyColumnType" in authoring && typeof authoring.qualifyColumnType === "function"; | ||
| } | ||
| function resolveColumnTypeQualifier(target) { | ||
| const authoring = target.authoring; | ||
| if (authoring === void 0) return void 0; | ||
| return hasColumnTypeQualifier(authoring) ? authoring.qualifyColumnType : void 0; | ||
| } | ||
| /** | ||
| * Applies the target's `qualifyColumnType` hook to a scalar column descriptor | ||
| * at construction, so the storage column and the domain field (which derives | ||
| * its `type.typeParams` from the storage column) are both built already | ||
| * qualified in a single pass. A descriptor whose codec the target leaves | ||
| * unchanged passes through untouched. | ||
| */ | ||
| function qualifyColumnDescriptor(descriptor, namespaceId, qualify) { | ||
| if (qualify === void 0) return descriptor; | ||
| const qualified = qualify({ | ||
| codecId: descriptor.codecId, | ||
| nativeType: descriptor.nativeType, | ||
| ...ifDefined("typeParams", descriptor.typeParams) | ||
| }, namespaceId); | ||
| if (qualified.nativeType === descriptor.nativeType && qualified.typeParams === descriptor.typeParams) return descriptor; | ||
| return { | ||
| ...descriptor, | ||
| nativeType: qualified.nativeType, | ||
| ...ifDefined("typeParams", qualified.typeParams) | ||
| }; | ||
| } | ||
| /** | ||
| * Records a deferred column's entity-ref into the namespace-scoped collection | ||
| * accumulator (`namespaceId → entityKind → entityName`) — folded into the same | ||
| * namespace assembly `deriveEntityValueSets`/`entries.<kind>` step as the | ||
| * entities-channel attachments, so a column-collected entity gets its | ||
| * value-set the same way an entities-channel one does. | ||
| * | ||
| * The same handle reused by many columns in one namespace is normal (a native | ||
| * enum type backs any number of columns) and records the identical entity once. | ||
| * Two *different* entity instances sharing a name+kind in one namespace is a | ||
| * name collision — the emitted `entries.valueSet.<name>` could only reflect one | ||
| * of them, silently mismatching the other column's type/cast. PSL hard-errors | ||
| * on the equivalent (`PSL_DUPLICATE_DECLARATION`); the TS path rejects it too. | ||
| */ | ||
| function collectEntityFromColumn(collected, namespaceId, entityRef) { | ||
| const forNs = collected[namespaceId] ?? {}; | ||
| const forKind = forNs[entityRef.entityKind] ?? {}; | ||
| const existing = forKind[entityRef.entityName]; | ||
| if (existing !== void 0 && existing !== entityRef.entity) throw new Error(`buildSqlContractFromDefinition: two different "${entityRef.entityKind}" entities named "${entityRef.entityName}" in namespace "${namespaceId}" — pack-entity names must be unique per namespace.`); | ||
| forKind[entityRef.entityName] = entityRef.entity; | ||
| forNs[entityRef.entityKind] = forKind; | ||
| collected[namespaceId] = forNs; | ||
| } | ||
| /** | ||
| * Merges a namespace's entities-channel attachments (lowered from the | ||
| * `entities` handle list, carried on `ContractDefinition.attachedEntities`) | ||
| * with the entities collected from that namespace's deferred entity-ref | ||
| * columns. A column-collected entity that shadows a *different* attached | ||
| * entity of the same kind+name (or vice-versa) is the same name-collision bug | ||
| * `collectEntityFromColumn` guards against across columns, so it is rejected | ||
| * the same way — by entity identity, so the same handle attached and used by | ||
| * a column does not throw. | ||
| */ | ||
| function mergeColumnAndAttachedEntities(namespaceId, attached, columnCollected) { | ||
| if (attached === void 0) return columnCollected; | ||
| if (columnCollected === void 0) return attached; | ||
| const kinds = /* @__PURE__ */ new Set([...Object.keys(attached), ...Object.keys(columnCollected)]); | ||
| const result = {}; | ||
| for (const kind of kinds) { | ||
| const attachedForKind = attached[kind]; | ||
| const columnForKind = columnCollected[kind]; | ||
| for (const [name, entity] of Object.entries(columnForKind ?? {})) { | ||
| const existing = attachedForKind?.[name]; | ||
| if (existing !== void 0 && existing !== entity) throw new Error(`buildSqlContractFromDefinition: two different "${kind}" entities named "${name}" in namespace "${namespaceId}" — a column-referenced entity conflicts with an attached one; pack-entity names must be unique per namespace.`); | ||
| } | ||
| result[kind] = { | ||
| ...attachedForKind, | ||
| ...columnForKind | ||
| }; | ||
| } | ||
| return result; | ||
| } | ||
| const JSONB_CODEC_ID = "pg/jsonb@1"; | ||
| const JSONB_NATIVE_TYPE = "jsonb"; | ||
| function resolveModelNamespaceId(model, modelNameToNamespaceId, defaultNamespaceId) { | ||
| if (model.namespaceId !== void 0 && model.namespaceId.length > 0) return model.namespaceId; | ||
| return modelNameToNamespaceId.get(model.modelName) ?? defaultNamespaceId; | ||
| } | ||
| function buildThroughDescriptor(through, tableNamespaceByName, targetModel, modelName, fieldName, defaultNamespaceId) { | ||
| if (!tableNamespaceByName.has(through.table)) throw new Error(`buildSqlContractFromDefinition: junction table "${through.table}" for relation "${modelName}.${fieldName}" is not a declared model.`); | ||
| const namespaceId = through.namespaceId ?? defaultNamespaceId; | ||
| return { | ||
| table: through.table, | ||
| namespaceId, | ||
| parentColumns: through.parentColumns, | ||
| childColumns: through.childColumns, | ||
| targetColumns: targetColumnsForJunction(targetModel, fieldName) | ||
| }; | ||
| } | ||
| function targetColumnsForJunction(targetModel, fieldName) { | ||
| const primaryKeyColumns = targetModel.id?.columns; | ||
| if (primaryKeyColumns && primaryKeyColumns.length > 0) return primaryKeyColumns; | ||
| const firstUnique = targetModel.uniques?.find((u) => u.columns.length > 0); | ||
| if (firstUnique) return firstUnique.columns; | ||
| throw new Error(`M:N target model "${targetModel.modelName}" (relation field "${fieldName}") has no primary id or unique key to derive junction targetColumns.`); | ||
| } | ||
| function buildStorageColumn(field, storageValueSetRef, codecLookup) { | ||
| if (isValueObjectField(field)) { | ||
| const encodedDefault = field.default !== void 0 ? encodeColumnDefault(field.default, JSONB_CODEC_ID, codecLookup) : void 0; | ||
| return { | ||
| nativeType: JSONB_NATIVE_TYPE, | ||
| codecId: JSONB_CODEC_ID, | ||
| nullable: field.nullable, | ||
| ...ifDefined("default", encodedDefault) | ||
| }; | ||
| } | ||
| const codecId = field.descriptor.codecId; | ||
| const encodedDefault = field.default !== void 0 ? encodeColumnDefault(field.default, codecId, codecLookup, field.many === true) : void 0; | ||
| const valueSet = storageValueSetRef ?? field.descriptor.valueSet; | ||
| return { | ||
| nativeType: field.descriptor.nativeType, | ||
| codecId, | ||
| nullable: field.nullable, | ||
| ...field.many ? { many: true } : {}, | ||
| ...ifDefined("typeParams", field.descriptor.typeParams), | ||
| ...ifDefined("default", encodedDefault), | ||
| ...ifDefined("typeRef", field.descriptor.typeRef), | ||
| ...ifDefined("valueSet", valueSet) | ||
| }; | ||
| } | ||
| function buildDomainField(field, column, domainValueSetRef) { | ||
| if (isValueObjectField(field)) return { | ||
| type: { | ||
| kind: "valueObject", | ||
| name: field.valueObjectName | ||
| }, | ||
| nullable: field.nullable, | ||
| ...field.many ? { many: true } : {} | ||
| }; | ||
| return { | ||
| type: { | ||
| kind: "scalar", | ||
| codecId: column.codecId, | ||
| ...ifDefined("typeParams", column.typeParams) | ||
| }, | ||
| nullable: column.nullable, | ||
| ...field.many ? { many: true } : {}, | ||
| ...ifDefined("valueSet", domainValueSetRef) | ||
| }; | ||
| } | ||
| function collectStorageNamespaceCoordinateIds(definition) { | ||
| const ids = /* @__PURE__ */ new Set(); | ||
| ids.add(definition.target.defaultNamespaceId); | ||
| for (const id of definition.namespaces ?? []) if (id.length > 0) ids.add(id); | ||
| for (const model of definition.models) if (model.namespaceId !== void 0 && model.namespaceId.length > 0) ids.add(model.namespaceId); | ||
| for (const id of Object.keys(definition.attachedEntities ?? {})) if (id.length > 0) ids.add(id); | ||
| return ids; | ||
| } | ||
| /** | ||
| * Entry kinds the framework assembler itself manages (`table` from models, | ||
| * `valueSet` from `enums` and attached-entity value-set derivation). A | ||
| * pack-attached entity claiming one of these would silently clobber or be | ||
| * clobbered by the managed slot, so it is rejected outright. | ||
| */ | ||
| const MANAGED_ENTRY_KINDS = /* @__PURE__ */ new Set([tableEntityKind.kind, valueSetEntityKind.kind]); | ||
| function assertNoManagedEntityKinds(namespaceId, entitiesForNs) { | ||
| if (entitiesForNs === void 0) return; | ||
| for (const kind of Object.keys(entitiesForNs)) if (MANAGED_ENTRY_KINDS.has(kind)) throw new Error(`buildSqlContractFromDefinition: attached entity in namespace "${namespaceId}" declares entry kind "${kind}", which is managed by the framework (table/valueSet) and cannot be attached.`); | ||
| } | ||
| /** | ||
| * Walks the flat `entityTypes` namespace tree contributed by the target pack | ||
| * and every extension pack, indexing descriptors by their `discriminator` — | ||
| * the same string a pack entity's entries-map key (`entries.<kind>`) uses. | ||
| * Mirrors `contract-psl`'s `buildEntityTypesByDiscriminator`, recomposed here | ||
| * from the packs `ContractDefinition` already carries (`target` + | ||
| * `extensionPacks`) since the TS assembler has no single pre-merged | ||
| * `AuthoringContributions` input to read the way the PSL interpreter does. | ||
| */ | ||
| function collectEntityTypeDescriptorsByDiscriminator(definition) { | ||
| const result = /* @__PURE__ */ new Map(); | ||
| const walk = (namespace) => { | ||
| for (const value of Object.values(namespace)) if (isAuthoringEntityTypeDescriptor(value)) result.set(value.discriminator, value); | ||
| else walk(value); | ||
| }; | ||
| const components = [definition.target, ...Object.values(definition.extensionPacks ?? {})]; | ||
| for (const component of components) { | ||
| const entityTypes = component.authoring?.entityTypes; | ||
| if (entityTypes !== void 0) walk(entityTypes); | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Derives value-sets for every pack entity declared in one namespace, | ||
| * reusing the same `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook | ||
| * `contract-psl`'s `lowerExtensionBlocksForNamespace` folds into | ||
| * `entries.valueSet` on the PSL path — so a TS-attached entity (e.g. a | ||
| * native enum) gets its value-set the same way. Entity kinds with no | ||
| * registered descriptor, or whose descriptor output doesn't derive a | ||
| * value-set, contribute nothing. | ||
| */ | ||
| function deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator) { | ||
| if (entitiesForNs === void 0) return void 0; | ||
| let result; | ||
| for (const [kind, entitiesByName] of Object.entries(entitiesForNs)) { | ||
| const descriptor = entityTypesByDiscriminator.get(kind); | ||
| if (descriptor === void 0) continue; | ||
| for (const [name, entity] of Object.entries(entitiesByName)) { | ||
| const derivedValueSet = deriveValueSetFromEntity(descriptor.output, entity); | ||
| if (derivedValueSet === void 0) continue; | ||
| result ??= {}; | ||
| result[name] = derivedValueSet; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Merges a namespace's `enumType()`-derived value-sets with its pack-entity- | ||
| * derived value-sets. Both land in the same `entries.valueSet[name]` slot — | ||
| * which drives value-set → codec typing and the domain-enum CHECK — so a | ||
| * same-named entry in both would let one silently overwrite the other and | ||
| * corrupt whichever column resolves against it. The same collision class the | ||
| * `mergeColumnAndAttachedEntities` guard rejects; the PSL path already hard-errors | ||
| * on the equivalent (`interpretPslDocumentToSqlContract`). Reject it here too. | ||
| */ | ||
| function mergeNamespaceValueSets(namespaceId, enumValueSets, packValueSets) { | ||
| if (enumValueSets !== void 0 && packValueSets !== void 0) { | ||
| for (const name of Object.keys(packValueSets)) if (Object.hasOwn(enumValueSets, name)) throw new Error(`buildSqlContractFromDefinition: value-set "${name}" in namespace "${namespaceId}" is derived from both an enum and a pack entity — names must be unique per namespace.`); | ||
| } | ||
| return { | ||
| ...enumValueSets, | ||
| ...packValueSets | ||
| }; | ||
| } | ||
| function ensureUnboundNamespaceSlot(namespaces, createNamespace) { | ||
| if (Object.hasOwn(namespaces, UNBOUND_NAMESPACE_ID)) return namespaces; | ||
| const unbound = createNamespace({ | ||
| id: UNBOUND_NAMESPACE_ID, | ||
| entries: { table: {} } | ||
| }); | ||
| return { | ||
| [UNBOUND_NAMESPACE_ID]: unbound, | ||
| ...namespaces | ||
| }; | ||
| } | ||
| function buildSqlContractFromDefinition(definition, codecLookup) { | ||
| const target = definition.target.targetId; | ||
| const defaultNamespaceId = definition.target.defaultNamespaceId; | ||
| const qualifyColumnType = resolveColumnTypeQualifier(definition.target); | ||
| const targetFamily = "sql"; | ||
| const resolveNamespaceId = (m) => m.namespaceId !== void 0 && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId; | ||
| const modelsByName = new Map(definition.models.map((m) => [m.modelName, m])); | ||
| const tableNamespaceByName = new Map(definition.models.map((m) => [m.tableName, m.namespaceId !== void 0 && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId])); | ||
| const modelsByCoordinate = new Map(definition.models.map((m) => [`${resolveNamespaceId(m)}:${m.modelName}`, m])); | ||
| const tablesByNamespace = {}; | ||
| const modelNameToNamespaceId = /* @__PURE__ */ new Map(); | ||
| const executionDefaults = []; | ||
| const modelsByNamespace = {}; | ||
| const collectedColumnEntities = {}; | ||
| const rootEntries = []; | ||
| for (const semanticModel of definition.models) { | ||
| const tableName = semanticModel.tableName; | ||
| const namespaceId = semanticModel.namespaceId !== void 0 && semanticModel.namespaceId.length > 0 ? semanticModel.namespaceId : defaultNamespaceId; | ||
| modelNameToNamespaceId.set(semanticModel.modelName, namespaceId); | ||
| if (!semanticModel.sharesBaseTable) rootEntries.push({ | ||
| tableName, | ||
| namespaceId, | ||
| ref: crossRef(semanticModel.modelName, namespaceId) | ||
| }); | ||
| const columns = {}; | ||
| const fieldToColumn = {}; | ||
| const domainFields = {}; | ||
| const domainFieldRefs = {}; | ||
| const checksForTable = []; | ||
| for (const field of semanticModel.fields) { | ||
| const executionDefaultPhases = field.executionDefaults?.onCreate || field.executionDefaults?.onUpdate ? field.executionDefaults : void 0; | ||
| if (executionDefaultPhases) { | ||
| if (field.default !== void 0) throw new Error(`Field "${semanticModel.modelName}.${field.fieldName}" cannot define both default and executionDefaults.`); | ||
| if (field.nullable) throw new Error(`Field "${semanticModel.modelName}.${field.fieldName}" cannot be nullable when executionDefaults are present.`); | ||
| } | ||
| const enumHandle = !isValueObjectField(field) ? field.enumTypeHandle : void 0; | ||
| const storageValueSetRef = enumHandle !== void 0 ? { | ||
| plane: "storage", | ||
| entityKind: "valueSet", | ||
| namespaceId: defaultNamespaceId, | ||
| entityName: enumHandle.enumName | ||
| } : void 0; | ||
| const domainValueSetRef = enumHandle !== void 0 ? { | ||
| plane: "domain", | ||
| entityKind: "enum", | ||
| namespaceId: defaultNamespaceId, | ||
| entityName: enumHandle.enumName | ||
| } : void 0; | ||
| let resolvedField = field; | ||
| if (!isValueObjectField(field)) { | ||
| let descriptor = field.descriptor; | ||
| const entityRef = descriptor.entityRef; | ||
| if (entityRef !== void 0) { | ||
| collectEntityFromColumn(collectedColumnEntities, namespaceId, entityRef); | ||
| descriptor = resolveEntityRefDescriptor(descriptor, namespaceId); | ||
| } | ||
| descriptor = qualifyColumnDescriptor(descriptor, namespaceId, qualifyColumnType); | ||
| if (descriptor !== field.descriptor) resolvedField = { | ||
| ...field, | ||
| descriptor | ||
| }; | ||
| } | ||
| const column = buildStorageColumn(resolvedField, storageValueSetRef, codecLookup); | ||
| columns[field.columnName] = column; | ||
| fieldToColumn[field.fieldName] = field.columnName; | ||
| if (column.valueSet !== void 0 && storageValueSetRef !== void 0) checksForTable.push({ | ||
| name: `${tableName}_${field.columnName}_check`, | ||
| column: field.columnName, | ||
| valueSet: column.valueSet | ||
| }); | ||
| domainFields[field.fieldName] = buildDomainField(field, column, domainValueSetRef); | ||
| if (isValueObjectField(field)) domainFieldRefs[field.fieldName] = { | ||
| kind: "valueObject", | ||
| name: field.valueObjectName, | ||
| ...field.many ? { many: true } : {} | ||
| }; | ||
| else if (field.many) domainFieldRefs[field.fieldName] = { | ||
| kind: "scalar", | ||
| many: true | ||
| }; | ||
| if (executionDefaultPhases) executionDefaults.push({ | ||
| ref: { | ||
| namespace: namespaceId, | ||
| table: tableName, | ||
| column: field.columnName | ||
| }, | ||
| ...ifDefined("onCreate", executionDefaultPhases.onCreate), | ||
| ...ifDefined("onUpdate", executionDefaultPhases.onUpdate) | ||
| }); | ||
| } | ||
| const foreignKeys = (semanticModel.foreignKeys ?? []).map((fk) => { | ||
| if (fk.references.spaceId !== void 0) { | ||
| const targetNamespaceId = fk.references.namespaceId ?? defaultNamespaceId; | ||
| return { | ||
| source: { | ||
| namespaceId: asNamespaceId(namespaceId), | ||
| tableName, | ||
| columns: fk.columns | ||
| }, | ||
| target: { | ||
| namespaceId: asNamespaceId(targetNamespaceId), | ||
| tableName: fk.references.table, | ||
| columns: fk.references.columns, | ||
| spaceId: fk.references.spaceId | ||
| }, | ||
| ...applyFkDefaults({ | ||
| ...ifDefined("constraint", fk.constraint), | ||
| ...ifDefined("index", fk.index) | ||
| }, definition.foreignKeyDefaults), | ||
| ...ifDefined("name", fk.name), | ||
| ...ifDefined("onDelete", fk.onDelete), | ||
| ...ifDefined("onUpdate", fk.onUpdate) | ||
| }; | ||
| } | ||
| const targetModel = assertKnownTargetModel(modelsByName, modelsByCoordinate, semanticModel.modelName, fk.references.model, fk.references.namespaceId, "Foreign key"); | ||
| assertTargetTableMatches(semanticModel.modelName, targetModel, fk.references.table, "Foreign key"); | ||
| const targetNamespaceId = fk.references.namespaceId ?? (targetModel.namespaceId !== void 0 && targetModel.namespaceId.length > 0 ? targetModel.namespaceId : defaultNamespaceId); | ||
| return { | ||
| source: { | ||
| namespaceId: asNamespaceId(namespaceId), | ||
| tableName, | ||
| columns: fk.columns | ||
| }, | ||
| target: { | ||
| namespaceId: asNamespaceId(targetNamespaceId), | ||
| tableName: fk.references.table, | ||
| columns: fk.references.columns | ||
| }, | ||
| ...applyFkDefaults({ | ||
| ...ifDefined("constraint", fk.constraint), | ||
| ...ifDefined("index", fk.index) | ||
| }, definition.foreignKeyDefaults), | ||
| ...ifDefined("name", fk.name), | ||
| ...ifDefined("onDelete", fk.onDelete), | ||
| ...ifDefined("onUpdate", fk.onUpdate) | ||
| }; | ||
| }); | ||
| if (!semanticModel.sharesBaseTable) { | ||
| const tableInput = { | ||
| columns, | ||
| ...ifDefined("control", semanticModel.control), | ||
| uniques: (semanticModel.uniques ?? []).map((u) => ({ | ||
| columns: u.columns, | ||
| ...ifDefined("name", u.name) | ||
| })), | ||
| indexes: (semanticModel.indexes ?? []).map((i) => ({ | ||
| columns: i.columns, | ||
| ...ifDefined("name", i.name), | ||
| ...ifDefined("type", i.type), | ||
| ...ifDefined("options", i.options) | ||
| })), | ||
| foreignKeys, | ||
| ...semanticModel.id ? { primaryKey: { | ||
| columns: semanticModel.id.columns, | ||
| ...ifDefined("name", semanticModel.id.name) | ||
| } } : {}, | ||
| ...checksForTable.length > 0 ? { checks: checksForTable } : {} | ||
| }; | ||
| let nsTables = tablesByNamespace[namespaceId]; | ||
| if (nsTables === void 0) { | ||
| nsTables = {}; | ||
| tablesByNamespace[namespaceId] = nsTables; | ||
| } | ||
| if (nsTables[tableName] !== void 0) throw new Error(`buildSqlContractFromDefinition: duplicate table "${tableName}" in namespace "${namespaceId}".`); | ||
| nsTables[tableName] = tableInput; | ||
| } | ||
| const storageFields = {}; | ||
| for (const [fieldName, columnName] of Object.entries(fieldToColumn)) storageFields[fieldName] = { column: columnName }; | ||
| const columnToField = new Map(Object.entries(fieldToColumn).map(([field, col]) => [col, field])); | ||
| const modelRelations = {}; | ||
| for (const relation of semanticModel.relations ?? []) { | ||
| if (relation.spaceId !== void 0) { | ||
| const targetNamespaceId = relation.namespaceId ?? defaultNamespaceId; | ||
| modelRelations[relation.fieldName] = { | ||
| to: crossRef(relation.toModel, targetNamespaceId, relation.spaceId), | ||
| cardinality: "N:1", | ||
| on: { | ||
| localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col), | ||
| targetFields: relation.on.childColumns | ||
| } | ||
| }; | ||
| continue; | ||
| } | ||
| const targetModel = assertKnownTargetModel(modelsByName, modelsByCoordinate, semanticModel.modelName, relation.toModel, relation.toNamespaceId, "Relation"); | ||
| assertTargetTableMatches(semanticModel.modelName, targetModel, relation.toTable, "Relation"); | ||
| const targetColumnToField = new Map(targetModel.fields.map((f) => [f.columnName, f.fieldName])); | ||
| const to = crossRef(relation.toModel, relation.toNamespaceId !== void 0 && relation.toNamespaceId.length > 0 ? relation.toNamespaceId : resolveModelNamespaceId(targetModel, modelNameToNamespaceId, defaultNamespaceId)); | ||
| const on = { | ||
| localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col), | ||
| targetFields: relation.on.childColumns.map((col) => targetColumnToField.get(col) ?? col) | ||
| }; | ||
| if (relation.cardinality === "N:M") { | ||
| if (!relation.through) throw new Error(`Relation "${semanticModel.modelName}.${relation.fieldName}" with cardinality "N:M" requires through metadata`); | ||
| modelRelations[relation.fieldName] = { | ||
| to, | ||
| cardinality: "N:M", | ||
| on, | ||
| through: buildThroughDescriptor(relation.through, tableNamespaceByName, targetModel, semanticModel.modelName, relation.fieldName, defaultNamespaceId) | ||
| }; | ||
| } else modelRelations[relation.fieldName] = { | ||
| to, | ||
| cardinality: relation.cardinality, | ||
| on | ||
| }; | ||
| } | ||
| let namespaceModels = modelsByNamespace[namespaceId]; | ||
| if (namespaceModels === void 0) { | ||
| namespaceModels = {}; | ||
| modelsByNamespace[namespaceId] = namespaceModels; | ||
| } | ||
| namespaceModels[semanticModel.modelName] = { | ||
| storage: { | ||
| table: tableName, | ||
| namespaceId, | ||
| fields: storageFields | ||
| }, | ||
| fields: domainFields, | ||
| relations: modelRelations | ||
| }; | ||
| } | ||
| const rootTableNameCounts = /* @__PURE__ */ new Map(); | ||
| for (const entry of rootEntries) rootTableNameCounts.set(entry.tableName, (rootTableNameCounts.get(entry.tableName) ?? 0) + 1); | ||
| const roots = {}; | ||
| for (const entry of rootEntries) { | ||
| const key = (rootTableNameCounts.get(entry.tableName) ?? 0) > 1 ? `${entry.namespaceId}.${entry.tableName}` : entry.tableName; | ||
| roots[key] = entry.ref; | ||
| } | ||
| const rawStorageTypes = definition.storageTypes ?? {}; | ||
| const documentTypes = Object.fromEntries(Object.entries(rawStorageTypes).map(([name, entry]) => { | ||
| if (entry.kind === "codec-instance") return [name, entry]; | ||
| return [name, toStorageTypeInstance({ | ||
| codecId: entry.codecId, | ||
| nativeType: entry.nativeType, | ||
| typeParams: entry.typeParams ?? {} | ||
| })]; | ||
| })); | ||
| const namespaceCoordinateIds = collectStorageNamespaceCoordinateIds(definition); | ||
| const domainEnumsByNs = {}; | ||
| const storageValueSetsByNs = {}; | ||
| for (const [enumName, handle] of Object.entries(definition.enums ?? {})) { | ||
| if (enumName !== handle.enumName) throw new Error(`enum declaration key "${enumName}" must match enumType name "${handle.enumName}". Aliases are not supported.`); | ||
| const nsId = defaultNamespaceId; | ||
| let domainSlot = domainEnumsByNs[nsId]; | ||
| if (domainSlot === void 0) { | ||
| domainSlot = {}; | ||
| domainEnumsByNs[nsId] = domainSlot; | ||
| } | ||
| domainSlot[enumName] = { | ||
| codecId: handle.codecId, | ||
| members: handle.enumMembers.map((m) => ({ | ||
| name: m.name, | ||
| value: encodeViaCodec(m.value, handle.codecId, codecLookup) | ||
| })) | ||
| }; | ||
| let storageSlot = storageValueSetsByNs[nsId]; | ||
| if (storageSlot === void 0) { | ||
| storageSlot = {}; | ||
| storageValueSetsByNs[nsId] = storageSlot; | ||
| } | ||
| storageSlot[enumName] = { | ||
| kind: "valueSet", | ||
| values: handle.values.map((v) => encodeViaCodec(v, handle.codecId, codecLookup)) | ||
| }; | ||
| } | ||
| const { createNamespace } = definition; | ||
| const entityTypesByDiscriminator = collectEntityTypeDescriptorsByDiscriminator(definition); | ||
| const namespaces = Object.fromEntries([...namespaceCoordinateIds].sort().map((id) => { | ||
| const entitiesForNs = mergeColumnAndAttachedEntities(id, definition.attachedEntities?.[id], collectedColumnEntities[id]); | ||
| assertNoManagedEntityKinds(id, entitiesForNs); | ||
| const enumValueSetEntries = storageValueSetsByNs[id]; | ||
| const packValueSetEntries = deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator); | ||
| const valueSetEntries = enumValueSetEntries !== void 0 || packValueSetEntries !== void 0 ? mergeNamespaceValueSets(id, enumValueSetEntries, packValueSetEntries) : void 0; | ||
| const nsInput = { | ||
| id, | ||
| entries: { | ||
| table: tablesByNamespace[id] ?? {}, | ||
| ...entitiesForNs, | ||
| ...valueSetEntries !== void 0 && Object.keys(valueSetEntries).length > 0 ? { valueSet: valueSetEntries } : {} | ||
| } | ||
| }; | ||
| return [id, createNamespace(nsInput)]; | ||
| })); | ||
| const storageWithoutHash = { | ||
| ...Object.keys(documentTypes).length > 0 ? { types: documentTypes } : {}, | ||
| namespaces: defaultNamespaceId === UNBOUND_NAMESPACE_ID ? ensureUnboundNamespaceSlot(namespaces, createNamespace) : namespaces | ||
| }; | ||
| const storageHash = definition.storageHash ? coreHash(definition.storageHash) : computeStorageHash({ | ||
| target, | ||
| targetFamily, | ||
| storage: storageWithoutHash, | ||
| ...sqlContractCanonicalizationHooks | ||
| }); | ||
| const storage = new SqlStorage({ | ||
| ...storageWithoutHash, | ||
| storageHash | ||
| }); | ||
| const executionSection = executionDefaults.length > 0 ? { mutations: { defaults: executionDefaults.sort((a, b) => { | ||
| const tableCompare = a.ref.table.localeCompare(b.ref.table); | ||
| if (tableCompare !== 0) return tableCompare; | ||
| return a.ref.column.localeCompare(b.ref.column); | ||
| }) } } : void 0; | ||
| const extensionNamespaces = definition.extensionPacks ? Object.values(definition.extensionPacks).map((pack) => pack.id) : void 0; | ||
| const extensionPacks = { ...definition.extensionPacks || {} }; | ||
| if (extensionNamespaces) { | ||
| for (const namespace of extensionNamespaces) if (!Object.hasOwn(extensionPacks, namespace)) extensionPacks[namespace] = {}; | ||
| } | ||
| const extensionPackCapabilitySources = definition.extensionPacks ? Object.values(definition.extensionPacks).map((pack) => pack.capabilities) : []; | ||
| const capabilities = mergeCapabilityMatrices(definition.target.capabilities, ...extensionPackCapabilitySources); | ||
| const profileHash = computeProfileHash({ | ||
| target, | ||
| targetFamily, | ||
| capabilities: {} | ||
| }); | ||
| const executionWithHash = executionSection ? { | ||
| ...executionSection, | ||
| executionHash: computeExecutionHash({ | ||
| target, | ||
| targetFamily, | ||
| execution: executionSection | ||
| }) | ||
| } : void 0; | ||
| const valueObjects = definition.valueObjects && definition.valueObjects.length > 0 ? Object.fromEntries(definition.valueObjects.map((vo) => [vo.name, { fields: Object.fromEntries(vo.fields.map((f) => [f.fieldName, isValueObjectField(f) ? { | ||
| type: { | ||
| kind: "valueObject", | ||
| name: f.valueObjectName | ||
| }, | ||
| nullable: f.nullable, | ||
| ...f.many ? { many: true } : {} | ||
| } : { | ||
| type: { | ||
| kind: "scalar", | ||
| codecId: f.descriptor.codecId, | ||
| ...ifDefined("typeParams", f.descriptor.typeParams) | ||
| }, | ||
| nullable: f.nullable | ||
| }])) }])) : void 0; | ||
| const domainNamespaceIds = new Set(Object.keys(modelsByNamespace)); | ||
| if (domainNamespaceIds.size === 0) domainNamespaceIds.add(defaultNamespaceId); | ||
| if (valueObjects !== void 0) domainNamespaceIds.add(defaultNamespaceId); | ||
| for (const nsId of Object.keys(domainEnumsByNs)) domainNamespaceIds.add(nsId); | ||
| const domainNamespaces = Object.fromEntries([...domainNamespaceIds].sort().map((namespaceId) => { | ||
| const modelsInNs = modelsByNamespace[namespaceId] ?? {}; | ||
| const enumsInNs = domainEnumsByNs[namespaceId]; | ||
| return [namespaceId, { | ||
| models: modelsInNs, | ||
| ...namespaceId === defaultNamespaceId && valueObjects !== void 0 ? { valueObjects } : {}, | ||
| ...enumsInNs !== void 0 && Object.keys(enumsInNs).length > 0 ? { enum: enumsInNs } : {} | ||
| }]; | ||
| })); | ||
| const contract = { | ||
| target, | ||
| targetFamily, | ||
| ...ifDefined("defaultControlPolicy", definition.defaultControlPolicy), | ||
| domain: { namespaces: domainNamespaces }, | ||
| roots, | ||
| storage, | ||
| ...executionWithHash ? { execution: executionWithHash } : {}, | ||
| extensionPacks, | ||
| capabilities, | ||
| profileHash, | ||
| meta: {} | ||
| }; | ||
| assertStorageSemantics(definition, contract); | ||
| return contract; | ||
| } | ||
| //#endregion | ||
| export { buildSqlContractFromDefinition as t }; | ||
| //# sourceMappingURL=build-contract-BzAyIu0y.mjs.map |
Sorry, the diff of this file is too big to display
| import { Contract, ControlPolicy } from "@prisma-next/contract/types"; | ||
| import { SqlNamespaceBase, SqlNamespaceInput } from "@prisma-next/sql-contract/types"; | ||
| import { ContractConfig, ContractConfig as ContractConfig$1 } from "@prisma-next/config/config-types"; | ||
@@ -12,2 +13,3 @@ import { TargetPackRef } from "@prisma-next/framework-components/components"; | ||
| readonly target: TargetPackRef<'sql', string>; | ||
| readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase; | ||
| readonly defaultControlPolicy?: ControlPolicy; | ||
@@ -14,0 +16,0 @@ }): ContractConfig$1; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;;UAsBiB,kCAAA;EAAA,SACN,oBAAA,GAAuB,aAAa;AAAA;AAAA,iBAG/B,aAAA,CAAc,OAAA;EAAA,SACnB,MAAA;EAAA,SACA,MAAA,EAAQ,aAAA;EAAA,SACR,oBAAA,GAAuB,aAAA;AAAA,IAC9B,gBAAA;AAAA,iBAYY,kBAAA,CACd,QAAA,EAAU,QAAA,EACV,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAA;AAAA,iBAYa,0BAAA,CACd,YAAA,UACA,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAc"} | ||
| {"version":3,"file":"config-types.d.mts","names":[],"sources":["../src/config-types.ts"],"mappings":";;;;;;UAuBiB,kCAAA;EAAA,SACN,oBAAA,GAAuB,aAAa;AAAA;AAAA,iBAG/B,aAAA,CAAc,OAAA;EAAA,SACnB,MAAA;EAAA,SACA,MAAA,EAAQ,aAAA;EAAA,SACR,eAAA,GAAkB,KAAA,EAAO,iBAAA,KAAsB,gBAAA;EAAA,SAC/C,oBAAA,GAAuB,aAAA;AAAA,IAC9B,gBAAA;AAAA,iBAiBY,kBAAA,CACd,QAAA,EAAU,QAAA,EACV,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAA;AAAA,iBAaa,0BAAA,CACd,YAAA,UACA,MAAA,WACA,OAAA,GAAU,kCAAA,GACT,gBAAc"} |
@@ -1,2 +0,2 @@ | ||
| import { t as buildSqlContractFromDefinition } from "./build-contract-CQ4u83jx.mjs"; | ||
| import { t as buildSqlContractFromDefinition } from "./build-contract-BzAyIu0y.mjs"; | ||
| import { ifDefined } from "@prisma-next/utils/defined"; | ||
@@ -21,8 +21,12 @@ import { pathToFileURL } from "node:url"; | ||
| return { | ||
| source: { load: async () => { | ||
| return ok(applySpecifierDefaultControlPolicy(buildSqlContractFromDefinition({ | ||
| target: options.target, | ||
| models: [] | ||
| }), options.defaultControlPolicy)); | ||
| } }, | ||
| source: { | ||
| sourceFormat: "typescript", | ||
| load: async () => { | ||
| return ok(applySpecifierDefaultControlPolicy(buildSqlContractFromDefinition({ | ||
| target: options.target, | ||
| createNamespace: options.createNamespace, | ||
| models: [] | ||
| }), options.defaultControlPolicy)); | ||
| } | ||
| }, | ||
| ...ifDefined("output", options.output) | ||
@@ -33,3 +37,6 @@ }; | ||
| return { | ||
| source: { load: async () => ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)) }, | ||
| source: { | ||
| sourceFormat: "typescript", | ||
| load: async () => ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)) | ||
| }, | ||
| ...ifDefined("output", output) | ||
@@ -41,2 +48,3 @@ }; | ||
| source: { | ||
| sourceFormat: "typescript", | ||
| inputs: [contractPath], | ||
@@ -43,0 +51,0 @@ load: async (context) => { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport type { ContractConfig } from '@prisma-next/config/config-types';\nimport { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';\nimport type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { TargetPackRef } from '@prisma-next/framework-components/components';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\nimport { extname } from 'pathe';\nimport { buildSqlContractFromDefinition } from './build-contract';\n\n/**\n * Derives the emit output path from the TS contract input so artefacts land\n * colocated with the source (e.g. `prisma/contract.ts` →\n * `prisma/contract.json`). Mirrors the same default-derivation logic in\n * `@prisma-next/sql-contract-psl/provider`.\n */\nfunction defaultOutputFromContractPath(contractPath: string): string {\n const ext = extname(contractPath);\n if (ext.length === 0) return `${contractPath}.json`;\n return `${contractPath.slice(0, -ext.length)}.json`;\n}\n\nexport interface TypeScriptContractSpecifierOptions {\n readonly defaultControlPolicy?: ControlPolicy;\n}\n\nexport function emptyContract(options: {\n readonly output?: string;\n readonly target: TargetPackRef<'sql', string>;\n readonly defaultControlPolicy?: ControlPolicy;\n}): ContractConfig {\n return {\n source: {\n load: async () => {\n const built = buildSqlContractFromDefinition({ target: options.target, models: [] });\n return ok(applySpecifierDefaultControlPolicy(built, options.defaultControlPolicy));\n },\n },\n ...ifDefined('output', options.output),\n };\n}\n\nexport function typescriptContract(\n contract: Contract,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n load: async () =>\n ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)),\n },\n // The in-memory variant has no input path to anchor on; fall through to\n // the global default in `normalizeContractConfig` when caller doesn't pin it.\n ...ifDefined('output', output),\n };\n}\n\nexport function typescriptContractFromPath(\n contractPath: string,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n inputs: [contractPath],\n load: async (context) => {\n const [absolutePath] = context.resolvedInputs;\n if (absolutePath === undefined) {\n throw new Error(\n 'typescriptContractFromPath: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',\n );\n }\n const mod = await import(pathToFileURL(absolutePath).href);\n const contract: Contract | undefined = mod.default ?? mod.contract;\n if (contract === undefined) {\n throw new Error(\n `typescriptContractFromPath: module at \"${absolutePath}\" has no \"default\" or \"contract\" export.`,\n );\n }\n return ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy));\n },\n },\n output: output ?? defaultOutputFromContractPath(contractPath),\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAS,8BAA8B,cAA8B;CACnE,MAAM,MAAM,QAAQ,YAAY;CAChC,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,aAAa;CAC7C,OAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;AAC/C;AAMA,SAAgB,cAAc,SAIX;CACjB,OAAO;EACL,QAAQ,EACN,MAAM,YAAY;GAEhB,OAAO,GAAG,mCADI,+BAA+B;IAAE,QAAQ,QAAQ;IAAQ,QAAQ,CAAC;GAAE,CACjC,GAAG,QAAQ,oBAAoB,CAAC;EACnF,EACF;EACA,GAAG,UAAU,UAAU,QAAQ,MAAM;CACvC;AACF;AAEA,SAAgB,mBACd,UACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ,EACN,MAAM,YACJ,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC,EAClF;EAGA,GAAG,UAAU,UAAU,MAAM;CAC/B;AACF;AAEA,SAAgB,2BACd,cACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ;GACN,QAAQ,CAAC,YAAY;GACrB,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,gBAAgB,QAAQ;IAC/B,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,MACR,8IACF;IAEF,MAAM,MAAM,MAAM,OAAO,cAAc,YAAY,CAAC,CAAC;IACrD,MAAM,WAAiC,IAAI,WAAW,IAAI;IAC1D,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,0CAA0C,aAAa,yCACzD;IAEF,OAAO,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC;GACvF;EACF;EACA,QAAQ,UAAU,8BAA8B,YAAY;CAC9D;AACF"} | ||
| {"version":3,"file":"config-types.mjs","names":[],"sources":["../src/config-types.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport type { ContractConfig } from '@prisma-next/config/config-types';\nimport { applySpecifierDefaultControlPolicy } from '@prisma-next/contract/apply-specifier-default-control-policy';\nimport type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { TargetPackRef } from '@prisma-next/framework-components/components';\nimport type { SqlNamespaceBase, SqlNamespaceInput } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { ok } from '@prisma-next/utils/result';\nimport { extname } from 'pathe';\nimport { buildSqlContractFromDefinition } from './build-contract';\n\n/**\n * Derives the emit output path from the TS contract input so artefacts land\n * colocated with the source (e.g. `prisma/contract.ts` →\n * `prisma/contract.json`). Mirrors the same default-derivation logic in\n * `@prisma-next/sql-contract-psl/provider`.\n */\nfunction defaultOutputFromContractPath(contractPath: string): string {\n const ext = extname(contractPath);\n if (ext.length === 0) return `${contractPath}.json`;\n return `${contractPath.slice(0, -ext.length)}.json`;\n}\n\nexport interface TypeScriptContractSpecifierOptions {\n readonly defaultControlPolicy?: ControlPolicy;\n}\n\nexport function emptyContract(options: {\n readonly output?: string;\n readonly target: TargetPackRef<'sql', string>;\n readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;\n readonly defaultControlPolicy?: ControlPolicy;\n}): ContractConfig {\n return {\n source: {\n sourceFormat: 'typescript',\n load: async () => {\n const built = buildSqlContractFromDefinition({\n target: options.target,\n createNamespace: options.createNamespace,\n models: [],\n });\n return ok(applySpecifierDefaultControlPolicy(built, options.defaultControlPolicy));\n },\n },\n ...ifDefined('output', options.output),\n };\n}\n\nexport function typescriptContract(\n contract: Contract,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n sourceFormat: 'typescript',\n load: async () =>\n ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)),\n },\n // The in-memory variant has no input path to anchor on; fall through to\n // the global default in `normalizeContractConfig` when caller doesn't pin it.\n ...ifDefined('output', output),\n };\n}\n\nexport function typescriptContractFromPath(\n contractPath: string,\n output?: string,\n options?: TypeScriptContractSpecifierOptions,\n): ContractConfig {\n return {\n source: {\n sourceFormat: 'typescript',\n inputs: [contractPath],\n load: async (context) => {\n const [absolutePath] = context.resolvedInputs;\n if (absolutePath === undefined) {\n throw new Error(\n 'typescriptContractFromPath: context.resolvedInputs is empty. The CLI config loader should populate it positional-matched with source.inputs.',\n );\n }\n const mod = await import(pathToFileURL(absolutePath).href);\n const contract: Contract | undefined = mod.default ?? mod.contract;\n if (contract === undefined) {\n throw new Error(\n `typescriptContractFromPath: module at \"${absolutePath}\" has no \"default\" or \"contract\" export.`,\n );\n }\n return ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy));\n },\n },\n output: output ?? defaultOutputFromContractPath(contractPath),\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,SAAS,8BAA8B,cAA8B;CACnE,MAAM,MAAM,QAAQ,YAAY;CAChC,IAAI,IAAI,WAAW,GAAG,OAAO,GAAG,aAAa;CAC7C,OAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;AAC/C;AAMA,SAAgB,cAAc,SAKX;CACjB,OAAO;EACL,QAAQ;GACN,cAAc;GACd,MAAM,YAAY;IAMhB,OAAO,GAAG,mCALI,+BAA+B;KAC3C,QAAQ,QAAQ;KAChB,iBAAiB,QAAQ;KACzB,QAAQ,CAAC;IACX,CACiD,GAAG,QAAQ,oBAAoB,CAAC;GACnF;EACF;EACA,GAAG,UAAU,UAAU,QAAQ,MAAM;CACvC;AACF;AAEA,SAAgB,mBACd,UACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ;GACN,cAAc;GACd,MAAM,YACJ,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC;EAClF;EAGA,GAAG,UAAU,UAAU,MAAM;CAC/B;AACF;AAEA,SAAgB,2BACd,cACA,QACA,SACgB;CAChB,OAAO;EACL,QAAQ;GACN,cAAc;GACd,QAAQ,CAAC,YAAY;GACrB,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,gBAAgB,QAAQ;IAC/B,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,MACR,8IACF;IAEF,MAAM,MAAM,MAAM,OAAO,cAAc,YAAY,CAAC,CAAC;IACrD,MAAM,WAAiC,IAAI,WAAW,IAAI;IAC1D,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,0CAA0C,aAAa,yCACzD;IAEF,OAAO,GAAG,mCAAmC,UAAU,SAAS,oBAAoB,CAAC;GACvF;EACF;EACA,QAAQ,UAAU,8BAA8B,YAAY;CAC9D;AACF"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../src/enum-type.ts","../src/contract-dsl.ts","../src/authoring-type-utils.ts","../src/contract-types.ts","../src/composed-authoring-helpers.ts","../src/contract-definition.ts","../src/build-contract.ts","../src/contract-builder.ts"],"mappings":";;;;;;;;;;;;;;;;UAaiB,UAAA;EAAA,SACN,IAAA,EAAM,IAAA;EAAA,SACN,KAAA,EAAO,KAAK;AAAA;;;;;;;;iBAUP,MAAA,4BAAkC,IAAA,EAAM,IAAA,GAAO,UAAA,CAAW,IAAA,EAAM,IAAA;AAAA,iBAChE,MAAA,yCACd,IAAA,EAAM,IAAA,EACN,KAAA,EAAO,KAAA,GACN,UAAA,CAAW,IAAA,EAAM,KAAA;AAAA,KAkBf,eAAA,0BAAyC,UAAA,8CACvB,OAAA,GAAU,OAAA,CAAQ,CAAA,UAAW,UAAA,oBAA8B,CAAA;AAAA,KAG7E,cAAA,0BAAwC,UAAA,8CACtB,OAAA,GAAU,OAAA,CAAQ,CAAA,UAAW,UAAA,qBAA+B,CAAA;AAAA,KAG9E,kBAAA,0BAA4C,UAAA,wCAChC,OA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AAA,EACA,kBAAA,EACA,UAAA,EACA,aAAA,GAEF,OAAA,EAAS,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,YAAA,IACvE,iBAAA,CACD,oBAAA,CACE,MAAA,EACA,MAAA,EACA,KAAA,EACA,MAAA,EACA,cAAA,EACA,MAAA,EACA,WAAA,EACA,kBAAA,EACA,UAAA,EACA,UAAA,CAAW,aAAA,EAAe,YAAA"} | ||
| {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../src/contract-dsl.ts","../src/authoring-type-utils.ts","../src/contract-types.ts","../src/composed-authoring-helpers.ts","../src/contract-definition.ts","../src/build-contract.ts","../src/contract-builder.ts","../src/contract-lowering.ts"],"mappings":";;;;;;;;;;;KA4BY,cAAA;AAAA,KAEA,YAAA;EAAA,SACD,MAAA,GAAS,cAAA;EAAA,SACT,OAAA,GAAU,cAAc;AAAA;AAAA,KAG9B,mBAAA,YAA+B,mBAAA,GAAsB,cAAc;AAAA,KAEnE,uBAAA;EAAA,SACM,IAAA,EAAM,IAAI;AAAA;AAAA,KAGT,gBAAA,oBACS,oBAAA,GAAuB,oBAAA,kBAC1B,mBAAA,yIAGD,mBAAA,6CACI,mBAAA;EAAA,SAGV,IAAA;EAAA,SACA,UAAA,GAAa,UAAA;EAAA,SACb,OAAA,GAAU,OAAA;EAAA,SACV,QAAA,EAAU,QAAA;EAAA,SACV,UAAA,GAAa,UAAA;EAAA,SACb,OAAA,GAAU,aAAA;EAAA,SACV,iBAAA,GAAoB,8BAAA;EAAA,SACpB,IAAA,GAAO,IAAA;AAAA,KACb,MAAA,SAAe,mBAAA;EAAA,SAAiC,EAAA,EAAI,MAAA;AAAA;EAAA,SAAsB,EAAA;AAAA,MAC5E,UAAA,SAAmB,mBAAA;EAAA,SACL,MAAA,EAAQ,UAAA;AAAA;EAAA,SACR,MAAA;AAAA;AAAA,KAEZ,mBAAA;EAAA,SACM,IAAA;EAAA,SACA,UA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A,EACA,UAAA,EACA,KAAA,IAED,iBAAA,CACD,oBAAA,CACE,MAAA,EACA,MAAA,EACA,KAAA,EACA,MAAA,EACA,cAAA,EACA,MAAA,EACA,WAAA,EACA,kBAAA,EACA,UAAA,EACA,KAAA;AAAA,iBAGY,cAAA,sBACO,aAAA,+BACA,aAAA,qCACD,MAAA,SAAe,mBAAA,IAAuB,MAAA,qCACrC,MAAA,SAAe,SAAA,IAAa,MAAA,6CAE7C,MAAA,SAAe,gBAAA,+DAEE,aAAA,+HAEY,uBAAA,0HAEL,MAAA,SAAe,cAAA,IAAkB,MAAA,SAAe,cAAA,8BACjD,MAAA,SAAe,cAAA,IAAkB,MAAA,SAAe,cAAA,GAE3E,UAAA,EAAY,gBAAA,CACV,MAAA,EACA,MAAA,EACA,cAAA,EACA,MAAA,EACA,WAAA,EACA,kBAAA,EACA,UAAA,EACA,aAAA,GAEF,OAAA,EAAS,eAAA,CAAgB,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,YAAA,IACvE,iBAAA,CACD,oBAAA,CACE,MAAA,EACA,MAAA,EACA,KAAA,EACA,MAAA,EACA,cAAA,EACA,MAAA,EACA,WAAA,EACA,kBAAA,EACA,UAAA,EACA,UAAA,CAAW,aAAA,EAAe,YAAA;;;iBCyed,uBAAA,CAAwB,UAAA,EAAY,aAAA,GAAgB,kBAAkB"} |
+14
-14
| { | ||
| "name": "@prisma-next/sql-contract-ts", | ||
| "version": "0.14.0", | ||
| "version": "0.15.0", | ||
| "license": "Apache-2.0", | ||
@@ -9,9 +9,9 @@ "type": "module", | ||
| "dependencies": { | ||
| "@prisma-next/config": "0.14.0", | ||
| "@prisma-next/contract": "0.14.0", | ||
| "@prisma-next/contract-authoring": "0.14.0", | ||
| "@prisma-next/framework-components": "0.14.0", | ||
| "@prisma-next/sql-contract": "0.14.0", | ||
| "@prisma-next/utils": "0.14.0", | ||
| "arktype": "^2.2.0", | ||
| "@prisma-next/config": "0.15.0", | ||
| "@prisma-next/contract": "0.15.0", | ||
| "@prisma-next/contract-authoring": "0.15.0", | ||
| "@prisma-next/framework-components": "0.15.0", | ||
| "@prisma-next/sql-contract": "0.15.0", | ||
| "@prisma-next/utils": "0.15.0", | ||
| "arktype": "^2.2.2", | ||
| "pathe": "^2.0.3", | ||
@@ -21,10 +21,10 @@ "ts-toolbelt": "^9.6.0" | ||
| "devDependencies": { | ||
| "@prisma-next/test-utils": "0.14.0", | ||
| "@prisma-next/tsconfig": "0.14.0", | ||
| "@prisma-next/test-utils": "0.15.0", | ||
| "@prisma-next/tsconfig": "0.15.0", | ||
| "@types/pg": "8.20.0", | ||
| "pg": "8.21.0", | ||
| "@prisma-next/tsdown": "0.14.0", | ||
| "tsdown": "0.22.1", | ||
| "pg": "8.22.0", | ||
| "@prisma-next/tsdown": "0.15.0", | ||
| "tsdown": "0.22.3", | ||
| "typescript": "5.9.3", | ||
| "vitest": "4.1.8" | ||
| "vitest": "4.1.10" | ||
| }, | ||
@@ -31,0 +31,0 @@ "peerDependencies": { |
@@ -66,3 +66,3 @@ import type { | ||
| helpers[key] = createTypeHelpersFromNamespace(value as AuthoringTypeNamespace, currentPath); | ||
| helpers[key] = createTypeHelpersFromNamespace(value, currentPath); | ||
| } | ||
@@ -137,7 +137,3 @@ | ||
| helpers[key] = createFieldHelpersFromNamespace( | ||
| value as AuthoringFieldNamespace, | ||
| createLeafHelper, | ||
| currentPath, | ||
| ); | ||
| helpers[key] = createFieldHelpersFromNamespace(value, createLeafHelper, currentPath); | ||
| } | ||
@@ -144,0 +140,0 @@ |
@@ -5,2 +5,3 @@ import type { | ||
| } from '@prisma-next/framework-components/authoring'; | ||
| import type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec'; | ||
| import type { ScalarFieldBuilder, ScalarFieldState } from './contract-dsl'; | ||
@@ -118,5 +119,7 @@ | ||
| ScalarFieldState< | ||
| ResolveTemplateValue<Descriptor['output']['codecId'], Args> extends string | ||
| ? ResolveTemplateValue<Descriptor['output']['codecId'], Args> | ||
| : string, | ||
| ColumnTypeDescriptor< | ||
| ResolveTemplateValue<Descriptor['output']['codecId'], Args> extends string | ||
| ? ResolveTemplateValue<Descriptor['output']['codecId'], Args> | ||
| : string | ||
| >, | ||
| undefined, | ||
@@ -123,0 +126,0 @@ ResolveTemplateValue<Descriptor['output']['nullable'], Args> extends true ? true : false, |
+401
-49
@@ -25,5 +25,12 @@ import { | ||
| import { type CapabilityMatrix, mergeCapabilityMatrices } from '@prisma-next/contract-authoring'; | ||
| import type { CodecLookup } from '@prisma-next/framework-components/codec'; | ||
| import type { | ||
| AuthoringContributions, | ||
| AuthoringEntityTypeDescriptor, | ||
| AuthoringEntityTypeNamespace, | ||
| } from '@prisma-next/framework-components/authoring'; | ||
| import { isAuthoringEntityTypeDescriptor } from '@prisma-next/framework-components/authoring'; | ||
| import type { CodecLookup, ColumnTypeDescriptor } from '@prisma-next/framework-components/codec'; | ||
| import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir'; | ||
| import { sqlContractCanonicalizationHooks } from '@prisma-next/sql-contract/canonicalization-hooks'; | ||
| import { tableEntityKind, valueSetEntityKind } from '@prisma-next/sql-contract/entity-kinds'; | ||
| import { validateIndexTypes } from '@prisma-next/sql-contract/index-type-validation'; | ||
@@ -37,5 +44,4 @@ import { | ||
| applyFkDefaults, | ||
| buildSqlNamespace, | ||
| type CheckConstraintInput, | ||
| type SqlNamespaceTablesInput, | ||
| type SqlNamespaceInput, | ||
| SqlStorage, | ||
@@ -50,2 +56,3 @@ type SqlStorageInput, | ||
| import { validateStorageSemantics } from '@prisma-next/sql-contract/validators'; | ||
| import { deriveValueSetFromEntity } from '@prisma-next/sql-contract/value-set-derivation-hook'; | ||
| import { blindCast } from '@prisma-next/utils/casts'; | ||
@@ -80,2 +87,3 @@ import { ifDefined } from '@prisma-next/utils/defined'; | ||
| codecLookup?: CodecLookup, | ||
| many = false, | ||
| ): ColumnDefault { | ||
@@ -85,2 +93,14 @@ if (defaultInput.kind === 'function') { | ||
| } | ||
| if (many) { | ||
| if (!Array.isArray(defaultInput.value)) { | ||
| throw new Error( | ||
| `Literal default on a list column must be an array; received ${typeof defaultInput.value}. ` + | ||
| 'A scalar default on a list field must be rejected at the authoring surface.', | ||
| ); | ||
| } | ||
| return { | ||
| kind: 'literal', | ||
| value: defaultInput.value.map((element) => encodeViaCodec(element, codecId, codecLookup)), | ||
| }; | ||
| } | ||
| return { | ||
@@ -168,2 +188,172 @@ kind: 'literal', | ||
| /** | ||
| * Resolves a deferred entity-ref column descriptor (e.g. a `pg.enum(handle)` | ||
| * column) against the field's now-known owning namespace: attaches the | ||
| * storage `valueSet` ref the collected entity's derived value-set is stored | ||
| * under. `nativeType` / `typeParams.typeName` stay bare here — schema | ||
| * qualification (e.g. `auth.aal_level`) is a target concern applied in the | ||
| * next step, `qualifyColumnDescriptor`. A descriptor with no `entityRef` (the | ||
| * ordinary case) passes through unchanged. | ||
| */ | ||
| function resolveEntityRefDescriptor( | ||
| descriptor: ColumnTypeDescriptor, | ||
| namespaceId: string, | ||
| ): ColumnTypeDescriptor { | ||
| const entityRef = descriptor.entityRef; | ||
| if (entityRef === undefined) return descriptor; | ||
| return { | ||
| ...descriptor, | ||
| valueSet: { | ||
| plane: 'storage', | ||
| entityKind: 'valueSet', | ||
| namespaceId, | ||
| entityName: entityRef.entityName, | ||
| }, | ||
| }; | ||
| } | ||
| /** | ||
| * A target's contract-construction-time column-type qualifier, contributed | ||
| * through `target.authoring.qualifyColumnType`. Given a column's bare type | ||
| * info and its owning `namespaceId`, it returns the type info the target's | ||
| * schema semantics require (e.g. Postgres schema-qualifies a native-enum | ||
| * column's type name to `auth.aal_level`). The dispatch keys off the codec | ||
| * id, so every codec — including ones needing no change — is passed through | ||
| * and the caller stays codec-blind. Targets without the hook leave every | ||
| * column bare. | ||
| */ | ||
| type ColumnTypeQualifier = ( | ||
| input: { | ||
| readonly codecId: string; | ||
| readonly nativeType: string; | ||
| readonly typeParams?: Record<string, unknown>; | ||
| }, | ||
| namespaceId: string, | ||
| ) => { readonly nativeType: string; readonly typeParams?: Record<string, unknown> }; | ||
| /** | ||
| * Structural check for a target that contributes a `qualifyColumnType` hook | ||
| * on its authoring contributions. Duck-typed (mirroring | ||
| * `contract-psl`'s `hasColumnFromEntityHook`) so the SQL family stays blind | ||
| * to the target's qualification logic and no framework/family interface has | ||
| * to name the hook. | ||
| */ | ||
| function hasColumnTypeQualifier( | ||
| authoring: AuthoringContributions, | ||
| ): authoring is AuthoringContributions & { readonly qualifyColumnType: ColumnTypeQualifier } { | ||
| return 'qualifyColumnType' in authoring && typeof authoring.qualifyColumnType === 'function'; | ||
| } | ||
| function resolveColumnTypeQualifier( | ||
| target: ContractDefinition['target'], | ||
| ): ColumnTypeQualifier | undefined { | ||
| const authoring = target.authoring; | ||
| if (authoring === undefined) return undefined; | ||
| return hasColumnTypeQualifier(authoring) ? authoring.qualifyColumnType : undefined; | ||
| } | ||
| /** | ||
| * Applies the target's `qualifyColumnType` hook to a scalar column descriptor | ||
| * at construction, so the storage column and the domain field (which derives | ||
| * its `type.typeParams` from the storage column) are both built already | ||
| * qualified in a single pass. A descriptor whose codec the target leaves | ||
| * unchanged passes through untouched. | ||
| */ | ||
| function qualifyColumnDescriptor( | ||
| descriptor: ColumnTypeDescriptor, | ||
| namespaceId: string, | ||
| qualify: ColumnTypeQualifier | undefined, | ||
| ): ColumnTypeDescriptor { | ||
| if (qualify === undefined) return descriptor; | ||
| const qualified = qualify( | ||
| { | ||
| codecId: descriptor.codecId, | ||
| nativeType: descriptor.nativeType, | ||
| ...ifDefined('typeParams', descriptor.typeParams), | ||
| }, | ||
| namespaceId, | ||
| ); | ||
| if ( | ||
| qualified.nativeType === descriptor.nativeType && | ||
| qualified.typeParams === descriptor.typeParams | ||
| ) { | ||
| return descriptor; | ||
| } | ||
| return { | ||
| ...descriptor, | ||
| nativeType: qualified.nativeType, | ||
| ...ifDefined('typeParams', qualified.typeParams), | ||
| }; | ||
| } | ||
| type CollectedColumnEntities = Record<string, Record<string, Record<string, unknown>>>; | ||
| /** | ||
| * Records a deferred column's entity-ref into the namespace-scoped collection | ||
| * accumulator (`namespaceId → entityKind → entityName`) — folded into the same | ||
| * namespace assembly `deriveEntityValueSets`/`entries.<kind>` step as the | ||
| * entities-channel attachments, so a column-collected entity gets its | ||
| * value-set the same way an entities-channel one does. | ||
| * | ||
| * The same handle reused by many columns in one namespace is normal (a native | ||
| * enum type backs any number of columns) and records the identical entity once. | ||
| * Two *different* entity instances sharing a name+kind in one namespace is a | ||
| * name collision — the emitted `entries.valueSet.<name>` could only reflect one | ||
| * of them, silently mismatching the other column's type/cast. PSL hard-errors | ||
| * on the equivalent (`PSL_DUPLICATE_DECLARATION`); the TS path rejects it too. | ||
| */ | ||
| function collectEntityFromColumn( | ||
| collected: CollectedColumnEntities, | ||
| namespaceId: string, | ||
| entityRef: NonNullable<ColumnTypeDescriptor['entityRef']>, | ||
| ): void { | ||
| const forNs = collected[namespaceId] ?? {}; | ||
| const forKind = forNs[entityRef.entityKind] ?? {}; | ||
| const existing = forKind[entityRef.entityName]; | ||
| if (existing !== undefined && existing !== entityRef.entity) { | ||
| throw new Error( | ||
| `buildSqlContractFromDefinition: two different "${entityRef.entityKind}" entities named "${entityRef.entityName}" in namespace "${namespaceId}" — pack-entity names must be unique per namespace.`, | ||
| ); | ||
| } | ||
| forKind[entityRef.entityName] = entityRef.entity; | ||
| forNs[entityRef.entityKind] = forKind; | ||
| collected[namespaceId] = forNs; | ||
| } | ||
| /** | ||
| * Merges a namespace's entities-channel attachments (lowered from the | ||
| * `entities` handle list, carried on `ContractDefinition.attachedEntities`) | ||
| * with the entities collected from that namespace's deferred entity-ref | ||
| * columns. A column-collected entity that shadows a *different* attached | ||
| * entity of the same kind+name (or vice-versa) is the same name-collision bug | ||
| * `collectEntityFromColumn` guards against across columns, so it is rejected | ||
| * the same way — by entity identity, so the same handle attached and used by | ||
| * a column does not throw. | ||
| */ | ||
| function mergeColumnAndAttachedEntities( | ||
| namespaceId: string, | ||
| attached: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined, | ||
| columnCollected: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined, | ||
| ): Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined { | ||
| if (attached === undefined) return columnCollected; | ||
| if (columnCollected === undefined) return attached; | ||
| const kinds = new Set([...Object.keys(attached), ...Object.keys(columnCollected)]); | ||
| const result: Record<string, Readonly<Record<string, unknown>>> = {}; | ||
| for (const kind of kinds) { | ||
| const attachedForKind = attached[kind]; | ||
| const columnForKind = columnCollected[kind]; | ||
| for (const [name, entity] of Object.entries(columnForKind ?? {})) { | ||
| const existing = attachedForKind?.[name]; | ||
| if (existing !== undefined && existing !== entity) { | ||
| throw new Error( | ||
| `buildSqlContractFromDefinition: two different "${kind}" entities named "${name}" in namespace "${namespaceId}" — a column-referenced entity conflicts with an attached one; pack-entity names must be unique per namespace.`, | ||
| ); | ||
| } | ||
| } | ||
| result[kind] = { ...attachedForKind, ...columnForKind }; | ||
| } | ||
| return result; | ||
| } | ||
| const JSONB_CODEC_ID = 'pg/jsonb@1'; | ||
@@ -244,16 +434,15 @@ const JSONB_NATIVE_TYPE = 'jsonb'; | ||
| if (field.many) { | ||
| return { | ||
| nativeType: JSONB_NATIVE_TYPE, | ||
| codecId: JSONB_CODEC_ID, | ||
| nullable: field.nullable, | ||
| }; | ||
| } | ||
| const codecId = field.descriptor.codecId; | ||
| const encodedDefault = | ||
| field.default !== undefined | ||
| ? encodeColumnDefault(field.default, codecId, codecLookup) | ||
| ? encodeColumnDefault(field.default, codecId, codecLookup, field.many === true) | ||
| : undefined; | ||
| // `storageValueSetRef` (derived from an `enumTypeHandle`) takes precedence | ||
| // when present — the established domain-enum path. `field.descriptor.valueSet` | ||
| // is the fallback: set by an entity-ref type constructor (e.g. `pg.enum(Ref)`) | ||
| // that resolved the field's type against a value-set-deriving entity with no | ||
| // domain enum involved. A field carries at most one of the two in practice. | ||
| const valueSet = storageValueSetRef ?? field.descriptor.valueSet; | ||
| return { | ||
@@ -263,6 +452,7 @@ nativeType: field.descriptor.nativeType, | ||
| nullable: field.nullable, | ||
| ...(field.many ? { many: true as const } : {}), | ||
| ...ifDefined('typeParams', field.descriptor.typeParams), | ||
| ...ifDefined('default', encodedDefault), | ||
| ...ifDefined('typeRef', field.descriptor.typeRef), | ||
| ...ifDefined('valueSet', storageValueSetRef), | ||
| ...ifDefined('valueSet', valueSet), | ||
| }; | ||
@@ -309,5 +499,118 @@ } | ||
| } | ||
| for (const id of Object.keys(definition.attachedEntities ?? {})) { | ||
| if (id.length > 0) { | ||
| ids.add(id); | ||
| } | ||
| } | ||
| return ids; | ||
| } | ||
| /** | ||
| * Entry kinds the framework assembler itself manages (`table` from models, | ||
| * `valueSet` from `enums` and attached-entity value-set derivation). A | ||
| * pack-attached entity claiming one of these would silently clobber or be | ||
| * clobbered by the managed slot, so it is rejected outright. | ||
| */ | ||
| const MANAGED_ENTRY_KINDS = new Set([tableEntityKind.kind, valueSetEntityKind.kind]); | ||
| function assertNoManagedEntityKinds( | ||
| namespaceId: string, | ||
| entitiesForNs: Readonly<Record<string, unknown>> | undefined, | ||
| ): void { | ||
| if (entitiesForNs === undefined) return; | ||
| for (const kind of Object.keys(entitiesForNs)) { | ||
| if (MANAGED_ENTRY_KINDS.has(kind)) { | ||
| throw new Error( | ||
| `buildSqlContractFromDefinition: attached entity in namespace "${namespaceId}" declares entry kind "${kind}", which is managed by the framework (table/valueSet) and cannot be attached.`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| /** | ||
| * Walks the flat `entityTypes` namespace tree contributed by the target pack | ||
| * and every extension pack, indexing descriptors by their `discriminator` — | ||
| * the same string a pack entity's entries-map key (`entries.<kind>`) uses. | ||
| * Mirrors `contract-psl`'s `buildEntityTypesByDiscriminator`, recomposed here | ||
| * from the packs `ContractDefinition` already carries (`target` + | ||
| * `extensionPacks`) since the TS assembler has no single pre-merged | ||
| * `AuthoringContributions` input to read the way the PSL interpreter does. | ||
| */ | ||
| function collectEntityTypeDescriptorsByDiscriminator( | ||
| definition: ContractDefinition, | ||
| ): ReadonlyMap<string, AuthoringEntityTypeDescriptor> { | ||
| const result = new Map<string, AuthoringEntityTypeDescriptor>(); | ||
| const walk = (namespace: AuthoringEntityTypeNamespace): void => { | ||
| for (const value of Object.values(namespace)) { | ||
| if (isAuthoringEntityTypeDescriptor(value)) { | ||
| result.set(value.discriminator, value); | ||
| } else { | ||
| walk(value); | ||
| } | ||
| } | ||
| }; | ||
| const components = [definition.target, ...Object.values(definition.extensionPacks ?? {})]; | ||
| for (const component of components) { | ||
| const entityTypes = component.authoring?.entityTypes; | ||
| if (entityTypes !== undefined) { | ||
| walk(entityTypes); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Derives value-sets for every pack entity declared in one namespace, | ||
| * reusing the same `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook | ||
| * `contract-psl`'s `lowerExtensionBlocksForNamespace` folds into | ||
| * `entries.valueSet` on the PSL path — so a TS-attached entity (e.g. a | ||
| * native enum) gets its value-set the same way. Entity kinds with no | ||
| * registered descriptor, or whose descriptor output doesn't derive a | ||
| * value-set, contribute nothing. | ||
| */ | ||
| function deriveEntityValueSets( | ||
| entitiesForNs: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined, | ||
| entityTypesByDiscriminator: ReadonlyMap<string, AuthoringEntityTypeDescriptor>, | ||
| ): Record<string, StorageValueSetInput> | undefined { | ||
| if (entitiesForNs === undefined) return undefined; | ||
| let result: Record<string, StorageValueSetInput> | undefined; | ||
| for (const [kind, entitiesByName] of Object.entries(entitiesForNs)) { | ||
| const descriptor = entityTypesByDiscriminator.get(kind); | ||
| if (descriptor === undefined) continue; | ||
| for (const [name, entity] of Object.entries(entitiesByName)) { | ||
| const derivedValueSet = deriveValueSetFromEntity(descriptor.output, entity); | ||
| if (derivedValueSet === undefined) continue; | ||
| result ??= {}; | ||
| result[name] = derivedValueSet; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Merges a namespace's `enumType()`-derived value-sets with its pack-entity- | ||
| * derived value-sets. Both land in the same `entries.valueSet[name]` slot — | ||
| * which drives value-set → codec typing and the domain-enum CHECK — so a | ||
| * same-named entry in both would let one silently overwrite the other and | ||
| * corrupt whichever column resolves against it. The same collision class the | ||
| * `mergeColumnAndAttachedEntities` guard rejects; the PSL path already hard-errors | ||
| * on the equivalent (`interpretPslDocumentToSqlContract`). Reject it here too. | ||
| */ | ||
| function mergeNamespaceValueSets( | ||
| namespaceId: string, | ||
| enumValueSets: Record<string, StorageValueSetInput> | undefined, | ||
| packValueSets: Record<string, StorageValueSetInput> | undefined, | ||
| ): Record<string, StorageValueSetInput> { | ||
| if (enumValueSets !== undefined && packValueSets !== undefined) { | ||
| for (const name of Object.keys(packValueSets)) { | ||
| if (Object.hasOwn(enumValueSets, name)) { | ||
| throw new Error( | ||
| `buildSqlContractFromDefinition: value-set "${name}" in namespace "${namespaceId}" is derived from both an enum and a pack entity — names must be unique per namespace.`, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| return { ...enumValueSets, ...packValueSets }; | ||
| } | ||
| function ensureUnboundNamespaceSlot( | ||
@@ -320,14 +623,11 @@ namespaces: SqlStorageInput['namespaces'], | ||
| } | ||
| const unboundInput: SqlNamespaceTablesInput = { | ||
| const unboundInput: SqlNamespaceInput = { | ||
| id: UNBOUND_NAMESPACE_ID, | ||
| entries: { table: {} }, | ||
| }; | ||
| const unbound = createNamespace ? createNamespace(unboundInput) : buildSqlNamespace(unboundInput); | ||
| return blindCast< | ||
| SqlStorageInput['namespaces'], | ||
| 'createNamespace may return a target namespace concretion; the unbound slot matches SqlNamespace at runtime' | ||
| >({ | ||
| const unbound = createNamespace(unboundInput); | ||
| return { | ||
| [UNBOUND_NAMESPACE_ID]: unbound, | ||
| ...namespaces, | ||
| }); | ||
| }; | ||
| } | ||
@@ -341,2 +641,3 @@ | ||
| const defaultNamespaceId = definition.target.defaultNamespaceId; | ||
| const qualifyColumnType = resolveColumnTypeQualifier(definition.target); | ||
| const targetFamily = 'sql'; | ||
@@ -360,2 +661,3 @@ const resolveNamespaceId = (m: ModelNode): string => | ||
| const modelsByNamespace: Record<string, Record<string, ContractModel>> = {}; | ||
| const collectedColumnEntities: CollectedColumnEntities = {}; | ||
| const rootEntries: Array<{ | ||
@@ -390,2 +692,3 @@ readonly tableName: string; | ||
| const domainFieldRefs: Record<string, DomainFieldRef> = {}; | ||
| const checksForTable: CheckConstraintInput[] = []; | ||
@@ -433,6 +736,54 @@ for (const field of semanticModel.fields) { | ||
| const column = buildStorageColumn(field, storageValueSetRef, codecLookup); | ||
| // A field authored through a deferred entity-ref column helper (e.g. | ||
| // `pg.enum(handle)`) carries `descriptor.entityRef`: the referenced | ||
| // entity is collected into `collectedColumnEntities` (folded into the | ||
| // same `entries.<kind>` + `entries.valueSet` assembly an entities-channel | ||
| // attachment goes through) and the descriptor is resolved | ||
| // against this field's now-known `namespaceId` — the builder call that | ||
| // produced it ran before the enclosing model associated one. The | ||
| // descriptor is then handed to the target's `qualifyColumnType` hook, | ||
| // which schema-qualifies a native-enum column's type name for its | ||
| // namespace. Keying off the codec id (inside the hook) catches both the | ||
| // TS `pg.enum(handle)` path (via `entityRef`) and the PSL `pg.enum(Ref)` | ||
| // path (resolved inline in the interpreter, no `entityRef`). Because the | ||
| // storage column is built from this qualified descriptor and the domain | ||
| // field derives its `type.typeParams` from that column, both come out | ||
| // qualified in this single pass. | ||
| let resolvedField: FieldNode | ValueObjectFieldNode = field; | ||
| if (!isValueObjectField(field)) { | ||
| let descriptor = field.descriptor; | ||
| const entityRef = descriptor.entityRef; | ||
| if (entityRef !== undefined) { | ||
| collectEntityFromColumn(collectedColumnEntities, namespaceId, entityRef); | ||
| descriptor = resolveEntityRefDescriptor(descriptor, namespaceId); | ||
| } | ||
| descriptor = qualifyColumnDescriptor(descriptor, namespaceId, qualifyColumnType); | ||
| if (descriptor !== field.descriptor) { | ||
| resolvedField = { ...field, descriptor }; | ||
| } | ||
| } | ||
| const column = buildStorageColumn(resolvedField, storageValueSetRef, codecLookup); | ||
| columns[field.columnName] = column; | ||
| fieldToColumn[field.fieldName] = field.columnName; | ||
| // A domain enum (`storageValueSetRef`, from an `enumType()` handle) is | ||
| // stored as a plain scalar column (`text`, `int4`, …) with no native | ||
| // type of its own to enforce membership, so it needs an explicit | ||
| // CHECK — scalar or array, since a `text[]` array has no element-level | ||
| // enforcement either. A value set resolved by an entity-ref type | ||
| // constructor (`field.descriptor.valueSet`, e.g. `pg.enum(Ref)`) binds | ||
| // the column to a codec/native-type pairing that IS the storage-level | ||
| // enforcement (a Postgres native enum type, or another target's | ||
| // equivalent) — including array columns, since the target enforces | ||
| // membership on every element of a native-typed array — so no CHECK | ||
| // for those. | ||
| if (column.valueSet !== undefined && storageValueSetRef !== undefined) { | ||
| checksForTable.push({ | ||
| name: `${tableName}_${field.columnName}_check`, | ||
| column: field.columnName, | ||
| valueSet: column.valueSet, | ||
| }); | ||
| } | ||
| domainFields[field.fieldName] = buildDomainField(field, column, domainValueSetRef); | ||
@@ -528,11 +879,2 @@ | ||
| if (!semanticModel.sharesBaseTable) { | ||
| const checksForTable: CheckConstraintInput[] = Object.entries(columns).flatMap( | ||
| ([columnName, col]) => { | ||
| const valueSet = col.valueSet; | ||
| return valueSet === undefined | ||
| ? [] | ||
| : [{ name: `${tableName}_${columnName}_check`, column: columnName, valueSet }]; | ||
| }, | ||
| ); | ||
| const tableInput: StorageTableInput = { | ||
@@ -747,21 +1089,31 @@ columns, | ||
| const { createNamespace } = definition; | ||
| const namespaces = blindCast< | ||
| SqlStorageInput['namespaces'], | ||
| 'contract authoring materialises each namespace coordinate from the model set and explicit namespace list' | ||
| >( | ||
| Object.fromEntries( | ||
| [...namespaceCoordinateIds].sort().map((id) => { | ||
| const valueSetEntries = storageValueSetsByNs[id]; | ||
| const nsInput: SqlNamespaceTablesInput = { | ||
| id, | ||
| entries: { | ||
| table: tablesByNamespace[id] ?? {}, | ||
| ...(valueSetEntries !== undefined && Object.keys(valueSetEntries).length > 0 | ||
| ? { valueSet: valueSetEntries } | ||
| : {}), | ||
| }, | ||
| }; | ||
| return [id, createNamespace ? createNamespace(nsInput) : buildSqlNamespace(nsInput)]; | ||
| }), | ||
| ), | ||
| const entityTypesByDiscriminator = collectEntityTypeDescriptorsByDiscriminator(definition); | ||
| const namespaces: SqlStorageInput['namespaces'] = Object.fromEntries( | ||
| [...namespaceCoordinateIds].sort().map((id) => { | ||
| const entitiesForNs = mergeColumnAndAttachedEntities( | ||
| id, | ||
| definition.attachedEntities?.[id], | ||
| collectedColumnEntities[id], | ||
| ); | ||
| assertNoManagedEntityKinds(id, entitiesForNs); | ||
| const enumValueSetEntries = storageValueSetsByNs[id]; | ||
| const packValueSetEntries = deriveEntityValueSets(entitiesForNs, entityTypesByDiscriminator); | ||
| const valueSetEntries = | ||
| enumValueSetEntries !== undefined || packValueSetEntries !== undefined | ||
| ? mergeNamespaceValueSets(id, enumValueSetEntries, packValueSetEntries) | ||
| : undefined; | ||
| const nsInput: SqlNamespaceInput = { | ||
| id, | ||
| entries: { | ||
| table: tablesByNamespace[id] ?? {}, | ||
| ...entitiesForNs, | ||
| ...(valueSetEntries !== undefined && Object.keys(valueSetEntries).length > 0 | ||
| ? { valueSet: valueSetEntries } | ||
| : {}), | ||
| }, | ||
| }; | ||
| return [id, createNamespace(nsInput)]; | ||
| }), | ||
| ); | ||
@@ -768,0 +1120,0 @@ const storageWithoutHash = { |
@@ -16,5 +16,2 @@ import { | ||
| assertNoCrossRegistryCollisions, | ||
| isAuthoringEntityTypeDescriptor, | ||
| isAuthoringFieldPresetDescriptor, | ||
| isAuthoringTypeConstructorDescriptor, | ||
| mergeAuthoringNamespaces, | ||
@@ -187,3 +184,3 @@ } from '@prisma-next/framework-components/authoring'; | ||
| if (Object.keys(ns).length > 0) { | ||
| mergeAuthoringNamespaces(merged, ns, [], isAuthoringTypeConstructorDescriptor, 'type'); | ||
| mergeAuthoringNamespaces(merged, ns, [], 'typeConstructor', 'type'); | ||
| } | ||
@@ -199,3 +196,3 @@ } | ||
| if (Object.keys(ns).length > 0) { | ||
| mergeAuthoringNamespaces(merged, ns, [], isAuthoringFieldPresetDescriptor, 'field'); | ||
| mergeAuthoringNamespaces(merged, ns, [], 'fieldPreset', 'field'); | ||
| } | ||
@@ -213,3 +210,3 @@ } | ||
| if (Object.keys(ns).length > 0) { | ||
| mergeAuthoringNamespaces(merged, ns, [], isAuthoringEntityTypeDescriptor, 'entity'); | ||
| mergeAuthoringNamespaces(merged, ns, [], 'entity', 'entity'); | ||
| } | ||
@@ -216,0 +213,0 @@ } |
+10
-1
@@ -6,2 +6,3 @@ import { pathToFileURL } from 'node:url'; | ||
| import type { TargetPackRef } from '@prisma-next/framework-components/components'; | ||
| import type { SqlNamespaceBase, SqlNamespaceInput } from '@prisma-next/sql-contract/types'; | ||
| import { ifDefined } from '@prisma-next/utils/defined'; | ||
@@ -31,2 +32,3 @@ import { ok } from '@prisma-next/utils/result'; | ||
| readonly target: TargetPackRef<'sql', string>; | ||
| readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase; | ||
| readonly defaultControlPolicy?: ControlPolicy; | ||
@@ -36,4 +38,9 @@ }): ContractConfig { | ||
| source: { | ||
| sourceFormat: 'typescript', | ||
| load: async () => { | ||
| const built = buildSqlContractFromDefinition({ target: options.target, models: [] }); | ||
| const built = buildSqlContractFromDefinition({ | ||
| target: options.target, | ||
| createNamespace: options.createNamespace, | ||
| models: [], | ||
| }); | ||
| return ok(applySpecifierDefaultControlPolicy(built, options.defaultControlPolicy)); | ||
@@ -53,2 +60,3 @@ }, | ||
| source: { | ||
| sourceFormat: 'typescript', | ||
| load: async () => | ||
@@ -70,2 +78,3 @@ ok(applySpecifierDefaultControlPolicy(contract, options?.defaultControlPolicy)), | ||
| source: { | ||
| sourceFormat: 'typescript', | ||
| inputs: [contractPath], | ||
@@ -72,0 +81,0 @@ load: async (context) => { |
@@ -9,4 +9,8 @@ import type { ControlPolicy } from '@prisma-next/contract/types'; | ||
| } from '@prisma-next/framework-components/components'; | ||
| import type { Namespace } from '@prisma-next/framework-components/ir'; | ||
| import type { SqlNamespaceTablesInput, StorageTypeInstance } from '@prisma-next/sql-contract/types'; | ||
| import type { PackEntityHandle } from '@prisma-next/sql-contract/entity-handle-lowering-hook'; | ||
| import type { | ||
| SqlNamespaceBase, | ||
| SqlNamespaceInput, | ||
| StorageTypeInstance, | ||
| } from '@prisma-next/sql-contract/types'; | ||
| import { blindCast } from '@prisma-next/utils/casts'; | ||
@@ -72,3 +76,3 @@ import { ifDefined } from '@prisma-next/utils/defined'; | ||
| readonly namespaces?: Namespaces; | ||
| readonly createNamespace?: (input: SqlNamespaceTablesInput) => Namespace; | ||
| readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase; | ||
| readonly types?: Types; | ||
@@ -78,2 +82,3 @@ readonly models?: Models; | ||
| readonly enums?: Enums; | ||
| readonly entities?: readonly PackEntityHandle[]; | ||
| }; | ||
@@ -99,3 +104,3 @@ | ||
| readonly namespaces?: Namespaces; | ||
| readonly createNamespace?: (input: SqlNamespaceTablesInput) => Namespace; | ||
| readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase; | ||
| readonly types?: never; | ||
@@ -105,2 +110,3 @@ readonly models?: never; | ||
| readonly enums?: Enums; | ||
| readonly entities?: readonly PackEntityHandle[]; | ||
| }; | ||
@@ -119,2 +125,3 @@ | ||
| readonly enums?: Enums; | ||
| readonly entities?: readonly PackEntityHandle[]; | ||
| }; | ||
@@ -323,3 +330,3 @@ | ||
| readonly namespaces?: Namespaces; | ||
| readonly createNamespace?: (input: SqlNamespaceTablesInput) => Namespace; | ||
| readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase; | ||
| readonly types?: Types; | ||
@@ -329,2 +336,3 @@ readonly models?: Models; | ||
| readonly enums?: Record<string, EnumTypeHandle>; | ||
| readonly entities?: readonly PackEntityHandle[]; | ||
| }; | ||
@@ -398,2 +406,3 @@ | ||
| readonly enums?: Record<string, EnumTypeHandle>; | ||
| readonly entities?: readonly PackEntityHandle[]; | ||
| }, | ||
@@ -424,2 +433,3 @@ >( | ||
| readonly enums?: Record<string, EnumTypeHandle>; | ||
| readonly entities?: readonly PackEntityHandle[]; | ||
| }) | ||
@@ -439,2 +449,3 @@ | undefined, | ||
| const mergedEnums = { ...(definition.enums ?? {}), ...built.enums }; | ||
| const mergedEntities = [...(definition.entities ?? []), ...(built.entities ?? [])]; | ||
| return buildContractFromDsl({ | ||
@@ -445,2 +456,3 @@ ...full, | ||
| ...ifDefined('enums', Object.keys(mergedEnums).length > 0 ? mergedEnums : undefined), | ||
| ...ifDefined('entities', mergedEntities.length > 0 ? mergedEntities : undefined), | ||
| }); | ||
@@ -447,0 +459,0 @@ } |
@@ -9,6 +9,6 @@ import type { | ||
| import type { ExtensionPackRef, TargetPackRef } from '@prisma-next/framework-components/components'; | ||
| import type { Namespace } from '@prisma-next/framework-components/ir'; | ||
| import type { | ||
| ReferentialAction, | ||
| SqlNamespaceTablesInput, | ||
| SqlNamespaceBase, | ||
| SqlNamespaceInput, | ||
| StorageTypeInstance, | ||
@@ -20,2 +20,19 @@ } from '@prisma-next/sql-contract/types'; | ||
| /** | ||
| * Namespace-scoped pack-entity attachments, the internal build IR carrying | ||
| * the lowered `entities` handle list: namespace id → entity kind (the | ||
| * discriminator the target/extension pack registered its | ||
| * `AuthoringContributions.entityTypes` descriptor under, e.g. `native_enum`) | ||
| * → entity name → the lowered entity instance. Generic on purpose — neither | ||
| * the framework nor `contract-ts` names a specific entity kind here; the | ||
| * shape mirrors `SqlNamespaceInput.entries` (`entries.<kind>[name]`), just | ||
| * namespace-nested so an attachment can target any declared namespace | ||
| * (default or named), not only the contract's default namespace. Produced by | ||
| * the generic entity-handle walk in `buildContractDefinition`; never an | ||
| * author-facing input. | ||
| */ | ||
| export type AttachedEntities = Readonly< | ||
| Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>> | ||
| >; | ||
| export interface FieldNode { | ||
@@ -180,4 +197,4 @@ readonly fieldName: string; | ||
| readonly namespaces?: readonly string[]; | ||
| /** Target-supplied factory that materialises a `Namespace` concretion for a declared namespace coordinate. */ | ||
| readonly createNamespace?: (input: SqlNamespaceTablesInput) => Namespace; | ||
| /** Target-supplied factory that materialises a `SqlNamespaceBase` concretion for a declared namespace coordinate. */ | ||
| readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase; | ||
| readonly models: readonly ModelNode[]; | ||
@@ -191,2 +208,13 @@ readonly valueObjects?: readonly ValueObjectNode[]; | ||
| readonly enums?: Record<string, EnumTypeHandle>; | ||
| /** | ||
| * Pack-entity attachments lowered from the `entities` handle list, keyed by | ||
| * namespace then entity kind then name. Each entity lands in | ||
| * `storage.namespaces[ns].entries.<kind>`; when the registered entity-type | ||
| * descriptor's factory output implements the | ||
| * `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook, the derived | ||
| * value-set also folds into `entries.valueSet`, mirroring how `enums` flows | ||
| * there. Internal build IR — populated by `buildContractDefinition`, not an | ||
| * author input. | ||
| */ | ||
| readonly attachedEntities?: AttachedEntities; | ||
| } |
+155
-1
@@ -0,6 +1,16 @@ | ||
| import { | ||
| type AuthoringEntityTypeNamespace, | ||
| isAuthoringEntityTypeDescriptor, | ||
| } from '@prisma-next/framework-components/authoring'; | ||
| import type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec'; | ||
| import type { ExtensionPackRef } from '@prisma-next/framework-components/components'; | ||
| import { | ||
| providesEntityHandleLowering, | ||
| type ResolvedEntityHandleRef, | ||
| type ResolvedPackEntityHandle, | ||
| } from '@prisma-next/sql-contract/entity-handle-lowering-hook'; | ||
| import type { StorageTypeInstance } from '@prisma-next/sql-contract/types'; | ||
| import { ifDefined } from '@prisma-next/utils/defined'; | ||
| import type { | ||
| AttachedEntities, | ||
| ContractDefinition, | ||
@@ -22,2 +32,3 @@ FieldNode, | ||
| type IdConstraint, | ||
| isCrossSpaceHandle, | ||
| type ModelAttributesSpec, | ||
@@ -731,2 +742,3 @@ normalizeRelationFieldNames, | ||
| nullable: fieldState.nullable, | ||
| ...(fieldState.many === true ? { many: true } : {}), | ||
| ...(fieldState.default ? { default: fieldState.default } : {}), | ||
@@ -868,5 +880,146 @@ ...(fieldState.executionDefaults ? { executionDefaults: fieldState.executionDefaults } : {}), | ||
| /** | ||
| * Kind-agnostic walk over the author-declared `entities` handle list: | ||
| * | ||
| * 1. Index the bound packs' `entityTypes` contributions by discriminator so | ||
| * each handle's `entityKind` maps to the pack that registered it; a | ||
| * handle whose kind no composed pack registers is an error naming the | ||
| * kind. | ||
| * 2. Resolve each handle's declared model refs (`handle.refs`, actual | ||
| * model-handle objects) to storage table coordinates — identity against | ||
| * the contract's `models` record first, then the handle's declared model | ||
| * name against the build's model specs; never by re-deriving a table | ||
| * name. A cross-space (extensionModel) handle resolves to its own | ||
| * coordinate annotated with `spaceId`. | ||
| * 3. Call each owning pack's batch lowering hook once with all of its | ||
| * claimed handles, and fold the returned rows into the namespace-scoped | ||
| * attachments (namespace → kind → key), rejecting two different entities | ||
| * in one slot. The result becomes `ContractDefinition.attachedEntities`. | ||
| * | ||
| * No entity kind is named anywhere in this walk. | ||
| */ | ||
| function lowerPackEntityHandles( | ||
| definition: ContractInput, | ||
| modelSpecs: ReadonlyMap<string, RuntimeModelSpec>, | ||
| ): AttachedEntities | undefined { | ||
| const entities = definition.entities; | ||
| if (entities === undefined || entities.length === 0) return undefined; | ||
| const components: readonly { | ||
| readonly authoring?: import('@prisma-next/framework-components/authoring').AuthoringContributions; | ||
| }[] = [ | ||
| definition.target, | ||
| ...Object.values<ExtensionPackRef<'sql', string>>(definition.extensionPacks ?? {}), | ||
| ]; | ||
| const owningComponent = new Map<string, (typeof components)[number]>(); | ||
| const walkEntityTypes = ( | ||
| namespace: AuthoringEntityTypeNamespace, | ||
| component: (typeof components)[number], | ||
| ): void => { | ||
| for (const value of Object.values(namespace)) { | ||
| if (isAuthoringEntityTypeDescriptor(value)) { | ||
| owningComponent.set(value.discriminator, component); | ||
| } else { | ||
| walkEntityTypes(value, component); | ||
| } | ||
| } | ||
| }; | ||
| for (const component of components) { | ||
| const entityTypes = component.authoring?.entityTypes; | ||
| if (entityTypes !== undefined) walkEntityTypes(entityTypes, component); | ||
| } | ||
| const defaultNamespaceId = definition.target.defaultNamespaceId; | ||
| const modelNamesByIdentity = new Map<unknown, string>(); | ||
| for (const [modelName, modelBuilder] of Object.entries(definition.models ?? {})) { | ||
| modelNamesByIdentity.set(modelBuilder, modelName); | ||
| } | ||
| const coordinateOf = (modelName: string): ResolvedEntityHandleRef | undefined => { | ||
| const spec = modelSpecs.get(modelName); | ||
| if (spec === undefined) return undefined; | ||
| return { | ||
| kind: 'resolved', | ||
| namespaceId: spec.namespace ?? defaultNamespaceId, | ||
| tableName: spec.tableName, | ||
| modelName, | ||
| }; | ||
| }; | ||
| const declaredModelName = (value: unknown): string | undefined => { | ||
| if (typeof value !== 'object' || value === null || !('stageOne' in value)) return undefined; | ||
| const stageOne = value.stageOne; | ||
| if (typeof stageOne !== 'object' || stageOne === null || !('modelName' in stageOne)) { | ||
| return undefined; | ||
| } | ||
| return typeof stageOne.modelName === 'string' ? stageOne.modelName : undefined; | ||
| }; | ||
| const resolveRef = (value: unknown): ResolvedEntityHandleRef => { | ||
| const modelName = declaredModelName(value); | ||
| if (isCrossSpaceHandle(value)) { | ||
| const tableName = value.tableName; | ||
| const namespaceId = value.stageOne.namespace; | ||
| if (tableName !== undefined && namespaceId !== undefined) { | ||
| return { | ||
| kind: 'cross-space', | ||
| spaceId: value.spaceId, | ||
| namespaceId, | ||
| tableName, | ||
| ...ifDefined('modelName', modelName), | ||
| }; | ||
| } | ||
| return { kind: 'unresolved', ...ifDefined('modelName', modelName) }; | ||
| } | ||
| const identityName = modelNamesByIdentity.get(value); | ||
| const resolved = | ||
| (identityName !== undefined ? coordinateOf(identityName) : undefined) ?? | ||
| (modelName !== undefined ? coordinateOf(modelName) : undefined); | ||
| return resolved ?? { kind: 'unresolved', ...ifDefined('modelName', modelName) }; | ||
| }; | ||
| const claimed = new Map<(typeof components)[number], ResolvedPackEntityHandle[]>(); | ||
| for (const handle of entities) { | ||
| const component = owningComponent.get(handle.entityKind); | ||
| if (component === undefined) { | ||
| throw new Error( | ||
| `defineContract: entities contains a handle with entityKind "${handle.entityKind}", which no composed pack registers. Compose a pack whose entityTypes contribution claims "${handle.entityKind}", or remove the handle.`, | ||
| ); | ||
| } | ||
| const refs: Record<string, ResolvedEntityHandleRef> = {}; | ||
| for (const [refName, refValue] of Object.entries(handle.refs ?? {})) { | ||
| refs[refName] = resolveRef(refValue); | ||
| } | ||
| const forComponent = claimed.get(component) ?? []; | ||
| forComponent.push({ handle, refs }); | ||
| claimed.set(component, forComponent); | ||
| } | ||
| const pack: Record<string, Record<string, Record<string, unknown>>> = {}; | ||
| for (const [component, handles] of claimed) { | ||
| const authoring = component.authoring; | ||
| if (!providesEntityHandleLowering(authoring)) { | ||
| const kinds = [...new Set(handles.map((entry) => entry.handle.entityKind))].sort(); | ||
| throw new Error( | ||
| `defineContract: entityKind(s) ${kinds.map((kind) => `"${kind}"`).join(', ')} are registered by a pack that does not implement entity-handle lowering (no lowerEntityHandles on its authoring contributions).`, | ||
| ); | ||
| } | ||
| for (const row of authoring.lowerEntityHandles({ handles, defaultNamespaceId })) { | ||
| const forNamespace = pack[row.namespaceId] ?? {}; | ||
| pack[row.namespaceId] = forNamespace; | ||
| const forKind = forNamespace[row.entityKind] ?? {}; | ||
| forNamespace[row.entityKind] = forKind; | ||
| const existing = forKind[row.key]; | ||
| if (existing !== undefined && existing !== row.entity) { | ||
| throw new Error( | ||
| `defineContract: two different "${row.entityKind}" entities named "${row.key}" in namespace "${row.namespaceId}" — pack-entity names must be unique per namespace.`, | ||
| ); | ||
| } | ||
| forKind[row.key] = row.entity; | ||
| } | ||
| } | ||
| return pack; | ||
| } | ||
| export function buildContractDefinition(definition: ContractInput): ContractDefinition { | ||
| const collection = collectRuntimeModelSpecs(definition); | ||
| const models = lowerModels(collection, definition.extensionPacks); | ||
| const attachedEntities = lowerPackEntityHandles(definition, collection.modelSpecs); | ||
@@ -883,8 +1036,9 @@ return { | ||
| ...(definition.namespaces ? { namespaces: definition.namespaces } : {}), | ||
| ...(definition.createNamespace ? { createNamespace: definition.createNamespace } : {}), | ||
| createNamespace: definition.createNamespace, | ||
| ...(definition.enums && Object.keys(definition.enums).length > 0 | ||
| ? { enums: definition.enums } | ||
| : {}), | ||
| ...(attachedEntities && Object.keys(attachedEntities).length > 0 ? { attachedEntities } : {}), | ||
| models, | ||
| }; | ||
| } |
+70
-13
@@ -24,6 +24,6 @@ import type { | ||
| export type ExtractCodecTypesFromPack<P> = P extends { __codecTypes?: infer C } | ||
| ? C extends Record<string, { output: unknown }> | ||
| ? C | ||
| : Record<string, never> | ||
| export type ExtractCodecTypesFromPack<P> = P extends { | ||
| __codecTypes?: infer C extends Record<string, { output: unknown }>; | ||
| } | ||
| ? C | ||
| : Record<string, never>; | ||
@@ -283,2 +283,4 @@ | ||
| type FieldManyOf<FieldState> = FieldState extends { readonly many?: true } ? true : false; | ||
| type FieldColumnOverrideOf<FieldState> = Present< | ||
@@ -476,2 +478,3 @@ FieldState extends { readonly columnName?: infer ColumnName } ? ColumnName : never | ||
| TypeParams extends Record<string, unknown> | undefined = undefined, | ||
| Many extends boolean = false, | ||
| > = { | ||
@@ -482,6 +485,7 @@ readonly nativeType: NativeType; | ||
| readonly default?: ColumnDefault; | ||
| } & (TypeRef extends string ? { readonly typeRef: TypeRef } : Record<string, never>) & | ||
| } & (TypeRef extends string ? { readonly typeRef: TypeRef } : Record<never, never>) & | ||
| (TypeParams extends Record<string, unknown> | ||
| ? { readonly typeParams: TypeParams } | ||
| : Record<string, never>); | ||
| : Record<never, never>) & | ||
| (Many extends true ? { readonly many: true } : Record<never, never>); | ||
@@ -503,3 +507,4 @@ type ModelStorageColumn< | ||
| ResolveFieldColumnTypeRef<Definition, ModelFieldState<Definition, ModelName, FieldName>>, | ||
| ResolveFieldColumnTypeParams<Definition, ModelFieldState<Definition, ModelName, FieldName>> | ||
| ResolveFieldColumnTypeParams<Definition, ModelFieldState<Definition, ModelName, FieldName>>, | ||
| FieldManyOf<ModelFieldState<Definition, ModelName, FieldName>> | ||
| > | ||
@@ -685,2 +690,4 @@ : never; | ||
| type StorageColumnManyOf<Col> = Col extends { readonly many: true } ? true : false; | ||
| // The enum value union for an enum-typed field, or `never` for a non-enum | ||
@@ -697,2 +704,27 @@ // field. The field's `typeRef` carries the authored `EnumTypeHandle`, whose | ||
| // The member-value literal tuple carried on a descriptor's `entityRef.entity` | ||
| // (e.g. a target's native-enum entity), or `never` when the descriptor has no | ||
| // entityRef, its entity has no `members`, or `members` is widened to | ||
| // `readonly string[]` — this is checked with non-optional property shapes so | ||
| // a descriptor genuinely lacking `entityRef` fails the structural match | ||
| // instead of matching vacuously through the framework type's optional slot. | ||
| type DescriptorEntityMembers<Descriptor> = Descriptor extends { | ||
| readonly entityRef: { | ||
| readonly entity: { readonly members: infer Members extends readonly string[] }; | ||
| }; | ||
| } | ||
| ? Members | ||
| : never; | ||
| // The value-set member union for a descriptor-carried entity (the type-level | ||
| // mirror of the runtime's generic `deriveValueSetFromEntity` fold), or | ||
| // `never` for a field with no descriptor, a descriptor with no entityRef.entity, | ||
| // or a widened (non-literal) members tuple — mirroring `EnumValueUnion`'s | ||
| // erasure guard. | ||
| type DescriptorValueSetUnion<FieldState> = [FieldDescriptorOf<FieldState>] extends [never] | ||
| ? never | ||
| : readonly string[] extends DescriptorEntityMembers<FieldDescriptorOf<FieldState>> | ||
| ? never | ||
| : DescriptorEntityMembers<FieldDescriptorOf<FieldState>>[number]; | ||
| // The codec's `output` / `input` JS type for a field's column, before | ||
@@ -708,8 +740,18 @@ // nullability. `unknown` when the codec is not in the definition's codec map. | ||
| ? CodecTypesFromDefinition<Definition>[Id] extends { readonly [K in Channel]: infer T } | ||
| ? T | ||
| ? StorageColumnManyOf<ModelStorageColumn<Definition, ModelName, FieldName>> extends true | ||
| ? ReadonlyArray<T> | ||
| : T | ||
| : unknown | ||
| : unknown; | ||
| // A field's read/write JS type: the enum value union when the field is | ||
| // enum-typed, otherwise the codec channel type, with column nullability applied. | ||
| // The literal value union for a field: the enum-typed union takes precedence | ||
| // (matching today's behavior), falling back to the descriptor-carried | ||
| // value-set union; `never` when neither applies. | ||
| type FieldValueUnion<FieldState> = [EnumValueUnion<FieldState>] extends [never] | ||
| ? DescriptorValueSetUnion<FieldState> | ||
| : EnumValueUnion<FieldState>; | ||
| // A field's read/write JS type: the value union (enum or descriptor value-set) | ||
| // when the field carries one, otherwise the codec channel type, with column | ||
| // nullability applied. | ||
| type FieldChannelType< | ||
@@ -721,5 +763,7 @@ Definition, | ||
| > = | ||
| | ([EnumValueUnion<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] | ||
| | ([FieldValueUnion<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] | ||
| ? CodecChannelType<Definition, ModelName, FieldName, Channel> | ||
| : EnumValueUnion<ModelFieldState<Definition, ModelName, FieldName>>) | ||
| : StorageColumnManyOf<ModelStorageColumn<Definition, ModelName, FieldName>> extends true | ||
| ? ReadonlyArray<FieldValueUnion<ModelFieldState<Definition, ModelName, FieldName>>> | ||
| : FieldValueUnion<ModelFieldState<Definition, ModelName, FieldName>>) | ||
| | (FieldNullableOf<ModelFieldState<Definition, ModelName, FieldName>> extends true | ||
@@ -747,2 +791,13 @@ ? null | ||
| type StorageColumnChannelTypes<Definition, Channel extends 'output' | 'input'> = { | ||
| readonly [Ns in DefaultStorageNamespaceId<Definition>]: { | ||
| readonly [ModelName in ModelNames<Definition> as BuiltModelTableName<Definition, ModelName>]: { | ||
| readonly [FieldName in ModelFieldNames<Definition, ModelName> as BuiltModelColumnMappings< | ||
| Definition, | ||
| ModelName | ||
| >[FieldName]['column']]: FieldChannelType<Definition, ModelName, FieldName, Channel>; | ||
| }; | ||
| }; | ||
| }; | ||
| export type SqlContractResult<Definition> = ContractWithTypeMaps< | ||
@@ -767,4 +822,6 @@ Omit<Contract<BuiltStorage<Definition>>, 'domain'> & { | ||
| FieldChannelTypes<Definition, 'output'>, | ||
| FieldChannelTypes<Definition, 'input'> | ||
| FieldChannelTypes<Definition, 'input'>, | ||
| StorageColumnChannelTypes<Definition, 'output'>, | ||
| StorageColumnChannelTypes<Definition, 'input'> | ||
| > | ||
| >; |
+14
-306
@@ -1,306 +0,14 @@ | ||
| import type { ColumnTypeDescriptor } from '@prisma-next/framework-components/codec'; | ||
| import { blindCast } from '@prisma-next/utils/casts'; | ||
| // --------------------------------------------------------------------------- | ||
| // EnumMember — a single member declaration with literal type preservation | ||
| // --------------------------------------------------------------------------- | ||
| /** | ||
| * A single enum member produced by `member()`. The `Name` and `Value` generics | ||
| * are preserved as literal types so `enumType()` can carry the ordered value | ||
| * tuple in its return type. `Value` is whatever the codec dictates — its type | ||
| * is constrained at `enumType` against the codec's input type, not here. | ||
| */ | ||
| export interface EnumMember<Name extends string, Value> { | ||
| readonly name: Name; | ||
| readonly value: Value; | ||
| } | ||
| /** | ||
| * Declare an enum member. The `value` defaults to `name` when omitted. The | ||
| * value is an unconstrained literal here; `enumType` constrains it against the | ||
| * codec's input type. Both generics are preserved as literals so downstream | ||
| * `enumType` carries the value union in its type; the value is serialized to its | ||
| * codec string form only at lowering. | ||
| */ | ||
| export function member<const Name extends string>(name: Name): EnumMember<Name, Name>; | ||
| export function member<const Name extends string, const Value>( | ||
| name: Name, | ||
| value: Value, | ||
| ): EnumMember<Name, Value>; | ||
| export function member<const Name extends string, const Value = Name>( | ||
| name: Name, | ||
| value?: Value, | ||
| ): EnumMember<Name, Value> { | ||
| return { | ||
| name, | ||
| value: blindCast< | ||
| Value, | ||
| 'overload signatures enforce Value=Name when value is omitted; default generic Value=Name makes this safe' | ||
| >(value ?? name), | ||
| }; | ||
| } | ||
| // --------------------------------------------------------------------------- | ||
| // Internal types for inferring the literal tuple from the members spread | ||
| // --------------------------------------------------------------------------- | ||
| type MembersToValues<Members extends readonly EnumMember<string, unknown>[]> = { | ||
| readonly [K in keyof Members]: Members[K] extends EnumMember<string, infer V> ? V : never; | ||
| }; | ||
| type MembersToNames<Members extends readonly EnumMember<string, unknown>[]> = { | ||
| readonly [K in keyof Members]: Members[K] extends EnumMember<infer N, unknown> ? N : never; | ||
| }; | ||
| type MembersAccessorMap<Members extends readonly EnumMember<string, unknown>[]> = { | ||
| readonly [M in Members[number] as M['name']]: M['value']; | ||
| }; | ||
| // --------------------------------------------------------------------------- | ||
| // EnumTypeHandle — the authoring handle returned by enumType() | ||
| // --------------------------------------------------------------------------- | ||
| /** | ||
| * Internal brand that identifies an EnumTypeHandle in the lowering pipeline. | ||
| * Not exported — callers only interact with `EnumTypeHandle`. | ||
| */ | ||
| export const ENUM_TYPE_HANDLE_BRAND = Symbol('EnumTypeHandle'); | ||
| /** | ||
| * Authoring handle returned by `enumType()`. Carries: | ||
| * | ||
| * - The ordered literal value tuple (`.values`) and name tuple (`.names`) | ||
| * so downstream type-tests can assert literal preservation. | ||
| * - A namespaced member accessor map (`.members`) to avoid collisions with | ||
| * `.values` / `.has` / `.nameOf` / `.ordinalOf`. | ||
| * - Runtime helpers `.has()`, `.nameOf()`, `.ordinalOf()`. | ||
| * - Internal metadata (`enumName`, `codecId`, `nativeType`, | ||
| * `enumMembers`) for the lowering pipeline. | ||
| * | ||
| * The type is generic over the ordered value tuple so callers that assign | ||
| * `const Role = enumType(...)` retain the literal tuple on `.values`. | ||
| */ | ||
| export interface EnumTypeHandle< | ||
| Name extends string = string, | ||
| Values extends readonly unknown[] = readonly unknown[], | ||
| Names extends readonly string[] = readonly string[], | ||
| MembersMap extends Record<string, unknown> = Record<string, unknown>, | ||
| > { | ||
| /** Internal brand for lowering-pipeline detection. */ | ||
| readonly [ENUM_TYPE_HANDLE_BRAND]: true; | ||
| /** The enum's declared name (used as the key in domain `enum` / storage `valueSet`). */ | ||
| readonly enumName: Name; | ||
| /** codecId from the codec passed to `enumType`. */ | ||
| readonly codecId: string; | ||
| /** nativeType from the codec passed to `enumType`. */ | ||
| readonly nativeType: string; | ||
| /** Ordered member list for lowering (name + value pairs). */ | ||
| readonly enumMembers: readonly { readonly name: string; readonly value: Values[number] }[]; | ||
| /** Ordered literal value tuple. Declaration order is preserved. */ | ||
| readonly values: Values; | ||
| /** Ordered literal name tuple. Declaration order is preserved. */ | ||
| readonly names: Names; | ||
| /** | ||
| * Namespaced accessor map: `Role.members.User === 'user'`. | ||
| * Namespaced under `.members` to avoid collisions with `.values` / `.has`. | ||
| */ | ||
| readonly members: MembersMap; | ||
| /** Returns `true` if `v` is a declared member value. */ | ||
| has(v: Values[number]): boolean; | ||
| /** Returns the member name for a value, or `undefined` if not found. */ | ||
| nameOf(v: Values[number]): string | undefined; | ||
| /** Returns the zero-based declaration index of a value, or `-1` if not found. */ | ||
| ordinalOf(v: Values[number]): number; | ||
| } | ||
| // --------------------------------------------------------------------------- | ||
| // enumType() | ||
| // --------------------------------------------------------------------------- | ||
| /** | ||
| * A codec typemap: codecId → `{ input, output }`, the same shape the query | ||
| * lanes consume (e.g. `{ 'pg/text@1': { input: string }, 'pg/int4@1': { input: number } }`). | ||
| * The bound `enumType` wrappers supply the target pack's typemap; the core | ||
| * defaults to an empty map (no codec is known), so member values stay | ||
| * unconstrained. | ||
| */ | ||
| export type CodecTypeMap = Record<string, { readonly input?: unknown }>; | ||
| /** | ||
| * The application input type the codec dictates for an enum's member values: | ||
| * looks `Codec['codecId']` up in the supplied codec typemap. When the codecId | ||
| * isn't in the map (the core's empty default, or an unknown codec) the input is | ||
| * unconstrained, so any member-value literal is accepted and inferred verbatim. | ||
| */ | ||
| export type CodecInput< | ||
| CodecTypes extends CodecTypeMap, | ||
| Codec extends { readonly codecId: string }, | ||
| > = Codec['codecId'] extends keyof CodecTypes | ||
| ? CodecTypes[Codec['codecId']] extends { readonly input: infer In } | ||
| ? In | ||
| : unknown | ||
| : unknown; | ||
| /** | ||
| * Declare a domain enum for use in TS-authoring contracts. | ||
| * | ||
| * - The codec is an explicit required argument — the `codecId` and | ||
| * `nativeType` are taken from the passed `ColumnTypeDescriptor` (e.g. | ||
| * `{ codecId: 'pg/text@1', nativeType: 'text' }` from a field preset | ||
| * output or a direct inline object). | ||
| * - `const` generics on the members spread preserve the ordered literal | ||
| * value tuple so `Role.values` is `readonly ['user','admin']`, not | ||
| * `string[]`. | ||
| * - Well-formedness assertions at construction: non-empty member list; | ||
| * unique names; unique values. | ||
| * | ||
| * The returned handle wires into `field.namedType(handle)` to set | ||
| * `valueSet` refs on both the domain field and the storage column. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const Role = enumType('Role', { codecId: 'pg/text@1', nativeType: 'text' }, | ||
| * member('User', 'user'), | ||
| * member('Admin', 'admin'), | ||
| * ); | ||
| * // Role.values → readonly ['user', 'admin'] | ||
| * // Role.members.User → 'user' | ||
| * ``` | ||
| */ | ||
| export function enumType< | ||
| CodecTypes extends CodecTypeMap = Record<string, never>, | ||
| const Name extends string = string, | ||
| const Codec extends Pick<ColumnTypeDescriptor, 'codecId' | 'nativeType'> = Pick< | ||
| ColumnTypeDescriptor, | ||
| 'codecId' | 'nativeType' | ||
| >, | ||
| const Members extends readonly [ | ||
| EnumMember<string, CodecInput<CodecTypes, Codec>>, | ||
| ...EnumMember<string, CodecInput<CodecTypes, Codec>>[], | ||
| ] = readonly [EnumMember<string, CodecInput<CodecTypes, Codec>>], | ||
| >( | ||
| name: Name, | ||
| codec: Codec, | ||
| ...members: Members | ||
| ): EnumTypeHandle< | ||
| Name, | ||
| MembersToValues<[...Members]>, | ||
| MembersToNames<[...Members]>, | ||
| MembersAccessorMap<[...Members]> | ||
| >; | ||
| export function enumType( | ||
| name: string, | ||
| codec: Pick<ColumnTypeDescriptor, 'codecId' | 'nativeType'>, | ||
| ...members: EnumMember<string, unknown>[] | ||
| ): EnumTypeHandle; | ||
| export function enumType( | ||
| name: string, | ||
| codec: Pick<ColumnTypeDescriptor, 'codecId' | 'nativeType'>, | ||
| ...members: EnumMember<string, unknown>[] | ||
| ): EnumTypeHandle { | ||
| if (members.length === 0) { | ||
| throw new Error(`enumType("${name}"): must have at least one member.`); | ||
| } | ||
| const seenNames = new Set<string>(); | ||
| const seenValues = new Set<string>(); | ||
| for (const m of members) { | ||
| if (seenNames.has(m.name)) { | ||
| throw new Error( | ||
| `enumType("${name}"): duplicate member name "${m.name}". Member names must be unique.`, | ||
| ); | ||
| } | ||
| seenNames.add(m.name); | ||
| const loweredValue = String(m.value); | ||
| if (seenValues.has(loweredValue)) { | ||
| throw new Error( | ||
| `enumType("${name}"): duplicate member value "${loweredValue}". Member values must be unique.`, | ||
| ); | ||
| } | ||
| seenValues.add(loweredValue); | ||
| } | ||
| const values = Object.freeze(members.map((m) => m.value)); | ||
| const names = Object.freeze(members.map((m) => m.name)); | ||
| const enumMembers = Object.freeze(members.map((m) => ({ name: m.name, value: m.value }))); | ||
| const membersAccessor = Object.freeze(Object.fromEntries(members.map((m) => [m.name, m.value]))); | ||
| const valueSet = new Set(values); | ||
| const valueToName = new Map(members.map((m) => [m.value, m.name])); | ||
| const valueToOrdinal = new Map(values.map((v, i) => [v, i])); | ||
| return { | ||
| [ENUM_TYPE_HANDLE_BRAND]: true, | ||
| enumName: name, | ||
| codecId: codec.codecId, | ||
| nativeType: codec.nativeType, | ||
| enumMembers, | ||
| values, | ||
| names, | ||
| members: membersAccessor, | ||
| has: (v: unknown) => valueSet.has(v), | ||
| nameOf: (v: unknown) => valueToName.get(v), | ||
| ordinalOf: (v: unknown) => valueToOrdinal.get(v) ?? -1, | ||
| }; | ||
| } | ||
| /** | ||
| * The signature of an `enumType` whose codec typemap is already bound — the | ||
| * shape a target-bound wrapper (e.g. `@prisma-next/postgres/contract-builder`) | ||
| * exposes. The member values are constrained to the codec's input type drawn | ||
| * from `CodecTypes` (so a `pg/text@1` codec rejects numeric members, etc.), | ||
| * while `Name`, `Codec`, and the member tuple still infer from the call. | ||
| */ | ||
| export type BoundEnumType<CodecTypes extends CodecTypeMap> = < | ||
| const Name extends string, | ||
| const Codec extends Pick<ColumnTypeDescriptor, 'codecId' | 'nativeType'>, | ||
| const Members extends readonly [ | ||
| EnumMember<string, CodecInput<CodecTypes, Codec>>, | ||
| ...EnumMember<string, CodecInput<CodecTypes, Codec>>[], | ||
| ], | ||
| >( | ||
| name: Name, | ||
| codec: Codec, | ||
| ...members: Members | ||
| ) => EnumTypeHandle< | ||
| Name, | ||
| MembersToValues<[...Members]>, | ||
| MembersToNames<[...Members]>, | ||
| MembersAccessorMap<[...Members]> | ||
| >; | ||
| /** | ||
| * Bind `enumType` to a target's codec typemap. The returned function is the | ||
| * same runtime `enumType`, retyped so member values are constrained to the | ||
| * codec's input type. Target packages call this with their pack's | ||
| * `ExtractCodecTypesFromPack<Pack>` to expose a codec-aware `enumType`. | ||
| */ | ||
| export function bindEnumType<CodecTypes extends CodecTypeMap>(): BoundEnumType<CodecTypes> { | ||
| return enumType; | ||
| } | ||
| /** | ||
| * Returns true when the value is an `EnumTypeHandle` produced by | ||
| * `enumType()`. Used in the lowering pipeline to detect enum handles | ||
| * in field state without importing the BRAND symbol at every call site. | ||
| */ | ||
| export function isEnumTypeHandle(value: unknown): value is EnumTypeHandle { | ||
| return ( | ||
| typeof value === 'object' && | ||
| value !== null && | ||
| Reflect.get(value, ENUM_TYPE_HANDLE_BRAND) === true | ||
| ); | ||
| } | ||
| export type { | ||
| BoundEnumType, | ||
| CodecInput, | ||
| CodecTypeMap, | ||
| EnumMember, | ||
| EnumTypeHandle, | ||
| } from '@prisma-next/contract-authoring'; | ||
| export { | ||
| bindEnumType, | ||
| ENUM_TYPE_HANDLE_BRAND, | ||
| enumType, | ||
| isEnumTypeHandle, | ||
| member, | ||
| } from '@prisma-next/contract-authoring'; |
@@ -19,2 +19,3 @@ export type { | ||
| export type { | ||
| AttachedEntities, | ||
| ContractDefinition, | ||
@@ -30,2 +31,3 @@ FieldNode, | ||
| export type { TargetFieldRef } from '../contract-dsl'; | ||
| export { buildContractDefinition } from '../contract-lowering'; | ||
| export type { ExtractCodecTypesFromPack } from '../contract-types'; | ||
@@ -32,0 +34,0 @@ export type { |
| import { blindCast } from "@prisma-next/utils/casts"; | ||
| import { ifDefined } from "@prisma-next/utils/defined"; | ||
| import { computeExecutionHash, computeProfileHash, computeStorageHash } from "@prisma-next/contract/hashing"; | ||
| import { asNamespaceId, coreHash, crossRef } from "@prisma-next/contract/types"; | ||
| import { mergeCapabilityMatrices } from "@prisma-next/contract-authoring"; | ||
| import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir"; | ||
| import { sqlContractCanonicalizationHooks } from "@prisma-next/sql-contract/canonicalization-hooks"; | ||
| import { validateIndexTypes } from "@prisma-next/sql-contract/index-type-validation"; | ||
| import { createIndexTypeRegistry } from "@prisma-next/sql-contract/index-types"; | ||
| import { SqlStorage, applyFkDefaults, buildSqlNamespace, toStorageTypeInstance } from "@prisma-next/sql-contract/types"; | ||
| import { validateStorageSemantics } from "@prisma-next/sql-contract/validators"; | ||
| //#region src/build-contract.ts | ||
| function encodeViaCodec(value, codecId, codecLookup) { | ||
| const codec = codecLookup?.get(codecId); | ||
| if (codec) return codec.encodeJson(value); | ||
| return blindCast(value); | ||
| } | ||
| function encodeColumnDefault(defaultInput, codecId, codecLookup) { | ||
| if (defaultInput.kind === "function") return { | ||
| kind: "function", | ||
| expression: defaultInput.expression | ||
| }; | ||
| return { | ||
| kind: "literal", | ||
| value: encodeViaCodec(defaultInput.value, codecId, codecLookup) | ||
| }; | ||
| } | ||
| function assertStorageSemantics(definition, contract) { | ||
| const semanticErrors = validateStorageSemantics(contract.storage); | ||
| if (semanticErrors.length > 0) throw new Error(`Contract semantic validation failed: ${semanticErrors.join("; ")}`); | ||
| const indexTypeRegistry = createIndexTypeRegistry(); | ||
| const packsToRegister = [definition.target, ...Object.values(definition.extensionPacks ?? {})]; | ||
| for (const pack of packsToRegister) { | ||
| const registration = pack.indexTypes; | ||
| if (registration === void 0) continue; | ||
| if (typeof registration !== "object" || registration === null || !Array.isArray(registration.entries)) throw new Error(`Pack "${pack.id ?? "<unknown>"}" declares "indexTypes" but its value is not an IndexTypeRegistration (expected an object with an "entries" array; got ${typeof registration}).`); | ||
| for (const entry of registration.entries) indexTypeRegistry.register(entry); | ||
| } | ||
| validateIndexTypes(contract, indexTypeRegistry); | ||
| } | ||
| function assertKnownTargetModel(modelsByName, modelsByCoordinate, sourceModelName, targetModelName, targetNamespaceId, context) { | ||
| const targetModel = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? modelsByCoordinate.get(`${targetNamespaceId}:${targetModelName}`) : modelsByName.get(targetModelName); | ||
| if (!targetModel) { | ||
| const qualified = targetNamespaceId !== void 0 && targetNamespaceId.length > 0 ? `${targetNamespaceId}.${targetModelName}` : targetModelName; | ||
| throw new Error(`${context} on model "${sourceModelName}" references unknown model "${qualified}"`); | ||
| } | ||
| return targetModel; | ||
| } | ||
| function assertTargetTableMatches(sourceModelName, targetModel, referencedTableName, context) { | ||
| if (targetModel.tableName !== referencedTableName) throw new Error(`${context} on model "${sourceModelName}" references table "${referencedTableName}" but model "${targetModel.modelName}" maps to "${targetModel.tableName}"`); | ||
| } | ||
| function isValueObjectField(field) { | ||
| return "valueObjectName" in field; | ||
| } | ||
| const JSONB_CODEC_ID = "pg/jsonb@1"; | ||
| const JSONB_NATIVE_TYPE = "jsonb"; | ||
| function resolveModelNamespaceId(model, modelNameToNamespaceId, defaultNamespaceId) { | ||
| if (model.namespaceId !== void 0 && model.namespaceId.length > 0) return model.namespaceId; | ||
| return modelNameToNamespaceId.get(model.modelName) ?? defaultNamespaceId; | ||
| } | ||
| function buildThroughDescriptor(through, tableNamespaceByName, targetModel, modelName, fieldName, defaultNamespaceId) { | ||
| if (!tableNamespaceByName.has(through.table)) throw new Error(`buildSqlContractFromDefinition: junction table "${through.table}" for relation "${modelName}.${fieldName}" is not a declared model.`); | ||
| const namespaceId = through.namespaceId ?? defaultNamespaceId; | ||
| return { | ||
| table: through.table, | ||
| namespaceId, | ||
| parentColumns: through.parentColumns, | ||
| childColumns: through.childColumns, | ||
| targetColumns: targetColumnsForJunction(targetModel, fieldName) | ||
| }; | ||
| } | ||
| function targetColumnsForJunction(targetModel, fieldName) { | ||
| const primaryKeyColumns = targetModel.id?.columns; | ||
| if (primaryKeyColumns && primaryKeyColumns.length > 0) return primaryKeyColumns; | ||
| const firstUnique = targetModel.uniques?.find((u) => u.columns.length > 0); | ||
| if (firstUnique) return firstUnique.columns; | ||
| throw new Error(`M:N target model "${targetModel.modelName}" (relation field "${fieldName}") has no primary id or unique key to derive junction targetColumns.`); | ||
| } | ||
| function buildStorageColumn(field, storageValueSetRef, codecLookup) { | ||
| if (isValueObjectField(field)) { | ||
| const encodedDefault = field.default !== void 0 ? encodeColumnDefault(field.default, JSONB_CODEC_ID, codecLookup) : void 0; | ||
| return { | ||
| nativeType: JSONB_NATIVE_TYPE, | ||
| codecId: JSONB_CODEC_ID, | ||
| nullable: field.nullable, | ||
| ...ifDefined("default", encodedDefault) | ||
| }; | ||
| } | ||
| if (field.many) return { | ||
| nativeType: JSONB_NATIVE_TYPE, | ||
| codecId: JSONB_CODEC_ID, | ||
| nullable: field.nullable | ||
| }; | ||
| const codecId = field.descriptor.codecId; | ||
| const encodedDefault = field.default !== void 0 ? encodeColumnDefault(field.default, codecId, codecLookup) : void 0; | ||
| return { | ||
| nativeType: field.descriptor.nativeType, | ||
| codecId, | ||
| nullable: field.nullable, | ||
| ...ifDefined("typeParams", field.descriptor.typeParams), | ||
| ...ifDefined("default", encodedDefault), | ||
| ...ifDefined("typeRef", field.descriptor.typeRef), | ||
| ...ifDefined("valueSet", storageValueSetRef) | ||
| }; | ||
| } | ||
| function buildDomainField(field, column, domainValueSetRef) { | ||
| if (isValueObjectField(field)) return { | ||
| type: { | ||
| kind: "valueObject", | ||
| name: field.valueObjectName | ||
| }, | ||
| nullable: field.nullable, | ||
| ...field.many ? { many: true } : {} | ||
| }; | ||
| return { | ||
| type: { | ||
| kind: "scalar", | ||
| codecId: column.codecId, | ||
| ...ifDefined("typeParams", column.typeParams) | ||
| }, | ||
| nullable: column.nullable, | ||
| ...field.many ? { many: true } : {}, | ||
| ...ifDefined("valueSet", domainValueSetRef) | ||
| }; | ||
| } | ||
| function collectStorageNamespaceCoordinateIds(definition) { | ||
| const ids = /* @__PURE__ */ new Set(); | ||
| ids.add(definition.target.defaultNamespaceId); | ||
| for (const id of definition.namespaces ?? []) if (id.length > 0) ids.add(id); | ||
| for (const model of definition.models) if (model.namespaceId !== void 0 && model.namespaceId.length > 0) ids.add(model.namespaceId); | ||
| return ids; | ||
| } | ||
| function ensureUnboundNamespaceSlot(namespaces, createNamespace) { | ||
| if (Object.hasOwn(namespaces, UNBOUND_NAMESPACE_ID)) return namespaces; | ||
| const unboundInput = { | ||
| id: UNBOUND_NAMESPACE_ID, | ||
| entries: { table: {} } | ||
| }; | ||
| const unbound = createNamespace ? createNamespace(unboundInput) : buildSqlNamespace(unboundInput); | ||
| return blindCast({ | ||
| [UNBOUND_NAMESPACE_ID]: unbound, | ||
| ...namespaces | ||
| }); | ||
| } | ||
| function buildSqlContractFromDefinition(definition, codecLookup) { | ||
| const target = definition.target.targetId; | ||
| const defaultNamespaceId = definition.target.defaultNamespaceId; | ||
| const targetFamily = "sql"; | ||
| const resolveNamespaceId = (m) => m.namespaceId !== void 0 && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId; | ||
| const modelsByName = new Map(definition.models.map((m) => [m.modelName, m])); | ||
| const tableNamespaceByName = new Map(definition.models.map((m) => [m.tableName, m.namespaceId !== void 0 && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId])); | ||
| const modelsByCoordinate = new Map(definition.models.map((m) => [`${resolveNamespaceId(m)}:${m.modelName}`, m])); | ||
| const tablesByNamespace = {}; | ||
| const modelNameToNamespaceId = /* @__PURE__ */ new Map(); | ||
| const executionDefaults = []; | ||
| const modelsByNamespace = {}; | ||
| const rootEntries = []; | ||
| for (const semanticModel of definition.models) { | ||
| const tableName = semanticModel.tableName; | ||
| const namespaceId = semanticModel.namespaceId !== void 0 && semanticModel.namespaceId.length > 0 ? semanticModel.namespaceId : defaultNamespaceId; | ||
| modelNameToNamespaceId.set(semanticModel.modelName, namespaceId); | ||
| if (!semanticModel.sharesBaseTable) rootEntries.push({ | ||
| tableName, | ||
| namespaceId, | ||
| ref: crossRef(semanticModel.modelName, namespaceId) | ||
| }); | ||
| const columns = {}; | ||
| const fieldToColumn = {}; | ||
| const domainFields = {}; | ||
| const domainFieldRefs = {}; | ||
| for (const field of semanticModel.fields) { | ||
| const executionDefaultPhases = field.executionDefaults?.onCreate || field.executionDefaults?.onUpdate ? field.executionDefaults : void 0; | ||
| if (executionDefaultPhases) { | ||
| if (field.default !== void 0) throw new Error(`Field "${semanticModel.modelName}.${field.fieldName}" cannot define both default and executionDefaults.`); | ||
| if (field.nullable) throw new Error(`Field "${semanticModel.modelName}.${field.fieldName}" cannot be nullable when executionDefaults are present.`); | ||
| } | ||
| const enumHandle = !isValueObjectField(field) ? field.enumTypeHandle : void 0; | ||
| const storageValueSetRef = enumHandle !== void 0 ? { | ||
| plane: "storage", | ||
| entityKind: "valueSet", | ||
| namespaceId: defaultNamespaceId, | ||
| entityName: enumHandle.enumName | ||
| } : void 0; | ||
| const domainValueSetRef = enumHandle !== void 0 ? { | ||
| plane: "domain", | ||
| entityKind: "enum", | ||
| namespaceId: defaultNamespaceId, | ||
| entityName: enumHandle.enumName | ||
| } : void 0; | ||
| const column = buildStorageColumn(field, storageValueSetRef, codecLookup); | ||
| columns[field.columnName] = column; | ||
| fieldToColumn[field.fieldName] = field.columnName; | ||
| domainFields[field.fieldName] = buildDomainField(field, column, domainValueSetRef); | ||
| if (isValueObjectField(field)) domainFieldRefs[field.fieldName] = { | ||
| kind: "valueObject", | ||
| name: field.valueObjectName, | ||
| ...field.many ? { many: true } : {} | ||
| }; | ||
| else if (field.many) domainFieldRefs[field.fieldName] = { | ||
| kind: "scalar", | ||
| many: true | ||
| }; | ||
| if (executionDefaultPhases) executionDefaults.push({ | ||
| ref: { | ||
| namespace: namespaceId, | ||
| table: tableName, | ||
| column: field.columnName | ||
| }, | ||
| ...ifDefined("onCreate", executionDefaultPhases.onCreate), | ||
| ...ifDefined("onUpdate", executionDefaultPhases.onUpdate) | ||
| }); | ||
| } | ||
| const foreignKeys = (semanticModel.foreignKeys ?? []).map((fk) => { | ||
| if (fk.references.spaceId !== void 0) { | ||
| const targetNamespaceId = fk.references.namespaceId ?? defaultNamespaceId; | ||
| return { | ||
| source: { | ||
| namespaceId: asNamespaceId(namespaceId), | ||
| tableName, | ||
| columns: fk.columns | ||
| }, | ||
| target: { | ||
| namespaceId: asNamespaceId(targetNamespaceId), | ||
| tableName: fk.references.table, | ||
| columns: fk.references.columns, | ||
| spaceId: fk.references.spaceId | ||
| }, | ||
| ...applyFkDefaults({ | ||
| ...ifDefined("constraint", fk.constraint), | ||
| ...ifDefined("index", fk.index) | ||
| }, definition.foreignKeyDefaults), | ||
| ...ifDefined("name", fk.name), | ||
| ...ifDefined("onDelete", fk.onDelete), | ||
| ...ifDefined("onUpdate", fk.onUpdate) | ||
| }; | ||
| } | ||
| const targetModel = assertKnownTargetModel(modelsByName, modelsByCoordinate, semanticModel.modelName, fk.references.model, fk.references.namespaceId, "Foreign key"); | ||
| assertTargetTableMatches(semanticModel.modelName, targetModel, fk.references.table, "Foreign key"); | ||
| const targetNamespaceId = fk.references.namespaceId ?? (targetModel.namespaceId !== void 0 && targetModel.namespaceId.length > 0 ? targetModel.namespaceId : defaultNamespaceId); | ||
| return { | ||
| source: { | ||
| namespaceId: asNamespaceId(namespaceId), | ||
| tableName, | ||
| columns: fk.columns | ||
| }, | ||
| target: { | ||
| namespaceId: asNamespaceId(targetNamespaceId), | ||
| tableName: fk.references.table, | ||
| columns: fk.references.columns | ||
| }, | ||
| ...applyFkDefaults({ | ||
| ...ifDefined("constraint", fk.constraint), | ||
| ...ifDefined("index", fk.index) | ||
| }, definition.foreignKeyDefaults), | ||
| ...ifDefined("name", fk.name), | ||
| ...ifDefined("onDelete", fk.onDelete), | ||
| ...ifDefined("onUpdate", fk.onUpdate) | ||
| }; | ||
| }); | ||
| if (!semanticModel.sharesBaseTable) { | ||
| const checksForTable = Object.entries(columns).flatMap(([columnName, col]) => { | ||
| const valueSet = col.valueSet; | ||
| return valueSet === void 0 ? [] : [{ | ||
| name: `${tableName}_${columnName}_check`, | ||
| column: columnName, | ||
| valueSet | ||
| }]; | ||
| }); | ||
| const tableInput = { | ||
| columns, | ||
| ...ifDefined("control", semanticModel.control), | ||
| uniques: (semanticModel.uniques ?? []).map((u) => ({ | ||
| columns: u.columns, | ||
| ...ifDefined("name", u.name) | ||
| })), | ||
| indexes: (semanticModel.indexes ?? []).map((i) => ({ | ||
| columns: i.columns, | ||
| ...ifDefined("name", i.name), | ||
| ...ifDefined("type", i.type), | ||
| ...ifDefined("options", i.options) | ||
| })), | ||
| foreignKeys, | ||
| ...semanticModel.id ? { primaryKey: { | ||
| columns: semanticModel.id.columns, | ||
| ...ifDefined("name", semanticModel.id.name) | ||
| } } : {}, | ||
| ...checksForTable.length > 0 ? { checks: checksForTable } : {} | ||
| }; | ||
| let nsTables = tablesByNamespace[namespaceId]; | ||
| if (nsTables === void 0) { | ||
| nsTables = {}; | ||
| tablesByNamespace[namespaceId] = nsTables; | ||
| } | ||
| if (nsTables[tableName] !== void 0) throw new Error(`buildSqlContractFromDefinition: duplicate table "${tableName}" in namespace "${namespaceId}".`); | ||
| nsTables[tableName] = tableInput; | ||
| } | ||
| const storageFields = {}; | ||
| for (const [fieldName, columnName] of Object.entries(fieldToColumn)) storageFields[fieldName] = { column: columnName }; | ||
| const columnToField = new Map(Object.entries(fieldToColumn).map(([field, col]) => [col, field])); | ||
| const modelRelations = {}; | ||
| for (const relation of semanticModel.relations ?? []) { | ||
| if (relation.spaceId !== void 0) { | ||
| const targetNamespaceId = relation.namespaceId ?? defaultNamespaceId; | ||
| modelRelations[relation.fieldName] = { | ||
| to: crossRef(relation.toModel, targetNamespaceId, relation.spaceId), | ||
| cardinality: "N:1", | ||
| on: { | ||
| localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col), | ||
| targetFields: relation.on.childColumns | ||
| } | ||
| }; | ||
| continue; | ||
| } | ||
| const targetModel = assertKnownTargetModel(modelsByName, modelsByCoordinate, semanticModel.modelName, relation.toModel, relation.toNamespaceId, "Relation"); | ||
| assertTargetTableMatches(semanticModel.modelName, targetModel, relation.toTable, "Relation"); | ||
| const targetColumnToField = new Map(targetModel.fields.map((f) => [f.columnName, f.fieldName])); | ||
| const to = crossRef(relation.toModel, relation.toNamespaceId !== void 0 && relation.toNamespaceId.length > 0 ? relation.toNamespaceId : resolveModelNamespaceId(targetModel, modelNameToNamespaceId, defaultNamespaceId)); | ||
| const on = { | ||
| localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col), | ||
| targetFields: relation.on.childColumns.map((col) => targetColumnToField.get(col) ?? col) | ||
| }; | ||
| if (relation.cardinality === "N:M") { | ||
| if (!relation.through) throw new Error(`Relation "${semanticModel.modelName}.${relation.fieldName}" with cardinality "N:M" requires through metadata`); | ||
| modelRelations[relation.fieldName] = { | ||
| to, | ||
| cardinality: "N:M", | ||
| on, | ||
| through: buildThroughDescriptor(relation.through, tableNamespaceByName, targetModel, semanticModel.modelName, relation.fieldName, defaultNamespaceId) | ||
| }; | ||
| } else modelRelations[relation.fieldName] = { | ||
| to, | ||
| cardinality: relation.cardinality, | ||
| on | ||
| }; | ||
| } | ||
| let namespaceModels = modelsByNamespace[namespaceId]; | ||
| if (namespaceModels === void 0) { | ||
| namespaceModels = {}; | ||
| modelsByNamespace[namespaceId] = namespaceModels; | ||
| } | ||
| namespaceModels[semanticModel.modelName] = { | ||
| storage: { | ||
| table: tableName, | ||
| namespaceId, | ||
| fields: storageFields | ||
| }, | ||
| fields: domainFields, | ||
| relations: modelRelations | ||
| }; | ||
| } | ||
| const rootTableNameCounts = /* @__PURE__ */ new Map(); | ||
| for (const entry of rootEntries) rootTableNameCounts.set(entry.tableName, (rootTableNameCounts.get(entry.tableName) ?? 0) + 1); | ||
| const roots = {}; | ||
| for (const entry of rootEntries) { | ||
| const key = (rootTableNameCounts.get(entry.tableName) ?? 0) > 1 ? `${entry.namespaceId}.${entry.tableName}` : entry.tableName; | ||
| roots[key] = entry.ref; | ||
| } | ||
| const rawStorageTypes = definition.storageTypes ?? {}; | ||
| const documentTypes = Object.fromEntries(Object.entries(rawStorageTypes).map(([name, entry]) => { | ||
| if (entry.kind === "codec-instance") return [name, entry]; | ||
| return [name, toStorageTypeInstance({ | ||
| codecId: entry.codecId, | ||
| nativeType: entry.nativeType, | ||
| typeParams: entry.typeParams ?? {} | ||
| })]; | ||
| })); | ||
| const namespaceCoordinateIds = collectStorageNamespaceCoordinateIds(definition); | ||
| const domainEnumsByNs = {}; | ||
| const storageValueSetsByNs = {}; | ||
| for (const [enumName, handle] of Object.entries(definition.enums ?? {})) { | ||
| if (enumName !== handle.enumName) throw new Error(`enum declaration key "${enumName}" must match enumType name "${handle.enumName}". Aliases are not supported.`); | ||
| const nsId = defaultNamespaceId; | ||
| let domainSlot = domainEnumsByNs[nsId]; | ||
| if (domainSlot === void 0) { | ||
| domainSlot = {}; | ||
| domainEnumsByNs[nsId] = domainSlot; | ||
| } | ||
| domainSlot[enumName] = { | ||
| codecId: handle.codecId, | ||
| members: handle.enumMembers.map((m) => ({ | ||
| name: m.name, | ||
| value: encodeViaCodec(m.value, handle.codecId, codecLookup) | ||
| })) | ||
| }; | ||
| let storageSlot = storageValueSetsByNs[nsId]; | ||
| if (storageSlot === void 0) { | ||
| storageSlot = {}; | ||
| storageValueSetsByNs[nsId] = storageSlot; | ||
| } | ||
| storageSlot[enumName] = { | ||
| kind: "valueSet", | ||
| values: handle.values.map((v) => encodeViaCodec(v, handle.codecId, codecLookup)) | ||
| }; | ||
| } | ||
| const { createNamespace } = definition; | ||
| const namespaces = blindCast(Object.fromEntries([...namespaceCoordinateIds].sort().map((id) => { | ||
| const valueSetEntries = storageValueSetsByNs[id]; | ||
| const nsInput = { | ||
| id, | ||
| entries: { | ||
| table: tablesByNamespace[id] ?? {}, | ||
| ...valueSetEntries !== void 0 && Object.keys(valueSetEntries).length > 0 ? { valueSet: valueSetEntries } : {} | ||
| } | ||
| }; | ||
| return [id, createNamespace ? createNamespace(nsInput) : buildSqlNamespace(nsInput)]; | ||
| }))); | ||
| const storageWithoutHash = { | ||
| ...Object.keys(documentTypes).length > 0 ? { types: documentTypes } : {}, | ||
| namespaces: defaultNamespaceId === UNBOUND_NAMESPACE_ID ? ensureUnboundNamespaceSlot(namespaces, createNamespace) : namespaces | ||
| }; | ||
| const storageHash = definition.storageHash ? coreHash(definition.storageHash) : computeStorageHash({ | ||
| target, | ||
| targetFamily, | ||
| storage: storageWithoutHash, | ||
| ...sqlContractCanonicalizationHooks | ||
| }); | ||
| const storage = new SqlStorage({ | ||
| ...storageWithoutHash, | ||
| storageHash | ||
| }); | ||
| const executionSection = executionDefaults.length > 0 ? { mutations: { defaults: executionDefaults.sort((a, b) => { | ||
| const tableCompare = a.ref.table.localeCompare(b.ref.table); | ||
| if (tableCompare !== 0) return tableCompare; | ||
| return a.ref.column.localeCompare(b.ref.column); | ||
| }) } } : void 0; | ||
| const extensionNamespaces = definition.extensionPacks ? Object.values(definition.extensionPacks).map((pack) => pack.id) : void 0; | ||
| const extensionPacks = { ...definition.extensionPacks || {} }; | ||
| if (extensionNamespaces) { | ||
| for (const namespace of extensionNamespaces) if (!Object.hasOwn(extensionPacks, namespace)) extensionPacks[namespace] = {}; | ||
| } | ||
| const extensionPackCapabilitySources = definition.extensionPacks ? Object.values(definition.extensionPacks).map((pack) => pack.capabilities) : []; | ||
| const capabilities = mergeCapabilityMatrices(definition.target.capabilities, ...extensionPackCapabilitySources); | ||
| const profileHash = computeProfileHash({ | ||
| target, | ||
| targetFamily, | ||
| capabilities: {} | ||
| }); | ||
| const executionWithHash = executionSection ? { | ||
| ...executionSection, | ||
| executionHash: computeExecutionHash({ | ||
| target, | ||
| targetFamily, | ||
| execution: executionSection | ||
| }) | ||
| } : void 0; | ||
| const valueObjects = definition.valueObjects && definition.valueObjects.length > 0 ? Object.fromEntries(definition.valueObjects.map((vo) => [vo.name, { fields: Object.fromEntries(vo.fields.map((f) => [f.fieldName, isValueObjectField(f) ? { | ||
| type: { | ||
| kind: "valueObject", | ||
| name: f.valueObjectName | ||
| }, | ||
| nullable: f.nullable, | ||
| ...f.many ? { many: true } : {} | ||
| } : { | ||
| type: { | ||
| kind: "scalar", | ||
| codecId: f.descriptor.codecId, | ||
| ...ifDefined("typeParams", f.descriptor.typeParams) | ||
| }, | ||
| nullable: f.nullable | ||
| }])) }])) : void 0; | ||
| const domainNamespaceIds = new Set(Object.keys(modelsByNamespace)); | ||
| if (domainNamespaceIds.size === 0) domainNamespaceIds.add(defaultNamespaceId); | ||
| if (valueObjects !== void 0) domainNamespaceIds.add(defaultNamespaceId); | ||
| for (const nsId of Object.keys(domainEnumsByNs)) domainNamespaceIds.add(nsId); | ||
| const domainNamespaces = Object.fromEntries([...domainNamespaceIds].sort().map((namespaceId) => { | ||
| const modelsInNs = modelsByNamespace[namespaceId] ?? {}; | ||
| const enumsInNs = domainEnumsByNs[namespaceId]; | ||
| return [namespaceId, { | ||
| models: modelsInNs, | ||
| ...namespaceId === defaultNamespaceId && valueObjects !== void 0 ? { valueObjects } : {}, | ||
| ...enumsInNs !== void 0 && Object.keys(enumsInNs).length > 0 ? { enum: enumsInNs } : {} | ||
| }]; | ||
| })); | ||
| const contract = { | ||
| target, | ||
| targetFamily, | ||
| ...ifDefined("defaultControlPolicy", definition.defaultControlPolicy), | ||
| domain: { namespaces: domainNamespaces }, | ||
| roots, | ||
| storage, | ||
| ...executionWithHash ? { execution: executionWithHash } : {}, | ||
| extensionPacks, | ||
| capabilities, | ||
| profileHash, | ||
| meta: {} | ||
| }; | ||
| assertStorageSemantics(definition, contract); | ||
| return contract; | ||
| } | ||
| //#endregion | ||
| export { buildSqlContractFromDefinition as t }; | ||
| //# sourceMappingURL=build-contract-CQ4u83jx.mjs.map |
| {"version":3,"file":"build-contract-CQ4u83jx.mjs","names":[],"sources":["../src/build-contract.ts"],"sourcesContent":["import {\n computeExecutionHash,\n computeProfileHash,\n computeStorageHash,\n} from '@prisma-next/contract/hashing';\nimport {\n asNamespaceId,\n type ColumnDefault,\n type Contract,\n type ContractEnum,\n type ContractField,\n type ContractModel,\n type ContractRelation,\n type ContractRelationThrough,\n type ContractValueObject,\n type CrossReference,\n coreHash,\n crossRef,\n type ExecutionMutationDefault,\n type JsonValue,\n type StorageHashBase,\n type ValueSetRef,\n} from '@prisma-next/contract/types';\nimport { type CapabilityMatrix, mergeCapabilityMatrices } from '@prisma-next/contract-authoring';\nimport type { CodecLookup } from '@prisma-next/framework-components/codec';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { sqlContractCanonicalizationHooks } from '@prisma-next/sql-contract/canonicalization-hooks';\nimport { validateIndexTypes } from '@prisma-next/sql-contract/index-type-validation';\nimport {\n createIndexTypeRegistry,\n type IndexTypeMap,\n type IndexTypeRegistration,\n} from '@prisma-next/sql-contract/index-types';\nimport {\n applyFkDefaults,\n buildSqlNamespace,\n type CheckConstraintInput,\n type SqlNamespaceTablesInput,\n SqlStorage,\n type SqlStorageInput,\n type StorageColumn,\n type StorageTableInput,\n type StorageTypeInstance,\n type StorageValueSetInput,\n toStorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { validateStorageSemantics } from '@prisma-next/sql-contract/validators';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type {\n ContractDefinition,\n FieldNode,\n ModelNode,\n RelationNode,\n ValueObjectFieldNode,\n} from './contract-definition';\n\ntype DomainFieldRef =\n | { readonly kind: 'scalar'; readonly many?: boolean }\n | { readonly kind: 'valueObject'; readonly name: string; readonly many?: boolean };\n\nfunction encodeViaCodec(value: unknown, codecId: string, codecLookup?: CodecLookup): JsonValue {\n const codec = codecLookup?.get(codecId);\n if (codec) {\n return codec.encodeJson(value);\n }\n return blindCast<\n JsonValue,\n 'no codec lookup at build time: literal/enum member value is already JSON-safe'\n >(value);\n}\n\nfunction encodeColumnDefault(\n defaultInput: ColumnDefault,\n codecId: string,\n codecLookup?: CodecLookup,\n): ColumnDefault {\n if (defaultInput.kind === 'function') {\n return { kind: 'function', expression: defaultInput.expression };\n }\n return {\n kind: 'literal',\n value: encodeViaCodec(defaultInput.value, codecId, codecLookup),\n };\n}\n\nfunction assertStorageSemantics(\n definition: ContractDefinition,\n contract: Contract<SqlStorage>,\n): void {\n const semanticErrors = validateStorageSemantics(contract.storage);\n if (semanticErrors.length > 0) {\n throw new Error(`Contract semantic validation failed: ${semanticErrors.join('; ')}`);\n }\n\n const indexTypeRegistry = createIndexTypeRegistry();\n const packsToRegister: ReadonlyArray<{ readonly id?: string; readonly indexTypes?: unknown }> = [\n definition.target,\n ...Object.values(definition.extensionPacks ?? {}),\n ];\n for (const pack of packsToRegister) {\n const registration = pack.indexTypes;\n if (registration === undefined) continue;\n if (\n typeof registration !== 'object' ||\n registration === null ||\n !Array.isArray((registration as { entries?: unknown }).entries)\n ) {\n throw new Error(\n `Pack \"${pack.id ?? '<unknown>'}\" declares \"indexTypes\" but its value is not an IndexTypeRegistration (expected an object with an \"entries\" array; got ${typeof registration}).`,\n );\n }\n for (const entry of (registration as IndexTypeRegistration<IndexTypeMap>).entries) {\n indexTypeRegistry.register(entry);\n }\n }\n validateIndexTypes(contract, indexTypeRegistry);\n}\n\nfunction assertKnownTargetModel(\n modelsByName: ReadonlyMap<string, ModelNode>,\n modelsByCoordinate: ReadonlyMap<string, ModelNode>,\n sourceModelName: string,\n targetModelName: string,\n targetNamespaceId: string | undefined,\n context: string,\n): ModelNode {\n const targetModel =\n targetNamespaceId !== undefined && targetNamespaceId.length > 0\n ? modelsByCoordinate.get(`${targetNamespaceId}:${targetModelName}`)\n : modelsByName.get(targetModelName);\n if (!targetModel) {\n const qualified =\n targetNamespaceId !== undefined && targetNamespaceId.length > 0\n ? `${targetNamespaceId}.${targetModelName}`\n : targetModelName;\n throw new Error(\n `${context} on model \"${sourceModelName}\" references unknown model \"${qualified}\"`,\n );\n }\n return targetModel;\n}\n\nfunction assertTargetTableMatches(\n sourceModelName: string,\n targetModel: ModelNode,\n referencedTableName: string,\n context: string,\n): void {\n if (targetModel.tableName !== referencedTableName) {\n throw new Error(\n `${context} on model \"${sourceModelName}\" references table \"${referencedTableName}\" but model \"${targetModel.modelName}\" maps to \"${targetModel.tableName}\"`,\n );\n }\n}\n\nfunction isValueObjectField(\n field: FieldNode | ValueObjectFieldNode,\n): field is ValueObjectFieldNode {\n return 'valueObjectName' in field;\n}\n\nconst JSONB_CODEC_ID = 'pg/jsonb@1';\nconst JSONB_NATIVE_TYPE = 'jsonb';\n\nfunction resolveModelNamespaceId(\n model: ModelNode,\n modelNameToNamespaceId: ReadonlyMap<string, string>,\n defaultNamespaceId: string,\n): string {\n if (model.namespaceId !== undefined && model.namespaceId.length > 0) {\n return model.namespaceId;\n }\n return modelNameToNamespaceId.get(model.modelName) ?? defaultNamespaceId;\n}\n\nfunction buildThroughDescriptor(\n through: NonNullable<RelationNode['through']>,\n tableNamespaceByName: ReadonlyMap<string, string>,\n targetModel: ModelNode,\n modelName: string,\n fieldName: string,\n defaultNamespaceId: string,\n): ContractRelationThrough {\n if (!tableNamespaceByName.has(through.table)) {\n throw new Error(\n `buildSqlContractFromDefinition: junction table \"${through.table}\" for relation \"${modelName}.${fieldName}\" is not a declared model.`,\n );\n }\n // Junction table names are unique per namespace, not globally. Prefer the\n // junction's own declared namespace (carried on the through node); fall back to\n // the target's default namespace. Resolving by bare table name would pick the\n // wrong namespace when the same junction table name exists in two namespaces.\n const namespaceId = through.namespaceId ?? defaultNamespaceId;\n\n return {\n table: through.table,\n namespaceId,\n parentColumns: through.parentColumns,\n childColumns: through.childColumns,\n targetColumns: targetColumnsForJunction(targetModel, fieldName),\n };\n}\n\nfunction targetColumnsForJunction(targetModel: ModelNode, fieldName: string): readonly string[] {\n const primaryKeyColumns = targetModel.id?.columns;\n if (primaryKeyColumns && primaryKeyColumns.length > 0) {\n return primaryKeyColumns;\n }\n const firstUnique = targetModel.uniques?.find((u) => u.columns.length > 0);\n if (firstUnique) {\n return firstUnique.columns;\n }\n throw new Error(\n `M:N target model \"${targetModel.modelName}\" (relation field \"${fieldName}\") has no primary id or unique key to derive junction targetColumns.`,\n );\n}\n\nfunction buildStorageColumn(\n field: FieldNode | ValueObjectFieldNode,\n storageValueSetRef: ValueSetRef | undefined,\n codecLookup?: CodecLookup,\n): StorageColumn {\n if (isValueObjectField(field)) {\n const encodedDefault =\n field.default !== undefined\n ? encodeColumnDefault(field.default, JSONB_CODEC_ID, codecLookup)\n : undefined;\n\n return {\n nativeType: JSONB_NATIVE_TYPE,\n codecId: JSONB_CODEC_ID,\n nullable: field.nullable,\n ...ifDefined('default', encodedDefault),\n };\n }\n\n if (field.many) {\n return {\n nativeType: JSONB_NATIVE_TYPE,\n codecId: JSONB_CODEC_ID,\n nullable: field.nullable,\n };\n }\n\n const codecId = field.descriptor.codecId;\n const encodedDefault =\n field.default !== undefined\n ? encodeColumnDefault(field.default, codecId, codecLookup)\n : undefined;\n\n return {\n nativeType: field.descriptor.nativeType,\n codecId,\n nullable: field.nullable,\n ...ifDefined('typeParams', field.descriptor.typeParams),\n ...ifDefined('default', encodedDefault),\n ...ifDefined('typeRef', field.descriptor.typeRef),\n ...ifDefined('valueSet', storageValueSetRef),\n };\n}\n\nfunction buildDomainField(\n field: FieldNode | ValueObjectFieldNode,\n column: StorageColumn,\n domainValueSetRef: ValueSetRef | undefined,\n): ContractField {\n if (isValueObjectField(field)) {\n return {\n type: { kind: 'valueObject', name: field.valueObjectName },\n nullable: field.nullable,\n ...(field.many ? { many: true } : {}),\n };\n }\n\n return {\n type: {\n kind: 'scalar',\n codecId: column.codecId,\n ...ifDefined('typeParams', column.typeParams),\n },\n nullable: column.nullable,\n ...(field.many ? { many: true } : {}),\n ...ifDefined('valueSet', domainValueSetRef),\n };\n}\n\nfunction collectStorageNamespaceCoordinateIds(definition: ContractDefinition): Set<string> {\n const ids = new Set<string>();\n ids.add(definition.target.defaultNamespaceId);\n for (const id of definition.namespaces ?? []) {\n if (id.length > 0) {\n ids.add(id);\n }\n }\n for (const model of definition.models) {\n if (model.namespaceId !== undefined && model.namespaceId.length > 0) {\n ids.add(model.namespaceId);\n }\n }\n return ids;\n}\n\nfunction ensureUnboundNamespaceSlot(\n namespaces: SqlStorageInput['namespaces'],\n createNamespace: ContractDefinition['createNamespace'],\n): SqlStorageInput['namespaces'] {\n if (Object.hasOwn(namespaces, UNBOUND_NAMESPACE_ID)) {\n return namespaces;\n }\n const unboundInput: SqlNamespaceTablesInput = {\n id: UNBOUND_NAMESPACE_ID,\n entries: { table: {} },\n };\n const unbound = createNamespace ? createNamespace(unboundInput) : buildSqlNamespace(unboundInput);\n return blindCast<\n SqlStorageInput['namespaces'],\n 'createNamespace may return a target namespace concretion; the unbound slot matches SqlNamespace at runtime'\n >({\n [UNBOUND_NAMESPACE_ID]: unbound,\n ...namespaces,\n });\n}\n\nexport function buildSqlContractFromDefinition(\n definition: ContractDefinition,\n codecLookup?: CodecLookup,\n): Contract<SqlStorage> {\n const target = definition.target.targetId;\n const defaultNamespaceId = definition.target.defaultNamespaceId;\n const targetFamily = 'sql';\n const resolveNamespaceId = (m: ModelNode): string =>\n m.namespaceId !== undefined && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId;\n const modelsByName = new Map(definition.models.map((m) => [m.modelName, m]));\n const tableNamespaceByName = new Map(\n definition.models.map((m) => [\n m.tableName,\n m.namespaceId !== undefined && m.namespaceId.length > 0 ? m.namespaceId : defaultNamespaceId,\n ]),\n );\n const modelsByCoordinate = new Map(\n definition.models.map((m) => [`${resolveNamespaceId(m)}:${m.modelName}`, m]),\n );\n\n const tablesByNamespace: Record<string, Record<string, StorageTableInput>> = {};\n const modelNameToNamespaceId = new Map<string, string>();\n const executionDefaults: ExecutionMutationDefault[] = [];\n const modelsByNamespace: Record<string, Record<string, ContractModel>> = {};\n const rootEntries: Array<{\n readonly tableName: string;\n readonly namespaceId: string;\n readonly ref: CrossReference;\n }> = [];\n\n for (const semanticModel of definition.models) {\n const tableName = semanticModel.tableName;\n const namespaceId =\n semanticModel.namespaceId !== undefined && semanticModel.namespaceId.length > 0\n ? semanticModel.namespaceId\n : defaultNamespaceId;\n modelNameToNamespaceId.set(semanticModel.modelName, namespaceId);\n // STI variants share the base table; the base model already owns this\n // table name and its root, so the variant contributes neither.\n if (!semanticModel.sharesBaseTable) {\n rootEntries.push({\n tableName,\n namespaceId,\n ref: crossRef(semanticModel.modelName, namespaceId),\n });\n }\n\n // --- Build storage table ---\n\n const columns: Record<string, StorageColumn> = {};\n const fieldToColumn: Record<string, string> = {};\n const domainFields: Record<string, ContractField> = {};\n const domainFieldRefs: Record<string, DomainFieldRef> = {};\n\n for (const field of semanticModel.fields) {\n const executionDefaultPhases =\n field.executionDefaults?.onCreate || field.executionDefaults?.onUpdate\n ? field.executionDefaults\n : undefined;\n if (executionDefaultPhases) {\n if (field.default !== undefined) {\n throw new Error(\n `Field \"${semanticModel.modelName}.${field.fieldName}\" cannot define both default and executionDefaults.`,\n );\n }\n if (field.nullable) {\n throw new Error(\n `Field \"${semanticModel.modelName}.${field.fieldName}\" cannot be nullable when executionDefaults are present.`,\n );\n }\n }\n\n const enumHandle = !isValueObjectField(field) ? field.enumTypeHandle : undefined;\n // Authored enums are always registered under the contract's defaultNamespaceId\n // (see the enum registration loop below), so refs must point there regardless\n // of which namespace the consuming model lives in.\n const storageValueSetRef: ValueSetRef | undefined =\n enumHandle !== undefined\n ? {\n plane: 'storage',\n entityKind: 'valueSet',\n namespaceId: defaultNamespaceId,\n entityName: enumHandle.enumName,\n }\n : undefined;\n const domainValueSetRef: ValueSetRef | undefined =\n enumHandle !== undefined\n ? {\n plane: 'domain',\n entityKind: 'enum',\n namespaceId: defaultNamespaceId,\n entityName: enumHandle.enumName,\n }\n : undefined;\n\n const column = buildStorageColumn(field, storageValueSetRef, codecLookup);\n columns[field.columnName] = column;\n fieldToColumn[field.fieldName] = field.columnName;\n\n domainFields[field.fieldName] = buildDomainField(field, column, domainValueSetRef);\n\n if (isValueObjectField(field)) {\n domainFieldRefs[field.fieldName] = {\n kind: 'valueObject',\n name: field.valueObjectName,\n ...(field.many ? { many: true } : {}),\n };\n } else if (field.many) {\n domainFieldRefs[field.fieldName] = { kind: 'scalar', many: true };\n }\n\n if (executionDefaultPhases) {\n executionDefaults.push({\n ref: { namespace: namespaceId, table: tableName, column: field.columnName },\n ...ifDefined('onCreate', executionDefaultPhases.onCreate),\n ...ifDefined('onUpdate', executionDefaultPhases.onUpdate),\n });\n }\n }\n\n const foreignKeys = (semanticModel.foreignKeys ?? []).map((fk) => {\n if (fk.references.spaceId !== undefined) {\n // Cross-space FK: the target lives in a different contract space.\n // Skip local model lookup and carry the spaceId coordinate through.\n const targetNamespaceId = fk.references.namespaceId ?? defaultNamespaceId;\n return {\n source: { namespaceId: asNamespaceId(namespaceId), tableName, columns: fk.columns },\n target: {\n namespaceId: asNamespaceId(targetNamespaceId),\n tableName: fk.references.table,\n columns: fk.references.columns,\n spaceId: fk.references.spaceId,\n },\n ...applyFkDefaults(\n {\n ...ifDefined('constraint', fk.constraint),\n ...ifDefined('index', fk.index),\n },\n definition.foreignKeyDefaults,\n ),\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n };\n }\n\n const targetModel = assertKnownTargetModel(\n modelsByName,\n modelsByCoordinate,\n semanticModel.modelName,\n fk.references.model,\n fk.references.namespaceId,\n 'Foreign key',\n );\n assertTargetTableMatches(\n semanticModel.modelName,\n targetModel,\n fk.references.table,\n 'Foreign key',\n );\n const targetNamespaceId =\n fk.references.namespaceId ??\n (targetModel.namespaceId !== undefined && targetModel.namespaceId.length > 0\n ? targetModel.namespaceId\n : defaultNamespaceId);\n return {\n source: { namespaceId: asNamespaceId(namespaceId), tableName, columns: fk.columns },\n target: {\n namespaceId: asNamespaceId(targetNamespaceId),\n tableName: fk.references.table,\n columns: fk.references.columns,\n },\n ...applyFkDefaults(\n {\n ...ifDefined('constraint', fk.constraint),\n ...ifDefined('index', fk.index),\n },\n definition.foreignKeyDefaults,\n ),\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n };\n });\n\n // STI variants share the base table: their columns are already\n // materialised onto the base `ModelNode`, so the variant builds a domain\n // model (below) but no storage table of its own.\n if (!semanticModel.sharesBaseTable) {\n const checksForTable: CheckConstraintInput[] = Object.entries(columns).flatMap(\n ([columnName, col]) => {\n const valueSet = col.valueSet;\n return valueSet === undefined\n ? []\n : [{ name: `${tableName}_${columnName}_check`, column: columnName, valueSet }];\n },\n );\n\n const tableInput: StorageTableInput = {\n columns,\n ...ifDefined('control', semanticModel.control),\n uniques: (semanticModel.uniques ?? []).map((u) => ({\n columns: u.columns,\n ...ifDefined('name', u.name),\n })),\n indexes: (semanticModel.indexes ?? []).map((i) => ({\n columns: i.columns,\n ...ifDefined('name', i.name),\n ...ifDefined('type', i.type),\n ...ifDefined('options', i.options),\n })),\n foreignKeys,\n ...(semanticModel.id\n ? {\n primaryKey: {\n columns: semanticModel.id.columns,\n ...ifDefined('name', semanticModel.id.name),\n },\n }\n : {}),\n ...(checksForTable.length > 0 ? { checks: checksForTable } : {}),\n };\n\n let nsTables = tablesByNamespace[namespaceId];\n if (nsTables === undefined) {\n nsTables = {};\n tablesByNamespace[namespaceId] = nsTables;\n }\n if (nsTables[tableName] !== undefined) {\n throw new Error(\n `buildSqlContractFromDefinition: duplicate table \"${tableName}\" in namespace \"${namespaceId}\".`,\n );\n }\n nsTables[tableName] = tableInput;\n }\n\n // --- Build contract model ---\n\n const storageFields: Record<string, { readonly column: string }> = {};\n for (const [fieldName, columnName] of Object.entries(fieldToColumn)) {\n storageFields[fieldName] = { column: columnName };\n }\n\n const columnToField = new Map(\n Object.entries(fieldToColumn).map(([field, col]) => [col, field]),\n );\n const modelRelations: Record<string, ContractRelation> = {};\n for (const relation of semanticModel.relations ?? []) {\n // Cross-space relations have `spaceId` set — the target model lives in\n // a different contract space, so skip local model lookup and validation.\n if (relation.spaceId !== undefined) {\n const targetNamespaceId = relation.namespaceId ?? defaultNamespaceId;\n modelRelations[relation.fieldName] = {\n to: crossRef(relation.toModel, targetNamespaceId, relation.spaceId),\n // Cross-space belongsTo relations are always N:1 (the FK-owning side).\n cardinality: 'N:1',\n on: {\n localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col),\n // For cross-space targets the lowering carries field names directly\n // (no fieldToColumn map available for the remote model).\n targetFields: relation.on.childColumns,\n },\n };\n continue;\n }\n\n const targetModel = assertKnownTargetModel(\n modelsByName,\n modelsByCoordinate,\n semanticModel.modelName,\n relation.toModel,\n relation.toNamespaceId,\n 'Relation',\n );\n assertTargetTableMatches(semanticModel.modelName, targetModel, relation.toTable, 'Relation');\n\n const targetColumnToField = new Map(\n targetModel.fields.map((f) => [f.columnName, f.fieldName]),\n );\n\n const to = crossRef(\n relation.toModel,\n relation.toNamespaceId !== undefined && relation.toNamespaceId.length > 0\n ? relation.toNamespaceId\n : resolveModelNamespaceId(targetModel, modelNameToNamespaceId, defaultNamespaceId),\n );\n const on = {\n localFields: relation.on.parentColumns.map((col) => columnToField.get(col) ?? col),\n targetFields: relation.on.childColumns.map((col) => targetColumnToField.get(col) ?? col),\n };\n\n if (relation.cardinality === 'N:M') {\n if (!relation.through) {\n throw new Error(\n `Relation \"${semanticModel.modelName}.${relation.fieldName}\" with cardinality \"N:M\" requires through metadata`,\n );\n }\n modelRelations[relation.fieldName] = {\n to,\n cardinality: 'N:M',\n on,\n through: buildThroughDescriptor(\n relation.through,\n tableNamespaceByName,\n targetModel,\n semanticModel.modelName,\n relation.fieldName,\n defaultNamespaceId,\n ),\n };\n } else {\n modelRelations[relation.fieldName] = { to, cardinality: relation.cardinality, on };\n }\n }\n\n let namespaceModels = modelsByNamespace[namespaceId];\n if (namespaceModels === undefined) {\n namespaceModels = {};\n modelsByNamespace[namespaceId] = namespaceModels;\n }\n namespaceModels[semanticModel.modelName] = {\n storage: {\n table: tableName,\n namespaceId,\n fields: storageFields,\n },\n fields: domainFields,\n relations: modelRelations,\n };\n }\n\n // --- Assemble contract ---\n\n // Aggregate roots are keyed by bare storage table name. When two models in\n // different namespaces map to the same bare table name, the bare key would\n // collide (last write wins, silently dropping a root), so those entries fall\n // back to a namespace-qualified key. Single-namespace contracts never\n // collide and keep their bare keys unchanged.\n const rootTableNameCounts = new Map<string, number>();\n for (const entry of rootEntries) {\n rootTableNameCounts.set(entry.tableName, (rootTableNameCounts.get(entry.tableName) ?? 0) + 1);\n }\n const roots: Record<string, CrossReference> = {};\n for (const entry of rootEntries) {\n const key =\n (rootTableNameCounts.get(entry.tableName) ?? 0) > 1\n ? `${entry.namespaceId}.${entry.tableName}`\n : entry.tableName;\n roots[key] = entry.ref;\n }\n\n // Normalise raw codec-triple inputs to the `kind: 'codec-instance'`\n // discriminator shape before hashing so the storageHash matches the\n // persisted JSON envelope produced from the SqlStorage class instance\n // (which always carries the discriminator).\n const rawStorageTypes = definition.storageTypes ?? {};\n const documentTypes: Record<string, StorageTypeInstance> = Object.fromEntries(\n Object.entries(rawStorageTypes).map(([name, entry]) => {\n if ((entry as { kind?: unknown }).kind === 'codec-instance') return [name, entry];\n return [\n name,\n toStorageTypeInstance({\n codecId: entry.codecId,\n nativeType: entry.nativeType,\n typeParams: (entry as { typeParams?: Record<string, unknown> }).typeParams ?? {},\n }),\n ];\n }),\n );\n const namespaceCoordinateIds = collectStorageNamespaceCoordinateIds(definition);\n\n // Build per-namespace registries for `enumType()` handles.\n // All authored enums target the contract's default namespace.\n const domainEnumsByNs: Record<string, Record<string, ContractEnum>> = {};\n const storageValueSetsByNs: Record<string, Record<string, StorageValueSetInput>> = {};\n for (const [enumName, handle] of Object.entries(definition.enums ?? {})) {\n if (enumName !== handle.enumName) {\n throw new Error(\n `enum declaration key \"${enumName}\" must match enumType name \"${handle.enumName}\". Aliases are not supported.`,\n );\n }\n const nsId = defaultNamespaceId;\n let domainSlot = domainEnumsByNs[nsId];\n if (domainSlot === undefined) {\n domainSlot = {};\n domainEnumsByNs[nsId] = domainSlot;\n }\n domainSlot[enumName] = {\n codecId: handle.codecId,\n members: handle.enumMembers.map((m) => ({\n name: m.name,\n value: encodeViaCodec(m.value, handle.codecId, codecLookup),\n })),\n };\n\n let storageSlot = storageValueSetsByNs[nsId];\n if (storageSlot === undefined) {\n storageSlot = {};\n storageValueSetsByNs[nsId] = storageSlot;\n }\n storageSlot[enumName] = {\n kind: 'valueSet',\n values: handle.values.map((v) => encodeViaCodec(v, handle.codecId, codecLookup)),\n };\n }\n\n const { createNamespace } = definition;\n const namespaces = blindCast<\n SqlStorageInput['namespaces'],\n 'contract authoring materialises each namespace coordinate from the model set and explicit namespace list'\n >(\n Object.fromEntries(\n [...namespaceCoordinateIds].sort().map((id) => {\n const valueSetEntries = storageValueSetsByNs[id];\n const nsInput: SqlNamespaceTablesInput = {\n id,\n entries: {\n table: tablesByNamespace[id] ?? {},\n ...(valueSetEntries !== undefined && Object.keys(valueSetEntries).length > 0\n ? { valueSet: valueSetEntries }\n : {}),\n },\n };\n return [id, createNamespace ? createNamespace(nsInput) : buildSqlNamespace(nsInput)];\n }),\n ),\n );\n const storageWithoutHash = {\n ...(Object.keys(documentTypes).length > 0 ? { types: documentTypes } : {}),\n namespaces:\n defaultNamespaceId === UNBOUND_NAMESPACE_ID\n ? ensureUnboundNamespaceSlot(namespaces, createNamespace)\n : namespaces,\n };\n const storageHash: StorageHashBase<string> = definition.storageHash\n ? coreHash(definition.storageHash)\n : computeStorageHash({\n target,\n targetFamily,\n storage: storageWithoutHash as Record<string, unknown>,\n ...sqlContractCanonicalizationHooks,\n });\n const storage = new SqlStorage({ ...storageWithoutHash, storageHash });\n\n const executionSection =\n executionDefaults.length > 0\n ? {\n mutations: {\n defaults: executionDefaults.sort((a, b) => {\n const tableCompare = a.ref.table.localeCompare(b.ref.table);\n if (tableCompare !== 0) {\n return tableCompare;\n }\n return a.ref.column.localeCompare(b.ref.column);\n }),\n },\n }\n : undefined;\n\n const extensionNamespaces = definition.extensionPacks\n ? Object.values(definition.extensionPacks).map((pack) => pack.id)\n : undefined;\n\n const extensionPacks: Record<string, unknown> = { ...(definition.extensionPacks || {}) };\n if (extensionNamespaces) {\n for (const namespace of extensionNamespaces) {\n if (!Object.hasOwn(extensionPacks, namespace)) {\n extensionPacks[namespace] = {};\n }\n }\n }\n\n const extensionPackCapabilitySources = definition.extensionPacks\n ? Object.values(definition.extensionPacks).map(\n (pack) => pack.capabilities as CapabilityMatrix | undefined,\n )\n : [];\n const capabilities = mergeCapabilityMatrices(\n definition.target.capabilities as CapabilityMatrix | undefined,\n ...extensionPackCapabilitySources,\n );\n // Internal `profileHash` computation is unchanged from `origin/main`: it\n // continues to fingerprint the author-declared capability subset. With\n // `capabilities` removed from the `defineContract` input that subset is\n // now always empty, so the hash naturally stabilises at `hash({})`.\n const profileHash = computeProfileHash({\n target,\n targetFamily,\n capabilities: {},\n });\n\n const executionWithHash = executionSection\n ? {\n ...executionSection,\n executionHash: computeExecutionHash({ target, targetFamily, execution: executionSection }),\n }\n : undefined;\n\n const valueObjects: Record<string, ContractValueObject> | undefined =\n definition.valueObjects && definition.valueObjects.length > 0\n ? Object.fromEntries(\n definition.valueObjects.map((vo) => [\n vo.name,\n {\n fields: Object.fromEntries(\n vo.fields.map((f) => [\n f.fieldName,\n isValueObjectField(f)\n ? {\n type: { kind: 'valueObject' as const, name: f.valueObjectName },\n nullable: f.nullable,\n ...(f.many ? { many: true } : {}),\n }\n : {\n type: {\n kind: 'scalar' as const,\n codecId: f.descriptor.codecId,\n ...ifDefined('typeParams', f.descriptor.typeParams),\n },\n nullable: f.nullable,\n },\n ]),\n ),\n },\n ]),\n )\n : undefined;\n\n const domainNamespaceIds = new Set(Object.keys(modelsByNamespace));\n if (domainNamespaceIds.size === 0) {\n domainNamespaceIds.add(defaultNamespaceId);\n }\n if (valueObjects !== undefined) {\n domainNamespaceIds.add(defaultNamespaceId);\n }\n for (const nsId of Object.keys(domainEnumsByNs)) {\n domainNamespaceIds.add(nsId);\n }\n const domainNamespaces = Object.fromEntries(\n [...domainNamespaceIds].sort().map((namespaceId) => {\n const modelsInNs = modelsByNamespace[namespaceId] ?? {};\n const enumsInNs = domainEnumsByNs[namespaceId];\n const namespaceSlice = {\n models: modelsInNs,\n ...(namespaceId === defaultNamespaceId && valueObjects !== undefined\n ? { valueObjects }\n : {}),\n ...(enumsInNs !== undefined && Object.keys(enumsInNs).length > 0\n ? { enum: enumsInNs }\n : {}),\n };\n return [namespaceId, namespaceSlice];\n }),\n );\n\n const contract: Contract<SqlStorage> = {\n target,\n targetFamily,\n ...ifDefined('defaultControlPolicy', definition.defaultControlPolicy),\n domain: { namespaces: domainNamespaces },\n roots,\n storage,\n ...(executionWithHash ? { execution: executionWithHash } : {}),\n extensionPacks,\n capabilities,\n profileHash,\n meta: {},\n };\n\n assertStorageSemantics(definition, contract);\n\n return contract;\n}\n"],"mappings":";;;;;;;;;;;;AA6DA,SAAS,eAAe,OAAgB,SAAiB,aAAsC;CAC7F,MAAM,QAAQ,aAAa,IAAI,OAAO;CACtC,IAAI,OACF,OAAO,MAAM,WAAW,KAAK;CAE/B,OAAO,UAGL,KAAK;AACT;AAEA,SAAS,oBACP,cACA,SACA,aACe;CACf,IAAI,aAAa,SAAS,YACxB,OAAO;EAAE,MAAM;EAAY,YAAY,aAAa;CAAW;CAEjE,OAAO;EACL,MAAM;EACN,OAAO,eAAe,aAAa,OAAO,SAAS,WAAW;CAChE;AACF;AAEA,SAAS,uBACP,YACA,UACM;CACN,MAAM,iBAAiB,yBAAyB,SAAS,OAAO;CAChE,IAAI,eAAe,SA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BAAmB,IAAI,IAAI;CAE7B,MAAM,mBAAmB,OAAO,YAC9B,CAAC,GAAG,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,gBAAgB;EAClD,MAAM,aAAa,kBAAkB,gBAAgB,CAAC;EACtD,MAAM,YAAY,gBAAgB;EAUlC,OAAO,CAAC,aAAa;GARnB,QAAQ;GACR,GAAI,gBAAgB,sBAAsB,iBAAiB,KAAA,IACvD,EAAE,aAAa,IACf,CAAC;GACL,GAAI,cAAc,KAAA,KAAa,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS,IAC3D,EAAE,MAAM,UAAU,IAClB,CAAC;EAE2B,CAAC;CACrC,CAAC,CACH;CAEA,MAAM,WAAiC;EACrC;EACA;EACA,GAAG,UAAU,wBAAwB,WAAW,oBAAoB;EACpE,QAAQ,EAAE,YAAY,iBAAiB;EACvC;EACA;EACA,GAAI,oBAAoB,EAAE,WAAW,kBAAkB,IAAI,CAAC;EAC5D;EACA;EACA;EACA,MAAM,CAAC;CACT;CAEA,uBAAuB,YAAY,QAAQ;CAE3C,OAAO;AACT"} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
771647
7.06%9201
8.29%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated