@geekmidas/cli 10.0.0-alpha.171 → 10.0.0-alpha.173

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 (194) hide show
  1. package/dist/{GoDaddyProvider-Cs32wo6I.cjs → GoDaddyProvider-CogJfGVY.cjs} +7 -7
  2. package/dist/{GoDaddyProvider-Cs32wo6I.cjs.map → GoDaddyProvider-CogJfGVY.cjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-D7CTqN0f.mjs → GoDaddyProvider-uJkNjoF6.mjs} +2 -2
  4. package/dist/{GoDaddyProvider-D7CTqN0f.mjs.map → GoDaddyProvider-uJkNjoF6.mjs.map} +1 -1
  5. package/dist/{HostingerProvider-B_3Qs9mT.mjs → HostingerProvider-DJFdGv-x.mjs} +2 -2
  6. package/dist/{HostingerProvider-B_3Qs9mT.mjs.map → HostingerProvider-DJFdGv-x.mjs.map} +1 -1
  7. package/dist/{HostingerProvider-D0515Stf.cjs → HostingerProvider-DQEv1dim.cjs} +4 -4
  8. package/dist/{HostingerProvider-D0515Stf.cjs.map → HostingerProvider-DQEv1dim.cjs.map} +1 -1
  9. package/dist/{LegacyStateStore-CUjKKENQ.mjs → LegacyStateStore-CEAYSDxQ.mjs} +2 -2
  10. package/dist/{LegacyStateStore-CUjKKENQ.mjs.map → LegacyStateStore-CEAYSDxQ.mjs.map} +1 -1
  11. package/dist/{LegacyStateStore-Bv_2L86H.cjs → LegacyStateStore-Du-QYvvW.cjs} +2 -2
  12. package/dist/{LegacyStateStore-Bv_2L86H.cjs.map → LegacyStateStore-Du-QYvvW.cjs.map} +1 -1
  13. package/dist/{LocalStateStore-PQ2qJ5VF.cjs → LocalStateStore-CBnOEVUw.cjs} +2 -2
  14. package/dist/{LocalStateStore-PQ2qJ5VF.cjs.map → LocalStateStore-CBnOEVUw.cjs.map} +1 -1
  15. package/dist/{LocalStateStore-DXuj1BDq.mjs → LocalStateStore-DyqbqdrE.mjs} +2 -2
  16. package/dist/{LocalStateStore-DXuj1BDq.mjs.map → LocalStateStore-DyqbqdrE.mjs.map} +1 -1
  17. package/dist/{S3StateStore-cmS6iUZn.cjs → S3StateStore-BPPv8S_Q.cjs} +5 -5
  18. package/dist/{S3StateStore-cmS6iUZn.cjs.map → S3StateStore-BPPv8S_Q.cjs.map} +1 -1
  19. package/dist/{S3StateStore-BGnOwqUp.mjs → S3StateStore-CQ2kN1Pb.mjs} +4 -4
  20. package/dist/{S3StateStore-BGnOwqUp.mjs.map → S3StateStore-CQ2kN1Pb.mjs.map} +1 -1
  21. package/dist/{SSMStateStore-BtNGbg8Z.cjs → SSMStateStore-CHy4p884.cjs} +2 -2
  22. package/dist/{SSMStateStore-BtNGbg8Z.cjs.map → SSMStateStore-CHy4p884.cjs.map} +1 -1
  23. package/dist/{SSMStateStore-BqXzPBbu.mjs → SSMStateStore-Ca1_Tv6e.mjs} +2 -2
  24. package/dist/{SSMStateStore-BqXzPBbu.mjs.map → SSMStateStore-Ca1_Tv6e.mjs.map} +1 -1
  25. package/dist/{add-Dp5xRn-u.cjs → add-nvNmOV4h.cjs} +7 -7
  26. package/dist/{add-Dp5xRn-u.cjs.map → add-nvNmOV4h.cjs.map} +1 -1
  27. package/dist/{add-DW2KLCY0.mjs → add-wFkYMhYc.mjs} +5 -5
  28. package/dist/{add-DW2KLCY0.mjs.map → add-wFkYMhYc.mjs.map} +1 -1
  29. package/dist/{apps-DYGKg5SP.cjs → apps-CnTjkv-C.cjs} +9 -9
  30. package/dist/{apps-DYGKg5SP.cjs.map → apps-CnTjkv-C.cjs.map} +1 -1
  31. package/dist/{apps-DrXwv-0A.mjs → apps-Dh2ito9T.mjs} +4 -4
  32. package/dist/{apps-DrXwv-0A.mjs.map → apps-Dh2ito9T.mjs.map} +1 -1
  33. package/dist/{bundler-Swt8wHG9.mjs → bundler-BXS0AEtM.mjs} +6 -6
  34. package/dist/{bundler-Swt8wHG9.mjs.map → bundler-BXS0AEtM.mjs.map} +1 -1
  35. package/dist/{bundler-BIfEe05e.cjs → bundler-B_2Mxi7l.cjs} +9 -9
  36. package/dist/{bundler-BIfEe05e.cjs.map → bundler-B_2Mxi7l.cjs.map} +1 -1
  37. package/dist/{cli-C9wdKQy_.mjs → cli-CuCePKEc.mjs} +4 -4
  38. package/dist/{cli-C9wdKQy_.mjs.map → cli-CuCePKEc.mjs.map} +1 -1
  39. package/dist/{cli-ohJToj0E.cjs → cli-Dew5Ay8s.cjs} +6 -6
  40. package/dist/{cli-ohJToj0E.cjs.map → cli-Dew5Ay8s.cjs.map} +1 -1
  41. package/dist/{compose-Br3SQ2bW.cjs → compose-B6emrIOB.cjs} +27 -27
  42. package/dist/compose-B6emrIOB.cjs.map +1 -0
  43. package/dist/{compose-BLOnkeaJ.mjs → compose-Cfd5-ubC.mjs} +42 -16
  44. package/dist/compose-Cfd5-ubC.mjs.map +1 -0
  45. package/dist/{compose-SNYBstbO.cjs → compose-CpAmz8GF.cjs} +54 -28
  46. package/dist/compose-CpAmz8GF.cjs.map +1 -0
  47. package/dist/{compose-iUOeazjW.mjs → compose-DxreKQnX.mjs} +10 -10
  48. package/dist/compose-DxreKQnX.mjs.map +1 -0
  49. package/dist/config.cjs +1 -1
  50. package/dist/config.mjs +1 -1
  51. package/dist/deploy/public.cjs +20 -20
  52. package/dist/deploy/public.cjs.map +1 -1
  53. package/dist/deploy/public.mjs +11 -11
  54. package/dist/{deploy-DqH8QReb.mjs → deploy-CV-e75Ja.mjs} +14 -25
  55. package/dist/deploy-CV-e75Ja.mjs.map +1 -0
  56. package/dist/{deploy-CYyf-Q8N.cjs → deploy-Cy2mXTnI.cjs} +55 -66
  57. package/dist/deploy-Cy2mXTnI.cjs.map +1 -0
  58. package/dist/{destroy-B9myEYFT.mjs → destroy-DQllGEWe.mjs} +9 -9
  59. package/dist/{destroy-B9myEYFT.mjs.map → destroy-DQllGEWe.mjs.map} +1 -1
  60. package/dist/{destroy-Bp5iHtLf.cjs → destroy-DjUM1nDI.cjs} +24 -24
  61. package/dist/{destroy-Bp5iHtLf.cjs.map → destroy-DjUM1nDI.cjs.map} +1 -1
  62. package/dist/{credentials-C2VfI-uf.mjs → dns-DPHKct-l.mjs} +123 -123
  63. package/dist/dns-DPHKct-l.mjs.map +1 -0
  64. package/dist/{credentials-BdZhygvW.cjs → dns-efZTlePp.cjs} +122 -122
  65. package/dist/dns-efZTlePp.cjs.map +1 -0
  66. package/dist/{docker-BezTRGxN.cjs → docker-1hv2ehU4.cjs} +7 -7
  67. package/dist/{docker-BezTRGxN.cjs.map → docker-1hv2ehU4.cjs.map} +1 -1
  68. package/dist/{docker-De_-Ll-A.mjs → docker-CeGpTbYR.mjs} +5 -5
  69. package/dist/{docker-De_-Ll-A.mjs.map → docker-CeGpTbYR.mjs.map} +1 -1
  70. package/dist/{dokploy-EsBgWO8W.mjs → dokploy-Cdy9uxyT.mjs} +2 -2
  71. package/dist/{dokploy-EsBgWO8W.mjs.map → dokploy-Cdy9uxyT.mjs.map} +1 -1
  72. package/dist/{dokploy-CWCIqro_.cjs → dokploy-DMCSZX9P.cjs} +2 -2
  73. package/dist/{dokploy-CWCIqro_.cjs.map → dokploy-DMCSZX9P.cjs.map} +1 -1
  74. package/dist/{eas-8t6PJRni.cjs → eas-B3vFP-9c.cjs} +3 -3
  75. package/dist/{eas-8t6PJRni.cjs.map → eas-B3vFP-9c.cjs.map} +1 -1
  76. package/dist/{eas-BalvsiH5.mjs → eas-KsVb80gp.mjs} +3 -3
  77. package/dist/{eas-BalvsiH5.mjs.map → eas-KsVb80gp.mjs.map} +1 -1
  78. package/dist/{encryption-CKBmU66R.cjs → encryption-BYpdYmaT.cjs} +6 -6
  79. package/dist/{encryption-CKBmU66R.cjs.map → encryption-BYpdYmaT.cjs.map} +1 -1
  80. package/dist/{encryption-B4mWxt4G.mjs → encryption-d_vz6csy.mjs} +3 -3
  81. package/dist/{encryption-B4mWxt4G.mjs.map → encryption-d_vz6csy.mjs.map} +1 -1
  82. package/dist/{engine-y8iWIXuv.mjs → engine-CQTK8HEF.mjs} +9 -9
  83. package/dist/{engine-y8iWIXuv.mjs.map → engine-CQTK8HEF.mjs.map} +1 -1
  84. package/dist/{engine-BTG46RG-.cjs → engine-DIzP1hty.cjs} +58 -58
  85. package/dist/{engine-BTG46RG-.cjs.map → engine-DIzP1hty.cjs.map} +1 -1
  86. package/dist/{github-CeXlzWWA.cjs → github-Chr0rEy5.cjs} +16 -16
  87. package/dist/{github-CeXlzWWA.cjs.map → github-Chr0rEy5.cjs.map} +1 -1
  88. package/dist/{github-DvGoKoQO.mjs → github-Ctmgt1Zv.mjs} +7 -7
  89. package/dist/{github-DvGoKoQO.mjs.map → github-Ctmgt1Zv.mjs.map} +1 -1
  90. package/dist/{googlePlay-CfzG7jOJ.cjs → googlePlay-C50ZneV3.cjs} +5 -5
  91. package/dist/{googlePlay-CfzG7jOJ.cjs.map → googlePlay-C50ZneV3.cjs.map} +1 -1
  92. package/dist/{googlePlay-DWv6CUgM.mjs → googlePlay-D5kL9gs5.mjs} +4 -4
  93. package/dist/{googlePlay-DWv6CUgM.mjs.map → googlePlay-D5kL9gs5.mjs.map} +1 -1
  94. package/dist/{iam-FA95ku7l.cjs → iam-CGd_oEyz.cjs} +2 -2
  95. package/dist/{iam-FA95ku7l.cjs.map → iam-CGd_oEyz.cjs.map} +1 -1
  96. package/dist/{iam-BE0qX5Lb.mjs → iam-Cs2Ph5f2.mjs} +2 -2
  97. package/dist/{iam-BE0qX5Lb.mjs.map → iam-Cs2Ph5f2.mjs.map} +1 -1
  98. package/dist/index.cjs +108 -109
  99. package/dist/index.cjs.map +1 -1
  100. package/dist/index.mjs +62 -63
  101. package/dist/index.mjs.map +1 -1
  102. package/dist/{local-DH9at_0c.cjs → local-CxqlHyVX.cjs} +3 -3
  103. package/dist/{local-DH9at_0c.cjs.map → local-CxqlHyVX.cjs.map} +1 -1
  104. package/dist/{local-CvRvfktv.mjs → local-Cy6Bb9ta.mjs} +2 -2
  105. package/dist/{local-CvRvfktv.mjs.map → local-Cy6Bb9ta.mjs.map} +1 -1
  106. package/dist/{migrate-B1lHo2K2.cjs → migrate-C7AEA5wP.cjs} +6 -6
  107. package/dist/{migrate-B1lHo2K2.cjs.map → migrate-C7AEA5wP.cjs.map} +1 -1
  108. package/dist/{migrate-D1iCmQgc.mjs → migrate-DB1lxrIj.mjs} +5 -5
  109. package/dist/{migrate-D1iCmQgc.mjs.map → migrate-DB1lxrIj.mjs.map} +1 -1
  110. package/dist/{migrate-NmW2Su8s.mjs → migrate-DU_BqEwZ.mjs} +3 -3
  111. package/dist/{migrate-NmW2Su8s.mjs.map → migrate-DU_BqEwZ.mjs.map} +1 -1
  112. package/dist/{migrate-DzOWCnRR.cjs → migrate-uYiBDHF4.cjs} +6 -6
  113. package/dist/{migrate-DzOWCnRR.cjs.map → migrate-uYiBDHF4.cjs.map} +1 -1
  114. package/dist/{notes-BdIY7IoB.mjs → notes-C23PJFnm.mjs} +3 -3
  115. package/dist/{notes-BdIY7IoB.mjs.map → notes-C23PJFnm.mjs.map} +1 -1
  116. package/dist/{notes-ikElBCC8.cjs → notes-DOj8AhIz.cjs} +3 -3
  117. package/dist/{notes-ikElBCC8.cjs.map → notes-DOj8AhIz.cjs.map} +1 -1
  118. package/dist/openapi.cjs +1 -1
  119. package/dist/openapi.mjs +1 -1
  120. package/dist/{projectBucket-uidxz03Q.cjs → projectBucket-BNxobT1q.cjs} +2 -2
  121. package/dist/{projectBucket-uidxz03Q.cjs.map → projectBucket-BNxobT1q.cjs.map} +1 -1
  122. package/dist/{projectBucket-C-FOIic4.mjs → projectBucket-BpwAxov3.mjs} +2 -2
  123. package/dist/{projectBucket-C-FOIic4.mjs.map → projectBucket-BpwAxov3.mjs.map} +1 -1
  124. package/dist/{publish-Ujng6o63.mjs → publish-CM2A0e24.mjs} +2 -2
  125. package/dist/{publish-Ujng6o63.mjs.map → publish-CM2A0e24.mjs.map} +1 -1
  126. package/dist/{publish-oO_8elIf.cjs → publish-DaFTebR5.cjs} +2 -2
  127. package/dist/{publish-oO_8elIf.cjs.map → publish-DaFTebR5.cjs.map} +1 -1
  128. package/dist/{resolve-Lk7fd8Kb.mjs → resolve-DO6xu8Da.mjs} +4 -4
  129. package/dist/{resolve-Lk7fd8Kb.mjs.map → resolve-DO6xu8Da.mjs.map} +1 -1
  130. package/dist/{resolve-CTb1gsTO.cjs → resolve-DgHrtRXG.cjs} +4 -4
  131. package/dist/{resolve-CTb1gsTO.cjs.map → resolve-DgHrtRXG.cjs.map} +1 -1
  132. package/dist/{rollback-PK4pSOLd.cjs → rollback-6Idn2ozU.cjs} +9 -9
  133. package/dist/{rollback-PK4pSOLd.cjs.map → rollback-6Idn2ozU.cjs.map} +1 -1
  134. package/dist/{rollback-B2DhSX-I.mjs → rollback-CmeGUxpC.mjs} +6 -6
  135. package/dist/{rollback-B2DhSX-I.mjs.map → rollback-CmeGUxpC.mjs.map} +1 -1
  136. package/dist/{s3-BY5ry__M.mjs → s3-DKFFpPrS.mjs} +3 -3
  137. package/dist/{s3-BY5ry__M.mjs.map → s3-DKFFpPrS.mjs.map} +1 -1
  138. package/dist/{s3-FG9qIgEB.cjs → s3-du68lLNe.cjs} +3 -3
  139. package/dist/{s3-FG9qIgEB.cjs.map → s3-du68lLNe.cjs.map} +1 -1
  140. package/dist/{serverSetup-BL1sHzRr.mjs → serverSetup-BHxCT8nA.mjs} +6 -6
  141. package/dist/{serverSetup-BL1sHzRr.mjs.map → serverSetup-BHxCT8nA.mjs.map} +1 -1
  142. package/dist/{serverSetup-C7fDKGiN.cjs → serverSetup-Uk07rJqu.cjs} +8 -8
  143. package/dist/{serverSetup-C7fDKGiN.cjs.map → serverSetup-Uk07rJqu.cjs.map} +1 -1
  144. package/dist/{sniffer-BvhDRsgI.mjs → sniffer-FQzApIZ2.mjs} +7 -7
  145. package/dist/{sniffer-BvhDRsgI.mjs.map → sniffer-FQzApIZ2.mjs.map} +1 -1
  146. package/dist/{sniffer-DJp9a2Pg.cjs → sniffer-_XeLyu2-.cjs} +7 -7
  147. package/dist/{sniffer-DJp9a2Pg.cjs.map → sniffer-_XeLyu2-.cjs.map} +1 -1
  148. package/dist/{snsSubscriptions-7y2XBXde.mjs → snsSubscriptions-BCLdw-vn.mjs} +5 -78
  149. package/dist/snsSubscriptions-BCLdw-vn.mjs.map +1 -0
  150. package/dist/{snsSubscriptions-8t1XFvoc.cjs → snsSubscriptions-By_79DkX.cjs} +20 -111
  151. package/dist/snsSubscriptions-By_79DkX.cjs.map +1 -0
  152. package/dist/{sst-8HZe83-M.cjs → sst--n0v4Fch.cjs} +7 -7
  153. package/dist/{sst-8HZe83-M.cjs.map → sst--n0v4Fch.cjs.map} +1 -1
  154. package/dist/{sst-CzFd-1om.mjs → sst-CtrAb04-.mjs} +5 -5
  155. package/dist/{sst-CzFd-1om.mjs.map → sst-CtrAb04-.mjs.map} +1 -1
  156. package/dist/{stack-j2e8ddGl.mjs → stack-BfK0IV3V.mjs} +139 -12
  157. package/dist/stack-BfK0IV3V.mjs.map +1 -0
  158. package/dist/{stack-3tvhk7SU.cjs → stack-mqaJRhoK.cjs} +160 -14
  159. package/dist/stack-mqaJRhoK.cjs.map +1 -0
  160. package/dist/{stage-DMv-IfSD.mjs → stage-DsfVOAAA.mjs} +6 -6
  161. package/dist/{stage-DMv-IfSD.mjs.map → stage-DsfVOAAA.mjs.map} +1 -1
  162. package/dist/{stage-DCSJii_y.cjs → stage-NGr_EzmY.cjs} +8 -8
  163. package/dist/{stage-DCSJii_y.cjs.map → stage-NGr_EzmY.cjs.map} +1 -1
  164. package/dist/{stages-D49CUpBY.cjs → stages-8izznWib.cjs} +2 -2
  165. package/dist/{stages-D49CUpBY.cjs.map → stages-8izznWib.cjs.map} +1 -1
  166. package/dist/{stages-CCAAe1tP.mjs → stages-QPWgbm9P.mjs} +2 -2
  167. package/dist/{stages-CCAAe1tP.mjs.map → stages-QPWgbm9P.mjs.map} +1 -1
  168. package/dist/target/public.cjs +1 -1
  169. package/dist/target/public.mjs +1 -1
  170. package/dist/{terminal-VLmWgL_N.mjs → terminal-AVJMJvk5.mjs} +2 -2
  171. package/dist/{terminal-VLmWgL_N.mjs.map → terminal-AVJMJvk5.mjs.map} +1 -1
  172. package/dist/{terminal-DIEj2Nap.cjs → terminal-BpzSISdv.cjs} +5 -5
  173. package/dist/{terminal-DIEj2Nap.cjs.map → terminal-BpzSISdv.cjs.map} +1 -1
  174. package/dist/workspace/index.cjs +1 -1
  175. package/dist/workspace/index.mjs +1 -1
  176. package/dist/{workspace-B0PI9k9p.mjs → workspace-BBa1Ck5j.mjs} +16 -2
  177. package/dist/workspace-BBa1Ck5j.mjs.map +1 -0
  178. package/dist/{workspace-LR9DFjU8.cjs → workspace-DirP2-ed.cjs} +21 -7
  179. package/dist/workspace-DirP2-ed.cjs.map +1 -0
  180. package/package.json +15 -15
  181. package/dist/compose-BLOnkeaJ.mjs.map +0 -1
  182. package/dist/compose-Br3SQ2bW.cjs.map +0 -1
  183. package/dist/compose-SNYBstbO.cjs.map +0 -1
  184. package/dist/compose-iUOeazjW.mjs.map +0 -1
  185. package/dist/credentials-BdZhygvW.cjs.map +0 -1
  186. package/dist/credentials-C2VfI-uf.mjs.map +0 -1
  187. package/dist/deploy-CYyf-Q8N.cjs.map +0 -1
  188. package/dist/deploy-DqH8QReb.mjs.map +0 -1
  189. package/dist/snsSubscriptions-7y2XBXde.mjs.map +0 -1
  190. package/dist/snsSubscriptions-8t1XFvoc.cjs.map +0 -1
  191. package/dist/stack-3tvhk7SU.cjs.map +0 -1
  192. package/dist/stack-j2e8ddGl.mjs.map +0 -1
  193. package/dist/workspace-B0PI9k9p.mjs.map +0 -1
  194. package/dist/workspace-LR9DFjU8.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-DzOWCnRR.cjs","names":["GkmError","s3SecretsLocation","SECRETS_STORE_PROVIDERS","UnknownSecretsStoreProvider","isDeepStrictEqual","secretsParameterName","secretsManagerSecretName","loadWorkspaceSettings","secretsStoreFor","storeFromConfig"],"sources":["../src/secrets/migrate.ts"],"sourcesContent":["/**\n * `gkm secrets:migrate` — copy a deployed stage's secrets from the store\n * `secrets.store` names to another one, whole: service passwords, URLs and\n * custom keys alike, so nothing is regenerated and running services keep\n * their credentials.\n *\n * It copies, reads the copy back and compares it, and nothing more. The source\n * is never deleted, and gkm.config.ts is not edited: pointing `secrets.store`\n * at the new store is the switch, and the old copy is deleted by hand — with\n * the command this prints — once deploys read from the new one. Run again, a\n * target already holding the same secrets is verified and left alone.\n */\n\nimport { isDeepStrictEqual } from 'node:util';\n\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport { secretsParameterName } from './aws.js';\nimport { secretsManagerSecretName } from './secretsManager.js';\nimport {\n\tSECRETS_STORE_PROVIDERS,\n\ttype SecretsStore,\n\ttype SecretsStoreConfig,\n\ttype SecretsStoreOptions,\n\ttype SecretsStoreProvider,\n\ts3SecretsLocation,\n\tsecretsStoreFor,\n\tstoreFromConfig,\n\tUnknownSecretsStoreProvider,\n} from './store.js';\nimport type { StageSecrets } from './types.js';\n\nconst logger = console;\n\nexport interface SecretsMigrateOptions {\n\tstage: string;\n\t/** The store to copy to: `'file'`, `'s3'`, `'ssm'` or `'secrets-manager'`. */\n\tto: string;\n\t/**\n\t * The target's AWS region; defaults to the configured store's — for `s3`,\n\t * to the S3 state's first.\n\t */\n\tregion?: string;\n\t/** Overwrite a stage the target already holds different secrets for. */\n\tforce?: boolean;\n\t/** The AWS profile for the stage's account, for both stores. */\n\tprofile?: string;\n}\n\n/** An AWS store to copy to, with no region given and none configured. */\nexport class MigrateTargetNeedsRegion extends GkmError {\n\tconstructor(readonly to: string) {\n\t\tsuper(\n\t\t\t`Copying to ${to} needs a region, and secrets.store has none to reuse. ` +\n\t\t\t\t`Pass it: gkm secrets:migrate --to ${to} --region <region> --stage <stage>.`,\n\t\t);\n\t\tthis.name = 'MigrateTargetNeedsRegion';\n\t}\n}\n\n/** The target is the store the stage is already read from. */\nexport class MigrateTargetIsSource extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly to: string,\n\t) {\n\t\tsuper(\n\t\t\t`Stage \"${stage}\" is already kept in ${to}, so there is nothing to copy. ` +\n\t\t\t\t'Name a different store with --to, or a different region with --region.',\n\t\t);\n\t\tthis.name = 'MigrateTargetIsSource';\n\t}\n}\n\n/** The configured store holds nothing for the stage. */\nexport class NoSecretsToMigrate extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly store: string,\n\t) {\n\t\tsuper(\n\t\t\t`The ${store} store holds no secrets for stage \"${stage}\", so there is nothing to copy. ` +\n\t\t\t\t`Check secrets.store in gkm.config.ts still names the store the stage is in, ` +\n\t\t\t\t`or create the stage there with gkm secrets:init --stage ${stage}.`,\n\t\t);\n\t\tthis.name = 'NoSecretsToMigrate';\n\t}\n}\n\n/**\n * The target already holds different secrets for the stage, and `--force` was\n * not given.\n */\nexport class MigrateTargetHoldsStage extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly to: string,\n\t) {\n\t\tsuper(\n\t\t\t`The ${to} store already holds different secrets for stage \"${stage}\". ` +\n\t\t\t\t'Pass --force to replace them with the ones being copied.',\n\t\t);\n\t\tthis.name = 'MigrateTargetHoldsStage';\n\t}\n}\n\n/** The copy read back from the target is not what was copied. */\nexport class MigratedSecretsDiffer extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly to: string,\n\t\t/** The keys whose values differ, or that only one side has. */\n\t\treadonly keys: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`The secrets for stage \"${stage}\" read back from ${to} differ from the ones copied` +\n\t\t\t\t(keys.length ? ` (${keys.join(', ')})` : '') +\n\t\t\t\t'. The source is untouched and secrets.store still names it; run the migration again, ' +\n\t\t\t\t'or with --force if something else is writing to the target.',\n\t\t);\n\t\tthis.name = 'MigratedSecretsDiffer';\n\t}\n}\n\n/** The region the configured store is in, where it is an AWS one. */\nfunction configuredRegion(\n\tconfigured: SecretsStoreConfig,\n\tstate: unknown,\n): string | undefined {\n\tif (typeof configured !== 'object') return undefined;\n\tif (configured.provider === 's3') {\n\t\treturn s3SecretsLocation(configured, state).region;\n\t}\n\t// A custom store has no region to reuse.\n\treturn 'region' in configured ? configured.region : undefined;\n}\n\n/** The store a `--to` name and region describe. */\nfunction targetConfig(\n\tto: string,\n\tregion: string | undefined,\n\tconfigured: SecretsStoreConfig,\n\tstate: unknown,\n): SecretsStoreConfig {\n\tif (!(SECRETS_STORE_PROVIDERS as readonly string[]).includes(to)) {\n\t\tthrow new UnknownSecretsStoreProvider(to);\n\t}\n\tconst provider = to as SecretsStoreProvider;\n\tif (provider === 'file') return 'file';\n\n\tconst fallback = configuredRegion(configured, state);\n\n\tif (provider === 's3') {\n\t\t// The project bucket beside an S3 state is in the state's region.\n\t\tconst inherits =\n\t\t\ttypeof state === 'object' &&\n\t\t\tstate !== null &&\n\t\t\t(state as { provider?: unknown }).provider === 's3';\n\t\tconst resolved = region ?? (inherits ? undefined : fallback);\n\t\tif (!resolved && !inherits) throw new MigrateTargetNeedsRegion(provider);\n\t\treturn { provider, ...(resolved ? { region: resolved } : {}) };\n\t}\n\n\tconst resolved = region ?? fallback;\n\tif (!resolved) throw new MigrateTargetNeedsRegion(provider);\n\treturn { provider, region: resolved };\n}\n\n/** Whether two configs name the same place. */\nfunction samePlace(\n\ta: SecretsStoreConfig,\n\tb: SecretsStoreConfig,\n\tstate: unknown,\n): boolean {\n\tif (typeof a === 'string' || typeof b === 'string') return a === b;\n\tif (a.provider !== b.provider) return false;\n\tif (a.provider === 's3' && b.provider === 's3') {\n\t\treturn isDeepStrictEqual(\n\t\t\ts3SecretsLocation(a, state),\n\t\t\ts3SecretsLocation(b, state),\n\t\t);\n\t}\n\treturn 'region' in a && 'region' in b && a.region === b.region;\n}\n\n/** The `secrets.store` value to write in gkm.config.ts. */\nfunction configLine(target: SecretsStoreConfig): string {\n\tif (typeof target === 'string') return `'${target}'`;\n\tconst region =\n\t\t'region' in target && target.region ? `, region: '${target.region}'` : '';\n\treturn `{ provider: '${String(target.provider)}'${region} }`;\n}\n\n/** The keys whose values differ between two documents, as `section.KEY`. */\nexport function differingKeys(\n\ta: StageSecrets,\n\tb: StageSecrets | null,\n): string[] {\n\tconst keys: string[] = [];\n\tfor (const section of ['custom', 'urls', 'services'] as const) {\n\t\tconst left = a[section] as Record<string, unknown>;\n\t\tconst right = (b?.[section] ?? {}) as Record<string, unknown>;\n\t\tfor (const key of new Set([...Object.keys(left), ...Object.keys(right)])) {\n\t\t\tif (!isDeepStrictEqual(left[key], right[key])) {\n\t\t\t\tkeys.push(`${section}.${key}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn keys.sort();\n}\n\n/**\n * The command that deletes the stage's copy in the source store, for the\n * person to run once deploys read from the target — gkm never runs it.\n */\nexport function deleteSourceCommand(\n\tworkspace: { name: string },\n\tconfigured: SecretsStoreConfig,\n\tsource: SecretsStore,\n\tstage: string,\n\tprofile: string | undefined,\n): string | null {\n\tconst as = profile ? ` --profile ${profile}` : '';\n\tif (configured === 'file') return `rm .gkm/secrets/${stage}.json`;\n\tswitch (configured.provider) {\n\t\tcase 'ssm':\n\t\t\treturn `aws ssm delete-parameter --name ${secretsParameterName(workspace.name, stage)} --region ${configured.region}${as}`;\n\t\tcase 'secrets-manager':\n\t\t\treturn `aws secretsmanager delete-secret --secret-id ${secretsManagerSecretName(workspace.name, stage)} --region ${configured.region}${as}`;\n\t\tcase 's3': {\n\t\t\tconst location = (\n\t\t\t\tsource as { location?(stage: string): string }\n\t\t\t).location?.(stage);\n\t\t\tif (!location) return null;\n\t\t\t// Every version, as the bucket keeps them: only a delete marker is added.\n\t\t\treturn `aws s3 rm ${location}${as}`;\n\t\t}\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nexport async function secretsMigrateCommand(\n\toptions: SecretsMigrateOptions,\n): Promise<void> {\n\tconst { stage, to } = options;\n\tconst workspace = await loadWorkspaceSettings();\n\tassertDeployedStage(workspace.stages, stage);\n\n\tconst configured = workspace.secrets.store ?? 'file';\n\tconst target = targetConfig(to, options.region, configured, workspace.state);\n\tif (samePlace(configured, target, workspace.state)) {\n\t\tthrow new MigrateTargetIsSource(stage, to);\n\t}\n\n\tconst storeOptions: SecretsStoreOptions = options.profile\n\t\t? { profile: options.profile }\n\t\t: {};\n\tconst source = await secretsStoreFor(workspace, stage, storeOptions);\n\tconst destination = await storeFromConfig(workspace, target, storeOptions);\n\n\tconst secrets = await source.read(stage);\n\tif (!secrets) throw new NoSecretsToMigrate(stage, source.name);\n\n\tconst held = await destination.read(stage);\n\tconst already = held !== null && isDeepStrictEqual(held, secrets);\n\tif (held && !already && !options.force) {\n\t\tthrow new MigrateTargetHoldsStage(stage, destination.name);\n\t}\n\tif (!already) await destination.write(stage, secrets);\n\n\t// Read back through a store of its own, so nothing cached answers.\n\tconst copied = await (\n\t\tawait storeFromConfig(workspace, target, storeOptions)\n\t).read(stage);\n\tif (!isDeepStrictEqual(copied, secrets)) {\n\t\tthrow new MigratedSecretsDiffer(\n\t\t\tstage,\n\t\t\tdestination.name,\n\t\t\tdifferingKeys(secrets, copied),\n\t\t);\n\t}\n\n\tconst count =\n\t\tObject.keys(secrets.custom).length +\n\t\tObject.keys(secrets.urls).length +\n\t\tObject.keys(secrets.services).length;\n\tlogger.log(\n\t\talready\n\t\t\t? `\\n✓ ${destination.name} already holds the same secrets for stage \"${stage}\" as ${source.name}; nothing copied`\n\t\t\t: `\\n✓ Copied the secrets for stage \"${stage}\" from ${source.name} to ${destination.name}`,\n\t);\n\tlogger.log(\n\t\t` Verified: ${count} keys read back from ${destination.name}, equal.`,\n\t);\n\tlogger.log(\n\t\t`\\n Next: set secrets.store to ${configLine(target)} in gkm.config.ts, so commands and deploys read from ${destination.name}.`,\n\t);\n\tconst remove = deleteSourceCommand(\n\t\tworkspace,\n\t\tconfigured,\n\t\tsource,\n\t\tstage,\n\t\toptions.profile,\n\t);\n\tlogger.log(\n\t\t` The copy in ${source.name} is left as it was. Once deploys read from ${destination.name}, delete it` +\n\t\t\t(remove ? ` with:\\n\\n ${remove}\\n` : '.'),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,SAAS;;AAkBf,IAAa,2BAAb,cAA8CA,eAAAA,SAAS;CACjC;CAArB,YAAY,IAAqB;EAChC,MACC,cAAc,GAAG,0FACqB,GAAG,oCAC1C;EAJoB,KAAA,KAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,wBAAb,cAA2CA,eAAAA,SAAS;CAEzC;CACA;CAFV,YACC,OACA,IACC;EACD,MACC,UAAU,MAAM,uBAAuB,GAAG,sGAE3C;EANS,KAAA,QAAA;EACA,KAAA,KAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAEtC;CACA;CAFV,YACC,OACA,OACC;EACD,MACC,OAAO,MAAM,qCAAqC,MAAM,sKAEI,MAAM,EACnE;EAPS,KAAA,QAAA;EACA,KAAA,QAAA;EAOT,KAAK,OAAO;CACb;AACD;;;;;AAMA,IAAa,0BAAb,cAA6CA,eAAAA,SAAS;CAE3C;CACA;CAFV,YACC,OACA,IACC;EACD,MACC,OAAO,GAAG,oDAAoD,MAAM,4DAErE;EANS,KAAA,QAAA;EACA,KAAA,KAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,wBAAb,cAA2CA,eAAAA,SAAS;CAEzC;CACA;CAEA;CAJV,YACC,OACA,IAEA,MACC;EACD,MACC,0BAA0B,MAAM,mBAAmB,GAAG,iCACpD,KAAK,SAAS,KAAK,KAAK,KAAK,IAAI,EAAE,KAAK,MACzC,kJAEF;EAVS,KAAA,QAAA;EACA,KAAA,KAAA;EAEA,KAAA,OAAA;EAQT,KAAK,OAAO;CACb;AACD;;AAGA,SAAS,iBACR,YACA,OACqB;CACrB,IAAI,OAAO,eAAe,UAAU,OAAO,KAAA;CAC3C,IAAI,WAA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H;CACA,MAAM,SAAS,oBACd,WACA,YACA,QACA,OACA,QAAQ,OACT;CACA,OAAO,IACN,iBAAiB,OAAO,KAAK,6CAA6C,YAAY,KAAK,gBACzF,SAAS,iBAAiB,OAAO,MAAM,IAC1C;AACD"}
1
+ {"version":3,"file":"migrate-uYiBDHF4.cjs","names":["GkmError","s3SecretsLocation","SECRETS_STORE_PROVIDERS","UnknownSecretsStoreProvider","isDeepStrictEqual","secretsParameterName","secretsManagerSecretName","loadWorkspaceSettings","secretsStoreFor","storeFromConfig"],"sources":["../src/secrets/migrate.ts"],"sourcesContent":["/**\n * `gkm secrets:migrate` — copy a deployed stage's secrets from the store\n * `secrets.store` names to another one, whole: service passwords, URLs and\n * custom keys alike, so nothing is regenerated and running services keep\n * their credentials.\n *\n * It copies, reads the copy back and compares it, and nothing more. The source\n * is never deleted, and gkm.config.ts is not edited: pointing `secrets.store`\n * at the new store is the switch, and the old copy is deleted by hand — with\n * the command this prints — once deploys read from the new one. Run again, a\n * target already holding the same secrets is verified and left alone.\n */\n\nimport { isDeepStrictEqual } from 'node:util';\n\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { assertDeployedStage } from '../workspace/stages.js';\nimport { secretsParameterName } from './aws.js';\nimport { secretsManagerSecretName } from './secretsManager.js';\nimport {\n\tSECRETS_STORE_PROVIDERS,\n\ttype SecretsStore,\n\ttype SecretsStoreConfig,\n\ttype SecretsStoreOptions,\n\ttype SecretsStoreProvider,\n\ts3SecretsLocation,\n\tsecretsStoreFor,\n\tstoreFromConfig,\n\tUnknownSecretsStoreProvider,\n} from './store.js';\nimport type { StageSecrets } from './types.js';\n\nconst logger = console;\n\nexport interface SecretsMigrateOptions {\n\tstage: string;\n\t/** The store to copy to: `'file'`, `'s3'`, `'ssm'` or `'secrets-manager'`. */\n\tto: string;\n\t/**\n\t * The target's AWS region; defaults to the configured store's — for `s3`,\n\t * to the S3 state's first.\n\t */\n\tregion?: string;\n\t/** Overwrite a stage the target already holds different secrets for. */\n\tforce?: boolean;\n\t/** The AWS profile for the stage's account, for both stores. */\n\tprofile?: string;\n}\n\n/** An AWS store to copy to, with no region given and none configured. */\nexport class MigrateTargetNeedsRegion extends GkmError {\n\tconstructor(readonly to: string) {\n\t\tsuper(\n\t\t\t`Copying to ${to} needs a region, and secrets.store has none to reuse. ` +\n\t\t\t\t`Pass it: gkm secrets:migrate --to ${to} --region <region> --stage <stage>.`,\n\t\t);\n\t\tthis.name = 'MigrateTargetNeedsRegion';\n\t}\n}\n\n/** The target is the store the stage is already read from. */\nexport class MigrateTargetIsSource extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly to: string,\n\t) {\n\t\tsuper(\n\t\t\t`Stage \"${stage}\" is already kept in ${to}, so there is nothing to copy. ` +\n\t\t\t\t'Name a different store with --to, or a different region with --region.',\n\t\t);\n\t\tthis.name = 'MigrateTargetIsSource';\n\t}\n}\n\n/** The configured store holds nothing for the stage. */\nexport class NoSecretsToMigrate extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly store: string,\n\t) {\n\t\tsuper(\n\t\t\t`The ${store} store holds no secrets for stage \"${stage}\", so there is nothing to copy. ` +\n\t\t\t\t`Check secrets.store in gkm.config.ts still names the store the stage is in, ` +\n\t\t\t\t`or create the stage there with gkm secrets:init --stage ${stage}.`,\n\t\t);\n\t\tthis.name = 'NoSecretsToMigrate';\n\t}\n}\n\n/**\n * The target already holds different secrets for the stage, and `--force` was\n * not given.\n */\nexport class MigrateTargetHoldsStage extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly to: string,\n\t) {\n\t\tsuper(\n\t\t\t`The ${to} store already holds different secrets for stage \"${stage}\". ` +\n\t\t\t\t'Pass --force to replace them with the ones being copied.',\n\t\t);\n\t\tthis.name = 'MigrateTargetHoldsStage';\n\t}\n}\n\n/** The copy read back from the target is not what was copied. */\nexport class MigratedSecretsDiffer extends GkmError {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly to: string,\n\t\t/** The keys whose values differ, or that only one side has. */\n\t\treadonly keys: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`The secrets for stage \"${stage}\" read back from ${to} differ from the ones copied` +\n\t\t\t\t(keys.length ? ` (${keys.join(', ')})` : '') +\n\t\t\t\t'. The source is untouched and secrets.store still names it; run the migration again, ' +\n\t\t\t\t'or with --force if something else is writing to the target.',\n\t\t);\n\t\tthis.name = 'MigratedSecretsDiffer';\n\t}\n}\n\n/** The region the configured store is in, where it is an AWS one. */\nfunction configuredRegion(\n\tconfigured: SecretsStoreConfig,\n\tstate: unknown,\n): string | undefined {\n\tif (typeof configured !== 'object') return undefined;\n\tif (configured.provider === 's3') {\n\t\treturn s3SecretsLocation(configured, state).region;\n\t}\n\t// A custom store has no region to reuse.\n\treturn 'region' in configured ? configured.region : undefined;\n}\n\n/** The store a `--to` name and region describe. */\nfunction targetConfig(\n\tto: string,\n\tregion: string | undefined,\n\tconfigured: SecretsStoreConfig,\n\tstate: unknown,\n): SecretsStoreConfig {\n\tif (!(SECRETS_STORE_PROVIDERS as readonly string[]).includes(to)) {\n\t\tthrow new UnknownSecretsStoreProvider(to);\n\t}\n\tconst provider = to as SecretsStoreProvider;\n\tif (provider === 'file') return 'file';\n\n\tconst fallback = configuredRegion(configured, state);\n\n\tif (provider === 's3') {\n\t\t// The project bucket beside an S3 state is in the state's region.\n\t\tconst inherits =\n\t\t\ttypeof state === 'object' &&\n\t\t\tstate !== null &&\n\t\t\t(state as { provider?: unknown }).provider === 's3';\n\t\tconst resolved = region ?? (inherits ? undefined : fallback);\n\t\tif (!resolved && !inherits) throw new MigrateTargetNeedsRegion(provider);\n\t\treturn { provider, ...(resolved ? { region: resolved } : {}) };\n\t}\n\n\tconst resolved = region ?? fallback;\n\tif (!resolved) throw new MigrateTargetNeedsRegion(provider);\n\treturn { provider, region: resolved };\n}\n\n/** Whether two configs name the same place. */\nfunction samePlace(\n\ta: SecretsStoreConfig,\n\tb: SecretsStoreConfig,\n\tstate: unknown,\n): boolean {\n\tif (typeof a === 'string' || typeof b === 'string') return a === b;\n\tif (a.provider !== b.provider) return false;\n\tif (a.provider === 's3' && b.provider === 's3') {\n\t\treturn isDeepStrictEqual(\n\t\t\ts3SecretsLocation(a, state),\n\t\t\ts3SecretsLocation(b, state),\n\t\t);\n\t}\n\treturn 'region' in a && 'region' in b && a.region === b.region;\n}\n\n/** The `secrets.store` value to write in gkm.config.ts. */\nfunction configLine(target: SecretsStoreConfig): string {\n\tif (typeof target === 'string') return `'${target}'`;\n\tconst region =\n\t\t'region' in target && target.region ? `, region: '${target.region}'` : '';\n\treturn `{ provider: '${String(target.provider)}'${region} }`;\n}\n\n/** The keys whose values differ between two documents, as `section.KEY`. */\nexport function differingKeys(\n\ta: StageSecrets,\n\tb: StageSecrets | null,\n): string[] {\n\tconst keys: string[] = [];\n\tfor (const section of ['custom', 'urls', 'services'] as const) {\n\t\tconst left = a[section] as Record<string, unknown>;\n\t\tconst right = (b?.[section] ?? {}) as Record<string, unknown>;\n\t\tfor (const key of new Set([...Object.keys(left), ...Object.keys(right)])) {\n\t\t\tif (!isDeepStrictEqual(left[key], right[key])) {\n\t\t\t\tkeys.push(`${section}.${key}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn keys.sort();\n}\n\n/**\n * The command that deletes the stage's copy in the source store, for the\n * person to run once deploys read from the target — gkm never runs it.\n */\nexport function deleteSourceCommand(\n\tworkspace: { name: string },\n\tconfigured: SecretsStoreConfig,\n\tsource: SecretsStore,\n\tstage: string,\n\tprofile: string | undefined,\n): string | null {\n\tconst as = profile ? ` --profile ${profile}` : '';\n\tif (configured === 'file') return `rm .gkm/secrets/${stage}.json`;\n\tswitch (configured.provider) {\n\t\tcase 'ssm':\n\t\t\treturn `aws ssm delete-parameter --name ${secretsParameterName(workspace.name, stage)} --region ${configured.region}${as}`;\n\t\tcase 'secrets-manager':\n\t\t\treturn `aws secretsmanager delete-secret --secret-id ${secretsManagerSecretName(workspace.name, stage)} --region ${configured.region}${as}`;\n\t\tcase 's3': {\n\t\t\tconst location = (\n\t\t\t\tsource as { location?(stage: string): string }\n\t\t\t).location?.(stage);\n\t\t\tif (!location) return null;\n\t\t\t// Every version, as the bucket keeps them: only a delete marker is added.\n\t\t\treturn `aws s3 rm ${location}${as}`;\n\t\t}\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nexport async function secretsMigrateCommand(\n\toptions: SecretsMigrateOptions,\n): Promise<void> {\n\tconst { stage, to } = options;\n\tconst workspace = await loadWorkspaceSettings();\n\tassertDeployedStage(workspace.stages, stage);\n\n\tconst configured = workspace.secrets.store ?? 'file';\n\tconst target = targetConfig(to, options.region, configured, workspace.state);\n\tif (samePlace(configured, target, workspace.state)) {\n\t\tthrow new MigrateTargetIsSource(stage, to);\n\t}\n\n\tconst storeOptions: SecretsStoreOptions = options.profile\n\t\t? { profile: options.profile }\n\t\t: {};\n\tconst source = await secretsStoreFor(workspace, stage, storeOptions);\n\tconst destination = await storeFromConfig(workspace, target, storeOptions);\n\n\tconst secrets = await source.read(stage);\n\tif (!secrets) throw new NoSecretsToMigrate(stage, source.name);\n\n\tconst held = await destination.read(stage);\n\tconst already = held !== null && isDeepStrictEqual(held, secrets);\n\tif (held && !already && !options.force) {\n\t\tthrow new MigrateTargetHoldsStage(stage, destination.name);\n\t}\n\tif (!already) await destination.write(stage, secrets);\n\n\t// Read back through a store of its own, so nothing cached answers.\n\tconst copied = await (\n\t\tawait storeFromConfig(workspace, target, storeOptions)\n\t).read(stage);\n\tif (!isDeepStrictEqual(copied, secrets)) {\n\t\tthrow new MigratedSecretsDiffer(\n\t\t\tstage,\n\t\t\tdestination.name,\n\t\t\tdifferingKeys(secrets, copied),\n\t\t);\n\t}\n\n\tconst count =\n\t\tObject.keys(secrets.custom).length +\n\t\tObject.keys(secrets.urls).length +\n\t\tObject.keys(secrets.services).length;\n\tlogger.log(\n\t\talready\n\t\t\t? `\\n✓ ${destination.name} already holds the same secrets for stage \"${stage}\" as ${source.name}; nothing copied`\n\t\t\t: `\\n✓ Copied the secrets for stage \"${stage}\" from ${source.name} to ${destination.name}`,\n\t);\n\tlogger.log(\n\t\t` Verified: ${count} keys read back from ${destination.name}, equal.`,\n\t);\n\tlogger.log(\n\t\t`\\n Next: set secrets.store to ${configLine(target)} in gkm.config.ts, so commands and deploys read from ${destination.name}.`,\n\t);\n\tconst remove = deleteSourceCommand(\n\t\tworkspace,\n\t\tconfigured,\n\t\tsource,\n\t\tstage,\n\t\toptions.profile,\n\t);\n\tlogger.log(\n\t\t` The copy in ${source.name} is left as it was. Once deploys read from ${destination.name}, delete it` +\n\t\t\t(remove ? ` with:\\n\\n ${remove}\\n` : '.'),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,SAAS;;AAkBf,IAAa,2BAAb,cAA8CA,eAAAA,SAAS;CACjC;CAArB,YAAY,IAAqB;EAChC,MACC,cAAc,GAAG,0FACqB,GAAG,oCAC1C;EAJoB,KAAA,KAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,wBAAb,cAA2CA,eAAAA,SAAS;CAEzC;CACA;CAFV,YACC,OACA,IACC;EACD,MACC,UAAU,MAAM,uBAAuB,GAAG,sGAE3C;EANS,KAAA,QAAA;EACA,KAAA,KAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwCA,eAAAA,SAAS;CAEtC;CACA;CAFV,YACC,OACA,OACC;EACD,MACC,OAAO,MAAM,qCAAqC,MAAM,sKAEI,MAAM,EACnE;EAPS,KAAA,QAAA;EACA,KAAA,QAAA;EAOT,KAAK,OAAO;CACb;AACD;;;;;AAMA,IAAa,0BAAb,cAA6CA,eAAAA,SAAS;CAE3C;CACA;CAFV,YACC,OACA,IACC;EACD,MACC,OAAO,GAAG,oDAAoD,MAAM,4DAErE;EANS,KAAA,QAAA;EACA,KAAA,KAAA;EAMT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,wBAAb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B,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,SAC1B,OAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC;CAC/B,OAAO,IACN,UACG,OAAO,YAAY,KAAK,6CAA6C,MAAM,OAAO,OAAO,KAAK,oBAC9F,qCAAqC,MAAM,SAAS,OAAO,KAAK,MAAM,YAAY,MACtF;CACA,OAAO,IACN,eAAe,MAAM,uBAAuB,YAAY,KAAK,SAC9D;CACA,OAAO,IACN,kCAAkC,WAAW,MAAM,EAAE,uDAAuD,YAAY,KAAK,EAC9H;CACA,MAAM,SAAS,oBACd,WACA,YACA,QACA,OACA,QAAQ,OACT;CACA,OAAO,IACN,iBAAiB,OAAO,KAAK,6CAA6C,YAAY,KAAK,gBACzF,SAAS,iBAAiB,OAAO,MAAM,IAC1C;AACD"}
@@ -1,6 +1,6 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
- import { Ft as SERVER_IPV4_KEY, H as provisioningOf, It as SERVER_IPV6_KEY, U as stageProvider, dt as fileServerLabel, ot as appKey } from "./workspace-B0PI9k9p.mjs";
3
- import { l as workerEnvKeys, t as appEnvKeys } from "./apps-DrXwv-0A.mjs";
2
+ import { Ft as SERVER_IPV4_KEY, H as provisioningOf, It as SERVER_IPV6_KEY, U as stageProvider, dt as fileServerLabel, ot as appKey } from "./workspace-BBa1Ck5j.mjs";
3
+ import { l as workerEnvKeys, t as appEnvKeys } from "./apps-Dh2ito9T.mjs";
4
4
  import { providedKeyFor, publicEnvFor, senderAddress } from "@geekmidas/manifest";
5
5
  //#region src/deploy/devServices.ts
6
6
  /**
@@ -406,4 +406,4 @@ function assertStageProvidersEnabled(workspace, manifest, stage) {
406
406
  //#endregion
407
407
  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 };
408
408
 
409
- //# sourceMappingURL=notes-BdIY7IoB.mjs.map
409
+ //# sourceMappingURL=notes-C23PJFnm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notes-BdIY7IoB.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\tprovidedKeyFor,\n\tpublicEnvFor,\n\tsenderAddress,\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';\nimport { fileServerLabel } from '../workspace/fileServerLabel.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/** Mail's local part — its declaration's `from`. */\n\tfrom?: 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(\n\t\t\tprovidedKeyFor(\n\t\t\t\tid,\n\t\t\t\tdeclaration.kind,\n\t\t\t\tdeclaration.kind === 'objects' ? 'connectionString' : 'url',\n\t\t\t),\n\t\t\tid,\n\t\t);\n\t\tif (declaration.kind === 'email')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'from'), id);\n\t\t// Derived from the connection: a site that holds only where the\n\t\t// bucket signs its links still needs the bucket configured.\n\t\tif (declaration.kind === 'objects')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'signedOrigin'), 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...(declaration.kind === 'email' && declaration.from\n\t\t\t\t\t\t? { from: declaration.from }\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?: StageProviderNote;\n\temail?: StageProviderNote;\n}\n\n/** What the stage's provider says of one kind. */\nexport interface StageProviderNote {\n\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\taccounted: boolean;\n\t/** What creates a missing key of it. */\n\thint?: string;\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 backing = (\n\t\t\tnote: StageProviderNote | undefined,\n\t\t\tservice: DevService,\n\t\t) =>\n\t\t\tnote?.accounted ? (note.hint ? { hint: note.hint } : {}) : { service };\n\t\tconst storage = backing(input.providers?.objects, 'minio');\n\t\tconst mail = backing(input.providers?.email, 'mailpit');\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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\t...mail,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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: senderAddress(d, domain),\n\t\t\t\t...mail,\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: providedKeyFor(d.id, 'objects', 'connectionString'),\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: providedKeyFor(d.id, 'file-server', '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://${fileServerLabel(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: providedKeyFor(d.id, d.kind, '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')\n\t\treturn key === providedKeyFor(id, 'external-api', '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(\n\t\t\t(k) =>\n\t\t\t\tk.kind === 'email' && k.key === providedKeyFor(k.id, 'email', 'url'),\n\t\t)\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, `inbox`, `email` — so a kind\n * such as `deploy.cache` slots in beside them with providers of its 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', 'email'] 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 notes: StageProviderNotes = {};\n\tfor (const kind of ['objects', 'email'] as const) {\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'external') {\n\t\t\tcontinue;\n\t\t}\n\t\tconst hint = provisionHint(workspace, kind, stage);\n\t\tnotes[kind] = { accounted: true, ...(hint ? { hint } : {}) };\n\t}\n\treturn notes;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,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,C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ClB,IAAI,WAAW,IAAI,cAAc,aAAa,EACvD;EAVS,KAAA,OAAA;EACA,KAAA,QAAA;EACA,KAAA,MAAA;EAST,KAAK,OAAO;CACb;AACD;;AAGA,SAAgB,iBAAiB,OAAuB;CACvD,OAAO,sBAAsB;AAC9B;;;;;;AAOA,SAAgB,cACf,WACA,MACA,OACqB;CACrB,MAAM,SAAS,cAAc,WAAoB,MAAM,KAAK;CAC5D,IAAI,OAAO,SAAS,YAAY,OAAO,KAAA;CACvC,MAAM,eAAe,eAAe,MAAM,OAAO,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;CACrB,MAAM,QAA4B,CAAC;CACnC,KAAK,MAAM,QAAQ,CAAC,WAAW,OAAO,GAAY;EACjD,IAAI,cAAc,WAAoB,MAAM,KAAK,CAAC,CAAC,SAAS,YAC3D;EAED,MAAM,OAAO,cAAc,WAAW,MAAM,KAAK;EACjD,MAAM,QAAQ;GAAE,WAAW;GAAM,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EAAG;CAC5D;CACA,OAAO;AACR;;;;;;;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-C23PJFnm.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\tprovidedKeyFor,\n\tpublicEnvFor,\n\tsenderAddress,\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';\nimport { fileServerLabel } from '../workspace/fileServerLabel.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/** Mail's local part — its declaration's `from`. */\n\tfrom?: 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(\n\t\t\tprovidedKeyFor(\n\t\t\t\tid,\n\t\t\t\tdeclaration.kind,\n\t\t\t\tdeclaration.kind === 'objects' ? 'connectionString' : 'url',\n\t\t\t),\n\t\t\tid,\n\t\t);\n\t\tif (declaration.kind === 'email')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'from'), id);\n\t\t// Derived from the connection: a site that holds only where the\n\t\t// bucket signs its links still needs the bucket configured.\n\t\tif (declaration.kind === 'objects')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'signedOrigin'), 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...(declaration.kind === 'email' && declaration.from\n\t\t\t\t\t\t? { from: declaration.from }\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?: StageProviderNote;\n\temail?: StageProviderNote;\n}\n\n/** What the stage's provider says of one kind. */\nexport interface StageProviderNote {\n\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\taccounted: boolean;\n\t/** What creates a missing key of it. */\n\thint?: string;\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 backing = (\n\t\t\tnote: StageProviderNote | undefined,\n\t\t\tservice: DevService,\n\t\t) =>\n\t\t\tnote?.accounted ? (note.hint ? { hint: note.hint } : {}) : { service };\n\t\tconst storage = backing(input.providers?.objects, 'minio');\n\t\tconst mail = backing(input.providers?.email, 'mailpit');\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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\t...mail,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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: senderAddress(d, domain),\n\t\t\t\t...mail,\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: providedKeyFor(d.id, 'objects', 'connectionString'),\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: providedKeyFor(d.id, 'file-server', '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://${fileServerLabel(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: providedKeyFor(d.id, d.kind, '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')\n\t\treturn key === providedKeyFor(id, 'external-api', '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(\n\t\t\t(k) =>\n\t\t\t\tk.kind === 'email' && k.key === providedKeyFor(k.id, 'email', 'url'),\n\t\t)\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, `inbox`, `email` — so a kind\n * such as `deploy.cache` slots in beside them with providers of its 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', 'email'] 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 notes: StageProviderNotes = {};\n\tfor (const kind of ['objects', 'email'] as const) {\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'external') {\n\t\t\tcontinue;\n\t\t}\n\t\tconst hint = provisionHint(workspace, kind, stage);\n\t\tnotes[kind] = { accounted: true, ...(hint ? { hint } : {}) };\n\t}\n\treturn notes;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,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,SAAS,aAAa,EAAE,KAAK,KAAK,IAAI,MAAM;GAC/D,OACC,qBAAqB,EA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AAO,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;CACrB,MAAM,QAA4B,CAAC;CACnC,KAAK,MAAM,QAAQ,CAAC,WAAW,OAAO,GAAY;EACjD,IAAI,cAAc,WAAoB,MAAM,KAAK,CAAC,CAAC,SAAS,YAC3D;EAED,MAAM,OAAO,cAAc,WAAW,MAAM,KAAK;EACjD,MAAM,QAAQ;GAAE,WAAW;GAAM,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EAAG;CAC5D;CACA,OAAO;AACR;;;;;;;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,6 +1,6 @@
1
1
  const require_errors = require("./errors-DMC4Umsb.cjs");
2
- const require_workspace = require("./workspace-LR9DFjU8.cjs");
3
- const require_apps = require("./apps-DYGKg5SP.cjs");
2
+ const require_workspace = require("./workspace-DirP2-ed.cjs");
3
+ const require_apps = require("./apps-CnTjkv-C.cjs");
4
4
  let _geekmidas_manifest = require("@geekmidas/manifest");
5
5
  //#region src/deploy/devServices.ts
6
6
  /**
@@ -507,4 +507,4 @@ Object.defineProperty(exports, "suppliedOnly", {
507
507
  }
508
508
  });
509
509
 
510
- //# sourceMappingURL=notes-ikElBCC8.cjs.map
510
+ //# sourceMappingURL=notes-DOj8AhIz.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"notes-ikElBCC8.cjs","names":["GkmError","providedKeyFor","appKey","appEnvKeys","publicEnvFor","workerEnvKeys","senderAddress","fileServerLabel","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\tprovidedKeyFor,\n\tpublicEnvFor,\n\tsenderAddress,\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';\nimport { fileServerLabel } from '../workspace/fileServerLabel.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/** Mail's local part — its declaration's `from`. */\n\tfrom?: 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(\n\t\t\tprovidedKeyFor(\n\t\t\t\tid,\n\t\t\t\tdeclaration.kind,\n\t\t\t\tdeclaration.kind === 'objects' ? 'connectionString' : 'url',\n\t\t\t),\n\t\t\tid,\n\t\t);\n\t\tif (declaration.kind === 'email')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'from'), id);\n\t\t// Derived from the connection: a site that holds only where the\n\t\t// bucket signs its links still needs the bucket configured.\n\t\tif (declaration.kind === 'objects')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'signedOrigin'), 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...(declaration.kind === 'email' && declaration.from\n\t\t\t\t\t\t? { from: declaration.from }\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?: StageProviderNote;\n\temail?: StageProviderNote;\n}\n\n/** What the stage's provider says of one kind. */\nexport interface StageProviderNote {\n\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\taccounted: boolean;\n\t/** What creates a missing key of it. */\n\thint?: string;\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 backing = (\n\t\t\tnote: StageProviderNote | undefined,\n\t\t\tservice: DevService,\n\t\t) =>\n\t\t\tnote?.accounted ? (note.hint ? { hint: note.hint } : {}) : { service };\n\t\tconst storage = backing(input.providers?.objects, 'minio');\n\t\tconst mail = backing(input.providers?.email, 'mailpit');\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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\t...mail,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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: senderAddress(d, domain),\n\t\t\t\t...mail,\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: providedKeyFor(d.id, 'objects', 'connectionString'),\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: providedKeyFor(d.id, 'file-server', '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://${fileServerLabel(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: providedKeyFor(d.id, d.kind, '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')\n\t\treturn key === providedKeyFor(id, 'external-api', '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(\n\t\t\t(k) =>\n\t\t\t\tk.kind === 'email' && k.key === providedKeyFor(k.id, 'email', 'url'),\n\t\t)\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, `inbox`, `email` — so a kind\n * such as `deploy.cache` slots in beside them with providers of its 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', 'email'] 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 notes: StageProviderNotes = {};\n\tfor (const kind of ['objects', 'email'] as const) {\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'external') {\n\t\t\tcontinue;\n\t\t}\n\t\tconst hint = provisionHint(workspace, kind, stage);\n\t\tnotes[kind] = { accounted: true, ...(hint ? { hint } : {}) };\n\t}\n\treturn notes;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,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,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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AU,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
+ {"version":3,"file":"notes-DOj8AhIz.cjs","names":["GkmError","providedKeyFor","appKey","appEnvKeys","publicEnvFor","workerEnvKeys","senderAddress","fileServerLabel","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\tprovidedKeyFor,\n\tpublicEnvFor,\n\tsenderAddress,\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';\nimport { fileServerLabel } from '../workspace/fileServerLabel.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/** Mail's local part — its declaration's `from`. */\n\tfrom?: 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(\n\t\t\tprovidedKeyFor(\n\t\t\t\tid,\n\t\t\t\tdeclaration.kind,\n\t\t\t\tdeclaration.kind === 'objects' ? 'connectionString' : 'url',\n\t\t\t),\n\t\t\tid,\n\t\t);\n\t\tif (declaration.kind === 'email')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'from'), id);\n\t\t// Derived from the connection: a site that holds only where the\n\t\t// bucket signs its links still needs the bucket configured.\n\t\tif (declaration.kind === 'objects')\n\t\t\towners.set(providedKeyFor(id, declaration.kind, 'signedOrigin'), 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...(declaration.kind === 'email' && declaration.from\n\t\t\t\t\t\t? { from: declaration.from }\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?: StageProviderNote;\n\temail?: StageProviderNote;\n}\n\n/** What the stage's provider says of one kind. */\nexport interface StageProviderNote {\n\t/** A provider (or `false`) backs the kind: no dev service for it. */\n\taccounted: boolean;\n\t/** What creates a missing key of it. */\n\thint?: string;\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 backing = (\n\t\t\tnote: StageProviderNote | undefined,\n\t\t\tservice: DevService,\n\t\t) =>\n\t\t\tnote?.accounted ? (note.hint ? { hint: note.hint } : {}) : { service };\n\t\tconst storage = backing(input.providers?.objects, 'minio');\n\t\tconst mail = backing(input.providers?.email, 'mailpit');\n\t\tfor (const d of services.filter((d) => d.kind === 'email')) {\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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\t...mail,\n\t\t\t\t...apps(d),\n\t\t\t});\n\t\t\tadd({\n\t\t\t\tkey: providedKeyFor(d.id, 'email', '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: senderAddress(d, domain),\n\t\t\t\t...mail,\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: providedKeyFor(d.id, 'objects', 'connectionString'),\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: providedKeyFor(d.id, 'file-server', '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://${fileServerLabel(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: providedKeyFor(d.id, d.kind, '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')\n\t\treturn key === providedKeyFor(id, 'external-api', '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(\n\t\t\t(k) =>\n\t\t\t\tk.kind === 'email' && k.key === providedKeyFor(k.id, 'email', 'url'),\n\t\t)\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, `inbox`, `email` — so a kind\n * such as `deploy.cache` slots in beside them with providers of its 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', 'email'] 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 notes: StageProviderNotes = {};\n\tfor (const kind of ['objects', 'email'] as const) {\n\t\tif (stageProvider(workspace as never, kind, stage).mode === 'external') {\n\t\t\tcontinue;\n\t\t}\n\t\tconst hint = provisionHint(workspace, kind, stage);\n\t\tnotes[kind] = { accounted: true, ...(hint ? { hint } : {}) };\n\t}\n\treturn notes;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,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,KAAK;EACjB,IAAI,IAAI,WAAW,uBAAuB,GACzC,MAAM,IAAI,6BAA6B,IA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AK;EACjD,MAAM,QAAQ;GAAE,WAAW;GAAM,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EAAG;CAC5D;CACA,OAAO;AACR;;;;;;;AAQA,SAAgB,4BACf,WACA,UACA,OACO;CACP,KAAK,MAAM,QAAQ,gBAAgB;EAClC,MAAM,MAAM,aAAa,UAAU,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"}
package/dist/openapi.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env -S npx tsx
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_workspace = require("./workspace-LR9DFjU8.cjs");
3
+ const require_workspace = require("./workspace-DirP2-ed.cjs");
4
4
  const require_EndpointGenerator = require("./EndpointGenerator-C1h_wExz.cjs");
5
5
  const require_config = require("./config.cjs");
6
6
  const require_OpenApiTsGenerator = require("./OpenApiTsGenerator-CzrLGzC0.cjs");
package/dist/openapi.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env -S npx tsx
2
- import { o as appConstructGlobs, ot as appKey } from "./workspace-B0PI9k9p.mjs";
2
+ import { o as appConstructGlobs, ot as appKey } from "./workspace-BBa1Ck5j.mjs";
3
3
  import { c as parseTelemetryFlag, t as EndpointGenerator, u as telemetryArgs } from "./EndpointGenerator-CSKhAD6W.mjs";
4
4
  import { loadWorkspaceConfig } from "./config.mjs";
5
5
  import { t as OpenApiTsGenerator } from "./OpenApiTsGenerator-5xPn-p65.mjs";
@@ -1,5 +1,5 @@
1
1
  const require_errors = require("./errors-DMC4Umsb.cjs");
2
- require("./credentials-BdZhygvW.cjs");
2
+ require("./dns-efZTlePp.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-uidxz03Q.cjs.map
263
+ //# sourceMappingURL=projectBucket-BNxobT1q.cjs.map