@prisma-next/framework-components 0.13.0-dev.16 → 0.13.0-dev.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring.d.mts +2 -2
- package/dist/authoring.mjs +1 -1
- package/dist/{codec-DCQAerzB.d.mts → codec-types-7Qng7VFc.d.mts} +67 -67
- package/dist/codec-types-7Qng7VFc.d.mts.map +1 -0
- package/dist/codec.d.mts +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/control.d.mts +4 -4
- package/dist/control.mjs +1 -1
- package/dist/execution.d.mts +1 -1
- package/dist/{framework-authoring-CnwPJCO4.mjs → framework-authoring-CLCzDm3Y.mjs} +35 -15
- package/dist/framework-authoring-CLCzDm3Y.mjs.map +1 -0
- package/dist/{framework-authoring-R0TYCkvG.d.mts → framework-authoring-DMAwH52s.d.mts} +90 -7
- package/dist/framework-authoring-DMAwH52s.d.mts.map +1 -0
- package/dist/{framework-components-DDQXmW0b.d.mts → framework-components-DXqiWAJX.d.mts} +3 -3
- package/dist/{framework-components-DDQXmW0b.d.mts.map → framework-components-DXqiWAJX.d.mts.map} +1 -1
- package/dist/{psl-ast-Cn50B-UG.d.mts → psl-ast-Mq7MlfKe.d.mts} +4 -4
- package/dist/{psl-ast-Cn50B-UG.d.mts.map → psl-ast-Mq7MlfKe.d.mts.map} +1 -1
- package/dist/psl-ast.d.mts +4 -4
- package/dist/psl-ast.mjs +11 -9
- package/dist/psl-ast.mjs.map +1 -1
- package/dist/runtime.d.mts +1 -1
- package/package.json +7 -7
- package/src/control/psl-ast.ts +4 -1
- package/src/control/psl-extension-block-validator.ts +11 -9
- package/src/exports/authoring.ts +1 -0
- package/src/shared/framework-authoring.ts +86 -26
- package/src/shared/psl-extension-block.ts +56 -5
- package/dist/codec-DCQAerzB.d.mts.map +0 -1
- package/dist/framework-authoring-CnwPJCO4.mjs.map +0 -1
- package/dist/framework-authoring-R0TYCkvG.d.mts.map +0 -1
package/dist/authoring.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type AuthoringArgRef, type AuthoringArgumentDescriptor, type AuthoringColumnDefaultTemplate, type AuthoringContributions, type AuthoringEntityContext, type AuthoringEntityTypeDescriptor, type AuthoringEntityTypeFactoryOutput, type AuthoringEntityTypeNamespace, type AuthoringEntityTypeTemplateOutput, type AuthoringFieldNamespace, type AuthoringFieldPresetDescriptor, type AuthoringFieldPresetOutput, type AuthoringPslBlockDescriptor, type AuthoringPslBlockDescriptorNamespace, type AuthoringStorageTypeTemplate, type AuthoringTemplateValue, type AuthoringTypeConstructorDescriptor, type AuthoringTypeNamespace, type PslBlockParam, type PslBlockParamList, type PslBlockParamOption, type PslBlockParamRef, type PslBlockParamValue, type PslExtensionBlock, type PslExtensionBlockParamList, type PslExtensionBlockParamOption, type PslExtensionBlockParamRef, type PslExtensionBlockParamScalarValue, type PslExtensionBlockParamValue, assertNoCrossRegistryCollisions, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, mergeAuthoringNamespaces, resolveAuthoringTemplateValue, validateAuthoringHelperArguments };
|
|
1
|
+
import { A as mergeAuthoringNamespaces, C as instantiateAuthoringFieldPreset, D as isAuthoringFieldPresetDescriptor, E as isAuthoringEntityTypeDescriptor, F as PslBlockParamOption, G as PslExtensionBlockParamRef, I as PslBlockParamRef, K as PslExtensionBlockParamScalarValue, L as PslBlockParamValue, M as validateAuthoringHelperArguments, N as PslBlockParam, O as isAuthoringPslBlockDescriptor, P as PslBlockParamList, S as instantiateAuthoringEntityType, T as isAuthoringArgRef, U as PslExtensionBlockParamList, W as PslExtensionBlockParamOption, _ as AuthoringTemplateValue, a as AuthoringDiagnosticSink, b as assertNoCrossRegistryCollisions, c as AuthoringEntityTypeFactoryOutput, d as AuthoringFieldNamespace, f as AuthoringFieldPresetDescriptor, g as AuthoringStorageTypeTemplate, h as AuthoringPslBlockDescriptorNamespace, i as AuthoringContributions, j as resolveAuthoringTemplateValue, k as isAuthoringTypeConstructorDescriptor, l as AuthoringEntityTypeNamespace, m as AuthoringPslBlockDescriptor, n as AuthoringArgumentDescriptor, o as AuthoringEntityContext, p as AuthoringFieldPresetOutput, q as PslExtensionBlockParamValue, r as AuthoringColumnDefaultTemplate, s as AuthoringEntityTypeDescriptor, t as AuthoringArgRef, u as AuthoringEntityTypeTemplateOutput, v as AuthoringTypeConstructorDescriptor, w as instantiateAuthoringTypeConstructor, x as hasRegisteredFieldNamespace, y as AuthoringTypeNamespace, z as PslExtensionBlock } from "./framework-authoring-DMAwH52s.mjs";
|
|
2
|
+
export { type AuthoringArgRef, type AuthoringArgumentDescriptor, type AuthoringColumnDefaultTemplate, type AuthoringContributions, type AuthoringDiagnosticSink, type AuthoringEntityContext, type AuthoringEntityTypeDescriptor, type AuthoringEntityTypeFactoryOutput, type AuthoringEntityTypeNamespace, type AuthoringEntityTypeTemplateOutput, type AuthoringFieldNamespace, type AuthoringFieldPresetDescriptor, type AuthoringFieldPresetOutput, type AuthoringPslBlockDescriptor, type AuthoringPslBlockDescriptorNamespace, type AuthoringStorageTypeTemplate, type AuthoringTemplateValue, type AuthoringTypeConstructorDescriptor, type AuthoringTypeNamespace, type PslBlockParam, type PslBlockParamList, type PslBlockParamOption, type PslBlockParamRef, type PslBlockParamValue, type PslExtensionBlock, type PslExtensionBlockParamList, type PslExtensionBlockParamOption, type PslExtensionBlockParamRef, type PslExtensionBlockParamScalarValue, type PslExtensionBlockParamValue, assertNoCrossRegistryCollisions, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, mergeAuthoringNamespaces, resolveAuthoringTemplateValue, validateAuthoringHelperArguments };
|
package/dist/authoring.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as instantiateAuthoringTypeConstructor, c as isAuthoringFieldPresetDescriptor, d as mergeAuthoringNamespaces, f as resolveAuthoringTemplateValue, i as instantiateAuthoringFieldPreset, l as isAuthoringPslBlockDescriptor, n as hasRegisteredFieldNamespace, o as isAuthoringArgRef, p as validateAuthoringHelperArguments, r as instantiateAuthoringEntityType, s as isAuthoringEntityTypeDescriptor, t as assertNoCrossRegistryCollisions, u as isAuthoringTypeConstructorDescriptor } from "./framework-authoring-
|
|
1
|
+
import { a as instantiateAuthoringTypeConstructor, c as isAuthoringFieldPresetDescriptor, d as mergeAuthoringNamespaces, f as resolveAuthoringTemplateValue, i as instantiateAuthoringFieldPreset, l as isAuthoringPslBlockDescriptor, n as hasRegisteredFieldNamespace, o as isAuthoringArgRef, p as validateAuthoringHelperArguments, r as instantiateAuthoringEntityType, s as isAuthoringEntityTypeDescriptor, t as assertNoCrossRegistryCollisions, u as isAuthoringTypeConstructorDescriptor } from "./framework-authoring-CLCzDm3Y.mjs";
|
|
2
2
|
export { assertNoCrossRegistryCollisions, hasRegisteredFieldNamespace, instantiateAuthoringEntityType, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringEntityTypeDescriptor, isAuthoringFieldPresetDescriptor, isAuthoringPslBlockDescriptor, isAuthoringTypeConstructorDescriptor, mergeAuthoringNamespaces, resolveAuthoringTemplateValue, validateAuthoringHelperArguments };
|
|
@@ -1,71 +1,6 @@
|
|
|
1
1
|
import { JsonValue } from "@prisma-next/contract/types";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
|
|
4
|
-
//#region src/shared/codec-types.d.ts
|
|
5
|
-
type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
|
|
6
|
-
/**
|
|
7
|
-
* Serializable codec identity carried by every codec-bearing AST node.
|
|
8
|
-
*
|
|
9
|
-
* `(codecId, typeParams?)` is the single fact the runtime needs to materialize a codec via `descriptorFor(codecId).factory(typeParams)(ctx)`. The pair is content-keyed: two refs with the same `codecId` and structurally equal `typeParams` (regardless of object key ordering) resolve to the same memoized {@link Codec} instance.
|
|
10
|
-
*
|
|
11
|
-
* `typeParams` is `JsonValue`-constrained so the ref survives JSON serialization (relevant for AST-embedded migration ops). Non-parameterized codecs leave `typeParams` undefined; the descriptor's `paramsSchema` validates the value at the JSON boundary.
|
|
12
|
-
*
|
|
13
|
-
* Family-agnostic by design — both SQL and Mongo AST nodes carry `codec: CodecRef | undefined`, and the resolver is the only dispatch path that survives serialization.
|
|
14
|
-
*/
|
|
15
|
-
interface CodecRef {
|
|
16
|
-
readonly codecId: string;
|
|
17
|
-
readonly typeParams?: JsonValue;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Per-call context the runtime threads to every `codec.encode` / `codec.decode` invocation for a single `runtime.execute()` call.
|
|
21
|
-
*
|
|
22
|
-
* The framework-level shape is family-agnostic and carries one field:
|
|
23
|
-
*
|
|
24
|
-
* - `signal?: AbortSignal` — per-query cancellation. The runtime returns a `RUNTIME.ABORTED` envelope when the signal aborts; codec authors who forward `signal` to their underlying SDK get true cancellation of in-flight network calls.
|
|
25
|
-
*
|
|
26
|
-
* Family layers extend this base with their own shape-of-call metadata: the SQL family adds `column?: SqlColumnRef` via `SqlCodecCallContext` (see `@prisma-next/sql-relational-core`). Mongo currently uses this framework type unchanged. Column metadata is intentionally **not** on the framework type — it is a SQL-family concept rooted in SQL's `(table, column)` addressing model and would not generalise to other families.
|
|
27
|
-
*
|
|
28
|
-
* The interface is named explicitly (not inlined) so future framework fields and family extensions can land additively without breaking codec author signatures.
|
|
29
|
-
*/
|
|
30
|
-
interface CodecCallContext {
|
|
31
|
-
readonly signal?: AbortSignal;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Codec-id-keyed read surface threaded into emit and authoring paths.
|
|
35
|
-
*
|
|
36
|
-
* - `get(id)` returns the runtime {@link Codec} instance for the codec id (used by `family.deserializeContract` for `decodeJson` of literal column defaults).
|
|
37
|
-
* - `targetTypesFor(id)` exposes the codec-id-keyed `targetTypes` metadata the runtime instance no longer carries (TML-2357). Returns the same array `CodecDescriptor.targetTypes` would; for Mongo (whose registration doesn't yet resolve through the unified descriptor map — TML-2324) the family-side assembly populates this directly from the contributor's codec metadata.
|
|
38
|
-
* - `metaFor(id)` exposes the codec-id-keyed `meta` (e.g. SQL-side `db.sql.postgres.nativeType`) the runtime instance no longer carries.
|
|
39
|
-
* - `renderOutputTypeFor(id, params)` exposes the codec-id-keyed `renderOutputType` renderer the runtime instance no longer carries. Returns `undefined` when the codec doesn't render a custom type or when the codec id is unknown.
|
|
40
|
-
*/
|
|
41
|
-
interface CodecLookup {
|
|
42
|
-
get(id: string): Codec | undefined;
|
|
43
|
-
targetTypesFor(id: string): readonly string[] | undefined;
|
|
44
|
-
metaFor(id: string): CodecMeta | undefined;
|
|
45
|
-
renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;
|
|
46
|
-
}
|
|
47
|
-
declare const emptyCodecLookup: CodecLookup;
|
|
48
|
-
/**
|
|
49
|
-
* Family-agnostic per-instance context supplied by the framework when applying a higher-order codec factory. Allows stateful codecs (e.g. column-scoped encryption) to derive per-instance state from the materialization site.
|
|
50
|
-
*
|
|
51
|
-
* - `name` — the family-agnostic instance identity. For SQL, the runtime populates this as the `storage.types` instance name (e.g. `Embedding1536`) for typeRef-shaped columns, an inline-column sentinel (`<col:Document.embedding>`) for inline-`typeParams` columns, a shared codec-id sentinel (`<codec:pg/text@1>`) for non-parameterized codec ids, or the canonical cache key (`<codecId>:<canonicalizeJson(typeParams)>`) for ad-hoc refs the contract walk did not pre-populate. Other families pick the analogous identity for their materialization sites.
|
|
52
|
-
*
|
|
53
|
-
* Family-specific extensions (e.g. {@link import('@prisma-next/sql-relational-core/ast').SqlCodecInstanceContext} in the SQL layer) augment this base with domain-shaped column-set metadata. Codec authors target the base when they don't read family-specific metadata; they target the family extension when they do.
|
|
54
|
-
*/
|
|
55
|
-
interface CodecInstanceContext {
|
|
56
|
-
readonly name: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Family-agnostic codec metadata. Family-specific extensions augment the base `db.<family>.<target>` block with native-type information; the base shape is an empty object so non-relational codecs can carry no metadata.
|
|
60
|
-
*/
|
|
61
|
-
interface CodecMeta {
|
|
62
|
-
readonly db?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Standard Schema validator for `void` params. Accepts only `undefined` (or absent input); rejects any other value so a contract that tries to thread `typeParams` through a non-parameterized codec id fails fast at the JSON boundary instead of silently coercing the value away. Used by the framework-supplied non-parameterized descriptor synthesizer.
|
|
66
|
-
*/
|
|
67
|
-
declare const voidParamsSchema: StandardSchemaV1<void>;
|
|
68
|
-
//#endregion
|
|
69
4
|
//#region src/shared/codec-descriptor.d.ts
|
|
70
5
|
/**
|
|
71
6
|
* Unified codec descriptor. Every codec in the framework registers through this shape — non-parameterized codecs use `P = void` and a constant factory that returns the same shared codec instance for every column; parameterized codecs use a non-empty `P` and a curried higher-order factory that returns a per-instance codec.
|
|
@@ -177,5 +112,70 @@ declare abstract class CodecImpl<Id extends string = string, TTraits extends rea
|
|
|
177
112
|
abstract decodeJson(json: JsonValue): TInput;
|
|
178
113
|
}
|
|
179
114
|
//#endregion
|
|
180
|
-
|
|
181
|
-
|
|
115
|
+
//#region src/shared/codec-types.d.ts
|
|
116
|
+
type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
|
|
117
|
+
/**
|
|
118
|
+
* Serializable codec identity carried by every codec-bearing AST node.
|
|
119
|
+
*
|
|
120
|
+
* `(codecId, typeParams?)` is the single fact the runtime needs to materialize a codec via `descriptorFor(codecId).factory(typeParams)(ctx)`. The pair is content-keyed: two refs with the same `codecId` and structurally equal `typeParams` (regardless of object key ordering) resolve to the same memoized {@link Codec} instance.
|
|
121
|
+
*
|
|
122
|
+
* `typeParams` is `JsonValue`-constrained so the ref survives JSON serialization (relevant for AST-embedded migration ops). Non-parameterized codecs leave `typeParams` undefined; the descriptor's `paramsSchema` validates the value at the JSON boundary.
|
|
123
|
+
*
|
|
124
|
+
* Family-agnostic by design — both SQL and Mongo AST nodes carry `codec: CodecRef | undefined`, and the resolver is the only dispatch path that survives serialization.
|
|
125
|
+
*/
|
|
126
|
+
interface CodecRef {
|
|
127
|
+
readonly codecId: string;
|
|
128
|
+
readonly typeParams?: JsonValue;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Per-call context the runtime threads to every `codec.encode` / `codec.decode` invocation for a single `runtime.execute()` call.
|
|
132
|
+
*
|
|
133
|
+
* The framework-level shape is family-agnostic and carries one field:
|
|
134
|
+
*
|
|
135
|
+
* - `signal?: AbortSignal` — per-query cancellation. The runtime returns a `RUNTIME.ABORTED` envelope when the signal aborts; codec authors who forward `signal` to their underlying SDK get true cancellation of in-flight network calls.
|
|
136
|
+
*
|
|
137
|
+
* Family layers extend this base with their own shape-of-call metadata: the SQL family adds `column?: SqlColumnRef` via `SqlCodecCallContext` (see `@prisma-next/sql-relational-core`). Mongo currently uses this framework type unchanged. Column metadata is intentionally **not** on the framework type — it is a SQL-family concept rooted in SQL's `(table, column)` addressing model and would not generalise to other families.
|
|
138
|
+
*
|
|
139
|
+
* The interface is named explicitly (not inlined) so future framework fields and family extensions can land additively without breaking codec author signatures.
|
|
140
|
+
*/
|
|
141
|
+
interface CodecCallContext {
|
|
142
|
+
readonly signal?: AbortSignal;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Codec-id-keyed read surface threaded into emit and authoring paths.
|
|
146
|
+
*
|
|
147
|
+
* - `get(id)` returns the runtime {@link Codec} instance for the codec id (used by `family.deserializeContract` for `decodeJson` of literal column defaults).
|
|
148
|
+
* - `targetTypesFor(id)` exposes the codec-id-keyed `targetTypes` metadata the runtime instance no longer carries (TML-2357). Returns the same array `CodecDescriptor.targetTypes` would; for Mongo (whose registration doesn't yet resolve through the unified descriptor map — TML-2324) the family-side assembly populates this directly from the contributor's codec metadata.
|
|
149
|
+
* - `metaFor(id)` exposes the codec-id-keyed `meta` (e.g. SQL-side `db.sql.postgres.nativeType`) the runtime instance no longer carries.
|
|
150
|
+
* - `renderOutputTypeFor(id, params)` exposes the codec-id-keyed `renderOutputType` renderer the runtime instance no longer carries. Returns `undefined` when the codec doesn't render a custom type or when the codec id is unknown.
|
|
151
|
+
*/
|
|
152
|
+
interface CodecLookup {
|
|
153
|
+
get(id: string): Codec | undefined;
|
|
154
|
+
targetTypesFor(id: string): readonly string[] | undefined;
|
|
155
|
+
metaFor(id: string): CodecMeta | undefined;
|
|
156
|
+
renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;
|
|
157
|
+
}
|
|
158
|
+
declare const emptyCodecLookup: CodecLookup;
|
|
159
|
+
/**
|
|
160
|
+
* Family-agnostic per-instance context supplied by the framework when applying a higher-order codec factory. Allows stateful codecs (e.g. column-scoped encryption) to derive per-instance state from the materialization site.
|
|
161
|
+
*
|
|
162
|
+
* - `name` — the family-agnostic instance identity. For SQL, the runtime populates this as the `storage.types` instance name (e.g. `Embedding1536`) for typeRef-shaped columns, an inline-column sentinel (`<col:Document.embedding>`) for inline-`typeParams` columns, a shared codec-id sentinel (`<codec:pg/text@1>`) for non-parameterized codec ids, or the canonical cache key (`<codecId>:<canonicalizeJson(typeParams)>`) for ad-hoc refs the contract walk did not pre-populate. Other families pick the analogous identity for their materialization sites.
|
|
163
|
+
*
|
|
164
|
+
* Family-specific extensions (e.g. {@link import('@prisma-next/sql-relational-core/ast').SqlCodecInstanceContext} in the SQL layer) augment this base with domain-shaped column-set metadata. Codec authors target the base when they don't read family-specific metadata; they target the family extension when they do.
|
|
165
|
+
*/
|
|
166
|
+
interface CodecInstanceContext {
|
|
167
|
+
readonly name: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Family-agnostic codec metadata. Family-specific extensions augment the base `db.<family>.<target>` block with native-type information; the base shape is an empty object so non-relational codecs can carry no metadata.
|
|
171
|
+
*/
|
|
172
|
+
interface CodecMeta {
|
|
173
|
+
readonly db?: Record<string, unknown>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Standard Schema validator for `void` params. Accepts only `undefined` (or absent input); rejects any other value so a contract that tries to thread `typeParams` through a non-parameterized codec id fails fast at the JSON boundary instead of silently coercing the value away. Used by the framework-supplied non-parameterized descriptor synthesizer.
|
|
177
|
+
*/
|
|
178
|
+
declare const voidParamsSchema: StandardSchemaV1<void>;
|
|
179
|
+
//#endregion
|
|
180
|
+
export { CodecRef as a, voidParamsSchema as c, AnyCodecDescriptor as d, CodecDescriptor as f, CodecMeta as i, Codec as l, CodecInstanceContext as n, CodecTrait as o, CodecDescriptorImpl as p, CodecLookup as r, emptyCodecLookup as s, CodecCallContext as t, CodecImpl as u };
|
|
181
|
+
//# sourceMappingURL=codec-types-7Qng7VFc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types-7Qng7VFc.d.mts","names":[],"sources":["../src/shared/codec-descriptor.ts","../src/shared/codec.ts","../src/shared/codec-types.ts"],"mappings":";;;;;;;;;;;;;;;UA8BiB,eAAA;EAUN;EAAA,SARA,OAAA;EAQ+B;EAAA,SAN/B,MAAA,WAAiB,UAAA;EAUjB;EAAA,SARA,WAAA;EAQoB;EAAA,SANpB,IAAA,GAAO,SAAA;EAQW;EAAA,SANlB,YAAA,EAAc,gBAAA,CAAiB,CAAA;EAMD;EAAA,SAJ9B,eAAA;EAIuD;EAAA,SAFvD,gBAAA,IAAoB,MAAA,EAAQ,CAAA;EAEgC;EAAA,SAA5D,OAAA,GAAU,MAAA,EAAQ,CAAA,MAAO,GAAA,EAAK,oBAAA,KAAyB,KAAA;AAAA;;;AASlB;AAShD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AAA,CAAQ,MAAA;EAAA,SACpD,UAAA,CAAW,KAAA,EAAO,MAAA,GAAS,SAAA;EAAA,SAC3B,UAAA,CAAW,IAAA,EAAM,SAAA,GAAY,MAAA;AAAA;;;KC1E5B,UAAA;AF0BZ;;;;;;;;;AAAA,UEfiB,QAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA,GAAa,SAAS;AAAA;;;;;;;;;;;;UAchB,gBAAA;EAAA,SACN,MAAA,GAAS,WAAW;AAAA;;;;;;;;AFcwC;UEHtD,WAAA;EACf,GAAA,CAAI,EAAA,WAAa,KAAA;EACjB,cAAA,CAAe,EAAA;EACf,OAAA,CAAQ,EAAA,WAAa,SAAA;EACrB,mBAAA,CAAoB,EAAA,UAAY,MAAA,EAAQ,MAAA;AAAA;AAAA,cAG7B,gBAAA,EAAkB,WAK9B;;;;;;;;UASgB,oBAAA;EAAA,SACN,IAAI;AAAA;;;;UAME,SAAA;EAAA,SACN,EAAA,GAAK,MAAM;AAAA;;;;cAMT,gBAAA,EAAkB,gBAAgB"}
|
package/dist/codec.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as CodecRef, c as voidParamsSchema, d as AnyCodecDescriptor, f as CodecDescriptor, i as CodecMeta, l as Codec, n as CodecInstanceContext, o as CodecTrait, p as CodecDescriptorImpl, r as CodecLookup, s as emptyCodecLookup, t as CodecCallContext, u as CodecImpl } from "./codec-types-7Qng7VFc.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/shared/column-spec.d.ts
|
|
4
4
|
/**
|
package/dist/components.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-
|
|
1
|
+
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-DXqiWAJX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/shared/capabilities.d.ts
|
|
4
4
|
/**
|
package/dist/control.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { A as LoweredDefaultResult, C as ControlMutationDefaultEntry, D as DefaultFunctionLoweringHandler, E as DefaultFunctionLoweringContext, F as SourceSpan, M as MutationDefaultGeneratorDescriptor, N as ParsedDefaultFunctionCall, O as DefaultFunctionRegistry, P as SourceDiagnostic, T as ControlMutationDefaults, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, j as LoweredDefaultValue, k as DefaultFunctionRegistryEntry, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, w as ControlMutationDefaultRegistry, y as TargetDescriptor } from "./framework-components-
|
|
1
|
+
import { r as CodecLookup } from "./codec-types-7Qng7VFc.mjs";
|
|
2
|
+
import { d as AuthoringFieldNamespace, h as AuthoringPslBlockDescriptorNamespace, i as AuthoringContributions, l as AuthoringEntityTypeNamespace, y as AuthoringTypeNamespace } from "./framework-authoring-DMAwH52s.mjs";
|
|
3
|
+
import { A as LoweredDefaultResult, C as ControlMutationDefaultEntry, D as DefaultFunctionLoweringHandler, E as DefaultFunctionLoweringContext, F as SourceSpan, M as MutationDefaultGeneratorDescriptor, N as ParsedDefaultFunctionCall, O as DefaultFunctionRegistry, P as SourceDiagnostic, T as ControlMutationDefaults, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, j as LoweredDefaultValue, k as DefaultFunctionRegistryEntry, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, w as ControlMutationDefaultRegistry, y as TargetDescriptor } from "./framework-components-DXqiWAJX.mjs";
|
|
4
4
|
import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20.mjs";
|
|
5
5
|
import { t as EmissionSpi } from "./emission-types-vfpSTe63.mjs";
|
|
6
|
-
import { m as PslDocumentAst } from "./psl-ast-
|
|
6
|
+
import { m as PslDocumentAst } from "./psl-ast-Mq7MlfKe.mjs";
|
|
7
7
|
import { Contract, ContractMarkerRecord, ControlPolicy, LedgerEntryRecord } from "@prisma-next/contract/types";
|
|
8
8
|
import { ImportRequirement, ImportRequirement as ImportRequirement$1 } from "@prisma-next/ts-render";
|
|
9
9
|
import { PreserveEmptyPredicate, StorageSort } from "@prisma-next/contract/hashing";
|
package/dist/control.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as isAuthoringFieldPresetDescriptor, d as mergeAuthoringNamespaces, l as isAuthoringPslBlockDescriptor, s as isAuthoringEntityTypeDescriptor, t as assertNoCrossRegistryCollisions, u as isAuthoringTypeConstructorDescriptor } from "./framework-authoring-
|
|
1
|
+
import { c as isAuthoringFieldPresetDescriptor, d as mergeAuthoringNamespaces, l as isAuthoringPslBlockDescriptor, s as isAuthoringEntityTypeDescriptor, t as assertNoCrossRegistryCollisions, u as isAuthoringTypeConstructorDescriptor } from "./framework-authoring-CLCzDm3Y.mjs";
|
|
2
2
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
3
3
|
//#region src/control/control-capabilities.ts
|
|
4
4
|
function hasMigrations(target) {
|
package/dist/execution.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, y as TargetDescriptor } from "./framework-components-
|
|
1
|
+
import { b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, y as TargetDescriptor } from "./framework-components-DXqiWAJX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/execution/execution-instances.d.ts
|
|
4
4
|
interface RuntimeFamilyInstance<TFamilyId extends string> extends FamilyInstance<TFamilyId> {}
|
|
@@ -96,7 +96,7 @@ function mergeAuthoringNamespaces(target, source, path, leafGuard, label) {
|
|
|
96
96
|
mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, leafGuard, label);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function collectDescriptorPaths(namespace, isLeaf, path = []) {
|
|
100
100
|
const paths = [];
|
|
101
101
|
for (const [key, value] of Object.entries(namespace)) {
|
|
102
102
|
const currentPath = [...path, key];
|
|
@@ -104,11 +104,11 @@ function collectAuthoringLeafPaths(namespace, isLeaf, path = []) {
|
|
|
104
104
|
paths.push(currentPath.join("."));
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...
|
|
107
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath));
|
|
108
108
|
}
|
|
109
109
|
return paths;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function collectDescriptorEntries(namespace, isLeaf, label, path = []) {
|
|
112
112
|
const entries = [];
|
|
113
113
|
for (const [key, value] of Object.entries(namespace)) {
|
|
114
114
|
const currentPath = [...path, key];
|
|
@@ -128,7 +128,7 @@ function collectAuthoringLeafDiscriminators(namespace, isLeaf, label, path = [])
|
|
|
128
128
|
const hasDiscriminator = typeof record["discriminator"] === "string";
|
|
129
129
|
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.`);
|
|
130
130
|
}
|
|
131
|
-
entries.push(...
|
|
131
|
+
entries.push(...collectDescriptorEntries(record, isLeaf, label, currentPath));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
return entries;
|
|
@@ -147,25 +147,45 @@ function assertUniqueDiscriminators(entries, label) {
|
|
|
147
147
|
seen.set(discriminator, path);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
function collectPslBlockDescriptorEntries(namespace, path = []) {
|
|
151
|
+
const entries = [];
|
|
152
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
153
|
+
const currentPath = [...path, key];
|
|
154
|
+
if (isAuthoringPslBlockDescriptor(value)) {
|
|
155
|
+
entries.push({
|
|
156
|
+
path: currentPath.join("."),
|
|
157
|
+
discriminator: value.discriminator
|
|
158
|
+
});
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
162
|
+
const record = blindCast(value);
|
|
163
|
+
const hasKind = record["kind"] === "pslBlock";
|
|
164
|
+
const hasKeyword = typeof record["keyword"] === "string";
|
|
165
|
+
const hasDiscriminator = typeof record["discriminator"] === "string";
|
|
166
|
+
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.`);
|
|
167
|
+
entries.push(...collectPslBlockDescriptorEntries(record, currentPath));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return entries;
|
|
171
|
+
}
|
|
150
172
|
/**
|
|
151
|
-
* Every `pslBlockDescriptors` entry
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* — an `entityTypes` factory may stand alone (e.g. `enum`, reachable from
|
|
155
|
-
* the TypeScript builder without any PSL block).
|
|
173
|
+
* Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory
|
|
174
|
+
* with the same discriminator. An `entityTypes` factory may stand alone (e.g.
|
|
175
|
+
* `enum`, reachable from the TypeScript builder without any PSL block).
|
|
156
176
|
*/
|
|
157
177
|
function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) {
|
|
158
|
-
const blockEntries =
|
|
159
|
-
const entityEntries =
|
|
178
|
+
const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace);
|
|
179
|
+
const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entityType");
|
|
160
180
|
assertUniqueDiscriminators(blockEntries, "pslBlock");
|
|
161
181
|
assertUniqueDiscriminators(entityEntries, "entityType");
|
|
162
182
|
const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator));
|
|
163
183
|
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}".`);
|
|
164
184
|
}
|
|
165
185
|
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}) {
|
|
166
|
-
const typePaths = new Set(
|
|
167
|
-
const fieldPaths = new Set(
|
|
168
|
-
const entityPaths = new Set(
|
|
186
|
+
const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor));
|
|
187
|
+
const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
|
|
188
|
+
const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
|
|
169
189
|
const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.";
|
|
170
190
|
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}`);
|
|
171
191
|
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}`);
|
|
@@ -298,4 +318,4 @@ function instantiateAuthoringFieldPreset(descriptor, args) {
|
|
|
298
318
|
//#endregion
|
|
299
319
|
export { instantiateAuthoringTypeConstructor as a, isAuthoringFieldPresetDescriptor as c, mergeAuthoringNamespaces as d, resolveAuthoringTemplateValue as f, instantiateAuthoringFieldPreset as i, isAuthoringPslBlockDescriptor as l, hasRegisteredFieldNamespace as n, isAuthoringArgRef as o, validateAuthoringHelperArguments as p, instantiateAuthoringEntityType as r, isAuthoringEntityTypeDescriptor as s, assertNoCrossRegistryCollisions as t, isAuthoringTypeConstructorDescriptor as u };
|
|
300
320
|
|
|
301
|
-
//# sourceMappingURL=framework-authoring-
|
|
321
|
+
//# sourceMappingURL=framework-authoring-CLCzDm3Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-authoring-CLCzDm3Y.mjs","names":[],"sources":["../src/shared/framework-authoring.ts"],"sourcesContent":["import type {\n ColumnDefault,\n ExecutionMutationDefaultPhases,\n ExecutionMutationDefaultValue,\n} from '@prisma-next/contract/types';\nimport {\n isColumnDefaultLiteralInputValue,\n isExecutionMutationDefaultValue,\n} from '@prisma-next/contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Type } from 'arktype';\nimport type { CodecLookup } from './codec-types';\nimport type { PslBlockParam } from './psl-extension-block';\n\nexport type AuthoringArgRef = {\n readonly kind: 'arg';\n readonly index: number;\n readonly path?: readonly string[];\n readonly default?: AuthoringTemplateValue;\n};\n\nexport type AuthoringTemplateValue =\n | string\n | number\n | boolean\n | null\n | AuthoringArgRef\n | readonly AuthoringTemplateValue[]\n | { readonly [key: string]: AuthoringTemplateValue };\n\ninterface AuthoringArgumentDescriptorCommon {\n readonly name?: string;\n readonly optional?: boolean;\n}\n\nexport type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon &\n (\n | { readonly kind: 'string' }\n | { readonly kind: 'boolean' }\n | {\n readonly kind: 'number';\n readonly integer?: boolean;\n readonly minimum?: number;\n readonly maximum?: number;\n }\n | { readonly kind: 'stringArray' }\n | {\n readonly kind: 'object';\n readonly properties: Record<string, AuthoringArgumentDescriptor>;\n }\n );\n\nexport interface AuthoringStorageTypeTemplate {\n readonly codecId: string;\n readonly nativeType: AuthoringTemplateValue;\n readonly typeParams?: Record<string, AuthoringTemplateValue>;\n}\n\nexport interface AuthoringTypeConstructorDescriptor {\n readonly kind: 'typeConstructor';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringStorageTypeTemplate;\n}\n\nexport interface AuthoringColumnDefaultTemplateLiteral {\n readonly kind: 'literal';\n readonly value: AuthoringTemplateValue;\n}\n\nexport interface AuthoringColumnDefaultTemplateFunction {\n readonly kind: 'function';\n readonly expression: AuthoringTemplateValue;\n}\n\nexport type AuthoringColumnDefaultTemplate =\n | AuthoringColumnDefaultTemplateLiteral\n | AuthoringColumnDefaultTemplateFunction;\n\nexport interface AuthoringExecutionDefaultsTemplate {\n readonly onCreate?: AuthoringTemplateValue;\n readonly onUpdate?: AuthoringTemplateValue;\n}\n\nexport interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {\n readonly nullable?: boolean;\n readonly default?: AuthoringColumnDefaultTemplate;\n readonly executionDefaults?: AuthoringExecutionDefaultsTemplate;\n readonly id?: boolean;\n readonly unique?: boolean;\n}\n\nexport interface AuthoringFieldPresetDescriptor {\n readonly kind: 'fieldPreset';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringFieldPresetOutput;\n}\n\nexport type AuthoringTypeNamespace = {\n readonly [name: string]: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace;\n};\n\nexport type AuthoringFieldNamespace = {\n readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;\n};\n\n/**\n * Context surfaced to entity-type factories at call time. Currently a\n * placeholder — sharpened as concrete consumers (enum, namespace, …)\n * discover what the factory actually needs to read (codec lookup,\n * namespace registry, …).\n */\n/**\n * A write-only sink that a factory may push authoring-time diagnostics into.\n * The concrete type pushed must be structurally compatible with whatever the\n * consumer accumulates (typically `ContractSourceDiagnostic[]`); the framework\n * layer deliberately does not depend on that concrete type.\n */\nexport interface AuthoringDiagnosticSink {\n push(d: {\n readonly code: string;\n readonly message: string;\n readonly sourceId: string;\n readonly span?: unknown;\n }): void;\n}\n\nexport interface AuthoringEntityContext {\n readonly family: string;\n readonly target: string;\n /** Codec registry available to factories that need to validate or decode values. */\n readonly codecLookup?: CodecLookup;\n /** Source file identifier threaded into diagnostics emitted by the factory. */\n readonly sourceId?: string;\n /** Push channel for authoring-time diagnostics emitted by the factory. */\n readonly diagnostics?: AuthoringDiagnosticSink;\n}\n\nexport interface AuthoringEntityTypeTemplateOutput {\n readonly template: AuthoringTemplateValue;\n}\n\n/**\n * Default `Input = never` is load-bearing for pack-bag-driven type\n * narrowing. Factory parameter positions are contravariant, so a pack\n * literal declaring `factory: (input: DemoEntityInput) => DemoEntity`\n * is only assignable to the base descriptor's factory shape if the\n * base's input is `never` (the bottom of the contravariant position).\n * The concrete input/output types are recovered at the helper-derivation\n * site via `EntityHelperFunction<Descriptor>`'s conditional inference,\n * which reads them from the pack's `as const` literal factory signature\n * — the base widening does not erase the literal because `satisfies`\n * does not widen the declared type.\n */\nexport interface AuthoringEntityTypeFactoryOutput<Input = never, Output = unknown> {\n readonly factory: (input: Input, ctx: AuthoringEntityContext) => Output;\n}\n\nexport interface AuthoringEntityTypeDescriptor<Input = never, Output = unknown> {\n readonly kind: 'entity';\n readonly discriminator: string;\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output:\n | AuthoringEntityTypeTemplateOutput\n | AuthoringEntityTypeFactoryOutput<Input, Output>;\n /**\n * arktype schema fragment for one entry whose envelope `kind` matches\n * this descriptor's {@link discriminator}. The family validator composes\n * contributed fragments into the per-namespace entry schema at\n * validator construction time so the structural check covers\n * pack-introduced kinds without the family core hard-coding the schema.\n *\n * Hydration uses {@link AuthoringEntityTypeFactoryOutput.factory}\n * directly — the wire shape conforms structurally to the factory's\n * `Input` after `validatorSchema` validates it.\n */\n readonly validatorSchema?: Type<unknown>;\n}\n\nexport type AuthoringEntityTypeNamespace = {\n readonly [name: string]: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace;\n};\n\n/**\n * Declarative descriptor for an extension-contributed top-level PSL block.\n *\n * An extension registers one of these per keyword it contributes. The\n * framework owns the generic parser, validator, and printer — no\n * parsing or printing code runs from the extension.\n *\n * - `keyword` is the PSL top-level identifier this descriptor claims\n * (`policy_select`, `role`, …).\n * - `discriminator` is the routing key used by the printer dispatch and\n * the `entityTypes` lowering factory lookup. Convention:\n * `<target-or-family>-<kind>` (`postgres-policy-select`).\n * - `name.required` declares whether the block must have a name token\n * after the keyword. Currently always `true` — anonymous blocks are\n * not part of the closed-grammar premise — but the field is explicit\n * so the type can evolve without a breaking change.\n * - `parameters` maps parameter names to their value-kind descriptors\n * (`ref` / `value` / `option` / `list`). The generic parser and\n * validator interpret these; the extension supplies no parser or\n * printer function.\n */\nexport interface AuthoringPslBlockDescriptor {\n readonly kind: 'pslBlock';\n readonly keyword: string;\n readonly discriminator: string;\n readonly name: { readonly required: boolean };\n readonly parameters: Record<string, PslBlockParam>;\n /**\n * When `true`, the block body accepts a variadic tail of parameters beyond\n * the declared set. The block body may contain: fields (model-style),\n * `key = value` parameters, and `@@` attributes. With `variadicParameters`,\n * bare identifiers (keys without a `= value`) and undeclared `key = value`\n * pairs flow into the variadic tail — their semantics belong to the\n * lowering, not the parser.\n *\n * A key that IS declared in `parameters` must still be supplied as\n * `key = value`; a bare occurrence of a declared key is a diagnostic.\n *\n * When `false` (default), the validator emits `PSL_EXTENSION_UNKNOWN_PARAMETER`\n * for keys absent from `parameters`.\n */\n readonly variadicParameters?: boolean;\n}\n\nexport type AuthoringPslBlockDescriptorNamespace = {\n readonly [name: string]: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace;\n};\n\nexport interface AuthoringContributions {\n readonly type?: AuthoringTypeNamespace;\n readonly field?: AuthoringFieldNamespace;\n readonly entityTypes?: AuthoringEntityTypeNamespace;\n /**\n * Registry of declarative block descriptors this contribution registers,\n * keyed by arbitrary path segments. Each leaf is an\n * {@link AuthoringPslBlockDescriptor} that claims a PSL top-level keyword.\n * The framework owns the generic parser, validator, and printer; the\n * contribution supplies only these declarative descriptors.\n *\n * Contrast with the parsed block nodes themselves, which live in a\n * namespace's `entries` under their discriminator key; this field holds the\n * registry of descriptors that teach the parser how to read those blocks.\n */\n readonly pslBlockDescriptors?: AuthoringPslBlockDescriptorNamespace;\n}\n\nexport function isAuthoringArgRef(value: unknown): value is AuthoringArgRef {\n if (typeof value !== 'object' || value === null || (value as { kind?: unknown }).kind !== 'arg') {\n return false;\n }\n const { index, path } = value as { index?: unknown; path?: unknown };\n if (typeof index !== 'number' || !Number.isInteger(index) || index < 0) {\n return false;\n }\n if (path !== undefined && (!Array.isArray(path) || path.some((s) => typeof s !== 'string'))) {\n return false;\n }\n return true;\n}\n\nfunction isAuthoringTemplateRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function isAuthoringTypeConstructorDescriptor(\n value: unknown,\n): value is AuthoringTypeConstructorDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'typeConstructor' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function isAuthoringFieldPresetDescriptor(\n value: unknown,\n): value is AuthoringFieldPresetDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'fieldPreset' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function isAuthoringEntityTypeDescriptor(\n value: unknown,\n): value is AuthoringEntityTypeDescriptor {\n if (\n typeof value !== 'object' ||\n value === null ||\n (value as { kind?: unknown }).kind !== 'entity'\n ) {\n return false;\n }\n const discriminator = (value as { discriminator?: unknown }).discriminator;\n if (typeof discriminator !== 'string' || discriminator.length === 0) {\n return false;\n }\n const output = (value as { output?: unknown }).output;\n if (typeof output !== 'object' || output === null) {\n return false;\n }\n const factory = (output as { factory?: unknown }).factory;\n const template = (output as { template?: unknown }).template;\n return typeof factory === 'function' || template !== undefined;\n}\n\nexport function isAuthoringPslBlockDescriptor(\n value: unknown,\n): value is AuthoringPslBlockDescriptor {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const record = blindCast<\n Record<string, unknown>,\n 'type-guard probing an unknown candidate-descriptor object for known property names'\n >(value);\n if (record['kind'] !== 'pslBlock') {\n return false;\n }\n const keyword = record['keyword'];\n if (typeof keyword !== 'string' || keyword.length === 0) {\n return false;\n }\n const discriminator = record['discriminator'];\n if (typeof discriminator !== 'string' || discriminator.length === 0) {\n return false;\n }\n const name = record['name'];\n if (typeof name !== 'object' || name === null) {\n return false;\n }\n const nameRecord = blindCast<\n Record<string, unknown>,\n 'type-guard probing the name property of a candidate pslBlock descriptor'\n >(name);\n if (typeof nameRecord['required'] !== 'boolean') {\n return false;\n }\n const parameters = record['parameters'];\n return typeof parameters === 'object' && parameters !== null && !Array.isArray(parameters);\n}\n\n/**\n * Returns true when `namespace` is a non-leaf key in `contributions.field`.\n *\n * `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including\n * the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`\n * registration must NOT be treated as a \"namespace\" with sub-paths. Callers\n * use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).\n */\nexport function hasRegisteredFieldNamespace(\n contributions: AuthoringContributions | undefined,\n namespace: string,\n): boolean {\n if (contributions?.field === undefined || !Object.hasOwn(contributions.field, namespace)) {\n return false;\n }\n return !isAuthoringFieldPresetDescriptor(contributions.field[namespace]);\n}\n\nfunction isPlainNamespaceObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Merges `source` into `target` recursively at the descriptor-namespace\n * level. `leafGuard` decides which values are descriptors (terminal\n * merge points; same-path registrations across components are reported\n * as duplicates) versus sub-namespaces (recursion targets).\n *\n * Path segments are validated against prototype-pollution names\n * (`__proto__`, `constructor`, `prototype`). A value that is neither a\n * recognized leaf nor a plain object — e.g. a malformed descriptor\n * where the canonical leaf guard rejected it for missing `output` —\n * is reported as an invalid contribution rather than recursed into,\n * which would either silently mangle state or infinite-loop on\n * primitive properties.\n *\n * Within-registry duplicate detection is this walker's job;\n * cross-registry detection runs separately via\n * `assertNoCrossRegistryCollisions` after merging completes.\n */\nexport function mergeAuthoringNamespaces(\n target: Record<string, unknown>,\n source: Record<string, unknown>,\n path: readonly string[],\n leafGuard: (value: unknown) => boolean,\n label: string,\n): void {\n const assertSafePath = (currentPath: readonly string[]) => {\n const blockedSegment = currentPath.find(\n (segment) => segment === '__proto__' || segment === 'constructor' || segment === 'prototype',\n );\n if (blockedSegment) {\n throw new Error(\n `Invalid authoring ${label} helper \"${currentPath.join('.')}\". Helper path segments must not use \"${blockedSegment}\".`,\n );\n }\n };\n\n for (const [key, sourceValue] of Object.entries(source)) {\n const currentPath = [...path, key];\n assertSafePath(currentPath);\n const hasExistingValue = Object.hasOwn(target, key);\n const existingValue = hasExistingValue ? target[key] : undefined;\n\n if (!hasExistingValue) {\n target[key] = sourceValue;\n continue;\n }\n\n const existingIsLeaf = leafGuard(existingValue);\n const sourceIsLeaf = leafGuard(sourceValue);\n\n if (existingIsLeaf || sourceIsLeaf) {\n throw new Error(\n `Duplicate authoring ${label} helper \"${currentPath.join('.')}\". Helper names must be unique across composed packs.`,\n );\n }\n\n if (!isPlainNamespaceObject(existingValue) || !isPlainNamespaceObject(sourceValue)) {\n throw new Error(\n `Invalid authoring ${label} helper \"${currentPath.join('.')}\". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`,\n );\n }\n\n mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, leafGuard, label);\n }\n}\n\nfunction collectDescriptorPaths(\n namespace: Readonly<Record<string, unknown>>,\n isLeaf: (value: unknown) => boolean,\n path: readonly string[] = [],\n): string[] {\n const paths: string[] = [];\n for (const [key, value] of Object.entries(namespace)) {\n const currentPath = [...path, key];\n if (isLeaf(value)) {\n paths.push(currentPath.join('.'));\n continue;\n }\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n paths.push(\n ...collectDescriptorPaths(value as Readonly<Record<string, unknown>>, isLeaf, currentPath),\n );\n }\n }\n return paths;\n}\n\ninterface DescriptorEntry {\n readonly path: string;\n readonly discriminator: string;\n}\n\nfunction collectDescriptorEntries(\n namespace: Readonly<Record<string, unknown>>,\n isLeaf: (value: unknown) => boolean,\n label: string,\n path: readonly string[] = [],\n): DescriptorEntry[] {\n const entries: DescriptorEntry[] = [];\n for (const [key, value] of Object.entries(namespace)) {\n const currentPath = [...path, key];\n if (isLeaf(value)) {\n const record = blindCast<\n Record<string, unknown>,\n 'discriminator extraction from a leaf already validated by isLeaf'\n >(value);\n const discriminator = record['discriminator'];\n if (typeof discriminator === 'string' && discriminator.length > 0) {\n entries.push({ path: currentPath.join('.'), discriminator });\n }\n continue;\n }\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n const record = blindCast<\n Readonly<Record<string, unknown>>,\n 'walker inspects a non-leaf value for descriptor-shaped keys before recursing'\n >(value);\n // A value carrying descriptor-shaped keys (`kind`/`keyword`/`discriminator`)\n // but failing `isAuthoringPslBlockDescriptor` (e.g. missing `parameters`) is\n // a malformed declarative descriptor. Descending into it as a sub-namespace\n // would silently skip it, so a half-built contribution would pass validation.\n // Reject it at load time instead, naming the path and what's wrong.\n //\n // A valid sub-namespace whose key happens to be named `kind`, `keyword`, or\n // `discriminator` (but which does not look like a descriptor overall) must\n // still descend normally — the check requires descriptor-shaped keys present\n // AND the leaf guard rejecting it.\n if (\n (record['kind'] !== undefined ||\n record['keyword'] !== undefined ||\n record['discriminator'] !== undefined) &&\n !isLeaf(value)\n ) {\n const hasKind = record['kind'] === 'pslBlock';\n const hasKeyword = typeof record['keyword'] === 'string';\n const hasDiscriminator = typeof record['discriminator'] === 'string';\n if (hasKind || (hasKeyword && hasDiscriminator)) {\n throw new Error(\n `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.`,\n );\n }\n }\n entries.push(...collectDescriptorEntries(record, isLeaf, label, currentPath));\n }\n }\n return entries;\n}\n\n/**\n * Throws when two or more entries in the same namespace share a discriminator.\n * Duplicate discriminators within a namespace make dispatch ambiguous — the\n * lowering factory lookup dispatches by discriminator, so one would silently\n * shadow the other. Catch duplicates before building any dispatch map.\n */\nfunction assertUniqueDiscriminators(entries: readonly DescriptorEntry[], label: string): void {\n const seen = new Map<string, string>();\n for (const { path, discriminator } of entries) {\n const existing = seen.get(discriminator);\n if (existing !== undefined) {\n throw new Error(\n `Duplicate ${label} discriminator \"${discriminator}\" registered at both \"${existing}\" and \"${path}\". Each ${label} contribution must use a unique discriminator.`,\n );\n }\n seen.set(discriminator, path);\n }\n}\n\nfunction collectPslBlockDescriptorEntries(\n namespace: Readonly<Record<string, unknown>>,\n path: readonly string[] = [],\n): DescriptorEntry[] {\n const entries: DescriptorEntry[] = [];\n for (const [key, value] of Object.entries(namespace)) {\n const currentPath = [...path, key];\n if (isAuthoringPslBlockDescriptor(value)) {\n entries.push({\n path: currentPath.join('.'),\n discriminator: value.discriminator,\n });\n continue;\n }\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n const record = blindCast<\n Readonly<Record<string, unknown>>,\n 'walker descends into psl block namespace'\n >(value);\n const hasKind = record['kind'] === 'pslBlock';\n const hasKeyword = typeof record['keyword'] === 'string';\n const hasDiscriminator = typeof record['discriminator'] === 'string';\n if (hasKind || (hasKeyword && hasDiscriminator)) {\n throw new Error(\n `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.`,\n );\n }\n entries.push(...collectPslBlockDescriptorEntries(record, currentPath));\n }\n }\n return entries;\n}\n\n/**\n * Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory\n * with the same discriminator. An `entityTypes` factory may stand alone (e.g.\n * `enum`, reachable from the TypeScript builder without any PSL block).\n */\nfunction assertPslBlocksHaveFactories(\n entityTypeNamespace: AuthoringEntityTypeNamespace,\n pslBlockNamespace: AuthoringPslBlockDescriptorNamespace,\n): void {\n const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace);\n const entityEntries = collectDescriptorEntries(\n entityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n 'entityType',\n );\n\n assertUniqueDiscriminators(blockEntries, 'pslBlock');\n assertUniqueDiscriminators(entityEntries, 'entityType');\n\n const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator));\n\n for (const block of blockEntries) {\n if (!entityDiscriminators.has(block.discriminator)) {\n throw new Error(\n `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}\".`,\n );\n }\n }\n}\n\nexport function assertNoCrossRegistryCollisions(\n typeNamespace: AuthoringTypeNamespace,\n fieldNamespace: AuthoringFieldNamespace,\n entityTypeNamespace: AuthoringEntityTypeNamespace = {},\n pslBlockNamespace: AuthoringPslBlockDescriptorNamespace = {},\n): void {\n const typePaths = new Set(\n collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor),\n );\n const fieldPaths = new Set(\n collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor),\n );\n const entityPaths = new Set(\n collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor),\n );\n // Within-registry duplicate detection is handled upstream by the merge\n // walker (`mergeAuthoringNamespaces` in control-stack.ts and\n // `mergeHelperNamespaces` in composed-authoring-helpers.ts), which throws\n // on same-path registrations within any single registry before this check\n // runs. This function only handles the cross-registry case.\n //\n // Cross-registry collisions are checked among `type` / `field` /\n // `entityTypes` only — these three are user-facing helper paths that PSL\n // must resolve unambiguously. `pslBlockDescriptors` is an internal\n // framework index consumed by parser and printer dispatch, not a\n // user-facing helper path; the natural authoring pattern is the same\n // path key in `entityTypes` and `pslBlockDescriptors` for a single\n // contribution. The block→factory link is enforced by\n // `assertPslBlocksHaveFactories` via the discriminator string, not by path.\n const ambiguityHint =\n 'Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.';\n for (const fieldPath of fieldPaths) {\n if (typePaths.has(fieldPath)) {\n throw new Error(\n `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}`,\n );\n }\n }\n for (const entityPath of entityPaths) {\n if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) {\n throw new Error(\n `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}`,\n );\n }\n }\n\n assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace);\n}\n\nexport function resolveAuthoringTemplateValue(\n template: AuthoringTemplateValue,\n args: readonly unknown[],\n): unknown {\n if (isAuthoringArgRef(template)) {\n let value = args[template.index];\n\n for (const segment of template.path ?? []) {\n if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) {\n value = undefined;\n break;\n }\n value = (value as Record<string, unknown>)[segment];\n }\n\n if (value === undefined && template.default !== undefined) {\n return resolveAuthoringTemplateValue(template.default, args);\n }\n\n return value;\n }\n if (Array.isArray(template)) {\n return template.map((value) => resolveAuthoringTemplateValue(value, args));\n }\n if (typeof template === 'object' && template !== null) {\n const resolved: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(template)) {\n const resolvedValue = resolveAuthoringTemplateValue(value, args);\n if (resolvedValue !== undefined) {\n resolved[key] = resolvedValue;\n }\n }\n return resolved;\n }\n return template;\n}\n\nfunction validateAuthoringArgument(\n descriptor: AuthoringArgumentDescriptor,\n value: unknown,\n path: string,\n): void {\n if (value === undefined) {\n if (descriptor.optional) {\n return;\n }\n throw new Error(`Missing required authoring helper argument at ${path}`);\n }\n\n if (descriptor.kind === 'string') {\n if (typeof value !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be a string`);\n }\n return;\n }\n\n if (descriptor.kind === 'boolean') {\n if (typeof value !== 'boolean') {\n throw new Error(`Authoring helper argument at ${path} must be a boolean`);\n }\n return;\n }\n\n if (descriptor.kind === 'stringArray') {\n if (!Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n }\n return;\n }\n\n if (descriptor.kind === 'object') {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an object`);\n }\n\n const input = value as Record<string, unknown>;\n const expectedKeys = new Set(Object.keys(descriptor.properties));\n\n for (const key of Object.keys(input)) {\n if (!expectedKeys.has(key)) {\n throw new Error(`Authoring helper argument at ${path} contains unknown property \"${key}\"`);\n }\n }\n\n for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) {\n validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);\n }\n\n return;\n }\n\n if (typeof value !== 'number' || Number.isNaN(value)) {\n throw new Error(`Authoring helper argument at ${path} must be a number`);\n }\n\n if (descriptor.integer && !Number.isInteger(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an integer`);\n }\n if (descriptor.minimum !== undefined && value < descriptor.minimum) {\n throw new Error(\n `Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`,\n );\n }\n if (descriptor.maximum !== undefined && value > descriptor.maximum) {\n throw new Error(\n `Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`,\n );\n }\n}\n\nexport function validateAuthoringHelperArguments(\n helperPath: string,\n descriptors: readonly AuthoringArgumentDescriptor[] | undefined,\n args: readonly unknown[],\n): void {\n const expected = descriptors ?? [];\n const minimumArgs = expected.reduce(\n (count, descriptor, index) => (descriptor.optional ? count : index + 1),\n 0,\n );\n if (args.length < minimumArgs || args.length > expected.length) {\n throw new Error(\n `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`,\n );\n }\n\n expected.forEach((descriptor, index) => {\n validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);\n });\n}\n\nfunction resolveAuthoringStorageTypeTemplate(\n template: AuthoringStorageTypeTemplate,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n const nativeType = resolveAuthoringTemplateValue(template.nativeType, args);\n if (typeof nativeType !== 'string') {\n throw new Error(\n `Resolved authoring nativeType must be a string for codec \"${template.codecId}\", received ${String(nativeType)}`,\n );\n }\n const typeParams =\n template.typeParams === undefined\n ? undefined\n : resolveAuthoringTemplateValue(template.typeParams, args);\n if (typeParams !== undefined && !isAuthoringTemplateRecord(typeParams)) {\n throw new Error(\n `Resolved authoring typeParams must be an object for codec \"${template.codecId}\", received ${String(typeParams)}`,\n );\n }\n\n return {\n codecId: template.codecId,\n nativeType,\n ...(typeParams === undefined ? {} : { typeParams }),\n };\n}\n\nfunction resolveAuthoringColumnDefaultTemplate(\n template: AuthoringColumnDefaultTemplate,\n args: readonly unknown[],\n): ColumnDefault {\n if (template.kind === 'literal') {\n const value = resolveAuthoringTemplateValue(template.value, args);\n if (value === undefined) {\n throw new Error('Resolved authoring literal default must not be undefined');\n }\n if (!isColumnDefaultLiteralInputValue(value)) {\n throw new Error(\n `Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`,\n );\n }\n return {\n kind: 'literal',\n value,\n };\n }\n\n const expression = resolveAuthoringTemplateValue(template.expression, args);\n if (expression === undefined || (typeof expression === 'object' && expression !== null)) {\n throw new Error(\n `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`,\n );\n }\n return {\n kind: 'function',\n expression: String(expression),\n };\n}\n\nfunction resolveExecutionMutationDefaultPhase(\n phase: 'onCreate' | 'onUpdate',\n template: AuthoringTemplateValue,\n args: readonly unknown[],\n): ExecutionMutationDefaultValue {\n const value = resolveAuthoringTemplateValue(template, args);\n if (!isExecutionMutationDefaultValue(value)) {\n throw new Error(\n `Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`,\n );\n }\n return value;\n}\n\nfunction resolveAuthoringExecutionDefaultsTemplate(\n template: AuthoringExecutionDefaultsTemplate,\n args: readonly unknown[],\n): ExecutionMutationDefaultPhases {\n return {\n ...ifDefined(\n 'onCreate',\n template.onCreate !== undefined\n ? resolveExecutionMutationDefaultPhase('onCreate', template.onCreate, args)\n : undefined,\n ),\n ...ifDefined(\n 'onUpdate',\n template.onUpdate !== undefined\n ? resolveExecutionMutationDefaultPhase('onUpdate', template.onUpdate, args)\n : undefined,\n ),\n };\n}\n\nexport function instantiateAuthoringTypeConstructor(\n descriptor: AuthoringTypeConstructorDescriptor,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n return resolveAuthoringStorageTypeTemplate(descriptor.output, args);\n}\n\nexport function instantiateAuthoringEntityType(\n helperPath: string,\n descriptor: AuthoringEntityTypeDescriptor,\n args: readonly unknown[],\n ctx: AuthoringEntityContext,\n): unknown {\n // Factory-output entities carry their input contract on the factory\n // signature itself — TypeScript narrows callers via\n // `EntityHelperFunction`'s extracted `input` parameter, and the factory\n // is free to do its own runtime validation (e.g. arktype Type). The\n // descriptor-level `args` validator is reserved for template-output\n // entities (which mirror field/type's declarative argument shape).\n if ('factory' in descriptor.output) {\n const input = args[0];\n // The base `AuthoringEntityTypeDescriptor`'s factory is typed\n // `(input: never, ctx) => unknown` so concrete pack-literal factories\n // with narrower input types remain assignable through the\n // contravariant position (see the type's docstring). The runtime\n // delegates input validation to the pack's factory itself, so we\n // forward the supplied input here without a static input contract.\n const factory = descriptor.output.factory as (\n input: unknown,\n ctx: AuthoringEntityContext,\n ) => unknown;\n return factory(input, ctx);\n }\n validateAuthoringHelperArguments(helperPath, descriptor.args, args);\n return resolveAuthoringTemplateValue(descriptor.output.template, args);\n}\n\nexport function instantiateAuthoringFieldPreset(\n descriptor: AuthoringFieldPresetDescriptor,\n args: readonly unknown[],\n): {\n readonly descriptor: {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n };\n readonly nullable: boolean;\n readonly default?: ColumnDefault;\n readonly executionDefaults?: ExecutionMutationDefaultPhases;\n readonly id: boolean;\n readonly unique: boolean;\n} {\n return {\n descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),\n nullable: descriptor.output.nullable ?? false,\n ...ifDefined(\n 'default',\n descriptor.output.default !== undefined\n ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args)\n : undefined,\n ),\n ...ifDefined(\n 'executionDefaults',\n descriptor.output.executionDefaults !== undefined\n ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args)\n : undefined,\n ),\n id: descriptor.output.id ?? false,\n unique: descriptor.output.unique ?? false,\n };\n}\n"],"mappings":";;;;AAyPA,SAAgB,kBAAkB,OAA0C;CAC1E,IAAI,OAAO,UAAU,YAAY,UAAU,QAAS,MAA6B,SAAS,OACxF,OAAO;CAET,MAAM,EAAE,OAAO,SAAS;CACxB,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,GACnE,OAAO;CAET,IAAI,SAAS,KAAA,MAAc,CAAC,MAAM,QAAQ,IAAI,KAAK,KAAK,MAAM,MAAM,OAAO,MAAM,QAAQ,IACvF,OAAO;CAET,OAAO;AACT;AAEA,SAAS,0BAA0B,OAAkD;CACnF,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAgB,qCACd,OAC6C;CAC7C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,qBACvC,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;AAE/C;AAEA,SAAgB,iCACd,OACyC;CACzC,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,iBACvC,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;AAE/C;AAEA,SAAgB,gCACd,OACwC;CACxC,IACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,UAEvC,OAAO;CAET,MAAM,gBAAiB,MAAsC;CAC7D,IAAI,OAAO,kBAAkB,YAAY,cAAc,WAAW,GA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AAM;EAC5B,QAAQ,WAAW,OAAO,UAAU;CACtC;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as CodecLookup } from "./codec-types-7Qng7VFc.mjs";
|
|
1
2
|
import { ColumnDefault, ExecutionMutationDefaultPhases } from "@prisma-next/contract/types";
|
|
2
3
|
import { Type } from "arktype";
|
|
3
4
|
|
|
@@ -58,7 +59,16 @@ type PslDiagnosticCode = 'PSL_UNTERMINATED_BLOCK' | 'PSL_UNSUPPORTED_TOP_LEVEL_B
|
|
|
58
59
|
* A `ref`-kind parameter identifier does not resolve to a declared entity of
|
|
59
60
|
* the required `refKind` within the declared scope.
|
|
60
61
|
*/
|
|
61
|
-
| 'PSL_EXTENSION_UNRESOLVED_REF'
|
|
62
|
+
| 'PSL_EXTENSION_UNRESOLVED_REF'
|
|
63
|
+
/**
|
|
64
|
+
* A parameter key appears more than once in an extension block body.
|
|
65
|
+
* The first occurrence is kept; subsequent occurrences emit this diagnostic.
|
|
66
|
+
*/
|
|
67
|
+
| 'PSL_EXTENSION_DUPLICATE_PARAMETER'
|
|
68
|
+
/**
|
|
69
|
+
* A `@@`-prefixed block-attribute line inside an extension block has invalid syntax.
|
|
70
|
+
*/
|
|
71
|
+
| 'PSL_INVALID_EXTENSION_BLOCK_ATTRIBUTE';
|
|
62
72
|
/**
|
|
63
73
|
* Descriptor vocabulary for a single parameter on a declared block.
|
|
64
74
|
*
|
|
@@ -96,19 +106,22 @@ interface PslBlockParamList {
|
|
|
96
106
|
/**
|
|
97
107
|
* The parsed representation of a single parameter value on a uniform
|
|
98
108
|
* extension-block AST node. Mirrors the `PslBlockParam` descriptor
|
|
99
|
-
* vocabulary:
|
|
109
|
+
* vocabulary, plus `bare` for keyonly entries:
|
|
100
110
|
*
|
|
101
111
|
* - `ref` → `PslExtensionBlockParamRef` — a raw identifier string
|
|
102
112
|
* (resolution runs in the validator, not the parser).
|
|
103
|
-
* - `value` → `
|
|
113
|
+
* - `value` → `PslExtensionBlockParamScalarValue` — a raw PSL literal string
|
|
104
114
|
* (codec validation runs in the validator).
|
|
105
115
|
* - `option` → `PslExtensionBlockParamOption` — the chosen token.
|
|
106
116
|
* - `list` → `PslExtensionBlockParamList` — ordered list of the above.
|
|
117
|
+
* - `bare` → `PslExtensionBlockParamBare` — a bare identifier line with no
|
|
118
|
+
* `= value` (e.g. `Low` in an enum2 block). The name is the key in
|
|
119
|
+
* `parameters`; the interpreting consumer decides the default value.
|
|
107
120
|
*
|
|
108
121
|
* These shapes are intentionally minimal. The validator and lowering refine
|
|
109
122
|
* and consume them; the generic framework parser produces them.
|
|
110
123
|
*/
|
|
111
|
-
type PslExtensionBlockParamValue = PslExtensionBlockParamRef | PslExtensionBlockParamScalarValue | PslExtensionBlockParamOption | PslExtensionBlockParamList;
|
|
124
|
+
type PslExtensionBlockParamValue = PslExtensionBlockParamRef | PslExtensionBlockParamScalarValue | PslExtensionBlockParamOption | PslExtensionBlockParamList | PslExtensionBlockParamBare;
|
|
112
125
|
interface PslExtensionBlockParamRef {
|
|
113
126
|
readonly kind: 'ref';
|
|
114
127
|
readonly identifier: string;
|
|
@@ -129,6 +142,35 @@ interface PslExtensionBlockParamList {
|
|
|
129
142
|
readonly items: readonly PslExtensionBlockParamValue[];
|
|
130
143
|
readonly span: PslSpan;
|
|
131
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* A bare identifier line inside an extension block — a key with no `= value`.
|
|
147
|
+
* Emitted when a line matches `/^[A-Za-z_]\w*$/` with no assignment. The
|
|
148
|
+
* consumer decides what default value (if any) to apply.
|
|
149
|
+
*/
|
|
150
|
+
interface PslExtensionBlockParamBare {
|
|
151
|
+
readonly kind: 'bare';
|
|
152
|
+
readonly span: PslSpan;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A positional argument on a block attribute, e.g. the `"pg/text@1"` in
|
|
156
|
+
* `@@type("pg/text@1")`.
|
|
157
|
+
*/
|
|
158
|
+
interface PslExtensionBlockAttributeArg {
|
|
159
|
+
readonly kind: 'positional';
|
|
160
|
+
readonly value: string;
|
|
161
|
+
readonly span: PslSpan;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A `@@`-prefixed block-level attribute parsed inside an extension block,
|
|
165
|
+
* e.g. `@@type("pg/text@1")`. Block attributes are captured generically
|
|
166
|
+
* — the parser does not validate attribute names or argument shapes; that
|
|
167
|
+
* is a concern of the block's interpreter.
|
|
168
|
+
*/
|
|
169
|
+
interface PslExtensionBlockAttribute {
|
|
170
|
+
readonly name: string;
|
|
171
|
+
readonly args: readonly PslExtensionBlockAttributeArg[];
|
|
172
|
+
readonly span: PslSpan;
|
|
173
|
+
}
|
|
132
174
|
/**
|
|
133
175
|
* Base shape for a uniform extension-contributed top-level PSL block
|
|
134
176
|
* node, as produced by the generic framework parser and consumed by the
|
|
@@ -142,13 +184,19 @@ interface PslExtensionBlockParamList {
|
|
|
142
184
|
* parameter names from the descriptor; values are the parsed parameter
|
|
143
185
|
* representations. Only parameters present in the source are included
|
|
144
186
|
* — absence of a required parameter is a validator concern, not a
|
|
145
|
-
* parser concern.
|
|
187
|
+
* parser concern. Insertion order is preserved; the first occurrence of a
|
|
188
|
+
* duplicate key is retained and subsequent occurrences emit
|
|
189
|
+
* `PSL_EXTENSION_DUPLICATE_PARAMETER`.
|
|
190
|
+
* - `blockAttributes` are `@@`-prefixed attribute lines inside the block, in
|
|
191
|
+
* declaration order. Captured generically — names and args are not validated
|
|
192
|
+
* by the parser.
|
|
146
193
|
* - `span` covers the full block from keyword to closing brace.
|
|
147
194
|
*/
|
|
148
195
|
interface PslExtensionBlock {
|
|
149
196
|
readonly kind: string;
|
|
150
197
|
readonly name: string;
|
|
151
198
|
readonly parameters: Record<string, PslExtensionBlockParamValue>;
|
|
199
|
+
readonly blockAttributes: readonly PslExtensionBlockAttribute[];
|
|
152
200
|
readonly span: PslSpan;
|
|
153
201
|
}
|
|
154
202
|
//#endregion
|
|
@@ -228,9 +276,29 @@ type AuthoringFieldNamespace = {
|
|
|
228
276
|
* discover what the factory actually needs to read (codec lookup,
|
|
229
277
|
* namespace registry, …).
|
|
230
278
|
*/
|
|
279
|
+
/**
|
|
280
|
+
* A write-only sink that a factory may push authoring-time diagnostics into.
|
|
281
|
+
* The concrete type pushed must be structurally compatible with whatever the
|
|
282
|
+
* consumer accumulates (typically `ContractSourceDiagnostic[]`); the framework
|
|
283
|
+
* layer deliberately does not depend on that concrete type.
|
|
284
|
+
*/
|
|
285
|
+
interface AuthoringDiagnosticSink {
|
|
286
|
+
push(d: {
|
|
287
|
+
readonly code: string;
|
|
288
|
+
readonly message: string;
|
|
289
|
+
readonly sourceId: string;
|
|
290
|
+
readonly span?: unknown;
|
|
291
|
+
}): void;
|
|
292
|
+
}
|
|
231
293
|
interface AuthoringEntityContext {
|
|
232
294
|
readonly family: string;
|
|
233
295
|
readonly target: string;
|
|
296
|
+
/** Codec registry available to factories that need to validate or decode values. */
|
|
297
|
+
readonly codecLookup?: CodecLookup;
|
|
298
|
+
/** Source file identifier threaded into diagnostics emitted by the factory. */
|
|
299
|
+
readonly sourceId?: string;
|
|
300
|
+
/** Push channel for authoring-time diagnostics emitted by the factory. */
|
|
301
|
+
readonly diagnostics?: AuthoringDiagnosticSink;
|
|
234
302
|
}
|
|
235
303
|
interface AuthoringEntityTypeTemplateOutput {
|
|
236
304
|
readonly template: AuthoringTemplateValue;
|
|
@@ -300,6 +368,21 @@ interface AuthoringPslBlockDescriptor {
|
|
|
300
368
|
readonly required: boolean;
|
|
301
369
|
};
|
|
302
370
|
readonly parameters: Record<string, PslBlockParam>;
|
|
371
|
+
/**
|
|
372
|
+
* When `true`, the block body accepts a variadic tail of parameters beyond
|
|
373
|
+
* the declared set. The block body may contain: fields (model-style),
|
|
374
|
+
* `key = value` parameters, and `@@` attributes. With `variadicParameters`,
|
|
375
|
+
* bare identifiers (keys without a `= value`) and undeclared `key = value`
|
|
376
|
+
* pairs flow into the variadic tail — their semantics belong to the
|
|
377
|
+
* lowering, not the parser.
|
|
378
|
+
*
|
|
379
|
+
* A key that IS declared in `parameters` must still be supplied as
|
|
380
|
+
* `key = value`; a bare occurrence of a declared key is a diagnostic.
|
|
381
|
+
*
|
|
382
|
+
* When `false` (default), the validator emits `PSL_EXTENSION_UNKNOWN_PARAMETER`
|
|
383
|
+
* for keys absent from `parameters`.
|
|
384
|
+
*/
|
|
385
|
+
readonly variadicParameters?: boolean;
|
|
303
386
|
}
|
|
304
387
|
type AuthoringPslBlockDescriptorNamespace = {
|
|
305
388
|
readonly [name: string]: AuthoringPslBlockDescriptor | AuthoringPslBlockDescriptorNamespace;
|
|
@@ -376,5 +459,5 @@ declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPrese
|
|
|
376
459
|
readonly unique: boolean;
|
|
377
460
|
};
|
|
378
461
|
//#endregion
|
|
379
|
-
export {
|
|
380
|
-
//# sourceMappingURL=framework-authoring-
|
|
462
|
+
export { mergeAuthoringNamespaces as A, PslExtensionBlockAttribute as B, instantiateAuthoringFieldPreset as C, isAuthoringFieldPresetDescriptor as D, isAuthoringEntityTypeDescriptor as E, PslBlockParamOption as F, PslExtensionBlockParamRef as G, PslExtensionBlockParamBare as H, PslBlockParamRef as I, PslPosition as J, PslExtensionBlockParamScalarValue as K, PslBlockParamValue as L, validateAuthoringHelperArguments as M, PslBlockParam as N, isAuthoringPslBlockDescriptor as O, PslBlockParamList as P, PslDiagnosticCode as R, instantiateAuthoringEntityType as S, isAuthoringArgRef as T, PslExtensionBlockParamList as U, PslExtensionBlockAttributeArg as V, PslExtensionBlockParamOption as W, PslSpan as Y, AuthoringTemplateValue as _, AuthoringDiagnosticSink as a, assertNoCrossRegistryCollisions as b, AuthoringEntityTypeFactoryOutput as c, AuthoringFieldNamespace as d, AuthoringFieldPresetDescriptor as f, AuthoringStorageTypeTemplate as g, AuthoringPslBlockDescriptorNamespace as h, AuthoringContributions as i, resolveAuthoringTemplateValue as j, isAuthoringTypeConstructorDescriptor as k, AuthoringEntityTypeNamespace as l, AuthoringPslBlockDescriptor as m, AuthoringArgumentDescriptor as n, AuthoringEntityContext as o, AuthoringFieldPresetOutput as p, PslExtensionBlockParamValue as q, AuthoringColumnDefaultTemplate as r, AuthoringEntityTypeDescriptor as s, AuthoringArgRef as t, AuthoringEntityTypeTemplateOutput as u, AuthoringTypeConstructorDescriptor as v, instantiateAuthoringTypeConstructor as w, hasRegisteredFieldNamespace as x, AuthoringTypeNamespace as y, PslExtensionBlock as z };
|
|
463
|
+
//# sourceMappingURL=framework-authoring-DMAwH52s.d.mts.map
|