@geekmidas/cli 10.0.0-alpha.12 → 10.0.0-alpha.13

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 (241) hide show
  1. package/dist/{HostingerProvider-BcyFRbqV.mjs → HostingerProvider-BY26bWwB.mjs} +20 -21
  2. package/dist/HostingerProvider-BY26bWwB.mjs.map +1 -0
  3. package/dist/{HostingerProvider-BOvsgATO.cjs → HostingerProvider-BZFGYYVA.cjs} +21 -22
  4. package/dist/HostingerProvider-BZFGYYVA.cjs.map +1 -0
  5. package/dist/{LocalStateProvider-yjXZXZDM.cjs → LocalStateProvider-7HR6SS2t.cjs} +11 -6
  6. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +1 -0
  7. package/dist/{LocalStateProvider-Bq-0C0sg.mjs → LocalStateProvider-D7QyJoLM.mjs} +10 -4
  8. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +1 -0
  9. package/dist/{Route53Provider-C0xmer8U.mjs → Route53Provider-Cvj40A8I.mjs} +12 -12
  10. package/dist/Route53Provider-Cvj40A8I.mjs.map +1 -0
  11. package/dist/{Route53Provider-CH9XH7bz.cjs → Route53Provider-DVILBsvV.cjs} +20 -21
  12. package/dist/Route53Provider-DVILBsvV.cjs.map +1 -0
  13. package/dist/{SSMStateProvider-DOZifZfE.mjs → SSMStateProvider-B0Hu1MKZ.mjs} +13 -4
  14. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +1 -0
  15. package/dist/{SSMStateProvider-CXtNgPfy.cjs → SSMStateProvider-VrQ-yeqd.cjs} +17 -9
  16. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +1 -0
  17. package/dist/{backup-provisioner-cE2PuCTb.cjs → backup-provisioner-BmhIO_Yr.cjs} +21 -19
  18. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +1 -0
  19. package/dist/{backup-provisioner-DXXg6FIL.mjs → backup-provisioner-DIVCbfee.mjs} +10 -7
  20. package/dist/backup-provisioner-DIVCbfee.mjs.map +1 -0
  21. package/dist/{bundler-BMekgx7a.cjs → bundler-BeNDZdHQ.cjs} +9 -12
  22. package/dist/bundler-BeNDZdHQ.cjs.map +1 -0
  23. package/dist/{bundler-Bux2iF-v.mjs → bundler-BodTL4kf.mjs} +8 -10
  24. package/dist/bundler-BodTL4kf.mjs.map +1 -0
  25. package/dist/{config-RYR9j6EF.cjs → config-Q1rvKHvw.cjs} +74 -69
  26. package/dist/config-Q1rvKHvw.cjs.map +1 -0
  27. package/dist/{config-DTsVjKZD.mjs → config-pqGD3hF9.mjs} +26 -14
  28. package/dist/config-pqGD3hF9.mjs.map +1 -0
  29. package/dist/config.cjs +4 -5
  30. package/dist/config.d.cts +14 -17
  31. package/dist/config.d.cts.map +1 -1
  32. package/dist/config.d.mts +14 -17
  33. package/dist/config.d.mts.map +1 -1
  34. package/dist/config.mjs +3 -5
  35. package/dist/{credentials-jMJC63qs.mjs → credentials-BekkKtY_.mjs} +234 -79
  36. package/dist/credentials-BekkKtY_.mjs.map +1 -0
  37. package/dist/{credentials-DQRvPz2S.cjs → credentials-Q6F0uqJq.cjs} +384 -236
  38. package/dist/credentials-Q6F0uqJq.cjs.map +1 -0
  39. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  40. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  41. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  42. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  43. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  44. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  45. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  46. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  47. package/dist/deploy/sniffer-hooks.cjs +13 -7
  48. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  49. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  50. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  51. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  52. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  53. package/dist/deploy/sniffer-hooks.mjs +9 -2
  54. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  55. package/dist/deploy/sniffer-loader.cjs +16 -7
  56. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  57. package/dist/deploy/sniffer-loader.d.cts +1 -1
  58. package/dist/deploy/sniffer-loader.d.mts +1 -1
  59. package/dist/deploy/sniffer-loader.mjs +13 -2
  60. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  61. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  62. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  63. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  64. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  65. package/dist/deploy/sniffer-routes-worker.mjs +2 -2
  66. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  67. package/dist/deploy/sniffer-worker.cjs +15 -6
  68. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  69. package/dist/deploy/sniffer-worker.d.cts +1 -3
  70. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  71. package/dist/deploy/sniffer-worker.d.mts +1 -3
  72. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  73. package/dist/deploy/sniffer-worker.mjs +15 -4
  74. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  75. package/dist/{discover-DmW9Bscc.cjs → discover-BERGFg8v.cjs} +68 -70
  76. package/dist/discover-BERGFg8v.cjs.map +1 -0
  77. package/dist/{discover-BYHQwQqu.mjs → discover-CK-n3w6b.mjs} +22 -20
  78. package/dist/discover-CK-n3w6b.mjs.map +1 -0
  79. package/dist/{emit-CUD1BWls.cjs → emit-BdoPFjZf.cjs} +53 -36
  80. package/dist/emit-BdoPFjZf.cjs.map +1 -0
  81. package/dist/{emit-CIlvnDvV.mjs → emit-Bzq7JsMP.mjs} +24 -6
  82. package/dist/emit-Bzq7JsMP.mjs.map +1 -0
  83. package/dist/{fullstack-secrets-B6KBHf-g.mjs → fullstack-secrets-BET8gqwK.mjs} +9 -15
  84. package/dist/fullstack-secrets-BET8gqwK.mjs.map +1 -0
  85. package/dist/{fullstack-secrets-DL8v0y4D.cjs → fullstack-secrets-DXsWO-5m.cjs} +19 -26
  86. package/dist/fullstack-secrets-DXsWO-5m.cjs.map +1 -0
  87. package/dist/{generator-VE2JrFlY.mjs → generator-LfZU7NlU.mjs} +8 -14
  88. package/dist/generator-LfZU7NlU.mjs.map +1 -0
  89. package/dist/{generator-CNzBw7g5.cjs → generator-Wdfp0jCS.cjs} +38 -45
  90. package/dist/generator-Wdfp0jCS.cjs.map +1 -0
  91. package/dist/{github-BThvbf2W.cjs → github-BfflNPVe.cjs} +36 -30
  92. package/dist/{github-BThvbf2W.cjs.map → github-BfflNPVe.cjs.map} +1 -1
  93. package/dist/{github-DpMZurEK.mjs → github-CRwnxKmD.mjs} +27 -20
  94. package/dist/github-CRwnxKmD.mjs.map +1 -0
  95. package/dist/{index-BzJ7QJ9c.d.mts → index-Cd-qeOam.d.mts} +3 -8
  96. package/dist/index-Cd-qeOam.d.mts.map +1 -0
  97. package/dist/{index-CfMjtdVC.d.cts → index-D-iAVHx-.d.cts} +3 -8
  98. package/dist/index-D-iAVHx-.d.cts.map +1 -0
  99. package/dist/index.cjs +2894 -1582
  100. package/dist/index.cjs.map +1 -1
  101. package/dist/index.d.cts +1 -1
  102. package/dist/index.d.mts +1 -1
  103. package/dist/index.mjs +2765 -1470
  104. package/dist/index.mjs.map +1 -1
  105. package/dist/{keystore-TxeYM7an.mjs → keystore-B4PRlbgE.mjs} +5 -7
  106. package/dist/keystore-B4PRlbgE.mjs.map +1 -0
  107. package/dist/{keystore-C9rint2E.cjs → keystore-DgGRj2Yy.cjs} +23 -26
  108. package/dist/keystore-DgGRj2Yy.cjs.map +1 -0
  109. package/dist/{openapi-DWLTsYLL.cjs → openapi-Dcbme-Us.cjs} +134 -171
  110. package/dist/openapi-Dcbme-Us.cjs.map +1 -0
  111. package/dist/openapi-react-query.cjs +156 -2
  112. package/dist/openapi-react-query.cjs.map +1 -0
  113. package/dist/openapi-react-query.d.cts +1 -3
  114. package/dist/openapi-react-query.d.cts.map +1 -1
  115. package/dist/openapi-react-query.d.mts +1 -3
  116. package/dist/openapi-react-query.d.mts.map +1 -1
  117. package/dist/openapi-react-query.mjs +156 -2
  118. package/dist/openapi-react-query.mjs.map +1 -0
  119. package/dist/{openapi-Bs3-5q_r.mjs → openapi-vy4JzhUv.mjs} +76 -106
  120. package/dist/openapi-vy4JzhUv.mjs.map +1 -0
  121. package/dist/openapi.cjs +3 -6
  122. package/dist/openapi.d.cts +8 -11
  123. package/dist/openapi.d.cts.map +1 -1
  124. package/dist/openapi.d.mts +8 -11
  125. package/dist/openapi.d.mts.map +1 -1
  126. package/dist/openapi.mjs +2 -6
  127. package/dist/reconcile/public.cjs +4 -4
  128. package/dist/reconcile/public.d.cts +8 -26
  129. package/dist/reconcile/public.d.cts.map +1 -1
  130. package/dist/reconcile/public.d.mts +8 -26
  131. package/dist/reconcile/public.d.mts.map +1 -1
  132. package/dist/reconcile/public.mjs +3 -4
  133. package/dist/{reconcile-Bhw5fmKu.cjs → reconcile-Dd2iyILf.cjs} +4 -7
  134. package/dist/reconcile-Dd2iyILf.cjs.map +1 -0
  135. package/dist/{reconcile-BI0tWkwz.mjs → reconcile-DhQ00DpU.mjs} +4 -7
  136. package/dist/reconcile-DhQ00DpU.mjs.map +1 -0
  137. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  138. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  139. package/dist/{storage-CSNplaJn.cjs → storage-C-30BD1e.cjs} +59 -69
  140. package/dist/storage-C-30BD1e.cjs.map +1 -0
  141. package/dist/{storage-B020InPW.mjs → storage-P_b3w7uj.mjs} +22 -13
  142. package/dist/storage-P_b3w7uj.mjs.map +1 -0
  143. package/dist/{sync-CzHXiR9c.mjs → sync-B3xxXtJT.mjs} +18 -6
  144. package/dist/sync-B3xxXtJT.mjs.map +1 -0
  145. package/dist/{sync-0ILCb-1S.cjs → sync-D7uTIIEi.cjs} +43 -25
  146. package/dist/sync-D7uTIIEi.cjs.map +1 -0
  147. package/dist/types-BGo5TaNE.d.mts +6164 -0
  148. package/dist/types-BGo5TaNE.d.mts.map +1 -0
  149. package/dist/types-C5ZNpUad.d.cts +6165 -0
  150. package/dist/types-C5ZNpUad.d.cts.map +1 -0
  151. package/dist/workspace/index.cjs +3 -3
  152. package/dist/workspace/index.d.cts +3 -3
  153. package/dist/workspace/index.d.mts +3 -3
  154. package/dist/workspace/index.mjs +2 -3
  155. package/dist/{workspace-CtnZnWsa.mjs → workspace-CgwmXEtc.mjs} +712 -806
  156. package/dist/workspace-CgwmXEtc.mjs.map +1 -0
  157. package/dist/{workspace-DPV7FtAv.cjs → workspace-mFpI_ky_.cjs} +881 -976
  158. package/dist/workspace-mFpI_ky_.cjs.map +1 -0
  159. package/package.json +14 -14
  160. package/dist/CachedStateProvider-BEBl2wQT.cjs +0 -60
  161. package/dist/CachedStateProvider-BEBl2wQT.cjs.map +0 -1
  162. package/dist/CachedStateProvider-C-8wtlto.mjs +0 -3
  163. package/dist/CachedStateProvider-Co4n5Wvs.mjs +0 -54
  164. package/dist/CachedStateProvider-Co4n5Wvs.mjs.map +0 -1
  165. package/dist/CachedStateProvider-DqhGpzsm.cjs +0 -3
  166. package/dist/HostingerProvider-BOvsgATO.cjs.map +0 -1
  167. package/dist/HostingerProvider-BcyFRbqV.mjs.map +0 -1
  168. package/dist/LocalStateProvider-Bq-0C0sg.mjs.map +0 -1
  169. package/dist/LocalStateProvider-yjXZXZDM.cjs.map +0 -1
  170. package/dist/Route53Provider-C0xmer8U.mjs.map +0 -1
  171. package/dist/Route53Provider-CH9XH7bz.cjs.map +0 -1
  172. package/dist/SSMStateProvider-CXtNgPfy.cjs.map +0 -1
  173. package/dist/SSMStateProvider-DOZifZfE.mjs.map +0 -1
  174. package/dist/backup-provisioner-DXXg6FIL.mjs.map +0 -1
  175. package/dist/backup-provisioner-cE2PuCTb.cjs.map +0 -1
  176. package/dist/bundler-BMekgx7a.cjs.map +0 -1
  177. package/dist/bundler-Bux2iF-v.mjs.map +0 -1
  178. package/dist/chunk-Duj1WY3L.mjs +0 -7
  179. package/dist/config-DTsVjKZD.mjs.map +0 -1
  180. package/dist/config-RYR9j6EF.cjs.map +0 -1
  181. package/dist/credentials-B5zRHdAl.mjs +0 -141
  182. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  183. package/dist/credentials-BapzjyV5.cjs +0 -195
  184. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  185. package/dist/credentials-DQRvPz2S.cjs.map +0 -1
  186. package/dist/credentials-jMJC63qs.mjs.map +0 -1
  187. package/dist/discover-BYHQwQqu.mjs.map +0 -1
  188. package/dist/discover-DmW9Bscc.cjs.map +0 -1
  189. package/dist/dokploy-api-5cK2InBm.cjs +0 -3
  190. package/dist/dokploy-api-D2Ny4Jrc.mjs +0 -3
  191. package/dist/dokploy-api-pdaBryoY.mjs +0 -706
  192. package/dist/dokploy-api-pdaBryoY.mjs.map +0 -1
  193. package/dist/dokploy-api-zqKe9lHH.cjs +0 -718
  194. package/dist/dokploy-api-zqKe9lHH.cjs.map +0 -1
  195. package/dist/emit-CIlvnDvV.mjs.map +0 -1
  196. package/dist/emit-CUD1BWls.cjs.map +0 -1
  197. package/dist/encryption-D2pL3tHH.cjs +0 -54
  198. package/dist/encryption-D2pL3tHH.cjs.map +0 -1
  199. package/dist/encryption-YDsXXi6w.mjs +0 -3
  200. package/dist/encryption-_4zwjOAR.mjs +0 -42
  201. package/dist/encryption-_4zwjOAR.mjs.map +0 -1
  202. package/dist/encryption-sQ2Oxx0d.cjs +0 -4
  203. package/dist/fullstack-secrets-B6KBHf-g.mjs.map +0 -1
  204. package/dist/fullstack-secrets-DL8v0y4D.cjs.map +0 -1
  205. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  206. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  207. package/dist/github-DpMZurEK.mjs.map +0 -1
  208. package/dist/index-BzJ7QJ9c.d.mts.map +0 -1
  209. package/dist/index-CfMjtdVC.d.cts.map +0 -1
  210. package/dist/keystore-C9rint2E.cjs.map +0 -1
  211. package/dist/keystore-TxeYM7an.mjs.map +0 -1
  212. package/dist/openapi-Bs3-5q_r.mjs.map +0 -1
  213. package/dist/openapi-DWLTsYLL.cjs.map +0 -1
  214. package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
  215. package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
  216. package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
  217. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
  218. package/dist/reconcile-BI0tWkwz.mjs.map +0 -1
  219. package/dist/reconcile-Bhw5fmKu.cjs.map +0 -1
  220. package/dist/setup-BmLoNrDX.mjs +0 -12
  221. package/dist/setup-BrR1_xGy.cjs +0 -12
  222. package/dist/setup-BsNR2LBG.cjs +0 -467
  223. package/dist/setup-BsNR2LBG.cjs.map +0 -1
  224. package/dist/setup-D5-JMknk.mjs +0 -437
  225. package/dist/setup-D5-JMknk.mjs.map +0 -1
  226. package/dist/storage-B020InPW.mjs.map +0 -1
  227. package/dist/storage-CSNplaJn.cjs.map +0 -1
  228. package/dist/storage-DGBzMLZa.mjs +0 -4
  229. package/dist/storage-DlVol_oj.cjs +0 -8
  230. package/dist/sync-0ILCb-1S.cjs.map +0 -1
  231. package/dist/sync-CzHXiR9c.mjs.map +0 -1
  232. package/dist/sync-DYENfOt4.cjs +0 -4
  233. package/dist/sync-HAau6h_R.mjs +0 -3
  234. package/dist/types-DVIx8I1N.d.mts +0 -1950
  235. package/dist/types-DVIx8I1N.d.mts.map +0 -1
  236. package/dist/types-PMP_qXRY.d.cts +0 -1950
  237. package/dist/types-PMP_qXRY.d.cts.map +0 -1
  238. package/dist/workspace-Cji6lE8E.cjs +0 -10
  239. package/dist/workspace-CkJAtRIX.mjs +0 -9
  240. package/dist/workspace-CtnZnWsa.mjs.map +0 -1
  241. package/dist/workspace-DPV7FtAv.cjs.map +0 -1
@@ -1,9 +1,10 @@
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
-
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
+ let node_path = require("node:path");
3
+ let _geekmidas_manifest = require("@geekmidas/manifest");
4
+ let fast_glob = require("fast-glob");
5
+ fast_glob = require_rolldown_runtime.__toESM(fast_glob, 1);
6
+ let lodash_kebabcase = require("lodash.kebabcase");
7
+ lodash_kebabcase = require_rolldown_runtime.__toESM(lodash_kebabcase, 1);
7
8
  //#region src/types.ts
8
9
  function isPartitionedRoutes(routes) {
9
10
  return typeof routes === "object" && routes !== null && !Array.isArray(routes) && "paths" in routes;
@@ -48,16 +49,6 @@ const DEFAULT_STORAGE = {
48
49
  aws: "s3",
49
50
  server: "minio"
50
51
  };
51
- /**
52
- * Who delivers mail when nobody said.
53
- *
54
- * Flat, unlike the others, and deliberately: mail is a SaaS on every target.
55
- * There is no self-hosted preset to default a container deploy to — Mailpit is
56
- * a development inbox, not a sender — so `server` has no answer of its own to
57
- * give and would only be `ses` written twice.
58
- */
59
- const DEFAULT_EMAIL = "ses";
60
-
61
52
  //#endregion
62
53
  //#region src/generators/Generator.ts
63
54
  /**
@@ -81,7 +72,7 @@ var ConstructGenerator = class {
81
72
  return generator.build(context, constructs, outputDir, options);
82
73
  }
83
74
  async load(patterns, cwd = process.cwd(), bustCache = false) {
84
- const logger$1 = console;
75
+ const logger = console;
85
76
  let globPatterns;
86
77
  let partitionFn;
87
78
  if (isPartitionedRoutes(patterns)) {
@@ -96,10 +87,9 @@ var ConstructGenerator = class {
96
87
  const constructs = [];
97
88
  for await (const f of files) try {
98
89
  const file = f.toString();
99
- const importPath = bustCache ? `${file}?t=${Date.now()}` : file;
100
- const module$1 = await import(importPath);
90
+ const module = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
101
91
  const partition = partitionFn ? partitionFn(file) : void 0;
102
- for (const [key, construct] of Object.entries(module$1)) if (this.isConstruct(construct)) constructs.push({
92
+ for (const [key, construct] of Object.entries(module)) if (this.isConstruct(construct)) constructs.push({
103
93
  key,
104
94
  name: (0, lodash_kebabcase.default)(key),
105
95
  construct,
@@ -111,16 +101,30 @@ var ConstructGenerator = class {
111
101
  });
112
102
  } catch (error) {
113
103
  const err = error;
114
- logger$1.error(`Failed to load ${f}: ${err.message}`);
115
- if (err.stack) logger$1.error(err.stack);
104
+ logger.error(`Failed to load ${f}: ${err.message}`);
105
+ if (err.stack) logger.error(err.stack);
116
106
  throw error;
117
107
  }
118
108
  return constructs;
119
109
  }
120
110
  };
121
-
122
111
  //#endregion
123
112
  //#region src/reconcile/discover.ts
113
+ /**
114
+ * Discovery — one glob, one structural test.
115
+ *
116
+ * A glob per kind is the same specialness the construct model removes, and
117
+ * resources have no kind to be listed under: a declared `ObjectStorage` would
118
+ * never be found by `routes:` or `crons:`. So there is one `constructs` glob,
119
+ * every export of every matching module is inspected, and the per-kind
120
+ * `isConstruct` checks collapse into a single question — does it have an id and
121
+ * can it declare?
122
+ *
123
+ * Structural rather than `instanceof` on purpose. A construct from a different
124
+ * copy of `@geekmidas/constructs` — a linked workspace, two versions in a
125
+ * lockfile — is still a construct, and `instanceof` is exactly the check that
126
+ * says otherwise.
127
+ */
124
128
  /** Matches the rest of the CLI, which logs through `console` directly. */
125
129
  const logger = console;
126
130
  /**
@@ -173,13 +177,13 @@ async function discover(options) {
173
177
  for await (const found of files) {
174
178
  matched++;
175
179
  const file = found.toString();
176
- const module$1 = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
177
- for (const [exportName, exported] of Object.entries(module$1)) {
180
+ const module = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
181
+ for (const [exportName, exported] of Object.entries(module)) {
178
182
  if (!isDeclarable(exported)) continue;
179
183
  if (seen.has(exported)) continue;
180
184
  seen.add(exported);
181
185
  for (const declaration of exported.declare()) {
182
- const id = (0, __geekmidas_manifest.canonicalId)(declaration.id);
186
+ const id = (0, _geekmidas_manifest.canonicalId)(declaration.id);
183
187
  const source = (0, node_path.relative)(cwd, file);
184
188
  const claimed = sources[id];
185
189
  if (claimed !== void 0 && claimed !== source) throw new DuplicateConstruct(id, [claimed, source]);
@@ -195,7 +199,7 @@ async function discover(options) {
195
199
  }
196
200
  }
197
201
  }
198
- (0, __geekmidas_manifest.assertDerivations)(manifest);
202
+ (0, _geekmidas_manifest.assertDerivations)(manifest);
199
203
  warnIfNothingFound(globs, matched, Object.keys(manifest).length);
200
204
  return manifest;
201
205
  }
@@ -237,54 +241,48 @@ var DuplicateConstruct = class extends Error {
237
241
  this.sources = sources;
238
242
  }
239
243
  };
240
-
241
244
  //#endregion
242
- Object.defineProperty(exports, 'ConstructGenerator', {
243
- enumerable: true,
244
- get: function () {
245
- return ConstructGenerator;
246
- }
247
- });
248
- Object.defineProperty(exports, 'DEFAULT_CACHE', {
249
- enumerable: true,
250
- get: function () {
251
- return DEFAULT_CACHE;
252
- }
245
+ Object.defineProperty(exports, "ConstructGenerator", {
246
+ enumerable: true,
247
+ get: function() {
248
+ return ConstructGenerator;
249
+ }
253
250
  });
254
- Object.defineProperty(exports, 'DEFAULT_EMAIL', {
255
- enumerable: true,
256
- get: function () {
257
- return DEFAULT_EMAIL;
258
- }
251
+ Object.defineProperty(exports, "DEFAULT_CACHE", {
252
+ enumerable: true,
253
+ get: function() {
254
+ return DEFAULT_CACHE;
255
+ }
259
256
  });
260
- Object.defineProperty(exports, 'DEFAULT_EVENTS', {
261
- enumerable: true,
262
- get: function () {
263
- return DEFAULT_EVENTS;
264
- }
257
+ Object.defineProperty(exports, "DEFAULT_EVENTS", {
258
+ enumerable: true,
259
+ get: function() {
260
+ return DEFAULT_EVENTS;
261
+ }
265
262
  });
266
- Object.defineProperty(exports, 'DEFAULT_STORAGE', {
267
- enumerable: true,
268
- get: function () {
269
- return DEFAULT_STORAGE;
270
- }
263
+ Object.defineProperty(exports, "DEFAULT_STORAGE", {
264
+ enumerable: true,
265
+ get: function() {
266
+ return DEFAULT_STORAGE;
267
+ }
271
268
  });
272
- Object.defineProperty(exports, 'discover', {
273
- enumerable: true,
274
- get: function () {
275
- return discover;
276
- }
269
+ Object.defineProperty(exports, "discover", {
270
+ enumerable: true,
271
+ get: function() {
272
+ return discover;
273
+ }
277
274
  });
278
- Object.defineProperty(exports, 'isDeclarable', {
279
- enumerable: true,
280
- get: function () {
281
- return isDeclarable;
282
- }
275
+ Object.defineProperty(exports, "isDeclarable", {
276
+ enumerable: true,
277
+ get: function() {
278
+ return isDeclarable;
279
+ }
283
280
  });
284
- Object.defineProperty(exports, 'isPartitionedRoutes', {
285
- enumerable: true,
286
- get: function () {
287
- return isPartitionedRoutes;
288
- }
281
+ Object.defineProperty(exports, "isPartitionedRoutes", {
282
+ enumerable: true,
283
+ get: function() {
284
+ return isPartitionedRoutes;
285
+ }
289
286
  });
290
- //# sourceMappingURL=discover-DmW9Bscc.cjs.map
287
+
288
+ //# sourceMappingURL=discover-BERGFg8v.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover-BERGFg8v.cjs","names":["fg","kebabCase","relative","fg","canonicalId","relative"],"sources":["../src/types.ts","../src/generators/Generator.ts","../src/reconcile/discover.ts"],"sourcesContent":["import type { StagesConfig } 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/**\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/**\n * Which broker carries a declared queue or topic, by target.\n *\n * Whether there are events at all is the manifest's answer — a declared\n * `Topic` or `Queue` — so this only ever answers the second question. AWS\n * deploys them to SNS and SQS, and locally the AWS emulator stands in, so the\n * broker a developer runs is the one production has. A server has a Postgres\n * already, and pg-boss keeps its queues there.\n */\nexport const DEFAULT_EVENTS: Record<MainProvider, EventsBackend> = {\n\taws: 'sns',\n\tserver: 'pgboss',\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\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}\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/** The project's stages: which one is local, which deploy */\n\tstages: StagesConfig;\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\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,oBACf,QAC8B;CAC9B,OACC,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,MAAM,QAAQ,MAAM,KACrB,WAAW;AAEb;;;;;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AClC,KAAK,IAAI,QAAkB;GAE3B,KAAK,MAAM,eAAe,SAAS,QAAQ,GAAG;IAG7C,MAAM,MAAA,GAAKC,oBAAAA,YAAAA,CAAY,YAAY,EAAE;IACrC,MAAM,UAAA,GAASC,UAAAA,SAAAA,CAAS,KAAK,IAAI;IAEjC,MAAM,UAAU,QAAQ;IACxB,IAAI,YAAY,KAAA,KAAa,YAAY,QACxC,MAAM,IAAI,mBAAmB,IAAI,CAAC,SAAS,MAAM,CAAC;IAGnD,SAAS,MAAM;KAAE,GAAG;KAAa;IAAG;IACpC,QAAQ,MAAM;IACd,IAAI,KAAK,IAAI,MAAM;KAAE;KAAM;IAAW;GACvC;EACD;CACD;CAIA,CAAA,GAAA,oBAAA,kBAAA,CAAkB,QAAQ;CAE1B,mBAAmB,OAAO,SAAS,OAAO,KAAK,QAAQ,CAAC,CAAC,MAAM;CAE/D,OAAO;AACR;;;;;;;;;;;;;;;;;;AAmBA,SAAS,mBACR,OACA,SACA,UACO;CACP,IAAI,MAAM,WAAW,GAAG;CAExB,IAAI,YAAY,GAAG;EAClB,OAAO,KACN,sFACiB,MAAM,KAAK,IAAI,EAAE,2JAKnC;EACA;CACD;CAEA,IAAI,aAAa,GAChB,OAAO,KACN,qCAAqC,QAAQ,qDAE5B,MAAM,KAAK,IAAI,EAAE,qIAInC;AAEF;;AAGA,IAAa,qBAAb,cAAwC,MAAM;;CAE7C;;CAEA;CAEA,YAAY,IAAY,SAA4B;EACnD,MAAM,oCAAoC;EAC1C,KAAK,OAAO;EACZ,KAAK,KAAK;EACV,KAAK,UAAU;CAChB;AACD"}
@@ -2,7 +2,6 @@ import { relative } from "node:path";
2
2
  import { assertDerivations, canonicalId } from "@geekmidas/manifest";
3
3
  import fg from "fast-glob";
4
4
  import kebabCase$1 from "lodash.kebabcase";
5
-
6
5
  //#region src/types.ts
7
6
  function isPartitionedRoutes(routes) {
8
7
  return typeof routes === "object" && routes !== null && !Array.isArray(routes) && "paths" in routes;
@@ -47,16 +46,6 @@ const DEFAULT_STORAGE = {
47
46
  aws: "s3",
48
47
  server: "minio"
49
48
  };
50
- /**
51
- * Who delivers mail when nobody said.
52
- *
53
- * Flat, unlike the others, and deliberately: mail is a SaaS on every target.
54
- * There is no self-hosted preset to default a container deploy to — Mailpit is
55
- * a development inbox, not a sender — so `server` has no answer of its own to
56
- * give and would only be `ses` written twice.
57
- */
58
- const DEFAULT_EMAIL = "ses";
59
-
60
49
  //#endregion
61
50
  //#region src/generators/Generator.ts
62
51
  /**
@@ -80,7 +69,7 @@ var ConstructGenerator = class {
80
69
  return generator.build(context, constructs, outputDir, options);
81
70
  }
82
71
  async load(patterns, cwd = process.cwd(), bustCache = false) {
83
- const logger$1 = console;
72
+ const logger = console;
84
73
  let globPatterns;
85
74
  let partitionFn;
86
75
  if (isPartitionedRoutes(patterns)) {
@@ -95,8 +84,7 @@ var ConstructGenerator = class {
95
84
  const constructs = [];
96
85
  for await (const f of files) try {
97
86
  const file = f.toString();
98
- const importPath = bustCache ? `${file}?t=${Date.now()}` : file;
99
- const module = await import(importPath);
87
+ const module = await (bustCache ? import(`${file}?t=${Date.now()}`) : import(file));
100
88
  const partition = partitionFn ? partitionFn(file) : void 0;
101
89
  for (const [key, construct] of Object.entries(module)) if (this.isConstruct(construct)) constructs.push({
102
90
  key,
@@ -110,16 +98,30 @@ var ConstructGenerator = class {
110
98
  });
111
99
  } catch (error) {
112
100
  const err = error;
113
- logger$1.error(`Failed to load ${f}: ${err.message}`);
114
- if (err.stack) logger$1.error(err.stack);
101
+ logger.error(`Failed to load ${f}: ${err.message}`);
102
+ if (err.stack) logger.error(err.stack);
115
103
  throw error;
116
104
  }
117
105
  return constructs;
118
106
  }
119
107
  };
120
-
121
108
  //#endregion
122
109
  //#region src/reconcile/discover.ts
110
+ /**
111
+ * Discovery — one glob, one structural test.
112
+ *
113
+ * A glob per kind is the same specialness the construct model removes, and
114
+ * resources have no kind to be listed under: a declared `ObjectStorage` would
115
+ * never be found by `routes:` or `crons:`. So there is one `constructs` glob,
116
+ * every export of every matching module is inspected, and the per-kind
117
+ * `isConstruct` checks collapse into a single question — does it have an id and
118
+ * can it declare?
119
+ *
120
+ * Structural rather than `instanceof` on purpose. A construct from a different
121
+ * copy of `@geekmidas/constructs` — a linked workspace, two versions in a
122
+ * lockfile — is still a construct, and `instanceof` is exactly the check that
123
+ * says otherwise.
124
+ */
123
125
  /** Matches the rest of the CLI, which logs through `console` directly. */
124
126
  const logger = console;
125
127
  /**
@@ -236,7 +238,7 @@ var DuplicateConstruct = class extends Error {
236
238
  this.sources = sources;
237
239
  }
238
240
  };
239
-
240
241
  //#endregion
241
- export { ConstructGenerator, DEFAULT_CACHE, DEFAULT_EMAIL, DEFAULT_EVENTS, DEFAULT_STORAGE, discover, isDeclarable, isPartitionedRoutes };
242
- //# sourceMappingURL=discover-BYHQwQqu.mjs.map
242
+ export { DEFAULT_EVENTS as a, DEFAULT_CACHE as i, isDeclarable as n, DEFAULT_STORAGE as o, ConstructGenerator as r, isPartitionedRoutes as s, discover as t };
243
+
244
+ //# sourceMappingURL=discover-CK-n3w6b.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover-CK-n3w6b.mjs","names":["kebabCase"],"sources":["../src/types.ts","../src/generators/Generator.ts","../src/reconcile/discover.ts"],"sourcesContent":["import type { StagesConfig } 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/**\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/**\n * Which broker carries a declared queue or topic, by target.\n *\n * Whether there are events at all is the manifest's answer — a declared\n * `Topic` or `Queue` — so this only ever answers the second question. AWS\n * deploys them to SNS and SQS, and locally the AWS emulator stands in, so the\n * broker a developer runs is the one production has. A server has a Postgres\n * already, and pg-boss keeps its queues there.\n */\nexport const DEFAULT_EVENTS: Record<MainProvider, EventsBackend> = {\n\taws: 'sns',\n\tserver: 'pgboss',\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\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}\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/** The project's stages: which one is local, which deploy */\n\tstages: StagesConfig;\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\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,oBACf,QAC8B;CAC9B,OACC,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,MAAM,QAAQ,MAAM,KACrB,WAAW;AAEb;;;;;;;;;;;;;;;;;;;AA6GA,MAAa,gBAAoD;CAEhE,KAAK;CAGL,QAAQ;AACT;;;;;;;;;;AAWA,MAAa,iBAAsD;CAClE,KAAK;CACL,QAAQ;AACT;;AAGA,MAAa,kBAAwD;CACpE,KAAK;CACL,QAAQ;AACT;;;;;;;;;;;;;;AC1IA,SAAgB,yBAA+B;CAC9C,MAAM,WACL,WACC;CACF,IAAI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,QAAQ,MAAM;IACd,IAAI,KAAK,IAAI,MAAM;KAAE;KAAM;IAAW;GACvC;EACD;CACD;CAIA,kBAAkB,QAAQ;CAE1B,mBAAmB,OAAO,SAAS,OAAO,KAAK,QAAQ,CAAC,CAAC,MAAM;CAE/D,OAAO;AACR;;;;;;;;;;;;;;;;;;AAmBA,SAAS,mBACR,OACA,SACA,UACO;CACP,IAAI,MAAM,WAAW,GAAG;CAExB,IAAI,YAAY,GAAG;EAClB,OAAO,KACN,sFACiB,MAAM,KAAK,IAAI,EAAE,2JAKnC;EACA;CACD;CAEA,IAAI,aAAa,GAChB,OAAO,KACN,qCAAqC,QAAQ,qDAE5B,MAAM,KAAK,IAAI,EAAE,qIAInC;AAEF;;AAGA,IAAa,qBAAb,cAAwC,MAAM;;CAE7C;;CAEA;CAEA,YAAY,IAAY,SAA4B;EACnD,MAAM,oCAAoC;EAC1C,KAAK,OAAO;EACZ,KAAK,KAAK;EACV,KAAK,UAAU;CAChB;AACD"}
@@ -1,9 +1,26 @@
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 node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
5
-
1
+ let node_fs_promises = require("node:fs/promises");
2
+ let node_path = require("node:path");
3
+ let _geekmidas_manifest = require("@geekmidas/manifest");
6
4
  //#region src/reconcile/emit.ts
5
+ /**
6
+ * The manifest, written out as a module.
7
+ *
8
+ * Discovery imports the application's own code — that is how it finds
9
+ * constructs — so anything calling it evaluates the whole runtime graph: React
10
+ * email templates, database clients, modules that read env at import time. That
11
+ * is fine inside `gkm dev`, which is already running the app. It is not fine
12
+ * inside a deploy config, where it fails on the first thing the deploy toolchain
13
+ * does not expect and would keep failing on the next.
14
+ *
15
+ * So discovery happens once, in the build, and everything downstream reads what
16
+ * it wrote. The same split `RestApi` makes by naming a routes glob rather than
17
+ * importing route modules.
18
+ *
19
+ * A module rather than JSON, because a manifest is not just data to this
20
+ * codebase — `as const satisfies ConstructManifest` is what keeps every id,
21
+ * kind and provided key a *literal*, so `IdsOf`, `ProvidedKeys` and the rest
22
+ * can select out of it. `JSON.parse` returns `any` and gives all of that up.
23
+ */
7
24
  /** Where the build writes it, relative to the app root. */
8
25
  const MANIFEST_PATH = ".gkm/manifest.ts";
9
26
  /**
@@ -36,7 +53,7 @@ const MANIFEST_PATH = ".gkm/manifest.ts";
36
53
  */
37
54
  function withRoutes(manifest, routes, options) {
38
55
  if (routes.length === 0 || !options.perRoute) return manifest;
39
- const target = Object.entries(manifest).find(([, declaration$1]) => declaration$1.kind === "rest-api" && declaration$1.endpoints.length === 0);
56
+ const target = Object.entries(manifest).find(([, declaration]) => declaration.kind === "rest-api" && declaration.endpoints.length === 0);
40
57
  if (!target) return manifest;
41
58
  const [id, declaration] = target;
42
59
  if (declaration.kind !== "rest-api") return manifest;
@@ -68,7 +85,7 @@ function withCompute(manifest, compute) {
68
85
  id: fn.name,
69
86
  handler: fn.handler,
70
87
  dependencies: edgesTo(manifest, fn.dependencies),
71
- provides: [(0, __geekmidas_manifest.provideKey)(fn.name, "url")]
88
+ provides: [(0, _geekmidas_manifest.provideKey)(fn.name, "url")]
72
89
  };
73
90
  for (const cron of compute.crons ?? []) next[cron.name] = {
74
91
  kind: "cron",
@@ -78,7 +95,7 @@ function withCompute(manifest, compute) {
78
95
  dependencies: edgesTo(manifest, cron.dependencies)
79
96
  };
80
97
  for (const worker of compute.queues ?? []) {
81
- const queue = next[(0, __geekmidas_manifest.canonicalId)(worker.name)];
98
+ const queue = next[(0, _geekmidas_manifest.canonicalId)(worker.name)];
82
99
  if (queue?.kind !== "queue") continue;
83
100
  next[queue.id] = {
84
101
  ...queue,
@@ -90,7 +107,7 @@ function withCompute(manifest, compute) {
90
107
  };
91
108
  }
92
109
  for (const subscriber of compute.subscribers ?? []) {
93
- const topicId = subscriber.topic && (0, __geekmidas_manifest.canonicalId)(subscriber.topic);
110
+ const topicId = subscriber.topic && (0, _geekmidas_manifest.canonicalId)(subscriber.topic);
94
111
  const topic = topicId ? next[topicId] : void 0;
95
112
  if (topic?.kind !== "topic") continue;
96
113
  next[topic.id] = {
@@ -201,36 +218,36 @@ import type {
201
218
  function serialise(value) {
202
219
  return JSON.stringify(value, null, " ").replace(/^(\t*)"([A-Za-z_$][\w$]*)":/gm, "$1$2:").replace(/"/g, "'");
203
220
  }
204
-
205
221
  //#endregion
206
- Object.defineProperty(exports, 'MANIFEST_PATH', {
207
- enumerable: true,
208
- get: function () {
209
- return MANIFEST_PATH;
210
- }
222
+ Object.defineProperty(exports, "MANIFEST_PATH", {
223
+ enumerable: true,
224
+ get: function() {
225
+ return MANIFEST_PATH;
226
+ }
211
227
  });
212
- Object.defineProperty(exports, 'manifestModule', {
213
- enumerable: true,
214
- get: function () {
215
- return manifestModule;
216
- }
228
+ Object.defineProperty(exports, "manifestModule", {
229
+ enumerable: true,
230
+ get: function() {
231
+ return manifestModule;
232
+ }
217
233
  });
218
- Object.defineProperty(exports, 'withCompute', {
219
- enumerable: true,
220
- get: function () {
221
- return withCompute;
222
- }
234
+ Object.defineProperty(exports, "withCompute", {
235
+ enumerable: true,
236
+ get: function() {
237
+ return withCompute;
238
+ }
223
239
  });
224
- Object.defineProperty(exports, 'withRoutes', {
225
- enumerable: true,
226
- get: function () {
227
- return withRoutes;
228
- }
240
+ Object.defineProperty(exports, "withRoutes", {
241
+ enumerable: true,
242
+ get: function() {
243
+ return withRoutes;
244
+ }
229
245
  });
230
- Object.defineProperty(exports, 'writeManifestModule', {
231
- enumerable: true,
232
- get: function () {
233
- return writeManifestModule;
234
- }
246
+ Object.defineProperty(exports, "writeManifestModule", {
247
+ enumerable: true,
248
+ get: function() {
249
+ return writeManifestModule;
250
+ }
235
251
  });
236
- //# sourceMappingURL=emit-CUD1BWls.cjs.map
252
+
253
+ //# sourceMappingURL=emit-BdoPFjZf.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-BdoPFjZf.cjs","names":["provideKey","canonicalId","join","mkdir","dirname","writeFile"],"sources":["../src/reconcile/emit.ts"],"sourcesContent":["/**\n * The manifest, written out as a module.\n *\n * Discovery imports the application's own code — that is how it finds\n * constructs — so anything calling it evaluates the whole runtime graph: React\n * email templates, database clients, modules that read env at import time. That\n * is fine inside `gkm dev`, which is already running the app. It is not fine\n * inside a deploy config, where it fails on the first thing the deploy toolchain\n * does not expect and would keep failing on the next.\n *\n * So discovery happens once, in the build, and everything downstream reads what\n * it wrote. The same split `RestApi` makes by naming a routes glob rather than\n * importing route modules.\n *\n * A module rather than JSON, because a manifest is not just data to this\n * codebase — `as const satisfies ConstructManifest` is what keeps every id,\n * kind and provided key a *literal*, so `IdsOf`, `ProvidedKeys` and the rest\n * can select out of it. `JSON.parse` returns `any` and gives all of that up.\n */\n\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type {\n\tConstructManifest,\n\tCronInfo,\n\tDeclaration,\n\tDependency,\n\tFunctionInfo,\n\tQueueInfo,\n\tRestApiEndpoint,\n\tRouteInfo,\n\tSubscriberInfo,\n} from '@geekmidas/manifest';\nimport { canonicalId, provideKey } from '@geekmidas/manifest';\nimport type { CacheBackend, EmailBackend } from '../types.js';\n\n/** Where the build writes it, relative to the app root. */\nexport const MANIFEST_PATH = '.gkm/manifest.ts';\n\n/**\n * Fold the build's generated routes into the surface that serves them.\n *\n * The routes already exist: `gkm build` generates one handler per endpoint and\n * records its path, method and environment. What was missing is that the\n * *construct* manifest never learned about them, so a `rest-api` node said\n * `endpoints: []` while five handlers sat in `.gkm/`. Two documents describing\n * the same routes, one of them wrong.\n *\n * Merging here rather than making the construct name a glob or import its\n * endpoints: the build is the thing that already walked the filesystem and\n * already knows where it wrote each handler. Asking the declaration to restate\n * any of that is how the two come to disagree.\n *\n * Attribution is by exclusion — routes go to the surface that declared none of\n * its own. A surface with static endpoints (an auth server's single wildcard)\n * keeps them. That is exact while an app has one API of its own, and needs a\n * real answer the day it has two; the alternative today would be inventing one\n * before anything needs it.\n *\n * **Only from a provider that generates one handler per route.** The `server`\n * provider generates a single catch-all — `ALL *` pointing at the Hono app that\n * routes in-process — which is a true description of that build and a false\n * description of the application. Merging it wrote `endpoints: [{ method:\n * 'ALL', path: '*' }]` into a manifest for an app with five routes, and made the\n * document's contents depend on which `--provider` ran last. A manifest must not\n * do that.\n */\nexport function withRoutes(\n\tmanifest: ConstructManifest,\n\troutes: readonly RouteInfo[],\n\toptions: { perRoute: boolean },\n): ConstructManifest {\n\tif (routes.length === 0 || !options.perRoute) return manifest;\n\n\tconst target = Object.entries(manifest).find(\n\t\t([, declaration]) =>\n\t\t\tdeclaration.kind === 'rest-api' && declaration.endpoints.length === 0,\n\t);\n\n\tif (!target) return manifest;\n\n\tconst [id, declaration] = target;\n\tif (declaration.kind !== 'rest-api') return manifest;\n\n\treturn {\n\t\t...manifest,\n\t\t[id]: {\n\t\t\t...declaration,\n\t\t\tendpoints: routes.map((route) => asEndpoint(manifest, id, route)),\n\t\t},\n\t};\n}\n\n/**\n * Fold in the compute the build generated: functions, crons, queue workers and\n * topic subscribers.\n *\n * All four are named by their *export*, the same way an endpoint's handler is —\n * `CronGenerator` uses the export key as the name — so none of them can declare\n * themselves and all of them are the build's to add. That is why a `Function`\n * has no `declare()` and never will.\n *\n * A worker and a subscriber **nest** inside the queue or topic that triggers\n * them, because position carries the trigger. A function and a cron are\n * top-level, because nothing triggers them but a caller or a clock.\n */\nexport function withCompute(\n\tmanifest: ConstructManifest,\n\tcompute: {\n\t\tfunctions?: readonly FunctionInfo[];\n\t\tcrons?: readonly CronInfo[];\n\t\tqueues?: readonly QueueInfo[];\n\t\tsubscribers?: readonly SubscriberInfo[];\n\t},\n): ConstructManifest {\n\tconst next: Record<string, Declaration> = { ...manifest };\n\n\tfor (const fn of compute.functions ?? []) {\n\t\tnext[fn.name] = {\n\t\t\tkind: 'function',\n\t\t\tid: fn.name,\n\t\t\thandler: fn.handler,\n\t\t\tdependencies: edgesTo(manifest, fn.dependencies),\n\t\t\tprovides: [provideKey(fn.name, 'url')],\n\t\t};\n\t}\n\n\tfor (const cron of compute.crons ?? []) {\n\t\tnext[cron.name] = {\n\t\t\tkind: 'cron',\n\t\t\tid: cron.name,\n\t\t\thandler: cron.handler,\n\t\t\tschedule: cron.schedule,\n\t\t\tdependencies: edgesTo(manifest, cron.dependencies),\n\t\t};\n\t}\n\n\t// A worker drains exactly one queue, so it is matched by the queue it names\n\t// rather than by anything about the handler.\n\tfor (const worker of compute.queues ?? []) {\n\t\tconst queue = next[canonicalId(worker.name)];\n\t\tif (queue?.kind !== 'queue') continue;\n\n\t\tnext[queue.id] = {\n\t\t\t...queue,\n\t\t\tworker: {\n\t\t\t\tid: `${queue.id}Worker`,\n\t\t\t\thandler: worker.handler,\n\t\t\t\tdependencies: edgesTo(manifest, worker.dependencies),\n\t\t\t},\n\t\t};\n\t}\n\n\tfor (const subscriber of compute.subscribers ?? []) {\n\t\tconst topicId = subscriber.topic && canonicalId(subscriber.topic);\n\t\tconst topic = topicId ? next[topicId] : undefined;\n\t\tif (topic?.kind !== 'topic') continue;\n\n\t\tnext[topic.id] = {\n\t\t\t...topic,\n\t\t\tsubscribers: [\n\t\t\t\t...topic.subscribers,\n\t\t\t\t{\n\t\t\t\t\tid: subscriber.name,\n\t\t\t\t\thandler: subscriber.handler,\n\t\t\t\t\tevents: subscriber.subscribedEvents,\n\t\t\t\t\tdependencies: edgesTo(manifest, subscriber.dependencies),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\n\treturn next;\n}\n\n/**\n * Construct ids as manifest edges.\n *\n * A `Dependency` carries the target's kind as well as its id, and the kind is\n * read off the manifest rather than recorded beside the edge — the same rule\n * `edgeTo` follows, for the same reason: a hand-written kind is one fact stated\n * twice, and the copy is what goes stale.\n *\n * An id that names nothing is dropped rather than thrown on. A handler can\n * depend on a construct that declares no node of its own — a lifted `Service`\n * is exactly that — and a build is the wrong place to refuse it; what a target\n * needs from this list is the subset it can actually grant.\n */\nfunction edgesTo(\n\tmanifest: ConstructManifest,\n\tids: readonly string[] = [],\n): Dependency[] {\n\treturn ids.flatMap((target) => {\n\t\tconst declaration = manifest[target];\n\n\t\treturn declaration ? [{ target, kind: declaration.kind }] : [];\n\t});\n}\n\n/** One generated route as the manifest's shape. */\nfunction asEndpoint(\n\tmanifest: ConstructManifest,\n\tsurface: string,\n\troute: RouteInfo,\n): RestApiEndpoint {\n\treturn {\n\t\t// The handler path is already unique per route and is what a target needs\n\t\t// to point a function at, so it is also the natural id.\n\t\tid: `${surface}${route.method}${route.path}`,\n\t\thandler: route.handler,\n\t\tmethod: route.method,\n\t\tpath: route.path,\n\t\t// The edges the handler declared, which is what a target reads to grant\n\t\t// this one function access to exactly those constructs. `environment` is\n\t\t// the same edges' shadow — the keys read — and cannot be turned back into\n\t\t// them, which is why the ids are carried rather than inferred.\n\t\tdependencies: edgesTo(manifest, route.dependencies),\n\t\t...(route.authorizer ? { authorizer: route.authorizer } : {}),\n\t};\n}\n\n/**\n * The manifest as TypeScript source.\n *\n * Pure, so what gets written can be asserted without touching a filesystem.\n */\nexport function manifestModule(\n\tmanifest: ConstructManifest,\n\tbackends: Backends = {},\n): string {\n\treturn `${HEADER}\nexport const manifest = ${serialise(manifest)} as const satisfies ConstructManifest;\n\n/**\n * Where the backends that are *config* rather than declaration resolved to.\n *\n * Recorded because they were being answered twice: once by the build, which\n * registers exactly one cache driver, and once by a deploy config, which told\n * the provisioner something else. The result was a deployed URL the running code\n * had no driver for — two documents disagreeing about one fact, which is what\n * this manifest exists to stop.\n */\nexport const backends = ${serialise(backends)} as const;\n\n// Derived types\nexport type Ids = IdsOf<typeof manifest>;\nexport type Construct<Id extends Ids> = DeclarationOf<typeof manifest, Id>;\nexport type Kind = Construct<Ids>['kind'];\n\n// Useful union types\nexport type ProvidedKeys = AllProvidedKeys<typeof manifest>;\nexport type Surfaces = IdsOfKind<typeof manifest, 'rest-api'>;\nexport type CacheBackend = (typeof backends)['cache'];\nexport type EmailBackend = (typeof backends)['email'];\n`;\n}\n\n/** Write it where the deploy config expects to import it from. */\nexport async function writeManifestModule(\n\tmanifest: ConstructManifest,\n\tappRoot: string,\n\tbackends: Backends = {},\n): Promise<string> {\n\tconst path = join(appRoot, MANIFEST_PATH);\n\n\tawait mkdir(dirname(path), { recursive: true });\n\tawait writeFile(path, manifestModule(manifest, backends), 'utf8');\n\n\treturn path;\n}\n\n/** The choices that are deployment config rather than declaration. */\nexport interface Backends {\n\tcache?: CacheBackend;\n\temail?: EmailBackend;\n}\n\nconst HEADER = `// Generated by \\`gkm build\\`. Do not edit.\n//\n// Discovery imports application code, so it runs once here rather than in every\n// consumer — a deploy config that discovered for itself would evaluate the whole\n// runtime graph inside its own toolchain. This is the result, as literals.\n\nimport type {\n\tAllProvidedKeys,\n\tConstructManifest,\n\tDeclarationOf,\n\tIdsOf,\n\tIdsOfKind,\n} from '@geekmidas/manifest';\n`;\n\n/**\n * JSON, re-indented with tabs and with keys left unquoted where they can be.\n *\n * Cosmetic, and worth it: this file is read by people trying to work out what\n * their app declares, and a wall of quoted keys reads as output rather than as\n * something anyone is expected to understand.\n */\nfunction serialise(value: object): string {\n\treturn JSON.stringify(value, null, '\\t')\n\t\t.replace(/^(\\t*)\"([A-Za-z_$][\\w$]*)\":/gm, '$1$2:')\n\t\t.replace(/\"/g, \"'\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B7B,SAAgB,WACf,UACA,QACA,SACoB;CACpB,IAAI,OAAO,WAAW,KAAK,CAAC,QAAQ,UAAU,OAAO;CAErD,MAAM,SAAS,OAAO,QAAQ,QAAQ,CAAC,CAAC,MACtC,GAAG,iBACH,YAAY,SAAS,cAAc,YAAY,UAAU,WAAW,CACtE;CAEA,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,CAAC,IAAI,eAAe;CAC1B,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