@geekmidas/cli 10.0.0-alpha.19 → 10.0.0-alpha.190

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 (436) hide show
  1. package/README.md +323 -380
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-CBKH87_b.mjs +1043 -0
  7. package/dist/EndpointGenerator-CBKH87_b.mjs.map +1 -0
  8. package/dist/EndpointGenerator-iyA3HkOH.cjs +1102 -0
  9. package/dist/EndpointGenerator-iyA3HkOH.cjs.map +1 -0
  10. package/dist/LegacyStateStore-CWiswz6T.mjs +124 -0
  11. package/dist/LegacyStateStore-CWiswz6T.mjs.map +1 -0
  12. package/dist/LegacyStateStore-CuSe37fl.cjs +124 -0
  13. package/dist/LegacyStateStore-CuSe37fl.cjs.map +1 -0
  14. package/dist/LocalStateStore-BciJ_DF0.cjs +178 -0
  15. package/dist/LocalStateStore-BciJ_DF0.cjs.map +1 -0
  16. package/dist/LocalStateStore-CLHasLJI.mjs +167 -0
  17. package/dist/LocalStateStore-CLHasLJI.mjs.map +1 -0
  18. package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs +534 -0
  19. package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs.map +1 -0
  20. package/dist/OpenApiTsGenerator-vy-fOJgs.cjs +539 -0
  21. package/dist/OpenApiTsGenerator-vy-fOJgs.cjs.map +1 -0
  22. package/dist/S3StateStore-BHLRjoj3.cjs +222 -0
  23. package/dist/S3StateStore-BHLRjoj3.cjs.map +1 -0
  24. package/dist/S3StateStore-CTiv2_ON.mjs +223 -0
  25. package/dist/S3StateStore-CTiv2_ON.mjs.map +1 -0
  26. package/dist/SSMStateStore-BqT3MXXb.cjs +204 -0
  27. package/dist/SSMStateStore-BqT3MXXb.cjs.map +1 -0
  28. package/dist/SSMStateStore-D6qqaem2.mjs +205 -0
  29. package/dist/SSMStateStore-D6qqaem2.mjs.map +1 -0
  30. package/dist/SubscriberGenerator-Cfoz8uTY.mjs +787 -0
  31. package/dist/SubscriberGenerator-Cfoz8uTY.mjs.map +1 -0
  32. package/dist/SubscriberGenerator-CxzECrfj.cjs +852 -0
  33. package/dist/SubscriberGenerator-CxzECrfj.cjs.map +1 -0
  34. package/dist/add-B2OmIQzs.cjs +712 -0
  35. package/dist/add-B2OmIQzs.cjs.map +1 -0
  36. package/dist/add-CXwL549o.mjs +710 -0
  37. package/dist/add-CXwL549o.mjs.map +1 -0
  38. package/dist/appPorts-BoXMwolc.mjs +249 -0
  39. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  40. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  41. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  42. package/dist/aws-BXfiWNbi.cjs +108 -0
  43. package/dist/aws-BXfiWNbi.cjs.map +1 -0
  44. package/dist/aws-BjvSTTcE.mjs +97 -0
  45. package/dist/aws-BjvSTTcE.mjs.map +1 -0
  46. package/dist/awsStore-BYYCmXiq.mjs +121 -0
  47. package/dist/awsStore-BYYCmXiq.mjs.map +1 -0
  48. package/dist/awsStore-DKQUElJL.cjs +138 -0
  49. package/dist/awsStore-DKQUElJL.cjs.map +1 -0
  50. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  51. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  52. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  53. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  54. package/dist/backups/runner.cjs +1007 -0
  55. package/dist/backups/runner.cjs.map +1 -0
  56. package/dist/backups/runner.d.cts +187 -0
  57. package/dist/backups/runner.d.cts.map +1 -0
  58. package/dist/backups/runner.d.mts +187 -0
  59. package/dist/backups/runner.d.mts.map +1 -0
  60. package/dist/backups/runner.mjs +984 -0
  61. package/dist/backups/runner.mjs.map +1 -0
  62. package/dist/{bundler-mwH7WOb1.mjs → bundler-CHXyJFsS.mjs} +68 -15
  63. package/dist/bundler-CHXyJFsS.mjs.map +1 -0
  64. package/dist/{bundler-mjqGAvu1.cjs → bundler-CLoVtcBi.cjs} +67 -14
  65. package/dist/bundler-CLoVtcBi.cjs.map +1 -0
  66. package/dist/cli-Bjua3PaZ.mjs +80 -0
  67. package/dist/cli-Bjua3PaZ.mjs.map +1 -0
  68. package/dist/cli-DiuUr1Am.cjs +80 -0
  69. package/dist/cli-DiuUr1Am.cjs.map +1 -0
  70. package/dist/clientTelemetry-DXuYNH-J.d.cts +10 -0
  71. package/dist/clientTelemetry-DXuYNH-J.d.cts.map +1 -0
  72. package/dist/clientTelemetry-eC8VQ6nB.d.mts +10 -0
  73. package/dist/clientTelemetry-eC8VQ6nB.d.mts.map +1 -0
  74. package/dist/compose-DUOETDhc.mjs +2855 -0
  75. package/dist/compose-DUOETDhc.mjs.map +1 -0
  76. package/dist/compose-gnNrY3NQ.cjs +2939 -0
  77. package/dist/compose-gnNrY3NQ.cjs.map +1 -0
  78. package/dist/config-1zirYXeO.d.mts +300 -0
  79. package/dist/config-1zirYXeO.d.mts.map +1 -0
  80. package/dist/config-rSlB-bXj.d.cts +300 -0
  81. package/dist/config-rSlB-bXj.d.cts.map +1 -0
  82. package/dist/config.cjs +462 -9
  83. package/dist/config.cjs.map +1 -0
  84. package/dist/config.d.cts +4 -117
  85. package/dist/config.d.mts +4 -117
  86. package/dist/config.mjs +446 -3
  87. package/dist/config.mjs.map +1 -0
  88. package/dist/credentialSchemas-D_85KW2k.mjs +236 -0
  89. package/dist/credentialSchemas-D_85KW2k.mjs.map +1 -0
  90. package/dist/credentialSchemas-DjK6xKMk.cjs +271 -0
  91. package/dist/credentialSchemas-DjK6xKMk.cjs.map +1 -0
  92. package/dist/credentials-BI52H1ad.cjs +2911 -0
  93. package/dist/credentials-BI52H1ad.cjs.map +1 -0
  94. package/dist/credentials-Cp09PIsc.cjs +1451 -0
  95. package/dist/credentials-Cp09PIsc.cjs.map +1 -0
  96. package/dist/credentials-DbjLhvix.mjs +1140 -0
  97. package/dist/credentials-DbjLhvix.mjs.map +1 -0
  98. package/dist/credentials-VLP_959f.mjs +2390 -0
  99. package/dist/credentials-VLP_959f.mjs.map +1 -0
  100. package/dist/databases-CV22HzrI.mjs +588 -0
  101. package/dist/databases-CV22HzrI.mjs.map +1 -0
  102. package/dist/databases-DwYYH2mX.cjs +703 -0
  103. package/dist/databases-DwYYH2mX.cjs.map +1 -0
  104. package/dist/dbTunnel-CLsqWr7o.mjs +153 -0
  105. package/dist/dbTunnel-CLsqWr7o.mjs.map +1 -0
  106. package/dist/dbTunnel-DQcdaaLi.cjs +153 -0
  107. package/dist/dbTunnel-DQcdaaLi.cjs.map +1 -0
  108. package/dist/define-BfrNaY82.mjs +106 -0
  109. package/dist/define-BfrNaY82.mjs.map +1 -0
  110. package/dist/define-zKgLY65H.cjs +153 -0
  111. package/dist/define-zKgLY65H.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +210 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +659 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +659 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +143 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  121. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  122. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  123. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  124. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  125. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  126. package/dist/deploy/sniffer-hooks.cjs +1 -1
  127. package/dist/deploy/sniffer-hooks.mjs +1 -1
  128. package/dist/deploy/sniffer-loader.cjs +2 -2
  129. package/dist/deploy/sniffer-loader.mjs +1 -1
  130. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  131. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  132. package/dist/deploy-DhIy2Ftj.mjs +3854 -0
  133. package/dist/deploy-DhIy2Ftj.mjs.map +1 -0
  134. package/dist/deploy-DpQ_4Pu1.cjs +3910 -0
  135. package/dist/deploy-DpQ_4Pu1.cjs.map +1 -0
  136. package/dist/destroy-DmTDT6V7.cjs +791 -0
  137. package/dist/destroy-DmTDT6V7.cjs.map +1 -0
  138. package/dist/destroy-wV9yNLQV.mjs +790 -0
  139. package/dist/destroy-wV9yNLQV.mjs.map +1 -0
  140. package/dist/discover-Dfmn6HQ7.mjs +940 -0
  141. package/dist/discover-Dfmn6HQ7.mjs.map +1 -0
  142. package/dist/discover-OXczlq08.cjs +1085 -0
  143. package/dist/discover-OXczlq08.cjs.map +1 -0
  144. package/dist/dokploy-B61ww4Yb.cjs +38 -0
  145. package/dist/dokploy-B61ww4Yb.cjs.map +1 -0
  146. package/dist/dokploy-Jhl3sPd4.mjs +38 -0
  147. package/dist/dokploy-Jhl3sPd4.mjs.map +1 -0
  148. package/dist/drivers-BQRb3KsL.mjs +294 -0
  149. package/dist/drivers-BQRb3KsL.mjs.map +1 -0
  150. package/dist/drivers-DP7__dJX.cjs +377 -0
  151. package/dist/drivers-DP7__dJX.cjs.map +1 -0
  152. package/dist/eas-BmvO40xS.mjs +334 -0
  153. package/dist/eas-BmvO40xS.mjs.map +1 -0
  154. package/dist/eas-X09Gz8_E.cjs +337 -0
  155. package/dist/eas-X09Gz8_E.cjs.map +1 -0
  156. package/dist/emit-C4KSXOeS.mjs +153 -0
  157. package/dist/emit-C4KSXOeS.mjs.map +1 -0
  158. package/dist/emit-DiW0kbue.cjs +164 -0
  159. package/dist/emit-DiW0kbue.cjs.map +1 -0
  160. package/dist/encryption-BBIUewnL.cjs +90 -0
  161. package/dist/encryption-BBIUewnL.cjs.map +1 -0
  162. package/dist/encryption-BOmswIgE.mjs +89 -0
  163. package/dist/encryption-BOmswIgE.mjs.map +1 -0
  164. package/dist/engine-BhjhShKf.cjs +3333 -0
  165. package/dist/engine-BhjhShKf.cjs.map +1 -0
  166. package/dist/engine-DW2H3KNa.mjs +3220 -0
  167. package/dist/engine-DW2H3KNa.mjs.map +1 -0
  168. package/dist/errors-C9uIyIDt.mjs +27 -0
  169. package/dist/errors-C9uIyIDt.mjs.map +1 -0
  170. package/dist/errors-D1x8duqI.cjs +38 -0
  171. package/dist/errors-D1x8duqI.cjs.map +1 -0
  172. package/dist/github-Ptbigbrq.mjs +986 -0
  173. package/dist/github-Ptbigbrq.mjs.map +1 -0
  174. package/dist/github-xUtu4Ur7.cjs +987 -0
  175. package/dist/github-xUtu4Ur7.cjs.map +1 -0
  176. package/dist/googlePlay-B4xhz5xT.cjs +931 -0
  177. package/dist/googlePlay-B4xhz5xT.cjs.map +1 -0
  178. package/dist/googlePlay-C9rrwN5b.mjs +931 -0
  179. package/dist/googlePlay-C9rrwN5b.mjs.map +1 -0
  180. package/dist/iam-D7mXd6by.cjs +521 -0
  181. package/dist/iam-D7mXd6by.cjs.map +1 -0
  182. package/dist/iam-DNlbVN_l.mjs +442 -0
  183. package/dist/iam-DNlbVN_l.mjs.map +1 -0
  184. package/dist/{index-RCUizGxL.d.cts → index-B1gfXH5K.d.mts} +38 -14
  185. package/dist/index-B1gfXH5K.d.mts.map +1 -0
  186. package/dist/{index-B4H4XF7A.d.mts → index-CunkOPOu.d.cts} +38 -14
  187. package/dist/index-CunkOPOu.d.cts.map +1 -0
  188. package/dist/index.cjs +15566 -13457
  189. package/dist/index.cjs.map +1 -1
  190. package/dist/index.mjs +15249 -13138
  191. package/dist/index.mjs.map +1 -1
  192. package/dist/local-CvC-z86k.mjs +224 -0
  193. package/dist/local-CvC-z86k.mjs.map +1 -0
  194. package/dist/local-DAJrhvSC.cjs +241 -0
  195. package/dist/local-DAJrhvSC.cjs.map +1 -0
  196. package/dist/migrate-0-A4BOcd.cjs +272 -0
  197. package/dist/migrate-0-A4BOcd.cjs.map +1 -0
  198. package/dist/migrate-C_36JSwV.mjs +181 -0
  199. package/dist/migrate-C_36JSwV.mjs.map +1 -0
  200. package/dist/migrate-DHbXzZIJ.mjs +267 -0
  201. package/dist/migrate-DHbXzZIJ.mjs.map +1 -0
  202. package/dist/migrate-fGWfv2DV.cjs +181 -0
  203. package/dist/migrate-fGWfv2DV.cjs.map +1 -0
  204. package/dist/next.cjs +59 -0
  205. package/dist/next.cjs.map +1 -0
  206. package/dist/next.d.cts +44 -0
  207. package/dist/next.d.cts.map +1 -0
  208. package/dist/next.d.mts +44 -0
  209. package/dist/next.d.mts.map +1 -0
  210. package/dist/next.mjs +58 -0
  211. package/dist/next.mjs.map +1 -0
  212. package/dist/openapi.cjs +213 -7
  213. package/dist/openapi.cjs.map +1 -0
  214. package/dist/openapi.d.cts +27 -8
  215. package/dist/openapi.d.cts.map +1 -1
  216. package/dist/openapi.d.mts +27 -8
  217. package/dist/openapi.d.mts.map +1 -1
  218. package/dist/openapi.mjs +208 -2
  219. package/dist/openapi.mjs.map +1 -0
  220. package/dist/projectBucket-BAoFOQtA.cjs +263 -0
  221. package/dist/projectBucket-BAoFOQtA.cjs.map +1 -0
  222. package/dist/projectBucket-Dxub09V1.mjs +222 -0
  223. package/dist/projectBucket-Dxub09V1.mjs.map +1 -0
  224. package/dist/provider-BvjDbsTR.mjs +46 -0
  225. package/dist/provider-BvjDbsTR.mjs.map +1 -0
  226. package/dist/provider-DLhgo-mB.cjs +57 -0
  227. package/dist/provider-DLhgo-mB.cjs.map +1 -0
  228. package/dist/publish-BX8_zXaf.cjs +124 -0
  229. package/dist/publish-BX8_zXaf.cjs.map +1 -0
  230. package/dist/publish-DE_yBzlz.mjs +123 -0
  231. package/dist/publish-DE_yBzlz.mjs.map +1 -0
  232. package/dist/ready-DCvnFZnJ.cjs +404 -0
  233. package/dist/ready-DCvnFZnJ.cjs.map +1 -0
  234. package/dist/ready-sSPuiZ7N.mjs +375 -0
  235. package/dist/ready-sSPuiZ7N.mjs.map +1 -0
  236. package/dist/reconcile/public.cjs +3 -5
  237. package/dist/reconcile/public.d.cts +33 -89
  238. package/dist/reconcile/public.d.cts.map +1 -1
  239. package/dist/reconcile/public.d.mts +33 -89
  240. package/dist/reconcile/public.d.mts.map +1 -1
  241. package/dist/reconcile/public.mjs +3 -3
  242. package/dist/reconcile--I7V4Klj.mjs +34 -0
  243. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  244. package/dist/reconcile-CuCQBa5-.cjs +34 -0
  245. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  246. package/dist/resolve-CPB2jkB4.cjs +316 -0
  247. package/dist/resolve-CPB2jkB4.cjs.map +1 -0
  248. package/dist/resolve-DCPtP7-X.mjs +263 -0
  249. package/dist/resolve-DCPtP7-X.mjs.map +1 -0
  250. package/dist/rollback-sefKrjlE.mjs +137 -0
  251. package/dist/rollback-sefKrjlE.mjs.map +1 -0
  252. package/dist/rollback-ygh2qRWo.cjs +166 -0
  253. package/dist/rollback-ygh2qRWo.cjs.map +1 -0
  254. package/dist/runtime-BwiWhqkI.d.cts +82 -0
  255. package/dist/runtime-BwiWhqkI.d.cts.map +1 -0
  256. package/dist/runtime-Dx5F8-IL.d.mts +82 -0
  257. package/dist/runtime-Dx5F8-IL.d.mts.map +1 -0
  258. package/dist/s3-Bcvbg8io.cjs +240 -0
  259. package/dist/s3-Bcvbg8io.cjs.map +1 -0
  260. package/dist/s3-DK1ofU4f.mjs +240 -0
  261. package/dist/s3-DK1ofU4f.mjs.map +1 -0
  262. package/dist/sandbox/config-worker.cjs +43 -0
  263. package/dist/sandbox/config-worker.cjs.map +1 -0
  264. package/dist/sandbox/config-worker.d.cts +1 -0
  265. package/dist/sandbox/config-worker.d.mts +1 -0
  266. package/dist/sandbox/config-worker.mjs +44 -0
  267. package/dist/sandbox/config-worker.mjs.map +1 -0
  268. package/dist/sandbox/credentials-worker.cjs +53 -0
  269. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  270. package/dist/sandbox/credentials-worker.d.cts +1 -0
  271. package/dist/sandbox/credentials-worker.d.mts +1 -0
  272. package/dist/sandbox/credentials-worker.mjs +54 -0
  273. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  274. package/dist/sandbox/discover-worker.cjs +47 -0
  275. package/dist/sandbox/discover-worker.cjs.map +1 -0
  276. package/dist/sandbox/discover-worker.d.cts +1 -0
  277. package/dist/sandbox/discover-worker.d.mts +1 -0
  278. package/dist/sandbox/discover-worker.mjs +48 -0
  279. package/dist/sandbox/discover-worker.mjs.map +1 -0
  280. package/dist/sandbox/migrate-worker.cjs +75 -0
  281. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  282. package/dist/sandbox/migrate-worker.d.cts +1 -0
  283. package/dist/sandbox/migrate-worker.d.mts +1 -0
  284. package/dist/sandbox/migrate-worker.mjs +76 -0
  285. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  286. package/dist/{workspace-CRD9YinV.cjs → schemas-BCwKKA42.mjs} +399 -1179
  287. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  288. package/dist/{workspace-Bu3xNCej.mjs → schemas-BQ_v0lEX.cjs} +487 -982
  289. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  290. package/dist/secretsManager-CjTo6CRq.mjs +113 -0
  291. package/dist/secretsManager-CjTo6CRq.mjs.map +1 -0
  292. package/dist/secretsManager-CvmBGjdM.cjs +124 -0
  293. package/dist/secretsManager-CvmBGjdM.cjs.map +1 -0
  294. package/dist/seeds-Bc3niNVb.cjs +382 -0
  295. package/dist/seeds-Bc3niNVb.cjs.map +1 -0
  296. package/dist/seeds-Ccn0Ru2T.mjs +299 -0
  297. package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
  298. package/dist/serverSetup-ClU2iSeU.cjs +686 -0
  299. package/dist/serverSetup-ClU2iSeU.cjs.map +1 -0
  300. package/dist/serverSetup-D68Otrp0.mjs +686 -0
  301. package/dist/serverSetup-D68Otrp0.mjs.map +1 -0
  302. package/dist/sniffer-CFOmQQit.cjs +1997 -0
  303. package/dist/sniffer-CFOmQQit.cjs.map +1 -0
  304. package/dist/sniffer-CRF3eD_B.mjs +1824 -0
  305. package/dist/sniffer-CRF3eD_B.mjs.map +1 -0
  306. package/dist/snsSubscriptions-CwA6Ceg2.mjs +1024 -0
  307. package/dist/snsSubscriptions-CwA6Ceg2.mjs.map +1 -0
  308. package/dist/snsSubscriptions-S_CMCXqI.cjs +1149 -0
  309. package/dist/snsSubscriptions-S_CMCXqI.cjs.map +1 -0
  310. package/dist/sst-BgG7dJJu.cjs +514 -0
  311. package/dist/sst-BgG7dJJu.cjs.map +1 -0
  312. package/dist/sst-CDnHFO3U.mjs +491 -0
  313. package/dist/sst-CDnHFO3U.mjs.map +1 -0
  314. package/dist/stack-BXmLQf3K.mjs +10920 -0
  315. package/dist/stack-BXmLQf3K.mjs.map +1 -0
  316. package/dist/stack-BtnflNSa.cjs +11901 -0
  317. package/dist/stack-BtnflNSa.cjs.map +1 -0
  318. package/dist/stage-BbQidxxa.mjs +302 -0
  319. package/dist/stage-BbQidxxa.mjs.map +1 -0
  320. package/dist/stage-ssuPXLhP.cjs +331 -0
  321. package/dist/stage-ssuPXLhP.cjs.map +1 -0
  322. package/dist/stages-CQwD2QxS.cjs +190 -0
  323. package/dist/stages-CQwD2QxS.cjs.map +1 -0
  324. package/dist/stages-MA2sXnX4.mjs +190 -0
  325. package/dist/stages-MA2sXnX4.mjs.map +1 -0
  326. package/dist/target/public.cjs +15 -0
  327. package/dist/target/public.d.cts +28 -0
  328. package/dist/target/public.d.cts.map +1 -0
  329. package/dist/target/public.d.mts +28 -0
  330. package/dist/target/public.d.mts.map +1 -0
  331. package/dist/target/public.mjs +4 -0
  332. package/dist/terminal-BEGE1AEV.mjs +85 -0
  333. package/dist/terminal-BEGE1AEV.mjs.map +1 -0
  334. package/dist/terminal-BecJpgA3.cjs +85 -0
  335. package/dist/terminal-BecJpgA3.cjs.map +1 -0
  336. package/dist/{types-7R81hu0i.d.mts → types-BvokH0ya.d.cts} +2235 -459
  337. package/dist/types-BvokH0ya.d.cts.map +1 -0
  338. package/dist/{types-N7c2O2m7.d.cts → types-DmLnGeii.d.mts} +2233 -459
  339. package/dist/types-DmLnGeii.d.mts.map +1 -0
  340. package/dist/utils-CdKxD8Lt.mjs +156 -0
  341. package/dist/utils-CdKxD8Lt.mjs.map +1 -0
  342. package/dist/utils-DBqXbB8P.cjs +205 -0
  343. package/dist/utils-DBqXbB8P.cjs.map +1 -0
  344. package/dist/vitest.cjs +65 -0
  345. package/dist/vitest.cjs.map +1 -0
  346. package/dist/vitest.d.cts +29 -0
  347. package/dist/vitest.d.cts.map +1 -0
  348. package/dist/vitest.d.mts +29 -0
  349. package/dist/vitest.d.mts.map +1 -0
  350. package/dist/vitest.mjs +65 -0
  351. package/dist/vitest.mjs.map +1 -0
  352. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  353. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  354. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  355. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  356. package/dist/workspace/index.cjs +6 -2
  357. package/dist/workspace/index.d.cts +3 -3
  358. package/dist/workspace/index.d.mts +3 -3
  359. package/dist/workspace/index.mjs +2 -2
  360. package/dist/workspace-DEmfa9RO.cjs +3689 -0
  361. package/dist/workspace-DEmfa9RO.cjs.map +1 -0
  362. package/dist/workspace-RgU7TBgg.mjs +3133 -0
  363. package/dist/workspace-RgU7TBgg.mjs.map +1 -0
  364. package/package.json +76 -13
  365. package/dist/HostingerProvider-BY26bWwB.mjs +0 -243
  366. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  367. package/dist/HostingerProvider-BZFGYYVA.cjs +0 -243
  368. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  369. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  370. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  371. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  372. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  373. package/dist/Route53Provider-Cvj40A8I.mjs +0 -209
  374. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  375. package/dist/Route53Provider-DVILBsvV.cjs +0 -209
  376. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  377. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  378. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  379. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  380. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  381. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  382. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  383. package/dist/bundler-mjqGAvu1.cjs.map +0 -1
  384. package/dist/bundler-mwH7WOb1.mjs.map +0 -1
  385. package/dist/config-DSXI480r.cjs +0 -467
  386. package/dist/config-DSXI480r.cjs.map +0 -1
  387. package/dist/config-DdKkoUE1.mjs +0 -414
  388. package/dist/config-DdKkoUE1.mjs.map +0 -1
  389. package/dist/config.d.cts.map +0 -1
  390. package/dist/config.d.mts.map +0 -1
  391. package/dist/credentials-C6Pfn6GY.cjs +0 -2939
  392. package/dist/credentials-C6Pfn6GY.cjs.map +0 -1
  393. package/dist/credentials-lbv-j0Be.mjs +0 -2802
  394. package/dist/credentials-lbv-j0Be.mjs.map +0 -1
  395. package/dist/discover-BERGFg8v.cjs +0 -288
  396. package/dist/discover-BERGFg8v.cjs.map +0 -1
  397. package/dist/discover-CK-n3w6b.mjs +0 -244
  398. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  399. package/dist/emit-BdoPFjZf.cjs +0 -253
  400. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  401. package/dist/emit-Bzq7JsMP.mjs +0 -224
  402. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  403. package/dist/generator-LfZU7NlU.mjs +0 -247
  404. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  405. package/dist/generator-Wdfp0jCS.cjs +0 -282
  406. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  407. package/dist/github-BvfpvBcW.cjs +0 -216
  408. package/dist/github-BvfpvBcW.cjs.map +0 -1
  409. package/dist/github-DW3CP-4D.mjs +0 -216
  410. package/dist/github-DW3CP-4D.mjs.map +0 -1
  411. package/dist/index-B4H4XF7A.d.mts.map +0 -1
  412. package/dist/index-RCUizGxL.d.cts.map +0 -1
  413. package/dist/openapi-B8bu_OXN.cjs +0 -2038
  414. package/dist/openapi-B8bu_OXN.cjs.map +0 -1
  415. package/dist/openapi-DfjbhrsM.mjs +0 -1991
  416. package/dist/openapi-DfjbhrsM.mjs.map +0 -1
  417. package/dist/reconcile-gb1lz1Dk.mjs +0 -113
  418. package/dist/reconcile-gb1lz1Dk.mjs.map +0 -1
  419. package/dist/reconcile-hx_vBvux.cjs +0 -136
  420. package/dist/reconcile-hx_vBvux.cjs.map +0 -1
  421. package/dist/ssm-BKN1Cg4z.mjs +0 -60
  422. package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
  423. package/dist/ssm-FxeSAt35.cjs +0 -60
  424. package/dist/ssm-FxeSAt35.cjs.map +0 -1
  425. package/dist/storage-DgypfSD6.cjs +0 -351
  426. package/dist/storage-DgypfSD6.cjs.map +0 -1
  427. package/dist/storage-TP0x118M.mjs +0 -304
  428. package/dist/storage-TP0x118M.mjs.map +0 -1
  429. package/dist/transfer-DjFZRgub.mjs +0 -122
  430. package/dist/transfer-DjFZRgub.mjs.map +0 -1
  431. package/dist/transfer-SeiSeKEF.cjs +0 -151
  432. package/dist/transfer-SeiSeKEF.cjs.map +0 -1
  433. package/dist/types-7R81hu0i.d.mts.map +0 -1
  434. package/dist/types-N7c2O2m7.d.cts.map +0 -1
  435. package/dist/workspace-Bu3xNCej.mjs.map +0 -1
  436. package/dist/workspace-CRD9YinV.cjs.map +0 -1
@@ -0,0 +1,2390 @@
1
+ import { t as GkmError } from "./errors-C9uIyIDt.mjs";
2
+ import { E as keystoreProject, O as readKey, Q as gkmHome, S as encrypt, T as getOrCreateKey, b as FileSecretsStore, h as toEmbeddableSecrets, l as secretsStoreFor, w as getKeystoreDir, x as decrypt } from "./credentials-DbjLhvix.mjs";
3
+ import { B as LOGS_PORT, R as stageSampleRate, ct as protectedSubdomains, dt as fileServerLabel, ot as appKey, v as getPublicEnvPrefix } from "./workspace-RgU7TBgg.mjs";
4
+ import { p as holdsEveryCache, u as DEFAULT_CACHE } from "./drivers-BQRb3KsL.mjs";
5
+ import { ConfigNotFound, NotInAnApp, loadWorkspaceAppInfo, loadWorkspaceConfig } from "./config.mjs";
6
+ import { dirname, join, resolve } from "node:path";
7
+ import { existsSync } from "node:fs";
8
+ import { mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
9
+ import { createServer } from "node:net";
10
+ import { createHash, randomBytes, randomInt } from "node:crypto";
11
+ import { DEFAULT_POSTGRES_VERSION, TELEMETRY_KEYS, WILDCARD_SUBDOMAIN, bucketExpiry, dependentsOf, drawSecret, hostLabels, imageOriginsFor, isHostedDeclaration, isPublicDeclaration, isWildcardSite, kebabCase, providedKeyFor, publicEnvFor, publicStageKey } from "@geekmidas/manifest";
12
+ import { stringify } from "yaml";
13
+ import { generateKeyring } from "@geekmidas/constructs/encryption";
14
+ import { config } from "dotenv";
15
+ //#region src/workspace/rootSite.ts
16
+ /**
17
+ * Which site the base domain points at — deployed and locally alike.
18
+ *
19
+ * Three rules, in order, and the last one is the point:
20
+ *
21
+ * 1. **One site** — it is the root. Unambiguous, so nothing has to be said.
22
+ * 2. **Named `web`** — the convention wins, because people already rely on it.
23
+ * 3. **Declared `root: true`** — the site says so itself.
24
+ *
25
+ * Anything else throws. It used to take the *first* site it iterated, and that
26
+ * order came from the manifest, which is built in glob traversal order — so two
27
+ * sites with neither named `web` meant renaming a file could move the root
28
+ * domain, silently.
29
+ *
30
+ * One rule for both targets: deployed the root site gets the base domain, and
31
+ * locally it gets the project's bare host behind the edge. Before this was
32
+ * shared, the local edge put every site on a subdomain, so what a developer
33
+ * browsed was not the shape production served.
34
+ *
35
+ * @returns the root site's name, or `undefined` when there are no sites
36
+ * @throws {AmbiguousRootSite} when several sites could be the root and none says it is
37
+ */
38
+ function rootSite(sites) {
39
+ if (sites.length === 0) return void 0;
40
+ if (sites.length === 1) return sites[0].name;
41
+ if (sites.some(({ name }) => name === "web")) return "web";
42
+ const declared = sites.filter(({ root }) => root === true);
43
+ if (declared.length === 1) return declared[0].name;
44
+ throw new AmbiguousRootSite(sites.map(({ name }) => name), declared.length > 1);
45
+ }
46
+ /** Several sites could hold the base domain, and none of them says it does. */
47
+ var AmbiguousRootSite = class extends GkmError {
48
+ sites;
49
+ tooMany;
50
+ constructor(sites, tooMany = false) {
51
+ super(tooMany ? `More than one site declares \`root: true\` — ${sites.join(", ")}. The base domain points at one of them.` : `${sites.length} sites and nothing says which holds the base domain: ${sites.join(", ")}. Name one of them \`web\`, or declare \`root: true\` on the one the base domain points at. It used to be whichever the glob reached first, which is not a thing to decide a hostname.`);
52
+ this.sites = sites;
53
+ this.tooMany = tooMany;
54
+ this.name = "AmbiguousRootSite";
55
+ }
56
+ };
57
+ //#endregion
58
+ //#region src/target/dokploy/domain.ts
59
+ /** A stage was deployed that `domains` gives no domain. */
60
+ var NoDomainForStage = class extends GkmError {
61
+ stage;
62
+ constructor(stage) {
63
+ super(`No domain for stage "${stage}". Add it to gkm.config.ts: domains: { ${stage}: 'example.com' }.`);
64
+ this.stage = stage;
65
+ this.name = "NoDomainForStage";
66
+ }
67
+ };
68
+ /**
69
+ * The hostname an app answers on for a stage.
70
+ *
71
+ * 1. An explicit `app.domain` — a string, or one per stage — wins.
72
+ * 2. Otherwise from the stage's base domain in `domains`: the root site
73
+ * answers on the domain itself, and every other app on
74
+ * `{subdomain}.{domain}` — its declaration's `subdomain`, or its own name.
75
+ *
76
+ * @throws {NoDomainForStage} when `domains` names no domain for it
77
+ */
78
+ function resolveHost(appName, app, stage, domains, isMainFrontend) {
79
+ if (app.domain) {
80
+ if (typeof app.domain === "string") return app.domain;
81
+ if (app.domain[stage]) return app.domain[stage];
82
+ }
83
+ const baseDomain = domains?.[stage];
84
+ if (!baseDomain) throw new NoDomainForStage(stage);
85
+ if (isMainFrontend) return baseDomain;
86
+ return `${app.subdomain ?? appName}.${baseDomain}`;
87
+ }
88
+ /**
89
+ * Whether this app is the site the base domain points at — see `rootSite`,
90
+ * which the local edge asks too.
91
+ *
92
+ * @throws {AmbiguousRootSite} when several sites could be the root and none says it is
93
+ */
94
+ function isMainFrontendApp(appName, app, allApps) {
95
+ const holds = (a) => a.type === "web" && a.subdomain !== WILDCARD_SUBDOMAIN;
96
+ if (!holds(app)) return false;
97
+ return rootSite(Object.entries(allApps).filter(([, a]) => holds(a)).map(([name, a]) => ({
98
+ name,
99
+ root: a.root
100
+ }))) === appName;
101
+ }
102
+ /**
103
+ * Get public URL arg names from app dependencies.
104
+ *
105
+ * @param app - The web/mobile app configuration
106
+ * @returns Array of arg names like 'NEXT_PUBLIC_API_URL', or [] for frameworks
107
+ * without a public prefix (e.g. Remix).
108
+ */
109
+ function getPublicUrlArgNames(app) {
110
+ const prefix = getPublicEnvPrefix(app.framework);
111
+ if (!prefix) return [];
112
+ return app.dependencies.map((dep) => `${prefix}${dep.toUpperCase()}_URL`);
113
+ }
114
+ //#endregion
115
+ //#region src/compose/logs.ts
116
+ /**
117
+ * The stack's log UI: OpenObserve, run beside the apps as telemetry's
118
+ * self-hosted provider, and every process with a `Telemetry` edge pointed at
119
+ * it.
120
+ *
121
+ * The production server already exports its traces and pino logs over
122
+ * OTLP/HTTP when `OTEL_EXPORTER_OTLP_ENDPOINT` is set. OpenObserve takes OTLP
123
+ * at `/api/<org>/v1/{logs,traces}` with HTTP basic auth, so wiring an app is
124
+ * two variables: the endpoint, `http://openobserve:5080/api/default`, and
125
+ * the header that signs in as the root user.
126
+ *
127
+ * It is reached, by default, through an SSH tunnel: published on 127.0.0.1
128
+ * only, because a port Docker publishes on every interface is opened in the
129
+ * firewall by Docker itself, past ufw's rules. Served publicly, it is a host
130
+ * on the stack's edge — the `Telemetry` construct's label under the stage's
131
+ * domain — that refuses every address not allowed.
132
+ *
133
+ * Pure: the stack decides it, and the phases print and check it.
134
+ */
135
+ /**
136
+ * The image, pinned — unless the `Telemetry` construct names its own. A log
137
+ * store's on-disk format is the thing that must not move under a running
138
+ * stack, so a new version is a change to this line, or to the construct's.
139
+ */
140
+ const OPENOBSERVE_IMAGE = "public.ecr.aws/zinclabs/openobserve:v1.0.4";
141
+ /** Its compose service name — the host the apps send to. */
142
+ const LOGS_SERVICE = "openobserve";
143
+ /** The organisation every app's telemetry lands in. */
144
+ const LOGS_ORG = "default";
145
+ /** The stage secrets that sign in as OpenObserve's root user. */
146
+ const LOGS_EMAIL_KEY = "ZO_ROOT_USER_EMAIL";
147
+ const LOGS_PASSWORD_KEY = "ZO_ROOT_USER_PASSWORD";
148
+ /**
149
+ * The local stage's root user. Its password is generated per machine with
150
+ * the other local logins — see `reconcile/localCredentials.ts`.
151
+ */
152
+ const LOCAL_LOGS_EMAIL = "admin@gkm.localhost";
153
+ /** A root password OpenObserve would refuse to start with. */
154
+ var LogsPasswordWeak = class extends GkmError {
155
+ stage;
156
+ constructor(stage) {
157
+ super(`The stage '${stage}' sets ${LOGS_PASSWORD_KEY}, and OpenObserve refuses it: a root password must be 8 to 128 characters with a lowercase letter, an uppercase letter, a digit and a symbol. Set another with gkm secrets:set ${LOGS_PASSWORD_KEY} '…' --stage ${stage}, or unset it to have one generated.`);
158
+ this.stage = stage;
159
+ this.name = "LogsPasswordWeak";
160
+ }
161
+ };
162
+ /**
163
+ * The loopback port a stage's OpenObserve is published on is held by another
164
+ * stack on its server — two stages on one machine, both on `5080`.
165
+ */
166
+ var LogsPortTaken = class extends GkmError {
167
+ stage;
168
+ port;
169
+ holder;
170
+ named;
171
+ constructor(stage, port, holder, named) {
172
+ super(named ? `deploy.telemetry.${stage}.port is ${port}, and '${holder}' already publishes ${port} on this server. Give the stage another: deploy.telemetry.${stage}.port = ${port + 1}, or remove port to have a free one picked.` : `No loopback port from ${port} up is free for the stage '${stage}'s OpenObserve on this server ('${holder}' holds the last one tried). Set one: deploy.telemetry.${stage}.port = <free port>.`);
173
+ this.stage = stage;
174
+ this.port = port;
175
+ this.holder = holder;
176
+ this.named = named;
177
+ this.name = "LogsPortTaken";
178
+ }
179
+ };
180
+ /** A deployed stage with logs on and no root login stored yet. */
181
+ var LogsLoginMissing = class extends GkmError {
182
+ stage;
183
+ constructor(stage) {
184
+ super(`The stage '${stage}' runs OpenObserve and has no ${LOGS_EMAIL_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to store it, or set the login its OpenObserve already has: gkm secrets:set ${LOGS_EMAIL_KEY} admin@… --stage ${stage}`);
185
+ this.stage = stage;
186
+ this.name = "LogsLoginMissing";
187
+ }
188
+ };
189
+ /** A deployed stage with logs on and no root password generated yet. */
190
+ var LogsPasswordMissing = class extends GkmError {
191
+ stage;
192
+ constructor(stage) {
193
+ super(`The stage '${stage}' runs OpenObserve and has no ${LOGS_PASSWORD_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to generate it, or set one: gkm secrets:set ${LOGS_PASSWORD_KEY} '…' --stage ${stage}`);
194
+ this.stage = stage;
195
+ this.name = "LogsPasswordMissing";
196
+ }
197
+ };
198
+ /** Whether OpenObserve accepts `password` for its root user. */
199
+ function isStrongLogsPassword(password) {
200
+ return password.length >= 8 && password.length <= 128 && /[a-z]/.test(password) && /[A-Z]/.test(password) && /\d/.test(password) && /[^A-Za-z0-9]/.test(password);
201
+ }
202
+ /**
203
+ * A root password: 192 random bits, with a fixed tail so every class
204
+ * OpenObserve requires is present whatever the random part drew.
205
+ */
206
+ function generateLogsPassword() {
207
+ return `${randomBytes(24).toString("base64url")}-Zo1`;
208
+ }
209
+ /**
210
+ * The stage's secrets with its root login stored, where they hold none:
211
+ * a generated password, and the email `admin@<stage domain>`.
212
+ *
213
+ * Stored once and read ever after, never derived again: OpenObserve creates
214
+ * its root user from these only on its first start, in its data volume, so a
215
+ * login computed afresh on each deploy would leave the stored user behind
216
+ * the moment what it was computed from — the stage's domain — moved. The
217
+ * first email is the one every stage's OpenObserve was created with before
218
+ * the login was stored, so a running stage keeps signing in.
219
+ *
220
+ * Pure, like `withGeneratedSecrets`: the caller keeps the result once the
221
+ * run goes ahead.
222
+ */
223
+ function withLogsLogin(secrets, domain) {
224
+ const custom = { ...secrets.custom };
225
+ const generated = [];
226
+ if (!custom["ZO_ROOT_USER_EMAIL"] && domain) {
227
+ custom[LOGS_EMAIL_KEY] = `admin@${domain}`;
228
+ generated.push(LOGS_EMAIL_KEY);
229
+ }
230
+ if (!custom["ZO_ROOT_USER_PASSWORD"]) {
231
+ custom[LOGS_PASSWORD_KEY] = generateLogsPassword();
232
+ generated.push(LOGS_PASSWORD_KEY);
233
+ }
234
+ if (generated.length === 0) return {
235
+ secrets,
236
+ generated
237
+ };
238
+ return {
239
+ secrets: {
240
+ ...secrets,
241
+ custom,
242
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
243
+ },
244
+ generated
245
+ };
246
+ }
247
+ /**
248
+ * `OTEL_EXPORTER_OTLP_HEADERS` signing in as `email`.
249
+ *
250
+ * The variable's values are percent-decoded by the SDK (they follow the W3C
251
+ * baggage format), so the space after `Basic` is written `%20`. Base64's own
252
+ * `+`, `/` and `=` pass through decoding unchanged.
253
+ */
254
+ function otlpHeaders(email, password) {
255
+ return `Authorization=Basic%20${Buffer.from(`${email}:${password}`).toString("base64")}`;
256
+ }
257
+ /** The stack's OpenObserve for one stage. */
258
+ function stackLogs(options) {
259
+ const { config, stage, local, custom } = options;
260
+ if (!local && !options.domain) throw new NoDomainForStage(stage);
261
+ const email = custom["ZO_ROOT_USER_EMAIL"] ?? (local ? options.localLogin?.email ?? "admin@gkm.localhost" : void 0);
262
+ if (!email) throw new LogsLoginMissing(stage);
263
+ const set = custom[LOGS_PASSWORD_KEY];
264
+ const password = set ?? (local ? options.localLogin?.password : void 0);
265
+ if (!password) throw new LogsPasswordMissing(stage);
266
+ if (!isStrongLogsPassword(password)) throw new LogsPasswordWeak(stage);
267
+ const { label } = options.telemetry;
268
+ const host = config.public ? local ? `${label}.${options.project}.localhost` : `${label}.${options.domain}` : void 0;
269
+ const url = host ? `https://${host}${local && options.https !== 443 ? `:${options.https}` : ""}` : loopbackUrl(config.port);
270
+ return {
271
+ ...config,
272
+ email,
273
+ password,
274
+ passwordFromSecrets: Boolean(set),
275
+ url,
276
+ ...host ? { host } : {},
277
+ image: options.telemetry.image ?? "public.ecr.aws/zinclabs/openobserve:v1.0.4",
278
+ env: {
279
+ [LOGS_EMAIL_KEY]: email,
280
+ [LOGS_PASSWORD_KEY]: password,
281
+ ZO_DATA_DIR: "/data",
282
+ ZO_COMPACT_DATA_RETENTION_DAYS: String(config.retentionDays),
283
+ ZO_TELEMETRY: "false"
284
+ },
285
+ appEnv: {
286
+ OTEL_EXPORTER_OTLP_ENDPOINT: `http://${LOGS_SERVICE}:${LOGS_PORT}/api/${LOGS_ORG}`,
287
+ OTEL_EXPORTER_OTLP_HEADERS: otlpHeaders(email, password)
288
+ }
289
+ };
290
+ }
291
+ /** Where a browser opens a loopback-published OpenObserve: the tunnel's end. */
292
+ function loopbackUrl(port) {
293
+ return `http://localhost:${port}`;
294
+ }
295
+ /**
296
+ * The stack's OpenObserve published on another loopback port — the one the
297
+ * server has free for it (`logsPortOnServer`). Served publicly, it publishes
298
+ * none, and is returned as it is.
299
+ */
300
+ function logsOnPort(logs, port) {
301
+ if (logs.public || logs.port === port) return logs;
302
+ return {
303
+ ...logs,
304
+ port,
305
+ url: loopbackUrl(port)
306
+ };
307
+ }
308
+ /**
309
+ * What OpenObserve's service publishes: its port on the server's loopback
310
+ * only — Docker opens a port it publishes on every interface in the firewall
311
+ * itself, past ufw — and nothing when it is served through the edge.
312
+ */
313
+ function logsPorts(logs) {
314
+ return logs.public ? {} : { ports: [`127.0.0.1:${logs.port}:${LOGS_PORT}`] };
315
+ }
316
+ /**
317
+ * OpenObserve's service. The image has no shell, `wget` or `curl`, so its
318
+ * health check is its own binary asking the running server for its status —
319
+ * which exits non-zero when nothing answers on its port.
320
+ */
321
+ function logsService(logs) {
322
+ return {
323
+ image: logs.image,
324
+ restart: "unless-stopped",
325
+ env_file: [{
326
+ path: `./${LOGS_SERVICE}.env`,
327
+ format: "raw"
328
+ }],
329
+ volumes: ["openobserve-data:/data"],
330
+ ...logsPorts(logs),
331
+ healthcheck: {
332
+ test: [
333
+ "CMD",
334
+ "/openobserve",
335
+ "node",
336
+ "status"
337
+ ],
338
+ interval: "10s",
339
+ timeout: "5s",
340
+ retries: 12,
341
+ start_period: "20s"
342
+ }
343
+ };
344
+ }
345
+ /** What `gkm compose` prints once the stack is up: how to open the logs. */
346
+ function logsAccess(logs, ctx) {
347
+ const login = `login: ${logs.email}, password: ${ctx.local && !logs.passwordFromSecrets ? logs.password : `gkm secrets:show --stage ${ctx.stage} --reveal → ${LOGS_PASSWORD_KEY}`}`;
348
+ if (logs.public) return [`📜 Logs (OpenObserve): ${logs.url} (${login})`, ` answered only for ${logs.public.allow.join(", ")}; every other address gets 403`];
349
+ return [
350
+ `📜 Logs (OpenObserve) on 127.0.0.1:${logs.port} — from your computer:`,
351
+ ...ctx.local ? [` on this machine, open http://localhost:${logs.port} directly; from another:`] : [],
352
+ ` ssh -N -L ${logs.port}:localhost:${logs.port} ${ctx.user}@${ctx.hostname}${ctx.known ? "" : " (user and host are guesses: this machine's)"}`,
353
+ ` then open http://localhost:${logs.port} (${login})`,
354
+ `⚠️ Docker-published ports bypass ufw, so OpenObserve is bound to 127.0.0.1 only — reach it through the tunnel, not by opening the port.`
355
+ ];
356
+ }
357
+ //#endregion
358
+ //#region src/reconcile/containers.ts
359
+ /**
360
+ * What gkm knows about each container it can derive.
361
+ *
362
+ * Everything provider-specific about the local target lives here: the image, the
363
+ * ports the image listens on, and whether its data is worth keeping. The plan
364
+ * says *which* containers exist and never says any of this, which is the split
365
+ * the design asks for — neutral facts from the declaration, provider detail
366
+ * from here and from config.
367
+ *
368
+ * Shared by allocation and by the compose writer so the two cannot disagree
369
+ * about how many ports a container needs.
370
+ */
371
+ /**
372
+ * The Postgres image for a major version.
373
+ *
374
+ * One place that knows the tag shape, so a declared version reaches the
375
+ * container without anyone restating `-alpine` beside it.
376
+ */
377
+ function postgresImage(version) {
378
+ return `postgres:${version}-alpine`;
379
+ }
380
+ /**
381
+ * The default image for each container.
382
+ *
383
+ * Pinned to a major rather than `latest` where the image publishes one, so a
384
+ * rebuild does not silently move a developer's Postgres a version. A database
385
+ * can name its own (`image: 'postgis/postgis:…'`); any other pin is the
386
+ * project's own `docker-compose.yml`.
387
+ */
388
+ const DEFAULT_IMAGES = {
389
+ postgres: postgresImage(DEFAULT_POSTGRES_VERSION),
390
+ minio: "pgsty/minio:RELEASE.2026-08-04T00-00-00Z",
391
+ mailpit: "axllent/mailpit:latest",
392
+ redis: "redis:8-alpine",
393
+ "redis-http": "hiett/serverless-redis-http:latest",
394
+ rabbitmq: "rabbitmq:4-management-alpine",
395
+ localstack: "floci/floci:2.1.0",
396
+ caddy: "caddy:2-alpine",
397
+ openobserve: OPENOBSERVE_IMAGE
398
+ };
399
+ /**
400
+ * The ports each container listens on.
401
+ *
402
+ * The first is always the one an app connects to; the rest are consoles and
403
+ * management UIs, published because a bucket or an inbox you can look at is most
404
+ * of why these are real containers rather than stubs.
405
+ */
406
+ const PORTS = {
407
+ postgres: [{
408
+ key: "postgres",
409
+ inside: 5432,
410
+ label: "postgres"
411
+ }],
412
+ minio: [{
413
+ key: "minio",
414
+ inside: 9e3,
415
+ label: "minio api"
416
+ }, {
417
+ key: "minio-console",
418
+ inside: 9001,
419
+ label: "minio console",
420
+ web: true
421
+ }],
422
+ mailpit: [{
423
+ key: "mailpit",
424
+ inside: 1025,
425
+ label: "smtp"
426
+ }, {
427
+ key: "mailpit-web",
428
+ inside: 8025,
429
+ label: "mailpit inbox",
430
+ web: true
431
+ }],
432
+ redis: [{
433
+ key: "redis",
434
+ inside: 6379,
435
+ label: "redis"
436
+ }],
437
+ "redis-http": [{
438
+ key: "redis-http",
439
+ inside: 80,
440
+ label: "cache"
441
+ }],
442
+ rabbitmq: [{
443
+ key: "rabbitmq",
444
+ inside: 5672,
445
+ label: "amqp"
446
+ }, {
447
+ key: "rabbitmq-management",
448
+ inside: 15672,
449
+ label: "rabbitmq console",
450
+ web: true
451
+ }],
452
+ localstack: [{
453
+ key: "localstack",
454
+ inside: 4566,
455
+ label: "localstack"
456
+ }],
457
+ caddy: [{
458
+ key: "caddy",
459
+ inside: 443,
460
+ label: "https edge"
461
+ }],
462
+ openobserve: [{
463
+ key: "openobserve",
464
+ inside: LOGS_PORT,
465
+ label: "openobserve",
466
+ web: true
467
+ }]
468
+ };
469
+ /** The port key — and container name, for an image — of an API's fake. */
470
+ function fakeKey(id) {
471
+ return `${kebabCase(id)}-fake`;
472
+ }
473
+ /**
474
+ * The ports a container needs published. Empty for one gkm does not know.
475
+ *
476
+ * `fakes` answers for the containers no table can: an external API's fake
477
+ * listens wherever its declaration says.
478
+ */
479
+ function portsOf(container, fakes = {}) {
480
+ const fake = fakes[container];
481
+ if (fake?.port !== void 0) return [{
482
+ key: container,
483
+ inside: fake.port,
484
+ label: `${fake.id} fake`
485
+ }];
486
+ return PORTS[container] ?? [];
487
+ }
488
+ /**
489
+ * Every port the containers publish — not only the one an app connects to.
490
+ *
491
+ * The consoles and the inbox are most of why these are real containers, and an
492
+ * inbox nobody can find is an inbox nobody opens: a sign-in link gets fished
493
+ * out of `docker ps` instead.
494
+ */
495
+ function serviceAddresses(containers, ports, fakes = {}) {
496
+ return containers.flatMap((container) => portsOf(container, fakes).flatMap((port) => {
497
+ const assigned = ports[port.key];
498
+ if (assigned === void 0) return [];
499
+ return [{
500
+ container,
501
+ label: port.label,
502
+ address: port.web ? `http://localhost:${assigned}` : `localhost:${assigned}`
503
+ }];
504
+ }));
505
+ }
506
+ /** The lines `gkm dev` and `gkm setup` print under the services heading. */
507
+ function describeServices(services) {
508
+ const width = Math.max(0, ...services.map(({ label }) => label.length));
509
+ return services.map(({ label, address }) => ` ${label.padEnd(width)} ${address}`);
510
+ }
511
+ /** The key a container's primary port is allocated under. */
512
+ function primaryPortKey(container) {
513
+ return portsOf(container)[0]?.key ?? container;
514
+ }
515
+ /**
516
+ * Every port key a set of containers needs, in a stable order.
517
+ *
518
+ * What allocation is handed: it assigns ports to names and knows nothing about
519
+ * what listens on them.
520
+ */
521
+ function portKeys(containers, fakes = {}) {
522
+ const keys = [...containers].sort().flatMap((container) => portsOf(container, fakes).map((port) => port.key));
523
+ return [.../* @__PURE__ */ new Set([...keys, ...Object.keys(fakes).sort()])];
524
+ }
525
+ /**
526
+ * The named volume a container's data lives in.
527
+ *
528
+ * Mailpit deliberately has none: local mail is disposable, and an inbox that
529
+ * survives days of dev is noise rather than state.
530
+ */
531
+ function volumeOf(container) {
532
+ return {
533
+ postgres: "postgres-data",
534
+ minio: "minio-data",
535
+ redis: "redis-data",
536
+ rabbitmq: "rabbitmq-data",
537
+ localstack: "localstack-data",
538
+ caddy: "caddy-data",
539
+ openobserve: "openobserve-data"
540
+ }[container];
541
+ }
542
+ //#endregion
543
+ //#region src/reconcile/emulator.ts
544
+ /**
545
+ * The AWS emulator (floci, LocalStack-compatible) the `sns` backend runs on
546
+ * locally — the facts the compose file, the env writer and the applier must
547
+ * agree on.
548
+ *
549
+ * The emulator has one account and answers with deterministic ARNs and queue
550
+ * URLs, which is what lets a connection string be composed before the topic
551
+ * or queue it names has been created.
552
+ */
553
+ /** The emulator's single account. */
554
+ const EMULATOR_ACCOUNT = "000000000000";
555
+ const EMULATOR_REGION = "us-east-1";
556
+ /**
557
+ * The emulator's access key id. The `LSIA` prefix is what LocalStack required
558
+ * on issued keys, and LocalStack reads the account from the id — so it is
559
+ * fixed, where the secret key beside it is generated per machine (see
560
+ * `localCredentials.ts`). Floci does not care; keeping it means a project
561
+ * that pins the old image still works.
562
+ */
563
+ const EMULATOR_ACCESS_KEY_ID = "LSIAQAAAAAAVNCBMPNSG";
564
+ /** The emulator's address from the host, on the port it was published on. */
565
+ function emulatorEndpoint(port) {
566
+ return `http://localhost:${port}`;
567
+ }
568
+ function emulatorTopicArn(name) {
569
+ return `arn:aws:sns:${EMULATOR_REGION}:${EMULATOR_ACCOUNT}:${name}`;
570
+ }
571
+ function emulatorQueueUrl(name, port) {
572
+ return `${emulatorEndpoint(port)}/${EMULATOR_ACCOUNT}/${name}`;
573
+ }
574
+ //#endregion
575
+ //#region src/reconcile/objectEvents.ts
576
+ /**
577
+ * A bucket's object events, where the bucket is a local MinIO.
578
+ *
579
+ * S3 publishes a bucket's events to a topic the deploy creates; MinIO has no
580
+ * topic to publish to, but it can post each event to a webhook. So where MinIO
581
+ * holds a watched bucket, it posts the bucket's events to the process that
582
+ * runs the bucket's subscribers, on a route only it can use, and that process
583
+ * relays each one onto the events broker — under the bucket's name, as
584
+ * `object.created` or `object.deleted` — where every subscriber drains a queue
585
+ * of its own, as a topic's subscribers do.
586
+ *
587
+ * Declared to MinIO in two halves, both derived here so they cannot drift:
588
+ *
589
+ * - **a webhook target per bucket**, as container environment: where to post,
590
+ * the token to present, and a queue on disk, because MinIO starts before the
591
+ * process it posts to and must keep what it could not deliver;
592
+ * - **the bucket's notification**, written through the S3 API once the bucket
593
+ * exists: every created and removed object, to that target. Unfiltered —
594
+ * two subscribers watching overlapping prefixes are two rules S3 refuses on
595
+ * one bucket, and each subscriber filters what it is handed anyway.
596
+ */
597
+ /**
598
+ * The token MinIO presents when it posts a bucket's events.
599
+ *
600
+ * Derived, never stored: the container and the process it posts to are handed
601
+ * the same value by the same derivation — with the stage's random seed where a
602
+ * deployed stage's stack has one, so the token is a secret there, and from the
603
+ * project alone locally, where everything it would protect is on loopback.
604
+ * Not salted by the stage: one MinIO serves `gkm dev` and `gkm test`, and a
605
+ * target is declared once per container.
606
+ */
607
+ function objectsWebhookToken(project, bucket, seed) {
608
+ return createHash("sha256").update(`${seed ? `${seed}:` : ""}${project}:objects-webhook:${bucket}`).digest("base64url").slice(0, 32);
609
+ }
610
+ /**
611
+ * The target's id in MinIO's environment — `MINIO_NOTIFY_WEBHOOK_*_<ID>`.
612
+ *
613
+ * Upper-cased with nothing between words: a canonical id is letters and
614
+ * digits, and an underscore inside the id would read as part of the setting's
615
+ * name.
616
+ */
617
+ function minioTargetId(bucket) {
618
+ return bucket.toUpperCase();
619
+ }
620
+ /** The target as a notification names it. */
621
+ function minioTargetArn(bucket) {
622
+ return `arn:minio:sqs::${minioTargetId(bucket)}:webhook`;
623
+ }
624
+ /** How a container reaches a process on the host. */
625
+ const HOST_GATEWAY = "host.docker.internal";
626
+ /** Where MinIO keeps what it could not deliver yet, inside its container. */
627
+ const QUEUE_ROOT = "/gkm-object-events";
628
+ /** The id of the notification rule gkm owns on a bucket. */
629
+ const NOTIFICATION_RULE_PREFIX = "gkm-";
630
+ /**
631
+ * MinIO's environment for each watched bucket's webhook target.
632
+ *
633
+ * Sorted, so the same buckets always render the same environment and a
634
+ * reconcile that changed nothing does not recreate the container.
635
+ */
636
+ function minioWebhookEnv(hooks) {
637
+ const env = {};
638
+ for (const hook of [...hooks].sort((a, b) => a.bucket.localeCompare(b.bucket))) {
639
+ const id = minioTargetId(hook.bucket);
640
+ env[`MINIO_NOTIFY_WEBHOOK_ENABLE_${id}`] = "on";
641
+ env[`MINIO_NOTIFY_WEBHOOK_ENDPOINT_${id}`] = hook.endpoint;
642
+ env[`MINIO_NOTIFY_WEBHOOK_AUTH_TOKEN_${id}`] = hook.token;
643
+ env[`MINIO_NOTIFY_WEBHOOK_QUEUE_DIR_${id}`] = `${QUEUE_ROOT}/${id.toLowerCase()}`;
644
+ }
645
+ return env;
646
+ }
647
+ /** The rule that sends every created and removed object to the bucket's target. */
648
+ function minioNotificationRule(bucket) {
649
+ return {
650
+ Id: `${NOTIFICATION_RULE_PREFIX}${bucket}`,
651
+ QueueArn: minioTargetArn(bucket),
652
+ Events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]
653
+ };
654
+ }
655
+ /**
656
+ * Each watched bucket, and the workers that run one of its subscribers.
657
+ *
658
+ * A bucket is watched when a subscriber reads its events key. MinIO posts a
659
+ * bucket's events to one place, and the relay fans them out to every
660
+ * subscriber whichever worker received them — so one worker per bucket is
661
+ * enough, and the first, by id, is the one chosen, so the choice is stable.
662
+ */
663
+ function watchedBuckets(manifest, subscribers) {
664
+ const byKey = /* @__PURE__ */ new Map();
665
+ for (const declaration of Object.values(manifest)) {
666
+ if (declaration.kind !== "objects") continue;
667
+ byKey.set(providedKeyFor(declaration.id, declaration.kind, "eventsConnectionString"), declaration.id);
668
+ }
669
+ const watched = /* @__PURE__ */ new Map();
670
+ for (const worker of Object.keys(subscribers).sort()) for (const { connectionKey } of subscribers[worker] ?? []) {
671
+ const bucket = byKey.get(connectionKey);
672
+ if (bucket && !watched.has(bucket)) watched.set(bucket, worker);
673
+ }
674
+ return watched;
675
+ }
676
+ //#endregion
677
+ //#region src/telemetry/edges.ts
678
+ /**
679
+ * Which processes use a `Telemetry` node — read off the manifest's edges.
680
+ *
681
+ * A process uses telemetry when its own declaration names the node: a
682
+ * surface's `telemetry`, a worker's. A surface's process runs its own
683
+ * endpoints, so a worker's edge never counts for it.
684
+ *
685
+ * A site's edge is recorded and never followed here: a site is handed none of
686
+ * the node's keys (see `PUBLIC.telemetry`).
687
+ */
688
+ /** The `OTEL_*` keys a `Telemetry` node provides. */
689
+ const TELEMETRY_ENV_KEYS = TELEMETRY_KEYS;
690
+ /** Whether `key` is one of the keys a `Telemetry` node provides. */
691
+ function isTelemetryKey(key) {
692
+ return TELEMETRY_ENV_KEYS.includes(key);
693
+ }
694
+ /** The node a declaration's `telemetry` edge names, when it names one. */
695
+ function nodeOf(manifest, id) {
696
+ if (!id) return void 0;
697
+ const node = manifest[id];
698
+ return node?.kind === "telemetry" ? node : void 0;
699
+ }
700
+ /**
701
+ * The `Telemetry` node the process for `id` — a surface, a worker, or a file
702
+ * server's processor unit, by construct id — emits through, or undefined
703
+ * when it has no edge to one.
704
+ */
705
+ function telemetryOf(manifest, id) {
706
+ const declaration = manifest[id];
707
+ if (!declaration) return void 0;
708
+ if (declaration.kind === "worker" || declaration.kind === "file-server") return nodeOf(manifest, declaration.telemetry);
709
+ if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api") return void 0;
710
+ return nodeOf(manifest, declaration.telemetry);
711
+ }
712
+ /**
713
+ * The `Telemetry` node the app `appName` emits through — its surface's, or
714
+ * undefined for a site, an app without one, or one with no edge.
715
+ */
716
+ function appTelemetry(manifest, appName) {
717
+ const id = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api") && appKey(id) === appName)?.[0];
718
+ return id ? telemetryOf(manifest, id) : void 0;
719
+ }
720
+ /** Whether any process in the manifest emits through a `Telemetry` node. */
721
+ function usesTelemetry(manifest) {
722
+ return Object.entries(manifest).some(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api" || d.kind === "worker" || d.kind === "file-server") && telemetryOf(manifest, id) !== void 0);
723
+ }
724
+ /**
725
+ * One process's share of the telemetry keys a stage resolved: all of them,
726
+ * named for the process, when it has an edge to the node — and none
727
+ * otherwise.
728
+ *
729
+ * `env` is everything else the process is handed; its `OTEL_*` keys are
730
+ * replaced, never merged, so a process without the edge cannot inherit them.
731
+ */
732
+ function scopeTelemetryEnv(env, options) {
733
+ const scoped = Object.fromEntries(Object.entries(env).filter(([key]) => !isTelemetryKey(key)));
734
+ if (!options.uses || !options.telemetry) return scoped;
735
+ const values = Object.fromEntries(Object.entries(options.telemetry).filter(([key]) => isTelemetryKey(key)));
736
+ if (!values.OTEL_EXPORTER_OTLP_ENDPOINT) return scoped;
737
+ return {
738
+ ...scoped,
739
+ ...values,
740
+ OTEL_SERVICE_NAME: options.serviceName
741
+ };
742
+ }
743
+ /** Whether the site `siteId` has an edge to a `Telemetry` node. */
744
+ function siteUsesTelemetry(manifest, siteId) {
745
+ const site = manifest[siteId];
746
+ return site?.kind === "site" && nodeOf(manifest, site.telemetry) !== void 0;
747
+ }
748
+ /**
749
+ * Whether the client of the surface `surfaceId` propagates trace context:
750
+ * when a site that calls it has an edge to a `Telemetry` node. One client
751
+ * serves every site that calls the surface on the host, so one with the
752
+ * edge turns it on; a site's image generates its own, from its own edge.
753
+ */
754
+ function surfaceClientTraced(manifest, surfaceId) {
755
+ return Object.entries(manifest).some(([id, d]) => d.kind === "site" && siteUsesTelemetry(manifest, id) && d.dependencies.some((edge) => edge.target === surfaceId));
756
+ }
757
+ /**
758
+ * Whether the site app `appName`'s clients propagate trace context, and at
759
+ * what rate: when the site has an edge to a `Telemetry` construct, at the
760
+ * stage's sample rate — a public value, every trace locally — and not at all
761
+ * for a stage that sends no telemetry.
762
+ */
763
+ function siteClientTelemetry(manifest, appName, workspace, stage) {
764
+ const id = Object.entries(manifest).find(([id, d]) => d.kind === "site" && appKey(id) === appName)?.[0];
765
+ if (!id || !siteUsesTelemetry(manifest, id)) return void 0;
766
+ const sampleRate = stageSampleRate(workspace.deploy?.telemetry, stage ?? workspace.stages.local, !stage || stage === workspace.stages.local);
767
+ return sampleRate === void 0 ? void 0 : { sampleRate };
768
+ }
769
+ /** The label a log UI answers on when the workspace declares no `Telemetry`. */
770
+ const DEFAULT_TELEMETRY_ID = "Telemetry";
771
+ /**
772
+ * Two `Telemetry` nodes declare different labels or images for the one
773
+ * OpenObserve a stack runs.
774
+ */
775
+ var TelemetryNodesDisagree = class extends GkmError {
776
+ field;
777
+ ids;
778
+ constructor(field, ids) {
779
+ super(`A stack runs one OpenObserve for every Telemetry node, and ${ids.join(", ")} give it different ${field === "subdomain" ? "labels" : "images"}. Give each the same ${field}${field === "subdomain" ? " (each defaults to its id kebab-cased)" : ""}.`);
780
+ this.field = field;
781
+ this.ids = ids;
782
+ this.name = "TelemetryNodesDisagree";
783
+ }
784
+ };
785
+ /**
786
+ * The stack's one OpenObserve, as the workspace's `Telemetry` nodes declare
787
+ * it: the label its UI answers on (`hostLabels`: `subdomain`, else the id
788
+ * kebab-cased) and the image it runs, where a node names one.
789
+ *
790
+ * @throws {TelemetryNodesDisagree} when two nodes declare different ones
791
+ */
792
+ function stackTelemetry(manifest) {
793
+ const nodes = Object.values(manifest).filter((d) => d.kind === "telemetry").sort((a, b) => a.id.localeCompare(b.id));
794
+ const labels = [...new Set((nodes.length ? nodes : [{ id: DEFAULT_TELEMETRY_ID }]).map((node) => hostLabels(node).primary))];
795
+ if (labels.length > 1) throw new TelemetryNodesDisagree("subdomain", nodes.map((node) => node.id));
796
+ const images = [...new Set(nodes.flatMap((node) => node.image ?? []))];
797
+ if (images.length > 1) throw new TelemetryNodesDisagree("image", nodes.filter((node) => node.image).map((node) => node.id));
798
+ return {
799
+ label: labels[0],
800
+ ...images[0] ? { image: images[0] } : {}
801
+ };
802
+ }
803
+ //#endregion
804
+ //#region src/generators/processorRoute.ts
805
+ /**
806
+ * Where `gkm dev` serves a file server's processors, on the dev server of the
807
+ * app holding them: named after the file server.
808
+ *
809
+ * One definition for both sides — the dev server mounts it, and the local
810
+ * edge rewrites each processor pattern on the file server's host onto it — so
811
+ * the path the edge sends and the path the server answers cannot drift.
812
+ */
813
+ const PROCESSORS_DEV_PREFIX = "/__gkm/processors/";
814
+ /** The base a file server's processors answer under, in `gkm dev`. */
815
+ function processorsDevRoute(fileServerId) {
816
+ return `${PROCESSORS_DEV_PREFIX}${fileServerId}`;
817
+ }
818
+ //#endregion
819
+ //#region src/reconcile/routes.ts
820
+ /**
821
+ * The kinds the edge serves.
822
+ *
823
+ * Everything that owns a *public address*. Deployed, each of these has a real
824
+ * hostname and a certificate, so this is what makes the local shape the same
825
+ * one rather than a near-enough one — and the application is indifferent
826
+ * either way, because it reads whichever address was injected and never
827
+ * composes one.
828
+ *
829
+ * Adding a kind here is the whole of adding it to the edge.
830
+ */
831
+ const EDGE_KINDS = {
832
+ "file-server": true,
833
+ "rest-api": true,
834
+ "websocket-api": true,
835
+ site: true
836
+ };
837
+ /**
838
+ * The suffix every local host shares.
839
+ *
840
+ * `.localhost` rather than a made-up TLD because it resolves to loopback
841
+ * without touching `/etc/hosts` — macOS and systemd-resolved both answer for
842
+ * subdomains of it.
843
+ */
844
+ const LOCAL_TLD = "localhost";
845
+ /** MinIO, as a Caddy on this project's network reaches it. */
846
+ const MINIO_UPSTREAM = {
847
+ service: "minio",
848
+ port: 9e3
849
+ };
850
+ /**
851
+ * The routes a plan implies: one per surface and site at an address, and one
852
+ * per file server over its bucket — named as `gkm compose` names the same
853
+ * construct's (`api`, `files-uploads`), on the hosts it gives them.
854
+ *
855
+ * A file server's leading label is the *server's* stage-scoped name rather
856
+ * than the bucket's, which is the difference that matters: two servers over
857
+ * one bucket are a legitimate arrangement — two cache behaviours, one origin
858
+ * — and naming the host after the bucket would make them collide.
859
+ */
860
+ function localRoutes(plan, project, options = {}) {
861
+ const { addresses = {}, processorAddresses = {} } = options;
862
+ const objects = options.objects ?? MINIO_UPSTREAM;
863
+ const byId = new Map(plan.resources.map((r) => [r.id, r]));
864
+ const routes = [];
865
+ for (const resource of plan.resources) {
866
+ if (!EDGE_KINDS[resource.kind]) continue;
867
+ const host = hostFor(resource, project);
868
+ if (resource.kind === "file-server") {
869
+ const origin = resource.of ? byId.get(resource.of) : void 0;
870
+ if (!origin) continue;
871
+ const address = processorAddresses[resource.id];
872
+ const port = address ? portOf(address) : void 0;
873
+ routes.push({
874
+ name: `files-${appKey(resource.id)}`,
875
+ host,
876
+ upstreams: [objects],
877
+ streaming: false,
878
+ prefix: `/${origin.name}`,
879
+ ...resource.processors?.length && port ? { handlers: [{
880
+ name: "processors",
881
+ prefixes: resource.processors,
882
+ upstreams: [{
883
+ onHost: true,
884
+ port
885
+ }],
886
+ under: processorsDevRoute(resource.id)
887
+ }] } : {}
888
+ });
889
+ continue;
890
+ }
891
+ const address = addresses[resource.id];
892
+ const port = address ? portOf(address) : void 0;
893
+ if (!port) continue;
894
+ const route = {
895
+ name: appKey(resource.id),
896
+ host,
897
+ upstreams: [{
898
+ onHost: true,
899
+ port
900
+ }],
901
+ streaming: true
902
+ };
903
+ if (resource.subdomain === WILDCARD_SUBDOMAIN) {
904
+ routes.push({
905
+ ...route,
906
+ wildcard: wildcardOf(resource, host, addresses)
907
+ });
908
+ continue;
909
+ }
910
+ const { aliases, redirects } = hostsFor(resource, project);
911
+ const edge = options.port && options.port !== 443 ? `:${options.port}` : "";
912
+ routes.push({
913
+ ...route,
914
+ ...aliases.length ? { aliases } : {},
915
+ ...redirects.length ? { redirects: {
916
+ hosts: redirects,
917
+ to: `https://${host}${edge}`
918
+ } } : {}
919
+ });
920
+ }
921
+ return routes;
922
+ }
923
+ /**
924
+ * What stands between a wildcard site and a host that is not a tenant.
925
+ *
926
+ * A named host wins over the `*` on either proxy, so `api.shop.localhost`
927
+ * reaches the API whatever the wildcard says. What neither can know is the
928
+ * labels nothing is running on: `www`, or an app this stage has not started.
929
+ * Those are refused, so no slug a deploy would protect is ever served locally
930
+ * either.
931
+ *
932
+ * The `hosts` route, where the surface serving it has an address, is a
933
+ * deployed edge's check in miniature: a `2xx` lets the request through, and
934
+ * any other answer — the app's own `404` — is what the browser gets.
935
+ */
936
+ function wildcardOf(resource, host, addresses) {
937
+ const domain = host.slice(`${WILDCARD_SUBDOMAIN}.`.length);
938
+ const surface = resource.hosts ? addresses[resource.hosts.surface] : void 0;
939
+ const port = surface ? portOf(surface) : void 0;
940
+ return {
941
+ domain,
942
+ except: [...resource.protectedSubdomains ?? []],
943
+ tls: { kind: "stage" },
944
+ ...resource.hosts && port ? { hosts: {
945
+ upstream: {
946
+ onHost: true,
947
+ port
948
+ },
949
+ path: resource.hosts.path
950
+ } } : {}
951
+ };
952
+ }
953
+ /** The port a local address answers on, defaulting by scheme. */
954
+ function portOf(address) {
955
+ try {
956
+ const { port, protocol } = new URL(address);
957
+ return Number(port || (protocol === "https:" ? 443 : 80));
958
+ } catch {
959
+ return;
960
+ }
961
+ }
962
+ /**
963
+ * Where one file server answers, including the stage its name carries.
964
+ *
965
+ * The project is a label rather than a decoration: it is what keeps two
966
+ * checkouts from answering on one address. Omitted when there is no project to
967
+ * name, because an empty label makes `uploads..localhost` — a host nothing
968
+ * resolves and no certificate can be issued for.
969
+ */
970
+ function hostFor(resource, project) {
971
+ const label = resource.root && project ? stageOf(resource) : labelOf(resource);
972
+ if (resource.subdomain === WILDCARD_SUBDOMAIN) return [
973
+ WILDCARD_SUBDOMAIN,
974
+ stageOf(resource),
975
+ project,
976
+ LOCAL_TLD
977
+ ].filter(Boolean).join(".");
978
+ return [
979
+ label,
980
+ project,
981
+ LOCAL_TLD
982
+ ].filter(Boolean).join(".");
983
+ }
984
+ /**
985
+ * Where a resource answers, every host of it: {@link hostFor}'s, and each
986
+ * alias and redirect label under the project, carrying the stage as its own
987
+ * label does — `www-test.shop.localhost` for `gkm test`.
988
+ */
989
+ function hostsFor(resource, project) {
990
+ const stage = stageOf(resource);
991
+ const under = (label) => [
992
+ stage ? `${label}-${stage}` : label,
993
+ project,
994
+ LOCAL_TLD
995
+ ].filter(Boolean).join(".");
996
+ return {
997
+ host: hostFor(resource, project),
998
+ aliases: (resource.aliases ?? []).map(under),
999
+ redirects: (resource.redirects ?? []).map(under)
1000
+ };
1001
+ }
1002
+ /**
1003
+ * A resource's own label: its `subdomain` where it declared one, and a file
1004
+ * server's own name — the label a deploy uses too — with the stage it carries
1005
+ * kept, so `gkm test` and `gkm dev` still answer on different hosts.
1006
+ */
1007
+ function labelOf(resource) {
1008
+ const own = resource.kind === "file-server" ? fileServerLabel(resource.id) : resource.subdomain;
1009
+ if (!own) return resource.name;
1010
+ const stage = stageOf(resource);
1011
+ return stage ? `${own}-${stage}` : own;
1012
+ }
1013
+ /** The stage a resource's name carries, or nothing for the local stage's. */
1014
+ function stageOf(resource) {
1015
+ const base = resource.id.toLowerCase();
1016
+ return resource.name === base ? void 0 : resource.name.slice(base.length + 1);
1017
+ }
1018
+ //#endregion
1019
+ //#region src/reconcile/plan.ts
1020
+ /**
1021
+ * The reconcile plan — what a manifest wants to exist, for one stage.
1022
+ *
1023
+ * Pure. Turning the plan into running containers and provisioned resources is
1024
+ * the applier's job; deciding *what* should exist is this, so the decisions can
1025
+ * be asserted as data rather than by starting Docker.
1026
+ *
1027
+ * One plan serves every stage. `gkm dev` reconciles `development` and `gkm test`
1028
+ * reconciles `test`; they differ only in what the resources are called, never in
1029
+ * what infrastructure exists. Roles are cluster-scoped in Postgres while grants
1030
+ * are per-object, so one container and one role pair serve both.
1031
+ */
1032
+ /**
1033
+ * Which container serves a kind.
1034
+ *
1035
+ * Derived kinds map to the same container as their parent — a schema tenant
1036
+ * lives in its parent's Postgres — so the set is deduplicated rather than
1037
+ * counted.
1038
+ */
1039
+ const CONTAINERS = {
1040
+ database: "postgres",
1041
+ "database-reader": "postgres",
1042
+ "database-schema": "postgres",
1043
+ objects: "minio",
1044
+ "file-server": "caddy",
1045
+ email: "mailpit",
1046
+ inbox: "mailpit",
1047
+ "websocket-api": "redis"
1048
+ };
1049
+ /**
1050
+ * The container a cache backend needs locally.
1051
+ *
1052
+ * Each one matches the protocol its deployed form speaks, which is the property
1053
+ * worth having: a cache that behaves differently in the two places is worse than
1054
+ * a slower one.
1055
+ *
1056
+ * `db` is deliberately absent, the same way `pgboss` is absent from
1057
+ * `EVENT_CONTAINERS`: the cache is a table in a database the manifest already
1058
+ * declares, so mapping it here would start a container for a project that needs
1059
+ * none.
1060
+ */
1061
+ const CACHE_CONTAINERS = {
1062
+ upstash: "redis-http",
1063
+ elasticache: "redis",
1064
+ redis: "redis"
1065
+ };
1066
+ /**
1067
+ * Kinds that resolve a value without anything running.
1068
+ *
1069
+ * A secret is the case: it has no address, so there is nothing to start and
1070
+ * nothing to connect to — but it still appears in the plan, because the target
1071
+ * still has to resolve it.
1072
+ */
1073
+ const CONTAINERLESS = {
1074
+ secret: true,
1075
+ credential: true,
1076
+ encryption: true,
1077
+ "rest-api": true,
1078
+ site: true,
1079
+ "mobile-app": true,
1080
+ "external-api": true,
1081
+ telemetry: true
1082
+ };
1083
+ /** The container that collects telemetry locally, and serves its UI. */
1084
+ const TELEMETRY_CONTAINER = "openobserve";
1085
+ /**
1086
+ * Containers that cannot run alone.
1087
+ *
1088
+ * The one case is the cache: `serverless-redis-http` is a proxy and needs the
1089
+ * Redis it proxies. Kept here rather than in the compose definition so the plan
1090
+ * -- which is what decides what must be running -- still names everything.
1091
+ */
1092
+ const REQUIRES = { "redis-http": ["redis"] };
1093
+ /**
1094
+ * The role each kind's one key plays, where it is not a URL.
1095
+ *
1096
+ * The twin of `ProvidesByKind` in `@geekmidas/manifest`: that is what a
1097
+ * construct declares, this is what the local target resolves, and both derive
1098
+ * the key from the same `providedKeyFor` so they cannot disagree.
1099
+ */
1100
+ const ROLES = {
1101
+ queue: "publisherConnectionString",
1102
+ topic: "publisherConnectionString",
1103
+ credential: "credentials",
1104
+ "mobile-app": "scheme",
1105
+ objects: "connectionString"
1106
+ };
1107
+ /** The kinds whose container is the events backend's rather than their own. */
1108
+ const EVENT_KINDS = {
1109
+ queue: true,
1110
+ topic: true
1111
+ };
1112
+ /**
1113
+ * Which kinds provision something *inside* their container.
1114
+ *
1115
+ * A database creates a database, a bucket creates a bucket; mail creates
1116
+ * nothing — Mailpit accepts whatever is sent to it and has no per-stage object
1117
+ * to name. Both still appear in the plan, because both still resolve a URL; the
1118
+ * flag is the difference between "must be running" and "must be created".
1119
+ */
1120
+ const PROVISIONS = {
1121
+ database: true,
1122
+ "database-reader": true,
1123
+ "database-schema": true,
1124
+ objects: true,
1125
+ cache: true,
1126
+ "file-server": true
1127
+ };
1128
+ /**
1129
+ * The container each events backend needs, where it needs one of its own.
1130
+ *
1131
+ * `pgboss` is deliberately absent rather than mapped to `postgres`: it is a
1132
+ * schema tenant in a database the manifest already declares, so mapping it here
1133
+ * would start a Postgres for a project that declared no database at all.
1134
+ *
1135
+ * This one comes from config rather than from a declaration because there are
1136
+ * no `topic` or `queue` kinds yet. When they land the mapping moves to
1137
+ * {@link CONTAINERS} keyed by kind, and this constant goes with them.
1138
+ */
1139
+ const EVENT_CONTAINERS = {
1140
+ sns: "localstack",
1141
+ rabbitmq: "rabbitmq"
1142
+ };
1143
+ /** The backend a project gets when it declares queues or topics and says nothing. */
1144
+ const DEFAULT_EVENTS = "pgboss";
1145
+ /**
1146
+ * How a resource of each kind separates its stage suffix.
1147
+ *
1148
+ * Postgres identifiers are snake_case and a hyphen would need quoting
1149
+ * everywhere; buckets and queues are kebab and disallow underscores in some
1150
+ * providers. The suffix is the same word either way.
1151
+ */
1152
+ const SEPARATORS = {
1153
+ database: "_",
1154
+ "database-reader": "_",
1155
+ "database-schema": "_",
1156
+ objects: "-"
1157
+ };
1158
+ /**
1159
+ * The stage-scoped name for a resource.
1160
+ *
1161
+ * The local stage carries no suffix, so `gkm dev` keeps using `orders` and a
1162
+ * developer's psql history, saved connections, and muscle memory survive a
1163
+ * change of stage name. Every other stage is suffixed.
1164
+ */
1165
+ function resourceName(id, kind, stage, localStage) {
1166
+ const base = id.toLowerCase();
1167
+ if (stage === localStage) return base;
1168
+ return `${base}${SEPARATORS[kind] ?? "-"}${stage}`;
1169
+ }
1170
+ /**
1171
+ * The container a kind needs, or `undefined` if it needs none.
1172
+ *
1173
+ * Queues and topics have no container of their own — they live in whichever
1174
+ * broker the project selected, which is why the backend is an argument here
1175
+ * rather than a second pass that adds containers after the fact.
1176
+ */
1177
+ function containerFor(kind, events = DEFAULT_EVENTS, cache = DEFAULT_CACHE.aws, derived = false, caddy = true) {
1178
+ if (EVENT_KINDS[kind]) return EVENT_CONTAINERS[events] ?? CONTAINERS.database;
1179
+ if (kind === "file-server") return caddy ? "caddy" : CONTAINERS.objects;
1180
+ if (kind === "cache") {
1181
+ if (derived && !holdsEveryCache(cache)) return CONTAINERS.database;
1182
+ return CACHE_CONTAINERS[cache] ?? CONTAINERS.database;
1183
+ }
1184
+ return CONTAINERS[kind];
1185
+ }
1186
+ /**
1187
+ * Build the plan for a manifest and stage.
1188
+ *
1189
+ * `order` is the caller's provisioning order — parents before children — which
1190
+ * `provisionOrder` produces from the manifest. Passing it in keeps this
1191
+ * function free of the traversal and makes the ordering assertable on its own.
1192
+ */
1193
+ function planFor(manifest, stage, order, options = {}) {
1194
+ const containers = /* @__PURE__ */ new Set();
1195
+ const resources = [];
1196
+ const fakes = {};
1197
+ const events = options.events ?? "pgboss";
1198
+ const cache = options.cache ?? DEFAULT_CACHE.aws;
1199
+ const edge = options.edge === false ? void 0 : options.edge ?? { proxy: "caddy" };
1200
+ for (const id of order) {
1201
+ const declaration = manifest[id];
1202
+ if (!declaration) continue;
1203
+ const local = declaration.kind === "external-api" ? options.fakes?.[id] : void 0;
1204
+ const fake = local && {
1205
+ key: fakeKey(id),
1206
+ ...local
1207
+ };
1208
+ if (fake) fakes[fake.key] = {
1209
+ id,
1210
+ ...fake.image ? {
1211
+ image: fake.image,
1212
+ port: fake.port
1213
+ } : {}
1214
+ };
1215
+ const detached = declaration.kind === "cache" && holdsEveryCache(cache);
1216
+ const container = fake?.image ? fake.key : declaration.kind === "telemetry" ? usesTelemetry(manifest) ? TELEMETRY_CONTAINER : void 0 : containerFor(declaration.kind, events, cache, "of" in declaration && typeof declaration.of === "string", edge?.proxy === "caddy");
1217
+ if (!container && !CONTAINERLESS[declaration.kind]) continue;
1218
+ if (container) {
1219
+ containers.add(container);
1220
+ for (const required of REQUIRES[container] ?? []) containers.add(required);
1221
+ }
1222
+ const images = isPublicDeclaration(declaration) ? imageOriginsFor(declaration, manifest) : void 0;
1223
+ resources.push({
1224
+ id,
1225
+ kind: declaration.kind,
1226
+ ...container ? { container } : {},
1227
+ name: resourceName(id, declaration.kind, stage, options.localStage),
1228
+ envKey: providedKeyFor(id, declaration.kind, ROLES[declaration.kind] ?? "url"),
1229
+ provisions: PROVISIONS[declaration.kind] === true,
1230
+ ...declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "objects" || declaration.kind === "file-server" ? { callers: dependentsOf(manifest, id) } : {},
1231
+ ...declaration.kind === "site" ? { publicEnv: publicEnvFor(declaration, manifest) } : {},
1232
+ ...images ? { imageOrigins: images } : {},
1233
+ ...isPublicDeclaration(declaration) ? { stageKey: publicStageKey(declaration) } : {},
1234
+ ...declaration.kind === "mobile-app" ? {
1235
+ publicEnv: publicEnvFor(declaration, manifest),
1236
+ ...declaration.scheme ? { scheme: declaration.scheme } : {}
1237
+ } : {},
1238
+ ...declaration.kind === "file-server" && declaration.open?.length ? { open: declaration.open } : {},
1239
+ ...declaration.kind === "file-server" && declaration.processors?.length ? { processors: [...new Set(declaration.processors.map((p) => p.prefix))].sort() } : {},
1240
+ ...declaration.kind === "email" && declaration.from ? { from: declaration.from } : {},
1241
+ ...declaration.kind === "inbox" ? { inbox: {
1242
+ addresses: declaration.addresses,
1243
+ subdomains: declaration.subdomains === true,
1244
+ topic: declaration.topic
1245
+ } } : {},
1246
+ ...declaration.kind === "objects" && bucketExpiry(manifest, id) ? { expire: bucketExpiry(manifest, id) } : {},
1247
+ ...(declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site") && declaration.subdomain ? { subdomain: declaration.subdomain } : {},
1248
+ ...isHostedDeclaration(declaration) && hostLabels(declaration).aliases.length ? { aliases: [...hostLabels(declaration).aliases] } : {},
1249
+ ...isHostedDeclaration(declaration) && hostLabels(declaration).redirects.length ? { redirects: [...hostLabels(declaration).redirects] } : {},
1250
+ ...isWildcardSite(declaration) ? {
1251
+ protectedSubdomains: protectedSubdomains(manifest, options.protectedSubdomains),
1252
+ ...declaration.hosts ? { hosts: declaration.hosts } : {}
1253
+ } : {},
1254
+ ...fake ? { fake: {
1255
+ key: fake.key,
1256
+ credentials: fake.credentials
1257
+ } } : {},
1258
+ ...declaration.kind === "external-api" && !fake ? { url: declaration.url } : {},
1259
+ ...declaration.kind === "credential" && options.credentialFakes?.[id] !== void 0 ? { fakeCredentials: options.credentialFakes[id] } : {},
1260
+ ...declaration.kind === "secret" && (declaration.length !== void 0 || declaration.symbols !== void 0) ? { format: {
1261
+ ...declaration.length !== void 0 ? { length: declaration.length } : {},
1262
+ ...declaration.symbols !== void 0 ? { symbols: declaration.symbols } : {}
1263
+ } } : {},
1264
+ ..."of" in declaration && !detached ? { of: declaration.of } : {},
1265
+ ..."schema" in declaration && declaration.schema ? { schema: declaration.schema } : {},
1266
+ ..."version" in declaration && declaration.version ? { version: declaration.version } : {},
1267
+ ..."image" in declaration && declaration.image ? { image: declaration.image } : {},
1268
+ ..."extensions" in declaration && declaration.extensions?.length ? { extensions: declaration.extensions } : {},
1269
+ ..."roles" in declaration && declaration.roles === false ? { roles: false } : {},
1270
+ ..."table" in declaration && declaration.table && !detached ? { table: declaration.table } : {}
1271
+ });
1272
+ }
1273
+ const served = edge !== void 0 && resources.some((r) => EDGE_KINDS[r.kind] === true);
1274
+ if (served && edge.proxy === "caddy") containers.add("caddy");
1275
+ for (const extra of options.extraContainers ?? []) containers.add(extra);
1276
+ if (events === "pgboss" && resources.some((r) => EVENT_KINDS[r.kind]) && !resources.some((r) => r.kind === "database")) throw new PgBossNeedsDatabase(resources.filter((r) => EVENT_KINDS[r.kind]).map((r) => r.id));
1277
+ if (cache === "db") {
1278
+ const placeless = resources.filter((r) => r.kind === "cache" && !r.of);
1279
+ if (placeless.length > 0) {
1280
+ const databases = resources.filter((r) => r.kind === "database");
1281
+ const [only] = databases;
1282
+ if (!only) throw new CacheNeedsDatabase(resources.filter((r) => r.kind === "cache").map((r) => r.id));
1283
+ if (databases.length > 1) throw new CacheIsAmbiguous(placeless.map((r) => r.id), databases.map((r) => r.id));
1284
+ for (const resource of placeless) resource.of = only.id;
1285
+ }
1286
+ }
1287
+ const sites = resources.filter((r) => r.kind === "site" && r.subdomain !== WILDCARD_SUBDOMAIN);
1288
+ const root = rootSite(sites.map((r) => {
1289
+ const declared = manifest[r.id];
1290
+ return {
1291
+ name: appKey(r.id),
1292
+ ...declared?.kind === "site" && declared.root ? { root: true } : {}
1293
+ };
1294
+ }));
1295
+ for (const site of sites) if (appKey(site.id) === root) site.root = true;
1296
+ const workerBroker = events === "pgboss" && Object.values(manifest).some((d) => d?.kind === "worker") && resources.some((r) => r.kind === "database");
1297
+ return {
1298
+ stage,
1299
+ events,
1300
+ cache,
1301
+ containers: [...containers],
1302
+ resources,
1303
+ ...Object.keys(fakes).length ? { fakes } : {},
1304
+ ...workerBroker ? { workerBroker: true } : {},
1305
+ ...served ? { edge } : {}
1306
+ };
1307
+ }
1308
+ /**
1309
+ * Queues or topics were declared with pg-boss and no database to hold them.
1310
+ *
1311
+ * Not a reconcile failure but a manifest one: the fix is a line of application
1312
+ * code either way — declare a database, or select a backend that brings its own
1313
+ * broker.
1314
+ */
1315
+ var CacheNeedsDatabase = class extends GkmError {
1316
+ ids;
1317
+ constructor(ids) {
1318
+ super(`A cache backed by the database needs a declared database, and none was declared, and on this deploy target that is where a cache lives. Declare one. Caches affected: ${ids.join(", ")}.`);
1319
+ this.ids = ids;
1320
+ this.name = "CacheNeedsDatabase";
1321
+ }
1322
+ };
1323
+ /**
1324
+ * A `'db'` cache — a server target's default — in an app that declares more
1325
+ * than one database.
1326
+ *
1327
+ * The target says *a* database and the graph offers several, so there is no
1328
+ * answer to give — and the wrong kind of failure would be to pick one, since a
1329
+ * cache silently landing in the wrong database is a bug that surfaces as
1330
+ * missing rows much later. The fix is a stronger statement in application code:
1331
+ * `orders.cache('Sessions')` names the database, which is a fact about the
1332
+ * application rather than a deployment choice.
1333
+ */
1334
+ var CacheIsAmbiguous = class extends GkmError {
1335
+ ids;
1336
+ databases;
1337
+ constructor(ids, databases) {
1338
+ super(`A cache backed by the database needs to know which one, and this app declares ${databases.length}: ${databases.join(", ")}. Declare the cache from its database — e.g. ${databases[0]}.cache('Sessions') — rather than as a bare new Cache(). Caches affected: ${ids.join(", ")}.`);
1339
+ this.ids = ids;
1340
+ this.databases = databases;
1341
+ this.name = "CacheIsAmbiguous";
1342
+ }
1343
+ };
1344
+ var PgBossNeedsDatabase = class extends GkmError {
1345
+ ids;
1346
+ constructor(ids) {
1347
+ super(`pg-boss keeps its queues in a declared database, and none was declared. Declare one: on this deploy target, events are carried by pg-boss. Queues and topics affected: ${ids.join(", ")}.`);
1348
+ this.ids = ids;
1349
+ this.name = "PgBossNeedsDatabase";
1350
+ }
1351
+ };
1352
+ //#endregion
1353
+ //#region src/reconcile/compose.ts
1354
+ /**
1355
+ * The compose document a plan implies.
1356
+ *
1357
+ * The third declaration of the same containers disappears here: today a
1358
+ * `services: ['postgres','minio']` block is kept in step with the code by hand,
1359
+ * which is the triplication this design exists to remove, in the one place you
1360
+ * touch every day. A `database` implies Postgres; the list is derived.
1361
+ *
1362
+ * Returns an object rather than a string for the same reason `plan` is pure —
1363
+ * what should exist is asserted as data, and turning it into YAML is one line at
1364
+ * the edge.
1365
+ *
1366
+ * What stays config is unchanged: images and versions are pinned explicitly, and
1367
+ * a container no construct implies is still declared by hand. Neutral facts come
1368
+ * from the declaration, provider detail from config.
1369
+ */
1370
+ /** The database every connection opens first: every cluster has it. */
1371
+ const CLUSTER_DATABASE = "postgres";
1372
+ /**
1373
+ * Where Postgres's volume is mounted: the parent of its data directory, not
1374
+ * the directory itself — see the service's definition.
1375
+ */
1376
+ const POSTGRES_MOUNT = "/var/lib/postgresql";
1377
+ /**
1378
+ * Build the compose document for a plan.
1379
+ *
1380
+ * Every container is published on its assigned port, never on the image's
1381
+ * default: the point of allocation is that two projects can run at once, and
1382
+ * one container publishing 5432 puts that back.
1383
+ */
1384
+ function composeFor(plan, options) {
1385
+ const services = {};
1386
+ const volumes = {};
1387
+ for (const container of [...plan.containers].sort()) {
1388
+ const declared = container === "postgres" ? plan.resources.find((r) => r.version)?.version : void 0;
1389
+ const named = container === "postgres" ? declaredPostgresImage(plan) : container === "openobserve" ? declaredTelemetryImage(plan) : void 0;
1390
+ const fake = plan.fakes?.[container];
1391
+ const image = named ?? (declared ? postgresImage(declared) : fake?.image ?? DEFAULT_IMAGES[container]);
1392
+ if (!image) throw new UnknownContainer(container);
1393
+ const published = publish(container, options.ports, plan.fakes);
1394
+ services[container] = fake ? {
1395
+ image,
1396
+ restart: "unless-stopped",
1397
+ ports: published
1398
+ } : define(container, image, published, options.credentials);
1399
+ const volume = volumeOf(container);
1400
+ if (volume) volumes[volume] = {};
1401
+ }
1402
+ const minio = services.minio;
1403
+ if (minio && options.objectWebhooks?.length) {
1404
+ minio.environment = {
1405
+ ...minio.environment,
1406
+ ...minioWebhookEnv(options.objectWebhooks)
1407
+ };
1408
+ if (options.objectWebhooks.some((hook) => hook.endpoint.includes(`//host.docker.internal:`))) minio.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];
1409
+ }
1410
+ const mailpit = services.mailpit;
1411
+ if (mailpit && options.inboxRelay) {
1412
+ mailpit.environment = {
1413
+ ...mailpit.environment,
1414
+ MP_WEBHOOK_URL: options.inboxRelay
1415
+ };
1416
+ if (options.inboxRelay.includes(`//host.docker.internal:`)) mailpit.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];
1417
+ }
1418
+ return {
1419
+ name: options.project,
1420
+ services: {
1421
+ ...services,
1422
+ ...options.apps
1423
+ },
1424
+ ...Object.keys(volumes).length ? { volumes } : {}
1425
+ };
1426
+ }
1427
+ /** Render a compose document as the file it becomes. */
1428
+ function toYaml(file) {
1429
+ return `# Generated by gkm from the construct manifest — do not edit.
1430
+ # Containers are derived from what the app declares. Image pins and anything
1431
+ # no construct implies go in your own docker-compose.yml, which is merged over
1432
+ # this file and wins:
1433
+ #
1434
+ # docker compose -f docker-compose.constructs.yml -f docker-compose.yml …
1435
+ #
1436
+ # "gkm dev" and "gkm test" start the containers. The apps sit behind the
1437
+ # "apps" profile: run "gkm setup", then
1438
+ # docker compose -f docker-compose.constructs.yml --profile apps up --build
1439
+ ${stringify(file, { lineWidth: 0 })}`;
1440
+ }
1441
+ /** A container with no image, from config or from the defaults. */
1442
+ /**
1443
+ * The image the databases in the plan named for the shared local cluster, if
1444
+ * any did.
1445
+ */
1446
+ function declaredPostgresImage(plan) {
1447
+ const named = plan.resources.filter((r) => r.kind === "database" && Boolean(r.image));
1448
+ const images = [...new Set(named.map((r) => r.image))];
1449
+ if (images.length > 1) throw new ConflictingPostgresImages(named.map((r) => ({
1450
+ id: r.id,
1451
+ image: r.image
1452
+ })));
1453
+ return images[0];
1454
+ }
1455
+ /**
1456
+ * The image a `Telemetry` node named for OpenObserve, if one did — the same
1457
+ * one the stack runs (`stackTelemetry` refuses two that disagree).
1458
+ */
1459
+ function declaredTelemetryImage(plan) {
1460
+ return plan.resources.filter((r) => r.kind === "telemetry" && r.image).sort((a, b) => a.id.localeCompare(b.id))[0]?.image;
1461
+ }
1462
+ /** Two databases on the one local cluster named different images for it. */
1463
+ var ConflictingPostgresImages = class extends Error {
1464
+ databases;
1465
+ constructor(databases) {
1466
+ super(`Locally every database runs in one Postgres container, and these name different images for it: ${databases.map((d) => `${d.id} (${d.image})`).join(", ")}. Give them the same image — one that ships every extension they declare.`);
1467
+ this.databases = databases;
1468
+ this.name = "ConflictingPostgresImages";
1469
+ }
1470
+ };
1471
+ var UnknownContainer = class extends Error {
1472
+ /** The container that could not be resolved. */
1473
+ container;
1474
+ /** The containers that have a default, so the caller can see the set. */
1475
+ known = Object.keys(DEFAULT_IMAGES).sort();
1476
+ constructor(container) {
1477
+ super("No image is known for this container; pin one in config");
1478
+ this.name = "UnknownContainer";
1479
+ this.container = container;
1480
+ }
1481
+ };
1482
+ /** One container's definition, published on the port it was assigned. */
1483
+ function define(container, image, published, credentials) {
1484
+ switch (container) {
1485
+ case "postgres": return {
1486
+ image,
1487
+ restart: "unless-stopped",
1488
+ ports: published,
1489
+ environment: {
1490
+ POSTGRES_USER: credentials.postgres.user,
1491
+ POSTGRES_PASSWORD: credentials.postgres.password,
1492
+ POSTGRES_DB: CLUSTER_DATABASE
1493
+ },
1494
+ volumes: [`postgres-data:${POSTGRES_MOUNT}`],
1495
+ healthcheck: {
1496
+ test: ["CMD-SHELL", `pg_isready -U ${credentials.postgres.user} -d ${CLUSTER_DATABASE}`],
1497
+ interval: "5s",
1498
+ timeout: "3s",
1499
+ retries: 10,
1500
+ start_period: "10s"
1501
+ }
1502
+ };
1503
+ case "minio": return {
1504
+ image,
1505
+ restart: "unless-stopped",
1506
+ ports: published,
1507
+ environment: {
1508
+ MINIO_ROOT_USER: credentials.minio.user,
1509
+ MINIO_ROOT_PASSWORD: credentials.minio.password
1510
+ },
1511
+ command: "server --console-address \":9001\" /data",
1512
+ volumes: ["minio-data:/data"],
1513
+ healthcheck: {
1514
+ test: [
1515
+ "CMD",
1516
+ "mc",
1517
+ "ready",
1518
+ "local"
1519
+ ],
1520
+ interval: "10s",
1521
+ timeout: "5s",
1522
+ retries: 5,
1523
+ start_period: "10s"
1524
+ }
1525
+ };
1526
+ case "caddy": return {
1527
+ image,
1528
+ restart: "unless-stopped",
1529
+ ports: published,
1530
+ volumes: [
1531
+ "./.gkm/Caddyfile:/etc/caddy/Caddyfile:ro",
1532
+ "./.gkm/caddy-sites:/etc/caddy/sites:ro",
1533
+ "caddy-data:/data"
1534
+ ],
1535
+ extra_hosts: ["host.docker.internal:host-gateway"],
1536
+ healthcheck: {
1537
+ test: [
1538
+ "CMD",
1539
+ "caddy",
1540
+ "version"
1541
+ ],
1542
+ interval: "10s",
1543
+ timeout: "5s",
1544
+ retries: 5
1545
+ }
1546
+ };
1547
+ case "mailpit": return {
1548
+ image,
1549
+ restart: "unless-stopped",
1550
+ ports: published,
1551
+ environment: {
1552
+ MP_SMTP_AUTH_ACCEPT_ANY: "1",
1553
+ MP_SMTP_AUTH_ALLOW_INSECURE: "1"
1554
+ },
1555
+ healthcheck: {
1556
+ test: [
1557
+ "CMD",
1558
+ "wget",
1559
+ "-q",
1560
+ "--spider",
1561
+ "http://localhost:8025"
1562
+ ],
1563
+ interval: "10s",
1564
+ timeout: "5s",
1565
+ retries: 5
1566
+ }
1567
+ };
1568
+ case "redis": return {
1569
+ image,
1570
+ restart: "unless-stopped",
1571
+ ports: published,
1572
+ command: "sh -c 'exec docker-entrypoint.sh redis-server --requirepass \"$$REDIS_PASSWORD\"'",
1573
+ environment: {
1574
+ REDIS_PASSWORD: credentials.redis.password,
1575
+ REDISCLI_AUTH: credentials.redis.password
1576
+ },
1577
+ volumes: ["redis-data:/data"],
1578
+ healthcheck: {
1579
+ test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"],
1580
+ interval: "5s",
1581
+ timeout: "3s",
1582
+ retries: 5
1583
+ }
1584
+ };
1585
+ case "redis-http": return {
1586
+ image,
1587
+ restart: "unless-stopped",
1588
+ ports: published,
1589
+ environment: {
1590
+ SRH_MODE: "env",
1591
+ SRH_TOKEN: credentials.cacheToken,
1592
+ SRH_CONNECTION_STRING: `redis://:${encodeURIComponent(credentials.redis.password)}@redis:6379`
1593
+ },
1594
+ depends_on: ["redis"],
1595
+ healthcheck: {
1596
+ test: [
1597
+ "CMD",
1598
+ "wget",
1599
+ "-q",
1600
+ "-O",
1601
+ "/dev/null",
1602
+ "http://127.0.0.1:80/"
1603
+ ],
1604
+ interval: "5s",
1605
+ timeout: "3s",
1606
+ retries: 10
1607
+ }
1608
+ };
1609
+ case "rabbitmq": return {
1610
+ image,
1611
+ restart: "unless-stopped",
1612
+ ports: published,
1613
+ environment: {
1614
+ RABBITMQ_DEFAULT_USER: credentials.rabbitmq.user,
1615
+ RABBITMQ_DEFAULT_PASS: credentials.rabbitmq.password
1616
+ },
1617
+ volumes: ["rabbitmq-data:/var/lib/rabbitmq"],
1618
+ healthcheck: {
1619
+ test: [
1620
+ "CMD",
1621
+ "rabbitmq-diagnostics",
1622
+ "-q",
1623
+ "ping"
1624
+ ],
1625
+ interval: "10s",
1626
+ timeout: "5s",
1627
+ retries: 5
1628
+ }
1629
+ };
1630
+ case "localstack": return {
1631
+ image,
1632
+ restart: "unless-stopped",
1633
+ ports: published,
1634
+ extra_hosts: ["host.docker.internal:host-gateway"],
1635
+ environment: {
1636
+ AWS_DEFAULT_REGION: EMULATOR_REGION,
1637
+ AWS_ACCESS_KEY_ID: credentials.emulator.accessKeyId,
1638
+ AWS_SECRET_ACCESS_KEY: credentials.emulator.secretAccessKey
1639
+ },
1640
+ volumes: ["localstack-data:/var/lib/localstack"],
1641
+ healthcheck: {
1642
+ test: [
1643
+ "CMD",
1644
+ "bash",
1645
+ "-c",
1646
+ "exec 3<>/dev/tcp/localhost/4566"
1647
+ ],
1648
+ interval: "10s",
1649
+ timeout: "5s",
1650
+ retries: 5,
1651
+ start_period: "10s"
1652
+ }
1653
+ };
1654
+ case "openobserve": {
1655
+ const login = credentials.logs;
1656
+ return {
1657
+ image,
1658
+ restart: "unless-stopped",
1659
+ ports: published,
1660
+ environment: {
1661
+ [LOGS_EMAIL_KEY]: login.email,
1662
+ [LOGS_PASSWORD_KEY]: login.password,
1663
+ ZO_DATA_DIR: "/data",
1664
+ ZO_COMPACT_DATA_RETENTION_DAYS: String(30),
1665
+ ZO_TELEMETRY: "false"
1666
+ },
1667
+ volumes: ["openobserve-data:/data"],
1668
+ healthcheck: {
1669
+ test: [
1670
+ "CMD",
1671
+ "/openobserve",
1672
+ "node",
1673
+ "status"
1674
+ ],
1675
+ interval: "10s",
1676
+ timeout: "5s",
1677
+ retries: 12,
1678
+ start_period: "20s"
1679
+ }
1680
+ };
1681
+ }
1682
+ default: throw new UnknownContainer(container);
1683
+ }
1684
+ }
1685
+ /**
1686
+ * The published port mappings for a container.
1687
+ *
1688
+ * Every port is looked up by its own key rather than being derived as an offset
1689
+ * from the container's first, so MinIO's console cannot land on whatever was
1690
+ * allocated to the next container.
1691
+ */
1692
+ function publish(container, ports, fakes) {
1693
+ return portsOf(container, fakes).map((port) => {
1694
+ const assigned = ports[port.key];
1695
+ if (assigned === void 0) throw new UnassignedPort(port.key);
1696
+ return `${assigned}:${port.inside}`;
1697
+ });
1698
+ }
1699
+ /** A planned port that allocation never assigned. */
1700
+ var UnassignedPort = class extends Error {
1701
+ /** The port key that went unassigned, e.g. `minio-console`. */
1702
+ key;
1703
+ constructor(key) {
1704
+ super("No port was assigned for this container port");
1705
+ this.name = "UnassignedPort";
1706
+ this.key = key;
1707
+ }
1708
+ };
1709
+ //#endregion
1710
+ //#region src/compose/redis.ts
1711
+ /**
1712
+ * The stack's Redis: what every declared cache lives in when a workspace runs
1713
+ * as a `gkm compose` stack, on the local stage and on a deployed one alike.
1714
+ *
1715
+ * A cache is the one store whose contents can always be rebuilt, so unlike
1716
+ * Mailpit and MinIO it is a production service, not a dev stand-in: it runs
1717
+ * for every stage, on the compose network only, with nothing published. It
1718
+ * is bounded (`maxmemory`, evicting the least recently used key), persisted
1719
+ * (an append-only file on a named volume, kept by `--down`) and password
1720
+ * protected — the stage's own password, generated once like its seed.
1721
+ *
1722
+ * A stage that sets a cache's URL in its secrets — a managed Redis — keeps
1723
+ * it, and a stack whose every cache is set that way runs no Redis at all.
1724
+ *
1725
+ * Pure: the stack decides it, and the phases keep the password.
1726
+ */
1727
+ /**
1728
+ * Where a stack's caches live: its own Redis, whatever the deploy target's
1729
+ * default is. A stack is one machine running containers, and a Redis beside
1730
+ * the apps is cheaper for a cache than a table in the database they share.
1731
+ */
1732
+ const STACK_CACHE = "redis";
1733
+ /** Its compose service name — the host every cache URL points at. */
1734
+ const REDIS_SERVICE = "redis";
1735
+ /** The port it answers on, inside the network. */
1736
+ const REDIS_PORT = 6379;
1737
+ /** Reconcile's pin, so `gkm dev` and the stack run one Redis. */
1738
+ const REDIS_IMAGE = DEFAULT_IMAGES.redis;
1739
+ /**
1740
+ * How much it may hold before it evicts. A cache that grows until the box
1741
+ * runs out of memory takes the apps with it; 256 MB is a lot of sessions and
1742
+ * little of a small server. A project's `docker-compose.<stage>.yml` can
1743
+ * replace the command to change it.
1744
+ */
1745
+ const REDIS_MAXMEMORY = "256mb";
1746
+ /** The stage secret holding its password. */
1747
+ const REDIS_PASSWORD_KEY = "REDIS_PASSWORD";
1748
+ /** Redis's own count of logical databases, before `--databases` raises it. */
1749
+ const REDIS_DATABASES = 16;
1750
+ /** A deployed stage that runs the stack's Redis and has no password yet. */
1751
+ var RedisPasswordMissing = class extends GkmError {
1752
+ stage;
1753
+ constructor(stage) {
1754
+ super(`The stage '${stage}' runs the stack's Redis and has no ${REDIS_PASSWORD_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to generate it, or set one: gkm secrets:set ${REDIS_PASSWORD_KEY} '…' --stage ${stage}`);
1755
+ this.stage = stage;
1756
+ this.name = "RedisPasswordMissing";
1757
+ }
1758
+ };
1759
+ /**
1760
+ * Whether a stage's stack runs Redis: a cache or a WebSocket surface is
1761
+ * declared and the stage's secrets do not set the URL of every one.
1762
+ */
1763
+ function runsRedis(manifest, custom) {
1764
+ return Object.values(manifest).some((declaration) => {
1765
+ if (declaration?.kind === "cache") return (declaration.provides ?? []).some((key) => custom[key] === void 0);
1766
+ return declaration?.kind === "websocket-api" && custom[providedKeyFor(declaration.id, declaration.kind, "publisherConnectionString")] === void 0;
1767
+ });
1768
+ }
1769
+ /** A password: 256 random bits, URL-safe, so it sits in a URL unescaped. */
1770
+ function generateRedisPassword() {
1771
+ return randomBytes(32).toString("base64url");
1772
+ }
1773
+ /**
1774
+ * The stage's secrets with a generated Redis password, where it has none.
1775
+ * Pure, like `withGeneratedSecrets`: the caller keeps the result once the run
1776
+ * goes ahead.
1777
+ */
1778
+ function withRedisPassword(secrets) {
1779
+ if (secrets.custom?.["REDIS_PASSWORD"]) return {
1780
+ secrets,
1781
+ generated: []
1782
+ };
1783
+ return {
1784
+ secrets: {
1785
+ ...secrets,
1786
+ custom: {
1787
+ ...secrets.custom,
1788
+ [REDIS_PASSWORD_KEY]: generateRedisPassword()
1789
+ },
1790
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1791
+ },
1792
+ generated: [REDIS_PASSWORD_KEY]
1793
+ };
1794
+ }
1795
+ /**
1796
+ * The stack's Redis for one stage, or nothing where no cache needs it.
1797
+ *
1798
+ * Each cache it holds gets a logical database of its own, by the order of
1799
+ * their ids, so two caches never read each other's keys.
1800
+ */
1801
+ function stackRedis(options) {
1802
+ const { plan, stage, local, custom } = options;
1803
+ const caches = plan.resources.filter((r) => r.kind === "cache" && custom[r.envKey] === void 0).sort((a, b) => a.id.localeCompare(b.id));
1804
+ const publishers = plan.resources.filter((r) => r.kind === "websocket-api").map((r) => providedKeyFor(r.id, r.kind, "publisherConnectionString")).filter((key) => custom[key] === void 0);
1805
+ if (caches.length === 0 && publishers.length === 0) return void 0;
1806
+ const set = custom[REDIS_PASSWORD_KEY];
1807
+ const password = set ?? (local ? options.localPassword : void 0);
1808
+ if (!password) throw new RedisPasswordMissing(stage);
1809
+ const auth = encodeURIComponent(password);
1810
+ return {
1811
+ password,
1812
+ passwordFromSecrets: Boolean(set),
1813
+ urls: Object.fromEntries([...caches.map((cache, index) => [cache.envKey, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}/${index}`]), ...publishers.map((key) => [key, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}`])]),
1814
+ env: {
1815
+ [REDIS_PASSWORD_KEY]: password,
1816
+ REDISCLI_AUTH: password
1817
+ },
1818
+ databases: Math.max(REDIS_DATABASES, caches.length)
1819
+ };
1820
+ }
1821
+ /**
1822
+ * Redis's service: bounded, persisted and password protected, on the
1823
+ * network alone.
1824
+ *
1825
+ * The command runs the image's own entrypoint with `redis-server` first, so
1826
+ * it still drops to the `redis` user and owns `/data`; the password is read
1827
+ * from the env file by the shell (`$$` is compose's escape for `$`), so
1828
+ * neither the compose file nor the container's command holds it.
1829
+ */
1830
+ function redisService(redis) {
1831
+ const flags = [
1832
+ `--requirepass "$$${REDIS_PASSWORD_KEY}"`,
1833
+ `--maxmemory ${REDIS_MAXMEMORY}`,
1834
+ "--maxmemory-policy allkeys-lru",
1835
+ "--appendonly yes",
1836
+ ...redis.databases > REDIS_DATABASES ? [`--databases ${redis.databases}`] : []
1837
+ ];
1838
+ return {
1839
+ image: REDIS_IMAGE,
1840
+ restart: "unless-stopped",
1841
+ command: [
1842
+ "sh",
1843
+ "-c",
1844
+ `exec docker-entrypoint.sh redis-server ${flags.join(" ")}`
1845
+ ],
1846
+ env_file: [{
1847
+ path: `./${REDIS_SERVICE}.env`,
1848
+ format: "raw"
1849
+ }],
1850
+ volumes: ["redis-data:/data"],
1851
+ healthcheck: {
1852
+ test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"],
1853
+ interval: "5s",
1854
+ timeout: "3s",
1855
+ retries: 10
1856
+ }
1857
+ };
1858
+ }
1859
+ //#endregion
1860
+ //#region src/deploy/nextRelease.ts
1861
+ /**
1862
+ * What every Next.js build gkm runs is handed so a release does not break the
1863
+ * tabs the last one opened (#508).
1864
+ *
1865
+ * - **`NEXT_DEPLOYMENT_ID`**, the release: the image tag on a server stage
1866
+ * (`<commit>-<stage>`), the deploy's tag on AWS. Next reads it at
1867
+ * `next build` as its `deploymentId`, tags every asset and request with it,
1868
+ * and when a tab opened on an older release asks for a chunk the new one
1869
+ * does not have, does a full page load instead of throwing
1870
+ * `ChunkLoadError`. Off Vercel, Next takes the variable over a
1871
+ * `deploymentId` in `next.config` rather than erroring — so a site that
1872
+ * sets one has gkm's.
1873
+ * - **`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`**, the stage's: 32 random bytes,
1874
+ * base64, generated on the stage's first deploy and kept in its secrets.
1875
+ * Next derives its server actions' ids and encrypts their closures with
1876
+ * it, so a form submitted from a tab opened before a deploy still finds
1877
+ * its action after it. A deploy never rotates it; `gkm secrets:set` does.
1878
+ *
1879
+ * Only a Next site that runs a server is handed the key — at build, and on
1880
+ * its server at runtime. No other app reads it: it is the stack's
1881
+ * (`isStackKey`), never one every process is handed.
1882
+ */
1883
+ /** The release Next tags a build with: its `deploymentId`. */
1884
+ const NEXT_DEPLOYMENT_ID_KEY = "NEXT_DEPLOYMENT_ID";
1885
+ /** The stage's server actions key. */
1886
+ const NEXT_ACTIONS_KEY = "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY";
1887
+ /** Whether a site is built by Next. */
1888
+ function isNextSite(site) {
1889
+ return site?.variant === "next";
1890
+ }
1891
+ /** Whether any site the manifest declares is built by Next. */
1892
+ function hasNextSite(manifest) {
1893
+ return Object.values(manifest).some((declaration) => declaration?.kind === "site" && isNextSite(declaration));
1894
+ }
1895
+ /** A new {@link NEXT_ACTIONS_KEY}: 32 random bytes, base64, as Next takes it. */
1896
+ function newNextActionsKey() {
1897
+ return randomBytes(32).toString("base64");
1898
+ }
1899
+ /**
1900
+ * What a site's build is handed for its release: the deployment id, and the
1901
+ * stage's actions key where it has one. Nothing for a site Next does not
1902
+ * build.
1903
+ */
1904
+ function nextBuildValues(site, release, secrets) {
1905
+ if (!isNextSite(site)) return {};
1906
+ return {
1907
+ [NEXT_DEPLOYMENT_ID_KEY]: release,
1908
+ ...nextRuntimeValues(site, secrets)
1909
+ };
1910
+ }
1911
+ /**
1912
+ * What a Next site's server reads at runtime: the stage's actions key — the
1913
+ * one its build was made with. Nothing for any other app.
1914
+ */
1915
+ function nextRuntimeValues(site, secrets) {
1916
+ if (!isNextSite(site)) return {};
1917
+ const key = secrets[NEXT_ACTIONS_KEY];
1918
+ return key ? { [NEXT_ACTIONS_KEY]: key } : {};
1919
+ }
1920
+ //#endregion
1921
+ //#region src/deploy/generated.ts
1922
+ /**
1923
+ * The values a deployed stage generates once and keeps: what nothing can
1924
+ * provision and nobody else issues.
1925
+ *
1926
+ * - **A seed**, which salts every password a deploy derives — a database's
1927
+ * master and roles, a bucket's root user. Derived from repo facts alone
1928
+ * (project, stage, construct id), those passwords were computable by anyone
1929
+ * who could read the repo.
1930
+ * - **Each `secret` construct's value** — an auth server's signing secret, a
1931
+ * `RandomPassword` — random, rather than derived, in its declared format.
1932
+ * - **Each `encryption` construct's keyring** — one random key and an index
1933
+ * key. Later keys are added by `gkm encryption:rotate`, never by a deploy.
1934
+ * - **A Next site's server actions key** (`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`),
1935
+ * where the stage has a Next site: one per stage, so an action submitted
1936
+ * from a tab opened before a deploy still resolves after it.
1937
+ *
1938
+ * Both are generated on the first deploy that needs them and written to the
1939
+ * stage's store, so every later deploy reads the same values: sessions survive
1940
+ * a redeploy, and a role's password does not move. A value set by hand with
1941
+ * `gkm secrets:set` is kept, never replaced.
1942
+ */
1943
+ /**
1944
+ * The stage's secrets with its seed and every declared `secret`'s value
1945
+ * present, generating what is missing. Pure: the caller writes the result
1946
+ * back to the stage's store when `generated` is not empty.
1947
+ */
1948
+ function withGeneratedSecrets(secrets, manifest) {
1949
+ const generated = [];
1950
+ const custom = { ...secrets.custom };
1951
+ for (const declaration of Object.values(manifest)) {
1952
+ if (declaration?.kind !== "secret" && declaration?.kind !== "encryption") continue;
1953
+ const key = declaration.provides?.[0];
1954
+ if (!key || custom[key]) continue;
1955
+ custom[key] = declaration.kind === "encryption" ? generateKeyring() : drawSecret(randomInt, declaration);
1956
+ generated.push(key);
1957
+ }
1958
+ if (hasNextSite(manifest) && !custom["NEXT_SERVER_ACTIONS_ENCRYPTION_KEY"]) {
1959
+ custom[NEXT_ACTIONS_KEY] = newNextActionsKey();
1960
+ generated.push(NEXT_ACTIONS_KEY);
1961
+ }
1962
+ const seed = secrets.seed ?? generateSeed();
1963
+ if (!secrets.seed) generated.push("seed");
1964
+ return {
1965
+ secrets: generated.length ? {
1966
+ ...secrets,
1967
+ seed,
1968
+ custom,
1969
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1970
+ } : secrets,
1971
+ generated
1972
+ };
1973
+ }
1974
+ /** A stage's seed: 256 random bits, URL-safe. */
1975
+ function generateSeed() {
1976
+ return random();
1977
+ }
1978
+ /** 256 bits, URL-safe. */
1979
+ function random() {
1980
+ return randomBytes(32).toString("base64url");
1981
+ }
1982
+ /** MinIO's root user, the same for every workspace: it is not a secret. */
1983
+ const LOCAL_MINIO_USER = "minio";
1984
+ /** RabbitMQ's administrator, the same way. */
1985
+ const LOCAL_RABBITMQ_USER = "rabbitmq";
1986
+ /**
1987
+ * The Postgres superuser for a workspace: its name as an identifier, with
1988
+ * `_admin` — never the bare name, which a database construct of the same
1989
+ * name would claim as its runtime role.
1990
+ */
1991
+ function postgresSuperuser(project) {
1992
+ return `${postgresRoleSlug(project)}_admin`;
1993
+ }
1994
+ /**
1995
+ * The project as the start of a role's name: lowercase, `_` for anything
1996
+ * else, never starting with a digit — `gkm` when nothing is left.
1997
+ */
1998
+ function postgresRoleSlug(project) {
1999
+ return project.toLowerCase().replace(/^@[^/]+\//, "").replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").replace(/^(\d)/, "_$1") || "gkm";
2000
+ }
2001
+ /** 256 random bits, URL-safe. */
2002
+ function token() {
2003
+ return randomBytes(32).toString("base64url");
2004
+ }
2005
+ /** `length` characters of letters and digits, which every client takes as is. */
2006
+ function alphanumeric(length) {
2007
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2008
+ let out = "";
2009
+ for (let i = 0; i < length; i++) out += alphabet[randomInt(62)];
2010
+ return out;
2011
+ }
2012
+ /** A fresh set of local logins for a workspace. */
2013
+ function generateLocalCredentials(project) {
2014
+ return {
2015
+ seed: generateSeed(),
2016
+ postgres: {
2017
+ user: postgresSuperuser(project),
2018
+ password: token()
2019
+ },
2020
+ minio: {
2021
+ user: LOCAL_MINIO_USER,
2022
+ password: alphanumeric(32)
2023
+ },
2024
+ rabbitmq: {
2025
+ user: LOCAL_RABBITMQ_USER,
2026
+ password: token()
2027
+ },
2028
+ redis: { password: generateRedisPassword() },
2029
+ cacheToken: token(),
2030
+ emulator: {
2031
+ accessKeyId: EMULATOR_ACCESS_KEY_ID,
2032
+ secretAccessKey: alphanumeric(40)
2033
+ },
2034
+ logs: {
2035
+ email: LOCAL_LOGS_EMAIL,
2036
+ password: generateLogsPassword()
2037
+ }
2038
+ };
2039
+ }
2040
+ /**
2041
+ * The stored logins with anything missing generated — a file an older gkm
2042
+ * wrote before a service existed. Pure: the caller writes the result back
2043
+ * when `generated` is not empty.
2044
+ */
2045
+ function withLocalCredentials(stored, project) {
2046
+ const fresh = generateLocalCredentials(project);
2047
+ const generated = Object.keys(fresh).filter((key) => stored?.[key] === void 0);
2048
+ return {
2049
+ credentials: {
2050
+ ...fresh,
2051
+ ...stored
2052
+ },
2053
+ generated
2054
+ };
2055
+ }
2056
+ /** Where a workspace's local logins are kept on this machine. */
2057
+ function localCredentialsPath(project) {
2058
+ const keys = getKeystoreDir(project);
2059
+ const name = keys.split(/[\\/]/).at(-1);
2060
+ const namespace = keys.split(/[\\/]/).at(-2);
2061
+ return join(project.home ?? gkmHome(), "local", namespace, `${name}.json`);
2062
+ }
2063
+ /** The local stage's logins file is there, and its key is not. */
2064
+ var LocalCredentialsKeyMissing = class extends GkmError {
2065
+ path;
2066
+ stage;
2067
+ constructor(path, stage) {
2068
+ super(`The local logins at ${path} are encrypted with the '${stage}' stage's key, and this machine has none. Remove the file to generate new ones — the containers' volumes are rotated to them on the next gkm dev.`);
2069
+ this.path = path;
2070
+ this.stage = stage;
2071
+ this.name = "LocalCredentialsKeyMissing";
2072
+ }
2073
+ };
2074
+ /** Another gkm held the logins file's lock for longer than any write takes. */
2075
+ var LocalCredentialsLocked = class extends GkmError {
2076
+ lock;
2077
+ constructor(lock) {
2078
+ super(`Another gkm has been writing the local logins for over ${LOCK_TIMEOUT_MS / 1e3}s. If none is running, remove ${lock} and run the command again.`);
2079
+ this.lock = lock;
2080
+ this.name = "LocalCredentialsLocked";
2081
+ }
2082
+ };
2083
+ /** Read the stored logins, or `null` where none were generated yet. */
2084
+ async function readLocalCredentials(workspace, home) {
2085
+ const project = keystoreProject(workspace, home);
2086
+ const path = localCredentialsPath(project);
2087
+ if (!existsSync(path)) return null;
2088
+ const stage = workspace.stages.local;
2089
+ const key = await readKey(stage, project);
2090
+ if (!key) throw new LocalCredentialsKeyMissing(path, stage);
2091
+ const file = JSON.parse(await readFile(path, "utf-8"));
2092
+ return decrypt(file, key);
2093
+ }
2094
+ /** Write the logins, encrypted with the local stage's key, owner-only. */
2095
+ async function saveLocalCredentials(workspace, credentials, home) {
2096
+ const project = keystoreProject(workspace, home);
2097
+ const path = localCredentialsPath(project);
2098
+ const key = await getOrCreateKey(workspace.stages.local, project);
2099
+ await mkdir(dirname(path), {
2100
+ recursive: true,
2101
+ mode: 448
2102
+ });
2103
+ await writeFile(path, JSON.stringify(encrypt(credentials, key), null, 2), { mode: 384 });
2104
+ }
2105
+ /**
2106
+ * The workspace's local logins: read back, or generated and kept the first
2107
+ * time anything needs them.
2108
+ *
2109
+ * Under a lock, because a workspace's `gkm dev` starts one per app and the
2110
+ * first run of each would otherwise generate — and keep — its own.
2111
+ */
2112
+ async function loadLocalCredentials(workspace, home) {
2113
+ return withLock(`${localCredentialsPath(keystoreProject(workspace, home))}.lock`, async () => {
2114
+ const result = withLocalCredentials(await readLocalCredentials(workspace, home), workspace.name);
2115
+ if (result.generated.length > 0) await saveLocalCredentials(workspace, result.credentials, home);
2116
+ return result;
2117
+ });
2118
+ }
2119
+ /** How long a lock may be held before it is someone else's problem. */
2120
+ const LOCK_TIMEOUT_MS = 15e3;
2121
+ async function withLock(lock, body) {
2122
+ await mkdir(dirname(lock), {
2123
+ recursive: true,
2124
+ mode: 448
2125
+ });
2126
+ const started = Date.now();
2127
+ for (;;) try {
2128
+ await mkdir(lock);
2129
+ break;
2130
+ } catch (error) {
2131
+ if (error.code !== "EEXIST") throw error;
2132
+ if (await stat(lock).then((s) => Date.now() - s.mtimeMs).catch(() => 0) > LOCK_TIMEOUT_MS) {
2133
+ await rm(lock, {
2134
+ recursive: true,
2135
+ force: true
2136
+ });
2137
+ continue;
2138
+ }
2139
+ if (Date.now() - started > LOCK_TIMEOUT_MS) throw new LocalCredentialsLocked(lock);
2140
+ await new Promise((resolve) => setTimeout(resolve, 50));
2141
+ }
2142
+ try {
2143
+ return await body();
2144
+ } finally {
2145
+ await rm(lock, {
2146
+ recursive: true,
2147
+ force: true
2148
+ });
2149
+ }
2150
+ }
2151
+ //#endregion
2152
+ //#region src/credentials/index.ts
2153
+ const logger = console;
2154
+ /**
2155
+ * Load environment files
2156
+ * @internal Exported for testing
2157
+ */
2158
+ function loadEnvFiles(envConfig, cwd = process.cwd()) {
2159
+ const loaded = [];
2160
+ const missing = [];
2161
+ const envFiles = envConfig ? Array.isArray(envConfig) ? envConfig : [envConfig] : [".env"];
2162
+ for (const envFile of envFiles) {
2163
+ const envPath = resolve(cwd, envFile);
2164
+ if (existsSync(envPath)) {
2165
+ config({
2166
+ path: envPath,
2167
+ override: true,
2168
+ quiet: true
2169
+ });
2170
+ loaded.push(envFile);
2171
+ } else if (envConfig) missing.push(envFile);
2172
+ }
2173
+ return {
2174
+ loaded,
2175
+ missing
2176
+ };
2177
+ }
2178
+ /**
2179
+ * Check if a port is available
2180
+ * @internal Exported for testing
2181
+ */
2182
+ async function isPortAvailable(port) {
2183
+ return new Promise((resolve) => {
2184
+ const server = createServer();
2185
+ server.once("error", (err) => {
2186
+ if (err.code === "EADDRINUSE") resolve(false);
2187
+ else resolve(false);
2188
+ });
2189
+ server.once("listening", () => {
2190
+ server.close();
2191
+ resolve(true);
2192
+ });
2193
+ server.listen(port);
2194
+ });
2195
+ }
2196
+ /**
2197
+ * Find an available port starting from the preferred port
2198
+ * @internal Exported for testing
2199
+ */
2200
+ async function findAvailablePort(preferredPort, maxAttempts = 10) {
2201
+ for (let i = 0; i < maxAttempts; i++) {
2202
+ const port = preferredPort + i;
2203
+ if (await isPortAvailable(port)) return port;
2204
+ logger.log(`⚠️ Port ${port} is in use, trying ${port + 1}...`);
2205
+ }
2206
+ throw new Error(`Could not find an available port after trying ${maxAttempts} ports starting from ${preferredPort}`);
2207
+ }
2208
+ const PORT_STATE_PATH = ".gkm/ports.json";
2209
+ /**
2210
+ * Load saved port state from .gkm/ports.json.
2211
+ * @internal Exported for testing
2212
+ */
2213
+ async function loadPortState(workspaceRoot) {
2214
+ try {
2215
+ const raw = await readFile(join(workspaceRoot, PORT_STATE_PATH), "utf-8");
2216
+ return JSON.parse(raw);
2217
+ } catch {
2218
+ return {};
2219
+ }
2220
+ }
2221
+ /**
2222
+ * Save port state to .gkm/ports.json.
2223
+ * @internal Exported for testing
2224
+ */
2225
+ async function savePortState(workspaceRoot, ports) {
2226
+ const dir = join(workspaceRoot, ".gkm");
2227
+ await mkdir(dir, { recursive: true });
2228
+ await writeFile(join(workspaceRoot, PORT_STATE_PATH), `${JSON.stringify(ports, null, 2)}\n`);
2229
+ }
2230
+ /**
2231
+ * Load and flatten a stage's secrets from its store.
2232
+ *
2233
+ * Every key as stored — nothing renamed. An app's database URL is its
2234
+ * construct's key, derived by reconcile, and never a stored per-app value
2235
+ * mapped onto `DATABASE_URL`.
2236
+ * @internal Exported for testing
2237
+ */
2238
+ async function loadSecretsForApp(store, stage) {
2239
+ const stageSecrets = await store.read(stage);
2240
+ if (!stageSecrets) return {};
2241
+ logger.log(`🔐 Loading secrets from stage: ${stage}`);
2242
+ return toEmbeddableSecrets(stageSecrets);
2243
+ }
2244
+ /**
2245
+ * Walk up the directory tree to find the root containing .gkm/secrets/.
2246
+ * @internal Exported for testing
2247
+ */
2248
+ function findSecretsRoot(startDir) {
2249
+ let dir = startDir;
2250
+ while (dir !== "/") {
2251
+ if (existsSync(join(dir, ".gkm", "secrets"))) return dir;
2252
+ const parent = dirname(dir);
2253
+ if (parent === dir) break;
2254
+ dir = parent;
2255
+ }
2256
+ return startDir;
2257
+ }
2258
+ /**
2259
+ * Generate the credentials injection code snippet.
2260
+ * This is the common logic used by both entry wrapper and exec preload.
2261
+ * @internal
2262
+ */
2263
+ function generateCredentialsInjection(secretsJsonPath) {
2264
+ return `import { existsSync, readFileSync } from 'node:fs';
2265
+
2266
+ // Inject dev secrets via globalThis and process.env
2267
+ // Using globalThis.__gkm_credentials__ avoids CJS/ESM interop issues where
2268
+ // Object.assign on the Credentials export only mutates one module copy.
2269
+ const secretsPath = '${secretsJsonPath}';
2270
+ if (existsSync(secretsPath)) {
2271
+ const secrets = JSON.parse(readFileSync(secretsPath, 'utf-8'));
2272
+ globalThis.__gkm_credentials__ = secrets;
2273
+ Object.assign(process.env, secrets);
2274
+ }
2275
+ `;
2276
+ }
2277
+ /**
2278
+ * Create a preload script that injects secrets into Credentials.
2279
+ * Used by `gkm exec` to inject secrets before running any command.
2280
+ * @internal Exported for testing
2281
+ */
2282
+ async function createCredentialsPreload(preloadPath, secretsJsonPath) {
2283
+ const content = `/**
2284
+ * Credentials preload generated by 'gkm exec'
2285
+ * This file is loaded via NODE_OPTIONS="--import <path>"
2286
+ */
2287
+ ${generateCredentialsInjection(secretsJsonPath)}`;
2288
+ await writeFile(preloadPath, content);
2289
+ }
2290
+ /**
2291
+ * Create a wrapper script that injects secrets before importing the entry file.
2292
+ * @internal Exported for testing
2293
+ */
2294
+ async function createEntryWrapper(wrapperPath, entryPath, secretsJsonPath) {
2295
+ const content = `#!/usr/bin/env node
2296
+ /**
2297
+ * Entry wrapper generated by 'gkm dev --entry'
2298
+ */
2299
+ ${secretsJsonPath ? `${generateCredentialsInjection(secretsJsonPath)}
2300
+ ` : ""}// Import and run the user's entry file (dynamic import ensures secrets load first)
2301
+ await import('${entryPath}');
2302
+ `;
2303
+ await writeFile(wrapperPath, content);
2304
+ }
2305
+ /**
2306
+ * Prepare credentials for dev/exec/test modes.
2307
+ * Loads workspace config, secrets, resolves Docker ports, rewrites URLs,
2308
+ * injects PORT, dependency URLs, and writes credentials JSON.
2309
+ *
2310
+ * @param options.stage - The stage whose secrets to load. Default: the project's `stages.local`.
2311
+ * @param options.startDocker - Start Docker Compose services after port resolution. Default: false.
2312
+ * @param options.secretsFileName - Custom secrets JSON filename. Default: 'dev-secrets-{appName}.json' or 'dev-secrets.json'.
2313
+ * @internal Exported for testing
2314
+ */
2315
+ async function prepareEntryCredentials(options) {
2316
+ const cwd = options.cwd ?? process.cwd();
2317
+ let workspaceAppPort;
2318
+ let secretsRoot = cwd;
2319
+ let appName;
2320
+ let appInfo;
2321
+ let workspace;
2322
+ try {
2323
+ appInfo = await loadWorkspaceAppInfo(cwd);
2324
+ workspace = appInfo.workspace;
2325
+ workspaceAppPort = appInfo.app.port;
2326
+ secretsRoot = appInfo.workspaceRoot;
2327
+ appName = appInfo.appName;
2328
+ } catch (error) {
2329
+ if (!(error instanceof NotInAnApp || error instanceof ConfigNotFound)) throw error;
2330
+ workspace = await loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
2331
+ secretsRoot = workspace?.root ?? findSecretsRoot(cwd);
2332
+ }
2333
+ if (appName && workspace && options.explicitPort === void 0) {
2334
+ const { assignAppPorts, describeMove, holderOf, withAppPorts } = await import("./appPorts-BoXMwolc.mjs").then((n) => n.n);
2335
+ const assigned = await assignAppPorts(workspace, [appName], {
2336
+ free: isPortAvailable,
2337
+ holder: holderOf
2338
+ });
2339
+ for (const move of assigned.moved) logger.log(describeMove(move));
2340
+ workspace = withAppPorts(workspace, assigned.ports);
2341
+ workspaceAppPort = assigned.ports[appName] ?? workspaceAppPort;
2342
+ }
2343
+ if (appName) {
2344
+ const { APP_TAG_ENV, appTag } = await import("./appPorts-BoXMwolc.mjs").then((n) => n.n);
2345
+ process.env[APP_TAG_ENV] = appTag(secretsRoot, appName);
2346
+ }
2347
+ const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
2348
+ const stage = options.stage ?? workspace?.stages.local;
2349
+ const store = stage ? workspace ? await secretsStoreFor(workspace, stage) : new FileSecretsStore(secretsRoot) : void 0;
2350
+ const credentials = store && stage ? await loadSecretsForApp(store, stage) : {};
2351
+ credentials.PORT = String(resolvedPort);
2352
+ if (appInfo?.app.type === "mobile") credentials.RCT_METRO_PORT = String(resolvedPort);
2353
+ const declaredKeys = [];
2354
+ let reconciled;
2355
+ if (workspace) {
2356
+ const { reconcileWorkspace } = await import("./stack-BXmLQf3K.mjs").then((n) => n.Pt);
2357
+ const result = await reconcileWorkspace(workspace, {
2358
+ stage: options.reconcileStage ?? workspace.stages.local,
2359
+ start: options.startDocker ?? false
2360
+ });
2361
+ reconciled = result;
2362
+ if (options.scoped && appName) {
2363
+ const { appProcess, processEnv } = await import("./stack-BXmLQf3K.mjs").then((n) => n.wt);
2364
+ const own = processEnv(result.manifest, appProcess(workspace, result.manifest, result.background, appName), { ...credentials }, result.env);
2365
+ for (const key of Object.keys(credentials)) delete credentials[key];
2366
+ Object.assign(credentials, own);
2367
+ } else Object.assign(credentials, reconciled.env);
2368
+ declaredKeys.push(...Object.keys(reconciled.env).filter((key) => key in credentials));
2369
+ if (Object.keys(reconciled.env).length > 0) logger.log(`🔌 Resolved ${Object.keys(reconciled.env).length} declared URL(s)`);
2370
+ }
2371
+ const secretsDir = join(secretsRoot, ".gkm");
2372
+ await mkdir(secretsDir, { recursive: true });
2373
+ const secretsFileName = options.secretsFileName ?? (appName ? `dev-secrets-${appName}.json` : "dev-secrets.json");
2374
+ const secretsJsonPath = join(secretsDir, secretsFileName);
2375
+ await writeFile(secretsJsonPath, JSON.stringify(credentials, null, 2));
2376
+ return {
2377
+ credentials,
2378
+ resolvedPort,
2379
+ secretsJsonPath,
2380
+ appName,
2381
+ secretsRoot,
2382
+ appInfo,
2383
+ declaredKeys,
2384
+ ...reconciled ? { reconciled } : {}
2385
+ };
2386
+ }
2387
+ //#endregion
2388
+ export { minioNotificationRule as $, POSTGRES_MOUNT as A, NoDomainForStage as At, hostsFor as B, REDIS_SERVICE as C, logsAccess as Ct, stackRedis as D, otlpHeaders as Dt, runsRedis as E, logsService as Et, TELEMETRY_CONTAINER as F, scopeTelemetryEnv as G, PROCESSORS_DEV_PREFIX as H, planFor as I, surfaceClientTraced as J, siteClientTelemetry as K, resourceName as L, declaredPostgresImage as M, isMainFrontendApp as Mt, toYaml as N, resolveHost as Nt, withRedisPassword as O, stackLogs as Ot, PgBossNeedsDatabase as P, NOTIFICATION_RULE_PREFIX as Q, LOCAL_TLD as R, REDIS_PASSWORD_KEY as S, LogsPortTaken as St, redisService as T, logsPorts as Tt, appTelemetry as U, localRoutes as V, isTelemetryKey as W, usesTelemetry as X, telemetryOf as Y, HOST_GATEWAY as Z, NEXT_ACTIONS_KEY as _, LOCAL_LOGS_EMAIL as _t, loadEnvFiles as a, emulatorEndpoint as at, nextBuildValues as b, LOGS_PASSWORD_KEY as bt, prepareEntryCredentials as c, DEFAULT_IMAGES as ct, loadLocalCredentials as d, portKeys as dt, minioWebhookEnv as et, postgresRoleSlug as f, portsOf as ft, withGeneratedSecrets as g, volumeOf as gt, saveLocalCredentials as h, serviceAddresses as ht, isPortAvailable as i, EMULATOR_REGION as it, composeFor as j, getPublicUrlArgNames as jt, CLUSTER_DATABASE as k, withLogsLogin as kt, savePortState as l, describeServices as lt, readLocalCredentials as m, primaryPortKey as mt, createEntryWrapper as n, watchedBuckets as nt, loadPortState as o, emulatorQueueUrl as ot, postgresSuperuser as p, postgresImage as pt, stackTelemetry as q, findAvailablePort as r, EMULATOR_ACCESS_KEY_ID as rt, loadSecretsForApp as s, emulatorTopicArn as st, createCredentialsPreload as t, objectsWebhookToken as tt, LOCAL_RABBITMQ_USER as u, fakeKey as ut, NEXT_DEPLOYMENT_ID_KEY as v, LOGS_EMAIL_KEY as vt, STACK_CACHE as w, logsOnPort as wt, nextRuntimeValues as x, LOGS_SERVICE as xt, hasNextSite as y, LOGS_ORG as yt, hostFor as z };
2389
+
2390
+ //# sourceMappingURL=credentials-VLP_959f.mjs.map