@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,20 +1,20 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { p as MUTATION_OPERATIONS } from "../constants-BONghE1Y.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { p as MUTATION_OPERATIONS } from "../constants-BQ2FbhPB.mjs";
3
3
  import { arcLog } from "../logger/index.mjs";
4
- import { c as getOrgId } from "../types-BqLyyH0o.mjs";
5
- import { n as requestContext } from "../requestContext-DpmntRZy.mjs";
6
- import { t as hasEvents } from "../typeGuards-DHTnEs5X.mjs";
7
- import { t as HookSystem } from "../HookSystem-C0ikzqQf.mjs";
8
- import { t as ResourceRegistry } from "../ResourceRegistry-DPcX--zk.mjs";
9
- import { a as requestIdPlugin, i as createRequestIdGenerator, n as health_default, o as requestId_default, s as sanitizeRequestId, t as healthPlugin } from "../health-Bh0N_FLk.mjs";
10
- import { n as caching_default, t as cachingPlugin } from "../caching-a3ZEcJJs.mjs";
11
- import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-BdmIWPba.mjs";
12
- import { n as metrics_default, t as metricsPlugin } from "../metrics-CsWaIVTa.mjs";
13
- import { n as realtime_default, t as realtimePlugin } from "../realtime-CPmjjgqd.mjs";
14
- import { t as replyHelpersPlugin } from "../replyHelpers-BHebarf0.mjs";
15
- import { n as schedules_default, t as schedulesPlugin } from "../schedules-DthM8Qag.mjs";
16
- import { n as sse_default, t as ssePlugin } from "../sse-D4MYqkic.mjs";
17
- import { n as versioning_default, t as versioningPlugin } from "../versioning-C2r0eOZ4.mjs";
4
+ import { c as getOrgId } from "../types-CNQyOrLk.mjs";
5
+ import { n as requestContext } from "../requestContext-D4PuGhEw.mjs";
6
+ import { t as hasEvents } from "../typeGuards-t_CVgRXN.mjs";
7
+ import { t as HookSystem } from "../HookSystem-96nzZLmk.mjs";
8
+ import { t as ResourceRegistry } from "../ResourceRegistry-B9WnuG2Q.mjs";
9
+ import { a as requestIdPlugin, i as createRequestIdGenerator, n as health_default, o as requestId_default, s as sanitizeRequestId, t as healthPlugin } from "../health-BlGHjkqZ.mjs";
10
+ import { n as caching_default, t as cachingPlugin } from "../caching-Bqcn3Brl.mjs";
11
+ import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-By9keRvX.mjs";
12
+ import { n as metrics_default, t as metricsPlugin } from "../metrics-P37sNV5H.mjs";
13
+ import { n as realtime_default, t as realtimePlugin } from "../realtime-zzoNLDtj.mjs";
14
+ import { t as replyHelpersPlugin } from "../replyHelpers-9h-a592u.mjs";
15
+ import { n as schedules_default, t as schedulesPlugin } from "../schedules-Dm21pqHU.mjs";
16
+ import { n as sse_default, t as ssePlugin } from "../sse-DbyXoQun.mjs";
17
+ import { n as versioning_default, t as versioningPlugin } from "../versioning-BXwmj5SD.mjs";
18
18
  import fp from "fastify-plugin";
19
19
  import { performance as performance$1 } from "node:perf_hooks";
20
20
  //#region src/core/arcCorePlugin.ts
@@ -41,6 +41,7 @@ const arcCorePlugin = async (fastify, opts = {}) => {
41
41
  ]) if (!fastify.hasRequestDecorator(field)) fastify.decorateRequest(field, void 0);
42
42
  fastify.addHook("onRequest", (request, _reply, done) => {
43
43
  const store = {
44
+ kind: "request",
44
45
  requestId: request.id,
45
46
  startTime: performance.now()
46
47
  };
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as hasEvents } from "../typeGuards-DHTnEs5X.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as hasEvents } from "../typeGuards-t_CVgRXN.mjs";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/plugins/response-cache.ts
5
5
  /**
@@ -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 { createRequire } from "node:module";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/plugins/tracing.ts
@@ -59,7 +59,7 @@ try {
59
59
  function createTracerProvider(options) {
60
60
  if (!isAvailable || !NodeTracerProvider || !BatchSpanProcessor || !OTLPTraceExporter) return null;
61
61
  const { serviceName = "@classytic/arc", serviceVersion, exporterUrl = "http://localhost:4318/v1/traces" } = options;
62
- const resolvedVersion = serviceVersion ?? "2.38.0";
62
+ const resolvedVersion = serviceVersion ?? "2.40.0";
63
63
  const exporter = new OTLPTraceExporter({ url: exporterUrl });
64
64
  const provider = new NodeTracerProvider({ resource: { attributes: {
65
65
  "service.name": serviceName,
@@ -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/pluralize.ts
3
3
  /**
4
4
  * Lightweight English pluralization for the Arc CLI.
@@ -1,12 +1,12 @@
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, configureArcLogger, createPinoWriter, enterArcLoggerScope, runWithArcLogger } from "./logger/index.mjs";
4
- import { n as PUBLIC_SCOPE } from "./types-BqLyyH0o.mjs";
5
- import { t as auditRuntimeCapabilities } from "./runtimeCapabilities-D793Pxci.mjs";
6
- import { t as createTenantKeyGenerator } from "./rateLimitKey-CewdR-m6.mjs";
7
- import { i as createRequestIdGenerator, r as mergeHealthChecks } from "./health-Bh0N_FLk.mjs";
8
- import { t as parseJsonBody } from "./jsonBody-DVui0uJl.mjs";
9
- import { r as wrapWithBoundary } from "./subscribe-helpers-CBZOi6pk.mjs";
4
+ import { n as PUBLIC_SCOPE } from "./types-CNQyOrLk.mjs";
5
+ import { t as auditRuntimeCapabilities } from "./runtimeCapabilities-Bo7rSKjm.mjs";
6
+ import { n as isScopeAwareKeyGenerator, t as createTenantKeyGenerator } from "./rateLimitKey-umrS6-vu.mjs";
7
+ import { i as createRequestIdGenerator, r as mergeHealthChecks } from "./health-BlGHjkqZ.mjs";
8
+ import { t as parseJsonBody } from "./jsonBody-Dx6jH_Nb.mjs";
9
+ import { r as wrapWithBoundary } from "./subscribe-helpers-KgVEcn8L.mjs";
10
10
  import { isProductionEnv } from "@classytic/primitives/environment";
11
11
  import Fastify from "fastify";
12
12
  import qs from "qs";
@@ -851,7 +851,7 @@ async function registerArcCore(fastify, config, trackPlugin) {
851
851
  await fastify.register(arcCorePlugin, { emitEvents: config.arcPlugins?.emitEvents !== false });
852
852
  trackPlugin("arc-core");
853
853
  if (config.arcPlugins?.events !== false) {
854
- const { default: eventPlugin } = await import("./eventPlugin-DJwpGMzx.mjs").then((n) => n.n);
854
+ const { default: eventPlugin } = await import("./eventPlugin-DB26V7uX.mjs").then((n) => n.n);
855
855
  const eventOpts = typeof config.arcPlugins?.events === "object" ? config.arcPlugins.events : {};
856
856
  await fastify.register(eventPlugin, {
857
857
  /**
@@ -910,15 +910,15 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules, moduleH
910
910
  trackPlugin("arc-graceful-shutdown");
911
911
  }
912
912
  if (config.arcPlugins?.caching) {
913
- const { default: cachingPlugin } = await import("./caching-a3ZEcJJs.mjs").then((n) => n.r);
913
+ const { default: cachingPlugin } = await import("./caching-Bqcn3Brl.mjs").then((n) => n.r);
914
914
  const opts = config.arcPlugins.caching === true ? {} : config.arcPlugins.caching;
915
915
  await fastify.register(cachingPlugin, opts);
916
916
  trackPlugin("arc-caching", opts);
917
917
  }
918
918
  if (config.arcPlugins?.queryCache) {
919
- const { queryCachePlugin } = await import("./queryCachePlugin-oTsmVyEQ.mjs").then((n) => n.n);
919
+ const { queryCachePlugin } = await import("./queryCachePlugin-2Pp9w-8D.mjs").then((n) => n.n);
920
920
  const opts = config.arcPlugins.queryCache === true ? {} : config.arcPlugins.queryCache;
921
- const store = config.stores?.queryCache ?? new (await (import("./memory-BiPVaCPg.mjs").then((n) => n.n))).MemoryCacheStore();
921
+ const store = config.stores?.queryCache ?? new (await (import("./memory-CNvjxzB2.mjs").then((n) => n.n))).MemoryCacheStore();
922
922
  await fastify.register(queryCachePlugin, {
923
923
  store,
924
924
  ...opts
@@ -928,7 +928,7 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules, moduleH
928
928
  if (config.arcPlugins?.sse) {
929
929
  if (config.arcPlugins?.events === false) fastify.log.warn("SSE plugin requires events plugin (arcPlugins.events). SSE disabled.");
930
930
  else {
931
- const { default: ssePlugin } = await import("./sse-D4MYqkic.mjs").then((n) => n.r);
931
+ const { default: ssePlugin } = await import("./sse-DbyXoQun.mjs").then((n) => n.r);
932
932
  const opts = config.arcPlugins.sse === true ? {} : config.arcPlugins.sse;
933
933
  await fastify.register(ssePlugin, opts);
934
934
  trackPlugin("arc-sse", opts);
@@ -937,20 +937,20 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules, moduleH
937
937
  if (config.arcPlugins?.realtime) {
938
938
  if (config.arcPlugins?.events === false) fastify.log.warn("Realtime plugin requires events plugin (arcPlugins.events). Realtime disabled.");
939
939
  else {
940
- const { default: realtimePlugin } = await import("./realtime-CPmjjgqd.mjs").then((n) => n.r);
940
+ const { default: realtimePlugin } = await import("./realtime-zzoNLDtj.mjs").then((n) => n.r);
941
941
  const opts = config.arcPlugins.realtime === true ? {} : config.arcPlugins.realtime;
942
942
  await fastify.register(realtimePlugin, opts);
943
943
  trackPlugin("arc-realtime", opts);
944
944
  }
945
945
  }
946
946
  if (config.arcPlugins?.metrics) {
947
- const { default: metricsPlugin } = await import("./metrics-CsWaIVTa.mjs").then((n) => n.r);
947
+ const { default: metricsPlugin } = await import("./metrics-P37sNV5H.mjs").then((n) => n.r);
948
948
  const opts = config.arcPlugins.metrics === true ? {} : config.arcPlugins.metrics;
949
949
  await fastify.register(metricsPlugin, opts);
950
950
  trackPlugin("arc-metrics", opts);
951
951
  }
952
952
  if (config.arcPlugins?.versioning) {
953
- const { default: versioningPlugin } = await import("./versioning-C2r0eOZ4.mjs").then((n) => n.r);
953
+ const { default: versioningPlugin } = await import("./versioning-BXwmj5SD.mjs").then((n) => n.r);
954
954
  await fastify.register(versioningPlugin, config.arcPlugins.versioning);
955
955
  trackPlugin("arc-versioning", config.arcPlugins.versioning);
956
956
  }
@@ -1027,7 +1027,7 @@ async function registerAuth(fastify, config, trackPlugin) {
1027
1027
  */
1028
1028
  async function registerElevation(fastify, config, trackPlugin) {
1029
1029
  if (!config.elevation) return;
1030
- const { elevationPlugin } = await import("./elevation-C6woysGC.mjs").then((n) => n.r);
1030
+ const { elevationPlugin } = await import("./elevation-CZy6n50b.mjs").then((n) => n.r);
1031
1031
  await fastify.register(elevationPlugin, config.elevation);
1032
1032
  trackPlugin("arc-elevation", config.elevation);
1033
1033
  fastify.log.debug("Elevation plugin enabled");
@@ -1042,7 +1042,7 @@ async function registerElevation(fastify, config, trackPlugin) {
1042
1042
  */
1043
1043
  async function registerErrorHandler(fastify, config, trackPlugin, moduleErrorMappers) {
1044
1044
  if (config.errorHandler === false) return;
1045
- const { errorHandlerPlugin } = await import("./errorHandler-BdmIWPba.mjs").then((n) => n.r);
1045
+ const { errorHandlerPlugin } = await import("./errorHandler-By9keRvX.mjs").then((n) => n.r);
1046
1046
  /**
1047
1047
  * DISCLOSURE DEFAULTS MERGE — they used to be REPLACED, and that was two bugs.
1048
1048
  *
@@ -1266,7 +1266,7 @@ async function registerResources(fastify, config, preResolvedModules) {
1266
1266
  let discoveryPath;
1267
1267
  let discoveryYieldedZero = false;
1268
1268
  if (resolvedResources === void 0 && config.resourceDir) {
1269
- const { loadResources } = await import("./loadResources-CNd1DWnK.mjs").then((n) => n.n);
1269
+ const { loadResources } = await import("./loadResources-E5UFlRrT.mjs").then((n) => n.n);
1270
1270
  const { resolve, dirname } = await import("node:path");
1271
1271
  const { fileURLToPath } = await import("node:url");
1272
1272
  const rawDir = config.resourceDir;
@@ -1392,7 +1392,7 @@ Resources supplied by "${m.name}": ${provided}.`);
1392
1392
  if (fastify.hasDecorator("getScheduleStats")) throw new Error("[arc] modules declare scheduledJobs but schedulesPlugin was already registered manually. Configure their runner through arcPlugins.schedules so Arc can compose one schedule table.");
1393
1393
  const frozenJobs = Object.freeze(scheduledJobs.map((job) => Object.freeze({ ...job })));
1394
1394
  const scheduleOptions = typeof config.arcPlugins?.schedules === "object" ? config.arcPlugins.schedules : {};
1395
- const { default: schedulesPlugin } = await import("./schedules-DthM8Qag.mjs").then((n) => n.r);
1395
+ const { default: schedulesPlugin } = await import("./schedules-Dm21pqHU.mjs").then((n) => n.r);
1396
1396
  await fastify.register(schedulesPlugin, {
1397
1397
  ...scheduleOptions,
1398
1398
  schedules: frozenJobs
@@ -1566,6 +1566,7 @@ function buildPlanOpts(rest, plan) {
1566
1566
  */
1567
1567
  function buildRateLimitOpts(input) {
1568
1568
  const { skipPaths, allowList, plan, ...bare } = input;
1569
+ applyScopeAwareHook(bare);
1569
1570
  const rest = plan ? buildPlanOpts(bare, plan) : bare;
1570
1571
  if (!skipPaths || skipPaths.length === 0) return allowList === void 0 ? rest : {
1571
1572
  ...rest,
@@ -1584,6 +1585,27 @@ function buildRateLimitOpts(input) {
1584
1585
  allowList: combined
1585
1586
  };
1586
1587
  }
1588
+ /**
1589
+ * A scope-keyed generator must run AFTER authentication, so arc places the hook itself.
1590
+ *
1591
+ * `@fastify/rate-limit` defaults to `onRequest`; arc authenticates in a `preHandler`. A
1592
+ * generator from `createTenantKeyGenerator` therefore saw `PUBLIC_SCOPE` and returned the
1593
+ * caller's IP for EVERY request — and behind a proxy with `trustProxy` unset that is one
1594
+ * address, so a whole deployment shared a single bucket. Nothing threw: the limiter ran,
1595
+ * the host's key function ran, and the answer was silently wrong.
1596
+ *
1597
+ * Defaulted rather than merely warned, because the correct value is knowable here and the
1598
+ * failure is unobservable in production. An explicit `onRequest` is REFUSED rather than
1599
+ * honoured — it cannot do what the caller is asking for.
1600
+ */
1601
+ function applyScopeAwareHook(bare) {
1602
+ if (!isScopeAwareKeyGenerator(bare.keyGenerator)) return;
1603
+ if (bare.hook === void 0) {
1604
+ bare.hook = "preHandler";
1605
+ return;
1606
+ }
1607
+ if (bare.hook === "onRequest") throw new Error("[arc] rateLimit.hook: 'onRequest' cannot be combined with a scope-aware keyGenerator (createTenantKeyGenerator). Authentication runs in a preHandler, so the generator would see PUBLIC_SCOPE and key every caller by IP — behind a proxy that is one bucket for the whole deployment. Use hook: 'preHandler' (arc's default for this generator), or supply a keyGenerator that derives identity without the scope.");
1608
+ }
1587
1609
  function compilePathMatcher(patterns) {
1588
1610
  const prefixes = [];
1589
1611
  const exact = /* @__PURE__ */ new Set();
@@ -1738,6 +1760,17 @@ var createApp_exports = /* @__PURE__ */ __exportAll({
1738
1760
  createApp: () => createApp,
1739
1761
  resolveLoggerConfig: () => resolveLoggerConfig
1740
1762
  });
1763
+ /**
1764
+ * The fail-loud switches, and what each one costs while OFF.
1765
+ *
1766
+ * Every one is a SPECIFIC instruction defeated by a GENERAL default, which is
1767
+ * why they are reported together rather than one at a time.
1768
+ */
1769
+ const STRICT_ENV_FLAGS = [
1770
+ ["ARC_STRICT_PERMISSIONS", "An ungated write route warns instead of failing boot."],
1771
+ ["ARC_STRICT_QUERY_PARAMS", "An unknown filter key is DROPPED, which WIDENS the read."],
1772
+ ["ARC_STRICT_IMMUTABLE_WRITES", "A PATCH of an immutable field returns 200, unchanged."]
1773
+ ];
1741
1774
  const MEMORY_STORE_NAMES = /* @__PURE__ */ new Set(["memory", "memory-cache"]);
1742
1775
  /**
1743
1776
  * Default redact paths layered into Fastify's pino logger when the host
@@ -1967,6 +2000,22 @@ async function buildApp(options, loggerScope, onInstance) {
1967
2000
  for (const warning of deferredWarnings) fastify.log.warn(warning);
1968
2001
  if (numericTrustProxy) fastify.log.warn(`[arc] trustProxy: ${String(config.trustProxy)} (a hop COUNT) trusts nothing on Fastify >= 5.12.1 — hop-count trust cannot validate the immediate peer, so it fails closed upstream to stop clients spoofing X-Forwarded-* with padded hops. \`request.ip\` is therefore the PROXY's address: rate-limit keys collapse onto one bucket and audit rows record the wrong client. Name the proxies instead — trustProxy: 'loopback', '10.0.0.0/8', a comma-separated list, or \`true\` if every upstream hop is genuinely trusted.`);
1969
2002
  if (inheritedTrustProxyDefault) fastify.log.warn("[arc] preset: 'production' now defaults to trustProxy: false (fail-closed; was true before 2.24). If this app runs behind a load balancer or reverse proxy, request.ip is currently the PROXY's address — rate-limit keys collapse onto one bucket and audit logs record the wrong client. Set trustProxy explicitly: a hop count (trustProxy: 1), a CIDR allow-list ('10.0.0.0/8'), a resolver function, or false if clients truly connect directly.");
2003
+ /**
2004
+ * `preset: 'production'` REPORTS the fail-loud switches it cannot set.
2005
+ *
2006
+ * All three are read where the object is CONSTRUCTED — `defineResource` at
2007
+ * define time, `QueryParser` and `BodySanitizer` in their constructors — and a
2008
+ * host imports its resources before it calls `createApp`. So setting
2009
+ * `process.env` here would be too late for everything already built: wired to
2010
+ * read, doing nothing. Reporting cannot fail that way.
2011
+ *
2012
+ * Set them in the process entrypoint, BEFORE the first resource import, with
2013
+ * `??=` so an operator's explicit `false` still wins.
2014
+ */
2015
+ if (config.preset === "production") {
2016
+ const off = STRICT_ENV_FLAGS.filter(([name]) => process.env[name] !== "true");
2017
+ if (off.length > 0) fastify.log.warn(`[arc] preset: 'production' with fail-loud OFF: ${off.map(([n]) => n).join(", ")}. ${off.map(([, what]) => what).join(" ")} Set them in the entrypoint BEFORE any resource import — they are read when resources, parsers and sanitizers are CONSTRUCTED, so setting them later is silently too late. Per-resource options still override.`);
2018
+ }
1970
2019
  fastify.removeContentTypeParser("application/json");
1971
2020
  fastify.addContentTypeParser("application/json", { parseAs: "string" }, (_req, body, done) => {
1972
2021
  try {
@@ -1999,7 +2048,7 @@ async function buildApp(options, loggerScope, onInstance) {
1999
2048
  await registerErrorHandler(fastify, config, trackPlugin, moduleErrorMappers);
2000
2049
  await registerResources(fastify, config, resolvedModules);
2001
2050
  if (config.replyHelpers) {
2002
- const { replyHelpersPlugin } = await import("./replyHelpers-BHebarf0.mjs").then((n) => n.n);
2051
+ const { replyHelpersPlugin } = await import("./replyHelpers-9h-a592u.mjs").then((n) => n.n);
2003
2052
  await fastify.register(replyHelpersPlugin);
2004
2053
  }
2005
2054
  if (config.serializeBigInt) {
@@ -1,15 +1,15 @@
1
1
 
2
- import { It as Authenticator } from "./index-B78WZom8.mjs";
2
+ import { It as Authenticator } from "./index-D3sIPcD4.mjs";
3
3
  import { r as CacheStore } from "./interface-BOk3YnTz.mjs";
4
4
  import { n as ElevationOptions } from "./elevation-BXCfVcNG.mjs";
5
- import { a as EventTransport } from "./EventTransport-Cx60_s-6.mjs";
5
+ import { a as EventTransport } from "./EventTransport-BPOQsEer.mjs";
6
6
  import { t as ExternalOpenApiPaths } from "./externalPaths-CmGOxOtD.mjs";
7
7
  import { r as QueryCachePluginOptions } from "./queryCachePlugin-BzqxconG.mjs";
8
- import { t as ErrorHandlerOptions } from "./errorHandler-DI5AN2b5.mjs";
9
- import { l as ResourceLike, m as SchedulesPluginOptions, n as ArcModuleInput, v as HealthOptions } from "./types-BRU-Kd3t.mjs";
10
- import "./index-D2uIUSQk.mjs";
11
- import { t as EventPluginOptions } from "./eventPlugin-DFvHa4Nf.mjs";
12
- import { g as CachingOptions, o as MetricsOptions, p as SSEOptions, t as VersioningOptions, u as RealtimeOptions } from "./versioning-B843jOYX.mjs";
8
+ import { t as ErrorHandlerOptions } from "./errorHandler--4rSMMvq.mjs";
9
+ import { l as ResourceLike, m as SchedulesPluginOptions, n as ArcModuleInput, v as HealthOptions } from "./types-BVlowlm7.mjs";
10
+ import "./index-DbMglURO.mjs";
11
+ import { t as EventPluginOptions } from "./eventPlugin-DfHaKEWQ.mjs";
12
+ import { g as CachingOptions, o as MetricsOptions, p as SSEOptions, t as VersioningOptions, u as RealtimeOptions } from "./versioning-P3V6ATyC.mjs";
13
13
  import { r as IdempotencyStore } from "./interface-DEWNOMza.mjs";
14
14
  import { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, FastifyServerOptions } from "fastify";
15
15
  //#region src/factory/types/assets.d.ts
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { i as RequestScope } from "../types-Ddl9OjmE.mjs";
3
3
  import { l as PermissionCheck } from "../base-C-NL2fTi.mjs";
4
- import { Y as PresetResult } from "../index-B78WZom8.mjs";
4
+ import { Y as PresetResult } from "../index-D3sIPcD4.mjs";
5
5
  import { a as StorageReadResult, i as StorageReadRange, n as StorageContext, o as StorageUploadInput, r as StorageFile, t as Storage } from "../storage-Cx9Sz3Ou.mjs";
6
6
  //#region src/presets/filesUpload.d.ts
7
7
  interface FilesUploadPresetRoutes {
@@ -1,8 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { i as NotFoundError, u as ValidationError } from "../errors-2ExmOgIJ.mjs";
3
- import { c as getOrgId, g as getUserId } from "../types-BqLyyH0o.mjs";
4
- import { B as requireAuth, F as allowPublic } from "../permissions-H7Zcb82Z.mjs";
5
- import { t as multipartBody } from "../multipartBody-u6VrS_iH.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { i as NotFoundError, u as ValidationError } from "../errors-BHD3L8of.mjs";
3
+ import { c as getOrgId, g as getUserId } from "../types-CNQyOrLk.mjs";
4
+ import { B as requireAuth, F as allowPublic } from "../permissions-C0GpDsB_.mjs";
5
+ import { t as multipartBody } from "../multipartBody-Bl_gU3Wg.mjs";
6
6
  //#region src/presets/filesUpload.ts
7
7
  const DEFAULT_FIELD_NAME = "file";
8
8
  const DEFAULT_MAX_FILE_SIZE = 10485760;
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { t as AnyRecord } from "../base-C-NL2fTi.mjs";
3
- import { Fn as IControllerResponse, In as IRequestContext, U as ResourceConfig, Y as PresetResult, d as PaginationResult } from "../index-B78WZom8.mjs";
3
+ import { Fn as IControllerResponse, In as IRequestContext, U as ResourceConfig, Y as PresetResult, d as PaginationResult } from "../index-D3sIPcD4.mjs";
4
4
  import { FilesUploadPresetOptions, FilesUploadPresetPermissions, FilesUploadPresetRoutes, filesUploadPreset } from "./filesUpload.mjs";
5
5
  import { MultiTenantOptions, TenantFieldSpec, multiTenantPreset } from "./multiTenant.mjs";
6
6
  import { SearchHandler, SearchPresetOptions, SearchRouteConfig, searchPreset } from "./search.mjs";
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
2
  import { multiTenantPreset } from "./multiTenant.mjs";
3
- import { a as registerPreset, c as auditedPreset, d as ownedByUserPreset, i as getPreset, l as softDeletePreset, n as flexibleMultiTenantPreset, o as treePreset, r as getAvailablePresets, s as bulkPreset, t as applyPresets, u as slugLookupPreset } from "../presets-CNyfaxGL.mjs";
3
+ import { a as registerPreset, c as auditedPreset, d as ownedByUserPreset, i as getPreset, l as softDeletePreset, n as flexibleMultiTenantPreset, o as treePreset, r as getAvailablePresets, s as bulkPreset, t as applyPresets, u as slugLookupPreset } from "../presets-CAaqVVcW.mjs";
4
4
  import { filesUploadPreset } from "./filesUpload.mjs";
5
5
  import { searchPreset } from "./search.mjs";
6
6
  export { applyPresets, auditedPreset, bulkPreset, filesUploadPreset, flexibleMultiTenantPreset, getAvailablePresets, getPreset, multiTenantPreset, ownedByUserPreset, registerPreset, searchPreset, slugLookupPreset, softDeletePreset, treePreset };
@@ -1,5 +1,5 @@
1
1
 
2
- import { X as CrudRouteKey, Y as PresetResult } from "../index-B78WZom8.mjs";
2
+ import { X as CrudRouteKey, Y as PresetResult } from "../index-D3sIPcD4.mjs";
3
3
  //#region src/presets/multiTenant.d.ts
4
4
  /**
5
5
  * One tenant dimension for multi-field filtering. Discriminated by source:
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import "../constants-BONghE1Y.mjs";
3
- import { b as isElevated, c as getOrgId, d as getScopeContext, m as getTeamId, u as getRequestScope, v as hasOrgAccess } from "../types-BqLyyH0o.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import "../constants-BQ2FbhPB.mjs";
3
+ import { b as isElevated, c as getOrgId, d as getScopeContext, m as getTeamId, u as getRequestScope, v as hasOrgAccess } from "../types-CNQyOrLk.mjs";
4
4
  //#region src/presets/multiTenant.ts
5
5
  /**
6
6
  * Resolve a single TenantFieldSpec against the current scope.
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { l as PermissionCheck } from "../base-C-NL2fTi.mjs";
3
- import { At as RouteDefinition, Y as PresetResult, jn as ControllerHandler, jt as RouteMcpConfig } from "../index-B78WZom8.mjs";
3
+ import { At as RouteDefinition, Y as PresetResult, jn as ControllerHandler, jt as RouteMcpConfig } from "../index-D3sIPcD4.mjs";
4
4
  //#region src/presets/search.d.ts
5
5
  /**
6
6
  * Search Preset — backend-agnostic search / vector / embed routes
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { B as requireAuth, F as allowPublic } from "../permissions-H7Zcb82Z.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { B as requireAuth, F as allowPublic } from "../permissions-C0GpDsB_.mjs";
3
3
  //#region src/presets/search.ts
4
4
  const BUILTINS = [
5
5
  {
@@ -1,7 +1,7 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { l as UnauthorizedError } from "./errors-2ExmOgIJ.mjs";
3
- import { b as isElevated, n as PUBLIC_SCOPE } from "./types-BqLyyH0o.mjs";
4
- import { B as requireAuth, F as allowPublic, U as requireRoles } from "./permissions-H7Zcb82Z.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { l as UnauthorizedError } from "./errors-BHD3L8of.mjs";
3
+ import { b as isElevated, n as PUBLIC_SCOPE } from "./types-CNQyOrLk.mjs";
4
+ import { B as requireAuth, F as allowPublic, U as requireRoles } from "./permissions-C0GpDsB_.mjs";
5
5
  import { multiTenantPreset } from "./presets/multiTenant.mjs";
6
6
  //#region src/presets/ownedByUser.ts
7
7
  /**
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { c as getOrgId, f as getScopeContextMap, g as getUserId, m as getTeamId, x as isMember } from "./types-BqLyyH0o.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { c as getOrgId, f as getScopeContextMap, g as getUserId, m as getTeamId, x as isMember } from "./types-CNQyOrLk.mjs";
3
3
  //#region src/scope/projection.ts
4
4
  /**
5
5
  * Compute the request-scope projection. Returns `undefined` when no
@@ -1,8 +1,8 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-Add2L50I.mjs";
3
- import { i as versionKey, r as tagVersionKey } from "./keys-BSuxGS-B.mjs";
4
- import { t as hasEvents } from "./typeGuards-DHTnEs5X.mjs";
5
- import { t as MemoryCacheStore } from "./memory-BiPVaCPg.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DzE6ikSH.mjs";
3
+ import { i as versionKey, r as tagVersionKey } from "./keys-Ds3ekBiu.mjs";
4
+ import { t as hasEvents } from "./typeGuards-t_CVgRXN.mjs";
5
+ import { t as MemoryCacheStore } from "./memory-CNvjxzB2.mjs";
6
6
  import fp from "fastify-plugin";
7
7
  //#region src/cache/QueryCache.ts
8
8
  var QueryCache = class {
@@ -0,0 +1,41 @@
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ //#region src/scope/rateLimitKey.ts
3
+ /**
4
+ * Marks a key generator as SCOPE-AWARE, so `buildRateLimitOpts` can place the rate-limit
5
+ * hook after authentication instead of before it.
6
+ *
7
+ * Without this, the degradation is invisible: `@fastify/rate-limit` runs at `onRequest`,
8
+ * arc authenticates in a `preHandler`, so a scope-keyed generator sees `PUBLIC_SCOPE`,
9
+ * returns the IP for every caller, and — behind a proxy — buckets an entire deployment
10
+ * together. Nothing throws; the limiter simply answers a question nobody asked.
11
+ *
12
+ * `Symbol.for` so the marker survives two copies of arc in one tree.
13
+ */
14
+ const SCOPE_AWARE_KEY_GENERATOR = Symbol.for("arc.rateLimit.scopeAwareKeyGenerator");
15
+ /** True when this generator needs a resolved scope (see the symbol's docblock). */
16
+ function isScopeAwareKeyGenerator(fn) {
17
+ return typeof fn === "function" && fn[SCOPE_AWARE_KEY_GENERATOR] === true;
18
+ }
19
+ function createTenantKeyGenerator(opts) {
20
+ const generator = opts?.strategy ?? defaultTenantStrategy;
21
+ /**
22
+ * Wrapped rather than tagged in place: a host's `strategy` is its own function, and
23
+ * stamping a symbol onto it would mutate a value it may reuse elsewhere.
24
+ */
25
+ const tagged = (ctx) => generator(ctx);
26
+ Object.defineProperty(tagged, SCOPE_AWARE_KEY_GENERATOR, {
27
+ value: true,
28
+ enumerable: false
29
+ });
30
+ return tagged;
31
+ }
32
+ function defaultTenantStrategy(ctx) {
33
+ const scope = ctx.scope;
34
+ if (!scope || scope.kind === "public") return ctx.ip;
35
+ if (scope.kind === "member") return scope.organizationId;
36
+ if (scope.kind === "service") return scope.organizationId;
37
+ if (scope.kind === "elevated") return scope.organizationId ?? scope.userId ?? ctx.ip;
38
+ return scope.userId ?? ctx.ip;
39
+ }
40
+ //#endregion
41
+ export { isScopeAwareKeyGenerator as n, createTenantKeyGenerator as t };
@@ -1,13 +1,13 @@
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 evaluateAndApplyPermission } from "./authorizationDecision-BP8GHtjc.mjs";
5
- import { n as getUserRoles } from "./userHelpers-CXySQFRg.mjs";
6
- import { c as getOrgId } from "./types-BqLyyH0o.mjs";
7
- import { t as simpleEqualityMatcher } from "./simpleEqualityMatcher-B7qVjQBv.mjs";
8
- import { t as applyFieldReadPermissions } from "./fields-Cha2QCKH.mjs";
9
- import { a as promoteStreamTokenToHeader } from "./streaming-DkpW1HwJ.mjs";
10
- import { t as openSseStream } from "./sseStream-BuMNPR6r.mjs";
4
+ import { n as evaluateAndApplyPermission } from "./authorizationDecision-D_LFvMlm.mjs";
5
+ import { n as getUserRoles } from "./userHelpers-DLueLQdQ.mjs";
6
+ import { c as getOrgId } from "./types-CNQyOrLk.mjs";
7
+ import { t as simpleEqualityMatcher } from "./simpleEqualityMatcher-Cldubvul.mjs";
8
+ import { t as applyFieldReadPermissions } from "./fields-fA-Dkou5.mjs";
9
+ import { a as promoteStreamTokenToHeader } from "./streaming-CFwCzEvU.mjs";
10
+ import { t as openSseStream } from "./sseStream-BfZtL5-m.mjs";
11
11
  import fp from "fastify-plugin";
12
12
  //#region src/plugins/realtime.ts
13
13
  var realtime_exports = /* @__PURE__ */ __exportAll({
@@ -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-stream.d.ts
4
4
  interface RedisStreamLike {
5
5
  xadd(key: string, id: string, ...fieldValues: string[]): Promise<string | null>;
@@ -232,8 +232,13 @@ declare class RedisStreamTransport implements EventTransport {
232
232
  private processEntries;
233
233
  private claimPending;
234
234
  private processEntry;
235
+ /**
236
+ * The canonical matcher from primitives — the SAME glob rules the memory
237
+ * transport speaks. A private matcher here once accepted `prefix.*` but not
238
+ * `prefix:*`, so an `order:*` subscription that worked in-process received
239
+ * nothing after a move to the stream, with no error.
240
+ */
235
241
  private getMatchingHandlers;
236
- private matchesPattern;
237
242
  private moveToDlq;
238
243
  /**
239
244
  * Reconstruct a `DeadLetteredEvent` for a message id. Reads the original
@@ -1,9 +1,9 @@
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 { r as deriveHiddenFieldPermissions } from "./fields-Cha2QCKH.mjs";
6
- import { n as requestContext } from "./requestContext-DpmntRZy.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 { r as deriveHiddenFieldPermissions } from "./fields-fA-Dkou5.mjs";
6
+ import { n as requestContext } from "./requestContext-D4PuGhEw.mjs";
7
7
  //#region src/core/middlewares/arcDecorator.ts
8
8
  /**
9
9
  * Build the `arcDecorator` preHandler for a resource.
@@ -1,6 +1,6 @@
1
1
 
2
- import { K as ResolvedTenantPurge, R as RegisterOptions, V as ResourceDefinition, X as CrudRouteKey, k as IntrospectionPluginOptions, p as RegistryEntry, z as ResourceRegistry } from "../index-B78WZom8.mjs";
3
- import "../fastify-augmentation-jYA2oHyL.mjs";
2
+ import { K as ResolvedTenantPurge, R as RegisterOptions, V as ResourceDefinition, X as CrudRouteKey, k as IntrospectionPluginOptions, p as RegistryEntry, z as ResourceRegistry } from "../index-D3sIPcD4.mjs";
3
+ import "../fastify-augmentation-HncZMmze.mjs";
4
4
  import { TenantPurgeProgress, TenantPurgeStrategy } from "@classytic/repo-core/repository";
5
5
  import { FastifyPluginAsync } from "fastify";
6
6
  //#region src/registry/assertNoTenantData.d.ts
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { a as cascadeDeleteForOrganization, c as assertNoTenantData, i as introspectionPlugin_default, n as buildResourceManifestFromRegistry, o as getCascadingResources, r as introspectionPlugin, s as getCascadingResourcesWithMetadata, t as buildResourceManifest } from "../registry-UFEJQN8R.mjs";
3
- import { t as ResourceRegistry } from "../ResourceRegistry-DPcX--zk.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { a as cascadeDeleteForOrganization, c as assertNoTenantData, i as introspectionPlugin_default, n as buildResourceManifestFromRegistry, o as getCascadingResources, r as introspectionPlugin, s as getCascadingResourcesWithMetadata, t as buildResourceManifest } from "../registry-CEpoRpLP.mjs";
3
+ import { t as ResourceRegistry } from "../ResourceRegistry-B9WnuG2Q.mjs";
4
4
  export { ResourceRegistry, assertNoTenantData, buildResourceManifest, buildResourceManifestFromRegistry, cascadeDeleteForOrganization, getCascadingResources, getCascadingResourcesWithMetadata, introspectionPlugin_default as introspectionPlugin, introspectionPlugin as introspectionPluginFn };
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.38.0 | MIT | https://classytic.com */
2
- import { t as CRUD_OPERATIONS } from "./constants-BONghE1Y.mjs";
1
+ /*! @classytic/arc v2.40.0 | MIT | https://classytic.com */
2
+ import { t as CRUD_OPERATIONS } from "./constants-BQ2FbhPB.mjs";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/registry/assertNoTenantData.ts
5
5
  /**
@@ -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/lock/renewingLease.ts
3
3
  /**
4
4
  * Start renewing an ALREADY-ACQUIRED lease. The caller performed the
@@ -1,5 +1,5 @@
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 { toCanonicalList } from "@classytic/repo-core/pagination";
4
4
  import fp from "fastify-plugin";
5
5
  //#region src/plugins/replyHelpers.ts
@@ -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 { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/context/requestContext.ts
4
4
  /**
@@ -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 "node:module";
3
3
  //#region \0rolldown/runtime.js
4
4
  var __defProp = Object.defineProperty;
@@ -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/runtimeCapabilities.ts
3
3
  /**
4
4
  * `Symbol.for` so declarations from two arc copies in one dependency graph