@geekmidas/constructs 9.0.2 → 10.0.0-alpha.1

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 (385) hide show
  1. package/README.md +71 -44
  2. package/dist/{AWSScheduledFunction-Bn99MceY.d.cts → AWSScheduledFunction-9bJS4WdJ.d.cts} +8 -3
  3. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-9bJS4WdJ.d.cts.map} +1 -1
  4. package/dist/{AWSScheduledFunction-CufMMhGB.mjs → AWSScheduledFunction-BJjj8B5V.mjs} +3 -3
  5. package/dist/{AWSScheduledFunction-CufMMhGB.mjs.map → AWSScheduledFunction-BJjj8B5V.mjs.map} +1 -1
  6. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-BO5iEMSh.d.mts} +9 -4
  7. package/dist/{AWSScheduledFunction-Bn99MceY.d.cts.map → AWSScheduledFunction-BO5iEMSh.d.mts.map} +1 -1
  8. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs → AWSScheduledFunction-qu4ieRZR.cjs} +9 -9
  9. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs.map → AWSScheduledFunction-qu4ieRZR.cjs.map} +1 -1
  10. package/dist/{Construct-_1wX7p_Y.d.cts → Construct-B-xc0SE9.d.mts} +27 -5
  11. package/dist/Construct-B-xc0SE9.d.mts.map +1 -0
  12. package/dist/{Construct-r0U2zBwW.mjs → Construct-CdhThxDI.mjs} +3 -2
  13. package/dist/Construct-CdhThxDI.mjs.map +1 -0
  14. package/dist/{Construct-DCMuYOox.d.mts → Construct-WhCXIOPV.d.cts} +29 -7
  15. package/dist/Construct-WhCXIOPV.d.cts.map +1 -0
  16. package/dist/{Construct-vXMZJgRp.cjs → Construct-roId57cU.cjs} +7 -43
  17. package/dist/Construct-roId57cU.cjs.map +1 -0
  18. package/dist/{lazyAccessors-DmTG8sQH.cjs → Endpoint-BBkV6l0k.cjs} +869 -1079
  19. package/dist/Endpoint-BBkV6l0k.cjs.map +1 -0
  20. package/dist/{Endpoint-DgfRslct.d.cts → Endpoint-BKR5QH6O.d.mts} +57 -8
  21. package/dist/Endpoint-BKR5QH6O.d.mts.map +1 -0
  22. package/dist/{Endpoint-CLPSIl6S.d.mts → Endpoint-BQ9O0P1w.d.cts} +58 -9
  23. package/dist/Endpoint-BQ9O0P1w.d.cts.map +1 -0
  24. package/dist/{lazyAccessors-DfqZR6C4.mjs → Endpoint-BTj58Gob.mjs} +840 -1003
  25. package/dist/Endpoint-BTj58Gob.mjs.map +1 -0
  26. package/dist/EndpointFactory-BejSTzbB.mjs +808 -0
  27. package/dist/EndpointFactory-BejSTzbB.mjs.map +1 -0
  28. package/dist/EndpointFactory-DYoGLaIT.cjs +850 -0
  29. package/dist/EndpointFactory-DYoGLaIT.cjs.map +1 -0
  30. package/dist/{HonoEndpointAdaptor-DJDT3PMx.mjs → HonoEndpointAdaptor-7aYNdqJq.mjs} +5 -4
  31. package/dist/HonoEndpointAdaptor-7aYNdqJq.mjs.map +1 -0
  32. package/dist/{HonoEndpointAdaptor-CkJENANP.cjs → HonoEndpointAdaptor-wMsCyMgt.cjs} +24 -23
  33. package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +1 -0
  34. package/dist/{Queue-DaxjwmOQ.d.cts → Queue-D6WeziRD.d.cts} +43 -4
  35. package/dist/Queue-D6WeziRD.d.cts.map +1 -0
  36. package/dist/{Queue-HBDf0fqz.d.mts → Queue-DpUeqdC8.d.mts} +43 -4
  37. package/dist/Queue-DpUeqdC8.d.mts.map +1 -0
  38. package/dist/{Subscriber-B69ngPwl.d.cts → Subscriber-4rBJgDKI.d.mts} +9 -4
  39. package/dist/{Subscriber-B69ngPwl.d.cts.map → Subscriber-4rBJgDKI.d.mts.map} +1 -1
  40. package/dist/{Subscriber-D8Xm-86W.d.mts → Subscriber-DVQowdyj.d.cts} +11 -6
  41. package/dist/Subscriber-DVQowdyj.d.cts.map +1 -0
  42. package/dist/{Topic-C5ZMfveW.d.cts → Topic-Ohx9dvWr.d.cts} +33 -2
  43. package/dist/Topic-Ohx9dvWr.d.cts.map +1 -0
  44. package/dist/{Topic-DT10AqHk.d.mts → Topic-cmy2jOUy.d.mts} +33 -2
  45. package/dist/Topic-cmy2jOUy.d.mts.map +1 -0
  46. package/dist/adaptors/aws.cjs +39 -26
  47. package/dist/adaptors/aws.cjs.map +1 -1
  48. package/dist/adaptors/aws.d.cts +24 -16
  49. package/dist/adaptors/aws.d.cts.map +1 -1
  50. package/dist/adaptors/aws.d.mts +25 -17
  51. package/dist/adaptors/aws.d.mts.map +1 -1
  52. package/dist/adaptors/aws.mjs +26 -14
  53. package/dist/adaptors/aws.mjs.map +1 -1
  54. package/dist/adaptors/hono.cjs +9 -6
  55. package/dist/adaptors/hono.d.cts +7 -6
  56. package/dist/adaptors/hono.d.cts.map +1 -1
  57. package/dist/adaptors/hono.d.mts +8 -7
  58. package/dist/adaptors/hono.d.mts.map +1 -1
  59. package/dist/adaptors/hono.mjs +9 -6
  60. package/dist/adaptors/testing.cjs +18 -14
  61. package/dist/adaptors/testing.cjs.map +1 -1
  62. package/dist/adaptors/testing.d.cts +7 -6
  63. package/dist/adaptors/testing.d.cts.map +1 -1
  64. package/dist/adaptors/testing.d.mts +11 -10
  65. package/dist/adaptors/testing.d.mts.map +1 -1
  66. package/dist/adaptors/testing.mjs +10 -7
  67. package/dist/adaptors/testing.mjs.map +1 -1
  68. package/dist/auth.cjs +165 -0
  69. package/dist/auth.cjs.map +1 -0
  70. package/dist/auth.d.cts +108 -0
  71. package/dist/auth.d.cts.map +1 -0
  72. package/dist/auth.d.mts +108 -0
  73. package/dist/auth.d.mts.map +1 -0
  74. package/dist/auth.mjs +164 -0
  75. package/dist/auth.mjs.map +1 -0
  76. package/dist/cache-0ANvRQnD.mjs +51 -0
  77. package/dist/cache-0ANvRQnD.mjs.map +1 -0
  78. package/dist/cache-3WSvAulx.cjs +57 -0
  79. package/dist/cache-3WSvAulx.cjs.map +1 -0
  80. package/dist/cache-CdQ7OLpR.d.cts +47 -0
  81. package/dist/cache-CdQ7OLpR.d.cts.map +1 -0
  82. package/dist/cache-DYoJFcfd.d.mts +47 -0
  83. package/dist/cache-DYoJFcfd.d.mts.map +1 -0
  84. package/dist/cache.cjs +3 -0
  85. package/dist/cache.d.cts +3 -0
  86. package/dist/cache.d.mts +3 -0
  87. package/dist/cache.mjs +3 -0
  88. package/dist/chunk-DWy1uDak.cjs +39 -0
  89. package/dist/clone-DblgEZZa.mjs +39 -0
  90. package/dist/clone-DblgEZZa.mjs.map +1 -0
  91. package/dist/clone-Dy0cR2SZ.cjs +45 -0
  92. package/dist/clone-Dy0cR2SZ.cjs.map +1 -0
  93. package/dist/construct-interface-BfjcOD_E.cjs +117 -0
  94. package/dist/construct-interface-BfjcOD_E.cjs.map +1 -0
  95. package/dist/construct-interface-BqwRNYA2.d.mts +131 -0
  96. package/dist/construct-interface-BqwRNYA2.d.mts.map +1 -0
  97. package/dist/construct-interface-D2nNkHUN.d.cts +131 -0
  98. package/dist/construct-interface-D2nNkHUN.d.cts.map +1 -0
  99. package/dist/construct-interface-Z4CpS8tK.mjs +81 -0
  100. package/dist/construct-interface-Z4CpS8tK.mjs.map +1 -0
  101. package/dist/construct-interface.cjs +8 -0
  102. package/dist/construct-interface.d.cts +2 -0
  103. package/dist/construct-interface.d.mts +2 -0
  104. package/dist/construct-interface.mjs +3 -0
  105. package/dist/credential.cjs +96 -0
  106. package/dist/credential.cjs.map +1 -0
  107. package/dist/credential.d.cts +61 -0
  108. package/dist/credential.d.cts.map +1 -0
  109. package/dist/credential.d.mts +61 -0
  110. package/dist/credential.d.mts.map +1 -0
  111. package/dist/credential.mjs +94 -0
  112. package/dist/credential.mjs.map +1 -0
  113. package/dist/crons/index.cjs +39 -37
  114. package/dist/crons/index.cjs.map +1 -1
  115. package/dist/crons/index.d.cts +21 -8
  116. package/dist/crons/index.d.cts.map +1 -1
  117. package/dist/crons/index.d.mts +29 -13
  118. package/dist/crons/index.d.mts.map +1 -1
  119. package/dist/crons/index.mjs +37 -36
  120. package/dist/crons/index.mjs.map +1 -1
  121. package/dist/database/kysely.cjs +181 -0
  122. package/dist/database/kysely.cjs.map +1 -0
  123. package/dist/database/kysely.d.cts +152 -0
  124. package/dist/database/kysely.d.cts.map +1 -0
  125. package/dist/database/kysely.d.mts +152 -0
  126. package/dist/database/kysely.d.mts.map +1 -0
  127. package/dist/database/kysely.mjs +180 -0
  128. package/dist/database/kysely.mjs.map +1 -0
  129. package/dist/email.cjs +59 -0
  130. package/dist/email.cjs.map +1 -0
  131. package/dist/email.d.cts +50 -0
  132. package/dist/email.d.cts.map +1 -0
  133. package/dist/email.d.mts +50 -0
  134. package/dist/email.d.mts.map +1 -0
  135. package/dist/email.mjs +58 -0
  136. package/dist/email.mjs.map +1 -0
  137. package/dist/endpoints/index.cjs +21 -747
  138. package/dist/endpoints/index.d.cts +7 -343
  139. package/dist/endpoints/index.d.mts +7 -342
  140. package/dist/endpoints/index.mjs +11 -738
  141. package/dist/file-server.cjs +154 -0
  142. package/dist/file-server.cjs.map +1 -0
  143. package/dist/file-server.d.cts +156 -0
  144. package/dist/file-server.d.cts.map +1 -0
  145. package/dist/file-server.d.mts +156 -0
  146. package/dist/file-server.d.mts.map +1 -0
  147. package/dist/file-server.mjs +152 -0
  148. package/dist/file-server.mjs.map +1 -0
  149. package/dist/functions/index.cjs +4 -2
  150. package/dist/functions/index.d.cts +3 -2
  151. package/dist/functions/index.d.mts +3 -2
  152. package/dist/functions/index.mjs +4 -2
  153. package/dist/{functions-B-qt91O7.mjs → functions-Cpff1uZH.mjs} +55 -51
  154. package/dist/functions-Cpff1uZH.mjs.map +1 -0
  155. package/dist/{functions-C8i1kCMM.cjs → functions-DukjG8ov.cjs} +62 -57
  156. package/dist/functions-DukjG8ov.cjs.map +1 -0
  157. package/dist/{index-BVs9DvIj.d.cts → index-BTvozlUD.d.cts} +36 -9
  158. package/dist/index-BTvozlUD.d.cts.map +1 -0
  159. package/dist/index-Cvz551AO.d.mts +419 -0
  160. package/dist/index-Cvz551AO.d.mts.map +1 -0
  161. package/dist/index-D5zqAJ2e.d.cts +419 -0
  162. package/dist/index-D5zqAJ2e.d.cts.map +1 -0
  163. package/dist/{index-DP6fqv0I.d.mts → index-L7pz0R0T.d.mts} +48 -19
  164. package/dist/index-L7pz0R0T.d.mts.map +1 -0
  165. package/dist/index.cjs +1 -1
  166. package/dist/index.d.cts +3 -3
  167. package/dist/index.d.mts +3 -3
  168. package/dist/index.mjs +1 -1
  169. package/dist/lazyAccessors-DM6HcXQk.mjs +175 -0
  170. package/dist/lazyAccessors-DM6HcXQk.mjs.map +1 -0
  171. package/dist/lazyAccessors-DrJj8NpA.cjs +223 -0
  172. package/dist/lazyAccessors-DrJj8NpA.cjs.map +1 -0
  173. package/dist/object-storage.cjs +48 -0
  174. package/dist/object-storage.cjs.map +1 -0
  175. package/dist/object-storage.d.cts +36 -0
  176. package/dist/object-storage.d.cts.map +1 -0
  177. package/dist/object-storage.d.mts +36 -0
  178. package/dist/object-storage.d.mts.map +1 -0
  179. package/dist/object-storage.mjs +47 -0
  180. package/dist/object-storage.mjs.map +1 -0
  181. package/dist/{processAudits-CKjjivyz.cjs → processAudits-Bc8rz6Ev.cjs} +3 -3
  182. package/dist/{processAudits-CKjjivyz.cjs.map → processAudits-Bc8rz6Ev.cjs.map} +1 -1
  183. package/dist/{processAudits-ySnizdMG.mjs → processAudits-D89tICM4.mjs} +1 -1
  184. package/dist/{processAudits-ySnizdMG.mjs.map → processAudits-D89tICM4.mjs.map} +1 -1
  185. package/dist/{publisher-BrFOF847.mjs → publisher-CGEo8UKD.mjs} +1 -1
  186. package/dist/{publisher-BrFOF847.mjs.map → publisher-CGEo8UKD.mjs.map} +1 -1
  187. package/dist/{publisher-lFQleddL.cjs → publisher-CqGsXB2X.cjs} +1 -1
  188. package/dist/{publisher-lFQleddL.cjs.map → publisher-CqGsXB2X.cjs.map} +1 -1
  189. package/dist/queue/index.cjs +92 -30
  190. package/dist/queue/index.cjs.map +1 -1
  191. package/dist/queue/index.d.cts +19 -4
  192. package/dist/queue/index.d.cts.map +1 -1
  193. package/dist/queue/index.d.mts +22 -6
  194. package/dist/queue/index.d.mts.map +1 -1
  195. package/dist/queue/index.mjs +90 -29
  196. package/dist/queue/index.mjs.map +1 -1
  197. package/dist/rest-api.cjs +187 -0
  198. package/dist/rest-api.cjs.map +1 -0
  199. package/dist/rest-api.d.cts +221 -0
  200. package/dist/rest-api.d.cts.map +1 -0
  201. package/dist/rest-api.d.mts +221 -0
  202. package/dist/rest-api.d.mts.map +1 -0
  203. package/dist/rest-api.mjs +186 -0
  204. package/dist/rest-api.mjs.map +1 -0
  205. package/dist/site.cjs +48 -0
  206. package/dist/site.cjs.map +1 -0
  207. package/dist/site.d.cts +101 -0
  208. package/dist/site.d.cts.map +1 -0
  209. package/dist/site.d.mts +101 -0
  210. package/dist/site.d.mts.map +1 -0
  211. package/dist/site.mjs +47 -0
  212. package/dist/site.mjs.map +1 -0
  213. package/dist/subscribers/index.cjs +35 -27
  214. package/dist/subscribers/index.cjs.map +1 -1
  215. package/dist/subscribers/index.d.cts +20 -5
  216. package/dist/subscribers/index.d.cts.map +1 -1
  217. package/dist/subscribers/index.d.mts +23 -7
  218. package/dist/subscribers/index.d.mts.map +1 -1
  219. package/dist/subscribers/index.mjs +34 -27
  220. package/dist/subscribers/index.mjs.map +1 -1
  221. package/dist/surfaceEnv-BFXEms2f.cjs +39 -0
  222. package/dist/surfaceEnv-BFXEms2f.cjs.map +1 -0
  223. package/dist/surfaceEnv-C3Ktahea.mjs +27 -0
  224. package/dist/surfaceEnv-C3Ktahea.mjs.map +1 -0
  225. package/dist/{telemetry-3vdxGn4q.d.mts → telemetry-C3L0iS28.d.cts} +2 -2
  226. package/dist/{telemetry-3vdxGn4q.d.mts.map → telemetry-C3L0iS28.d.cts.map} +1 -1
  227. package/dist/{telemetry-Dqx-D3F7.d.cts → telemetry-D7bVFLGi.d.mts} +2 -2
  228. package/dist/{telemetry-Dqx-D3F7.d.cts.map → telemetry-D7bVFLGi.d.mts.map} +1 -1
  229. package/dist/topic/index.cjs +56 -13
  230. package/dist/topic/index.cjs.map +1 -1
  231. package/dist/topic/index.d.cts +2 -2
  232. package/dist/topic/index.d.cts.map +1 -1
  233. package/dist/topic/index.d.mts +2 -2
  234. package/dist/topic/index.d.mts.map +1 -1
  235. package/dist/topic/index.mjs +54 -12
  236. package/dist/topic/index.mjs.map +1 -1
  237. package/dist/{types-BDNGr7pv.d.mts → types-BlAkSuGI.d.cts} +1 -1
  238. package/dist/{types-BDNGr7pv.d.mts.map → types-BlAkSuGI.d.cts.map} +1 -1
  239. package/dist/{types-BdAaYDvd.d.cts → types-aKksMEWL.d.mts} +1 -1
  240. package/dist/{types-BdAaYDvd.d.cts.map → types-aKksMEWL.d.mts.map} +1 -1
  241. package/dist/types.d.cts +1 -1
  242. package/dist/types.d.mts +1 -1
  243. package/package.json +155 -23
  244. package/CHANGELOG.md +0 -396
  245. package/dist/Construct-DCMuYOox.d.mts.map +0 -1
  246. package/dist/Construct-_1wX7p_Y.d.cts.map +0 -1
  247. package/dist/Construct-r0U2zBwW.mjs.map +0 -1
  248. package/dist/Construct-vXMZJgRp.cjs.map +0 -1
  249. package/dist/Endpoint-CLPSIl6S.d.mts.map +0 -1
  250. package/dist/Endpoint-DgfRslct.d.cts.map +0 -1
  251. package/dist/HonoEndpointAdaptor-CkJENANP.cjs.map +0 -1
  252. package/dist/HonoEndpointAdaptor-DJDT3PMx.mjs.map +0 -1
  253. package/dist/Queue-DaxjwmOQ.d.cts.map +0 -1
  254. package/dist/Queue-HBDf0fqz.d.mts.map +0 -1
  255. package/dist/Subscriber-D8Xm-86W.d.mts.map +0 -1
  256. package/dist/Topic-C5ZMfveW.d.cts.map +0 -1
  257. package/dist/Topic-DT10AqHk.d.mts.map +0 -1
  258. package/dist/endpoints/index.cjs.map +0 -1
  259. package/dist/endpoints/index.d.cts.map +0 -1
  260. package/dist/endpoints/index.d.mts.map +0 -1
  261. package/dist/endpoints/index.mjs.map +0 -1
  262. package/dist/functions-B-qt91O7.mjs.map +0 -1
  263. package/dist/functions-C8i1kCMM.cjs.map +0 -1
  264. package/dist/index-BVs9DvIj.d.cts.map +0 -1
  265. package/dist/index-DP6fqv0I.d.mts.map +0 -1
  266. package/dist/lazyAccessors-DfqZR6C4.mjs.map +0 -1
  267. package/dist/lazyAccessors-DmTG8sQH.cjs.map +0 -1
  268. package/src/Construct.ts +0 -204
  269. package/src/__benchmarks__/build-time-optimization.bench.ts +0 -274
  270. package/src/__benchmarks__/endpoint.bench.ts +0 -494
  271. package/src/__benchmarks__/fixtures.ts +0 -241
  272. package/src/__benchmarks__/hono-adaptor.bench.ts +0 -533
  273. package/src/__benchmarks__/hono-server.bench.ts +0 -249
  274. package/src/__benchmarks__/response-builder.bench.ts +0 -428
  275. package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +0 -319
  276. package/src/__benchmarks__/strategies/strategy-c-middleware.ts +0 -530
  277. package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +0 -567
  278. package/src/__tests__/Construct.environment.spec.ts +0 -704
  279. package/src/__tests__/publisher.setting.spec.ts +0 -508
  280. package/src/__tests__/publisher.spec.ts +0 -452
  281. package/src/adaptors/aws.ts +0 -6
  282. package/src/adaptors/hono.ts +0 -1
  283. package/src/adaptors/testing.ts +0 -11
  284. package/src/crons/AWSScheduledFunction.ts +0 -73
  285. package/src/crons/Cron.ts +0 -149
  286. package/src/crons/CronBuilder.ts +0 -271
  287. package/src/crons/__tests__/AWSScheduledFunction.spec.ts +0 -152
  288. package/src/crons/__tests__/Cron.spec.ts +0 -464
  289. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +0 -227
  290. package/src/crons/index.ts +0 -12
  291. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +0 -677
  292. package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +0 -105
  293. package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +0 -97
  294. package/src/endpoints/Authorizer.ts +0 -152
  295. package/src/endpoints/Endpoint.ts +0 -1287
  296. package/src/endpoints/EndpointBuilder.ts +0 -758
  297. package/src/endpoints/EndpointFactory.ts +0 -1148
  298. package/src/endpoints/HonoEndpointAdaptor.ts +0 -677
  299. package/src/endpoints/MswEndpointAdaptor.ts +0 -226
  300. package/src/endpoints/TestEndpointAdaptor.ts +0 -422
  301. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +0 -499
  302. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +0 -560
  303. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +0 -1304
  304. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +0 -626
  305. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +0 -732
  306. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +0 -296
  307. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +0 -951
  308. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +0 -111
  309. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +0 -307
  310. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +0 -629
  311. package/src/endpoints/__tests__/Authorizer.spec.ts +0 -286
  312. package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +0 -207
  313. package/src/endpoints/__tests__/Endpoint.headers.spec.ts +0 -187
  314. package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +0 -175
  315. package/src/endpoints/__tests__/Endpoint.spec.ts +0 -857
  316. package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +0 -448
  317. package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +0 -47
  318. package/src/endpoints/__tests__/EndpointBuilder.spec.ts +0 -523
  319. package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +0 -492
  320. package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +0 -509
  321. package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +0 -190
  322. package/src/endpoints/__tests__/EndpointFactory.spec.ts +0 -479
  323. package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +0 -155
  324. package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +0 -703
  325. package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +0 -632
  326. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +0 -577
  327. package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +0 -1067
  328. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +0 -317
  329. package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +0 -289
  330. package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +0 -128
  331. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +0 -1207
  332. package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +0 -211
  333. package/src/endpoints/__tests__/ResponseBuilder.spec.ts +0 -235
  334. package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +0 -602
  335. package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +0 -1044
  336. package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +0 -54
  337. package/src/endpoints/__tests__/endpoint-types.test.ts +0 -88
  338. package/src/endpoints/__tests__/helpers.spec.ts +0 -37
  339. package/src/endpoints/__tests__/lazyAccessors.spec.ts +0 -330
  340. package/src/endpoints/__tests__/processAudits.spec.ts +0 -631
  341. package/src/endpoints/audit.ts +0 -87
  342. package/src/endpoints/helpers.ts +0 -98
  343. package/src/endpoints/index.ts +0 -42
  344. package/src/endpoints/lazyAccessors.ts +0 -241
  345. package/src/endpoints/parseHonoQuery.ts +0 -16
  346. package/src/endpoints/parseQueryParams.ts +0 -32
  347. package/src/endpoints/processAudits.ts +0 -371
  348. package/src/endpoints/rls.ts +0 -67
  349. package/src/functions/AWSLambdaFunction.ts +0 -348
  350. package/src/functions/BaseFunctionBuilder.ts +0 -201
  351. package/src/functions/Function.ts +0 -238
  352. package/src/functions/FunctionBuilder.ts +0 -391
  353. package/src/functions/FunctionExecutionWrapper.ts +0 -216
  354. package/src/functions/TestFunctionAdaptor.ts +0 -217
  355. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +0 -513
  356. package/src/functions/__tests__/Function.audits.spec.ts +0 -393
  357. package/src/functions/__tests__/Function.spec.ts +0 -477
  358. package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +0 -207
  359. package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +0 -480
  360. package/src/functions/index.ts +0 -12
  361. package/src/index.ts +0 -23
  362. package/src/publisher.ts +0 -93
  363. package/src/queue/AWSLambdaQueueAdaptor.ts +0 -162
  364. package/src/queue/Queue.ts +0 -128
  365. package/src/queue/QueueBuilder.ts +0 -115
  366. package/src/queue/TestQueueAdaptor.ts +0 -63
  367. package/src/queue/__tests__/QueueBuilder.spec.ts +0 -137
  368. package/src/queue/index.ts +0 -12
  369. package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +0 -342
  370. package/src/subscribers/Subscriber.ts +0 -117
  371. package/src/subscribers/SubscriberBuilder.ts +0 -186
  372. package/src/subscribers/TestSubscriberAdaptor.ts +0 -133
  373. package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +0 -1018
  374. package/src/subscribers/__tests__/Subscriber.spec.ts +0 -430
  375. package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +0 -652
  376. package/src/subscribers/index.ts +0 -6
  377. package/src/telemetry.ts +0 -103
  378. package/src/topic/Topic.ts +0 -103
  379. package/src/topic/TopicBuilder.ts +0 -51
  380. package/src/topic/__tests__/TopicBuilder.spec.ts +0 -82
  381. package/src/topic/index.ts +0 -11
  382. package/src/types.ts +0 -13
  383. package/test.ts +0 -91
  384. package/tsconfig.json +0 -9
  385. package/tsdown.config.ts +0 -34
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["DEFAULT_LOGGER","ConsoleLogger","Construct","obj: unknown","ConstructType","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","batchSize?: number","fifo?: boolean","DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import { environmentCase } from '@geekmidas/envkit';\nimport {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\nconst DEFAULT_LOGGER = new ConsoleLogger() as unknown as Logger;\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t);\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\tthis._name = name;\n\t\treturn this as unknown as QueueBuilder<T, TMessage, TServices, TLogger>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\tthis._timeout = timeout;\n\t\treturn this;\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\tthis._batchSize = batchSize;\n\t\treturn this;\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\tthis._fifo = fifo;\n\t\treturn this;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\tthis._services = [...this._services, ...services] as unknown as TServices;\n\t\treturn this as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\tthis._logger = logger as unknown as TLogger;\n\t\treturn this as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\tthis._messageSchema = schema as unknown as TMessage;\n\t\treturn this as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t);\n\n\t\t// Reset builder state to prevent pollution across reuse.\n\t\tthis._name = undefined;\n\t\tthis._messageSchema = undefined;\n\t\tthis._timeout = 30000;\n\t\tthis._batchSize = undefined;\n\t\tthis._fifo = undefined;\n\t\tthis._services = [] as Service[] as TServices;\n\t\tthis._logger = DEFAULT_LOGGER as TLogger;\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;AAcA,MAAMA,mBAAiB,IAAIC;;;;;;;;;;AAsB3B,IAAa,QAAb,cAKUC,4BAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAASC,gCAAc,MAC3C;CACD;CAED,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBV,kBAE3BW,WAEAC,MACf;AACD,QACCR,gCAAc,OACd,QACA,UACA,CAAE,mBAGF,QACA;EAnBe;EACA;EACA;EACS;EACA;EACA;EAET;EAEA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AAEf,SAAO;CACP;AACD;;;;ACvGD,MAAa,IAAI,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":["Construct","obj: unknown","ConstructType","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","DEFAULT_LOGGER","batchSize?: number","fifo?: boolean","constructs: string[]","DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","constructs: T","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and\n\t * {@link publisher}, so what the target publishes and what the producer\n\t * looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves\n\t * into, reachable as `services.emails`.\n\t *\n\t * It is the producer: a consumer is the worker written right here, so the\n\t * only thing another construct can want from a queue is the ability to send\n\t * to it. {@link publisher} is the same service under its older\n\t * `<name>Publisher` key, kept for `.services([queue.publisher])`.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,IAAa,QAAb,cAKUA,4BAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAASC,gCAAc,MAC3C;CACD;;;;;;;;;CAUD,AAAS;;;;;;CAOT,AAAiB;CAEjB,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBC,2CAE3BC,WAEAC,MAKhBC,aAAuB,CAAE,GACxB;AACD,QACCV,gCAAc,OACd,QACA,UACA,CAAE,mBAGF,yBAGA,WAC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;;CAGD,KAAK,OAAO,MAAY;AACvB,SAAO,wBAAU,MAAM,EAAE,OAAO,KAAM,EAAC;CACvC;;;;;;;;;;;;CAaD,UACCC,YAC2E;EAQ3E,MAAM,WAAW,uCAAW,WAAW;AAEvC,SAAO,wBAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS;GAC3C,aAAa,kCAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAMF;CAED,SACCC,UAC+D;AAC/D,SAAO,wBAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CAMF;CAED,OACCC,QAC8C;AAC9C,SAAO,wBAAU,MAAM,EACtB,SAAS,OACT,EAAC;CACF;;CAGD,QACCC,QAC6C;AAC7C,SAAO,wBAAU,MAAM,EACtB,gBAAgB,OAChB,EAAC;CACF;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAI,MACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK;AASN,SAAO;CACP;AACD;;;;ACpJD,MAAa,IAAI,IAAI"}
@@ -1,6 +1,7 @@
1
- import "../Construct-_1wX7p_Y.cjs";
2
- import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-DaxjwmOQ.cjs";
3
- import * as _geekmidas_logger5 from "@geekmidas/logger";
1
+ import "../Construct-WhCXIOPV.cjs";
2
+ import { Consumable, ServicesOf } from "../construct-interface-D2nNkHUN.cjs";
3
+ import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-D6WeziRD.cjs";
4
+ import * as _geekmidas_logger15 from "@geekmidas/logger";
4
5
  import { Logger } from "@geekmidas/logger";
5
6
  import { Service } from "@geekmidas/services";
6
7
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -20,6 +21,8 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
20
21
  private _batchSize?;
21
22
  private _fifo?;
22
23
  private _services;
24
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
25
+ _constructs: string[];
23
26
  private _logger;
24
27
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
25
28
  queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger>;
@@ -28,6 +31,18 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
28
31
  batchSize(batchSize: number): this;
29
32
  /** Mark the queue as FIFO (deployed). */
30
33
  fifo(fifo?: boolean): this;
34
+ /**
35
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
36
+ * topic.
37
+ *
38
+ * It records the edge and dissolves each construct's client into the
39
+ * handler's service record under the construct's own id, so
40
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
41
+ *
42
+ * Constructs only. A `Service` does not match the shape, which is what keeps
43
+ * env sniffing confined to `.services()` and the explicit lift.
44
+ */
45
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
31
46
  services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
32
47
  logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
33
48
  /** The typed message (job) payload the queue carries. */
@@ -37,7 +52,7 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
37
52
  //# sourceMappingURL=QueueBuilder.d.ts.map
38
53
  //#endregion
39
54
  //#region src/queue/index.d.ts
40
- declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger5.Logger>;
55
+ declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger15.Logger>;
41
56
  //# sourceMappingURL=index.d.ts.map
42
57
 
43
58
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],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,OAeH,EAAA,CAAA,CAAA,QAAA,EAdL,CAcK,CAAA,EAbb,YAaa,CAbA,KAaA,EAbO,QAaP,EAAA,CAAA,GAbqB,SAarB,EAAA,GAbmC,CAanC,CAAA,EAbuC,OAavC,CAAA;EAAK,MAAE,CAAA,UAFN,MAEM,CAAA,CAAA,MAAA,EADd,CACc,CAAA,EAApB,YAAoB,CAAP,KAAO,EAAA,QAAA,EAAU,SAAV,EAAqB,CAArB,CAAA;EAAQ;EAAW,OAAE,CAAA,UAO1B,gBAP0B,CAAA,CAAA,MAAA,EAQnC,CARmC,CAAA,EASzC,YATyC,CAS5B,KAT4B,EASrB,CATqB,EASlB,SATkB,EASP,OATO,CAAA;EAAC,MAA1C,CAAA,EAAA,EAgBE,YAhBF,CAgBe,WAhBf,CAgB2B,QAhB3B,CAAA,EAgBsC,SAhBtC,EAgBiD,OAhBjD,CAAA,CAAA,EAiBA,KAjBA,CAiBM,KAjBN,EAiBa,WAjBb,CAiByB,QAjBzB,CAAA,EAiBoC,SAjBpC,EAiB+C,OAjB/C,CAAA;;;;;cCnGS,GAAC,oCAAqB,mBAAA,CAArB,MAAA"}
@@ -1,7 +1,9 @@
1
- import "../Construct-DCMuYOox.mjs";
2
- import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-HBDf0fqz.mjs";
1
+ import "../Construct-B-xc0SE9.mjs";
2
+ import { Consumable, ServicesOf } from "../construct-interface-BqwRNYA2.mjs";
3
+ import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-DpUeqdC8.mjs";
3
4
  import { Service } from "@geekmidas/services";
4
- import { Logger as Logger$1 } from "@geekmidas/logger";
5
+ import * as _geekmidas_logger17 from "@geekmidas/logger";
6
+ import { Logger } from "@geekmidas/logger";
5
7
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
8
 
7
9
  //#region src/queue/QueueBuilder.d.ts
@@ -12,13 +14,15 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
12
14
  * job payload; `handle` is the single consumer. The queue name is captured as a
13
15
  * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
14
16
  */
15
- declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger$1 = Logger$1> {
17
+ declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> {
16
18
  private _name?;
17
19
  private _messageSchema?;
18
20
  private _timeout;
19
21
  private _batchSize?;
20
22
  private _fifo?;
21
23
  private _services;
24
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
25
+ _constructs: string[];
22
26
  private _logger;
23
27
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
24
28
  queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger>;
@@ -27,8 +31,20 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
27
31
  batchSize(batchSize: number): this;
28
32
  /** Mark the queue as FIFO (deployed). */
29
33
  fifo(fifo?: boolean): this;
34
+ /**
35
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
36
+ * topic.
37
+ *
38
+ * It records the edge and dissolves each construct's client into the
39
+ * handler's service record under the construct's own id, so
40
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
41
+ *
42
+ * Constructs only. A `Service` does not match the shape, which is what keeps
43
+ * env sniffing confined to `.services()` and the explicit lift.
44
+ */
45
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
30
46
  services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
31
- logger<T extends Logger$1>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
47
+ logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
32
48
  /** The typed message (job) payload the queue carries. */
33
49
  message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger>;
34
50
  handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>): Queue<TName, NonNullable<TMessage>, TServices, TLogger>;
@@ -36,7 +52,7 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
36
52
  //# sourceMappingURL=QueueBuilder.d.ts.map
37
53
  //#endregion
38
54
  //#region src/queue/index.d.ts
39
- declare const q: QueueBuilder<string, undefined, [], Logger>;
55
+ declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger17.Logger>;
40
56
  //# sourceMappingURL=index.d.ts.map
41
57
 
42
58
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAYA;;;AAGmB,cAHN,YAGM,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,iBADD,gBACC,GAAA,SAAA,GAAA,SAAA,EAAA,kBAAA,OAAA,EAAA,GAAA,EAAA,EAAA,gBACF,QADE,GACO,QADP,CAAA,CAAA;EAAO,QACT,KAAA;EAAM,QAAG,cAAA;EAAM,QAYxB,QAAA;EAAC,QACQ,UAAA;EAAC,QAAE,KAAA;EAAQ,QAAE,SAAA;EAAS,QAAE,OAAA;EAAO;EAAhC,KAsBI,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EAvBZ,CAuBY,CAAA,EAtBhB,YAsBgB,CAtBH,CAsBG,EAtBA,QAsBA,EAtBU,SAsBV,EAtBqB,OAsBrB,CAAA;EAAO,OACf,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAC;EACS,SAAE,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAQ;EAAe,IAAK,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAC,QAAG,CAAA,UAFpC,OAEoC,EAAA,CAAA,CAAA,QAAA,EAD5C,CAC4C,CAAA,EAApD,YAAoD,CAAvC,KAAuC,EAAhC,QAAgC,EAA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K;EAAU,SAAM,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAS;EAAiB,IAAZ,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAU;;;;;;;;;;;EAkCtC,SACd,CAAA,gBAAA,SArC0B,UAqC1B,EAAA,CAAA,CAAA,UAAA,EApCI,CAoCJ,CAAA,EAnCN,YAmCM,CAnCO,KAmCP,EAnCc,QAmCd,EAAA,CAAA,GAnC4B,SAmC5B,EAAA,GAnC0C,UAmC1C,CAnCqD,CAmCrD,CAAA,CAAA,EAnC0D,OAmC1D,CAAA;EAAC,QACM,CAAA,UAfG,OAeH,EAAA,CAAA,CAAA,QAAA,EAdL,CAcK,CAAA,EAbb,YAaa,CAbA,KAaA,EAbO,QAaP,EAAA,CAAA,GAbqB,SAarB,EAAA,GAbmC,CAanC,CAAA,EAbuC,OAavC,CAAA;EAAK,MAAE,CAAA,UAFN,MAEM,CAAA,CAAA,MAAA,EADd,CACc,CAAA,EAApB,YAAoB,CAAP,KAAO,EAAA,QAAA,EAAU,SAAV,EAAqB,CAArB,CAAA;EAAQ;EAAW,OAAE,CAAA,UAO1B,gBAP0B,CAAA,CAAA,MAAA,EAQnC,CARmC,CAAA,EASzC,YATyC,CAS5B,KAT4B,EASrB,CATqB,EASlB,SATkB,EASP,OATO,CAAA;EAAC,MAA1C,CAAA,EAAA,EAgBE,YAhBF,CAgBe,WAhBf,CAgB2B,QAhB3B,CAAA,EAgBsC,SAhBtC,EAgBiD,OAhBjD,CAAA,CAAA,EAiBA,KAjBA,CAiBM,KAjBN,EAiBa,WAjBb,CAiByB,QAjBzB,CAAA,EAiBoC,SAjBpC,EAiB+C,OAjB/C,CAAA;;;;;cCnGS,GAAC,oCAAqB,mBAAA,CAArB,MAAA"}
@@ -1,10 +1,11 @@
1
- import { Construct, ConstructType } from "../Construct-r0U2zBwW.mjs";
2
- import { ConsoleLogger, DEFAULT_LOGGER } from "@geekmidas/logger/console";
3
- import { environmentCase } from "@geekmidas/envkit";
1
+ import { Construct, ConstructType } from "../Construct-CdhThxDI.mjs";
2
+ import { idsOf, servicesOf } from "../construct-interface-Z4CpS8tK.mjs";
3
+ import { cloneWith } from "../clone-DblgEZZa.mjs";
4
+ import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
5
+ import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
4
6
  import { Publisher } from "@geekmidas/events";
5
7
 
6
8
  //#region src/queue/Queue.ts
7
- const DEFAULT_LOGGER$1 = new ConsoleLogger();
8
9
  /**
9
10
  * A queue worker — a point-to-point SQS-style queue and its single consumer.
10
11
  * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
@@ -19,8 +20,23 @@ var Queue = class extends Construct {
19
20
  static isQueue(obj) {
20
21
  return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === ConstructType.Queue);
21
22
  }
22
- constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = DEFAULT_LOGGER$1, batchSize, fifo) {
23
- super(ConstructType.Queue, logger, services, [], void 0, void 0, timeout);
23
+ /**
24
+ * The canonical id this queue is declared under.
25
+ *
26
+ * Derived from the name rather than given separately, so `emails` and
27
+ * `Emails` are one queue. The name stays what it was: it is the wire `type`
28
+ * a producer sends and the worker subscribes to, and changing that would
29
+ * silently orphan in-flight messages.
30
+ */
31
+ id;
32
+ /**
33
+ * The producer's env key. Read by both {@link declare} and
34
+ * {@link publisher}, so what the target publishes and what the producer
35
+ * looks up cannot drift.
36
+ */
37
+ connectionKey;
38
+ constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
39
+ super(ConstructType.Queue, logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
24
40
  this.name = name;
25
41
  this.handler = handler;
26
42
  this.messageSchema = messageSchema;
@@ -29,6 +45,29 @@ var Queue = class extends Construct {
29
45
  this.logger = logger;
30
46
  this.batchSize = batchSize;
31
47
  this.fifo = fifo;
48
+ this.id = canonicalId(name);
49
+ this.connectionKey = provideKey(this.id, "publisherConnectionString");
50
+ }
51
+ /**
52
+ * What this queue is in the manifest.
53
+ *
54
+ * A queue is a resource, not a handler: the worker is reached *through* it,
55
+ * so the declaration carries the producer's key and nothing about the code
56
+ * that drains it. The local target reads this to know which broker has to be
57
+ * running and what connection string to inject.
58
+ */
59
+ declare() {
60
+ return [{
61
+ kind: "queue",
62
+ id: this.id,
63
+ provides: [this.connectionKey],
64
+ ...this.fifo ? { fifo: true } : {},
65
+ worker: {
66
+ id: `${this.id}Worker`,
67
+ handler: `${this.id}.handler`,
68
+ dependencies: []
69
+ }
70
+ }];
32
71
  }
33
72
  /**
34
73
  * The producer side — a `Service` exposing an `EventPublisher` typed to this
@@ -41,8 +80,24 @@ var Queue = class extends Construct {
41
80
  * `Construct.getEnvironment()` sniffs it, so the env requirement flows into
42
81
  * the manifest and infra links exactly this queue with least privilege.
43
82
  */
83
+ /**
84
+ * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves
85
+ * into, reachable as `services.emails`.
86
+ *
87
+ * It is the producer: a consumer is the worker written right here, so the
88
+ * only thing another construct can want from a queue is the ability to send
89
+ * to it. {@link publisher} is the same service under its older
90
+ * `<name>Publisher` key, kept for `.services([queue.publisher])`.
91
+ */
92
+ get service() {
93
+ const { register } = this.publisher;
94
+ return {
95
+ serviceName: serviceKey(this.id),
96
+ register
97
+ };
98
+ }
44
99
  get publisher() {
45
- const envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;
100
+ const envVar = this.connectionKey;
46
101
  return {
47
102
  serviceName: `${this.name}Publisher`,
48
103
  async register({ envParser }) {
@@ -68,50 +123,56 @@ var QueueBuilder = class {
68
123
  _batchSize;
69
124
  _fifo;
70
125
  _services = [];
126
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
127
+ _constructs = [];
71
128
  _logger = DEFAULT_LOGGER;
72
129
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
73
130
  queue(name) {
74
- this._name = name;
75
- return this;
131
+ return cloneWith(this, { _name: name });
76
132
  }
77
133
  timeout(timeout) {
78
- this._timeout = timeout;
79
- return this;
134
+ return cloneWith(this, { _timeout: timeout });
80
135
  }
81
136
  /** SQS event-source batch size (deployed). */
82
137
  batchSize(batchSize) {
83
- this._batchSize = batchSize;
84
- return this;
138
+ return cloneWith(this, { _batchSize: batchSize });
85
139
  }
86
140
  /** Mark the queue as FIFO (deployed). */
87
141
  fifo(fifo = true) {
88
- this._fifo = fifo;
89
- return this;
142
+ return cloneWith(this, { _fifo: fifo });
143
+ }
144
+ /**
145
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
146
+ * topic.
147
+ *
148
+ * It records the edge and dissolves each construct's client into the
149
+ * handler's service record under the construct's own id, so
150
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
151
+ *
152
+ * Constructs only. A `Service` does not match the shape, which is what keeps
153
+ * env sniffing confined to `.services()` and the explicit lift.
154
+ */
155
+ dependsOn(constructs) {
156
+ const services = servicesOf(constructs);
157
+ return cloneWith(this, {
158
+ _services: [...this._services, ...services],
159
+ _constructs: idsOf(constructs, this._constructs)
160
+ });
90
161
  }
91
162
  services(services) {
92
- this._services = [...this._services, ...services];
93
- return this;
163
+ return cloneWith(this, { _services: [...this._services, ...services] });
94
164
  }
95
165
  logger(logger) {
96
- this._logger = logger;
97
- return this;
166
+ return cloneWith(this, { _logger: logger });
98
167
  }
99
168
  /** The typed message (job) payload the queue carries. */
100
169
  message(schema) {
101
- this._messageSchema = schema;
102
- return this;
170
+ return cloneWith(this, { _messageSchema: schema });
103
171
  }
104
172
  handle(fn) {
105
173
  if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
106
174
  if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
107
- const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo);
108
- this._name = void 0;
109
- this._messageSchema = void 0;
110
- this._timeout = 3e4;
111
- this._batchSize = void 0;
112
- this._fifo = void 0;
113
- this._services = [];
114
- this._logger = DEFAULT_LOGGER;
175
+ const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
115
176
  return queue;
116
177
  }
117
178
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["DEFAULT_LOGGER","obj: unknown","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","batchSize?: number","fifo?: boolean","name: T","timeout: number","batchSize: number","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import { environmentCase } from '@geekmidas/envkit';\nimport {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { ConsoleLogger } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\nconst DEFAULT_LOGGER = new ConsoleLogger() as unknown as Logger;\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t);\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = `${environmentCase(this.name)}_PUBLISHER_CONNECTION_STRING`;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\tthis._name = name;\n\t\treturn this as unknown as QueueBuilder<T, TMessage, TServices, TLogger>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\tthis._timeout = timeout;\n\t\treturn this;\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\tthis._batchSize = batchSize;\n\t\treturn this;\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\tthis._fifo = fifo;\n\t\treturn this;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\tthis._services = [...this._services, ...services] as unknown as TServices;\n\t\treturn this as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\tthis._logger = logger as unknown as TLogger;\n\t\treturn this as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\tthis._messageSchema = schema as unknown as TMessage;\n\t\treturn this as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t);\n\n\t\t// Reset builder state to prevent pollution across reuse.\n\t\tthis._name = undefined;\n\t\tthis._messageSchema = undefined;\n\t\tthis._timeout = 30000;\n\t\tthis._batchSize = undefined;\n\t\tthis._fifo = undefined;\n\t\tthis._services = [] as Service[] as TServices;\n\t\tthis._logger = DEFAULT_LOGGER as TLogger;\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;AAcA,MAAMA,mBAAiB,IAAI;;;;;;;;;;AAsB3B,IAAa,QAAb,cAKU,UAA4D;CACrE,eAAe;CAEf,OAAO,QACNC,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAS,cAAc,MAC3C;CACD;CAED,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkBP,kBAE3BQ,WAEAC,MACf;AACD,QACC,cAAc,OACd,QACA,UACA,CAAE,mBAGF,QACA;EAnBe;EACA;EACA;EACS;EACA;EACA;EAET;EAEA;CAWhB;;;;;;;;;;;;CAaD,IAAI,YAGF;EACD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AI"}
1
+ {"version":3,"file":"index.mjs","names":["obj: unknown","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","batchSize?: number","fifo?: boolean","constructs: string[]","name: T","timeout: number","batchSize: number","constructs: T","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and\n\t * {@link publisher}, so what the target publishes and what the producer\n\t * looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves\n\t * into, reachable as `services.emails`.\n\t *\n\t * It is the producer: a consumer is the worker written right here, so the\n\t * only thing another construct can want from a queue is the ability to send\n\t * to it. {@link publisher} is the same service under its older\n\t * `<name>Publisher` key, kept for `.services([queue.publisher])`.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<T, TMessage, TServices, TLogger> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, T>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn queue;\n\t}\n}\n","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAa,QAAb,cAKU,UAA4D;CACrE,eAAe;CAEf,OAAO,QACNA,KAC4D;AAC5D,SAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAS,cAAc,MAC3C;CACD;;;;;;;;;CAUD,AAAS;;;;;;CAOT,AAAiB;CAEjB,YACiBC,MACAC,SACAC,eACSC,UAAkB,KAClBC,WAAsB,CAAE,GACxBC,SAAkB,gBAE3BC,WAEAC,MAKhBC,aAAuB,CAAE,GACxB;AACD,QACC,cAAc,OACd,QACA,UACA,CAAE,mBAGF,yBAGA,WACA;EA3Be;EACA;EACA;EACS;EACA;EACA;EAET;EAEA;AAoBhB,OAAK,KAAK,YAAY,KAAK;AAC3B,OAAK,gBAAgB,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C2E;EAQ3E,MAAM,WAAW,WAAW,WAAW;AAEvC,SAAO,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS;GAC3C,aAAa,MAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAMF;CAED,SACCC,UAC+D;AAC/D,SAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CAMF;CAED,OACCC,QAC8C;AAC9C,SAAO,UAAU,MAAM,EACtB,SAAS,OACT,EAAC;CACF;;CAGD,QACCC,QAC6C;AAC7C,SAAO,UAAU,MAAM,EACtB,gBAAgB,OAChB,EAAC;CACF;CAED,OACCC,IAC0D;AAC1D,OAAK,KAAK,MACT,OAAM,IAAI,MACT;AAGF,OAAK,KAAK,eACT,OAAM,IAAI,MACT;EAIF,MAAM,QAAQ,IAAI,MACjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK;AASN,SAAO;CACP;AACD;;;;ACpJD,MAAa,IAAI,IAAI"}
@@ -0,0 +1,187 @@
1
+ const require_chunk = require('./chunk-DWy1uDak.cjs');
2
+ const require_construct_interface = require('./construct-interface-BfjcOD_E.cjs');
3
+ require('./Construct-roId57cU.cjs');
4
+ require('./functions-DukjG8ov.cjs');
5
+ const require_EndpointFactory = require('./EndpointFactory-DYoGLaIT.cjs');
6
+ require('./clone-Dy0cR2SZ.cjs');
7
+ require('./Endpoint-BBkV6l0k.cjs');
8
+ const require_surfaceEnv = require('./surfaceEnv-BFXEms2f.cjs');
9
+ const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
10
+ const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
11
+
12
+ //#region src/rest-api.ts
13
+ /**
14
+ * What is *not* here, and why.
15
+ *
16
+ * `dependsOn`, `database`, `auditor` and `publisher` all inject a capability
17
+ * into a handler. Putting one on the surface hands it to every route the
18
+ * surface serves — a health check gets the database because a report needed it
19
+ * — which is the thing least privilege forbids and the reason `.calls()` is not
20
+ * spelled `dependsOn`. They belong to the endpoint, or to a factory branched
21
+ * from `api.endpoints` for a group of endpoints that genuinely share them.
22
+ *
23
+ * `auth` is not here either: `.auth(construct)` already declares it, and a
24
+ * second way to say the same thing is the duplication this whole model removes.
25
+ *
26
+ * What is left is what the *process* is rather than what a route may reach.
27
+ */
28
+ var RestApi = class RestApi {
29
+ id;
30
+ /**
31
+ * Declared once and read by both `declare()` and anything that consumes this
32
+ * surface, so what the target publishes and what a consumer reads cannot
33
+ * drift.
34
+ */
35
+ keys;
36
+ /**
37
+ * The logger every endpoint on this surface runs with.
38
+ *
39
+ * Always defined — the surface's own if it was given one, the console
40
+ * logger otherwise — so nothing downstream has to decide what to do about a
41
+ * missing one. The generated entry reads it from here.
42
+ */
43
+ logger;
44
+ /**
45
+ * The environment parser every endpoint on this surface runs with.
46
+ *
47
+ * Always defined, and normally the default: `process.env` merged with the
48
+ * credentials `gkm dev`/`gkm exec` injected. That is what every
49
+ * application's own `config/env.ts` was — boilerplate identical in every
50
+ * project, and mandatory, which is a poor combination.
51
+ */
52
+ envParser;
53
+ /** The Telescope instance, when this surface was given one. */
54
+ telescope;
55
+ constructor(id, config, dependencies = [], authenticator) {
56
+ this.config = config;
57
+ this.dependencies = dependencies;
58
+ this.authenticator = authenticator;
59
+ const canonical = (0, __geekmidas_manifest.canonicalId)(id);
60
+ this.id = canonical;
61
+ this.keys = {
62
+ url: (0, __geekmidas_manifest.provideKey)(canonical, "url"),
63
+ trustedOrigins: (0, __geekmidas_manifest.provideKey)(canonical, "trustedOrigins"),
64
+ cookieDomain: (0, __geekmidas_manifest.provideKey)(canonical, "cookieDomain")
65
+ };
66
+ this.logger = config.logger ?? __geekmidas_logger_console.DEFAULT_LOGGER;
67
+ this.telescope = config.telescope;
68
+ this.envParser = require_surfaceEnv.envParserFor(config.envParser ? {
69
+ id: canonical,
70
+ envParser: config.envParser
71
+ } : void 0);
72
+ this.endpoints = new require_EndpointFactory.EndpointFactory({
73
+ defaultLogger: this.logger,
74
+ ...config.authorizers ? { availableAuthorizers: config.authorizers.map((name) => ({ name })) } : {},
75
+ ...config.defaultAuthorizer && config.defaultAuthorizer !== "none" ? { defaultAuthorizerName: config.defaultAuthorizer } : {},
76
+ surface: {
77
+ id: this.id,
78
+ envParser: this.envParser
79
+ }
80
+ });
81
+ }
82
+ /**
83
+ * This surface's endpoint factory.
84
+ *
85
+ * `api.get('/users')` is the short form and covers most routes. Reach for
86
+ * this one when a *group* of endpoints shares something a single route would
87
+ * otherwise repeat — a database, an auditor, a publisher:
88
+ *
89
+ * ```ts
90
+ * const audited = api.endpoints.database(db).auditor(AuditStore);
91
+ * export const createUser = audited.post('/users').handle(...);
92
+ * ```
93
+ *
94
+ * A factory branched from here keeps the surface, so its endpoints still
95
+ * know which API serves them. That is deliberately narrower than putting the
96
+ * same thing in the surface's own config: a group opts in, where a surface
97
+ * would grant it to every route it serves.
98
+ */
99
+ endpoints;
100
+ /** `api.get('/users')` — sugar for `api.endpoints.get('/users')`. */
101
+ get(path) {
102
+ return this.endpoints.get(path);
103
+ }
104
+ post(path) {
105
+ return this.endpoints.post(path);
106
+ }
107
+ put(path) {
108
+ return this.endpoints.put(path);
109
+ }
110
+ patch(path) {
111
+ return this.endpoints.patch(path);
112
+ }
113
+ delete(path) {
114
+ return this.endpoints.delete(path);
115
+ }
116
+ options(path) {
117
+ return this.endpoints.options(path);
118
+ }
119
+ /**
120
+ * What authenticates this surface.
121
+ *
122
+ * An edge like `.calls()` — the auth server learns this origin, and the two
123
+ * share a cookie domain — but a named one, because *who authenticates me* is
124
+ * a different fact from *who I happen to call*, and only one of them decides
125
+ * what a request is allowed to be. A surface with two of the first is a
126
+ * mistake; two of the second is Tuesday.
127
+ *
128
+ * It records the id, not a client. Every endpoint consumes the same thing —
129
+ * `verify(request) → Session | null` — and that is what every provider
130
+ * shares, whether the server is mounted in this process, deployed beside it,
131
+ * or an OIDC issuer somebody else runs.
132
+ */
133
+ auth(construct) {
134
+ return new RestApi(this.id, this.config, [...this.dependencies, require_construct_interface.edgeTo(construct)], construct.id);
135
+ }
136
+ /**
137
+ * Other surfaces this one calls.
138
+ *
139
+ * **Not `.dependsOn()`, and the difference matters.** An endpoint's
140
+ * `.dependsOn()` injects a client into that handler and grants it exactly
141
+ * what it named. This grants nothing and injects nothing: it records that
142
+ * this API calls another surface, which is what puts this API's origin on
143
+ * that surface's trusted-origin list.
144
+ *
145
+ * Spelling it `dependsOn` would invite the thing least privilege forbids —
146
+ * every route on the surface receiving whatever the surface named.
147
+ *
148
+ * Immutable, like every other builder here.
149
+ */
150
+ calls(constructs) {
151
+ return new RestApi(this.id, this.config, [...this.dependencies, ...constructs.map(require_construct_interface.edgeTo)], this.authenticator);
152
+ }
153
+ /**
154
+ * One surface node, with its endpoints left to the build.
155
+ *
156
+ * The three provided keys are one fact about this surface and two about its
157
+ * callers. Declaring the caller-derived pair here rather than having the
158
+ * target invent them is what makes the contract checkable: a target that
159
+ * resolves no origins is caught against this list instead of being noticed
160
+ * when a browser is refused in production.
161
+ */
162
+ declare() {
163
+ return [{
164
+ kind: "rest-api",
165
+ id: this.id,
166
+ app: {
167
+ ...this.config.app,
168
+ ...this.config.telescope ? { telescope: true } : {}
169
+ },
170
+ ...this.config.cors ? { cors: this.config.cors } : {},
171
+ ...this.authenticator ? { auth: this.authenticator } : {},
172
+ endpoints: [],
173
+ ...this.dependencies.length ? { calls: this.dependencies } : {},
174
+ ...this.config.authorizers?.length ? { authorizers: this.config.authorizers } : {},
175
+ defaultAuthorizer: this.config.defaultAuthorizer,
176
+ provides: [
177
+ this.keys.url,
178
+ this.keys.trustedOrigins,
179
+ this.keys.cookieDomain
180
+ ]
181
+ }];
182
+ }
183
+ };
184
+
185
+ //#endregion
186
+ exports.RestApi = RestApi;
187
+ //# sourceMappingURL=rest-api.cjs.map