@prisma/orm-framework 0.16.0
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/LICENSE +201 -0
- package/README.md +27 -0
- package/dist/abortable-CQO6uG9F.mjs +39 -0
- package/dist/abortable-CQO6uG9F.mjs.map +1 -0
- package/dist/abortable-DBbAaT_4.d.mts +29 -0
- package/dist/abortable-DBbAaT_4.d.mts.map +1 -0
- package/dist/apply-specifier-default-control-policy-CAxiXxKg.d.mts +7 -0
- package/dist/apply-specifier-default-control-policy-CAxiXxKg.d.mts.map +1 -0
- package/dist/apply-specifier-default-control-policy-CsYHsfTF.mjs +12 -0
- package/dist/apply-specifier-default-control-policy-CsYHsfTF.mjs.map +1 -0
- package/dist/array-equal-28xupwIB.mjs +26 -0
- package/dist/array-equal-28xupwIB.mjs.map +1 -0
- package/dist/array-equal-dUd-VPlk.d.mts +22 -0
- package/dist/array-equal-dUd-VPlk.d.mts.map +1 -0
- package/dist/assertions-BEQnOIQd.d.mts +31 -0
- package/dist/assertions-BEQnOIQd.d.mts.map +1 -0
- package/dist/assertions-Cz-GWH8P.mjs +36 -0
- package/dist/assertions-Cz-GWH8P.mjs.map +1 -0
- package/dist/authoring-Dd7p6pTS.d.mts +1 -0
- package/dist/canonical-stringify-Bl6agy_g.d.mts +51 -0
- package/dist/canonical-stringify-Bl6agy_g.d.mts.map +1 -0
- package/dist/canonical-stringify-DY4NaAJi.mjs +104 -0
- package/dist/canonical-stringify-DY4NaAJi.mjs.map +1 -0
- package/dist/canonicalization-DFpB09nP-4OdB2nsy.d.mts +69 -0
- package/dist/canonicalization-DFpB09nP-4OdB2nsy.d.mts.map +1 -0
- package/dist/canonicalization-path-match-CNgHuwM_-CCPBeUuk.mjs +25 -0
- package/dist/canonicalization-path-match-CNgHuwM_-CCPBeUuk.mjs.map +1 -0
- package/dist/capabilities-CPj7MfXO-GRkp0Q_D.mjs +64 -0
- package/dist/capabilities-CPj7MfXO-GRkp0Q_D.mjs.map +1 -0
- package/dist/capabilities-Cupq4-1--C71ORI3N.d.mts +34 -0
- package/dist/capabilities-Cupq4-1--C71ORI3N.d.mts.map +1 -0
- package/dist/casts-D29CHGrr.d.mts +78 -0
- package/dist/casts-D29CHGrr.d.mts.map +1 -0
- package/dist/casts-DpaahrlC-Bd5n2coI.mjs +82 -0
- package/dist/casts-DpaahrlC-Bd5n2coI.mjs.map +1 -0
- package/dist/codec-Cly9VPoA.mjs +78 -0
- package/dist/codec-Cly9VPoA.mjs.map +1 -0
- package/dist/codec-D3GVAkR_.d.mts +116 -0
- package/dist/codec-D3GVAkR_.d.mts.map +1 -0
- package/dist/codec-types-XJO6eC9U-B_K2q0zm.d.mts +221 -0
- package/dist/codec-types-XJO6eC9U-B_K2q0zm.d.mts.map +1 -0
- package/dist/components-CawuxTia.d.mts +1 -0
- package/dist/components.d.mts +20 -0
- package/dist/components.mjs +15 -0
- package/dist/components__authoring.d.mts +3 -0
- package/dist/components__authoring.mjs +2 -0
- package/dist/components__codec.d.mts +3 -0
- package/dist/components__codec.mjs +3 -0
- package/dist/components__components.d.mts +4 -0
- package/dist/components__components.mjs +3 -0
- package/dist/components__control.d.mts +4 -0
- package/dist/components__control.mjs +2 -0
- package/dist/components__emission.d.mts +4 -0
- package/dist/components__emission.mjs +2 -0
- package/dist/components__execution.d.mts +2 -0
- package/dist/components__execution.mjs +2 -0
- package/dist/components__ir.d.mts +3 -0
- package/dist/components__ir.mjs +3 -0
- package/dist/components__psl-ast.d.mts +4 -0
- package/dist/components__psl-ast.mjs +2 -0
- package/dist/components__runtime.d.mts +2 -0
- package/dist/components__runtime.mjs +3 -0
- package/dist/components__utils.d.mts +2 -0
- package/dist/components__utils.mjs +2 -0
- package/dist/config-errors-CBdiX587-DwIyJIX9.mjs +9 -0
- package/dist/config-errors-CBdiX587-DwIyJIX9.mjs.map +1 -0
- package/dist/config-types-Cf9lVsHR.mjs +62 -0
- package/dist/config-types-Cf9lVsHR.mjs.map +1 -0
- package/dist/config-types-W-87vhZ4-BgYaH8YO.d.mts +162 -0
- package/dist/config-types-W-87vhZ4-BgYaH8YO.d.mts.map +1 -0
- package/dist/config-types-zrHI32Om.d.mts +1 -0
- package/dist/config-validation-ByGTw6zQ.mjs +99 -0
- package/dist/config-validation-ByGTw6zQ.mjs.map +1 -0
- package/dist/config-validation-DXggMTZf.d.mts +14 -0
- package/dist/config-validation-DXggMTZf.d.mts.map +1 -0
- package/dist/config.d.mts +4 -0
- package/dist/config.mjs +3 -0
- package/dist/config__config-types.d.mts +3 -0
- package/dist/config__config-types.mjs +2 -0
- package/dist/config__config-validation.d.mts +2 -0
- package/dist/config__config-validation.mjs +2 -0
- package/dist/contract-authoring.d.mts +213 -0
- package/dist/contract-authoring.d.mts.map +1 -0
- package/dist/contract-authoring.mjs +133 -0
- package/dist/contract-authoring.mjs.map +1 -0
- package/dist/contract-types-CkdMH7F7-9EHXSwbH.d.mts +77 -0
- package/dist/contract-types-CkdMH7F7-9EHXSwbH.d.mts.map +1 -0
- package/dist/contract-validation-error-DEiWp_EI-CRwtUgRw.mjs +14 -0
- package/dist/contract-validation-error-DEiWp_EI-CRwtUgRw.mjs.map +1 -0
- package/dist/contract-validation-error-R7cMoK04.d.mts +11 -0
- package/dist/contract-validation-error-R7cMoK04.d.mts.map +1 -0
- package/dist/contract.d.mts +14 -0
- package/dist/contract.mjs +13 -0
- package/dist/contract__apply-specifier-default-control-policy.d.mts +2 -0
- package/dist/contract__apply-specifier-default-control-policy.mjs +2 -0
- package/dist/contract__contract-validation-error.d.mts +2 -0
- package/dist/contract__contract-validation-error.mjs +2 -0
- package/dist/contract__default-namespace.d.mts +2 -0
- package/dist/contract__default-namespace.mjs +2 -0
- package/dist/contract__enum-accessor.d.mts +2 -0
- package/dist/contract__enum-accessor.mjs +2 -0
- package/dist/contract__hashing-utils.d.mts +2 -0
- package/dist/contract__hashing-utils.mjs +3 -0
- package/dist/contract__hashing.d.mts +3 -0
- package/dist/contract__hashing.mjs +2 -0
- package/dist/contract__is-plain-record.d.mts +2 -0
- package/dist/contract__is-plain-record.mjs +2 -0
- package/dist/contract__resolve-domain-model.d.mts +2 -0
- package/dist/contract__resolve-domain-model.mjs +2 -0
- package/dist/contract__types.d.mts +6 -0
- package/dist/contract__types.mjs +5 -0
- package/dist/contract__validate-domain.d.mts +2 -0
- package/dist/contract__validate-domain.mjs +2 -0
- package/dist/control-B87KWI_K-C_R8WfEr.d.mts +213 -0
- package/dist/control-B87KWI_K-C_R8WfEr.d.mts.map +1 -0
- package/dist/control-CBvTj7Ia.d.mts +1383 -0
- package/dist/control-CBvTj7Ia.d.mts.map +1 -0
- package/dist/control-DTouE89s.mjs +621 -0
- package/dist/control-DTouE89s.mjs.map +1 -0
- package/dist/control-Ftiau058-CCeJcAVQ.mjs +284 -0
- package/dist/control-Ftiau058-CCeJcAVQ.mjs.map +1 -0
- package/dist/declarations-DR6To8_k-BFwkCGeP.mjs +1046 -0
- package/dist/declarations-DR6To8_k-BFwkCGeP.mjs.map +1 -0
- package/dist/default-namespace-D4vCwkXg-BaiW8LNK.mjs +39 -0
- package/dist/default-namespace-D4vCwkXg-BaiW8LNK.mjs.map +1 -0
- package/dist/default-namespace-D5X_k6hJ-GH8P1ror.d.mts +26 -0
- package/dist/default-namespace-D5X_k6hJ-GH8P1ror.d.mts.map +1 -0
- package/dist/defined-BQWA85QH-BRSBMULx.mjs +31 -0
- package/dist/defined-BQWA85QH-BRSBMULx.mjs.map +1 -0
- package/dist/defined-BSXuxrnl.d.mts +28 -0
- package/dist/defined-BSXuxrnl.d.mts.map +1 -0
- package/dist/domain-envelope-D6Wn9AmZ-BqZKTT9U.d.mts +359 -0
- package/dist/domain-envelope-D6Wn9AmZ-BqZKTT9U.d.mts.map +1 -0
- package/dist/emission-CeoAV9mj.mjs +26 -0
- package/dist/emission-CeoAV9mj.mjs.map +1 -0
- package/dist/emission-DeoQufVd.d.mts +1 -0
- package/dist/emission-types-hfRVB_Yw-DpQ3hISB.d.mts +75 -0
- package/dist/emission-types-hfRVB_Yw-DpQ3hISB.d.mts.map +1 -0
- package/dist/enum-accessor-Db5DaTNX.mjs +35 -0
- package/dist/enum-accessor-Db5DaTNX.mjs.map +1 -0
- package/dist/enum-accessor-PH5vjghI.d.mts +85 -0
- package/dist/enum-accessor-PH5vjghI.d.mts.map +1 -0
- package/dist/errors.d.mts +4 -0
- package/dist/errors.mjs +4 -0
- package/dist/errors__control.d.mts +2 -0
- package/dist/errors__control.mjs +2 -0
- package/dist/errors__execution.d.mts +2 -0
- package/dist/errors__execution.mjs +2 -0
- package/dist/errors__migration.d.mts +2 -0
- package/dist/errors__migration.mjs +2 -0
- package/dist/execution-BNwBzmRd.mjs +40 -0
- package/dist/execution-BNwBzmRd.mjs.map +1 -0
- package/dist/execution-BbOD4GyR.mjs +164 -0
- package/dist/execution-BbOD4GyR.mjs.map +1 -0
- package/dist/execution-Bo5Bu2Ys.d.mts +79 -0
- package/dist/execution-Bo5Bu2Ys.d.mts.map +1 -0
- package/dist/execution-MOde1lmD.d.mts +98 -0
- package/dist/execution-MOde1lmD.d.mts.map +1 -0
- package/dist/framework-authoring-7YMP9TwM-C9P-N6_a.d.mts +777 -0
- package/dist/framework-authoring-7YMP9TwM-C9P-N6_a.d.mts.map +1 -0
- package/dist/framework-authoring-CDEvlouU-mlMWSksD.mjs +698 -0
- package/dist/framework-authoring-CDEvlouU-mlMWSksD.mjs.map +1 -0
- package/dist/framework-components-D6j4Y5K7-RW9H184y.mjs +27 -0
- package/dist/framework-components-D6j4Y5K7-RW9H184y.mjs.map +1 -0
- package/dist/framework-components-MFoo0sYx-G_6k9jt4.d.mts +388 -0
- package/dist/framework-components-MFoo0sYx-G_6k9jt4.d.mts.map +1 -0
- package/dist/hash-content-Bugg_nZn.mjs +63 -0
- package/dist/hash-content-Bugg_nZn.mjs.map +1 -0
- package/dist/hash-content-DwEUh-Rx.d.mts +59 -0
- package/dist/hash-content-DwEUh-Rx.d.mts.map +1 -0
- package/dist/hashing-BtIZVNYX.mjs +199 -0
- package/dist/hashing-BtIZVNYX.mjs.map +1 -0
- package/dist/hashing-CccSPELN.d.mts +25 -0
- package/dist/hashing-CccSPELN.d.mts.map +1 -0
- package/dist/hashing-utils-DQgS3nOe.mjs +48 -0
- package/dist/hashing-utils-DQgS3nOe.mjs.map +1 -0
- package/dist/hashing-utils-qKu59RSC.d.mts +19 -0
- package/dist/hashing-utils-qKu59RSC.d.mts.map +1 -0
- package/dist/ids.d.mts +44 -0
- package/dist/ids.d.mts.map +1 -0
- package/dist/ids.mjs +96 -0
- package/dist/ids.mjs.map +1 -0
- package/dist/ids__runtime.d.mts +7 -0
- package/dist/ids__runtime.d.mts.map +1 -0
- package/dist/ids__runtime.mjs +31 -0
- package/dist/ids__runtime.mjs.map +1 -0
- package/dist/index-GY2oGH9L.d.mts +120 -0
- package/dist/index-GY2oGH9L.d.mts.map +1 -0
- package/dist/internal-error-BIc-ehme-ouBQPoEL.mjs +24 -0
- package/dist/internal-error-BIc-ehme-ouBQPoEL.mjs.map +1 -0
- package/dist/internal-error-kK8QvlDE.d.mts +19 -0
- package/dist/internal-error-kK8QvlDE.d.mts.map +1 -0
- package/dist/ir-BvE7L9FK.d.mts +359 -0
- package/dist/ir-BvE7L9FK.d.mts.map +1 -0
- package/dist/ir-ChmSSAhX.mjs +200 -0
- package/dist/ir-ChmSSAhX.mjs.map +1 -0
- package/dist/is-plain-record-C9BWiqcw.d.mts +12 -0
- package/dist/is-plain-record-C9BWiqcw.d.mts.map +1 -0
- package/dist/is-plain-record-CUofyVQ7-DWEzdhIx.mjs +16 -0
- package/dist/is-plain-record-CUofyVQ7-DWEzdhIx.mjs.map +1 -0
- package/dist/json-Dkqr3say.d.mts +26 -0
- package/dist/json-Dkqr3say.d.mts.map +1 -0
- package/dist/migration-4VOHVEzx.mjs +118 -0
- package/dist/migration-4VOHVEzx.mjs.map +1 -0
- package/dist/migration-DKbDzBwy.d.mts +74 -0
- package/dist/migration-DKbDzBwy.d.mts.map +1 -0
- package/dist/namespace-id-asbWpwMw-3yxn-tRe.mjs +9 -0
- package/dist/namespace-id-asbWpwMw-3yxn-tRe.mjs.map +1 -0
- package/dist/operations.d.mts +46 -0
- package/dist/operations.d.mts.map +1 -0
- package/dist/operations.mjs +28 -0
- package/dist/operations.mjs.map +1 -0
- package/dist/parse-0ZJjj_2N-WZZ1nlrv.d.mts +427 -0
- package/dist/parse-0ZJjj_2N-WZZ1nlrv.d.mts.map +1 -0
- package/dist/parse-GbZGfMUj-BFSrD2AN.mjs +621 -0
- package/dist/parse-GbZGfMUj-BFSrD2AN.mjs.map +1 -0
- package/dist/promise-D8meygPf.mjs +13 -0
- package/dist/promise-D8meygPf.mjs.map +1 -0
- package/dist/promise-DHJWZv49.d.mts +11 -0
- package/dist/promise-DHJWZv49.d.mts.map +1 -0
- package/dist/psl-ast-BEwO80EH.d.mts +37 -0
- package/dist/psl-ast-BEwO80EH.d.mts.map +1 -0
- package/dist/psl-ast-Chgi8e4o-rSlBk1UV.d.mts +259 -0
- package/dist/psl-ast-Chgi8e4o-rSlBk1UV.d.mts.map +1 -0
- package/dist/psl-ast-DUCvVXbB.mjs +239 -0
- package/dist/psl-ast-DUCvVXbB.mjs.map +1 -0
- package/dist/psl-parser.d.mts +158 -0
- package/dist/psl-parser.d.mts.map +1 -0
- package/dist/psl-parser.mjs +804 -0
- package/dist/psl-parser.mjs.map +1 -0
- package/dist/psl-parser__format.d.mts +12 -0
- package/dist/psl-parser__format.d.mts.map +1 -0
- package/dist/psl-parser__format.mjs +464 -0
- package/dist/psl-parser__format.mjs.map +1 -0
- package/dist/psl-parser__interpret.d.mts +40 -0
- package/dist/psl-parser__interpret.d.mts.map +1 -0
- package/dist/psl-parser__interpret.mjs +25 -0
- package/dist/psl-parser__interpret.mjs.map +1 -0
- package/dist/psl-parser__syntax.d.mts +31 -0
- package/dist/psl-parser__syntax.d.mts.map +1 -0
- package/dist/psl-parser__syntax.mjs +43 -0
- package/dist/psl-parser__syntax.mjs.map +1 -0
- package/dist/psl-parser__tokenizer.d.mts +2 -0
- package/dist/psl-parser__tokenizer.mjs +2 -0
- package/dist/psl-printer.d.mts +37 -0
- package/dist/psl-printer.d.mts.map +1 -0
- package/dist/psl-printer.mjs +393 -0
- package/dist/psl-printer.mjs.map +1 -0
- package/dist/redact-db-url-BlaloOwt.d.mts +22 -0
- package/dist/redact-db-url-BlaloOwt.d.mts.map +1 -0
- package/dist/redact-db-url-CRWJWdB1.mjs +26 -0
- package/dist/redact-db-url-CRWJWdB1.mjs.map +1 -0
- package/dist/resolve-codec-BZF8TZh_-D-xORT9Q.mjs +59 -0
- package/dist/resolve-codec-BZF8TZh_-D-xORT9Q.mjs.map +1 -0
- package/dist/resolve-domain-model-BVSb5wS5-C6Yq0dsD.d.mts +17 -0
- package/dist/resolve-domain-model-BVSb5wS5-C6Yq0dsD.d.mts.map +1 -0
- package/dist/resolve-domain-model-BovPAsW2-8rwyzjxp.mjs +20 -0
- package/dist/resolve-domain-model-BovPAsW2-8rwyzjxp.mjs.map +1 -0
- package/dist/result-Bpupv5vO.d.mts +54 -0
- package/dist/result-Bpupv5vO.d.mts.map +1 -0
- package/dist/result-CBZ8X9mU.mjs +92 -0
- package/dist/result-CBZ8X9mU.mjs.map +1 -0
- package/dist/runtime--RZXG1zP.d.mts +901 -0
- package/dist/runtime--RZXG1zP.d.mts.map +1 -0
- package/dist/runtime-DYTFHGwh.mjs +516 -0
- package/dist/runtime-DYTFHGwh.mjs.map +1 -0
- package/dist/runtime-error-BA9d7XjZ-BlT8t6LB.mjs +40 -0
- package/dist/runtime-error-BA9d7XjZ-BlT8t6LB.mjs.map +1 -0
- package/dist/simplify-deep-Dw9I_ZUl.d.mts +6 -0
- package/dist/simplify-deep-Dw9I_ZUl.d.mts.map +1 -0
- package/dist/structured-error-BVmv2aPB.d.mts +34 -0
- package/dist/structured-error-BVmv2aPB.d.mts.map +1 -0
- package/dist/structured-error-H6WU9Kjt.mjs +31 -0
- package/dist/structured-error-H6WU9Kjt.mjs.map +1 -0
- package/dist/symbol-table-CZ7EVCTL-oYQtrmzq.d.mts +125 -0
- package/dist/symbol-table-CZ7EVCTL-oYQtrmzq.d.mts.map +1 -0
- package/dist/tokenizer-1hAHZzmp-QGPORvmA.mjs +228 -0
- package/dist/tokenizer-1hAHZzmp-QGPORvmA.mjs.map +1 -0
- package/dist/tokenizer-DcYI0Xrq-C-nNE9mE.d.mts +16 -0
- package/dist/tokenizer-DcYI0Xrq-C-nNE9mE.d.mts.map +1 -0
- package/dist/ts-render.d.mts +2 -0
- package/dist/ts-render.mjs +240 -0
- package/dist/ts-render.mjs.map +1 -0
- package/dist/types-ByeQhU9p.d.mts +17 -0
- package/dist/types-ByeQhU9p.d.mts.map +1 -0
- package/dist/types-DGxlljKG.d.mts +7 -0
- package/dist/types-DGxlljKG.d.mts.map +1 -0
- package/dist/types-DgdgskBY.mjs +96 -0
- package/dist/types-DgdgskBY.mjs.map +1 -0
- package/dist/types-import-spec-DRKzrJ20-WYwyCtil.d.mts +14 -0
- package/dist/types-import-spec-DRKzrJ20-WYwyCtil.d.mts.map +1 -0
- package/dist/utils-DMAM0unR.mjs +20 -0
- package/dist/utils-DMAM0unR.mjs.map +1 -0
- package/dist/utils-DeWL_zD9.d.mts +11 -0
- package/dist/utils-DeWL_zD9.d.mts.map +1 -0
- package/dist/utils.d.mts +16 -0
- package/dist/utils.mjs +13 -0
- package/dist/utils__abortable.d.mts +2 -0
- package/dist/utils__abortable.mjs +2 -0
- package/dist/utils__array-equal.d.mts +2 -0
- package/dist/utils__array-equal.mjs +2 -0
- package/dist/utils__assertions.d.mts +2 -0
- package/dist/utils__assertions.mjs +2 -0
- package/dist/utils__canonical-stringify.d.mts +2 -0
- package/dist/utils__canonical-stringify.mjs +2 -0
- package/dist/utils__casts.d.mts +2 -0
- package/dist/utils__casts.mjs +2 -0
- package/dist/utils__defined.d.mts +2 -0
- package/dist/utils__defined.mjs +2 -0
- package/dist/utils__hash-content.d.mts +2 -0
- package/dist/utils__hash-content.mjs +2 -0
- package/dist/utils__internal-error.d.mts +2 -0
- package/dist/utils__internal-error.mjs +2 -0
- package/dist/utils__json.d.mts +2 -0
- package/dist/utils__json.mjs +1 -0
- package/dist/utils__promise.d.mts +2 -0
- package/dist/utils__promise.mjs +2 -0
- package/dist/utils__redact-db-url.d.mts +2 -0
- package/dist/utils__redact-db-url.mjs +2 -0
- package/dist/utils__result.d.mts +2 -0
- package/dist/utils__result.mjs +2 -0
- package/dist/utils__simplify-deep.d.mts +2 -0
- package/dist/utils__simplify-deep.mjs +1 -0
- package/dist/utils__structured-error.d.mts +2 -0
- package/dist/utils__structured-error.mjs +2 -0
- package/dist/utils__types.d.mts +2 -0
- package/dist/utils__types.mjs +1 -0
- package/dist/validate-domain-BNBs-TVv.d.mts +22 -0
- package/dist/validate-domain-BNBs-TVv.d.mts.map +1 -0
- package/dist/validate-domain-BkvFlY3B.mjs +143 -0
- package/dist/validate-domain-BkvFlY3B.mjs.map +1 -0
- package/package.json +109 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
import { t as blindCast } from "./casts-DpaahrlC-Bd5n2coI.mjs";
|
|
2
|
+
import { t as ifDefined } from "./defined-BQWA85QH-BRSBMULx.mjs";
|
|
3
|
+
import { l as isColumnDefaultLiteralInputValue, u as isExecutionMutationDefaultValue } from "./types-DgdgskBY.mjs";
|
|
4
|
+
import { t as InternalError } from "./internal-error-BIc-ehme-ouBQPoEL.mjs";
|
|
5
|
+
import { n as runtimeError } from "./runtime-error-BA9d7XjZ-BlT8t6LB.mjs";
|
|
6
|
+
//#region ../../../1-framework/1-core/framework-components/dist/framework-authoring-CDEvlouU.mjs
|
|
7
|
+
const AUTHORING_WARNING_BATCH_THRESHOLD = 5;
|
|
8
|
+
/**
|
|
9
|
+
* Emits collected authoring warnings once per build, grouped by `code`:
|
|
10
|
+
* a group at or below the threshold itemizes every `message`; above it,
|
|
11
|
+
* one summary — `"<count> <summary>"` followed by the `item` lines — so
|
|
12
|
+
* a build with many hits of one kind does not wall-of-text, and warnings
|
|
13
|
+
* of different codes never batch into each other's summary.
|
|
14
|
+
*/
|
|
15
|
+
function flushAuthoringWarnings(warnings) {
|
|
16
|
+
const groups = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const warning of warnings) {
|
|
18
|
+
const key = `${warning.code}\u0000${warning.summary}`;
|
|
19
|
+
const group = groups.get(key) ?? [];
|
|
20
|
+
group.push(warning);
|
|
21
|
+
groups.set(key, group);
|
|
22
|
+
}
|
|
23
|
+
for (const group of groups.values()) {
|
|
24
|
+
const first = group[0];
|
|
25
|
+
if (first === void 0) continue;
|
|
26
|
+
if (group.length <= AUTHORING_WARNING_BATCH_THRESHOLD) {
|
|
27
|
+
for (const warning of group) process.emitWarning(warning.message, { code: warning.code });
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
process.emitWarning(`${group.length} ${first.summary}\n${group.map((w) => ` - ${w.item}`).join("\n")}`, { code: first.code });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Classifies an `enum` block's members (before codec decoding, which needs
|
|
35
|
+
* the codec chosen first) into which default codec an omitted `@@type`
|
|
36
|
+
* should resolve to:
|
|
37
|
+
*
|
|
38
|
+
* - every member is `bare`, or a `value` whose raw JSON is a string → `'text'`
|
|
39
|
+
* - every member is a `value` whose raw JSON is an integer → `'int'`
|
|
40
|
+
* - anything else (float, bigint, boolean, mixed, or a `ref`/`option`/`list`
|
|
41
|
+
* parameter) → `null`, meaning the caller must require an explicit `@@type`.
|
|
42
|
+
*/
|
|
43
|
+
function classifyEnumMemberType(block) {
|
|
44
|
+
let sawText = false;
|
|
45
|
+
let sawInt = false;
|
|
46
|
+
for (const paramValue of Object.values(block.parameters)) {
|
|
47
|
+
if (paramValue.kind === "bare") {
|
|
48
|
+
sawText = true;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (paramValue.kind !== "value") return null;
|
|
52
|
+
let jsonValue;
|
|
53
|
+
try {
|
|
54
|
+
jsonValue = JSON.parse(paramValue.raw);
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (typeof jsonValue === "string") sawText = true;
|
|
59
|
+
else if (typeof jsonValue === "number" && Number.isInteger(jsonValue)) sawInt = true;
|
|
60
|
+
else return null;
|
|
61
|
+
}
|
|
62
|
+
if (sawText && sawInt) return null;
|
|
63
|
+
if (sawText) return "text";
|
|
64
|
+
if (sawInt) return "int";
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the codec id for an `enum` block. When `@@type` is absent, the codec
|
|
69
|
+
* is inferred from the members via {@link classifyEnumMemberType}; otherwise the
|
|
70
|
+
* explicit `@@type("codec")` argument is parsed. Pushes the appropriate
|
|
71
|
+
* diagnostic and returns `undefined` when neither yields a codec. `codecSpan` is
|
|
72
|
+
* the span downstream codec-validation diagnostics should anchor to. Shared by
|
|
73
|
+
* every family's enum factory so inference and the explicit path stay identical.
|
|
74
|
+
*/
|
|
75
|
+
function resolveEnumCodecId(block, ctx) {
|
|
76
|
+
const sourceId = ctx.sourceId ?? "unknown";
|
|
77
|
+
const typeAttr = block.blockAttributes.find((a) => a.name === "type");
|
|
78
|
+
if (typeAttr === void 0) {
|
|
79
|
+
const inferredKind = classifyEnumMemberType(block);
|
|
80
|
+
if (inferredKind === null || ctx.enumInferenceCodecs === void 0) {
|
|
81
|
+
ctx.diagnostics?.push({
|
|
82
|
+
code: "PSL_ENUM_CANNOT_INFER_TYPE",
|
|
83
|
+
message: `cannot infer @@type for enum "${block.name}"; add an explicit @@type(...)`,
|
|
84
|
+
sourceId,
|
|
85
|
+
span: block.span
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
codecId: ctx.enumInferenceCodecs[inferredKind],
|
|
91
|
+
codecSpan: block.span
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const rawCodecArg = typeAttr.args[0]?.value;
|
|
95
|
+
const codecId = rawCodecArg?.startsWith("\"") && rawCodecArg.endsWith("\"") && rawCodecArg.length >= 2 ? rawCodecArg.slice(1, -1) : void 0;
|
|
96
|
+
if (codecId === void 0) {
|
|
97
|
+
ctx.diagnostics?.push({
|
|
98
|
+
code: "PSL_ENUM_MISSING_TYPE",
|
|
99
|
+
message: `enum "${block.name}" @@type attribute must have a quoted codec id argument`,
|
|
100
|
+
sourceId,
|
|
101
|
+
span: typeAttr.span
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
codecId,
|
|
107
|
+
codecSpan: typeAttr.args[0]?.span ?? typeAttr.span
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function isAuthoringArgRef(value) {
|
|
111
|
+
if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
|
|
112
|
+
const { index, path } = value;
|
|
113
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
|
|
114
|
+
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
function isAuthoringSelectRef(value) {
|
|
118
|
+
if (!isAuthoringTemplateRecord(value) || value["kind"] !== "select") return false;
|
|
119
|
+
const index = value["index"];
|
|
120
|
+
const path = value["path"];
|
|
121
|
+
const cases = value["cases"];
|
|
122
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
|
|
123
|
+
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
|
|
124
|
+
return typeof cases === "object" && cases !== null && !Array.isArray(cases);
|
|
125
|
+
}
|
|
126
|
+
function isAuthoringTemplateRecord(value) {
|
|
127
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
128
|
+
}
|
|
129
|
+
function readTemplateArgumentValue(args, index, path) {
|
|
130
|
+
let value = args[index];
|
|
131
|
+
for (const segment of path ?? []) {
|
|
132
|
+
if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) return;
|
|
133
|
+
value = value[segment];
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
function isAuthoringTypeConstructorDescriptor(value) {
|
|
138
|
+
return "kind" in value && value.kind === "typeConstructor";
|
|
139
|
+
}
|
|
140
|
+
function isAuthoringFieldPresetDescriptor(value) {
|
|
141
|
+
return "kind" in value && value.kind === "fieldPreset";
|
|
142
|
+
}
|
|
143
|
+
function isAuthoringEntityTypeDescriptor(value) {
|
|
144
|
+
return "kind" in value && value.kind === "entity";
|
|
145
|
+
}
|
|
146
|
+
function isAuthoringPslBlockDescriptor(value) {
|
|
147
|
+
return "kind" in value && value.kind === "pslBlock";
|
|
148
|
+
}
|
|
149
|
+
function isAuthoringModelAttributeDescriptor(value) {
|
|
150
|
+
return "kind" in value && value.kind === "modelAttribute";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Returns true when `namespace` is a non-leaf key in `contributions.field`.
|
|
154
|
+
*
|
|
155
|
+
* `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
|
|
156
|
+
* the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
|
|
157
|
+
* registration must NOT be treated as a "namespace" with sub-paths. Callers
|
|
158
|
+
* use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
|
|
159
|
+
*/
|
|
160
|
+
function hasRegisteredFieldNamespace(contributions, namespace) {
|
|
161
|
+
if (contributions?.field === void 0 || !Object.hasOwn(contributions.field, namespace)) return false;
|
|
162
|
+
const value = contributions.field[namespace];
|
|
163
|
+
return value !== void 0 && !isAuthoringFieldPresetDescriptor(value);
|
|
164
|
+
}
|
|
165
|
+
function isCopyableNamespaceObject(value) {
|
|
166
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
167
|
+
const proto = Object.getPrototypeOf(value);
|
|
168
|
+
return proto === Object.prototype || proto === null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Deep structural check run only at the composition boundary (the merge and
|
|
172
|
+
* collect walkers) to classify a raw namespace-tree node as a leaf descriptor.
|
|
173
|
+
* A node counts as a leaf iff its `kind` matches `descriptorKind` AND it
|
|
174
|
+
* carries that kind's required fields.
|
|
175
|
+
*
|
|
176
|
+
* This is boundary validation over `unknown`, NOT a type-predicate: the four
|
|
177
|
+
* exported `isAuthoring*Descriptor` predicates deliberately narrow on `kind`
|
|
178
|
+
* alone and trust the static types. The walkers, by contrast, also receive
|
|
179
|
+
* type-bypassing packs (`as unknown as never` in tests, untyped JS at runtime)
|
|
180
|
+
* whose descriptor-shaped-but-incomplete nodes must be rejected rather than
|
|
181
|
+
* silently treated as sub-namespaces — so the well-formedness check lives here.
|
|
182
|
+
*/
|
|
183
|
+
function isWellFormedDescriptor(value, descriptorKind) {
|
|
184
|
+
if (typeof value !== "object" || value === null) return false;
|
|
185
|
+
if (!("kind" in value) || value.kind !== descriptorKind) return false;
|
|
186
|
+
switch (descriptorKind) {
|
|
187
|
+
case "typeConstructor":
|
|
188
|
+
case "fieldPreset": {
|
|
189
|
+
if (!("output" in value)) return false;
|
|
190
|
+
const output = value.output;
|
|
191
|
+
return typeof output === "object" && output !== null;
|
|
192
|
+
}
|
|
193
|
+
case "entity": {
|
|
194
|
+
if (!("discriminator" in value) || typeof value.discriminator !== "string") return false;
|
|
195
|
+
if (value.discriminator.length === 0) return false;
|
|
196
|
+
if (!("output" in value)) return false;
|
|
197
|
+
const output = value.output;
|
|
198
|
+
if (typeof output !== "object" || output === null) return false;
|
|
199
|
+
const factory = "factory" in output ? output.factory : void 0;
|
|
200
|
+
const template = "template" in output ? output.template : void 0;
|
|
201
|
+
return typeof factory === "function" || template !== void 0;
|
|
202
|
+
}
|
|
203
|
+
case "pslBlock": {
|
|
204
|
+
if (!("keyword" in value) || typeof value.keyword !== "string" || value.keyword.length === 0) return false;
|
|
205
|
+
if (!("discriminator" in value) || typeof value.discriminator !== "string" || value.discriminator.length === 0) return false;
|
|
206
|
+
if (!("name" in value)) return false;
|
|
207
|
+
const name = value.name;
|
|
208
|
+
if (typeof name !== "object" || name === null) return false;
|
|
209
|
+
if (!("required" in name) || typeof name.required !== "boolean") return false;
|
|
210
|
+
if (!("parameters" in value)) return false;
|
|
211
|
+
const parameters = value.parameters;
|
|
212
|
+
return typeof parameters === "object" && parameters !== null && !Array.isArray(parameters);
|
|
213
|
+
}
|
|
214
|
+
case "modelAttribute":
|
|
215
|
+
if (!("attribute" in value) || typeof value.attribute !== "string" || value.attribute.length === 0) return false;
|
|
216
|
+
if (!("spec" in value)) return false;
|
|
217
|
+
return "lower" in value && typeof value.lower === "function";
|
|
218
|
+
default: return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function deepCopyNamespace(source, descriptorKind) {
|
|
222
|
+
const copy = {};
|
|
223
|
+
for (const [key, value] of Object.entries(source)) copy[key] = isCopyableNamespaceObject(value) && !isWellFormedDescriptor(value, descriptorKind) ? deepCopyNamespace(value, descriptorKind) : value;
|
|
224
|
+
return copy;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Merges `source` into `target` recursively at the descriptor-namespace
|
|
228
|
+
* level. `descriptorKind` is the `kind` value ('typeConstructor',
|
|
229
|
+
* 'fieldPreset', 'entity', or 'pslBlock') that identifies a descriptor
|
|
230
|
+
* (terminal merge point; same-path registrations across components are
|
|
231
|
+
* reported as duplicates) as opposed to a sub-namespace (recursion target).
|
|
232
|
+
*
|
|
233
|
+
* Path segments are validated against prototype-pollution names
|
|
234
|
+
* (`__proto__`, `constructor`, `prototype`). A value that is neither a
|
|
235
|
+
* recognized leaf nor a plain object — e.g. a malformed descriptor
|
|
236
|
+
* where the canonical leaf guard rejected it for missing `output` —
|
|
237
|
+
* is reported as an invalid contribution rather than recursed into,
|
|
238
|
+
* which would either silently mangle state or infinite-loop on
|
|
239
|
+
* primitive properties.
|
|
240
|
+
*
|
|
241
|
+
* Within-registry duplicate detection is this walker's job;
|
|
242
|
+
* cross-registry detection runs separately via
|
|
243
|
+
* `assertNoCrossRegistryCollisions` after merging completes.
|
|
244
|
+
*/
|
|
245
|
+
function mergeAuthoringNamespaces(target, source, path, descriptorKind, label) {
|
|
246
|
+
const assertSafePath = (currentPath) => {
|
|
247
|
+
const blockedSegment = currentPath.find((segment) => segment === "__proto__" || segment === "constructor" || segment === "prototype");
|
|
248
|
+
if (blockedSegment) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring ${label} helper "${currentPath.join(".")}". Helper path segments must not use "${blockedSegment}".`);
|
|
249
|
+
};
|
|
250
|
+
for (const [key, sourceValue] of Object.entries(source)) {
|
|
251
|
+
const currentPath = [...path, key];
|
|
252
|
+
assertSafePath(currentPath);
|
|
253
|
+
const hasExistingValue = Object.hasOwn(target, key);
|
|
254
|
+
const existingValue = hasExistingValue ? target[key] : void 0;
|
|
255
|
+
if (!hasExistingValue) {
|
|
256
|
+
target[key] = isCopyableNamespaceObject(sourceValue) && !isWellFormedDescriptor(sourceValue, descriptorKind) ? deepCopyNamespace(sourceValue, descriptorKind) : sourceValue;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
const existingIsLeaf = isWellFormedDescriptor(existingValue, descriptorKind);
|
|
260
|
+
const sourceIsLeaf = isWellFormedDescriptor(sourceValue, descriptorKind);
|
|
261
|
+
if (existingIsLeaf || sourceIsLeaf) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate authoring ${label} helper "${currentPath.join(".")}". Helper names must be unique across composed packs.`);
|
|
262
|
+
if (!isCopyableNamespaceObject(existingValue) || !isCopyableNamespaceObject(sourceValue)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Invalid authoring ${label} helper "${currentPath.join(".")}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`);
|
|
263
|
+
mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, descriptorKind, label);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Collects the full dotted paths of every well-formed descriptor of
|
|
268
|
+
* `descriptorKind` in a raw contribution tree, using the same boundary
|
|
269
|
+
* classification as {@link mergeAuthoringNamespaces}. Lets assembly-level
|
|
270
|
+
* callers attribute each contributed path to its contributing component
|
|
271
|
+
* before merging, so a same-path collision can be reported naming both
|
|
272
|
+
* contributors.
|
|
273
|
+
*/
|
|
274
|
+
function collectContributedDescriptorPaths(namespace, descriptorKind, path = []) {
|
|
275
|
+
const paths = [];
|
|
276
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
277
|
+
const currentPath = [...path, key];
|
|
278
|
+
if (isWellFormedDescriptor(value, descriptorKind)) {
|
|
279
|
+
paths.push(currentPath.join("."));
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (isCopyableNamespaceObject(value)) paths.push(...collectContributedDescriptorPaths(value, descriptorKind, currentPath));
|
|
283
|
+
}
|
|
284
|
+
return paths;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Derives the scalar view of an assembled authoring type namespace: every
|
|
288
|
+
* **top-level** type constructor that is instantiable with an empty argument
|
|
289
|
+
* list — all declared args optional and no entity-ref argument. A bare type
|
|
290
|
+
* name `T` in a schema is semantically the zero-arg instantiation `T()`, so
|
|
291
|
+
* each entry is exactly what that call produces (defaulted template values
|
|
292
|
+
* applied, absent optional-arg typeParams keys omitted). Constructors
|
|
293
|
+
* registered under a namespace segment, constructors with required args, and
|
|
294
|
+
* entity-ref constructors are not scalars and are excluded.
|
|
295
|
+
*
|
|
296
|
+
* Eligibility needs no template inspection: templates that cannot resolve
|
|
297
|
+
* for their legal call shapes are rejected at the composition boundary by
|
|
298
|
+
* {@link assertResolvableTypeConstructorTemplates}, so the zero-arg
|
|
299
|
+
* instantiation below cannot fail for an eligible constructor.
|
|
300
|
+
*/
|
|
301
|
+
function collectScalarTypeConstructors(namespace) {
|
|
302
|
+
const result = /* @__PURE__ */ new Map();
|
|
303
|
+
for (const [name, value] of Object.entries(namespace)) {
|
|
304
|
+
if (!isAuthoringTypeConstructorDescriptor(value)) continue;
|
|
305
|
+
if (value.entityRefArg !== void 0) continue;
|
|
306
|
+
if (value.args?.some((arg) => arg.optional !== true)) continue;
|
|
307
|
+
result.set(name, instantiateAuthoringTypeConstructor(value, []));
|
|
308
|
+
}
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
function visitTemplateArgRefs(template, visit) {
|
|
312
|
+
if (template === void 0) return;
|
|
313
|
+
if (isAuthoringArgRef(template)) {
|
|
314
|
+
visit(template);
|
|
315
|
+
visitTemplateArgRefs(template.default, visit);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (Array.isArray(template)) {
|
|
319
|
+
for (const value of template) visitTemplateArgRefs(value, visit);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (typeof template === "object" && template !== null) for (const value of Object.values(template)) visitTemplateArgRefs(value, visit);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Boundary validation for a contributed authoring type namespace, called
|
|
326
|
+
* per contributing component at assembly (which supplies `contributedBy`
|
|
327
|
+
* for attribution). Rejects what the types cannot express — entity-ref
|
|
328
|
+
* constructors are skipped (their output derives from the referenced
|
|
329
|
+
* entity): a plain constructor must declare its output storage type name,
|
|
330
|
+
* and every `typeParams` arg-ref (including refs inside arg-ref defaults)
|
|
331
|
+
* must point at a declared argument index.
|
|
332
|
+
*/
|
|
333
|
+
function assertResolvableTypeConstructorTemplates(namespace, contributedBy, path = []) {
|
|
334
|
+
for (const [name, value] of Object.entries(namespace)) {
|
|
335
|
+
const currentPath = [...path, name];
|
|
336
|
+
if (!isAuthoringTypeConstructorDescriptor(value)) {
|
|
337
|
+
assertResolvableTypeConstructorTemplates(value, contributedBy, currentPath);
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
if (value.entityRefArg !== void 0) continue;
|
|
341
|
+
const args = value.args ?? [];
|
|
342
|
+
const invalid = (detail) => /* @__PURE__ */ new Error(`Invalid authoring type constructor "${currentPath.join(".")}" contributed by descriptor "${contributedBy}". ${detail}`);
|
|
343
|
+
if (value.output.nativeType === void 0) throw invalid("The output declares no storage type template and no entityRefArg; a plain constructor must declare one.");
|
|
344
|
+
for (const [key, template] of Object.entries(value.output.typeParams ?? {})) visitTemplateArgRefs(template, (ref) => {
|
|
345
|
+
if (args[ref.index] === void 0) throw invalid(`output.typeParams.${key} references argument ${ref.index}, but the constructor declares ${args.length} argument(s). Declare the argument or correct the reference index.`);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function collectDescriptorPaths(namespace, isLeaf, path = []) {
|
|
350
|
+
const paths = [];
|
|
351
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
352
|
+
const currentPath = [...path, key];
|
|
353
|
+
if (isLeaf(value)) {
|
|
354
|
+
paths.push(currentPath.join("."));
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) paths.push(...collectDescriptorPaths(value, isLeaf, currentPath));
|
|
358
|
+
}
|
|
359
|
+
return paths;
|
|
360
|
+
}
|
|
361
|
+
function collectDescriptorEntries(namespace, isLeaf, descriptorKind, label, path = []) {
|
|
362
|
+
const entries = [];
|
|
363
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
364
|
+
const currentPath = [...path, key];
|
|
365
|
+
if (isLeaf(value)) {
|
|
366
|
+
if (!isWellFormedDescriptor(value, descriptorKind)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
|
|
367
|
+
if (value.discriminator.length > 0) entries.push({
|
|
368
|
+
path: currentPath.join("."),
|
|
369
|
+
discriminator: value.discriminator
|
|
370
|
+
});
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
374
|
+
const record = blindCast(value);
|
|
375
|
+
if ((record["kind"] !== void 0 || record["keyword"] !== void 0 || record["discriminator"] !== void 0) && !isLeaf(value)) {
|
|
376
|
+
const hasKind = record["kind"] === "pslBlock";
|
|
377
|
+
const hasKeyword = typeof record["keyword"] === "string";
|
|
378
|
+
const hasDiscriminator = typeof record["discriminator"] === "string";
|
|
379
|
+
if (hasKind || hasKeyword && hasDiscriminator) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring ${label} contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the ${label} descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
|
|
380
|
+
}
|
|
381
|
+
entries.push(...collectDescriptorEntries(value, isLeaf, descriptorKind, label, currentPath));
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return entries;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Throws when two or more entries in the same namespace share a key. A
|
|
388
|
+
* duplicate key makes dispatch ambiguous — the caller's lookup dispatches by
|
|
389
|
+
* this key, so one entry would silently shadow the other. Catch duplicates
|
|
390
|
+
* before building any dispatch map.
|
|
391
|
+
*
|
|
392
|
+
* `label` (e.g. `'pslBlock'`, `'entityType'`) names which namespace the
|
|
393
|
+
* duplicate was found in and is carried in the structured error metadata;
|
|
394
|
+
* the key itself is always called `key` in both the message and the
|
|
395
|
+
* metadata, since what it semantically represents (a discriminator for
|
|
396
|
+
* `entityType`, the parser's dispatch keyword for `pslBlock`) is the
|
|
397
|
+
* caller's concern, not this function's.
|
|
398
|
+
*/
|
|
399
|
+
function assertUniqueDiscriminators(entries, label) {
|
|
400
|
+
const seen = /* @__PURE__ */ new Map();
|
|
401
|
+
for (const { path, discriminator: key } of entries) {
|
|
402
|
+
const existing = seen.get(key);
|
|
403
|
+
if (existing !== void 0) throw runtimeError("RUNTIME.DUPLICATE_AUTHORING_DISCRIMINATOR", `Duplicate ${label} key "${key}" registered at both "${existing}" and "${path}". Each ${label} contribution must use a unique key.`, {
|
|
404
|
+
label,
|
|
405
|
+
key,
|
|
406
|
+
existingPath: existing,
|
|
407
|
+
path
|
|
408
|
+
});
|
|
409
|
+
seen.set(key, path);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function collectPslBlockDescriptorEntries(namespace, path = []) {
|
|
413
|
+
const entries = [];
|
|
414
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
415
|
+
const currentPath = [...path, key];
|
|
416
|
+
if (isAuthoringPslBlockDescriptor(value)) {
|
|
417
|
+
if (!isWellFormedDescriptor(value, "pslBlock")) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
|
|
418
|
+
entries.push({
|
|
419
|
+
path: currentPath.join("."),
|
|
420
|
+
discriminator: value.discriminator,
|
|
421
|
+
keyword: value.keyword
|
|
422
|
+
});
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
426
|
+
const record = blindCast(value);
|
|
427
|
+
const hasKind = record["kind"] === "pslBlock";
|
|
428
|
+
const hasKeyword = typeof record["keyword"] === "string";
|
|
429
|
+
const hasDiscriminator = typeof record["discriminator"] === "string";
|
|
430
|
+
if (hasKind || hasKeyword && hasDiscriminator) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring pslBlock contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/keyword/discriminator) but does not satisfy the pslBlock descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
|
|
431
|
+
entries.push(...collectPslBlockDescriptorEntries(value, currentPath));
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return entries;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Every `pslBlockDescriptors` entry requires a matching `entityTypes` factory
|
|
438
|
+
* with the same discriminator. An `entityTypes` factory may stand alone (e.g.
|
|
439
|
+
* `enum`, reachable from the TypeScript builder without any PSL block).
|
|
440
|
+
*
|
|
441
|
+
* Uniqueness for pslBlock entries is keyed on **keyword**, not discriminator:
|
|
442
|
+
* several keywords (e.g. `policy_select`/`policy_insert`) may legitimately
|
|
443
|
+
* share one discriminator, routing to the same `entityTypes` factory and the
|
|
444
|
+
* same `entries[discriminator]` slot — that N:1 shape is exactly what lets
|
|
445
|
+
* one entity kind be authored through several PSL keywords. What must stay
|
|
446
|
+
* unique is the keyword itself, since that's what the parser dispatches on.
|
|
447
|
+
*/
|
|
448
|
+
function assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace) {
|
|
449
|
+
const blockEntries = collectPslBlockDescriptorEntries(pslBlockNamespace);
|
|
450
|
+
const entityEntries = collectDescriptorEntries(entityTypeNamespace, isAuthoringEntityTypeDescriptor, "entity", "entityType");
|
|
451
|
+
assertUniqueDiscriminators(blockEntries.map((entry) => ({
|
|
452
|
+
path: entry.path,
|
|
453
|
+
discriminator: entry.keyword
|
|
454
|
+
})), "pslBlock");
|
|
455
|
+
assertUniqueDiscriminators(entityEntries, "entityType");
|
|
456
|
+
const entityDiscriminators = new Set(entityEntries.map((entry) => entry.discriminator));
|
|
457
|
+
for (const block of blockEntries) if (!entityDiscriminators.has(block.discriminator)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Incomplete extension contribution: pslBlock helper "${block.path}" registers discriminator "${block.discriminator}" but no entityType contribution shares that discriminator. An extension-contributed PSL block requires a matching entityType factory so the parsed AST node can lower to an IR class instance; add an entityType helper with discriminator "${block.discriminator}".`);
|
|
458
|
+
}
|
|
459
|
+
function collectModelAttributeEntries(namespace, path = []) {
|
|
460
|
+
const entries = [];
|
|
461
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
462
|
+
const currentPath = [...path, key];
|
|
463
|
+
if (isAuthoringModelAttributeDescriptor(value)) {
|
|
464
|
+
if (!isWellFormedDescriptor(value, "modelAttribute")) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
|
|
465
|
+
entries.push({
|
|
466
|
+
path: currentPath.join("."),
|
|
467
|
+
discriminator: value.attribute
|
|
468
|
+
});
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
472
|
+
const record = blindCast(value);
|
|
473
|
+
if (typeof record["attribute"] === "string" && "spec" in record) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Malformed authoring modelAttribute contribution at "${currentPath.join(".")}". The value carries descriptor keys (kind/attribute) but does not satisfy the modelAttribute descriptor shape. Fix the contribution so it is a complete descriptor, or remove the stray keys if it was meant to be a sub-namespace.`);
|
|
474
|
+
entries.push(...collectModelAttributeEntries(value, currentPath));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return entries;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Throws when two modelAttribute contributions — at any paths, even
|
|
481
|
+
* different ones — claim the same bare `@@` attribute name. The family
|
|
482
|
+
* interpreter dispatches by attribute name, not by registration path, so
|
|
483
|
+
* two descriptors claiming the same name would have one silently shadow
|
|
484
|
+
* the other.
|
|
485
|
+
*/
|
|
486
|
+
function assertUniqueModelAttributeNames(entries) {
|
|
487
|
+
const seen = /* @__PURE__ */ new Map();
|
|
488
|
+
for (const { path, discriminator: attribute } of entries) {
|
|
489
|
+
const existing = seen.get(attribute);
|
|
490
|
+
if (existing !== void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Duplicate modelAttribute "${attribute}" registered at both "${existing}" and "${path}". Each modelAttribute contribution must claim a unique attribute name.`);
|
|
491
|
+
seen.set(attribute, path);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function assertNoCrossRegistryCollisions(typeNamespace, fieldNamespace, entityTypeNamespace = {}, pslBlockNamespace = {}, modelAttributeNamespace = {}) {
|
|
495
|
+
const typePaths = new Set(collectDescriptorPaths(typeNamespace, isAuthoringTypeConstructorDescriptor));
|
|
496
|
+
const fieldPaths = new Set(collectDescriptorPaths(fieldNamespace, isAuthoringFieldPresetDescriptor));
|
|
497
|
+
const entityPaths = new Set(collectDescriptorPaths(entityTypeNamespace, isAuthoringEntityTypeDescriptor));
|
|
498
|
+
const ambiguityHint = "Register each path in only one of authoringContributions.field / authoringContributions.type / authoringContributions.entityTypes.";
|
|
499
|
+
for (const fieldPath of fieldPaths) if (typePaths.has(fieldPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
|
|
500
|
+
for (const entityPath of entityPaths) if (typePaths.has(entityPath) || fieldPaths.has(entityPath)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Ambiguous authoring registry path "${entityPath}". The same path is registered as an entity contribution AND as a type constructor or field preset; PSL resolution would be ambiguous. ${ambiguityHint}`);
|
|
501
|
+
assertPslBlocksHaveFactories(entityTypeNamespace, pslBlockNamespace);
|
|
502
|
+
assertUniqueModelAttributeNames(collectModelAttributeEntries(modelAttributeNamespace));
|
|
503
|
+
assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace);
|
|
504
|
+
}
|
|
505
|
+
function collectDescriptorNodes(namespace, isLeaf, path = []) {
|
|
506
|
+
const nodes = [];
|
|
507
|
+
for (const [key, value] of Object.entries(namespace)) {
|
|
508
|
+
const currentPath = [...path, key];
|
|
509
|
+
if (isLeaf(value)) {
|
|
510
|
+
nodes.push([currentPath.join("."), value]);
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) nodes.push(...collectDescriptorNodes(value, isLeaf, currentPath));
|
|
514
|
+
}
|
|
515
|
+
return nodes;
|
|
516
|
+
}
|
|
517
|
+
function collectSelectRefs(value, found) {
|
|
518
|
+
if (typeof value !== "object" || value === null) return;
|
|
519
|
+
if (isAuthoringSelectRef(value)) {
|
|
520
|
+
found.push(value);
|
|
521
|
+
for (const caseTemplate of Object.values(value.cases)) collectSelectRefs(caseTemplate, found);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (isAuthoringArgRef(value)) {
|
|
525
|
+
collectSelectRefs(value.default, found);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (Array.isArray(value)) {
|
|
529
|
+
for (const entry of value) collectSelectRefs(entry, found);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
for (const entry of Object.values(value)) collectSelectRefs(entry, found);
|
|
533
|
+
}
|
|
534
|
+
function validateSelectRefsAgainstArgs(label, helperPath, args, templateRoot) {
|
|
535
|
+
const selects = [];
|
|
536
|
+
collectSelectRefs(templateRoot, selects);
|
|
537
|
+
for (const select of selects) {
|
|
538
|
+
const position = `#${select.index + 1}`;
|
|
539
|
+
let descriptor = args?.[select.index];
|
|
540
|
+
if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, but the helper declares no argument at that position.`);
|
|
541
|
+
for (const segment of select.path ?? []) {
|
|
542
|
+
descriptor = descriptor.kind === "object" ? descriptor.properties[segment] : void 0;
|
|
543
|
+
if (descriptor === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position} at path "${(select.path ?? []).join(".")}", which does not resolve to a declared argument property.`);
|
|
544
|
+
}
|
|
545
|
+
if (descriptor.kind !== "option") throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template references argument ${position}, which is kind "${descriptor.kind}"; select requires an option argument.`);
|
|
546
|
+
const argumentLabel = descriptor.name !== void 0 ? `"${descriptor.name}"` : position;
|
|
547
|
+
const missing = descriptor.values.filter((value) => !Object.hasOwn(select.cases, value));
|
|
548
|
+
if (missing.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" option argument ${argumentLabel} allows [${descriptor.values.join(", ")}] but the select template has no case for: ${missing.join(", ")}.`);
|
|
549
|
+
const values = descriptor.values;
|
|
550
|
+
const unreachable = Object.keys(select.cases).filter((key) => !values.includes(key));
|
|
551
|
+
if (unreachable.length > 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring ${label} helper "${helperPath}" select template has case(s) not allowed by option argument ${argumentLabel}: ${unreachable.join(", ")}. Allowed values: [${values.join(", ")}].`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Every `select` template node must target an option argument whose `values`
|
|
556
|
+
* exactly cover the node's `cases` — a legal token with no case and a case no
|
|
557
|
+
* token can reach are both declaration bugs, caught here at pack-registration
|
|
558
|
+
* time rather than at first resolution.
|
|
559
|
+
*/
|
|
560
|
+
function assertSelectTemplatesMatchOptionArgs(typeNamespace, fieldNamespace, entityTypeNamespace) {
|
|
561
|
+
for (const [helperPath, descriptor] of collectDescriptorNodes(fieldNamespace, isAuthoringFieldPresetDescriptor)) validateSelectRefsAgainstArgs("field", helperPath, descriptor.args, descriptor.output);
|
|
562
|
+
for (const [helperPath, descriptor] of collectDescriptorNodes(typeNamespace, isAuthoringTypeConstructorDescriptor)) validateSelectRefsAgainstArgs("type", helperPath, descriptor.args, descriptor.output);
|
|
563
|
+
for (const [helperPath, descriptor] of collectDescriptorNodes(entityTypeNamespace, isAuthoringEntityTypeDescriptor)) if ("template" in descriptor.output) validateSelectRefsAgainstArgs("entityType", helperPath, descriptor.args, descriptor.output.template);
|
|
564
|
+
}
|
|
565
|
+
function resolveAuthoringTemplateValue(template, args) {
|
|
566
|
+
if (template === void 0) return;
|
|
567
|
+
if (isAuthoringArgRef(template)) {
|
|
568
|
+
const value = readTemplateArgumentValue(args, template.index, template.path);
|
|
569
|
+
if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
|
|
570
|
+
return value;
|
|
571
|
+
}
|
|
572
|
+
if (isAuthoringSelectRef(template)) {
|
|
573
|
+
const value = readTemplateArgumentValue(args, template.index, template.path);
|
|
574
|
+
if (value === void 0) return;
|
|
575
|
+
if (typeof value !== "string" || !Object.hasOwn(template.cases, value)) throw new InternalError(`Authoring template select has no case for value "${String(value)}"`);
|
|
576
|
+
return resolveAuthoringTemplateValue(template.cases[value], args);
|
|
577
|
+
}
|
|
578
|
+
if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
|
|
579
|
+
if (typeof template === "object" && template !== null) {
|
|
580
|
+
const resolved = {};
|
|
581
|
+
for (const [key, value] of Object.entries(template)) {
|
|
582
|
+
const resolvedValue = resolveAuthoringTemplateValue(value, args);
|
|
583
|
+
if (resolvedValue !== void 0) resolved[key] = resolvedValue;
|
|
584
|
+
}
|
|
585
|
+
return resolved;
|
|
586
|
+
}
|
|
587
|
+
return template;
|
|
588
|
+
}
|
|
589
|
+
function validateAuthoringArgument(descriptor, value, path) {
|
|
590
|
+
if (value === void 0) {
|
|
591
|
+
if (descriptor.optional) return;
|
|
592
|
+
throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Missing required authoring helper argument at ${path}`);
|
|
593
|
+
}
|
|
594
|
+
if (descriptor.kind === "string") {
|
|
595
|
+
if (typeof value !== "string") throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be a string`);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (descriptor.kind === "boolean") {
|
|
599
|
+
if (typeof value !== "boolean") throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be a boolean`);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (descriptor.kind === "stringArray") {
|
|
603
|
+
if (!Array.isArray(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an array of strings`);
|
|
604
|
+
for (const entry of value) if (typeof entry !== "string") throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an array of strings`);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (descriptor.kind === "object") {
|
|
608
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an object`);
|
|
609
|
+
const input = value;
|
|
610
|
+
const expectedKeys = new Set(Object.keys(descriptor.properties));
|
|
611
|
+
for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} contains unknown property "${key}"`);
|
|
612
|
+
for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (descriptor.kind === "option") {
|
|
616
|
+
if (typeof value !== "string" || !descriptor.values.includes(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be one of: ${descriptor.values.join(", ")}`);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
if (typeof value !== "number" || Number.isNaN(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be a number`);
|
|
620
|
+
if (descriptor.integer && !Number.isInteger(value)) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be an integer`);
|
|
621
|
+
if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`);
|
|
622
|
+
if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`);
|
|
623
|
+
}
|
|
624
|
+
function validateAuthoringHelperArguments(helperPath, descriptors, args) {
|
|
625
|
+
const expected = descriptors ?? [];
|
|
626
|
+
const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
|
|
627
|
+
if (args.length < minimumArgs || args.length > expected.length) throw runtimeError("CONTRACT.ARGUMENT_INVALID", `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
|
|
628
|
+
expected.forEach((descriptor, index) => {
|
|
629
|
+
validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
function resolveAuthoringStorageTypeTemplate(template, args) {
|
|
633
|
+
const nativeType = template.nativeType;
|
|
634
|
+
if (nativeType === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring output template for codec "${template.codecId}" declares no nativeType; only entity-ref constructors may omit it`);
|
|
635
|
+
const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
|
|
636
|
+
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)}`);
|
|
637
|
+
const normalizedTypeParams = typeParams !== void 0 && Object.keys(typeParams).length === 0 ? void 0 : typeParams;
|
|
638
|
+
return {
|
|
639
|
+
codecId: template.codecId,
|
|
640
|
+
nativeType,
|
|
641
|
+
...ifDefined("typeParams", normalizedTypeParams)
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function resolveAuthoringColumnDefaultTemplate(template, args) {
|
|
645
|
+
if (template.kind === "literal") {
|
|
646
|
+
const value = resolveAuthoringTemplateValue(template.value, args);
|
|
647
|
+
if (value === void 0) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", "Resolved authoring literal default must not be undefined");
|
|
648
|
+
if (!isColumnDefaultLiteralInputValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`);
|
|
649
|
+
return {
|
|
650
|
+
kind: "literal",
|
|
651
|
+
value
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
const expression = resolveAuthoringTemplateValue(template.expression, args);
|
|
655
|
+
if (expression === void 0 || typeof expression === "object" && expression !== null) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
|
|
656
|
+
return {
|
|
657
|
+
kind: "function",
|
|
658
|
+
expression: String(expression)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function resolveExecutionMutationDefaultPhase(phase, template, args) {
|
|
662
|
+
const value = resolveAuthoringTemplateValue(template, args);
|
|
663
|
+
if (value === void 0) return;
|
|
664
|
+
if (!isExecutionMutationDefaultValue(value)) throw runtimeError("CONTRACT.PACK_CONTRIBUTION_INVALID", `Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`);
|
|
665
|
+
return value;
|
|
666
|
+
}
|
|
667
|
+
function resolveAuthoringExecutionDefaultsTemplate(template, args) {
|
|
668
|
+
const phases = {
|
|
669
|
+
...ifDefined("onCreate", template.onCreate !== void 0 ? resolveExecutionMutationDefaultPhase("onCreate", template.onCreate, args) : void 0),
|
|
670
|
+
...ifDefined("onUpdate", template.onUpdate !== void 0 ? resolveExecutionMutationDefaultPhase("onUpdate", template.onUpdate, args) : void 0)
|
|
671
|
+
};
|
|
672
|
+
return Object.keys(phases).length === 0 ? void 0 : phases;
|
|
673
|
+
}
|
|
674
|
+
function instantiateAuthoringTypeConstructor(descriptor, args) {
|
|
675
|
+
return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
|
|
676
|
+
}
|
|
677
|
+
function instantiateAuthoringEntityType(helperPath, descriptor, args, ctx) {
|
|
678
|
+
if ("factory" in descriptor.output) {
|
|
679
|
+
const input = args[0];
|
|
680
|
+
return blindCast(descriptor.output.factory)(input, ctx);
|
|
681
|
+
}
|
|
682
|
+
validateAuthoringHelperArguments(helperPath, descriptor.args, args);
|
|
683
|
+
return blindCast(resolveAuthoringTemplateValue(descriptor.output.template, args));
|
|
684
|
+
}
|
|
685
|
+
function instantiateAuthoringFieldPreset(descriptor, args) {
|
|
686
|
+
return {
|
|
687
|
+
descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
|
|
688
|
+
nullable: descriptor.output.nullable ?? false,
|
|
689
|
+
...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
|
|
690
|
+
...ifDefined("executionDefaults", descriptor.output.executionDefaults !== void 0 ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args) : void 0),
|
|
691
|
+
id: descriptor.output.id ?? false,
|
|
692
|
+
unique: descriptor.output.unique ?? false
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
export { mergeAuthoringNamespaces as _, collectScalarTypeConstructors as a, validateAuthoringHelperArguments as b, instantiateAuthoringEntityType as c, isAuthoringArgRef as d, isAuthoringEntityTypeDescriptor as f, isAuthoringTypeConstructorDescriptor as g, isAuthoringPslBlockDescriptor as h, collectContributedDescriptorPaths as i, instantiateAuthoringFieldPreset as l, isAuthoringModelAttributeDescriptor as m, assertResolvableTypeConstructorTemplates as n, flushAuthoringWarnings as o, isAuthoringFieldPresetDescriptor as p, classifyEnumMemberType as r, hasRegisteredFieldNamespace as s, assertNoCrossRegistryCollisions as t, instantiateAuthoringTypeConstructor as u, resolveAuthoringTemplateValue as v, resolveEnumCodecId as y };
|
|
697
|
+
|
|
698
|
+
//# sourceMappingURL=framework-authoring-CDEvlouU-mlMWSksD.mjs.map
|