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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) 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-B5BKAoLz.mjs +1039 -0
  7. package/dist/EndpointGenerator-B5BKAoLz.mjs.map +1 -0
  8. package/dist/EndpointGenerator-DxrRqfJ3.cjs +1098 -0
  9. package/dist/EndpointGenerator-DxrRqfJ3.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-CBqsvbER.cjs +412 -0
  11. package/dist/GoDaddyProvider-CBqsvbER.cjs.map +1 -0
  12. package/dist/GoDaddyProvider-CwqdLM1E.mjs +412 -0
  13. package/dist/GoDaddyProvider-CwqdLM1E.mjs.map +1 -0
  14. package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-DtOtsFkM.cjs} +23 -9
  15. package/dist/HostingerProvider-DtOtsFkM.cjs.map +1 -0
  16. package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-gD4uqzMN.mjs} +23 -9
  17. package/dist/HostingerProvider-gD4uqzMN.mjs.map +1 -0
  18. package/dist/LegacyStateStore-6xsGADme.mjs +124 -0
  19. package/dist/LegacyStateStore-6xsGADme.mjs.map +1 -0
  20. package/dist/LegacyStateStore-C0rm5slD.cjs +124 -0
  21. package/dist/LegacyStateStore-C0rm5slD.cjs.map +1 -0
  22. package/dist/LocalStateStore-G0JHXOVW.mjs +167 -0
  23. package/dist/LocalStateStore-G0JHXOVW.mjs.map +1 -0
  24. package/dist/LocalStateStore-NBMF3zCb.cjs +178 -0
  25. package/dist/LocalStateStore-NBMF3zCb.cjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-DOTLKBFf.cjs +539 -0
  27. package/dist/OpenApiTsGenerator-DOTLKBFf.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-Vaf0pI8u.mjs +534 -0
  29. package/dist/OpenApiTsGenerator-Vaf0pI8u.mjs.map +1 -0
  30. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
  31. package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
  32. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
  33. package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
  34. package/dist/S3StateStore-7n6gIYEJ.cjs +222 -0
  35. package/dist/S3StateStore-7n6gIYEJ.cjs.map +1 -0
  36. package/dist/S3StateStore-B7IPTvu0.mjs +223 -0
  37. package/dist/S3StateStore-B7IPTvu0.mjs.map +1 -0
  38. package/dist/SSMStateStore-CWEShHLS.mjs +205 -0
  39. package/dist/SSMStateStore-CWEShHLS.mjs.map +1 -0
  40. package/dist/SSMStateStore-O12NeGEg.cjs +204 -0
  41. package/dist/SSMStateStore-O12NeGEg.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-BybB6uez.mjs +783 -0
  43. package/dist/SubscriberGenerator-BybB6uez.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-mZpSuSU7.cjs +848 -0
  45. package/dist/SubscriberGenerator-mZpSuSU7.cjs.map +1 -0
  46. package/dist/add-C-nlqQgN.mjs +711 -0
  47. package/dist/add-C-nlqQgN.mjs.map +1 -0
  48. package/dist/add-ktNZmJb-.cjs +713 -0
  49. package/dist/add-ktNZmJb-.cjs.map +1 -0
  50. package/dist/appPorts-BoXMwolc.mjs +249 -0
  51. package/dist/appPorts-BoXMwolc.mjs.map +1 -0
  52. package/dist/appPorts-IW-OZmRi.cjs +296 -0
  53. package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
  54. package/dist/apps-C7SujLV-.mjs +5621 -0
  55. package/dist/apps-C7SujLV-.mjs.map +1 -0
  56. package/dist/apps-CtjYJS9e.cjs +6247 -0
  57. package/dist/apps-CtjYJS9e.cjs.map +1 -0
  58. package/dist/aws-C5LAU_Ii.mjs +97 -0
  59. package/dist/aws-C5LAU_Ii.mjs.map +1 -0
  60. package/dist/aws-DKC2m3sT.cjs +108 -0
  61. package/dist/aws-DKC2m3sT.cjs.map +1 -0
  62. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  63. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  64. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  65. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  66. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  67. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  68. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  69. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  70. package/dist/backups/runner.cjs +519 -0
  71. package/dist/backups/runner.cjs.map +1 -0
  72. package/dist/backups/runner.d.cts +102 -0
  73. package/dist/backups/runner.d.cts.map +1 -0
  74. package/dist/backups/runner.d.mts +102 -0
  75. package/dist/backups/runner.d.mts.map +1 -0
  76. package/dist/backups/runner.mjs +506 -0
  77. package/dist/backups/runner.mjs.map +1 -0
  78. package/dist/{bundler-BeNDZdHQ.cjs → bundler-DGwgZmim.cjs} +59 -14
  79. package/dist/bundler-DGwgZmim.cjs.map +1 -0
  80. package/dist/{bundler-BodTL4kf.mjs → bundler-DnHKVaZz.mjs} +59 -14
  81. package/dist/bundler-DnHKVaZz.mjs.map +1 -0
  82. package/dist/cli-CI9v138l.mjs +80 -0
  83. package/dist/cli-CI9v138l.mjs.map +1 -0
  84. package/dist/cli-k2G7rG15.cjs +80 -0
  85. package/dist/cli-k2G7rG15.cjs.map +1 -0
  86. package/dist/compose-BD2rwRfn.cjs +1919 -0
  87. package/dist/compose-BD2rwRfn.cjs.map +1 -0
  88. package/dist/compose-Co-Dt-a4.mjs +1560 -0
  89. package/dist/compose-Co-Dt-a4.mjs.map +1 -0
  90. package/dist/compose-nGgRylPu.cjs +3163 -0
  91. package/dist/compose-nGgRylPu.cjs.map +1 -0
  92. package/dist/compose-reJW9x-G.mjs +3074 -0
  93. package/dist/compose-reJW9x-G.mjs.map +1 -0
  94. package/dist/config-B5Hi3mLK.cjs +821 -0
  95. package/dist/config-B5Hi3mLK.cjs.map +1 -0
  96. package/dist/config-C60T2h98.d.cts +291 -0
  97. package/dist/config-C60T2h98.d.cts.map +1 -0
  98. package/dist/config-CfI2g_Ho.d.mts +291 -0
  99. package/dist/config-CfI2g_Ho.d.mts.map +1 -0
  100. package/dist/config-DWTUVGRE.mjs +696 -0
  101. package/dist/config-DWTUVGRE.mjs.map +1 -0
  102. package/dist/config.cjs +13 -3
  103. package/dist/config.d.cts +4 -117
  104. package/dist/config.d.mts +4 -117
  105. package/dist/config.mjs +3 -3
  106. package/dist/credentialSchemas-BAklWDna.cjs +271 -0
  107. package/dist/credentialSchemas-BAklWDna.cjs.map +1 -0
  108. package/dist/credentialSchemas-mz9QZTYh.mjs +236 -0
  109. package/dist/credentialSchemas-mz9QZTYh.mjs.map +1 -0
  110. package/dist/credentials-BG1KOq9I.mjs +1838 -0
  111. package/dist/credentials-BG1KOq9I.mjs.map +1 -0
  112. package/dist/credentials-UlL1n_Rd.cjs +2293 -0
  113. package/dist/credentials-UlL1n_Rd.cjs.map +1 -0
  114. package/dist/databases-C1qqNxTu.mjs +588 -0
  115. package/dist/databases-C1qqNxTu.mjs.map +1 -0
  116. package/dist/databases-CrKh5jw6.cjs +703 -0
  117. package/dist/databases-CrKh5jw6.cjs.map +1 -0
  118. package/dist/define-6poNqm5O.mjs +106 -0
  119. package/dist/define-6poNqm5O.mjs.map +1 -0
  120. package/dist/define-crmMcXFS.cjs +153 -0
  121. package/dist/define-crmMcXFS.cjs.map +1 -0
  122. package/dist/deploy/public.cjs +211 -0
  123. package/dist/deploy/public.cjs.map +1 -0
  124. package/dist/deploy/public.d.cts +658 -0
  125. package/dist/deploy/public.d.cts.map +1 -0
  126. package/dist/deploy/public.d.mts +658 -0
  127. package/dist/deploy/public.d.mts.map +1 -0
  128. package/dist/deploy/public.mjs +144 -0
  129. package/dist/deploy/public.mjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  131. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  133. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  134. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  135. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  136. package/dist/deploy/sniffer-hooks.cjs +1 -1
  137. package/dist/deploy/sniffer-hooks.mjs +1 -1
  138. package/dist/deploy/sniffer-loader.cjs +2 -2
  139. package/dist/deploy/sniffer-loader.mjs +1 -1
  140. package/dist/deploy/sniffer-routes-worker.cjs +2 -2
  141. package/dist/deploy/sniffer-routes-worker.mjs +1 -1
  142. package/dist/deploy-CqIULk0k.cjs +3425 -0
  143. package/dist/deploy-CqIULk0k.cjs.map +1 -0
  144. package/dist/deploy-DRkCNV7f.mjs +3369 -0
  145. package/dist/deploy-DRkCNV7f.mjs.map +1 -0
  146. package/dist/destroy-CMldkiX-.cjs +789 -0
  147. package/dist/destroy-CMldkiX-.cjs.map +1 -0
  148. package/dist/destroy-DXIAL8nF.mjs +788 -0
  149. package/dist/destroy-DXIAL8nF.mjs.map +1 -0
  150. package/dist/discover-CRywE7yc.cjs +1085 -0
  151. package/dist/discover-CRywE7yc.cjs.map +1 -0
  152. package/dist/discover-DbDrCQ8h.mjs +940 -0
  153. package/dist/discover-DbDrCQ8h.mjs.map +1 -0
  154. package/dist/docker-DFFzQe2f.mjs +1408 -0
  155. package/dist/docker-DFFzQe2f.mjs.map +1 -0
  156. package/dist/docker-LwJW3dx_.cjs +1515 -0
  157. package/dist/docker-LwJW3dx_.cjs.map +1 -0
  158. package/dist/dokploy-DYm0D6Tp.mjs +38 -0
  159. package/dist/dokploy-DYm0D6Tp.mjs.map +1 -0
  160. package/dist/dokploy-wTsJqG-N.cjs +38 -0
  161. package/dist/dokploy-wTsJqG-N.cjs.map +1 -0
  162. package/dist/drivers-BhdC9Efj.cjs +248 -0
  163. package/dist/drivers-BhdC9Efj.cjs.map +1 -0
  164. package/dist/drivers-wcDnzf7l.mjs +213 -0
  165. package/dist/drivers-wcDnzf7l.mjs.map +1 -0
  166. package/dist/eas-BJ_Zlvm8.mjs +334 -0
  167. package/dist/eas-BJ_Zlvm8.mjs.map +1 -0
  168. package/dist/eas-C4EkjTGJ.cjs +337 -0
  169. package/dist/eas-C4EkjTGJ.cjs.map +1 -0
  170. package/dist/emit-C4KSXOeS.mjs +153 -0
  171. package/dist/emit-C4KSXOeS.mjs.map +1 -0
  172. package/dist/emit-DiW0kbue.cjs +164 -0
  173. package/dist/emit-DiW0kbue.cjs.map +1 -0
  174. package/dist/encryption-BQEqqrGq.cjs +90 -0
  175. package/dist/encryption-BQEqqrGq.cjs.map +1 -0
  176. package/dist/encryption-Cu5YTs9V.mjs +89 -0
  177. package/dist/encryption-Cu5YTs9V.mjs.map +1 -0
  178. package/dist/engine-DdRauUQC.cjs +3330 -0
  179. package/dist/engine-DdRauUQC.cjs.map +1 -0
  180. package/dist/engine-q8aCVbLH.mjs +3217 -0
  181. package/dist/engine-q8aCVbLH.mjs.map +1 -0
  182. package/dist/errors-D8Gwp5kU.mjs +23 -0
  183. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  184. package/dist/errors-DMC4Umsb.cjs +34 -0
  185. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  186. package/dist/github-CoXirRes.mjs +901 -0
  187. package/dist/github-CoXirRes.mjs.map +1 -0
  188. package/dist/github-OVZF2k0L.cjs +902 -0
  189. package/dist/github-OVZF2k0L.cjs.map +1 -0
  190. package/dist/googlePlay-CUeTUT7s.cjs +931 -0
  191. package/dist/googlePlay-CUeTUT7s.cjs.map +1 -0
  192. package/dist/googlePlay-HXRRVq0l.mjs +931 -0
  193. package/dist/googlePlay-HXRRVq0l.mjs.map +1 -0
  194. package/dist/iam-6LH6wptf.cjs +618 -0
  195. package/dist/iam-6LH6wptf.cjs.map +1 -0
  196. package/dist/iam-c0e8m04X.mjs +509 -0
  197. package/dist/iam-c0e8m04X.mjs.map +1 -0
  198. package/dist/{index-C-VLwB_Y.d.mts → index-DDY0cZCo.d.cts} +38 -14
  199. package/dist/index-DDY0cZCo.d.cts.map +1 -0
  200. package/dist/{index-C-HkOEBt.d.cts → index-DWNwkcy7.d.mts} +38 -14
  201. package/dist/index-DWNwkcy7.d.mts.map +1 -0
  202. package/dist/index.cjs +13752 -12326
  203. package/dist/index.cjs.map +1 -1
  204. package/dist/index.mjs +13791 -12363
  205. package/dist/index.mjs.map +1 -1
  206. package/dist/local-CCJ-T37d.mjs +224 -0
  207. package/dist/local-CCJ-T37d.mjs.map +1 -0
  208. package/dist/local-Dx0o6vfp.cjs +241 -0
  209. package/dist/local-Dx0o6vfp.cjs.map +1 -0
  210. package/dist/migrate-BkwSXhxv.mjs +181 -0
  211. package/dist/migrate-BkwSXhxv.mjs.map +1 -0
  212. package/dist/migrate-CJoKOCGY.cjs +181 -0
  213. package/dist/migrate-CJoKOCGY.cjs.map +1 -0
  214. package/dist/migrate-DEsYfgzn.cjs +272 -0
  215. package/dist/migrate-DEsYfgzn.cjs.map +1 -0
  216. package/dist/migrate-Dr0BeWsY.mjs +267 -0
  217. package/dist/migrate-Dr0BeWsY.mjs.map +1 -0
  218. package/dist/notes-BOyzuPqr.mjs +399 -0
  219. package/dist/notes-BOyzuPqr.mjs.map +1 -0
  220. package/dist/notes-VFPa51Pd.cjs +500 -0
  221. package/dist/notes-VFPa51Pd.cjs.map +1 -0
  222. package/dist/openapi.cjs +213 -7
  223. package/dist/openapi.cjs.map +1 -0
  224. package/dist/openapi.d.cts +32 -8
  225. package/dist/openapi.d.cts.map +1 -1
  226. package/dist/openapi.d.mts +32 -8
  227. package/dist/openapi.d.mts.map +1 -1
  228. package/dist/openapi.mjs +208 -2
  229. package/dist/openapi.mjs.map +1 -0
  230. package/dist/projectBucket-B26ucBRI.mjs +222 -0
  231. package/dist/projectBucket-B26ucBRI.mjs.map +1 -0
  232. package/dist/projectBucket-CWpY3Vxv.cjs +263 -0
  233. package/dist/projectBucket-CWpY3Vxv.cjs.map +1 -0
  234. package/dist/provider-BqpjG9QM.cjs +57 -0
  235. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  236. package/dist/provider-CEOKk8NS.mjs +46 -0
  237. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  238. package/dist/publish-Bg4iffje.mjs +123 -0
  239. package/dist/publish-Bg4iffje.mjs.map +1 -0
  240. package/dist/publish-IjcRoorJ.cjs +124 -0
  241. package/dist/publish-IjcRoorJ.cjs.map +1 -0
  242. package/dist/ready-BjFMu_1J.mjs +375 -0
  243. package/dist/ready-BjFMu_1J.mjs.map +1 -0
  244. package/dist/ready-eVMJIcWn.cjs +404 -0
  245. package/dist/ready-eVMJIcWn.cjs.map +1 -0
  246. package/dist/reconcile/public.cjs +3 -5
  247. package/dist/reconcile/public.d.cts +33 -89
  248. package/dist/reconcile/public.d.cts.map +1 -1
  249. package/dist/reconcile/public.d.mts +33 -89
  250. package/dist/reconcile/public.d.mts.map +1 -1
  251. package/dist/reconcile/public.mjs +3 -3
  252. package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
  253. package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
  254. package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
  255. package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
  256. package/dist/resolve-CgVDhWW8.cjs +316 -0
  257. package/dist/resolve-CgVDhWW8.cjs.map +1 -0
  258. package/dist/resolve-rw7mLp5E.mjs +263 -0
  259. package/dist/resolve-rw7mLp5E.mjs.map +1 -0
  260. package/dist/rollback-Cv02Cnky.mjs +136 -0
  261. package/dist/rollback-Cv02Cnky.mjs.map +1 -0
  262. package/dist/rollback-vdkPi_Rm.cjs +165 -0
  263. package/dist/rollback-vdkPi_Rm.cjs.map +1 -0
  264. package/dist/runtime-D-rOcRoq.d.cts +82 -0
  265. package/dist/runtime-D-rOcRoq.d.cts.map +1 -0
  266. package/dist/runtime-DG1mNh_5.d.mts +82 -0
  267. package/dist/runtime-DG1mNh_5.d.mts.map +1 -0
  268. package/dist/s3-DIvAtJwk.cjs +240 -0
  269. package/dist/s3-DIvAtJwk.cjs.map +1 -0
  270. package/dist/s3-DmsM_V2R.mjs +240 -0
  271. package/dist/s3-DmsM_V2R.mjs.map +1 -0
  272. package/dist/sandbox/config-worker.cjs +43 -0
  273. package/dist/sandbox/config-worker.cjs.map +1 -0
  274. package/dist/sandbox/config-worker.d.cts +1 -0
  275. package/dist/sandbox/config-worker.d.mts +1 -0
  276. package/dist/sandbox/config-worker.mjs +44 -0
  277. package/dist/sandbox/config-worker.mjs.map +1 -0
  278. package/dist/sandbox/credentials-worker.cjs +53 -0
  279. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  280. package/dist/sandbox/credentials-worker.d.cts +1 -0
  281. package/dist/sandbox/credentials-worker.d.mts +1 -0
  282. package/dist/sandbox/credentials-worker.mjs +54 -0
  283. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  284. package/dist/sandbox/discover-worker.cjs +47 -0
  285. package/dist/sandbox/discover-worker.cjs.map +1 -0
  286. package/dist/sandbox/discover-worker.d.cts +1 -0
  287. package/dist/sandbox/discover-worker.d.mts +1 -0
  288. package/dist/sandbox/discover-worker.mjs +48 -0
  289. package/dist/sandbox/discover-worker.mjs.map +1 -0
  290. package/dist/sandbox/migrate-worker.cjs +75 -0
  291. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  292. package/dist/sandbox/migrate-worker.d.cts +1 -0
  293. package/dist/sandbox/migrate-worker.d.mts +1 -0
  294. package/dist/sandbox/migrate-worker.mjs +76 -0
  295. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  296. package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
  297. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  298. package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
  299. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  300. package/dist/secretsManager-CJyxFcBH.mjs +113 -0
  301. package/dist/secretsManager-CJyxFcBH.mjs.map +1 -0
  302. package/dist/secretsManager-D8on44WI.cjs +124 -0
  303. package/dist/secretsManager-D8on44WI.cjs.map +1 -0
  304. package/dist/seeds-D7q1zKCJ.cjs +369 -0
  305. package/dist/seeds-D7q1zKCJ.cjs.map +1 -0
  306. package/dist/seeds-y1rzXlAc.mjs +298 -0
  307. package/dist/seeds-y1rzXlAc.mjs.map +1 -0
  308. package/dist/serverSetup-CvcN4zJQ.mjs +685 -0
  309. package/dist/serverSetup-CvcN4zJQ.mjs.map +1 -0
  310. package/dist/serverSetup-qXIRRhgw.cjs +685 -0
  311. package/dist/serverSetup-qXIRRhgw.cjs.map +1 -0
  312. package/dist/sniffer-CGfL25Bc.cjs +1997 -0
  313. package/dist/sniffer-CGfL25Bc.cjs.map +1 -0
  314. package/dist/sniffer-DuKVVAs_.mjs +1824 -0
  315. package/dist/sniffer-DuKVVAs_.mjs.map +1 -0
  316. package/dist/snsSubscriptions-DPfGjpuB.cjs +1179 -0
  317. package/dist/snsSubscriptions-DPfGjpuB.cjs.map +1 -0
  318. package/dist/snsSubscriptions-nnSUW2Eh.mjs +1048 -0
  319. package/dist/snsSubscriptions-nnSUW2Eh.mjs.map +1 -0
  320. package/dist/sst-Bw7686br.mjs +478 -0
  321. package/dist/sst-Bw7686br.mjs.map +1 -0
  322. package/dist/sst-Md7c1UC_.cjs +501 -0
  323. package/dist/sst-Md7c1UC_.cjs.map +1 -0
  324. package/dist/stack-D2cLLaO-.mjs +2256 -0
  325. package/dist/stack-D2cLLaO-.mjs.map +1 -0
  326. package/dist/stack-DTcnynGb.cjs +2431 -0
  327. package/dist/stack-DTcnynGb.cjs.map +1 -0
  328. package/dist/stage-Bw3bJ7Au.mjs +302 -0
  329. package/dist/stage-Bw3bJ7Au.mjs.map +1 -0
  330. package/dist/stage-RLOenlHV.cjs +313 -0
  331. package/dist/stage-RLOenlHV.cjs.map +1 -0
  332. package/dist/stages-B0yOikgt.cjs +190 -0
  333. package/dist/stages-B0yOikgt.cjs.map +1 -0
  334. package/dist/stages-yA9bhStl.mjs +190 -0
  335. package/dist/stages-yA9bhStl.mjs.map +1 -0
  336. package/dist/target/public.cjs +15 -0
  337. package/dist/target/public.d.cts +28 -0
  338. package/dist/target/public.d.cts.map +1 -0
  339. package/dist/target/public.d.mts +28 -0
  340. package/dist/target/public.d.mts.map +1 -0
  341. package/dist/target/public.mjs +4 -0
  342. package/dist/terminal-C-_cMKTY.cjs +85 -0
  343. package/dist/terminal-C-_cMKTY.cjs.map +1 -0
  344. package/dist/terminal-Dq29bK3u.mjs +85 -0
  345. package/dist/terminal-Dq29bK3u.mjs.map +1 -0
  346. package/dist/types-Bl_CwZC9.cjs +90 -0
  347. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  348. package/dist/{types-RhXmHR-e.d.cts → types-CvucX3yD.d.mts} +2163 -364
  349. package/dist/types-CvucX3yD.d.mts.map +1 -0
  350. package/dist/{types-kvBQjpPo.d.mts → types-D1C8pUyh.d.cts} +2165 -364
  351. package/dist/types-D1C8pUyh.d.cts.map +1 -0
  352. package/dist/types-Y1NfWlyG.mjs +61 -0
  353. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  354. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  355. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  356. package/dist/utils-D_fxUqvU.mjs +156 -0
  357. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  358. package/dist/vitest.cjs +65 -0
  359. package/dist/vitest.cjs.map +1 -0
  360. package/dist/vitest.d.cts +29 -0
  361. package/dist/vitest.d.cts.map +1 -0
  362. package/dist/vitest.d.mts +29 -0
  363. package/dist/vitest.d.mts.map +1 -0
  364. package/dist/vitest.mjs +65 -0
  365. package/dist/vitest.mjs.map +1 -0
  366. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  367. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  368. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  369. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  370. package/dist/workspace/index.cjs +6 -2
  371. package/dist/workspace/index.d.cts +3 -3
  372. package/dist/workspace/index.d.mts +3 -3
  373. package/dist/workspace/index.mjs +2 -2
  374. package/dist/workspace-1szcahj9.cjs +2916 -0
  375. package/dist/workspace-1szcahj9.cjs.map +1 -0
  376. package/dist/workspace-DFGsrjGD.mjs +2480 -0
  377. package/dist/workspace-DFGsrjGD.mjs.map +1 -0
  378. package/package.json +65 -13
  379. package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
  380. package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
  381. package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
  382. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
  383. package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
  384. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
  385. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  386. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  387. package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
  388. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
  389. package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
  390. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
  391. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  392. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  393. package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
  394. package/dist/bundler-BodTL4kf.mjs.map +0 -1
  395. package/dist/config-Q1rvKHvw.cjs +0 -467
  396. package/dist/config-Q1rvKHvw.cjs.map +0 -1
  397. package/dist/config-pqGD3hF9.mjs +0 -414
  398. package/dist/config-pqGD3hF9.mjs.map +0 -1
  399. package/dist/config.d.cts.map +0 -1
  400. package/dist/config.d.mts.map +0 -1
  401. package/dist/credentials-BekkKtY_.mjs +0 -2780
  402. package/dist/credentials-BekkKtY_.mjs.map +0 -1
  403. package/dist/credentials-Q6F0uqJq.cjs +0 -2917
  404. package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
  405. package/dist/discover-BERGFg8v.cjs +0 -288
  406. package/dist/discover-BERGFg8v.cjs.map +0 -1
  407. package/dist/discover-CK-n3w6b.mjs +0 -244
  408. package/dist/discover-CK-n3w6b.mjs.map +0 -1
  409. package/dist/emit-BdoPFjZf.cjs +0 -253
  410. package/dist/emit-BdoPFjZf.cjs.map +0 -1
  411. package/dist/emit-Bzq7JsMP.mjs +0 -224
  412. package/dist/emit-Bzq7JsMP.mjs.map +0 -1
  413. package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
  414. package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
  415. package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
  416. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
  417. package/dist/generator-LfZU7NlU.mjs +0 -247
  418. package/dist/generator-LfZU7NlU.mjs.map +0 -1
  419. package/dist/generator-Wdfp0jCS.cjs +0 -282
  420. package/dist/generator-Wdfp0jCS.cjs.map +0 -1
  421. package/dist/github-BfflNPVe.cjs +0 -203
  422. package/dist/github-BfflNPVe.cjs.map +0 -1
  423. package/dist/github-CRwnxKmD.mjs +0 -203
  424. package/dist/github-CRwnxKmD.mjs.map +0 -1
  425. package/dist/index-C-HkOEBt.d.cts.map +0 -1
  426. package/dist/index-C-VLwB_Y.d.mts.map +0 -1
  427. package/dist/keystore-B4PRlbgE.mjs +0 -81
  428. package/dist/keystore-B4PRlbgE.mjs.map +0 -1
  429. package/dist/keystore-DgGRj2Yy.cjs +0 -98
  430. package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
  431. package/dist/openapi-Dcbme-Us.cjs +0 -2038
  432. package/dist/openapi-Dcbme-Us.cjs.map +0 -1
  433. package/dist/openapi-vy4JzhUv.mjs +0 -1991
  434. package/dist/openapi-vy4JzhUv.mjs.map +0 -1
  435. package/dist/storage-C-30BD1e.cjs +0 -272
  436. package/dist/storage-C-30BD1e.cjs.map +0 -1
  437. package/dist/storage-P_b3w7uj.mjs +0 -231
  438. package/dist/storage-P_b3w7uj.mjs.map +0 -1
  439. package/dist/sync-B3xxXtJT.mjs +0 -88
  440. package/dist/sync-B3xxXtJT.mjs.map +0 -1
  441. package/dist/sync-D7uTIIEi.cjs +0 -111
  442. package/dist/sync-D7uTIIEi.cjs.map +0 -1
  443. package/dist/types-RhXmHR-e.d.cts.map +0 -1
  444. package/dist/types-kvBQjpPo.d.mts.map +0 -1
  445. package/dist/workspace-CgwmXEtc.mjs.map +0 -1
  446. package/dist/workspace-mFpI_ky_.cjs.map +0 -1
@@ -0,0 +1,1560 @@
1
+ import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { B as FileSecretsStore, F as toEmbeddableSecrets, G as getOrCreateKey, H as encrypt, J as readKey, K as keystoreProject, V as decrypt, W as getKeystoreDir, bt as gkmHome, k as secretsStoreFor } from "./credentials-BG1KOq9I.mjs";
3
+ import { B as LOGS_PORT, v as getPublicEnvPrefix } from "./workspace-DFGsrjGD.mjs";
4
+ import { m as loadWorkspaceConfig, o as NotInAnApp, p as loadWorkspaceAppInfo, r as ConfigNotFound } from "./config-DWTUVGRE.mjs";
5
+ import { dirname, join, resolve } from "node:path";
6
+ import { existsSync } from "node:fs";
7
+ import { mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
8
+ import { createServer } from "node:net";
9
+ import { createHash, randomBytes, randomInt } from "node:crypto";
10
+ import { DEFAULT_POSTGRES_VERSION, WILDCARD_SUBDOMAIN, drawSecret, kebabCase, provideKey } from "@geekmidas/manifest";
11
+ import { generateKeyring } from "@geekmidas/constructs/encryption";
12
+ import { config } from "dotenv";
13
+ import { stringify } from "yaml";
14
+ //#region src/workspace/rootSite.ts
15
+ /**
16
+ * Which site the base domain points at — deployed and locally alike.
17
+ *
18
+ * Three rules, in order, and the last one is the point:
19
+ *
20
+ * 1. **One site** — it is the root. Unambiguous, so nothing has to be said.
21
+ * 2. **Named `web`** — the convention wins, because people already rely on it.
22
+ * 3. **Declared `root: true`** — the site says so itself.
23
+ *
24
+ * Anything else throws. It used to take the *first* site it iterated, and that
25
+ * order came from the manifest, which is built in glob traversal order — so two
26
+ * sites with neither named `web` meant renaming a file could move the root
27
+ * domain, silently.
28
+ *
29
+ * One rule for both targets: deployed the root site gets the base domain, and
30
+ * locally it gets the project's bare host behind the edge. Before this was
31
+ * shared, the local edge put every site on a subdomain, so what a developer
32
+ * browsed was not the shape production served.
33
+ *
34
+ * @returns the root site's name, or `undefined` when there are no sites
35
+ * @throws {AmbiguousRootSite} when several sites could be the root and none says it is
36
+ */
37
+ function rootSite(sites) {
38
+ if (sites.length === 0) return void 0;
39
+ if (sites.length === 1) return sites[0].name;
40
+ if (sites.some(({ name }) => name === "web")) return "web";
41
+ const declared = sites.filter(({ root }) => root === true);
42
+ if (declared.length === 1) return declared[0].name;
43
+ throw new AmbiguousRootSite(sites.map(({ name }) => name), declared.length > 1);
44
+ }
45
+ /** Several sites could hold the base domain, and none of them says it does. */
46
+ var AmbiguousRootSite = class extends GkmError {
47
+ sites;
48
+ tooMany;
49
+ constructor(sites, tooMany = false) {
50
+ 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.`);
51
+ this.sites = sites;
52
+ this.tooMany = tooMany;
53
+ this.name = "AmbiguousRootSite";
54
+ }
55
+ };
56
+ //#endregion
57
+ //#region src/target/dokploy/domain.ts
58
+ /** A stage was deployed that `domains` gives no domain. */
59
+ var NoDomainForStage = class extends GkmError {
60
+ stage;
61
+ constructor(stage) {
62
+ super(`No domain for stage "${stage}". Add it to gkm.config.ts: domains: { ${stage}: 'example.com' }.`);
63
+ this.stage = stage;
64
+ this.name = "NoDomainForStage";
65
+ }
66
+ };
67
+ /**
68
+ * The hostname an app answers on for a stage.
69
+ *
70
+ * 1. An explicit `app.domain` — a string, or one per stage — wins.
71
+ * 2. Otherwise from the stage's base domain in `domains`: the root site
72
+ * answers on the domain itself, and every other app on
73
+ * `{subdomain}.{domain}` — its declaration's `subdomain`, or its own name.
74
+ *
75
+ * @throws {NoDomainForStage} when `domains` names no domain for it
76
+ */
77
+ function resolveHost(appName, app, stage, domains, isMainFrontend) {
78
+ if (app.domain) {
79
+ if (typeof app.domain === "string") return app.domain;
80
+ if (app.domain[stage]) return app.domain[stage];
81
+ }
82
+ const baseDomain = domains?.[stage];
83
+ if (!baseDomain) throw new NoDomainForStage(stage);
84
+ if (isMainFrontend) return baseDomain;
85
+ return `${app.subdomain ?? appName}.${baseDomain}`;
86
+ }
87
+ /**
88
+ * Whether this app is the site the base domain points at — see `rootSite`,
89
+ * which the local edge asks too.
90
+ *
91
+ * @throws {AmbiguousRootSite} when several sites could be the root and none says it is
92
+ */
93
+ function isMainFrontendApp(appName, app, allApps) {
94
+ const holds = (a) => a.type === "web" && a.subdomain !== WILDCARD_SUBDOMAIN;
95
+ if (!holds(app)) return false;
96
+ return rootSite(Object.entries(allApps).filter(([, a]) => holds(a)).map(([name, a]) => ({
97
+ name,
98
+ root: a.root
99
+ }))) === appName;
100
+ }
101
+ /**
102
+ * Get public URL arg names from app dependencies.
103
+ *
104
+ * @param app - The web/mobile app configuration
105
+ * @returns Array of arg names like 'NEXT_PUBLIC_API_URL', or [] for frameworks
106
+ * without a public prefix (e.g. Remix).
107
+ */
108
+ function getPublicUrlArgNames(app) {
109
+ const prefix = getPublicEnvPrefix(app.framework);
110
+ if (!prefix) return [];
111
+ return app.dependencies.map((dep) => `${prefix}${dep.toUpperCase()}_URL`);
112
+ }
113
+ //#endregion
114
+ //#region src/compose/logs.ts
115
+ /**
116
+ * The stack's log UI: OpenObserve, run beside the apps as telemetry's
117
+ * self-hosted provider, and every process with a `Telemetry` edge pointed at
118
+ * it.
119
+ *
120
+ * The production server already exports its traces and pino logs over
121
+ * OTLP/HTTP when `OTEL_EXPORTER_OTLP_ENDPOINT` is set. OpenObserve takes OTLP
122
+ * at `/api/<org>/v1/{logs,traces}` with HTTP basic auth, so wiring an app is
123
+ * two variables: the endpoint, `http://openobserve:5080/api/default`, and
124
+ * the header that signs in as the root user.
125
+ *
126
+ * It is reached, by default, through an SSH tunnel: published on 127.0.0.1
127
+ * only, because a port Docker publishes on every interface is opened in the
128
+ * firewall by Docker itself, past ufw's rules. Served publicly, it is a host
129
+ * on the stack's Caddy that refuses every address not allowed.
130
+ *
131
+ * Pure: the stack decides it, and the phases print and check it.
132
+ */
133
+ /**
134
+ * The image, pinned. A log store's on-disk format is the thing that must not
135
+ * move under a running stack, so a new version is a change to this line.
136
+ */
137
+ const OPENOBSERVE_IMAGE = "public.ecr.aws/zinclabs/openobserve:v1.0.4";
138
+ /** Its compose service name — the host the apps send to. */
139
+ const LOGS_SERVICE = "openobserve";
140
+ /** The organisation every app's telemetry lands in. */
141
+ const LOGS_ORG = "default";
142
+ /** The stage secrets that sign in as OpenObserve's root user. */
143
+ const LOGS_EMAIL_KEY = "ZO_ROOT_USER_EMAIL";
144
+ const LOGS_PASSWORD_KEY = "ZO_ROOT_USER_PASSWORD";
145
+ /**
146
+ * The local stage's root user. Its password is generated per machine with
147
+ * the other local logins — see `reconcile/localCredentials.ts`.
148
+ */
149
+ const LOCAL_LOGS_EMAIL = "admin@gkm.localhost";
150
+ /** A root password OpenObserve would refuse to start with. */
151
+ var LogsPasswordWeak = class extends GkmError {
152
+ stage;
153
+ constructor(stage) {
154
+ 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.`);
155
+ this.stage = stage;
156
+ this.name = "LogsPasswordWeak";
157
+ }
158
+ };
159
+ /** A deployed stage with logs on and no root password generated yet. */
160
+ var LogsPasswordMissing = class extends GkmError {
161
+ stage;
162
+ constructor(stage) {
163
+ 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}`);
164
+ this.stage = stage;
165
+ this.name = "LogsPasswordMissing";
166
+ }
167
+ };
168
+ /** Whether OpenObserve accepts `password` for its root user. */
169
+ function isStrongLogsPassword(password) {
170
+ return password.length >= 8 && password.length <= 128 && /[a-z]/.test(password) && /[A-Z]/.test(password) && /\d/.test(password) && /[^A-Za-z0-9]/.test(password);
171
+ }
172
+ /**
173
+ * A root password: 192 random bits, with a fixed tail so every class
174
+ * OpenObserve requires is present whatever the random part drew.
175
+ */
176
+ function generateLogsPassword() {
177
+ return `${randomBytes(24).toString("base64url")}-Zo1`;
178
+ }
179
+ /**
180
+ * The stage's secrets with a generated root password, where it has none.
181
+ * Pure, like `withGeneratedSecrets`: the caller keeps the result once the
182
+ * run goes ahead.
183
+ */
184
+ function withLogsPassword(secrets) {
185
+ if (secrets.custom?.["ZO_ROOT_USER_PASSWORD"]) return {
186
+ secrets,
187
+ generated: []
188
+ };
189
+ return {
190
+ secrets: {
191
+ ...secrets,
192
+ custom: {
193
+ ...secrets.custom,
194
+ [LOGS_PASSWORD_KEY]: generateLogsPassword()
195
+ },
196
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
197
+ },
198
+ generated: [LOGS_PASSWORD_KEY]
199
+ };
200
+ }
201
+ /**
202
+ * `OTEL_EXPORTER_OTLP_HEADERS` signing in as `email`.
203
+ *
204
+ * The variable's values are percent-decoded by the SDK (they follow the W3C
205
+ * baggage format), so the space after `Basic` is written `%20`. Base64's own
206
+ * `+`, `/` and `=` pass through decoding unchanged.
207
+ */
208
+ function otlpHeaders(email, password) {
209
+ return `Authorization=Basic%20${Buffer.from(`${email}:${password}`).toString("base64")}`;
210
+ }
211
+ /** The stack's OpenObserve for one stage. */
212
+ function stackLogs(options) {
213
+ const { config, stage, local, custom } = options;
214
+ if (!local && !options.domain) throw new NoDomainForStage(stage);
215
+ const email = custom["ZO_ROOT_USER_EMAIL"] ?? (local ? options.localLogin?.email ?? "admin@gkm.localhost" : `admin@${options.domain}`);
216
+ const set = custom[LOGS_PASSWORD_KEY];
217
+ const password = set ?? (local ? options.localLogin?.password : void 0);
218
+ if (!password) throw new LogsPasswordMissing(stage);
219
+ if (!isStrongLogsPassword(password)) throw new LogsPasswordWeak(stage);
220
+ const host = config.public ? local ? `logs.${options.project}.localhost` : `logs.${options.domain}` : void 0;
221
+ const url = host ? `https://${host}${local && options.https !== 443 ? `:${options.https}` : ""}` : `http://localhost:${config.port}`;
222
+ return {
223
+ ...config,
224
+ email,
225
+ password,
226
+ passwordFromSecrets: Boolean(set),
227
+ url,
228
+ ...host ? { host } : {},
229
+ env: {
230
+ [LOGS_EMAIL_KEY]: email,
231
+ [LOGS_PASSWORD_KEY]: password,
232
+ ZO_DATA_DIR: "/data",
233
+ ZO_COMPACT_DATA_RETENTION_DAYS: String(config.retentionDays),
234
+ ZO_TELEMETRY: "false"
235
+ },
236
+ appEnv: {
237
+ OTEL_EXPORTER_OTLP_ENDPOINT: `http://${LOGS_SERVICE}:${LOGS_PORT}/api/${LOGS_ORG}`,
238
+ OTEL_EXPORTER_OTLP_HEADERS: otlpHeaders(email, password)
239
+ }
240
+ };
241
+ }
242
+ /**
243
+ * OpenObserve's service. The image has no shell, `wget` or `curl`, so its
244
+ * health check is its own binary asking the running server for its status —
245
+ * which exits non-zero when nothing answers on its port.
246
+ */
247
+ function logsService(logs) {
248
+ return {
249
+ image: OPENOBSERVE_IMAGE,
250
+ restart: "unless-stopped",
251
+ env_file: [{
252
+ path: `./${LOGS_SERVICE}.env`,
253
+ format: "raw"
254
+ }],
255
+ volumes: ["openobserve-data:/data"],
256
+ ...logs.public ? {} : { ports: [`127.0.0.1:${logs.port}:${LOGS_PORT}`] },
257
+ healthcheck: {
258
+ test: [
259
+ "CMD",
260
+ "/openobserve",
261
+ "node",
262
+ "status"
263
+ ],
264
+ interval: "10s",
265
+ timeout: "5s",
266
+ retries: 12,
267
+ start_period: "20s"
268
+ }
269
+ };
270
+ }
271
+ /** What `gkm compose` prints once the stack is up: how to open the logs. */
272
+ function logsAccess(logs, ctx) {
273
+ const login = `login: ${logs.email}, password: ${ctx.local && !logs.passwordFromSecrets ? logs.password : `gkm secrets:show --stage ${ctx.stage} --reveal → ${LOGS_PASSWORD_KEY}`}`;
274
+ if (logs.public) return [`📜 Logs (OpenObserve): ${logs.url} (${login})`, ` answered only for ${logs.public.allow.join(", ")}; every other address gets 403`];
275
+ return [
276
+ `📜 Logs (OpenObserve) on 127.0.0.1:${logs.port} — from your computer:`,
277
+ ...ctx.local ? [` on this machine, open http://localhost:${logs.port} directly; from another:`] : [],
278
+ ` ssh -N -L ${logs.port}:localhost:${logs.port} ${ctx.user}@${ctx.hostname}${ctx.known ? "" : " (user and host are guesses: this machine's)"}`,
279
+ ` then open http://localhost:${logs.port} (${login})`,
280
+ `⚠️ 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.`
281
+ ];
282
+ }
283
+ //#endregion
284
+ //#region src/reconcile/containers.ts
285
+ /**
286
+ * What gkm knows about each container it can derive.
287
+ *
288
+ * Everything provider-specific about the local target lives here: the image, the
289
+ * ports the image listens on, and whether its data is worth keeping. The plan
290
+ * says *which* containers exist and never says any of this, which is the split
291
+ * the design asks for — neutral facts from the declaration, provider detail
292
+ * from here and from config.
293
+ *
294
+ * Shared by allocation and by the compose writer so the two cannot disagree
295
+ * about how many ports a container needs.
296
+ */
297
+ /**
298
+ * The Postgres image for a major version.
299
+ *
300
+ * One place that knows the tag shape, so a declared version reaches the
301
+ * container without anyone restating `-alpine` beside it.
302
+ */
303
+ function postgresImage(version) {
304
+ return `postgres:${version}-alpine`;
305
+ }
306
+ /**
307
+ * The default image for each container.
308
+ *
309
+ * Pinned to a major rather than `latest` where the image publishes one, so a
310
+ * rebuild does not silently move a developer's Postgres a version. A database
311
+ * can name its own (`image: 'postgis/postgis:…'`); any other pin is the
312
+ * project's own `docker-compose.yml`.
313
+ */
314
+ const DEFAULT_IMAGES = {
315
+ postgres: postgresImage(DEFAULT_POSTGRES_VERSION),
316
+ minio: "pgsty/minio:RELEASE.2026-08-04T00-00-00Z",
317
+ mailpit: "axllent/mailpit:latest",
318
+ redis: "redis:8-alpine",
319
+ "redis-http": "hiett/serverless-redis-http:latest",
320
+ rabbitmq: "rabbitmq:4-management-alpine",
321
+ localstack: "floci/floci:2.1.0",
322
+ caddy: "caddy:2-alpine",
323
+ openobserve: OPENOBSERVE_IMAGE
324
+ };
325
+ /**
326
+ * The ports each container listens on.
327
+ *
328
+ * The first is always the one an app connects to; the rest are consoles and
329
+ * management UIs, published because a bucket or an inbox you can look at is most
330
+ * of why these are real containers rather than stubs.
331
+ */
332
+ const PORTS = {
333
+ postgres: [{
334
+ key: "postgres",
335
+ inside: 5432,
336
+ label: "postgres"
337
+ }],
338
+ minio: [{
339
+ key: "minio",
340
+ inside: 9e3,
341
+ label: "minio api"
342
+ }, {
343
+ key: "minio-console",
344
+ inside: 9001,
345
+ label: "minio console",
346
+ web: true
347
+ }],
348
+ mailpit: [{
349
+ key: "mailpit",
350
+ inside: 1025,
351
+ label: "smtp"
352
+ }, {
353
+ key: "mailpit-web",
354
+ inside: 8025,
355
+ label: "mailpit inbox",
356
+ web: true
357
+ }],
358
+ redis: [{
359
+ key: "redis",
360
+ inside: 6379,
361
+ label: "redis"
362
+ }],
363
+ "redis-http": [{
364
+ key: "redis-http",
365
+ inside: 80,
366
+ label: "cache"
367
+ }],
368
+ rabbitmq: [{
369
+ key: "rabbitmq",
370
+ inside: 5672,
371
+ label: "amqp"
372
+ }, {
373
+ key: "rabbitmq-management",
374
+ inside: 15672,
375
+ label: "rabbitmq console",
376
+ web: true
377
+ }],
378
+ localstack: [{
379
+ key: "localstack",
380
+ inside: 4566,
381
+ label: "localstack"
382
+ }],
383
+ caddy: [{
384
+ key: "caddy",
385
+ inside: 443,
386
+ label: "https edge"
387
+ }],
388
+ openobserve: [{
389
+ key: "openobserve",
390
+ inside: LOGS_PORT,
391
+ label: "openobserve",
392
+ web: true
393
+ }]
394
+ };
395
+ /** The port key — and container name, for an image — of an API's fake. */
396
+ function fakeKey(id) {
397
+ return `${kebabCase(id)}-fake`;
398
+ }
399
+ /**
400
+ * The ports a container needs published. Empty for one gkm does not know.
401
+ *
402
+ * `fakes` answers for the containers no table can: an external API's fake
403
+ * listens wherever its declaration says.
404
+ */
405
+ function portsOf(container, fakes = {}) {
406
+ const fake = fakes[container];
407
+ if (fake?.port !== void 0) return [{
408
+ key: container,
409
+ inside: fake.port,
410
+ label: `${fake.id} fake`
411
+ }];
412
+ return PORTS[container] ?? [];
413
+ }
414
+ /**
415
+ * Every port the containers publish — not only the one an app connects to.
416
+ *
417
+ * The consoles and the inbox are most of why these are real containers, and an
418
+ * inbox nobody can find is an inbox nobody opens: a sign-in link gets fished
419
+ * out of `docker ps` instead.
420
+ */
421
+ function serviceAddresses(containers, ports, fakes = {}) {
422
+ return containers.flatMap((container) => portsOf(container, fakes).flatMap((port) => {
423
+ const assigned = ports[port.key];
424
+ if (assigned === void 0) return [];
425
+ return [{
426
+ container,
427
+ label: port.label,
428
+ address: port.web ? `http://localhost:${assigned}` : `localhost:${assigned}`
429
+ }];
430
+ }));
431
+ }
432
+ /** The lines `gkm dev` and `gkm setup` print under the services heading. */
433
+ function describeServices(services) {
434
+ const width = Math.max(0, ...services.map(({ label }) => label.length));
435
+ return services.map(({ label, address }) => ` ${label.padEnd(width)} ${address}`);
436
+ }
437
+ /** The key a container's primary port is allocated under. */
438
+ function primaryPortKey(container) {
439
+ return portsOf(container)[0]?.key ?? container;
440
+ }
441
+ /**
442
+ * Every port key a set of containers needs, in a stable order.
443
+ *
444
+ * What allocation is handed: it assigns ports to names and knows nothing about
445
+ * what listens on them.
446
+ */
447
+ function portKeys(containers, fakes = {}) {
448
+ const keys = [...containers].sort().flatMap((container) => portsOf(container, fakes).map((port) => port.key));
449
+ return [.../* @__PURE__ */ new Set([...keys, ...Object.keys(fakes).sort()])];
450
+ }
451
+ /**
452
+ * The named volume a container's data lives in.
453
+ *
454
+ * Mailpit deliberately has none: local mail is disposable, and an inbox that
455
+ * survives days of dev is noise rather than state.
456
+ */
457
+ function volumeOf(container) {
458
+ return {
459
+ postgres: "postgres-data",
460
+ minio: "minio-data",
461
+ redis: "redis-data",
462
+ rabbitmq: "rabbitmq-data",
463
+ localstack: "localstack-data",
464
+ caddy: "caddy-data",
465
+ openobserve: "openobserve-data"
466
+ }[container];
467
+ }
468
+ //#endregion
469
+ //#region src/reconcile/emulator.ts
470
+ /**
471
+ * The AWS emulator (floci, LocalStack-compatible) the `sns` backend runs on
472
+ * locally — the facts the compose file, the env writer and the applier must
473
+ * agree on.
474
+ *
475
+ * The emulator has one account and answers with deterministic ARNs and queue
476
+ * URLs, which is what lets a connection string be composed before the topic
477
+ * or queue it names has been created.
478
+ */
479
+ /** The emulator's single account. */
480
+ const EMULATOR_ACCOUNT = "000000000000";
481
+ const EMULATOR_REGION = "us-east-1";
482
+ /**
483
+ * The emulator's access key id. The `LSIA` prefix is what LocalStack required
484
+ * on issued keys, and LocalStack reads the account from the id — so it is
485
+ * fixed, where the secret key beside it is generated per machine (see
486
+ * `localCredentials.ts`). Floci does not care; keeping it means a project
487
+ * that pins the old image still works.
488
+ */
489
+ const EMULATOR_ACCESS_KEY_ID = "LSIAQAAAAAAVNCBMPNSG";
490
+ /** The emulator's address from the host, on the port it was published on. */
491
+ function emulatorEndpoint(port) {
492
+ return `http://localhost:${port}`;
493
+ }
494
+ function emulatorTopicArn(name) {
495
+ return `arn:aws:sns:${EMULATOR_REGION}:${EMULATOR_ACCOUNT}:${name}`;
496
+ }
497
+ function emulatorQueueUrl(name, port) {
498
+ return `${emulatorEndpoint(port)}/${EMULATOR_ACCOUNT}/${name}`;
499
+ }
500
+ //#endregion
501
+ //#region src/reconcile/objectEvents.ts
502
+ /**
503
+ * A bucket's object events, where the bucket is a local MinIO.
504
+ *
505
+ * S3 publishes a bucket's events to a topic the deploy creates; MinIO has no
506
+ * topic to publish to, but it can post each event to a webhook. So where MinIO
507
+ * holds a watched bucket, it posts the bucket's events to the process that
508
+ * runs the bucket's subscribers, on a route only it can use, and that process
509
+ * relays each one onto the events broker — under the bucket's name, as
510
+ * `object.created` or `object.deleted` — where every subscriber drains a queue
511
+ * of its own, as a topic's subscribers do.
512
+ *
513
+ * Declared to MinIO in two halves, both derived here so they cannot drift:
514
+ *
515
+ * - **a webhook target per bucket**, as container environment: where to post,
516
+ * the token to present, and a queue on disk, because MinIO starts before the
517
+ * process it posts to and must keep what it could not deliver;
518
+ * - **the bucket's notification**, written through the S3 API once the bucket
519
+ * exists: every created and removed object, to that target. Unfiltered —
520
+ * two subscribers watching overlapping prefixes are two rules S3 refuses on
521
+ * one bucket, and each subscriber filters what it is handed anyway.
522
+ */
523
+ /**
524
+ * The token MinIO presents when it posts a bucket's events.
525
+ *
526
+ * Derived, never stored: the container and the process it posts to are handed
527
+ * the same value by the same derivation — with the stage's random seed where a
528
+ * deployed stage's stack has one, so the token is a secret there, and from the
529
+ * project alone locally, where everything it would protect is on loopback.
530
+ * Not salted by the stage: one MinIO serves `gkm dev` and `gkm test`, and a
531
+ * target is declared once per container.
532
+ */
533
+ function objectsWebhookToken(project, bucket, seed) {
534
+ return createHash("sha256").update(`${seed ? `${seed}:` : ""}${project}:objects-webhook:${bucket}`).digest("base64url").slice(0, 32);
535
+ }
536
+ /**
537
+ * The target's id in MinIO's environment — `MINIO_NOTIFY_WEBHOOK_*_<ID>`.
538
+ *
539
+ * Upper-cased with nothing between words: a canonical id is letters and
540
+ * digits, and an underscore inside the id would read as part of the setting's
541
+ * name.
542
+ */
543
+ function minioTargetId(bucket) {
544
+ return bucket.toUpperCase();
545
+ }
546
+ /** The target as a notification names it. */
547
+ function minioTargetArn(bucket) {
548
+ return `arn:minio:sqs::${minioTargetId(bucket)}:webhook`;
549
+ }
550
+ /** How a container reaches a process on the host. */
551
+ const HOST_GATEWAY = "host.docker.internal";
552
+ /** Where MinIO keeps what it could not deliver yet, inside its container. */
553
+ const QUEUE_ROOT = "/gkm-object-events";
554
+ /** The id of the notification rule gkm owns on a bucket. */
555
+ const NOTIFICATION_RULE_PREFIX = "gkm-";
556
+ /**
557
+ * MinIO's environment for each watched bucket's webhook target.
558
+ *
559
+ * Sorted, so the same buckets always render the same environment and a
560
+ * reconcile that changed nothing does not recreate the container.
561
+ */
562
+ function minioWebhookEnv(hooks) {
563
+ const env = {};
564
+ for (const hook of [...hooks].sort((a, b) => a.bucket.localeCompare(b.bucket))) {
565
+ const id = minioTargetId(hook.bucket);
566
+ env[`MINIO_NOTIFY_WEBHOOK_ENABLE_${id}`] = "on";
567
+ env[`MINIO_NOTIFY_WEBHOOK_ENDPOINT_${id}`] = hook.endpoint;
568
+ env[`MINIO_NOTIFY_WEBHOOK_AUTH_TOKEN_${id}`] = hook.token;
569
+ env[`MINIO_NOTIFY_WEBHOOK_QUEUE_DIR_${id}`] = `${QUEUE_ROOT}/${id.toLowerCase()}`;
570
+ }
571
+ return env;
572
+ }
573
+ /** The rule that sends every created and removed object to the bucket's target. */
574
+ function minioNotificationRule(bucket) {
575
+ return {
576
+ Id: `${NOTIFICATION_RULE_PREFIX}${bucket}`,
577
+ QueueArn: minioTargetArn(bucket),
578
+ Events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]
579
+ };
580
+ }
581
+ /**
582
+ * Each watched bucket, and the workers that run one of its subscribers.
583
+ *
584
+ * A bucket is watched when a subscriber reads its events key. MinIO posts a
585
+ * bucket's events to one place, and the relay fans them out to every
586
+ * subscriber whichever worker received them — so one worker per bucket is
587
+ * enough, and the first, by id, is the one chosen, so the choice is stable.
588
+ */
589
+ function watchedBuckets(manifest, subscribers) {
590
+ const byKey = /* @__PURE__ */ new Map();
591
+ for (const declaration of Object.values(manifest)) {
592
+ if (declaration.kind !== "objects") continue;
593
+ byKey.set(provideKey(declaration.id, "eventsConnectionString"), declaration.id);
594
+ }
595
+ const watched = /* @__PURE__ */ new Map();
596
+ for (const worker of Object.keys(subscribers).sort()) for (const { connectionKey } of subscribers[worker] ?? []) {
597
+ const bucket = byKey.get(connectionKey);
598
+ if (bucket && !watched.has(bucket)) watched.set(bucket, worker);
599
+ }
600
+ return watched;
601
+ }
602
+ //#endregion
603
+ //#region src/compose/redis.ts
604
+ /**
605
+ * The stack's Redis: what every declared cache lives in when a workspace runs
606
+ * as a `gkm compose` stack, on the local stage and on a deployed one alike.
607
+ *
608
+ * A cache is the one store whose contents can always be rebuilt, so unlike
609
+ * Mailpit and MinIO it is a production service, not a dev stand-in: it runs
610
+ * for every stage, on the compose network only, with nothing published. It
611
+ * is bounded (`maxmemory`, evicting the least recently used key), persisted
612
+ * (an append-only file on a named volume, kept by `--down`) and password
613
+ * protected — the stage's own password, generated once like its seed.
614
+ *
615
+ * A stage that sets a cache's URL in its secrets — a managed Redis — keeps
616
+ * it, and a stack whose every cache is set that way runs no Redis at all.
617
+ *
618
+ * Pure: the stack decides it, and the phases keep the password.
619
+ */
620
+ /**
621
+ * Where a stack's caches live: its own Redis, whatever the deploy target's
622
+ * default is. A stack is one machine running containers, and a Redis beside
623
+ * the apps is cheaper for a cache than a table in the database they share.
624
+ */
625
+ const STACK_CACHE = "redis";
626
+ /** Its compose service name — the host every cache URL points at. */
627
+ const REDIS_SERVICE = "redis";
628
+ /** The port it answers on, inside the network. */
629
+ const REDIS_PORT = 6379;
630
+ /** Reconcile's pin, so `gkm dev` and the stack run one Redis. */
631
+ const REDIS_IMAGE = DEFAULT_IMAGES.redis;
632
+ /**
633
+ * How much it may hold before it evicts. A cache that grows until the box
634
+ * runs out of memory takes the apps with it; 256 MB is a lot of sessions and
635
+ * little of a small server. A project's `docker-compose.<stage>.yml` can
636
+ * replace the command to change it.
637
+ */
638
+ const REDIS_MAXMEMORY = "256mb";
639
+ /** The stage secret holding its password. */
640
+ const REDIS_PASSWORD_KEY = "REDIS_PASSWORD";
641
+ /** Redis's own count of logical databases, before `--databases` raises it. */
642
+ const REDIS_DATABASES = 16;
643
+ /** A deployed stage that runs the stack's Redis and has no password yet. */
644
+ var RedisPasswordMissing = class extends GkmError {
645
+ stage;
646
+ constructor(stage) {
647
+ 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}`);
648
+ this.stage = stage;
649
+ this.name = "RedisPasswordMissing";
650
+ }
651
+ };
652
+ /**
653
+ * Whether a stage's stack runs Redis: a cache or a WebSocket surface is
654
+ * declared and the stage's secrets do not set the URL of every one.
655
+ */
656
+ function runsRedis(manifest, custom) {
657
+ return Object.values(manifest).some((declaration) => {
658
+ if (declaration?.kind === "cache") return (declaration.provides ?? []).some((key) => custom[key] === void 0);
659
+ return declaration?.kind === "websocket-api" && custom[provideKey(declaration.id, "publisherConnectionString")] === void 0;
660
+ });
661
+ }
662
+ /** A password: 256 random bits, URL-safe, so it sits in a URL unescaped. */
663
+ function generateRedisPassword() {
664
+ return randomBytes(32).toString("base64url");
665
+ }
666
+ /**
667
+ * The stage's secrets with a generated Redis password, where it has none.
668
+ * Pure, like `withGeneratedSecrets`: the caller keeps the result once the run
669
+ * goes ahead.
670
+ */
671
+ function withRedisPassword(secrets) {
672
+ if (secrets.custom?.["REDIS_PASSWORD"]) return {
673
+ secrets,
674
+ generated: []
675
+ };
676
+ return {
677
+ secrets: {
678
+ ...secrets,
679
+ custom: {
680
+ ...secrets.custom,
681
+ [REDIS_PASSWORD_KEY]: generateRedisPassword()
682
+ },
683
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
684
+ },
685
+ generated: [REDIS_PASSWORD_KEY]
686
+ };
687
+ }
688
+ /**
689
+ * The stack's Redis for one stage, or nothing where no cache needs it.
690
+ *
691
+ * Each cache it holds gets a logical database of its own, by the order of
692
+ * their ids, so two caches never read each other's keys.
693
+ */
694
+ function stackRedis(options) {
695
+ const { plan, stage, local, custom } = options;
696
+ const caches = plan.resources.filter((r) => r.kind === "cache" && custom[r.envKey] === void 0).sort((a, b) => a.id.localeCompare(b.id));
697
+ const publishers = plan.resources.filter((r) => r.kind === "websocket-api").map((r) => provideKey(r.id, "publisherConnectionString")).filter((key) => custom[key] === void 0);
698
+ if (caches.length === 0 && publishers.length === 0) return void 0;
699
+ const set = custom[REDIS_PASSWORD_KEY];
700
+ const password = set ?? (local ? options.localPassword : void 0);
701
+ if (!password) throw new RedisPasswordMissing(stage);
702
+ const auth = encodeURIComponent(password);
703
+ return {
704
+ password,
705
+ passwordFromSecrets: Boolean(set),
706
+ 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}`])]),
707
+ env: {
708
+ [REDIS_PASSWORD_KEY]: password,
709
+ REDISCLI_AUTH: password
710
+ },
711
+ databases: Math.max(REDIS_DATABASES, caches.length)
712
+ };
713
+ }
714
+ /**
715
+ * Redis's service: bounded, persisted and password protected, on the
716
+ * network alone.
717
+ *
718
+ * The command runs the image's own entrypoint with `redis-server` first, so
719
+ * it still drops to the `redis` user and owns `/data`; the password is read
720
+ * from the env file by the shell (`$$` is compose's escape for `$`), so
721
+ * neither the compose file nor the container's command holds it.
722
+ */
723
+ function redisService(redis) {
724
+ const flags = [
725
+ `--requirepass "$$${REDIS_PASSWORD_KEY}"`,
726
+ `--maxmemory ${REDIS_MAXMEMORY}`,
727
+ "--maxmemory-policy allkeys-lru",
728
+ "--appendonly yes",
729
+ ...redis.databases > REDIS_DATABASES ? [`--databases ${redis.databases}`] : []
730
+ ];
731
+ return {
732
+ image: REDIS_IMAGE,
733
+ restart: "unless-stopped",
734
+ command: [
735
+ "sh",
736
+ "-c",
737
+ `exec docker-entrypoint.sh redis-server ${flags.join(" ")}`
738
+ ],
739
+ env_file: [{
740
+ path: `./${REDIS_SERVICE}.env`,
741
+ format: "raw"
742
+ }],
743
+ volumes: ["redis-data:/data"],
744
+ healthcheck: {
745
+ test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"],
746
+ interval: "5s",
747
+ timeout: "3s",
748
+ retries: 10
749
+ }
750
+ };
751
+ }
752
+ //#endregion
753
+ //#region src/deploy/generated.ts
754
+ /**
755
+ * The values a deployed stage generates once and keeps: what nothing can
756
+ * provision and nobody else issues.
757
+ *
758
+ * - **A seed**, which salts every password a deploy derives — a database's
759
+ * master and roles, a bucket's root user. Derived from repo facts alone
760
+ * (project, stage, construct id), those passwords were computable by anyone
761
+ * who could read the repo.
762
+ * - **Each `secret` construct's value** — an auth server's signing secret, a
763
+ * `RandomPassword` — random, rather than derived, in its declared format.
764
+ * - **Each `encryption` construct's keyring** — one random key and an index
765
+ * key. Later keys are added by `gkm encryption:rotate`, never by a deploy.
766
+ *
767
+ * Both are generated on the first deploy that needs them and written to the
768
+ * stage's store, so every later deploy reads the same values: sessions survive
769
+ * a redeploy, and a role's password does not move. A value set by hand with
770
+ * `gkm secrets:set` is kept, never replaced.
771
+ */
772
+ /**
773
+ * The stage's secrets with its seed and every declared `secret`'s value
774
+ * present, generating what is missing. Pure: the caller writes the result
775
+ * back to the stage's store when `generated` is not empty.
776
+ */
777
+ function withGeneratedSecrets(secrets, manifest) {
778
+ const generated = [];
779
+ const custom = { ...secrets.custom };
780
+ for (const declaration of Object.values(manifest)) {
781
+ if (declaration?.kind !== "secret" && declaration?.kind !== "encryption") continue;
782
+ const key = declaration.provides?.[0];
783
+ if (!key || custom[key]) continue;
784
+ custom[key] = declaration.kind === "encryption" ? generateKeyring() : drawSecret(randomInt, declaration);
785
+ generated.push(key);
786
+ }
787
+ const seed = secrets.seed ?? generateSeed();
788
+ if (!secrets.seed) generated.push("seed");
789
+ return {
790
+ secrets: generated.length ? {
791
+ ...secrets,
792
+ seed,
793
+ custom,
794
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
795
+ } : secrets,
796
+ generated
797
+ };
798
+ }
799
+ /** A stage's seed: 256 random bits, URL-safe. */
800
+ function generateSeed() {
801
+ return random();
802
+ }
803
+ /** 256 bits, URL-safe. */
804
+ function random() {
805
+ return randomBytes(32).toString("base64url");
806
+ }
807
+ /** MinIO's root user, the same for every workspace: it is not a secret. */
808
+ const LOCAL_MINIO_USER = "minio";
809
+ /** RabbitMQ's administrator, the same way. */
810
+ const LOCAL_RABBITMQ_USER = "rabbitmq";
811
+ /**
812
+ * The Postgres superuser for a workspace: its name as an identifier, with
813
+ * `_admin` — never the bare name, which a database construct of the same
814
+ * name would claim as its runtime role.
815
+ */
816
+ function postgresSuperuser(project) {
817
+ return `${postgresRoleSlug(project)}_admin`;
818
+ }
819
+ /**
820
+ * The project as the start of a role's name: lowercase, `_` for anything
821
+ * else, never starting with a digit — `gkm` when nothing is left.
822
+ */
823
+ function postgresRoleSlug(project) {
824
+ return project.toLowerCase().replace(/^@[^/]+\//, "").replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").replace(/^(\d)/, "_$1") || "gkm";
825
+ }
826
+ /** 256 random bits, URL-safe. */
827
+ function token() {
828
+ return randomBytes(32).toString("base64url");
829
+ }
830
+ /** `length` characters of letters and digits, which every client takes as is. */
831
+ function alphanumeric(length) {
832
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
833
+ let out = "";
834
+ for (let i = 0; i < length; i++) out += alphabet[randomInt(62)];
835
+ return out;
836
+ }
837
+ /** A fresh set of local logins for a workspace. */
838
+ function generateLocalCredentials(project) {
839
+ return {
840
+ seed: generateSeed(),
841
+ postgres: {
842
+ user: postgresSuperuser(project),
843
+ password: token()
844
+ },
845
+ minio: {
846
+ user: LOCAL_MINIO_USER,
847
+ password: alphanumeric(32)
848
+ },
849
+ rabbitmq: {
850
+ user: LOCAL_RABBITMQ_USER,
851
+ password: token()
852
+ },
853
+ redis: { password: generateRedisPassword() },
854
+ cacheToken: token(),
855
+ emulator: {
856
+ accessKeyId: EMULATOR_ACCESS_KEY_ID,
857
+ secretAccessKey: alphanumeric(40)
858
+ },
859
+ logs: {
860
+ email: LOCAL_LOGS_EMAIL,
861
+ password: generateLogsPassword()
862
+ }
863
+ };
864
+ }
865
+ /**
866
+ * The stored logins with anything missing generated — a file an older gkm
867
+ * wrote before a service existed. Pure: the caller writes the result back
868
+ * when `generated` is not empty.
869
+ */
870
+ function withLocalCredentials(stored, project) {
871
+ const fresh = generateLocalCredentials(project);
872
+ const generated = Object.keys(fresh).filter((key) => stored?.[key] === void 0);
873
+ return {
874
+ credentials: {
875
+ ...fresh,
876
+ ...stored
877
+ },
878
+ generated
879
+ };
880
+ }
881
+ /** Where a workspace's local logins are kept on this machine. */
882
+ function localCredentialsPath(project) {
883
+ const keys = getKeystoreDir(project);
884
+ const name = keys.split(/[\\/]/).at(-1);
885
+ const namespace = keys.split(/[\\/]/).at(-2);
886
+ return join(project.home ?? gkmHome(), "local", namespace, `${name}.json`);
887
+ }
888
+ /** The local stage's logins file is there, and its key is not. */
889
+ var LocalCredentialsKeyMissing = class extends GkmError {
890
+ path;
891
+ stage;
892
+ constructor(path, stage) {
893
+ 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.`);
894
+ this.path = path;
895
+ this.stage = stage;
896
+ this.name = "LocalCredentialsKeyMissing";
897
+ }
898
+ };
899
+ /** Another gkm held the logins file's lock for longer than any write takes. */
900
+ var LocalCredentialsLocked = class extends GkmError {
901
+ lock;
902
+ constructor(lock) {
903
+ 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.`);
904
+ this.lock = lock;
905
+ this.name = "LocalCredentialsLocked";
906
+ }
907
+ };
908
+ /** Read the stored logins, or `null` where none were generated yet. */
909
+ async function readLocalCredentials(workspace, home) {
910
+ const project = keystoreProject(workspace, home);
911
+ const path = localCredentialsPath(project);
912
+ if (!existsSync(path)) return null;
913
+ const stage = workspace.stages.local;
914
+ const key = await readKey(stage, project);
915
+ if (!key) throw new LocalCredentialsKeyMissing(path, stage);
916
+ const file = JSON.parse(await readFile(path, "utf-8"));
917
+ return decrypt(file, key);
918
+ }
919
+ /** Write the logins, encrypted with the local stage's key, owner-only. */
920
+ async function saveLocalCredentials(workspace, credentials, home) {
921
+ const project = keystoreProject(workspace, home);
922
+ const path = localCredentialsPath(project);
923
+ const key = await getOrCreateKey(workspace.stages.local, project);
924
+ await mkdir(dirname(path), {
925
+ recursive: true,
926
+ mode: 448
927
+ });
928
+ await writeFile(path, JSON.stringify(encrypt(credentials, key), null, 2), { mode: 384 });
929
+ }
930
+ /**
931
+ * The workspace's local logins: read back, or generated and kept the first
932
+ * time anything needs them.
933
+ *
934
+ * Under a lock, because a workspace's `gkm dev` starts one per app and the
935
+ * first run of each would otherwise generate — and keep — its own.
936
+ */
937
+ async function loadLocalCredentials(workspace, home) {
938
+ return withLock(`${localCredentialsPath(keystoreProject(workspace, home))}.lock`, async () => {
939
+ const result = withLocalCredentials(await readLocalCredentials(workspace, home), workspace.name);
940
+ if (result.generated.length > 0) await saveLocalCredentials(workspace, result.credentials, home);
941
+ return result;
942
+ });
943
+ }
944
+ /** How long a lock may be held before it is someone else's problem. */
945
+ const LOCK_TIMEOUT_MS = 15e3;
946
+ async function withLock(lock, body) {
947
+ await mkdir(dirname(lock), {
948
+ recursive: true,
949
+ mode: 448
950
+ });
951
+ const started = Date.now();
952
+ for (;;) try {
953
+ await mkdir(lock);
954
+ break;
955
+ } catch (error) {
956
+ if (error.code !== "EEXIST") throw error;
957
+ if (await stat(lock).then((s) => Date.now() - s.mtimeMs).catch(() => 0) > LOCK_TIMEOUT_MS) {
958
+ await rm(lock, {
959
+ recursive: true,
960
+ force: true
961
+ });
962
+ continue;
963
+ }
964
+ if (Date.now() - started > LOCK_TIMEOUT_MS) throw new LocalCredentialsLocked(lock);
965
+ await new Promise((resolve) => setTimeout(resolve, 50));
966
+ }
967
+ try {
968
+ return await body();
969
+ } finally {
970
+ await rm(lock, {
971
+ recursive: true,
972
+ force: true
973
+ });
974
+ }
975
+ }
976
+ //#endregion
977
+ //#region src/credentials/index.ts
978
+ const logger = console;
979
+ /**
980
+ * Load environment files
981
+ * @internal Exported for testing
982
+ */
983
+ function loadEnvFiles(envConfig, cwd = process.cwd()) {
984
+ const loaded = [];
985
+ const missing = [];
986
+ const envFiles = envConfig ? Array.isArray(envConfig) ? envConfig : [envConfig] : [".env"];
987
+ for (const envFile of envFiles) {
988
+ const envPath = resolve(cwd, envFile);
989
+ if (existsSync(envPath)) {
990
+ config({
991
+ path: envPath,
992
+ override: true,
993
+ quiet: true
994
+ });
995
+ loaded.push(envFile);
996
+ } else if (envConfig) missing.push(envFile);
997
+ }
998
+ return {
999
+ loaded,
1000
+ missing
1001
+ };
1002
+ }
1003
+ /**
1004
+ * Check if a port is available
1005
+ * @internal Exported for testing
1006
+ */
1007
+ async function isPortAvailable(port) {
1008
+ return new Promise((resolve) => {
1009
+ const server = createServer();
1010
+ server.once("error", (err) => {
1011
+ if (err.code === "EADDRINUSE") resolve(false);
1012
+ else resolve(false);
1013
+ });
1014
+ server.once("listening", () => {
1015
+ server.close();
1016
+ resolve(true);
1017
+ });
1018
+ server.listen(port);
1019
+ });
1020
+ }
1021
+ /**
1022
+ * Find an available port starting from the preferred port
1023
+ * @internal Exported for testing
1024
+ */
1025
+ async function findAvailablePort(preferredPort, maxAttempts = 10) {
1026
+ for (let i = 0; i < maxAttempts; i++) {
1027
+ const port = preferredPort + i;
1028
+ if (await isPortAvailable(port)) return port;
1029
+ logger.log(`⚠️ Port ${port} is in use, trying ${port + 1}...`);
1030
+ }
1031
+ throw new Error(`Could not find an available port after trying ${maxAttempts} ports starting from ${preferredPort}`);
1032
+ }
1033
+ const PORT_STATE_PATH = ".gkm/ports.json";
1034
+ /**
1035
+ * Load saved port state from .gkm/ports.json.
1036
+ * @internal Exported for testing
1037
+ */
1038
+ async function loadPortState(workspaceRoot) {
1039
+ try {
1040
+ const raw = await readFile(join(workspaceRoot, PORT_STATE_PATH), "utf-8");
1041
+ return JSON.parse(raw);
1042
+ } catch {
1043
+ return {};
1044
+ }
1045
+ }
1046
+ /**
1047
+ * Save port state to .gkm/ports.json.
1048
+ * @internal Exported for testing
1049
+ */
1050
+ async function savePortState(workspaceRoot, ports) {
1051
+ const dir = join(workspaceRoot, ".gkm");
1052
+ await mkdir(dir, { recursive: true });
1053
+ await writeFile(join(workspaceRoot, PORT_STATE_PATH), `${JSON.stringify(ports, null, 2)}\n`);
1054
+ }
1055
+ /**
1056
+ * Load and flatten a stage's secrets from its store.
1057
+ *
1058
+ * Every key as stored — nothing renamed. An app's database URL is its
1059
+ * construct's key, derived by reconcile, and never a stored per-app value
1060
+ * mapped onto `DATABASE_URL`.
1061
+ * @internal Exported for testing
1062
+ */
1063
+ async function loadSecretsForApp(store, stage) {
1064
+ const stageSecrets = await store.read(stage);
1065
+ if (!stageSecrets) return {};
1066
+ logger.log(`🔐 Loading secrets from stage: ${stage}`);
1067
+ return toEmbeddableSecrets(stageSecrets);
1068
+ }
1069
+ /**
1070
+ * Walk up the directory tree to find the root containing .gkm/secrets/.
1071
+ * @internal Exported for testing
1072
+ */
1073
+ function findSecretsRoot(startDir) {
1074
+ let dir = startDir;
1075
+ while (dir !== "/") {
1076
+ if (existsSync(join(dir, ".gkm", "secrets"))) return dir;
1077
+ const parent = dirname(dir);
1078
+ if (parent === dir) break;
1079
+ dir = parent;
1080
+ }
1081
+ return startDir;
1082
+ }
1083
+ /**
1084
+ * Generate the credentials injection code snippet.
1085
+ * This is the common logic used by both entry wrapper and exec preload.
1086
+ * @internal
1087
+ */
1088
+ function generateCredentialsInjection(secretsJsonPath) {
1089
+ return `import { existsSync, readFileSync } from 'node:fs';
1090
+
1091
+ // Inject dev secrets via globalThis and process.env
1092
+ // Using globalThis.__gkm_credentials__ avoids CJS/ESM interop issues where
1093
+ // Object.assign on the Credentials export only mutates one module copy.
1094
+ const secretsPath = '${secretsJsonPath}';
1095
+ if (existsSync(secretsPath)) {
1096
+ const secrets = JSON.parse(readFileSync(secretsPath, 'utf-8'));
1097
+ globalThis.__gkm_credentials__ = secrets;
1098
+ Object.assign(process.env, secrets);
1099
+ }
1100
+ `;
1101
+ }
1102
+ /**
1103
+ * Create a preload script that injects secrets into Credentials.
1104
+ * Used by `gkm exec` to inject secrets before running any command.
1105
+ * @internal Exported for testing
1106
+ */
1107
+ async function createCredentialsPreload(preloadPath, secretsJsonPath) {
1108
+ const content = `/**
1109
+ * Credentials preload generated by 'gkm exec'
1110
+ * This file is loaded via NODE_OPTIONS="--import <path>"
1111
+ */
1112
+ ${generateCredentialsInjection(secretsJsonPath)}`;
1113
+ await writeFile(preloadPath, content);
1114
+ }
1115
+ /**
1116
+ * Create a wrapper script that injects secrets before importing the entry file.
1117
+ * @internal Exported for testing
1118
+ */
1119
+ async function createEntryWrapper(wrapperPath, entryPath, secretsJsonPath) {
1120
+ const content = `#!/usr/bin/env node
1121
+ /**
1122
+ * Entry wrapper generated by 'gkm dev --entry'
1123
+ */
1124
+ ${secretsJsonPath ? `${generateCredentialsInjection(secretsJsonPath)}
1125
+ ` : ""}// Import and run the user's entry file (dynamic import ensures secrets load first)
1126
+ await import('${entryPath}');
1127
+ `;
1128
+ await writeFile(wrapperPath, content);
1129
+ }
1130
+ /**
1131
+ * Prepare credentials for dev/exec/test modes.
1132
+ * Loads workspace config, secrets, resolves Docker ports, rewrites URLs,
1133
+ * injects PORT, dependency URLs, and writes credentials JSON.
1134
+ *
1135
+ * @param options.stage - The stage whose secrets to load. Default: the project's `stages.local`.
1136
+ * @param options.startDocker - Start Docker Compose services after port resolution. Default: false.
1137
+ * @param options.secretsFileName - Custom secrets JSON filename. Default: 'dev-secrets-{appName}.json' or 'dev-secrets.json'.
1138
+ * @internal Exported for testing
1139
+ */
1140
+ async function prepareEntryCredentials(options) {
1141
+ const cwd = options.cwd ?? process.cwd();
1142
+ let workspaceAppPort;
1143
+ let secretsRoot = cwd;
1144
+ let appName;
1145
+ let appInfo;
1146
+ let workspace;
1147
+ try {
1148
+ appInfo = await loadWorkspaceAppInfo(cwd);
1149
+ workspace = appInfo.workspace;
1150
+ workspaceAppPort = appInfo.app.port;
1151
+ secretsRoot = appInfo.workspaceRoot;
1152
+ appName = appInfo.appName;
1153
+ } catch (error) {
1154
+ if (!(error instanceof NotInAnApp || error instanceof ConfigNotFound)) throw error;
1155
+ workspace = await loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
1156
+ secretsRoot = workspace?.root ?? findSecretsRoot(cwd);
1157
+ }
1158
+ if (appName && workspace && options.explicitPort === void 0) {
1159
+ const { assignAppPorts, describeMove, holderOf, withAppPorts } = await import("./appPorts-BoXMwolc.mjs").then((n) => n.n);
1160
+ const assigned = await assignAppPorts(workspace, [appName], {
1161
+ free: isPortAvailable,
1162
+ holder: holderOf
1163
+ });
1164
+ for (const move of assigned.moved) logger.log(describeMove(move));
1165
+ workspace = withAppPorts(workspace, assigned.ports);
1166
+ workspaceAppPort = assigned.ports[appName] ?? workspaceAppPort;
1167
+ }
1168
+ if (appName) {
1169
+ const { APP_TAG_ENV, appTag } = await import("./appPorts-BoXMwolc.mjs").then((n) => n.n);
1170
+ process.env[APP_TAG_ENV] = appTag(secretsRoot, appName);
1171
+ }
1172
+ const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
1173
+ const stage = options.stage ?? workspace?.stages.local;
1174
+ const store = stage ? workspace ? await secretsStoreFor(workspace, stage) : new FileSecretsStore(secretsRoot) : void 0;
1175
+ const credentials = store && stage ? await loadSecretsForApp(store, stage) : {};
1176
+ credentials.PORT = String(resolvedPort);
1177
+ if (appInfo?.app.type === "mobile") credentials.RCT_METRO_PORT = String(resolvedPort);
1178
+ const declaredKeys = [];
1179
+ let reconciled;
1180
+ if (workspace) {
1181
+ const { reconcileWorkspace } = await import("./apps-C7SujLV-.mjs").then((n) => n.h);
1182
+ const result = await reconcileWorkspace(workspace, {
1183
+ stage: options.reconcileStage ?? workspace.stages.local,
1184
+ start: options.startDocker ?? false
1185
+ });
1186
+ reconciled = result;
1187
+ if (options.scoped && appName) {
1188
+ const { appProcess, processEnv } = await import("./apps-C7SujLV-.mjs").then((n) => n.r);
1189
+ const own = processEnv(result.manifest, appProcess(workspace, result.manifest, result.background, appName), { ...credentials }, result.env);
1190
+ for (const key of Object.keys(credentials)) delete credentials[key];
1191
+ Object.assign(credentials, own);
1192
+ } else Object.assign(credentials, reconciled.env);
1193
+ declaredKeys.push(...Object.keys(reconciled.env).filter((key) => key in credentials));
1194
+ if (Object.keys(reconciled.env).length > 0) logger.log(`🔌 Resolved ${Object.keys(reconciled.env).length} declared URL(s)`);
1195
+ }
1196
+ const secretsDir = join(secretsRoot, ".gkm");
1197
+ await mkdir(secretsDir, { recursive: true });
1198
+ const secretsFileName = options.secretsFileName ?? (appName ? `dev-secrets-${appName}.json` : "dev-secrets.json");
1199
+ const secretsJsonPath = join(secretsDir, secretsFileName);
1200
+ await writeFile(secretsJsonPath, JSON.stringify(credentials, null, 2));
1201
+ return {
1202
+ credentials,
1203
+ resolvedPort,
1204
+ secretsJsonPath,
1205
+ appName,
1206
+ secretsRoot,
1207
+ appInfo,
1208
+ declaredKeys,
1209
+ ...reconciled ? { reconciled } : {}
1210
+ };
1211
+ }
1212
+ //#endregion
1213
+ //#region src/reconcile/compose.ts
1214
+ /**
1215
+ * The compose document a plan implies.
1216
+ *
1217
+ * The third declaration of the same containers disappears here: today a
1218
+ * `services: ['postgres','minio']` block is kept in step with the code by hand,
1219
+ * which is the triplication this design exists to remove, in the one place you
1220
+ * touch every day. A `database` implies Postgres; the list is derived.
1221
+ *
1222
+ * Returns an object rather than a string for the same reason `plan` is pure —
1223
+ * what should exist is asserted as data, and turning it into YAML is one line at
1224
+ * the edge.
1225
+ *
1226
+ * What stays config is unchanged: images and versions are pinned explicitly, and
1227
+ * a container no construct implies is still declared by hand. Neutral facts come
1228
+ * from the declaration, provider detail from config.
1229
+ */
1230
+ /** The database every connection opens first: every cluster has it. */
1231
+ const CLUSTER_DATABASE = "postgres";
1232
+ /**
1233
+ * Build the compose document for a plan.
1234
+ *
1235
+ * Every container is published on its assigned port, never on the image's
1236
+ * default: the point of allocation is that two projects can run at once, and
1237
+ * one container publishing 5432 puts that back.
1238
+ */
1239
+ function composeFor(plan, options) {
1240
+ const services = {};
1241
+ const volumes = {};
1242
+ for (const container of [...plan.containers].sort()) {
1243
+ const declared = container === "postgres" ? plan.resources.find((r) => r.version)?.version : void 0;
1244
+ const named = container === "postgres" ? declaredPostgresImage(plan) : void 0;
1245
+ const fake = plan.fakes?.[container];
1246
+ const image = named ?? (declared ? postgresImage(declared) : fake?.image ?? DEFAULT_IMAGES[container]);
1247
+ if (!image) throw new UnknownContainer(container);
1248
+ const published = publish(container, options.ports, plan.fakes);
1249
+ services[container] = fake ? {
1250
+ image,
1251
+ restart: "unless-stopped",
1252
+ ports: published
1253
+ } : define(container, image, published, options.credentials);
1254
+ const volume = volumeOf(container);
1255
+ if (volume) volumes[volume] = {};
1256
+ }
1257
+ const minio = services.minio;
1258
+ if (minio && options.objectWebhooks?.length) {
1259
+ minio.environment = {
1260
+ ...minio.environment,
1261
+ ...minioWebhookEnv(options.objectWebhooks)
1262
+ };
1263
+ if (options.objectWebhooks.some((hook) => hook.endpoint.includes(`//host.docker.internal:`))) minio.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];
1264
+ }
1265
+ const mailpit = services.mailpit;
1266
+ if (mailpit && options.inboxRelay) {
1267
+ mailpit.environment = {
1268
+ ...mailpit.environment,
1269
+ MP_WEBHOOK_URL: options.inboxRelay
1270
+ };
1271
+ if (options.inboxRelay.includes(`//host.docker.internal:`)) mailpit.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];
1272
+ }
1273
+ return {
1274
+ name: options.project,
1275
+ services: {
1276
+ ...services,
1277
+ ...options.apps
1278
+ },
1279
+ ...Object.keys(volumes).length ? { volumes } : {}
1280
+ };
1281
+ }
1282
+ /** Render a compose document as the file it becomes. */
1283
+ function toYaml(file) {
1284
+ return `# Generated by gkm from the construct manifest — do not edit.
1285
+ # Containers are derived from what the app declares. Image pins and anything
1286
+ # no construct implies go in your own docker-compose.yml, which is merged over
1287
+ # this file and wins:
1288
+ #
1289
+ # docker compose -f docker-compose.constructs.yml -f docker-compose.yml …
1290
+ #
1291
+ # "gkm dev" and "gkm test" start the containers. The apps sit behind the
1292
+ # "apps" profile: run "gkm setup", then
1293
+ # docker compose -f docker-compose.constructs.yml --profile apps up --build
1294
+ ${stringify(file, { lineWidth: 0 })}`;
1295
+ }
1296
+ /** A container with no image, from config or from the defaults. */
1297
+ /**
1298
+ * The image the databases in the plan named for the shared local cluster, if
1299
+ * any did.
1300
+ */
1301
+ function declaredPostgresImage(plan) {
1302
+ const named = plan.resources.filter((r) => r.kind === "database" && Boolean(r.image));
1303
+ const images = [...new Set(named.map((r) => r.image))];
1304
+ if (images.length > 1) throw new ConflictingPostgresImages(named.map((r) => ({
1305
+ id: r.id,
1306
+ image: r.image
1307
+ })));
1308
+ return images[0];
1309
+ }
1310
+ /** Two databases on the one local cluster named different images for it. */
1311
+ var ConflictingPostgresImages = class extends Error {
1312
+ databases;
1313
+ constructor(databases) {
1314
+ 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.`);
1315
+ this.databases = databases;
1316
+ this.name = "ConflictingPostgresImages";
1317
+ }
1318
+ };
1319
+ var UnknownContainer = class extends Error {
1320
+ /** The container that could not be resolved. */
1321
+ container;
1322
+ /** The containers that have a default, so the caller can see the set. */
1323
+ known = Object.keys(DEFAULT_IMAGES).sort();
1324
+ constructor(container) {
1325
+ super("No image is known for this container; pin one in config");
1326
+ this.name = "UnknownContainer";
1327
+ this.container = container;
1328
+ }
1329
+ };
1330
+ /** One container's definition, published on the port it was assigned. */
1331
+ function define(container, image, published, credentials) {
1332
+ switch (container) {
1333
+ case "postgres": return {
1334
+ image,
1335
+ restart: "unless-stopped",
1336
+ ports: published,
1337
+ environment: {
1338
+ POSTGRES_USER: credentials.postgres.user,
1339
+ POSTGRES_PASSWORD: credentials.postgres.password,
1340
+ POSTGRES_DB: CLUSTER_DATABASE
1341
+ },
1342
+ volumes: ["postgres-data:/var/lib/postgresql"],
1343
+ healthcheck: {
1344
+ test: ["CMD-SHELL", `pg_isready -U ${credentials.postgres.user} -d ${CLUSTER_DATABASE}`],
1345
+ interval: "5s",
1346
+ timeout: "3s",
1347
+ retries: 10,
1348
+ start_period: "10s"
1349
+ }
1350
+ };
1351
+ case "minio": return {
1352
+ image,
1353
+ restart: "unless-stopped",
1354
+ ports: published,
1355
+ environment: {
1356
+ MINIO_ROOT_USER: credentials.minio.user,
1357
+ MINIO_ROOT_PASSWORD: credentials.minio.password
1358
+ },
1359
+ command: "server --console-address \":9001\" /data",
1360
+ volumes: ["minio-data:/data"],
1361
+ healthcheck: {
1362
+ test: [
1363
+ "CMD",
1364
+ "mc",
1365
+ "ready",
1366
+ "local"
1367
+ ],
1368
+ interval: "10s",
1369
+ timeout: "5s",
1370
+ retries: 5,
1371
+ start_period: "10s"
1372
+ }
1373
+ };
1374
+ case "caddy": return {
1375
+ image,
1376
+ restart: "unless-stopped",
1377
+ ports: published,
1378
+ volumes: [
1379
+ "./.gkm/Caddyfile:/etc/caddy/Caddyfile:ro",
1380
+ "./.gkm/caddy-sites:/etc/caddy/sites:ro",
1381
+ "caddy-data:/data"
1382
+ ],
1383
+ extra_hosts: ["host.docker.internal:host-gateway"],
1384
+ healthcheck: {
1385
+ test: [
1386
+ "CMD",
1387
+ "caddy",
1388
+ "version"
1389
+ ],
1390
+ interval: "10s",
1391
+ timeout: "5s",
1392
+ retries: 5
1393
+ }
1394
+ };
1395
+ case "mailpit": return {
1396
+ image,
1397
+ restart: "unless-stopped",
1398
+ ports: published,
1399
+ environment: {
1400
+ MP_SMTP_AUTH_ACCEPT_ANY: "1",
1401
+ MP_SMTP_AUTH_ALLOW_INSECURE: "1"
1402
+ },
1403
+ healthcheck: {
1404
+ test: [
1405
+ "CMD",
1406
+ "wget",
1407
+ "-q",
1408
+ "--spider",
1409
+ "http://localhost:8025"
1410
+ ],
1411
+ interval: "10s",
1412
+ timeout: "5s",
1413
+ retries: 5
1414
+ }
1415
+ };
1416
+ case "redis": return {
1417
+ image,
1418
+ restart: "unless-stopped",
1419
+ ports: published,
1420
+ command: "sh -c 'exec docker-entrypoint.sh redis-server --requirepass \"$$REDIS_PASSWORD\"'",
1421
+ environment: {
1422
+ REDIS_PASSWORD: credentials.redis.password,
1423
+ REDISCLI_AUTH: credentials.redis.password
1424
+ },
1425
+ volumes: ["redis-data:/data"],
1426
+ healthcheck: {
1427
+ test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"],
1428
+ interval: "5s",
1429
+ timeout: "3s",
1430
+ retries: 5
1431
+ }
1432
+ };
1433
+ case "redis-http": return {
1434
+ image,
1435
+ restart: "unless-stopped",
1436
+ ports: published,
1437
+ environment: {
1438
+ SRH_MODE: "env",
1439
+ SRH_TOKEN: credentials.cacheToken,
1440
+ SRH_CONNECTION_STRING: `redis://:${encodeURIComponent(credentials.redis.password)}@redis:6379`
1441
+ },
1442
+ depends_on: ["redis"],
1443
+ healthcheck: {
1444
+ test: [
1445
+ "CMD",
1446
+ "wget",
1447
+ "-q",
1448
+ "-O",
1449
+ "/dev/null",
1450
+ "http://127.0.0.1:80/"
1451
+ ],
1452
+ interval: "5s",
1453
+ timeout: "3s",
1454
+ retries: 10
1455
+ }
1456
+ };
1457
+ case "rabbitmq": return {
1458
+ image,
1459
+ restart: "unless-stopped",
1460
+ ports: published,
1461
+ environment: {
1462
+ RABBITMQ_DEFAULT_USER: credentials.rabbitmq.user,
1463
+ RABBITMQ_DEFAULT_PASS: credentials.rabbitmq.password
1464
+ },
1465
+ volumes: ["rabbitmq-data:/var/lib/rabbitmq"],
1466
+ healthcheck: {
1467
+ test: [
1468
+ "CMD",
1469
+ "rabbitmq-diagnostics",
1470
+ "-q",
1471
+ "ping"
1472
+ ],
1473
+ interval: "10s",
1474
+ timeout: "5s",
1475
+ retries: 5
1476
+ }
1477
+ };
1478
+ case "localstack": return {
1479
+ image,
1480
+ restart: "unless-stopped",
1481
+ ports: published,
1482
+ extra_hosts: ["host.docker.internal:host-gateway"],
1483
+ environment: {
1484
+ AWS_DEFAULT_REGION: EMULATOR_REGION,
1485
+ AWS_ACCESS_KEY_ID: credentials.emulator.accessKeyId,
1486
+ AWS_SECRET_ACCESS_KEY: credentials.emulator.secretAccessKey
1487
+ },
1488
+ volumes: ["localstack-data:/var/lib/localstack"],
1489
+ healthcheck: {
1490
+ test: [
1491
+ "CMD",
1492
+ "bash",
1493
+ "-c",
1494
+ "exec 3<>/dev/tcp/localhost/4566"
1495
+ ],
1496
+ interval: "10s",
1497
+ timeout: "5s",
1498
+ retries: 5,
1499
+ start_period: "10s"
1500
+ }
1501
+ };
1502
+ case "openobserve": {
1503
+ const login = credentials.logs;
1504
+ return {
1505
+ image,
1506
+ restart: "unless-stopped",
1507
+ ports: published,
1508
+ environment: {
1509
+ [LOGS_EMAIL_KEY]: login.email,
1510
+ [LOGS_PASSWORD_KEY]: login.password,
1511
+ ZO_DATA_DIR: "/data",
1512
+ ZO_COMPACT_DATA_RETENTION_DAYS: String(30),
1513
+ ZO_TELEMETRY: "false"
1514
+ },
1515
+ volumes: ["openobserve-data:/data"],
1516
+ healthcheck: {
1517
+ test: [
1518
+ "CMD",
1519
+ "/openobserve",
1520
+ "node",
1521
+ "status"
1522
+ ],
1523
+ interval: "10s",
1524
+ timeout: "5s",
1525
+ retries: 12,
1526
+ start_period: "20s"
1527
+ }
1528
+ };
1529
+ }
1530
+ default: throw new UnknownContainer(container);
1531
+ }
1532
+ }
1533
+ /**
1534
+ * The published port mappings for a container.
1535
+ *
1536
+ * Every port is looked up by its own key rather than being derived as an offset
1537
+ * from the container's first, so MinIO's console cannot land on whatever was
1538
+ * allocated to the next container.
1539
+ */
1540
+ function publish(container, ports, fakes) {
1541
+ return portsOf(container, fakes).map((port) => {
1542
+ const assigned = ports[port.key];
1543
+ if (assigned === void 0) throw new UnassignedPort(port.key);
1544
+ return `${assigned}:${port.inside}`;
1545
+ });
1546
+ }
1547
+ /** A planned port that allocation never assigned. */
1548
+ var UnassignedPort = class extends Error {
1549
+ /** The port key that went unassigned, e.g. `minio-console`. */
1550
+ key;
1551
+ constructor(key) {
1552
+ super("No port was assigned for this container port");
1553
+ this.name = "UnassignedPort";
1554
+ this.key = key;
1555
+ }
1556
+ };
1557
+ //#endregion
1558
+ export { otlpHeaders as $, minioWebhookEnv as A, fakeKey as B, redisService as C, HOST_GATEWAY as D, withRedisPassword as E, emulatorEndpoint as F, serviceAddresses as G, portsOf as H, emulatorQueueUrl as I, LOGS_ORG as J, LOCAL_LOGS_EMAIL as K, emulatorTopicArn as L, watchedBuckets as M, EMULATOR_ACCESS_KEY_ID as N, NOTIFICATION_RULE_PREFIX as O, EMULATOR_REGION as P, logsService as Q, DEFAULT_IMAGES as R, STACK_CACHE as S, stackRedis as T, postgresImage as U, portKeys as V, primaryPortKey as W, LOGS_SERVICE as X, LOGS_PASSWORD_KEY as Y, logsAccess as Z, readLocalCredentials as _, createEntryWrapper as a, resolveHost as at, REDIS_PASSWORD_KEY as b, loadEnvFiles as c, prepareEntryCredentials as d, stackLogs as et, savePortState as f, postgresSuperuser as g, postgresRoleSlug as h, createCredentialsPreload as i, isMainFrontendApp as it, objectsWebhookToken as j, minioNotificationRule as k, loadPortState as l, loadLocalCredentials as m, composeFor as n, NoDomainForStage as nt, findAvailablePort as o, rootSite as ot, LOCAL_RABBITMQ_USER as p, LOGS_EMAIL_KEY as q, toYaml as r, getPublicUrlArgNames as rt, isPortAvailable as s, CLUSTER_DATABASE as t, withLogsPassword as tt, loadSecretsForApp as u, saveLocalCredentials as v, runsRedis as w, REDIS_SERVICE as x, withGeneratedSecrets as y, describeServices as z };
1559
+
1560
+ //# sourceMappingURL=compose-Co-Dt-a4.mjs.map