@geekmidas/cli 10.0.0-alpha.12 → 10.0.0-alpha.121

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 (517) hide show
  1. package/README.md +310 -377
  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-BDa6pPgE.cjs +1090 -0
  7. package/dist/EndpointGenerator-BDa6pPgE.cjs.map +1 -0
  8. package/dist/EndpointGenerator-CP_z_E3e.mjs +1031 -0
  9. package/dist/EndpointGenerator-CP_z_E3e.mjs.map +1 -0
  10. package/dist/GoDaddyProvider-3C8U_tVu.cjs +388 -0
  11. package/dist/GoDaddyProvider-3C8U_tVu.cjs.map +1 -0
  12. package/dist/GoDaddyProvider-D0MQoOM4.mjs +388 -0
  13. package/dist/GoDaddyProvider-D0MQoOM4.mjs.map +1 -0
  14. package/dist/{HostingerProvider-BcyFRbqV.mjs → HostingerProvider-BNpS9aRJ.mjs} +29 -25
  15. package/dist/HostingerProvider-BNpS9aRJ.mjs.map +1 -0
  16. package/dist/{HostingerProvider-BOvsgATO.cjs → HostingerProvider-DR1iws1P.cjs} +29 -25
  17. package/dist/HostingerProvider-DR1iws1P.cjs.map +1 -0
  18. package/dist/LegacyStateStore-CRi7TosX.mjs +124 -0
  19. package/dist/LegacyStateStore-CRi7TosX.mjs.map +1 -0
  20. package/dist/LegacyStateStore-DHsoQGOo.cjs +124 -0
  21. package/dist/LegacyStateStore-DHsoQGOo.cjs.map +1 -0
  22. package/dist/LocalStateStore-BQXTkeoS.cjs +178 -0
  23. package/dist/LocalStateStore-BQXTkeoS.cjs.map +1 -0
  24. package/dist/LocalStateStore-Dkth0jXX.mjs +167 -0
  25. package/dist/LocalStateStore-Dkth0jXX.mjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-CsrukCE-.mjs +536 -0
  27. package/dist/OpenApiTsGenerator-CsrukCE-.mjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-FNhY7Ssz.cjs +541 -0
  29. package/dist/OpenApiTsGenerator-FNhY7Ssz.cjs.map +1 -0
  30. package/dist/{Route53Provider-CH9XH7bz.cjs → Route53Provider-Bllus2NR.cjs} +21 -22
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-C0xmer8U.mjs → Route53Provider-QXxjkZO1.mjs} +13 -13
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-DGKZgyKz.cjs +222 -0
  35. package/dist/S3StateStore-DGKZgyKz.cjs.map +1 -0
  36. package/dist/S3StateStore-pZZnLLBd.mjs +223 -0
  37. package/dist/S3StateStore-pZZnLLBd.mjs.map +1 -0
  38. package/dist/SSMStateStore-CZRMERDA.mjs +205 -0
  39. package/dist/SSMStateStore-CZRMERDA.mjs.map +1 -0
  40. package/dist/SSMStateStore-DzkyjQ5D.cjs +204 -0
  41. package/dist/SSMStateStore-DzkyjQ5D.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-C8CPxrCK.cjs +592 -0
  43. package/dist/SubscriberGenerator-C8CPxrCK.cjs.map +1 -0
  44. package/dist/SubscriberGenerator-y3pncae_.mjs +533 -0
  45. package/dist/SubscriberGenerator-y3pncae_.mjs.map +1 -0
  46. package/dist/add-C0kXOsWS.mjs +717 -0
  47. package/dist/add-C0kXOsWS.mjs.map +1 -0
  48. package/dist/add-Df8cmz0H.cjs +719 -0
  49. package/dist/add-Df8cmz0H.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/aws-8QQ8n-t6.mjs +89 -0
  55. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  56. package/dist/aws-DY9NqQIT.cjs +100 -0
  57. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  58. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  59. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  60. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  61. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  62. package/dist/{backup-provisioner-DXXg6FIL.mjs → backup-provisioner-C8DnCmxK.mjs} +11 -8
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-cE2PuCTb.cjs → backup-provisioner-oDEsPj02.cjs} +22 -20
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/backups/runner.cjs +519 -0
  67. package/dist/backups/runner.cjs.map +1 -0
  68. package/dist/backups/runner.d.cts +102 -0
  69. package/dist/backups/runner.d.cts.map +1 -0
  70. package/dist/backups/runner.d.mts +102 -0
  71. package/dist/backups/runner.d.mts.map +1 -0
  72. package/dist/backups/runner.mjs +506 -0
  73. package/dist/backups/runner.mjs.map +1 -0
  74. package/dist/{bundler-Bux2iF-v.mjs → bundler-B-I4Du99.mjs} +35 -16
  75. package/dist/bundler-B-I4Du99.mjs.map +1 -0
  76. package/dist/{bundler-BMekgx7a.cjs → bundler-Dx_grUmc.cjs} +37 -19
  77. package/dist/bundler-Dx_grUmc.cjs.map +1 -0
  78. package/dist/cli-Cd9exatJ.cjs +71 -0
  79. package/dist/cli-Cd9exatJ.cjs.map +1 -0
  80. package/dist/cli-DL7GxGAe.mjs +71 -0
  81. package/dist/cli-DL7GxGAe.mjs.map +1 -0
  82. package/dist/compose-C43c03WZ.mjs +3284 -0
  83. package/dist/compose-C43c03WZ.mjs.map +1 -0
  84. package/dist/compose-Mdgea4Yt.cjs +3427 -0
  85. package/dist/compose-Mdgea4Yt.cjs.map +1 -0
  86. package/dist/config-D48erO2j.d.mts +269 -0
  87. package/dist/config-D48erO2j.d.mts.map +1 -0
  88. package/dist/config-DHDtsQrB.d.cts +269 -0
  89. package/dist/config-DHDtsQrB.d.cts.map +1 -0
  90. package/dist/config.cjs +421 -11
  91. package/dist/config.cjs.map +1 -0
  92. package/dist/config.d.cts +4 -120
  93. package/dist/config.d.mts +4 -120
  94. package/dist/config.mjs +405 -4
  95. package/dist/config.mjs.map +1 -0
  96. package/dist/credentialSchemas-B67WJOOm.cjs +272 -0
  97. package/dist/credentialSchemas-B67WJOOm.cjs.map +1 -0
  98. package/dist/credentialSchemas-DDOLRCLF.mjs +237 -0
  99. package/dist/credentialSchemas-DDOLRCLF.mjs.map +1 -0
  100. package/dist/credentials-B5N5yKk6.mjs +267 -0
  101. package/dist/credentials-B5N5yKk6.mjs.map +1 -0
  102. package/dist/credentials-Zqr3QQYB.cjs +350 -0
  103. package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
  104. package/dist/databases-BPOgTn1u.mjs +522 -0
  105. package/dist/databases-BPOgTn1u.mjs.map +1 -0
  106. package/dist/databases-fOaoBInm.cjs +625 -0
  107. package/dist/databases-fOaoBInm.cjs.map +1 -0
  108. package/dist/define-6poNqm5O.mjs +106 -0
  109. package/dist/define-6poNqm5O.mjs.map +1 -0
  110. package/dist/define-crmMcXFS.cjs +153 -0
  111. package/dist/define-crmMcXFS.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +212 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +654 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +654 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +145 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  121. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  122. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  123. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  124. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  125. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  126. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  127. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  128. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  129. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  131. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  133. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  134. package/dist/deploy/sniffer-hooks.cjs +13 -7
  135. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  136. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  137. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  138. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  139. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  140. package/dist/deploy/sniffer-hooks.mjs +10 -3
  141. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  142. package/dist/deploy/sniffer-loader.cjs +16 -7
  143. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  144. package/dist/deploy/sniffer-loader.d.cts +1 -1
  145. package/dist/deploy/sniffer-loader.d.mts +1 -1
  146. package/dist/deploy/sniffer-loader.mjs +14 -3
  147. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  148. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  149. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  150. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  151. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  152. package/dist/deploy/sniffer-routes-worker.mjs +4 -4
  153. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  154. package/dist/deploy/sniffer-worker.cjs +15 -6
  155. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  156. package/dist/deploy/sniffer-worker.d.cts +1 -3
  157. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  158. package/dist/deploy/sniffer-worker.d.mts +1 -3
  159. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  160. package/dist/deploy/sniffer-worker.mjs +15 -4
  161. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  162. package/dist/deploy-BMM2hx-K.cjs +2401 -0
  163. package/dist/deploy-BMM2hx-K.cjs.map +1 -0
  164. package/dist/deploy-D5YhwDng.mjs +2328 -0
  165. package/dist/deploy-D5YhwDng.mjs.map +1 -0
  166. package/dist/derive-B4vDpzgP.mjs +150 -0
  167. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  168. package/dist/derive-DAbo49sm.cjs +161 -0
  169. package/dist/derive-DAbo49sm.cjs.map +1 -0
  170. package/dist/discover-C5roJuc9.mjs +560 -0
  171. package/dist/discover-C5roJuc9.mjs.map +1 -0
  172. package/dist/discover-CSW_BMWa.d.cts +125 -0
  173. package/dist/discover-CSW_BMWa.d.cts.map +1 -0
  174. package/dist/discover-DozUKs8f.cjs +639 -0
  175. package/dist/discover-DozUKs8f.cjs.map +1 -0
  176. package/dist/discover-xtT7fgWg.d.mts +125 -0
  177. package/dist/discover-xtT7fgWg.d.mts.map +1 -0
  178. package/dist/dns-BIYf20p7.cjs +1057 -0
  179. package/dist/dns-BIYf20p7.cjs.map +1 -0
  180. package/dist/dns-agf2VCdV.mjs +926 -0
  181. package/dist/dns-agf2VCdV.mjs.map +1 -0
  182. package/dist/dokploy-2p4PK6ej.mjs +38 -0
  183. package/dist/dokploy-2p4PK6ej.mjs.map +1 -0
  184. package/dist/dokploy-BANMTroy.cjs +38 -0
  185. package/dist/dokploy-BANMTroy.cjs.map +1 -0
  186. package/dist/drivers-BjGDYfnC.mjs +195 -0
  187. package/dist/drivers-BjGDYfnC.mjs.map +1 -0
  188. package/dist/drivers-DbjiYpW6.cjs +224 -0
  189. package/dist/drivers-DbjiYpW6.cjs.map +1 -0
  190. package/dist/eas-CNi16SoO.cjs +337 -0
  191. package/dist/eas-CNi16SoO.cjs.map +1 -0
  192. package/dist/eas-iT2JDHCh.mjs +334 -0
  193. package/dist/eas-iT2JDHCh.mjs.map +1 -0
  194. package/dist/{emit-CIlvnDvV.mjs → emit-C1e8qD08.mjs} +13 -26
  195. package/dist/emit-C1e8qD08.mjs.map +1 -0
  196. package/dist/{emit-CUD1BWls.cjs → emit-Dmc1nvdS.cjs} +31 -57
  197. package/dist/emit-Dmc1nvdS.cjs.map +1 -0
  198. package/dist/encryption-DkXVbyZc.mjs +89 -0
  199. package/dist/encryption-DkXVbyZc.mjs.map +1 -0
  200. package/dist/encryption-d2lLtkYx.cjs +90 -0
  201. package/dist/encryption-d2lLtkYx.cjs.map +1 -0
  202. package/dist/engine-CatKW6E-.mjs +3089 -0
  203. package/dist/engine-CatKW6E-.mjs.map +1 -0
  204. package/dist/engine-DlEHexED.cjs +3202 -0
  205. package/dist/engine-DlEHexED.cjs.map +1 -0
  206. package/dist/errors-D8Gwp5kU.mjs +23 -0
  207. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  208. package/dist/errors-DMC4Umsb.cjs +34 -0
  209. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  210. package/dist/github-BAeaC1Pl.cjs +833 -0
  211. package/dist/github-BAeaC1Pl.cjs.map +1 -0
  212. package/dist/github-DErsqKGN.mjs +832 -0
  213. package/dist/github-DErsqKGN.mjs.map +1 -0
  214. package/dist/googlePlay-BVcfFWRO.cjs +931 -0
  215. package/dist/googlePlay-BVcfFWRO.cjs.map +1 -0
  216. package/dist/googlePlay-BXJ5ZjMK.mjs +931 -0
  217. package/dist/googlePlay-BXJ5ZjMK.mjs.map +1 -0
  218. package/dist/identity-CBXr4wNi.mjs +129 -0
  219. package/dist/identity-CBXr4wNi.mjs.map +1 -0
  220. package/dist/identity-CbLfgQNT.cjs +182 -0
  221. package/dist/identity-CbLfgQNT.cjs.map +1 -0
  222. package/dist/{index-BzJ7QJ9c.d.mts → index-8OfpOtSI.d.cts} +39 -20
  223. package/dist/index-8OfpOtSI.d.cts.map +1 -0
  224. package/dist/{index-CfMjtdVC.d.cts → index-Dpji6Bxq.d.mts} +39 -20
  225. package/dist/index-Dpji6Bxq.d.mts.map +1 -0
  226. package/dist/index.cjs +14291 -11898
  227. package/dist/index.cjs.map +1 -1
  228. package/dist/index.d.cts +1 -1
  229. package/dist/index.d.mts +1 -1
  230. package/dist/index.mjs +13938 -11560
  231. package/dist/index.mjs.map +1 -1
  232. package/dist/local-BwC2v2Y8.mjs +224 -0
  233. package/dist/local-BwC2v2Y8.mjs.map +1 -0
  234. package/dist/local-DNhnkugT.cjs +241 -0
  235. package/dist/local-DNhnkugT.cjs.map +1 -0
  236. package/dist/migrate-Bb1MmGHl.mjs +181 -0
  237. package/dist/migrate-Bb1MmGHl.mjs.map +1 -0
  238. package/dist/migrate-D79GI0XM.cjs +271 -0
  239. package/dist/migrate-D79GI0XM.cjs.map +1 -0
  240. package/dist/migrate-L4a273dY.cjs +181 -0
  241. package/dist/migrate-L4a273dY.cjs.map +1 -0
  242. package/dist/migrate-s4QizIoM.mjs +266 -0
  243. package/dist/migrate-s4QizIoM.mjs.map +1 -0
  244. package/dist/openapi.cjs +214 -10
  245. package/dist/openapi.cjs.map +1 -0
  246. package/dist/openapi.d.cts +38 -17
  247. package/dist/openapi.d.cts.map +1 -1
  248. package/dist/openapi.d.mts +38 -17
  249. package/dist/openapi.d.mts.map +1 -1
  250. package/dist/openapi.mjs +208 -5
  251. package/dist/openapi.mjs.map +1 -0
  252. package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
  253. package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
  254. package/dist/projectBucket-C_DN4WzF.mjs +222 -0
  255. package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
  256. package/dist/provider-BqpjG9QM.cjs +57 -0
  257. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  258. package/dist/provider-CEOKk8NS.mjs +46 -0
  259. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  260. package/dist/publish-CcTlmJT6.mjs +123 -0
  261. package/dist/publish-CcTlmJT6.mjs.map +1 -0
  262. package/dist/publish-ydscCYsW.cjs +124 -0
  263. package/dist/publish-ydscCYsW.cjs.map +1 -0
  264. package/dist/ready-BFFP838V.cjs +404 -0
  265. package/dist/ready-BFFP838V.cjs.map +1 -0
  266. package/dist/ready-BOfogqzr.mjs +375 -0
  267. package/dist/ready-BOfogqzr.mjs.map +1 -0
  268. package/dist/reconcile/public.cjs +3 -5
  269. package/dist/reconcile/public.d.cts +11 -87
  270. package/dist/reconcile/public.d.cts.map +1 -1
  271. package/dist/reconcile/public.d.mts +11 -87
  272. package/dist/reconcile/public.d.mts.map +1 -1
  273. package/dist/reconcile/public.mjs +3 -4
  274. package/dist/{reconcile-BI0tWkwz.mjs → reconcile--I7V4Klj.mjs} +4 -7
  275. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  276. package/dist/{reconcile-Bhw5fmKu.cjs → reconcile-CuCQBa5-.cjs} +5 -8
  277. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  278. package/dist/resolve-BLp2trep.mjs +263 -0
  279. package/dist/resolve-BLp2trep.mjs.map +1 -0
  280. package/dist/resolve-BgL-brF9.cjs +316 -0
  281. package/dist/resolve-BgL-brF9.cjs.map +1 -0
  282. package/dist/rollback-2cyLXEH1.cjs +165 -0
  283. package/dist/rollback-2cyLXEH1.cjs.map +1 -0
  284. package/dist/rollback-DwqZ8zzj.mjs +136 -0
  285. package/dist/rollback-DwqZ8zzj.mjs.map +1 -0
  286. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  287. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  288. package/dist/run-BJLIerMM.mjs +133 -0
  289. package/dist/run-BJLIerMM.mjs.map +1 -0
  290. package/dist/run-fVZ-rLnc.cjs +174 -0
  291. package/dist/run-fVZ-rLnc.cjs.map +1 -0
  292. package/dist/runtime-ACdfK59n.d.cts +82 -0
  293. package/dist/runtime-ACdfK59n.d.cts.map +1 -0
  294. package/dist/runtime-YyQuekxi.d.mts +82 -0
  295. package/dist/runtime-YyQuekxi.d.mts.map +1 -0
  296. package/dist/s3-CrPoA89T.cjs +215 -0
  297. package/dist/s3-CrPoA89T.cjs.map +1 -0
  298. package/dist/s3-DQXZdmCM.mjs +215 -0
  299. package/dist/s3-DQXZdmCM.mjs.map +1 -0
  300. package/dist/sandbox/config-worker.cjs +43 -0
  301. package/dist/sandbox/config-worker.cjs.map +1 -0
  302. package/dist/sandbox/config-worker.d.cts +1 -0
  303. package/dist/sandbox/config-worker.d.mts +1 -0
  304. package/dist/sandbox/config-worker.mjs +44 -0
  305. package/dist/sandbox/config-worker.mjs.map +1 -0
  306. package/dist/sandbox/credentials-worker.cjs +54 -0
  307. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  308. package/dist/sandbox/credentials-worker.d.cts +1 -0
  309. package/dist/sandbox/credentials-worker.d.mts +1 -0
  310. package/dist/sandbox/credentials-worker.mjs +55 -0
  311. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  312. package/dist/sandbox/discover-worker.cjs +50 -0
  313. package/dist/sandbox/discover-worker.cjs.map +1 -0
  314. package/dist/sandbox/discover-worker.d.cts +1 -0
  315. package/dist/sandbox/discover-worker.d.mts +1 -0
  316. package/dist/sandbox/discover-worker.mjs +51 -0
  317. package/dist/sandbox/discover-worker.mjs.map +1 -0
  318. package/dist/sandbox/migrate-worker.cjs +75 -0
  319. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  320. package/dist/sandbox/migrate-worker.d.cts +1 -0
  321. package/dist/sandbox/migrate-worker.d.mts +1 -0
  322. package/dist/sandbox/migrate-worker.mjs +76 -0
  323. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  324. package/dist/sandbox-C4g1eG31.d.mts +104 -0
  325. package/dist/sandbox-C4g1eG31.d.mts.map +1 -0
  326. package/dist/sandbox-CHv3OYXg.cjs +165 -0
  327. package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
  328. package/dist/sandbox-CbVB7uOD.mjs +118 -0
  329. package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
  330. package/dist/sandbox-CdKgQ3XU.d.cts +104 -0
  331. package/dist/sandbox-CdKgQ3XU.d.cts.map +1 -0
  332. package/dist/{workspace-DPV7FtAv.cjs → schemas-BCwKKA42.mjs} +958 -1816
  333. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  334. package/dist/{workspace-CtnZnWsa.mjs → schemas-BQ_v0lEX.cjs} +1048 -1626
  335. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  336. package/dist/secretsManager-CQORubp9.mjs +97 -0
  337. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  338. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  339. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  340. package/dist/seeds-C2w4UqVP.cjs +9347 -0
  341. package/dist/seeds-C2w4UqVP.cjs.map +1 -0
  342. package/dist/seeds-Cwtv-U9-.mjs +8350 -0
  343. package/dist/seeds-Cwtv-U9-.mjs.map +1 -0
  344. package/dist/serverSetup-BdFOD93s.cjs +631 -0
  345. package/dist/serverSetup-BdFOD93s.cjs.map +1 -0
  346. package/dist/serverSetup-utKsoyGH.mjs +631 -0
  347. package/dist/serverSetup-utKsoyGH.mjs.map +1 -0
  348. package/dist/sniffer-8C4q6Szd.mjs +1825 -0
  349. package/dist/sniffer-8C4q6Szd.mjs.map +1 -0
  350. package/dist/sniffer-CF7wNxMo.cjs +1998 -0
  351. package/dist/sniffer-CF7wNxMo.cjs.map +1 -0
  352. package/dist/sst-B-Uz4cvm.cjs +464 -0
  353. package/dist/sst-B-Uz4cvm.cjs.map +1 -0
  354. package/dist/sst-C1pxbFEd.mjs +441 -0
  355. package/dist/sst-C1pxbFEd.mjs.map +1 -0
  356. package/dist/stage-BvM_u2z4.mjs +302 -0
  357. package/dist/stage-BvM_u2z4.mjs.map +1 -0
  358. package/dist/stage-DEQJGW3r.cjs +313 -0
  359. package/dist/stage-DEQJGW3r.cjs.map +1 -0
  360. package/dist/stages-Cb9rqRbN.mjs +190 -0
  361. package/dist/stages-Cb9rqRbN.mjs.map +1 -0
  362. package/dist/stages-D4SnG5yl.cjs +190 -0
  363. package/dist/stages-D4SnG5yl.cjs.map +1 -0
  364. package/dist/target/public.cjs +15 -0
  365. package/dist/target/public.d.cts +28 -0
  366. package/dist/target/public.d.cts.map +1 -0
  367. package/dist/target/public.d.mts +28 -0
  368. package/dist/target/public.d.mts.map +1 -0
  369. package/dist/target/public.mjs +4 -0
  370. package/dist/terminal-CW_dWeTe.mjs +85 -0
  371. package/dist/terminal-CW_dWeTe.mjs.map +1 -0
  372. package/dist/terminal-DJlqcW_U.cjs +85 -0
  373. package/dist/terminal-DJlqcW_U.cjs.map +1 -0
  374. package/dist/types-B6UXlEkf.d.cts +7650 -0
  375. package/dist/types-B6UXlEkf.d.cts.map +1 -0
  376. package/dist/types-HqVPddRK.d.mts +7649 -0
  377. package/dist/types-HqVPddRK.d.mts.map +1 -0
  378. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  379. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  380. package/dist/utils-D_fxUqvU.mjs +156 -0
  381. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  382. package/dist/vitest.cjs +65 -0
  383. package/dist/vitest.cjs.map +1 -0
  384. package/dist/vitest.d.cts +29 -0
  385. package/dist/vitest.d.cts.map +1 -0
  386. package/dist/vitest.d.mts +29 -0
  387. package/dist/vitest.d.mts.map +1 -0
  388. package/dist/vitest.mjs +65 -0
  389. package/dist/vitest.mjs.map +1 -0
  390. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  391. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  392. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  393. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  394. package/dist/workspace/index.cjs +8 -4
  395. package/dist/workspace/index.d.cts +3 -3
  396. package/dist/workspace/index.d.mts +3 -3
  397. package/dist/workspace/index.mjs +2 -3
  398. package/dist/workspace-BwqQnool.cjs +2806 -0
  399. package/dist/workspace-BwqQnool.cjs.map +1 -0
  400. package/dist/workspace-D1QbNd55.mjs +2394 -0
  401. package/dist/workspace-D1QbNd55.mjs.map +1 -0
  402. package/package.json +54 -22
  403. package/dist/CachedStateProvider-BEBl2wQT.cjs +0 -60
  404. package/dist/CachedStateProvider-BEBl2wQT.cjs.map +0 -1
  405. package/dist/CachedStateProvider-C-8wtlto.mjs +0 -3
  406. package/dist/CachedStateProvider-Co4n5Wvs.mjs +0 -54
  407. package/dist/CachedStateProvider-Co4n5Wvs.mjs.map +0 -1
  408. package/dist/CachedStateProvider-DqhGpzsm.cjs +0 -3
  409. package/dist/HostingerProvider-BOvsgATO.cjs.map +0 -1
  410. package/dist/HostingerProvider-BcyFRbqV.mjs.map +0 -1
  411. package/dist/LocalStateProvider-Bq-0C0sg.mjs +0 -42
  412. package/dist/LocalStateProvider-Bq-0C0sg.mjs.map +0 -1
  413. package/dist/LocalStateProvider-yjXZXZDM.cjs +0 -43
  414. package/dist/LocalStateProvider-yjXZXZDM.cjs.map +0 -1
  415. package/dist/Route53Provider-C0xmer8U.mjs.map +0 -1
  416. package/dist/Route53Provider-CH9XH7bz.cjs.map +0 -1
  417. package/dist/SSMStateProvider-CXtNgPfy.cjs +0 -66
  418. package/dist/SSMStateProvider-CXtNgPfy.cjs.map +0 -1
  419. package/dist/SSMStateProvider-DOZifZfE.mjs +0 -66
  420. package/dist/SSMStateProvider-DOZifZfE.mjs.map +0 -1
  421. package/dist/backup-provisioner-DXXg6FIL.mjs.map +0 -1
  422. package/dist/backup-provisioner-cE2PuCTb.cjs.map +0 -1
  423. package/dist/bundler-BMekgx7a.cjs.map +0 -1
  424. package/dist/bundler-Bux2iF-v.mjs.map +0 -1
  425. package/dist/chunk-Duj1WY3L.mjs +0 -7
  426. package/dist/config-DTsVjKZD.mjs +0 -402
  427. package/dist/config-DTsVjKZD.mjs.map +0 -1
  428. package/dist/config-RYR9j6EF.cjs +0 -462
  429. package/dist/config-RYR9j6EF.cjs.map +0 -1
  430. package/dist/config.d.cts.map +0 -1
  431. package/dist/config.d.mts.map +0 -1
  432. package/dist/credentials-B5zRHdAl.mjs +0 -141
  433. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  434. package/dist/credentials-BapzjyV5.cjs +0 -195
  435. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  436. package/dist/credentials-DQRvPz2S.cjs +0 -2769
  437. package/dist/credentials-DQRvPz2S.cjs.map +0 -1
  438. package/dist/credentials-jMJC63qs.mjs +0 -2625
  439. package/dist/credentials-jMJC63qs.mjs.map +0 -1
  440. package/dist/discover-BYHQwQqu.mjs +0 -242
  441. package/dist/discover-BYHQwQqu.mjs.map +0 -1
  442. package/dist/discover-DmW9Bscc.cjs +0 -290
  443. package/dist/discover-DmW9Bscc.cjs.map +0 -1
  444. package/dist/dokploy-api-5cK2InBm.cjs +0 -3
  445. package/dist/dokploy-api-D2Ny4Jrc.mjs +0 -3
  446. package/dist/dokploy-api-pdaBryoY.mjs +0 -706
  447. package/dist/dokploy-api-pdaBryoY.mjs.map +0 -1
  448. package/dist/dokploy-api-zqKe9lHH.cjs +0 -718
  449. package/dist/dokploy-api-zqKe9lHH.cjs.map +0 -1
  450. package/dist/emit-CIlvnDvV.mjs.map +0 -1
  451. package/dist/emit-CUD1BWls.cjs.map +0 -1
  452. package/dist/encryption-D2pL3tHH.cjs +0 -54
  453. package/dist/encryption-D2pL3tHH.cjs.map +0 -1
  454. package/dist/encryption-YDsXXi6w.mjs +0 -3
  455. package/dist/encryption-_4zwjOAR.mjs +0 -42
  456. package/dist/encryption-_4zwjOAR.mjs.map +0 -1
  457. package/dist/encryption-sQ2Oxx0d.cjs +0 -4
  458. package/dist/fullstack-secrets-B6KBHf-g.mjs +0 -87
  459. package/dist/fullstack-secrets-B6KBHf-g.mjs.map +0 -1
  460. package/dist/fullstack-secrets-DL8v0y4D.cjs +0 -99
  461. package/dist/fullstack-secrets-DL8v0y4D.cjs.map +0 -1
  462. package/dist/generator-CNzBw7g5.cjs +0 -289
  463. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  464. package/dist/generator-VE2JrFlY.mjs +0 -253
  465. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  466. package/dist/github-BThvbf2W.cjs +0 -197
  467. package/dist/github-BThvbf2W.cjs.map +0 -1
  468. package/dist/github-DpMZurEK.mjs +0 -196
  469. package/dist/github-DpMZurEK.mjs.map +0 -1
  470. package/dist/index-BzJ7QJ9c.d.mts.map +0 -1
  471. package/dist/index-CfMjtdVC.d.cts.map +0 -1
  472. package/dist/keystore-C9rint2E.cjs +0 -101
  473. package/dist/keystore-C9rint2E.cjs.map +0 -1
  474. package/dist/keystore-TxeYM7an.mjs +0 -83
  475. package/dist/keystore-TxeYM7an.mjs.map +0 -1
  476. package/dist/openapi-Bs3-5q_r.mjs +0 -2021
  477. package/dist/openapi-Bs3-5q_r.mjs.map +0 -1
  478. package/dist/openapi-DWLTsYLL.cjs +0 -2075
  479. package/dist/openapi-DWLTsYLL.cjs.map +0 -1
  480. package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
  481. package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
  482. package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
  483. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
  484. package/dist/openapi-react-query.cjs +0 -4
  485. package/dist/openapi-react-query.d.cts +0 -11
  486. package/dist/openapi-react-query.d.cts.map +0 -1
  487. package/dist/openapi-react-query.d.mts +0 -11
  488. package/dist/openapi-react-query.d.mts.map +0 -1
  489. package/dist/openapi-react-query.mjs +0 -4
  490. package/dist/reconcile-BI0tWkwz.mjs.map +0 -1
  491. package/dist/reconcile-Bhw5fmKu.cjs.map +0 -1
  492. package/dist/setup-BmLoNrDX.mjs +0 -12
  493. package/dist/setup-BrR1_xGy.cjs +0 -12
  494. package/dist/setup-BsNR2LBG.cjs +0 -467
  495. package/dist/setup-BsNR2LBG.cjs.map +0 -1
  496. package/dist/setup-D5-JMknk.mjs +0 -437
  497. package/dist/setup-D5-JMknk.mjs.map +0 -1
  498. package/dist/storage-B020InPW.mjs +0 -222
  499. package/dist/storage-B020InPW.mjs.map +0 -1
  500. package/dist/storage-CSNplaJn.cjs +0 -282
  501. package/dist/storage-CSNplaJn.cjs.map +0 -1
  502. package/dist/storage-DGBzMLZa.mjs +0 -4
  503. package/dist/storage-DlVol_oj.cjs +0 -8
  504. package/dist/sync-0ILCb-1S.cjs +0 -93
  505. package/dist/sync-0ILCb-1S.cjs.map +0 -1
  506. package/dist/sync-CzHXiR9c.mjs +0 -76
  507. package/dist/sync-CzHXiR9c.mjs.map +0 -1
  508. package/dist/sync-DYENfOt4.cjs +0 -4
  509. package/dist/sync-HAau6h_R.mjs +0 -3
  510. package/dist/types-DVIx8I1N.d.mts +0 -1950
  511. package/dist/types-DVIx8I1N.d.mts.map +0 -1
  512. package/dist/types-PMP_qXRY.d.cts +0 -1950
  513. package/dist/types-PMP_qXRY.d.cts.map +0 -1
  514. package/dist/workspace-Cji6lE8E.cjs +0 -10
  515. package/dist/workspace-CkJAtRIX.mjs +0 -9
  516. package/dist/workspace-CtnZnWsa.mjs.map +0 -1
  517. package/dist/workspace-DPV7FtAv.cjs.map +0 -1
@@ -1,2625 +0,0 @@
1
- import { DEFAULT_CACHE, DEFAULT_EVENTS, DEFAULT_STORAGE, discover } from "./discover-BYHQwQqu.mjs";
2
- import { appKey, getAppNameFromCwd, hostOf, loadWorkspaceAppInfo } from "./config-DTsVjKZD.mjs";
3
- import { allConstructGlobs, getDependencyEnvVars } from "./workspace-CtnZnWsa.mjs";
4
- import { generatePgBossUrl } from "./generator-VE2JrFlY.mjs";
5
- import { readStageSecrets, secretsExist, toEmbeddableSecrets } from "./storage-B020InPW.mjs";
6
- import { existsSync, readFileSync } from "node:fs";
7
- import { dirname, join, resolve } from "node:path";
8
- import { DEFAULT_POSTGRES_VERSION, cacheTable, cookieDomain, dependentsOf, provideKey, providedKeyFor, provisionOrder, publicEnvFor } from "@geekmidas/manifest";
9
- import { mkdir, readFile, writeFile } from "node:fs/promises";
10
- import { execFile, execSync } from "node:child_process";
11
- import { createServer } from "node:net";
12
- import { config } from "dotenv";
13
- import { parse as parse$1, stringify } from "yaml";
14
- import { createHash } from "node:crypto";
15
- import { ownerRole, readerRole, roleStatements } from "@geekmidas/db/pg/roles";
16
- import { CreateBucketCommand, GetBucketPolicyCommand, HeadBucketCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
17
- import { Client } from "pg";
18
- import { promisify } from "node:util";
19
- import { cacheTableStatements } from "@geekmidas/cache/postgres";
20
-
21
- //#region src/workspace/backends.ts
22
- /**
23
- * Which family of defaults a workspace's deploy target belongs to.
24
- *
25
- * One question, asked once: **does this target run containers the project
26
- * controls?** Dokploy and a bare server do, so a bucket or a cache can live
27
- * beside the app; AWS, Vercel and Cloudflare do not, so the default has to be
28
- * something managed. That is the whole of the distinction, and it is why
29
- * `MainProvider` is the right axis rather than the deploy target's own name —
30
- * three targets share one answer.
31
- *
32
- * An AWS deploy names no `deploy.default` at all, because it goes through SST,
33
- * which is why the absence is what selects `aws`.
34
- */
35
- function providerOf(workspace) {
36
- const target = workspace.deploy?.default;
37
- return target === "dokploy" || target === "server" ? "server" : "aws";
38
- }
39
- /**
40
- * The cache backend a target implies.
41
- *
42
- * The same answer locally and deployed: a local `gkm dev` for an AWS app still
43
- * uses the Upstash protocol, because a backend that differed between the two
44
- * would be worse than a slower one.
45
- */
46
- function cacheBackendFor(on) {
47
- return DEFAULT_CACHE[on];
48
- }
49
- /** Where a declared bucket lives on a target. */
50
- function storageBackendFor(on) {
51
- return DEFAULT_STORAGE[on];
52
- }
53
- /**
54
- * Which broker carries declared queues and topics on a target.
55
- *
56
- * Only consulted when something declares one; a project with no `Topic` or
57
- * `Queue` has no events at all, whatever the target.
58
- */
59
- function eventsBackendFor(on) {
60
- return DEFAULT_EVENTS[on];
61
- }
62
-
63
- //#endregion
64
- //#region src/reconcile/containers.ts
65
- /**
66
- * What gkm knows about each container it can derive.
67
- *
68
- * Everything provider-specific about the local target lives here: the image, the
69
- * ports the image listens on, and whether its data is worth keeping. The plan
70
- * says *which* containers exist and never says any of this, which is the split
71
- * the design asks for — neutral facts from the declaration, provider detail
72
- * from here and from config.
73
- *
74
- * Shared by allocation and by the compose writer so the two cannot disagree
75
- * about how many ports a container needs.
76
- */
77
- /**
78
- * The Postgres image for a major version.
79
- *
80
- * One place that knows the tag shape, so a declared version reaches the
81
- * container without anyone restating `-alpine` beside it.
82
- */
83
- function postgresImage(version) {
84
- return `postgres:${version}-alpine`;
85
- }
86
- /**
87
- * The default image for each container.
88
- *
89
- * Pinned to a major rather than `latest` where the image publishes one, so a
90
- * rebuild does not silently move a developer's Postgres a version. Overridable
91
- * per project: a project needing `postgis/postgis` says so in config.
92
- */
93
- const DEFAULT_IMAGES = {
94
- postgres: postgresImage(DEFAULT_POSTGRES_VERSION),
95
- minio: "pgsty/minio:RELEASE.2026-08-04T00-00-00Z",
96
- mailpit: "axllent/mailpit:latest",
97
- redis: "redis:8-alpine",
98
- "redis-http": "hiett/serverless-redis-http:latest",
99
- rabbitmq: "rabbitmq:4-management-alpine",
100
- localstack: "floci/floci:latest",
101
- caddy: "caddy:2-alpine"
102
- };
103
- /**
104
- * The ports each container listens on.
105
- *
106
- * The first is always the one an app connects to; the rest are consoles and
107
- * management UIs, published because a bucket or an inbox you can look at is most
108
- * of why these are real containers rather than stubs.
109
- */
110
- const PORTS = {
111
- postgres: [{
112
- key: "postgres",
113
- inside: 5432,
114
- label: "postgres"
115
- }],
116
- minio: [{
117
- key: "minio",
118
- inside: 9e3,
119
- label: "minio api"
120
- }, {
121
- key: "minio-console",
122
- inside: 9001,
123
- label: "minio console"
124
- }],
125
- mailpit: [{
126
- key: "mailpit",
127
- inside: 1025,
128
- label: "smtp"
129
- }, {
130
- key: "mailpit-web",
131
- inside: 8025,
132
- label: "mailpit inbox"
133
- }],
134
- redis: [{
135
- key: "redis",
136
- inside: 6379,
137
- label: "redis"
138
- }],
139
- "redis-http": [{
140
- key: "redis-http",
141
- inside: 80,
142
- label: "cache"
143
- }],
144
- rabbitmq: [{
145
- key: "rabbitmq",
146
- inside: 5672,
147
- label: "amqp"
148
- }, {
149
- key: "rabbitmq-management",
150
- inside: 15672,
151
- label: "rabbitmq console"
152
- }],
153
- localstack: [{
154
- key: "localstack",
155
- inside: 4566,
156
- label: "localstack"
157
- }],
158
- caddy: [{
159
- key: "caddy",
160
- inside: 443,
161
- label: "https edge"
162
- }]
163
- };
164
- /** The ports a container needs published. Empty for one gkm does not know. */
165
- function portsOf(container) {
166
- return PORTS[container] ?? [];
167
- }
168
- /** The key a container's primary port is allocated under. */
169
- function primaryPortKey(container) {
170
- return portsOf(container)[0]?.key ?? container;
171
- }
172
- /**
173
- * Every port key a set of containers needs, in a stable order.
174
- *
175
- * What allocation is handed: it assigns ports to names and knows nothing about
176
- * what listens on them.
177
- */
178
- function portKeys(containers) {
179
- return [...containers].sort().flatMap((container) => portsOf(container).map((port) => port.key));
180
- }
181
- /**
182
- * The named volume a container's data lives in.
183
- *
184
- * Mailpit deliberately has none: local mail is disposable, and an inbox that
185
- * survives days of dev is noise rather than state.
186
- */
187
- function volumeOf(container) {
188
- const volumes = {
189
- postgres: "postgres-data",
190
- minio: "minio-data",
191
- redis: "redis-data",
192
- rabbitmq: "rabbitmq-data",
193
- localstack: "localstack-data",
194
- caddy: "caddy-data"
195
- };
196
- return volumes[container];
197
- }
198
-
199
- //#endregion
200
- //#region src/reconcile/caddyfile.ts
201
- /**
202
- * The kinds the edge serves.
203
- *
204
- * Everything that owns a *public address*. Deployed, each of these has a real
205
- * hostname and a certificate, so this is what makes the local shape the same
206
- * one rather than a near-enough one — and the application is indifferent
207
- * either way, because it reads whichever address was injected and never
208
- * composes one.
209
- *
210
- * Adding a kind here is the whole of adding it to the edge.
211
- */
212
- const EDGE_KINDS = {
213
- "file-server": true,
214
- "rest-api": true,
215
- site: true
216
- };
217
- /**
218
- * How the edge reaches the host, from inside its container.
219
- *
220
- * A surface and a site are served by processes `gkm dev` starts on the host,
221
- * not by containers — so the edge has to leave Docker's network to reach them.
222
- * Docker Desktop resolves this name already; on Linux the compose definition
223
- * maps it to the host gateway.
224
- */
225
- const HOST_GATEWAY = "host.docker.internal";
226
- /**
227
- * The suffix every local host shares.
228
- *
229
- * `.localhost` rather than a made-up TLD because it resolves to loopback
230
- * without touching `/etc/hosts` — macOS and systemd-resolved both answer for
231
- * subdomains of it, and Caddy issues internal certificates for it by default.
232
- */
233
- const LOCAL_TLD = "localhost";
234
- /**
235
- * The sites a plan implies, one per file server.
236
- *
237
- * The leading label is the *server's* stage-scoped name rather than the
238
- * bucket's, which is the difference that matters: two servers over one bucket
239
- * are a legitimate arrangement — two cache behaviours, one origin — and naming
240
- * the host after the bucket would make them collide.
241
- */
242
- function sitesFor(plan, project, addresses = {}) {
243
- const byId = new Map(plan.resources.map((r) => [r.id, r]));
244
- const sites = [];
245
- for (const resource of plan.resources) {
246
- if (!EDGE_KINDS[resource.kind]) continue;
247
- const host = hostFor(resource, project);
248
- if (resource.kind === "file-server") {
249
- const origin = resource.of ? byId.get(resource.of) : void 0;
250
- if (!origin) continue;
251
- sites.push({
252
- host,
253
- upstream: "http://minio:9000",
254
- rewrite: `/${origin.name}{uri}`
255
- });
256
- continue;
257
- }
258
- const address = addresses[resource.id];
259
- if (!address) continue;
260
- const port = portOf(address);
261
- if (!port) continue;
262
- sites.push({
263
- host,
264
- upstream: `http://${HOST_GATEWAY}:${port}`
265
- });
266
- }
267
- return sites;
268
- }
269
- /** The port a local address answers on, defaulting by scheme. */
270
- function portOf(address) {
271
- try {
272
- const { port, protocol } = new URL(address);
273
- return port || (protocol === "https:" ? "443" : "80");
274
- } catch {
275
- return void 0;
276
- }
277
- }
278
- /**
279
- * Where one file server answers, including the stage its name carries.
280
- *
281
- * The project is a label rather than a decoration: it is what keeps two
282
- * checkouts from answering on one address. Omitted when there is no project to
283
- * name, because an empty label makes `uploads..localhost` — a host nothing
284
- * resolves and no certificate can be issued for.
285
- */
286
- function hostFor(resource, project) {
287
- return [
288
- resource.name,
289
- project,
290
- LOCAL_TLD
291
- ].filter(Boolean).join(".");
292
- }
293
- /**
294
- * The static root config, which only ever imports.
295
- *
296
- * Written once and identical for every stage, because the *sites* are what
297
- * differ and they live in their own files. That split is not tidiness: one
298
- * container serves every stage — the same way one Postgres holds `orders` and
299
- * `orders_test` — so a single Caddyfile would mean `gkm test` deleting the
300
- * routes `gkm dev` is serving, and each command silently breaking the other.
301
- */
302
- function caddyfileRoot() {
303
- return `${GENERATED}
304
- {
305
- # No ACME, no public DNS: the CA is local and so are the names.
306
- local_certs
307
- auto_https disable_redirects
308
- }
309
-
310
- # One file per stage, so two stages share this edge the way they already share
311
- # one Postgres and one MinIO.
312
- import /etc/caddy/sites/*.caddy
313
- `;
314
- }
315
- /**
316
- * One stage's sites, as the file imported above.
317
- *
318
- * `rewrite` rather than a path prefix on the address: the bucket is the
319
- * origin's business, and the client asks for the key it stored.
320
- *
321
- * `header_up Host {upstream_hostport}` matters more than it looks. MinIO routes
322
- * and signs on the Host header, so forwarding the requested hostname would make
323
- * it look for a bucket named after the domain.
324
- */
325
- function toCaddyfile(sites) {
326
- if (sites.length === 0) return `${GENERATED}
327
- # No file server is declared in this stage, so it routes nothing.
328
- `;
329
- const blocks = sites.map(({ host, upstream, rewrite }) => `
330
- https://${host} {
331
- tls internal
332
-
333
- reverse_proxy ${upstream} {${rewrite ? `
334
- rewrite ${rewrite}
335
- # MinIO routes and signs on the Host header, so forwarding the requested
336
- # hostname would make it look for a bucket named after the domain.
337
- header_up Host {upstream_hostport}` : `
338
- # The application reads whatever address was injected, so it has to see
339
- # the one a caller used — that is what makes a redirect, a cookie domain
340
- # and a generated link point back here rather than at the upstream.
341
- header_up Host {host}
342
- header_up X-Forwarded-Proto {scheme}`}
343
- }
344
- }`);
345
- return `${GENERATED}${blocks.join("\n")}\n`;
346
- }
347
- const GENERATED = `# Generated by gkm from the construct manifest — do not edit.
348
- #
349
- # One host per declared file server, in front of the object store that holds its
350
- # objects. This is the shape a file server has deployed — a domain serving a
351
- # bucket — which MinIO alone cannot produce: its virtual-host mode reads the
352
- # leading label as the bucket name.
353
- #
354
- # Certificates come from Caddy's own CA. "gkm dev" and "gkm test" export its
355
- # root and point Node at it, so nothing has to be installed to use these URLs
356
- # from code; a browser needs the root trusted once.
357
- `;
358
-
359
- //#endregion
360
- //#region src/reconcile/plan.ts
361
- /**
362
- * Which container serves a kind.
363
- *
364
- * Derived kinds map to the same container as their parent — a schema tenant
365
- * lives in its parent's Postgres — so the set is deduplicated rather than
366
- * counted.
367
- */
368
- const CONTAINERS = {
369
- database: "postgres",
370
- "database-reader": "postgres",
371
- "database-schema": "postgres",
372
- objects: "minio",
373
- "file-server": "caddy",
374
- email: "mailpit"
375
- };
376
- /**
377
- * The container a cache backend needs locally.
378
- *
379
- * Each one matches the protocol its deployed form speaks, which is the property
380
- * worth having: a cache that behaves differently in the two places is worse than
381
- * a slower one.
382
- *
383
- * `db` is deliberately absent, the same way `pgboss` is absent from
384
- * `EVENT_CONTAINERS`: the cache is a table in a database the manifest already
385
- * declares, so mapping it here would start a container for a project that needs
386
- * none.
387
- */
388
- const CACHE_CONTAINERS = {
389
- upstash: "redis-http",
390
- elasticache: "redis"
391
- };
392
- /**
393
- * Kinds that resolve a value without anything running.
394
- *
395
- * A secret is the case: it has no address, so there is nothing to start and
396
- * nothing to connect to — but it still appears in the plan, because the target
397
- * still has to resolve it.
398
- */
399
- const CONTAINERLESS = {
400
- secret: true,
401
- credential: true,
402
- "rest-api": true,
403
- site: true
404
- };
405
- /**
406
- * Containers that cannot run alone.
407
- *
408
- * The one case is the cache: `serverless-redis-http` is a proxy and needs the
409
- * Redis it proxies. Kept here rather than in the compose definition so the plan
410
- * -- which is what decides what must be running -- still names everything.
411
- */
412
- const REQUIRES = { "redis-http": ["redis"] };
413
- /**
414
- * The role each kind's one key plays, where it is not a URL.
415
- *
416
- * The twin of `ProvidesByKind` in `@geekmidas/manifest`: that is what a
417
- * construct declares, this is what the local target resolves, and both derive
418
- * the key from the same `provideKey` so they cannot disagree.
419
- */
420
- const ROLES = {
421
- queue: "publisherConnectionString",
422
- topic: "publisherConnectionString",
423
- credential: "credential"
424
- };
425
- /** The kinds whose container is the events backend's rather than their own. */
426
- const EVENT_KINDS = {
427
- queue: true,
428
- topic: true
429
- };
430
- /**
431
- * Which kinds provision something *inside* their container.
432
- *
433
- * A database creates a database, a bucket creates a bucket; mail creates
434
- * nothing — Mailpit accepts whatever is sent to it and has no per-stage object
435
- * to name. Both still appear in the plan, because both still resolve a URL; the
436
- * flag is the difference between "must be running" and "must be created".
437
- */
438
- const PROVISIONS = {
439
- database: true,
440
- "database-reader": true,
441
- "database-schema": true,
442
- objects: true,
443
- cache: true,
444
- "file-server": true
445
- };
446
- /**
447
- * The container each events backend needs, where it needs one of its own.
448
- *
449
- * `pgboss` is deliberately absent rather than mapped to `postgres`: it is a
450
- * schema tenant in a database the manifest already declares, so mapping it here
451
- * would start a Postgres for a project that declared no database at all.
452
- *
453
- * This one comes from config rather than from a declaration because there are
454
- * no `topic` or `queue` kinds yet. When they land the mapping moves to
455
- * {@link CONTAINERS} keyed by kind, and this constant goes with them.
456
- */
457
- const EVENT_CONTAINERS = {
458
- sns: "localstack",
459
- rabbitmq: "rabbitmq"
460
- };
461
- /** The backend a project gets when it declares queues or topics and says nothing. */
462
- const DEFAULT_EVENTS$1 = "pgboss";
463
- /**
464
- * How a resource of each kind separates its stage suffix.
465
- *
466
- * Postgres identifiers are snake_case and a hyphen would need quoting
467
- * everywhere; buckets and queues are kebab and disallow underscores in some
468
- * providers. The suffix is the same word either way.
469
- */
470
- const SEPARATORS = {
471
- database: "_",
472
- "database-reader": "_",
473
- "database-schema": "_",
474
- objects: "-"
475
- };
476
- /**
477
- * The stage-scoped name for a resource.
478
- *
479
- * The local stage carries no suffix, so `gkm dev` keeps using `orders` and a
480
- * developer's psql history, saved connections, and muscle memory survive a
481
- * change of stage name. Every other stage is suffixed.
482
- */
483
- function resourceName(id, kind, stage, localStage) {
484
- const base = id.toLowerCase();
485
- if (stage === localStage) return base;
486
- return `${base}${SEPARATORS[kind] ?? "-"}${stage}`;
487
- }
488
- /**
489
- * The container a kind needs, or `undefined` if it needs none.
490
- *
491
- * Queues and topics have no container of their own — they live in whichever
492
- * broker the project selected, which is why the backend is an argument here
493
- * rather than a second pass that adds containers after the fact.
494
- */
495
- function containerFor(kind, events = DEFAULT_EVENTS$1, cache = DEFAULT_CACHE.aws, derived = false, edge = true) {
496
- if (EVENT_KINDS[kind]) return EVENT_CONTAINERS[events] ?? CONTAINERS.database;
497
- if (kind === "file-server") return edge ? "caddy" : CONTAINERS.objects;
498
- if (kind === "cache") {
499
- if (derived) return CONTAINERS.database;
500
- return CACHE_CONTAINERS[cache] ?? CONTAINERS.database;
501
- }
502
- return CONTAINERS[kind];
503
- }
504
- /**
505
- * Build the plan for a manifest and stage.
506
- *
507
- * `order` is the caller's provisioning order — parents before children — which
508
- * `provisionOrder` produces from the manifest. Passing it in keeps this
509
- * function free of the traversal and makes the ordering assertable on its own.
510
- */
511
- function planFor(manifest, stage, order, options = {}) {
512
- const containers = /* @__PURE__ */ new Set();
513
- const resources = [];
514
- const events = options.events ?? DEFAULT_EVENTS$1;
515
- const cache = options.cache ?? DEFAULT_CACHE.aws;
516
- for (const id of order) {
517
- const declaration = manifest[id];
518
- if (!declaration) continue;
519
- const container = containerFor(declaration.kind, events, cache, "of" in declaration && typeof declaration.of === "string", options.edge !== false);
520
- if (!container && !CONTAINERLESS[declaration.kind]) continue;
521
- if (container) {
522
- containers.add(container);
523
- for (const required of REQUIRES[container] ?? []) containers.add(required);
524
- }
525
- resources.push({
526
- id,
527
- kind: declaration.kind,
528
- ...container ? { container } : {},
529
- name: resourceName(id, declaration.kind, stage, options.localStage),
530
- envKey: providedKeyFor(id, declaration.kind, ROLES[declaration.kind] ?? "url"),
531
- provisions: PROVISIONS[declaration.kind] === true,
532
- ...declaration.kind === "rest-api" ? { callers: dependentsOf(manifest, id) } : {},
533
- ...declaration.kind === "site" ? { publicEnv: publicEnvFor(declaration, manifest) } : {},
534
- ...declaration.kind === "file-server" && declaration.open?.length ? { open: declaration.open } : {},
535
- ..."of" in declaration ? { of: declaration.of } : {},
536
- ..."schema" in declaration && declaration.schema ? { schema: declaration.schema } : {},
537
- ..."version" in declaration && declaration.version ? { version: declaration.version } : {},
538
- ..."roles" in declaration && declaration.roles === false ? { roles: false } : {},
539
- ..."table" in declaration && declaration.table ? { table: declaration.table } : {}
540
- });
541
- }
542
- if (options.edge !== false && resources.some((r) => EDGE_KINDS[r.kind] === true)) containers.add("caddy");
543
- for (const extra of options.extraContainers ?? []) containers.add(extra);
544
- 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));
545
- if (cache === "db") {
546
- const placeless = resources.filter((r) => r.kind === "cache" && !r.of);
547
- if (placeless.length > 0) {
548
- const databases = resources.filter((r) => r.kind === "database");
549
- const [only] = databases;
550
- if (!only) throw new CacheNeedsDatabase(resources.filter((r) => r.kind === "cache").map((r) => r.id));
551
- if (databases.length > 1) throw new CacheIsAmbiguous(placeless.map((r) => r.id), databases.map((r) => r.id));
552
- for (const resource of placeless) resource.of = only.id;
553
- }
554
- }
555
- return {
556
- stage,
557
- events,
558
- cache,
559
- containers: [...containers],
560
- resources
561
- };
562
- }
563
- /**
564
- * Queues or topics were declared with pg-boss and no database to hold them.
565
- *
566
- * Not a reconcile failure but a manifest one: the fix is a line of application
567
- * code either way — declare a database, or select a backend that brings its own
568
- * broker.
569
- */
570
- var CacheNeedsDatabase = class extends Error {
571
- constructor(ids) {
572
- 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(", ")}.`);
573
- this.ids = ids;
574
- this.name = "CacheNeedsDatabase";
575
- }
576
- };
577
- /**
578
- * A `'db'` cache — a server target's default — in an app that declares more
579
- * than one database.
580
- *
581
- * The target says *a* database and the graph offers several, so there is no
582
- * answer to give — and the wrong kind of failure would be to pick one, since a
583
- * cache silently landing in the wrong database is a bug that surfaces as
584
- * missing rows much later. The fix is a stronger statement in application code:
585
- * `orders.cache('Sessions')` names the database, which is a fact about the
586
- * application rather than a deployment choice.
587
- */
588
- var CacheIsAmbiguous = class extends Error {
589
- constructor(ids, databases) {
590
- 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(", ")}.`);
591
- this.ids = ids;
592
- this.databases = databases;
593
- this.name = "CacheIsAmbiguous";
594
- }
595
- };
596
- var PgBossNeedsDatabase = class extends Error {
597
- constructor(ids) {
598
- 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(", ")}.`);
599
- this.ids = ids;
600
- this.name = "PgBossNeedsDatabase";
601
- }
602
- };
603
-
604
- //#endregion
605
- //#region src/reconcile/env.ts
606
- /**
607
- * The credential local containers are brought up with.
608
- *
609
- * The design's `roles: false` case — both URLs fall back to the cluster's master
610
- * credential. A deliberate downgrade, not a default: it holds until the role DDL
611
- * lands in `@geekmidas/db`, at which point the runtime role's URL replaces this
612
- * and the owner URL stops being reachable from any manifest edge.
613
- */
614
- const LOCAL_USER$2 = "geekmidas";
615
- /** The host containers are published on. */
616
- const LOCAL_HOST = "localhost";
617
- /** The region local buckets claim, so the client has one to sign with. */
618
- const LOCAL_REGION = "us-east-1";
619
- /**
620
- * The credentials the S3 client resolves for MinIO.
621
- *
622
- * An `s3://` URL deliberately carries none: deployed, the SDK reads them from
623
- * the execution role, so a URL that embedded a key would be one more thing to
624
- * rotate and one more thing to leak into a log. Locally there is no role, and
625
- * the same chain reads these — which is why they are injected beside the URL
626
- * rather than written into it.
627
- */
628
- const STORAGE_CREDENTIALS = {
629
- AWS_ACCESS_KEY_ID: LOCAL_USER$2,
630
- AWS_SECRET_ACCESS_KEY: LOCAL_USER$2,
631
- AWS_REGION: LOCAL_REGION
632
- };
633
- /** The token the local cache proxy accepts. Matches the compose definition. */
634
- const LOCAL_TOKEN$1 = "geekmidas";
635
- /** The schema pg-boss keeps its tables in, inside the declared database. */
636
- const PGBOSS_SCHEMA = "pgboss";
637
- /** The exchange every local topic and queue shares on RabbitMQ. */
638
- const RABBITMQ_EXCHANGE = "geekmidas.events";
639
- /**
640
- * Every env key a reconciled plan resolves, and its value.
641
- *
642
- * Keys come from the declaration rather than being re-derived, so what the build
643
- * publishes and what the app reads cannot drift.
644
- */
645
- function envFor(plan, options) {
646
- const env = {};
647
- const resolved = {};
648
- for (const resource of plan.resources) {
649
- const url = urlFor(resource, plan, options.ports, options.project ?? "", options.addresses);
650
- if (url) resolved[resource.id] = url;
651
- }
652
- for (const resource of plan.resources) {
653
- const url = resolved[resource.id];
654
- if (resource.kind === "rest-api") Object.assign(env, surfaceEnv(resource, url, resolved));
655
- if (url) env[resource.envKey] = url;
656
- if (isDatabase(resource.kind) && resource.roles !== false) {
657
- const owner = ownerUrl(resource, plan, options.ports, options.project ?? "");
658
- if (owner) env[provideKey(resource.id, "ownerUrl")] = owner;
659
- }
660
- if (resource.kind === "email" && url) env[provideKey(resource.id, "from")] = options.mailFrom ?? `noreply@${LOCAL_HOST}`;
661
- }
662
- Object.assign(env, publicEnv(plan, env));
663
- Object.assign(env, brokerEnv(plan, options.ports));
664
- if (plan.resources.some((r) => r.kind === "objects" && env[r.envKey])) Object.assign(env, STORAGE_CREDENTIALS);
665
- return env;
666
- }
667
- /**
668
- * The values a site's bundler inlines, under the names it inlines them by.
669
- *
670
- * A rename and nothing more. `API_URL` was resolved once, by the same code that
671
- * resolved it for the server; a site reads the same value under `VITE_API_URL`
672
- * because that prefix is how its bundler is told to ship it. Nothing is derived
673
- * twice, so a site and its API cannot come to disagree about where the API is.
674
- *
675
- * A source that resolved to nothing is skipped rather than written empty: an
676
- * inlined empty string is a frontend that builds and then fails at runtime
677
- * against `http:///`, where a missing variable fails at build with the name of
678
- * the thing that is missing.
679
- */
680
- function publicEnv(plan, resolved) {
681
- const env = {};
682
- for (const resource of plan.resources) for (const [key, source] of Object.entries(resource.publicEnv ?? {})) {
683
- const value = resolved[source];
684
- if (value) env[key] = value;
685
- }
686
- return env;
687
- }
688
- /**
689
- * What a surface publishes beyond its own address: who may call it, and where
690
- * a cookie set by it is readable.
691
- *
692
- * Both are read off the same list — the constructs that declared an edge to
693
- * this surface — which is why neither appears in application code. A surface
694
- * that listed its own callers would be edited every time something new called
695
- * it, and the thing being edited is already recorded in the graph.
696
- *
697
- * An empty origin list is written, and a surface with no address writes nothing
698
- * at all. The two cases look alike and are not: "nothing depends on this yet" is
699
- * a real state a target should publish, while "this surface has no address here"
700
- * means it is not running in this stage, and keys belong with the address they
701
- * describe.
702
- */
703
- function surfaceEnv(resource, url, resolved = {}) {
704
- if (!url) return {};
705
- const origins = [...new Set((resource.callers ?? []).map((caller) => resolved[caller]).filter((address) => Boolean(address)).map(originOf).filter((origin) => Boolean(origin)))].sort();
706
- const domain = cookieDomain([url, ...origins]);
707
- return {
708
- [provideKey(resource.id, "trustedOrigins")]: origins.join(","),
709
- ...domain ? { [provideKey(resource.id, "cookieDomain")]: domain } : {}
710
- };
711
- }
712
- /** An address reduced to the origin a browser compares against. */
713
- function originOf(address) {
714
- try {
715
- return new URL(address).origin;
716
- } catch {
717
- return void 0;
718
- }
719
- }
720
- /**
721
- * The runtime role of whatever a derived node hangs off.
722
- *
723
- * A reader's parent may itself be a schema tenant, so this follows `of` by one
724
- * hop rather than assuming the cluster — the reader of a tenant reads that
725
- * tenant's schema, not the database's.
726
- */
727
- function parentRole(resource, plan) {
728
- const parent = plan.resources.find((r) => r.id === resource.of);
729
- return parent ? localRole(parent) : resource.name;
730
- }
731
- /** Whether a kind connects to Postgres and therefore has an owner role. */
732
- function isDatabase(kind) {
733
- return kind === "database" || kind === "database-schema";
734
- }
735
- /**
736
- * The URL a migrator connects with — the owner role, which can create, alter
737
- * and drop.
738
- *
739
- * Never in `provides`, which is the whole point. A handler that could reach this
740
- * could `DROP TABLE`, and the security property the role split exists for is
741
- * that it cannot: the value is injected by `gkm exec` for the migrate step and
742
- * by nothing else.
743
- */
744
- function ownerUrl(resource, plan, ports, project) {
745
- if (!resource.container) return void 0;
746
- const port = ports[primaryPortKey(resource.container)];
747
- if (port === void 0) return void 0;
748
- const owner = ownerRole(localRole(resource));
749
- return postgres(port, rootDatabase(resource, plan), {
750
- user: owner,
751
- password: localRolePassword(project, plan, owner)
752
- });
753
- }
754
- /**
755
- * The shared broker keys, when anything is published or consumed.
756
- *
757
- * A queue's own key is the producer's. These two are the *connection* itself,
758
- * which locally is one broker for every queue and topic in the project: the
759
- * generated pollers open a single connection and subscribe each worker by name
760
- * on it. Deployed there is no such thing — a Lambda is handed its own event
761
- * source — so this pair exists for the local target and says so.
762
- */
763
- function brokerEnv(plan, ports) {
764
- const carrier = plan.resources.find((r) => r.kind === "queue" || r.kind === "topic");
765
- if (!carrier) return {};
766
- const publisher = urlFor(carrier, plan, ports, "");
767
- if (!publisher) return {};
768
- return {
769
- EVENT_PUBLISHER_CONNECTION_STRING: publisher,
770
- EVENT_SUBSCRIBER_CONNECTION_STRING: plan.events === "sns" ? publisher.replace(/^sns:/, "sqs:") : publisher
771
- };
772
- }
773
- /**
774
- * The URL for one planned resource.
775
- *
776
- * Every part of it comes from the resource and the port it was published on.
777
- */
778
- function urlFor(resource, plan, ports, project, addresses = {}) {
779
- if (resource.kind === "secret") return localSecret(project, plan, resource);
780
- if (resource.kind === "credential") return void 0;
781
- if (resource.kind === "rest-api" || resource.kind === "site") {
782
- const address = addresses[resource.id];
783
- const edge = plan.containers.includes("caddy") ? ports[primaryPortKey("caddy")] : void 0;
784
- return address && edge !== void 0 ? `https://${hostFor(resource, project)}:${edge}` : address;
785
- }
786
- if (!resource.container) return void 0;
787
- const port = ports[primaryPortKey(resource.container)];
788
- if (port === void 0) return void 0;
789
- switch (resource.kind) {
790
- case "database":
791
- case "database-schema":
792
- case "database-reader": {
793
- const database = rootDatabase(resource, plan);
794
- if (resource.roles === false) {
795
- const schema = schemaOf(resource, plan);
796
- return schema ? `${postgres(port, database)}?search_path=${schema}` : postgres(port, database);
797
- }
798
- const role = resource.kind === "database-reader" ? readerRole(parentRole(resource, plan)) : localRole(resource);
799
- return postgres(port, database, {
800
- user: role,
801
- password: localRolePassword(project, plan, role)
802
- });
803
- }
804
- case "email": return `smtp://${LOCAL_HOST}:${port}`;
805
- case "objects": return `s3://${resource.name}?region=${LOCAL_REGION}&endpoint=http://${LOCAL_HOST}:${port}&forcePathStyle=true`;
806
- case "file-server": {
807
- const origin = plan.resources.find((r) => r.id === resource.of);
808
- if (!origin) return void 0;
809
- return plan.containers.includes("caddy") ? `https://${hostFor(resource, project)}:${port}` : `http://${LOCAL_HOST}:${port}/${origin.name}`;
810
- }
811
- case "cache":
812
- if (resource.of) {
813
- const parent = plan.resources.find((r) => r.id === resource.of);
814
- const url = parent ? urlFor(parent, plan, ports, project, addresses) : void 0;
815
- return url ? withTable(url, resource.table ?? cacheTable(resource.id)) : void 0;
816
- }
817
- switch (plan.cache) {
818
- case "elasticache": return `redis://${LOCAL_HOST}:${port}`;
819
- default: return `http://:${LOCAL_TOKEN$1}@${LOCAL_HOST}:${port}`;
820
- }
821
- case "queue":
822
- case "topic": return broker(plan, port);
823
- default: return void 0;
824
- }
825
- }
826
- /**
827
- * The producer's connection string, composed from the backend the plan chose.
828
- *
829
- * The protocol is what picks the transport, so a producer never branches: the
830
- * same `.publish()` reaches pg-boss here and SQS deployed because the string it
831
- * was handed said so.
832
- */
833
- function broker(plan, port) {
834
- switch (plan.events) {
835
- case "pgboss": {
836
- const database = plan.resources.find((r) => r.kind === "database");
837
- if (!database) throw new PgBossNeedsDatabase([]);
838
- return `pgboss://${LOCAL_USER$2}:${LOCAL_USER$2}@${LOCAL_HOST}:${port}/${database.name}?schema=${PGBOSS_SCHEMA}`;
839
- }
840
- case "rabbitmq": return `rabbitmq://${LOCAL_USER$2}:${LOCAL_USER$2}@${LOCAL_HOST}:${port}?exchange=${RABBITMQ_EXCHANGE}`;
841
- case "sns": throw new UnprovisionedEventsBackend("sns");
842
- }
843
- }
844
- /** A local Postgres URL, master credential and all. */
845
- function postgres(port, database, credential = {
846
- user: LOCAL_USER$2,
847
- password: LOCAL_USER$2
848
- }) {
849
- return `postgres://${credential.user}:${credential.password}@${LOCAL_HOST}:${port}/${database}`;
850
- }
851
- /**
852
- * The role a handler connects as, for one database or tenant.
853
- *
854
- * The construct's id, lowercased and stage-scoped exactly as its database or
855
- * schema is — so `Orders` in the `test` stage connects as `orders_test`, and two
856
- * stages sharing one cluster cannot share a credential. Roles are cluster-scoped
857
- * in Postgres, which is why the suffix is not optional here the way it is for a
858
- * schema.
859
- */
860
- function localRole(resource) {
861
- return resource.name;
862
- }
863
- /**
864
- * The password for a derived local role.
865
- *
866
- * Derived rather than random, for the same reason the local secret is: a
867
- * password that changed on every `gkm dev` would lock a developer out of the
868
- * data they had a moment ago. Seeded by the project so two checkouts do not
869
- * share one, and by the stage so `test` and `development` do not.
870
- *
871
- * It is a *local* credential by construction — the cluster is on loopback and
872
- * the seed is a checkout path — and no deployed target uses this function.
873
- */
874
- function localRolePassword(project, plan, role) {
875
- return createHash("sha256").update(`${project}:${plan.stage}:role:${role}`).digest("base64url").slice(0, 32);
876
- }
877
- /**
878
- * A cache's address: its database's URL, carrying the table it reads.
879
- *
880
- * Appended rather than kept beside the URL as a second key, for the reason the
881
- * design gives everywhere else — an address and what it opens are one fact, and
882
- * two keys are one more thing to keep in step.
883
- */
884
- function withTable(url, table) {
885
- const parsed = new URL(url);
886
- parsed.searchParams.set("table", table);
887
- return parsed.toString();
888
- }
889
- /**
890
- * The physical database a derived resource lives in.
891
- *
892
- * Walks `of` to the top rather than reading the immediate parent, because a
893
- * reader's parent may itself be a schema tenant — two hops from the database
894
- * that actually exists.
895
- */
896
- function rootDatabase(resource, plan) {
897
- const byId = new Map(plan.resources.map((r) => [r.id, r]));
898
- let current = resource;
899
- while (current.of) {
900
- const parent = byId.get(current.of);
901
- if (!parent) break;
902
- current = parent;
903
- }
904
- return current.name;
905
- }
906
- /** The schema a derived resource puts on its search path, if it has one. */
907
- function schemaOf(resource, plan) {
908
- const byId = new Map(plan.resources.map((r) => [r.id, r]));
909
- let current = resource;
910
- while (current) {
911
- if (current.kind === "database-schema") return current.schema;
912
- current = current.of ? byId.get(current.of) : void 0;
913
- }
914
- return void 0;
915
- }
916
- /**
917
- * A backend whose local addresses cannot be derived yet.
918
- *
919
- * SNS and SQS are addressed by ARN, which means the topic and queue have to be
920
- * created in LocalStack before a URL can name them. Until that provisioning
921
- * lands, saying so is better than handing out a string that fails on first use.
922
- */
923
- var UnprovisionedEventsBackend = class extends Error {
924
- constructor(backend) {
925
- super(`The local target cannot derive addresses for '${backend}' yet — its topics and queues are named by ARN, which nothing creates locally. Use 'pgboss' (the default) or 'rabbitmq' for local development.`);
926
- this.backend = backend;
927
- this.name = "UnprovisionedEventsBackend";
928
- }
929
- };
930
- /**
931
- * The value a secret resolves to locally.
932
- *
933
- * A hash of what identifies it, so it is stable, distinct per project, stage
934
- * and construct, and never written to disk as a literal. Deployed this is the
935
- * one kind whose value does *not* come from here — a secret manager generates
936
- * it once and the target reads it back.
937
- */
938
- function localSecret(project, plan, resource) {
939
- return createHash("sha256").update(`${project}:${plan.stage}:${resource.id}`).digest("base64url").slice(0, 43);
940
- }
941
-
942
- //#endregion
943
- //#region src/reconcile/apps.ts
944
- /** The profile app services carry, so `gkm dev` starts only the containers. */
945
- const APPS_PROFILE = "apps";
946
- /**
947
- * Where an app's image is built from.
948
- *
949
- * An app at the project root is a single-app project, whose `gkm docker`
950
- * writes `.gkm/docker/Dockerfile`; a workspace writes one per app.
951
- */
952
- function dockerfileOf(appName, path) {
953
- return path === "." ? ".gkm/docker/Dockerfile" : `.gkm/docker/Dockerfile.${appName}`;
954
- }
955
- /**
956
- * Every construct key, addressed across the compose network.
957
- *
958
- * `envFor` is asked with a placeholder port for every port key, so each
959
- * `localhost:<placeholder>` in its answer names exactly one container port —
960
- * two containers listening on the same port inside cannot be confused — and is
961
- * rewritten to `<container>:<inside>`.
962
- */
963
- function inNetworkEnv(workspace, manifest) {
964
- const plan = planFor(manifest, workspace.stages.local, provisionOrder(manifest), {
965
- localStage: workspace.stages.local,
966
- ...backendsOf(workspace)
967
- });
968
- const placeholders = {};
969
- const targets = /* @__PURE__ */ new Map();
970
- let next = 49152;
971
- for (const container of [...plan.containers].sort()) for (const port of portsOf(container)) {
972
- placeholders[port.key] = next;
973
- targets.set(next, `${container}:${port.inside}`);
974
- next += 1;
975
- }
976
- for (const key of portKeys(plan.containers)) placeholders[key] ??= next++;
977
- const env = envFor(plan, {
978
- ports: placeholders,
979
- project: workspace.name,
980
- addresses: surfaceAddresses(workspace, manifest, (app, port) => `http://${app}:${port}`)
981
- });
982
- const rewrite = (value) => value.replace(/(?:localhost|127\.0\.0\.1):(\d+)/g, (match, port) => {
983
- return targets.get(Number(port)) ?? match;
984
- });
985
- return Object.fromEntries(Object.entries(env).map(([key, value]) => [key, rewrite(value)]));
986
- }
987
- /** One compose service per app the workspace runs, behind the apps profile. */
988
- function appServices(workspace, manifest, containers) {
989
- const env = inNetworkEnv(workspace, manifest);
990
- const services = {};
991
- for (const [name, app] of Object.entries(workspace.apps)) {
992
- if (app.type === "mobile" || !app.port) continue;
993
- const key = appKey(name);
994
- const health = app.type === "web" ? "/" : "/health";
995
- services[key] = {
996
- image: `${key}:\${TAG:-latest}`,
997
- build: {
998
- context: ".",
999
- dockerfile: dockerfileOf(name, app.path)
1000
- },
1001
- profiles: [APPS_PROFILE],
1002
- ports: [`${app.port}:${app.port}`],
1003
- environment: {
1004
- NODE_ENV: "production",
1005
- PORT: String(app.port),
1006
- ...env
1007
- },
1008
- ...containers.some((c) => c !== "caddy") ? { depends_on: containers.filter((c) => c !== "caddy") } : {},
1009
- healthcheck: {
1010
- test: [
1011
- "CMD",
1012
- "wget",
1013
- "-q",
1014
- "--spider",
1015
- `http://localhost:${app.port}${health}`
1016
- ],
1017
- interval: "10s",
1018
- timeout: "5s",
1019
- retries: 5
1020
- }
1021
- };
1022
- }
1023
- return services;
1024
- }
1025
-
1026
- //#endregion
1027
- //#region src/reconcile/clients.ts
1028
- /** The credential local containers are brought up with. */
1029
- const LOCAL_USER$1 = "geekmidas";
1030
- /**
1031
- * A Postgres client that opens one connection per database it is asked about.
1032
- *
1033
- * `CREATE DATABASE` cannot run from a connection to the database being created,
1034
- * and a schema must be created from inside its own database — so the database is
1035
- * part of each query rather than fixed when the client is built.
1036
- */
1037
- function pgClient(port) {
1038
- return { async query(database, sql, values) {
1039
- const client = new Client({
1040
- host: "localhost",
1041
- port,
1042
- user: LOCAL_USER$1,
1043
- password: LOCAL_USER$1,
1044
- database: database ?? LOCAL_USER$1
1045
- });
1046
- await client.connect();
1047
- try {
1048
- const result = await client.query(sql, values);
1049
- return result.rows;
1050
- } finally {
1051
- await client.end();
1052
- }
1053
- } };
1054
- }
1055
- /** A bucket client pointed at the local MinIO. */
1056
- function bucketClient(port) {
1057
- const s3 = new S3Client({
1058
- region: "us-east-1",
1059
- endpoint: `http://localhost:${port}`,
1060
- forcePathStyle: true,
1061
- credentials: {
1062
- accessKeyId: LOCAL_USER$1,
1063
- secretAccessKey: LOCAL_USER$1
1064
- }
1065
- });
1066
- return {
1067
- async exists(bucket) {
1068
- try {
1069
- await s3.send(new HeadBucketCommand({ Bucket: bucket }));
1070
- return true;
1071
- } catch {
1072
- return false;
1073
- }
1074
- },
1075
- async create(bucket) {
1076
- await s3.send(new CreateBucketCommand({ Bucket: bucket }));
1077
- },
1078
- async policy(bucket) {
1079
- try {
1080
- const result = await s3.send(new GetBucketPolicyCommand({ Bucket: bucket }));
1081
- return result.Policy;
1082
- } catch {
1083
- return void 0;
1084
- }
1085
- },
1086
- async setPolicy(bucket, policy) {
1087
- await s3.send(new PutBucketPolicyCommand({
1088
- Bucket: bucket,
1089
- Policy: policy
1090
- }));
1091
- }
1092
- };
1093
- }
1094
-
1095
- //#endregion
1096
- //#region src/reconcile/compose.ts
1097
- /** The credential every derived container is brought up with locally. */
1098
- const LOCAL_USER = "geekmidas";
1099
- /**
1100
- * The token the local cache accepts.
1101
- *
1102
- * Fixed rather than generated: it is only ever reachable on a port this project
1103
- * published, and the URL that carries it is derived, so nothing is made safer
1104
- * by making it unguessable and a stable one keeps `redis-cli` sessions working.
1105
- */
1106
- const LOCAL_TOKEN = "geekmidas";
1107
- /**
1108
- * Build the compose document for a plan.
1109
- *
1110
- * Every container is published on its assigned port, never on the image's
1111
- * default: the point of allocation is that two projects can run at once, and
1112
- * one container publishing 5432 puts that back.
1113
- */
1114
- function composeFor(plan, options) {
1115
- const services = {};
1116
- const volumes = {};
1117
- for (const container of [...plan.containers].sort()) {
1118
- const declared = container === "postgres" ? plan.resources.find((r) => r.version)?.version : void 0;
1119
- const image = declared ? postgresImage(declared) : DEFAULT_IMAGES[container];
1120
- if (!image) throw new UnknownContainer(container);
1121
- services[container] = define(container, image, publish(container, options.ports));
1122
- const volume = volumeOf(container);
1123
- if (volume) volumes[volume] = {};
1124
- }
1125
- return {
1126
- name: options.project,
1127
- services: {
1128
- ...services,
1129
- ...options.apps
1130
- },
1131
- ...Object.keys(volumes).length ? { volumes } : {}
1132
- };
1133
- }
1134
- /** Render a compose document as the file it becomes. */
1135
- function toYaml(file) {
1136
- return `# Generated by gkm from the construct manifest — do not edit.
1137
- # Containers are derived from what the app declares. Image pins and anything
1138
- # no construct implies go in your own docker-compose.yml, which is merged over
1139
- # this file and wins:
1140
- #
1141
- # docker compose -f docker-compose.constructs.yml -f docker-compose.yml …
1142
- #
1143
- # "gkm dev" and "gkm test" start the containers. The apps sit behind the
1144
- # "apps" profile: run "gkm setup", then
1145
- # docker compose -f docker-compose.constructs.yml --profile apps up --build
1146
- ${stringify(file, { lineWidth: 0 })}`;
1147
- }
1148
- /** A container with no image, from config or from the defaults. */
1149
- var UnknownContainer = class extends Error {
1150
- /** The container that could not be resolved. */
1151
- container;
1152
- /** The containers that have a default, so the caller can see the set. */
1153
- known = Object.keys(DEFAULT_IMAGES).sort();
1154
- constructor(container) {
1155
- super("No image is known for this container; pin one in config");
1156
- this.name = "UnknownContainer";
1157
- this.container = container;
1158
- }
1159
- };
1160
- /** One container's definition, published on the port it was assigned. */
1161
- function define(container, image, published) {
1162
- switch (container) {
1163
- case "postgres": return {
1164
- image,
1165
- restart: "unless-stopped",
1166
- ports: published,
1167
- environment: {
1168
- POSTGRES_USER: LOCAL_USER,
1169
- POSTGRES_PASSWORD: LOCAL_USER,
1170
- POSTGRES_DB: LOCAL_USER
1171
- },
1172
- volumes: ["postgres-data:/var/lib/postgresql"],
1173
- healthcheck: {
1174
- test: ["CMD-SHELL", `pg_isready -U ${LOCAL_USER}`],
1175
- interval: "5s",
1176
- timeout: "3s",
1177
- retries: 10,
1178
- start_period: "10s"
1179
- }
1180
- };
1181
- case "minio": return {
1182
- image,
1183
- restart: "unless-stopped",
1184
- ports: published,
1185
- environment: {
1186
- MINIO_ROOT_USER: LOCAL_USER,
1187
- MINIO_ROOT_PASSWORD: LOCAL_USER
1188
- },
1189
- command: "server --console-address \":9001\" /data",
1190
- volumes: ["minio-data:/data"],
1191
- healthcheck: {
1192
- test: [
1193
- "CMD",
1194
- "mc",
1195
- "ready",
1196
- "local"
1197
- ],
1198
- interval: "10s",
1199
- timeout: "5s",
1200
- retries: 5,
1201
- start_period: "10s"
1202
- }
1203
- };
1204
- case "caddy": return {
1205
- image,
1206
- restart: "unless-stopped",
1207
- ports: published,
1208
- volumes: [
1209
- "./.gkm/Caddyfile:/etc/caddy/Caddyfile:ro",
1210
- "./.gkm/caddy-sites:/etc/caddy/sites:ro",
1211
- "caddy-data:/data"
1212
- ],
1213
- extra_hosts: ["host.docker.internal:host-gateway"],
1214
- healthcheck: {
1215
- test: [
1216
- "CMD",
1217
- "caddy",
1218
- "version"
1219
- ],
1220
- interval: "10s",
1221
- timeout: "5s",
1222
- retries: 5
1223
- }
1224
- };
1225
- case "mailpit": return {
1226
- image,
1227
- restart: "unless-stopped",
1228
- ports: published,
1229
- environment: {
1230
- MP_SMTP_AUTH_ACCEPT_ANY: "1",
1231
- MP_SMTP_AUTH_ALLOW_INSECURE: "1"
1232
- },
1233
- healthcheck: {
1234
- test: [
1235
- "CMD",
1236
- "wget",
1237
- "-q",
1238
- "--spider",
1239
- "http://localhost:8025"
1240
- ],
1241
- interval: "10s",
1242
- timeout: "5s",
1243
- retries: 5
1244
- }
1245
- };
1246
- case "redis": return {
1247
- image,
1248
- restart: "unless-stopped",
1249
- ports: published,
1250
- volumes: ["redis-data:/data"],
1251
- healthcheck: {
1252
- test: [
1253
- "CMD",
1254
- "redis-cli",
1255
- "ping"
1256
- ],
1257
- interval: "5s",
1258
- timeout: "3s",
1259
- retries: 5
1260
- }
1261
- };
1262
- case "redis-http": return {
1263
- image,
1264
- restart: "unless-stopped",
1265
- ports: published,
1266
- environment: {
1267
- SRH_MODE: "env",
1268
- SRH_TOKEN: LOCAL_TOKEN,
1269
- SRH_CONNECTION_STRING: "redis://redis:6379"
1270
- },
1271
- depends_on: ["redis"],
1272
- healthcheck: {
1273
- test: [
1274
- "CMD",
1275
- "wget",
1276
- "-q",
1277
- "-O",
1278
- "/dev/null",
1279
- "http://127.0.0.1:80/"
1280
- ],
1281
- interval: "5s",
1282
- timeout: "3s",
1283
- retries: 10
1284
- }
1285
- };
1286
- case "rabbitmq": return {
1287
- image,
1288
- restart: "unless-stopped",
1289
- ports: published,
1290
- environment: {
1291
- RABBITMQ_DEFAULT_USER: LOCAL_USER,
1292
- RABBITMQ_DEFAULT_PASS: LOCAL_USER
1293
- },
1294
- volumes: ["rabbitmq-data:/var/lib/rabbitmq"],
1295
- healthcheck: {
1296
- test: [
1297
- "CMD",
1298
- "rabbitmq-diagnostics",
1299
- "-q",
1300
- "ping"
1301
- ],
1302
- interval: "10s",
1303
- timeout: "5s",
1304
- retries: 5
1305
- }
1306
- };
1307
- case "localstack": return {
1308
- image,
1309
- restart: "unless-stopped",
1310
- ports: published,
1311
- environment: {
1312
- AWS_DEFAULT_REGION: "us-east-1",
1313
- AWS_ACCESS_KEY_ID: "LSIAQAAAAAAVNCBMPNSG",
1314
- AWS_SECRET_ACCESS_KEY: LOCAL_USER
1315
- },
1316
- volumes: ["localstack-data:/var/lib/localstack"],
1317
- healthcheck: {
1318
- test: [
1319
- "CMD",
1320
- "curl",
1321
- "-f",
1322
- "http://localhost:4566/_localstack/health"
1323
- ],
1324
- interval: "10s",
1325
- timeout: "5s",
1326
- retries: 5,
1327
- start_period: "10s"
1328
- }
1329
- };
1330
- default: throw new UnknownContainer(container);
1331
- }
1332
- }
1333
- /**
1334
- * The published port mappings for a container.
1335
- *
1336
- * Every port is looked up by its own key rather than being derived as an offset
1337
- * from the container's first, so MinIO's console cannot land on whatever was
1338
- * allocated to the next container.
1339
- */
1340
- function publish(container, ports) {
1341
- return portsOf(container).map((port) => {
1342
- const assigned = ports[port.key];
1343
- if (assigned === void 0) throw new UnassignedPort(port.key);
1344
- return `${assigned}:${port.inside}`;
1345
- });
1346
- }
1347
- /** A planned port that allocation never assigned. */
1348
- var UnassignedPort = class extends Error {
1349
- /** The port key that went unassigned, e.g. `minio-console`. */
1350
- key;
1351
- constructor(key) {
1352
- super("No port was assigned for this container port");
1353
- this.name = "UnassignedPort";
1354
- this.key = key;
1355
- }
1356
- };
1357
-
1358
- //#endregion
1359
- //#region src/reconcile/docker.ts
1360
- const run = promisify(execFile);
1361
- /**
1362
- * The generated file, then the project's own if it has one.
1363
- *
1364
- * Merged in that order so the project's wins — an `image:` there pins a
1365
- * container this file derived, and a service there is added beside them.
1366
- */
1367
- function composeFiles(composePath) {
1368
- const project = join(dirname(composePath), "docker-compose.yml");
1369
- return [
1370
- "-f",
1371
- composePath,
1372
- ...existsSync(project) ? ["-f", project] : []
1373
- ];
1374
- }
1375
- /** How long to wait for containers to pass their health checks. */
1376
- const HEALTH_TIMEOUT_MS = 12e4;
1377
- const dockerCli = {
1378
- async publishedPort(composePath, service, inside) {
1379
- try {
1380
- const { stdout } = await run("docker", [
1381
- "compose",
1382
- ...composeFiles(composePath),
1383
- "port",
1384
- service,
1385
- String(inside)
1386
- ]);
1387
- const port = Number(stdout.trim().split(":").pop());
1388
- return Number.isFinite(port) && port > 0 ? port : void 0;
1389
- } catch {
1390
- return void 0;
1391
- }
1392
- },
1393
- async up(composePath, services) {
1394
- await run("docker", [
1395
- "compose",
1396
- ...composeFiles(composePath),
1397
- "up",
1398
- "-d",
1399
- "--remove-orphans",
1400
- "--wait",
1401
- `--wait-timeout=${Math.floor(HEALTH_TIMEOUT_MS / 1e3)}`,
1402
- ...services
1403
- ]);
1404
- },
1405
- async copyOut(composePath, service, from, to) {
1406
- await mkdir(dirname(to), { recursive: true });
1407
- await run("docker", [
1408
- "compose",
1409
- ...composeFiles(composePath),
1410
- "cp",
1411
- `${service}:${from}`,
1412
- to
1413
- ]);
1414
- },
1415
- async reload(composePath, service) {
1416
- await run("docker", [
1417
- "compose",
1418
- ...composeFiles(composePath),
1419
- "exec",
1420
- "-T",
1421
- service,
1422
- "caddy",
1423
- "reload",
1424
- "--config",
1425
- "/etc/caddy/Caddyfile"
1426
- ]);
1427
- },
1428
- async healthy(composePath, services) {
1429
- if (services.length === 0) return true;
1430
- try {
1431
- const { stdout } = await run("docker", [
1432
- "compose",
1433
- ...composeFiles(composePath),
1434
- "ps",
1435
- "--format",
1436
- "json",
1437
- ...services
1438
- ]);
1439
- const running = /* @__PURE__ */ new Set();
1440
- for (const line of stdout.trim().split("\n").filter(Boolean)) {
1441
- const entry = JSON.parse(line);
1442
- const ok = entry.State === "running" && (entry.Health === void 0 || entry.Health === "" || entry.Health === "healthy");
1443
- if (ok && entry.Service) running.add(entry.Service);
1444
- }
1445
- return services.every((service) => running.has(service));
1446
- } catch {
1447
- return false;
1448
- }
1449
- }
1450
- };
1451
-
1452
- //#endregion
1453
- //#region src/reconcile/ports.ts
1454
- /**
1455
- * The window ports are drawn from.
1456
- *
1457
- * Above the registered range so nothing here needs privileges, and below the
1458
- * ephemeral range both Linux (32768+) and macOS (49152+) allocate from — a port
1459
- * the kernel might hand to an outgoing connection is one that is free when
1460
- * checked and taken by the time it is bound.
1461
- */
1462
- const WINDOW = {
1463
- min: 2e4,
1464
- max: 32e3
1465
- };
1466
- /**
1467
- * How far apart two projects start.
1468
- *
1469
- * Wide enough that a project can add containers without walking into its
1470
- * neighbour's block, narrow enough that the window holds many projects.
1471
- */
1472
- const BLOCK = 50;
1473
- /**
1474
- * Where a project's ports start.
1475
- *
1476
- * Derived from the name rather than assigned sequentially so that a fresh clone
1477
- * of the same project on the same machine lands on the same block — the first
1478
- * run has nothing persisted to read, and hashing is what keeps that first run
1479
- * from colliding with whatever else is already allocated.
1480
- *
1481
- * @example startingPort('toolbox') // stable for a given name
1482
- */
1483
- function startingPort(project) {
1484
- const digest = createHash("sha256").update(project).digest();
1485
- const blocks = Math.floor((WINDOW.max - WINDOW.min) / BLOCK);
1486
- return WINDOW.min + digest.readUInt32BE(0) % blocks * BLOCK;
1487
- }
1488
- /**
1489
- * Assign a port to every container that has none, keeping the ones that do.
1490
- *
1491
- * Existing assignments are returned untouched even when the container is no
1492
- * longer in the plan: removing a construct must not renumber what is left, and
1493
- * keeping the entry means re-adding it later restores the same port rather than
1494
- * inventing a new one.
1495
- *
1496
- * @param probe - reports what is actually listening. A port assigned to this
1497
- * project is skipped without probing, because on a converged reconcile our own
1498
- * container is the thing listening on it.
1499
- * @throws {NoPortAvailable} when the window is exhausted.
1500
- */
1501
- async function allocate(project, containers, existing = {}, probe = isPortFree) {
1502
- const assignments = { ...existing };
1503
- const taken = new Set(Object.values(assignments));
1504
- for (const container of [...containers].sort()) {
1505
- if (assignments[container] !== void 0) continue;
1506
- const port = await nextFree(startingPort(project), taken, probe);
1507
- assignments[container] = port;
1508
- taken.add(port);
1509
- }
1510
- return assignments;
1511
- }
1512
- /** The window was exhausted. */
1513
- var NoPortAvailable = class extends Error {
1514
- /** Where the search started. */
1515
- from;
1516
- /** The window searched, so the caller can report what was full. */
1517
- window = WINDOW;
1518
- constructor(from) {
1519
- super("No free port is available in the local port range");
1520
- this.name = "NoPortAvailable";
1521
- this.from = from;
1522
- }
1523
- };
1524
- /**
1525
- * The first port at or after `from` that is neither ours nor in use.
1526
- *
1527
- * Wraps at the top of the window rather than stopping, so a project whose block
1528
- * sits near the end is not the one that fails.
1529
- */
1530
- async function nextFree(from, taken, probe) {
1531
- const span = WINDOW.max - WINDOW.min;
1532
- for (let offset = 0; offset < span; offset++) {
1533
- const port = WINDOW.min + (from - WINDOW.min + offset) % span;
1534
- if (taken.has(port)) continue;
1535
- if (await probe(port)) return port;
1536
- }
1537
- throw new NoPortAvailable(from);
1538
- }
1539
- /**
1540
- * Whether nothing is listening on a port.
1541
- *
1542
- * Binds rather than connects: a refused connection says nothing about whether
1543
- * the port can be *published*, which is the question Docker will ask. Binds on
1544
- * `0.0.0.0` for the same reason — a port free on loopback can still be taken on
1545
- * the address Docker publishes to.
1546
- *
1547
- * Inherently racy, and that is acceptable: Docker failing to bind stays the real
1548
- * check. This exists so the common case surfaces as a message at reconcile
1549
- * rather than as a connection failure ten minutes later.
1550
- */
1551
- function isPortFree(port) {
1552
- return new Promise((resolve$1) => {
1553
- const server = createServer();
1554
- server.once("error", () => resolve$1(false));
1555
- server.once("listening", () => server.close(() => resolve$1(true)));
1556
- server.listen(port, "0.0.0.0");
1557
- });
1558
- }
1559
-
1560
- //#endregion
1561
- //#region src/reconcile/provision.ts
1562
- /**
1563
- * The Postgres work a plan implies.
1564
- *
1565
- * Databases before the schemas inside them, which `provisionOrder` already
1566
- * guarantees by putting parents first.
1567
- */
1568
- function postgresStatements(plan, project = "") {
1569
- const statements = [];
1570
- for (const resource of plan.resources) {
1571
- if (!resource.provisions || resource.container !== "postgres") continue;
1572
- if (resource.kind === "database") {
1573
- statements.push({
1574
- id: resource.id,
1575
- describe: `database ${resource.name}`,
1576
- exists: {
1577
- sql: "SELECT 1 FROM pg_database WHERE datname = $1",
1578
- values: [resource.name]
1579
- },
1580
- create: `CREATE DATABASE ${quoteIdentifier(resource.name)}`
1581
- });
1582
- if (resource.schema) statements.push(...rolesFor(resource, resource.schema, plan, project));
1583
- continue;
1584
- }
1585
- if (resource.kind === "database-schema" && resource.schema) statements.push(...rolesFor(resource, resource.schema, plan, project));
1586
- const cacheHome = resource.kind === "cache" && resource.of ? plan.resources.find((r) => r.id === resource.of) : void 0;
1587
- if (cacheHome) statements.push(...cacheTableDdl(resource, cacheHome, plan));
1588
- }
1589
- return statements;
1590
- }
1591
- /**
1592
- * A cache's table, in the schema the role that reads it resolves names in.
1593
- *
1594
- * Two things have to line up, and neither is the table's contents. The driver
1595
- * names the table unqualified and lets the connection's `search_path` place it
1596
- * — which the role carries — so creating it from the master connection, whose
1597
- * path is `public`, leaves a table the application cannot see and a
1598
- * `relation "cache" does not exist` on the first request. And the default
1599
- * privileges that make a tenant's tables reachable are granted *for the owner
1600
- * role*, so nothing covers a table the master created.
1601
- *
1602
- * Hence: qualified with the tenant's schema, handed to its owner, and granted
1603
- * explicitly — `roleStatements` grants what exists at the time it runs, and
1604
- * this table does not exist yet.
1605
- *
1606
- * A database that opted out of roles needs none of it: everything connects as
1607
- * the master, whose `search_path` finds `public`, and the table it creates
1608
- * there is the table it reads.
1609
- */
1610
- function cacheTableDdl(cache, home, plan) {
1611
- const database = rootDatabase(home, plan);
1612
- const schema = home.roles === false ? void 0 : home.schema;
1613
- const name = cache.table ?? cacheTable(cache.id);
1614
- const table = schema ? `${schema}.${name}` : name;
1615
- const created = cacheTableStatements({ table }).map((statement) => ({
1616
- id: cache.id,
1617
- describe: statement.describe,
1618
- database,
1619
- ...statement.exists ? { exists: statement.exists } : {},
1620
- create: statement.sql
1621
- }));
1622
- if (!schema) return created;
1623
- const runtime = localRole(home);
1624
- const owner = ownerRole(runtime);
1625
- const qualified = table.split(".").map((part) => quoteIdentifier(part)).join(".");
1626
- return [
1627
- ...created,
1628
- {
1629
- id: cache.id,
1630
- describe: `cache table ${table} is owned by ${owner}`,
1631
- database,
1632
- create: `ALTER TABLE ${qualified} OWNER TO ${quoteIdentifier(owner)}`
1633
- },
1634
- {
1635
- id: cache.id,
1636
- describe: `${runtime} may read and write ${table}`,
1637
- database,
1638
- create: `GRANT SELECT, INSERT, UPDATE, DELETE ON ${qualified} TO ${quoteIdentifier(runtime)}`
1639
- }
1640
- ];
1641
- }
1642
- /**
1643
- * The roles and schema for one database or tenant.
1644
- *
1645
- * Skipped entirely when the construct declared `roles: false` — the documented
1646
- * downgrade, where both URLs fall back to the cluster's master credential. It
1647
- * is a choice someone made rather than a default they got.
1648
- */
1649
- function rolesFor(resource, schema, plan, project) {
1650
- if (resource.roles === false) return [];
1651
- const runtime = localRole(resource);
1652
- const owner = ownerRole(runtime);
1653
- const reader = plan.resources.some((r) => r.kind === "database-reader" && r.of === resource.id) ? readerRole(runtime) : void 0;
1654
- return roleStatements({
1655
- runtime,
1656
- owner,
1657
- ...reader ? { reader } : {},
1658
- schema,
1659
- passwords: {
1660
- runtime: localRolePassword(project, plan, runtime),
1661
- owner: localRolePassword(project, plan, owner),
1662
- ...reader ? { reader: localRolePassword(project, plan, reader) } : {}
1663
- }
1664
- }).map((statement) => ({
1665
- id: resource.id,
1666
- describe: statement.describe,
1667
- database: rootDatabase(resource, plan),
1668
- ...statement.exists ? { exists: statement.exists } : {},
1669
- create: statement.sql
1670
- }));
1671
- }
1672
- /** The buckets a plan implies. */
1673
- function bucketNames(plan) {
1674
- return plan.resources.filter((r) => r.provisions && r.kind === "objects").map((r) => r.name);
1675
- }
1676
- /**
1677
- * Quote an identifier for use in DDL.
1678
- *
1679
- * Names reaching here are already canonical and stage-suffixed, so this is
1680
- * defence rather than sanitisation — but DDL cannot be parameterised, and an
1681
- * unquoted identifier is the one place a name could ever be more than a name.
1682
- */
1683
- function quoteIdentifier(name) {
1684
- return `"${name.replace(/"/g, "\"\"")}"`;
1685
- }
1686
- /**
1687
- * Apply the plan's Postgres statements.
1688
- *
1689
- * Each is checked before it is run, so this converges rather than erroring on a
1690
- * second pass.
1691
- */
1692
- async function applyPostgres(client, statements) {
1693
- const applied = [];
1694
- for (const statement of statements) {
1695
- if (!statement.exists) {
1696
- await client.query(statement.database, statement.create);
1697
- applied.push({
1698
- id: statement.id,
1699
- describe: statement.describe,
1700
- created: false
1701
- });
1702
- continue;
1703
- }
1704
- const rows = await client.query(statement.database, statement.exists.sql, statement.exists.values);
1705
- if (rows.length > 0) {
1706
- applied.push({
1707
- id: statement.id,
1708
- describe: statement.describe,
1709
- created: false
1710
- });
1711
- continue;
1712
- }
1713
- await client.query(statement.database, statement.create);
1714
- applied.push({
1715
- id: statement.id,
1716
- describe: statement.describe,
1717
- created: true
1718
- });
1719
- }
1720
- return applied;
1721
- }
1722
- /**
1723
- * What each bucket's open paths are, if anything serves it.
1724
- *
1725
- * Keyed by the *origin*, because that is where the policy lives: two servers
1726
- * over one bucket contribute to one policy, so the patterns are unioned rather
1727
- * than the last one winning.
1728
- */
1729
- function bucketPolicies(plan) {
1730
- const byBucket = /* @__PURE__ */ new Map();
1731
- for (const resource of plan.resources) {
1732
- if (resource.kind !== "file-server" || !resource.open?.length) continue;
1733
- const origin = plan.resources.find((r) => r.id === resource.of);
1734
- if (!origin) continue;
1735
- const patterns = byBucket.get(origin.name) ?? /* @__PURE__ */ new Set();
1736
- for (const pattern of resource.open) patterns.add(pattern);
1737
- byBucket.set(origin.name, patterns);
1738
- }
1739
- return [...byBucket].map(([bucket, open]) => ({
1740
- bucket,
1741
- open: [...open].sort()
1742
- })).sort((a, b) => a.bucket.localeCompare(b.bucket));
1743
- }
1744
- /**
1745
- * One bucket's open paths as an S3 bucket policy.
1746
- *
1747
- * Anonymous `s3:GetObject` on the named prefixes and nothing else — which is
1748
- * what "open" means everywhere: the server serves that path without a
1749
- * signature, and the bucket stays private for everything else.
1750
- *
1751
- * One fidelity note, stated rather than discovered: an S3 policy resource's `*`
1752
- * crosses `/`, so a single-star pattern is *wider* here than the construct's own
1753
- * runtime check, which stops at a segment boundary. The construct is the
1754
- * stricter of the two, so a key it refuses to serve unsigned is never one this
1755
- * policy was relied on to refuse — but a key fetched directly, bypassing the
1756
- * client, can be admitted by the policy where the client would have said no.
1757
- * Prefer `**` where crossing segments is what you meant.
1758
- */
1759
- function bucketPolicy(bucket, open) {
1760
- return JSON.stringify({
1761
- Version: "2012-10-17",
1762
- Statement: [{
1763
- Sid: "GkmOpenPaths",
1764
- Effect: "Allow",
1765
- Principal: { AWS: ["*"] },
1766
- Action: ["s3:GetObject"],
1767
- Resource: open.map((pattern) => `arn:aws:s3:::${bucket}/${pattern.replace(/\*\*/g, "*")}`)
1768
- }]
1769
- });
1770
- }
1771
- /**
1772
- * Apply each served bucket's open-path policy, skipping those already correct.
1773
- *
1774
- * Compared as parsed JSON rather than as text: the same policy re-serialised
1775
- * with different key order is the same policy, and rewriting it every reconcile
1776
- * would report a change on every start.
1777
- */
1778
- async function applyPolicies(client, policies) {
1779
- const applied = [];
1780
- for (const { bucket, open } of policies) {
1781
- const wanted = bucketPolicy(bucket, open);
1782
- const describe = `open paths on ${bucket}`;
1783
- if (equivalent(await client.policy(bucket), wanted)) {
1784
- applied.push({
1785
- id: `${bucket}:policy`,
1786
- describe,
1787
- created: false
1788
- });
1789
- continue;
1790
- }
1791
- await client.setPolicy(bucket, wanted);
1792
- applied.push({
1793
- id: `${bucket}:policy`,
1794
- describe,
1795
- created: true
1796
- });
1797
- }
1798
- return applied;
1799
- }
1800
- /** Whether two policy documents say the same thing. */
1801
- function equivalent(current, wanted) {
1802
- if (!current) return false;
1803
- try {
1804
- return JSON.stringify(JSON.parse(current)) === JSON.stringify(JSON.parse(wanted));
1805
- } catch {
1806
- return false;
1807
- }
1808
- }
1809
- /** Create every bucket the plan names, skipping those that exist. */
1810
- async function applyBuckets(client, buckets) {
1811
- const applied = [];
1812
- for (const bucket of buckets) {
1813
- if (await client.exists(bucket)) {
1814
- applied.push({
1815
- id: bucket,
1816
- describe: `bucket ${bucket}`,
1817
- created: false
1818
- });
1819
- continue;
1820
- }
1821
- await client.create(bucket);
1822
- applied.push({
1823
- id: bucket,
1824
- describe: `bucket ${bucket}`,
1825
- created: true
1826
- });
1827
- }
1828
- return applied;
1829
- }
1830
-
1831
- //#endregion
1832
- //#region src/reconcile/state.ts
1833
- const STATE_DIR = ".gkm/reconcile";
1834
- /**
1835
- * The hash of everything a reconcile would act on.
1836
- *
1837
- * Covers the compose document rather than the plan alone, because the plan is
1838
- * unchanged when only an image pin moves — and a changed image is exactly a
1839
- * container that must be recreated. `stringify` is stable here because
1840
- * `composeFor` sorts its containers, which is what makes the hash meaningful.
1841
- *
1842
- * Deliberately a plain function over serialisable input: the deployed target
1843
- * keys its provisioner invocation on the same idea, and the two must not be able
1844
- * to disagree about what counts as a change.
1845
- */
1846
- function planHash(plan, compose, generated = {}) {
1847
- return createHash("sha256").update(JSON.stringify({
1848
- stage: plan.stage,
1849
- plan,
1850
- compose,
1851
- generated
1852
- })).digest("hex");
1853
- }
1854
- /** Read the recorded state, or nothing if this stage has never reconciled. */
1855
- async function loadState(root, stage) {
1856
- try {
1857
- const raw = await readFile(statePath(root, stage), "utf-8");
1858
- const state = JSON.parse(raw);
1859
- return state.stage === stage ? state : void 0;
1860
- } catch {
1861
- return void 0;
1862
- }
1863
- }
1864
- /** Record what was applied, so the next run can skip it. */
1865
- async function saveState(root, state) {
1866
- const path = statePath(root, state.stage);
1867
- await mkdir(dirname(path), { recursive: true });
1868
- await writeFile(path, `${JSON.stringify(state, null, 2)}\n`);
1869
- }
1870
- function statePath(root, stage) {
1871
- return join(root, STATE_DIR, `${stage}.json`);
1872
- }
1873
-
1874
- //#endregion
1875
- //#region src/reconcile/index.ts
1876
- /**
1877
- * Where the generated compose file is written, relative to the project root.
1878
- *
1879
- * At the root, beside the project's own `docker-compose.yml`, because the two
1880
- * are one stack: this file is everything the constructs imply and is never
1881
- * edited, that one is anything they cannot express — an image pin, an extra
1882
- * service — and is merged over it, so it wins.
1883
- */
1884
- const COMPOSE_PATH = "docker-compose.constructs.yml";
1885
- /**
1886
- * The local edge's config, beside the compose file that mounts it.
1887
- *
1888
- * Relative in the compose volume, so it resolves against `.gkm/` wherever the
1889
- * project lives.
1890
- */
1891
- const CADDYFILE_PATH = ".gkm/Caddyfile";
1892
- /**
1893
- * Where one stage's routes live, imported by the file above.
1894
- *
1895
- * Per stage because one edge serves every stage, the same way one Postgres
1896
- * holds `orders` and `orders_test`. A single file would mean `gkm test`
1897
- * deleting the routes `gkm dev` is serving.
1898
- */
1899
- const caddySitesPath = (stage) => `.gkm/caddy-sites/${stage}.caddy`;
1900
- /**
1901
- * Where the local edge's root certificate is copied to.
1902
- *
1903
- * Exported so a process can be pointed at it without installing anything:
1904
- * `NODE_EXTRA_CA_CERTS` is the whole of the trust story for Node, and it needs
1905
- * no sudo. A browser is the case that still wants the root in the system store,
1906
- * which is a one-time `caddy trust` rather than something a reconcile should do
1907
- * on a developer's behalf.
1908
- */
1909
- const LOCAL_CA_PATH = ".gkm/caddy-root.crt";
1910
- /** Where Caddy keeps the root of the CA it generated. */
1911
- const CADDY_ROOT_IN_CONTAINER = "/data/caddy/pki/authorities/local/root.crt";
1912
- /**
1913
- * Converge the local target on what the manifest declares.
1914
- *
1915
- * Cheap when there is nothing to do: the hash is compared before the compose
1916
- * file is written or a container is touched, and a converged project pays one
1917
- * hash and one health check.
1918
- */
1919
- async function reconcile(options) {
1920
- const { root, project, manifest, stage, start = true, provision = true, docker = dockerCli, probe = isPortFree, sql = pgClient, buckets = bucketClient } = options;
1921
- const plan = planFor(manifest, stage, provisionOrder(manifest), {
1922
- localStage: options.localStage,
1923
- events: options.events,
1924
- cache: options.cache,
1925
- extraContainers: options.extraContainers,
1926
- ...options.edge === void 0 ? {} : { edge: options.edge }
1927
- });
1928
- const composePath = join(root, COMPOSE_PATH);
1929
- const observed = await observedPorts(docker, composePath, plan.containers);
1930
- const ports = await allocate(project, portKeys(plan.containers), {
1931
- ...options.saved,
1932
- ...observed
1933
- }, probe);
1934
- const compose = composeFor(plan, {
1935
- project,
1936
- ports,
1937
- ...options.apps ? { apps: options.apps(plan.containers) } : {}
1938
- });
1939
- const caddyfile = toCaddyfile(sitesFor(plan, project, options.addresses));
1940
- const hash = planHash(plan, compose, { caddyfile });
1941
- const addresses = addressesFor(plan.containers, ports);
1942
- const env = envFor(plan, {
1943
- ports,
1944
- project,
1945
- ...options.mailFrom ? { mailFrom: options.mailFrom } : {},
1946
- ...options.addresses ? { addresses: options.addresses } : {}
1947
- });
1948
- if (plan.containers.includes("caddy")) env.NODE_EXTRA_CA_CERTS = join(root, LOCAL_CA_PATH);
1949
- const result = {
1950
- stage,
1951
- plan,
1952
- compose,
1953
- ports,
1954
- addresses,
1955
- env,
1956
- provisioned: [],
1957
- hash,
1958
- changed: false
1959
- };
1960
- const recorded = await loadState(root, stage);
1961
- const converged = recorded?.hash === hash && existsSync(composePath) && (!start || await docker.healthy(composePath, plan.containers));
1962
- if (converged) return result;
1963
- await write(composePath, toYaml(compose));
1964
- if (plan.containers.includes("caddy")) {
1965
- await write(join(root, CADDYFILE_PATH), caddyfileRoot());
1966
- await write(join(root, caddySitesPath(stage)), caddyfile);
1967
- }
1968
- if (start && plan.containers.length > 0) await docker.up(composePath, plan.containers);
1969
- if (start && plan.containers.includes("caddy")) await docker.reload(composePath, "caddy").catch(() => {});
1970
- if (start && plan.containers.includes("caddy")) await docker.copyOut(composePath, "caddy", CADDY_ROOT_IN_CONTAINER, join(root, LOCAL_CA_PATH)).catch(() => {});
1971
- const provisioned = start && provision ? await create(plan, ports, sql, buckets, project) : [];
1972
- await saveState(root, {
1973
- hash,
1974
- stage
1975
- });
1976
- return {
1977
- ...result,
1978
- provisioned,
1979
- changed: true
1980
- };
1981
- }
1982
- /**
1983
- * Create the databases, schemas, and buckets the plan names.
1984
- *
1985
- * Idempotent throughout, so this runs on every non-converged reconcile rather
1986
- * than being something to remember.
1987
- */
1988
- async function create(plan, ports, sql, buckets, project) {
1989
- const applied = [];
1990
- const postgresPort = ports[primaryPortKey("postgres")];
1991
- const statements = postgresStatements(plan, project);
1992
- if (postgresPort !== void 0 && statements.length > 0) applied.push(...await applyPostgres(sql(postgresPort), statements));
1993
- const minioPort = ports[primaryPortKey("minio")];
1994
- const names = bucketNames(plan);
1995
- const policies = bucketPolicies(plan);
1996
- if (minioPort !== void 0 && (names.length > 0 || policies.length > 0)) {
1997
- const client = buckets(minioPort);
1998
- if (names.length > 0) applied.push(...await applyBuckets(client, names));
1999
- if (policies.length > 0) applied.push(...await applyPolicies(client, policies));
2000
- }
2001
- return applied;
2002
- }
2003
- /**
2004
- * The host ports of containers already running.
2005
- *
2006
- * Keyed the same way allocation keys them, so the two merge without either
2007
- * knowing about the other.
2008
- */
2009
- async function observedPorts(docker, composePath, containers) {
2010
- const observed = {};
2011
- for (const container of containers) for (const port of portsOf(container)) {
2012
- const running = await docker.publishedPort(composePath, container, port.inside);
2013
- if (running !== void 0) observed[port.key] = running;
2014
- }
2015
- return observed;
2016
- }
2017
- /**
2018
- * Where each container can be reached on this machine.
2019
- *
2020
- * The primary port only — a container's console is for a human to open, not
2021
- * something an app connects to.
2022
- */
2023
- function addressesFor(containers, ports) {
2024
- const addresses = {};
2025
- for (const container of containers) {
2026
- const port = ports[primaryPortKey(container)];
2027
- if (port !== void 0) addresses[container] = `localhost:${port}`;
2028
- }
2029
- return addresses;
2030
- }
2031
- /** Write a file only when its content would change, so mtimes stay meaningful. */
2032
- async function write(path, content) {
2033
- try {
2034
- if (await readFile(path, "utf-8") === content) return;
2035
- } catch {}
2036
- await mkdir(dirname(path), { recursive: true });
2037
- await writeFile(path, content);
2038
- }
2039
-
2040
- //#endregion
2041
- //#region src/reconcile/workspace.ts
2042
- /**
2043
- * Every constructs glob in the workspace, resolved against its app.
2044
- *
2045
- * Absolute because discovery globs from a single cwd while apps live in
2046
- * different directories.
2047
- */
2048
- function constructGlobs(workspace) {
2049
- return allConstructGlobs(workspace);
2050
- }
2051
- /** Whether any app has adopted the constructs glob. */
2052
- function usesConstructs(workspace) {
2053
- return constructGlobs(workspace).length > 0;
2054
- }
2055
- /** The backends a workspace's target implies, as the plan takes them. */
2056
- function backendsOf(workspace) {
2057
- const on = providerOf(workspace);
2058
- return {
2059
- events: eventsBackendFor(on),
2060
- cache: cacheBackendFor(on)
2061
- };
2062
- }
2063
- /**
2064
- * The containers a workspace's declarations imply, without reconciling.
2065
- *
2066
- * The same derivation `reconcileWorkspace` makes, available to callers that
2067
- * need to know *what would run* without starting anything or writing ports —
2068
- * `gkm setup` deciding which credentials to generate, `gkm docker` writing a
2069
- * compose file. Those used to each read a boolean per service out of config,
2070
- * which is how a container could exist because config asked for one rather than
2071
- * because something declared it.
2072
- */
2073
- async function derivedContainers(workspace, stage, manifest) {
2074
- const found = manifest ?? await discover({
2075
- patterns: constructGlobs(workspace),
2076
- cwd: workspace.root
2077
- });
2078
- return planFor(found, stage, provisionOrder(found), {
2079
- localStage: workspace.stages.local,
2080
- ...backendsOf(workspace)
2081
- }).containers;
2082
- }
2083
- /**
2084
- * Reconcile a workspace for one stage.
2085
- *
2086
- * Ports are loaded and saved around the call rather than inside it, so the loop
2087
- * stays a pure-ish function of its inputs and the store keeps its single owner.
2088
- */
2089
- async function reconcileWorkspace(workspace, options) {
2090
- const manifest = options.manifest ?? await discover({
2091
- patterns: constructGlobs(workspace),
2092
- cwd: workspace.root
2093
- });
2094
- const result = await reconcile({
2095
- root: workspace.root,
2096
- project: workspace.name,
2097
- manifest,
2098
- stage: options.stage,
2099
- localStage: workspace.stages.local,
2100
- ...backendsOf(workspace),
2101
- saved: await loadPortState(workspace.root),
2102
- addresses: surfaceAddresses(workspace, manifest),
2103
- apps: (containers) => appServices(workspace, manifest, containers),
2104
- ...options.start === void 0 ? {} : { start: options.start }
2105
- });
2106
- await savePortState(workspace.root, { ...result.ports });
2107
- return result;
2108
- }
2109
- /**
2110
- * Where each declared surface and site answers locally.
2111
- *
2112
- * The addresses come from the ports the workspace already assigns; which
2113
- * construct sits at which one comes from the manifest. That split is the point:
2114
- * this used to answer "who may call whom" by listing every app the workspace
2115
- * runs, which is a different question that happened to give the same answer in
2116
- * a single-repo workspace and no answer at all deployed. Now it answers only
2117
- * "where does this construct answer", and the graph answers the rest.
2118
- *
2119
- * A site is matched to its app by `path`, because that is the one thing a site
2120
- * declaration and a workspace app both name. Surfaces are matched to the
2121
- * backend app: every `rest-api` in a process answers on that process's port, so
2122
- * an app serving both its own API and an auth server publishes one address
2123
- * twice — which is exactly what it does at runtime.
2124
- */
2125
- function surfaceAddresses(workspace, manifest, at = (_app, port) => localAddress(port)) {
2126
- const addresses = {};
2127
- for (const [id, declaration] of Object.entries(manifest)) {
2128
- if (declaration.kind !== "rest-api" && declaration.kind !== "site") continue;
2129
- const host = declaration.kind === "site" ? appKey(id) : appKeyOfHost(manifest, id);
2130
- const app = host ? workspace.apps[host] : void 0;
2131
- if (host && app?.port) addresses[id] = at(host, app.port);
2132
- }
2133
- return addresses;
2134
- }
2135
- /** The app key serving a surface, following a mount to its host. */
2136
- function appKeyOfHost(manifest, id) {
2137
- const host = hostOf(manifest, id);
2138
- return host ? appKey(host) : void 0;
2139
- }
2140
- /** Where a local process answers, given the port the workspace gave it. */
2141
- function localAddress(port) {
2142
- return `http://localhost:${port}`;
2143
- }
2144
-
2145
- //#endregion
2146
- //#region src/credentials/index.ts
2147
- const logger = console;
2148
- /**
2149
- * Load environment files
2150
- * @internal Exported for testing
2151
- */
2152
- function loadEnvFiles(envConfig, cwd = process.cwd()) {
2153
- const loaded = [];
2154
- const missing = [];
2155
- const envFiles = envConfig ? Array.isArray(envConfig) ? envConfig : [envConfig] : [".env"];
2156
- for (const envFile of envFiles) {
2157
- const envPath = resolve(cwd, envFile);
2158
- if (existsSync(envPath)) {
2159
- config({
2160
- path: envPath,
2161
- override: true,
2162
- quiet: true
2163
- });
2164
- loaded.push(envFile);
2165
- } else if (envConfig) missing.push(envFile);
2166
- }
2167
- return {
2168
- loaded,
2169
- missing
2170
- };
2171
- }
2172
- /**
2173
- * Check if a port is available
2174
- * @internal Exported for testing
2175
- */
2176
- async function isPortAvailable(port) {
2177
- return new Promise((resolve$1) => {
2178
- const server = createServer();
2179
- server.once("error", (err) => {
2180
- if (err.code === "EADDRINUSE") resolve$1(false);
2181
- else resolve$1(false);
2182
- });
2183
- server.once("listening", () => {
2184
- server.close();
2185
- resolve$1(true);
2186
- });
2187
- server.listen(port);
2188
- });
2189
- }
2190
- /**
2191
- * Find an available port starting from the preferred port
2192
- * @internal Exported for testing
2193
- */
2194
- async function findAvailablePort(preferredPort, maxAttempts = 10) {
2195
- for (let i = 0; i < maxAttempts; i++) {
2196
- const port = preferredPort + i;
2197
- if (await isPortAvailable(port)) return port;
2198
- logger.log(`⚠️ Port ${port} is in use, trying ${port + 1}...`);
2199
- }
2200
- throw new Error(`Could not find an available port after trying ${maxAttempts} ports starting from ${preferredPort}`);
2201
- }
2202
- const PORT_STATE_PATH = ".gkm/ports.json";
2203
- /**
2204
- * Parse docker-compose.yml and extract all port mappings that use env var interpolation.
2205
- * Entries like `'${POSTGRES_HOST_PORT:-5432}:5432'` are captured.
2206
- * Fixed port mappings like `'5050:80'` are skipped.
2207
- * @internal Exported for testing
2208
- */
2209
- function parseComposePortMappings(composePath) {
2210
- if (!existsSync(composePath)) return [];
2211
- const content = readFileSync(composePath, "utf-8");
2212
- const compose = parse$1(content);
2213
- if (!compose?.services) return [];
2214
- const results = [];
2215
- for (const [serviceName, serviceConfig] of Object.entries(compose.services)) for (const portMapping of serviceConfig?.ports ?? []) {
2216
- const match = String(portMapping).match(/\$\{(\w+):-(\d+)\}:(\d+)/);
2217
- if (match?.[1] && match[2] && match[3]) results.push({
2218
- service: serviceName,
2219
- envVar: match[1],
2220
- defaultPort: Number(match[2]),
2221
- containerPort: Number(match[3])
2222
- });
2223
- }
2224
- return results;
2225
- }
2226
- /**
2227
- * Load saved port state from .gkm/ports.json.
2228
- * @internal Exported for testing
2229
- */
2230
- async function loadPortState(workspaceRoot) {
2231
- try {
2232
- const raw = await readFile(join(workspaceRoot, PORT_STATE_PATH), "utf-8");
2233
- return JSON.parse(raw);
2234
- } catch {
2235
- return {};
2236
- }
2237
- }
2238
- /**
2239
- * Save port state to .gkm/ports.json.
2240
- * @internal Exported for testing
2241
- */
2242
- async function savePortState(workspaceRoot, ports) {
2243
- const dir = join(workspaceRoot, ".gkm");
2244
- await mkdir(dir, { recursive: true });
2245
- await writeFile(join(workspaceRoot, PORT_STATE_PATH), `${JSON.stringify(ports, null, 2)}\n`);
2246
- }
2247
- /**
2248
- * Check if a project's own Docker container is running and return its host port.
2249
- * Uses `docker compose port` scoped to the project's compose file.
2250
- * @internal Exported for testing
2251
- */
2252
- function getContainerHostPort(workspaceRoot, service, containerPort) {
2253
- try {
2254
- const result = execSync(`docker compose port ${service} ${containerPort}`, {
2255
- cwd: workspaceRoot,
2256
- stdio: "pipe"
2257
- }).toString().trim();
2258
- const match = result.match(/:(\d+)$/);
2259
- return match ? Number(match[1]) : null;
2260
- } catch {
2261
- return null;
2262
- }
2263
- }
2264
- /**
2265
- * Resolve host ports for Docker services by parsing docker-compose.yml.
2266
- * Priority: running container → saved state → find available port.
2267
- * Persists resolved ports to .gkm/ports.json.
2268
- * @internal Exported for testing
2269
- */
2270
- async function resolveServicePorts(workspaceRoot) {
2271
- const composePath = join(workspaceRoot, "docker-compose.yml");
2272
- const mappings = parseComposePortMappings(composePath);
2273
- if (mappings.length === 0) return {
2274
- dockerEnv: {},
2275
- ports: {},
2276
- mappings: []
2277
- };
2278
- const savedState = await loadPortState(workspaceRoot);
2279
- const dockerEnv = {};
2280
- const ports = {};
2281
- const assignedPorts = /* @__PURE__ */ new Set();
2282
- logger.log("\n🔌 Resolving service ports...");
2283
- for (const mapping of mappings) {
2284
- const containerPort = getContainerHostPort(workspaceRoot, mapping.service, mapping.containerPort);
2285
- if (containerPort !== null) {
2286
- ports[mapping.envVar] = containerPort;
2287
- dockerEnv[mapping.envVar] = String(containerPort);
2288
- assignedPorts.add(containerPort);
2289
- logger.log(` 🔄 ${mapping.service}:${mapping.containerPort}: reusing existing container on port ${containerPort}`);
2290
- continue;
2291
- }
2292
- const savedPort = savedState[mapping.envVar];
2293
- if (savedPort && !assignedPorts.has(savedPort) && await isPortAvailable(savedPort)) {
2294
- ports[mapping.envVar] = savedPort;
2295
- dockerEnv[mapping.envVar] = String(savedPort);
2296
- assignedPorts.add(savedPort);
2297
- logger.log(` 💾 ${mapping.service}:${mapping.containerPort}: using saved port ${savedPort}`);
2298
- continue;
2299
- }
2300
- let resolvedPort = await findAvailablePort(mapping.defaultPort);
2301
- while (assignedPorts.has(resolvedPort)) resolvedPort = await findAvailablePort(resolvedPort + 1);
2302
- ports[mapping.envVar] = resolvedPort;
2303
- dockerEnv[mapping.envVar] = String(resolvedPort);
2304
- assignedPorts.add(resolvedPort);
2305
- if (resolvedPort !== mapping.defaultPort) logger.log(` ⚡ ${mapping.service}:${mapping.containerPort}: port ${mapping.defaultPort} occupied, using port ${resolvedPort}`);
2306
- else logger.log(` ✅ ${mapping.service}:${mapping.containerPort}: using default port ${resolvedPort}`);
2307
- }
2308
- await savePortState(workspaceRoot, ports);
2309
- return {
2310
- dockerEnv,
2311
- ports,
2312
- mappings
2313
- };
2314
- }
2315
- /**
2316
- * Replace a port in a URL string.
2317
- * Handles both `hostname:port` and `localhost:port` patterns.
2318
- * @internal Exported for testing
2319
- */
2320
- function replacePortInUrl(url, oldPort, newPort) {
2321
- if (oldPort === newPort) return url;
2322
- let result = url.replace(new RegExp(`:${oldPort}(?=[/?#]|$)`, "g"), `:${newPort}`);
2323
- result = result.replace(new RegExp(`%3A${oldPort}(?=[%/?#&]|$)`, "gi"), `%3A${newPort}`);
2324
- return result;
2325
- }
2326
- /**
2327
- * Rewrite connection URLs and port vars in secrets with resolved ports.
2328
- * Uses the parsed compose mappings to determine which default ports to replace.
2329
- * Pure transform — does not modify secrets on disk.
2330
- * @internal Exported for testing
2331
- */
2332
- function rewriteUrlsWithPorts(secrets, resolvedPorts) {
2333
- const { ports, mappings } = resolvedPorts;
2334
- const result = { ...secrets };
2335
- const portReplacements = [];
2336
- const serviceNames = /* @__PURE__ */ new Set();
2337
- for (const mapping of mappings) {
2338
- serviceNames.add(mapping.service);
2339
- const resolved = ports[mapping.envVar];
2340
- if (resolved !== void 0) portReplacements.push({
2341
- defaultPort: mapping.defaultPort,
2342
- resolvedPort: resolved
2343
- });
2344
- }
2345
- for (const [key, value] of Object.entries(result)) {
2346
- if (!key.endsWith("_HOST")) continue;
2347
- if (serviceNames.has(value)) result[key] = "localhost";
2348
- }
2349
- for (const [key, value] of Object.entries(result)) {
2350
- if (!key.endsWith("_PORT")) continue;
2351
- for (const { defaultPort, resolvedPort } of portReplacements) if (value === String(defaultPort)) result[key] = String(resolvedPort);
2352
- }
2353
- for (const [key, value] of Object.entries(result)) {
2354
- if (!key.endsWith("_URL") && !key.endsWith("_ENDPOINT") && !key.endsWith("_CONNECTION_STRING") && key !== "DATABASE_URL") continue;
2355
- let rewritten = value;
2356
- for (const name of serviceNames) rewritten = rewritten.replace(new RegExp(`@${name}:`, "g"), "@localhost:");
2357
- for (const { defaultPort, resolvedPort } of portReplacements) rewritten = replacePortInUrl(rewritten, defaultPort, resolvedPort);
2358
- result[key] = rewritten;
2359
- }
2360
- return result;
2361
- }
2362
- /**
2363
- * Build the environment variables to pass to `docker compose up`.
2364
- * Merges process.env, secrets, and port mappings so that Docker Compose
2365
- * can interpolate variables like ${POSTGRES_USER} correctly.
2366
- * @internal Exported for testing
2367
- */
2368
- function buildDockerComposeEnv(secretsEnv, portEnv) {
2369
- return {
2370
- ...process.env,
2371
- ...secretsEnv,
2372
- ...portEnv
2373
- };
2374
- }
2375
- /**
2376
- * Parse all service names from a docker-compose.yml file.
2377
- * @internal Exported for testing
2378
- */
2379
- function parseComposeServiceNames(composePath) {
2380
- if (!existsSync(composePath)) return [];
2381
- const content = readFileSync(composePath, "utf-8");
2382
- const compose = parse$1(content);
2383
- return Object.keys(compose?.services ?? {});
2384
- }
2385
- /**
2386
- * Start docker-compose services for a single-app project (no workspace config).
2387
- * Starts all services defined in docker-compose.yml.
2388
- */
2389
- async function startComposeServices(cwd, portEnv, secretsEnv) {
2390
- const composeFile = join(cwd, "docker-compose.yml");
2391
- if (!existsSync(composeFile)) return;
2392
- const servicesToStart = parseComposeServiceNames(composeFile);
2393
- if (servicesToStart.length === 0) return;
2394
- logger.log(`🐳 Starting services: ${servicesToStart.join(", ")}`);
2395
- try {
2396
- execSync(`docker compose up -d ${servicesToStart.join(" ")}`, {
2397
- cwd,
2398
- stdio: "inherit",
2399
- env: buildDockerComposeEnv(secretsEnv, portEnv)
2400
- });
2401
- logger.log("✅ Services started");
2402
- } catch (error) {
2403
- logger.error("❌ Failed to start services:", error.message);
2404
- throw error;
2405
- }
2406
- }
2407
- /**
2408
- * Start docker-compose services for a workspace.
2409
- * Discovers all services from docker-compose.yml and starts everything
2410
- * except app services (which are managed by turbo).
2411
- * @internal Exported for testing
2412
- */
2413
- async function startWorkspaceServices(workspace, portEnv, secretsEnv) {
2414
- const composeFile = join(workspace.root, "docker-compose.yml");
2415
- if (!existsSync(composeFile)) return;
2416
- const allServices = parseComposeServiceNames(composeFile);
2417
- const appNames = new Set(Object.keys(workspace.apps));
2418
- const servicesToStart = allServices.filter((name) => !appNames.has(name));
2419
- if (servicesToStart.length === 0) return;
2420
- logger.log(`🐳 Starting services: ${servicesToStart.join(", ")}`);
2421
- try {
2422
- execSync(`docker compose up -d ${servicesToStart.join(" ")}`, {
2423
- cwd: workspace.root,
2424
- stdio: "inherit",
2425
- env: buildDockerComposeEnv(secretsEnv, portEnv)
2426
- });
2427
- logger.log("✅ Services started");
2428
- } catch (error) {
2429
- logger.error("❌ Failed to start services:", error.message);
2430
- throw error;
2431
- }
2432
- }
2433
- /**
2434
- * Load and flatten secrets for an app from encrypted storage.
2435
- * For workspace app: maps {APP}_DATABASE_URL → DATABASE_URL.
2436
- * @internal Exported for testing
2437
- */
2438
- async function loadSecretsForApp(secretsRoot, stage, appName) {
2439
- let secrets = {};
2440
- if (secretsExist(stage, secretsRoot)) {
2441
- const stageSecrets = await readStageSecrets(stage, secretsRoot);
2442
- if (stageSecrets) {
2443
- logger.log(`🔐 Loading secrets from stage: ${stage}`);
2444
- secrets = toEmbeddableSecrets(stageSecrets);
2445
- }
2446
- }
2447
- if (Object.keys(secrets).length === 0) return {};
2448
- if (!appName) return secrets;
2449
- const prefix = appName.toUpperCase();
2450
- const mapped = { ...secrets };
2451
- const appDbUrl = secrets[`${prefix}_DATABASE_URL`];
2452
- if (appDbUrl) mapped.DATABASE_URL = appDbUrl;
2453
- return mapped;
2454
- }
2455
- /**
2456
- * Walk up the directory tree to find the root containing .gkm/secrets/.
2457
- * @internal Exported for testing
2458
- */
2459
- function findSecretsRoot(startDir) {
2460
- let dir = startDir;
2461
- while (dir !== "/") {
2462
- if (existsSync(join(dir, ".gkm", "secrets"))) return dir;
2463
- const parent = dirname(dir);
2464
- if (parent === dir) break;
2465
- dir = parent;
2466
- }
2467
- return startDir;
2468
- }
2469
- /**
2470
- * Generate the credentials injection code snippet.
2471
- * This is the common logic used by both entry wrapper and exec preload.
2472
- * @internal
2473
- */
2474
- function generateCredentialsInjection(secretsJsonPath) {
2475
- return `import { existsSync, readFileSync } from 'node:fs';
2476
-
2477
- // Inject dev secrets via globalThis and process.env
2478
- // Using globalThis.__gkm_credentials__ avoids CJS/ESM interop issues where
2479
- // Object.assign on the Credentials export only mutates one module copy.
2480
- const secretsPath = '${secretsJsonPath}';
2481
- if (existsSync(secretsPath)) {
2482
- const secrets = JSON.parse(readFileSync(secretsPath, 'utf-8'));
2483
- globalThis.__gkm_credentials__ = secrets;
2484
- Object.assign(process.env, secrets);
2485
- }
2486
- `;
2487
- }
2488
- /**
2489
- * Create a preload script that injects secrets into Credentials.
2490
- * Used by `gkm exec` to inject secrets before running any command.
2491
- * @internal Exported for testing
2492
- */
2493
- async function createCredentialsPreload(preloadPath, secretsJsonPath) {
2494
- const content = `/**
2495
- * Credentials preload generated by 'gkm exec'
2496
- * This file is loaded via NODE_OPTIONS="--import <path>"
2497
- */
2498
- ${generateCredentialsInjection(secretsJsonPath)}`;
2499
- await writeFile(preloadPath, content);
2500
- }
2501
- /**
2502
- * Create a wrapper script that injects secrets before importing the entry file.
2503
- * @internal Exported for testing
2504
- */
2505
- async function createEntryWrapper(wrapperPath, entryPath, secretsJsonPath) {
2506
- const credentialsInjection = secretsJsonPath ? `${generateCredentialsInjection(secretsJsonPath)}
2507
- ` : "";
2508
- const content = `#!/usr/bin/env node
2509
- /**
2510
- * Entry wrapper generated by 'gkm dev --entry'
2511
- */
2512
- ${credentialsInjection}// Import and run the user's entry file (dynamic import ensures secrets load first)
2513
- await import('${entryPath}');
2514
- `;
2515
- await writeFile(wrapperPath, content);
2516
- }
2517
- /**
2518
- * Prepare credentials for dev/exec/test modes.
2519
- * Loads workspace config, secrets, resolves Docker ports, rewrites URLs,
2520
- * injects PORT, dependency URLs, and writes credentials JSON.
2521
- *
2522
- * @param options.resolveDockerPorts - How to resolve Docker ports:
2523
- * - `'full'` (default): probe running containers, saved state, then find available ports. Used by dev/test.
2524
- * - `'readonly'`: check running containers and saved state only, never probe for new ports. Used by exec.
2525
- * @param options.stage - The stage whose secrets to load. Default: the project's `stages.local`.
2526
- * @param options.startDocker - Start Docker Compose services after port resolution. Default: false.
2527
- * @param options.secretsFileName - Custom secrets JSON filename. Default: 'dev-secrets-{appName}.json' or 'dev-secrets.json'.
2528
- * @internal Exported for testing
2529
- */
2530
- async function prepareEntryCredentials(options) {
2531
- const cwd = options.cwd ?? process.cwd();
2532
- const portMode = options.resolveDockerPorts ?? "full";
2533
- let workspaceAppPort;
2534
- let secretsRoot = cwd;
2535
- let appName;
2536
- let appInfo;
2537
- try {
2538
- appInfo = await loadWorkspaceAppInfo(cwd);
2539
- workspaceAppPort = appInfo.app.port;
2540
- secretsRoot = appInfo.workspaceRoot;
2541
- appName = appInfo.appName;
2542
- } catch {
2543
- secretsRoot = findSecretsRoot(cwd);
2544
- appName = getAppNameFromCwd(cwd) ?? void 0;
2545
- }
2546
- const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
2547
- const stage = options.stage ?? appInfo?.workspace.stages.local;
2548
- const credentials = stage ? await loadSecretsForApp(secretsRoot, stage, appName) : {};
2549
- credentials.PORT = String(resolvedPort);
2550
- const declaredKeys = [];
2551
- if (appInfo && usesConstructs(appInfo.workspace)) {
2552
- const { reconcileWorkspace: reconcileWorkspace$1 } = await import("./workspace-CkJAtRIX.mjs");
2553
- const reconciled = await reconcileWorkspace$1(appInfo.workspace, {
2554
- stage: options.reconcileStage ?? appInfo.workspace.stages.local,
2555
- start: options.startDocker ?? false
2556
- });
2557
- Object.assign(credentials, reconciled.env);
2558
- declaredKeys.push(...Object.keys(reconciled.env));
2559
- if (Object.keys(reconciled.env).length > 0) logger.log(`🔌 Resolved ${Object.keys(reconciled.env).length} declared URL(s)`);
2560
- } else {
2561
- const composePath = join(secretsRoot, "docker-compose.yml");
2562
- const mappings = parseComposePortMappings(composePath);
2563
- if (mappings.length > 0) {
2564
- let resolvedPorts;
2565
- if (portMode === "full") resolvedPorts = await resolveServicePorts(secretsRoot);
2566
- else {
2567
- const savedPorts = await loadPortState(secretsRoot);
2568
- const ports = {};
2569
- for (const mapping of mappings) {
2570
- const containerPort = getContainerHostPort(secretsRoot, mapping.service, mapping.containerPort);
2571
- if (containerPort !== null) ports[mapping.envVar] = containerPort;
2572
- else {
2573
- const saved = savedPorts[mapping.envVar];
2574
- if (saved !== void 0) ports[mapping.envVar] = saved;
2575
- }
2576
- }
2577
- resolvedPorts = {
2578
- dockerEnv: {},
2579
- ports,
2580
- mappings
2581
- };
2582
- }
2583
- if (options.startDocker) if (appInfo) await startWorkspaceServices(appInfo.workspace, resolvedPorts.dockerEnv, credentials);
2584
- else await startComposeServices(secretsRoot, resolvedPorts.dockerEnv, credentials);
2585
- if (Object.keys(resolvedPorts.ports).length > 0) {
2586
- const rewritten = rewriteUrlsWithPorts(credentials, resolvedPorts);
2587
- Object.assign(credentials, rewritten);
2588
- logger.log(`🔌 Applied ${Object.keys(resolvedPorts.ports).length} port mapping(s)`);
2589
- }
2590
- }
2591
- }
2592
- if (appInfo?.appName) {
2593
- const depEnv = getDependencyEnvVars(appInfo.workspace, appInfo.appName);
2594
- Object.assign(credentials, depEnv);
2595
- }
2596
- if (!credentials.EVENT_PUBLISHER_CONNECTION_STRING && !credentials.EVENT_SUBSCRIBER_CONNECTION_STRING && credentials.PGBOSS_DB_USER) {
2597
- const pgbossUrl = generatePgBossUrl({
2598
- username: credentials.PGBOSS_DB_USER,
2599
- password: credentials.PGBOSS_DB_PASSWORD ?? "",
2600
- host: credentials.POSTGRES_HOST ?? "localhost",
2601
- port: Number(credentials.POSTGRES_PORT ?? "5432"),
2602
- database: credentials.POSTGRES_DB ?? "app"
2603
- });
2604
- credentials.EVENT_PUBLISHER_CONNECTION_STRING = pgbossUrl;
2605
- credentials.EVENT_SUBSCRIBER_CONNECTION_STRING = pgbossUrl;
2606
- }
2607
- const secretsDir = join(secretsRoot, ".gkm");
2608
- await mkdir(secretsDir, { recursive: true });
2609
- const secretsFileName = options.secretsFileName ?? (appName ? `dev-secrets-${appName}.json` : "dev-secrets.json");
2610
- const secretsJsonPath = join(secretsDir, secretsFileName);
2611
- await writeFile(secretsJsonPath, JSON.stringify(credentials, null, 2));
2612
- return {
2613
- credentials,
2614
- resolvedPort,
2615
- secretsJsonPath,
2616
- appName,
2617
- secretsRoot,
2618
- appInfo,
2619
- declaredKeys
2620
- };
2621
- }
2622
-
2623
- //#endregion
2624
- export { COMPOSE_PATH, LOCAL_CA_PATH, applyPostgres, backendsOf, cacheBackendFor, constructGlobs, createCredentialsPreload, createEntryWrapper, derivedContainers, eventsBackendFor, findAvailablePort, isPortAvailable, loadEnvFiles, loadSecretsForApp, prepareEntryCredentials, providerOf, reconcileWorkspace, resolveServicePorts, resourceName, rewriteUrlsWithPorts, startWorkspaceServices, storageBackendFor, surfaceAddresses, usesConstructs };
2625
- //# sourceMappingURL=credentials-jMJC63qs.mjs.map