@geekmidas/cli 10.0.0-alpha.99 → 10.0.0

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