@geekmidas/cli 10.0.0-alpha.184 → 10.0.0-alpha.185

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.
Files changed (245) hide show
  1. package/dist/{LegacyStateStore-BtDLNkIH.cjs → LegacyStateStore-BtN83gfS.cjs} +2 -2
  2. package/dist/{LegacyStateStore-BtDLNkIH.cjs.map → LegacyStateStore-BtN83gfS.cjs.map} +1 -1
  3. package/dist/{LegacyStateStore-CTfoMtC2.mjs → LegacyStateStore-DKyEAWGI.mjs} +2 -2
  4. package/dist/{LegacyStateStore-CTfoMtC2.mjs.map → LegacyStateStore-DKyEAWGI.mjs.map} +1 -1
  5. package/dist/{LocalStateStore-BKp45OoB.cjs → LocalStateStore-BFh6rPhX.cjs} +2 -2
  6. package/dist/{LocalStateStore-BKp45OoB.cjs.map → LocalStateStore-BFh6rPhX.cjs.map} +1 -1
  7. package/dist/{LocalStateStore-C4zDHVM-.mjs → LocalStateStore-Dc3aGvQi.mjs} +2 -2
  8. package/dist/{LocalStateStore-C4zDHVM-.mjs.map → LocalStateStore-Dc3aGvQi.mjs.map} +1 -1
  9. package/dist/{S3StateStore-B6SjbLxh.cjs → S3StateStore-DZMpqbvD.cjs} +5 -5
  10. package/dist/{S3StateStore-B6SjbLxh.cjs.map → S3StateStore-DZMpqbvD.cjs.map} +1 -1
  11. package/dist/{S3StateStore-S0TXLlMW.mjs → S3StateStore-p6DyuAFZ.mjs} +4 -4
  12. package/dist/{S3StateStore-S0TXLlMW.mjs.map → S3StateStore-p6DyuAFZ.mjs.map} +1 -1
  13. package/dist/{SSMStateStore-ClPHFhRQ.mjs → SSMStateStore-BvH8XX4O.mjs} +2 -2
  14. package/dist/{SSMStateStore-ClPHFhRQ.mjs.map → SSMStateStore-BvH8XX4O.mjs.map} +1 -1
  15. package/dist/{SSMStateStore-6Di_zxwC.cjs → SSMStateStore-sbaLlCmj.cjs} +2 -2
  16. package/dist/{SSMStateStore-6Di_zxwC.cjs.map → SSMStateStore-sbaLlCmj.cjs.map} +1 -1
  17. package/dist/{add-Bd9MDHuU.cjs → add-CdVGxiKW.cjs} +13 -14
  18. package/dist/{add-Bd9MDHuU.cjs.map → add-CdVGxiKW.cjs.map} +1 -1
  19. package/dist/{add-BR8XW4IH.mjs → add-dOvgsAU6.mjs} +4 -5
  20. package/dist/{add-BR8XW4IH.mjs.map → add-dOvgsAU6.mjs.map} +1 -1
  21. package/dist/backups/runner.cjs +501 -13
  22. package/dist/backups/runner.cjs.map +1 -1
  23. package/dist/backups/runner.d.cts +87 -2
  24. package/dist/backups/runner.d.cts.map +1 -1
  25. package/dist/backups/runner.d.mts +87 -2
  26. package/dist/backups/runner.d.mts.map +1 -1
  27. package/dist/backups/runner.mjs +493 -15
  28. package/dist/backups/runner.mjs.map +1 -1
  29. package/dist/{bundler-4E-CGdL3.cjs → bundler-B5ioF-1Q.cjs} +9 -9
  30. package/dist/{bundler-4E-CGdL3.cjs.map → bundler-B5ioF-1Q.cjs.map} +1 -1
  31. package/dist/{bundler-Cwr4YSpp.mjs → bundler-Cvx6Bt3e.mjs} +6 -6
  32. package/dist/{bundler-Cwr4YSpp.mjs.map → bundler-Cvx6Bt3e.mjs.map} +1 -1
  33. package/dist/{cli-C3mHXsAE.mjs → cli-BjapgcXG.mjs} +4 -4
  34. package/dist/{cli-C3mHXsAE.mjs.map → cli-BjapgcXG.mjs.map} +1 -1
  35. package/dist/{cli-CrPJr29x.cjs → cli-PLhqvPOC.cjs} +6 -6
  36. package/dist/{cli-CrPJr29x.cjs.map → cli-PLhqvPOC.cjs.map} +1 -1
  37. package/dist/{clientTelemetry-Ej1tf1VE.d.cts → clientTelemetry-Bzc4KXz5.d.mts} +2 -2
  38. package/dist/clientTelemetry-Bzc4KXz5.d.mts.map +1 -0
  39. package/dist/{clientTelemetry-crdjgehZ.d.mts → clientTelemetry-N8NAguGI.d.cts} +2 -2
  40. package/dist/clientTelemetry-N8NAguGI.d.cts.map +1 -0
  41. package/dist/{compose-CKBieltT.cjs → compose-BEVBxf4w.cjs} +87 -948
  42. package/dist/compose-BEVBxf4w.cjs.map +1 -0
  43. package/dist/{compose-DPXoarGI.mjs → compose-Dx_nSZYU.mjs} +23 -842
  44. package/dist/compose-Dx_nSZYU.mjs.map +1 -0
  45. package/dist/{config-q4ewzIA_.d.mts → config-CTrfNKYd.d.mts} +3 -3
  46. package/dist/{config-lSOwPbUy.d.cts.map → config-CTrfNKYd.d.mts.map} +1 -1
  47. package/dist/{config-lSOwPbUy.d.cts → config-D9g_nYIu.d.cts} +3 -3
  48. package/dist/{config-q4ewzIA_.d.mts.map → config-D9g_nYIu.d.cts.map} +1 -1
  49. package/dist/config.cjs +1 -1
  50. package/dist/config.d.cts +3 -3
  51. package/dist/config.d.mts +3 -3
  52. package/dist/config.mjs +1 -1
  53. package/dist/{compose-CJznzQc7.mjs → credentials-DW5MvS4A.mjs} +1148 -1261
  54. package/dist/credentials-DW5MvS4A.mjs.map +1 -0
  55. package/dist/{compose-CvNyjqwL.cjs → credentials-Eyx2tM7B.cjs} +1175 -1288
  56. package/dist/credentials-Eyx2tM7B.cjs.map +1 -0
  57. package/dist/{dns-BzYrbB2Y.cjs → credentials-n2abUWwJ.cjs} +6 -847
  58. package/dist/credentials-n2abUWwJ.cjs.map +1 -0
  59. package/dist/{dns-C0wbTjVX.mjs → credentials-ztezRtR4.mjs} +5 -708
  60. package/dist/credentials-ztezRtR4.mjs.map +1 -0
  61. package/dist/{dbTunnel-DSzAG_wy.cjs → dbTunnel-DVohSZJQ.cjs} +8 -9
  62. package/dist/{dbTunnel-DSzAG_wy.cjs.map → dbTunnel-DVohSZJQ.cjs.map} +1 -1
  63. package/dist/{dbTunnel-CphoKGyk.mjs → dbTunnel-bV1CPWUv.mjs} +5 -6
  64. package/dist/{dbTunnel-CphoKGyk.mjs.map → dbTunnel-bV1CPWUv.mjs.map} +1 -1
  65. package/dist/deploy/public.cjs +25 -26
  66. package/dist/deploy/public.cjs.map +1 -1
  67. package/dist/deploy/public.d.cts +5 -5
  68. package/dist/deploy/public.d.mts +5 -5
  69. package/dist/deploy/public.mjs +10 -11
  70. package/dist/deploy/public.mjs.map +1 -1
  71. package/dist/{deploy-BaSYxpny.cjs → deploy-CDUWcl58.cjs} +72 -62
  72. package/dist/deploy-CDUWcl58.cjs.map +1 -0
  73. package/dist/{deploy-C_uZBzvS.mjs → deploy-Cpz5sKbh.mjs} +25 -15
  74. package/dist/deploy-Cpz5sKbh.mjs.map +1 -0
  75. package/dist/{destroy-yTBmL1jf.mjs → destroy-DRlcWJwm.mjs} +9 -9
  76. package/dist/{destroy-yTBmL1jf.mjs.map → destroy-DRlcWJwm.mjs.map} +1 -1
  77. package/dist/{destroy-PvrHxZDu.cjs → destroy-DzeV0EdY.cjs} +21 -21
  78. package/dist/{destroy-PvrHxZDu.cjs.map → destroy-DzeV0EdY.cjs.map} +1 -1
  79. package/dist/{dokploy-DYUMx2MY.cjs → dokploy-BTNfj3Zt.cjs} +2 -2
  80. package/dist/{dokploy-DYUMx2MY.cjs.map → dokploy-BTNfj3Zt.cjs.map} +1 -1
  81. package/dist/{dokploy-DqL3jeDu.mjs → dokploy-BveqiW2h.mjs} +2 -2
  82. package/dist/{dokploy-DqL3jeDu.mjs.map → dokploy-BveqiW2h.mjs.map} +1 -1
  83. package/dist/{eas-DHDU86PL.mjs → eas-BmYTfjY6.mjs} +3 -3
  84. package/dist/{eas-DHDU86PL.mjs.map → eas-BmYTfjY6.mjs.map} +1 -1
  85. package/dist/{eas-DEM-iWg6.cjs → eas-Dt_vRzb4.cjs} +3 -3
  86. package/dist/{eas-DEM-iWg6.cjs.map → eas-Dt_vRzb4.cjs.map} +1 -1
  87. package/dist/{encryption-BKWmbKkN.cjs → encryption-BE2wxfyH.cjs} +6 -6
  88. package/dist/{encryption-BKWmbKkN.cjs.map → encryption-BE2wxfyH.cjs.map} +1 -1
  89. package/dist/{encryption-CbMprdAb.mjs → encryption-DqoQltP8.mjs} +3 -3
  90. package/dist/{encryption-CbMprdAb.mjs.map → encryption-DqoQltP8.mjs.map} +1 -1
  91. package/dist/{engine-DaI4iScI.mjs → engine-B72vyrO8.mjs} +7 -9
  92. package/dist/{engine-DaI4iScI.mjs.map → engine-B72vyrO8.mjs.map} +1 -1
  93. package/dist/{engine-3imTFxdN.cjs → engine-BevpkNZe.cjs} +100 -102
  94. package/dist/{engine-3imTFxdN.cjs.map → engine-BevpkNZe.cjs.map} +1 -1
  95. package/dist/{github-Y6NAwHG1.cjs → github-DoHdtsDX.cjs} +18 -18
  96. package/dist/{github-Y6NAwHG1.cjs.map → github-DoHdtsDX.cjs.map} +1 -1
  97. package/dist/{github-Dijjr__H.mjs → github-hxvid6J3.mjs} +7 -7
  98. package/dist/{github-Dijjr__H.mjs.map → github-hxvid6J3.mjs.map} +1 -1
  99. package/dist/{googlePlay-Dcp3Yycu.cjs → googlePlay-CYney-Of.cjs} +5 -5
  100. package/dist/{googlePlay-Dcp3Yycu.cjs.map → googlePlay-CYney-Of.cjs.map} +1 -1
  101. package/dist/{googlePlay-SDT3j9Kf.mjs → googlePlay-DsvZTWgP.mjs} +4 -4
  102. package/dist/{googlePlay-SDT3j9Kf.mjs.map → googlePlay-DsvZTWgP.mjs.map} +1 -1
  103. package/dist/{iam-CqW9hsd2.mjs → iam-DloEBLXZ.mjs} +2 -2
  104. package/dist/{iam-CqW9hsd2.mjs.map → iam-DloEBLXZ.mjs.map} +1 -1
  105. package/dist/{iam-DeBQcSvw.cjs → iam-SxPKYCI_.cjs} +2 -2
  106. package/dist/{iam-DeBQcSvw.cjs.map → iam-SxPKYCI_.cjs.map} +1 -1
  107. package/dist/{index-DJzVO6Ht.d.cts → index-BThTZV8T.d.mts} +2 -2
  108. package/dist/{index-Ccsgoq3_.d.mts.map → index-BThTZV8T.d.mts.map} +1 -1
  109. package/dist/{index-Ccsgoq3_.d.mts → index-Cgd-ouyI.d.cts} +2 -2
  110. package/dist/{index-DJzVO6Ht.d.cts.map → index-Cgd-ouyI.d.cts.map} +1 -1
  111. package/dist/index.cjs +590 -246
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.mjs +443 -99
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/{local-DjaAcHZb.cjs → local-BuR4fIW6.cjs} +3 -3
  116. package/dist/{local-DjaAcHZb.cjs.map → local-BuR4fIW6.cjs.map} +1 -1
  117. package/dist/{local-4gzM52HT.mjs → local-Cmq75U_o.mjs} +2 -2
  118. package/dist/{local-4gzM52HT.mjs.map → local-Cmq75U_o.mjs.map} +1 -1
  119. package/dist/{migrate-0Rfhftef.mjs → migrate-Bf-EG8Fj.mjs} +5 -5
  120. package/dist/{migrate-0Rfhftef.mjs.map → migrate-Bf-EG8Fj.mjs.map} +1 -1
  121. package/dist/{migrate-DDIc3twm.cjs → migrate-CDMdrniJ.cjs} +13 -13
  122. package/dist/{migrate-DDIc3twm.cjs.map → migrate-CDMdrniJ.cjs.map} +1 -1
  123. package/dist/{migrate-CuHGYJL9.cjs → migrate-CuTQha4s.cjs} +6 -6
  124. package/dist/{migrate-CuHGYJL9.cjs.map → migrate-CuTQha4s.cjs.map} +1 -1
  125. package/dist/{migrate-BLW4BwLd.mjs → migrate-DYJffHOm.mjs} +3 -3
  126. package/dist/{migrate-BLW4BwLd.mjs.map → migrate-DYJffHOm.mjs.map} +1 -1
  127. package/dist/openapi.cjs +1 -1
  128. package/dist/openapi.d.cts +2 -2
  129. package/dist/openapi.d.mts +2 -2
  130. package/dist/openapi.mjs +1 -1
  131. package/dist/{projectBucket-BhEOVVch.mjs → projectBucket-B5YkuSVr.mjs} +2 -2
  132. package/dist/{projectBucket-BhEOVVch.mjs.map → projectBucket-B5YkuSVr.mjs.map} +1 -1
  133. package/dist/{projectBucket-C5Ap5kGw.cjs → projectBucket-NcgqleyH.cjs} +2 -2
  134. package/dist/{projectBucket-C5Ap5kGw.cjs.map → projectBucket-NcgqleyH.cjs.map} +1 -1
  135. package/dist/{publish-BELe2FO2.cjs → publish--EQ4Tw3F.cjs} +2 -2
  136. package/dist/{publish-BELe2FO2.cjs.map → publish--EQ4Tw3F.cjs.map} +1 -1
  137. package/dist/{publish-DiDv40hA.mjs → publish-YL8WZHSo.mjs} +2 -2
  138. package/dist/{publish-DiDv40hA.mjs.map → publish-YL8WZHSo.mjs.map} +1 -1
  139. package/dist/{ready--_hMxbUX.cjs → ready-DCvnFZnJ.cjs} +2 -2
  140. package/dist/{ready--_hMxbUX.cjs.map → ready-DCvnFZnJ.cjs.map} +1 -1
  141. package/dist/{ready-CjIqXFXe.mjs → ready-sSPuiZ7N.mjs} +2 -2
  142. package/dist/{ready-CjIqXFXe.mjs.map → ready-sSPuiZ7N.mjs.map} +1 -1
  143. package/dist/reconcile/public.d.cts +1 -1
  144. package/dist/reconcile/public.d.mts +1 -1
  145. package/dist/{resolve-DIPHwLan.cjs → resolve-Ced8-gj4.cjs} +4 -4
  146. package/dist/{resolve-DIPHwLan.cjs.map → resolve-Ced8-gj4.cjs.map} +1 -1
  147. package/dist/{resolve-N8EZzWqJ.mjs → resolve-DcG10_JV.mjs} +4 -4
  148. package/dist/{resolve-N8EZzWqJ.mjs.map → resolve-DcG10_JV.mjs.map} +1 -1
  149. package/dist/{rollback-DIeA6dba.mjs → rollback-BxI2p53H.mjs} +7 -6
  150. package/dist/{rollback-DIeA6dba.mjs.map → rollback-BxI2p53H.mjs.map} +1 -1
  151. package/dist/{rollback-Bp6hepUh.cjs → rollback-C6bCANv7.cjs} +10 -9
  152. package/dist/{rollback-Bp6hepUh.cjs.map → rollback-C6bCANv7.cjs.map} +1 -1
  153. package/dist/{runtime-D_UphAAH.d.cts → runtime-BtoiRP5G.d.cts} +2 -2
  154. package/dist/{runtime-BZlClwy2.d.mts.map → runtime-BtoiRP5G.d.cts.map} +1 -1
  155. package/dist/{runtime-BZlClwy2.d.mts → runtime-Ct41f0tN.d.mts} +2 -2
  156. package/dist/{runtime-D_UphAAH.d.cts.map → runtime-Ct41f0tN.d.mts.map} +1 -1
  157. package/dist/{s3-CIEf4puu.mjs → s3-BAI0ELtE.mjs} +3 -3
  158. package/dist/{s3-CIEf4puu.mjs.map → s3-BAI0ELtE.mjs.map} +1 -1
  159. package/dist/{s3-Bwd6lhTU.cjs → s3-DucPHZAn.cjs} +3 -3
  160. package/dist/{s3-Bwd6lhTU.cjs.map → s3-DucPHZAn.cjs.map} +1 -1
  161. package/dist/{serverSetup-C9DP30J4.cjs → serverSetup-D3-FE7Dj.cjs} +9 -8
  162. package/dist/{serverSetup-C9DP30J4.cjs.map → serverSetup-D3-FE7Dj.cjs.map} +1 -1
  163. package/dist/{serverSetup-mRCLdZQW.mjs → serverSetup-DS9tW50_.mjs} +7 -6
  164. package/dist/{serverSetup-mRCLdZQW.mjs.map → serverSetup-DS9tW50_.mjs.map} +1 -1
  165. package/dist/{sniffer-01tbQFmg.mjs → sniffer-CX8sI8Cu.mjs} +7 -7
  166. package/dist/{sniffer-01tbQFmg.mjs.map → sniffer-CX8sI8Cu.mjs.map} +1 -1
  167. package/dist/{sniffer-CkPIytPI.cjs → sniffer-XlvJLrhZ.cjs} +7 -7
  168. package/dist/{sniffer-CkPIytPI.cjs.map → sniffer-XlvJLrhZ.cjs.map} +1 -1
  169. package/dist/{snsSubscriptions-DmKrw7AF.cjs → snsSubscriptions-CJAOhWq9.cjs} +11 -12
  170. package/dist/{snsSubscriptions-DmKrw7AF.cjs.map → snsSubscriptions-CJAOhWq9.cjs.map} +1 -1
  171. package/dist/{snsSubscriptions-k61hsIRw.mjs → snsSubscriptions-DDrra9rN.mjs} +3 -4
  172. package/dist/{snsSubscriptions-k61hsIRw.mjs.map → snsSubscriptions-DDrra9rN.mjs.map} +1 -1
  173. package/dist/{sst-CvOnXAel.mjs → sst-CdHflajE.mjs} +6 -6
  174. package/dist/{sst-CvOnXAel.mjs.map → sst-CdHflajE.mjs.map} +1 -1
  175. package/dist/{sst-DGsteg5j.cjs → sst-CsEjVFtz.cjs} +8 -8
  176. package/dist/{sst-DGsteg5j.cjs.map → sst-CsEjVFtz.cjs.map} +1 -1
  177. package/dist/stack-BYhtz-bE.cjs +11449 -0
  178. package/dist/stack-BYhtz-bE.cjs.map +1 -0
  179. package/dist/stack-CLHY-_2m.mjs +10474 -0
  180. package/dist/stack-CLHY-_2m.mjs.map +1 -0
  181. package/dist/{stage-8KJCtYtl.cjs → stage-Bc_BtQeG.cjs} +11 -12
  182. package/dist/stage-Bc_BtQeG.cjs.map +1 -0
  183. package/dist/{stage-CXIdtjY2.mjs → stage-C7aYyDMr.mjs} +5 -6
  184. package/dist/stage-C7aYyDMr.mjs.map +1 -0
  185. package/dist/{stages-BNoiMXfL.mjs → stages-DFvE7iEO.mjs} +2 -2
  186. package/dist/{stages-BNoiMXfL.mjs.map → stages-DFvE7iEO.mjs.map} +1 -1
  187. package/dist/{stages-tdJKM9qp.cjs → stages-Dk6Lv7DY.cjs} +2 -2
  188. package/dist/{stages-tdJKM9qp.cjs.map → stages-Dk6Lv7DY.cjs.map} +1 -1
  189. package/dist/target/public.cjs +1 -1
  190. package/dist/target/public.d.cts +2 -2
  191. package/dist/target/public.d.mts +2 -2
  192. package/dist/target/public.mjs +1 -1
  193. package/dist/{terminal-GzAW5lzO.mjs → terminal-BZzK69T9.mjs} +2 -2
  194. package/dist/{terminal-GzAW5lzO.mjs.map → terminal-BZzK69T9.mjs.map} +1 -1
  195. package/dist/{terminal-DSQgidon.cjs → terminal-DXUXlqrO.cjs} +5 -5
  196. package/dist/{terminal-DSQgidon.cjs.map → terminal-DXUXlqrO.cjs.map} +1 -1
  197. package/dist/{types-BRnmoWCt.d.cts → types-BVDaaLas.d.cts} +22 -4
  198. package/dist/{types-BRnmoWCt.d.cts.map → types-BVDaaLas.d.cts.map} +1 -1
  199. package/dist/{types-Bg7LSAD2.d.mts → types-CJTKWLkK.d.mts} +22 -4
  200. package/dist/{types-Bg7LSAD2.d.mts.map → types-CJTKWLkK.d.mts.map} +1 -1
  201. package/dist/{utils-D_fxUqvU.mjs → utils-CdKxD8Lt.mjs} +2 -2
  202. package/dist/{utils-D_fxUqvU.mjs.map → utils-CdKxD8Lt.mjs.map} +1 -1
  203. package/dist/{utils-D2Nk1Nv2.cjs → utils-DBqXbB8P.cjs} +2 -2
  204. package/dist/{utils-D2Nk1Nv2.cjs.map → utils-DBqXbB8P.cjs.map} +1 -1
  205. package/dist/vitest.cjs +1 -1
  206. package/dist/vitest.mjs +1 -1
  207. package/dist/workspace/index.cjs +1 -1
  208. package/dist/workspace/index.d.cts +2 -2
  209. package/dist/workspace/index.d.mts +2 -2
  210. package/dist/workspace/index.mjs +1 -1
  211. package/dist/{workspace-fGwzXa5l.cjs → workspace-CTspddnJ.cjs} +55 -16
  212. package/dist/workspace-CTspddnJ.cjs.map +1 -0
  213. package/dist/{workspace-DTX6CJi2.mjs → workspace-CdiCMRap.mjs} +55 -16
  214. package/dist/workspace-CdiCMRap.mjs.map +1 -0
  215. package/package.json +16 -16
  216. package/dist/apps-CXzjaPWR.mjs +0 -4650
  217. package/dist/apps-CXzjaPWR.mjs.map +0 -1
  218. package/dist/apps-vLzb0ZSA.cjs +0 -5174
  219. package/dist/apps-vLzb0ZSA.cjs.map +0 -1
  220. package/dist/clientTelemetry-Ej1tf1VE.d.cts.map +0 -1
  221. package/dist/clientTelemetry-crdjgehZ.d.mts.map +0 -1
  222. package/dist/compose-CJznzQc7.mjs.map +0 -1
  223. package/dist/compose-CKBieltT.cjs.map +0 -1
  224. package/dist/compose-CvNyjqwL.cjs.map +0 -1
  225. package/dist/compose-DPXoarGI.mjs.map +0 -1
  226. package/dist/deploy-BaSYxpny.cjs.map +0 -1
  227. package/dist/deploy-C_uZBzvS.mjs.map +0 -1
  228. package/dist/dns-BzYrbB2Y.cjs.map +0 -1
  229. package/dist/dns-C0wbTjVX.mjs.map +0 -1
  230. package/dist/docker-CPoUMg5X.mjs +0 -1649
  231. package/dist/docker-CPoUMg5X.mjs.map +0 -1
  232. package/dist/docker-CrhpQWnL.cjs +0 -1798
  233. package/dist/docker-CrhpQWnL.cjs.map +0 -1
  234. package/dist/notes-6F8YXU8m.mjs +0 -409
  235. package/dist/notes-6F8YXU8m.mjs.map +0 -1
  236. package/dist/notes-DMOLnNJI.cjs +0 -510
  237. package/dist/notes-DMOLnNJI.cjs.map +0 -1
  238. package/dist/stack-Dd-egttk.mjs +0 -1777
  239. package/dist/stack-Dd-egttk.mjs.map +0 -1
  240. package/dist/stack-vBnc84e8.cjs +0 -1887
  241. package/dist/stack-vBnc84e8.cjs.map +0 -1
  242. package/dist/stage-8KJCtYtl.cjs.map +0 -1
  243. package/dist/stage-CXIdtjY2.mjs.map +0 -1
  244. package/dist/workspace-DTX6CJi2.mjs.map +0 -1
  245. package/dist/workspace-fGwzXa5l.cjs.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { t as GkmError } from "./errors-C9uIyIDt.mjs";
2
- import { E as secretsStoreFor, l as storedCredentials, n as findRootDomain, q as deployIdentity, r as normalizeDnsConfig, t as extractSubdomain } from "./dns-C0wbTjVX.mjs";
3
- import { d as removeEdgeRoutes, f as composeServer, h as sshTarget, o as stackOverrideFile, p as dockerHost, u as edgeRef, v as dockerCompose } from "./compose-DPXoarGI.mjs";
4
- import { N as assertDeployedStage } from "./workspace-DTX6CJi2.mjs";
2
+ import { A as deployIdentity, l as secretsStoreFor, r as storedCredentials } from "./credentials-ztezRtR4.mjs";
3
+ import { G as findRootDomain, Gn as dockerCompose, Ht as removeEdgeRoutes, K as normalizeDnsConfig, W as extractSubdomain, g as awsProvisioningCredentials, h as awsEndpoint, l as stackDir, m as awsClientConfig, r as composeProject, zt as edgeRef } from "./stack-CLHY-_2m.mjs";
4
+ import { N as assertDeployedStage } from "./workspace-CdiCMRap.mjs";
5
+ import { a as stackOverrideFile, f as sshTarget, l as composeServer, u as dockerHost } from "./compose-Dx_nSZYU.mjs";
5
6
  import { loadWorkspaceConfig } from "./config.mjs";
6
- import { _ as awsEndpoint, a as composeProject, d as stackDir, g as awsClientConfig, v as awsProvisioningCredentials } from "./stack-Dd-egttk.mjs";
7
- import { S as createStateStore } from "./sniffer-01tbQFmg.mjs";
8
- import { c as defaultCdnClients, o as defaultClients, s as cdnName } from "./deploy-C_uZBzvS.mjs";
9
- import { d as dnsCredentials, m as recordTtl, p as pruneStackDns } from "./snsSubscriptions-k61hsIRw.mjs";
10
- import "./iam-CqW9hsd2.mjs";
7
+ import { S as createStateStore } from "./sniffer-CX8sI8Cu.mjs";
8
+ import { c as defaultCdnClients, o as defaultClients, s as cdnName } from "./deploy-Cpz5sKbh.mjs";
9
+ import { d as dnsCredentials, m as recordTtl, p as pruneStackDns } from "./snsSubscriptions-DDrra9rN.mjs";
10
+ import "./iam-DloEBLXZ.mjs";
11
11
  import { c as dnsRecordFqdn, d as dnsResources } from "./seeds-Ccn0Ru2T.mjs";
12
12
  import { l as canPrompt, u as prompt } from "./index.mjs";
13
13
  import { join, resolve } from "node:path";
@@ -786,4 +786,4 @@ function providerDnsRecords(workspace, records) {
786
786
  //#endregion
787
787
  export { composeDestroyCommand, composeStackRef };
788
788
 
789
- //# sourceMappingURL=destroy-yTBmL1jf.mjs.map
789
+ //# sourceMappingURL=destroy-DRlcWJwm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"destroy-yTBmL1jf.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 type { DnsProvider } from '@geekmidas/edge/dns';\nimport { EDGE_PROJECT } from '@geekmidas/edge/proxy/traefik';\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 {\n\textractSubdomain,\n\tfindRootDomain,\n\tnormalizeDnsConfig,\n} from '../dns/index';\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 { 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';\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,8CAC1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G,KAAK,MAAM,4BACd,KAAK;EACT,MAAM,CAAC,KAAK,GAAG;EACf,GAAI,KAAK,SAAS,EAAE,KAAK,KAAK,OAAO,IAAI,CAAC;CAC3C;AACD;;AAGA,SAAS,mBACR,WACA,SACsB;CACtB,MAAM,MAAM,UAAU,MAAM,mBAAmB,UAAU,GAAG,IAAI,CAAC;CACjE,MAAM,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-DRlcWJwm.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 type { DnsProvider } from '@geekmidas/edge/dns';\nimport { EDGE_PROJECT } from '@geekmidas/edge/proxy/traefik';\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 {\n\textractSubdomain,\n\tfindRootDomain,\n\tnormalizeDnsConfig,\n} from '../dns/index';\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 { 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';\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,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AAM,CAAC,KAAK,GAAG;EACf,GAAI,KAAK,SAAS,EAAE,KAAK,KAAK,OAAO,IAAI,CAAC;CAC3C;AACD;;AAGA,SAAS,mBACR,WACA,SACsB;CACtB,MAAM,MAAM,UAAU,MAAM,mBAAmB,UAAU,GAAG,IAAI,CAAC;CACjE,MAAM,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,13 +1,13 @@
1
1
  const require_errors = require("./errors-D1x8duqI.cjs");
2
- const require_dns = require("./dns-BzYrbB2Y.cjs");
3
- const require_compose = require("./compose-CKBieltT.cjs");
4
- const require_workspace = require("./workspace-fGwzXa5l.cjs");
2
+ const require_credentials = require("./credentials-n2abUWwJ.cjs");
3
+ const require_stack = require("./stack-BYhtz-bE.cjs");
4
+ const require_workspace = require("./workspace-CTspddnJ.cjs");
5
+ const require_compose = require("./compose-BEVBxf4w.cjs");
5
6
  const require_config = require("./config.cjs");
6
- const require_stack = require("./stack-vBnc84e8.cjs");
7
- const require_sniffer = require("./sniffer-CkPIytPI.cjs");
8
- const require_deploy = require("./deploy-BaSYxpny.cjs");
9
- const require_snsSubscriptions = require("./snsSubscriptions-DmKrw7AF.cjs");
10
- require("./iam-DeBQcSvw.cjs");
7
+ const require_sniffer = require("./sniffer-XlvJLrhZ.cjs");
8
+ const require_deploy = require("./deploy-CDUWcl58.cjs");
9
+ const require_snsSubscriptions = require("./snsSubscriptions-CJAOhWq9.cjs");
10
+ require("./iam-SxPKYCI_.cjs");
11
11
  const require_seeds = require("./seeds-Bc3niNVb.cjs");
12
12
  const require_index = require("./index.cjs");
13
13
  let node_path = require("node:path");
@@ -596,13 +596,13 @@ async function composeStackRef(workspace, stage) {
596
596
  stage,
597
597
  local,
598
598
  config: workspace.deploy?.compose?.server,
599
- custom: (await (await require_dns.secretsStoreFor(workspace, stage)).read(stage))?.custom
599
+ custom: (await (await require_credentials.secretsStoreFor(workspace, stage)).read(stage))?.custom
600
600
  });
601
601
  const override = require_compose.stackOverrideFile(workspace.root, stage);
602
602
  const dir = (0, node_path.join)(workspace.root, require_stack.stackDir(stage));
603
603
  return {
604
604
  ref: {
605
- project: require_stack.composeProject(require_dns.deployIdentity(workspace, stage)),
605
+ project: require_stack.composeProject(require_credentials.deployIdentity(workspace, stage)),
606
606
  file: (0, node_path.join)(dir, "docker-compose.yml"),
607
607
  ...(0, node_fs.existsSync)(override) ? { overrides: [override] } : {},
608
608
  cwd: workspace.root,
@@ -621,7 +621,7 @@ async function composeDestroyCommand(options, deps = {}) {
621
621
  const { stage } = options;
622
622
  const local = stage === workspace.stages.local;
623
623
  if (!local) require_workspace.assertDeployedStage(workspace.stages, stage);
624
- const identity = require_dns.deployIdentity(workspace, stage);
624
+ const identity = require_credentials.deployIdentity(workspace, stage);
625
625
  const project = require_stack.composeProject(identity);
626
626
  const interactive = deps.interactive ?? require_index.canPrompt;
627
627
  if (!options.dryRun && !interactive()) throw new ComposeDestroyNeedsTerminal(stage, project);
@@ -666,12 +666,12 @@ async function plan(workspace, stage, options, deps, state, env) {
666
666
  const resources = (await state.read(stage))?.resources ?? {};
667
667
  const records = Object.values(resources);
668
668
  const { ref, dir, server } = await composeStackRef(workspace, stage);
669
- const docker = deps.docker ?? require_compose.dockerCompose;
669
+ const docker = deps.docker ?? require_stack.dockerCompose;
670
670
  steps.push({
671
671
  label: `${server ? `on ${require_compose.sshTarget(server)}: ` : ""}stack ${ref.project} — its containers, its volumes and their data, its routes on ${_geekmidas_edge_proxy_traefik.EDGE_PROJECT}`,
672
672
  run: async () => {
673
673
  const edgeFile = (0, node_path.join)(dir, `${_geekmidas_edge_proxy_traefik.EDGE_PROJECT}.yml`);
674
- if (server || (0, node_fs.existsSync)(edgeFile)) await require_compose.removeEdgeRoutes(docker, require_compose.edgeRef(edgeFile, { host: ref.host }), ref.project);
674
+ if (server || (0, node_fs.existsSync)(edgeFile)) await require_stack.removeEdgeRoutes(docker, require_stack.edgeRef(edgeFile, { host: ref.host }), ref.project);
675
675
  await docker.down(ref, { volumes: true });
676
676
  }
677
677
  });
@@ -684,7 +684,7 @@ async function plan(workspace, stage, options, deps, state, env) {
684
684
  ...deps.home ? { home: deps.home } : {}
685
685
  })))();
686
686
  if (!credential) throw new ComposeDestroyNeedsAwsCredentials(stage, aws.map((r) => r.key));
687
- const identity = require_dns.deployIdentity(workspace, stage);
687
+ const identity = require_credentials.deployIdentity(workspace, stage);
688
688
  const planned = await planAwsDestroy({
689
689
  resources,
690
690
  identityKey: identity.key,
@@ -703,12 +703,12 @@ async function plan(workspace, stage, options, deps, state, env) {
703
703
  const seen = new Set(recorded.map((r) => `${r.fqdn} ${r.type}`));
704
704
  const dnsRecords = [...recorded, ...cdnDns.filter((r) => !seen.has(`${r.fqdn} ${r.type}`))];
705
705
  if (dnsRecords.length > 0) {
706
- const dns = workspace.dns ? require_dns.normalizeDnsConfig(workspace.dns) : {};
706
+ const dns = workspace.dns ? require_stack.normalizeDnsConfig(workspace.dns) : {};
707
707
  const domains = [...new Set(dnsRecords.map((r) => r.domain))].filter((domain) => dns[domain]).map((domain) => ({
708
708
  domain,
709
709
  config: dns[domain]
710
710
  }));
711
- const tokens = await require_snsSubscriptions.dnsCredentials(stage, domains, deps.credentials ?? require_dns.storedCredentials({ env }));
711
+ const tokens = await require_snsSubscriptions.dnsCredentials(stage, domains, deps.credentials ?? require_credentials.storedCredentials({ env }));
712
712
  const log = deps.log ?? ((line) => console.log(line));
713
713
  steps.push({
714
714
  label: `DNS: ${dnsRecords.map((r) => `${r.type} ${r.fqdn}`).join(", ")} — each only while it holds the value gkm wrote`,
@@ -738,7 +738,7 @@ async function plan(workspace, stage, options, deps, state, env) {
738
738
  });
739
739
  }
740
740
  if (options.secrets) {
741
- const store = await require_dns.secretsStoreFor(workspace, stage, { ...deps.home ? { home: deps.home } : {} });
741
+ const store = await require_credentials.secretsStoreFor(workspace, stage, { ...deps.home ? { home: deps.home } : {} });
742
742
  if (!store.delete) throw new SecretsStoreCannotDelete(stage, store.name);
743
743
  steps.push({
744
744
  label: `the stage's secrets, in its ${store.name} store`,
@@ -764,17 +764,17 @@ function awsStep(step) {
764
764
  }
765
765
  /** The CDN's records, as the DNS prune takes them. */
766
766
  function providerDnsRecords(workspace, records) {
767
- const dns = workspace.dns ? require_dns.normalizeDnsConfig(workspace.dns) : {};
767
+ const dns = workspace.dns ? require_stack.normalizeDnsConfig(workspace.dns) : {};
768
768
  const out = [];
769
769
  for (const record of records) {
770
770
  const host = record.host.toLowerCase().replace(/\.$/, "");
771
- const domain = require_dns.findRootDomain(host, dns);
771
+ const domain = require_stack.findRootDomain(host, dns);
772
772
  if (!domain) continue;
773
773
  const config = dns[domain];
774
774
  out.push({
775
775
  fqdn: host,
776
776
  domain,
777
- name: require_dns.extractSubdomain(host, domain),
777
+ name: require_stack.extractSubdomain(host, domain),
778
778
  type: record.type,
779
779
  value: record.value.replace(/\.$/, ""),
780
780
  ttl: require_snsSubscriptions.recordTtl(config),
@@ -787,4 +787,4 @@ function providerDnsRecords(workspace, records) {
787
787
  exports.composeDestroyCommand = composeDestroyCommand;
788
788
  exports.composeStackRef = composeStackRef;
789
789
 
790
- //# sourceMappingURL=destroy-PvrHxZDu.cjs.map
790
+ //# sourceMappingURL=destroy-DzeV0EdY.cjs.map