@classytic/arc 2.32.0 → 2.33.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 (192) hide show
  1. package/README.md +1 -1
  2. package/bin/arc.js +58 -17
  3. package/dist/{BaseController-Dk34dxhI.mjs → BaseController-CaQC5EXX.mjs} +293 -33
  4. package/dist/{EventTransport-2uVV34WU.d.mts → EventTransport-BEVP50ka.d.mts} +16 -0
  5. package/dist/{EventTransport-BV10D0oG.mjs → EventTransport-tq4CEB-q.mjs} +39 -2
  6. package/dist/{HookSystem-vimw5D7Z.mjs → HookSystem-DqXkMXkB.mjs} +2 -2
  7. package/dist/{ResourceRegistry-BVr7PgA0.mjs → ResourceRegistry-DoALUlOO.mjs} +3 -2
  8. package/dist/{actionPermissions-Dti7ebyv.mjs → actionPermissions-CUeCmpUd.mjs} +1 -1
  9. package/dist/audit/index.d.mts +2 -2
  10. package/dist/audit/index.mjs +2 -2
  11. package/dist/auth/audit.mjs +1 -1
  12. package/dist/auth/index.d.mts +2 -2
  13. package/dist/auth/index.mjs +39 -7
  14. package/dist/auth/redis-session.mjs +1 -1
  15. package/dist/{authorizationDecision-__T3EJDA.mjs → authorizationDecision-B3mP_QTy.mjs} +2 -2
  16. package/dist/{types-B7XeLEgK.d.mts → base-Csjc2oF-.d.mts} +74 -74
  17. package/dist/{buildHandler-Dn7rzUJo.mjs → buildHandler-DLE9xX-V.mjs} +4 -4
  18. package/dist/cache/index.mjs +4 -4
  19. package/dist/{caching-DFJqHyFs.mjs → caching-BcGmvnHh.mjs} +2 -2
  20. package/dist/cleanup/index.d.mts +17 -5
  21. package/dist/cleanup/index.mjs +240 -7
  22. package/dist/cli/commands/describe.d.mts +1 -1
  23. package/dist/cli/commands/describe.mjs +3 -3
  24. package/dist/cli/commands/docs.mjs +3 -3
  25. package/dist/cli/commands/doctor.mjs +1 -1
  26. package/dist/cli/commands/generate.mjs +2 -2
  27. package/dist/cli/commands/init.mjs +2 -2
  28. package/dist/cli/commands/introspect.mjs +2 -2
  29. package/dist/cli/index.mjs +3 -3
  30. package/dist/{constants-J99LGTJI.mjs → constants-BxCoxmiN.mjs} +1 -1
  31. package/dist/context/index.mjs +3 -3
  32. package/dist/core/index.d.mts +2 -2
  33. package/dist/core/index.mjs +7 -7
  34. package/dist/{core-BwwmNSp7.mjs → core-dxhcHhUD.mjs} +3 -3
  35. package/dist/{createActionRouter-DkJZWo0m.mjs → createActionRouter-DVpoA0do.mjs} +8 -8
  36. package/dist/{createAggregationRouter-B1exOVD8.mjs → createAggregationRouter-B_B48JZ-.mjs} +7 -7
  37. package/dist/{createApp-Bv0m-Q6_.mjs → createApp-CLGegqiG.mjs} +128 -24
  38. package/dist/{defineAggregation-gX4No1gt.mjs → defineAggregation-Nv-DwfOf.mjs} +1 -1
  39. package/dist/{defineResource-XFPPUu2c.mjs → defineResource-DR9vsUYy.mjs} +297 -23
  40. package/dist/discovery/index.mjs +1 -1
  41. package/dist/docs/index.d.mts +1 -1
  42. package/dist/docs/index.mjs +3 -3
  43. package/dist/{elevation-DNXXxgjl.mjs → elevation-B0tlY8y1.mjs} +4 -4
  44. package/dist/encryption/index.mjs +3 -3
  45. package/dist/{errorHandler-B2AZUJUj.mjs → errorHandler-C7xBqHsI.mjs} +42 -5
  46. package/dist/{errorHandler-CpYUJmPA.d.mts → errorHandler-DI5AN2b5.d.mts} +14 -3
  47. package/dist/{errors-Bh1KK5ps.mjs → errors-Cd_yy7aW.mjs} +1 -1
  48. package/dist/{eventPlugin-GF5nnBIq.d.mts → eventPlugin-DSNEZWfV.d.mts} +29 -1
  49. package/dist/{eventPlugin-Dk_TyXeE.mjs → eventPlugin-Dar8qRaj.mjs} +65 -9
  50. package/dist/events/index.d.mts +5 -351
  51. package/dist/events/index.mjs +5 -780
  52. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  53. package/dist/events/transports/redis-stream-entry.mjs +1 -1
  54. package/dist/events/transports/redis.d.mts +1 -1
  55. package/dist/events/transports/redis.mjs +1 -1
  56. package/dist/factory/index.d.mts +20 -5
  57. package/dist/factory/index.mjs +7 -7
  58. package/dist/{fastify-augmentation-BppG5bMT.d.mts → fastify-augmentation-DVsTAy6X.d.mts} +3 -3
  59. package/dist/{fields-DEi65pGj.mjs → fields-CojeUkS4.mjs} +1 -1
  60. package/dist/{generate-CRSG0jTv.mjs → generate-DiB0nHPR.mjs} +2 -2
  61. package/dist/{headers-BXjQYbeC.mjs → headers-CveNO9gR.mjs} +2 -2
  62. package/dist/{health-5XnTa2uo.mjs → health-CasG2A28.mjs} +1 -1
  63. package/dist/hooks/index.d.mts +1 -1
  64. package/dist/hooks/index.mjs +2 -2
  65. package/dist/idempotency/index.d.mts +45 -1
  66. package/dist/idempotency/index.mjs +91 -9
  67. package/dist/idempotency/redis.mjs +1 -1
  68. package/dist/{index-zq6VrjaB.d.mts → index-B-DvUzsr.d.mts} +12 -2
  69. package/dist/{index-CpzxqePp.d.mts → index-BcR2bFZQ.d.mts} +707 -373
  70. package/dist/{index-DXlHwvuE.d.mts → index-Brin0ODU.d.mts} +4 -4
  71. package/dist/{index-ZWhLTp_s.d.mts → index-C5NnMEKF.d.mts} +1 -1
  72. package/dist/{index-C-481Zf2.d.mts → index-ugr1tQlW.d.mts} +17 -1
  73. package/dist/index.d.mts +6 -6
  74. package/dist/index.mjs +11 -11
  75. package/dist/{init-BbfP8aky.mjs → init-mdJ-v4Xp.mjs} +18 -12
  76. package/dist/integrations/event-gateway.d.mts +1 -1
  77. package/dist/integrations/event-gateway.mjs +2 -2
  78. package/dist/integrations/index.d.mts +2 -2
  79. package/dist/integrations/index.mjs +1 -1
  80. package/dist/integrations/jobs/index.d.mts +1 -1
  81. package/dist/integrations/jobs/index.mjs +99 -97
  82. package/dist/integrations/mcp/index.d.mts +12 -3
  83. package/dist/integrations/mcp/index.mjs +2 -2
  84. package/dist/integrations/mcp/testing.d.mts +1 -1
  85. package/dist/integrations/mcp/testing.mjs +2 -2
  86. package/dist/integrations/streamline.mjs +3 -3
  87. package/dist/integrations/webhooks.d.mts +124 -1
  88. package/dist/integrations/webhooks.mjs +180 -2
  89. package/dist/integrations/websocket-pushref-redis.mjs +1 -1
  90. package/dist/integrations/websocket-redis.mjs +1 -1
  91. package/dist/integrations/websocket.mjs +1 -1
  92. package/dist/{interface-BP4IJCBO.mjs → interface-DznJrm9R.mjs} +1 -1
  93. package/dist/{jsonBody-DDSR2HFl.mjs → jsonBody-CfGH-GxO.mjs} +2 -2
  94. package/dist/{keys-B-HBTGXl.mjs → keys-WeKvY1dE.mjs} +1 -1
  95. package/dist/{loadResources-DisEAmkm.mjs → loadResources-Bj-aSsXi.mjs} +2 -2
  96. package/dist/{loadResourcesFromEntry-D1MJp13f.mjs → loadResourcesFromEntry-DwaxNcE2.mjs} +2 -2
  97. package/dist/logger/index.mjs +1 -1
  98. package/dist/{mcpPlugin-CpfVpKHE.mjs → mcpPlugin-aJg5TqHi.mjs} +60 -21
  99. package/dist/{memory-DsuWnj4T.mjs → memory-qYSB7rMQ.mjs} +2 -2
  100. package/dist/{metrics-DdQL8syd.mjs → metrics-D7uchLjN.mjs} +2 -2
  101. package/dist/middleware/index.d.mts +1 -1
  102. package/dist/middleware/index.mjs +3 -3
  103. package/dist/migrations/index.mjs +2 -2
  104. package/dist/{module-Br81am6m.mjs → module-CwKsgZXp.mjs} +1 -1
  105. package/dist/{multipartBody-BnkBLN7v.mjs → multipartBody-4w-S3-PU.mjs} +1 -1
  106. package/dist/{openapi-DIRzvxC0.mjs → openapi-BN5cQaO2.mjs} +6 -6
  107. package/dist/outbox-admin/index.d.mts +2 -2
  108. package/dist/outbox-admin/index.mjs +4 -4
  109. package/dist/outbox-module-CXB79bvt.mjs +839 -0
  110. package/dist/outbox-module-D-VFq37T.d.mts +368 -0
  111. package/dist/permissions/index.d.mts +2 -2
  112. package/dist/permissions/index.mjs +5 -5
  113. package/dist/{permissions-Dl_m0NCe.mjs → permissions-BAfwgBxc.mjs} +25 -6
  114. package/dist/{pipe-ELHCP3zj.mjs → pipe-BzzoEhHj.mjs} +2 -2
  115. package/dist/pipeline/index.d.mts +1 -1
  116. package/dist/pipeline/index.mjs +2 -2
  117. package/dist/{pipeline-CPA-jx0M.mjs → pipeline-q69DZzgG.mjs} +6 -6
  118. package/dist/plugins/index.d.mts +6 -6
  119. package/dist/plugins/index.mjs +16 -16
  120. package/dist/plugins/response-cache.mjs +2 -2
  121. package/dist/plugins/tracing-entry.mjs +2 -2
  122. package/dist/{pluralize-C2ZkKbsn.mjs → pluralize-B7xf8qZF.mjs} +1 -1
  123. package/dist/{preloadResources-CDs87fTw.mjs → preloadResources-BkyqeTDz.mjs} +1 -1
  124. package/dist/{preloadResources-T1hmlTEZ.d.mts → preloadResources-g07ldtzh.d.mts} +30 -7
  125. package/dist/presets/filesUpload.d.mts +2 -2
  126. package/dist/presets/filesUpload.mjs +5 -5
  127. package/dist/presets/index.d.mts +2 -2
  128. package/dist/presets/index.mjs +2 -2
  129. package/dist/presets/multiTenant.d.mts +1 -1
  130. package/dist/presets/multiTenant.mjs +3 -3
  131. package/dist/presets/search.d.mts +2 -2
  132. package/dist/presets/search.mjs +2 -2
  133. package/dist/{presets-Dntd_pUO.mjs → presets-D-h0uWtP.mjs} +4 -4
  134. package/dist/projection-BKM0Ui-s.mjs +42 -0
  135. package/dist/{queryCachePlugin-Dhps-Ldt.mjs → queryCachePlugin-DhsZ0ZIc.mjs} +49 -7
  136. package/dist/{rateLimit-C7mmAGs3.mjs → rateLimit-D4-ASwsI.mjs} +2 -2
  137. package/dist/{rateLimitKey-CccEFBfk.mjs → rateLimitKey-XngqVNEV.mjs} +1 -1
  138. package/dist/{realtime-DVvVZZFz.mjs → realtime-CTkv3O59.mjs} +9 -9
  139. package/dist/{redis-stream-qN6A-RFv.d.mts → redis-stream-mwLWlfHG.d.mts} +1 -1
  140. package/dist/{registerRoute-B_QrjYZS.mjs → registerRoute-DNnd3vkz.mjs} +4 -4
  141. package/dist/registry/index.d.mts +3 -3
  142. package/dist/registry/index.mjs +3 -3
  143. package/dist/{registry-DqUmzA9W.mjs → registry-CLxCR5LF.mjs} +2 -2
  144. package/dist/{renewingLease-BpP9wwj7.mjs → renewingLease-BnWtbA2U.mjs} +1 -1
  145. package/dist/{replyHelpers-DS-P0b32.mjs → replyHelpers-BSBVCwL3.mjs} +2 -2
  146. package/dist/{repositoryFilter-DotlxG3L.mjs → repositoryFilter-DKny7PDn.mjs} +1 -1
  147. package/dist/{requestContext-B6vQF-sy.mjs → requestContext-uYE35JxI.mjs} +1 -1
  148. package/dist/{rolldown-runtime-BhflRrBs.mjs → rolldown-runtime-DNg-KNCk.mjs} +1 -1
  149. package/dist/runtimeCapabilities-Dm88DaTW.mjs +49 -0
  150. package/dist/{schedules-C2Q3uv2d.mjs → schedules-CAcZgia0.mjs} +3 -3
  151. package/dist/{schemaConverter-Crjvczi_.mjs → schemaConverter-XH1RZRyu.mjs} +1 -1
  152. package/dist/{schemaIR-CnyKK_1j.mjs → schemaIR-CDvclAew.mjs} +2 -2
  153. package/dist/schemas/index.mjs +1 -1
  154. package/dist/scim/index.mjs +2 -2
  155. package/dist/scope/index.mjs +5 -5
  156. package/dist/{scope-afz_Ieek.mjs → scope-BaWcqBvr.mjs} +4 -4
  157. package/dist/{simpleEqualityMatcher-C4KiMWUa.mjs → simpleEqualityMatcher-Se8VrsaP.mjs} +1 -1
  158. package/dist/{sse-B9P4Y-UI.mjs → sse-Cf0jUHsh.mjs} +5 -5
  159. package/dist/{sseStream-B3zb_d1h.mjs → sseStream-Bvpi-UXQ.mjs} +2 -2
  160. package/dist/{store-helpers-DmEMHlPQ.mjs → store-helpers-B88p99Z2.mjs} +1 -1
  161. package/dist/{streaming-DPZdQmDz.mjs → streaming-DsT1B5zJ.mjs} +1 -1
  162. package/dist/{subscribe-helpers-sp5xTDVA.mjs → subscribe-helpers-CLIOHsOK.mjs} +2 -2
  163. package/dist/sync/changelog.mjs +1 -1
  164. package/dist/testing/cleanupStoreContract.d.mts +1 -1
  165. package/dist/testing/cleanupStoreContract.mjs +3 -1
  166. package/dist/testing/index.d.mts +24 -12
  167. package/dist/testing/index.mjs +24 -12
  168. package/dist/testing/outboxStoreContract.mjs +1 -1
  169. package/dist/testing/storageContract.mjs +1 -1
  170. package/dist/{transactionContext-BvLKvOIL.mjs → transactionContext-BYtWnwAS.mjs} +1 -1
  171. package/dist/{typeGuards-B_5-hKjJ.mjs → typeGuards-jjKJDN13.mjs} +1 -1
  172. package/dist/types/index.d.mts +3 -3
  173. package/dist/types/index.mjs +1 -1
  174. package/dist/types/storage.mjs +1 -1
  175. package/dist/{types-CT5vu6M0.d.mts → types-BcTumAz_.d.mts} +41 -7
  176. package/dist/{types-CwcUQ610.d.mts → types-BfC83KsP.d.mts} +15 -1
  177. package/dist/{types-DXYX7dIR.mjs → types-CoqIRrkY.mjs} +4 -4
  178. package/dist/{types-C4QE8qnm.d.mts → types-DVLddu2q.d.mts} +144 -1
  179. package/dist/usage/index.d.mts +1 -1
  180. package/dist/usage/index.mjs +0 -0
  181. package/dist/{userHelpers-BNsOXzOd.mjs → userHelpers-CWF5pbZD.mjs} +1 -1
  182. package/dist/utils/index.d.mts +57 -5
  183. package/dist/utils/index.mjs +12 -11
  184. package/dist/{utils-BtOha_Sp.mjs → utils-h1V_sT-t.mjs} +38 -7
  185. package/dist/{validate-PMCPR9El.mjs → validate-CdQlz52F.mjs} +2 -2
  186. package/dist/{versioning-D_rhHfZm.d.mts → versioning-DEs-_hFi.d.mts} +1 -1
  187. package/dist/{versioning-CKv2jz_U.mjs → versioning-rZbyLVD-.mjs} +3 -3
  188. package/package.json +17 -16
  189. package/skills/arc/SKILL.md +96 -4
  190. package/skills/arc/references/api-reference.md +19 -0
  191. package/skills/arc/references/production.md +2 -2
  192. package/dist/projection-CjHhM5W1.mjs +0 -18
@@ -1,14 +1,14 @@
1
1
 
2
- import { V as ResourceDefinition } from "../index-CpzxqePp.mjs";
3
2
  import { i as RequestScope } from "../types-ChuShpCP.mjs";
4
- import { l as AnyRecord, r as PermissionCheck } from "../types-B7XeLEgK.mjs";
5
- import { n as ArcModuleInput, o as ModuleDisposer, s as ModuleSetupContext } from "../types-CT5vu6M0.mjs";
6
- import "../index-ZWhLTp_s.mjs";
7
- import { n as preloadResourcesAsync, r as CreateAppOptions, t as preloadResources } from "../preloadResources-T1hmlTEZ.mjs";
3
+ import { l as PermissionCheck, t as AnyRecord } from "../base-Csjc2oF-.mjs";
4
+ import { V as ResourceDefinition } from "../index-BcR2bFZQ.mjs";
5
+ import { n as ArcModuleInput, o as ModuleDisposer, s as ModuleSetupContext } from "../types-BcTumAz_.mjs";
6
+ import "../index-C5NnMEKF.mjs";
7
+ import { n as preloadResourcesAsync, r as CreateAppOptions, t as preloadResources } from "../preloadResources-g07ldtzh.mjs";
8
8
  import { StorageContractSetup, StorageContractSetupResult, runStorageContract } from "./storageContract.mjs";
9
+ import { StandardRepo } from "@classytic/repo-core/repository";
9
10
  import { FastifyInstance, FastifyServerOptions } from "fastify";
10
11
  import { Mock } from "vitest";
11
- import { StandardRepo } from "@classytic/repo-core/repository";
12
12
  //#region src/testing/assertions.d.ts
13
13
  /**
14
14
  * expectArc — Arc-specific response assertions
@@ -611,15 +611,27 @@ declare function createMockRequest(overrides?: Partial<AnyRecord>): unknown;
611
611
  */
612
612
  declare function createMockReply(): unknown;
613
613
  /**
614
- * Create a mock controller for testing
614
+ * Create a mock controller for testing.
615
+ *
616
+ * The return type is ANNOTATED rather than inferred, and writing it out IS the
617
+ * fix: inference expands `Mock`'s default type argument to `Procedure`, which
618
+ * vitest declares in an internal sub-package arc does not depend on. The
619
+ * emitted declaration then referenced that package by name — resolvable under
620
+ * npm's hoisting because `vitest` (a real peer) drags it in, and broken under
621
+ * pnpm's strict layout, where a transitive dep is not reachable from a
622
+ * consumer's root.
623
+ *
624
+ * Bare `Mock` keeps the permissive ergonomics (`.mockResolvedValue(...)`, any
625
+ * arguments) while naming only `vitest`, which arc does declare. Same shape
626
+ * `MockRepository` above uses.
615
627
  */
616
628
  declare function createMockController(repository: StandardRepo<AnyRecord>): {
617
629
  repository: StandardRepo<AnyRecord>;
618
- list: Mock<import("@vitest/spy").Procedure>;
619
- get: Mock<import("@vitest/spy").Procedure>;
620
- create: Mock<import("@vitest/spy").Procedure>;
621
- update: Mock<import("@vitest/spy").Procedure>;
622
- delete: Mock<import("@vitest/spy").Procedure>;
630
+ list: Mock;
631
+ get: Mock;
632
+ create: Mock;
633
+ update: Mock;
634
+ delete: Mock;
623
635
  };
624
636
  /**
625
637
  * Create mock data factory
@@ -1,13 +1,13 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { t as CRUD_OPERATIONS } from "../constants-J99LGTJI.mjs";
3
- import { g as getUserId } from "../types-DXYX7dIR.mjs";
4
- import { t as BaseController } from "../BaseController-Dk34dxhI.mjs";
5
- import { t as defineResource } from "../defineResource-XFPPUu2c.mjs";
6
- import { t as defineAggregation } from "../defineAggregation-gX4No1gt.mjs";
7
- import { E as requireOrgRole } from "../permissions-Dl_m0NCe.mjs";
8
- import { n as createApp } from "../createApp-Bv0m-Q6_.mjs";
9
- import { n as getModuleExports } from "../module-Br81am6m.mjs";
10
- import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-CDs87fTw.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { t as CRUD_OPERATIONS } from "../constants-BxCoxmiN.mjs";
3
+ import { g as getUserId } from "../types-CoqIRrkY.mjs";
4
+ import { t as BaseController } from "../BaseController-CaQC5EXX.mjs";
5
+ import { t as defineResource } from "../defineResource-DR9vsUYy.mjs";
6
+ import { t as defineAggregation } from "../defineAggregation-Nv-DwfOf.mjs";
7
+ import { E as requireOrgRole } from "../permissions-BAfwgBxc.mjs";
8
+ import { r as createApp } from "../createApp-CLGegqiG.mjs";
9
+ import { n as getModuleExports } from "../module-CwKsgZXp.mjs";
10
+ import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-BkyqeTDz.mjs";
11
11
  import { runStorageContract } from "./storageContract.mjs";
12
12
  import Fastify from "fastify";
13
13
  import { afterAll, describe, expect, it, vi } from "vitest";
@@ -251,7 +251,19 @@ function createMockReply() {
251
251
  };
252
252
  }
253
253
  /**
254
- * Create a mock controller for testing
254
+ * Create a mock controller for testing.
255
+ *
256
+ * The return type is ANNOTATED rather than inferred, and writing it out IS the
257
+ * fix: inference expands `Mock`'s default type argument to `Procedure`, which
258
+ * vitest declares in an internal sub-package arc does not depend on. The
259
+ * emitted declaration then referenced that package by name — resolvable under
260
+ * npm's hoisting because `vitest` (a real peer) drags it in, and broken under
261
+ * pnpm's strict layout, where a transitive dep is not reachable from a
262
+ * consumer's root.
263
+ *
264
+ * Bare `Mock` keeps the permissive ergonomics (`.mockResolvedValue(...)`, any
265
+ * arguments) while naming only `vitest`, which arc does declare. Same shape
266
+ * `MockRepository` above uses.
255
267
  */
256
268
  function createMockController(repository) {
257
269
  return {
@@ -1493,7 +1505,7 @@ function pickDefaultAuth(authMode, callerAuth) {
1493
1505
  };
1494
1506
  }
1495
1507
  async function createTestApp(options = {}) {
1496
- const { createApp } = await import("../createApp-Bv0m-Q6_.mjs").then((n) => n.r);
1508
+ const { createApp } = await import("../createApp-CLGegqiG.mjs").then((n) => n.i);
1497
1509
  const { resources = [], db = "in-memory", connectMongoose = false, authMode = "jwt", defaultOrgId, plugins, auth: callerAuth, ...appOptions } = options;
1498
1510
  let dbHandle;
1499
1511
  let dbUri;
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  import { OutboxOwnershipError } from "@classytic/primitives/outbox";
3
3
  import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
4
4
  //#region src/testing/outboxStoreContract.ts
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  import { afterAll, beforeAll, describe, expect, it } from "vitest";
3
3
  //#region src/testing/storageContract.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/context/transactionContext.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  //#region src/utils/typeGuards.ts
3
3
  /** Check if fastify has the events plugin registered */
4
4
  function hasEvents(instance) {
@@ -1,6 +1,6 @@
1
1
 
2
- import { $ as OpenApiSchemas, A as RequestIdOptions, An as BaseControllerOptions, At as RouteDefinition, Bt as RawRouteHandler, C as RequestContext, D as HealthCheck, Dt as ActionEntry, E as GracefulShutdownOptions, Et as ActionDefinition, F as FastifyWithDecorators, Ft as ControllerLike, G as OnTenantDeleteConfig, Gt as Authenticator, H as CrudController, I as MiddlewareHandler, It as FastifyHandler, J as PresetHook, Jt as TokenPair, K as ResolvedTenantPurge, Kt as AuthenticatorContext, L as RequestWithExtras, Lt as IController, M as EventsDecorator, Mt as RouteMethod, N as FastifyRequestExtras, Nt as RateLimitConfig, O as HealthOptions, Ot as ActionHandlerFn, P as FastifyWithAuth, Pt as ControllerHandler, Q as MiddlewareConfig, Rt as IControllerResponse, S as QueryParserInterface, T as CrudRouterOptions, Tt as ResourceCacheConfig, U as ResourceConfig, Ut as AuthHelpers, Vt as RouteHandler, W as ResourcePermissions, Wt as AuthPluginOptions, X as CrudRouteKey, Y as PresetResult, Z as CrudSchemas, _ as ControllerQueryOptions, a as InferAdapterDoc, at as ResourceExtensions, b as ParsedQuery, c as TypedController, d as PaginationResult, et as RouteSchemaOptions, f as IntrospectionData, g as ArcInternalMetadata, h as ResourceMetadata, i as ValidationResult, it as ResourceHooks, j as ArcDecorator, jt as RouteMcpConfig, k as IntrospectionPluginOptions, kt as ActionsMap, l as TypedRepository, m as RegistryStats, n as ConfigError, nt as FieldRule, o as InferDocType, ot as EventDefinition, p as RegistryEntry, q as PresetFunction, qt as JwtContext, r as ValidateOptions, rt as ResourceHookContext, s as InferResourceDoc, t as RouteHandlerMethod, tt as ArcFieldRule, u as TypedResourceConfig, v as LookupOption, w as ServiceContext, x as PopulateOption, y as OwnershipCheck, zt as IRequestContext } from "../index-CpzxqePp.mjs";
3
2
  import { i as RequestScope } from "../types-ChuShpCP.mjs";
4
- import { a as UserBase, d as JWTPayload, f as ObjectId, i as PermissionContext, l as AnyRecord, m as UserOrganization, n as DataPolicy, p as UserLike, r as PermissionCheck, t as AuthorizationDecision, u as ArcRequest } from "../types-B7XeLEgK.mjs";
3
+ import { a as UserLike, c as DataPolicy, d as UserBase, i as ObjectId, l as PermissionCheck, n as ArcRequest, o as UserOrganization, r as JWTPayload, s as AuthorizationDecision, t as AnyRecord, u as PermissionContext } from "../base-Csjc2oF-.mjs";
4
+ import { $ as OpenApiSchemas, A as RequestIdOptions, An as WriteVerbKey, At as RouteDefinition, C as RequestContext, D as HealthCheck, Dn as MutationWriteContext, Dt as ActionEntry, E as GracefulShutdownOptions, Et as ActionDefinition, F as FastifyWithDecorators, Fn as IControllerResponse, Ft as AuthPluginOptions, G as OnTenantDeleteConfig, H as CrudController, I as MiddlewareHandler, In as IRequestContext, It as Authenticator, J as PresetHook, K as ResolvedTenantPurge, L as RequestWithExtras, Ln as RawRouteHandler, Lt as AuthenticatorContext, M as EventsDecorator, Mn as ControllerLike, Mt as RouteMethod, N as FastifyRequestExtras, Nn as FastifyHandler, Nt as RateLimitConfig, O as HealthOptions, On as ResourceWrites, Ot as ActionHandlerFn, P as FastifyWithAuth, Pn as IController, Pt as AuthHelpers, Q as MiddlewareConfig, Rn as RouteHandler, Rt as JwtContext, S as QueryParserInterface, T as CrudRouterOptions, Tt as ResourceCacheConfig, U as ResourceConfig, W as ResourcePermissions, X as CrudRouteKey, Y as PresetResult, Z as CrudSchemas, _ as ControllerQueryOptions, a as InferAdapterDoc, at as ResourceExtensions, b as ParsedQuery, c as TypedController, d as PaginationResult, et as RouteSchemaOptions, f as IntrospectionData, g as ArcInternalMetadata, h as ResourceMetadata, i as ValidationResult, it as ResourceHooks, j as ArcDecorator, jn as ControllerHandler, jt as RouteMcpConfig, k as IntrospectionPluginOptions, kn as WriteContext, kt as ActionsMap, l as TypedRepository, m as RegistryStats, n as ConfigError, nt as FieldRule, o as InferDocType, ot as EventDefinition, p as RegistryEntry, q as PresetFunction, r as ValidateOptions, rt as ResourceHookContext, s as InferResourceDoc, t as RouteHandlerMethod, tt as ArcFieldRule, u as TypedResourceConfig, v as LookupOption, w as ServiceContext, x as PopulateOption, xn as BaseControllerOptions, y as OwnershipCheck, zt as TokenPair } from "../index-BcR2bFZQ.mjs";
5
5
  import { n as ElevationOptions, t as ElevationEvent } from "../elevation-BXCfVcNG.mjs";
6
- export type { ActionDefinition, ActionEntry, ActionHandlerFn, ActionsMap, AnyRecord, ArcDecorator, ArcFieldRule, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, AuthorizationDecision, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRouteKey, CrudRouterOptions, CrudSchemas, DataPolicy, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, ObjectId, OnTenantDeleteConfig, OpenApiSchemas, OwnershipCheck, PaginationResult, ParsedQuery, PermissionCheck, PermissionContext, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryParserInterface, RateLimitConfig, RawRouteHandler, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResolvedTenantPurge, ResourceCacheConfig, ResourceConfig, ResourceExtensions, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, RouteDefinition, RouteHandler, RouteHandlerMethod, RouteMcpConfig, RouteMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult };
6
+ export type { ActionDefinition, ActionEntry, ActionHandlerFn, ActionsMap, AnyRecord, ArcDecorator, ArcFieldRule, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, AuthorizationDecision, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRouteKey, CrudRouterOptions, CrudSchemas, DataPolicy, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, MutationWriteContext, ObjectId, OnTenantDeleteConfig, OpenApiSchemas, OwnershipCheck, PaginationResult, ParsedQuery, PermissionCheck, PermissionContext, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryParserInterface, RateLimitConfig, RawRouteHandler, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResolvedTenantPurge, ResourceCacheConfig, ResourceConfig, ResourceExtensions, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, ResourceWrites, RouteDefinition, RouteHandler, RouteHandlerMethod, RouteMcpConfig, RouteMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult, WriteContext, WriteVerbKey };
@@ -1,2 +1,2 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  export {};
@@ -1,2 +1,2 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  export {};
@@ -1,6 +1,6 @@
1
1
 
2
- import { n as DomainEvent, r as EventHandler } from "./EventTransport-2uVV34WU.mjs";
3
- import { n as ErrorMapper } from "./errorHandler-CpYUJmPA.mjs";
2
+ import { n as DomainEvent, r as EventHandler } from "./EventTransport-BEVP50ka.mjs";
3
+ import { n as ErrorMapper } from "./errorHandler-DI5AN2b5.mjs";
4
4
  import { FastifyInstance, FastifyPluginAsync } from "fastify";
5
5
  import { LockAdapter } from "@classytic/repo-core/lock";
6
6
  //#region src/plugins/health.d.ts
@@ -49,6 +49,12 @@ interface ScheduleDefinition {
49
49
  handler: (fastify: FastifyInstance) => void | Promise<void>;
50
50
  /** Fire once immediately when the app becomes ready (default: false). */
51
51
  runOnStart?: boolean;
52
+ /**
53
+ * Topology tag: `'relay'` marks an arm a `role: 'relay'` process runs
54
+ * (outbox relays); everything else is `'job'` (default). See
55
+ * `CreateAppOptions.role`.
56
+ */
57
+ kind?: "relay" | "job";
52
58
  /**
53
59
  * Random extra delay in `[0, jitterMs)` added to the FIRST tick only.
54
60
  * Spreads boot-aligned jobs so multiple same-cadence schedules don't all
@@ -440,11 +446,39 @@ interface ArcModule<TExports = unknown> {
440
446
  */
441
447
  readonly dependsOn?: readonly string[];
442
448
  /**
443
- * Fastify plugins / decorators this module needs — the module-level analog
444
- * of the app's `plugins()` slot. Runs in the plugins phase: AFTER the app's
445
- * own `plugins()` (so module infra can build on app foundations like a DB
446
- * connection) and in `dependsOn` order, but BEFORE any module `bootstrap` —
447
- * so engines initialised in `bootstrap` can rely on what's registered here.
449
+ * Infra SETUP function — the module-level analog of the app's `plugins()`
450
+ * slot. Runs in the plugins phase: AFTER the app's own `plugins()` (so
451
+ * module infra can build on app foundations like a DB connection) and in
452
+ * `dependsOn` order, but BEFORE any module `bootstrap` — so engines
453
+ * initialised in `bootstrap` can rely on what's registered here.
454
+ *
455
+ * ## ⚠ This is NOT itself a Fastify plugin
456
+ *
457
+ * Despite the name, arc CALLS this function directly — it is never handed
458
+ * to `fastify.register()`. Two consequences, both of which bite module
459
+ * authors coming from ordinary Fastify plugins:
460
+ *
461
+ * - **You must register plugins yourself.** `await fastify.register(x)`,
462
+ * not `return x`. A returned function is read as a DISPOSER (below),
463
+ * so returning a plugin silently registers nothing and then invokes
464
+ * your plugin as a teardown callback. Arc detects the `fastify-plugin`
465
+ * case and throws; the bare-function case warns.
466
+ * - **There is no encapsulation and no prefix here.** Decorators and
467
+ * hooks you add land on the instance arc passes you — the same
468
+ * instance every other module sees. Fastify's encapsulation applies
469
+ * only inside a `register()` call you make yourself. See
470
+ * https://fastify.dev/docs/latest/Reference/Plugins/
471
+ *
472
+ * ```ts
473
+ * plugins: async (fastify) => {
474
+ * await fastify.register(somePlugin, { prefix: '/x' }); // ✅ register
475
+ * fastify.decorate('thing', thing); // ✅ root-visible
476
+ * // return somePlugin // ❌ never registered
477
+ * },
478
+ * ```
479
+ *
480
+ * The name is kept for the 2.x line; v3 renames the slot to `setup` and
481
+ * REMOVES `plugins` outright — v3 ships no compatibility aliases (v3.md).
448
482
  *
449
483
  * Separating this from `bootstrap` keeps lifecycle intent explicit for
450
484
  * published ecosystem packages: `plugins` = "register infra"; `bootstrap` =
@@ -1,5 +1,5 @@
1
1
 
2
- import { V as ResourceDefinition } from "./index-CpzxqePp.mjs";
2
+ import { V as ResourceDefinition } from "./index-BcR2bFZQ.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/integrations/mcp/types.d.ts
5
5
  /** Behavioral hints for MCP clients (tool annotations per MCP spec) */
@@ -377,6 +377,20 @@ interface McpAuthResult {
377
377
  * Carried on the `service` RequestScope for fine-grained permission checks.
378
378
  */
379
379
  scopes?: readonly string[];
380
+ /**
381
+ * Active team — carried onto a `member` scope so `getTeamId()` answers the
382
+ * same on MCP as on HTTP. Member-only, like the HTTP surface.
383
+ */
384
+ teamId?: string;
385
+ /**
386
+ * Host-defined scope dimensions (`branchId`, `projectId`, `region`, …),
387
+ * carried onto `member` / `service` scopes.
388
+ *
389
+ * Declared explicitly because `requireScopeContext()` AUTHORISES against
390
+ * these: a resource gated on `branchId` denies every MCP call until the
391
+ * resolver supplies it. Non-string entries are dropped rather than coerced.
392
+ */
393
+ context?: Record<string, string>;
380
394
  /** Any extra metadata from the auth resolver */
381
395
  [key: string]: unknown;
382
396
  }
@@ -1,7 +1,7 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { l as UnauthorizedError, o as OrgRequiredError } from "./errors-Bh1KK5ps.mjs";
3
- import { n as requireSingleHeaderValue } from "./headers-BXjQYbeC.mjs";
4
- import { t as getUserId$1 } from "./userHelpers-BNsOXzOd.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { l as UnauthorizedError, o as OrgRequiredError } from "./errors-Cd_yy7aW.mjs";
3
+ import { n as requireSingleHeaderValue } from "./headers-CveNO9gR.mjs";
4
+ import { t as getUserId$1 } from "./userHelpers-CWF5pbZD.mjs";
5
5
  //#region src/scope/types.ts
6
6
  /**
7
7
  * Request Scope — The One Standard
@@ -40,6 +40,18 @@ interface CleanupExecutionContext extends CleanupContext {
40
40
  * commits, call this so the executor learns of a cancel request promptly.
41
41
  */
42
42
  onStep(step: CleanupStepResult): Promise<void>;
43
+ /**
44
+ * Report a STEP LIFECYCLE transition — running / completed / skipped / failed.
45
+ *
46
+ * Separate from {@link onStep}, which reports a committed CHUNK and drives the
47
+ * aggregate counters. Folding both into one call would double-count `steps`
48
+ * and conflate "a batch landed" with "this phase is now done" — two different
49
+ * facts an operator reads differently.
50
+ *
51
+ * OPTIONAL on the context so a recipe that does not model discrete steps is
52
+ * unaffected; `recipeFromSteps` drives it for every composed recipe.
53
+ */
54
+ onStepState?(state: CleanupStepProgress): Promise<void>;
43
55
  /**
44
56
  * Throw `CleanupCancelled` if a cancel has been requested for this run. Cheap
45
57
  * to call between chunks; backed by the durable `cancelRequested` flag (the
@@ -56,13 +68,72 @@ interface Availability {
56
68
  /** Operator-supplied recipe parameters (branch, module set, before-date, …). */
57
69
  interface CleanupInput {
58
70
  readonly parameters?: Readonly<Record<string, unknown>> | undefined;
71
+ /**
72
+ * Step ids the operator chose to LEAVE OUT of this run.
73
+ *
74
+ * The obvious shape for this is a free-text ignore-list, which carries one
75
+ * dangerous gap: anything can be ignored, including the checks. Here a step
76
+ * that PROTECTS is not excludable — see
77
+ * {@link CleanupPlanItem.excluded} — because being able to switch off the
78
+ * thing standing between you and a statutory record makes the guard advisory.
79
+ * An unknown or unexcludable id REFUSES the plan rather than being dropped: a
80
+ * silently-ignored exclusion is an operator believing they narrowed a
81
+ * destructive run when they did not.
82
+ *
83
+ * SEALED INTO THE DIGEST. The exclusion set is part of what was consented to,
84
+ * so a plan previewed with accounting excluded cannot be executed as one that
85
+ * includes it.
86
+ *
87
+ * Framework-level and deliberately NOT smuggled through `parameters`:
88
+ * parameters are the recipe's domain scope, this is the composition.
89
+ */
90
+ readonly excludeSteps?: readonly string[] | undefined;
59
91
  }
92
+ /**
93
+ * What a line's `estimated` COUNTS. Absent ⇒ `'remove'`, so every existing
94
+ * recipe keeps its meaning.
95
+ *
96
+ * A protective guard step reports the records it DEFENDS, not records it would
97
+ * touch — and summing those into a "records to remove" headline overstates the
98
+ * damage by exactly the protected count. That is not cosmetic: a pre-live reset
99
+ * showed **540 records to remove** when 173 of them were posted journal entries
100
+ * the run would refuse to touch. The number was plausible, internally
101
+ * consistent, and wrong — this codebase's signature failure, in the one place an
102
+ * operator reads before authorising a destructive act.
103
+ *
104
+ * The count cannot be inferred from `blockers`: a guard that finds nothing still
105
+ * reports zero protected records, and a REMOVING line can carry a blocker too.
106
+ * The line has to say which quantity it is.
107
+ */
108
+ type CleanupPlanItemDisposition = "remove" | "protect" | "rebuild";
60
109
  /** One logical line in the preview — a business record class, never a collection. */
61
110
  interface CleanupPlanItem {
111
+ /**
112
+ * The contributing step, when the recipe is composed from steps.
113
+ *
114
+ * Without it the exclusion list is enforceable but not DISCOVERABLE: a UI
115
+ * showing `resource` labels has no id to send, so the capability exists and
116
+ * nothing can reach it. Absent for a recipe that is not step-composed.
117
+ */
118
+ readonly stepId?: string | undefined;
62
119
  /** Logical module / resource label, e.g. `'orders'`, `'journal entries'`. */
63
120
  readonly resource: string;
64
121
  /** Estimated records affected. */
65
122
  readonly estimated: number;
123
+ /**
124
+ * Whether `estimated` counts records this line REMOVES, PROTECTS, or REBUILDS.
125
+ * Defaults to `'remove'` — only a line that does something else must say so.
126
+ */
127
+ readonly disposition?: CleanupPlanItemDisposition | undefined;
128
+ /**
129
+ * The operator excluded this line from the run.
130
+ *
131
+ * It still appears in the plan — showing what was left out is the point; a
132
+ * line that vanishes is indistinguishable from one that was never in scope.
133
+ * Its `estimated` is kept out of both totals, and at execute time the step is
134
+ * reported `skipped` with the reason rather than silently not run.
135
+ */
136
+ readonly excluded?: boolean | undefined;
66
137
  /** What is retained for this line (e.g. `'measures kept, PII redacted'`). */
67
138
  readonly retained?: string | undefined;
68
139
  /** Domain blockers preventing this line (e.g. `'OPEN_TRANSFER'`). */
@@ -101,7 +172,26 @@ interface CleanupPlan {
101
172
  readonly blockers: readonly string[];
102
173
  readonly rebuildActions: readonly string[];
103
174
  readonly warnings: readonly string[];
175
+ /**
176
+ * Records this plan would REMOVE — the headline an operator authorises against.
177
+ *
178
+ * Counts only `disposition: 'remove'` lines. It used to sum every line, so a
179
+ * protective guard's count landed in the removal total (see
180
+ * {@link CleanupPlanItemDisposition}).
181
+ */
104
182
  readonly estimatedTotal: number;
183
+ /**
184
+ * Records a guard step is DEFENDING in this plan, reported separately so it
185
+ * can be shown as reassurance rather than as damage. Zero when no line
186
+ * protects anything.
187
+ */
188
+ readonly protectedTotal: number;
189
+ /**
190
+ * Step ids the operator left out, SEALED. re-resolves from here,
191
+ * never from a fresh caller input, so a run cannot be widened past what was
192
+ * previewed and confirmed.
193
+ */
194
+ readonly excludeSteps: readonly string[];
105
195
  readonly confirmationPhrase: string;
106
196
  /** Deterministic checksum of the plan's material content — see `computePlanDigest`. */
107
197
  readonly digest: string;
@@ -122,11 +212,64 @@ interface CleanupStepResult {
122
212
  * fixed-size aggregate, never an unbounded per-chunk array. Detailed steps, if a
123
213
  * host wants them, go to a separate capped sink — not this document.
124
214
  */
215
+ /**
216
+ * One step's lifecycle within a run.
217
+ *
218
+ * `skipped` and `failed` are DISTINCT from each other and from `completed`,
219
+ * because collapsing them is what makes a long destructive run unreadable: an
220
+ * operator watching "1,204 processed" cannot tell whether accounting ran, was
221
+ * deliberately not applicable, or blew up and left the rest half-done.
222
+ */
223
+ type CleanupStepRunStatus = "pending" | "running" | "completed" | "skipped" | "failed";
224
+ /**
225
+ * Per-step progress — the readable half of a run.
226
+ *
227
+ * The conventional shape is one FIXED COLUMN per phase, each holding
228
+ * `Pending | Completed | Skipped`. That works for a fixed pipeline and breaks
229
+ * the moment the pipeline is composed: adding a phase means a schema migration,
230
+ * and a recipe assembled from contributed steps has no fixed phase list at all.
231
+ *
232
+ * So this is a bounded LIST keyed by step id rather than columns. Two further
233
+ * properties, both deliberate:
234
+ *
235
+ * - a `Skipped` with no reason is unreadable — "nothing to do" and
236
+ * "deliberately excluded" are opposite facts, and a bare status enum cannot
237
+ * tell them apart. {@link detail} is REQUIRED for `skipped` and `failed`.
238
+ * - per-step `processed` and timings, so a stalled step is visible while it is
239
+ * still running instead of after the run ends.
240
+ *
241
+ * Bounded by construction: one entry per step in the SEALED plan, and the plan
242
+ * is already capped at `maxPlanItems`. This is not the unbounded per-chunk array
243
+ * the progress summary exists to avoid.
244
+ */
245
+ interface CleanupStepProgress {
246
+ /** Stable id of the contributing step — survives relabelling of `resource`. */
247
+ readonly stepId: string;
248
+ /** Human-facing record class, e.g. `'journal entries'`. */
249
+ readonly resource: string;
250
+ readonly status: CleanupStepRunStatus;
251
+ /** Records this step has processed so far. */
252
+ readonly processed: number;
253
+ readonly startedAt?: Date | undefined;
254
+ readonly completedAt?: Date | undefined;
255
+ /**
256
+ * WHY, for any non-`completed` terminal state. Required for `skipped` and
257
+ * `failed`: an unexplained non-completion is the thing this field exists to
258
+ * prevent.
259
+ */
260
+ readonly detail?: string | undefined;
261
+ }
125
262
  interface CleanupProgressSummary {
126
263
  /** Running total of processed records across all steps. */
127
264
  readonly processed: number;
128
265
  /** Count of steps reported so far. */
129
266
  readonly steps: number;
267
+ /**
268
+ * Per-step lifecycle. Bounded by the sealed plan's step count — see
269
+ * {@link CleanupStepProgress}. Absent on runs recorded before this existed,
270
+ * so a reader must treat it as optional rather than assume an empty run.
271
+ */
272
+ readonly stepProgress?: readonly CleanupStepProgress[] | undefined;
130
273
  /** Resource the last step touched. */
131
274
  readonly currentResource?: string | undefined;
132
275
  /** Last resume cursor reported. */
@@ -448,4 +591,4 @@ interface CleanupLimits {
448
591
  }
449
592
  declare const DEFAULT_CLEANUP_LIMITS: CleanupLimits;
450
593
  //#endregion
451
- export { CleanupWriteFence as A, CleanupResult as C, CleanupRunStore as D, CleanupRunStatus as E, PurgeStrategyKind$1 as F, PurgeVerificationSummary as I, VerificationCheck as L, PurgeActor as M, PurgeEvidence as N, CleanupRunTransitionPatch as O, PurgeResourceResult as P, VerificationResult as R, CleanupRecipe as S, CleanupRunCreateResult as T, CleanupPermissions as _, CleanupEvidenceStore as a, CleanupPlanItem as b, CleanupInput as c, CleanupLease as d, CleanupLimits as f, CleanupPermissionCheck as g, CleanupOutcomeStatus as h, CleanupContext as i, DEFAULT_CLEANUP_LIMITS as j, CleanupStepResult as k, CleanupJob as l, CleanupManifest as m, CLEANUP_TERMINAL_STATUSES as n, CleanupExecutionContext as o, CleanupLogger as p, CleanupCancelRequest as r, CleanupFinalizationPayload as s, Availability as t, CleanupJobQueue as u, CleanupPlan as v, CleanupRun as w, CleanupProgressSummary as x, CleanupPlanDraft as y };
594
+ export { CleanupStepResult as A, VerificationResult as B, CleanupResult as C, CleanupRunStore as D, CleanupRunStatus as E, PurgeEvidence as F, PurgeResourceResult as I, PurgeStrategyKind$1 as L, CleanupWriteFence as M, DEFAULT_CLEANUP_LIMITS as N, CleanupRunTransitionPatch as O, PurgeActor as P, PurgeVerificationSummary as R, CleanupRecipe as S, CleanupRunCreateResult as T, CleanupPermissions as _, CleanupEvidenceStore as a, CleanupPlanItem as b, CleanupInput as c, CleanupLease as d, CleanupLimits as f, CleanupPermissionCheck as g, CleanupOutcomeStatus as h, CleanupContext as i, CleanupStepRunStatus as j, CleanupStepProgress as k, CleanupJob as l, CleanupManifest as m, CLEANUP_TERMINAL_STATUSES as n, CleanupExecutionContext as o, CleanupLogger as p, CleanupCancelRequest as r, CleanupFinalizationPayload as s, Availability as t, CleanupJobQueue as u, CleanupPlan as v, CleanupRun as w, CleanupProgressSummary as x, CleanupPlanDraft as y, VerificationCheck as z };
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { i as RequestScope } from "../types-ChuShpCP.mjs";
3
- import { i as PermissionContext, r as PermissionCheck } from "../types-B7XeLEgK.mjs";
3
+ import { l as PermissionCheck, u as PermissionContext } from "../base-Csjc2oF-.mjs";
4
4
  import { UsageBucket, UsageStore, usagePeriod } from "@classytic/repo-core/usage";
5
5
  import { FastifyPluginAsync, FastifyRequest } from "fastify";
6
6
  //#region src/usage/requireQuota.d.ts
Binary file
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  //#region src/utils/userHelpers.ts
3
3
  /**
4
4
  * Extract a user ID from a user object. Accepts `id` or `_id` — returns
@@ -1,8 +1,8 @@
1
1
 
2
- import { $ as OpenApiSchemas, S as QueryParserInterface, b as ParsedQuery } from "../index-CpzxqePp.mjs";
3
2
  import { F as getHeader, I as requireSingleHeaderValue, P as ArcHeaders } from "../types-ChuShpCP.mjs";
4
- import { c as normalizeRoles, l as AnyRecord, o as getUserId, s as getUserRoles } from "../types-B7XeLEgK.mjs";
5
- import { n as ErrorMapper } from "../errorHandler-CpYUJmPA.mjs";
3
+ import { f as getUserId, m as normalizeRoles, p as getUserRoles, t as AnyRecord } from "../base-Csjc2oF-.mjs";
4
+ import { $ as OpenApiSchemas, S as QueryParserInterface, b as ParsedQuery } from "../index-BcR2bFZQ.mjs";
5
+ import { n as ErrorMapper } from "../errorHandler-DI5AN2b5.mjs";
6
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
7
  import { errorContractSchema, errorDetailSchema } from "@classytic/repo-core/errors";
8
8
  import { scheduleBackground } from "@classytic/repo-core/cache";
@@ -478,6 +478,29 @@ interface ArcQueryParserOptions {
478
478
  * Also used by MCP to auto-derive filterable fields in tool schemas.
479
479
  */
480
480
  allowedFilterFields?: string[];
481
+ /**
482
+ * REFUSE a filter key that is not in {@link allowedFilterFields}, instead of
483
+ * dropping it (default: `false` — today's drop behaviour, kept because arc
484
+ * is published and an unconditional throw would reject requests that work).
485
+ *
486
+ * Dropping a filter does not fail, it **WIDENS**: the caller asked for a
487
+ * narrower set and is silently answered with a broader one, HTTP 200. Two
488
+ * live instances:
489
+ *
490
+ * `?filters[status]=pending` → 200, every row `status:"verified"`
491
+ * `?productId=…` (the param is `skuRef`) → a different product's 75 units,
492
+ * filed for weeks as "quant leakage"
493
+ *
494
+ * Turn this on per-parser, or fleet-wide via `ARC_STRICT_QUERY_PARAMS`.
495
+ * Mirrors the `ARC_STRICT_PERMISSIONS` precedent: off by default here, and
496
+ * the HOST opts in from its env-loader so a forgotten `.env` line cannot
497
+ * silently disable enforcement.
498
+ *
499
+ * Only the FILTER whitelist is covered. `allowedSortFields` /
500
+ * `allowedOperators` keep dropping: a rejected sort or operator degrades
501
+ * ordering, it does not widen the row set.
502
+ */
503
+ strictFilterFields?: boolean;
481
504
  /**
482
505
  * Whitelist of fields that can be sorted on.
483
506
  * When set, sort fields not in this list are silently dropped.
@@ -527,7 +550,12 @@ interface ArcQueryParserOptions {
527
550
  * For advanced MongoDB features ($lookup, aggregations), use MongoKit's QueryParser.
528
551
  */
529
552
  declare class ArcQueryParser implements QueryParserInterface {
530
- private readonly maxLimit;
553
+ /**
554
+ * PUBLIC, deliberately: `QueryResolver` reads it so it does not apply a second cap
555
+ * on top of this one. Three layers capping independently, lowest winning silently,
556
+ * is what made a 696-row chart of accounts render as 100.
557
+ */
558
+ readonly maxLimit: number;
531
559
  private readonly defaultLimit;
532
560
  private readonly maxRegexLength;
533
561
  private readonly maxSearchLength;
@@ -535,6 +563,7 @@ declare class ArcQueryParser implements QueryParserInterface {
535
563
  private readonly _allowedFilterFields?;
536
564
  private readonly _allowedSortFields?;
537
565
  private readonly _allowedOperators?;
566
+ private readonly strictFilterFields;
538
567
  /** Allowed filter fields (used by MCP for auto-derive) */
539
568
  readonly allowedFilterFields?: readonly string[];
540
569
  /** Allowed sort fields (used by MCP for sort descriptions) */
@@ -1105,6 +1134,29 @@ declare function getListQueryParams(): AnyRecord;
1105
1134
  */
1106
1135
  declare function getDefaultCrudSchemas(): Record<string, Record<string, unknown>>;
1107
1136
  //#endregion
1137
+ //#region src/utils/runtimeCapabilities.d.ts
1138
+ /** What a subsystem declares about the state it holds. */
1139
+ interface RuntimeCapabilityDeclaration {
1140
+ /** Dotted subsystem id, e.g. `'webhooks.subscriptions'`, `'events.transport'`. */
1141
+ subsystem: string;
1142
+ /** Where the state lives: `'memory'` = this process only; `'shared'` = external/durable. */
1143
+ durability: "memory" | "shared";
1144
+ /**
1145
+ * `'memory'` durability that is CORRECT by design (per-process micro-cache,
1146
+ * declared single-process topology). Audited as info, never an error —
1147
+ * acceptance must be stated by the declarant, not inferred by the audit.
1148
+ */
1149
+ accepted?: boolean;
1150
+ /** One line for the audit output: what breaks multi-replica, or why accepted. */
1151
+ detail?: string;
1152
+ }
1153
+ /**
1154
+ * Declare a runtime capability. Callable from ANY registration context —
1155
+ * arc's own plugins, host `plugins()` callbacks, module `plugins` phases —
1156
+ * which is the point: the audit sees what the constructor-time guard cannot.
1157
+ */
1158
+ declare function declareRuntimeCapability(fastify: FastifyInstance, decl: RuntimeCapabilityDeclaration): void;
1159
+ //#endregion
1108
1160
  //#region src/utils/schemaConverter.d.ts
1109
1161
  /**
1110
1162
  * Supported JSON Schema output targets for Zod v4's `toJSONSchema()`.
@@ -1514,4 +1566,4 @@ declare function hasEvents(instance: FastifyInstance): instance is FastifyInstan
1514
1566
  events: EventsDecorator;
1515
1567
  };
1516
1568
  //#endregion
1517
- export { ArcError, type ArcHeaders, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, 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, 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, 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 };
1569
+ export { ArcError, type ArcHeaders, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, 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, 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 };
@@ -1,11 +1,12 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { a as OrgAccessDeniedError, c as ServiceUnavailableError, d as createDomainError, f as createError, i as NotFoundError, l as UnauthorizedError, n as ConflictError, o as OrgRequiredError, p as isArcError, r as ForbiddenError, s as RateLimitError, t as ArcError, u as ValidationError } from "../errors-Bh1KK5ps.mjs";
3
- import { n as requireSingleHeaderValue, t as getHeader } from "../headers-BXjQYbeC.mjs";
4
- import { n as getUserRoles, r as normalizeRoles, t as getUserId } from "../userHelpers-BNsOXzOd.mjs";
5
- import { t as simpleEqualityMatcher } from "../simpleEqualityMatcher-C4KiMWUa.mjs";
6
- import { A as createCircuitBreakerRegistry, C as defineCompensation, D as CircuitBreakerRegistry, E as CircuitBreakerError, O as CircuitState, S as defineErrorMapper, T as CircuitBreaker, _ as createQueryParser, a as deleteResponse, b as NEUTRAL_DIALECT, c as getDefaultCrudSchemas, d as listResponse, f as offsetListResponse, g as ArcQueryParser, h as responses, i as bareListResponse, k as createCircuitBreaker, l as getListQueryParams, m as queryParams, n as scheduleBackground, o as errorContractSchema, p as paginationSchema, r as aggregateListResponse, s as errorDetailSchema, t as createStateMachine, u as keysetListResponse, v as handleRaw, w as withCompensation, x as defineGuard, y as MONGO_DIALECT } from "../utils-BtOha_Sp.mjs";
7
- import { a as isZodSchema, i as isJsonSchema, n as convertRouteSchema, o as toJsonSchema, t as convertOpenApiSchemas } from "../schemaConverter-Crjvczi_.mjs";
8
- import { a as promoteStreamTokenToHeader, i as pipeUIMessageStreamToReply, n as forwardedStreamHeaders, r as isReadableStream, t as UI_MESSAGE_STREAM_HEADERS } from "../streaming-DPZdQmDz.mjs";
9
- import { t as openSseStream } from "../sseStream-B3zb_d1h.mjs";
10
- import { t as hasEvents } from "../typeGuards-B_5-hKjJ.mjs";
11
- export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, 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 };
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { a as OrgAccessDeniedError, c as ServiceUnavailableError, d as createDomainError, f as createError, i as NotFoundError, l as UnauthorizedError, n as ConflictError, o as OrgRequiredError, p as isArcError, r as ForbiddenError, s as RateLimitError, t as ArcError, u as ValidationError } from "../errors-Cd_yy7aW.mjs";
3
+ import { n as requireSingleHeaderValue, t as getHeader } from "../headers-CveNO9gR.mjs";
4
+ import { n as getUserRoles, r as normalizeRoles, t as getUserId } from "../userHelpers-CWF5pbZD.mjs";
5
+ import { t as simpleEqualityMatcher } from "../simpleEqualityMatcher-Se8VrsaP.mjs";
6
+ import { A as createCircuitBreakerRegistry, C as defineCompensation, D as CircuitBreakerRegistry, E as CircuitBreakerError, O as CircuitState, S as defineErrorMapper, T as CircuitBreaker, _ as createQueryParser, a as deleteResponse, b as NEUTRAL_DIALECT, c as getDefaultCrudSchemas, d as listResponse, f as offsetListResponse, g as ArcQueryParser, h as responses, i as bareListResponse, k as createCircuitBreaker, l as getListQueryParams, m as queryParams, n as scheduleBackground, o as errorContractSchema, p as paginationSchema, r as aggregateListResponse, s as errorDetailSchema, t as createStateMachine, u as keysetListResponse, v as handleRaw, w as withCompensation, x as defineGuard, y as MONGO_DIALECT } from "../utils-h1V_sT-t.mjs";
7
+ import { n as declareRuntimeCapability } from "../runtimeCapabilities-Dm88DaTW.mjs";
8
+ import { a as isZodSchema, i as isJsonSchema, n as convertRouteSchema, o as toJsonSchema, t as convertOpenApiSchemas } from "../schemaConverter-XH1RZRyu.mjs";
9
+ import { a as promoteStreamTokenToHeader, i as pipeUIMessageStreamToReply, n as forwardedStreamHeaders, r as isReadableStream, t as UI_MESSAGE_STREAM_HEADERS } from "../streaming-DsT1B5zJ.mjs";
10
+ import { t as openSseStream } from "../sseStream-Bvpi-UXQ.mjs";
11
+ import { t as hasEvents } from "../typeGuards-jjKJDN13.mjs";
12
+ export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, 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 };