@geekmidas/constructs 10.0.0-alpha.99 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (533) hide show
  1. package/CHANGELOG.md +437 -0
  2. package/README.md +193 -285
  3. package/dist/AWSScheduledFunction-BzGCUbkk.d.mts +117 -0
  4. package/dist/AWSScheduledFunction-BzGCUbkk.d.mts.map +1 -0
  5. package/dist/AWSScheduledFunction-C42adp8A.cjs +266 -0
  6. package/dist/AWSScheduledFunction-C42adp8A.cjs.map +1 -0
  7. package/dist/AWSScheduledFunction-CsNJhXQj.d.cts +117 -0
  8. package/dist/AWSScheduledFunction-CsNJhXQj.d.cts.map +1 -0
  9. package/dist/AWSScheduledFunction-KP6lqbsW.mjs +254 -0
  10. package/dist/AWSScheduledFunction-KP6lqbsW.mjs.map +1 -0
  11. package/dist/{Construct-B1vGBPme.mjs → Construct-BWF5HxaM.mjs} +37 -47
  12. package/dist/Construct-BWF5HxaM.mjs.map +1 -0
  13. package/dist/Construct-JlyQkBkv.d.cts +117 -0
  14. package/dist/Construct-JlyQkBkv.d.cts.map +1 -0
  15. package/dist/{Construct-DUSXuTHP.cjs → Construct-TGIM_E4o.cjs} +88 -67
  16. package/dist/Construct-TGIM_E4o.cjs.map +1 -0
  17. package/dist/Construct-pxwC6fDD.d.mts +117 -0
  18. package/dist/Construct-pxwC6fDD.d.mts.map +1 -0
  19. package/dist/{Endpoint-Du-NwPX2.d.mts → Endpoint-B0P_pEMr.d.mts} +85 -126
  20. package/dist/Endpoint-B0P_pEMr.d.mts.map +1 -0
  21. package/dist/{Endpoint-aCvBMPoH.d.cts → Endpoint-BLZ7r67m.d.cts} +84 -125
  22. package/dist/Endpoint-BLZ7r67m.d.cts.map +1 -0
  23. package/dist/{HonoEndpointAdaptor-PtPlbeKY.mjs → HonoEndpointAdaptor-BMVwx2cz.mjs} +69 -81
  24. package/dist/HonoEndpointAdaptor-BMVwx2cz.mjs.map +1 -0
  25. package/dist/{HonoEndpointAdaptor-zVzVLJEO.cjs → HonoEndpointAdaptor-DPDsDi-D.cjs} +77 -92
  26. package/dist/HonoEndpointAdaptor-DPDsDi-D.cjs.map +1 -0
  27. package/dist/Queue-BL68oDJ-.d.mts +66 -0
  28. package/dist/Queue-BL68oDJ-.d.mts.map +1 -0
  29. package/dist/Queue-DxJ6btRE.d.cts +66 -0
  30. package/dist/Queue-DxJ6btRE.d.cts.map +1 -0
  31. package/dist/Subscriber-BpVhcGhX.d.cts +47 -0
  32. package/dist/Subscriber-BpVhcGhX.d.cts.map +1 -0
  33. package/dist/Subscriber-DF6xsBAJ.d.mts +47 -0
  34. package/dist/Subscriber-DF6xsBAJ.d.mts.map +1 -0
  35. package/dist/Topic-DJXoDeMP.d.cts +60 -0
  36. package/dist/Topic-DJXoDeMP.d.cts.map +1 -0
  37. package/dist/Topic-DxWQBgMN.d.mts +60 -0
  38. package/dist/Topic-DxWQBgMN.d.mts.map +1 -0
  39. package/dist/adaptors/aws.cjs +205 -355
  40. package/dist/adaptors/aws.cjs.map +1 -1
  41. package/dist/adaptors/aws.d.cts +48 -126
  42. package/dist/adaptors/aws.d.cts.map +1 -1
  43. package/dist/adaptors/aws.d.mts +49 -127
  44. package/dist/adaptors/aws.d.mts.map +1 -1
  45. package/dist/adaptors/aws.mjs +178 -325
  46. package/dist/adaptors/aws.mjs.map +1 -1
  47. package/dist/adaptors/hono.cjs +9 -3
  48. package/dist/adaptors/hono.d.cts +15 -7
  49. package/dist/adaptors/hono.d.cts.map +1 -1
  50. package/dist/adaptors/hono.d.mts +17 -9
  51. package/dist/adaptors/hono.d.mts.map +1 -1
  52. package/dist/adaptors/hono.mjs +9 -2
  53. package/dist/adaptors/testing.cjs +209 -831
  54. package/dist/adaptors/testing.cjs.map +1 -1
  55. package/dist/adaptors/testing.d.cts +55 -351
  56. package/dist/adaptors/testing.d.cts.map +1 -1
  57. package/dist/adaptors/testing.d.mts +53 -349
  58. package/dist/adaptors/testing.d.mts.map +1 -1
  59. package/dist/adaptors/testing.mjs +195 -798
  60. package/dist/adaptors/testing.mjs.map +1 -1
  61. package/dist/{clone-UGJpvQnL.cjs → clone-I_WIpiFf.cjs} +8 -7
  62. package/dist/clone-I_WIpiFf.cjs.map +1 -0
  63. package/dist/{clone-EKNovYHu.mjs → clone-pdXxc0t3.mjs} +3 -3
  64. package/dist/clone-pdXxc0t3.mjs.map +1 -0
  65. package/dist/crons/index.cjs +66 -190
  66. package/dist/crons/index.cjs.map +1 -1
  67. package/dist/crons/index.d.cts +35 -70
  68. package/dist/crons/index.d.cts.map +1 -1
  69. package/dist/crons/index.d.mts +32 -70
  70. package/dist/crons/index.d.mts.map +1 -1
  71. package/dist/crons/index.mjs +63 -184
  72. package/dist/crons/index.mjs.map +1 -1
  73. package/dist/endpoints/index.cjs +761 -19
  74. package/dist/endpoints/index.cjs.map +1 -0
  75. package/dist/endpoints/index.d.cts +322 -22
  76. package/dist/endpoints/index.d.cts.map +1 -1
  77. package/dist/endpoints/index.d.mts +321 -22
  78. package/dist/endpoints/index.d.mts.map +1 -1
  79. package/dist/endpoints/index.mjs +751 -6
  80. package/dist/endpoints/index.mjs.map +1 -0
  81. package/dist/functions/index.cjs +5 -2
  82. package/dist/functions/index.d.cts +3 -3
  83. package/dist/functions/index.d.mts +3 -3
  84. package/dist/functions/index.mjs +5 -2
  85. package/dist/{functions-BFizikJU.mjs → functions-EqTloHjo.mjs} +331 -425
  86. package/dist/functions-EqTloHjo.mjs.map +1 -0
  87. package/dist/{functions-CfzJG9hK.cjs → functions-SqtCDc9c.cjs} +370 -459
  88. package/dist/functions-SqtCDc9c.cjs.map +1 -0
  89. package/dist/index-C7iynzLI.d.mts +139 -0
  90. package/dist/index-C7iynzLI.d.mts.map +1 -0
  91. package/dist/index-D4dM_WDY.d.cts +142 -0
  92. package/dist/index-D4dM_WDY.d.cts.map +1 -0
  93. package/dist/index.cjs +3 -6
  94. package/dist/index.d.cts +4 -27
  95. package/dist/index.d.mts +4 -27
  96. package/dist/index.mjs +3 -3
  97. package/dist/{Endpoint-BG4UJ9oA.mjs → lazyAccessors-CCTK19xj.mjs} +1040 -914
  98. package/dist/lazyAccessors-CCTK19xj.mjs.map +1 -0
  99. package/dist/{Endpoint-BoUg8ocM.cjs → lazyAccessors-D04oftGw.cjs} +1127 -960
  100. package/dist/lazyAccessors-D04oftGw.cjs.map +1 -0
  101. package/dist/monitors/index.cjs +49 -0
  102. package/dist/monitors/index.cjs.map +1 -0
  103. package/dist/monitors/index.d.cts +45 -0
  104. package/dist/monitors/index.d.cts.map +1 -0
  105. package/dist/monitors/index.d.mts +45 -0
  106. package/dist/monitors/index.d.mts.map +1 -0
  107. package/dist/monitors/index.mjs +48 -0
  108. package/dist/monitors/index.mjs.map +1 -0
  109. package/dist/processAudits-BJZT5gmy.cjs +92 -0
  110. package/dist/processAudits-BJZT5gmy.cjs.map +1 -0
  111. package/dist/processAudits-CwyaaSQc.mjs +80 -0
  112. package/dist/processAudits-CwyaaSQc.mjs.map +1 -0
  113. package/dist/publisher-BZgcrVPy.cjs +53 -0
  114. package/dist/publisher-BZgcrVPy.cjs.map +1 -0
  115. package/dist/publisher-CnpeMv-r.mjs +41 -0
  116. package/dist/publisher-CnpeMv-r.mjs.map +1 -0
  117. package/dist/queue/index.cjs +114 -6
  118. package/dist/queue/index.cjs.map +1 -0
  119. package/dist/queue/index.d.cts +45 -3
  120. package/dist/queue/index.d.cts.map +1 -0
  121. package/dist/queue/index.d.mts +44 -3
  122. package/dist/queue/index.d.mts.map +1 -0
  123. package/dist/queue/index.mjs +112 -3
  124. package/dist/queue/index.mjs.map +1 -0
  125. package/dist/subscribers/index.cjs +80 -111
  126. package/dist/subscribers/index.cjs.map +1 -1
  127. package/dist/subscribers/index.d.cts +43 -46
  128. package/dist/subscribers/index.d.cts.map +1 -1
  129. package/dist/subscribers/index.d.mts +42 -46
  130. package/dist/subscribers/index.d.mts.map +1 -1
  131. package/dist/subscribers/index.mjs +78 -108
  132. package/dist/subscribers/index.mjs.map +1 -1
  133. package/dist/{lambdaTelemetry-8vnmVZQ5.d.cts → telemetry-C--EgYVr.d.mts} +7 -4
  134. package/dist/telemetry-C--EgYVr.d.mts.map +1 -0
  135. package/dist/{lambdaTelemetry-8vnmVZQ5.d.mts → telemetry-Dqx-D3F7.d.cts} +7 -4
  136. package/dist/telemetry-Dqx-D3F7.d.cts.map +1 -0
  137. package/dist/topic/index.cjs +91 -3
  138. package/dist/topic/index.cjs.map +1 -0
  139. package/dist/topic/index.d.cts +32 -2
  140. package/dist/topic/index.d.cts.map +1 -0
  141. package/dist/topic/index.d.mts +32 -2
  142. package/dist/topic/index.d.mts.map +1 -0
  143. package/dist/topic/index.mjs +89 -2
  144. package/dist/topic/index.mjs.map +1 -0
  145. package/dist/{types-DMuSQeLL.d.cts → types-BdAaYDvd.d.cts} +5 -3
  146. package/dist/types-BdAaYDvd.d.cts.map +1 -0
  147. package/dist/{types-DMuSQeLL.d.mts → types-DNngH0fX.d.mts} +5 -3
  148. package/dist/types-DNngH0fX.d.mts.map +1 -0
  149. package/dist/types.d.cts +1 -1
  150. package/dist/types.d.mts +1 -1
  151. package/dist/types.mjs +0 -1
  152. package/package.json +55 -223
  153. package/src/Construct.ts +209 -0
  154. package/src/__benchmarks__/build-time-optimization.bench.ts +274 -0
  155. package/src/__benchmarks__/endpoint.bench.ts +494 -0
  156. package/src/__benchmarks__/fixtures.ts +241 -0
  157. package/src/__benchmarks__/hono-adaptor.bench.ts +533 -0
  158. package/src/__benchmarks__/hono-server.bench.ts +249 -0
  159. package/src/__benchmarks__/response-builder.bench.ts +428 -0
  160. package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +319 -0
  161. package/src/__benchmarks__/strategies/strategy-c-middleware.ts +530 -0
  162. package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +567 -0
  163. package/src/__tests__/Construct.environment.spec.ts +704 -0
  164. package/src/__tests__/builder-reuse.spec.ts +587 -0
  165. package/src/__tests__/monitor.spec.ts +636 -0
  166. package/src/__tests__/publisher.setting.spec.ts +508 -0
  167. package/src/__tests__/publisher.spec.ts +452 -0
  168. package/src/adaptors/aws.ts +6 -0
  169. package/src/adaptors/hono.ts +1 -0
  170. package/src/adaptors/testing.ts +11 -0
  171. package/src/clone.ts +38 -0
  172. package/src/crons/AWSScheduledFunction.ts +73 -0
  173. package/src/crons/Cron.ts +149 -0
  174. package/src/crons/CronBuilder.ts +261 -0
  175. package/src/crons/__tests__/AWSScheduledFunction.spec.ts +152 -0
  176. package/src/crons/__tests__/Cron.spec.ts +472 -0
  177. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +273 -0
  178. package/src/crons/index.ts +12 -0
  179. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +698 -0
  180. package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +105 -0
  181. package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +97 -0
  182. package/src/endpoints/Authorizer.ts +152 -0
  183. package/src/endpoints/Endpoint.ts +1287 -0
  184. package/src/endpoints/EndpointBuilder.ts +749 -0
  185. package/src/endpoints/EndpointFactory.ts +1179 -0
  186. package/src/endpoints/HonoEndpointAdaptor.ts +692 -0
  187. package/src/endpoints/MswEndpointAdaptor.ts +226 -0
  188. package/src/endpoints/TestEndpointAdaptor.ts +466 -0
  189. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +499 -0
  190. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +560 -0
  191. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +1304 -0
  192. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +626 -0
  193. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +732 -0
  194. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +296 -0
  195. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +951 -0
  196. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +111 -0
  197. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +307 -0
  198. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +629 -0
  199. package/src/endpoints/__tests__/Authorizer.spec.ts +286 -0
  200. package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +207 -0
  201. package/src/endpoints/__tests__/Endpoint.headers.spec.ts +187 -0
  202. package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +175 -0
  203. package/src/endpoints/__tests__/Endpoint.spec.ts +857 -0
  204. package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +451 -0
  205. package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +50 -0
  206. package/src/endpoints/__tests__/EndpointBuilder.spec.ts +531 -0
  207. package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +492 -0
  208. package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +509 -0
  209. package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +190 -0
  210. package/src/endpoints/__tests__/EndpointFactory.spec.ts +479 -0
  211. package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +155 -0
  212. package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +703 -0
  213. package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +632 -0
  214. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +577 -0
  215. package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1067 -0
  216. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +317 -0
  217. package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +289 -0
  218. package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +128 -0
  219. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1207 -0
  220. package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +211 -0
  221. package/src/endpoints/__tests__/ResponseBuilder.spec.ts +235 -0
  222. package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +602 -0
  223. package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +1044 -0
  224. package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +54 -0
  225. package/src/endpoints/__tests__/endpoint-types.test.ts +88 -0
  226. package/src/endpoints/__tests__/helpers.spec.ts +37 -0
  227. package/src/endpoints/__tests__/lazyAccessors.spec.ts +330 -0
  228. package/src/endpoints/__tests__/processAudits.spec.ts +631 -0
  229. package/src/endpoints/audit.ts +87 -0
  230. package/src/endpoints/helpers.ts +98 -0
  231. package/src/endpoints/index.ts +42 -0
  232. package/src/endpoints/lazyAccessors.ts +241 -0
  233. package/src/endpoints/parseHonoQuery.ts +16 -0
  234. package/src/endpoints/parseQueryParams.ts +32 -0
  235. package/src/endpoints/processAudits.ts +371 -0
  236. package/src/endpoints/rls.ts +67 -0
  237. package/src/functions/AWSLambdaFunction.ts +374 -0
  238. package/src/functions/BaseFunctionBuilder.ts +212 -0
  239. package/src/functions/Function.ts +238 -0
  240. package/src/functions/FunctionBuilder.ts +381 -0
  241. package/src/functions/FunctionExecutionWrapper.ts +216 -0
  242. package/src/functions/TestFunctionAdaptor.ts +252 -0
  243. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +513 -0
  244. package/src/functions/__tests__/Function.audits.spec.ts +393 -0
  245. package/src/functions/__tests__/Function.spec.ts +477 -0
  246. package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +250 -0
  247. package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +480 -0
  248. package/src/functions/index.ts +12 -0
  249. package/src/index.ts +29 -0
  250. package/src/monitor.ts +145 -0
  251. package/src/monitors/heartbeat.ts +86 -0
  252. package/src/monitors/index.ts +6 -0
  253. package/src/publisher.ts +93 -0
  254. package/src/queue/AWSLambdaQueueAdaptor.ts +162 -0
  255. package/src/queue/Queue.ts +128 -0
  256. package/src/queue/QueueBuilder.ts +115 -0
  257. package/src/queue/TestQueueAdaptor.ts +63 -0
  258. package/src/queue/__tests__/QueueBuilder.spec.ts +137 -0
  259. package/src/queue/index.ts +12 -0
  260. package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +342 -0
  261. package/src/subscribers/Subscriber.ts +117 -0
  262. package/src/subscribers/SubscriberBuilder.ts +183 -0
  263. package/src/subscribers/TestSubscriberAdaptor.ts +133 -0
  264. package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +1018 -0
  265. package/src/subscribers/__tests__/Subscriber.spec.ts +430 -0
  266. package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +652 -0
  267. package/src/subscribers/index.ts +6 -0
  268. package/src/telemetry.ts +103 -0
  269. package/src/topic/Topic.ts +103 -0
  270. package/src/topic/TopicBuilder.ts +53 -0
  271. package/src/topic/__tests__/TopicBuilder.spec.ts +82 -0
  272. package/src/topic/index.ts +11 -0
  273. package/src/types.ts +13 -0
  274. package/test.ts +91 -0
  275. package/tsconfig.json +9 -0
  276. package/tsdown.config.ts +35 -0
  277. package/dist/Construct-B1vGBPme.mjs.map +0 -1
  278. package/dist/Construct-BQALFCh2.d.cts +0 -230
  279. package/dist/Construct-BQALFCh2.d.cts.map +0 -1
  280. package/dist/Construct-DUSXuTHP.cjs.map +0 -1
  281. package/dist/Construct-QXnl3VqT.d.mts +0 -230
  282. package/dist/Construct-QXnl3VqT.d.mts.map +0 -1
  283. package/dist/Cron-DI3nKoic.d.cts +0 -45
  284. package/dist/Cron-DI3nKoic.d.cts.map +0 -1
  285. package/dist/Cron-uYAHPnp7.d.mts +0 -45
  286. package/dist/Cron-uYAHPnp7.d.mts.map +0 -1
  287. package/dist/CronBuilder-C0Ek1-RA.cjs +0 -121
  288. package/dist/CronBuilder-C0Ek1-RA.cjs.map +0 -1
  289. package/dist/CronBuilder-DaSUm2Na.d.mts +0 -47
  290. package/dist/CronBuilder-DaSUm2Na.d.mts.map +0 -1
  291. package/dist/CronBuilder-Dmix_Pen.mjs +0 -109
  292. package/dist/CronBuilder-Dmix_Pen.mjs.map +0 -1
  293. package/dist/CronBuilder-g1lZLWyG.d.cts +0 -47
  294. package/dist/CronBuilder-g1lZLWyG.d.cts.map +0 -1
  295. package/dist/Endpoint-BG4UJ9oA.mjs.map +0 -1
  296. package/dist/Endpoint-BoUg8ocM.cjs.map +0 -1
  297. package/dist/Endpoint-Du-NwPX2.d.mts.map +0 -1
  298. package/dist/Endpoint-aCvBMPoH.d.cts.map +0 -1
  299. package/dist/EndpointFactory-BDtsrEvJ.mjs +0 -791
  300. package/dist/EndpointFactory-BDtsrEvJ.mjs.map +0 -1
  301. package/dist/EndpointFactory-DJ7gXLpR.cjs +0 -833
  302. package/dist/EndpointFactory-DJ7gXLpR.cjs.map +0 -1
  303. package/dist/EndpointFactory-DMYdJCOj.d.mts +0 -363
  304. package/dist/EndpointFactory-DMYdJCOj.d.mts.map +0 -1
  305. package/dist/EndpointFactory-I7s1co3Y.d.cts +0 -363
  306. package/dist/EndpointFactory-I7s1co3Y.d.cts.map +0 -1
  307. package/dist/Function-DuqGcbOI.d.mts +0 -76
  308. package/dist/Function-DuqGcbOI.d.mts.map +0 -1
  309. package/dist/Function-Pu-1kKZz.d.cts +0 -76
  310. package/dist/Function-Pu-1kKZz.d.cts.map +0 -1
  311. package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +0 -1
  312. package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +0 -1
  313. package/dist/Queue-A3wfD0it.cjs +0 -109
  314. package/dist/Queue-A3wfD0it.cjs.map +0 -1
  315. package/dist/Queue-D6USGS4q.mjs +0 -104
  316. package/dist/Queue-D6USGS4q.mjs.map +0 -1
  317. package/dist/Queue-DlsHRzUp.d.mts +0 -105
  318. package/dist/Queue-DlsHRzUp.d.mts.map +0 -1
  319. package/dist/Queue-HPyi0e1i.d.cts +0 -105
  320. package/dist/Queue-HPyi0e1i.d.cts.map +0 -1
  321. package/dist/QueueBuilder-BjuF0UBl.cjs +0 -135
  322. package/dist/QueueBuilder-BjuF0UBl.cjs.map +0 -1
  323. package/dist/QueueBuilder-Cue73M4t.mjs +0 -118
  324. package/dist/QueueBuilder-Cue73M4t.mjs.map +0 -1
  325. package/dist/QueueBuilder-OSi6LkV9.d.cts +0 -75
  326. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +0 -1
  327. package/dist/QueueBuilder-QHsnVt1P.d.mts +0 -75
  328. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +0 -1
  329. package/dist/Subscriber-Bpp02cGr.d.cts +0 -61
  330. package/dist/Subscriber-Bpp02cGr.d.cts.map +0 -1
  331. package/dist/Subscriber-CtN9R48-.d.mts +0 -61
  332. package/dist/Subscriber-CtN9R48-.d.mts.map +0 -1
  333. package/dist/SubscriberBuilder-CDy4nHCz.mjs +0 -134
  334. package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +0 -1
  335. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +0 -67
  336. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +0 -1
  337. package/dist/SubscriberBuilder-D_owVoHo.cjs +0 -145
  338. package/dist/SubscriberBuilder-D_owVoHo.cjs.map +0 -1
  339. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +0 -67
  340. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +0 -1
  341. package/dist/Topic-D74b5cgs.mjs +0 -99
  342. package/dist/Topic-D74b5cgs.mjs.map +0 -1
  343. package/dist/Topic-GHxcU8AG.cjs +0 -104
  344. package/dist/Topic-GHxcU8AG.cjs.map +0 -1
  345. package/dist/auth-BMCJN30Y.d.cts +0 -268
  346. package/dist/auth-BMCJN30Y.d.cts.map +0 -1
  347. package/dist/auth-CcuceLYo.d.mts +0 -268
  348. package/dist/auth-CcuceLYo.d.mts.map +0 -1
  349. package/dist/auth.cjs +0 -433
  350. package/dist/auth.cjs.map +0 -1
  351. package/dist/auth.d.cts +0 -2
  352. package/dist/auth.d.mts +0 -2
  353. package/dist/auth.mjs +0 -426
  354. package/dist/auth.mjs.map +0 -1
  355. package/dist/cache-CXh6GIgb.d.mts +0 -44
  356. package/dist/cache-CXh6GIgb.d.mts.map +0 -1
  357. package/dist/cache-DnGDGly3.d.cts +0 -44
  358. package/dist/cache-DnGDGly3.d.cts.map +0 -1
  359. package/dist/cache.cjs +0 -69
  360. package/dist/cache.cjs.map +0 -1
  361. package/dist/cache.d.cts +0 -2
  362. package/dist/cache.d.mts +0 -2
  363. package/dist/cache.mjs +0 -68
  364. package/dist/cache.mjs.map +0 -1
  365. package/dist/cipher-C1lEFX63.mjs +0 -225
  366. package/dist/cipher-C1lEFX63.mjs.map +0 -1
  367. package/dist/cipher-CVxfwLjk.cjs +0 -332
  368. package/dist/cipher-CVxfwLjk.cjs.map +0 -1
  369. package/dist/clone-EKNovYHu.mjs.map +0 -1
  370. package/dist/clone-UGJpvQnL.cjs.map +0 -1
  371. package/dist/construct-interface-B1AfqRl4.d.cts +0 -162
  372. package/dist/construct-interface-B1AfqRl4.d.cts.map +0 -1
  373. package/dist/construct-interface-DluK3_da.d.mts +0 -162
  374. package/dist/construct-interface-DluK3_da.d.mts.map +0 -1
  375. package/dist/construct-interface.cjs +0 -114
  376. package/dist/construct-interface.cjs.map +0 -1
  377. package/dist/construct-interface.d.cts +0 -2
  378. package/dist/construct-interface.d.mts +0 -2
  379. package/dist/construct-interface.mjs +0 -107
  380. package/dist/construct-interface.mjs.map +0 -1
  381. package/dist/credential.cjs +0 -156
  382. package/dist/credential.cjs.map +0 -1
  383. package/dist/credential.d.cts +0 -86
  384. package/dist/credential.d.cts.map +0 -1
  385. package/dist/credential.d.mts +0 -86
  386. package/dist/credential.d.mts.map +0 -1
  387. package/dist/credential.mjs +0 -152
  388. package/dist/credential.mjs.map +0 -1
  389. package/dist/database/kysely.cjs +0 -4
  390. package/dist/database/kysely.d.cts +0 -2
  391. package/dist/database/kysely.d.mts +0 -2
  392. package/dist/database/kysely.mjs +0 -2
  393. package/dist/email.cjs +0 -72
  394. package/dist/email.cjs.map +0 -1
  395. package/dist/email.d.cts +0 -46
  396. package/dist/email.d.cts.map +0 -1
  397. package/dist/email.d.mts +0 -46
  398. package/dist/email.d.mts.map +0 -1
  399. package/dist/email.mjs +0 -71
  400. package/dist/email.mjs.map +0 -1
  401. package/dist/encryption.cjs +0 -96
  402. package/dist/encryption.cjs.map +0 -1
  403. package/dist/encryption.d.cts +0 -117
  404. package/dist/encryption.d.cts.map +0 -1
  405. package/dist/encryption.d.mts +0 -117
  406. package/dist/encryption.d.mts.map +0 -1
  407. package/dist/encryption.mjs +0 -83
  408. package/dist/encryption.mjs.map +0 -1
  409. package/dist/external-api-MJ8id87V.d.mts +0 -105
  410. package/dist/external-api-MJ8id87V.d.mts.map +0 -1
  411. package/dist/external-api-O107yzZJ.d.cts +0 -105
  412. package/dist/external-api-O107yzZJ.d.cts.map +0 -1
  413. package/dist/external-api.cjs +0 -142
  414. package/dist/external-api.cjs.map +0 -1
  415. package/dist/external-api.d.cts +0 -2
  416. package/dist/external-api.d.mts +0 -2
  417. package/dist/external-api.mjs +0 -139
  418. package/dist/external-api.mjs.map +0 -1
  419. package/dist/file-server.cjs +0 -186
  420. package/dist/file-server.cjs.map +0 -1
  421. package/dist/file-server.d.cts +0 -152
  422. package/dist/file-server.d.cts.map +0 -1
  423. package/dist/file-server.d.mts +0 -152
  424. package/dist/file-server.d.mts.map +0 -1
  425. package/dist/file-server.mjs +0 -184
  426. package/dist/file-server.mjs.map +0 -1
  427. package/dist/functions-BFizikJU.mjs.map +0 -1
  428. package/dist/functions-CfzJG9hK.cjs.map +0 -1
  429. package/dist/index-BuzRvKOQ.d.cts +0 -115
  430. package/dist/index-BuzRvKOQ.d.cts.map +0 -1
  431. package/dist/index-CTkKOer4.d.mts +0 -115
  432. package/dist/index-CTkKOer4.d.mts.map +0 -1
  433. package/dist/index-CeEtxDmK.d.cts +0 -79
  434. package/dist/index-CeEtxDmK.d.cts.map +0 -1
  435. package/dist/index-CeEtxDmK.d.mts +0 -79
  436. package/dist/index-CeEtxDmK.d.mts.map +0 -1
  437. package/dist/index.d.cts.map +0 -1
  438. package/dist/index.d.mts.map +0 -1
  439. package/dist/kms-B-Hm3d5r.cjs +0 -85
  440. package/dist/kms-B-Hm3d5r.cjs.map +0 -1
  441. package/dist/kms-BdUlMJEZ.mjs +0 -85
  442. package/dist/kms-BdUlMJEZ.mjs.map +0 -1
  443. package/dist/kysely-Bii4l6eP.mjs +0 -370
  444. package/dist/kysely-Bii4l6eP.mjs.map +0 -1
  445. package/dist/kysely-CO_Dk43W.cjs +0 -383
  446. package/dist/kysely-CO_Dk43W.cjs.map +0 -1
  447. package/dist/kysely-D0bpzgPs.d.cts +0 -175
  448. package/dist/kysely-D0bpzgPs.d.cts.map +0 -1
  449. package/dist/kysely-DUqC3Ie0.d.mts +0 -175
  450. package/dist/kysely-DUqC3Ie0.d.mts.map +0 -1
  451. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +0 -1
  452. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +0 -1
  453. package/dist/lazyAccessors-CFanua0O.mjs +0 -174
  454. package/dist/lazyAccessors-CFanua0O.mjs.map +0 -1
  455. package/dist/lazyAccessors-hJKGv8Ay.cjs +0 -221
  456. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +0 -1
  457. package/dist/mobile-app.cjs +0 -73
  458. package/dist/mobile-app.cjs.map +0 -1
  459. package/dist/mobile-app.d.cts +0 -61
  460. package/dist/mobile-app.d.cts.map +0 -1
  461. package/dist/mobile-app.d.mts +0 -61
  462. package/dist/mobile-app.d.mts.map +0 -1
  463. package/dist/mobile-app.mjs +0 -72
  464. package/dist/mobile-app.mjs.map +0 -1
  465. package/dist/object-storage.cjs +0 -56
  466. package/dist/object-storage.cjs.map +0 -1
  467. package/dist/object-storage.d.cts +0 -32
  468. package/dist/object-storage.d.cts.map +0 -1
  469. package/dist/object-storage.d.mts +0 -32
  470. package/dist/object-storage.d.mts.map +0 -1
  471. package/dist/object-storage.mjs +0 -55
  472. package/dist/object-storage.mjs.map +0 -1
  473. package/dist/processAudits-BRRVVHUB.mjs +0 -131
  474. package/dist/processAudits-BRRVVHUB.mjs.map +0 -1
  475. package/dist/processAudits-DasOZjPl.cjs +0 -154
  476. package/dist/processAudits-DasOZjPl.cjs.map +0 -1
  477. package/dist/rest-api.cjs +0 -216
  478. package/dist/rest-api.cjs.map +0 -1
  479. package/dist/rest-api.d.cts +0 -241
  480. package/dist/rest-api.d.cts.map +0 -1
  481. package/dist/rest-api.d.mts +0 -241
  482. package/dist/rest-api.d.mts.map +0 -1
  483. package/dist/rest-api.mjs +0 -215
  484. package/dist/rest-api.mjs.map +0 -1
  485. package/dist/rolldown-runtime-y5ARvAq5.cjs +0 -35
  486. package/dist/runSubscriber-BHvJ8POr.mjs +0 -109
  487. package/dist/runSubscriber-BHvJ8POr.mjs.map +0 -1
  488. package/dist/runSubscriber-D8nLXIv1.cjs +0 -126
  489. package/dist/runSubscriber-D8nLXIv1.cjs.map +0 -1
  490. package/dist/shutdown-BMJmAhSt.cjs +0 -38
  491. package/dist/shutdown-BMJmAhSt.cjs.map +0 -1
  492. package/dist/shutdown-C7xa8x9S.mjs +0 -27
  493. package/dist/shutdown-C7xa8x9S.mjs.map +0 -1
  494. package/dist/site.cjs +0 -74
  495. package/dist/site.cjs.map +0 -1
  496. package/dist/site.d.cts +0 -104
  497. package/dist/site.d.cts.map +0 -1
  498. package/dist/site.d.mts +0 -104
  499. package/dist/site.d.mts.map +0 -1
  500. package/dist/site.mjs +0 -73
  501. package/dist/site.mjs.map +0 -1
  502. package/dist/stages-BSCF19o2.d.cts +0 -56
  503. package/dist/stages-BSCF19o2.d.cts.map +0 -1
  504. package/dist/stages-BSCF19o2.d.mts +0 -56
  505. package/dist/stages-BSCF19o2.d.mts.map +0 -1
  506. package/dist/surfaceEnv-CNimK76p.cjs +0 -56
  507. package/dist/surfaceEnv-CNimK76p.cjs.map +0 -1
  508. package/dist/surfaceEnv-wMT5QzgZ.mjs +0 -45
  509. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +0 -1
  510. package/dist/telemetry-B48RLjyk.d.cts +0 -40
  511. package/dist/telemetry-B48RLjyk.d.cts.map +0 -1
  512. package/dist/telemetry-DRtT1_0A.d.mts +0 -40
  513. package/dist/telemetry-DRtT1_0A.d.mts.map +0 -1
  514. package/dist/telemetry.cjs +0 -56
  515. package/dist/telemetry.cjs.map +0 -1
  516. package/dist/telemetry.d.cts +0 -2
  517. package/dist/telemetry.d.mts +0 -2
  518. package/dist/telemetry.mjs +0 -55
  519. package/dist/telemetry.mjs.map +0 -1
  520. package/dist/tracing-CxaZ98IB.mjs +0 -110
  521. package/dist/tracing-CxaZ98IB.mjs.map +0 -1
  522. package/dist/tracing-DPMidF_r.cjs +0 -127
  523. package/dist/tracing-DPMidF_r.cjs.map +0 -1
  524. package/dist/types-DMuSQeLL.d.cts.map +0 -1
  525. package/dist/types-DMuSQeLL.d.mts.map +0 -1
  526. package/dist/worker.cjs +0 -191
  527. package/dist/worker.cjs.map +0 -1
  528. package/dist/worker.d.cts +0 -171
  529. package/dist/worker.d.cts.map +0 -1
  530. package/dist/worker.d.mts +0 -171
  531. package/dist/worker.d.mts.map +0 -1
  532. package/dist/worker.mjs +0 -190
  533. package/dist/worker.mjs.map +0 -1
package/README.md CHANGED
@@ -25,61 +25,36 @@ pnpm add @geekmidas/constructs
25
25
  ## Package Exports
26
26
 
27
27
  ```typescript
28
- // The HTTP surface. Endpoints are built from it — `api.get(…)`, or
29
- // `api.database(db)` for a branch that a group of endpoints shares.
30
- import { RestApi } from '@geekmidas/constructs/rest-api';
28
+ // Endpoints
29
+ import { e, EndpointBuilder } from '@geekmidas/constructs/endpoints';
31
30
 
32
- // Endpoint internals: the factory a surface hands you, and the builder it
33
- // returns. There is no free-standing `e` — an endpoint belongs to a surface.
34
- import { EndpointBuilder, EndpointFactory } from '@geekmidas/constructs/endpoints';
31
+ // Functions
32
+ import { f, FunctionBuilder } from '@geekmidas/constructs/functions';
35
33
 
36
- // The process with no port. Crons, topic subscribers, queues and functions
37
- // are built from it — `worker.cron(…)`, `worker.topic(…)`, `worker.queue(…)`,
38
- // `worker.input(…)` — and carry its logger.
39
- import { Worker } from '@geekmidas/constructs/worker';
34
+ // Crons
35
+ import { cron, CronBuilder } from '@geekmidas/constructs/crons';
40
36
 
41
- // A declared event contract. Its publisher is its `service`.
42
- import { Topic } from '@geekmidas/constructs/topic';
37
+ // Subscribers
38
+ import { SubscriberBuilder } from '@geekmidas/constructs/subscribers';
43
39
  ```
44
40
 
45
41
  ## Quick Start
46
42
 
47
43
  ### HTTP Endpoints
48
44
 
49
- An endpoint is built from the surface that will serve it. Declare the surface
50
- once — one `RestApi` is one server — and everything built from it carries its
51
- logger, its environment parser and its authorizers:
45
+ Create type-safe HTTP endpoints with the fluent builder pattern:
52
46
 
53
47
  ```typescript
54
- // constructs/api.ts
55
- import { RestApi } from '@geekmidas/constructs/rest-api';
56
- import { logger } from './logger';
57
-
58
- export const api = new RestApi('Api', {
59
- path: 'apps/api',
60
- // Required, and `'none'` is a valid answer that has to be typed out. An API
61
- // that ships open because a field was left off is the one default worth
62
- // refusing to have.
63
- defaultAuthorizer: 'none',
64
- // The actual logger, not a path to one.
65
- logger,
66
- });
67
- ```
68
-
69
- Then build endpoints from it with the fluent builder pattern:
70
-
71
- ```typescript
72
- // endpoints/users.ts
73
- import { api } from '../constructs/api';
48
+ import { e } from '@geekmidas/constructs/endpoints';
74
49
  import { z } from 'zod';
75
50
 
76
51
  // Simple GET endpoint
77
- export const getUsers = api
52
+ export const getUsers = e
78
53
  .get('/users')
79
54
  .output(z.array(z.object({
80
55
  id: z.string(),
81
56
  name: z.string(),
82
- email: z.email()
57
+ email: z.string().email()
83
58
  })))
84
59
  .handle(async () => {
85
60
  return [
@@ -88,11 +63,11 @@ export const getUsers = api
88
63
  });
89
64
 
90
65
  // POST endpoint with body validation
91
- export const createUser = api
66
+ export const createUser = e
92
67
  .post('/users')
93
68
  .body(z.object({
94
69
  name: z.string().min(1),
95
- email: z.email()
70
+ email: z.string().email()
96
71
  }))
97
72
  .output(z.object({
98
73
  id: z.string(),
@@ -109,7 +84,7 @@ export const createUser = api
109
84
  });
110
85
 
111
86
  // Endpoint with query parameters
112
- export const searchUsers = api
87
+ export const searchUsers = e
113
88
  .get('/users/search')
114
89
  .query(z.object({
115
90
  q: z.string(),
@@ -125,31 +100,15 @@ export const searchUsers = api
125
100
  });
126
101
  ```
127
102
 
128
- ### The Worker
129
-
130
- Everything that is not an HTTP route is built from a `Worker`: the process
131
- that runs a schedule, drains a queue or consumes a topic. It takes no
132
- authorizer, because nothing reaches it from outside.
133
-
134
- ```typescript
135
- // constructs/worker.ts
136
- import { Worker } from '@geekmidas/constructs/worker';
137
- import { database } from './database';
138
- import { logger } from './logger';
139
-
140
- // `.database(…)` is where a server target keeps cron schedules.
141
- export const worker = new Worker('Jobs', { logger }).database(database);
142
- ```
143
-
144
103
  ### Cloud Functions
145
104
 
146
- Create functions with input/output validation:
105
+ Create serverless functions with input/output validation:
147
106
 
148
107
  ```typescript
149
- import { worker } from '../constructs/worker';
108
+ import { f } from '@geekmidas/constructs/functions';
150
109
  import { z } from 'zod';
151
110
 
152
- export const processOrder = worker
111
+ export const processOrder = f
153
112
  .input(z.object({
154
113
  orderId: z.string(),
155
114
  items: z.array(z.object({
@@ -160,12 +119,13 @@ export const processOrder = worker
160
119
  .output(z.object({
161
120
  orderId: z.string(),
162
121
  status: z.enum(['processing', 'completed', 'failed']),
163
- processedAt: z.iso.datetime()
122
+ processedAt: z.string().datetime()
164
123
  }))
165
124
  .timeout(300000) // 5 minutes
166
125
  .handle(async ({ input, logger }) => {
167
126
  logger.info(`Processing order ${input.orderId}`);
168
127
 
128
+ // Process order logic
169
129
  for (const item of input.items) {
170
130
  logger.info(`Processing item ${item.id}, quantity: ${item.quantity}`);
171
131
  }
@@ -180,99 +140,87 @@ export const processOrder = worker
180
140
 
181
141
  ### Scheduled Tasks (Crons)
182
142
 
143
+ Define cron jobs with schedules:
144
+
183
145
  ```typescript
184
- import { worker } from '../constructs/worker';
146
+ import { cron } from '@geekmidas/constructs/crons';
185
147
 
186
148
  // Daily report at 9 AM UTC
187
- export const dailyReport = worker
188
- .cron('cron(0 9 * * ? *)')
149
+ export const dailyReport = cron
150
+ .schedule('cron(0 9 * * ? *)')
189
151
  .timeout(600000) // 10 minutes
190
152
  .handle(async ({ logger }) => {
153
+ logger.info('Generating daily report');
154
+
155
+ const reportDate = new Date().toISOString().split('T')[0];
191
156
  const reportData = {
192
- date: new Date().toISOString().split('T')[0],
157
+ date: reportDate,
193
158
  totalOrders: 150,
159
+ totalRevenue: 12500.00
194
160
  };
195
161
 
196
- logger.info(reportData, 'Daily report generated');
162
+ logger.info('Daily report generated', reportData);
197
163
  return reportData;
198
164
  });
199
165
 
200
166
  // Hourly cleanup
201
- export const hourlyCleanup = worker
202
- .cron('rate(1 hour)')
203
- .dependsOn([database])
204
- .handle(async ({ services, logger }) => {
205
- const result = await services.database
206
- .deleteFrom('sessions')
207
- .where('expires_at', '<', new Date())
208
- .executeTakeFirst();
167
+ export const hourlyCleanup = cron
168
+ .schedule('rate(1 hour)')
169
+ .timeout(300000) // 5 minutes
170
+ .handle(async ({ logger }) => {
171
+ logger.info('Running hourly cleanup');
172
+
173
+ const itemsCleaned = 42;
174
+ logger.info(`Cleaned ${itemsCleaned} items`);
209
175
 
210
- logger.info({ deleted: Number(result.numDeletedRows) }, 'Cleaned up');
176
+ return { itemsCleaned };
211
177
  });
212
178
  ```
213
179
 
214
- On AWS a cron is an EventBridge rule; on a server the worker schedules it in
215
- the database it was given.
216
-
217
- ### Topics and Subscribers
180
+ ### Event Subscribers
218
181
 
219
- A topic declares the event contract once. A subscriber binds to it from the
220
- worker and is typed by it:
182
+ Handle events with type-safe message processing:
221
183
 
222
184
  ```typescript
223
- // constructs/topics.ts
224
- import { Topic } from '@geekmidas/constructs/topic';
185
+ import { SubscriberBuilder } from '@geekmidas/constructs/subscribers';
225
186
  import { z } from 'zod';
226
187
 
227
- export const users = new Topic('Users', {
228
- events: {
229
- 'user.created': z.object({ userId: z.string(), email: z.email() }),
230
- 'user.updated': z.object({ userId: z.string(), changes: z.array(z.string()) }),
231
- },
232
- });
233
-
234
- // subscribers/userEvents.ts
235
- export const userEventsSubscriber = worker
236
- .topic(users)
237
- .subscribe(['user.created', 'user.updated'])
188
+ export const userEventsSubscriber = new SubscriberBuilder()
189
+ .subscribe(['user.created', 'user.updated', 'user.deleted'])
190
+ .timeout(30000)
191
+ .output(z.object({
192
+ processed: z.number(),
193
+ success: z.boolean()
194
+ }))
238
195
  .handle(async ({ events, logger }) => {
239
- for (const event of events) {
240
- // event.type narrows event.payload to that event's schema
241
- logger.info({ type: event.type, userId: event.payload.userId }, 'User event');
242
- }
243
- });
244
- ```
245
-
246
- A subscriber is bound, not handed a publisher. One that emits follow-ups
247
- depends on the topic it emits to: `.dependsOn([notifications])`.
196
+ logger.info(
197
+ { eventCount: events.length },
198
+ 'Processing user events'
199
+ );
248
200
 
249
- ### Queues
250
-
251
- A queue and its one consumer are one construct. Producers send by depending on
252
- it:
253
-
254
- ```typescript
255
- // queues/emails.ts
256
- export const emails = worker
257
- .queue('Emails')
258
- .message(z.object({ to: z.email(), template: z.enum(['welcome']) }))
259
- .dependsOn([mail])
260
- .handle(async ({ messages, services }) => {
261
- for (const { to, template } of messages) {
262
- await services.mail.sendTemplate(template, { to, subject: 'Welcome', props: {} });
201
+ for (const event of events) {
202
+ try {
203
+ switch (event.type) {
204
+ case 'user.created':
205
+ logger.info({ userId: event.data.userId }, 'User created');
206
+ break;
207
+ case 'user.updated':
208
+ logger.info({ userId: event.data.userId }, 'User updated');
209
+ break;
210
+ case 'user.deleted':
211
+ logger.info({ userId: event.data.userId }, 'User deleted');
212
+ break;
213
+ }
214
+ } catch (error) {
215
+ logger.error({ error, event }, 'Failed to process event');
216
+ throw error;
217
+ }
263
218
  }
264
- });
265
219
 
266
- // endpoints/invites.ts
267
- export const invite = api
268
- .post('/invites')
269
- .body(z.object({ email: z.email() }))
270
- .dependsOn([emails])
271
- .handle(async ({ body, services }) => {
272
- // `type` is the queue's name exactly as written
273
- await services.emails.publish([
274
- { type: 'Emails', payload: { to: body.email, template: 'welcome' } },
275
- ]);
220
+ return {
221
+ processed: events.length,
222
+ success: true
223
+ };
276
224
  });
277
225
  ```
278
226
 
@@ -296,10 +244,10 @@ The following authorizer names automatically map to OpenAPI security schemes:
296
244
  | `iam` | `{ type: 'apiKey', in: 'header', name: 'Authorization' }` (AWS SigV4) |
297
245
 
298
246
  ```typescript
299
- import { api } from '../constructs/api';
247
+ import { e } from '@geekmidas/constructs/endpoints';
300
248
 
301
249
  // Using built-in 'jwt' scheme
302
- export const getUsers = api
250
+ export const getUsers = e
303
251
  .get('/users')
304
252
  .authorizer('jwt') // Automatically uses JWT security scheme
305
253
  .handle(async ({ session }) => {
@@ -310,12 +258,12 @@ export const getUsers = api
310
258
 
311
259
  #### Custom Security Schemes
312
260
 
313
- For custom authentication methods, use `.securitySchemes()` on the surface's factory:
261
+ For custom authentication methods, use `.securitySchemes()` on the EndpointFactory:
314
262
 
315
263
  ```typescript
316
- import { api } from '../constructs/api';
264
+ import { EndpointFactory } from '@geekmidas/constructs/endpoints';
317
265
 
318
- const router = api
266
+ const api = new EndpointFactory()
319
267
  .securitySchemes({
320
268
  // Custom OAuth2 with specific flows
321
269
  oauth2: {
@@ -340,7 +288,7 @@ const router = api
340
288
  });
341
289
 
342
290
  // Use custom security scheme
343
- export const getUsers = router
291
+ export const getUsers = api
344
292
  .get('/users')
345
293
  .authorizer('oauth2')
346
294
  .handle(async () => []);
@@ -348,97 +296,125 @@ export const getUsers = router
348
296
 
349
297
  #### Default Authorizer
350
298
 
351
- Set a default authorizer for every endpoint built from one branch:
299
+ Set a default authorizer for all endpoints from a factory:
352
300
 
353
301
  ```typescript
354
- // A branch of the surface's factory, with a default every endpoint on it
355
- // inherits. (The surface's own `default` does the same thing for every
356
- // endpoint it serves — this narrows it for one group.)
357
- const router = api.authorizer('jwt');
302
+ const api = new EndpointFactory()
303
+ .authorizer('jwt'); // All endpoints inherit this authorizer
358
304
 
359
305
  // Protected by default
360
- export const getProfile = router
306
+ export const getProfile = api
361
307
  .get('/profile')
362
308
  .handle(async ({ session }) => {
363
309
  return { userId: session.claims.sub };
364
310
  });
365
311
 
366
312
  // Override to make public
367
- export const getHealth = router
313
+ export const getHealth = api
368
314
  .get('/health')
369
315
  .authorizer('none') // Explicitly public
370
316
  .handle(async () => ({ status: 'ok' }));
371
317
  ```
372
318
 
373
- ### Dependencies
319
+ ### Service Discovery
374
320
 
375
- `.dependsOn([...])` takes constructs. Each one's client lands in the handler's
376
- `services` under the construct's own id, and the edge is what the manifest
377
- records — so the environment, the runtime client and the cloud access all come
378
- from the one line:
321
+ Inject services into your constructs:
379
322
 
380
323
  ```typescript
381
- import { api } from '../constructs/api';
382
- import { database } from '../constructs/database';
324
+ import { e } from '@geekmidas/constructs/endpoints';
325
+ import type { Service } from '@geekmidas/services';
326
+ import type { EnvironmentParser } from '@geekmidas/envkit';
327
+ import { Kysely } from 'kysely';
383
328
  import { z } from 'zod';
384
329
 
385
- export const getUserFromDb = api
330
+ // Define a database service
331
+ const databaseService = {
332
+ serviceName: 'database' as const,
333
+ async register(envParser: EnvironmentParser<{}>) {
334
+ const config = envParser.create((get) => ({
335
+ url: get('DATABASE_URL').string()
336
+ })).parse();
337
+
338
+ const db = new Kysely({ /* config */ });
339
+ return db;
340
+ }
341
+ } satisfies Service<'database', Kysely<Database>>;
342
+
343
+ // Use service in endpoint
344
+ export const getUserFromDb = e
386
345
  .get('/users/:id')
387
346
  .params(z.object({ id: z.string() }))
388
- .dependsOn([database])
347
+ .services([databaseService])
389
348
  .handle(async ({ params, services }) => {
390
- // services.database is a Kysely client typed by the construct's schema
391
- return services.database
349
+ // services.database is fully typed
350
+ const user = await services.database
392
351
  .selectFrom('users')
393
352
  .where('id', '=', params.id)
394
353
  .selectAll()
395
354
  .executeTakeFirst();
355
+
356
+ return user;
396
357
  });
397
358
  ```
398
359
 
399
- A hand-written `Service` still works through `.services()` on every builder,
400
- for code that has not moved to a construct yet. It records no edge, so a deploy
401
- target cannot grant it anything.
402
-
403
360
  ### Event Publishing
404
361
 
405
- An endpoint, function or cron publishes to a topic with `.event(topic, …)`,
406
- once its handler has succeeded:
362
+ Publish events from any construct:
407
363
 
408
364
  ```typescript
409
- import { users } from '../constructs/topics';
365
+ import { e } from '@geekmidas/constructs/endpoints';
366
+ import type { Service } from '@geekmidas/services';
367
+ import type { EventPublisher, PublishableMessage } from '@geekmidas/events';
368
+ import { z } from 'zod';
410
369
 
411
- export const createUser = router
412
- .post('/users')
413
- .body(z.object({ name: z.string(), email: z.email() }))
414
- .output(z.object({ id: z.string(), name: z.string(), email: z.email() }))
415
- .event(users, {
416
- type: 'user.created',
417
- payload: (user) => ({ userId: user.id, email: user.email }),
418
- when: (user) => !user.email.endsWith('@example.com'), // optional
419
- })
420
- .handle(async ({ body }) => ({ id: crypto.randomUUID(), ...body }));
421
- ```
370
+ // Define event types
371
+ type UserEvents =
372
+ | PublishableMessage<'user.created', { userId: string; email: string }>
373
+ | PublishableMessage<'user.updated', { userId: string }>;
422
374
 
423
- - `type` is checked against the topic's events, and `payload` against that
424
- event's schema.
425
- - `.event()` is repeatable across topics. Two calls to two topics publish to
426
- each, every event through its own topic's publisher.
427
- - It also puts the topic's publisher in the handler as `services.users`, as
428
- `.dependsOn([users])` would, for events the handler decides on:
429
- `await services.users.publish([{ type: 'user.updated', payload }])`.
430
- - A failed publish is logged, never thrown — the handler already succeeded.
375
+ // Create event publisher service
376
+ const userEventPublisher = {
377
+ serviceName: 'userEventPublisher' as const,
378
+ async register(envParser: EnvironmentParser<{}>) {
379
+ const config = envParser.create((get) => ({
380
+ publisherUrl: get('EVENT_PUBLISHER_URL').string()
381
+ })).parse();
431
382
 
432
- The publisher reads `USERS_PUBLISHER_CONNECTION_STRING`, which only constructs
433
- that publish to the topic are given, and picks its transport from the protocol:
434
- `pgboss://` locally, `sns://` deployed.
383
+ const { Publisher } = await import('@geekmidas/events');
384
+ return Publisher.fromConnectionString<UserEvents>(config.publisherUrl);
385
+ }
386
+ } satisfies Service<'userEventPublisher', EventPublisher<UserEvents>>;
387
+
388
+ // Use in endpoint with event publishing
389
+ export const createUser = e
390
+ .post('/users')
391
+ .body(z.object({
392
+ name: z.string(),
393
+ email: z.string().email()
394
+ }))
395
+ .publisher(userEventPublisher)
396
+ .event('user.created', (body, result) => ({
397
+ userId: result.id,
398
+ email: body.email
399
+ }))
400
+ .handle(async ({ body, publish }) => {
401
+ const user = {
402
+ id: crypto.randomUUID(),
403
+ name: body.name,
404
+ email: body.email
405
+ };
406
+
407
+ // Events are automatically published after successful execution
408
+ return user;
409
+ });
410
+ ```
435
411
 
436
412
  ### Database Context
437
413
 
438
414
  Inject a database instance directly into the handler context using `.database()`:
439
415
 
440
416
  ```typescript
441
- import { api } from '../constructs/api';
417
+ import { e } from '@geekmidas/constructs/endpoints';
442
418
  import type { Service } from '@geekmidas/services';
443
419
  import type { EnvironmentParser } from '@geekmidas/envkit';
444
420
  import { Kysely, PostgresDialect } from 'kysely';
@@ -461,7 +437,7 @@ const databaseService = {
461
437
  } satisfies Service<'database', Kysely<Database>>;
462
438
 
463
439
  // Use .database() to inject db into context
464
- export const getUsers = api
440
+ export const getUsers = e
465
441
  .get('/users')
466
442
  .output(z.array(userSchema))
467
443
  .database(databaseService)
@@ -487,9 +463,9 @@ export const getUsers = api
487
463
  When using both `.database()` and `.auditor()` with the same database, `db` is automatically the transaction - ensuring ACID compliance without any extra code:
488
464
 
489
465
  ```typescript
490
- export const createUser = api
466
+ export const createUser = e
491
467
  .post('/users')
492
- .body(z.object({ name: z.string(), email: z.email() }))
468
+ .body(z.object({ name: z.string(), email: z.string().email() }))
493
469
  .output(userSchema)
494
470
  .database(databaseService)
495
471
  .auditor(auditStorageService)
@@ -573,18 +549,18 @@ type AppAuditAction =
573
549
  Define audits declaratively on the endpoint - they're automatically recorded after successful handler execution:
574
550
 
575
551
  ```typescript
576
- import { api } from '../constructs/api';
552
+ import { e } from '@geekmidas/constructs/endpoints';
577
553
  import { z } from 'zod';
578
554
 
579
555
  const userSchema = z.object({
580
556
  id: z.string(),
581
557
  name: z.string(),
582
- email: z.email()
558
+ email: z.string().email()
583
559
  });
584
560
 
585
- export const createUser = api
561
+ export const createUser = e
586
562
  .post('/users')
587
- .body(z.object({ name: z.string(), email: z.email() }))
563
+ .body(z.object({ name: z.string(), email: z.string().email() }))
588
564
  .output(userSchema)
589
565
  .database(databaseService)
590
566
  .auditor(auditStorageService)
@@ -628,12 +604,11 @@ export const createUser = api
628
604
  For complex scenarios, use `ctx.auditor` to record audits manually within your handler:
629
605
 
630
606
  ```typescript
631
- export const processOrder = api
632
- .database(database)
633
- .auditor(auditStorageService)
607
+ export const processOrder = e
634
608
  .post('/orders')
635
- // `payments` is an ExternalApi whose client has `charge()`
636
- .dependsOn([payments])
609
+ .database(databaseService)
610
+ .services([paymentService])
611
+ .auditor(auditStorageService)
637
612
  .actor(({ session }) => ({ id: session.userId, type: 'user' }))
638
613
  .handle(async ({ body, db, services, auditor }) => {
639
614
  // db is automatically the transaction when auditor uses KyselyAuditStorage
@@ -644,7 +619,7 @@ export const processOrder = api
644
619
  .executeTakeFirstOrThrow();
645
620
 
646
621
  // Manual audit for payment (external service call)
647
- const payment = await services.payments.charge(order.total);
622
+ const payment = await services.payment.charge(order.total);
648
623
  auditor.audit('payment.processed', {
649
624
  orderId: order.id,
650
625
  amount: order.total,
@@ -669,10 +644,10 @@ export const processOrder = api
669
644
  You can use both approaches together:
670
645
 
671
646
  ```typescript
672
- export const updateUser = api
647
+ export const updateUser = e
673
648
  .put('/users/:id')
674
649
  .params(z.object({ id: z.string() }))
675
- .body(z.object({ name: z.string().optional(), email: z.email().optional() }))
650
+ .body(z.object({ name: z.string().optional(), email: z.string().email().optional() }))
676
651
  .output(userSchema)
677
652
  .database(databaseService)
678
653
  .auditor(auditStorageService)
@@ -885,11 +860,11 @@ const audits = await auditStorage.query({
885
860
  Add rate limiting to endpoints:
886
861
 
887
862
  ```typescript
888
- import { api } from '../constructs/api';
863
+ import { e } from '@geekmidas/constructs/endpoints';
889
864
  import { InMemoryCache } from '@geekmidas/cache/memory';
890
865
  import { z } from 'zod';
891
866
 
892
- export const sendMessage = api
867
+ export const sendMessage = e
893
868
  .post('/api/messages')
894
869
  .rateLimit({
895
870
  limit: 10,
@@ -905,69 +880,6 @@ export const sendMessage = api
905
880
  });
906
881
  ```
907
882
 
908
- ## Feature Tests
909
-
910
- A feature test drives an app the way it runs deployed: a browser signs in and
911
- calls the API, the API asks the auth server who is calling, each over its URL,
912
- and every database is in its own transaction, rolled back after the test.
913
- Nothing runs as a server — each URL an app's constructs answer on is served
914
- in-process through MSW, from the real handler, for the test that made the
915
- request. Postgres, Mailpit and MinIO are the real local ones `gkm test` starts.
916
-
917
- Nothing is declared in test code. `gkm test` writes `.gkm/test/` into each app:
918
-
919
- - `manifest.json` — which construct and endpoint is exported where, and the
920
- test stage's environment, keyed as the constructs derive their keys;
921
- - `clients/<surface>.ts` — each surface's typed client, from the same generator
922
- `gkm build` uses;
923
- - `index.ts` — a `Browser` with a client per surface (`Api` → `browser.api`)
924
- and per auth server (`browser.auth`, its better-auth plugins paired with
925
- their client plugins), and the configured `it`.
926
-
927
- Map it once in the app's `package.json` — `"imports": { "#test":
928
- "./.gkm/test/index.ts" }` — and a test is:
929
-
930
- ```typescript
931
- import { it } from '#test';
932
-
933
- it('shows the signed-in user their orders', async ({ browser, db, factories }) => {
934
- const factory = await factories.get('database');
935
- await factory.insert('orders', { email: 'ada@shop.test' });
936
-
937
- await browser.signIn('ada@shop.test');
938
- const { orders } = await browser.api.get('/orders');
939
- expect(orders).toHaveLength(1);
940
-
941
- const app = await db.get('database');
942
- expect(await app.selectFrom('orders').selectAll().execute()).toHaveLength(1);
943
- });
944
- ```
945
-
946
- - **`browser`** — already the global `fetch`; its cookie jar follows the
947
- browser's rules, so a session cookie set for the wrong domain never reaches
948
- the API.
949
- - **`browser.signIn(email)`** — when the auth server has the magic-link plugin
950
- and the app sends mail: the link requested, read from the inbox and
951
- followed, as a person signs in. Returns the session the auth server reports.
952
- - **`db.get(name)`** — the app's own databases by service name
953
- (`db.get('database')`), each this test's transaction, typed by its schema.
954
- Opened on first use by whatever reaches it first — the test, a factory, an
955
- endpoint — and the same one for all of them. A tenant an auth server owns is
956
- not among them: it is reached through the auth server, as the app reaches
957
- it. Nor is a reader.
958
- - **`factories.get(name)`** — each of those databases' factory, from
959
- `test/factories/<construct>.ts` at the project root, on the same
960
- transaction: `(await factories.get('database')).insert('users', …)`.
961
- - **`mailbox(address)`** — the mail actually sent, read from Mailpit.
962
- - **`published(topic | queue)`** — what the test published or enqueued.
963
- Nothing is delivered: a subscriber or a worker is run on its own with
964
- **`subscriber(s).invoke({ events })`** / **`queue(q).invoke({ messages })`**,
965
- on the test's services and transactions.
966
- - Each database construct — the app's and each schema tenant — gets its own
967
- transaction on its own connection, as deployed.
968
- - A request that belongs to no running test is refused with
969
- `UnknownTestContext` rather than reaching another test's data.
970
-
971
883
  ## AWS Lambda Adapters
972
884
 
973
885
  Deploy your constructs to AWS Lambda:
@@ -1093,20 +1005,20 @@ All constructs support automatic environment variable detection for build-time i
1093
1005
  Every construct has an async `getEnvironment()` method that returns the environment variables required by its services:
1094
1006
 
1095
1007
  ```typescript
1096
- import { api } from '../constructs/api';
1097
- import { cache } from '../constructs/cache';
1098
- import { database } from '../constructs/database';
1008
+ import { e } from '@geekmidas/constructs/endpoints';
1009
+ import { databaseService } from './services/database';
1010
+ import { cacheService } from './services/cache';
1099
1011
 
1100
- const endpoint = api
1012
+ const endpoint = e
1101
1013
  .get('/users')
1102
- .dependsOn([database, cache])
1014
+ .services([databaseService, cacheService])
1103
1015
  .handle(async ({ services }) => {
1104
1016
  // Implementation
1105
1017
  });
1106
1018
 
1107
1019
  // Detect required environment variables
1108
1020
  const envVars = await endpoint.getEnvironment();
1109
- // Returns: ['DATABASE_URL', 'SESSIONS_URL'] (sorted alphabetically)
1021
+ // Returns: ['CACHE_URL', 'DATABASE_URL'] (sorted alphabetically)
1110
1022
  ```
1111
1023
 
1112
1024
  ### How It Works
@@ -1194,37 +1106,33 @@ This manifest can then be used by infrastructure-as-code tools (Terraform, CDK,
1194
1106
  - **Deduplication**: Each variable listed once even if used by multiple services
1195
1107
  - **Sorted Output**: Variables always returned in alphabetical order
1196
1108
  - **Error Resilient**: Parse failures don't affect detection
1197
- - **Topic Support**: A topic named by `.event(topic, …)` contributes its `<ID>_PUBLISHER_CONNECTION_STRING`
1109
+ - **Publisher Support**: Detects variables from `.publisher()` services
1198
1110
 
1199
1111
  ### Example with Multiple Services
1200
1112
 
1201
1113
  ```typescript
1202
- import { api } from '../constructs/api';
1203
- import { cache } from '../constructs/cache';
1204
- import { database } from '../constructs/database';
1205
- import { mail } from '../constructs/email';
1206
- import { users } from '../constructs/topics';
1114
+ import { e } from '@geekmidas/constructs/endpoints';
1115
+ import { databaseService } from './services/database';
1116
+ import { cacheService } from './services/cache';
1117
+ import { emailService } from './services/email';
1207
1118
 
1208
- const endpoint = api
1119
+ const endpoint = e
1209
1120
  .post('/users')
1210
- .dependsOn([database, cache, mail])
1211
- .output(userSchema)
1212
- .event(users, {
1213
- type: 'user.created',
1214
- payload: (user) => ({ userId: user.id, email: user.email }),
1215
- })
1121
+ .services([databaseService, cacheService, emailService])
1216
1122
  .handle(async ({ services }) => {
1217
1123
  // Create user
1218
1124
  });
1219
1125
 
1220
- // Detects the keys of every construct it names
1126
+ // Automatically detects all variables from all services
1221
1127
  const envVars = await endpoint.getEnvironment();
1222
1128
  // Returns: [
1129
+ // 'CACHE_URL',
1223
1130
  // 'DATABASE_URL',
1224
- // 'MAIL_FROM',
1225
- // 'MAIL_URL',
1226
- // 'SESSIONS_URL',
1227
- // 'USERS_PUBLISHER_CONNECTION_STRING'
1131
+ // 'DATABASE_PORT',
1132
+ // 'SMTP_HOST',
1133
+ // 'SMTP_PORT',
1134
+ // 'SMTP_USER',
1135
+ // 'SMTP_PASS'
1228
1136
  // ]
1229
1137
  ```
1230
1138