@geekmidas/cli 10.0.0-alpha.160 → 10.0.0-alpha.161

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 (219) hide show
  1. package/dist/{GoDaddyProvider-DkUMcMYy.cjs → GoDaddyProvider-CBqsvbER.cjs} +2 -2
  2. package/dist/{GoDaddyProvider-DkUMcMYy.cjs.map → GoDaddyProvider-CBqsvbER.cjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-C9dDlH9I.mjs → GoDaddyProvider-CwqdLM1E.mjs} +2 -2
  4. package/dist/{GoDaddyProvider-C9dDlH9I.mjs.map → GoDaddyProvider-CwqdLM1E.mjs.map} +1 -1
  5. package/dist/{HostingerProvider-9faYOQnQ.cjs → HostingerProvider-DtOtsFkM.cjs} +2 -2
  6. package/dist/{HostingerProvider-9faYOQnQ.cjs.map → HostingerProvider-DtOtsFkM.cjs.map} +1 -1
  7. package/dist/{HostingerProvider-BEuKG2gz.mjs → HostingerProvider-gD4uqzMN.mjs} +2 -2
  8. package/dist/{HostingerProvider-BEuKG2gz.mjs.map → HostingerProvider-gD4uqzMN.mjs.map} +1 -1
  9. package/dist/{LegacyStateStore-DPKhjUR6.mjs → LegacyStateStore-6xsGADme.mjs} +3 -3
  10. package/dist/{LegacyStateStore-DPKhjUR6.mjs.map → LegacyStateStore-6xsGADme.mjs.map} +1 -1
  11. package/dist/{LegacyStateStore-C44jUnMH.cjs → LegacyStateStore-C0rm5slD.cjs} +3 -3
  12. package/dist/{LegacyStateStore-C44jUnMH.cjs.map → LegacyStateStore-C0rm5slD.cjs.map} +1 -1
  13. package/dist/{LocalStateStore-BU3fWkcT.mjs → LocalStateStore-G0JHXOVW.mjs} +2 -2
  14. package/dist/{LocalStateStore-BU3fWkcT.mjs.map → LocalStateStore-G0JHXOVW.mjs.map} +1 -1
  15. package/dist/{LocalStateStore-B95WE99i.cjs → LocalStateStore-NBMF3zCb.cjs} +2 -2
  16. package/dist/{LocalStateStore-B95WE99i.cjs.map → LocalStateStore-NBMF3zCb.cjs.map} +1 -1
  17. package/dist/{S3StateStore-zU5kClhd.cjs → S3StateStore-7n6gIYEJ.cjs} +4 -4
  18. package/dist/{S3StateStore-zU5kClhd.cjs.map → S3StateStore-7n6gIYEJ.cjs.map} +1 -1
  19. package/dist/{S3StateStore-Cpbeijr5.mjs → S3StateStore-B7IPTvu0.mjs} +4 -4
  20. package/dist/{S3StateStore-Cpbeijr5.mjs.map → S3StateStore-B7IPTvu0.mjs.map} +1 -1
  21. package/dist/{SSMStateStore-BxkKMBi_.mjs → SSMStateStore-CWEShHLS.mjs} +2 -2
  22. package/dist/{SSMStateStore-BxkKMBi_.mjs.map → SSMStateStore-CWEShHLS.mjs.map} +1 -1
  23. package/dist/{SSMStateStore-D9uviQ3T.cjs → SSMStateStore-O12NeGEg.cjs} +2 -2
  24. package/dist/{SSMStateStore-D9uviQ3T.cjs.map → SSMStateStore-O12NeGEg.cjs.map} +1 -1
  25. package/dist/{add-Dj-gtqTO.mjs → add-C-nlqQgN.mjs} +4 -4
  26. package/dist/{add-Dj-gtqTO.mjs.map → add-C-nlqQgN.mjs.map} +1 -1
  27. package/dist/{add-Bb2IL3Yq.cjs → add-ktNZmJb-.cjs} +4 -4
  28. package/dist/{add-Bb2IL3Yq.cjs.map → add-ktNZmJb-.cjs.map} +1 -1
  29. package/dist/{apps-FRNlECwi.mjs → apps-C7SujLV-.mjs} +3 -3
  30. package/dist/{apps-FRNlECwi.mjs.map → apps-C7SujLV-.mjs.map} +1 -1
  31. package/dist/{apps-0vc4Oz9_.cjs → apps-CtjYJS9e.cjs} +3 -3
  32. package/dist/{apps-0vc4Oz9_.cjs.map → apps-CtjYJS9e.cjs.map} +1 -1
  33. package/dist/{aws-8QQ8n-t6.mjs → aws-C5LAU_Ii.mjs} +10 -2
  34. package/dist/aws-C5LAU_Ii.mjs.map +1 -0
  35. package/dist/{aws-DY9NqQIT.cjs → aws-DKC2m3sT.cjs} +9 -1
  36. package/dist/aws-DKC2m3sT.cjs.map +1 -0
  37. package/dist/{bundler-Bg2eEFEh.cjs → bundler-DGwgZmim.cjs} +6 -6
  38. package/dist/{bundler-Bg2eEFEh.cjs.map → bundler-DGwgZmim.cjs.map} +1 -1
  39. package/dist/{bundler-9EM4ZHcu.mjs → bundler-DnHKVaZz.mjs} +6 -6
  40. package/dist/{bundler-9EM4ZHcu.mjs.map → bundler-DnHKVaZz.mjs.map} +1 -1
  41. package/dist/{cli-CmoSOzNq.mjs → cli-CI9v138l.mjs} +4 -4
  42. package/dist/{cli-CmoSOzNq.mjs.map → cli-CI9v138l.mjs.map} +1 -1
  43. package/dist/{cli-YtLjcAZT.cjs → cli-k2G7rG15.cjs} +4 -4
  44. package/dist/{cli-YtLjcAZT.cjs.map → cli-k2G7rG15.cjs.map} +1 -1
  45. package/dist/{compose-CW1DGfYc.cjs → compose-BD2rwRfn.cjs} +4 -4
  46. package/dist/{compose-CW1DGfYc.cjs.map → compose-BD2rwRfn.cjs.map} +1 -1
  47. package/dist/{compose-3AtZF7ul.mjs → compose-Co-Dt-a4.mjs} +4 -4
  48. package/dist/{compose-3AtZF7ul.mjs.map → compose-Co-Dt-a4.mjs.map} +1 -1
  49. package/dist/{compose-D7gOSspy.cjs → compose-nGgRylPu.cjs} +16 -10
  50. package/dist/compose-nGgRylPu.cjs.map +1 -0
  51. package/dist/{compose-CnXZAYNM.mjs → compose-reJW9x-G.mjs} +16 -10
  52. package/dist/compose-reJW9x-G.mjs.map +1 -0
  53. package/dist/{config-CkuiD9Jv.d.cts → config-C60T2h98.d.cts} +3 -3
  54. package/dist/{config-BNmLn0dw.d.mts.map → config-C60T2h98.d.cts.map} +1 -1
  55. package/dist/{config-BNmLn0dw.d.mts → config-CfI2g_Ho.d.mts} +3 -3
  56. package/dist/{config-CkuiD9Jv.d.cts.map → config-CfI2g_Ho.d.mts.map} +1 -1
  57. package/dist/config.d.cts +3 -3
  58. package/dist/config.d.mts +3 -3
  59. package/dist/{credentials-CjFtNBVH.mjs → credentials-BG1KOq9I.mjs} +11 -7
  60. package/dist/credentials-BG1KOq9I.mjs.map +1 -0
  61. package/dist/{credentials-DwIRfeBL.cjs → credentials-UlL1n_Rd.cjs} +11 -7
  62. package/dist/credentials-UlL1n_Rd.cjs.map +1 -0
  63. package/dist/deploy/public.cjs +11 -11
  64. package/dist/deploy/public.d.cts +4 -4
  65. package/dist/deploy/public.d.mts +4 -4
  66. package/dist/deploy/public.mjs +11 -11
  67. package/dist/{deploy-3bsiWJxj.cjs → deploy-CqIULk0k.cjs} +57 -557
  68. package/dist/deploy-CqIULk0k.cjs.map +1 -0
  69. package/dist/{deploy-BI3fHnyb.mjs → deploy-DRkCNV7f.mjs} +16 -516
  70. package/dist/deploy-DRkCNV7f.mjs.map +1 -0
  71. package/dist/destroy-CMldkiX-.cjs +789 -0
  72. package/dist/destroy-CMldkiX-.cjs.map +1 -0
  73. package/dist/destroy-DXIAL8nF.mjs +788 -0
  74. package/dist/destroy-DXIAL8nF.mjs.map +1 -0
  75. package/dist/{docker-DPdn7tYJ.mjs → docker-DFFzQe2f.mjs} +4 -4
  76. package/dist/{docker-DPdn7tYJ.mjs.map → docker-DFFzQe2f.mjs.map} +1 -1
  77. package/dist/{docker-CwayjAF2.cjs → docker-LwJW3dx_.cjs} +4 -4
  78. package/dist/{docker-CwayjAF2.cjs.map → docker-LwJW3dx_.cjs.map} +1 -1
  79. package/dist/{dokploy-tmnH0Du_.mjs → dokploy-DYm0D6Tp.mjs} +2 -2
  80. package/dist/{dokploy-tmnH0Du_.mjs.map → dokploy-DYm0D6Tp.mjs.map} +1 -1
  81. package/dist/{dokploy-BMBL-_Xu.cjs → dokploy-wTsJqG-N.cjs} +2 -2
  82. package/dist/{dokploy-BMBL-_Xu.cjs.map → dokploy-wTsJqG-N.cjs.map} +1 -1
  83. package/dist/{eas-BVGQAUDc.mjs → eas-BJ_Zlvm8.mjs} +2 -2
  84. package/dist/{eas-BVGQAUDc.mjs.map → eas-BJ_Zlvm8.mjs.map} +1 -1
  85. package/dist/{eas-meN1xady.cjs → eas-C4EkjTGJ.cjs} +2 -2
  86. package/dist/{eas-meN1xady.cjs.map → eas-C4EkjTGJ.cjs.map} +1 -1
  87. package/dist/{encryption-DvFVZdGz.cjs → encryption-BQEqqrGq.cjs} +2 -2
  88. package/dist/{encryption-DvFVZdGz.cjs.map → encryption-BQEqqrGq.cjs.map} +1 -1
  89. package/dist/{encryption-C8AMbomA.mjs → encryption-Cu5YTs9V.mjs} +2 -2
  90. package/dist/{encryption-C8AMbomA.mjs.map → encryption-Cu5YTs9V.mjs.map} +1 -1
  91. package/dist/{engine-BmiIUVWa.cjs → engine-DdRauUQC.cjs} +9 -9
  92. package/dist/{engine-BmiIUVWa.cjs.map → engine-DdRauUQC.cjs.map} +1 -1
  93. package/dist/{engine-BbWj0w3F.mjs → engine-q8aCVbLH.mjs} +9 -9
  94. package/dist/{engine-BbWj0w3F.mjs.map → engine-q8aCVbLH.mjs.map} +1 -1
  95. package/dist/{github-Dc1daUbH.mjs → github-CoXirRes.mjs} +9 -8
  96. package/dist/{github-Dc1daUbH.mjs.map → github-CoXirRes.mjs.map} +1 -1
  97. package/dist/{github-BWqQr8q6.cjs → github-OVZF2k0L.cjs} +13 -12
  98. package/dist/{github-BWqQr8q6.cjs.map → github-OVZF2k0L.cjs.map} +1 -1
  99. package/dist/{googlePlay-CdVCdfU8.cjs → googlePlay-CUeTUT7s.cjs} +4 -4
  100. package/dist/{googlePlay-CdVCdfU8.cjs.map → googlePlay-CUeTUT7s.cjs.map} +1 -1
  101. package/dist/{googlePlay-ByaFUly7.mjs → googlePlay-HXRRVq0l.mjs} +4 -4
  102. package/dist/{googlePlay-ByaFUly7.mjs.map → googlePlay-HXRRVq0l.mjs.map} +1 -1
  103. package/dist/iam-6LH6wptf.cjs +618 -0
  104. package/dist/iam-6LH6wptf.cjs.map +1 -0
  105. package/dist/iam-c0e8m04X.mjs +509 -0
  106. package/dist/iam-c0e8m04X.mjs.map +1 -0
  107. package/dist/{index-Dv1Zj86i.d.mts → index-DDY0cZCo.d.cts} +2 -2
  108. package/dist/{index-B35vTdAW.d.cts.map → index-DDY0cZCo.d.cts.map} +1 -1
  109. package/dist/{index-B35vTdAW.d.cts → index-DWNwkcy7.d.mts} +2 -2
  110. package/dist/{index-Dv1Zj86i.d.mts.map → index-DWNwkcy7.d.mts.map} +1 -1
  111. package/dist/index.cjs +98 -77
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.mjs +98 -77
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/{local-CnVFHJjS.mjs → local-CCJ-T37d.mjs} +2 -2
  116. package/dist/{local-CnVFHJjS.mjs.map → local-CCJ-T37d.mjs.map} +1 -1
  117. package/dist/{local-qevrV6dZ.cjs → local-Dx0o6vfp.cjs} +2 -2
  118. package/dist/{local-qevrV6dZ.cjs.map → local-Dx0o6vfp.cjs.map} +1 -1
  119. package/dist/{migrate-DgfKZB41.mjs → migrate-BkwSXhxv.mjs} +4 -4
  120. package/dist/{migrate-DgfKZB41.mjs.map → migrate-BkwSXhxv.mjs.map} +1 -1
  121. package/dist/{migrate-CU8_ZWP1.cjs → migrate-CJoKOCGY.cjs} +4 -4
  122. package/dist/{migrate-CU8_ZWP1.cjs.map → migrate-CJoKOCGY.cjs.map} +1 -1
  123. package/dist/{migrate-CRRps1i6.cjs → migrate-DEsYfgzn.cjs} +4 -4
  124. package/dist/{migrate-CRRps1i6.cjs.map → migrate-DEsYfgzn.cjs.map} +1 -1
  125. package/dist/{migrate-BEuCcCwN.mjs → migrate-Dr0BeWsY.mjs} +4 -4
  126. package/dist/{migrate-BEuCcCwN.mjs.map → migrate-Dr0BeWsY.mjs.map} +1 -1
  127. package/dist/{notes-CIzrdBKE.mjs → notes-BOyzuPqr.mjs} +2 -2
  128. package/dist/{notes-CIzrdBKE.mjs.map → notes-BOyzuPqr.mjs.map} +1 -1
  129. package/dist/{notes-BrBnyZz5.cjs → notes-VFPa51Pd.cjs} +2 -2
  130. package/dist/{notes-BrBnyZz5.cjs.map → notes-VFPa51Pd.cjs.map} +1 -1
  131. package/dist/openapi.d.cts +1 -1
  132. package/dist/openapi.d.mts +1 -1
  133. package/dist/{projectBucket-CDJd3prK.mjs → projectBucket-B26ucBRI.mjs} +2 -2
  134. package/dist/{projectBucket-CDJd3prK.mjs.map → projectBucket-B26ucBRI.mjs.map} +1 -1
  135. package/dist/{projectBucket-CKr_zObJ.cjs → projectBucket-CWpY3Vxv.cjs} +2 -2
  136. package/dist/{projectBucket-CKr_zObJ.cjs.map → projectBucket-CWpY3Vxv.cjs.map} +1 -1
  137. package/dist/{publish-Bq96_QnK.mjs → publish-Bg4iffje.mjs} +2 -2
  138. package/dist/{publish-Bq96_QnK.mjs.map → publish-Bg4iffje.mjs.map} +1 -1
  139. package/dist/{publish-DMKXh1Tb.cjs → publish-IjcRoorJ.cjs} +2 -2
  140. package/dist/{publish-DMKXh1Tb.cjs.map → publish-IjcRoorJ.cjs.map} +1 -1
  141. package/dist/reconcile/public.d.cts +1 -1
  142. package/dist/reconcile/public.d.mts +1 -1
  143. package/dist/{resolve-DF9GrosZ.cjs → resolve-CgVDhWW8.cjs} +4 -4
  144. package/dist/{resolve-DF9GrosZ.cjs.map → resolve-CgVDhWW8.cjs.map} +1 -1
  145. package/dist/{resolve-CSsE7frp.mjs → resolve-rw7mLp5E.mjs} +4 -4
  146. package/dist/{resolve-CSsE7frp.mjs.map → resolve-rw7mLp5E.mjs.map} +1 -1
  147. package/dist/{rollback-CZthwqus.mjs → rollback-Cv02Cnky.mjs} +6 -6
  148. package/dist/{rollback-CZthwqus.mjs.map → rollback-Cv02Cnky.mjs.map} +1 -1
  149. package/dist/{rollback-BBFGGmMa.cjs → rollback-vdkPi_Rm.cjs} +6 -6
  150. package/dist/{rollback-BBFGGmMa.cjs.map → rollback-vdkPi_Rm.cjs.map} +1 -1
  151. package/dist/{runtime-CFvcLEJW.d.cts → runtime-D-rOcRoq.d.cts} +2 -2
  152. package/dist/{runtime-CFvcLEJW.d.cts.map → runtime-D-rOcRoq.d.cts.map} +1 -1
  153. package/dist/{runtime-dwsH6ddo.d.mts → runtime-DG1mNh_5.d.mts} +2 -2
  154. package/dist/{runtime-dwsH6ddo.d.mts.map → runtime-DG1mNh_5.d.mts.map} +1 -1
  155. package/dist/{s3-CI2QYgXH.cjs → s3-DIvAtJwk.cjs} +27 -2
  156. package/dist/s3-DIvAtJwk.cjs.map +1 -0
  157. package/dist/{s3-BBRkezf7.mjs → s3-DmsM_V2R.mjs} +28 -3
  158. package/dist/s3-DmsM_V2R.mjs.map +1 -0
  159. package/dist/{secretsManager-CQORubp9.mjs → secretsManager-CJyxFcBH.mjs} +18 -2
  160. package/dist/secretsManager-CJyxFcBH.mjs.map +1 -0
  161. package/dist/{secretsManager-RAGcEDX1.cjs → secretsManager-D8on44WI.cjs} +17 -1
  162. package/dist/secretsManager-D8on44WI.cjs.map +1 -0
  163. package/dist/{seeds-B3xvUAQf.cjs → seeds-D7q1zKCJ.cjs} +7 -1
  164. package/dist/{seeds-B3xvUAQf.cjs.map → seeds-D7q1zKCJ.cjs.map} +1 -1
  165. package/dist/{seeds-BCC8vAXR.mjs → seeds-y1rzXlAc.mjs} +2 -2
  166. package/dist/{seeds-BCC8vAXR.mjs.map → seeds-y1rzXlAc.mjs.map} +1 -1
  167. package/dist/{serverSetup-C4iAABtI.mjs → serverSetup-CvcN4zJQ.mjs} +6 -6
  168. package/dist/{serverSetup-C4iAABtI.mjs.map → serverSetup-CvcN4zJQ.mjs.map} +1 -1
  169. package/dist/{serverSetup-Dt2DTlwa.cjs → serverSetup-qXIRRhgw.cjs} +6 -6
  170. package/dist/{serverSetup-Dt2DTlwa.cjs.map → serverSetup-qXIRRhgw.cjs.map} +1 -1
  171. package/dist/{sniffer-bTrGuu9z.cjs → sniffer-CGfL25Bc.cjs} +7 -7
  172. package/dist/{sniffer-bTrGuu9z.cjs.map → sniffer-CGfL25Bc.cjs.map} +1 -1
  173. package/dist/{sniffer-C2Ot1IbK.mjs → sniffer-DuKVVAs_.mjs} +7 -7
  174. package/dist/{sniffer-C2Ot1IbK.mjs.map → sniffer-DuKVVAs_.mjs.map} +1 -1
  175. package/dist/{snsSubscriptions-CFKb7fv0.cjs → snsSubscriptions-DPfGjpuB.cjs} +8 -2
  176. package/dist/{snsSubscriptions-CFKb7fv0.cjs.map → snsSubscriptions-DPfGjpuB.cjs.map} +1 -1
  177. package/dist/{snsSubscriptions-QDDDn9Qi.mjs → snsSubscriptions-nnSUW2Eh.mjs} +3 -3
  178. package/dist/{snsSubscriptions-QDDDn9Qi.mjs.map → snsSubscriptions-nnSUW2Eh.mjs.map} +1 -1
  179. package/dist/{sst-DDRWlXdv.mjs → sst-Bw7686br.mjs} +4 -4
  180. package/dist/{sst-DDRWlXdv.mjs.map → sst-Bw7686br.mjs.map} +1 -1
  181. package/dist/{sst-iRdMlGKd.cjs → sst-Md7c1UC_.cjs} +4 -4
  182. package/dist/{sst-iRdMlGKd.cjs.map → sst-Md7c1UC_.cjs.map} +1 -1
  183. package/dist/{stack-CIOY44aC.mjs → stack-D2cLLaO-.mjs} +6 -6
  184. package/dist/{stack-CIOY44aC.mjs.map → stack-D2cLLaO-.mjs.map} +1 -1
  185. package/dist/{stack-B9iDYMrq.cjs → stack-DTcnynGb.cjs} +6 -6
  186. package/dist/{stack-B9iDYMrq.cjs.map → stack-DTcnynGb.cjs.map} +1 -1
  187. package/dist/{stage-DA74aD_V.mjs → stage-Bw3bJ7Au.mjs} +5 -5
  188. package/dist/{stage-DA74aD_V.mjs.map → stage-Bw3bJ7Au.mjs.map} +1 -1
  189. package/dist/{stage-ycFS9mVn.cjs → stage-RLOenlHV.cjs} +5 -5
  190. package/dist/{stage-ycFS9mVn.cjs.map → stage-RLOenlHV.cjs.map} +1 -1
  191. package/dist/target/public.cjs +1 -1
  192. package/dist/target/public.d.cts +2 -2
  193. package/dist/target/public.d.mts +2 -2
  194. package/dist/target/public.mjs +1 -1
  195. package/dist/{terminal-RxfbNUwl.cjs → terminal-C-_cMKTY.cjs} +2 -2
  196. package/dist/{terminal-RxfbNUwl.cjs.map → terminal-C-_cMKTY.cjs.map} +1 -1
  197. package/dist/{terminal-DX22WLvT.mjs → terminal-Dq29bK3u.mjs} +2 -2
  198. package/dist/{terminal-DX22WLvT.mjs.map → terminal-Dq29bK3u.mjs.map} +1 -1
  199. package/dist/{types-Dk--xVOT.d.cts → types-CvucX3yD.d.mts} +7 -2
  200. package/dist/types-CvucX3yD.d.mts.map +1 -0
  201. package/dist/{types-DwQYpd_0.d.mts → types-D1C8pUyh.d.cts} +8 -1
  202. package/dist/types-D1C8pUyh.d.cts.map +1 -0
  203. package/dist/workspace/index.d.cts +2 -2
  204. package/dist/workspace/index.d.mts +2 -2
  205. package/package.json +15 -15
  206. package/dist/aws-8QQ8n-t6.mjs.map +0 -1
  207. package/dist/aws-DY9NqQIT.cjs.map +0 -1
  208. package/dist/compose-CnXZAYNM.mjs.map +0 -1
  209. package/dist/compose-D7gOSspy.cjs.map +0 -1
  210. package/dist/credentials-CjFtNBVH.mjs.map +0 -1
  211. package/dist/credentials-DwIRfeBL.cjs.map +0 -1
  212. package/dist/deploy-3bsiWJxj.cjs.map +0 -1
  213. package/dist/deploy-BI3fHnyb.mjs.map +0 -1
  214. package/dist/s3-BBRkezf7.mjs.map +0 -1
  215. package/dist/s3-CI2QYgXH.cjs.map +0 -1
  216. package/dist/secretsManager-CQORubp9.mjs.map +0 -1
  217. package/dist/secretsManager-RAGcEDX1.cjs.map +0 -1
  218. package/dist/types-Dk--xVOT.d.cts.map +0 -1
  219. package/dist/types-DwQYpd_0.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"rollback-BBFGGmMa.cjs","names":["GkmError","storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","asDokployState","dokployApi","verifySettings","restoreImage"],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: 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\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAErC;CACA;CAFV,YACC,OACA,KACC;EACD,MACC,IAAI,IAAI,+BAA+B,MAAM,oIAE9C;EANS,KAAA,QAAA;EACA,KAAA,MAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAC3B;CAArB,YAAY,OAAwB;EACnC,MACC,IAAI,MAAM,6JAEX;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;;;;AAMA,eAAsB,cACrB,OACwB;CACxB,MAAM,SAAS,MAAM,UAAU,IAAI,gBAAgB,CAAC,CAAC;CACrD,MAAM,MAAM,MAAM,cAAc,CAAC;CACjC,MAAM,cAAc,MAAM,eAAeC,oBAAAA,kBAAkB;CAC3D,MAAM,UACL,MAAM,WACN,IAAIC,cAAAA,aAAa,EAAE,MAAMC,eAAAA,mBAAAA,GAAkBC,UAAAA,QAAAA,CAAQ,MAAM,GAAG,CAAC,EAAE,CAAC;CAEjE,OAAOC,iBAAAA,YAAY,SAAS,YAAY;EACvC,MAAM,EAAE,cAAc,MAAMC,eAAAA,qBAAAA,GAAoBF,UAAAA,QAAAA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OAAO,eAAe;IACtB,MAAM,EAAE,SAAS,aAAa,SAAS;IACvC,MAAM,gBAAgB,MAAM,aAAa;IACzC,IAAI,CAAC,YAAY,CAAC,eACjB,MAAM,IAAI,kBAAkB,MAAM,OAAO,GAAG;IAG7C,IAAI,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,SAAS,KAAK;IAChD,MAAMC,eAAAA,aAAa,KAAK;KACvB;KACA,OAAO;KACP,YAAY,MAAM;KAClB;KACA;IACD,CAAC;IACD,oBAAA,eAAe,OAAO,KAAK,QAAQ;IACnC,MAAM,QAAQ,KAAK;IACnB,IAAI,QAAQ,IAAI,cAAc,SAAS,KAAK;IAC5C,OAAO,KAAK;KAAE;KAAK,MAAM;KAAS,IAAI;IAAS,CAAC;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
1
+ {"version":3,"file":"rollback-vdkPi_Rm.cjs","names":["GkmError","storedCredentials","LocalSandbox","findWorkspaceRoot","resolve","withSandbox","loadWorkspaceConfig","createStateStore","DeployJournal","createEmptyState","asDokployState","dokployApi","verifySettings","restoreImage"],"sources":["../src/target/dokploy/rollback.ts"],"sourcesContent":["/**\n * `gkm deploy:rollback`: a stage's apps put back on the release before the\n * one they run, by hand — for a release that passed its checks and turned out\n * wrong anyway.\n *\n * One app by default, because an app is what usually broke: rolling the API\n * back over a site fix that shipped beside it undoes the fix too. `atomic`\n * rolls back every app that has a release to go back to, for apps that only\n * work together — an API and the site built against its newer contract.\n *\n * It restores images and nothing else. The environment an app runs with is\n * the stage's, resolved on every deploy, and migrations are forward-only: a\n * migration that the older code cannot run against is undone by a new\n * migration, never by a rollback.\n */\n\nimport { resolve } from 'node:path';\nimport { findWorkspaceRoot, loadWorkspaceConfig } from '../../config';\nimport {\n\ttype CredentialProvider,\n\tstoredCredentials,\n} from '../../deploy/credentials';\nimport { DeployJournal } from '../../deploy/journal';\nimport {\n\tassertStateOutlivesRun,\n\tcreateStateStore,\n} from '../../deploy/StateStore';\nimport {\n\tasDokployState,\n\tcreateEmptyState,\n\ttype ReleasedImage,\n\trecordRollback,\n} from '../../deploy/state';\nimport { GkmError } from '../../errors';\nimport { LocalSandbox } from '../../sandbox/local';\nimport { type Sandbox, withSandbox } from '../../sandbox/sandbox';\nimport { assertDeployedStage } from '../../workspace/stages';\nimport { dokployApi, restoreImage, verifySettings } from './engine';\n\nexport interface RollbackInput {\n\t/** The project: the directory holding `gkm.config.ts`, or one inside it. */\n\tcwd: string;\n\tstage: string;\n\t/** The app to roll back. */\n\tapp?: string;\n\t/** Every app with an earlier release, instead of one. */\n\tatomic?: boolean;\n\t/** Defaults to the environment, then the logins `gkm login` stored. */\n\tcredentials?: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Each progress line. Defaults to none. */\n\tlog?: (line: string) => void;\n\t/** Where the config is loaded. Defaults to a `LocalSandbox` on the project. */\n\tsandbox?: Sandbox;\n}\n\n/** One app rolled back. */\nexport interface RolledBack {\n\tapp: string;\n\tfrom: ReleasedImage;\n\tto: ReleasedImage;\n}\n\n/** Neither an app nor every app was asked for. */\nexport class RollbackNeedsApp extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The apps that have a release to go back to. */\n\t\treadonly apps: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Say what to roll back: --app <name> for one app (${apps.join(', ') || 'none has an earlier release'}), ` +\n\t\t\t\t`or --atomic for every app of \"${stage}\" together.`,\n\t\t);\n\t\tthis.name = 'RollbackNeedsApp';\n\t}\n}\n\n/** An app has no release before the one it runs. */\nexport class NothingToRollBack extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly app: string,\n\t) {\n\t\tsuper(\n\t\t\t`\"${app}\" has no earlier release on \"${stage}\" to roll back to: it has been released once, ` +\n\t\t\t\t'or every earlier release was itself rolled back. Deploy the version you want instead.',\n\t\t);\n\t\tthis.name = 'NothingToRollBack';\n\t}\n}\n\n/** The stage was never deployed through Dokploy from this state. */\nexport class StageNeverDeployed extends GkmError {\n\tconstructor(readonly stage: string) {\n\t\tsuper(\n\t\t\t`\"${stage}\" has no deploy state, so there is nothing to roll back. ` +\n\t\t\t\t'Check the stage name, and that `state` in gkm.config.ts points at the store the deploys write to.',\n\t\t);\n\t\tthis.name = 'StageNeverDeployed';\n\t}\n}\n\n/**\n * Roll a stage's app — or, `atomic`, all of them — back to its previous\n * release, holding the stage's lock as a deploy does.\n */\nexport async function rollbackStage(\n\tinput: RollbackInput,\n): Promise<RolledBack[]> {\n\tconst signal = input.signal ?? new AbortController().signal;\n\tconst log = input.log ?? (() => {});\n\tconst credentials = input.credentials ?? storedCredentials();\n\tconst sandbox =\n\t\tinput.sandbox ??\n\t\tnew LocalSandbox({ root: findWorkspaceRoot(resolve(input.cwd)) });\n\n\treturn withSandbox(sandbox, async () => {\n\t\tconst { workspace } = await loadWorkspaceConfig(resolve(input.cwd), {\n\t\t\tsandbox,\n\t\t});\n\t\tassertDeployedStage(workspace.stages, input.stage);\n\t\tassertStateOutlivesRun(workspace, input.stage, 'deploy:rollback');\n\n\t\tconst store = await createStateStore({\n\t\t\tconfig: 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\tif (!(await store.read(input.stage))) {\n\t\t\tthrow new StageNeverDeployed(input.stage);\n\t\t}\n\n\t\tconst lock = await store.lock(input.stage, { operation: 'rollback' });\n\t\ttry {\n\t\t\tconst journal = await DeployJournal.open(\n\t\t\t\tstore,\n\t\t\t\tinput.stage,\n\t\t\t\t() => createEmptyState(input.stage, '', ''),\n\t\t\t\tasDokployState,\n\t\t\t);\n\t\t\tconst { state } = journal;\n\t\t\tconst releases = state.releases ?? {};\n\t\t\tconst restorable = Object.keys(releases).filter(\n\t\t\t\t(app) => releases[app]!.previous,\n\t\t\t);\n\n\t\t\tlet apps: string[];\n\t\t\tif (input.atomic) {\n\t\t\t\tapps = restorable;\n\t\t\t\tif (apps.length === 0) {\n\t\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t\t}\n\t\t\t} else if (input.app) {\n\t\t\t\tif (!releases[input.app]?.previous) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, input.app);\n\t\t\t\t}\n\t\t\t\tapps = [input.app];\n\t\t\t} else {\n\t\t\t\tthrow new RollbackNeedsApp(input.stage, restorable);\n\t\t\t}\n\n\t\t\tconst { api } = await dokployApi(workspace, { credentials, signal });\n\t\t\tconst verify = verifySettings(workspace.deploy.dokploy?.verify);\n\t\t\tconst rolled: RolledBack[] = [];\n\n\t\t\tfor (const app of apps) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst { current, previous } = releases[app]!;\n\t\t\t\tconst applicationId = state.applications[app];\n\t\t\t\tif (!previous || !applicationId) {\n\t\t\t\t\tthrow new NothingToRollBack(input.stage, app);\n\t\t\t\t}\n\n\t\t\t\tlog(`⏪ ${app}: ${current.ref} → ${previous.ref}`);\n\t\t\t\tawait restoreImage(api, {\n\t\t\t\t\tapplicationId,\n\t\t\t\t\timage: previous,\n\t\t\t\t\tregistryId: state.registryId,\n\t\t\t\t\tverify,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\trecordRollback(state, app, previous);\n\t\t\t\tawait journal.save();\n\t\t\t\tlog(` ✓ ${app} is running ${previous.ref}`);\n\t\t\t\trolled.push({ app, from: current, to: previous });\n\t\t\t}\n\n\t\t\treturn rolled;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,mBAAb,cAAsCA,eAAAA,SAAS;CAEpC;CAEA;CAHV,YACC,OAEA,MACC;EACD,MACC,oDAAoD,KAAK,KAAK,IAAI,KAAK,8BAA8B,mCACnE,MAAM,YACzC;EAPS,KAAA,QAAA;EAEA,KAAA,OAAA;EAMT,KAAK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C;GACjD;GAEA,OAAO;EACR,UAAU;GACT,MAAM,KAAK,QAAQ;EACpB;CACD,CAAC;AACF"}
@@ -1,4 +1,4 @@
1
- import { Gt as GkmError, K as DeployRuntime, et as TargetOptionsIssue } from "./types-Dk--xVOT.cjs";
1
+ import { Gt as GkmError, K as DeployRuntime, et as TargetOptionsIssue } from "./types-D1C8pUyh.cjs";
2
2
  //#region src/target/builtins.d.ts
3
3
  /** A target name that is neither built in nor in `deploy.targets`. */
4
4
  declare class UnknownDeployTarget extends GkmError {
@@ -79,4 +79,4 @@ declare class TargetRuntimeUndeclared extends GkmError {
79
79
  }
80
80
  //#endregion
81
81
  export { TargetRuntimeMismatch as a, DeployTargetNotYetSupported as c, TargetPackageInvalid as i, UnknownDeployTarget as l, InvalidTargetOptions as n, ProviderRemoved as o, TargetEntryInvalid as r, TargetPackageNotFound as s, TargetRuntimeUndeclared as t };
82
- //# sourceMappingURL=runtime-CFvcLEJW.d.cts.map
82
+ //# sourceMappingURL=runtime-D-rOcRoq.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-CFvcLEJW.d.cts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
1
+ {"version":3,"file":"runtime-D-rOcRoq.d.cts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
@@ -1,4 +1,4 @@
1
- import { Gt as GkmError, K as DeployRuntime, et as TargetOptionsIssue } from "./types-DwQYpd_0.mjs";
1
+ import { Gt as GkmError, K as DeployRuntime, et as TargetOptionsIssue } from "./types-CvucX3yD.mjs";
2
2
  //#region src/target/builtins.d.ts
3
3
  /** A target name that is neither built in nor in `deploy.targets`. */
4
4
  declare class UnknownDeployTarget extends GkmError {
@@ -79,4 +79,4 @@ declare class TargetRuntimeUndeclared extends GkmError {
79
79
  }
80
80
  //#endregion
81
81
  export { TargetRuntimeMismatch as a, DeployTargetNotYetSupported as c, TargetPackageInvalid as i, UnknownDeployTarget as l, InvalidTargetOptions as n, ProviderRemoved as o, TargetEntryInvalid as r, TargetPackageNotFound as s, TargetRuntimeUndeclared as t };
82
- //# sourceMappingURL=runtime-dwsH6ddo.d.mts.map
82
+ //# sourceMappingURL=runtime-DG1mNh_5.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-dwsH6ddo.d.mts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
1
+ {"version":3,"file":"runtime-DG1mNh_5.d.mts","names":[],"sources":["../src/target/builtins.ts","../src/target/package.ts","../src/target/provider.ts","../src/target/resolve.ts","../src/target/runtime.ts"],"mappings":";;;cAgEa,4BAA4B;WAE9B;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;cAUE,oCAAoC;WAEtC;;WAEA;EAHV,YACU,gBAEA;;EAAA;;;;;cCrDE,8BAA8B;WAEhC;WACA;WACA;EAHV,YACU,gBACA,qBACA;;;;;cCZE,wBAAwB;WAE1B;;WAEA;EAHV,YACU,kBAEA;;EAAA;;;;;cCoCE,6BAA6B;WAE/B;WACA;EAFV,YACU,gBACA;;;cAUE,2BAA2B;WAClB;EAArB,YAAqB;;;cAST,8BAA8B;WAEhC;WACA;WACA,UAAU;WACV,QAAQ;EAJlB,YACU,gBACA,qBACA,UAAU,eACV,QAAQ;;;cAUN,6BAA6B;WAE/B;WACA,iBAAiB;EAF3B,YACU,gBACA,iBAAiB;;;;;cC1Ef,gCAAgC;WAElC;WACA;;WAEA;EAJV,YACU,gBACA,qBAEA;;EAAA"}
@@ -1,6 +1,6 @@
1
1
  const require_errors = require("./errors-DMC4Umsb.cjs");
2
2
  const require_workspace = require("./workspace-1szcahj9.cjs");
3
- const require_projectBucket = require("./projectBucket-CKr_zObJ.cjs");
3
+ const require_projectBucket = require("./projectBucket-CWpY3Vxv.cjs");
4
4
  const require_awsStore = require("./awsStore-u3ehhMoY.cjs");
5
5
  let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
6
6
  let _aws_sdk_client_sts = require("@aws-sdk/client-sts");
@@ -189,6 +189,31 @@ var S3SecretsStore = class {
189
189
  }
190
190
  }
191
191
  /**
192
+ * Every version of the stage's secrets: the bucket keeps each past
193
+ * document, and a secret left in an old version is not destroyed.
194
+ */
195
+ async delete(stage) {
196
+ const { s3, bucket } = await this.use(stage, false);
197
+ if (!bucket) return;
198
+ const Key = this.key(stage);
199
+ const listed = await this.call(stage, "write", () => s3.send(new _aws_sdk_client_s3.ListObjectVersionsCommand({
200
+ Bucket: bucket,
201
+ Prefix: Key
202
+ })));
203
+ const objects = [...listed.Versions ?? [], ...listed.DeleteMarkers ?? []].filter((o) => o.Key === Key).map((o) => ({
204
+ Key,
205
+ ...o.VersionId ? { VersionId: o.VersionId } : {}
206
+ }));
207
+ if (objects.length > 0) await this.call(stage, "write", () => s3.send(new _aws_sdk_client_s3.DeleteObjectsCommand({
208
+ Bucket: bucket,
209
+ Delete: {
210
+ Objects: objects,
211
+ Quiet: true
212
+ }
213
+ })));
214
+ this.etags.set(stage, null);
215
+ }
216
+ /**
192
217
  * The ETag the stage is now at. Some S3-compatible servers answer without
193
218
  * one: then nothing is remembered, and the next write asks for it first.
194
219
  */
@@ -212,4 +237,4 @@ var S3SecretsStore = class {
212
237
  //#endregion
213
238
  exports.S3SecretsStore = S3SecretsStore;
214
239
 
215
- //# sourceMappingURL=s3-CI2QYgXH.cjs.map
240
+ //# sourceMappingURL=s3-DIvAtJwk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-DIvAtJwk.cjs","names":["GkmError","projectBucketName","s3SecretsKey","awsClientConfig","S3Client","STSClient","withStageCredentials","callerAccountId","ensureProjectBucket","findProjectBucket","GetObjectCommand","PutObjectCommand","ListObjectVersionsCommand","DeleteObjectsCommand","HeadObjectCommand"],"sources":["../src/secrets/s3.ts"],"sourcesContent":["/**\n * A stage's secrets in S3: one object per stage,\n * `<prefix>/<project>/<stage>/secrets.json`, in the project bucket beside the\n * deploy state (`providers/projectBucket.ts`) — or in a bucket the config\n * names, which must exist.\n *\n * Encrypted at rest with SSE-S3, asked for on every write although the\n * project bucket defaults to it, so no KMS key is another place to keep. The\n * bucket's versioning keeps every past document. Unlike an SSM parameter\n * there is no size to outgrow.\n *\n * The project bucket is created by the first write, never by a read: a stage\n * whose bucket or object does not exist yet has no secrets. Every write is\n * conditional — `If-Match` on the ETag this store last read for the stage,\n * `If-None-Match: *` when it read none — so two `secrets:set` runs at once\n * cannot each overwrite the other's key: the second is refused with\n * {@link StageSecretsChanged}.\n */\n\nimport {\n\tDeleteObjectsCommand,\n\tGetObjectCommand,\n\tHeadObjectCommand,\n\tListObjectVersionsCommand,\n\tPutObjectCommand,\n\tS3Client,\n\ttype S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { STSClient } from '@aws-sdk/client-sts';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\nimport {\n\tcallerAccountId,\n\tensureProjectBucket,\n\tfindProjectBucket,\n\tprojectBucketName,\n} from '../providers/projectBucket.js';\nimport {\n\ttype AwsStoreOptions,\n\tawsClientConfig,\n\twithStageCredentials,\n} from './awsStore.js';\nimport { s3SecretsKey } from './providers.js';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface S3SecretsStoreOptions extends AwsStoreOptions {\n\t/** The deploy identity: the project bucket's name and its tag. */\n\tidentity: Pick<DeployIdentity, 'scope' | 'key'>;\n\t/** A bucket that exists; omitted, the project bucket. */\n\tbucket?: string;\n\t/** Key prefix inside the bucket, without a trailing slash. */\n\tprefix: string;\n\t/** For tests: credentials to use instead of the default chain. */\n\tcredentials?: S3ClientConfig['credentials'];\n}\n\n/**\n * Another run wrote the stage's secrets after this one read them. Nothing was\n * written: the change is to be made again, on top of theirs.\n */\nexport class StageSecretsChanged extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** `s3://<bucket>/<key>` */\n\t\treadonly location: string,\n\t) {\n\t\tsuper(\n\t\t\t`The secrets for stage \"${stage}\" at ${location} changed after this command read them — ` +\n\t\t\t\t'another secrets command or deploy wrote them first. Nothing was written; run the command ' +\n\t\t\t\t'again to make the change on top of theirs.',\n\t\t);\n\t\tthis.name = 'StageSecretsChanged';\n\t}\n}\n\ninterface S3Failure {\n\tname?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/** A conditional write that lost: the object is not what the write assumed. */\nfunction lostRace(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'PreconditionFailed' ||\n\t\tname === 'ConditionalRequestConflict' ||\n\t\t$metadata?.httpStatusCode === 412 ||\n\t\t$metadata?.httpStatusCode === 409\n\t);\n}\n\nfunction notFound(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'NoSuchKey' ||\n\t\tname === 'NotFound' ||\n\t\t$metadata?.httpStatusCode === 404\n\t);\n}\n\nexport class S3SecretsStore implements SecretsStore {\n\treadonly name = 's3';\n\n\tprivate clients?: { s3: S3Client; sts: STSClient };\n\t/** The bucket's name, once known. */\n\tprivate bucketName?: string;\n\t/** Whether the bucket is known to exist. */\n\tprivate exists = false;\n\t/** The ETag each stage was last read at — null: read, and not there. */\n\tprivate readonly etags = new Map<string, string | null>();\n\n\tconstructor(private readonly options: S3SecretsStoreOptions) {\n\t\tif (options.bucket) {\n\t\t\tthis.bucketName = options.bucket;\n\t\t\tthis.exists = true;\n\t\t}\n\t}\n\n\t/** The bucket's name; the project bucket's is known after the first call. */\n\tget bucket(): string {\n\t\treturn (\n\t\t\tthis.bucketName ??\n\t\t\tprojectBucketName(this.options.identity.scope, '<account id>')\n\t\t);\n\t}\n\n\t/** Where a stage's secrets are kept: `s3://<bucket>/<key>`. */\n\tlocation(stage: string): string {\n\t\treturn `s3://${this.bucket}/${this.key(stage)}`;\n\t}\n\n\tprivate key(stage: string): string {\n\t\treturn s3SecretsKey(this.options.prefix, this.options.project, stage);\n\t}\n\n\tprivate async client(): Promise<{ s3: S3Client; sts: STSClient }> {\n\t\tif (this.clients) return this.clients;\n\t\tconst base = await awsClientConfig(this.options);\n\t\tconst endpoint =\n\t\t\tbase.endpoint ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL_S3 ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL;\n\t\tconst credentials = this.options.credentials ?? base.credentials;\n\t\tthis.clients = {\n\t\t\ts3: new S3Client({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(endpoint ? { endpoint, forcePathStyle: true } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t\tsts: new STSClient({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(base.endpoint ? { endpoint: base.endpoint } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t};\n\t\treturn this.clients;\n\t}\n\n\t/** One AWS call, a missing or expired credential refused by name. */\n\tprivate call<T>(\n\t\tstage: string,\n\t\taccess: 'read' | 'write',\n\t\trun: () => Promise<T>,\n\t): Promise<T> {\n\t\treturn withStageCredentials(\n\t\t\t{ stage, store: this.name, profile: this.options.profile, access },\n\t\t\trun,\n\t\t);\n\t}\n\n\t/**\n\t * The bucket, or null for a project bucket that does not exist yet and is\n\t * not to be created (a read).\n\t */\n\tprivate async use(\n\t\tstage: string,\n\t\tcreate: boolean,\n\t): Promise<{ s3: S3Client; bucket: string | null }> {\n\t\tconst { s3, sts } = await this.client();\n\t\tif (this.exists) return { s3, bucket: this.bucketName! };\n\t\tconst access = create ? 'write' : 'read';\n\t\tthis.bucketName ??= projectBucketName(\n\t\t\tthis.options.identity.scope,\n\t\t\tawait this.call(stage, access, () => callerAccountId(sts)),\n\t\t);\n\t\tconst bucket = this.bucketName;\n\t\tif (create) {\n\t\t\tawait this.call(stage, access, () =>\n\t\t\t\tensureProjectBucket(s3, {\n\t\t\t\t\tbucket,\n\t\t\t\t\tregion: this.options.region,\n\t\t\t\t\tidentity: this.options.identity,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (\n\t\t\t(await this.call(stage, access, () => findProjectBucket(s3, bucket))) ===\n\t\t\t'none'\n\t\t) {\n\t\t\treturn { s3, bucket: null };\n\t\t}\n\t\tthis.exists = true;\n\t\treturn { s3, bucket };\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * read it with, or they have expired\n\t */\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) {\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tconst response = await this.call(stage, 'read', () =>\n\t\t\t\ts3.send(new GetObjectCommand({ Bucket: bucket, Key: this.key(stage) })),\n\t\t\t);\n\t\t\tconst body = await (\n\t\t\t\tresponse.Body as {\n\t\t\t\t\ttransformToString(encoding: string): Promise<string>;\n\t\t\t\t}\n\t\t\t).transformToString('utf-8');\n\t\t\tthis.remember(stage, response.ETag);\n\t\t\treturn JSON.parse(body) as StageSecrets;\n\t\t} catch (error) {\n\t\t\tif (!notFound(error)) throw error;\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Replace the stage's secrets — on the condition that they are still what\n\t * this store last read. A stage never read here is replaced as it is now.\n\t *\n\t * @throws {StageSecretsChanged} when another run wrote them in between\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * write it with, or they have expired\n\t */\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, true);\n\t\tconst Bucket = bucket!;\n\t\tconst Key = this.key(stage);\n\t\tconst expected = this.etags.has(stage)\n\t\t\t? (this.etags.get(stage) ?? null)\n\t\t\t: await this.currentEtag(s3, stage, Bucket, Key);\n\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew PutObjectCommand({\n\t\t\t\t\t\tBucket,\n\t\t\t\t\t\tKey,\n\t\t\t\t\t\tBody: JSON.stringify(secrets),\n\t\t\t\t\t\tContentType: 'application/json',\n\t\t\t\t\t\tServerSideEncryption: 'AES256',\n\t\t\t\t\t\t...(expected === null\n\t\t\t\t\t\t\t? { IfNoneMatch: '*' }\n\t\t\t\t\t\t\t: { IfMatch: expected }),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.remember(stage, ETag);\n\t\t} catch (error) {\n\t\t\tif (lostRace(error)) {\n\t\t\t\tthis.etags.delete(stage);\n\t\t\t\tthrow new StageSecretsChanged(stage, `s3://${Bucket}/${Key}`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Every version of the stage's secrets: the bucket keeps each past\n\t * document, and a secret left in an old version is not destroyed.\n\t */\n\tasync delete(stage: string): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) return;\n\t\tconst Key = this.key(stage);\n\t\tconst listed = await this.call(stage, 'write', () =>\n\t\t\ts3.send(new ListObjectVersionsCommand({ Bucket: bucket, Prefix: Key })),\n\t\t);\n\t\tconst objects = [\n\t\t\t...(listed.Versions ?? []),\n\t\t\t...(listed.DeleteMarkers ?? []),\n\t\t]\n\t\t\t.filter((o) => o.Key === Key)\n\t\t\t.map((o) => ({\n\t\t\t\tKey,\n\t\t\t\t...(o.VersionId ? { VersionId: o.VersionId } : {}),\n\t\t\t}));\n\t\tif (objects.length > 0) {\n\t\t\tawait this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew DeleteObjectsCommand({\n\t\t\t\t\t\tBucket: bucket,\n\t\t\t\t\t\tDelete: { Objects: objects, Quiet: true },\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tthis.etags.set(stage, null);\n\t}\n\n\t/**\n\t * The ETag the stage is now at. Some S3-compatible servers answer without\n\t * one: then nothing is remembered, and the next write asks for it first.\n\t */\n\tprivate remember(stage: string, etag: string | undefined): void {\n\t\tif (etag) this.etags.set(stage, etag);\n\t\telse this.etags.delete(stage);\n\t}\n\n\tprivate async currentEtag(\n\t\ts3: S3Client,\n\t\tstage: string,\n\t\tBucket: string,\n\t\tKey: string,\n\t): Promise<string | null> {\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(new HeadObjectCommand({ Bucket, Key })),\n\t\t\t);\n\t\t\treturn ETag ?? null;\n\t\t} catch (error) {\n\t\t\tif (notFound(error)) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,sBAAb,cAAyCA,eAAAA,SAAS;CAEvC;CAEA;CAHV,YACC,OAEA,UACC;EACD,MACC,0BAA0B,MAAM,OAAO,SAAS,4KAGjD;EARS,KAAA,QAAA;EAEA,KAAA,WAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAQA,SAAS,SAAS,OAAyB;CAC1C,MAAM,EAAE,MAAM,cAAc;CAC5B,OACC,SAAS,wBACT,SAAS,gCACT,WAAW,mBAAmB,OAC9B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M,EAAE,QAAQ,GAAG,CAAC,CAC5B,KAAK,OAAO;GACZ;GACA,GAAI,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,IAAI,CAAC;EACjD,EAAE;EACH,IAAI,QAAQ,SAAS,GACpB,MAAM,KAAK,KAAK,OAAO,eACtB,GAAG,KACF,IAAIC,mBAAAA,qBAAqB;GACxB,QAAQ;GACR,QAAQ;IAAE,SAAS;IAAS,OAAO;GAAK;EACzC,CAAC,CACF,CACD;EAED,KAAK,MAAM,IAAI,OAAO,IAAI;CAC3B;;;;;CAMA,SAAiB,OAAe,MAAgC;EAC/D,IAAI,MAAM,KAAK,MAAM,IAAI,OAAO,IAAI;OAC/B,KAAK,MAAM,OAAO,KAAK;CAC7B;CAEA,MAAc,YACb,IACA,OACA,QACA,KACyB;EACzB,IAAI;GACH,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,OAAO,eACvC,GAAG,KAAK,IAAIC,mBAAAA,kBAAkB;IAAE;IAAQ;GAAI,CAAC,CAAC,CAC/C;GACA,OAAO,QAAQ;EAChB,SAAS,OAAO;GACf,IAAI,SAAS,KAAK,GAAG,OAAO;GAC5B,MAAM;EACP;CACD;AACD"}
@@ -1,8 +1,8 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
2
  import { pt as s3SecretsKey } from "./workspace-DFGsrjGD.mjs";
3
- import { a as findProjectBucket, i as ensureProjectBucket, o as projectBucketName, r as callerAccountId } from "./projectBucket-CDJd3prK.mjs";
3
+ import { a as findProjectBucket, i as ensureProjectBucket, o as projectBucketName, r as callerAccountId } from "./projectBucket-B26ucBRI.mjs";
4
4
  import { r as withStageCredentials, t as awsClientConfig } from "./awsStore-Bx5nCFnS.mjs";
5
- import { GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
5
+ import { DeleteObjectsCommand, GetObjectCommand, HeadObjectCommand, ListObjectVersionsCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
6
6
  import { STSClient } from "@aws-sdk/client-sts";
7
7
  //#region src/secrets/s3.ts
8
8
  /**
@@ -189,6 +189,31 @@ var S3SecretsStore = class {
189
189
  }
190
190
  }
191
191
  /**
192
+ * Every version of the stage's secrets: the bucket keeps each past
193
+ * document, and a secret left in an old version is not destroyed.
194
+ */
195
+ async delete(stage) {
196
+ const { s3, bucket } = await this.use(stage, false);
197
+ if (!bucket) return;
198
+ const Key = this.key(stage);
199
+ const listed = await this.call(stage, "write", () => s3.send(new ListObjectVersionsCommand({
200
+ Bucket: bucket,
201
+ Prefix: Key
202
+ })));
203
+ const objects = [...listed.Versions ?? [], ...listed.DeleteMarkers ?? []].filter((o) => o.Key === Key).map((o) => ({
204
+ Key,
205
+ ...o.VersionId ? { VersionId: o.VersionId } : {}
206
+ }));
207
+ if (objects.length > 0) await this.call(stage, "write", () => s3.send(new DeleteObjectsCommand({
208
+ Bucket: bucket,
209
+ Delete: {
210
+ Objects: objects,
211
+ Quiet: true
212
+ }
213
+ })));
214
+ this.etags.set(stage, null);
215
+ }
216
+ /**
192
217
  * The ETag the stage is now at. Some S3-compatible servers answer without
193
218
  * one: then nothing is remembered, and the next write asks for it first.
194
219
  */
@@ -212,4 +237,4 @@ var S3SecretsStore = class {
212
237
  //#endregion
213
238
  export { S3SecretsStore };
214
239
 
215
- //# sourceMappingURL=s3-BBRkezf7.mjs.map
240
+ //# sourceMappingURL=s3-DmsM_V2R.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-DmsM_V2R.mjs","names":[],"sources":["../src/secrets/s3.ts"],"sourcesContent":["/**\n * A stage's secrets in S3: one object per stage,\n * `<prefix>/<project>/<stage>/secrets.json`, in the project bucket beside the\n * deploy state (`providers/projectBucket.ts`) — or in a bucket the config\n * names, which must exist.\n *\n * Encrypted at rest with SSE-S3, asked for on every write although the\n * project bucket defaults to it, so no KMS key is another place to keep. The\n * bucket's versioning keeps every past document. Unlike an SSM parameter\n * there is no size to outgrow.\n *\n * The project bucket is created by the first write, never by a read: a stage\n * whose bucket or object does not exist yet has no secrets. Every write is\n * conditional — `If-Match` on the ETag this store last read for the stage,\n * `If-None-Match: *` when it read none — so two `secrets:set` runs at once\n * cannot each overwrite the other's key: the second is refused with\n * {@link StageSecretsChanged}.\n */\n\nimport {\n\tDeleteObjectsCommand,\n\tGetObjectCommand,\n\tHeadObjectCommand,\n\tListObjectVersionsCommand,\n\tPutObjectCommand,\n\tS3Client,\n\ttype S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { STSClient } from '@aws-sdk/client-sts';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\nimport {\n\tcallerAccountId,\n\tensureProjectBucket,\n\tfindProjectBucket,\n\tprojectBucketName,\n} from '../providers/projectBucket.js';\nimport {\n\ttype AwsStoreOptions,\n\tawsClientConfig,\n\twithStageCredentials,\n} from './awsStore.js';\nimport { s3SecretsKey } from './providers.js';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface S3SecretsStoreOptions extends AwsStoreOptions {\n\t/** The deploy identity: the project bucket's name and its tag. */\n\tidentity: Pick<DeployIdentity, 'scope' | 'key'>;\n\t/** A bucket that exists; omitted, the project bucket. */\n\tbucket?: string;\n\t/** Key prefix inside the bucket, without a trailing slash. */\n\tprefix: string;\n\t/** For tests: credentials to use instead of the default chain. */\n\tcredentials?: S3ClientConfig['credentials'];\n}\n\n/**\n * Another run wrote the stage's secrets after this one read them. Nothing was\n * written: the change is to be made again, on top of theirs.\n */\nexport class StageSecretsChanged extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** `s3://<bucket>/<key>` */\n\t\treadonly location: string,\n\t) {\n\t\tsuper(\n\t\t\t`The secrets for stage \"${stage}\" at ${location} changed after this command read them — ` +\n\t\t\t\t'another secrets command or deploy wrote them first. Nothing was written; run the command ' +\n\t\t\t\t'again to make the change on top of theirs.',\n\t\t);\n\t\tthis.name = 'StageSecretsChanged';\n\t}\n}\n\ninterface S3Failure {\n\tname?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/** A conditional write that lost: the object is not what the write assumed. */\nfunction lostRace(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'PreconditionFailed' ||\n\t\tname === 'ConditionalRequestConflict' ||\n\t\t$metadata?.httpStatusCode === 412 ||\n\t\t$metadata?.httpStatusCode === 409\n\t);\n}\n\nfunction notFound(error: unknown): boolean {\n\tconst { name, $metadata } = error as S3Failure;\n\treturn (\n\t\tname === 'NoSuchKey' ||\n\t\tname === 'NotFound' ||\n\t\t$metadata?.httpStatusCode === 404\n\t);\n}\n\nexport class S3SecretsStore implements SecretsStore {\n\treadonly name = 's3';\n\n\tprivate clients?: { s3: S3Client; sts: STSClient };\n\t/** The bucket's name, once known. */\n\tprivate bucketName?: string;\n\t/** Whether the bucket is known to exist. */\n\tprivate exists = false;\n\t/** The ETag each stage was last read at — null: read, and not there. */\n\tprivate readonly etags = new Map<string, string | null>();\n\n\tconstructor(private readonly options: S3SecretsStoreOptions) {\n\t\tif (options.bucket) {\n\t\t\tthis.bucketName = options.bucket;\n\t\t\tthis.exists = true;\n\t\t}\n\t}\n\n\t/** The bucket's name; the project bucket's is known after the first call. */\n\tget bucket(): string {\n\t\treturn (\n\t\t\tthis.bucketName ??\n\t\t\tprojectBucketName(this.options.identity.scope, '<account id>')\n\t\t);\n\t}\n\n\t/** Where a stage's secrets are kept: `s3://<bucket>/<key>`. */\n\tlocation(stage: string): string {\n\t\treturn `s3://${this.bucket}/${this.key(stage)}`;\n\t}\n\n\tprivate key(stage: string): string {\n\t\treturn s3SecretsKey(this.options.prefix, this.options.project, stage);\n\t}\n\n\tprivate async client(): Promise<{ s3: S3Client; sts: STSClient }> {\n\t\tif (this.clients) return this.clients;\n\t\tconst base = await awsClientConfig(this.options);\n\t\tconst endpoint =\n\t\t\tbase.endpoint ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL_S3 ??\n\t\t\tprocess.env.AWS_ENDPOINT_URL;\n\t\tconst credentials = this.options.credentials ?? base.credentials;\n\t\tthis.clients = {\n\t\t\ts3: new S3Client({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(endpoint ? { endpoint, forcePathStyle: true } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t\tsts: new STSClient({\n\t\t\t\tregion: base.region,\n\t\t\t\t...(base.endpoint ? { endpoint: base.endpoint } : {}),\n\t\t\t\t...(credentials ? { credentials } : {}),\n\t\t\t}),\n\t\t};\n\t\treturn this.clients;\n\t}\n\n\t/** One AWS call, a missing or expired credential refused by name. */\n\tprivate call<T>(\n\t\tstage: string,\n\t\taccess: 'read' | 'write',\n\t\trun: () => Promise<T>,\n\t): Promise<T> {\n\t\treturn withStageCredentials(\n\t\t\t{ stage, store: this.name, profile: this.options.profile, access },\n\t\t\trun,\n\t\t);\n\t}\n\n\t/**\n\t * The bucket, or null for a project bucket that does not exist yet and is\n\t * not to be created (a read).\n\t */\n\tprivate async use(\n\t\tstage: string,\n\t\tcreate: boolean,\n\t): Promise<{ s3: S3Client; bucket: string | null }> {\n\t\tconst { s3, sts } = await this.client();\n\t\tif (this.exists) return { s3, bucket: this.bucketName! };\n\t\tconst access = create ? 'write' : 'read';\n\t\tthis.bucketName ??= projectBucketName(\n\t\t\tthis.options.identity.scope,\n\t\t\tawait this.call(stage, access, () => callerAccountId(sts)),\n\t\t);\n\t\tconst bucket = this.bucketName;\n\t\tif (create) {\n\t\t\tawait this.call(stage, access, () =>\n\t\t\t\tensureProjectBucket(s3, {\n\t\t\t\t\tbucket,\n\t\t\t\t\tregion: this.options.region,\n\t\t\t\t\tidentity: this.options.identity,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else if (\n\t\t\t(await this.call(stage, access, () => findProjectBucket(s3, bucket))) ===\n\t\t\t'none'\n\t\t) {\n\t\t\treturn { s3, bucket: null };\n\t\t}\n\t\tthis.exists = true;\n\t\treturn { s3, bucket };\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * read it with, or they have expired\n\t */\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) {\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tconst response = await this.call(stage, 'read', () =>\n\t\t\t\ts3.send(new GetObjectCommand({ Bucket: bucket, Key: this.key(stage) })),\n\t\t\t);\n\t\t\tconst body = await (\n\t\t\t\tresponse.Body as {\n\t\t\t\t\ttransformToString(encoding: string): Promise<string>;\n\t\t\t\t}\n\t\t\t).transformToString('utf-8');\n\t\t\tthis.remember(stage, response.ETag);\n\t\t\treturn JSON.parse(body) as StageSecrets;\n\t\t} catch (error) {\n\t\t\tif (!notFound(error)) throw error;\n\t\t\tthis.etags.set(stage, null);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Replace the stage's secrets — on the condition that they are still what\n\t * this store last read. A stage never read here is replaced as it is now.\n\t *\n\t * @throws {StageSecretsChanged} when another run wrote them in between\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * write it with, or they have expired\n\t */\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, true);\n\t\tconst Bucket = bucket!;\n\t\tconst Key = this.key(stage);\n\t\tconst expected = this.etags.has(stage)\n\t\t\t? (this.etags.get(stage) ?? null)\n\t\t\t: await this.currentEtag(s3, stage, Bucket, Key);\n\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew PutObjectCommand({\n\t\t\t\t\t\tBucket,\n\t\t\t\t\t\tKey,\n\t\t\t\t\t\tBody: JSON.stringify(secrets),\n\t\t\t\t\t\tContentType: 'application/json',\n\t\t\t\t\t\tServerSideEncryption: 'AES256',\n\t\t\t\t\t\t...(expected === null\n\t\t\t\t\t\t\t? { IfNoneMatch: '*' }\n\t\t\t\t\t\t\t: { IfMatch: expected }),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.remember(stage, ETag);\n\t\t} catch (error) {\n\t\t\tif (lostRace(error)) {\n\t\t\t\tthis.etags.delete(stage);\n\t\t\t\tthrow new StageSecretsChanged(stage, `s3://${Bucket}/${Key}`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Every version of the stage's secrets: the bucket keeps each past\n\t * document, and a secret left in an old version is not destroyed.\n\t */\n\tasync delete(stage: string): Promise<void> {\n\t\tconst { s3, bucket } = await this.use(stage, false);\n\t\tif (!bucket) return;\n\t\tconst Key = this.key(stage);\n\t\tconst listed = await this.call(stage, 'write', () =>\n\t\t\ts3.send(new ListObjectVersionsCommand({ Bucket: bucket, Prefix: Key })),\n\t\t);\n\t\tconst objects = [\n\t\t\t...(listed.Versions ?? []),\n\t\t\t...(listed.DeleteMarkers ?? []),\n\t\t]\n\t\t\t.filter((o) => o.Key === Key)\n\t\t\t.map((o) => ({\n\t\t\t\tKey,\n\t\t\t\t...(o.VersionId ? { VersionId: o.VersionId } : {}),\n\t\t\t}));\n\t\tif (objects.length > 0) {\n\t\t\tawait this.call(stage, 'write', () =>\n\t\t\t\ts3.send(\n\t\t\t\t\tnew DeleteObjectsCommand({\n\t\t\t\t\t\tBucket: bucket,\n\t\t\t\t\t\tDelete: { Objects: objects, Quiet: true },\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tthis.etags.set(stage, null);\n\t}\n\n\t/**\n\t * The ETag the stage is now at. Some S3-compatible servers answer without\n\t * one: then nothing is remembered, and the next write asks for it first.\n\t */\n\tprivate remember(stage: string, etag: string | undefined): void {\n\t\tif (etag) this.etags.set(stage, etag);\n\t\telse this.etags.delete(stage);\n\t}\n\n\tprivate async currentEtag(\n\t\ts3: S3Client,\n\t\tstage: string,\n\t\tBucket: string,\n\t\tKey: string,\n\t): Promise<string | null> {\n\t\ttry {\n\t\t\tconst { ETag } = await this.call(stage, 'write', () =>\n\t\t\t\ts3.send(new HeadObjectCommand({ Bucket, Key })),\n\t\t\t);\n\t\t\treturn ETag ?? null;\n\t\t} catch (error) {\n\t\t\tif (notFound(error)) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,sBAAb,cAAyC,SAAS;CAEvC;CAEA;CAHV,YACC,OAEA,UACC;EACD,MACC,0BAA0B,MAAM,OAAO,SAAS,4KAGjD;EARS,KAAA,QAAA;EAEA,KAAA,WAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAQA,SAAS,SAAS,OAAyB;CAC1C,MAAM,EAAE,MAAM,cAAc;CAC5B,OACC,SAAS,wBACT,SAAS,gCACT,WAAW,mBAAmB,OAC9B,WAAW,mBAAmB;AAEhC;AAEA,SAAS,SAAS,OAAyB;CAC1C,MAAM,EAAE,MAAM,cAAc;CAC5B,OACC,SAAS,eACT,SAAS,cACT,WAAW,mBAAmB;AAEhC;AAEA,IAAa,iBAAb,MAAoD;CAWtB;CAV7B,OAAgB;CAEhB;;CAEA;;CAEA,SAAiB;;CAEjB,wBAAyB,IAAI,IAA2B;CAExD,YAAY,SAAiD;EAAhC,KAAA,UAAA;EAC5B,IAAI,QAAQ,QAAQ;GACnB,KAAK,aAAa,QAAQ;GAC1B,KAAK,SAAS;EACf;CACD;;CAGA,IAAI,SAAiB;EACpB,OACC,KAAK,cACL,kBAAkB,KAAK,QAAQ,SAAS,OAAO,cAAc;CAE/D;;CAGA,SAAS,OAAuB;EAC/B,OAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,IAAI,KAAK;CAC7C;CAEA,IAAY,OAAuB;EAClC,OAAO,aAAa,KAAK,QAAQ,QAAQ,KAAK,QAAQ,SAAS,KAAK;CACrE;CAEA,MAAc,SAAoD;EACjE,IAAI,KAAK,SAAS,OAAO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eWithin, r as withStageCredentials, t as awsClientConfig } from "./awsStore-Bx5nCFnS.mjs";
3
- import { CreateSecretCommand, GetSecretValueCommand, PutSecretValueCommand, ResourceNotFoundException, SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
3
+ import { CreateSecretCommand, DeleteSecretCommand, GetSecretValueCommand, PutSecretValueCommand, ResourceNotFoundException, SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
4
4
  //#region src/secrets/secretsManager.ts
5
5
  /**
6
6
  * A stage's secrets in AWS Secrets Manager, in the stage's own AWS account.
@@ -73,6 +73,22 @@ var SecretsManagerSecretsStore = class {
73
73
  const name = this.secretName(stage);
74
74
  await withStageCredentials(this.context(stage, "write"), () => this.put(client, stage, name, value));
75
75
  }
76
+ /**
77
+ * At once, with no recovery window: a stage destroyed and deployed again
78
+ * creates its secret under the same name, which a secret waiting out its
79
+ * window would still hold.
80
+ */
81
+ async delete(stage) {
82
+ const client = await this.secretsManager();
83
+ try {
84
+ await withStageCredentials(this.context(stage, "write"), () => client.send(new DeleteSecretCommand({
85
+ SecretId: this.secretName(stage),
86
+ ForceDeleteWithoutRecovery: true
87
+ })));
88
+ } catch (error) {
89
+ if (!(error instanceof ResourceNotFoundException)) throw error;
90
+ }
91
+ }
76
92
  /** Put the secret, creating it on the stage's first write. */
77
93
  async put(client, stage, name, value) {
78
94
  try {
@@ -94,4 +110,4 @@ var SecretsManagerSecretsStore = class {
94
110
  //#endregion
95
111
  export { secretsManager_exports as n, secretsManagerSecretName as t };
96
112
 
97
- //# sourceMappingURL=secretsManager-CQORubp9.mjs.map
113
+ //# sourceMappingURL=secretsManager-CJyxFcBH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretsManager-CJyxFcBH.mjs","names":[],"sources":["../src/secrets/secretsManager.ts"],"sourcesContent":["/**\n * A stage's secrets in AWS Secrets Manager, in the stage's own AWS account.\n *\n * One secret per stage, `gkm/<project>/<stage>/secrets` — the SSM store's\n * parameter name without its leading `/` — holding the same JSON. It is\n * encrypted with the account's `aws/secretsmanager` key unless `kmsKeyId`\n * names another. Which account it is in is whichever credentials are active,\n * exactly as for the SSM store.\n *\n * Chosen over SSM for size (64 KB rather than 8 KB) and for Secrets Manager's\n * own versioning, at a monthly price per secret.\n */\n\nimport {\n\tCreateSecretCommand,\n\tDeleteSecretCommand,\n\tGetSecretValueCommand,\n\tPutSecretValueCommand,\n\tResourceNotFoundException,\n\tSecretsManagerClient,\n} from '@aws-sdk/client-secrets-manager';\nimport {\n\ttype AwsStoreOptions,\n\tawsClientConfig,\n\tserializeWithin,\n\twithStageCredentials,\n} from './awsStore.js';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface SecretsManagerStoreOptions extends AwsStoreOptions {\n\t/** The KMS key a new secret is encrypted with; `aws/secretsmanager` if unset. */\n\tkmsKeyId?: string;\n}\n\n/** The most a Secrets Manager secret holds: 64 KB. */\nexport const SECRETS_MANAGER_SECRET_LIMIT = 64 * 1024;\n\n/** The secret a stage's secrets are kept in. */\nexport function secretsManagerSecretName(\n\tproject: string,\n\tstage: string,\n): string {\n\treturn `gkm/${project}/${stage}/secrets`;\n}\n\nexport class SecretsManagerSecretsStore implements SecretsStore {\n\treadonly name = 'secrets-manager';\n\n\tprivate client?: SecretsManagerClient;\n\n\tconstructor(private readonly options: SecretsManagerStoreOptions) {}\n\n\tprivate async secretsManager(): Promise<SecretsManagerClient> {\n\t\tif (this.client) return this.client;\n\t\tthis.client = new SecretsManagerClient(await awsClientConfig(this.options));\n\t\treturn this.client;\n\t}\n\n\tprivate secretName(stage: string): string {\n\t\treturn secretsManagerSecretName(this.options.project, stage);\n\t}\n\n\t/** Where a call for `stage` is, for an error saying it has no credentials. */\n\tprivate context(stage: string, access: 'read' | 'write') {\n\t\treturn { stage, store: this.name, profile: this.options.profile, access };\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * read it with, or they have expired\n\t */\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst client = await this.secretsManager();\n\n\t\ttry {\n\t\t\tconst { SecretString } = await withStageCredentials(\n\t\t\t\tthis.context(stage, 'read'),\n\t\t\t\t() =>\n\t\t\t\t\tclient.send(\n\t\t\t\t\t\tnew GetSecretValueCommand({ SecretId: this.secretName(stage) }),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\treturn SecretString ? (JSON.parse(SecretString) as StageSecrets) : null;\n\t\t} catch (error) {\n\t\t\tif (error instanceof ResourceNotFoundException) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * write it with, or they have expired\n\t */\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tconst value = serializeWithin(\n\t\t\tstage,\n\t\t\tthis.name,\n\t\t\tsecrets,\n\t\t\tSECRETS_MANAGER_SECRET_LIMIT,\n\t\t);\n\t\tconst client = await this.secretsManager();\n\t\tconst name = this.secretName(stage);\n\n\t\tawait withStageCredentials(this.context(stage, 'write'), () =>\n\t\t\tthis.put(client, stage, name, value),\n\t\t);\n\t}\n\n\t/**\n\t * At once, with no recovery window: a stage destroyed and deployed again\n\t * creates its secret under the same name, which a secret waiting out its\n\t * window would still hold.\n\t */\n\tasync delete(stage: string): Promise<void> {\n\t\tconst client = await this.secretsManager();\n\t\ttry {\n\t\t\tawait withStageCredentials(this.context(stage, 'write'), () =>\n\t\t\t\tclient.send(\n\t\t\t\t\tnew DeleteSecretCommand({\n\t\t\t\t\t\tSecretId: this.secretName(stage),\n\t\t\t\t\t\tForceDeleteWithoutRecovery: true,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof ResourceNotFoundException)) throw error;\n\t\t}\n\t}\n\n\t/** Put the secret, creating it on the stage's first write. */\n\tprivate async put(\n\t\tclient: SecretsManagerClient,\n\t\tstage: string,\n\t\tname: string,\n\t\tvalue: string,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait client.send(\n\t\t\t\tnew PutSecretValueCommand({ SecretId: name, SecretString: value }),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof ResourceNotFoundException)) throw error;\n\t\t\t// The stage's first write: the secret does not exist yet.\n\t\t\tawait client.send(\n\t\t\t\tnew CreateSecretCommand({\n\t\t\t\t\tName: name,\n\t\t\t\t\tSecretString: value,\n\t\t\t\t\tDescription: `gkm secrets for ${this.options.project}/${stage}`,\n\t\t\t\t\t...(this.options.kmsKeyId ? { KmsKeyId: this.options.kmsKeyId } : {}),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,+BAA+B;;AAG5C,SAAgB,yBACf,SACA,OACS;CACT,OAAO,OAAO,QAAQ,GAAG,MAAM;AAChC;AAEA,IAAa,6BAAb,MAAgE;CAKlC;CAJ7B,OAAgB;CAEhB;CAEA,YAAY,SAAsD;EAArC,KAAA,UAAA;CAAsC;CAEnE,MAAc,iBAAgD;EAC7D,IAAI,KAAK,QAAQ,OAAO,KAAK;EAC7B,KAAK,SAAS,IAAI,qBAAqB,MAAM,gBAAgB,KAAK,OAAO,CAAC;EAC1E,OAAO,KAAK;CACb;CAEA,WAAmB,OAAuB;EACzC,OAAO,yBAAyB,KAAK,QAAQ,SAAS,KAAK;CAC5D;;CAGA,QAAgB,OAAe,QAA0B;EACxD,OAAO;GAAE;GAAO,OAAO,KAAK;GAAM,SAAS,KAAK,QAAQ;GAAS;EAAO;CACzE;;;;;CAMA,MAAM,KAAK,OAA6C;EACvD,MAAM,SAAS,MAAM,KAAK,eAAe;EAEzC,IAAI;GACH,MAAM,EAAE,iBAAiB,MAAM,qBAC9B,KAAK,QAAQ,OAAO,MAAM,SAEzB,OAAO,KACN,IAAI,sBAAsB,EAAE,UAAU,KAAK,WAAW,KAAK,EAAE,CAAC,CAC/D,CACF;GACA,OAAO,eAAgB,KAAK,MAAM,YAAY,IAAqB;EACpE,SAAS,OAAO;GACf,IAAI,iBAAiB,2BAA2B,OAAO;GACvD,MAAM;EACP;CACD;;;;;CAMA,MAAM,MAAM,OAAe,SAAsC;EAChE,MAAM,QAAQ,gBACb,OACA,KAAK,MACL,SACA,4BACD;EACA,MAAM,SAAS,MAAM,KAAK,eAAe;EACzC,MAAM,OAAO,KAAK,WAAW,KAAK;EAElC,MAAM,qBAAqB,KAAK,QAAQ,OAAO,OAAO,SACrD,KAAK,IAAI,QAAQ,OAAO,MAAM,KAAK,CACpC;CACD;;;;;;CAOA,MAAM,OAAO,OAA8B;EAC1C,MAAM,SAAS,MAAM,KAAK,eAAe;EACzC,IAAI;GACH,MAAM,qBAAqB,KAAK,QAAQ,OAAO,OAAO,SACrD,OAAO,KACN,IAAI,oBAAoB;IACvB,UAAU,KAAK,WAAW,KAAK;IAC/B,4BAA4B;GAC7B,CAAC,CACF,CACD;EACD,SAAS,OAAO;GACf,IAAI,EAAE,iBAAiB,4BAA4B,MAAM;EAC1D;CACD;;CAGA,MAAc,IACb,QACA,OACA,MACA,OACgB;EAChB,IAAI;GACH,MAAM,OAAO,KACZ,IAAI,sBAAsB;IAAE,UAAU;IAAM,cAAc;GAAM,CAAC,CAClE;EACD,SAAS,OAAO;GACf,IAAI,EAAE,iBAAiB,4BAA4B,MAAM;GAEzD,MAAM,OAAO,KACZ,IAAI,oBAAoB;IACvB,MAAM;IACN,cAAc;IACd,aAAa,mBAAmB,KAAK,QAAQ,QAAQ,GAAG;IACxD,GAAI,KAAK,QAAQ,WAAW,EAAE,UAAU,KAAK,QAAQ,SAAS,IAAI,CAAC;GACpE,CAAC,CACF;EACD;CACD;AACD"}
@@ -73,6 +73,22 @@ var SecretsManagerSecretsStore = class {
73
73
  const name = this.secretName(stage);
74
74
  await require_awsStore.withStageCredentials(this.context(stage, "write"), () => this.put(client, stage, name, value));
75
75
  }
76
+ /**
77
+ * At once, with no recovery window: a stage destroyed and deployed again
78
+ * creates its secret under the same name, which a secret waiting out its
79
+ * window would still hold.
80
+ */
81
+ async delete(stage) {
82
+ const client = await this.secretsManager();
83
+ try {
84
+ await require_awsStore.withStageCredentials(this.context(stage, "write"), () => client.send(new _aws_sdk_client_secrets_manager.DeleteSecretCommand({
85
+ SecretId: this.secretName(stage),
86
+ ForceDeleteWithoutRecovery: true
87
+ })));
88
+ } catch (error) {
89
+ if (!(error instanceof _aws_sdk_client_secrets_manager.ResourceNotFoundException)) throw error;
90
+ }
91
+ }
76
92
  /** Put the secret, creating it on the stage's first write. */
77
93
  async put(client, stage, name, value) {
78
94
  try {
@@ -105,4 +121,4 @@ Object.defineProperty(exports, "secretsManager_exports", {
105
121
  }
106
122
  });
107
123
 
108
- //# sourceMappingURL=secretsManager-RAGcEDX1.cjs.map
124
+ //# sourceMappingURL=secretsManager-D8on44WI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretsManager-D8on44WI.cjs","names":["SecretsManagerClient","awsClientConfig","withStageCredentials","GetSecretValueCommand","ResourceNotFoundException","serializeWithin","DeleteSecretCommand","PutSecretValueCommand","CreateSecretCommand"],"sources":["../src/secrets/secretsManager.ts"],"sourcesContent":["/**\n * A stage's secrets in AWS Secrets Manager, in the stage's own AWS account.\n *\n * One secret per stage, `gkm/<project>/<stage>/secrets` — the SSM store's\n * parameter name without its leading `/` — holding the same JSON. It is\n * encrypted with the account's `aws/secretsmanager` key unless `kmsKeyId`\n * names another. Which account it is in is whichever credentials are active,\n * exactly as for the SSM store.\n *\n * Chosen over SSM for size (64 KB rather than 8 KB) and for Secrets Manager's\n * own versioning, at a monthly price per secret.\n */\n\nimport {\n\tCreateSecretCommand,\n\tDeleteSecretCommand,\n\tGetSecretValueCommand,\n\tPutSecretValueCommand,\n\tResourceNotFoundException,\n\tSecretsManagerClient,\n} from '@aws-sdk/client-secrets-manager';\nimport {\n\ttype AwsStoreOptions,\n\tawsClientConfig,\n\tserializeWithin,\n\twithStageCredentials,\n} from './awsStore.js';\nimport type { SecretsStore } from './store.js';\nimport type { StageSecrets } from './types.js';\n\nexport interface SecretsManagerStoreOptions extends AwsStoreOptions {\n\t/** The KMS key a new secret is encrypted with; `aws/secretsmanager` if unset. */\n\tkmsKeyId?: string;\n}\n\n/** The most a Secrets Manager secret holds: 64 KB. */\nexport const SECRETS_MANAGER_SECRET_LIMIT = 64 * 1024;\n\n/** The secret a stage's secrets are kept in. */\nexport function secretsManagerSecretName(\n\tproject: string,\n\tstage: string,\n): string {\n\treturn `gkm/${project}/${stage}/secrets`;\n}\n\nexport class SecretsManagerSecretsStore implements SecretsStore {\n\treadonly name = 'secrets-manager';\n\n\tprivate client?: SecretsManagerClient;\n\n\tconstructor(private readonly options: SecretsManagerStoreOptions) {}\n\n\tprivate async secretsManager(): Promise<SecretsManagerClient> {\n\t\tif (this.client) return this.client;\n\t\tthis.client = new SecretsManagerClient(await awsClientConfig(this.options));\n\t\treturn this.client;\n\t}\n\n\tprivate secretName(stage: string): string {\n\t\treturn secretsManagerSecretName(this.options.project, stage);\n\t}\n\n\t/** Where a call for `stage` is, for an error saying it has no credentials. */\n\tprivate context(stage: string, access: 'read' | 'write') {\n\t\treturn { stage, store: this.name, profile: this.options.profile, access };\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * read it with, or they have expired\n\t */\n\tasync read(stage: string): Promise<StageSecrets | null> {\n\t\tconst client = await this.secretsManager();\n\n\t\ttry {\n\t\t\tconst { SecretString } = await withStageCredentials(\n\t\t\t\tthis.context(stage, 'read'),\n\t\t\t\t() =>\n\t\t\t\t\tclient.send(\n\t\t\t\t\t\tnew GetSecretValueCommand({ SecretId: this.secretName(stage) }),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\treturn SecretString ? (JSON.parse(SecretString) as StageSecrets) : null;\n\t\t} catch (error) {\n\t\t\tif (error instanceof ResourceNotFoundException) return null;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * @throws {StageSecretsUnreadable} when there are no AWS credentials to\n\t * write it with, or they have expired\n\t */\n\tasync write(stage: string, secrets: StageSecrets): Promise<void> {\n\t\tconst value = serializeWithin(\n\t\t\tstage,\n\t\t\tthis.name,\n\t\t\tsecrets,\n\t\t\tSECRETS_MANAGER_SECRET_LIMIT,\n\t\t);\n\t\tconst client = await this.secretsManager();\n\t\tconst name = this.secretName(stage);\n\n\t\tawait withStageCredentials(this.context(stage, 'write'), () =>\n\t\t\tthis.put(client, stage, name, value),\n\t\t);\n\t}\n\n\t/**\n\t * At once, with no recovery window: a stage destroyed and deployed again\n\t * creates its secret under the same name, which a secret waiting out its\n\t * window would still hold.\n\t */\n\tasync delete(stage: string): Promise<void> {\n\t\tconst client = await this.secretsManager();\n\t\ttry {\n\t\t\tawait withStageCredentials(this.context(stage, 'write'), () =>\n\t\t\t\tclient.send(\n\t\t\t\t\tnew DeleteSecretCommand({\n\t\t\t\t\t\tSecretId: this.secretName(stage),\n\t\t\t\t\t\tForceDeleteWithoutRecovery: true,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof ResourceNotFoundException)) throw error;\n\t\t}\n\t}\n\n\t/** Put the secret, creating it on the stage's first write. */\n\tprivate async put(\n\t\tclient: SecretsManagerClient,\n\t\tstage: string,\n\t\tname: string,\n\t\tvalue: string,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait client.send(\n\t\t\t\tnew PutSecretValueCommand({ SecretId: name, SecretString: value }),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof ResourceNotFoundException)) throw error;\n\t\t\t// The stage's first write: the secret does not exist yet.\n\t\t\tawait client.send(\n\t\t\t\tnew CreateSecretCommand({\n\t\t\t\t\tName: name,\n\t\t\t\t\tSecretString: value,\n\t\t\t\t\tDescription: `gkm secrets for ${this.options.project}/${stage}`,\n\t\t\t\t\t...(this.options.kmsKeyId ? { KmsKeyId: this.options.kmsKeyId } : {}),\n\t\t\t\t}),\n\t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OAAO,MAAM,KAAK,CACpC;CACD;;;;;;CAOA,MAAM,OAAO,OAA8B;EAC1C,MAAM,SAAS,MAAM,KAAK,eAAe;EACzC,IAAI;GACH,MAAMA,iBAAAA,qBAAqB,KAAK,QAAQ,OAAO,OAAO,SACrD,OAAO,KACN,IAAII,gCAAAA,oBAAoB;IACvB,UAAU,KAAK,WAAW,KAAK;IAC/B,4BAA4B;GAC7B,CAAC,CACF,CACD;EACD,SAAS,OAAO;GACf,IAAI,EAAE,iBAAiBF,gCAAAA,4BAA4B,MAAM;EAC1D;CACD;;CAGA,MAAc,IACb,QACA,OACA,MACA,OACgB;EAChB,IAAI;GACH,MAAM,OAAO,KACZ,IAAIG,gCAAAA,sBAAsB;IAAE,UAAU;IAAM,cAAc;GAAM,CAAC,CAClE;EACD,SAAS,OAAO;GACf,IAAI,EAAE,iBAAiBH,gCAAAA,4BAA4B,MAAM;GAEzD,MAAM,OAAO,KACZ,IAAII,gCAAAA,oBAAoB;IACvB,MAAM;IACN,cAAc;IACd,aAAa,mBAAmB,KAAK,QAAQ,QAAQ,GAAG;IACxD,GAAI,KAAK,QAAQ,WAAW,EAAE,UAAU,KAAK,QAAQ,SAAS,IAAI,CAAC;GACpE,CAAC,CACF;EACD;CACD;AACD"}
@@ -317,6 +317,12 @@ Object.defineProperty(exports, "describeActor", {
317
317
  return describeActor;
318
318
  }
319
319
  });
320
+ Object.defineProperty(exports, "dnsRecordFqdn", {
321
+ enumerable: true,
322
+ get: function() {
323
+ return dnsRecordFqdn;
324
+ }
325
+ });
320
326
  Object.defineProperty(exports, "dnsRecordResource", {
321
327
  enumerable: true,
322
328
  get: function() {
@@ -360,4 +366,4 @@ Object.defineProperty(exports, "reportPlannedSeeds", {
360
366
  }
361
367
  });
362
368
 
363
- //# sourceMappingURL=seeds-B3xvUAQf.cjs.map
369
+ //# sourceMappingURL=seeds-D7q1zKCJ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"seeds-B3xvUAQf.cjs","names":["userInfo","hostname"],"sources":["../src/deploy/journal.ts","../src/deploy/actor.ts","../src/deploy/dnsResources.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;AAsDA,IAAa,gBAAb,MAAa,cAAiD;CAE3C;CACR;CAEA;CACD;CACA;CAEC;CARV,YACC,OACA,OAEA,OACA,WACA,SAEA,SACC;EARgB,KAAA,QAAA;EACR,KAAA,QAAA;EAEA,KAAA,QAAA;EACD,KAAA,YAAA;EACA,KAAA,UAAA;EAEC,KAAA,UAAA;CACP;CAsBH,aAAa,KACZ,OACA,OACA,SACA,SAA6C,WAAW,QACnB;EACrC,MAAM,SAAS,MAAM,MAAM,KAAK,KAAK;EACrC,IAAI,QACH,OAAO,IAAI,cACV,OACA,OACA,MAAM,OAAO,KAAK,GAClB,OAAO,WACP,OAAO,SACP,IACD;EAGD,MAAM,QAAQ,QAAQ;EACtB,MAAM,UAAU,MAAM,MAAM,MAAM,OAAO,OAAO,EAAE,iBAAiB,KAAK,CAAC;EACzE,OAAO,IAAI,cAAc,OAAO,OAAO,OAAO,CAAC,GAAG,SAAS,KAAK;CACjE;CAEA,OAAO,KAAyC;EAC/C,OAAO,KAAK,UAAU;CACvB;;CAGA,aAAuB;EACtB,OAAO,OAAO,OAAO,KAAK,SAAS,CAAC,CAClC,QAAQ,WAAW,OAAO,WAAW,SAAS,CAAC,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,aAAa,OAAwB;CAC7C,MAAM,WAAW,UAChB,SAAS,OAAO,UAAU,YAAY,aAAa,QAChD,OAAO,MAAM,OAAO,IACpB,KAAA;CAKJ,QAHC,SAAS,OAAO,UAAU,YAAY,WAAW,QAC9C,QAAQ,MAAM,KAAK,IACnB,KAAA,MACY,QAAQ,KAAK,KAAK,OAAO,KAAK;AAC/C;;;;;;AAqBA,SAAgB,mBACf,YACA,OACA,KACA,MACO;CACP,KAAK,MAAM,EAAE,WAAW,QAAQ,aAAa,YAAY;EACxD,IAAI,QAAQ,WAAW,GAAG;EAC1B,IAAI,QAAQ,OAAO,YAAY,QAAQ,QAAQ;EAC/C,KAAK,MAAM,QAAQ,SAAS,IAAI,QAAQ,MAAM;EAC9C,KAAK;GACJ,MAAM;GACN;GACA;GACA,SAAS,CAAC,GAAG,OAAO;EACrB,CAAC;CACF;CACA,KAAK,MAAM,EAAE,WAAW,QAAQ,YAAY,OAAO;EAClD,IAAI,OAAO,WAAW,GAAG;EACzB,IAAI,MAAM,OAAO,QAAQ,OAAO,QAAQ;EACxC,KAAK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
1
+ {"version":3,"file":"seeds-D7q1zKCJ.cjs","names":["userInfo","hostname"],"sources":["../src/deploy/journal.ts","../src/deploy/actor.ts","../src/deploy/dnsResources.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;AAsDA,IAAa,gBAAb,MAAa,cAAiD;CAE3C;CACR;CAEA;CACD;CACA;CAEC;CARV,YACC,OACA,OAEA,OACA,WACA,SAEA,SACC;EARgB,KAAA,QAAA;EACR,KAAA,QAAA;EAEA,KAAA,QAAA;EACD,KAAA,YAAA;EACA,KAAA,UAAA;EAEC,KAAA,UAAA;CACP;CAsBH,aAAa,KACZ,OACA,OACA,SACA,SAA6C,WAAW,QACnB;EACrC,MAAM,SAAS,MAAM,MAAM,KAAK,KAAK;EACrC,IAAI,QACH,OAAO,IAAI,cACV,OACA,OACA,MAAM,OAAO,KAAK,GAClB,OAAO,WACP,OAAO,SACP,IACD;EAGD,MAAM,QAAQ,QAAQ;EACtB,MAAM,UAAU,MAAM,MAAM,MAAM,OAAO,OAAO,EAAE,iBAAiB,KAAK,CAAC;EACzE,OAAO,IAAI,cAAc,OAAO,OAAO,OAAO,CAAC,GAAG,SAAS,KAAK;CACjE;CAEA,OAAO,KAAyC;EAC/C,OAAO,KAAK,UAAU;CACvB;;CAGA,aAAuB;EACtB,OAAO,OAAO,OAAO,KAAK,SAAS,CAAC,CAClC,QAAQ,WAAW,OAAO,WAAW,SAAS,CAAC,CAC/C,KAAK,WAAW,OAAO,GAAG;CAC7B;;CAGA,MAAM,QAAQ,OAAoC;EACjD,MAAM,KAAK,IAAI;GAAE,GAAG;GAAO,QAAQ;EAAU,CAAC;CAC/C;;;;;CAMA,MAAM,MAAM,OAAqB,IAA2B;EAC3D,MAAM,UAAU,KAAK,UAAU,MAAM;EACrC,IACC,SAAS,WA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C;;;;;;AAqBA,SAAgB,mBACf,YACA,OACA,KACA,MACO;CACP,KAAK,MAAM,EAAE,WAAW,QAAQ,aAAa,YAAY;EACxD,IAAI,QAAQ,WAAW,GAAG;EAC1B,IAAI,QAAQ,OAAO,YAAY,QAAQ,QAAQ;EAC/C,KAAK,MAAM,QAAQ,SAAS,IAAI,QAAQ,MAAM;EAC9C,KAAK;GACJ,MAAM;GACN;GACA;GACA,SAAS,CAAC,GAAG,OAAO;EACrB,CAAC;CACF;CACA,KAAK,MAAM,EAAE,WAAW,QAAQ,YAAY,OAAO;EAClD,IAAI,OAAO,WAAW,GAAG;EACzB,IAAI,MAAM,OAAO,QAAQ,OAAO,QAAQ;EACxC,KAAK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
@@ -293,6 +293,6 @@ function reportPlannedSeeds(planned, log) {
293
293
  for (const { folder, seeds } of planned) log(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(", ")})`);
294
294
  }
295
295
  //#endregion
296
- export { dnsResources as a, currentActor as c, DeployJournal as d, dnsRecordResource as i, describeActor as l, reportDatabaseRuns as n, forgetDnsResource as o, reportPlannedSeeds as r, recordDnsChanges as s, DeploySeedsFailed as t, isCi as u };
296
+ export { dnsRecordResource as a, recordDnsChanges as c, isCi as d, DeployJournal as f, dnsRecordFqdn as i, currentActor as l, reportDatabaseRuns as n, dnsResources as o, reportPlannedSeeds as r, forgetDnsResource as s, DeploySeedsFailed as t, describeActor as u };
297
297
 
298
- //# sourceMappingURL=seeds-BCC8vAXR.mjs.map
298
+ //# sourceMappingURL=seeds-y1rzXlAc.mjs.map