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