@geekmidas/cli 10.0.0-alpha.167 → 10.0.0-alpha.168
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-DxrRqfJ3.cjs → EndpointGenerator-C1h_wExz.cjs} +2 -2
- package/dist/{EndpointGenerator-DxrRqfJ3.cjs.map → EndpointGenerator-C1h_wExz.cjs.map} +1 -1
- package/dist/{EndpointGenerator-B5BKAoLz.mjs → EndpointGenerator-CSKhAD6W.mjs} +2 -2
- package/dist/{EndpointGenerator-B5BKAoLz.mjs.map → EndpointGenerator-CSKhAD6W.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-Dci0SlN5.mjs → GoDaddyProvider-CJIYlkUN.mjs} +2 -2
- package/dist/{GoDaddyProvider-Dci0SlN5.mjs.map → GoDaddyProvider-CJIYlkUN.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-o6DJAsBZ.cjs → GoDaddyProvider-CYAlIeML.cjs} +2 -2
- package/dist/{GoDaddyProvider-o6DJAsBZ.cjs.map → GoDaddyProvider-CYAlIeML.cjs.map} +1 -1
- package/dist/{HostingerProvider-BzHPhONW.cjs → HostingerProvider-Ceqc_nlG.cjs} +2 -2
- package/dist/{HostingerProvider-BzHPhONW.cjs.map → HostingerProvider-Ceqc_nlG.cjs.map} +1 -1
- package/dist/{HostingerProvider-Dd5x1zvF.mjs → HostingerProvider-Tb0bnTpM.mjs} +2 -2
- package/dist/{HostingerProvider-Dd5x1zvF.mjs.map → HostingerProvider-Tb0bnTpM.mjs.map} +1 -1
- package/dist/{LegacyStateStore-tqY0hM8z.cjs → LegacyStateStore-Ci-CRqt2.cjs} +2 -2
- package/dist/{LegacyStateStore-tqY0hM8z.cjs.map → LegacyStateStore-Ci-CRqt2.cjs.map} +1 -1
- package/dist/{LegacyStateStore-CpF6rmZc.mjs → LegacyStateStore-DJWY64Jj.mjs} +2 -2
- package/dist/{LegacyStateStore-CpF6rmZc.mjs.map → LegacyStateStore-DJWY64Jj.mjs.map} +1 -1
- package/dist/{LocalStateStore-Adp96xPy.mjs → LocalStateStore-BFgjv29N.mjs} +2 -2
- package/dist/{LocalStateStore-Adp96xPy.mjs.map → LocalStateStore-BFgjv29N.mjs.map} +1 -1
- package/dist/{LocalStateStore-BYMUEGZN.cjs → LocalStateStore-Enw_wV7d.cjs} +2 -2
- package/dist/{LocalStateStore-BYMUEGZN.cjs.map → LocalStateStore-Enw_wV7d.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-Vaf0pI8u.mjs → OpenApiTsGenerator-5xPn-p65.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-Vaf0pI8u.mjs.map → OpenApiTsGenerator-5xPn-p65.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-DOTLKBFf.cjs → OpenApiTsGenerator-CzrLGzC0.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-DOTLKBFf.cjs.map → OpenApiTsGenerator-CzrLGzC0.cjs.map} +1 -1
- package/dist/{S3StateStore-DjXyhGIP.cjs → S3StateStore-B48M3z7L.cjs} +4 -4
- package/dist/{S3StateStore-DjXyhGIP.cjs.map → S3StateStore-B48M3z7L.cjs.map} +1 -1
- package/dist/{S3StateStore-13Go3hfM.mjs → S3StateStore-Cwfd-ZnJ.mjs} +4 -4
- package/dist/{S3StateStore-13Go3hfM.mjs.map → S3StateStore-Cwfd-ZnJ.mjs.map} +1 -1
- package/dist/{SSMStateStore-DspMPho-.cjs → SSMStateStore-CuBe-NK5.cjs} +2 -2
- package/dist/{SSMStateStore-DspMPho-.cjs.map → SSMStateStore-CuBe-NK5.cjs.map} +1 -1
- package/dist/{SSMStateStore-CQHUyH-c.mjs → SSMStateStore-DYgE98Sm.mjs} +2 -2
- package/dist/{SSMStateStore-CQHUyH-c.mjs.map → SSMStateStore-DYgE98Sm.mjs.map} +1 -1
- package/dist/{SubscriberGenerator-BybB6uez.mjs → SubscriberGenerator-CfZWX0lT.mjs} +6 -6
- package/dist/SubscriberGenerator-CfZWX0lT.mjs.map +1 -0
- package/dist/{SubscriberGenerator-mZpSuSU7.cjs → SubscriberGenerator-DMi4siph.cjs} +5 -5
- package/dist/SubscriberGenerator-DMi4siph.cjs.map +1 -0
- package/dist/{add-DsxJ0Knr.cjs → add-4AT0LlDK.cjs} +10 -10
- package/dist/add-4AT0LlDK.cjs.map +1 -0
- package/dist/{add-Dt8QKSOw.mjs → add-C85tazt0.mjs} +11 -11
- package/dist/add-C85tazt0.mjs.map +1 -0
- package/dist/{apps-C6s-trVp.cjs → apps-By6pnfzA.cjs} +40 -40
- package/dist/apps-By6pnfzA.cjs.map +1 -0
- package/dist/{apps-w2sRQKCr.mjs → apps-CWGmV2nQ.mjs} +41 -41
- package/dist/apps-CWGmV2nQ.mjs.map +1 -0
- package/dist/{bundler-BCWWne6N.mjs → bundler-B9rkNGpK.mjs} +6 -6
- package/dist/{bundler-BCWWne6N.mjs.map → bundler-B9rkNGpK.mjs.map} +1 -1
- package/dist/{bundler-AzkSRAuu.cjs → bundler-DPBLrtjT.cjs} +6 -6
- package/dist/{bundler-AzkSRAuu.cjs.map → bundler-DPBLrtjT.cjs.map} +1 -1
- package/dist/{cli-OGss08bZ.cjs → cli-BnWRqhwx.cjs} +4 -4
- package/dist/{cli-OGss08bZ.cjs.map → cli-BnWRqhwx.cjs.map} +1 -1
- package/dist/{cli-DSGw0Mw-.mjs → cli-DgL0QED8.mjs} +4 -4
- package/dist/{cli-DSGw0Mw-.mjs.map → cli-DgL0QED8.mjs.map} +1 -1
- package/dist/{compose-QSBmhr4V.cjs → compose-CLM-sqgE.cjs} +11 -11
- package/dist/compose-CLM-sqgE.cjs.map +1 -0
- package/dist/{compose-Csegtvq_.mjs → compose-CcK-QoYU.mjs} +12 -12
- package/dist/compose-CcK-QoYU.mjs.map +1 -0
- package/dist/{compose-RhuFQmZS.mjs → compose-DuRBnjxx.mjs} +9 -9
- package/dist/compose-DuRBnjxx.mjs.map +1 -0
- package/dist/{compose-BqTuzitb.cjs → compose-DwjaxFFK.cjs} +8 -8
- package/dist/compose-DwjaxFFK.cjs.map +1 -0
- package/dist/config.cjs +2 -2
- package/dist/config.mjs +2 -2
- package/dist/{credentialSchemas-mz9QZTYh.mjs → credentialSchemas-BzJiK1nQ.mjs} +4 -4
- package/dist/credentialSchemas-BzJiK1nQ.mjs.map +1 -0
- package/dist/{credentialSchemas-BAklWDna.cjs → credentialSchemas-OVXofU-r.cjs} +3 -3
- package/dist/credentialSchemas-OVXofU-r.cjs.map +1 -0
- package/dist/{credentials-CORvhcrO.cjs → credentials-CCCAy3NL.cjs} +7 -7
- package/dist/{credentials-CORvhcrO.cjs.map → credentials-CCCAy3NL.cjs.map} +1 -1
- package/dist/{credentials-D4DUPPPP.mjs → credentials-CeCOEKP3.mjs} +7 -7
- package/dist/{credentials-D4DUPPPP.mjs.map → credentials-CeCOEKP3.mjs.map} +1 -1
- package/dist/{databases-CrKh5jw6.cjs → databases-CuTL1e7s.cjs} +3 -3
- package/dist/databases-CuTL1e7s.cjs.map +1 -0
- package/dist/{databases-C1qqNxTu.mjs → databases-zN-gEox0.mjs} +4 -4
- package/dist/databases-zN-gEox0.mjs.map +1 -0
- package/dist/deploy/public.cjs +12 -12
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +12 -12
- package/dist/{deploy-BwJ7uWXd.cjs → deploy-Dy5jyciI.cjs} +36 -36
- package/dist/deploy-Dy5jyciI.cjs.map +1 -0
- package/dist/{deploy-DDfnQm8l.mjs → deploy-F6GA-u59.mjs} +37 -37
- package/dist/deploy-F6GA-u59.mjs.map +1 -0
- package/dist/{destroy-nTNRfdy6.cjs → destroy-B7-8EgCJ.cjs} +9 -9
- package/dist/{destroy-nTNRfdy6.cjs.map → destroy-B7-8EgCJ.cjs.map} +1 -1
- package/dist/{destroy-DKt8S051.mjs → destroy-Gyxrl5yO.mjs} +9 -9
- package/dist/{destroy-DKt8S051.mjs.map → destroy-Gyxrl5yO.mjs.map} +1 -1
- package/dist/{discover-CRywE7yc.cjs → discover-39VKSE2i.cjs} +5 -5
- package/dist/discover-39VKSE2i.cjs.map +1 -0
- package/dist/{discover-DbDrCQ8h.mjs → discover-B_PDDaVj.mjs} +6 -6
- package/dist/discover-B_PDDaVj.mjs.map +1 -0
- package/dist/{docker-Ele34O8z.mjs → docker-COHyyOkv.mjs} +11 -11
- package/dist/docker-COHyyOkv.mjs.map +1 -0
- package/dist/{docker-Dy1ZJUzV.cjs → docker-CP4bspkW.cjs} +10 -10
- package/dist/docker-CP4bspkW.cjs.map +1 -0
- package/dist/{dokploy-DN2W1YIH.cjs → dokploy-C7ampvzk.cjs} +2 -2
- package/dist/{dokploy-DN2W1YIH.cjs.map → dokploy-C7ampvzk.cjs.map} +1 -1
- package/dist/{dokploy-BrfA2m5K.mjs → dokploy-DBmB9vWu.mjs} +2 -2
- package/dist/{dokploy-BrfA2m5K.mjs.map → dokploy-DBmB9vWu.mjs.map} +1 -1
- package/dist/{eas-BRBdxmwe.cjs → eas-CbnTdz8d.cjs} +3 -3
- package/dist/{eas-BRBdxmwe.cjs.map → eas-CbnTdz8d.cjs.map} +1 -1
- package/dist/{eas-CO3ogve5.mjs → eas-EXRkhGSM.mjs} +3 -3
- package/dist/{eas-CO3ogve5.mjs.map → eas-EXRkhGSM.mjs.map} +1 -1
- package/dist/{encryption-BZ1zgtF5.cjs → encryption-CdDDSAu_.cjs} +4 -4
- package/dist/encryption-CdDDSAu_.cjs.map +1 -0
- package/dist/{encryption-CHmfNBAy.mjs → encryption-lLZV2eMs.mjs} +5 -5
- package/dist/encryption-lLZV2eMs.mjs.map +1 -0
- package/dist/{engine-DewbDHOq.cjs → engine-Cg92m1Xf.cjs} +37 -37
- package/dist/engine-Cg92m1Xf.cjs.map +1 -0
- package/dist/{engine-B3Gmu8-O.mjs → engine-ZzUy2czq.mjs} +38 -38
- package/dist/engine-ZzUy2czq.mjs.map +1 -0
- package/dist/{github-DPNgIxdc.cjs → github-BHqRcUgU.cjs} +8 -8
- package/dist/{github-DPNgIxdc.cjs.map → github-BHqRcUgU.cjs.map} +1 -1
- package/dist/{github-DU3iEmJN.mjs → github-CPpJmNgV.mjs} +8 -8
- package/dist/{github-DU3iEmJN.mjs.map → github-CPpJmNgV.mjs.map} +1 -1
- package/dist/{googlePlay-C2jnPqYn.cjs → googlePlay-DRz0ya3q.cjs} +4 -4
- package/dist/{googlePlay-C2jnPqYn.cjs.map → googlePlay-DRz0ya3q.cjs.map} +1 -1
- package/dist/{googlePlay-KPHn9H2f.mjs → googlePlay-Dg-0ASWN.mjs} +4 -4
- package/dist/{googlePlay-KPHn9H2f.mjs.map → googlePlay-Dg-0ASWN.mjs.map} +1 -1
- package/dist/{iam-CW61VcT3.mjs → iam-CLIne3Ny.mjs} +2 -2
- package/dist/{iam-CW61VcT3.mjs.map → iam-CLIne3Ny.mjs.map} +1 -1
- package/dist/{iam-C2sf6AUi.cjs → iam-b4IvC1fm.cjs} +2 -2
- package/dist/{iam-C2sf6AUi.cjs.map → iam-b4IvC1fm.cjs.map} +1 -1
- package/dist/index.cjs +79 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +80 -80
- package/dist/index.mjs.map +1 -1
- package/dist/{local-BxjA0EXj.cjs → local-BIrl0ENw.cjs} +3 -3
- package/dist/{local-BxjA0EXj.cjs.map → local-BIrl0ENw.cjs.map} +1 -1
- package/dist/{local-CwR2DW6i.mjs → local-Cin6exc0.mjs} +3 -3
- package/dist/{local-CwR2DW6i.mjs.map → local-Cin6exc0.mjs.map} +1 -1
- package/dist/{migrate-B0a3WY4X.cjs → migrate-BtkwylxW.cjs} +7 -7
- package/dist/{migrate-B0a3WY4X.cjs.map → migrate-BtkwylxW.cjs.map} +1 -1
- package/dist/{migrate-CYtM1UBH.cjs → migrate-CxI07Ey0.cjs} +3 -3
- package/dist/{migrate-CYtM1UBH.cjs.map → migrate-CxI07Ey0.cjs.map} +1 -1
- package/dist/{migrate-vWy2CUoi.mjs → migrate-DEU8I8sQ.mjs} +7 -7
- package/dist/{migrate-vWy2CUoi.mjs.map → migrate-DEU8I8sQ.mjs.map} +1 -1
- package/dist/{migrate-DHWy64pc.mjs → migrate-DpLMJLCw.mjs} +3 -3
- package/dist/{migrate-DHWy64pc.mjs.map → migrate-DpLMJLCw.mjs.map} +1 -1
- package/dist/{notes-9bOfe08J.mjs → notes-or_kXTal.mjs} +11 -11
- package/dist/notes-or_kXTal.mjs.map +1 -0
- package/dist/{notes-DRdlsCYV.cjs → notes-rTfi6rfN.cjs} +10 -10
- package/dist/notes-rTfi6rfN.cjs.map +1 -0
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.mjs +3 -3
- package/dist/{projectBucket-gIQUuhGm.cjs → projectBucket-CRa1b1Td.cjs} +2 -2
- package/dist/{projectBucket-gIQUuhGm.cjs.map → projectBucket-CRa1b1Td.cjs.map} +1 -1
- package/dist/{projectBucket-Cd7sEDhG.mjs → projectBucket-Coh5K3-g.mjs} +2 -2
- package/dist/{projectBucket-Cd7sEDhG.mjs.map → projectBucket-Coh5K3-g.mjs.map} +1 -1
- package/dist/{publish-DOxz4mxf.mjs → publish-Bwhywmpz.mjs} +2 -2
- package/dist/{publish-DOxz4mxf.mjs.map → publish-Bwhywmpz.mjs.map} +1 -1
- package/dist/{publish-BgDFx08y.cjs → publish-D9Yl4AzW.cjs} +2 -2
- package/dist/{publish-BgDFx08y.cjs.map → publish-D9Yl4AzW.cjs.map} +1 -1
- package/dist/{ready-BjFMu_1J.mjs → ready-COJHr1Yi.mjs} +9 -9
- package/dist/ready-COJHr1Yi.mjs.map +1 -0
- package/dist/{ready-eVMJIcWn.cjs → ready-DcD0SCnV.cjs} +8 -8
- package/dist/ready-DcD0SCnV.cjs.map +1 -0
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-CdDyPOE8.mjs → resolve-B9tboVm2.mjs} +4 -4
- package/dist/{resolve-CdDyPOE8.mjs.map → resolve-B9tboVm2.mjs.map} +1 -1
- package/dist/{resolve-BhQd4IkT.cjs → resolve-BrJUFIUu.cjs} +4 -4
- package/dist/{resolve-BhQd4IkT.cjs.map → resolve-BrJUFIUu.cjs.map} +1 -1
- package/dist/{rollback-Brc-_HBJ.cjs → rollback-D48bPMpD.cjs} +7 -7
- package/dist/{rollback-Brc-_HBJ.cjs.map → rollback-D48bPMpD.cjs.map} +1 -1
- package/dist/{rollback-CLBKeSMl.mjs → rollback-M6b0z1tp.mjs} +7 -7
- package/dist/{rollback-CLBKeSMl.mjs.map → rollback-M6b0z1tp.mjs.map} +1 -1
- package/dist/{s3-CuLmr6Q9.cjs → s3-3iS3jlKU.cjs} +3 -3
- package/dist/{s3-CuLmr6Q9.cjs.map → s3-3iS3jlKU.cjs.map} +1 -1
- package/dist/{s3-D0BIG_ml.mjs → s3-CNOSRjqH.mjs} +3 -3
- package/dist/{s3-D0BIG_ml.mjs.map → s3-CNOSRjqH.mjs.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 +2 -2
- package/dist/sandbox/migrate-worker.mjs +2 -2
- package/dist/{serverSetup-An1fE9nd.mjs → serverSetup-CzLJ_RV0.mjs} +6 -6
- package/dist/{serverSetup-An1fE9nd.mjs.map → serverSetup-CzLJ_RV0.mjs.map} +1 -1
- package/dist/{serverSetup-BMpzrB1y.cjs → serverSetup-DnOdoucM.cjs} +6 -6
- package/dist/{serverSetup-BMpzrB1y.cjs.map → serverSetup-DnOdoucM.cjs.map} +1 -1
- package/dist/{sniffer-9a8wQeeD.cjs → sniffer-C5F7uYQB.cjs} +8 -8
- package/dist/{sniffer-9a8wQeeD.cjs.map → sniffer-C5F7uYQB.cjs.map} +1 -1
- package/dist/{sniffer-BObBXR5q.mjs → sniffer-yeftYpWK.mjs} +8 -8
- package/dist/{sniffer-BObBXR5q.mjs.map → sniffer-yeftYpWK.mjs.map} +1 -1
- package/dist/{snsSubscriptions-oUTOkG-s.mjs → snsSubscriptions-CXRa_bwG.mjs} +3 -3
- package/dist/{snsSubscriptions-oUTOkG-s.mjs.map → snsSubscriptions-CXRa_bwG.mjs.map} +1 -1
- package/dist/{snsSubscriptions-BRmEdsks.cjs → snsSubscriptions-CXwELBil.cjs} +3 -3
- package/dist/{snsSubscriptions-BRmEdsks.cjs.map → snsSubscriptions-CXwELBil.cjs.map} +1 -1
- package/dist/{sst-DVIeKWCH.mjs → sst-BAQrBaGa.mjs} +6 -6
- package/dist/{sst-DVIeKWCH.mjs.map → sst-BAQrBaGa.mjs.map} +1 -1
- package/dist/{sst-CJQI9GYW.cjs → sst-B_srWo15.cjs} +6 -6
- package/dist/{sst-CJQI9GYW.cjs.map → sst-B_srWo15.cjs.map} +1 -1
- package/dist/{stack-2jMvQfLo.cjs → stack-DaJ9D2Uc.cjs} +20 -20
- package/dist/stack-DaJ9D2Uc.cjs.map +1 -0
- package/dist/{stack-kcxH-2tZ.mjs → stack-t2tN1jYo.mjs} +21 -21
- package/dist/stack-t2tN1jYo.mjs.map +1 -0
- package/dist/{stage-BQSSMJL4.mjs → stage-B4gqRg7l.mjs} +7 -7
- package/dist/{stage-BQSSMJL4.mjs.map → stage-B4gqRg7l.mjs.map} +1 -1
- package/dist/{stage-AHgVG7H8.cjs → stage-Clk6oQO_.cjs} +7 -7
- package/dist/{stage-AHgVG7H8.cjs.map → stage-Clk6oQO_.cjs.map} +1 -1
- package/dist/{stages-BsK1Ro4s.mjs → stages-D1rnfO18.mjs} +2 -2
- package/dist/{stages-BsK1Ro4s.mjs.map → stages-D1rnfO18.mjs.map} +1 -1
- package/dist/{stages-DpF2K3PZ.cjs → stages-afi9P-Cd.cjs} +2 -2
- package/dist/{stages-DpF2K3PZ.cjs.map → stages-afi9P-Cd.cjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-DWROY7JE.mjs → terminal-D4kY5oz7.mjs} +3 -3
- package/dist/{terminal-DWROY7JE.mjs.map → terminal-D4kY5oz7.mjs.map} +1 -1
- package/dist/{terminal-BNjNr7BN.cjs → terminal-JAudEZRC.cjs} +3 -3
- package/dist/{terminal-BNjNr7BN.cjs.map → terminal-JAudEZRC.cjs.map} +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-9q4TSHlM.mjs → workspace-Gubg8xLJ.mjs} +3 -3
- package/dist/workspace-Gubg8xLJ.mjs.map +1 -0
- package/dist/{workspace-Ciw3SnME.cjs → workspace-p7gmCQVS.cjs} +2 -2
- package/dist/workspace-p7gmCQVS.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/SubscriberGenerator-BybB6uez.mjs.map +0 -1
- package/dist/SubscriberGenerator-mZpSuSU7.cjs.map +0 -1
- package/dist/add-DsxJ0Knr.cjs.map +0 -1
- package/dist/add-Dt8QKSOw.mjs.map +0 -1
- package/dist/apps-C6s-trVp.cjs.map +0 -1
- package/dist/apps-w2sRQKCr.mjs.map +0 -1
- package/dist/compose-BqTuzitb.cjs.map +0 -1
- package/dist/compose-Csegtvq_.mjs.map +0 -1
- package/dist/compose-QSBmhr4V.cjs.map +0 -1
- package/dist/compose-RhuFQmZS.mjs.map +0 -1
- package/dist/credentialSchemas-BAklWDna.cjs.map +0 -1
- package/dist/credentialSchemas-mz9QZTYh.mjs.map +0 -1
- package/dist/databases-C1qqNxTu.mjs.map +0 -1
- package/dist/databases-CrKh5jw6.cjs.map +0 -1
- package/dist/deploy-BwJ7uWXd.cjs.map +0 -1
- package/dist/deploy-DDfnQm8l.mjs.map +0 -1
- package/dist/discover-CRywE7yc.cjs.map +0 -1
- package/dist/discover-DbDrCQ8h.mjs.map +0 -1
- package/dist/docker-Dy1ZJUzV.cjs.map +0 -1
- package/dist/docker-Ele34O8z.mjs.map +0 -1
- package/dist/encryption-BZ1zgtF5.cjs.map +0 -1
- package/dist/encryption-CHmfNBAy.mjs.map +0 -1
- package/dist/engine-B3Gmu8-O.mjs.map +0 -1
- package/dist/engine-DewbDHOq.cjs.map +0 -1
- package/dist/notes-9bOfe08J.mjs.map +0 -1
- package/dist/notes-DRdlsCYV.cjs.map +0 -1
- package/dist/ready-BjFMu_1J.mjs.map +0 -1
- package/dist/ready-eVMJIcWn.cjs.map +0 -1
- package/dist/stack-2jMvQfLo.cjs.map +0 -1
- package/dist/stack-kcxH-2tZ.mjs.map +0 -1
- package/dist/workspace-9q4TSHlM.mjs.map +0 -1
- package/dist/workspace-Ciw3SnME.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy-DKt8S051.mjs","names":[],"sources":["../src/providers/s3/destroy.ts","../src/compose/destroy.ts"],"sourcesContent":["/**\n * What `gkm compose --destroy` deletes in the stage's AWS account: each\n * resource a deploy recorded in the stage's state, and only once it is\n * proven gkm's own for this stage.\n *\n * A record alone proves nothing — a deploy records what it found and adopted\n * exactly as what it made (a certificate for the host, a bucket with no\n * tags). So each is checked against what gkm marks its own with: the\n * `gkm:project` and `gkm:stage` tags on a bucket, a user, a certificate, a\n * distribution, a topic or a queue; the stage's own name on an origin access\n * control and a headers policy, which take no tags. What fails the check is\n * left where it is, and said so.\n *\n * Nothing here runs on its own: `planAwsDestroy` reads, and returns a step\n * per resource whose `remove()` the command calls — after the person typed\n * the stage's name — in the order AWS needs: a distribution disabled and\n * gone before its certificate, a user's keys and policies before the user,\n * a bucket emptied before it is deleted.\n */\n\nimport type { ResourceRecord } from '../../deploy/StateStore.js';\nimport { GkmError } from '../../errors.js';\nimport { type AwsProvisioning, awsClientConfig, awsEndpoint } from '../aws.js';\nimport { TAG_PROJECT, TAG_STAGE } from '../iam.js';\nimport { type CdnClients, cdnName, defaultCdnClients } from './cdn.js';\nimport { defaultClients } from './index.js';\nimport { IAM_USER_PATH } from './naming.js';\n\n/** What a destroy step is about, as the person reads it. */\nexport interface AwsDestroyStep {\n\t/** The state record it is kept as: forgotten once it is gone. */\n\tkey: string;\n\tlabel: string;\n\t/** Why it is not deleted. Absent for one that will be. */\n\tleftAlone?: string;\n\t/** Already gone from the account: only its record is forgotten. */\n\tgone?: boolean;\n\t/** Deleted along with its user's step: only its record is forgotten here. */\n\twithUser?: boolean;\n\t/** Deletes it. Absent when it is left alone or already gone. */\n\tremove?: () => Promise<void>;\n}\n\n/** A DNS record a resource here needs, worked out from the resource. */\nexport interface AwsDnsRecord {\n\thost: string;\n\ttype: 'CNAME';\n\tvalue: string;\n}\n\nexport interface AwsDestroyPlan {\n\t/** In the order they are removed. */\n\tsteps: AwsDestroyStep[];\n\t/**\n\t * The records the s3 provider wrote for what it deletes — a CDN's name, a\n\t * certificate's validation — which no state record names.\n\t */\n\tdns: AwsDnsRecord[];\n}\n\nexport interface AwsDestroyInput {\n\tresources: Record<string, ResourceRecord>;\n\t/** `deployIdentity(…).key` — what `gkm:project` holds. */\n\tidentityKey: string;\n\t/** `deployIdentity(…).scope` — what CDN resource names start with. */\n\tscope: string;\n\tstage: string;\n\tcredential: AwsProvisioning;\n\t/** How long a disabled distribution is waited on, and how often asked. */\n\twait?: { timeoutMs: number; intervalMs: number };\n\t/** For tests: where the clients come from. */\n\tclients?: {\n\t\ts3?: typeof defaultClients;\n\t\tcdn?: (credential: AwsProvisioning) => Promise<CdnClients>;\n\t};\n}\n\n/** The record types this plans. Every other is the command's to report. */\nexport const AWS_RESOURCE_TYPES = [\n\t'cloudfront-distribution',\n\t'cloudfront-oac',\n\t'cloudfront-headers',\n\t'acm-certificate',\n\t'sns-subscription',\n\t'sns-topic',\n\t'sqs-queue',\n\t'iam-access-key',\n\t'iam-user',\n\t's3-bucket',\n] as const;\n\n/** A distribution disabled before it is deleted can take this long. */\nconst DISABLE_WAIT = { timeoutMs: 45 * 60_000, intervalMs: 20_000 };\n\n/** A disabled distribution that never finished deploying. */\nexport class DistributionStillDeploying extends GkmError {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly waitedMs: number,\n\t) {\n\t\tsuper(\n\t\t\t`CloudFront distribution ${id} was disabled, and is still deploying after ` +\n\t\t\t\t`${Math.round(waitedMs / 60_000)} minutes. CloudFront deletes only a ` +\n\t\t\t\t'disabled distribution that has finished deploying. Run the destroy ' +\n\t\t\t\t'again later: everything deleted so far is forgotten, and it carries ' +\n\t\t\t\t'on from here.',\n\t\t);\n\t\tthis.name = 'DistributionStillDeploying';\n\t}\n}\n\n/** What an AWS SDK error is called, whichever field carries it. */\nfunction errorName(error: unknown): string {\n\tconst e = error as { name?: string; Code?: string };\n\treturn e?.Code ?? e?.name ?? '';\n}\n\n/** A read whose \"there is none\" answer is one of `missing`. */\nasync function readOr<T>(\n\tread: () => Promise<T>,\n\tmissing: readonly string[],\n): Promise<T | undefined> {\n\ttry {\n\t\treturn await read();\n\t} catch (error) {\n\t\tif (missing.includes(errorName(error))) return undefined;\n\t\tthrow error;\n\t}\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n/** Whether a tag list says gkm made it for this project's stage. */\nfunction ours(\n\ttags: readonly { Key?: string; Value?: string }[] | undefined,\n\tinput: Pick<AwsDestroyInput, 'identityKey' | 'stage'>,\n): boolean {\n\tconst of = (key: string) => tags?.find((t) => t.Key === key)?.Value;\n\treturn of(TAG_PROJECT) === input.identityKey && of(TAG_STAGE) === input.stage;\n}\n\nconst NOT_TAGGED =\n\t\"not tagged as this stage's (gkm:project, gkm:stage): gkm found it, it did not make it\";\n\n/** The id after the type in a record's key: `cloudfront-oac:Uploads` → `Uploads`. */\nfunction keyId(record: ResourceRecord): string {\n\treturn record.key.slice(record.key.indexOf(':') + 1);\n}\n\n/** The file server a CDN record is for: `cloudfront-headers:Uploads:cors` → `Uploads`. */\nfunction serverOf(record: ResourceRecord): string {\n\treturn keyId(record).split(':')[0] ?? '';\n}\n\n/**\n * Each AWS resource the stage's state records, checked, in the order it is\n * deleted — and the DNS records the deleted ones were given.\n */\nexport async function planAwsDestroy(\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyPlan> {\n\tconst steps: AwsDestroyStep[] = [];\n\tconst dns: AwsDnsRecord[] = [];\n\tconst records = Object.values(input.resources);\n\tconst of = (type: string) => records.filter((r) => r.type === type);\n\tconst wait = input.wait ?? DISABLE_WAIT;\n\n\tconst cdnRecords = [\n\t\t...of('cloudfront-distribution'),\n\t\t...of('cloudfront-oac'),\n\t\t...of('cloudfront-headers'),\n\t\t...of('acm-certificate'),\n\t];\n\tif (cdnRecords.length > 0) {\n\t\tconst cdn = await (input.clients?.cdn ?? defaultCdnClients)(\n\t\t\tinput.credential,\n\t\t);\n\t\t// A distribution left alone keeps what it uses: deleting its origin\n\t\t// access control, a headers policy or its certificate would break it.\n\t\tconst kept = new Map<string, string>();\n\t\tfor (const record of of('cloudfront-distribution')) {\n\t\t\tconst step = await distributionStep(cdn, record, input, wait, dns);\n\t\t\tif (step.leftAlone) kept.set(serverOf(record), step.label);\n\t\t\tsteps.push(step);\n\t\t}\n\t\tconst usedBy = async (\n\t\t\trecord: ResourceRecord,\n\t\t\tstep: () => Promise<AwsDestroyStep>,\n\t\t): Promise<AwsDestroyStep> => {\n\t\t\tconst holder = kept.get(serverOf(record));\n\t\t\tif (!holder) return step();\n\t\t\tconst label = (await step()).label;\n\t\t\treturn {\n\t\t\t\tkey: record.key,\n\t\t\t\tlabel,\n\t\t\t\tleftAlone: `used by ${holder}, which is left alone`,\n\t\t\t};\n\t\t};\n\t\tfor (const record of of('cloudfront-oac')) {\n\t\t\tsteps.push(\n\t\t\t\tawait usedBy(record, () => originAccessControlStep(cdn, record, input)),\n\t\t\t);\n\t\t}\n\t\tfor (const record of of('cloudfront-headers')) {\n\t\t\tsteps.push(\n\t\t\t\tawait usedBy(record, () => headersPolicyStep(cdn, record, input)),\n\t\t\t);\n\t\t}\n\t\tfor (const record of of('acm-certificate')) {\n\t\t\t// Its validation record goes only with the certificate itself.\n\t\t\tconst found: AwsDnsRecord[] = [];\n\t\t\tconst step = await usedBy(record, () =>\n\t\t\t\tcertificateStep(cdn, record, input, found),\n\t\t\t);\n\t\t\tif (!step.leftAlone) dns.push(...found);\n\t\t\tsteps.push(step);\n\t\t}\n\t}\n\n\tconst eventRecords = [\n\t\t...of('sns-subscription'),\n\t\t...of('sns-topic'),\n\t\t...of('sqs-queue'),\n\t];\n\tif (eventRecords.length > 0) {\n\t\tconst events = await eventClients(input.credential, records);\n\t\tfor (const record of of('sns-subscription')) {\n\t\t\tsteps.push(subscriptionStep(events, record));\n\t\t}\n\t\tfor (const record of of('sns-topic')) {\n\t\t\tsteps.push(await topicStep(events, record, input));\n\t\t}\n\t\tfor (const record of of('sqs-queue')) {\n\t\t\tsteps.push(await queueStep(events, record, input));\n\t\t}\n\t}\n\n\tconst users = of('iam-user');\n\tconst keys = of('iam-access-key');\n\tconst buckets = of('s3-bucket');\n\tif (users.length + keys.length + buckets.length > 0) {\n\t\tconst global = await (input.clients?.s3 ?? defaultClients)(\n\t\t\tinput.credential,\n\t\t\tregionOf(buckets[0]) ?? 'us-east-1',\n\t\t);\n\t\tconst userSteps = new Map<string, AwsDestroyStep>();\n\t\tfor (const record of users) {\n\t\t\tconst step = await userStep(global, record, input);\n\t\t\tuserSteps.set(record.id ?? '', step);\n\t\t\tsteps.push(step);\n\t\t}\n\t\t// A key goes with its user, and is checked through it.\n\t\tfor (const record of keys) {\n\t\t\tconst user = (record.data as { user?: string } | undefined)?.user;\n\t\t\tconst owner = user ? userSteps.get(user) : undefined;\n\t\t\tsteps.push({\n\t\t\t\tkey: record.key,\n\t\t\t\tlabel: `IAM access key ${record.id ?? ''} of ${user ?? 'an unknown user'}`,\n\t\t\t\t...(owner?.leftAlone\n\t\t\t\t\t? { leftAlone: `its user is left alone: ${owner.leftAlone}` }\n\t\t\t\t\t: owner\n\t\t\t\t\t\t? { withUser: true }\n\t\t\t\t\t\t: { leftAlone: 'its user is not one this stage recorded' }),\n\t\t\t});\n\t\t}\n\t\tfor (const record of buckets) {\n\t\t\tconst region = regionOf(record) ?? global.region;\n\t\t\tconst clients =\n\t\t\t\tregion === global.region\n\t\t\t\t\t? global\n\t\t\t\t\t: await (input.clients?.s3 ?? defaultClients)(\n\t\t\t\t\t\t\tinput.credential,\n\t\t\t\t\t\t\tregion,\n\t\t\t\t\t\t);\n\t\t\tsteps.push(await bucketStep(clients, record, input));\n\t\t}\n\t}\n\n\treturn { steps, dns };\n}\n\nfunction regionOf(record: ResourceRecord | undefined): string | undefined {\n\treturn (record?.data as { region?: string } | undefined)?.region;\n}\n\n// ---------------------------------------------------------------------------\n// CloudFront and ACM\n// ---------------------------------------------------------------------------\n\nasync function distributionStep(\n\t{ CF, cloudfront }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n\twait: { timeoutMs: number; intervalMs: number },\n\tdns: AwsDnsRecord[],\n): Promise<AwsDestroyStep> {\n\tconst id = record.id ?? '';\n\tconst found = await readOr(\n\t\t() => cloudfront.send(new CF.GetDistributionCommand({ Id: id })),\n\t\t['NoSuchDistribution'],\n\t);\n\tconst distribution = found?.Distribution;\n\tconst aliases = distribution?.DistributionConfig?.Aliases?.Items ?? [];\n\tconst label = `CloudFront distribution ${id}${aliases.length ? ` (${aliases.join(', ')})` : ''}`;\n\tif (!distribution) return { key: record.key, label, gone: true };\n\n\t// Its tags, or the comment gkm writes on every distribution it makes —\n\t// `gkm <project> <stage> <file server>`, which nothing else writes.\n\tconst tags = await cloudfront.send(\n\t\tnew CF.ListTagsForResourceCommand({ Resource: distribution.ARN }),\n\t);\n\tconst comment = `gkm ${input.identityKey} ${input.stage} ${serverOf(record)}`;\n\tconst marked =\n\t\tdistribution.DistributionConfig?.Comment === comment.slice(0, 128);\n\tif (!ours(tags.Tags?.Items, input) && !marked) {\n\t\treturn {\n\t\t\tkey: record.key,\n\t\t\tlabel,\n\t\t\tleftAlone: `${NOT_TAGGED}, and its comment is not \"${comment}\"`,\n\t\t};\n\t}\n\tfor (const host of aliases) {\n\t\tdns.push({ host, type: 'CNAME', value: distribution.DomainName ?? '' });\n\t}\n\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tlet current = await cloudfront.send(\n\t\t\t\tnew CF.GetDistributionConfigCommand({ Id: id }),\n\t\t\t);\n\t\t\tif (current.DistributionConfig?.Enabled) {\n\t\t\t\tawait cloudfront.send(\n\t\t\t\t\tnew CF.UpdateDistributionCommand({\n\t\t\t\t\t\tId: id,\n\t\t\t\t\t\tIfMatch: current.ETag,\n\t\t\t\t\t\tDistributionConfig: {\n\t\t\t\t\t\t\t...current.DistributionConfig,\n\t\t\t\t\t\t\tEnabled: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst started = Date.now();\n\t\t\tfor (;;) {\n\t\t\t\tconst state = await cloudfront.send(\n\t\t\t\t\tnew CF.GetDistributionCommand({ Id: id }),\n\t\t\t\t);\n\t\t\t\tif (state.Distribution?.Status === 'Deployed') break;\n\t\t\t\tif (Date.now() - started > wait.timeoutMs) {\n\t\t\t\t\tthrow new DistributionStillDeploying(id, Date.now() - started);\n\t\t\t\t}\n\t\t\t\tawait sleep(wait.intervalMs);\n\t\t\t}\n\t\t\tcurrent = await cloudfront.send(\n\t\t\t\tnew CF.GetDistributionConfigCommand({ Id: id }),\n\t\t\t);\n\t\t\tawait cloudfront.send(\n\t\t\t\tnew CF.DeleteDistributionCommand({ Id: id, IfMatch: current.ETag }),\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function originAccessControlStep(\n\t{ CF, cloudfront }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst id = record.id ?? '';\n\tconst expected = cdnName(input.scope, input.stage, keyId(record));\n\tconst label = `CloudFront origin access control ${expected}`;\n\tconst found = await readOr(\n\t\t() => cloudfront.send(new CF.GetOriginAccessControlCommand({ Id: id })),\n\t\t['NoSuchOriginAccessControl'],\n\t);\n\tif (!found) return { key: record.key, label, gone: true };\n\tconst name = found.OriginAccessControl?.OriginAccessControlConfig?.Name;\n\tif (name !== expected) {\n\t\treturn {\n\t\t\tkey: record.key,\n\t\t\tlabel,\n\t\t\tleftAlone: `named ${name}, not this stage's ${expected}`,\n\t\t};\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst { ETag } = await cloudfront.send(\n\t\t\t\tnew CF.GetOriginAccessControlCommand({ Id: id }),\n\t\t\t);\n\t\t\tawait cloudfront.send(\n\t\t\t\tnew CF.DeleteOriginAccessControlCommand({ Id: id, IfMatch: ETag }),\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function headersPolicyStep(\n\t{ CF, cloudfront }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst id = record.id ?? '';\n\t// `cloudfront-headers:<server>:<kind>`\n\tconst [server = '', kind = ''] = keyId(record).split(':');\n\tconst expected = `${cdnName(input.scope, input.stage, server)}-${kind}`;\n\tconst label = `CloudFront response headers policy ${expected}`;\n\tconst found = await readOr(\n\t\t() =>\n\t\t\tcloudfront.send(new CF.GetResponseHeadersPolicyConfigCommand({ Id: id })),\n\t\t['NoSuchResponseHeadersPolicy'],\n\t);\n\tif (!found) return { key: record.key, label, gone: true };\n\tconst name = found.ResponseHeadersPolicyConfig?.Name;\n\tif (name !== expected) {\n\t\treturn {\n\t\t\tkey: record.key,\n\t\t\tlabel,\n\t\t\tleftAlone: `named ${name}, not this stage's ${expected}`,\n\t\t};\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst { ETag } = await cloudfront.send(\n\t\t\t\tnew CF.GetResponseHeadersPolicyConfigCommand({ Id: id }),\n\t\t\t);\n\t\t\tawait cloudfront.send(\n\t\t\t\tnew CF.DeleteResponseHeadersPolicyCommand({ Id: id, IfMatch: ETag }),\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function certificateStep(\n\t{ ACM, acm }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n\tdns: AwsDnsRecord[],\n): Promise<AwsDestroyStep> {\n\tconst arn = record.id ?? '';\n\tconst host = (record.data as { host?: string } | undefined)?.host ?? arn;\n\tconst label = `ACM certificate ${host} (us-east-1)`;\n\tconst found = await readOr(\n\t\t() => acm.send(new ACM.DescribeCertificateCommand({ CertificateArn: arn })),\n\t\t['ResourceNotFoundException'],\n\t);\n\tif (!found?.Certificate) return { key: record.key, label, gone: true };\n\tconst tags = await acm.send(\n\t\tnew ACM.ListTagsForCertificateCommand({ CertificateArn: arn }),\n\t);\n\tif (!ours(tags.Tags, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\tfor (const option of found.Certificate.DomainValidationOptions ?? []) {\n\t\tconst r = option.ResourceRecord;\n\t\tif (r?.Name && r.Value && r.Type === 'CNAME') {\n\t\t\tdns.push({ host: r.Name, type: 'CNAME', value: r.Value });\n\t\t}\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tawait acm.send(new ACM.DeleteCertificateCommand({ CertificateArn: arn }));\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// SNS and SQS\n// ---------------------------------------------------------------------------\n\ninterface EventClients {\n\tSNS: typeof import('@aws-sdk/client-sns');\n\tSQS: typeof import('@aws-sdk/client-sqs');\n\tsns: (\n\t\tregion: string,\n\t) => Promise<InstanceType<typeof import('@aws-sdk/client-sns')['SNSClient']>>;\n\tsqs: (\n\t\tregion: string,\n\t) => Promise<InstanceType<typeof import('@aws-sdk/client-sqs')['SQSClient']>>;\n}\n\nasync function eventClients(\n\tcredential: AwsProvisioning,\n\t_records: readonly ResourceRecord[],\n): Promise<EventClients> {\n\tconst SNS = await import('@aws-sdk/client-sns');\n\tconst SQS = await import('@aws-sdk/client-sqs');\n\tconst sns = new Map<string, InstanceType<typeof SNS.SNSClient>>();\n\tconst sqs = new Map<string, InstanceType<typeof SQS.SQSClient>>();\n\treturn {\n\t\tSNS,\n\t\tSQS,\n\t\tsns: async (region) => {\n\t\t\tif (!sns.has(region)) {\n\t\t\t\tconst endpoint = awsEndpoint(process.env, 'SNS');\n\t\t\t\tsns.set(\n\t\t\t\t\tregion,\n\t\t\t\t\tnew SNS.SNSClient({\n\t\t\t\t\t\t...(await awsClientConfig(credential, region)),\n\t\t\t\t\t\t...(endpoint ? { endpoint } : {}),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn sns.get(region)!;\n\t\t},\n\t\tsqs: async (region) => {\n\t\t\tif (!sqs.has(region)) {\n\t\t\t\tconst endpoint = awsEndpoint(process.env, 'SQS');\n\t\t\t\tsqs.set(\n\t\t\t\t\tregion,\n\t\t\t\t\tnew SQS.SQSClient({\n\t\t\t\t\t\t...(await awsClientConfig(credential, region)),\n\t\t\t\t\t\t...(endpoint ? { endpoint } : {}),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn sqs.get(region)!;\n\t\t},\n\t};\n}\n\n/** `arn:aws:sns:<region>:<account>:<name>` */\nfunction arnParts(arn: string) {\n\tconst [, , , region = '', account = '', ...rest] = arn.split(':');\n\treturn { region, account, name: rest.join(':') };\n}\n\nfunction subscriptionStep(\n\t{ SNS, sns }: EventClients,\n\trecord: ResourceRecord,\n): AwsDestroyStep {\n\tconst arn = record.id ?? '';\n\tconst label = `SNS subscription ${keyId(record)}`;\n\t// Made by gkm, to its own push endpoint: a pending one has no ARN yet.\n\tif (!arn.startsWith('arn:')) return { key: record.key, label, gone: true };\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst client = await sns(arnParts(arn).region);\n\t\t\tawait readOr(\n\t\t\t\t() => client.send(new SNS.UnsubscribeCommand({ SubscriptionArn: arn })),\n\t\t\t\t['NotFound', 'NotFoundException'],\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function topicStep(\n\t{ SNS, sns }: EventClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst arn = record.id ?? '';\n\tconst label = `SNS topic ${arnParts(arn).name}`;\n\tconst client = await sns(arnParts(arn).region);\n\tconst tags = await readOr(\n\t\t() => client.send(new SNS.ListTagsForResourceCommand({ ResourceArn: arn })),\n\t\t[\n\t\t\t'NotFound',\n\t\t\t'NotFoundException',\n\t\t\t'ResourceNotFound',\n\t\t\t'ResourceNotFoundException',\n\t\t],\n\t);\n\tif (!tags) return { key: record.key, label, gone: true };\n\tif (!ours(tags.Tags, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tawait client.send(new SNS.DeleteTopicCommand({ TopicArn: arn }));\n\t\t},\n\t};\n}\n\nasync function queueStep(\n\t{ SQS, sqs }: EventClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst arn = record.id ?? '';\n\tconst { region, account, name } = arnParts(arn);\n\tconst label = `SQS queue ${name}`;\n\tconst client = await sqs(region);\n\tconst url = await readOr(\n\t\t() =>\n\t\t\tclient.send(\n\t\t\t\tnew SQS.GetQueueUrlCommand({\n\t\t\t\t\tQueueName: name,\n\t\t\t\t\tQueueOwnerAWSAccountId: account,\n\t\t\t\t}),\n\t\t\t),\n\t\t['QueueDoesNotExist', 'AWS.SimpleQueueService.NonExistentQueue'],\n\t);\n\tif (!url?.QueueUrl) return { key: record.key, label, gone: true };\n\tconst queueUrl = url.QueueUrl;\n\tconst tags = await client.send(\n\t\tnew SQS.ListQueueTagsCommand({ QueueUrl: queueUrl }),\n\t);\n\tconst list = Object.entries(tags.Tags ?? {}).map(([Key, Value]) => ({\n\t\tKey,\n\t\tValue,\n\t}));\n\tif (!ours(list, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tawait client.send(new SQS.DeleteQueueCommand({ QueueUrl: queueUrl }));\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// IAM and S3\n// ---------------------------------------------------------------------------\n\ntype S3Clients = Awaited<ReturnType<typeof defaultClients>>;\n\nasync function userStep(\n\t{ IAM, iam }: S3Clients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst name = record.id ?? '';\n\tconst label = `IAM user ${name}, its access keys and policies`;\n\tconst found = await readOr(\n\t\t() => iam.send(new IAM.GetUserCommand({ UserName: name })),\n\t\t['NoSuchEntity', 'NoSuchEntityException'],\n\t);\n\tif (!found?.User) return { key: record.key, label, gone: true };\n\tconst tags = await iam.send(new IAM.ListUserTagsCommand({ UserName: name }));\n\tif (found.User.Path !== IAM_USER_PATH || !ours(tags.Tags, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst keys = await iam.send(\n\t\t\t\tnew IAM.ListAccessKeysCommand({ UserName: name }),\n\t\t\t);\n\t\t\tfor (const key of keys.AccessKeyMetadata ?? []) {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.DeleteAccessKeyCommand({\n\t\t\t\t\t\tUserName: name,\n\t\t\t\t\t\tAccessKeyId: key.AccessKeyId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst inline = await iam.send(\n\t\t\t\tnew IAM.ListUserPoliciesCommand({ UserName: name }),\n\t\t\t);\n\t\t\tfor (const policy of inline.PolicyNames ?? []) {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.DeleteUserPolicyCommand({\n\t\t\t\t\t\tUserName: name,\n\t\t\t\t\t\tPolicyName: policy,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst attached = await iam.send(\n\t\t\t\tnew IAM.ListAttachedUserPoliciesCommand({ UserName: name }),\n\t\t\t);\n\t\t\tfor (const policy of attached.AttachedPolicies ?? []) {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.DetachUserPolicyCommand({\n\t\t\t\t\t\tUserName: name,\n\t\t\t\t\t\tPolicyArn: policy.PolicyArn,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait iam.send(new IAM.DeleteUserCommand({ UserName: name }));\n\t\t},\n\t};\n}\n\n/** Every object version and delete marker in a bucket, a page at a time. */\nasync function* bucketVersions({ S3, s3 }: S3Clients, bucket: string) {\n\tlet KeyMarker: string | undefined;\n\tlet VersionIdMarker: string | undefined;\n\tfor (;;) {\n\t\tconst page = await s3.send(\n\t\t\tnew S3.ListObjectVersionsCommand({\n\t\t\t\tBucket: bucket,\n\t\t\t\t...(KeyMarker ? { KeyMarker } : {}),\n\t\t\t\t...(VersionIdMarker ? { VersionIdMarker } : {}),\n\t\t\t}),\n\t\t);\n\t\tconst objects = [...(page.Versions ?? []), ...(page.DeleteMarkers ?? [])]\n\t\t\t.filter((o) => o.Key)\n\t\t\t.map((o) => ({\n\t\t\t\tKey: o.Key!,\n\t\t\t\t// `null` is the one version an unversioned bucket's object has:\n\t\t\t\t// named or not, the same object is deleted.\n\t\t\t\t...(o.VersionId && o.VersionId !== 'null'\n\t\t\t\t\t? { VersionId: o.VersionId }\n\t\t\t\t\t: {}),\n\t\t\t}));\n\t\tif (objects.length > 0) yield objects;\n\t\tif (!page.IsTruncated) return;\n\t\tKeyMarker = page.NextKeyMarker;\n\t\tVersionIdMarker = page.NextVersionIdMarker;\n\t}\n}\n\nasync function bucketStep(\n\tclients: S3Clients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst { S3, s3 } = clients;\n\tconst bucket = record.id ?? '';\n\tconst tagging = await readOr(\n\t\t() => s3.send(new S3.GetBucketTaggingCommand({ Bucket: bucket })),\n\t\t['NoSuchBucket', 'NoSuchTagSet', 'NoSuchTagSetError'],\n\t);\n\tconst exists = await readOr(\n\t\t() => s3.send(new S3.HeadBucketCommand({ Bucket: bucket })),\n\t\t['NotFound', 'NoSuchBucket'],\n\t);\n\tconst base = `S3 bucket ${bucket}`;\n\tif (!exists) return { key: record.key, label: base, gone: true };\n\tif (!ours(tagging?.TagSet, input)) {\n\t\treturn { key: record.key, label: base, leftAlone: NOT_TAGGED };\n\t}\n\tlet count = 0;\n\tfor await (const page of bucketVersions(clients, bucket))\n\t\tcount += page.length;\n\treturn {\n\t\tkey: record.key,\n\t\tlabel: `${base}, emptied first: ${count} object version${count === 1 ? '' : 's'}`,\n\t\tremove: async () => {\n\t\t\t// Until it lists nothing: deleting a version-less object in a bucket\n\t\t\t// whose versioning was suspended leaves a delete marker behind.\n\t\t\tfor (let pass = 0; pass < 5; pass++) {\n\t\t\t\tlet deleted = 0;\n\t\t\t\tfor await (const page of bucketVersions(clients, bucket)) {\n\t\t\t\t\t// At most a thousand a call.\n\t\t\t\t\tfor (let i = 0; i < page.length; i += 1000) {\n\t\t\t\t\t\tawait s3.send(\n\t\t\t\t\t\t\tnew S3.DeleteObjectsCommand({\n\t\t\t\t\t\t\t\tBucket: bucket,\n\t\t\t\t\t\t\t\tDelete: { Objects: page.slice(i, i + 1000), Quiet: true },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tdeleted += page.length;\n\t\t\t\t}\n\t\t\t\tif (deleted === 0) break;\n\t\t\t}\n\t\t\tawait s3.send(new S3.DeleteBucketCommand({ Bucket: bucket }));\n\t\t},\n\t};\n}\n","/**\n * `gkm compose --stage <stage> --destroy`: everything a deploy made for the\n * stage, deleted for good.\n *\n * The one thing in gkm that deletes what a deploy created — a deploy itself\n * never does. So it is careful in three ways:\n *\n * - **Only what is provably gkm's.** Each AWS resource is checked against\n * what gkm marks its own with before it is deleted (see\n * `providers/s3/destroy.ts`); a DNS record only while it still holds the\n * value gkm wrote. What fails is listed, and left where it is.\n * - **Only with a person typing the stage.** The whole plan is printed\n * first, then the compose project's name — `<project>-<stage>` — has to be\n * typed back. Nothing skips that: there is no flag that answers it, and\n * with no terminal to ask at it refuses before reading anything.\n * - **Resumable.** Each resource's record is forgotten as soon as it is gone,\n * so a run that stops part way — a distribution still deploying — carries\n * on from there when it is run again.\n *\n * What other stages or projects share is never touched: the project bucket\n * that holds every stage's state, the shared Traefik edge, the server's own\n * setup (`gkm compose:server`). The stage's secrets are kept unless\n * `--secrets` is passed.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { loadWorkspaceConfig } from '../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../deploy/credentials.js';\nimport { dnsRecordFqdn, dnsResources } from '../deploy/dnsResources.js';\nimport { deployIdentity } from '../deploy/identity.js';\nimport { createStateStore, type StateStore } from '../deploy/StateStore.js';\nimport { GkmError } from '../errors';\nimport { canPrompt, prompt } from '../prompt';\nimport {\n\ttype AwsProvisioning,\n\tawsProvisioningCredentials,\n} from '../providers/aws.js';\nimport {\n\tAWS_RESOURCE_TYPES,\n\ttype AwsDestroyInput,\n\ttype AwsDestroyStep,\n\tplanAwsDestroy,\n} from '../providers/s3/destroy.js';\nimport { secretsStoreFor } from '../secrets/store.js';\nimport { stackOverrideFile } from '../target/compose/index';\nimport type { DnsProvider } from '../target/dokploy/dns/DnsProvider.js';\nimport {\n\textractSubdomain,\n\tfindRootDomain,\n\tnormalizeDnsConfig,\n} from '../target/dokploy/dns/index.js';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport type {\n\tDnsProvider as DnsProviderConfig,\n\tNormalizedWorkspace,\n} from '../workspace/types.js';\nimport {\n\tdnsCredentials,\n\tpruneStackDns,\n\ttype RecordedDnsRecord,\n\trecordTtl,\n} from './dns';\nimport { type ComposeDocker, dockerCompose, type StackRef } from './docker';\nimport { edgeRef, removeEdgeRoutes } from './edge';\nimport { composeServer, dockerHost, sshTarget } from './server';\nimport { composeProject, stackDir } from './stack';\nimport { EDGE_PROJECT } from './traefik';\n\nexport interface ComposeDestroyOptions {\n\tcwd?: string;\n\tstage: string;\n\t/** Delete the stage's secrets too. Kept otherwise. */\n\tsecrets?: boolean;\n\t/** Print what would be deleted; delete nothing, ask nothing. */\n\tdryRun?: boolean;\n}\n\nexport interface ComposeDestroyDeps {\n\tdocker?: ComposeDocker;\n\t/** Whether a person is at a terminal to answer. */\n\tinteractive?: () => boolean;\n\t/** Ask the person, and resolve with what they typed. */\n\task?: (question: string) => Promise<string>;\n\t/** Where the DNS providers' tokens come from. */\n\tcredentials?: CredentialProvider;\n\t/** The provider for a domain — `createDnsProvider` by default. */\n\tdnsProviderFor?: (config: DnsProviderConfig) => Promise<DnsProvider | null>;\n\t/**\n\t * How the AWS account's credential is found — the machine's, as a deploy\n\t * finds it, by default.\n\t */\n\tawsCredentials?: () => Promise<AwsProvisioning | undefined>;\n\t/** For tests: the AWS clients and how long a distribution is waited on. */\n\taws?: Pick<AwsDestroyInput, 'clients' | 'wait'>;\n\tstate?: StateStore;\n\tenv?: NodeJS.ProcessEnv;\n\thome?: string;\n\tlog?: (line: string) => void;\n}\n\n/** A destroy with no terminal to type the stage's name at. */\nexport class ComposeDestroyNeedsTerminal extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`Destroying '${stage}' deletes everything its deploys made, and asks you to ` +\n\t\t\t\t`type ${project} first — there is no terminal here to ask at, and no flag ` +\n\t\t\t\t'answers it. Run it yourself, from a terminal. `--dry-run` prints what it ' +\n\t\t\t\t'would delete, anywhere.',\n\t\t);\n\t\tthis.name = 'ComposeDestroyNeedsTerminal';\n\t}\n}\n\n/** What was typed was not the project's name. */\nexport class ComposeDestroyNotConfirmed extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`Nothing was deleted: destroying '${stage}' needs ${project} typed exactly.`,\n\t\t);\n\t\tthis.name = 'ComposeDestroyNotConfirmed';\n\t}\n}\n\n/** AWS resources to delete, and no credentials to delete them with. */\nexport class ComposeDestroyNeedsAwsCredentials extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly resources: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' has ${resources.length} AWS resource${resources.length === 1 ? '' : 's'} ` +\n\t\t\t\t`to delete (${resources.slice(0, 3).join(', ')}${resources.length > 3 ? ', …' : ''}), ` +\n\t\t\t\t\"and no AWS credentials were found to delete them with. Supply the stage's \" +\n\t\t\t\t'account the way a deploy does — AWS_PROFILE, or AWS_ACCESS_KEY_ID and ' +\n\t\t\t\t'AWS_SECRET_ACCESS_KEY — and run it again. Nothing was deleted.',\n\t\t);\n\t\tthis.name = 'ComposeDestroyNeedsAwsCredentials';\n\t}\n}\n\n/** `--secrets`, and a store that cannot delete. */\nexport class SecretsStoreCannotDelete extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly store: string,\n\t) {\n\t\tsuper(\n\t\t\t`--secrets deletes '${stage}''s secrets, and its store (${store}) has no ` +\n\t\t\t\t'delete(stage). Give the custom store one, or run without --secrets and ' +\n\t\t\t\t'delete them where they are kept. Nothing was deleted.',\n\t\t);\n\t\tthis.name = 'SecretsStoreCannotDelete';\n\t}\n}\n\n/** One line of the plan, and how it is carried out. */\ninterface Step {\n\tlabel: string;\n\tleftAlone?: string;\n\t/** Forgotten from the stage's state once done. */\n\tkeys?: string[];\n\trun?: () => Promise<void>;\n}\n\n/** What a record of each type is to destroy. */\nconst KEPT_TYPES: Record<string, string> = {\n\t// The server's setup — its users, firewall, Docker — is the server's.\n\tserver:\n\t\t\"the server's setup is kept: gkm compose:server made it, for any stage\",\n};\n\n/** Records that name no resource of their own — a key in the secrets. */\nconst VALUE_TYPES = new Set(['url', 'email-from']);\n\n/**\n * The stage's stack: its project on the server (or this machine), as\n * `gkm compose --down` finds it.\n */\nexport async function composeStackRef(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n): Promise<{\n\tref: StackRef;\n\tdir: string;\n\tserver?: ReturnType<typeof composeServer>;\n}> {\n\tconst local = stage === workspace.stages.local;\n\tconst server = local\n\t\t? undefined\n\t\t: composeServer({\n\t\t\t\tstage,\n\t\t\t\tlocal,\n\t\t\t\tconfig: workspace.deploy?.compose?.server,\n\t\t\t\tcustom: (await (await secretsStoreFor(workspace, stage)).read(stage))\n\t\t\t\t\t?.custom,\n\t\t\t});\n\tconst override = stackOverrideFile(workspace.root, stage);\n\tconst dir = join(workspace.root, stackDir(stage));\n\tconst ref: StackRef = {\n\t\tproject: composeProject(deployIdentity(workspace, stage)),\n\t\tfile: join(dir, 'docker-compose.yml'),\n\t\t...(existsSync(override) ? { overrides: [override] } : {}),\n\t\tcwd: workspace.root,\n\t\t...(server ? { host: dockerHost(server) } : {}),\n\t};\n\treturn { ref, dir, ...(server ? { server } : {}) };\n}\n\n/** `gkm compose --stage <stage> --destroy`. */\nexport async function composeDestroyCommand(\n\toptions: ComposeDestroyOptions,\n\tdeps: ComposeDestroyDeps = {},\n): Promise<void> {\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\tconst env = deps.env ?? process.env;\n\tconst cwd = resolve(options.cwd ?? process.cwd());\n\tconst { workspace } = await loadWorkspaceConfig(cwd);\n\tconst { stage } = options;\n\tconst local = stage === workspace.stages.local;\n\tif (!local) assertDeployedStage(workspace.stages, stage);\n\n\tconst identity = deployIdentity(workspace, stage);\n\tconst project = composeProject(identity);\n\tconst interactive = deps.interactive ?? canPrompt;\n\tif (!options.dryRun && !interactive()) {\n\t\tthrow new ComposeDestroyNeedsTerminal(stage, project);\n\t}\n\n\tconst state =\n\t\tdeps.state ??\n\t\t(await createStateStore({\n\t\t\tconfig: local ? undefined : workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t}));\n\t// Held throughout: a deploy of the stage while it is torn down would\n\t// make what this is deleting.\n\tconst lock = options.dryRun\n\t\t? undefined\n\t\t: await state.lock(stage, { operation: 'destroy' });\n\ttry {\n\t\tconst steps = await plan(workspace, stage, options, deps, state, env);\n\t\tconst { ref } = await composeStackRef(workspace, stage);\n\n\t\tlog(\n\t\t\t`\\n🧨 ${options.dryRun ? 'Would delete' : 'This deletes'} stage '${stage}' of ${workspace.name} for good:\\n`,\n\t\t);\n\t\tconst doing = steps.filter((s) => !s.leftAlone);\n\t\tconst kept = steps.filter((s) => s.leftAlone);\n\t\tfor (const step of doing) log(` - ${step.label}`);\n\t\tif (kept.length > 0) {\n\t\t\tlog('\\n Left where it is:');\n\t\t\tfor (const step of kept) log(` · ${step.label} — ${step.leftAlone}`);\n\t\t}\n\t\tif (!options.secrets) {\n\t\t\tlog(\n\t\t\t\t\"\\n The stage's secrets are kept: a deploy of it again reuses them. --secrets deletes them too.\",\n\t\t\t);\n\t\t}\n\n\t\tif (options.dryRun) {\n\t\t\tlog('\\n--dry-run: nothing was deleted.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst ask =\n\t\t\tdeps.ask ??\n\t\t\t((question: string) =>\n\t\t\t\tprompt(question, {\n\t\t\t\t\tinstead: 'Run it yourself, from a terminal.',\n\t\t\t\t}));\n\t\tconst typed = await ask(`\\n Type ${project} to destroy it: `);\n\t\tif (typed.trim() !== project) {\n\t\t\tthrow new ComposeDestroyNotConfirmed(stage, project);\n\t\t}\n\n\t\tlog('');\n\t\tfor (const step of doing) {\n\t\t\tawait step.run?.();\n\t\t\tfor (const key of step.keys ?? []) {\n\t\t\t\tawait state.deleteResource(stage, key);\n\t\t\t}\n\t\t\tlog(` ✓ ${step.label}`);\n\t\t}\n\t\tlog(`\\n💥 '${stage}' destroyed. ${ref.project} is gone.`);\n\t} finally {\n\t\tawait lock?.release();\n\t}\n}\n\n/** Every step, in the order it is carried out. */\nasync function plan(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n\toptions: ComposeDestroyOptions,\n\tdeps: ComposeDestroyDeps,\n\tstate: StateStore,\n\tenv: NodeJS.ProcessEnv,\n): Promise<Step[]> {\n\tconst steps: Step[] = [];\n\tconst resources = (await state.read(stage))?.resources ?? {};\n\tconst records = Object.values(resources);\n\n\t// ── The stack: containers, volumes, its routes on the edge ─────────────\n\tconst { ref, dir, server } = await composeStackRef(workspace, stage);\n\tconst docker = deps.docker ?? dockerCompose;\n\tsteps.push({\n\t\tlabel: `${server ? `on ${sshTarget(server)}: ` : ''}stack ${ref.project} — its containers, its volumes and their data, its routes on ${EDGE_PROJECT}`,\n\t\trun: async () => {\n\t\t\tconst edgeFile = join(dir, `${EDGE_PROJECT}.yml`);\n\t\t\tif (server || existsSync(edgeFile)) {\n\t\t\t\tawait removeEdgeRoutes(\n\t\t\t\t\tdocker,\n\t\t\t\t\tedgeRef(edgeFile, { host: ref.host }),\n\t\t\t\t\tref.project,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait docker.down(ref, { volumes: true });\n\t\t},\n\t});\n\n\t// ── AWS ─────────────────────────────────────────────────────────────────\n\tconst aws = records.filter((r) =>\n\t\t(AWS_RESOURCE_TYPES as readonly string[]).includes(r.type),\n\t);\n\tlet cdnDns: RecordedDnsRecord[] = [];\n\tif (aws.length > 0) {\n\t\tconst credential = await (\n\t\t\tdeps.awsCredentials ??\n\t\t\t(() =>\n\t\t\t\tawsProvisioningCredentials({\n\t\t\t\t\tstage,\n\t\t\t\t\tenv,\n\t\t\t\t\t...(deps.home ? { home: deps.home } : {}),\n\t\t\t\t}))\n\t\t)();\n\t\tif (!credential) {\n\t\t\tthrow new ComposeDestroyNeedsAwsCredentials(\n\t\t\t\tstage,\n\t\t\t\taws.map((r) => r.key),\n\t\t\t);\n\t\t}\n\t\tconst identity = deployIdentity(workspace, stage);\n\t\tconst planned = await planAwsDestroy({\n\t\t\tresources,\n\t\t\tidentityKey: identity.key,\n\t\t\tscope: identity.scope,\n\t\t\tstage,\n\t\t\tcredential,\n\t\t\t...(deps.aws ?? {}),\n\t\t});\n\t\tfor (const step of planned.steps) steps.push(awsStep(step));\n\t\tcdnDns = providerDnsRecords(workspace, planned.dns);\n\t}\n\n\t// ── DNS: what the stage recorded, and what its CDN was given ───────────\n\tconst recorded = dnsResources(resources).map((r) => ({\n\t\t...r,\n\t\tfqdn: r.fqdn || dnsRecordFqdn(r.domain, r.name),\n\t}));\n\tconst seen = new Set(recorded.map((r) => `${r.fqdn} ${r.type}`));\n\tconst dnsRecords: RecordedDnsRecord[] = [\n\t\t...recorded,\n\t\t...cdnDns.filter((r) => !seen.has(`${r.fqdn} ${r.type}`)),\n\t];\n\tif (dnsRecords.length > 0) {\n\t\t// The providers' tokens are read now: a missing one stops the destroy\n\t\t// before anything is deleted, rather than after the stack is gone.\n\t\tconst dns = workspace.dns ? normalizeDnsConfig(workspace.dns) : {};\n\t\tconst domains = [...new Set(dnsRecords.map((r) => r.domain))]\n\t\t\t.filter((domain) => dns[domain])\n\t\t\t.map((domain) => ({ domain, config: dns[domain]! }));\n\t\tconst tokens = await dnsCredentials(\n\t\t\tstage,\n\t\t\tdomains,\n\t\t\tdeps.credentials ?? storedCredentials({ env }),\n\t\t);\n\t\tconst log = deps.log ?? ((line: string) => console.log(line));\n\t\tsteps.push({\n\t\t\tlabel: `DNS: ${dnsRecords.map((r) => `${r.type} ${r.fqdn}`).join(', ')} — each only while it holds the value gkm wrote`,\n\t\t\tkeys: recorded.map(\n\t\t\t\t(r) => `dns-record:${r.fqdn.toLowerCase()}:${r.type.toUpperCase()}`,\n\t\t\t),\n\t\t\trun: async () => {\n\t\t\t\tawait pruneStackDns(dnsRecords, {\n\t\t\t\t\tstage,\n\t\t\t\t\tdns: workspace.dns,\n\t\t\t\t\tlog,\n\t\t\t\t\tcredentials: {\n\t\t\t\t\t\t...(tokens.godaddy ? { credential: tokens.godaddy } : {}),\n\t\t\t\t\t\tlog,\n\t\t\t\t\t},\n\t\t\t\t\t...(tokens.hostinger ? { hostinger: tokens.hostinger } : {}),\n\t\t\t\t\t...(deps.dnsProviderFor ? { providerFor: deps.dnsProviderFor } : {}),\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\t}\n\n\t// ── What gkm cannot delete, and what names nothing ──────────────────────\n\tconst handled = new Set<string>([\n\t\t...(AWS_RESOURCE_TYPES as readonly string[]),\n\t\t'dns-record',\n\t]);\n\tconst values = records.filter((r) => VALUE_TYPES.has(r.type));\n\tfor (const record of records) {\n\t\tif (handled.has(record.type) || VALUE_TYPES.has(record.type)) continue;\n\t\tsteps.push({\n\t\t\tlabel: `${record.type} ${record.id ?? record.key}`,\n\t\t\tleftAlone:\n\t\t\t\tKEPT_TYPES[record.type] ??\n\t\t\t\t`gkm does not delete a ${record.type} yet: delete it by hand`,\n\t\t});\n\t}\n\n\t// ── The stage's secrets ────────────────────────────────────────────────\n\tif (options.secrets) {\n\t\tconst store = await secretsStoreFor(workspace, stage, {\n\t\t\t...(deps.home ? { home: deps.home } : {}),\n\t\t});\n\t\tif (!store.delete) throw new SecretsStoreCannotDelete(stage, store.name);\n\t\tsteps.push({\n\t\t\tlabel: `the stage's secrets, in its ${store.name} store`,\n\t\t\t// The keys the deleted resources were reached by go with them.\n\t\t\tkeys: values.map((r) => r.key),\n\t\t\trun: () => store.delete!(stage),\n\t\t});\n\t} else if (values.length > 0) {\n\t\t// Their resources are gone; the keys stay in the kept secrets, and a\n\t\t// deploy writes them again.\n\t\tsteps.push({\n\t\t\tlabel: `${values.length} record${values.length === 1 ? '' : 's'} of keys written into the secrets`,\n\t\t\tkeys: values.map((r) => r.key),\n\t\t});\n\t}\n\n\treturn steps;\n}\n\nfunction awsStep(step: AwsDestroyStep): Step {\n\tif (step.leftAlone) return { label: step.label, leftAlone: step.leftAlone };\n\treturn {\n\t\tlabel: step.gone\n\t\t\t? `${step.label} (already gone)`\n\t\t\t: step.withUser\n\t\t\t\t? `${step.label} — deleted with its user`\n\t\t\t\t: step.label,\n\t\tkeys: [step.key],\n\t\t...(step.remove ? { run: step.remove } : {}),\n\t};\n}\n\n/** The CDN's records, as the DNS prune takes them. */\nfunction providerDnsRecords(\n\tworkspace: NormalizedWorkspace,\n\trecords: readonly { host: string; type: 'CNAME'; value: string }[],\n): RecordedDnsRecord[] {\n\tconst dns = workspace.dns ? normalizeDnsConfig(workspace.dns) : {};\n\tconst out: RecordedDnsRecord[] = [];\n\tfor (const record of records) {\n\t\tconst host = record.host.toLowerCase().replace(/\\.$/, '');\n\t\tconst domain = findRootDomain(host, dns);\n\t\tif (!domain) continue;\n\t\tconst config = dns[domain]!;\n\t\tout.push({\n\t\t\tfqdn: host,\n\t\t\tdomain,\n\t\t\tname: extractSubdomain(host, domain),\n\t\t\ttype: record.type,\n\t\t\tvalue: record.value.replace(/\\.$/, ''),\n\t\t\tttl: recordTtl(config),\n\t\t\t...(typeof config.provider === 'string'\n\t\t\t\t? { provider: config.provider }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\treturn out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8EA,MAAa,qBAAqB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAGA,MAAM,eAAe;CAAE,WAAW;CAAa,YAAY;AAAO;;AAGlE,IAAa,6BAAb,cAAgD,SAAS;CAE9C;CACA;CAFV,YACC,IACA,UACC;EACD,MACC,2BAA2B,GAAG,8CAC1B,KAAK,MAAM,WAAW,GAAM,EAAE,yLAInC;EATS,KAAA,KAAA;EACA,KAAA,WAAA;EAST,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,UAAU,OAAwB;CAC1C,MAAM,IAAI;CACV,OAAO,GAAG,QAAQ,GAAG,QAAQ;AAC9B;;AAGA,eAAe,OACd,MACA,SACyB;CACzB,IAA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M,MAA2B,CAAC;CAClC,KAAK,MAAM,UAAU,SAAS;EAC7B,MAAM,OAAO,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,OAAO,EAAE;EACxD,MAAM,SAAS,eAAe,MAAM,GAAG;EACvC,IAAI,CAAC,QAAQ;EACb,MAAM,SAAS,IAAI;EACnB,IAAI,KAAK;GACR,MAAM;GACN;GACA,MAAM,iBAAiB,MAAM,MAAM;GACnC,MAAM,OAAO;GACb,OAAO,OAAO,MAAM,QAAQ,OAAO,EAAE;GACrC,KAAK,UAAU,MAAM;GACrB,GAAI,OAAO,OAAO,aAAa,WAC5B,EAAE,UAAU,OAAO,SAAS,IAC5B,CAAC;EACL,CAAC;CACF;CACA,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"destroy-Gyxrl5yO.mjs","names":[],"sources":["../src/providers/s3/destroy.ts","../src/compose/destroy.ts"],"sourcesContent":["/**\n * What `gkm compose --destroy` deletes in the stage's AWS account: each\n * resource a deploy recorded in the stage's state, and only once it is\n * proven gkm's own for this stage.\n *\n * A record alone proves nothing — a deploy records what it found and adopted\n * exactly as what it made (a certificate for the host, a bucket with no\n * tags). So each is checked against what gkm marks its own with: the\n * `gkm:project` and `gkm:stage` tags on a bucket, a user, a certificate, a\n * distribution, a topic or a queue; the stage's own name on an origin access\n * control and a headers policy, which take no tags. What fails the check is\n * left where it is, and said so.\n *\n * Nothing here runs on its own: `planAwsDestroy` reads, and returns a step\n * per resource whose `remove()` the command calls — after the person typed\n * the stage's name — in the order AWS needs: a distribution disabled and\n * gone before its certificate, a user's keys and policies before the user,\n * a bucket emptied before it is deleted.\n */\n\nimport type { ResourceRecord } from '../../deploy/StateStore.js';\nimport { GkmError } from '../../errors.js';\nimport { type AwsProvisioning, awsClientConfig, awsEndpoint } from '../aws.js';\nimport { TAG_PROJECT, TAG_STAGE } from '../iam.js';\nimport { type CdnClients, cdnName, defaultCdnClients } from './cdn.js';\nimport { defaultClients } from './index.js';\nimport { IAM_USER_PATH } from './naming.js';\n\n/** What a destroy step is about, as the person reads it. */\nexport interface AwsDestroyStep {\n\t/** The state record it is kept as: forgotten once it is gone. */\n\tkey: string;\n\tlabel: string;\n\t/** Why it is not deleted. Absent for one that will be. */\n\tleftAlone?: string;\n\t/** Already gone from the account: only its record is forgotten. */\n\tgone?: boolean;\n\t/** Deleted along with its user's step: only its record is forgotten here. */\n\twithUser?: boolean;\n\t/** Deletes it. Absent when it is left alone or already gone. */\n\tremove?: () => Promise<void>;\n}\n\n/** A DNS record a resource here needs, worked out from the resource. */\nexport interface AwsDnsRecord {\n\thost: string;\n\ttype: 'CNAME';\n\tvalue: string;\n}\n\nexport interface AwsDestroyPlan {\n\t/** In the order they are removed. */\n\tsteps: AwsDestroyStep[];\n\t/**\n\t * The records the s3 provider wrote for what it deletes — a CDN's name, a\n\t * certificate's validation — which no state record names.\n\t */\n\tdns: AwsDnsRecord[];\n}\n\nexport interface AwsDestroyInput {\n\tresources: Record<string, ResourceRecord>;\n\t/** `deployIdentity(…).key` — what `gkm:project` holds. */\n\tidentityKey: string;\n\t/** `deployIdentity(…).scope` — what CDN resource names start with. */\n\tscope: string;\n\tstage: string;\n\tcredential: AwsProvisioning;\n\t/** How long a disabled distribution is waited on, and how often asked. */\n\twait?: { timeoutMs: number; intervalMs: number };\n\t/** For tests: where the clients come from. */\n\tclients?: {\n\t\ts3?: typeof defaultClients;\n\t\tcdn?: (credential: AwsProvisioning) => Promise<CdnClients>;\n\t};\n}\n\n/** The record types this plans. Every other is the command's to report. */\nexport const AWS_RESOURCE_TYPES = [\n\t'cloudfront-distribution',\n\t'cloudfront-oac',\n\t'cloudfront-headers',\n\t'acm-certificate',\n\t'sns-subscription',\n\t'sns-topic',\n\t'sqs-queue',\n\t'iam-access-key',\n\t'iam-user',\n\t's3-bucket',\n] as const;\n\n/** A distribution disabled before it is deleted can take this long. */\nconst DISABLE_WAIT = { timeoutMs: 45 * 60_000, intervalMs: 20_000 };\n\n/** A disabled distribution that never finished deploying. */\nexport class DistributionStillDeploying extends GkmError {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly waitedMs: number,\n\t) {\n\t\tsuper(\n\t\t\t`CloudFront distribution ${id} was disabled, and is still deploying after ` +\n\t\t\t\t`${Math.round(waitedMs / 60_000)} minutes. CloudFront deletes only a ` +\n\t\t\t\t'disabled distribution that has finished deploying. Run the destroy ' +\n\t\t\t\t'again later: everything deleted so far is forgotten, and it carries ' +\n\t\t\t\t'on from here.',\n\t\t);\n\t\tthis.name = 'DistributionStillDeploying';\n\t}\n}\n\n/** What an AWS SDK error is called, whichever field carries it. */\nfunction errorName(error: unknown): string {\n\tconst e = error as { name?: string; Code?: string };\n\treturn e?.Code ?? e?.name ?? '';\n}\n\n/** A read whose \"there is none\" answer is one of `missing`. */\nasync function readOr<T>(\n\tread: () => Promise<T>,\n\tmissing: readonly string[],\n): Promise<T | undefined> {\n\ttry {\n\t\treturn await read();\n\t} catch (error) {\n\t\tif (missing.includes(errorName(error))) return undefined;\n\t\tthrow error;\n\t}\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n/** Whether a tag list says gkm made it for this project's stage. */\nfunction ours(\n\ttags: readonly { Key?: string; Value?: string }[] | undefined,\n\tinput: Pick<AwsDestroyInput, 'identityKey' | 'stage'>,\n): boolean {\n\tconst of = (key: string) => tags?.find((t) => t.Key === key)?.Value;\n\treturn of(TAG_PROJECT) === input.identityKey && of(TAG_STAGE) === input.stage;\n}\n\nconst NOT_TAGGED =\n\t\"not tagged as this stage's (gkm:project, gkm:stage): gkm found it, it did not make it\";\n\n/** The id after the type in a record's key: `cloudfront-oac:Uploads` → `Uploads`. */\nfunction keyId(record: ResourceRecord): string {\n\treturn record.key.slice(record.key.indexOf(':') + 1);\n}\n\n/** The file server a CDN record is for: `cloudfront-headers:Uploads:cors` → `Uploads`. */\nfunction serverOf(record: ResourceRecord): string {\n\treturn keyId(record).split(':')[0] ?? '';\n}\n\n/**\n * Each AWS resource the stage's state records, checked, in the order it is\n * deleted — and the DNS records the deleted ones were given.\n */\nexport async function planAwsDestroy(\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyPlan> {\n\tconst steps: AwsDestroyStep[] = [];\n\tconst dns: AwsDnsRecord[] = [];\n\tconst records = Object.values(input.resources);\n\tconst of = (type: string) => records.filter((r) => r.type === type);\n\tconst wait = input.wait ?? DISABLE_WAIT;\n\n\tconst cdnRecords = [\n\t\t...of('cloudfront-distribution'),\n\t\t...of('cloudfront-oac'),\n\t\t...of('cloudfront-headers'),\n\t\t...of('acm-certificate'),\n\t];\n\tif (cdnRecords.length > 0) {\n\t\tconst cdn = await (input.clients?.cdn ?? defaultCdnClients)(\n\t\t\tinput.credential,\n\t\t);\n\t\t// A distribution left alone keeps what it uses: deleting its origin\n\t\t// access control, a headers policy or its certificate would break it.\n\t\tconst kept = new Map<string, string>();\n\t\tfor (const record of of('cloudfront-distribution')) {\n\t\t\tconst step = await distributionStep(cdn, record, input, wait, dns);\n\t\t\tif (step.leftAlone) kept.set(serverOf(record), step.label);\n\t\t\tsteps.push(step);\n\t\t}\n\t\tconst usedBy = async (\n\t\t\trecord: ResourceRecord,\n\t\t\tstep: () => Promise<AwsDestroyStep>,\n\t\t): Promise<AwsDestroyStep> => {\n\t\t\tconst holder = kept.get(serverOf(record));\n\t\t\tif (!holder) return step();\n\t\t\tconst label = (await step()).label;\n\t\t\treturn {\n\t\t\t\tkey: record.key,\n\t\t\t\tlabel,\n\t\t\t\tleftAlone: `used by ${holder}, which is left alone`,\n\t\t\t};\n\t\t};\n\t\tfor (const record of of('cloudfront-oac')) {\n\t\t\tsteps.push(\n\t\t\t\tawait usedBy(record, () => originAccessControlStep(cdn, record, input)),\n\t\t\t);\n\t\t}\n\t\tfor (const record of of('cloudfront-headers')) {\n\t\t\tsteps.push(\n\t\t\t\tawait usedBy(record, () => headersPolicyStep(cdn, record, input)),\n\t\t\t);\n\t\t}\n\t\tfor (const record of of('acm-certificate')) {\n\t\t\t// Its validation record goes only with the certificate itself.\n\t\t\tconst found: AwsDnsRecord[] = [];\n\t\t\tconst step = await usedBy(record, () =>\n\t\t\t\tcertificateStep(cdn, record, input, found),\n\t\t\t);\n\t\t\tif (!step.leftAlone) dns.push(...found);\n\t\t\tsteps.push(step);\n\t\t}\n\t}\n\n\tconst eventRecords = [\n\t\t...of('sns-subscription'),\n\t\t...of('sns-topic'),\n\t\t...of('sqs-queue'),\n\t];\n\tif (eventRecords.length > 0) {\n\t\tconst events = await eventClients(input.credential, records);\n\t\tfor (const record of of('sns-subscription')) {\n\t\t\tsteps.push(subscriptionStep(events, record));\n\t\t}\n\t\tfor (const record of of('sns-topic')) {\n\t\t\tsteps.push(await topicStep(events, record, input));\n\t\t}\n\t\tfor (const record of of('sqs-queue')) {\n\t\t\tsteps.push(await queueStep(events, record, input));\n\t\t}\n\t}\n\n\tconst users = of('iam-user');\n\tconst keys = of('iam-access-key');\n\tconst buckets = of('s3-bucket');\n\tif (users.length + keys.length + buckets.length > 0) {\n\t\tconst global = await (input.clients?.s3 ?? defaultClients)(\n\t\t\tinput.credential,\n\t\t\tregionOf(buckets[0]) ?? 'us-east-1',\n\t\t);\n\t\tconst userSteps = new Map<string, AwsDestroyStep>();\n\t\tfor (const record of users) {\n\t\t\tconst step = await userStep(global, record, input);\n\t\t\tuserSteps.set(record.id ?? '', step);\n\t\t\tsteps.push(step);\n\t\t}\n\t\t// A key goes with its user, and is checked through it.\n\t\tfor (const record of keys) {\n\t\t\tconst user = (record.data as { user?: string } | undefined)?.user;\n\t\t\tconst owner = user ? userSteps.get(user) : undefined;\n\t\t\tsteps.push({\n\t\t\t\tkey: record.key,\n\t\t\t\tlabel: `IAM access key ${record.id ?? ''} of ${user ?? 'an unknown user'}`,\n\t\t\t\t...(owner?.leftAlone\n\t\t\t\t\t? { leftAlone: `its user is left alone: ${owner.leftAlone}` }\n\t\t\t\t\t: owner\n\t\t\t\t\t\t? { withUser: true }\n\t\t\t\t\t\t: { leftAlone: 'its user is not one this stage recorded' }),\n\t\t\t});\n\t\t}\n\t\tfor (const record of buckets) {\n\t\t\tconst region = regionOf(record) ?? global.region;\n\t\t\tconst clients =\n\t\t\t\tregion === global.region\n\t\t\t\t\t? global\n\t\t\t\t\t: await (input.clients?.s3 ?? defaultClients)(\n\t\t\t\t\t\t\tinput.credential,\n\t\t\t\t\t\t\tregion,\n\t\t\t\t\t\t);\n\t\t\tsteps.push(await bucketStep(clients, record, input));\n\t\t}\n\t}\n\n\treturn { steps, dns };\n}\n\nfunction regionOf(record: ResourceRecord | undefined): string | undefined {\n\treturn (record?.data as { region?: string } | undefined)?.region;\n}\n\n// ---------------------------------------------------------------------------\n// CloudFront and ACM\n// ---------------------------------------------------------------------------\n\nasync function distributionStep(\n\t{ CF, cloudfront }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n\twait: { timeoutMs: number; intervalMs: number },\n\tdns: AwsDnsRecord[],\n): Promise<AwsDestroyStep> {\n\tconst id = record.id ?? '';\n\tconst found = await readOr(\n\t\t() => cloudfront.send(new CF.GetDistributionCommand({ Id: id })),\n\t\t['NoSuchDistribution'],\n\t);\n\tconst distribution = found?.Distribution;\n\tconst aliases = distribution?.DistributionConfig?.Aliases?.Items ?? [];\n\tconst label = `CloudFront distribution ${id}${aliases.length ? ` (${aliases.join(', ')})` : ''}`;\n\tif (!distribution) return { key: record.key, label, gone: true };\n\n\t// Its tags, or the comment gkm writes on every distribution it makes —\n\t// `gkm <project> <stage> <file server>`, which nothing else writes.\n\tconst tags = await cloudfront.send(\n\t\tnew CF.ListTagsForResourceCommand({ Resource: distribution.ARN }),\n\t);\n\tconst comment = `gkm ${input.identityKey} ${input.stage} ${serverOf(record)}`;\n\tconst marked =\n\t\tdistribution.DistributionConfig?.Comment === comment.slice(0, 128);\n\tif (!ours(tags.Tags?.Items, input) && !marked) {\n\t\treturn {\n\t\t\tkey: record.key,\n\t\t\tlabel,\n\t\t\tleftAlone: `${NOT_TAGGED}, and its comment is not \"${comment}\"`,\n\t\t};\n\t}\n\tfor (const host of aliases) {\n\t\tdns.push({ host, type: 'CNAME', value: distribution.DomainName ?? '' });\n\t}\n\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tlet current = await cloudfront.send(\n\t\t\t\tnew CF.GetDistributionConfigCommand({ Id: id }),\n\t\t\t);\n\t\t\tif (current.DistributionConfig?.Enabled) {\n\t\t\t\tawait cloudfront.send(\n\t\t\t\t\tnew CF.UpdateDistributionCommand({\n\t\t\t\t\t\tId: id,\n\t\t\t\t\t\tIfMatch: current.ETag,\n\t\t\t\t\t\tDistributionConfig: {\n\t\t\t\t\t\t\t...current.DistributionConfig,\n\t\t\t\t\t\t\tEnabled: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst started = Date.now();\n\t\t\tfor (;;) {\n\t\t\t\tconst state = await cloudfront.send(\n\t\t\t\t\tnew CF.GetDistributionCommand({ Id: id }),\n\t\t\t\t);\n\t\t\t\tif (state.Distribution?.Status === 'Deployed') break;\n\t\t\t\tif (Date.now() - started > wait.timeoutMs) {\n\t\t\t\t\tthrow new DistributionStillDeploying(id, Date.now() - started);\n\t\t\t\t}\n\t\t\t\tawait sleep(wait.intervalMs);\n\t\t\t}\n\t\t\tcurrent = await cloudfront.send(\n\t\t\t\tnew CF.GetDistributionConfigCommand({ Id: id }),\n\t\t\t);\n\t\t\tawait cloudfront.send(\n\t\t\t\tnew CF.DeleteDistributionCommand({ Id: id, IfMatch: current.ETag }),\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function originAccessControlStep(\n\t{ CF, cloudfront }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst id = record.id ?? '';\n\tconst expected = cdnName(input.scope, input.stage, keyId(record));\n\tconst label = `CloudFront origin access control ${expected}`;\n\tconst found = await readOr(\n\t\t() => cloudfront.send(new CF.GetOriginAccessControlCommand({ Id: id })),\n\t\t['NoSuchOriginAccessControl'],\n\t);\n\tif (!found) return { key: record.key, label, gone: true };\n\tconst name = found.OriginAccessControl?.OriginAccessControlConfig?.Name;\n\tif (name !== expected) {\n\t\treturn {\n\t\t\tkey: record.key,\n\t\t\tlabel,\n\t\t\tleftAlone: `named ${name}, not this stage's ${expected}`,\n\t\t};\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst { ETag } = await cloudfront.send(\n\t\t\t\tnew CF.GetOriginAccessControlCommand({ Id: id }),\n\t\t\t);\n\t\t\tawait cloudfront.send(\n\t\t\t\tnew CF.DeleteOriginAccessControlCommand({ Id: id, IfMatch: ETag }),\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function headersPolicyStep(\n\t{ CF, cloudfront }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst id = record.id ?? '';\n\t// `cloudfront-headers:<server>:<kind>`\n\tconst [server = '', kind = ''] = keyId(record).split(':');\n\tconst expected = `${cdnName(input.scope, input.stage, server)}-${kind}`;\n\tconst label = `CloudFront response headers policy ${expected}`;\n\tconst found = await readOr(\n\t\t() =>\n\t\t\tcloudfront.send(new CF.GetResponseHeadersPolicyConfigCommand({ Id: id })),\n\t\t['NoSuchResponseHeadersPolicy'],\n\t);\n\tif (!found) return { key: record.key, label, gone: true };\n\tconst name = found.ResponseHeadersPolicyConfig?.Name;\n\tif (name !== expected) {\n\t\treturn {\n\t\t\tkey: record.key,\n\t\t\tlabel,\n\t\t\tleftAlone: `named ${name}, not this stage's ${expected}`,\n\t\t};\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst { ETag } = await cloudfront.send(\n\t\t\t\tnew CF.GetResponseHeadersPolicyConfigCommand({ Id: id }),\n\t\t\t);\n\t\t\tawait cloudfront.send(\n\t\t\t\tnew CF.DeleteResponseHeadersPolicyCommand({ Id: id, IfMatch: ETag }),\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function certificateStep(\n\t{ ACM, acm }: CdnClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n\tdns: AwsDnsRecord[],\n): Promise<AwsDestroyStep> {\n\tconst arn = record.id ?? '';\n\tconst host = (record.data as { host?: string } | undefined)?.host ?? arn;\n\tconst label = `ACM certificate ${host} (us-east-1)`;\n\tconst found = await readOr(\n\t\t() => acm.send(new ACM.DescribeCertificateCommand({ CertificateArn: arn })),\n\t\t['ResourceNotFoundException'],\n\t);\n\tif (!found?.Certificate) return { key: record.key, label, gone: true };\n\tconst tags = await acm.send(\n\t\tnew ACM.ListTagsForCertificateCommand({ CertificateArn: arn }),\n\t);\n\tif (!ours(tags.Tags, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\tfor (const option of found.Certificate.DomainValidationOptions ?? []) {\n\t\tconst r = option.ResourceRecord;\n\t\tif (r?.Name && r.Value && r.Type === 'CNAME') {\n\t\t\tdns.push({ host: r.Name, type: 'CNAME', value: r.Value });\n\t\t}\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tawait acm.send(new ACM.DeleteCertificateCommand({ CertificateArn: arn }));\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// SNS and SQS\n// ---------------------------------------------------------------------------\n\ninterface EventClients {\n\tSNS: typeof import('@aws-sdk/client-sns');\n\tSQS: typeof import('@aws-sdk/client-sqs');\n\tsns: (\n\t\tregion: string,\n\t) => Promise<InstanceType<typeof import('@aws-sdk/client-sns')['SNSClient']>>;\n\tsqs: (\n\t\tregion: string,\n\t) => Promise<InstanceType<typeof import('@aws-sdk/client-sqs')['SQSClient']>>;\n}\n\nasync function eventClients(\n\tcredential: AwsProvisioning,\n\t_records: readonly ResourceRecord[],\n): Promise<EventClients> {\n\tconst SNS = await import('@aws-sdk/client-sns');\n\tconst SQS = await import('@aws-sdk/client-sqs');\n\tconst sns = new Map<string, InstanceType<typeof SNS.SNSClient>>();\n\tconst sqs = new Map<string, InstanceType<typeof SQS.SQSClient>>();\n\treturn {\n\t\tSNS,\n\t\tSQS,\n\t\tsns: async (region) => {\n\t\t\tif (!sns.has(region)) {\n\t\t\t\tconst endpoint = awsEndpoint(process.env, 'SNS');\n\t\t\t\tsns.set(\n\t\t\t\t\tregion,\n\t\t\t\t\tnew SNS.SNSClient({\n\t\t\t\t\t\t...(await awsClientConfig(credential, region)),\n\t\t\t\t\t\t...(endpoint ? { endpoint } : {}),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn sns.get(region)!;\n\t\t},\n\t\tsqs: async (region) => {\n\t\t\tif (!sqs.has(region)) {\n\t\t\t\tconst endpoint = awsEndpoint(process.env, 'SQS');\n\t\t\t\tsqs.set(\n\t\t\t\t\tregion,\n\t\t\t\t\tnew SQS.SQSClient({\n\t\t\t\t\t\t...(await awsClientConfig(credential, region)),\n\t\t\t\t\t\t...(endpoint ? { endpoint } : {}),\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn sqs.get(region)!;\n\t\t},\n\t};\n}\n\n/** `arn:aws:sns:<region>:<account>:<name>` */\nfunction arnParts(arn: string) {\n\tconst [, , , region = '', account = '', ...rest] = arn.split(':');\n\treturn { region, account, name: rest.join(':') };\n}\n\nfunction subscriptionStep(\n\t{ SNS, sns }: EventClients,\n\trecord: ResourceRecord,\n): AwsDestroyStep {\n\tconst arn = record.id ?? '';\n\tconst label = `SNS subscription ${keyId(record)}`;\n\t// Made by gkm, to its own push endpoint: a pending one has no ARN yet.\n\tif (!arn.startsWith('arn:')) return { key: record.key, label, gone: true };\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst client = await sns(arnParts(arn).region);\n\t\t\tawait readOr(\n\t\t\t\t() => client.send(new SNS.UnsubscribeCommand({ SubscriptionArn: arn })),\n\t\t\t\t['NotFound', 'NotFoundException'],\n\t\t\t);\n\t\t},\n\t};\n}\n\nasync function topicStep(\n\t{ SNS, sns }: EventClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst arn = record.id ?? '';\n\tconst label = `SNS topic ${arnParts(arn).name}`;\n\tconst client = await sns(arnParts(arn).region);\n\tconst tags = await readOr(\n\t\t() => client.send(new SNS.ListTagsForResourceCommand({ ResourceArn: arn })),\n\t\t[\n\t\t\t'NotFound',\n\t\t\t'NotFoundException',\n\t\t\t'ResourceNotFound',\n\t\t\t'ResourceNotFoundException',\n\t\t],\n\t);\n\tif (!tags) return { key: record.key, label, gone: true };\n\tif (!ours(tags.Tags, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tawait client.send(new SNS.DeleteTopicCommand({ TopicArn: arn }));\n\t\t},\n\t};\n}\n\nasync function queueStep(\n\t{ SQS, sqs }: EventClients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst arn = record.id ?? '';\n\tconst { region, account, name } = arnParts(arn);\n\tconst label = `SQS queue ${name}`;\n\tconst client = await sqs(region);\n\tconst url = await readOr(\n\t\t() =>\n\t\t\tclient.send(\n\t\t\t\tnew SQS.GetQueueUrlCommand({\n\t\t\t\t\tQueueName: name,\n\t\t\t\t\tQueueOwnerAWSAccountId: account,\n\t\t\t\t}),\n\t\t\t),\n\t\t['QueueDoesNotExist', 'AWS.SimpleQueueService.NonExistentQueue'],\n\t);\n\tif (!url?.QueueUrl) return { key: record.key, label, gone: true };\n\tconst queueUrl = url.QueueUrl;\n\tconst tags = await client.send(\n\t\tnew SQS.ListQueueTagsCommand({ QueueUrl: queueUrl }),\n\t);\n\tconst list = Object.entries(tags.Tags ?? {}).map(([Key, Value]) => ({\n\t\tKey,\n\t\tValue,\n\t}));\n\tif (!ours(list, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tawait client.send(new SQS.DeleteQueueCommand({ QueueUrl: queueUrl }));\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// IAM and S3\n// ---------------------------------------------------------------------------\n\ntype S3Clients = Awaited<ReturnType<typeof defaultClients>>;\n\nasync function userStep(\n\t{ IAM, iam }: S3Clients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst name = record.id ?? '';\n\tconst label = `IAM user ${name}, its access keys and policies`;\n\tconst found = await readOr(\n\t\t() => iam.send(new IAM.GetUserCommand({ UserName: name })),\n\t\t['NoSuchEntity', 'NoSuchEntityException'],\n\t);\n\tif (!found?.User) return { key: record.key, label, gone: true };\n\tconst tags = await iam.send(new IAM.ListUserTagsCommand({ UserName: name }));\n\tif (found.User.Path !== IAM_USER_PATH || !ours(tags.Tags, input)) {\n\t\treturn { key: record.key, label, leftAlone: NOT_TAGGED };\n\t}\n\treturn {\n\t\tkey: record.key,\n\t\tlabel,\n\t\tremove: async () => {\n\t\t\tconst keys = await iam.send(\n\t\t\t\tnew IAM.ListAccessKeysCommand({ UserName: name }),\n\t\t\t);\n\t\t\tfor (const key of keys.AccessKeyMetadata ?? []) {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.DeleteAccessKeyCommand({\n\t\t\t\t\t\tUserName: name,\n\t\t\t\t\t\tAccessKeyId: key.AccessKeyId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst inline = await iam.send(\n\t\t\t\tnew IAM.ListUserPoliciesCommand({ UserName: name }),\n\t\t\t);\n\t\t\tfor (const policy of inline.PolicyNames ?? []) {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.DeleteUserPolicyCommand({\n\t\t\t\t\t\tUserName: name,\n\t\t\t\t\t\tPolicyName: policy,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst attached = await iam.send(\n\t\t\t\tnew IAM.ListAttachedUserPoliciesCommand({ UserName: name }),\n\t\t\t);\n\t\t\tfor (const policy of attached.AttachedPolicies ?? []) {\n\t\t\t\tawait iam.send(\n\t\t\t\t\tnew IAM.DetachUserPolicyCommand({\n\t\t\t\t\t\tUserName: name,\n\t\t\t\t\t\tPolicyArn: policy.PolicyArn,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait iam.send(new IAM.DeleteUserCommand({ UserName: name }));\n\t\t},\n\t};\n}\n\n/** Every object version and delete marker in a bucket, a page at a time. */\nasync function* bucketVersions({ S3, s3 }: S3Clients, bucket: string) {\n\tlet KeyMarker: string | undefined;\n\tlet VersionIdMarker: string | undefined;\n\tfor (;;) {\n\t\tconst page = await s3.send(\n\t\t\tnew S3.ListObjectVersionsCommand({\n\t\t\t\tBucket: bucket,\n\t\t\t\t...(KeyMarker ? { KeyMarker } : {}),\n\t\t\t\t...(VersionIdMarker ? { VersionIdMarker } : {}),\n\t\t\t}),\n\t\t);\n\t\tconst objects = [...(page.Versions ?? []), ...(page.DeleteMarkers ?? [])]\n\t\t\t.filter((o) => o.Key)\n\t\t\t.map((o) => ({\n\t\t\t\tKey: o.Key!,\n\t\t\t\t// `null` is the one version an unversioned bucket's object has:\n\t\t\t\t// named or not, the same object is deleted.\n\t\t\t\t...(o.VersionId && o.VersionId !== 'null'\n\t\t\t\t\t? { VersionId: o.VersionId }\n\t\t\t\t\t: {}),\n\t\t\t}));\n\t\tif (objects.length > 0) yield objects;\n\t\tif (!page.IsTruncated) return;\n\t\tKeyMarker = page.NextKeyMarker;\n\t\tVersionIdMarker = page.NextVersionIdMarker;\n\t}\n}\n\nasync function bucketStep(\n\tclients: S3Clients,\n\trecord: ResourceRecord,\n\tinput: AwsDestroyInput,\n): Promise<AwsDestroyStep> {\n\tconst { S3, s3 } = clients;\n\tconst bucket = record.id ?? '';\n\tconst tagging = await readOr(\n\t\t() => s3.send(new S3.GetBucketTaggingCommand({ Bucket: bucket })),\n\t\t['NoSuchBucket', 'NoSuchTagSet', 'NoSuchTagSetError'],\n\t);\n\tconst exists = await readOr(\n\t\t() => s3.send(new S3.HeadBucketCommand({ Bucket: bucket })),\n\t\t['NotFound', 'NoSuchBucket'],\n\t);\n\tconst base = `S3 bucket ${bucket}`;\n\tif (!exists) return { key: record.key, label: base, gone: true };\n\tif (!ours(tagging?.TagSet, input)) {\n\t\treturn { key: record.key, label: base, leftAlone: NOT_TAGGED };\n\t}\n\tlet count = 0;\n\tfor await (const page of bucketVersions(clients, bucket))\n\t\tcount += page.length;\n\treturn {\n\t\tkey: record.key,\n\t\tlabel: `${base}, emptied first: ${count} object version${count === 1 ? '' : 's'}`,\n\t\tremove: async () => {\n\t\t\t// Until it lists nothing: deleting a version-less object in a bucket\n\t\t\t// whose versioning was suspended leaves a delete marker behind.\n\t\t\tfor (let pass = 0; pass < 5; pass++) {\n\t\t\t\tlet deleted = 0;\n\t\t\t\tfor await (const page of bucketVersions(clients, bucket)) {\n\t\t\t\t\t// At most a thousand a call.\n\t\t\t\t\tfor (let i = 0; i < page.length; i += 1000) {\n\t\t\t\t\t\tawait s3.send(\n\t\t\t\t\t\t\tnew S3.DeleteObjectsCommand({\n\t\t\t\t\t\t\t\tBucket: bucket,\n\t\t\t\t\t\t\t\tDelete: { Objects: page.slice(i, i + 1000), Quiet: true },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tdeleted += page.length;\n\t\t\t\t}\n\t\t\t\tif (deleted === 0) break;\n\t\t\t}\n\t\t\tawait s3.send(new S3.DeleteBucketCommand({ Bucket: bucket }));\n\t\t},\n\t};\n}\n","/**\n * `gkm compose --stage <stage> --destroy`: everything a deploy made for the\n * stage, deleted for good.\n *\n * The one thing in gkm that deletes what a deploy created — a deploy itself\n * never does. So it is careful in three ways:\n *\n * - **Only what is provably gkm's.** Each AWS resource is checked against\n * what gkm marks its own with before it is deleted (see\n * `providers/s3/destroy.ts`); a DNS record only while it still holds the\n * value gkm wrote. What fails is listed, and left where it is.\n * - **Only with a person typing the stage.** The whole plan is printed\n * first, then the compose project's name — `<project>-<stage>` — has to be\n * typed back. Nothing skips that: there is no flag that answers it, and\n * with no terminal to ask at it refuses before reading anything.\n * - **Resumable.** Each resource's record is forgotten as soon as it is gone,\n * so a run that stops part way — a distribution still deploying — carries\n * on from there when it is run again.\n *\n * What other stages or projects share is never touched: the project bucket\n * that holds every stage's state, the shared Traefik edge, the server's own\n * setup (`gkm compose:server`). The stage's secrets are kept unless\n * `--secrets` is passed.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { loadWorkspaceConfig } from '../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../deploy/credentials.js';\nimport { dnsRecordFqdn, dnsResources } from '../deploy/dnsResources.js';\nimport { deployIdentity } from '../deploy/identity.js';\nimport { createStateStore, type StateStore } from '../deploy/StateStore.js';\nimport { GkmError } from '../errors';\nimport { canPrompt, prompt } from '../prompt';\nimport {\n\ttype AwsProvisioning,\n\tawsProvisioningCredentials,\n} from '../providers/aws.js';\nimport {\n\tAWS_RESOURCE_TYPES,\n\ttype AwsDestroyInput,\n\ttype AwsDestroyStep,\n\tplanAwsDestroy,\n} from '../providers/s3/destroy.js';\nimport { secretsStoreFor } from '../secrets/store.js';\nimport { stackOverrideFile } from '../target/compose/index';\nimport type { DnsProvider } from '../target/dokploy/dns/DnsProvider.js';\nimport {\n\textractSubdomain,\n\tfindRootDomain,\n\tnormalizeDnsConfig,\n} from '../target/dokploy/dns/index.js';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport type {\n\tDnsProvider as DnsProviderConfig,\n\tNormalizedWorkspace,\n} from '../workspace/types.js';\nimport {\n\tdnsCredentials,\n\tpruneStackDns,\n\ttype RecordedDnsRecord,\n\trecordTtl,\n} from './dns';\nimport { type ComposeDocker, dockerCompose, type StackRef } from './docker';\nimport { edgeRef, removeEdgeRoutes } from './edge';\nimport { composeServer, dockerHost, sshTarget } from './server';\nimport { composeProject, stackDir } from './stack';\nimport { EDGE_PROJECT } from './traefik';\n\nexport interface ComposeDestroyOptions {\n\tcwd?: string;\n\tstage: string;\n\t/** Delete the stage's secrets too. Kept otherwise. */\n\tsecrets?: boolean;\n\t/** Print what would be deleted; delete nothing, ask nothing. */\n\tdryRun?: boolean;\n}\n\nexport interface ComposeDestroyDeps {\n\tdocker?: ComposeDocker;\n\t/** Whether a person is at a terminal to answer. */\n\tinteractive?: () => boolean;\n\t/** Ask the person, and resolve with what they typed. */\n\task?: (question: string) => Promise<string>;\n\t/** Where the DNS providers' tokens come from. */\n\tcredentials?: CredentialProvider;\n\t/** The provider for a domain — `createDnsProvider` by default. */\n\tdnsProviderFor?: (config: DnsProviderConfig) => Promise<DnsProvider | null>;\n\t/**\n\t * How the AWS account's credential is found — the machine's, as a deploy\n\t * finds it, by default.\n\t */\n\tawsCredentials?: () => Promise<AwsProvisioning | undefined>;\n\t/** For tests: the AWS clients and how long a distribution is waited on. */\n\taws?: Pick<AwsDestroyInput, 'clients' | 'wait'>;\n\tstate?: StateStore;\n\tenv?: NodeJS.ProcessEnv;\n\thome?: string;\n\tlog?: (line: string) => void;\n}\n\n/** A destroy with no terminal to type the stage's name at. */\nexport class ComposeDestroyNeedsTerminal extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`Destroying '${stage}' deletes everything its deploys made, and asks you to ` +\n\t\t\t\t`type ${project} first — there is no terminal here to ask at, and no flag ` +\n\t\t\t\t'answers it. Run it yourself, from a terminal. `--dry-run` prints what it ' +\n\t\t\t\t'would delete, anywhere.',\n\t\t);\n\t\tthis.name = 'ComposeDestroyNeedsTerminal';\n\t}\n}\n\n/** What was typed was not the project's name. */\nexport class ComposeDestroyNotConfirmed extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly project: string,\n\t) {\n\t\tsuper(\n\t\t\t`Nothing was deleted: destroying '${stage}' needs ${project} typed exactly.`,\n\t\t);\n\t\tthis.name = 'ComposeDestroyNotConfirmed';\n\t}\n}\n\n/** AWS resources to delete, and no credentials to delete them with. */\nexport class ComposeDestroyNeedsAwsCredentials extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly resources: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${stage}' has ${resources.length} AWS resource${resources.length === 1 ? '' : 's'} ` +\n\t\t\t\t`to delete (${resources.slice(0, 3).join(', ')}${resources.length > 3 ? ', …' : ''}), ` +\n\t\t\t\t\"and no AWS credentials were found to delete them with. Supply the stage's \" +\n\t\t\t\t'account the way a deploy does — AWS_PROFILE, or AWS_ACCESS_KEY_ID and ' +\n\t\t\t\t'AWS_SECRET_ACCESS_KEY — and run it again. Nothing was deleted.',\n\t\t);\n\t\tthis.name = 'ComposeDestroyNeedsAwsCredentials';\n\t}\n}\n\n/** `--secrets`, and a store that cannot delete. */\nexport class SecretsStoreCannotDelete extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly store: string,\n\t) {\n\t\tsuper(\n\t\t\t`--secrets deletes '${stage}''s secrets, and its store (${store}) has no ` +\n\t\t\t\t'delete(stage). Give the custom store one, or run without --secrets and ' +\n\t\t\t\t'delete them where they are kept. Nothing was deleted.',\n\t\t);\n\t\tthis.name = 'SecretsStoreCannotDelete';\n\t}\n}\n\n/** One line of the plan, and how it is carried out. */\ninterface Step {\n\tlabel: string;\n\tleftAlone?: string;\n\t/** Forgotten from the stage's state once done. */\n\tkeys?: string[];\n\trun?: () => Promise<void>;\n}\n\n/** What a record of each type is to destroy. */\nconst KEPT_TYPES: Record<string, string> = {\n\t// The server's setup — its users, firewall, Docker — is the server's.\n\tserver:\n\t\t\"the server's setup is kept: gkm compose:server made it, for any stage\",\n};\n\n/** Records that name no resource of their own — a key in the secrets. */\nconst VALUE_TYPES = new Set(['url', 'email-from']);\n\n/**\n * The stage's stack: its project on the server (or this machine), as\n * `gkm compose --down` finds it.\n */\nexport async function composeStackRef(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n): Promise<{\n\tref: StackRef;\n\tdir: string;\n\tserver?: ReturnType<typeof composeServer>;\n}> {\n\tconst local = stage === workspace.stages.local;\n\tconst server = local\n\t\t? undefined\n\t\t: composeServer({\n\t\t\t\tstage,\n\t\t\t\tlocal,\n\t\t\t\tconfig: workspace.deploy?.compose?.server,\n\t\t\t\tcustom: (await (await secretsStoreFor(workspace, stage)).read(stage))\n\t\t\t\t\t?.custom,\n\t\t\t});\n\tconst override = stackOverrideFile(workspace.root, stage);\n\tconst dir = join(workspace.root, stackDir(stage));\n\tconst ref: StackRef = {\n\t\tproject: composeProject(deployIdentity(workspace, stage)),\n\t\tfile: join(dir, 'docker-compose.yml'),\n\t\t...(existsSync(override) ? { overrides: [override] } : {}),\n\t\tcwd: workspace.root,\n\t\t...(server ? { host: dockerHost(server) } : {}),\n\t};\n\treturn { ref, dir, ...(server ? { server } : {}) };\n}\n\n/** `gkm compose --stage <stage> --destroy`. */\nexport async function composeDestroyCommand(\n\toptions: ComposeDestroyOptions,\n\tdeps: ComposeDestroyDeps = {},\n): Promise<void> {\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\tconst env = deps.env ?? process.env;\n\tconst cwd = resolve(options.cwd ?? process.cwd());\n\tconst { workspace } = await loadWorkspaceConfig(cwd);\n\tconst { stage } = options;\n\tconst local = stage === workspace.stages.local;\n\tif (!local) assertDeployedStage(workspace.stages, stage);\n\n\tconst identity = deployIdentity(workspace, stage);\n\tconst project = composeProject(identity);\n\tconst interactive = deps.interactive ?? canPrompt;\n\tif (!options.dryRun && !interactive()) {\n\t\tthrow new ComposeDestroyNeedsTerminal(stage, project);\n\t}\n\n\tconst state =\n\t\tdeps.state ??\n\t\t(await createStateStore({\n\t\t\tconfig: local ? undefined : workspace.state,\n\t\t\tworkspaceRoot: workspace.root,\n\t\t\tworkspaceName: workspace.name,\n\t\t\tnamespace: workspace.deploy?.namespace,\n\t\t}));\n\t// Held throughout: a deploy of the stage while it is torn down would\n\t// make what this is deleting.\n\tconst lock = options.dryRun\n\t\t? undefined\n\t\t: await state.lock(stage, { operation: 'destroy' });\n\ttry {\n\t\tconst steps = await plan(workspace, stage, options, deps, state, env);\n\t\tconst { ref } = await composeStackRef(workspace, stage);\n\n\t\tlog(\n\t\t\t`\\n🧨 ${options.dryRun ? 'Would delete' : 'This deletes'} stage '${stage}' of ${workspace.name} for good:\\n`,\n\t\t);\n\t\tconst doing = steps.filter((s) => !s.leftAlone);\n\t\tconst kept = steps.filter((s) => s.leftAlone);\n\t\tfor (const step of doing) log(` - ${step.label}`);\n\t\tif (kept.length > 0) {\n\t\t\tlog('\\n Left where it is:');\n\t\t\tfor (const step of kept) log(` · ${step.label} — ${step.leftAlone}`);\n\t\t}\n\t\tif (!options.secrets) {\n\t\t\tlog(\n\t\t\t\t\"\\n The stage's secrets are kept: a deploy of it again reuses them. --secrets deletes them too.\",\n\t\t\t);\n\t\t}\n\n\t\tif (options.dryRun) {\n\t\t\tlog('\\n--dry-run: nothing was deleted.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst ask =\n\t\t\tdeps.ask ??\n\t\t\t((question: string) =>\n\t\t\t\tprompt(question, {\n\t\t\t\t\tinstead: 'Run it yourself, from a terminal.',\n\t\t\t\t}));\n\t\tconst typed = await ask(`\\n Type ${project} to destroy it: `);\n\t\tif (typed.trim() !== project) {\n\t\t\tthrow new ComposeDestroyNotConfirmed(stage, project);\n\t\t}\n\n\t\tlog('');\n\t\tfor (const step of doing) {\n\t\t\tawait step.run?.();\n\t\t\tfor (const key of step.keys ?? []) {\n\t\t\t\tawait state.deleteResource(stage, key);\n\t\t\t}\n\t\t\tlog(` ✓ ${step.label}`);\n\t\t}\n\t\tlog(`\\n💥 '${stage}' destroyed. ${ref.project} is gone.`);\n\t} finally {\n\t\tawait lock?.release();\n\t}\n}\n\n/** Every step, in the order it is carried out. */\nasync function plan(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n\toptions: ComposeDestroyOptions,\n\tdeps: ComposeDestroyDeps,\n\tstate: StateStore,\n\tenv: NodeJS.ProcessEnv,\n): Promise<Step[]> {\n\tconst steps: Step[] = [];\n\tconst resources = (await state.read(stage))?.resources ?? {};\n\tconst records = Object.values(resources);\n\n\t// ── The stack: containers, volumes, its routes on the edge ─────────────\n\tconst { ref, dir, server } = await composeStackRef(workspace, stage);\n\tconst docker = deps.docker ?? dockerCompose;\n\tsteps.push({\n\t\tlabel: `${server ? `on ${sshTarget(server)}: ` : ''}stack ${ref.project} — its containers, its volumes and their data, its routes on ${EDGE_PROJECT}`,\n\t\trun: async () => {\n\t\t\tconst edgeFile = join(dir, `${EDGE_PROJECT}.yml`);\n\t\t\tif (server || existsSync(edgeFile)) {\n\t\t\t\tawait removeEdgeRoutes(\n\t\t\t\t\tdocker,\n\t\t\t\t\tedgeRef(edgeFile, { host: ref.host }),\n\t\t\t\t\tref.project,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait docker.down(ref, { volumes: true });\n\t\t},\n\t});\n\n\t// ── AWS ─────────────────────────────────────────────────────────────────\n\tconst aws = records.filter((r) =>\n\t\t(AWS_RESOURCE_TYPES as readonly string[]).includes(r.type),\n\t);\n\tlet cdnDns: RecordedDnsRecord[] = [];\n\tif (aws.length > 0) {\n\t\tconst credential = await (\n\t\t\tdeps.awsCredentials ??\n\t\t\t(() =>\n\t\t\t\tawsProvisioningCredentials({\n\t\t\t\t\tstage,\n\t\t\t\t\tenv,\n\t\t\t\t\t...(deps.home ? { home: deps.home } : {}),\n\t\t\t\t}))\n\t\t)();\n\t\tif (!credential) {\n\t\t\tthrow new ComposeDestroyNeedsAwsCredentials(\n\t\t\t\tstage,\n\t\t\t\taws.map((r) => r.key),\n\t\t\t);\n\t\t}\n\t\tconst identity = deployIdentity(workspace, stage);\n\t\tconst planned = await planAwsDestroy({\n\t\t\tresources,\n\t\t\tidentityKey: identity.key,\n\t\t\tscope: identity.scope,\n\t\t\tstage,\n\t\t\tcredential,\n\t\t\t...(deps.aws ?? {}),\n\t\t});\n\t\tfor (const step of planned.steps) steps.push(awsStep(step));\n\t\tcdnDns = providerDnsRecords(workspace, planned.dns);\n\t}\n\n\t// ── DNS: what the stage recorded, and what its CDN was given ───────────\n\tconst recorded = dnsResources(resources).map((r) => ({\n\t\t...r,\n\t\tfqdn: r.fqdn || dnsRecordFqdn(r.domain, r.name),\n\t}));\n\tconst seen = new Set(recorded.map((r) => `${r.fqdn} ${r.type}`));\n\tconst dnsRecords: RecordedDnsRecord[] = [\n\t\t...recorded,\n\t\t...cdnDns.filter((r) => !seen.has(`${r.fqdn} ${r.type}`)),\n\t];\n\tif (dnsRecords.length > 0) {\n\t\t// The providers' tokens are read now: a missing one stops the destroy\n\t\t// before anything is deleted, rather than after the stack is gone.\n\t\tconst dns = workspace.dns ? normalizeDnsConfig(workspace.dns) : {};\n\t\tconst domains = [...new Set(dnsRecords.map((r) => r.domain))]\n\t\t\t.filter((domain) => dns[domain])\n\t\t\t.map((domain) => ({ domain, config: dns[domain]! }));\n\t\tconst tokens = await dnsCredentials(\n\t\t\tstage,\n\t\t\tdomains,\n\t\t\tdeps.credentials ?? storedCredentials({ env }),\n\t\t);\n\t\tconst log = deps.log ?? ((line: string) => console.log(line));\n\t\tsteps.push({\n\t\t\tlabel: `DNS: ${dnsRecords.map((r) => `${r.type} ${r.fqdn}`).join(', ')} — each only while it holds the value gkm wrote`,\n\t\t\tkeys: recorded.map(\n\t\t\t\t(r) => `dns-record:${r.fqdn.toLowerCase()}:${r.type.toUpperCase()}`,\n\t\t\t),\n\t\t\trun: async () => {\n\t\t\t\tawait pruneStackDns(dnsRecords, {\n\t\t\t\t\tstage,\n\t\t\t\t\tdns: workspace.dns,\n\t\t\t\t\tlog,\n\t\t\t\t\tcredentials: {\n\t\t\t\t\t\t...(tokens.godaddy ? { credential: tokens.godaddy } : {}),\n\t\t\t\t\t\tlog,\n\t\t\t\t\t},\n\t\t\t\t\t...(tokens.hostinger ? { hostinger: tokens.hostinger } : {}),\n\t\t\t\t\t...(deps.dnsProviderFor ? { providerFor: deps.dnsProviderFor } : {}),\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\t}\n\n\t// ── What gkm cannot delete, and what names nothing ──────────────────────\n\tconst handled = new Set<string>([\n\t\t...(AWS_RESOURCE_TYPES as readonly string[]),\n\t\t'dns-record',\n\t]);\n\tconst values = records.filter((r) => VALUE_TYPES.has(r.type));\n\tfor (const record of records) {\n\t\tif (handled.has(record.type) || VALUE_TYPES.has(record.type)) continue;\n\t\tsteps.push({\n\t\t\tlabel: `${record.type} ${record.id ?? record.key}`,\n\t\t\tleftAlone:\n\t\t\t\tKEPT_TYPES[record.type] ??\n\t\t\t\t`gkm does not delete a ${record.type} yet: delete it by hand`,\n\t\t});\n\t}\n\n\t// ── The stage's secrets ────────────────────────────────────────────────\n\tif (options.secrets) {\n\t\tconst store = await secretsStoreFor(workspace, stage, {\n\t\t\t...(deps.home ? { home: deps.home } : {}),\n\t\t});\n\t\tif (!store.delete) throw new SecretsStoreCannotDelete(stage, store.name);\n\t\tsteps.push({\n\t\t\tlabel: `the stage's secrets, in its ${store.name} store`,\n\t\t\t// The keys the deleted resources were reached by go with them.\n\t\t\tkeys: values.map((r) => r.key),\n\t\t\trun: () => store.delete!(stage),\n\t\t});\n\t} else if (values.length > 0) {\n\t\t// Their resources are gone; the keys stay in the kept secrets, and a\n\t\t// deploy writes them again.\n\t\tsteps.push({\n\t\t\tlabel: `${values.length} record${values.length === 1 ? '' : 's'} of keys written into the secrets`,\n\t\t\tkeys: values.map((r) => r.key),\n\t\t});\n\t}\n\n\treturn steps;\n}\n\nfunction awsStep(step: AwsDestroyStep): Step {\n\tif (step.leftAlone) return { label: step.label, leftAlone: step.leftAlone };\n\treturn {\n\t\tlabel: step.gone\n\t\t\t? `${step.label} (already gone)`\n\t\t\t: step.withUser\n\t\t\t\t? `${step.label} — deleted with its user`\n\t\t\t\t: step.label,\n\t\tkeys: [step.key],\n\t\t...(step.remove ? { run: step.remove } : {}),\n\t};\n}\n\n/** The CDN's records, as the DNS prune takes them. */\nfunction providerDnsRecords(\n\tworkspace: NormalizedWorkspace,\n\trecords: readonly { host: string; type: 'CNAME'; value: string }[],\n): RecordedDnsRecord[] {\n\tconst dns = workspace.dns ? normalizeDnsConfig(workspace.dns) : {};\n\tconst out: RecordedDnsRecord[] = [];\n\tfor (const record of records) {\n\t\tconst host = record.host.toLowerCase().replace(/\\.$/, '');\n\t\tconst domain = findRootDomain(host, dns);\n\t\tif (!domain) continue;\n\t\tconst config = dns[domain]!;\n\t\tout.push({\n\t\t\tfqdn: host,\n\t\t\tdomain,\n\t\t\tname: extractSubdomain(host, domain),\n\t\t\ttype: record.type,\n\t\t\tvalue: record.value.replace(/\\.$/, ''),\n\t\t\tttl: recordTtl(config),\n\t\t\t...(typeof config.provider === 'string'\n\t\t\t\t? { provider: config.provider }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\treturn out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8EA,MAAa,qBAAqB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAGA,MAAM,eAAe;CAAE,WAAW;CAAa,YAAY;AAAO;;AAGlE,IAAa,6BAAb,cAAgD,SAAS;CAE9C;CACA;CAFV,YACC,IACA,UACC;EACD,MACC,2BAA2B,GAAG,8CAC1B,KAAK,MAAM,WAAW,GAAM,EAAE,yLAInC;EATS,KAAA,KAAA;EACA,KAAA,WAAA;EAST,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,UAAU,OAAwB;CAC1C,MAAM,IAAI;CACV,OAAO,GAAG,QAAQ,GAAG,QAAQ;AAC9B;;AAGA,eAAe,OACd,MACA,SACyB;CACzB,IAAI;EACH,OAAO,MAAM,KAA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AAK,MAAM,UAAU,SAAS;EAC7B,MAAM,OAAO,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,OAAO,EAAE;EACxD,MAAM,SAAS,eAAe,MAAM,GAAG;EACvC,IAAI,CAAC,QAAQ;EACb,MAAM,SAAS,IAAI;EACnB,IAAI,KAAK;GACR,MAAM;GACN;GACA,MAAM,iBAAiB,MAAM,MAAM;GACnC,MAAM,OAAO;GACb,OAAO,OAAO,MAAM,QAAQ,OAAO,EAAE;GACrC,KAAK,UAAU,MAAM;GACrB,GAAI,OAAO,OAAO,aAAa,WAC5B,EAAE,UAAU,OAAO,SAAS,IAC5B,CAAC;EACL,CAAC;CACF;CACA,OAAO;AACR"}
|
|
@@ -43,15 +43,15 @@ function eventsEdgeBucket(edge) {
|
|
|
43
43
|
* connection string, or its bucket's events connection string.
|
|
44
44
|
*/
|
|
45
45
|
function subscriberConnectionKey(construct) {
|
|
46
|
-
if (construct.bucketName) return (0, _geekmidas_manifest.
|
|
47
|
-
if (construct.topicName) return (0, _geekmidas_manifest.
|
|
46
|
+
if (construct.bucketName) return (0, _geekmidas_manifest.providedKeyFor)((0, _geekmidas_manifest.canonicalId)(construct.bucketName), "objects", "eventsConnectionString");
|
|
47
|
+
if (construct.topicName) return (0, _geekmidas_manifest.providedKeyFor)((0, _geekmidas_manifest.canonicalId)(construct.topicName), "topic", "publisherConnectionString");
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* The key a bucket's relay token is read from, by the process that runs the
|
|
51
51
|
* bucket's subscribers — beside its events connection string.
|
|
52
52
|
*/
|
|
53
53
|
function subscriberTokenKey(construct) {
|
|
54
|
-
return construct.bucketName ? (0, _geekmidas_manifest.
|
|
54
|
+
return construct.bucketName ? (0, _geekmidas_manifest.providedKeyFor)((0, _geekmidas_manifest.canonicalId)(construct.bucketName), "objects", "eventsToken") : void 0;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* What a worker's process reaches: the worker's own edges, and those of
|
|
@@ -818,7 +818,7 @@ function nestRunnables(manifest, found, cwd) {
|
|
|
818
818
|
id: exportName,
|
|
819
819
|
handler,
|
|
820
820
|
dependencies: edges(construct.constructs),
|
|
821
|
-
provides: [(0, _geekmidas_manifest.
|
|
821
|
+
provides: [(0, _geekmidas_manifest.providedKeyFor)(exportName, "function", "url")],
|
|
822
822
|
...ownerOf(construct)
|
|
823
823
|
};
|
|
824
824
|
continue;
|
|
@@ -1082,4 +1082,4 @@ Object.defineProperty(exports, "workerEdges", {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
});
|
|
1084
1084
|
|
|
1085
|
-
//# sourceMappingURL=discover-
|
|
1085
|
+
//# sourceMappingURL=discover-39VKSE2i.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-39VKSE2i.cjs","names":["providedKeyFor","canonicalId","dependenciesOf","AsyncLocalStorage","format","fg","kebabCase","relative","GkmError","existsSync","realpathSync","resolve","relative","sep","isAbsolute","AsyncLocalStorage","dirname","fileURLToPath","join","existsSync","pathToFileURL","dirname","fileURLToPath","join","existsSync","pathToFileURL","createRequire","WORKER_RESULT_MARKER","fg","Processor","canonicalId","relative","Cron","Queue","Subscriber","GkmError","Endpoint","WebSocketRoute","Function","providedKeyFor"],"sources":["../src/reconcile/edges.ts","../src/output.ts","../src/generators/Generator.ts","../src/sandbox/sandbox.ts","../src/owningTsconfigJsx.ts","../src/sandbox/worker.ts","../src/reconcile/discover.ts"],"sourcesContent":["/**\n * Edges a process records for what its runnables consume, beyond the\n * construct ids `.dependsOn()` names.\n */\n\nimport {\n\ttype ConstructManifest,\n\tcanonicalId,\n\tdependenciesOf,\n\ttype Fn,\n\tprovidedKeyFor,\n} from '@geekmidas/manifest';\n\nconst EVENTS_SUFFIX = '#events';\n\n/**\n * A bucket's events, as an edge: what a process running one of the bucket's\n * subscribers consumes. Not the bucket's id — binding to a bucket's changes\n * is not reading its objects, so the process is handed the events key alone.\n */\nexport function eventsEdge(bucketId: string): string {\n\treturn `${bucketId}${EVENTS_SUFFIX}`;\n}\n\n/** The bucket an events edge names, or nothing for any other edge. */\nexport function eventsEdgeBucket(edge: string): string | undefined {\n\treturn edge.endsWith(EVENTS_SUFFIX)\n\t\t? edge.slice(0, -EVENTS_SUFFIX.length)\n\t\t: undefined;\n}\n\n/**\n * The env key a subscriber's deliveries come from: its topic's publisher\n * connection string, or its bucket's events connection string.\n */\nexport function subscriberConnectionKey(construct: {\n\ttopicName?: string;\n\tbucketName?: string;\n}): string | undefined {\n\tif (construct.bucketName) {\n\t\treturn providedKeyFor(\n\t\t\tcanonicalId(construct.bucketName),\n\t\t\t'objects',\n\t\t\t'eventsConnectionString',\n\t\t);\n\t}\n\tif (construct.topicName) {\n\t\treturn providedKeyFor(\n\t\t\tcanonicalId(construct.topicName),\n\t\t\t'topic',\n\t\t\t'publisherConnectionString',\n\t\t);\n\t}\n\treturn undefined;\n}\n\n/**\n * The key a bucket's relay token is read from, by the process that runs the\n * bucket's subscribers — beside its events connection string.\n */\nexport function subscriberTokenKey(construct: {\n\tbucketName?: string;\n}): string | undefined {\n\treturn construct.bucketName\n\t\t? providedKeyFor(\n\t\t\t\tcanonicalId(construct.bucketName),\n\t\t\t\t'objects',\n\t\t\t\t'eventsToken',\n\t\t\t)\n\t\t: undefined;\n}\n\n/**\n * What a worker's process reaches: the worker's own edges, and those of\n * everything it owns — its crons and functions, its queue consumers and the\n * queue each drains, its subscribers and the topic each is bound to, or the\n * events of the bucket each watches.\n *\n * Read off the manifest: the same nodes every command sees, so `gkm dev`\n * hands a worker what a deploy grants it.\n */\nexport function workerEdges(\n\tmanifest: ConstructManifest,\n\tworkerId: string,\n): string[] {\n\tconst worker = manifest[workerId];\n\tif (worker?.kind !== 'worker') return [];\n\n\tconst edges = dependenciesOf(worker).map((edge) => edge.target);\n\tconst owned = (fn: Fn | undefined, consumed?: string) => {\n\t\tif (fn?.owner !== workerId) return;\n\t\tedges.push(...fn.dependencies.map((edge) => edge.target));\n\t\tif (consumed) edges.push(consumed);\n\t};\n\n\tfor (const declaration of Object.values(manifest)) {\n\t\tswitch (declaration.kind) {\n\t\t\tcase 'cron':\n\t\t\tcase 'function':\n\t\t\t\towned(declaration);\n\t\t\t\tbreak;\n\t\t\tcase 'queue':\n\t\t\t\towned(declaration.worker, declaration.id);\n\t\t\t\tbreak;\n\t\t\tcase 'topic':\n\t\t\t\tfor (const s of declaration.subscribers) owned(s, declaration.id);\n\t\t\t\tbreak;\n\t\t\tcase 'objects':\n\t\t\t\tfor (const s of declaration.subscribers ?? []) {\n\t\t\t\t\towned(s, eventsEdge(declaration.id));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn [...new Set(edges)];\n}\n","/**\n * Where the CLI's progress lines go.\n *\n * Commands write their progress through `output` rather than `console`. Run\n * from the terminal that is the same thing. Run inside `deploy()`, each line\n * goes to the run that wrote it instead — as an event its caller can iterate,\n * and to the logger it was handed — so a deploy embedded in another program\n * does not print over that program's own output.\n *\n * Carried by `AsyncLocalStorage` rather than passed down, because the lines\n * come from everywhere a deploy reaches — the Dockerfile generator, the env\n * sniffer, construct discovery — and two deploys running in one process must\n * not hear each other.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { format } from 'node:util';\n\n/** How loud a line is. */\nexport type OutputLevel = 'info' | 'warn' | 'error';\n\n/** Receives each line written while it is the current sink. */\nexport type OutputSink = (level: OutputLevel, message: string) => void;\n\nconst current = new AsyncLocalStorage<OutputSink>();\n\n/** Runs `fn` with every line written through `output` sent to `sink`. */\nexport function withOutput<T>(sink: OutputSink, fn: () => T): T {\n\treturn current.run(sink, fn);\n}\n\nfunction write(\n\tlevel: OutputLevel,\n\tfallback: (...args: unknown[]) => void,\n): (...args: unknown[]) => void {\n\treturn (...args) => {\n\t\tconst sink = current.getStore();\n\t\tif (sink) sink(level, format(...args));\n\t\telse fallback(...args);\n\t};\n}\n\n/**\n * `console`, for the methods the CLI logs through — routed to the current\n * run's sink when there is one.\n */\nexport const output = {\n\tlog: write('info', (...args) => console.log(...args)),\n\tinfo: write('info', (...args) => console.info(...args)),\n\twarn: write('warn', (...args) => console.warn(...args)),\n\terror: write('error', (...args) => console.error(...args)),\n};\n","import { relative } from 'node:path';\nimport type { Construct } from '@geekmidas/constructs';\nimport fg from 'fast-glob';\nimport kebabCase from 'lodash.kebabcase';\nimport type { BuildContext } from '../build/types';\nimport type { MainProvider, Routes } from '../types';\n\n/**\n * Zod v4 maintains a process-wide registry of schemas registered via\n * `.meta({ id })`. When we cache-bust user module imports (by appending a\n * `?t=timestamp` query), those modules re-execute and try to register the\n * same ids again, which throws `ID X already exists in the registry`.\n *\n * Clearing the registry in the CLI process is safe: the user's running\n * server lives in a subprocess and has its own isolated registry.\n *\n * Exported for tests.\n */\nexport function clearZodGlobalRegistry(): void {\n\tconst registry = (\n\t\tglobalThis as { __zod_globalRegistry?: { clear?: () => void } }\n\t).__zod_globalRegistry;\n\tif (registry && typeof registry.clear === 'function') {\n\t\tregistry.clear();\n\t}\n}\n\nexport interface GeneratorOptions {\n\t/** Where the build deploys: one Lambda per construct, or one process. */\n\ttarget?: MainProvider;\n\t/**\n\t * What a handler path in the manifest is relative to — the workspace root,\n\t * which is where `sst.config.ts` runs and resolves it from.\n\t */\n\troot?: string;\n\t[key: string]: any;\n}\n\nexport abstract class ConstructGenerator<T extends Construct, R = void> {\n\tabstract isConstruct(value: any): value is T;\n\n\tstatic async build<T extends Construct, R = void>(\n\t\tcontext: BuildContext,\n\t\toutputDir: string,\n\t\tgenerator: ConstructGenerator<T, R>,\n\t\tpatterns?: Routes,\n\t\toptions?: GeneratorOptions,\n\t): Promise<R> {\n\t\tconst constructs = await generator.load(patterns);\n\t\treturn generator.build(context, constructs, outputDir, options);\n\t}\n\n\tabstract build(\n\t\tcontext: BuildContext,\n\t\tconstructs: GeneratedConstruct<T>[],\n\t\toutputDir: string,\n\t\toptions?: GeneratorOptions,\n\t): Promise<R>;\n\n\tasync load(\n\t\tpatterns?: Routes,\n\t\tcwd = process.cwd(),\n\t\tbustCache = false,\n\t): Promise<GeneratedConstruct<T>[]> {\n\t\tconst logger = console;\n\n\t\tconst globPatterns = Array.isArray(patterns)\n\t\t\t? patterns\n\t\t\t: patterns\n\t\t\t\t? [patterns]\n\t\t\t\t: [];\n\n\t\t// Find all files\n\t\tconst files = fg.stream(globPatterns, {\n\t\t\tcwd,\n\t\t\tabsolute: true,\n\t\t});\n\n\t\t// Cache-busted re-imports re-execute user modules, which would try to\n\t\t// re-register Zod schemas with the same `.meta({ id })`. Clear the\n\t\t// global registry once per load to prevent duplicate-id errors.\n\t\tif (bustCache) {\n\t\t\tclearZodGlobalRegistry();\n\t\t}\n\n\t\t// Load constructs\n\t\tconst constructs: GeneratedConstruct<T>[] = [];\n\n\t\tfor await (const f of files) {\n\t\t\ttry {\n\t\t\t\tconst file = f.toString();\n\t\t\t\t// Append cache-busting query param to force re-import of changed modules\n\t\t\t\tconst importPath = bustCache ? `${file}?t=${Date.now()}` : file;\n\t\t\t\tconst module = await import(importPath);\n\n\t\t\t\t// Check all exports for constructs\n\t\t\t\tfor (const [key, construct] of Object.entries(module)) {\n\t\t\t\t\tif (this.isConstruct(construct)) {\n\t\t\t\t\t\tconstructs.push({\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tname: kebabCase(key),\n\t\t\t\t\t\t\tconstruct,\n\t\t\t\t\t\t\tpath: {\n\t\t\t\t\t\t\t\tabsolute: file,\n\t\t\t\t\t\t\t\trelative: relative(process.cwd(), file),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst err = error as Error;\n\t\t\t\tlogger.error(`Failed to load ${f}: ${err.message}`);\n\t\t\t\tif (err.stack) {\n\t\t\t\t\tlogger.error(err.stack);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn constructs;\n\t}\n}\n\nexport interface GeneratedConstruct<T extends Construct> {\n\tkey: string;\n\tname: string;\n\tconstruct: T;\n\tpath: {\n\t\tabsolute: string;\n\t\trelative: string;\n\t};\n}\n","/**\n * Where a deploy runs the project's own code.\n *\n * A deploy holds credentials — Dokploy's token, a registry login, an AWS key —\n * and loading `gkm.config.ts`, sniffing an app's environment and building it\n * all execute code from the repository being deployed. On a developer's own\n * laptop that is the developer's code. On a CI job for a fork, or a shared\n * build runner, it is not, and that code should not be able to read the\n * credentials used to deploy it, hang the deploy, or reach outside the\n * checkout.\n *\n * So every step that runs project code goes through a `Sandbox`: one call,\n * with an argument array rather than a shell line, the complete environment\n * the step needs rather than the host's, a timeout it cannot outlive, secrets\n * as files rather than variables, and a working directory inside the project.\n * The steps that need credentials — provisioning, pushing, releasing — are\n * the deploy's own code and never run in one.\n *\n * `LocalSandbox` is the default: a child process on this machine with an\n * allowlisted environment. A host that builds repositories it does not trust\n * passes its own — a container per build, a VM — through `deploy()`'s\n * `sandbox`.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport { existsSync, realpathSync } from 'node:fs';\nimport { isAbsolute, relative, resolve, sep } from 'node:path';\nimport { GkmError } from '../errors';\n\n/** Where a command's output goes. */\nexport type SandboxOutput = 'capture' | 'inherit' | 'stderr' | 'ignore';\n\nexport interface SandboxExecOptions {\n\t/**\n\t * Where the command runs: the project root or a directory below it, as an\n\t * absolute path or relative to the root. Anywhere else is refused with\n\t * {@link SandboxCwdEscape}.\n\t */\n\tcwd: string;\n\t/**\n\t * The command's whole environment. Nothing of the host's is added to it:\n\t * start from {@link Sandbox.env} and add what the step needs.\n\t */\n\tenv: Readonly<Record<string, string>>;\n\t/**\n\t * How long the command may run before it is killed. Required: a step that\n\t * waits forever — a sniffed entry that opens a server, a build stuck on a\n\t * prompt — would otherwise hold the deploy, and its lock, forever.\n\t */\n\ttimeoutMs: number;\n\t/**\n\t * Files the command can read, by name. Mounted in a directory of their own\n\t * — named by `GKM_SECRETS_DIR` in the command's environment — and removed\n\t * when it exits. Never set as variables, which every child inherits, a\n\t * crash report prints and `/proc/<pid>/environ` shows.\n\t */\n\tsecrets?: Readonly<Record<string, string>>;\n\t/**\n\t * `capture` (the default) returns stdout and stderr in the result;\n\t * `inherit` gives the command the host's terminal; `stderr` sends both\n\t * streams to the host's stderr; `ignore` discards them.\n\t */\n\toutput?: SandboxOutput;\n\t/** Kills the command when aborted; `exec` rejects with the signal's reason. */\n\tsignal?: AbortSignal;\n}\n\n/** How a command ended. A non-zero exit is a result, not an error. */\nexport interface SandboxResult {\n\texitCode: number | null;\n\tsignal: string | null;\n\t/** What it wrote to stdout, when its output was captured. */\n\tstdout: string;\n\t/** What it wrote to stderr, when its output was captured. */\n\tstderr: string;\n}\n\n/**\n * Runs a command against the project, and nothing else of the host's.\n *\n * `exec` resolves with the result however the command exited. It rejects\n * with {@link CommandTimedOut} once the timeout passes — after the command is\n * gone — with {@link SandboxCwdEscape} for a directory outside the project,\n * with the signal's reason when aborted, and with the spawn error when the\n * program cannot be started.\n */\nexport interface Sandbox {\n\t/** The project: the directory every command runs at or below. */\n\treadonly root: string;\n\t/**\n\t * Whether the code it runs is kept from the host: its files, its\n\t * processes, its memory.\n\t *\n\t * An isolating sandbox shares nothing but what crosses `exec`, so a config\n\t * reaches the deploy as data — a live object in it (a custom state store,\n\t * an inline target) cannot cross, and is refused with\n\t * `ConfigObjectNotSerializable`. A non-isolating one, like\n\t * {@link LocalSandbox}, runs on the host as the host's user; a project\n\t * whose config holds live objects is then loaded in-process as before,\n\t * because a project trusted to run there is trusted to do that.\n\t */\n\treadonly isolating: boolean;\n\t/**\n\t * The environment a command starts from: what any program needs to run\n\t * here — `PATH`, `HOME`, the locale — and no credential.\n\t */\n\treadonly env: Readonly<Record<string, string>>;\n\texec(\n\t\tcommand: string,\n\t\targs: readonly string[],\n\t\toptions: SandboxExecOptions,\n\t): Promise<SandboxResult>;\n}\n\n/** The variable naming the directory a command's secrets are mounted in. */\nexport const SECRETS_DIR_ENV = 'GKM_SECRETS_DIR';\n\n/** A command was asked to run outside the project. */\nexport class SandboxCwdEscape extends GkmError {\n\tconstructor(\n\t\treadonly cwd: string,\n\t\treadonly root: string,\n\t) {\n\t\tsuper(\n\t\t\t`Refusing to run in '${cwd}': it is outside the project at '${root}'. ` +\n\t\t\t\t'A sandboxed step only runs inside the project it was given — check ' +\n\t\t\t\t'the app paths in gkm.config.ts for `..` or an absolute path.',\n\t\t);\n\t\tthis.name = 'SandboxCwdEscape';\n\t}\n}\n\n/** A path with its symlinks resolved where it exists — `/tmp` is `/private/tmp`. */\nfunction real(path: string): string {\n\treturn existsSync(path) ? realpathSync(path) : path;\n}\n\n/**\n * `cwd` as an absolute directory inside `root`, or {@link SandboxCwdEscape}.\n *\n * Symlinks are resolved on both sides first, so a link inside the project\n * that points out of it is an escape, and a project reached through a link\n * (`/tmp` on macOS) is still itself. For a sandbox of a host's own to call\n * before it runs anything.\n */\nexport function confineCwd(root: string, cwd: string): string {\n\tconst absolute = resolve(root, cwd);\n\tconst from = relative(real(resolve(root)), real(absolute));\n\tif (from === '..' || from.startsWith(`..${sep}`) || isAbsolute(from)) {\n\t\tthrow new SandboxCwdEscape(cwd, root);\n\t}\n\treturn absolute;\n}\n\n/** A secret's file name: one path segment, so it cannot be written elsewhere. */\nexport class SecretNameInvalid extends GkmError {\n\tconstructor(readonly secretName: string) {\n\t\tsuper(\n\t\t\t`'${secretName}' cannot be a secret's name: it becomes a file name in ` +\n\t\t\t\t'the secrets directory, so it must be one segment of letters, digits, ' +\n\t\t\t\t\"'.', '-' or '_' and not start with '.'.\",\n\t\t);\n\t\tthis.name = 'SecretNameInvalid';\n\t}\n}\n\nconst SECRET_NAME = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;\n\n/** Every secret name, checked before anything is written. */\nexport function assertSecretNames(\n\tsecrets: Readonly<Record<string, string>> | undefined,\n): void {\n\tfor (const name of Object.keys(secrets ?? {})) {\n\t\tif (!SECRET_NAME.test(name)) throw new SecretNameInvalid(name);\n\t}\n}\n\n/** A run's sandbox, and what its workers already answered. */\ninterface SandboxRun {\n\tsandbox: Sandbox;\n\tanswers: Map<string, Promise<unknown>>;\n}\n\nconst active = new AsyncLocalStorage<SandboxRun>();\n\n/**\n * Run `fn` with `sandbox` as the one its steps use.\n *\n * Per run rather than global, as `withOutput` routes a run's lines: two\n * deploys in one host process each build in their own sandbox. A step deep in\n * the engine — discovering constructs, sniffing an app — asks\n * {@link activeSandbox} rather than every function between `deploy()` and it\n * taking one more parameter.\n */\nexport function withSandbox<T>(sandbox: Sandbox, fn: () => T): T {\n\treturn active.run({ sandbox, answers: new Map() }, fn);\n}\n\n/** The sandbox of the run this is part of, if it was started with one. */\nexport function activeSandbox(): Sandbox | undefined {\n\treturn active.getStore()?.sandbox;\n}\n\n/**\n * `ask()`'s answer, asked once per run.\n *\n * A deploy loads its config and discovers its constructs from several places\n * — the first load, the engine, the Dockerfile generator — and in a sandbox\n * each was a child process of its own, for the same answer: the checkout does\n * not change while it deploys. Within a run in `sandbox`, the first answer\n * for `key` is the one every later ask gets. Outside one, or for another\n * sandbox, `ask()` runs each time.\n */\nexport function oncePerRun<T>(\n\tsandbox: Sandbox,\n\tkey: string,\n\task: () => Promise<T>,\n): Promise<T> {\n\tconst run = active.getStore();\n\tif (!run || run.sandbox !== sandbox) return ask();\n\n\tlet answer = run.answers.get(key) as Promise<T> | undefined;\n\tif (!answer) {\n\t\tanswer = ask();\n\t\trun.answers.set(key, answer);\n\t\t// A failure is not remembered: the next ask tries again.\n\t\tanswer.catch(() => run.answers.delete(key));\n\t}\n\treturn answer;\n}\n","import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nconst REGISTER = 'owning-tsconfig-jsx-register.mjs';\n\n/** The CLI's `bin/` was not found above the module looking for it. */\nexport class OwningTsconfigJsxHookMissing extends Error {\n\tconstructor(readonly from: string) {\n\t\tsuper(\n\t\t\t`Could not find bin/${REGISTER} in any directory above '${from}'. ` +\n\t\t\t\t'It ships with @geekmidas/cli beside bin/gkm.mjs; reinstall the ' +\n\t\t\t\t'package if it is missing.',\n\t\t);\n\t\tthis.name = 'OwningTsconfigJsxHookMissing';\n\t}\n}\n\n/**\n * The CLI's `bin/owning-tsconfig-jsx-register.mjs`, as a file URL. Searched\n * upward because this module runs from `src/` in the repo and from a chunk in\n * `dist/` once built, and `bin/` sits beside both.\n */\nfunction registerUrl(): string {\n\tconst from = dirname(fileURLToPath(import.meta.url));\n\tfor (let dir = from; ; dir = dirname(dir)) {\n\t\tconst candidate = join(dir, 'bin', REGISTER);\n\t\tif (existsSync(candidate)) return pathToFileURL(candidate).href;\n\t\tif (dirname(dir) === dir) throw new OwningTsconfigJsxHookMissing(from);\n\t}\n}\n\n/**\n * `NODE_OPTIONS` for a process that runs app code through tsx, with the hook\n * that compiles each `.tsx` with its own tsconfig's JSX settings (see\n * `bin/owning-tsconfig-jsx.mjs`) put in front of every other `--import`, so it\n * is registered before tsx and reads the source on tsx's behalf.\n *\n * `bin/gkm.mjs` already starts the CLI this way, and its children inherit it;\n * this is for those that set `NODE_OPTIONS` themselves, or whose CLI was\n * started with tsx already imported.\n */\nexport function withOwningTsconfigJsx(nodeOptions = ''): string {\n\tif (nodeOptions.includes(REGISTER)) return nodeOptions;\n\treturn [`--import=${registerUrl()}`, nodeOptions].filter(Boolean).join(' ');\n}\n","/**\n * Running one of the CLI's own worker scripts inside a sandbox, and reading\n * back the one JSON value it answers with.\n *\n * The worker imports the project's TypeScript — `gkm.config.ts`, construct\n * modules, an app's entry — so it starts with the CLI's own tsx and the two\n * hooks `gkm` itself runs with (JSX by the owning tsconfig, path aliases by\n * the adjacent one). The host process needs none of them loaded: a program\n * calling `deploy()` without `--import tsx` still loads a TypeScript config.\n */\n\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport type { z } from 'zod';\nimport { withOwningTsconfigJsx } from '../owningTsconfigJsx';\nimport { oncePerRun, type Sandbox } from './sandbox';\nimport { WORKER_RESULT_MARKER } from './workerRuntime';\n\nconst here = dirname(fileURLToPath(import.meta.url));\n\n/**\n * A worker's file: `dist/sandbox/<name>.mjs` once built — whether this module\n * was bundled into `dist/` or sits beside it — or the `.ts` source under tsx.\n */\nexport function workerFile(name: string): string {\n\tconst candidates = [\n\t\tjoin(here, 'sandbox', `${name}.mjs`),\n\t\tjoin(here, `${name}.mjs`),\n\t\tjoin(here, '..', 'sandbox', `${name}.mjs`),\n\t\tjoin(here, `${name}.ts`),\n\t];\n\treturn (\n\t\tcandidates.find((path) => existsSync(path)) ?? join(here, `${name}.ts`)\n\t);\n}\n\n/** tsx, from the CLI's own dependencies — never the project's. */\nexport function tsxUrl(): string {\n\treturn pathToFileURL(createRequire(import.meta.url).resolve('tsx')).href;\n}\n\n/**\n * `node`'s arguments for `script`: the CLI's TypeScript loaders, then any\n * further `imports`, then the script and its `args` — an argument array, so\n * nothing about a path is read by a shell.\n */\nexport function nodeWithTsx(\n\tscript: string,\n\targs: readonly string[],\n\timports: readonly string[] = [],\n): string[] {\n\treturn [\n\t\t...withOwningTsconfigJsx(`--import=${tsxUrl()}`).split(' '),\n\t\t...imports.map((path) => `--import=${pathToFileURL(path).href}`),\n\t\tscript,\n\t\t...args,\n\t];\n}\n\n/** A worker ended without the answer it exists to give. */\nexport class SandboxWorkerFailed extends Error {\n\tconstructor(\n\t\treadonly step: string,\n\t\treadonly exitCode: number | null,\n\t\treadonly stderr: string,\n\t) {\n\t\tsuper(\n\t\t\t`The sandboxed ${step} ended (exit code ${exitCode}) without an ` +\n\t\t\t\t`answer.${stderr.trim() ? `\\n${stderr.trim()}` : ''}\\nIts output ` +\n\t\t\t\t'above says why; the sandbox must be able to run `node` with the ' +\n\t\t\t\t\"CLI's own files at the paths they have here.\",\n\t\t);\n\t\tthis.name = 'SandboxWorkerFailed';\n\t}\n}\n\nexport interface WorkerRun<T> {\n\t/** What the worker answered, as the schema reads it. */\n\tvalue: T;\n\t/** What it wrote to stderr: warnings a caller may pass on. */\n\tstderr: string;\n}\n\n/**\n * Run worker `name` in `sandbox`, and parse its answer with `schema`.\n *\n * The answer is the last marked line on stdout. Anything else the project's\n * code printed is ignored, and an answer the schema refuses is a failure\n * rather than data — a worker in an isolating sandbox runs code the host does\n * not trust.\n *\n * Within a run (`withSandbox`), the same worker asked the same question is\n * started once; every ask gets its own copy of the answer, and its stderr, as\n * though it had run again.\n */\nexport async function runWorker<S extends z.ZodType>(\n\tsandbox: Sandbox,\n\tstep: string,\n\toptions: WorkerOptions<S>,\n): Promise<WorkerRun<z.infer<S>>> {\n\t// A step handed secrets acts on something — a database it migrates — and\n\t// is not a question whose answer can be reused; nor do its secrets belong\n\t// in a cache key.\n\tif (options.secrets) return startWorker(sandbox, step, options);\n\n\tconst key = JSON.stringify([\n\t\toptions.name,\n\t\toptions.cwd,\n\t\toptions.args,\n\t\toptions.env ?? {},\n\t]);\n\tconst answer = await oncePerRun(sandbox, key, () =>\n\t\tstartWorker(sandbox, step, options),\n\t);\n\treturn structuredClone(answer);\n}\n\ninterface WorkerOptions<S extends z.ZodType> {\n\tname: string;\n\targs: readonly string[];\n\tcwd: string;\n\ttimeoutMs: number;\n\tenv?: Readonly<Record<string, string>>;\n\t/** Mounted as files, named by `GKM_SECRETS_DIR` — never variables. */\n\tsecrets?: Readonly<Record<string, string>>;\n\tsignal?: AbortSignal;\n\tschema: S;\n}\n\nasync function startWorker<S extends z.ZodType>(\n\tsandbox: Sandbox,\n\tstep: string,\n\toptions: WorkerOptions<S>,\n): Promise<WorkerRun<z.infer<S>>> {\n\tconst result = await sandbox.exec(\n\t\t'node',\n\t\tnodeWithTsx(workerFile(options.name), options.args),\n\t\t{\n\t\t\tcwd: options.cwd,\n\t\t\tenv: { ...sandbox.env, ...options.env },\n\t\t\ttimeoutMs: options.timeoutMs,\n\t\t\toutput: 'capture',\n\t\t\t...(options.secrets ? { secrets: options.secrets } : {}),\n\t\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t},\n\t);\n\n\tconst line = result.stdout\n\t\t.split('\\n')\n\t\t.reverse()\n\t\t.find((l) => l.startsWith(WORKER_RESULT_MARKER));\n\tif (line) {\n\t\ttry {\n\t\t\tconst parsed = options.schema.safeParse(\n\t\t\t\tJSON.parse(line.slice(WORKER_RESULT_MARKER.length)),\n\t\t\t);\n\t\t\tif (parsed.success) return { value: parsed.data, stderr: result.stderr };\n\t\t} catch {\n\t\t\t// Not JSON: as good as no answer.\n\t\t}\n\t}\n\n\tthrow new SandboxWorkerFailed(step, result.exitCode, result.stderr);\n}\n","/**\n * Discovery — one glob, one structural test.\n *\n * A glob per kind is the same specialness the construct model removes, and\n * resources have no kind to be listed under: a declared `ObjectStorage` would\n * never be found by `routes:` or `crons:`. So there is one `constructs` glob,\n * every export of every matching module is inspected, and the per-kind\n * `isConstruct` checks collapse into a single question — does it have an id and\n * can it declare?\n *\n * Structural rather than `instanceof` on purpose. A construct from a different\n * copy of `@geekmidas/constructs` — a linked workspace, two versions in a\n * lockfile — is still a construct, and `instanceof` is exactly the check that\n * says otherwise.\n */\n\nimport { relative } from 'node:path';\nimport { Cron } from '@geekmidas/constructs/crons';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { Function } from '@geekmidas/constructs/functions';\nimport { Processor } from '@geekmidas/constructs/processors';\nimport { Queue } from '@geekmidas/constructs/queue';\nimport { Subscriber } from '@geekmidas/constructs/subscribers';\nimport { WebSocketRoute } from '@geekmidas/constructs/websocket-api';\nimport {\n\tassertDerivations,\n\ttype ConstructManifest,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\ttype ProcessorDeclaration,\n\tprovidedKeyFor,\n} from '@geekmidas/manifest';\nimport fg from 'fast-glob';\nimport { z } from 'zod';\nimport { GkmError } from '../errors';\nimport { clearZodGlobalRegistry } from '../generators/Generator';\nimport { output } from '../output';\nimport { activeSandbox, type Sandbox } from '../sandbox/sandbox';\nimport { runWorker } from '../sandbox/worker';\nimport { subscriberConnectionKey } from './edges';\n\n/** `console`, or the deploy run discovering the manifest. */\nconst logger = output;\n\n/** The construct face discovery needs: an id, and the ability to declare. */\ninterface Declarable {\n\tid: string;\n\tdeclare(): Declaration[];\n}\n\n/**\n * Whether a module export is a construct.\n *\n * Deliberately loose about what else it carries — a construct that also has a\n * `service` is still a construct, and requiring one would exclude the kinds that\n * own no address.\n */\nexport function isDeclarable(value: unknown): value is Declarable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Declarable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\tcandidate.id.length > 0 &&\n\t\ttypeof candidate.declare === 'function'\n\t);\n}\n\nexport interface DiscoverOptions {\n\t/** The glob(s) to search. One pattern, not one per kind. */\n\tpatterns: string | readonly string[];\n\tcwd?: string;\n\t/**\n\t * Re-import changed modules, for the dev watcher.\n\t *\n\t * A single glob makes discovery more central, not less: a new construct file\n\t * has to be picked up on `add`, not only on `change`.\n\t */\n\tbustCache?: boolean;\n\t/**\n\t * Filled in with where each construct was found, when provided.\n\t *\n\t * Discovery is the only thing that knows: it globbed the files and imported\n\t * them. Everything downstream that needs to *write* an import — the build,\n\t * generating a server entry that reads a surface's logger — would otherwise\n\t * have to be told the path in config, which is the string this removes.\n\t *\n\t * An out-parameter rather than a second return value so that every existing\n\t * caller, which wants the manifest and nothing else, is unchanged.\n\t */\n\tsources?: Record<string, ConstructSource>;\n\t/**\n\t * Filled in, when provided, with the files each worker's background work is\n\t * declared in — its crons, queue consumers and topic subscribers — keyed by\n\t * the worker.\n\t *\n\t * What says which app's build carries a worker's entry: the one whose\n\t * directory holds its work. A worker declares no path of its own.\n\t */\n\tbackground?: Record<string, string[]>;\n\t/**\n\t * Filled in, when provided, with the files that export something built\n\t * from each surface — an endpoint, a WebSocket route — keyed by the\n\t * surface. What a surface that serves itself imports its routes from.\n\t */\n\tserved?: Record<string, string[]>;\n\t/**\n\t * Filled in, when provided, with each worker's subscribers — by the export\n\t * a push route is named after, and the key its deliveries come from: its\n\t * topic's, or its bucket's events — keyed by the worker.\n\t *\n\t * What says which worker SNS pushes to, and on which paths: a build bound\n\t * for a server records no subscriber in the manifest, because none has a\n\t * handler of its own there.\n\t */\n\tsubscribers?: Record<string, BoundSubscriber[]>;\n\t/**\n\t * Import the construct modules in this sandbox rather than in this\n\t * process. Defaults to the run's own (`withSandbox`), so a deploy's every\n\t * discovery — the engine's included — happens there; with neither, they\n\t * are imported here, as before.\n\t */\n\tsandbox?: Sandbox;\n}\n\n/** A worker's subscriber — to a topic or to a bucket — as discovery found it. */\nexport interface BoundSubscriber {\n\t/** Its export — what its push route is named after. */\n\tname: string;\n\t/**\n\t * The env key its deliveries come from: its topic's publisher connection\n\t * string, or its bucket's events connection string. An `sns://` value is\n\t * what makes SNS push to it.\n\t */\n\tconnectionKey: string;\n\t/**\n\t * The event types a topic subscriber names — its SNS subscription's filter\n\t * on the `type` attribute the topic's publisher sets. Absent for a\n\t * bucket's subscriber: S3 sets no such attribute, and the subscriber's own\n\t * filter decides.\n\t */\n\tevents?: readonly string[];\n}\n\n/** What the discovery worker answers. Checked: the worker ran project code. */\nconst DiscoverAnswer = z.discriminatedUnion('reason', [\n\tz.object({\n\t\treason: z.literal('discovered'),\n\t\tmanifest: z.record(\n\t\t\tz.string(),\n\t\t\tz.object({ id: z.string(), kind: z.string() }).loose(),\n\t\t),\n\t\tbackground: z.record(z.string(), z.array(z.string())).optional(),\n\t\tsubscribers: z\n\t\t\t.record(\n\t\t\t\tz.string(),\n\t\t\t\tz.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tname: z.string(),\n\t\t\t\t\t\tconnectionKey: z.string(),\n\t\t\t\t\t\tevents: z.array(z.string()).optional(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.optional(),\n\t}),\n\tz.object({ reason: z.literal('live'), paths: z.array(z.string()) }),\n\tz.object({\n\t\treason: z.literal('failed'),\n\t\terror: z\n\t\t\t.object({\n\t\t\t\tname: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t\tid: z.string().optional(),\n\t\t\t\tsources: z.array(z.string()).optional(),\n\t\t\t})\n\t\t\t.loose(),\n\t}),\n]);\n\n/**\n * The manifest, discovered in `sandbox` and handed back as JSON — or\n * `undefined` when it holds something JSON cannot carry and the sandbox is\n * not isolating, for the caller to discover here as before.\n */\nasync function discoverInSandbox(\n\tsandbox: Sandbox,\n\toptions: DiscoverOptions,\n): Promise<ConstructManifest | undefined> {\n\tconst cwd = options.cwd ?? sandbox.root;\n\tconst patterns =\n\t\ttypeof options.patterns === 'string'\n\t\t\t? [options.patterns]\n\t\t\t: [...options.patterns];\n\n\tconst { value, stderr } = await runWorker(sandbox, 'construct discovery', {\n\t\tname: 'discover-worker',\n\t\targs: [JSON.stringify({ patterns, cwd })],\n\t\tcwd,\n\t\ttimeoutMs: DISCOVER_TIMEOUT_MS,\n\t\tschema: DiscoverAnswer,\n\t});\n\n\t// Discovery's own warnings — a glob that matched nothing — are the\n\t// run's, as they would be had it discovered in-process: as written, one\n\t// message, less the newline the worker's `console.warn` ended it with.\n\tif (stderr.trim()) logger.warn(stderr.replace(/\\n$/, ''));\n\n\tswitch (value.reason) {\n\t\tcase 'discovered':\n\t\t\tif (options.background) {\n\t\t\t\tfor (const [owner, files] of Object.entries(value.background ?? {})) {\n\t\t\t\t\toptions.background[owner] = files;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (options.subscribers) {\n\t\t\t\tfor (const [owner, bound] of Object.entries(value.subscribers ?? {})) {\n\t\t\t\t\toptions.subscribers[owner] = bound;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn value.manifest as unknown as ConstructManifest;\n\t\tcase 'failed':\n\t\t\tif (value.error.name === 'DuplicateConstruct' && value.error.id) {\n\t\t\t\tthrow new DuplicateConstruct(value.error.id, value.error.sources ?? []);\n\t\t\t}\n\t\t\tthrow new ConstructDiscoveryFailed(value.error.name, value.error.message);\n\t\tcase 'live':\n\t\t\tif (sandbox.isolating) throw new ConstructsNotSerializable(value.paths);\n\t\t\treturn undefined;\n\t}\n}\n\n/**\n * A caller asked for the construct objects (`sources`) or a watcher's\n * re-import under an isolating sandbox, where only data comes back.\n */\nexport class LiveConstructsUnavailable extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'Discovery was asked for the construct objects themselves under an ' +\n\t\t\t\t'isolating sandbox, which hands back only data. Run this step ' +\n\t\t\t\t'without one, or ask only for the manifest.',\n\t\t);\n\t\tthis.name = 'LiveConstructsUnavailable';\n\t}\n}\n\n/** How long discovering a project's constructs may take in a sandbox. */\nconst DISCOVER_TIMEOUT_MS = 60_000;\n\n/** Importing a construct module, or declaring one, threw in the sandbox. */\nexport class ConstructDiscoveryFailed extends Error {\n\tconstructor(\n\t\treadonly errorName: string,\n\t\treadonly detail: string,\n\t) {\n\t\tsuper(`Discovering constructs failed (${errorName}): ${detail}`);\n\t\tthis.name = 'ConstructDiscoveryFailed';\n\t}\n}\n\n/**\n * The constructs' declarations hold something that is not data, and the\n * sandbox they were discovered in hands the deploy nothing but data.\n */\nexport class ConstructsNotSerializable extends Error {\n\tconstructor(readonly paths: readonly string[]) {\n\t\tsuper(\n\t\t\t`The construct manifest holds values that are not plain data at: ` +\n\t\t\t\t`${paths.join(', ')}. Under an isolating sandbox the deploy only ` +\n\t\t\t\t'receives what JSON can carry; deploy with a sandbox that is not ' +\n\t\t\t\t'isolating if the host trusts this project.',\n\t\t);\n\t\tthis.name = 'ConstructsNotSerializable';\n\t}\n}\n\n/** Where a construct was declared, and under what name. */\nexport interface ConstructSource {\n\t/** Absolute path to the module that exported it. */\n\tfile: string;\n\t/** The name it was exported as — what an import statement has to say. */\n\texportName: string;\n\t/**\n\t * The exported construct itself.\n\t *\n\t * What a declaration cannot say — whether it serves itself — the object can\n\t * be asked, and discovery already imported it.\n\t */\n\tconstruct: unknown;\n}\n\n/**\n * Build the construct manifest for a project.\n *\n * Runs the manifest's own validation before returning, so an app is wrong here\n * — where the error names a file — rather than at deploy.\n *\n * @throws {DuplicateConstruct} when two exports claim one id.\n */\nexport async function discover(\n\toptions: DiscoverOptions,\n): Promise<ConstructManifest> {\n\tconst sandbox = options.sandbox ?? activeSandbox();\n\tif (sandbox) {\n\t\tif (!options.sources && !options.bustCache) {\n\t\t\tconst sandboxed = await discoverInSandbox(sandbox, options);\n\t\t\tif (sandboxed) return sandboxed;\n\t\t} else if (sandbox.isolating) {\n\t\t\t// The construct objects themselves, or a re-import for the watcher:\n\t\t\t// neither can cross a sandbox that hands back only data.\n\t\t\tthrow new LiveConstructsUnavailable();\n\t\t}\n\t}\n\n\tconst {\n\t\tpatterns,\n\t\tcwd = process.cwd(),\n\t\tbustCache = false,\n\t\tsources: out,\n\t} = options;\n\n\t// Re-importing user modules re-executes them, and Zod v4 throws on a\n\t// re-registered `.meta({ id })`. Same reason the generators clear it.\n\tif (bustCache) clearZodGlobalRegistry();\n\n\tconst manifest: Record<string, Declaration> = {};\n\t/** Which file declared each id, for the error when two of them do. */\n\tconst sources: Record<string, string> = {};\n\t/**\n\t * Constructs already seen, by identity.\n\t *\n\t * A re-export is the *same object* reached through a second file — ESM\n\t * bindings are live, so `export * from './database.js'` hands back the\n\t * binding rather than a copy. Without this, a barrel file made every\n\t * construct in it appear declared twice, and `constructs/index.ts` is the\n\t * first thing anyone writes in a shared folder.\n\t *\n\t * Identity rather than file is also the more honest rule: what may not\n\t * happen twice is two *different* constructs claiming one id, and that is\n\t * still an error below.\n\t */\n\tconst seen = new WeakSet<object>();\n\n\tconst globs = Array.isArray(patterns) ? [...patterns] : [patterns as string];\n\tconst files = fg.stream(globs, { cwd, absolute: true });\n\n\t/** Matched files, for the diagnostic below. */\n\tlet matched = 0;\n\n\t/** Each processor, once, by the export that first reached it. */\n\tconst processors = new Map<\n\t\tobject,\n\t\t{ exportName: string; file: string; processor: Processor<string> }\n\t>();\n\t/** Each runnable, once, under the export most likely to define it. */\n\tconst runnables = new Map<object, Found>();\n\n\tfor await (const found of files) {\n\t\tmatched++;\n\t\tconst file = found.toString();\n\t\tconst module = await import(bustCache ? `${file}?t=${Date.now()}` : file);\n\n\t\tfor (const [exportName, exported] of Object.entries(module)) {\n\t\t\tif (options.background)\n\t\t\t\trecordBackground(options.background, exported, file);\n\t\t\tif (options.served) recordServed(options.served, exported, file);\n\t\t\tif (options.subscribers)\n\t\t\t\trecordSubscriber(options.subscribers, exported, exportName);\n\t\t\tif (Processor.isProcessor(exported)) {\n\t\t\t\tconst seenAt = processors.get(exported);\n\t\t\t\tif (!seenAt || definedIn(file, seenAt.file)) {\n\t\t\t\t\tprocessors.set(exported, { exportName, file, processor: exported });\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isRunnable(exported)) {\n\t\t\t\tconst seenAt = runnables.get(exported);\n\t\t\t\tif (!seenAt || definedIn(file, seenAt.file)) {\n\t\t\t\t\trunnables.set(exported, { exportName, file, construct: exported });\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!isDeclarable(exported)) continue;\n\n\t\t\t// The same construct, reached again through a re-export. Skipped\n\t\t\t// rather than re-declared: it has already claimed its id, from the\n\t\t\t// file that defined it.\n\t\t\tif (seen.has(exported as object)) continue;\n\t\t\tseen.add(exported as object);\n\n\t\t\tfor (const declaration of exported.declare()) {\n\t\t\t\t// Canonicalise here too: a construct built by hand rather than through\n\t\t\t\t// a constructor is still subject to the same identity rule.\n\t\t\t\tconst id = canonicalId(declaration.id);\n\t\t\t\tconst source = relative(cwd, file);\n\n\t\t\t\tconst claimed = sources[id];\n\t\t\t\tif (claimed !== undefined && claimed !== source) {\n\t\t\t\t\tthrow new DuplicateConstruct(id, [claimed, source]);\n\t\t\t\t}\n\n\t\t\t\tmanifest[id] = { ...declaration, id };\n\t\t\t\tsources[id] = source;\n\t\t\t\tif (out) out[id] = { file, exportName, construct: exported };\n\t\t\t}\n\t\t}\n\t}\n\n\tnestProcessors(manifest, [...processors.values()], cwd);\n\tnestRunnables(manifest, [...runnables.values()], cwd);\n\n\t// Reference integrity before anyone reads it — a schema tenant naming a\n\t// database that was deleted is a manifest error, not a reconcile failure.\n\tassertDerivations(manifest);\n\n\twarnIfNothingFound(globs, matched, Object.keys(manifest).length);\n\n\treturn manifest;\n}\n\n/**\n * Record where a worker's background work is declared: a cron, a queue\n * consumer or a topic subscriber, under the worker that owns it.\n */\nfunction recordBackground(\n\tbackground: Record<string, string[]>,\n\texported: unknown,\n\tfile: string,\n): void {\n\tif (\n\t\t!Cron.isCron(exported) &&\n\t\t!Queue.isQueue(exported) &&\n\t\t!Subscriber.isSubscriber(exported)\n\t) {\n\t\treturn;\n\t}\n\tconst owner = (exported as { owner?: unknown }).owner;\n\tif (typeof owner !== 'string') return;\n\n\tconst key = canonicalId(owner);\n\tconst files = background[key] ?? [];\n\tbackground[key] = files;\n\tif (!files.includes(file)) files.push(file);\n}\n\n/** Record the file of anything built from a surface, under that surface. */\nfunction recordServed(\n\tserved: Record<string, string[]>,\n\texported: unknown,\n\tfile: string,\n): void {\n\tif (typeof exported !== 'object' || exported === null) return;\n\tconst surface = (exported as { surface?: { id?: unknown } }).surface?.id;\n\tif (typeof surface !== 'string') return;\n\n\tconst key = canonicalId(surface);\n\tconst files = served[key] ?? [];\n\tserved[key] = files;\n\tif (!files.includes(file)) files.push(file);\n}\n\n/** A processor built from a file server the discovery never found. */\nexport class ProcessorServerUnknown extends GkmError {\n\tconstructor(\n\t\treadonly processor: string,\n\t\treadonly server: string,\n\t) {\n\t\tsuper(\n\t\t\t`The processor '${processor}' answers on '${server}', which no ` +\n\t\t\t\t`discovered file declares. Export the FileServer from a file the ` +\n\t\t\t\t`workspace's constructs glob matches.`,\n\t\t);\n\t\tthis.name = 'ProcessorServerUnknown';\n\t}\n}\n\n/**\n * Whether `file` is the likelier home of an export also reached from\n * `other`: not a barrel (`index.*`) where the other is, and otherwise the\n * first by path — so the answer never depends on the order the glob\n * streamed them in.\n */\nfunction definedIn(file: string, other: string): boolean {\n\tconst barrel = (path: string) => /(^|[/\\\\])index\\.[cm]?[jt]s$/.test(path);\n\tif (barrel(file) !== barrel(other)) return barrel(other);\n\treturn file < other;\n}\n\n/**\n * Nest each processor in the file server it answers on.\n *\n * A processor is positional, as a subscriber is: it answers on its server's\n * domain and nothing else. It is nested here, not only by the build, because\n * every deploy path — the compose stack, the CDN in front of the bucket, the\n * SST stack — reads the discovered manifest. Its handler is its source until a\n * build replaces it with the generated one.\n */\nfunction nestProcessors(\n\tmanifest: Record<string, Declaration>,\n\tprocessors: readonly {\n\t\texportName: string;\n\t\tfile: string;\n\t\tprocessor: Processor<string>;\n\t}[],\n\tcwd: string,\n): void {\n\tfor (const { exportName, file, processor } of processors) {\n\t\tconst server = manifest[processor.surfaceId];\n\t\tif (server?.kind !== 'file-server') {\n\t\t\tthrow new ProcessorServerUnknown(exportName, processor.surfaceId);\n\t\t}\n\t\tconst declaration: ProcessorDeclaration = {\n\t\t\tid: exportName,\n\t\t\thandler: `${relative(cwd, file)}#${exportName}`,\n\t\t\tpath: processor.pattern,\n\t\t\tprefix: processor.prefix,\n\t\t\t...(processor.native.length ? { native: [...processor.native] } : {}),\n\t\t\t...(processor.timeout !== undefined\n\t\t\t\t? { timeout: processor.timeout }\n\t\t\t\t: {}),\n\t\t\t...(processor.memorySize !== undefined\n\t\t\t\t? { memorySize: processor.memorySize }\n\t\t\t\t: {}),\n\t\t\tdependencies: processor.constructs.flatMap((id) => {\n\t\t\t\tconst target = manifest[canonicalId(id)];\n\t\t\t\treturn target ? [{ target: target.id, kind: target.kind }] : [];\n\t\t\t}),\n\t\t};\n\t\tmanifest[server.id] = {\n\t\t\t...server,\n\t\t\tprocessors: [\n\t\t\t\t...(server.processors ?? []).filter((p) => p.id !== exportName),\n\t\t\t\tdeclaration,\n\t\t\t].sort((a, b) => a.id.localeCompare(b.id)),\n\t\t};\n\t}\n}\n\n/** A runnable export, under the name and file it was found by. */\ninterface Found {\n\texportName: string;\n\tfile: string;\n\tconstruct: unknown;\n}\n\n/**\n * Whether an export is something a process runs: an endpoint or a WebSocket\n * route its surface serves, or a cron, function, queue consumer or subscriber\n * a worker does.\n */\nfunction isRunnable(value: unknown): value is object {\n\treturn (\n\t\tEndpoint.isEndpoint(value) ||\n\t\tWebSocketRoute.isRoute(value) ||\n\t\tCron.isCron(value) ||\n\t\tFunction.isFunction(value) ||\n\t\tQueue.isQueue(value) ||\n\t\tSubscriber.isSubscriber(value)\n\t);\n}\n\n/**\n * Nest each runnable where it runs: an endpoint in its surface, a route in\n * its WebSocket surface, a consumer in its queue, a subscriber in its topic or\n * bucket; a cron or function as a node of its own.\n *\n * Here and not in the build, so the manifest is the whole application in every\n * command: `gkm dev` reads the same edges `gkm build` writes and a deploy\n * grants. Each handler is its source, `<file>#<export>`, until a build that\n * generates one per function replaces it with the generated entry.\n */\nfunction nestRunnables(\n\tmanifest: Record<string, Declaration>,\n\tfound: readonly Found[],\n\tcwd: string,\n): void {\n\t// An id that names nothing is dropped: a handler can depend on a lifted\n\t// `Service`, which declares no node of its own.\n\tconst edges = (ids: readonly string[] = []): Dependency[] =>\n\t\t[...new Set(ids.map(canonicalId))].flatMap((id) => {\n\t\t\tconst target = manifest[id];\n\t\t\treturn target ? [{ target: target.id, kind: target.kind }] : [];\n\t\t});\n\tconst ownerOf = (construct: { owner?: unknown }) =>\n\t\ttypeof construct.owner === 'string'\n\t\t\t? { owner: canonicalId(construct.owner) }\n\t\t\t: {};\n\tconst byId = <T extends { id: string }>(list: readonly T[], next: T) =>\n\t\t[...list.filter((item) => item.id !== next.id), next].sort((a, b) =>\n\t\t\ta.id.localeCompare(b.id),\n\t\t);\n\n\tconst sorted = [...found].sort((a, b) =>\n\t\ta.exportName.localeCompare(b.exportName),\n\t);\n\tfor (const { exportName, file, construct } of sorted) {\n\t\tconst handler = `${relative(cwd, file)}#${exportName}`;\n\n\t\tif (Endpoint.isEndpoint(construct)) {\n\t\t\tconst surfaceId = construct.surface?.id;\n\t\t\tconst surface = surfaceId ? manifest[canonicalId(surfaceId)] : undefined;\n\t\t\tif (surface?.kind !== 'rest-api') continue;\n\t\t\tmanifest[surface.id] = {\n\t\t\t\t...surface,\n\t\t\t\tendpoints: byId(surface.endpoints, {\n\t\t\t\t\tid: `${surface.id}${construct.method}${construct._path}`,\n\t\t\t\t\thandler,\n\t\t\t\t\tmethod: construct.method,\n\t\t\t\t\tpath: construct._path,\n\t\t\t\t\tdependencies: edges(construct.constructs),\n\t\t\t\t\tauthorizer: construct.authorizer?.name ?? 'none',\n\t\t\t\t}),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (WebSocketRoute.isRoute(construct)) {\n\t\t\tconst surface = manifest[canonicalId(construct.surface.id)];\n\t\t\tif (surface?.kind !== 'websocket-api') continue;\n\t\t\tmanifest[surface.id] = {\n\t\t\t\t...surface,\n\t\t\t\troutes: byId(surface.routes ?? [], {\n\t\t\t\t\tid: `${surface.id}${construct.action}`,\n\t\t\t\t\thandler,\n\t\t\t\t\taction: construct.action,\n\t\t\t\t\tdependencies: edges(construct.constructs),\n\t\t\t\t}),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Cron.isCron(construct)) {\n\t\t\tmanifest[exportName] = {\n\t\t\t\tkind: 'cron',\n\t\t\t\tid: exportName,\n\t\t\t\thandler,\n\t\t\t\tschedule: construct.schedule || 'rate(1 hour)',\n\t\t\t\tdependencies: edges(construct.constructs),\n\t\t\t\t...ownerOf(construct),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Function.isFunction(construct)) {\n\t\t\tmanifest[exportName] = {\n\t\t\t\tkind: 'function',\n\t\t\t\tid: exportName,\n\t\t\t\thandler,\n\t\t\t\tdependencies: edges(construct.constructs),\n\t\t\t\tprovides: [providedKeyFor(exportName, 'function', 'url')],\n\t\t\t\t...ownerOf(construct),\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\t// A queue declared itself; its consumer is what the worker runs.\n\t\tif (Queue.isQueue(construct)) {\n\t\t\tconst queue = manifest[construct.id];\n\t\t\tif (queue?.kind !== 'queue') continue;\n\t\t\tmanifest[queue.id] = {\n\t\t\t\t...queue,\n\t\t\t\tworker: {\n\t\t\t\t\t...queue.worker,\n\t\t\t\t\thandler,\n\t\t\t\t\tdependencies: edges(construct.constructs),\n\t\t\t\t\t...ownerOf(construct),\n\t\t\t\t},\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (Subscriber.isSubscriber(construct)) {\n\t\t\tconst subscriber = {\n\t\t\t\tid: exportName,\n\t\t\t\thandler,\n\t\t\t\tevents: [...(construct.subscribedEvents ?? [])],\n\t\t\t\tdependencies: edges(construct.constructs),\n\t\t\t\t...ownerOf(construct),\n\t\t\t};\n\t\t\tif (construct.bucketName) {\n\t\t\t\tconst bucket = manifest[canonicalId(construct.bucketName)];\n\t\t\t\tif (bucket?.kind !== 'objects') continue;\n\t\t\t\tmanifest[bucket.id] = {\n\t\t\t\t\t...bucket,\n\t\t\t\t\tsubscribers: byId(bucket.subscribers ?? [], {\n\t\t\t\t\t\t...subscriber,\n\t\t\t\t\t\t...construct.objectFilter,\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst topic = construct.topicName\n\t\t\t\t? manifest[canonicalId(construct.topicName)]\n\t\t\t\t: undefined;\n\t\t\tif (topic?.kind !== 'topic') continue;\n\t\t\tmanifest[topic.id] = {\n\t\t\t\t...topic,\n\t\t\t\tsubscribers: byId(topic.subscribers, subscriber),\n\t\t\t};\n\t\t}\n\t}\n}\n\n/**\n * Record a subscriber — to a topic or to a bucket — under the worker that\n * runs it, by its export. Once per name: a file reached twice through a\n * re-export finds it again.\n */\nfunction recordSubscriber(\n\tsubscribers: Record<string, BoundSubscriber[]>,\n\texported: unknown,\n\texportName: string,\n): void {\n\tif (!Subscriber.isSubscriber(exported)) return;\n\tconst owner = (exported as { owner?: unknown }).owner;\n\tconst connectionKey = subscriberConnectionKey(exported);\n\tif (typeof owner !== 'string' || !connectionKey) return;\n\n\tconst key = canonicalId(owner);\n\tconst bound = subscribers[key] ?? [];\n\tsubscribers[key] = bound;\n\tif (\n\t\t!bound.some(\n\t\t\t(s) => s.connectionKey === connectionKey && s.name === exportName,\n\t\t)\n\t) {\n\t\t// An inbox's topic is published to by the provider, bare, with no\n\t\t// `type` attribute a filter could match: its subscriber takes it all and\n\t\t// keeps what its inbox receives at.\n\t\tconst events =\n\t\t\texported.topicName && !exported.inboxName\n\t\t\t\t? exported.subscribedEvents\n\t\t\t\t: undefined;\n\t\tbound.push({\n\t\t\tname: exportName,\n\t\t\tconnectionKey,\n\t\t\t...(events ? { events: [...events] } : {}),\n\t\t});\n\t}\n}\n\n/**\n * What a runnable consumes, by id: a queue's consumer drains that queue, a\n * subscriber its topic. Nothing for anything else.\n */\nexport function consumedBy(runnable: unknown): string[] {\n\tif (Queue.isQueue(runnable)) return [runnable.id];\n\tif (Subscriber.isSubscriber(runnable) && runnable.topicName) {\n\t\treturn [canonicalId(runnable.topicName)];\n\t}\n\tif (Subscriber.isSubscriber(runnable) && runnable.bucketName) {\n\t\treturn [canonicalId(runnable.bucketName)];\n\t}\n\treturn [];\n}\n\n/**\n * Say so when a glob was configured and found nothing.\n *\n * The glob is not a filter over declarations already known — it is *how they\n * are found*, by importing what it matches. So a file it misses is a\n * declaration that does not exist, and every symptom of that appears somewhere\n * other than the cause: no container starts, no env key is written, and the\n * application fails on first use against a resource it can see in its own\n * source.\n *\n * Nothing reported it before, because an unmatched file is indistinguishable\n * from a file nobody wrote. These two cases are the ones that are *not*\n * ambiguous — a glob was configured, so something was expected.\n *\n * Silent when no glob is configured at all: that is a project which has not\n * adopted constructs, and has nothing to be missing.\n */\nfunction warnIfNothingFound(\n\tglobs: readonly string[],\n\tmatched: number,\n\tdeclared: number,\n): void {\n\tif (globs.length === 0) return;\n\n\tif (matched === 0) {\n\t\tlogger.warn(\n\t\t\t`\\n⚠️ The constructs glob matched no files, so nothing was declared.\\n` +\n\t\t\t\t` Patterns: ${globs.join(', ')}\\n` +\n\t\t\t\t` Nothing will be provisioned — no containers, no env keys, no ` +\n\t\t\t\t`resources.\\n` +\n\t\t\t\t` A common cause is depth: '*.ts' matches one level, '**/*.ts' ` +\n\t\t\t\t`matches any.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tif (declared === 0) {\n\t\tlogger.warn(\n\t\t\t`\\n⚠️ The constructs glob matched ${matched} file(s) but none declared ` +\n\t\t\t\t`anything.\\n` +\n\t\t\t\t` Patterns: ${globs.join(', ')}\\n` +\n\t\t\t\t` Discovery keeps exports with an 'id' that can 'declare()'. A ` +\n\t\t\t\t`construct that is\\n` +\n\t\t\t\t` built but never exported is invisible to it.`,\n\t\t);\n\t}\n}\n\n/** Two constructs claiming one id. */\nexport class DuplicateConstruct extends GkmError {\n\t/** The id claimed twice. */\n\treadonly id: string;\n\t/** The files that claimed it. */\n\treadonly sources: readonly string[];\n\n\tconstructor(id: string, sources: readonly string[]) {\n\t\tsuper('Two constructs declare the same id');\n\t\tthis.name = 'DuplicateConstruct';\n\t\tthis.id = id;\n\t\tthis.sources = sources;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,gBAAgB;;;;;;AAOtB,SAAgB,WAAW,UAA0B;CACpD,OAAO,GAAG,WAAW;AACtB;;AAGA,SAAgB,iBAAiB,MAAkC;CAClE,OAAO,KAAK,SAAS,aAAa,IAC/B,KAAK,MAAM,GAAG,EAAqB,IACnC,KAAA;AACJ;;;;;AAMA,SAAgB,wBAAwB,WAGjB;CACtB,IAAI,UAAU,YACb,QAAA,GAAOA,oBAAAA,eAAAA,EAAAA,GACNC,oBAAAA,YAAAA,CAAY,UAAU,UAAU,GAChC,WACA,wBACD;CAED,IAAI,UAAU,WACb,QAAA,GAAOD,oBAAAA,eAAAA,EAAAA,GACNC,oBAAAA,YAAAA,CAAY,UAAU,SAAS,GAC/B,SACA,2BACD;AAGF;;;;;AAMA,SAAgB,mBAAmB,WAE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CAAAA,WAAW,aAAa,QAAQ,KAAK,SAAS,YACjD,OAAO,EAAA,GAACJ,oBAAAA,YAAAA,CAAY,SAAS,UAAU,CAAC;CAEzC,OAAO,CAAC;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAS,mBACR,OACA,SACA,UACO;CACP,IAAI,MAAM,WAAW,GAAG;CAExB,IAAI,YAAY,GAAG;EAClB,OAAO,KACN,sFACiB,MAAM,KAAK,IAAI,EAAE,2JAKnC;EACA;CACD;CAEA,IAAI,aAAa,GAChB,OAAO,KACN,qCAAqC,QAAQ,qDAE5B,MAAM,KAAK,IAAI,EAAE,qIAInC;AAEF;;AAGA,IAAa,qBAAb,cAAwCK,eAAAA,SAAS;;CAEhD;;CAEA;CAEA,YAAY,IAAY,SAA4B;EACnD,MAAM,oCAAoC;EAC1C,KAAK,OAAO;EACZ,KAAK,KAAK;EACV,KAAK,UAAU;CAChB;AACD"}
|
|
@@ -5,7 +5,7 @@ import { t as WORKER_RESULT_MARKER } from "./workerRuntime-CsOyBRx2.mjs";
|
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { existsSync, realpathSync } from "node:fs";
|
|
8
|
-
import { assertDerivations, canonicalId, dependenciesOf,
|
|
8
|
+
import { assertDerivations, canonicalId, dependenciesOf, providedKeyFor } from "@geekmidas/manifest";
|
|
9
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
11
|
import { format } from "node:util";
|
|
@@ -41,15 +41,15 @@ function eventsEdgeBucket(edge) {
|
|
|
41
41
|
* connection string, or its bucket's events connection string.
|
|
42
42
|
*/
|
|
43
43
|
function subscriberConnectionKey(construct) {
|
|
44
|
-
if (construct.bucketName) return
|
|
45
|
-
if (construct.topicName) return
|
|
44
|
+
if (construct.bucketName) return providedKeyFor(canonicalId(construct.bucketName), "objects", "eventsConnectionString");
|
|
45
|
+
if (construct.topicName) return providedKeyFor(canonicalId(construct.topicName), "topic", "publisherConnectionString");
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* The key a bucket's relay token is read from, by the process that runs the
|
|
49
49
|
* bucket's subscribers — beside its events connection string.
|
|
50
50
|
*/
|
|
51
51
|
function subscriberTokenKey(construct) {
|
|
52
|
-
return construct.bucketName ?
|
|
52
|
+
return construct.bucketName ? providedKeyFor(canonicalId(construct.bucketName), "objects", "eventsToken") : void 0;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* What a worker's process reaches: the worker's own edges, and those of
|
|
@@ -816,7 +816,7 @@ function nestRunnables(manifest, found, cwd) {
|
|
|
816
816
|
id: exportName,
|
|
817
817
|
handler,
|
|
818
818
|
dependencies: edges(construct.constructs),
|
|
819
|
-
provides: [
|
|
819
|
+
provides: [providedKeyFor(exportName, "function", "url")],
|
|
820
820
|
...ownerOf(construct)
|
|
821
821
|
};
|
|
822
822
|
continue;
|
|
@@ -937,4 +937,4 @@ var DuplicateConstruct = class extends GkmError {
|
|
|
937
937
|
//#endregion
|
|
938
938
|
export { subscriberTokenKey as C, subscriberConnectionKey as S, withSandbox as _, discover_exports as a, withOutput as b, nodeWithTsx as c, SECRETS_DIR_ENV as d, SandboxCwdEscape as f, confineCwd as g, assertSecretNames as h, discover as i, runWorker as l, activeSandbox as m, ConstructsNotSerializable as n, isDeclarable as o, SecretNameInvalid as p, consumedBy as r, SandboxWorkerFailed as s, ConstructDiscoveryFailed as t, withOwningTsconfigJsx as u, ConstructGenerator as v, workerEdges as w, eventsEdgeBucket as x, output as y };
|
|
939
939
|
|
|
940
|
-
//# sourceMappingURL=discover-
|
|
940
|
+
//# sourceMappingURL=discover-B_PDDaVj.mjs.map
|