@classytic/arc 2.41.0 → 2.43.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 (230) hide show
  1. package/dist/{EventTransport-CbUKDzZZ.d.mts → EventTransport-CiicKz2Z.d.mts} +1 -1
  2. package/dist/{EventTransport-n7qO5Cz3.mjs → EventTransport-tzA7CAB4.mjs} +22 -17
  3. package/dist/{HookSystem-CxvZBo77.mjs → HookSystem-B6UaKRbF.mjs} +2 -2
  4. package/dist/{QueryCache-DFA-QrU9.d.mts → QueryCache--5uAuYPW.d.mts} +7 -3
  5. package/dist/{ResourceRegistry-Cu7uTJp9.mjs → ResourceRegistry-CuCARu2B.mjs} +44 -13
  6. package/dist/actionPermissions-BotX1YOa.mjs +776 -0
  7. package/dist/audit/index.d.mts +43 -5
  8. package/dist/audit/index.mjs +48 -26
  9. package/dist/auth/audit.mjs +1 -1
  10. package/dist/auth/index.d.mts +43 -13
  11. package/dist/auth/index.mjs +130 -155
  12. package/dist/auth/redis-session.mjs +1 -1
  13. package/dist/{authorizationDecision-2YY_Kaj1.mjs → authorizationDecision-DQYrkl5f.mjs} +7 -102
  14. package/dist/{base-CxrV1LmG.d.mts → base-CZyixEQR.d.mts} +27 -5
  15. package/dist/boundedMap-BULzfXYU.mjs +57 -0
  16. package/dist/{buildHandler-CUhjGHGZ.mjs → buildHandler-CRQ8EcX5.mjs} +4 -4
  17. package/dist/cache/index.d.mts +22 -34
  18. package/dist/cache/index.mjs +4 -4
  19. package/dist/{caching-DsWDjIxx.mjs → caching-Cc2M1DwO.mjs} +3 -3
  20. package/dist/claimed-B10RTfkM.mjs +8 -0
  21. package/dist/cleanup/index.d.mts +6 -10
  22. package/dist/cleanup/index.mjs +27 -73
  23. package/dist/cli/commands/describe.d.mts +4 -2
  24. package/dist/cli/commands/describe.mjs +7 -4
  25. package/dist/cli/commands/docs.mjs +3 -3
  26. package/dist/cli/commands/doctor.mjs +1 -1
  27. package/dist/cli/commands/generate.mjs +2 -2
  28. package/dist/cli/commands/init.mjs +2 -2
  29. package/dist/cli/commands/introspect.mjs +2 -2
  30. package/dist/cli/index.mjs +3 -3
  31. package/dist/{constants-BxLgNFF7.mjs → constants-Cu7Mx7_U.mjs} +4 -2
  32. package/dist/context/index.d.mts +2 -5
  33. package/dist/context/index.mjs +18 -38
  34. package/dist/core/index.d.mts +3 -3
  35. package/dist/core/index.mjs +8 -8
  36. package/dist/{core-iNGqYerO.mjs → core-Cb0LjccA.mjs} +5 -4
  37. package/dist/{createActionRouter-BBlbPs3k.mjs → createActionRouter-xjqonMRO.mjs} +87 -39
  38. package/dist/{createAggregationRouter-Dv5SuK2x.mjs → createAggregationRouter-zRYWw_5D.mjs} +11 -8
  39. package/dist/{preloadResources-Bbp4QJ8V.mjs → createApp-D-953ZAq.mjs} +299 -390
  40. package/dist/{createMcpServer-CbDWkZ1T.d.mts → createMcpServer-C9cxS8zt.d.mts} +1 -1
  41. package/dist/{defineAggregation-UyeurGkp.mjs → defineAggregation-Bm8RjMbq.mjs} +1 -1
  42. package/dist/{defineResource-DzGT-2LP.mjs → defineResource-DIC7JZGU.mjs} +118 -1024
  43. package/dist/discovery/index.mjs +1 -1
  44. package/dist/docs/index.d.mts +10 -4
  45. package/dist/docs/index.mjs +4 -4
  46. package/dist/{elevation-BXCfVcNG.d.mts → elevation-BW2J3tNj.d.mts} +1 -2
  47. package/dist/{elevation-BF-vhGxY.mjs → elevation-DG8SrLN-.mjs} +41 -12
  48. package/dist/encryption/index.mjs +3 -3
  49. package/dist/{errorHandler-CIMkCOWm.mjs → errorHandler-BnfDviL1.mjs} +26 -5
  50. package/dist/{errors-C_YhELhe.mjs → errors-CtrywMHP.mjs} +58 -23
  51. package/dist/{errors-BGdVwP25.d.mts → errors-JYc9vwqE.d.mts} +9 -0
  52. package/dist/{eventPlugin-B52abJ8W.d.mts → eventPlugin-BtmA4-3P.d.mts} +65 -9
  53. package/dist/{eventPlugin-CmXaPWLv.mjs → eventPlugin-Q6BhzHzs.mjs} +82 -21
  54. package/dist/{subscribe-helpers-AVYPgqTl.mjs → eventTypes-Cdhm6ZlV.mjs} +151 -17
  55. package/dist/events/index.d.mts +33 -8
  56. package/dist/events/index.mjs +49 -53
  57. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  58. package/dist/events/transports/redis-stream-entry.mjs +139 -157
  59. package/dist/events/transports/redis.d.mts +1 -1
  60. package/dist/events/transports/redis.mjs +2 -2
  61. package/dist/factory/index.d.mts +32 -17
  62. package/dist/factory/index.mjs +213 -32
  63. package/dist/{fastify-augmentation-Cq2nHVaW.d.mts → fastify-augmentation-DhUJ-mvo.d.mts} +11 -25
  64. package/dist/{fields-I_EeRWND.d.mts → fields-BBSpf8pS.d.mts} +1 -1
  65. package/dist/{fields-BTyPLHK0.mjs → fields-ToPYpMqS.mjs} +1 -1
  66. package/dist/filter-merge-IpGywvym.mjs +99 -0
  67. package/dist/{generate-D_YmiCNf.mjs → generate-DRTkLlIl.mjs} +2 -2
  68. package/dist/{headers-CNECDE6q.mjs → headers-BbkIF6vA.mjs} +2 -2
  69. package/dist/health-D-Ft6JM6.mjs +22 -0
  70. package/dist/{health-CxQzbJmr.mjs → health-DqbsG-_w.mjs} +115 -55
  71. package/dist/hooks/index.d.mts +2 -2
  72. package/dist/hooks/index.mjs +2 -2
  73. package/dist/idempotency/index.d.mts +31 -7
  74. package/dist/idempotency/index.mjs +155 -98
  75. package/dist/idempotency/redis.d.mts +1 -1
  76. package/dist/idempotency/redis.mjs +48 -11
  77. package/dist/{index-BHdZD8zK.d.mts → index-Bxriq3so.d.mts} +84 -21
  78. package/dist/{preloadResources-CjS2OfpU.d.mts → index-C8zVGYsk.d.mts} +37 -38
  79. package/dist/{index-D4u76eQW.d.mts → index-CRoPtISf.d.mts} +23 -73
  80. package/dist/{index-CbJiYrfv.d.mts → index-Chgz3d0i.d.mts} +1 -1
  81. package/dist/index-JdbZAIsm.d.mts +510 -0
  82. package/dist/{index-DHbyPo5j.d.mts → index-mqaqZNpe.d.mts} +253 -254
  83. package/dist/index.d.mts +8 -8
  84. package/dist/index.mjs +11 -11
  85. package/dist/{init-Y2MlSN9n.mjs → init-B_oUYDXI.mjs} +1 -1
  86. package/dist/integrations/event-gateway.d.mts +8 -3
  87. package/dist/integrations/event-gateway.mjs +4 -4
  88. package/dist/integrations/index.d.mts +3 -3
  89. package/dist/integrations/index.mjs +1 -1
  90. package/dist/integrations/jobs/index.d.mts +1 -1
  91. package/dist/integrations/jobs/index.mjs +18 -5
  92. package/dist/integrations/mcp/index.d.mts +72 -59
  93. package/dist/integrations/mcp/index.mjs +19 -4
  94. package/dist/integrations/mcp/testing.d.mts +2 -2
  95. package/dist/integrations/mcp/testing.mjs +2 -2
  96. package/dist/integrations/streamline.d.mts +78 -136
  97. package/dist/integrations/streamline.mjs +116 -54
  98. package/dist/integrations/webhooks.d.mts +60 -120
  99. package/dist/integrations/webhooks.mjs +36 -80
  100. package/dist/integrations/websocket-pushref-redis.d.mts +1 -1
  101. package/dist/integrations/websocket-pushref-redis.mjs +1 -1
  102. package/dist/integrations/websocket-redis.d.mts +1 -1
  103. package/dist/integrations/websocket-redis.mjs +1 -1
  104. package/dist/integrations/websocket.d.mts +3 -3
  105. package/dist/integrations/websocket.mjs +2 -2
  106. package/dist/{interface-DEWNOMza.d.mts → interface-C0395yUN.d.mts} +13 -1
  107. package/dist/{jsonBody-Cq9KYl2Z.mjs → jsonBody-B4YVGcql.mjs} +2 -2
  108. package/dist/{keys-Cmv4cBRa.mjs → keys-B2KtgMLJ.mjs} +7 -18
  109. package/dist/{loadResources-CblF7xt2.mjs → loadResources-Dn4lalw2.mjs} +3 -3
  110. package/dist/{loadResourcesFromEntry-99fIMC3p.mjs → loadResourcesFromEntry-3sLYbuse.mjs} +2 -2
  111. package/dist/logger/index.d.mts +1 -8
  112. package/dist/logger/index.mjs +3 -153
  113. package/dist/logger-DXjfIqjV.mjs +160 -0
  114. package/dist/{mcpPlugin-xF3Gw-HW.mjs → mcpPlugin-C08HalN5.mjs} +433 -170
  115. package/dist/{memory-CpDZ9NPw.mjs → memory-9Cp7611C.mjs} +36 -34
  116. package/dist/{metrics-BaKnq8ag.mjs → metrics-CWI11eRu.mjs} +39 -72
  117. package/dist/middleware/index.d.mts +2 -2
  118. package/dist/middleware/index.mjs +3 -3
  119. package/dist/migrations/index.mjs +2 -2
  120. package/dist/{module-BkQEesNQ.mjs → module-BSvOQC7E.mjs} +8 -8
  121. package/dist/multiTenant-cY0FkDiA.d.mts +104 -0
  122. package/dist/{multipartBody-C92aJ8am.mjs → multipartBody-CXM2a-Dy.mjs} +46 -7
  123. package/dist/{openapi-C3LFRzPq.mjs → openapi-DT_G4VhY.mjs} +48 -10
  124. package/dist/outbox-admin/index.d.mts +3 -3
  125. package/dist/outbox-admin/index.mjs +6 -18
  126. package/dist/{outbox-module-dsCyLxXH.mjs → outbox-module-Bjgzl6tg.mjs} +203 -33
  127. package/dist/{outbox-module-BHdUnuuK.d.mts → outbox-module-gZCHoE4H.d.mts} +79 -6
  128. package/dist/permissions/index.d.mts +5 -4
  129. package/dist/permissions/index.mjs +8 -6
  130. package/dist/{permissions-DiHXy8Ck.mjs → permissions-Cm0uYHvd.mjs} +149 -33
  131. package/dist/{pipe-CBVmUJ-j.mjs → pipe-BqeGT6UO.mjs} +2 -2
  132. package/dist/pipeline/index.d.mts +2 -2
  133. package/dist/pipeline/index.mjs +2 -2
  134. package/dist/plan-FVR6LP59.mjs +565 -0
  135. package/dist/{BaseController-DYJRZ0EJ.mjs → plugin-BccET1tL.mjs} +1256 -344
  136. package/dist/plugins/index.d.mts +14 -11
  137. package/dist/plugins/index.mjs +44 -22
  138. package/dist/plugins/response-cache.mjs +8 -14
  139. package/dist/plugins/tracing-entry.mjs +2 -2
  140. package/dist/{pluralize-2_U6QZQg.mjs → pluralize-CVIOcgMF.mjs} +1 -1
  141. package/dist/presets/filesUpload.d.mts +2 -2
  142. package/dist/presets/filesUpload.mjs +5 -5
  143. package/dist/presets/index.d.mts +26 -31
  144. package/dist/presets/index.mjs +4 -4
  145. package/dist/presets/multiTenant.d.mts +2 -107
  146. package/dist/presets/multiTenant.mjs +22 -162
  147. package/dist/presets/search.d.mts +2 -2
  148. package/dist/presets/search.mjs +2 -2
  149. package/dist/{presets-BdlugYTc.mjs → presets-Cpvj6fGO.mjs} +99 -107
  150. package/dist/{projection-Uvgp-EEj.mjs → projection-Ce4aQhQk.mjs} +2 -2
  151. package/dist/{pushref-registry-Dov9l4qE.d.mts → pushref-registry-UxCkoA4C.d.mts} +1 -1
  152. package/dist/{queryCachePlugin-BzqxconG.d.mts → queryCachePlugin-C2lZjTxk.d.mts} +1 -1
  153. package/dist/{queryCachePlugin-B5F09bYr.mjs → queryCachePlugin-CFWNH8aT.mjs} +12 -14
  154. package/dist/{rateLimitKey-CK-EU2L8.mjs → rateLimitKey-C4O-kPm0.mjs} +1 -1
  155. package/dist/{realtime-FnnD0n3Z.mjs → realtime-DmPE9S54.mjs} +25 -21
  156. package/dist/redis-stream-BMk-bpQS.d.mts +219 -0
  157. package/dist/{redis-Bzi1y3F9.d.mts → redis-vLvtcGy_.d.mts} +13 -24
  158. package/dist/redisShapes-CQksY67q.d.mts +55 -0
  159. package/dist/registry/index.d.mts +9 -4
  160. package/dist/registry/index.mjs +4 -4
  161. package/dist/{registry-D3y8VEJ1.mjs → registry-Bcz9G1bh.mjs} +10 -8
  162. package/dist/{renewingLease-B3VYh5aU.mjs → renewingLease-qODa7KJQ.mjs} +1 -1
  163. package/dist/{replyHelpers-DPHsdw-5.mjs → replyHelpers-CG_VtVgS.mjs} +2 -2
  164. package/dist/{requestContext-cSVKnYPk.mjs → requestContext-Dsu9P1bV.mjs} +1 -1
  165. package/dist/requirement-CbiLdQ1n.d.mts +22 -0
  166. package/dist/requirement-KDdoRcOP.mjs +35 -0
  167. package/dist/resourceRateLimit-Wf6d6FL9.d.mts +30 -0
  168. package/dist/resourceRateLimit-dSjVr1pk.mjs +180 -0
  169. package/dist/{rolldown-runtime-DjDuyglE.mjs → rolldown-runtime-D1w9Y1VJ.mjs} +1 -1
  170. package/dist/routeValidator-D36SW8qt.mjs +70 -0
  171. package/dist/{runtimeCapabilities-DSA_dH1_.mjs → runtimeCapabilities-0tccjRlj.mjs} +1 -1
  172. package/dist/{schedules-BktJb3Y3.mjs → schedules-C-OpmHBq.mjs} +46 -37
  173. package/dist/{schemaConverter-BLCSmNbr.mjs → schemaConverter-BORek3O-.mjs} +2 -2
  174. package/dist/{schemaIR-K16Bb5BX.mjs → schemaIR-C7Vbp71I.mjs} +2 -2
  175. package/dist/schemas/index.d.mts +10 -0
  176. package/dist/schemas/index.mjs +8 -3
  177. package/dist/scim/index.mjs +2 -2
  178. package/dist/scope/index.d.mts +2 -2
  179. package/dist/scope/index.mjs +6 -6
  180. package/dist/{scope-jSxuBTFM.mjs → scope-DQthe88b.mjs} +4 -4
  181. package/dist/shutdown-MqA81z_P.mjs +59 -0
  182. package/dist/{simpleEqualityMatcher-BiOnyflP.mjs → simpleEqualityMatcher-auW8QjXN.mjs} +1 -1
  183. package/dist/{sse-CH7Slxc1.mjs → sse-CYzQBVFe.mjs} +11 -15
  184. package/dist/{sseStream-CN-Lh1Tu.mjs → sseStream-B5_Afiqn.mjs} +2 -2
  185. package/dist/{store-helpers-9DX9-1j_.mjs → store-helpers-BOzk-CuX.mjs} +1 -1
  186. package/dist/{streaming-dvppnxsr.mjs → streaming-DjTQhZrN.mjs} +1 -1
  187. package/dist/subscriberIdentity-CW39uA8G.mjs +28 -0
  188. package/dist/tenancy--ed9eH_z.mjs +43 -0
  189. package/dist/tenantPreparation-BKon6Yox.mjs +67 -0
  190. package/dist/testing/cleanupStoreContract.mjs +1 -1
  191. package/dist/testing/index.d.mts +193 -175
  192. package/dist/testing/index.mjs +286 -212
  193. package/dist/testing/outboxStoreContract.mjs +137 -2
  194. package/dist/testing/requiredPorts.d.mts +17 -0
  195. package/dist/testing/requiredPorts.mjs +65 -0
  196. package/dist/testing/storageContract.mjs +1 -1
  197. package/dist/timing-qczZ0YC-.mjs +46 -0
  198. package/dist/{transactionContext-DCWMI6hV.mjs → transactionContext-DjFkrNG6.mjs} +1 -1
  199. package/dist/{typeGuards-D7tHFdH6.mjs → typeGuards-CySF12G-.mjs} +1 -1
  200. package/dist/types/index.d.mts +4 -4
  201. package/dist/types/index.mjs +1 -1
  202. package/dist/types/storage.mjs +1 -1
  203. package/dist/{types-CWQn9-IC.d.mts → types-B4Aq4Sdj.d.mts} +22 -9
  204. package/dist/{types-DfVDvkdP.d.mts → types-BJ-2XqVF.d.mts} +189 -204
  205. package/dist/{types-CDy3-zw1.mjs → types-Bk9NOgOC.mjs} +4 -4
  206. package/dist/usage/index.d.mts +2 -3
  207. package/dist/usage/index.mjs +5 -5
  208. package/dist/{userHelpers-DDMOZ_Pm.mjs → userHelpers-aklawRaK.mjs} +1 -1
  209. package/dist/utils/index.d.mts +84 -223
  210. package/dist/utils/index.mjs +13 -12
  211. package/dist/{utils-B-zj_b__.mjs → utils-ec1oTo1n.mjs} +315 -404
  212. package/dist/{validate-R0G_JrnK.mjs → validate-9yzHC1e2.mjs} +6 -14
  213. package/dist/{versioning-D6JIK8Tk.d.mts → versioning-Bsb51gGT.d.mts} +28 -13
  214. package/dist/{versioning-DuVWcu-F.mjs → versioning-fhhWHV74.mjs} +4 -4
  215. package/dist/{websocket-BOXVggMf.d.mts → websocket-Cs4awVyD.d.mts} +1 -1
  216. package/dist/{workScope-BhsWde4k.mjs → workScope-zpPyge4t.mjs} +2 -2
  217. package/package.json +578 -574
  218. package/skills/arc/SKILL.md +13 -4
  219. package/skills/arc/references/auth.md +8 -5
  220. package/skills/arc/references/integrations.md +1 -1
  221. package/skills/arc/references/mcp.md +8 -6
  222. package/skills/arc/references/multi-tenancy.md +19 -14
  223. package/skills/arc/references/production.md +27 -10
  224. package/dist/actionPermissions-DPwPWPOV.mjs +0 -350
  225. package/dist/index-CFfLKMH4.d.mts +0 -290
  226. package/dist/interface-BIpgzbZl.mjs +0 -17
  227. package/dist/redis-stream-BPKscsTB.d.mts +0 -260
  228. package/dist/registerRoute-DRsSHPSM.mjs +0 -364
  229. package/dist/sync/changelog.d.mts +0 -3
  230. package/dist/sync/changelog.mjs +0 -3
@@ -1,290 +0,0 @@
1
-
2
- import { _ as HealthCheck, a as ModuleContribution, f as ScheduleDefinition, n as ArcModuleInput, r as ArcModuleRegistry, s as ModuleSetupContext, t as ArcModule } from "./types-DfVDvkdP.mjs";
3
- import { FastifyInstance } from "fastify";
4
- //#region src/factory/module/contributions.d.ts
5
- /**
6
- * Collect every module's `healthChecks` in the caller's order. Fails at boot
7
- * on a duplicate check `name` across modules, naming BOTH owning modules.
8
- * The host's app-level checks are appended AFTER this (modules-first,
9
- * host-last) by the caller.
10
- */
11
- declare function collectModuleHealthChecks(modules: readonly ArcModule[]): HealthCheck[];
12
- /**
13
- * Collect every module's `workflows`. Resolves factory contributions (so a
14
- * factory can close over a container the caller has already decorated on
15
- * `fastify`) and flattens to a single opaque array. Arc core deliberately
16
- * does NOT validate or interpret the values — the streamline integration
17
- * owns name/shape checks and registration. Called by the integration at init
18
- * time, not by arc's boot pipeline (workflows depend on the integration's
19
- * container).
20
- */
21
- declare function collectModuleWorkflows(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<unknown[]>;
22
- /**
23
- * Collect every module's `scheduledJobs`. Resolves factory contributions
24
- * (after bootstraps) and fails at boot on a duplicate job `name` across
25
- * modules. The caller passes the returned definitions to the canonical
26
- * schedules plugin; factories must therefore be resolved only once.
27
- */
28
- declare function collectModuleScheduledJobs(fastify: FastifyInstance, modules: readonly ArcModule[],
29
- /**
30
- * Optional sink for per-module counts, filled as each arm resolves.
31
- *
32
- * Exists so `arc.moduleDescriptors` can report real numbers without
33
- * resolving the factories a SECOND time — a contribution factory closes over
34
- * booted engines and may register or allocate, so running it twice is not a
35
- * free read. One resolution feeds both activation and introspection.
36
- */
37
- countsByModule?: Map<string, number>): Promise<ScheduleDefinition[]>;
38
- //#endregion
39
- //#region src/factory/module/extend.d.ts
40
- /**
41
- * What a caller may add. Every mergeable arm of `ArcModule`, plus `bootstrap`
42
- * in wrapper form only.
43
- *
44
- * `name` is absent on purpose: renaming a module mid-composition breaks the
45
- * `dependsOn` graph and the registry key its consumers read, and it is the one
46
- * "extension" that is never additive.
47
- */
48
- interface ModuleExtension<TExports = unknown> {
49
- dependsOn?: readonly string[];
50
- owns?: readonly string[] | "provided";
51
- resources?: ArcModule<TExports>["resources"];
52
- eventHandlers?: ArcModule<TExports>["eventHandlers"];
53
- scheduledJobs?: ArcModule<TExports>["scheduledJobs"];
54
- workflows?: ArcModule<TExports>["workflows"];
55
- healthChecks?: ArcModule<TExports>["healthChecks"];
56
- errorMappers?: ArcModule<TExports>["errorMappers"];
57
- plugins?: ArcModule<TExports>["plugins"];
58
- afterResources?: ArcModule<TExports>["afterResources"];
59
- onClose?: ArcModule<TExports>["onClose"];
60
- /**
61
- * WRAP the module's bootstrap — it is never replaced.
62
- *
63
- * Bootstrap returns the module's exports, so two of them cannot be
64
- * concatenated: one value has to win, and a host silently winning is the gym
65
- * failure (`{ ...mod, bootstrap }` overwrote the factory's own, so the engine
66
- * the module published was never created). The wrapper form makes the
67
- * relationship explicit — call `inner` and decorate its result, or
68
- * deliberately do not.
69
- *
70
- * `inner` is `undefined` when the module has no bootstrap of its own.
71
- */
72
- bootstrap?: (inner: ((f: FastifyInstance, c: ModuleSetupContext) => TExports | Promise<TExports>) | undefined) => (f: FastifyInstance, c: ModuleSetupContext) => TExports | Promise<TExports>;
73
- }
74
- /**
75
- * Merge a host's additions onto a module. Nothing the module declared is lost.
76
- *
77
- * ```ts
78
- * return extendModule(createOrderModule({ … }), {
79
- * eventHandlers: () => hostHandlers(), // appended after the module's
80
- * dependsOn: ["outbox"], // unioned
81
- * bootstrap: (inner) => async (f, c) => { // wraps, never replaces
82
- * const exports = await inner?.(f, c);
83
- * return decorate(exports);
84
- * },
85
- * });
86
- * ```
87
- */
88
- declare function extendModule<TExports = unknown>(mod: ArcModule<TExports>, extension: ModuleExtension<TExports>): ArcModule<TExports>;
89
- //#endregion
90
- //#region src/factory/module/lifecycle.d.ts
91
- /**
92
- * Subscribe every module's `eventHandlers` in dependency order (pass the
93
- * `orderModules`-sorted list). Returns the ordered list of unsubscribe
94
- * functions so the caller can tear them down at shutdown BEFORE module
95
- * `onClose` (while module deps are still alive). Fails at boot on:
96
- * - a duplicate NAMED handler across modules (attributing both owners);
97
- * - a module declaring handlers while the event subsystem is unavailable.
98
- * Resolves factory contributions (after bootstraps) so a handler can close over
99
- * booted engines rather than a global getter.
100
- */
101
- declare function subscribeModuleEventHandlers(fastify: FastifyInstance, modules: readonly ArcModule[],
102
- /**
103
- * Optional sink for per-module handler counts, filled as each arm resolves.
104
- * Lets `arc.moduleDescriptors` report real numbers without resolving the
105
- * factories a SECOND time — see the note on `collectModuleScheduledJobs`.
106
- */
107
- countsByModule?: Map<string, number>): Promise<Array<() => void | Promise<void>>>;
108
- //#endregion
109
- //#region src/factory/module/order.d.ts
110
- /**
111
- * Order modules for composition by their `dependsOn` edges — a STABLE
112
- * topological sort. Called once at the start of the bootstrap phase; every
113
- * subsequent phase (bootstrap, resources, afterResources, and reverse-order
114
- * onClose) iterates the returned list, so a module's declared dependencies are
115
- * always composed before it.
116
- *
117
- * "Stable" = modules with no edge between them keep their original list order,
118
- * so declaring `dependsOn` on one module never silently reorders an unrelated
119
- * one. Backward compatible: a `modules` array with NO `dependsOn` anywhere is
120
- * returned unchanged.
121
- *
122
- * Fail-fast — throws (never reorders past a broken contract) on:
123
- * - duplicate module names (the name is the graph key)
124
- * - a `dependsOn` name not present in the composed set
125
- * - a self-reference (`dependsOn` includes the module's own name)
126
- * - a dependency cycle (reports the concrete `a → b → … → a` path)
127
- */
128
- declare function orderModules(modules: readonly ArcModule[]): ArcModule[];
129
- //#endregion
130
- //#region src/factory/module/resolve.d.ts
131
- /**
132
- * Resolve any module-input form to a concrete `ArcModule`. A thunk is invoked
133
- * (this is where a dynamic `import()` fires); a promise (or plain module) is
134
- * awaited. Called once per module at the start of the bootstrap phase.
135
- */
136
- declare function resolveModule(input: ArcModuleInput): Promise<ArcModule>;
137
- /** Resolve a `ModuleContribution` to a concrete array (array passthrough or factory call). */
138
- declare function resolveContribution<T>(contribution: ModuleContribution<T> | undefined, fastify: FastifyInstance): Promise<readonly T[]>;
139
- //#endregion
140
- //#region src/factory/module/state.d.ts
141
- type ModuleState = "resolved" | "bootstrapping" | "ready" | "closing" | "closed" | "failed";
142
- /**
143
- * Is `name` in the composed module graph? TRUE for resource-only modules and
144
- * modules that exported nothing — the question `hasModuleExports()` cannot
145
- * answer. FALSE before registerResources runs (no graph yet) and for
146
- * uncomposed names.
147
- */
148
- declare function hasModule(fastify: FastifyInstance, name: string): boolean;
149
- /**
150
- * The module's current lifecycle state, or `undefined` when the module is not
151
- * composed (or no graph has been composed on this instance). See the state
152
- * machine in the file header.
153
- */
154
- declare function getModuleState(fastify: FastifyInstance, name: string): ModuleState | undefined;
155
- //#endregion
156
- //#region src/factory/module/index.d.ts
157
- /**
158
- * Identity helper for authoring a typed module — mirrors `defineResource`.
159
- * Gives inference + a single obvious construction site; does no work.
160
- *
161
- * `TExports` is inferred from the `bootstrap` return value, so a module
162
- * author gets a typed public export for free:
163
- *
164
- * ```ts
165
- * export const accountingModule = (deps: Deps) =>
166
- * defineModule({
167
- * name: "accounting",
168
- * bootstrap: async () => createAccountingEngine(deps), // TExports inferred
169
- * });
170
- * ```
171
- */
172
- declare function defineModule<TExports = unknown>(module: ArcModule<TExports>): ArcModule<TExports>;
173
- /**
174
- * Typed accessor for a module's public export (its `bootstrap` return value),
175
- * recorded at `fastify.arc.modules[name]`.
176
- *
177
- * Throwing, in line with the fail-fast contract (and `requireOrgId`-style
178
- * accessors): a missing entry means the module either isn't composed, is
179
- * composed AFTER the caller (list order = init order), or returned nothing —
180
- * all wiring bugs that must surface at boot, not as `undefined` downstream.
181
- *
182
- * The type parameter is an assertion, not a proof. Two ways to type it:
183
- * - augment `ArcModuleRegistry` once — then the name alone infers the type:
184
- * `getModuleExports(f, "accounting")` → `AccountingEngine`.
185
- * - or pass it inline: `getModuleExports<AccountingEngine>(f, "accounting")`.
186
- *
187
- * Siblings, for the two shapes this one is wrong for:
188
- * - `getOptionalModuleExports` — the module is genuinely OPTIONAL.
189
- * - `lazyModuleExports` / `lazyRequiredModuleExports` — the read happens at
190
- * composition time, where boot order decides the answer.
191
- */
192
- declare function getModuleExports<K extends keyof ArcModuleRegistry>(fastify: FastifyInstance, name: K): ArcModuleRegistry[K];
193
- declare function getModuleExports<TExports = unknown>(fastify: FastifyInstance, name: string): TExports;
194
- /**
195
- * Non-throwing sibling of `getModuleExports`: `undefined` when the module is
196
- * not composed (or has not bootstrapped yet).
197
- *
198
- * Exists because OPTIONAL sibling modules are a first-class composition shape —
199
- * a deployment that turns `inventory` off still sells services, so its POS
200
- * module must ask "is inventory here?" rather than fail-fast. Hosts were
201
- * spelling that question as
202
- *
203
- * ```ts
204
- * (fastify as { arc?: { modules?: Record<string, unknown> } })
205
- * .arc?.modules?.inventory;
206
- * ```
207
- *
208
- * — a double cast that (a) defeats `ArcModuleRegistry` inference, (b) silently
209
- * survives a typo in the module name, and (c) is impossible to grep for. Use
210
- * `getModuleExports` when the dependency is REQUIRED (boot must fail), this
211
- * when it is genuinely optional.
212
- *
213
- * Prefer `lazyModuleExports` whenever the read happens at COMPOSITION time —
214
- * see its doc for why a value read once can latch `undefined` forever.
215
- */
216
- declare function getOptionalModuleExports<K extends keyof ArcModuleRegistry>(fastify: FastifyInstance, name: K): ArcModuleRegistry[K] | undefined;
217
- declare function getOptionalModuleExports<TExports = unknown>(fastify: FastifyInstance, name: string): TExports | undefined;
218
- /**
219
- * Is a module's public export recorded yet? The predicate form of
220
- * `getOptionalModuleExports`, for readiness gates (`ready: () => ...`) that
221
- * should not have to reason about falsy-but-present exports.
222
- */
223
- declare function hasModuleExports(fastify: FastifyInstance, name: string): boolean;
224
- /**
225
- * A DEFERRED reader of a sibling module's export: returns a getter that reads
226
- * the registry at CALL time, not now.
227
- *
228
- * ── Why this exists (the bug it removes) ─────────────────────────────────────
229
- *
230
- * Module composition runs bootstraps in dependency/list order, but a lot of
231
- * wiring is *registered* earlier than it *runs*: an `eventHandlers` factory, a
232
- * bridge accessor handed to another module, a hook added during bootstrap and
233
- * fired per request. Such a factory can execute BEFORE the sibling it needs has
234
- * bootstrapped — so a sibling engine captured into a local at that moment is
235
- * `undefined`, and stays `undefined` for the life of the process even though the
236
- * sibling came up milliseconds later.
237
- *
238
- * That failure is SILENT by construction: the consumer sees a null bridge and
239
- * treats it as "this deployment has no inventory / no revenue engine", which is
240
- * a legitimate configuration. Real cost in this codebase: orders were created
241
- * and never payment-confirmed (no entitlement, no card, no door) and nothing
242
- * errored anywhere.
243
- *
244
- * The getter therefore:
245
- * - re-reads while the module is ABSENT, so boot order cannot matter;
246
- * - memoizes the FIRST resolved value, so the steady-state read is a closure
247
- * variable rather than a registry lookup per request;
248
- * - never memoizes absence — that is precisely the latch this replaces.
249
- *
250
- * ```ts
251
- * const inventory = lazyModuleExports<FlowEngine>(fastify, "inventory");
252
- * return {
253
- * flowBridge: () => (inventory() ? createFlowEngineBridge({ getFlowEngine: () => inventory()! }) : null),
254
- * ready: () => inventory() !== undefined,
255
- * };
256
- * ```
257
- */
258
- declare function lazyModuleExports<K extends keyof ArcModuleRegistry>(fastify: FastifyInstance, name: K): () => ArcModuleRegistry[K] | undefined;
259
- declare function lazyModuleExports<TExports = unknown>(fastify: FastifyInstance, name: string): () => TExports | undefined;
260
- /**
261
- * Required counterpart of `lazyModuleExports`: defers the read, then throws
262
- * `getModuleExports`' error if the module is still absent at first use.
263
- *
264
- * The pair matters because "required" and "readable now" are different
265
- * questions. A hook registered at bootstrap that needs the `order` engine at
266
- * REQUEST time is a hard dependency, but reading it eagerly turns a correct
267
- * composition into a boot crash purely because of list order. Deferring keeps
268
- * the fail-fast guarantee and moves it to the first moment the answer is
269
- * actually needed.
270
- *
271
- * Deferred does NOT mean unvalidated: a lazily-required module is still a
272
- * HARD dependency, so PRESENCE is checked eagerly. When the composed module
273
- * graph is known (any `createApp`/`registerResources` boot — the normal
274
- * case), a name that is not in the graph throws HERE, at composition time,
275
- * instead of surviving startup and failing on the first request or event.
276
- * Only the EXPORT read (does bootstrap's return value exist yet?) is
277
- * deferred to first call.
278
- *
279
- * Convention for hard sibling access: also declare the target in the
280
- * consumer's `dependsOn`. That orders composition (the sibling's bootstrap
281
- * runs first), while this accessor merely defers the read — the two are
282
- * complementary, not alternatives:
283
- * - hard dependency, read during bootstrap → `dependsOn` + `getModuleExports`
284
- * - hard dependency, read at request/event time → `dependsOn` + this
285
- * - optional integration → `lazyModuleExports` (no `dependsOn` needed)
286
- */
287
- declare function lazyRequiredModuleExports<K extends keyof ArcModuleRegistry>(fastify: FastifyInstance, name: K): () => ArcModuleRegistry[K];
288
- declare function lazyRequiredModuleExports<TExports = unknown>(fastify: FastifyInstance, name: string): () => TExports;
289
- //#endregion
290
- export { collectModuleScheduledJobs as _, lazyModuleExports as a, getModuleState as c, resolveModule as d, orderModules as f, collectModuleHealthChecks as g, extendModule as h, hasModuleExports as i, hasModule as l, ModuleExtension as m, getModuleExports as n, lazyRequiredModuleExports as o, subscribeModuleEventHandlers as p, getOptionalModuleExports as r, ModuleState as s, defineModule as t, resolveContribution as u, collectModuleWorkflows as v };
@@ -1,17 +0,0 @@
1
- /*! @classytic/arc v2.41.0 | MIT | https://classytic.com */
2
- //#region src/idempotency/stores/interface.ts
3
- /**
4
- * Helper to create a result object
5
- */
6
- function createIdempotencyResult(statusCode, body, headers, ttlMs) {
7
- const now = /* @__PURE__ */ new Date();
8
- return {
9
- statusCode,
10
- headers,
11
- body,
12
- createdAt: now,
13
- expiresAt: new Date(now.getTime() + ttlMs)
14
- };
15
- }
16
- //#endregion
17
- export { createIdempotencyResult as t };
@@ -1,260 +0,0 @@
1
-
2
- import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler } from "./EventTransport-CbUKDzZZ.mjs";
3
- //#region src/events/transports/redis-stream.d.ts
4
- interface RedisStreamLike {
5
- xadd(key: string, id: string, ...fieldValues: string[]): Promise<string | null>;
6
- xreadgroup(command: "GROUP", group: string, consumer: string, ...args: unknown[]): Promise<Array<[string, Array<[string, string[] | null]>]> | null>;
7
- xack(key: string, group: string, ...ids: unknown[]): Promise<number>;
8
- xgroup(command: string, key: string, group: string, ...args: unknown[]): Promise<unknown>;
9
- xpending(key: string, group: string, ...args: unknown[]): Promise<unknown[]>;
10
- xclaim(key: string, group: string, consumer: string, minIdleTime: number, ...ids: unknown[]): Promise<unknown[]>;
11
- xlen(key: string): Promise<number>;
12
- /**
13
- * Read a range of entries by id. When present, the DLQ writer uses this
14
- * to fetch the original message payload so dead-lettered events are
15
- * **fully replayable** (a re-publish of `envelope.event` is sufficient).
16
- *
17
- * Optional to preserve back-compat with custom Redis wrappers that
18
- * satisfied the pre-2.11.3 shape. When missing, the DLQ envelope still
19
- * carries the **error reason + attempt accounting** (operator-grade
20
- * triage info survives), but `envelope.event.payload` is `null` and
21
- * `envelope.event.type` is `<unknown>` — replay is NOT possible without
22
- * upgrading the client. A one-shot warning fires per process so this
23
- * isn't silent.
24
- */
25
- xrange?(key: string, start: string, end: string): Promise<Array<[string, string[]]>>;
26
- /** Graceful close — flushes queued commands then closes. ioredis-style. */
27
- quit(): Promise<unknown>;
28
- /**
29
- * Force-disconnect — closes the socket immediately, abandoning any
30
- * pending command (including a live `XREADGROUP BLOCK`). Optional because
31
- * non-ioredis clients may not expose a force path; `close()` falls back
32
- * to `quit()` when this is missing, accepting a longer shutdown wait.
33
- */
34
- disconnect?(): void;
35
- }
36
- interface RedisStreamTransportOptions {
37
- /**
38
- * Redis stream key name.
39
- * @default 'arc:events'
40
- */
41
- stream?: string;
42
- /**
43
- * Consumer group name. Each group receives every event independently.
44
- * Multiple instances of the same service should share a group name.
45
- * @default 'default'
46
- */
47
- group?: string;
48
- /**
49
- * Consumer name within the group. Must be unique per instance.
50
- * @default 'consumer-<random>'
51
- */
52
- consumer?: string;
53
- /**
54
- * Block time in ms when waiting for new events.
55
- * @default 5000
56
- */
57
- blockTimeMs?: number;
58
- /**
59
- * Max events to read per batch.
60
- * @default 10
61
- */
62
- batchSize?: number;
63
- /**
64
- * Bounded concurrency for processing a batch's ENTRIES (default: 1 —
65
- * strict stream order, the safe default). With one slow handler,
66
- * throughput per consumer is ~`1 / total handler latency`; raising this
67
- * processes up to N entries of a batch concurrently.
68
- *
69
- * Trade-off: entries within a batch may complete OUT OF ORDER — only
70
- * raise it when handlers are order-independent (idempotent, keyed
71
- * upserts). Handlers on this transport should be short and I/O-bound
72
- * regardless; heavy work belongs in jobs. Matching handlers for a single
73
- * event always run sequentially.
74
- * @default 1
75
- */
76
- processingConcurrency?: number;
77
- /**
78
- * Max delivery attempts before moving to dead letter stream.
79
- * @default 5
80
- */
81
- maxRetries?: number;
82
- /**
83
- * Idle time in ms before pending entries are claimed by this consumer.
84
- * Handles crash recovery — if a consumer dies mid-processing, another
85
- * consumer will claim its pending entries after this timeout.
86
- * @default 30000
87
- */
88
- claimTimeoutMs?: number;
89
- /**
90
- * Dead letter stream name. Failed events are moved here after maxRetries.
91
- * Set to `false` to disable DLQ (failed events are acked and dropped).
92
- * @default 'arc:events:dlq'
93
- */
94
- deadLetterStream?: string | false;
95
- /**
96
- * Max stream length (approximate). Uses XADD MAXLEN ~ to trim old entries.
97
- * Set to 0 to disable trimming.
98
- * @default 10000
99
- */
100
- maxLen?: number;
101
- /**
102
- * Max event payload size in bytes. Publish rejects events exceeding this limit
103
- * to prevent Redis memory exhaustion from oversized payloads.
104
- * @default 1_000_000 (1 MB)
105
- */
106
- maxPayloadBytes?: number;
107
- /**
108
- * If `true`, `close()` does NOT call `redis.quit()` — useful when the host
109
- * manages the Redis connection lifecycle externally (shared client across
110
- * multiple transports / cache stores). Without this, every transport
111
- * `close()` would tear down a shared client and break siblings.
112
- *
113
- * Mirror of `RedisEventTransportOptions.externalLifecycle`.
114
- * @default false
115
- */
116
- externalLifecycle?: boolean;
117
- /**
118
- * Hard cap on how long `close()` waits for the in-flight `XREADGROUP BLOCK`
119
- * iteration to drain. Tests and serverless shutdowns would otherwise hang
120
- * up to `blockTimeMs` (default 5s) per close.
121
- *
122
- * Behaviour after timeout:
123
- * - `externalLifecycle: false` (default) — `redis.disconnect()` (or
124
- * `quit()` if the client lacks `disconnect`) breaks the BLOCK
125
- * immediately. Strict bounded close.
126
- * - `externalLifecycle: true` — arc CANNOT touch the host's connection,
127
- * so the poll loop is left to drain in the background when its
128
- * XREADGROUP returns. `close()` returns within `closeTimeoutMs` but
129
- * the loop's eventual completion is silently absorbed (no log spam,
130
- * no unhandled rejection). The contract here is "bounded return,
131
- * background drain" — set `blockTimeMs` low (e.g. 500ms) under
132
- * externalLifecycle to keep the drain window short.
133
- *
134
- * @default 1000
135
- */
136
- closeTimeoutMs?: number;
137
- /**
138
- * Logger for error messages (default: console).
139
- * Pass `fastify.log` to integrate with your application logger.
140
- */
141
- logger?: EventLogger;
142
- }
143
- declare class RedisStreamTransport implements EventTransport {
144
- readonly name = "redis-stream";
145
- private redis;
146
- private stream;
147
- private group;
148
- private consumer;
149
- private blockTimeMs;
150
- private batchSize;
151
- private processingConcurrency;
152
- private maxRetries;
153
- private claimTimeoutMs;
154
- private deadLetterStream;
155
- private maxLen;
156
- private maxPayloadBytes;
157
- private logger;
158
- /** Tracks the lifecycle policy — set in constructor, read in close(). */
159
- private externalLifecycle;
160
- private closeTimeoutMs;
161
- private handlers;
162
- private running;
163
- private pollPromise;
164
- /**
165
- * Monotonic counter bumped every time the poll loop should stop —
166
- * `unsubscribe` (last handler removed) and `close()` increment it. Each
167
- * `pollLoop` instance captures its generation at start and exits when
168
- * `this.generation` no longer matches. Prevents the
169
- * subscribe → unsubscribe → fast-resubscribe race where the old loop
170
- * would still be in `XREADGROUP BLOCK` while a new loop started, leading
171
- * to two concurrent poll loops on the same consumer name.
172
- */
173
- private generation;
174
- private groupCreated;
175
- /**
176
- * Last-seen failure context per message id, populated when an in-process
177
- * handler throws in {@link processEntry}. Consumed (and cleared) by
178
- * {@link moveToDlq} so the dead-letter envelope carries the actual error
179
- * message instead of opaque "reclaimed without context". Entries are
180
- * deleted on ack and on DLQ write; messages resolved by ANOTHER consumer
181
- * never drain locally, so the map is additionally hard-capped at
182
- * {@link MAX_FAILURE_CONTEXT_ENTRIES} with oldest-first eviction.
183
- */
184
- private failureContext;
185
- /** One-shot guard so the "client lacks xrange" warning fires once per process. */
186
- private xrangeWarningEmitted;
187
- constructor(redis: RedisStreamLike, options?: RedisStreamTransportOptions);
188
- publish(event: DomainEvent): Promise<void>;
189
- subscribe(pattern: string, handler: EventHandler): Promise<() => void>;
190
- /**
191
- * Stop polling and release transport state.
192
- *
193
- * **Two close contracts** — pick the one that matches your deployment:
194
- *
195
- * 1. **Default (`externalLifecycle: false`) — strict bounded close.**
196
- * `close()` waits up to `closeTimeoutMs` for the in-flight
197
- * `XREADGROUP BLOCK` to drain. On timeout it calls `redis.disconnect()`
198
- * (or `quit()` if the client lacks `disconnect`) to break the BLOCK
199
- * immediately, then awaits the loop's exit. After `close()` returns
200
- * the transport is fully closed and the connection is released.
201
- *
202
- * 2. **`externalLifecycle: true` — bounded RETURN, background drain.**
203
- * Arc must NOT touch a connection it doesn't own. `close()` returns
204
- * within `closeTimeoutMs`, but the poll loop is left to drain on its
205
- * own when its outstanding `XREADGROUP BLOCK` returns (up to
206
- * `blockTimeMs`). Arc silently absorbs the loop's eventual completion
207
- * so the host doesn't see unhandled rejections / log spam against a
208
- * transport it considers closed. The host's own `redis.quit()` /
209
- * process exit is what ultimately tears the connection down.
210
- *
211
- * Practical implication: under `externalLifecycle: true`, set
212
- * `blockTimeMs` low (e.g. 500ms) so the background drain window is
213
- * short. The transport is "closed enough" to stop dispatching to
214
- * handlers (handlers map is cleared and generation is bumped) but is
215
- * not "fully closed" in the connection-lifecycle sense until the host
216
- * closes the underlying client.
217
- *
218
- * In both modes the generation counter is bumped, so a follow-up
219
- * `subscribe()` spawns a fresh poll loop with a new generation — the
220
- * stale loop exits on its next iteration and never overlaps the new one.
221
- */
222
- close(): Promise<void>;
223
- private ensureGroup;
224
- private pollLoop;
225
- private readNewMessages;
226
- /**
227
- * Process a batch's entries with bounded concurrency
228
- * (`processingConcurrency`, default 1 = strict order). Worker-pool over a
229
- * shared index — at most N entries in flight, each entry's own handlers
230
- * still sequential inside `processEntry`.
231
- */
232
- private processEntries;
233
- private claimPending;
234
- private processEntry;
235
- /**
236
- * The canonical matcher from primitives — the SAME glob rules the memory
237
- * transport speaks. A private matcher here once accepted `prefix.*` but not
238
- * `prefix:*`, so an `order:*` subscription that worked in-process received
239
- * nothing after a move to the stream, with no error.
240
- */
241
- private getMatchingHandlers;
242
- private moveToDlq;
243
- /**
244
- * Reconstruct a `DeadLetteredEvent` for a message id. Reads the original
245
- * entry via `xrange` (when the client supports it) and merges in any
246
- * in-process failure context. Returns `null` only when BOTH sources are
247
- * missing — callers ack-and-drop rather than re-queuing a ghost.
248
- *
249
- * Graceful degradation paths:
250
- * - Client lacks `xrange` (older custom wrappers) → log once, build the
251
- * envelope from `failureContext` alone. Payload is absent but the
252
- * error reason + attempt accounting still survive.
253
- * - `xrange` throws (network blip, ACL) → same fallback.
254
- * - Source entry trimmed before DLQ write → same fallback.
255
- */
256
- private buildDlqEnvelope;
257
- private sleep;
258
- }
259
- //#endregion
260
- export { RedisStreamTransport as n, RedisStreamTransportOptions as r, RedisStreamLike as t };