@prisma-next/framework-components 0.5.0-dev.8 → 0.5.0-dev.80
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/README.md +53 -4
- package/dist/authoring.d.mts +2 -2
- package/dist/authoring.mjs +2 -122
- package/dist/codec-m_-FAyQn.d.mts +168 -0
- package/dist/codec-m_-FAyQn.d.mts.map +1 -0
- package/dist/codec.d.mts +48 -2
- package/dist/codec.d.mts.map +1 -0
- package/dist/codec.mjs +67 -4
- package/dist/codec.mjs.map +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs +2 -3
- package/dist/control.d.mts +420 -74
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +83 -49
- package/dist/control.mjs.map +1 -1
- package/dist/emission-types-BKa4bR9m.d.mts +39 -0
- package/dist/emission-types-BKa4bR9m.d.mts.map +1 -0
- package/dist/emission.d.mts +2 -2
- package/dist/emission.mjs +1 -1
- package/dist/execution.d.mts +5 -5
- package/dist/execution.d.mts.map +1 -1
- package/dist/execution.mjs +4 -6
- package/dist/execution.mjs.map +1 -1
- package/dist/{framework-authoring-D1-JZ37B.d.mts → framework-authoring-DGIQbNPt.d.mts} +43 -12
- package/dist/framework-authoring-DGIQbNPt.d.mts.map +1 -0
- package/dist/framework-authoring-DxXcjyJX.mjs +209 -0
- package/dist/framework-authoring-DxXcjyJX.mjs.map +1 -0
- package/dist/{framework-components-DFZMi2h7.d.mts → framework-components-BGo7HsbL.d.mts} +45 -55
- package/dist/framework-components-BGo7HsbL.d.mts.map +1 -0
- package/dist/{framework-components-C8ZhSwXe.mjs → framework-components-FdqmlGUj.mjs} +3 -3
- package/dist/framework-components-FdqmlGUj.mjs.map +1 -0
- package/dist/psl-ast-Ckn_G-jv.d.mts +159 -0
- package/dist/psl-ast-Ckn_G-jv.d.mts.map +1 -0
- package/dist/psl-ast.d.mts +2 -0
- package/dist/psl-ast.mjs +1 -0
- package/dist/runtime.d.mts +395 -19
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +256 -7
- package/dist/runtime.mjs.map +1 -1
- package/dist/{types-import-spec-C4sc7wbb.d.mts → types-import-spec-BxI5cSQy.d.mts} +2 -2
- package/dist/types-import-spec-BxI5cSQy.d.mts.map +1 -0
- package/package.json +10 -6
- package/src/control/control-capabilities.ts +96 -0
- package/src/{control-descriptors.ts → control/control-descriptors.ts} +7 -7
- package/src/{control-instances.ts → control/control-instances.ts} +52 -6
- package/src/{control-migration-types.ts → control/control-migration-types.ts} +251 -63
- package/src/control/control-operation-preview.ts +23 -0
- package/src/control/control-spaces.ts +82 -0
- package/src/{control-stack.ts → control/control-stack.ts} +77 -94
- package/src/control/emission-types.ts +49 -0
- package/src/control/psl-ast.ts +193 -0
- package/src/{execution-descriptors.ts → execution/execution-descriptors.ts} +7 -7
- package/src/{execution-instances.ts → execution/execution-instances.ts} +1 -1
- package/src/{execution-requirements.ts → execution/execution-requirements.ts} +1 -1
- package/src/execution/query-plan.ts +53 -0
- package/src/execution/race-against-abort.ts +89 -0
- package/src/execution/run-with-middleware.ts +153 -0
- package/src/execution/runtime-core.ts +133 -0
- package/src/execution/runtime-error.ts +94 -0
- package/src/execution/runtime-middleware.ts +235 -0
- package/src/exports/authoring.ts +5 -2
- package/src/exports/codec.ts +27 -2
- package/src/exports/components.ts +2 -2
- package/src/exports/control.ts +41 -13
- package/src/exports/emission.ts +2 -2
- package/src/exports/execution.ts +5 -5
- package/src/exports/psl-ast.ts +1 -0
- package/src/exports/runtime.ts +18 -5
- package/src/shared/codec-descriptor.ts +87 -0
- package/src/shared/codec-types.ts +79 -0
- package/src/shared/codec.ts +80 -0
- package/src/shared/column-spec.ts +83 -0
- package/src/{framework-authoring.ts → shared/framework-authoring.ts} +210 -23
- package/src/{framework-components.ts → shared/framework-components.ts} +22 -48
- package/src/{mutation-default-types.ts → shared/mutation-default-types.ts} +22 -2
- package/dist/authoring.mjs.map +0 -1
- package/dist/codec-types-DQ1Agjom.d.mts +0 -58
- package/dist/codec-types-DQ1Agjom.d.mts.map +0 -1
- package/dist/emission-types-BPAALJbF.d.mts +0 -24
- package/dist/emission-types-BPAALJbF.d.mts.map +0 -1
- package/dist/framework-authoring-D1-JZ37B.d.mts.map +0 -1
- package/dist/framework-components-C8ZhSwXe.mjs.map +0 -1
- package/dist/framework-components-DFZMi2h7.d.mts.map +0 -1
- package/dist/types-import-spec-C4sc7wbb.d.mts.map +0 -1
- package/src/codec-types.ts +0 -64
- package/src/control-capabilities.ts +0 -34
- package/src/emission-types.ts +0 -28
- package/src/runtime-error.ts +0 -55
- package/src/runtime-middleware.ts +0 -83
- /package/src/{control-result-types.ts → control/control-result-types.ts} +0 -0
- /package/src/{control-schema-view.ts → control/control-schema-view.ts} +0 -0
- /package/src/{async-iterable-result.ts → execution/async-iterable-result.ts} +0 -0
- /package/src/{execution-stack.ts → execution/execution-stack.ts} +0 -0
- /package/src/{types-import-spec.ts → shared/types-import-spec.ts} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { ColumnDefault, ExecutionMutationDefaultPhases } from "@prisma-next/contract/types";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/framework-authoring.d.ts
|
|
2
4
|
type AuthoringArgRef = {
|
|
3
5
|
readonly kind: 'arg';
|
|
4
6
|
readonly index: number;
|
|
@@ -14,6 +16,8 @@ interface AuthoringArgumentDescriptorCommon {
|
|
|
14
16
|
}
|
|
15
17
|
type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon & ({
|
|
16
18
|
readonly kind: 'string';
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'boolean';
|
|
17
21
|
} | {
|
|
18
22
|
readonly kind: 'number';
|
|
19
23
|
readonly integer?: boolean;
|
|
@@ -44,10 +48,14 @@ interface AuthoringColumnDefaultTemplateFunction {
|
|
|
44
48
|
readonly expression: AuthoringTemplateValue;
|
|
45
49
|
}
|
|
46
50
|
type AuthoringColumnDefaultTemplate = AuthoringColumnDefaultTemplateLiteral | AuthoringColumnDefaultTemplateFunction;
|
|
51
|
+
interface AuthoringExecutionDefaultsTemplate {
|
|
52
|
+
readonly onCreate?: AuthoringTemplateValue;
|
|
53
|
+
readonly onUpdate?: AuthoringTemplateValue;
|
|
54
|
+
}
|
|
47
55
|
interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {
|
|
48
56
|
readonly nullable?: boolean;
|
|
49
57
|
readonly default?: AuthoringColumnDefaultTemplate;
|
|
50
|
-
readonly
|
|
58
|
+
readonly executionDefaults?: AuthoringExecutionDefaultsTemplate;
|
|
51
59
|
readonly id?: boolean;
|
|
52
60
|
readonly unique?: boolean;
|
|
53
61
|
}
|
|
@@ -69,6 +77,35 @@ interface AuthoringContributions {
|
|
|
69
77
|
declare function isAuthoringArgRef(value: unknown): value is AuthoringArgRef;
|
|
70
78
|
declare function isAuthoringTypeConstructorDescriptor(value: unknown): value is AuthoringTypeConstructorDescriptor;
|
|
71
79
|
declare function isAuthoringFieldPresetDescriptor(value: unknown): value is AuthoringFieldPresetDescriptor;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
|
|
82
|
+
*
|
|
83
|
+
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
|
|
84
|
+
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
|
|
85
|
+
* registration must NOT be treated as a "namespace" with sub-paths. Callers
|
|
86
|
+
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
|
|
87
|
+
*/
|
|
88
|
+
declare function hasRegisteredFieldNamespace(contributions: AuthoringContributions | undefined, namespace: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Merges `source` into `target` recursively at the descriptor-namespace
|
|
91
|
+
* level. `leafGuard` decides which values are descriptors (terminal
|
|
92
|
+
* merge points; same-path registrations across components are reported
|
|
93
|
+
* as duplicates) versus sub-namespaces (recursion targets).
|
|
94
|
+
*
|
|
95
|
+
* Path segments are validated against prototype-pollution names
|
|
96
|
+
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
|
|
97
|
+
* recognized leaf nor a plain object — e.g. a malformed descriptor
|
|
98
|
+
* where the canonical leaf guard rejected it for missing `output` —
|
|
99
|
+
* is reported as an invalid contribution rather than recursed into,
|
|
100
|
+
* which would either silently mangle state or infinite-loop on
|
|
101
|
+
* primitive properties.
|
|
102
|
+
*
|
|
103
|
+
* Within-registry duplicate detection is this walker's job;
|
|
104
|
+
* cross-registry detection runs separately via
|
|
105
|
+
* `assertNoCrossRegistryCollisions` after merging completes.
|
|
106
|
+
*/
|
|
107
|
+
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;
|
|
72
109
|
declare function resolveAuthoringTemplateValue(template: AuthoringTemplateValue, args: readonly unknown[]): unknown;
|
|
73
110
|
declare function validateAuthoringHelperArguments(helperPath: string, descriptors: readonly AuthoringArgumentDescriptor[] | undefined, args: readonly unknown[]): void;
|
|
74
111
|
declare function instantiateAuthoringTypeConstructor(descriptor: AuthoringTypeConstructorDescriptor, args: readonly unknown[]): {
|
|
@@ -83,17 +120,11 @@ declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPrese
|
|
|
83
120
|
readonly typeParams?: Record<string, unknown>;
|
|
84
121
|
};
|
|
85
122
|
readonly nullable: boolean;
|
|
86
|
-
readonly default?:
|
|
87
|
-
|
|
88
|
-
readonly value: unknown;
|
|
89
|
-
} | {
|
|
90
|
-
readonly kind: 'function';
|
|
91
|
-
readonly expression: string;
|
|
92
|
-
};
|
|
93
|
-
readonly executionDefault?: unknown;
|
|
123
|
+
readonly default?: ColumnDefault;
|
|
124
|
+
readonly executionDefaults?: ExecutionMutationDefaultPhases;
|
|
94
125
|
readonly id: boolean;
|
|
95
126
|
readonly unique: boolean;
|
|
96
127
|
};
|
|
97
128
|
//#endregion
|
|
98
|
-
export {
|
|
99
|
-
//# sourceMappingURL=framework-authoring-
|
|
129
|
+
export { isAuthoringFieldPresetDescriptor as _, AuthoringFieldNamespace as a, resolveAuthoringTemplateValue as b, AuthoringStorageTypeTemplate as c, AuthoringTypeNamespace as d, assertNoCrossRegistryCollisions as f, isAuthoringArgRef as g, instantiateAuthoringTypeConstructor as h, AuthoringContributions as i, AuthoringTemplateValue as l, instantiateAuthoringFieldPreset as m, AuthoringArgumentDescriptor as n, AuthoringFieldPresetDescriptor as o, hasRegisteredFieldNamespace as p, AuthoringColumnDefaultTemplate as r, AuthoringFieldPresetOutput as s, AuthoringArgRef as t, AuthoringTypeConstructorDescriptor as u, isAuthoringTypeConstructorDescriptor as v, validateAuthoringHelperArguments as x, mergeAuthoringNamespaces as y };
|
|
130
|
+
//# sourceMappingURL=framework-authoring-DGIQbNPt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,OAA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B,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;AAAA,iBA2BF,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,+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"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { isColumnDefaultLiteralInputValue, isExecutionMutationDefaultValue } from "@prisma-next/contract/types";
|
|
2
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
3
|
+
//#region src/shared/framework-authoring.ts
|
|
4
|
+
function isAuthoringArgRef(value) {
|
|
5
|
+
if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
|
|
6
|
+
const { index, path } = value;
|
|
7
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
|
|
8
|
+
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
function isAuthoringTemplateRecord(value) {
|
|
12
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function isAuthoringTypeConstructorDescriptor(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && value.kind === "typeConstructor" && typeof value.output === "object" && value.output !== null;
|
|
16
|
+
}
|
|
17
|
+
function isAuthoringFieldPresetDescriptor(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && value.kind === "fieldPreset" && typeof value.output === "object" && value.output !== null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
|
|
22
|
+
*
|
|
23
|
+
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
|
|
24
|
+
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
|
|
25
|
+
* registration must NOT be treated as a "namespace" with sub-paths. Callers
|
|
26
|
+
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
|
|
27
|
+
*/
|
|
28
|
+
function hasRegisteredFieldNamespace(contributions, namespace) {
|
|
29
|
+
if (contributions?.field === void 0 || !Object.hasOwn(contributions.field, namespace)) return false;
|
|
30
|
+
return !isAuthoringFieldPresetDescriptor(contributions.field[namespace]);
|
|
31
|
+
}
|
|
32
|
+
function isPlainNamespaceObject(value) {
|
|
33
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Merges `source` into `target` recursively at the descriptor-namespace
|
|
37
|
+
* level. `leafGuard` decides which values are descriptors (terminal
|
|
38
|
+
* merge points; same-path registrations across components are reported
|
|
39
|
+
* as duplicates) versus sub-namespaces (recursion targets).
|
|
40
|
+
*
|
|
41
|
+
* Path segments are validated against prototype-pollution names
|
|
42
|
+
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
|
|
43
|
+
* recognized leaf nor a plain object — e.g. a malformed descriptor
|
|
44
|
+
* where the canonical leaf guard rejected it for missing `output` —
|
|
45
|
+
* is reported as an invalid contribution rather than recursed into,
|
|
46
|
+
* which would either silently mangle state or infinite-loop on
|
|
47
|
+
* primitive properties.
|
|
48
|
+
*
|
|
49
|
+
* Within-registry duplicate detection is this walker's job;
|
|
50
|
+
* cross-registry detection runs separately via
|
|
51
|
+
* `assertNoCrossRegistryCollisions` after merging completes.
|
|
52
|
+
*/
|
|
53
|
+
function mergeAuthoringNamespaces(target, source, path, leafGuard, label) {
|
|
54
|
+
const assertSafePath = (currentPath) => {
|
|
55
|
+
const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype");
|
|
56
|
+
if (blockedSegment) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`);
|
|
57
|
+
};
|
|
58
|
+
for (const [key, sourceValue] of Object.entries(source)) {
|
|
59
|
+
const currentPath = [...path, key];
|
|
60
|
+
assertSafePath(currentPath);
|
|
61
|
+
const hasExistingValue = Object.hasOwn(target, key);
|
|
62
|
+
const existingValue = hasExistingValue ? target[key] : void 0;
|
|
63
|
+
if (!hasExistingValue) {
|
|
64
|
+
target[key] = sourceValue;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const existingIsLeaf = leafGuard(existingValue);
|
|
68
|
+
const sourceIsLeaf = leafGuard(sourceValue);
|
|
69
|
+
if (existingIsLeaf || sourceIsLeaf) throw new Error(`Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`);
|
|
70
|
+
if (!isPlainNamespaceObject(existingValue) || !isPlainNamespaceObject(sourceValue)) throw new Error(`Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`);
|
|
71
|
+
mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, leafGuard, label);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function collectAuthoringLeafPaths(namespace, isLeaf, path = []) {
|
|
75
|
+
const paths = [];
|
|
76
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
77
|
+
const currentPath = [...path, key];
|
|
78
|
+
if (isLeaf(value)) {
|
|
79
|
+
paths.push(currentPath.join("."));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectAuthoringLeafPaths(value, isLeaf, currentPath));
|
|
83
|
+
}
|
|
84
|
+
return paths;
|
|
85
|
+
}
|
|
86
|
+
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace) {
|
|
87
|
+
const typePaths = new Set(collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor));
|
|
88
|
+
if (typePaths.size === 0) return;
|
|
89
|
+
for (const fieldPath of collectAuthoringLeafPaths(fieldNamespace, isAuthoringFieldPresetDescriptor)) 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.`);
|
|
90
|
+
}
|
|
91
|
+
function resolveAuthoringTemplateValue(template, args) {
|
|
92
|
+
if (isAuthoringArgRef(template)) {
|
|
93
|
+
let value = args[template.index];
|
|
94
|
+
for (const segment of template.path ?? []) {
|
|
95
|
+
if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) {
|
|
96
|
+
value = void 0;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
value = value[segment];
|
|
100
|
+
}
|
|
101
|
+
if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
|
|
105
|
+
if (typeof template === "object" && template !== null) {
|
|
106
|
+
const resolved = {};
|
|
107
|
+
for (const [key, value] of Object.entries(template)) {
|
|
108
|
+
const resolvedValue = resolveAuthoringTemplateValue(value, args);
|
|
109
|
+
if (resolvedValue !== void 0) resolved[key] = resolvedValue;
|
|
110
|
+
}
|
|
111
|
+
return resolved;
|
|
112
|
+
}
|
|
113
|
+
return template;
|
|
114
|
+
}
|
|
115
|
+
function validateAuthoringArgument(descriptor, value, path) {
|
|
116
|
+
if (value === void 0) {
|
|
117
|
+
if (descriptor.optional) return;
|
|
118
|
+
throw new Error(`Missing required authoring helper argument at ${path}`);
|
|
119
|
+
}
|
|
120
|
+
if (descriptor.kind === "string") {
|
|
121
|
+
if (typeof value !== "string") throw new Error(`Authoring helper argument at ${path} must be a string`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (descriptor.kind === "boolean") {
|
|
125
|
+
if (typeof value !== "boolean") throw new Error(`Authoring helper argument at ${path} must be a boolean`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (descriptor.kind === "stringArray") {
|
|
129
|
+
if (!Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
|
|
130
|
+
for (const entry of value) if (typeof entry !== "string") throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (descriptor.kind === "object") {
|
|
134
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an object`);
|
|
135
|
+
const input = value;
|
|
136
|
+
const expectedKeys = new Set(Object.keys(descriptor.properties));
|
|
137
|
+
for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw new Error(`Authoring helper argument at ${path} contains unknown property "${key}"`);
|
|
138
|
+
for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (typeof value !== "number" || Number.isNaN(value)) throw new Error(`Authoring helper argument at ${path} must be a number`);
|
|
142
|
+
if (descriptor.integer && !Number.isInteger(value)) throw new Error(`Authoring helper argument at ${path} must be an integer`);
|
|
143
|
+
if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw new Error(`Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`);
|
|
144
|
+
if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw new Error(`Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`);
|
|
145
|
+
}
|
|
146
|
+
function validateAuthoringHelperArguments(helperPath, descriptors, args) {
|
|
147
|
+
const expected = descriptors ?? [];
|
|
148
|
+
const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
|
|
149
|
+
if (args.length < minimumArgs || args.length > expected.length) throw new Error(`${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
|
|
150
|
+
expected.forEach((descriptor, index) => {
|
|
151
|
+
validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function resolveAuthoringStorageTypeTemplate(template, args) {
|
|
155
|
+
const nativeType = resolveAuthoringTemplateValue(template.nativeType, args);
|
|
156
|
+
if (typeof nativeType !== "string") throw new Error(`Resolved authoring nativeType must be a string for codec "${template.codecId}", received ${String(nativeType)}`);
|
|
157
|
+
const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
|
|
158
|
+
if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw new Error(`Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`);
|
|
159
|
+
return {
|
|
160
|
+
codecId: template.codecId,
|
|
161
|
+
nativeType,
|
|
162
|
+
...typeParams === void 0 ? {} : { typeParams }
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function resolveAuthoringColumnDefaultTemplate(template, args) {
|
|
166
|
+
if (template.kind === "literal") {
|
|
167
|
+
const value = resolveAuthoringTemplateValue(template.value, args);
|
|
168
|
+
if (value === void 0) throw new Error("Resolved authoring literal default must not be undefined");
|
|
169
|
+
if (!isColumnDefaultLiteralInputValue(value)) throw new Error(`Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`);
|
|
170
|
+
return {
|
|
171
|
+
kind: "literal",
|
|
172
|
+
value
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const expression = resolveAuthoringTemplateValue(template.expression, args);
|
|
176
|
+
if (expression === void 0 || typeof expression === "object" && expression !== null) throw new Error(`Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
|
|
177
|
+
return {
|
|
178
|
+
kind: "function",
|
|
179
|
+
expression: String(expression)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function resolveExecutionMutationDefaultPhase(phase, template, args) {
|
|
183
|
+
const value = resolveAuthoringTemplateValue(template, args);
|
|
184
|
+
if (!isExecutionMutationDefaultValue(value)) throw new Error(`Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`);
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
function resolveAuthoringExecutionDefaultsTemplate(template, args) {
|
|
188
|
+
return {
|
|
189
|
+
...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0),
|
|
190
|
+
...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function instantiateAuthoringTypeConstructor(descriptor, args) {
|
|
194
|
+
return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
|
|
195
|
+
}
|
|
196
|
+
function instantiateAuthoringFieldPreset(descriptor, args) {
|
|
197
|
+
return {
|
|
198
|
+
descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
|
|
199
|
+
nullable: descriptor.output.nullable ?? false,
|
|
200
|
+
...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
|
|
201
|
+
...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0),
|
|
202
|
+
id: descriptor.output.id ?? false,
|
|
203
|
+
unique: descriptor.output.unique ?? false
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
export { isAuthoringArgRef as a, mergeAuthoringNamespaces as c, instantiateAuthoringTypeConstructor as i, resolveAuthoringTemplateValue as l, hasRegisteredFieldNamespace as n, isAuthoringFieldPresetDescriptor as o, instantiateAuthoringFieldPreset as r, isAuthoringTypeConstructorDescriptor as s, assertNoCrossRegistryCollisions as t, validateAuthoringHelperArguments as u };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=framework-authoring-DxXcjyJX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,iBACvC,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;;;;;;;;;;AAY/C,SAAgB,4BACd,eACA,WACS;CACT,IAAI,eAAe,UAAU,KAAA,KAAa,CAAC,OAAO,OAAO,cAAc,OAAO,UAAU,EACtF,OAAO;CAET,OAAO,CAAC,iCAAiC,cAAc,MAAM,WAAW;;AAG1E,SAAS,uBAAuB,OAAkD;CAChF,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;AAqB7E,SAAgB,yBACd,QACA,QACA,MACA,WACA,OACM;CACN,MAAM,kBAAkB,gBA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;EACL,MAAM;EACN,YAAY,OAAO,WAAW;EAC/B;;AAGH,SAAS,qCACP,OACA,UACA,MAC+B;CAC/B,MAAM,QAAQ,8BAA8B,UAAU,KAAK;CAC3D,IAAI,CAAC,gCAAgC,MAAM,EACzC,MAAM,IAAI,MACR,sCAAsC,MAAM,mFAC7C;CAEH,OAAO;;AAGT,SAAS,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,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,9 +1,9 @@
|
|
|
1
|
-
import { i as AuthoringContributions } from "./framework-authoring-
|
|
2
|
-
import {
|
|
3
|
-
import { t as TypesImportSpec } from "./types-import-spec-
|
|
4
|
-
import { ColumnDefault, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
|
|
1
|
+
import { i as AuthoringContributions } from "./framework-authoring-DGIQbNPt.mjs";
|
|
2
|
+
import { r as AnyCodecDescriptor } from "./codec-m_-FAyQn.mjs";
|
|
3
|
+
import { t as TypesImportSpec } from "./types-import-spec-BxI5cSQy.mjs";
|
|
4
|
+
import { ColumnDefault, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
|
|
5
5
|
|
|
6
|
-
//#region src/mutation-default-types.d.ts
|
|
6
|
+
//#region src/shared/mutation-default-types.d.ts
|
|
7
7
|
interface SourcePosition {
|
|
8
8
|
readonly offset: number;
|
|
9
9
|
readonly line: number;
|
|
@@ -61,7 +61,16 @@ interface DefaultFunctionRegistryEntry {
|
|
|
61
61
|
type DefaultFunctionRegistry = ReadonlyMap<string, DefaultFunctionRegistryEntry>;
|
|
62
62
|
interface MutationDefaultGeneratorDescriptor {
|
|
63
63
|
readonly id: string;
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Codec ids the generator is compatible with when the codec choice
|
|
66
|
+
* and the generator choice are made independently by the contract
|
|
67
|
+
* author. Set when the registry-coherence check is meaningful
|
|
68
|
+
* (the codec and the generator can be paired arbitrarily by the
|
|
69
|
+
* caller); omitted when the generator is only reachable through a
|
|
70
|
+
* descriptor that co-registers a fixed codec, so coherence is
|
|
71
|
+
* structural and the list would be tautological.
|
|
72
|
+
*/
|
|
73
|
+
readonly applicableCodecIds?: readonly string[];
|
|
65
74
|
readonly resolveGeneratedColumnDescriptor?: (input: {
|
|
66
75
|
readonly generated: ExecutionMutationDefaultValue;
|
|
67
76
|
}) => {
|
|
@@ -70,6 +79,13 @@ interface MutationDefaultGeneratorDescriptor {
|
|
|
70
79
|
readonly typeRef?: string;
|
|
71
80
|
readonly typeParams?: Record<string, unknown>;
|
|
72
81
|
} | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Construct the `onCreate`/`onUpdate` phases value owned by this
|
|
84
|
+
* generator. Authoring layers (PSL `temporal.updatedAt()`, TS field presets) call
|
|
85
|
+
* this instead of building the literal inline so PSL/TS-authored
|
|
86
|
+
* contracts stay byte-equivalent for any future params-bearing generator.
|
|
87
|
+
*/
|
|
88
|
+
readonly buildPhases?: (args?: Record<string, unknown>) => ExecutionMutationDefaultPhases;
|
|
73
89
|
}
|
|
74
90
|
interface ControlMutationDefaultEntry {
|
|
75
91
|
readonly lower: (input: {
|
|
@@ -84,7 +100,7 @@ interface ControlMutationDefaults {
|
|
|
84
100
|
readonly generatorDescriptors: readonly MutationDefaultGeneratorDescriptor[];
|
|
85
101
|
}
|
|
86
102
|
//#endregion
|
|
87
|
-
//#region src/framework-components.d.ts
|
|
103
|
+
//#region src/shared/framework-components.d.ts
|
|
88
104
|
/**
|
|
89
105
|
* Declarative fields that describe component metadata.
|
|
90
106
|
*/
|
|
@@ -94,39 +110,32 @@ interface ComponentMetadata {
|
|
|
94
110
|
/**
|
|
95
111
|
* Capabilities this component provides.
|
|
96
112
|
*
|
|
97
|
-
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into
|
|
98
|
-
* the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);
|
|
99
|
-
* keep these declarations in sync. Targets are identifiers/descriptors and typically do not
|
|
100
|
-
* declare capabilities.
|
|
113
|
+
* For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`); keep these declarations in sync. Targets are identifiers/descriptors and typically do not declare capabilities.
|
|
101
114
|
*/
|
|
102
115
|
readonly capabilities?: Record<string, unknown>;
|
|
103
116
|
/** Type imports for contract.d.ts generation */
|
|
104
117
|
readonly types?: {
|
|
105
118
|
readonly codecTypes?: {
|
|
106
119
|
/**
|
|
107
|
-
* Base codec types import spec.
|
|
108
|
-
* Optional: adapters typically provide this, extensions usually don't.
|
|
120
|
+
* Base codec types import spec. Optional: adapters typically provide this, extensions usually don't.
|
|
109
121
|
*/
|
|
110
122
|
readonly import?: TypesImportSpec;
|
|
111
123
|
/**
|
|
112
124
|
* Additional type-only imports for parameterized codec branded types.
|
|
113
125
|
*
|
|
114
|
-
* These imports are included in generated `contract.d.ts` but are NOT treated as
|
|
115
|
-
* codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
|
|
126
|
+
* These imports are included in generated `contract.d.ts` but are NOT treated as codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
|
|
116
127
|
*
|
|
117
128
|
* Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`
|
|
118
129
|
*/
|
|
119
130
|
readonly typeImports?: ReadonlyArray<TypesImportSpec>;
|
|
120
131
|
/**
|
|
121
|
-
* Optional control-plane hooks keyed by codecId.
|
|
122
|
-
* Used by family-specific planners/verifiers to handle storage types.
|
|
132
|
+
* Optional control-plane hooks keyed by codecId. Used by family-specific planners/verifiers to handle storage types.
|
|
123
133
|
*/
|
|
124
134
|
readonly controlPlaneHooks?: Record<string, unknown>;
|
|
125
135
|
/**
|
|
126
|
-
* Codec
|
|
127
|
-
* Used to build a CodecLookup for codec-dispatched type rendering during emission.
|
|
136
|
+
* Codec descriptors contributed by this component. Source of truth for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`, `renderOutputType`) consumed by `extractCodecLookup`, and used to materialize representative `Codec` instances for codec-dispatched type rendering during emission.
|
|
128
137
|
*/
|
|
129
|
-
readonly
|
|
138
|
+
readonly codecDescriptors?: ReadonlyArray<AnyCodecDescriptor>;
|
|
130
139
|
};
|
|
131
140
|
readonly operationTypes?: {
|
|
132
141
|
readonly import: TypesImportSpec;
|
|
@@ -144,32 +153,24 @@ interface ComponentMetadata {
|
|
|
144
153
|
/**
|
|
145
154
|
* Optional pure-data authoring contributions exposed by this component.
|
|
146
155
|
*
|
|
147
|
-
* These contributions are safe to include on pack refs and descriptors because
|
|
148
|
-
* they contain only declarative metadata. Higher-level authoring packages may
|
|
149
|
-
* project them into concrete helper functions for TS-first workflows.
|
|
156
|
+
* These contributions are safe to include on pack refs and descriptors because they contain only declarative metadata. Higher-level authoring packages may project them into concrete helper functions for TS-first workflows.
|
|
150
157
|
*/
|
|
151
158
|
readonly authoring?: AuthoringContributions;
|
|
152
159
|
/**
|
|
153
|
-
* Scalar type name to codec ID mapping contributed by this component.
|
|
154
|
-
* Assembled by `createControlStack` with duplicate detection.
|
|
160
|
+
* Scalar type name to codec ID mapping contributed by this component. Assembled by `createControlStack` with duplicate detection.
|
|
155
161
|
*/
|
|
156
162
|
readonly scalarTypeDescriptors?: ReadonlyMap<string, string>;
|
|
157
163
|
/**
|
|
158
|
-
* Mutation default function handlers and generator descriptors contributed
|
|
159
|
-
* by this component. Assembled by `createControlStack` with duplicate detection.
|
|
164
|
+
* Mutation default function handlers and generator descriptors contributed by this component. Assembled by `createControlStack` with duplicate detection.
|
|
160
165
|
*/
|
|
161
166
|
readonly controlMutationDefaults?: ControlMutationDefaults;
|
|
162
167
|
}
|
|
163
168
|
/**
|
|
164
169
|
* Base descriptor for any framework component.
|
|
165
170
|
*
|
|
166
|
-
* All component descriptors share these fundamental properties that identify
|
|
167
|
-
* the component and provide its metadata. This interface is extended by
|
|
168
|
-
* specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
|
|
171
|
+
* All component descriptors share these fundamental properties that identify the component and provide its metadata. This interface is extended by specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
|
|
169
172
|
*
|
|
170
|
-
* @template Kind - Discriminator literal identifying the component type.
|
|
171
|
-
* Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',
|
|
172
|
-
* but the type accepts any string to allow ecosystem extensions.
|
|
173
|
+
* @template Kind - Discriminator literal identifying the component type. Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension', but the type accepts any string to allow ecosystem extensions.
|
|
173
174
|
*
|
|
174
175
|
* @example
|
|
175
176
|
* ```ts
|
|
@@ -210,14 +211,12 @@ declare function checkContractComponentRequirements(input: ContractComponentRequ
|
|
|
210
211
|
/**
|
|
211
212
|
* Descriptor for a family component.
|
|
212
213
|
*
|
|
213
|
-
* A "family" represents a category of data sources with shared semantics
|
|
214
|
-
* (e.g., SQL databases, document stores). Families define:
|
|
214
|
+
* A "family" represents a category of data sources with shared semantics (e.g., SQL databases, document stores). Families define:
|
|
215
215
|
* - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
|
|
216
216
|
* - Contract structure (tables vs collections, columns vs fields)
|
|
217
217
|
* - Type system and codecs
|
|
218
218
|
*
|
|
219
|
-
* Families are the top-level grouping. Each family contains multiple targets
|
|
220
|
-
* (e.g., SQL family contains Postgres, MySQL, SQLite targets).
|
|
219
|
+
* Families are the top-level grouping. Each family contains multiple targets (e.g., SQL family contains Postgres, MySQL, SQLite targets).
|
|
221
220
|
*
|
|
222
221
|
* Extended by plane-specific descriptors:
|
|
223
222
|
* - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations
|
|
@@ -241,13 +240,11 @@ interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor
|
|
|
241
240
|
/**
|
|
242
241
|
* Descriptor for a target component.
|
|
243
242
|
*
|
|
244
|
-
* A "target" represents a specific database or data store within a family
|
|
245
|
-
* (e.g., Postgres, MySQL, MongoDB). Targets define:
|
|
243
|
+
* A "target" represents a specific database or data store within a family (e.g., Postgres, MySQL, MongoDB). Targets define:
|
|
246
244
|
* - Native type mappings (e.g., Postgres int4 → TypeScript number)
|
|
247
245
|
* - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
|
|
248
246
|
*
|
|
249
|
-
* Targets are bound to a family and provide the target-specific implementation
|
|
250
|
-
* details that adapters and drivers use.
|
|
247
|
+
* Targets are bound to a family and provide the target-specific implementation details that adapters and drivers use.
|
|
251
248
|
*
|
|
252
249
|
* Extended by plane-specific descriptors:
|
|
253
250
|
* - `ControlTargetDescriptor` - adds optional `migrations` capability
|
|
@@ -272,8 +269,7 @@ interface TargetDescriptor<TFamilyId extends string, TTargetId extends string> e
|
|
|
272
269
|
readonly targetId: TTargetId;
|
|
273
270
|
}
|
|
274
271
|
/**
|
|
275
|
-
* Base shape for any pack reference.
|
|
276
|
-
* Pack refs are pure JSON-friendly objects safe to import in authoring flows.
|
|
272
|
+
* Base shape for any pack reference. Pack refs are pure JSON-friendly objects safe to import in authoring flows.
|
|
277
273
|
*/
|
|
278
274
|
interface PackRefBase<Kind extends string, TFamilyId extends string> extends ComponentMetadata {
|
|
279
275
|
readonly kind: Kind;
|
|
@@ -298,14 +294,12 @@ type DriverPackRef<TFamilyId extends string = string, TTargetId extends string =
|
|
|
298
294
|
/**
|
|
299
295
|
* Descriptor for an adapter component.
|
|
300
296
|
*
|
|
301
|
-
* An "adapter" provides the protocol and dialect implementation for a target.
|
|
302
|
-
* Adapters handle:
|
|
297
|
+
* An "adapter" provides the protocol and dialect implementation for a target. Adapters handle:
|
|
303
298
|
* - SQL/query generation (lowering AST to target-specific syntax)
|
|
304
299
|
* - Codec registration (encoding/decoding between JS and wire types)
|
|
305
300
|
* - Type mappings and coercions
|
|
306
301
|
*
|
|
307
|
-
* Adapters are bound to a specific family+target combination and work with
|
|
308
|
-
* any compatible driver for that target.
|
|
302
|
+
* Adapters are bound to a specific family+target combination and work with any compatible driver for that target.
|
|
309
303
|
*
|
|
310
304
|
* Extended by plane-specific descriptors:
|
|
311
305
|
* - `ControlAdapterDescriptor` - control-plane factory
|
|
@@ -332,16 +326,13 @@ interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string>
|
|
|
332
326
|
/**
|
|
333
327
|
* Descriptor for a driver component.
|
|
334
328
|
*
|
|
335
|
-
* A "driver" provides the connection and execution layer for a target.
|
|
336
|
-
* Drivers handle:
|
|
329
|
+
* A "driver" provides the connection and execution layer for a target. Drivers handle:
|
|
337
330
|
* - Connection management (pooling, timeouts, retries)
|
|
338
331
|
* - Query execution (sending SQL/commands, receiving results)
|
|
339
332
|
* - Transaction management
|
|
340
333
|
* - Wire protocol communication
|
|
341
334
|
*
|
|
342
|
-
* Drivers are bound to a specific family+target and work with any compatible
|
|
343
|
-
* adapter. Multiple drivers can exist for the same target (e.g., node-postgres
|
|
344
|
-
* vs postgres.js for Postgres).
|
|
335
|
+
* Drivers are bound to a specific family+target and work with any compatible adapter. Multiple drivers can exist for the same target (e.g., node-postgres vs postgres.js for Postgres).
|
|
345
336
|
*
|
|
346
337
|
* Extended by plane-specific descriptors:
|
|
347
338
|
* - `ControlDriverDescriptor` - creates driver from connection URL
|
|
@@ -373,8 +364,7 @@ interface DriverDescriptor<TFamilyId extends string, TTargetId extends string> e
|
|
|
373
364
|
* - Custom types and codecs (e.g., vector type)
|
|
374
365
|
* - Extended query capabilities
|
|
375
366
|
*
|
|
376
|
-
* Extensions are bound to a specific family+target and are registered in the
|
|
377
|
-
* config alongside the core components. Multiple extensions can be used together.
|
|
367
|
+
* Extensions are bound to a specific family+target and are registered in the config alongside the core components. Multiple extensions can be used together.
|
|
378
368
|
*
|
|
379
369
|
* Extended by plane-specific descriptors:
|
|
380
370
|
* - `ControlExtensionDescriptor` - control-plane extension factory
|
|
@@ -421,4 +411,4 @@ interface ExtensionInstance<TFamilyId extends string, TTargetId extends string>
|
|
|
421
411
|
}
|
|
422
412
|
//#endregion
|
|
423
413
|
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 };
|
|
424
|
-
//# sourceMappingURL=framework-components-
|
|
414
|
+
//# sourceMappingURL=framework-components-BGo7HsbL.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-components-BGo7HsbL.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,GAAO,UAAA;EAAA,SACP,IAAA,GAAO,QAAA,CAAS,MAAA;AAAA;AAAA,UAGjB,uBAAA;EAAA,SACC,GAAA;EAAA,SACA,IAAA,EAAM,UAAA;AAAA;AAAA,UAGA,yBAAA;EAAA,SACN,IAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA,WAAe,uBAAA;EAAA,SACf,IAAA,EAAM,UAAA;AAAA;AAAA,UAGA,8BAAA;EAAA,SACN,QAAA;EAAA,SACA,SAAA;EAAA,SACA,SAAA;EAAA,SACA,aAAA;AAAA;AAAA,KAGC,mBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,YAAA,EAAc,aAAA;AAAA;EAAA,SACxC,IAAA;EAAA,SAA4B,SAAA,EAAW,6BAAA;AAAA;AAAA,KAE1C,oBAAA;EAAA,SACG,EAAA;EAAA,SAAmB,KAAA,EAAO,mBAAA;AAAA;EAAA,SAC1B,EAAA;EAAA,SAAoB,UAAA,EAAY,gBAAA;AAAA;AAAA,KAEnC,8BAAA,IAAkC,KAAA;EAAA,SACnC,IAAA,EAAM,yBAAA;EAAA,SACN,OAAA,EAAS,8BAAA;AAAA,MACd,oBAAA;AAAA,UAEW,4BAAA;EAAA,SACN,KAAA,EAAO,8BAAA;EAAA,SACP,eAAA;AAAA;AAAA,KAGC,uBAAA,GAA0B,WAAA,SAAoB,4BAAA;AAAA,UAEzC,kCAAA;EAAA,SACN,EAAA;EAhCA;;;;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|
2
2
|
function checkContractComponentRequirements(input) {
|
|
3
3
|
const providedIds = /* @__PURE__ */ new Set();
|
|
4
4
|
for (const id of input.providedComponentIds) providedIds.add(id);
|
|
@@ -21,7 +21,7 @@ function checkContractComponentRequirements(input) {
|
|
|
21
21
|
missingExtensionPackIds
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
//#endregion
|
|
26
25
|
export { checkContractComponentRequirements as t };
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=framework-components-FdqmlGUj.mjs.map
|