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

@prisma-next/framework-components

Package Overview
Dependencies
Maintainers
4
Versions
556
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/framework-components - npm Package Compare versions

Comparing version
0.16.0-dev.30
to
0.16.0-dev.31
+672
dist/framework-authoring-B1j8y_1y.mjs
import { n as runtimeError } from "./runtime-error-BA9d7XjZ.mjs";
import { blindCast } from "@prisma-next/utils/casts";
import { isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue } from "@prisma-next/contract/types";
import { ifDefined } from "@prisma-next/utils/defined";
import { InternalError } from "@prisma-next/utils/internal-error";
//#region src/shared/framework-authoring.ts
/**
* Classifies an `enum` block's members (before codec decoding, which needs
* the codec chosen first) into which default codec an omitted `@@type`
* should resolve to:
*
* - every member is `bare`, or a `value` whose raw JSON is a string → `'text'`
* - every member is a `value` whose raw JSON is an integer → `'int'`
* - anything else (float, bigint, boolean, mixed, or a `ref`/`option`/`list`
* parameter) → `null`, meaning the caller must require an explicit `@@type`.
*/
function classifyEnumMemberType(block) {
let sawText = false;
let sawInt = false;
for (const paramValue of Object.values(block.parameters)) {
if (paramValue.kind === "bare") {
sawText = true;
continue;
}
if (paramValue.kind !== "value") return null;
let jsonValue;
try {
jsonValue = JSON.parse(paramValue.raw);
} catch {
return null;
}
if (typeof jsonValue === "string") sawText = true;
else if (typeof jsonValue === "number" && Number.isInteger(jsonValue)) sawInt = true;
else return null;
}
if (sawText && sawInt) return null;
if (sawText) return "text";
if (sawInt) return "int";
return null;
}
/**
* Resolves the codec id for an `enum` block. When `@@type` is absent, the codec
* is inferred from the members via {@link classifyEnumMemberType}; otherwise the
* explicit `@@type("codec")` argument is parsed. Pushes the appropriate
* diagnostic and returns `undefined` when neither yields a codec. `codecSpan` is
* the span downstream codec-validation diagnostics should anchor to. Shared by
* every family's enum factory so inference and the explicit path stay identical.
*/
function resolveEnumCodecId(block, ctx) {
const sourceId = ctx.sourceId ?? "unknown";
const typeAttr = block.blockAttributes.find((a) => a.name === "type");
if (typeAttr === void 0) {
const inferredKind = classifyEnumMemberType(block);
if (inferredKind === null || ctx.enumInferenceCodecs === void 0) {
ctx.diagnostics?.push({
code: "PSL_ENUM_CANNOT_INFER_TYPE",
message: `cannot infer @@type for enum "${block.name}"; add an explicit @@type(...)`,
sourceId,
span: block.span
});
return;
}
return {
codecId: ctx.enumInferenceCodecs[inferredKind],
codecSpan: block.span
};
}
const rawCodecArg = typeAttr.args[0]?.value;
const codecId = rawCodecArg?.startsWith("\"") && rawCodecArg.endsWith("\"") && rawCodecArg.length >= 2 ? rawCodecArg.slice(1, -1) : void 0;
if (codecId === void 0) {
ctx.diagnostics?.push({
code: "PSL_ENUM_MISSING_TYPE",
message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`,
sourceId,
span: typeAttr.span
});
return;
}
return {
codecId,
codecSpan: typeAttr.args[0]?.span ?? typeAttr.span
};
}
function isAuthoringArgRef(value) {
if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
const { index, path } = value;
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
return true;
}
function isAuthoringSelectRef(value) {
if (!isAuthoringTemplateRecord(value) || value["kind"] !== "select") return false;
const index = value["index"];
const path = value["path"];
const cases = value["cases"];
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
return typeof cases === "object" && cases !== null && !Array.isArray(cases);
}
function isAuthoringTemplateRecord(value) {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function readTemplateArgumentValue(args, index, path) {
let value = args[index];
for (const segment of path ?? []) {
if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) return;
value = value[segment];
}
return value;
}
function isAuthoringTypeConstructorDescriptor(value) {
return "kind" in value && value.kind === "typeConstructor";
}
function isAuthoringFieldPresetDescriptor(value) {
return "kind" in value && value.kind === "fieldPreset";
}
function isAuthoringEntityTypeDescriptor(value) {
return "kind" in value && value.kind === "entity";
}
function isAuthoringPslBlockDescriptor(value) {
return "kind" in value && value.kind === "pslBlock";
}
function isAuthoringModelAttributeDescriptor(value) {
return "kind" in value && value.kind === "modelAttribute";
}
/**
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
*
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
* registration must NOT be treated as a "namespace" with sub-paths. Callers
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
*/
function hasRegisteredFieldNamespace(contributions, namespace) {
if (contributions?.field === void 0 || !Object.hasOwn(contributions.field, namespace)) return false;
const value = contributions.field[namespace];
return value !== void 0 && !isAuthoringFieldPresetDescriptor(value);
}
function isCopyableNamespaceObject(value) {
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
const proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null;
}
/**
* Deep structural check run only at the composition boundary (the merge and
* collect walkers) to classify a raw namespace-tree node as a leaf descriptor.
* A node counts as a leaf iff its `kind` matches `descriptorKind` AND it
* carries that kind's required fields.
*
* This is boundary validation over `unknown`, NOT a type-predicate: the four
* exported `isAuthoring*Descriptor` predicates deliberately narrow on `kind`
* alone and trust the static types. The walkers, by contrast, also receive
* type-bypassing packs (`as unknown as never` in tests, untyped JS at runtime)
* whose descriptor-shaped-but-incomplete nodes must be rejected rather than
* silently treated as sub-namespaces — so the well-formedness check lives here.
*/
function isWellFormedDescriptor(value, descriptorKind) {
if (typeof value !== "object" || value === null) return false;
if (!("kind" in value) || value.kind !== descriptorKind) return false;
switch (descriptorKind) {
case "typeConstructor":
case "fieldPreset": {
if (!("output" in value)) return false;
const output = value.output;
return typeof output === "object" && output !== null;
}
case "entity": {
if (!("discriminator" in value) || typeof value.discriminator !== "string") return false;
if (value.discriminator.length === 0) return false;
if (!("output" in value)) return false;
const output = value.output;
if (typeof output !== "object" || output === null) return false;
const factory = "factory" in output ? output.factory : void 0;
const template = "template" in output ? output.template : void 0;
return typeof factory === "function" || template !== void 0;
}
case "pslBlock": {
if (!("keyword" in value) || typeof value.keyword !== "string" || value.keyword.length === 0) return false;
if (!("discriminator" in value) || typeof value.discriminator !== "string" || value.discriminator.length === 0) return false;
if (!("name" in value)) return false;
const name = value.name;
if (typeof name !== "object" || name === null) return false;
if (!("required" in name) || typeof name.required !== "boolean") return false;
if (!("parameters" in value)) return false;
const parameters = value.parameters;
return typeof parameters === "object" && parameters !== null && !Array.isArray(parameters);
}
case "modelAttribute":
if (!("attribute" in value) || typeof value.attribute !== "string" || value.attribute.length === 0) return false;
if (!("spec" in value)) return false;
return "lower" in value && typeof value.lower === "function";
default: return false;
}
}
function deepCopyNamespace(source, descriptorKind) {
const copy = {};
for (const [key, value] of Object.entries(source)) copy[key] = isCopyableNamespaceObject(value) && !isWellFormedDescriptor(value, descriptorKind) ? deepCopyNamespace(value, descriptorKind) : value;
return copy;
}
/**
* Merges `source` into `target` recursively at the descriptor-namespace
* level. `descriptorKind` is the `kind` value ('typeConstructor',
* 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
* (terminal merge point; same-path registrations across components are
* reported as duplicates) as opposed to a sub-namespace (recursion target).
*
* Path segments are validated against prototype-pollution names
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
* recognized leaf nor a plain object — e.g. a malformed descriptor
* where the canonical leaf guard rejected it for missing `output` —
* is reported as an invalid contribution rather than recursed into,
* which would either silently mangle state or infinite-loop on
* primitive properties.
*
* Within-registry duplicate detection is this walker's job;
* cross-registry detection runs separately via
* `assertNoCrossRegistryCollisions` after merging completes.
*/
function mergeAuthoringNamespaces(target, source, path, descriptorKind, label) {
const assertSafePath = (currentPath) => {
const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype");
if (blockedSegment) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`);
};
for (const [key, sourceValue] of Object.entries(source)) {
const currentPath = [...path, key];
assertSafePath(currentPath);
const hasExistingValue = Object.hasOwn(target, key);
const existingValue = hasExistingValue ? target[key] : void 0;
if (!hasExistingValue) {
target[key] = isCopyableNamespaceObject(sourceValue) && !isWellFormedDescriptor(sourceValue, descriptorKind) ? deepCopyNamespace(sourceValue, descriptorKind) : sourceValue;
continue;
}
const existingIsLeaf = isWellFormedDescriptor(existingValue, descriptorKind);
const sourceIsLeaf = isWellFormedDescriptor(sourceValue, descriptorKind);
if (existingIsLeaf || sourceIsLeaf) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`);
if (!isCopyableNamespaceObject(existingValue) || !isCopyableNamespaceObject(sourceValue)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`);
mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, descriptorKind, label);
}
}
/**
* Collects the full dotted paths of every well-formed descriptor of
* `descriptorKind` in a raw contribution tree, using the same boundary
* classification as {@link mergeAuthoringNamespaces}. Lets assembly-level
* callers attribute each contributed path to its contributing component
* before merging, so a same-path collision can be reported naming both
* contributors.
*/
function collectContributedDescriptorPaths(namespace, descriptorKind, path = []) {
const paths = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isWellFormedDescriptor(value, descriptorKind)) {
paths.push(currentPath.join("."));
continue;
}
if (isCopyableNamespaceObject(value)) paths.push(...collectContributedDescriptorPaths(value, descriptorKind, currentPath));
}
return paths;
}
/**
* Derives the scalar view of an assembled authoring type namespace: every
* **top-level** type constructor that is instantiable with an empty argument
* list — all declared args optional and no entity-ref argument. A bare type
* name `T` in a schema is semantically the zero-arg instantiation `T()`, so
* each entry is exactly what that call produces (defaulted template values
* applied, absent optional-arg typeParams keys omitted). Constructors
* registered under a namespace segment, constructors with required args, and
* entity-ref constructors are not scalars and are excluded.
*
* Eligibility needs no template inspection: templates that cannot resolve
* for their legal call shapes are rejected at the composition boundary by
* {@link assertResolvableTypeConstructorTemplates}, so the zero-arg
* instantiation below cannot fail for an eligible constructor.
*/
function collectScalarTypeConstructors(namespace) {
const result = /* @__PURE__ */ new Map();
for (const [name, value] of Object.entries(namespace)) {
if (!isAuthoringTypeConstructorDescriptor(value)) continue;
if (value.entityRefArg !== void 0) continue;
if (value.args?.some((arg) => arg.optional !== true)) continue;
result.set(name, instantiateAuthoringTypeConstructor(value, []));
}
return result;
}
function visitTemplateArgRefs(template, visit) {
if (template === void 0) return;
if (isAuthoringArgRef(template)) {
visit(template);
visitTemplateArgRefs(template.default, visit);
return;
}
if (Array.isArray(template)) {
for (const value of template) visitTemplateArgRefs(value, visit);
return;
}
if (typeof template === "object" && template !== null) for (const value of Object.values(template)) visitTemplateArgRefs(value, visit);
}
/**
* Boundary validation for a contributed authoring type namespace, called
* per contributing component at assembly (which supplies `contributedBy`
* for attribution). Rejects what the types cannot express — entity-ref
* constructors are skipped (their output derives from the referenced
* entity): a plain constructor must declare its output storage type name,
* and every `typeParams` arg-ref (including refs inside arg-ref defaults)
* must point at a declared argument index.
*/
function assertResolvableTypeConstructorTemplates(namespace, contributedBy, path = []) {
for (const [name, value] of Object.entries(namespace)) {
const currentPath = [...path, name];
if (!isAuthoringTypeConstructorDescriptor(value)) {
assertResolvableTypeConstructorTemplates(value, contributedBy, currentPath);
continue;
}
if (value.entityRefArg !== void 0) continue;
const args = value.args ?? [];
const invalid = (detail) => /* @__PURE__ */ new Error(`Invalid authoring type constructor "${currentPath.join(".")}" contributed by descriptor "${contributedBy}". ${detail}`);
if (value.output.nativeType === void 0) throw invalid("The output declares no storage type template and no entityRefArg; a plain constructor must declare one.");
for (const [key, template] of Object.entries(value.output.typeParams ?? {})) visitTemplateArgRefs(template, (ref) => {
if (args[ref.index] === void 0) throw invalid(`output.typeParams.${key} references argument ${ref.index}, but the constructor declares ${args.length} argument(s). Declare the argument or correct the reference index.`);
});
}
}
function collectDescriptorPaths(namespace, isLeaf, path = []) {
const paths = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isLeaf(value)) {
paths.push(currentPath.join("."));
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath));
}
return paths;
}
function collectDescriptorEntries(namespace, isLeaf, descriptorKind, label, path = []) {
const entries = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isLeaf(value)) {
if (!isWellFormedDescriptor(value, descriptorKind)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
if (value.discriminator.length > 0) entries.push({
path: currentPath.join("."),
discriminator: value.discriminator
});
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
const record = blindCast(value);
if ((record["kind"] !== void 0 || record["keyword"] !== void 0 || record["discriminator"] !== void 0) && !isLeaf(value)) {
const hasKind = record["kind"] === "pslBlock";
const hasKeyword = typeof record["keyword"] === "string";
const hasDiscriminator = typeof record["discriminator"] === "string";
if (hasKind || hasKeyword && hasDiscriminator) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
}
entries.push(...collectDescriptorEntries(value, isLeaf, descriptorKind, label, currentPath));
}
}
return entries;
}
/**
* Throws when two or more entries in the same namespace share a key. A
* duplicate key makes dispatch ambiguous — the caller's lookup dispatches by
* this key, so one entry would silently shadow the other. Catch duplicates
* before building any dispatch map.
*
* `label` (e.g. `'pslBlock'`, `'entityType'`) names which namespace the
* duplicate was found in and is carried in the structured error metadata;
* the key itself is always called `key` in both the message and the
* metadata, since what it semantically represents (a discriminator for
* `entityType`, the parser's dispatch keyword for `pslBlock`) is the
* caller's concern, not this function's.
*/
function assertUniqueDiscriminators(entries, label) {
const seen = /* @__PURE__ */ new Map();
for (const { path, discriminator: key } of entries) {
const existing = seen.get(key);
if (existing !== void 0) throw runtimeError("RUNTIME.DUPLICATE_AUTHORING_DISCRIMINATOR", `Duplicate ${label} key "${key}" registered at both "${existing}" and "${path}". Each ${label} contribution must use a unique key.`, {
label,
key,
existingPath: existing,
path
});
seen.set(key, path);
}
}
function collectPslBlockDescriptorEntries(namespace, path = []) {
const entries = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isAuthoringPslBlockDescriptor(value)) {
if (!isWellFormedDescriptor(value, "pslBlock")) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push({
path: currentPath.join("."),
discriminator: value.discriminator,
keyword: value.keyword
});
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
const record = blindCast(value);
const hasKind = record["kind"] === "pslBlock";
const hasKeyword = typeof record["keyword"] === "string";
const hasDiscriminator = typeof record["discriminator"] === "string";
if (hasKind || hasKeyword && hasDiscriminator) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push(...collectPslBlockDescriptorEntries(value, currentPath));
}
}
return entries;
}
/**
* Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory
* with the same discriminator. An `entityTypes` factory may stand alone (e.g.
* `enum`, reachable from the TypeScript builder without any PSL block).
*
* Uniqueness for pslBlock entries is keyed on **keyword**, not discriminator:
* several keywords (e.g. `policy_select`/`policy_insert`) may legitimately
* share one discriminator, routing to the same `entityTypes` factory and the
* same `entries[discriminator]` slot — that N:1 shape is exactly what lets
* one entity kind be authored through several PSL keywords. What must stay
* unique is the keyword itself, since that's what the parser dispatches on.
*/
function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) {
const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace);
const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entity", "entityType");
assertUniqueDiscriminators(blockEntries.map((entry) => ({
path: entry.path,
discriminator: entry.keyword
})), "pslBlock");
assertUniqueDiscriminators(entityEntries, "entityType");
const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator));
for (const block of blockEntries) if (!entityDiscriminators.has(block.discriminator)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Incomplete extension contribution: pslBlock helper "${block.path}" registers discriminator "${block.discriminator}" but no entityType contribution shares that discriminator. An extension-contributed PSL block requires a matching entityType factory so the parsed AST node can lower to an IR class instance; add an entityType helper with discriminator "${block.discriminator}".`);
}
function collectModelAttributeEntries(namespace, path = []) {
const entries = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isAuthoringModelAttributeDescriptor(value)) {
if (!isWellFormedDescriptor(value, "modelAttribute")) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push({
path: currentPath.join("."),
discriminator: value.attribute
});
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
const record = blindCast(value);
if (typeof record["attribute"] === "string" && "spec" in record) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push(...collectModelAttributeEntries(value, currentPath));
}
}
return entries;
}
/**
* Throws when two modelAttribute contributions — at any paths, even
* different ones — claim the same bare `@@` attribute name. The family
* interpreter dispatches by attribute name, not by registration path, so
* two descriptors claiming the same name would have one silently shadow
* the other.
*/
function assertUniqueModelAttributeNames(entries) {
const seen = /* @__PURE__ */ new Map();
for (const { path, discriminator: attribute } of entries) {
const existing = seen.get(attribute);
if (existing !== void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate modelAttribute "${attribute}" registered at both "${existing}" and "${path}". Each modelAttribute contribution must claim a unique attribute name.`);
seen.set(attribute, path);
}
}
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) {
const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor));
const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.";
for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace);
assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace));
assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace);
}
function collectDescriptorNodes(namespace, isLeaf, path = []) {
const nodes = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isLeaf(value)) {
nodes.push([currentPath.join("."), value]);
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) nodes.push(...collectDescriptorNodes(value, isLeaf, currentPath));
}
return nodes;
}
function collectSelectRefs(value, found) {
if (typeof value !== "object" || value === null) return;
if (isAuthoringSelectRef(value)) {
found.push(value);
for (const caseTemplate of Object.values(value.cases)) collectSelectRefs(caseTemplate, found);
return;
}
if (isAuthoringArgRef(value)) {
collectSelectRefs(value.default, found);
return;
}
if (Array.isArray(value)) {
for (const entry of value) collectSelectRefs(entry, found);
return;
}
for (const entry of Object.values(value)) collectSelectRefs(entry, found);
}
function validateSelectRefsAgainstArgs(label, helperPath, args, templateRoot) {
const selects = [];
collectSelectRefs(templateRoot, selects);
for (const select of selects) {
const position = `#${select.index + 1}`;
let descriptor = args?.[select.index];
if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`);
for (const segment of select.path ?? []) {
descriptor = descriptor.kind === "object" ? descriptor.properties[segment] : void 0;
if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join(".")}", which does not resolve to a declared argument property.`);
}
if (descriptor.kind !== "option") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`);
const argumentLabel = descriptor.name !== void 0 ? `"${descriptor.name}"` : position;
const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value));
if (missing.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(", ")}] but the select template has no case for: ${missing.join(", ")}.`);
const values = descriptor.values;
const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key));
if (unreachable.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(", ")}. Allowed values: [${values.join(", ")}].`);
}
}
/**
* Every `select` template node must target an option argument whose `values`
* exactly cover the node's `cases` — a legal token with no case and a case no
* token can reach are both declaration bugs, caught here at pack-registration
* time rather than at first resolution.
*/
function assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace) {
for (const [helperPath, descriptor] of collectDescriptorNodes(fieldNamespace, isAuthoringFieldPresetDescriptor)) validateSelectRefsAgainstArgs("field", helperPath, descriptor.args, descriptor.output);
for (const [helperPath, descriptor] of collectDescriptorNodes(typeNamespace, isAuthoringTypeConstructorDescriptor)) validateSelectRefsAgainstArgs("type", helperPath, descriptor.args, descriptor.output);
for (const [helperPath, descriptor] of collectDescriptorNodes(entityTypeNamespace, isAuthoringEntityTypeDescriptor)) if ("template" in descriptor.output) validateSelectRefsAgainstArgs("entityType", helperPath, descriptor.args, descriptor.output.template);
}
function resolveAuthoringTemplateValue(template, args) {
if (template === void 0) return;
if (isAuthoringArgRef(template)) {
const value = readTemplateArgumentValue(args, template.index, template.path);
if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
return value;
}
if (isAuthoringSelectRef(template)) {
const value = readTemplateArgumentValue(args, template.index, template.path);
if (value === void 0) return;
if (typeof value !== "string" || !Object.hasOwn(template.cases, value)) throw new InternalError(`Authoring template select has no case for value "${String(value)}"`);
return resolveAuthoringTemplateValue(template.cases[value], args);
}
if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
if (typeof template === "object" && template !== null) {
const resolved = {};
for (const [key, value] of Object.entries(template)) {
const resolvedValue = resolveAuthoringTemplateValue(value, args);
if (resolvedValue !== void 0) resolved[key] = resolvedValue;
}
return resolved;
}
return template;
}
function validateAuthoringArgument(descriptor, value, path) {
if (value === void 0) {
if (descriptor.optional) return;
throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Missing required authoring helper argument at ${path}`);
}
if (descriptor.kind === "string") {
if (typeof value !== "string") throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be a string`);
return;
}
if (descriptor.kind === "boolean") {
if (typeof value !== "boolean") throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be a boolean`);
return;
}
if (descriptor.kind === "stringArray") {
if (!Array.isArray(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an array of strings`);
for (const entry of value) if (typeof entry !== "string") throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an array of strings`);
return;
}
if (descriptor.kind === "object") {
if (typeof value !== "object" || value === null || Array.isArray(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an object`);
const input = value;
const expectedKeys = new Set(Object.keys(descriptor.properties));
for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} contains unknown property "${key}"`);
for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
return;
}
if (descriptor.kind === "option") {
if (typeof value !== "string" || !descriptor.values.includes(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be one of: ${descriptor.values.join(", ")}`);
return;
}
if (typeof value !== "number" || Number.isNaN(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be a number`);
if (descriptor.integer && !Number.isInteger(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an integer`);
if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`);
if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`);
}
function validateAuthoringHelperArguments(helperPath, descriptors, args) {
const expected = descriptors ?? [];
const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
if (args.length < minimumArgs || args.length > expected.length) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
expected.forEach((descriptor, index) => {
validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);
});
}
function resolveAuthoringStorageTypeTemplate(template, args) {
const nativeType = template.nativeType;
if (nativeType === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring output template for codec "${template.codecId}" declares no nativeType; only entity-ref constructors may omit it`);
const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`);
const normalizedTypeParams = typeParams !== void 0 && Object.keys(typeParams).length === 0 ? void 0 : typeParams;
return {
codecId: template.codecId,
nativeType,
...ifDefined("typeParams", normalizedTypeParams)
};
}
function resolveAuthoringColumnDefaultTemplate(template, args) {
if (template.kind === "literal") {
const value = resolveAuthoringTemplateValue(template.value, args);
if (value === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", "Resolved authoring literal default must not be undefined");
if (!isColumnDefaultLiteralInputValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`);
return {
kind: "literal",
value
};
}
const expression = resolveAuthoringTemplateValue(template.expression, args);
if (expression === void 0 || typeof expression === "object" && expression !== null) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
return {
kind: "function",
expression: String(expression)
};
}
function resolveExecutionMutationDefaultPhase(phase, template, args) {
const value = resolveAuthoringTemplateValue(template, args);
if (value === void 0) return;
if (!isExecutionMutationDefaultValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`);
return value;
}
function resolveAuthoringExecutionDefaultsTemplate(template, args) {
const phases = {
...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0),
...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0)
};
return Object.keys(phases).length === 0 ? void 0 : phases;
}
function instantiateAuthoringTypeConstructor(descriptor, args) {
return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
}
function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
if ("factory" in descriptor.output) {
const input = args[0];
return blindCast(descriptor.output.factory)(input, ctx);
}
validateAuthoringHelperArguments(helperPath, descriptor.args, args);
return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args));
}
function instantiateAuthoringFieldPreset(descriptor, args) {
return {
descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
nullable: descriptor.output.nullable ?? false,
...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0),
id: descriptor.output.id ?? false,
unique: descriptor.output.unique ?? false
};
}
//#endregion
export { resolveAuthoringTemplateValue as _, collectScalarTypeConstructors as a, instantiateAuthoringFieldPreset as c, isAuthoringEntityTypeDescriptor as d, isAuthoringFieldPresetDescriptor as f, mergeAuthoringNamespaces as g, isAuthoringTypeConstructorDescriptor as h, collectContributedDescriptorPaths as i, instantiateAuthoringTypeConstructor as l, isAuthoringPslBlockDescriptor as m, assertResolvableTypeConstructorTemplates as n, hasRegisteredFieldNamespace as o, isAuthoringModelAttributeDescriptor as p, classifyEnumMemberType as r, instantiateAuthoringEntityType as s, assertNoCrossRegistryCollisions as t, isAuthoringArgRef as u, resolveEnumCodecId as v, validateAuthoringHelperArguments as y };
//# sourceMappingURL=framework-authoring-B1j8y_1y.mjs.map

Sorry, the diff of this file is too big to display

+1
-1

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

import { _ as resolveAuthoringTemplateValue, a as collectScalarTypeConstructors, c as instantiateAuthoringFieldPreset, d as isAuthoringEntityTypeDescriptor, f as isAuthoringFieldPresetDescriptor, g as mergeAuthoringNamespaces, h as isAuthoringTypeConstructorDescriptor, l as instantiateAuthoringTypeConstructor, m as isAuthoringPslBlockDescriptor, n as assertResolvableTypeConstructorTemplates, o as hasRegisteredFieldNamespace, p as isAuthoringModelAttributeDescriptor, r as classifyEnumMemberType, s as instantiateAuthoringEntityType, t as assertNoCrossRegistryCollisions, u as isAuthoringArgRef, v as resolveEnumCodecId, y as validateAuthoringHelperArguments } from "./framework-authoring-DfnkbOVh.mjs";
import { _ as resolveAuthoringTemplateValue, a as collectScalarTypeConstructors, c as instantiateAuthoringFieldPreset, d as isAuthoringEntityTypeDescriptor, f as isAuthoringFieldPresetDescriptor, g as mergeAuthoringNamespaces, h as isAuthoringTypeConstructorDescriptor, l as instantiateAuthoringTypeConstructor, m as isAuthoringPslBlockDescriptor, n as assertResolvableTypeConstructorTemplates, o as hasRegisteredFieldNamespace, p as isAuthoringModelAttributeDescriptor, r as classifyEnumMemberType, s as instantiateAuthoringEntityType, t as assertNoCrossRegistryCollisions, u as isAuthoringArgRef, v as resolveEnumCodecId, y as validateAuthoringHelperArguments } from "./framework-authoring-B1j8y_1y.mjs";
export { assertNoCrossRegistryCollisions, assertResolvableTypeConstructorTemplates, classifyEnumMemberType, collectScalarTypeConstructors, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringModelAttributeDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, mergeAuthoringNamespaces, resolveAuthoringTemplateValue, resolveEnumCodecId, validateAuthoringHelperArguments };

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

{"version":3,"file":"control.d.mts","names":[],"sources":["../src/control/contract-serializer.ts","../src/control/contract-snapshot-layout.ts","../src/control/schema-diff.ts","../src/control/control-operation-results.ts","../src/control/control-instances.ts","../src/control/control-migration-types.ts","../src/control/control-spaces.ts","../src/control/control-stack.ts","../src/control/control-descriptors.ts","../src/control/control-operation-preview.ts","../src/control/control-schema-view.ts","../src/control/control-capabilities.ts","../src/control/order-issues-by-dependencies.ts","../src/control/schema-verifier.ts","../src/control/verifier-disposition.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmBiB,mBAAmB;;;;;;;;;;;;EAYlC,oBAAoB,UAAU,YAAY,WAAW,gBAAgB;;;;;;;;;;EAWrE,kBAAkB,UAAU,YAAY;;;;;;;;WAS/B,sBAAsB;;;;;;;;WAStB,cAAc;;;;cC1DZ;;iBAKG,eAAe;;iBAUf,8BACd,6BACA;;iBAMc,+BACd,6BACA;;;;;;;;;;KCpB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C,YAAY,sBAAsB,WAAW,aAAa,wBAAwB;;;;;;UAYpE;EACf,mBAAmB,qBAAqB,2BAA2B;;iBAGrD,oBAAoB,0BAA0B,WAC5D,UAAU,sBAAsB,WAAW,aAC1C,YAAY,sBAAsB,WAAW,aAAa;;;;;;;;;;;;;KAmBjD;;;;;;;;;;;;;;;;;UAkBK;EACf,2BAA2B,OAAO,kBAAkB;EACpD,mBAAmB,OAAO;;iBAGZ,2BAA2B,0BAA0B,WACnE,UAAU,sBAAsB,WAAW,aAC1C,YAAY,sBAAsB,WAAW,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC3C7C,0BAA0B,cAAc,eAAe,cACrE,iBAAiB,gBAAgB,oBACvB,gBAAgB;;;;;;;;;;;;;;;;;;UCpDX,eAAe,WAAW;EACzC,aAAa,SAAS,oBAAoB,WAAW,WAAW;;;;;;;;UASjD,oBAAoB,WAAW;WACrC,UAAU;WACV,QAAQ;;;;;;;;UASF;WACN;WACA,iBAAiB;;;;KCtChB;KAEA,kBAAkB;;;;;;;;;;;;;;;;;KAkBlB;;;;;;;;;;iBAiBI,uBACd,eAAe,eACf,UAAU,wBACT"}
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/control/contract-serializer.ts","../src/control/contract-snapshot-layout.ts","../src/control/schema-diff.ts","../src/control/control-operation-results.ts","../src/control/control-instances.ts","../src/control/control-migration-types.ts","../src/control/control-spaces.ts","../src/control/control-stack.ts","../src/control/control-descriptors.ts","../src/control/control-operation-preview.ts","../src/control/control-schema-view.ts","../src/control/control-capabilities.ts","../src/control/order-issues-by-dependencies.ts","../src/control/schema-verifier.ts","../src/control/verifier-disposition.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmBiB,mBAAmB;;;;;;;;;;;;EAYlC,oBAAoB,UAAU,YAAY,WAAW,gBAAgB;;;;;;;;;;EAWrE,kBAAkB,UAAU,YAAY;;;;;;;;WAS/B,sBAAsB;;;;;;;;WAStB,cAAc;;;;cC1D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,UAAU,YAAY;;iBAGzB,oBAAoB,0BAA0B,WAC5D,UAAU,sBAAsB,WAAW,aAC1C,YAAY,sBAAsB,WAAW,aAAa,wBAAwB;;;;;;UAYpE;EACf,mBAAmB,qBAAqB,2BAA2B;;iBAGrD,oBAAoB,0BAA0B,WAC5D,UAAU,sBAAsB,WAAW,aAC1C,YAAY,sBAAsB,WAAW,aAAa;;;;;;;;;;;;;KAmBjD;;;;;;;;;;;;;;;;;UAkBK;EACf,2BAA2B,OAAO,kBAAkB;EACpD,mBAAmB,OAAO;;iBAGZ,2BAA2B,0BAA0B,WACnE,UAAU,sBAAsB,WAAW,aAC1C,YAAY,sBAAsB,WAAW,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC1C7C,0BAA0B,cAAc,eAAe,cACrE,iBAAiB,gBAAgB,oBACvB,gBAAgB;;;;;;;;;;;;;;;;;;UCrDX,eAAe,WAAW;EACzC,aAAa,SAAS,oBAAoB,WAAW,WAAW;;;;;;;;UASjD,oBAAoB,WAAW;WACrC,UAAU;WACV,QAAQ;;;;;;;;UASF;WACN;WACA,iBAAiB;;;;KCtChB;KAEA,kBAAkB;;;;;;;;;;;;;;;;;KAkBlB;;;;;;;;;;iBAiBI,uBACd,eAAe,eACf,UAAU,wBACT"}
import { n as materializeCodec, r as resolveCodecDescriptorOrThrow, t as CONTRACT_CODEC_DESCRIPTOR_MISSING } from "./resolve-codec-CHARBCXP.mjs";
import { t as mergeCapabilityMatrices } from "./capabilities-BnRAFKP5.mjs";
import { a as collectScalarTypeConstructors, g as mergeAuthoringNamespaces, i as collectContributedDescriptorPaths, n as assertResolvableTypeConstructorTemplates, t as assertNoCrossRegistryCollisions } from "./framework-authoring-DfnkbOVh.mjs";
import { a as collectScalarTypeConstructors, g as mergeAuthoringNamespaces, i as collectContributedDescriptorPaths, n as assertResolvableTypeConstructorTemplates, t as assertNoCrossRegistryCollisions } from "./framework-authoring-B1j8y_1y.mjs";
import { blindCast } from "@prisma-next/utils/casts";

@@ -470,4 +470,3 @@ import { InternalError } from "@prisma-next/utils/internal-error";

const placed = new Set(order);
const unresolved = nodes.filter((node) => !placed.has(node)).map((node) => node.issue.path.join("/"));
throw new Error(`orderIssuesByDependencies: dependency cycle among schema-diff issues (unresolved: ${unresolved.join(", ")})`);
throw new InternalError(`orderIssuesByDependencies: dependency cycle among schema-diff issues (unresolved: ${nodes.filter((node) => !placed.has(node)).map((node) => node.issue.path.join("/")).join(", ")})`);
}

@@ -490,3 +489,3 @@ return order.map((node) => node.issue);

if (hasActual) return "not-expected";
throw new Error(`issueOutcome: issue at "${issue.path.join("/")}" carries neither an expected nor an actual node`);
throw new InternalError(`issueOutcome: issue at "${issue.path.join("/")}" carries neither an expected nor an actual node`);
}

@@ -500,3 +499,3 @@ /** Delimiter joining `nodeKind` and `id` into one sibling-map key. Every `nodeKind` is a code-defined literal (kebab-case-style), so a null character can never appear in one. */

const key = siblingKey(node);
if (map.has(key)) throw new Error(`diffSchemas: duplicate id among siblings: ${node.nodeKind}/${node.id}`);
if (map.has(key)) throw new InternalError(`diffSchemas: duplicate id among siblings: ${node.nodeKind}/${node.id}`);
map.set(key, node);

@@ -503,0 +502,0 @@ }

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

{"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution/execution-instances.ts","../src/execution/execution-stack.ts","../src/execution/execution-descriptors.ts","../src/execution/execution-requirements.ts"],"mappings":";;UAQiB,sBAAsB,kCAC7B,eAAe;UAER,sBAAsB,0BAA0B,kCACvD,eAAe,WAAW;UAEnB,uBAAuB,0BAA0B,kCACxD,gBAAgB,WAAW;UAEpB,sBAAsB,0BAA0B,kCACvD,eAAe,WAAW;UAEnB,yBAAyB,0BAA0B,kCAC1D,kBAAkB,WAAW;;;UCRtB,eACf,0BACA,0BACA,yBAAyB,uBAAuB,WAAW,aAAa,uBACtE,WACA,YAEF,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,YAEF,2BAA2B,yBACzB,WACA,aACE,yBAAyB,W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BAA2B,WAAW;MAClE;;UAGW,wBACf,0BACA,0BACA,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,oBAEM,iBAAiB,WAAW;EACpC,UAAU;;UAGK,yBACf,0BACA,0BACA,yBAAyB,uBAAuB,WAAW,aAAa,uBACtE,WACA,oBAEM,kBAAkB,WAAW;;;;;;;;EAQrC,OAAO,OAAO,eAAe,WAAW,aAAa;;UAGtC,wBACf,0BACA,0BACA,uBACA,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,oBAEM,iBAAiB,WAAW;EACpC,OAAO,UAAU,iBAAiB;;UAGnB,2BACf,0BACA,0BACA,2BAA2B,yBACzB,WACA,aACE,yBAAyB,WAAW,oBAChC,oBAAoB,WAAW;EACvC,UAAU;;;;iBCrEI,2CACd,0BACA,4BAEA,UACA,QACA,QACA,SACA;WAES;aAAqB;aAAyB,aAAa;;WAC3D,QAAQ,wBAAwB;WAChC,QAAQ,wBAAwB,WAAW;WAC3C,SAAS,yBAAyB,WAAW;WAC7C,qBAAqB,2BAA2B,WAAW"}
{"version":3,"file":"execution.d.mts","names":[],"sources":["../src/execution/execution-instances.ts","../src/execution/execution-stack.ts","../src/execution/execution-descriptors.ts","../src/execution/execution-requirements.ts"],"mappings":";;UAQiB,sBAAsB,kCAC7B,eAAe;UAER,sBAAsB,0BAA0B,kCACvD,eAAe,WAAW;UAEnB,uBAAuB,0BAA0B,kCACxD,gBAAgB,WAAW;UAEpB,sBAAsB,0BAA0B,kCACvD,eAAe,WAAW;UAEnB,yBAAyB,0BAA0B,kCAC1D,kBAAkB,WAAW;;;UCRtB,eACf,0BACA,0BACA,yBAAyB,uBAAuB,WAAW,aAAa,uBACtE,WACA,YAEF,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,YAEF,2BAA2B,yBACzB,WACA,aACE,yBAAyB,WAAW;WAE/B,QAAQ,wBAAwB,WAAW;WAC3C,SAAS,yBAAyB,WAAW,WAAW;WACxD,QACL,wBAAwB,WAA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M,iBAAiB,WAAW;EACpC,UAAU;;UAGK,yBACf,0BACA,0BACA,yBAAyB,uBAAuB,WAAW,aAAa,uBACtE,WACA,oBAEM,kBAAkB,WAAW;;;;;;;;EAQrC,OAAO,OAAO,eAAe,WAAW,aAAa;;UAGtC,wBACf,0BACA,0BACA,uBACA,wBAAwB,sBAAsB,WAAW,aAAa,sBACpE,WACA,oBAEM,iBAAiB,WAAW;EACpC,OAAO,UAAU,iBAAiB;;UAGnB,2BACf,0BACA,0BACA,2BAA2B,yBACzB,WACA,aACE,yBAAyB,WAAW,oBAChC,oBAAoB,WAAW;EACvC,UAAU;;;;iBCpEI,2CACd,0BACA,4BAEA,UACA,QACA,QACA,SACA;WAES;aAAqB;aAAyB,aAAa;;WAC3D,QAAQ,wBAAwB;WAChC,QAAQ,wBAAwB,WAAW;WAC3C,SAAS,yBAAyB,WAAW;WAC7C,qBAAqB,2BAA2B,WAAW"}

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

import { n as runtimeError } from "./runtime-error-BA9d7XjZ.mjs";
import { t as checkContractComponentRequirements } from "./framework-components-D6j4Y5K7.mjs";

@@ -15,4 +16,4 @@ //#region src/execution/execution-requirements.ts

});
if (result.targetMismatch) throw new Error(`Contract target '${result.targetMismatch.actual}' does not match runtime target descriptor '${result.targetMismatch.expected}'.`);
for (const packId of result.missingExtensionPackIds) throw new Error(`Contract requires extension pack '${packId}', but runtime descriptors do not provide a matching component.`);
if (result.targetMismatch) throw runtimeError("CONTRACT.TARGET_MISMATCH", `Contract target '${result.targetMismatch.actual}' does not match runtime target descriptor '${result.targetMismatch.expected}'.`);
for (const packId of result.missingExtensionPackIds) throw runtimeError("RUNTIME.MISSING_EXTENSION_PACK", `Contract requires extension pack '${packId}', but runtime descriptors do not provide a matching component.`);
}

@@ -19,0 +20,0 @@ //#endregion

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

{"version":3,"file":"execution.mjs","names":[],"sources":["../src/execution/execution-requirements.ts","../src/execution/execution-stack.ts"],"sourcesContent":["import { checkContractComponentRequirements } from '../shared/framework-components';\nimport type {\n RuntimeAdapterDescriptor,\n RuntimeExtensionDescriptor,\n RuntimeFamilyDescriptor,\n RuntimeTargetDescriptor,\n} from './execution-descriptors';\n\nexport function assertRuntimeContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n family,\n target,\n adapter,\n extensions,\n}: {\n readonly contract: { readonly target: string; readonly extensions?: Record<string, unknown> };\n readonly family: RuntimeFamilyDescriptor<TFamilyId>;\n readonly target: RuntimeTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: RuntimeAdapterDescriptor<TFamilyId, TTargetId>;\n readonly extensions: readonly RuntimeExtensionDescriptor<TFamilyId, TTargetId>[];\n}): void {\n const providedComponentIds = new Set<string>([family.id, target.id, adapter.id]);\n for (const extension of extensions) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetId: target.targetId,\n providedComponentIds,\n });\n\n if (result.targetMismatch) {\n throw new Error(\n `Contract target '${result.targetMismatch.actual}' does not match runtime target descriptor '${result.targetMismatch.expected}'.`,\n );\n }\n\n for (const packId of result.missingExtensionPackIds) {\n throw new Error(\n `Contract requires extension pack '${packId}', but runtime descriptors do not provide a matching component.`,\n );\n }\n}\n","import type {\n RuntimeAdapterDescriptor,\n RuntimeDriverDescriptor,\n RuntimeExtensionDescriptor,\n RuntimeTargetDescriptor,\n} from './execution-descriptors';\nimport type {\n RuntimeAdapterInstance,\n RuntimeDriverInstance,\n RuntimeExtensionInstance,\n RuntimeTargetInstance,\n} from './execution-instances';\n\nexport interface ExecutionStack<\n TFamilyId extends string,\n TTargetId extends string,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId> = RuntimeAdapterInstance<\n TFamilyId,\n TTargetId\n >,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId> = RuntimeDriverInstance<\n TFamilyId,\n TTargetId\n >,\n TExtensionInstance extends RuntimeExtensionInstance<\n TFamilyId,\n TTargetId\n > = RuntimeExtensionInstance<TFamilyId, TTargetId>,\n> {\n readonly target: RuntimeTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: RuntimeAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>;\n readonly driver:\n | RuntimeDriverDescriptor<TFamilyId, TTargetId, unknown, TDriverInstance>\n | undefined;\n readonly extensions: readonly RuntimeExtensionDescriptor<\n TFamilyId,\n TTargetId,\n TExtensionInstance\n >[];\n}\n\nexport interface ExecutionStackInstance<\n TFamilyId extends string,\n TTargetId extends string,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId> = RuntimeAdapterInstance<\n TFamilyId,\n TTargetId\n >,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId> = RuntimeDriverInstance<\n TFamilyId,\n TTargetId\n >,\n TExtensionInstance extends RuntimeExtensionInstance<\n TFamilyId,\n TTargetId\n > = RuntimeExtensionInstance<TFamilyId, TTargetId>,\n> {\n readonly stack: ExecutionStack<\n TFamilyId,\n TTargetId,\n TAdapterInstance,\n TDriverInstance,\n TExtensionInstance\n >;\n readonly target: RuntimeTargetInstance<TFamilyId, TTargetId>;\n readonly adapter: TAdapterInstance;\n readonly driver: TDriverInstance | undefined;\n readonly extensions: readonly TExtensionInstance[];\n}\n\nexport function createExecutionStack<\n TFamilyId extends string,\n TTargetId extends string,\n TTargetInstance extends RuntimeTargetInstance<TFamilyId, TTargetId>,\n TTargetDescriptor extends RuntimeTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId>,\n TAdapterDescriptor extends RuntimeAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId> = RuntimeDriverInstance<\n TFamilyId,\n TTargetId\n >,\n TDriverDescriptor extends\n | RuntimeDriverDescriptor<TFamilyId, TTargetId, unknown, TDriverInstance>\n | undefined = undefined,\n TExtensionInstance extends RuntimeExtensionInstance<\n TFamilyId,\n TTargetId\n > = RuntimeExtensionInstance<TFamilyId, TTargetId>,\n TExtensionDescriptor extends RuntimeExtensionDescriptor<\n TFamilyId,\n TTargetId,\n TExtensionInstance\n > = never,\n>(input: {\n readonly target: TTargetDescriptor;\n readonly adapter: TAdapterDescriptor;\n readonly driver?: TDriverDescriptor | undefined;\n readonly extensions?: readonly TExtensionDescriptor[] | undefined;\n}): ExecutionStack<TFamilyId, TTargetId, TAdapterInstance, TDriverInstance, TExtensionInstance> & {\n readonly target: TTargetDescriptor;\n readonly adapter: TAdapterDescriptor;\n readonly driver: TDriverDescriptor | undefined;\n readonly extensions: readonly TExtensionDescriptor[];\n} {\n return {\n target: input.target,\n adapter: input.adapter,\n driver: input.driver,\n extensions: input.extensions ?? [],\n };\n}\n\nexport function instantiateExecutionStack<\n TFamilyId extends string,\n TTargetId extends string,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId>,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId>,\n TExtensionInstance extends RuntimeExtensionInstance<TFamilyId, TTargetId>,\n>(\n stack: ExecutionStack<\n TFamilyId,\n TTargetId,\n TAdapterInstance,\n TDriverInstance,\n TExtensionInstance\n >,\n): ExecutionStackInstance<\n TFamilyId,\n TTargetId,\n TAdapterInstance,\n TDriverInstance,\n TExtensionInstance\n> {\n const driver = stack.driver ? stack.driver.create() : undefined;\n\n return {\n stack,\n target: stack.target.create(),\n adapter: stack.adapter.create(stack),\n driver,\n extensions: stack.extensions.map((descriptor) => descriptor.create()),\n };\n}\n"],"mappings":";;AAQA,SAAgB,2CAGd,EACA,UACA,QACA,QACA,SACA,cAOO;CACP,MAAM,uCAAuB,IAAI,IAAY;EAAC,OAAO;EAAI,OAAO;EAAI,QAAQ;CAAE,CAAC;CAC/E,KAAK,MAAM,aAAa,YACtB,qBAAqB,IAAI,UAAU,EAAE;CAGvC,MAAM,SAAS,mCAAmC;EAChD;EACA,kBAAkB,OAAO;EACzB;CACF,CAAC;CAED,IAAI,OAAO,gBACT,MAAM,IAAI,MACR,oBAAoB,OAAO,eAAe,OAAO,8CAA8C,OAAO,eAAe,SAAS,GAChI;CAGF,KAAK,MAAM,UAAU,OAAO,yBAC1B,MAAM,IAAI,MACR,qCAAqC,OAAO,gEAC9C;AAEJ;;;ACwBA,SAAgB,qBAuBd,OAUA;CACA,OAAO;EACL,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,YAAY,MAAM,cAAc,CAAC;CACnC;AACF;AAEA,SAAgB,0BAOd,OAaA;CACA,MAAM,SAAS,MAAM,SAAS,MAAM,OAAO,OAAO,IAAI,KAAA;CAEtD,OAAO;EACL;EACA,QAAQ,MAAM,OAAO,OAAO;EAC5B,SAAS,MAAM,QAAQ,OAAO,KAAK;EACnC;EACA,YAAY,MAAM,WAAW,KAAK,eAAe,WAAW,OAAO,CAAC;CACtE;AACF"}
{"version":3,"file":"execution.mjs","names":[],"sources":["../src/execution/execution-requirements.ts","../src/execution/execution-stack.ts"],"sourcesContent":["import { checkContractComponentRequirements } from '../shared/framework-components';\nimport { runtimeError } from '../shared/runtime-error';\nimport type {\n RuntimeAdapterDescriptor,\n RuntimeExtensionDescriptor,\n RuntimeFamilyDescriptor,\n RuntimeTargetDescriptor,\n} from './execution-descriptors';\n\nexport function assertRuntimeContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n family,\n target,\n adapter,\n extensions,\n}: {\n readonly contract: { readonly target: string; readonly extensions?: Record<string, unknown> };\n readonly family: RuntimeFamilyDescriptor<TFamilyId>;\n readonly target: RuntimeTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: RuntimeAdapterDescriptor<TFamilyId, TTargetId>;\n readonly extensions: readonly RuntimeExtensionDescriptor<TFamilyId, TTargetId>[];\n}): void {\n const providedComponentIds = new Set<string>([family.id, target.id, adapter.id]);\n for (const extension of extensions) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetId: target.targetId,\n providedComponentIds,\n });\n\n if (result.targetMismatch) {\n throw runtimeError(\n 'CONTRACT.TARGET_MISMATCH',\n `Contract target '${result.targetMismatch.actual}' does not match runtime target descriptor '${result.targetMismatch.expected}'.`,\n );\n }\n\n for (const packId of result.missingExtensionPackIds) {\n throw runtimeError(\n 'RUNTIME.MISSING_EXTENSION_PACK',\n `Contract requires extension pack '${packId}', but runtime descriptors do not provide a matching component.`,\n );\n }\n}\n","import type {\n RuntimeAdapterDescriptor,\n RuntimeDriverDescriptor,\n RuntimeExtensionDescriptor,\n RuntimeTargetDescriptor,\n} from './execution-descriptors';\nimport type {\n RuntimeAdapterInstance,\n RuntimeDriverInstance,\n RuntimeExtensionInstance,\n RuntimeTargetInstance,\n} from './execution-instances';\n\nexport interface ExecutionStack<\n TFamilyId extends string,\n TTargetId extends string,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId> = RuntimeAdapterInstance<\n TFamilyId,\n TTargetId\n >,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId> = RuntimeDriverInstance<\n TFamilyId,\n TTargetId\n >,\n TExtensionInstance extends RuntimeExtensionInstance<\n TFamilyId,\n TTargetId\n > = RuntimeExtensionInstance<TFamilyId, TTargetId>,\n> {\n readonly target: RuntimeTargetDescriptor<TFamilyId, TTargetId>;\n readonly adapter: RuntimeAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>;\n readonly driver:\n | RuntimeDriverDescriptor<TFamilyId, TTargetId, unknown, TDriverInstance>\n | undefined;\n readonly extensions: readonly RuntimeExtensionDescriptor<\n TFamilyId,\n TTargetId,\n TExtensionInstance\n >[];\n}\n\nexport interface ExecutionStackInstance<\n TFamilyId extends string,\n TTargetId extends string,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId> = RuntimeAdapterInstance<\n TFamilyId,\n TTargetId\n >,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId> = RuntimeDriverInstance<\n TFamilyId,\n TTargetId\n >,\n TExtensionInstance extends RuntimeExtensionInstance<\n TFamilyId,\n TTargetId\n > = RuntimeExtensionInstance<TFamilyId, TTargetId>,\n> {\n readonly stack: ExecutionStack<\n TFamilyId,\n TTargetId,\n TAdapterInstance,\n TDriverInstance,\n TExtensionInstance\n >;\n readonly target: RuntimeTargetInstance<TFamilyId, TTargetId>;\n readonly adapter: TAdapterInstance;\n readonly driver: TDriverInstance | undefined;\n readonly extensions: readonly TExtensionInstance[];\n}\n\nexport function createExecutionStack<\n TFamilyId extends string,\n TTargetId extends string,\n TTargetInstance extends RuntimeTargetInstance<TFamilyId, TTargetId>,\n TTargetDescriptor extends RuntimeTargetDescriptor<TFamilyId, TTargetId, TTargetInstance>,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId>,\n TAdapterDescriptor extends RuntimeAdapterDescriptor<TFamilyId, TTargetId, TAdapterInstance>,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId> = RuntimeDriverInstance<\n TFamilyId,\n TTargetId\n >,\n TDriverDescriptor extends\n | RuntimeDriverDescriptor<TFamilyId, TTargetId, unknown, TDriverInstance>\n | undefined = undefined,\n TExtensionInstance extends RuntimeExtensionInstance<\n TFamilyId,\n TTargetId\n > = RuntimeExtensionInstance<TFamilyId, TTargetId>,\n TExtensionDescriptor extends RuntimeExtensionDescriptor<\n TFamilyId,\n TTargetId,\n TExtensionInstance\n > = never,\n>(input: {\n readonly target: TTargetDescriptor;\n readonly adapter: TAdapterDescriptor;\n readonly driver?: TDriverDescriptor | undefined;\n readonly extensions?: readonly TExtensionDescriptor[] | undefined;\n}): ExecutionStack<TFamilyId, TTargetId, TAdapterInstance, TDriverInstance, TExtensionInstance> & {\n readonly target: TTargetDescriptor;\n readonly adapter: TAdapterDescriptor;\n readonly driver: TDriverDescriptor | undefined;\n readonly extensions: readonly TExtensionDescriptor[];\n} {\n return {\n target: input.target,\n adapter: input.adapter,\n driver: input.driver,\n extensions: input.extensions ?? [],\n };\n}\n\nexport function instantiateExecutionStack<\n TFamilyId extends string,\n TTargetId extends string,\n TAdapterInstance extends RuntimeAdapterInstance<TFamilyId, TTargetId>,\n TDriverInstance extends RuntimeDriverInstance<TFamilyId, TTargetId>,\n TExtensionInstance extends RuntimeExtensionInstance<TFamilyId, TTargetId>,\n>(\n stack: ExecutionStack<\n TFamilyId,\n TTargetId,\n TAdapterInstance,\n TDriverInstance,\n TExtensionInstance\n >,\n): ExecutionStackInstance<\n TFamilyId,\n TTargetId,\n TAdapterInstance,\n TDriverInstance,\n TExtensionInstance\n> {\n const driver = stack.driver ? stack.driver.create() : undefined;\n\n return {\n stack,\n target: stack.target.create(),\n adapter: stack.adapter.create(stack),\n driver,\n extensions: stack.extensions.map((descriptor) => descriptor.create()),\n };\n}\n"],"mappings":";;;AASA,SAAgB,2CAGd,EACA,UACA,QACA,QACA,SACA,cAOO;CACP,MAAM,uCAAuB,IAAI,IAAY;EAAC,OAAO;EAAI,OAAO;EAAI,QAAQ;CAAE,CAAC;CAC/E,KAAK,MAAM,aAAa,YACtB,qBAAqB,IAAI,UAAU,EAAE;CAGvC,MAAM,SAAS,mCAAmC;EAChD;EACA,kBAAkB,OAAO;EACzB;CACF,CAAC;CAED,IAAI,OAAO,gBACT,MAAM,aACJ,4BACA,oBAAoB,OAAO,eAAe,OAAO,8CAA8C,OAAO,eAAe,SAAS,GAChI;CAGF,KAAK,MAAM,UAAU,OAAO,yBAC1B,MAAM,aACJ,kCACA,qCAAqC,OAAO,gEAC9C;AAEJ;;;ACqBA,SAAgB,qBAuBd,OAUA;CACA,OAAO;EACL,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,YAAY,MAAM,cAAc,CAAC;CACnC;AACF;AAEA,SAAgB,0BAOd,OAaA;CACA,MAAM,SAAS,MAAM,SAAS,MAAM,OAAO,OAAO,IAAI,KAAA;CAEtD,OAAO;EACL;EACA,QAAQ,MAAM,OAAO,OAAO;EAC5B,SAAS,MAAM,QAAQ,OAAO,KAAK;EACnC;EACA,YAAY,MAAM,WAAW,KAAK,eAAe,WAAW,OAAO,CAAC;CACtE;AACF"}

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

{"version":3,"file":"framework-authoring-DT8QRvDv.d.mts","names":[],"sources":["../src/shared/option-descriptor.ts","../src/shared/psl-extension-block.ts","../src/shared/framework-authoring.ts"],"mappings":";;;;;;;;;;;UAOiB;WACN;WACA;;;;UCKM;WACN;WACA;WACA;;UAGM;WACN,OAAO;WACP,KAAK;;KAGJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0GA,gBACR,mBACA,qBACA,sBACA;UAEa;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;;UAGM,4BAA4B;WAClC;;UAGM;WACN;WACA,IAAI;WACJ;;;;;;;;;;;;;;;;;;;;KAqBC,8BACR,4BACA,oCACA,+BACA,6BACA;UAEa;WACN;WACA;WACA,MAAM;;UAGA;WACN;WACA;WACA,MAAM;;UAGA;WACN;WACA;WACA,MAAM;;UAGA;WACN;WACA,gBAAgB;WAChB,MAAM;;;;;;;UAQA;WACN;WACA,MAAM;;;;;;UAOA;WACN;WACA;WACA,MAAM;;;;;;;;UASA;WACN;WACA,eAAe;WACf,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkCA;WACN;;;;;;;WAOA;WACA;WACA,YAAY,eAAe;WAC3B,0BAA0B;WAC1B,MAAM;;;;KCzQL;WACD;WACA;WACA;WACA,UAAU;;;;;;;;;;;;;;;;UAiBJ;WACN;WACA;WACA;WACA,OAAO,SAAS,eAAe;;KAG9B,4DAKR,kBACA,8BACS;YACG,cAAc;;UAEpB;WACC;WACA;;KAGC,8BAA8B;WAEzB;;WACA;;WAEA;WACA;WACA;WACA;;WAEA;;WAEA;WACA,YAAY,eAAe;IAEtC;UAGW;WACN;;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AsB;;;;;;;;;WAStB,kBAAkB;;;;;;;;;;;;WAYlB;;iBAGK,kBAAkB,iBAAiB,SAAS;iBAiD5C,qCACd,OAAO,qCAAqC,yBAC3C,SAAS;iBAII,iCACd,OAAO,iCAAiC,0BACvC,SAAS;iBAII,gCACd,OAAO,gCAAgC,+BACtC,SAAS;iBAII,8BACd,OAAO,8BAA8B,uCACpC,SAAS;iBAII,oCACd,OAAO,oCAAoC,6CAC1C,SAAS;;;;;;;;;iBAYI,4BACd,eAAe,oCACf;;;;;;;;;;;;;;;;;;;;iBAwHc,yBACd,QAAQ,yBACR,QAAQ,yBACR,yBACA,wBACA;UA8Ee;WACN;WACA;WACA,aAAa;;;;;;;;;;;;;;;;;iBAkBR,8BACd,WAAW,yBACV,oBAAoB;;;;;;;;;;iBA6CP,yCACd,WAAW,wBACX,uBACA;iBA2Sc,gCACd,eAAe,wBACf,gBAAgB,yBAChB,sBAAqB,8BACrB,oBAAmB,sCACnB,0BAAyB;iBAyKX,8BACd,UAAU,oCACV;iBAgIc,iCACd,oBACA,sBAAsB,2CACtB;iBAyHc,oCACd,YAAY,oCACZ;WAES;WACA;WACA,aAAa;;iBAKR,+BAA+B,mBAC7C,oBACA,YAAY,+BACZ,0BACA,KAAK,yBACJ;iBA2Ba,gCACd,YAAY,gCACZ;WAES;aACE;aACA;aACA,aAAa;;WAEf;WACA,UAAU;WACV,oBAAoB;WACpB;WACA"}
{"version":3,"file":"framework-authoring-DT8QRvDv.d.mts","names":[],"sources":["../src/shared/option-descriptor.ts","../src/shared/psl-extension-block.ts","../src/shared/framework-authoring.ts"],"mappings":";;;;;;;;;;;UAOiB;WACN;WACA;;;;UCKM;WACN;WACA;WACA;;UAGM;WACN,OAAO;WACP,KAAK;;KAGJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0GA,gBACR,mBACA,qBACA,sBACA;UAEa;W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BA6CP,yCACd,WAAW,wBACX,uBACA;iBAmTc,gCACd,eAAe,wBACf,gBAAgB,yBAChB,sBAAqB,8BACrB,oBAAmB,sCACnB,0BAAyB;iBAgLX,8BACd,UAAU,oCACV;iBA8Jc,iCACd,oBACA,sBAAsB,2CACtB;iBAkIc,oCACd,YAAY,oCACZ;WAES;WACA;WACA,aAAa;;iBAKR,+BAA+B,mBAC7C,oBACA,YAAY,+BACZ,0BACA,KAAK,yBACJ;iBA2Ba,gCACd,YAAY,gCACZ;WAES;aACE;aACA;aACA,aAAa;;WAEf;WACA,UAAU;WACV,oBAAoB;WACpB;WACA"}

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

{"version":3,"file":"ir.d.mts","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/storage.ts","../src/ir/contract-view.ts","../src/ir/domain.ts","../src/ir/entity-kind.ts","../src/ir/storage-type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAyCiB;WACN;;uBAGW,sBAAsB;oBACxB;;;;;;;;;;;iBAYJ,WAAW,UAAU,QAAQ,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;cChC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkCI,kBAAkB,QAAQ;WAChC;WACA,SAAS,SAAS,eAAe,SAAS;;;;;;;WAO1C;;uBAGW,sBAAsB,sBAAsB;oBAC9C;oBACA,SAAS,SAAS,eAAe,SAAS;oBACjC;;;;;;MAOvB;;;;;;;;;;;;;;;;;;;;UC1DW;WACN;WACA;WACA;WACA;;;;;;;;;;;;;iBAcM,mBACf,SAAS,KAAK,6BACb,UAAU;;;;;;;;;;;;;;iBA0BG,cACd,YAAY,KAAK;;;;;;;iBAaH,SAAS,aACvB,SAAS,KAAK,4BACd,OAAO,KAAK,iEACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgDc,gBAAgB;WACtB,YAAY,SAAS,eAAe;;;;;;;;;KC/HnC,wBAAwB;WAA4B;KAC9D,+BAA+B,cAAc;WAAiC,eAAe;KACzF;;;;;;;;;;;;;;;;KAkBM,oBAAoB,UAAU,4CAC9B,KAAK,kBAAkB,gBAAgB,WAC7C,YAAY,SAAS,MACrB;WAEK,qBACG,KAAK,cAAc,UAAU,mDAAmD,YAEtF,IAAI,SAAS;;;KAKhB,UAAU,cAAc;WAA8B,eAAe;IAAM;;;;;;;;;;KAWpE,mBACV;WAA4B;GAC5B,4CAEU,YAAY,yBAAyB,oBAC7C,UAAU,uBAAuB,MACjC;;;;;;;iBAUY,oBAAoB,OAClC,SAAS,SAAS,0BAClB,kCACC;;;;;;;;iBA4Ba,yBAAyB,OACvC,SAAS,SACT,kCACC;;;;;;iBAiBa,wBAAwB,MACtC,SAAS,SACT,kCACC;;;;;;;;;;iBCjHc,yBACf,QAAQ,KAAK,mCACZ,UAAU;;;UCTI,qBAAqB,OAAO;WAClC;WAEA,QAAQ;WACR,YAAY,OAAO,UAAU;;KAG5B,0BAA0B;;;;;;;;;;;;;iBActB,yBACd,SAAS,SAAS,eAAe,SAAS,4BAC1C,OAAO,oBAAoB,0BAC3B,6BACA,gBACC,eAAe,SAAS;;;;;;;;;;;;;;;;;;;;;UCTV,oBAAoB;WAC1B"}
{"version":3,"file":"ir.d.mts","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/storage.ts","../src/ir/contract-view.ts","../src/ir/domain.ts","../src/ir/entity-kind.ts","../src/ir/storage-type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAyCiB;WACN;;uBAGW,sBAAsB;oBACxB;;;;;;;;;;;iBAYJ,WAAW,UAAU,QAAQ,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;cChC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkCI,kBAAkB,QAAQ;WAChC;WACA,SAAS,SAAS,eAAe,SAAS;;;;;;;WAO1C;;uBAG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prisma-next/utils/casts";
import { InternalError } from "@prisma-next/utils/internal-error";
import { isPlainRecord } from "@prisma-next/contract/is-plain-record";

@@ -80,3 +82,3 @@ //#region src/ir/ir-node.ts

const defaultNs = storage.namespaces[UNBOUND_NAMESPACE_ID];
if (defaultNs === void 0) throw new Error(`ContractView: contract has no default namespace (${UNBOUND_NAMESPACE_ID})`);
if (defaultNs === void 0) throw new InternalError(`ContractView: contract has no default namespace (${UNBOUND_NAMESPACE_ID})`);
return promoteBuiltinKinds(blindCast(defaultNs.entries), builtinKinds);

@@ -138,3 +140,3 @@ }

} else if (onUnknown === "carry") result[kind] = Object.freeze(rawMap);
else throw new Error(`Unknown entries key "${kind}" in namespace "${nsId ?? "?"}"; no hydration factory registered for this entity kind`);
else throw runtimeError("CONTRACT.ENTITY_KIND_UNKNOWN", `Unknown entries key "${kind}" in namespace "${nsId ?? "?"}"; no hydration factory registered for this entity kind`);
}

@@ -141,0 +143,0 @@ return result;

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

{"version":3,"file":"ir.mjs","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/contract-view.ts","../src/ir/domain.ts","../src/ir/entity-kind.ts","../src/ir/storage.ts"],"sourcesContent":["/**\n * Framework-level IR alphabet.\n *\n * The framework's contribution to Contract IR / Schema IR is a common\n * root for the IR class hierarchy and a freeze affordance. Family\n * abstract bases (e.g. `SqlNode`, `MongoSchemaIRNode`) refine the alphabet\n * for their family shape; targets ship the concrete classes.\n *\n * `kind` is an optional discriminator on the base. Families and leaves\n * that benefit from discriminated-union dispatch declare their own\n * literal `kind` at the level that earns it — Mongo leaves carry\n * per-class literals (`readonly kind = 'mongo-collection' as const`)\n * because Mongo IR has polymorphic walkers; SQL declares a single\n * family-level `kind = 'sql'` on `SqlNode` because SQL IR has no\n * polymorphic dispatch today. No framework consumer dispatches on\n * `IRNode.kind` at the BASE type — every dispatch site narrows\n * through a union of leaves where each leaf carries a literal kind, so\n * requiring `kind` at the base would be unearned. Future leaves that\n * earn polymorphic dispatch override with a required literal at that\n * leaf (e.g. `override readonly kind = 'pack-contributed-kind' as const`).\n *\n * `IRNodeBase` carries no methods: the freeze-and-assign affordance\n * lives in the free `freezeNode` helper below. Keeping `freezeNode` out\n * of the class type means an emitted contract literal type\n * (`{ readonly kind: 'mongo-collection', ... }` or an unkeyed literal\n * like `{ nativeType, codecId, nullable }`) is structurally assignable\n * to its class type — a `protected freeze()` instance method would\n * otherwise leak into the public type surface and require the literal\n * to carry it too.\n *\n * Subclasses construct fields then call `freezeNode(this)` to seal the\n * instance. Frozen instances + plain readonly fields keep IR nodes\n * JSON-clean by construction, so `JSON.stringify(node)` produces canonical\n * JSON without a `toJSON()` method. The `ContractSerializer` SPI handles\n * round-trip from canonical JSON back to typed class instances.\n *\n * The name (`IRNode` / `IRNodeBase`) reflects the dual-hierarchy reality:\n * this base is the common root for both Contract IR and Schema IR class\n * hierarchies, not a Schema-IR-specific alphabet.\n */\n\nexport interface IRNode {\n readonly kind?: string;\n}\n\nexport abstract class IRNodeBase implements IRNode {\n abstract readonly kind?: string;\n}\n\n/**\n * Seal an IR class instance after its constructor has assigned all\n * fields. The free-helper form (rather than a `protected freeze()`\n * instance method) keeps the class type structurally narrow so emitted\n * contract literal types remain assignable to their class types.\n *\n * The helper name stays `freezeNode` — it operates on IR nodes\n * regardless of root naming.\n */\nexport function freezeNode<T extends IRNode>(node: T): T {\n Object.freeze(node);\n return node;\n}\n","import type { StorageNamespace } from '@prisma-next/contract/types';\nimport { type IRNode, IRNodeBase } from './ir-node';\n\n/**\n * Reserved sentinel namespace id for the late-bound storage slot —\n * the slot whose binding the target resolves at connection time\n * rather than at authoring time. Postgres uses it for `search_path`\n * late binding; SQLite uses it for the trivial singleton; Mongo uses\n * it for the connection's `db` binding.\n *\n * Materialised target-side as a singleton subclass of the target's\n * `NamespaceBase` concretion that overrides the namespace's\n * qualifier-emission methods to elide the prefix entirely. Call sites\n * stay polymorphic and never branch on `id === UNBOUND_NAMESPACE_ID`\n * — the singleton's overrides drop the qualifier so emitted SQL / Mongo\n * commands look unqualified.\n *\n * The double-underscore decoration marks the id as a framework-reserved\n * coordinate when it appears in a JSON envelope (cold-read-as-reserved\n * — no realistic collision with user-declared namespace names).\n *\n * Encoded as an exported const (rather than scattered string literals)\n * so the sentinel-id invariant is single-sourced: any production-source\n * site that constructs an unbound-namespace singleton imports this\n * constant.\n */\nexport const UNBOUND_NAMESPACE_ID = '__unbound__' as const;\n\n/**\n * Framework-level building block for a \"namespace\" — the database-level\n * grouping under which storage objects (tables, collections, enums, …)\n * reside. Each target's namespace concretion maps the framework concept to\n * a target-native binding:\n *\n * - Postgres: a schema (`CREATE SCHEMA …`); rendered as `\"<schema>\"`.\n * - SQLite: the singleton `UNBOUND_NAMESPACE_ID`; emitted SQL has no qualifier.\n * - Mongo: the connection's `db` field; addressed as a database name.\n *\n * See `UNBOUND_NAMESPACE_ID` above for the sentinel id and the\n * singleton-subclass pattern that materialises it.\n *\n * The framework promises only the coordinate (`id`) — the named storage\n * entities a namespace contains are family-typed (SQL contributes\n * `table` / `type`, Mongo contributes `collection`, future families pick\n * their own native idiom under `entries`). Generic consumers walking \"all\n * named entries\" go through a family-typed namespace, not the framework\n * `Namespace`.\n *\n * Every namespace concretion (e.g. family-built SQL namespaces,\n * `MongoUnboundNamespace`, target-promoted namespaces like\n * `PostgresSchema`) carries exactly: `id` (enumerable string),\n * `entries` (frozen object holding entity-kind slot maps), and `kind`\n * (non-enumerable string discriminator set via `Object.defineProperty`).\n * Each slot map under `entries` uses a singular essence key (`table`,\n * `type`, `collection`, …) mapping entity names to IR classes. No other\n * own-enumerable data lives on a namespace; non-entity computed data lives\n * on the surrounding storage or contract IR. The framework's\n * `elementCoordinates(storage)` walk relies on this invariant to enumerate\n * entities structurally without family-specific knowledge.\n */\nexport interface Namespace extends IRNode, StorageNamespace {\n readonly kind: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n /**\n * Whether this namespace is the late-bound unbound slot (see\n * {@link UNBOUND_NAMESPACE_ID}). Optional so JSON-shaped structural\n * satisfiers remain valid; every hydrated `NamespaceBase` concretion\n * answers it.\n */\n readonly isUnbound?: boolean;\n}\n\nexport abstract class NamespaceBase extends IRNodeBase implements Namespace {\n abstract readonly id: string;\n abstract readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n abstract override readonly kind: string;\n\n /**\n * Answers \"am I the unbound namespace\" as node behavior, so consumers\n * never compare ids against the sentinel. This getter is the single\n * encapsulated place the {@link UNBOUND_NAMESPACE_ID} comparison lives.\n */\n get isUnbound(): boolean {\n return this.id === UNBOUND_NAMESPACE_ID;\n }\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport { UNBOUND_NAMESPACE_ID } from './namespace';\nimport type { Storage } from './storage';\n\n/**\n * Extracts the entries map of a contract's single default namespace\n * (`UNBOUND_NAMESPACE_ID`). Both single-namespace families (Mongo, SQLite)\n * store all entities under this one namespace.\n */\nexport type DefaultNamespaceEntries<TStorage extends { readonly namespaces: object }> =\n TStorage['namespaces'] extends Record<typeof UNBOUND_NAMESPACE_ID, { readonly entries: infer E }>\n ? E\n : never;\n\n/**\n * Generic single-namespace projection shape — one namespace's entity-kind slots.\n * A family supplies:\n * - `TEntries` — the family's `*NamespaceEntries` type for the namespace.\n * - `TBuiltinKinds` — the union of the family's statically-named built-in kind\n * keys (Mongo `'collection'`; SQL `'table' | 'valueSet'`).\n *\n * Each built-in kind becomes a top-level accessor; the remaining pack-contributed\n * kinds stay under `.entries` (keyed by their registered singular kind string).\n *\n * A built-in kind that the emitted contract does not carry resolves to an empty\n * map (`Record<string, never>`), matching the runtime which always materializes\n * each built-in slot. The `& string` index-signature member of `TEntries` is\n * excluded from `.entries` so only the literal pack-kind keys remain.\n */\nexport type SingleNamespaceView<TEntries, TBuiltinKinds extends string> = {\n readonly [K in TBuiltinKinds]-?: K extends keyof TEntries\n ? NonNullable<TEntries[K]>\n : Record<string, never>;\n} & {\n readonly entries: {\n readonly [K in Exclude<keyof TEntries, TBuiltinKinds | number | symbol> as string extends K\n ? never\n : K]: TEntries[K];\n };\n};\n\n/** The `entries` shape of one namespace in a storage map. */\ntype EntriesOf<TNamespace> = TNamespace extends { readonly entries: infer E } ? E : never;\n\n/**\n * The namespace-keyed entity-view map — every storage namespace keyed by its raw\n * id, each projected to its {@link SingleNamespaceView}. Mirrors\n * `NamespacedEnums` from `@prisma-next/contract/enum-accessor`: the migration\n * author's storage-side `view.namespace.<nsId>` is the twin of the runtime's\n * `db.enums.<nsId>`. Nesting the schema map under one fixed `namespace` member\n * makes it collision-proof — a schema named `storage` is `view.namespace.storage`,\n * never a contract-root key.\n */\nexport type NamespacedEntities<\n TStorage extends { readonly namespaces: object },\n TBuiltinKinds extends string,\n> = {\n readonly [Ns in keyof TStorage['namespaces']]: SingleNamespaceView<\n EntriesOf<TStorage['namespaces'][Ns]>,\n TBuiltinKinds\n >;\n};\n\n/**\n * Projects one namespace's `entries` into the view shape: each built-in kind\n * becomes a top-level slot (materialized empty if absent), and the remaining\n * pack-contributed kinds sit under `.entries`. Shared by the single-namespace\n * builder and the namespace-map builder.\n */\nexport function promoteBuiltinKinds<TView>(\n entries: Readonly<Record<string, unknown>>,\n builtinKinds: readonly string[],\n): TView {\n const view: Record<string, unknown> = {};\n const rest: Record<string, unknown> = {};\n for (const [kind, kindMap] of Object.entries(entries)) {\n if (builtinKinds.includes(kind)) {\n view[kind] = kindMap;\n } else {\n rest[kind] = kindMap;\n }\n }\n for (const kind of builtinKinds) {\n if (!(kind in view)) {\n view[kind] = {};\n }\n }\n view['entries'] = rest;\n return blindCast<TView, 'view is built to the SingleNamespaceView shape the caller parametrizes'>(\n view,\n );\n}\n\n/**\n * Builds one namespace's entity view: promotes the given built-in kind slots to\n * top-level for the default (`UNBOUND_NAMESPACE_ID`) namespace. Single-namespace\n * targets (Mongo, SQLite) use this to unwrap their sole namespace to the root.\n *\n * Throws if the contract has no default (`UNBOUND_NAMESPACE_ID`) namespace.\n */\nexport function buildSingleNamespaceView<TView>(\n storage: Storage,\n builtinKinds: readonly string[],\n): TView {\n const defaultNs = storage.namespaces[UNBOUND_NAMESPACE_ID];\n if (defaultNs === undefined) {\n throw new Error(`ContractView: contract has no default namespace (${UNBOUND_NAMESPACE_ID})`);\n }\n const entries = blindCast<\n Record<string, unknown>,\n 'Namespace.entries is the open ADR 224 dictionary Record<string, Record<string, unknown>>'\n >(defaultNs.entries);\n return promoteBuiltinKinds<TView>(entries, builtinKinds);\n}\n\n/**\n * Builds the namespace-keyed entity-view map (`{ <nsId>: SingleNamespaceView }`)\n * for every namespace in the storage, keyed by raw namespace id. Mirrors\n * `buildNamespacedEnums(domain)` — the storage-side twin.\n */\nexport function buildNamespacedEntities<TMap>(\n storage: Storage,\n builtinKinds: readonly string[],\n): TMap {\n const out: Record<string, unknown> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n out[nsId] = promoteBuiltinKinds(\n blindCast<\n Readonly<Record<string, unknown>>,\n 'Namespace.entries is the open ADR 224 dictionary Record<string, Record<string, unknown>>'\n >(ns.entries),\n builtinKinds,\n );\n }\n return blindCast<\n TMap,\n 'each namespace projected to its SingleNamespaceView; keys mirror the storage namespace ids'\n >(out);\n}\n","import type { ApplicationDomain } from '@prisma-next/contract/types';\nimport type { EntityCoordinate } from './storage';\n\n/**\n * Lazy walk over every named domain entity in a {@link ApplicationDomain},\n * yielded as {@link EntityCoordinate} tuples with `plane: 'domain'`.\n *\n * Same structural rules as {@link elementCoordinates} over storage: skip\n * scalar `id`; each other object-valued property is an entity-kind slot.\n */\nexport function* domainElementCoordinates(\n domain: Pick<ApplicationDomain, 'namespaces'>,\n): Generator<EntityCoordinate> {\n for (const [namespaceId, ns] of Object.entries(domain.namespaces)) {\n for (const [entityKind, slot] of Object.entries(ns)) {\n if (entityKind === 'id') continue;\n if (slot === null || typeof slot !== 'object') continue;\n for (const entityName of Object.keys(slot)) {\n yield { plane: 'domain', namespaceId, entityKind, entityName };\n }\n }\n }\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport type { Type } from 'arktype';\n\nexport interface EntityKindDescriptor<Input, Node> {\n readonly kind: string;\n // Type<unknown>, not Type<Input>: AnyEntityKindDescriptor widens Input to never, which would force an unusable Type<never>; concrete descriptors still carry their real schema.\n readonly schema: Type<unknown>;\n readonly construct: (input: Input) => Node;\n}\n\nexport type AnyEntityKindDescriptor = EntityKindDescriptor<never, unknown>;\n\n/**\n * Hydrates a namespace's entities from raw JSON maps into IR class instances.\n *\n * For each kind in `entries`: if the descriptor map has a descriptor,\n * construct each inner-map value; otherwise freeze-and-carry (`'carry'`)\n * or throw naming the kind and nsId (`'fail'`).\n *\n * The single boundary cast hands `value` to `descriptor.construct` as its\n * `Input`. The value satisfies the kind's `Input` either by the\n * entries-input contract at authoring time or by prior `validateStorage`\n * validation at hydration time.\n */\nexport function hydrateNamespaceEntities(\n entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>,\n kinds: ReadonlyMap<string, AnyEntityKindDescriptor>,\n onUnknown: 'carry' | 'fail',\n nsId?: string,\n): Record<string, Readonly<Record<string, unknown>>> {\n const result: Record<string, Readonly<Record<string, unknown>>> = {};\n for (const [kind, rawMap] of Object.entries(entries)) {\n const descriptor = kinds.get(kind);\n if (descriptor !== undefined) {\n const built: Record<string, unknown> = {};\n for (const [name, value] of Object.entries(rawMap)) {\n built[name] = descriptor.construct(\n blindCast<\n never,\n \"value is this kind's descriptor Input: when authoring, the typed entries-input contract produces it; when hydrating, it was validated against descriptor.schema before this loop. The never target is AnyEntityKindDescriptor's erased Input parameter.\"\n >(value),\n );\n }\n result[kind] = Object.freeze(built);\n } else if (onUnknown === 'carry') {\n result[kind] = Object.freeze(rawMap);\n } else {\n throw new Error(\n `Unknown entries key \"${kind}\" in namespace \"${nsId ?? '?'}\"; no hydration factory registered for this entity kind`,\n );\n }\n }\n return result;\n}\n","import { isPlainRecord } from '@prisma-next/contract/is-plain-record';\nimport type { StorageBase } from '@prisma-next/contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { IRNode } from './ir-node';\nimport type { Namespace } from './namespace';\n\nexport { isPlainRecord };\n\n/**\n * Canonical address for a named entity in Contract IR / Schema IR.\n *\n * `plane` is `'domain' | 'storage'`: which top-level contract plane the\n * entity lives on. Domain-side walks yield `plane: 'domain'` via\n * {@link domainElementCoordinates}; {@link elementCoordinates} over storage\n * yields `plane: 'storage'`.\n *\n * Cross-plane references obey a directional invariant: domain → storage is\n * allowed; storage → domain is forbidden. That rule is enforced by a\n * separate validator, not by constraining this coordinate shape — the\n * coordinate carries the axis the validator checks.\n *\n * Iteration order over namespace properties follows `Object.entries` order;\n * consumers that depend on ordering must sort.\n */\nexport interface EntityCoordinate {\n readonly plane: 'domain' | 'storage';\n readonly namespaceId: string;\n readonly entityKind: string;\n readonly entityName: string;\n}\n\n/**\n * Lazy walk over every named storage entity in a `Storage`-shaped\n * value, yielded as {@link EntityCoordinate} tuples with\n * `plane: 'storage'` (the parameter type binds the plane).\n *\n * Iterates each namespace's `entries` kind maps structurally. Skips\n * non-object `entries`; `id` and `kind` are not walked (`kind` is\n * non-enumerable on concretions). For every entity-kind key under\n * `entries` whose value is a non-null object, yields one coordinate per\n * entity name in that map. No family-specific kind vocabulary is required.\n */\nexport function* elementCoordinates(\n storage: Pick<StorageBase, 'namespaces'>,\n): Generator<EntityCoordinate> {\n for (const [namespaceId, ns] of Object.entries(storage.namespaces)) {\n const entries = ns.entries;\n if (entries === null || typeof entries !== 'object') continue;\n for (const [entityKind, kindMap] of Object.entries(entries)) {\n if (kindMap === null || typeof kindMap !== 'object') continue;\n for (const entityName of Object.keys(kindMap)) {\n yield { plane: 'storage', namespaceId, entityKind, entityName };\n }\n }\n }\n}\n\n/**\n * Canonical, collision-safe key for an {@link EntityCoordinate}. Encodes each\n * axis individually with `JSON.stringify` before joining with `-`, so no\n * namespace id, entity kind, or entity name can forge a collision by\n * embedding the delimiter itself (e.g. a delimiter of `:` would let\n * `('a', 'b:c', 'd')` collide with `('a:b', 'c', 'd')`) — each component is\n * quoted, and any `-` or `\"` inside it is escaped or safely inside those\n * quotes.\n *\n * The single shared key every coordinate-driven ownership/omission/collision\n * check should use — `contract infer`'s pack-described-element omission and\n * the migration tools' cross-space disjointness check both key on this.\n */\nexport function coordinateKey(\n coordinate: Pick<EntityCoordinate, 'namespaceId' | 'entityKind' | 'entityName'>,\n): string {\n return [coordinate.namespaceId, coordinate.entityKind, coordinate.entityName]\n .map((value) => JSON.stringify(value))\n .join('-');\n}\n\n/**\n * Looks up a single entity in a `Storage`-shaped value by its full coordinate.\n * Returns `undefined` if the namespace, entity kind, or entity name is absent.\n * The type parameter is a caller assertion — the walk itself is structural\n * and cannot verify the entity's shape.\n */\nexport function entityAt<T = unknown>(\n storage: Pick<StorageBase, 'namespaces'>,\n coord: Pick<EntityCoordinate, 'namespaceId' | 'entityKind' | 'entityName'>,\n): T | undefined {\n const ns = storage.namespaces[coord.namespaceId];\n if (ns === undefined) return undefined;\n const entries = ns.entries;\n if (!isPlainRecord(entries)) return undefined;\n const kindMap = entries[coord.entityKind];\n if (!isPlainRecord(kindMap)) return undefined;\n if (!Object.hasOwn(kindMap, coord.entityName)) return undefined;\n return blindCast<T | undefined, 'caller asserts the entity type at this coordinate'>(\n kindMap[coord.entityName],\n );\n}\n\n/**\n * Framework-level promise that every Contract IR / Schema IR carries a\n * collection of namespaces keyed by namespace id. Family storage\n * concretions (`SqlStorage`, `MongoStorage`) refine the shape with\n * family-specific fields (tables, collections, enums, …); target\n * concretions add target fields where the family vocabulary doesn't\n * reach.\n *\n * Keeping `namespaces` at the framework layer enforces that every storage\n * object — across any target — is namespace-scoped. The framework can\n * therefore walk the namespace map without knowing the family alphabet, and\n * the `(namespace.id, name)` keying that the verifier and planner depend on\n * is honest at every layer.\n *\n * Extends `IRNode` so the framework's IR-walking surfaces (verifiers,\n * serializers) can dispatch on `Storage`-typed fields through the same\n * IR-node alphabet as every other node — the structural dual already\n * holds in code (every concrete storage class extends an IR-node base);\n * the interface promotion makes the typing honest.\n *\n * **Persisted envelope shape is target-owned, not framework-promised.**\n * Whether the `namespaces` map appears in the on-disk JSON envelope is\n * a per-target decision made by `ContractSerializer.serializeContract`.\n * Some targets emit a JSON-clean namespace shape that round-trips\n * through `JSON.stringify` cleanly (SQL today via the family-layer\n * identity serializer); others ship runtime-only fields on their\n * namespace concretions and override `serializeContract` to strip\n * them (Mongo). Future open (F16): extend the per-target\n * `ContractSerializer` integration-test surface with an explicit\n * envelope-shape assertion for each target, so the strip-vs-pass-through\n * choice is locked at test time rather than implied by the override\n * presence/absence. Earned by PR2's per-target namespace lift, when\n * `PostgresSchema` / `SqliteUnboundDatabase` start carrying\n * target-specific fields.\n */\nexport interface Storage extends IRNode {\n readonly namespaces: Readonly<Record<string, Namespace>>;\n}\n"],"mappings":";;;AA6CA,IAAsB,aAAtB,MAAmD,CAEnD;;;;;;;;;;AAWA,SAAgB,WAA6B,MAAY;CACvD,OAAO,OAAO,IAAI;CAClB,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;ACnCA,MAAa,uBAAuB;AA8CpC,IAAsB,gBAAtB,cAA4C,WAAgC;;;;;;CAU1E,IAAI,YAAqB;EACvB,OAAO,KAAK,OAAO;CACrB;AACF;;;;;;;;;AChBA,SAAgB,oBACd,SACA,cACO;CACP,MAAM,OAAgC,CAAC;CACvC,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,OAAO,GAClD,IAAI,aAAa,SAAS,IAAI,GAC5B,KAAK,QAAQ;MAEb,KAAK,QAAQ;CAGjB,KAAK,MAAM,QAAQ,cACjB,IAAI,EAAE,QAAQ,OACZ,KAAK,QAAQ,CAAC;CAGlB,KAAK,aAAa;CAClB,OAAO,UACL,IACF;AACF;;;;;;;;AASA,SAAgB,yBACd,SACA,cACO;CACP,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,cAAc,KAAA,GAChB,MAAM,IAAI,MAAM,oDAAoD,qBAA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AAQ,UAAU,GAAG;EAClE,MAAM,UAAU,GAAG;EACnB,IAAI,YAAY,QAAQ,OAAO,YAAY,UAAU;EACrD,KAAK,MAAM,CAAC,YAAY,YAAY,OAAO,QAAQ,OAAO,GAAG;GAC3D,IAAI,YAAY,QAAQ,OAAO,YAAY,UAAU;GACrD,KAAK,MAAM,cAAc,OAAO,KAAK,OAAO,GAC1C,MAAM;IAAE,OAAO;IAAW;IAAa;IAAY;GAAW;EAElE;CACF;AACF;;;;;;;;;;;;;;AAeA,SAAgB,cACd,YACQ;CACR,OAAO;EAAC,WAAW;EAAa,WAAW;EAAY,WAAW;CAAU,CAAC,CAC1E,KAAK,UAAU,KAAK,UAAU,KAAK,CAAC,CAAC,CACrC,KAAK,GAAG;AACb;;;;;;;AAQA,SAAgB,SACd,SACA,OACe;CACf,MAAM,KAAK,QAAQ,WAAW,MAAM;CACpC,IAAI,OAAO,KAAA,GAAW,OAAO,KAAA;CAC7B,MAAM,UAAU,GAAG;CACnB,IAAI,CAAC,cAAc,OAAO,GAAG,OAAO,KAAA;CACpC,MAAM,UAAU,QAAQ,MAAM;CAC9B,IAAI,CAAC,cAAc,OAAO,GAAG,OAAO,KAAA;CACpC,IAAI,CAAC,OAAO,OAAO,SAAS,MAAM,UAAU,GAAG,OAAO,KAAA;CACtD,OAAO,UACL,QAAQ,MAAM,WAChB;AACF"}
{"version":3,"file":"ir.mjs","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/contract-view.ts","../src/ir/domain.ts","../src/ir/entity-kind.ts","../src/ir/storage.ts"],"sourcesContent":["/**\n * Framework-level IR alphabet.\n *\n * The framework's contribution to Contract IR / Schema IR is a common\n * root for the IR class hierarchy and a freeze affordance. Family\n * abstract bases (e.g. `SqlNode`, `MongoSchemaIRNode`) refine the alphabet\n * for their family shape; targets ship the concrete classes.\n *\n * `kind` is an optional discriminator on the base. Families and leaves\n * that benefit from discriminated-union dispatch declare their own\n * literal `kind` at the level that earns it — Mongo leaves carry\n * per-class literals (`readonly kind = 'mongo-collection' as const`)\n * because Mongo IR has polymorphic walkers; SQL declares a single\n * family-level `kind = 'sql'` on `SqlNode` because SQL IR has no\n * polymorphic dispatch today. No framework consumer dispatches on\n * `IRNode.kind` at the BASE type — every dispatch site narrows\n * through a union of leaves where each leaf carries a literal kind, so\n * requiring `kind` at the base would be unearned. Future leaves that\n * earn polymorphic dispatch override with a required literal at that\n * leaf (e.g. `override readonly kind = 'pack-contributed-kind' as const`).\n *\n * `IRNodeBase` carries no methods: the freeze-and-assign affordance\n * lives in the free `freezeNode` helper below. Keeping `freezeNode` out\n * of the class type means an emitted contract literal type\n * (`{ readonly kind: 'mongo-collection', ... }` or an unkeyed literal\n * like `{ nativeType, codecId, nullable }`) is structurally assignable\n * to its class type — a `protected freeze()` instance method would\n * otherwise leak into the public type surface and require the literal\n * to carry it too.\n *\n * Subclasses construct fields then call `freezeNode(this)` to seal the\n * instance. Frozen instances + plain readonly fields keep IR nodes\n * JSON-clean by construction, so `JSON.stringify(node)` produces canonical\n * JSON without a `toJSON()` method. The `ContractSerializer` SPI handles\n * round-trip from canonical JSON back to typed class instances.\n *\n * The name (`IRNode` / `IRNodeBase`) reflects the dual-hierarchy reality:\n * this base is the common root for both Contract IR and Schema IR class\n * hierarchies, not a Schema-IR-specific alphabet.\n */\n\nexport interface IRNode {\n readonly kind?: string;\n}\n\nexport abstract class IRNodeBase implements IRNode {\n abstract readonly kind?: string;\n}\n\n/**\n * Seal an IR class instance after its constructor has assigned all\n * fields. The free-helper form (rather than a `protected freeze()`\n * instance method) keeps the class type structurally narrow so emitted\n * contract literal types remain assignable to their class types.\n *\n * The helper name stays `freezeNode` — it operates on IR nodes\n * regardless of root naming.\n */\nexport function freezeNode<T extends IRNode>(node: T): T {\n Object.freeze(node);\n return node;\n}\n","import type { StorageNamespace } from '@prisma-next/contract/types';\nimport { type IRNode, IRNodeBase } from './ir-node';\n\n/**\n * Reserved sentinel namespace id for the late-bound storage slot —\n * the slot whose binding the target resolves at connection time\n * rather than at authoring time. Postgres uses it for `search_path`\n * late binding; SQLite uses it for the trivial singleton; Mongo uses\n * it for the connection's `db` binding.\n *\n * Materialised target-side as a singleton subclass of the target's\n * `NamespaceBase` concretion that overrides the namespace's\n * qualifier-emission methods to elide the prefix entirely. Call sites\n * stay polymorphic and never branch on `id === UNBOUND_NAMESPACE_ID`\n * — the singleton's overrides drop the qualifier so emitted SQL / Mongo\n * commands look unqualified.\n *\n * The double-underscore decoration marks the id as a framework-reserved\n * coordinate when it appears in a JSON envelope (cold-read-as-reserved\n * — no realistic collision with user-declared namespace names).\n *\n * Encoded as an exported const (rather than scattered string literals)\n * so the sentinel-id invariant is single-sourced: any production-source\n * site that constructs an unbound-namespace singleton imports this\n * constant.\n */\nexport const UNBOUND_NAMESPACE_ID = '__unbound__' as const;\n\n/**\n * Framework-level building block for a \"namespace\" — the database-level\n * grouping under which storage objects (tables, collections, enums, …)\n * reside. Each target's namespace concretion maps the framework concept to\n * a target-native binding:\n *\n * - Postgres: a schema (`CREATE SCHEMA …`); rendered as `\"<schema>\"`.\n * - SQLite: the singleton `UNBOUND_NAMESPACE_ID`; emitted SQL has no qualifier.\n * - Mongo: the connection's `db` field; addressed as a database name.\n *\n * See `UNBOUND_NAMESPACE_ID` above for the sentinel id and the\n * singleton-subclass pattern that materialises it.\n *\n * The framework promises only the coordinate (`id`) — the named storage\n * entities a namespace contains are family-typed (SQL contributes\n * `table` / `type`, Mongo contributes `collection`, future families pick\n * their own native idiom under `entries`). Generic consumers walking \"all\n * named entries\" go through a family-typed namespace, not the framework\n * `Namespace`.\n *\n * Every namespace concretion (e.g. family-built SQL namespaces,\n * `MongoUnboundNamespace`, target-promoted namespaces like\n * `PostgresSchema`) carries exactly: `id` (enumerable string),\n * `entries` (frozen object holding entity-kind slot maps), and `kind`\n * (non-enumerable string discriminator set via `Object.defineProperty`).\n * Each slot map under `entries` uses a singular essence key (`table`,\n * `type`, `collection`, …) mapping entity names to IR classes. No other\n * own-enumerable data lives on a namespace; non-entity computed data lives\n * on the surrounding storage or contract IR. The framework's\n * `elementCoordinates(storage)` walk relies on this invariant to enumerate\n * entities structurally without family-specific knowledge.\n */\nexport interface Namespace extends IRNode, StorageNamespace {\n readonly kind: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n /**\n * Whether this namespace is the late-bound unbound slot (see\n * {@link UNBOUND_NAMESPACE_ID}). Optional so JSON-shaped structural\n * satisfiers remain valid; every hydrated `NamespaceBase` concretion\n * answers it.\n */\n readonly isUnbound?: boolean;\n}\n\nexport abstract class NamespaceBase extends IRNodeBase implements Namespace {\n abstract readonly id: string;\n abstract readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n abstract override readonly kind: string;\n\n /**\n * Answers \"am I the unbound namespace\" as node behavior, so consumers\n * never compare ids against the sentinel. This getter is the single\n * encapsulated place the {@link UNBOUND_NAMESPACE_ID} comparison lives.\n */\n get isUnbound(): boolean {\n return this.id === UNBOUND_NAMESPACE_ID;\n }\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport { InternalError } from '@prisma-next/utils/internal-error';\nimport { UNBOUND_NAMESPACE_ID } from './namespace';\nimport type { Storage } from './storage';\n\n/**\n * Extracts the entries map of a contract's single default namespace\n * (`UNBOUND_NAMESPACE_ID`). Both single-namespace families (Mongo, SQLite)\n * store all entities under this one namespace.\n */\nexport type DefaultNamespaceEntries<TStorage extends { readonly namespaces: object }> =\n TStorage['namespaces'] extends Record<typeof UNBOUND_NAMESPACE_ID, { readonly entries: infer E }>\n ? E\n : never;\n\n/**\n * Generic single-namespace projection shape — one namespace's entity-kind slots.\n * A family supplies:\n * - `TEntries` — the family's `*NamespaceEntries` type for the namespace.\n * - `TBuiltinKinds` — the union of the family's statically-named built-in kind\n * keys (Mongo `'collection'`; SQL `'table' | 'valueSet'`).\n *\n * Each built-in kind becomes a top-level accessor; the remaining pack-contributed\n * kinds stay under `.entries` (keyed by their registered singular kind string).\n *\n * A built-in kind that the emitted contract does not carry resolves to an empty\n * map (`Record<string, never>`), matching the runtime which always materializes\n * each built-in slot. The `& string` index-signature member of `TEntries` is\n * excluded from `.entries` so only the literal pack-kind keys remain.\n */\nexport type SingleNamespaceView<TEntries, TBuiltinKinds extends string> = {\n readonly [K in TBuiltinKinds]-?: K extends keyof TEntries\n ? NonNullable<TEntries[K]>\n : Record<string, never>;\n} & {\n readonly entries: {\n readonly [K in Exclude<keyof TEntries, TBuiltinKinds | number | symbol> as string extends K\n ? never\n : K]: TEntries[K];\n };\n};\n\n/** The `entries` shape of one namespace in a storage map. */\ntype EntriesOf<TNamespace> = TNamespace extends { readonly entries: infer E } ? E : never;\n\n/**\n * The namespace-keyed entity-view map — every storage namespace keyed by its raw\n * id, each projected to its {@link SingleNamespaceView}. Mirrors\n * `NamespacedEnums` from `@prisma-next/contract/enum-accessor`: the migration\n * author's storage-side `view.namespace.<nsId>` is the twin of the runtime's\n * `db.enums.<nsId>`. Nesting the schema map under one fixed `namespace` member\n * makes it collision-proof — a schema named `storage` is `view.namespace.storage`,\n * never a contract-root key.\n */\nexport type NamespacedEntities<\n TStorage extends { readonly namespaces: object },\n TBuiltinKinds extends string,\n> = {\n readonly [Ns in keyof TStorage['namespaces']]: SingleNamespaceView<\n EntriesOf<TStorage['namespaces'][Ns]>,\n TBuiltinKinds\n >;\n};\n\n/**\n * Projects one namespace's `entries` into the view shape: each built-in kind\n * becomes a top-level slot (materialized empty if absent), and the remaining\n * pack-contributed kinds sit under `.entries`. Shared by the single-namespace\n * builder and the namespace-map builder.\n */\nexport function promoteBuiltinKinds<TView>(\n entries: Readonly<Record<string, unknown>>,\n builtinKinds: readonly string[],\n): TView {\n const view: Record<string, unknown> = {};\n const rest: Record<string, unknown> = {};\n for (const [kind, kindMap] of Object.entries(entries)) {\n if (builtinKinds.includes(kind)) {\n view[kind] = kindMap;\n } else {\n rest[kind] = kindMap;\n }\n }\n for (const kind of builtinKinds) {\n if (!(kind in view)) {\n view[kind] = {};\n }\n }\n view['entries'] = rest;\n return blindCast<TView, 'view is built to the SingleNamespaceView shape the caller parametrizes'>(\n view,\n );\n}\n\n/**\n * Builds one namespace's entity view: promotes the given built-in kind slots to\n * top-level for the default (`UNBOUND_NAMESPACE_ID`) namespace. Single-namespace\n * targets (Mongo, SQLite) use this to unwrap their sole namespace to the root.\n *\n * Throws if the contract has no default (`UNBOUND_NAMESPACE_ID`) namespace.\n */\nexport function buildSingleNamespaceView<TView>(\n storage: Storage,\n builtinKinds: readonly string[],\n): TView {\n const defaultNs = storage.namespaces[UNBOUND_NAMESPACE_ID];\n if (defaultNs === undefined) {\n throw new InternalError(\n `ContractView: contract has no default namespace (${UNBOUND_NAMESPACE_ID})`,\n );\n }\n const entries = blindCast<\n Record<string, unknown>,\n 'Namespace.entries is the open ADR 224 dictionary Record<string, Record<string, unknown>>'\n >(defaultNs.entries);\n return promoteBuiltinKinds<TView>(entries, builtinKinds);\n}\n\n/**\n * Builds the namespace-keyed entity-view map (`{ <nsId>: SingleNamespaceView }`)\n * for every namespace in the storage, keyed by raw namespace id. Mirrors\n * `buildNamespacedEnums(domain)` — the storage-side twin.\n */\nexport function buildNamespacedEntities<TMap>(\n storage: Storage,\n builtinKinds: readonly string[],\n): TMap {\n const out: Record<string, unknown> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n out[nsId] = promoteBuiltinKinds(\n blindCast<\n Readonly<Record<string, unknown>>,\n 'Namespace.entries is the open ADR 224 dictionary Record<string, Record<string, unknown>>'\n >(ns.entries),\n builtinKinds,\n );\n }\n return blindCast<\n TMap,\n 'each namespace projected to its SingleNamespaceView; keys mirror the storage namespace ids'\n >(out);\n}\n","import type { ApplicationDomain } from '@prisma-next/contract/types';\nimport type { EntityCoordinate } from './storage';\n\n/**\n * Lazy walk over every named domain entity in a {@link ApplicationDomain},\n * yielded as {@link EntityCoordinate} tuples with `plane: 'domain'`.\n *\n * Same structural rules as {@link elementCoordinates} over storage: skip\n * scalar `id`; each other object-valued property is an entity-kind slot.\n */\nexport function* domainElementCoordinates(\n domain: Pick<ApplicationDomain, 'namespaces'>,\n): Generator<EntityCoordinate> {\n for (const [namespaceId, ns] of Object.entries(domain.namespaces)) {\n for (const [entityKind, slot] of Object.entries(ns)) {\n if (entityKind === 'id') continue;\n if (slot === null || typeof slot !== 'object') continue;\n for (const entityName of Object.keys(slot)) {\n yield { plane: 'domain', namespaceId, entityKind, entityName };\n }\n }\n }\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport type { Type } from 'arktype';\nimport { runtimeError } from '../shared/runtime-error';\n\nexport interface EntityKindDescriptor<Input, Node> {\n readonly kind: string;\n // Type<unknown>, not Type<Input>: AnyEntityKindDescriptor widens Input to never, which would force an unusable Type<never>; concrete descriptors still carry their real schema.\n readonly schema: Type<unknown>;\n readonly construct: (input: Input) => Node;\n}\n\nexport type AnyEntityKindDescriptor = EntityKindDescriptor<never, unknown>;\n\n/**\n * Hydrates a namespace's entities from raw JSON maps into IR class instances.\n *\n * For each kind in `entries`: if the descriptor map has a descriptor,\n * construct each inner-map value; otherwise freeze-and-carry (`'carry'`)\n * or throw naming the kind and nsId (`'fail'`).\n *\n * The single boundary cast hands `value` to `descriptor.construct` as its\n * `Input`. The value satisfies the kind's `Input` either by the\n * entries-input contract at authoring time or by prior `validateStorage`\n * validation at hydration time.\n */\nexport function hydrateNamespaceEntities(\n entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>,\n kinds: ReadonlyMap<string, AnyEntityKindDescriptor>,\n onUnknown: 'carry' | 'fail',\n nsId?: string,\n): Record<string, Readonly<Record<string, unknown>>> {\n const result: Record<string, Readonly<Record<string, unknown>>> = {};\n for (const [kind, rawMap] of Object.entries(entries)) {\n const descriptor = kinds.get(kind);\n if (descriptor !== undefined) {\n const built: Record<string, unknown> = {};\n for (const [name, value] of Object.entries(rawMap)) {\n built[name] = descriptor.construct(\n blindCast<\n never,\n \"value is this kind's descriptor Input: when authoring, the typed entries-input contract produces it; when hydrating, it was validated against descriptor.schema before this loop. The never target is AnyEntityKindDescriptor's erased Input parameter.\"\n >(value),\n );\n }\n result[kind] = Object.freeze(built);\n } else if (onUnknown === 'carry') {\n result[kind] = Object.freeze(rawMap);\n } else {\n throw runtimeError(\n 'CONTRACT.ENTITY_KIND_UNKNOWN',\n `Unknown entries key \"${kind}\" in namespace \"${nsId ?? '?'}\"; no hydration factory registered for this entity kind`,\n );\n }\n }\n return result;\n}\n","import { isPlainRecord } from '@prisma-next/contract/is-plain-record';\nimport type { StorageBase } from '@prisma-next/contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { IRNode } from './ir-node';\nimport type { Namespace } from './namespace';\n\nexport { isPlainRecord };\n\n/**\n * Canonical address for a named entity in Contract IR / Schema IR.\n *\n * `plane` is `'domain' | 'storage'`: which top-level contract plane the\n * entity lives on. Domain-side walks yield `plane: 'domain'` via\n * {@link domainElementCoordinates}; {@link elementCoordinates} over storage\n * yields `plane: 'storage'`.\n *\n * Cross-plane references obey a directional invariant: domain → storage is\n * allowed; storage → domain is forbidden. That rule is enforced by a\n * separate validator, not by constraining this coordinate shape — the\n * coordinate carries the axis the validator checks.\n *\n * Iteration order over namespace properties follows `Object.entries` order;\n * consumers that depend on ordering must sort.\n */\nexport interface EntityCoordinate {\n readonly plane: 'domain' | 'storage';\n readonly namespaceId: string;\n readonly entityKind: string;\n readonly entityName: string;\n}\n\n/**\n * Lazy walk over every named storage entity in a `Storage`-shaped\n * value, yielded as {@link EntityCoordinate} tuples with\n * `plane: 'storage'` (the parameter type binds the plane).\n *\n * Iterates each namespace's `entries` kind maps structurally. Skips\n * non-object `entries`; `id` and `kind` are not walked (`kind` is\n * non-enumerable on concretions). For every entity-kind key under\n * `entries` whose value is a non-null object, yields one coordinate per\n * entity name in that map. No family-specific kind vocabulary is required.\n */\nexport function* elementCoordinates(\n storage: Pick<StorageBase, 'namespaces'>,\n): Generator<EntityCoordinate> {\n for (const [namespaceId, ns] of Object.entries(storage.namespaces)) {\n const entries = ns.entries;\n if (entries === null || typeof entries !== 'object') continue;\n for (const [entityKind, kindMap] of Object.entries(entries)) {\n if (kindMap === null || typeof kindMap !== 'object') continue;\n for (const entityName of Object.keys(kindMap)) {\n yield { plane: 'storage', namespaceId, entityKind, entityName };\n }\n }\n }\n}\n\n/**\n * Canonical, collision-safe key for an {@link EntityCoordinate}. Encodes each\n * axis individually with `JSON.stringify` before joining with `-`, so no\n * namespace id, entity kind, or entity name can forge a collision by\n * embedding the delimiter itself (e.g. a delimiter of `:` would let\n * `('a', 'b:c', 'd')` collide with `('a:b', 'c', 'd')`) — each component is\n * quoted, and any `-` or `\"` inside it is escaped or safely inside those\n * quotes.\n *\n * The single shared key every coordinate-driven ownership/omission/collision\n * check should use — `contract infer`'s pack-described-element omission and\n * the migration tools' cross-space disjointness check both key on this.\n */\nexport function coordinateKey(\n coordinate: Pick<EntityCoordinate, 'namespaceId' | 'entityKind' | 'entityName'>,\n): string {\n return [coordinate.namespaceId, coordinate.entityKind, coordinate.entityName]\n .map((value) => JSON.stringify(value))\n .join('-');\n}\n\n/**\n * Looks up a single entity in a `Storage`-shaped value by its full coordinate.\n * Returns `undefined` if the namespace, entity kind, or entity name is absent.\n * The type parameter is a caller assertion — the walk itself is structural\n * and cannot verify the entity's shape.\n */\nexport function entityAt<T = unknown>(\n storage: Pick<StorageBase, 'namespaces'>,\n coord: Pick<EntityCoordinate, 'namespaceId' | 'entityKind' | 'entityName'>,\n): T | undefined {\n const ns = storage.namespaces[coord.namespaceId];\n if (ns === undefined) return undefined;\n const entries = ns.entries;\n if (!isPlainRecord(entries)) return undefined;\n const kindMap = entries[coord.entityKind];\n if (!isPlainRecord(kindMap)) return undefined;\n if (!Object.hasOwn(kindMap, coord.entityName)) return undefined;\n return blindCast<T | undefined, 'caller asserts the entity type at this coordinate'>(\n kindMap[coord.entityName],\n );\n}\n\n/**\n * Framework-level promise that every Contract IR / Schema IR carries a\n * collection of namespaces keyed by namespace id. Family storage\n * concretions (`SqlStorage`, `MongoStorage`) refine the shape with\n * family-specific fields (tables, collections, enums, …); target\n * concretions add target fields where the family vocabulary doesn't\n * reach.\n *\n * Keeping `namespaces` at the framework layer enforces that every storage\n * object — across any target — is namespace-scoped. The framework can\n * therefore walk the namespace map without knowing the family alphabet, and\n * the `(namespace.id, name)` keying that the verifier and planner depend on\n * is honest at every layer.\n *\n * Extends `IRNode` so the framework's IR-walking surfaces (verifiers,\n * serializers) can dispatch on `Storage`-typed fields through the same\n * IR-node alphabet as every other node — the structural dual already\n * holds in code (every concrete storage class extends an IR-node base);\n * the interface promotion makes the typing honest.\n *\n * **Persisted envelope shape is target-owned, not framework-promised.**\n * Whether the `namespaces` map appears in the on-disk JSON envelope is\n * a per-target decision made by `ContractSerializer.serializeContract`.\n * Some targets emit a JSON-clean namespace shape that round-trips\n * through `JSON.stringify` cleanly (SQL today via the family-layer\n * identity serializer); others ship runtime-only fields on their\n * namespace concretions and override `serializeContract` to strip\n * them (Mongo). Future open (F16): extend the per-target\n * `ContractSerializer` integration-test surface with an explicit\n * envelope-shape assertion for each target, so the strip-vs-pass-through\n * choice is locked at test time rather than implied by the override\n * presence/absence. Earned by PR2's per-target namespace lift, when\n * `PostgresSchema` / `SqliteUnboundDatabase` start carrying\n * target-specific fields.\n */\nexport interface Storage extends IRNode {\n readonly namespaces: Readonly<Record<string, Namespace>>;\n}\n"],"mappings":";;;;;AA6CA,IAAsB,aAAtB,MAAmD,CAEnD;;;;;;;;;;AAWA,SAAgB,WAA6B,MAAY;CACvD,OAAO,OAAO,IAAI;CAClB,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;ACnCA,MAAa,uBAAuB;AA8CpC,IAAsB,gBAAtB,cAA4C,WAAgC;;;;;;CAU1E,IAAI,YAAqB;EACvB,OAAO,KAAK,OAAO;CACrB;AACF;;;;;;;;;ACfA,SAAgB,oBACd,SACA,cACO;CACP,MAAM,OAAgC,CAAC;CACvC,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,MAAM,YAA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version": "0.16.0-dev.31",
"license": "Apache-2.0",

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

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

@@ -18,4 +18,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",

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

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

import { InternalError } from '@prisma-next/utils/internal-error';
import type { DiffableNode, SchemaDiffIssue } from './schema-diff';

@@ -149,3 +150,3 @@

.map((node) => node.issue.path.join('/'));
throw new Error(
throw new InternalError(
`orderIssuesByDependencies: dependency cycle among schema-diff issues (unresolved: ${unresolved.join(', ')})`,

@@ -152,0 +153,0 @@ );

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

import { InternalError } from '@prisma-next/utils/internal-error';
/**

@@ -55,3 +57,3 @@ * A root-anchored chain of `(nodeKind, id)` steps identifying a node in a

if (hasActual) return 'not-expected';
throw new Error(
throw new InternalError(
`issueOutcome: issue at "${issue.path.join('/')}" carries neither an expected nor an actual node`,

@@ -99,3 +101,5 @@ );

if (map.has(key)) {
throw new Error(`diffSchemas: duplicate id among siblings: ${node.nodeKind}/${node.id}`);
throw new InternalError(
`diffSchemas: duplicate id among siblings: ${node.nodeKind}/${node.id}`,
);
}

@@ -102,0 +106,0 @@ map.set(key, node);

import { checkContractComponentRequirements } from '../shared/framework-components';
import { runtimeError } from '../shared/runtime-error';
import type {

@@ -37,3 +38,4 @@ RuntimeAdapterDescriptor,

if (result.targetMismatch) {
throw new Error(
throw runtimeError(
'CONTRACT.TARGET_MISMATCH',
`Contract target '${result.targetMismatch.actual}' does not match runtime target descriptor '${result.targetMismatch.expected}'.`,

@@ -44,3 +46,4 @@ );

for (const packId of result.missingExtensionPackIds) {
throw new Error(
throw runtimeError(
'RUNTIME.MISSING_EXTENSION_PACK',
`Contract requires extension pack '${packId}', but runtime descriptors do not provide a matching component.`,

@@ -47,0 +50,0 @@ );

import { blindCast } from '@prisma-next/utils/casts';
import { InternalError } from '@prisma-next/utils/internal-error';
import { UNBOUND_NAMESPACE_ID } from './namespace';

@@ -107,3 +108,5 @@ import type { Storage } from './storage';

if (defaultNs === undefined) {
throw new Error(`ContractView: contract has no default namespace (${UNBOUND_NAMESPACE_ID})`);
throw new InternalError(
`ContractView: contract has no default namespace (${UNBOUND_NAMESPACE_ID})`,
);
}

@@ -110,0 +113,0 @@ const entries = blindCast<

import { blindCast } from '@prisma-next/utils/casts';
import type { Type } from 'arktype';
import { runtimeError } from '../shared/runtime-error';

@@ -48,3 +49,4 @@ export interface EntityKindDescriptor<Input, Node> {

} else {
throw new Error(
throw runtimeError(
'CONTRACT.ENTITY_KIND_UNKNOWN',
`Unknown entries key "${kind}" in namespace "${nsId ?? '?'}"; no hydration factory registered for this entity kind`,

@@ -51,0 +53,0 @@ );

import { n as runtimeError } from "./runtime-error-BA9d7XjZ.mjs";
import { blindCast } from "@prisma-next/utils/casts";
import { isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue } from "@prisma-next/contract/types";
import { ifDefined } from "@prisma-next/utils/defined";
//#region src/shared/framework-authoring.ts
/**
* Classifies an `enum` block's members (before codec decoding, which needs
* the codec chosen first) into which default codec an omitted `@@type`
* should resolve to:
*
* - every member is `bare`, or a `value` whose raw JSON is a string → `'text'`
* - every member is a `value` whose raw JSON is an integer → `'int'`
* - anything else (float, bigint, boolean, mixed, or a `ref`/`option`/`list`
* parameter) → `null`, meaning the caller must require an explicit `@@type`.
*/
function classifyEnumMemberType(block) {
let sawText = false;
let sawInt = false;
for (const paramValue of Object.values(block.parameters)) {
if (paramValue.kind === "bare") {
sawText = true;
continue;
}
if (paramValue.kind !== "value") return null;
let jsonValue;
try {
jsonValue = JSON.parse(paramValue.raw);
} catch {
return null;
}
if (typeof jsonValue === "string") sawText = true;
else if (typeof jsonValue === "number" && Number.isInteger(jsonValue)) sawInt = true;
else return null;
}
if (sawText && sawInt) return null;
if (sawText) return "text";
if (sawInt) return "int";
return null;
}
/**
* Resolves the codec id for an `enum` block. When `@@type` is absent, the codec
* is inferred from the members via {@link classifyEnumMemberType}; otherwise the
* explicit `@@type("codec")` argument is parsed. Pushes the appropriate
* diagnostic and returns `undefined` when neither yields a codec. `codecSpan` is
* the span downstream codec-validation diagnostics should anchor to. Shared by
* every family's enum factory so inference and the explicit path stay identical.
*/
function resolveEnumCodecId(block, ctx) {
const sourceId = ctx.sourceId ?? "unknown";
const typeAttr = block.blockAttributes.find((a) => a.name === "type");
if (typeAttr === void 0) {
const inferredKind = classifyEnumMemberType(block);
if (inferredKind === null || ctx.enumInferenceCodecs === void 0) {
ctx.diagnostics?.push({
code: "PSL_ENUM_CANNOT_INFER_TYPE",
message: `cannot infer @@type for enum "${block.name}"; add an explicit @@type(...)`,
sourceId,
span: block.span
});
return;
}
return {
codecId: ctx.enumInferenceCodecs[inferredKind],
codecSpan: block.span
};
}
const rawCodecArg = typeAttr.args[0]?.value;
const codecId = rawCodecArg?.startsWith("\"") && rawCodecArg.endsWith("\"") && rawCodecArg.length >= 2 ? rawCodecArg.slice(1, -1) : void 0;
if (codecId === void 0) {
ctx.diagnostics?.push({
code: "PSL_ENUM_MISSING_TYPE",
message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`,
sourceId,
span: typeAttr.span
});
return;
}
return {
codecId,
codecSpan: typeAttr.args[0]?.span ?? typeAttr.span
};
}
function isAuthoringArgRef(value) {
if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
const { index, path } = value;
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
return true;
}
function isAuthoringSelectRef(value) {
if (!isAuthoringTemplateRecord(value) || value["kind"] !== "select") return false;
const index = value["index"];
const path = value["path"];
const cases = value["cases"];
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
return typeof cases === "object" && cases !== null && !Array.isArray(cases);
}
function isAuthoringTemplateRecord(value) {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function readTemplateArgumentValue(args, index, path) {
let value = args[index];
for (const segment of path ?? []) {
if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) return;
value = value[segment];
}
return value;
}
function isAuthoringTypeConstructorDescriptor(value) {
return "kind" in value && value.kind === "typeConstructor";
}
function isAuthoringFieldPresetDescriptor(value) {
return "kind" in value && value.kind === "fieldPreset";
}
function isAuthoringEntityTypeDescriptor(value) {
return "kind" in value && value.kind === "entity";
}
function isAuthoringPslBlockDescriptor(value) {
return "kind" in value && value.kind === "pslBlock";
}
function isAuthoringModelAttributeDescriptor(value) {
return "kind" in value && value.kind === "modelAttribute";
}
/**
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
*
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
* registration must NOT be treated as a "namespace" with sub-paths. Callers
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
*/
function hasRegisteredFieldNamespace(contributions, namespace) {
if (contributions?.field === void 0 || !Object.hasOwn(contributions.field, namespace)) return false;
const value = contributions.field[namespace];
return value !== void 0 && !isAuthoringFieldPresetDescriptor(value);
}
function isCopyableNamespaceObject(value) {
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
const proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null;
}
/**
* Deep structural check run only at the composition boundary (the merge and
* collect walkers) to classify a raw namespace-tree node as a leaf descriptor.
* A node counts as a leaf iff its `kind` matches `descriptorKind` AND it
* carries that kind's required fields.
*
* This is boundary validation over `unknown`, NOT a type-predicate: the four
* exported `isAuthoring*Descriptor` predicates deliberately narrow on `kind`
* alone and trust the static types. The walkers, by contrast, also receive
* type-bypassing packs (`as unknown as never` in tests, untyped JS at runtime)
* whose descriptor-shaped-but-incomplete nodes must be rejected rather than
* silently treated as sub-namespaces — so the well-formedness check lives here.
*/
function isWellFormedDescriptor(value, descriptorKind) {
if (typeof value !== "object" || value === null) return false;
if (!("kind" in value) || value.kind !== descriptorKind) return false;
switch (descriptorKind) {
case "typeConstructor":
case "fieldPreset": {
if (!("output" in value)) return false;
const output = value.output;
return typeof output === "object" && output !== null;
}
case "entity": {
if (!("discriminator" in value) || typeof value.discriminator !== "string") return false;
if (value.discriminator.length === 0) return false;
if (!("output" in value)) return false;
const output = value.output;
if (typeof output !== "object" || output === null) return false;
const factory = "factory" in output ? output.factory : void 0;
const template = "template" in output ? output.template : void 0;
return typeof factory === "function" || template !== void 0;
}
case "pslBlock": {
if (!("keyword" in value) || typeof value.keyword !== "string" || value.keyword.length === 0) return false;
if (!("discriminator" in value) || typeof value.discriminator !== "string" || value.discriminator.length === 0) return false;
if (!("name" in value)) return false;
const name = value.name;
if (typeof name !== "object" || name === null) return false;
if (!("required" in name) || typeof name.required !== "boolean") return false;
if (!("parameters" in value)) return false;
const parameters = value.parameters;
return typeof parameters === "object" && parameters !== null && !Array.isArray(parameters);
}
case "modelAttribute":
if (!("attribute" in value) || typeof value.attribute !== "string" || value.attribute.length === 0) return false;
if (!("spec" in value)) return false;
return "lower" in value && typeof value.lower === "function";
default: return false;
}
}
function deepCopyNamespace(source, descriptorKind) {
const copy = {};
for (const [key, value] of Object.entries(source)) copy[key] = isCopyableNamespaceObject(value) && !isWellFormedDescriptor(value, descriptorKind) ? deepCopyNamespace(value, descriptorKind) : value;
return copy;
}
/**
* Merges `source` into `target` recursively at the descriptor-namespace
* level. `descriptorKind` is the `kind` value ('typeConstructor',
* 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
* (terminal merge point; same-path registrations across components are
* reported as duplicates) as opposed to a sub-namespace (recursion target).
*
* Path segments are validated against prototype-pollution names
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
* recognized leaf nor a plain object — e.g. a malformed descriptor
* where the canonical leaf guard rejected it for missing `output` —
* is reported as an invalid contribution rather than recursed into,
* which would either silently mangle state or infinite-loop on
* primitive properties.
*
* Within-registry duplicate detection is this walker's job;
* cross-registry detection runs separately via
* `assertNoCrossRegistryCollisions` after merging completes.
*/
function mergeAuthoringNamespaces(target, source, path, descriptorKind, label) {
const assertSafePath = (currentPath) => {
const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype");
if (blockedSegment) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`);
};
for (const [key, sourceValue] of Object.entries(source)) {
const currentPath = [...path, key];
assertSafePath(currentPath);
const hasExistingValue = Object.hasOwn(target, key);
const existingValue = hasExistingValue ? target[key] : void 0;
if (!hasExistingValue) {
target[key] = isCopyableNamespaceObject(sourceValue) && !isWellFormedDescriptor(sourceValue, descriptorKind) ? deepCopyNamespace(sourceValue, descriptorKind) : sourceValue;
continue;
}
const existingIsLeaf = isWellFormedDescriptor(existingValue, descriptorKind);
const sourceIsLeaf = isWellFormedDescriptor(sourceValue, descriptorKind);
if (existingIsLeaf || sourceIsLeaf) throw new Error(`Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`);
if (!isCopyableNamespaceObject(existingValue) || !isCopyableNamespaceObject(sourceValue)) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`);
mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, descriptorKind, label);
}
}
/**
* Collects the full dotted paths of every well-formed descriptor of
* `descriptorKind` in a raw contribution tree, using the same boundary
* classification as {@link mergeAuthoringNamespaces}. Lets assembly-level
* callers attribute each contributed path to its contributing component
* before merging, so a same-path collision can be reported naming both
* contributors.
*/
function collectContributedDescriptorPaths(namespace, descriptorKind, path = []) {
const paths = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isWellFormedDescriptor(value, descriptorKind)) {
paths.push(currentPath.join("."));
continue;
}
if (isCopyableNamespaceObject(value)) paths.push(...collectContributedDescriptorPaths(value, descriptorKind, currentPath));
}
return paths;
}
/**
* Derives the scalar view of an assembled authoring type namespace: every
* **top-level** type constructor that is instantiable with an empty argument
* list — all declared args optional and no entity-ref argument. A bare type
* name `T` in a schema is semantically the zero-arg instantiation `T()`, so
* each entry is exactly what that call produces (defaulted template values
* applied, absent optional-arg typeParams keys omitted). Constructors
* registered under a namespace segment, constructors with required args, and
* entity-ref constructors are not scalars and are excluded.
*
* Eligibility needs no template inspection: templates that cannot resolve
* for their legal call shapes are rejected at the composition boundary by
* {@link assertResolvableTypeConstructorTemplates}, so the zero-arg
* instantiation below cannot fail for an eligible constructor.
*/
function collectScalarTypeConstructors(namespace) {
const result = /* @__PURE__ */ new Map();
for (const [name, value] of Object.entries(namespace)) {
if (!isAuthoringTypeConstructorDescriptor(value)) continue;
if (value.entityRefArg !== void 0) continue;
if (value.args?.some((arg) => arg.optional !== true)) continue;
result.set(name, instantiateAuthoringTypeConstructor(value, []));
}
return result;
}
function visitTemplateArgRefs(template, visit) {
if (template === void 0) return;
if (isAuthoringArgRef(template)) {
visit(template);
visitTemplateArgRefs(template.default, visit);
return;
}
if (Array.isArray(template)) {
for (const value of template) visitTemplateArgRefs(value, visit);
return;
}
if (typeof template === "object" && template !== null) for (const value of Object.values(template)) visitTemplateArgRefs(value, visit);
}
/**
* Boundary validation for a contributed authoring type namespace, called
* per contributing component at assembly (which supplies `contributedBy`
* for attribution). Rejects what the types cannot express — entity-ref
* constructors are skipped (their output derives from the referenced
* entity): a plain constructor must declare its output storage type name,
* and every `typeParams` arg-ref (including refs inside arg-ref defaults)
* must point at a declared argument index.
*/
function assertResolvableTypeConstructorTemplates(namespace, contributedBy, path = []) {
for (const [name, value] of Object.entries(namespace)) {
const currentPath = [...path, name];
if (!isAuthoringTypeConstructorDescriptor(value)) {
assertResolvableTypeConstructorTemplates(value, contributedBy, currentPath);
continue;
}
if (value.entityRefArg !== void 0) continue;
const args = value.args ?? [];
const invalid = (detail) => /* @__PURE__ */ new Error(`Invalid authoring type constructor "${currentPath.join(".")}" contributed by descriptor "${contributedBy}". ${detail}`);
if (value.output.nativeType === void 0) throw invalid("The output declares no storage type template and no entityRefArg; a plain constructor must declare one.");
for (const [key, template] of Object.entries(value.output.typeParams ?? {})) visitTemplateArgRefs(template, (ref) => {
if (args[ref.index] === void 0) throw invalid(`output.typeParams.${key} references argument ${ref.index}, but the constructor declares ${args.length} argument(s). Declare the argument or correct the reference index.`);
});
}
}
function collectDescriptorPaths(namespace, isLeaf, path = []) {
const paths = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isLeaf(value)) {
paths.push(currentPath.join("."));
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath));
}
return paths;
}
function collectDescriptorEntries(namespace, isLeaf, descriptorKind, label, path = []) {
const entries = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isLeaf(value)) {
if (!isWellFormedDescriptor(value, descriptorKind)) throw new Error(`Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
if (value.discriminator.length > 0) entries.push({
path: currentPath.join("."),
discriminator: value.discriminator
});
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
const record = blindCast(value);
if ((record["kind"] !== void 0 || record["keyword"] !== void 0 || record["discriminator"] !== void 0) && !isLeaf(value)) {
const hasKind = record["kind"] === "pslBlock";
const hasKeyword = typeof record["keyword"] === "string";
const hasDiscriminator = typeof record["discriminator"] === "string";
if (hasKind || hasKeyword && hasDiscriminator) throw new Error(`Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
}
entries.push(...collectDescriptorEntries(value, isLeaf, descriptorKind, label, currentPath));
}
}
return entries;
}
/**
* Throws when two or more entries in the same namespace share a key. A
* duplicate key makes dispatch ambiguous — the caller's lookup dispatches by
* this key, so one entry would silently shadow the other. Catch duplicates
* before building any dispatch map.
*
* `label` (e.g. `'pslBlock'`, `'entityType'`) names which namespace the
* duplicate was found in and is carried in the structured error metadata;
* the key itself is always called `key` in both the message and the
* metadata, since what it semantically represents (a discriminator for
* `entityType`, the parser's dispatch keyword for `pslBlock`) is the
* caller's concern, not this function's.
*/
function assertUniqueDiscriminators(entries, label) {
const seen = /* @__PURE__ */ new Map();
for (const { path, discriminator: key } of entries) {
const existing = seen.get(key);
if (existing !== void 0) throw runtimeError("RUNTIME.DUPLICATE_AUTHORING_DISCRIMINATOR", `Duplicate ${label} key "${key}" registered at both "${existing}" and "${path}". Each ${label} contribution must use a unique key.`, {
label,
key,
existingPath: existing,
path
});
seen.set(key, path);
}
}
function collectPslBlockDescriptorEntries(namespace, path = []) {
const entries = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isAuthoringPslBlockDescriptor(value)) {
if (!isWellFormedDescriptor(value, "pslBlock")) throw new Error(`Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push({
path: currentPath.join("."),
discriminator: value.discriminator,
keyword: value.keyword
});
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
const record = blindCast(value);
const hasKind = record["kind"] === "pslBlock";
const hasKeyword = typeof record["keyword"] === "string";
const hasDiscriminator = typeof record["discriminator"] === "string";
if (hasKind || hasKeyword && hasDiscriminator) throw new Error(`Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push(...collectPslBlockDescriptorEntries(value, currentPath));
}
}
return entries;
}
/**
* Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory
* with the same discriminator. An `entityTypes` factory may stand alone (e.g.
* `enum`, reachable from the TypeScript builder without any PSL block).
*
* Uniqueness for pslBlock entries is keyed on **keyword**, not discriminator:
* several keywords (e.g. `policy_select`/`policy_insert`) may legitimately
* share one discriminator, routing to the same `entityTypes` factory and the
* same `entries[discriminator]` slot — that N:1 shape is exactly what lets
* one entity kind be authored through several PSL keywords. What must stay
* unique is the keyword itself, since that's what the parser dispatches on.
*/
function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) {
const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace);
const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entity", "entityType");
assertUniqueDiscriminators(blockEntries.map((entry) => ({
path: entry.path,
discriminator: entry.keyword
})), "pslBlock");
assertUniqueDiscriminators(entityEntries, "entityType");
const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator));
for (const block of blockEntries) if (!entityDiscriminators.has(block.discriminator)) throw new Error(`Incomplete extension contribution: pslBlock helper "${block.path}" registers discriminator "${block.discriminator}" but no entityType contribution shares that discriminator. An extension-contributed PSL block requires a matching entityType factory so the parsed AST node can lower to an IR class instance; add an entityType helper with discriminator "${block.discriminator}".`);
}
function collectModelAttributeEntries(namespace, path = []) {
const entries = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isAuthoringModelAttributeDescriptor(value)) {
if (!isWellFormedDescriptor(value, "modelAttribute")) throw new Error(`Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push({
path: currentPath.join("."),
discriminator: value.attribute
});
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
const record = blindCast(value);
if (typeof record["attribute"] === "string" && "spec" in record) throw new Error(`Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
entries.push(...collectModelAttributeEntries(value, currentPath));
}
}
return entries;
}
/**
* Throws when two modelAttribute contributions — at any paths, even
* different ones — claim the same bare `@@` attribute name. The family
* interpreter dispatches by attribute name, not by registration path, so
* two descriptors claiming the same name would have one silently shadow
* the other.
*/
function assertUniqueModelAttributeNames(entries) {
const seen = /* @__PURE__ */ new Map();
for (const { path, discriminator: attribute } of entries) {
const existing = seen.get(attribute);
if (existing !== void 0) throw new Error(`Duplicate modelAttribute "${attribute}" registered at both "${existing}" and "${path}". Each modelAttribute contribution must claim a unique attribute name.`);
seen.set(attribute, path);
}
}
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) {
const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor));
const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.";
for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw new Error(`Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw new Error(`Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace);
assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace));
assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace);
}
function collectDescriptorNodes(namespace, isLeaf, path = []) {
const nodes = [];
for (const [key, value] of Object.entries(namespace)) {
const currentPath = [...path, key];
if (isLeaf(value)) {
nodes.push([currentPath.join("."), value]);
continue;
}
if (typeof value === "object" && value !== null && !Array.isArray(value)) nodes.push(...collectDescriptorNodes(value, isLeaf, currentPath));
}
return nodes;
}
function collectSelectRefs(value, found) {
if (typeof value !== "object" || value === null) return;
if (isAuthoringSelectRef(value)) {
found.push(value);
for (const caseTemplate of Object.values(value.cases)) collectSelectRefs(caseTemplate, found);
return;
}
if (isAuthoringArgRef(value)) {
collectSelectRefs(value.default, found);
return;
}
if (Array.isArray(value)) {
for (const entry of value) collectSelectRefs(entry, found);
return;
}
for (const entry of Object.values(value)) collectSelectRefs(entry, found);
}
function validateSelectRefsAgainstArgs(label, helperPath, args, templateRoot) {
const selects = [];
collectSelectRefs(templateRoot, selects);
for (const select of selects) {
const position = `#${select.index + 1}`;
let descriptor = args?.[select.index];
if (descriptor === void 0) throw new Error(`Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`);
for (const segment of select.path ?? []) {
descriptor = descriptor.kind === "object" ? descriptor.properties[segment] : void 0;
if (descriptor === void 0) throw new Error(`Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join(".")}", which does not resolve to a declared argument property.`);
}
if (descriptor.kind !== "option") throw new Error(`Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`);
const argumentLabel = descriptor.name !== void 0 ? `"${descriptor.name}"` : position;
const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value));
if (missing.length > 0) throw new Error(`Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(", ")}] but the select template has no case for: ${missing.join(", ")}.`);
const values = descriptor.values;
const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key));
if (unreachable.length > 0) throw new Error(`Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(", ")}. Allowed values: [${values.join(", ")}].`);
}
}
/**
* Every `select` template node must target an option argument whose `values`
* exactly cover the node's `cases` — a legal token with no case and a case no
* token can reach are both declaration bugs, caught here at pack-registration
* time rather than at first resolution.
*/
function assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace) {
for (const [helperPath, descriptor] of collectDescriptorNodes(fieldNamespace, isAuthoringFieldPresetDescriptor)) validateSelectRefsAgainstArgs("field", helperPath, descriptor.args, descriptor.output);
for (const [helperPath, descriptor] of collectDescriptorNodes(typeNamespace, isAuthoringTypeConstructorDescriptor)) validateSelectRefsAgainstArgs("type", helperPath, descriptor.args, descriptor.output);
for (const [helperPath, descriptor] of collectDescriptorNodes(entityTypeNamespace, isAuthoringEntityTypeDescriptor)) if ("template" in descriptor.output) validateSelectRefsAgainstArgs("entityType", helperPath, descriptor.args, descriptor.output.template);
}
function resolveAuthoringTemplateValue(template, args) {
if (template === void 0) return;
if (isAuthoringArgRef(template)) {
const value = readTemplateArgumentValue(args, template.index, template.path);
if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
return value;
}
if (isAuthoringSelectRef(template)) {
const value = readTemplateArgumentValue(args, template.index, template.path);
if (value === void 0) return;
if (typeof value !== "string" || !Object.hasOwn(template.cases, value)) throw new Error(`Authoring template select has no case for value "${String(value)}"`);
return resolveAuthoringTemplateValue(template.cases[value], args);
}
if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
if (typeof template === "object" && template !== null) {
const resolved = {};
for (const [key, value] of Object.entries(template)) {
const resolvedValue = resolveAuthoringTemplateValue(value, args);
if (resolvedValue !== void 0) resolved[key] = resolvedValue;
}
return resolved;
}
return template;
}
function validateAuthoringArgument(descriptor, value, path) {
if (value === void 0) {
if (descriptor.optional) return;
throw new Error(`Missing required authoring helper argument at ${path}`);
}
if (descriptor.kind === "string") {
if (typeof value !== "string") throw new Error(`Authoring helper argument at ${path} must be a string`);
return;
}
if (descriptor.kind === "boolean") {
if (typeof value !== "boolean") throw new Error(`Authoring helper argument at ${path} must be a boolean`);
return;
}
if (descriptor.kind === "stringArray") {
if (!Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
for (const entry of value) if (typeof entry !== "string") throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
return;
}
if (descriptor.kind === "object") {
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an object`);
const input = value;
const expectedKeys = new Set(Object.keys(descriptor.properties));
for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw new Error(`Authoring helper argument at ${path} contains unknown property "${key}"`);
for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
return;
}
if (descriptor.kind === "option") {
if (typeof value !== "string" || !descriptor.values.includes(value)) throw new Error(`Authoring helper argument at ${path} must be one of: ${descriptor.values.join(", ")}`);
return;
}
if (typeof value !== "number" || Number.isNaN(value)) throw new Error(`Authoring helper argument at ${path} must be a number`);
if (descriptor.integer && !Number.isInteger(value)) throw new Error(`Authoring helper argument at ${path} must be an integer`);
if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw new Error(`Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`);
if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw new Error(`Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`);
}
function validateAuthoringHelperArguments(helperPath, descriptors, args) {
const expected = descriptors ?? [];
const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
if (args.length < minimumArgs || args.length > expected.length) throw new Error(`${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
expected.forEach((descriptor, index) => {
validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);
});
}
function resolveAuthoringStorageTypeTemplate(template, args) {
const nativeType = template.nativeType;
if (nativeType === void 0) throw new Error(`Authoring output template for codec "${template.codecId}" declares no nativeType; only entity-ref constructors may omit it`);
const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw new Error(`Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`);
const normalizedTypeParams = typeParams !== void 0 && Object.keys(typeParams).length === 0 ? void 0 : typeParams;
return {
codecId: template.codecId,
nativeType,
...ifDefined("typeParams", normalizedTypeParams)
};
}
function resolveAuthoringColumnDefaultTemplate(template, args) {
if (template.kind === "literal") {
const value = resolveAuthoringTemplateValue(template.value, args);
if (value === void 0) throw new Error("Resolved authoring literal default must not be undefined");
if (!isColumnDefaultLiteralInputValue(value)) throw new Error(`Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`);
return {
kind: "literal",
value
};
}
const expression = resolveAuthoringTemplateValue(template.expression, args);
if (expression === void 0 || typeof expression === "object" && expression !== null) throw new Error(`Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
return {
kind: "function",
expression: String(expression)
};
}
function resolveExecutionMutationDefaultPhase(phase, template, args) {
const value = resolveAuthoringTemplateValue(template, args);
if (value === void 0) return;
if (!isExecutionMutationDefaultValue(value)) throw new Error(`Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`);
return value;
}
function resolveAuthoringExecutionDefaultsTemplate(template, args) {
const phases = {
...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0),
...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0)
};
return Object.keys(phases).length === 0 ? void 0 : phases;
}
function instantiateAuthoringTypeConstructor(descriptor, args) {
return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
}
function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
if ("factory" in descriptor.output) {
const input = args[0];
return blindCast(descriptor.output.factory)(input, ctx);
}
validateAuthoringHelperArguments(helperPath, descriptor.args, args);
return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args));
}
function instantiateAuthoringFieldPreset(descriptor, args) {
return {
descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
nullable: descriptor.output.nullable ?? false,
...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0),
id: descriptor.output.id ?? false,
unique: descriptor.output.unique ?? false
};
}
//#endregion
export { resolveAuthoringTemplateValue as _, collectScalarTypeConstructors as a, instantiateAuthoringFieldPreset as c, isAuthoringEntityTypeDescriptor as d, isAuthoringFieldPresetDescriptor as f, mergeAuthoringNamespaces as g, isAuthoringTypeConstructorDescriptor as h, collectContributedDescriptorPaths as i, instantiateAuthoringTypeConstructor as l, isAuthoringPslBlockDescriptor as m, assertResolvableTypeConstructorTemplates as n, hasRegisteredFieldNamespace as o, isAuthoringModelAttributeDescriptor as p, classifyEnumMemberType as r, instantiateAuthoringEntityType as s, assertNoCrossRegistryCollisions as t, isAuthoringArgRef as u, resolveEnumCodecId as v, validateAuthoringHelperArguments as y };
//# sourceMappingURL=framework-authoring-DfnkbOVh.mjs.map

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