@classytic/arc 2.46.0 → 2.48.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.
- package/dist/{EventTransport-DNgD9NP4.mjs → EventTransport-BWwg5YAU.mjs} +4 -4
- package/dist/{HookSystem-DRbPzEcP.mjs → HookSystem-B9x-Y_k7.mjs} +2 -2
- package/dist/{ResourceRegistry-Douk51fa.mjs → ResourceRegistry-BcvEJoZd.mjs} +2 -2
- package/dist/{acquire-RbtvDg9s.mjs → acquire-D2yj6Zzl.mjs} +1 -1
- package/dist/{actionPermissions-De0AJ7hm.mjs → actionPermissions-Dha8sAz2.mjs} +13 -13
- package/dist/audit/index.d.mts +1 -1
- package/dist/audit/index.mjs +4 -4
- package/dist/auth/audit.mjs +1 -1
- package/dist/auth/index.d.mts +1 -1
- package/dist/auth/index.mjs +7 -7
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/{authorizationDecision-DeZMrHcm.mjs → authorizationDecision-BZSJcPNE.mjs} +4 -4
- package/dist/{boundedMap-2WBh3gM9.mjs → boundedMap-o2KZDCWy.mjs} +1 -1
- package/dist/{buildHandler-DxVOOBpw.mjs → buildHandler-G3k59KY2.mjs} +4 -4
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-BYRwYrUo.mjs → caching-CJIDPZOv.mjs} +2 -2
- package/dist/{claimed-DYlELdnm.mjs → claimed-D0A43wjT.mjs} +1 -1
- package/dist/cleanup/index.d.mts +1 -1
- package/dist/cleanup/index.mjs +4 -4
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/describe.mjs +3 -3
- package/dist/cli/commands/docs.mjs +3 -3
- package/dist/cli/commands/doctor.mjs +1 -1
- package/dist/cli/commands/generate.mjs +2 -2
- package/dist/cli/commands/init.mjs +2 -2
- package/dist/cli/commands/introspect.mjs +2 -2
- package/dist/cli/index.mjs +3 -3
- package/dist/{constants-CHZMUwBW.mjs → constants-D-faL5SX.mjs} +1 -1
- package/dist/context/index.mjs +5 -5
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +7 -7
- package/dist/{core-D9rS2BxO.mjs → core-NSu1peyq.mjs} +3 -3
- package/dist/{createActionRouter-0qkCRzTL.mjs → createActionRouter-DTSVv1VK.mjs} +6 -6
- package/dist/{createAggregationRouter-CUf5Esd9.mjs → createAggregationRouter-zEasm-ax.mjs} +7 -7
- package/dist/{createApp-DZIXfDKD.mjs → createApp-CjqhkX1x.mjs} +29 -29
- package/dist/{createMcpServer-DeVpqQF-.d.mts → createMcpServer-hSFeqRUb.d.mts} +9 -10
- package/dist/{defineAggregation-bmKQ4NmC.mjs → defineAggregation-DH2L6_v9.mjs} +1 -1
- package/dist/{defineResource-CGmdmGwh.mjs → defineResource-zYCrhNaN.mjs} +10 -8
- package/dist/discovery/index.mjs +1 -1
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +3 -3
- package/dist/{elevation-CzhqAyVN.mjs → elevation-z--rFcZ5.mjs} +5 -5
- package/dist/encryption/index.mjs +3 -3
- package/dist/{errorHandler-dFyGOEoB.mjs → errorHandler-3_3oN-Uc.mjs} +3 -3
- package/dist/{errors-BY8vzlP4.mjs → errors-DyY48oRi.mjs} +1 -1
- package/dist/{eventPlugin-eMhAPtQA.mjs → eventPlugin-Co9sABCg.mjs} +8 -8
- package/dist/{eventTypes-Do2KYeJx.mjs → eventTypes-HmAFyJmJ.mjs} +2 -2
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +8 -7
- package/dist/events/transports/redis-stream-entry.mjs +4 -4
- package/dist/events/transports/redis.mjs +2 -2
- package/dist/factory/index.d.mts +3 -3
- package/dist/factory/index.mjs +6 -6
- package/dist/{fastify-augmentation-Dtn0IIRn.d.mts → fastify-augmentation-bzkWPt1f.d.mts} +2 -2
- package/dist/{fields-LnbCcvsw.mjs → fields-rfsl26Ov.mjs} +1 -1
- package/dist/{filter-merge-BAWi019Q.mjs → filter-merge-8glLr7Dk.mjs} +1 -1
- package/dist/{generate-oXoDnpJf.mjs → generate-BOfBueRt.mjs} +2 -2
- package/dist/{headers-DBd3Qheo.mjs → headers-CHSOqpcY.mjs} +2 -2
- package/dist/{health-BlJu9GXS.mjs → health-DHvAIVmM.mjs} +1 -1
- package/dist/{health-Dp-3EC9o.mjs → health-ezwTHQh2.mjs} +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/http-cache/index.d.mts +211 -0
- package/dist/http-cache/index.mjs +605 -0
- package/dist/http-cache/purgers/cloudflare.d.mts +13 -0
- package/dist/http-cache/purgers/cloudflare.mjs +46 -0
- package/dist/http-cache/purgers/fastly.d.mts +12 -0
- package/dist/http-cache/purgers/fastly.mjs +47 -0
- package/dist/http-cache/testing/index.d.mts +68 -0
- package/dist/http-cache/testing/index.mjs +168 -0
- package/dist/idempotency/index.mjs +8 -8
- package/dist/idempotency/redis.mjs +2 -2
- package/dist/{index-BTxzJ_MN.d.mts → index-BxZS-8So.d.mts} +2 -2
- package/dist/{index-DyJFTJLA.d.mts → index-Cy2-QffW.d.mts} +9 -0
- package/dist/{index-CUdaoCYt.d.mts → index-D1X_C_qz.d.mts} +2 -2
- package/dist/{index-Bqfo8hLz.d.mts → index-DFCCQ9AE.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +11 -11
- package/dist/{init-BOaNkLYb.mjs → init-MoE3eZNR.mjs} +1 -1
- package/dist/integrations/event-gateway.mjs +2 -2
- package/dist/integrations/index.d.mts +1 -1
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs/index.mjs +3 -3
- package/dist/integrations/mcp/index.d.mts +4 -36
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +11 -15
- package/dist/integrations/mcp/testing.mjs +22 -42
- package/dist/integrations/streamline.mjs +3 -3
- package/dist/integrations/webhooks.d.mts +1 -1
- package/dist/integrations/webhooks.mjs +4 -3
- package/dist/integrations/websocket-pushref-redis.mjs +1 -1
- package/dist/integrations/websocket-redis.mjs +1 -1
- package/dist/integrations/websocket.mjs +2 -2
- package/dist/{jsonBody-DpRpKR_K.mjs → jsonBody-DZGiCawf.mjs} +2 -2
- package/dist/{keys-FBz6Ull-.mjs → keys-CrMOZuk6.mjs} +1 -1
- package/dist/{loadResources-Bx1sKPnF.mjs → loadResources-CVQvYUhN.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-b_jcqbxh.mjs → loadResourcesFromEntry-D0naccV2.mjs} +2 -2
- package/dist/logger/index.mjs +2 -2
- package/dist/{logger-CbFcIEBZ.mjs → logger-VyMcSmVG.mjs} +1 -1
- package/dist/{mcpPlugin-yix548XX.mjs → mcpPlugin-DQACaqVu.mjs} +210 -373
- package/dist/{memory-Bgw5dn8N.mjs → memory-Lpfu8Hga.mjs} +3 -3
- package/dist/{metrics-CZDQWVjS.mjs → metrics-DjVj1sg5.mjs} +3 -3
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.mjs +3 -3
- package/dist/migrations/index.mjs +2 -2
- package/dist/{module-Dsc_nKL5.mjs → module-BqPJpZ_L.mjs} +1 -1
- package/dist/{multiTenant-XCxAUlru.d.mts → multiTenant-KZj8j1uJ.d.mts} +1 -1
- package/dist/{multipartBody-B85ek8Kj.mjs → multipartBody-BNgNv7r0.mjs} +1 -1
- package/dist/{observeSend-BK-JN1jK.mjs → observeSend-BKJHibJz.mjs} +1 -1
- package/dist/{openapi-Co7hl073.mjs → openapi-T90KrPR6.mjs} +6 -6
- package/dist/outbox-admin/index.mjs +5 -5
- package/dist/{outbox-module-XvUThpqn.d.mts → outbox-module-5Mnwcycy.d.mts} +1 -1
- package/dist/outbox-module-C874VgBr.mjs +297 -0
- package/dist/permissions/index.mjs +7 -7
- package/dist/{permissions-A1oKtpiC.mjs → permissions-R9T2G1PH.mjs} +9 -9
- package/dist/{pipe-Czpw9U2n.mjs → pipe-DzqbsZy-.mjs} +2 -2
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +2 -2
- package/dist/{plan-KVseuBCL.mjs → plan-C0gkeABY.mjs} +1 -1
- package/dist/{plugin-DTWt_8C3.mjs → plugin-BJcVOX5r.mjs} +48 -24
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.mjs +17 -17
- package/dist/plugins/response-cache.mjs +4 -4
- package/dist/plugins/tracing-entry.mjs +2 -2
- package/dist/{pluralize-msB9X3yw.mjs → pluralize-CrCpyoZs.mjs} +1 -1
- package/dist/policy.types-DPqToKG1.d.mts +50 -0
- package/dist/presets/filesUpload.d.mts +1 -1
- package/dist/presets/filesUpload.mjs +5 -5
- package/dist/presets/index.d.mts +2 -2
- package/dist/presets/index.mjs +2 -2
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +5 -5
- package/dist/presets/search.d.mts +1 -1
- package/dist/presets/search.mjs +2 -2
- package/dist/{presets-qKCehiJM.mjs → presets-CNDvNYsz.mjs} +4 -4
- package/dist/{projection-ClBqtsIw.mjs → projection-CIUe8b59.mjs} +2 -2
- package/dist/purger.types-DvPp4-yd.d.mts +26 -0
- package/dist/purger.types-f83fTzGy.mjs +24 -0
- package/dist/{queryCachePlugin-3gJj5Rbz.mjs → queryCachePlugin-B2jpwFcv.mjs} +6 -6
- package/dist/{rateLimitKey-Kro---xl.mjs → rateLimitKey-BWx-qep0.mjs} +1 -1
- package/dist/{realtime-Ber8uJN2.mjs → realtime-D2tqi3d2.mjs} +11 -11
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +3 -3
- package/dist/{registry-BA-_vFYk.mjs → registry-Dl0k6UXy.mjs} +2 -2
- package/dist/{outbox-module-mg9kDYkd.mjs → relay-ZYvS4xyW.mjs} +5 -299
- package/dist/{renewingLease-CMY8YOcc.mjs → renewingLease-DT4yLb29.mjs} +1 -1
- package/dist/{replyHelpers-DK9P_XSz.mjs → replyHelpers-BJFN5AW7.mjs} +2 -2
- package/dist/{requestContext-GYO_0gEw.mjs → requestContext-Ct5la-SA.mjs} +1 -1
- package/dist/{requirement-DeNjZIH3.mjs → requirement-CxDxjB6V.mjs} +1 -1
- package/dist/{resourceRateLimit-tHLbrtWc.mjs → resourceRateLimit-D1oH2obv.mjs} +2 -2
- package/dist/{rolldown-runtime-Kv1fZdLg.mjs → rolldown-runtime-BdTN42uL.mjs} +1 -1
- package/dist/{routeValidator-C_H5NanI.mjs → routeValidator-DclDl5WJ.mjs} +1 -1
- package/dist/{runtimeCapabilities-DWqbxkyw.mjs → runtimeCapabilities-ClWr60El.mjs} +1 -1
- package/dist/{schedules-eO_RzhCU.mjs → schedules-gVkRcs-9.mjs} +5 -5
- package/dist/{schemaConverter-DBJrPZN4.mjs → schemaConverter-CIwB5wPO.mjs} +2 -2
- package/dist/{schemaIR-CEScKT2v.mjs → schemaIR-A0IoD05P.mjs} +2 -2
- package/dist/schemas/index.mjs +1 -1
- package/dist/scim/index.mjs +2 -2
- package/dist/scope/index.mjs +5 -5
- package/dist/{scope-B-Sm9m_E.mjs → scope-VMZhdkbT.mjs} +4 -4
- package/dist/{shutdown-DzLFbe27.mjs → shutdown-Bi19vH0z.mjs} +1 -1
- package/dist/{simpleEqualityMatcher-DOJhwQ8g.mjs → simpleEqualityMatcher-CaCS09fh.mjs} +1 -1
- package/dist/{sse-2972pVwV.mjs → sse-BqM359f1.mjs} +7 -7
- package/dist/{sseStream-AWLEeNV-.mjs → sseStream-qSa-F2Qm.mjs} +2 -2
- package/dist/{store-helpers-VzjgVTkM.mjs → store-helpers-rx-F2ZGR.mjs} +1 -1
- package/dist/{streaming-DvraWW6x.mjs → streaming-CPChx3A7.mjs} +1 -1
- package/dist/{subscriberIdentity-Bya56jsg.mjs → subscriberIdentity-CYNYw8p_.mjs} +1 -1
- package/dist/{tenancy-DSa_0hhw.mjs → tenancy-BoWImS3K.mjs} +2 -2
- package/dist/{tenantPreparation-BrpkQre3.mjs → tenantPreparation-oqKCZQZM.mjs} +4 -4
- package/dist/testing/cleanupStoreContract.mjs +1 -1
- package/dist/testing/index.d.mts +3 -3
- package/dist/testing/index.mjs +11 -11
- package/dist/testing/outboxStoreContract.mjs +2 -2
- package/dist/testing/requiredPorts.mjs +2 -2
- package/dist/testing/storageContract.mjs +1 -1
- package/dist/{timing-6rQTuCwg.mjs → timing-Dsteq59c.mjs} +1 -1
- package/dist/{transactionContext-DaxYUEgH.mjs → transactionContext-C1OgH-hW.mjs} +1 -1
- package/dist/{typeGuards-UKnX8wPX.mjs → typeGuards-DNlpASzd.mjs} +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/storage.mjs +1 -1
- package/dist/{types-BYEb_dLW.d.mts → types-DduBiYaI.d.mts} +19 -30
- package/dist/{types-CuGjhn83.mjs → types-HFFSwF_K.mjs} +4 -4
- package/dist/usage/index.mjs +4 -4
- package/dist/{userHelpers-oX5_mOVs.mjs → userHelpers-N-k-8dNF.mjs} +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +12 -12
- package/dist/{utils-CjjGOT4E.mjs → utils-C7w_RVlx.mjs} +5 -5
- package/dist/{validate-4RlTKOJb.mjs → validate-Brr4b_fH.mjs} +3 -3
- package/dist/{versioning-Dk2-19La.mjs → versioning-CE5kdWOY.mjs} +3 -3
- package/dist/{workScope-DoBsoVo4.mjs → workScope-A3XBpYTa.mjs} +2 -2
- package/package.json +47 -27
- package/skills/arc/references/mcp-custom-tools.md +1 -1
- package/skills/arc/references/mcp-setup.md +11 -10
- package/skills/arc/references/mcp-testing.md +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { n as evictToSize } from "./boundedMap-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-BdTN42uL.mjs";
|
|
3
|
+
import { n as evictToSize } from "./boundedMap-o2KZDCWy.mjs";
|
|
4
4
|
// src/cache/memory.ts
|
|
5
5
|
var memory_exports = /* @__PURE__ */ __exportAll({ MemoryCacheStore: () => MemoryCacheStore });
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { a as MetricHistogram, i as DURATION_BUCKETS_SECONDS, o as MetricSeries, s as renderMetricSample } from "./health-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-BdTN42uL.mjs";
|
|
3
|
+
import { a as MetricHistogram, i as DURATION_BUCKETS_SECONDS, o as MetricSeries, s as renderMetricSample } from "./health-ezwTHQh2.mjs";
|
|
4
4
|
import fp from "fastify-plugin";
|
|
5
5
|
// src/plugins/metrics.ts
|
|
6
6
|
var metrics_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { A as RequestWithExtras, J as MiddlewareConfig, k as MiddlewareHandler } from "../index-
|
|
2
|
+
import { A as RequestWithExtras, J as MiddlewareConfig, k as MiddlewareHandler } from "../index-Cy2-QffW.mjs";
|
|
3
3
|
import { RouteHandlerMethod } from "fastify";
|
|
4
4
|
interface NamedMiddleware {
|
|
5
5
|
/** Unique name for debugging/introspection */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as CRUD_OPERATIONS } from "../constants-
|
|
3
|
-
import { t as multipartBody } from "../multipartBody-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as CRUD_OPERATIONS } from "../constants-D-faL5SX.mjs";
|
|
3
|
+
import { t as multipartBody } from "../multipartBody-BNgNv7r0.mjs";
|
|
4
4
|
// src/middleware/middleware.ts
|
|
5
5
|
/**
|
|
6
6
|
* Named Middleware — Priority-based, conditional middleware execution.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as startRenewingLease } from "../renewingLease-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as startRenewingLease } from "../renewingLease-DT4yLb29.mjs";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
// src/migrations/index.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
2
|
// src/utils/observeSend.ts
|
|
3
3
|
/** Run `fn`, reporting whether it called `reply.send` (or the reply is already sent). */
|
|
4
4
|
async function runObservingSend(reply, fn) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as getUserRoles } from "./userHelpers-
|
|
3
|
-
import { n as convertRouteSchema } from "./schemaConverter-
|
|
4
|
-
import { t as resolveActionPermission } from "./actionPermissions-
|
|
5
|
-
import { t as pluralize } from "./pluralize-
|
|
6
|
-
import { t as buildActionBodySchema } from "./createActionRouter-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as getUserRoles } from "./userHelpers-N-k-8dNF.mjs";
|
|
3
|
+
import { n as convertRouteSchema } from "./schemaConverter-CIwB5wPO.mjs";
|
|
4
|
+
import { t as resolveActionPermission } from "./actionPermissions-Dha8sAz2.mjs";
|
|
5
|
+
import { t as pluralize } from "./pluralize-CrCpyoZs.mjs";
|
|
6
|
+
import { t as buildActionBodySchema } from "./createActionRouter-DTSVv1VK.mjs";
|
|
7
7
|
import fp from "fastify-plugin";
|
|
8
8
|
// src/docs/openapi/canonical-schemas.ts
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { i as NotFoundError, u as ValidationError } from "../errors-
|
|
3
|
-
import { t as defineResource } from "../defineResource-
|
|
4
|
-
import { n as getModuleExports, t as defineModule } from "../module-
|
|
5
|
-
import { r as readOutboxHealth } from "../health-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { i as NotFoundError, u as ValidationError } from "../errors-DyY48oRi.mjs";
|
|
3
|
+
import { t as defineResource } from "../defineResource-zYCrhNaN.mjs";
|
|
4
|
+
import { n as getModuleExports, t as defineModule } from "../module-BqPJpZ_L.mjs";
|
|
5
|
+
import { r as readOutboxHealth } from "../health-DHvAIVmM.mjs";
|
|
6
6
|
// src/outbox-admin/module.ts
|
|
7
7
|
/**
|
|
8
8
|
* Strip the domain payload and the stack unless explicitly opted in.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { a as EventTransport, n as DomainEvent, t as DeadLetteredEvent } from "./EventTransport-CYEoCJGe.mjs";
|
|
3
3
|
import { n as ArcModule } from "./types-BeEJm-DV.mjs";
|
|
4
4
|
import { FastifyInstance } from "fastify";
|
|
5
|
-
import { MemoryOutboxStore } from "@classytic/primitives/memory-outbox";
|
|
6
5
|
import { OutboxFailurePolicy, OutboxStore, OutboxWriteOptions } from "@classytic/primitives/outbox";
|
|
6
|
+
import { MemoryOutboxStore } from "@classytic/primitives/memory-outbox";
|
|
7
7
|
import { RepositoryLike } from "@classytic/repo-core/adapter";
|
|
8
8
|
/** Pending age past which the relay counts as stalled. */
|
|
9
9
|
declare const DEFAULT_RELAY_LAG_UNHEALTHY_MS: number;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as transactionContext } from "./transactionContext-C1OgH-hW.mjs";
|
|
3
|
+
import { n as requestContext } from "./requestContext-Ct5la-SA.mjs";
|
|
4
|
+
import { i as resolveEventTransport } from "./EventTransport-BWwg5YAU.mjs";
|
|
5
|
+
import { t as EventOutbox } from "./relay-ZYvS4xyW.mjs";
|
|
6
|
+
import { t as emitObserved } from "./eventPlugin-Co9sABCg.mjs";
|
|
7
|
+
import { n as canReportHealth, r as readOutboxHealth } from "./health-DHvAIVmM.mjs";
|
|
8
|
+
import { randomBytes } from "node:crypto";
|
|
9
|
+
import { hostname } from "node:os";
|
|
10
|
+
// src/events/outbox-module.ts
|
|
11
|
+
/**
|
|
12
|
+
* The OUTBOX as a module — so the store is a SLOT other modules depend on, not a value the host
|
|
13
|
+
* threads by hand.
|
|
14
|
+
*
|
|
15
|
+
* ## The failure this exists to make impossible
|
|
16
|
+
*
|
|
17
|
+
* A durable store passed as a constructor argument to N consumers will eventually miss one, and
|
|
18
|
+
* the miss is silent. Observed in two independent ERP hosts on the same fleet:
|
|
19
|
+
*
|
|
20
|
+
* - one passed an outbox to its revenue-attach seam and **not** to `createOrder`, so
|
|
21
|
+
* `order:created` published fire-and-forget — a failed publish discarded the revenue trigger
|
|
22
|
+
* entirely: no attach, no dead-letter, no log. Cash collected, nothing recorded.
|
|
23
|
+
* - the other had the identical gap, written independently.
|
|
24
|
+
*
|
|
25
|
+
* Six consumers had to be wired by hand in each host (order kernel, revenue kernel, access
|
|
26
|
+
* kernel, revenue-attach durability, line-activation dead letters, promo-commit dead letters).
|
|
27
|
+
* That is not a discipline problem; it is a design problem.
|
|
28
|
+
*
|
|
29
|
+
* As a module the store is registered ONCE and read from the registry. A consumer declares
|
|
30
|
+
* `dependsOn: ['outbox']` and arc refuses to boot without it — the omission becomes a startup
|
|
31
|
+
* failure instead of a quiet data-loss window.
|
|
32
|
+
*
|
|
33
|
+
* ## What this module does NOT do
|
|
34
|
+
*
|
|
35
|
+
* It does not build a store. Store construction is store-specific (a mongo model, a SQL table),
|
|
36
|
+
* and arc is deliberately storage-agnostic — `repositoryAsOutboxStore` already adapts any
|
|
37
|
+
* repository, and kits own their own schema (e.g. `@classytic/mongokit/outbox`). This module owns
|
|
38
|
+
* the three things that are genuinely arc's: the module SLOT, the relay SCHEDULE, and shutdown.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* The store contract is `@classytic/primitives/outbox`'s, not arc's — arc adapts to it rather
|
|
42
|
+
* than owning it, which is why a kit (mongokit) can supply a store with no arc dependency.
|
|
43
|
+
*/
|
|
44
|
+
/** Default relay cadence. Frequent enough that a retry is not a user-visible delay. */
|
|
45
|
+
const DEFAULT_RELAY_EVERY_MS = 5e3;
|
|
46
|
+
/** How long the readiness check reuses a relay-health reading. See `health.probeCacheMs`. */
|
|
47
|
+
const DEFAULT_PROBE_CACHE_MS = 5e3;
|
|
48
|
+
/** How often an unhealthy outbox is logged. See `health.alertEveryMs`. */
|
|
49
|
+
const DEFAULT_HEALTH_ALERT_EVERY_MS = 3e5;
|
|
50
|
+
/**
|
|
51
|
+
* One relay identity per RELAY INSTANCE — `<name>:<hostname>:<pid>:<random>`.
|
|
52
|
+
*
|
|
53
|
+
* A lease identifies an independently executing CLAIMANT, not a crash domain.
|
|
54
|
+
* Arc lets two outbox modules coexist (`name` is the `dependsOn` key), each
|
|
55
|
+
* with its own schedule arm, and nothing stops two of them pointing at the
|
|
56
|
+
* same store: they tick independently, so they are two claimants and must be
|
|
57
|
+
* two identities. Scoping this per-process instead would have made the module
|
|
58
|
+
* WEAKER than the primitive it wraps — `EventOutbox`'s own fallback is already
|
|
59
|
+
* per-instance — and would leave the store unable to tell the two apart after
|
|
60
|
+
* a lease expiry, which is exactly the stale-owner hole this replaced.
|
|
61
|
+
*
|
|
62
|
+
* Every component earns its place: `name` distinguishes co-resident modules,
|
|
63
|
+
* `hostname:pid` makes a lease row legible in ops tooling, and the random
|
|
64
|
+
* suffix breaks the tie a container restart creates — same hostname, often the
|
|
65
|
+
* same pid, and the restarted process must not inherit a predecessor's
|
|
66
|
+
* identity while that predecessor's lease is still live.
|
|
67
|
+
*
|
|
68
|
+
* Called once per `bootstrap()`, so the id is stable across every tick of the
|
|
69
|
+
* relay it belongs to — which the lease depends on.
|
|
70
|
+
*/
|
|
71
|
+
function mintConsumerId(name) {
|
|
72
|
+
return `${name}:${hostname()}:${process.pid}:${randomBytes(4).toString("hex")}`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compose the outbox as a module.
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* // host
|
|
79
|
+
* const model = createOutboxModel(connection, { visibleAtField: 'nextVisibleAt' });
|
|
80
|
+
* createApp({ modules: [
|
|
81
|
+
* createOutboxModule({
|
|
82
|
+
* store: repositoryAsOutboxStore(new Repository(model), { visibleAtField: 'nextVisibleAt' }),
|
|
83
|
+
* onError: (err, ctx) => app.log.error({ err, ...ctx }, 'outbox relay'),
|
|
84
|
+
* }),
|
|
85
|
+
* …
|
|
86
|
+
* ]});
|
|
87
|
+
*
|
|
88
|
+
* // consumer module
|
|
89
|
+
* defineModule({
|
|
90
|
+
* name: 'order',
|
|
91
|
+
* dependsOn: ['outbox'],
|
|
92
|
+
* bootstrap: (f) => createOrder({
|
|
93
|
+
* outbox: getModuleExports<OutboxModuleExports>(f, 'outbox').store,
|
|
94
|
+
* }),
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* `dependsOn` is doing real work there: it both orders the bootstraps and makes a missing outbox a
|
|
99
|
+
* boot error naming the module that needed it.
|
|
100
|
+
*/
|
|
101
|
+
function createOutboxModule(options) {
|
|
102
|
+
const name = options.name ?? "outbox";
|
|
103
|
+
const relayEveryMs = options.relayEveryMs ?? DEFAULT_RELAY_EVERY_MS;
|
|
104
|
+
const lagUnhealthyMs = (options.health === false ? void 0 : options.health?.relayLagUnhealthyMs) ?? 3e5;
|
|
105
|
+
const probeCacheMs = (options.health === false ? void 0 : options.health?.probeCacheMs) ?? DEFAULT_PROBE_CACHE_MS;
|
|
106
|
+
if (!Number.isFinite(probeCacheMs) || probeCacheMs < 0) throw new Error(`Outbox module "${name}": health.probeCacheMs must be a non-negative number, got ${String(probeCacheMs)}.`);
|
|
107
|
+
const alertEveryMs = options.health === false ? 0 : options.health?.alertEveryMs ?? DEFAULT_HEALTH_ALERT_EVERY_MS;
|
|
108
|
+
if (!Number.isFinite(alertEveryMs) || alertEveryMs < 0) throw new Error(`Outbox module "${name}": health.alertEveryMs must be a non-negative number, got ${String(alertEveryMs)}.`);
|
|
109
|
+
let log;
|
|
110
|
+
/** The unmeasurable-store warning is said once, not every alert tick. */
|
|
111
|
+
let warnedUnmeasurable = false;
|
|
112
|
+
/**
|
|
113
|
+
* The readiness probe's reading, reused for `probeCacheMs` and shared by
|
|
114
|
+
* concurrent probes (single-flight). A failed or unmeasurable reading is
|
|
115
|
+
* cached as unhealthy for the same window — retrying a failing store on
|
|
116
|
+
* every probe is load on the thing that is already failing.
|
|
117
|
+
*/
|
|
118
|
+
let probeReading;
|
|
119
|
+
let probeInFlight;
|
|
120
|
+
const probeHealthy = (read) => {
|
|
121
|
+
if (probeReading && Date.now() - probeReading.at < probeCacheMs) return Promise.resolve(probeReading.healthy);
|
|
122
|
+
probeInFlight ??= read().then((h) => h.healthy, () => false).then((healthy) => {
|
|
123
|
+
probeReading = {
|
|
124
|
+
at: Date.now(),
|
|
125
|
+
healthy
|
|
126
|
+
};
|
|
127
|
+
return healthy;
|
|
128
|
+
}).finally(() => {
|
|
129
|
+
probeInFlight = void 0;
|
|
130
|
+
});
|
|
131
|
+
return probeInFlight;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Built at bootstrap and reused by the schedule.
|
|
135
|
+
*
|
|
136
|
+
* Not rebuilt per tick: `EventOutbox` carries the consumer id the lease is keyed on, and a fresh
|
|
137
|
+
* instance per tick would be a fresh claimant every few seconds — which defeats the lease it
|
|
138
|
+
* depends on for exactly-once publishing.
|
|
139
|
+
*/
|
|
140
|
+
let exports;
|
|
141
|
+
/** Passes THIS module started (nudge, schedule) that have not settled — `drain()` waits on them. */
|
|
142
|
+
const inFlightPasses = /* @__PURE__ */ new Set();
|
|
143
|
+
const trackPass = (pass) => {
|
|
144
|
+
inFlightPasses.add(pass);
|
|
145
|
+
const untrack = () => {
|
|
146
|
+
inFlightPasses.delete(pass);
|
|
147
|
+
};
|
|
148
|
+
pass.then(untrack, untrack);
|
|
149
|
+
return pass;
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
name,
|
|
153
|
+
bootstrap: (fastify) => {
|
|
154
|
+
log = fastify.log;
|
|
155
|
+
const store = typeof options.store === "function" ? options.store(fastify) : options.store;
|
|
156
|
+
/**
|
|
157
|
+
* The RAW transport, never `fastify.events`.
|
|
158
|
+
*
|
|
159
|
+
* This read used to be `(fastify as { events?: EventTransport }).events` — a cast across
|
|
160
|
+
* two INCOMPATIBLE shapes. The facade's `publish(type, payload, meta?)` took the relayed
|
|
161
|
+
* `DomainEvent` as its `type` argument and failed the non-empty-string guard, so the
|
|
162
|
+
* documented default path published NOTHING: subscribers saw nothing and every tick
|
|
163
|
+
* reported `publishFailed: 1` until the row dead-lettered. The cast is what let two
|
|
164
|
+
* mismatched signatures typecheck.
|
|
165
|
+
*/
|
|
166
|
+
const transport = options.transport === void 0 ? resolveEventTransport(fastify) : typeof options.transport === "function" ? options.transport(fastify) : options.transport;
|
|
167
|
+
/**
|
|
168
|
+
* No transport is BOOT-FATAL, because the alternative is invisible:
|
|
169
|
+
* `EventOutbox.relayBatch()` returns an empty result when it has none, so the
|
|
170
|
+
* module's schedule would tick forever, publish nothing, and let the store grow —
|
|
171
|
+
* a durable backlog nobody is draining, reported as healthy. The failure this
|
|
172
|
+
* module exists to prevent, arrived at from the other side.
|
|
173
|
+
*/
|
|
174
|
+
if (transport === void 0) throw new Error(`Outbox module "${name}" could not resolve an event transport, so its relay would tick forever without publishing while the store grows. Register arc's events plugin (it is on by default — check \`arcPlugins.events !== false\`), or pass an explicit \`transport\` to \`createOutboxModule\`. Note the outbox needs the RAW EventTransport, not the \`fastify.events\` facade: the facade takes \`(type, payload, meta?)\` and fails open, which would acknowledge rows whose publish actually failed.`);
|
|
175
|
+
const relay = new EventOutbox({
|
|
176
|
+
store,
|
|
177
|
+
transport,
|
|
178
|
+
onPublished: (event) => emitObserved(fastify.events, event),
|
|
179
|
+
...options.batchSize !== void 0 ? { batchSize: options.batchSize } : {},
|
|
180
|
+
...options.leaseMs !== void 0 ? { leaseMs: options.leaseMs } : {},
|
|
181
|
+
consumerId: options.consumerId ?? mintConsumerId(name),
|
|
182
|
+
onError: options.onError ?? ((info) => {
|
|
183
|
+
fastify.log.error({
|
|
184
|
+
err: info.error,
|
|
185
|
+
kind: info.kind,
|
|
186
|
+
...info.event?.meta.id !== void 0 ? { eventId: info.event.meta.id } : {},
|
|
187
|
+
...info.event?.type !== void 0 ? { eventType: info.event.type } : {}
|
|
188
|
+
}, `outbox relay "${name}" failed`);
|
|
189
|
+
}),
|
|
190
|
+
...options.failurePolicy !== void 0 ? { failurePolicy: options.failurePolicy } : {},
|
|
191
|
+
...options.sessionProvider === false ? {} : { sessionProvider: options.sessionProvider ?? (() => transactionContext.get()) }
|
|
192
|
+
});
|
|
193
|
+
/**
|
|
194
|
+
* One pass per burst of requests. `drainQueued` stays true from the
|
|
195
|
+
* first request until the pass STARTS, so a request landing mid-pass
|
|
196
|
+
* schedules the next one — a row written during a pass is never left
|
|
197
|
+
* waiting for the interval.
|
|
198
|
+
*/
|
|
199
|
+
let drainQueued = false;
|
|
200
|
+
const requestDrain = () => {
|
|
201
|
+
if (drainQueued) return;
|
|
202
|
+
drainQueued = true;
|
|
203
|
+
let passDone = () => {};
|
|
204
|
+
trackPass(new Promise((resolve) => passDone = resolve));
|
|
205
|
+
setImmediate(() => {
|
|
206
|
+
drainQueued = false;
|
|
207
|
+
requestContext.storage.exit(() => {
|
|
208
|
+
relay.relayBatch().catch((err) => {
|
|
209
|
+
fastify.log.error({ err }, `outbox relay "${name}" requested drain failed`);
|
|
210
|
+
}).finally(passDone);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
const drain = ({ maxPasses = 100 } = {}) => requestContext.storage.exit(async () => {
|
|
215
|
+
const total = {
|
|
216
|
+
passes: 0,
|
|
217
|
+
relayed: 0,
|
|
218
|
+
publishFailed: 0,
|
|
219
|
+
deadLettered: 0,
|
|
220
|
+
drained: false
|
|
221
|
+
};
|
|
222
|
+
while (total.passes < maxPasses) {
|
|
223
|
+
if (inFlightPasses.size > 0) await Promise.allSettled([...inFlightPasses]);
|
|
224
|
+
const r = await relay.relayBatch();
|
|
225
|
+
total.passes++;
|
|
226
|
+
total.relayed += r.relayed;
|
|
227
|
+
total.publishFailed += r.publishFailed;
|
|
228
|
+
total.deadLettered += r.deadLettered;
|
|
229
|
+
if (r.attempted === 0 && inFlightPasses.size === 0) {
|
|
230
|
+
total.drained = true;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return total;
|
|
235
|
+
});
|
|
236
|
+
const health = async () => {
|
|
237
|
+
if (!canReportHealth(store)) throw new Error(`Outbox module "${name}": relay health needs BOTH countByStatus and oldestPendingAgeMs on the store, and it is missing at least one.`);
|
|
238
|
+
return readOutboxHealth(store, lagUnhealthyMs);
|
|
239
|
+
};
|
|
240
|
+
exports = {
|
|
241
|
+
store,
|
|
242
|
+
relay,
|
|
243
|
+
requestDrain,
|
|
244
|
+
drain,
|
|
245
|
+
health
|
|
246
|
+
};
|
|
247
|
+
return exports;
|
|
248
|
+
},
|
|
249
|
+
...options.health === false ? {} : { healthChecks: [{
|
|
250
|
+
name: `${name}.relay`,
|
|
251
|
+
critical: false,
|
|
252
|
+
check: () => exports ? probeHealthy(exports.health) : Promise.resolve(false)
|
|
253
|
+
}] },
|
|
254
|
+
/**
|
|
255
|
+
* The relay runs on the module's OWN schedule arm, so the host stops owning the tick — and
|
|
256
|
+
* a host that forgets to start one cannot exist.
|
|
257
|
+
*/
|
|
258
|
+
scheduledJobs: () => [{
|
|
259
|
+
name: `${name}.relay`,
|
|
260
|
+
kind: "relay",
|
|
261
|
+
every: relayEveryMs,
|
|
262
|
+
runOnStart: options.runOnStart ?? true,
|
|
263
|
+
handler: async () => {
|
|
264
|
+
if (exports) await trackPass(exports.relay.relay());
|
|
265
|
+
}
|
|
266
|
+
}, ...alertEveryMs > 0 ? [{
|
|
267
|
+
name: `${name}.health`,
|
|
268
|
+
kind: "relay",
|
|
269
|
+
every: alertEveryMs,
|
|
270
|
+
handler: async () => {
|
|
271
|
+
if (!exports || !log) return;
|
|
272
|
+
if (!canReportHealth(exports.store)) {
|
|
273
|
+
if (!warnedUnmeasurable) {
|
|
274
|
+
warnedUnmeasurable = true;
|
|
275
|
+
log.warn({
|
|
276
|
+
marker: "OUTBOX_HEALTH_UNMEASURABLE",
|
|
277
|
+
outbox: name
|
|
278
|
+
}, `outbox "${name}" store lacks countByStatus or oldestPendingAgeMs — relay stalls cannot be alerted on`);
|
|
279
|
+
}
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const h = await exports.health();
|
|
283
|
+
if (h.deadLetter > 0) log.warn({
|
|
284
|
+
marker: "OUTBOX_DEAD_LETTER",
|
|
285
|
+
outbox: name,
|
|
286
|
+
...h
|
|
287
|
+
}, `outbox "${name}" has dead-lettered events — inspect and replay them`);
|
|
288
|
+
if (h.relayLagMs !== null && h.relayLagMs >= lagUnhealthyMs) log.error({
|
|
289
|
+
marker: "OUTBOX_RELAY_LAG",
|
|
290
|
+
outbox: name,
|
|
291
|
+
...h
|
|
292
|
+
}, `outbox "${name}" relay is behind — events are committed but not delivered`);
|
|
293
|
+
}
|
|
294
|
+
}] : []]
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
export { createOutboxModule as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as conjoinPolicyFilters } from "../filter-merge-
|
|
3
|
-
import { n as getUserRoles, r as normalizeRoles } from "../userHelpers-
|
|
4
|
-
import { a as resolveEffectiveRoles, i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "../fields-
|
|
5
|
-
import { i as normalizeToDecision, r as evaluatePermissionDecision, t as applyAuthorizationDecision } from "../authorizationDecision-
|
|
6
|
-
import { i as resolveResourceRateLimiter, t as createMemoryResourceRateLimiter } from "../resourceRateLimit-
|
|
7
|
-
import { A as requireAgentScope, B as requireAuth, C as createOrgPermissions, D as requireScopeContext, E as requireOrgRole, F as allowPublic, G as when, H as requirePlatformRole, I as anyOf, K as scopeOf, L as deny, M as requireMandate, N as allOf, O as requireServiceScope, P as allow, R as denyAll, S as createDynamicPermissionMatrix, T as requireOrgMembership, U as requireRoles, V as requireOwnership, W as roles, _ as requireGrant, a as adminOnly, b as describePermissionMap, c as ownerWithAdminBypass, d as publicRead, f as publicReadAdminWrite, g as modeSatisfies, h as GRANT_MODES, i as introspectRegistry, j as requireDPoP, k as requireTeamMembership, l as permissionMatrix, m as createRoleHierarchy, n as introspectCheck, o as authenticated, p as readOnly, r as introspectModule, s as fullPublic, t as buildPermissionMatrix, u as presets_exports, v as collectPublicSurface, w as requireOrgInScope, x as explainAccess, y as describePermission, z as not } from "../permissions-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as conjoinPolicyFilters } from "../filter-merge-8glLr7Dk.mjs";
|
|
3
|
+
import { n as getUserRoles, r as normalizeRoles } from "../userHelpers-N-k-8dNF.mjs";
|
|
4
|
+
import { a as resolveEffectiveRoles, i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "../fields-rfsl26Ov.mjs";
|
|
5
|
+
import { i as normalizeToDecision, r as evaluatePermissionDecision, t as applyAuthorizationDecision } from "../authorizationDecision-BZSJcPNE.mjs";
|
|
6
|
+
import { i as resolveResourceRateLimiter, t as createMemoryResourceRateLimiter } from "../resourceRateLimit-D1oH2obv.mjs";
|
|
7
|
+
import { A as requireAgentScope, B as requireAuth, C as createOrgPermissions, D as requireScopeContext, E as requireOrgRole, F as allowPublic, G as when, H as requirePlatformRole, I as anyOf, K as scopeOf, L as deny, M as requireMandate, N as allOf, O as requireServiceScope, P as allow, R as denyAll, S as createDynamicPermissionMatrix, T as requireOrgMembership, U as requireRoles, V as requireOwnership, W as roles, _ as requireGrant, a as adminOnly, b as describePermissionMap, c as ownerWithAdminBypass, d as publicRead, f as publicReadAdminWrite, g as modeSatisfies, h as GRANT_MODES, i as introspectRegistry, j as requireDPoP, k as requireTeamMembership, l as permissionMatrix, m as createRoleHierarchy, n as introspectCheck, o as authenticated, p as readOnly, r as introspectModule, s as fullPublic, t as buildPermissionMatrix, u as presets_exports, v as collectPublicSurface, w as requireOrgInScope, x as explainAccess, y as describePermission, z as not } from "../permissions-R9T2G1PH.mjs";
|
|
8
8
|
export { GRANT_MODES, adminOnly, allOf, allow, allowPublic, anyOf, applyAuthorizationDecision, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, buildPermissionMatrix, collectPublicSurface, conjoinPolicyFilters, createDynamicPermissionMatrix, createMemoryResourceRateLimiter, createOrgPermissions, createRoleHierarchy, deny, denyAll, describePermission, describePermissionMap, evaluatePermissionDecision, explainAccess, fields, fullPublic, getUserRoles, introspectCheck, introspectModule, introspectRegistry, modeSatisfies, normalizeRoles, normalizeToDecision, not, ownerWithAdminBypass, permissionMatrix, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAgentScope, requireAuth, requireDPoP, requireGrant, requireMandate, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requirePlatformRole, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, resolveEffectiveRoles, resolveResourceRateLimiter, roles, scopeOf, when };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { t as arcLog } from "./logger-
|
|
4
|
-
import { t as conjoinPolicyFilters } from "./filter-merge-
|
|
5
|
-
import { n as getUserRoles } from "./userHelpers-
|
|
6
|
-
import { C as isService, S as isOrgInScope, a as getDPoPJkt, b as isElevated, d as getScopeContext, f as getScopeContextMap, g as getUserId, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, u as getRequestScope, v as hasOrgAccess, x as isMember } from "./types-
|
|
7
|
-
import { i as normalizeToDecision } from "./authorizationDecision-
|
|
8
|
-
import { n as declareRuntimeCapability } from "./runtimeCapabilities-
|
|
9
|
-
import { t as MemoryCacheStore } from "./memory-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-BdTN42uL.mjs";
|
|
3
|
+
import { t as arcLog } from "./logger-VyMcSmVG.mjs";
|
|
4
|
+
import { t as conjoinPolicyFilters } from "./filter-merge-8glLr7Dk.mjs";
|
|
5
|
+
import { n as getUserRoles } from "./userHelpers-N-k-8dNF.mjs";
|
|
6
|
+
import { C as isService, S as isOrgInScope, a as getDPoPJkt, b as isElevated, d as getScopeContext, f as getScopeContextMap, g as getUserId, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, u as getRequestScope, v as hasOrgAccess, x as isMember } from "./types-HFFSwF_K.mjs";
|
|
7
|
+
import { i as normalizeToDecision } from "./authorizationDecision-BZSJcPNE.mjs";
|
|
8
|
+
import { n as declareRuntimeCapability } from "./runtimeCapabilities-ClWr60El.mjs";
|
|
9
|
+
import { t as MemoryCacheStore } from "./memory-Lpfu8Hga.mjs";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
// src/permissions/context.ts
|
|
12
12
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { r as ForbiddenError } from "./errors-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { r as ForbiddenError } from "./errors-DyY48oRi.mjs";
|
|
3
3
|
// src/pipeline/pipe.ts
|
|
4
4
|
/**
|
|
5
5
|
* Compose pipeline steps into an ordered array.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { Vn as IControllerResponse, _t as PipelineConfig, bt as Transform, gt as OperationFilter, ht as NextFunction, mt as Interceptor, pt as Guard, vt as PipelineContext, yt as PipelineStep } from "../index-
|
|
2
|
+
import { Vn as IControllerResponse, _t as PipelineConfig, bt as Transform, gt as OperationFilter, ht as NextFunction, mt as Interceptor, pt as Guard, vt as PipelineContext, yt as PipelineStep } from "../index-Cy2-QffW.mjs";
|
|
3
3
|
interface GuardOptions {
|
|
4
4
|
operations?: OperationFilter;
|
|
5
5
|
handler: (ctx: PipelineContext) => boolean | Promise<boolean>;
|
package/dist/pipeline/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as pipe, t as executePipeline } from "../pipe-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as pipe, t as executePipeline } from "../pipe-DzqbsZy-.mjs";
|
|
3
3
|
// src/pipeline/guard.ts
|
|
4
4
|
/**
|
|
5
5
|
* Create a named guard.
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { g as SYSTEM_FIELDS, o as DEFAULT_TENANT_FIELD, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS } from "./constants-
|
|
3
|
-
import { t as arcLog } from "./logger-
|
|
4
|
-
import { t as conjoinPolicyFilters } from "./filter-merge-
|
|
5
|
-
import { d as createDomainError, f as createError, i as NotFoundError, p as isArcError, r as ForbiddenError, u as ValidationError } from "./errors-
|
|
6
|
-
import { t as simpleEqualityMatcher } from "./simpleEqualityMatcher-
|
|
7
|
-
import { n as requireSingleHeaderValue } from "./headers-
|
|
8
|
-
import { n as getUserRoles, t as getUserId } from "./userHelpers-
|
|
9
|
-
import { b as isElevated, c as getOrgId, n as PUBLIC_SCOPE, x as isMember } from "./types-
|
|
10
|
-
import { r as resolveTenancy } from "./tenancy-
|
|
11
|
-
import { t as buildQueryKey } from "./keys-
|
|
12
|
-
import { t as transactionContext } from "./transactionContext-
|
|
13
|
-
import { a as resolveEffectiveRoles, n as applyFieldWritePermissions } from "./fields-
|
|
14
|
-
import { E as ArcQueryParser, v as getDefaultCrudSchemas } from "./utils-
|
|
15
|
-
import { n as convertRouteSchema, r as ensureSchemaConverter, t as convertOpenApiSchemas } from "./schemaConverter-
|
|
16
|
-
import { i as pipeUIMessageStreamToReply, r as isReadableStream } from "./streaming-
|
|
17
|
-
import { _ as buildArcDecorator, a as resolveRouterPluginMw, b as createRequestContext, c as buildPipelineHandler, d as buildCrudPermissionMw, f as buildRouteHooks, h as buildAuthMiddleware, i as buildRouteConfig, l as resolvePipelineSteps, m as routeHookOptions, n as tryRegisterRoute, o as selectPluginMw, p as resolveRoutePreHandlers, r as buildRateLimitConfig, t as resolveActionPermission, v as createCrudHandlers, y as createFastifyHandler } from "./actionPermissions-
|
|
18
|
-
import { a as withoutTenantInjection } from "./tenantPreparation-
|
|
19
|
-
import { t as hasEvents } from "./typeGuards-
|
|
20
|
-
import { n as idempotencyConfigProblem } from "./requirement-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { g as SYSTEM_FIELDS, o as DEFAULT_TENANT_FIELD, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS } from "./constants-D-faL5SX.mjs";
|
|
3
|
+
import { t as arcLog } from "./logger-VyMcSmVG.mjs";
|
|
4
|
+
import { t as conjoinPolicyFilters } from "./filter-merge-8glLr7Dk.mjs";
|
|
5
|
+
import { d as createDomainError, f as createError, i as NotFoundError, p as isArcError, r as ForbiddenError, u as ValidationError } from "./errors-DyY48oRi.mjs";
|
|
6
|
+
import { t as simpleEqualityMatcher } from "./simpleEqualityMatcher-CaCS09fh.mjs";
|
|
7
|
+
import { n as requireSingleHeaderValue } from "./headers-CHSOqpcY.mjs";
|
|
8
|
+
import { n as getUserRoles, t as getUserId } from "./userHelpers-N-k-8dNF.mjs";
|
|
9
|
+
import { b as isElevated, c as getOrgId, n as PUBLIC_SCOPE, x as isMember } from "./types-HFFSwF_K.mjs";
|
|
10
|
+
import { r as resolveTenancy } from "./tenancy-BoWImS3K.mjs";
|
|
11
|
+
import { t as buildQueryKey } from "./keys-CrMOZuk6.mjs";
|
|
12
|
+
import { t as transactionContext } from "./transactionContext-C1OgH-hW.mjs";
|
|
13
|
+
import { a as resolveEffectiveRoles, n as applyFieldWritePermissions } from "./fields-rfsl26Ov.mjs";
|
|
14
|
+
import { E as ArcQueryParser, v as getDefaultCrudSchemas } from "./utils-C7w_RVlx.mjs";
|
|
15
|
+
import { n as convertRouteSchema, r as ensureSchemaConverter, t as convertOpenApiSchemas } from "./schemaConverter-CIwB5wPO.mjs";
|
|
16
|
+
import { i as pipeUIMessageStreamToReply, r as isReadableStream } from "./streaming-CPChx3A7.mjs";
|
|
17
|
+
import { _ as buildArcDecorator, a as resolveRouterPluginMw, b as createRequestContext, c as buildPipelineHandler, d as buildCrudPermissionMw, f as buildRouteHooks, h as buildAuthMiddleware, i as buildRouteConfig, l as resolvePipelineSteps, m as routeHookOptions, n as tryRegisterRoute, o as selectPluginMw, p as resolveRoutePreHandlers, r as buildRateLimitConfig, t as resolveActionPermission, v as createCrudHandlers, y as createFastifyHandler } from "./actionPermissions-Dha8sAz2.mjs";
|
|
18
|
+
import { a as withoutTenantInjection } from "./tenantPreparation-oqKCZQZM.mjs";
|
|
19
|
+
import { t as hasEvents } from "./typeGuards-DNlpASzd.mjs";
|
|
20
|
+
import { n as idempotencyConfigProblem } from "./requirement-CxDxjB6V.mjs";
|
|
21
21
|
import { ARC_ERROR_CODES } from "@classytic/repo-core/errors";
|
|
22
22
|
import { policyRecordToFilter } from "@classytic/repo-core/filter";
|
|
23
23
|
import { retryingTransaction } from "@classytic/repo-core/repository";
|
|
@@ -2247,6 +2247,29 @@ function methodCarriesBody(method) {
|
|
|
2247
2247
|
* SINGLE `config` key Fastify reads. Returns arc's object untouched when the host
|
|
2248
2248
|
* supplied none, so the route options stay literally what was declared.
|
|
2249
2249
|
*/
|
|
2250
|
+
/** The `config.httpCache` a CRUD read route carries when its resource declared `httpCache`. */
|
|
2251
|
+
function routeHttpCache(httpCache, resourceName, op) {
|
|
2252
|
+
if (!httpCache || op !== "list" && op !== "get") return void 0;
|
|
2253
|
+
const policy = op === "list" ? httpCache.list : httpCache.get;
|
|
2254
|
+
if (!policy) return void 0;
|
|
2255
|
+
const extra = httpCache.tags?.extra;
|
|
2256
|
+
return {
|
|
2257
|
+
...policy,
|
|
2258
|
+
resource: {
|
|
2259
|
+
name: resourceName,
|
|
2260
|
+
op,
|
|
2261
|
+
...extra ? { extra } : {}
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
/** Add `httpCache` to a route's `config`, keeping whatever `buildRouteConfig` produced. */
|
|
2266
|
+
function withHttpCache(base, policy) {
|
|
2267
|
+
if (!policy) return base;
|
|
2268
|
+
return { config: {
|
|
2269
|
+
...base.config ?? {},
|
|
2270
|
+
httpCache: policy
|
|
2271
|
+
} };
|
|
2272
|
+
}
|
|
2250
2273
|
function mergeRouteConfig(hostConfig, arcConfig) {
|
|
2251
2274
|
if (!hostConfig) return arcConfig;
|
|
2252
2275
|
return { config: {
|
|
@@ -2375,7 +2398,7 @@ function createCustomRoutes(fastify, routes, controller, options) {
|
|
|
2375
2398
|
* @param options - Router configuration
|
|
2376
2399
|
*/
|
|
2377
2400
|
function createCrudRouter(fastify, controller, options = {}) {
|
|
2378
|
-
const { tag = "Resource", schemas = {}, permissions = {}, middlewares = {}, routeGuards = [], routes: customRoutes = [], disableDefaultRoutes = false, disabledRoutes = [], resourceName = "unknown", schemaOptions, rateLimit, pipe: pipeline, fields: fieldPermissions, onFieldWriteDenied, updateMethod = DEFAULT_UPDATE_METHOD, idField, extensions, idempotency } = options;
|
|
2401
|
+
const { tag = "Resource", schemas = {}, permissions = {}, middlewares = {}, routeGuards = [], routes: customRoutes = [], disableDefaultRoutes = false, disabledRoutes = [], resourceName = "unknown", schemaOptions, rateLimit, pipe: pipeline, fields: fieldPermissions, onFieldWriteDenied, updateMethod = DEFAULT_UPDATE_METHOD, idField, extensions, idempotency, httpCache } = options;
|
|
2379
2402
|
const idempotentOps = new Set(idempotency?.required ?? []);
|
|
2380
2403
|
for (const op of idempotentOps) if (disableDefaultRoutes || disabledRoutes.includes(op)) throw new Error(`[arc] Resource "${resourceName}" declares idempotency.required '${op}', but that built-in route is not mounted — drop it from idempotency.required.`);
|
|
2381
2404
|
const rateLimitConfig = buildRateLimitConfig(rateLimit);
|
|
@@ -2473,7 +2496,7 @@ function createCrudRouter(fastify, controller, options = {}) {
|
|
|
2473
2496
|
}, defaultSchemas[spec.op], schemas[spec.op]),
|
|
2474
2497
|
...routeHookOptions(hooks),
|
|
2475
2498
|
handler: handlers[spec.op],
|
|
2476
|
-
...buildRouteConfig(rateLimitConfig, extensions, void 0, idempotentOps.has(spec.op) ? { required: true } : void 0)
|
|
2499
|
+
...withHttpCache(buildRouteConfig(rateLimitConfig, extensions, void 0, idempotentOps.has(spec.op) ? { required: true } : void 0), routeHttpCache(httpCache, resourceName, spec.op))
|
|
2477
2500
|
}, {
|
|
2478
2501
|
resourceName,
|
|
2479
2502
|
op: spec.op
|
|
@@ -3145,6 +3168,7 @@ function buildResourcePlugin(resource) {
|
|
|
3145
3168
|
schemaOptions: resource.schemaOptions,
|
|
3146
3169
|
rateLimit: resource.rateLimit,
|
|
3147
3170
|
idempotency: resource.idempotency,
|
|
3171
|
+
httpCache: resource.httpCache,
|
|
3148
3172
|
updateMethod: resource.updateMethod,
|
|
3149
3173
|
pipe: resource.pipe,
|
|
3150
3174
|
fields: resource.fields,
|
|
@@ -3153,7 +3177,7 @@ function buildResourcePlugin(resource) {
|
|
|
3153
3177
|
extensions: resource.extensions
|
|
3154
3178
|
});
|
|
3155
3179
|
if (resource.actions && Object.keys(resource.actions).length > 0) {
|
|
3156
|
-
const { createActionRouter } = await import("./createActionRouter-
|
|
3180
|
+
const { createActionRouter } = await import("./createActionRouter-DTSVv1VK.mjs").then((n) => n.n);
|
|
3157
3181
|
const actionConfig = normalizeActionsToRouterConfig(resource.actions, resource.actionPermissions, resource.tag, resource.permissions, resource.name, typedInstance.log);
|
|
3158
3182
|
const actionTarget = resolveActionTargetFence(resource, actionConfig);
|
|
3159
3183
|
createActionRouter(typedInstance, {
|
|
@@ -3173,7 +3197,7 @@ function buildResourcePlugin(resource) {
|
|
|
3173
3197
|
});
|
|
3174
3198
|
}
|
|
3175
3199
|
if (resource.aggregations && Object.keys(resource.aggregations).length > 0) {
|
|
3176
|
-
const [{ createAggregationRouter }, { adapterSupportsAggregate, ArcAggregationConfigError }] = await Promise.all([import("./createAggregationRouter-
|
|
3200
|
+
const [{ createAggregationRouter }, { adapterSupportsAggregate, ArcAggregationConfigError }] = await Promise.all([import("./createAggregationRouter-zEasm-ax.mjs"), import("./validate-Brr4b_fH.mjs").then((n) => n.r)]);
|
|
3177
3201
|
const repoForAgg = resource.controller?.repository ?? resource.repository;
|
|
3178
3202
|
if (!adapterSupportsAggregate(repoForAgg)) {
|
|
3179
3203
|
const undispatchable = Object.entries(resource.aggregations).filter(([, cfg]) => !cfg.materialized).map(([name]) => name);
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { t as AnyRecord } from "../base-HXNgPQww.mjs";
|
|
3
|
-
import { Et as RouteDefinition, J as MiddlewareConfig, U as PresetHook, X as RouteSchemaOptions } from "../index-
|
|
3
|
+
import { Et as RouteDefinition, J as MiddlewareConfig, U as PresetHook, X as RouteSchemaOptions } from "../index-Cy2-QffW.mjs";
|
|
4
4
|
import { i as errorHandlerPlugin, n as ErrorMapper, r as defaultIsDuplicateKeyError, t as ErrorHandlerOptions } from "../errorHandler-B9r88jZV.mjs";
|
|
5
5
|
import { A as DailyLedger, C as ScheduleStats, D as DailyClock, E as DailyClaimInfo, F as HealthCheck, I as HealthOptions, L as _default$3, M as MemoryDailyLedger, N as createDailyGate, O as DailyGate, P as createMemoryDailyLedger, S as ScheduleRunContext, T as _default$8, b as DailyScheduleOptions, j as DailyRunOutcome, k as DailyGateOptions, w as SchedulesPluginOptions, x as ScheduleDefinition } from "../types-BeEJm-DV.mjs";
|
|
6
|
-
import { i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-
|
|
6
|
+
import { i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-bzkWPt1f.mjs";
|
|
7
7
|
import { _ as ShutdownState, a as MetricsOptions, c as RealtimeOptions, d as SSEStats, f as _default$9, g as GracefulShutdownOptions, h as _default$1, i as MetricsCollector, l as _default$6, m as CachingRule, n as _default$10, o as _default$4, p as CachingOptions, r as MetricEntry, s as ChangeOperation, t as VersioningOptions, u as SSEOptions, v as _default$2 } from "../versioning-S18y2-0C.mjs";
|
|
8
8
|
import { t as TracingOptions } from "../tracing-JSFiBl5r.mjs";
|
|
9
9
|
import { PaginatedResult } from "@classytic/repo-core/pagination";
|