@geekmidas/cli 10.0.0-alpha.9 → 10.0.0-alpha.91

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 (457) 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-CVc6Oi1Y.mjs +1021 -0
  7. package/dist/EndpointGenerator-CVc6Oi1Y.mjs.map +1 -0
  8. package/dist/EndpointGenerator-CwLjBCFE.cjs +1080 -0
  9. package/dist/EndpointGenerator-CwLjBCFE.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-DSStJVAv.mjs +387 -0
  11. package/dist/GoDaddyProvider-DSStJVAv.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DqZ1qD_F.cjs +387 -0
  13. package/dist/GoDaddyProvider-DqZ1qD_F.cjs.map +1 -0
  14. package/dist/{HostingerProvider-Cft7lEYr.mjs → HostingerProvider-BI6J7oJr.mjs} +22 -23
  15. package/dist/HostingerProvider-BI6J7oJr.mjs.map +1 -0
  16. package/dist/{HostingerProvider-h3EbEp-Z.cjs → HostingerProvider-CyTpG_jy.cjs} +22 -23
  17. package/dist/HostingerProvider-CyTpG_jy.cjs.map +1 -0
  18. package/dist/LegacyStateStore-DXmNA7hy.cjs +89 -0
  19. package/dist/LegacyStateStore-DXmNA7hy.cjs.map +1 -0
  20. package/dist/LegacyStateStore-ZkdmiUFZ.mjs +89 -0
  21. package/dist/LegacyStateStore-ZkdmiUFZ.mjs.map +1 -0
  22. package/dist/LocalStateStore-BBeTlRTH.cjs +178 -0
  23. package/dist/LocalStateStore-BBeTlRTH.cjs.map +1 -0
  24. package/dist/LocalStateStore-CU-O0SBp.mjs +167 -0
  25. package/dist/LocalStateStore-CU-O0SBp.mjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-B--HV-sW.cjs +541 -0
  27. package/dist/OpenApiTsGenerator-B--HV-sW.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-CkvsPdgg.mjs +536 -0
  29. package/dist/OpenApiTsGenerator-CkvsPdgg.mjs.map +1 -0
  30. package/dist/{Route53Provider-di2fMM5N.cjs → Route53Provider-Bllus2NR.cjs} +21 -22
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-RdpUDJQk.mjs → Route53Provider-QXxjkZO1.mjs} +13 -13
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-Br8VMY22.cjs +160 -0
  35. package/dist/S3StateStore-Br8VMY22.cjs.map +1 -0
  36. package/dist/S3StateStore-bwxcI_wQ.mjs +161 -0
  37. package/dist/S3StateStore-bwxcI_wQ.mjs.map +1 -0
  38. package/dist/SSMStateStore-CsOS0W1y.mjs +154 -0
  39. package/dist/SSMStateStore-CsOS0W1y.mjs.map +1 -0
  40. package/dist/SSMStateStore-DoZE1Wi1.cjs +153 -0
  41. package/dist/SSMStateStore-DoZE1Wi1.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-BPqQf8fB.mjs +448 -0
  43. package/dist/SubscriberGenerator-BPqQf8fB.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-BVn7cQ-2.cjs +489 -0
  45. package/dist/SubscriberGenerator-BVn7cQ-2.cjs.map +1 -0
  46. package/dist/add-BSHk5Ngn.mjs +747 -0
  47. package/dist/add-BSHk5Ngn.mjs.map +1 -0
  48. package/dist/add-DmmBDV2e.cjs +749 -0
  49. package/dist/add-DmmBDV2e.cjs.map +1 -0
  50. package/dist/appPorts-C9z9Pzn9.mjs +223 -0
  51. package/dist/appPorts-C9z9Pzn9.mjs.map +1 -0
  52. package/dist/appPorts-Cu79hJF6.cjs +264 -0
  53. package/dist/appPorts-Cu79hJF6.cjs.map +1 -0
  54. package/dist/aws-B-6uEhgP.mjs +71 -0
  55. package/dist/aws-B-6uEhgP.mjs.map +1 -0
  56. package/dist/aws-BTawF0F-.cjs +82 -0
  57. package/dist/aws-BTawF0F-.cjs.map +1 -0
  58. package/dist/awsStore-7VmS_cZR.cjs +54 -0
  59. package/dist/awsStore-7VmS_cZR.cjs.map +1 -0
  60. package/dist/awsStore-B529csle.mjs +43 -0
  61. package/dist/awsStore-B529csle.mjs.map +1 -0
  62. package/dist/{backup-provisioner-Bgj5Vi_L.mjs → backup-provisioner-C8DnCmxK.mjs} +11 -8
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-BrsHwYG0.cjs → backup-provisioner-oDEsPj02.cjs} +22 -20
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/{bundler-BY1OmV1e.cjs → bundler-BQJiB7Ub.cjs} +38 -35
  67. package/dist/bundler-BQJiB7Ub.cjs.map +1 -0
  68. package/dist/{bundler-Be8Zg4Wd.mjs → bundler-D6eBfVkl.mjs} +36 -32
  69. package/dist/bundler-D6eBfVkl.mjs.map +1 -0
  70. package/dist/cli-BE9mqeX8.cjs +69 -0
  71. package/dist/cli-BE9mqeX8.cjs.map +1 -0
  72. package/dist/cli-DD-Yk-I5.mjs +69 -0
  73. package/dist/cli-DD-Yk-I5.mjs.map +1 -0
  74. package/dist/compose-Bhmf0n4o.mjs +3140 -0
  75. package/dist/compose-Bhmf0n4o.mjs.map +1 -0
  76. package/dist/compose-CvpU6ooi.cjs +3265 -0
  77. package/dist/compose-CvpU6ooi.cjs.map +1 -0
  78. package/dist/config-CdEcTrjG.d.mts +269 -0
  79. package/dist/config-CdEcTrjG.d.mts.map +1 -0
  80. package/dist/config-pST7E0CS.d.cts +269 -0
  81. package/dist/config-pST7E0CS.d.cts.map +1 -0
  82. package/dist/config.cjs +420 -11
  83. package/dist/config.cjs.map +1 -0
  84. package/dist/config.d.cts +4 -120
  85. package/dist/config.d.mts +4 -120
  86. package/dist/config.mjs +404 -4
  87. package/dist/config.mjs.map +1 -0
  88. package/dist/credentialSchemas-BJqRJNK4.mjs +236 -0
  89. package/dist/credentialSchemas-BJqRJNK4.mjs.map +1 -0
  90. package/dist/credentialSchemas-DCR4Wd1W.cjs +271 -0
  91. package/dist/credentialSchemas-DCR4Wd1W.cjs.map +1 -0
  92. package/dist/credentials-BKfIugu2.cjs +513 -0
  93. package/dist/credentials-BKfIugu2.cjs.map +1 -0
  94. package/dist/credentials-CnVqoXMb.mjs +388 -0
  95. package/dist/credentials-CnVqoXMb.mjs.map +1 -0
  96. package/dist/databases-BY-pEImp.cjs +597 -0
  97. package/dist/databases-BY-pEImp.cjs.map +1 -0
  98. package/dist/databases-CzszQV0N.mjs +494 -0
  99. package/dist/databases-CzszQV0N.mjs.map +1 -0
  100. package/dist/define-DR8xGYfL.mjs +97 -0
  101. package/dist/define-DR8xGYfL.mjs.map +1 -0
  102. package/dist/define-DzRz8FgH.cjs +144 -0
  103. package/dist/define-DzRz8FgH.cjs.map +1 -0
  104. package/dist/deploy/public.cjs +208 -0
  105. package/dist/deploy/public.cjs.map +1 -0
  106. package/dist/deploy/public.d.cts +649 -0
  107. package/dist/deploy/public.d.cts.map +1 -0
  108. package/dist/deploy/public.d.mts +649 -0
  109. package/dist/deploy/public.d.mts.map +1 -0
  110. package/dist/deploy/public.mjs +142 -0
  111. package/dist/deploy/public.mjs.map +1 -0
  112. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  113. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  114. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  115. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  116. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  117. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  118. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  119. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  120. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  121. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  122. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  123. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  124. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  125. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  126. package/dist/deploy/sniffer-hooks.cjs +13 -7
  127. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  128. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  129. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  130. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  131. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  132. package/dist/deploy/sniffer-hooks.mjs +10 -3
  133. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  134. package/dist/deploy/sniffer-loader.cjs +16 -7
  135. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  136. package/dist/deploy/sniffer-loader.d.cts +1 -1
  137. package/dist/deploy/sniffer-loader.d.mts +1 -1
  138. package/dist/deploy/sniffer-loader.mjs +14 -3
  139. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  140. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  141. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  142. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  143. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  144. package/dist/deploy/sniffer-routes-worker.mjs +4 -4
  145. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  146. package/dist/deploy/sniffer-worker.cjs +15 -6
  147. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  148. package/dist/deploy/sniffer-worker.d.cts +1 -3
  149. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  150. package/dist/deploy/sniffer-worker.d.mts +1 -3
  151. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  152. package/dist/deploy/sniffer-worker.mjs +15 -4
  153. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  154. package/dist/deploy-CuHasEA4.cjs +554 -0
  155. package/dist/deploy-CuHasEA4.cjs.map +1 -0
  156. package/dist/deploy-QNtx_eWR.mjs +525 -0
  157. package/dist/deploy-QNtx_eWR.mjs.map +1 -0
  158. package/dist/derive-B4vDpzgP.mjs +150 -0
  159. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  160. package/dist/derive-DAbo49sm.cjs +161 -0
  161. package/dist/derive-DAbo49sm.cjs.map +1 -0
  162. package/dist/discover-BPelzeGW.mjs +526 -0
  163. package/dist/discover-BPelzeGW.mjs.map +1 -0
  164. package/dist/discover-CU0paUyH.d.cts +108 -0
  165. package/dist/discover-CU0paUyH.d.cts.map +1 -0
  166. package/dist/discover-D1It5r_h.cjs +599 -0
  167. package/dist/discover-D1It5r_h.cjs.map +1 -0
  168. package/dist/discover-DFiJxwfv.d.mts +108 -0
  169. package/dist/discover-DFiJxwfv.d.mts.map +1 -0
  170. package/dist/dokploy-CYcMLh9-.mjs +38 -0
  171. package/dist/dokploy-CYcMLh9-.mjs.map +1 -0
  172. package/dist/dokploy-DIowwyIB.cjs +38 -0
  173. package/dist/dokploy-DIowwyIB.cjs.map +1 -0
  174. package/dist/drivers-DTZzxeIl.mjs +177 -0
  175. package/dist/drivers-DTZzxeIl.mjs.map +1 -0
  176. package/dist/drivers-LYSdQDmd.cjs +200 -0
  177. package/dist/drivers-LYSdQDmd.cjs.map +1 -0
  178. package/dist/{emit-CiZS_5Ub.mjs → emit-C1e8qD08.mjs} +13 -26
  179. package/dist/emit-C1e8qD08.mjs.map +1 -0
  180. package/dist/{emit-CbcRolsa.cjs → emit-Dmc1nvdS.cjs} +31 -57
  181. package/dist/emit-Dmc1nvdS.cjs.map +1 -0
  182. package/dist/encryption-BrEef7Jk.mjs +88 -0
  183. package/dist/encryption-BrEef7Jk.mjs.map +1 -0
  184. package/dist/encryption-CjYdUb2s.cjs +89 -0
  185. package/dist/encryption-CjYdUb2s.cjs.map +1 -0
  186. package/dist/engine-2h4k5ICq.mjs +3085 -0
  187. package/dist/engine-2h4k5ICq.mjs.map +1 -0
  188. package/dist/engine-BhJ7ZP9K.cjs +3198 -0
  189. package/dist/engine-BhJ7ZP9K.cjs.map +1 -0
  190. package/dist/github-B5Bw4HIu.cjs +669 -0
  191. package/dist/github-B5Bw4HIu.cjs.map +1 -0
  192. package/dist/github-BCDF6xVH.mjs +669 -0
  193. package/dist/github-BCDF6xVH.mjs.map +1 -0
  194. package/dist/{index-C6e-ULLx.d.mts → index-D-F_hTDz.d.cts} +39 -24
  195. package/dist/index-D-F_hTDz.d.cts.map +1 -0
  196. package/dist/{index-CR5urhWX.d.cts → index-YFNxR5Ns.d.mts} +39 -24
  197. package/dist/index-YFNxR5Ns.d.mts.map +1 -0
  198. package/dist/index.cjs +9487 -12080
  199. package/dist/index.cjs.map +1 -1
  200. package/dist/index.d.cts +1 -1
  201. package/dist/index.d.mts +1 -1
  202. package/dist/index.mjs +9420 -12026
  203. package/dist/index.mjs.map +1 -1
  204. package/dist/local-BjxDfPvy.cjs +241 -0
  205. package/dist/local-BjxDfPvy.cjs.map +1 -0
  206. package/dist/local-IuoIF3CT.mjs +224 -0
  207. package/dist/local-IuoIF3CT.mjs.map +1 -0
  208. package/dist/migrate-CGaancHY.cjs +93 -0
  209. package/dist/migrate-CGaancHY.cjs.map +1 -0
  210. package/dist/migrate-DWZz9kah.mjs +93 -0
  211. package/dist/migrate-DWZz9kah.mjs.map +1 -0
  212. package/dist/migrate-DbtcuOr_.mjs +265 -0
  213. package/dist/migrate-DbtcuOr_.mjs.map +1 -0
  214. package/dist/migrate-q2YYLJLE.cjs +270 -0
  215. package/dist/migrate-q2YYLJLE.cjs.map +1 -0
  216. package/dist/openapi.cjs +214 -10
  217. package/dist/openapi.cjs.map +1 -0
  218. package/dist/openapi.d.cts +47 -17
  219. package/dist/openapi.d.cts.map +1 -1
  220. package/dist/openapi.d.mts +47 -17
  221. package/dist/openapi.d.mts.map +1 -1
  222. package/dist/openapi.mjs +208 -5
  223. package/dist/openapi.mjs.map +1 -0
  224. package/dist/provider-C9_-45d5.cjs +56 -0
  225. package/dist/provider-C9_-45d5.cjs.map +1 -0
  226. package/dist/provider-q4lsYzYG.mjs +45 -0
  227. package/dist/provider-q4lsYzYG.mjs.map +1 -0
  228. package/dist/ready-BpNbORRB.cjs +402 -0
  229. package/dist/ready-BpNbORRB.cjs.map +1 -0
  230. package/dist/ready-b6vm0-W-.mjs +373 -0
  231. package/dist/ready-b6vm0-W-.mjs.map +1 -0
  232. package/dist/reconcile/public.cjs +3 -5
  233. package/dist/reconcile/public.d.cts +11 -87
  234. package/dist/reconcile/public.d.cts.map +1 -1
  235. package/dist/reconcile/public.d.mts +11 -87
  236. package/dist/reconcile/public.d.mts.map +1 -1
  237. package/dist/reconcile/public.mjs +3 -4
  238. package/dist/{reconcile-D0pimNiy.cjs → reconcile-CuCQBa5-.cjs} +5 -8
  239. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  240. package/dist/{reconcile-CFs8C_1a.mjs → reconcile-Dh1Jk7WE.mjs} +4 -7
  241. package/dist/reconcile-Dh1Jk7WE.mjs.map +1 -0
  242. package/dist/resolve-Cns0v6dN.cjs +315 -0
  243. package/dist/resolve-Cns0v6dN.cjs.map +1 -0
  244. package/dist/resolve-DNg0icnh.mjs +262 -0
  245. package/dist/resolve-DNg0icnh.mjs.map +1 -0
  246. package/dist/rollback-CFrNLmxs.mjs +132 -0
  247. package/dist/rollback-CFrNLmxs.mjs.map +1 -0
  248. package/dist/rollback-UIjS25F1.cjs +161 -0
  249. package/dist/rollback-UIjS25F1.cjs.map +1 -0
  250. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  251. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  252. package/dist/runtime-CN_kmqxo.d.cts +90 -0
  253. package/dist/runtime-CN_kmqxo.d.cts.map +1 -0
  254. package/dist/runtime-Cjvon3oj.d.mts +90 -0
  255. package/dist/runtime-Cjvon3oj.d.mts.map +1 -0
  256. package/dist/sandbox/config-worker.cjs +43 -0
  257. package/dist/sandbox/config-worker.cjs.map +1 -0
  258. package/dist/sandbox/config-worker.d.cts +1 -0
  259. package/dist/sandbox/config-worker.d.mts +1 -0
  260. package/dist/sandbox/config-worker.mjs +44 -0
  261. package/dist/sandbox/config-worker.mjs.map +1 -0
  262. package/dist/sandbox/credentials-worker.cjs +54 -0
  263. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  264. package/dist/sandbox/credentials-worker.d.cts +1 -0
  265. package/dist/sandbox/credentials-worker.d.mts +1 -0
  266. package/dist/sandbox/credentials-worker.mjs +55 -0
  267. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  268. package/dist/sandbox/discover-worker.cjs +47 -0
  269. package/dist/sandbox/discover-worker.cjs.map +1 -0
  270. package/dist/sandbox/discover-worker.d.cts +1 -0
  271. package/dist/sandbox/discover-worker.d.mts +1 -0
  272. package/dist/sandbox/discover-worker.mjs +48 -0
  273. package/dist/sandbox/discover-worker.mjs.map +1 -0
  274. package/dist/sandbox/migrate-worker.cjs +75 -0
  275. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  276. package/dist/sandbox/migrate-worker.d.cts +1 -0
  277. package/dist/sandbox/migrate-worker.d.mts +1 -0
  278. package/dist/sandbox/migrate-worker.mjs +76 -0
  279. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  280. package/dist/sandbox-CL--ZDui.cjs +164 -0
  281. package/dist/sandbox-CL--ZDui.cjs.map +1 -0
  282. package/dist/sandbox-Dm247NGx.mjs +117 -0
  283. package/dist/sandbox-Dm247NGx.mjs.map +1 -0
  284. package/dist/sandbox-M8UnLhXE.d.cts +126 -0
  285. package/dist/sandbox-M8UnLhXE.d.cts.map +1 -0
  286. package/dist/sandbox-M8UnLhXE.d.mts +126 -0
  287. package/dist/sandbox-M8UnLhXE.d.mts.map +1 -0
  288. package/dist/{workspace-zoqRbihZ.mjs → schemas-BObwxB_t.cjs} +998 -1659
  289. package/dist/schemas-BObwxB_t.cjs.map +1 -0
  290. package/dist/{workspace-C6VJQVtG.cjs → schemas-D-xeKJDD.mjs} +913 -1842
  291. package/dist/schemas-D-xeKJDD.mjs.map +1 -0
  292. package/dist/secretsManager-Chs9VV2r.mjs +76 -0
  293. package/dist/secretsManager-Chs9VV2r.mjs.map +1 -0
  294. package/dist/secretsManager-DcMlHnRC.cjs +87 -0
  295. package/dist/secretsManager-DcMlHnRC.cjs.map +1 -0
  296. package/dist/seeds-CkIPFGNO.cjs +10560 -0
  297. package/dist/seeds-CkIPFGNO.cjs.map +1 -0
  298. package/dist/seeds-odfgSCmu.mjs +9538 -0
  299. package/dist/seeds-odfgSCmu.mjs.map +1 -0
  300. package/dist/sniffer-BTtX3NUM.mjs +1262 -0
  301. package/dist/sniffer-BTtX3NUM.mjs.map +1 -0
  302. package/dist/sniffer-IAQEpsQb.cjs +1333 -0
  303. package/dist/sniffer-IAQEpsQb.cjs.map +1 -0
  304. package/dist/sst-BgcOsaBi.cjs +453 -0
  305. package/dist/sst-BgcOsaBi.cjs.map +1 -0
  306. package/dist/sst-CJzvyrEz.mjs +430 -0
  307. package/dist/sst-CJzvyrEz.mjs.map +1 -0
  308. package/dist/stages-CUn6gvXL.cjs +174 -0
  309. package/dist/stages-CUn6gvXL.cjs.map +1 -0
  310. package/dist/stages-CnZRYmkI.mjs +174 -0
  311. package/dist/stages-CnZRYmkI.mjs.map +1 -0
  312. package/dist/target/public.cjs +15 -0
  313. package/dist/target/public.d.cts +28 -0
  314. package/dist/target/public.d.cts.map +1 -0
  315. package/dist/target/public.d.mts +28 -0
  316. package/dist/target/public.d.mts.map +1 -0
  317. package/dist/target/public.mjs +4 -0
  318. package/dist/terminal-D8TPK7o9.mjs +84 -0
  319. package/dist/terminal-D8TPK7o9.mjs.map +1 -0
  320. package/dist/terminal-DuapRxh6.cjs +84 -0
  321. package/dist/terminal-DuapRxh6.cjs.map +1 -0
  322. package/dist/types-NqX1Hz4P.d.cts +7454 -0
  323. package/dist/types-NqX1Hz4P.d.cts.map +1 -0
  324. package/dist/types-ZHuZ89hv.d.mts +7453 -0
  325. package/dist/types-ZHuZ89hv.d.mts.map +1 -0
  326. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  327. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  328. package/dist/utils-D_fxUqvU.mjs +156 -0
  329. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  330. package/dist/vitest.cjs +65 -0
  331. package/dist/vitest.cjs.map +1 -0
  332. package/dist/vitest.d.cts +29 -0
  333. package/dist/vitest.d.cts.map +1 -0
  334. package/dist/vitest.d.mts +29 -0
  335. package/dist/vitest.d.mts.map +1 -0
  336. package/dist/vitest.mjs +65 -0
  337. package/dist/vitest.mjs.map +1 -0
  338. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  339. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  340. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  341. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  342. package/dist/workspace/index.cjs +8 -4
  343. package/dist/workspace/index.d.cts +3 -3
  344. package/dist/workspace/index.d.mts +3 -3
  345. package/dist/workspace/index.mjs +2 -3
  346. package/dist/workspace-CJ0lKFq-.mjs +1979 -0
  347. package/dist/workspace-CJ0lKFq-.mjs.map +1 -0
  348. package/dist/workspace-CwW3Gkru.cjs +2355 -0
  349. package/dist/workspace-CwW3Gkru.cjs.map +1 -0
  350. package/package.json +53 -22
  351. package/dist/CachedStateProvider-BLo7zv7S.cjs +0 -3
  352. package/dist/CachedStateProvider-BxoAm-B2.mjs +0 -3
  353. package/dist/CachedStateProvider-CqPdW7CB.cjs +0 -60
  354. package/dist/CachedStateProvider-CqPdW7CB.cjs.map +0 -1
  355. package/dist/CachedStateProvider-DTniehMP.mjs +0 -54
  356. package/dist/CachedStateProvider-DTniehMP.mjs.map +0 -1
  357. package/dist/HostingerProvider-Cft7lEYr.mjs.map +0 -1
  358. package/dist/HostingerProvider-h3EbEp-Z.cjs.map +0 -1
  359. package/dist/LocalStateProvider-Bn6tS-oL.mjs +0 -42
  360. package/dist/LocalStateProvider-Bn6tS-oL.mjs.map +0 -1
  361. package/dist/LocalStateProvider-Db9SEjyH.cjs +0 -43
  362. package/dist/LocalStateProvider-Db9SEjyH.cjs.map +0 -1
  363. package/dist/Route53Provider-RdpUDJQk.mjs.map +0 -1
  364. package/dist/Route53Provider-di2fMM5N.cjs.map +0 -1
  365. package/dist/SSMStateProvider-BRt2py-A.mjs +0 -66
  366. package/dist/SSMStateProvider-BRt2py-A.mjs.map +0 -1
  367. package/dist/SSMStateProvider-DyX8s9HI.cjs +0 -66
  368. package/dist/SSMStateProvider-DyX8s9HI.cjs.map +0 -1
  369. package/dist/backup-provisioner-Bgj5Vi_L.mjs.map +0 -1
  370. package/dist/backup-provisioner-BrsHwYG0.cjs.map +0 -1
  371. package/dist/bundler-BY1OmV1e.cjs.map +0 -1
  372. package/dist/bundler-Be8Zg4Wd.mjs.map +0 -1
  373. package/dist/chunk-Duj1WY3L.mjs +0 -7
  374. package/dist/config-BZ1F0WuA.cjs +0 -462
  375. package/dist/config-BZ1F0WuA.cjs.map +0 -1
  376. package/dist/config-DVVph9yz.mjs +0 -402
  377. package/dist/config-DVVph9yz.mjs.map +0 -1
  378. package/dist/config.d.cts.map +0 -1
  379. package/dist/config.d.mts.map +0 -1
  380. package/dist/credentials-B5zRHdAl.mjs +0 -141
  381. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  382. package/dist/credentials-BapzjyV5.cjs +0 -195
  383. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  384. package/dist/credentials-Xamqe_NJ.cjs +0 -2681
  385. package/dist/credentials-Xamqe_NJ.cjs.map +0 -1
  386. package/dist/credentials-dP8vRVRv.mjs +0 -2549
  387. package/dist/credentials-dP8vRVRv.mjs.map +0 -1
  388. package/dist/discover-CAlFgYec.mjs +0 -229
  389. package/dist/discover-CAlFgYec.mjs.map +0 -1
  390. package/dist/discover-DTmFeloL.cjs +0 -271
  391. package/dist/discover-DTmFeloL.cjs.map +0 -1
  392. package/dist/dokploy-api-BS2xnJLZ.mjs +0 -3
  393. package/dist/dokploy-api-BsVH0y_s.cjs +0 -718
  394. package/dist/dokploy-api-BsVH0y_s.cjs.map +0 -1
  395. package/dist/dokploy-api-BuxDRo3l.cjs +0 -3
  396. package/dist/dokploy-api-aTFPz7_4.mjs +0 -706
  397. package/dist/dokploy-api-aTFPz7_4.mjs.map +0 -1
  398. package/dist/emit-CbcRolsa.cjs.map +0 -1
  399. package/dist/emit-CiZS_5Ub.mjs.map +0 -1
  400. package/dist/encryption-C6jaU0hE.cjs +0 -54
  401. package/dist/encryption-C6jaU0hE.cjs.map +0 -1
  402. package/dist/encryption-CHzzeR8a.cjs +0 -4
  403. package/dist/encryption-CQUncu7v.mjs +0 -3
  404. package/dist/encryption-D-abyhZx.mjs +0 -42
  405. package/dist/encryption-D-abyhZx.mjs.map +0 -1
  406. package/dist/fullstack-secrets-C-GGohke.cjs +0 -111
  407. package/dist/fullstack-secrets-C-GGohke.cjs.map +0 -1
  408. package/dist/fullstack-secrets-D1o9-G5l.mjs +0 -87
  409. package/dist/fullstack-secrets-D1o9-G5l.mjs.map +0 -1
  410. package/dist/generator-CNzBw7g5.cjs +0 -289
  411. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  412. package/dist/generator-VE2JrFlY.mjs +0 -253
  413. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  414. package/dist/index-C6e-ULLx.d.mts.map +0 -1
  415. package/dist/index-CR5urhWX.d.cts.map +0 -1
  416. package/dist/openapi-SjsgARie.cjs +0 -2075
  417. package/dist/openapi-SjsgARie.cjs.map +0 -1
  418. package/dist/openapi-Xx0A7Wg0.mjs +0 -2021
  419. package/dist/openapi-Xx0A7Wg0.mjs.map +0 -1
  420. package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
  421. package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
  422. package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
  423. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
  424. package/dist/openapi-react-query.cjs +0 -4
  425. package/dist/openapi-react-query.d.cts +0 -11
  426. package/dist/openapi-react-query.d.cts.map +0 -1
  427. package/dist/openapi-react-query.d.mts +0 -11
  428. package/dist/openapi-react-query.d.mts.map +0 -1
  429. package/dist/openapi-react-query.mjs +0 -4
  430. package/dist/reconcile-CFs8C_1a.mjs.map +0 -1
  431. package/dist/reconcile-D0pimNiy.cjs.map +0 -1
  432. package/dist/setup-BA8ciTPU.mjs +0 -11
  433. package/dist/setup-BsZvZP6f.cjs +0 -11
  434. package/dist/setup-C8KOx8_8.mjs +0 -443
  435. package/dist/setup-C8KOx8_8.mjs.map +0 -1
  436. package/dist/setup-hC6hI86f.cjs +0 -473
  437. package/dist/setup-hC6hI86f.cjs.map +0 -1
  438. package/dist/storage-BJmzYxt8.cjs +0 -363
  439. package/dist/storage-BJmzYxt8.cjs.map +0 -1
  440. package/dist/storage-BM9hGpgv.cjs +0 -7
  441. package/dist/storage-Bi24WfoW.mjs +0 -297
  442. package/dist/storage-Bi24WfoW.mjs.map +0 -1
  443. package/dist/storage-CYlGwWTj.mjs +0 -3
  444. package/dist/sync-CmEuNZsB.mjs +0 -76
  445. package/dist/sync-CmEuNZsB.mjs.map +0 -1
  446. package/dist/sync-D306yOWu.cjs +0 -4
  447. package/dist/sync-SizaChmC.cjs +0 -93
  448. package/dist/sync-SizaChmC.cjs.map +0 -1
  449. package/dist/sync-hOqAWHR6.mjs +0 -3
  450. package/dist/types-6pkp2RRj.d.mts +0 -2220
  451. package/dist/types-6pkp2RRj.d.mts.map +0 -1
  452. package/dist/types-Y3fKQSAK.d.cts +0 -2220
  453. package/dist/types-Y3fKQSAK.d.cts.map +0 -1
  454. package/dist/workspace-BzrG_2SI.mjs +0 -8
  455. package/dist/workspace-C6VJQVtG.cjs.map +0 -1
  456. package/dist/workspace-XXtNhqJl.cjs +0 -9
  457. package/dist/workspace-zoqRbihZ.mjs.map +0 -1
@@ -0,0 +1,1979 @@
1
+ import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
+ import { a as discriminatedUnion, d as record, f as string, g as url, h as unknown, i as custom, l as number, m as union, n as array, p as tuple, r as boolean, s as literal, t as _enum, u as object } from "./schemas-D-xeKJDD.mjs";
3
+ import { n as isDeployTarget, o as builtinTarget, r as BUILTIN_TARGETS, s as configurableBuiltins } from "./define-DR8xGYfL.mjs";
4
+ import { basename, isAbsolute, join, resolve } from "node:path";
5
+ import { isIP } from "node:net";
6
+ //#region src/secrets/providers.ts
7
+ /**
8
+ * The secrets stores gkm ships, by name — with no imports, so the config
9
+ * loader can check `secrets.store` without loading any store.
10
+ */
11
+ /** The stores this package ships, by the name `secrets.store` gives them. */
12
+ const SECRETS_STORE_PROVIDERS = [
13
+ "file",
14
+ "ssm",
15
+ "secrets-manager"
16
+ ];
17
+ /**
18
+ * `secrets.store` names a provider this package does not ship — a typo such
19
+ * as `'secretsmanager'` or `'ssm-parameter'`. Refused rather than read as the
20
+ * file, which would leave a deployed stage's secrets on one machine.
21
+ */
22
+ var UnknownSecretsStoreProvider = class extends Error {
23
+ provider;
24
+ constructor(provider) {
25
+ super(`secrets.store names the provider ${JSON.stringify(provider)}, which is not one gkm ships. Use 'file', { provider: 'ssm', region }, { provider: 'secrets-manager', region }, or { provider: <an object with name, read() and write()> } in gkm.config.ts.`);
26
+ this.provider = provider;
27
+ this.name = "UnknownSecretsStoreProvider";
28
+ }
29
+ };
30
+ /**
31
+ * Refuse a `secrets.store` naming a provider that is not one, before the
32
+ * schema reduces it to a generic validation failure.
33
+ */
34
+ function assertKnownSecretsStore(store) {
35
+ if (store === void 0) return;
36
+ const provider = typeof store === "object" && store !== null && "provider" in store ? store.provider : store;
37
+ if (typeof provider === "string" && !SECRETS_STORE_PROVIDERS.includes(provider)) throw new UnknownSecretsStoreProvider(provider);
38
+ }
39
+ //#endregion
40
+ //#region src/compose/dnsConfig.ts
41
+ /**
42
+ * `dns['<root domain>'].records` — how a domain's hosts point at a compose
43
+ * stage's server — checked and read. Pure, and kept apart from the DNS step
44
+ * so the workspace schema checks a config with the same rules and the same
45
+ * named errors the step applies.
46
+ */
47
+ /** The stage-secret key holding the server's public IPv4 address. */
48
+ const SERVER_IPV4_KEY = "GKM_SERVER_IPV4";
49
+ /** The stage-secret key holding the server's public IPv6 address, if any. */
50
+ const SERVER_IPV6_KEY = "GKM_SERVER_IPV6";
51
+ /**
52
+ * Whether a stage secret is gkm's own — the server's address — and so never
53
+ * written into an app's or a worker's environment.
54
+ */
55
+ function isReservedStageKey(key) {
56
+ return key.startsWith("GKM_SERVER_");
57
+ }
58
+ /** A DNS hostname: dot-separated labels of letters, digits and inner '-'. */
59
+ const HOSTNAME = /^(?=.{1,253}$)([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/i;
60
+ /** Whether `value` is a DNS hostname with at least two labels. */
61
+ function isHostname(value) {
62
+ return typeof value === "string" && HOSTNAME.test(value);
63
+ }
64
+ /** A CNAME target that is not a hostname under its own domain. */
65
+ var DnsTargetInvalid = class extends Error {
66
+ domain;
67
+ target;
68
+ stage;
69
+ constructor(domain, target, stage) {
70
+ super(`dns['${domain}'].records.target${stage ? ` for '${stage}'` : ""} is ${JSON.stringify(target)}, which is not a hostname under ${domain}. Every host's CNAME points at it and gkm writes its A record, so it must be a name in the same zone — like 'server.${domain}'.`);
71
+ this.domain = domain;
72
+ this.target = target;
73
+ this.stage = stage;
74
+ this.name = "DnsTargetInvalid";
75
+ }
76
+ };
77
+ /** The CNAME target names under one domain, by the stage they are for, checked. */
78
+ function targets(records) {
79
+ const { target } = records;
80
+ if (target && typeof target === "object" && !Array.isArray(target)) return Object.entries(target);
81
+ return [[void 0, target]];
82
+ }
83
+ /**
84
+ * One domain's records mode checked.
85
+ *
86
+ * @throws {DnsTargetInvalid} for a target that is not a hostname under it
87
+ */
88
+ function checkDnsRecordsMode(domain, records) {
89
+ if (!records || typeof records !== "object") return;
90
+ const mode = records;
91
+ if (mode.mode !== "cname") return;
92
+ for (const [stage, target] of targets(mode)) {
93
+ const name = typeof target === "string" ? target.toLowerCase() : target;
94
+ if (!isHostname(name) || !name.endsWith(`.${domain.toLowerCase()}`)) throw new DnsTargetInvalid(domain, target, stage);
95
+ }
96
+ }
97
+ /**
98
+ * The CNAME target a domain's hosts point at on `stage`, or `undefined` for
99
+ * A records — including a per-stage map that names no target for it.
100
+ */
101
+ function cnameTarget(records, stage) {
102
+ if (!records || records === "a") return void 0;
103
+ return (typeof records.target === "string" ? records.target : records.target[stage])?.toLowerCase();
104
+ }
105
+ //#endregion
106
+ //#region src/compose/proxy.ts
107
+ /**
108
+ * Which proxy a stage's stack is served by, and with whose certificate —
109
+ * `deploy.compose.proxy` and `deploy.compose.tls`, resolved for one stage.
110
+ *
111
+ * Pure, and kept apart from the stack so the workspace schema can check a
112
+ * config with the same rules — and the same named errors — the stack applies.
113
+ */
114
+ /** A per-stage setting keyed by a stage the workspace does not have. */
115
+ var ComposeStageUnknown = class extends Error {
116
+ setting;
117
+ stage;
118
+ stages;
119
+ constructor(setting, stage, stages) {
120
+ super(`deploy.compose.${setting} names the stage '${stage}', which is not one of this workspace's (${stages.join(", ")}). Use a stage from stages.local or stages.deployed.`);
121
+ this.setting = setting;
122
+ this.stage = stage;
123
+ this.stages = stages;
124
+ this.name = "ComposeStageUnknown";
125
+ }
126
+ };
127
+ /**
128
+ * A certificate for the local stage, whose certificates are always Caddy's
129
+ * own CA — the one `gkm trust` installs.
130
+ */
131
+ var ComposeTlsOnLocalStage = class extends Error {
132
+ stage;
133
+ constructor(stage) {
134
+ super(`deploy.compose.tls sets a certificate for '${stage}', the local stage, whose certificates always come from Caddy's local CA (\`gkm trust\` installs it). Remove it, or set it for a deployed stage.`);
135
+ this.stage = stage;
136
+ this.name = "ComposeTlsOnLocalStage";
137
+ }
138
+ };
139
+ /** The stage's certificate or key file is not there to read. */
140
+ var ComposeTlsFileMissing = class extends Error {
141
+ stage;
142
+ file;
143
+ constructor(stage, file) {
144
+ super(`deploy.compose.tls for '${stage}' names ${file}, and there is no file there. Point certFile and keyFile at the PEM certificate (with its chain) and key — relative to the workspace root, or absolute.`);
145
+ this.stage = stage;
146
+ this.file = file;
147
+ this.name = "ComposeTlsFileMissing";
148
+ }
149
+ };
150
+ /**
151
+ * The proxy a stage's stack is served by. The local stage is always Caddy —
152
+ * its internal CA and `gkm trust` — whatever is configured.
153
+ */
154
+ function proxyFor(config, stage, local) {
155
+ if (local) return "caddy";
156
+ const proxy = config?.proxy;
157
+ if (!proxy) return "caddy";
158
+ if (typeof proxy === "string") return proxy;
159
+ return proxy[stage] ?? "caddy";
160
+ }
161
+ /** A deployed stage's own certificate, its paths absolute, when it sets one. */
162
+ function certificateFor(config, stage, root) {
163
+ const tls = config?.tls?.[stage];
164
+ if (!tls) return void 0;
165
+ const absolute = (file) => isAbsolute(file) ? file : resolve(root, file);
166
+ return {
167
+ certFile: absolute(tls.certFile),
168
+ keyFile: absolute(tls.keyFile)
169
+ };
170
+ }
171
+ /**
172
+ * Throws the named error for the first thing wrong with the per-stage
173
+ * settings: a stage the workspace does not have, or a certificate for the
174
+ * local stage.
175
+ */
176
+ function checkComposeStages(config, stages) {
177
+ const known = [stages.local, ...stages.deployed];
178
+ if (config?.proxy && typeof config.proxy === "object") {
179
+ for (const stage of Object.keys(config.proxy)) if (!known.includes(stage)) throw new ComposeStageUnknown("proxy", stage, known);
180
+ }
181
+ for (const stage of Object.keys(config?.tls ?? {})) {
182
+ if (stage === stages.local) throw new ComposeTlsOnLocalStage(stage);
183
+ if (!known.includes(stage)) throw new ComposeStageUnknown("tls", stage, known);
184
+ }
185
+ }
186
+ //#endregion
187
+ //#region src/providers/s3/errors.ts
188
+ /** What the `s3` provider refuses, and how each is put right. */
189
+ /** An `objects` entry for `s3` with a field it does not take or cannot use. */
190
+ var S3ProviderConfigInvalid = class extends Error {
191
+ stage;
192
+ field;
193
+ value;
194
+ expected;
195
+ constructor(stage, field, value, expected) {
196
+ super(`deploy.objects.${stage}.${field} is ${JSON.stringify(value)}; ${expected}.`);
197
+ this.stage = stage;
198
+ this.field = field;
199
+ this.value = value;
200
+ this.expected = expected;
201
+ this.name = "S3ProviderConfigInvalid";
202
+ }
203
+ };
204
+ /** No region anywhere to create the stage's buckets in. */
205
+ var S3RegionRequired = class extends Error {
206
+ stage;
207
+ constructor(stage) {
208
+ super(`The s3 provider has no region for the stage '${stage}'. Name one in gkm.config.ts: deploy: { objects: { ${stage}: { provider: 's3', region: 'eu-west-1' } } } — or set AWS_REGION.`);
209
+ this.stage = stage;
210
+ this.name = "S3RegionRequired";
211
+ }
212
+ };
213
+ /** The good name and every suffixed one are taken by other accounts. */
214
+ var BucketNameUnavailable = class extends Error {
215
+ id;
216
+ tried;
217
+ constructor(id, tried) {
218
+ super(`Every name tried for the bucket '${id}' is taken by another AWS account: ${tried.join(", ")}. Set deploy.namespace in gkm.config.ts to something more particular to you, and run the provision again.`);
219
+ this.id = id;
220
+ this.tried = tried;
221
+ this.name = "BucketNameUnavailable";
222
+ }
223
+ };
224
+ /** A bucket in this account carries another project's tag. */
225
+ var BucketOwnedByAnotherProject = class extends Error {
226
+ bucket;
227
+ owner;
228
+ project;
229
+ constructor(bucket, owner, project) {
230
+ super(`The bucket '${bucket}' is in this account and tagged gkm:project=${owner}, not ${project}: another project's. gkm never adopts it. Set deploy.namespace in gkm.config.ts so this project names its buckets differently.`);
231
+ this.bucket = bucket;
232
+ this.owner = owner;
233
+ this.project = project;
234
+ this.name = "BucketOwnedByAnotherProject";
235
+ }
236
+ };
237
+ /** The bucket the stage's state names exists, and this account cannot reach it. */
238
+ var RecordedBucketUnreachable = class extends Error {
239
+ id;
240
+ bucket;
241
+ constructor(id, bucket) {
242
+ super(`The stage's state records '${bucket}' as the bucket for '${id}', and this account cannot reach it — it is in another account, or the credentials are not the stage account's. Run with the account that created it (--profile).`);
243
+ this.id = id;
244
+ this.bucket = bucket;
245
+ this.name = "RecordedBucketUnreachable";
246
+ }
247
+ };
248
+ /** An IAM user by gkm's name exists, and gkm did not create it for this stage. */
249
+ var IamUserNotOwned = class extends Error {
250
+ user;
251
+ project;
252
+ stage;
253
+ constructor(user, project, stage) {
254
+ super(`The IAM user '${user}' exists and is not tagged gkm:project=${project}, gkm:stage=${stage}, so gkm leaves it alone. Rename or delete it, or set deploy.namespace in gkm.config.ts so gkm names its users differently.`);
255
+ this.user = user;
256
+ this.project = project;
257
+ this.stage = stage;
258
+ this.name = "IamUserNotOwned";
259
+ }
260
+ };
261
+ /** The user already has the two access keys IAM allows. */
262
+ var AccessKeyLimit = class extends Error {
263
+ user;
264
+ keys;
265
+ constructor(user, keys) {
266
+ super(`The IAM user '${user}' already has two access keys (${keys.join(", ")}), the most IAM allows, and gkm needs to issue one. Delete the one the stage does not use (aws iam delete-access-key --user-name ${user} --access-key-id …), then run the provision again.`);
267
+ this.user = user;
268
+ this.keys = keys;
269
+ this.name = "AccessKeyLimit";
270
+ }
271
+ };
272
+ /** `--rotate-keys` while the last rotation's old key is still active. */
273
+ var RotationInProgress = class extends Error {
274
+ id;
275
+ previous;
276
+ stage;
277
+ constructor(id, previous, stage) {
278
+ super(`The bucket '${id}' is mid-rotation: its old key ${previous} is still active. Deploy '${stage}', then run gkm setup --stage ${stage} — or pass --retire-old-keys to delete it now — before rotating again.`);
279
+ this.id = id;
280
+ this.previous = previous;
281
+ this.stage = stage;
282
+ this.name = "RotationInProgress";
283
+ }
284
+ };
285
+ /** The stage's secrets point the bucket's key at a bucket gkm did not provision. */
286
+ var BucketKeySetElsewhere = class extends Error {
287
+ key;
288
+ bucket;
289
+ found;
290
+ stage;
291
+ constructor(key, bucket, found, stage) {
292
+ super(`${key} in the stage '${stage}' points at the bucket '${found}', and the s3 provider manages '${bucket}' for it. Remove the key (gkm secrets:unset ${key} --stage ${stage}) to have the provider write its own, or set deploy.objects.${stage} to 'external' to keep yours.`);
293
+ this.key = key;
294
+ this.bucket = bucket;
295
+ this.found = found;
296
+ this.stage = stage;
297
+ this.name = "BucketKeySetElsewhere";
298
+ }
299
+ };
300
+ /** `verify()`: a provisioned bucket the stage's key cannot reach. */
301
+ var ProvisionedBucketUnreachable = class extends Error {
302
+ id;
303
+ bucket;
304
+ stage;
305
+ reason;
306
+ constructor(id, bucket, stage, reason) {
307
+ super(`The bucket '${bucket}' (${id}) cannot be reached with the key in the stage '${stage}''s secrets: ${reason}. Run gkm setup --stage ${stage} with the stage account's credentials to create or repair it, then deploy again.`);
308
+ this.id = id;
309
+ this.bucket = bucket;
310
+ this.stage = stage;
311
+ this.reason = reason;
312
+ this.name = "ProvisionedBucketUnreachable";
313
+ }
314
+ };
315
+ //#endregion
316
+ //#region src/providers/s3/config.ts
317
+ const FIELDS = [
318
+ "provider",
319
+ "region",
320
+ "versioning"
321
+ ];
322
+ /** An AWS region code: `eu-west-1`, `us-gov-west-1`, `ap-southeast-4`. */
323
+ const REGION = /^[a-z]{2}(-[a-z]+)+-\d+$/;
324
+ function checkS3Config(stage, config) {
325
+ const entry = config;
326
+ for (const field of Object.keys(entry)) if (!FIELDS.includes(field)) throw new S3ProviderConfigInvalid(stage, field, entry[field], `the s3 provider takes ${FIELDS.slice(1).join(" and ")} only`);
327
+ if (entry.region !== void 0) {
328
+ if (typeof entry.region !== "string" || !REGION.test(entry.region)) throw new S3ProviderConfigInvalid(stage, "region", entry.region, "set it to an AWS region code, like 'eu-west-1'");
329
+ }
330
+ if (entry.versioning !== void 0 && typeof entry.versioning !== "boolean") throw new S3ProviderConfigInvalid(stage, "versioning", entry.versioning, "set it to true to keep previous versions of every object, or leave it out");
331
+ return entry;
332
+ }
333
+ /** How the s3 provider's provisioning credentials are supplied. */
334
+ const S3_PROVISIONING = {
335
+ env: [
336
+ "AWS_PROFILE",
337
+ "AWS_ACCESS_KEY_ID",
338
+ "AWS_SECRET_ACCESS_KEY",
339
+ "AWS_SESSION_TOKEN"
340
+ ],
341
+ describe: "the stage's AWS account — --profile <name>, AWS_PROFILE, or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY (in CI, what aws-actions/configure-aws-credentials exports)"
342
+ };
343
+ //#endregion
344
+ //#region src/providers/config.ts
345
+ /**
346
+ * `deploy.<kind>.<stage>`, read: what backs one kind of construct on a stage.
347
+ *
348
+ * Kept free of the providers themselves — of the AWS SDK and the graph — so
349
+ * the workspace schema can check an entry with the words a deploy would use,
350
+ * the way `checkStageTelemetry` does for `deploy.telemetry`.
351
+ */
352
+ /** Each provider's config check, by kind and name. */
353
+ const CHECKS = { objects: { s3: checkS3Config } };
354
+ /** How each provider's provisioning credentials are supplied, by kind and name. */
355
+ const PROVISIONING = { objects: { s3: S3_PROVISIONING } };
356
+ /** How `name`'s provisioning credentials are supplied, for messages. */
357
+ function provisioningOf(kind, name) {
358
+ return Object.hasOwn(PROVISIONING[kind], name) ? PROVISIONING[kind][name] : void 0;
359
+ }
360
+ /** The `provider:` names a kind accepts. */
361
+ function providerNamesOf(kind) {
362
+ return Object.keys(CHECKS[kind]).sort();
363
+ }
364
+ /** What `deploy.<kind>.<stage>` may be, for messages. */
365
+ function accepted(kind) {
366
+ return [
367
+ "'external'",
368
+ ...providerNamesOf(kind).map((name) => `{ provider: '${name}' }`),
369
+ "false"
370
+ ].join(", ");
371
+ }
372
+ /** An entry that names no provider gkm has, or is not an entry at all. */
373
+ var UnknownStageProvider = class extends Error {
374
+ kind;
375
+ stage;
376
+ value;
377
+ constructor(kind, stage, value) {
378
+ super(`deploy.${kind}.${stage} is ${JSON.stringify(value)}, which is not a provider gkm has for ${kind}. It takes ${accepted(kind)}.`);
379
+ this.kind = kind;
380
+ this.stage = stage;
381
+ this.value = value;
382
+ this.name = "UnknownStageProvider";
383
+ }
384
+ };
385
+ /**
386
+ * One stage's entry checked: `'external'`, `false`, or a provider's object
387
+ * that its own check accepts.
388
+ *
389
+ * @throws {UnknownStageProvider} for anything else — `'minio'` included
390
+ */
391
+ function checkStageProvider(kind, stage, value) {
392
+ if (value === "external" || value === false) return value;
393
+ if (value && typeof value === "object" && !Array.isArray(value)) {
394
+ const name = value.provider;
395
+ const check = typeof name === "string" && Object.hasOwn(CHECKS[kind], name) ? CHECKS[kind][name] : void 0;
396
+ if (check) return check(stage, value);
397
+ }
398
+ throw new UnknownStageProvider(kind, stage, value);
399
+ }
400
+ /**
401
+ * What backs `kind` on `stage`: the local stage is always `external` here —
402
+ * `gkm dev` runs its own — and a deployed stage that names nothing is too.
403
+ */
404
+ function stageProvider(workspace, kind, stage) {
405
+ if (stage === workspace.stages?.local) return { mode: "external" };
406
+ const value = workspace.deploy?.[kind]?.[stage];
407
+ if (value === void 0) return { mode: "external" };
408
+ const entry = checkStageProvider(kind, stage, value);
409
+ if (entry === "external") return { mode: "external" };
410
+ if (entry === false) return { mode: "none" };
411
+ return {
412
+ mode: "provider",
413
+ name: entry.provider,
414
+ config: entry
415
+ };
416
+ }
417
+ //#endregion
418
+ //#region src/compose/logsConfig.ts
419
+ /**
420
+ * The self-hosted telemetry provider's options, read: how the stack's
421
+ * OpenObserve is run and reached — `deploy.telemetry.<stage>` with
422
+ * `provider: 'self-hosted'`.
423
+ *
424
+ * Kept apart from the stack so the workspace schema can check a config with
425
+ * the same rules — and the same named errors — the stack applies.
426
+ */
427
+ /** The port OpenObserve listens on, and the one it is published on by default. */
428
+ const LOGS_PORT = 5080;
429
+ /** `public` with no address to allow: nobody could reach it. */
430
+ var LogsAllowEmpty = class extends Error {
431
+ stage;
432
+ constructor(stage) {
433
+ super(`deploy.telemetry.${stage}.public.allow is empty, so the logs site would answer every request with 403. List the addresses that may reach it (public: { allow: ['203.0.113.7', '10.0.0.0/8'] }), or remove public and reach it through an SSH tunnel.`);
434
+ this.stage = stage;
435
+ this.name = "LogsAllowEmpty";
436
+ }
437
+ };
438
+ /** An `allow` entry that is not an IP address or a CIDR range. */
439
+ var LogsAllowEntryInvalid = class extends Error {
440
+ stage;
441
+ entry;
442
+ constructor(stage, entry) {
443
+ super(`deploy.telemetry.${stage}.public.allow has '${entry}', which is not an IP address or a CIDR range. Write one like '203.0.113.7', '10.0.0.0/8' or '2001:db8::/32'.`);
444
+ this.stage = stage;
445
+ this.entry = entry;
446
+ this.name = "LogsAllowEntryInvalid";
447
+ }
448
+ };
449
+ /** A retention OpenObserve would refuse to start with. */
450
+ var LogsRetentionInvalid = class extends Error {
451
+ stage;
452
+ retentionDays;
453
+ constructor(stage, retentionDays) {
454
+ super(`deploy.telemetry.${stage}.retentionDays is ${String(retentionDays)}; it must be a whole number of days, at least 3 — OpenObserve refuses to start with fewer. Leave it out for 30.`);
455
+ this.stage = stage;
456
+ this.retentionDays = retentionDays;
457
+ this.name = "LogsRetentionInvalid";
458
+ }
459
+ };
460
+ /** A port that is not one. */
461
+ var LogsPortInvalid = class extends Error {
462
+ stage;
463
+ port;
464
+ constructor(stage, port) {
465
+ super(`deploy.telemetry.${stage}.port is ${String(port)}; set it to a number between 1 and 65535, or leave it out for ${LOGS_PORT}.`);
466
+ this.stage = stage;
467
+ this.port = port;
468
+ this.name = "LogsPortInvalid";
469
+ }
470
+ };
471
+ /** Whether `entry` is an IP address, or an address and a prefix length. */
472
+ function isAddressOrRange(entry) {
473
+ const [address = "", prefix, ...rest] = entry.split("/");
474
+ if (rest.length > 0) return false;
475
+ const family = isIP(address);
476
+ if (family === 0) return false;
477
+ if (prefix === void 0) return true;
478
+ if (!/^\d{1,3}$/.test(prefix)) return false;
479
+ return Number(prefix) <= (family === 4 ? 32 : 128);
480
+ }
481
+ /**
482
+ * The self-hosted provider's options with their defaults — `{}` for all of
483
+ * them. Throws the named error for the first thing wrong with them.
484
+ */
485
+ function resolveSelfHosted(config, stage) {
486
+ const port = config.port ?? 5080;
487
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new LogsPortInvalid(stage, config.port);
488
+ const retentionDays = config.retentionDays ?? 30;
489
+ if (!Number.isInteger(retentionDays) || retentionDays < 3) throw new LogsRetentionInvalid(stage, config.retentionDays);
490
+ if (config.public) {
491
+ const allow = config.public.allow ?? [];
492
+ if (allow.length === 0) throw new LogsAllowEmpty(stage);
493
+ for (const entry of allow) if (!isAddressOrRange(entry)) throw new LogsAllowEntryInvalid(stage, entry);
494
+ return {
495
+ port,
496
+ retentionDays,
497
+ public: { allow: [...allow] }
498
+ };
499
+ }
500
+ return {
501
+ port,
502
+ retentionDays
503
+ };
504
+ }
505
+ //#endregion
506
+ //#region src/telemetry/config.ts
507
+ /**
508
+ * `deploy.telemetry`, read: where one stage's telemetry goes, and how much.
509
+ *
510
+ * The application says what it emits (the `Telemetry` construct). This says
511
+ * where it is sent, per stage, and is the only place that does:
512
+ *
513
+ * - **self-hosted** — the target runs OpenObserve beside the apps (#189's
514
+ * stack service). A server target that can run it uses it when a stage
515
+ * names nothing.
516
+ * - **otlp** — any OTLP/HTTP endpoint, with its headers.
517
+ * - **false** — nothing is sent.
518
+ *
519
+ * Vendor presets (a known endpoint and header shape, with the stage secret
520
+ * `TELEMETRY_CREDENTIALS`) are one more entry in {@link PROVIDERS}: a
521
+ * resolver from the stage's config to a {@link ResolvedTelemetry}, which
522
+ * every target already consumes through {@link telemetryEnv}.
523
+ *
524
+ * The local stage ignores all of it: `gkm dev` and `gkm compose` on it run
525
+ * OpenObserve and keep every trace.
526
+ */
527
+ /** A deployed stage uses telemetry and its target cannot choose for it. */
528
+ var TelemetryProviderRequired = class extends Error {
529
+ stage;
530
+ target;
531
+ constructor(stage, target) {
532
+ super(`The stage '${stage}' deploys through ${target}, which cannot run telemetry itself, and a process uses a Telemetry construct. Say where it goes in gkm.config.ts: deploy: { telemetry: { ${stage}: { provider: 'otlp', endpoint: 'https://…' } } } — or deploy: { telemetry: { ${stage}: false } } to send nothing.`);
533
+ this.stage = stage;
534
+ this.target = target;
535
+ this.name = "TelemetryProviderRequired";
536
+ }
537
+ };
538
+ /** A stage asks for the self-hosted provider on a target that cannot run it. */
539
+ var SelfHostedTelemetryUnavailable = class extends Error {
540
+ stage;
541
+ target;
542
+ constructor(stage, target) {
543
+ super(`deploy.telemetry.${stage} is 'self-hosted', and ${target} does not run OpenObserve beside the apps — the compose target does. Deploy '${stage}' through compose, or send its telemetry elsewhere: deploy: { telemetry: { ${stage}: { provider: 'otlp', endpoint: 'https://…' } } }.`);
544
+ this.stage = stage;
545
+ this.target = target;
546
+ this.name = "SelfHostedTelemetryUnavailable";
547
+ }
548
+ };
549
+ /** A sample rate that is not a fraction. */
550
+ var TelemetrySampleRateInvalid = class extends Error {
551
+ stage;
552
+ sampleRate;
553
+ constructor(stage, sampleRate) {
554
+ super(`deploy.telemetry.${stage}.sampleRate is ${String(sampleRate)}; set it to a number from 0 to 1 — the fraction of traces kept — or leave it out to keep every one.`);
555
+ this.stage = stage;
556
+ this.sampleRate = sampleRate;
557
+ this.name = "TelemetrySampleRateInvalid";
558
+ }
559
+ };
560
+ /** An OTLP endpoint that is not an http(s) URL. */
561
+ var TelemetryEndpointInvalid = class extends Error {
562
+ stage;
563
+ endpoint;
564
+ constructor(stage, endpoint) {
565
+ super(`deploy.telemetry.${stage}.endpoint is ${JSON.stringify(endpoint)}; set it to the collector's OTLP/HTTP base URL, like 'https://otlp.example.com' — /v1/traces and /v1/logs are added to it.`);
566
+ this.stage = stage;
567
+ this.endpoint = endpoint;
568
+ this.name = "TelemetryEndpointInvalid";
569
+ }
570
+ };
571
+ /** The sample rate a stage keeps, checked. */
572
+ function sampleRateOf(stage, sampleRate) {
573
+ const rate = sampleRate ?? 1;
574
+ if (!Number.isFinite(rate) || rate < 0 || rate > 1) throw new TelemetrySampleRateInvalid(stage, sampleRate);
575
+ return rate;
576
+ }
577
+ /**
578
+ * Each provider's resolver: a stage's config to what the targets consume.
579
+ * A vendor preset is one more entry here.
580
+ */
581
+ const PROVIDERS = {
582
+ "self-hosted": (config, stage) => {
583
+ const { provider: _, sampleRate, ...options } = config;
584
+ return {
585
+ provider: "self-hosted",
586
+ selfHosted: resolveSelfHosted(options, stage),
587
+ sampleRate: sampleRateOf(stage, sampleRate)
588
+ };
589
+ },
590
+ otlp: (config, stage) => {
591
+ if (typeof config.endpoint !== "string" || !isHttpUrl(config.endpoint)) throw new TelemetryEndpointInvalid(stage, config.endpoint);
592
+ return {
593
+ provider: "otlp",
594
+ endpoint: config.endpoint.replace(/\/+$/, ""),
595
+ headers: { ...config.headers },
596
+ sampleRate: sampleRateOf(stage, config.sampleRate)
597
+ };
598
+ }
599
+ };
600
+ function isHttpUrl(value) {
601
+ try {
602
+ const url = new URL(value);
603
+ return url.protocol === "http:" || url.protocol === "https:";
604
+ } catch {
605
+ return false;
606
+ }
607
+ }
608
+ /**
609
+ * One stage's entry, checked on its own — what the workspace schema runs, so
610
+ * a bad config fails to load with the words a deploy would fail with.
611
+ */
612
+ function checkStageTelemetry(stage, config) {
613
+ if (config === false) return void 0;
614
+ const entry = config === "self-hosted" ? { provider: "self-hosted" } : config;
615
+ const resolve = PROVIDERS[entry.provider];
616
+ return resolve(entry, stage);
617
+ }
618
+ /**
619
+ * Where a stage's telemetry goes, or undefined when nothing is sent — no
620
+ * process uses a `Telemetry` node, or the stage opted out with `false`.
621
+ *
622
+ * The local stage always runs the self-hosted provider with its defaults and
623
+ * keeps every trace, whatever `deploy.telemetry` says. A deployed stage that
624
+ * names nothing gets the self-hosted provider where its target runs one, and
625
+ * {@link TelemetryProviderRequired} where it cannot — AWS has none.
626
+ */
627
+ function resolveStageTelemetry(input) {
628
+ const { stage } = input;
629
+ if (!input.used) return void 0;
630
+ if (input.local) return {
631
+ provider: "self-hosted",
632
+ selfHosted: resolveSelfHosted({}, stage),
633
+ sampleRate: 1
634
+ };
635
+ const config = input.telemetry?.[stage];
636
+ if (config === void 0) {
637
+ if (input.runtime === "server" && input.selfHosted) return checkStageTelemetry(stage, "self-hosted");
638
+ throw new TelemetryProviderRequired(stage, input.target);
639
+ }
640
+ const resolved = checkStageTelemetry(stage, config);
641
+ if (resolved?.provider === "self-hosted" && !input.selfHosted) throw new SelfHostedTelemetryUnavailable(stage, input.target);
642
+ return resolved;
643
+ }
644
+ /** The sampler every process with the edge runs, per the stage's rate. */
645
+ const TRACES_SAMPLER = "parentbased_traceidratio";
646
+ /**
647
+ * `OTEL_EXPORTER_OTLP_HEADERS` for a set of headers: `key=value` pairs,
648
+ * comma-separated, each value percent-encoded — the W3C baggage format the
649
+ * SDK parses.
650
+ */
651
+ function otlpHeaderString(headers) {
652
+ return Object.entries(headers).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join(",");
653
+ }
654
+ /**
655
+ * The `OTEL_*` values a stage resolves for its `Telemetry` node, before any
656
+ * one process is named: where to export, how to sign, and how much to keep.
657
+ * `OTEL_SERVICE_NAME` is each process's own — see `scopeTelemetryEnv`.
658
+ */
659
+ function telemetryEnv(destination, sampleRate) {
660
+ return {
661
+ OTEL_EXPORTER_OTLP_ENDPOINT: destination.endpoint,
662
+ ...destination.headers ? { OTEL_EXPORTER_OTLP_HEADERS: destination.headers } : {},
663
+ OTEL_TRACES_SAMPLER: TRACES_SAMPLER,
664
+ OTEL_TRACES_SAMPLER_ARG: String(sampleRate)
665
+ };
666
+ }
667
+ /** What an `otlp` stage resolves, for every process with the edge. */
668
+ function otlpTelemetryEnv(resolved) {
669
+ const headers = otlpHeaderString(resolved.headers);
670
+ return telemetryEnv({
671
+ endpoint: resolved.endpoint,
672
+ ...headers ? { headers } : {}
673
+ }, resolved.sampleRate);
674
+ }
675
+ /**
676
+ * The sample rate a stage's browsers trace page views at — a public value,
677
+ * the same rate its servers sample at — or undefined when the stage sends no
678
+ * telemetry. The local stage keeps every trace.
679
+ *
680
+ * Lenient where `resolveStageTelemetry` is strict: a site's client is built
681
+ * before, and apart from, the deploy that refuses a stage with no provider.
682
+ */
683
+ function stageSampleRate(telemetry, stage, local) {
684
+ if (local) return 1;
685
+ const config = telemetry?.[stage];
686
+ if (config === false) return void 0;
687
+ if (config === void 0 || config === "self-hosted") return 1;
688
+ return sampleRateOf(stage, config.sampleRate);
689
+ }
690
+ //#endregion
691
+ //#region src/workspace/stages.ts
692
+ /**
693
+ * What `gkm test` runs as. The CLI's own, so no project stage may take it:
694
+ * its containers are torn down and rebuilt between runs.
695
+ */
696
+ const TEST_STAGE = "test";
697
+ /** A stage becomes part of every physical name, so it has to fit in one. */
698
+ const STAGE_NAME = /^[a-z][a-z0-9-]*$/;
699
+ /** Everything wrong with one stage name, or nothing. */
700
+ function nameProblems(name) {
701
+ const problems = [];
702
+ if (!STAGE_NAME.test(name)) problems.push(`stage "${name}" must be lowercase letters, digits and hyphens, starting with a letter`);
703
+ if (name === "test") problems.push(`stage "${TEST_STAGE}" is reserved for gkm test`);
704
+ return problems;
705
+ }
706
+ /** Everything wrong with a list of deployed stages on its own. */
707
+ function deployedProblems(deployed) {
708
+ const problems = deployed.flatMap(nameProblems);
709
+ const seen = /* @__PURE__ */ new Set();
710
+ for (const name of deployed) {
711
+ if (seen.has(name)) problems.push(`stage "${name}" is listed twice`);
712
+ seen.add(name);
713
+ }
714
+ return problems;
715
+ }
716
+ /** Everything wrong with a stages block, or nothing. */
717
+ function stageProblems(stages) {
718
+ if (!stages) return ["`stages` is required, e.g. stages: { local: 'dev', deployed: ['prod'] }"];
719
+ const { local, deployed, protected: kept = [] } = stages;
720
+ const problems = [...nameProblems(local), ...deployedProblems(deployed)];
721
+ if (deployed.includes(local)) problems.push(`"${local}" is both the local stage and a deployed one; they would share secrets`);
722
+ for (const name of kept) if (!deployed.includes(name)) problems.push(`protected stage "${name}" is not a deployed stage`);
723
+ return problems;
724
+ }
725
+ /** The stages block, or an error naming everything wrong with it. */
726
+ function validateStages(stages) {
727
+ const problems = stageProblems(stages);
728
+ if (problems.length) throw new InvalidStages(problems);
729
+ return stages;
730
+ }
731
+ /** Refuses a stage the project does not deploy to. */
732
+ function assertDeployedStage(stages, stage) {
733
+ if (!stages.deployed.includes(stage)) throw new UndeclaredStage(stage, stages.deployed);
734
+ }
735
+ /** A stages block — in gkm.config.ts or from `gkm init`'s flags — that breaks a rule. */
736
+ var InvalidStages = class extends Error {
737
+ problems;
738
+ constructor(problems) {
739
+ super(`Invalid stages:\n ${problems.join("\n ")}`);
740
+ this.problems = problems;
741
+ this.name = "InvalidStages";
742
+ }
743
+ };
744
+ /**
745
+ * A stage the project does not deploy to. Refused before anything is
746
+ * provisioned, so a typo does not become a second environment.
747
+ */
748
+ var UndeclaredStage = class extends Error {
749
+ stage;
750
+ deployed;
751
+ constructor(stage, deployed) {
752
+ super(`"${stage}" is not a deployed stage. gkm.config.ts deploys to: ${deployed.join(", ") || "nothing yet"}.`);
753
+ this.stage = stage;
754
+ this.deployed = deployed;
755
+ this.name = "UndeclaredStage";
756
+ }
757
+ };
758
+ /**
759
+ * A per-stage setting keyed by a stage the workspace does not deploy: a typo,
760
+ * a stage since removed, or the local stage, which none of them apply to.
761
+ */
762
+ var UnknownStageKey = class extends Error {
763
+ setting;
764
+ stage;
765
+ deployed;
766
+ local;
767
+ constructor(setting, stage, deployed, local) {
768
+ super(`${setting} names the stage '${stage}', ` + (stage === local ? `the local stage — ${setting} is read for deployed stages only. ` : "which is not one of this workspace's deployed stages. ") + `It takes ${deployed.length > 0 ? deployed.map((s) => `'${s}'`).join(", ") : "no stage: stages.deployed is empty"} — the stages in stages.deployed.`);
769
+ this.setting = setting;
770
+ this.stage = stage;
771
+ this.deployed = deployed;
772
+ this.local = local;
773
+ this.name = "UnknownStageKey";
774
+ }
775
+ };
776
+ /**
777
+ * The first key of a per-stage map that is not a deployed stage.
778
+ *
779
+ * @throws {UnknownStageKey}
780
+ */
781
+ function assertDeployedStageKeys(setting, map, stages) {
782
+ if (!map || !stages?.deployed) return;
783
+ for (const key of Object.keys(map)) if (!stages.deployed.includes(key)) throw new UnknownStageKey(setting, key, stages.deployed, stages.local);
784
+ }
785
+ //#endregion
786
+ //#region src/workspace/schema.ts
787
+ /** Routes are a glob, or a list of them. */
788
+ const RoutesSchema = union([string(), array(string())]);
789
+ /**
790
+ * Telescope configuration schema.
791
+ */
792
+ const TelescopeConfigSchema = object({
793
+ enabled: boolean().optional(),
794
+ port: number().optional(),
795
+ path: string().optional(),
796
+ ignore: array(string()).optional(),
797
+ recordBody: boolean().optional(),
798
+ maxEntries: number().optional(),
799
+ websocket: boolean().optional()
800
+ });
801
+ /**
802
+ * OpenAPI configuration schema.
803
+ */
804
+ const OpenApiConfigSchema = object({
805
+ enabled: boolean().optional(),
806
+ title: string().optional(),
807
+ version: string().optional(),
808
+ description: string().optional()
809
+ });
810
+ /**
811
+ * Hooks configuration schema.
812
+ */
813
+ const HooksConfigSchema = object({ server: string().optional() });
814
+ /**
815
+ * Backend framework schema for non-gkm apps.
816
+ */
817
+ const BackendFrameworkSchema = _enum([
818
+ "hono",
819
+ "better-auth",
820
+ "express",
821
+ "fastify"
822
+ ]);
823
+ /**
824
+ * Frontend framework schema.
825
+ */
826
+ const FrontendFrameworkSchema = _enum([
827
+ "nextjs",
828
+ "remix",
829
+ "vite",
830
+ "tanstack-start"
831
+ ]);
832
+ /**
833
+ * Mobile framework schema.
834
+ */
835
+ const MobileFrameworkSchema = _enum(["expo"]);
836
+ /**
837
+ * Combined framework schema (backend, frontend, or mobile).
838
+ */
839
+ const FrameworkSchema = union([
840
+ BackendFrameworkSchema,
841
+ FrontendFrameworkSchema,
842
+ MobileFrameworkSchema
843
+ ]);
844
+ /** Frontend framework values, kept in sync with FrontendFrameworkSchema. */
845
+ const FRONTEND_FRAMEWORKS = [
846
+ "nextjs",
847
+ "remix",
848
+ "vite",
849
+ "tanstack-start"
850
+ ];
851
+ /** Mobile framework values, kept in sync with MobileFrameworkSchema. */
852
+ const MOBILE_FRAMEWORKS = ["expo"];
853
+ /**
854
+ * A deploy target's name. Which names exist is the workspace's to say — the
855
+ * built-ins and its own `deploy.targets` — so it is checked against both
856
+ * once the whole config is read.
857
+ */
858
+ const DeployTargetSchema = string().min(1);
859
+ /**
860
+ * The built-in targets a config may name, both deployed by `gkm deploy`:
861
+ * `dokploy`, and `sst`, which runs `sst deploy` on the manifest `gkm build`
862
+ * writes.
863
+ */
864
+ const SUPPORTED_DEPLOY_TARGETS = configurableBuiltins();
865
+ /** Built-in names reserved for targets that do not exist yet. */
866
+ const PHASE_2_DEPLOY_TARGETS = Object.entries(BUILTIN_TARGETS).filter(([, target]) => target.status === "planned").map(([name]) => name);
867
+ /**
868
+ * Whether a config may name `target`: a usable built-in, or one of its own
869
+ * `deploy.targets`.
870
+ */
871
+ function isDeployTargetSupported(target, targets = {}) {
872
+ return SUPPORTED_DEPLOY_TARGETS.includes(target) || Object.hasOwn(targets, target);
873
+ }
874
+ /**
875
+ * Check if a deploy target is planned for Phase 2.
876
+ */
877
+ function isPhase2DeployTarget(target) {
878
+ return PHASE_2_DEPLOY_TARGETS.includes(target);
879
+ }
880
+ /**
881
+ * Get error message for unsupported deploy targets.
882
+ */
883
+ function getDeployTargetError(target, appName) {
884
+ if (isPhase2DeployTarget(target)) return `Deploy target "${target}"${appName ? ` for app "${appName}"` : ""} is coming in Phase 2. Currently "dokploy" and "sst" are supported.`;
885
+ return `Unknown deploy target: ${target}. Built in: ${SUPPORTED_DEPLOY_TARGETS.join(", ")}; any other is named in deploy.targets with the package that provides it. Coming in Phase 2: ${PHASE_2_DEPLOY_TARGETS.join(", ")}.`;
886
+ }
887
+ /**
888
+ * One `deploy.targets` entry: a package name, a target object, or either
889
+ * with options.
890
+ */
891
+ const DeployTargetEntrySchema = union([
892
+ string().min(1, "A target package name cannot be empty"),
893
+ custom((value) => isDeployTarget(value), { message: "Expected a package name, a target (defineTarget), or [package or target, options]" }),
894
+ tuple([union([string().min(1), custom((value) => isDeployTarget(value), { message: "Expected a package name or a target (defineTarget)" })]), unknown()])
895
+ ]);
896
+ /**
897
+ * Dokploy workspace configuration schema.
898
+ * Supports either a single endpoint or per-stage endpoints.
899
+ */
900
+ const DokployWorkspaceConfigSchema = object({
901
+ /** Single endpoint for all stages */
902
+ endpoint: url("Dokploy endpoint must be a valid URL").optional(),
903
+ /** Per-stage endpoints (stage name -> endpoint URL) */
904
+ endpoints: record(string(), url("Endpoint must be a valid URL")).optional(),
905
+ registryId: string().optional(),
906
+ verify: object({
907
+ deploymentTimeoutMs: number().int().positive().optional(),
908
+ healthCheckPath: string().startsWith("/", "healthCheckPath must start with /").optional(),
909
+ healthyAfter: number().int().positive().optional(),
910
+ intervalMs: number().int().positive().optional(),
911
+ healthTimeoutMs: number().int().positive().optional()
912
+ }).optional()
913
+ }).refine((data) => data.endpoint || data.endpoints, { message: "Either endpoint or endpoints must be provided" });
914
+ /**
915
+ * Valid AWS regions.
916
+ */
917
+ const AwsRegionSchema = _enum([
918
+ "us-east-1",
919
+ "us-east-2",
920
+ "us-west-1",
921
+ "us-west-2",
922
+ "af-south-1",
923
+ "ap-east-1",
924
+ "ap-south-1",
925
+ "ap-south-2",
926
+ "ap-southeast-1",
927
+ "ap-southeast-2",
928
+ "ap-southeast-3",
929
+ "ap-southeast-4",
930
+ "ap-northeast-1",
931
+ "ap-northeast-2",
932
+ "ap-northeast-3",
933
+ "ca-central-1",
934
+ "eu-central-1",
935
+ "eu-central-2",
936
+ "eu-west-1",
937
+ "eu-west-2",
938
+ "eu-west-3",
939
+ "eu-south-1",
940
+ "eu-south-2",
941
+ "eu-north-1",
942
+ "me-south-1",
943
+ "me-central-1",
944
+ "sa-east-1"
945
+ ]);
946
+ /**
947
+ * DNS record types supported across providers.
948
+ */
949
+ const DnsRecordTypeSchema = _enum([
950
+ "A",
951
+ "AAAA",
952
+ "CNAME",
953
+ "MX",
954
+ "TXT",
955
+ "NS",
956
+ "SRV",
957
+ "CAA"
958
+ ]);
959
+ object({
960
+ /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
961
+ name: string(),
962
+ /** Record type */
963
+ type: DnsRecordTypeSchema,
964
+ /** TTL in seconds */
965
+ ttl: number().int().positive(),
966
+ /** Record values */
967
+ values: array(string())
968
+ });
969
+ /**
970
+ * A DNS record to create or update.
971
+ */
972
+ const UpsertDnsRecordSchema = object({
973
+ /** Subdomain name (e.g., 'api' for api.example.com, '@' for root) */
974
+ name: string(),
975
+ /** Record type */
976
+ type: DnsRecordTypeSchema,
977
+ /** TTL in seconds */
978
+ ttl: number().int().positive(),
979
+ /** Record value (IP address, hostname, etc.) */
980
+ value: string()
981
+ });
982
+ object({
983
+ /** The record that was upserted */
984
+ record: UpsertDnsRecordSchema,
985
+ /** Whether the record was created (true) or updated (false) */
986
+ created: boolean(),
987
+ /** Whether the record already existed with the same value */
988
+ unchanged: boolean()
989
+ });
990
+ /**
991
+ * How a domain's hosts point at a compose stage's server: an A (and AAAA)
992
+ * record each (`'a'`, the default), or one A record for `target` and a CNAME
993
+ * to it for every other host but the apex. `target` is one name, or one per
994
+ * stage; it must be under the domain.
995
+ */
996
+ const DnsRecordsModeSchema = union([literal("a"), object({
997
+ mode: literal("cname"),
998
+ target: union([string(), record(string(), string())])
999
+ }).strict()]);
1000
+ /**
1001
+ * Hostinger DNS provider config (without domain - domain is the record key).
1002
+ */
1003
+ const HostingerDnsProviderSchema = object({
1004
+ provider: literal("hostinger"),
1005
+ /** How the hosts point at a compose stage's server — see {@link DnsRecordsModeSchema}. */
1006
+ records: DnsRecordsModeSchema.optional(),
1007
+ /** TTL in seconds (default: 300) */
1008
+ ttl: number().int().positive().optional()
1009
+ });
1010
+ /**
1011
+ * Route53 DNS provider config (without domain - domain is the record key).
1012
+ */
1013
+ const Route53DnsProviderSchema = object({
1014
+ provider: literal("route53"),
1015
+ /** How the hosts point at a compose stage's server — see {@link DnsRecordsModeSchema}. */
1016
+ records: DnsRecordsModeSchema.optional(),
1017
+ /** AWS region (optional - uses AWS_REGION env var if not provided) */
1018
+ region: AwsRegionSchema.optional(),
1019
+ /** AWS profile name (optional - uses default credential chain if not provided) */
1020
+ profile: string().optional(),
1021
+ /** Hosted zone ID (optional - auto-detected from domain if not provided) */
1022
+ hostedZoneId: string().optional(),
1023
+ /** TTL in seconds (default: 300) */
1024
+ ttl: number().int().positive().optional()
1025
+ });
1026
+ /**
1027
+ * GoDaddy DNS provider config (without domain - domain is the record key).
1028
+ *
1029
+ * Credentials: `GODADDY_API_TOKEN` (a Personal Access Token scoped to
1030
+ * `domains.dns:update`), else `gkm login --provider godaddy`. GoDaddy refuses
1031
+ * a TTL under 600 seconds.
1032
+ */
1033
+ const GoDaddyDnsProviderSchema = object({
1034
+ provider: literal("godaddy"),
1035
+ /** How the hosts point at a compose stage's server — see {@link DnsRecordsModeSchema}. */
1036
+ records: DnsRecordsModeSchema.optional(),
1037
+ /** TTL in seconds (default and minimum: 600) */
1038
+ ttl: number().int().min(600, "GoDaddy's minimum TTL is 600 seconds").optional()
1039
+ });
1040
+ /**
1041
+ * Cloudflare DNS provider config (placeholder for future).
1042
+ */
1043
+ const CloudflareDnsProviderSchema = object({
1044
+ provider: literal("cloudflare"),
1045
+ /** How the hosts point at a compose stage's server — see {@link DnsRecordsModeSchema}. */
1046
+ records: DnsRecordsModeSchema.optional(),
1047
+ /** TTL in seconds (default: 300) */
1048
+ ttl: number().int().positive().optional()
1049
+ });
1050
+ /**
1051
+ * Manual DNS configuration (user handles DNS themselves).
1052
+ */
1053
+ const ManualDnsProviderSchema = object({
1054
+ provider: literal("manual"),
1055
+ /** How the hosts point at a compose stage's server — see {@link DnsRecordsModeSchema}. */
1056
+ records: DnsRecordsModeSchema.optional()
1057
+ });
1058
+ /**
1059
+ * Custom DNS provider config (user-provided implementation).
1060
+ */
1061
+ const CustomDnsProviderSchema = object({
1062
+ /** Custom DnsProvider implementation */
1063
+ provider: custom((val) => typeof val === "object" && val !== null && typeof val.name === "string" && typeof val.getRecords === "function" && typeof val.upsertRecords === "function", { message: "Custom DNS provider must implement name, getRecords(), and upsertRecords() methods" }),
1064
+ /** How the hosts point at a compose stage's server — see {@link DnsRecordsModeSchema}. */
1065
+ records: DnsRecordsModeSchema.optional(),
1066
+ /** TTL in seconds (default: 300) */
1067
+ ttl: number().int().positive().optional()
1068
+ });
1069
+ /**
1070
+ * Built-in DNS provider config (discriminated union).
1071
+ */
1072
+ const BuiltInDnsProviderSchema = discriminatedUnion("provider", [
1073
+ HostingerDnsProviderSchema,
1074
+ Route53DnsProviderSchema,
1075
+ GoDaddyDnsProviderSchema,
1076
+ CloudflareDnsProviderSchema,
1077
+ ManualDnsProviderSchema
1078
+ ]);
1079
+ /**
1080
+ * Single DNS provider config (for one domain).
1081
+ */
1082
+ const DnsProviderSchema = union([BuiltInDnsProviderSchema, CustomDnsProviderSchema]);
1083
+ /**
1084
+ * DNS configuration schema.
1085
+ *
1086
+ * Maps root domains to their DNS provider configuration.
1087
+ * Example:
1088
+ * ```
1089
+ * dns: {
1090
+ * 'geekmidas.dev': { provider: 'hostinger' },
1091
+ * 'geekmidas.com': { provider: 'route53' },
1092
+ * }
1093
+ * ```
1094
+ *
1095
+ * Supported providers:
1096
+ * - 'hostinger': Use Hostinger DNS API
1097
+ * - 'route53': Use AWS Route53
1098
+ * - 'godaddy': Use GoDaddy's v1 DNS API
1099
+ * - 'cloudflare': Use Cloudflare DNS API (future)
1100
+ * - 'manual': Don't create records, just print required records
1101
+ * - Custom: Provide a DnsProvider implementation
1102
+ */
1103
+ const DnsConfigSchema = record(string(), DnsProviderSchema);
1104
+ const HostingerDnsConfigSchema = HostingerDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
1105
+ const Route53DnsConfigSchema = Route53DnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
1106
+ const GoDaddyDnsConfigSchema = GoDaddyDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
1107
+ const CloudflareDnsConfigSchema = CloudflareDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
1108
+ const ManualDnsConfigSchema = ManualDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
1109
+ const CustomDnsConfigSchema = CustomDnsProviderSchema.extend({ domain: string().min(1, "Domain is required") });
1110
+ const BuiltInDnsConfigSchema = discriminatedUnion("provider", [
1111
+ HostingerDnsConfigSchema,
1112
+ Route53DnsConfigSchema,
1113
+ GoDaddyDnsConfigSchema,
1114
+ CloudflareDnsConfigSchema,
1115
+ ManualDnsConfigSchema
1116
+ ]);
1117
+ const LegacyDnsConfigSchema = union([BuiltInDnsConfigSchema, CustomDnsConfigSchema]);
1118
+ union([DnsConfigSchema, LegacyDnsConfigSchema]);
1119
+ /**
1120
+ * Backups configuration schema.
1121
+ *
1122
+ * Configures automatic backup destinations for database services.
1123
+ * On first deploy, creates S3 bucket with unique name and IAM credentials.
1124
+ */
1125
+ const BackupsConfigSchema = object({
1126
+ /** Backup storage type (currently only 's3' supported) */
1127
+ type: literal("s3"),
1128
+ /** AWS profile name for creating bucket/IAM resources */
1129
+ profile: string().optional(),
1130
+ /** AWS region for the backup bucket */
1131
+ region: AwsRegionSchema,
1132
+ /** Cron schedule for backups (default: '0 2 * * *' = 2 AM daily) */
1133
+ schedule: string().optional(),
1134
+ /** Number of backups to retain (default: 30) */
1135
+ retention: number().optional()
1136
+ });
1137
+ /** `deploy.compose` — what the compose target runs beside the apps. */
1138
+ const ComposeWorkspaceConfigSchema = object({
1139
+ proxy: union([_enum(["caddy", "traefik"]), record(string(), _enum(["caddy", "traefik"]))]).optional(),
1140
+ tls: record(string(), object({
1141
+ certFile: string().min(1),
1142
+ keyFile: string().min(1)
1143
+ }).strict()).optional()
1144
+ }).strict();
1145
+ const TelemetrySampleRate = number().optional();
1146
+ /**
1147
+ * `deploy.telemetry` — where each stage's telemetry goes. The rules past the
1148
+ * shape are `checkStageTelemetry`'s, so the schema and a deploy refuse the
1149
+ * same configs with the same words.
1150
+ */
1151
+ const TelemetryConfigSchema = record(string(), union([
1152
+ literal(false),
1153
+ literal("self-hosted"),
1154
+ object({
1155
+ provider: literal("self-hosted"),
1156
+ port: number().optional(),
1157
+ retentionDays: number().optional(),
1158
+ public: object({ allow: array(string()) }).optional(),
1159
+ sampleRate: TelemetrySampleRate
1160
+ }).strict(),
1161
+ object({
1162
+ provider: literal("otlp"),
1163
+ endpoint: string(),
1164
+ headers: record(string(), string()).optional(),
1165
+ sampleRate: TelemetrySampleRate
1166
+ }).strict()
1167
+ ])).superRefine((telemetry, ctx) => {
1168
+ for (const [stage, config] of Object.entries(telemetry)) try {
1169
+ checkStageTelemetry(stage, config);
1170
+ } catch (error) {
1171
+ ctx.addIssue({
1172
+ code: "custom",
1173
+ message: error instanceof Error ? error.message : String(error),
1174
+ path: [stage]
1175
+ });
1176
+ }
1177
+ });
1178
+ /**
1179
+ * `deploy.objects` — what backs each deployed stage's buckets. The rules are
1180
+ * `checkStageProvider`'s, so the schema and a provision run refuse the same
1181
+ * entries with the same words.
1182
+ */
1183
+ const ObjectsConfigSchema = record(string(), unknown()).superRefine((entries, ctx) => {
1184
+ for (const [stage, value] of Object.entries(entries)) try {
1185
+ checkStageProvider("objects", stage, value);
1186
+ } catch (error) {
1187
+ ctx.addIssue({
1188
+ code: "custom",
1189
+ message: error instanceof Error ? error.message : String(error),
1190
+ path: [stage]
1191
+ });
1192
+ }
1193
+ });
1194
+ /**
1195
+ * Deploy configuration schema.
1196
+ */
1197
+ const DeployConfigSchema = object({
1198
+ default: DeployTargetSchema.optional(),
1199
+ targets: record(string(), DeployTargetEntrySchema).superRefine((targets, ctx) => {
1200
+ for (const name of Object.keys(targets)) if (builtinTarget(name)) ctx.addIssue({
1201
+ code: "custom",
1202
+ message: `"${name}" is a built-in target; give this one a name of its own`,
1203
+ path: [name]
1204
+ });
1205
+ }).optional(),
1206
+ /** Whose deploy this is, on a target shared with other workspaces. */
1207
+ namespace: string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "deploy.namespace must be lowercase letters and digits with single '-' between them").optional(),
1208
+ /** Where every target pushes and pulls the apps' images. */
1209
+ registry: string().min(1).optional(),
1210
+ dokploy: DokployWorkspaceConfigSchema.optional(),
1211
+ compose: ComposeWorkspaceConfigSchema.optional(),
1212
+ telemetry: TelemetryConfigSchema.optional(),
1213
+ objects: ObjectsConfigSchema.optional(),
1214
+ backups: BackupsConfigSchema.optional()
1215
+ });
1216
+ /**
1217
+ * Models configuration schema.
1218
+ */
1219
+ const ModelsConfigSchema = object({
1220
+ path: string().optional(),
1221
+ schema: _enum(["zod"]).optional()
1222
+ });
1223
+ /**
1224
+ * Shared configuration schema.
1225
+ */
1226
+ const SharedConfigSchema = object({
1227
+ packages: array(string()).optional(),
1228
+ models: ModelsConfigSchema.optional()
1229
+ });
1230
+ /**
1231
+ * Secrets configuration schema.
1232
+ */
1233
+ const StagesConfigSchema = object({
1234
+ local: string(),
1235
+ deployed: array(string()),
1236
+ protected: array(string()).optional()
1237
+ }).superRefine((stages, ctx) => {
1238
+ for (const message of stageProblems(stages)) ctx.addIssue({
1239
+ code: "custom",
1240
+ message
1241
+ });
1242
+ });
1243
+ const SecretsStoreSchema = union([
1244
+ literal("file"),
1245
+ object({
1246
+ provider: literal("ssm"),
1247
+ region: AwsRegionSchema
1248
+ }).strict(),
1249
+ object({
1250
+ provider: literal("secrets-manager"),
1251
+ region: AwsRegionSchema,
1252
+ kmsKeyId: string().min(1).optional()
1253
+ }).strict(),
1254
+ object({
1255
+ /** Any backend: an object implementing SecretsStore */
1256
+ provider: custom((val) => typeof val === "object" && val !== null && typeof val.name === "string" && typeof val.read === "function" && typeof val.write === "function", { message: "a secrets store has a name, read() and write()" }) })
1257
+ ]);
1258
+ const SecretsConfigSchema = object({
1259
+ enabled: boolean().optional(),
1260
+ store: SecretsStoreSchema.optional(),
1261
+ algorithm: string().optional(),
1262
+ kdf: _enum(["scrypt", "pbkdf2"]).optional()
1263
+ });
1264
+ /**
1265
+ * Local state provider config.
1266
+ */
1267
+ const LocalStateConfigSchema = object({ provider: literal("local") });
1268
+ /**
1269
+ * SSM state provider config (requires region).
1270
+ */
1271
+ const SSMStateConfigSchema = object({
1272
+ provider: literal("ssm"),
1273
+ /** AWS region (required for SSM provider) */
1274
+ region: AwsRegionSchema,
1275
+ /** AWS profile name (optional - uses default credential chain if not provided) */
1276
+ profile: string().optional()
1277
+ });
1278
+ /**
1279
+ * S3 state provider config: conditional writes and a lock object in a bucket.
1280
+ */
1281
+ const S3StateConfigSchema = object({
1282
+ provider: literal("s3"),
1283
+ /** Bucket the state lives in (must already exist) */
1284
+ bucket: string().min(1),
1285
+ /** AWS region of the bucket */
1286
+ region: AwsRegionSchema,
1287
+ /** Key prefix inside the bucket (default: 'gkm') */
1288
+ prefix: string().optional(),
1289
+ /** AWS profile name (optional - uses default credential chain if not provided) */
1290
+ profile: string().optional()
1291
+ });
1292
+ /**
1293
+ * Custom state provider config (user-provided implementation).
1294
+ */
1295
+ const CustomStateConfigSchema = object({
1296
+ /** Custom StateProvider implementation */
1297
+ provider: custom((val) => typeof val === "object" && val !== null && typeof val.read === "function" && typeof val.write === "function", { message: "Custom provider must implement read() and write() methods" }) });
1298
+ /**
1299
+ * Built-in state provider config (discriminated union).
1300
+ */
1301
+ const BuiltInStateConfigSchema = discriminatedUnion("provider", [
1302
+ LocalStateConfigSchema,
1303
+ SSMStateConfigSchema,
1304
+ S3StateConfigSchema
1305
+ ]);
1306
+ /**
1307
+ * State configuration schema.
1308
+ *
1309
+ * Configures how deployment state is stored.
1310
+ * - 'local': Store in .gkm/deploy-{stage}.json (default)
1311
+ * - 'ssm': Store in AWS SSM Parameter Store (requires region)
1312
+ * - 's3': Store in an S3 bucket with conditional writes (requires bucket, region)
1313
+ * - Custom: Provide a StateStore, or a StateProvider with read/write methods
1314
+ */
1315
+ const StateConfigSchema = union([BuiltInStateConfigSchema, CustomStateConfigSchema]);
1316
+ /**
1317
+ * App configuration schema.
1318
+ */
1319
+ const AppConfigSchema = object({
1320
+ type: _enum([
1321
+ "backend",
1322
+ "web",
1323
+ "mobile"
1324
+ ]).optional().default("backend"),
1325
+ path: string().min(1, "App path is required"),
1326
+ port: number().int().positive("Port must be a positive integer"),
1327
+ dependencies: array(string()).optional(),
1328
+ deploy: DeployTargetSchema.optional(),
1329
+ constructs: RoutesSchema.optional(),
1330
+ routes: RoutesSchema.optional(),
1331
+ functions: RoutesSchema.optional(),
1332
+ crons: RoutesSchema.optional(),
1333
+ queues: RoutesSchema.optional(),
1334
+ topics: RoutesSchema.optional(),
1335
+ subscribers: RoutesSchema.optional(),
1336
+ envParser: string().optional(),
1337
+ logger: string().optional(),
1338
+ hooks: HooksConfigSchema.optional(),
1339
+ telescope: union([
1340
+ string(),
1341
+ boolean(),
1342
+ TelescopeConfigSchema
1343
+ ]).optional(),
1344
+ openapi: union([boolean(), OpenApiConfigSchema]).optional(),
1345
+ runtime: _enum(["node", "bun"]).optional(),
1346
+ env: union([string(), array(string())]).optional(),
1347
+ entry: string().optional(),
1348
+ framework: FrameworkSchema.optional(),
1349
+ config: object({
1350
+ client: string().optional(),
1351
+ server: string().optional()
1352
+ }).optional()
1353
+ }).refine((data) => {
1354
+ if (data.type === "web") {
1355
+ if (!data.framework || !FRONTEND_FRAMEWORKS.includes(data.framework)) return false;
1356
+ }
1357
+ return true;
1358
+ }, {
1359
+ message: `Web apps must have a valid web framework (${FRONTEND_FRAMEWORKS.join(", ")})`,
1360
+ path: ["framework"]
1361
+ }).refine((data) => {
1362
+ if (data.type === "mobile") {
1363
+ if (!data.framework || !MOBILE_FRAMEWORKS.includes(data.framework)) return false;
1364
+ }
1365
+ return true;
1366
+ }, {
1367
+ message: `Mobile apps must have a valid mobile framework (${MOBILE_FRAMEWORKS.join(", ")})`,
1368
+ path: ["framework"]
1369
+ });
1370
+ /** What `gkm test` hands a feature test. */
1371
+ const TestConfigSchema = object({
1372
+ /** The folder of per-database factories; `test/factories` by default. */
1373
+ factories: string().optional() }).strict();
1374
+ /** How `gkm dev` is reached from outside the apps it runs. */
1375
+ const DevConfigSchema = object({
1376
+ /** Browser origins that may read the discovery endpoint. */
1377
+ allowedOrigins: array(url().refine((value) => URL.canParse(value) && new URL(value).origin === value, { message: "An origin is a scheme, host and port only, e.g. https://console.example.com — no path or trailing slash" })).optional(),
1378
+ /** The discovery endpoint's loopback port; 4983 by default. */
1379
+ discoveryPort: number().int().min(0).max(65535).optional()
1380
+ }).strict();
1381
+ /**
1382
+ * Workspace configuration schema.
1383
+ */
1384
+ const WorkspaceConfigSchema = object({
1385
+ name: string().optional(),
1386
+ /**
1387
+ * Where the workspace's own constructs live, relative to its root.
1388
+ *
1389
+ * Infrastructure is a fact about the product, not about the process that
1390
+ * happens to import it — so a database two apps share is declared once,
1391
+ * at the top, and both find it. An app-level glob still works and is
1392
+ * additive, for something only one app uses.
1393
+ */
1394
+ constructs: RoutesSchema.optional(),
1395
+ /**
1396
+ * Apps that nothing declares.
1397
+ *
1398
+ * Optional, and normally absent: a `site` is an app and so is a
1399
+ * `rest-api` that named one, so the list is read off the graph. This is
1400
+ * the escape hatch for what no construct describes — a mobile app, a
1401
+ * process someone runs by hand — and for overriding one field of a
1402
+ * derived app without restating it.
1403
+ */
1404
+ apps: record(string(), AppConfigSchema).optional(),
1405
+ shared: SharedConfigSchema.optional(),
1406
+ /** Each deployed stage's base domain (stage name -> domain). */
1407
+ domains: record(string(), string()).optional(),
1408
+ /** Each root domain's DNS provider, and how its hosts are pointed. */
1409
+ dns: DnsConfigSchema.optional(),
1410
+ deploy: DeployConfigSchema.optional(),
1411
+ stages: StagesConfigSchema,
1412
+ secrets: SecretsConfigSchema.optional(),
1413
+ state: StateConfigSchema.optional(),
1414
+ test: TestConfigSchema.optional(),
1415
+ dev: DevConfigSchema.optional()
1416
+ }).strict().refine((data) => {
1417
+ const appNames = Object.keys(data.apps ?? {});
1418
+ for (const [appName, app] of Object.entries(data.apps ?? {})) for (const dep of app.dependencies ?? []) {
1419
+ if (!appNames.includes(dep)) return false;
1420
+ if (dep === appName) return false;
1421
+ }
1422
+ return true;
1423
+ }, { message: "App dependencies must reference existing apps and cannot be self-referential" }).refine((data) => {
1424
+ const appNames = Object.keys(data.apps ?? {});
1425
+ const visited = /* @__PURE__ */ new Set();
1426
+ const recStack = /* @__PURE__ */ new Set();
1427
+ function hasCycle(app) {
1428
+ if (recStack.has(app)) return true;
1429
+ if (visited.has(app)) return false;
1430
+ visited.add(app);
1431
+ recStack.add(app);
1432
+ const deps = data.apps?.[app]?.dependencies ?? [];
1433
+ for (const dep of deps) if (hasCycle(dep)) return true;
1434
+ recStack.delete(app);
1435
+ return false;
1436
+ }
1437
+ for (const app of appNames) {
1438
+ visited.clear();
1439
+ recStack.clear();
1440
+ if (hasCycle(app)) return false;
1441
+ }
1442
+ return true;
1443
+ }, { message: "Circular dependencies detected between apps" }).superRefine((data, ctx) => {
1444
+ const defaultTarget = data.deploy?.default;
1445
+ const ownTargets = data.deploy?.targets ?? {};
1446
+ if (defaultTarget && !isDeployTargetSupported(defaultTarget, ownTargets)) {
1447
+ ctx.addIssue({
1448
+ code: "custom",
1449
+ message: getDeployTargetError(defaultTarget),
1450
+ path: ["deploy", "default"]
1451
+ });
1452
+ return;
1453
+ }
1454
+ for (const [appName, app] of Object.entries(data.apps ?? {})) if (app.deploy && !isDeployTargetSupported(app.deploy, ownTargets)) {
1455
+ ctx.addIssue({
1456
+ code: "custom",
1457
+ message: getDeployTargetError(app.deploy, appName),
1458
+ path: [
1459
+ "apps",
1460
+ appName,
1461
+ "deploy"
1462
+ ]
1463
+ });
1464
+ return;
1465
+ }
1466
+ try {
1467
+ checkComposeStages(data.deploy?.compose, data.stages);
1468
+ } catch (error) {
1469
+ ctx.addIssue({
1470
+ code: "custom",
1471
+ message: error instanceof Error ? error.message : String(error),
1472
+ path: ["deploy", "compose"]
1473
+ });
1474
+ }
1475
+ const perStage = [
1476
+ [
1477
+ "domains",
1478
+ ["domains"],
1479
+ data.domains
1480
+ ],
1481
+ [
1482
+ "deploy.objects",
1483
+ ["deploy", "objects"],
1484
+ data.deploy?.objects
1485
+ ],
1486
+ [
1487
+ "deploy.telemetry",
1488
+ ["deploy", "telemetry"],
1489
+ data.deploy?.telemetry
1490
+ ],
1491
+ ...Object.entries(data.dns ?? {}).map(([domain, entry]) => {
1492
+ const records = entry.records;
1493
+ const target = records && typeof records === "object" ? records.target : void 0;
1494
+ return [
1495
+ `dns['${domain}'].records.target`,
1496
+ [
1497
+ "dns",
1498
+ domain,
1499
+ "records",
1500
+ "target"
1501
+ ],
1502
+ target && typeof target === "object" ? target : void 0
1503
+ ];
1504
+ })
1505
+ ];
1506
+ for (const [setting, path, map] of perStage) try {
1507
+ assertDeployedStageKeys(setting, map, data.stages);
1508
+ } catch (error) {
1509
+ ctx.addIssue({
1510
+ code: "custom",
1511
+ message: error instanceof Error ? error.message : String(error),
1512
+ path
1513
+ });
1514
+ }
1515
+ for (const [domain, entry] of Object.entries(data.dns ?? {})) try {
1516
+ checkDnsRecordsMode(domain, entry.records);
1517
+ } catch (error) {
1518
+ ctx.addIssue({
1519
+ code: "custom",
1520
+ message: error instanceof Error ? error.message : String(error),
1521
+ path: [
1522
+ "dns",
1523
+ domain,
1524
+ "records"
1525
+ ]
1526
+ });
1527
+ }
1528
+ if (data.state?.provider === "ssm" && !data.name) ctx.addIssue({
1529
+ code: "custom",
1530
+ message: "Workspace name is required when using SSM state provider. Add \"name\" to your gkm.config.ts.",
1531
+ path: ["name"]
1532
+ });
1533
+ });
1534
+ /**
1535
+ * Validate workspace configuration.
1536
+ * Throws ZodError with detailed messages on validation failure.
1537
+ */
1538
+ function validateWorkspaceConfig(config) {
1539
+ return WorkspaceConfigSchema.parse(config);
1540
+ }
1541
+ /**
1542
+ * Safe validation that returns result instead of throwing.
1543
+ */
1544
+ function safeValidateWorkspaceConfig(config) {
1545
+ const result = WorkspaceConfigSchema.safeParse(config);
1546
+ if (result.success) return {
1547
+ success: true,
1548
+ data: result.data
1549
+ };
1550
+ return {
1551
+ success: false,
1552
+ error: result.error
1553
+ };
1554
+ }
1555
+ /**
1556
+ * Format Zod errors into user-friendly messages.
1557
+ */
1558
+ function formatValidationErrors(error) {
1559
+ return `Workspace configuration validation failed:\n${error.issues.map((issue) => {
1560
+ const path = issue.path.join(".");
1561
+ return path ? ` - ${path}: ${issue.message}` : ` - ${issue.message}`;
1562
+ }).join("\n")}`;
1563
+ }
1564
+ //#endregion
1565
+ //#region src/workspace/types.ts
1566
+ /**
1567
+ * Type guard to check if a config is a WorkspaceConfig.
1568
+ *
1569
+ * @example
1570
+ * ```ts
1571
+ * const config = await loadConfig();
1572
+ * if (isWorkspaceConfig(config)) {
1573
+ * // config.apps is available
1574
+ * console.log(Object.keys(config.apps));
1575
+ * }
1576
+ * ```
1577
+ */
1578
+ function isWorkspaceConfig(config) {
1579
+ if (typeof config !== "object" || config === null) return false;
1580
+ if ("apps" in config && typeof config.apps === "object") return true;
1581
+ return "constructs" in config && Object.keys(config).every((key) => WORKSPACE_KEYS.has(key));
1582
+ }
1583
+ /** Every top-level key a workspace config has — see `WorkspaceConfigSchema`. */
1584
+ const WORKSPACE_KEYS = /* @__PURE__ */ new Set([
1585
+ "name",
1586
+ "constructs",
1587
+ "apps",
1588
+ "shared",
1589
+ "domains",
1590
+ "dns",
1591
+ "deploy",
1592
+ "stages",
1593
+ "secrets",
1594
+ "state"
1595
+ ]);
1596
+ //#endregion
1597
+ //#region src/workspace/publicEnv.ts
1598
+ /**
1599
+ * All public env-var prefixes the toolbox understands.
1600
+ *
1601
+ * Used when resolving incoming var names back to a dependency
1602
+ * (e.g. `VITE_AUTH_URL` → `auth`). A var matching any of these
1603
+ * is considered safe to inline into a client bundle.
1604
+ */
1605
+ const PUBLIC_ENV_PREFIXES = [
1606
+ "NEXT_PUBLIC_",
1607
+ "VITE_",
1608
+ "EXPO_PUBLIC_"
1609
+ ];
1610
+ /**
1611
+ * Resolve the public env-var prefix that a frontend framework's bundler
1612
+ * inlines into client code at build time:
1613
+ *
1614
+ * - `nextjs` → `NEXT_PUBLIC_`
1615
+ * - `vite` → `VITE_`
1616
+ * - `tanstack-start` → `VITE_` (uses Vite under the hood)
1617
+ * - `expo` → `EXPO_PUBLIC_`
1618
+ * - `remix` → `''` (Remix exposes via loaders, no prefix convention)
1619
+ *
1620
+ * For backend frameworks or unspecified, falls back to `NEXT_PUBLIC_` to
1621
+ * preserve the historical default. Backend apps never read these vars
1622
+ * from a bundle, so the prefix only affects scaffolding/symmetry.
1623
+ */
1624
+ function getPublicEnvPrefix(framework) {
1625
+ switch (framework) {
1626
+ case "vite":
1627
+ case "tanstack-start": return "VITE_";
1628
+ case "expo": return "EXPO_PUBLIC_";
1629
+ case "remix": return "";
1630
+ case "nextjs": return "NEXT_PUBLIC_";
1631
+ default: return "NEXT_PUBLIC_";
1632
+ }
1633
+ }
1634
+ /**
1635
+ * Strip a known public prefix from a var name.
1636
+ * Returns the un-prefixed name, or `null` if no prefix matched.
1637
+ */
1638
+ function stripPublicPrefix(name) {
1639
+ for (const prefix of PUBLIC_ENV_PREFIXES) if (prefix && name.startsWith(prefix)) return name.slice(prefix.length);
1640
+ return null;
1641
+ }
1642
+ //#endregion
1643
+ //#region src/workspace/index.ts
1644
+ /**
1645
+ * Validate that all dependencies reference existing apps.
1646
+ * Returns the config if valid, throws otherwise.
1647
+ */
1648
+ function validateDependencies(apps) {
1649
+ const appNames = new Set(Object.keys(apps));
1650
+ for (const [appName, app] of Object.entries(apps)) for (const dep of app.dependencies ?? []) {
1651
+ if (!appNames.has(dep)) throw new Error(`Invalid dependency: App "${appName}" depends on "${dep}" which does not exist. Valid apps are: ${[...appNames].join(", ")}`);
1652
+ if (dep === appName) throw new Error(`Invalid dependency: App "${appName}" cannot depend on itself.`);
1653
+ }
1654
+ }
1655
+ /**
1656
+ * Define workspace configuration with full TypeScript support and type inference.
1657
+ *
1658
+ * Uses `const` type parameter to infer literal app names, providing:
1659
+ * - Autocomplete for app names in dependencies
1660
+ * - Type errors for invalid dependency references
1661
+ * - Full type inference for the returned config
1662
+ *
1663
+ * @example
1664
+ * ```ts
1665
+ * // gkm.config.ts
1666
+ * import { defineWorkspace } from '@geekmidas/cli';
1667
+ *
1668
+ * export default defineWorkspace({
1669
+ * name: 'my-saas',
1670
+ * apps: {
1671
+ * api: {
1672
+ * type: 'backend',
1673
+ * path: 'apps/api',
1674
+ * port: 3000,
1675
+ * routes: './src/endpoints/**\/*.ts',
1676
+ * envParser: './src/config/env',
1677
+ * logger: './src/logger',
1678
+ * },
1679
+ * web: {
1680
+ * type: 'web',
1681
+ * framework: 'nextjs',
1682
+ * path: 'apps/web',
1683
+ * port: 3001,
1684
+ * dependencies: ['api'], // <- autocomplete shows 'api' | 'web'
1685
+ * },
1686
+ * },
1687
+ * });
1688
+ *
1689
+ * // config.apps.api <- full type inference
1690
+ * // config.apps.foo <- TypeScript error
1691
+ * ```
1692
+ */
1693
+ function defineWorkspace(config) {
1694
+ assertNoMovedDeployKeys(config.deploy);
1695
+ assertKnownSecretsStore(config.secrets?.store);
1696
+ if (config.apps) validateDependencies(config.apps);
1697
+ const result = safeValidateWorkspaceConfig(config);
1698
+ if (!result.success && result.error) throw new Error(formatValidationErrors(result.error));
1699
+ return config;
1700
+ }
1701
+ /**
1702
+ * Get the package name from package.json in the given directory.
1703
+ */
1704
+ function getPackageName(cwd) {
1705
+ try {
1706
+ return __require(`${cwd}/package.json`).name?.replace(/^@[^/]+\//, "");
1707
+ } catch {
1708
+ return;
1709
+ }
1710
+ }
1711
+ /**
1712
+ * Normalize a workspace configuration with resolved defaults.
1713
+ */
1714
+ function normalizeWorkspace(config, cwd) {
1715
+ const name = config.name ?? getPackageName(cwd) ?? basename(cwd);
1716
+ const defaultTarget = config.deploy?.default ?? "dokploy";
1717
+ const normalizedApps = {};
1718
+ for (const [appName, app] of Object.entries(config.apps ?? {})) normalizedApps[appName] = normalizeAppConfig(app, defaultTarget);
1719
+ return {
1720
+ name,
1721
+ root: cwd,
1722
+ ...config.constructs ? { constructs: config.constructs } : {},
1723
+ apps: normalizedApps,
1724
+ ...config.domains ? { domains: config.domains } : {},
1725
+ ...config.dns ? { dns: config.dns } : {},
1726
+ deploy: config.deploy ?? { default: "dokploy" },
1727
+ shared: config.shared ?? { packages: ["packages/*"] },
1728
+ stages: validateStages(config.stages),
1729
+ secrets: config.secrets ?? {},
1730
+ state: config.state,
1731
+ test: config.test ?? {},
1732
+ ...config.dev ? { dev: config.dev } : {}
1733
+ };
1734
+ }
1735
+ /**
1736
+ * Normalize an app configuration with resolved defaults.
1737
+ * @param app - App configuration
1738
+ * @param defaultTarget - Default deploy target from workspace config
1739
+ */
1740
+ function normalizeAppConfig(app, defaultTarget) {
1741
+ return {
1742
+ ...app,
1743
+ type: app.type ?? "backend",
1744
+ port: app.port,
1745
+ path: app.path,
1746
+ dependencies: app.dependencies ?? [],
1747
+ resolvedDeployTarget: app.deploy ?? defaultTarget
1748
+ };
1749
+ }
1750
+ /**
1751
+ * Wrap a single-app GkmConfig as a workspace.
1752
+ * This allows existing single-app configs to work seamlessly.
1753
+ */
1754
+ function wrapSingleAppAsWorkspace(config, cwd) {
1755
+ return {
1756
+ name: config.name ?? getPackageName(cwd) ?? basename(cwd),
1757
+ root: cwd,
1758
+ apps: { api: {
1759
+ type: "backend",
1760
+ path: ".",
1761
+ port: 3e3,
1762
+ dependencies: [],
1763
+ resolvedDeployTarget: config.deploy?.default ?? "dokploy",
1764
+ constructs: config.constructs,
1765
+ hooks: config.hooks,
1766
+ telescope: config.telescope,
1767
+ openapi: config.openapi,
1768
+ runtime: config.runtime,
1769
+ env: config.env
1770
+ } },
1771
+ ...config.domains ? { domains: config.domains } : {},
1772
+ ...config.dns ? { dns: config.dns } : {},
1773
+ deploy: {
1774
+ default: "dokploy",
1775
+ ...config.deploy
1776
+ },
1777
+ shared: { packages: [] },
1778
+ stages: validateStages(config.stages),
1779
+ secrets: config.secrets ?? {},
1780
+ test: config.test ?? {},
1781
+ ...config.dev ? { dev: config.dev } : {}
1782
+ };
1783
+ }
1784
+ /**
1785
+ * Process a loaded configuration (either single-app or workspace).
1786
+ * Returns a normalized workspace in both cases.
1787
+ */
1788
+ /**
1789
+ * `deploy.dokploy.registry`, which became `deploy.registry`: every target
1790
+ * pushes and pulls through the one registry, so it is not Dokploy's to hold.
1791
+ *
1792
+ * Refused by name rather than dropped: the schema strips keys it does not
1793
+ * know, and a registry silently gone would deploy images under no registry.
1794
+ */
1795
+ var DokployRegistryMoved = class extends Error {
1796
+ registry;
1797
+ constructor(registry) {
1798
+ super(`deploy.dokploy.registry is now deploy.registry, read by every deploy target. In gkm.config.ts, move it up one level: deploy: { registry: ${JSON.stringify(registry)}, dokploy: { … } }.`);
1799
+ this.registry = registry;
1800
+ this.name = "DokployRegistryMoved";
1801
+ }
1802
+ };
1803
+ /**
1804
+ * `deploy.domains`, which became `domains` at the root of the config: a stage's
1805
+ * domain is a fact about the product every target and every command reads,
1806
+ * not a deploy setting.
1807
+ */
1808
+ var DomainsMoved = class extends Error {
1809
+ domains;
1810
+ constructor(domains) {
1811
+ super(`deploy.domains is now domains, at the root of gkm.config.ts. Move it out of deploy: defineWorkspace({ …, domains: ${JSON.stringify(domains)}, deploy: { … } }).`);
1812
+ this.domains = domains;
1813
+ this.name = "DomainsMoved";
1814
+ }
1815
+ };
1816
+ /**
1817
+ * `deploy.dns`, which became `dns` at the root of the config, keyed by root
1818
+ * domain.
1819
+ */
1820
+ var DnsMoved = class extends Error {
1821
+ dns;
1822
+ constructor(dns) {
1823
+ const legacy = dns && typeof dns === "object" && "domain" in dns && "provider" in dns;
1824
+ const { domain, ...rest } = legacy ? dns : {};
1825
+ super(`deploy.dns is now dns, at the root of gkm.config.ts, keyed by root domain. Move it out of deploy: defineWorkspace({ …, dns: ${JSON.stringify(legacy ? { [String(domain)]: rest } : dns)}, deploy: { … } }).`);
1826
+ this.dns = dns;
1827
+ this.name = "DnsMoved";
1828
+ }
1829
+ };
1830
+ /** Refuse a deploy key that has moved, naming where it lives now. */
1831
+ function assertNoMovedDeployKeys(deploy) {
1832
+ const dokploy = deploy?.dokploy;
1833
+ if (dokploy && typeof dokploy === "object" && "registry" in dokploy) throw new DokployRegistryMoved(dokploy.registry);
1834
+ if (deploy && typeof deploy === "object") {
1835
+ if ("domains" in deploy) throw new DomainsMoved(deploy.domains);
1836
+ if ("dns" in deploy) throw new DnsMoved(deploy.dns);
1837
+ }
1838
+ }
1839
+ function processConfig(config, cwd) {
1840
+ assertNoMovedDeployKeys(config.deploy);
1841
+ if (isWorkspaceConfig(config)) {
1842
+ assertKnownSecretsStore(config.secrets?.store);
1843
+ if (config.stages === void 0) throw new InvalidStages(stageProblems(void 0));
1844
+ const result = safeValidateWorkspaceConfig(config);
1845
+ if (!result.success && result.error) throw new InvalidWorkspaceConfig(formatValidationErrors(result.error));
1846
+ return {
1847
+ type: "workspace",
1848
+ raw: config,
1849
+ workspace: normalizeWorkspace(config, cwd)
1850
+ };
1851
+ }
1852
+ return {
1853
+ type: "single",
1854
+ raw: config,
1855
+ workspace: wrapSingleAppAsWorkspace(config, cwd)
1856
+ };
1857
+ }
1858
+ /** A workspace config the schema refuses; the message lists every issue. */
1859
+ var InvalidWorkspaceConfig = class extends Error {
1860
+ constructor(message) {
1861
+ super(message);
1862
+ this.name = "InvalidWorkspaceConfig";
1863
+ }
1864
+ };
1865
+ /**
1866
+ * The workspace's own constructs globs, absolute.
1867
+ *
1868
+ * Infrastructure two apps share is a fact about the product, and declaring it
1869
+ * inside one of them makes moving that app a change to the other's database.
1870
+ */
1871
+ function workspaceConstructGlobs(workspace) {
1872
+ return constructPatterns(workspace.constructs).map((pattern) => isAbsolute(pattern) ? pattern : join(workspace.root, pattern));
1873
+ }
1874
+ /**
1875
+ * Every constructs glob an app can see, absolute.
1876
+ *
1877
+ * The workspace's own first, then the app's. Absolute because the app builds
1878
+ * from its own directory while the workspace's constructs live above it —
1879
+ * a relative glob resolved from the app would look for the product's
1880
+ * infrastructure inside one of its consumers and find nothing.
1881
+ *
1882
+ * Additive, not overriding: an app that declares its own constructs still sees
1883
+ * the ones the workspace declared for everybody.
1884
+ */
1885
+ function appConstructGlobs(workspace, appName) {
1886
+ const globs = workspaceConstructGlobs(workspace);
1887
+ const app = workspace.apps[appName];
1888
+ if (app) {
1889
+ const root = isAbsolute(app.path) ? app.path : join(workspace.root, app.path);
1890
+ for (const pattern of constructPatterns(app.constructs)) globs.push(isAbsolute(pattern) ? pattern : join(root, pattern));
1891
+ }
1892
+ return globs;
1893
+ }
1894
+ /**
1895
+ * Every constructs glob in the workspace: its own, plus each app's.
1896
+ *
1897
+ * One list, so what a deploy provisions and what an app's entry point
1898
+ * registers drivers for are read off the same globs.
1899
+ */
1900
+ function allConstructGlobs(workspace) {
1901
+ const globs = [...workspaceConstructGlobs(workspace), ...Object.keys(workspace.apps).flatMap((appName) => appConstructGlobs(workspace, appName))];
1902
+ return [...new Set(globs)];
1903
+ }
1904
+ /** A `Routes` in any of its accepted shapes, as a flat list of patterns. */
1905
+ function constructPatterns(routes) {
1906
+ if (!routes) return [];
1907
+ return typeof routes === "string" ? [routes] : routes;
1908
+ }
1909
+ /**
1910
+ * Get the GkmConfig for a specific app in a workspace.
1911
+ * Useful for running existing single-app commands on a specific app.
1912
+ */
1913
+ function getAppGkmConfig(workspace, appName) {
1914
+ const app = workspace.apps[appName];
1915
+ if (!app || app.type !== "backend") return;
1916
+ return {
1917
+ ...workspace.deploy ? { deploy: workspace.deploy } : {},
1918
+ stages: workspace.stages,
1919
+ constructs: appConstructGlobs(workspace, appName),
1920
+ hooks: app.hooks,
1921
+ telescope: app.telescope,
1922
+ openapi: app.openapi,
1923
+ runtime: app.runtime,
1924
+ env: app.env
1925
+ };
1926
+ }
1927
+ /**
1928
+ * Get topologically sorted app names based on dependencies.
1929
+ * Apps with no dependencies come first, then apps that depend on them.
1930
+ */
1931
+ function getAppBuildOrder(workspace) {
1932
+ const appNames = Object.keys(workspace.apps);
1933
+ const visited = /* @__PURE__ */ new Set();
1934
+ const result = [];
1935
+ function visit(name) {
1936
+ if (visited.has(name)) return;
1937
+ visited.add(name);
1938
+ const app = workspace.apps[name];
1939
+ if (app) for (const dep of app.dependencies) visit(dep);
1940
+ result.push(name);
1941
+ }
1942
+ for (const name of appNames) visit(name);
1943
+ return result;
1944
+ }
1945
+ /**
1946
+ * Resolve the Dokploy endpoint for a specific stage.
1947
+ *
1948
+ * Uses per-stage endpoint from `endpoints` if available,
1949
+ * otherwise falls back to the global `endpoint`.
1950
+ *
1951
+ * @param dokployConfig - Dokploy workspace configuration
1952
+ * @param stage - Deployment stage (e.g., 'development', 'production')
1953
+ * @returns The endpoint URL for the stage, or undefined if not configured
1954
+ *
1955
+ * @example
1956
+ * ```ts
1957
+ * // With per-stage endpoints
1958
+ * const config = {
1959
+ * endpoints: {
1960
+ * development: 'https://dev.dokploy.example.com:3000',
1961
+ * production: 'https://prod.dokploy.example.com:3000',
1962
+ * },
1963
+ * };
1964
+ * getEndpointForStage(config, 'production'); // => 'https://prod.dokploy.example.com:3000'
1965
+ *
1966
+ * // With single endpoint
1967
+ * const config = { endpoint: 'https://dokploy.example.com:3000' };
1968
+ * getEndpointForStage(config, 'production'); // => 'https://dokploy.example.com:3000'
1969
+ * ```
1970
+ */
1971
+ function getEndpointForStage(dokployConfig, stage) {
1972
+ if (!dokployConfig) return void 0;
1973
+ if (dokployConfig.endpoints?.[stage]) return dokployConfig.endpoints[stage];
1974
+ return dokployConfig.endpoint;
1975
+ }
1976
+ //#endregion
1977
+ export { RotationInProgress as $, InvalidStages as A, LOGS_PORT as B, WorkspaceConfigSchema as C, isPhase2DeployTarget as D, isDeployTargetSupported as E, stageProblems as F, checkS3Config as G, provisioningOf as H, otlpTelemetryEnv as I, BucketNameUnavailable as J, AccessKeyLimit as K, resolveStageTelemetry as L, UndeclaredStage as M, assertDeployedStage as N, safeValidateWorkspaceConfig as O, deployedProblems as P, RecordedBucketUnreachable as Q, stageSampleRate as R, SUPPORTED_DEPLOY_TARGETS as S, getDeployTargetError as T, stageProvider as U, UnknownStageProvider as V, S3_PROVISIONING as W, IamUserNotOwned as X, BucketOwnedByAnotherProject as Y, ProvisionedBucketUnreachable as Z, PUBLIC_ENV_PREFIXES as _, allConstructGlobs as a, SERVER_IPV6_KEY as at, isWorkspaceConfig as b, constructPatterns as c, SECRETS_STORE_PROVIDERS as ct, getAppGkmConfig as d, S3RegionRequired as et, getEndpointForStage as f, wrapSingleAppAsWorkspace as g, workspaceConstructGlobs as h, InvalidWorkspaceConfig as i, SERVER_IPV4_KEY as it, TEST_STAGE as j, validateWorkspaceConfig as k, defineWorkspace as l, UnknownSecretsStoreProvider as lt, processConfig as m, DokployRegistryMoved as n, certificateFor as nt, appConstructGlobs as o, cnameTarget as ot, normalizeWorkspace as p, BucketKeySetElsewhere as q, DomainsMoved as r, proxyFor as rt, assertNoMovedDeployKeys as s, isReservedStageKey as st, DnsMoved as t, ComposeTlsFileMissing as tt, getAppBuildOrder as u, getPublicEnvPrefix as v, formatValidationErrors as w, PHASE_2_DEPLOY_TARGETS as x, stripPublicPrefix as y, telemetryEnv as z };
1978
+
1979
+ //# sourceMappingURL=workspace-CJ0lKFq-.mjs.map