@prisma/orm-framework 8.0.0-rc.21-dev.5 → 8.0.0-rc.21-dev.7
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/{apply-specifier-default-control-policy-Dlz0iwnK.d.mts → apply-specifier-default-control-policy-BSgLNgKj.d.mts} +2 -2
- package/dist/apply-specifier-default-control-policy-BSgLNgKj.d.mts.map +1 -0
- package/dist/{authoring-C2UAuRfN.d.mts → authoring-BKOoGNxH.d.mts} +58 -6
- package/dist/authoring-BKOoGNxH.d.mts.map +1 -0
- package/dist/{authoring-4wc_1ETR.mjs → authoring-CcfXu8Dz.mjs} +377 -31
- package/dist/authoring-CcfXu8Dz.mjs.map +1 -0
- package/dist/{framework-authoring-ebqZ8M_M-DIDpVcUB.d.mts → authoring-type-choice-CHcRX0RP-CkG1L8a9.d.mts} +113 -29
- package/dist/authoring-type-choice-CHcRX0RP-CkG1L8a9.d.mts.map +1 -0
- package/dist/{binder-BszqDG1t-icu83_4f.d.mts → binder-CMy3WM5A-DRrDzBAq.d.mts} +38 -20
- package/dist/{binder-BszqDG1t-icu83_4f.d.mts.map → binder-CMy3WM5A-DRrDzBAq.d.mts.map} +1 -1
- package/dist/{canonicalization-CyrrXGmj-CeKUkht1.d.mts → canonicalization-BIS6ONYT-VttZI7M4.d.mts} +3 -3
- package/dist/{canonicalization-CyrrXGmj-CeKUkht1.d.mts.map → canonicalization-BIS6ONYT-VttZI7M4.d.mts.map} +1 -1
- package/dist/{codec-CZ3VQq7G.d.mts → codec-h0kvF5B8.d.mts} +4 -3
- package/dist/codec-h0kvF5B8.d.mts.map +1 -0
- package/dist/{codec-types-B4wPvO-K-BqcGrCE-.d.mts → codec-types-B4wPvO-K-BIPFT7EP.d.mts} +2 -2
- package/dist/{codec-types-B4wPvO-K-BqcGrCE-.d.mts.map → codec-types-B4wPvO-K-BIPFT7EP.d.mts.map} +1 -1
- package/dist/{components-BenCVFk4.d.mts → components-BvnVHOK3.d.mts} +5 -5
- package/dist/{components-BenCVFk4.d.mts.map → components-BvnVHOK3.d.mts.map} +1 -1
- package/dist/components.d.mts +17 -17
- package/dist/components.mjs +5 -5
- package/dist/components__authoring.d.mts +4 -4
- package/dist/components__authoring.mjs +3 -3
- package/dist/components__codec.d.mts +2 -2
- package/dist/components__components.d.mts +4 -4
- package/dist/components__control.d.mts +4 -4
- package/dist/components__control.mjs +2 -2
- package/dist/components__emission.d.mts +3 -3
- package/dist/components__execution.d.mts +1 -1
- package/dist/components__ir.d.mts +2 -2
- package/dist/components__ir.mjs +2 -2
- package/dist/components__psl-ast.d.mts +3 -3
- package/dist/components__runtime.d.mts +1 -1
- package/dist/{config-types-BJ79TZCl.d.mts → config-types-De3gHQOy.d.mts} +8 -8
- package/dist/{config-types-BJ79TZCl.d.mts.map → config-types-De3gHQOy.d.mts.map} +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config__config-types.d.mts +1 -1
- package/dist/contract-authoring.d.mts +6 -6
- package/dist/contract-authoring.mjs +3 -3
- package/dist/{contract-types-DEIEpzU_-DvAVuBr5.d.mts → contract-types-ib-VnKHG-l9vE5Vd-.d.mts} +22 -8
- package/dist/contract-types-ib-VnKHG-l9vE5Vd-.d.mts.map +1 -0
- package/dist/contract.d.mts +13 -11
- package/dist/contract.mjs +5 -3
- package/dist/contract__apply-specifier-default-control-policy.d.mts +1 -1
- package/dist/contract__enum-accessor.d.mts +1 -1
- package/dist/contract__hashing-utils.d.mts +1 -1
- package/dist/contract__hashing.d.mts +2 -2
- package/dist/contract__resolve-domain-model.d.mts +1 -1
- package/dist/contract__types.d.mts +6 -5
- package/dist/contract__types.mjs +3 -2
- package/dist/contract__validate-domain.d.mts +2 -2
- package/dist/contract__validate-domain.mjs +2 -2
- package/dist/contract__validate-storage.d.mts +2 -0
- package/dist/contract__validate-storage.mjs +2 -0
- package/dist/{control-DLpQIwer.mjs → control-BE0sjzPI.mjs} +6 -2
- package/dist/control-BE0sjzPI.mjs.map +1 -0
- package/dist/{control-BeXOxtXA-BU8y-LiK.d.mts → control-BeXOxtXA-DOfRFBDx.d.mts} +2 -2
- package/dist/{control-BeXOxtXA-BU8y-LiK.d.mts.map → control-BeXOxtXA-DOfRFBDx.d.mts.map} +1 -1
- package/dist/{control-CS1uqJj_.d.mts → control-DanUY6NX.d.mts} +24 -12
- package/dist/control-DanUY6NX.d.mts.map +1 -0
- package/dist/{control-MllEQmML-yjvIIvnf.mjs → control-MllEQmML-BgM0TgK3.mjs} +2 -2
- package/dist/{control-MllEQmML-yjvIIvnf.mjs.map → control-MllEQmML-BgM0TgK3.mjs.map} +1 -1
- package/dist/control-QJnHVB3m.d.mts +1 -0
- package/dist/{declarations-BgUAq1RG-D99LhVXe.mjs → declarations-BgUAq1RG-DvmyJ8LS.mjs} +2 -2
- package/dist/{declarations-BgUAq1RG-D99LhVXe.mjs.map → declarations-BgUAq1RG-DvmyJ8LS.mjs.map} +1 -1
- package/dist/domain-envelope-CJNIHBn_-DBFAmkNL.d.mts +191 -0
- package/dist/domain-envelope-CJNIHBn_-DBFAmkNL.d.mts.map +1 -0
- package/dist/emission-DGYCaKjl.d.mts +2 -0
- package/dist/{emission-types-bX2HmNSC-C9vDMKbg.d.mts → emission-types-bX2HmNSC-vaRddb1_.d.mts} +6 -5
- package/dist/emission-types-bX2HmNSC-vaRddb1_.d.mts.map +1 -0
- package/dist/{enum-accessor-2OZgavDX.d.mts → enum-accessor-BXc2Jseo.d.mts} +4 -3
- package/dist/enum-accessor-BXc2Jseo.d.mts.map +1 -0
- package/dist/errors.d.mts +4 -4
- package/dist/errors.mjs +3 -3
- package/dist/errors__control.d.mts +2 -2
- package/dist/errors__control.mjs +1 -1
- package/dist/errors__execution.d.mts +1 -1
- package/dist/errors__execution.mjs +1 -1
- package/dist/errors__migration.d.mts +1 -1
- package/dist/errors__migration.mjs +1 -1
- package/dist/{execution-CXXKXfwB.mjs → execution-BkFLjpfc.mjs} +2 -2
- package/dist/{execution-CXXKXfwB.mjs.map → execution-BkFLjpfc.mjs.map} +1 -1
- package/dist/{execution-BWR_z8XI.d.mts → execution-C_12rfIR.d.mts} +2 -2
- package/dist/{execution-BWR_z8XI.d.mts.map → execution-C_12rfIR.d.mts.map} +1 -1
- package/dist/{execution-BPJbNttJ.d.mts → execution-CyddhERj.d.mts} +2 -2
- package/dist/{execution-BPJbNttJ.d.mts.map → execution-CyddhERj.d.mts.map} +1 -1
- package/dist/{expressions-CMQzbnHk-Db8YJA0B.mjs → expressions-CMQzbnHk-B7zBWJ0c.mjs} +2 -2
- package/dist/{expressions-CMQzbnHk-Db8YJA0B.mjs.map → expressions-CMQzbnHk-B7zBWJ0c.mjs.map} +1 -1
- package/dist/field-problems-DMpmScuG-R70w-aDk.mjs +41 -0
- package/dist/field-problems-DMpmScuG-R70w-aDk.mjs.map +1 -0
- package/dist/{framework-components-BqHA1V92-D9j8uXa-.d.mts → framework-components-GBAmsfWO-DUJQpMpU.d.mts} +5 -5
- package/dist/{framework-components-BqHA1V92-D9j8uXa-.d.mts.map → framework-components-GBAmsfWO-DUJQpMpU.d.mts.map} +1 -1
- package/dist/{hashing-D-DHz0zl.d.mts → hashing-Ca2uTBmm.d.mts} +4 -4
- package/dist/{hashing-D-DHz0zl.d.mts.map → hashing-Ca2uTBmm.d.mts.map} +1 -1
- package/dist/{hashing-utils-DiGHKd3b.d.mts → hashing-utils-daflaalA.d.mts} +2 -2
- package/dist/{hashing-utils-DiGHKd3b.d.mts.map → hashing-utils-daflaalA.d.mts.map} +1 -1
- package/dist/ids__runtime.d.mts +1 -1
- package/dist/{ir-uDGU9vaj.mjs → ir-B7QKO3dq.mjs} +18 -2
- package/dist/ir-B7QKO3dq.mjs.map +1 -0
- package/dist/{ir-LV4tXsw3.d.mts → ir-DoVMhmqa.d.mts} +10 -25
- package/dist/ir-DoVMhmqa.d.mts.map +1 -0
- package/dist/{migration-Dk1sYIvs.d.mts → migration-B7ur91Et.d.mts} +2 -2
- package/dist/{migration-Dk1sYIvs.d.mts.map → migration-B7ur91Et.d.mts.map} +1 -1
- package/dist/{migration-B1TEF2ij.mjs → migration-CQufZA_7.mjs} +2 -2
- package/dist/{migration-B1TEF2ij.mjs.map → migration-CQufZA_7.mjs.map} +1 -1
- package/dist/{parse-bZgfjovA-CaBuZnet.mjs → parse-bZgfjovA-Vk8LMIu5.mjs} +3 -3
- package/dist/{parse-bZgfjovA-CaBuZnet.mjs.map → parse-bZgfjovA-Vk8LMIu5.mjs.map} +1 -1
- package/dist/{parse-djL5wker-DnMlKOii.d.mts → parse-djL5wker-4_2Cqwev.d.mts} +6 -6
- package/dist/{parse-djL5wker-DnMlKOii.d.mts.map → parse-djL5wker-4_2Cqwev.d.mts.map} +1 -1
- package/dist/{psl-ast-0oMzInxd-Nx9cHmcc.d.mts → psl-ast-B4ZxpQdr-DT9LRqBC.d.mts} +3 -3
- package/dist/{psl-ast-0oMzInxd-Nx9cHmcc.d.mts.map → psl-ast-B4ZxpQdr-DT9LRqBC.d.mts.map} +1 -1
- package/dist/psl-ast-Dsf1-QLK.d.mts +2 -0
- package/dist/psl-parser.d.mts +24 -15
- package/dist/psl-parser.d.mts.map +1 -1
- package/dist/psl-parser.mjs +29 -43
- package/dist/psl-parser.mjs.map +1 -1
- package/dist/psl-parser__format.d.mts +1 -1
- package/dist/psl-parser__format.mjs +3 -3
- package/dist/psl-parser__interpret.d.mts +65 -23
- package/dist/psl-parser__interpret.d.mts.map +1 -1
- package/dist/psl-parser__interpret.mjs +135 -140
- package/dist/psl-parser__interpret.mjs.map +1 -1
- package/dist/psl-parser__syntax.d.mts +1 -1
- package/dist/psl-parser__syntax.mjs +3 -3
- package/dist/psl-printer.d.mts +4 -4
- package/dist/psl-printer.mjs +1 -1
- package/dist/{resolve-domain-model-BNr1glea-BLuR-phK.d.mts → resolve-domain-model-CZ5E6qxa-Caq2Becx.d.mts} +3 -3
- package/dist/resolve-domain-model-CZ5E6qxa-Caq2Becx.d.mts.map +1 -0
- package/dist/{runtime-CTJc8PII.d.mts → runtime-BERs-lBJ.d.mts} +4 -4
- package/dist/{runtime-CTJc8PII.d.mts.map → runtime-BERs-lBJ.d.mts.map} +1 -1
- package/dist/storage-value-objects-Di8Cowdl-QNqJXkk0.mjs +28 -0
- package/dist/storage-value-objects-Di8Cowdl-QNqJXkk0.mjs.map +1 -0
- package/dist/{temporal-type-aliases-C9tIy4rv-Dsun86cY.mjs → temporal-type-aliases-BI3SL5iB-DIP8j4Gv.mjs} +383 -172
- package/dist/temporal-type-aliases-BI3SL5iB-DIP8j4Gv.mjs.map +1 -0
- package/dist/{temporal-type-aliases-BIiamFSH-BrpK13hf.d.mts → temporal-type-aliases-D5QWPhYa-BNKiNvmd.d.mts} +4 -4
- package/dist/{temporal-type-aliases-BIiamFSH-BrpK13hf.d.mts.map → temporal-type-aliases-D5QWPhYa-BNKiNvmd.d.mts.map} +1 -1
- package/dist/type-constructor-calls-Bfg5ojed-DYHnzC9z.mjs +538 -0
- package/dist/type-constructor-calls-Bfg5ojed-DYHnzC9z.mjs.map +1 -0
- package/dist/{types-B8ULzMAX.mjs → types-Boh5NGDz.mjs} +52 -9
- package/dist/types-Boh5NGDz.mjs.map +1 -0
- package/dist/types-CkFfDIud-C1u8M2UE.d.mts +196 -0
- package/dist/types-CkFfDIud-C1u8M2UE.d.mts.map +1 -0
- package/dist/{types-GNXJ7xW2.d.mts → types-Dh_AMVRf.d.mts} +145 -25
- package/dist/types-Dh_AMVRf.d.mts.map +1 -0
- package/dist/{types-import-spec-Bkh243Hv-B-fdw0Wl.d.mts → types-import-spec-Bkh243Hv-BI9m5WFL.d.mts} +3 -3
- package/dist/{types-import-spec-Bkh243Hv-B-fdw0Wl.d.mts.map → types-import-spec-Bkh243Hv-BI9m5WFL.d.mts.map} +1 -1
- package/dist/{validate-domain-CbXHDYpF.mjs → validate-domain-KUhPCj7i.mjs} +18 -35
- package/dist/validate-domain-KUhPCj7i.mjs.map +1 -0
- package/dist/{validate-domain-B5kmlBFB.d.mts → validate-domain-eU07L3vi.d.mts} +7 -3
- package/dist/{validate-domain-B5kmlBFB.d.mts.map → validate-domain-eU07L3vi.d.mts.map} +1 -1
- package/dist/validate-storage-CGeJ-62G.mjs +31 -0
- package/dist/validate-storage-CGeJ-62G.mjs.map +1 -0
- package/dist/validate-storage-ChcQuhTb.d.mts +10 -0
- package/dist/validate-storage-ChcQuhTb.d.mts.map +1 -0
- package/package.json +16 -15
- package/dist/apply-specifier-default-control-policy-Dlz0iwnK.d.mts.map +0 -1
- package/dist/authoring-4wc_1ETR.mjs.map +0 -1
- package/dist/authoring-C2UAuRfN.d.mts.map +0 -1
- package/dist/codec-CZ3VQq7G.d.mts.map +0 -1
- package/dist/contract-types-DEIEpzU_-DvAVuBr5.d.mts.map +0 -1
- package/dist/control-B3OS8JEw.d.mts +0 -1
- package/dist/control-CS1uqJj_.d.mts.map +0 -1
- package/dist/control-DLpQIwer.mjs.map +0 -1
- package/dist/domain-envelope-CN721GnP-4huRt7Wc.d.mts +0 -373
- package/dist/domain-envelope-CN721GnP-4huRt7Wc.d.mts.map +0 -1
- package/dist/emission-ByTWEe2j.d.mts +0 -2
- package/dist/emission-types-bX2HmNSC-C9vDMKbg.d.mts.map +0 -1
- package/dist/enum-accessor-2OZgavDX.d.mts.map +0 -1
- package/dist/framework-authoring-ebqZ8M_M-DIDpVcUB.d.mts.map +0 -1
- package/dist/ir-LV4tXsw3.d.mts.map +0 -1
- package/dist/ir-uDGU9vaj.mjs.map +0 -1
- package/dist/psl-ast-CFQfCJeM.d.mts +0 -2
- package/dist/resolve-domain-model-BNr1glea-BLuR-phK.d.mts.map +0 -1
- package/dist/temporal-type-aliases-C9tIy4rv-Dsun86cY.mjs.map +0 -1
- package/dist/type-constructor-calls-CNd1Xlw2-CfYTYNSm.mjs +0 -306
- package/dist/type-constructor-calls-CNd1Xlw2-CfYTYNSm.mjs.map +0 -1
- package/dist/types-B8ULzMAX.mjs.map +0 -1
- package/dist/types-GNXJ7xW2.d.mts.map +0 -1
- package/dist/validate-domain-CbXHDYpF.mjs.map +0 -1
|
@@ -6,9 +6,13 @@ import { n as notOk, r as ok } from "./result-8OXF26MN.mjs";
|
|
|
6
6
|
import { n as runtimeError } from "./runtime-error-BA9d7XjZ-BlT8t6LB.mjs";
|
|
7
7
|
import { o as assembleDataTypes } from "./data-type-DPsP4_9m-BRPJX_-z.mjs";
|
|
8
8
|
import { c as tsTemplateText, o as tsQuotedTextSource } from "./dist-D1f6xr7F.mjs";
|
|
9
|
-
//#region ../../../1-framework/1-core/framework-components/dist/temporal-type-aliases-
|
|
9
|
+
//#region ../../../1-framework/1-core/framework-components/dist/temporal-type-aliases-BI3SL5iB.mjs
|
|
10
10
|
/** The descriptor kinds a `type` namespace holds as leaves. */
|
|
11
|
-
const AUTHORING_TYPE_DESCRIPTOR_KINDS = [
|
|
11
|
+
const AUTHORING_TYPE_DESCRIPTOR_KINDS = [
|
|
12
|
+
"typeConstructor",
|
|
13
|
+
"typeAlias",
|
|
14
|
+
"typeChoice"
|
|
15
|
+
];
|
|
12
16
|
const AUTHORING_WARNING_BATCH_THRESHOLD = 5;
|
|
13
17
|
/**
|
|
14
18
|
* Emits collected authoring warnings once per build, grouped by `code`:
|
|
@@ -102,9 +106,12 @@ function isAuthoringTypeConstructorDescriptor(value) {
|
|
|
102
106
|
function isAuthoringTypeAliasDescriptor(value) {
|
|
103
107
|
return "kind" in value && value.kind === "typeAlias";
|
|
104
108
|
}
|
|
105
|
-
|
|
109
|
+
function isAuthoringTypeChoiceDescriptor(value) {
|
|
110
|
+
return "kind" in value && value.kind === "typeChoice";
|
|
111
|
+
}
|
|
112
|
+
/** Whether `value` is a leaf of a `type` namespace: a type constructor, a type alias or a type choice. */
|
|
106
113
|
function isAuthoringTypeDescriptor(value) {
|
|
107
|
-
return isAuthoringTypeConstructorDescriptor(value) || isAuthoringTypeAliasDescriptor(value);
|
|
114
|
+
return isAuthoringTypeConstructorDescriptor(value) || isAuthoringTypeAliasDescriptor(value) || isAuthoringTypeChoiceDescriptor(value);
|
|
108
115
|
}
|
|
109
116
|
/** The type constructor at `path` in the contributions' type namespace, or `undefined` when none is there. */
|
|
110
117
|
function getAuthoringTypeConstructor(contributions, path) {
|
|
@@ -139,6 +146,7 @@ function isWellFormedDescriptor(value, descriptorKinds) {
|
|
|
139
146
|
const output = value.output;
|
|
140
147
|
return typeof output === "object" && output !== null;
|
|
141
148
|
}
|
|
149
|
+
case "typeChoice": return "args" in value && Array.isArray(value.args) && "choices" in value && Array.isArray(value.choices);
|
|
142
150
|
case "typeAlias": {
|
|
143
151
|
if (!("output" in value)) return false;
|
|
144
152
|
const output = value.output;
|
|
@@ -259,31 +267,6 @@ function collectContributedDescriptorPaths(namespace, descriptorKind, path = [])
|
|
|
259
267
|
}
|
|
260
268
|
return paths;
|
|
261
269
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Derives the scalar view of an assembled authoring type namespace: every
|
|
264
|
-
* **top-level** type constructor that is instantiable with an empty argument
|
|
265
|
-
* list — all declared args optional and no entity-ref argument. A bare type
|
|
266
|
-
* name `T` in a schema is semantically the zero-arg instantiation `T()`, so
|
|
267
|
-
* each entry is exactly what that call produces (defaulted template values
|
|
268
|
-
* applied, absent optional-arg typeParams keys omitted). Constructors
|
|
269
|
-
* registered under a namespace segment, constructors with required args, and
|
|
270
|
-
* entity-ref constructors are not scalars and are excluded.
|
|
271
|
-
*
|
|
272
|
-
* Eligibility needs no template inspection: templates that cannot resolve
|
|
273
|
-
* for their legal call shapes are rejected at the composition boundary by
|
|
274
|
-
* {@link assertResolvableTypeConstructorTemplates}, so the zero-arg
|
|
275
|
-
* instantiation below cannot fail for an eligible constructor.
|
|
276
|
-
*/
|
|
277
|
-
function collectScalarTypeConstructors(namespace) {
|
|
278
|
-
const result = /* @__PURE__ */ new Map();
|
|
279
|
-
for (const [name, value] of Object.entries(namespace)) {
|
|
280
|
-
if (!isAuthoringTypeConstructorDescriptor(value)) continue;
|
|
281
|
-
if (value.entityRefArg !== void 0) continue;
|
|
282
|
-
if (value.args?.some((arg) => arg.optional !== true)) continue;
|
|
283
|
-
result.set(name, instantiateAuthoringTypeConstructor(value, []));
|
|
284
|
-
}
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
270
|
function visitTemplateArgRefs(template, visit) {
|
|
288
271
|
if (template === void 0) return;
|
|
289
272
|
if (isAuthoringArgRef(template)) {
|
|
@@ -313,6 +296,7 @@ function assertResolvableTypeConstructorTemplates(namespace, contributedBy, path
|
|
|
313
296
|
});
|
|
314
297
|
continue;
|
|
315
298
|
}
|
|
299
|
+
if (isAuthoringTypeChoiceDescriptor(value)) continue;
|
|
316
300
|
if (!isAuthoringTypeConstructorDescriptor(value)) {
|
|
317
301
|
assertResolvableTypeConstructorTemplates(value, contributedBy, currentPath);
|
|
318
302
|
continue;
|
|
@@ -550,6 +534,19 @@ function validateAuthoringTypeParams(helperPath, template, typeParams, paramsSch
|
|
|
550
534
|
...ifDefined("argumentIndex", argumentIndex)
|
|
551
535
|
});
|
|
552
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* {@link validateAuthoringTypeParams} for a call of the type choice `choice` that chose `chosen`: a failure names the choice's own argument the failing parameter came from, by its name and its index in the choice's arguments.
|
|
539
|
+
*/
|
|
540
|
+
function validateAuthoringTypeChoiceParams(helperPath, choice, chosen, typeParams, paramsSchema) {
|
|
541
|
+
const issue = authoringTypeParamsIssue(chosen.output, typeParams, paramsSchema);
|
|
542
|
+
if (issue === void 0) return;
|
|
543
|
+
const name = issue.argumentIndex === void 0 ? void 0 : chosen.args?.[issue.argumentIndex]?.name;
|
|
544
|
+
const argumentIndex = name === void 0 ? -1 : choice.args.findIndex((argument) => argument.name === name);
|
|
545
|
+
throw runtimeError("CONTRACT.ARGUMENT_INVALID", argumentIndex < 0 ? `The type parameters of ${helperPath} are invalid: ${issue.message}` : `Argument "${name}" of ${helperPath} is invalid: ${issue.message}`, {
|
|
546
|
+
helperPath,
|
|
547
|
+
...ifDefined("argumentIndex", argumentIndex < 0 ? void 0 : argumentIndex)
|
|
548
|
+
});
|
|
549
|
+
}
|
|
553
550
|
function resolveAuthoringStorageTypeTemplate(template, args) {
|
|
554
551
|
const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
|
|
555
552
|
if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`);
|
|
@@ -633,166 +630,219 @@ function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
|
|
|
633
630
|
validateAuthoringHelperArguments(helperPath, descriptor.args, args);
|
|
634
631
|
return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args));
|
|
635
632
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
function assembleAuthoringDataTypes(components) {
|
|
639
|
-
const merged = {};
|
|
640
|
-
const owners = /* @__PURE__ */ new Map();
|
|
641
|
-
for (const component of components) {
|
|
642
|
-
const contributedBy = component.id ?? UNKNOWN_CONTRIBUTOR;
|
|
643
|
-
for (const [key, entry] of Object.entries(component.authoring?.dataTypes ?? {})) {
|
|
644
|
-
const existingOwner = owners.get(key);
|
|
645
|
-
if (existingOwner !== void 0) throw runtimeError("CONTRACT.DATA_TYPE_ENTRY_DUPLICATE", `Duplicate authoring entry for "${key}". Component "${contributedBy}" conflicts with "${existingOwner}".`, {
|
|
646
|
-
key,
|
|
647
|
-
contributedBy,
|
|
648
|
-
owner: existingOwner
|
|
649
|
-
});
|
|
650
|
-
owners.set(key, contributedBy);
|
|
651
|
-
merged[key] = entry;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
return merged;
|
|
633
|
+
function isAuthoringTypeChoiceOption(argument) {
|
|
634
|
+
return argument.kind === "option";
|
|
655
635
|
}
|
|
656
|
-
function
|
|
657
|
-
return
|
|
658
|
-
const currentPath = [...path, key];
|
|
659
|
-
if (isLeaf(value)) return [{
|
|
660
|
-
path: currentPath.join("."),
|
|
661
|
-
descriptor: value
|
|
662
|
-
}];
|
|
663
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return [];
|
|
664
|
-
return descriptorsIn(value, isLeaf, currentPath);
|
|
665
|
-
});
|
|
636
|
+
function rowMatches(row, chosen, names) {
|
|
637
|
+
return names.every((name) => row.when[name] === chosen.get(name));
|
|
666
638
|
}
|
|
667
|
-
/**
|
|
668
|
-
function
|
|
669
|
-
return
|
|
670
|
-
path,
|
|
671
|
-
descriptor,
|
|
672
|
-
contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
|
|
673
|
-
}] : []);
|
|
639
|
+
/** How a combination of option values is written, as in `as: string, storage: timestamp`. */
|
|
640
|
+
function typeChoiceCombinationText(row) {
|
|
641
|
+
return Object.entries(row.when).map(([name, value]) => `${name}: ${value}`).join(", ");
|
|
674
642
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
return new Set(entries.flatMap(({ key, entry }) => [key, ...entry.written.kind === "plain" && entry.written.syntax === "number" ? entry.written.types : []]));
|
|
643
|
+
function listedNames(names) {
|
|
644
|
+
return names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
678
645
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const { path, descriptor, contributedBy } = contributed;
|
|
682
|
-
for (const [index, argument] of (descriptor.args ?? []).entries()) {
|
|
683
|
-
const label = `Argument ${argument.name === void 0 ? `#${index + 1}` : `"${argument.name}"`} of type constructor "${path}"`;
|
|
684
|
-
const argumentKind = argument.kind;
|
|
685
|
-
if (argumentKind !== "value") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `${label} contributed by "${contributedBy}" is an argument of kind "${argumentKind}", but a type constructor's argument is a value of a data type. Declare it as { kind: 'value', dataType: ... }, naming the data type its value belongs to.`, {
|
|
686
|
-
packId: contributedBy,
|
|
687
|
-
contribution: path,
|
|
688
|
-
reason: "type-constructor-argument-not-a-value"
|
|
689
|
-
});
|
|
690
|
-
const type = support.lookup.get(argument.dataType);
|
|
691
|
-
if (type === void 0) throw runtimeError("CONTRACT.DATA_TYPE_UNREGISTERED", `${label} names data type "${argument.dataType}", which no component registers. Contributed by "${contributedBy}".`, {
|
|
692
|
-
dataType: argument.dataType,
|
|
693
|
-
contributedBy
|
|
694
|
-
});
|
|
695
|
-
if (![argument.dataType, ...Object.keys(type.casts)].some((admittedType) => writable.has(admittedType))) throw runtimeError("CONTRACT.DATA_TYPE_NOT_WRITABLE", `${label} contributed by "${contributedBy}" takes a value of data type "${argument.dataType}", which no contract source can write.`, {
|
|
696
|
-
dataType: argument.dataType,
|
|
697
|
-
contributedBy
|
|
698
|
-
});
|
|
699
|
-
}
|
|
646
|
+
function isArgumentObject(value) {
|
|
647
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
700
648
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
|
|
705
|
-
})));
|
|
649
|
+
/** Why `subject`, a call of the type choice `descriptor`, cannot take the argument `name`, naming the arguments it takes. */
|
|
650
|
+
function unknownTypeChoiceArgumentMessage(subject, descriptor, name) {
|
|
651
|
+
return `${subject} has no argument "${name}"; its arguments are ${listedNames(descriptor.args.map((argument) => argument.name))}.`;
|
|
706
652
|
}
|
|
707
653
|
/**
|
|
708
|
-
* The
|
|
709
|
-
*
|
|
710
|
-
* 1. every codec names a registered data type;
|
|
711
|
-
* 2. every authoring entry, and every type a number classifier returns, names a registered data type;
|
|
712
|
-
* 3. every type a cast takes values of is registered and can be written, because a cast from a type nobody can write is never exercised;
|
|
713
|
-
* 4. no two entries claim one tag or one plain form;
|
|
714
|
-
* 5. every text data type a component names is registered.
|
|
654
|
+
* The values of a type choice call that writes its arguments as one object, by the choice's argument positions, as {@link resolveAuthoringTypeChoice} reads them. `written` is the call's arguments: none, or one object keyed by argument name. Anything else, and a key the choice has no argument for, is refused with `CONTRACT.ARGUMENT_INVALID`.
|
|
715
655
|
*/
|
|
716
|
-
function
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
656
|
+
function typeChoiceArgumentsFromObject(helperPath, descriptor, written) {
|
|
657
|
+
const names = descriptor.args.map((argument) => argument.name);
|
|
658
|
+
const [first] = written;
|
|
659
|
+
const object = written.length === 0 ? {} : first;
|
|
660
|
+
if (written.length > 1 || !isArgumentObject(object)) {
|
|
661
|
+
const example = descriptor.args.find(isAuthoringTypeChoiceOption);
|
|
662
|
+
const sample = example === void 0 ? "" : `{ ${example.name}: '${example.default}' }`;
|
|
663
|
+
throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${helperPath} takes its arguments as one object with the keys ${listedNames(names)}, such as ${helperPath}(${sample}).`, { helperPath });
|
|
664
|
+
}
|
|
665
|
+
const unknown = Object.keys(object).find((key) => !names.includes(key));
|
|
666
|
+
if (unknown !== void 0) throw runtimeError("CONTRACT.ARGUMENT_INVALID", unknownTypeChoiceArgumentMessage(helperPath, descriptor, unknown), { helperPath });
|
|
667
|
+
return names.map((name) => object[name]);
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* The type constructor a call of the type choice `descriptor` chooses, and the arguments it passes on. `args` are the call's values by the choice's argument positions; an option left out takes its default. A value an option does not list, a combination with no row, and a passed-on argument the chosen constructor does not take are refused with `CONTRACT.ARGUMENT_INVALID`, naming the argument by its index.
|
|
671
|
+
*/
|
|
672
|
+
function resolveAuthoringTypeChoice(input) {
|
|
673
|
+
const { helperPath, descriptor, args } = input;
|
|
674
|
+
const refuse = (argumentIndex, message) => {
|
|
675
|
+
throw runtimeError("CONTRACT.ARGUMENT_INVALID", message, {
|
|
676
|
+
helperPath,
|
|
677
|
+
argumentIndex
|
|
721
678
|
});
|
|
722
679
|
};
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
680
|
+
const label = (index) => `Argument "${descriptor.args[index]?.name}" of ${helperPath}`;
|
|
681
|
+
const options = descriptor.args.flatMap((argument, index) => isAuthoringTypeChoiceOption(argument) ? [{
|
|
682
|
+
argument,
|
|
683
|
+
index
|
|
684
|
+
}] : []);
|
|
685
|
+
const written = options.filter(({ index }) => args[index] !== void 0);
|
|
686
|
+
const defaulted = options.filter(({ index }) => args[index] === void 0);
|
|
687
|
+
const chosen = /* @__PURE__ */ new Map();
|
|
688
|
+
const decided = [];
|
|
689
|
+
for (const { argument, index } of [...written, ...defaulted]) {
|
|
690
|
+
const value = args[index] ?? argument.default;
|
|
691
|
+
if (typeof value !== "string" || !argument.values.includes(value)) refuse(index, `${label(index)} is ${String(value)}; write one of: ${argument.values.join(", ")}.`);
|
|
692
|
+
const fitting = descriptor.choices.filter((row) => rowMatches(row, chosen, decided));
|
|
693
|
+
const accepted = argument.values.filter((candidate) => fitting.some((row) => row.when[argument.name] === candidate));
|
|
694
|
+
if (!accepted.includes(String(value))) {
|
|
695
|
+
const others = decided.map((name) => `${name}: ${chosen.get(name)}`).join(", ");
|
|
696
|
+
refuse(index, `${label(index)} cannot be ${String(value)} with ${others}; write one of: ${accepted.join(", ")}.`);
|
|
728
697
|
}
|
|
698
|
+
chosen.set(argument.name, String(value));
|
|
699
|
+
decided.push(argument.name);
|
|
729
700
|
}
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
701
|
+
const row = descriptor.choices.find((candidate) => rowMatches(candidate, chosen, decided));
|
|
702
|
+
const chosenType = row === void 0 ? void 0 : input.constructorNamed(row.type);
|
|
703
|
+
if (row === void 0 || chosenType === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Type choice "${helperPath}" chooses no registered type constructor for ${[...chosen].map(([name, value]) => `${name}: ${value}`).join(", ")}.`, { helperPath });
|
|
704
|
+
const parameters = chosenType.args ?? [];
|
|
705
|
+
descriptor.args.forEach((argument, index) => {
|
|
706
|
+
if (isAuthoringTypeChoiceOption(argument) || args[index] === void 0) return;
|
|
707
|
+
if (!parameters.some((parameter) => parameter.name === argument.name)) refuse(index, `${label(index)} does not apply to ${row.type}, the type that ${typeChoiceCombinationText(row)} chooses.`);
|
|
708
|
+
});
|
|
709
|
+
return {
|
|
710
|
+
type: row.type,
|
|
711
|
+
descriptor: chosenType,
|
|
712
|
+
args: parameters.map((parameter) => {
|
|
713
|
+
const index = descriptor.args.findIndex((argument) => !isAuthoringTypeChoiceOption(argument) && argument.name === parameter.name);
|
|
714
|
+
return (index < 0 ? void 0 : args[index]) ?? (parameter.name === void 0 ? void 0 : row.defaults?.[parameter.name]);
|
|
715
|
+
})
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
/** Looks a type constructor up by name in one level of a type namespace, as a type choice's rows name them. */
|
|
719
|
+
function typeConstructorLookup(namespace) {
|
|
720
|
+
return (name) => {
|
|
721
|
+
const member = Object.hasOwn(namespace, name) ? namespace[name] : void 0;
|
|
722
|
+
return member !== void 0 && isAuthoringTypeConstructorDescriptor(member) ? member : void 0;
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function memberNamed(namespace, name) {
|
|
726
|
+
return Object.hasOwn(namespace, name) ? namespace[name] : void 0;
|
|
727
|
+
}
|
|
728
|
+
function subNamespace(member) {
|
|
729
|
+
return member === void 0 || isAuthoringTypeDescriptor(member) ? void 0 : member;
|
|
730
|
+
}
|
|
731
|
+
/** The sub-namespace at `path` of a type namespace, or `undefined` when a segment names no sub-namespace. */
|
|
732
|
+
function authoringTypeNamespaceLevel(namespace, path) {
|
|
733
|
+
let level = namespace;
|
|
734
|
+
for (const segment of path) level = level === void 0 ? void 0 : subNamespace(memberNamed(level, segment));
|
|
735
|
+
return level;
|
|
736
|
+
}
|
|
737
|
+
/** The type choice at `path` in the contributions' type namespace, with a lookup of the type constructors beside it that its rows name, or `undefined` when none is there. */
|
|
738
|
+
function getAuthoringTypeChoice(contributions, path) {
|
|
739
|
+
const level = authoringTypeNamespaceLevel(contributions?.type, path.slice(0, -1));
|
|
740
|
+
const name = path.at(-1);
|
|
741
|
+
const member = level === void 0 || name === void 0 ? void 0 : memberNamed(level, name);
|
|
742
|
+
return member !== void 0 && level !== void 0 && isAuthoringTypeChoiceDescriptor(member) ? {
|
|
743
|
+
descriptor: member,
|
|
744
|
+
constructorNamed: typeConstructorLookup(level)
|
|
745
|
+
} : void 0;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* The column a call of the type constructor or type choice `name`, in one level of a type namespace, makes from its arguments. A type choice's arguments choose a constructor of the same level, which is instantiated with the arguments it passes on.
|
|
749
|
+
*/
|
|
750
|
+
function instantiateAuthoringTypeCall(namespace, name, args) {
|
|
751
|
+
const member = memberNamed(namespace, name);
|
|
752
|
+
if (member !== void 0 && isAuthoringTypeConstructorDescriptor(member)) return instantiateAuthoringTypeConstructor(member, args);
|
|
753
|
+
if (member === void 0 || !isAuthoringTypeChoiceDescriptor(member)) throw new InternalError(`"${name}" is not a type constructor or type choice of this namespace.`);
|
|
754
|
+
const chosen = resolveAuthoringTypeChoice({
|
|
755
|
+
helperPath: name,
|
|
756
|
+
descriptor: member,
|
|
757
|
+
args,
|
|
758
|
+
constructorNamed: typeConstructorLookup(namespace)
|
|
759
|
+
});
|
|
760
|
+
return instantiateAuthoringTypeConstructor(chosen.descriptor, chosen.args);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Derives the scalar view of an assembled authoring type namespace: every
|
|
764
|
+
* **top-level** type constructor that is instantiable with an empty argument
|
|
765
|
+
* list — all declared args optional and no entity-ref argument. A bare type
|
|
766
|
+
* name `T` in a schema is semantically the zero-arg instantiation `T()`, so
|
|
767
|
+
* each entry is exactly what that call produces (defaulted template values
|
|
768
|
+
* applied, absent optional-arg typeParams keys omitted). Constructors
|
|
769
|
+
* registered under a namespace segment, constructors with required args, and
|
|
770
|
+
* entity-ref constructors are not scalars and are excluded.
|
|
771
|
+
*
|
|
772
|
+
* Eligibility needs no template inspection: templates that cannot resolve
|
|
773
|
+
* for their legal call shapes are rejected at the composition boundary by
|
|
774
|
+
* {@link assertResolvableTypeConstructorTemplates}, so the zero-arg
|
|
775
|
+
* instantiation below cannot fail for an eligible constructor.
|
|
776
|
+
*/
|
|
777
|
+
function collectScalarTypeConstructors(namespace) {
|
|
778
|
+
const result = /* @__PURE__ */ new Map();
|
|
779
|
+
for (const [name, value] of Object.entries(namespace)) {
|
|
780
|
+
if (isAuthoringTypeChoiceDescriptor(value)) {
|
|
781
|
+
result.set(name, instantiateAuthoringTypeCall(namespace, name, []));
|
|
782
|
+
continue;
|
|
741
783
|
}
|
|
784
|
+
if (!isAuthoringTypeConstructorDescriptor(value)) continue;
|
|
785
|
+
if (value.entityRefArg !== void 0) continue;
|
|
786
|
+
if (value.args?.some((arg) => arg.optional !== true)) continue;
|
|
787
|
+
result.set(name, instantiateAuthoringTypeConstructor(value, []));
|
|
742
788
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
789
|
+
return result;
|
|
790
|
+
}
|
|
791
|
+
function assertTypeChoiceValid(path, descriptor, contributedBy, level) {
|
|
792
|
+
const invalidError = (detail) => runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Type choice "${path}" contributed by "${contributedBy}" ${detail}`, {
|
|
793
|
+
packId: contributedBy,
|
|
794
|
+
contribution: path
|
|
795
|
+
});
|
|
796
|
+
const invalid = (detail) => {
|
|
797
|
+
throw invalidError(detail);
|
|
798
|
+
};
|
|
799
|
+
const constructorNamed = typeConstructorLookup(level);
|
|
800
|
+
const options = descriptor.args.filter(isAuthoringTypeChoiceOption);
|
|
801
|
+
const passed = descriptor.args.filter((argument) => !isAuthoringTypeChoiceOption(argument));
|
|
802
|
+
for (const option of options) if (!option.values.includes(option.default)) invalid(`defaults option "${option.name}" to ${option.default}, which it does not list.`);
|
|
803
|
+
for (const row of descriptor.choices) {
|
|
804
|
+
if (!(Object.keys(row.when).length === options.length && options.every((option) => option.values.includes(row.when[option.name] ?? "")))) invalid(`has a row for ${typeChoiceCombinationText(row)}, which does not give every option one of its values.`);
|
|
805
|
+
const names = options.map((option) => option.name);
|
|
806
|
+
const chosen = new Map(Object.entries(row.when));
|
|
807
|
+
if (descriptor.choices.filter((other) => rowMatches(other, chosen, names)).length > 1) invalid(`has two rows for ${typeChoiceCombinationText(row)}; each combination chooses one type.`);
|
|
808
|
+
const chosenType = constructorNamed(row.type);
|
|
809
|
+
if (chosenType === void 0) throw invalidError(`chooses "${row.type}", which is not a type constructor "${contributedBy}" registers beside it.`);
|
|
810
|
+
for (const name of Object.keys(row.defaults ?? {})) {
|
|
811
|
+
if (!passed.some((argument) => argument.name === name)) invalid(`gives a default for "${name}", which is not an argument it passes on.`);
|
|
812
|
+
if (!chosenType.args?.some((parameter) => parameter.name === name)) invalid(`gives a default for "${name}" to "${row.type}", which takes no argument of that name.`);
|
|
813
|
+
}
|
|
814
|
+
for (const argument of passed) {
|
|
815
|
+
const parameter = chosenType.args?.find((candidate) => candidate.name === argument.name);
|
|
816
|
+
if (parameter?.kind === "value" && parameter.dataType !== argument.dataType) invalid(`passes "${argument.name}" as a value of data type "${argument.dataType}" to "${row.type}", which takes "${parameter.dataType}".`);
|
|
817
|
+
}
|
|
818
|
+
chosenType.args?.forEach((parameter, index) => {
|
|
819
|
+
if (parameter.optional === true) return;
|
|
820
|
+
if (parameter.name !== void 0 && Object.hasOwn(row.defaults ?? {}, parameter.name)) return;
|
|
821
|
+
const required = parameter.name === void 0 ? `an unnamed argument ${index + 1}` : `"${parameter.name}"`;
|
|
822
|
+
invalid(`has a row for ${typeChoiceCombinationText(row)} that chooses "${row.type}", which requires ${required}, and gives it no default.`);
|
|
758
823
|
});
|
|
759
824
|
}
|
|
825
|
+
const defaults = {
|
|
826
|
+
when: Object.fromEntries(options.map((option) => [option.name, option.default])),
|
|
827
|
+
type: ""
|
|
828
|
+
};
|
|
829
|
+
const names = options.map((option) => option.name);
|
|
830
|
+
const chosen = new Map(Object.entries(defaults.when));
|
|
831
|
+
if (!descriptor.choices.some((row) => rowMatches(row, chosen, names))) invalid(`has no row for its defaults ${typeChoiceCombinationText(defaults)}, so it cannot be written bare.`);
|
|
760
832
|
}
|
|
761
833
|
/**
|
|
762
|
-
*
|
|
834
|
+
* Refuses a type choice of a component's `contributed` type namespace whose table cannot be resolved: a row that names no type constructor the same component contributes at the same level, a combination or default an option does not list, defaults with no row, a parameter default for an argument it does not pass on, a passed-on argument of another data type than the constructor takes, or a row whose constructor requires an argument the row gives no default. ADR 279: each row names an explicit type of the same target.
|
|
763
835
|
*/
|
|
764
|
-
function
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
lookup,
|
|
775
|
-
declaredTypes: declared,
|
|
776
|
-
codecs: components.flatMap((component) => (component.types?.codecTypes?.codecDescriptors ?? []).map(({ codecId, dataType }) => ({
|
|
777
|
-
codecId,
|
|
778
|
-
dataType,
|
|
779
|
-
contributedBy: contributedBy(component)
|
|
780
|
-
}))),
|
|
781
|
-
authoringEntries,
|
|
782
|
-
textDataTypes: textDataTypesOf(components)
|
|
783
|
-
});
|
|
784
|
-
const support = {
|
|
785
|
-
entries,
|
|
786
|
-
lookup,
|
|
787
|
-
dataTypeOfCodec,
|
|
788
|
-
textDataTypes: [...new Set(components.flatMap((component) => component.authoring?.textDataTypes ?? []))]
|
|
789
|
-
};
|
|
790
|
-
const writable = writableDataTypes(authoringEntries);
|
|
791
|
-
for (const contributed of components.flatMap(contributedHelpers)) enforceValueArguments(support, contributed, writable);
|
|
792
|
-
return {
|
|
793
|
-
support,
|
|
794
|
-
declared
|
|
795
|
-
};
|
|
836
|
+
function assertTypeChoicesValid(contributed, contributedBy, path = []) {
|
|
837
|
+
for (const [name, value] of Object.entries(contributed)) {
|
|
838
|
+
const currentPath = [...path, name];
|
|
839
|
+
if (isAuthoringTypeChoiceDescriptor(value)) {
|
|
840
|
+
assertTypeChoiceValid(currentPath.join("."), value, contributedBy, contributed);
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
const level = subNamespace(value);
|
|
844
|
+
if (level !== void 0) assertTypeChoicesValid(level, contributedBy, currentPath);
|
|
845
|
+
}
|
|
796
846
|
}
|
|
797
847
|
const TAGGED_LITERAL_MAX_BYTES = 65536;
|
|
798
848
|
/** The message a tagged literal's canonicalization failure is reported with, in PSL and in TypeScript. */
|
|
@@ -981,6 +1031,167 @@ function holdsCharacterThatNeedsAnEscape(text) {
|
|
|
981
1031
|
}
|
|
982
1032
|
return false;
|
|
983
1033
|
}
|
|
1034
|
+
const UNKNOWN_CONTRIBUTOR = "<unknown>";
|
|
1035
|
+
/** Merge every component's PSL support for its data types, refusing two claims on one key. */
|
|
1036
|
+
function assembleAuthoringDataTypes(components) {
|
|
1037
|
+
const merged = {};
|
|
1038
|
+
const owners = /* @__PURE__ */ new Map();
|
|
1039
|
+
for (const component of components) {
|
|
1040
|
+
const contributedBy = component.id ?? UNKNOWN_CONTRIBUTOR;
|
|
1041
|
+
for (const [key, entry] of Object.entries(component.authoring?.dataTypes ?? {})) {
|
|
1042
|
+
const existingOwner = owners.get(key);
|
|
1043
|
+
if (existingOwner !== void 0) throw runtimeError("CONTRACT.DATA_TYPE_ENTRY_DUPLICATE", `Duplicate authoring entry for "${key}". Component "${contributedBy}" conflicts with "${existingOwner}".`, {
|
|
1044
|
+
key,
|
|
1045
|
+
contributedBy,
|
|
1046
|
+
owner: existingOwner
|
|
1047
|
+
});
|
|
1048
|
+
owners.set(key, contributedBy);
|
|
1049
|
+
merged[key] = entry;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return merged;
|
|
1053
|
+
}
|
|
1054
|
+
function descriptorsIn(namespace, isLeaf, path = []) {
|
|
1055
|
+
return Object.entries(namespace ?? {}).flatMap(([key, value]) => {
|
|
1056
|
+
const currentPath = [...path, key];
|
|
1057
|
+
if (isLeaf(value)) return [{
|
|
1058
|
+
path: currentPath.join("."),
|
|
1059
|
+
descriptor: value
|
|
1060
|
+
}];
|
|
1061
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return [];
|
|
1062
|
+
return descriptorsIn(value, isLeaf, currentPath);
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
/** Every type constructor a component contributes. */
|
|
1066
|
+
function contributedHelpers(component) {
|
|
1067
|
+
return descriptorsIn(component.authoring?.type, isAuthoringTypeDescriptor).flatMap(({ path, descriptor }) => isAuthoringTypeConstructorDescriptor(descriptor) ? [{
|
|
1068
|
+
path,
|
|
1069
|
+
descriptor,
|
|
1070
|
+
contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
|
|
1071
|
+
}] : []);
|
|
1072
|
+
}
|
|
1073
|
+
/** The data types a contract source can write: each entry's own, and every type a plain-number entry classifies a number as. */
|
|
1074
|
+
function writableDataTypes(entries) {
|
|
1075
|
+
return new Set(entries.flatMap(({ key, entry }) => [key, ...entry.written.kind === "plain" && entry.written.syntax === "number" ? entry.written.types : []]));
|
|
1076
|
+
}
|
|
1077
|
+
/** Refuses a value argument whose data type is unregistered, or that no contract source can write, directly or through a cast, and a type-constructor argument that is not a value. */
|
|
1078
|
+
function enforceValueArguments(support, contributed, writable) {
|
|
1079
|
+
const { path, descriptor, contributedBy } = contributed;
|
|
1080
|
+
for (const [index, argument] of (descriptor.args ?? []).entries()) {
|
|
1081
|
+
const label = `Argument ${argument.name === void 0 ? `#${index + 1}` : `"${argument.name}"`} of type constructor "${path}"`;
|
|
1082
|
+
const argumentKind = argument.kind;
|
|
1083
|
+
if (argumentKind !== "value") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `${label} contributed by "${contributedBy}" is an argument of kind "${argumentKind}", but a type constructor's argument is a value of a data type. Declare it as { kind: 'value', dataType: ... }, naming the data type its value belongs to.`, {
|
|
1084
|
+
packId: contributedBy,
|
|
1085
|
+
contribution: path,
|
|
1086
|
+
reason: "type-constructor-argument-not-a-value"
|
|
1087
|
+
});
|
|
1088
|
+
const type = support.lookup.get(argument.dataType);
|
|
1089
|
+
if (type === void 0) throw runtimeError("CONTRACT.DATA_TYPE_UNREGISTERED", `${label} names data type "${argument.dataType}", which no component registers. Contributed by "${contributedBy}".`, {
|
|
1090
|
+
dataType: argument.dataType,
|
|
1091
|
+
contributedBy
|
|
1092
|
+
});
|
|
1093
|
+
if (![argument.dataType, ...Object.keys(type.casts)].some((admittedType) => writable.has(admittedType))) throw runtimeError("CONTRACT.DATA_TYPE_NOT_WRITABLE", `${label} contributed by "${contributedBy}" takes a value of data type "${argument.dataType}", which no contract source can write.`, {
|
|
1094
|
+
dataType: argument.dataType,
|
|
1095
|
+
contributedBy
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function textDataTypesOf(components) {
|
|
1100
|
+
return components.flatMap((component) => (component.authoring?.textDataTypes ?? []).map((dataType) => ({
|
|
1101
|
+
dataType,
|
|
1102
|
+
contributedBy: component.id ?? UNKNOWN_CONTRIBUTOR
|
|
1103
|
+
})));
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* The checks assembly makes across components on their data types, each naming the component and the id at fault:
|
|
1107
|
+
*
|
|
1108
|
+
* 1. every codec names a registered data type;
|
|
1109
|
+
* 2. every authoring entry, and every type a number classifier returns, names a registered data type;
|
|
1110
|
+
* 3. every type a cast takes values of is registered and can be written, because a cast from a type nobody can write is never exercised;
|
|
1111
|
+
* 4. no two entries claim one tag or one plain form;
|
|
1112
|
+
* 5. every text data type a component names is registered.
|
|
1113
|
+
*/
|
|
1114
|
+
function enforceDataTypeAssemblyInvariants(input) {
|
|
1115
|
+
const unregistered = (contributedBy, id, what) => {
|
|
1116
|
+
throw runtimeError("CONTRACT.DATA_TYPE_UNREGISTERED", `${what} names data type "${id}", which no component registers. Contributed by "${contributedBy}".`, {
|
|
1117
|
+
dataType: id,
|
|
1118
|
+
contributedBy
|
|
1119
|
+
});
|
|
1120
|
+
};
|
|
1121
|
+
for (const codec of input.codecs) if (!input.lookup.has(codec.dataType)) unregistered(codec.contributedBy, codec.dataType, `Codec "${codec.codecId}"`);
|
|
1122
|
+
for (const { key, entry, contributedBy } of input.authoringEntries) {
|
|
1123
|
+
if (!input.lookup.has(key)) unregistered(contributedBy, key, "Authoring entry");
|
|
1124
|
+
if (entry.written.kind === "plain" && entry.written.syntax === "number") {
|
|
1125
|
+
for (const classified of entry.written.types) if (!input.lookup.has(classified)) unregistered(contributedBy, classified, `The classifier of authoring entry "${key}"`);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
for (const { dataType, contributedBy } of input.textDataTypes) if (!input.lookup.has(dataType)) unregistered(contributedBy, dataType, "The text data types");
|
|
1129
|
+
const writable = writableDataTypes(input.authoringEntries);
|
|
1130
|
+
for (const { type, contributedBy } of input.declaredTypes) {
|
|
1131
|
+
const sources = [...Object.keys(type.casts), ...type.listCast?.of ?? []];
|
|
1132
|
+
for (const source of sources) {
|
|
1133
|
+
if (!input.lookup.has(source)) unregistered(contributedBy, source, `The casts of data type "${type.id}"`);
|
|
1134
|
+
if (!writable.has(source)) throw runtimeError("CONTRACT.DATA_TYPE_NOT_WRITABLE", `Data type "${type.id}" casts from "${source}", which no contract source can write, so the cast is never exercised. Contributed by "${contributedBy}".`, {
|
|
1135
|
+
dataType: type.id,
|
|
1136
|
+
source,
|
|
1137
|
+
contributedBy
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
const claimants = /* @__PURE__ */ new Map();
|
|
1142
|
+
for (const { key, entry, contributedBy } of input.authoringEntries) {
|
|
1143
|
+
const written = entry.written;
|
|
1144
|
+
const claim = written.kind === "tag" ? `tag "${written.tag}"` : `plain ${written.syntax}`;
|
|
1145
|
+
const existing = claimants.get(claim);
|
|
1146
|
+
if (existing !== void 0) throw runtimeError("CONTRACT.DATA_TYPE_WRITTEN_FORM_DUPLICATE", `Two authoring entries claim the ${claim}: "${key}" from "${contributedBy}" conflicts with "${existing.key}" from "${existing.contributedBy}".`, {
|
|
1147
|
+
claim,
|
|
1148
|
+
key,
|
|
1149
|
+
contributedBy,
|
|
1150
|
+
owner: existing.key,
|
|
1151
|
+
ownerContributedBy: existing.contributedBy
|
|
1152
|
+
});
|
|
1153
|
+
claimants.set(claim, {
|
|
1154
|
+
key,
|
|
1155
|
+
contributedBy
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* The data types the components register, with their authoring entries, as every contract source reads values with. Refuses two registrations of one data type or one entry key, every case {@link enforceDataTypeAssemblyInvariants} lists, a value argument of a type constructor whose data type is unregistered or that no contract source can write, and a type-constructor argument that is not a value. ADR 254.
|
|
1161
|
+
*/
|
|
1162
|
+
function assembleDataTypeSupport(components, dataTypeOfCodec) {
|
|
1163
|
+
const { lookup, declared } = assembleDataTypes(components);
|
|
1164
|
+
const entries = assembleAuthoringDataTypes(components);
|
|
1165
|
+
const contributedBy = (component) => component.id ?? UNKNOWN_CONTRIBUTOR;
|
|
1166
|
+
const authoringEntries = components.flatMap((component) => Object.entries(component.authoring?.dataTypes ?? {}).map(([key, entry]) => ({
|
|
1167
|
+
key,
|
|
1168
|
+
entry,
|
|
1169
|
+
contributedBy: contributedBy(component)
|
|
1170
|
+
})));
|
|
1171
|
+
enforceDataTypeAssemblyInvariants({
|
|
1172
|
+
lookup,
|
|
1173
|
+
declaredTypes: declared,
|
|
1174
|
+
codecs: components.flatMap((component) => (component.types?.codecTypes?.codecDescriptors ?? []).map(({ codecId, dataType }) => ({
|
|
1175
|
+
codecId,
|
|
1176
|
+
dataType,
|
|
1177
|
+
contributedBy: contributedBy(component)
|
|
1178
|
+
}))),
|
|
1179
|
+
authoringEntries,
|
|
1180
|
+
textDataTypes: textDataTypesOf(components)
|
|
1181
|
+
});
|
|
1182
|
+
const support = {
|
|
1183
|
+
entries,
|
|
1184
|
+
lookup,
|
|
1185
|
+
dataTypeOfCodec,
|
|
1186
|
+
textDataTypes: [...new Set(components.flatMap((component) => component.authoring?.textDataTypes ?? []))]
|
|
1187
|
+
};
|
|
1188
|
+
const writable = writableDataTypes(authoringEntries);
|
|
1189
|
+
for (const contributed of components.flatMap(contributedHelpers)) enforceValueArguments(support, contributed, writable);
|
|
1190
|
+
return {
|
|
1191
|
+
support,
|
|
1192
|
+
declared
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
984
1195
|
/**
|
|
985
1196
|
* Canonical id for the wall-clock-now mutation default generator. It flows to the control-plane descriptor, to each family's runtime generator, and to the `now()` binding of the codecs that store it.
|
|
986
1197
|
*/
|
|
@@ -1019,6 +1230,6 @@ function temporalTypeAliases(type, value) {
|
|
|
1019
1230
|
};
|
|
1020
1231
|
}
|
|
1021
1232
|
//#endregion
|
|
1022
|
-
export {
|
|
1233
|
+
export { validateAuthoringTypeChoiceParams as $, isAuthoringTypeAliasDescriptor as A, resolveAuthoringTypeChoice as B, instantiateAuthoringTypeCall as C, isAuthoringEntityTypeDescriptor as D, isAuthoringArgRef as E, mergeAuthoringAttributeSpecs as F, temporalTypeAliases as G, resolvePslBacktickEscapes as H, mergeAuthoringNamespaces as I, typeChoiceArgumentsFromObject as J, timestampNowControlDescriptor as K, printTaggedLiteral as L, isAuthoringTypeChoiceOption as M, isAuthoringTypeConstructorDescriptor as N, isAuthoringModelAttributeDescriptor as O, isAuthoringTypeDescriptor as P, validateAuthoringHelperArguments as Q, printedTaggedLiteralReadsBack as R, instantiateAuthoringTypeAlias as S, instantiateAuthoringTypeConstructorFromValues as T, resolveTemplateTagEscapes as U, resolveEnumCodecId as V, resolveTypeAliasGenerators as W, typeConstructorLookup as X, typeChoiceCombinationText as Y, unknownTypeChoiceArgumentMessage as Z, describeTaggedLiteralFailure as _, assembleDataTypeSupport as a, getAuthoringTypeConstructor as b, assertResolvableTypeConstructorTemplates as c, authoringTypeNamespaceLevel as d, validateAuthoringTypeParams as et, canonicalizeTaggedLiteralBody as f, contributedHelpers as g, collectScalarTypeConstructors as h, assembleAuthoringDataTypes as i, isAuthoringTypeChoiceDescriptor as j, isAuthoringPslBlockDescriptor as k, assertTypeAliasesValid as l, collectContributedDescriptorPaths as m, TAGGED_LITERAL_MAX_BYTES as n, assertNoAuthoringFieldNamespace as o, classifyEnumMemberType as p, tsTaggedTemplateSource as q, TIMESTAMP_NOW_GENERATOR_ID as r, assertNoCrossRegistryCollisions as s, AUTHORING_TYPE_DESCRIPTOR_KINDS as t, assertTypeChoicesValid as u, flushAuthoringWarnings as v, instantiateAuthoringTypeConstructor as w, instantiateAuthoringEntityType as x, getAuthoringTypeChoice as y, resolveAuthoringTemplateValue as z };
|
|
1023
1234
|
|
|
1024
|
-
//# sourceMappingURL=temporal-type-aliases-
|
|
1235
|
+
//# sourceMappingURL=temporal-type-aliases-BI3SL5iB-DIP8j4Gv.mjs.map
|