@classytic/arc 2.41.1 → 2.44.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 (248) hide show
  1. package/dist/{EventTransport-CbUKDzZZ.d.mts → EventTransport-CiicKz2Z.d.mts} +1 -1
  2. package/dist/{EventTransport-DSqD_Xsg.mjs → EventTransport-DZWDsaPa.mjs} +22 -17
  3. package/dist/{HookSystem-CMF94SEA.mjs → HookSystem-yjEgn7Cm.mjs} +2 -2
  4. package/dist/{QueryCache-DFA-QrU9.d.mts → QueryCache--5uAuYPW.d.mts} +7 -3
  5. package/dist/{ResourceRegistry-MGpXoxHZ.mjs → ResourceRegistry-DJxHUpE4.mjs} +44 -13
  6. package/dist/acquire-BozJ-9yt.mjs +35 -0
  7. package/dist/actionPermissions-5N04zBL4.mjs +772 -0
  8. package/dist/audit/index.d.mts +46 -8
  9. package/dist/audit/index.mjs +48 -26
  10. package/dist/auth/audit.d.mts +8 -8
  11. package/dist/auth/audit.mjs +1 -1
  12. package/dist/auth/index.d.mts +46 -16
  13. package/dist/auth/index.mjs +134 -156
  14. package/dist/auth/redis-session.d.mts +4 -5
  15. package/dist/auth/redis-session.mjs +1 -1
  16. package/dist/{authorizationDecision-DawKGoXb.mjs → authorizationDecision-wX3SA9w_.mjs} +7 -102
  17. package/dist/{base-CxrV1LmG.d.mts → base-CZyixEQR.d.mts} +27 -5
  18. package/dist/boundedMap-DWiKW7lP.mjs +57 -0
  19. package/dist/{buildHandler-CvxKOc0m.mjs → buildHandler-Bswu_vNb.mjs} +4 -4
  20. package/dist/cache/index.d.mts +31 -43
  21. package/dist/cache/index.mjs +4 -4
  22. package/dist/{caching-DbCBxlgw.mjs → caching-Drp68DIS.mjs} +3 -3
  23. package/dist/claimed-DYvQoZLv.mjs +8 -0
  24. package/dist/cleanup/index.d.mts +18 -22
  25. package/dist/cleanup/index.mjs +27 -73
  26. package/dist/cli/commands/describe.d.mts +7 -5
  27. package/dist/cli/commands/describe.mjs +7 -4
  28. package/dist/cli/commands/docs.d.mts +2 -3
  29. package/dist/cli/commands/docs.mjs +3 -3
  30. package/dist/cli/commands/doctor.d.mts +2 -3
  31. package/dist/cli/commands/doctor.mjs +1 -1
  32. package/dist/cli/commands/generate.mjs +2 -3
  33. package/dist/cli/commands/init.mjs +2 -3
  34. package/dist/cli/commands/introspect.d.mts +2 -3
  35. package/dist/cli/commands/introspect.mjs +2 -2
  36. package/dist/cli/index.mjs +3 -3
  37. package/dist/{constants-D5Ubn1fe.mjs → constants-B2QHb6u6.mjs} +4 -2
  38. package/dist/context/index.d.mts +11 -14
  39. package/dist/context/index.mjs +18 -38
  40. package/dist/core/index.d.mts +3 -3
  41. package/dist/core/index.mjs +8 -8
  42. package/dist/{core-5lazhva9.mjs → core-COcqo0Cp.mjs} +15 -5
  43. package/dist/{createActionRouter-DNqoaK81.mjs → createActionRouter-zG13rpPJ.mjs} +97 -39
  44. package/dist/{createAggregationRouter-BcbQJf10.mjs → createAggregationRouter-CWRz96Vr.mjs} +11 -8
  45. package/dist/{preloadResources-f3boenVZ.mjs → createApp-BGLYtErt.mjs} +305 -394
  46. package/dist/{createMcpServer-CbDWkZ1T.d.mts → createMcpServer-DSztofa9.d.mts} +1 -1
  47. package/dist/{defineAggregation-D_eJjm5A.mjs → defineAggregation--3xguLkk.mjs} +1 -1
  48. package/dist/{defineResource-DxkMTjRn.mjs → defineResource-gUp9ug66.mjs} +118 -1024
  49. package/dist/discovery/index.d.mts +6 -7
  50. package/dist/discovery/index.mjs +1 -1
  51. package/dist/docs/index.d.mts +11 -5
  52. package/dist/docs/index.mjs +4 -4
  53. package/dist/{elevation-CkvG0LG2.mjs → elevation-BG4gnMsJ.mjs} +41 -12
  54. package/dist/{elevation-BXCfVcNG.d.mts → elevation-BW2J3tNj.d.mts} +1 -2
  55. package/dist/encryption/index.d.mts +5 -5
  56. package/dist/encryption/index.mjs +3 -3
  57. package/dist/{errorHandler-D1GHKGlV.mjs → errorHandler-COHw3N1b.mjs} +26 -5
  58. package/dist/{errors-BH7YU_9O.mjs → errors-CW4anJBy.mjs} +58 -23
  59. package/dist/{errors-BGdVwP25.d.mts → errors-JYc9vwqE.d.mts} +9 -0
  60. package/dist/{eventPlugin-B52abJ8W.d.mts → eventPlugin-BtmA4-3P.d.mts} +65 -9
  61. package/dist/{eventPlugin-zZY-unhr.mjs → eventPlugin-BweHAVws.mjs} +82 -21
  62. package/dist/{subscribe-helpers-DatDkcuG.mjs → eventTypes-N4-omQFR.mjs} +151 -17
  63. package/dist/events/index.d.mts +43 -18
  64. package/dist/events/index.mjs +49 -53
  65. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  66. package/dist/events/transports/redis-stream-entry.mjs +139 -157
  67. package/dist/events/transports/redis.d.mts +5 -6
  68. package/dist/events/transports/redis.mjs +2 -2
  69. package/dist/factory/index.d.mts +42 -27
  70. package/dist/factory/index.mjs +213 -32
  71. package/dist/{fastify-augmentation-Cq2nHVaW.d.mts → fastify-augmentation-DRlCIWE9.d.mts} +11 -25
  72. package/dist/{fields-BHrkoF5y.mjs → fields-A5crhsJb.mjs} +1 -1
  73. package/dist/{fields-I_EeRWND.d.mts → fields-BBSpf8pS.d.mts} +1 -1
  74. package/dist/filter-merge-DGM-GQ1J.mjs +99 -0
  75. package/dist/{generate-BLRf2m3y.mjs → generate-BXKo2Gc8.mjs} +2 -2
  76. package/dist/{headers-BIXWKrzQ.mjs → headers-DKZQKL-Z.mjs} +2 -2
  77. package/dist/health-BYAwA6YS.mjs +22 -0
  78. package/dist/{health-ZRHeDHXH.mjs → health-CrqUp3sz.mjs} +115 -55
  79. package/dist/hooks/index.d.mts +2 -2
  80. package/dist/hooks/index.mjs +2 -3
  81. package/dist/idempotency/index.d.mts +36 -10
  82. package/dist/idempotency/index.mjs +230 -111
  83. package/dist/idempotency/redis.d.mts +1 -1
  84. package/dist/idempotency/redis.mjs +77 -12
  85. package/dist/{index-D4u76eQW.d.mts → index-Beg3aNnK.d.mts} +23 -101
  86. package/dist/{preloadResources-CjS2OfpU.d.mts → index-BkV55WlV.d.mts} +37 -38
  87. package/dist/{index-BHdZD8zK.d.mts → index-Bxriq3so.d.mts} +84 -21
  88. package/dist/index-CUJvoyw3.d.mts +510 -0
  89. package/dist/{index-CbJiYrfv.d.mts → index-Chgz3d0i.d.mts} +1 -1
  90. package/dist/{index-DHbyPo5j.d.mts → index-WH7xgvxS.d.mts} +304 -254
  91. package/dist/index.d.mts +9 -9
  92. package/dist/index.mjs +11 -11
  93. package/dist/{init-CpLkjU18.mjs → init-BPzK5Lnr.mjs} +1 -1
  94. package/dist/integrations/event-gateway.d.mts +11 -7
  95. package/dist/integrations/event-gateway.mjs +4 -4
  96. package/dist/integrations/index.d.mts +3 -3
  97. package/dist/integrations/index.mjs +1 -1
  98. package/dist/integrations/jobs/index.d.mts +1 -1
  99. package/dist/integrations/jobs/index.mjs +18 -5
  100. package/dist/integrations/mcp/index.d.mts +102 -89
  101. package/dist/integrations/mcp/index.mjs +19 -4
  102. package/dist/integrations/mcp/testing.d.mts +8 -9
  103. package/dist/integrations/mcp/testing.mjs +2 -2
  104. package/dist/integrations/streamline.d.mts +85 -144
  105. package/dist/integrations/streamline.mjs +131 -55
  106. package/dist/integrations/webhooks.d.mts +83 -143
  107. package/dist/integrations/webhooks.mjs +36 -80
  108. package/dist/integrations/websocket-pushref-redis.d.mts +5 -6
  109. package/dist/integrations/websocket-pushref-redis.mjs +1 -1
  110. package/dist/integrations/websocket-redis.d.mts +5 -6
  111. package/dist/integrations/websocket-redis.mjs +1 -1
  112. package/dist/integrations/websocket.d.mts +3 -3
  113. package/dist/integrations/websocket.mjs +2 -2
  114. package/dist/{interface-DEWNOMza.d.mts → interface-JJzwH4Ro.d.mts} +34 -2
  115. package/dist/{jsonBody-ELR9lfeU.mjs → jsonBody-YIq-vGLv.mjs} +2 -2
  116. package/dist/{keys-cpZCtcIE.mjs → keys-CpoiZ8hU.mjs} +7 -18
  117. package/dist/{loadResources-BPfWiI5s.mjs → loadResources-6jO52-RR.mjs} +3 -3
  118. package/dist/{loadResourcesFromEntry-ixtfL3J2.mjs → loadResourcesFromEntry-MP8xEppu.mjs} +2 -2
  119. package/dist/logger/index.d.mts +9 -17
  120. package/dist/logger/index.mjs +2 -153
  121. package/dist/logger-D4V1zGLI.mjs +160 -0
  122. package/dist/{mcpPlugin-BX5PujI0.mjs → mcpPlugin-srPc7ItN.mjs} +446 -170
  123. package/dist/{memory-Iotz0cCx.mjs → memory-CTa5pOCW.mjs} +36 -34
  124. package/dist/{metrics-NMsmpRmY.mjs → metrics-DsZrvnpB.mjs} +39 -72
  125. package/dist/middleware/index.d.mts +5 -5
  126. package/dist/middleware/index.mjs +3 -3
  127. package/dist/migrations/index.d.mts +13 -13
  128. package/dist/migrations/index.mjs +2 -2
  129. package/dist/{module-DpLJG2_N.mjs → module--L0iBIZz.mjs} +8 -8
  130. package/dist/mongodb-memory-server-CHhYSq5y.mjs +35539 -0
  131. package/dist/mongoose-CYJCLyi-.mjs +67451 -0
  132. package/dist/multiTenant-CAtYlW6H.d.mts +104 -0
  133. package/dist/{multipartBody-DtRWM6_U.mjs → multipartBody-Cc7eZ9cq.mjs} +46 -7
  134. package/dist/node-D8UZv_8c.mjs +41236 -0
  135. package/dist/{openapi-CmFf3yq_.mjs → openapi-CMegfsm8.mjs} +48 -10
  136. package/dist/outbox-admin/index.d.mts +5 -5
  137. package/dist/outbox-admin/index.mjs +6 -18
  138. package/dist/{outbox-module-D2z5WkDY.mjs → outbox-module-Ryk270jd.mjs} +203 -33
  139. package/dist/{outbox-module-BHdUnuuK.d.mts → outbox-module-gZCHoE4H.d.mts} +79 -6
  140. package/dist/permissions/index.d.mts +5 -4
  141. package/dist/permissions/index.mjs +8 -6
  142. package/dist/{permissions-D8TBH44E.mjs → permissions-C5ijIz5Q.mjs} +149 -33
  143. package/dist/{pipe-FMWNheSO.mjs → pipe-D81zMtWs.mjs} +2 -2
  144. package/dist/pipeline/index.d.mts +7 -7
  145. package/dist/pipeline/index.mjs +2 -2
  146. package/dist/plan-CJGMKoui.mjs +565 -0
  147. package/dist/{BaseController-CYEwjyjN.mjs → plugin-DALd9dcF.mjs} +1269 -346
  148. package/dist/plugins/index.d.mts +17 -14
  149. package/dist/plugins/index.mjs +44 -22
  150. package/dist/plugins/response-cache.d.mts +5 -6
  151. package/dist/plugins/response-cache.mjs +8 -14
  152. package/dist/plugins/tracing-entry.mjs +2 -2
  153. package/dist/{pluralize-CXWZIzTv.mjs → pluralize-COUNYo3d.mjs} +1 -1
  154. package/dist/presets/filesUpload.d.mts +8 -8
  155. package/dist/presets/filesUpload.mjs +5 -5
  156. package/dist/presets/index.d.mts +35 -40
  157. package/dist/presets/index.mjs +4 -4
  158. package/dist/presets/multiTenant.d.mts +2 -107
  159. package/dist/presets/multiTenant.mjs +22 -162
  160. package/dist/presets/search.d.mts +9 -10
  161. package/dist/presets/search.mjs +2 -2
  162. package/dist/{presets-ZJSPgmT2.mjs → presets-CONf2Qem.mjs} +99 -107
  163. package/dist/{projection-BzIgzoKZ.mjs → projection-wFoLqdss.mjs} +2 -2
  164. package/dist/{pushref-registry-Dov9l4qE.d.mts → pushref-registry-UxCkoA4C.d.mts} +1 -1
  165. package/dist/{queryCachePlugin-DZHPOm9p.mjs → queryCachePlugin-BATECpyh.mjs} +12 -14
  166. package/dist/{queryCachePlugin-BzqxconG.d.mts → queryCachePlugin-C2lZjTxk.d.mts} +1 -1
  167. package/dist/{rateLimitKey-BvOvcBDi.mjs → rateLimitKey-DVEZ_UpV.mjs} +1 -1
  168. package/dist/{realtime-8tIQWZz4.mjs → realtime-xyubMKSB.mjs} +25 -21
  169. package/dist/{redis-Bzi1y3F9.d.mts → redis-BDgv9Glw.d.mts} +17 -24
  170. package/dist/redis-stream-BMk-bpQS.d.mts +219 -0
  171. package/dist/redisShapes-CQksY67q.d.mts +55 -0
  172. package/dist/registry/index.d.mts +15 -10
  173. package/dist/registry/index.mjs +4 -4
  174. package/dist/{registry-DNkgGQcK.mjs → registry-Bdzg-hdm.mjs} +13 -10
  175. package/dist/{renewingLease-yF8BdW4b.mjs → renewingLease-BFJxGPuh.mjs} +1 -1
  176. package/dist/{replyHelpers-CNdvMfM4.mjs → replyHelpers-Bnc6lJyy.mjs} +2 -2
  177. package/dist/{requestContext-cDkAUr-P.mjs → requestContext-C10UeFe5.mjs} +1 -1
  178. package/dist/requirement-Bu50QALH.mjs +35 -0
  179. package/dist/requirement-CbiLdQ1n.d.mts +22 -0
  180. package/dist/resourceRateLimit-Wf6d6FL9.d.mts +30 -0
  181. package/dist/resourceRateLimit-urWPJxrt.mjs +180 -0
  182. package/dist/rolldown-runtime-MYrLNGnq.mjs +45 -0
  183. package/dist/routeValidator-DHtpzrzk.mjs +70 -0
  184. package/dist/{runtimeCapabilities-CkhS6jn6.mjs → runtimeCapabilities-DIMKMV2G.mjs} +1 -1
  185. package/dist/{schedules-j6uXXAeJ.mjs → schedules-CKTs5ys8.mjs} +46 -37
  186. package/dist/{schemaConverter-BVA7cFRG.mjs → schemaConverter-BVjkQ5DD.mjs} +2 -2
  187. package/dist/{schemaIR-CTvPDoPB.mjs → schemaIR-BA0Hb21Y.mjs} +2 -2
  188. package/dist/schemas/index.d.mts +20 -10
  189. package/dist/schemas/index.mjs +8 -3
  190. package/dist/scim/index.d.mts +13 -13
  191. package/dist/scim/index.mjs +2 -2
  192. package/dist/scope/index.d.mts +4 -4
  193. package/dist/scope/index.mjs +6 -6
  194. package/dist/{scope-BUi1xV1I.mjs → scope-DINaj7Ax.mjs} +4 -4
  195. package/dist/shutdown-LpLMH8T1.mjs +59 -0
  196. package/dist/{simpleEqualityMatcher-C9bzq2gO.mjs → simpleEqualityMatcher-DbwIM1f1.mjs} +1 -1
  197. package/dist/{sse-BeqVKQKu.mjs → sse-BzJFPX_1.mjs} +11 -15
  198. package/dist/{sseStream-Ppzo-WUH.mjs → sseStream-DQChzGTs.mjs} +2 -2
  199. package/dist/{store-helpers-dW71XVWL.mjs → store-helpers-Coj9RhOZ.mjs} +1 -1
  200. package/dist/{streaming-IcRFjWQU.mjs → streaming-JzB5CAga.mjs} +1 -1
  201. package/dist/subscriberIdentity-DeyppIif.mjs +28 -0
  202. package/dist/tenancy-DxV8OuX2.mjs +43 -0
  203. package/dist/tenantPreparation-CBvvAcAj.mjs +67 -0
  204. package/dist/testing/cleanupStoreContract.d.mts +4 -5
  205. package/dist/testing/cleanupStoreContract.mjs +1 -1
  206. package/dist/testing/index.d.mts +215 -197
  207. package/dist/testing/index.mjs +289 -214
  208. package/dist/testing/outboxStoreContract.d.mts +4 -5
  209. package/dist/testing/outboxStoreContract.mjs +137 -2
  210. package/dist/testing/requiredPorts.d.mts +16 -0
  211. package/dist/testing/requiredPorts.mjs +65 -0
  212. package/dist/testing/storageContract.d.mts +4 -5
  213. package/dist/testing/storageContract.mjs +1 -1
  214. package/dist/timing-CntavTlR.mjs +46 -0
  215. package/dist/{transactionContext-CPbdlnVw.mjs → transactionContext-orvnGu4F.mjs} +1 -1
  216. package/dist/{typeGuards-BLjPgVBm.mjs → typeGuards-kEaP_WmO.mjs} +1 -1
  217. package/dist/types/index.d.mts +4 -4
  218. package/dist/types/index.mjs +1 -1
  219. package/dist/types/storage.mjs +1 -1
  220. package/dist/{types-DfVDvkdP.d.mts → types-BJ-2XqVF.d.mts} +189 -204
  221. package/dist/{types-CWQn9-IC.d.mts → types-D3Ixsh00.d.mts} +22 -9
  222. package/dist/{types-CgenB1gv.mjs → types-fvO6Ovzx.mjs} +4 -4
  223. package/dist/usage/index.d.mts +5 -6
  224. package/dist/usage/index.mjs +5 -5
  225. package/dist/{userHelpers-ChRvkuSZ.mjs → userHelpers-C76zD5pa.mjs} +1 -1
  226. package/dist/utils/index.d.mts +125 -264
  227. package/dist/utils/index.mjs +13 -12
  228. package/dist/{utils-CxcctrAh.mjs → utils-BpkVZ8rB.mjs} +315 -404
  229. package/dist/{validate-DrYWnOzI.mjs → validate-CWp-lsrm.mjs} +6 -14
  230. package/dist/{versioning-D6JIK8Tk.d.mts → versioning-Bsb51gGT.d.mts} +28 -13
  231. package/dist/{versioning-DKkT4hNJ.mjs → versioning-CHhL9P3o.mjs} +4 -4
  232. package/dist/{websocket-BOXVggMf.d.mts → websocket-Cs4awVyD.d.mts} +1 -1
  233. package/dist/{workScope-CxKqoIFn.mjs → workScope-n9a7d_lZ.mjs} +2 -2
  234. package/package.json +57 -59
  235. package/skills/arc/SKILL.md +13 -4
  236. package/skills/arc/references/auth.md +8 -5
  237. package/skills/arc/references/integrations.md +1 -1
  238. package/skills/arc/references/mcp.md +8 -6
  239. package/skills/arc/references/multi-tenancy.md +19 -14
  240. package/skills/arc/references/production.md +27 -10
  241. package/dist/actionPermissions-BoPGQ5-4.mjs +0 -350
  242. package/dist/index-CFfLKMH4.d.mts +0 -290
  243. package/dist/interface-YzIbF7Ii.mjs +0 -17
  244. package/dist/redis-stream-BPKscsTB.d.mts +0 -260
  245. package/dist/registerRoute-Bsnk6NiZ.mjs +0 -364
  246. package/dist/rolldown-runtime-eysyzFAF.mjs +0 -15
  247. package/dist/sync/changelog.d.mts +0 -3
  248. package/dist/sync/changelog.mjs +0 -3
@@ -1,48 +1,19 @@
1
1
 
2
2
  import { F as getHeader, I as requireSingleHeaderValue, P as ArcHeaders } from "../types-Ddl9OjmE.mjs";
3
- import { f as getUserId, m as normalizeRoles, p as getUserRoles, t as AnyRecord } from "../base-CxrV1LmG.mjs";
4
- import { $ as OpenApiSchemas, S as QueryParserInterface, b as ParsedQuery } from "../index-DHbyPo5j.mjs";
3
+ import { f as getUserId, m as normalizeRoles, p as getUserRoles, t as AnyRecord } from "../base-CZyixEQR.mjs";
4
+ import { Y as OpenApiSchemas, h as QueryParserInterface, p as ParsedQuery } from "../index-WH7xgvxS.mjs";
5
5
  import { n as ErrorMapper } from "../errorHandler--4rSMMvq.mjs";
6
- import { a as NotFoundError, c as RateLimitError, d as ValidationError, f as createDomainError, i as ForbiddenError, l as ServiceUnavailableError, m as isArcError, n as ConflictError, o as OrgAccessDeniedError, p as createError, r as ErrorOptions, s as OrgRequiredError, t as ArcError, u as UnauthorizedError } from "../errors-BGdVwP25.mjs";
7
- import { scheduleBackground } from "@classytic/repo-core/cache";
8
- import { errorContractSchema, errorDetailSchema } from "@classytic/repo-core/errors";
6
+ import { a as NotFoundError, c as RateLimitError, d as ValidationError, f as createDomainError, i as ForbiddenError, l as ServiceUnavailableError, m as isArcError, n as ConflictError, o as OrgAccessDeniedError, p as createError, r as ErrorOptions, s as OrgRequiredError, t as ArcError, u as UnauthorizedError } from "../errors-JYc9vwqE.mjs";
7
+ import { errorContractSchema } from "@classytic/repo-core/errors";
8
+ import { FilterClause } from "@classytic/repo-core/query-parser";
9
9
  import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
10
10
  //#region src/utils/circuitBreaker.d.ts
11
- /**
12
- * Circuit Breaker Pattern
13
- *
14
- * Wraps external service calls with failure protection.
15
- * Prevents cascading failures by "opening" the circuit when
16
- * a service is failing, allowing it time to recover.
17
- *
18
- * States:
19
- * - CLOSED: Normal operation, requests pass through
20
- * - OPEN: Too many failures, all requests fail fast
21
- * - HALF_OPEN: Testing if service recovered, limited requests
22
- *
23
- * @example
24
- * import { CircuitBreaker } from '@classytic/arc/utils';
25
- *
26
- * const paymentBreaker = new CircuitBreaker(async (amount) => {
27
- * return await stripe.charges.create({ amount });
28
- * }, {
29
- * failureThreshold: 5,
30
- * resetTimeout: 30000,
31
- * timeout: 5000,
32
- * });
33
- *
34
- * try {
35
- * const result = await paymentBreaker.call(100);
36
- * } catch (error) {
37
- * // Handle failure or circuit open
38
- * }
39
- */
40
- declare const CircuitState: {
11
+ export declare const CircuitState: {
41
12
  readonly CLOSED: "CLOSED";
42
13
  readonly OPEN: "OPEN";
43
14
  readonly HALF_OPEN: "HALF_OPEN";
44
15
  };
45
- type CircuitState = (typeof CircuitState)[keyof typeof CircuitState];
16
+ export type CircuitState = (typeof CircuitState)[keyof typeof CircuitState];
46
17
  /**
47
18
  * Generic constraint for "any async function" that survives strict TS.
48
19
  *
@@ -187,11 +158,29 @@ interface CircuitBreakerStats {
187
158
  openedAt: number | null;
188
159
  lastCallAt: number | null;
189
160
  }
190
- declare class CircuitBreakerError extends Error {
191
- state: CircuitState;
192
- constructor(message: string, state: CircuitState);
161
+ /**
162
+ * Thrown when a call is refused because the circuit is OPEN (or HALF_OPEN with
163
+ * every probe slot taken).
164
+ *
165
+ * An `ArcError` with status **503**, code `arc.circuit_open`. It extended plain
166
+ * `Error` and carried no status, so an open circuit reaching arc's error
167
+ * handler was classified `arc.internal_error`: a 500, logged at error level
168
+ * with a stack trace, once per fast-failed call. That is the opposite of what
169
+ * a breaker is for — it turned deliberate, cheap load shedding into the
170
+ * loudest failure in the logs, during exactly the outage where it fires
171
+ * thousands of times a minute.
172
+ *
173
+ * `retryAfter` (seconds, rounded up) is when the circuit next probes; the
174
+ * error handler sends it as `Retry-After`, so well-behaved clients back off
175
+ * for as long as the breaker is actually going to refuse them.
176
+ */
177
+ export declare class CircuitBreakerError extends ArcError {
178
+ readonly state: CircuitState;
179
+ /** Seconds until the circuit next probes, when known. */
180
+ readonly retryAfter?: number;
181
+ constructor(message: string, state: CircuitState, retryAfter?: number);
193
182
  }
194
- declare class CircuitBreaker<T extends AnyAsyncFn> {
183
+ export declare class CircuitBreaker<T extends AnyAsyncFn> {
195
184
  private state;
196
185
  private failures;
197
186
  private successes;
@@ -278,11 +267,11 @@ declare class CircuitBreaker<T extends AnyAsyncFn> {
278
267
  * { name: 'email-service' }
279
268
  * );
280
269
  */
281
- declare function createCircuitBreaker<T extends AnyAsyncFn>(fn: T, options?: CircuitBreakerOptions): CircuitBreaker<T>;
270
+ export declare function createCircuitBreaker<T extends AnyAsyncFn>(fn: T, options?: CircuitBreakerOptions): CircuitBreaker<T>;
282
271
  /**
283
272
  * Circuit breaker registry for managing multiple breakers
284
273
  */
285
- declare class CircuitBreakerRegistry {
274
+ export declare class CircuitBreakerRegistry {
286
275
  private breakers;
287
276
  /**
288
277
  * Register a circuit breaker
@@ -317,7 +306,7 @@ declare class CircuitBreakerRegistry {
317
306
  * Create a new CircuitBreakerRegistry instance.
318
307
  * Use this instead of a global singleton — attach to fastify.arc or pass explicitly.
319
308
  */
320
- declare function createCircuitBreakerRegistry(): CircuitBreakerRegistry;
309
+ export declare function createCircuitBreakerRegistry(): CircuitBreakerRegistry;
321
310
  //#endregion
322
311
  //#region src/utils/circuitBreakerRedis.d.ts
323
312
  /**
@@ -347,7 +336,7 @@ interface RedisCircuitBreakerStateOptions {
347
336
  windowMs?: number;
348
337
  }
349
338
  /** Fixed-window cluster failure counter. See the module header. */
350
- declare class RedisCircuitBreakerState implements CircuitBreakerSharedState {
339
+ export declare class RedisCircuitBreakerState implements CircuitBreakerSharedState {
351
340
  #private;
352
341
  readonly name = "redis";
353
342
  constructor(options: RedisCircuitBreakerStateOptions);
@@ -457,12 +446,12 @@ type CompensationResult = {
457
446
  *
458
447
  * @typeParam TCtx - Context type shared across steps (defaults to Record<string, unknown>)
459
448
  */
460
- declare function withCompensation<TCtx extends Record<string, unknown> = Record<string, unknown>>(_name: string, steps: readonly CompensationStep<TCtx>[], initialContext?: TCtx, hooks?: CompensationHooks): Promise<CompensationResult>;
449
+ export declare function withCompensation<TCtx extends Record<string, unknown> = Record<string, unknown>>(_name: string, steps: readonly CompensationStep<TCtx>[], initialContext?: TCtx, hooks?: CompensationHooks): Promise<CompensationResult>;
461
450
  interface CompensationDefinition<TCtx extends Record<string, unknown> = Record<string, unknown>> {
462
451
  readonly name: string;
463
452
  readonly execute: (initialContext?: TCtx, hooks?: CompensationHooks) => Promise<CompensationResult>;
464
453
  }
465
- declare function defineCompensation<TCtx extends Record<string, unknown> = Record<string, unknown>>(name: string, steps: readonly CompensationStep<TCtx>[]): CompensationDefinition<TCtx>;
454
+ export declare function defineCompensation<TCtx extends Record<string, unknown> = Record<string, unknown>>(name: string, steps: readonly CompensationStep<TCtx>[]): CompensationDefinition<TCtx>;
466
455
  //#endregion
467
456
  //#region src/utils/defineErrorMapper.d.ts
468
457
  /**
@@ -478,7 +467,7 @@ declare function defineCompensation<TCtx extends Record<string, unknown> = Recor
478
467
  * called with a non-`T` error at runtime. This helper codifies that invariant
479
468
  * in one place.
480
469
  */
481
- declare function defineErrorMapper<T extends Error>(mapper: ErrorMapper<T>): ErrorMapper;
470
+ export declare function defineErrorMapper<T extends Error>(mapper: ErrorMapper<T>): ErrorMapper;
482
471
  //#endregion
483
472
  //#region src/utils/defineGuard.d.ts
484
473
  interface GuardConfig<T> {
@@ -505,50 +494,21 @@ interface Guard<T> {
505
494
  /**
506
495
  * Create a typed guard. See module JSDoc for usage.
507
496
  */
508
- declare function defineGuard<T>(config: GuardConfig<T>): Guard<T>;
497
+ export declare function defineGuard<T>(config: GuardConfig<T>): Guard<T>;
509
498
  //#endregion
510
499
  //#region src/utils/filter-dialect.d.ts
511
- /**
512
- * Filter dialects — decouple `ArcQueryParser` from any single datastore's
513
- * operator vocabulary.
514
- *
515
- * The parser owns everything store-INDEPENDENT: URL parsing, field/operator
516
- * whitelisting, depth limits, value coercion, ReDoS-safe regex sanitisation.
517
- * A `FilterDialect` owns the ONLY store-specific part of the output — which
518
- * token each neutral operator (`gte`, `like`, `in`, …) is emitted as, and how a
519
- * case-insensitive text match is expressed. Swap the dialect (or the whole
520
- * parser via `QueryParserInterface`) to target a non-Mongo store; the default
521
- * stays Mongo, so existing hosts are unaffected.
522
- */
523
500
  interface FilterDialect {
524
- /**
525
- * Neutral operator name → emitted token. An operator absent from this map is
526
- * treated as unsupported (dropped), so a dialect also defines its operator set.
527
- */
528
- readonly operators: Readonly<Record<string, string>>;
529
- /**
530
- * Extra keys merged into a field-filter when a documented case-insensitive
531
- * text operator (`like` / `contains`) is used. Mongo expresses this as a
532
- * sibling `{ $options: 'i' }`; a dialect that encodes case-insensitivity in
533
- * the operator itself returns `{}`.
534
- */
535
- caseInsensitiveModifier(): Record<string, unknown>;
501
+ /** Emit the parsed clauses as one filter. Several clauses on a field are ANDed. */
502
+ emit(clauses: readonly FilterClause[]): Record<string, unknown>;
503
+ /** The operator tokens this dialect can emit — for audits and docs. */
504
+ readonly tokens: readonly string[];
536
505
  }
506
+ export declare const MONGO_DIALECT: FilterDialect;
537
507
  /**
538
- * Default dialect — MongoDB / MongoKit operator shape. Emits `$`-prefixed
539
- * tokens and the `$options: 'i'` case-insensitive sibling. This is what
540
- * `ArcQueryParser` uses when no dialect is supplied, so behaviour is identical
541
- * to every prior arc version.
542
- */
543
- declare const MONGO_DIALECT: FilterDialect;
544
- /**
545
- * Store-neutral reference dialect — emits UN-prefixed operator tokens as a
546
- * translation AST (`?price[gte]=40` → `{ price: { gte: 40 } }`, with
547
- * `{ caseInsensitive: true }` for `like`/`contains`). A non-Mongo adapter can
548
- * consume this directly instead of writing a full `QueryParserInterface`. Use
549
- * as a starting point; adjust the token names to your store's vocabulary.
508
+ * Store-neutral: `{ field: { <op>: value } }` with the grammar's own operator names, for a host
509
+ * that compiles the canonical clauses itself.
550
510
  */
551
- declare const NEUTRAL_DIALECT: FilterDialect;
511
+ export declare const NEUTRAL_DIALECT: FilterDialect;
552
512
  //#endregion
553
513
  //#region src/utils/handleRaw.d.ts
554
514
  /**
@@ -558,195 +518,86 @@ declare const NEUTRAL_DIALECT: FilterDialect;
558
518
  * The return value is sent raw (no envelope). If it returns `undefined`,
559
519
  * the response body is empty (HTTP status only).
560
520
  * @param statusCode - HTTP status code for successful responses (default: 200)
521
+ * @returns The reply, so Fastify waits for it: resolving `undefined` after `reply.send()` while an
522
+ * async `preSerialization` hook (idempotency, encryption) is pending re-sends an empty body.
561
523
  */
562
- declare function handleRaw<T>(handler: (request: FastifyRequest, reply: FastifyReply) => Promise<T>, statusCode?: number): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
524
+ export declare function handleRaw<T>(handler: (request: FastifyRequest, reply: FastifyReply) => Promise<T>, statusCode?: number): (request: FastifyRequest, reply: FastifyReply) => Promise<FastifyReply>;
563
525
  //#endregion
564
526
  //#region src/utils/queryParser.d.ts
565
527
  interface ArcQueryParserOptions {
566
- /** Maximum allowed limit value (default: 1000) */
528
+ /** Cap on `limit`; a larger request is clamped to it (default: 1000). */
567
529
  maxLimit?: number;
568
- /** Default limit for pagination (default: 20) */
530
+ /** Per-page count when the URL omits `limit` (default: 20). */
569
531
  defaultLimit?: number;
570
- /** Maximum regex pattern length (default: 500) */
532
+ /** Longest text-operator value or regex pattern (default: 200). */
571
533
  maxRegexLength?: number;
572
- /** Maximum search query length (default: 200) */
534
+ /** Longest `search` (default: 200). */
573
535
  maxSearchLength?: number;
574
- /** Maximum filter nesting depth (default: 10) */
575
- maxFilterDepth?: number;
576
- /**
577
- * Whitelist of fields that can be filtered on.
578
- * When set, only these fields are accepted as filters — all others are silently dropped.
579
- * Also used by MCP to auto-derive filterable fields in tool schemas.
580
- */
536
+ /** Filterable fields. Also used by MCP to derive filterable fields. */
581
537
  allowedFilterFields?: string[];
582
538
  /**
583
- * REFUSE a filter key that is not in {@link allowedFilterFields}, instead of
584
- * dropping it (default: `false` — today's drop behaviour, kept because arc
585
- * is published and an unconditional throw would reject requests that work).
586
- *
587
- * Dropping a filter does not fail, it **WIDENS**: the caller asked for a
588
- * narrower set and is silently answered with a broader one, HTTP 200. Two
589
- * live instances:
590
- *
591
- * `?filters[status]=pending` → 200, every row `status:"verified"`
592
- * `?productId=…` (the param is `skuRef`) → a different product's 75 units,
593
- * filed for weeks as "quant leakage"
594
- *
595
- * Turn this on per-parser, or fleet-wide via `ARC_STRICT_QUERY_PARAMS`.
596
- * Mirrors the `ARC_STRICT_PERMISSIONS` precedent: off by default here, and
597
- * the HOST opts in from its env-loader so a forgotten `.env` line cannot
598
- * silently disable enforcement.
599
- *
600
- * Only the FILTER whitelist is covered. `allowedSortFields` /
601
- * `allowedOperators` keep dropping: a rejected sort or operator degrades
602
- * ordering, it does not widen the row set.
539
+ * REFUSE (400) a field, operator or sort field outside its allowlist — a dropped filter silently
540
+ * WIDENS the read. Default `true`; `false` (or `ARC_STRICT_QUERY_PARAMS=false`) logs and drops
541
+ * those instead. Malformed or smuggled input (`$where`, `x[$ne]`) is refused either way.
603
542
  */
604
543
  strictFilterFields?: boolean;
605
- /**
606
- * Whitelist of fields that can be sorted on.
607
- * When set, sort fields not in this list are silently dropped.
608
- * Also used by MCP to describe available sort options.
609
- */
544
+ /** Sortable fields. Also used by MCP. */
610
545
  allowedSortFields?: string[];
611
- /**
612
- * Whitelist of filter operators (e.g. ['eq', 'ne', 'gt', 'lt', 'in']).
613
- * When set, only these operators are accepted — all others are dropped.
614
- * Also used by MCP to enrich list tool descriptions.
615
- */
546
+ /** URL operator names permitted in `field[op]` (e.g. `['in', 'gte']`). Also used by MCP. */
616
547
  allowedOperators?: string[];
617
- /**
618
- * Datastore dialect for the EMITTED filter shape (operator tokens +
619
- * case-insensitive expression). Defaults to `MONGO_DIALECT`. Pass
620
- * `NEUTRAL_DIALECT` (or a custom one) to retarget the operator vocabulary
621
- * without writing a full `QueryParserInterface`.
622
- */
548
+ /** The emitted filter shape. Default `MONGO_DIALECT`. */
623
549
  dialect?: FilterDialect;
624
550
  }
625
551
  /**
626
- * Arc's default query parser
627
- *
628
- * Converts URL query parameters to a structured query format:
629
- * - Pagination: ?page=1&limit=20
630
- * - Sorting: ?sort=-createdAt,name (- prefix = descending)
631
- * - Filtering — TWO supported forms (both produce identical output):
632
- * - Bare (default, terse): `?status=active&price[gte]=100&price[lte]=500`
633
- * - Bracket envelope: `?filter[status]=active&filter[price][gte]=100`
634
- * The envelope form matches the convention used by JSON:API / Stripe /
635
- * most modern REST style guides, and is the safe choice on busy URLs
636
- * that might otherwise collide with reserved meta keys (`page`, `sort`,
637
- * `select`, `populate`, etc.). Operator notation (`[gte]`, `[lte]`,
638
- * `[ne]`, `[in]`, ...) works inside either form.
639
- * - Search: ?search=keyword
640
- * - Populate: ?populate=author,category
641
- * - Field selection: ?select=name,price,status
642
- * - Keyset pagination: ?after=cursor_value
643
- *
644
- * **NOTE on parser portability.** `ArcQueryParser` accepts both filter
645
- * forms. Other parser implementations (`@classytic/mongokit`'s
646
- * `QueryParser`, custom hosts-side parsers) may accept only one form —
647
- * MongoKit historically only accepts the bare form. If your host swaps
648
- * `queryParser` to a different implementation, double-check which forms
649
- * it understands before publishing URLs that mix the two.
650
- *
651
- * For advanced MongoDB features ($lookup, aggregations), use MongoKit's QueryParser.
552
+ * Arc's default query parser:
553
+ * - Paging `?page=1&limit=20`, keyset `?after=cursor`; sort `?sort=-createdAt,name`
554
+ * - Filters bare (`?status=active&price[gte]=100`) or in the `?filter[...]` envelope, which
555
+ * avoids collisions with reserved keys (`page`, `sort`, ...)
556
+ * - Search `?search=`, populate `?populate=a,b`, select `?select=a,-b`
652
557
  */
653
- declare class ArcQueryParser implements QueryParserInterface {
558
+ export declare class ArcQueryParser implements QueryParserInterface {
654
559
  /**
655
- * PUBLIC, deliberately: `QueryResolver` reads it so it does not apply a second cap
656
- * on top of this one. Three layers capping independently, lowest winning silently,
657
- * is what made a 696-row chart of accounts render as 100.
560
+ * Public so `QueryResolver` reuses this cap instead of stacking its own
561
+ * (independent caps silently truncate to the lowest).
658
562
  */
659
563
  readonly maxLimit: number;
660
564
  private readonly defaultLimit;
661
565
  private readonly maxRegexLength;
662
566
  private readonly maxSearchLength;
663
- private readonly maxFilterDepth;
664
- private readonly _allowedFilterFields?;
665
- private readonly _allowedSortFields?;
666
- private readonly _allowedOperators?;
667
- private readonly strictFilterFields;
567
+ private readonly strict;
568
+ private readonly dialect;
668
569
  /** Allowed filter fields (used by MCP for auto-derive) */
669
570
  readonly allowedFilterFields?: readonly string[];
670
571
  /** Allowed sort fields (used by MCP for sort descriptions) */
671
572
  readonly allowedSortFields?: readonly string[];
672
573
  /** Allowed operators (used by MCP for operator descriptions) */
673
574
  readonly allowedOperators?: readonly string[];
674
- /**
675
- * Datastore dialect — owns the store-specific operator tokens + the
676
- * case-insensitive modifier. Defaults to Mongo (backward-compatible).
677
- */
678
- private readonly dialect;
679
- /** Supported filter operators (neutral name → emitted token), from the dialect. */
680
- private get operators();
681
575
  constructor(options?: ArcQueryParserOptions);
682
- /**
683
- * Parse URL query parameters into structured query options
684
- */
576
+ /** Parse URL query parameters into structured query options. Invalid input is a 400. */
685
577
  parse(query: Record<string, unknown> | null | undefined): ParsedQuery;
686
- private parseNumber;
687
- private parseString;
578
+ /** A grammar refusal is a 400 (`ValidationError`) — unless lenient and only an allowlist miss. */
579
+ private read;
580
+ private drop;
688
581
  /**
689
- * Parse populate parameter — handles both simple string and bracket notation.
690
- *
691
- * Simple: ?populate=author,category → { populate: 'author,category' }
692
- * Bracket: ?populate[author][select]=name,email → { populateOptions: [{ path: 'author', select: 'name email' }] }
582
+ * Simple `?populate=author,category`, or bracket `?populate[author][select]=name,email` and
583
+ * `?populate[author][match][field]=value` (field equality only).
693
584
  */
694
585
  private parsePopulate;
695
- private parseSort;
696
- private parseSearch;
697
- private parseSelect;
698
586
  /**
699
- * Check if a value exceeds the maximum nesting depth.
700
- * Prevents filter bombs where deeply nested objects consume excessive memory/CPU.
701
- */
702
- private exceedsDepth;
703
- /**
704
- * Parse all filter entries from the query, supporting BOTH the bare
705
- * top-level form and the bracket-wrapped `filter[...]` envelope.
706
- *
707
- * Two equivalent ways to express the same query:
708
- * - Bare (legacy, arc default): `?status=active&price[gte]=40`
709
- * - Bracket envelope (REST convention): `?filter[status]=active&filter[price][gte]=40`
710
- *
711
- * Both forms parse to the same `filters: { status: 'active', price: { $gte: 40 } }`.
712
- * The envelope form mirrors the convention used by most REST API style
713
- * guides (JSON:API, Stripe API, etc.) and disambiguates filter fields
714
- * from reserved meta params on busy URLs — a query string with a field
715
- * literally named `page` or `sort` can't collide with the framework's
716
- * meta keys when wrapped under `filter[...]`. The bare form stays as
717
- * the default since it's the shortest path for simple queries; expect
718
- * it to remain supported indefinitely.
719
- *
720
- * Precedence when the same key appears in both forms:
721
- * `?status=closed&filter[status]=active` → bare wins (`status: closed`).
722
- * Mixing should be rare; the deterministic rule avoids silent surprises.
723
- */
724
- private parseFilters;
725
- /**
726
- * Apply one filter entry — used by both the bracket-envelope branch and
727
- * the bare top-level branch of `parseFilters`. Centralising the field-
728
- * validation + operator-conversion logic keeps the two forms in
729
- * lockstep; a future regex/security tweak only changes one place.
730
- */
731
- private applyFilterEntry;
732
- private parseFilterValue;
733
- private coerceValue;
734
- /**
735
- * Generate OpenAPI-compatible JSON Schema for query parameters.
736
- * Arc's defineResource() auto-detects this method and uses it
737
- * to document list endpoint query parameters in OpenAPI/Swagger.
587
+ * A populate `match` is plain field EQUALITY in bracket form (`populate[p][match][f]=v`). A `$`
588
+ * key, a nested object or a non-object `match` (a JSON string) is refused, never passed to the
589
+ * driver or dropped — a dropped match populates every document.
738
590
  */
591
+ private parsePopulateMatch;
592
+ /** JSON Schema for list query parameters (auto-detected by `defineResource`). */
739
593
  getQuerySchema(): {
740
594
  type: "object";
741
595
  properties: Record<string, unknown>;
742
596
  required?: string[];
743
597
  };
744
- private sanitizeRegex;
745
598
  }
746
- /**
747
- * Create a new ArcQueryParser instance
748
- */
749
- declare function createQueryParser(options?: ArcQueryParserOptions): ArcQueryParser;
599
+ /** Create a new ArcQueryParser instance. */
600
+ export declare function createQueryParser(options?: ArcQueryParserOptions): ArcQueryParser;
750
601
  //#endregion
751
602
  //#region src/utils/responseSchemas.d.ts
752
603
  interface JsonSchema {
@@ -773,7 +624,7 @@ interface JsonSchema {
773
624
  * Runtime format (flat fields):
774
625
  * { page, limit, total, pages, hasNext, hasPrev }
775
626
  */
776
- declare const paginationSchema: JsonSchema;
627
+ export declare const paginationSchema: JsonSchema;
777
628
  /**
778
629
  * List response schema — accepts every wire shape `toCanonicalList` can
779
630
  * emit. Hosts who know their endpoint only ever produces one variant can
@@ -795,18 +646,18 @@ declare const paginationSchema: JsonSchema;
795
646
  * per-response branch validation. The list route also serves count, exists
796
647
  * and distinct dispatch verbs, so no field is common to every valid shape.
797
648
  */
798
- declare function listResponse(itemSchema: JsonSchema): JsonSchema;
649
+ export declare function listResponse(itemSchema: JsonSchema): JsonSchema;
799
650
  /** Offset variant — `{ method: 'offset', data, page, limit, total, pages, hasNext, hasPrev }`. */
800
- declare function offsetListResponse(itemSchema: JsonSchema): JsonSchema;
651
+ export declare function offsetListResponse(itemSchema: JsonSchema): JsonSchema;
801
652
  /** Keyset variant — `{ method: 'keyset', data, limit, hasMore, next: string | null }`. */
802
- declare function keysetListResponse(itemSchema: JsonSchema): JsonSchema;
653
+ export declare function keysetListResponse(itemSchema: JsonSchema): JsonSchema;
803
654
  /** Aggregate variant — same shape as offset, discriminated by `method: 'aggregate'`. */
804
- declare function aggregateListResponse(itemSchema: JsonSchema): JsonSchema;
655
+ export declare function aggregateListResponse(itemSchema: JsonSchema): JsonSchema;
805
656
  /** Bare variant — `{ data }`, no `method` discriminant. */
806
- declare function bareListResponse(itemSchema: JsonSchema): JsonSchema;
657
+ export declare function bareListResponse(itemSchema: JsonSchema): JsonSchema;
807
658
  /** Delete response — flat shape mirroring the canonical delete envelope. */
808
- declare function deleteResponse(): JsonSchema;
809
- declare const responses: {
659
+ export declare function deleteResponse(): JsonSchema;
660
+ export declare const responses: {
810
661
  200: (schema: JsonSchema) => {
811
662
  description: string;
812
663
  content: {
@@ -1182,7 +1033,7 @@ declare const responses: {
1182
1033
  };
1183
1034
  };
1184
1035
  };
1185
- declare const queryParams: {
1036
+ export declare const queryParams: {
1186
1037
  pagination: {
1187
1038
  page: {
1188
1039
  type: string;
@@ -1219,21 +1070,19 @@ declare const queryParams: {
1219
1070
  /**
1220
1071
  * Get standard list query parameters schema
1221
1072
  */
1222
- declare function getListQueryParams(): AnyRecord;
1073
+ export declare function getListQueryParams(): AnyRecord;
1223
1074
  /**
1224
1075
  * Get default response schemas for all CRUD operations.
1225
1076
  *
1226
- * When routes have response schemas, Fastify compiles them with
1227
- * fast-json-stringify for 2-3x faster serialization and prevents
1228
- * accidental field disclosure.
1229
- *
1230
- * These defaults use `additionalProperties: true` so all fields pass through.
1231
- * Override with specific schemas for full serialization performance + safety.
1077
+ * The envelope is typed (its fields are known); rows and single documents
1078
+ * pass through as `{}` — see `genericItemSchema`. A resource that declares a
1079
+ * response schema with real `properties` gets typed row serialization, which
1080
+ * also drops undeclared fields.
1232
1081
  *
1233
1082
  * Note: `example` properties are stripped from defaults so they work with
1234
1083
  * any Fastify instance (not just createApp which adds `keywords: ['example']`).
1235
1084
  */
1236
- declare function getDefaultCrudSchemas(): Record<string, Record<string, unknown>>;
1085
+ export declare function getDefaultCrudSchemas(): Record<string, Record<string, unknown>>;
1237
1086
  //#endregion
1238
1087
  //#region src/utils/runtimeCapabilities.d.ts
1239
1088
  /** What a subsystem declares about the state it holds. */
@@ -1257,7 +1106,7 @@ interface RuntimeCapabilityDeclaration {
1257
1106
  * and encapsulated children of any of them — which is the point: the audit
1258
1107
  * sees what the constructor-time guard cannot.
1259
1108
  */
1260
- declare function declareRuntimeCapability(fastify: FastifyInstance, decl: RuntimeCapabilityDeclaration): void;
1109
+ export declare function declareRuntimeCapability(fastify: FastifyInstance, decl: RuntimeCapabilityDeclaration): void;
1261
1110
  //#endregion
1262
1111
  //#region src/utils/schemaConverter.d.ts
1263
1112
  /**
@@ -1278,11 +1127,11 @@ type SchemaIo = "input" | "output";
1278
1127
  * Returns true if it has JSON Schema markers (`type`, `properties`, `$ref`,
1279
1128
  * `allOf`, `anyOf`, `oneOf`, `items`, `enum`) and does NOT have Zod markers.
1280
1129
  */
1281
- declare function isJsonSchema(input: unknown): input is Record<string, unknown>;
1130
+ export declare function isJsonSchema(input: unknown): input is Record<string, unknown>;
1282
1131
  /**
1283
1132
  * Check if an object is a Zod schema (has `_zod` marker from Zod v4).
1284
1133
  */
1285
- declare function isZodSchema(input: unknown): boolean;
1134
+ export declare function isZodSchema(input: unknown): boolean;
1286
1135
  /**
1287
1136
  * How `toJsonSchema` reacts when a Zod schema CANNOT be converted (zod not
1288
1137
  * installed/loaded, zod v3, or `z.toJSONSchema()` threw):
@@ -1316,7 +1165,7 @@ type UnconvertibleMode = "warn" | "throw";
1316
1165
  * docblock. Defaults to `'output'`, matching Zod's own default;
1317
1166
  * arc's request-side call sites pass `'input'` explicitly.
1318
1167
  */
1319
- declare function toJsonSchema(input: unknown, target?: JsonSchemaTarget, mode?: UnconvertibleMode, io?: SchemaIo): Record<string, unknown> | undefined;
1168
+ export declare function toJsonSchema(input: unknown, target?: JsonSchemaTarget, mode?: UnconvertibleMode, io?: SchemaIo): Record<string, unknown> | undefined;
1320
1169
  /**
1321
1170
  * Convert all schema fields in an OpenApiSchemas object.
1322
1171
  * JSON Schema values pass through unchanged. Only Zod schemas are converted.
@@ -1324,7 +1173,7 @@ declare function toJsonSchema(input: unknown, target?: JsonSchemaTarget, mode?:
1324
1173
  * Defaults to the `openapi-3.0` target since this function feeds OpenAPI doc
1325
1174
  * generation, not Fastify route validation.
1326
1175
  */
1327
- declare function convertOpenApiSchemas(schemas: OpenApiSchemas, target?: JsonSchemaTarget): OpenApiSchemas;
1176
+ export declare function convertOpenApiSchemas(schemas: OpenApiSchemas, target?: JsonSchemaTarget): OpenApiSchemas;
1328
1177
  /**
1329
1178
  * Convert schema values in a Fastify route schema record.
1330
1179
  *
@@ -1338,7 +1187,19 @@ declare function convertOpenApiSchemas(schemas: OpenApiSchemas, target?: JsonSch
1338
1187
  * Defaults to `draft-7` so Fastify v5's bundled AJV 8 accepts the output.
1339
1188
  * Pass `openapi-3.0` (or `openapi-3.1`) when generating OpenAPI documents.
1340
1189
  */
1341
- declare function convertRouteSchema(schema: Record<string, unknown>, target?: JsonSchemaTarget): Record<string, unknown>;
1190
+ export declare function convertRouteSchema(schema: Record<string, unknown>, target?: JsonSchemaTarget): Record<string, unknown>;
1191
+ //#endregion
1192
+ //#region src/utils/shutdown.d.ts
1193
+ interface ShutdownParticipant {
1194
+ readonly name: string;
1195
+ readonly kind?: "producer" | "consumer";
1196
+ stop?(): void | Promise<void>;
1197
+ drain?(): void | Promise<void>;
1198
+ }
1199
+ /** Descendants of admitted work may finish their causal publications during shutdown. */
1200
+ export declare function runAdmittedWork<T>(work: () => T | Promise<T>): Promise<T>;
1201
+ /** A participant's stop must prevent new work; drain waits for work already admitted. */
1202
+ export declare function registerShutdownParticipant(fastify: FastifyInstance, participant: ShutdownParticipant): void;
1342
1203
  //#endregion
1343
1204
  //#region src/utils/simpleEqualityMatcher.d.ts
1344
1205
  /**
@@ -1365,7 +1226,7 @@ declare function convertRouteSchema(schema: Record<string, unknown>, target?: Js
1365
1226
  * matchesFilter: simpleEqualityMatcher };
1366
1227
  * ```
1367
1228
  */
1368
- declare function simpleEqualityMatcher(item: unknown, filters: Record<string, unknown>): boolean;
1229
+ export declare function simpleEqualityMatcher(item: unknown, filters: Record<string, unknown>): boolean;
1369
1230
  //#endregion
1370
1231
  //#region src/utils/sseStream.d.ts
1371
1232
  interface SseStreamOptions {
@@ -1397,7 +1258,7 @@ interface SseStream {
1397
1258
  * gate (auth, permissions, validation) has passed — after `hijack()` no
1398
1259
  * JSON error can be sent.
1399
1260
  */
1400
- declare function openSseStream(request: FastifyRequest, reply: FastifyReply, options?: SseStreamOptions): SseStream;
1261
+ export declare function openSseStream(request: FastifyRequest, reply: FastifyReply, options?: SseStreamOptions): SseStream;
1401
1262
  //#endregion
1402
1263
  //#region src/utils/stateMachine.d.ts
1403
1264
  /**
@@ -1508,7 +1369,7 @@ type TransitionConfig = Record<string, string[] | {
1508
1369
  * },
1509
1370
  * }, { trackHistory: true });
1510
1371
  */
1511
- declare function createStateMachine(name: string, transitions?: TransitionConfig, options?: {
1372
+ export declare function createStateMachine(name: string, transitions?: TransitionConfig, options?: {
1512
1373
  trackHistory?: boolean;
1513
1374
  }): StateMachine;
1514
1375
  //#endregion
@@ -1520,7 +1381,7 @@ declare function createStateMachine(name: string, transitions?: TransitionConfig
1520
1381
  * client uses to detect the v1 UI message stream protocol (vs the older
1521
1382
  * data stream protocol). Surfaced as a constant so hosts don't memorise it.
1522
1383
  */
1523
- declare const UI_MESSAGE_STREAM_HEADERS: {
1384
+ export declare const UI_MESSAGE_STREAM_HEADERS: {
1524
1385
  readonly "content-type": "text/event-stream";
1525
1386
  readonly "cache-control": "no-cache";
1526
1387
  readonly connection: "keep-alive";
@@ -1577,7 +1438,7 @@ interface PipeUIMessageStreamOptions {
1577
1438
  * });
1578
1439
  * ```
1579
1440
  */
1580
- declare function pipeUIMessageStreamToReply(reply: FastifyReply, stream: ReadableStream<unknown>, options?: PipeUIMessageStreamOptions): Promise<void>;
1441
+ export declare function pipeUIMessageStreamToReply(reply: FastifyReply, stream: ReadableStream<unknown>, options?: PipeUIMessageStreamOptions): Promise<void>;
1581
1442
  /**
1582
1443
  * Promote a stream auth token from the query string into the `Authorization`
1583
1444
  * header, in place, so the standard `fastify.authenticate` decorator can read it.
@@ -1601,7 +1462,7 @@ declare function pipeUIMessageStreamToReply(reply: FastifyReply, stream: Readabl
1601
1462
  *
1602
1463
  * @param queryParam name of the query parameter carrying the token (default `token`).
1603
1464
  */
1604
- declare function promoteStreamTokenToHeader(request: FastifyRequest, queryParam?: string): void;
1465
+ export declare function promoteStreamTokenToHeader(request: FastifyRequest, queryParam?: string): void;
1605
1466
  /**
1606
1467
  * Collect the CORS / `Vary` headers a plugin (e.g. `@fastify/cors`, whose default
1607
1468
  * `onRequest` hook runs BEFORE the route handler) has already set on the reply, so
@@ -1615,7 +1476,7 @@ declare function promoteStreamTokenToHeader(request: FastifyRequest, queryParam?
1615
1476
  * honors the host's configured policy (origin allowlist, credentials) rather than
1616
1477
  * re-deriving it. Returns lowercased header names suitable for `writeHead`.
1617
1478
  */
1618
- declare function forwardedStreamHeaders(reply: FastifyReply): Record<string, string>;
1479
+ export declare function forwardedStreamHeaders(reply: FastifyReply): Record<string, string>;
1619
1480
  /**
1620
1481
  * Heuristic — does this value look like a Web `ReadableStream`?
1621
1482
  *
@@ -1625,7 +1486,7 @@ declare function forwardedStreamHeaders(reply: FastifyReply): Record<string, str
1625
1486
  * the Streams spec mandates: `getReader`, `cancel`, and the `locked`
1626
1487
  * getter.
1627
1488
  */
1628
- declare function isReadableStream(value: unknown): value is ReadableStream<unknown>;
1489
+ export declare function isReadableStream(value: unknown): value is ReadableStream<unknown>;
1629
1490
  //#endregion
1630
1491
  //#region src/utils/typeGuards.d.ts
1631
1492
  interface EventsDecorator {
@@ -1638,8 +1499,8 @@ interface EventsDecorator {
1638
1499
  transportName: string;
1639
1500
  }
1640
1501
  /** Check if fastify has the events plugin registered */
1641
- declare function hasEvents(instance: FastifyInstance): instance is FastifyInstance & {
1502
+ export declare function hasEvents(instance: FastifyInstance): instance is FastifyInstance & {
1642
1503
  events: EventsDecorator;
1643
1504
  };
1644
1505
  //#endregion
1645
- export { ArcError, type ArcHeaders, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, type CircuitBreakerRedisLike, CircuitBreakerRegistry, type CircuitBreakerSharedState, type CircuitBreakerStats, CircuitState, type CompensationDefinition, type CompensationError, type CompensationHooks, type CompensationResult, type CompensationStep, ConflictError, type ErrorOptions, type EventsDecorator, type FilterDialect, ForbiddenError, type Guard, type GuardConfig, type JsonSchema, type JsonSchemaTarget, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, type PipeUIMessageStreamOptions, RateLimitError, RedisCircuitBreakerState, type RedisCircuitBreakerStateOptions, type RuntimeCapabilityDeclaration, type SchemaIo, ServiceUnavailableError, type SseStream, type SseStreamOptions, type StateMachine, type TransitionConfig, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, declareRuntimeCapability, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, forwardedStreamHeaders, getDefaultCrudSchemas, getHeader, getListQueryParams, getUserId, getUserRoles, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, normalizeRoles, offsetListResponse, openSseStream, paginationSchema, pipeUIMessageStreamToReply, promoteStreamTokenToHeader, queryParams, requireSingleHeaderValue, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, withCompensation };
1506
+ export { type AnyAsyncFn, ArcError, type ArcHeaders, type ArcQueryParserOptions, type CircuitBreakerOptions, type CircuitBreakerRedisLike, type CircuitBreakerSharedState, type CircuitBreakerStats, type CompensationDefinition, type CompensationError, type CompensationHooks, type CompensationResult, type CompensationStep, ConflictError, type ErrorOptions, type EventsDecorator, type FilterDialect, ForbiddenError, type Guard, type GuardConfig, type JsonSchema, type JsonSchemaTarget, NotFoundError, OrgAccessDeniedError, OrgRequiredError, type PipeUIMessageStreamOptions, RateLimitError, type RedisCircuitBreakerStateOptions, type RuntimeCapabilityDeclaration, type SchemaIo, ServiceUnavailableError, type ShutdownParticipant, type SseStream, type SseStreamOptions, type StateMachine, type TransitionConfig, UnauthorizedError, type UnconvertibleMode, ValidationError, createDomainError, createError, errorContractSchema, getHeader, getUserId, getUserRoles, isArcError, normalizeRoles, requireSingleHeaderValue };