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

@prisma-next/contract

Package Overview
Maintainers
4
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/contract - npm Package Compare versions

Source code not available
We could not scan this package. Some page functionalities have been disabled
Comparing version
0.16.0-dev.30
to
0.16.0-dev.31
+14
dist/contract-validation-error-DEiWp_EI.mjs
//#region src/contract-validation-error.ts
var ContractValidationError = class extends Error {
code = "CONTRACT.VALIDATION_FAILED";
phase;
constructor(message, phase) {
super(message);
this.name = "ContractValidationError";
this.phase = phase;
}
};
//#endregion
export { ContractValidationError as t };
//# sourceMappingURL=contract-validation-error-DEiWp_EI.mjs.map
{"version":3,"file":"contract-validation-error-DEiWp_EI.mjs","names":[],"sources":["../src/contract-validation-error.ts"],"sourcesContent":["export type ContractValidationPhase = 'structural' | 'domain' | 'storage';\n\nexport class ContractValidationError extends Error {\n readonly code = 'CONTRACT.VALIDATION_FAILED';\n readonly phase: ContractValidationPhase;\n\n constructor(message: string, phase: ContractValidationPhase) {\n super(message);\n this.name = 'ContractValidationError';\n this.phase = phase;\n }\n}\n"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF"}
{"version":3,"file":"contract-validation-error.d.mts","names":[],"sources":["../src/contract-validation-error.ts"],"mappings":";KAAY;cAEC,gCAAgC;WAClC;WACA,OAAO;cAEJ,iBAAiB,OAAO"}
import { structuredError } from "@prisma-next/utils/structured-error";
//#region src/contract-errors.ts
function contractError(code, message, options) {
return structuredError(code, message, options);
}
//#endregion
//#region src/default-namespace.ts
/**
* Reserved sentinel domain namespace id for the late-bound application-domain
* slot — the namespace a model lands in when it is authored without an explicit
* namespace. This is target-agnostic: targets that allow un-namespaced
* authoring (e.g. Mongo, SQLite) declare this id as their default on the target
* descriptor; the framework names the sentinel, never a target. Mirrors
* storage's `UNBOUND_NAMESPACE_ID` on the domain plane.
*/
const UNBOUND_DOMAIN_NAMESPACE_ID = "__unbound__";
/**
* Resolve the single domain namespace of a single-namespace contract.
*
* Bare-name access (`db.User`) reads "the contract's one namespace". Every
* contract in scope today declares exactly one domain namespace, so this is
* exact — there is nothing to infer. A contract that declares more than one
* namespace is ambiguous for a bare name, so rather than silently pick one this
* throws; cross-namespace selection is made explicit (TML-2550).
*/
function soleDomainNamespaceId(domain) {
const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);
if (soleNamespaceId === void 0) throw contractError("CONTRACT.NAMESPACE_INVALID", "domain has no namespaces", { meta: { reason: "no-domain-namespaces" } });
if (rest.length > 0) {
const all = [soleNamespaceId, ...rest];
throw contractError("CONTRACT.NAMESPACE_INVALID", `bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(", ")}); select a namespace explicitly`, { meta: {
reason: "multiple-domain-namespaces",
namespaceIds: all
} });
}
return soleNamespaceId;
}
//#endregion
export { soleDomainNamespaceId as n, contractError as r, UNBOUND_DOMAIN_NAMESPACE_ID as t };
//# sourceMappingURL=default-namespace-Z7Meqbw0.mjs.map
{"version":3,"file":"default-namespace-Z7Meqbw0.mjs","names":[],"sources":["../src/contract-errors.ts","../src/default-namespace.ts"],"sourcesContent":["import type { StructuredError, StructuredErrorOptions } from '@prisma-next/utils/structured-error';\nimport { structuredError } from '@prisma-next/utils/structured-error';\n\nexport type ContractCode = `CONTRACT.${ContractSubcode}`;\n\ntype ContractSubcode = 'NAMESPACE_INVALID';\n\nexport function contractError(\n code: ContractCode,\n message: string,\n options?: StructuredErrorOptions,\n): StructuredError {\n return structuredError(code, message, options);\n}\n","import { contractError } from './contract-errors';\n\n/**\n * Reserved sentinel domain namespace id for the late-bound application-domain\n * slot — the namespace a model lands in when it is authored without an explicit\n * namespace. This is target-agnostic: targets that allow un-namespaced\n * authoring (e.g. Mongo, SQLite) declare this id as their default on the target\n * descriptor; the framework names the sentinel, never a target. Mirrors\n * storage's `UNBOUND_NAMESPACE_ID` on the domain plane.\n */\nexport const UNBOUND_DOMAIN_NAMESPACE_ID = '__unbound__' as const;\n\n/**\n * Resolve the single domain namespace of a single-namespace contract.\n *\n * Bare-name access (`db.User`) reads \"the contract's one namespace\". Every\n * contract in scope today declares exactly one domain namespace, so this is\n * exact — there is nothing to infer. A contract that declares more than one\n * namespace is ambiguous for a bare name, so rather than silently pick one this\n * throws; cross-namespace selection is made explicit (TML-2550).\n */\nexport function soleDomainNamespaceId(domain: {\n readonly namespaces: Readonly<Record<string, unknown>>;\n}): string {\n const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);\n if (soleNamespaceId === undefined) {\n throw contractError('CONTRACT.NAMESPACE_INVALID', 'domain has no namespaces', {\n meta: { reason: 'no-domain-namespaces' },\n });\n }\n if (rest.length > 0) {\n const all = [soleNamespaceId, ...rest];\n throw contractError(\n 'CONTRACT.NAMESPACE_INVALID',\n `bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(', ')}); select a namespace explicitly`,\n { meta: { reason: 'multiple-domain-namespaces', namespaceIds: all } },\n );\n }\n return soleNamespaceId;\n}\n"],"mappings":";;AAOA,SAAgB,cACd,MACA,SACA,SACiB;CACjB,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC/C;;;;;;;;;;;ACHA,MAAa,8BAA8B;;;;;;;;;;AAW3C,SAAgB,sBAAsB,QAE3B;CACT,MAAM,CAAC,iBAAiB,GAAG,QAAQ,OAAO,KAAK,OAAO,UAAU;CAChE,IAAI,oBAAoB,KAAA,GACtB,MAAM,cAAc,8BAA8B,4BAA4B,EAC5E,MAAM,EAAE,QAAQ,uBAAuB,EACzC,CAAC;CAEH,IAAI,KAAK,SAAS,GAAG;EACnB,MAAM,MAAM,CAAC,iBAAiB,GAAG,IAAI;EACrC,MAAM,cACJ,8BACA,qEAAqE,IAAI,OAAO,IAAI,IAAI,KAAK,IAAI,EAAE,mCACnG,EAAE,MAAM;GAAE,QAAQ;GAA8B,cAAc;EAAI,EAAE,CACtE;CACF;CACA,OAAO;AACT"}
import type { StructuredError, StructuredErrorOptions } from '@prisma-next/utils/structured-error';
import { structuredError } from '@prisma-next/utils/structured-error';
export type ContractCode = `CONTRACT.${ContractSubcode}`;
type ContractSubcode = 'NAMESPACE_INVALID';
export function contractError(
code: ContractCode,
message: string,
options?: StructuredErrorOptions,
): StructuredError {
return structuredError(code, message, options);
}
+10
-2

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

import { n as ContractValidationPhase, r as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-D7g0kmcc.mjs";
export { ContractValidationError, type ContractValidationPhase, DomainNamespaceResolutionError };
//#region src/contract-validation-error.d.ts
type ContractValidationPhase = 'structural' | 'domain' | 'storage';
declare class ContractValidationError extends Error {
readonly code = "CONTRACT.VALIDATION_FAILED";
readonly phase: ContractValidationPhase;
constructor(message: string, phase: ContractValidationPhase);
}
//#endregion
export { ContractValidationError, type ContractValidationPhase };
//# sourceMappingURL=contract-validation-error.d.mts.map
+2
-2

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

import { n as DomainNamespaceResolutionError, t as ContractValidationError } from "./contract-validation-error-BFA66rwU.mjs";
export { ContractValidationError, DomainNamespaceResolutionError };
import { t as ContractValidationError } from "./contract-validation-error-DEiWp_EI.mjs";
export { ContractValidationError };

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

import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-rpdJeUMq.mjs";
import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-Z7Meqbw0.mjs";
export { UNBOUND_DOMAIN_NAMESPACE_ID, soleDomainNamespaceId };
import { a as effectiveControlPolicy, i as ControlPolicy, n as ContractExecutionSection, r as ContractValueObjectDefinitions, t as Contract } from "./contract-types-CkdMH7F7.mjs";
import { $ as executionHash, A as ColumnDefaultLiteralValue, B as FieldType, C as UnionFieldType, D as Brand, E as $, F as ExecutionMutationDefault, G as PlanMeta, H as JsonPrimitive, I as ExecutionMutationDefaultPhases, J as StorageBase, K as ProfileHashBase, L as ExecutionMutationDefaultValue, M as DocCollection, N as DocIndex, O as ColumnDefault, P as ExecutionHashBase, Q as coreHash, R as ExecutionSection, S as ScalarFieldType, T as ValueSetRef, U as JsonValue, V as GeneratedValueSpec, W as LedgerEntryRecord, X as StorageHashBase, Y as StorageEntitySlot, Z as StorageNamespace, _ as ContractValueObject, a as ContractEmbedRelation, at as CrossReferenceSchema, b as ModelStorageBase, c as ContractFieldType, ct as asNamespaceId, d as ContractModelBase, et as isColumnDefault, f as ContractNonJunctionRelation, g as ContractRelationThrough, h as ContractRelationOn, i as ContractDiscriminator, it as CrossReference, j as ContractMarkerRecord, k as ColumnDefaultLiteralInputValue, l as ContractManyToManyRelation, m as ContractRelation, n as ApplicationDomainNamespace, nt as isExecutionMutationDefaultValue, o as ContractEnum, ot as crossRef, p as ContractReferenceRelation, q as Source, r as ContractWithDomain, rt as profileHash, s as ContractField, st as NamespaceId, t as ApplicationDomain, tt as isColumnDefaultLiteralInputValue, u as ContractModel, v as ContractVariantEntry, w as ValueObjectFieldType, x as ReferenceRelationKeys, y as EmbedRelationKeys, z as Expr } from "./domain-envelope-D6Wn9AmZ.mjs";
import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-D5X_k6hJ.mjs";
import { r as DomainNamespaceResolutionError } from "./contract-validation-error-D7g0kmcc.mjs";
import { n as resolveDomainModel, t as ResolvedDomainModel } from "./resolve-domain-model-BVSb5wS5.mjs";

@@ -19,3 +18,3 @@ //#region src/domain-namespace-access.d.ts

//#endregion
export { type $, type ApplicationDomain, type ApplicationDomainNamespace, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractEnum, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractManyToManyRelation, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractNonJunctionRelation, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractRelationThrough, type ContractValueObject, type ContractValueObjectDefinitions, type ContractVariantEntry, type ContractWithDomain, type ControlPolicy, type CrossReference, CrossReferenceSchema, type DocCollection, type DocIndex, DomainNamespaceResolutionError, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultPhases, type ExecutionMutationDefaultValue, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type LedgerEntryRecord, type ModelStorageBase, type NamespaceId, type PlanMeta, type ProfileHashBase, type ReferenceRelationKeys, type ResolvedDomainModel, type ScalarFieldType, type Source, type StorageBase, type StorageEntitySlot, type StorageHashBase, type StorageNamespace, UNBOUND_DOMAIN_NAMESPACE_ID, type UnionFieldType, type ValueObjectFieldType, type ValueSetRef, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
export { type $, type ApplicationDomain, type ApplicationDomainNamespace, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type Contract, type ContractDiscriminator, type ContractEmbedRelation, type ContractEnum, type ContractExecutionSection, type ContractField, type ContractFieldType, type ContractManyToManyRelation, type ContractMarkerRecord, type ContractModel, type ContractModelBase, type ContractNonJunctionRelation, type ContractReferenceRelation, type ContractRelation, type ContractRelationOn, type ContractRelationThrough, type ContractValueObject, type ContractValueObjectDefinitions, type ContractVariantEntry, type ContractWithDomain, type ControlPolicy, type CrossReference, CrossReferenceSchema, type DocCollection, type DocIndex, type EmbedRelationKeys, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultPhases, type ExecutionMutationDefaultValue, type ExecutionSection, type Expr, type FieldType, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type LedgerEntryRecord, type ModelStorageBase, type NamespaceId, type PlanMeta, type ProfileHashBase, type ReferenceRelationKeys, type ResolvedDomainModel, type ScalarFieldType, type Source, type StorageBase, type StorageEntitySlot, type StorageHashBase, type StorageNamespace, UNBOUND_DOMAIN_NAMESPACE_ID, type UnionFieldType, type ValueObjectFieldType, type ValueSetRef, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
//# sourceMappingURL=types.d.mts.map

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

{"version":3,"file":"types.d.mts","names":[],"sources":["../src/domain-namespace-access.ts"],"mappings":";;;;;;;;;;;iBAUgB,+BACd,QAAQ,oBACP,eAAe;;;;;iBAeF,qCACd,QAAQ,oBACP,eAAe"}
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/domain-namespace-access.ts"],"mappings":";;;;;;;;;;iBAUgB,+BACd,QAAQ,oBACP,eAAe;;;;;iBAiBF,qCACd,QAAQ,oBACP,eAAe"}

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

import { n as DomainNamespaceResolutionError } from "./contract-validation-error-BFA66rwU.mjs";
import { n as soleDomainNamespaceId, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-rpdJeUMq.mjs";
import { n as soleDomainNamespaceId, r as contractError, t as UNBOUND_DOMAIN_NAMESPACE_ID } from "./default-namespace-Z7Meqbw0.mjs";
import { t as resolveDomainModel } from "./resolve-domain-model-BovPAsW2.mjs";

@@ -45,3 +44,6 @@ import { t as asNamespaceId } from "./namespace-id-CUxYd4KL.mjs";

const domainNamespace = domain.namespaces[namespaceId];
if (domainNamespace === void 0) throw new DomainNamespaceResolutionError(`domain namespace "${namespaceId}" is not present on the contract`);
if (domainNamespace === void 0) throw contractError("CONTRACT.NAMESPACE_INVALID", `domain namespace "${namespaceId}" is not present on the contract`, { meta: {
reason: "domain-namespace-missing",
namespaceId
} });
return domainNamespace.models;

@@ -100,4 +102,4 @@ }

//#endregion
export { CrossReferenceSchema, DomainNamespaceResolutionError, UNBOUND_DOMAIN_NAMESPACE_ID, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
export { CrossReferenceSchema, UNBOUND_DOMAIN_NAMESPACE_ID, asNamespaceId, coreHash, crossRef, domainModelsAtDefaultNamespace, domainValueObjectsAtDefaultNamespace, effectiveControlPolicy, executionHash, isColumnDefault, isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue, profileHash, resolveDomainModel, soleDomainNamespaceId };
//# sourceMappingURL=types.mjs.map

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

{"version":3,"file":"types.mjs","names":[],"sources":["../src/control-policy.ts","../src/cross-reference.ts","../src/domain-namespace-access.ts","../src/types.ts"],"sourcesContent":["/**\n * Governance posture for a storage-plane node or for the contract as a whole.\n *\n * - `managed` — Prisma Next owns the full lifecycle (DDL, migrations, verification).\n * - `tolerated` — node was found in the database but is not schema-managed; Prisma Next\n * leaves it untouched while tracking its existence.\n * - `external` — node is owned by an external system; Prisma Next never emits DDL for it.\n * - `observed` — read-only access; Prisma Next does not write to or migrate the node.\n */\nexport type ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed';\n\n/**\n * Resolves the effective control policy for a storage-plane node.\n *\n * Precedence: node-level value → contract default → `'managed'`.\n *\n * Both parameters are optional raw values so this function stays node-type-agnostic\n * and can be called by any consumer (verifier, planner, etc.) without importing IR classes.\n */\nexport function effectiveControlPolicy(\n nodeControl: ControlPolicy | undefined,\n defaultControlPolicy: ControlPolicy | undefined,\n): ControlPolicy {\n return nodeControl ?? defaultControlPolicy ?? 'managed';\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport { type Type, type } from 'arktype';\nimport { asNamespaceId, type NamespaceId } from './namespace-id';\n\nexport interface CrossReference {\n readonly namespace: NamespaceId;\n readonly model: string;\n /**\n * Contract-space identity for cross-space relations. When present, the\n * referenced model lives in a different contract space. Absent for local\n * (same-space) relations.\n */\n readonly space?: string;\n}\n\nexport const CrossReferenceSchema = /* @__PURE__ */ blindCast<\n Type<CrossReference>,\n 'namespace is validated as string at runtime and branded to NamespaceId by asNamespaceId in crossRef(); the schema accepts plain strings but the public type reflects the branded shape'\n>(\n /* @__PURE__ */ type({\n '+': 'reject',\n namespace: 'string',\n model: 'string',\n 'space?': 'string',\n }),\n);\n\nconst DEFAULT_CROSS_REF_NAMESPACE = '__unbound__';\n\nexport function crossRef(\n model: string,\n namespace: string = DEFAULT_CROSS_REF_NAMESPACE,\n space?: string,\n): CrossReference {\n return {\n namespace: asNamespaceId(namespace),\n model,\n ...(space !== undefined ? { space } : {}),\n };\n}\n","import { DomainNamespaceResolutionError } from './contract-validation-error';\nimport { soleDomainNamespaceId } from './default-namespace';\nimport type { ApplicationDomain } from './domain-envelope';\nimport type { ContractModelBase, ContractValueObject } from './domain-types';\n\n/**\n * Models map for the contract's single domain namespace. Throws when the\n * contract does not declare exactly one namespace — bare-name access is\n * ambiguous across namespaces and must be qualified explicitly (TML-2550).\n */\nexport function domainModelsAtDefaultNamespace(\n domain: ApplicationDomain,\n): Record<string, ContractModelBase> {\n const namespaceId = soleDomainNamespaceId(domain);\n const domainNamespace = domain.namespaces[namespaceId];\n if (domainNamespace === undefined) {\n throw new DomainNamespaceResolutionError(\n `domain namespace \"${namespaceId}\" is not present on the contract`,\n );\n }\n return domainNamespace.models;\n}\n\n/**\n * Value objects for the contract's single domain namespace, when present.\n * Throws when the contract does not declare exactly one namespace.\n */\nexport function domainValueObjectsAtDefaultNamespace(\n domain: ApplicationDomain,\n): Record<string, ContractValueObject> | undefined {\n return domain.namespaces[soleDomainNamespaceId(domain)]?.valueObjects;\n}\n","/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function executionHash<const T extends string>(value: T): ExecutionHashBase<T> {\n return value as ExecutionHashBase<T>;\n}\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\n/**\n * One entity-kind slot in a namespace — a map of entity name to entry.\n * Values are opaque at the foundation layer; family and target concretions\n * refine them to typed IR classes.\n */\nexport type StorageEntitySlot = Readonly<Record<string, unknown>>;\n\n/**\n * Plain-data namespace entry in a storage block. Every hydrated contract\n * carries at least `id` plus entity-kind slot maps under `entries`\n * (`table`, `collection`, …). Foundation declares only this shape — no IR\n * machinery.\n */\nexport interface StorageNamespace {\n readonly id: string;\n readonly entries: Readonly<Record<string, StorageEntitySlot>>;\n}\n\n/**\n * Base type for family-specific storage blocks.\n * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the\n * storage hash alongside family-specific data (tables, collections, etc.).\n *\n * The `namespaces` map is carried by every hydrated storage block. Serialized\n * envelope shape is target-owned; this types the in-memory contract after\n * `deserializeContract`.\n */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, StorageNamespace>>;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type ColumnDefaultLiteralValue = JsonValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;\n\n/**\n * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers\n * resolve template values from caller-supplied args (typed `unknown` at the\n * boundary) and need to validate before constructing a `ColumnDefault`.\n * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`\n * instances. Rejects functions, class instances (other than `Date`),\n * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.\n */\nexport function isColumnDefaultLiteralInputValue(\n value: unknown,\n): value is ColumnDefaultLiteralInputValue {\n if (value === null) return true;\n const t = typeof value;\n if (t === 'string' || t === 'number' || t === 'boolean') return true;\n if (value instanceof Date) return true;\n if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);\n if (t === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return Object.values(value as Record<string, unknown>).every(isColumnDefaultLiteralInputValue);\n }\n return false;\n}\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport function isColumnDefault(value: unknown): value is ColumnDefault {\n if (typeof value !== 'object' || value === null) return false;\n const kind = (value as { kind?: unknown }).kind;\n if (kind === 'literal') {\n return 'value' in value;\n }\n if (kind === 'function') {\n return typeof (value as { expression?: unknown }).expression === 'string';\n }\n return false;\n}\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport function isExecutionMutationDefaultValue(\n value: unknown,\n): value is ExecutionMutationDefaultValue {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {\n kind?: unknown;\n id?: unknown;\n params?: unknown;\n };\n if (candidate.kind !== 'generator') return false;\n if (typeof candidate.id !== 'string') return false;\n if (\n candidate.params !== undefined &&\n (typeof candidate.params !== 'object' ||\n candidate.params === null ||\n Array.isArray(candidate.params))\n ) {\n return false;\n }\n return true;\n}\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly namespace: string; readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\n/**\n * `ExecutionMutationDefault` minus its `ref` — the per-field phases value\n * authoring layers attach to a column before the column ref is known.\n */\nexport type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;\n\nexport type ExecutionSection<THash extends string = string> = {\n readonly executionHash: ExecutionHashBase<THash>;\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n readonly [key: string]: unknown;\n };\n}\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n readonly invariants: readonly string[];\n}\n\n/**\n * One applied migration edge from the per-space ledger journal.\n * Returned by `readLedger` in append (apply) order.\n */\nexport interface LedgerEntryRecord {\n readonly space: string;\n readonly migrationName: string;\n readonly migrationHash: string;\n readonly from: string | null;\n readonly to: string;\n readonly appliedAt: Date;\n readonly operationCount: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,uBACd,aACA,sBACe;CACf,OAAO,eAAe,wBAAwB;AAChD;;;ACTA,MAAa,uBAAuC,0BAIlC,qBAAK;CACnB,KAAK;CACL,WAAW;CACX,OAAO;CACP,UAAU;AACZ,CAAC,CACH;AAEA,MAAM,8BAA8B;AAEpC,SAAgB,SACd,OACA,YAAoB,6BACpB,OACgB;CAChB,OAAO;EACL,WAAW,cAAc,SAAS;EAClC;EACA,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;CACzC;AACF;;;;;;;;AC7BA,SAAgB,+BACd,QACmC;CACnC,MAAM,cAAc,sBAAsB,MAAM;CAChD,MAAM,kBAAkB,OAAO,WAAW;CAC1C,IAAI,oBAAoB,KAAA,GACtB,MAAM,IAAI,+BACR,qBAAqB,YAAY,iCACnC;CAEF,OAAO,gBAAgB;AACzB;;;;;AAMA,SAAgB,qCACd,QACiD;CACjD,OAAO,OAAO,WAAW,sBAAsB,MAAM,EAAE,EAAE;AAC3D;;;ACAA,SAAgB,cAAsC,OAAgC;CACpF,OAAO;AACT;AAEA,SAAgB,SAAiC,OAA8B;CAC7E,OAAO;AACT;AASA,SAAgB,YAAoC,OAA8B;CAChF,OAAO;AACT;;;;;;;;;AAiEA,SAAgB,iCACd,OACyC;CACzC,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,IAAI,OAAO;CACjB,IAAI,MAAM,YAAY,MAAM,YAAY,MAAM,WAAW,OAAO;CAChE,IAAI,iBAAiB,MAAM,OAAO;CAClC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,MAAM,gCAAgC;CAC7E,IAAI,MAAM,YAAY,OAAO,eAAe,KAAK,MAAM,OAAO,WAC5D,OAAO,OAAO,OAAO,KAAgC,CAAC,CAAC,MAAM,gCAAgC;CAE/F,OAAO;AACT;AASA,SAAgB,gBAAgB,OAAwC;CACtE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,OAAQ,MAA6B;CAC3C,IAAI,SAAS,WACX,OAAO,WAAW;CAEpB,IAAI,SAAS,YACX,OAAO,OAAQ,MAAmC,eAAe;CAEnE,OAAO;AACT;AAQA,SAAgB,gCACd,OACwC;CACxC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,YAAY;CAKlB,IAAI,UAAU,SAAS,aAAa,OAAO;CAC3C,IAAI,OAAO,UAAU,OAAO,UAAU,OAAO;CAC7C,IACE,UAAU,WAAW,KAAA,MACpB,OAAO,UAAU,WAAW,YAC3B,UAAU,WAAW,QACrB,MAAM,QAAQ,UAAU,MAAM,IAEhC,OAAO;CAET,OAAO;AACT"}
{"version":3,"file":"types.mjs","names":[],"sources":["../src/control-policy.ts","../src/cross-reference.ts","../src/domain-namespace-access.ts","../src/types.ts"],"sourcesContent":["/**\n * Governance posture for a storage-plane node or for the contract as a whole.\n *\n * - `managed` — Prisma Next owns the full lifecycle (DDL, migrations, verification).\n * - `tolerated` — node was found in the database but is not schema-managed; Prisma Next\n * leaves it untouched while tracking its existence.\n * - `external` — node is owned by an external system; Prisma Next never emits DDL for it.\n * - `observed` — read-only access; Prisma Next does not write to or migrate the node.\n */\nexport type ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed';\n\n/**\n * Resolves the effective control policy for a storage-plane node.\n *\n * Precedence: node-level value → contract default → `'managed'`.\n *\n * Both parameters are optional raw values so this function stays node-type-agnostic\n * and can be called by any consumer (verifier, planner, etc.) without importing IR classes.\n */\nexport function effectiveControlPolicy(\n nodeControl: ControlPolicy | undefined,\n defaultControlPolicy: ControlPolicy | undefined,\n): ControlPolicy {\n return nodeControl ?? defaultControlPolicy ?? 'managed';\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport { type Type, type } from 'arktype';\nimport { asNamespaceId, type NamespaceId } from './namespace-id';\n\nexport interface CrossReference {\n readonly namespace: NamespaceId;\n readonly model: string;\n /**\n * Contract-space identity for cross-space relations. When present, the\n * referenced model lives in a different contract space. Absent for local\n * (same-space) relations.\n */\n readonly space?: string;\n}\n\nexport const CrossReferenceSchema = /* @__PURE__ */ blindCast<\n Type<CrossReference>,\n 'namespace is validated as string at runtime and branded to NamespaceId by asNamespaceId in crossRef(); the schema accepts plain strings but the public type reflects the branded shape'\n>(\n /* @__PURE__ */ type({\n '+': 'reject',\n namespace: 'string',\n model: 'string',\n 'space?': 'string',\n }),\n);\n\nconst DEFAULT_CROSS_REF_NAMESPACE = '__unbound__';\n\nexport function crossRef(\n model: string,\n namespace: string = DEFAULT_CROSS_REF_NAMESPACE,\n space?: string,\n): CrossReference {\n return {\n namespace: asNamespaceId(namespace),\n model,\n ...(space !== undefined ? { space } : {}),\n };\n}\n","import { contractError } from './contract-errors';\nimport { soleDomainNamespaceId } from './default-namespace';\nimport type { ApplicationDomain } from './domain-envelope';\nimport type { ContractModelBase, ContractValueObject } from './domain-types';\n\n/**\n * Models map for the contract's single domain namespace. Throws when the\n * contract does not declare exactly one namespace — bare-name access is\n * ambiguous across namespaces and must be qualified explicitly (TML-2550).\n */\nexport function domainModelsAtDefaultNamespace(\n domain: ApplicationDomain,\n): Record<string, ContractModelBase> {\n const namespaceId = soleDomainNamespaceId(domain);\n const domainNamespace = domain.namespaces[namespaceId];\n if (domainNamespace === undefined) {\n throw contractError(\n 'CONTRACT.NAMESPACE_INVALID',\n `domain namespace \"${namespaceId}\" is not present on the contract`,\n { meta: { reason: 'domain-namespace-missing', namespaceId } },\n );\n }\n return domainNamespace.models;\n}\n\n/**\n * Value objects for the contract's single domain namespace, when present.\n * Throws when the contract does not declare exactly one namespace.\n */\nexport function domainValueObjectsAtDefaultNamespace(\n domain: ApplicationDomain,\n): Record<string, ContractValueObject> | undefined {\n return domain.namespaces[soleDomainNamespaceId(domain)]?.valueObjects;\n}\n","/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function executionHash<const T extends string>(value: T): ExecutionHashBase<T> {\n return value as ExecutionHashBase<T>;\n}\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\n/**\n * One entity-kind slot in a namespace — a map of entity name to entry.\n * Values are opaque at the foundation layer; family and target concretions\n * refine them to typed IR classes.\n */\nexport type StorageEntitySlot = Readonly<Record<string, unknown>>;\n\n/**\n * Plain-data namespace entry in a storage block. Every hydrated contract\n * carries at least `id` plus entity-kind slot maps under `entries`\n * (`table`, `collection`, …). Foundation declares only this shape — no IR\n * machinery.\n */\nexport interface StorageNamespace {\n readonly id: string;\n readonly entries: Readonly<Record<string, StorageEntitySlot>>;\n}\n\n/**\n * Base type for family-specific storage blocks.\n * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the\n * storage hash alongside family-specific data (tables, collections, etc.).\n *\n * The `namespaces` map is carried by every hydrated storage block. Serialized\n * envelope shape is target-owned; this types the in-memory contract after\n * `deserializeContract`.\n */\nexport interface StorageBase<THash extends string = string> {\n readonly storageHash: StorageHashBase<THash>;\n readonly namespaces: Readonly<Record<string, StorageNamespace>>;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type ColumnDefaultLiteralValue = JsonValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;\n\n/**\n * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers\n * resolve template values from caller-supplied args (typed `unknown` at the\n * boundary) and need to validate before constructing a `ColumnDefault`.\n * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`\n * instances. Rejects functions, class instances (other than `Date`),\n * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.\n */\nexport function isColumnDefaultLiteralInputValue(\n value: unknown,\n): value is ColumnDefaultLiteralInputValue {\n if (value === null) return true;\n const t = typeof value;\n if (t === 'string' || t === 'number' || t === 'boolean') return true;\n if (value instanceof Date) return true;\n if (Array.isArray(value)) return value.every(isColumnDefaultLiteralInputValue);\n if (t === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return Object.values(value as Record<string, unknown>).every(isColumnDefaultLiteralInputValue);\n }\n return false;\n}\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport function isColumnDefault(value: unknown): value is ColumnDefault {\n if (typeof value !== 'object' || value === null) return false;\n const kind = (value as { kind?: unknown }).kind;\n if (kind === 'literal') {\n return 'value' in value;\n }\n if (kind === 'function') {\n return typeof (value as { expression?: unknown }).expression === 'string';\n }\n return false;\n}\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport function isExecutionMutationDefaultValue(\n value: unknown,\n): value is ExecutionMutationDefaultValue {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {\n kind?: unknown;\n id?: unknown;\n params?: unknown;\n };\n if (candidate.kind !== 'generator') return false;\n if (typeof candidate.id !== 'string') return false;\n if (\n candidate.params !== undefined &&\n (typeof candidate.params !== 'object' ||\n candidate.params === null ||\n Array.isArray(candidate.params))\n ) {\n return false;\n }\n return true;\n}\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly namespace: string; readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\n/**\n * `ExecutionMutationDefault` minus its `ref` — the per-field phases value\n * authoring layers attach to a column before the column ref is known.\n */\nexport type ExecutionMutationDefaultPhases = Omit<ExecutionMutationDefault, 'ref'>;\n\nexport type ExecutionSection<THash extends string = string> = {\n readonly executionHash: ExecutionHashBase<THash>;\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n readonly [key: string]: unknown;\n };\n}\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n readonly invariants: readonly string[];\n}\n\n/**\n * One applied migration edge from the per-space ledger journal.\n * Returned by `readLedger` in append (apply) order.\n */\nexport interface LedgerEntryRecord {\n readonly space: string;\n readonly migrationName: string;\n readonly migrationHash: string;\n readonly from: string | null;\n readonly to: string;\n readonly appliedAt: Date;\n readonly operationCount: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,uBACd,aACA,sBACe;CACf,OAAO,eAAe,wBAAwB;AAChD;;;ACTA,MAAa,uBAAuC,0BAIlC,qBAAK;CACnB,KAAK;CACL,WAAW;CACX,OAAO;CACP,UAAU;AACZ,CAAC,CACH;AAEA,MAAM,8BAA8B;AAEpC,SAAgB,SACd,OACA,YAAoB,6BACpB,OACgB;CAChB,OAAO;EACL,WAAW,cAAc,SAAS;EAClC;EACA,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;CACzC;AACF;;;;;;;;AC7BA,SAAgB,+BACd,QACmC;CACnC,MAAM,cAAc,sBAAsB,MAAM;CAChD,MAAM,kBAAkB,OAAO,WAAW;CAC1C,IAAI,oBAAoB,KAAA,GACtB,MAAM,cACJ,8BACA,qBAAqB,YAAY,mCACjC,EAAE,MAAM;EAAE,QAAQ;EAA4B;CAAY,EAAE,CAC9D;CAEF,OAAO,gBAAgB;AACzB;;;;;AAMA,SAAgB,qCACd,QACiD;CACjD,OAAO,OAAO,WAAW,sBAAsB,MAAM,EAAE,EAAE;AAC3D;;;ACFA,SAAgB,cAAsC,OAAgC;CACpF,OAAO;AACT;AAEA,SAAgB,SAAiC,OAA8B;CAC7E,OAAO;AACT;AASA,SAAgB,YAAoC,OAA8B;CAChF,OAAO;AACT;;;;;;;;;AAiEA,SAAgB,iCACd,OACyC;CACzC,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,IAAI,OAAO;CACjB,IAAI,MAAM,YAAY,MAAM,YAAY,MAAM,WAAW,OAAO;CAChE,IAAI,iBAAiB,MAAM,OAAO;CAClC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,MAAM,gCAAgC;CAC7E,IAAI,MAAM,YAAY,OAAO,eAAe,KAAK,MAAM,OAAO,WAC5D,OAAO,OAAO,OAAO,KAAgC,CAAC,CAAC,MAAM,gCAAgC;CAE/F,OAAO;AACT;AASA,SAAgB,gBAAgB,OAAwC;CACtE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,OAAQ,MAA6B;CAC3C,IAAI,SAAS,WACX,OAAO,WAAW;CAEpB,IAAI,SAAS,YACX,OAAO,OAAQ,MAAmC,eAAe;CAEnE,OAAO;AACT;AAQA,SAAgB,gCACd,OACwC;CACxC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,YAAY;CAKlB,IAAI,UAAU,SAAS,aAAa,OAAO;CAC3C,IAAI,OAAO,UAAU,OAAO,UAAU,OAAO;CAC7C,IACE,UAAU,WAAW,KAAA,MACpB,OAAO,UAAU,WAAW,YAC3B,UAAU,WAAW,QACrB,MAAM,QAAQ,UAAU,MAAM,IAEhC,OAAO;CAET,OAAO;AACT"}

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

import { t as ContractValidationError } from "./contract-validation-error-BFA66rwU.mjs";
import { t as asNamespaceId } from "./namespace-id-CUxYd4KL.mjs";
import { t as ContractValidationError } from "./contract-validation-error-DEiWp_EI.mjs";
//#region src/validate-domain.ts

@@ -4,0 +4,0 @@ function indexDomainModels(contract) {

{
"name": "@prisma-next/contract",
"version": "0.16.0-dev.30",
"version": "0.16.0-dev.31",
"license": "Apache-2.0",

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

"dependencies": {
"@prisma-next/utils": "0.16.0-dev.30",
"@prisma-next/utils": "0.16.0-dev.31",
"@standard-schema/spec": "^1.1.0",

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

"devDependencies": {
"@prisma-next/tsconfig": "0.16.0-dev.30",
"@prisma-next/tsdown": "0.16.0-dev.30",
"@prisma-next/tsconfig": "0.16.0-dev.31",
"@prisma-next/tsdown": "0.16.0-dev.31",
"tsdown": "0.22.8",

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

@@ -13,8 +13,1 @@ export type ContractValidationPhase = 'structural' | 'domain' | 'storage';

}
export class DomainNamespaceResolutionError extends Error {
constructor(message: string) {
super(message);
this.name = 'DomainNamespaceResolutionError';
}
}

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

import { DomainNamespaceResolutionError } from './contract-validation-error';
import { contractError } from './contract-errors';

@@ -27,8 +27,12 @@ /**

if (soleNamespaceId === undefined) {
throw new DomainNamespaceResolutionError('domain has no namespaces');
throw contractError('CONTRACT.NAMESPACE_INVALID', 'domain has no namespaces', {
meta: { reason: 'no-domain-namespaces' },
});
}
if (rest.length > 0) {
const all = [soleNamespaceId, ...rest];
throw new DomainNamespaceResolutionError(
throw contractError(
'CONTRACT.NAMESPACE_INVALID',
`bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(', ')}); select a namespace explicitly`,
{ meta: { reason: 'multiple-domain-namespaces', namespaceIds: all } },
);

@@ -35,0 +39,0 @@ }

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

import { DomainNamespaceResolutionError } from './contract-validation-error';
import { contractError } from './contract-errors';
import { soleDomainNamespaceId } from './default-namespace';

@@ -17,4 +17,6 @@ import type { ApplicationDomain } from './domain-envelope';

if (domainNamespace === undefined) {
throw new DomainNamespaceResolutionError(
throw contractError(
'CONTRACT.NAMESPACE_INVALID',
`domain namespace "${namespaceId}" is not present on the contract`,
{ meta: { reason: 'domain-namespace-missing', namespaceId } },
);

@@ -21,0 +23,0 @@ }

export {
ContractValidationError,
type ContractValidationPhase,
DomainNamespaceResolutionError,
} from '../contract-validation-error';

@@ -6,3 +6,2 @@ export type {

} from '../contract-types';
export { DomainNamespaceResolutionError } from '../contract-validation-error';
export type { ControlPolicy } from '../control-policy';

@@ -9,0 +8,0 @@ export { effectiveControlPolicy } from '../control-policy';

//#region src/contract-validation-error.ts
var ContractValidationError = class extends Error {
code = "CONTRACT.VALIDATION_FAILED";
phase;
constructor(message, phase) {
super(message);
this.name = "ContractValidationError";
this.phase = phase;
}
};
var DomainNamespaceResolutionError = class extends Error {
constructor(message) {
super(message);
this.name = "DomainNamespaceResolutionError";
}
};
//#endregion
export { DomainNamespaceResolutionError as n, ContractValidationError as t };
//# sourceMappingURL=contract-validation-error-BFA66rwU.mjs.map
{"version":3,"file":"contract-validation-error-BFA66rwU.mjs","names":[],"sources":["../src/contract-validation-error.ts"],"sourcesContent":["export type ContractValidationPhase = 'structural' | 'domain' | 'storage';\n\nexport class ContractValidationError extends Error {\n readonly code = 'CONTRACT.VALIDATION_FAILED';\n readonly phase: ContractValidationPhase;\n\n constructor(message: string, phase: ContractValidationPhase) {\n super(message);\n this.name = 'ContractValidationError';\n this.phase = phase;\n }\n}\n\nexport class DomainNamespaceResolutionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DomainNamespaceResolutionError';\n }\n}\n"],"mappings":";AAEA,IAAa,0BAAb,cAA6C,MAAM;CACjD,OAAgB;CAChB;CAEA,YAAY,SAAiB,OAAgC;EAC3D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
//#region src/contract-validation-error.d.ts
type ContractValidationPhase = 'structural' | 'domain' | 'storage';
declare class ContractValidationError extends Error {
readonly code = "CONTRACT.VALIDATION_FAILED";
readonly phase: ContractValidationPhase;
constructor(message: string, phase: ContractValidationPhase);
}
declare class DomainNamespaceResolutionError extends Error {
constructor(message: string);
}
//#endregion
export { ContractValidationPhase as n, DomainNamespaceResolutionError as r, ContractValidationError as t };
//# sourceMappingURL=contract-validation-error-D7g0kmcc.d.mts.map
{"version":3,"file":"contract-validation-error-D7g0kmcc.d.mts","names":[],"sources":["../src/contract-validation-error.ts"],"mappings":";KAAY;cAEC,gCAAgC;WAClC;WACA,OAAO;cAEJ,iBAAiB,OAAO;;cAOzB,uCAAuC;cACtC"}
import { n as DomainNamespaceResolutionError } from "./contract-validation-error-BFA66rwU.mjs";
//#region src/default-namespace.ts
/**
* Reserved sentinel domain namespace id for the late-bound application-domain
* slot — the namespace a model lands in when it is authored without an explicit
* namespace. This is target-agnostic: targets that allow un-namespaced
* authoring (e.g. Mongo, SQLite) declare this id as their default on the target
* descriptor; the framework names the sentinel, never a target. Mirrors
* storage's `UNBOUND_NAMESPACE_ID` on the domain plane.
*/
const UNBOUND_DOMAIN_NAMESPACE_ID = "__unbound__";
/**
* Resolve the single domain namespace of a single-namespace contract.
*
* Bare-name access (`db.User`) reads "the contract's one namespace". Every
* contract in scope today declares exactly one domain namespace, so this is
* exact — there is nothing to infer. A contract that declares more than one
* namespace is ambiguous for a bare name, so rather than silently pick one this
* throws; cross-namespace selection is made explicit (TML-2550).
*/
function soleDomainNamespaceId(domain) {
const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);
if (soleNamespaceId === void 0) throw new DomainNamespaceResolutionError("domain has no namespaces");
if (rest.length > 0) {
const all = [soleNamespaceId, ...rest];
throw new DomainNamespaceResolutionError(`bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(", ")}); select a namespace explicitly`);
}
return soleNamespaceId;
}
//#endregion
export { soleDomainNamespaceId as n, UNBOUND_DOMAIN_NAMESPACE_ID as t };
//# sourceMappingURL=default-namespace-rpdJeUMq.mjs.map
{"version":3,"file":"default-namespace-rpdJeUMq.mjs","names":[],"sources":["../src/default-namespace.ts"],"sourcesContent":["import { DomainNamespaceResolutionError } from './contract-validation-error';\n\n/**\n * Reserved sentinel domain namespace id for the late-bound application-domain\n * slot — the namespace a model lands in when it is authored without an explicit\n * namespace. This is target-agnostic: targets that allow un-namespaced\n * authoring (e.g. Mongo, SQLite) declare this id as their default on the target\n * descriptor; the framework names the sentinel, never a target. Mirrors\n * storage's `UNBOUND_NAMESPACE_ID` on the domain plane.\n */\nexport const UNBOUND_DOMAIN_NAMESPACE_ID = '__unbound__' as const;\n\n/**\n * Resolve the single domain namespace of a single-namespace contract.\n *\n * Bare-name access (`db.User`) reads \"the contract's one namespace\". Every\n * contract in scope today declares exactly one domain namespace, so this is\n * exact — there is nothing to infer. A contract that declares more than one\n * namespace is ambiguous for a bare name, so rather than silently pick one this\n * throws; cross-namespace selection is made explicit (TML-2550).\n */\nexport function soleDomainNamespaceId(domain: {\n readonly namespaces: Readonly<Record<string, unknown>>;\n}): string {\n const [soleNamespaceId, ...rest] = Object.keys(domain.namespaces);\n if (soleNamespaceId === undefined) {\n throw new DomainNamespaceResolutionError('domain has no namespaces');\n }\n if (rest.length > 0) {\n const all = [soleNamespaceId, ...rest];\n throw new DomainNamespaceResolutionError(\n `bare-name resolution requires exactly one domain namespace, found ${all.length} (${all.join(', ')}); select a namespace explicitly`,\n );\n }\n return soleNamespaceId;\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAa,8BAA8B;;;;;;;;;;AAW3C,SAAgB,sBAAsB,QAE3B;CACT,MAAM,CAAC,iBAAiB,GAAG,QAAQ,OAAO,KAAK,OAAO,UAAU;CAChE,IAAI,oBAAoB,KAAA,GACtB,MAAM,IAAI,+BAA+B,0BAA0B;CAErE,IAAI,KAAK,SAAS,GAAG;EACnB,MAAM,MAAM,CAAC,iBAAiB,GAAG,IAAI;EACrC,MAAM,IAAI,+BACR,qEAAqE,IAAI,OAAO,IAAI,IAAI,KAAK,IAAI,EAAE,iCACrG;CACF;CACA,OAAO;AACT"}