@geekmidas/cli 9.0.2 → 10.0.0-alpha.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 (390) hide show
  1. package/README.md +71 -120
  2. package/dist/{CachedStateProvider-BdX7klRc.cjs → CachedStateProvider-BLo7zv7S.cjs} +1 -1
  3. package/dist/CachedStateProvider-BxoAm-B2.mjs +3 -0
  4. package/dist/{CachedStateProvider-klLWZXWF.cjs → CachedStateProvider-CqPdW7CB.cjs} +1 -1
  5. package/dist/{CachedStateProvider-klLWZXWF.cjs.map → CachedStateProvider-CqPdW7CB.cjs.map} +1 -1
  6. package/dist/{CachedStateProvider-CzyFct42.mjs → CachedStateProvider-DTniehMP.mjs} +1 -1
  7. package/dist/{CachedStateProvider-CzyFct42.mjs.map → CachedStateProvider-DTniehMP.mjs.map} +1 -1
  8. package/dist/{HostingerProvider-B2ZYz7Yc.mjs → HostingerProvider-Cft7lEYr.mjs} +4 -3
  9. package/dist/HostingerProvider-Cft7lEYr.mjs.map +1 -0
  10. package/dist/{HostingerProvider-CrHfsgz9.cjs → HostingerProvider-h3EbEp-Z.cjs} +4 -3
  11. package/dist/HostingerProvider-h3EbEp-Z.cjs.map +1 -0
  12. package/dist/{LocalStateProvider-CP49rjzt.mjs → LocalStateProvider-Bn6tS-oL.mjs} +1 -1
  13. package/dist/{LocalStateProvider-CP49rjzt.mjs.map → LocalStateProvider-Bn6tS-oL.mjs.map} +1 -1
  14. package/dist/{LocalStateProvider-CalzNfNA.cjs → LocalStateProvider-Db9SEjyH.cjs} +1 -1
  15. package/dist/{LocalStateProvider-CalzNfNA.cjs.map → LocalStateProvider-Db9SEjyH.cjs.map} +1 -1
  16. package/dist/{Route53Provider-tlgBzrRQ.mjs → Route53Provider-RdpUDJQk.mjs} +1 -1
  17. package/dist/{Route53Provider-tlgBzrRQ.mjs.map → Route53Provider-RdpUDJQk.mjs.map} +1 -1
  18. package/dist/{Route53Provider-DwgXiLxt.cjs → Route53Provider-di2fMM5N.cjs} +1 -1
  19. package/dist/{Route53Provider-DwgXiLxt.cjs.map → Route53Provider-di2fMM5N.cjs.map} +1 -1
  20. package/dist/{SSMStateProvider-BlrTiV5m.mjs → SSMStateProvider-BRt2py-A.mjs} +1 -1
  21. package/dist/{SSMStateProvider-BlrTiV5m.mjs.map → SSMStateProvider-BRt2py-A.mjs.map} +1 -1
  22. package/dist/{SSMStateProvider-Bt6r8CTL.cjs → SSMStateProvider-DyX8s9HI.cjs} +1 -1
  23. package/dist/{SSMStateProvider-Bt6r8CTL.cjs.map → SSMStateProvider-DyX8s9HI.cjs.map} +1 -1
  24. package/dist/{backup-provisioner-Xunq-p_8.mjs → backup-provisioner-Bgj5Vi_L.mjs} +2 -2
  25. package/dist/{backup-provisioner-Xunq-p_8.mjs.map → backup-provisioner-Bgj5Vi_L.mjs.map} +1 -1
  26. package/dist/{backup-provisioner-B3HBN-2k.cjs → backup-provisioner-BrsHwYG0.cjs} +2 -2
  27. package/dist/{backup-provisioner-B3HBN-2k.cjs.map → backup-provisioner-BrsHwYG0.cjs.map} +1 -1
  28. package/dist/{bundler-Dufq3uvI.cjs → bundler-BY1OmV1e.cjs} +44 -14
  29. package/dist/bundler-BY1OmV1e.cjs.map +1 -0
  30. package/dist/{bundler-DkA4qzUD.mjs → bundler-Be8Zg4Wd.mjs} +45 -15
  31. package/dist/bundler-Be8Zg4Wd.mjs.map +1 -0
  32. package/dist/config-D8o6I_7Z.mjs +469 -0
  33. package/dist/config-D8o6I_7Z.mjs.map +1 -0
  34. package/dist/config-DbPE1KXF.cjs +535 -0
  35. package/dist/config-DbPE1KXF.cjs.map +1 -0
  36. package/dist/config.cjs +3 -2
  37. package/dist/config.d.cts +2 -2
  38. package/dist/config.d.cts.map +1 -1
  39. package/dist/config.d.mts +2 -2
  40. package/dist/config.d.mts.map +1 -1
  41. package/dist/config.mjs +3 -2
  42. package/dist/{credentials-s1kLcIzK.mjs → credentials-B5zRHdAl.mjs} +21 -6
  43. package/dist/credentials-B5zRHdAl.mjs.map +1 -0
  44. package/dist/{credentials-C8DWtnMY.cjs → credentials-BapzjyV5.cjs} +26 -5
  45. package/dist/credentials-BapzjyV5.cjs.map +1 -0
  46. package/dist/credentials-Dh0Q6HzY.mjs +2548 -0
  47. package/dist/credentials-Dh0Q6HzY.mjs.map +1 -0
  48. package/dist/credentials-K961ThG3.cjs +2680 -0
  49. package/dist/credentials-K961ThG3.cjs.map +1 -0
  50. package/dist/deploy/sniffer-routes-worker.cjs +6 -2
  51. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  52. package/dist/deploy/sniffer-routes-worker.mjs +6 -2
  53. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  54. package/dist/discover-CAlFgYec.mjs +229 -0
  55. package/dist/discover-CAlFgYec.mjs.map +1 -0
  56. package/dist/discover-DTmFeloL.cjs +271 -0
  57. package/dist/discover-DTmFeloL.cjs.map +1 -0
  58. package/dist/dokploy-api-BS2xnJLZ.mjs +3 -0
  59. package/dist/{dokploy-api-CqOIKHme.cjs → dokploy-api-BsVH0y_s.cjs} +141 -32
  60. package/dist/dokploy-api-BsVH0y_s.cjs.map +1 -0
  61. package/dist/dokploy-api-BuxDRo3l.cjs +3 -0
  62. package/dist/{dokploy-api-sfZFlWuE.mjs → dokploy-api-aTFPz7_4.mjs} +141 -32
  63. package/dist/dokploy-api-aTFPz7_4.mjs.map +1 -0
  64. package/dist/emit-CbcRolsa.cjs +236 -0
  65. package/dist/emit-CbcRolsa.cjs.map +1 -0
  66. package/dist/emit-CiZS_5Ub.mjs +206 -0
  67. package/dist/emit-CiZS_5Ub.mjs.map +1 -0
  68. package/dist/{encryption-MfXAiFTm.cjs → encryption-C6jaU0hE.cjs} +1 -1
  69. package/dist/{encryption-MfXAiFTm.cjs.map → encryption-C6jaU0hE.cjs.map} +1 -1
  70. package/dist/{encryption-BVS7Vmzs.cjs → encryption-CHzzeR8a.cjs} +1 -1
  71. package/dist/encryption-CQUncu7v.mjs +3 -0
  72. package/dist/{encryption-CO5Q4Bhf.mjs → encryption-D-abyhZx.mjs} +1 -1
  73. package/dist/{encryption-CO5Q4Bhf.mjs.map → encryption-D-abyhZx.mjs.map} +1 -1
  74. package/dist/fullstack-secrets-C-GGohke.cjs +111 -0
  75. package/dist/fullstack-secrets-C-GGohke.cjs.map +1 -0
  76. package/dist/fullstack-secrets-D1o9-G5l.mjs +87 -0
  77. package/dist/fullstack-secrets-D1o9-G5l.mjs.map +1 -0
  78. package/dist/{fullstack-secrets-BYzi6Hwl.cjs → generator-CNzBw7g5.cjs} +1 -114
  79. package/dist/generator-CNzBw7g5.cjs.map +1 -0
  80. package/dist/{fullstack-secrets-l8s3II_H.mjs → generator-VE2JrFlY.mjs} +2 -85
  81. package/dist/generator-VE2JrFlY.mjs.map +1 -0
  82. package/dist/index-BThUzEIp.d.mts +175 -0
  83. package/dist/index-BThUzEIp.d.mts.map +1 -0
  84. package/dist/index-CHB4tSzX.d.cts +175 -0
  85. package/dist/index-CHB4tSzX.d.cts.map +1 -0
  86. package/dist/index.cjs +2329 -1584
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/index.mjs +2306 -1561
  89. package/dist/index.mjs.map +1 -1
  90. package/dist/{openapi-Cfwi0fqF.mjs → openapi-CgpMWMmM.mjs} +174 -95
  91. package/dist/openapi-CgpMWMmM.mjs.map +1 -0
  92. package/dist/{openapi-BzNOC7_i.cjs → openapi-CljONd_M.cjs} +175 -108
  93. package/dist/openapi-CljONd_M.cjs.map +1 -0
  94. package/dist/{openapi-react-query-C4iIvpPf.mjs → openapi-react-query-Byltvm_7.mjs} +2 -2
  95. package/dist/openapi-react-query-Byltvm_7.mjs.map +1 -0
  96. package/dist/{openapi-react-query-CYWik72n.cjs → openapi-react-query-CmJ1xDbn.cjs} +2 -2
  97. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +1 -0
  98. package/dist/openapi-react-query.cjs +1 -1
  99. package/dist/openapi-react-query.mjs +1 -1
  100. package/dist/openapi.cjs +4 -3
  101. package/dist/openapi.d.cts +1 -1
  102. package/dist/openapi.d.mts +1 -1
  103. package/dist/openapi.mjs +4 -3
  104. package/dist/reconcile/public.cjs +9 -0
  105. package/dist/reconcile/public.d.cts +125 -0
  106. package/dist/reconcile/public.d.cts.map +1 -0
  107. package/dist/reconcile/public.d.mts +125 -0
  108. package/dist/reconcile/public.d.mts.map +1 -0
  109. package/dist/reconcile/public.mjs +4 -0
  110. package/dist/{reconcile-B2FoJE0a.mjs → reconcile-CFs8C_1a.mjs} +5 -4
  111. package/dist/reconcile-CFs8C_1a.mjs.map +1 -0
  112. package/dist/{reconcile-BzqKJ2Rt.cjs → reconcile-D0pimNiy.cjs} +5 -4
  113. package/dist/reconcile-D0pimNiy.cjs.map +1 -0
  114. package/dist/setup-CJiQM2pX.cjs +473 -0
  115. package/dist/setup-CJiQM2pX.cjs.map +1 -0
  116. package/dist/setup-DMtU3p41.cjs +11 -0
  117. package/dist/setup-DOsYueeQ.mjs +443 -0
  118. package/dist/setup-DOsYueeQ.mjs.map +1 -0
  119. package/dist/setup-DSutDAlt.mjs +11 -0
  120. package/dist/{storage-B1wvztiJ.cjs → storage-BJmzYxt8.cjs} +1 -1
  121. package/dist/{storage-B1wvztiJ.cjs.map → storage-BJmzYxt8.cjs.map} +1 -1
  122. package/dist/{storage-DOEtT2Hr.cjs → storage-BM9hGpgv.cjs} +1 -1
  123. package/dist/{storage-dbb9RyBl.mjs → storage-Bi24WfoW.mjs} +1 -1
  124. package/dist/{storage-dbb9RyBl.mjs.map → storage-Bi24WfoW.mjs.map} +1 -1
  125. package/dist/{storage-Cs4WBsc4.mjs → storage-CYlGwWTj.mjs} +1 -1
  126. package/dist/{sync-CSooqRQ8.mjs → sync-CmEuNZsB.mjs} +2 -2
  127. package/dist/{sync-CSooqRQ8.mjs.map → sync-CmEuNZsB.mjs.map} +1 -1
  128. package/dist/sync-D306yOWu.cjs +4 -0
  129. package/dist/{sync-o_CtEbvR.cjs → sync-SizaChmC.cjs} +2 -2
  130. package/dist/{sync-o_CtEbvR.cjs.map → sync-SizaChmC.cjs.map} +1 -1
  131. package/dist/{sync-B5UHXwRM.mjs → sync-hOqAWHR6.mjs} +1 -1
  132. package/dist/{index-Bw548Bta.d.mts → types-C-arnQ1r.d.mts} +590 -143
  133. package/dist/types-C-arnQ1r.d.mts.map +1 -0
  134. package/dist/{index-DTpkeFb8.d.cts → types-abJQuk7m.d.cts} +590 -143
  135. package/dist/types-abJQuk7m.d.cts.map +1 -0
  136. package/dist/workspace/index.cjs +5 -1
  137. package/dist/workspace/index.d.cts +3 -3
  138. package/dist/workspace/index.d.mts +3 -3
  139. package/dist/workspace/index.mjs +2 -2
  140. package/dist/{workspace-D-37Ylqo.mjs → workspace-7FqprxuJ.mjs} +117 -30
  141. package/dist/workspace-7FqprxuJ.mjs.map +1 -0
  142. package/dist/workspace-8acupeaI.cjs +9 -0
  143. package/dist/{workspace-CQTT7HJQ.cjs → workspace-XvqO9jIv.cjs} +139 -28
  144. package/dist/workspace-XvqO9jIv.cjs.map +1 -0
  145. package/dist/workspace-yP5AHnrn.mjs +8 -0
  146. package/package.json +26 -9
  147. package/CHANGELOG.md +0 -650
  148. package/FUNCTION_CRON_SUPPORT.md +0 -266
  149. package/dist/CachedStateProvider-GcGziXh1.mjs +0 -3
  150. package/dist/HostingerProvider-B2ZYz7Yc.mjs.map +0 -1
  151. package/dist/HostingerProvider-CrHfsgz9.cjs.map +0 -1
  152. package/dist/bundler-DkA4qzUD.mjs.map +0 -1
  153. package/dist/bundler-Dufq3uvI.cjs.map +0 -1
  154. package/dist/config-Bbu1JKvf.mjs +0 -211
  155. package/dist/config-Bbu1JKvf.mjs.map +0 -1
  156. package/dist/config-DujV8DbR.cjs +0 -253
  157. package/dist/config-DujV8DbR.cjs.map +0 -1
  158. package/dist/credentials-C8DWtnMY.cjs.map +0 -1
  159. package/dist/credentials-s1kLcIzK.mjs.map +0 -1
  160. package/dist/dokploy-api-BPYkG-ZZ.cjs +0 -3
  161. package/dist/dokploy-api-BiSzWM4v.mjs +0 -3
  162. package/dist/dokploy-api-CqOIKHme.cjs.map +0 -1
  163. package/dist/dokploy-api-sfZFlWuE.mjs.map +0 -1
  164. package/dist/encryption-Bd_m4q3g.mjs +0 -3
  165. package/dist/fullstack-secrets-BYzi6Hwl.cjs.map +0 -1
  166. package/dist/fullstack-secrets-l8s3II_H.mjs.map +0 -1
  167. package/dist/index-Bw548Bta.d.mts.map +0 -1
  168. package/dist/index-DTpkeFb8.d.cts.map +0 -1
  169. package/dist/openapi-BzNOC7_i.cjs.map +0 -1
  170. package/dist/openapi-Cfwi0fqF.mjs.map +0 -1
  171. package/dist/openapi-react-query-C4iIvpPf.mjs.map +0 -1
  172. package/dist/openapi-react-query-CYWik72n.cjs.map +0 -1
  173. package/dist/reconcile-B2FoJE0a.mjs.map +0 -1
  174. package/dist/reconcile-BzqKJ2Rt.cjs.map +0 -1
  175. package/dist/setup-DDXUXzzl.mjs +0 -765
  176. package/dist/setup-DDXUXzzl.mjs.map +0 -1
  177. package/dist/setup-DLwhfyt-.cjs +0 -8
  178. package/dist/setup-Dh-B7YTX.mjs +0 -8
  179. package/dist/setup-WZ-xqAQO.cjs +0 -849
  180. package/dist/setup-WZ-xqAQO.cjs.map +0 -1
  181. package/dist/sync-BLA94rgC.cjs +0 -4
  182. package/dist/types-B3GQUg3k.d.mts +0 -280
  183. package/dist/types-B3GQUg3k.d.mts.map +0 -1
  184. package/dist/types-BWQDiooe.d.cts +0 -280
  185. package/dist/types-BWQDiooe.d.cts.map +0 -1
  186. package/dist/workspace-CQTT7HJQ.cjs.map +0 -1
  187. package/dist/workspace-D-37Ylqo.mjs.map +0 -1
  188. package/docs/OPENAPI_TYPESCRIPT_DESIGN.md +0 -408
  189. package/docs/dev-server-resilience-design.md +0 -189
  190. package/docs/manifest-refactor-design.md +0 -287
  191. package/examples/cron-example.ts +0 -45
  192. package/examples/env.ts +0 -33
  193. package/examples/function-example.ts +0 -40
  194. package/examples/gkm.config.json +0 -22
  195. package/examples/gkm.config.ts +0 -14
  196. package/examples/gkm.minimal.config.json +0 -7
  197. package/examples/gkm.production.config.json +0 -27
  198. package/examples/logger.ts +0 -10
  199. package/scripts/sync-versions.ts +0 -108
  200. package/src/__tests__/EndpointGenerator.hooks.spec.ts +0 -204
  201. package/src/__tests__/config.spec.ts +0 -422
  202. package/src/__tests__/loadEnvFiles.spec.ts +0 -131
  203. package/src/__tests__/normalizeHooksConfig.spec.ts +0 -63
  204. package/src/__tests__/openapi-react-query.spec.ts +0 -506
  205. package/src/__tests__/openapi.spec.ts +0 -625
  206. package/src/__tests__/test-helpers.ts +0 -181
  207. package/src/auth/__tests__/credentials.spec.ts +0 -331
  208. package/src/auth/__tests__/index.spec.ts +0 -237
  209. package/src/auth/credentials.ts +0 -286
  210. package/src/auth/index.ts +0 -233
  211. package/src/build/__tests__/bundler.spec.ts +0 -446
  212. package/src/build/__tests__/endpoint-analyzer.spec.ts +0 -623
  213. package/src/build/__tests__/handler-templates.spec.ts +0 -1287
  214. package/src/build/__tests__/index-new.spec.ts +0 -550
  215. package/src/build/__tests__/manifests.spec.ts +0 -583
  216. package/src/build/__tests__/partitions.spec.ts +0 -110
  217. package/src/build/__tests__/workspace-build.spec.ts +0 -215
  218. package/src/build/bundler.ts +0 -256
  219. package/src/build/endpoint-analyzer.ts +0 -236
  220. package/src/build/handler-templates.ts +0 -1253
  221. package/src/build/index.ts +0 -616
  222. package/src/build/manifests.ts +0 -285
  223. package/src/build/partitions.ts +0 -58
  224. package/src/build/providerResolver.ts +0 -184
  225. package/src/build/types.ts +0 -104
  226. package/src/config.ts +0 -330
  227. package/src/credentials/__tests__/fullDockerPorts.spec.ts +0 -144
  228. package/src/credentials/__tests__/helpers.ts +0 -112
  229. package/src/credentials/__tests__/prepareEntryCredentials.spec.ts +0 -125
  230. package/src/credentials/__tests__/readonlyDockerPorts.spec.ts +0 -190
  231. package/src/credentials/__tests__/workspaceCredentials.spec.ts +0 -209
  232. package/src/credentials/index.ts +0 -843
  233. package/src/debug.ts +0 -68
  234. package/src/deploy/CachedStateProvider.ts +0 -86
  235. package/src/deploy/LocalStateProvider.ts +0 -57
  236. package/src/deploy/SSMStateProvider.ts +0 -117
  237. package/src/deploy/StateProvider.ts +0 -175
  238. package/src/deploy/__tests__/CachedStateProvider.spec.ts +0 -235
  239. package/src/deploy/__tests__/HostingerProvider.spec.ts +0 -347
  240. package/src/deploy/__tests__/LocalStateProvider.spec.ts +0 -130
  241. package/src/deploy/__tests__/Route53Provider.spec.ts +0 -425
  242. package/src/deploy/__tests__/SSMStateProvider.spec.ts +0 -201
  243. package/src/deploy/__tests__/__fixtures__/entry-apps/async-entry.ts +0 -24
  244. package/src/deploy/__tests__/__fixtures__/entry-apps/nested-config-entry.ts +0 -24
  245. package/src/deploy/__tests__/__fixtures__/entry-apps/no-env-entry.ts +0 -12
  246. package/src/deploy/__tests__/__fixtures__/entry-apps/simple-entry.ts +0 -14
  247. package/src/deploy/__tests__/__fixtures__/entry-apps/throwing-entry.ts +0 -16
  248. package/src/deploy/__tests__/__fixtures__/env-parsers/non-function-export.ts +0 -10
  249. package/src/deploy/__tests__/__fixtures__/env-parsers/optional-env-parser.ts +0 -21
  250. package/src/deploy/__tests__/__fixtures__/env-parsers/parseable-env-parser.ts +0 -18
  251. package/src/deploy/__tests__/__fixtures__/env-parsers/throwing-env-parser.ts +0 -16
  252. package/src/deploy/__tests__/__fixtures__/env-parsers/valid-env-parser.ts +0 -16
  253. package/src/deploy/__tests__/__fixtures__/route-apps/endpoints/auth.ts +0 -16
  254. package/src/deploy/__tests__/__fixtures__/route-apps/endpoints/health.ts +0 -13
  255. package/src/deploy/__tests__/__fixtures__/route-apps/endpoints/users.ts +0 -15
  256. package/src/deploy/__tests__/__fixtures__/route-apps/services.ts +0 -55
  257. package/src/deploy/__tests__/backup-provisioner.spec.ts +0 -428
  258. package/src/deploy/__tests__/createDnsProvider.spec.ts +0 -195
  259. package/src/deploy/__tests__/createStateProvider.spec.ts +0 -126
  260. package/src/deploy/__tests__/dns-orchestration.spec.ts +0 -192
  261. package/src/deploy/__tests__/dns-verification.spec.ts +0 -229
  262. package/src/deploy/__tests__/docker.spec.ts +0 -149
  263. package/src/deploy/__tests__/dokploy-api.spec.ts +0 -697
  264. package/src/deploy/__tests__/dokploy.spec.ts +0 -435
  265. package/src/deploy/__tests__/domain.spec.ts +0 -235
  266. package/src/deploy/__tests__/env-resolver.spec.ts +0 -903
  267. package/src/deploy/__tests__/index.spec.ts +0 -1091
  268. package/src/deploy/__tests__/init.spec.ts +0 -793
  269. package/src/deploy/__tests__/secrets.spec.ts +0 -303
  270. package/src/deploy/__tests__/sniffer.spec.ts +0 -838
  271. package/src/deploy/__tests__/state-e2e.spec.ts +0 -387
  272. package/src/deploy/__tests__/state.spec.ts +0 -876
  273. package/src/deploy/__tests__/undeploy.spec.ts +0 -758
  274. package/src/deploy/backup-provisioner.ts +0 -316
  275. package/src/deploy/dns/DnsProvider.ts +0 -201
  276. package/src/deploy/dns/HostingerProvider.ts +0 -174
  277. package/src/deploy/dns/Route53Provider.ts +0 -340
  278. package/src/deploy/dns/hostinger-api.ts +0 -261
  279. package/src/deploy/dns/index.ts +0 -627
  280. package/src/deploy/docker.ts +0 -260
  281. package/src/deploy/dokploy-api.ts +0 -1101
  282. package/src/deploy/dokploy.ts +0 -177
  283. package/src/deploy/domain.ts +0 -134
  284. package/src/deploy/env-resolver.ts +0 -305
  285. package/src/deploy/index.ts +0 -2094
  286. package/src/deploy/init.ts +0 -427
  287. package/src/deploy/secrets.ts +0 -187
  288. package/src/deploy/sniffer-envkit-patch.ts +0 -61
  289. package/src/deploy/sniffer-hooks.ts +0 -57
  290. package/src/deploy/sniffer-loader.ts +0 -28
  291. package/src/deploy/sniffer-routes-worker.ts +0 -104
  292. package/src/deploy/sniffer-worker.ts +0 -75
  293. package/src/deploy/sniffer.ts +0 -578
  294. package/src/deploy/state-commands.ts +0 -274
  295. package/src/deploy/state.ts +0 -482
  296. package/src/deploy/types.ts +0 -102
  297. package/src/deploy/undeploy.ts +0 -407
  298. package/src/dev/__tests__/entry-integration.spec.ts +0 -347
  299. package/src/dev/__tests__/entry.spec.ts +0 -144
  300. package/src/dev/__tests__/index.spec.ts +0 -2084
  301. package/src/dev/index.ts +0 -1649
  302. package/src/docker/__tests__/compose.spec.ts +0 -1142
  303. package/src/docker/__tests__/templates.spec.ts +0 -694
  304. package/src/docker/compose.ts +0 -808
  305. package/src/docker/index.ts +0 -523
  306. package/src/docker/templates.ts +0 -1067
  307. package/src/exec/index.ts +0 -118
  308. package/src/generators/CronGenerator.ts +0 -105
  309. package/src/generators/EndpointGenerator.ts +0 -954
  310. package/src/generators/FunctionGenerator.ts +0 -117
  311. package/src/generators/Generator.ts +0 -147
  312. package/src/generators/OpenApiTsGenerator.ts +0 -821
  313. package/src/generators/QueueGenerator.ts +0 -245
  314. package/src/generators/SubscriberGenerator.ts +0 -282
  315. package/src/generators/TopicGenerator.ts +0 -45
  316. package/src/generators/__tests__/CronGenerator.spec.ts +0 -445
  317. package/src/generators/__tests__/EndpointGenerator.spec.ts +0 -544
  318. package/src/generators/__tests__/FunctionGenerator.spec.ts +0 -256
  319. package/src/generators/__tests__/Generator.bustCache.spec.ts +0 -72
  320. package/src/generators/__tests__/OpenApiTsGenerator.registry.spec.ts +0 -98
  321. package/src/generators/__tests__/OpenApiTsGenerator.responseType.spec.ts +0 -56
  322. package/src/generators/__tests__/QueueGenerator.spec.ts +0 -141
  323. package/src/generators/__tests__/SubscriberGenerator.spec.ts +0 -410
  324. package/src/generators/index.ts +0 -11
  325. package/src/index.ts +0 -972
  326. package/src/init/__tests__/generators.spec.ts +0 -1070
  327. package/src/init/__tests__/init.spec.ts +0 -577
  328. package/src/init/__tests__/utils.spec.ts +0 -104
  329. package/src/init/generators/auth.ts +0 -225
  330. package/src/init/generators/config.ts +0 -316
  331. package/src/init/generators/docker.ts +0 -388
  332. package/src/init/generators/env.ts +0 -62
  333. package/src/init/generators/index.ts +0 -6
  334. package/src/init/generators/mobile-expo.ts +0 -576
  335. package/src/init/generators/models.ts +0 -153
  336. package/src/init/generators/monorepo.ts +0 -475
  337. package/src/init/generators/package.ts +0 -95
  338. package/src/init/generators/source.ts +0 -15
  339. package/src/init/generators/test.ts +0 -178
  340. package/src/init/generators/ui.ts +0 -1473
  341. package/src/init/generators/web-tanstack.ts +0 -348
  342. package/src/init/generators/web.ts +0 -363
  343. package/src/init/index.ts +0 -542
  344. package/src/init/templates/api.ts +0 -404
  345. package/src/init/templates/index.ts +0 -342
  346. package/src/init/templates/minimal.ts +0 -207
  347. package/src/init/templates/serverless.ts +0 -148
  348. package/src/init/templates/worker.ts +0 -216
  349. package/src/init/utils.ts +0 -197
  350. package/src/init/versions.ts +0 -52
  351. package/src/openapi-react-query.ts +0 -288
  352. package/src/openapi.ts +0 -259
  353. package/src/secrets/__tests__/encryption.spec.ts +0 -226
  354. package/src/secrets/__tests__/generator.spec.ts +0 -575
  355. package/src/secrets/__tests__/index.spec.ts +0 -91
  356. package/src/secrets/__tests__/reconcile.spec.ts +0 -123
  357. package/src/secrets/__tests__/storage.spec.ts +0 -645
  358. package/src/secrets/encryption.ts +0 -91
  359. package/src/secrets/generator.ts +0 -329
  360. package/src/secrets/index.ts +0 -417
  361. package/src/secrets/keystore.ts +0 -144
  362. package/src/secrets/reconcile.ts +0 -53
  363. package/src/secrets/storage.ts +0 -337
  364. package/src/secrets/sync.ts +0 -136
  365. package/src/secrets/types.ts +0 -70
  366. package/src/setup/__tests__/auto-setup.spec.ts +0 -147
  367. package/src/setup/__tests__/reconcile-secrets.spec.ts +0 -439
  368. package/src/setup/fullstack-secrets.ts +0 -140
  369. package/src/setup/index.ts +0 -411
  370. package/src/test/__tests__/__fixtures__/workspace.ts +0 -104
  371. package/src/test/__tests__/api.spec.ts +0 -199
  372. package/src/test/__tests__/auth.spec.ts +0 -162
  373. package/src/test/__tests__/index.spec.ts +0 -502
  374. package/src/test/__tests__/web.spec.ts +0 -210
  375. package/src/test/index.ts +0 -198
  376. package/src/types.ts +0 -363
  377. package/src/upgrade/__tests__/index.spec.ts +0 -354
  378. package/src/upgrade/index.ts +0 -253
  379. package/src/workspace/__tests__/client-generator.spec.ts +0 -326
  380. package/src/workspace/__tests__/index.spec.ts +0 -766
  381. package/src/workspace/__tests__/publicEnv.spec.ts +0 -64
  382. package/src/workspace/__tests__/schema.spec.ts +0 -737
  383. package/src/workspace/__tests__/type-inference.spec.ts +0 -251
  384. package/src/workspace/client-generator.ts +0 -109
  385. package/src/workspace/index.ts +0 -433
  386. package/src/workspace/publicEnv.ts +0 -57
  387. package/src/workspace/schema.ts +0 -861
  388. package/src/workspace/types.ts +0 -943
  389. package/tsconfig.json +0 -9
  390. package/tsdown.config.ts +0 -22
@@ -27,6 +27,7 @@ function isConstruct(value) {
27
27
  */
28
28
  async function sniff() {
29
29
  const envVars = /* @__PURE__ */ new Set();
30
+ const optionalEnvVars = /* @__PURE__ */ new Set();
30
31
  let error = null;
31
32
  try {
32
33
  const files = await fg(routesPattern, {
@@ -36,8 +37,9 @@ async function sniff() {
36
37
  for (const file of files) try {
37
38
  const module = await import(file);
38
39
  for (const [, exportValue] of Object.entries(module)) if (isConstruct(exportValue)) try {
39
- const constructEnvVars = await exportValue.getEnvironment();
40
- constructEnvVars.forEach((v) => envVars.add(v));
40
+ const constructEnvVars = await exportValue.getEnvironment({ markOptional: true });
41
+ for (const name of constructEnvVars) if (name.endsWith("?")) optionalEnvVars.add(name.slice(0, -1));
42
+ else envVars.add(name);
41
43
  } catch {}
42
44
  } catch (e) {
43
45
  const msg = e instanceof Error ? e.message : String(e);
@@ -46,8 +48,10 @@ async function sniff() {
46
48
  } catch (e) {
47
49
  error = e instanceof Error ? e.message : String(e);
48
50
  }
51
+ for (const name of envVars) optionalEnvVars.delete(name);
49
52
  console.log(JSON.stringify({
50
53
  envVars: Array.from(envVars).sort(),
54
+ optionalEnvVars: Array.from(optionalEnvVars).sort(),
51
55
  error
52
56
  }));
53
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sniffer-routes-worker.mjs","names":["appPath: string","routesPattern: string","value: unknown","error: string | null"],"sources":["../../src/deploy/sniffer-routes-worker.ts"],"sourcesContent":["/**\n * Subprocess worker for route-based app sniffing.\n *\n * This script is executed in a subprocess with tsx loader,\n * which handles TypeScript compilation and path alias resolution.\n *\n * Usage:\n * node --import tsx ./sniffer-routes-worker.ts \"/path/to/app\" \"./src/endpoints/**\\/*.ts\"\n *\n * Output (JSON to stdout):\n * { \"envVars\": [\"PORT\", \"DATABASE_URL\", ...], \"error\": null }\n */\n\nimport type { Construct } from '@geekmidas/constructs';\nimport { Cron } from '@geekmidas/constructs/crons';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { Function as GkmFunction } from '@geekmidas/constructs/functions';\nimport { Subscriber } from '@geekmidas/constructs/subscribers';\nimport fg from 'fast-glob';\n\n// Get args from command line\nconst appPathArg = process.argv[2];\nconst routesPatternArg = process.argv[3];\n\nif (!appPathArg || !routesPatternArg) {\n\tconsole.log(\n\t\tJSON.stringify({\n\t\t\tenvVars: [],\n\t\t\terror: 'App path and routes pattern are required',\n\t\t}),\n\t);\n\tprocess.exit(1);\n}\n\n// After validation, these are guaranteed to be strings\nconst appPath: string = appPathArg;\nconst routesPattern: string = routesPatternArg;\n\n/**\n * Check if a value is a gkm construct.\n */\nfunction isConstruct(value: unknown): value is Construct {\n\treturn (\n\t\tEndpoint.isEndpoint(value) ||\n\t\tGkmFunction.isFunction(value) ||\n\t\tCron.isCron(value) ||\n\t\tSubscriber.isSubscriber(value)\n\t);\n}\n\n/**\n * Main sniffing function\n */\nasync function sniff(): Promise<void> {\n\tconst envVars = new Set<string>();\n\tlet error: string | null = null;\n\n\ttry {\n\t\t// Find all route files matching the pattern\n\t\tconst files = await fg(routesPattern, {\n\t\t\tcwd: appPath,\n\t\t\tabsolute: true,\n\t\t});\n\n\t\t// Import each route file and find constructs\n\t\tfor (const file of files) {\n\t\t\ttry {\n\t\t\t\tconst module = await import(file);\n\n\t\t\t\t// Check all exports for constructs\n\t\t\t\tfor (const [, exportValue] of Object.entries(module)) {\n\t\t\t\t\tif (isConstruct(exportValue)) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst constructEnvVars = await exportValue.getEnvironment();\n\t\t\t\t\t\t\tconstructEnvVars.forEach((v) => envVars.add(v));\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Individual construct may fail, continue with others\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t// Log import errors but continue with other files\n\t\t\t\tconst msg = e instanceof Error ? e.message : String(e);\n\t\t\t\tconsole.error(`[sniffer] Failed to import ${file}: ${msg}`);\n\t\t\t}\n\t\t}\n\t} catch (e) {\n\t\terror = e instanceof Error ? e.message : String(e);\n\t}\n\n\t// Output result as JSON (last line of stdout)\n\tconsole.log(JSON.stringify({ envVars: Array.from(envVars).sort(), error }));\n}\n\n// Handle unhandled rejections\nprocess.on('unhandledRejection', () => {\n\t// Silently ignore - we only care about env var capture\n});\n\n// Run the sniffer\nsniff().catch((e) => {\n\tconsole.log(JSON.stringify({ envVars: [], error: e.message || String(e) }));\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;AAqBA,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAM,mBAAmB,QAAQ,KAAK;AAEtC,KAAK,eAAe,kBAAkB;AACrC,SAAQ,IACP,KAAK,UAAU;EACd,SAAS,CAAE;EACX,OAAO;CACP,EAAC,CACF;AACD,SAAQ,KAAK,EAAE;AACf;AAGD,MAAMA,UAAkB;AACxB,MAAMC,gBAAwB;;;;AAK9B,SAAS,YAAYC,OAAoC;AACxD,QACC,SAAS,WAAW,MAAM,IAC1B,SAAY,WAAW,MAAM,IAC7B,KAAK,OAAO,MAAM,IAClB,WAAW,aAAa,MAAM;AAE/B;;;;AAKD,eAAe,QAAuB;CACrC,MAAM,0BAAU,IAAI;CACpB,IAAIC,QAAuB;AAE3B,KAAI;EAEH,MAAM,QAAQ,MAAM,GAAG,eAAe;GACrC,KAAK;GACL,UAAU;EACV,EAAC;AAGF,OAAK,MAAM,QAAQ,MAClB,KAAI;GACH,MAAM,SAAS,MAAM,OAAO;AAG5B,QAAK,MAAM,GAAG,YAAY,IAAI,OAAO,QAAQ,OAAO,CACnD,KAAI,YAAY,YAAY,CAC3B,KAAI;IACH,MAAM,mBAAmB,MAAM,YAAY,gBAAgB;AAC3D,qBAAiB,QAAQ,CAAC,MAAM,QAAQ,IAAI,EAAE,CAAC;GAC/C,QAAO,CAEP;EAGH,SAAQ,GAAG;GAEX,MAAM,MAAM,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AACtD,WAAQ,OAAO,6BAA6B,KAAK,IAAI,IAAI,EAAE;EAC3D;CAEF,SAAQ,GAAG;AACX,UAAQ,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;CAClD;AAGD,SAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,MAAM,KAAK,QAAQ,CAAC,MAAM;EAAE;CAAO,EAAC,CAAC;AAC3E;AAGD,QAAQ,GAAG,sBAAsB,MAAM,CAEtC,EAAC;AAGF,OAAO,CAAC,MAAM,CAAC,MAAM;AACpB,SAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,CAAE;EAAE,OAAO,EAAE,WAAW,OAAO,EAAE;CAAE,EAAC,CAAC;AAC3E,SAAQ,KAAK,EAAE;AACf,EAAC"}
1
+ {"version":3,"file":"sniffer-routes-worker.mjs","names":["appPath: string","routesPattern: string","value: unknown","error: string | null"],"sources":["../../src/deploy/sniffer-routes-worker.ts"],"sourcesContent":["/**\n * Subprocess worker for route-based app sniffing.\n *\n * This script is executed in a subprocess with tsx loader,\n * which handles TypeScript compilation and path alias resolution.\n *\n * Usage:\n * node --import tsx ./sniffer-routes-worker.ts \"/path/to/app\" \"./src/endpoints/**\\/*.ts\"\n *\n * Output (JSON to stdout):\n * { \"envVars\": [\"PORT\", \"DATABASE_URL\", ...], \"error\": null }\n */\n\nimport type { Construct } from '@geekmidas/constructs';\nimport { Cron } from '@geekmidas/constructs/crons';\nimport { Endpoint } from '@geekmidas/constructs/endpoints';\nimport { Function as GkmFunction } from '@geekmidas/constructs/functions';\nimport { Subscriber } from '@geekmidas/constructs/subscribers';\nimport fg from 'fast-glob';\n\n// Get args from command line\nconst appPathArg = process.argv[2];\nconst routesPatternArg = process.argv[3];\n\nif (!appPathArg || !routesPatternArg) {\n\tconsole.log(\n\t\tJSON.stringify({\n\t\t\tenvVars: [],\n\t\t\terror: 'App path and routes pattern are required',\n\t\t}),\n\t);\n\tprocess.exit(1);\n}\n\n// After validation, these are guaranteed to be strings\nconst appPath: string = appPathArg;\nconst routesPattern: string = routesPatternArg;\n\n/**\n * Check if a value is a gkm construct.\n */\nfunction isConstruct(value: unknown): value is Construct {\n\treturn (\n\t\tEndpoint.isEndpoint(value) ||\n\t\tGkmFunction.isFunction(value) ||\n\t\tCron.isCron(value) ||\n\t\tSubscriber.isSubscriber(value)\n\t);\n}\n\n/**\n * Main sniffing function\n */\nasync function sniff(): Promise<void> {\n\tconst envVars = new Set<string>();\n\tconst optionalEnvVars = new Set<string>();\n\tlet error: string | null = null;\n\n\ttry {\n\t\t// Find all route files matching the pattern\n\t\tconst files = await fg(routesPattern, {\n\t\t\tcwd: appPath,\n\t\t\tabsolute: true,\n\t\t});\n\n\t\t// Import each route file and find constructs\n\t\tfor (const file of files) {\n\t\t\ttry {\n\t\t\t\tconst module = await import(file);\n\n\t\t\t\t// Check all exports for constructs\n\t\t\t\tfor (const [, exportValue] of Object.entries(module)) {\n\t\t\t\t\tif (isConstruct(exportValue)) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// `markOptional`, so a key read through `.optional()` or\n\t\t\t\t\t\t\t// `.default()` comes back suffixed `?` and is reported\n\t\t\t\t\t\t\t// apart from the rest. Without it every sniffed read\n\t\t\t\t\t\t\t// looked required, and a key that is *absent by design*\n\t\t\t\t\t\t\t// — `AUTH_COOKIE_DOMAIN`, published only when a surface\n\t\t\t\t\t\t\t// has a domain to widen a cookie to — failed the deploy\n\t\t\t\t\t\t\t// as though it were a missing secret.\n\t\t\t\t\t\t\tconst constructEnvVars = await exportValue.getEnvironment({\n\t\t\t\t\t\t\t\tmarkOptional: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tfor (const name of constructEnvVars) {\n\t\t\t\t\t\t\t\tif (name.endsWith('?')) optionalEnvVars.add(name.slice(0, -1));\n\t\t\t\t\t\t\t\telse envVars.add(name);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Individual construct may fail, continue with others\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t// Log import errors but continue with other files\n\t\t\t\tconst msg = e instanceof Error ? e.message : String(e);\n\t\t\t\tconsole.error(`[sniffer] Failed to import ${file}: ${msg}`);\n\t\t\t}\n\t\t}\n\t} catch (e) {\n\t\terror = e instanceof Error ? e.message : String(e);\n\t}\n\n\t// Output result as JSON (last line of stdout)\n\t// A key required by one construct and optional in another is required: the\n\t// strictest read is the one that fails at runtime.\n\tfor (const name of envVars) optionalEnvVars.delete(name);\n\n\tconsole.log(\n\t\tJSON.stringify({\n\t\t\tenvVars: Array.from(envVars).sort(),\n\t\t\toptionalEnvVars: Array.from(optionalEnvVars).sort(),\n\t\t\terror,\n\t\t}),\n\t);\n}\n\n// Handle unhandled rejections\nprocess.on('unhandledRejection', () => {\n\t// Silently ignore - we only care about env var capture\n});\n\n// Run the sniffer\nsniff().catch((e) => {\n\tconsole.log(JSON.stringify({ envVars: [], error: e.message || String(e) }));\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;AAqBA,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAM,mBAAmB,QAAQ,KAAK;AAEtC,KAAK,eAAe,kBAAkB;AACrC,SAAQ,IACP,KAAK,UAAU;EACd,SAAS,CAAE;EACX,OAAO;CACP,EAAC,CACF;AACD,SAAQ,KAAK,EAAE;AACf;AAGD,MAAMA,UAAkB;AACxB,MAAMC,gBAAwB;;;;AAK9B,SAAS,YAAYC,OAAoC;AACxD,QACC,SAAS,WAAW,MAAM,IAC1B,SAAY,WAAW,MAAM,IAC7B,KAAK,OAAO,MAAM,IAClB,WAAW,aAAa,MAAM;AAE/B;;;;AAKD,eAAe,QAAuB;CACrC,MAAM,0BAAU,IAAI;CACpB,MAAM,kCAAkB,IAAI;CAC5B,IAAIC,QAAuB;AAE3B,KAAI;EAEH,MAAM,QAAQ,MAAM,GAAG,eAAe;GACrC,KAAK;GACL,UAAU;EACV,EAAC;AAGF,OAAK,MAAM,QAAQ,MAClB,KAAI;GACH,MAAM,SAAS,MAAM,OAAO;AAG5B,QAAK,MAAM,GAAG,YAAY,IAAI,OAAO,QAAQ,OAAO,CACnD,KAAI,YAAY,YAAY,CAC3B,KAAI;IAQH,MAAM,mBAAmB,MAAM,YAAY,eAAe,EACzD,cAAc,KACd,EAAC;AACF,SAAK,MAAM,QAAQ,iBAClB,KAAI,KAAK,SAAS,IAAI,CAAE,iBAAgB,IAAI,KAAK,MAAM,GAAG,GAAG,CAAC;QACzD,SAAQ,IAAI,KAAK;GAEvB,QAAO,CAEP;EAGH,SAAQ,GAAG;GAEX,MAAM,MAAM,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AACtD,WAAQ,OAAO,6BAA6B,KAAK,IAAI,IAAI,EAAE;EAC3D;CAEF,SAAQ,GAAG;AACX,UAAQ,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;CAClD;AAKD,MAAK,MAAM,QAAQ,QAAS,iBAAgB,OAAO,KAAK;AAExD,SAAQ,IACP,KAAK,UAAU;EACd,SAAS,MAAM,KAAK,QAAQ,CAAC,MAAM;EACnC,iBAAiB,MAAM,KAAK,gBAAgB,CAAC,MAAM;EACnD;CACA,EAAC,CACF;AACD;AAGD,QAAQ,GAAG,sBAAsB,MAAM,CAEtC,EAAC;AAGF,OAAO,CAAC,MAAM,CAAC,MAAM;AACpB,SAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,CAAE;EAAE,OAAO,EAAE,WAAW,OAAO,EAAE;CAAE,EAAC,CAAC;AAC3E,SAAQ,KAAK,EAAE;AACf,EAAC"}
@@ -0,0 +1,229 @@
1
+ import { relative } from "node:path";
2
+ import { assertDerivations, canonicalId } from "@geekmidas/manifest";
3
+ import fg from "fast-glob";
4
+ import kebabCase$1 from "lodash.kebabcase";
5
+
6
+ //#region src/types.ts
7
+ function isPartitionedRoutes(routes) {
8
+ return typeof routes === "object" && routes !== null && !Array.isArray(routes) && "paths" in routes;
9
+ }
10
+ /**
11
+ * The backend a project gets when it says nothing, by where it deploys.
12
+ *
13
+ * Flat defaults could not be right for both: `upstash` on a single box means a
14
+ * SaaS round-trip for a cache the database could have held, and `minio` on AWS
15
+ * means running a bucket beside S3. So the default is a function of the target,
16
+ * and an app that says nothing gets the obvious answer in both places — which
17
+ * is the whole of what "zero config" can mean once there is more than one
18
+ * target.
19
+ *
20
+ * `server` covers Dokploy and a bare host alike: the question these answer is
21
+ * whether the app is next to a managed cloud or next to its own containers, and
22
+ * on that question the two are the same.
23
+ *
24
+ * A per-construct, per-stage override is the layer above this — see
25
+ * `constructs-outstanding.md` — so two buckets in one app can differ. This is
26
+ * only what happens when nobody has said anything at all.
27
+ */
28
+ const DEFAULT_CACHE = {
29
+ aws: "upstash",
30
+ server: "db"
31
+ };
32
+ /** Where a bucket lives when nobody said — see {@link DEFAULT_CACHE}. */
33
+ const DEFAULT_STORAGE = {
34
+ aws: "s3",
35
+ server: "minio"
36
+ };
37
+ /**
38
+ * Who delivers mail when nobody said.
39
+ *
40
+ * Flat, unlike the others, and deliberately: mail is a SaaS on every target.
41
+ * There is no self-hosted preset to default a container deploy to — Mailpit is
42
+ * a development inbox, not a sender — so `server` has no answer of its own to
43
+ * give and would only be `ses` written twice.
44
+ */
45
+ const DEFAULT_EMAIL = "ses";
46
+
47
+ //#endregion
48
+ //#region src/generators/Generator.ts
49
+ /**
50
+ * Zod v4 maintains a process-wide registry of schemas registered via
51
+ * `.meta({ id })`. When we cache-bust user module imports (by appending a
52
+ * `?t=timestamp` query), those modules re-execute and try to register the
53
+ * same ids again, which throws `ID X already exists in the registry`.
54
+ *
55
+ * Clearing the registry in the CLI process is safe: the user's running
56
+ * server lives in a subprocess and has its own isolated registry.
57
+ *
58
+ * Exported for tests.
59
+ */
60
+ function clearZodGlobalRegistry() {
61
+ const registry = globalThis.__zod_globalRegistry;
62
+ if (registry && typeof registry.clear === "function") registry.clear();
63
+ }
64
+ var ConstructGenerator = class {
65
+ static async build(context, outputDir, generator, patterns, options) {
66
+ const constructs = await generator.load(patterns);
67
+ return generator.build(context, constructs, outputDir, options);
68
+ }
69
+ async load(patterns, cwd = process.cwd(), bustCache = false) {
70
+ const logger$1 = console;
71
+ let globPatterns;
72
+ let partitionFn;
73
+ if (isPartitionedRoutes(patterns)) {
74
+ globPatterns = Array.isArray(patterns.paths) ? patterns.paths : [patterns.paths];
75
+ partitionFn = patterns.partition;
76
+ } else globPatterns = Array.isArray(patterns) ? patterns : patterns ? [patterns] : [];
77
+ const files = fg.stream(globPatterns, {
78
+ cwd,
79
+ absolute: true
80
+ });
81
+ if (bustCache) clearZodGlobalRegistry();
82
+ const constructs = [];
83
+ for await (const f of files) try {
84
+ const file = f.toString();
85
+ const importPath = bustCache ? `${file}?t=${Date.now()}` : file;
86
+ const module = await import(importPath);
87
+ const partition = partitionFn ? partitionFn(file) : void 0;
88
+ for (const [key, construct] of Object.entries(module)) if (this.isConstruct(construct)) constructs.push({
89
+ key,
90
+ name: kebabCase$1(key),
91
+ construct,
92
+ path: {
93
+ absolute: file,
94
+ relative: relative(process.cwd(), file)
95
+ },
96
+ partition
97
+ });
98
+ } catch (error) {
99
+ const err = error;
100
+ logger$1.error(`Failed to load ${f}: ${err.message}`);
101
+ if (err.stack) logger$1.error(err.stack);
102
+ throw error;
103
+ }
104
+ return constructs;
105
+ }
106
+ };
107
+
108
+ //#endregion
109
+ //#region src/reconcile/discover.ts
110
+ /** Matches the rest of the CLI, which logs through `console` directly. */
111
+ const logger = console;
112
+ /**
113
+ * Whether a module export is a construct.
114
+ *
115
+ * Deliberately loose about what else it carries — a construct that also has a
116
+ * `service` is still a construct, and requiring one would exclude the kinds that
117
+ * own no address.
118
+ */
119
+ function isDeclarable(value) {
120
+ if (typeof value !== "object" || value === null) return false;
121
+ const candidate = value;
122
+ return typeof candidate.id === "string" && candidate.id.length > 0 && typeof candidate.declare === "function";
123
+ }
124
+ /**
125
+ * Build the construct manifest for a project.
126
+ *
127
+ * Runs the manifest's own validation before returning, so an app is wrong here
128
+ * — where the error names a file — rather than at deploy.
129
+ *
130
+ * @throws {DuplicateConstruct} when two exports claim one id.
131
+ */
132
+ async function discover(options) {
133
+ const { patterns, cwd = process.cwd(), bustCache = false, sources: out } = options;
134
+ if (bustCache) clearZodGlobalRegistry();
135
+ const manifest = {};
136
+ /** Which file declared each id, for the error when two of them do. */
137
+ const sources = {};
138
+ /**
139
+ * Constructs already seen, by identity.
140
+ *
141
+ * A re-export is the *same object* reached through a second file — ESM
142
+ * bindings are live, so `export * from './database.js'` hands back the
143
+ * binding rather than a copy. Without this, a barrel file made every
144
+ * construct in it appear declared twice, and `constructs/index.ts` is the
145
+ * first thing anyone writes in a shared folder.
146
+ *
147
+ * Identity rather than file is also the more honest rule: what may not
148
+ * happen twice is two *different* constructs claiming one id, and that is
149
+ * still an error below.
150
+ */
151
+ const seen = /* @__PURE__ */ new WeakSet();
152
+ const globs = Array.isArray(patterns) ? [...patterns] : [patterns];
153
+ const files = fg.stream(globs, {
154
+ cwd,
155
+ absolute: true
156
+ });
157
+ /** Matched files, for the diagnostic below. */
158
+ let matched = 0;
159
+ for await (const found of files) {
160
+ matched++;
161
+ const file = found.toString();
162
+ const module = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
163
+ for (const [exportName, exported] of Object.entries(module)) {
164
+ if (!isDeclarable(exported)) continue;
165
+ if (seen.has(exported)) continue;
166
+ seen.add(exported);
167
+ for (const declaration of exported.declare()) {
168
+ const id = canonicalId(declaration.id);
169
+ const source = relative(cwd, file);
170
+ const claimed = sources[id];
171
+ if (claimed !== void 0 && claimed !== source) throw new DuplicateConstruct(id, [claimed, source]);
172
+ manifest[id] = {
173
+ ...declaration,
174
+ id
175
+ };
176
+ sources[id] = source;
177
+ if (out) out[id] = {
178
+ file,
179
+ exportName
180
+ };
181
+ }
182
+ }
183
+ }
184
+ assertDerivations(manifest);
185
+ warnIfNothingFound(globs, matched, Object.keys(manifest).length);
186
+ return manifest;
187
+ }
188
+ /**
189
+ * Say so when a glob was configured and found nothing.
190
+ *
191
+ * The glob is not a filter over declarations already known — it is *how they
192
+ * are found*, by importing what it matches. So a file it misses is a
193
+ * declaration that does not exist, and every symptom of that appears somewhere
194
+ * other than the cause: no container starts, no env key is written, and the
195
+ * application fails on first use against a resource it can see in its own
196
+ * source.
197
+ *
198
+ * Nothing reported it before, because an unmatched file is indistinguishable
199
+ * from a file nobody wrote. These two cases are the ones that are *not*
200
+ * ambiguous — a glob was configured, so something was expected.
201
+ *
202
+ * Silent when no glob is configured at all: that is a project which has not
203
+ * adopted constructs, and has nothing to be missing.
204
+ */
205
+ function warnIfNothingFound(globs, matched, declared) {
206
+ if (globs.length === 0) return;
207
+ if (matched === 0) {
208
+ logger.warn(`\n⚠️ The constructs glob matched no files, so nothing was declared.\n Patterns: ${globs.join(", ")}\n Nothing will be provisioned — no containers, no env keys, no resources.\n A common cause is depth: '*.ts' matches one level, '**/*.ts' matches any.`);
209
+ return;
210
+ }
211
+ if (declared === 0) logger.warn(`\n⚠️ The constructs glob matched ${matched} file(s) but none declared anything.\n Patterns: ${globs.join(", ")}\n Discovery keeps exports with an 'id' that can 'declare()'. A construct that is\n built but never exported is invisible to it.`);
212
+ }
213
+ /** Two constructs claiming one id. */
214
+ var DuplicateConstruct = class extends Error {
215
+ /** The id claimed twice. */
216
+ id;
217
+ /** The files that claimed it. */
218
+ sources;
219
+ constructor(id, sources) {
220
+ super("Two constructs declare the same id");
221
+ this.name = "DuplicateConstruct";
222
+ this.id = id;
223
+ this.sources = sources;
224
+ }
225
+ };
226
+
227
+ //#endregion
228
+ export { ConstructGenerator, DEFAULT_CACHE, DEFAULT_EMAIL, DEFAULT_STORAGE, discover, isDeclarable, isPartitionedRoutes };
229
+ //# sourceMappingURL=discover-CAlFgYec.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover-CAlFgYec.mjs","names":["routes: Routes | undefined","DEFAULT_CACHE: Record<MainProvider, CacheBackend>","DEFAULT_STORAGE: Record<MainProvider, StorageBackend>","DEFAULT_EMAIL: EmailBackend","context: BuildContext","outputDir: string","generator: ConstructGenerator<T, R>","patterns?: Routes","options?: GeneratorOptions","logger","globPatterns: string[]","partitionFn: ((filepath: string) => string) | undefined","constructs: GeneratedConstruct<T>[]","value: unknown","options: DiscoverOptions","manifest: Record<string, Declaration>","sources: Record<string, string>","globs: readonly string[]","matched: number","declared: number","id: string","sources: readonly string[]"],"sources":["../src/types.ts","../src/generators/Generator.ts","../src/reconcile/discover.ts"],"sourcesContent":["import type { ServicesConfig } from './workspace/types.js';\n\nexport type MainProvider = 'aws' | 'server';\nexport type LegacyProvider =\n\t| 'server'\n\t| 'aws-apigatewayv1'\n\t| 'aws-apigatewayv2'\n\t| 'aws-lambda';\n\nexport interface PartitionedRoutes {\n\tpaths: string | string[];\n\tpartition: (filepath: string) => string;\n}\n\nexport type Routes = string | string[] | PartitionedRoutes;\n\nexport function isPartitionedRoutes(\n\troutes: Routes | undefined,\n): routes is PartitionedRoutes {\n\treturn (\n\t\ttypeof routes === 'object' &&\n\t\troutes !== null &&\n\t\t!Array.isArray(routes) &&\n\t\t'paths' in routes\n\t);\n}\n\nexport interface ProviderConfig {\n\tenabled?: boolean;\n\toutputDir?: string;\n}\n\nexport interface AWSApiGatewayConfig extends ProviderConfig {\n\t// Additional AWS API Gateway specific options\n}\n\nexport interface AWSLambdaConfig extends ProviderConfig {\n\t// Additional AWS Lambda specific options\n}\n\nexport interface ProductionConfig {\n\t/** Enable production mode (default: false) */\n\tenabled?: boolean;\n\t/** Bundle server into single file (default: true) */\n\tbundle?: boolean;\n\t/** Minify bundled output (default: true) */\n\tminify?: boolean;\n\t/** Health check endpoint path (default: '/health') */\n\thealthCheck?: string;\n\t/** Enable graceful shutdown handling (default: true) */\n\tgracefulShutdown?: boolean;\n\t/** Packages to exclude from bundling (default: []) */\n\texternal?: string[];\n\t/** Include subscribers in production build (default: 'exclude' for serverless) */\n\tsubscribers?: 'include' | 'exclude';\n\t/** Include OpenAPI spec in production (default: false) */\n\topenapi?: boolean;\n\t/**\n\t * Enable build-time optimized handler generation (default: true)\n\t * Generates specialized handlers based on endpoint tier:\n\t * - minimal: Near-raw-Hono performance for simple endpoints\n\t * - standard: Optimized handlers for auth/services\n\t * - full: Uses HonoEndpoint.addRoutes for complex endpoints\n\t */\n\toptimizedHandlers?: boolean;\n}\n\n/** Service-specific configuration for docker-compose */\nexport interface ServiceConfig {\n\t/**\n\t * Full Docker image reference (e.g., 'postgis/postgis:16-3.4-alpine').\n\t * When specified, overrides the default image entirely.\n\t */\n\timage?: string;\n\t/**\n\t * Docker image version/tag (e.g., '15-alpine' for postgres).\n\t * Only used when `image` is not specified.\n\t */\n\tversion?: string;\n}\n\n/**\n * Supported event backend types.\n *\n * - `pgboss`: Reuses PostgreSQL with a dedicated user/schema. Auto-enables db service.\n * - `sns`: Adds LocalStack container with SNS+SQS services.\n * - `rabbitmq`: Adds RabbitMQ container.\n *\n * All backends generate EVENT_PUBLISHER_CONNECTION_STRING and EVENT_SUBSCRIBER_CONNECTION_STRING.\n */\nexport type EventsBackend = 'pgboss' | 'sns' | 'rabbitmq';\n\n/**\n * Where a declared cache actually lives.\n *\n * A deployment choice, not an application one — the same code caches into any\n * of these — so it is config here beside `events` rather than a field on the\n * construct. Each backend is consistent between local and deployed, which is\n * the property worth having: a cache that behaves differently in the two places\n * is worse than a slower one.\n *\n * - `upstash` (default) — HTTP with a token. Reachable from a Lambda with no\n * VPC and no connection pool, which is why it is the default; locally the\n * `serverless-redis-http` proxy in front of Redis speaks the same protocol.\n * - `elasticache` — the Redis wire protocol, inside a VPC. Locally, plain Redis.\n * - `db` — a table in the database the app already declared. No infrastructure\n * at all, and the same relationship pg-boss has to Postgres: it creates its\n * own table on first use and needs a declared database to live in.\n */\nexport type CacheBackend = 'upstash' | 'elasticache' | 'db';\n\n/**\n * Where a declared bucket actually lives.\n *\n * The fourth of these selectors and the last to arrive, which is why\n * `UPLOADS_URL` had no answer on a container target: there was nothing to\n * choose with. Like the others it changes no application code — the `s3://`\n * scheme picks the driver, and every one of these speaks it.\n *\n * - `s3` — a real bucket. Nothing is created on the host; the URL is composed\n * against credentials you already hold, the same way `resend` is an API key\n * rather than infrastructure.\n * - `r2` — Cloudflare's, reached through the same S3 API and differing only in\n * its endpoint.\n * - `minio` — a container. Everything the app declares lives on the box, which\n * is what makes a single-host deploy self-contained, and what makes it a\n * single disk with no replication. Locally this is what every backend is.\n */\nexport type StorageBackend = 'minio' | 's3' | 'r2';\n\n/**\n * The backend a project gets when it says nothing, by where it deploys.\n *\n * Flat defaults could not be right for both: `upstash` on a single box means a\n * SaaS round-trip for a cache the database could have held, and `minio` on AWS\n * means running a bucket beside S3. So the default is a function of the target,\n * and an app that says nothing gets the obvious answer in both places — which\n * is the whole of what \"zero config\" can mean once there is more than one\n * target.\n *\n * `server` covers Dokploy and a bare host alike: the question these answer is\n * whether the app is next to a managed cloud or next to its own containers, and\n * on that question the two are the same.\n *\n * A per-construct, per-stage override is the layer above this — see\n * `constructs-outstanding.md` — so two buckets in one app can differ. This is\n * only what happens when nobody has said anything at all.\n */\nexport const DEFAULT_CACHE: Record<MainProvider, CacheBackend> = {\n\t// Reachable from a Lambda with no VPC and no connection pool.\n\taws: 'upstash',\n\t// The database is already there and already has a connection pool open to\n\t// it. Anything else is a second service to run for a table.\n\tserver: 'db',\n};\n\n/** Where a bucket lives when nobody said — see {@link DEFAULT_CACHE}. */\nexport const DEFAULT_STORAGE: Record<MainProvider, StorageBackend> = {\n\taws: 's3',\n\tserver: 'minio',\n};\n\n/**\n * Who delivers a declared app's mail.\n *\n * Unlike a cache, this changes *nothing* about the client. Every backend speaks\n * SMTP, so the declaration's `smtp://` URL is true of all of them and only the\n * provisioner differs — which is the same reason the declaration has no\n * `provider` field and there is no `ses://` scheme.\n *\n * - `ses` (default) — the only backend that can be a *chain* of resources: an\n * identity, a user, an access key, and an SMTP password derived from it,\n * because SES issues IAM credentials rather than SMTP ones. Hand it a URL and\n * it uses that instead, which is what you want when the credentials already\n * exist — provisioning a second set of sending credentials for an identity\n * that already has them is not a thing to do by default.\n * - `resend` — an API key you hold, composed into an SMTP URL. Nothing to\n * provision: a SaaS account is not infrastructure.\n * - `smtp` — a URL supplied whole, for a relay somebody else runs.\n *\n * Locally every one of them is Mailpit, because locally none of it matters.\n */\nexport type EmailBackend = 'resend' | 'ses' | 'smtp';\n\n/**\n * Who delivers mail when nobody said.\n *\n * Flat, unlike the others, and deliberately: mail is a SaaS on every target.\n * There is no self-hosted preset to default a container deploy to — Mailpit is\n * a development inbox, not a sender — so `server` has no answer of its own to\n * give and would only be `ses` written twice.\n */\nexport const DEFAULT_EMAIL: EmailBackend = 'ses';\n\n/** Supported docker-compose service names */\nexport type ComposeServiceName =\n\t| 'postgres'\n\t| 'redis'\n\t| 'rabbitmq'\n\t| 'minio'\n\t| 'mailpit'\n\t| 'localstack';\n\n/** Services configuration - can be boolean (use defaults) or object with version */\nexport type ComposeServicesConfig = {\n\t[K in ComposeServiceName]?: boolean | ServiceConfig;\n};\n\nexport interface DockerConfig {\n\t/** Container registry URL (e.g., 'ghcr.io/myorg') */\n\tregistry?: string;\n\t/** Docker image name (default: derived from package.json name) */\n\timageName?: string;\n\t/** Base Docker image (default: 'node:22-alpine') */\n\tbaseImage?: string;\n\t/** Container port (default: 3000) */\n\tport?: number;\n\t/** docker-compose services to include */\n\tcompose?: {\n\t\t/**\n\t\t * Services to include in docker-compose.\n\t\t * Can be an object with service configs or an array of service names (legacy).\n\t\t *\n\t\t * @example Object format (recommended)\n\t\t * services: {\n\t\t * postgres: { version: '15-alpine' },\n\t\t * redis: true, // use default version\n\t\t * }\n\t\t *\n\t\t * @example Array format (legacy, uses default versions)\n\t\t * services: ['postgres', 'redis']\n\t\t */\n\t\tservices?: ComposeServicesConfig | ComposeServiceName[];\n\t};\n}\n\nexport interface ServerConfig extends ProviderConfig {\n\tenableOpenApi?: boolean;\n\tport?: number;\n\t/** Production build configuration */\n\tproduction?: ProductionConfig;\n}\n\nexport type Runtime = 'node' | 'bun';\n\nexport interface TelescopeConfig {\n\t/** Enable/disable telescope (default: true in development) */\n\tenabled?: boolean;\n\t/** Port for telescope to use (defaults to server port) */\n\tport?: number;\n\t/** Path prefix for telescope UI (default: /__telescope) */\n\tpath?: string;\n\t/** Ignore patterns for telescope (e.g., ['/health', '/metrics']) */\n\tignore?: string[];\n\t/** Record request/response bodies (default: true) */\n\trecordBody?: boolean;\n\t/** Maximum entries to keep in memory (default: 1000) */\n\tmaxEntries?: number;\n\t/** Enable WebSocket for real-time updates (default: true, requires @hono/node-ws for Node.js) */\n\twebsocket?: boolean;\n}\n\nexport interface StudioConfig {\n\t/** Enable/disable studio (default: true in development) */\n\tenabled?: boolean;\n\t/** Path prefix for studio UI (default: /__studio) */\n\tpath?: string;\n\t/** Schema to introspect (default: 'public') */\n\tschema?: string;\n}\n\nexport interface OpenApiConfig {\n\t/** Enable OpenAPI generation (default: true) */\n\tenabled?: boolean;\n\t/** API title */\n\ttitle?: string;\n\t/** API version */\n\tversion?: string;\n\t/** API description */\n\tdescription?: string;\n}\n\nexport interface HooksConfig {\n\t/**\n\t * Path to a module exporting server lifecycle hooks.\n\t * The module should export `beforeSetup` and/or `afterSetup` functions.\n\t *\n\t * @example\n\t * ```typescript\n\t * // src/config/hooks.ts\n\t * import type { Hono } from 'hono';\n\t * import type { Logger } from '@geekmidas/logger';\n\t * import type { EnvironmentParser } from '@geekmidas/envkit';\n\t *\n\t * // Called BEFORE gkm endpoints are registered\n\t * export function beforeSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {\n\t * app.use('*', cors());\n\t * app.get('/custom/health', (c) => c.json({ status: 'ok' }));\n\t * }\n\t *\n\t * // Called AFTER gkm endpoints are registered\n\t * export function afterSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {\n\t * app.notFound((c) => c.json({ error: 'Not found' }, 404));\n\t * app.onError((err, c) => c.json({ error: err.message }, 500));\n\t * }\n\t * ```\n\t */\n\tserver?: string;\n}\n\n/** Dokploy deployment configuration */\nexport interface DokployProviderConfig {\n\t/** Dokploy API endpoint (e.g., 'https://dokploy.example.com') */\n\tendpoint: string;\n\t/** Project ID in Dokploy */\n\tprojectId: string;\n\t/** Application ID in Dokploy */\n\tapplicationId: string;\n\t/** Container registry (overrides docker.registry if set) */\n\tregistry?: string;\n\t/** Registry ID in Dokploy (recommended for private registries) */\n\tregistryId?: string;\n}\n\nexport interface ProvidersConfig {\n\taws?: {\n\t\tapiGateway?: {\n\t\t\tv1?: boolean | AWSApiGatewayConfig;\n\t\t\tv2?: boolean | AWSApiGatewayConfig;\n\t\t};\n\t\tlambda?: {\n\t\t\tfunctions?: boolean | AWSLambdaConfig;\n\t\t\tcrons?: boolean | AWSLambdaConfig;\n\t\t};\n\t};\n\tserver?: boolean | ServerConfig;\n\t/** Dokploy deployment configuration */\n\tdokploy?: boolean | DokployProviderConfig;\n}\n\nexport interface GkmConfig {\n\t/**\n\t * What this app is called, and therefore how everything it declares is named.\n\t *\n\t * The same field `sst.config.ts` carries, doing the same job: every physical\n\t * name is `{stage}-{name}-{construct}`, so `Database` in the `production`\n\t * stage of `kitchen-sink` is `production-kitchen-sink-database` on AWS and on\n\t * Dokploy alike. One statement, in the config, rather than a rule each\n\t * provider restates.\n\t *\n\t * `defineWorkspace` has always had this. A single-app config did not, so its\n\t * names fell back to whatever the directory happened to be called — the\n\t * monorepo's package name for the project and the app's for the application,\n\t * two accidents of layout standing in for a decision.\n\t *\n\t * Defaults to the package.json name with any scope stripped, then the\n\t * directory name.\n\t */\n\tname?: string;\n\t/**\n\t * Where the things no construct implies live.\n\t *\n\t * The same block a workspace config carries, and the same split: `db` and\n\t * `storage` are derived from the declared `KyselyDatabase` and\n\t * `ObjectStorage` and are ignored here, while `cache`, `mail`, and `events`\n\t * name a *backend* — where the cache lives, who delivers the mail, which\n\t * broker carries events. A single-app project had no way to say any of that\n\t * before, so its event backend could only be guessed.\n\t */\n\tservices?: ServicesConfig;\n\t/**\n\t * Constructs glob pattern — one glob, every kind.\n\t *\n\t * What reconcile reads to derive the containers a stage needs: a database\n\t * implies Postgres, objects imply MinIO, mail implies Mailpit. A glob per\n\t * kind cannot find a resource, because a declared `ObjectStorage` has no\n\t * kind to be listed under.\n\t *\n\t * @example './src/**\\/*.ts'\n\t */\n\tconstructs?: Routes;\n\troutes: Routes;\n\tfunctions?: Routes;\n\tcrons?: Routes;\n\tsubscribers?: Routes;\n\tqueues?: Routes;\n\ttopics?: Routes;\n\tenvParser: string;\n\tlogger: string;\n\tproviders?: ProvidersConfig;\n\t/**\n\t * Server lifecycle hooks for customizing the Hono app.\n\t * Allows adding custom routes, middleware, error handlers, etc.\n\t *\n\t * @example\n\t * hooks: {\n\t * server: './src/config/hooks'\n\t * }\n\t */\n\thooks?: HooksConfig;\n\t/**\n\t * Telescope configuration for debugging/monitoring.\n\t * Can be:\n\t * - A string path to a module that exports a Telescope instance (recommended)\n\t * - A boolean to enable/disable with defaults\n\t * - A TelescopeConfig object for inline configuration\n\t */\n\ttelescope?: string | boolean | TelescopeConfig;\n\t/**\n\t * Studio configuration for database browsing.\n\t * Can be:\n\t * - A string path to a module that exports a Studio instance (recommended)\n\t * - A boolean to enable/disable with defaults\n\t * - A StudioConfig object for inline configuration\n\t *\n\t * Requires a database connection configured via services.\n\t */\n\tstudio?: string | boolean | StudioConfig;\n\t/**\n\t * OpenAPI generation configuration.\n\t * Can be:\n\t * - A boolean to enable/disable with defaults (output: ./src/api/openapi.ts)\n\t * - An OpenApiConfig object for customization\n\t *\n\t * When enabled, OpenAPI spec is generated on startup and regenerated on route changes.\n\t *\n\t * @example\n\t * openapi: true\n\t *\n\t * @example\n\t * openapi: {\n\t * output: './src/api/openapi.ts',\n\t * title: 'My API',\n\t * version: '1.0.0',\n\t * }\n\t */\n\topenapi?: boolean | OpenApiConfig;\n\t/** Runtime to use for dev server (default: 'node') */\n\truntime?: Runtime;\n\t/**\n\t * Environment file(s) to load for development.\n\t * Can be:\n\t * - A string path to a single env file (e.g., '.env.local')\n\t * - An array of paths to load in order (later files override earlier)\n\t * - Defaults to '.env' if not specified\n\t *\n\t * @example\n\t * env: '.env.local'\n\t *\n\t * @example\n\t * env: ['.env', '.env.local']\n\t */\n\tenv?: string | string[];\n\t/**\n\t * Docker deployment configuration.\n\t * Used by `gkm docker` and `gkm prepack` commands.\n\t *\n\t * @example\n\t * docker: {\n\t * registry: 'ghcr.io/myorg',\n\t * imageName: 'my-api',\n\t * compose: {\n\t * services: ['postgres', 'redis']\n\t * }\n\t * }\n\t */\n\tdocker?: DockerConfig;\n\t/**\n\t * Where this app deploys, and what the target needs to know.\n\t *\n\t * Absent until now, which meant a single-app project could not configure a\n\t * Dokploy deploy at all: the wrap that turns one into a workspace hardcoded\n\t * `{ default: 'dokploy' }` and dropped everything else, so there was no\n\t * endpoint, no registry and no domain — and `resolveHost` failed with \"no\n\t * domain configured for stage\" on a config that had nowhere to put one.\n\t *\n\t * The same shape a workspace config uses, so moving from one to the other is\n\t * a rename rather than a rewrite.\n\t */\n\tdeploy?: import('./workspace/types').DeployConfig;\n}\n\nexport interface BuildOptions {\n\tprovider?: MainProvider;\n\t// Legacy support - will be deprecated\n\tproviders?: LegacyProvider[];\n\tenableOpenApi?: boolean;\n\t/** Build for production (no dev tools, bundled output) */\n\tproduction?: boolean;\n\t/** Skip bundling step in production build */\n\tskipBundle?: boolean;\n\t/** Stage for secrets injection (e.g., 'production', 'staging') */\n\tstage?: string;\n\t/**\n\t * When true, optional environment variables (those with `.optional()` or\n\t * `.default()` in the envParser) are suffixed with `?` within each\n\t * construct's `environment` array in the manifest (e.g. `PORT?`).\n\t * Defaults to false.\n\t */\n\tmarkOptional?: boolean;\n}\n\n/** Result from build command when secrets are injected */\nexport interface BuildResult {\n\t/** Ephemeral master key for deployment (only if stage was provided) */\n\tmasterKey?: string;\n}\n\n// The deployment manifest types are a shared, dependency-free data contract\n// in `@geekmidas/manifest`, re-exported here for back-compat with existing\n// `@geekmidas/cli` imports.\nexport type {\n\tCronInfo,\n\tFunctionInfo,\n\tManifest,\n\tQueueInfo,\n\tRouteInfo,\n\tSubscriberInfo,\n\tTopicInfo,\n} from '@geekmidas/manifest';\n","import { relative } from 'node:path';\nimport type { Construct } from '@geekmidas/constructs';\nimport fg from 'fast-glob';\nimport kebabCase from 'lodash.kebabcase';\nimport type { BuildContext } from '../build/types';\nimport {\n\tisPartitionedRoutes,\n\ttype LegacyProvider,\n\ttype Routes,\n} from '../types';\n\n/**\n * Zod v4 maintains a process-wide registry of schemas registered via\n * `.meta({ id })`. When we cache-bust user module imports (by appending a\n * `?t=timestamp` query), those modules re-execute and try to register the\n * same ids again, which throws `ID X already exists in the registry`.\n *\n * Clearing the registry in the CLI process is safe: the user's running\n * server lives in a subprocess and has its own isolated registry.\n *\n * Exported for tests.\n */\nexport function clearZodGlobalRegistry(): void {\n\tconst registry = (\n\t\tglobalThis as { __zod_globalRegistry?: { clear?: () => void } }\n\t).__zod_globalRegistry;\n\tif (registry && typeof registry.clear === 'function') {\n\t\tregistry.clear();\n\t}\n}\n\nexport interface GeneratorOptions {\n\tprovider?: LegacyProvider;\n\t[key: string]: any;\n}\n\nexport abstract class ConstructGenerator<T extends Construct, R = void> {\n\tabstract isConstruct(value: any): value is T;\n\n\tstatic async build<T extends Construct, R = void>(\n\t\tcontext: BuildContext,\n\t\toutputDir: string,\n\t\tgenerator: ConstructGenerator<T, R>,\n\t\tpatterns?: Routes,\n\t\toptions?: GeneratorOptions,\n\t): Promise<R> {\n\t\tconst constructs = await generator.load(patterns);\n\t\treturn generator.build(context, constructs, outputDir, options);\n\t}\n\n\tabstract build(\n\t\tcontext: BuildContext,\n\t\tconstructs: GeneratedConstruct<T>[],\n\t\toutputDir: string,\n\t\toptions?: GeneratorOptions,\n\t): Promise<R>;\n\n\tasync load(\n\t\tpatterns?: Routes,\n\t\tcwd = process.cwd(),\n\t\tbustCache = false,\n\t): Promise<GeneratedConstruct<T>[]> {\n\t\tconst logger = console;\n\n\t\t// Extract glob patterns and optional partition function\n\t\tlet globPatterns: string[];\n\t\tlet partitionFn: ((filepath: string) => string) | undefined;\n\n\t\tif (isPartitionedRoutes(patterns)) {\n\t\t\tglobPatterns = Array.isArray(patterns.paths)\n\t\t\t\t? patterns.paths\n\t\t\t\t: [patterns.paths];\n\t\t\tpartitionFn = patterns.partition;\n\t\t} else {\n\t\t\tglobPatterns = Array.isArray(patterns)\n\t\t\t\t? patterns\n\t\t\t\t: patterns\n\t\t\t\t\t? [patterns]\n\t\t\t\t\t: [];\n\t\t}\n\n\t\t// Find all files\n\t\tconst files = fg.stream(globPatterns, {\n\t\t\tcwd,\n\t\t\tabsolute: true,\n\t\t});\n\n\t\t// Cache-busted re-imports re-execute user modules, which would try to\n\t\t// re-register Zod schemas with the same `.meta({ id })`. Clear the\n\t\t// global registry once per load to prevent duplicate-id errors.\n\t\tif (bustCache) {\n\t\t\tclearZodGlobalRegistry();\n\t\t}\n\n\t\t// Load constructs\n\t\tconst constructs: GeneratedConstruct<T>[] = [];\n\n\t\tfor await (const f of files) {\n\t\t\ttry {\n\t\t\t\tconst file = f.toString();\n\t\t\t\t// Append cache-busting query param to force re-import of changed modules\n\t\t\t\tconst importPath = bustCache ? `${file}?t=${Date.now()}` : file;\n\t\t\t\tconst module = await import(importPath);\n\n\t\t\t\t// Compute partition name for this file (if partition function provided)\n\t\t\t\tconst partition = partitionFn ? partitionFn(file) : undefined;\n\n\t\t\t\t// Check all exports for constructs\n\t\t\t\tfor (const [key, construct] of Object.entries(module)) {\n\t\t\t\t\tif (this.isConstruct(construct)) {\n\t\t\t\t\t\tconstructs.push({\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tname: kebabCase(key),\n\t\t\t\t\t\t\tconstruct,\n\t\t\t\t\t\t\tpath: {\n\t\t\t\t\t\t\t\tabsolute: file,\n\t\t\t\t\t\t\t\trelative: relative(process.cwd(), file),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpartition,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst err = error as Error;\n\t\t\t\tlogger.error(`Failed to load ${f}: ${err.message}`);\n\t\t\t\tif (err.stack) {\n\t\t\t\t\tlogger.error(err.stack);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn constructs;\n\t}\n}\n\nexport interface GeneratedConstruct<T extends Construct> {\n\tkey: string;\n\tname: string;\n\tconstruct: T;\n\tpath: {\n\t\tabsolute: string;\n\t\trelative: string;\n\t};\n\t/** Partition name assigned by the partition function, if configured. */\n\tpartition?: string;\n}\n","/**\n * Discovery — one glob, one structural test.\n *\n * A glob per kind is the same specialness the construct model removes, and\n * resources have no kind to be listed under: a declared `ObjectStorage` would\n * never be found by `routes:` or `crons:`. So there is one `constructs` glob,\n * every export of every matching module is inspected, and the per-kind\n * `isConstruct` checks collapse into a single question — does it have an id and\n * can it declare?\n *\n * Structural rather than `instanceof` on purpose. A construct from a different\n * copy of `@geekmidas/constructs` — a linked workspace, two versions in a\n * lockfile — is still a construct, and `instanceof` is exactly the check that\n * says otherwise.\n */\n\nimport { relative } from 'node:path';\nimport {\n\tassertDerivations,\n\ttype ConstructManifest,\n\tcanonicalId,\n\ttype Declaration,\n} from '@geekmidas/manifest';\nimport fg from 'fast-glob';\nimport { clearZodGlobalRegistry } from '../generators/Generator';\n\n/** Matches the rest of the CLI, which logs through `console` directly. */\nconst logger = console;\n\n/** The construct face discovery needs: an id, and the ability to declare. */\ninterface Declarable {\n\tid: string;\n\tdeclare(): Declaration[];\n}\n\n/**\n * Whether a module export is a construct.\n *\n * Deliberately loose about what else it carries — a construct that also has a\n * `service` is still a construct, and requiring one would exclude the kinds that\n * own no address.\n */\nexport function isDeclarable(value: unknown): value is Declarable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Declarable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\tcandidate.id.length > 0 &&\n\t\ttypeof candidate.declare === 'function'\n\t);\n}\n\nexport interface DiscoverOptions {\n\t/** The glob(s) to search. One pattern, not one per kind. */\n\tpatterns: string | readonly string[];\n\tcwd?: string;\n\t/**\n\t * Re-import changed modules, for the dev watcher.\n\t *\n\t * A single glob makes discovery more central, not less: a new construct file\n\t * has to be picked up on `add`, not only on `change`.\n\t */\n\tbustCache?: boolean;\n\t/**\n\t * Filled in with where each construct was found, when provided.\n\t *\n\t * Discovery is the only thing that knows: it globbed the files and imported\n\t * them. Everything downstream that needs to *write* an import — the build,\n\t * generating a server entry that reads a surface's logger — would otherwise\n\t * have to be told the path in config, which is the string this removes.\n\t *\n\t * An out-parameter rather than a second return value so that every existing\n\t * caller, which wants the manifest and nothing else, is unchanged.\n\t */\n\tsources?: Record<string, ConstructSource>;\n}\n\n/** Where a construct was declared, and under what name. */\nexport interface ConstructSource {\n\t/** Absolute path to the module that exported it. */\n\tfile: string;\n\t/** The name it was exported as — what an import statement has to say. */\n\texportName: string;\n}\n\n/**\n * Build the construct manifest for a project.\n *\n * Runs the manifest's own validation before returning, so an app is wrong here\n * — where the error names a file — rather than at deploy.\n *\n * @throws {DuplicateConstruct} when two exports claim one id.\n */\nexport async function discover(\n\toptions: DiscoverOptions,\n): Promise<ConstructManifest> {\n\tconst {\n\t\tpatterns,\n\t\tcwd = process.cwd(),\n\t\tbustCache = false,\n\t\tsources: out,\n\t} = options;\n\n\t// Re-importing user modules re-executes them, and Zod v4 throws on a\n\t// re-registered `.meta({ id })`. Same reason the generators clear it.\n\tif (bustCache) clearZodGlobalRegistry();\n\n\tconst manifest: Record<string, Declaration> = {};\n\t/** Which file declared each id, for the error when two of them do. */\n\tconst sources: Record<string, string> = {};\n\t/**\n\t * Constructs already seen, by identity.\n\t *\n\t * A re-export is the *same object* reached through a second file — ESM\n\t * bindings are live, so `export * from './database.js'` hands back the\n\t * binding rather than a copy. Without this, a barrel file made every\n\t * construct in it appear declared twice, and `constructs/index.ts` is the\n\t * first thing anyone writes in a shared folder.\n\t *\n\t * Identity rather than file is also the more honest rule: what may not\n\t * happen twice is two *different* constructs claiming one id, and that is\n\t * still an error below.\n\t */\n\tconst seen = new WeakSet<object>();\n\n\tconst globs = Array.isArray(patterns) ? [...patterns] : [patterns as string];\n\tconst files = fg.stream(globs, { cwd, absolute: true });\n\n\t/** Matched files, for the diagnostic below. */\n\tlet matched = 0;\n\n\tfor await (const found of files) {\n\t\tmatched++;\n\t\tconst file = found.toString();\n\t\tconst module = await import(bustCache ? `${file}?t=${Date.now()}` : file);\n\n\t\tfor (const [exportName, exported] of Object.entries(module)) {\n\t\t\tif (!isDeclarable(exported)) continue;\n\n\t\t\t// The same construct, reached again through a re-export. Skipped\n\t\t\t// rather than re-declared: it has already claimed its id, from the\n\t\t\t// file that defined it.\n\t\t\tif (seen.has(exported as object)) continue;\n\t\t\tseen.add(exported as object);\n\n\t\t\tfor (const declaration of exported.declare()) {\n\t\t\t\t// Canonicalise here too: a construct built by hand rather than through\n\t\t\t\t// a constructor is still subject to the same identity rule.\n\t\t\t\tconst id = canonicalId(declaration.id);\n\t\t\t\tconst source = relative(cwd, file);\n\n\t\t\t\tconst claimed = sources[id];\n\t\t\t\tif (claimed !== undefined && claimed !== source) {\n\t\t\t\t\tthrow new DuplicateConstruct(id, [claimed, source]);\n\t\t\t\t}\n\n\t\t\t\tmanifest[id] = { ...declaration, id };\n\t\t\t\tsources[id] = source;\n\t\t\t\tif (out) out[id] = { file, exportName };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Reference integrity before anyone reads it — a schema tenant naming a\n\t// database that was deleted is a manifest error, not a reconcile failure.\n\tassertDerivations(manifest);\n\n\twarnIfNothingFound(globs, matched, Object.keys(manifest).length);\n\n\treturn manifest;\n}\n\n/**\n * Say so when a glob was configured and found nothing.\n *\n * The glob is not a filter over declarations already known — it is *how they\n * are found*, by importing what it matches. So a file it misses is a\n * declaration that does not exist, and every symptom of that appears somewhere\n * other than the cause: no container starts, no env key is written, and the\n * application fails on first use against a resource it can see in its own\n * source.\n *\n * Nothing reported it before, because an unmatched file is indistinguishable\n * from a file nobody wrote. These two cases are the ones that are *not*\n * ambiguous — a glob was configured, so something was expected.\n *\n * Silent when no glob is configured at all: that is a project which has not\n * adopted constructs, and has nothing to be missing.\n */\nfunction warnIfNothingFound(\n\tglobs: readonly string[],\n\tmatched: number,\n\tdeclared: number,\n): void {\n\tif (globs.length === 0) return;\n\n\tif (matched === 0) {\n\t\tlogger.warn(\n\t\t\t`\\n⚠️ The constructs glob matched no files, so nothing was declared.\\n` +\n\t\t\t\t` Patterns: ${globs.join(', ')}\\n` +\n\t\t\t\t` Nothing will be provisioned — no containers, no env keys, no ` +\n\t\t\t\t`resources.\\n` +\n\t\t\t\t` A common cause is depth: '*.ts' matches one level, '**/*.ts' ` +\n\t\t\t\t`matches any.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tif (declared === 0) {\n\t\tlogger.warn(\n\t\t\t`\\n⚠️ The constructs glob matched ${matched} file(s) but none declared ` +\n\t\t\t\t`anything.\\n` +\n\t\t\t\t` Patterns: ${globs.join(', ')}\\n` +\n\t\t\t\t` Discovery keeps exports with an 'id' that can 'declare()'. A ` +\n\t\t\t\t`construct that is\\n` +\n\t\t\t\t` built but never exported is invisible to it.`,\n\t\t);\n\t}\n}\n\n/** Two constructs claiming one id. */\nexport class DuplicateConstruct extends Error {\n\t/** The id claimed twice. */\n\treadonly id: string;\n\t/** The files that claimed it. */\n\treadonly sources: readonly string[];\n\n\tconstructor(id: string, sources: readonly string[]) {\n\t\tsuper('Two constructs declare the same id');\n\t\tthis.name = 'DuplicateConstruct';\n\t\tthis.id = id;\n\t\tthis.sources = sources;\n\t}\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,oBACfA,QAC8B;AAC9B,eACQ,WAAW,YAClB,WAAW,SACV,MAAM,QAAQ,OAAO,IACtB,WAAW;AAEZ;;;;;;;;;;;;;;;;;;;AA2HD,MAAaC,gBAAoD;CAEhE,KAAK;CAGL,QAAQ;AACR;;AAGD,MAAaC,kBAAwD;CACpE,KAAK;CACL,QAAQ;AACR;;;;;;;;;AAgCD,MAAaC,gBAA8B;;;;;;;;;;;;;;;AC1K3C,SAAgB,yBAA+B;CAC9C,MAAM,WACL,WACC;AACF,KAAI,mBAAmB,SAAS,UAAU,WACzC,UAAS,OAAO;AAEjB;AAOD,IAAsB,qBAAtB,MAAwE;CAGvE,aAAa,MACZC,SACAC,WACAC,WACAC,UACAC,SACa;EACb,MAAM,aAAa,MAAM,UAAU,KAAK,SAAS;AACjD,SAAO,UAAU,MAAM,SAAS,YAAY,WAAW,QAAQ;CAC/D;CASD,MAAM,KACLD,UACA,MAAM,QAAQ,KAAK,EACnB,YAAY,OACuB;EACnC,MAAME,WAAS;EAGf,IAAIC;EACJ,IAAIC;AAEJ,MAAI,oBAAoB,SAAS,EAAE;AAClC,kBAAe,MAAM,QAAQ,SAAS,MAAM,GACzC,SAAS,QACT,CAAC,SAAS,KAAM;AACnB,iBAAc,SAAS;EACvB,MACA,gBAAe,MAAM,QAAQ,SAAS,GACnC,WACA,WACC,CAAC,QAAS,IACV,CAAE;EAIP,MAAM,QAAQ,GAAG,OAAO,cAAc;GACrC;GACA,UAAU;EACV,EAAC;AAKF,MAAI,UACH,yBAAwB;EAIzB,MAAMC,aAAsC,CAAE;AAE9C,aAAW,MAAM,KAAK,MACrB,KAAI;GACH,MAAM,OAAO,EAAE,UAAU;GAEzB,MAAM,aAAa,aAAa,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC,IAAI;GAC3D,MAAM,SAAS,MAAM,OAAO;GAG5B,MAAM,YAAY,cAAc,YAAY,KAAK;AAGjD,QAAK,MAAM,CAAC,KAAK,UAAU,IAAI,OAAO,QAAQ,OAAO,CACpD,KAAI,KAAK,YAAY,UAAU,CAC9B,YAAW,KAAK;IACf;IACA,MAAM,YAAU,IAAI;IACpB;IACA,MAAM;KACL,UAAU;KACV,UAAU,SAAS,QAAQ,KAAK,EAAE,KAAK;IACvC;IACD;GACA,EAAC;EAGJ,SAAQ,OAAO;GACf,MAAM,MAAM;AACZ,YAAO,OAAO,iBAAiB,EAAE,IAAI,IAAI,QAAQ,EAAE;AACnD,OAAI,IAAI,MACP,UAAO,MAAM,IAAI,MAAM;AAExB,SAAM;EACN;AAGF,SAAO;CACP;AACD;;;;;AC3GD,MAAM,SAAS;;;;;;;;AAef,SAAgB,aAAaC,OAAqC;AACjE,YAAW,UAAU,YAAY,UAAU,KAAM,QAAO;CAExD,MAAM,YAAY;AAElB,eACQ,UAAU,OAAO,YACxB,UAAU,GAAG,SAAS,YACf,UAAU,YAAY;AAE9B;;;;;;;;;AA2CD,eAAsB,SACrBC,SAC6B;CAC7B,MAAM,EACL,UACA,MAAM,QAAQ,KAAK,EACnB,YAAY,OACZ,SAAS,KACT,GAAG;AAIJ,KAAI,UAAW,yBAAwB;CAEvC,MAAMC,WAAwC,CAAE;;CAEhD,MAAMC,UAAkC,CAAE;;;;;;;;;;;;;;CAc1C,MAAM,uBAAO,IAAI;CAEjB,MAAM,QAAQ,MAAM,QAAQ,SAAS,GAAG,CAAC,GAAG,QAAS,IAAG,CAAC,QAAmB;CAC5E,MAAM,QAAQ,GAAG,OAAO,OAAO;EAAE;EAAK,UAAU;CAAM,EAAC;;CAGvD,IAAI,UAAU;AAEd,YAAW,MAAM,SAAS,OAAO;AAChC;EACA,MAAM,OAAO,MAAM,UAAU;EAC7B,MAAM,SAAS,OAAa,YAoG7B,QApG0C,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC,KAoGhE,OApGoE;AAEpE,OAAK,MAAM,CAAC,YAAY,SAAS,IAAI,OAAO,QAAQ,OAAO,EAAE;AAC5D,QAAK,aAAa,SAAS,CAAE;AAK7B,OAAI,KAAK,IAAI,SAAmB,CAAE;AAClC,QAAK,IAAI,SAAmB;AAE5B,QAAK,MAAM,eAAe,SAAS,SAAS,EAAE;IAG7C,MAAM,KAAK,YAAY,YAAY,GAAG;IACtC,MAAM,SAAS,SAAS,KAAK,KAAK;IAElC,MAAM,UAAU,QAAQ;AACxB,QAAI,sBAAyB,YAAY,OACxC,OAAM,IAAI,mBAAmB,IAAI,CAAC,SAAS,MAAO;AAGnD,aAAS,MAAM;KAAE,GAAG;KAAa;IAAI;AACrC,YAAQ,MAAM;AACd,QAAI,IAAK,KAAI,MAAM;KAAE;KAAM;IAAY;GACvC;EACD;CACD;AAID,mBAAkB,SAAS;AAE3B,oBAAmB,OAAO,SAAS,OAAO,KAAK,SAAS,CAAC,OAAO;AAEhE,QAAO;AACP;;;;;;;;;;;;;;;;;;AAmBD,SAAS,mBACRC,OACAC,SACAC,UACO;AACP,KAAI,MAAM,WAAW,EAAG;AAExB,KAAI,YAAY,GAAG;AAClB,SAAO,MACL,qFACgB,MAAM,KAAK,KAAK,CAAC,4JAKlC;AACD;CACA;AAED,KAAI,aAAa,EAChB,QAAO,MACL,oCAAoC,QAAQ,qDAE5B,MAAM,KAAK,KAAK,CAAC,sIAIlC;AAEF;;AAGD,IAAa,qBAAb,cAAwC,MAAM;;CAE7C,AAAS;;CAET,AAAS;CAET,YAAYC,IAAYC,SAA4B;AACnD,QAAM,qCAAqC;AAC3C,OAAK,OAAO;AACZ,OAAK,KAAK;AACV,OAAK,UAAU;CACf;AACD"}
@@ -0,0 +1,271 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const node_path = require_chunk.__toESM(require("node:path"));
3
+ const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
4
+ const fast_glob = require_chunk.__toESM(require("fast-glob"));
5
+ const lodash_kebabcase = require_chunk.__toESM(require("lodash.kebabcase"));
6
+
7
+ //#region src/types.ts
8
+ function isPartitionedRoutes(routes) {
9
+ return typeof routes === "object" && routes !== null && !Array.isArray(routes) && "paths" in routes;
10
+ }
11
+ /**
12
+ * The backend a project gets when it says nothing, by where it deploys.
13
+ *
14
+ * Flat defaults could not be right for both: `upstash` on a single box means a
15
+ * SaaS round-trip for a cache the database could have held, and `minio` on AWS
16
+ * means running a bucket beside S3. So the default is a function of the target,
17
+ * and an app that says nothing gets the obvious answer in both places — which
18
+ * is the whole of what "zero config" can mean once there is more than one
19
+ * target.
20
+ *
21
+ * `server` covers Dokploy and a bare host alike: the question these answer is
22
+ * whether the app is next to a managed cloud or next to its own containers, and
23
+ * on that question the two are the same.
24
+ *
25
+ * A per-construct, per-stage override is the layer above this — see
26
+ * `constructs-outstanding.md` — so two buckets in one app can differ. This is
27
+ * only what happens when nobody has said anything at all.
28
+ */
29
+ const DEFAULT_CACHE = {
30
+ aws: "upstash",
31
+ server: "db"
32
+ };
33
+ /** Where a bucket lives when nobody said — see {@link DEFAULT_CACHE}. */
34
+ const DEFAULT_STORAGE = {
35
+ aws: "s3",
36
+ server: "minio"
37
+ };
38
+ /**
39
+ * Who delivers mail when nobody said.
40
+ *
41
+ * Flat, unlike the others, and deliberately: mail is a SaaS on every target.
42
+ * There is no self-hosted preset to default a container deploy to — Mailpit is
43
+ * a development inbox, not a sender — so `server` has no answer of its own to
44
+ * give and would only be `ses` written twice.
45
+ */
46
+ const DEFAULT_EMAIL = "ses";
47
+
48
+ //#endregion
49
+ //#region src/generators/Generator.ts
50
+ /**
51
+ * Zod v4 maintains a process-wide registry of schemas registered via
52
+ * `.meta({ id })`. When we cache-bust user module imports (by appending a
53
+ * `?t=timestamp` query), those modules re-execute and try to register the
54
+ * same ids again, which throws `ID X already exists in the registry`.
55
+ *
56
+ * Clearing the registry in the CLI process is safe: the user's running
57
+ * server lives in a subprocess and has its own isolated registry.
58
+ *
59
+ * Exported for tests.
60
+ */
61
+ function clearZodGlobalRegistry() {
62
+ const registry = globalThis.__zod_globalRegistry;
63
+ if (registry && typeof registry.clear === "function") registry.clear();
64
+ }
65
+ var ConstructGenerator = class {
66
+ static async build(context, outputDir, generator, patterns, options) {
67
+ const constructs = await generator.load(patterns);
68
+ return generator.build(context, constructs, outputDir, options);
69
+ }
70
+ async load(patterns, cwd = process.cwd(), bustCache = false) {
71
+ const logger$1 = console;
72
+ let globPatterns;
73
+ let partitionFn;
74
+ if (isPartitionedRoutes(patterns)) {
75
+ globPatterns = Array.isArray(patterns.paths) ? patterns.paths : [patterns.paths];
76
+ partitionFn = patterns.partition;
77
+ } else globPatterns = Array.isArray(patterns) ? patterns : patterns ? [patterns] : [];
78
+ const files = fast_glob.default.stream(globPatterns, {
79
+ cwd,
80
+ absolute: true
81
+ });
82
+ if (bustCache) clearZodGlobalRegistry();
83
+ const constructs = [];
84
+ for await (const f of files) try {
85
+ const file = f.toString();
86
+ const importPath = bustCache ? `${file}?t=${Date.now()}` : file;
87
+ const module$1 = await import(importPath);
88
+ const partition = partitionFn ? partitionFn(file) : void 0;
89
+ for (const [key, construct] of Object.entries(module$1)) if (this.isConstruct(construct)) constructs.push({
90
+ key,
91
+ name: (0, lodash_kebabcase.default)(key),
92
+ construct,
93
+ path: {
94
+ absolute: file,
95
+ relative: (0, node_path.relative)(process.cwd(), file)
96
+ },
97
+ partition
98
+ });
99
+ } catch (error) {
100
+ const err = error;
101
+ logger$1.error(`Failed to load ${f}: ${err.message}`);
102
+ if (err.stack) logger$1.error(err.stack);
103
+ throw error;
104
+ }
105
+ return constructs;
106
+ }
107
+ };
108
+
109
+ //#endregion
110
+ //#region src/reconcile/discover.ts
111
+ /** Matches the rest of the CLI, which logs through `console` directly. */
112
+ const logger = console;
113
+ /**
114
+ * Whether a module export is a construct.
115
+ *
116
+ * Deliberately loose about what else it carries — a construct that also has a
117
+ * `service` is still a construct, and requiring one would exclude the kinds that
118
+ * own no address.
119
+ */
120
+ function isDeclarable(value) {
121
+ if (typeof value !== "object" || value === null) return false;
122
+ const candidate = value;
123
+ return typeof candidate.id === "string" && candidate.id.length > 0 && typeof candidate.declare === "function";
124
+ }
125
+ /**
126
+ * Build the construct manifest for a project.
127
+ *
128
+ * Runs the manifest's own validation before returning, so an app is wrong here
129
+ * — where the error names a file — rather than at deploy.
130
+ *
131
+ * @throws {DuplicateConstruct} when two exports claim one id.
132
+ */
133
+ async function discover(options) {
134
+ const { patterns, cwd = process.cwd(), bustCache = false, sources: out } = options;
135
+ if (bustCache) clearZodGlobalRegistry();
136
+ const manifest = {};
137
+ /** Which file declared each id, for the error when two of them do. */
138
+ const sources = {};
139
+ /**
140
+ * Constructs already seen, by identity.
141
+ *
142
+ * A re-export is the *same object* reached through a second file — ESM
143
+ * bindings are live, so `export * from './database.js'` hands back the
144
+ * binding rather than a copy. Without this, a barrel file made every
145
+ * construct in it appear declared twice, and `constructs/index.ts` is the
146
+ * first thing anyone writes in a shared folder.
147
+ *
148
+ * Identity rather than file is also the more honest rule: what may not
149
+ * happen twice is two *different* constructs claiming one id, and that is
150
+ * still an error below.
151
+ */
152
+ const seen = /* @__PURE__ */ new WeakSet();
153
+ const globs = Array.isArray(patterns) ? [...patterns] : [patterns];
154
+ const files = fast_glob.default.stream(globs, {
155
+ cwd,
156
+ absolute: true
157
+ });
158
+ /** Matched files, for the diagnostic below. */
159
+ let matched = 0;
160
+ for await (const found of files) {
161
+ matched++;
162
+ const file = found.toString();
163
+ const module$1 = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
164
+ for (const [exportName, exported] of Object.entries(module$1)) {
165
+ if (!isDeclarable(exported)) continue;
166
+ if (seen.has(exported)) continue;
167
+ seen.add(exported);
168
+ for (const declaration of exported.declare()) {
169
+ const id = (0, __geekmidas_manifest.canonicalId)(declaration.id);
170
+ const source = (0, node_path.relative)(cwd, file);
171
+ const claimed = sources[id];
172
+ if (claimed !== void 0 && claimed !== source) throw new DuplicateConstruct(id, [claimed, source]);
173
+ manifest[id] = {
174
+ ...declaration,
175
+ id
176
+ };
177
+ sources[id] = source;
178
+ if (out) out[id] = {
179
+ file,
180
+ exportName
181
+ };
182
+ }
183
+ }
184
+ }
185
+ (0, __geekmidas_manifest.assertDerivations)(manifest);
186
+ warnIfNothingFound(globs, matched, Object.keys(manifest).length);
187
+ return manifest;
188
+ }
189
+ /**
190
+ * Say so when a glob was configured and found nothing.
191
+ *
192
+ * The glob is not a filter over declarations already known — it is *how they
193
+ * are found*, by importing what it matches. So a file it misses is a
194
+ * declaration that does not exist, and every symptom of that appears somewhere
195
+ * other than the cause: no container starts, no env key is written, and the
196
+ * application fails on first use against a resource it can see in its own
197
+ * source.
198
+ *
199
+ * Nothing reported it before, because an unmatched file is indistinguishable
200
+ * from a file nobody wrote. These two cases are the ones that are *not*
201
+ * ambiguous — a glob was configured, so something was expected.
202
+ *
203
+ * Silent when no glob is configured at all: that is a project which has not
204
+ * adopted constructs, and has nothing to be missing.
205
+ */
206
+ function warnIfNothingFound(globs, matched, declared) {
207
+ if (globs.length === 0) return;
208
+ if (matched === 0) {
209
+ logger.warn(`\n⚠️ The constructs glob matched no files, so nothing was declared.\n Patterns: ${globs.join(", ")}\n Nothing will be provisioned — no containers, no env keys, no resources.\n A common cause is depth: '*.ts' matches one level, '**/*.ts' matches any.`);
210
+ return;
211
+ }
212
+ if (declared === 0) logger.warn(`\n⚠️ The constructs glob matched ${matched} file(s) but none declared anything.\n Patterns: ${globs.join(", ")}\n Discovery keeps exports with an 'id' that can 'declare()'. A construct that is\n built but never exported is invisible to it.`);
213
+ }
214
+ /** Two constructs claiming one id. */
215
+ var DuplicateConstruct = class extends Error {
216
+ /** The id claimed twice. */
217
+ id;
218
+ /** The files that claimed it. */
219
+ sources;
220
+ constructor(id, sources) {
221
+ super("Two constructs declare the same id");
222
+ this.name = "DuplicateConstruct";
223
+ this.id = id;
224
+ this.sources = sources;
225
+ }
226
+ };
227
+
228
+ //#endregion
229
+ Object.defineProperty(exports, 'ConstructGenerator', {
230
+ enumerable: true,
231
+ get: function () {
232
+ return ConstructGenerator;
233
+ }
234
+ });
235
+ Object.defineProperty(exports, 'DEFAULT_CACHE', {
236
+ enumerable: true,
237
+ get: function () {
238
+ return DEFAULT_CACHE;
239
+ }
240
+ });
241
+ Object.defineProperty(exports, 'DEFAULT_EMAIL', {
242
+ enumerable: true,
243
+ get: function () {
244
+ return DEFAULT_EMAIL;
245
+ }
246
+ });
247
+ Object.defineProperty(exports, 'DEFAULT_STORAGE', {
248
+ enumerable: true,
249
+ get: function () {
250
+ return DEFAULT_STORAGE;
251
+ }
252
+ });
253
+ Object.defineProperty(exports, 'discover', {
254
+ enumerable: true,
255
+ get: function () {
256
+ return discover;
257
+ }
258
+ });
259
+ Object.defineProperty(exports, 'isDeclarable', {
260
+ enumerable: true,
261
+ get: function () {
262
+ return isDeclarable;
263
+ }
264
+ });
265
+ Object.defineProperty(exports, 'isPartitionedRoutes', {
266
+ enumerable: true,
267
+ get: function () {
268
+ return isPartitionedRoutes;
269
+ }
270
+ });
271
+ //# sourceMappingURL=discover-DTmFeloL.cjs.map