@prisma-next/framework-components 0.7.0 → 0.8.0-dev.10
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 +2 -2
- package/dist/components.d.mts +1 -1
- package/dist/control.d.mts +121 -29
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +9 -6
- package/dist/control.mjs.map +1 -1
- package/dist/execution.d.mts +1 -1
- package/dist/{framework-authoring-DGIQbNPt.d.mts → framework-authoring-Bb_GEnzj.d.mts} +43 -3
- package/dist/framework-authoring-Bb_GEnzj.d.mts.map +1 -0
- package/dist/{framework-authoring-DxXcjyJX.mjs → framework-authoring-DcEZ5Lin.mjs} +26 -5
- package/dist/framework-authoring-DcEZ5Lin.mjs.map +1 -0
- package/dist/{framework-components-DwkHnl-e.d.mts → framework-components-DQRRmQOH.d.mts} +2 -2
- package/dist/{framework-components-DwkHnl-e.d.mts.map → framework-components-DQRRmQOH.d.mts.map} +1 -1
- package/dist/ir.d.mts +161 -0
- package/dist/ir.d.mts.map +1 -0
- package/dist/ir.mjs +39 -0
- package/dist/ir.mjs.map +1 -0
- package/dist/runtime.d.mts +336 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +140 -1
- package/dist/runtime.mjs.map +1 -1
- package/package.json +10 -9
- package/src/annotations.ts +322 -0
- package/src/control/contract-serializer.ts +37 -0
- package/src/control/control-capabilities.ts +1 -1
- package/src/control/control-descriptors.ts +10 -0
- package/src/control/control-instances.ts +7 -15
- package/src/control/control-migration-types.ts +10 -4
- package/src/control/control-schema-view.ts +3 -3
- package/src/control/control-spaces.ts +2 -3
- package/src/control/control-stack.ts +24 -10
- package/src/control/schema-verifier.ts +51 -0
- package/src/execution/runtime-middleware.ts +49 -0
- package/src/exports/authoring.ts +7 -0
- package/src/exports/control.ts +7 -1
- package/src/exports/ir.ts +6 -0
- package/src/exports/runtime.ts +11 -0
- package/src/ir/ir-node.ts +62 -0
- package/src/ir/namespace.ts +40 -0
- package/src/ir/storage-type.ts +23 -0
- package/src/ir/storage.ts +41 -0
- package/src/meta-builder.ts +101 -0
- package/src/shared/framework-authoring.ts +116 -12
- package/dist/framework-authoring-DGIQbNPt.d.mts.map +0 -1
- package/dist/framework-authoring-DxXcjyJX.mjs.map +0 -1
|
@@ -70,13 +70,52 @@ type AuthoringTypeNamespace = {
|
|
|
70
70
|
type AuthoringFieldNamespace = {
|
|
71
71
|
readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Context surfaced to entity-type factories at call time. Currently a
|
|
75
|
+
* placeholder — sharpened as concrete consumers (enum, namespace, …)
|
|
76
|
+
* discover what the factory actually needs to read (codec lookup,
|
|
77
|
+
* namespace registry, …).
|
|
78
|
+
*/
|
|
79
|
+
interface AuthoringEntityContext {
|
|
80
|
+
readonly family: string;
|
|
81
|
+
readonly target: string;
|
|
82
|
+
}
|
|
83
|
+
interface AuthoringEntityTypeTemplateOutput {
|
|
84
|
+
readonly template: AuthoringTemplateValue;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Default `Input = never` is load-bearing for pack-bag-driven type
|
|
88
|
+
* narrowing. Factory parameter positions are contravariant, so a pack
|
|
89
|
+
* literal declaring `factory: (input: DemoEntityInput) => DemoEntity`
|
|
90
|
+
* is only assignable to the base descriptor's factory shape if the
|
|
91
|
+
* base's input is `never` (the bottom of the contravariant position).
|
|
92
|
+
* The concrete input/output types are recovered at the helper-derivation
|
|
93
|
+
* site via `EntityHelperFunction<Descriptor>`'s conditional inference,
|
|
94
|
+
* which reads them from the pack's `as const` literal factory signature
|
|
95
|
+
* — the base widening does not erase the literal because `satisfies`
|
|
96
|
+
* does not widen the declared type.
|
|
97
|
+
*/
|
|
98
|
+
interface AuthoringEntityTypeFactoryOutput<Input = never, Output = unknown> {
|
|
99
|
+
readonly factory: (input: Input, ctx: AuthoringEntityContext) => Output;
|
|
100
|
+
}
|
|
101
|
+
interface AuthoringEntityTypeDescriptor<Input = never, Output = unknown> {
|
|
102
|
+
readonly kind: 'entity';
|
|
103
|
+
readonly discriminator: string;
|
|
104
|
+
readonly args?: readonly AuthoringArgumentDescriptor[];
|
|
105
|
+
readonly output: AuthoringEntityTypeTemplateOutput | AuthoringEntityTypeFactoryOutput<Input, Output>;
|
|
106
|
+
}
|
|
107
|
+
type AuthoringEntityTypeNamespace = {
|
|
108
|
+
readonly [name: string]: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace;
|
|
109
|
+
};
|
|
73
110
|
interface AuthoringContributions {
|
|
74
111
|
readonly type?: AuthoringTypeNamespace;
|
|
75
112
|
readonly field?: AuthoringFieldNamespace;
|
|
113
|
+
readonly entityTypes?: AuthoringEntityTypeNamespace;
|
|
76
114
|
}
|
|
77
115
|
declare function isAuthoringArgRef(value: unknown): value is AuthoringArgRef;
|
|
78
116
|
declare function isAuthoringTypeConstructorDescriptor(value: unknown): value is AuthoringTypeConstructorDescriptor;
|
|
79
117
|
declare function isAuthoringFieldPresetDescriptor(value: unknown): value is AuthoringFieldPresetDescriptor;
|
|
118
|
+
declare function isAuthoringEntityTypeDescriptor(value: unknown): value is AuthoringEntityTypeDescriptor;
|
|
80
119
|
/**
|
|
81
120
|
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
|
|
82
121
|
*
|
|
@@ -105,7 +144,7 @@ declare function hasRegisteredFieldNamespace(contributions: AuthoringContributio
|
|
|
105
144
|
* `assertNoCrossRegistryCollisions` after merging completes.
|
|
106
145
|
*/
|
|
107
146
|
declare function mergeAuthoringNamespaces(target: Record<string, unknown>, source: Record<string, unknown>, path: readonly string[], leafGuard: (value: unknown) => boolean, label: string): void;
|
|
108
|
-
declare function assertNoCrossRegistryCollisions(typeNamespace: AuthoringTypeNamespace, fieldNamespace: AuthoringFieldNamespace): void;
|
|
147
|
+
declare function assertNoCrossRegistryCollisions(typeNamespace: AuthoringTypeNamespace, fieldNamespace: AuthoringFieldNamespace, entityTypeNamespace?: AuthoringEntityTypeNamespace): void;
|
|
109
148
|
declare function resolveAuthoringTemplateValue(template: AuthoringTemplateValue, args: readonly unknown[]): unknown;
|
|
110
149
|
declare function validateAuthoringHelperArguments(helperPath: string, descriptors: readonly AuthoringArgumentDescriptor[] | undefined, args: readonly unknown[]): void;
|
|
111
150
|
declare function instantiateAuthoringTypeConstructor(descriptor: AuthoringTypeConstructorDescriptor, args: readonly unknown[]): {
|
|
@@ -113,6 +152,7 @@ declare function instantiateAuthoringTypeConstructor(descriptor: AuthoringTypeCo
|
|
|
113
152
|
readonly nativeType: string;
|
|
114
153
|
readonly typeParams?: Record<string, unknown>;
|
|
115
154
|
};
|
|
155
|
+
declare function instantiateAuthoringEntityType(helperPath: string, descriptor: AuthoringEntityTypeDescriptor, args: readonly unknown[], ctx: AuthoringEntityContext): unknown;
|
|
116
156
|
declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPresetDescriptor, args: readonly unknown[]): {
|
|
117
157
|
readonly descriptor: {
|
|
118
158
|
readonly codecId: string;
|
|
@@ -126,5 +166,5 @@ declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPrese
|
|
|
126
166
|
readonly unique: boolean;
|
|
127
167
|
};
|
|
128
168
|
//#endregion
|
|
129
|
-
export {
|
|
130
|
-
//# sourceMappingURL=framework-authoring-
|
|
169
|
+
export { isAuthoringEntityTypeDescriptor as C, resolveAuthoringTemplateValue as D, mergeAuthoringNamespaces as E, validateAuthoringHelperArguments as O, isAuthoringArgRef as S, isAuthoringTypeConstructorDescriptor as T, assertNoCrossRegistryCollisions as _, AuthoringEntityContext as a, instantiateAuthoringFieldPreset as b, AuthoringEntityTypeNamespace as c, AuthoringFieldPresetDescriptor as d, AuthoringFieldPresetOutput as f, AuthoringTypeNamespace as g, AuthoringTypeConstructorDescriptor as h, AuthoringContributions as i, AuthoringEntityTypeTemplateOutput as l, AuthoringTemplateValue as m, AuthoringArgumentDescriptor as n, AuthoringEntityTypeDescriptor as o, AuthoringStorageTypeTemplate as p, AuthoringColumnDefaultTemplate as r, AuthoringEntityTypeFactoryOutput as s, AuthoringArgRef as t, AuthoringFieldNamespace as u, hasRegisteredFieldNamespace as v, isAuthoringFieldPresetDescriptor as w, instantiateAuthoringTypeConstructor as x, instantiateAuthoringEntityType as y };
|
|
170
|
+
//# sourceMappingURL=framework-authoring-Bb_GEnzj.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-authoring-Bb_GEnzj.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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A,CACd,KAAA,YACC,KAAA,IAAS,kCAAA;AAAA,iBAUI,gCAAA,CACd,KAAA,YACC,KAAA,IAAS,8BAAA;AAAA,iBAUI,+BAAA,CACd,KAAA,YACC,KAAA,IAAS,6BAAA;;;;;;;;;iBA6BI,2BAAA,CACd,aAAA,EAAe,sBAAA,cACf,SAAA;;;;;;;;;AA3IF;;;;;;;;;;iBAyKgB,wBAAA,CACd,MAAA,EAAQ,MAAA,mBACR,MAAA,EAAQ,MAAA,mBACR,IAAA,qBACA,SAAA,GAAY,KAAA,uBACZ,KAAA;AAAA,iBAoEc,+BAAA,CACd,aAAA,EAAe,sBAAA,EACf,cAAA,EAAgB,uBAAA,EAChB,mBAAA,GAAqB,4BAAA;AAAA,iBAgCP,6BAAA,CACd,QAAA,EAAU,sBAAA,EACV,IAAA;AAAA,iBAiHc,gCAAA,CACd,UAAA,UACA,WAAA,WAAsB,2BAAA,gBACtB,IAAA;AAAA,iBAmHc,mCAAA,CACd,UAAA,EAAY,kCAAA,EACZ,IAAA;EAAA,SAES,OAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA,GAAa,MAAA;AAAA;AAAA,iBAKR,8BAAA,CACd,UAAA,UACA,UAAA,EAAY,6BAAA,EACZ,IAAA,sBACA,GAAA,EAAK,sBAAA;AAAA,iBA0BS,+BAAA,CACd,UAAA,EAAY,8BAAA,EACZ,IAAA;EAAA,SAES,UAAA;IAAA,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"}
|
|
@@ -17,6 +17,16 @@ function isAuthoringTypeConstructorDescriptor(value) {
|
|
|
17
17
|
function isAuthoringFieldPresetDescriptor(value) {
|
|
18
18
|
return typeof value === "object" && value !== null && value.kind === "fieldPreset" && typeof value.output === "object" && value.output !== null;
|
|
19
19
|
}
|
|
20
|
+
function isAuthoringEntityTypeDescriptor(value) {
|
|
21
|
+
if (typeof value !== "object" || value === null || value.kind !== "entity") return false;
|
|
22
|
+
const discriminator = value.discriminator;
|
|
23
|
+
if (typeof discriminator !== "string" || discriminator.length === 0) return false;
|
|
24
|
+
const output = value.output;
|
|
25
|
+
if (typeof output !== "object" || output === null) return false;
|
|
26
|
+
const factory = output.factory;
|
|
27
|
+
const template = output.template;
|
|
28
|
+
return typeof factory === "function" || template !== void 0;
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
31
|
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
|
|
22
32
|
*
|
|
@@ -83,10 +93,12 @@ function collectAuthoringLeafPaths(namespace, isLeaf, path = []) {
|
|
|
83
93
|
}
|
|
84
94
|
return paths;
|
|
85
95
|
}
|
|
86
|
-
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace) {
|
|
96
|
+
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}) {
|
|
87
97
|
const typePaths = new Set(collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor));
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
const fieldPaths = new Set(collectAuthoringLeafPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
|
|
99
|
+
const entityPaths = new Set(collectAuthoringLeafPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
|
|
100
|
+
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. Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.`);
|
|
101
|
+
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. Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.`);
|
|
90
102
|
}
|
|
91
103
|
function resolveAuthoringTemplateValue(template, args) {
|
|
92
104
|
if (isAuthoringArgRef(template)) {
|
|
@@ -193,6 +205,15 @@ function resolveAuthoringExecutionDefaultsTemplate(template, args) {
|
|
|
193
205
|
function instantiateAuthoringTypeConstructor(descriptor, args) {
|
|
194
206
|
return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
|
|
195
207
|
}
|
|
208
|
+
function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
|
|
209
|
+
if ("factory" in descriptor.output) {
|
|
210
|
+
const input = args[0];
|
|
211
|
+
const factory = descriptor.output.factory;
|
|
212
|
+
return factory(input, ctx);
|
|
213
|
+
}
|
|
214
|
+
validateAuthoringHelperArguments(helperPath, descriptor.args, args);
|
|
215
|
+
return resolveAuthoringTemplateValue(descriptor.output.template, args);
|
|
216
|
+
}
|
|
196
217
|
function instantiateAuthoringFieldPreset(descriptor, args) {
|
|
197
218
|
return {
|
|
198
219
|
descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
|
|
@@ -204,6 +225,6 @@ function instantiateAuthoringFieldPreset(descriptor, args) {
|
|
|
204
225
|
};
|
|
205
226
|
}
|
|
206
227
|
//#endregion
|
|
207
|
-
export {
|
|
228
|
+
export { instantiateAuthoringTypeConstructor as a, isAuthoringFieldPresetDescriptor as c, resolveAuthoringTemplateValue as d, validateAuthoringHelperArguments as f, instantiateAuthoringFieldPreset as i, isAuthoringTypeConstructorDescriptor as l, hasRegisteredFieldNamespace as n, isAuthoringArgRef as o, instantiateAuthoringEntityType as r, isAuthoringEntityTypeDescriptor as s, assertNoCrossRegistryCollisions as t, mergeAuthoringNamespaces as u };
|
|
208
229
|
|
|
209
|
-
//# sourceMappingURL=framework-authoring-
|
|
230
|
+
//# sourceMappingURL=framework-authoring-DcEZ5Lin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-authoring-DcEZ5Lin.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\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 */\nexport interface AuthoringEntityContext {\n readonly family: string;\n readonly target: string;\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\nexport type AuthoringEntityTypeNamespace = {\n readonly [name: string]: AuthoringEntityTypeDescriptor | AuthoringEntityTypeNamespace;\n};\n\nexport interface AuthoringContributions {\n readonly type?: AuthoringTypeNamespace;\n readonly field?: AuthoringFieldNamespace;\n readonly entityTypes?: AuthoringEntityTypeNamespace;\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\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 entityTypeNamespace: AuthoringEntityTypeNamespace = {},\n): void {\n const typePaths = new Set(\n collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor),\n );\n const fieldPaths = new Set(\n collectAuthoringLeafPaths(fieldNamespace, isAuthoringFieldPresetDescriptor),\n );\n const entityPaths = new Set(\n collectAuthoringLeafPaths(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 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. Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.`,\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. Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.`,\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 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":";;;AAwJA,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,MAAM,IAAI,QAAQ,GACnE,OAAO;CAET,IAAI,SAAS,KAAA,MAAc,CAAC,MAAM,QAAQ,KAAK,IAAI,KAAK,MAAM,MAAM,OAAO,MAAM,SAAS,GACxF,OAAO;CAET,OAAO;;AAGT,SAAS,0BAA0B,OAAkD;CACnF,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAgB,qCACd,OAC6C;CAC7C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,qBACvC,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;;AAI/C,SAAgB,iCACd,OACyC;CACzC,OACE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0CACP,UACA,MACgC;CAChC,OAAO;EACL,GAAG,UACD,YACA,SAAS,aAAa,KAAA,IAClB,qCAAqC,YAAY,SAAS,UAAU,KAAK,GACzE,KAAA,EACL;EACD,GAAG,UACD,YACA,SAAS,aAAa,KAAA,IAClB,qCAAqC,YAAY,SAAS,UAAU,KAAK,GACzE,KAAA,EACL;EACF;;AAGH,SAAgB,oCACd,YACA,MAKA;CACA,OAAO,oCAAoC,WAAW,QAAQ,KAAK;;AAGrE,SAAgB,+BACd,YACA,YACA,MACA,KACS;CAOT,IAAI,aAAa,WAAW,QAAQ;EAClC,MAAM,QAAQ,KAAK;EAOnB,MAAM,UAAU,WAAW,OAAO;EAIlC,OAAO,QAAQ,OAAO,IAAI;;CAE5B,iCAAiC,YAAY,WAAW,MAAM,KAAK;CACnE,OAAO,8BAA8B,WAAW,OAAO,UAAU,KAAK;;AAGxE,SAAgB,gCACd,YACA,MAYA;CACA,OAAO;EACL,YAAY,oCAAoC,WAAW,QAAQ,KAAK;EACxE,UAAU,WAAW,OAAO,YAAY;EACxC,GAAG,UACD,WACA,WAAW,OAAO,YAAY,KAAA,IAC1B,sCAAsC,WAAW,OAAO,SAAS,KAAK,GACtE,KAAA,EACL;EACD,GAAG,UACD,qBACA,WAAW,OAAO,sBAAsB,KAAA,IACpC,0CAA0C,WAAW,OAAO,mBAAmB,KAAK,GACpF,KAAA,EACL;EACD,IAAI,WAAW,OAAO,MAAM;EAC5B,QAAQ,WAAW,OAAO,UAAU;EACrC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as AuthoringContributions } from "./framework-authoring-
|
|
1
|
+
import { i as AuthoringContributions } from "./framework-authoring-Bb_GEnzj.mjs";
|
|
2
2
|
import { r as AnyCodecDescriptor } from "./codec-DcjlJbcO.mjs";
|
|
3
3
|
import { t as TypesImportSpec } from "./types-import-spec-BxI5cSQy.mjs";
|
|
4
4
|
import { ColumnDefault, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
|
|
@@ -408,4 +408,4 @@ interface ExtensionInstance<TFamilyId extends string, TTargetId extends string>
|
|
|
408
408
|
}
|
|
409
409
|
//#endregion
|
|
410
410
|
export { LoweredDefaultResult as A, ControlMutationDefaultEntry as C, DefaultFunctionLoweringHandler as D, DefaultFunctionLoweringContext as E, SourceSpan as F, MutationDefaultGeneratorDescriptor as M, ParsedDefaultFunctionCall as N, DefaultFunctionRegistry as O, SourceDiagnostic as P, checkContractComponentRequirements as S, ControlMutationDefaults as T, PackRefBase as _, ComponentMetadata as a, TargetInstance as b, DriverDescriptor as c, ExtensionDescriptor as d, ExtensionInstance as f, FamilyPackRef as g, FamilyInstance as h, ComponentDescriptor as i, LoweredDefaultValue as j, DefaultFunctionRegistryEntry as k, DriverInstance as l, FamilyDescriptor as m, AdapterInstance as n, ContractComponentRequirementsCheckInput as o, ExtensionPackRef as p, AdapterPackRef as r, ContractComponentRequirementsCheckResult as s, AdapterDescriptor as t, DriverPackRef as u, TargetBoundComponentDescriptor as v, ControlMutationDefaultRegistry as w, TargetPackRef as x, TargetDescriptor as y };
|
|
411
|
-
//# sourceMappingURL=framework-components-
|
|
411
|
+
//# sourceMappingURL=framework-components-DQRRmQOH.d.mts.map
|
package/dist/{framework-components-DwkHnl-e.d.mts.map → framework-components-DQRRmQOH.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-components-
|
|
1
|
+
{"version":3,"file":"framework-components-DQRRmQOH.d.mts","names":[],"sources":["../src/shared/mutation-default-types.ts","../src/shared/framework-components.ts"],"mappings":";;;;;;UAMU,cAAA;EAAA,SACC,MAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;AAAA;AAAA,UAGM,UAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,GAAA,EAAK,cAAA;AAAA;AAAA,UAGC,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA,GAA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EAAU,SAAA;AAAA;;;;;;;;;;AAxNrB;;;;;;;;;;;;;AAMA;;;;UA+OiB,mBAAA,6DACP,mBAAA;EA/OR;EAAA,SAiPS,QAAA,EAAU,SAAA;EAhPsB;EAAA,SAmPhC,QAAA,EAAU,SAAA;AAAA;;KAIT,8BAAA,uDACR,gBAAA,CAAiB,SAAA,EAAW,SAAA,IAC5B,iBAAA,CAAkB,SAAA,EAAW,SAAA,IAC7B,gBAAA,CAAiB,SAAA,EAAW,SAAA,IAC5B,mBAAA,CAAoB,SAAA,EAAW,SAAA;AAAA,UAElB,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,eAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,cAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAA;AAAA;AAAA,UAGJ,iBAAA;EAAA,SACN,QAAA,EAAU,SAAA;EAAA,SACV,QAAA,EAAU,SAAA;AAAA"}
|
package/dist/ir.d.mts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
//#region src/ir/ir-node.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Framework-level IR alphabet.
|
|
4
|
+
*
|
|
5
|
+
* The framework's contribution to Contract IR / Schema IR is a common
|
|
6
|
+
* root for the IR class hierarchy and a freeze affordance. Family
|
|
7
|
+
* abstract bases (e.g. `SqlNode`, `MongoSchemaIRNode`) refine the alphabet
|
|
8
|
+
* for their family shape; targets ship the concrete classes.
|
|
9
|
+
*
|
|
10
|
+
* `kind` is an optional discriminator on the base. Families and leaves
|
|
11
|
+
* that benefit from discriminated-union dispatch declare their own
|
|
12
|
+
* literal `kind` at the level that earns it — Mongo leaves carry
|
|
13
|
+
* per-class literals (`readonly kind = 'mongo-collection' as const`)
|
|
14
|
+
* because Mongo IR has polymorphic walkers; SQL declares a single
|
|
15
|
+
* family-level `kind = 'sql'` on `SqlNode` because SQL IR has no
|
|
16
|
+
* polymorphic dispatch today. No framework consumer dispatches on
|
|
17
|
+
* `IRNode.kind` at the BASE type — every dispatch site narrows
|
|
18
|
+
* through a union of leaves where each leaf carries a literal kind, so
|
|
19
|
+
* requiring `kind` at the base would be unearned. Future leaves that
|
|
20
|
+
* earn polymorphic dispatch override with a required literal at that
|
|
21
|
+
* leaf (e.g. `override readonly kind = 'postgres-enum' as const`).
|
|
22
|
+
*
|
|
23
|
+
* `IRNodeBase` carries no methods: the freeze-and-assign affordance
|
|
24
|
+
* lives in the free `freezeNode` helper below. Keeping `freezeNode` out
|
|
25
|
+
* of the class type means an emitted contract literal type
|
|
26
|
+
* (`{ readonly kind: 'mongo-collection', ... }` or an unkeyed literal
|
|
27
|
+
* like `{ nativeType, codecId, nullable }`) is structurally assignable
|
|
28
|
+
* to its class type — a `protected freeze()` instance method would
|
|
29
|
+
* otherwise leak into the public type surface and require the literal
|
|
30
|
+
* to carry it too.
|
|
31
|
+
*
|
|
32
|
+
* Subclasses construct fields then call `freezeNode(this)` to seal the
|
|
33
|
+
* instance. Frozen instances + plain readonly fields keep IR nodes
|
|
34
|
+
* JSON-clean by construction, so `JSON.stringify(node)` produces canonical
|
|
35
|
+
* JSON without a `toJSON()` method. The `ContractSerializer` SPI handles
|
|
36
|
+
* round-trip from canonical JSON back to typed class instances.
|
|
37
|
+
*
|
|
38
|
+
* The name (`IRNode` / `IRNodeBase`) reflects the dual-hierarchy reality:
|
|
39
|
+
* this base is the common root for both Contract IR and Schema IR class
|
|
40
|
+
* hierarchies, not a Schema-IR-specific alphabet.
|
|
41
|
+
*/
|
|
42
|
+
interface IRNode {
|
|
43
|
+
readonly kind?: string;
|
|
44
|
+
}
|
|
45
|
+
declare abstract class IRNodeBase implements IRNode {
|
|
46
|
+
abstract readonly kind?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Seal an IR class instance after its constructor has assigned all
|
|
50
|
+
* fields. The free-helper form (rather than a `protected freeze()`
|
|
51
|
+
* instance method) keeps the class type structurally narrow so emitted
|
|
52
|
+
* contract literal types remain assignable to their class types.
|
|
53
|
+
*
|
|
54
|
+
* The helper name stays `freezeNode` — it operates on IR nodes
|
|
55
|
+
* regardless of root naming.
|
|
56
|
+
*/
|
|
57
|
+
declare function freezeNode<T extends IRNode>(node: T): T;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/ir/namespace.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Reserved sentinel namespace id meaning
|
|
62
|
+
* "no namespace bound at authoring time; resolve from connection context".
|
|
63
|
+
*
|
|
64
|
+
* Materialised target-side as a singleton subclass of the target's
|
|
65
|
+
* `NamespaceBase` concretion that overrides the namespace's
|
|
66
|
+
* qualifier-emission methods to elide the prefix entirely. Call sites
|
|
67
|
+
* stay polymorphic and never branch on `id === UNSPECIFIED_NAMESPACE_ID`
|
|
68
|
+
* — the singleton's overrides drop the qualifier so emitted SQL / Mongo
|
|
69
|
+
* commands look unqualified.
|
|
70
|
+
*
|
|
71
|
+
* Encoded as an exported const (rather than scattered string literals)
|
|
72
|
+
* so the sentinel-id invariant is single-sourced: any production-source
|
|
73
|
+
* site that constructs an unspecified-namespace singleton imports this
|
|
74
|
+
* constant.
|
|
75
|
+
*/
|
|
76
|
+
declare const UNSPECIFIED_NAMESPACE_ID: "__unspecified__";
|
|
77
|
+
/**
|
|
78
|
+
* Framework-level building block for a "namespace" — the database-level
|
|
79
|
+
* grouping under which storage objects (tables, collections, enums, …)
|
|
80
|
+
* reside. Each target's namespace concretion maps the framework concept to
|
|
81
|
+
* a target-native binding:
|
|
82
|
+
*
|
|
83
|
+
* - Postgres: a schema (`CREATE SCHEMA …`); rendered as `"<schema>"`.
|
|
84
|
+
* - SQLite: the singleton `UNSPECIFIED_NAMESPACE_ID`; emitted SQL has no qualifier.
|
|
85
|
+
* - Mongo: the connection's `db` field; addressed as a database name.
|
|
86
|
+
*
|
|
87
|
+
* See `UNSPECIFIED_NAMESPACE_ID` above for the sentinel id and the
|
|
88
|
+
* singleton-subclass pattern that materialises it.
|
|
89
|
+
*/
|
|
90
|
+
interface Namespace extends IRNode {
|
|
91
|
+
readonly id: string;
|
|
92
|
+
}
|
|
93
|
+
declare abstract class NamespaceBase extends IRNodeBase implements Namespace {
|
|
94
|
+
abstract readonly id: string;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/ir/storage.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* Framework-level promise that every Contract IR / Schema IR carries a
|
|
100
|
+
* collection of namespaces keyed by namespace id. Family storage
|
|
101
|
+
* concretions (`SqlStorage`, `MongoStorage`) refine the shape with
|
|
102
|
+
* family-specific fields (tables, collections, enums, …); target
|
|
103
|
+
* concretions add target fields where the family vocabulary doesn't
|
|
104
|
+
* reach.
|
|
105
|
+
*
|
|
106
|
+
* Keeping `namespaces` at the framework layer enforces that every storage
|
|
107
|
+
* object — across any target — is namespace-scoped. The framework can
|
|
108
|
+
* therefore walk the namespace map without knowing the family alphabet, and
|
|
109
|
+
* the `(namespace.id, name)` keying that the verifier and planner depend on
|
|
110
|
+
* is honest at every layer.
|
|
111
|
+
*
|
|
112
|
+
* Extends `IRNode` so the framework's IR-walking surfaces (verifiers,
|
|
113
|
+
* serializers) can dispatch on `Storage`-typed slots through the same
|
|
114
|
+
* IR-node alphabet as every other node — the structural dual already
|
|
115
|
+
* holds in code (every concrete storage class extends an IR-node base);
|
|
116
|
+
* the interface promotion makes the typing honest.
|
|
117
|
+
*
|
|
118
|
+
* **Persisted envelope shape is target-owned, not framework-promised.**
|
|
119
|
+
* Whether the `namespaces` map appears in the on-disk JSON envelope is
|
|
120
|
+
* a per-target decision made by `ContractSerializer.serializeContract`.
|
|
121
|
+
* Some targets emit a JSON-clean namespace shape that round-trips
|
|
122
|
+
* through `JSON.stringify` cleanly (SQL today via the family-layer
|
|
123
|
+
* identity serializer); others ship runtime-only fields on their
|
|
124
|
+
* namespace concretions and override `serializeContract` to strip
|
|
125
|
+
* them (Mongo). Future open (F16): extend the per-target
|
|
126
|
+
* `ContractSerializer` integration-test surface with an explicit
|
|
127
|
+
* envelope-shape assertion for each target, so the strip-vs-pass-through
|
|
128
|
+
* choice is locked at test time rather than implied by the override
|
|
129
|
+
* presence/absence. Earned by PR2's per-target namespace lift, when
|
|
130
|
+
* `PostgresSchema` / `SqliteUnspecifiedDatabase` start carrying
|
|
131
|
+
* target-specific fields.
|
|
132
|
+
*/
|
|
133
|
+
interface Storage extends IRNode {
|
|
134
|
+
readonly namespaces: Readonly<Record<string, Namespace>>;
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/ir/storage-type.d.ts
|
|
138
|
+
/**
|
|
139
|
+
* Framework-level alphabet for entries in a storage `types` slot.
|
|
140
|
+
*
|
|
141
|
+
* The slot is polymorphic at the framework level: a family or target can
|
|
142
|
+
* persist either a JSON-clean codec-triple object literal (carrying
|
|
143
|
+
* `kind: 'codec-instance'`) or a class-instance IR node with a narrower
|
|
144
|
+
* kind discriminator (e.g. `'postgres-enum'`). Hydration walkers,
|
|
145
|
+
* verifiers, and planners dispatch on the `kind` literal to recover the
|
|
146
|
+
* precise variant.
|
|
147
|
+
*
|
|
148
|
+
* The `kind` field is required at this layer (in contrast with
|
|
149
|
+
* `IRNode.kind` which is optional) because the slot's downstream
|
|
150
|
+
* consumers dispatch on it — without a guaranteed discriminator the
|
|
151
|
+
* polymorphic walk cannot pick the right reader. Concrete variants
|
|
152
|
+
* narrow `kind` to their literal and add their own field set;
|
|
153
|
+
* downstream consumers use `kind`-discriminator helpers to recover
|
|
154
|
+
* the precise shape.
|
|
155
|
+
*/
|
|
156
|
+
interface StorageType extends IRNode {
|
|
157
|
+
readonly kind: string;
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
export { type IRNode, IRNodeBase, type Namespace, NamespaceBase, type Storage, type StorageType, UNSPECIFIED_NAMESPACE_ID, freezeNode };
|
|
161
|
+
//# sourceMappingURL=ir.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.d.mts","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts","../src/ir/storage.ts","../src/ir/storage-type.ts"],"mappings":";;AAyCA;;;;;AAIA;;;;;AAaA;;;;;;;;;;;;;;;;;;ACxCA;;;;;AAeA;;;;;AAIA;UDIiB,MAAA;EAAA,SACN,IAAA;AAAA;AAAA,uBAGW,UAAA,YAAsB,MAAA;EAAA,kBACxB,IAAA;AAAA;;;;;;AERpB;;;;iBFoBgB,UAAA,WAAqB,MAAA,CAAA,CAAQ,IAAA,EAAM,CAAA,GAAI,CAAA;;;AAjBvD;;;;;AAIA;;;;;AAaA;;;;;;AAjBA,cCvBa,wBAAA;;;;;;;;;;;;AAAb;;UAeiB,SAAA,SAAkB,MAAA;EAAA,SACxB,EAAA;AAAA;AAAA,uBAGW,aAAA,SAAsB,UAAA,YAAsB,SAAA;EAAA,kBAC9C,EAAA;AAAA;;;;;;;ADOpB;;;;;AAaA;;;;;;;;;;;;;;;;;;ACxCA;;;;;AAeA;;;UCKiB,OAAA,SAAgB,MAAA;EAAA,SACtB,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,SAAA;AAAA;;;AFE/C;;;;;AAIA;;;;;AAaA;;;;;;;;AAjBA,UGrBiB,WAAA,SAAoB,MAAA;EAAA,SAC1B,IAAA;AAAA"}
|
package/dist/ir.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/ir/ir-node.ts
|
|
2
|
+
var IRNodeBase = class {};
|
|
3
|
+
/**
|
|
4
|
+
* Seal an IR class instance after its constructor has assigned all
|
|
5
|
+
* fields. The free-helper form (rather than a `protected freeze()`
|
|
6
|
+
* instance method) keeps the class type structurally narrow so emitted
|
|
7
|
+
* contract literal types remain assignable to their class types.
|
|
8
|
+
*
|
|
9
|
+
* The helper name stays `freezeNode` — it operates on IR nodes
|
|
10
|
+
* regardless of root naming.
|
|
11
|
+
*/
|
|
12
|
+
function freezeNode(node) {
|
|
13
|
+
Object.freeze(node);
|
|
14
|
+
return node;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/ir/namespace.ts
|
|
18
|
+
/**
|
|
19
|
+
* Reserved sentinel namespace id meaning
|
|
20
|
+
* "no namespace bound at authoring time; resolve from connection context".
|
|
21
|
+
*
|
|
22
|
+
* Materialised target-side as a singleton subclass of the target's
|
|
23
|
+
* `NamespaceBase` concretion that overrides the namespace's
|
|
24
|
+
* qualifier-emission methods to elide the prefix entirely. Call sites
|
|
25
|
+
* stay polymorphic and never branch on `id === UNSPECIFIED_NAMESPACE_ID`
|
|
26
|
+
* — the singleton's overrides drop the qualifier so emitted SQL / Mongo
|
|
27
|
+
* commands look unqualified.
|
|
28
|
+
*
|
|
29
|
+
* Encoded as an exported const (rather than scattered string literals)
|
|
30
|
+
* so the sentinel-id invariant is single-sourced: any production-source
|
|
31
|
+
* site that constructs an unspecified-namespace singleton imports this
|
|
32
|
+
* constant.
|
|
33
|
+
*/
|
|
34
|
+
const UNSPECIFIED_NAMESPACE_ID = "__unspecified__";
|
|
35
|
+
var NamespaceBase = class extends IRNodeBase {};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { IRNodeBase, NamespaceBase, UNSPECIFIED_NAMESPACE_ID, freezeNode };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=ir.mjs.map
|
package/dist/ir.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.mjs","names":[],"sources":["../src/ir/ir-node.ts","../src/ir/namespace.ts"],"sourcesContent":["/**\n * Framework-level IR alphabet.\n *\n * The framework's contribution to Contract IR / Schema IR is a common\n * root for the IR class hierarchy and a freeze affordance. Family\n * abstract bases (e.g. `SqlNode`, `MongoSchemaIRNode`) refine the alphabet\n * for their family shape; targets ship the concrete classes.\n *\n * `kind` is an optional discriminator on the base. Families and leaves\n * that benefit from discriminated-union dispatch declare their own\n * literal `kind` at the level that earns it — Mongo leaves carry\n * per-class literals (`readonly kind = 'mongo-collection' as const`)\n * because Mongo IR has polymorphic walkers; SQL declares a single\n * family-level `kind = 'sql'` on `SqlNode` because SQL IR has no\n * polymorphic dispatch today. No framework consumer dispatches on\n * `IRNode.kind` at the BASE type — every dispatch site narrows\n * through a union of leaves where each leaf carries a literal kind, so\n * requiring `kind` at the base would be unearned. Future leaves that\n * earn polymorphic dispatch override with a required literal at that\n * leaf (e.g. `override readonly kind = 'postgres-enum' as const`).\n *\n * `IRNodeBase` carries no methods: the freeze-and-assign affordance\n * lives in the free `freezeNode` helper below. Keeping `freezeNode` out\n * of the class type means an emitted contract literal type\n * (`{ readonly kind: 'mongo-collection', ... }` or an unkeyed literal\n * like `{ nativeType, codecId, nullable }`) is structurally assignable\n * to its class type — a `protected freeze()` instance method would\n * otherwise leak into the public type surface and require the literal\n * to carry it too.\n *\n * Subclasses construct fields then call `freezeNode(this)` to seal the\n * instance. Frozen instances + plain readonly fields keep IR nodes\n * JSON-clean by construction, so `JSON.stringify(node)` produces canonical\n * JSON without a `toJSON()` method. The `ContractSerializer` SPI handles\n * round-trip from canonical JSON back to typed class instances.\n *\n * The name (`IRNode` / `IRNodeBase`) reflects the dual-hierarchy reality:\n * this base is the common root for both Contract IR and Schema IR class\n * hierarchies, not a Schema-IR-specific alphabet.\n */\n\nexport interface IRNode {\n readonly kind?: string;\n}\n\nexport abstract class IRNodeBase implements IRNode {\n abstract readonly kind?: string;\n}\n\n/**\n * Seal an IR class instance after its constructor has assigned all\n * fields. The free-helper form (rather than a `protected freeze()`\n * instance method) keeps the class type structurally narrow so emitted\n * contract literal types remain assignable to their class types.\n *\n * The helper name stays `freezeNode` — it operates on IR nodes\n * regardless of root naming.\n */\nexport function freezeNode<T extends IRNode>(node: T): T {\n Object.freeze(node);\n return node;\n}\n","import { type IRNode, IRNodeBase } from './ir-node';\n\n/**\n * Reserved sentinel namespace id meaning\n * \"no namespace bound at authoring time; resolve from connection context\".\n *\n * Materialised target-side as a singleton subclass of the target's\n * `NamespaceBase` concretion that overrides the namespace's\n * qualifier-emission methods to elide the prefix entirely. Call sites\n * stay polymorphic and never branch on `id === UNSPECIFIED_NAMESPACE_ID`\n * — the singleton's overrides drop the qualifier so emitted SQL / Mongo\n * commands look unqualified.\n *\n * Encoded as an exported const (rather than scattered string literals)\n * so the sentinel-id invariant is single-sourced: any production-source\n * site that constructs an unspecified-namespace singleton imports this\n * constant.\n */\nexport const UNSPECIFIED_NAMESPACE_ID = '__unspecified__' as const;\n\n/**\n * Framework-level building block for a \"namespace\" — the database-level\n * grouping under which storage objects (tables, collections, enums, …)\n * reside. Each target's namespace concretion maps the framework concept to\n * a target-native binding:\n *\n * - Postgres: a schema (`CREATE SCHEMA …`); rendered as `\"<schema>\"`.\n * - SQLite: the singleton `UNSPECIFIED_NAMESPACE_ID`; emitted SQL has no qualifier.\n * - Mongo: the connection's `db` field; addressed as a database name.\n *\n * See `UNSPECIFIED_NAMESPACE_ID` above for the sentinel id and the\n * singleton-subclass pattern that materialises it.\n */\nexport interface Namespace extends IRNode {\n readonly id: string;\n}\n\nexport abstract class NamespaceBase extends IRNodeBase implements Namespace {\n abstract readonly id: string;\n}\n"],"mappings":";AA6CA,IAAsB,aAAtB,MAAmD;;;;;;;;;;AAanD,SAAgB,WAA6B,MAAY;CACvD,OAAO,OAAO,KAAK;CACnB,OAAO;;;;;;;;;;;;;;;;;;;;AC1CT,MAAa,2BAA2B;AAmBxC,IAAsB,gBAAtB,cAA4C,WAAgC"}
|