@classytic/arc 2.32.0 → 2.34.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 (193) hide show
  1. package/README.md +1 -1
  2. package/bin/arc.js +58 -17
  3. package/dist/{BaseController-Dk34dxhI.mjs → BaseController-CbkuhNI2.mjs} +329 -35
  4. package/dist/{EventTransport-2uVV34WU.d.mts → EventTransport-BEVP50ka.d.mts} +16 -0
  5. package/dist/{EventTransport-BV10D0oG.mjs → EventTransport-tq4CEB-q.mjs} +39 -2
  6. package/dist/{HookSystem-vimw5D7Z.mjs → HookSystem-DqXkMXkB.mjs} +2 -2
  7. package/dist/{ResourceRegistry-BVr7PgA0.mjs → ResourceRegistry-DoALUlOO.mjs} +3 -2
  8. package/dist/{actionPermissions-Dti7ebyv.mjs → actionPermissions-CUeCmpUd.mjs} +1 -1
  9. package/dist/audit/index.d.mts +2 -2
  10. package/dist/audit/index.mjs +2 -2
  11. package/dist/auth/audit.mjs +1 -1
  12. package/dist/auth/index.d.mts +2 -2
  13. package/dist/auth/index.mjs +39 -7
  14. package/dist/auth/redis-session.mjs +1 -1
  15. package/dist/{authorizationDecision-__T3EJDA.mjs → authorizationDecision-CMMLWmuZ.mjs} +6 -2
  16. package/dist/{types-B7XeLEgK.d.mts → base-Csjc2oF-.d.mts} +74 -74
  17. package/dist/{buildHandler-Dn7rzUJo.mjs → buildHandler-BrdYrG_1.mjs} +4 -4
  18. package/dist/cache/index.mjs +4 -4
  19. package/dist/{caching-DFJqHyFs.mjs → caching-BcGmvnHh.mjs} +2 -2
  20. package/dist/cleanup/index.d.mts +17 -5
  21. package/dist/cleanup/index.mjs +240 -7
  22. package/dist/cli/commands/describe.d.mts +1 -1
  23. package/dist/cli/commands/describe.mjs +3 -3
  24. package/dist/cli/commands/docs.mjs +3 -3
  25. package/dist/cli/commands/doctor.mjs +1 -1
  26. package/dist/cli/commands/generate.mjs +2 -2
  27. package/dist/cli/commands/init.mjs +2 -2
  28. package/dist/cli/commands/introspect.mjs +2 -2
  29. package/dist/cli/index.mjs +3 -3
  30. package/dist/{constants-J99LGTJI.mjs → constants-BxCoxmiN.mjs} +1 -1
  31. package/dist/context/index.mjs +3 -3
  32. package/dist/core/index.d.mts +3 -3
  33. package/dist/core/index.mjs +9 -8
  34. package/dist/{core-BwwmNSp7.mjs → core-BYKa8wHu.mjs} +3 -3
  35. package/dist/{createActionRouter-DkJZWo0m.mjs → createActionRouter-D6T0jWhS.mjs} +8 -8
  36. package/dist/{createAggregationRouter-B1exOVD8.mjs → createAggregationRouter-QLV2PrWP.mjs} +7 -7
  37. package/dist/{createApp-Bv0m-Q6_.mjs → createApp-zR-DEesr.mjs} +128 -24
  38. package/dist/{defineAggregation-gX4No1gt.mjs → defineAggregation-Nv-DwfOf.mjs} +1 -1
  39. package/dist/{defineResource-XFPPUu2c.mjs → defineResource-ZhuLonLm.mjs} +297 -23
  40. package/dist/discovery/index.mjs +1 -1
  41. package/dist/docs/index.d.mts +1 -1
  42. package/dist/docs/index.mjs +3 -3
  43. package/dist/{elevation-DNXXxgjl.mjs → elevation-B0tlY8y1.mjs} +4 -4
  44. package/dist/encryption/index.mjs +3 -3
  45. package/dist/{errorHandler-B2AZUJUj.mjs → errorHandler-C7xBqHsI.mjs} +42 -5
  46. package/dist/{errorHandler-CpYUJmPA.d.mts → errorHandler-DI5AN2b5.d.mts} +14 -3
  47. package/dist/{errors-Bh1KK5ps.mjs → errors-Cd_yy7aW.mjs} +1 -1
  48. package/dist/{eventPlugin-GF5nnBIq.d.mts → eventPlugin-DSNEZWfV.d.mts} +29 -1
  49. package/dist/{eventPlugin-Dk_TyXeE.mjs → eventPlugin-Dar8qRaj.mjs} +65 -9
  50. package/dist/events/index.d.mts +5 -351
  51. package/dist/events/index.mjs +5 -780
  52. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  53. package/dist/events/transports/redis-stream-entry.mjs +1 -1
  54. package/dist/events/transports/redis.d.mts +1 -1
  55. package/dist/events/transports/redis.mjs +1 -1
  56. package/dist/factory/index.d.mts +20 -5
  57. package/dist/factory/index.mjs +7 -7
  58. package/dist/{fastify-augmentation-BppG5bMT.d.mts → fastify-augmentation-DVsTAy6X.d.mts} +3 -3
  59. package/dist/{fields-DEi65pGj.mjs → fields-CojeUkS4.mjs} +1 -1
  60. package/dist/{generate-CRSG0jTv.mjs → generate-DiB0nHPR.mjs} +2 -2
  61. package/dist/{headers-BXjQYbeC.mjs → headers-CveNO9gR.mjs} +2 -2
  62. package/dist/{health-5XnTa2uo.mjs → health-CasG2A28.mjs} +1 -1
  63. package/dist/hooks/index.d.mts +1 -1
  64. package/dist/hooks/index.mjs +2 -2
  65. package/dist/idempotency/index.d.mts +45 -1
  66. package/dist/idempotency/index.mjs +90 -9
  67. package/dist/idempotency/redis.mjs +1 -1
  68. package/dist/{index-zq6VrjaB.d.mts → index-B-DvUzsr.d.mts} +12 -2
  69. package/dist/{index-CpzxqePp.d.mts → index-BcR2bFZQ.d.mts} +707 -373
  70. package/dist/{index-ZWhLTp_s.d.mts → index-C5NnMEKF.d.mts} +1 -1
  71. package/dist/{index-DXlHwvuE.d.mts → index-CFAJEWCX.d.mts} +18 -5
  72. package/dist/{index-C-481Zf2.d.mts → index-ugr1tQlW.d.mts} +17 -1
  73. package/dist/index.d.mts +6 -6
  74. package/dist/index.mjs +13 -12
  75. package/dist/{init-BbfP8aky.mjs → init-mdJ-v4Xp.mjs} +18 -12
  76. package/dist/integrations/event-gateway.d.mts +1 -1
  77. package/dist/integrations/event-gateway.mjs +2 -2
  78. package/dist/integrations/index.d.mts +2 -2
  79. package/dist/integrations/index.mjs +1 -1
  80. package/dist/integrations/jobs/index.d.mts +1 -1
  81. package/dist/integrations/jobs/index.mjs +99 -97
  82. package/dist/integrations/mcp/index.d.mts +12 -3
  83. package/dist/integrations/mcp/index.mjs +2 -2
  84. package/dist/integrations/mcp/testing.d.mts +1 -1
  85. package/dist/integrations/mcp/testing.mjs +2 -2
  86. package/dist/integrations/streamline.mjs +3 -3
  87. package/dist/integrations/webhooks.d.mts +124 -1
  88. package/dist/integrations/webhooks.mjs +180 -2
  89. package/dist/integrations/websocket-pushref-redis.mjs +1 -1
  90. package/dist/integrations/websocket-redis.mjs +1 -1
  91. package/dist/integrations/websocket.mjs +1 -1
  92. package/dist/{interface-BP4IJCBO.mjs → interface-DznJrm9R.mjs} +1 -1
  93. package/dist/{jsonBody-DDSR2HFl.mjs → jsonBody-CfGH-GxO.mjs} +2 -2
  94. package/dist/{keys-B-HBTGXl.mjs → keys-WeKvY1dE.mjs} +1 -1
  95. package/dist/{loadResources-DisEAmkm.mjs → loadResources-Bj-aSsXi.mjs} +2 -2
  96. package/dist/{loadResourcesFromEntry-D1MJp13f.mjs → loadResourcesFromEntry-DwaxNcE2.mjs} +2 -2
  97. package/dist/logger/index.mjs +1 -1
  98. package/dist/{mcpPlugin-CpfVpKHE.mjs → mcpPlugin-DX3PHD7K.mjs} +60 -21
  99. package/dist/{memory-DsuWnj4T.mjs → memory-qYSB7rMQ.mjs} +2 -2
  100. package/dist/{metrics-DdQL8syd.mjs → metrics-D7uchLjN.mjs} +2 -2
  101. package/dist/middleware/index.d.mts +1 -1
  102. package/dist/middleware/index.mjs +3 -3
  103. package/dist/migrations/index.mjs +2 -2
  104. package/dist/{module-Br81am6m.mjs → module-CwKsgZXp.mjs} +1 -1
  105. package/dist/{multipartBody-BnkBLN7v.mjs → multipartBody-4w-S3-PU.mjs} +1 -1
  106. package/dist/{openapi-DIRzvxC0.mjs → openapi-CkV5mQ53.mjs} +6 -6
  107. package/dist/outbox-admin/index.d.mts +2 -2
  108. package/dist/outbox-admin/index.mjs +4 -4
  109. package/dist/outbox-module-C1Bs_FXF.d.mts +382 -0
  110. package/dist/outbox-module-D1QfHqO4.mjs +846 -0
  111. package/dist/permissions/index.d.mts +2 -2
  112. package/dist/permissions/index.mjs +5 -5
  113. package/dist/{permissions-Dl_m0NCe.mjs → permissions-CP47jdi7.mjs} +25 -6
  114. package/dist/{pipe-ELHCP3zj.mjs → pipe-BzzoEhHj.mjs} +2 -2
  115. package/dist/pipeline/index.d.mts +1 -1
  116. package/dist/pipeline/index.mjs +2 -2
  117. package/dist/{pipeline-CPA-jx0M.mjs → pipeline-q69DZzgG.mjs} +6 -6
  118. package/dist/plugins/index.d.mts +6 -6
  119. package/dist/plugins/index.mjs +16 -16
  120. package/dist/plugins/response-cache.mjs +2 -2
  121. package/dist/plugins/tracing-entry.mjs +2 -2
  122. package/dist/{pluralize-C2ZkKbsn.mjs → pluralize-B7xf8qZF.mjs} +1 -1
  123. package/dist/{preloadResources-CDs87fTw.mjs → preloadResources-BkyqeTDz.mjs} +1 -1
  124. package/dist/{preloadResources-T1hmlTEZ.d.mts → preloadResources-g07ldtzh.d.mts} +30 -7
  125. package/dist/presets/filesUpload.d.mts +2 -2
  126. package/dist/presets/filesUpload.mjs +5 -5
  127. package/dist/presets/index.d.mts +2 -2
  128. package/dist/presets/index.mjs +2 -2
  129. package/dist/presets/multiTenant.d.mts +1 -1
  130. package/dist/presets/multiTenant.mjs +3 -3
  131. package/dist/presets/search.d.mts +2 -2
  132. package/dist/presets/search.mjs +2 -2
  133. package/dist/{presets-Dntd_pUO.mjs → presets-BAPijK_A.mjs} +4 -4
  134. package/dist/projection-BKM0Ui-s.mjs +42 -0
  135. package/dist/{queryCachePlugin-Dhps-Ldt.mjs → queryCachePlugin-DhsZ0ZIc.mjs} +49 -7
  136. package/dist/{rateLimit-C7mmAGs3.mjs → rateLimit-D4-ASwsI.mjs} +2 -2
  137. package/dist/{rateLimitKey-CccEFBfk.mjs → rateLimitKey-XngqVNEV.mjs} +1 -1
  138. package/dist/{realtime-DVvVZZFz.mjs → realtime-G1TC6Yzc.mjs} +9 -9
  139. package/dist/{redis-stream-qN6A-RFv.d.mts → redis-stream-mwLWlfHG.d.mts} +1 -1
  140. package/dist/{registerRoute-B_QrjYZS.mjs → registerRoute-Ba8v0PCa.mjs} +4 -4
  141. package/dist/registry/index.d.mts +3 -3
  142. package/dist/registry/index.mjs +3 -3
  143. package/dist/{registry-DqUmzA9W.mjs → registry-CLxCR5LF.mjs} +2 -2
  144. package/dist/{renewingLease-BpP9wwj7.mjs → renewingLease-BnWtbA2U.mjs} +1 -1
  145. package/dist/{replyHelpers-DS-P0b32.mjs → replyHelpers-BSBVCwL3.mjs} +2 -2
  146. package/dist/repositoryFilter-BANpz6BX.mjs +78 -0
  147. package/dist/{requestContext-B6vQF-sy.mjs → requestContext-uYE35JxI.mjs} +1 -1
  148. package/dist/{rolldown-runtime-BhflRrBs.mjs → rolldown-runtime-DNg-KNCk.mjs} +1 -1
  149. package/dist/runtimeCapabilities-Dm88DaTW.mjs +49 -0
  150. package/dist/{schedules-C2Q3uv2d.mjs → schedules-CAcZgia0.mjs} +3 -3
  151. package/dist/{schemaConverter-Crjvczi_.mjs → schemaConverter-XH1RZRyu.mjs} +1 -1
  152. package/dist/{schemaIR-CnyKK_1j.mjs → schemaIR-CDvclAew.mjs} +2 -2
  153. package/dist/schemas/index.mjs +1 -1
  154. package/dist/scim/index.mjs +2 -2
  155. package/dist/scope/index.mjs +5 -5
  156. package/dist/{scope-afz_Ieek.mjs → scope-BaWcqBvr.mjs} +4 -4
  157. package/dist/{simpleEqualityMatcher-C4KiMWUa.mjs → simpleEqualityMatcher-Se8VrsaP.mjs} +1 -1
  158. package/dist/{sse-B9P4Y-UI.mjs → sse-Cf0jUHsh.mjs} +5 -5
  159. package/dist/{sseStream-B3zb_d1h.mjs → sseStream-Bvpi-UXQ.mjs} +2 -2
  160. package/dist/{store-helpers-DmEMHlPQ.mjs → store-helpers-B88p99Z2.mjs} +1 -1
  161. package/dist/{streaming-DPZdQmDz.mjs → streaming-DsT1B5zJ.mjs} +1 -1
  162. package/dist/{subscribe-helpers-sp5xTDVA.mjs → subscribe-helpers-CLIOHsOK.mjs} +2 -2
  163. package/dist/sync/changelog.mjs +1 -1
  164. package/dist/testing/cleanupStoreContract.d.mts +1 -1
  165. package/dist/testing/cleanupStoreContract.mjs +3 -1
  166. package/dist/testing/index.d.mts +24 -12
  167. package/dist/testing/index.mjs +24 -12
  168. package/dist/testing/outboxStoreContract.mjs +1 -1
  169. package/dist/testing/storageContract.mjs +1 -1
  170. package/dist/{transactionContext-BvLKvOIL.mjs → transactionContext-BYtWnwAS.mjs} +1 -1
  171. package/dist/{typeGuards-B_5-hKjJ.mjs → typeGuards-jjKJDN13.mjs} +1 -1
  172. package/dist/types/index.d.mts +3 -3
  173. package/dist/types/index.mjs +1 -1
  174. package/dist/types/storage.mjs +1 -1
  175. package/dist/{types-CT5vu6M0.d.mts → types-BcTumAz_.d.mts} +41 -7
  176. package/dist/{types-CwcUQ610.d.mts → types-BfC83KsP.d.mts} +15 -1
  177. package/dist/{types-DXYX7dIR.mjs → types-CoqIRrkY.mjs} +4 -4
  178. package/dist/{types-C4QE8qnm.d.mts → types-DVLddu2q.d.mts} +144 -1
  179. package/dist/usage/index.d.mts +1 -1
  180. package/dist/usage/index.mjs +0 -0
  181. package/dist/{userHelpers-BNsOXzOd.mjs → userHelpers-CWF5pbZD.mjs} +1 -1
  182. package/dist/utils/index.d.mts +57 -5
  183. package/dist/utils/index.mjs +12 -11
  184. package/dist/{utils-BtOha_Sp.mjs → utils-h1V_sT-t.mjs} +38 -7
  185. package/dist/{validate-PMCPR9El.mjs → validate-CdQlz52F.mjs} +2 -2
  186. package/dist/{versioning-D_rhHfZm.d.mts → versioning-DEs-_hFi.d.mts} +1 -1
  187. package/dist/{versioning-CKv2jz_U.mjs → versioning-rZbyLVD-.mjs} +3 -3
  188. package/package.json +17 -16
  189. package/skills/arc/SKILL.md +96 -4
  190. package/skills/arc/references/api-reference.md +19 -0
  191. package/skills/arc/references/production.md +2 -2
  192. package/dist/projection-CjHhM5W1.mjs +0 -18
  193. package/dist/repositoryFilter-DotlxG3L.mjs +0 -45
@@ -1,6 +1,6 @@
1
1
 
2
- import "../index-CpzxqePp.mjs";
3
- import { a as UserBase } from "../types-B7XeLEgK.mjs";
2
+ import { d as UserBase } from "../base-Csjc2oF-.mjs";
3
+ import "../index-BcR2bFZQ.mjs";
4
4
  import { FastifyPluginAsync } from "fastify";
5
5
  import { RepositoryLike } from "@classytic/repo-core/adapter";
6
6
  //#region src/audit/stores/interface.d.ts
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { t as transactionContext } from "../transactionContext-BvLKvOIL.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { t as transactionContext } from "../transactionContext-BYtWnwAS.mjs";
3
3
  import { and, anyOf, eq, gte, lt, lte } from "@classytic/repo-core/filter";
4
4
  import fp from "fastify-plugin";
5
5
  //#region src/audit/repository-audit-adapter.ts
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  //#region src/auth/audit.ts
3
3
  function compileGlobs(patterns) {
4
4
  if (patterns.length === 0) return () => false;
@@ -1,6 +1,6 @@
1
1
 
2
- import { Ut as AuthHelpers, Wt as AuthPluginOptions } from "../index-CpzxqePp.mjs";
3
- import { r as PermissionCheck } from "../types-B7XeLEgK.mjs";
2
+ import { l as PermissionCheck } from "../base-Csjc2oF-.mjs";
3
+ import { Ft as AuthPluginOptions, Pt as AuthHelpers } from "../index-BcR2bFZQ.mjs";
4
4
  import { t as ExternalOpenApiPaths } from "../externalPaths-CmGOxOtD.mjs";
5
5
  import { a as SessionManagerOptions, c as createSessionManager, i as SessionData, n as MemorySessionStoreOptions, o as SessionManagerResult, r as SessionCookieOptions, s as SessionStore, t as MemorySessionStore } from "../sessionManager-qimlKV0P.mjs";
6
6
  import { FastifyPluginAsync, FastifyReply as FastifyReply$1, FastifyRequest } from "fastify";
@@ -1,9 +1,10 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { d as createDomainError, l as UnauthorizedError, p as isArcError, t as ArcError } from "../errors-Bh1KK5ps.mjs";
3
- import { n as requireSingleHeaderValue } from "../headers-BXjQYbeC.mjs";
4
- import { n as getUserRoles, r as normalizeRoles } from "../userHelpers-BNsOXzOd.mjs";
5
- import { o as toJsonSchema } from "../schemaConverter-Crjvczi_.mjs";
6
- import { E as requireOrgRole, T as requireOrgMembership, k as requireTeamMembership } from "../permissions-Dl_m0NCe.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { d as createDomainError, l as UnauthorizedError, p as isArcError, t as ArcError } from "../errors-Cd_yy7aW.mjs";
3
+ import { n as requireSingleHeaderValue } from "../headers-CveNO9gR.mjs";
4
+ import { n as getUserRoles, r as normalizeRoles } from "../userHelpers-CWF5pbZD.mjs";
5
+ import { o as toJsonSchema } from "../schemaConverter-XH1RZRyu.mjs";
6
+ import { E as requireOrgRole, T as requireOrgMembership, k as requireTeamMembership } from "../permissions-CP47jdi7.mjs";
7
+ import { isProductionEnv } from "@classytic/primitives/environment";
7
8
  import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
8
9
  import fp from "fastify-plugin";
9
10
  //#region src/auth/authPlugin.ts
@@ -861,6 +862,25 @@ function createBetterAuthAdapter(options) {
861
862
  if (openapiOpt === false) extractedOpenApi = void 0;
862
863
  else if (typeof openapiOpt === "object") extractedOpenApi = openapiOpt;
863
864
  const betterAuthPlugin = async (fastify) => {
865
+ /**
866
+ * `orgContext` without the `organization()` plugin is a SILENT
867
+ * misconfiguration, so it fails at boot instead.
868
+ *
869
+ * Arc resolves org membership through `auth.api.getActiveMember` /
870
+ * `getActiveMemberRole`. Absent the plugin those methods do not exist,
871
+ * every lookup returns null, and `request.scope` silently stays
872
+ * `'authenticated'` — so `requireOrgId()` throws 403 on every
873
+ * tenant-scoped route. It fails CLOSED (no data leak), but the symptom
874
+ * points nowhere near the cause: the host sees blanket 403s and no
875
+ * indication that a plugin is missing. One check at registration turns
876
+ * that into a sentence.
877
+ */
878
+ if (orgEnabled) {
879
+ if (!(pickApiMethod(auth, "getActiveMember", "organization") !== void 0 || pickApiMethod(auth, "getActiveMemberRole", "organization") !== void 0)) throw new ArcError("createBetterAuthAdapter({ orgContext: true }) requires Better Auth's `organization()` plugin — `auth.api.getActiveMember` / `getActiveMemberRole` are missing. Without it arc can never resolve membership, so request.scope stays 'authenticated' and every tenant-scoped route answers 403. Add `organization()` to your betterAuth({ plugins }), or drop `orgContext`.", {
880
+ code: "BETTER_AUTH_ORG_PLUGIN_MISSING",
881
+ statusCode: 500
882
+ });
883
+ }
864
884
  const routeOpts = options.rateLimit && typeof options.rateLimit === "object" ? { config: { rateLimit: options.rateLimit } } : {};
865
885
  fastify.all(`${normalizedBase}/*`, routeOpts, async (request, reply) => {
866
886
  try {
@@ -994,7 +1014,19 @@ function buildSetCookieHeader(name, value, maxAgeSeconds, options) {
994
1014
  `Path=${options.path ?? "/"}`
995
1015
  ];
996
1016
  if (options.httpOnly !== false) parts.push("HttpOnly");
997
- if (options.secure ?? process.env.NODE_ENV === "production") parts.push("Secure");
1017
+ /**
1018
+ * `Secure` defaults to "is this a production environment?" — via the shared classifier, NOT a
1019
+ * raw `NODE_ENV === "production"` comparison.
1020
+ *
1021
+ * The raw form shipped session cookies WITHOUT `Secure` on any deployment using `NODE_ENV=prod`,
1022
+ * because that comparison recognises only the long spelling. A cookie without `Secure` is sent
1023
+ * over plaintext HTTP, so a session token becomes interceptable — and nothing anywhere reports
1024
+ * it: the cookie is set, login works, the app behaves normally.
1025
+ *
1026
+ * `options.secure` still wins when stated (`??`), including an explicit `false` for local HTTP
1027
+ * development. Only the DEFAULT changed, and only in the direction of being correct more often.
1028
+ */
1029
+ if (options.secure ?? isProductionEnv(process.env.NODE_ENV)) parts.push("Secure");
998
1030
  parts.push(`SameSite=${capitalize(options.sameSite ?? "lax")}`);
999
1031
  if (options.domain) parts.push(`Domain=${options.domain}`);
1000
1032
  return parts.join("; ");
@@ -1,4 +1,4 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  import sjson from "secure-json-parse";
3
3
  //#region src/auth/redis-session.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
2
  import { arcLog } from "./logger/index.mjs";
3
- import { t as ArcError } from "./errors-Bh1KK5ps.mjs";
3
+ import { t as ArcError } from "./errors-Cd_yy7aW.mjs";
4
4
  //#region src/permissions/filter-merge.ts
5
5
  /**
6
6
  * Policy-filter composition — logical AND, never last-writer-wins.
@@ -91,6 +91,10 @@ function conjoinPolicyFilters(base, incoming) {
91
91
  delete result[key];
92
92
  }
93
93
  if (andParts.length > 0) result.$and = andParts;
94
+ for (const source of [base, incoming]) for (const symbol of Object.getOwnPropertySymbols(source)) {
95
+ const descriptor = Object.getOwnPropertyDescriptor(source, symbol);
96
+ if (descriptor) Object.defineProperty(result, symbol, descriptor);
97
+ }
94
98
  return result;
95
99
  }
96
100
  //#endregion
@@ -1,79 +1,6 @@
1
1
 
2
2
  import { i as RequestScope } from "./types-ChuShpCP.mjs";
3
3
  import { FastifyRequest } from "fastify";
4
- //#region src/types/base.d.ts
5
- declare module "fastify" {
6
- interface FastifyRequest {
7
- /** Request scope — set by auth adapter, read by permissions/presets/guards */
8
- scope: RequestScope;
9
- /**
10
- * Current user — set by auth adapter (Better Auth, JWT, custom).
11
- * `undefined` on public routes (`auth: false`) or unauthenticated requests.
12
- * Guard with `if (request.user)` on routes that allow anonymous access.
13
- *
14
- * Kept as required (not `user?`) because `@fastify/jwt` declares it
15
- * as required — declaration merges must have identical modifiers.
16
- * The `| undefined` in the type achieves the same DX.
17
- */
18
- user: Record<string, unknown> | undefined;
19
- /** Policy-injected query filters (e.g. ownership, org-scoping) */
20
- _policyFilters?: Record<string, unknown>;
21
- /** Field mask — fields to include/exclude in responses */
22
- fieldMask?: {
23
- include?: string[];
24
- exclude?: string[];
25
- };
26
- /** Arbitrary policy metadata for downstream consumers */
27
- policyMetadata?: Record<string, unknown>;
28
- /** Document loaded by policy middleware for ownership checks */
29
- document?: unknown;
30
- /** Ownership check context (field name + user field) */
31
- _ownershipCheck?: Record<string, unknown>;
32
- }
33
- }
34
- type AnyRecord = Record<string, unknown>;
35
- /** MongoDB ObjectId — accepts string or any object with a `toString()` (e.g. mongoose ObjectId). */
36
- type ObjectId = string | {
37
- toString(): string;
38
- };
39
- /**
40
- * Flexible user type that accepts any object with id/_id properties.
41
- * The actual user structure is defined by your app's auth system.
42
- */
43
- type UserLike = UserBase & {
44
- /** User email (optional) */
45
- email?: string;
46
- };
47
- interface UserOrganization {
48
- userId: string;
49
- organizationId: string;
50
- [key: string]: unknown;
51
- }
52
- interface JWTPayload {
53
- sub: string;
54
- [key: string]: unknown;
55
- }
56
- /**
57
- * Typed Fastify request with Arc decorations. Use in `rawHandler` routes
58
- * instead of `(req as any).user`.
59
- *
60
- * @example
61
- * ```typescript
62
- * import type { ArcRequest } from '@classytic/arc';
63
- *
64
- * handler: async (req: ArcRequest, reply) => {
65
- * req.user?.id; // typed
66
- * req.scope.organizationId; // typed (when member)
67
- * req.signal; // AbortSignal (Fastify 5)
68
- * }
69
- * ```
70
- */
71
- type ArcRequest = FastifyRequest & {
72
- scope: RequestScope;
73
- user: Record<string, unknown> | undefined;
74
- signal: AbortSignal;
75
- };
76
- //#endregion
77
4
  //#region src/utils/userHelpers.d.ts
78
5
  /**
79
6
  * Extract a user ID from a user object. Accepts `id` or `_id` — returns
@@ -324,4 +251,77 @@ interface PermissionCheckMeta {
324
251
  _conditional?: boolean;
325
252
  }
326
253
  //#endregion
327
- export { UserBase as a, normalizeRoles as c, JWTPayload as d, ObjectId as f, PermissionContext as i, AnyRecord as l, UserOrganization as m, DataPolicy as n, getUserId as o, UserLike as p, PermissionCheck as r, getUserRoles as s, AuthorizationDecision as t, ArcRequest as u };
254
+ //#region src/types/base.d.ts
255
+ declare module "fastify" {
256
+ interface FastifyRequest {
257
+ /** Request scope — set by auth adapter, read by permissions/presets/guards */
258
+ scope: RequestScope;
259
+ /**
260
+ * Current user — set by auth adapter (Better Auth, JWT, custom).
261
+ * `undefined` on public routes (`auth: false`) or unauthenticated requests.
262
+ * Guard with `if (request.user)` on routes that allow anonymous access.
263
+ *
264
+ * Kept as required (not `user?`) because `@fastify/jwt` declares it
265
+ * as required — declaration merges must have identical modifiers.
266
+ * The `| undefined` in the type achieves the same DX.
267
+ */
268
+ user: Record<string, unknown> | undefined;
269
+ /** Policy-injected query filters (e.g. ownership, org-scoping) */
270
+ _policyFilters?: Record<string, unknown>;
271
+ /** Field mask — fields to include/exclude in responses */
272
+ fieldMask?: {
273
+ include?: string[];
274
+ exclude?: string[];
275
+ };
276
+ /** Arbitrary policy metadata for downstream consumers */
277
+ policyMetadata?: Record<string, unknown>;
278
+ /** Document loaded by policy middleware for ownership checks */
279
+ document?: unknown;
280
+ /** Ownership check context (field name + user field) */
281
+ _ownershipCheck?: Record<string, unknown>;
282
+ }
283
+ }
284
+ type AnyRecord = Record<string, unknown>;
285
+ /** MongoDB ObjectId — accepts string or any object with a `toString()` (e.g. mongoose ObjectId). */
286
+ type ObjectId = string | {
287
+ toString(): string;
288
+ };
289
+ /**
290
+ * Flexible user type that accepts any object with id/_id properties.
291
+ * The actual user structure is defined by your app's auth system.
292
+ */
293
+ type UserLike = UserBase & {
294
+ /** User email (optional) */
295
+ email?: string;
296
+ };
297
+ interface UserOrganization {
298
+ userId: string;
299
+ organizationId: string;
300
+ [key: string]: unknown;
301
+ }
302
+ interface JWTPayload {
303
+ sub: string;
304
+ [key: string]: unknown;
305
+ }
306
+ /**
307
+ * Typed Fastify request with Arc decorations. Use in `rawHandler` routes
308
+ * instead of `(req as any).user`.
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * import type { ArcRequest } from '@classytic/arc';
313
+ *
314
+ * handler: async (req: ArcRequest, reply) => {
315
+ * req.user?.id; // typed
316
+ * req.scope.organizationId; // typed (when member)
317
+ * req.signal; // AbortSignal (Fastify 5)
318
+ * }
319
+ * ```
320
+ */
321
+ type ArcRequest = FastifyRequest & {
322
+ scope: RequestScope;
323
+ user: Record<string, unknown> | undefined;
324
+ signal: AbortSignal;
325
+ };
326
+ //#endregion
327
+ export { UserLike as a, DataPolicy as c, UserBase as d, getUserId as f, ObjectId as i, PermissionCheck as l, normalizeRoles as m, ArcRequest as n, UserOrganization as o, getUserRoles as p, JWTPayload as r, AuthorizationDecision as s, AnyRecord as t, PermissionContext as u };
@@ -1,7 +1,7 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { a as conjoinPolicyFilters } from "./authorizationDecision-__T3EJDA.mjs";
3
- import { t as toRepositoryFilter } from "./repositoryFilter-DotlxG3L.mjs";
4
- import { i as compileAggRequest, t as adapterSupportsAggregate } from "./validate-PMCPR9El.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { a as conjoinPolicyFilters } from "./authorizationDecision-CMMLWmuZ.mjs";
3
+ import { n as toRepositoryFilter } from "./repositoryFilter-BANpz6BX.mjs";
4
+ import { i as compileAggRequest, t as adapterSupportsAggregate } from "./validate-CdQlz52F.mjs";
5
5
  //#region src/core/aggregation/buildHandler.ts
6
6
  /**
7
7
  * Framework-agnostic aggregation execution. Runs safety guards,
@@ -1,7 +1,7 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { i as versionKey, n as hashParams, r as tagVersionKey, t as buildQueryKey } from "../keys-B-HBTGXl.mjs";
3
- import { t as MemoryCacheStore } from "../memory-DsuWnj4T.mjs";
4
- import { r as QueryCache, t as queryCachePlugin } from "../queryCachePlugin-Dhps-Ldt.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { i as versionKey, n as hashParams, r as tagVersionKey, t as buildQueryKey } from "../keys-WeKvY1dE.mjs";
3
+ import { t as MemoryCacheStore } from "../memory-qYSB7rMQ.mjs";
4
+ import { r as QueryCache, t as queryCachePlugin } from "../queryCachePlugin-DhsZ0ZIc.mjs";
5
5
  //#region src/cache/redis.ts
6
6
  /**
7
7
  * Redis-backed cache store.
@@ -1,5 +1,5 @@
1
- /*! @classytic/arc v2.32.0 | MIT | https://classytic.com */
2
- import { t as __exportAll } from "./rolldown-runtime-BhflRrBs.mjs";
1
+ /*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
2
+ import { t as __exportAll } from "./rolldown-runtime-DNg-KNCk.mjs";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/plugins/caching.ts
5
5
  var caching_exports = /* @__PURE__ */ __exportAll({
@@ -1,7 +1,7 @@
1
1
 
2
- import { L as RequestWithExtras } from "../index-CpzxqePp.mjs";
3
- import { A as CleanupWriteFence, C as CleanupResult, D as CleanupRunStore, E as CleanupRunStatus, F as PurgeStrategyKind, I as PurgeVerificationSummary, L as VerificationCheck, M as PurgeActor, N as PurgeEvidence, O as CleanupRunTransitionPatch, P as PurgeResourceResult, R as VerificationResult, S as CleanupRecipe, T as CleanupRunCreateResult, _ as CleanupPermissions, a as CleanupEvidenceStore, b as CleanupPlanItem, c as CleanupInput, d as CleanupLease, f as CleanupLimits, g as CleanupPermissionCheck, h as CleanupOutcomeStatus, i as CleanupContext, j as DEFAULT_CLEANUP_LIMITS, k as CleanupStepResult, l as CleanupJob, m as CleanupManifest, n as CLEANUP_TERMINAL_STATUSES, o as CleanupExecutionContext, p as CleanupLogger, r as CleanupCancelRequest, s as CleanupFinalizationPayload, t as Availability, u as CleanupJobQueue, v as CleanupPlan, w as CleanupRun, x as CleanupProgressSummary, y as CleanupPlanDraft } from "../types-C4QE8qnm.mjs";
4
- import { t as ArcModule } from "../types-CT5vu6M0.mjs";
2
+ import { L as RequestWithExtras } from "../index-BcR2bFZQ.mjs";
3
+ import { A as CleanupStepResult, B as VerificationResult, C as CleanupResult, D as CleanupRunStore, E as CleanupRunStatus, F as PurgeEvidence, I as PurgeResourceResult, L as PurgeStrategyKind, M as CleanupWriteFence, N as DEFAULT_CLEANUP_LIMITS, O as CleanupRunTransitionPatch, P as PurgeActor, R as PurgeVerificationSummary, S as CleanupRecipe, T as CleanupRunCreateResult, _ as CleanupPermissions, a as CleanupEvidenceStore, b as CleanupPlanItem, c as CleanupInput, d as CleanupLease, f as CleanupLimits, g as CleanupPermissionCheck, h as CleanupOutcomeStatus, i as CleanupContext, j as CleanupStepRunStatus, k as CleanupStepProgress, l as CleanupJob, m as CleanupManifest, n as CLEANUP_TERMINAL_STATUSES, o as CleanupExecutionContext, p as CleanupLogger, r as CleanupCancelRequest, s as CleanupFinalizationPayload, t as Availability, u as CleanupJobQueue, v as CleanupPlan, w as CleanupRun, x as CleanupProgressSummary, y as CleanupPlanDraft, z as VerificationCheck } from "../types-DVLddu2q.mjs";
4
+ import { t as ArcModule } from "../types-BcTumAz_.mjs";
5
5
  import { PurgeStrategyKind as PurgeStrategyKind$1 } from "@classytic/primitives/retention";
6
6
  import { canonicalJson } from "@classytic/primitives/canonical";
7
7
  import { CleanupStep } from "@classytic/repo-core/cleanup";
@@ -75,7 +75,9 @@ type CleanupErrorCode =
75
75
  /** No authenticated actor could be resolved for a destructive action (fail-closed). */
76
76
  "CLEANUP_ACTOR_REQUIRED" |
77
77
  /** Caller lacks permission for the operation. */
78
- "CLEANUP_FORBIDDEN";
78
+ "CLEANUP_FORBIDDEN" |
79
+ /** The exclusion list names an unknown or protective step (fail-closed). */
80
+ "CLEANUP_INVALID_EXCLUSION";
79
81
  /**
80
82
  * A framework error carrying BOTH `status` (read directly in code/tests) and
81
83
  * `statusCode` (the Fastify convention arc's global error handler recognizes,
@@ -112,6 +114,16 @@ declare const CleanupErrors: {
112
114
  readonly alreadyRunning: (runId: string) => CleanupError;
113
115
  readonly runNotFound: (id: string) => CleanupError;
114
116
  readonly invalidAction: (action: string, status: string) => CleanupError;
117
+ /**
118
+ * The operator's exclusion list cannot be honoured as written.
119
+ *
120
+ * A 400 rather than a filter: dropping an unrecognised exclusion leaves
121
+ * someone believing they narrowed a destructive run when they did not, and
122
+ * dropping a PROTECTIVE one would let a guard be switched off from the same
123
+ * request that starts the run. `steps` carries the offending ids so a UI can
124
+ * point at them.
125
+ */
126
+ readonly invalidExclusion: (reason: string, steps: readonly string[]) => CleanupError;
115
127
  readonly forbidden: (operation: string) => CleanupError;
116
128
  };
117
129
  //#endregion
@@ -333,4 +345,4 @@ declare function computePlanDigest(plan: Omit<CleanupPlan, "digest">): string;
333
345
  */
334
346
  declare function computeManifestDigest(manifest: Record<string, unknown>): string;
335
347
  //#endregion
336
- export { type Availability, CLEANUP_TERMINAL_STATUSES, type CancelInput, type CleanupCancelRequest, CleanupCancelled, type CleanupContext, CleanupError, type CleanupErrorCode, CleanupErrors, type CleanupEvidenceStore, type CleanupExecutionContext, type CleanupFinalizationPayload, type CleanupInput, type CleanupJob, type CleanupJobQueue, type CleanupLease, type CleanupLimits, type CleanupLogger, type CleanupManifest, type CleanupOutcomeStatus, type CleanupPermissionCheck, type CleanupPermissions, type CleanupPlan, type CleanupPlanDraft, type CleanupPlanItem, type CleanupProgressSummary, type CleanupRecipe, type CleanupRecipeInfo, type CleanupRegistry, type CleanupResult, type CleanupRun, type CleanupRunCreateResult, type CleanupRunStatus, type CleanupRunStore, type CleanupRunTransitionPatch, type CleanupService, type CleanupServiceDeps, type CleanupStepResult, type CleanupWriteFence, DEFAULT_CLEANUP_LIMITS, type DataCleanupModuleDeps, type ExecuteInput, GLOBAL_DESTRUCTIVE_KEY, MemoryCleanupEvidenceStore, MemoryCleanupJobQueue, MemoryCleanupRunStore, type PreviewInput, type PurgeActor, type PurgeEvidence, type PurgeResourceResult, type PurgeStrategyKind, type PurgeVerificationSummary, type RecipeFromStepsInput, type VerificationCheck, type VerificationResult, canonicalJson, computeManifestDigest, computePlanDigest, createCleanupRegistry, createCleanupService, createDataCleanupModule, recipeFromSteps };
348
+ export { type Availability, CLEANUP_TERMINAL_STATUSES, type CancelInput, type CleanupCancelRequest, CleanupCancelled, type CleanupContext, CleanupError, type CleanupErrorCode, CleanupErrors, type CleanupEvidenceStore, type CleanupExecutionContext, type CleanupFinalizationPayload, type CleanupInput, type CleanupJob, type CleanupJobQueue, type CleanupLease, type CleanupLimits, type CleanupLogger, type CleanupManifest, type CleanupOutcomeStatus, type CleanupPermissionCheck, type CleanupPermissions, type CleanupPlan, type CleanupPlanDraft, type CleanupPlanItem, type CleanupProgressSummary, type CleanupRecipe, type CleanupRecipeInfo, type CleanupRegistry, type CleanupResult, type CleanupRun, type CleanupRunCreateResult, type CleanupRunStatus, type CleanupRunStore, type CleanupRunTransitionPatch, type CleanupService, type CleanupServiceDeps, type CleanupStepProgress, type CleanupStepResult, type CleanupStepRunStatus, type CleanupWriteFence, DEFAULT_CLEANUP_LIMITS, type DataCleanupModuleDeps, type ExecuteInput, GLOBAL_DESTRUCTIVE_KEY, MemoryCleanupEvidenceStore, MemoryCleanupJobQueue, MemoryCleanupRunStore, type PreviewInput, type PurgeActor, type PurgeEvidence, type PurgeResourceResult, type PurgeStrategyKind, type PurgeVerificationSummary, type RecipeFromStepsInput, type VerificationCheck, type VerificationResult, canonicalJson, computeManifestDigest, computePlanDigest, createCleanupRegistry, createCleanupService, createDataCleanupModule, recipeFromSteps };