@geekmidas/cli 10.0.0-alpha.17 → 10.0.0-alpha.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +323 -380
- package/bin/adjacent-tsconfig.mjs +46 -8
- package/bin/gkm.mjs +11 -3
- package/bin/owning-tsconfig-jsx-register.mjs +18 -0
- package/bin/owning-tsconfig-jsx.mjs +108 -0
- package/dist/EndpointGenerator-C1h_wExz.cjs +1098 -0
- package/dist/EndpointGenerator-C1h_wExz.cjs.map +1 -0
- package/dist/EndpointGenerator-CSKhAD6W.mjs +1039 -0
- package/dist/EndpointGenerator-CSKhAD6W.mjs.map +1 -0
- package/dist/GoDaddyProvider-Cf4MIuaD.mjs +412 -0
- package/dist/GoDaddyProvider-Cf4MIuaD.mjs.map +1 -0
- package/dist/GoDaddyProvider-DK9_Jw9d.cjs +412 -0
- package/dist/GoDaddyProvider-DK9_Jw9d.cjs.map +1 -0
- package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-CQebZrz3.mjs} +23 -9
- package/dist/HostingerProvider-CQebZrz3.mjs.map +1 -0
- package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-qQzo4MYp.cjs} +23 -9
- package/dist/HostingerProvider-qQzo4MYp.cjs.map +1 -0
- package/dist/LegacyStateStore-BeMRGXRi.cjs +124 -0
- package/dist/LegacyStateStore-BeMRGXRi.cjs.map +1 -0
- package/dist/LegacyStateStore-DXPHKdMk.mjs +124 -0
- package/dist/LegacyStateStore-DXPHKdMk.mjs.map +1 -0
- package/dist/LocalStateStore-BYQ9lPje.mjs +167 -0
- package/dist/LocalStateStore-BYQ9lPje.mjs.map +1 -0
- package/dist/LocalStateStore-E_sa5GR2.cjs +178 -0
- package/dist/LocalStateStore-E_sa5GR2.cjs.map +1 -0
- package/dist/OpenApiTsGenerator-5xPn-p65.mjs +534 -0
- package/dist/OpenApiTsGenerator-5xPn-p65.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-CzrLGzC0.cjs +539 -0
- package/dist/OpenApiTsGenerator-CzrLGzC0.cjs.map +1 -0
- package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
- package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
- package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
- package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
- package/dist/S3StateStore-BQaGVNRf.mjs +223 -0
- package/dist/S3StateStore-BQaGVNRf.mjs.map +1 -0
- package/dist/S3StateStore-Cjr4Rtsf.cjs +222 -0
- package/dist/S3StateStore-Cjr4Rtsf.cjs.map +1 -0
- package/dist/SSMStateStore-Bq_S7x5_.mjs +205 -0
- package/dist/SSMStateStore-Bq_S7x5_.mjs.map +1 -0
- package/dist/SSMStateStore-Cnfwdlme.cjs +204 -0
- package/dist/SSMStateStore-Cnfwdlme.cjs.map +1 -0
- package/dist/SubscriberGenerator-CfZWX0lT.mjs +783 -0
- package/dist/SubscriberGenerator-CfZWX0lT.mjs.map +1 -0
- package/dist/SubscriberGenerator-DMi4siph.cjs +848 -0
- package/dist/SubscriberGenerator-DMi4siph.cjs.map +1 -0
- package/dist/add-3_IHpF5F.cjs +713 -0
- package/dist/add-3_IHpF5F.cjs.map +1 -0
- package/dist/add-CNQFnG0C.mjs +711 -0
- package/dist/add-CNQFnG0C.mjs.map +1 -0
- package/dist/appPorts-BoXMwolc.mjs +249 -0
- package/dist/appPorts-BoXMwolc.mjs.map +1 -0
- package/dist/appPorts-IW-OZmRi.cjs +296 -0
- package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
- package/dist/apps-BGu47YRF.cjs +6404 -0
- package/dist/apps-BGu47YRF.cjs.map +1 -0
- package/dist/apps-DGod3aS9.mjs +5765 -0
- package/dist/apps-DGod3aS9.mjs.map +1 -0
- package/dist/aws-C5LAU_Ii.mjs +97 -0
- package/dist/aws-C5LAU_Ii.mjs.map +1 -0
- package/dist/aws-DKC2m3sT.cjs +108 -0
- package/dist/aws-DKC2m3sT.cjs.map +1 -0
- package/dist/awsStore-Bx5nCFnS.mjs +121 -0
- package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
- package/dist/awsStore-u3ehhMoY.cjs +138 -0
- package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
- package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
- package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
- package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
- package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
- package/dist/backups/runner.cjs +519 -0
- package/dist/backups/runner.cjs.map +1 -0
- package/dist/backups/runner.d.cts +102 -0
- package/dist/backups/runner.d.cts.map +1 -0
- package/dist/backups/runner.d.mts +102 -0
- package/dist/backups/runner.d.mts.map +1 -0
- package/dist/backups/runner.mjs +506 -0
- package/dist/backups/runner.mjs.map +1 -0
- package/dist/{bundler-mjqGAvu1.cjs → bundler-DWGxNGSB.cjs} +59 -14
- package/dist/bundler-DWGxNGSB.cjs.map +1 -0
- package/dist/{bundler-mwH7WOb1.mjs → bundler-Dm0mB7EK.mjs} +59 -14
- package/dist/bundler-Dm0mB7EK.mjs.map +1 -0
- package/dist/cli-CYeZF85I.cjs +80 -0
- package/dist/cli-CYeZF85I.cjs.map +1 -0
- package/dist/cli-Qm-8tG46.mjs +80 -0
- package/dist/cli-Qm-8tG46.mjs.map +1 -0
- package/dist/compose-BVeevJO_.mjs +3139 -0
- package/dist/compose-BVeevJO_.mjs.map +1 -0
- package/dist/compose-CXgwCuqv.mjs +1560 -0
- package/dist/compose-CXgwCuqv.mjs.map +1 -0
- package/dist/compose-CshnO-Th.cjs +1919 -0
- package/dist/compose-CshnO-Th.cjs.map +1 -0
- package/dist/compose-IsvqY6iX.cjs +3240 -0
- package/dist/compose-IsvqY6iX.cjs.map +1 -0
- package/dist/config-B8gSu59v.d.mts +291 -0
- package/dist/config-B8gSu59v.d.mts.map +1 -0
- package/dist/config-u5XdE1Cq.d.cts +291 -0
- package/dist/config-u5XdE1Cq.d.cts.map +1 -0
- package/dist/config.cjs +457 -9
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +4 -117
- package/dist/config.d.mts +4 -117
- package/dist/config.mjs +441 -3
- package/dist/config.mjs.map +1 -0
- package/dist/credentialSchemas-BzJiK1nQ.mjs +236 -0
- package/dist/credentialSchemas-BzJiK1nQ.mjs.map +1 -0
- package/dist/credentialSchemas-OVXofU-r.cjs +271 -0
- package/dist/credentialSchemas-OVXofU-r.cjs.map +1 -0
- package/dist/credentials-CKIeLL7T.mjs +1838 -0
- package/dist/credentials-CKIeLL7T.mjs.map +1 -0
- package/dist/credentials-DzR2j8h1.cjs +2293 -0
- package/dist/credentials-DzR2j8h1.cjs.map +1 -0
- package/dist/databases-CuTL1e7s.cjs +703 -0
- package/dist/databases-CuTL1e7s.cjs.map +1 -0
- package/dist/databases-zN-gEox0.mjs +588 -0
- package/dist/databases-zN-gEox0.mjs.map +1 -0
- package/dist/define-6poNqm5O.mjs +106 -0
- package/dist/define-6poNqm5O.mjs.map +1 -0
- package/dist/define-crmMcXFS.cjs +153 -0
- package/dist/define-crmMcXFS.cjs.map +1 -0
- package/dist/deploy/public.cjs +211 -0
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +658 -0
- package/dist/deploy/public.d.cts.map +1 -0
- package/dist/deploy/public.d.mts +658 -0
- package/dist/deploy/public.d.mts.map +1 -0
- package/dist/deploy/public.mjs +144 -0
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/deploy/sniffer-hooks.cjs +1 -1
- package/dist/deploy/sniffer-hooks.mjs +1 -1
- package/dist/deploy/sniffer-loader.cjs +2 -2
- package/dist/deploy/sniffer-loader.mjs +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +1 -1
- package/dist/deploy-CjubyZlP.mjs +3848 -0
- package/dist/deploy-CjubyZlP.mjs.map +1 -0
- package/dist/deploy-DQjEjUfB.cjs +3904 -0
- package/dist/deploy-DQjEjUfB.cjs.map +1 -0
- package/dist/destroy-D1375m8C.cjs +789 -0
- package/dist/destroy-D1375m8C.cjs.map +1 -0
- package/dist/destroy-D4m5aO9k.mjs +788 -0
- package/dist/destroy-D4m5aO9k.mjs.map +1 -0
- package/dist/discover-39VKSE2i.cjs +1085 -0
- package/dist/discover-39VKSE2i.cjs.map +1 -0
- package/dist/discover-B_PDDaVj.mjs +940 -0
- package/dist/discover-B_PDDaVj.mjs.map +1 -0
- package/dist/docker-C27YUUMQ.mjs +1413 -0
- package/dist/docker-C27YUUMQ.mjs.map +1 -0
- package/dist/docker-CSEAKwFr.cjs +1520 -0
- package/dist/docker-CSEAKwFr.cjs.map +1 -0
- package/dist/dokploy-CSqDsvY-.mjs +38 -0
- package/dist/dokploy-CSqDsvY-.mjs.map +1 -0
- package/dist/dokploy-DJDdiFz6.cjs +38 -0
- package/dist/dokploy-DJDdiFz6.cjs.map +1 -0
- package/dist/drivers-BhdC9Efj.cjs +248 -0
- package/dist/drivers-BhdC9Efj.cjs.map +1 -0
- package/dist/drivers-wcDnzf7l.mjs +213 -0
- package/dist/drivers-wcDnzf7l.mjs.map +1 -0
- package/dist/eas-DC3F8cy0.mjs +334 -0
- package/dist/eas-DC3F8cy0.mjs.map +1 -0
- package/dist/eas-DryGYjFk.cjs +337 -0
- package/dist/eas-DryGYjFk.cjs.map +1 -0
- package/dist/emit-C4KSXOeS.mjs +153 -0
- package/dist/emit-C4KSXOeS.mjs.map +1 -0
- package/dist/emit-DiW0kbue.cjs +164 -0
- package/dist/emit-DiW0kbue.cjs.map +1 -0
- package/dist/encryption-8qZGm15p.cjs +90 -0
- package/dist/encryption-8qZGm15p.cjs.map +1 -0
- package/dist/encryption-C8Y8Ly6n.mjs +89 -0
- package/dist/encryption-C8Y8Ly6n.mjs.map +1 -0
- package/dist/engine-C9E0MeLm.mjs +3216 -0
- package/dist/engine-C9E0MeLm.mjs.map +1 -0
- package/dist/engine-DI7JAyiD.cjs +3329 -0
- package/dist/engine-DI7JAyiD.cjs.map +1 -0
- package/dist/errors-D8Gwp5kU.mjs +23 -0
- package/dist/errors-D8Gwp5kU.mjs.map +1 -0
- package/dist/errors-DMC4Umsb.cjs +34 -0
- package/dist/errors-DMC4Umsb.cjs.map +1 -0
- package/dist/github-DdaV-Gll.mjs +977 -0
- package/dist/github-DdaV-Gll.mjs.map +1 -0
- package/dist/github-g3nRZlli.cjs +978 -0
- package/dist/github-g3nRZlli.cjs.map +1 -0
- package/dist/googlePlay-BHJ_iThq.cjs +931 -0
- package/dist/googlePlay-BHJ_iThq.cjs.map +1 -0
- package/dist/googlePlay-BmeR1kY4.mjs +931 -0
- package/dist/googlePlay-BmeR1kY4.mjs.map +1 -0
- package/dist/iam-BoYPPNdM.cjs +521 -0
- package/dist/iam-BoYPPNdM.cjs.map +1 -0
- package/dist/iam-ra1_Y405.mjs +442 -0
- package/dist/iam-ra1_Y405.mjs.map +1 -0
- package/dist/{index-RCUizGxL.d.cts → index-1H93w_H6.d.cts} +38 -14
- package/dist/index-1H93w_H6.d.cts.map +1 -0
- package/dist/{index-B4H4XF7A.d.mts → index-DFZ0SMwN.d.mts} +38 -14
- package/dist/index-DFZ0SMwN.d.mts.map +1 -0
- package/dist/index.cjs +15142 -13470
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +14959 -13285
- package/dist/index.mjs.map +1 -1
- package/dist/local-Bkv-e8uM.mjs +224 -0
- package/dist/local-Bkv-e8uM.mjs.map +1 -0
- package/dist/local-DTidpa-a.cjs +241 -0
- package/dist/local-DTidpa-a.cjs.map +1 -0
- package/dist/migrate-BZRsJwni.mjs +181 -0
- package/dist/migrate-BZRsJwni.mjs.map +1 -0
- package/dist/migrate-CXLhrHwu.cjs +272 -0
- package/dist/migrate-CXLhrHwu.cjs.map +1 -0
- package/dist/migrate-DNOI23QA.mjs +267 -0
- package/dist/migrate-DNOI23QA.mjs.map +1 -0
- package/dist/migrate-DU4MtKxz.cjs +181 -0
- package/dist/migrate-DU4MtKxz.cjs.map +1 -0
- package/dist/next.cjs +59 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +44 -0
- package/dist/next.d.cts.map +1 -0
- package/dist/next.d.mts +44 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +58 -0
- package/dist/next.mjs.map +1 -0
- package/dist/notes-1TM_Vzi7.mjs +408 -0
- package/dist/notes-1TM_Vzi7.mjs.map +1 -0
- package/dist/notes-BpaXOAkA.cjs +509 -0
- package/dist/notes-BpaXOAkA.cjs.map +1 -0
- package/dist/openapi.cjs +213 -7
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +32 -8
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +32 -8
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +208 -2
- package/dist/openapi.mjs.map +1 -0
- package/dist/projectBucket-BRgsSv2P.mjs +222 -0
- package/dist/projectBucket-BRgsSv2P.mjs.map +1 -0
- package/dist/projectBucket-DbEWuLGX.cjs +263 -0
- package/dist/projectBucket-DbEWuLGX.cjs.map +1 -0
- package/dist/provider-BqpjG9QM.cjs +57 -0
- package/dist/provider-BqpjG9QM.cjs.map +1 -0
- package/dist/provider-CEOKk8NS.mjs +46 -0
- package/dist/provider-CEOKk8NS.mjs.map +1 -0
- package/dist/publish-BN1l3tPF.cjs +124 -0
- package/dist/publish-BN1l3tPF.cjs.map +1 -0
- package/dist/publish-DjFgxu2v.mjs +123 -0
- package/dist/publish-DjFgxu2v.mjs.map +1 -0
- package/dist/ready-COJHr1Yi.mjs +375 -0
- package/dist/ready-COJHr1Yi.mjs.map +1 -0
- package/dist/ready-DcD0SCnV.cjs +404 -0
- package/dist/ready-DcD0SCnV.cjs.map +1 -0
- package/dist/reconcile/public.cjs +3 -5
- package/dist/reconcile/public.d.cts +33 -89
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +33 -89
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/reconcile--I7V4Klj.mjs +34 -0
- package/dist/reconcile--I7V4Klj.mjs.map +1 -0
- package/dist/reconcile-CuCQBa5-.cjs +34 -0
- package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
- package/dist/resolve-BHVyg4Hg.cjs +316 -0
- package/dist/resolve-BHVyg4Hg.cjs.map +1 -0
- package/dist/resolve-NEKsqNAw.mjs +263 -0
- package/dist/resolve-NEKsqNAw.mjs.map +1 -0
- package/dist/rollback-BVgyLE7B.mjs +136 -0
- package/dist/rollback-BVgyLE7B.mjs.map +1 -0
- package/dist/rollback-CUjvOIDE.cjs +165 -0
- package/dist/rollback-CUjvOIDE.cjs.map +1 -0
- package/dist/runtime-CKOkIrw0.d.cts +82 -0
- package/dist/runtime-CKOkIrw0.d.cts.map +1 -0
- package/dist/runtime-Cdvv8SfU.d.mts +82 -0
- package/dist/runtime-Cdvv8SfU.d.mts.map +1 -0
- package/dist/s3-BO4yr61G.mjs +240 -0
- package/dist/s3-BO4yr61G.mjs.map +1 -0
- package/dist/s3-DnPbDfQN.cjs +240 -0
- package/dist/s3-DnPbDfQN.cjs.map +1 -0
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/credentials-worker.cjs +53 -0
- package/dist/sandbox/credentials-worker.cjs.map +1 -0
- package/dist/sandbox/credentials-worker.d.cts +1 -0
- package/dist/sandbox/credentials-worker.d.mts +1 -0
- package/dist/sandbox/credentials-worker.mjs +54 -0
- package/dist/sandbox/credentials-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +47 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +48 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox/migrate-worker.cjs +75 -0
- package/dist/sandbox/migrate-worker.cjs.map +1 -0
- package/dist/sandbox/migrate-worker.d.cts +1 -0
- package/dist/sandbox/migrate-worker.d.mts +1 -0
- package/dist/sandbox/migrate-worker.mjs +76 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/{workspace-B8NLb54N.cjs → schemas-BCwKKA42.mjs} +399 -1173
- package/dist/schemas-BCwKKA42.mjs.map +1 -0
- package/dist/{workspace-DI-M3BnN.mjs → schemas-BQ_v0lEX.cjs} +487 -982
- package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
- package/dist/secretsManager-CJyxFcBH.mjs +113 -0
- package/dist/secretsManager-CJyxFcBH.mjs.map +1 -0
- package/dist/secretsManager-D8on44WI.cjs +124 -0
- package/dist/secretsManager-D8on44WI.cjs.map +1 -0
- package/dist/seeds-Bc3niNVb.cjs +382 -0
- package/dist/seeds-Bc3niNVb.cjs.map +1 -0
- package/dist/seeds-Ccn0Ru2T.mjs +299 -0
- package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
- package/dist/serverSetup-BxnCM11A.mjs +685 -0
- package/dist/serverSetup-BxnCM11A.mjs.map +1 -0
- package/dist/serverSetup-DScJ7tQs.cjs +685 -0
- package/dist/serverSetup-DScJ7tQs.cjs.map +1 -0
- package/dist/sniffer-9smKtb86.mjs +1824 -0
- package/dist/sniffer-9smKtb86.mjs.map +1 -0
- package/dist/sniffer-DHcxlSJF.cjs +1997 -0
- package/dist/sniffer-DHcxlSJF.cjs.map +1 -0
- package/dist/snsSubscriptions-B8TYeAM-.cjs +1184 -0
- package/dist/snsSubscriptions-B8TYeAM-.cjs.map +1 -0
- package/dist/snsSubscriptions-CygsiXhb.mjs +1053 -0
- package/dist/snsSubscriptions-CygsiXhb.mjs.map +1 -0
- package/dist/sst-Bgb3WWEl.mjs +478 -0
- package/dist/sst-Bgb3WWEl.mjs.map +1 -0
- package/dist/sst-DiHVSku5.cjs +501 -0
- package/dist/sst-DiHVSku5.cjs.map +1 -0
- package/dist/stack-A3evQgbk.cjs +2512 -0
- package/dist/stack-A3evQgbk.cjs.map +1 -0
- package/dist/stack-Cy2FwO3Z.mjs +2331 -0
- package/dist/stack-Cy2FwO3Z.mjs.map +1 -0
- package/dist/stage-Bm1x9Anp.cjs +313 -0
- package/dist/stage-Bm1x9Anp.cjs.map +1 -0
- package/dist/stage-Dgy08WVL.mjs +302 -0
- package/dist/stage-Dgy08WVL.mjs.map +1 -0
- package/dist/stages-BWg3NU3J.cjs +190 -0
- package/dist/stages-BWg3NU3J.cjs.map +1 -0
- package/dist/stages-COiipV8N.mjs +190 -0
- package/dist/stages-COiipV8N.mjs.map +1 -0
- package/dist/target/public.cjs +15 -0
- package/dist/target/public.d.cts +28 -0
- package/dist/target/public.d.cts.map +1 -0
- package/dist/target/public.d.mts +28 -0
- package/dist/target/public.d.mts.map +1 -0
- package/dist/target/public.mjs +4 -0
- package/dist/terminal-BDRxzEZD.cjs +85 -0
- package/dist/terminal-BDRxzEZD.cjs.map +1 -0
- package/dist/terminal-BRAIvH83.mjs +85 -0
- package/dist/terminal-BRAIvH83.mjs.map +1 -0
- package/dist/types-Bl_CwZC9.cjs +90 -0
- package/dist/types-Bl_CwZC9.cjs.map +1 -0
- package/dist/{types-7R81hu0i.d.mts → types-DEmuMHsS.d.cts} +2147 -428
- package/dist/types-DEmuMHsS.d.cts.map +1 -0
- package/dist/types-Y1NfWlyG.mjs +61 -0
- package/dist/types-Y1NfWlyG.mjs.map +1 -0
- package/dist/{types-N7c2O2m7.d.cts → types-g_S0_RAi.d.mts} +2145 -428
- package/dist/types-g_S0_RAi.d.mts.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +65 -0
- package/dist/vitest.cjs.map +1 -0
- package/dist/vitest.d.cts +29 -0
- package/dist/vitest.d.cts.map +1 -0
- package/dist/vitest.d.mts +29 -0
- package/dist/vitest.d.mts.map +1 -0
- package/dist/vitest.mjs +65 -0
- package/dist/vitest.mjs.map +1 -0
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- package/dist/workspace/index.cjs +6 -2
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/workspace-CEpojAus.cjs +3528 -0
- package/dist/workspace-CEpojAus.cjs.map +1 -0
- package/dist/workspace-_aoe8v6u.mjs +2990 -0
- package/dist/workspace-_aoe8v6u.mjs.map +1 -0
- package/package.json +75 -13
- package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
- package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
- package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
- package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
- package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
- package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
- package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
- package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
- package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
- package/dist/bundler-mjqGAvu1.cjs.map +0 -1
- package/dist/bundler-mwH7WOb1.mjs.map +0 -1
- package/dist/config-CdTMeMU_.cjs +0 -467
- package/dist/config-CdTMeMU_.cjs.map +0 -1
- package/dist/config-DPnPkWyH.mjs +0 -414
- package/dist/config-DPnPkWyH.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/credentials-fJP5-fa1.mjs +0 -2780
- package/dist/credentials-fJP5-fa1.mjs.map +0 -1
- package/dist/credentials-tvyReUAd.cjs +0 -2917
- package/dist/credentials-tvyReUAd.cjs.map +0 -1
- package/dist/discover-BERGFg8v.cjs +0 -288
- package/dist/discover-BERGFg8v.cjs.map +0 -1
- package/dist/discover-CK-n3w6b.mjs +0 -244
- package/dist/discover-CK-n3w6b.mjs.map +0 -1
- package/dist/emit-BdoPFjZf.cjs +0 -253
- package/dist/emit-BdoPFjZf.cjs.map +0 -1
- package/dist/emit-Bzq7JsMP.mjs +0 -224
- package/dist/emit-Bzq7JsMP.mjs.map +0 -1
- package/dist/generator-LfZU7NlU.mjs +0 -247
- package/dist/generator-LfZU7NlU.mjs.map +0 -1
- package/dist/generator-Wdfp0jCS.cjs +0 -282
- package/dist/generator-Wdfp0jCS.cjs.map +0 -1
- package/dist/github-CAfKyYPN.mjs +0 -216
- package/dist/github-CAfKyYPN.mjs.map +0 -1
- package/dist/github-DVE8Gg_F.cjs +0 -216
- package/dist/github-DVE8Gg_F.cjs.map +0 -1
- package/dist/index-B4H4XF7A.d.mts.map +0 -1
- package/dist/index-RCUizGxL.d.cts.map +0 -1
- package/dist/openapi-BeckoaP9.cjs +0 -2038
- package/dist/openapi-BeckoaP9.cjs.map +0 -1
- package/dist/openapi-DolhBm6r.mjs +0 -1991
- package/dist/openapi-DolhBm6r.mjs.map +0 -1
- package/dist/reconcile-Cq4cO83R.cjs +0 -136
- package/dist/reconcile-Cq4cO83R.cjs.map +0 -1
- package/dist/reconcile-fmoluZmZ.mjs +0 -113
- package/dist/reconcile-fmoluZmZ.mjs.map +0 -1
- package/dist/ssm-BKN1Cg4z.mjs +0 -60
- package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
- package/dist/ssm-FxeSAt35.cjs +0 -60
- package/dist/ssm-FxeSAt35.cjs.map +0 -1
- package/dist/storage-DgypfSD6.cjs +0 -351
- package/dist/storage-DgypfSD6.cjs.map +0 -1
- package/dist/storage-TP0x118M.mjs +0 -304
- package/dist/storage-TP0x118M.mjs.map +0 -1
- package/dist/transfer-4A4S2hcw.mjs +0 -122
- package/dist/transfer-4A4S2hcw.mjs.map +0 -1
- package/dist/transfer-DdmtKLzi.cjs +0 -151
- package/dist/transfer-DdmtKLzi.cjs.map +0 -1
- package/dist/types-7R81hu0i.d.mts.map +0 -1
- package/dist/types-N7c2O2m7.d.cts.map +0 -1
- package/dist/workspace-B8NLb54N.cjs.map +0 -1
- package/dist/workspace-DI-M3BnN.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeds-Bc3niNVb.cjs","names":["userInfo","hostname"],"sources":["../src/deploy/dnsResources.ts","../src/deploy/journal.ts","../src/deploy/actor.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n\t/**\n\t * `provider`: a resource provider asked for it — a DKIM, MX, validation\n\t * or CDN record — rather than the stack's hosts. Pruned when no provider\n\t * asks for it on a deploy, not when the stack stops serving it.\n\t */\n\tsource?: 'provider';\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t\t...(record.source ? { source: record.source } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;;AAaA,MAAa,sBAAsB;;AA4BnC,SAAgB,cAAc,QAAgB,MAAsB;CACnE,OAAO,SAAS,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG;AAC1D;;AAGA,SAAgB,eAAe,MAAc,MAAsB;CAClE,OAAO,GAAG,oBAAoB,GAAG,KAAK,YAAY,EAAE,GAAG,KAAK,YAAY;AACzE;;AAGA,SAAgB,kBAAkB,QAA0C;CAC3E,MAAM,OAAO,cAAc,OAAO,QAAQ,OAAO,IAAI,CAAC,CAAC,YAAY;CACnE,MAAM,OAAO,OAAO,KAAK,YAAY;CACrC,MAAM,OAAwB;EAC7B,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,OAAO,OAAO;EACd,KAAK,OAAO;EACZ,GAAI,OAAO,WAAW,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EACvD,GAAI,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;CAClD;CACA,OAAO;EACN,KAAK,eAAe,MAAM,IAAI;EAC9B,MAAM;EACN,IAAI,GAAG,KAAK,GAAG;EACf,QAAQ;EACR;CACD;AACD;;AAGA,eAAsB,kBACrB,SACA,QACgB;CAChB,MAAM,EAAE,KAAK,MAAM,IAAI,SAAS,kBAAkB,MAAM;CACxD,MAAM,QAAQ,MA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AC7C,MAAM,WAAW,UAChB,SAAS,OAAO,UAAU,YAAY,aAAa,QAChD,OAAO,MAAM,OAAO,IACpB,KAAA;CAKJ,QAHC,SAAS,OAAO,UAAU,YAAY,WAAW,QAC9C,QAAQ,MAAM,KAAK,IACnB,KAAA,MACY,QAAQ,KAAK,KAAK,OAAO,KAAK;AAC/C;;;;;;AAqBA,SAAgB,mBACf,YACA,OACA,KACA,MACO;CACP,KAAK,MAAM,EAAE,WAAW,QAAQ,aAAa,YAAY;EACxD,IAAI,QAAQ,WAAW,GAAG;EAC1B,IAAI,QAAQ,OAAO,YAAY,QAAQ,QAAQ;EAC/C,KAAK,MAAM,QAAQ,SAAS,IAAI,QAAQ,MAAM;EAC9C,KAAK;GACJ,MAAM;GACN;GACA;GACA,SAAS,CAAC,GAAG,OAAO;EACrB,CAAC;CACF;CACA,KAAK,MAAM,EAAE,WAAW,QAAQ,YAAY,OAAO;EAClD,IAAI,OAAO,WAAW,GAAG;EACzB,IAAI,MAAM,OAAO,QAAQ,OAAO,QAAQ;EACxC,KAAK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { hostname, userInfo } from "node:os";
|
|
2
|
+
//#region src/deploy/dnsResources.ts
|
|
3
|
+
/** The resource type of a DNS record gkm wrote. */
|
|
4
|
+
const DNS_RECORD_RESOURCE = "dns-record";
|
|
5
|
+
/** A record's full name: `api.example.com`, or the domain for `@`. */
|
|
6
|
+
function dnsRecordFqdn(domain, name) {
|
|
7
|
+
return name === "@" || name === "" ? domain : `${name}.${domain}`;
|
|
8
|
+
}
|
|
9
|
+
/** `dns-record:<fqdn>:<type>` */
|
|
10
|
+
function dnsResourceKey(fqdn, type) {
|
|
11
|
+
return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
|
|
12
|
+
}
|
|
13
|
+
/** The resource record a written DNS record is kept as. */
|
|
14
|
+
function dnsRecordResource(record) {
|
|
15
|
+
const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
|
|
16
|
+
const type = record.type.toUpperCase();
|
|
17
|
+
const data = {
|
|
18
|
+
domain: record.domain,
|
|
19
|
+
name: record.name,
|
|
20
|
+
value: record.value,
|
|
21
|
+
ttl: record.ttl,
|
|
22
|
+
...record.provider ? { provider: record.provider } : {},
|
|
23
|
+
...record.source ? { source: record.source } : {}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
key: dnsResourceKey(fqdn, type),
|
|
27
|
+
type: DNS_RECORD_RESOURCE,
|
|
28
|
+
id: `${fqdn} ${type}`,
|
|
29
|
+
status: "ready",
|
|
30
|
+
data
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Records that gkm wrote `record` — or updates the value it holds. */
|
|
34
|
+
async function recordDnsResource(journal, record) {
|
|
35
|
+
const { key, type, id, data } = dnsRecordResource(record);
|
|
36
|
+
await journal.ready({
|
|
37
|
+
key,
|
|
38
|
+
type,
|
|
39
|
+
...data ? { data } : {}
|
|
40
|
+
}, id);
|
|
41
|
+
}
|
|
42
|
+
/** Forgets a DNS record gkm deleted. */
|
|
43
|
+
async function forgetDnsResource(journal, record) {
|
|
44
|
+
await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The changes a DNS step made, kept: what it created, updated or wrote is
|
|
48
|
+
* recorded, what it deleted is forgotten. A record it found already right is
|
|
49
|
+
* recorded only if gkm wrote it before; one it left to a person is not.
|
|
50
|
+
*/
|
|
51
|
+
async function recordDnsChanges(journal, changes, providerOf) {
|
|
52
|
+
for (const change of changes) {
|
|
53
|
+
if (change.action === "delete") {
|
|
54
|
+
await forgetDnsResource(journal, change);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const written = change.action === "create" || change.action === "update" || change.action === "write";
|
|
58
|
+
const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
|
|
59
|
+
if (!written && !known || change.value === void 0) continue;
|
|
60
|
+
const provider = providerOf(change.domain);
|
|
61
|
+
await recordDnsResource(journal, {
|
|
62
|
+
domain: change.domain,
|
|
63
|
+
name: change.name,
|
|
64
|
+
type: change.type,
|
|
65
|
+
value: change.value,
|
|
66
|
+
ttl: change.ttl ?? 0,
|
|
67
|
+
...provider ? { provider } : {}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Every DNS record gkm wrote for the stage, from its resource records. */
|
|
72
|
+
function dnsResources(resources) {
|
|
73
|
+
return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
|
|
74
|
+
const data = record.data ?? {};
|
|
75
|
+
const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
|
|
76
|
+
return {
|
|
77
|
+
...data,
|
|
78
|
+
type,
|
|
79
|
+
fqdn
|
|
80
|
+
};
|
|
81
|
+
}).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/deploy/journal.ts
|
|
85
|
+
var DeployJournal = class DeployJournal {
|
|
86
|
+
store;
|
|
87
|
+
stage;
|
|
88
|
+
state;
|
|
89
|
+
resources;
|
|
90
|
+
version;
|
|
91
|
+
existed;
|
|
92
|
+
constructor(store, stage, state, resources, version, existed) {
|
|
93
|
+
this.store = store;
|
|
94
|
+
this.stage = stage;
|
|
95
|
+
this.state = state;
|
|
96
|
+
this.resources = resources;
|
|
97
|
+
this.version = version;
|
|
98
|
+
this.existed = existed;
|
|
99
|
+
}
|
|
100
|
+
static async open(store, stage, initial, adopt = (stored) => stored) {
|
|
101
|
+
const stored = await store.read(stage);
|
|
102
|
+
if (stored) return new DeployJournal(store, stage, adopt(stored.state), stored.resources, stored.version, true);
|
|
103
|
+
const state = initial();
|
|
104
|
+
const version = await store.write(stage, state, { expectedVersion: null });
|
|
105
|
+
return new DeployJournal(store, stage, state, {}, version, false);
|
|
106
|
+
}
|
|
107
|
+
record(key) {
|
|
108
|
+
return this.resources[key];
|
|
109
|
+
}
|
|
110
|
+
/** The keys a previous run marked `pending` and never saw created. */
|
|
111
|
+
unfinished() {
|
|
112
|
+
return Object.values(this.resources).filter((record) => record.status === "pending").map((record) => record.key);
|
|
113
|
+
}
|
|
114
|
+
/** Records that `entry` is about to be created. */
|
|
115
|
+
async pending(entry) {
|
|
116
|
+
await this.put({
|
|
117
|
+
...entry,
|
|
118
|
+
status: "pending"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Records `entry` as existing with `id`; a no-op if it already is, with
|
|
123
|
+
* the same data.
|
|
124
|
+
*/
|
|
125
|
+
async ready(entry, id) {
|
|
126
|
+
const current = this.resources[entry.key];
|
|
127
|
+
if (current?.status === "ready" && current.id === id && JSON.stringify(current.data) === JSON.stringify(entry.data)) return;
|
|
128
|
+
await this.put({
|
|
129
|
+
...entry,
|
|
130
|
+
status: "ready",
|
|
131
|
+
id
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The resource `entry` names: by its recorded id, else by looking it up,
|
|
136
|
+
* else created — with `pending` written before the create and `ready`
|
|
137
|
+
* after, so a run that dies in between leaves a record the next run
|
|
138
|
+
* resolves by looking the resource up rather than creating another.
|
|
139
|
+
*/
|
|
140
|
+
async ensure(entry, steps) {
|
|
141
|
+
const record = this.resources[entry.key];
|
|
142
|
+
let staleId;
|
|
143
|
+
if (record?.status === "ready" && record.id && steps.get) {
|
|
144
|
+
const known = await steps.get(record.id);
|
|
145
|
+
if (known) {
|
|
146
|
+
await this.ready(entry, steps.id(known));
|
|
147
|
+
return {
|
|
148
|
+
resource: known,
|
|
149
|
+
via: "recorded"
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
staleId = record.id;
|
|
153
|
+
}
|
|
154
|
+
const existing = await steps.find();
|
|
155
|
+
if (existing) {
|
|
156
|
+
await this.ready(entry, steps.id(existing));
|
|
157
|
+
return {
|
|
158
|
+
resource: existing,
|
|
159
|
+
via: record?.status === "pending" ? "resumed" : "found",
|
|
160
|
+
...staleId ? { staleId } : {}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
await this.pending(entry);
|
|
164
|
+
const created = await steps.create();
|
|
165
|
+
await this.ready(entry, steps.id(created));
|
|
166
|
+
return {
|
|
167
|
+
resource: created,
|
|
168
|
+
via: "created",
|
|
169
|
+
...staleId ? { staleId } : {}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Removes `key`'s record — a resource that no longer exists. */
|
|
173
|
+
async forget(key) {
|
|
174
|
+
if (!(key in this.resources)) return;
|
|
175
|
+
this.version = await this.store.deleteResource(this.stage, key, { expectedVersion: this.version });
|
|
176
|
+
const { [key]: _removed, ...resources } = this.resources;
|
|
177
|
+
this.resources = resources;
|
|
178
|
+
}
|
|
179
|
+
/** Every record, as the journal last wrote or read it. */
|
|
180
|
+
records() {
|
|
181
|
+
return this.resources;
|
|
182
|
+
}
|
|
183
|
+
/** Writes the stage's state, keeping its resource records. */
|
|
184
|
+
async save() {
|
|
185
|
+
this.state.lastDeployedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
186
|
+
this.version = await this.store.write(this.stage, this.state, { expectedVersion: this.version });
|
|
187
|
+
}
|
|
188
|
+
async put(record) {
|
|
189
|
+
this.version = await this.store.putResource(this.stage, record, { expectedVersion: this.version });
|
|
190
|
+
this.resources = {
|
|
191
|
+
...this.resources,
|
|
192
|
+
[record.key]: {
|
|
193
|
+
...record,
|
|
194
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/deploy/actor.ts
|
|
201
|
+
/**
|
|
202
|
+
* Who wrote a stage's deploy state: a GitHub Actions run, or a person at a
|
|
203
|
+
* machine. Recorded on every state write (`updatedBy`), on every resource
|
|
204
|
+
* record and on every release (`releasedBy`), so "who put this here" has an
|
|
205
|
+
* answer that does not depend on anyone's memory.
|
|
206
|
+
*/
|
|
207
|
+
/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */
|
|
208
|
+
function isCi(env = process.env) {
|
|
209
|
+
return env.GITHUB_ACTIONS === "true" || env.CI === "true";
|
|
210
|
+
}
|
|
211
|
+
/** Who this process is writing as. */
|
|
212
|
+
function currentActor(env = process.env) {
|
|
213
|
+
if (env.GITHUB_ACTIONS === "true") {
|
|
214
|
+
const server = env.GITHUB_SERVER_URL ?? "https://github.com";
|
|
215
|
+
return {
|
|
216
|
+
kind: "github",
|
|
217
|
+
actor: env.GITHUB_ACTOR ?? "unknown",
|
|
218
|
+
run: `${server}/${env.GITHUB_REPOSITORY ?? "unknown"}/actions/runs/${env.GITHUB_RUN_ID ?? "unknown"}`,
|
|
219
|
+
...env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
let user = "unknown";
|
|
223
|
+
try {
|
|
224
|
+
user = userInfo().username;
|
|
225
|
+
} catch {}
|
|
226
|
+
return {
|
|
227
|
+
kind: "local",
|
|
228
|
+
user,
|
|
229
|
+
host: hostname()
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */
|
|
233
|
+
function describeActor(actor) {
|
|
234
|
+
if (!actor) return "unknown";
|
|
235
|
+
if (actor.kind === "local") return `${actor.user}@${actor.host}`;
|
|
236
|
+
return `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ""}${actor.run})`;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/target/seeds.ts
|
|
240
|
+
/** A seed of a deployed stage failed; the release stopped before any app. */
|
|
241
|
+
var DeploySeedsFailed = class extends Error {
|
|
242
|
+
stage;
|
|
243
|
+
construct;
|
|
244
|
+
seed;
|
|
245
|
+
cause;
|
|
246
|
+
constructor(stage, construct, seed, cause) {
|
|
247
|
+
super(`Seeding "${stage}" failed, so no app was released: ${construct}'s seed '${seed}' failed — ${causeMessage(cause)}. Its writes were rolled back; the migrations and the seeds before it stay applied. Seeds run on every deploy, so each must be an idempotent upsert: fix it and deploy again.`);
|
|
248
|
+
this.stage = stage;
|
|
249
|
+
this.construct = construct;
|
|
250
|
+
this.seed = seed;
|
|
251
|
+
this.cause = cause;
|
|
252
|
+
this.name = "DeploySeedsFailed";
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* What went wrong underneath: a `SeedFailed`'s own cause (the database's
|
|
257
|
+
* error), or — from a sandbox, where errors arrive as data — the same.
|
|
258
|
+
*/
|
|
259
|
+
function causeMessage(cause) {
|
|
260
|
+
const message = (value) => value && typeof value === "object" && "message" in value ? String(value.message) : void 0;
|
|
261
|
+
return (cause && typeof cause === "object" && "cause" in cause ? message(cause.cause) : void 0) ?? message(cause) ?? String(cause);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Say what a deploy's migrations and seeds did: a line per construct with
|
|
265
|
+
* something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —
|
|
266
|
+
* and a `migration.applied` or `seed.ran` event beside it.
|
|
267
|
+
*/
|
|
268
|
+
function reportDatabaseRuns(migrations, seeds, log, emit) {
|
|
269
|
+
for (const { construct, folder, applied } of migrations) {
|
|
270
|
+
if (applied.length === 0) continue;
|
|
271
|
+
log(`🗄️ ${folder}: applied ${applied.length}`);
|
|
272
|
+
for (const name of applied) log(` ✓ ${name}`);
|
|
273
|
+
emit({
|
|
274
|
+
type: "migration.applied",
|
|
275
|
+
construct,
|
|
276
|
+
folder,
|
|
277
|
+
applied: [...applied]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
for (const { construct, folder, seeded } of seeds) {
|
|
281
|
+
if (seeded.length === 0) continue;
|
|
282
|
+
log(`🌱 ${folder}: ran ${seeded.length}`);
|
|
283
|
+
for (const name of seeded) log(` ✓ ${name}`);
|
|
284
|
+
emit({
|
|
285
|
+
type: "seed.ran",
|
|
286
|
+
construct,
|
|
287
|
+
folder,
|
|
288
|
+
seeded: [...seeded]
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/** What a dry run lists: the seeds a deploy would run, construct by construct. */
|
|
293
|
+
function reportPlannedSeeds(planned, log) {
|
|
294
|
+
for (const { folder, seeds } of planned) log(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(", ")})`);
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
export { describeActor as a, dnsRecordFqdn as c, dnsResources as d, forgetDnsResource as f, currentActor as i, dnsRecordResource as l, recordDnsResource as m, reportDatabaseRuns as n, isCi as o, recordDnsChanges as p, reportPlannedSeeds as r, DeployJournal as s, DeploySeedsFailed as t, dnsResourceKey as u };
|
|
298
|
+
|
|
299
|
+
//# sourceMappingURL=seeds-Ccn0Ru2T.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeds-Ccn0Ru2T.mjs","names":[],"sources":["../src/deploy/dnsResources.ts","../src/deploy/journal.ts","../src/deploy/actor.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n\t/**\n\t * `provider`: a resource provider asked for it — a DKIM, MX, validation\n\t * or CDN record — rather than the stack's hosts. Pruned when no provider\n\t * asks for it on a deploy, not when the stack stops serving it.\n\t */\n\tsource?: 'provider';\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t\t...(record.source ? { source: record.source } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;;AAaA,MAAa,sBAAsB;;AA4BnC,SAAgB,cAAc,QAAgB,MAAsB;CACnE,OAAO,SAAS,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG;AAC1D;;AAGA,SAAgB,eAAe,MAAc,MAAsB;CAClE,OAAO,GAAG,oBAAoB,GAAG,KAAK,YAAY,EAAE,GAAG,KAAK,YAAY;AACzE;;AAGA,SAAgB,kBAAkB,QAA0C;CAC3E,MAAM,OAAO,cAAc,OAAO,QAAQ,OAAO,IAAI,CAAC,CAAC,YAAY;CACnE,MAAM,OAAO,OAAO,KAAK,YAAY;CACrC,MAAM,OAAwB;EAC7B,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,OAAO,OAAO;EACd,KAAK,OAAO;EACZ,GAAI,OAAO,WAAW,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EACvD,GAAI,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;CAClD;CACA,OAAO;EACN,KAAK,eAAe,MAAM,IAAI;EAC9B,MAAM;EACN,IAAI,GAAG,KAAK,GAAG;EACf,QAAQ;EACR;CACD;AACD;;AAGA,eAAsB,kBACrB,SACA,QACgB;CAChB,MAAM,EAAE,KAAK,MAAM,IAAI,SAAS,kBAAkB,MAAM;CACxD,MAAM,QAA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