@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,1383 @@
|
|
|
1
|
+
import { B as LedgerEntryRecord, m as ContractMarkerRecord } from "./domain-envelope-D6Wn9AmZ-BqZKTT9U.mjs";
|
|
2
|
+
import { i as ControlPolicy, t as Contract } from "./contract-types-CkdMH7F7-9EHXSwbH.mjs";
|
|
3
|
+
import { u as CodecRegistry } from "./codec-types-XJO6eC9U-B_K2q0zm.mjs";
|
|
4
|
+
import { E as AuthoringTypeNamespace, b as AuthoringPslBlockDescriptorNamespace, d as AuthoringFieldNamespace, g as AuthoringModelAttributeDescriptorNamespace, i as AuthoringContributions, l as AuthoringEntityTypeNamespace } from "./framework-authoring-7YMP9TwM-C9P-N6_a.mjs";
|
|
5
|
+
import { t as CapabilityMatrix } from "./capabilities-Cupq4-1--C71ORI3N.mjs";
|
|
6
|
+
import { t as TypesImportSpec } from "./types-import-spec-DRKzrJ20-WYwyCtil.mjs";
|
|
7
|
+
import { D as TargetBoundComponentDescriptor, O as TargetDescriptor, a as ComponentMetadata, f as DriverDescriptor, g as ExtensionInstance, h as ExtensionDescriptor, k as TargetInstance, n as AdapterInstance, p as DriverInstance, t as AdapterDescriptor, u as ControlMutationDefaults, v as FamilyDescriptor, y as FamilyInstance } from "./framework-components-MFoo0sYx-G_6k9jt4.mjs";
|
|
8
|
+
import { r as ImportSpecifierResolver, t as EmissionSpi } from "./emission-types-hfRVB_Yw-DpQ3hISB.mjs";
|
|
9
|
+
import { m as PslDocumentAst } from "./psl-ast-Chgi8e4o-rSlBk1UV.mjs";
|
|
10
|
+
import { t as ImportRequirement } from "./index-GY2oGH9L.mjs";
|
|
11
|
+
import { n as JsonObject } from "./json-Dkqr3say.mjs";
|
|
12
|
+
import { i as StorageSort, n as PreserveEmptyPredicate } from "./canonicalization-DFpB09nP-4OdB2nsy.mjs";
|
|
13
|
+
import { r as Result } from "./result-Bpupv5vO.mjs";
|
|
14
|
+
//#region ../../../1-framework/1-core/framework-components/dist/control.d.mts
|
|
15
|
+
//#region src/control/contract-serializer.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Framework SPI for moving a contract between its canonical on-disk JSON
|
|
18
|
+
* form and its in-memory class-hierarchy form. Both directions live on the
|
|
19
|
+
* same SPI so the conceptual seam — "the boundary where the contract
|
|
20
|
+
* crosses between persisted JSON and live class instances" — has a single
|
|
21
|
+
* named home.
|
|
22
|
+
*
|
|
23
|
+
* Both faces are needed by the framework today (round-trip property tests,
|
|
24
|
+
* drift detection, future canonicalization), not eventually. For most
|
|
25
|
+
* targets `serializeContract` is identity over JSON-clean class instances;
|
|
26
|
+
* the method exists because the seam is real, not as a convention placeholder.
|
|
27
|
+
*
|
|
28
|
+
* Implementers compose this SPI as a named property on their target
|
|
29
|
+
* descriptor (`descriptor.contractSerializer`); the descriptor itself
|
|
30
|
+
* remains the aggregator of all per-target SPIs.
|
|
31
|
+
*/
|
|
32
|
+
interface ContractSerializer<TContract> {
|
|
33
|
+
/**
|
|
34
|
+
* Validate the JSON shape and construct typed class instances. Throws on
|
|
35
|
+
* structural / domain / storage validation failures. Returns the typed
|
|
36
|
+
* contract on success.
|
|
37
|
+
*
|
|
38
|
+
* The method-level type parameter lets call sites that hold a
|
|
39
|
+
* precisely-typed contract literal (e.g. `typeof contract` from a
|
|
40
|
+
* generated `contract.d.ts`) recover that literal type without an
|
|
41
|
+
* external cast. The default `T = TContract` preserves the inferred
|
|
42
|
+
* return type for every caller that does not opt in.
|
|
43
|
+
*/
|
|
44
|
+
deserializeContract<T extends TContract = TContract>(json: unknown): T;
|
|
45
|
+
/**
|
|
46
|
+
* Serialize a typed contract to its canonical JSON shape. Returns
|
|
47
|
+
* `JsonObject` so callers can stringify, hash, or feed the result into
|
|
48
|
+
* another SPI without re-asserting JSON-cleanness. Targets whose contract
|
|
49
|
+
* fields are JSON-clean by construction return the contract unchanged
|
|
50
|
+
* (the symmetric pair to `deserializeContract`); targets that need to
|
|
51
|
+
* canonicalize on the way out (key ordering, dropping computed-only
|
|
52
|
+
* fields, normalizing numeric encodings) do that work here.
|
|
53
|
+
*/
|
|
54
|
+
serializeContract(contract: TContract): JsonObject;
|
|
55
|
+
/**
|
|
56
|
+
* Optional family-contributed preserve-empty predicate for the
|
|
57
|
+
* framework canonicalizer. When present, the canonicalizer calls this
|
|
58
|
+
* inside its default-omission walk to let the family veto the stripping
|
|
59
|
+
* of empty objects/arrays/`false` values at family-specific storage paths.
|
|
60
|
+
* Families whose storage has no such special-case paths omit this hook.
|
|
61
|
+
*/
|
|
62
|
+
readonly shouldPreserveEmpty?: PreserveEmptyPredicate;
|
|
63
|
+
/**
|
|
64
|
+
* Optional family-contributed storage sort hook for the framework
|
|
65
|
+
* canonicalizer. When present, the canonicalizer applies this to the
|
|
66
|
+
* serialized `storage` subtree after the omission walk and before the
|
|
67
|
+
* final key sort. Families that need deterministic ordering of storage
|
|
68
|
+
* arrays (e.g. SQL `indexes`/`uniques`) supply this hook.
|
|
69
|
+
*/
|
|
70
|
+
readonly sortStorage?: StorageSort;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/control/contract-snapshot-layout.d.ts
|
|
74
|
+
declare const CONTRACT_SNAPSHOTS_DIRNAME = "snapshots";
|
|
75
|
+
/** Validate a storage hash for use as a directory name. */
|
|
76
|
+
declare function storageHashHex(storageHash: string): string;
|
|
77
|
+
/** Module specifier for the store's `contract.json`, POSIX separators. */
|
|
78
|
+
declare function contractSnapshotJsonSpecifier(snapshotsImportPath: string, storageHash: string): string;
|
|
79
|
+
/** Type-only module specifier for the store's `contract.d.ts` (no extension). */
|
|
80
|
+
declare function contractSnapshotTypesSpecifier(snapshotsImportPath: string, storageHash: string): string;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/control/schema-diff.d.ts
|
|
83
|
+
/**
|
|
84
|
+
* A root-anchored chain of `(nodeKind, id)` steps identifying a node in a
|
|
85
|
+
* schema tree — the same vocabulary the differ pairs siblings with. Used by
|
|
86
|
+
* `DiffableNode.dependsOn` to name a node's structural prerequisites without
|
|
87
|
+
* holding a reference to the node itself (the target may live on the other
|
|
88
|
+
* diff side, or not exist at all).
|
|
89
|
+
*/
|
|
90
|
+
type SchemaNodeRef = readonly {
|
|
91
|
+
readonly nodeKind: string;
|
|
92
|
+
readonly id: string;
|
|
93
|
+
}[];
|
|
94
|
+
interface SchemaDiffIssue<TNode extends DiffableNode = DiffableNode> {
|
|
95
|
+
/** Path from the root node down to the diffed node, as a sequence of local keys. */
|
|
96
|
+
readonly path: readonly string[];
|
|
97
|
+
/** The expected (desired-side) node, when available. Absent for a drop. */
|
|
98
|
+
readonly expected?: TNode;
|
|
99
|
+
/** The actual (current-side) node, when available. Absent for a create. */
|
|
100
|
+
readonly actual?: TNode;
|
|
101
|
+
/**
|
|
102
|
+
* Paths of the other in-diff issues this issue depends on. Mirrored by
|
|
103
|
+
* `diffSchemas` from the node's own `dependsOn` refs: a ref resolves to a
|
|
104
|
+
* path only when some emitted issue sits at that exact path with a
|
|
105
|
+
* matching `nodeKind` — a ref whose target produced no issue is dropped
|
|
106
|
+
* (the dependency is satisfied by reality).
|
|
107
|
+
*/
|
|
108
|
+
readonly dependsOn?: readonly (readonly string[])[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The three ways an actual state can fail an expectation: it lacks a node that
|
|
112
|
+
* was expected (`not-found`), holds a node that was not expected
|
|
113
|
+
* (`not-expected`), or holds a node not equal to the expected one
|
|
114
|
+
* (`not-equal`). Expected is the desired side, actual the current side, of
|
|
115
|
+
* whatever comparison produced the issue (contract-vs-database, or
|
|
116
|
+
* contract-vs-contract in an offline plan), so the vocabulary is
|
|
117
|
+
* comparison-relative and never ambiguous about a base — and reads cleanly for
|
|
118
|
+
* both the planner and `db verify`.
|
|
119
|
+
*
|
|
120
|
+
* This is the RETURN TYPE of the derived {@link issueOutcome} helper, not a
|
|
121
|
+
* stored field: presence is the single source of truth, and the outcome is
|
|
122
|
+
* computed from it on demand.
|
|
123
|
+
*/
|
|
124
|
+
type ExpectationFailureReason = 'not-found' | 'not-expected' | 'not-equal';
|
|
125
|
+
/**
|
|
126
|
+
* The outcome an issue represents, discriminated by presence rather than any
|
|
127
|
+
* stored field — the single source of truth every consumer reads. An issue
|
|
128
|
+
* always carries at least one side by construction; neither is a malformed
|
|
129
|
+
* issue and throws.
|
|
130
|
+
*/
|
|
131
|
+
declare function issueOutcome(issue: SchemaDiffIssue): ExpectationFailureReason;
|
|
132
|
+
/**
|
|
133
|
+
* A node in the schema tree. Every node in the tree implements this interface.
|
|
134
|
+
*
|
|
135
|
+
* The differ pairs siblings by the combination of `nodeKind` and `id`, not by
|
|
136
|
+
* `id` alone: `id` needs only be unique among siblings of the same
|
|
137
|
+
* `nodeKind` at the same level, not globally unique at that level. Two
|
|
138
|
+
* distinct kinds of child in distinct slots (e.g. a role and a namespace) may
|
|
139
|
+
* legitimately share a name — they are never paired against each other, so
|
|
140
|
+
* the collision is harmless. A node never folds its kind into its id string
|
|
141
|
+
* to route around this; `nodeKind` is the discriminant that does that job.
|
|
142
|
+
* A same-`nodeKind`/same-`id` collision among siblings is a genuine
|
|
143
|
+
* duplicate and is enforced by a throw. The differ accumulates ids (not
|
|
144
|
+
* nodeKind) into a path that stamps every emitted issue.
|
|
145
|
+
*/
|
|
146
|
+
interface DiffableNode {
|
|
147
|
+
readonly id: string;
|
|
148
|
+
readonly nodeKind: string;
|
|
149
|
+
/**
|
|
150
|
+
* The nodes this node structurally depends on — resolved references to the
|
|
151
|
+
* prerequisites that must exist before it. Stamped by the derivation that
|
|
152
|
+
* holds the parent context; both the expected and the actual derivation
|
|
153
|
+
* stamp it by the same structural rules. Never compared by `isEqualTo`.
|
|
154
|
+
*/
|
|
155
|
+
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
156
|
+
isEqualTo(other: DiffableNode): boolean;
|
|
157
|
+
children(): readonly DiffableNode[];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Diff two schema trees starting from their roots.
|
|
161
|
+
*
|
|
162
|
+
* The differ is **total**: every node-level difference is reported. An unmatched
|
|
163
|
+
* non-leaf node emits its own issue and descends, emitting an issue for every
|
|
164
|
+
* node in the missing/extra subtree. Coalescing a parent change over its
|
|
165
|
+
* children is the planner's responsibility. Ownership filtering (dropping `extra`
|
|
166
|
+
* issues in namespaces a contract doesn't own) is the caller's responsibility.
|
|
167
|
+
*/
|
|
168
|
+
declare function diffSchemas(expected: DiffableNode, actual: DiffableNode): readonly SchemaDiffIssue[];
|
|
169
|
+
/**
|
|
170
|
+
* The result of diffing a contract's expected schema against the introspected
|
|
171
|
+
* actual schema: one node-typed issue list. Carries no verdict, verification
|
|
172
|
+
* tree, or counts — those are the verifier's own presentation, built from the
|
|
173
|
+
* same underlying comparison.
|
|
174
|
+
*
|
|
175
|
+
* `TNode` is the concrete schema-IR node the issues carry; it defaults to
|
|
176
|
+
* `DiffableNode`, so this is purely additive — a caller that wants the
|
|
177
|
+
* concrete node opts in (the Postgres planner uses the concrete node type),
|
|
178
|
+
* everyone else keeps the default unchanged.
|
|
179
|
+
*/
|
|
180
|
+
declare class SchemaDiff<TNode extends DiffableNode = DiffableNode> {
|
|
181
|
+
readonly issues: readonly SchemaDiffIssue<TNode>[];
|
|
182
|
+
constructor(issues: readonly SchemaDiffIssue<TNode>[]);
|
|
183
|
+
/** Returns a new `SchemaDiff` narrowed to the issues `keep` returns true for. */
|
|
184
|
+
filter(keep: (issue: SchemaDiffIssue<TNode>) => boolean): SchemaDiff<TNode>;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/control/control-operation-results.d.ts
|
|
188
|
+
declare const VERIFY_CODE_MARKER_MISSING = "CONTRACT.MARKER_MISSING";
|
|
189
|
+
declare const VERIFY_CODE_HASH_MISMATCH = "CONTRACT.MARKER_MISMATCH";
|
|
190
|
+
declare const VERIFY_CODE_TARGET_MISMATCH = "CONTRACT.TARGET_MISMATCH";
|
|
191
|
+
declare const VERIFY_CODE_SCHEMA_FAILURE = "CONTRACT.SCHEMA_VERIFICATION_FAILED";
|
|
192
|
+
interface OperationContext {
|
|
193
|
+
readonly contractPath?: string;
|
|
194
|
+
readonly configPath?: string;
|
|
195
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
196
|
+
}
|
|
197
|
+
interface VerifyDatabaseResult {
|
|
198
|
+
readonly ok: boolean;
|
|
199
|
+
readonly code?: string;
|
|
200
|
+
readonly summary: string;
|
|
201
|
+
readonly contract: {
|
|
202
|
+
readonly storageHash: string;
|
|
203
|
+
readonly profileHash?: string;
|
|
204
|
+
};
|
|
205
|
+
readonly marker?: {
|
|
206
|
+
readonly storageHash?: string;
|
|
207
|
+
readonly profileHash?: string;
|
|
208
|
+
};
|
|
209
|
+
readonly target: {
|
|
210
|
+
readonly expected: string;
|
|
211
|
+
readonly actual?: string;
|
|
212
|
+
};
|
|
213
|
+
readonly missingCodecs?: readonly string[];
|
|
214
|
+
readonly codecCoverageSkipped?: boolean;
|
|
215
|
+
readonly meta?: {
|
|
216
|
+
readonly configPath?: string;
|
|
217
|
+
readonly contractPath: string;
|
|
218
|
+
};
|
|
219
|
+
readonly timings: {
|
|
220
|
+
readonly total: number;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The issue-based schema-verify result. `ok` derives from the FAILURE list
|
|
225
|
+
* only: a verify passes exactly when `schema.issues` is empty, post
|
|
226
|
+
* strict-gating and control-policy disposition.
|
|
227
|
+
*
|
|
228
|
+
* `schema.warnings` carries warn-graded issues (an `observed`-policy
|
|
229
|
+
* subject's drift, and any other `warn` disposition) in the same shape.
|
|
230
|
+
* Warnings are informational — they never affect `ok` — but they MUST be
|
|
231
|
+
* surfaced: an `observed` table that drifted yields `ok: true` with a
|
|
232
|
+
* non-empty warnings channel, which is what distinguishes "watch without
|
|
233
|
+
* failing" from full suppression.
|
|
234
|
+
*/
|
|
235
|
+
interface VerifyDatabaseSchemaResult {
|
|
236
|
+
readonly ok: boolean;
|
|
237
|
+
readonly code?: string;
|
|
238
|
+
readonly summary: string;
|
|
239
|
+
readonly contract: {
|
|
240
|
+
readonly storageHash: string;
|
|
241
|
+
readonly profileHash?: string;
|
|
242
|
+
};
|
|
243
|
+
readonly target: {
|
|
244
|
+
readonly expected: string;
|
|
245
|
+
readonly actual?: string;
|
|
246
|
+
};
|
|
247
|
+
readonly schema: {
|
|
248
|
+
readonly issues: readonly SchemaDiffIssue[];
|
|
249
|
+
readonly warnings?: {
|
|
250
|
+
readonly issues: readonly SchemaDiffIssue[];
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
readonly meta?: {
|
|
254
|
+
readonly configPath?: string;
|
|
255
|
+
readonly contractPath?: string;
|
|
256
|
+
readonly strict: boolean;
|
|
257
|
+
};
|
|
258
|
+
readonly timings: {
|
|
259
|
+
readonly total: number;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
interface EmitContractResult {
|
|
263
|
+
readonly contractJson: string;
|
|
264
|
+
readonly contractDts: string;
|
|
265
|
+
readonly storageHash: string;
|
|
266
|
+
readonly executionHash?: string;
|
|
267
|
+
readonly profileHash: string;
|
|
268
|
+
}
|
|
269
|
+
interface IntrospectSchemaResult<TSchemaIR> {
|
|
270
|
+
readonly ok: true;
|
|
271
|
+
readonly summary: string;
|
|
272
|
+
readonly target: {
|
|
273
|
+
readonly familyId: string;
|
|
274
|
+
readonly id: string;
|
|
275
|
+
};
|
|
276
|
+
readonly schema: TSchemaIR;
|
|
277
|
+
readonly meta?: {
|
|
278
|
+
readonly configPath?: string;
|
|
279
|
+
readonly dbUrl?: string;
|
|
280
|
+
};
|
|
281
|
+
readonly timings: {
|
|
282
|
+
readonly total: number;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
interface SignDatabaseResult {
|
|
286
|
+
readonly ok: boolean;
|
|
287
|
+
readonly summary: string;
|
|
288
|
+
readonly contract: {
|
|
289
|
+
readonly storageHash: string;
|
|
290
|
+
readonly profileHash?: string;
|
|
291
|
+
};
|
|
292
|
+
readonly target: {
|
|
293
|
+
readonly expected: string;
|
|
294
|
+
readonly actual?: string;
|
|
295
|
+
};
|
|
296
|
+
readonly marker: {
|
|
297
|
+
readonly created: boolean;
|
|
298
|
+
readonly updated: boolean;
|
|
299
|
+
readonly previous?: {
|
|
300
|
+
readonly storageHash?: string;
|
|
301
|
+
readonly profileHash?: string;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
readonly meta?: {
|
|
305
|
+
readonly configPath?: string;
|
|
306
|
+
readonly contractPath: string;
|
|
307
|
+
};
|
|
308
|
+
readonly timings: {
|
|
309
|
+
readonly total: number;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/control/control-instances.d.ts
|
|
314
|
+
interface ControlFamilyInstance<TFamilyId extends string, TSchemaIR> extends FamilyInstance<TFamilyId> {
|
|
315
|
+
/**
|
|
316
|
+
* The family seam-of-record for on-disk contract reads. Structurally
|
|
317
|
+
* validates the JSON envelope and hydrates IR-class instances via the
|
|
318
|
+
* per-target ContractSerializer. The single named entry point every
|
|
319
|
+
* CLI on-disk read crosses (TML-2536) — `as Contract` casts in
|
|
320
|
+
* production package sources are a serializer-bypass smell guarded by
|
|
321
|
+
* `pnpm lint:no-contract-cast`.
|
|
322
|
+
*/
|
|
323
|
+
deserializeContract(contractJson: unknown): Contract;
|
|
324
|
+
verify(options: {
|
|
325
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
326
|
+
readonly contract: unknown;
|
|
327
|
+
readonly expectedTargetId: string;
|
|
328
|
+
readonly contractPath: string;
|
|
329
|
+
readonly configPath?: string;
|
|
330
|
+
}): Promise<VerifyDatabaseResult>;
|
|
331
|
+
/**
|
|
332
|
+
* Verify a contract against an already-introspected schema.
|
|
333
|
+
*
|
|
334
|
+
* Callers that need to verify against the live database compose
|
|
335
|
+
* {@link introspect} + `verifySchema` directly. The aggregate verifier
|
|
336
|
+
* verifies each member against the full introspected schema and scopes the
|
|
337
|
+
* result to that member's contract space afterwards — it never prunes the
|
|
338
|
+
* schema up front.
|
|
339
|
+
*
|
|
340
|
+
* Synchronous — no I/O. Idempotent.
|
|
341
|
+
*/
|
|
342
|
+
verifySchema(options: {
|
|
343
|
+
readonly contract: unknown;
|
|
344
|
+
readonly schema: TSchemaIR;
|
|
345
|
+
readonly strict: boolean;
|
|
346
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, string>>;
|
|
347
|
+
}): VerifyDatabaseSchemaResult;
|
|
348
|
+
sign(options: {
|
|
349
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
350
|
+
readonly contract: unknown;
|
|
351
|
+
readonly contractPath: string;
|
|
352
|
+
readonly configPath?: string;
|
|
353
|
+
}): Promise<SignDatabaseResult>;
|
|
354
|
+
/**
|
|
355
|
+
* Reads the contract marker for `space` from the database, returning
|
|
356
|
+
* `null` if no marker row exists for that space (or if the marker
|
|
357
|
+
* table itself is missing).
|
|
358
|
+
*
|
|
359
|
+
* `space` is required at every call site so the type system surfaces
|
|
360
|
+
* every place that needs to thread the value: callers in app-only
|
|
361
|
+
* paths pass {@link import('./control-spaces').APP_SPACE_ID}
|
|
362
|
+
* (`'app'`); per-extension callers pass the extension's space id.
|
|
363
|
+
* Defaulting at the family-interface level was a silent bug door —
|
|
364
|
+
* it let callers forget to pass `space` and collapse onto the app's
|
|
365
|
+
* marker row.
|
|
366
|
+
*
|
|
367
|
+
* Families whose underlying storage doesn't yet support per-space
|
|
368
|
+
* markers (Mongo, today) accept `space` for interface conformance and
|
|
369
|
+
* reject any non-`APP_SPACE_ID` value rather than silently ignoring
|
|
370
|
+
* it; see the family-specific implementation for details.
|
|
371
|
+
*/
|
|
372
|
+
readMarker(options: {
|
|
373
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
374
|
+
readonly space: string;
|
|
375
|
+
}): Promise<ContractMarkerRecord | null>;
|
|
376
|
+
/**
|
|
377
|
+
* Reads every marker row keyed by `space`. Used by the per-space
|
|
378
|
+
* verifier to detect orphan marker rows and marker-vs-on-disk drift.
|
|
379
|
+
* Returns an empty map when the marker table does not yet exist.
|
|
380
|
+
*/
|
|
381
|
+
readAllMarkers(options: {
|
|
382
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
383
|
+
}): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
|
|
384
|
+
/**
|
|
385
|
+
* Reads the per-migration ledger journal in apply order. When `space` is
|
|
386
|
+
* omitted, returns rows for every space. Returns an empty array when the
|
|
387
|
+
* ledger store does not yet exist or has no matching rows.
|
|
388
|
+
*/
|
|
389
|
+
readLedger(options: {
|
|
390
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
391
|
+
readonly space?: string;
|
|
392
|
+
}): Promise<readonly LedgerEntryRecord[]>;
|
|
393
|
+
introspect(options: {
|
|
394
|
+
readonly driver: ControlDriverInstance<TFamilyId, string>;
|
|
395
|
+
readonly contract?: unknown;
|
|
396
|
+
}): Promise<TSchemaIR>;
|
|
397
|
+
}
|
|
398
|
+
interface ControlTargetInstance<TFamilyId extends string, TTargetId extends string> extends TargetInstance<TFamilyId, TTargetId> {}
|
|
399
|
+
interface ControlAdapterInstance<TFamilyId extends string, TTargetId extends string> extends AdapterInstance<TFamilyId, TTargetId> {}
|
|
400
|
+
interface ControlDriverInstance<TFamilyId extends string, TTargetId extends string> extends DriverInstance<TFamilyId, TTargetId> {
|
|
401
|
+
close(): Promise<void>;
|
|
402
|
+
}
|
|
403
|
+
interface ControlExtensionInstance<TFamilyId extends string, TTargetId extends string> extends ExtensionInstance<TFamilyId, TTargetId> {}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/control/control-migration-types.d.ts
|
|
406
|
+
/**
|
|
407
|
+
* In-memory migration metadata envelope. Every migration is
|
|
408
|
+
* content-addressed: the `migrationHash` is a hash over the metadata
|
|
409
|
+
* envelope plus the operations list, computed at write time. There is no
|
|
410
|
+
* draft state — a migration directory either exists with fully attested
|
|
411
|
+
* metadata or it does not.
|
|
412
|
+
*
|
|
413
|
+
* When the planner cannot lower an operation because of an unfilled
|
|
414
|
+
* `placeholder(...)` slot, the migration is still written with
|
|
415
|
+
* `migrationHash` hashed over `ops: []`. Re-running self-emit after the
|
|
416
|
+
* user fills the placeholder produces a *different* `migrationHash`
|
|
417
|
+
* (committed to the real ops); this is intentional.
|
|
418
|
+
*
|
|
419
|
+
* The on-disk JSON shape in `migration.json` matches this type
|
|
420
|
+
* field-for-field — `JSON.stringify(metadata, null, 2)` is the canonical
|
|
421
|
+
* writer output (defined in `@internal/migration-tools/io`).
|
|
422
|
+
*
|
|
423
|
+
* The manifest carries identity (`from`, `to`, `migrationHash`) but
|
|
424
|
+
* not the full contract IRs themselves. The destination and predecessor
|
|
425
|
+
* contracts resolve by hash through the shared content-addressed store
|
|
426
|
+
* at `migrations/snapshots/<hex>/contract.json`. The runner depends only
|
|
427
|
+
* on `migration.json` + `ops.json` per package (plus the project-root
|
|
428
|
+
* head contract). See `docs/architecture docs/subsystems/7. Migration System.md`.
|
|
429
|
+
*/
|
|
430
|
+
interface MigrationMetadata {
|
|
431
|
+
readonly migrationHash: string;
|
|
432
|
+
readonly from: string | null;
|
|
433
|
+
readonly to: string;
|
|
434
|
+
/**
|
|
435
|
+
* Sorted, deduplicated list of `invariantId`s declared by the
|
|
436
|
+
* migration's data-transform ops. Always present; an empty array
|
|
437
|
+
* means the migration has no routing-visible data transforms.
|
|
438
|
+
*/
|
|
439
|
+
readonly providedInvariants: readonly string[];
|
|
440
|
+
readonly createdAt: string;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Migration operation classes define the safety level of an operation.
|
|
444
|
+
* - 'additive': Adds new structures without modifying existing ones (safe)
|
|
445
|
+
* - 'widening': Relaxes constraints or expands types (generally safe)
|
|
446
|
+
* - 'destructive': Removes or alters existing structures (potentially unsafe)
|
|
447
|
+
* - 'data': Data transformation operation (e.g., backfill, type conversion)
|
|
448
|
+
*/
|
|
449
|
+
type MigrationOperationClass = 'additive' | 'widening' | 'destructive' | 'data';
|
|
450
|
+
/**
|
|
451
|
+
* Policy defining which operation classes are allowed during a migration.
|
|
452
|
+
*/
|
|
453
|
+
interface MigrationOperationPolicy {
|
|
454
|
+
readonly allowedOperationClasses: readonly MigrationOperationClass[];
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* A single migration operation for display purposes.
|
|
458
|
+
* Contains only the fields needed for CLI output (tree view, JSON envelope).
|
|
459
|
+
*/
|
|
460
|
+
interface MigrationPlanOperation {
|
|
461
|
+
/** Unique identifier for this operation (e.g., "table.users.create"). */
|
|
462
|
+
readonly id: string;
|
|
463
|
+
/** Human-readable label for display in UI/CLI (e.g., "Create table users"). */
|
|
464
|
+
readonly label: string;
|
|
465
|
+
/** The class of operation (additive, widening, destructive). */
|
|
466
|
+
readonly operationClass: MigrationOperationClass;
|
|
467
|
+
/**
|
|
468
|
+
* Optional opt-in routing identity for data-transform operations.
|
|
469
|
+
* Presence opts the transform into invariant-aware routing; absence
|
|
470
|
+
* means it is path-dependent and not referenceable from refs.
|
|
471
|
+
*
|
|
472
|
+
* Lives on the base op so the manifest emitter and
|
|
473
|
+
* `deriveProvidedInvariants` can read it without depending on a
|
|
474
|
+
* target-specific shape. Schema-DDL ops (additive / widening /
|
|
475
|
+
* destructive) leave it undefined.
|
|
476
|
+
*/
|
|
477
|
+
readonly invariantId?: string;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Framework-level contract for a single factory call in a target's planner
|
|
481
|
+
* IR — the canonical shape for any node participating in the two-renderer
|
|
482
|
+
* pattern (source-text rendering for `migration.ts` + runtime-op derivation
|
|
483
|
+
* for `ops.json`).
|
|
484
|
+
*
|
|
485
|
+
* Implementations declare:
|
|
486
|
+
*
|
|
487
|
+
* - **Identity / display metadata** (`factoryName`, `operationClass`,
|
|
488
|
+
* `label`) used by CLI summaries and the issue planner.
|
|
489
|
+
* - **`renderTypeScript()`** — emit the call as a TypeScript expression
|
|
490
|
+
* suitable for inclusion in a generated `migration.ts`. Polymorphic
|
|
491
|
+
* across postgres / mongo / sqlite / extension-owned calls.
|
|
492
|
+
* - **`importRequirements()`** — the symbols this rendered expression
|
|
493
|
+
* pulls in. Aggregated and deduplicated by the top-level renderer
|
|
494
|
+
* into a single import block per file.
|
|
495
|
+
* - **`toOp()`** — lower the call to a runtime
|
|
496
|
+
* `MigrationPlanOperation`. Returns the framework base; concrete
|
|
497
|
+
* implementations narrow via covariant return (e.g. SQL targets
|
|
498
|
+
* return `SqlMigrationPlanOperation<TTargetDetails>`).
|
|
499
|
+
*
|
|
500
|
+
* Each domain (target, extension) defines its own set of concrete `*Call`
|
|
501
|
+
* classes that implement this interface — typically by extending
|
|
502
|
+
* {@link import('@prisma/orm-framework/ts-render').TsExpression} and adding the
|
|
503
|
+
* concrete `toOp()` body. Extensions can implement the interface
|
|
504
|
+
* directly without depending on a target's package-private base.
|
|
505
|
+
*
|
|
506
|
+
* @see ADR 195 — Planner IR with two renderers.
|
|
507
|
+
*/
|
|
508
|
+
interface OpFactoryCall {
|
|
509
|
+
/** The name of the factory that would produce this call's runtime op. */
|
|
510
|
+
readonly factoryName: string;
|
|
511
|
+
/** The operation's safety class (additive, widening, destructive, data). */
|
|
512
|
+
readonly operationClass: MigrationOperationClass;
|
|
513
|
+
/** Human-readable label for CLI output and diagnostics. */
|
|
514
|
+
readonly label: string;
|
|
515
|
+
/**
|
|
516
|
+
* Render this call as a TypeScript expression suitable for inclusion in
|
|
517
|
+
* a generated `migration.ts`. The output is composed alongside other
|
|
518
|
+
* calls' rendered expressions inside the migration's `operations`
|
|
519
|
+
* array.
|
|
520
|
+
*/
|
|
521
|
+
renderTypeScript(): string;
|
|
522
|
+
/**
|
|
523
|
+
* Import requirements pulled in by the rendered TypeScript expression.
|
|
524
|
+
* Aggregated and deduplicated across all calls into a single import
|
|
525
|
+
* block per file.
|
|
526
|
+
*/
|
|
527
|
+
importRequirements(): readonly ImportRequirement[];
|
|
528
|
+
/**
|
|
529
|
+
* Lower this call to a runtime migration plan operation suitable for
|
|
530
|
+
* execution / inclusion in `ops.json`. Concrete implementations narrow
|
|
531
|
+
* the return type via covariant return (e.g. SQL targets return
|
|
532
|
+
* `SqlMigrationPlanOperation<TTargetDetails>`). May return a Promise when
|
|
533
|
+
* the lowering requires async codec resolution (e.g. DDL with literal defaults).
|
|
534
|
+
*/
|
|
535
|
+
toOp(): MigrationPlanOperation | Promise<MigrationPlanOperation>;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* A migration plan for display purposes.
|
|
539
|
+
* Contains only the fields needed for CLI output (summary, JSON envelope).
|
|
540
|
+
*/
|
|
541
|
+
interface MigrationPlan {
|
|
542
|
+
/** The target ID this plan is for (e.g., 'postgres'). */
|
|
543
|
+
readonly targetId: string;
|
|
544
|
+
/**
|
|
545
|
+
* Contract space this plan applies to. Runners cross-check
|
|
546
|
+
* `options.space` against `plan.spaceId` so the marker row gets keyed
|
|
547
|
+
* by the right space when applying via {@link MigrationRunner.execute}.
|
|
548
|
+
*
|
|
549
|
+
* Optional because not every plan carries a space id; when present,
|
|
550
|
+
* runners enforce that it matches `options.space`.
|
|
551
|
+
*/
|
|
552
|
+
readonly spaceId?: string;
|
|
553
|
+
/**
|
|
554
|
+
* Origin contract identity that the plan expects the database to currently be at.
|
|
555
|
+
* If omitted or null, the runner skips origin validation entirely.
|
|
556
|
+
*/
|
|
557
|
+
readonly origin?: {
|
|
558
|
+
readonly storageHash: string;
|
|
559
|
+
readonly profileHash?: string;
|
|
560
|
+
} | null;
|
|
561
|
+
/** Destination contract identity that the plan intends to reach. */
|
|
562
|
+
readonly destination: {
|
|
563
|
+
readonly storageHash: string;
|
|
564
|
+
readonly profileHash?: string;
|
|
565
|
+
};
|
|
566
|
+
/** Ordered list of operations to execute. May contain Promises for ops that require async codec resolution. */
|
|
567
|
+
readonly operations: readonly (MigrationPlanOperation | Promise<MigrationPlanOperation>)[];
|
|
568
|
+
/**
|
|
569
|
+
* Sorted, deduplicated invariant ids declared by this plan's data-transform
|
|
570
|
+
* ops. Authored migrations carry the canonical value from
|
|
571
|
+
* `migration.json.providedInvariants`; planner-built plans (`db init`,
|
|
572
|
+
* `db update`) omit it (the runner treats it as `[]`). Runners read this
|
|
573
|
+
* field for marker writes and self-edge no-op detection rather than
|
|
574
|
+
* re-deriving from `operations`, since the manifest is the canonical
|
|
575
|
+
* source for the invariant set across all runners (postgres, sqlite,
|
|
576
|
+
* mongo).
|
|
577
|
+
*/
|
|
578
|
+
readonly providedInvariants?: readonly string[];
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* A migration plan that can also render itself back to user-editable
|
|
582
|
+
* TypeScript source (a `migration.ts` file).
|
|
583
|
+
*
|
|
584
|
+
* Planners produce this richer shape so that CLI commands can both:
|
|
585
|
+
* - hand the plan to the runner for execution (via `MigrationPlan`), and
|
|
586
|
+
* - materialize the plan as an editable source file via `renderTypeScript()`.
|
|
587
|
+
*
|
|
588
|
+
* User-authored migrations (`Migration` subclasses) satisfy `MigrationPlan`
|
|
589
|
+
* but not this interface: they are already the source.
|
|
590
|
+
*/
|
|
591
|
+
interface MigrationPlanWithAuthoringSurface extends MigrationPlan {
|
|
592
|
+
/**
|
|
593
|
+
* Render this plan back to TypeScript source suitable for writing to
|
|
594
|
+
* `migration.ts`. Output may start with a shebang; when it does, the caller
|
|
595
|
+
* should make the resulting file executable.
|
|
596
|
+
*
|
|
597
|
+
* `resolveImportSpecifier` rewrites every package name the rendered file
|
|
598
|
+
* imports for the import root the consuming application installed (ADR
|
|
599
|
+
* 242), exactly as the same resolver does for `contract.d.ts` — a
|
|
600
|
+
* scaffolded migration is a file the application keeps, so every name in
|
|
601
|
+
* it has to be one the application can resolve. The caller supplies it
|
|
602
|
+
* rather than the plan capturing it, because the project a plan is
|
|
603
|
+
* rendered into is known at the render call and not at planning time: `db
|
|
604
|
+
* init` and `db update` build plans they never render. Pass
|
|
605
|
+
* {@link import('../shared/import-specifier-resolver').keepInternalSpecifiers}
|
|
606
|
+
* to emit workspace names unchanged.
|
|
607
|
+
*/
|
|
608
|
+
renderTypeScript(resolveImportSpecifier: ImportSpecifierResolver): string;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* A conflict detected during migration planning.
|
|
612
|
+
*/
|
|
613
|
+
interface MigrationPlannerConflict {
|
|
614
|
+
/** Kind of conflict (e.g., 'typeMismatch', 'nullabilityConflict'). */
|
|
615
|
+
readonly kind: string;
|
|
616
|
+
/** Human-readable summary of the conflict. */
|
|
617
|
+
readonly summary: string;
|
|
618
|
+
/** Optional explanation of why this conflict occurred. */
|
|
619
|
+
readonly why?: string;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Successful planner result with the migration plan.
|
|
623
|
+
*
|
|
624
|
+
* The plan is typed as `MigrationPlanWithAuthoringSurface` so the CLI can
|
|
625
|
+
* uniformly ask any plan to render itself to TypeScript.
|
|
626
|
+
*/
|
|
627
|
+
interface MigrationPlannerSuccessResult {
|
|
628
|
+
readonly kind: 'success';
|
|
629
|
+
readonly plan: MigrationPlanWithAuthoringSurface;
|
|
630
|
+
readonly warnings?: readonly MigrationPlannerConflict[];
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Failed planner result with the list of conflicts.
|
|
634
|
+
*/
|
|
635
|
+
interface MigrationPlannerFailureResult {
|
|
636
|
+
readonly kind: 'failure';
|
|
637
|
+
readonly conflicts: readonly MigrationPlannerConflict[];
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Union type for planner results.
|
|
641
|
+
*/
|
|
642
|
+
type MigrationPlannerResult = MigrationPlannerSuccessResult | MigrationPlannerFailureResult;
|
|
643
|
+
/**
|
|
644
|
+
* Per-space success payload returned inside
|
|
645
|
+
* {@link MigrationRunnerSuccessValue.perSpaceResults}.
|
|
646
|
+
*/
|
|
647
|
+
interface MigrationRunnerPerSpaceSuccessValue {
|
|
648
|
+
readonly operationsPlanned: number;
|
|
649
|
+
readonly operationsExecuted: number;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Success value for migration runner execution across one or more contract
|
|
653
|
+
* spaces.
|
|
654
|
+
*/
|
|
655
|
+
interface MigrationRunnerSuccessValue {
|
|
656
|
+
readonly perSpaceResults: ReadonlyArray<{
|
|
657
|
+
readonly space: string;
|
|
658
|
+
readonly value: MigrationRunnerPerSpaceSuccessValue;
|
|
659
|
+
}>;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Failure details for migration runner execution.
|
|
663
|
+
*/
|
|
664
|
+
interface MigrationRunnerFailure {
|
|
665
|
+
/** Error code for the failure. */
|
|
666
|
+
readonly code: string;
|
|
667
|
+
/** Human-readable summary of the failure. */
|
|
668
|
+
readonly summary: string;
|
|
669
|
+
/** Optional explanation of why the failure occurred. */
|
|
670
|
+
readonly why?: string;
|
|
671
|
+
/** Optional metadata for debugging and UX (e.g., schema issues, SQL state). */
|
|
672
|
+
readonly meta?: Record<string, unknown>;
|
|
673
|
+
/**
|
|
674
|
+
* Identifier of the space whose plan caused the rollback when
|
|
675
|
+
* {@link MigrationRunner.execute} processes multiple spaces.
|
|
676
|
+
*/
|
|
677
|
+
readonly failingSpace?: string;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Result type for migration runner execution.
|
|
681
|
+
*/
|
|
682
|
+
type MigrationRunnerResult = Result<MigrationRunnerSuccessValue, MigrationRunnerFailure>;
|
|
683
|
+
/**
|
|
684
|
+
* Execution-time checks configuration for migration runners.
|
|
685
|
+
* All checks default to `true` (enabled) when omitted.
|
|
686
|
+
*/
|
|
687
|
+
interface MigrationRunnerExecutionChecks {
|
|
688
|
+
/**
|
|
689
|
+
* Whether to run prechecks before executing operations.
|
|
690
|
+
* Defaults to `true` (prechecks are run).
|
|
691
|
+
*/
|
|
692
|
+
readonly prechecks?: boolean;
|
|
693
|
+
/**
|
|
694
|
+
* Whether to run postchecks after executing operations.
|
|
695
|
+
* Defaults to `true` (postchecks are run).
|
|
696
|
+
*/
|
|
697
|
+
readonly postchecks?: boolean;
|
|
698
|
+
/**
|
|
699
|
+
* Whether to run idempotency probe (check if postcheck is already satisfied before execution).
|
|
700
|
+
* Defaults to `true` (idempotency probe is run).
|
|
701
|
+
*/
|
|
702
|
+
readonly idempotencyChecks?: boolean;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* The canonical schema-IR entity coordinate: which namespace, which kind of
|
|
706
|
+
* entity, and which name. A bare entity name is not a unique identity —
|
|
707
|
+
* two namespaces can each declare an entity of the same name, and one
|
|
708
|
+
* namespace can declare two different-kind entities that share a name — so
|
|
709
|
+
* every schema-IR consumer that addresses one live or declared entity does
|
|
710
|
+
* it by this full triple.
|
|
711
|
+
*
|
|
712
|
+
* `entityKind` uses the same vocabulary as the contract storage's `entries`
|
|
713
|
+
* dictionary — the same vocabulary
|
|
714
|
+
* {@link import('../ir/storage').elementCoordinates} walks. This type has no
|
|
715
|
+
* `plane`: schema IR is storage-only (contract IR spans domain and storage,
|
|
716
|
+
* which is why its own coordinate type carries a plane), so a plane field
|
|
717
|
+
* here would always read `'storage'` and say nothing.
|
|
718
|
+
*/
|
|
719
|
+
interface SchemaEntityCoordinate {
|
|
720
|
+
readonly namespaceId: string;
|
|
721
|
+
readonly entityKind: string;
|
|
722
|
+
readonly entityName: string;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Contract-space ownership query the planner consults while planning one
|
|
726
|
+
* space against a live database.
|
|
727
|
+
*
|
|
728
|
+
* A live schema node the planned space does not own surfaces from the diff
|
|
729
|
+
* as `not-expected` (an extra). Before treating such a node as this plan's
|
|
730
|
+
* to drop, the planner asks the ownership oracle whether *any* contract
|
|
731
|
+
* space in the composition declares it: a node another (sibling) space owns
|
|
732
|
+
* is not an orphan, so it is left untouched; a node no space owns is a
|
|
733
|
+
* genuine extra the planner may drop under a destructive policy. (A node the
|
|
734
|
+
* planned space itself owns is in its expected tree and never surfaces as an
|
|
735
|
+
* extra, so a positive answer always means a sibling.)
|
|
736
|
+
*
|
|
737
|
+
* The oracle is a real domain object — the passive
|
|
738
|
+
* {@link import('@prisma/orm-toolchain/migration-tools/aggregate').ContractSpaceAggregate},
|
|
739
|
+
* which answers this from its loaded contract spaces. The planner holds no
|
|
740
|
+
* list of other spaces' names and no ownership rules of its own; it only
|
|
741
|
+
* asks. Single-space plans (offline `migration plan`) pass an aggregate of
|
|
742
|
+
* one — the same path, no special-casing.
|
|
743
|
+
*/
|
|
744
|
+
interface SchemaOwnership {
|
|
745
|
+
/**
|
|
746
|
+
* True when some contract space in the composition declares a storage
|
|
747
|
+
* entity at this coordinate.
|
|
748
|
+
*/
|
|
749
|
+
declaresEntity(coordinate: SchemaEntityCoordinate): boolean;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Migration planner interface for planning schema changes.
|
|
753
|
+
* This is the minimal interface that CLI commands use.
|
|
754
|
+
*
|
|
755
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
756
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
757
|
+
*/
|
|
758
|
+
interface MigrationPlanner<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
759
|
+
plan(options: {
|
|
760
|
+
readonly contract: unknown;
|
|
761
|
+
readonly schema: unknown;
|
|
762
|
+
readonly policy: MigrationOperationPolicy;
|
|
763
|
+
/**
|
|
764
|
+
* The "from" contract (the state the planner assumes the database starts
|
|
765
|
+
* at), or `null` for a baseline plan with no prior state.
|
|
766
|
+
*
|
|
767
|
+
* Planners derive any "from" identity they need to stamp onto the
|
|
768
|
+
* produced plan's `describe()` from `fromContract?.storage.storageHash
|
|
769
|
+
* ?? null`. They also pass this to data-safety strategies so they can
|
|
770
|
+
* compare `from` and `to` column shapes (e.g. to detect unsafe type
|
|
771
|
+
* changes).
|
|
772
|
+
*
|
|
773
|
+
* Required at every call site to make the structural fact "I have a
|
|
774
|
+
* prior contract / I don't" visible in the type. Reconciliation
|
|
775
|
+
* commands (`db init`, `db update`) introspect a live schema and pass
|
|
776
|
+
* `null`; authoring commands (`migration plan`) read the predecessor's
|
|
777
|
+
* contract from the snapshot store by its storage hash and pass the
|
|
778
|
+
* parsed value.
|
|
779
|
+
*/
|
|
780
|
+
readonly fromContract: Contract | null;
|
|
781
|
+
/**
|
|
782
|
+
* Active framework components participating in this composition.
|
|
783
|
+
* Families/targets can interpret this list to derive family-specific metadata.
|
|
784
|
+
* All components must have matching familyId and targetId.
|
|
785
|
+
*/
|
|
786
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
787
|
+
/**
|
|
788
|
+
* Contract space this plan applies to. Stamped onto the produced
|
|
789
|
+
* plan so the runner keys the marker row by the right space when
|
|
790
|
+
* executing. App-plan callers pass `APP_SPACE_ID` (`'app'`);
|
|
791
|
+
* per-extension callers pass the extension's space id.
|
|
792
|
+
*/
|
|
793
|
+
readonly spaceId: string;
|
|
794
|
+
/**
|
|
795
|
+
* Ownership oracle over the whole contract-space composition (the
|
|
796
|
+
* passive aggregate). The planner asks it, per live extra node, whether
|
|
797
|
+
* any space declares that entity: a sibling-owned node is left
|
|
798
|
+
* untouched, an unowned node is a genuine extra. The planner holds no
|
|
799
|
+
* list of other spaces' names — ownership lives in the aggregate; it
|
|
800
|
+
* only asks. Absent for a single-space plan handed no aggregate.
|
|
801
|
+
* See {@link SchemaOwnership}.
|
|
802
|
+
*/
|
|
803
|
+
readonly ownership?: SchemaOwnership;
|
|
804
|
+
/**
|
|
805
|
+
* POSIX-relative path from the migration package dir to
|
|
806
|
+
* `migrations/snapshots`, e.g. `'../../snapshots'`. Targets that render a
|
|
807
|
+
* family authoring surface pass this straight through to the produced
|
|
808
|
+
* plan's `renderTypeScript()` metadata. Callers that never render the
|
|
809
|
+
* produced plan to TypeScript (diff-based reconciliation for `db init` /
|
|
810
|
+
* `db update`) pass a placeholder — see `planFromDiff` in
|
|
811
|
+
* `@internal/migration-tools`.
|
|
812
|
+
*/
|
|
813
|
+
readonly snapshotsImportPath: string;
|
|
814
|
+
}): MigrationPlannerResult;
|
|
815
|
+
/**
|
|
816
|
+
* Produce an empty migration with the target's authoring conventions.
|
|
817
|
+
*
|
|
818
|
+
* Used by `migration new` to scaffold a fresh `migration.ts`. The
|
|
819
|
+
* returned plan has no operations; its `renderTypeScript()` yields a
|
|
820
|
+
* stub the user can edit.
|
|
821
|
+
*
|
|
822
|
+
* `spaceId` is stamped onto the produced plan; reconciliation flows
|
|
823
|
+
* (`db init`, `db update`) and authoring flows (`migration new`) all
|
|
824
|
+
* pass it explicitly.
|
|
825
|
+
*/
|
|
826
|
+
emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Migration runner interface for executing migration plans.
|
|
830
|
+
* This is the minimal interface that CLI commands use.
|
|
831
|
+
*
|
|
832
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
833
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
834
|
+
*/
|
|
835
|
+
/**
|
|
836
|
+
* Per-space input for {@link MigrationRunner.execute}.
|
|
837
|
+
*
|
|
838
|
+
* Each entry's `driver` must reference the same connection the outer
|
|
839
|
+
* transaction is opened on (typically the same value as the top-level
|
|
840
|
+
* `driver` on `execute`). An apply that targets one space passes a
|
|
841
|
+
* one-element `perSpaceOptions` list.
|
|
842
|
+
*
|
|
843
|
+
* Family-specific runners (e.g. the SQL family's `SqlMigrationRunner`) define
|
|
844
|
+
* a richer per-space option shape that is structurally compatible with this
|
|
845
|
+
* one — additional optional fields (e.g. SQL's `schemaName`, `callbacks`) are
|
|
846
|
+
* tolerated by the underlying runner without affecting cross-target wiring.
|
|
847
|
+
*/
|
|
848
|
+
interface MigrationRunnerPerSpaceOptions<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
849
|
+
readonly space: string;
|
|
850
|
+
readonly plan: MigrationPlan;
|
|
851
|
+
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
852
|
+
readonly destinationContract: unknown;
|
|
853
|
+
readonly policy: MigrationOperationPolicy;
|
|
854
|
+
readonly executionChecks?: MigrationRunnerExecutionChecks;
|
|
855
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
856
|
+
/**
|
|
857
|
+
* When `false`, schema verification tolerates objects owned by sibling
|
|
858
|
+
* contract spaces. Aggregate apply passes `false` per space because each
|
|
859
|
+
* `destinationContract` describes only that space's slice.
|
|
860
|
+
*/
|
|
861
|
+
readonly strictVerification?: boolean;
|
|
862
|
+
/**
|
|
863
|
+
* Paths and metadata forwarded to schema verification diagnostics.
|
|
864
|
+
*/
|
|
865
|
+
readonly context?: OperationContext;
|
|
866
|
+
/**
|
|
867
|
+
* Per-edge breakdown from aggregate planning. Runners write one ledger row
|
|
868
|
+
* per edge in walk order.
|
|
869
|
+
*/
|
|
870
|
+
readonly migrationEdges: ReadonlyArray<{
|
|
871
|
+
readonly migrationHash: string;
|
|
872
|
+
readonly dirName: string;
|
|
873
|
+
readonly from: string;
|
|
874
|
+
readonly to: string;
|
|
875
|
+
readonly operationCount: number;
|
|
876
|
+
readonly destinationContractJson?: unknown;
|
|
877
|
+
}>;
|
|
878
|
+
}
|
|
879
|
+
interface MigrationRunner<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
880
|
+
/**
|
|
881
|
+
* Apply one or more per-space migration plans against the configured driver.
|
|
882
|
+
*
|
|
883
|
+
* Each plan is trusted input. Callers are responsible for upstream
|
|
884
|
+
* verification of the originating migration package — typically by
|
|
885
|
+
* obtaining the package via `readMigrationPackage` from
|
|
886
|
+
* `@internal/migration-tools/io`, which performs hash-integrity checks
|
|
887
|
+
* at the load boundary. Runners do not re-verify plans and assume the
|
|
888
|
+
* `(metadata, ops)` pairs on disk have not been tampered with since emit.
|
|
889
|
+
*
|
|
890
|
+
* Atomicity semantics differ by family: SQL targets open one outer
|
|
891
|
+
* transaction across every space; Mongo iterates per-space without an
|
|
892
|
+
* outer transaction and relies on per-space verify-gated marker atomicity.
|
|
893
|
+
*/
|
|
894
|
+
execute(options: {
|
|
895
|
+
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
896
|
+
readonly perSpaceOptions: ReadonlyArray<MigrationRunnerPerSpaceOptions<TFamilyId, TTargetId>>;
|
|
897
|
+
}): Promise<MigrationRunnerResult>;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Optional capability interface for targets that support migrations.
|
|
901
|
+
* Targets that implement migrations expose this via their descriptor.
|
|
902
|
+
*
|
|
903
|
+
* @template TFamilyId - The family ID (e.g., 'sql', 'document')
|
|
904
|
+
* @template TTargetId - The target ID (e.g., 'postgres', 'mysql')
|
|
905
|
+
* @template TFamilyInstance - The family instance type (e.g., SqlControlFamilyInstance)
|
|
906
|
+
*/
|
|
907
|
+
interface TargetMigrationsCapability<TFamilyId extends string = string, TTargetId extends string = string, TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<TFamilyId, unknown>> {
|
|
908
|
+
createPlanner(adapter: ControlAdapterInstance<TFamilyId, TTargetId>): MigrationPlanner<TFamilyId, TTargetId>;
|
|
909
|
+
createRunner(family: TFamilyInstance): MigrationRunner<TFamilyId, TTargetId>;
|
|
910
|
+
/**
|
|
911
|
+
* Synthesizes a family-specific schema IR from a contract for offline planning.
|
|
912
|
+
* The returned schema can be passed to `planner.plan({ schema })` as the "from" state.
|
|
913
|
+
*
|
|
914
|
+
* @param contract - The contract to convert, or null for a new project (empty schema).
|
|
915
|
+
* @param frameworkComponents - Active framework components, used to derive database
|
|
916
|
+
* dependencies (e.g. extensions) that should be reflected in the schema IR.
|
|
917
|
+
* @returns Family-specific schema IR (e.g., `SqlSchemaIR` for SQL targets).
|
|
918
|
+
*/
|
|
919
|
+
contractToSchema(contract: Contract | null, frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>): unknown;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Context for rendering migration source files.
|
|
923
|
+
*
|
|
924
|
+
* Kept minimal: only the paths a target might need to compute relative imports
|
|
925
|
+
* (e.g. the contract `.d.ts` import for typed-contract builders). Passed to
|
|
926
|
+
* `MigrationPlanner.emptyMigration(context)`.
|
|
927
|
+
*/
|
|
928
|
+
interface MigrationScaffoldContext {
|
|
929
|
+
/** Absolute path to the migration package directory. Used by targets to compute relative imports. */
|
|
930
|
+
readonly packageDir: string;
|
|
931
|
+
/** Absolute path to the contract.json file, if one exists. Used by targets that emit typed-contract imports. */
|
|
932
|
+
readonly contractJsonPath?: string;
|
|
933
|
+
/**
|
|
934
|
+
* Storage hash of the "from" contract, or `null` for a baseline scaffold
|
|
935
|
+
* with no prior state. Targets use this to populate `describe()` on the
|
|
936
|
+
* rendered empty migration so that identity metadata is correctly
|
|
937
|
+
* populated.
|
|
938
|
+
*/
|
|
939
|
+
readonly fromHash: string | null;
|
|
940
|
+
/**
|
|
941
|
+
* Storage hash of the "to" contract. Same purpose as `fromHash` — threaded
|
|
942
|
+
* through so the rendered class's `describe()` declares the correct
|
|
943
|
+
* destination identity.
|
|
944
|
+
*/
|
|
945
|
+
readonly toHash: string;
|
|
946
|
+
/**
|
|
947
|
+
* POSIX-relative path from the migration package dir to
|
|
948
|
+
* `migrations/snapshots`, e.g. `'../../snapshots'` for an app-space
|
|
949
|
+
* package. Targets that emit contract-snapshot imports pass this straight
|
|
950
|
+
* through to their renderer's `RenderMigrationMeta.snapshotsImportPath`.
|
|
951
|
+
*/
|
|
952
|
+
readonly snapshotsImportPath: string;
|
|
953
|
+
}
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/control/control-spaces.d.ts
|
|
956
|
+
/**
|
|
957
|
+
* Canonical control-plane identifiers for contract spaces.
|
|
958
|
+
*
|
|
959
|
+
* A contract space is the disjoint `(contract.json, migration-graph)` unit
|
|
960
|
+
* the per-space planner / runner / verifier (project: extension contract
|
|
961
|
+
* spaces, TML-2397) operates on. The application owns one well-known
|
|
962
|
+
* space — the value below — and each loaded extension that contributes
|
|
963
|
+
* schema owns a uniquely-named space.
|
|
964
|
+
*
|
|
965
|
+
* Lives in `framework-components/control` so every layer that has to
|
|
966
|
+
* reason about space identity (the migration tooling, the SQL runtime's
|
|
967
|
+
* marker reader, target-side statement builders, target-side adapters)
|
|
968
|
+
* can import a single value rather than duplicating the literal. Raw
|
|
969
|
+
* `'app'` string literals in framework / target / runtime / adapter
|
|
970
|
+
* source code are forbidden and policed by
|
|
971
|
+
* `scripts/lint-app-space-id.mjs` (wired into `pnpm lint:deps`).
|
|
972
|
+
*
|
|
973
|
+
* @see specs/framework-mechanism.spec.md § 3 — Layout convention (γ).
|
|
974
|
+
*/
|
|
975
|
+
declare const APP_SPACE_ID: "app";
|
|
976
|
+
/**
|
|
977
|
+
* Head ref for a contract space — the `(hash, invariants)` tuple
|
|
978
|
+
* a runner targets when applying that space's migration graph. Identical
|
|
979
|
+
* in shape to the on-disk `migrations/<space-id>/refs/head.json` the
|
|
980
|
+
* framework writes per loaded extension, and to the app-space
|
|
981
|
+
* `<projectRoot>/refs/head.json`. Family-agnostic: SQL, Mongo, and any
|
|
982
|
+
* future family share the same head-ref shape.
|
|
983
|
+
*
|
|
984
|
+
* @see specs/framework-mechanism.spec.md § 1.
|
|
985
|
+
*/
|
|
986
|
+
interface ContractSpaceHeadRef {
|
|
987
|
+
readonly hash: string;
|
|
988
|
+
readonly invariants: readonly string[];
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Canonical structural shape of a migration package — the unit a planner
|
|
992
|
+
* produces and a runner consumes: a directory name, the metadata
|
|
993
|
+
* envelope, and the operation list.
|
|
994
|
+
*
|
|
995
|
+
* In-memory by default. Readers in `@internal/migration-tools`
|
|
996
|
+
* (`readMigrationPackage` / `readMigrationsDir`) return the augmented
|
|
997
|
+
* {@link import('@prisma/orm-toolchain/migration-tools/package').OnDiskMigrationPackage}
|
|
998
|
+
* variant which adds `dirPath`; everything else operates against the
|
|
999
|
+
* canonical shape so the same value flows through pre-emission
|
|
1000
|
+
* authoring, on-disk loading, and runner execution without conversion.
|
|
1001
|
+
*
|
|
1002
|
+
* @see specs/framework-mechanism.spec.md § 1.
|
|
1003
|
+
*/
|
|
1004
|
+
interface MigrationPackage {
|
|
1005
|
+
readonly dirName: string;
|
|
1006
|
+
readonly metadata: MigrationMetadata;
|
|
1007
|
+
readonly ops: readonly MigrationPlanOperation[];
|
|
1008
|
+
/**
|
|
1009
|
+
* Contract IR JSON of this migration's destination state, populated by
|
|
1010
|
+
* the on-disk readers from the shared snapshot store entry for the
|
|
1011
|
+
* migration's `to` hash when present (raw parsed JSON). Absent for
|
|
1012
|
+
* packages loaded without a resolvable store entry — the runner never
|
|
1013
|
+
* requires it (see ADR 199: identity is anchored on the storage-hash
|
|
1014
|
+
* bookends). The edge's *start* state is deliberately not carried: it
|
|
1015
|
+
* is by construction the end state of the predecessor edge, so
|
|
1016
|
+
* consumers derive it from the previous row.
|
|
1017
|
+
*/
|
|
1018
|
+
readonly endContractJson?: unknown;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Canonical structural shape of a contract space — one disjoint
|
|
1022
|
+
* `(contractJson, migration-graph)` unit the per-space planner / runner
|
|
1023
|
+
* / verifier operates on. The application owns one well-known space
|
|
1024
|
+
* ({@link APP_SPACE_ID}); each loaded extension that contributes schema
|
|
1025
|
+
* owns a uniquely-named space. Whether a value is the app's space or an
|
|
1026
|
+
* extension's space is a control-plane concern; the type carries no
|
|
1027
|
+
* such distinction.
|
|
1028
|
+
*
|
|
1029
|
+
* Generic over the contract so each family pins a typed contract value
|
|
1030
|
+
* at consumption time. The SQL family specialises to
|
|
1031
|
+
* `ContractSpace<Contract<SqlStorage>>` at the descriptor surface;
|
|
1032
|
+
* Mongo's symmetrical `ContractSpace<Contract<MongoStorage>>` will land
|
|
1033
|
+
* with that family.
|
|
1034
|
+
*
|
|
1035
|
+
* @see specs/framework-mechanism.spec.md § 1.
|
|
1036
|
+
*/
|
|
1037
|
+
interface ContractSpace<TContract extends Contract = Contract> {
|
|
1038
|
+
readonly contractJson: TContract;
|
|
1039
|
+
readonly migrations: readonly MigrationPackage[];
|
|
1040
|
+
readonly headRef: ContractSpaceHeadRef;
|
|
1041
|
+
}
|
|
1042
|
+
//#endregion
|
|
1043
|
+
//#region src/control/control-stack.d.ts
|
|
1044
|
+
interface AssembledAuthoringContributions {
|
|
1045
|
+
readonly field: AuthoringFieldNamespace;
|
|
1046
|
+
readonly type: AuthoringTypeNamespace;
|
|
1047
|
+
readonly entityTypes: AuthoringEntityTypeNamespace;
|
|
1048
|
+
readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;
|
|
1049
|
+
readonly modelAttributes: AuthoringModelAttributeDescriptorNamespace;
|
|
1050
|
+
/** The single {@link AuthoringContributions.valueObjectStorageType} declared across the composed components, validated at assembly against the merged `type` namespace. */
|
|
1051
|
+
readonly valueObjectStorageType?: string;
|
|
1052
|
+
}
|
|
1053
|
+
interface ControlStack<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
1054
|
+
readonly family: ControlFamilyDescriptor<TFamilyId>;
|
|
1055
|
+
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
1056
|
+
readonly adapter?: ControlAdapterDescriptor<TFamilyId, TTargetId> | undefined;
|
|
1057
|
+
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;
|
|
1058
|
+
readonly extensions: readonly ControlExtensionDescriptor<TFamilyId, TTargetId>[];
|
|
1059
|
+
readonly extensionContracts: ReadonlyMap<string, Contract>;
|
|
1060
|
+
readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
1061
|
+
readonly queryOperationTypeImports: ReadonlyArray<TypesImportSpec>;
|
|
1062
|
+
readonly extensionIds: ReadonlyArray<string>;
|
|
1063
|
+
readonly codecLookup: CodecRegistry;
|
|
1064
|
+
readonly authoringContributions: AssembledAuthoringContributions;
|
|
1065
|
+
/** Names of the top-level zero-arg type constructors in the assembled authoring namespace — the base scalars of the composed stack. */
|
|
1066
|
+
readonly scalarTypes: ReadonlyArray<string>;
|
|
1067
|
+
readonly controlMutationDefaults: ControlMutationDefaults;
|
|
1068
|
+
readonly capabilities: CapabilityMatrix;
|
|
1069
|
+
}
|
|
1070
|
+
interface CreateControlStackInput<TFamilyId extends string = string, TTargetId extends string = string> {
|
|
1071
|
+
readonly family: ControlFamilyDescriptor<TFamilyId>;
|
|
1072
|
+
readonly target: ControlTargetDescriptor<TFamilyId, TTargetId>;
|
|
1073
|
+
readonly adapter?: ControlAdapterDescriptor<TFamilyId, TTargetId> | undefined;
|
|
1074
|
+
readonly driver?: ControlDriverDescriptor<TFamilyId, TTargetId> | undefined;
|
|
1075
|
+
readonly extensions?: ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>> | undefined;
|
|
1076
|
+
}
|
|
1077
|
+
declare function assertUniqueCodecOwner(options: {
|
|
1078
|
+
readonly codecId: string;
|
|
1079
|
+
readonly owners: Map<string, string>;
|
|
1080
|
+
readonly descriptorId: string;
|
|
1081
|
+
readonly entityLabel: string;
|
|
1082
|
+
readonly entityOwnershipLabel: string;
|
|
1083
|
+
}): void;
|
|
1084
|
+
declare function extractCodecTypeImports(descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>): ReadonlyArray<TypesImportSpec>;
|
|
1085
|
+
declare function extractQueryOperationTypeImports(descriptors: ReadonlyArray<Pick<ComponentMetadata, 'types'>>): ReadonlyArray<TypesImportSpec>;
|
|
1086
|
+
declare function extractComponentIds(family: {
|
|
1087
|
+
readonly id: string;
|
|
1088
|
+
}, target: {
|
|
1089
|
+
readonly id: string;
|
|
1090
|
+
}, adapter: {
|
|
1091
|
+
readonly id: string;
|
|
1092
|
+
} | undefined, extensions: ReadonlyArray<{
|
|
1093
|
+
readonly id: string;
|
|
1094
|
+
}>): ReadonlyArray<string>;
|
|
1095
|
+
declare function assembleAuthoringContributions(descriptors: ReadonlyArray<{
|
|
1096
|
+
readonly id?: string;
|
|
1097
|
+
readonly authoring?: AuthoringContributions;
|
|
1098
|
+
}>): AssembledAuthoringContributions;
|
|
1099
|
+
declare function assembleControlMutationDefaults(descriptors: ReadonlyArray<Pick<ComponentMetadata, 'controlMutationDefaults'> & {
|
|
1100
|
+
readonly id?: string;
|
|
1101
|
+
}>): ControlMutationDefaults;
|
|
1102
|
+
declare function extractCodecLookup(descriptors: ReadonlyArray<Pick<ComponentMetadata & {
|
|
1103
|
+
id: string;
|
|
1104
|
+
}, 'types' | 'id'>>): CodecRegistry;
|
|
1105
|
+
interface DependencyDeclaringDescriptor {
|
|
1106
|
+
readonly id: string;
|
|
1107
|
+
readonly contractSpace?: {
|
|
1108
|
+
readonly contractJson?: {
|
|
1109
|
+
readonly extensions?: Readonly<Record<string, unknown>>;
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Builds a dependency-respecting load order for the given extension descriptors
|
|
1115
|
+
* using Kahn's topological sort algorithm. Dependencies (packs declared in
|
|
1116
|
+
* `contractSpace.contractJson.extensions`) are placed before the extensions
|
|
1117
|
+
* that depend on them.
|
|
1118
|
+
*
|
|
1119
|
+
* Throws if the dependency graph contains a cycle, with an error message that
|
|
1120
|
+
* names every extension involved in the cycle.
|
|
1121
|
+
*
|
|
1122
|
+
* Throws if any extension declares a dependency on a pack ID that is not present
|
|
1123
|
+
* in the provided list — add the missing pack to the `extensions` list to
|
|
1124
|
+
* resolve the error.
|
|
1125
|
+
*/
|
|
1126
|
+
declare function buildExtensionLoadOrder(extensions: ReadonlyArray<DependencyDeclaringDescriptor>): readonly string[];
|
|
1127
|
+
declare function createControlStack<TFamilyId extends string, TTargetId extends string>(input: CreateControlStackInput<TFamilyId, TTargetId>): ControlStack<TFamilyId, TTargetId>;
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region src/control/control-descriptors.d.ts
|
|
1130
|
+
interface ControlFamilyDescriptor<TFamilyId extends string, TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<TFamilyId, unknown>> extends FamilyDescriptor<TFamilyId> {
|
|
1131
|
+
readonly emission: EmissionSpi;
|
|
1132
|
+
create<TTargetId extends string>(stack: ControlStack<TFamilyId, TTargetId>): TFamilyInstance;
|
|
1133
|
+
}
|
|
1134
|
+
interface ControlTargetDescriptor<TFamilyId extends string, TTargetId extends string, TTargetInstance extends ControlTargetInstance<TFamilyId, TTargetId> = ControlTargetInstance<TFamilyId, TTargetId>, TContract extends Contract = Contract> extends TargetDescriptor<TFamilyId, TTargetId> {
|
|
1135
|
+
/**
|
|
1136
|
+
* JSON ⇄ class boundary for this target's contract. Every target
|
|
1137
|
+
* ships the SPI: framework consumers reach the serializer through
|
|
1138
|
+
* `descriptor.contractSerializer` rather than importing a per-target
|
|
1139
|
+
* `deserializeContract` helper. The descriptor IS the aggregator.
|
|
1140
|
+
*/
|
|
1141
|
+
readonly contractSerializer: ContractSerializer<TContract>;
|
|
1142
|
+
create(): TTargetInstance;
|
|
1143
|
+
}
|
|
1144
|
+
interface ControlAdapterDescriptor<TFamilyId extends string, TTargetId extends string, TAdapterInstance extends ControlAdapterInstance<TFamilyId, TTargetId> = ControlAdapterInstance<TFamilyId, TTargetId>> extends AdapterDescriptor<TFamilyId, TTargetId> {
|
|
1145
|
+
/**
|
|
1146
|
+
* Construct a control adapter instance for this stack.
|
|
1147
|
+
*
|
|
1148
|
+
* The `stack` argument mirrors `ControlFamilyDescriptor.create(stack)`:
|
|
1149
|
+
* adapter implementations may inspect `stack.codecLookup`, extension packs,
|
|
1150
|
+
* or other assembled metadata when constructing the instance.
|
|
1151
|
+
*/
|
|
1152
|
+
create(stack: ControlStack<TFamilyId, TTargetId>): TAdapterInstance;
|
|
1153
|
+
}
|
|
1154
|
+
interface ControlDriverDescriptor<TFamilyId extends string, TTargetId extends string, TDriverInstance extends ControlDriverInstance<TFamilyId, TTargetId> = ControlDriverInstance<TFamilyId, TTargetId>, TConnection = string> extends DriverDescriptor<TFamilyId, TTargetId> {
|
|
1155
|
+
create(connection: TConnection): Promise<TDriverInstance>;
|
|
1156
|
+
}
|
|
1157
|
+
interface ControlExtensionDescriptor<TFamilyId extends string, TTargetId extends string, TExtensionInstance extends ControlExtensionInstance<TFamilyId, TTargetId> = ControlExtensionInstance<TFamilyId, TTargetId>> extends ExtensionDescriptor<TFamilyId, TTargetId> {
|
|
1158
|
+
readonly contractSpace?: ContractSpace;
|
|
1159
|
+
create(): TExtensionInstance;
|
|
1160
|
+
}
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/control/control-operation-preview.d.ts
|
|
1163
|
+
/**
|
|
1164
|
+
* Family-agnostic textual preview of a migration plan, used by the CLI to
|
|
1165
|
+
* render a "DDL preview" section for `db init` / `db update` / `migration plan`
|
|
1166
|
+
* / `migration show`. Each statement carries a free-form `language` tag so
|
|
1167
|
+
* formatters can suffix `;` for SQL but render Mongo shell lines verbatim.
|
|
1168
|
+
*
|
|
1169
|
+
* Producers are family-specific: SQL emits `language: 'sql'` (existing DDL
|
|
1170
|
+
* extraction); Mongo emits `language: 'mongodb-shell'` via the
|
|
1171
|
+
* `MongoDdlCommandFormatter` visitor.
|
|
1172
|
+
*
|
|
1173
|
+
* The capability `OperationPreviewCapable` (declared in
|
|
1174
|
+
* `./control-capabilities`) is how a family announces it can produce these.
|
|
1175
|
+
*/
|
|
1176
|
+
interface OperationPreviewStatement {
|
|
1177
|
+
readonly text: string;
|
|
1178
|
+
/** Dialect identifier, e.g. `'sql'`, `'mongodb-shell'`. Free-form by design (OQ-3). */
|
|
1179
|
+
readonly language: string;
|
|
1180
|
+
}
|
|
1181
|
+
interface OperationPreview {
|
|
1182
|
+
readonly statements: readonly OperationPreviewStatement[];
|
|
1183
|
+
}
|
|
1184
|
+
//#endregion
|
|
1185
|
+
//#region src/control/control-schema-view.d.ts
|
|
1186
|
+
/**
|
|
1187
|
+
* Core schema view types for family-agnostic schema visualization.
|
|
1188
|
+
*
|
|
1189
|
+
* These types provide a minimal, generic, tree-shaped representation of schemas
|
|
1190
|
+
* across families, designed for CLI visualization and lightweight tooling.
|
|
1191
|
+
*
|
|
1192
|
+
* Families can optionally project their family-specific Schema IR into this
|
|
1193
|
+
* core view via the `toSchemaView` method on `FamilyInstance`.
|
|
1194
|
+
*/
|
|
1195
|
+
type SchemaViewNodeKind = 'root' | 'namespace' | 'collection' | 'entity' | 'field' | 'index' | 'dependency';
|
|
1196
|
+
interface SchemaTreeVisitor<R> {
|
|
1197
|
+
visit(node: SchemaTreeNode): R;
|
|
1198
|
+
}
|
|
1199
|
+
interface SchemaTreeNodeOptions {
|
|
1200
|
+
readonly kind: SchemaViewNodeKind;
|
|
1201
|
+
readonly id: string;
|
|
1202
|
+
readonly label: string;
|
|
1203
|
+
readonly meta?: Record<string, unknown>;
|
|
1204
|
+
readonly children?: readonly SchemaTreeNode[];
|
|
1205
|
+
}
|
|
1206
|
+
declare class SchemaTreeNode {
|
|
1207
|
+
readonly kind: SchemaViewNodeKind;
|
|
1208
|
+
readonly id: string;
|
|
1209
|
+
readonly label: string;
|
|
1210
|
+
readonly meta?: Record<string, unknown>;
|
|
1211
|
+
readonly children?: readonly SchemaTreeNode[];
|
|
1212
|
+
constructor(options: SchemaTreeNodeOptions);
|
|
1213
|
+
accept<R>(visitor: SchemaTreeVisitor<R>): R;
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Core schema view providing a family-agnostic tree representation of a schema.
|
|
1217
|
+
* Used by CLI and cross-family tooling for visualization.
|
|
1218
|
+
*/
|
|
1219
|
+
interface CoreSchemaView {
|
|
1220
|
+
readonly root: SchemaTreeNode;
|
|
1221
|
+
}
|
|
1222
|
+
//#endregion
|
|
1223
|
+
//#region src/control/control-capabilities.d.ts
|
|
1224
|
+
interface MigratableTargetDescriptor<TFamilyId extends string, TTargetId extends string, TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<TFamilyId, unknown>> extends ControlTargetDescriptor<TFamilyId, TTargetId> {
|
|
1225
|
+
readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;
|
|
1226
|
+
}
|
|
1227
|
+
declare function hasMigrations<TFamilyId extends string, TTargetId extends string>(target: ControlTargetDescriptor<TFamilyId, TTargetId>): target is MigratableTargetDescriptor<TFamilyId, TTargetId>;
|
|
1228
|
+
interface SchemaViewCapable<TSchemaIR = unknown> {
|
|
1229
|
+
toSchemaView(schema: TSchemaIR): CoreSchemaView;
|
|
1230
|
+
}
|
|
1231
|
+
declare function hasSchemaView<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaViewCapable<TSchemaIR>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Capability declaring that a family can infer a PSL contract AST from its
|
|
1234
|
+
* opaque introspected schema IR. Consumed by `prisma-next contract infer`.
|
|
1235
|
+
*/
|
|
1236
|
+
interface PslContractInferCapable<TSchemaIR = unknown> {
|
|
1237
|
+
inferPslContract(schemaIR: TSchemaIR): PslDocumentAst;
|
|
1238
|
+
}
|
|
1239
|
+
declare function hasPslContractInfer<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & PslContractInferCapable<TSchemaIR>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Capability declaring that a family can render a textual preview of migration
|
|
1242
|
+
* operations for the CLI's "DDL preview" output. SQL families emit
|
|
1243
|
+
* `language: 'sql'` statements; Mongo families emit `language: 'mongodb-shell'`.
|
|
1244
|
+
*/
|
|
1245
|
+
interface OperationPreviewCapable {
|
|
1246
|
+
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
|
|
1247
|
+
}
|
|
1248
|
+
declare function hasOperationPreview<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & OperationPreviewCapable;
|
|
1249
|
+
/**
|
|
1250
|
+
* The granularity of a {@link SchemaDiffIssue}'s subject, resolved on demand
|
|
1251
|
+
* from the issue's node `nodeKind` — never stamped on the issue or the node.
|
|
1252
|
+
*
|
|
1253
|
+
* - `namespace`: a whole namespace.
|
|
1254
|
+
* - `entity`: a whole top-level entity (the thing a namespace contains).
|
|
1255
|
+
* - `field`: a field of an entity.
|
|
1256
|
+
* - `auxiliary`: a secondary part of an entity (an index, a default, a key).
|
|
1257
|
+
* - `structural`: a cross-cutting object (an access policy, a tree root) that
|
|
1258
|
+
* is the owning space's own concern, never a sibling's unclaimed entity —
|
|
1259
|
+
* its extras fail verify in both modes.
|
|
1260
|
+
*/
|
|
1261
|
+
type DiffSubjectGranularity = 'namespace' | 'entity' | 'field' | 'auxiliary' | 'structural';
|
|
1262
|
+
/**
|
|
1263
|
+
* Capability declaring that a family can classify a {@link SchemaDiffIssue}'s
|
|
1264
|
+
* subject granularity, and separately its storage `entityKind`, on demand —
|
|
1265
|
+
* both resolved from its node's `nodeKind` through the family/target
|
|
1266
|
+
* vocabulary it owns. Consumed by framework code that spans contract spaces
|
|
1267
|
+
* (the migration aggregate's unclaimed-elements sweep) and cannot itself read
|
|
1268
|
+
* family/target node vocabulary, so it asks this capability instead of
|
|
1269
|
+
* hardcoding a family entity kind. `undefined` when the issue's node kind is
|
|
1270
|
+
* unrecognized, or when the family injects no classifier at all — callers
|
|
1271
|
+
* fall back to path shape in that case.
|
|
1272
|
+
*
|
|
1273
|
+
* `classifyEntityKind` returns the same per-family vocabulary as the contract
|
|
1274
|
+
* storage's `entries` dictionary keys (the vocabulary
|
|
1275
|
+
* {@link import('../ir/storage').elementCoordinates} walks) — never a
|
|
1276
|
+
* granularity word, and never a word this framework layer names itself.
|
|
1277
|
+
*/
|
|
1278
|
+
interface SchemaSubjectClassifierCapable {
|
|
1279
|
+
classifySubjectGranularity(issue: SchemaDiffIssue): DiffSubjectGranularity | undefined;
|
|
1280
|
+
classifyEntityKind(issue: SchemaDiffIssue): string | undefined;
|
|
1281
|
+
}
|
|
1282
|
+
declare function hasSchemaSubjectClassifier<TFamilyId extends string, TSchemaIR>(instance: ControlFamilyInstance<TFamilyId, TSchemaIR>): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaSubjectClassifierCapable;
|
|
1283
|
+
//#endregion
|
|
1284
|
+
//#region src/control/order-issues-by-dependencies.d.ts
|
|
1285
|
+
/**
|
|
1286
|
+
* Orders schema-diff issues so that every dependency's op precedes its
|
|
1287
|
+
* dependent on the way up and follows it on the way down, breaking ties
|
|
1288
|
+
* deterministically by path.
|
|
1289
|
+
*
|
|
1290
|
+
* Edges come from two sources:
|
|
1291
|
+
* - **`dependsOn` cross-links** — the resolved issue-to-issue paths the differ
|
|
1292
|
+
* mirrors onto each issue (a node's declared structural prerequisites). A
|
|
1293
|
+
* path that resolves to no issue in this list is skipped (the dependency is
|
|
1294
|
+
* satisfied by reality); a path shared by two same-id/different-kind siblings
|
|
1295
|
+
* links to every match, over-constraining safely.
|
|
1296
|
+
* - **containment** — every issue depends on its nearest strict-ancestor issue
|
|
1297
|
+
* (a child entity on the parent entity that owns it). Subtree coalescing has
|
|
1298
|
+
* already removed the descendants of a whole create/drop, so this only links
|
|
1299
|
+
* the parent/child pairs that legitimately survive together.
|
|
1300
|
+
*
|
|
1301
|
+
* The ordering law reads each dependent's presence for direction: an issue that
|
|
1302
|
+
* builds up (`expected` present — a create or alter) needs its dependency
|
|
1303
|
+
* first; a pure drop needs its dependent removed first, so the edge reverses.
|
|
1304
|
+
* The graph is a DAG by construction (dependencies point from dependents to
|
|
1305
|
+
* their prerequisites, and prerequisites never point back), so a cycle is a
|
|
1306
|
+
* derivation or authoring bug: the topological sort asserts acyclicity and
|
|
1307
|
+
* throws, naming the issues it could not place.
|
|
1308
|
+
*/
|
|
1309
|
+
declare function orderIssuesByDependencies<TNode extends DiffableNode = DiffableNode>(issues: readonly SchemaDiffIssue<TNode>[]): readonly SchemaDiffIssue<TNode>[];
|
|
1310
|
+
//#endregion
|
|
1311
|
+
//#region src/control/schema-verifier.d.ts
|
|
1312
|
+
/**
|
|
1313
|
+
* Framework SPI for verifying that an introspected schema matches the
|
|
1314
|
+
* contract that authored it. The implementer walks the target's IR
|
|
1315
|
+
* natively — concrete classes, target-only kinds — and reports issues.
|
|
1316
|
+
*
|
|
1317
|
+
* The framework verifier (per FR6) walks the contract-space aggregate,
|
|
1318
|
+
* dispatches to the right target's verifier (`descriptor.schemaVerifier`)
|
|
1319
|
+
* per space, and wraps the per-target results into a unified
|
|
1320
|
+
* `VerifyDatabaseSchemaResult` with timings, summary, and the issue list.
|
|
1321
|
+
*
|
|
1322
|
+
* Family-level abstract bases (e.g. `SqlSchemaVerifierBase`) carry the
|
|
1323
|
+
* shared SQL/Mongo walk logic and expose protected hooks for target
|
|
1324
|
+
* extensions; concrete target verifiers (`PostgresSchemaVerifier extends
|
|
1325
|
+
* SqlSchemaVerifierBase`) own the dispatch on target-specific kinds.
|
|
1326
|
+
*/
|
|
1327
|
+
interface SchemaVerifier<TContract, TSchema> {
|
|
1328
|
+
verifySchema(options: SchemaVerifyOptions<TContract, TSchema>): SchemaVerifyResult;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Minimal per-target verifier input. Family abstract bases extend this
|
|
1332
|
+
* shape with family-specific options (`strict`, `frameworkComponents`,
|
|
1333
|
+
* codec hooks, …) — the framework SPI itself stays at the contract +
|
|
1334
|
+
* schema pair every implementer needs.
|
|
1335
|
+
*/
|
|
1336
|
+
interface SchemaVerifyOptions<TContract, TSchema> {
|
|
1337
|
+
readonly contract: TContract;
|
|
1338
|
+
readonly schema: TSchema;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Per-target verifier result. The framework verifier wraps these into the
|
|
1342
|
+
* existing `VerifyDatabaseSchemaResult` envelope (with timings, summary,
|
|
1343
|
+
* issue list); the SPI itself returns just the core ok/issues pair so the
|
|
1344
|
+
* seam between target-walk and framework-aggregation is explicit.
|
|
1345
|
+
*/
|
|
1346
|
+
interface SchemaVerifyResult {
|
|
1347
|
+
readonly ok: boolean;
|
|
1348
|
+
readonly issues: readonly SchemaDiffIssue[];
|
|
1349
|
+
}
|
|
1350
|
+
//#endregion
|
|
1351
|
+
//#region src/control/verifier-disposition.d.ts
|
|
1352
|
+
type VerificationStatus = 'pass' | 'warn' | 'fail';
|
|
1353
|
+
type VerifierOutcome = VerificationStatus | 'suppress';
|
|
1354
|
+
/**
|
|
1355
|
+
* Target-neutral classification of a verifier finding, abstracted away from any
|
|
1356
|
+
* one storage model's vocabulary. Each family classifies its own concrete issue
|
|
1357
|
+
* kinds into these categories; the framework only grades the category against a
|
|
1358
|
+
* control policy.
|
|
1359
|
+
*
|
|
1360
|
+
* - `declaredMissing` — a declared object/element is absent from the database.
|
|
1361
|
+
* - `declaredIncompatible` — a declared object/element exists but its shape diverges.
|
|
1362
|
+
* - `valueDrift` — the value set of an existing type drifted (e.g. enum values).
|
|
1363
|
+
* - `extraNestedElement` — an undeclared element nested inside a declared object
|
|
1364
|
+
* (a SQL column, a document field).
|
|
1365
|
+
* - `extraAuxiliary` — an undeclared auxiliary attached to a declared object
|
|
1366
|
+
* (a SQL constraint/index, a Mongo index/validator).
|
|
1367
|
+
* - `extraTopLevelObject` — an undeclared top-level object (a SQL table, a
|
|
1368
|
+
* Mongo collection).
|
|
1369
|
+
*/
|
|
1370
|
+
type VerifierIssueCategory = 'declaredMissing' | 'declaredIncompatible' | 'valueDrift' | 'extraNestedElement' | 'extraAuxiliary' | 'extraTopLevelObject';
|
|
1371
|
+
/**
|
|
1372
|
+
* Grades a target-neutral issue category against a control policy.
|
|
1373
|
+
*
|
|
1374
|
+
* - `observed` warns on everything.
|
|
1375
|
+
* - `tolerated` suppresses only an extra nested element (everything else fails).
|
|
1376
|
+
* - `external` suppresses every extra category and value drift (existence and
|
|
1377
|
+
* declared-shape divergences still fail).
|
|
1378
|
+
* - `managed` (and any other) fails.
|
|
1379
|
+
*/
|
|
1380
|
+
declare function dispositionForCategory(controlPolicy: ControlPolicy, category: VerifierIssueCategory): VerifierOutcome;
|
|
1381
|
+
//#endregion
|
|
1382
|
+
export { SchemaDiffIssue as $, MigrationPlan as A, diffSchemas as At, MigrationRunnerFailure as B, hasSchemaView as Bt, ExpectationFailureReason as C, assembleAuthoringContributions as Ct, MigrationOperationClass as D, contractSnapshotJsonSpecifier as Dt, MigrationMetadata as E, buildExtensionLoadOrder as Et, MigrationPlannerFailureResult as F, extractQueryOperationTypeImports as Ft, MigrationScaffoldContext as G, MigrationRunnerPerSpaceSuccessValue as H, orderIssuesByDependencies as Ht, MigrationPlannerResult as I, hasMigrations as It, OperationPreview as J, OpFactoryCall as K, MigrationPlannerSuccessResult as L, hasOperationPreview as Lt, MigrationPlanWithAuthoringSurface as M, extractCodecLookup as Mt, MigrationPlanner as N, extractCodecTypeImports as Nt, MigrationOperationPolicy as O, contractSnapshotTypesSpecifier as Ot, MigrationPlannerConflict as P, extractComponentIds as Pt, SchemaDiff as Q, MigrationRunner as R, hasPslContractInfer as Rt, EmitContractResult as S, VerifyDatabaseSchemaResult as St, MigratableTargetDescriptor as T, assertUniqueCodecOwner as Tt, MigrationRunnerResult as U, storageHashHex as Ut, MigrationRunnerPerSpaceOptions as V, issueOutcome as Vt, MigrationRunnerSuccessValue as W, OperationPreviewStatement as X, OperationPreviewCapable as Y, PslContractInferCapable as Z, ControlTargetInstance as _, VERIFY_CODE_TARGET_MISMATCH as _t, ContractSpace as a, SchemaTreeNodeOptions as at, DiffSubjectGranularity as b, VerifierOutcome as bt, ControlAdapterInstance as c, SchemaVerifyOptions as ct, ControlExtensionDescriptor as d, SchemaViewNodeKind as dt, SchemaEntityCoordinate as et, ControlExtensionInstance as f, SignDatabaseResult as ft, ControlTargetDescriptor as g, VERIFY_CODE_SCHEMA_FAILURE as gt, ControlStack as h, VERIFY_CODE_MARKER_MISSING as ht, ContractSerializer as i, SchemaTreeNode as it, MigrationPlanOperation as j, dispositionForCategory as jt, MigrationPackage as k, createControlStack as kt, ControlDriverDescriptor as l, SchemaVerifyResult as lt, ControlFamilyInstance as m, VERIFY_CODE_HASH_MISMATCH as mt, AssembledAuthoringContributions as n, SchemaOwnership as nt, ContractSpaceHeadRef as o, SchemaTreeVisitor as ot, ControlFamilyDescriptor as p, TargetMigrationsCapability as pt, OperationContext as q, CONTRACT_SNAPSHOTS_DIRNAME as r, SchemaSubjectClassifierCapable as rt, ControlAdapterDescriptor as s, SchemaVerifier as st, APP_SPACE_ID as t, SchemaNodeRef as tt, ControlDriverInstance as u, SchemaViewCapable as ut, CoreSchemaView as v, VerificationStatus as vt, IntrospectSchemaResult as w, assembleControlMutationDefaults as wt, DiffableNode as x, VerifyDatabaseResult as xt, CreateControlStackInput as y, VerifierIssueCategory as yt, MigrationRunnerExecutionChecks as z, hasSchemaSubjectClassifier as zt };
|
|
1383
|
+
//# sourceMappingURL=control-CBvTj7Ia.d.mts.map
|