@prisma-next/framework-components 0.7.0-dev.7 → 0.8.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/authoring.d.mts +2 -2
  2. package/dist/authoring.mjs +2 -2
  3. package/dist/components.d.mts +1 -1
  4. package/dist/control.d.mts +108 -21
  5. package/dist/control.d.mts.map +1 -1
  6. package/dist/control.mjs +8 -5
  7. package/dist/control.mjs.map +1 -1
  8. package/dist/execution.d.mts +1 -1
  9. package/dist/{framework-authoring-DGIQbNPt.d.mts → framework-authoring-Bb_GEnzj.d.mts} +43 -3
  10. package/dist/framework-authoring-Bb_GEnzj.d.mts.map +1 -0
  11. package/dist/{framework-authoring-DxXcjyJX.mjs → framework-authoring-DcEZ5Lin.mjs} +26 -5
  12. package/dist/framework-authoring-DcEZ5Lin.mjs.map +1 -0
  13. package/dist/{framework-components-DwkHnl-e.d.mts → framework-components-DQRRmQOH.d.mts} +2 -2
  14. package/dist/{framework-components-DwkHnl-e.d.mts.map → framework-components-DQRRmQOH.d.mts.map} +1 -1
  15. package/dist/ir.d.mts +161 -0
  16. package/dist/ir.d.mts.map +1 -0
  17. package/dist/ir.mjs +39 -0
  18. package/dist/ir.mjs.map +1 -0
  19. package/package.json +8 -7
  20. package/src/control/contract-serializer.ts +37 -0
  21. package/src/control/control-descriptors.ts +10 -0
  22. package/src/control/control-instances.ts +7 -15
  23. package/src/control/control-schema-view.ts +3 -3
  24. package/src/control/control-stack.ts +24 -10
  25. package/src/control/schema-verifier.ts +51 -0
  26. package/src/exports/authoring.ts +7 -0
  27. package/src/exports/control.ts +7 -1
  28. package/src/exports/ir.ts +6 -0
  29. package/src/ir/ir-node.ts +62 -0
  30. package/src/ir/namespace.ts +40 -0
  31. package/src/ir/storage-type.ts +23 -0
  32. package/src/ir/storage.ts +41 -0
  33. package/src/shared/framework-authoring.ts +116 -12
  34. package/dist/framework-authoring-DGIQbNPt.d.mts.map +0 -1
  35. package/dist/framework-authoring-DxXcjyJX.mjs.map +0 -1
@@ -0,0 +1,51 @@
1
+ import type { SchemaIssue } from './control-result-types';
2
+
3
+ /**
4
+ * Framework SPI for verifying that an introspected schema matches the
5
+ * contract that authored it. The implementer walks the target's IR
6
+ * natively — concrete classes, target-only kinds — and reports issues.
7
+ *
8
+ * The framework verifier (per FR6) walks the contract-space aggregate,
9
+ * dispatches to the right target's verifier (`descriptor.schemaVerifier`)
10
+ * per space, and wraps the per-target results into a unified
11
+ * `VerifyDatabaseSchemaResult` with timings, summary, and per-node
12
+ * verification tree.
13
+ *
14
+ * Family-level abstract bases (e.g. `SqlSchemaVerifierBase`) carry the
15
+ * shared SQL/Mongo walk logic and expose protected hooks for target
16
+ * extensions; concrete target verifiers (`PostgresSchemaVerifier extends
17
+ * SqlSchemaVerifierBase`) own the dispatch on target-specific kinds.
18
+ *
19
+ * Target-specific issue kinds (RLS-policy-mismatch, namespace-mismatch,
20
+ * future function-shape-mismatch) are widened target-side; the framework
21
+ * `SchemaIssue` union (in `control-result-types.ts`) is intentionally not
22
+ * generic over target kinds in this project — see the spec's
23
+ * "Forward note: SchemaIssue layering" for the layering observation
24
+ * captured for a future project.
25
+ */
26
+ export interface SchemaVerifier<TContract, TSchema> {
27
+ verifySchema(options: SchemaVerifyOptions<TContract, TSchema>): SchemaVerifyResult;
28
+ }
29
+
30
+ /**
31
+ * Minimal per-target verifier input. Family abstract bases extend this
32
+ * shape with family-specific options (`strict`, `frameworkComponents`,
33
+ * codec hooks, …) — the framework SPI itself stays at the contract +
34
+ * schema pair every implementer needs.
35
+ */
36
+ export interface SchemaVerifyOptions<TContract, TSchema> {
37
+ readonly contract: TContract;
38
+ readonly schema: TSchema;
39
+ }
40
+
41
+ /**
42
+ * Per-target verifier result. The framework verifier wraps these into the
43
+ * existing `VerifyDatabaseSchemaResult` envelope (with timings, summary,
44
+ * per-node verification tree); the SPI itself returns just the
45
+ * core ok/issues pair so the seam between target-walk and
46
+ * framework-aggregation is explicit.
47
+ */
48
+ export interface SchemaVerifyResult {
49
+ readonly ok: boolean;
50
+ readonly issues: readonly SchemaIssue[];
51
+ }
@@ -3,6 +3,11 @@ export type {
3
3
  AuthoringArgumentDescriptor,
4
4
  AuthoringColumnDefaultTemplate,
5
5
  AuthoringContributions,
6
+ AuthoringEntityContext,
7
+ AuthoringEntityTypeDescriptor,
8
+ AuthoringEntityTypeFactoryOutput,
9
+ AuthoringEntityTypeNamespace,
10
+ AuthoringEntityTypeTemplateOutput,
6
11
  AuthoringFieldNamespace,
7
12
  AuthoringFieldPresetDescriptor,
8
13
  AuthoringFieldPresetOutput,
@@ -14,9 +19,11 @@ export type {
14
19
  export {
15
20
  assertNoCrossRegistryCollisions,
16
21
  hasRegisteredFieldNamespace,
22
+ instantiateAuthoringEntityType,
17
23
  instantiateAuthoringFieldPreset,
18
24
  instantiateAuthoringTypeConstructor,
19
25
  isAuthoringArgRef,
26
+ isAuthoringEntityTypeDescriptor,
20
27
  isAuthoringFieldPresetDescriptor,
21
28
  isAuthoringTypeConstructorDescriptor,
22
29
  mergeAuthoringNamespaces,
@@ -1,4 +1,5 @@
1
1
  export type { ImportRequirement } from '@prisma-next/ts-render';
2
+ export type { ContractSerializer } from '../control/contract-serializer';
2
3
  export type {
3
4
  MigratableTargetDescriptor,
4
5
  OperationPreviewCapable,
@@ -78,9 +79,9 @@ export {
78
79
  } from '../control/control-result-types';
79
80
  export type {
80
81
  CoreSchemaView,
81
- SchemaNodeKind,
82
82
  SchemaTreeNodeOptions,
83
83
  SchemaTreeVisitor,
84
+ SchemaViewNodeKind,
84
85
  } from '../control/control-schema-view';
85
86
  export { SchemaTreeNode } from '../control/control-schema-view';
86
87
  export type {
@@ -105,6 +106,11 @@ export {
105
106
  extractComponentIds,
106
107
  extractQueryOperationTypeImports,
107
108
  } from '../control/control-stack';
109
+ export type {
110
+ SchemaVerifier,
111
+ SchemaVerifyOptions,
112
+ SchemaVerifyResult,
113
+ } from '../control/schema-verifier';
108
114
  export type {
109
115
  ControlMutationDefaultEntry,
110
116
  ControlMutationDefaultRegistry,
@@ -0,0 +1,6 @@
1
+ export type { IRNode } from '../ir/ir-node';
2
+ export { freezeNode, IRNodeBase } from '../ir/ir-node';
3
+ export type { Namespace } from '../ir/namespace';
4
+ export { NamespaceBase, UNSPECIFIED_NAMESPACE_ID } from '../ir/namespace';
5
+ export type { Storage } from '../ir/storage';
6
+ export type { StorageType } from '../ir/storage-type';
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Framework-level IR alphabet.
3
+ *
4
+ * The framework's contribution to Contract IR / Schema IR is a common
5
+ * root for the IR class hierarchy and a freeze affordance. Family
6
+ * abstract bases (e.g. `SqlNode`, `MongoSchemaIRNode`) refine the alphabet
7
+ * for their family shape; targets ship the concrete classes.
8
+ *
9
+ * `kind` is an optional discriminator on the base. Families and leaves
10
+ * that benefit from discriminated-union dispatch declare their own
11
+ * literal `kind` at the level that earns it — Mongo leaves carry
12
+ * per-class literals (`readonly kind = 'mongo-collection' as const`)
13
+ * because Mongo IR has polymorphic walkers; SQL declares a single
14
+ * family-level `kind = 'sql'` on `SqlNode` because SQL IR has no
15
+ * polymorphic dispatch today. No framework consumer dispatches on
16
+ * `IRNode.kind` at the BASE type — every dispatch site narrows
17
+ * through a union of leaves where each leaf carries a literal kind, so
18
+ * requiring `kind` at the base would be unearned. Future leaves that
19
+ * earn polymorphic dispatch override with a required literal at that
20
+ * leaf (e.g. `override readonly kind = 'postgres-enum' as const`).
21
+ *
22
+ * `IRNodeBase` carries no methods: the freeze-and-assign affordance
23
+ * lives in the free `freezeNode` helper below. Keeping `freezeNode` out
24
+ * of the class type means an emitted contract literal type
25
+ * (`{ readonly kind: 'mongo-collection', ... }` or an unkeyed literal
26
+ * like `{ nativeType, codecId, nullable }`) is structurally assignable
27
+ * to its class type — a `protected freeze()` instance method would
28
+ * otherwise leak into the public type surface and require the literal
29
+ * to carry it too.
30
+ *
31
+ * Subclasses construct fields then call `freezeNode(this)` to seal the
32
+ * instance. Frozen instances + plain readonly fields keep IR nodes
33
+ * JSON-clean by construction, so `JSON.stringify(node)` produces canonical
34
+ * JSON without a `toJSON()` method. The `ContractSerializer` SPI handles
35
+ * round-trip from canonical JSON back to typed class instances.
36
+ *
37
+ * The name (`IRNode` / `IRNodeBase`) reflects the dual-hierarchy reality:
38
+ * this base is the common root for both Contract IR and Schema IR class
39
+ * hierarchies, not a Schema-IR-specific alphabet.
40
+ */
41
+
42
+ export interface IRNode {
43
+ readonly kind?: string;
44
+ }
45
+
46
+ export abstract class IRNodeBase implements IRNode {
47
+ abstract readonly kind?: string;
48
+ }
49
+
50
+ /**
51
+ * Seal an IR class instance after its constructor has assigned all
52
+ * fields. The free-helper form (rather than a `protected freeze()`
53
+ * instance method) keeps the class type structurally narrow so emitted
54
+ * contract literal types remain assignable to their class types.
55
+ *
56
+ * The helper name stays `freezeNode` — it operates on IR nodes
57
+ * regardless of root naming.
58
+ */
59
+ export function freezeNode<T extends IRNode>(node: T): T {
60
+ Object.freeze(node);
61
+ return node;
62
+ }
@@ -0,0 +1,40 @@
1
+ import { type IRNode, IRNodeBase } from './ir-node';
2
+
3
+ /**
4
+ * Reserved sentinel namespace id meaning
5
+ * "no namespace bound at authoring time; resolve from connection context".
6
+ *
7
+ * Materialised target-side as a singleton subclass of the target's
8
+ * `NamespaceBase` concretion that overrides the namespace's
9
+ * qualifier-emission methods to elide the prefix entirely. Call sites
10
+ * stay polymorphic and never branch on `id === UNSPECIFIED_NAMESPACE_ID`
11
+ * — the singleton's overrides drop the qualifier so emitted SQL / Mongo
12
+ * commands look unqualified.
13
+ *
14
+ * Encoded as an exported const (rather than scattered string literals)
15
+ * so the sentinel-id invariant is single-sourced: any production-source
16
+ * site that constructs an unspecified-namespace singleton imports this
17
+ * constant.
18
+ */
19
+ export const UNSPECIFIED_NAMESPACE_ID = '__unspecified__' as const;
20
+
21
+ /**
22
+ * Framework-level building block for a "namespace" — the database-level
23
+ * grouping under which storage objects (tables, collections, enums, …)
24
+ * reside. Each target's namespace concretion maps the framework concept to
25
+ * a target-native binding:
26
+ *
27
+ * - Postgres: a schema (`CREATE SCHEMA …`); rendered as `"<schema>"`.
28
+ * - SQLite: the singleton `UNSPECIFIED_NAMESPACE_ID`; emitted SQL has no qualifier.
29
+ * - Mongo: the connection's `db` field; addressed as a database name.
30
+ *
31
+ * See `UNSPECIFIED_NAMESPACE_ID` above for the sentinel id and the
32
+ * singleton-subclass pattern that materialises it.
33
+ */
34
+ export interface Namespace extends IRNode {
35
+ readonly id: string;
36
+ }
37
+
38
+ export abstract class NamespaceBase extends IRNodeBase implements Namespace {
39
+ abstract readonly id: string;
40
+ }
@@ -0,0 +1,23 @@
1
+ import type { IRNode } from './ir-node';
2
+
3
+ /**
4
+ * Framework-level alphabet for entries in a storage `types` slot.
5
+ *
6
+ * The slot is polymorphic at the framework level: a family or target can
7
+ * persist either a JSON-clean codec-triple object literal (carrying
8
+ * `kind: 'codec-instance'`) or a class-instance IR node with a narrower
9
+ * kind discriminator (e.g. `'postgres-enum'`). Hydration walkers,
10
+ * verifiers, and planners dispatch on the `kind` literal to recover the
11
+ * precise variant.
12
+ *
13
+ * The `kind` field is required at this layer (in contrast with
14
+ * `IRNode.kind` which is optional) because the slot's downstream
15
+ * consumers dispatch on it — without a guaranteed discriminator the
16
+ * polymorphic walk cannot pick the right reader. Concrete variants
17
+ * narrow `kind` to their literal and add their own field set;
18
+ * downstream consumers use `kind`-discriminator helpers to recover
19
+ * the precise shape.
20
+ */
21
+ export interface StorageType extends IRNode {
22
+ readonly kind: string;
23
+ }
@@ -0,0 +1,41 @@
1
+ import type { IRNode } from './ir-node';
2
+ import type { Namespace } from './namespace';
3
+
4
+ /**
5
+ * Framework-level promise that every Contract IR / Schema IR carries a
6
+ * collection of namespaces keyed by namespace id. Family storage
7
+ * concretions (`SqlStorage`, `MongoStorage`) refine the shape with
8
+ * family-specific fields (tables, collections, enums, …); target
9
+ * concretions add target fields where the family vocabulary doesn't
10
+ * reach.
11
+ *
12
+ * Keeping `namespaces` at the framework layer enforces that every storage
13
+ * object — across any target — is namespace-scoped. The framework can
14
+ * therefore walk the namespace map without knowing the family alphabet, and
15
+ * the `(namespace.id, name)` keying that the verifier and planner depend on
16
+ * is honest at every layer.
17
+ *
18
+ * Extends `IRNode` so the framework's IR-walking surfaces (verifiers,
19
+ * serializers) can dispatch on `Storage`-typed slots through the same
20
+ * IR-node alphabet as every other node — the structural dual already
21
+ * holds in code (every concrete storage class extends an IR-node base);
22
+ * the interface promotion makes the typing honest.
23
+ *
24
+ * **Persisted envelope shape is target-owned, not framework-promised.**
25
+ * Whether the `namespaces` map appears in the on-disk JSON envelope is
26
+ * a per-target decision made by `ContractSerializer.serializeContract`.
27
+ * Some targets emit a JSON-clean namespace shape that round-trips
28
+ * through `JSON.stringify` cleanly (SQL today via the family-layer
29
+ * identity serializer); others ship runtime-only fields on their
30
+ * namespace concretions and override `serializeContract` to strip
31
+ * them (Mongo). Future open (F16): extend the per-target
32
+ * `ContractSerializer` integration-test surface with an explicit
33
+ * envelope-shape assertion for each target, so the strip-vs-pass-through
34
+ * choice is locked at test time rather than implied by the override
35
+ * presence/absence. Earned by PR2's per-target namespace lift, when
36
+ * `PostgresSchema` / `SqliteUnspecifiedDatabase` start carrying
37
+ * target-specific fields.
38
+ */
39
+ export interface Storage extends IRNode {
40
+ readonly namespaces: Readonly<Record<string, Namespace>>;
41
+ }
@@ -100,9 +100,54 @@ export type AuthoringFieldNamespace = {
100
100
  readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;
101
101
  };
102
102
 
103
+ /**
104
+ * Context surfaced to entity-type factories at call time. Currently a
105
+ * placeholder — sharpened as concrete consumers (enum, namespace, …)
106
+ * discover what the factory actually needs to read (codec lookup,
107
+ * namespace registry, …).
108
+ */
109
+ export interface AuthoringEntityContext {
110
+ readonly family: string;
111
+ readonly target: string;
112
+ }
113
+
114
+ export interface AuthoringEntityTypeTemplateOutput {
115
+ readonly template: AuthoringTemplateValue;
116
+ }
117
+
118
+ /**
119
+ * Default `Input = never` is load-bearing for pack-bag-driven type
120
+ * narrowing. Factory parameter positions are contravariant, so a pack
121
+ * literal declaring `factory: (input: DemoEntityInput) => DemoEntity`
122
+ * is only assignable to the base descriptor's factory shape if the
123
+ * base's input is `never` (the bottom of the contravariant position).
124
+ * The concrete input/output types are recovered at the helper-derivation
125
+ * site via `EntityHelperFunction<Descriptor>`'s conditional inference,
126
+ * which reads them from the pack's `as const` literal factory signature
127
+ * — the base widening does not erase the literal because `satisfies`
128
+ * does not widen the declared type.
129
+ */
130
+ export interface AuthoringEntityTypeFactoryOutput<Input = never, Output = unknown> {
131
+ readonly factory: (input: Input, ctx: AuthoringEntityContext) => Output;
132
+ }
133
+
134
+ export interface AuthoringEntityTypeDescriptor<Input = never, Output = unknown> {
135
+ readonly kind: 'entity';
136
+ readonly discriminator: string;
137
+ readonly args?: readonly AuthoringArgumentDescriptor[];
138
+ readonly output:
139
+ | AuthoringEntityTypeTemplateOutput
140
+ | AuthoringEntityTypeFactoryOutput<Input, Output>;
141
+ }
142
+
143
+ export type AuthoringEntityTypeNamespace = {
144
+ readonly [name: string]: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace;
145
+ };
146
+
103
147
  export interface AuthoringContributions {
104
148
  readonly type?: AuthoringTypeNamespace;
105
149
  readonly field?: AuthoringFieldNamespace;
150
+ readonly entityTypes?: AuthoringEntityTypeNamespace;
106
151
  }
107
152
 
108
153
  export function isAuthoringArgRef(value: unknown): value is AuthoringArgRef {
@@ -147,6 +192,29 @@ export function isAuthoringFieldPresetDescriptor(
147
192
  );
148
193
  }
149
194
 
195
+ export function isAuthoringEntityTypeDescriptor(
196
+ value: unknown,
197
+ ): value is AuthoringEntityTypeDescriptor {
198
+ if (
199
+ typeof value !== 'object' ||
200
+ value === null ||
201
+ (value as { kind?: unknown }).kind !== 'entity'
202
+ ) {
203
+ return false;
204
+ }
205
+ const discriminator = (value as { discriminator?: unknown }).discriminator;
206
+ if (typeof discriminator !== 'string' || discriminator.length === 0) {
207
+ return false;
208
+ }
209
+ const output = (value as { output?: unknown }).output;
210
+ if (typeof output !== 'object' || output === null) {
211
+ return false;
212
+ }
213
+ const factory = (output as { factory?: unknown }).factory;
214
+ const template = (output as { template?: unknown }).template;
215
+ return typeof factory === 'function' || template !== undefined;
216
+ }
217
+
150
218
  /**
151
219
  * Returns true when `namespace` is a non-leaf key in `contributions.field`.
152
220
  *
@@ -263,27 +331,33 @@ function collectAuthoringLeafPaths(
263
331
  export function assertNoCrossRegistryCollisions(
264
332
  typeNamespace: AuthoringTypeNamespace,
265
333
  fieldNamespace: AuthoringFieldNamespace,
334
+ entityTypeNamespace: AuthoringEntityTypeNamespace = {},
266
335
  ): void {
267
336
  const typePaths = new Set(
268
337
  collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor),
269
338
  );
339
+ const fieldPaths = new Set(
340
+ collectAuthoringLeafPaths(fieldNamespace, isAuthoringFieldPresetDescriptor),
341
+ );
342
+ const entityPaths = new Set(
343
+ collectAuthoringLeafPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor),
344
+ );
270
345
  // Within-registry duplicate detection is handled upstream by the merge
271
346
  // walker (`mergeAuthoringNamespaces` in control-stack.ts and
272
347
  // `mergeHelperNamespaces` in composed-authoring-helpers.ts), which throws
273
- // on same-path registrations within either registry before this check
274
- // runs. This function only handles the cross-registry case — and an
275
- // empty type namespace makes a cross-registry collision structurally
276
- // impossible, so the early-out is sound.
277
- if (typePaths.size === 0) {
278
- return;
279
- }
280
- for (const fieldPath of collectAuthoringLeafPaths(
281
- fieldNamespace,
282
- isAuthoringFieldPresetDescriptor,
283
- )) {
348
+ // on same-path registrations within any single registry before this check
349
+ // runs. This function only handles the cross-registry case.
350
+ for (const fieldPath of fieldPaths) {
284
351
  if (typePaths.has(fieldPath)) {
285
352
  throw new Error(
286
- `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. Register each path in only one of authoringContributions.field / authoringContributions.type.`,
353
+ `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.`,
354
+ );
355
+ }
356
+ }
357
+ for (const entityPath of entityPaths) {
358
+ if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) {
359
+ throw new Error(
360
+ `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. Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.`,
287
361
  );
288
362
  }
289
363
  }
@@ -533,6 +607,36 @@ export function instantiateAuthoringTypeConstructor(
533
607
  return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
534
608
  }
535
609
 
610
+ export function instantiateAuthoringEntityType(
611
+ helperPath: string,
612
+ descriptor: AuthoringEntityTypeDescriptor,
613
+ args: readonly unknown[],
614
+ ctx: AuthoringEntityContext,
615
+ ): unknown {
616
+ // Factory-output entities carry their input contract on the factory
617
+ // signature itself — TypeScript narrows callers via
618
+ // `EntityHelperFunction`'s extracted `input` parameter, and the factory
619
+ // is free to do its own runtime validation (e.g. arktype Type). The
620
+ // descriptor-level `args` validator is reserved for template-output
621
+ // entities (which mirror field/type's declarative argument shape).
622
+ if ('factory' in descriptor.output) {
623
+ const input = args[0];
624
+ // The base `AuthoringEntityTypeDescriptor`'s factory is typed
625
+ // `(input: never, ctx) => unknown` so concrete pack-literal factories
626
+ // with narrower input types remain assignable through the
627
+ // contravariant position (see the type's docstring). The runtime
628
+ // delegates input validation to the pack's factory itself, so we
629
+ // forward the supplied input here without a static input contract.
630
+ const factory = descriptor.output.factory as (
631
+ input: unknown,
632
+ ctx: AuthoringEntityContext,
633
+ ) => unknown;
634
+ return factory(input, ctx);
635
+ }
636
+ validateAuthoringHelperArguments(helperPath, descriptor.args, args);
637
+ return resolveAuthoringTemplateValue(descriptor.output.template, args);
638
+ }
639
+
536
640
  export function instantiateAuthoringFieldPreset(
537
641
  descriptor: AuthoringFieldPresetDescriptor,
538
642
  args: readonly unknown[],
@@ -1 +0,0 @@
1
- {"version":3,"file":"framework-authoring-DGIQbNPt.d.mts","names":[],"sources":["../src/shared/framework-authoring.ts"],"mappings":";;;KAWY,eAAA;EAAA,SACD,IAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA,GAAU,sBAAA;AAAA;AAAA,KAGT,sBAAA,sCAKR,eAAA,YACS,sBAAA;EAAA,UACG,GAAA,WAAc,sBAAA;AAAA;AAAA,UAEpB,iCAAA;EAAA,SACC,IAAA;EAAA,SACA,QAAA;AAAA;AAAA,KAGC,2BAAA,GAA8B,iCAAA;EAAA,SAEzB,IAAA;AAAA;EAAA,SACA,IAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SACA,OAAA;EAAA,SACA,OAAA;EAAA,SACA,OAAA;AAAA;EAAA,SAEA,IAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SACA,UAAA,EAAY,MAAA,SAAe,2BAAA;AAAA;AAAA,UAI3B,4BAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA,EAAY,sBAAA;EAAA,SACZ,UAAA,GAAa,MAAA,SAAe,sBAAA;AAAA;AAAA,UAGtB,kCAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA,YAAgB,2BAAA;EAAA,SAChB,MAAA,EAAQ,4BAAA;AAAA;AAAA,UAGF,qCAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA,EAAO,sBAAA;AAAA;AAAA,UAGD,sCAAA;EAAA,SACN,IAAA;EAAA,SACA,UAAA,EAAY,sBAAA;AAAA;AAAA,KAGX,8BAAA,GACR,qCAAA,GACA,sCAAA;AAAA,UAEa,kCAAA;EAAA,SACN,QAAA,GAAW,sBAAA;EAAA,SACX,QAAA,GAAW,sBAAA;AAAA;AAAA,UAGL,0BAAA,SAAmC,4BAAA;EAAA,SACzC,QA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A,SACE,OAAA;IAAA,SACA,UAAA;IAAA,SACA,UAAA,GAAa,MAAA;EAAA;EAAA,SAEf,QAAA;EAAA,SACA,OAAA,GAAU,aAAA;EAAA,SACV,iBAAA,GAAoB,8BAAA;EAAA,SACpB,EAAA;EAAA,SACA,MAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"framework-authoring-DxXcjyJX.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 { ifDefined } from '@prisma-next/utils/defined';\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\nexport interface AuthoringContributions {\n readonly type?: AuthoringTypeNamespace;\n readonly field?: AuthoringFieldNamespace;\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\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 collectAuthoringLeafPaths(\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 ...collectAuthoringLeafPaths(\n value as Readonly<Record<string, unknown>>,\n isLeaf,\n currentPath,\n ),\n );\n }\n }\n return paths;\n}\n\nexport function assertNoCrossRegistryCollisions(\n typeNamespace: AuthoringTypeNamespace,\n fieldNamespace: AuthoringFieldNamespace,\n): void {\n const typePaths = new Set(\n collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor),\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 either registry before this check\n // runs. This function only handles the cross-registry case — and an\n // empty type namespace makes a cross-registry collision structurally\n // impossible, so the early-out is sound.\n if (typePaths.size === 0) {\n return;\n }\n for (const fieldPath of collectAuthoringLeafPaths(\n fieldNamespace,\n isAuthoringFieldPresetDescriptor,\n )) {\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. Register each path in only one of authoringContributions.field / authoringContributions.type.`,\n );\n }\n }\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 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":";;;AA2GA,SAAgB,kBAAkB,OAA0C;CAC1E,IAAI,OAAO,UA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