@geekmidas/cli 10.0.0-alpha.10 → 10.0.0-alpha.100

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 (489) hide show
  1. package/README.md +315 -414
  2. package/bin/adjacent-tsconfig.mjs +46 -8
  3. package/bin/gkm.mjs +11 -3
  4. package/bin/owning-tsconfig-jsx-register.mjs +18 -0
  5. package/bin/owning-tsconfig-jsx.mjs +108 -0
  6. package/dist/EndpointGenerator-Br97xgs_.mjs +1031 -0
  7. package/dist/EndpointGenerator-Br97xgs_.mjs.map +1 -0
  8. package/dist/EndpointGenerator-By5_tYE9.cjs +1090 -0
  9. package/dist/EndpointGenerator-By5_tYE9.cjs.map +1 -0
  10. package/dist/GoDaddyProvider-CVnzcWX5.mjs +388 -0
  11. package/dist/GoDaddyProvider-CVnzcWX5.mjs.map +1 -0
  12. package/dist/GoDaddyProvider-DS4Wgu0c.cjs +388 -0
  13. package/dist/GoDaddyProvider-DS4Wgu0c.cjs.map +1 -0
  14. package/dist/{HostingerProvider-Cft7lEYr.mjs → HostingerProvider-BNpS9aRJ.mjs} +29 -25
  15. package/dist/HostingerProvider-BNpS9aRJ.mjs.map +1 -0
  16. package/dist/{HostingerProvider-h3EbEp-Z.cjs → HostingerProvider-DR1iws1P.cjs} +29 -25
  17. package/dist/HostingerProvider-DR1iws1P.cjs.map +1 -0
  18. package/dist/LegacyStateStore-C2Xlqy4v.mjs +124 -0
  19. package/dist/LegacyStateStore-C2Xlqy4v.mjs.map +1 -0
  20. package/dist/LegacyStateStore-CoHPQMLO.cjs +124 -0
  21. package/dist/LegacyStateStore-CoHPQMLO.cjs.map +1 -0
  22. package/dist/LocalStateStore-BGDzf2f8.cjs +178 -0
  23. package/dist/LocalStateStore-BGDzf2f8.cjs.map +1 -0
  24. package/dist/LocalStateStore-By59pUve.mjs +167 -0
  25. package/dist/LocalStateStore-By59pUve.mjs.map +1 -0
  26. package/dist/OpenApiTsGenerator-BgSX_Z-e.cjs +541 -0
  27. package/dist/OpenApiTsGenerator-BgSX_Z-e.cjs.map +1 -0
  28. package/dist/OpenApiTsGenerator-C8aTX--y.mjs +536 -0
  29. package/dist/OpenApiTsGenerator-C8aTX--y.mjs.map +1 -0
  30. package/dist/{Route53Provider-di2fMM5N.cjs → Route53Provider-Bllus2NR.cjs} +21 -22
  31. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  32. package/dist/{Route53Provider-RdpUDJQk.mjs → Route53Provider-QXxjkZO1.mjs} +13 -13
  33. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  34. package/dist/S3StateStore-CU485pYn.mjs +223 -0
  35. package/dist/S3StateStore-CU485pYn.mjs.map +1 -0
  36. package/dist/S3StateStore-Re4LfDTl.cjs +222 -0
  37. package/dist/S3StateStore-Re4LfDTl.cjs.map +1 -0
  38. package/dist/SSMStateStore-BquRBbUG.mjs +205 -0
  39. package/dist/SSMStateStore-BquRBbUG.mjs.map +1 -0
  40. package/dist/SSMStateStore-CLX4Dm5d.cjs +204 -0
  41. package/dist/SSMStateStore-CLX4Dm5d.cjs.map +1 -0
  42. package/dist/SubscriberGenerator-1-IsjIwF.mjs +449 -0
  43. package/dist/SubscriberGenerator-1-IsjIwF.mjs.map +1 -0
  44. package/dist/SubscriberGenerator-BlIOdbi-.cjs +490 -0
  45. package/dist/SubscriberGenerator-BlIOdbi-.cjs.map +1 -0
  46. package/dist/add-Blv6Q_YA.mjs +718 -0
  47. package/dist/add-Blv6Q_YA.mjs.map +1 -0
  48. package/dist/add-C6RhiCBX.cjs +720 -0
  49. package/dist/add-C6RhiCBX.cjs.map +1 -0
  50. package/dist/appPorts-C9z9Pzn9.mjs +223 -0
  51. package/dist/appPorts-C9z9Pzn9.mjs.map +1 -0
  52. package/dist/appPorts-Cu79hJF6.cjs +264 -0
  53. package/dist/appPorts-Cu79hJF6.cjs.map +1 -0
  54. package/dist/aws-8QQ8n-t6.mjs +89 -0
  55. package/dist/aws-8QQ8n-t6.mjs.map +1 -0
  56. package/dist/aws-DY9NqQIT.cjs +100 -0
  57. package/dist/aws-DY9NqQIT.cjs.map +1 -0
  58. package/dist/awsStore-Bx5nCFnS.mjs +121 -0
  59. package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
  60. package/dist/awsStore-u3ehhMoY.cjs +138 -0
  61. package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
  62. package/dist/{backup-provisioner-Bgj5Vi_L.mjs → backup-provisioner-C8DnCmxK.mjs} +11 -8
  63. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  64. package/dist/{backup-provisioner-BrsHwYG0.cjs → backup-provisioner-oDEsPj02.cjs} +22 -20
  65. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  66. package/dist/backups/runner.cjs +519 -0
  67. package/dist/backups/runner.cjs.map +1 -0
  68. package/dist/backups/runner.d.cts +102 -0
  69. package/dist/backups/runner.d.cts.map +1 -0
  70. package/dist/backups/runner.d.mts +102 -0
  71. package/dist/backups/runner.d.mts.map +1 -0
  72. package/dist/backups/runner.mjs +506 -0
  73. package/dist/backups/runner.mjs.map +1 -0
  74. package/dist/{bundler-Be8Zg4Wd.mjs → bundler-Cquc0e8N.mjs} +36 -32
  75. package/dist/bundler-Cquc0e8N.mjs.map +1 -0
  76. package/dist/{bundler-BY1OmV1e.cjs → bundler-DAeBIOlG.cjs} +38 -35
  77. package/dist/bundler-DAeBIOlG.cjs.map +1 -0
  78. package/dist/cli-DbeqYBTs.cjs +71 -0
  79. package/dist/cli-DbeqYBTs.cjs.map +1 -0
  80. package/dist/cli-tWfeiYmO.mjs +71 -0
  81. package/dist/cli-tWfeiYmO.mjs.map +1 -0
  82. package/dist/compose-BftbEv0b.mjs +3154 -0
  83. package/dist/compose-BftbEv0b.mjs.map +1 -0
  84. package/dist/compose-C_mfrSVH.cjs +3267 -0
  85. package/dist/compose-C_mfrSVH.cjs.map +1 -0
  86. package/dist/config-D48erO2j.d.mts +269 -0
  87. package/dist/config-D48erO2j.d.mts.map +1 -0
  88. package/dist/config-DHDtsQrB.d.cts +269 -0
  89. package/dist/config-DHDtsQrB.d.cts.map +1 -0
  90. package/dist/config.cjs +421 -11
  91. package/dist/config.cjs.map +1 -0
  92. package/dist/config.d.cts +4 -120
  93. package/dist/config.d.mts +4 -120
  94. package/dist/config.mjs +405 -4
  95. package/dist/config.mjs.map +1 -0
  96. package/dist/credentialSchemas-DDda4Mmm.cjs +272 -0
  97. package/dist/credentialSchemas-DDda4Mmm.cjs.map +1 -0
  98. package/dist/credentialSchemas-DvitraL-.mjs +237 -0
  99. package/dist/credentialSchemas-DvitraL-.mjs.map +1 -0
  100. package/dist/credentials-B5N5yKk6.mjs +267 -0
  101. package/dist/credentials-B5N5yKk6.mjs.map +1 -0
  102. package/dist/credentials-Zqr3QQYB.cjs +350 -0
  103. package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
  104. package/dist/databases-BeGP5eDh.mjs +495 -0
  105. package/dist/databases-BeGP5eDh.mjs.map +1 -0
  106. package/dist/databases-DGALFDG3.cjs +598 -0
  107. package/dist/databases-DGALFDG3.cjs.map +1 -0
  108. package/dist/define-6poNqm5O.mjs +106 -0
  109. package/dist/define-6poNqm5O.mjs.map +1 -0
  110. package/dist/define-crmMcXFS.cjs +153 -0
  111. package/dist/define-crmMcXFS.cjs.map +1 -0
  112. package/dist/deploy/public.cjs +212 -0
  113. package/dist/deploy/public.cjs.map +1 -0
  114. package/dist/deploy/public.d.cts +653 -0
  115. package/dist/deploy/public.d.cts.map +1 -0
  116. package/dist/deploy/public.d.mts +653 -0
  117. package/dist/deploy/public.d.mts.map +1 -0
  118. package/dist/deploy/public.mjs +145 -0
  119. package/dist/deploy/public.mjs.map +1 -0
  120. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  121. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  122. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  123. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  124. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  125. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  126. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  127. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  128. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  129. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  130. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  131. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  132. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  133. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  134. package/dist/deploy/sniffer-hooks.cjs +13 -7
  135. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  136. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  137. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  138. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  139. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  140. package/dist/deploy/sniffer-hooks.mjs +10 -3
  141. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  142. package/dist/deploy/sniffer-loader.cjs +16 -7
  143. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  144. package/dist/deploy/sniffer-loader.d.cts +1 -1
  145. package/dist/deploy/sniffer-loader.d.mts +1 -1
  146. package/dist/deploy/sniffer-loader.mjs +14 -3
  147. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  148. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  149. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  150. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  151. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  152. package/dist/deploy/sniffer-routes-worker.mjs +4 -4
  153. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  154. package/dist/deploy/sniffer-worker.cjs +15 -6
  155. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  156. package/dist/deploy/sniffer-worker.d.cts +1 -3
  157. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  158. package/dist/deploy/sniffer-worker.d.mts +1 -3
  159. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  160. package/dist/deploy/sniffer-worker.mjs +15 -4
  161. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  162. package/dist/deploy-BSilGXuR.mjs +2317 -0
  163. package/dist/deploy-BSilGXuR.mjs.map +1 -0
  164. package/dist/deploy-CktQpmpU.cjs +2390 -0
  165. package/dist/deploy-CktQpmpU.cjs.map +1 -0
  166. package/dist/derive-B4vDpzgP.mjs +150 -0
  167. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  168. package/dist/derive-DAbo49sm.cjs +161 -0
  169. package/dist/derive-DAbo49sm.cjs.map +1 -0
  170. package/dist/discover-BfhVW_kT.cjs +600 -0
  171. package/dist/discover-BfhVW_kT.cjs.map +1 -0
  172. package/dist/discover-CvTtV5ZD.d.cts +108 -0
  173. package/dist/discover-CvTtV5ZD.d.cts.map +1 -0
  174. package/dist/discover-W2kab9Lc.d.mts +108 -0
  175. package/dist/discover-W2kab9Lc.d.mts.map +1 -0
  176. package/dist/discover-kziEht4W.mjs +527 -0
  177. package/dist/discover-kziEht4W.mjs.map +1 -0
  178. package/dist/dns-CQZQL3gj.mjs +926 -0
  179. package/dist/dns-CQZQL3gj.mjs.map +1 -0
  180. package/dist/dns-KPxvcCdL.cjs +1057 -0
  181. package/dist/dns-KPxvcCdL.cjs.map +1 -0
  182. package/dist/dokploy-B7eMa6Pa.cjs +38 -0
  183. package/dist/dokploy-B7eMa6Pa.cjs.map +1 -0
  184. package/dist/dokploy-Dguhz3Uo.mjs +38 -0
  185. package/dist/dokploy-Dguhz3Uo.mjs.map +1 -0
  186. package/dist/drivers-BLU1fNs_.cjs +200 -0
  187. package/dist/drivers-BLU1fNs_.cjs.map +1 -0
  188. package/dist/drivers-C08LL4E8.mjs +177 -0
  189. package/dist/drivers-C08LL4E8.mjs.map +1 -0
  190. package/dist/{emit-CiZS_5Ub.mjs → emit-C1e8qD08.mjs} +13 -26
  191. package/dist/emit-C1e8qD08.mjs.map +1 -0
  192. package/dist/{emit-CbcRolsa.cjs → emit-Dmc1nvdS.cjs} +31 -57
  193. package/dist/emit-Dmc1nvdS.cjs.map +1 -0
  194. package/dist/encryption-CixpDF6e.mjs +89 -0
  195. package/dist/encryption-CixpDF6e.mjs.map +1 -0
  196. package/dist/encryption-DrhCX7G6.cjs +90 -0
  197. package/dist/encryption-DrhCX7G6.cjs.map +1 -0
  198. package/dist/engine-32gL2ju3.mjs +3082 -0
  199. package/dist/engine-32gL2ju3.mjs.map +1 -0
  200. package/dist/engine-CQgycl7o.cjs +3195 -0
  201. package/dist/engine-CQgycl7o.cjs.map +1 -0
  202. package/dist/errors-D8Gwp5kU.mjs +23 -0
  203. package/dist/errors-D8Gwp5kU.mjs.map +1 -0
  204. package/dist/errors-DMC4Umsb.cjs +34 -0
  205. package/dist/errors-DMC4Umsb.cjs.map +1 -0
  206. package/dist/github-DYQ5wvod.mjs +829 -0
  207. package/dist/github-DYQ5wvod.mjs.map +1 -0
  208. package/dist/github-DkSCUoWS.cjs +829 -0
  209. package/dist/github-DkSCUoWS.cjs.map +1 -0
  210. package/dist/identity-CBXr4wNi.mjs +129 -0
  211. package/dist/identity-CBXr4wNi.mjs.map +1 -0
  212. package/dist/identity-CbLfgQNT.cjs +182 -0
  213. package/dist/identity-CbLfgQNT.cjs.map +1 -0
  214. package/dist/{index-C6e-ULLx.d.mts → index-8OfpOtSI.d.cts} +39 -24
  215. package/dist/index-8OfpOtSI.d.cts.map +1 -0
  216. package/dist/{index-CR5urhWX.d.cts → index-Dpji6Bxq.d.mts} +39 -24
  217. package/dist/index-Dpji6Bxq.d.mts.map +1 -0
  218. package/dist/index.cjs +10022 -12718
  219. package/dist/index.cjs.map +1 -1
  220. package/dist/index.d.cts +1 -1
  221. package/dist/index.d.mts +1 -1
  222. package/dist/index.mjs +10648 -13356
  223. package/dist/index.mjs.map +1 -1
  224. package/dist/local-BwC2v2Y8.mjs +224 -0
  225. package/dist/local-BwC2v2Y8.mjs.map +1 -0
  226. package/dist/local-DNhnkugT.cjs +241 -0
  227. package/dist/local-DNhnkugT.cjs.map +1 -0
  228. package/dist/migrate-BoJxKbfR.mjs +181 -0
  229. package/dist/migrate-BoJxKbfR.mjs.map +1 -0
  230. package/dist/migrate-CJTyeBul.cjs +271 -0
  231. package/dist/migrate-CJTyeBul.cjs.map +1 -0
  232. package/dist/migrate-CxmkvMbw.mjs +266 -0
  233. package/dist/migrate-CxmkvMbw.mjs.map +1 -0
  234. package/dist/migrate-ISBZNDKU.cjs +181 -0
  235. package/dist/migrate-ISBZNDKU.cjs.map +1 -0
  236. package/dist/openapi.cjs +214 -10
  237. package/dist/openapi.cjs.map +1 -0
  238. package/dist/openapi.d.cts +38 -17
  239. package/dist/openapi.d.cts.map +1 -1
  240. package/dist/openapi.d.mts +38 -17
  241. package/dist/openapi.d.mts.map +1 -1
  242. package/dist/openapi.mjs +208 -5
  243. package/dist/openapi.mjs.map +1 -0
  244. package/dist/projectBucket-BBbQ1lHF.cjs +263 -0
  245. package/dist/projectBucket-BBbQ1lHF.cjs.map +1 -0
  246. package/dist/projectBucket-C_DN4WzF.mjs +222 -0
  247. package/dist/projectBucket-C_DN4WzF.mjs.map +1 -0
  248. package/dist/provider-BqpjG9QM.cjs +57 -0
  249. package/dist/provider-BqpjG9QM.cjs.map +1 -0
  250. package/dist/provider-CEOKk8NS.mjs +46 -0
  251. package/dist/provider-CEOKk8NS.mjs.map +1 -0
  252. package/dist/ready-BtxiI7Qb.cjs +403 -0
  253. package/dist/ready-BtxiI7Qb.cjs.map +1 -0
  254. package/dist/ready-CzHNHhI6.mjs +374 -0
  255. package/dist/ready-CzHNHhI6.mjs.map +1 -0
  256. package/dist/reconcile/public.cjs +3 -5
  257. package/dist/reconcile/public.d.cts +11 -87
  258. package/dist/reconcile/public.d.cts.map +1 -1
  259. package/dist/reconcile/public.d.mts +11 -87
  260. package/dist/reconcile/public.d.mts.map +1 -1
  261. package/dist/reconcile/public.mjs +3 -4
  262. package/dist/{reconcile-CFs8C_1a.mjs → reconcile--I7V4Klj.mjs} +4 -7
  263. package/dist/reconcile--I7V4Klj.mjs.map +1 -0
  264. package/dist/{reconcile-D0pimNiy.cjs → reconcile-CuCQBa5-.cjs} +5 -8
  265. package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
  266. package/dist/resolve-Bei6BMbw.mjs +263 -0
  267. package/dist/resolve-Bei6BMbw.mjs.map +1 -0
  268. package/dist/resolve-qm7FrBj_.cjs +316 -0
  269. package/dist/resolve-qm7FrBj_.cjs.map +1 -0
  270. package/dist/rollback-BJ3H4kQ8.mjs +136 -0
  271. package/dist/rollback-BJ3H4kQ8.mjs.map +1 -0
  272. package/dist/rollback-Bt4xRXtq.cjs +165 -0
  273. package/dist/rollback-Bt4xRXtq.cjs.map +1 -0
  274. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  275. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  276. package/dist/run-BJLIerMM.mjs +133 -0
  277. package/dist/run-BJLIerMM.mjs.map +1 -0
  278. package/dist/run-fVZ-rLnc.cjs +174 -0
  279. package/dist/run-fVZ-rLnc.cjs.map +1 -0
  280. package/dist/runtime-ACdfK59n.d.cts +82 -0
  281. package/dist/runtime-ACdfK59n.d.cts.map +1 -0
  282. package/dist/runtime-YyQuekxi.d.mts +82 -0
  283. package/dist/runtime-YyQuekxi.d.mts.map +1 -0
  284. package/dist/s3-CrPoA89T.cjs +215 -0
  285. package/dist/s3-CrPoA89T.cjs.map +1 -0
  286. package/dist/s3-DQXZdmCM.mjs +215 -0
  287. package/dist/s3-DQXZdmCM.mjs.map +1 -0
  288. package/dist/sandbox/config-worker.cjs +43 -0
  289. package/dist/sandbox/config-worker.cjs.map +1 -0
  290. package/dist/sandbox/config-worker.d.cts +1 -0
  291. package/dist/sandbox/config-worker.d.mts +1 -0
  292. package/dist/sandbox/config-worker.mjs +44 -0
  293. package/dist/sandbox/config-worker.mjs.map +1 -0
  294. package/dist/sandbox/credentials-worker.cjs +54 -0
  295. package/dist/sandbox/credentials-worker.cjs.map +1 -0
  296. package/dist/sandbox/credentials-worker.d.cts +1 -0
  297. package/dist/sandbox/credentials-worker.d.mts +1 -0
  298. package/dist/sandbox/credentials-worker.mjs +55 -0
  299. package/dist/sandbox/credentials-worker.mjs.map +1 -0
  300. package/dist/sandbox/discover-worker.cjs +47 -0
  301. package/dist/sandbox/discover-worker.cjs.map +1 -0
  302. package/dist/sandbox/discover-worker.d.cts +1 -0
  303. package/dist/sandbox/discover-worker.d.mts +1 -0
  304. package/dist/sandbox/discover-worker.mjs +48 -0
  305. package/dist/sandbox/discover-worker.mjs.map +1 -0
  306. package/dist/sandbox/migrate-worker.cjs +75 -0
  307. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  308. package/dist/sandbox/migrate-worker.d.cts +1 -0
  309. package/dist/sandbox/migrate-worker.d.mts +1 -0
  310. package/dist/sandbox/migrate-worker.mjs +76 -0
  311. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  312. package/dist/sandbox-C4g1eG31.d.mts +104 -0
  313. package/dist/sandbox-C4g1eG31.d.mts.map +1 -0
  314. package/dist/sandbox-CHv3OYXg.cjs +165 -0
  315. package/dist/sandbox-CHv3OYXg.cjs.map +1 -0
  316. package/dist/sandbox-CbVB7uOD.mjs +118 -0
  317. package/dist/sandbox-CbVB7uOD.mjs.map +1 -0
  318. package/dist/sandbox-CdKgQ3XU.d.cts +104 -0
  319. package/dist/sandbox-CdKgQ3XU.d.cts.map +1 -0
  320. package/dist/{workspace-C6VJQVtG.cjs → schemas-BCwKKA42.mjs} +958 -1842
  321. package/dist/schemas-BCwKKA42.mjs.map +1 -0
  322. package/dist/{workspace-zoqRbihZ.mjs → schemas-BQ_v0lEX.cjs} +1048 -1658
  323. package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
  324. package/dist/secretsManager-CQORubp9.mjs +97 -0
  325. package/dist/secretsManager-CQORubp9.mjs.map +1 -0
  326. package/dist/secretsManager-RAGcEDX1.cjs +108 -0
  327. package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
  328. package/dist/seeds-CHIPcMrY.cjs +9115 -0
  329. package/dist/seeds-CHIPcMrY.cjs.map +1 -0
  330. package/dist/seeds-E4nUeXTl.mjs +8148 -0
  331. package/dist/seeds-E4nUeXTl.mjs.map +1 -0
  332. package/dist/sniffer-bUiSXLMj.mjs +1825 -0
  333. package/dist/sniffer-bUiSXLMj.mjs.map +1 -0
  334. package/dist/sniffer-n3TkX6JD.cjs +1998 -0
  335. package/dist/sniffer-n3TkX6JD.cjs.map +1 -0
  336. package/dist/sst-B-Uz4cvm.cjs +464 -0
  337. package/dist/sst-B-Uz4cvm.cjs.map +1 -0
  338. package/dist/sst-C1pxbFEd.mjs +441 -0
  339. package/dist/sst-C1pxbFEd.mjs.map +1 -0
  340. package/dist/stages-DJrOYLZ-.mjs +176 -0
  341. package/dist/stages-DJrOYLZ-.mjs.map +1 -0
  342. package/dist/stages-_3RVNG83.cjs +176 -0
  343. package/dist/stages-_3RVNG83.cjs.map +1 -0
  344. package/dist/target/public.cjs +15 -0
  345. package/dist/target/public.d.cts +28 -0
  346. package/dist/target/public.d.cts.map +1 -0
  347. package/dist/target/public.d.mts +28 -0
  348. package/dist/target/public.d.mts.map +1 -0
  349. package/dist/target/public.mjs +4 -0
  350. package/dist/terminal-Bs_lNQhL.mjs +85 -0
  351. package/dist/terminal-Bs_lNQhL.mjs.map +1 -0
  352. package/dist/terminal-CsQz4oT0.cjs +85 -0
  353. package/dist/terminal-CsQz4oT0.cjs.map +1 -0
  354. package/dist/types-B6UXlEkf.d.cts +7650 -0
  355. package/dist/types-B6UXlEkf.d.cts.map +1 -0
  356. package/dist/types-HqVPddRK.d.mts +7649 -0
  357. package/dist/types-HqVPddRK.d.mts.map +1 -0
  358. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  359. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  360. package/dist/utils-D_fxUqvU.mjs +156 -0
  361. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  362. package/dist/vitest.cjs +65 -0
  363. package/dist/vitest.cjs.map +1 -0
  364. package/dist/vitest.d.cts +29 -0
  365. package/dist/vitest.d.cts.map +1 -0
  366. package/dist/vitest.d.mts +29 -0
  367. package/dist/vitest.d.mts.map +1 -0
  368. package/dist/vitest.mjs +65 -0
  369. package/dist/vitest.mjs.map +1 -0
  370. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  371. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  372. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  373. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  374. package/dist/workspace/index.cjs +8 -4
  375. package/dist/workspace/index.d.cts +3 -3
  376. package/dist/workspace/index.d.mts +3 -3
  377. package/dist/workspace/index.mjs +2 -3
  378. package/dist/workspace-BwqQnool.cjs +2806 -0
  379. package/dist/workspace-BwqQnool.cjs.map +1 -0
  380. package/dist/workspace-D1QbNd55.mjs +2394 -0
  381. package/dist/workspace-D1QbNd55.mjs.map +1 -0
  382. package/package.json +54 -22
  383. package/dist/CachedStateProvider-BLo7zv7S.cjs +0 -3
  384. package/dist/CachedStateProvider-BxoAm-B2.mjs +0 -3
  385. package/dist/CachedStateProvider-CqPdW7CB.cjs +0 -60
  386. package/dist/CachedStateProvider-CqPdW7CB.cjs.map +0 -1
  387. package/dist/CachedStateProvider-DTniehMP.mjs +0 -54
  388. package/dist/CachedStateProvider-DTniehMP.mjs.map +0 -1
  389. package/dist/HostingerProvider-Cft7lEYr.mjs.map +0 -1
  390. package/dist/HostingerProvider-h3EbEp-Z.cjs.map +0 -1
  391. package/dist/LocalStateProvider-Bn6tS-oL.mjs +0 -42
  392. package/dist/LocalStateProvider-Bn6tS-oL.mjs.map +0 -1
  393. package/dist/LocalStateProvider-Db9SEjyH.cjs +0 -43
  394. package/dist/LocalStateProvider-Db9SEjyH.cjs.map +0 -1
  395. package/dist/Route53Provider-RdpUDJQk.mjs.map +0 -1
  396. package/dist/Route53Provider-di2fMM5N.cjs.map +0 -1
  397. package/dist/SSMStateProvider-BRt2py-A.mjs +0 -66
  398. package/dist/SSMStateProvider-BRt2py-A.mjs.map +0 -1
  399. package/dist/SSMStateProvider-DyX8s9HI.cjs +0 -66
  400. package/dist/SSMStateProvider-DyX8s9HI.cjs.map +0 -1
  401. package/dist/backup-provisioner-Bgj5Vi_L.mjs.map +0 -1
  402. package/dist/backup-provisioner-BrsHwYG0.cjs.map +0 -1
  403. package/dist/bundler-BY1OmV1e.cjs.map +0 -1
  404. package/dist/bundler-Be8Zg4Wd.mjs.map +0 -1
  405. package/dist/chunk-Duj1WY3L.mjs +0 -7
  406. package/dist/config-BZ1F0WuA.cjs +0 -462
  407. package/dist/config-BZ1F0WuA.cjs.map +0 -1
  408. package/dist/config-DVVph9yz.mjs +0 -402
  409. package/dist/config-DVVph9yz.mjs.map +0 -1
  410. package/dist/config.d.cts.map +0 -1
  411. package/dist/config.d.mts.map +0 -1
  412. package/dist/credentials-B5zRHdAl.mjs +0 -141
  413. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  414. package/dist/credentials-BapzjyV5.cjs +0 -195
  415. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  416. package/dist/credentials-Xamqe_NJ.cjs +0 -2681
  417. package/dist/credentials-Xamqe_NJ.cjs.map +0 -1
  418. package/dist/credentials-dP8vRVRv.mjs +0 -2549
  419. package/dist/credentials-dP8vRVRv.mjs.map +0 -1
  420. package/dist/discover-CAlFgYec.mjs +0 -229
  421. package/dist/discover-CAlFgYec.mjs.map +0 -1
  422. package/dist/discover-DTmFeloL.cjs +0 -271
  423. package/dist/discover-DTmFeloL.cjs.map +0 -1
  424. package/dist/dokploy-api-BS2xnJLZ.mjs +0 -3
  425. package/dist/dokploy-api-BsVH0y_s.cjs +0 -718
  426. package/dist/dokploy-api-BsVH0y_s.cjs.map +0 -1
  427. package/dist/dokploy-api-BuxDRo3l.cjs +0 -3
  428. package/dist/dokploy-api-aTFPz7_4.mjs +0 -706
  429. package/dist/dokploy-api-aTFPz7_4.mjs.map +0 -1
  430. package/dist/emit-CbcRolsa.cjs.map +0 -1
  431. package/dist/emit-CiZS_5Ub.mjs.map +0 -1
  432. package/dist/encryption-C6jaU0hE.cjs +0 -54
  433. package/dist/encryption-C6jaU0hE.cjs.map +0 -1
  434. package/dist/encryption-CHzzeR8a.cjs +0 -4
  435. package/dist/encryption-CQUncu7v.mjs +0 -3
  436. package/dist/encryption-D-abyhZx.mjs +0 -42
  437. package/dist/encryption-D-abyhZx.mjs.map +0 -1
  438. package/dist/fullstack-secrets-C-GGohke.cjs +0 -111
  439. package/dist/fullstack-secrets-C-GGohke.cjs.map +0 -1
  440. package/dist/fullstack-secrets-D1o9-G5l.mjs +0 -87
  441. package/dist/fullstack-secrets-D1o9-G5l.mjs.map +0 -1
  442. package/dist/generator-CNzBw7g5.cjs +0 -289
  443. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  444. package/dist/generator-VE2JrFlY.mjs +0 -253
  445. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  446. package/dist/index-C6e-ULLx.d.mts.map +0 -1
  447. package/dist/index-CR5urhWX.d.cts.map +0 -1
  448. package/dist/openapi-SjsgARie.cjs +0 -2075
  449. package/dist/openapi-SjsgARie.cjs.map +0 -1
  450. package/dist/openapi-Xx0A7Wg0.mjs +0 -2021
  451. package/dist/openapi-Xx0A7Wg0.mjs.map +0 -1
  452. package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
  453. package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
  454. package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
  455. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
  456. package/dist/openapi-react-query.cjs +0 -4
  457. package/dist/openapi-react-query.d.cts +0 -11
  458. package/dist/openapi-react-query.d.cts.map +0 -1
  459. package/dist/openapi-react-query.d.mts +0 -11
  460. package/dist/openapi-react-query.d.mts.map +0 -1
  461. package/dist/openapi-react-query.mjs +0 -4
  462. package/dist/reconcile-CFs8C_1a.mjs.map +0 -1
  463. package/dist/reconcile-D0pimNiy.cjs.map +0 -1
  464. package/dist/setup-BA8ciTPU.mjs +0 -11
  465. package/dist/setup-BsZvZP6f.cjs +0 -11
  466. package/dist/setup-C8KOx8_8.mjs +0 -443
  467. package/dist/setup-C8KOx8_8.mjs.map +0 -1
  468. package/dist/setup-hC6hI86f.cjs +0 -473
  469. package/dist/setup-hC6hI86f.cjs.map +0 -1
  470. package/dist/storage-BJmzYxt8.cjs +0 -363
  471. package/dist/storage-BJmzYxt8.cjs.map +0 -1
  472. package/dist/storage-BM9hGpgv.cjs +0 -7
  473. package/dist/storage-Bi24WfoW.mjs +0 -297
  474. package/dist/storage-Bi24WfoW.mjs.map +0 -1
  475. package/dist/storage-CYlGwWTj.mjs +0 -3
  476. package/dist/sync-CmEuNZsB.mjs +0 -76
  477. package/dist/sync-CmEuNZsB.mjs.map +0 -1
  478. package/dist/sync-D306yOWu.cjs +0 -4
  479. package/dist/sync-SizaChmC.cjs +0 -93
  480. package/dist/sync-SizaChmC.cjs.map +0 -1
  481. package/dist/sync-hOqAWHR6.mjs +0 -3
  482. package/dist/types-6pkp2RRj.d.mts +0 -2220
  483. package/dist/types-6pkp2RRj.d.mts.map +0 -1
  484. package/dist/types-Y3fKQSAK.d.cts +0 -2220
  485. package/dist/types-Y3fKQSAK.d.cts.map +0 -1
  486. package/dist/workspace-BzrG_2SI.mjs +0 -8
  487. package/dist/workspace-C6VJQVtG.cjs.map +0 -1
  488. package/dist/workspace-XXtNhqJl.cjs +0 -9
  489. package/dist/workspace-zoqRbihZ.mjs.map +0 -1
@@ -0,0 +1,1090 @@
1
+ const require_errors = require("./errors-DMC4Umsb.cjs");
2
+ const require_discover = require("./discover-BfhVW_kT.cjs");
3
+ let node_path = require("node:path");
4
+ let node_fs = require("node:fs");
5
+ let node_fs_promises = require("node:fs/promises");
6
+ let _geekmidas_constructs_endpoints = require("@geekmidas/constructs/endpoints");
7
+ //#region src/generators/clientTelemetry.ts
8
+ /**
9
+ * Whether a generated client propagates trace context by default.
10
+ *
11
+ * `false` (the default) prints a client that sends no trace headers unless
12
+ * its caller passes `telemetry`. Anything else prints that default into
13
+ * `createApi`: `true`, or `{ sampleRate }` — the stage's rate, for the page
14
+ * views no OpenTelemetry SDK is tracing. A caller's own `telemetry` option
15
+ * still wins.
16
+ */
17
+ /** A `sampleRate` outside 0–1, which no sampler can honour. */
18
+ var InvalidClientTelemetrySampleRate = class extends require_errors.GkmError {
19
+ sampleRate;
20
+ constructor(sampleRate) {
21
+ super(`The client's telemetry sample rate must be a number from 0 to 1, got ${sampleRate}. Pass the stage's rate, such as 0.1, or leave it out for 1.`);
22
+ this.sampleRate = sampleRate;
23
+ this.name = "InvalidClientTelemetrySampleRate";
24
+ }
25
+ };
26
+ /** The `telemetry` default as the generated module prints it. */
27
+ function printTelemetryDefault(telemetry) {
28
+ if (typeof telemetry === "boolean") return String(telemetry);
29
+ const { sampleRate } = telemetry;
30
+ if (!Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) throw new InvalidClientTelemetrySampleRate(sampleRate);
31
+ return `{ sampleRate: ${sampleRate} }`;
32
+ }
33
+ /**
34
+ * `--telemetry [rate]` for a client default, as `gkm openapi` takes it — and
35
+ * as a site's Dockerfile passes it to the `gkm openapi --app` it runs.
36
+ */
37
+ function telemetryArgs(telemetry) {
38
+ if (!telemetry) return [];
39
+ if (telemetry === true) return ["--telemetry"];
40
+ return ["--telemetry", String(telemetry.sampleRate)];
41
+ }
42
+ /** What `--telemetry [rate]` parsed to: on, at a rate when one was given. */
43
+ function parseTelemetryFlag(value) {
44
+ if (value === void 0 || value === false) return void 0;
45
+ if (value === true) return true;
46
+ return { sampleRate: Number(value) };
47
+ }
48
+ //#endregion
49
+ //#region src/generators/telemetry.ts
50
+ /** Each endpoint's own `.telemetry({ ignore, attributes })`, as routes. */
51
+ function routeTelemetry(endpoints) {
52
+ return endpoints.flatMap((endpoint) => endpoint.telemetry ? [{
53
+ method: endpoint.method,
54
+ path: endpoint.route,
55
+ ...endpoint.telemetry
56
+ }] : []);
57
+ }
58
+ /**
59
+ * Every package `@geekmidas/telescope/instrumentation` loads at runtime.
60
+ *
61
+ * All of them, rather than one as a proxy: the production bundle follows each
62
+ * import, and a single missing one fails the build rather than the telemetry.
63
+ */
64
+ const TELEMETRY_PACKAGES = [
65
+ "@opentelemetry/api",
66
+ "@opentelemetry/auto-instrumentations-node",
67
+ "@opentelemetry/exporter-logs-otlp-http",
68
+ "@opentelemetry/exporter-trace-otlp-http",
69
+ "@opentelemetry/instrumentation-pino",
70
+ "@opentelemetry/resources",
71
+ "@opentelemetry/sdk-logs",
72
+ "@opentelemetry/sdk-node",
73
+ "@opentelemetry/sdk-trace-base",
74
+ "@opentelemetry/sdk-trace-node",
75
+ "@opentelemetry/semantic-conventions"
76
+ ];
77
+ /**
78
+ * The directory of `name` as `node_modules` lookup finds it from `fromDir`,
79
+ * symlinks resolved — or undefined.
80
+ *
81
+ * The directory walk alone, not `require.resolve`: that also searches
82
+ * `NODE_PATH`, which a package manager's bin shim sets to its own store, so a
83
+ * `gkm build` run through one would find packages the app never installed —
84
+ * and the bundler, which does not look there, would then fail on them.
85
+ */
86
+ function packageDir(fromDir, name) {
87
+ for (let dir = (0, node_path.resolve)(fromDir);; dir = (0, node_path.dirname)(dir)) {
88
+ const candidate = (0, node_path.join)(dir, "node_modules", name);
89
+ if ((0, node_fs.existsSync)((0, node_path.join)(candidate, "package.json"))) return (0, node_fs.realpathSync)(candidate);
90
+ if ((0, node_path.dirname)(dir) === dir) return void 0;
91
+ }
92
+ }
93
+ /**
94
+ * The telemetry packages that do not resolve the way the bundler will resolve
95
+ * them — telescope from the app, and the OpenTelemetry packages from
96
+ * telescope, where a peer is linked under pnpm, which need not be where the
97
+ * app sees it. Empty when every one does.
98
+ */
99
+ function missingTelemetryPackages(appRoot) {
100
+ const telescope = packageDir(appRoot, "@geekmidas/telescope");
101
+ if (!telescope) return ["@geekmidas/telescope", ...TELEMETRY_PACKAGES];
102
+ return TELEMETRY_PACKAGES.filter((pkg) => !packageDir(telescope, pkg));
103
+ }
104
+ /**
105
+ * An app uses a `Telemetry` construct and cannot load what it needs to.
106
+ *
107
+ * Failed at build, not at startup: a process that was given telemetry and
108
+ * quietly ran without it is an outage nobody can see into.
109
+ */
110
+ var TelemetryPackagesMissing = class extends require_errors.GkmError {
111
+ app;
112
+ missing;
113
+ dir;
114
+ command;
115
+ constructor(app, missing, dir) {
116
+ const command = `pnpm --dir ${dir || "."} add ${missing.join(" ")}`;
117
+ super(`'${app}' uses a Telemetry construct, and ${missing.join(", ")} ${missing.length === 1 ? "does" : "do"} not resolve from it — its server would start without exporting a span. Add them to the app and build again:\n\n ${command}\n`);
118
+ this.app = app;
119
+ this.missing = missing;
120
+ this.dir = dir;
121
+ this.name = "TelemetryPackagesMissing";
122
+ this.command = command;
123
+ }
124
+ };
125
+ /**
126
+ * The telemetry half of a build context: undefined for a process with no
127
+ * edge to a `Telemetry` node, and — for one with an edge — what its entry
128
+ * starts with, once every package it needs resolves.
129
+ */
130
+ function telemetryFor(options) {
131
+ const { node } = options;
132
+ if (!node) return void 0;
133
+ const missing = missingTelemetryPackages(options.appRoot);
134
+ if (missing.length > 0) throw new TelemetryPackagesMissing(options.app, missing, (0, node_path.relative)(options.cwd ?? process.cwd(), options.appRoot));
135
+ return {
136
+ serviceName: options.serviceName,
137
+ ...options.workspaceName && { serviceNamespace: options.workspaceName },
138
+ ignorePaths: [...node.ignorePaths ?? []],
139
+ attributes: { ...node.attributes },
140
+ routes: [...options.routes ?? []]
141
+ };
142
+ }
143
+ const HEADER = `/**
144
+ * Generated by gkm, for the production entry and the \`gkm dev\` one alike.
145
+ *
146
+ * Starts OpenTelemetry when OTEL_EXPORTER_OTLP_ENDPOINT names a collector, and
147
+ * does nothing otherwise: without it, the telemetry packages are not loaded.
148
+ * The standard OTEL_* variables (OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARG,
149
+ * OTEL_EXPORTER_OTLP_HEADERS, OTEL_RESOURCE_ATTRIBUTES, OTEL_SERVICE_NAME)
150
+ * configure the rest.
151
+ */
152
+
153
+ import type { MiddlewareHandler } from 'hono';
154
+
155
+ export interface StartTelemetryOptions {
156
+ /** Requests whose spans would only be noise: health checks, by default. */
157
+ ignorePaths?: string[];
158
+ /**
159
+ * The API's own sites — the origins its CORS allows — read on each request.
160
+ * Their \`traceparent\` is continued, as is an internal caller's; anyone
161
+ * else's starts a new trace linked to the one it claimed.
162
+ */
163
+ trustedOrigins?: () => readonly string[];
164
+ }
165
+ `;
166
+ /** `/users/:id` as a pattern over a request's path. */
167
+ function routePattern(path) {
168
+ return `^${path.split("/").map((segment) => {
169
+ if (segment.startsWith(":")) return "[^/]+";
170
+ if (segment === "*") return ".*";
171
+ return segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
172
+ }).join("/")}/?$`;
173
+ }
174
+ /**
175
+ * The entry's `telemetry.ts`: a `startTelemetry()` the server awaits before it
176
+ * imports the app, so the libraries the app loads are instrumented. It returns
177
+ * the Hono middleware that traces each request, or undefined when telemetry is
178
+ * off — the server mounts it ahead of every route.
179
+ *
180
+ * Without a context — a process with no edge to a `Telemetry` node — it is a
181
+ * stub that loads nothing and says nothing: telemetry is not something that
182
+ * process was given.
183
+ *
184
+ * Failing to start telemetry warns (a named `TelemetryUnavailable`, through
185
+ * `process.emitWarning`) and never stops the server: an outage in observability
186
+ * is not a reason to have an outage in the service.
187
+ */
188
+ function generateTelemetryModule(telemetry) {
189
+ if (!telemetry) return `${HEADER}
190
+ // This process has no Telemetry construct, so there is nothing to start.
191
+ export async function startTelemetry(
192
+ _options: StartTelemetryOptions = {},
193
+ ): Promise<MiddlewareHandler | undefined> {
194
+ return undefined;
195
+ }
196
+ `;
197
+ const options = [
198
+ `serviceName: ${JSON.stringify(telemetry.serviceName)},`,
199
+ ...telemetry.serviceNamespace ? [`serviceNamespace: ${JSON.stringify(telemetry.serviceNamespace)},`] : [],
200
+ "deploymentEnvironment: process.env.STAGE,",
201
+ ...Object.keys(telemetry.attributes).length ? [`resourceAttributes: ${JSON.stringify(telemetry.attributes)},`] : [],
202
+ "handleSignals: false,",
203
+ "instrumentPino: false,",
204
+ "incomingHttpSpans: false,"
205
+ ];
206
+ const routes = telemetry.routes.map((route) => ({
207
+ method: route.method.toUpperCase(),
208
+ pattern: routePattern(route.path),
209
+ ...route.ignore ? { ignore: true } : {},
210
+ ...route.attributes && Object.keys(route.attributes).length ? { attributes: route.attributes } : {}
211
+ }));
212
+ const withAttributes = routes.some((route) => "attributes" in route);
213
+ return `${HEADER}
214
+ /** Telemetry was asked for and cannot start. The server runs without it. */
215
+ export class TelemetryUnavailable extends Error {
216
+ constructor(readonly reason: string, options?: { cause?: unknown }) {
217
+ super(
218
+ \`OTEL_EXPORTER_OTLP_ENDPOINT is set, but \${reason} This server exports no traces or logs until that is fixed.\`,
219
+ options,
220
+ );
221
+ this.name = 'TelemetryUnavailable';
222
+ }
223
+ }
224
+
225
+ /** The Telemetry construct's own ignored paths, beside the entry's. */
226
+ const IGNORE_PATHS: string[] = ${JSON.stringify(telemetry.ignorePaths)};
227
+
228
+ /** Each route's own .telemetry({ ignore, attributes }). */
229
+ const ROUTES: {
230
+ method: string;
231
+ pattern: string;
232
+ ignore?: boolean;
233
+ attributes?: Record<string, string>;
234
+ }[] = ${JSON.stringify(routes)};
235
+
236
+ const MATCHERS = ROUTES.map((route) => ({ ...route, regex: new RegExp(route.pattern) }));
237
+
238
+ function routeOf(method: string, path: string) {
239
+ return MATCHERS.find(
240
+ (route) => (route.method === method || route.method === 'ALL' || route.method === 'ANY') && route.regex.test(path),
241
+ );
242
+ }
243
+
244
+ export async function startTelemetry(
245
+ options: StartTelemetryOptions = {},
246
+ ): Promise<MiddlewareHandler | undefined> {
247
+ if (!process.env.OTEL_EXPORTER_OTLP_ENDPOINT) return undefined;
248
+
249
+ let instrumentation;
250
+ try {
251
+ instrumentation = await import('@geekmidas/telescope/instrumentation');
252
+ } catch (cause) {
253
+ process.emitWarning(
254
+ new TelemetryUnavailable(
255
+ '@geekmidas/telescope/instrumentation or an @opentelemetry package it needs could not be loaded. Install them in the app and rebuild.',
256
+ { cause },
257
+ ),
258
+ );
259
+ return undefined;
260
+ }
261
+
262
+ instrumentation.setupTelemetry({
263
+ ${options.join("\n ")}
264
+ });
265
+
266
+ // Flush what is buffered when the process is told to stop. When nothing
267
+ // else handles the signal, re-raise it once flushed, so the process still
268
+ // stops the way it would have without this listener.
269
+ for (const signal of ['SIGTERM', 'SIGINT'] as const) {
270
+ process.once(signal, () => {
271
+ void instrumentation.flushTelemetry().finally(() => {
272
+ if (process.listenerCount(signal) === 0) process.kill(process.pid, signal);
273
+ });
274
+ });
275
+ }
276
+
277
+ // A SERVER span per request, opened by the app itself rather than by
278
+ // hooking node:http: \`GET /users/:id\`, continuing an incoming traceparent
279
+ // from the API's own sites and internal callers (a new, linked trace from
280
+ // anyone else), with the handler — its logs, fetches and queries — running
281
+ // inside it.
282
+ const spans = instrumentation.honoTelemetryMiddleware({
283
+ ignorePaths: [...(options.ignorePaths ?? []), ...IGNORE_PATHS],
284
+ trustedOrigins: options.trustedOrigins,
285
+ ...(MATCHERS.some((route) => route.ignore)
286
+ ? { shouldSkip: (c) => routeOf(c.req.method, c.req.path)?.ignore === true }
287
+ : {}),
288
+ });
289
+ ${withAttributes ? `
290
+ // A route's own attributes, on the span the middleware just opened.
291
+ const { trace } = await import('@opentelemetry/api');
292
+ return (c, next) =>
293
+ spans(c, async () => {
294
+ const attributes = routeOf(c.req.method, c.req.path)?.attributes;
295
+ if (attributes) trace.getActiveSpan()?.setAttributes(attributes);
296
+ await next();
297
+ });
298
+ ` : ` return spans;
299
+ `}}
300
+ `;
301
+ }
302
+ /**
303
+ * What an entry starts telemetry with, before it imports the app — shared by
304
+ * the production server, a self-serving surface's server and the `gkm dev`
305
+ * entry, so the three cannot start it differently. Defines `requestSpans`.
306
+ */
307
+ function startTelemetryCode(ignorePaths) {
308
+ return `// The API's own sites, known once the app has read its configuration: the
309
+ // origins its CORS allows are the ones whose trace context is continued.
310
+ let trustedOrigins: readonly string[] = [];
311
+
312
+ // Before the app is imported, so the libraries it loads are instrumented.
313
+ const { startTelemetry } = await import('./telemetry.js');
314
+ const requestSpans = await startTelemetry({
315
+ ignorePaths: ${JSON.stringify(ignorePaths)},
316
+ trustedOrigins: () => trustedOrigins,
317
+ });
318
+ `;
319
+ }
320
+ /** Mounts `requestSpans` on `app` ahead of every route. */
321
+ function mountRequestSpansCode(app) {
322
+ return `// The span middleware goes on before any route, so every request runs in it.
323
+ if (requestSpans) ${app}.use('*', requestSpans);
324
+ `;
325
+ }
326
+ /** Writes the entry's `telemetry.ts` beside it. */
327
+ async function writeTelemetryModule(outputDir, telemetry) {
328
+ await (0, node_fs_promises.mkdir)(outputDir, { recursive: true });
329
+ await (0, node_fs_promises.writeFile)((0, node_path.join)(outputDir, "telemetry.ts"), generateTelemetryModule(telemetry));
330
+ }
331
+ //#endregion
332
+ //#region src/generators/EndpointGenerator.ts
333
+ /**
334
+ * How a generated entry gets its logger and environment parser.
335
+ *
336
+ * From the surface it serves, when there is one: the surface holds both as
337
+ * *objects*, and discovery already recorded which module declares it, so the
338
+ * entry imports that module and reads them off it.
339
+ *
340
+ * The alternative — the shape this replaces — was naming both in config as
341
+ * module paths, `envParser: './config/env#envParser'`, and printing an import
342
+ * for each. Two strings per app, checked by nothing, describing files the
343
+ * surface was already holding the contents of.
344
+ *
345
+ * Falls back to the configured paths for an app that declares no surface.
346
+ */
347
+ function runtimeFor(context, fromDir, owner) {
348
+ const module = owner ? context.owners?.[owner] ?? context.surface?.module : context.surface?.module;
349
+ if (module) {
350
+ const specifier = importSpecifier(fromDir, module.specifier);
351
+ return {
352
+ imports: `import { ${module.exportName} as __surface } from '${specifier}';`,
353
+ bindings: [
354
+ "// What this construct was declared with. Objects, not module paths:",
355
+ "// the entry imports the owner, so there is nothing to print.",
356
+ "const envParser = __surface.envParser;",
357
+ "const logger = __surface.logger;"
358
+ ].join("\n")
359
+ };
360
+ }
361
+ throw new Error(`No owner to take a logger and an environment parser from${owner ? ` for "${owner}"` : ""}. Build it from a \`RestApi\` or a \`Worker\`.`);
362
+ }
363
+ /** A relative specifier ESM will accept: always prefixed, never bare. */
364
+ function importSpecifier(fromDir, target) {
365
+ const rel = (0, node_path.relative)(fromDir, target).replace(/\.ts$/, ".js");
366
+ return rel.startsWith(".") ? rel : `./${rel}`;
367
+ }
368
+ /**
369
+ * CORS for a surface, derived rather than hand-written.
370
+ *
371
+ * Who may call a surface is already in the graph — every construct that
372
+ * declared an edge to it — and reaches the process as one comma-separated
373
+ * value. An application that maintained this by hand maintained a list that was
374
+ * wrong in two directions at once: it trusted origins nothing was serving, and
375
+ * it could not name hosts a deploy had not chosen yet.
376
+ *
377
+ * Only the parts a graph cannot answer are configurable, and every one has a
378
+ * default: a surface that says nothing about CORS still gets it.
379
+ */
380
+ function corsFor(surface) {
381
+ if (!surface) return {
382
+ imports: "",
383
+ setup: ""
384
+ };
385
+ const cors = surface.cors ?? {};
386
+ const allowHeaders = [.../* @__PURE__ */ new Set([
387
+ "content-type",
388
+ "authorization",
389
+ "traceparent",
390
+ "tracestate",
391
+ ...cors.allowHeaders ?? []
392
+ ])];
393
+ return {
394
+ imports: `import { cors } from 'hono/cors';`,
395
+ setup: `
396
+ // Who may call ${surface.id}, read off the graph rather than listed here.
397
+ {
398
+ const { origins } = envParser
399
+ .create((get) => ({
400
+ origins: get('${surface.trustedOriginsKey}')
401
+ .string()
402
+ .default('')
403
+ .transform((value: string) =>
404
+ value.split(',').map((origin) => origin.trim()).filter(Boolean),
405
+ ),
406
+ }))
407
+ .parse();
408
+
409
+ // The same origins are the ones whose trace context the request spans
410
+ // continue — the server reads them back from \`createApp\`.
411
+ trustedOrigins.push(...origins);
412
+
413
+ honoApp.use('*', cors({
414
+ origin: origins,
415
+ allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
416
+ allowHeaders: ${JSON.stringify(allowHeaders)},${cors.exposeHeaders ? `\n exposeHeaders: ${JSON.stringify(cors.exposeHeaders)},` : ""}
417
+ credentials: ${cors.credentials ?? true},
418
+ maxAge: ${cors.maxAge ?? 86400},
419
+ }));
420
+ }
421
+ `
422
+ };
423
+ }
424
+ var EndpointGenerator = class extends require_discover.ConstructGenerator {
425
+ isConstruct(value) {
426
+ return _geekmidas_constructs_endpoints.Endpoint.isEndpoint(value);
427
+ }
428
+ async build(context, constructs, outputDir, options) {
429
+ const target = options?.target ?? "aws";
430
+ const root = options?.root ?? process.cwd();
431
+ const enableOpenApi = options?.enableOpenApi || false;
432
+ const logger = console;
433
+ const routes = [];
434
+ if (constructs.length === 0) return routes;
435
+ if (target === "server") {
436
+ await this.generateEndpointsFile(outputDir, constructs);
437
+ const appFile = await this.generateAppFile(outputDir, context);
438
+ routes.push({
439
+ path: "*",
440
+ method: "ALL",
441
+ handler: (0, node_path.relative)(root, appFile),
442
+ authorizer: "none"
443
+ });
444
+ logger.log(`Generated server with ${constructs.length} endpoints${enableOpenApi ? " (OpenAPI enabled)" : ""}`);
445
+ return routes;
446
+ }
447
+ const routesDir = (0, node_path.join)(outputDir, "routes");
448
+ await (0, node_fs_promises.mkdir)(routesDir, { recursive: true });
449
+ for (const { key, construct, path } of constructs) {
450
+ const handlerFile = await this.generateHandlerFile(routesDir, path.relative, key, context);
451
+ const routeInfo = {
452
+ path: construct._path,
453
+ method: construct.method,
454
+ handler: (0, node_path.relative)(root, handlerFile).replace(/\.ts$/, ".handler"),
455
+ timeout: construct.timeout,
456
+ memorySize: construct.memorySize,
457
+ environment: await construct.getEnvironment({ markOptional: context.markOptional }),
458
+ dependencies: construct.constructs,
459
+ authorizer: construct.authorizer?.name ?? "none"
460
+ };
461
+ routes.push(routeInfo);
462
+ logger.log(`Generated handler for ${routeInfo.method} ${routeInfo.path}`);
463
+ }
464
+ return routes;
465
+ }
466
+ async generateHandlerFile(outputDir, sourceFile, exportName, context) {
467
+ const handlerPath = (0, node_path.join)(outputDir, `${exportName}.ts`);
468
+ const importPath = (0, node_path.relative)((0, node_path.dirname)(handlerPath), sourceFile).replace(/\.ts$/, ".js");
469
+ await (0, node_fs_promises.writeFile)(handlerPath, this.generateAWSApiGatewayV2Handler(importPath, exportName, context.storageDrivers));
470
+ return handlerPath;
471
+ }
472
+ async generateEndpointsFile(outputDir, endpoints) {
473
+ const endpointsPath = (0, node_path.join)(outputDir, "endpoints.ts");
474
+ const importsByFile = /* @__PURE__ */ new Map();
475
+ for (const { path, key } of endpoints) {
476
+ const importPath = (0, node_path.relative)((0, node_path.dirname)(endpointsPath), path.relative).replace(/\.ts$/, ".js");
477
+ if (!importsByFile.has(importPath)) importsByFile.set(importPath, []);
478
+ importsByFile.get(importPath)?.push(key);
479
+ }
480
+ const content = `import type { EnvironmentParser } from '@geekmidas/envkit';
481
+ import type { Logger } from '@geekmidas/logger';
482
+ import { HonoEndpoint } from '@geekmidas/constructs/hono';
483
+ import { Endpoint } from '@geekmidas/constructs/endpoints';
484
+ import { ServiceDiscovery } from '@geekmidas/services';
485
+ import type { Hono } from 'hono';
486
+ ${Array.from(importsByFile.entries()).map(([importPath, exports]) => `import { ${exports.join(", ")} } from '${importPath}';`).join("\n")}
487
+
488
+ export const endpoints: Endpoint<any, any, any, any, any, any, any, any, any, any, any, any>[] = [
489
+ ${endpoints.map(({ key }) => key).join(",\n ")}
490
+ ];
491
+
492
+ export async function setupEndpoints(
493
+ app: Hono,
494
+ envParser: EnvironmentParser<any>,
495
+ logger: Logger,
496
+ enableOpenApi: boolean = true,
497
+ ): Promise<void> {
498
+ const serviceDiscovery = ServiceDiscovery.getInstance(envParser);
499
+
500
+ // Configure OpenAPI options based on enableOpenApi flag
501
+ const openApiOptions: any = enableOpenApi ? {
502
+ docsPath: '/__docs',
503
+ openApiOptions: {
504
+ title: 'API Documentation',
505
+ version: '1.0.0',
506
+ description: 'Generated API documentation'
507
+ }
508
+ } : { docsPath: false };
509
+
510
+ HonoEndpoint.addRoutes(endpoints, serviceDiscovery, app, openApiOptions);
511
+
512
+ // Add Swagger UI if OpenAPI is enabled
513
+ if (enableOpenApi) {
514
+ try {
515
+ const { swaggerUI } = await import('@hono/swagger-ui');
516
+ app.get('/__docs/ui', swaggerUI({ url: '/__docs' }));
517
+ } catch {
518
+ // @hono/swagger-ui not installed, skip Swagger UI
519
+ }
520
+ }
521
+ }
522
+ `;
523
+ await (0, node_fs_promises.writeFile)(endpointsPath, content);
524
+ return endpointsPath;
525
+ }
526
+ async generateAppFile(outputDir, context) {
527
+ await writeTelemetryModule(outputDir, context.telemetry);
528
+ if (context.production?.enabled) return this.generateProductionAppFile(outputDir, context);
529
+ const appPath = (0, node_path.join)(outputDir, "app.ts");
530
+ const runtime = runtimeFor(context, (0, node_path.dirname)(appPath));
531
+ const telescopeEnabled = context.telescope?.enabled;
532
+ const telescopeWebSocketEnabled = context.telescope?.websocket;
533
+ const usesExternalTelescope = !!context.telescope?.telescopePath;
534
+ const telescopeFromSurface = !!context.surface?.module && !usesExternalTelescope;
535
+ let telescopeImports = "";
536
+ if (telescopeEnabled) {
537
+ if (telescopeFromSurface) telescopeImports = `import { Telescope, InMemoryStorage } from '@geekmidas/telescope';
538
+ import { createApi, createMiddleware } from '@geekmidas/telescope/hono';`;
539
+ else if (usesExternalTelescope) {
540
+ const relativeTelescopePath = (0, node_path.relative)((0, node_path.dirname)(appPath), context.telescope?.telescopePath);
541
+ telescopeImports = `import ${context.telescope?.telescopeImportPattern} from '${relativeTelescopePath}';
542
+ import { createApi, createMiddleware } from '@geekmidas/telescope/hono';`;
543
+ } else telescopeImports = `import { Telescope, InMemoryStorage } from '@geekmidas/telescope';
544
+ import { createApi, createMiddleware } from '@geekmidas/telescope/hono';`;
545
+ }
546
+ const databaseApi = context.databaseApi;
547
+ const databaseApiImports = databaseApi ? `import { snifferContext } from '@geekmidas/constructs';
548
+ import { createIntrospectionHandler } from '@geekmidas/db/introspect';
549
+ import { ${databaseApi.database.exportName} as __introspectedDb } from '${importSpecifier((0, node_path.dirname)(appPath), databaseApi.database.specifier)}';` : "";
550
+ const cors = corsFor(context.surface);
551
+ let hooksImports = "";
552
+ let beforeSetupCall = "";
553
+ let afterSetupCall = "";
554
+ if (context.hooks?.serverHooksPath) {
555
+ hooksImports = `import * as serverHooks from '${(0, node_path.relative)((0, node_path.dirname)(appPath), context.hooks.serverHooksPath)}';`;
556
+ beforeSetupCall = `
557
+ // Call beforeSetup hook if defined
558
+ if (typeof serverHooks.beforeSetup === 'function') {
559
+ await serverHooks.beforeSetup(honoApp, { envParser, logger });
560
+ }
561
+ `;
562
+ afterSetupCall = `
563
+ // Call afterSetup hook if defined
564
+ if (typeof serverHooks.afterSetup === 'function') {
565
+ await serverHooks.afterSetup(honoApp, { envParser, logger });
566
+ }
567
+ `;
568
+ }
569
+ const telescopeWebSocketSetupCode = telescopeWebSocketEnabled ? `
570
+ // Setup WebSocket for real-time telescope updates
571
+ try {
572
+ const { createNodeWebSocket } = await import('@hono/node-ws');
573
+ const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app: honoApp });
574
+ // Add WebSocket route directly to main app (sub-app routes don't support WS upgrade)
575
+ honoApp.get('${context.telescope?.path}/ws', upgradeWebSocket(() => ({
576
+ onOpen: (_event: Event, ws: any) => {
577
+ telescope.addWsClient(ws);
578
+ },
579
+ onClose: (_event: Event, ws: any) => {
580
+ telescope.removeWsClient(ws);
581
+ },
582
+ onMessage: (event: MessageEvent, ws: any) => {
583
+ try {
584
+ const data = JSON.parse(event.data);
585
+ if (data.type === 'ping') {
586
+ ws.send(JSON.stringify({ type: 'pong' }));
587
+ }
588
+ } catch {
589
+ // Ignore invalid messages
590
+ }
591
+ },
592
+ })));
593
+ // Store injectWebSocket for server entry to call after serve()
594
+ (honoApp as any).__injectWebSocket = injectWebSocket;
595
+ logger.info('Telescope WebSocket enabled');
596
+ } catch (e) {
597
+ logger.warn({ err: e }, 'WebSocket support not available - install @hono/node-ws for real-time updates');
598
+ }
599
+ ` : "";
600
+ let telescopeSetup = "";
601
+ if (telescopeEnabled) {
602
+ if (telescopeFromSurface || usesExternalTelescope) telescopeSetup = `
603
+ ${telescopeWebSocketSetupCode}
604
+ // Add telescope middleware (before endpoints to capture all requests)
605
+ honoApp.use('*', createMiddleware(telescope));
606
+
607
+ // Mount Telescope's JSON API
608
+ const telescopeApi = createApi(telescope);
609
+ honoApp.route('${context.telescope?.path}', telescopeApi);
610
+ `;
611
+ else telescopeSetup = `
612
+ // Setup Telescope for debugging/monitoring
613
+ const telescopeStorage = new InMemoryStorage({ maxEntries: ${context.telescope?.maxEntries} });
614
+ const telescope = new Telescope({
615
+ enabled: true,
616
+ path: '${context.telescope?.path}',
617
+ ignorePatterns: ${JSON.stringify(context.telescope?.ignore)},
618
+ recordBody: ${context.telescope?.recordBody},
619
+ storage: telescopeStorage,
620
+ });
621
+ ${telescopeWebSocketSetupCode}
622
+ // Add telescope middleware (before endpoints to capture all requests)
623
+ honoApp.use('*', createMiddleware(telescope));
624
+
625
+ // Mount Telescope's JSON API
626
+ const telescopeApi = createApi(telescope);
627
+ honoApp.route('${context.telescope?.path}', telescopeApi);
628
+ `;
629
+ }
630
+ const databaseApiSetup = databaseApi ? `
631
+ // The database's structure and rows as JSON, read-only, for whatever tool
632
+ // the developer points at it. Dev only: it answers anyone who can reach the
633
+ // port.
634
+ const databaseApi = createIntrospectionHandler({
635
+ db: await __introspectedDb.service.register({ envParser, context: snifferContext }),
636
+ basePath: '${databaseApi.path}',
637
+ });
638
+ honoApp.all('${databaseApi.path}/*', (c) => databaseApi(c.req.raw));
639
+ ` : "";
640
+ const content = `/**
641
+ * Generated server application
642
+ *
643
+ * ⚠️ WARNING: This is for LOCAL DEVELOPMENT ONLY
644
+ * The subscriber polling mechanism is not production-ready.
645
+ * For production, use AWS Lambda with SQS/SNS event sources.
646
+ */
647
+ import { Hono } from 'hono';
648
+ import type { Hono as HonoType } from 'hono';
649
+ import { setupEndpoints } from './endpoints.js';
650
+ import { setupSubscribers } from './subscribers.js';
651
+ import { setupQueues } from './queues.js';
652
+ import { setupCrons } from './crons.js';
653
+ ${runtime.imports}
654
+ ${telescopeImports}
655
+ ${databaseApiImports}
656
+ ${hooksImports}
657
+ ${cors.imports}
658
+ ${context.storageDrivers?.imports ?? ""}
659
+
660
+ ${runtime.bindings}
661
+ ${telescopeEnabled && telescopeFromSurface ? `// The surface's own Telescope, or the one \`telescope\` config describes.
662
+ const telescope =
663
+ __surface.telescope ??
664
+ new Telescope({
665
+ enabled: true,
666
+ path: '${context.telescope?.path}',
667
+ ignorePatterns: ${JSON.stringify(context.telescope?.ignore)},
668
+ recordBody: ${context.telescope?.recordBody},
669
+ storage: new InMemoryStorage({ maxEntries: ${context.telescope?.maxEntries} }),
670
+ });` : ""}
671
+
672
+ ${context.storageDrivers?.setup ? `// Which drivers exist — storage, cache, events — is the entry point's
673
+ // decision: the scheme in each injected URL picks one, so no construct and no
674
+ // application module names a provider.
675
+ ${context.storageDrivers.setup}
676
+ ` : ""}
677
+ ${context.surface ? `// Who this server is to Postgres: application_name on every connection.
678
+ process.env.GKM_APP_NAME ??= ${JSON.stringify(context.surface.id)};
679
+
680
+ ` : ""}export interface ServerApp {
681
+ app: HonoType;
682
+ /** The origins this API's CORS allows: its own sites. */
683
+ trustedOrigins: readonly string[];
684
+ start: (options?: {
685
+ port?: number;
686
+ /** Returns the server, so a shutdown can stop it taking requests. */
687
+ serve: (app: HonoType, port: number) => unknown;
688
+ }) => Promise<void>;
689
+ }
690
+
691
+ /**
692
+ * Create and configure the Hono application
693
+ *
694
+ * @param app - Optional Hono app instance to configure (creates new one if not provided)
695
+ * @param enableOpenApi - Enable OpenAPI documentation (default: true)
696
+ * @returns Server app with configured Hono app and start function
697
+ *
698
+ * @example
699
+ * // With Bun
700
+ * import { createApp } from './.gkm/server/app.js';
701
+ *
702
+ * const { app, start } = await createApp();
703
+ *
704
+ * await start({
705
+ * port: 3000,
706
+ * serve: (app, port) => {
707
+ * Bun.serve({ port, fetch: app.fetch });
708
+ * }
709
+ * });
710
+ *
711
+ * @example
712
+ * // With Node.js (using @hono/node-server)
713
+ * import { serve } from '@hono/node-server';
714
+ * import { createApp } from './.gkm/server/app.js';
715
+ *
716
+ * const { app, start } = await createApp();
717
+ *
718
+ * await start({
719
+ * port: 3000,
720
+ * serve: (app, port) => {
721
+ * serve({ fetch: app.fetch, port });
722
+ * }
723
+ * });
724
+ */
725
+ export async function createApp(app?: HonoType, enableOpenApi: boolean = true): Promise<ServerApp> {
726
+ const honoApp = app || new Hono();
727
+ const trustedOrigins: string[] = [];
728
+ ${telescopeSetup}${cors.setup}${beforeSetupCall}${databaseApiSetup}
729
+ // Setup HTTP endpoints
730
+ await setupEndpoints(honoApp, envParser, logger, enableOpenApi);
731
+ ${afterSetupCall}
732
+
733
+ return {
734
+ app: honoApp,
735
+ trustedOrigins,
736
+ async start(options) {
737
+ if (!options?.serve) {
738
+ throw new Error(
739
+ 'serve function is required. Pass a serve function for your runtime:\\n' +
740
+ ' - Bun: (app, port) => Bun.serve({ port, fetch: app.fetch })\\n' +
741
+ ' - Node: (app, port) => serve({ fetch: app.fetch, port })'
742
+ );
743
+ }
744
+
745
+ const port = options.port ?? 3000;
746
+
747
+ // Mount pushed subscribers' routes and start polled ones. What comes
748
+ // back subscribes the routes, once the server can answer them.
749
+ const subscribeForPush = await setupSubscribers(honoApp, envParser, logger).catch((error) => {
750
+ logger.error({ err: error }, 'Failed to start subscribers');
751
+ return async (_port: number) => {};
752
+ });
753
+
754
+ // Start queue workers in background (non-blocking, local development only)
755
+ await setupQueues(envParser, logger).catch((error) => {
756
+ logger.error({ err: error }, 'Failed to start queue workers');
757
+ });
758
+
759
+ // Schedule this app's crons. Caught like the others: a scheduler that
760
+ // cannot start is not a reason for the HTTP server not to.
761
+ await setupCrons(envParser, logger).catch((error) => {
762
+ logger.error({ err: error }, 'Failed to schedule crons');
763
+ });
764
+
765
+ logger.info({ port }, 'Starting server');
766
+
767
+ // Start HTTP server using provided serve function
768
+ await options.serve(honoApp, port);
769
+
770
+ logger.info({ port }, 'Server started');
771
+
772
+ await subscribeForPush(port);
773
+ }
774
+ };
775
+ }
776
+
777
+ // Default export for convenience
778
+ export default createApp;
779
+ `;
780
+ await (0, node_fs_promises.writeFile)(appPath, content);
781
+ return appPath;
782
+ }
783
+ /**
784
+ * One Lambda, one endpoint — and no environment import.
785
+ *
786
+ * The endpoint was built from its surface, so it carries the parser the
787
+ * adaptor needs. This used to read
788
+ * `import { envParser } from '../../config/env'`, a line the build wrote
789
+ * because a generator can print a module specifier and cannot print an
790
+ * object. Nothing has to be printed now, which is also why nothing has to be
791
+ * named in config.
792
+ */
793
+ generateAWSApiGatewayV2Handler(importPath, exportName, drivers) {
794
+ return `import { AmazonApiGatewayV2Endpoint } from '@geekmidas/constructs/aws';
795
+ import { ${exportName} } from '${importPath}';
796
+ ${drivers?.imports ?? ""}
797
+ ${drivers?.setup ? `\n// The handler registers the drivers its target needs.\n${drivers.setup}\n` : ""}
798
+ const adapter = new AmazonApiGatewayV2Endpoint(${exportName});
799
+
800
+ export const handler = adapter.handler;
801
+ `;
802
+ }
803
+ /**
804
+ * Generate a production-optimized app.ts file
805
+ * No dev tools (Telescope, Studio, WebSocket), includes health checks and graceful shutdown
806
+ */
807
+ async generateProductionAppFile(outputDir, context) {
808
+ const appPath = (0, node_path.join)(outputDir, "app.ts");
809
+ const runtime = runtimeFor(context, (0, node_path.dirname)(appPath));
810
+ const production = context.production;
811
+ const healthCheckPath = production.healthCheck;
812
+ const enableGracefulShutdown = production.gracefulShutdown;
813
+ const enableOpenApi = production.openapi;
814
+ const includeSubscribers = production.subscribers === "include";
815
+ const cors = corsFor(context.surface);
816
+ let hooksImports = "";
817
+ let beforeSetupCall = "";
818
+ let afterSetupCall = "";
819
+ if (context.hooks?.serverHooksPath) {
820
+ hooksImports = `import * as serverHooks from '${(0, node_path.relative)((0, node_path.dirname)(appPath), context.hooks.serverHooksPath)}';`;
821
+ beforeSetupCall = `
822
+ // Call beforeSetup hook if defined
823
+ if (typeof serverHooks.beforeSetup === 'function') {
824
+ await serverHooks.beforeSetup(honoApp, { envParser, logger });
825
+ }
826
+ `;
827
+ afterSetupCall = `
828
+ // Call afterSetup hook if defined
829
+ if (typeof serverHooks.afterSetup === 'function') {
830
+ await serverHooks.afterSetup(honoApp, { envParser, logger });
831
+ }
832
+ `;
833
+ }
834
+ const subscriberSetup = includeSubscribers ? `
835
+ // Mount pushed subscribers' routes and start polled ones. What comes
836
+ // back subscribes the routes, once the server can answer them.
837
+ const subscribeForPush = await setupSubscribers(honoApp, envParser, logger).catch((error) => {
838
+ logger.error({ err: error }, 'Failed to start subscribers');
839
+ return async (_port: number) => {};
840
+ });
841
+
842
+ // Start queue workers in background
843
+ await setupQueues(envParser, logger).catch((error) => {
844
+ logger.error({ err: error }, 'Failed to start queue workers');
845
+ });
846
+
847
+ // Schedule this app's crons. Caught like the others: a scheduler that
848
+ // cannot start is not a reason for the HTTP server not to.
849
+ await setupCrons(envParser, logger).catch((error) => {
850
+ logger.error({ err: error }, 'Failed to schedule crons');
851
+ });
852
+ ` : "";
853
+ const subscriberImport = includeSubscribers ? `import { setupSubscribers } from './subscribers.js';
854
+ import { setupQueues } from './queues.js';
855
+ import { setupCrons } from './crons.js';` : "";
856
+ const gracefulShutdownCode = enableGracefulShutdown ? `
857
+ // Graceful shutdown: stop taking requests, let in-flight ones finish, then
858
+ // close what constructs opened (database pools) — so a rolling deploy does
859
+ // not leave the old task holding connections. Bounded by
860
+ // GKM_SHUTDOWN_TIMEOUT_MS, 8s by default: under Docker's 10s stop timeout,
861
+ // so the process exits on its own terms rather than being killed mid-drain.
862
+ let isShuttingDown = false;
863
+
864
+ const shutdown = async () => {
865
+ if (isShuttingDown) return;
866
+ isShuttingDown = true;
867
+ const deadline = Number(process.env.GKM_SHUTDOWN_TIMEOUT_MS) || 8000;
868
+ logger.info({ deadline }, 'Graceful shutdown initiated');
869
+ setTimeout(() => {
870
+ logger.warn({ deadline }, 'Shutdown deadline reached, exiting');
871
+ process.exit(1);
872
+ }, deadline).unref();
873
+ await new Promise<void>((resolve) => {
874
+ const close = (server as { close?: (done: () => void) => void } | undefined)?.close;
875
+ if (typeof close === 'function') close.call(server, () => resolve());
876
+ else resolve();
877
+ });
878
+ await runShutdownHooks((error) => logger.error({ err: error }, 'Shutdown hook failed'));
879
+ process.exit(0);
880
+ };
881
+
882
+ process.on('SIGTERM', shutdown);
883
+ process.on('SIGINT', shutdown);
884
+ ` : "";
885
+ const content = `/**
886
+ * Generated production server application
887
+ *
888
+ * This is a production-optimized build without dev tools.
889
+ * - No Telescope debugging dashboard
890
+ * - No Studio database browser
891
+ * - No WebSocket updates
892
+ * - Includes health checks and graceful shutdown
893
+ */
894
+ import { Hono } from 'hono';
895
+ import type { Hono as HonoType } from 'hono';
896
+ ${enableGracefulShutdown ? "import { runShutdownHooks } from '@geekmidas/constructs';\n" : ""}import { setupEndpoints } from './endpoints.js';
897
+ ${subscriberImport}
898
+ ${runtime.imports}
899
+ ${runtime.bindings}
900
+ ${hooksImports}
901
+ ${cors.imports}
902
+ ${context.storageDrivers?.imports ?? ""}
903
+
904
+ ${context.storageDrivers?.setup ? `// The entry point registers the drivers its target needs.
905
+ ${context.storageDrivers.setup}
906
+ ` : ""}
907
+ ${context.surface ? `// Who this server is to Postgres: application_name on every connection.
908
+ process.env.GKM_APP_NAME ??= ${JSON.stringify(context.surface.id)};
909
+
910
+ ` : ""}export interface ServerApp {
911
+ app: HonoType;
912
+ /** The origins this API's CORS allows: its own sites. */
913
+ trustedOrigins: readonly string[];
914
+ start: (options?: {
915
+ port?: number;
916
+ serve: (app: HonoType, port: number) => void | Promise<void>;
917
+ }) => Promise<void>;
918
+ }
919
+
920
+ /**
921
+ * Create and configure the production Hono application
922
+ */
923
+ export async function createApp(app?: HonoType): Promise<ServerApp> {
924
+ const honoApp = app || new Hono();
925
+ const trustedOrigins: string[] = [];
926
+
927
+ // Health check endpoint (always first)
928
+ honoApp.get('${healthCheckPath}', (c) => c.json({ status: 'ok', timestamp: Date.now() }));
929
+ honoApp.get('/ready', (c) => c.json({ ready: true }));
930
+
931
+ // An HttpError a handler or a session callback throws — a 401, a 404 —
932
+ // answers with its own status, as it does under gkm dev. The optimized
933
+ // handlers do not catch, so without this every one of them was a 500.
934
+ // Anything else is a 500 that says nothing about why, and is logged.
935
+ honoApp.onError((error, c) => {
936
+ const http = error as {
937
+ isHttpError?: boolean;
938
+ statusCode?: number;
939
+ statusMessage?: string;
940
+ code?: string;
941
+ details?: unknown;
942
+ };
943
+ if (http.isHttpError === true && typeof http.statusCode === 'number') {
944
+ return c.json(
945
+ {
946
+ name: error.name,
947
+ message: error.message,
948
+ statusCode: http.statusCode,
949
+ statusMessage: http.statusMessage,
950
+ code: http.code,
951
+ details: http.details,
952
+ },
953
+ http.statusCode as 500,
954
+ );
955
+ }
956
+ logger.error({ err: error }, 'Unhandled error');
957
+ return c.json({ message: 'Internal Server Error' }, 500);
958
+ });
959
+ ${cors.setup}${beforeSetupCall}
960
+ // Setup HTTP endpoints (OpenAPI: ${enableOpenApi})
961
+ await setupEndpoints(honoApp, envParser, logger, ${enableOpenApi});
962
+ ${afterSetupCall}
963
+ return {
964
+ app: honoApp,
965
+ trustedOrigins,
966
+ async start(options) {
967
+ if (!options?.serve) {
968
+ throw new Error(
969
+ 'serve function is required. Pass a serve function for your runtime:\\n' +
970
+ ' - Bun: (app, port) => Bun.serve({ port, fetch: app.fetch })\\n' +
971
+ ' - Node: (app, port) => serve({ fetch: app.fetch, port })'
972
+ );
973
+ }
974
+
975
+ const port = options.port ?? Number(process.env.PORT) ?? 3000;
976
+ let server: unknown;
977
+ ${gracefulShutdownCode}${subscriberSetup}
978
+ logger.info({ port }, 'Starting production server');
979
+
980
+ // Start HTTP server using provided serve function
981
+ server = await options.serve(honoApp, port);
982
+
983
+ logger.info({ port }, 'Production server started');
984
+ ${includeSubscribers ? "\n await subscribeForPush(port);" : ""}
985
+ }
986
+ };
987
+ }
988
+
989
+ // Default export for convenience
990
+ export default createApp;
991
+ `;
992
+ await (0, node_fs_promises.writeFile)(appPath, content);
993
+ await this.generateProductionServerEntry(outputDir, context);
994
+ return appPath;
995
+ }
996
+ /**
997
+ * Generate production server.ts entry point
998
+ */
999
+ async generateProductionServerEntry(outputDir, context) {
1000
+ const serverPath = (0, node_path.join)(outputDir, "server.ts");
1001
+ const content = `#!/usr/bin/env node
1002
+ /**
1003
+ * Production server entry point
1004
+ * Generated by 'gkm build --production'
1005
+ */
1006
+ import { serve } from '@hono/node-server';
1007
+ import { Hono } from 'hono';
1008
+
1009
+ ${startTelemetryCode([context.production?.healthCheck ?? "/health", "/ready"])}
1010
+ const { createApp } = await import('./app.js');
1011
+
1012
+ const port = Number(process.env.PORT) || 3000;
1013
+
1014
+ const app = new Hono();
1015
+ ${mountRequestSpansCode("app")}
1016
+ const created = await createApp(app);
1017
+ trustedOrigins = created.trustedOrigins;
1018
+ const { start } = created;
1019
+
1020
+ await start({
1021
+ port,
1022
+ serve: (app, port) => serve({ fetch: app.fetch, port }),
1023
+ });
1024
+ `;
1025
+ await (0, node_fs_promises.writeFile)(serverPath, content);
1026
+ }
1027
+ };
1028
+ //#endregion
1029
+ Object.defineProperty(exports, "EndpointGenerator", {
1030
+ enumerable: true,
1031
+ get: function() {
1032
+ return EndpointGenerator;
1033
+ }
1034
+ });
1035
+ Object.defineProperty(exports, "mountRequestSpansCode", {
1036
+ enumerable: true,
1037
+ get: function() {
1038
+ return mountRequestSpansCode;
1039
+ }
1040
+ });
1041
+ Object.defineProperty(exports, "parseTelemetryFlag", {
1042
+ enumerable: true,
1043
+ get: function() {
1044
+ return parseTelemetryFlag;
1045
+ }
1046
+ });
1047
+ Object.defineProperty(exports, "printTelemetryDefault", {
1048
+ enumerable: true,
1049
+ get: function() {
1050
+ return printTelemetryDefault;
1051
+ }
1052
+ });
1053
+ Object.defineProperty(exports, "routeTelemetry", {
1054
+ enumerable: true,
1055
+ get: function() {
1056
+ return routeTelemetry;
1057
+ }
1058
+ });
1059
+ Object.defineProperty(exports, "runtimeFor", {
1060
+ enumerable: true,
1061
+ get: function() {
1062
+ return runtimeFor;
1063
+ }
1064
+ });
1065
+ Object.defineProperty(exports, "startTelemetryCode", {
1066
+ enumerable: true,
1067
+ get: function() {
1068
+ return startTelemetryCode;
1069
+ }
1070
+ });
1071
+ Object.defineProperty(exports, "telemetryArgs", {
1072
+ enumerable: true,
1073
+ get: function() {
1074
+ return telemetryArgs;
1075
+ }
1076
+ });
1077
+ Object.defineProperty(exports, "telemetryFor", {
1078
+ enumerable: true,
1079
+ get: function() {
1080
+ return telemetryFor;
1081
+ }
1082
+ });
1083
+ Object.defineProperty(exports, "writeTelemetryModule", {
1084
+ enumerable: true,
1085
+ get: function() {
1086
+ return writeTelemetryModule;
1087
+ }
1088
+ });
1089
+
1090
+ //# sourceMappingURL=EndpointGenerator-By5_tYE9.cjs.map