@geekmidas/cli 10.0.0-alpha.11 → 10.0.0-alpha.111

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