@classytic/arc 2.38.0 → 2.40.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 (183) hide show
  1. package/dist/{BaseController-CYaDvmOB.mjs → BaseController-BqJtbiUA.mjs} +107 -23
  2. package/dist/{EventTransport-Cx60_s-6.d.mts → EventTransport-BPOQsEer.d.mts} +8 -0
  3. package/dist/{EventTransport-Gq7JWbWw.mjs → EventTransport-BUkTwY_x.mjs} +13 -2
  4. package/dist/{HookSystem-C0ikzqQf.mjs → HookSystem-96nzZLmk.mjs} +2 -2
  5. package/dist/{ResourceRegistry-DPcX--zk.mjs → ResourceRegistry-B9WnuG2Q.mjs} +2 -2
  6. package/dist/{actionPermissions-jlFZ1it4.mjs → actionPermissions-4OGbe3Hf.mjs} +6 -6
  7. package/dist/audit/index.d.mts +1 -1
  8. package/dist/audit/index.mjs +2 -2
  9. package/dist/auth/audit.mjs +1 -1
  10. package/dist/auth/index.d.mts +1 -1
  11. package/dist/auth/index.mjs +6 -6
  12. package/dist/auth/redis-session.mjs +1 -1
  13. package/dist/{authorizationDecision-BP8GHtjc.mjs → authorizationDecision-D_LFvMlm.mjs} +2 -2
  14. package/dist/{buildHandler-DjXOqIvX.mjs → buildHandler-BG_CHXqQ.mjs} +4 -4
  15. package/dist/cache/index.mjs +4 -4
  16. package/dist/{caching-a3ZEcJJs.mjs → caching-Bqcn3Brl.mjs} +2 -2
  17. package/dist/cleanup/index.d.mts +2 -2
  18. package/dist/cleanup/index.mjs +21 -5
  19. package/dist/cli/commands/describe.d.mts +1 -1
  20. package/dist/cli/commands/describe.mjs +3 -3
  21. package/dist/cli/commands/docs.mjs +3 -3
  22. package/dist/cli/commands/doctor.mjs +1 -1
  23. package/dist/cli/commands/generate.mjs +2 -2
  24. package/dist/cli/commands/init.mjs +2 -2
  25. package/dist/cli/commands/introspect.mjs +2 -2
  26. package/dist/cli/index.mjs +3 -3
  27. package/dist/{constants-BONghE1Y.mjs → constants-BQ2FbhPB.mjs} +1 -1
  28. package/dist/context/index.d.mts +34 -6
  29. package/dist/context/index.mjs +12 -19
  30. package/dist/core/index.d.mts +2 -2
  31. package/dist/core/index.mjs +7 -7
  32. package/dist/{core-8She7FgF.mjs → core-CsZR037F.mjs} +3 -3
  33. package/dist/{createActionRouter-Bqi6Bhhx.mjs → createActionRouter-BR93gCKg.mjs} +7 -7
  34. package/dist/{createAggregationRouter-BsYO7ktd.mjs → createAggregationRouter-CF40Aw95.mjs} +7 -7
  35. package/dist/createMcpServer-BVTs2S5G.d.mts +48 -0
  36. package/dist/{defineAggregation-0KBvqEEC.mjs → defineAggregation-BDA2Tw7v.mjs} +1 -1
  37. package/dist/{defineResource-BMdyRelW.mjs → defineResource-DaIySrQr.mjs} +20 -22
  38. package/dist/discovery/index.mjs +1 -1
  39. package/dist/docs/index.d.mts +1 -1
  40. package/dist/docs/index.mjs +3 -3
  41. package/dist/{elevation-C6woysGC.mjs → elevation-CZy6n50b.mjs} +4 -4
  42. package/dist/encryption/index.mjs +3 -3
  43. package/dist/{errorHandler-DI5AN2b5.d.mts → errorHandler--4rSMMvq.d.mts} +7 -1
  44. package/dist/{errorHandler-BdmIWPba.mjs → errorHandler-By9keRvX.mjs} +3 -3
  45. package/dist/{errors-2ExmOgIJ.mjs → errors-BHD3L8of.mjs} +1 -1
  46. package/dist/{eventPlugin-DJwpGMzx.mjs → eventPlugin-DB26V7uX.mjs} +5 -5
  47. package/dist/{eventPlugin-DFvHa4Nf.d.mts → eventPlugin-DfHaKEWQ.d.mts} +1 -1
  48. package/dist/events/index.d.mts +4 -4
  49. package/dist/events/index.mjs +5 -5
  50. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  51. package/dist/events/transports/redis-stream-entry.mjs +21 -20
  52. package/dist/events/transports/redis.d.mts +1 -1
  53. package/dist/events/transports/redis.mjs +11 -8
  54. package/dist/factory/index.d.mts +4 -4
  55. package/dist/factory/index.mjs +5 -5
  56. package/dist/{fastify-augmentation-jYA2oHyL.d.mts → fastify-augmentation-HncZMmze.d.mts} +3 -3
  57. package/dist/{fields-Cha2QCKH.mjs → fields-fA-Dkou5.mjs} +1 -1
  58. package/dist/{generate-BUP4Oydg.mjs → generate-BSSdtiOy.mjs} +4 -3
  59. package/dist/{headers-DeXNifVj.mjs → headers-BFEEshDS.mjs} +2 -2
  60. package/dist/{health-Bh0N_FLk.mjs → health-BlGHjkqZ.mjs} +1 -1
  61. package/dist/hooks/index.d.mts +1 -1
  62. package/dist/hooks/index.mjs +2 -2
  63. package/dist/idempotency/index.mjs +4 -4
  64. package/dist/idempotency/redis.mjs +1 -1
  65. package/dist/{index-B78WZom8.d.mts → index-D3sIPcD4.d.mts} +47 -11
  66. package/dist/{index-D2uIUSQk.d.mts → index-DbMglURO.d.mts} +2 -2
  67. package/dist/{index-BRoDtjek.d.mts → index-SCsOJxWB.d.mts} +2 -2
  68. package/dist/index.d.mts +3 -3
  69. package/dist/index.mjs +11 -11
  70. package/dist/{init-Dg_Am2o_.mjs → init-pl88PHzb.mjs} +9 -9
  71. package/dist/integrations/event-gateway.d.mts +1 -1
  72. package/dist/integrations/event-gateway.mjs +2 -2
  73. package/dist/integrations/index.d.mts +1 -1
  74. package/dist/integrations/index.mjs +1 -1
  75. package/dist/integrations/jobs/index.mjs +2 -2
  76. package/dist/integrations/mcp/index.d.mts +3 -46
  77. package/dist/integrations/mcp/index.mjs +2 -2
  78. package/dist/integrations/mcp/testing.d.mts +22 -2
  79. package/dist/integrations/mcp/testing.mjs +55 -33
  80. package/dist/integrations/streamline.mjs +3 -3
  81. package/dist/integrations/webhooks.d.mts +2 -2
  82. package/dist/integrations/webhooks.mjs +3 -3
  83. package/dist/integrations/websocket-pushref-redis.mjs +1 -1
  84. package/dist/integrations/websocket-redis.mjs +1 -1
  85. package/dist/integrations/websocket.mjs +13 -6
  86. package/dist/{interface-DYPVscCU.mjs → interface-DjtFnZxH.mjs} +1 -1
  87. package/dist/{jsonBody-DVui0uJl.mjs → jsonBody-Dx6jH_Nb.mjs} +2 -2
  88. package/dist/{keys-BSuxGS-B.mjs → keys-Ds3ekBiu.mjs} +1 -1
  89. package/dist/{loadResources-CNd1DWnK.mjs → loadResources-E5UFlRrT.mjs} +2 -2
  90. package/dist/{loadResourcesFromEntry-DNj8cpiY.mjs → loadResourcesFromEntry-C2jrJbWG.mjs} +2 -2
  91. package/dist/logger/index.mjs +1 -1
  92. package/dist/{mcpPlugin-KWsezMx7.mjs → mcpPlugin-D-3OLxNz.mjs} +75 -31
  93. package/dist/{memory-BiPVaCPg.mjs → memory-CNvjxzB2.mjs} +2 -2
  94. package/dist/{metrics-CsWaIVTa.mjs → metrics-P37sNV5H.mjs} +2 -2
  95. package/dist/middleware/index.d.mts +1 -1
  96. package/dist/middleware/index.mjs +3 -3
  97. package/dist/migrations/index.mjs +2 -2
  98. package/dist/{module-BQXHxMEk.mjs → module-CNcwCKUJ.mjs} +1 -1
  99. package/dist/{multipartBody-u6VrS_iH.mjs → multipartBody-Bl_gU3Wg.mjs} +1 -1
  100. package/dist/{openapi-Dxc8RLy_.mjs → openapi-BYrL8zvY.mjs} +6 -6
  101. package/dist/outbox-admin/index.d.mts +1 -1
  102. package/dist/outbox-admin/index.mjs +4 -4
  103. package/dist/{outbox-module-DyIqA5vo.mjs → outbox-module-6DMC_WNu.mjs} +40 -21
  104. package/dist/{outbox-module-CQXu_O6o.d.mts → outbox-module-CzsKRBvO.d.mts} +11 -2
  105. package/dist/permissions/index.mjs +5 -5
  106. package/dist/{permissions-H7Zcb82Z.mjs → permissions-C0GpDsB_.mjs} +6 -6
  107. package/dist/{pipe-SunhEaZ6.mjs → pipe-4_XamfxI.mjs} +2 -2
  108. package/dist/pipeline/index.d.mts +1 -1
  109. package/dist/pipeline/index.mjs +2 -2
  110. package/dist/plugins/index.d.mts +5 -5
  111. package/dist/plugins/index.mjs +17 -16
  112. package/dist/plugins/response-cache.mjs +2 -2
  113. package/dist/plugins/tracing-entry.mjs +2 -2
  114. package/dist/{pluralize-Da7IT_qJ.mjs → pluralize-BaQ62hOW.mjs} +1 -1
  115. package/dist/{preloadResources-DlhH81py.mjs → preloadResources-BAx5s9EF.mjs} +70 -21
  116. package/dist/{preloadResources-BbBkNkqK.d.mts → preloadResources-DVgPCNcD.d.mts} +7 -7
  117. package/dist/presets/filesUpload.d.mts +1 -1
  118. package/dist/presets/filesUpload.mjs +5 -5
  119. package/dist/presets/index.d.mts +1 -1
  120. package/dist/presets/index.mjs +2 -2
  121. package/dist/presets/multiTenant.d.mts +1 -1
  122. package/dist/presets/multiTenant.mjs +3 -3
  123. package/dist/presets/search.d.mts +1 -1
  124. package/dist/presets/search.mjs +2 -2
  125. package/dist/{presets-CNyfaxGL.mjs → presets-CAaqVVcW.mjs} +4 -4
  126. package/dist/{projection-DSfEoooA.mjs → projection-qbCOEvsh.mjs} +2 -2
  127. package/dist/{queryCachePlugin-oTsmVyEQ.mjs → queryCachePlugin-2Pp9w-8D.mjs} +5 -5
  128. package/dist/rateLimitKey-umrS6-vu.mjs +41 -0
  129. package/dist/{realtime-CPmjjgqd.mjs → realtime-zzoNLDtj.mjs} +9 -9
  130. package/dist/{redis-stream-eh0eOtjh.d.mts → redis-stream-DSsPyYzd.d.mts} +7 -2
  131. package/dist/{registerRoute-XvcI_3sh.mjs → registerRoute-_6zHiz0x.mjs} +6 -6
  132. package/dist/registry/index.d.mts +2 -2
  133. package/dist/registry/index.mjs +3 -3
  134. package/dist/{registry-UFEJQN8R.mjs → registry-CEpoRpLP.mjs} +2 -2
  135. package/dist/{renewingLease-DuRGVOMe.mjs → renewingLease-B5Grm0pI.mjs} +1 -1
  136. package/dist/{replyHelpers-BHebarf0.mjs → replyHelpers-9h-a592u.mjs} +2 -2
  137. package/dist/{requestContext-DpmntRZy.mjs → requestContext-D4PuGhEw.mjs} +1 -1
  138. package/dist/{rolldown-runtime-Add2L50I.mjs → rolldown-runtime-DzE6ikSH.mjs} +1 -1
  139. package/dist/{runtimeCapabilities-D793Pxci.mjs → runtimeCapabilities-Bo7rSKjm.mjs} +1 -1
  140. package/dist/{schedules-DthM8Qag.mjs → schedules-Dm21pqHU.mjs} +8 -4
  141. package/dist/{schemaConverter-Db-MMsH6.mjs → schemaConverter-DENbixyA.mjs} +1 -1
  142. package/dist/{schemaIR-CIXShch7.mjs → schemaIR-C2qUNzC6.mjs} +2 -2
  143. package/dist/schemas/index.mjs +1 -1
  144. package/dist/scim/index.mjs +2 -2
  145. package/dist/scope/index.mjs +5 -5
  146. package/dist/{scope-D03sk17n.mjs → scope-CdYxQVxt.mjs} +4 -4
  147. package/dist/{simpleEqualityMatcher-B7qVjQBv.mjs → simpleEqualityMatcher-Cldubvul.mjs} +1 -1
  148. package/dist/{sse-D4MYqkic.mjs → sse-DbyXoQun.mjs} +5 -5
  149. package/dist/{sseStream-BuMNPR6r.mjs → sseStream-BfZtL5-m.mjs} +2 -2
  150. package/dist/{store-helpers-CIF4RG8s.mjs → store-helpers-BfyOd5i6.mjs} +1 -1
  151. package/dist/{streaming-DkpW1HwJ.mjs → streaming-CFwCzEvU.mjs} +1 -1
  152. package/dist/{subscribe-helpers-CBZOi6pk.mjs → subscribe-helpers-KgVEcn8L.mjs} +2 -2
  153. package/dist/sync/changelog.mjs +1 -1
  154. package/dist/testing/cleanupStoreContract.mjs +1 -1
  155. package/dist/testing/index.d.mts +4 -4
  156. package/dist/testing/index.mjs +10 -10
  157. package/dist/testing/outboxStoreContract.mjs +14 -3
  158. package/dist/testing/storageContract.mjs +1 -1
  159. package/dist/{transactionContext-DMmvcfdo.mjs → transactionContext-46KyUADP.mjs} +1 -1
  160. package/dist/{typeGuards-DHTnEs5X.mjs → typeGuards-t_CVgRXN.mjs} +1 -1
  161. package/dist/types/index.d.mts +1 -1
  162. package/dist/types/index.mjs +1 -1
  163. package/dist/types/storage.mjs +1 -1
  164. package/dist/{types-LQFwC37d.d.mts → types-9rvxn5Ym.d.mts} +46 -1
  165. package/dist/{types-BRU-Kd3t.d.mts → types-BVlowlm7.d.mts} +2 -2
  166. package/dist/{types-BqLyyH0o.mjs → types-CNQyOrLk.mjs} +4 -4
  167. package/dist/usage/index.mjs +0 -0
  168. package/dist/{userHelpers-CXySQFRg.mjs → userHelpers-DLueLQdQ.mjs} +1 -1
  169. package/dist/utils/index.d.mts +4 -4
  170. package/dist/utils/index.mjs +11 -11
  171. package/dist/{utils-BbGG8XNT.mjs → utils-CUFBrhq-.mjs} +14 -6
  172. package/dist/{validate-CidSeUrx.mjs → validate-DV3hRbsz.mjs} +2 -2
  173. package/dist/{versioning-C2r0eOZ4.mjs → versioning-BXwmj5SD.mjs} +3 -3
  174. package/dist/{versioning-B843jOYX.d.mts → versioning-P3V6ATyC.d.mts} +1 -1
  175. package/dist/workScope-CoGpuzDX.mjs +42 -0
  176. package/package.json +48 -39
  177. package/skills/arc/references/mcp.md +20 -0
  178. package/skills/arc/references/testing.md +0 -12
  179. package/skills/arc-code-review/references/anti-patterns.md +1 -1
  180. package/skills/arc-code-review/references/migration-recipes.md +0 -60
  181. package/skills/arc-code-review/references/mongokit-migration.md +0 -27
  182. package/skills/arc-module-publishing/references/package-manifest.md +3 -1
  183. package/dist/rateLimitKey-CewdR-m6.mjs +0 -15
@@ -1,12 +1,10 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as transactionContext } from "../transactionContext-DMmvcfdo.mjs";
3
- import { n as requestContext, t as getTraceHeaders } from "../requestContext-DpmntRZy.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as transactionContext } from "../transactionContext-46KyUADP.mjs";
3
+ import { n as requestContext, t as getTraceHeaders } from "../requestContext-D4PuGhEw.mjs";
4
+ import { n as scopedValue, r as workSeedFromEvent, t as runWorkScope } from "../workScope-CoGpuzDX.mjs";
4
5
  //#region src/context/requestScopedCache.ts
5
- /**
6
- * The slot the per-request store hangs off. Underscore-prefixed to sit apart
7
- * from the fields arc's own hooks populate on `RequestStore`.
8
- */
9
- const SLOT = "_requestCache";
6
+ /** The memo slot the per-scope store hangs off. */
7
+ const SLOT = Symbol.for("arc.requestScopedCache");
10
8
  /**
11
9
  * A `Map`-backed `CacheAdapter` with NO eviction and NO TTL — both deliberate.
12
10
  *
@@ -39,26 +37,21 @@ function createRequestCacheAdapter() {
39
37
  };
40
38
  }
41
39
  /**
42
- * The cache for the CURRENT request, or `undefined` outside one.
40
+ * The cache for the CURRENT unit of work — a request, an event dispatch or a
41
+ * job run (see `runWorkScope`) — or `undefined` outside one.
43
42
  *
44
- * Lazily created on first use, so a request that never touches a cached
43
+ * Lazily created on first use, so a scope that never touches a cached
45
44
  * repository allocates nothing.
46
45
  */
47
46
  function requestScopedCache() {
48
- const store = requestContext.get();
49
- if (!store) return void 0;
50
- const existing = store[SLOT];
51
- if (existing) return existing;
52
- const created = createRequestCacheAdapter();
53
- store[SLOT] = created;
54
- return created;
47
+ return scopedValue(SLOT, createRequestCacheAdapter);
55
48
  }
56
49
  /**
57
- * Whether the current request has allocated a cache yet. Diagnostics and
50
+ * Whether the current scope has allocated a cache yet. Diagnostics and
58
51
  * tests only — never branch application behaviour on this.
59
52
  */
60
53
  function hasRequestScopedCache() {
61
54
  return requestContext.get()?.[SLOT] !== void 0;
62
55
  }
63
56
  //#endregion
64
- export { getTraceHeaders, hasRequestScopedCache, requestContext, requestScopedCache, transactionContext };
57
+ export { getTraceHeaders, hasRequestScopedCache, requestContext, requestScopedCache, runWorkScope, scopedValue, transactionContext, workSeedFromEvent };
@@ -1,4 +1,4 @@
1
1
 
2
- import { $t as AccessControlConfig, B as defineResource, Bt as BaseController, Cn as ControllerConstructionOptions, En as BodySanitizerConfig, Gt as SlugExt, Ht as SoftDeleteMixin, Jt as BulkMixin, Kt as SlugMixin, Qt as AccessControl, Sn as ControllerConfigurableOptions, Tn as BodySanitizer, Ut as TreeExt, V as ResourceDefinition, Vt as SoftDeleteExt, Wt as TreeMixin, Xt as QueryResolver, Yt as BaseCrudController, Zt as QueryResolverConfig, ct as AggMeasureShorthand, dt as AggregationDateRangeRequirement, ft as AggregationIndexHint, gt as AggregationsMap, ht as AggregationRateLimit, lt as AggregationCacheConfig, mt as AggregationMaterializedResult, pt as AggregationMaterializedContext, qt as BulkExt, st as AggMeasureInput, ut as AggregationConfig, wn as ListResult, xn as BaseControllerOptions } from "../index-B78WZom8.mjs";
3
- import { A as CRUD_OPERATIONS, B as HookOperation, C as SeamedResourceConfig, D as createCrudRouter, E as defineAction, F as DEFAULT_SORT, G as MUTATION_OPERATIONS, H as MAX_FILTER_DEPTH, I as DEFAULT_TENANT_FIELD, J as SYSTEM_FIELDS, K as MutationOperation, L as DEFAULT_UPDATE_METHOD, M as DEFAULT_ID_FIELD, N as DEFAULT_LIMIT, O as createPermissionMiddleware, P as DEFAULT_MAX_LIMIT, R as HOOK_OPERATIONS, S as ResourceSeams, T as DefineActionConfig, U as MAX_REGEX_LENGTH, V as HookPhase, W as MAX_SEARCH_LENGTH, _ as getEntityId, a as formatValidationErrors, b as defineResourceVariants, c as nativePolicyFilter, d as createCrudHandlers, f as createFastifyHandler, g as sendControllerResponse, h as getControllerScope, i as assertValidConfig, j as CrudOperation, k as defineAggregation, l as collectReadBlockedFields, m as getControllerContext, n as ValidateOptions, o as validateResourceConfig, p as createRequestContext, q as RESERVED_QUERY_PARAMS, r as ValidationResult, s as NativePolicyFilter, t as ConfigError, u as isFieldReadable, v as getEntityIdField, w as mergeResourceConfig, x as AdapterLike, y as getEntityQuery, z as HOOK_PHASES } from "../index-BRoDtjek.mjs";
2
+ import { $t as AccessControlConfig, B as defineResource, Bt as BaseController, Cn as ControllerConstructionOptions, En as BodySanitizerConfig, Gt as SlugExt, Ht as SoftDeleteMixin, Jt as BulkMixin, Kt as SlugMixin, Qt as AccessControl, Sn as ControllerConfigurableOptions, Tn as BodySanitizer, Ut as TreeExt, V as ResourceDefinition, Vt as SoftDeleteExt, Wt as TreeMixin, Xt as QueryResolver, Yt as BaseCrudController, Zt as QueryResolverConfig, ct as AggMeasureShorthand, dt as AggregationDateRangeRequirement, ft as AggregationIndexHint, gt as AggregationsMap, ht as AggregationRateLimit, lt as AggregationCacheConfig, mt as AggregationMaterializedResult, pt as AggregationMaterializedContext, qt as BulkExt, st as AggMeasureInput, ut as AggregationConfig, wn as ListResult, xn as BaseControllerOptions } from "../index-D3sIPcD4.mjs";
3
+ import { A as CRUD_OPERATIONS, B as HookOperation, C as SeamedResourceConfig, D as createCrudRouter, E as defineAction, F as DEFAULT_SORT, G as MUTATION_OPERATIONS, H as MAX_FILTER_DEPTH, I as DEFAULT_TENANT_FIELD, J as SYSTEM_FIELDS, K as MutationOperation, L as DEFAULT_UPDATE_METHOD, M as DEFAULT_ID_FIELD, N as DEFAULT_LIMIT, O as createPermissionMiddleware, P as DEFAULT_MAX_LIMIT, R as HOOK_OPERATIONS, S as ResourceSeams, T as DefineActionConfig, U as MAX_REGEX_LENGTH, V as HookPhase, W as MAX_SEARCH_LENGTH, _ as getEntityId, a as formatValidationErrors, b as defineResourceVariants, c as nativePolicyFilter, d as createCrudHandlers, f as createFastifyHandler, g as sendControllerResponse, h as getControllerScope, i as assertValidConfig, j as CrudOperation, k as defineAggregation, l as collectReadBlockedFields, m as getControllerContext, n as ValidateOptions, o as validateResourceConfig, p as createRequestContext, q as RESERVED_QUERY_PARAMS, r as ValidationResult, s as NativePolicyFilter, t as ConfigError, u as isFieldReadable, v as getEntityIdField, w as mergeResourceConfig, x as AdapterLike, y as getEntityQuery, z as HOOK_PHASES } from "../index-SCsOJxWB.mjs";
4
4
  export { AccessControl, type AccessControlConfig, type AdapterLike, type AggMeasureInput, type AggMeasureShorthand, type AggregationCacheConfig, type AggregationConfig, type AggregationDateRangeRequirement, type AggregationIndexHint, type AggregationMaterializedContext, type AggregationMaterializedResult, type AggregationRateLimit, type AggregationsMap, BaseController, type BaseControllerOptions, BaseCrudController, BodySanitizer, type BodySanitizerConfig, type BulkExt, BulkMixin, CRUD_OPERATIONS, type ConfigError, type ControllerConfigurableOptions, type ControllerConstructionOptions, CrudOperation, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, type DefineActionConfig, HOOK_OPERATIONS, HOOK_PHASES, HookOperation, HookPhase, type ListResult, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, MutationOperation, type NativePolicyFilter, QueryResolver, type QueryResolverConfig, RESERVED_QUERY_PARAMS, ResourceDefinition, type ResourceSeams, SYSTEM_FIELDS, type SeamedResourceConfig, type SlugExt, SlugMixin, type SoftDeleteExt, SoftDeleteMixin, type TreeExt, TreeMixin, type ValidateOptions, type ValidationResult, assertValidConfig, collectReadBlockedFields, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineAction, defineAggregation, defineResource, defineResourceVariants, formatValidationErrors, getControllerContext, getControllerScope, getEntityId, getEntityIdField, getEntityQuery, isFieldReadable, mergeResourceConfig, nativePolicyFilter, sendControllerResponse, validateResourceConfig };
@@ -1,8 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { a as DEFAULT_SORT, c as HOOK_OPERATIONS, d as MAX_REGEX_LENGTH, f as MAX_SEARCH_LENGTH, h as SYSTEM_FIELDS, i as DEFAULT_MAX_LIMIT, l as HOOK_PHASES, m as RESERVED_QUERY_PARAMS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MUTATION_OPERATIONS, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as MAX_FILTER_DEPTH } from "../constants-BONghE1Y.mjs";
3
- import { a as BulkMixin, c as collectReadBlockedFields, f as BodySanitizer, h as nativePolicyFilter, i as SlugMixin, l as isFieldReadable, m as AccessControl, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, s as QueryResolver, t as BaseController } from "../BaseController-CYaDvmOB.mjs";
4
- import { t as defineAggregation } from "../defineAggregation-0KBvqEEC.mjs";
5
- import { a as createCrudHandlers, c as getControllerContext, l as getControllerScope, o as createFastifyHandler, s as createRequestContext, u as sendControllerResponse } from "../actionPermissions-jlFZ1it4.mjs";
6
- import { a as ResourceDefinition, i as validateResourceConfig, n as assertValidConfig, o as createCrudRouter, r as formatValidationErrors, s as createPermissionMiddleware, t as defineResource } from "../defineResource-BMdyRelW.mjs";
7
- import { a as mergeResourceConfig, i as defineResourceVariants, n as getEntityIdField, o as defineAction, r as getEntityQuery, t as getEntityId } from "../core-8She7FgF.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { a as DEFAULT_SORT, c as HOOK_OPERATIONS, d as MAX_REGEX_LENGTH, f as MAX_SEARCH_LENGTH, h as SYSTEM_FIELDS, i as DEFAULT_MAX_LIMIT, l as HOOK_PHASES, m as RESERVED_QUERY_PARAMS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MUTATION_OPERATIONS, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as MAX_FILTER_DEPTH } from "../constants-BQ2FbhPB.mjs";
3
+ import { a as BulkMixin, c as collectReadBlockedFields, f as BodySanitizer, h as nativePolicyFilter, i as SlugMixin, l as isFieldReadable, m as AccessControl, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, s as QueryResolver, t as BaseController } from "../BaseController-BqJtbiUA.mjs";
4
+ import { t as defineAggregation } from "../defineAggregation-BDA2Tw7v.mjs";
5
+ import { a as createCrudHandlers, c as getControllerContext, l as getControllerScope, o as createFastifyHandler, s as createRequestContext, u as sendControllerResponse } from "../actionPermissions-4OGbe3Hf.mjs";
6
+ import { a as ResourceDefinition, i as validateResourceConfig, n as assertValidConfig, o as createCrudRouter, r as formatValidationErrors, s as createPermissionMiddleware, t as defineResource } from "../defineResource-DaIySrQr.mjs";
7
+ import { a as mergeResourceConfig, i as defineResourceVariants, n as getEntityIdField, o as defineAction, r as getEntityQuery, t as getEntityId } from "../core-CsZR037F.mjs";
8
8
  export { AccessControl, BaseController, BaseCrudController, BodySanitizer, BulkMixin, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, QueryResolver, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, assertValidConfig, collectReadBlockedFields, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineAction, defineAggregation, defineResource, defineResourceVariants, formatValidationErrors, getControllerContext, getControllerScope, getEntityId, getEntityIdField, getEntityQuery, isFieldReadable, mergeResourceConfig, nativePolicyFilter, sendControllerResponse, validateResourceConfig };
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import "./constants-BONghE1Y.mjs";
3
- import { t as defineResource } from "./defineResource-BMdyRelW.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import "./constants-BQ2FbhPB.mjs";
3
+ import { t as defineResource } from "./defineResource-DaIySrQr.mjs";
4
4
  //#region src/core/defineAction.ts
5
5
  /**
6
6
  * Build an `ActionDefinition` with a typed handler. The literal schema
@@ -1,10 +1,10 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
3
- import "./constants-BONghE1Y.mjs";
4
- import { f as createError } from "./errors-2ExmOgIJ.mjs";
5
- import { i as resolvePipelineSteps, n as buildActionPipelineHandler, u as sendControllerResponse } from "./actionPermissions-jlFZ1it4.mjs";
6
- import { a as selectPluginMw, c as buildRouteHooks, f as buildAuthMiddlewareForPermissions, i as resolveRouterPluginMw, n as buildRateLimitConfig, o as buildActionPermissionMw, p as buildArcDecorator, r as buildRouteConfig, t as tryRegisterRoute, u as routeHookOptions } from "./registerRoute-XvcI_3sh.mjs";
7
- import { n as schemaIRToJsonSchemaBranch, t as normalizeSchemaIR } from "./schemaIR-CIXShch7.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DzE6ikSH.mjs";
3
+ import "./constants-BQ2FbhPB.mjs";
4
+ import { f as createError } from "./errors-BHD3L8of.mjs";
5
+ import { i as resolvePipelineSteps, n as buildActionPipelineHandler, u as sendControllerResponse } from "./actionPermissions-4OGbe3Hf.mjs";
6
+ import { a as selectPluginMw, c as buildRouteHooks, f as buildAuthMiddlewareForPermissions, i as resolveRouterPluginMw, n as buildRateLimitConfig, o as buildActionPermissionMw, p as buildArcDecorator, r as buildRouteConfig, t as tryRegisterRoute, u as routeHookOptions } from "./registerRoute-_6zHiz0x.mjs";
7
+ import { n as schemaIRToJsonSchemaBranch, t as normalizeSchemaIR } from "./schemaIR-C2qUNzC6.mjs";
8
8
  //#region src/core/createActionRouter.ts
9
9
  var createActionRouter_exports = /* @__PURE__ */ __exportAll({
10
10
  buildActionBodySchema: () => buildActionBodySchema,
@@ -1,10 +1,10 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { n as evaluateAndApplyPermission } from "./authorizationDecision-BP8GHtjc.mjs";
3
- import { f as createError } from "./errors-2ExmOgIJ.mjs";
4
- import { u as getRequestScope } from "./types-BqLyyH0o.mjs";
5
- import { a as selectPluginMw, c as buildRouteHooks, d as buildAuthMiddleware, i as resolveRouterPluginMw, n as buildRateLimitConfig, p as buildArcDecorator, u as routeHookOptions } from "./registerRoute-XvcI_3sh.mjs";
6
- import { n as validateAggregations } from "./validate-CidSeUrx.mjs";
7
- import { t as buildAggregationHandler } from "./buildHandler-DjXOqIvX.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { n as evaluateAndApplyPermission } from "./authorizationDecision-D_LFvMlm.mjs";
3
+ import { f as createError } from "./errors-BHD3L8of.mjs";
4
+ import { u as getRequestScope } from "./types-CNQyOrLk.mjs";
5
+ import { a as selectPluginMw, c as buildRouteHooks, d as buildAuthMiddleware, i as resolveRouterPluginMw, n as buildRateLimitConfig, p as buildArcDecorator, u as routeHookOptions } from "./registerRoute-_6zHiz0x.mjs";
6
+ import { n as validateAggregations } from "./validate-DV3hRbsz.mjs";
7
+ import { t as buildAggregationHandler } from "./buildHandler-BG_CHXqQ.mjs";
8
8
  //#region src/core/aggregation/createAggregationRouter.ts
9
9
  /**
10
10
  * Register one Fastify route per aggregation. No-op when the map is
@@ -0,0 +1,48 @@
1
+
2
+ import { _ as ToolDefinition, c as McpAuthResult, r as CreateMcpServerConfig } from "./types-9rvxn5Ym.mjs";
3
+ //#region src/integrations/mcp/createMcpServer.d.ts
4
+ /**
5
+ * Mutable auth ref — updated per-request by mcpPlugin.
6
+ * Tool handlers read from this to get the current request's auth context.
7
+ */
8
+ interface AuthRef {
9
+ current: McpAuthResult | null;
10
+ }
11
+ /**
12
+ * Create a configured MCP server from declarative config.
13
+ *
14
+ * @param config - Server name, version, tools, prompts
15
+ * @returns McpServer instance (not yet connected to a transport)
16
+ */
17
+ declare function createMcpServer(config: CreateMcpServerConfig, authRef?: AuthRef): Promise<McpServerInstance>;
18
+ /**
19
+ * Detect and resolve duplicate MCP tool names across the assembled tool list.
20
+ *
21
+ * Two outcomes:
22
+ *
23
+ * 1. **Auto-namespace** — when one tool's `source` carries a `preset:<name>`
24
+ * prefix and the other doesn't, the preset tool is renamed to
25
+ * `<presetName>_<originalName>` (e.g. softDelete's `restore_post`
26
+ * becomes `softdelete_restore_post` when the user defines
27
+ * `actions.restore`). The user's tool wins the canonical name because
28
+ * it's the more-specific intent.
29
+ *
30
+ * 2. **Typed throw** — every other collision (two user actions, two
31
+ * custom routes, two presets) raises `ArcError('arc.mcp.tool_name_collision')`
32
+ * naming both sources so the host's stack trace points at the
33
+ * resource definitions, not the MCP SDK internals.
34
+ *
35
+ * Exported for the testing harness so collision behaviour can be exercised
36
+ * without a full server boot.
37
+ */
38
+ declare function resolveToolCollisions(tools: readonly ToolDefinition[]): ToolDefinition[];
39
+ /** Minimal interface for McpServer — avoids hard SDK type dependency */
40
+ interface McpServerInstance {
41
+ connect: (transport: unknown) => Promise<void>;
42
+ registerTool: (name: string, config: Record<string, unknown>, handler: (input: Record<string, unknown>, extra: Record<string, unknown>) => unknown) => unknown;
43
+ registerPrompt: (name: string, config: Record<string, unknown>, handler: (args: Record<string, unknown>) => unknown) => void;
44
+ /** v2 name. v1 called this `resource()` — same four arguments. */
45
+ registerResource: (...args: unknown[]) => void;
46
+ }
47
+ //#endregion
48
+ export { resolveToolCollisions as i, McpServerInstance as n, createMcpServer as r, AuthRef as t };
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
2
  //#region src/core/aggregation/defineAggregation.ts
3
3
  /**
4
4
  * Declare a single resource aggregation. Exported configs flow into
@@ -1,20 +1,20 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { p as MUTATION_OPERATIONS, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS } from "./constants-BONghE1Y.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { p as MUTATION_OPERATIONS, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS } from "./constants-BQ2FbhPB.mjs";
3
3
  import { arcLog } from "./logger/index.mjs";
4
- import { r as ForbiddenError } from "./errors-2ExmOgIJ.mjs";
5
- import { n as getUserRoles } from "./userHelpers-CXySQFRg.mjs";
6
- import { b as isElevated, n as PUBLIC_SCOPE, x as isMember } from "./types-BqLyyH0o.mjs";
7
- import { d as isWriteVerbCapable, p as DEFAULT_FIELD_WRITE_DENIAL_POLICY, t as BaseController, u as detectOverriddenWriteSlots } from "./BaseController-CYaDvmOB.mjs";
8
- import { v as getDefaultCrudSchemas } from "./utils-BbGG8XNT.mjs";
9
- import { a as resolveEffectiveRoles, n as applyFieldWritePermissions } from "./fields-Cha2QCKH.mjs";
10
- import { n as convertRouteSchema, r as ensureSchemaConverter, t as convertOpenApiSchemas } from "./schemaConverter-Db-MMsH6.mjs";
11
- import { i as pipeUIMessageStreamToReply, r as isReadableStream } from "./streaming-DkpW1HwJ.mjs";
12
- import { a as createCrudHandlers, i as resolvePipelineSteps, o as createFastifyHandler, r as buildPipelineHandler, s as createRequestContext, t as resolveActionPermission } from "./actionPermissions-jlFZ1it4.mjs";
13
- import { a as selectPluginMw, c as buildRouteHooks, d as buildAuthMiddleware, i as resolveRouterPluginMw, l as resolveRoutePreHandlers, n as buildRateLimitConfig, p as buildArcDecorator, r as buildRouteConfig, s as buildCrudPermissionMw, t as tryRegisterRoute, u as routeHookOptions } from "./registerRoute-XvcI_3sh.mjs";
14
- import { t as hasEvents } from "./typeGuards-DHTnEs5X.mjs";
15
- import { B as requireAuth } from "./permissions-H7Zcb82Z.mjs";
16
- import { r as getAvailablePresets, t as applyPresets } from "./presets-CNyfaxGL.mjs";
17
- import { t as pluralize } from "./pluralize-Da7IT_qJ.mjs";
4
+ import { r as ForbiddenError } from "./errors-BHD3L8of.mjs";
5
+ import { n as getUserRoles } from "./userHelpers-DLueLQdQ.mjs";
6
+ import { b as isElevated, n as PUBLIC_SCOPE, x as isMember } from "./types-CNQyOrLk.mjs";
7
+ import { d as isWriteVerbCapable, p as DEFAULT_FIELD_WRITE_DENIAL_POLICY, t as BaseController, u as detectOverriddenWriteSlots } from "./BaseController-BqJtbiUA.mjs";
8
+ import { v as getDefaultCrudSchemas } from "./utils-CUFBrhq-.mjs";
9
+ import { a as resolveEffectiveRoles, n as applyFieldWritePermissions } from "./fields-fA-Dkou5.mjs";
10
+ import { n as convertRouteSchema, r as ensureSchemaConverter, t as convertOpenApiSchemas } from "./schemaConverter-DENbixyA.mjs";
11
+ import { i as pipeUIMessageStreamToReply, r as isReadableStream } from "./streaming-CFwCzEvU.mjs";
12
+ import { a as createCrudHandlers, i as resolvePipelineSteps, o as createFastifyHandler, r as buildPipelineHandler, s as createRequestContext, t as resolveActionPermission } from "./actionPermissions-4OGbe3Hf.mjs";
13
+ import { a as selectPluginMw, c as buildRouteHooks, d as buildAuthMiddleware, i as resolveRouterPluginMw, l as resolveRoutePreHandlers, n as buildRateLimitConfig, p as buildArcDecorator, r as buildRouteConfig, s as buildCrudPermissionMw, t as tryRegisterRoute, u as routeHookOptions } from "./registerRoute-_6zHiz0x.mjs";
14
+ import { t as hasEvents } from "./typeGuards-t_CVgRXN.mjs";
15
+ import { B as requireAuth } from "./permissions-C0GpDsB_.mjs";
16
+ import { r as getAvailablePresets, t as applyPresets } from "./presets-CAaqVVcW.mjs";
17
+ import { t as pluralize } from "./pluralize-BaQ62hOW.mjs";
18
18
  import { isReadOnlyRepo } from "@classytic/repo-core/repository";
19
19
  //#region src/core/middlewares/fieldWrite.ts
20
20
  /**
@@ -1425,7 +1425,7 @@ function buildResourcePlugin(resource) {
1425
1425
  extensions: resource.extensions
1426
1426
  });
1427
1427
  if (resource.actions && Object.keys(resource.actions).length > 0) {
1428
- const { createActionRouter } = await import("./createActionRouter-Bqi6Bhhx.mjs").then((n) => n.n);
1428
+ const { createActionRouter } = await import("./createActionRouter-BR93gCKg.mjs").then((n) => n.n);
1429
1429
  createActionRouter(typedInstance, {
1430
1430
  ...normalizeActionsToRouterConfig(resource.actions, resource.actionPermissions, resource.tag, resource.permissions, resource.name, typedInstance.log),
1431
1431
  resourceName: resource.name,
@@ -1440,7 +1440,7 @@ function buildResourcePlugin(resource) {
1440
1440
  });
1441
1441
  }
1442
1442
  if (resource.aggregations && Object.keys(resource.aggregations).length > 0) {
1443
- const [{ createAggregationRouter }, { adapterSupportsAggregate, ArcAggregationConfigError }] = await Promise.all([import("./createAggregationRouter-BsYO7ktd.mjs"), import("./validate-CidSeUrx.mjs").then((n) => n.r)]);
1443
+ const [{ createAggregationRouter }, { adapterSupportsAggregate, ArcAggregationConfigError }] = await Promise.all([import("./createAggregationRouter-CF40Aw95.mjs"), import("./validate-DV3hRbsz.mjs").then((n) => n.r)]);
1444
1444
  const repoForAgg = resource.controller?.repository ?? resource.repository;
1445
1445
  if (!adapterSupportsAggregate(repoForAgg)) {
1446
1446
  const undispatchable = Object.entries(resource.aggregations).filter(([, cfg]) => !cfg.materialized).map(([name]) => name);
@@ -2457,10 +2457,8 @@ function defineResource(config) {
2457
2457
  const configWithId = resolveIdField(normalisedConfig, repository);
2458
2458
  const resolvedConfig = applyPresetsAndAutoInject(configWithId);
2459
2459
  const hasCrudRoutes = computeHasCrudRoutes(resolvedConfig);
2460
- if (!normalisedConfig.skipValidation) {
2461
- const strict = resolvedConfig.strictPermissions ?? process.env.ARC_STRICT_PERMISSIONS === "true";
2462
- diagnostics = diagnostics.concat(collectUngatedCrudDiagnostics(resolvedConfig, strict));
2463
- }
2460
+ const strict = resolvedConfig.strictPermissions ?? process.env.ARC_STRICT_PERMISSIONS === "true";
2461
+ diagnostics = diagnostics.concat(collectUngatedCrudDiagnostics(resolvedConfig, strict));
2464
2462
  const fatal = diagnostics.filter((d) => d.severity === "error");
2465
2463
  if (fatal.length > 0) throw new Error(fatal.map((d) => d.message).join("\n\n"));
2466
2464
  const narrowedConfig = resolvedConfig;
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
2
  import { readdir } from "node:fs/promises";
3
3
  import { extname, join, resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
@@ -1,5 +1,5 @@
1
1
 
2
- import { p as RegistryEntry } from "../index-B78WZom8.mjs";
2
+ import { p as RegistryEntry } from "../index-D3sIPcD4.mjs";
3
3
  import { t as ExternalOpenApiPaths } from "../externalPaths-CmGOxOtD.mjs";
4
4
  import { FastifyPluginAsync } from "fastify";
5
5
  //#region src/docs/openapi/types.d.ts
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { n as getUserRoles } from "../userHelpers-CXySQFRg.mjs";
3
- import { n as openApiPlugin, r as openapi_default, t as buildOpenApiSpec } from "../openapi-Dxc8RLy_.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { n as getUserRoles } from "../userHelpers-DLueLQdQ.mjs";
3
+ import { n as openApiPlugin, r as openapi_default, t as buildOpenApiSpec } from "../openapi-BYrL8zvY.mjs";
4
4
  import fp from "fastify-plugin";
5
5
  //#region src/docs/scalar.ts
6
6
  const scalarPlugin = async (fastify, opts = {}) => {
@@ -1,8 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DzE6ikSH.mjs";
3
3
  import { arcLog } from "./logger/index.mjs";
4
- import { n as requireSingleHeaderValue } from "./headers-DeXNifVj.mjs";
5
- import { n as getUserRoles } from "./userHelpers-CXySQFRg.mjs";
4
+ import { n as requireSingleHeaderValue } from "./headers-BFEEshDS.mjs";
5
+ import { n as getUserRoles } from "./userHelpers-DLueLQdQ.mjs";
6
6
  import fp from "fastify-plugin";
7
7
  //#region src/scope/elevation.ts
8
8
  var elevation_exports = /* @__PURE__ */ __exportAll({
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as ArcError } from "../errors-2ExmOgIJ.mjs";
3
- import { t as parseJsonBody } from "../jsonBody-DVui0uJl.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as ArcError } from "../errors-BHD3L8of.mjs";
3
+ import { t as parseJsonBody } from "../jsonBody-Dx6jH_Nb.mjs";
4
4
  import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
5
5
  import fp from "fastify-plugin";
6
6
  //#region src/encryption/fieldCipher.ts
@@ -7,7 +7,13 @@ import { FastifyInstance, FastifyRequest } from "fastify";
7
7
  * to a partial `ErrorContract`. Highest-priority dispatch in the handler.
8
8
  */
9
9
  interface ErrorMapper<T extends Error = Error> {
10
- type: abstract new (...args: any[]) => T;
10
+ /**
11
+ * Only ever used as `error instanceof mapper.type` — the constructor is never
12
+ * CALLED through this interface, so `never[]` is the sound parameter type:
13
+ * every real class assigns to it (constructor parameters are contravariant),
14
+ * and nothing can invoke it. `any[]` here was a permission nothing used.
15
+ */
16
+ type: abstract new (...args: never[]) => T;
11
17
  toResponse: (error: T) => {
12
18
  status: number;
13
19
  code?: string;
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
3
- import { m as statusToArcCode, p as isArcError } from "./errors-2ExmOgIJ.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DzE6ikSH.mjs";
3
+ import { m as statusToArcCode, p as isArcError } from "./errors-BHD3L8of.mjs";
4
4
  import { isProductionEnv } from "@classytic/primitives/environment";
5
5
  import { isHttpError, toErrorContract } from "@classytic/repo-core/errors";
6
6
  import fp from "fastify-plugin";
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
2
  //#region src/utils/errors.ts
3
3
  /**
4
4
  * Base Arc Error. Implements the canonical `HttpError` contract — `status`
@@ -1,9 +1,9 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DzE6ikSH.mjs";
3
3
  import { arcLog } from "./logger/index.mjs";
4
- import { d as createDomainError } from "./errors-2ExmOgIJ.mjs";
5
- import { n as requestContext } from "./requestContext-DpmntRZy.mjs";
6
- import { n as MemoryEventTransport, r as createEvent, t as ARC_EVENT_TRANSPORT } from "./EventTransport-Gq7JWbWw.mjs";
4
+ import { d as createDomainError } from "./errors-BHD3L8of.mjs";
5
+ import { n as requestContext } from "./requestContext-D4PuGhEw.mjs";
6
+ import { n as MemoryEventTransport, r as createEvent, t as ARC_EVENT_TRANSPORT } from "./EventTransport-BUkTwY_x.mjs";
7
7
  import { isProductionEnv } from "@classytic/primitives/environment";
8
8
  import fp from "fastify-plugin";
9
9
  //#region src/events/retry.ts
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler, s as MemoryEventTransportOptions } from "./EventTransport-Cx60_s-6.mjs";
2
+ import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler, s as MemoryEventTransportOptions } from "./EventTransport-BPOQsEer.mjs";
3
3
  import { FastifyPluginAsync } from "fastify";
4
4
  //#region src/events/defineEvent.d.ts
5
5
  interface EventSchema {
@@ -1,9 +1,9 @@
1
1
 
2
- import { i as EventLogger, n as DomainEvent, o as MemoryEventTransport, r as EventHandler, s as MemoryEventTransportOptions } from "../EventTransport-Cx60_s-6.mjs";
3
- import { a as withRetry, c as EventDefinitionOutput, d as EventSchema, f as ValidationResult, i as createDeadLetterPublisher, l as EventRegistry, m as defineEvent, n as eventPlugin, o as CustomValidator, p as createEventRegistry, r as RetryOptions, s as EventDefinitionInput, t as EventPluginOptions, u as EventRegistryOptions } from "../eventPlugin-DFvHa4Nf.mjs";
4
- import { a as EventOutbox, c as OutboxRelayErrorKind, i as MemoryOutboxStore, l as RelayResult, n as OutboxModuleOptions, o as EventOutboxOptions, r as createOutboxModule, s as OutboxRelayErrorHandler, t as OutboxModuleExports } from "../outbox-module-CQXu_O6o.mjs";
2
+ import { i as EventLogger, n as DomainEvent, o as MemoryEventTransport, r as EventHandler, s as MemoryEventTransportOptions } from "../EventTransport-BPOQsEer.mjs";
3
+ import { a as withRetry, c as EventDefinitionOutput, d as EventSchema, f as ValidationResult, i as createDeadLetterPublisher, l as EventRegistry, m as defineEvent, n as eventPlugin, o as CustomValidator, p as createEventRegistry, r as RetryOptions, s as EventDefinitionInput, t as EventPluginOptions, u as EventRegistryOptions } from "../eventPlugin-DfHaKEWQ.mjs";
4
+ import { a as EventOutbox, c as OutboxRelayErrorKind, i as MemoryOutboxStore, l as RelayResult, n as OutboxModuleOptions, o as EventOutboxOptions, r as createOutboxModule, s as OutboxRelayErrorHandler, t as OutboxModuleExports } from "../outbox-module-CzsKRBvO.mjs";
5
5
  import { RedisEventTransportOptions, RedisLike } from "./transports/redis.mjs";
6
- import { r as RedisStreamTransportOptions, t as RedisStreamLike } from "../redis-stream-eh0eOtjh.mjs";
6
+ import { r as RedisStreamTransportOptions, t as RedisStreamLike } from "../redis-stream-DSsPyYzd.mjs";
7
7
  import { OutboxStore } from "@classytic/primitives/outbox";
8
8
  import { RepositoryLike } from "@classytic/repo-core/adapter";
9
9
  //#region src/events/eventTypes.d.ts
@@ -1,8 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { n as MemoryEventTransport } from "../EventTransport-Gq7JWbWw.mjs";
3
- import { a as createEventRegistry, i as wrapWithSchema, n as subscribeWithSchema, o as defineEvent, r as wrapWithBoundary, t as subscribeWithBoundary } from "../subscribe-helpers-CBZOi6pk.mjs";
4
- import { i as withRetry, r as createDeadLetterPublisher, t as eventPlugin } from "../eventPlugin-DJwpGMzx.mjs";
5
- import { i as exponentialBackoff, n as EventOutbox, r as repositoryAsOutboxStore, t as createOutboxModule } from "../outbox-module-DyIqA5vo.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { n as MemoryEventTransport } from "../EventTransport-BUkTwY_x.mjs";
3
+ import { a as createEventRegistry, i as wrapWithSchema, n as subscribeWithSchema, o as defineEvent, r as wrapWithBoundary, t as subscribeWithBoundary } from "../subscribe-helpers-KgVEcn8L.mjs";
4
+ import { i as withRetry, r as createDeadLetterPublisher, t as eventPlugin } from "../eventPlugin-DB26V7uX.mjs";
5
+ import { i as exponentialBackoff, n as EventOutbox, r as repositoryAsOutboxStore, t as createOutboxModule } from "../outbox-module-6DMC_WNu.mjs";
6
6
  import { MemoryOutboxStore } from "@classytic/primitives/memory-outbox";
7
7
  //#region src/events/eventTypes.ts
8
8
  /**
@@ -1,3 +1,3 @@
1
1
 
2
- import { n as RedisStreamTransport, r as RedisStreamTransportOptions, t as RedisStreamLike } from "../../redis-stream-eh0eOtjh.mjs";
2
+ import { n as RedisStreamTransport, r as RedisStreamTransportOptions, t as RedisStreamLike } from "../../redis-stream-DSsPyYzd.mjs";
3
3
  export { type RedisStreamLike, RedisStreamTransport, type RedisStreamTransportOptions };
@@ -1,5 +1,7 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { r as workSeedFromEvent, t as runWorkScope } from "../../workScope-CoGpuzDX.mjs";
2
3
  import sjson from "secure-json-parse";
4
+ import { matchEventPattern } from "@classytic/primitives/events";
3
5
  //#region src/events/transports/redis-stream.ts
4
6
  /**
5
7
  * Redis Stream Event Transport — Durable Event Delivery
@@ -183,7 +185,7 @@ var RedisStreamTransport = class {
183
185
  this.generation++;
184
186
  this.handlers.clear();
185
187
  this.failureContext.clear();
186
- if (this.pollPromise) {
188
+ if (this.pollPromise !== null) {
187
189
  if (await Promise.race([this.pollPromise.then(() => "drained"), this.sleep(this.closeTimeoutMs).then(() => "timeout")]) === "timeout") {
188
190
  if (!this.externalLifecycle) {
189
191
  if (typeof this.redis.disconnect === "function") this.redis.disconnect();
@@ -278,14 +280,16 @@ var RedisStreamTransport = class {
278
280
  let allSucceeded = true;
279
281
  let lastError;
280
282
  let lastHandlerName;
281
- for (const handler of matchingHandlers) try {
282
- await handler(event);
283
- } catch (err) {
284
- allSucceeded = false;
285
- lastError = err instanceof Error ? err : new Error(String(err));
286
- lastHandlerName = handler.name || lastHandlerName;
287
- this.logger.error(`[RedisStreamTransport] Handler error for ${event.type}:`, err);
288
- }
283
+ await runWorkScope(workSeedFromEvent(event), async () => {
284
+ for (const handler of matchingHandlers) try {
285
+ await handler(event);
286
+ } catch (err) {
287
+ allSucceeded = false;
288
+ lastError = err instanceof Error ? err : new Error(String(err));
289
+ lastHandlerName = handler.name || lastHandlerName;
290
+ this.logger.error(`[RedisStreamTransport] Handler error for ${event.type}:`, err);
291
+ }
292
+ });
289
293
  if (allSucceeded) {
290
294
  await this.redis.xack(this.stream, this.group, messageId);
291
295
  this.failureContext.delete(messageId);
@@ -306,20 +310,17 @@ var RedisStreamTransport = class {
306
310
  if (oldest !== void 0) this.failureContext.delete(oldest);
307
311
  }
308
312
  }
313
+ /**
314
+ * The canonical matcher from primitives — the SAME glob rules the memory
315
+ * transport speaks. A private matcher here once accepted `prefix.*` but not
316
+ * `prefix:*`, so an `order:*` subscription that worked in-process received
317
+ * nothing after a move to the stream, with no error.
318
+ */
309
319
  getMatchingHandlers(eventType) {
310
320
  const matched = [];
311
- for (const [pattern, handlers] of this.handlers) if (this.matchesPattern(pattern, eventType)) for (const h of handlers) matched.push(h);
321
+ for (const [pattern, handlers] of this.handlers) if (matchEventPattern(pattern, eventType)) for (const h of handlers) matched.push(h);
312
322
  return matched;
313
323
  }
314
- matchesPattern(pattern, eventType) {
315
- if (pattern === "*") return true;
316
- if (pattern === eventType) return true;
317
- if (pattern.endsWith(".*")) {
318
- const prefix = pattern.slice(0, -2);
319
- return eventType.startsWith(`${prefix}.`);
320
- }
321
- return false;
322
- }
323
324
  async moveToDlq(ids) {
324
325
  if (this.deadLetterStream === false) {
325
326
  for (const id of ids) {
@@ -1,5 +1,5 @@
1
1
 
2
- import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler } from "../../EventTransport-Cx60_s-6.mjs";
2
+ import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler } from "../../EventTransport-BPOQsEer.mjs";
3
3
  //#region src/events/transports/redis.d.ts
4
4
  interface RedisLike {
5
5
  publish(channel: string, message: string): Promise<number>;
@@ -1,4 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { r as workSeedFromEvent, t as runWorkScope } from "../../workScope-CoGpuzDX.mjs";
2
3
  import sjson from "secure-json-parse";
3
4
  //#region src/events/transports/redis.ts
4
5
  /**
@@ -107,14 +108,16 @@ var RedisEventTransport = class {
107
108
  } catch {
108
109
  return;
109
110
  }
110
- for (const handler of handlers) try {
111
- const result = handler(event);
112
- if (result && typeof result === "object" && "catch" in result) result.catch((err) => {
111
+ runWorkScope(workSeedFromEvent(event), () => {
112
+ for (const handler of handlers) try {
113
+ const result = handler(event);
114
+ if (result && typeof result === "object" && "catch" in result) result.catch((err) => {
115
+ this.logger.error(`[RedisEventTransport] Handler error for ${event.type}:`, err);
116
+ });
117
+ } catch (err) {
113
118
  this.logger.error(`[RedisEventTransport] Handler error for ${event.type}:`, err);
114
- });
115
- } catch (err) {
116
- this.logger.error(`[RedisEventTransport] Handler error for ${event.type}:`, err);
117
- }
119
+ }
120
+ });
118
121
  }
119
122
  /**
120
123
  * Convert an Arc event pattern to a Redis channel/pattern string.
@@ -1,8 +1,8 @@
1
1
 
2
- import { _ as HealthCheck, a as ModuleContribution, c as LoadResourcesOptions, d as loadResources, i as EventHandlerDefinition, l as ResourceLike, n as ArcModuleInput, o as ModuleDisposer, r as ArcModuleRegistry, s as ModuleSetupContext, t as ArcModule, u as ResourceModule } from "../types-BRU-Kd3t.mjs";
3
- import { _ as collectModuleScheduledJobs, a as lazyModuleExports, c as getModuleState, d as resolveModule, f as orderModules, g as collectModuleHealthChecks, h as extendModule, i as hasModuleExports, l as hasModule, m as ModuleExtension, n as getModuleExports, o as lazyRequiredModuleExports, p as subscribeModuleEventHandlers, r as getOptionalModuleExports, s as ModuleState, t as defineModule, u as resolveContribution, v as collectModuleWorkflows } from "../index-D2uIUSQk.mjs";
4
- import { c as ResolvedResourceDescriptor, l as describeResolvedModule, o as ResolvedModuleDescriptor, s as ResolvedModuleLifecycle } from "../fastify-augmentation-jYA2oHyL.mjs";
5
- import { a as RawBodyOptions, c as BetterAuthOption, d as JwtAuthOption, i as MultipartOptions, l as CustomAuthenticatorOption, n as preloadResourcesAsync, o as UnderPressureOptions, r as CreateAppOptions, s as AuthOption, t as preloadResources, u as CustomPluginAuthOption } from "../preloadResources-BbBkNkqK.mjs";
2
+ import { _ as HealthCheck, a as ModuleContribution, c as LoadResourcesOptions, d as loadResources, i as EventHandlerDefinition, l as ResourceLike, n as ArcModuleInput, o as ModuleDisposer, r as ArcModuleRegistry, s as ModuleSetupContext, t as ArcModule, u as ResourceModule } from "../types-BVlowlm7.mjs";
3
+ import { _ as collectModuleScheduledJobs, a as lazyModuleExports, c as getModuleState, d as resolveModule, f as orderModules, g as collectModuleHealthChecks, h as extendModule, i as hasModuleExports, l as hasModule, m as ModuleExtension, n as getModuleExports, o as lazyRequiredModuleExports, p as subscribeModuleEventHandlers, r as getOptionalModuleExports, s as ModuleState, t as defineModule, u as resolveContribution, v as collectModuleWorkflows } from "../index-DbMglURO.mjs";
4
+ import { c as ResolvedResourceDescriptor, l as describeResolvedModule, o as ResolvedModuleDescriptor, s as ResolvedModuleLifecycle } from "../fastify-augmentation-HncZMmze.mjs";
5
+ import { a as RawBodyOptions, c as BetterAuthOption, d as JwtAuthOption, i as MultipartOptions, l as CustomAuthenticatorOption, n as preloadResourcesAsync, o as UnderPressureOptions, r as CreateAppOptions, s as AuthOption, t as preloadResources, u as CustomPluginAuthOption } from "../preloadResources-DVgPCNcD.mjs";
6
6
  import { FastifyInstance, FastifyServerOptions } from "fastify";
7
7
  //#region src/factory/createApp.d.ts
8
8
  /**
@@ -1,8 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { r as mergeHealthChecks, t as healthPlugin } from "../health-Bh0N_FLk.mjs";
3
- import { S as resolveModule, _ as describeResolvedModule, a as createApp, b as collectModuleWorkflows, c as edgePreset, d as testingPreset, f as workerPreset, g as subscribeModuleEventHandlers, h as orderModules, i as DEFAULT_LOGGER_REDACT_PATHS, l as getPreset, m as hasModule, n as preloadResourcesAsync, p as getModuleState, r as ArcFactory, s as developmentPreset, t as preloadResources, u as productionPreset, v as collectModuleHealthChecks, x as resolveContribution, y as collectModuleScheduledJobs } from "../preloadResources-DlhH81py.mjs";
4
- import { a as lazyModuleExports, i as hasModuleExports, n as getModuleExports, o as lazyRequiredModuleExports, r as getOptionalModuleExports, t as defineModule } from "../module-BQXHxMEk.mjs";
5
- import { t as loadResources } from "../loadResources-CNd1DWnK.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { r as mergeHealthChecks, t as healthPlugin } from "../health-BlGHjkqZ.mjs";
3
+ import { S as resolveModule, _ as describeResolvedModule, a as createApp, b as collectModuleWorkflows, c as edgePreset, d as testingPreset, f as workerPreset, g as subscribeModuleEventHandlers, h as orderModules, i as DEFAULT_LOGGER_REDACT_PATHS, l as getPreset, m as hasModule, n as preloadResourcesAsync, p as getModuleState, r as ArcFactory, s as developmentPreset, t as preloadResources, u as productionPreset, v as collectModuleHealthChecks, x as resolveContribution, y as collectModuleScheduledJobs } from "../preloadResources-BAx5s9EF.mjs";
4
+ import { a as lazyModuleExports, i as hasModuleExports, n as getModuleExports, o as lazyRequiredModuleExports, r as getOptionalModuleExports, t as defineModule } from "../module-CNcwCKUJ.mjs";
5
+ import { t as loadResources } from "../loadResources-E5UFlRrT.mjs";
6
6
  //#region src/factory/module/extend.ts
7
7
  /** Concatenate two contributions, resolving factories only when arc asks. */
8
8
  function mergeContribution(own, extra) {
@@ -1,8 +1,8 @@
1
1
 
2
- import { on as HookSystem, z as ResourceRegistry } from "./index-B78WZom8.mjs";
2
+ import { on as HookSystem, z as ResourceRegistry } from "./index-D3sIPcD4.mjs";
3
3
  import { t as ExternalOpenApiPaths } from "./externalPaths-CmGOxOtD.mjs";
4
- import { _ as HealthCheck, f as ScheduleDefinition, r as ArcModuleRegistry, t as ArcModule } from "./types-BRU-Kd3t.mjs";
5
- import { s as ModuleState } from "./index-D2uIUSQk.mjs";
4
+ import { _ as HealthCheck, f as ScheduleDefinition, r as ArcModuleRegistry, t as ArcModule } from "./types-BVlowlm7.mjs";
5
+ import { s as ModuleState } from "./index-DbMglURO.mjs";
6
6
  import { FastifyPluginAsync } from "fastify";
7
7
  //#region src/factory/module/descriptor.d.ts
8
8
  /**
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
2
  //#region src/permissions/fields.ts
3
3
  /**
4
4
  * Field-Level Permissions
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as pluralize } from "./pluralize-Da7IT_qJ.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as pluralize } from "./pluralize-BaQ62hOW.mjs";
3
3
  import { join } from "node:path";
4
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
5
  //#region src/cli/commands/generate/name-helpers.ts
@@ -470,7 +470,8 @@ export default ${camel}Resource;
470
470
  */
471
471
 
472
472
  import { defineTool } from '@classytic/arc/mcp';
473
- ${ts ? "import { z } from 'zod';\n" : "const { z } = require('zod');\n"}
473
+ import { z } from 'zod';
474
+
474
475
  // Example: domain-specific action tool
475
476
  // export const activate${name}Tool = defineTool('activate_${fileName}', {
476
477
  // description: 'Activate a ${name.toLowerCase()} by ID',