@geekmidas/cli 10.0.0-alpha.122 → 10.0.0-alpha.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{EndpointGenerator-BDa6pPgE.cjs → EndpointGenerator-B2MUa4M2.cjs} +2 -2
- package/dist/{EndpointGenerator-BDa6pPgE.cjs.map → EndpointGenerator-B2MUa4M2.cjs.map} +1 -1
- package/dist/{EndpointGenerator-CP_z_E3e.mjs → EndpointGenerator-Z_BUTocT.mjs} +2 -2
- package/dist/{EndpointGenerator-CP_z_E3e.mjs.map → EndpointGenerator-Z_BUTocT.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-BJ9j9mR7.cjs → GoDaddyProvider-0z5RAN1k.cjs} +3 -3
- package/dist/{GoDaddyProvider-BJ9j9mR7.cjs.map → GoDaddyProvider-0z5RAN1k.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-wIKYdm7V.mjs → GoDaddyProvider-55x4o-4z.mjs} +3 -3
- package/dist/{GoDaddyProvider-wIKYdm7V.mjs.map → GoDaddyProvider-55x4o-4z.mjs.map} +1 -1
- package/dist/{HostingerProvider-BNpS9aRJ.mjs → HostingerProvider-Cjh_2Ml6.mjs} +2 -2
- package/dist/{HostingerProvider-BNpS9aRJ.mjs.map → HostingerProvider-Cjh_2Ml6.mjs.map} +1 -1
- package/dist/{HostingerProvider-DR1iws1P.cjs → HostingerProvider-OdQmKXE3.cjs} +2 -2
- package/dist/{HostingerProvider-DR1iws1P.cjs.map → HostingerProvider-OdQmKXE3.cjs.map} +1 -1
- package/dist/{LegacyStateStore-CkXUJP7i.mjs → LegacyStateStore-C-vumKSN.mjs} +3 -3
- package/dist/{LegacyStateStore-CkXUJP7i.mjs.map → LegacyStateStore-C-vumKSN.mjs.map} +1 -1
- package/dist/{LegacyStateStore-D1S87I_B.cjs → LegacyStateStore-DRpB-yC5.cjs} +3 -3
- package/dist/{LegacyStateStore-D1S87I_B.cjs.map → LegacyStateStore-DRpB-yC5.cjs.map} +1 -1
- package/dist/{LocalStateStore-DmXfpvu4.cjs → LocalStateStore-C3ummuDT.cjs} +2 -2
- package/dist/{LocalStateStore-DmXfpvu4.cjs.map → LocalStateStore-C3ummuDT.cjs.map} +1 -1
- package/dist/{LocalStateStore-BWoWeSq0.mjs → LocalStateStore-CtOjpV1w.mjs} +2 -2
- package/dist/{LocalStateStore-BWoWeSq0.mjs.map → LocalStateStore-CtOjpV1w.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-CsrukCE-.mjs → OpenApiTsGenerator-MtnMQL_g.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-CsrukCE-.mjs.map → OpenApiTsGenerator-MtnMQL_g.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-FNhY7Ssz.cjs → OpenApiTsGenerator-t3_E98Fi.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-FNhY7Ssz.cjs.map → OpenApiTsGenerator-t3_E98Fi.cjs.map} +1 -1
- package/dist/{S3StateStore-D19JSGE9.mjs → S3StateStore-BC4Jm3Tw.mjs} +2 -2
- package/dist/{S3StateStore-D19JSGE9.mjs.map → S3StateStore-BC4Jm3Tw.mjs.map} +1 -1
- package/dist/{S3StateStore-BEdsjjP4.cjs → S3StateStore-BeArp0aF.cjs} +2 -2
- package/dist/{S3StateStore-BEdsjjP4.cjs.map → S3StateStore-BeArp0aF.cjs.map} +1 -1
- package/dist/{SSMStateStore-7xKw0Zz9.mjs → SSMStateStore-Crl76aYZ.mjs} +2 -2
- package/dist/{SSMStateStore-7xKw0Zz9.mjs.map → SSMStateStore-Crl76aYZ.mjs.map} +1 -1
- package/dist/{SSMStateStore--2bcxoiH.cjs → SSMStateStore-DcstR6cW.cjs} +2 -2
- package/dist/{SSMStateStore--2bcxoiH.cjs.map → SSMStateStore-DcstR6cW.cjs.map} +1 -1
- package/dist/{SubscriberGenerator-C8CPxrCK.cjs → SubscriberGenerator-C3QTae-R.cjs} +237 -54
- package/dist/SubscriberGenerator-C3QTae-R.cjs.map +1 -0
- package/dist/{SubscriberGenerator-y3pncae_.mjs → SubscriberGenerator-COAVPgM-.mjs} +227 -56
- package/dist/SubscriberGenerator-COAVPgM-.mjs.map +1 -0
- package/dist/{add-DlFUKdjX.cjs → add-BFjb6mMq.cjs} +7 -7
- package/dist/{add-DlFUKdjX.cjs.map → add-BFjb6mMq.cjs.map} +1 -1
- package/dist/{add-Bu6FkaTn.mjs → add-CIjmgzkb.mjs} +6 -6
- package/dist/{add-Bu6FkaTn.mjs.map → add-CIjmgzkb.mjs.map} +1 -1
- package/dist/{bundler-Bg0lPDoi.cjs → bundler-CiUoIsku.cjs} +5 -5
- package/dist/{bundler-Bg0lPDoi.cjs.map → bundler-CiUoIsku.cjs.map} +1 -1
- package/dist/{bundler-CgE5XTyr.mjs → bundler-D6KFNpQk.mjs} +5 -5
- package/dist/{bundler-CgE5XTyr.mjs.map → bundler-D6KFNpQk.mjs.map} +1 -1
- package/dist/{cli-z5S3bHyK.mjs → cli-DNtSTtMc.mjs} +4 -4
- package/dist/{cli-z5S3bHyK.mjs.map → cli-DNtSTtMc.mjs.map} +1 -1
- package/dist/{cli-Cvjlnpon.cjs → cli-r4eUr98C.cjs} +4 -4
- package/dist/{cli-Cvjlnpon.cjs.map → cli-r4eUr98C.cjs.map} +1 -1
- package/dist/{compose-bKLAtHLj.cjs → compose-BfXXWJSp.cjs} +362 -59
- package/dist/compose-BfXXWJSp.cjs.map +1 -0
- package/dist/{compose-CgBPA44v.mjs → compose-DJvvmF3X.mjs} +336 -33
- package/dist/compose-DJvvmF3X.mjs.map +1 -0
- package/dist/{config-D48erO2j.d.mts → config-IgK6YaGp.d.cts} +3 -4
- package/dist/config-IgK6YaGp.d.cts.map +1 -0
- package/dist/{config-DHDtsQrB.d.cts → config-kE-p5hxq.d.mts} +3 -4
- package/dist/config-kE-p5hxq.d.mts.map +1 -0
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +2 -2
- package/dist/{credentialSchemas-B67WJOOm.cjs → credentialSchemas-AhIBuQxQ.cjs} +2 -2
- package/dist/{credentialSchemas-B67WJOOm.cjs.map → credentialSchemas-AhIBuQxQ.cjs.map} +1 -1
- package/dist/{credentialSchemas-DDOLRCLF.mjs → credentialSchemas-DLKbxYBy.mjs} +2 -2
- package/dist/{credentialSchemas-DDOLRCLF.mjs.map → credentialSchemas-DLKbxYBy.mjs.map} +1 -1
- package/dist/{credentials-Zqr3QQYB.cjs → credentials-D7XJypNd.cjs} +173 -3
- package/dist/credentials-D7XJypNd.cjs.map +1 -0
- package/dist/{credentials-B5N5yKk6.mjs → credentials-DpfnUvIR.mjs} +132 -4
- package/dist/credentials-DpfnUvIR.mjs.map +1 -0
- package/dist/deploy/public.cjs +16 -17
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts +3 -5
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +3 -5
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +11 -12
- package/dist/deploy/public.mjs.map +1 -1
- package/dist/{deploy-CI85F6dr.cjs → deploy-BbI1UMh3.cjs} +477 -156
- package/dist/deploy-BbI1UMh3.cjs.map +1 -0
- package/dist/{deploy-Ddy8UBoE.mjs → deploy-CiRYwFmr.mjs} +456 -117
- package/dist/deploy-CiRYwFmr.mjs.map +1 -0
- package/dist/{discover-C5roJuc9.mjs → discover-BvJOVsYG.mjs} +66 -14
- package/dist/discover-BvJOVsYG.mjs.map +1 -0
- package/dist/{discover-DozUKs8f.cjs → discover-ojkcbxHw.cjs} +88 -12
- package/dist/discover-ojkcbxHw.cjs.map +1 -0
- package/dist/{dokploy-CiozgdKO.cjs → dokploy-C0aQrCgs.cjs} +2 -2
- package/dist/{dokploy-CiozgdKO.cjs.map → dokploy-C0aQrCgs.cjs.map} +1 -1
- package/dist/{dokploy-Boj1NSHV.mjs → dokploy-MM7c3IE0.mjs} +2 -2
- package/dist/{dokploy-Boj1NSHV.mjs.map → dokploy-MM7c3IE0.mjs.map} +1 -1
- package/dist/{drivers-DbjiYpW6.cjs → drivers-CQ32PB5w.cjs} +2 -2
- package/dist/{drivers-DbjiYpW6.cjs.map → drivers-CQ32PB5w.cjs.map} +1 -1
- package/dist/{drivers-BjGDYfnC.mjs → drivers-Chb5Akov.mjs} +2 -2
- package/dist/{drivers-BjGDYfnC.mjs.map → drivers-Chb5Akov.mjs.map} +1 -1
- package/dist/{eas-DCg41jKK.mjs → eas-1Ee6kql0.mjs} +2 -2
- package/dist/{eas-DCg41jKK.mjs.map → eas-1Ee6kql0.mjs.map} +1 -1
- package/dist/{eas-BmBjIFf_.cjs → eas-CJoys9yh.cjs} +2 -2
- package/dist/{eas-BmBjIFf_.cjs.map → eas-CJoys9yh.cjs.map} +1 -1
- package/dist/{emit-C1e8qD08.mjs → emit-CNpuV_6Q.mjs} +17 -1
- package/dist/emit-CNpuV_6Q.mjs.map +1 -0
- package/dist/{emit-Dmc1nvdS.cjs → emit-qvHxMV9b.cjs} +17 -1
- package/dist/emit-qvHxMV9b.cjs.map +1 -0
- package/dist/{encryption-QOQbGXgV.mjs → encryption-B8Bk1Mvu.mjs} +3 -3
- package/dist/{encryption-QOQbGXgV.mjs.map → encryption-B8Bk1Mvu.mjs.map} +1 -1
- package/dist/{encryption-CwLWV2ig.cjs → encryption-Bo9VlRnl.cjs} +3 -3
- package/dist/{encryption-CwLWV2ig.cjs.map → encryption-Bo9VlRnl.cjs.map} +1 -1
- package/dist/{engine-HVqo3mQu.mjs → engine-BuinpJfS.mjs} +7 -8
- package/dist/{engine-HVqo3mQu.mjs.map → engine-BuinpJfS.mjs.map} +1 -1
- package/dist/{engine-D7YNY3v7.cjs → engine-esxTxcIx.cjs} +10 -11
- package/dist/{engine-D7YNY3v7.cjs.map → engine-esxTxcIx.cjs.map} +1 -1
- package/dist/{github-CO8W9SDs.cjs → github-BEA4K3_X.cjs} +80 -47
- package/dist/github-BEA4K3_X.cjs.map +1 -0
- package/dist/{github-CQt3xc3o.mjs → github-BUlKJfOV.mjs} +78 -45
- package/dist/github-BUlKJfOV.mjs.map +1 -0
- package/dist/{googlePlay-Cfu17aEp.mjs → googlePlay-CK05QiTq.mjs} +4 -4
- package/dist/{googlePlay-Cfu17aEp.mjs.map → googlePlay-CK05QiTq.mjs.map} +1 -1
- package/dist/{googlePlay-DSuF6jbF.cjs → googlePlay-CiqAS2ma.cjs} +5 -5
- package/dist/{googlePlay-DSuF6jbF.cjs.map → googlePlay-CiqAS2ma.cjs.map} +1 -1
- package/dist/{index-8OfpOtSI.d.cts → index-4CO0HD27.d.cts} +2 -2
- package/dist/{index-8OfpOtSI.d.cts.map → index-4CO0HD27.d.cts.map} +1 -1
- package/dist/{index-Dpji6Bxq.d.mts → index-DhUf0B0m.d.mts} +2 -2
- package/dist/{index-Dpji6Bxq.d.mts.map → index-DhUf0B0m.d.mts.map} +1 -1
- package/dist/index.cjs +81 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +64 -65
- package/dist/index.mjs.map +1 -1
- package/dist/{local-BwC2v2Y8.mjs → local-B7Zv1NoA.mjs} +2 -2
- package/dist/{local-BwC2v2Y8.mjs.map → local-B7Zv1NoA.mjs.map} +1 -1
- package/dist/{local-DNhnkugT.cjs → local-OPC9BCZt.cjs} +3 -3
- package/dist/{local-DNhnkugT.cjs.map → local-OPC9BCZt.cjs.map} +1 -1
- package/dist/{migrate-CGkir5LM.mjs → migrate-BzCHT9qs.mjs} +3 -3
- package/dist/{migrate-CGkir5LM.mjs.map → migrate-BzCHT9qs.mjs.map} +1 -1
- package/dist/{migrate-CXsMaHbb.cjs → migrate-C-hmbjpG.cjs} +3 -3
- package/dist/{migrate-CXsMaHbb.cjs.map → migrate-C-hmbjpG.cjs.map} +1 -1
- package/dist/{migrate-Bkz8BGaZ.mjs → migrate-CnbvrVag.mjs} +4 -4
- package/dist/{migrate-Bkz8BGaZ.mjs.map → migrate-CnbvrVag.mjs.map} +1 -1
- package/dist/{migrate-dbAI2XF8.cjs → migrate-DeQJBexh.cjs} +4 -4
- package/dist/{migrate-dbAI2XF8.cjs.map → migrate-DeQJBexh.cjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/{publish-eUcWvSdP.mjs → publish-BISBrrqR.mjs} +2 -2
- package/dist/{publish-eUcWvSdP.mjs.map → publish-BISBrrqR.mjs.map} +1 -1
- package/dist/{publish-Bbd-2PI2.cjs → publish-DtSIB-hZ.cjs} +2 -2
- package/dist/{publish-Bbd-2PI2.cjs.map → publish-DtSIB-hZ.cjs.map} +1 -1
- package/dist/{ready-BOfogqzr.mjs → ready-DqsyadOs.mjs} +6 -6
- package/dist/{ready-BOfogqzr.mjs.map → ready-DqsyadOs.mjs.map} +1 -1
- package/dist/{ready-BFFP838V.cjs → ready-IVGu-q18.cjs} +6 -6
- package/dist/{ready-BFFP838V.cjs.map → ready-IVGu-q18.cjs.map} +1 -1
- package/dist/reconcile/public.cjs +2 -2
- package/dist/reconcile/public.d.cts +1 -2
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +1 -2
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +2 -2
- package/dist/{resolve-DSilYpzm.mjs → resolve-BT7fkPN5.mjs} +4 -4
- package/dist/{resolve-DSilYpzm.mjs.map → resolve-BT7fkPN5.mjs.map} +1 -1
- package/dist/{resolve-CyprRcQo.cjs → resolve-C7GKQcE4.cjs} +4 -4
- package/dist/{resolve-CyprRcQo.cjs.map → resolve-C7GKQcE4.cjs.map} +1 -1
- package/dist/{rollback-DfwsnwGO.cjs → rollback-BEiB-Pje.cjs} +7 -7
- package/dist/{rollback-DfwsnwGO.cjs.map → rollback-BEiB-Pje.cjs.map} +1 -1
- package/dist/{rollback-C4ri3h7i.mjs → rollback-DbP0KuDw.mjs} +7 -7
- package/dist/{rollback-C4ri3h7i.mjs.map → rollback-DbP0KuDw.mjs.map} +1 -1
- package/dist/{runtime-ACdfK59n.d.cts → runtime-BFJQNqwd.d.mts} +2 -2
- package/dist/{runtime-ACdfK59n.d.cts.map → runtime-BFJQNqwd.d.mts.map} +1 -1
- package/dist/{runtime-YyQuekxi.d.mts → runtime-BJO-FFef.d.cts} +2 -2
- package/dist/{runtime-YyQuekxi.d.mts.map → runtime-BJO-FFef.d.cts.map} +1 -1
- package/dist/{s3-DQXZdmCM.mjs → s3-B4FTQQkV.mjs} +2 -2
- package/dist/{s3-DQXZdmCM.mjs.map → s3-B4FTQQkV.mjs.map} +1 -1
- package/dist/{s3-CrPoA89T.cjs → s3-DwKLXwUT.cjs} +2 -2
- package/dist/{s3-CrPoA89T.cjs.map → s3-DwKLXwUT.cjs.map} +1 -1
- package/dist/sandbox/credentials-worker.cjs +2 -2
- package/dist/sandbox/credentials-worker.mjs +2 -2
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox/migrate-worker.cjs +1 -1
- package/dist/sandbox/migrate-worker.mjs +1 -1
- package/dist/{seeds-CFG-f24B.cjs → seeds-DOfxmDRO.cjs} +362 -34
- package/dist/seeds-DOfxmDRO.cjs.map +1 -0
- package/dist/{seeds-oY0qDqui.mjs → seeds-rG-Evfz9.mjs} +341 -31
- package/dist/seeds-rG-Evfz9.mjs.map +1 -0
- package/dist/{serverSetup-CQZt0OT6.cjs → serverSetup-CWWVcU6Y.cjs} +6 -6
- package/dist/{serverSetup-CQZt0OT6.cjs.map → serverSetup-CWWVcU6Y.cjs.map} +1 -1
- package/dist/{serverSetup-D8nngcNL.mjs → serverSetup-xGw1fxuZ.mjs} +6 -6
- package/dist/{serverSetup-D8nngcNL.mjs.map → serverSetup-xGw1fxuZ.mjs.map} +1 -1
- package/dist/{sniffer-BAmtXzou.cjs → sniffer-C7O9Pna_.cjs} +9 -9
- package/dist/{sniffer-BAmtXzou.cjs.map → sniffer-C7O9Pna_.cjs.map} +1 -1
- package/dist/{sniffer-Cgx608Tl.mjs → sniffer-DVPgfyHr.mjs} +9 -9
- package/dist/{sniffer-Cgx608Tl.mjs.map → sniffer-DVPgfyHr.mjs.map} +1 -1
- package/dist/{dns-CfEZHt7r.cjs → snsSubscriptions-CSkteK2J.cjs} +520 -3
- package/dist/snsSubscriptions-CSkteK2J.cjs.map +1 -0
- package/dist/{dns-BgxvvcQa.mjs → snsSubscriptions-CvBIGGp0.mjs} +431 -6
- package/dist/snsSubscriptions-CvBIGGp0.mjs.map +1 -0
- package/dist/{sst-C1pxbFEd.mjs → sst-CTqZZl1_.mjs} +3 -4
- package/dist/{sst-C1pxbFEd.mjs.map → sst-CTqZZl1_.mjs.map} +1 -1
- package/dist/{sst-B-Uz4cvm.cjs → sst-lEkBwzGc.cjs} +4 -5
- package/dist/{sst-B-Uz4cvm.cjs.map → sst-lEkBwzGc.cjs.map} +1 -1
- package/dist/{stage-BKDdQm65.mjs → stage-2EKpzPQ1.mjs} +6 -6
- package/dist/{stage-BKDdQm65.mjs.map → stage-2EKpzPQ1.mjs.map} +1 -1
- package/dist/{stage-CJysBXWB.cjs → stage-fRfFtLwj.cjs} +7 -7
- package/dist/{stage-CJysBXWB.cjs.map → stage-fRfFtLwj.cjs.map} +1 -1
- package/dist/{stages-D4SnG5yl.cjs → stages-B7mCWI_R.cjs} +2 -2
- package/dist/{stages-D4SnG5yl.cjs.map → stages-B7mCWI_R.cjs.map} +1 -1
- package/dist/{stages-Cb9rqRbN.mjs → stages-DSltTW2d.mjs} +2 -2
- package/dist/{stages-Cb9rqRbN.mjs.map → stages-DSltTW2d.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-CW_dWeTe.mjs → terminal-BAVrDhhN.mjs} +3 -3
- package/dist/{terminal-CW_dWeTe.mjs.map → terminal-BAVrDhhN.mjs.map} +1 -1
- package/dist/{terminal-DJlqcW_U.cjs → terminal-D1aeTkgv.cjs} +3 -3
- package/dist/{terminal-DJlqcW_U.cjs.map → terminal-D1aeTkgv.cjs.map} +1 -1
- package/dist/{types-HqVPddRK.d.mts → types-CFU2uvrz.d.cts} +263 -4
- package/dist/types-CFU2uvrz.d.cts.map +1 -0
- package/dist/{types-B6UXlEkf.d.cts → types-D3BeGucy.d.mts} +262 -5
- package/dist/types-D3BeGucy.d.mts.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-BwqQnool.cjs → workspace-C82GLPnf.cjs} +8 -2
- package/dist/workspace-C82GLPnf.cjs.map +1 -0
- package/dist/{workspace-D1QbNd55.mjs → workspace-DUnnVjqC.mjs} +8 -2
- package/dist/workspace-DUnnVjqC.mjs.map +1 -0
- package/package.json +17 -16
- package/dist/SubscriberGenerator-C8CPxrCK.cjs.map +0 -1
- package/dist/SubscriberGenerator-y3pncae_.mjs.map +0 -1
- package/dist/compose-CgBPA44v.mjs.map +0 -1
- package/dist/compose-bKLAtHLj.cjs.map +0 -1
- package/dist/config-D48erO2j.d.mts.map +0 -1
- package/dist/config-DHDtsQrB.d.cts.map +0 -1
- package/dist/credentials-B5N5yKk6.mjs.map +0 -1
- package/dist/credentials-Zqr3QQYB.cjs.map +0 -1
- package/dist/deploy-CI85F6dr.cjs.map +0 -1
- package/dist/deploy-Ddy8UBoE.mjs.map +0 -1
- package/dist/discover-C5roJuc9.mjs.map +0 -1
- package/dist/discover-CSW_BMWa.d.cts +0 -125
- package/dist/discover-CSW_BMWa.d.cts.map +0 -1
- package/dist/discover-DozUKs8f.cjs.map +0 -1
- package/dist/discover-xtT7fgWg.d.mts +0 -125
- package/dist/discover-xtT7fgWg.d.mts.map +0 -1
- package/dist/dns-BgxvvcQa.mjs.map +0 -1
- package/dist/dns-CfEZHt7r.cjs.map +0 -1
- package/dist/emit-C1e8qD08.mjs.map +0 -1
- package/dist/emit-Dmc1nvdS.cjs.map +0 -1
- package/dist/github-CO8W9SDs.cjs.map +0 -1
- package/dist/github-CQt3xc3o.mjs.map +0 -1
- package/dist/run-BJLIerMM.mjs +0 -133
- package/dist/run-BJLIerMM.mjs.map +0 -1
- package/dist/run-fVZ-rLnc.cjs +0 -174
- package/dist/run-fVZ-rLnc.cjs.map +0 -1
- package/dist/sandbox-C4g1eG31.d.mts +0 -104
- package/dist/sandbox-C4g1eG31.d.mts.map +0 -1
- package/dist/sandbox-CdKgQ3XU.d.cts +0 -104
- package/dist/sandbox-CdKgQ3XU.d.cts.map +0 -1
- package/dist/seeds-CFG-f24B.cjs.map +0 -1
- package/dist/seeds-oY0qDqui.mjs.map +0 -1
- package/dist/types-B6UXlEkf.d.cts.map +0 -1
- package/dist/types-HqVPddRK.d.mts.map +0 -1
- package/dist/workspace-BwqQnool.cjs.map +0 -1
- package/dist/workspace-D1QbNd55.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snsSubscriptions-CSkteK2J.cjs","names":["checkStageBackups","kebabCase","GkmError","postgresRoleSlug","dirname","fileURLToPath","join","existsSync","readFileSync","createRequire","DEFAULT_POSTGRES_VERSION","postgresImage","createHash","localRolePassword","quoteIdentifier","GkmError","environmentCase","appKey","randomBytes","bcrypt","createHash","storedCredentials","SERVER_IPV4_KEY","GkmError","SERVER_IPV6_KEY","isIPv6","isIPv4","normalizeDnsConfig","extractSubdomain","findRootDomain","cnameTarget","createDnsProvider","DnsRecordsUnreadable","dnsLookup","GkmError"],"sources":["../src/providers/dns.ts","../src/backups/config.ts","../src/backups/service.ts","../src/compose/sitePassword.ts","../src/providers/aws.ts","../src/compose/dns.ts","../src/deploy/snsSubscriptions.ts"],"sourcesContent":["/**\n * What the deploy's DNS step needs to know about a workspace before its\n * stack is run: whether it deploys with compose.\n *\n * The step itself is `stageDns` in `compose/dns.ts`, run by every deploy\n * (`gkm deploy`, and `gkm compose`, the same run) where the deploy runs — a\n * CI runner or a developer's machine, which hold the DNS provider's token.\n * The server never does.\n */\n\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\n/** Whether the workspace deploys through the compose target. */\nexport function deploysWithCompose(workspace: NormalizedWorkspace): boolean {\n\treturn (\n\t\tworkspace.deploy?.default === 'compose' ||\n\t\tObject.values(workspace.apps).some(\n\t\t\t(app) => app.resolvedDeployTarget === 'compose',\n\t\t)\n\t);\n}\n","/**\n * Which stages take backups, and where they are kept.\n *\n * A deployed compose stage whose stack runs Postgres is backed up by\n * default — every day at 02:00 UTC, kept 30 days — unless\n * `deploy.backups.<stage>` says otherwise. The local stage never is.\n *\n * Every backup is kept in the project bucket (`providers/projectBucket.ts`),\n * beside the stage's deploy state, one folder per run and one file per\n * database:\n *\n * ```\n * gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/database.sql.gz\n * gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/auth-database.sql.gz\n * ```\n *\n * The file is named after the database's construct, the way its migrations\n * folder is: `AuthDatabase` is `db/auth-database`, and `auth-database.sql.gz`.\n */\n\nimport { type ConstructManifest, kebabCase } from '@geekmidas/manifest';\nimport { deploysWithCompose } from '../providers/dns.js';\nimport type { PrefixExpiry } from '../providers/projectBucket.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { checkStageBackups, type StageBackups } from './schedule.js';\n\n/** What a stage's backups come to. */\nexport type StageBackupsChoice =\n\t| {\n\t\t\tmode: 'on';\n\t\t\tbackups: StageBackups;\n\t\t\t/** Whether the stage named it, or took the default. */\n\t\t\tsource: 'config' | 'default';\n\t }\n\t/** `deploy.backups.<stage>: false`. */\n\t| { mode: 'disabled' }\n\t/** Nothing to back up, or nowhere it applies. */\n\t| { mode: 'none'; reason: 'local' | 'not-compose' | 'no-postgres' };\n\n/** The workspace parts {@link stageBackups} reads. */\nexport type BackupsWorkspace = Pick<\n\tNormalizedWorkspace,\n\t'name' | 'apps' | 'deploy' | 'stages' | 'state'\n>;\n\n/** Whether the stack runs Postgres: some construct is a database. */\nexport function runsPostgres(manifest: ConstructManifest): boolean {\n\treturn Object.values(manifest).some((d) => d.kind === 'database');\n}\n\n/**\n * What `stage`'s backups are: on — by its entry or the default — off by\n * `false`, or none, for the local stage, a stage compose does not deploy,\n * and a stack with no database.\n */\nexport function stageBackups(\n\tworkspace: BackupsWorkspace,\n\tmanifest: ConstructManifest,\n\tstage: string,\n): StageBackupsChoice {\n\tif (stage === workspace.stages?.local) {\n\t\treturn { mode: 'none', reason: 'local' };\n\t}\n\tif (!deploysWithCompose(workspace as NormalizedWorkspace)) {\n\t\treturn { mode: 'none', reason: 'not-compose' };\n\t}\n\tif (!runsPostgres(manifest)) return { mode: 'none', reason: 'no-postgres' };\n\tconst value = (\n\t\tworkspace.deploy?.backups as Record<string, unknown> | undefined\n\t)?.[stage];\n\tconst checked = checkStageBackups(stage, value ?? {});\n\tif (checked === false) return { mode: 'disabled' };\n\treturn {\n\t\tmode: 'on',\n\t\tbackups: checked,\n\t\tsource: value === undefined ? 'default' : 'config',\n\t};\n}\n\n/**\n * Where a stage's backups are, in the project bucket — under the same\n * `<prefix>/<project>/<stage>` its deploy state is: `gkm/shop/production/backups`.\n */\nexport function backupsPrefix(\n\tworkspace: Pick<NormalizedWorkspace, 'name' | 'state'>,\n\tstage: string,\n): string {\n\tconst state = workspace.state;\n\tconst prefix =\n\t\tstate?.provider === 's3' && state.prefix !== undefined\n\t\t\t? state.prefix.replace(/\\/+$/, '')\n\t\t\t: 'gkm';\n\treturn `${prefix ? `${prefix}/` : ''}${workspace.name}/${stage}/backups`;\n}\n\n/** One run's folder: `2026-10-10/02-00-00Z`, for the time it started. */\nexport function runFolder(at: Date): string {\n\tconst iso = at.toISOString();\n\treturn `${iso.slice(0, 10)}/${iso.slice(11, 19).replace(/:/g, '-')}Z`;\n}\n\n/** A run folder's time back, or `undefined` for a key that is not one. */\nexport function runTime(folder: string): Date | undefined {\n\tconst match = /^(\\d{4}-\\d{2}-\\d{2})\\/(\\d{2})-(\\d{2})-(\\d{2})Z$/.exec(folder);\n\tif (!match) return undefined;\n\tconst at = new Date(`${match[1]}T${match[2]}:${match[3]}:${match[4]}Z`);\n\treturn Number.isNaN(at.getTime()) ? undefined : at;\n}\n\n/** One database the stack backs up. */\nexport interface BackupDatabase {\n\t/** Its construct: `AuthDatabase`. */\n\tid: string;\n\t/** Its file in a run's folder, less `.sql.gz`: `auth-database`. */\n\tfile: string;\n\t/** Its name in the stack's Postgres: `auth_database_production`. */\n\tname: string;\n}\n\n/** A database's file in a run's folder: `auth-database.sql.gz`. */\nexport function backupFile(database: Pick<BackupDatabase, 'file'>): string {\n\treturn `${database.file}.sql.gz`;\n}\n\n/** Each database the stack runs, by its construct and its name in Postgres. */\nexport function backupDatabases(\n\tresources: readonly { id: string; kind: string; name: string }[],\n): BackupDatabase[] {\n\treturn resources\n\t\t.filter((r) => r.kind === 'database')\n\t\t.map((r) => ({ id: r.id, file: kebabCase(r.id), name: r.name }))\n\t\t.sort((a, b) => a.file.localeCompare(b.file));\n}\n\n/**\n * The expiry of every stage's backups, by each stage's own entry — what the\n * project bucket's lifecycle carries beside its own rule.\n *\n * A put replaces a bucket's whole lifecycle, so this is built from every\n * deployed stage each time, never from the stage being deployed alone: one\n * stage's deploy keeps every other's rule. A stage set to `false` has none,\n * and its backups are kept until someone deletes them.\n */\nexport function backupExpiries(\n\tworkspace: BackupsWorkspace,\n\tmanifest: ConstructManifest,\n): PrefixExpiry[] {\n\tconst expiries: PrefixExpiry[] = [];\n\tfor (const stage of [...(workspace.stages?.deployed ?? [])].sort()) {\n\t\tconst choice = stageBackups(workspace, manifest, stage);\n\t\tif (choice.mode !== 'on') continue;\n\t\texpiries.push({\n\t\t\tid: `gkm-backups-${stage}`,\n\t\t\tprefix: `${backupsPrefix(workspace, stage)}/`,\n\t\t\tdays: choice.backups.keepDays,\n\t\t\tabortIncompleteDays: 1,\n\t\t});\n\t}\n\treturn expiries;\n}\n","/**\n * The stack's `backups` service: what a deployed compose stage with Postgres\n * runs beside its apps, unless `deploy.backups.<stage>` is `false`.\n *\n * - **The image** is built from the stack's own Postgres image —\n * `postgres:<major>-alpine`, already on the server for the stack, and with\n * the `pg_dump` that matches the server — with Node added and gkm's runner\n * (`runner.ts`) copied in. Nothing is pulled that the stack does not have,\n * and nothing is mounted from the host: the build context is two files.\n * - **Its key** is `BACKUPS_URL`, from the stage's secrets, like any app's:\n * allowed to put objects under the stage's backups prefix and nothing else.\n * The server holds no AWS credentials of its own.\n * - **Its login** is a role of its own, `<project>_backups`, granted\n * `pg_read_all_data` — it can read every database and write none. Postgres\n * before 14 has no such role, and there it signs in as the stack's\n * superuser.\n * - **Its health** is the last good run: unhealthy once that is more than\n * twice the schedule's longest gap old, after a startup grace.\n */\n\nimport { createHash } from 'node:crypto';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_POSTGRES_VERSION } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport { postgresImage } from '../reconcile/containers.js';\nimport { localRolePassword } from '../reconcile/env.js';\nimport { postgresRoleSlug } from '../reconcile/localCredentials.js';\nimport type { Plan } from '../reconcile/plan.js';\nimport { quoteIdentifier, type Statement } from '../reconcile/provision.js';\nimport {\n\ttype BackupDatabase,\n\ttype BackupsWorkspace,\n\tbackupDatabases,\n\tbackupsPrefix,\n} from './config.js';\nimport type { StageBackups } from './schedule.js';\n\n/** The service's name in the stack. */\nexport const BACKUPS_SERVICE = 'backups';\n\n/** The secret its key is written to. */\nexport const BACKUPS_URL_KEY = 'BACKUPS_URL';\n\n/** Where the runner is, in the image. */\nexport const RUNNER_PATH = '/gkm/backup.mjs';\n\n/** The first Postgres with `pg_read_all_data`. */\nconst READ_ALL_DATA_SINCE = 14;\n\n/** A stage that backs up, and no key to back up with. */\nexport class BackupsUrlMissing extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`'${stage}' runs Postgres, so its stack backs it up, and its secrets ` +\n\t\t\t\t`hold no ${BACKUPS_URL_KEY} to back up with. The deploy writes it — ` +\n\t\t\t\t\"the IAM user and key it creates in the stage's AWS account — so \" +\n\t\t\t\t'run the deploy with the ' +\n\t\t\t\t\"account's credentials. To take no backups on this stage, set \" +\n\t\t\t\t`deploy.backups.${stage}: false.`,\n\t\t);\n\t\tthis.name = 'BackupsUrlMissing';\n\t}\n}\n\n/** The backups role: `<project>_backups`, as the superuser is `<project>_admin`. */\nexport function backupsRole(project: string): string {\n\treturn `${postgresRoleSlug(project)}_backups`;\n}\n\n/** The stack's backups, as its compose file and env file have them. */\nexport interface StackBackups {\n\tbackups: StageBackups;\n\tdatabases: BackupDatabase[];\n\t/** `gkm/<project>/<stage>/backups`. */\n\tprefix: string;\n\t/** The Postgres image it is built from. */\n\tfrom: string;\n\t/** `<project>-backups:pg18-<hash>`: built on the server, never pushed. */\n\timage: string;\n\t/** Its build context: the Dockerfile and the runner. */\n\tfiles: { Dockerfile: string; 'backup.mjs': string };\n\t/** What it signs in to Postgres as. */\n\tlogin: { user: string; password: string };\n\t/** Whether that is its own read-only role (else the superuser). */\n\treadOnly: boolean;\n\t/** Its environment — empty in a stack that only builds. */\n\tenv: Record<string, string>;\n}\n\n/**\n * The runner's source, as JavaScript: the built `backups/runner.mjs` beside\n * the CLI's bundle, or — run from source — `runner.ts`, with its types\n * stripped by esbuild.\n */\nexport function runnerSource(): string {\n\tconst here = dirname(fileURLToPath(import.meta.url));\n\tfor (const path of [\n\t\tjoin(here, 'backups', 'runner.mjs'),\n\t\tjoin(here, 'runner.mjs'),\n\t\tjoin(here, '..', 'backups', 'runner.mjs'),\n\t]) {\n\t\tif (existsSync(path)) return readFileSync(path, 'utf-8');\n\t}\n\tconst { transformSync } = createRequire(import.meta.url)(\n\t\t'esbuild',\n\t) as typeof import('esbuild');\n\treturn transformSync(readFileSync(join(here, 'runner.ts'), 'utf-8'), {\n\t\tloader: 'ts',\n\t\tformat: 'esm',\n\t\ttarget: 'node22',\n\t}).code;\n}\n\n/** The image's Dockerfile: the stack's Postgres, Node, and the runner. */\nexport function backupsDockerfile(from: string): string {\n\treturn `# Generated by gkm — the stage's backups: pg_dump from ${from}, and gkm's uploader.\nFROM ${from}\nRUN apk add --no-cache nodejs\nCOPY backup.mjs ${RUNNER_PATH}\nUSER postgres\nENTRYPOINT []\nCMD [\"node\", \"${RUNNER_PATH}\", \"serve\"]\n`;\n}\n\nexport interface StackBackupsInput {\n\tworkspace: BackupsWorkspace;\n\tstage: string;\n\tproject: string;\n\tplan: Plan;\n\tbackups: StageBackups;\n\t/** The stage's secrets, by key. */\n\tcustom: Readonly<Record<string, string>>;\n\tseed: string;\n\t/** The stack's superuser. */\n\tsuperuser: { user: string; password: string };\n\t/** What the stage's telemetry hands a process, when it is on. */\n\ttelemetry?: Readonly<Record<string, string>>;\n\t/** The stack only builds: no environment, no key needed. */\n\tbuildOnly?: boolean;\n}\n\n/**\n * The stack's backups service, for a stage whose backups are on.\n *\n * @throws {BackupsUrlMissing} when the stage's secrets hold no key\n */\nexport function stackBackups(input: StackBackupsInput): StackBackups {\n\tconst { plan, stage } = input;\n\tconst version =\n\t\tplan.resources.find((r) => r.version)?.version ?? DEFAULT_POSTGRES_VERSION;\n\tconst from = postgresImage(version);\n\tconst script = runnerSource();\n\tconst dockerfile = backupsDockerfile(from);\n\tconst hash = createHash('sha256')\n\t\t.update(dockerfile)\n\t\t.update(script)\n\t\t.digest('hex')\n\t\t.slice(0, 12);\n\n\tconst readOnly = version >= READ_ALL_DATA_SINCE;\n\tconst role = backupsRole(input.workspace.name);\n\tconst login = readOnly\n\t\t? {\n\t\t\t\tuser: role,\n\t\t\t\tpassword: localRolePassword(\n\t\t\t\t\tinput.workspace.name,\n\t\t\t\t\tplan,\n\t\t\t\t\trole,\n\t\t\t\t\tinput.seed,\n\t\t\t\t),\n\t\t\t}\n\t\t: input.superuser;\n\n\tconst databases = backupDatabases(plan.resources);\n\tconst prefix = backupsPrefix(input.workspace, stage);\n\tconst { kind, ...schedule } = input.backups.schedule;\n\n\tlet env: Record<string, string> = {};\n\tif (!input.buildOnly) {\n\t\tconst url = input.custom[BACKUPS_URL_KEY];\n\t\tif (!url) throw new BackupsUrlMissing(stage);\n\t\tenv = {\n\t\t\tBACKUPS_URL: url,\n\t\t\tBACKUPS_PREFIX: prefix,\n\t\t\tBACKUPS_DATABASES: JSON.stringify(\n\t\t\t\tdatabases.map(({ file, name }) => ({ file, name })),\n\t\t\t),\n\t\t\tBACKUPS_SCHEDULE: JSON.stringify(\n\t\t\t\tkind === 'cron'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tminutes: input.backups.schedule.minutes,\n\t\t\t\t\t\t\thours: input.backups.schedule.hours,\n\t\t\t\t\t\t\tdays: input.backups.schedule.days,\n\t\t\t\t\t\t\tmonths: input.backups.schedule.months,\n\t\t\t\t\t\t\tweekdays: input.backups.schedule.weekdays,\n\t\t\t\t\t\t}\n\t\t\t\t\t: { kind, ...schedule },\n\t\t\t),\n\t\t\tBACKUPS_MAX_GAP_SECONDS: String(input.backups.maxGapSeconds),\n\t\t\tPGHOST: 'postgres',\n\t\t\tPGPORT: '5432',\n\t\t\tPGUSER: login.user,\n\t\t\tPGPASSWORD: login.password,\n\t\t\t...(input.telemetry?.OTEL_EXPORTER_OTLP_ENDPOINT\n\t\t\t\t? {\n\t\t\t\t\t\tOTEL_EXPORTER_OTLP_ENDPOINT:\n\t\t\t\t\t\t\tinput.telemetry.OTEL_EXPORTER_OTLP_ENDPOINT,\n\t\t\t\t\t\t...(input.telemetry.OTEL_EXPORTER_OTLP_HEADERS\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tOTEL_EXPORTER_OTLP_HEADERS:\n\t\t\t\t\t\t\t\t\t\tinput.telemetry.OTEL_EXPORTER_OTLP_HEADERS,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tOTEL_SERVICE_NAME: BACKUPS_SERVICE,\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\treturn {\n\t\tbackups: input.backups,\n\t\tdatabases,\n\t\tprefix,\n\t\tfrom,\n\t\timage: `${input.project}-backups:pg${version}-${hash}`,\n\t\tfiles: { Dockerfile: dockerfile, 'backup.mjs': script },\n\t\tlogin,\n\t\treadOnly,\n\t\tenv,\n\t};\n}\n\n/** The service in the stack's compose file. */\nexport function backupsService(backups: StackBackups, envFiles: boolean) {\n\treturn {\n\t\timage: backups.image,\n\t\t// Built on the server from two files; there is nothing to pull.\n\t\tbuild: { context: `./${BACKUPS_SERVICE}`, dockerfile: 'Dockerfile' },\n\t\tpull_policy: 'build' as const,\n\t\trestart: 'unless-stopped',\n\t\t...(envFiles\n\t\t\t? {\n\t\t\t\t\tenv_file: [\n\t\t\t\t\t\t{ path: `./${BACKUPS_SERVICE}.env`, format: 'raw' as const },\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t: {}),\n\t\tdepends_on: { postgres: { condition: 'service_healthy' as const } },\n\t\thealthcheck: {\n\t\t\ttest: ['CMD', 'node', RUNNER_PATH, 'health'],\n\t\t\tinterval: '1m',\n\t\t\ttimeout: '10s',\n\t\t\tretries: 3,\n\t\t\tstart_period: '30s',\n\t\t},\n\t};\n}\n\n/**\n * The backups role, created and kept: able to sign in and read every\n * database, and nothing else. None when it signs in as the superuser.\n */\nexport function backupsRoleStatements(backups: StackBackups): Statement[] {\n\tif (!backups.readOnly) return [];\n\tconst role = quoteIdentifier(backups.login.user);\n\tconst password = `'${backups.login.password.replace(/'/g, \"''\")}'`;\n\treturn [\n\t\t{\n\t\t\tid: BACKUPS_SERVICE,\n\t\t\tdescribe: `role ${backups.login.user}`,\n\t\t\texists: {\n\t\t\t\tsql: 'SELECT 1 FROM pg_roles WHERE rolname = $1',\n\t\t\t\tvalues: [backups.login.user],\n\t\t\t},\n\t\t\tcreate: `CREATE ROLE ${role} LOGIN PASSWORD ${password}`,\n\t\t},\n\t\t{\n\t\t\tid: BACKUPS_SERVICE,\n\t\t\tdescribe: `role ${backups.login.user}: its password`,\n\t\t\tcreate: `ALTER ROLE ${role} WITH LOGIN PASSWORD ${password}`,\n\t\t},\n\t\t{\n\t\t\tid: BACKUPS_SERVICE,\n\t\t\tdescribe: `role ${backups.login.user}: read every database`,\n\t\t\tcreate: `GRANT pg_read_all_data TO ${role}`,\n\t\t},\n\t];\n}\n","/**\n * A deployed stage's sites behind a password — `deploy.sitePassword` — so a\n * staging build is not public while it is being tried.\n *\n * The edge asks for it with HTTP basic auth, before a request reaches the\n * site: the browser prompts, and nothing of the site loads until the stage's\n * login is given. The user is the stage's name; the password is generated\n * once per site and kept in the stage's secrets, where one set by hand wins.\n * Only its bcrypt hash reaches the edge's config.\n *\n * Pure.\n */\n\nimport { createHash, randomBytes } from 'node:crypto';\nimport { type ConstructManifest, environmentCase } from '@geekmidas/manifest';\nimport bcrypt from 'bcryptjs';\nimport { GkmError } from '../errors';\nimport type { StageSecrets } from '../secrets/types.js';\nimport { appKey } from '../workspace/derive.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\n/** The basic-auth login a site is served behind. */\nexport interface SiteAuth {\n\t/** The stage's name. */\n\tuser: string;\n\tpassword: string;\n\t/** The password's bcrypt hash — what the edge's config holds. */\n\thash: string;\n\t/** The stage secret the password is kept in: `WEB_SITE_PASSWORD`. */\n\tkey: string;\n}\n\n/** `deploy.sitePassword` names something that is not one of the stage's sites. */\nexport class UnknownPasswordSite extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly site: string,\n\t\treadonly sites: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`deploy.sitePassword.${stage} names '${site}', which is not a site of ` +\n\t\t\t\t`this workspace. ${\n\t\t\t\t\tsites.length > 0\n\t\t\t\t\t\t? `Its sites: ${sites.map((s) => `'${s}'`).join(', ')}.`\n\t\t\t\t\t\t: 'It declares no site.'\n\t\t\t\t} Name one of them, or set ${stage}: true for every site.`,\n\t\t);\n\t\tthis.name = 'UnknownPasswordSite';\n\t}\n}\n\n/** A site the stage puts behind a password, with none in the stage's secrets. */\nexport class SitePasswordMissing extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.sitePassword puts a site of '${stage}' behind a password, and ` +\n\t\t\t\t`the stage has no ${key} in its secrets. Run gkm compose --stage ` +\n\t\t\t\t`${stage} once to generate it, or set one: ` +\n\t\t\t\t`gkm secrets:set ${key} '…' --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'SitePasswordMissing';\n\t}\n}\n\n/**\n * `deploy.sitePassword` names a stage that deploys through a target that\n * cannot ask for a login. Refused rather than ignored: ignored, the stage\n * would be public while its config says it is not.\n */\nexport class SitePasswordNeedsCompose extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly target: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.sitePassword puts '${stage}' behind a password, and it deploys ` +\n\t\t\t\t`through '${target}', which cannot ask for one yet — only compose ` +\n\t\t\t\t`does. Remove ${stage} from deploy.sitePassword, or deploy it with ` +\n\t\t\t\t`compose.`,\n\t\t);\n\t\tthis.name = 'SitePasswordNeedsCompose';\n\t}\n}\n\n/**\n * @throws {SitePasswordNeedsCompose} where `stage` asks for a site password\n * and `target` is not compose\n */\nexport function assertSitePasswordTarget(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy'>,\n\tstage: string,\n\ttarget: string,\n): void {\n\tif (workspace.deploy?.sitePassword?.[stage] && target !== 'compose') {\n\t\tthrow new SitePasswordNeedsCompose(stage, target);\n\t}\n}\n\n/** The stage secret a site's password is kept in: `WEB_SITE_PASSWORD`. */\nexport function sitePasswordKey(site: string): string {\n\treturn `${environmentCase(site)}_SITE_PASSWORD`;\n}\n\n/** Every site the manifest declares, by app name. */\nexport function siteNames(manifest: ConstructManifest): string[] {\n\treturn Object.values(manifest)\n\t\t.filter((declaration) => declaration.kind === 'site')\n\t\t.map((declaration) => appKey(declaration.id));\n}\n\n/**\n * The sites `deploy.sitePassword` puts behind a password on `stage`, by app\n * name: every one for `true`, the ones it names otherwise.\n *\n * @throws {UnknownPasswordSite} for a name that is not one of `sites`\n */\nexport function passwordSites(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy'>,\n\tstage: string,\n\tsites: readonly string[],\n): string[] {\n\tconst choice = workspace.deploy?.sitePassword?.[stage];\n\tif (!choice) return [];\n\tif (choice === true) return [...sites];\n\n\tconst chosen = new Set<string>();\n\tfor (const name of choice) {\n\t\tconst site = appKey(name);\n\t\tif (!sites.includes(site)) {\n\t\t\tthrow new UnknownPasswordSite(stage, name, sites);\n\t\t}\n\t\tchosen.add(site);\n\t}\n\treturn [...chosen];\n}\n\n/** A password: 192 random bits, URL-safe, so it is typed or pasted as is. */\nexport function generateSitePassword(): string {\n\treturn randomBytes(24).toString('base64url');\n}\n\n/**\n * The stage's secrets with a generated password for each site, where it has\n * none. Pure, like `withGeneratedSecrets`: the caller keeps the result once\n * the run goes ahead.\n */\nexport function withSitePasswords(\n\tsecrets: StageSecrets,\n\tsites: readonly string[],\n): { secrets: StageSecrets; generated: string[] } {\n\tconst missing = sites\n\t\t.map(sitePasswordKey)\n\t\t.filter((key) => !secrets.custom?.[key]);\n\tif (missing.length === 0) return { secrets, generated: [] };\n\n\treturn {\n\t\tsecrets: {\n\t\t\t...secrets,\n\t\t\tcustom: {\n\t\t\t\t...secrets.custom,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\tmissing.map((key) => [key, generateSitePassword()]),\n\t\t\t\t),\n\t\t\t},\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t},\n\t\tgenerated: missing,\n\t};\n}\n\n/**\n * The login a site is served behind on `stage`.\n *\n * The hash's salt is derived from the password, so the same password always\n * renders the same edge config: a deploy that changed nothing rewrites\n * nothing, and the proxy is not reloaded for it. A per-hash random salt\n * guards against a precomputed table of common passwords; a generated one is\n * 192 random bits, which no table holds.\n *\n * @throws {SitePasswordMissing} where the stage's secrets hold none\n */\nexport function siteAuth(\n\tstage: string,\n\tsite: string,\n\tcustom: Readonly<Record<string, string>>,\n): SiteAuth {\n\tconst key = sitePasswordKey(site);\n\tconst password = custom[key];\n\tif (!password) throw new SitePasswordMissing(stage, key);\n\n\treturn {\n\t\tuser: stage,\n\t\tpassword,\n\t\thash: bcrypt.hashSync(password, saltFor(password)),\n\t\tkey,\n\t};\n}\n\n/** bcrypt's own base-64 alphabet, in which a salt is written. */\nconst BCRYPT_ALPHABET =\n\t'./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * A bcrypt salt — `$2a$`, which Caddy and Traefik both read, at cost 10 —\n * derived from the password.\n */\nfunction saltFor(password: string): string {\n\tconst digest = createHash('sha256').update(password).digest();\n\tlet salt = '';\n\tfor (let i = 0; i < 22; i++) salt += BCRYPT_ALPHABET[digest[i]! % 64];\n\treturn `$2a$10$${salt}`;\n}\n","/**\n * The AWS account a provider provisions in — the stage's, found the way the\n * SSM and Secrets Manager stores find it.\n *\n * 1. `--profile`, resolved on its own: exported keys left over from another\n * account never win over a profile someone named.\n * 2. `AWS_PROFILE`, else `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` — the\n * deploy's own `aws` credential kind (`storedCredentials`).\n * 3. The SDK's default chain: `~/.aws` default profile, SSO, a role. In CI,\n * whatever `aws-actions/configure-aws-credentials` exported.\n *\n * None of them: the provider has no provisioning credentials, and the stage\n * is treated as `external`.\n */\n\nimport {\n\ttype AwsCredential,\n\tstoredCredentials,\n} from '../deploy/credentials.js';\nimport type { CredentialLookup } from './types.js';\n\n/** An AWS credential, or the default chain the SDK resolves itself. */\nexport type AwsProvisioning =\n\t| AwsCredential\n\t| {\n\t\t\tchain: true;\n\t\t\tregion?: string;\n\t };\n\nexport async function awsProvisioningCredentials(\n\tlookup: CredentialLookup,\n): Promise<AwsProvisioning | undefined> {\n\tconst region = lookup.env.AWS_REGION ?? lookup.env.AWS_DEFAULT_REGION;\n\tconst where = region ? { region } : {};\n\tif (lookup.profile) return { profile: lookup.profile, ...where };\n\n\tconst stored = await storedCredentials({\n\t\tenv: lookup.env,\n\t\t...(lookup.home ? { home: lookup.home } : {}),\n\t}).get({ kind: 'aws', stage: lookup.stage });\n\tif (stored) return stored;\n\n\ttry {\n\t\tconst { fromNodeProviderChain } = await import(\n\t\t\t'@aws-sdk/credential-providers'\n\t\t);\n\t\tawait fromNodeProviderChain({ timeout: 1000, maxRetries: 0 })();\n\t\treturn { chain: true, ...where };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * An S3-compatible endpoint the environment points the SDK at — the AWS\n * emulator in tests. The SDK reads it itself; it is read here too, because\n * an emulator takes path-style requests, and a key written for one has to\n * say where it is.\n */\nexport function awsEndpoint(\n\tenv: NodeJS.ProcessEnv,\n\tservice: 'S3' | 'IAM' | 'SNS' | 'SQS' | 'STS',\n): string | undefined {\n\treturn env[`AWS_ENDPOINT_URL_${service}`] ?? env.AWS_ENDPOINT_URL;\n}\n\n/** An SDK client's config for a provisioning credential. */\nexport async function awsClientConfig(\n\tcredential: AwsProvisioning,\n\tregion: string,\n): Promise<{\n\tregion: string;\n\tcredentials?:\n\t\t| ReturnType<typeof import('@aws-sdk/credential-providers').fromIni>\n\t\t| { accessKeyId: string; secretAccessKey: string; sessionToken?: string };\n}> {\n\tif ('profile' in credential) {\n\t\tconst { fromIni } = await import('@aws-sdk/credential-providers');\n\t\treturn { region, credentials: fromIni({ profile: credential.profile }) };\n\t}\n\tif ('accessKeyId' in credential) {\n\t\treturn {\n\t\t\tregion,\n\t\t\tcredentials: {\n\t\t\t\taccessKeyId: credential.accessKeyId,\n\t\t\t\tsecretAccessKey: credential.secretAccessKey,\n\t\t\t\t...(credential.sessionToken\n\t\t\t\t\t? { sessionToken: credential.sessionToken }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t};\n\t}\n\treturn { region };\n}\n","/**\n * A compose stage's DNS: the records its public hosts need, and the check that\n * they resolve to its server before a certificate is asked for.\n *\n * - **The server** (`serverAddress`): the stage's own secrets hold its public\n * addresses — `GKM_SERVER_IPV4`, and `GKM_SERVER_IPV6` where it has one.\n * Reserved for gkm: never handed to an app.\n * - **The plan** (`planStackDns`, pure): every public host the stack serves —\n * its apex, each app, each file server, the public log UI — pointed at the\n * server. An A record per host (and an AAAA with an IPv6 address), or, where\n * the domain's `dns` entry says `records: { mode: 'cname', target }`, one A\n * record for the target and a CNAME to it for every other host but the\n * apex, which DNS forbids a CNAME at.\n * - **Applying it** (`applyStackDns`): through the domain's provider in `dns`,\n * a record set at a time. A record with the right value is left alone; one\n * with another value is replaced and the change printed. A `manual` domain\n * is printed and nothing else. A dry run reads, prints and writes nothing.\n * - **The check** (`checkStackDns`): each host resolved with the system\n * resolver. One that is not the server stops the deploy with\n * {@link HostNotPointingAtServer}, before Caddy or Traefik ask Let's Encrypt\n * for a certificate it cannot get — and use up the rate limit trying.\n * - **What gkm wrote before** (`diffRecordedDns`, pure): the plan against the\n * records the stage's state says gkm wrote — added, kept, and stale: a\n * host the stage no longer serves, after a domain or an app changed.\n * - **The prune** (`pruneStackDns`): each stale record deleted through its\n * domain's provider, if it still holds the value gkm wrote. One someone\n * pointed elsewhere is left alone; one no provider can delete is printed.\n * - **The step** (`stageDns`): all of it, as every deploy runs it — the plan applied through each provider,\n * what was written read back from the provider, the stale records pruned,\n * and only the hosts no provider wrote resolved publicly. A brand-new name\n * is never looked up before its record exists, so no resolver caches it as\n * missing.\n */\n\nimport { lookup as dnsLookup } from 'node:dns/promises';\nimport { isIPv4, isIPv6 } from 'node:net';\nimport type {\n\tCredentialProvider,\n\tGoDaddyCredential,\n\tHostingerCredential,\n} from '../deploy/credentials';\nimport type { DnsResourceRecord } from '../deploy/dnsResources';\nimport {\n\tcreateDnsProvider,\n\ttype DnsProvider,\n\ttype DnsRecord,\n\tDnsRecordsUnreadable,\n\ttype DnsConfig as SchemaDnsConfig,\n} from '../target/dokploy/dns/DnsProvider';\nimport type { GoDaddyProviderOptions } from '../target/dokploy/dns/GoDaddyProvider';\nimport {\n\textractSubdomain,\n\tfindRootDomain,\n\tnormalizeDnsConfig,\n} from '../target/dokploy/dns/index';\nimport type {\n\tDnsProvider as DnsProviderConfig,\n\tWorkspaceDnsConfig,\n} from '../workspace/types';\nimport {\n\tcnameTarget,\n\ttype DnsRecordsMode,\n\tisReservedStageKey,\n\tSERVER_IPV4_KEY,\n\tSERVER_IPV6_KEY,\n} from './dnsConfig';\n\nexport { isReservedStageKey, SERVER_IPV4_KEY, SERVER_IPV6_KEY };\n\nimport { GkmError } from '../errors';\nimport type { ComposeStack } from './stack';\n\n/** A deployed stage's server: what its hosts' records point at. */\nexport interface ServerAddress {\n\tipv4: string;\n\tipv6?: string;\n}\n\n/** The line that says how to set the server's address. */\nexport function serverAddressHint(stage: string): string {\n\treturn `gkm secrets:set ${SERVER_IPV4_KEY} '<ip>' --stage ${stage}`;\n}\n\n/** A server address in the stage's secrets that is not an address. */\nexport class ServerAddressInvalid extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly key: string,\n\t\treadonly value: string,\n\t) {\n\t\tconst ipv4 = key === SERVER_IPV4_KEY;\n\t\tsuper(\n\t\t\t`${key} in the '${stage}' stage's secrets is ${JSON.stringify(value)}, ` +\n\t\t\t\t`which is not an ${ipv4 ? 'IPv4 address (like 203.0.113.10)' : 'IPv6 address (like 2001:db8::10)'}. ` +\n\t\t\t\t`Set the server's public address: gkm secrets:set ${key} '<ip>' --stage ${stage}.`,\n\t\t);\n\t\tthis.name = 'ServerAddressInvalid';\n\t}\n}\n\n/**\n * A compose stage that serves real domains with no server address: its hosts\n * cannot be pointed or checked, and a certificate would be asked for blind.\n */\nexport class ServerAddressMissing extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly domain: string,\n\t) {\n\t\tsuper(\n\t\t\t`The '${stage}' stage serves ${domain} and its secrets hold no ` +\n\t\t\t\t`${SERVER_IPV4_KEY} — the public address of the server its stack runs ` +\n\t\t\t\t\"on, which its hosts' DNS records point at and every deploy checks \" +\n\t\t\t\t`before asking for certificates. Set it: ${serverAddressHint(stage)} ` +\n\t\t\t\t`(and ${SERVER_IPV6_KEY} for an IPv6 address).`,\n\t\t);\n\t\tthis.name = 'ServerAddressMissing';\n\t}\n}\n\n/**\n * The server's address from the stage's secrets, checked — `undefined` when\n * `GKM_SERVER_IPV4` is not set.\n *\n * @throws {ServerAddressInvalid} for a value that is not an address\n */\nexport function serverAddress(\n\tstage: string,\n\tcustom: Readonly<Record<string, string>> | undefined,\n): ServerAddress | undefined {\n\tconst ipv4 = custom?.[SERVER_IPV4_KEY]?.trim();\n\tconst ipv6 = custom?.[SERVER_IPV6_KEY]?.trim();\n\tif (ipv6 && !isIPv6(ipv6)) {\n\t\tthrow new ServerAddressInvalid(stage, SERVER_IPV6_KEY, ipv6);\n\t}\n\tif (!ipv4) return undefined;\n\tif (!isIPv4(ipv4))\n\t\tthrow new ServerAddressInvalid(stage, SERVER_IPV4_KEY, ipv4);\n\treturn { ipv4, ...(ipv6 ? { ipv6 } : {}) };\n}\n\n/**\n * A name that resolves to this machine by definition — `localhost` and every\n * `*.localhost` — and is in nobody's DNS.\n */\nexport function isLocalHost(host: string): boolean {\n\tconst name = host.toLowerCase().replace(/\\.$/, '');\n\treturn name === 'localhost' || name.endsWith('.localhost');\n}\n\n/**\n * The server's address, required where the stage serves real domains — not\n * `*.localhost` ones, which point at this machine already.\n *\n * @throws {ServerAddressMissing} when the stage has a domain and no address\n * @throws {ServerAddressInvalid} for a value that is not an address\n */\nexport function requiredServerAddress(\n\tstage: string,\n\tdomain: string | undefined,\n\tcustom: Readonly<Record<string, string>> | undefined,\n): ServerAddress | undefined {\n\tconst server = serverAddress(stage, custom);\n\tif (!server && domain && !isLocalHost(domain)) {\n\t\tthrow new ServerAddressMissing(stage, domain);\n\t}\n\treturn server;\n}\n\n/** The record types the DNS step writes. */\nexport type StackRecordType = 'A' | 'AAAA' | 'CNAME';\n\nconst MANAGED: readonly StackRecordType[] = ['A', 'AAAA', 'CNAME'];\n\n/** One record a stack's host needs. */\nexport interface PlannedDnsRecord {\n\t/** The full name: `api.example.com`. */\n\thost: string;\n\t/** The root domain in `dns` it is under. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: StackRecordType;\n\tvalue: string;\n\tttl: number;\n}\n\n/** One `dns` domain's share of the plan. */\nexport interface DomainDnsPlan {\n\tdomain: string;\n\t/** `godaddy`, `route53`, `manual`, … — `custom` for an object. */\n\tprovider: string;\n\tconfig: DnsProviderConfig;\n\trecords: PlannedDnsRecord[];\n}\n\nexport interface StackDnsPlan {\n\tstage: string;\n\tserver: ServerAddress;\n\tdomains: DomainDnsPlan[];\n\t/** Hosts under no `dns` domain: theirs to point by hand. */\n\tuncovered: string[];\n}\n\n/** Every public host the stack serves, once each, sorted. */\nexport function stackHosts(stack: Pick<ComposeStack, 'routes'>): string[] {\n\treturn [...new Set(stack.routes.map((route) => route.host))].sort();\n}\n\n/** The TTL a domain's records are written with. */\nexport function recordTtl(config: DnsProviderConfig): number {\n\tconst ttl = 'ttl' in config ? config.ttl : undefined;\n\tif (ttl) return ttl;\n\treturn config.provider === 'godaddy' ? 600 : 300;\n}\n\nfunction providerName(config: DnsProviderConfig): string {\n\treturn typeof config.provider === 'string' ? config.provider : 'custom';\n}\n\nexport interface PlanStackDnsInput {\n\tstage: string;\n\thosts: readonly string[];\n\tserver: ServerAddress;\n\tdns: WorkspaceDnsConfig | undefined;\n}\n\n/**\n * A wildcard host: gkm writes one record per public host, so a stage on\n * another server — or a name someone else points elsewhere — is never caught\n * by a record it did not ask for.\n */\nexport class DnsWildcardRefused extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly host: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' would point ${host} at its server, and gkm never writes a ` +\n\t\t\t\t'wildcard record: each public host gets its own. Give the app a ' +\n\t\t\t\t'subdomain of its own instead.',\n\t\t);\n\t\tthis.name = 'DnsWildcardRefused';\n\t}\n}\n\n/** The records a stage's hosts need — pure. */\nexport function planStackDns(input: PlanStackDnsInput): StackDnsPlan {\n\tconst { stage, server } = input;\n\tconst dns = input.dns ? normalizeDnsConfig(input.dns) : {};\n\tconst records = new Map<string, PlannedDnsRecord>();\n\tconst uncovered: string[] = [];\n\n\tconst add = (\n\t\thost: string,\n\t\tdomain: string,\n\t\ttype: StackRecordType,\n\t\tvalue: string,\n\t) => {\n\t\tconst name = extractSubdomain(host, domain);\n\t\trecords.set(`${domain} ${name} ${type}`, {\n\t\t\thost,\n\t\t\tdomain,\n\t\t\tname,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\tttl: recordTtl(dns[domain]!),\n\t\t});\n\t};\n\tconst pointAt = (host: string, domain: string) => {\n\t\tadd(host, domain, 'A', server.ipv4);\n\t\tif (server.ipv6) add(host, domain, 'AAAA', server.ipv6);\n\t};\n\n\tfor (const raw of input.hosts) {\n\t\tconst host = raw.toLowerCase();\n\t\tif (host.includes('*')) throw new DnsWildcardRefused(stage, host);\n\t\tconst domain = findRootDomain(host, dns);\n\t\tif (!domain) {\n\t\t\tuncovered.push(host);\n\t\t\tcontinue;\n\t\t}\n\t\t// A target under the domain itself — the schema refuses one that is\n\t\t// not — gets the A record every other host's CNAME points at.\n\t\tconst target = cnameTarget(\n\t\t\t(dns[domain] as { records?: DnsRecordsMode }).records,\n\t\t\tstage,\n\t\t);\n\t\tif (target) pointAt(target, domain);\n\t\t// The apex can hold no CNAME — it has the zone's SOA and NS — so it\n\t\t// is always an A record.\n\t\tif (target && host !== domain && host !== target) {\n\t\t\tadd(host, domain, 'CNAME', target);\n\t\t} else {\n\t\t\tpointAt(host, domain);\n\t\t}\n\t}\n\n\tconst domains = new Map<string, DomainDnsPlan>();\n\tfor (const record of [...records.values()].sort(\n\t\t(a, b) =>\n\t\t\ta.domain.localeCompare(b.domain) ||\n\t\t\ta.name.localeCompare(b.name) ||\n\t\t\ta.type.localeCompare(b.type),\n\t)) {\n\t\tconst config = dns[record.domain]!;\n\t\tconst plan = domains.get(record.domain) ?? {\n\t\t\tdomain: record.domain,\n\t\t\tprovider: providerName(config),\n\t\t\tconfig,\n\t\t\trecords: [],\n\t\t};\n\t\tplan.records.push(record);\n\t\tdomains.set(record.domain, plan);\n\t}\n\n\treturn {\n\t\tstage,\n\t\tserver,\n\t\tdomains: [...domains.values()],\n\t\tuncovered: uncovered.sort(),\n\t};\n}\n\n/** One change applying a plan makes — or, in a dry run, would. */\nexport interface DnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: StackRecordType;\n\t/**\n\t * `write`: the provider's key cannot read records, so the record is\n\t * written without knowing what is there — idempotent, and not diffed.\n\t */\n\taction: 'create' | 'update' | 'delete' | 'unchanged' | 'write' | 'manual';\n\t/** The value it is set to — absent for a delete. */\n\tvalue?: string;\n\t/** What it was, for an update or a delete. */\n\tprevious?: string;\n\tttl?: number;\n}\n\nexport interface ApplyStackDnsOptions {\n\tdryRun?: boolean;\n\tlog?: (line: string) => void;\n\t/** Where the GoDaddy provider reads its key: the environment and the CLI's home. */\n\tcredentials?: GoDaddyProviderOptions;\n\t/** The Hostinger token, when the caller already has it. */\n\thostinger?: HostingerCredential;\n\t/** The provider for a domain — `createDnsProvider` by default. */\n\tproviderFor?: (config: DnsProviderConfig) => Promise<DnsProvider | null>;\n\t/**\n\t * Read every record written back from its provider, and throw\n\t * {@link DnsRecordsNotConfirmed} for one that does not hold its value.\n\t */\n\tconfirm?: boolean;\n}\n\n/** What applying a plan did, and what of it the providers confirmed. */\nexport interface StackDnsApplied {\n\t/** Every change, the unchanged included; a dry run makes none of them. */\n\tchanges: DnsChange[];\n\t/**\n\t * Hosts whose every record the provider holds with its value — read\n\t * before the run (unchanged) or after it wrote them (`confirm`).\n\t */\n\tconfirmed: string[];\n\t/**\n\t * Hosts no provider vouches for: a `manual` domain's, those under no\n\t * domain in `dns`, and those of a key that can write and not read.\n\t */\n\tunconfirmed: string[];\n}\n\n/** One record a provider did not hold with its value after it was written. */\nexport interface UnconfirmedRecord {\n\thost: string;\n\ttype: StackRecordType;\n\texpected: string;\n\t/** What the provider read back — empty when the record is not there. */\n\tfound: string[];\n}\n\n/** Records a provider accepted and then did not read back with their value. */\nexport class DnsRecordsNotConfirmed extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly domain: string,\n\t\treadonly provider: string,\n\t\treadonly records: readonly UnconfirmedRecord[],\n\t) {\n\t\tconst lines = records.map(\n\t\t\t(r) =>\n\t\t\t\t` - ${r.host} ${r.type}: ${r.found.length > 0 ? r.found.join(', ') : 'nothing'}, expected ${r.expected}`,\n\t\t);\n\t\tsuper(\n\t\t\t`${provider} accepted '${stage}''s records for ${domain}, and reading them ` +\n\t\t\t\t`back does not show them:\\n${lines.join('\\n')}\\n` +\n\t\t\t\t\"Deploy again; if it persists, check the records in the provider's \" +\n\t\t\t\t'console — another tool may be writing the same names.',\n\t\t);\n\t\tthis.name = 'DnsRecordsNotConfirmed';\n\t}\n}\n\n/** `api.example.com A 203.0.113.10 (TTL 600)` */\nfunction describe(record: PlannedDnsRecord): string {\n\treturn `${record.host.padEnd(32)} ${record.type.padEnd(5)} ${record.value} (TTL ${record.ttl})`;\n}\n\nfunction printManual(\n\tplan: DomainDnsPlan,\n\tlog: (line: string) => void,\n\twhy: string,\n): DnsChange[] {\n\tlog(` ${plan.domain}: ${why} — create these records at its DNS host:`);\n\tfor (const record of plan.records) log(` ${describe(record)}`);\n\treturn plan.records.map((r) => ({\n\t\tdomain: r.domain,\n\t\tname: r.name,\n\t\ttype: r.type,\n\t\taction: 'manual',\n\t\tvalue: r.value,\n\t\tttl: r.ttl,\n\t}));\n}\n\n/** The existing records of every planned name, for the types gkm manages. */\nasync function existingRecords(\n\tprovider: DnsProvider,\n\tplan: DomainDnsPlan,\n): Promise<DnsRecord[]> {\n\tconst names = [...new Set(plan.records.map((r) => r.name))];\n\treturn readRecords(\n\t\tprovider,\n\t\tplan.domain,\n\t\tnames.flatMap((name) => MANAGED.map((type) => ({ name, type }))),\n\t);\n}\n\n/** Exactly these names and types, as the provider holds them. */\nasync function readRecords(\n\tprovider: DnsProvider,\n\tdomain: string,\n\twanted: readonly { name: string; type: StackRecordType }[],\n): Promise<DnsRecord[]> {\n\tif (provider.readRecords) return provider.readRecords(domain, wanted);\n\tconst all = await provider.getRecords(domain);\n\treturn all.filter((r) =>\n\t\twanted.some((w) => w.name === r.name && w.type === r.type),\n\t);\n}\n\n/** The provider for a domain's config: `providerFor`, or the real one. */\nfunction providerResolver(\n\toptions: Pick<\n\t\tApplyStackDnsOptions,\n\t\t'providerFor' | 'credentials' | 'hostinger'\n\t>,\n): (config: DnsProviderConfig) => Promise<DnsProvider | null> {\n\treturn (\n\t\toptions.providerFor ??\n\t\t((config: DnsProviderConfig) =>\n\t\t\tcreateDnsProvider({\n\t\t\t\tconfig: config as SchemaDnsConfig,\n\t\t\t\t...(options.credentials ? { godaddy: options.credentials } : {}),\n\t\t\t\t...(options.hostinger ? { hostinger: options.hostinger } : {}),\n\t\t\t}))\n\t);\n}\n\nconst same = (a: string, b: string) =>\n\ta.trim().replace(/\\.$/, '').toLowerCase() ===\n\tb.trim().replace(/\\.$/, '').toLowerCase();\n\n/**\n * What each domain's records need, compared with what is there: creates,\n * updates, and the deletes a change of mode needs — a name moving from an A\n * record to a CNAME, or back, cannot hold both. Nothing else is deleted.\n */\nexport function diffDomainDns(\n\tplan: DomainDnsPlan,\n\texisting: readonly DnsRecord[],\n): DnsChange[] {\n\tconst changes: DnsChange[] = [];\n\tconst find = (name: string, type: string) =>\n\t\texisting.find((r) => r.name === name && r.type === type);\n\n\tconst planned = new Map<string, Set<StackRecordType>>();\n\tfor (const record of plan.records) {\n\t\tconst types = planned.get(record.name) ?? new Set();\n\t\ttypes.add(record.type);\n\t\tplanned.set(record.name, types);\n\t}\n\n\t// The deletes first: a CNAME where an A record goes, A and AAAA where a\n\t// CNAME goes.\n\tfor (const [name, types] of planned) {\n\t\tconst conflicting: StackRecordType[] = types.has('CNAME')\n\t\t\t? ['A', 'AAAA']\n\t\t\t: ['CNAME'];\n\t\tfor (const type of conflicting) {\n\t\t\tconst found = find(name, type);\n\t\t\tif (!found || found.values.length === 0) continue;\n\t\t\tchanges.push({\n\t\t\t\tdomain: plan.domain,\n\t\t\t\tname,\n\t\t\t\ttype,\n\t\t\t\taction: 'delete',\n\t\t\t\tprevious: found.values.join(', '),\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const record of plan.records) {\n\t\tconst found = find(record.name, record.type);\n\t\tconst base = {\n\t\t\tdomain: plan.domain,\n\t\t\tname: record.name,\n\t\t\ttype: record.type,\n\t\t\tvalue: record.value,\n\t\t\tttl: record.ttl,\n\t\t};\n\t\tif (!found || found.values.length === 0) {\n\t\t\tchanges.push({ ...base, action: 'create' });\n\t\t} else if (\n\t\t\tfound.values.length === 1 &&\n\t\t\tsame(found.values[0]!, record.value)\n\t\t) {\n\t\t\tchanges.push({ ...base, action: 'unchanged' });\n\t\t} else {\n\t\t\tchanges.push({\n\t\t\t\t...base,\n\t\t\t\taction: 'update',\n\t\t\t\tprevious: found.values.join(', '),\n\t\t\t});\n\t\t}\n\t}\n\treturn changes;\n}\n\n/** A host's full name from a domain and a relative name. */\nfunction fullName(domain: string, name: string): string {\n\treturn name === '@' ? domain : `${name}.${domain}`;\n}\n\nfunction printChange(\n\tchange: DnsChange,\n\tdryRun: boolean,\n\tlog: (line: string) => void,\n) {\n\tconst host = fullName(change.domain, change.name).padEnd(32);\n\tconst type = change.type.padEnd(5);\n\tconst would = dryRun ? 'would ' : '';\n\tswitch (change.action) {\n\t\tcase 'unchanged':\n\t\t\tlog(\n\t\t\t\t` ✓ ${host} ${type} ${change.value} (TTL ${change.ttl}) — up to date`,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'create':\n\t\t\tlog(\n\t\t\t\t` + ${host} ${type} ${change.value} (TTL ${change.ttl}) — ${would}create`,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'update':\n\t\t\tlog(\n\t\t\t\t` ~ ${host} ${type} ${change.previous} → ${change.value} (TTL ${change.ttl}) — ${would}update`,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'write':\n\t\t\tlog(\n\t\t\t\tdryRun\n\t\t\t\t\t? ` ? ${host} ${type} ${change.value} (TTL ${change.ttl}) — would write; current value unknown (key cannot read DNS)`\n\t\t\t\t\t: ` ! ${host} ${type} ${change.value} (TTL ${change.ttl}) — written (not diffed)`,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'delete':\n\t\t\tlog(\n\t\t\t\t` - ${host} ${type} ${change.previous} — ${would}delete (a name cannot hold a CNAME and an A record)`,\n\t\t\t);\n\t\t\tbreak;\n\t}\n}\n\n/**\n * Each domain's records, through its provider. Returns every change, the\n * unchanged included; a dry run makes none of them.\n */\nexport async function applyStackDns(\n\tplan: StackDnsPlan,\n\toptions: ApplyStackDnsOptions = {},\n): Promise<DnsChange[]> {\n\treturn (await settleStackDns(plan, options)).changes;\n}\n\n/**\n * Each domain's records, through its provider — and, with `confirm`, what was\n * written read back from it. A record already holding its value is neither\n * written nor read again.\n *\n * @throws {DnsRecordsNotConfirmed} when a written record does not read back\n */\nexport async function settleStackDns(\n\tplan: StackDnsPlan,\n\toptions: ApplyStackDnsOptions = {},\n): Promise<StackDnsApplied> {\n\tconst dryRun = options.dryRun === true;\n\tconst log = options.log ?? ((line: string) => console.log(line));\n\tconst providerFor = providerResolver(options);\n\n\tconst changes: DnsChange[] = [];\n\tconst confirmed = new Set<string>();\n\tconst unconfirmed = new Set<string>();\n\tconst hostsOf = (domain: DomainDnsPlan) =>\n\t\tnew Set(domain.records.map((r) => r.host));\n\tfor (const host of plan.uncovered) {\n\t\tlog(\n\t\t\t` ⚠ ${host} is under no domain in dns — point it at ${plan.server.ipv4} yourself`,\n\t\t);\n\t}\n\n\tfor (const domain of plan.domains) {\n\t\tif (domain.provider === 'manual') {\n\t\t\tchanges.push(...printManual(domain, log, 'manual'));\n\t\t\tfor (const host of hostsOf(domain)) unconfirmed.add(host);\n\t\t\tcontinue;\n\t\t}\n\t\tconst provider = await providerFor(domain.config);\n\t\tif (!provider) {\n\t\t\tchanges.push(...printManual(domain, log, 'manual'));\n\t\t\tfor (const host of hostsOf(domain)) unconfirmed.add(host);\n\t\t\tcontinue;\n\t\t}\n\n\t\tlog(` ${domain.domain} (${provider.name})${dryRun ? ' — dry run' : ''}`);\n\t\tlet existing: DnsRecord[];\n\t\tlet diff: DnsChange[];\n\t\tlet unreadable = false;\n\t\ttry {\n\t\t\texisting = await existingRecords(provider, domain);\n\t\t\tdiff = diffDomainDns(domain, existing);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof DnsRecordsUnreadable)) throw error;\n\t\t\tlog(\n\t\t\t\t` ℹ The ${provider.name} key cannot read ${domain.domain}'s DNS records, so changes cannot be diffed: every record is written (idempotent).`,\n\t\t\t);\n\t\t\tunreadable = true;\n\t\t\texisting = [];\n\t\t\tdiff = domain.records.map((r) => ({\n\t\t\t\tdomain: r.domain,\n\t\t\t\tname: r.name,\n\t\t\t\ttype: r.type,\n\t\t\t\taction: 'write' as const,\n\t\t\t\tvalue: r.value,\n\t\t\t\tttl: r.ttl,\n\t\t\t}));\n\t\t}\n\t\tfor (const change of diff) printChange(change, dryRun, log);\n\n\t\t// An AAAA nobody planned, at a name that points here: IPv6 clients —\n\t\t// Let's Encrypt among them — would go somewhere else.\n\t\tif (!plan.server.ipv6) {\n\t\t\tfor (const name of new Set(domain.records.map((r) => r.name))) {\n\t\t\t\tconst aaaa = existing.find((r) => r.name === name && r.type === 'AAAA');\n\t\t\t\tconst planned = domain.records.find(\n\t\t\t\t\t(r) => r.name === name && r.type === 'A',\n\t\t\t\t);\n\t\t\t\tif (aaaa && planned && aaaa.values.length > 0) {\n\t\t\t\t\tlog(\n\t\t\t\t\t\t` ⚠ ${fullName(domain.domain, name)} also has AAAA ${aaaa.values.join(', ')}: ` +\n\t\t\t\t\t\t\t`set ${SERVER_IPV6_KEY} in the '${plan.stage}' stage's secrets to the server's IPv6 address, ` +\n\t\t\t\t\t\t\t'or remove that record, or IPv6 clients go elsewhere',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tchanges.push(...diff);\n\n\t\t// A host every one of whose records was already right is confirmed by\n\t\t// the read that found it so; one with a write is confirmed by reading\n\t\t// it back — or, with a key that cannot read, by nobody.\n\t\tconst written = new Set(\n\t\t\tdiff\n\t\t\t\t.filter((c) => c.action !== 'unchanged')\n\t\t\t\t.map((c) => fullName(c.domain, c.name)),\n\t\t);\n\t\tfor (const host of hostsOf(domain)) {\n\t\t\t// A dry run writes nothing, so nothing it would write is resolved:\n\t\t\t// a name looked up before its record exists is cached as missing.\n\t\t\tif (unreadable) {\n\t\t\t\tif (!dryRun) unconfirmed.add(host);\n\t\t\t} else if (!written.has(host)) confirmed.add(host);\n\t\t}\n\t\tif (dryRun) continue;\n\n\t\tconst deletes = diff.filter((c) => c.action === 'delete');\n\t\tif (deletes.length > 0) {\n\t\t\tawait provider.deleteRecords(\n\t\t\t\tdomain.domain,\n\t\t\t\tdeletes.map((c) => ({ name: c.name, type: c.type })),\n\t\t\t);\n\t\t}\n\t\tconst writes = diff.filter(\n\t\t\t(c) =>\n\t\t\t\tc.action === 'create' || c.action === 'update' || c.action === 'write',\n\t\t);\n\t\tif (writes.length > 0) {\n\t\t\tawait provider.upsertRecords(\n\t\t\t\tdomain.domain,\n\t\t\t\twrites.map((c) => ({\n\t\t\t\t\tname: c.name,\n\t\t\t\t\ttype: c.type,\n\t\t\t\t\tvalue: c.value!,\n\t\t\t\t\tttl: c.ttl!,\n\t\t\t\t})),\n\t\t\t);\n\t\t}\n\n\t\tif (!options.confirm || unreadable || written.size === 0) continue;\n\t\tconst rewritten = {\n\t\t\t...domain,\n\t\t\trecords: domain.records.filter((r) => written.has(r.host)),\n\t\t};\n\t\tconst after = await existingRecords(provider, rewritten);\n\t\tconst missing: UnconfirmedRecord[] = [];\n\t\tfor (const record of rewritten.records) {\n\t\t\tconst found = after.find(\n\t\t\t\t(r) => r.name === record.name && r.type === record.type,\n\t\t\t);\n\t\t\tconst values = found?.values ?? [];\n\t\t\tif (values.length !== 1 || !same(values[0]!, record.value)) {\n\t\t\t\tmissing.push({\n\t\t\t\t\thost: record.host,\n\t\t\t\t\ttype: record.type,\n\t\t\t\t\texpected: record.value,\n\t\t\t\t\tfound: values,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (missing.length > 0) {\n\t\t\tthrow new DnsRecordsNotConfirmed(\n\t\t\t\tplan.stage,\n\t\t\t\tdomain.domain,\n\t\t\t\tprovider.name,\n\t\t\t\tmissing,\n\t\t\t);\n\t\t}\n\t\tfor (const host of written) confirmed.add(host);\n\t\tlog(\n\t\t\t` ✓ ${written.size} host${written.size === 1 ? '' : 's'} read back from ${provider.name}`,\n\t\t);\n\t}\n\tfor (const host of plan.uncovered) unconfirmed.add(host);\n\treturn {\n\t\tchanges,\n\t\tconfirmed: [...confirmed].sort(),\n\t\tunconfirmed: [...unconfirmed].filter((h) => !confirmed.has(h)).sort(),\n\t};\n}\n\n// ============================================================================\n// What gkm wrote before: the diff and the prune\n// ============================================================================\n\n/** A record gkm wrote for the stage, as its state keeps it. */\nexport type RecordedDnsRecord = DnsResourceRecord & { fqdn: string };\n\n/** The plan against the records the stage's state says gkm wrote. */\nexport interface RecordedDnsDiff {\n\t/** Planned, and never written by gkm for the stage. */\n\tadded: PlannedDnsRecord[];\n\t/** Planned, and written by gkm before — at this value or another. */\n\tkept: PlannedDnsRecord[];\n\t/** Written by gkm before, and no longer planned. */\n\tstale: RecordedDnsRecord[];\n}\n\n/** `api.example.com A` — a record's identity, whatever its value. */\nconst recordKey = (fqdn: string, type: string) =>\n\t`${fqdn.trim().replace(/\\.$/, '').toLowerCase()} ${type.toUpperCase()}`;\n\n/**\n * The plan against the records gkm wrote for the stage — pure. A record is\n * its full name and its type: one the plan has at another value is kept (the\n * apply updates it), and one whose name or type the plan no longer has is\n * stale — a host the stage stopped serving when its domain or an app changed,\n * or an AAAA once its server has no IPv6 address.\n */\nexport function diffRecordedDns(\n\tplan: StackDnsPlan,\n\trecorded: readonly RecordedDnsRecord[],\n): RecordedDnsDiff {\n\tconst planned = plan.domains.flatMap((domain) => domain.records);\n\tconst wanted = new Set(planned.map((r) => recordKey(r.host, r.type)));\n\tconst written = new Set(recorded.map((r) => recordKey(r.fqdn, r.type)));\n\treturn {\n\t\tadded: planned.filter((r) => !written.has(recordKey(r.host, r.type))),\n\t\tkept: planned.filter((r) => written.has(recordKey(r.host, r.type))),\n\t\tstale: recorded.filter((r) => !wanted.has(recordKey(r.fqdn, r.type))),\n\t};\n}\n\n/** What the prune did with one stale record — or, in a dry run, would. */\nexport interface PrunedDnsRecord {\n\trecord: RecordedDnsRecord;\n\t/**\n\t * - `delete`: it still held the value gkm wrote, and is deleted\n\t * - `gone`: the provider no longer has it\n\t * - `changed`: it was pointed elsewhere since, and is left as it is\n\t * - `manual`: no provider gkm can use deletes it — printed for a person\n\t *\n\t * Each is forgotten from the stage's state: none is gkm's any more.\n\t */\n\taction: 'delete' | 'gone' | 'changed' | 'manual';\n\t/** What the provider holds, for `changed`. */\n\tfound?: string[];\n}\n\nexport interface PruneStackDnsOptions\n\textends Pick<\n\t\tApplyStackDnsOptions,\n\t\t'dryRun' | 'log' | 'credentials' | 'hostinger' | 'providerFor'\n\t> {\n\tstage: string;\n\tdns: WorkspaceDnsConfig | undefined;\n}\n\n/**\n * Each stale record deleted through its domain's provider — only where the\n * provider still holds exactly the value gkm wrote, so a name someone has\n * since pointed elsewhere is never taken from them. Where no provider can\n * read and delete it — a `manual` domain, one gone from `dns`, a key that\n * can only write — it is printed for a person to remove. A dry run reads\n * and prints, and deletes nothing.\n */\nexport async function pruneStackDns(\n\tstale: readonly RecordedDnsRecord[],\n\toptions: PruneStackDnsOptions,\n): Promise<PrunedDnsRecord[]> {\n\tif (stale.length === 0) return [];\n\tconst dryRun = options.dryRun === true;\n\tconst log = options.log ?? ((line: string) => console.log(line));\n\tconst providerFor = providerResolver(options);\n\tconst dns = options.dns ? normalizeDnsConfig(options.dns) : {};\n\n\tconst byDomain = new Map<string, RecordedDnsRecord[]>();\n\tfor (const record of stale) {\n\t\tbyDomain.set(record.domain, [\n\t\t\t...(byDomain.get(record.domain) ?? []),\n\t\t\trecord,\n\t\t]);\n\t}\n\n\tlog(` No longer served by '${options.stage}':`);\n\tconst pruned: PrunedDnsRecord[] = [];\n\tconst byHand = (\n\t\tdomain: string,\n\t\trecords: RecordedDnsRecord[],\n\t\twhy: string,\n\t) => {\n\t\tlog(` ${domain}: ${why} — remove these records at its DNS host:`);\n\t\tfor (const record of records) {\n\t\t\tlog(\n\t\t\t\t` ${record.fqdn.padEnd(32)} ${record.type.padEnd(5)} ${record.value}`,\n\t\t\t);\n\t\t\tpruned.push({ record, action: 'manual' });\n\t\t}\n\t};\n\n\tfor (const [domain, records] of byDomain) {\n\t\tconst config = dns[domain];\n\t\tif (!config) {\n\t\t\tbyHand(domain, records, 'no longer in dns');\n\t\t\tcontinue;\n\t\t}\n\t\tconst provider =\n\t\t\tproviderName(config) === 'manual' ? null : await providerFor(config);\n\t\tif (!provider) {\n\t\t\tbyHand(domain, records, 'manual');\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet existing: DnsRecord[];\n\t\ttry {\n\t\t\texisting = await readRecords(\n\t\t\t\tprovider,\n\t\t\t\tdomain,\n\t\t\t\trecords.map((r) => ({ name: r.name, type: r.type as StackRecordType })),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof DnsRecordsUnreadable)) throw error;\n\t\t\tbyHand(\n\t\t\t\tdomain,\n\t\t\t\trecords,\n\t\t\t\t`the ${provider.name} key cannot read its records, so none is deleted unchecked`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst would = dryRun ? 'would ' : '';\n\t\tconst deletes: PrunedDnsRecord[] = [];\n\t\tfor (const record of records) {\n\t\t\tconst host = record.fqdn.padEnd(32);\n\t\t\tconst type = record.type.padEnd(5);\n\t\t\tconst found =\n\t\t\t\texisting.find((r) => r.name === record.name && r.type === record.type)\n\t\t\t\t\t?.values ?? [];\n\t\t\tif (found.length === 0) {\n\t\t\t\tlog(` · ${host} ${type} already gone`);\n\t\t\t\tpruned.push({ record, action: 'gone' });\n\t\t\t} else if (found.length === 1 && same(found[0]!, record.value)) {\n\t\t\t\tlog(` - ${host} ${type} ${record.value} — ${would}delete`);\n\t\t\t\tdeletes.push({ record, action: 'delete' });\n\t\t\t} else {\n\t\t\t\tlog(\n\t\t\t\t\t` ⚠ ${host} ${type} ${found.join(', ')} — pointed elsewhere since gkm wrote ${record.value}; left as it is`,\n\t\t\t\t);\n\t\t\t\tpruned.push({ record, action: 'changed', found });\n\t\t\t}\n\t\t}\n\t\tif (!dryRun && deletes.length > 0) {\n\t\t\tawait provider.deleteRecords(\n\t\t\t\tdomain,\n\t\t\t\tdeletes.map(({ record }) => ({\n\t\t\t\t\tname: record.name,\n\t\t\t\t\ttype: record.type as StackRecordType,\n\t\t\t\t})),\n\t\t\t);\n\t\t}\n\t\tpruned.push(...deletes);\n\t}\n\treturn pruned;\n}\n\n// ============================================================================\n// The check\n// ============================================================================\n\n/** Resolves a host to every address it has — `dns.promises.lookup`, `all`. */\nexport type HostLookup = (host: string) => Promise<string[]>;\n\n/** The system resolver: what the server's own clients would be told. */\nexport const systemLookup: HostLookup = async (host) => {\n\tconst found = await dnsLookup(host, { all: true });\n\treturn found.map((a) => a.address);\n};\n\n/** One host that does not resolve to the server. */\nexport interface MisdirectedHost {\n\thost: string;\n\t/** What it resolves to — empty when it does not resolve. */\n\tresolved: string[];\n\t/** Why it did not resolve, when it did not. */\n\terror?: string;\n}\n\n/** Hosts that do not resolve to the stage's server. */\nexport class HostNotPointingAtServer extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly hosts: readonly MisdirectedHost[],\n\t\treadonly expected: { ipv4: string; ipv6?: string },\n\t\t/** The records to create, where `dns` covers none of them. */\n\t\treadonly fix: string,\n\t) {\n\t\tconst want = expected.ipv6\n\t\t\t? `${expected.ipv4} (and ${expected.ipv6})`\n\t\t\t: expected.ipv4;\n\t\tconst lines = hosts.map(\n\t\t\t(h) =>\n\t\t\t\t` - ${h.host} → ${h.resolved.length > 0 ? h.resolved.join(', ') : `nothing${h.error ? ` (${h.error})` : ''}`}, expected ${want}`,\n\t\t);\n\t\tsuper(\n\t\t\t`${hosts.length === 1 ? 'A host' : `${hosts.length} hosts`} of '${stage}' ` +\n\t\t\t\t`do${hosts.length === 1 ? 'es' : ''} not resolve to its server, so a ` +\n\t\t\t\t`certificate for ${hosts.length === 1 ? 'it' : 'them'} cannot be issued:\\n` +\n\t\t\t\t`${lines.join('\\n')}\\n${fix}\\n` +\n\t\t\t\t'Records can take a few minutes to propagate. With a CDN or proxy in ' +\n\t\t\t\t'front of the server, pass --skip-dns.',\n\t\t);\n\t\tthis.name = 'HostNotPointingAtServer';\n\t}\n}\n\nexport interface CheckStackDnsInput {\n\tstage: string;\n\thosts: readonly string[];\n\tserver: ServerAddress;\n\tdns: WorkspaceDnsConfig | undefined;\n\tlookup?: HostLookup;\n}\n\n/**\n * Every host resolved: each must resolve to the server's IPv4 address and to\n * nothing but the server's addresses.\n *\n * @throws {HostNotPointingAtServer} naming every host that does not\n */\nexport async function checkStackDns(\n\tinput: CheckStackDnsInput,\n): Promise<string[]> {\n\tconst lookup = input.lookup ?? systemLookup;\n\tconst { server } = input;\n\tconst ours = new Set(\n\t\t[server.ipv4, server.ipv6].filter(Boolean).map((a) => a!.toLowerCase()),\n\t);\n\tconst bad: MisdirectedHost[] = [];\n\tconst ok: string[] = [];\n\tfor (const host of input.hosts) {\n\t\tlet resolved: string[];\n\t\ttry {\n\t\t\tresolved = [...new Set(await lookup(host))];\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\terror && typeof error === 'object' && 'code' in error\n\t\t\t\t\t? String((error as { code: unknown }).code)\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: String(error);\n\t\t\tbad.push({ host, resolved: [], error: code });\n\t\t\tcontinue;\n\t\t}\n\t\tconst pointsHere =\n\t\t\tresolved.some((a) => a.toLowerCase() === server.ipv4.toLowerCase()) &&\n\t\t\tresolved.every((a) => ours.has(a.toLowerCase()));\n\t\tif (pointsHere) ok.push(host);\n\t\telse bad.push({ host, resolved });\n\t}\n\n\tif (bad.length > 0) {\n\t\tthrow new HostNotPointingAtServer(\n\t\t\tinput.stage,\n\t\t\tbad,\n\t\t\t{ ipv4: server.ipv4, ...(server.ipv6 ? { ipv6: server.ipv6 } : {}) },\n\t\t\tdnsFix(input, bad),\n\t\t);\n\t}\n\treturn ok;\n}\n\n/** How to fix it: the deploy, or the records to create by hand. */\nfunction dnsFix(input: CheckStackDnsInput, bad: readonly MisdirectedHost[]) {\n\tconst hosts = bad.map((h) => h.host);\n\tlet plan: StackDnsPlan;\n\ttry {\n\t\tplan = planStackDns({\n\t\t\tstage: input.stage,\n\t\t\thosts,\n\t\t\tserver: input.server,\n\t\t\tdns: input.dns,\n\t\t});\n\t} catch {\n\t\tplan = {\n\t\t\tstage: input.stage,\n\t\t\tserver: input.server,\n\t\t\tdomains: [],\n\t\t\tuncovered: hosts,\n\t\t};\n\t}\n\tconst automatic = plan.domains.filter((d) => d.provider !== 'manual');\n\tconst byHand = [\n\t\t...plan.domains\n\t\t\t.filter((d) => d.provider === 'manual')\n\t\t\t.flatMap((d) => d.records.map(describe)),\n\t\t...plan.uncovered.flatMap((host) => [\n\t\t\t`${host.padEnd(32)} A ${input.server.ipv4}`,\n\t\t\t...(input.server.ipv6\n\t\t\t\t? [`${host.padEnd(32)} AAAA ${input.server.ipv6}`]\n\t\t\t\t: []),\n\t\t]),\n\t];\n\tconst lines: string[] = [];\n\tif (automatic.length > 0) {\n\t\tlines.push(\n\t\t\t`Fix: gkm deploy --stage ${input.stage} writes the records for ${automatic.map((d) => d.domain).join(', ')} through their provider (--dry-run shows them first).`,\n\t\t);\n\t}\n\tif (byHand.length > 0) {\n\t\tlines.push(\n\t\t\t`${automatic.length > 0 ? 'And create' : 'Fix: create'} these records at the DNS host:`,\n\t\t\t...byHand.map((line) => ` ${line}`),\n\t\t);\n\t}\n\treturn lines.join('\\n');\n}\n\n// ============================================================================\n// The step: plan, apply, confirm, check\n// ============================================================================\n\n/** The environment variable each token-authenticated provider reads. */\nexport const DNS_TOKEN_KEYS = {\n\tgodaddy: 'GODADDY_API_TOKEN',\n\thostinger: 'HOSTINGER_API_TOKEN',\n} as const;\n\n/** A provider whose credential is a token gkm reads. */\nexport type TokenDnsProvider = keyof typeof DNS_TOKEN_KEYS;\n\n/** The tokens a stage's records are written with. */\nexport interface DnsCredentials {\n\tgodaddy?: GoDaddyCredential;\n\thostinger?: HostingerCredential;\n}\n\n/**\n * A domain whose records the deploy writes, and no token to write them with.\n * Raised before anything is built, started or written.\n */\nexport class DnsCredentialMissing extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly domain: string,\n\t\treadonly provider: TokenDnsProvider,\n\t\t/** The variable the token is read from: `GODADDY_API_TOKEN`. */\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}''s hosts are under ${domain}, whose DNS is ${provider}'s, and ` +\n\t\t\t\t`the deploy writes their records — but ${key} is not set. In CI, add ` +\n\t\t\t\t`${key} as a secret on the '${stage}' GitHub environment and pass it ` +\n\t\t\t\t`to the step that writes the records: env: { ${key}: \\${{ secrets.${key} }} }. ` +\n\t\t\t\t`On this machine, export ${key} or run gkm login --provider ${provider}. ` +\n\t\t\t\t'With a CDN or proxy in front of the server, pass --skip-dns.',\n\t\t);\n\t\tthis.name = 'DnsCredentialMissing';\n\t}\n}\n\n/** One `dns` domain and its provider's config. */\nexport interface DnsDomain {\n\tdomain: string;\n\tconfig: DnsProviderConfig;\n}\n\n/**\n * The `dns` domain a stage's own domain (`domains.<stage>`) is under — where\n * its hosts' records go — or none.\n */\nexport function stageDnsDomains(\n\tstage: string,\n\tdomains: Readonly<Record<string, string>> | undefined,\n\tdns: WorkspaceDnsConfig | undefined,\n): DnsDomain[] {\n\tconst own = domains?.[stage];\n\tif (!own || !dns || isLocalHost(own)) return [];\n\tconst normalized = normalizeDnsConfig(dns);\n\tconst root = findRootDomain(own.toLowerCase(), normalized);\n\treturn root ? [{ domain: root, config: normalized[root]! }] : [];\n}\n\n/**\n * Each token the domains' providers need, from `credentials` — `manual`,\n * Route53 (the AWS SDK's own chain) and a provider object need none.\n *\n * @throws {DnsCredentialMissing} naming the first domain with no token\n */\nexport async function dnsCredentials(\n\tstage: string,\n\tdomains: readonly DnsDomain[],\n\tcredentials: CredentialProvider,\n): Promise<DnsCredentials> {\n\tconst found: DnsCredentials = {};\n\tfor (const { domain, config } of domains) {\n\t\tconst provider = config.provider;\n\t\tif (provider !== 'godaddy' && provider !== 'hostinger') continue;\n\t\tif (found[provider]) continue;\n\t\tconst token = await credentials.get({ kind: provider });\n\t\tif (!token?.token) {\n\t\t\tthrow new DnsCredentialMissing(\n\t\t\t\tstage,\n\t\t\t\tdomain,\n\t\t\t\tprovider,\n\t\t\t\tDNS_TOKEN_KEYS[provider],\n\t\t\t);\n\t\t}\n\t\tfound[provider] = token;\n\t}\n\treturn found;\n}\n\nexport interface StageDnsInput {\n\tstage: string;\n\t/** The stage's public hosts, read off its stack. */\n\thosts: readonly string[];\n\tserver: ServerAddress;\n\tdns: WorkspaceDnsConfig | undefined;\n\t/** Where the providers' tokens come from. */\n\tcredentials: CredentialProvider;\n\tdryRun?: boolean;\n\tlog?: (line: string) => void;\n\t/** Resolves the hosts no provider confirmed — the system resolver by default. */\n\tlookup?: HostLookup;\n\t/** The provider for a domain — `createDnsProvider` by default. */\n\tproviderFor?: (config: DnsProviderConfig) => Promise<DnsProvider | null>;\n\t/** GoDaddy's API, for tests: its base URL and how a 429 is waited out. */\n\tgodaddy?: Pick<GoDaddyProviderOptions, 'baseUrl' | 'sleep' | 'maxAttempts'>;\n\t/** The records the stage's state says gkm wrote: the stale ones are pruned. */\n\trecorded?: readonly RecordedDnsRecord[];\n}\n\nexport interface StageDnsResult {\n\tplan: StackDnsPlan;\n\tchanges: DnsChange[];\n\t/** Hosts whose records their provider holds with the server's address. */\n\tconfirmed: string[];\n\t/** Hosts the system resolver found pointing at the server. */\n\tresolved: string[];\n\t/** The plan against the records gkm wrote for the stage before. */\n\trecorded: RecordedDnsDiff;\n\t/**\n\t * The stale records pruned, through the providers this step used — called\n\t * once the stack serves its new hosts, so a run that stops short leaves\n\t * the old ones answering. In a dry run it reads and prints.\n\t */\n\tprune: () => Promise<PrunedDnsRecord[]>;\n}\n\n/**\n * A stage's DNS, as every deploy runs it: the\n * stage's own hosts planned, written through each domain's provider where\n * they differ, and read back from it — and each record gkm wrote for a host\n * the stage no longer serves found, for `prune` to delete. Only A, AAAA and CNAME records of those\n * names are touched; nothing is a wildcard, and no other name is read,\n * written or deleted. What no provider confirms — a `manual` domain, a host\n * under no domain in `dns`, a key that cannot read — is resolved publicly.\n * A dry run prints the plan and writes nothing.\n *\n * @throws {DnsCredentialMissing} before anything is read or written\n * @throws {DnsRecordsNotConfirmed} when a written record does not read back\n * @throws {HostNotPointingAtServer} when a resolved host is not the server\n */\nexport async function stageDns(input: StageDnsInput): Promise<StageDnsResult> {\n\tconst { stage, server } = input;\n\tconst log = input.log ?? ((line: string) => console.log(line));\n\tconst plan = planStackDns({\n\t\tstage,\n\t\thosts: input.hosts,\n\t\tserver,\n\t\tdns: input.dns,\n\t});\n\tconst recorded = diffRecordedDns(plan, input.recorded ?? []);\n\t// A stale record's domain needs its provider's token too — the stage's\n\t// old domain, after it moved to another.\n\tconst dns = input.dns ? normalizeDnsConfig(input.dns) : {};\n\tconst staleDomains = [...new Set(recorded.stale.map((r) => r.domain))]\n\t\t.filter(\n\t\t\t(domain) => dns[domain] && !plan.domains.some((d) => d.domain === domain),\n\t\t)\n\t\t.map((domain) => ({ domain, config: dns[domain]! }));\n\tconst tokens = await dnsCredentials(\n\t\tstage,\n\t\t[\n\t\t\t...plan.domains.map(({ domain, config }) => ({ domain, config })),\n\t\t\t...staleDomains,\n\t\t],\n\t\tinput.credentials,\n\t);\n\tconst providers = {\n\t\tlog,\n\t\tcredentials: {\n\t\t\t...(input.godaddy ?? {}),\n\t\t\t...(tokens.godaddy ? { credential: tokens.godaddy } : {}),\n\t\t\tlog,\n\t\t},\n\t\t...(tokens.hostinger ? { hostinger: tokens.hostinger } : {}),\n\t\t...(input.providerFor ? { providerFor: input.providerFor } : {}),\n\t};\n\t// No `dns` at all: nothing to write, and every host is the person's to\n\t// point — checked, without a line per host saying so.\n\tconst applied: StackDnsApplied = !input.dns\n\t\t? { changes: [], confirmed: [], unconfirmed: [...plan.uncovered] }\n\t\t: await settleStackDns(plan, {\n\t\t\t\t...(input.dryRun ? { dryRun: true } : { confirm: true }),\n\t\t\t\t...providers,\n\t\t\t});\n\n\t// A record the apply already deleted — a change of mode — is not pruned.\n\tconst deleted = new Set(\n\t\tapplied.changes\n\t\t\t.filter((c) => c.action === 'delete')\n\t\t\t.map((c) => recordKey(fullName(c.domain, c.name), c.type)),\n\t);\n\tconst stale = recorded.stale.filter(\n\t\t(r) => !deleted.has(recordKey(r.fqdn, r.type)),\n\t);\n\tconst prune = () =>\n\t\tpruneStackDns(stale, {\n\t\t\tstage,\n\t\t\tdns: input.dns,\n\t\t\t...(input.dryRun ? { dryRun: true } : {}),\n\t\t\t...providers,\n\t\t});\n\n\tlet resolved: string[] = [];\n\tif (applied.unconfirmed.length > 0) {\n\t\tresolved = await checkStackDns({\n\t\t\tstage,\n\t\t\thosts: applied.unconfirmed,\n\t\t\tserver,\n\t\t\tdns: input.dns,\n\t\t\t...(input.lookup ? { lookup: input.lookup } : {}),\n\t\t});\n\t}\n\treturn {\n\t\tplan,\n\t\tchanges: applied.changes,\n\t\tconfirmed: applied.confirmed,\n\t\tresolved,\n\t\trecorded,\n\t\tprune,\n\t};\n}\n","/**\n * The SNS subscriptions a deploy makes for the subscribers it pushes to, and\n * keeps: what both owners of them share.\n *\n * Against SNS itself a worker never subscribes — its credentials can only\n * confirm — so the deploy subscribes each pushed subscriber's route, records\n * the ARN in the stage's state, and hands the worker those ARNs as\n * `GKM_SNS_SUBSCRIPTIONS`. Two places make them: the `s3` provider, for a\n * bucket's subscribers (it created the topic), and the compose target, for a\n * topic whose connection string the stage set by hand. Both record them the\n * same way, so one confirmation pass and one read serve both.\n */\n\nimport type {\n\tHttpSubscriptionSpec,\n\tSNSConnection,\n} from '@geekmidas/events/sns';\nimport { GkmError } from '../errors';\nimport {\n\ttype AwsProvisioning,\n\tawsClientConfig,\n\tawsEndpoint,\n\tawsProvisioningCredentials,\n} from '../providers/aws.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport type { ResourceInput, ResourceRecord } from './StateStore.js';\n\n/** The type every recorded subscription has in the stage's state. */\nexport const SUBSCRIPTION_TYPE = 'sns-subscription';\n\n/** The state key a subscriber's SNS subscription is recorded under. */\nexport const subscriptionKey = (worker: string, name: string) =>\n\t`${SUBSCRIPTION_TYPE}:${worker}/${name}`;\n\n/** One subscription, as the deploy made it. */\nexport interface RecordedSubscription {\n\tworker: string;\n\t/** The subscriber's export. */\n\tname: string;\n\ttopicArn: string;\n\tendpoint: string;\n\tdeadLetterQueueArn?: string;\n\t/** The `type` filter of a topic subscriber; absent for a bucket's. */\n\tevents?: readonly string[];\n\t/**\n\t * The stage secret whose connection string the subscription was made\n\t * with — a topic set by hand, whose credentials are its own. Absent for a\n\t * bucket's, made with the deploy's provisioning credentials.\n\t */\n\tconnectionKey?: string;\n\t/** SNS still waits for the worker to confirm it. */\n\tpending: boolean;\n}\n\n/** What a recorded subscription is written to the stage's state as. */\nexport function subscriptionResource(\n\tsubscription: RecordedSubscription,\n\tarn: string,\n): ResourceInput {\n\tconst { name, ...data } = subscription;\n\treturn {\n\t\tkey: subscriptionKey(subscription.worker, name),\n\t\ttype: SUBSCRIPTION_TYPE,\n\t\tid: arn,\n\t\tstatus: 'ready',\n\t\tdata: { ...data, ...(data.events ? { events: [...data.events] } : {}) },\n\t};\n}\n\n/** The subscription a record holds, as an endpoint to reconcile. */\nfunction specOf(record: ResourceRecord): HttpSubscriptionSpec {\n\tconst events = record.data?.events;\n\treturn {\n\t\tname: record.key.split('/').pop()!,\n\t\tendpoint: String(record.data?.endpoint),\n\t\t...(record.data?.deadLetterQueueArn\n\t\t\t? { deadLetterQueueArn: String(record.data.deadLetterQueueArn) }\n\t\t\t: {}),\n\t\t...(Array.isArray(events) ? { events: events.map(String) } : {}),\n\t};\n}\n\n/**\n * The subscriptions the deploy recorded, by worker and export — what each\n * worker is handed as `GKM_SNS_SUBSCRIPTIONS`.\n */\nexport function recordedPushSubscriptions(\n\tresources: Readonly<Record<string, ResourceRecord>> | undefined,\n): Record<string, Record<string, string>> {\n\tconst byWorker: Record<string, Record<string, string>> = {};\n\tfor (const record of Object.values(resources ?? {})) {\n\t\tif (record.type !== SUBSCRIPTION_TYPE || !record.id) continue;\n\t\tconst [worker, name] = record.key\n\t\t\t.slice(`${SUBSCRIPTION_TYPE}:`.length)\n\t\t\t.split('/');\n\t\tif (!worker || !name) continue;\n\t\tbyWorker[worker] = { ...byWorker[worker], [name]: record.id };\n\t}\n\treturn byWorker;\n}\n\n/** A topic connection string the deploy cannot sign with. */\nexport class TopicSubscriptionUnsigned extends GkmError {\n\tconstructor(readonly connectionKey: string) {\n\t\tsuper(\n\t\t\t`'${connectionKey}' carries no keys, and the deploy found no AWS ` +\n\t\t\t\t`credentials of its own to subscribe the worker's routes with. Put ` +\n\t\t\t\t`accessKeyId and secretAccessKey in it — keys allowed ` +\n\t\t\t\t`sns:Subscribe, sns:ListSubscriptionsByTopic, ` +\n\t\t\t\t`sns:GetSubscriptionAttributes, sns:SetSubscriptionAttributes and ` +\n\t\t\t\t`sns:Unsubscribe on the topic — or sign in with \\`gkm login\\`.`,\n\t\t);\n\t\tthis.name = 'TopicSubscriptionUnsigned';\n\t}\n}\n\n/**\n * A connection to the topic a stage's connection string names, signed with\n * its own keys — or, carrying none, the deploy's.\n *\n * The emulator the environment points the SDK at stands in for SNS, as it\n * does for every provider: a string with no `endpoint` is SNS itself.\n *\n * @throws {TopicSubscriptionUnsigned} with no keys from either\n */\nexport async function topicConnection(input: {\n\tconnectionKey: string;\n\tconnectionString: string;\n\tstage: string;\n\tenv: NodeJS.ProcessEnv;\n\thome?: string;\n}): Promise<SNSConnection> {\n\tconst { SNSConnection, snsUrl } = await import('@geekmidas/events/sns');\n\tconst { topicArn, region, endpoint } = snsUrl.parse(input.connectionString);\n\tconst params = new URL(input.connectionString).searchParams;\n\tconst accessKeyId = params.get('accessKeyId');\n\tconst secretAccessKey = params.get('secretAccessKey');\n\t// The topic's own region, read off its ARN where the string names none.\n\tconst where = region ?? topicArn.split(':')[3];\n\n\tlet credentials: SNSConnectionCredentials | undefined;\n\tif (accessKeyId && secretAccessKey) {\n\t\tconst sessionToken = params.get('sessionToken');\n\t\tcredentials = {\n\t\t\taccessKeyId,\n\t\t\tsecretAccessKey,\n\t\t\t...(sessionToken ? { sessionToken } : {}),\n\t\t};\n\t} else {\n\t\tconst provisioning = await awsProvisioningCredentials({\n\t\t\tstage: input.stage,\n\t\t\tenv: input.env,\n\t\t\t...(input.home ? { home: input.home } : {}),\n\t\t});\n\t\tif (!provisioning) throw new TopicSubscriptionUnsigned(input.connectionKey);\n\t\tcredentials = (await awsClientConfig(provisioning, where ?? 'us-east-1'))\n\t\t\t.credentials;\n\t}\n\n\tconst override = endpoint ?? awsEndpoint(input.env, 'SNS');\n\treturn new SNSConnection({\n\t\ttopicArn,\n\t\t...(where ? { region: where } : {}),\n\t\t...(override ? { endpoint: override } : {}),\n\t\t...(credentials ? { credentials } : {}),\n\t});\n}\n\ntype SNSConnectionCredentials = NonNullable<\n\tConstructorParameters<typeof SNSConnection>[0]['credentials']\n>;\n\n/** A subscription still waiting to be confirmed once its worker is up. */\nexport class PushSubscriptionsUnconfirmed extends GkmError {\n\tconstructor(readonly endpoints: readonly string[]) {\n\t\tsuper(\n\t\t\t`SNS still waits for ${endpoints.join(', ')} to confirm ${endpoints.length === 1 ? 'its subscription' : 'their subscriptions'}, ` +\n\t\t\t\t`so nothing is pushed there yet. Check the worker's logs for the ` +\n\t\t\t\t`confirmation it refused, and that its host answers from the internet; ` +\n\t\t\t\t`the next deploy sends the confirmation again.`,\n\t\t);\n\t\tthis.name = 'PushSubscriptionsUnconfirmed';\n\t}\n}\n\n/**\n * Once the workers are up: every subscription recorded as pending is\n * subscribed again — SNS resends its confirmation to a worker now there to\n * answer it — and waited on until confirmed.\n *\n * The first deploy needs it: the subscription is made before the worker\n * starts, so SNS's first confirmation finds nobody.\n *\n * A bucket's subscriptions are reached with the deploy's provisioning\n * credentials; a hand-set topic's with the connection string they were made\n * with, read from the stage's secrets.\n *\n * @returns what is still pending when the wait ran out — none, normally.\n */\nexport async function confirmPendingSubscriptions(input: {\n\tworkspace: NormalizedWorkspace;\n\tstage: string;\n\tresources: Readonly<Record<string, ResourceRecord>> | undefined;\n\t/** The stage's secrets — a hand-set topic's connection string. */\n\tsecrets?: Readonly<Record<string, string>>;\n\tenv?: NodeJS.ProcessEnv;\n\thome?: string;\n\t/** How long to wait for confirmations, in milliseconds. */\n\ttimeoutMs?: number;\n\trecord?: (record: ResourceRecord) => Promise<void>;\n\tlog?: (line: string) => void;\n}): Promise<string[]> {\n\tconst env = input.env ?? process.env;\n\tconst records = Object.values(input.resources ?? {}).filter(\n\t\t(r) => r.type === SUBSCRIPTION_TYPE && r.id,\n\t);\n\tif (!records.some((r) => r.data?.pending === true)) return [];\n\n\tconst { SNSConnection, reconcileHttpSubscriptions } = await import(\n\t\t'@geekmidas/events/sns'\n\t);\n\tconst { GetSubscriptionAttributesCommand } = await import(\n\t\t'@aws-sdk/client-sns'\n\t);\n\tconst endpoint = awsEndpoint(env, 'SNS');\n\tlet provisioning: AwsProvisioning | undefined | null = null;\n\n\t// Every subscription to the same topic on the same host, not only the\n\t// pending ones: the reconcile removes what it is not handed.\n\tconst groups = new Map<string, ResourceRecord[]>();\n\tfor (const record of records) {\n\t\tconst host = new URL(String(record.data?.endpoint)).host;\n\t\tconst group = `${record.data?.topicArn}|${host}`;\n\t\tgroups.set(group, [...(groups.get(group) ?? []), record]);\n\t}\n\n\tconst left: string[] = [];\n\tfor (const [group, members] of groups) {\n\t\tconst pending = members.filter((r) => r.data?.pending === true);\n\t\tif (pending.length === 0) continue;\n\t\tconst [topicArn, host] = group.split('|') as [string, string];\n\t\tconst unreachable = () =>\n\t\t\tleft.push(...pending.map((r) => String(r.data?.endpoint)));\n\n\t\tlet connection: SNSConnection;\n\t\tconst connectionKey = members[0]!.data?.connectionKey;\n\t\tif (typeof connectionKey === 'string') {\n\t\t\tconst connectionString = input.secrets?.[connectionKey];\n\t\t\tif (!connectionString?.startsWith('sns:')) {\n\t\t\t\tunreachable();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconnection = await topicConnection({\n\t\t\t\tconnectionKey,\n\t\t\t\tconnectionString,\n\t\t\t\tstage: input.stage,\n\t\t\t\tenv,\n\t\t\t\t...(input.home ? { home: input.home } : {}),\n\t\t\t});\n\t\t} else {\n\t\t\tif (provisioning === null) {\n\t\t\t\tprovisioning = await awsProvisioningCredentials({\n\t\t\t\t\tstage: input.stage,\n\t\t\t\t\tenv,\n\t\t\t\t\t...(input.home ? { home: input.home } : {}),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!provisioning) {\n\t\t\t\tunreachable();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// The topic's own region, read off its ARN: a bucket may be elsewhere.\n\t\t\tconst region = topicArn.split(':')[3]!;\n\t\t\tconst { credentials } = await awsClientConfig(provisioning, region);\n\t\t\tconnection = new SNSConnection({\n\t\t\t\ttopicArn,\n\t\t\t\tregion,\n\t\t\t\t...(endpoint ? { endpoint } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t});\n\t\t}\n\n\t\tawait reconcileHttpSubscriptions(connection, {\n\t\t\tendpoints: members.map(specOf),\n\t\t\townedHost: host,\n\t\t});\n\n\t\tconst deadline = Date.now() + (input.timeoutMs ?? 60_000);\n\t\tfor (const record of pending) {\n\t\t\tlet confirmed = false;\n\t\t\twhile (!confirmed) {\n\t\t\t\tconst { Attributes = {} } = await connection.snsClient.send(\n\t\t\t\t\tnew GetSubscriptionAttributesCommand({\n\t\t\t\t\t\tSubscriptionArn: record.id!,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tconfirmed = Attributes.PendingConfirmation !== 'true';\n\t\t\t\tif (confirmed || Date.now() > deadline) break;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t\t\t}\n\t\t\tif (confirmed) {\n\t\t\t\tinput.log?.(` ✓ ${record.data?.endpoint} confirmed its subscription`);\n\t\t\t\tawait input.record?.({\n\t\t\t\t\t...record,\n\t\t\t\t\tdata: { ...record.data, pending: false },\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tleft.push(String(record.data?.endpoint));\n\t\t\t}\n\t\t}\n\t\tawait connection.close();\n\t}\n\treturn left;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,WAAyC;CAC3E,OACC,UAAU,QAAQ,YAAY,aAC9B,OAAO,OAAO,UAAU,IAAI,CAAC,CAAC,MAC5B,QAAQ,IAAI,yBAAyB,SACvC;AAEF;;;;;;;;;;;;;;;;;;;;;;;AC0BA,SAAgB,aAAa,UAAsC;CAClE,OAAO,OAAO,OAAO,QAAQ,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,UAAU;AACjE;;;;;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