@geekmidas/cli 10.0.0-alpha.157 → 10.0.0-alpha.159

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 (181) hide show
  1. package/dist/{EndpointGenerator-CusLH-9S.mjs → EndpointGenerator-B5BKAoLz.mjs} +4 -2
  2. package/dist/EndpointGenerator-B5BKAoLz.mjs.map +1 -0
  3. package/dist/{EndpointGenerator-DyLMYClE.cjs → EndpointGenerator-DxrRqfJ3.cjs} +4 -2
  4. package/dist/EndpointGenerator-DxrRqfJ3.cjs.map +1 -0
  5. package/dist/{GoDaddyProvider-CRDZ574t.cjs → GoDaddyProvider-CKDquvxI.cjs} +2 -2
  6. package/dist/{GoDaddyProvider-CRDZ574t.cjs.map → GoDaddyProvider-CKDquvxI.cjs.map} +1 -1
  7. package/dist/{GoDaddyProvider-DplVl6PV.mjs → GoDaddyProvider-DwyQXxO9.mjs} +2 -2
  8. package/dist/{GoDaddyProvider-DplVl6PV.mjs.map → GoDaddyProvider-DwyQXxO9.mjs.map} +1 -1
  9. package/dist/{HostingerProvider-B4pWxtNL.mjs → HostingerProvider-BZIKJDKU.mjs} +2 -2
  10. package/dist/{HostingerProvider-B4pWxtNL.mjs.map → HostingerProvider-BZIKJDKU.mjs.map} +1 -1
  11. package/dist/{HostingerProvider-Car70UOZ.cjs → HostingerProvider-CRDllmxA.cjs} +2 -2
  12. package/dist/{HostingerProvider-Car70UOZ.cjs.map → HostingerProvider-CRDllmxA.cjs.map} +1 -1
  13. package/dist/{LegacyStateStore-DLfjqri1.mjs → LegacyStateStore-BwnVnaHW.mjs} +2 -2
  14. package/dist/{LegacyStateStore-DLfjqri1.mjs.map → LegacyStateStore-BwnVnaHW.mjs.map} +1 -1
  15. package/dist/{LegacyStateStore--HvaCD_x.cjs → LegacyStateStore-CQ1J1rpx.cjs} +2 -2
  16. package/dist/{LegacyStateStore--HvaCD_x.cjs.map → LegacyStateStore-CQ1J1rpx.cjs.map} +1 -1
  17. package/dist/{LocalStateStore-Bck7bNAu.cjs → LocalStateStore-BvlLiIO_.cjs} +2 -2
  18. package/dist/{LocalStateStore-Bck7bNAu.cjs.map → LocalStateStore-BvlLiIO_.cjs.map} +1 -1
  19. package/dist/{LocalStateStore-BxvEMGIg.mjs → LocalStateStore-vA76-rrz.mjs} +2 -2
  20. package/dist/{LocalStateStore-BxvEMGIg.mjs.map → LocalStateStore-vA76-rrz.mjs.map} +1 -1
  21. package/dist/{OpenApiTsGenerator-CI-tceXV.cjs → OpenApiTsGenerator-DOTLKBFf.cjs} +2 -2
  22. package/dist/{OpenApiTsGenerator-CI-tceXV.cjs.map → OpenApiTsGenerator-DOTLKBFf.cjs.map} +1 -1
  23. package/dist/{OpenApiTsGenerator-BTMuu1WS.mjs → OpenApiTsGenerator-Vaf0pI8u.mjs} +2 -2
  24. package/dist/{OpenApiTsGenerator-BTMuu1WS.mjs.map → OpenApiTsGenerator-Vaf0pI8u.mjs.map} +1 -1
  25. package/dist/{S3StateStore-BFJ3KaNH.cjs → S3StateStore-BxeAk09j.cjs} +4 -4
  26. package/dist/{S3StateStore-BFJ3KaNH.cjs.map → S3StateStore-BxeAk09j.cjs.map} +1 -1
  27. package/dist/{S3StateStore-Ba9zrMWD.mjs → S3StateStore-DnJHHDPk.mjs} +4 -4
  28. package/dist/{S3StateStore-Ba9zrMWD.mjs.map → S3StateStore-DnJHHDPk.mjs.map} +1 -1
  29. package/dist/{SSMStateStore-C0xhLKD2.mjs → SSMStateStore-DXzyEcIH.mjs} +2 -2
  30. package/dist/{SSMStateStore-C0xhLKD2.mjs.map → SSMStateStore-DXzyEcIH.mjs.map} +1 -1
  31. package/dist/{SSMStateStore-a5oX3zgi.cjs → SSMStateStore-DzXyEoBx.cjs} +2 -2
  32. package/dist/{SSMStateStore-a5oX3zgi.cjs.map → SSMStateStore-DzXyEoBx.cjs.map} +1 -1
  33. package/dist/{SubscriberGenerator-CzPrixYu.mjs → SubscriberGenerator-BybB6uez.mjs} +2 -2
  34. package/dist/{SubscriberGenerator-CzPrixYu.mjs.map → SubscriberGenerator-BybB6uez.mjs.map} +1 -1
  35. package/dist/{SubscriberGenerator-BNJyPmXJ.cjs → SubscriberGenerator-mZpSuSU7.cjs} +2 -2
  36. package/dist/{SubscriberGenerator-BNJyPmXJ.cjs.map → SubscriberGenerator-mZpSuSU7.cjs.map} +1 -1
  37. package/dist/{add-5QcLsP3H.cjs → add-C_adddD3.cjs} +4 -4
  38. package/dist/{add-5QcLsP3H.cjs.map → add-C_adddD3.cjs.map} +1 -1
  39. package/dist/{add-CO16e9iI.mjs → add-WRwjtnks.mjs} +4 -4
  40. package/dist/{add-CO16e9iI.mjs.map → add-WRwjtnks.mjs.map} +1 -1
  41. package/dist/{apps-BVcA1Hy7.mjs → apps-BHiqiigd.mjs} +5 -5
  42. package/dist/{apps-BVcA1Hy7.mjs.map → apps-BHiqiigd.mjs.map} +1 -1
  43. package/dist/{apps-BRzZ5pIa.cjs → apps-Cri_aQvD.cjs} +5 -5
  44. package/dist/{apps-BRzZ5pIa.cjs.map → apps-Cri_aQvD.cjs.map} +1 -1
  45. package/dist/{bundler-CrNow5yF.mjs → bundler-Bh5MoDSl.mjs} +6 -6
  46. package/dist/{bundler-CrNow5yF.mjs.map → bundler-Bh5MoDSl.mjs.map} +1 -1
  47. package/dist/{bundler-Bo4JMtRH.cjs → bundler-CP0Nw6_V.cjs} +6 -6
  48. package/dist/{bundler-Bo4JMtRH.cjs.map → bundler-CP0Nw6_V.cjs.map} +1 -1
  49. package/dist/{cli-CEbLgLW5.cjs → cli-D8hr5lr4.cjs} +4 -4
  50. package/dist/{cli-CEbLgLW5.cjs.map → cli-D8hr5lr4.cjs.map} +1 -1
  51. package/dist/{cli-BsiiOIVE.mjs → cli-LI1NhjE5.mjs} +4 -4
  52. package/dist/{cli-BsiiOIVE.mjs.map → cli-LI1NhjE5.mjs.map} +1 -1
  53. package/dist/{compose-DZroNh2I.cjs → compose-CQPisITP.cjs} +4 -4
  54. package/dist/{compose-DZroNh2I.cjs.map → compose-CQPisITP.cjs.map} +1 -1
  55. package/dist/{compose-BSLOkoX8.mjs → compose-CS6WIN-0.mjs} +4 -4
  56. package/dist/{compose-BSLOkoX8.mjs.map → compose-CS6WIN-0.mjs.map} +1 -1
  57. package/dist/{compose-CtL6-1af.mjs → compose-D1rST6pU.mjs} +7 -7
  58. package/dist/{compose-CtL6-1af.mjs.map → compose-D1rST6pU.mjs.map} +1 -1
  59. package/dist/{compose-RtLoPN86.cjs → compose-DWgccYYU.cjs} +7 -7
  60. package/dist/{compose-RtLoPN86.cjs.map → compose-DWgccYYU.cjs.map} +1 -1
  61. package/dist/{credentials-C69J5G91.mjs → credentials-CKCKknMs.mjs} +5 -5
  62. package/dist/{credentials-C69J5G91.mjs.map → credentials-CKCKknMs.mjs.map} +1 -1
  63. package/dist/{credentials-D4XclzQZ.cjs → credentials-i6NycDXd.cjs} +5 -5
  64. package/dist/{credentials-D4XclzQZ.cjs.map → credentials-i6NycDXd.cjs.map} +1 -1
  65. package/dist/deploy/public.cjs +10 -10
  66. package/dist/deploy/public.mjs +10 -10
  67. package/dist/{deploy-uxEAC6Vv.cjs → deploy-DGjYbiqq.cjs} +12 -12
  68. package/dist/{deploy-uxEAC6Vv.cjs.map → deploy-DGjYbiqq.cjs.map} +1 -1
  69. package/dist/{deploy-RD6J-w2h.mjs → deploy-EopBQqnJ.mjs} +12 -12
  70. package/dist/{deploy-RD6J-w2h.mjs.map → deploy-EopBQqnJ.mjs.map} +1 -1
  71. package/dist/{docker-C2WagkrW.cjs → docker-2PN6JmUz.cjs} +6 -6
  72. package/dist/{docker-C2WagkrW.cjs.map → docker-2PN6JmUz.cjs.map} +1 -1
  73. package/dist/{docker-Db0TnF9j.mjs → docker-Br4lwU8K.mjs} +6 -6
  74. package/dist/{docker-Db0TnF9j.mjs.map → docker-Br4lwU8K.mjs.map} +1 -1
  75. package/dist/{dokploy-Ds1AvRQa.mjs → dokploy-Bq06k6hU.mjs} +2 -2
  76. package/dist/{dokploy-Ds1AvRQa.mjs.map → dokploy-Bq06k6hU.mjs.map} +1 -1
  77. package/dist/{dokploy-Ds-dwYjG.cjs → dokploy-DP07onK9.cjs} +2 -2
  78. package/dist/{dokploy-Ds-dwYjG.cjs.map → dokploy-DP07onK9.cjs.map} +1 -1
  79. package/dist/{eas-C_96kJG8.mjs → eas-e1TJSqsO.mjs} +2 -2
  80. package/dist/{eas-C_96kJG8.mjs.map → eas-e1TJSqsO.mjs.map} +1 -1
  81. package/dist/{eas-BgC-aXgY.cjs → eas-hSOnAjM1.cjs} +2 -2
  82. package/dist/{eas-BgC-aXgY.cjs.map → eas-hSOnAjM1.cjs.map} +1 -1
  83. package/dist/{encryption-KErhFgTQ.cjs → encryption-5g0QMUXJ.cjs} +2 -2
  84. package/dist/{encryption-KErhFgTQ.cjs.map → encryption-5g0QMUXJ.cjs.map} +1 -1
  85. package/dist/{encryption-DfoPAQ06.mjs → encryption-Bkiis13Q.mjs} +2 -2
  86. package/dist/{encryption-DfoPAQ06.mjs.map → encryption-Bkiis13Q.mjs.map} +1 -1
  87. package/dist/{engine-eaVZpdsY.mjs → engine-DB08e1EB.mjs} +8 -8
  88. package/dist/{engine-eaVZpdsY.mjs.map → engine-DB08e1EB.mjs.map} +1 -1
  89. package/dist/{engine-CgkVqYY-.cjs → engine-g86XmSu-.cjs} +8 -8
  90. package/dist/{engine-CgkVqYY-.cjs.map → engine-g86XmSu-.cjs.map} +1 -1
  91. package/dist/{github-DWgux2Mc.mjs → github-BuDZaqTQ.mjs} +6 -6
  92. package/dist/{github-DWgux2Mc.mjs.map → github-BuDZaqTQ.mjs.map} +1 -1
  93. package/dist/{github-hZ_qJn2O.cjs → github-Dx_XSH19.cjs} +6 -6
  94. package/dist/{github-hZ_qJn2O.cjs.map → github-Dx_XSH19.cjs.map} +1 -1
  95. package/dist/{googlePlay-BneaYZYU.cjs → googlePlay-BY9o6t23.cjs} +4 -4
  96. package/dist/{googlePlay-BneaYZYU.cjs.map → googlePlay-BY9o6t23.cjs.map} +1 -1
  97. package/dist/{googlePlay-CcDoKDlM.mjs → googlePlay-ewWbA1n2.mjs} +4 -4
  98. package/dist/{googlePlay-CcDoKDlM.mjs.map → googlePlay-ewWbA1n2.mjs.map} +1 -1
  99. package/dist/index.cjs +63 -63
  100. package/dist/index.cjs.map +1 -1
  101. package/dist/index.mjs +63 -63
  102. package/dist/index.mjs.map +1 -1
  103. package/dist/{local-DX5F9mI1.cjs → local-B_-OnfQ3.cjs} +2 -2
  104. package/dist/{local-DX5F9mI1.cjs.map → local-B_-OnfQ3.cjs.map} +1 -1
  105. package/dist/{local-CSkxxmZ5.mjs → local-DdqiukDq.mjs} +2 -2
  106. package/dist/{local-CSkxxmZ5.mjs.map → local-DdqiukDq.mjs.map} +1 -1
  107. package/dist/{migrate-T0b6IPf-.cjs → migrate-39p-DRKn.cjs} +4 -4
  108. package/dist/{migrate-T0b6IPf-.cjs.map → migrate-39p-DRKn.cjs.map} +1 -1
  109. package/dist/{migrate-Y_QjN95a.mjs → migrate-77UvdtrA.mjs} +4 -4
  110. package/dist/{migrate-Y_QjN95a.mjs.map → migrate-77UvdtrA.mjs.map} +1 -1
  111. package/dist/{migrate-Hi5BARdP.mjs → migrate-BhvmnG65.mjs} +2 -2
  112. package/dist/{migrate-Hi5BARdP.mjs.map → migrate-BhvmnG65.mjs.map} +1 -1
  113. package/dist/{migrate-BA2AgnvW.cjs → migrate-Dwdxal87.cjs} +2 -2
  114. package/dist/{migrate-BA2AgnvW.cjs.map → migrate-Dwdxal87.cjs.map} +1 -1
  115. package/dist/{notes-CjFVW8bn.cjs → notes-BI7Dnyrp.cjs} +2 -2
  116. package/dist/{notes-CjFVW8bn.cjs.map → notes-BI7Dnyrp.cjs.map} +1 -1
  117. package/dist/{notes-C5LmC9-z.mjs → notes-DdNcS5q5.mjs} +2 -2
  118. package/dist/{notes-C5LmC9-z.mjs.map → notes-DdNcS5q5.mjs.map} +1 -1
  119. package/dist/openapi.cjs +2 -2
  120. package/dist/openapi.mjs +2 -2
  121. package/dist/{projectBucket-BokyGleo.cjs → projectBucket-BxLoiySR.cjs} +2 -2
  122. package/dist/{projectBucket-BokyGleo.cjs.map → projectBucket-BxLoiySR.cjs.map} +1 -1
  123. package/dist/{projectBucket-CJC-C3cD.mjs → projectBucket-q4M_7rYh.mjs} +2 -2
  124. package/dist/{projectBucket-CJC-C3cD.mjs.map → projectBucket-q4M_7rYh.mjs.map} +1 -1
  125. package/dist/{publish-CxQyLRhO.mjs → publish-Bfr2okmd.mjs} +2 -2
  126. package/dist/{publish-CxQyLRhO.mjs.map → publish-Bfr2okmd.mjs.map} +1 -1
  127. package/dist/{publish-CKuhnFwH.cjs → publish-DqnMTMq0.cjs} +2 -2
  128. package/dist/{publish-CKuhnFwH.cjs.map → publish-DqnMTMq0.cjs.map} +1 -1
  129. package/dist/{ready-Dkw_Xt4P.mjs → ready-BjFMu_1J.mjs} +4 -4
  130. package/dist/{ready-Dkw_Xt4P.mjs.map → ready-BjFMu_1J.mjs.map} +1 -1
  131. package/dist/{ready-DV-_oK_O.cjs → ready-eVMJIcWn.cjs} +4 -4
  132. package/dist/{ready-DV-_oK_O.cjs.map → ready-eVMJIcWn.cjs.map} +1 -1
  133. package/dist/{resolve-CenYGcnj.mjs → resolve-DQ3QsMGK.mjs} +4 -4
  134. package/dist/{resolve-CenYGcnj.mjs.map → resolve-DQ3QsMGK.mjs.map} +1 -1
  135. package/dist/{resolve-mS7fO8YL.cjs → resolve-Ysdv1y9t.cjs} +4 -4
  136. package/dist/{resolve-mS7fO8YL.cjs.map → resolve-Ysdv1y9t.cjs.map} +1 -1
  137. package/dist/{rollback-DfJ0Rpkb.mjs → rollback-CbpKGQGn.mjs} +5 -5
  138. package/dist/{rollback-DfJ0Rpkb.mjs.map → rollback-CbpKGQGn.mjs.map} +1 -1
  139. package/dist/{rollback-D5rjIQwJ.cjs → rollback-D8-jEiQa.cjs} +5 -5
  140. package/dist/{rollback-D5rjIQwJ.cjs.map → rollback-D8-jEiQa.cjs.map} +1 -1
  141. package/dist/{s3-jtCO7o69.mjs → s3-Di_aCl0q.mjs} +2 -2
  142. package/dist/{s3-jtCO7o69.mjs.map → s3-Di_aCl0q.mjs.map} +1 -1
  143. package/dist/{s3-AIH2NmEI.cjs → s3-DtLAvo4D.cjs} +2 -2
  144. package/dist/{s3-AIH2NmEI.cjs.map → s3-DtLAvo4D.cjs.map} +1 -1
  145. package/dist/{serverSetup-6bczKo49.mjs → serverSetup-CrCEhS0g.mjs} +42 -9
  146. package/dist/serverSetup-CrCEhS0g.mjs.map +1 -0
  147. package/dist/{serverSetup-CVeRKNXR.cjs → serverSetup-WWrNW3Md.cjs} +42 -9
  148. package/dist/serverSetup-WWrNW3Md.cjs.map +1 -0
  149. package/dist/{sniffer-CzjFwmlR.mjs → sniffer-CEw1spoV.mjs} +6 -6
  150. package/dist/{sniffer-CzjFwmlR.mjs.map → sniffer-CEw1spoV.mjs.map} +1 -1
  151. package/dist/{sniffer-3Wix1Bez.cjs → sniffer-CvsdmfuV.cjs} +6 -6
  152. package/dist/{sniffer-3Wix1Bez.cjs.map → sniffer-CvsdmfuV.cjs.map} +1 -1
  153. package/dist/{snsSubscriptions-ByM_a0-4.mjs → snsSubscriptions-CB-WnmUi.mjs} +2 -2
  154. package/dist/{snsSubscriptions-ByM_a0-4.mjs.map → snsSubscriptions-CB-WnmUi.mjs.map} +1 -1
  155. package/dist/{snsSubscriptions-CDFlapU9.cjs → snsSubscriptions-G-FNGLvt.cjs} +2 -2
  156. package/dist/{snsSubscriptions-CDFlapU9.cjs.map → snsSubscriptions-G-FNGLvt.cjs.map} +1 -1
  157. package/dist/{sst-DykouxeI.cjs → sst-B3DBmq5F.cjs} +4 -4
  158. package/dist/{sst-DykouxeI.cjs.map → sst-B3DBmq5F.cjs.map} +1 -1
  159. package/dist/{sst-Bsf-6bw5.mjs → sst-CjiSTuNU.mjs} +4 -4
  160. package/dist/{sst-Bsf-6bw5.mjs.map → sst-CjiSTuNU.mjs.map} +1 -1
  161. package/dist/{stack-DbM4Z8XX.mjs → stack--9_32IOM.mjs} +7 -7
  162. package/dist/{stack-DbM4Z8XX.mjs.map → stack--9_32IOM.mjs.map} +1 -1
  163. package/dist/{stack-wBYoBpNL.cjs → stack-B4PwA10G.cjs} +7 -7
  164. package/dist/{stack-wBYoBpNL.cjs.map → stack-B4PwA10G.cjs.map} +1 -1
  165. package/dist/{stage-BAeoWlaT.cjs → stage-Dk52SAc3.cjs} +5 -5
  166. package/dist/{stage-BAeoWlaT.cjs.map → stage-Dk52SAc3.cjs.map} +1 -1
  167. package/dist/{stage-C9OePz1T.mjs → stage-sirtVzDQ.mjs} +5 -5
  168. package/dist/{stage-C9OePz1T.mjs.map → stage-sirtVzDQ.mjs.map} +1 -1
  169. package/dist/target/public.cjs +1 -1
  170. package/dist/target/public.mjs +1 -1
  171. package/dist/{terminal-vsCCECku.cjs → terminal-BBjilWid.cjs} +2 -2
  172. package/dist/{terminal-vsCCECku.cjs.map → terminal-BBjilWid.cjs.map} +1 -1
  173. package/dist/{terminal-cYD0PvkL.mjs → terminal-CEORTJyM.mjs} +2 -2
  174. package/dist/{terminal-cYD0PvkL.mjs.map → terminal-CEORTJyM.mjs.map} +1 -1
  175. package/dist/vitest.cjs +1 -1
  176. package/dist/vitest.mjs +1 -1
  177. package/package.json +15 -15
  178. package/dist/EndpointGenerator-CusLH-9S.mjs.map +0 -1
  179. package/dist/EndpointGenerator-DyLMYClE.cjs.map +0 -1
  180. package/dist/serverSetup-6bczKo49.mjs.map +0 -1
  181. package/dist/serverSetup-CVeRKNXR.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"notes-CjFVW8bn.cjs","names":["GkmError","provideKey","appKey","appEnvKeys","publicEnvFor","workerEnvKeys","SERVER_IPV4_KEY","SERVER_IPV6_KEY","GkmError","stageProvider","provisioningOf"],"sources":["../src/deploy/devServices.ts","../src/providers/types.ts","../src/providers/notes.ts"],"sourcesContent":["/**\n * Mail and object storage on a deployed stage: real ones, or — only when\n * someone asked — the dev services the local stage runs.\n *\n * Locally a declared `Email` is Mailpit and a declared bucket is MinIO, and\n * nobody has to configure either. Deployed, the same two containers would be\n * a stage that silently delivers no mail and keeps its files on one\n * container's disk. So a deployed stage on a server target takes both from\n * its secrets — the mail server's URL and sending address, and each bucket's\n * URL — and a stage missing any of them fails before anything is built,\n * provisioned or written, naming every key at once.\n *\n * A bucket's credentials are not checked: they are optional, and come from\n * either of two places. The bucket's URL may carry a key of its own\n * (`s3://KEY:SECRET@uploads`), which wins; otherwise the S3 client's default\n * chain applies — the stage's shared `AWS_ACCESS_KEY_ID`/\n * `AWS_SECRET_ACCESS_KEY` when it set them, or a role.\n *\n * `--allow-dev-services` is the way out for a stage that is not production —\n * a preview, a demo: every construct the stage does not account for gets the\n * dev service the local stage runs for it — a bucket MinIO, mail Mailpit —\n * and the target derives the keys from it. What the stage does account for\n * still wins: a key set in its secrets, or a provider (`deploy.objects`)\n * that backs the kind. Every run that uses one says so, loudly.\n *\n * Pure: what each target runs is decided here from declarations and the\n * stage's values, and the targets do the running.\n */\n\nimport {\n\ttype ConstructManifest,\n\tprovideKey,\n\tpublicEnvFor,\n} from '@geekmidas/manifest';\nimport { SERVER_IPV4_KEY, SERVER_IPV6_KEY } from '../compose/dnsConfig.js';\nimport { GkmError } from '../errors';\nimport { appEnvKeys, workerEnvKeys } from '../reconcile/apps.js';\nimport { appKey } from '../workspace/derive.js';\n\n/**\n * The dev services a deployed stage can run — one per kind that has one on\n * every server target: a bucket's MinIO and mail's Mailpit. A cache or a\n * database is not here because a server stage runs its own anyway.\n */\nexport const DEV_SERVICES = ['minio', 'mailpit'] as const;\n\nexport type DevService = (typeof DEV_SERVICES)[number];\n\n/**\n * The S3 client's shared key pair. Optional: a bucket whose URL carries its own\n * key (`s3://KEY:SECRET@bucket`) signs with that, and one without signs with\n * this pair when the stage set it, or with whatever else the SDK's default\n * chain finds — a role.\n */\nexport const STORAGE_KEY_PAIR = [\n\t'AWS_ACCESS_KEY_ID',\n\t'AWS_SECRET_ACCESS_KEY',\n] as const;\n\n/** Dev services asked of a target that runs no containers. */\nexport class DevServicesNeedServerTarget extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services applies to server targets only, and '${target}' ` +\n\t\t\t\t`deploys to AWS, where a bucket is S3 and mail is the stage's own. ` +\n\t\t\t\t'Drop --allow-dev-services.',\n\t\t);\n\t\tthis.name = 'DevServicesNeedServerTarget';\n\t}\n}\n\n/**\n * `--allow-dev-services` given a value — the list it used to take. It is a\n * switch now: every construct the stage does not account for gets its dev\n * service.\n */\nexport class AllowDevServicesTakesNoValue extends GkmError {\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services takes no value (it was given '${value}'). It runs ` +\n\t\t\t\t'the dev service for every bucket and mail the stage does not account ' +\n\t\t\t\t'for — no key in its secrets, no provider in deploy.<kind>.<stage> — so ' +\n\t\t\t\t'there is nothing to list. Pass --allow-dev-services on its own.',\n\t\t);\n\t\tthis.name = 'AllowDevServicesTakesNoValue';\n\t}\n}\n\n/**\n * Refuses `--allow-dev-services <value>` and `--allow-dev-services=<value>` on\n * a command line, with the reason, before the parser calls the value an\n * excess argument. `gkm deploy` and `gkm compose` take no positional\n * argument, so whatever follows the flag and is not a flag was meant for it.\n *\n * @throws {AllowDevServicesTakesNoValue}\n */\nexport function assertDevServicesFlag(argv: readonly string[]): void {\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i]!;\n\t\tif (arg.startsWith('--allow-dev-services=')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(arg.slice(arg.indexOf('=') + 1));\n\t\t}\n\t\tconst next = argv[i + 1];\n\t\tif (arg === '--allow-dev-services' && next && !next.startsWith('-')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(next);\n\t\t}\n\t}\n}\n\n/** One key a deployed stage needs and its secrets do not hold. */\nexport interface MissingServiceKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, unless the stage accounts for it. */\n\tservice?: DevService;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n}\n\n/**\n * A deployed stage with mail or object storage that its secrets do not\n * configure — every missing key, across every app, at once.\n */\nexport class ExternalServicesNotConfigured extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly missing: readonly MissingServiceKey[],\n\t) {\n\t\tconst standIns = missing.some((m) => m.service !== undefined);\n\t\tconst lines = missing.map((m) => {\n\t\t\tconst by = m.apps?.length ? `, read by ${m.apps.join(', ')}` : '';\n\t\t\treturn (\n\t\t\t\t` gkm secrets:set ${m.key} '${m.example}' --stage ${stage}\\n` +\n\t\t\t\t` ${m.what}${by}` +\n\t\t\t\t(m.note ? `\\n ${m.note}` : '') +\n\t\t\t\t(m.hint ? `\\n ${m.hint}` : '')\n\t\t\t);\n\t\t});\n\t\tsuper(\n\t\t\t`The stage '${stage}' is deployed, and a deployed stage's mail and ` +\n\t\t\t\t`object storage are real services: gkm runs no Mailpit or MinIO for ` +\n\t\t\t\t`it. Set ${missing.length === 1 ? 'this key' : `these ${missing.length} keys`} in the stage's secrets:\\n\\n` +\n\t\t\t\t`${lines.join('\\n')}\\n\\n` +\n\t\t\t\t(standIns\n\t\t\t\t\t? `For a stage that is not production — a preview, a demo — the ` +\n\t\t\t\t\t\t`dev services can run instead, with --allow-dev-services. ` +\n\t\t\t\t\t\t`Mailpit delivers no mail, and MinIO keeps every object on one ` +\n\t\t\t\t\t\t`container's disk.\\n\\n`\n\t\t\t\t\t: '') +\n\t\t\t\t`Or run: gkm secrets:add --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'ExternalServicesNotConfigured';\n\t}\n}\n\n/** A declaration that is mail or object storage. */\nexport interface ServiceDeclaration {\n\tid: string;\n\tkind: 'email' | 'objects' | 'file-server';\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** The kinds a deployed stage takes from its secrets, or a dev service. */\nconst SERVICE_KINDS: Readonly<Record<string, ServiceDeclaration['kind']>> = {\n\temail: 'email',\n\tobjects: 'objects',\n\t'file-server': 'file-server',\n};\n\nexport interface StageServiceDeclarationsInput {\n\tmanifest: ConstructManifest;\n}\n\n/**\n * Every mail and storage construct a manifest declares, each with the apps\n * and workers that read it — a process's environment, a site's build args. A\n * file server's reader reads its bucket too.\n *\n * The one list a deploy's readiness check refuses a stage by, every server\n * target decides its dev services from, and `gkm secrets:add` offers — so\n * none of them can disagree.\n */\nexport function stageServiceDeclarations(\n\tinput: StageServiceDeclarationsInput,\n): ServiceDeclaration[] {\n\tconst { manifest } = input;\n\n\t// The construct each key belongs to.\n\tconst owners = new Map<string, string>();\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tif (!SERVICE_KINDS[declaration.kind]) continue;\n\t\towners.set(provideKey(id, 'url'), id);\n\t\tif (declaration.kind === 'email') owners.set(provideKey(id, 'from'), id);\n\t}\n\n\t// Who reads which construct.\n\tconst readers = new Map<string, Set<string>>();\n\tconst read = (process: string, keys: Iterable<string>) => {\n\t\tfor (const key of keys) {\n\t\t\tconst id = owners.get(key);\n\t\t\tif (!id) continue;\n\t\t\tconst declaration = manifest[id];\n\t\t\tconst of =\n\t\t\t\tdeclaration?.kind === 'file-server' ? declaration.of : undefined;\n\t\t\tfor (const owner of of ? [id, of] : [id]) {\n\t\t\t\tconst set = readers.get(owner) ?? new Set<string>();\n\t\t\t\tset.add(process);\n\t\t\t\treaders.set(owner, set);\n\t\t\t}\n\t\t}\n\t};\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tconst name = appKey(id);\n\t\tif (\n\t\t\tdeclaration.kind === 'rest-api' ||\n\t\t\tdeclaration.kind === 'websocket-api' ||\n\t\t\tdeclaration.kind === 'site' ||\n\t\t\tdeclaration.kind === 'mobile-app'\n\t\t) {\n\t\t\tread(name, appEnvKeys(manifest, name) ?? []);\n\t\t}\n\t\t// A site's build args, by the keys they rename.\n\t\tif (declaration.kind === 'site') {\n\t\t\tread(name, Object.values(publicEnvFor(declaration, manifest)));\n\t\t}\n\t\tif (declaration.kind === 'worker') {\n\t\t\tread(name, workerEnvKeys(manifest, id) ?? []);\n\t\t}\n\t}\n\n\treturn Object.entries(manifest).flatMap(\n\t\t([id, declaration]): ServiceDeclaration[] => {\n\t\t\tconst kind = SERVICE_KINDS[declaration.kind];\n\t\t\tif (!kind) return [];\n\t\t\tconst apps = [...(readers.get(id) ?? [])].sort();\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid,\n\t\t\t\t\tkind,\n\t\t\t\t\t...(declaration.kind === 'file-server' && declaration.of\n\t\t\t\t\t\t? { of: declaration.of }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(apps.length ? { apps } : {}),\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t);\n}\n\nexport interface ExternalServicesInput {\n\tstage: string;\n\t/** Every mail and storage construct something on the stage reads. */\n\tdeclarations: readonly ServiceDeclaration[];\n\t/** The stage's values by key — what `gkm secrets:set` stored. */\n\tsupplied: Readonly<Record<string, string>>;\n\t/**\n\t * `--allow-dev-services`: every construct the stage does not account for\n\t * gets its dev service.\n\t */\n\tallow: boolean;\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/**\n\t * What the stage's providers say, by kind: a kind one backs is accounted\n\t * for, so no dev service stands in for it, and a missing key of it names\n\t * what creates it.\n\t */\n\tproviders?: StageProviderNotes;\n}\n\n/** The stage's providers, as a deploy's checks read them. */\nexport interface StageProviderNotes {\n\tobjects?: {\n\t\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\t\taccounted: boolean;\n\t\t/** What creates a missing key of it. */\n\t\thint?: string;\n\t};\n}\n\n/** Where a deployed stage's mail and storage come from. */\nexport interface ExternalServices {\n\t/** Keys the stage needs and has not set. Empty when it can deploy. */\n\tmissing: MissingServiceKey[];\n\t/** The buckets the target runs MinIO for. */\n\tminio: string[];\n\t/** The mail constructs the target runs Mailpit for. */\n\tmailpit: string[];\n}\n\n/** One dev service a run uses, and for which constructs. */\nexport interface DevServiceUse {\n\tservice: DevService;\n\tids: string[];\n}\n\n/** A third party's credentials a construct reads: an external API's, or a `Credential`. */\nexport interface CredentialDeclaration {\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** What a stage-supplied key belongs to. */\nexport type StageKeyKind =\n\t| 'bucket'\n\t| 'email'\n\t| 'file-server'\n\t| 'external-api'\n\t| 'credential'\n\t/** The server a compose stage's stack runs on: `GKM_SERVER_IPV4`. */\n\t| 'server';\n\n/**\n * One key only the stage's secrets can hold — nothing derives it — whether\n * or not it is set.\n */\nexport interface StageKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\tkind: StageKeyKind;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, where one can. */\n\tservice?: DevService;\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\nexport interface StageKeysInput {\n\t/** Whether the stage is the local one, which derives its mail and storage. */\n\tlocal: boolean;\n\t/** Every mail and storage construct something on the stage reads. */\n\tservices?: readonly ServiceDeclaration[];\n\t/** Every third party's credentials something on the stage reads. */\n\tcredentials?: readonly CredentialDeclaration[];\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/** What the stage's providers say — see {@link StageProviderNotes}. */\n\tproviders?: StageProviderNotes;\n\t/**\n\t * The stage serves a domain from a server of its own — a compose stage —\n\t * so its secrets hold the server's address, `GKM_SERVER_IPV4`.\n\t */\n\tserver?: boolean;\n}\n\n/**\n * Every key a stage must be given rather than derive — the one list both a\n * deploy's checks and `gkm secrets:add` read, so what a deploy refuses and\n * what the builder offers cannot drift.\n *\n * - Deployed, mail is its URL and its sending address, a bucket its URL, and\n * a file server its public URL. Locally all of it is Mailpit and MinIO.\n * - On every stage, a third party's credentials: nobody but the third party\n * can issue them.\n *\n * Never a derived value: a database URL, a generated secret, the seed.\n */\nexport function requiredStageKeys(input: StageKeysInput): StageKey[] {\n\tconst domain = input.domain ?? 'example.com';\n\tconst keys: StageKey[] = [];\n\tconst add = (entry: StageKey) => {\n\t\tif (!keys.some((k) => k.key === entry.key)) keys.push(entry);\n\t};\n\tconst byId = <T extends { id: string }>(list: readonly T[] | undefined) =>\n\t\t[...(list ?? [])].sort((a, b) => a.id.localeCompare(b.id));\n\tconst apps = (d: { apps?: readonly string[] }) =>\n\t\td.apps?.length ? { apps: [...d.apps].sort() } : {};\n\n\tif (!input.local) {\n\t\tconst services = byId(input.services);\n\t\t// A kind a provider backs on the stage has no dev service, and a key of\n\t\t// it names what creates it.\n\t\tconst objects = input.providers?.objects;\n\t\tconst storage = objects?.accounted\n\t\t\t? objects.hint\n\t\t\t\t? { hint: objects.hint }\n\t\t\t\t: {}\n\t\t\t: { service: 'minio' as const };\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `where '${d.id}' sends mail — any SMTP server`,\n\t\t\t\texample: `smtp://user:password@smtp.${domain}:587`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'from'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `the address '${d.id}' sends from, on a domain the mail server has verified`,\n\t\t\t\texample: `noreply@${domain}`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'objects')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'bucket',\n\t\t\t\twhat: `the bucket '${d.id}' — S3, R2, or any S3-compatible store (add &endpoint=… for one that is not S3)`,\n\t\t\t\tnote: `credentials are optional: a key for this bucket alone in the URL (s3://KEY:SECRET@${appKey(d.id)}?…) wins; without one, the shared AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or a role signs`,\n\t\t\t\texample: `s3://${appKey(d.id)}?region=eu-west-1`,\n\t\t\t\t...storage,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'file-server')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'file-server',\n\t\t\t\twhat: `the public address '${d.id}' serves its bucket on — a CDN or the bucket's own domain`,\n\t\t\t\texample: `https://${appKey(d.id)}.${domain}`,\n\t\t\t\t...storage,\n\t\t\t\t...(d.of ? { of: d.of } : {}),\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t}\n\n\tif (!input.local && input.server) {\n\t\tadd({\n\t\t\tkey: SERVER_IPV4_KEY,\n\t\t\tid: 'server',\n\t\t\tkind: 'server',\n\t\t\twhat: \"the public IPv4 address of the server the stage's stack runs on — its hosts' DNS records point at it, and every deploy checks they do\",\n\t\t\tnote: `${SERVER_IPV6_KEY} adds its IPv6 address (AAAA records); neither is ever handed to an app`,\n\t\t\texample: '203.0.113.10',\n\t\t});\n\t}\n\n\tfor (const d of byId(input.credentials)) {\n\t\tadd({\n\t\t\tkey: provideKey(d.id, 'credentials'),\n\t\t\tid: d.id,\n\t\t\tkind: d.kind,\n\t\t\twhat:\n\t\t\t\td.kind === 'external-api'\n\t\t\t\t\t? `the credentials '${d.id}' was issued for this stage, as its schema describes them`\n\t\t\t\t\t: `the credential '${d.id}', as its schema describes it`,\n\t\t\texample: '{\"apiKey\":\"…\"}',\n\t\t\t...apps(d),\n\t\t});\n\t}\n\n\treturn keys;\n}\n\n/**\n * Whether only the stage's secrets can supply `key` to a construct of `kind`\n * — what nothing on the stage derives.\n *\n * A third party's credentials, always. Deployed, also each generated secret\n * and keyring: the stage generated each one once, and every run reads the\n * same value back.\n */\nexport function suppliedOnly(\n\tkind: string,\n\tid: string,\n\tkey: string,\n\tlocal: boolean,\n): boolean {\n\tif (kind === 'credential') return true;\n\tif (kind === 'external-api') return key === provideKey(id, 'credentials');\n\tif (local) return false;\n\treturn kind === 'secret' || kind === 'encryption';\n}\n\n/**\n * Where a deployed stage's mail and storage come from, and what it lacks.\n *\n * - Mail is external once its URL is set, and then needs its sending\n * address too. Unset, it is Mailpit where allowed — the address derived\n * unless set — and missing otherwise.\n * - A bucket is external once its URL is set; its credentials, in the URL or\n * the shared pair, are optional. Unset, it is MinIO where allowed, and\n * missing otherwise.\n * - A file server's URL is derived where its bucket is MinIO, unless set;\n * over an external bucket the stage must set it.\n *\n * The keys themselves are {@link requiredStageKeys}'s.\n */\nexport function externalServices(\n\tinput: ExternalServicesInput,\n): ExternalServices {\n\tconst { supplied, allow } = input;\n\tconst has = (key: string) => supplied[key] !== undefined;\n\n\tconst required = requiredStageKeys({\n\t\tlocal: false,\n\t\tservices: input.declarations,\n\t\t...(input.domain ? { domain: input.domain } : {}),\n\t\t...(input.providers ? { providers: input.providers } : {}),\n\t});\n\n\t// A dev service stands in for each construct the stage does not account\n\t// for: no key in its secrets, and no provider backing its kind.\n\tconst standIn = (k: StageKey) =>\n\t\tallow && k.service !== undefined && !has(k.key);\n\tconst mailpit = required\n\t\t.filter((k) => k.kind === 'email' && k.key === provideKey(k.id, 'url'))\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\tconst minio = required\n\t\t.filter((k) => k.kind === 'bucket')\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\n\tconst covered = (k: StageKey) =>\n\t\t(k.kind === 'email' && mailpit.includes(k.id)) ||\n\t\t(k.kind === 'bucket' && minio.includes(k.id)) ||\n\t\t(k.kind === 'file-server' && k.of !== undefined && minio.includes(k.of));\n\n\tconst missing = required\n\t\t.filter((k) => !has(k.key) && !covered(k))\n\t\t.map(\n\t\t\t({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\tnote,\n\t\t\t\texample,\n\t\t\t\tservice,\n\t\t\t\tapps,\n\t\t\t\thint,\n\t\t\t}): MissingServiceKey => ({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\t...(note ? { note } : {}),\n\t\t\t\texample,\n\t\t\t\t...(service ? { service } : {}),\n\t\t\t\t...(apps ? { apps } : {}),\n\t\t\t\t...(hint ? { hint } : {}),\n\t\t\t}),\n\t\t);\n\n\treturn { missing, minio, mailpit };\n}\n\n/** The dev services a run uses, one entry per service it runs. */\nexport function devServicesUsed(services: ExternalServices): DevServiceUse[] {\n\tconst used: DevServiceUse[] = [];\n\tif (services.mailpit.length > 0) {\n\t\tused.push({ service: 'mailpit', ids: services.mailpit });\n\t}\n\tif (services.minio.length > 0) {\n\t\tused.push({ service: 'minio', ids: services.minio });\n\t}\n\treturn used;\n}\n\n/** The line a run prints for each dev service a deployed stage uses. */\nexport function devServiceWarning(stage: string, use: DevServiceUse): string {\n\tconst what =\n\t\tuse.service === 'mailpit'\n\t\t\t? `Mailpit is catching mail for ${use.ids.join(', ')}. It delivers NO mail: nobody receives a sign-in link, a receipt or a reset`\n\t\t\t: `MinIO is storing ${use.ids.join(', ')}. Every object is on one container's disk, with no replication and no backup`;\n\treturn (\n\t\t`⚠️ DEV SERVICE ON A DEPLOYED STAGE (${stage}): ${what}. It is not ` +\n\t\t`production-grade — set the stage's own keys in its secrets for that.`\n\t);\n}\n\n/**\n * Report each dev service a run uses: a loud line, and a `dev-service.used`\n * event a host can act on.\n */\nexport function reportDevServices(\n\tctx: {\n\t\tstage: string;\n\t\tlogger: { warn(message: string): void };\n\t\temit(event: {\n\t\t\ttype: 'dev-service.used';\n\t\t\tservice: DevService;\n\t\t\tstage: string;\n\t\t\tconstructs: string[];\n\t\t}): void;\n\t},\n\tuses: readonly DevServiceUse[],\n): void {\n\tfor (const use of uses) {\n\t\tctx.logger.warn(`\\n${devServiceWarning(ctx.stage, use)}`);\n\t\tctx.emit({\n\t\t\ttype: 'dev-service.used',\n\t\t\tservice: use.service,\n\t\t\tstage: ctx.stage,\n\t\t\tconstructs: use.ids,\n\t\t});\n\t}\n}\n","/**\n * Providers: what creates the thing a construct is backed by, on a stage.\n *\n * The manifest says a bucket exists (`ObjectStorage`); `deploy.<kind>.<stage>`\n * says what backs it there. A stage that names a provider has gkm *create*\n * the backing resource — when it holds the account's provisioning\n * credentials — and write the connection value into the stage's secrets,\n * where every deploy reads it as if it had been set by hand. A stage that\n * names none is `external`: the value is yours to set, as it always was.\n *\n * | Part | What it is |\n * | ------------------------ | ------------------------------------------------------- |\n * | provisioning credentials | What creates the resource. Never given to an app. |\n * | `ensure()` | Idempotent find-or-create. Records in state. Never deletes. |\n * | runtime credentials | The keys it writes into the stage's secrets. |\n * | `verify()` | The cheap check every deploy runs. |\n *\n * The key under `deploy` is the manifest kind — `objects`, which\n * `ObjectStorage` and `FileServer` produce — so `deploy.cache` and\n * `deploy.email` slot in beside it with providers of their own.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport type { ResourceRecord } from '../deploy/StateStore.js';\nimport type { BoundSubscriber } from '../reconcile/discover.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\n/** The manifest kinds a stage can name a provider for. */\nexport const PROVIDER_KINDS = ['objects', 'inbox'] as const;\n\nexport type ProviderKind = (typeof PROVIDER_KINDS)[number];\n\n/** A provider's own entry: `{ provider: 's3', … }`. */\nexport interface ProviderConfig {\n\tprovider: string;\n}\n\n/**\n * One stage's entry under `deploy.<kind>`:\n *\n * - `'external'` — the default: the stage's secrets hold the key, set by you.\n * - `{ provider, … }` — that provider creates the resource and writes the key.\n * - `false` — the stage has none of this kind; a construct of it is refused.\n */\nexport type StageProviderEntry<C extends ProviderConfig = ProviderConfig> =\n\t| 'external'\n\t| C\n\t| false;\n\n/** One change `ensure()` makes, or — in a dry run — would make. */\nexport interface ProvisionAction {\n\t/** The construct it is for. */\n\tconstruct: string;\n\t/** What it acts on: `bucket acme-shop-prod-uploads`. */\n\tresource: string;\n\t/** What it does: `create`, `set CORS (2 origins)`. */\n\tchange: string;\n}\n\n/** The stage's provisioning record, as `ensure()` reads and writes it. */\nexport interface ProvisionState {\n\t/** A resource recorded by an earlier run. */\n\trecord(key: string): ResourceRecord | undefined;\n\t/** About to be created — written before the call that creates it. */\n\tpending(entry: StateEntry): Promise<void>;\n\t/** Exists, as `id`. */\n\tready(entry: StateEntry, id: string): Promise<void>;\n\t/** When the stage was last deployed, for a rotation to know it was. */\n\treadonly lastDeployedAt?: string;\n}\n\nexport interface StateEntry {\n\t/** `<type>:<name>`, unique within the stage. */\n\tkey: string;\n\ttype: string;\n\tdata?: Record<string, unknown>;\n}\n\n/** What `ensure()` is handed. */\nexport interface EnsureContext<C extends ProviderConfig, K> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Each Worker's subscribers, from discovery — by export and the key its\n\t * deliveries come from. What a provider subscribes on a worker's behalf.\n\t */\n\tsubscribers?: Readonly<Record<string, readonly BoundSubscriber[]>>;\n\tstage: string;\n\tidentity: DeployIdentity;\n\tconfig: C;\n\t/** The provisioning credentials {@link ResourceProvider.credentials} found. */\n\tcredential: K;\n\t/** The stage's secrets as they are now, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\tstate: ProvisionState;\n\tdryRun: boolean;\n\t/** `--rotate-keys`: issue each runtime key a successor. */\n\trotateKeys: boolean;\n\t/** `--retire-old-keys`: delete a rotated-out key without waiting for a deploy. */\n\tretireOldKeys: boolean;\n\t/**\n\t * Runs `apply` and records `action` — or, in a dry run, only records it.\n\t * Every write to the provider's account goes through here.\n\t */\n\tchange(action: ProvisionAction, apply: () => Promise<void>): Promise<void>;\n\t/**\n\t * Writes keys into the stage's secrets now — not at the end of the run, so\n\t * a secret the account shows only once is kept the moment it exists. A dry\n\t * run writes nothing.\n\t */\n\twriteSecrets(values: Record<string, string>): Promise<void>;\n\t/**\n\t * Writes DNS records through the stage's DNS providers (`dns`), as the\n\t * deploy's own DNS step does — what a certificate's validation record and\n\t * a CDN's name, a domain's inbound mail (MX) need. A dry run prints them\n\t * and writes nothing.\n\t */\n\twriteDns(records: readonly ProviderDnsRecord[]): Promise<ProviderDnsResult>;\n\tlog(line: string): void;\n}\n\n/** One record a provider asks the stage's DNS for. */\nexport type ProviderDnsRecord =\n\t| {\n\t\t\t/** The full name: `_abc.files.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'CNAME';\n\t\t\tvalue: string;\n\t }\n\t| {\n\t\t\t/** The full name: `example.com`, `*.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'MX';\n\t\t\t/** The mail server: `inbound-smtp.eu-west-1.amazonaws.com`. */\n\t\t\tvalue: string;\n\t\t\t/** Lower is preferred: `10`. */\n\t\t\tpriority: number;\n\t };\n\n/** What writing a provider's records came to. */\nexport interface ProviderDnsResult {\n\t/**\n\t * Hosts no DNS provider wrote — under no domain in `dns`, or a `manual`\n\t * one — printed for the person to create.\n\t */\n\tmanual: string[];\n}\n\n/** What `verify()` is handed. */\nexport interface VerifyContext<C extends ProviderConfig> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\tstage: string;\n\tconfig: C;\n\t/** The stage's secrets, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\t/**\n\t * What the stage's state records, by key — how a provider knows a key it\n\t * checks was issued moments ago. Absent when nothing was read.\n\t */\n\tresources?: Readonly<Record<string, ResourceRecord>>;\n\t/** Progress worth printing: waiting on something. */\n\tlog?: (line: string) => void;\n}\n\n/** Where a provider's provisioning credentials are looked for. */\nexport interface CredentialLookup {\n\tstage: string;\n\t/** `--profile`, when given. */\n\tprofile?: string;\n\tenv: NodeJS.ProcessEnv;\n\t/** The CLI's home, for stored logins. */\n\thome?: string;\n}\n\n/**\n * A provider. `C` is its config entry, `K` its provisioning credential.\n *\n * Built-ins are registered in `providers/registry.ts`, the way a deploy\n * target's built-ins are.\n */\nexport interface ResourceProvider<\n\tC extends ProviderConfig = ProviderConfig,\n\tK = unknown,\n> {\n\treadonly kind: ProviderKind;\n\t/** What `provider:` names it. */\n\treadonly name: string;\n\t/**\n\t * Its config entry checked: returns it, or throws a named error saying\n\t * what is wrong — what the workspace schema runs.\n\t */\n\tcheck(stage: string, config: ProviderConfig): C;\n\t/** How its provisioning credentials are supplied, for messages. */\n\treadonly provisioning: {\n\t\t/** The environment variables it reads. */\n\t\tenv: readonly string[];\n\t\t/** A `gkm login --provider` name, where it has one. */\n\t\tlogin?: string;\n\t\t/** One line saying how to supply them. */\n\t\tdescribe: string;\n\t};\n\t/** Its provisioning credentials, or `undefined` when there are none. */\n\tcredentials(lookup: CredentialLookup): Promise<K | undefined>;\n\t/** The keys it writes into the stage's secrets for these constructs. */\n\truntimeKeys(manifest: ConstructManifest): string[];\n\tensure(ctx: EnsureContext<C, K>): Promise<void>;\n\tverify(ctx: VerifyContext<C>): Promise<void>;\n}\n","/**\n * What a deploy's checks read off `deploy.<kind>.<stage>`, without loading a\n * provider: which kinds the stage accounts for, what creates a missing key,\n * and a kind the stage has none of.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { StageProviderNotes } from '../deploy/devServices.js';\nimport { GkmError } from '../errors';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { provisioningOf, stageProvider } from './config.js';\nimport { PROVIDER_KINDS, type ProviderKind } from './types.js';\n\n/** The constructs of a kind: `objects` is every bucket. */\nexport function constructsOf(manifest: ConstructManifest, kind: ProviderKind) {\n\treturn Object.entries(manifest)\n\t\t.filter(([, d]) => d.kind === kind)\n\t\t.map(([id]) => id)\n\t\t.sort();\n}\n\n/** A stage that names `false` for a kind, and declares constructs of it. */\nexport class StageProviderDisabled extends GkmError {\n\tconstructor(\n\t\treadonly kind: ProviderKind,\n\t\treadonly stage: string,\n\t\treadonly ids: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`deploy.${kind}.${stage} is false — the stage has no ${kind} — and ` +\n\t\t\t\t`${ids.join(', ')} ${ids.length === 1 ? 'is' : 'are'} declared. ` +\n\t\t\t\t`Name what backs ${ids.length === 1 ? 'it' : 'them'} on '${stage}' ` +\n\t\t\t\t`(deploy.${kind}.${stage}: 'external', or a provider), or remove ` +\n\t\t\t\t`the ${ids.length === 1 ? 'construct' : 'constructs'}.`,\n\t\t);\n\t\tthis.name = 'StageProviderDisabled';\n\t}\n}\n\n/** The command a stage's providers are run with: every deploy runs them. */\nexport function provisionCommand(stage: string): string {\n\treturn `gkm deploy --stage ${stage}`;\n}\n\n/**\n * The line a stage missing a key a provider would write is given: what\n * creates it, and with which credentials. Undefined when no provider backs\n * the kind on the stage.\n */\nexport function provisionHint(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tkind: ProviderKind,\n\tstage: string,\n): string | undefined {\n\tconst choice = stageProvider(workspace as never, kind, stage);\n\tif (choice.mode !== 'provider') return undefined;\n\tconst provisioning = provisioningOf(kind, choice.name);\n\tif (!provisioning) return undefined;\n\treturn (\n\t\t`deploy.${kind}.${stage} is ${choice.name}: the deploy ` +\n\t\t`(${provisionCommand(stage)}) creates it and writes this key, with ` +\n\t\t`${provisioning.describe}` +\n\t\t(provisioning.login\n\t\t\t? `, or gkm login --provider ${provisioning.login}`\n\t\t\t: '')\n\t);\n}\n\n/**\n * What a deploy's checks read off the stage's providers: whether each kind is\n * accounted for — a provider, or `false` — so no dev service stands in for\n * it, and what creates a missing key of it.\n */\nexport function stageProviderNotes(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tstage: string,\n): StageProviderNotes {\n\tconst choice = stageProvider(workspace as never, 'objects', stage);\n\tif (choice.mode === 'external') return {};\n\tconst hint = provisionHint(workspace, 'objects', stage);\n\treturn { objects: { accounted: true, ...(hint ? { hint } : {}) } };\n}\n\n/**\n * A kind the stage set to `false`, declared anyway — refused before anything\n * else is checked. Pure: what a stack is composed from.\n *\n * @throws {StageProviderDisabled}\n */\nexport function assertStageProvidersEnabled(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tmanifest: ConstructManifest,\n\tstage: string,\n): void {\n\tfor (const kind of PROVIDER_KINDS) {\n\t\tconst ids = constructsOf(manifest, kind);\n\t\tif (ids.length === 0) continue;\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'none') {\n\t\t\tthrow new StageProviderDisabled(kind, stage, ids);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,eAAe,CAAC,SAAS,SAAS;;;;;;;AAU/C,MAAa,mBAAmB,CAC/B,qBACA,uBACD;;AAGA,IAAa,8BAAb,cAAiDA,eAAAA,SAAS;CACpC;CAArB,YAAY,QAAyB;EACpC,MACC,6DAA6D,OAAO,+FAGrE;EALoB,KAAA,SAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;;AAOA,IAAa,+BAAb,cAAkDA,eAAAA,SAAS;CACrC;CAArB,YAAY,OAAwB;EACnC,MACC,sDAAsD,MAAM,wNAI7D;EANoB,KAAA,QAAA;EAOpB,KAAK,OAAO;CACb;AACD;;;;;;;;;AAUA,SAAgB,sBAAsB,MAA+B;CACpE,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,MAAM,KAA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p.cjs","names":["GkmError","provideKey","appKey","appEnvKeys","publicEnvFor","workerEnvKeys","SERVER_IPV4_KEY","SERVER_IPV6_KEY","GkmError","stageProvider","provisioningOf"],"sources":["../src/deploy/devServices.ts","../src/providers/types.ts","../src/providers/notes.ts"],"sourcesContent":["/**\n * Mail and object storage on a deployed stage: real ones, or — only when\n * someone asked — the dev services the local stage runs.\n *\n * Locally a declared `Email` is Mailpit and a declared bucket is MinIO, and\n * nobody has to configure either. Deployed, the same two containers would be\n * a stage that silently delivers no mail and keeps its files on one\n * container's disk. So a deployed stage on a server target takes both from\n * its secrets — the mail server's URL and sending address, and each bucket's\n * URL — and a stage missing any of them fails before anything is built,\n * provisioned or written, naming every key at once.\n *\n * A bucket's credentials are not checked: they are optional, and come from\n * either of two places. The bucket's URL may carry a key of its own\n * (`s3://KEY:SECRET@uploads`), which wins; otherwise the S3 client's default\n * chain applies — the stage's shared `AWS_ACCESS_KEY_ID`/\n * `AWS_SECRET_ACCESS_KEY` when it set them, or a role.\n *\n * `--allow-dev-services` is the way out for a stage that is not production —\n * a preview, a demo: every construct the stage does not account for gets the\n * dev service the local stage runs for it — a bucket MinIO, mail Mailpit —\n * and the target derives the keys from it. What the stage does account for\n * still wins: a key set in its secrets, or a provider (`deploy.objects`)\n * that backs the kind. Every run that uses one says so, loudly.\n *\n * Pure: what each target runs is decided here from declarations and the\n * stage's values, and the targets do the running.\n */\n\nimport {\n\ttype ConstructManifest,\n\tprovideKey,\n\tpublicEnvFor,\n} from '@geekmidas/manifest';\nimport { SERVER_IPV4_KEY, SERVER_IPV6_KEY } from '../compose/dnsConfig.js';\nimport { GkmError } from '../errors';\nimport { appEnvKeys, workerEnvKeys } from '../reconcile/apps.js';\nimport { appKey } from '../workspace/derive.js';\n\n/**\n * The dev services a deployed stage can run — one per kind that has one on\n * every server target: a bucket's MinIO and mail's Mailpit. A cache or a\n * database is not here because a server stage runs its own anyway.\n */\nexport const DEV_SERVICES = ['minio', 'mailpit'] as const;\n\nexport type DevService = (typeof DEV_SERVICES)[number];\n\n/**\n * The S3 client's shared key pair. Optional: a bucket whose URL carries its own\n * key (`s3://KEY:SECRET@bucket`) signs with that, and one without signs with\n * this pair when the stage set it, or with whatever else the SDK's default\n * chain finds — a role.\n */\nexport const STORAGE_KEY_PAIR = [\n\t'AWS_ACCESS_KEY_ID',\n\t'AWS_SECRET_ACCESS_KEY',\n] as const;\n\n/** Dev services asked of a target that runs no containers. */\nexport class DevServicesNeedServerTarget extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services applies to server targets only, and '${target}' ` +\n\t\t\t\t`deploys to AWS, where a bucket is S3 and mail is the stage's own. ` +\n\t\t\t\t'Drop --allow-dev-services.',\n\t\t);\n\t\tthis.name = 'DevServicesNeedServerTarget';\n\t}\n}\n\n/**\n * `--allow-dev-services` given a value — the list it used to take. It is a\n * switch now: every construct the stage does not account for gets its dev\n * service.\n */\nexport class AllowDevServicesTakesNoValue extends GkmError {\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services takes no value (it was given '${value}'). It runs ` +\n\t\t\t\t'the dev service for every bucket and mail the stage does not account ' +\n\t\t\t\t'for — no key in its secrets, no provider in deploy.<kind>.<stage> — so ' +\n\t\t\t\t'there is nothing to list. Pass --allow-dev-services on its own.',\n\t\t);\n\t\tthis.name = 'AllowDevServicesTakesNoValue';\n\t}\n}\n\n/**\n * Refuses `--allow-dev-services <value>` and `--allow-dev-services=<value>` on\n * a command line, with the reason, before the parser calls the value an\n * excess argument. `gkm deploy` and `gkm compose` take no positional\n * argument, so whatever follows the flag and is not a flag was meant for it.\n *\n * @throws {AllowDevServicesTakesNoValue}\n */\nexport function assertDevServicesFlag(argv: readonly string[]): void {\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i]!;\n\t\tif (arg.startsWith('--allow-dev-services=')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(arg.slice(arg.indexOf('=') + 1));\n\t\t}\n\t\tconst next = argv[i + 1];\n\t\tif (arg === '--allow-dev-services' && next && !next.startsWith('-')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(next);\n\t\t}\n\t}\n}\n\n/** One key a deployed stage needs and its secrets do not hold. */\nexport interface MissingServiceKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, unless the stage accounts for it. */\n\tservice?: DevService;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n}\n\n/**\n * A deployed stage with mail or object storage that its secrets do not\n * configure — every missing key, across every app, at once.\n */\nexport class ExternalServicesNotConfigured extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly missing: readonly MissingServiceKey[],\n\t) {\n\t\tconst standIns = missing.some((m) => m.service !== undefined);\n\t\tconst lines = missing.map((m) => {\n\t\t\tconst by = m.apps?.length ? `, read by ${m.apps.join(', ')}` : '';\n\t\t\treturn (\n\t\t\t\t` gkm secrets:set ${m.key} '${m.example}' --stage ${stage}\\n` +\n\t\t\t\t` ${m.what}${by}` +\n\t\t\t\t(m.note ? `\\n ${m.note}` : '') +\n\t\t\t\t(m.hint ? `\\n ${m.hint}` : '')\n\t\t\t);\n\t\t});\n\t\tsuper(\n\t\t\t`The stage '${stage}' is deployed, and a deployed stage's mail and ` +\n\t\t\t\t`object storage are real services: gkm runs no Mailpit or MinIO for ` +\n\t\t\t\t`it. Set ${missing.length === 1 ? 'this key' : `these ${missing.length} keys`} in the stage's secrets:\\n\\n` +\n\t\t\t\t`${lines.join('\\n')}\\n\\n` +\n\t\t\t\t(standIns\n\t\t\t\t\t? `For a stage that is not production — a preview, a demo — the ` +\n\t\t\t\t\t\t`dev services can run instead, with --allow-dev-services. ` +\n\t\t\t\t\t\t`Mailpit delivers no mail, and MinIO keeps every object on one ` +\n\t\t\t\t\t\t`container's disk.\\n\\n`\n\t\t\t\t\t: '') +\n\t\t\t\t`Or run: gkm secrets:add --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'ExternalServicesNotConfigured';\n\t}\n}\n\n/** A declaration that is mail or object storage. */\nexport interface ServiceDeclaration {\n\tid: string;\n\tkind: 'email' | 'objects' | 'file-server';\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** The kinds a deployed stage takes from its secrets, or a dev service. */\nconst SERVICE_KINDS: Readonly<Record<string, ServiceDeclaration['kind']>> = {\n\temail: 'email',\n\tobjects: 'objects',\n\t'file-server': 'file-server',\n};\n\nexport interface StageServiceDeclarationsInput {\n\tmanifest: ConstructManifest;\n}\n\n/**\n * Every mail and storage construct a manifest declares, each with the apps\n * and workers that read it — a process's environment, a site's build args. A\n * file server's reader reads its bucket too.\n *\n * The one list a deploy's readiness check refuses a stage by, every server\n * target decides its dev services from, and `gkm secrets:add` offers — so\n * none of them can disagree.\n */\nexport function stageServiceDeclarations(\n\tinput: StageServiceDeclarationsInput,\n): ServiceDeclaration[] {\n\tconst { manifest } = input;\n\n\t// The construct each key belongs to.\n\tconst owners = new Map<string, string>();\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tif (!SERVICE_KINDS[declaration.kind]) continue;\n\t\towners.set(provideKey(id, 'url'), id);\n\t\tif (declaration.kind === 'email') owners.set(provideKey(id, 'from'), id);\n\t}\n\n\t// Who reads which construct.\n\tconst readers = new Map<string, Set<string>>();\n\tconst read = (process: string, keys: Iterable<string>) => {\n\t\tfor (const key of keys) {\n\t\t\tconst id = owners.get(key);\n\t\t\tif (!id) continue;\n\t\t\tconst declaration = manifest[id];\n\t\t\tconst of =\n\t\t\t\tdeclaration?.kind === 'file-server' ? declaration.of : undefined;\n\t\t\tfor (const owner of of ? [id, of] : [id]) {\n\t\t\t\tconst set = readers.get(owner) ?? new Set<string>();\n\t\t\t\tset.add(process);\n\t\t\t\treaders.set(owner, set);\n\t\t\t}\n\t\t}\n\t};\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tconst name = appKey(id);\n\t\tif (\n\t\t\tdeclaration.kind === 'rest-api' ||\n\t\t\tdeclaration.kind === 'websocket-api' ||\n\t\t\tdeclaration.kind === 'site' ||\n\t\t\tdeclaration.kind === 'mobile-app'\n\t\t) {\n\t\t\tread(name, appEnvKeys(manifest, name) ?? []);\n\t\t}\n\t\t// A site's build args, by the keys they rename.\n\t\tif (declaration.kind === 'site') {\n\t\t\tread(name, Object.values(publicEnvFor(declaration, manifest)));\n\t\t}\n\t\tif (declaration.kind === 'worker') {\n\t\t\tread(name, workerEnvKeys(manifest, id) ?? []);\n\t\t}\n\t}\n\n\treturn Object.entries(manifest).flatMap(\n\t\t([id, declaration]): ServiceDeclaration[] => {\n\t\t\tconst kind = SERVICE_KINDS[declaration.kind];\n\t\t\tif (!kind) return [];\n\t\t\tconst apps = [...(readers.get(id) ?? [])].sort();\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid,\n\t\t\t\t\tkind,\n\t\t\t\t\t...(declaration.kind === 'file-server' && declaration.of\n\t\t\t\t\t\t? { of: declaration.of }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(apps.length ? { apps } : {}),\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t);\n}\n\nexport interface ExternalServicesInput {\n\tstage: string;\n\t/** Every mail and storage construct something on the stage reads. */\n\tdeclarations: readonly ServiceDeclaration[];\n\t/** The stage's values by key — what `gkm secrets:set` stored. */\n\tsupplied: Readonly<Record<string, string>>;\n\t/**\n\t * `--allow-dev-services`: every construct the stage does not account for\n\t * gets its dev service.\n\t */\n\tallow: boolean;\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/**\n\t * What the stage's providers say, by kind: a kind one backs is accounted\n\t * for, so no dev service stands in for it, and a missing key of it names\n\t * what creates it.\n\t */\n\tproviders?: StageProviderNotes;\n}\n\n/** The stage's providers, as a deploy's checks read them. */\nexport interface StageProviderNotes {\n\tobjects?: {\n\t\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\t\taccounted: boolean;\n\t\t/** What creates a missing key of it. */\n\t\thint?: string;\n\t};\n}\n\n/** Where a deployed stage's mail and storage come from. */\nexport interface ExternalServices {\n\t/** Keys the stage needs and has not set. Empty when it can deploy. */\n\tmissing: MissingServiceKey[];\n\t/** The buckets the target runs MinIO for. */\n\tminio: string[];\n\t/** The mail constructs the target runs Mailpit for. */\n\tmailpit: string[];\n}\n\n/** One dev service a run uses, and for which constructs. */\nexport interface DevServiceUse {\n\tservice: DevService;\n\tids: string[];\n}\n\n/** A third party's credentials a construct reads: an external API's, or a `Credential`. */\nexport interface CredentialDeclaration {\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** What a stage-supplied key belongs to. */\nexport type StageKeyKind =\n\t| 'bucket'\n\t| 'email'\n\t| 'file-server'\n\t| 'external-api'\n\t| 'credential'\n\t/** The server a compose stage's stack runs on: `GKM_SERVER_IPV4`. */\n\t| 'server';\n\n/**\n * One key only the stage's secrets can hold — nothing derives it — whether\n * or not it is set.\n */\nexport interface StageKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\tkind: StageKeyKind;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, where one can. */\n\tservice?: DevService;\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\nexport interface StageKeysInput {\n\t/** Whether the stage is the local one, which derives its mail and storage. */\n\tlocal: boolean;\n\t/** Every mail and storage construct something on the stage reads. */\n\tservices?: readonly ServiceDeclaration[];\n\t/** Every third party's credentials something on the stage reads. */\n\tcredentials?: readonly CredentialDeclaration[];\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/** What the stage's providers say — see {@link StageProviderNotes}. */\n\tproviders?: StageProviderNotes;\n\t/**\n\t * The stage serves a domain from a server of its own — a compose stage —\n\t * so its secrets hold the server's address, `GKM_SERVER_IPV4`.\n\t */\n\tserver?: boolean;\n}\n\n/**\n * Every key a stage must be given rather than derive — the one list both a\n * deploy's checks and `gkm secrets:add` read, so what a deploy refuses and\n * what the builder offers cannot drift.\n *\n * - Deployed, mail is its URL and its sending address, a bucket its URL, and\n * a file server its public URL. Locally all of it is Mailpit and MinIO.\n * - On every stage, a third party's credentials: nobody but the third party\n * can issue them.\n *\n * Never a derived value: a database URL, a generated secret, the seed.\n */\nexport function requiredStageKeys(input: StageKeysInput): StageKey[] {\n\tconst domain = input.domain ?? 'example.com';\n\tconst keys: StageKey[] = [];\n\tconst add = (entry: StageKey) => {\n\t\tif (!keys.some((k) => k.key === entry.key)) keys.push(entry);\n\t};\n\tconst byId = <T extends { id: string }>(list: readonly T[] | undefined) =>\n\t\t[...(list ?? [])].sort((a, b) => a.id.localeCompare(b.id));\n\tconst apps = (d: { apps?: readonly string[] }) =>\n\t\td.apps?.length ? { apps: [...d.apps].sort() } : {};\n\n\tif (!input.local) {\n\t\tconst services = byId(input.services);\n\t\t// A kind a provider backs on the stage has no dev service, and a key of\n\t\t// it names what creates it.\n\t\tconst objects = input.providers?.objects;\n\t\tconst storage = objects?.accounted\n\t\t\t? objects.hint\n\t\t\t\t? { hint: objects.hint }\n\t\t\t\t: {}\n\t\t\t: { service: 'minio' as const };\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `where '${d.id}' sends mail — any SMTP server`,\n\t\t\t\texample: `smtp://user:password@smtp.${domain}:587`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'from'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `the address '${d.id}' sends from, on a domain the mail server has verified`,\n\t\t\t\texample: `noreply@${domain}`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'objects')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'bucket',\n\t\t\t\twhat: `the bucket '${d.id}' — S3, R2, or any S3-compatible store (add &endpoint=… for one that is not S3)`,\n\t\t\t\tnote: `credentials are optional: a key for this bucket alone in the URL (s3://KEY:SECRET@${appKey(d.id)}?…) wins; without one, the shared AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or a role signs`,\n\t\t\t\texample: `s3://${appKey(d.id)}?region=eu-west-1`,\n\t\t\t\t...storage,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'file-server')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'file-server',\n\t\t\t\twhat: `the public address '${d.id}' serves its bucket on — a CDN or the bucket's own domain`,\n\t\t\t\texample: `https://${appKey(d.id)}.${domain}`,\n\t\t\t\t...storage,\n\t\t\t\t...(d.of ? { of: d.of } : {}),\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t}\n\n\tif (!input.local && input.server) {\n\t\tadd({\n\t\t\tkey: SERVER_IPV4_KEY,\n\t\t\tid: 'server',\n\t\t\tkind: 'server',\n\t\t\twhat: \"the public IPv4 address of the server the stage's stack runs on — its hosts' DNS records point at it, and every deploy checks they do\",\n\t\t\tnote: `${SERVER_IPV6_KEY} adds its IPv6 address (AAAA records); neither is ever handed to an app`,\n\t\t\texample: '203.0.113.10',\n\t\t});\n\t}\n\n\tfor (const d of byId(input.credentials)) {\n\t\tadd({\n\t\t\tkey: provideKey(d.id, 'credentials'),\n\t\t\tid: d.id,\n\t\t\tkind: d.kind,\n\t\t\twhat:\n\t\t\t\td.kind === 'external-api'\n\t\t\t\t\t? `the credentials '${d.id}' was issued for this stage, as its schema describes them`\n\t\t\t\t\t: `the credential '${d.id}', as its schema describes it`,\n\t\t\texample: '{\"apiKey\":\"…\"}',\n\t\t\t...apps(d),\n\t\t});\n\t}\n\n\treturn keys;\n}\n\n/**\n * Whether only the stage's secrets can supply `key` to a construct of `kind`\n * — what nothing on the stage derives.\n *\n * A third party's credentials, always. Deployed, also each generated secret\n * and keyring: the stage generated each one once, and every run reads the\n * same value back.\n */\nexport function suppliedOnly(\n\tkind: string,\n\tid: string,\n\tkey: string,\n\tlocal: boolean,\n): boolean {\n\tif (kind === 'credential') return true;\n\tif (kind === 'external-api') return key === provideKey(id, 'credentials');\n\tif (local) return false;\n\treturn kind === 'secret' || kind === 'encryption';\n}\n\n/**\n * Where a deployed stage's mail and storage come from, and what it lacks.\n *\n * - Mail is external once its URL is set, and then needs its sending\n * address too. Unset, it is Mailpit where allowed — the address derived\n * unless set — and missing otherwise.\n * - A bucket is external once its URL is set; its credentials, in the URL or\n * the shared pair, are optional. Unset, it is MinIO where allowed, and\n * missing otherwise.\n * - A file server's URL is derived where its bucket is MinIO, unless set;\n * over an external bucket the stage must set it.\n *\n * The keys themselves are {@link requiredStageKeys}'s.\n */\nexport function externalServices(\n\tinput: ExternalServicesInput,\n): ExternalServices {\n\tconst { supplied, allow } = input;\n\tconst has = (key: string) => supplied[key] !== undefined;\n\n\tconst required = requiredStageKeys({\n\t\tlocal: false,\n\t\tservices: input.declarations,\n\t\t...(input.domain ? { domain: input.domain } : {}),\n\t\t...(input.providers ? { providers: input.providers } : {}),\n\t});\n\n\t// A dev service stands in for each construct the stage does not account\n\t// for: no key in its secrets, and no provider backing its kind.\n\tconst standIn = (k: StageKey) =>\n\t\tallow && k.service !== undefined && !has(k.key);\n\tconst mailpit = required\n\t\t.filter((k) => k.kind === 'email' && k.key === provideKey(k.id, 'url'))\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\tconst minio = required\n\t\t.filter((k) => k.kind === 'bucket')\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\n\tconst covered = (k: StageKey) =>\n\t\t(k.kind === 'email' && mailpit.includes(k.id)) ||\n\t\t(k.kind === 'bucket' && minio.includes(k.id)) ||\n\t\t(k.kind === 'file-server' && k.of !== undefined && minio.includes(k.of));\n\n\tconst missing = required\n\t\t.filter((k) => !has(k.key) && !covered(k))\n\t\t.map(\n\t\t\t({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\tnote,\n\t\t\t\texample,\n\t\t\t\tservice,\n\t\t\t\tapps,\n\t\t\t\thint,\n\t\t\t}): MissingServiceKey => ({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\t...(note ? { note } : {}),\n\t\t\t\texample,\n\t\t\t\t...(service ? { service } : {}),\n\t\t\t\t...(apps ? { apps } : {}),\n\t\t\t\t...(hint ? { hint } : {}),\n\t\t\t}),\n\t\t);\n\n\treturn { missing, minio, mailpit };\n}\n\n/** The dev services a run uses, one entry per service it runs. */\nexport function devServicesUsed(services: ExternalServices): DevServiceUse[] {\n\tconst used: DevServiceUse[] = [];\n\tif (services.mailpit.length > 0) {\n\t\tused.push({ service: 'mailpit', ids: services.mailpit });\n\t}\n\tif (services.minio.length > 0) {\n\t\tused.push({ service: 'minio', ids: services.minio });\n\t}\n\treturn used;\n}\n\n/** The line a run prints for each dev service a deployed stage uses. */\nexport function devServiceWarning(stage: string, use: DevServiceUse): string {\n\tconst what =\n\t\tuse.service === 'mailpit'\n\t\t\t? `Mailpit is catching mail for ${use.ids.join(', ')}. It delivers NO mail: nobody receives a sign-in link, a receipt or a reset`\n\t\t\t: `MinIO is storing ${use.ids.join(', ')}. Every object is on one container's disk, with no replication and no backup`;\n\treturn (\n\t\t`⚠️ DEV SERVICE ON A DEPLOYED STAGE (${stage}): ${what}. It is not ` +\n\t\t`production-grade — set the stage's own keys in its secrets for that.`\n\t);\n}\n\n/**\n * Report each dev service a run uses: a loud line, and a `dev-service.used`\n * event a host can act on.\n */\nexport function reportDevServices(\n\tctx: {\n\t\tstage: string;\n\t\tlogger: { warn(message: string): void };\n\t\temit(event: {\n\t\t\ttype: 'dev-service.used';\n\t\t\tservice: DevService;\n\t\t\tstage: string;\n\t\t\tconstructs: string[];\n\t\t}): void;\n\t},\n\tuses: readonly DevServiceUse[],\n): void {\n\tfor (const use of uses) {\n\t\tctx.logger.warn(`\\n${devServiceWarning(ctx.stage, use)}`);\n\t\tctx.emit({\n\t\t\ttype: 'dev-service.used',\n\t\t\tservice: use.service,\n\t\t\tstage: ctx.stage,\n\t\t\tconstructs: use.ids,\n\t\t});\n\t}\n}\n","/**\n * Providers: what creates the thing a construct is backed by, on a stage.\n *\n * The manifest says a bucket exists (`ObjectStorage`); `deploy.<kind>.<stage>`\n * says what backs it there. A stage that names a provider has gkm *create*\n * the backing resource — when it holds the account's provisioning\n * credentials — and write the connection value into the stage's secrets,\n * where every deploy reads it as if it had been set by hand. A stage that\n * names none is `external`: the value is yours to set, as it always was.\n *\n * | Part | What it is |\n * | ------------------------ | ------------------------------------------------------- |\n * | provisioning credentials | What creates the resource. Never given to an app. |\n * | `ensure()` | Idempotent find-or-create. Records in state. Never deletes. |\n * | runtime credentials | The keys it writes into the stage's secrets. |\n * | `verify()` | The cheap check every deploy runs. |\n *\n * The key under `deploy` is the manifest kind — `objects`, which\n * `ObjectStorage` and `FileServer` produce — so `deploy.cache` and\n * `deploy.email` slot in beside it with providers of their own.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport type { ResourceRecord } from '../deploy/StateStore.js';\nimport type { BoundSubscriber } from '../reconcile/discover.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\n/** The manifest kinds a stage can name a provider for. */\nexport const PROVIDER_KINDS = ['objects', 'inbox'] as const;\n\nexport type ProviderKind = (typeof PROVIDER_KINDS)[number];\n\n/** A provider's own entry: `{ provider: 's3', … }`. */\nexport interface ProviderConfig {\n\tprovider: string;\n}\n\n/**\n * One stage's entry under `deploy.<kind>`:\n *\n * - `'external'` — the default: the stage's secrets hold the key, set by you.\n * - `{ provider, … }` — that provider creates the resource and writes the key.\n * - `false` — the stage has none of this kind; a construct of it is refused.\n */\nexport type StageProviderEntry<C extends ProviderConfig = ProviderConfig> =\n\t| 'external'\n\t| C\n\t| false;\n\n/** One change `ensure()` makes, or — in a dry run — would make. */\nexport interface ProvisionAction {\n\t/** The construct it is for. */\n\tconstruct: string;\n\t/** What it acts on: `bucket acme-shop-prod-uploads`. */\n\tresource: string;\n\t/** What it does: `create`, `set CORS (2 origins)`. */\n\tchange: string;\n}\n\n/** The stage's provisioning record, as `ensure()` reads and writes it. */\nexport interface ProvisionState {\n\t/** A resource recorded by an earlier run. */\n\trecord(key: string): ResourceRecord | undefined;\n\t/** About to be created — written before the call that creates it. */\n\tpending(entry: StateEntry): Promise<void>;\n\t/** Exists, as `id`. */\n\tready(entry: StateEntry, id: string): Promise<void>;\n\t/** When the stage was last deployed, for a rotation to know it was. */\n\treadonly lastDeployedAt?: string;\n}\n\nexport interface StateEntry {\n\t/** `<type>:<name>`, unique within the stage. */\n\tkey: string;\n\ttype: string;\n\tdata?: Record<string, unknown>;\n}\n\n/** What `ensure()` is handed. */\nexport interface EnsureContext<C extends ProviderConfig, K> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Each Worker's subscribers, from discovery — by export and the key its\n\t * deliveries come from. What a provider subscribes on a worker's behalf.\n\t */\n\tsubscribers?: Readonly<Record<string, readonly BoundSubscriber[]>>;\n\tstage: string;\n\tidentity: DeployIdentity;\n\tconfig: C;\n\t/** The provisioning credentials {@link ResourceProvider.credentials} found. */\n\tcredential: K;\n\t/** The stage's secrets as they are now, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\tstate: ProvisionState;\n\tdryRun: boolean;\n\t/** `--rotate-keys`: issue each runtime key a successor. */\n\trotateKeys: boolean;\n\t/** `--retire-old-keys`: delete a rotated-out key without waiting for a deploy. */\n\tretireOldKeys: boolean;\n\t/**\n\t * Runs `apply` and records `action` — or, in a dry run, only records it.\n\t * Every write to the provider's account goes through here.\n\t */\n\tchange(action: ProvisionAction, apply: () => Promise<void>): Promise<void>;\n\t/**\n\t * Writes keys into the stage's secrets now — not at the end of the run, so\n\t * a secret the account shows only once is kept the moment it exists. A dry\n\t * run writes nothing.\n\t */\n\twriteSecrets(values: Record<string, string>): Promise<void>;\n\t/**\n\t * Writes DNS records through the stage's DNS providers (`dns`), as the\n\t * deploy's own DNS step does — what a certificate's validation record and\n\t * a CDN's name, a domain's inbound mail (MX) need. A dry run prints them\n\t * and writes nothing.\n\t */\n\twriteDns(records: readonly ProviderDnsRecord[]): Promise<ProviderDnsResult>;\n\tlog(line: string): void;\n}\n\n/** One record a provider asks the stage's DNS for. */\nexport type ProviderDnsRecord =\n\t| {\n\t\t\t/** The full name: `_abc.files.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'CNAME';\n\t\t\tvalue: string;\n\t }\n\t| {\n\t\t\t/** The full name: `example.com`, `*.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'MX';\n\t\t\t/** The mail server: `inbound-smtp.eu-west-1.amazonaws.com`. */\n\t\t\tvalue: string;\n\t\t\t/** Lower is preferred: `10`. */\n\t\t\tpriority: number;\n\t };\n\n/** What writing a provider's records came to. */\nexport interface ProviderDnsResult {\n\t/**\n\t * Hosts no DNS provider wrote — under no domain in `dns`, or a `manual`\n\t * one — printed for the person to create.\n\t */\n\tmanual: string[];\n}\n\n/** What `verify()` is handed. */\nexport interface VerifyContext<C extends ProviderConfig> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\tstage: string;\n\tconfig: C;\n\t/** The stage's secrets, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\t/**\n\t * What the stage's state records, by key — how a provider knows a key it\n\t * checks was issued moments ago. Absent when nothing was read.\n\t */\n\tresources?: Readonly<Record<string, ResourceRecord>>;\n\t/** Progress worth printing: waiting on something. */\n\tlog?: (line: string) => void;\n}\n\n/** Where a provider's provisioning credentials are looked for. */\nexport interface CredentialLookup {\n\tstage: string;\n\t/** `--profile`, when given. */\n\tprofile?: string;\n\tenv: NodeJS.ProcessEnv;\n\t/** The CLI's home, for stored logins. */\n\thome?: string;\n}\n\n/**\n * A provider. `C` is its config entry, `K` its provisioning credential.\n *\n * Built-ins are registered in `providers/registry.ts`, the way a deploy\n * target's built-ins are.\n */\nexport interface ResourceProvider<\n\tC extends ProviderConfig = ProviderConfig,\n\tK = unknown,\n> {\n\treadonly kind: ProviderKind;\n\t/** What `provider:` names it. */\n\treadonly name: string;\n\t/**\n\t * Its config entry checked: returns it, or throws a named error saying\n\t * what is wrong — what the workspace schema runs.\n\t */\n\tcheck(stage: string, config: ProviderConfig): C;\n\t/** How its provisioning credentials are supplied, for messages. */\n\treadonly provisioning: {\n\t\t/** The environment variables it reads. */\n\t\tenv: readonly string[];\n\t\t/** A `gkm login --provider` name, where it has one. */\n\t\tlogin?: string;\n\t\t/** One line saying how to supply them. */\n\t\tdescribe: string;\n\t};\n\t/** Its provisioning credentials, or `undefined` when there are none. */\n\tcredentials(lookup: CredentialLookup): Promise<K | undefined>;\n\t/** The keys it writes into the stage's secrets for these constructs. */\n\truntimeKeys(manifest: ConstructManifest): string[];\n\tensure(ctx: EnsureContext<C, K>): Promise<void>;\n\tverify(ctx: VerifyContext<C>): Promise<void>;\n}\n","/**\n * What a deploy's checks read off `deploy.<kind>.<stage>`, without loading a\n * provider: which kinds the stage accounts for, what creates a missing key,\n * and a kind the stage has none of.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { StageProviderNotes } from '../deploy/devServices.js';\nimport { GkmError } from '../errors';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { provisioningOf, stageProvider } from './config.js';\nimport { PROVIDER_KINDS, type ProviderKind } from './types.js';\n\n/** The constructs of a kind: `objects` is every bucket. */\nexport function constructsOf(manifest: ConstructManifest, kind: ProviderKind) {\n\treturn Object.entries(manifest)\n\t\t.filter(([, d]) => d.kind === kind)\n\t\t.map(([id]) => id)\n\t\t.sort();\n}\n\n/** A stage that names `false` for a kind, and declares constructs of it. */\nexport class StageProviderDisabled extends GkmError {\n\tconstructor(\n\t\treadonly kind: ProviderKind,\n\t\treadonly stage: string,\n\t\treadonly ids: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`deploy.${kind}.${stage} is false — the stage has no ${kind} — and ` +\n\t\t\t\t`${ids.join(', ')} ${ids.length === 1 ? 'is' : 'are'} declared. ` +\n\t\t\t\t`Name what backs ${ids.length === 1 ? 'it' : 'them'} on '${stage}' ` +\n\t\t\t\t`(deploy.${kind}.${stage}: 'external', or a provider), or remove ` +\n\t\t\t\t`the ${ids.length === 1 ? 'construct' : 'constructs'}.`,\n\t\t);\n\t\tthis.name = 'StageProviderDisabled';\n\t}\n}\n\n/** The command a stage's providers are run with: every deploy runs them. */\nexport function provisionCommand(stage: string): string {\n\treturn `gkm deploy --stage ${stage}`;\n}\n\n/**\n * The line a stage missing a key a provider would write is given: what\n * creates it, and with which credentials. Undefined when no provider backs\n * the kind on the stage.\n */\nexport function provisionHint(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tkind: ProviderKind,\n\tstage: string,\n): string | undefined {\n\tconst choice = stageProvider(workspace as never, kind, stage);\n\tif (choice.mode !== 'provider') return undefined;\n\tconst provisioning = provisioningOf(kind, choice.name);\n\tif (!provisioning) return undefined;\n\treturn (\n\t\t`deploy.${kind}.${stage} is ${choice.name}: the deploy ` +\n\t\t`(${provisionCommand(stage)}) creates it and writes this key, with ` +\n\t\t`${provisioning.describe}` +\n\t\t(provisioning.login\n\t\t\t? `, or gkm login --provider ${provisioning.login}`\n\t\t\t: '')\n\t);\n}\n\n/**\n * What a deploy's checks read off the stage's providers: whether each kind is\n * accounted for — a provider, or `false` — so no dev service stands in for\n * it, and what creates a missing key of it.\n */\nexport function stageProviderNotes(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tstage: string,\n): StageProviderNotes {\n\tconst choice = stageProvider(workspace as never, 'objects', stage);\n\tif (choice.mode === 'external') return {};\n\tconst hint = provisionHint(workspace, 'objects', stage);\n\treturn { objects: { accounted: true, ...(hint ? { hint } : {}) } };\n}\n\n/**\n * A kind the stage set to `false`, declared anyway — refused before anything\n * else is checked. Pure: what a stack is composed from.\n *\n * @throws {StageProviderDisabled}\n */\nexport function assertStageProvidersEnabled(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tmanifest: ConstructManifest,\n\tstage: string,\n): void {\n\tfor (const kind of PROVIDER_KINDS) {\n\t\tconst ids = constructsOf(manifest, kind);\n\t\tif (ids.length === 0) continue;\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'none') {\n\t\t\tthrow new StageProviderDisabled(kind, stage, ids);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,eAAe,CAAC,SAAS,SAAS;;;;;;;AAU/C,MAAa,mBAAmB,CAC/B,qBACA,uBACD;;AAGA,IAAa,8BAAb,cAAiDA,eAAAA,SAAS;CACpC;CAArB,YAAY,QAAyB;EACpC,MACC,6DAA6D,OAAO,+FAGrE;EALoB,KAAA,SAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;;AAOA,IAAa,+BAAb,cAAkDA,eAAAA,SAAS;CACrC;CAArB,YAAY,OAAwB;EACnC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,IAAI;EACvC,IAAI,IAAI,WAAW,GAAG;EACtB,IAAIA,kBAAAA,cAAc,WAAoB,MAAM,KAAK,CAAC,CAAC,SAAS,QAC3D,MAAM,IAAI,sBAAsB,MAAM,OAAO,GAAG;CAElD;AACD"}
@@ -1,6 +1,6 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
2
  import { H as provisioningOf, U as stageProvider, _t as SERVER_IPV6_KEY, gt as SERVER_IPV4_KEY } from "./workspace-DFGsrjGD.mjs";
3
- import { l as workerEnvKeys, t as appEnvKeys } from "./apps-BVcA1Hy7.mjs";
3
+ import { l as workerEnvKeys, t as appEnvKeys } from "./apps-BHiqiigd.mjs";
4
4
  import { g as appKey } from "./config-BLrAd7Of.mjs";
5
5
  import { provideKey, publicEnvFor } from "@geekmidas/manifest";
6
6
  //#region src/deploy/devServices.ts
@@ -396,4 +396,4 @@ function assertStageProvidersEnabled(workspace, manifest, stage) {
396
396
  //#endregion
397
397
  export { suppliedOnly as _, PROVIDER_KINDS as a, DevServicesNeedServerTarget as c, assertDevServicesFlag as d, devServicesUsed as f, stageServiceDeclarations as g, requiredStageKeys as h, stageProviderNotes as i, ExternalServicesNotConfigured as l, reportDevServices as m, assertStageProvidersEnabled as n, AllowDevServicesTakesNoValue as o, externalServices as p, provisionCommand as r, DEV_SERVICES as s, StageProviderDisabled as t, STORAGE_KEY_PAIR as u };
398
398
 
399
- //# sourceMappingURL=notes-C5LmC9-z.mjs.map
399
+ //# sourceMappingURL=notes-DdNcS5q5.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notes-C5LmC9-z.mjs","names":[],"sources":["../src/deploy/devServices.ts","../src/providers/types.ts","../src/providers/notes.ts"],"sourcesContent":["/**\n * Mail and object storage on a deployed stage: real ones, or — only when\n * someone asked — the dev services the local stage runs.\n *\n * Locally a declared `Email` is Mailpit and a declared bucket is MinIO, and\n * nobody has to configure either. Deployed, the same two containers would be\n * a stage that silently delivers no mail and keeps its files on one\n * container's disk. So a deployed stage on a server target takes both from\n * its secrets — the mail server's URL and sending address, and each bucket's\n * URL — and a stage missing any of them fails before anything is built,\n * provisioned or written, naming every key at once.\n *\n * A bucket's credentials are not checked: they are optional, and come from\n * either of two places. The bucket's URL may carry a key of its own\n * (`s3://KEY:SECRET@uploads`), which wins; otherwise the S3 client's default\n * chain applies — the stage's shared `AWS_ACCESS_KEY_ID`/\n * `AWS_SECRET_ACCESS_KEY` when it set them, or a role.\n *\n * `--allow-dev-services` is the way out for a stage that is not production —\n * a preview, a demo: every construct the stage does not account for gets the\n * dev service the local stage runs for it — a bucket MinIO, mail Mailpit —\n * and the target derives the keys from it. What the stage does account for\n * still wins: a key set in its secrets, or a provider (`deploy.objects`)\n * that backs the kind. Every run that uses one says so, loudly.\n *\n * Pure: what each target runs is decided here from declarations and the\n * stage's values, and the targets do the running.\n */\n\nimport {\n\ttype ConstructManifest,\n\tprovideKey,\n\tpublicEnvFor,\n} from '@geekmidas/manifest';\nimport { SERVER_IPV4_KEY, SERVER_IPV6_KEY } from '../compose/dnsConfig.js';\nimport { GkmError } from '../errors';\nimport { appEnvKeys, workerEnvKeys } from '../reconcile/apps.js';\nimport { appKey } from '../workspace/derive.js';\n\n/**\n * The dev services a deployed stage can run — one per kind that has one on\n * every server target: a bucket's MinIO and mail's Mailpit. A cache or a\n * database is not here because a server stage runs its own anyway.\n */\nexport const DEV_SERVICES = ['minio', 'mailpit'] as const;\n\nexport type DevService = (typeof DEV_SERVICES)[number];\n\n/**\n * The S3 client's shared key pair. Optional: a bucket whose URL carries its own\n * key (`s3://KEY:SECRET@bucket`) signs with that, and one without signs with\n * this pair when the stage set it, or with whatever else the SDK's default\n * chain finds — a role.\n */\nexport const STORAGE_KEY_PAIR = [\n\t'AWS_ACCESS_KEY_ID',\n\t'AWS_SECRET_ACCESS_KEY',\n] as const;\n\n/** Dev services asked of a target that runs no containers. */\nexport class DevServicesNeedServerTarget extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services applies to server targets only, and '${target}' ` +\n\t\t\t\t`deploys to AWS, where a bucket is S3 and mail is the stage's own. ` +\n\t\t\t\t'Drop --allow-dev-services.',\n\t\t);\n\t\tthis.name = 'DevServicesNeedServerTarget';\n\t}\n}\n\n/**\n * `--allow-dev-services` given a value — the list it used to take. It is a\n * switch now: every construct the stage does not account for gets its dev\n * service.\n */\nexport class AllowDevServicesTakesNoValue extends GkmError {\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services takes no value (it was given '${value}'). It runs ` +\n\t\t\t\t'the dev service for every bucket and mail the stage does not account ' +\n\t\t\t\t'for — no key in its secrets, no provider in deploy.<kind>.<stage> — so ' +\n\t\t\t\t'there is nothing to list. Pass --allow-dev-services on its own.',\n\t\t);\n\t\tthis.name = 'AllowDevServicesTakesNoValue';\n\t}\n}\n\n/**\n * Refuses `--allow-dev-services <value>` and `--allow-dev-services=<value>` on\n * a command line, with the reason, before the parser calls the value an\n * excess argument. `gkm deploy` and `gkm compose` take no positional\n * argument, so whatever follows the flag and is not a flag was meant for it.\n *\n * @throws {AllowDevServicesTakesNoValue}\n */\nexport function assertDevServicesFlag(argv: readonly string[]): void {\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i]!;\n\t\tif (arg.startsWith('--allow-dev-services=')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(arg.slice(arg.indexOf('=') + 1));\n\t\t}\n\t\tconst next = argv[i + 1];\n\t\tif (arg === '--allow-dev-services' && next && !next.startsWith('-')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(next);\n\t\t}\n\t}\n}\n\n/** One key a deployed stage needs and its secrets do not hold. */\nexport interface MissingServiceKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, unless the stage accounts for it. */\n\tservice?: DevService;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n}\n\n/**\n * A deployed stage with mail or object storage that its secrets do not\n * configure — every missing key, across every app, at once.\n */\nexport class ExternalServicesNotConfigured extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly missing: readonly MissingServiceKey[],\n\t) {\n\t\tconst standIns = missing.some((m) => m.service !== undefined);\n\t\tconst lines = missing.map((m) => {\n\t\t\tconst by = m.apps?.length ? `, read by ${m.apps.join(', ')}` : '';\n\t\t\treturn (\n\t\t\t\t` gkm secrets:set ${m.key} '${m.example}' --stage ${stage}\\n` +\n\t\t\t\t` ${m.what}${by}` +\n\t\t\t\t(m.note ? `\\n ${m.note}` : '') +\n\t\t\t\t(m.hint ? `\\n ${m.hint}` : '')\n\t\t\t);\n\t\t});\n\t\tsuper(\n\t\t\t`The stage '${stage}' is deployed, and a deployed stage's mail and ` +\n\t\t\t\t`object storage are real services: gkm runs no Mailpit or MinIO for ` +\n\t\t\t\t`it. Set ${missing.length === 1 ? 'this key' : `these ${missing.length} keys`} in the stage's secrets:\\n\\n` +\n\t\t\t\t`${lines.join('\\n')}\\n\\n` +\n\t\t\t\t(standIns\n\t\t\t\t\t? `For a stage that is not production — a preview, a demo — the ` +\n\t\t\t\t\t\t`dev services can run instead, with --allow-dev-services. ` +\n\t\t\t\t\t\t`Mailpit delivers no mail, and MinIO keeps every object on one ` +\n\t\t\t\t\t\t`container's disk.\\n\\n`\n\t\t\t\t\t: '') +\n\t\t\t\t`Or run: gkm secrets:add --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'ExternalServicesNotConfigured';\n\t}\n}\n\n/** A declaration that is mail or object storage. */\nexport interface ServiceDeclaration {\n\tid: string;\n\tkind: 'email' | 'objects' | 'file-server';\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** The kinds a deployed stage takes from its secrets, or a dev service. */\nconst SERVICE_KINDS: Readonly<Record<string, ServiceDeclaration['kind']>> = {\n\temail: 'email',\n\tobjects: 'objects',\n\t'file-server': 'file-server',\n};\n\nexport interface StageServiceDeclarationsInput {\n\tmanifest: ConstructManifest;\n}\n\n/**\n * Every mail and storage construct a manifest declares, each with the apps\n * and workers that read it — a process's environment, a site's build args. A\n * file server's reader reads its bucket too.\n *\n * The one list a deploy's readiness check refuses a stage by, every server\n * target decides its dev services from, and `gkm secrets:add` offers — so\n * none of them can disagree.\n */\nexport function stageServiceDeclarations(\n\tinput: StageServiceDeclarationsInput,\n): ServiceDeclaration[] {\n\tconst { manifest } = input;\n\n\t// The construct each key belongs to.\n\tconst owners = new Map<string, string>();\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tif (!SERVICE_KINDS[declaration.kind]) continue;\n\t\towners.set(provideKey(id, 'url'), id);\n\t\tif (declaration.kind === 'email') owners.set(provideKey(id, 'from'), id);\n\t}\n\n\t// Who reads which construct.\n\tconst readers = new Map<string, Set<string>>();\n\tconst read = (process: string, keys: Iterable<string>) => {\n\t\tfor (const key of keys) {\n\t\t\tconst id = owners.get(key);\n\t\t\tif (!id) continue;\n\t\t\tconst declaration = manifest[id];\n\t\t\tconst of =\n\t\t\t\tdeclaration?.kind === 'file-server' ? declaration.of : undefined;\n\t\t\tfor (const owner of of ? [id, of] : [id]) {\n\t\t\t\tconst set = readers.get(owner) ?? new Set<string>();\n\t\t\t\tset.add(process);\n\t\t\t\treaders.set(owner, set);\n\t\t\t}\n\t\t}\n\t};\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tconst name = appKey(id);\n\t\tif (\n\t\t\tdeclaration.kind === 'rest-api' ||\n\t\t\tdeclaration.kind === 'websocket-api' ||\n\t\t\tdeclaration.kind === 'site' ||\n\t\t\tdeclaration.kind === 'mobile-app'\n\t\t) {\n\t\t\tread(name, appEnvKeys(manifest, name) ?? []);\n\t\t}\n\t\t// A site's build args, by the keys they rename.\n\t\tif (declaration.kind === 'site') {\n\t\t\tread(name, Object.values(publicEnvFor(declaration, manifest)));\n\t\t}\n\t\tif (declaration.kind === 'worker') {\n\t\t\tread(name, workerEnvKeys(manifest, id) ?? []);\n\t\t}\n\t}\n\n\treturn Object.entries(manifest).flatMap(\n\t\t([id, declaration]): ServiceDeclaration[] => {\n\t\t\tconst kind = SERVICE_KINDS[declaration.kind];\n\t\t\tif (!kind) return [];\n\t\t\tconst apps = [...(readers.get(id) ?? [])].sort();\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid,\n\t\t\t\t\tkind,\n\t\t\t\t\t...(declaration.kind === 'file-server' && declaration.of\n\t\t\t\t\t\t? { of: declaration.of }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(apps.length ? { apps } : {}),\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t);\n}\n\nexport interface ExternalServicesInput {\n\tstage: string;\n\t/** Every mail and storage construct something on the stage reads. */\n\tdeclarations: readonly ServiceDeclaration[];\n\t/** The stage's values by key — what `gkm secrets:set` stored. */\n\tsupplied: Readonly<Record<string, string>>;\n\t/**\n\t * `--allow-dev-services`: every construct the stage does not account for\n\t * gets its dev service.\n\t */\n\tallow: boolean;\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/**\n\t * What the stage's providers say, by kind: a kind one backs is accounted\n\t * for, so no dev service stands in for it, and a missing key of it names\n\t * what creates it.\n\t */\n\tproviders?: StageProviderNotes;\n}\n\n/** The stage's providers, as a deploy's checks read them. */\nexport interface StageProviderNotes {\n\tobjects?: {\n\t\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\t\taccounted: boolean;\n\t\t/** What creates a missing key of it. */\n\t\thint?: string;\n\t};\n}\n\n/** Where a deployed stage's mail and storage come from. */\nexport interface ExternalServices {\n\t/** Keys the stage needs and has not set. Empty when it can deploy. */\n\tmissing: MissingServiceKey[];\n\t/** The buckets the target runs MinIO for. */\n\tminio: string[];\n\t/** The mail constructs the target runs Mailpit for. */\n\tmailpit: string[];\n}\n\n/** One dev service a run uses, and for which constructs. */\nexport interface DevServiceUse {\n\tservice: DevService;\n\tids: string[];\n}\n\n/** A third party's credentials a construct reads: an external API's, or a `Credential`. */\nexport interface CredentialDeclaration {\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** What a stage-supplied key belongs to. */\nexport type StageKeyKind =\n\t| 'bucket'\n\t| 'email'\n\t| 'file-server'\n\t| 'external-api'\n\t| 'credential'\n\t/** The server a compose stage's stack runs on: `GKM_SERVER_IPV4`. */\n\t| 'server';\n\n/**\n * One key only the stage's secrets can hold — nothing derives it — whether\n * or not it is set.\n */\nexport interface StageKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\tkind: StageKeyKind;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, where one can. */\n\tservice?: DevService;\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\nexport interface StageKeysInput {\n\t/** Whether the stage is the local one, which derives its mail and storage. */\n\tlocal: boolean;\n\t/** Every mail and storage construct something on the stage reads. */\n\tservices?: readonly ServiceDeclaration[];\n\t/** Every third party's credentials something on the stage reads. */\n\tcredentials?: readonly CredentialDeclaration[];\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/** What the stage's providers say — see {@link StageProviderNotes}. */\n\tproviders?: StageProviderNotes;\n\t/**\n\t * The stage serves a domain from a server of its own — a compose stage —\n\t * so its secrets hold the server's address, `GKM_SERVER_IPV4`.\n\t */\n\tserver?: boolean;\n}\n\n/**\n * Every key a stage must be given rather than derive — the one list both a\n * deploy's checks and `gkm secrets:add` read, so what a deploy refuses and\n * what the builder offers cannot drift.\n *\n * - Deployed, mail is its URL and its sending address, a bucket its URL, and\n * a file server its public URL. Locally all of it is Mailpit and MinIO.\n * - On every stage, a third party's credentials: nobody but the third party\n * can issue them.\n *\n * Never a derived value: a database URL, a generated secret, the seed.\n */\nexport function requiredStageKeys(input: StageKeysInput): StageKey[] {\n\tconst domain = input.domain ?? 'example.com';\n\tconst keys: StageKey[] = [];\n\tconst add = (entry: StageKey) => {\n\t\tif (!keys.some((k) => k.key === entry.key)) keys.push(entry);\n\t};\n\tconst byId = <T extends { id: string }>(list: readonly T[] | undefined) =>\n\t\t[...(list ?? [])].sort((a, b) => a.id.localeCompare(b.id));\n\tconst apps = (d: { apps?: readonly string[] }) =>\n\t\td.apps?.length ? { apps: [...d.apps].sort() } : {};\n\n\tif (!input.local) {\n\t\tconst services = byId(input.services);\n\t\t// A kind a provider backs on the stage has no dev service, and a key of\n\t\t// it names what creates it.\n\t\tconst objects = input.providers?.objects;\n\t\tconst storage = objects?.accounted\n\t\t\t? objects.hint\n\t\t\t\t? { hint: objects.hint }\n\t\t\t\t: {}\n\t\t\t: { service: 'minio' as const };\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `where '${d.id}' sends mail — any SMTP server`,\n\t\t\t\texample: `smtp://user:password@smtp.${domain}:587`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'from'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `the address '${d.id}' sends from, on a domain the mail server has verified`,\n\t\t\t\texample: `noreply@${domain}`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'objects')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'bucket',\n\t\t\t\twhat: `the bucket '${d.id}' — S3, R2, or any S3-compatible store (add &endpoint=… for one that is not S3)`,\n\t\t\t\tnote: `credentials are optional: a key for this bucket alone in the URL (s3://KEY:SECRET@${appKey(d.id)}?…) wins; without one, the shared AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or a role signs`,\n\t\t\t\texample: `s3://${appKey(d.id)}?region=eu-west-1`,\n\t\t\t\t...storage,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'file-server')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'file-server',\n\t\t\t\twhat: `the public address '${d.id}' serves its bucket on — a CDN or the bucket's own domain`,\n\t\t\t\texample: `https://${appKey(d.id)}.${domain}`,\n\t\t\t\t...storage,\n\t\t\t\t...(d.of ? { of: d.of } : {}),\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t}\n\n\tif (!input.local && input.server) {\n\t\tadd({\n\t\t\tkey: SERVER_IPV4_KEY,\n\t\t\tid: 'server',\n\t\t\tkind: 'server',\n\t\t\twhat: \"the public IPv4 address of the server the stage's stack runs on — its hosts' DNS records point at it, and every deploy checks they do\",\n\t\t\tnote: `${SERVER_IPV6_KEY} adds its IPv6 address (AAAA records); neither is ever handed to an app`,\n\t\t\texample: '203.0.113.10',\n\t\t});\n\t}\n\n\tfor (const d of byId(input.credentials)) {\n\t\tadd({\n\t\t\tkey: provideKey(d.id, 'credentials'),\n\t\t\tid: d.id,\n\t\t\tkind: d.kind,\n\t\t\twhat:\n\t\t\t\td.kind === 'external-api'\n\t\t\t\t\t? `the credentials '${d.id}' was issued for this stage, as its schema describes them`\n\t\t\t\t\t: `the credential '${d.id}', as its schema describes it`,\n\t\t\texample: '{\"apiKey\":\"…\"}',\n\t\t\t...apps(d),\n\t\t});\n\t}\n\n\treturn keys;\n}\n\n/**\n * Whether only the stage's secrets can supply `key` to a construct of `kind`\n * — what nothing on the stage derives.\n *\n * A third party's credentials, always. Deployed, also each generated secret\n * and keyring: the stage generated each one once, and every run reads the\n * same value back.\n */\nexport function suppliedOnly(\n\tkind: string,\n\tid: string,\n\tkey: string,\n\tlocal: boolean,\n): boolean {\n\tif (kind === 'credential') return true;\n\tif (kind === 'external-api') return key === provideKey(id, 'credentials');\n\tif (local) return false;\n\treturn kind === 'secret' || kind === 'encryption';\n}\n\n/**\n * Where a deployed stage's mail and storage come from, and what it lacks.\n *\n * - Mail is external once its URL is set, and then needs its sending\n * address too. Unset, it is Mailpit where allowed — the address derived\n * unless set — and missing otherwise.\n * - A bucket is external once its URL is set; its credentials, in the URL or\n * the shared pair, are optional. Unset, it is MinIO where allowed, and\n * missing otherwise.\n * - A file server's URL is derived where its bucket is MinIO, unless set;\n * over an external bucket the stage must set it.\n *\n * The keys themselves are {@link requiredStageKeys}'s.\n */\nexport function externalServices(\n\tinput: ExternalServicesInput,\n): ExternalServices {\n\tconst { supplied, allow } = input;\n\tconst has = (key: string) => supplied[key] !== undefined;\n\n\tconst required = requiredStageKeys({\n\t\tlocal: false,\n\t\tservices: input.declarations,\n\t\t...(input.domain ? { domain: input.domain } : {}),\n\t\t...(input.providers ? { providers: input.providers } : {}),\n\t});\n\n\t// A dev service stands in for each construct the stage does not account\n\t// for: no key in its secrets, and no provider backing its kind.\n\tconst standIn = (k: StageKey) =>\n\t\tallow && k.service !== undefined && !has(k.key);\n\tconst mailpit = required\n\t\t.filter((k) => k.kind === 'email' && k.key === provideKey(k.id, 'url'))\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\tconst minio = required\n\t\t.filter((k) => k.kind === 'bucket')\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\n\tconst covered = (k: StageKey) =>\n\t\t(k.kind === 'email' && mailpit.includes(k.id)) ||\n\t\t(k.kind === 'bucket' && minio.includes(k.id)) ||\n\t\t(k.kind === 'file-server' && k.of !== undefined && minio.includes(k.of));\n\n\tconst missing = required\n\t\t.filter((k) => !has(k.key) && !covered(k))\n\t\t.map(\n\t\t\t({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\tnote,\n\t\t\t\texample,\n\t\t\t\tservice,\n\t\t\t\tapps,\n\t\t\t\thint,\n\t\t\t}): MissingServiceKey => ({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\t...(note ? { note } : {}),\n\t\t\t\texample,\n\t\t\t\t...(service ? { service } : {}),\n\t\t\t\t...(apps ? { apps } : {}),\n\t\t\t\t...(hint ? { hint } : {}),\n\t\t\t}),\n\t\t);\n\n\treturn { missing, minio, mailpit };\n}\n\n/** The dev services a run uses, one entry per service it runs. */\nexport function devServicesUsed(services: ExternalServices): DevServiceUse[] {\n\tconst used: DevServiceUse[] = [];\n\tif (services.mailpit.length > 0) {\n\t\tused.push({ service: 'mailpit', ids: services.mailpit });\n\t}\n\tif (services.minio.length > 0) {\n\t\tused.push({ service: 'minio', ids: services.minio });\n\t}\n\treturn used;\n}\n\n/** The line a run prints for each dev service a deployed stage uses. */\nexport function devServiceWarning(stage: string, use: DevServiceUse): string {\n\tconst what =\n\t\tuse.service === 'mailpit'\n\t\t\t? `Mailpit is catching mail for ${use.ids.join(', ')}. It delivers NO mail: nobody receives a sign-in link, a receipt or a reset`\n\t\t\t: `MinIO is storing ${use.ids.join(', ')}. Every object is on one container's disk, with no replication and no backup`;\n\treturn (\n\t\t`⚠️ DEV SERVICE ON A DEPLOYED STAGE (${stage}): ${what}. It is not ` +\n\t\t`production-grade — set the stage's own keys in its secrets for that.`\n\t);\n}\n\n/**\n * Report each dev service a run uses: a loud line, and a `dev-service.used`\n * event a host can act on.\n */\nexport function reportDevServices(\n\tctx: {\n\t\tstage: string;\n\t\tlogger: { warn(message: string): void };\n\t\temit(event: {\n\t\t\ttype: 'dev-service.used';\n\t\t\tservice: DevService;\n\t\t\tstage: string;\n\t\t\tconstructs: string[];\n\t\t}): void;\n\t},\n\tuses: readonly DevServiceUse[],\n): void {\n\tfor (const use of uses) {\n\t\tctx.logger.warn(`\\n${devServiceWarning(ctx.stage, use)}`);\n\t\tctx.emit({\n\t\t\ttype: 'dev-service.used',\n\t\t\tservice: use.service,\n\t\t\tstage: ctx.stage,\n\t\t\tconstructs: use.ids,\n\t\t});\n\t}\n}\n","/**\n * Providers: what creates the thing a construct is backed by, on a stage.\n *\n * The manifest says a bucket exists (`ObjectStorage`); `deploy.<kind>.<stage>`\n * says what backs it there. A stage that names a provider has gkm *create*\n * the backing resource — when it holds the account's provisioning\n * credentials — and write the connection value into the stage's secrets,\n * where every deploy reads it as if it had been set by hand. A stage that\n * names none is `external`: the value is yours to set, as it always was.\n *\n * | Part | What it is |\n * | ------------------------ | ------------------------------------------------------- |\n * | provisioning credentials | What creates the resource. Never given to an app. |\n * | `ensure()` | Idempotent find-or-create. Records in state. Never deletes. |\n * | runtime credentials | The keys it writes into the stage's secrets. |\n * | `verify()` | The cheap check every deploy runs. |\n *\n * The key under `deploy` is the manifest kind — `objects`, which\n * `ObjectStorage` and `FileServer` produce — so `deploy.cache` and\n * `deploy.email` slot in beside it with providers of their own.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport type { ResourceRecord } from '../deploy/StateStore.js';\nimport type { BoundSubscriber } from '../reconcile/discover.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\n/** The manifest kinds a stage can name a provider for. */\nexport const PROVIDER_KINDS = ['objects', 'inbox'] as const;\n\nexport type ProviderKind = (typeof PROVIDER_KINDS)[number];\n\n/** A provider's own entry: `{ provider: 's3', … }`. */\nexport interface ProviderConfig {\n\tprovider: string;\n}\n\n/**\n * One stage's entry under `deploy.<kind>`:\n *\n * - `'external'` — the default: the stage's secrets hold the key, set by you.\n * - `{ provider, … }` — that provider creates the resource and writes the key.\n * - `false` — the stage has none of this kind; a construct of it is refused.\n */\nexport type StageProviderEntry<C extends ProviderConfig = ProviderConfig> =\n\t| 'external'\n\t| C\n\t| false;\n\n/** One change `ensure()` makes, or — in a dry run — would make. */\nexport interface ProvisionAction {\n\t/** The construct it is for. */\n\tconstruct: string;\n\t/** What it acts on: `bucket acme-shop-prod-uploads`. */\n\tresource: string;\n\t/** What it does: `create`, `set CORS (2 origins)`. */\n\tchange: string;\n}\n\n/** The stage's provisioning record, as `ensure()` reads and writes it. */\nexport interface ProvisionState {\n\t/** A resource recorded by an earlier run. */\n\trecord(key: string): ResourceRecord | undefined;\n\t/** About to be created — written before the call that creates it. */\n\tpending(entry: StateEntry): Promise<void>;\n\t/** Exists, as `id`. */\n\tready(entry: StateEntry, id: string): Promise<void>;\n\t/** When the stage was last deployed, for a rotation to know it was. */\n\treadonly lastDeployedAt?: string;\n}\n\nexport interface StateEntry {\n\t/** `<type>:<name>`, unique within the stage. */\n\tkey: string;\n\ttype: string;\n\tdata?: Record<string, unknown>;\n}\n\n/** What `ensure()` is handed. */\nexport interface EnsureContext<C extends ProviderConfig, K> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Each Worker's subscribers, from discovery — by export and the key its\n\t * deliveries come from. What a provider subscribes on a worker's behalf.\n\t */\n\tsubscribers?: Readonly<Record<string, readonly BoundSubscriber[]>>;\n\tstage: string;\n\tidentity: DeployIdentity;\n\tconfig: C;\n\t/** The provisioning credentials {@link ResourceProvider.credentials} found. */\n\tcredential: K;\n\t/** The stage's secrets as they are now, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\tstate: ProvisionState;\n\tdryRun: boolean;\n\t/** `--rotate-keys`: issue each runtime key a successor. */\n\trotateKeys: boolean;\n\t/** `--retire-old-keys`: delete a rotated-out key without waiting for a deploy. */\n\tretireOldKeys: boolean;\n\t/**\n\t * Runs `apply` and records `action` — or, in a dry run, only records it.\n\t * Every write to the provider's account goes through here.\n\t */\n\tchange(action: ProvisionAction, apply: () => Promise<void>): Promise<void>;\n\t/**\n\t * Writes keys into the stage's secrets now — not at the end of the run, so\n\t * a secret the account shows only once is kept the moment it exists. A dry\n\t * run writes nothing.\n\t */\n\twriteSecrets(values: Record<string, string>): Promise<void>;\n\t/**\n\t * Writes DNS records through the stage's DNS providers (`dns`), as the\n\t * deploy's own DNS step does — what a certificate's validation record and\n\t * a CDN's name, a domain's inbound mail (MX) need. A dry run prints them\n\t * and writes nothing.\n\t */\n\twriteDns(records: readonly ProviderDnsRecord[]): Promise<ProviderDnsResult>;\n\tlog(line: string): void;\n}\n\n/** One record a provider asks the stage's DNS for. */\nexport type ProviderDnsRecord =\n\t| {\n\t\t\t/** The full name: `_abc.files.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'CNAME';\n\t\t\tvalue: string;\n\t }\n\t| {\n\t\t\t/** The full name: `example.com`, `*.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'MX';\n\t\t\t/** The mail server: `inbound-smtp.eu-west-1.amazonaws.com`. */\n\t\t\tvalue: string;\n\t\t\t/** Lower is preferred: `10`. */\n\t\t\tpriority: number;\n\t };\n\n/** What writing a provider's records came to. */\nexport interface ProviderDnsResult {\n\t/**\n\t * Hosts no DNS provider wrote — under no domain in `dns`, or a `manual`\n\t * one — printed for the person to create.\n\t */\n\tmanual: string[];\n}\n\n/** What `verify()` is handed. */\nexport interface VerifyContext<C extends ProviderConfig> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\tstage: string;\n\tconfig: C;\n\t/** The stage's secrets, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\t/**\n\t * What the stage's state records, by key — how a provider knows a key it\n\t * checks was issued moments ago. Absent when nothing was read.\n\t */\n\tresources?: Readonly<Record<string, ResourceRecord>>;\n\t/** Progress worth printing: waiting on something. */\n\tlog?: (line: string) => void;\n}\n\n/** Where a provider's provisioning credentials are looked for. */\nexport interface CredentialLookup {\n\tstage: string;\n\t/** `--profile`, when given. */\n\tprofile?: string;\n\tenv: NodeJS.ProcessEnv;\n\t/** The CLI's home, for stored logins. */\n\thome?: string;\n}\n\n/**\n * A provider. `C` is its config entry, `K` its provisioning credential.\n *\n * Built-ins are registered in `providers/registry.ts`, the way a deploy\n * target's built-ins are.\n */\nexport interface ResourceProvider<\n\tC extends ProviderConfig = ProviderConfig,\n\tK = unknown,\n> {\n\treadonly kind: ProviderKind;\n\t/** What `provider:` names it. */\n\treadonly name: string;\n\t/**\n\t * Its config entry checked: returns it, or throws a named error saying\n\t * what is wrong — what the workspace schema runs.\n\t */\n\tcheck(stage: string, config: ProviderConfig): C;\n\t/** How its provisioning credentials are supplied, for messages. */\n\treadonly provisioning: {\n\t\t/** The environment variables it reads. */\n\t\tenv: readonly string[];\n\t\t/** A `gkm login --provider` name, where it has one. */\n\t\tlogin?: string;\n\t\t/** One line saying how to supply them. */\n\t\tdescribe: string;\n\t};\n\t/** Its provisioning credentials, or `undefined` when there are none. */\n\tcredentials(lookup: CredentialLookup): Promise<K | undefined>;\n\t/** The keys it writes into the stage's secrets for these constructs. */\n\truntimeKeys(manifest: ConstructManifest): string[];\n\tensure(ctx: EnsureContext<C, K>): Promise<void>;\n\tverify(ctx: VerifyContext<C>): Promise<void>;\n}\n","/**\n * What a deploy's checks read off `deploy.<kind>.<stage>`, without loading a\n * provider: which kinds the stage accounts for, what creates a missing key,\n * and a kind the stage has none of.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { StageProviderNotes } from '../deploy/devServices.js';\nimport { GkmError } from '../errors';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { provisioningOf, stageProvider } from './config.js';\nimport { PROVIDER_KINDS, type ProviderKind } from './types.js';\n\n/** The constructs of a kind: `objects` is every bucket. */\nexport function constructsOf(manifest: ConstructManifest, kind: ProviderKind) {\n\treturn Object.entries(manifest)\n\t\t.filter(([, d]) => d.kind === kind)\n\t\t.map(([id]) => id)\n\t\t.sort();\n}\n\n/** A stage that names `false` for a kind, and declares constructs of it. */\nexport class StageProviderDisabled extends GkmError {\n\tconstructor(\n\t\treadonly kind: ProviderKind,\n\t\treadonly stage: string,\n\t\treadonly ids: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`deploy.${kind}.${stage} is false — the stage has no ${kind} — and ` +\n\t\t\t\t`${ids.join(', ')} ${ids.length === 1 ? 'is' : 'are'} declared. ` +\n\t\t\t\t`Name what backs ${ids.length === 1 ? 'it' : 'them'} on '${stage}' ` +\n\t\t\t\t`(deploy.${kind}.${stage}: 'external', or a provider), or remove ` +\n\t\t\t\t`the ${ids.length === 1 ? 'construct' : 'constructs'}.`,\n\t\t);\n\t\tthis.name = 'StageProviderDisabled';\n\t}\n}\n\n/** The command a stage's providers are run with: every deploy runs them. */\nexport function provisionCommand(stage: string): string {\n\treturn `gkm deploy --stage ${stage}`;\n}\n\n/**\n * The line a stage missing a key a provider would write is given: what\n * creates it, and with which credentials. Undefined when no provider backs\n * the kind on the stage.\n */\nexport function provisionHint(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tkind: ProviderKind,\n\tstage: string,\n): string | undefined {\n\tconst choice = stageProvider(workspace as never, kind, stage);\n\tif (choice.mode !== 'provider') return undefined;\n\tconst provisioning = provisioningOf(kind, choice.name);\n\tif (!provisioning) return undefined;\n\treturn (\n\t\t`deploy.${kind}.${stage} is ${choice.name}: the deploy ` +\n\t\t`(${provisionCommand(stage)}) creates it and writes this key, with ` +\n\t\t`${provisioning.describe}` +\n\t\t(provisioning.login\n\t\t\t? `, or gkm login --provider ${provisioning.login}`\n\t\t\t: '')\n\t);\n}\n\n/**\n * What a deploy's checks read off the stage's providers: whether each kind is\n * accounted for — a provider, or `false` — so no dev service stands in for\n * it, and what creates a missing key of it.\n */\nexport function stageProviderNotes(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tstage: string,\n): StageProviderNotes {\n\tconst choice = stageProvider(workspace as never, 'objects', stage);\n\tif (choice.mode === 'external') return {};\n\tconst hint = provisionHint(workspace, 'objects', stage);\n\treturn { objects: { accounted: true, ...(hint ? { hint } : {}) } };\n}\n\n/**\n * A kind the stage set to `false`, declared anyway — refused before anything\n * else is checked. Pure: what a stack is composed from.\n *\n * @throws {StageProviderDisabled}\n */\nexport function assertStageProvidersEnabled(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tmanifest: ConstructManifest,\n\tstage: string,\n): void {\n\tfor (const kind of PROVIDER_KINDS) {\n\t\tconst ids = constructsOf(manifest, kind);\n\t\tif (ids.length === 0) continue;\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'none') {\n\t\t\tthrow new StageProviderDisabled(kind, stage, ids);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,eAAe,CAAC,SAAS,SAAS;;;;;;;AAU/C,MAAa,mBAAmB,CAC/B,qBACA,uBACD;;AAGA,IAAa,8BAAb,cAAiD,SAAS;CACpC;CAArB,YAAY,QAAyB;EACpC,MACC,6DAA6D,OAAO,+FAGrE;EALoB,KAAA,SAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;;AAOA,IAAa,+BAAb,cAAkD,SAAS;CACrC;CAArB,YAAY,OAAwB;EACnC,MACC,sDAAsD,MAAM,wNAI7D;EANoB,KAAA,QAAA;EAOpB,KAAK,OAAO;CACb;AACD;;;;;;;;;AAUA,SAAgB,sBAAsB,MAA+B;CACpE,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,MAAM,KAAK;EACjB,IAAI,IAAI,WAAW,uBAAuB,GACzC,MAAM,IAAI,6BAA6B,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC;EAEvE,MAAM,OAAO,KAAK,IAAI;EACtB,IAAI,QAAQ,0BAA0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AO,IAAI;CACrD,IAAI,CAAC,cAAc,OAAO,KAAA;CAC1B,OACC,UAAU,KAAK,GAAG,MAAM,MAAM,OAAO,KAAK,gBACtC,iBAAiB,KAAK,EAAE,yCACzB,aAAa,cACf,aAAa,QACX,6BAA6B,aAAa,UAC1C;AAEL;;;;;;AAOA,SAAgB,mBACf,WACA,OACqB;CAErB,IADe,cAAc,WAAoB,WAAW,KACnD,CAAC,CAAC,SAAS,YAAY,OAAO,CAAC;CACxC,MAAM,OAAO,cAAc,WAAW,WAAW,KAAK;CACtD,OAAO,EAAE,SAAS;EAAE,WAAW;EAAM,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;CAAG,EAAE;AAClE;;;;;;;AAQA,SAAgB,4BACf,WACA,UACA,OACO;CACP,KAAK,MAAM,QAAQ,gBAAgB;EAClC,MAAM,MAAM,aAAa,UAAU,IAAI;EACvC,IAAI,IAAI,WAAW,GAAG;EACtB,IAAI,cAAc,WAAoB,MAAM,KAAK,CAAC,CAAC,SAAS,QAC3D,MAAM,IAAI,sBAAsB,MAAM,OAAO,GAAG;CAElD;AACD"}
1
+ {"version":3,"file":"notes-DdNcS5q5.mjs","names":[],"sources":["../src/deploy/devServices.ts","../src/providers/types.ts","../src/providers/notes.ts"],"sourcesContent":["/**\n * Mail and object storage on a deployed stage: real ones, or — only when\n * someone asked — the dev services the local stage runs.\n *\n * Locally a declared `Email` is Mailpit and a declared bucket is MinIO, and\n * nobody has to configure either. Deployed, the same two containers would be\n * a stage that silently delivers no mail and keeps its files on one\n * container's disk. So a deployed stage on a server target takes both from\n * its secrets — the mail server's URL and sending address, and each bucket's\n * URL — and a stage missing any of them fails before anything is built,\n * provisioned or written, naming every key at once.\n *\n * A bucket's credentials are not checked: they are optional, and come from\n * either of two places. The bucket's URL may carry a key of its own\n * (`s3://KEY:SECRET@uploads`), which wins; otherwise the S3 client's default\n * chain applies — the stage's shared `AWS_ACCESS_KEY_ID`/\n * `AWS_SECRET_ACCESS_KEY` when it set them, or a role.\n *\n * `--allow-dev-services` is the way out for a stage that is not production —\n * a preview, a demo: every construct the stage does not account for gets the\n * dev service the local stage runs for it — a bucket MinIO, mail Mailpit —\n * and the target derives the keys from it. What the stage does account for\n * still wins: a key set in its secrets, or a provider (`deploy.objects`)\n * that backs the kind. Every run that uses one says so, loudly.\n *\n * Pure: what each target runs is decided here from declarations and the\n * stage's values, and the targets do the running.\n */\n\nimport {\n\ttype ConstructManifest,\n\tprovideKey,\n\tpublicEnvFor,\n} from '@geekmidas/manifest';\nimport { SERVER_IPV4_KEY, SERVER_IPV6_KEY } from '../compose/dnsConfig.js';\nimport { GkmError } from '../errors';\nimport { appEnvKeys, workerEnvKeys } from '../reconcile/apps.js';\nimport { appKey } from '../workspace/derive.js';\n\n/**\n * The dev services a deployed stage can run — one per kind that has one on\n * every server target: a bucket's MinIO and mail's Mailpit. A cache or a\n * database is not here because a server stage runs its own anyway.\n */\nexport const DEV_SERVICES = ['minio', 'mailpit'] as const;\n\nexport type DevService = (typeof DEV_SERVICES)[number];\n\n/**\n * The S3 client's shared key pair. Optional: a bucket whose URL carries its own\n * key (`s3://KEY:SECRET@bucket`) signs with that, and one without signs with\n * this pair when the stage set it, or with whatever else the SDK's default\n * chain finds — a role.\n */\nexport const STORAGE_KEY_PAIR = [\n\t'AWS_ACCESS_KEY_ID',\n\t'AWS_SECRET_ACCESS_KEY',\n] as const;\n\n/** Dev services asked of a target that runs no containers. */\nexport class DevServicesNeedServerTarget extends GkmError {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services applies to server targets only, and '${target}' ` +\n\t\t\t\t`deploys to AWS, where a bucket is S3 and mail is the stage's own. ` +\n\t\t\t\t'Drop --allow-dev-services.',\n\t\t);\n\t\tthis.name = 'DevServicesNeedServerTarget';\n\t}\n}\n\n/**\n * `--allow-dev-services` given a value — the list it used to take. It is a\n * switch now: every construct the stage does not account for gets its dev\n * service.\n */\nexport class AllowDevServicesTakesNoValue extends GkmError {\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`--allow-dev-services takes no value (it was given '${value}'). It runs ` +\n\t\t\t\t'the dev service for every bucket and mail the stage does not account ' +\n\t\t\t\t'for — no key in its secrets, no provider in deploy.<kind>.<stage> — so ' +\n\t\t\t\t'there is nothing to list. Pass --allow-dev-services on its own.',\n\t\t);\n\t\tthis.name = 'AllowDevServicesTakesNoValue';\n\t}\n}\n\n/**\n * Refuses `--allow-dev-services <value>` and `--allow-dev-services=<value>` on\n * a command line, with the reason, before the parser calls the value an\n * excess argument. `gkm deploy` and `gkm compose` take no positional\n * argument, so whatever follows the flag and is not a flag was meant for it.\n *\n * @throws {AllowDevServicesTakesNoValue}\n */\nexport function assertDevServicesFlag(argv: readonly string[]): void {\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i]!;\n\t\tif (arg.startsWith('--allow-dev-services=')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(arg.slice(arg.indexOf('=') + 1));\n\t\t}\n\t\tconst next = argv[i + 1];\n\t\tif (arg === '--allow-dev-services' && next && !next.startsWith('-')) {\n\t\t\tthrow new AllowDevServicesTakesNoValue(next);\n\t\t}\n\t}\n}\n\n/** One key a deployed stage needs and its secrets do not hold. */\nexport interface MissingServiceKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, unless the stage accounts for it. */\n\tservice?: DevService;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n}\n\n/**\n * A deployed stage with mail or object storage that its secrets do not\n * configure — every missing key, across every app, at once.\n */\nexport class ExternalServicesNotConfigured extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly missing: readonly MissingServiceKey[],\n\t) {\n\t\tconst standIns = missing.some((m) => m.service !== undefined);\n\t\tconst lines = missing.map((m) => {\n\t\t\tconst by = m.apps?.length ? `, read by ${m.apps.join(', ')}` : '';\n\t\t\treturn (\n\t\t\t\t` gkm secrets:set ${m.key} '${m.example}' --stage ${stage}\\n` +\n\t\t\t\t` ${m.what}${by}` +\n\t\t\t\t(m.note ? `\\n ${m.note}` : '') +\n\t\t\t\t(m.hint ? `\\n ${m.hint}` : '')\n\t\t\t);\n\t\t});\n\t\tsuper(\n\t\t\t`The stage '${stage}' is deployed, and a deployed stage's mail and ` +\n\t\t\t\t`object storage are real services: gkm runs no Mailpit or MinIO for ` +\n\t\t\t\t`it. Set ${missing.length === 1 ? 'this key' : `these ${missing.length} keys`} in the stage's secrets:\\n\\n` +\n\t\t\t\t`${lines.join('\\n')}\\n\\n` +\n\t\t\t\t(standIns\n\t\t\t\t\t? `For a stage that is not production — a preview, a demo — the ` +\n\t\t\t\t\t\t`dev services can run instead, with --allow-dev-services. ` +\n\t\t\t\t\t\t`Mailpit delivers no mail, and MinIO keeps every object on one ` +\n\t\t\t\t\t\t`container's disk.\\n\\n`\n\t\t\t\t\t: '') +\n\t\t\t\t`Or run: gkm secrets:add --stage ${stage}`,\n\t\t);\n\t\tthis.name = 'ExternalServicesNotConfigured';\n\t}\n}\n\n/** A declaration that is mail or object storage. */\nexport interface ServiceDeclaration {\n\tid: string;\n\tkind: 'email' | 'objects' | 'file-server';\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** The kinds a deployed stage takes from its secrets, or a dev service. */\nconst SERVICE_KINDS: Readonly<Record<string, ServiceDeclaration['kind']>> = {\n\temail: 'email',\n\tobjects: 'objects',\n\t'file-server': 'file-server',\n};\n\nexport interface StageServiceDeclarationsInput {\n\tmanifest: ConstructManifest;\n}\n\n/**\n * Every mail and storage construct a manifest declares, each with the apps\n * and workers that read it — a process's environment, a site's build args. A\n * file server's reader reads its bucket too.\n *\n * The one list a deploy's readiness check refuses a stage by, every server\n * target decides its dev services from, and `gkm secrets:add` offers — so\n * none of them can disagree.\n */\nexport function stageServiceDeclarations(\n\tinput: StageServiceDeclarationsInput,\n): ServiceDeclaration[] {\n\tconst { manifest } = input;\n\n\t// The construct each key belongs to.\n\tconst owners = new Map<string, string>();\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tif (!SERVICE_KINDS[declaration.kind]) continue;\n\t\towners.set(provideKey(id, 'url'), id);\n\t\tif (declaration.kind === 'email') owners.set(provideKey(id, 'from'), id);\n\t}\n\n\t// Who reads which construct.\n\tconst readers = new Map<string, Set<string>>();\n\tconst read = (process: string, keys: Iterable<string>) => {\n\t\tfor (const key of keys) {\n\t\t\tconst id = owners.get(key);\n\t\t\tif (!id) continue;\n\t\t\tconst declaration = manifest[id];\n\t\t\tconst of =\n\t\t\t\tdeclaration?.kind === 'file-server' ? declaration.of : undefined;\n\t\t\tfor (const owner of of ? [id, of] : [id]) {\n\t\t\t\tconst set = readers.get(owner) ?? new Set<string>();\n\t\t\t\tset.add(process);\n\t\t\t\treaders.set(owner, set);\n\t\t\t}\n\t\t}\n\t};\n\tfor (const [id, declaration] of Object.entries(manifest)) {\n\t\tconst name = appKey(id);\n\t\tif (\n\t\t\tdeclaration.kind === 'rest-api' ||\n\t\t\tdeclaration.kind === 'websocket-api' ||\n\t\t\tdeclaration.kind === 'site' ||\n\t\t\tdeclaration.kind === 'mobile-app'\n\t\t) {\n\t\t\tread(name, appEnvKeys(manifest, name) ?? []);\n\t\t}\n\t\t// A site's build args, by the keys they rename.\n\t\tif (declaration.kind === 'site') {\n\t\t\tread(name, Object.values(publicEnvFor(declaration, manifest)));\n\t\t}\n\t\tif (declaration.kind === 'worker') {\n\t\t\tread(name, workerEnvKeys(manifest, id) ?? []);\n\t\t}\n\t}\n\n\treturn Object.entries(manifest).flatMap(\n\t\t([id, declaration]): ServiceDeclaration[] => {\n\t\t\tconst kind = SERVICE_KINDS[declaration.kind];\n\t\t\tif (!kind) return [];\n\t\t\tconst apps = [...(readers.get(id) ?? [])].sort();\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid,\n\t\t\t\t\tkind,\n\t\t\t\t\t...(declaration.kind === 'file-server' && declaration.of\n\t\t\t\t\t\t? { of: declaration.of }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(apps.length ? { apps } : {}),\n\t\t\t\t},\n\t\t\t];\n\t\t},\n\t);\n}\n\nexport interface ExternalServicesInput {\n\tstage: string;\n\t/** Every mail and storage construct something on the stage reads. */\n\tdeclarations: readonly ServiceDeclaration[];\n\t/** The stage's values by key — what `gkm secrets:set` stored. */\n\tsupplied: Readonly<Record<string, string>>;\n\t/**\n\t * `--allow-dev-services`: every construct the stage does not account for\n\t * gets its dev service.\n\t */\n\tallow: boolean;\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/**\n\t * What the stage's providers say, by kind: a kind one backs is accounted\n\t * for, so no dev service stands in for it, and a missing key of it names\n\t * what creates it.\n\t */\n\tproviders?: StageProviderNotes;\n}\n\n/** The stage's providers, as a deploy's checks read them. */\nexport interface StageProviderNotes {\n\tobjects?: {\n\t\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\t\taccounted: boolean;\n\t\t/** What creates a missing key of it. */\n\t\thint?: string;\n\t};\n}\n\n/** Where a deployed stage's mail and storage come from. */\nexport interface ExternalServices {\n\t/** Keys the stage needs and has not set. Empty when it can deploy. */\n\tmissing: MissingServiceKey[];\n\t/** The buckets the target runs MinIO for. */\n\tminio: string[];\n\t/** The mail constructs the target runs Mailpit for. */\n\tmailpit: string[];\n}\n\n/** One dev service a run uses, and for which constructs. */\nexport interface DevServiceUse {\n\tservice: DevService;\n\tids: string[];\n}\n\n/** A third party's credentials a construct reads: an external API's, or a `Credential`. */\nexport interface CredentialDeclaration {\n\tid: string;\n\tkind: 'external-api' | 'credential';\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\n/** What a stage-supplied key belongs to. */\nexport type StageKeyKind =\n\t| 'bucket'\n\t| 'email'\n\t| 'file-server'\n\t| 'external-api'\n\t| 'credential'\n\t/** The server a compose stage's stack runs on: `GKM_SERVER_IPV4`. */\n\t| 'server';\n\n/**\n * One key only the stage's secrets can hold — nothing derives it — whether\n * or not it is set.\n */\nexport interface StageKey {\n\tkey: string;\n\t/** The construct that reads it. */\n\tid: string;\n\tkind: StageKeyKind;\n\t/** What it is, for the line that names it. */\n\twhat: string;\n\t/** A line after `what`, for what else there is to know about it. */\n\tnote?: string;\n\t/** A placeholder value to show in the `gkm secrets:set` line. */\n\texample: string;\n\t/** The dev service that would stand in for it, where one can. */\n\tservice?: DevService;\n\t/** What creates it, where a provider backs it on the stage. */\n\thint?: string;\n\t/** A file server's bucket. */\n\tof?: string;\n\t/** The apps that read it, where known. */\n\tapps?: readonly string[];\n}\n\nexport interface StageKeysInput {\n\t/** Whether the stage is the local one, which derives its mail and storage. */\n\tlocal: boolean;\n\t/** Every mail and storage construct something on the stage reads. */\n\tservices?: readonly ServiceDeclaration[];\n\t/** Every third party's credentials something on the stage reads. */\n\tcredentials?: readonly CredentialDeclaration[];\n\t/** The stage's base domain, for the examples. */\n\tdomain?: string;\n\t/** What the stage's providers say — see {@link StageProviderNotes}. */\n\tproviders?: StageProviderNotes;\n\t/**\n\t * The stage serves a domain from a server of its own — a compose stage —\n\t * so its secrets hold the server's address, `GKM_SERVER_IPV4`.\n\t */\n\tserver?: boolean;\n}\n\n/**\n * Every key a stage must be given rather than derive — the one list both a\n * deploy's checks and `gkm secrets:add` read, so what a deploy refuses and\n * what the builder offers cannot drift.\n *\n * - Deployed, mail is its URL and its sending address, a bucket its URL, and\n * a file server its public URL. Locally all of it is Mailpit and MinIO.\n * - On every stage, a third party's credentials: nobody but the third party\n * can issue them.\n *\n * Never a derived value: a database URL, a generated secret, the seed.\n */\nexport function requiredStageKeys(input: StageKeysInput): StageKey[] {\n\tconst domain = input.domain ?? 'example.com';\n\tconst keys: StageKey[] = [];\n\tconst add = (entry: StageKey) => {\n\t\tif (!keys.some((k) => k.key === entry.key)) keys.push(entry);\n\t};\n\tconst byId = <T extends { id: string }>(list: readonly T[] | undefined) =>\n\t\t[...(list ?? [])].sort((a, b) => a.id.localeCompare(b.id));\n\tconst apps = (d: { apps?: readonly string[] }) =>\n\t\td.apps?.length ? { apps: [...d.apps].sort() } : {};\n\n\tif (!input.local) {\n\t\tconst services = byId(input.services);\n\t\t// A kind a provider backs on the stage has no dev service, and a key of\n\t\t// it names what creates it.\n\t\tconst objects = input.providers?.objects;\n\t\tconst storage = objects?.accounted\n\t\t\t? objects.hint\n\t\t\t\t? { hint: objects.hint }\n\t\t\t\t: {}\n\t\t\t: { service: 'minio' as const };\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `where '${d.id}' sends mail — any SMTP server`,\n\t\t\t\texample: `smtp://user:password@smtp.${domain}:587`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'from'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'email',\n\t\t\t\twhat: `the address '${d.id}' sends from, on a domain the mail server has verified`,\n\t\t\t\texample: `noreply@${domain}`,\n\t\t\t\tservice: 'mailpit',\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'objects')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'bucket',\n\t\t\t\twhat: `the bucket '${d.id}' — S3, R2, or any S3-compatible store (add &endpoint=… for one that is not S3)`,\n\t\t\t\tnote: `credentials are optional: a key for this bucket alone in the URL (s3://KEY:SECRET@${appKey(d.id)}?…) wins; without one, the shared AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or a role signs`,\n\t\t\t\texample: `s3://${appKey(d.id)}?region=eu-west-1`,\n\t\t\t\t...storage,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t\tfor (const d of services.filter((d) => d.kind === 'file-server')) {\n\t\t\tadd({\n\t\t\t\tkey: provideKey(d.id, 'url'),\n\t\t\t\tid: d.id,\n\t\t\t\tkind: 'file-server',\n\t\t\t\twhat: `the public address '${d.id}' serves its bucket on — a CDN or the bucket's own domain`,\n\t\t\t\texample: `https://${appKey(d.id)}.${domain}`,\n\t\t\t\t...storage,\n\t\t\t\t...(d.of ? { of: d.of } : {}),\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t}\n\t}\n\n\tif (!input.local && input.server) {\n\t\tadd({\n\t\t\tkey: SERVER_IPV4_KEY,\n\t\t\tid: 'server',\n\t\t\tkind: 'server',\n\t\t\twhat: \"the public IPv4 address of the server the stage's stack runs on — its hosts' DNS records point at it, and every deploy checks they do\",\n\t\t\tnote: `${SERVER_IPV6_KEY} adds its IPv6 address (AAAA records); neither is ever handed to an app`,\n\t\t\texample: '203.0.113.10',\n\t\t});\n\t}\n\n\tfor (const d of byId(input.credentials)) {\n\t\tadd({\n\t\t\tkey: provideKey(d.id, 'credentials'),\n\t\t\tid: d.id,\n\t\t\tkind: d.kind,\n\t\t\twhat:\n\t\t\t\td.kind === 'external-api'\n\t\t\t\t\t? `the credentials '${d.id}' was issued for this stage, as its schema describes them`\n\t\t\t\t\t: `the credential '${d.id}', as its schema describes it`,\n\t\t\texample: '{\"apiKey\":\"…\"}',\n\t\t\t...apps(d),\n\t\t});\n\t}\n\n\treturn keys;\n}\n\n/**\n * Whether only the stage's secrets can supply `key` to a construct of `kind`\n * — what nothing on the stage derives.\n *\n * A third party's credentials, always. Deployed, also each generated secret\n * and keyring: the stage generated each one once, and every run reads the\n * same value back.\n */\nexport function suppliedOnly(\n\tkind: string,\n\tid: string,\n\tkey: string,\n\tlocal: boolean,\n): boolean {\n\tif (kind === 'credential') return true;\n\tif (kind === 'external-api') return key === provideKey(id, 'credentials');\n\tif (local) return false;\n\treturn kind === 'secret' || kind === 'encryption';\n}\n\n/**\n * Where a deployed stage's mail and storage come from, and what it lacks.\n *\n * - Mail is external once its URL is set, and then needs its sending\n * address too. Unset, it is Mailpit where allowed — the address derived\n * unless set — and missing otherwise.\n * - A bucket is external once its URL is set; its credentials, in the URL or\n * the shared pair, are optional. Unset, it is MinIO where allowed, and\n * missing otherwise.\n * - A file server's URL is derived where its bucket is MinIO, unless set;\n * over an external bucket the stage must set it.\n *\n * The keys themselves are {@link requiredStageKeys}'s.\n */\nexport function externalServices(\n\tinput: ExternalServicesInput,\n): ExternalServices {\n\tconst { supplied, allow } = input;\n\tconst has = (key: string) => supplied[key] !== undefined;\n\n\tconst required = requiredStageKeys({\n\t\tlocal: false,\n\t\tservices: input.declarations,\n\t\t...(input.domain ? { domain: input.domain } : {}),\n\t\t...(input.providers ? { providers: input.providers } : {}),\n\t});\n\n\t// A dev service stands in for each construct the stage does not account\n\t// for: no key in its secrets, and no provider backing its kind.\n\tconst standIn = (k: StageKey) =>\n\t\tallow && k.service !== undefined && !has(k.key);\n\tconst mailpit = required\n\t\t.filter((k) => k.kind === 'email' && k.key === provideKey(k.id, 'url'))\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\tconst minio = required\n\t\t.filter((k) => k.kind === 'bucket')\n\t\t.filter(standIn)\n\t\t.map((k) => k.id);\n\n\tconst covered = (k: StageKey) =>\n\t\t(k.kind === 'email' && mailpit.includes(k.id)) ||\n\t\t(k.kind === 'bucket' && minio.includes(k.id)) ||\n\t\t(k.kind === 'file-server' && k.of !== undefined && minio.includes(k.of));\n\n\tconst missing = required\n\t\t.filter((k) => !has(k.key) && !covered(k))\n\t\t.map(\n\t\t\t({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\tnote,\n\t\t\t\texample,\n\t\t\t\tservice,\n\t\t\t\tapps,\n\t\t\t\thint,\n\t\t\t}): MissingServiceKey => ({\n\t\t\t\tkey,\n\t\t\t\tid,\n\t\t\t\twhat,\n\t\t\t\t...(note ? { note } : {}),\n\t\t\t\texample,\n\t\t\t\t...(service ? { service } : {}),\n\t\t\t\t...(apps ? { apps } : {}),\n\t\t\t\t...(hint ? { hint } : {}),\n\t\t\t}),\n\t\t);\n\n\treturn { missing, minio, mailpit };\n}\n\n/** The dev services a run uses, one entry per service it runs. */\nexport function devServicesUsed(services: ExternalServices): DevServiceUse[] {\n\tconst used: DevServiceUse[] = [];\n\tif (services.mailpit.length > 0) {\n\t\tused.push({ service: 'mailpit', ids: services.mailpit });\n\t}\n\tif (services.minio.length > 0) {\n\t\tused.push({ service: 'minio', ids: services.minio });\n\t}\n\treturn used;\n}\n\n/** The line a run prints for each dev service a deployed stage uses. */\nexport function devServiceWarning(stage: string, use: DevServiceUse): string {\n\tconst what =\n\t\tuse.service === 'mailpit'\n\t\t\t? `Mailpit is catching mail for ${use.ids.join(', ')}. It delivers NO mail: nobody receives a sign-in link, a receipt or a reset`\n\t\t\t: `MinIO is storing ${use.ids.join(', ')}. Every object is on one container's disk, with no replication and no backup`;\n\treturn (\n\t\t`⚠️ DEV SERVICE ON A DEPLOYED STAGE (${stage}): ${what}. It is not ` +\n\t\t`production-grade — set the stage's own keys in its secrets for that.`\n\t);\n}\n\n/**\n * Report each dev service a run uses: a loud line, and a `dev-service.used`\n * event a host can act on.\n */\nexport function reportDevServices(\n\tctx: {\n\t\tstage: string;\n\t\tlogger: { warn(message: string): void };\n\t\temit(event: {\n\t\t\ttype: 'dev-service.used';\n\t\t\tservice: DevService;\n\t\t\tstage: string;\n\t\t\tconstructs: string[];\n\t\t}): void;\n\t},\n\tuses: readonly DevServiceUse[],\n): void {\n\tfor (const use of uses) {\n\t\tctx.logger.warn(`\\n${devServiceWarning(ctx.stage, use)}`);\n\t\tctx.emit({\n\t\t\ttype: 'dev-service.used',\n\t\t\tservice: use.service,\n\t\t\tstage: ctx.stage,\n\t\t\tconstructs: use.ids,\n\t\t});\n\t}\n}\n","/**\n * Providers: what creates the thing a construct is backed by, on a stage.\n *\n * The manifest says a bucket exists (`ObjectStorage`); `deploy.<kind>.<stage>`\n * says what backs it there. A stage that names a provider has gkm *create*\n * the backing resource — when it holds the account's provisioning\n * credentials — and write the connection value into the stage's secrets,\n * where every deploy reads it as if it had been set by hand. A stage that\n * names none is `external`: the value is yours to set, as it always was.\n *\n * | Part | What it is |\n * | ------------------------ | ------------------------------------------------------- |\n * | provisioning credentials | What creates the resource. Never given to an app. |\n * | `ensure()` | Idempotent find-or-create. Records in state. Never deletes. |\n * | runtime credentials | The keys it writes into the stage's secrets. |\n * | `verify()` | The cheap check every deploy runs. |\n *\n * The key under `deploy` is the manifest kind — `objects`, which\n * `ObjectStorage` and `FileServer` produce — so `deploy.cache` and\n * `deploy.email` slot in beside it with providers of their own.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { DeployIdentity } from '../deploy/identity.js';\nimport type { ResourceRecord } from '../deploy/StateStore.js';\nimport type { BoundSubscriber } from '../reconcile/discover.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\n\n/** The manifest kinds a stage can name a provider for. */\nexport const PROVIDER_KINDS = ['objects', 'inbox'] as const;\n\nexport type ProviderKind = (typeof PROVIDER_KINDS)[number];\n\n/** A provider's own entry: `{ provider: 's3', … }`. */\nexport interface ProviderConfig {\n\tprovider: string;\n}\n\n/**\n * One stage's entry under `deploy.<kind>`:\n *\n * - `'external'` — the default: the stage's secrets hold the key, set by you.\n * - `{ provider, … }` — that provider creates the resource and writes the key.\n * - `false` — the stage has none of this kind; a construct of it is refused.\n */\nexport type StageProviderEntry<C extends ProviderConfig = ProviderConfig> =\n\t| 'external'\n\t| C\n\t| false;\n\n/** One change `ensure()` makes, or — in a dry run — would make. */\nexport interface ProvisionAction {\n\t/** The construct it is for. */\n\tconstruct: string;\n\t/** What it acts on: `bucket acme-shop-prod-uploads`. */\n\tresource: string;\n\t/** What it does: `create`, `set CORS (2 origins)`. */\n\tchange: string;\n}\n\n/** The stage's provisioning record, as `ensure()` reads and writes it. */\nexport interface ProvisionState {\n\t/** A resource recorded by an earlier run. */\n\trecord(key: string): ResourceRecord | undefined;\n\t/** About to be created — written before the call that creates it. */\n\tpending(entry: StateEntry): Promise<void>;\n\t/** Exists, as `id`. */\n\tready(entry: StateEntry, id: string): Promise<void>;\n\t/** When the stage was last deployed, for a rotation to know it was. */\n\treadonly lastDeployedAt?: string;\n}\n\nexport interface StateEntry {\n\t/** `<type>:<name>`, unique within the stage. */\n\tkey: string;\n\ttype: string;\n\tdata?: Record<string, unknown>;\n}\n\n/** What `ensure()` is handed. */\nexport interface EnsureContext<C extends ProviderConfig, K> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Each Worker's subscribers, from discovery — by export and the key its\n\t * deliveries come from. What a provider subscribes on a worker's behalf.\n\t */\n\tsubscribers?: Readonly<Record<string, readonly BoundSubscriber[]>>;\n\tstage: string;\n\tidentity: DeployIdentity;\n\tconfig: C;\n\t/** The provisioning credentials {@link ResourceProvider.credentials} found. */\n\tcredential: K;\n\t/** The stage's secrets as they are now, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\tstate: ProvisionState;\n\tdryRun: boolean;\n\t/** `--rotate-keys`: issue each runtime key a successor. */\n\trotateKeys: boolean;\n\t/** `--retire-old-keys`: delete a rotated-out key without waiting for a deploy. */\n\tretireOldKeys: boolean;\n\t/**\n\t * Runs `apply` and records `action` — or, in a dry run, only records it.\n\t * Every write to the provider's account goes through here.\n\t */\n\tchange(action: ProvisionAction, apply: () => Promise<void>): Promise<void>;\n\t/**\n\t * Writes keys into the stage's secrets now — not at the end of the run, so\n\t * a secret the account shows only once is kept the moment it exists. A dry\n\t * run writes nothing.\n\t */\n\twriteSecrets(values: Record<string, string>): Promise<void>;\n\t/**\n\t * Writes DNS records through the stage's DNS providers (`dns`), as the\n\t * deploy's own DNS step does — what a certificate's validation record and\n\t * a CDN's name, a domain's inbound mail (MX) need. A dry run prints them\n\t * and writes nothing.\n\t */\n\twriteDns(records: readonly ProviderDnsRecord[]): Promise<ProviderDnsResult>;\n\tlog(line: string): void;\n}\n\n/** One record a provider asks the stage's DNS for. */\nexport type ProviderDnsRecord =\n\t| {\n\t\t\t/** The full name: `_abc.files.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'CNAME';\n\t\t\tvalue: string;\n\t }\n\t| {\n\t\t\t/** The full name: `example.com`, `*.example.com`. */\n\t\t\thost: string;\n\t\t\ttype: 'MX';\n\t\t\t/** The mail server: `inbound-smtp.eu-west-1.amazonaws.com`. */\n\t\t\tvalue: string;\n\t\t\t/** Lower is preferred: `10`. */\n\t\t\tpriority: number;\n\t };\n\n/** What writing a provider's records came to. */\nexport interface ProviderDnsResult {\n\t/**\n\t * Hosts no DNS provider wrote — under no domain in `dns`, or a `manual`\n\t * one — printed for the person to create.\n\t */\n\tmanual: string[];\n}\n\n/** What `verify()` is handed. */\nexport interface VerifyContext<C extends ProviderConfig> {\n\tworkspace: NormalizedWorkspace;\n\tmanifest: ConstructManifest;\n\tstage: string;\n\tconfig: C;\n\t/** The stage's secrets, by key. */\n\tsecrets: Readonly<Record<string, string>>;\n\t/**\n\t * What the stage's state records, by key — how a provider knows a key it\n\t * checks was issued moments ago. Absent when nothing was read.\n\t */\n\tresources?: Readonly<Record<string, ResourceRecord>>;\n\t/** Progress worth printing: waiting on something. */\n\tlog?: (line: string) => void;\n}\n\n/** Where a provider's provisioning credentials are looked for. */\nexport interface CredentialLookup {\n\tstage: string;\n\t/** `--profile`, when given. */\n\tprofile?: string;\n\tenv: NodeJS.ProcessEnv;\n\t/** The CLI's home, for stored logins. */\n\thome?: string;\n}\n\n/**\n * A provider. `C` is its config entry, `K` its provisioning credential.\n *\n * Built-ins are registered in `providers/registry.ts`, the way a deploy\n * target's built-ins are.\n */\nexport interface ResourceProvider<\n\tC extends ProviderConfig = ProviderConfig,\n\tK = unknown,\n> {\n\treadonly kind: ProviderKind;\n\t/** What `provider:` names it. */\n\treadonly name: string;\n\t/**\n\t * Its config entry checked: returns it, or throws a named error saying\n\t * what is wrong — what the workspace schema runs.\n\t */\n\tcheck(stage: string, config: ProviderConfig): C;\n\t/** How its provisioning credentials are supplied, for messages. */\n\treadonly provisioning: {\n\t\t/** The environment variables it reads. */\n\t\tenv: readonly string[];\n\t\t/** A `gkm login --provider` name, where it has one. */\n\t\tlogin?: string;\n\t\t/** One line saying how to supply them. */\n\t\tdescribe: string;\n\t};\n\t/** Its provisioning credentials, or `undefined` when there are none. */\n\tcredentials(lookup: CredentialLookup): Promise<K | undefined>;\n\t/** The keys it writes into the stage's secrets for these constructs. */\n\truntimeKeys(manifest: ConstructManifest): string[];\n\tensure(ctx: EnsureContext<C, K>): Promise<void>;\n\tverify(ctx: VerifyContext<C>): Promise<void>;\n}\n","/**\n * What a deploy's checks read off `deploy.<kind>.<stage>`, without loading a\n * provider: which kinds the stage accounts for, what creates a missing key,\n * and a kind the stage has none of.\n */\n\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport type { StageProviderNotes } from '../deploy/devServices.js';\nimport { GkmError } from '../errors';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport { provisioningOf, stageProvider } from './config.js';\nimport { PROVIDER_KINDS, type ProviderKind } from './types.js';\n\n/** The constructs of a kind: `objects` is every bucket. */\nexport function constructsOf(manifest: ConstructManifest, kind: ProviderKind) {\n\treturn Object.entries(manifest)\n\t\t.filter(([, d]) => d.kind === kind)\n\t\t.map(([id]) => id)\n\t\t.sort();\n}\n\n/** A stage that names `false` for a kind, and declares constructs of it. */\nexport class StageProviderDisabled extends GkmError {\n\tconstructor(\n\t\treadonly kind: ProviderKind,\n\t\treadonly stage: string,\n\t\treadonly ids: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`deploy.${kind}.${stage} is false — the stage has no ${kind} — and ` +\n\t\t\t\t`${ids.join(', ')} ${ids.length === 1 ? 'is' : 'are'} declared. ` +\n\t\t\t\t`Name what backs ${ids.length === 1 ? 'it' : 'them'} on '${stage}' ` +\n\t\t\t\t`(deploy.${kind}.${stage}: 'external', or a provider), or remove ` +\n\t\t\t\t`the ${ids.length === 1 ? 'construct' : 'constructs'}.`,\n\t\t);\n\t\tthis.name = 'StageProviderDisabled';\n\t}\n}\n\n/** The command a stage's providers are run with: every deploy runs them. */\nexport function provisionCommand(stage: string): string {\n\treturn `gkm deploy --stage ${stage}`;\n}\n\n/**\n * The line a stage missing a key a provider would write is given: what\n * creates it, and with which credentials. Undefined when no provider backs\n * the kind on the stage.\n */\nexport function provisionHint(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tkind: ProviderKind,\n\tstage: string,\n): string | undefined {\n\tconst choice = stageProvider(workspace as never, kind, stage);\n\tif (choice.mode !== 'provider') return undefined;\n\tconst provisioning = provisioningOf(kind, choice.name);\n\tif (!provisioning) return undefined;\n\treturn (\n\t\t`deploy.${kind}.${stage} is ${choice.name}: the deploy ` +\n\t\t`(${provisionCommand(stage)}) creates it and writes this key, with ` +\n\t\t`${provisioning.describe}` +\n\t\t(provisioning.login\n\t\t\t? `, or gkm login --provider ${provisioning.login}`\n\t\t\t: '')\n\t);\n}\n\n/**\n * What a deploy's checks read off the stage's providers: whether each kind is\n * accounted for — a provider, or `false` — so no dev service stands in for\n * it, and what creates a missing key of it.\n */\nexport function stageProviderNotes(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tstage: string,\n): StageProviderNotes {\n\tconst choice = stageProvider(workspace as never, 'objects', stage);\n\tif (choice.mode === 'external') return {};\n\tconst hint = provisionHint(workspace, 'objects', stage);\n\treturn { objects: { accounted: true, ...(hint ? { hint } : {}) } };\n}\n\n/**\n * A kind the stage set to `false`, declared anyway — refused before anything\n * else is checked. Pure: what a stack is composed from.\n *\n * @throws {StageProviderDisabled}\n */\nexport function assertStageProvidersEnabled(\n\tworkspace: Pick<NormalizedWorkspace, 'deploy' | 'stages'>,\n\tmanifest: ConstructManifest,\n\tstage: string,\n): void {\n\tfor (const kind of PROVIDER_KINDS) {\n\t\tconst ids = constructsOf(manifest, kind);\n\t\tif (ids.length === 0) continue;\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'none') {\n\t\t\tthrow new StageProviderDisabled(kind, stage, ids);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,eAAe,CAAC,SAAS,SAAS;;;;;;;AAU/C,MAAa,mBAAmB,CAC/B,qBACA,uBACD;;AAGA,IAAa,8BAAb,cAAiD,SAAS;CACpC;CAArB,YAAY,QAAyB;EACpC,MACC,6DAA6D,OAAO,+FAGrE;EALoB,KAAA,SAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;;AAOA,IAAa,+BAAb,cAAkD,SAAS;CACrC;CAArB,YAAY,OAAwB;EACnC,MACC,sDAAsD,MAAM,wNAI7D;EANoB,KAAA,QAAA;EAOpB,KAAK,OAAO;CACb;AACD;;;;;;;;;AAUA,SAAgB,sBAAsB,MAA+B;CACpE,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,MAAM,KAAK;EACjB,IAAI,IAAI,WAAW,uBAAuB,GACzC,MAAM,IAAI,6BAA6B,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC;EAEvE,MAAM,OAAO,KAAK,IAAI;EACtB,IAAI,QAAQ,0BAA0B,QAAQ,CAAC,KAAK,WAAW,GAAG,GACjE,MAAM,IAAI,6BAA6B,IAAI;CAE7C;AACD;;;;;AAyBA,IAAa,gCAAb,cAAmD,SAAS;CAEjD;CACA;CAFV,YACC,OACA,SACC;EACD,MAAM,WAAW,QAAQ,MAAM,MAAM,EAAE,YAAY,KAAA,CAAS;EAC5D,MAAM,QAAQ,QAAQ,KAAK,MAAM;GAChC,MAAM,KAAK,EAAE,MAAM,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,OAAO,CAAC;CACxC,MAAM,OAAO,cAAc,WAAW,WAAW,KAAK;CACtD,OAAO,EAAE,SAAS;EAAE,WAAW;EAAM,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;CAAG,EAAE;AAClE;;;;;;;AAQA,SAAgB,4BACf,WACA,UACA,OACO;CACP,KAAK,MAAM,QAAQ,gBAAgB;EAClC,MAAM,MAAM,aAAa,UAAU,IAAI;EACvC,IAAI,IAAI,WAAW,GAAG;EACtB,IAAI,cAAc,WAAoB,MAAM,KAAK,CAAC,CAAC,SAAS,QAC3D,MAAM,IAAI,sBAAsB,MAAM,OAAO,GAAG;CAElD;AACD"}
package/dist/openapi.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_workspace = require("./workspace-1szcahj9.cjs");
4
4
  const require_config = require("./config-juUyBlb1.cjs");
5
- const require_EndpointGenerator = require("./EndpointGenerator-DyLMYClE.cjs");
6
- const require_OpenApiTsGenerator = require("./OpenApiTsGenerator-CI-tceXV.cjs");
5
+ const require_EndpointGenerator = require("./EndpointGenerator-DxrRqfJ3.cjs");
6
+ const require_OpenApiTsGenerator = require("./OpenApiTsGenerator-DOTLKBFf.cjs");
7
7
  let node_path = require("node:path");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  let node_child_process = require("node:child_process");
package/dist/openapi.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env -S npx tsx
2
2
  import { o as appConstructGlobs } from "./workspace-DFGsrjGD.mjs";
3
3
  import { g as appKey, p as loadWorkspaceConfig } from "./config-BLrAd7Of.mjs";
4
- import { c as parseTelemetryFlag, t as EndpointGenerator, u as telemetryArgs } from "./EndpointGenerator-CusLH-9S.mjs";
5
- import { t as OpenApiTsGenerator } from "./OpenApiTsGenerator-BTMuu1WS.mjs";
4
+ import { c as parseTelemetryFlag, t as EndpointGenerator, u as telemetryArgs } from "./EndpointGenerator-B5BKAoLz.mjs";
5
+ import { t as OpenApiTsGenerator } from "./OpenApiTsGenerator-Vaf0pI8u.mjs";
6
6
  import { dirname, join, relative, resolve } from "node:path";
7
7
  import { mkdir, writeFile } from "node:fs/promises";
8
8
  import { spawn } from "node:child_process";
@@ -1,5 +1,5 @@
1
1
  const require_errors = require("./errors-DMC4Umsb.cjs");
2
- require("./credentials-D4XclzQZ.cjs");
2
+ require("./credentials-i6NycDXd.cjs");
3
3
  let node_crypto = require("node:crypto");
4
4
  //#region src/providers/projectBucket.ts
5
5
  /**
@@ -260,4 +260,4 @@ Object.defineProperty(exports, "reconcileProjectBucketLifecycle", {
260
260
  }
261
261
  });
262
262
 
263
- //# sourceMappingURL=projectBucket-BokyGleo.cjs.map
263
+ //# sourceMappingURL=projectBucket-BxLoiySR.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectBucket-BokyGleo.cjs","names":["GkmError","createHash"],"sources":["../src/providers/projectBucket.ts"],"sourcesContent":["/**\n * The project bucket: one S3 bucket per project and AWS account, created and\n * owned by gkm, that holds what gkm keeps for every stage — the deploy state\n * under `<prefix>/<project>/<stage>/`, and anything else gkm writes per stage\n * beside it.\n *\n * Nothing can record its name — the deploy state lives in it — so the name is\n * worked out the same way every time: `gkm-<scope>-<account id>`, the scope\n * being the one the `s3` objects provider names its buckets with. The account\n * id keeps it from clashing with another account's project of the same name\n * without a random suffix; a clash that happens anyway (HeadBucket 403) is\n * refused, never adopted.\n *\n * Created with versioning, SSE-S3, every public access blocked, ownership\n * enforced for the bucket owner, a lifecycle that expires old versions, and\n * the tag `gkm:project=<identity key>`.\n */\n\nimport { createHash } from 'node:crypto';\nimport type {\n\tBucketLocationConstraint,\n\tLifecycleRule,\n\tS3Client,\n} from '@aws-sdk/client-s3';\nimport type { STSClient } from '@aws-sdk/client-sts';\nimport { type DeployIdentity, deployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\n\n/** S3's limit on a bucket name. */\nconst BUCKET_NAME_MAX = 63;\n/** What the project part may take: 63 less `gkm-`, `-` and a 12-digit id. */\nconst SCOPE_MAX = BUCKET_NAME_MAX - 'gkm-'.length - 1 - 12;\n\n/** The tag the bucket is created with, as the `s3` provider tags its own. */\nexport const PROJECT_BUCKET_TAG = 'gkm:project';\n\n/** How long a replaced or deleted object's old version is kept. */\nexport const NONCURRENT_VERSION_DAYS = 90;\n\n/** The bucket's name is held by another account, or cannot be reached. */\nexport class ProjectBucketTaken extends GkmError {\n\tconstructor(\n\t\treadonly bucket: string,\n\t\t/** HeadBucket's status: 403 another account's, 301 another region's. */\n\t\treadonly status: number,\n\t) {\n\t\tconst why =\n\t\t\tstatus === 301\n\t\t\t\t? 'is in another region than the one configured'\n\t\t\t\t: 'exists and this account cannot reach it — another account holds the name';\n\t\tsuper(\n\t\t\t`The project bucket '${bucket}' ${why} (HTTP ${status}). Name a bucket ` +\n\t\t\t\t\"you own instead — in gkm.config.ts: state: { provider: 's3', \" +\n\t\t\t\t\"bucket: '<your bucket>', region: '<its region>' } — or run with the \" +\n\t\t\t\t'credentials of the account the name is for.',\n\t\t);\n\t\tthis.name = 'ProjectBucketTaken';\n\t}\n}\n\n/** The running credentials may not create the project bucket. */\nexport class ProjectBucketNotCreatable extends GkmError {\n\tconstructor(\n\t\treadonly bucket: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`The project bucket '${bucket}' does not exist yet, and these ` +\n\t\t\t\t`credentials cannot create it (${reason}). Run the first deploy with ` +\n\t\t\t\t'credentials allowed s3:CreateBucket and the bucket put-config ' +\n\t\t\t\t'actions on it — `gkm deploy:github` grants them to the CI role — ' +\n\t\t\t\t\"or name an existing bucket: state: { provider: 's3', bucket, region }.\",\n\t\t);\n\t\tthis.name = 'ProjectBucketNotCreatable';\n\t}\n}\n\n/**\n * The project bucket's name: `gkm-<scope>-<account id>`, lowercase and\n * DNS-safe. A scope too long to fit keeps its start and ends in a hash of\n * the whole, so two long scopes never share a name.\n */\nexport function projectBucket(\n\tworkspace: { name: string; deploy?: { namespace?: string } },\n\toptions: { accountId: string },\n): string {\n\tconst { scope } = deployIdentity(workspace, '');\n\treturn projectBucketName(scope, options.accountId);\n}\n\n/** {@link projectBucket}, from a deploy identity's scope. */\nexport function projectBucketName(scope: string, accountId: string): string {\n\tlet part = scope\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '-')\n\t\t.replace(/^-+|-+$/g, '');\n\tif (part.length > SCOPE_MAX) {\n\t\tconst hash = createHash('sha256').update(scope).digest('hex').slice(0, 6);\n\t\tpart = `${part.slice(0, SCOPE_MAX - 7).replace(/-+$/, '')}-${hash}`;\n\t}\n\treturn `gkm-${part}-${accountId}`;\n}\n\n/** The account the credentials are in — what the bucket is named by. */\nexport async function callerAccountId(sts: STSClient): Promise<string> {\n\tconst { GetCallerIdentityCommand } = await import('@aws-sdk/client-sts');\n\tconst { Account } = await sts.send(new GetCallerIdentityCommand({}));\n\treturn Account ?? '';\n}\n\n/** An expiry for one stage's prefix, added beside the bucket's own rule. */\nexport interface PrefixExpiry {\n\t/** Rule id, unique in the bucket — e.g. `backups-production`. */\n\tid: string;\n\t/** Key prefix it applies to — e.g. `gkm/acme/production/backups/`. */\n\tprefix: string;\n\t/** Days after which a current object expires. */\n\tdays: number;\n\t/**\n\t * Days after which a multipart upload under the prefix that never\n\t * completed is aborted — its parts are stored, and billed, until it is.\n\t */\n\tabortIncompleteDays?: number;\n}\n\n/**\n * The bucket's whole lifecycle configuration. A put replaces every rule the\n * bucket has, so this is the one place the set is built: the bucket's own\n * noncurrent-version expiry, and any per-prefix expiry passed in.\n */\nexport function projectBucketLifecycle(\n\texpiries: readonly PrefixExpiry[] = [],\n): LifecycleRule[] {\n\treturn [\n\t\t{\n\t\t\tID: 'gkm-noncurrent-versions',\n\t\t\tStatus: 'Enabled',\n\t\t\tFilter: { Prefix: '' },\n\t\t\tNoncurrentVersionExpiration: { NoncurrentDays: NONCURRENT_VERSION_DAYS },\n\t\t\t// A lock is deleted every run; its markers go once nothing is under them.\n\t\t\tExpiration: { ExpiredObjectDeleteMarker: true },\n\t\t},\n\t\t...expiries.map(\n\t\t\t(expiry): LifecycleRule => ({\n\t\t\t\tID: expiry.id,\n\t\t\t\tStatus: 'Enabled',\n\t\t\t\tFilter: { Prefix: expiry.prefix },\n\t\t\t\tExpiration: { Days: expiry.days },\n\t\t\t\t...(expiry.abortIncompleteDays\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAbortIncompleteMultipartUpload: {\n\t\t\t\t\t\t\t\tDaysAfterInitiation: expiry.abortIncompleteDays,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}),\n\t\t),\n\t];\n}\n\n/** A lifecycle rule reduced to what gkm sets, for comparing with what is there. */\nfunction canonicalRule(rule: LifecycleRule): string {\n\treturn JSON.stringify({\n\t\tid: rule.ID ?? '',\n\t\tstatus: rule.Status ?? '',\n\t\tprefix: rule.Filter?.Prefix ?? rule.Prefix ?? '',\n\t\tdays: rule.Expiration?.Days ?? null,\n\t\tmarkers: rule.Expiration?.ExpiredObjectDeleteMarker ?? null,\n\t\tnoncurrent: rule.NoncurrentVersionExpiration?.NoncurrentDays ?? null,\n\t\tabort: rule.AbortIncompleteMultipartUpload?.DaysAfterInitiation ?? null,\n\t});\n}\n\n/** Whether two rule sets say the same thing, in any order. */\nexport function sameLifecycle(\n\ta: readonly LifecycleRule[],\n\tb: readonly LifecycleRule[],\n): boolean {\n\tconst canonical = (rules: readonly LifecycleRule[]) =>\n\t\trules.map(canonicalRule).sort().join('\\n');\n\treturn canonical(a) === canonical(b);\n}\n\n/**\n * The project bucket's lifecycle put to {@link projectBucketLifecycle} of\n * `expiries` — every stage's — when what it holds says anything else.\n * Returns whether it was put; with `dryRun`, whether it would be.\n */\nexport async function reconcileProjectBucketLifecycle(\n\ts3: S3Client,\n\tbucket: string,\n\texpiries: readonly PrefixExpiry[],\n\toptions: { dryRun?: boolean } = {},\n): Promise<boolean> {\n\tconst S3 = await import('@aws-sdk/client-s3');\n\tconst rules = projectBucketLifecycle(expiries);\n\tlet current: LifecycleRule[] = [];\n\ttry {\n\t\tconst out = await s3.send(\n\t\t\tnew S3.GetBucketLifecycleConfigurationCommand({ Bucket: bucket }),\n\t\t);\n\t\tcurrent = out.Rules ?? [];\n\t} catch (error) {\n\t\tconst failure = error as S3Failure;\n\t\tconst code = failure.Code ?? failure.name;\n\t\tif (code !== 'NoSuchLifecycleConfiguration') throw error;\n\t}\n\tif (sameLifecycle(current, rules)) return false;\n\tif (!options.dryRun) {\n\t\tawait s3.send(\n\t\t\tnew S3.PutBucketLifecycleConfigurationCommand({\n\t\t\t\tBucket: bucket,\n\t\t\t\tLifecycleConfiguration: { Rules: rules },\n\t\t\t}),\n\t\t);\n\t}\n\treturn true;\n}\n\ninterface S3Failure {\n\tname?: string;\n\tCode?: string;\n\tmessage?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/**\n * Whether `bucket` is this account's (`ours`) or does not exist (`none`).\n * Mapped by status: a HEAD has no body, so SDK v3 names a 301, 400 or 403\n * `Unknown`.\n *\n * @throws {ProjectBucketTaken} on a 403 or 301\n */\nexport async function findProjectBucket(\n\ts3: S3Client,\n\tbucket: string,\n): Promise<'ours' | 'none'> {\n\tconst { HeadBucketCommand } = await import('@aws-sdk/client-s3');\n\ttry {\n\t\tawait s3.send(new HeadBucketCommand({ Bucket: bucket }));\n\t\treturn 'ours';\n\t} catch (error) {\n\t\tconst status = (error as S3Failure).$metadata?.httpStatusCode;\n\t\tif (status === 404) return 'none';\n\t\tif (status === 403 || status === 301) {\n\t\t\tthrow new ProjectBucketTaken(bucket, status);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport interface EnsureProjectBucketOptions {\n\tbucket: string;\n\tregion: string;\n\t/** The deploy identity the bucket is tagged with. */\n\tidentity: Pick<DeployIdentity, 'key'>;\n\t/** Per-prefix expiries beside the bucket's own rule. */\n\texpiries?: readonly PrefixExpiry[];\n}\n\n/**\n * The project bucket, created and configured if it does not exist yet.\n * Returns whether this call created it. One that exists is used as it is.\n *\n * @throws {ProjectBucketTaken} when another account holds the name\n * @throws {ProjectBucketNotCreatable} when the credentials may not create it\n */\nexport async function ensureProjectBucket(\n\ts3: S3Client,\n\toptions: EnsureProjectBucketOptions,\n): Promise<{ created: boolean }> {\n\tconst { bucket: Bucket, region } = options;\n\tif ((await findProjectBucket(s3, Bucket)) === 'ours') {\n\t\treturn { created: false };\n\t}\n\n\tconst S3 = await import('@aws-sdk/client-s3');\n\ttry {\n\t\tawait s3.send(\n\t\t\tnew S3.CreateBucketCommand({\n\t\t\t\tBucket,\n\t\t\t\tObjectOwnership: 'BucketOwnerEnforced',\n\t\t\t\t// us-east-1 is the one region named by leaving it out.\n\t\t\t\t...(region === 'us-east-1'\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tCreateBucketConfiguration: {\n\t\t\t\t\t\t\t\tLocationConstraint: region as BucketLocationConstraint,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t} catch (error) {\n\t\tconst failure = error as S3Failure;\n\t\tconst code = failure.Code ?? failure.name;\n\t\t// Another run created it a moment ago: configure it all the same.\n\t\tif (code !== 'BucketAlreadyOwnedByYou') {\n\t\t\tif (code === 'BucketAlreadyExists') {\n\t\t\t\tthrow new ProjectBucketTaken(Bucket, 409);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcode === 'AccessDenied' ||\n\t\t\t\tfailure.$metadata?.httpStatusCode === 403\n\t\t\t) {\n\t\t\t\tthrow new ProjectBucketNotCreatable(\n\t\t\t\t\tBucket,\n\t\t\t\t\tfailure.message ?? 'AccessDenied',\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tawait s3.send(\n\t\tnew S3.PutPublicAccessBlockCommand({\n\t\t\tBucket,\n\t\t\tPublicAccessBlockConfiguration: {\n\t\t\t\tBlockPublicAcls: true,\n\t\t\t\tIgnorePublicAcls: true,\n\t\t\t\tBlockPublicPolicy: true,\n\t\t\t\tRestrictPublicBuckets: true,\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketOwnershipControlsCommand({\n\t\t\tBucket,\n\t\t\tOwnershipControls: {\n\t\t\t\tRules: [{ ObjectOwnership: 'BucketOwnerEnforced' }],\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketEncryptionCommand({\n\t\t\tBucket,\n\t\t\tServerSideEncryptionConfiguration: {\n\t\t\t\tRules: [\n\t\t\t\t\t{ ApplyServerSideEncryptionByDefault: { SSEAlgorithm: 'AES256' } },\n\t\t\t\t],\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketVersioningCommand({\n\t\t\tBucket,\n\t\t\tVersioningConfiguration: { Status: 'Enabled' },\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketLifecycleConfigurationCommand({\n\t\t\tBucket,\n\t\t\tLifecycleConfiguration: {\n\t\t\t\tRules: projectBucketLifecycle(options.expiries),\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketTaggingCommand({\n\t\t\tBucket,\n\t\t\tTagging: {\n\t\t\t\tTagSet: [{ Key: PROJECT_BUCKET_TAG, Value: options.identity.key }],\n\t\t\t},\n\t\t}),\n\t);\n\treturn { created: true };\n}\n\n/**\n * The IAM actions creating and configuring the project bucket takes — what a\n * role that runs the first deploy needs on it, beside object access.\n */\nexport const PROJECT_BUCKET_CREATE_ACTIONS = [\n\t's3:CreateBucket',\n\t's3:PutBucketVersioning',\n\t's3:PutEncryptionConfiguration',\n\t's3:PutBucketPublicAccessBlock',\n\t's3:PutBucketOwnershipControls',\n\t's3:PutLifecycleConfiguration',\n\t's3:PutBucketTagging',\n] as const;\n\n/**\n * What keeping the project bucket's lifecycle takes on a bucket that exists:\n * reading it, to put it back only when it drifted.\n */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B;EACxB;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,kCAAkC;EACxC;EACA,mBAAmB,EAClB,OAAO,CAAC,EAAE,iBAAiB,sBAAsB,CAAC,EACnD;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,2BAA2B;EACjC;EACA,mCAAmC,EAClC,OAAO,CACN,EAAE,oCAAoC,EAAE,cAAc,SAAS,EAAE,CAClE,EACD;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,2BAA2B;EACjC;EACA,yBAAyB,EAAE,QAAQ,UAAU;CAC9C,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,uCAAuC;EAC7C;EACA,wBAAwB,EACvB,OAAO,uBAAuB,QAAQ,QAAQ,EAC/C;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,wBAAwB;EAC9B;EACA,SAAS,EACR,QAAQ,CAAC;GAAE,KAAK;GAAoB,OAAO,QAAQ,SAAS;EAAI,CAAC,EAClE;CACD,CAAC,CACF;CACA,OAAO,EAAE,SAAS,KAAK;AACxB;;;;;AAMA,MAAa,gCAAgC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;AAMA,MAAa,mCAAmC,CAC/C,gCACA,8BACD"}
1
+ {"version":3,"file":"projectBucket-BxLoiySR.cjs","names":["GkmError","createHash"],"sources":["../src/providers/projectBucket.ts"],"sourcesContent":["/**\n * The project bucket: one S3 bucket per project and AWS account, created and\n * owned by gkm, that holds what gkm keeps for every stage — the deploy state\n * under `<prefix>/<project>/<stage>/`, and anything else gkm writes per stage\n * beside it.\n *\n * Nothing can record its name — the deploy state lives in it — so the name is\n * worked out the same way every time: `gkm-<scope>-<account id>`, the scope\n * being the one the `s3` objects provider names its buckets with. The account\n * id keeps it from clashing with another account's project of the same name\n * without a random suffix; a clash that happens anyway (HeadBucket 403) is\n * refused, never adopted.\n *\n * Created with versioning, SSE-S3, every public access blocked, ownership\n * enforced for the bucket owner, a lifecycle that expires old versions, and\n * the tag `gkm:project=<identity key>`.\n */\n\nimport { createHash } from 'node:crypto';\nimport type {\n\tBucketLocationConstraint,\n\tLifecycleRule,\n\tS3Client,\n} from '@aws-sdk/client-s3';\nimport type { STSClient } from '@aws-sdk/client-sts';\nimport { type DeployIdentity, deployIdentity } from '../deploy/identity.js';\nimport { GkmError } from '../errors';\n\n/** S3's limit on a bucket name. */\nconst BUCKET_NAME_MAX = 63;\n/** What the project part may take: 63 less `gkm-`, `-` and a 12-digit id. */\nconst SCOPE_MAX = BUCKET_NAME_MAX - 'gkm-'.length - 1 - 12;\n\n/** The tag the bucket is created with, as the `s3` provider tags its own. */\nexport const PROJECT_BUCKET_TAG = 'gkm:project';\n\n/** How long a replaced or deleted object's old version is kept. */\nexport const NONCURRENT_VERSION_DAYS = 90;\n\n/** The bucket's name is held by another account, or cannot be reached. */\nexport class ProjectBucketTaken extends GkmError {\n\tconstructor(\n\t\treadonly bucket: string,\n\t\t/** HeadBucket's status: 403 another account's, 301 another region's. */\n\t\treadonly status: number,\n\t) {\n\t\tconst why =\n\t\t\tstatus === 301\n\t\t\t\t? 'is in another region than the one configured'\n\t\t\t\t: 'exists and this account cannot reach it — another account holds the name';\n\t\tsuper(\n\t\t\t`The project bucket '${bucket}' ${why} (HTTP ${status}). Name a bucket ` +\n\t\t\t\t\"you own instead — in gkm.config.ts: state: { provider: 's3', \" +\n\t\t\t\t\"bucket: '<your bucket>', region: '<its region>' } — or run with the \" +\n\t\t\t\t'credentials of the account the name is for.',\n\t\t);\n\t\tthis.name = 'ProjectBucketTaken';\n\t}\n}\n\n/** The running credentials may not create the project bucket. */\nexport class ProjectBucketNotCreatable extends GkmError {\n\tconstructor(\n\t\treadonly bucket: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`The project bucket '${bucket}' does not exist yet, and these ` +\n\t\t\t\t`credentials cannot create it (${reason}). Run the first deploy with ` +\n\t\t\t\t'credentials allowed s3:CreateBucket and the bucket put-config ' +\n\t\t\t\t'actions on it — `gkm deploy:github` grants them to the CI role — ' +\n\t\t\t\t\"or name an existing bucket: state: { provider: 's3', bucket, region }.\",\n\t\t);\n\t\tthis.name = 'ProjectBucketNotCreatable';\n\t}\n}\n\n/**\n * The project bucket's name: `gkm-<scope>-<account id>`, lowercase and\n * DNS-safe. A scope too long to fit keeps its start and ends in a hash of\n * the whole, so two long scopes never share a name.\n */\nexport function projectBucket(\n\tworkspace: { name: string; deploy?: { namespace?: string } },\n\toptions: { accountId: string },\n): string {\n\tconst { scope } = deployIdentity(workspace, '');\n\treturn projectBucketName(scope, options.accountId);\n}\n\n/** {@link projectBucket}, from a deploy identity's scope. */\nexport function projectBucketName(scope: string, accountId: string): string {\n\tlet part = scope\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '-')\n\t\t.replace(/^-+|-+$/g, '');\n\tif (part.length > SCOPE_MAX) {\n\t\tconst hash = createHash('sha256').update(scope).digest('hex').slice(0, 6);\n\t\tpart = `${part.slice(0, SCOPE_MAX - 7).replace(/-+$/, '')}-${hash}`;\n\t}\n\treturn `gkm-${part}-${accountId}`;\n}\n\n/** The account the credentials are in — what the bucket is named by. */\nexport async function callerAccountId(sts: STSClient): Promise<string> {\n\tconst { GetCallerIdentityCommand } = await import('@aws-sdk/client-sts');\n\tconst { Account } = await sts.send(new GetCallerIdentityCommand({}));\n\treturn Account ?? '';\n}\n\n/** An expiry for one stage's prefix, added beside the bucket's own rule. */\nexport interface PrefixExpiry {\n\t/** Rule id, unique in the bucket — e.g. `backups-production`. */\n\tid: string;\n\t/** Key prefix it applies to — e.g. `gkm/acme/production/backups/`. */\n\tprefix: string;\n\t/** Days after which a current object expires. */\n\tdays: number;\n\t/**\n\t * Days after which a multipart upload under the prefix that never\n\t * completed is aborted — its parts are stored, and billed, until it is.\n\t */\n\tabortIncompleteDays?: number;\n}\n\n/**\n * The bucket's whole lifecycle configuration. A put replaces every rule the\n * bucket has, so this is the one place the set is built: the bucket's own\n * noncurrent-version expiry, and any per-prefix expiry passed in.\n */\nexport function projectBucketLifecycle(\n\texpiries: readonly PrefixExpiry[] = [],\n): LifecycleRule[] {\n\treturn [\n\t\t{\n\t\t\tID: 'gkm-noncurrent-versions',\n\t\t\tStatus: 'Enabled',\n\t\t\tFilter: { Prefix: '' },\n\t\t\tNoncurrentVersionExpiration: { NoncurrentDays: NONCURRENT_VERSION_DAYS },\n\t\t\t// A lock is deleted every run; its markers go once nothing is under them.\n\t\t\tExpiration: { ExpiredObjectDeleteMarker: true },\n\t\t},\n\t\t...expiries.map(\n\t\t\t(expiry): LifecycleRule => ({\n\t\t\t\tID: expiry.id,\n\t\t\t\tStatus: 'Enabled',\n\t\t\t\tFilter: { Prefix: expiry.prefix },\n\t\t\t\tExpiration: { Days: expiry.days },\n\t\t\t\t...(expiry.abortIncompleteDays\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tAbortIncompleteMultipartUpload: {\n\t\t\t\t\t\t\t\tDaysAfterInitiation: expiry.abortIncompleteDays,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}),\n\t\t),\n\t];\n}\n\n/** A lifecycle rule reduced to what gkm sets, for comparing with what is there. */\nfunction canonicalRule(rule: LifecycleRule): string {\n\treturn JSON.stringify({\n\t\tid: rule.ID ?? '',\n\t\tstatus: rule.Status ?? '',\n\t\tprefix: rule.Filter?.Prefix ?? rule.Prefix ?? '',\n\t\tdays: rule.Expiration?.Days ?? null,\n\t\tmarkers: rule.Expiration?.ExpiredObjectDeleteMarker ?? null,\n\t\tnoncurrent: rule.NoncurrentVersionExpiration?.NoncurrentDays ?? null,\n\t\tabort: rule.AbortIncompleteMultipartUpload?.DaysAfterInitiation ?? null,\n\t});\n}\n\n/** Whether two rule sets say the same thing, in any order. */\nexport function sameLifecycle(\n\ta: readonly LifecycleRule[],\n\tb: readonly LifecycleRule[],\n): boolean {\n\tconst canonical = (rules: readonly LifecycleRule[]) =>\n\t\trules.map(canonicalRule).sort().join('\\n');\n\treturn canonical(a) === canonical(b);\n}\n\n/**\n * The project bucket's lifecycle put to {@link projectBucketLifecycle} of\n * `expiries` — every stage's — when what it holds says anything else.\n * Returns whether it was put; with `dryRun`, whether it would be.\n */\nexport async function reconcileProjectBucketLifecycle(\n\ts3: S3Client,\n\tbucket: string,\n\texpiries: readonly PrefixExpiry[],\n\toptions: { dryRun?: boolean } = {},\n): Promise<boolean> {\n\tconst S3 = await import('@aws-sdk/client-s3');\n\tconst rules = projectBucketLifecycle(expiries);\n\tlet current: LifecycleRule[] = [];\n\ttry {\n\t\tconst out = await s3.send(\n\t\t\tnew S3.GetBucketLifecycleConfigurationCommand({ Bucket: bucket }),\n\t\t);\n\t\tcurrent = out.Rules ?? [];\n\t} catch (error) {\n\t\tconst failure = error as S3Failure;\n\t\tconst code = failure.Code ?? failure.name;\n\t\tif (code !== 'NoSuchLifecycleConfiguration') throw error;\n\t}\n\tif (sameLifecycle(current, rules)) return false;\n\tif (!options.dryRun) {\n\t\tawait s3.send(\n\t\t\tnew S3.PutBucketLifecycleConfigurationCommand({\n\t\t\t\tBucket: bucket,\n\t\t\t\tLifecycleConfiguration: { Rules: rules },\n\t\t\t}),\n\t\t);\n\t}\n\treturn true;\n}\n\ninterface S3Failure {\n\tname?: string;\n\tCode?: string;\n\tmessage?: string;\n\t$metadata?: { httpStatusCode?: number };\n}\n\n/**\n * Whether `bucket` is this account's (`ours`) or does not exist (`none`).\n * Mapped by status: a HEAD has no body, so SDK v3 names a 301, 400 or 403\n * `Unknown`.\n *\n * @throws {ProjectBucketTaken} on a 403 or 301\n */\nexport async function findProjectBucket(\n\ts3: S3Client,\n\tbucket: string,\n): Promise<'ours' | 'none'> {\n\tconst { HeadBucketCommand } = await import('@aws-sdk/client-s3');\n\ttry {\n\t\tawait s3.send(new HeadBucketCommand({ Bucket: bucket }));\n\t\treturn 'ours';\n\t} catch (error) {\n\t\tconst status = (error as S3Failure).$metadata?.httpStatusCode;\n\t\tif (status === 404) return 'none';\n\t\tif (status === 403 || status === 301) {\n\t\t\tthrow new ProjectBucketTaken(bucket, status);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport interface EnsureProjectBucketOptions {\n\tbucket: string;\n\tregion: string;\n\t/** The deploy identity the bucket is tagged with. */\n\tidentity: Pick<DeployIdentity, 'key'>;\n\t/** Per-prefix expiries beside the bucket's own rule. */\n\texpiries?: readonly PrefixExpiry[];\n}\n\n/**\n * The project bucket, created and configured if it does not exist yet.\n * Returns whether this call created it. One that exists is used as it is.\n *\n * @throws {ProjectBucketTaken} when another account holds the name\n * @throws {ProjectBucketNotCreatable} when the credentials may not create it\n */\nexport async function ensureProjectBucket(\n\ts3: S3Client,\n\toptions: EnsureProjectBucketOptions,\n): Promise<{ created: boolean }> {\n\tconst { bucket: Bucket, region } = options;\n\tif ((await findProjectBucket(s3, Bucket)) === 'ours') {\n\t\treturn { created: false };\n\t}\n\n\tconst S3 = await import('@aws-sdk/client-s3');\n\ttry {\n\t\tawait s3.send(\n\t\t\tnew S3.CreateBucketCommand({\n\t\t\t\tBucket,\n\t\t\t\tObjectOwnership: 'BucketOwnerEnforced',\n\t\t\t\t// us-east-1 is the one region named by leaving it out.\n\t\t\t\t...(region === 'us-east-1'\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tCreateBucketConfiguration: {\n\t\t\t\t\t\t\t\tLocationConstraint: region as BucketLocationConstraint,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\t} catch (error) {\n\t\tconst failure = error as S3Failure;\n\t\tconst code = failure.Code ?? failure.name;\n\t\t// Another run created it a moment ago: configure it all the same.\n\t\tif (code !== 'BucketAlreadyOwnedByYou') {\n\t\t\tif (code === 'BucketAlreadyExists') {\n\t\t\t\tthrow new ProjectBucketTaken(Bucket, 409);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tcode === 'AccessDenied' ||\n\t\t\t\tfailure.$metadata?.httpStatusCode === 403\n\t\t\t) {\n\t\t\t\tthrow new ProjectBucketNotCreatable(\n\t\t\t\t\tBucket,\n\t\t\t\t\tfailure.message ?? 'AccessDenied',\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tawait s3.send(\n\t\tnew S3.PutPublicAccessBlockCommand({\n\t\t\tBucket,\n\t\t\tPublicAccessBlockConfiguration: {\n\t\t\t\tBlockPublicAcls: true,\n\t\t\t\tIgnorePublicAcls: true,\n\t\t\t\tBlockPublicPolicy: true,\n\t\t\t\tRestrictPublicBuckets: true,\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketOwnershipControlsCommand({\n\t\t\tBucket,\n\t\t\tOwnershipControls: {\n\t\t\t\tRules: [{ ObjectOwnership: 'BucketOwnerEnforced' }],\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketEncryptionCommand({\n\t\t\tBucket,\n\t\t\tServerSideEncryptionConfiguration: {\n\t\t\t\tRules: [\n\t\t\t\t\t{ ApplyServerSideEncryptionByDefault: { SSEAlgorithm: 'AES256' } },\n\t\t\t\t],\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketVersioningCommand({\n\t\t\tBucket,\n\t\t\tVersioningConfiguration: { Status: 'Enabled' },\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketLifecycleConfigurationCommand({\n\t\t\tBucket,\n\t\t\tLifecycleConfiguration: {\n\t\t\t\tRules: projectBucketLifecycle(options.expiries),\n\t\t\t},\n\t\t}),\n\t);\n\tawait s3.send(\n\t\tnew S3.PutBucketTaggingCommand({\n\t\t\tBucket,\n\t\t\tTagging: {\n\t\t\t\tTagSet: [{ Key: PROJECT_BUCKET_TAG, Value: options.identity.key }],\n\t\t\t},\n\t\t}),\n\t);\n\treturn { created: true };\n}\n\n/**\n * The IAM actions creating and configuring the project bucket takes — what a\n * role that runs the first deploy needs on it, beside object access.\n */\nexport const PROJECT_BUCKET_CREATE_ACTIONS = [\n\t's3:CreateBucket',\n\t's3:PutBucketVersioning',\n\t's3:PutEncryptionConfiguration',\n\t's3:PutBucketPublicAccessBlock',\n\t's3:PutBucketOwnershipControls',\n\t's3:PutLifecycleConfiguration',\n\t's3:PutBucketTagging',\n] as const;\n\n/**\n * What keeping the project bucket's lifecycle takes on a bucket that exists:\n * reading it, to put it back only when it drifted.\n */\nexport const PROJECT_BUCKET_LIFECYCLE_ACTIONS = [\n\t's3:GetLifecycleConfiguration',\n\t's3:PutLifecycleConfiguration',\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,YAAY;;AAGlB,MAAa,qBAAqB;;AAMlC,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAEtC;CAEA;CAHV,YACC,QAEA,QACC;EAKD,MACC,uBAAuB,OAAO,IAJ9B,WAAW,MACR,iDACA,2EAEmC,SAAS,OAAO,8LAIvD;EAbS,KAAA,SAAA;EAEA,KAAA,SAAA;EAYT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,4BAAb,cAA+CA,eAAAA,SAAS;CAE7C;CACA;CAFV,YACC,QACA,QACC;EACD,MACC,uBAAuB,OAAO,gEACI,OAAO,qOAI1C;EATS,KAAA,SAAA;EACA,KAAA,SAAA;EAST,KAAK,OAAO;CACb;AACD;;AAgBA,SAAgB,kBAAkB,OAAe,WAA2B;CAC3E,IAAI,OAAO,MACT,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE;CACxB,IAAI,KAAK,SAAS,WAAW;EAC5B,MAAM,QAAA,GAAOC,YAAAA,WAAAA,CAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;EACxE,OAAO,GAAG,KAAK,MAAM,GAAG,EAAa,CAAC,CAAC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I,SAAS,2BAA2B;GACvC,IAAI,SAAS,uBACZ,MAAM,IAAI,mBAAmB,QAAQ,GAAG;GAEzC,IACC,SAAS,kBACT,QAAQ,WAAW,mBAAmB,KAEtC,MAAM,IAAI,0BACT,QACA,QAAQ,WAAW,cACpB;GAED,MAAM;EACP;CACD;CAEA,MAAM,GAAG,KACR,IAAI,GAAG,4BAA4B;EAClC;EACA,gCAAgC;GAC/B,iBAAiB;GACjB,kBAAkB;GAClB,mBAAmB;GACnB,uBAAuB;EACxB;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,kCAAkC;EACxC;EACA,mBAAmB,EAClB,OAAO,CAAC,EAAE,iBAAiB,sBAAsB,CAAC,EACnD;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,2BAA2B;EACjC;EACA,mCAAmC,EAClC,OAAO,CACN,EAAE,oCAAoC,EAAE,cAAc,SAAS,EAAE,CAClE,EACD;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,2BAA2B;EACjC;EACA,yBAAyB,EAAE,QAAQ,UAAU;CAC9C,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,uCAAuC;EAC7C;EACA,wBAAwB,EACvB,OAAO,uBAAuB,QAAQ,QAAQ,EAC/C;CACD,CAAC,CACF;CACA,MAAM,GAAG,KACR,IAAI,GAAG,wBAAwB;EAC9B;EACA,SAAS,EACR,QAAQ,CAAC;GAAE,KAAK;GAAoB,OAAO,QAAQ,SAAS;EAAI,CAAC,EAClE;CACD,CAAC,CACF;CACA,OAAO,EAAE,SAAS,KAAK;AACxB;;;;;AAMA,MAAa,gCAAgC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;AAMA,MAAa,mCAAmC,CAC/C,gCACA,8BACD"}
@@ -1,5 +1,5 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
- import "./credentials-C69J5G91.mjs";
2
+ import "./credentials-CKCKknMs.mjs";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/providers/projectBucket.ts
5
5
  /**
@@ -219,4 +219,4 @@ const PROJECT_BUCKET_LIFECYCLE_ACTIONS = ["s3:GetLifecycleConfiguration", "s3:Pu
219
219
  //#endregion
220
220
  export { findProjectBucket as a, ensureProjectBucket as i, PROJECT_BUCKET_LIFECYCLE_ACTIONS as n, projectBucketName as o, callerAccountId as r, reconcileProjectBucketLifecycle as s, PROJECT_BUCKET_CREATE_ACTIONS as t };
221
221
 
222
- //# sourceMappingURL=projectBucket-CJC-C3cD.mjs.map
222
+ //# sourceMappingURL=projectBucket-q4M_7rYh.mjs.map