@classytic/arc 2.48.0 → 2.50.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-BWwg5YAU.mjs → EventTransport-B18mcj_M.mjs} +2 -2
- package/dist/{HookSystem-B9x-Y_k7.mjs → HookSystem-FUBaLTRm.mjs} +2 -2
- package/dist/{QueryCache-DdvrGG8Q.d.mts → QueryCache-BE47tmlO.d.mts} +36 -1
- package/dist/{ResourceRegistry-BcvEJoZd.mjs → ResourceRegistry-C5NM07fZ.mjs} +2 -2
- package/dist/{acquire-D2yj6Zzl.mjs → acquire-MHCnbDtH.mjs} +1 -1
- 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 +2 -2
- package/dist/auth/index.mjs +53 -15
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/{authorizationDecision-BZSJcPNE.mjs → authorizationDecision-BD8K4jdQ.mjs} +4 -4
- package/dist/{boundedMap-o2KZDCWy.mjs → boundedMap-CuCwos_X.mjs} +1 -1
- package/dist/{buildHandler-G3k59KY2.mjs → buildHandler-BttjNkTM.mjs} +23 -16
- package/dist/cache/index.d.mts +2 -2
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-CJIDPZOv.mjs → caching-CxUQLHfR.mjs} +3 -6
- package/dist/{claimed-D0A43wjT.mjs → claimed-CQ4ZpD8K.mjs} +1 -1
- package/dist/cleanup/index.d.mts +2 -2
- 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-D-faL5SX.mjs → constants-BZFsZwJh.mjs} +1 -1
- package/dist/context/index.mjs +5 -5
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +7 -7
- package/dist/{core-NSu1peyq.mjs → core-DWA1-5IE.mjs} +3 -3
- package/dist/{createActionRouter-DTSVv1VK.mjs → createActionRouter-fP3l2xVF.mjs} +54 -18
- package/dist/{createAggregationRouter-zEasm-ax.mjs → createAggregationRouter-BJZeOmBa.mjs} +13 -11
- package/dist/{createApp-CjqhkX1x.mjs → createApp-Db9JRumw.mjs} +332 -40
- package/dist/{createMcpServer-hSFeqRUb.d.mts → createMcpServer-CS2KOVP6.d.mts} +1 -1
- package/dist/{defineAggregation-DH2L6_v9.mjs → defineAggregation-BskqRz8M.mjs} +1 -1
- package/dist/{defineResource-zYCrhNaN.mjs → defineResource-B2vTvKzW.mjs} +8 -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-z--rFcZ5.mjs → elevation-XoY0C73T.mjs} +6 -9
- package/dist/encryption/index.mjs +3 -3
- package/dist/{errorHandler-3_3oN-Uc.mjs → errorHandler-BYI-JQMm.mjs} +4 -7
- package/dist/{errors-DyY48oRi.mjs → errors-3xaK0i9n.mjs} +1 -1
- package/dist/{eventPlugin-Co9sABCg.mjs → eventPlugin-CVQ9ddnL.mjs} +9 -13
- package/dist/{eventTypes-HmAFyJmJ.mjs → eventTypes-UPYg7gW1.mjs} +2 -2
- package/dist/events/index.d.mts +18 -5
- package/dist/events/index.mjs +8 -8
- package/dist/events/transports/redis-stream-entry.mjs +4 -4
- package/dist/events/transports/redis.d.mts +35 -0
- package/dist/events/transports/redis.mjs +87 -11
- package/dist/factory/index.d.mts +4 -4
- package/dist/factory/index.mjs +6 -6
- package/dist/{fastify-augmentation-bzkWPt1f.d.mts → fastify-augmentation-baQc3MaO.d.mts} +2 -2
- package/dist/fieldTypes-CxRvCaaZ.mjs +80 -0
- package/dist/{fields-rfsl26Ov.mjs → fields-DLFcJiDe.mjs} +1 -1
- package/dist/{filter-merge-8glLr7Dk.mjs → filter-merge-Bvjk_8dV.mjs} +1 -1
- package/dist/{generate-BOfBueRt.mjs → generate-0OpCUjUv.mjs} +2 -2
- package/dist/{headers-CHSOqpcY.mjs → headers-BROW65-r.mjs} +2 -2
- package/dist/{health-ezwTHQh2.mjs → health-Cfh-kYI_.mjs} +1 -1
- package/dist/{health-DHvAIVmM.mjs → health-Cy6aOg1i.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 +2 -2
- package/dist/http-cache/index.mjs +4 -4
- package/dist/http-cache/purgers/cloudflare.mjs +2 -2
- package/dist/http-cache/purgers/fastly.mjs +2 -2
- package/dist/http-cache/testing/index.mjs +1 -1
- package/dist/idempotency/index.d.mts +1 -1
- package/dist/idempotency/index.mjs +10 -8
- package/dist/idempotency/redis.mjs +2 -2
- package/dist/{index-B5i9-vuP.d.mts → index-CMNpMBtW.d.mts} +1 -1
- package/dist/{index-BxZS-8So.d.mts → index-DKM2p5w5.d.mts} +48 -23
- package/dist/{index-Cy2-QffW.d.mts → index-DLCcLUQT.d.mts} +69 -6
- package/dist/{index-DFCCQ9AE.d.mts → index-DexdFs1a.d.mts} +1 -1
- package/dist/{index-D1X_C_qz.d.mts → index-Dhrks-hM.d.mts} +60 -10
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +11 -11
- package/dist/{init-MoE3eZNR.mjs → init-D7PQcvvL.mjs} +1 -1
- package/dist/integrations/event-gateway.mjs +2 -2
- package/dist/integrations/index.d.mts +2 -2
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs/index.mjs +3 -3
- package/dist/integrations/mcp/index.d.mts +5 -5
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +2 -2
- package/dist/integrations/mcp/testing.mjs +2 -2
- package/dist/integrations/streamline.mjs +3 -3
- package/dist/integrations/webhooks.d.mts +1 -1
- package/dist/integrations/webhooks.mjs +4 -4
- 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-DZGiCawf.mjs → jsonBody-C0oREwUc.mjs} +2 -2
- package/dist/{keys-CrMOZuk6.mjs → keys-CGlPoVSn.mjs} +1 -1
- package/dist/{loadResources-CVQvYUhN.mjs → loadResources-Oi47dogA.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-D0naccV2.mjs → loadResourcesFromEntry-BW-LexBz.mjs} +2 -2
- package/dist/logger/index.mjs +2 -2
- package/dist/{logger-VyMcSmVG.mjs → logger-BagW7_YA.mjs} +1 -1
- package/dist/{mcpPlugin-DQACaqVu.mjs → mcpPlugin-C6-wFsOX.mjs} +29 -26
- package/dist/{memory-Lpfu8Hga.mjs → memory-Bl7kv6TS.mjs} +3 -3
- package/dist/{metrics-DjVj1sg5.mjs → metrics-CqnMJKrJ.mjs} +4 -7
- 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-BqPJpZ_L.mjs → module-lbEbHUfI.mjs} +1 -1
- package/dist/{multiTenant-KZj8j1uJ.d.mts → multiTenant-QtDzxx_K.d.mts} +1 -1
- package/dist/{multipartBody-BNgNv7r0.mjs → multipartBody-CqNezaB3.mjs} +1 -1
- package/dist/{observeSend-BKJHibJz.mjs → observeSend-BjilzlYl.mjs} +1 -1
- package/dist/{openapi-T90KrPR6.mjs → openapi-DXNbadgd.mjs} +7 -7
- package/dist/outbox-admin/index.d.mts +1 -1
- package/dist/outbox-admin/index.mjs +5 -5
- package/dist/{outbox-module-5Mnwcycy.d.mts → outbox-module-DzW6zwWJ.d.mts} +103 -10
- package/dist/{outbox-module-C874VgBr.mjs → outbox-module-k5rIszQ4.mjs} +197 -28
- package/dist/permissions/index.d.mts +2 -2
- package/dist/permissions/index.mjs +7 -7
- package/dist/{permissions-R9T2G1PH.mjs → permissions-BJylQopQ.mjs} +9 -9
- package/dist/{pipe-DzqbsZy-.mjs → pipe-D1cq8hET.mjs} +2 -2
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +2 -2
- package/dist/{plan-C0gkeABY.mjs → plan-iEgaS5_H.mjs} +1 -1
- package/dist/{plugin-BJcVOX5r.mjs → plugin-DsLr6L4O.mjs} +94 -50
- package/dist/plugins/index.d.mts +6 -5
- package/dist/plugins/index.mjs +19 -18
- package/dist/plugins/response-cache.mjs +4 -4
- package/dist/plugins/tracing-entry.mjs +2 -2
- package/dist/{pluralize-CrCpyoZs.mjs → pluralize-CX4ZvwCa.mjs} +1 -1
- 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-CNDvNYsz.mjs → presets-D_suT4OY.mjs} +4 -4
- package/dist/{projection-CIUe8b59.mjs → projection-CmjGjFih.mjs} +2 -2
- package/dist/{purger.types-f83fTzGy.mjs → purger.types-CZwkTZ7B.mjs} +1 -1
- package/dist/{queryCachePlugin-B2jpwFcv.mjs → queryCachePlugin-BDOPEAmH.mjs} +114 -14
- package/dist/{queryCachePlugin-DYQUyeJ9.d.mts → queryCachePlugin-DrQNnGws.d.mts} +1 -1
- package/dist/{rateLimitKey-BWx-qep0.mjs → rateLimitKey-igF1x64n.mjs} +1 -1
- package/dist/{realtime-D2tqi3d2.mjs → realtime-Cq_ugiWw.mjs} +75 -22
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +3 -3
- package/dist/{registry-Dl0k6UXy.mjs → registry-DmF9Akvn.mjs} +2 -2
- package/dist/{relay-ZYvS4xyW.mjs → relay-DA89IhFt.mjs} +200 -99
- package/dist/{renewingLease-DT4yLb29.mjs → renewingLease-DBtGUt8T.mjs} +1 -1
- package/dist/{replyHelpers-BJFN5AW7.mjs → replyHelpers-CUbeUc5q.mjs} +2 -2
- package/dist/{requestContext-Ct5la-SA.mjs → requestContext-DO9Qv0gw.mjs} +1 -1
- package/dist/{requirement-CxDxjB6V.mjs → requirement-C3GaQmkR.mjs} +1 -1
- package/dist/{resourceRateLimit-DCWglD7V.d.mts → resourceRateLimit-BPiESPtG.d.mts} +4 -0
- package/dist/{resourceRateLimit-D1oH2obv.mjs → resourceRateLimit-KKn-sFhb.mjs} +19 -4
- package/dist/{rolldown-runtime-BdTN42uL.mjs → rolldown-runtime-Ck1Tj4Ax.mjs} +1 -1
- package/dist/{routeValidator-DclDl5WJ.mjs → routeValidator-BF7n34xV.mjs} +47 -5
- package/dist/{runtimeCapabilities-ClWr60El.mjs → runtimeCapabilities-D0A4kkrC.mjs} +1 -1
- package/dist/{schedules-gVkRcs-9.mjs → schedules-CLrQRSTt.mjs} +6 -9
- package/dist/{schemaConverter-CIwB5wPO.mjs → schemaConverter-JEmU21fu.mjs} +2 -2
- package/dist/{actionPermissions-Dha8sAz2.mjs → schemaIR-wOffQlbq.mjs} +184 -16
- package/dist/schemas/index.mjs +1 -1
- package/dist/scim/index.mjs +2 -2
- package/dist/scope/index.d.mts +1 -1
- package/dist/scope/index.mjs +5 -5
- package/dist/{scope-VMZhdkbT.mjs → scope-CcTMRd7s.mjs} +4 -4
- package/dist/{shutdown-Bi19vH0z.mjs → shutdown-BIR-QBYM.mjs} +1 -1
- package/dist/{simpleEqualityMatcher-CaCS09fh.mjs → simpleEqualityMatcher-DqqJqovq.mjs} +1 -1
- package/dist/{sse-BqM359f1.mjs → sse-OEuPpgss.mjs} +9 -35
- package/dist/sseStats-DQqNN385.d.mts +112 -0
- package/dist/sseStream-DknHE2K5.mjs +166 -0
- package/dist/{store-helpers-rx-F2ZGR.mjs → store-helpers-D4vtEXt2.mjs} +1 -1
- package/dist/{streaming-CPChx3A7.mjs → streaming-CcIpcx02.mjs} +1 -1
- package/dist/{subscriberIdentity-CYNYw8p_.mjs → subscriberIdentity-PO6kimAl.mjs} +1 -1
- package/dist/{tenancy-BoWImS3K.mjs → tenancy-CH2Kuksc.mjs} +2 -2
- package/dist/{tenantPreparation-oqKCZQZM.mjs → tenantPreparation-BTGpblQW.mjs} +4 -4
- package/dist/testing/cleanupStoreContract.mjs +1 -1
- package/dist/testing/index.d.mts +4 -4
- package/dist/testing/index.mjs +324 -17
- package/dist/testing/outboxStoreContract.mjs +2 -2
- package/dist/testing/requiredPorts.mjs +2 -2
- package/dist/testing/storageContract.mjs +1 -1
- package/dist/{timing-Dsteq59c.mjs → timing-Dii5X7AP.mjs} +1 -1
- package/dist/{transactionContext-C1OgH-hW.mjs → transactionContext-DMPhYEOt.mjs} +1 -1
- package/dist/{typeGuards-DNlpASzd.mjs → typeGuards-C1o_XEyp.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-DduBiYaI.d.mts → types-B4E0sc6D.d.mts} +2 -2
- package/dist/{types-HFFSwF_K.mjs → types-BuV_cFqT.mjs} +4 -4
- package/dist/usage/index.d.mts +1 -1
- package/dist/usage/index.mjs +7 -7
- package/dist/{userHelpers-N-k-8dNF.mjs → userHelpers-D4m_pLSC.mjs} +1 -1
- package/dist/utils/index.d.mts +193 -34
- package/dist/utils/index.mjs +13 -13
- package/dist/{utils-C7w_RVlx.mjs → utils-CxLMXGn5.mjs} +761 -8
- package/dist/{validate-Brr4b_fH.mjs → validate-CZ975J8N.mjs} +3 -3
- package/dist/{versioning-S18y2-0C.d.mts → versioning-B07RgD27.d.mts} +2 -13
- package/dist/{versioning-CE5kdWOY.mjs → versioning-B2_8SBZo.mjs} +4 -7
- package/dist/{workScope-A3XBpYTa.mjs → workScope-B3W3r35s.mjs} +2 -2
- package/llms.txt +2 -2
- package/package.json +34 -34
- package/skills/arc/references/api-reference.md +2 -2
- package/skills/arc/references/auth-better-auth.md +1 -0
- package/skills/arc/references/events-outbox.md +7 -4
- package/skills/arc/references/events.md +2 -2
- package/skills/arc/references/production-api.md +4 -0
- package/skills/arc/references/production-boot.md +2 -0
- package/skills/arc/references/production-idempotency.md +1 -1
- package/skills/arc/references/production-realtime.md +28 -2
- package/skills/arc/references/validation.md +4 -0
- package/skills/arc/references/writes-hooks-errors.md +1 -0
- package/dist/schemaIR-A0IoD05P.mjs +0 -108
- package/dist/sseStream-qSa-F2Qm.mjs +0 -57
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { a as enterArcLoggerScope, i as runWithArcLogger, n as configureArcLogger, r as createPinoWriter, t as arcLog } from "./logger-
|
|
4
|
-
import { n as PUBLIC_SCOPE } from "./types-
|
|
5
|
-
import { t as runObservingSend } from "./observeSend-
|
|
6
|
-
import { r as initRuntimeCapabilityRegistry, t as auditRuntimeCapabilities } from "./runtimeCapabilities-
|
|
7
|
-
import { a as runShutdown, t as initShutdownRegistry } from "./shutdown-
|
|
8
|
-
import { n as isScopeAwareKeyGenerator, t as createTenantKeyGenerator } from "./rateLimitKey-
|
|
9
|
-
import { i as resolveResourceRateLimiter, n as markRateLimitingDisabled } from "./resourceRateLimit-
|
|
10
|
-
import {
|
|
11
|
-
import { c as createRequestIdGenerator, r as mergeHealthChecks } from "./health-
|
|
12
|
-
import { t as parseJsonBody } from "./jsonBody-
|
|
13
|
-
import { a as portsForModule, b as verifyEventDurability, f as resolveModuleArm, g as crudEventsOf, h as buildModuleGraph, m as analyzeModuleGraph, n as composeModules, x as verifyModuleGraph } from "./plan-
|
|
14
|
-
import { c as wrapWithAttribution, f as defineEvent, l as wrapWithBoundary, r as CRUD_EVENT_SCHEMA } from "./eventTypes-
|
|
15
|
-
import { r as withSubscriberId } from "./subscriberIdentity-
|
|
16
|
-
import { r as getOptionalModuleExports } from "./module-
|
|
1
|
+
/*! @classytic/arc v2.50.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-Ck1Tj4Ax.mjs";
|
|
3
|
+
import { a as enterArcLoggerScope, i as runWithArcLogger, n as configureArcLogger, r as createPinoWriter, t as arcLog } from "./logger-BagW7_YA.mjs";
|
|
4
|
+
import { n as PUBLIC_SCOPE } from "./types-BuV_cFqT.mjs";
|
|
5
|
+
import { t as runObservingSend } from "./observeSend-BjilzlYl.mjs";
|
|
6
|
+
import { r as initRuntimeCapabilityRegistry, t as auditRuntimeCapabilities } from "./runtimeCapabilities-D0A4kkrC.mjs";
|
|
7
|
+
import { a as runShutdown, t as initShutdownRegistry } from "./shutdown-BIR-QBYM.mjs";
|
|
8
|
+
import { n as isScopeAwareKeyGenerator, t as createTenantKeyGenerator } from "./rateLimitKey-igF1x64n.mjs";
|
|
9
|
+
import { i as resolveResourceRateLimiter, n as markRateLimitingDisabled } from "./resourceRateLimit-KKn-sFhb.mjs";
|
|
10
|
+
import { i as markArcRootValidator, r as arcValidatorBuilder, t as arcAjvCustomOptions } from "./routeValidator-BF7n34xV.mjs";
|
|
11
|
+
import { c as createRequestIdGenerator, r as mergeHealthChecks } from "./health-Cfh-kYI_.mjs";
|
|
12
|
+
import { t as parseJsonBody } from "./jsonBody-C0oREwUc.mjs";
|
|
13
|
+
import { a as portsForModule, b as verifyEventDurability, f as resolveModuleArm, g as crudEventsOf, h as buildModuleGraph, m as analyzeModuleGraph, n as composeModules, x as verifyModuleGraph } from "./plan-iEgaS5_H.mjs";
|
|
14
|
+
import { c as wrapWithAttribution, f as defineEvent, l as wrapWithBoundary, r as CRUD_EVENT_SCHEMA } from "./eventTypes-UPYg7gW1.mjs";
|
|
15
|
+
import { r as withSubscriberId } from "./subscriberIdentity-PO6kimAl.mjs";
|
|
16
|
+
import { r as getOptionalModuleExports } from "./module-lbEbHUfI.mjs";
|
|
17
17
|
import { isProductionEnv, readEnv } from "@classytic/primitives/environment";
|
|
18
18
|
import Fastify from "fastify";
|
|
19
19
|
import qs from "qs";
|
|
@@ -766,7 +766,7 @@ async function registerArcCore(fastify, config, trackPlugin) {
|
|
|
766
766
|
await fastify.register(arcCorePlugin, { emitEvents: config.arcPlugins?.emitEvents !== false });
|
|
767
767
|
trackPlugin("arc-core");
|
|
768
768
|
if (config.arcPlugins?.events !== false) {
|
|
769
|
-
const { default: eventPlugin } = await import("./eventPlugin-
|
|
769
|
+
const { default: eventPlugin } = await import("./eventPlugin-CVQ9ddnL.mjs").then((n) => n.r);
|
|
770
770
|
const eventOpts = typeof config.arcPlugins?.events === "object" ? config.arcPlugins.events : {};
|
|
771
771
|
await fastify.register(eventPlugin, {
|
|
772
772
|
/**
|
|
@@ -821,15 +821,15 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules, moduleH
|
|
|
821
821
|
trackPlugin("arc-graceful-shutdown", shutdownOpts);
|
|
822
822
|
}
|
|
823
823
|
if (config.arcPlugins?.caching) {
|
|
824
|
-
const { default: cachingPlugin } = await import("./caching-
|
|
824
|
+
const { default: cachingPlugin } = await import("./caching-CxUQLHfR.mjs").then((n) => n.n);
|
|
825
825
|
const opts = config.arcPlugins.caching === true ? {} : config.arcPlugins.caching;
|
|
826
826
|
await fastify.register(cachingPlugin, opts);
|
|
827
827
|
trackPlugin("arc-caching", opts);
|
|
828
828
|
}
|
|
829
829
|
if (config.arcPlugins?.queryCache) {
|
|
830
|
-
const { queryCachePlugin } = await import("./queryCachePlugin-
|
|
830
|
+
const { queryCachePlugin } = await import("./queryCachePlugin-BDOPEAmH.mjs").then((n) => n.n);
|
|
831
831
|
const opts = config.arcPlugins.queryCache === true ? {} : config.arcPlugins.queryCache;
|
|
832
|
-
const store = config.stores?.queryCache ?? new (await (import("./memory-
|
|
832
|
+
const store = config.stores?.queryCache ?? new (await (import("./memory-Bl7kv6TS.mjs").then((n) => n.n))).MemoryCacheStore();
|
|
833
833
|
await fastify.register(queryCachePlugin, {
|
|
834
834
|
store,
|
|
835
835
|
...opts
|
|
@@ -839,7 +839,7 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules, moduleH
|
|
|
839
839
|
if (config.arcPlugins?.sse) {
|
|
840
840
|
if (config.arcPlugins?.events === false) fastify.log.warn("SSE plugin requires events plugin (arcPlugins.events). SSE disabled.");
|
|
841
841
|
else {
|
|
842
|
-
const { default: ssePlugin } = await import("./sse-
|
|
842
|
+
const { default: ssePlugin } = await import("./sse-OEuPpgss.mjs").then((n) => n.n);
|
|
843
843
|
const opts = config.arcPlugins.sse === true ? {} : config.arcPlugins.sse;
|
|
844
844
|
await fastify.register(ssePlugin, opts);
|
|
845
845
|
trackPlugin("arc-sse", opts);
|
|
@@ -848,20 +848,20 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules, moduleH
|
|
|
848
848
|
if (config.arcPlugins?.realtime) {
|
|
849
849
|
if (config.arcPlugins?.events === false) fastify.log.warn("Realtime plugin requires events plugin (arcPlugins.events). Realtime disabled.");
|
|
850
850
|
else {
|
|
851
|
-
const { default: realtimePlugin } = await import("./realtime-
|
|
851
|
+
const { default: realtimePlugin } = await import("./realtime-Cq_ugiWw.mjs").then((n) => n.n);
|
|
852
852
|
const opts = config.arcPlugins.realtime === true ? {} : config.arcPlugins.realtime;
|
|
853
853
|
await fastify.register(realtimePlugin, opts);
|
|
854
854
|
trackPlugin("arc-realtime", opts);
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
857
|
if (config.arcPlugins?.metrics) {
|
|
858
|
-
const { default: metricsPlugin } = await import("./metrics-
|
|
858
|
+
const { default: metricsPlugin } = await import("./metrics-CqnMJKrJ.mjs").then((n) => n.n);
|
|
859
859
|
const opts = config.arcPlugins.metrics === true ? {} : config.arcPlugins.metrics;
|
|
860
860
|
await fastify.register(metricsPlugin, opts);
|
|
861
861
|
trackPlugin("arc-metrics", opts);
|
|
862
862
|
}
|
|
863
863
|
if (config.arcPlugins?.versioning) {
|
|
864
|
-
const { default: versioningPlugin } = await import("./versioning-
|
|
864
|
+
const { default: versioningPlugin } = await import("./versioning-B2_8SBZo.mjs").then((n) => n.n);
|
|
865
865
|
await fastify.register(versioningPlugin, config.arcPlugins.versioning);
|
|
866
866
|
trackPlugin("arc-versioning", config.arcPlugins.versioning);
|
|
867
867
|
}
|
|
@@ -938,7 +938,7 @@ async function registerAuth(fastify, config, trackPlugin) {
|
|
|
938
938
|
*/
|
|
939
939
|
async function registerElevation(fastify, config, trackPlugin) {
|
|
940
940
|
if (!config.elevation) return;
|
|
941
|
-
const { elevationPlugin } = await import("./elevation-
|
|
941
|
+
const { elevationPlugin } = await import("./elevation-XoY0C73T.mjs").then((n) => n.n);
|
|
942
942
|
await fastify.register(elevationPlugin, config.elevation);
|
|
943
943
|
trackPlugin("arc-elevation", config.elevation);
|
|
944
944
|
fastify.log.debug("Elevation plugin enabled");
|
|
@@ -953,7 +953,7 @@ async function registerElevation(fastify, config, trackPlugin) {
|
|
|
953
953
|
*/
|
|
954
954
|
async function registerErrorHandler(fastify, config, trackPlugin, moduleErrorMappers) {
|
|
955
955
|
if (config.errorHandler === false) return;
|
|
956
|
-
const { errorHandlerPlugin } = await import("./errorHandler-
|
|
956
|
+
const { errorHandlerPlugin } = await import("./errorHandler-BYI-JQMm.mjs").then((n) => n.r);
|
|
957
957
|
/**
|
|
958
958
|
* DISCLOSURE DEFAULTS MERGE — they used to be REPLACED, and that was two bugs.
|
|
959
959
|
*
|
|
@@ -1172,7 +1172,7 @@ async function registerResources(fastify, config, preResolvedModules, skippedBri
|
|
|
1172
1172
|
let discoveryPath;
|
|
1173
1173
|
let discoveryYieldedZero = false;
|
|
1174
1174
|
if (resolvedResources === void 0 && config.resourceDir) {
|
|
1175
|
-
const { loadResources } = await import("./loadResources-
|
|
1175
|
+
const { loadResources } = await import("./loadResources-Oi47dogA.mjs").then((n) => n.n);
|
|
1176
1176
|
const { resolve, dirname } = await import("node:path");
|
|
1177
1177
|
const { fileURLToPath } = await import("node:url");
|
|
1178
1178
|
const rawDir = config.resourceDir;
|
|
@@ -1297,7 +1297,7 @@ Resources supplied by "${m.name}": ${provided}.`);
|
|
|
1297
1297
|
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.");
|
|
1298
1298
|
const frozenJobs = Object.freeze(scheduledJobs.map((job) => Object.freeze({ ...job })));
|
|
1299
1299
|
const scheduleOptions = typeof config.arcPlugins?.schedules === "object" ? config.arcPlugins.schedules : {};
|
|
1300
|
-
const { default: schedulesPlugin } = await import("./schedules-
|
|
1300
|
+
const { default: schedulesPlugin } = await import("./schedules-CLrQRSTt.mjs").then((n) => n.n);
|
|
1301
1301
|
await fastify.register(schedulesPlugin, {
|
|
1302
1302
|
...scheduleOptions,
|
|
1303
1303
|
schedules: frozenJobs
|
|
@@ -1484,6 +1484,54 @@ const ARC_EXPOSED_HEADERS = ["set-auth-token"];
|
|
|
1484
1484
|
*/
|
|
1485
1485
|
const DEFAULT_CORS_MAX_AGE = 86400;
|
|
1486
1486
|
/**
|
|
1487
|
+
* `Access-Control-Allow-Methods` when the host's `cors` object names none:
|
|
1488
|
+
* the verbs arc's own routes register (CRUD `PUT`/`PATCH`/`DELETE` included),
|
|
1489
|
+
* the same list the production and development presets carry. `@fastify/cors`
|
|
1490
|
+
* alone allows only `GET,HEAD,POST`, so a host `cors` object (which replaces the
|
|
1491
|
+
* preset's) silently broke every cross-origin update and delete.
|
|
1492
|
+
*/
|
|
1493
|
+
const ARC_DEFAULT_CORS_METHODS = [
|
|
1494
|
+
"GET",
|
|
1495
|
+
"HEAD",
|
|
1496
|
+
"POST",
|
|
1497
|
+
"PUT",
|
|
1498
|
+
"PATCH",
|
|
1499
|
+
"DELETE",
|
|
1500
|
+
"OPTIONS"
|
|
1501
|
+
];
|
|
1502
|
+
/** `@fastify/cors`'s own `methods` default, answered when `options.methods` is unset. */
|
|
1503
|
+
const FASTIFY_CORS_DEFAULT_METHODS = [
|
|
1504
|
+
"GET",
|
|
1505
|
+
"HEAD",
|
|
1506
|
+
"POST"
|
|
1507
|
+
];
|
|
1508
|
+
/**
|
|
1509
|
+
* CORS-safelisted methods: browsers never check them against
|
|
1510
|
+
* `Access-Control-Allow-Methods`, so a route on one of these verbs cannot
|
|
1511
|
+
* fail its preflight for want of the verb. `OPTIONS` is the preflight itself.
|
|
1512
|
+
*/
|
|
1513
|
+
const PREFLIGHT_EXEMPT_METHODS = /* @__PURE__ */ new Set([
|
|
1514
|
+
"GET",
|
|
1515
|
+
"HEAD",
|
|
1516
|
+
"POST",
|
|
1517
|
+
"OPTIONS"
|
|
1518
|
+
]);
|
|
1519
|
+
/**
|
|
1520
|
+
* The verbs registered routes use that the resolved CORS `methods` do not allow
|
|
1521
|
+
* (sorted, upper case). Safelisted verbs never count. Feeds the boot warning
|
|
1522
|
+
* for cross-origin PUT/PATCH/DELETE that would fail their preflight silently.
|
|
1523
|
+
*/
|
|
1524
|
+
function corsMissingRouteMethods(options, routeMethods) {
|
|
1525
|
+
const declared = options.methods;
|
|
1526
|
+
const allowed = new Set((Array.isArray(declared) ? declared : typeof declared === "string" ? declared.split(",") : FASTIFY_CORS_DEFAULT_METHODS).map((m) => m.trim().toUpperCase()));
|
|
1527
|
+
const missing = /* @__PURE__ */ new Set();
|
|
1528
|
+
for (const method of routeMethods) {
|
|
1529
|
+
const verb = method.toUpperCase();
|
|
1530
|
+
if (!PREFLIGHT_EXEMPT_METHODS.has(verb) && !allowed.has(verb)) missing.add(verb);
|
|
1531
|
+
}
|
|
1532
|
+
return [...missing].sort();
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1487
1535
|
* Resolve the host's CORS config into `@fastify/cors` options + warnings.
|
|
1488
1536
|
* Throws on the one configuration arc refuses to ship (see module header).
|
|
1489
1537
|
* Callers decide only HOW to surface warnings — the policy is all here.
|
|
@@ -1491,6 +1539,7 @@ const DEFAULT_CORS_MAX_AGE = 86400;
|
|
|
1491
1539
|
function resolveCorsOptions(config) {
|
|
1492
1540
|
const corsOptions = { ...config.cors ?? {} };
|
|
1493
1541
|
const warnings = [];
|
|
1542
|
+
let methodsWarned = false;
|
|
1494
1543
|
const originDeclared = "origin" in corsOptions && corsOptions.origin !== void 0;
|
|
1495
1544
|
if (config.preset === "production" && !originDeclared) warnings.push("CORS origin is not explicitly configured in production. Browser apps: set cors.origin to allowed domains (e.g. ['https://app.example.com']) with credentials: true. Server-to-server / API-key services: cors: { origin: '*', credentials: false } OR cors: false to disable. Tip: when wiring cors.origin from an env var, fail fast on missing (`if (!process.env.ALLOWED_ORIGINS) throw ...`) instead of letting `undefined` slip through.");
|
|
1496
1545
|
if (corsOptions.credentials === true && corsOptions.origin === "*") throw new Error("[Arc] cors: `origin: '*'` cannot be combined with `credentials: true`.\nReflecting arbitrary origins with credentials lets any website read authenticated responses (CSRF-adjacent data theft).\nFix one of:\n • cors: { origin: ['https://app.example.com'], credentials: true } — explicit allow-list\n • cors: { origin: /\\.example\\.com$/, credentials: true } — pattern allow-list\n • cors: { origin: '*', credentials: false } — public, uncredentialed API");
|
|
@@ -1506,10 +1555,19 @@ function resolveCorsOptions(config) {
|
|
|
1506
1555
|
for (const arcHeader of ARC_EXPOSED_HEADERS) if (!declared.has(arcHeader)) exposed.push(arcHeader);
|
|
1507
1556
|
corsOptions.exposedHeaders = exposed;
|
|
1508
1557
|
}
|
|
1558
|
+
if (corsOptions.methods === void 0) {
|
|
1559
|
+
const origin = corsOptions.origin;
|
|
1560
|
+
if (typeof origin === "string" || Array.isArray(origin) || origin instanceof RegExp) corsOptions.methods = [...ARC_DEFAULT_CORS_METHODS];
|
|
1561
|
+
else if (corsOptions.credentials === true && (origin === true || typeof origin === "function")) {
|
|
1562
|
+
warnings.push("CORS `origin` reflects any origin (true or a function) with `credentials: true` and names no `methods`: arc keeps @fastify/cors's GET,HEAD,POST, so cross-origin PUT/PATCH/DELETE fail their preflight. Set cors.origin to an explicit allow-list (arc then allows its route verbs), or declare cors.methods yourself if the origin function already restricts origins.");
|
|
1563
|
+
methodsWarned = true;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1509
1566
|
if (corsOptions.maxAge === void 0) corsOptions.maxAge = DEFAULT_CORS_MAX_AGE;
|
|
1510
1567
|
return {
|
|
1511
1568
|
options: corsOptions,
|
|
1512
|
-
warnings
|
|
1569
|
+
warnings,
|
|
1570
|
+
methodsWarned
|
|
1513
1571
|
};
|
|
1514
1572
|
}
|
|
1515
1573
|
// src/factory/security/rateLimit.ts
|
|
@@ -1602,6 +1660,233 @@ function compilePathMatcher(patterns) {
|
|
|
1602
1660
|
return false;
|
|
1603
1661
|
};
|
|
1604
1662
|
}
|
|
1663
|
+
// src/factory/security/rateLimitStore.ts
|
|
1664
|
+
const DEFAULT_TIMEOUT_MS = 250;
|
|
1665
|
+
const DEFAULT_RETRY_AFTER_MS = 5e3;
|
|
1666
|
+
const DEFAULT_CAPACITY = 1e4;
|
|
1667
|
+
function positive(name, value, fallback) {
|
|
1668
|
+
if (value === void 0) return fallback;
|
|
1669
|
+
if (!Number.isFinite(value) || value <= 0) throw new Error(`[arc] rateLimit.storeFallback.${name} must be a positive number of milliseconds.`);
|
|
1670
|
+
return value;
|
|
1671
|
+
}
|
|
1672
|
+
/** One outage state per app: every route's child store switches together. */
|
|
1673
|
+
var StoreHealth = class {
|
|
1674
|
+
mode = "shared";
|
|
1675
|
+
since = /* @__PURE__ */ new Date();
|
|
1676
|
+
outages = 0;
|
|
1677
|
+
lastError;
|
|
1678
|
+
retryAt = 0;
|
|
1679
|
+
probing = false;
|
|
1680
|
+
retryAfterMs;
|
|
1681
|
+
log;
|
|
1682
|
+
onStatus;
|
|
1683
|
+
now;
|
|
1684
|
+
constructor(retryAfterMs, log, onStatus, now) {
|
|
1685
|
+
this.retryAfterMs = retryAfterMs;
|
|
1686
|
+
this.log = log;
|
|
1687
|
+
this.onStatus = onStatus;
|
|
1688
|
+
this.now = now;
|
|
1689
|
+
}
|
|
1690
|
+
/** Whether this call goes to the shared store: always when healthy, one probe at a time when degraded. */
|
|
1691
|
+
tryShared() {
|
|
1692
|
+
if (this.mode === "shared") return true;
|
|
1693
|
+
if (this.probing || this.now() < this.retryAt) return false;
|
|
1694
|
+
this.probing = true;
|
|
1695
|
+
return true;
|
|
1696
|
+
}
|
|
1697
|
+
succeeded() {
|
|
1698
|
+
this.probing = false;
|
|
1699
|
+
if (this.mode === "shared") return;
|
|
1700
|
+
this.mode = "shared";
|
|
1701
|
+
this.since = new Date(this.now());
|
|
1702
|
+
this.log.info({ outages: this.outages }, "[arc] rate-limit store recovered: limits are shared across instances again");
|
|
1703
|
+
this.report();
|
|
1704
|
+
}
|
|
1705
|
+
failed(err) {
|
|
1706
|
+
this.probing = false;
|
|
1707
|
+
this.retryAt = this.now() + this.retryAfterMs;
|
|
1708
|
+
if (this.mode === "fallback") return;
|
|
1709
|
+
this.mode = "fallback";
|
|
1710
|
+
this.since = new Date(this.now());
|
|
1711
|
+
this.outages++;
|
|
1712
|
+
this.lastError = err instanceof Error ? err.message : String(err);
|
|
1713
|
+
this.log.warn({
|
|
1714
|
+
err: this.lastError,
|
|
1715
|
+
retryAfterMs: this.retryAfterMs
|
|
1716
|
+
}, "[arc] rate-limit store unavailable: limiting per instance in memory until it answers again");
|
|
1717
|
+
this.report();
|
|
1718
|
+
}
|
|
1719
|
+
status() {
|
|
1720
|
+
return {
|
|
1721
|
+
mode: this.mode,
|
|
1722
|
+
since: this.since,
|
|
1723
|
+
outages: this.outages,
|
|
1724
|
+
...this.lastError !== void 0 ? { lastError: this.lastError } : {}
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
report() {
|
|
1728
|
+
try {
|
|
1729
|
+
this.onStatus?.(this.status());
|
|
1730
|
+
} catch {}
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
/** Fixed-window counters for one store (route); the oldest key is dropped at capacity. */
|
|
1734
|
+
var MemoryWindows = class {
|
|
1735
|
+
windows = /* @__PURE__ */ new Map();
|
|
1736
|
+
capacity;
|
|
1737
|
+
now;
|
|
1738
|
+
constructor(capacity, now) {
|
|
1739
|
+
this.capacity = capacity;
|
|
1740
|
+
this.now = now;
|
|
1741
|
+
}
|
|
1742
|
+
incr(key, timeWindow) {
|
|
1743
|
+
const now = this.now();
|
|
1744
|
+
let slot = this.windows.get(key);
|
|
1745
|
+
if (!slot || slot.start + timeWindow <= now) {
|
|
1746
|
+
if (slot) this.windows.delete(key);
|
|
1747
|
+
if (this.windows.size >= this.capacity) this.evict(now, timeWindow);
|
|
1748
|
+
slot = {
|
|
1749
|
+
start: now,
|
|
1750
|
+
current: 0
|
|
1751
|
+
};
|
|
1752
|
+
this.windows.set(key, slot);
|
|
1753
|
+
}
|
|
1754
|
+
slot.current++;
|
|
1755
|
+
return {
|
|
1756
|
+
current: slot.current,
|
|
1757
|
+
ttl: slot.start + timeWindow - now
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
read(key, timeWindow) {
|
|
1761
|
+
const now = this.now();
|
|
1762
|
+
const slot = this.windows.get(key);
|
|
1763
|
+
if (!slot || slot.start + timeWindow <= now) return {
|
|
1764
|
+
current: 0,
|
|
1765
|
+
ttl: 0
|
|
1766
|
+
};
|
|
1767
|
+
return {
|
|
1768
|
+
current: slot.current,
|
|
1769
|
+
ttl: slot.start + timeWindow - now
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
evict(now, timeWindow) {
|
|
1773
|
+
for (const [key, slot] of this.windows) if (slot.start + timeWindow <= now) this.windows.delete(key);
|
|
1774
|
+
while (this.windows.size >= this.capacity) {
|
|
1775
|
+
const oldest = this.windows.keys().next().value;
|
|
1776
|
+
if (oldest === void 0) break;
|
|
1777
|
+
this.windows.delete(oldest);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
var FallbackStore = class FallbackStore {
|
|
1782
|
+
memory;
|
|
1783
|
+
primary;
|
|
1784
|
+
health;
|
|
1785
|
+
timeoutMs;
|
|
1786
|
+
capacity;
|
|
1787
|
+
now;
|
|
1788
|
+
constructor(primary, health, timeoutMs, capacity, now) {
|
|
1789
|
+
this.primary = primary;
|
|
1790
|
+
this.health = health;
|
|
1791
|
+
this.timeoutMs = timeoutMs;
|
|
1792
|
+
this.capacity = capacity;
|
|
1793
|
+
this.now = now;
|
|
1794
|
+
this.memory = new MemoryWindows(capacity, now);
|
|
1795
|
+
}
|
|
1796
|
+
incr(key, cb, timeWindow, max) {
|
|
1797
|
+
this.call((done) => this.primary.incr(key, done, timeWindow, max), () => this.memory.incr(key, timeWindow), cb);
|
|
1798
|
+
}
|
|
1799
|
+
read(key, cb, timeWindow, max) {
|
|
1800
|
+
const read = this.primary.read;
|
|
1801
|
+
if (typeof read !== "function") {
|
|
1802
|
+
cb(/* @__PURE__ */ new Error("The configured rate-limit store does not implement a `read` method"));
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
this.call((done) => read.call(this.primary, key, done, timeWindow, max), () => this.memory.read(key, timeWindow), cb);
|
|
1806
|
+
}
|
|
1807
|
+
child(routeOptions) {
|
|
1808
|
+
return new FallbackStore(this.primary.child(routeOptions), this.health, this.timeoutMs, this.capacity, this.now);
|
|
1809
|
+
}
|
|
1810
|
+
call(shared, local, cb) {
|
|
1811
|
+
if (!this.health.tryShared()) {
|
|
1812
|
+
cb(null, local());
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
let settled = false;
|
|
1816
|
+
const settle = (err, res) => {
|
|
1817
|
+
if (settled) return;
|
|
1818
|
+
settled = true;
|
|
1819
|
+
clearTimeout(timer);
|
|
1820
|
+
if (err || !res) {
|
|
1821
|
+
this.health.failed(err ?? /* @__PURE__ */ new Error("rate-limit store returned no result"));
|
|
1822
|
+
cb(null, local());
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
this.health.succeeded();
|
|
1826
|
+
cb(null, res);
|
|
1827
|
+
};
|
|
1828
|
+
const timer = setTimeout(() => settle(/* @__PURE__ */ new Error(`rate-limit store did not answer within ${this.timeoutMs} ms`)), this.timeoutMs);
|
|
1829
|
+
timer.unref?.();
|
|
1830
|
+
try {
|
|
1831
|
+
shared((err, res) => settle(err, res));
|
|
1832
|
+
} catch (err) {
|
|
1833
|
+
settle(err);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
/**
|
|
1838
|
+
* Build the `@fastify/rate-limit` `store` class that wraps `createPrimary` (called with the
|
|
1839
|
+
* plugin's global params, as the plugin would construct a store) in the fallback.
|
|
1840
|
+
*/
|
|
1841
|
+
function createFallbackStoreClass(createPrimary, options) {
|
|
1842
|
+
const timeoutMs = positive("timeoutMs", options.timeoutMs, DEFAULT_TIMEOUT_MS);
|
|
1843
|
+
const retryAfterMs = positive("retryAfterMs", options.retryAfterMs, DEFAULT_RETRY_AFTER_MS);
|
|
1844
|
+
const capacity = positive("capacity", options.capacity, DEFAULT_CAPACITY);
|
|
1845
|
+
const now = options.now ?? Date.now;
|
|
1846
|
+
const health = new StoreHealth(retryAfterMs, options.log, options.onStatus, now);
|
|
1847
|
+
return class SharedStoreWithFallback extends FallbackStore {
|
|
1848
|
+
constructor(params) {
|
|
1849
|
+
super(createPrimary(params), health, timeoutMs, capacity, now);
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
const REDIS_STORE_SPECIFIER = "@fastify/rate-limit/store/RedisStore.js";
|
|
1854
|
+
async function loadRedisStore() {
|
|
1855
|
+
const mod = await import(REDIS_STORE_SPECIFIER);
|
|
1856
|
+
const ctor = mod.default ?? mod;
|
|
1857
|
+
if (typeof ctor !== "function") throw new Error(`[arc] ${REDIS_STORE_SPECIFIER} did not export the Redis store constructor`);
|
|
1858
|
+
return ctor;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Wrap the shared store of built rate-limit options in the fallback (default ON whenever a
|
|
1862
|
+
* shared store is configured; `storeFallback: false` keeps the plugin's own behaviour).
|
|
1863
|
+
* `storeFallback` itself is always removed from the options handed to the plugin.
|
|
1864
|
+
*/
|
|
1865
|
+
async function applyRateLimitStoreFallback(opts, log, deps = {}) {
|
|
1866
|
+
const { storeFallback, ...rest } = opts;
|
|
1867
|
+
if (storeFallback === false) return rest;
|
|
1868
|
+
const fallbackOptions = {
|
|
1869
|
+
...storeFallback ?? {},
|
|
1870
|
+
log,
|
|
1871
|
+
...deps.now ? { now: deps.now } : {}
|
|
1872
|
+
};
|
|
1873
|
+
if (rest.store != null) {
|
|
1874
|
+
const Store = rest.store;
|
|
1875
|
+
return {
|
|
1876
|
+
...rest,
|
|
1877
|
+
store: createFallbackStoreClass((params) => new Store(params), fallbackOptions)
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
if (rest.redis != null) {
|
|
1881
|
+
const { redis, nameSpace, ...withoutRedis } = rest;
|
|
1882
|
+
const RedisStore = await (deps.loadRedisStore ?? loadRedisStore)();
|
|
1883
|
+
return {
|
|
1884
|
+
...withoutRedis,
|
|
1885
|
+
store: createFallbackStoreClass((params) => new RedisStore(params.continueExceeding, params.exponentialBackoff, redis, nameSpace), fallbackOptions)
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
return rest;
|
|
1889
|
+
}
|
|
1605
1890
|
// src/factory/registerSecurity.ts
|
|
1606
1891
|
/**
|
|
1607
1892
|
* Register security plugins (Helmet, CORS, Rate Limiting).
|
|
@@ -1620,17 +1905,27 @@ async function registerSecurityPlugins(fastify, config) {
|
|
|
1620
1905
|
} else fastify.log.warn("Helmet disabled - security headers not applied");
|
|
1621
1906
|
if (config.cors !== false) {
|
|
1622
1907
|
const cors = await loadPlugin("cors");
|
|
1623
|
-
const { options: corsOptions, warnings } = resolveCorsOptions(config);
|
|
1908
|
+
const { options: corsOptions, warnings, methodsWarned } = resolveCorsOptions(config);
|
|
1624
1909
|
for (const warning of warnings) fastify.log.warn(warning);
|
|
1625
1910
|
await fastify.register(cors, corsOptions);
|
|
1911
|
+
const routeMethods = /* @__PURE__ */ new Set();
|
|
1912
|
+
fastify.addHook("onRoute", (route) => {
|
|
1913
|
+
for (const method of [route.method].flat()) routeMethods.add(String(method));
|
|
1914
|
+
});
|
|
1915
|
+
fastify.addHook("onReady", async () => {
|
|
1916
|
+
if (methodsWarned) return;
|
|
1917
|
+
const missing = corsMissingRouteMethods(corsOptions, routeMethods);
|
|
1918
|
+
if (missing.length === 0) return;
|
|
1919
|
+
fastify.log.warn(`CORS \`methods\` omit ${missing.join(", ")}, which registered routes use: cross-origin requests on those verbs fail their browser preflight. Declare cors.methods (e.g. ['GET','HEAD','POST','PUT','PATCH','DELETE','OPTIONS']) or set cors.origin to an explicit allow-list so arc allows its route verbs. Ignore this if those routes are same-origin only.`);
|
|
1920
|
+
});
|
|
1626
1921
|
fastify.log.debug("CORS enabled");
|
|
1627
1922
|
} else fastify.log.warn("CORS disabled");
|
|
1628
1923
|
if (config.rateLimit !== false) {
|
|
1629
1924
|
const rateLimit = await loadPlugin("rateLimit");
|
|
1630
|
-
const rateLimitOpts = buildRateLimitOpts(config.rateLimit ?? {
|
|
1925
|
+
const rateLimitOpts = await applyRateLimitStoreFallback(buildRateLimitOpts(config.rateLimit ?? {
|
|
1631
1926
|
max: 100,
|
|
1632
1927
|
timeWindow: "1 minute"
|
|
1633
|
-
});
|
|
1928
|
+
}), fastify.log);
|
|
1634
1929
|
await fastify.register(rateLimit, rateLimitOpts);
|
|
1635
1930
|
const rateLimitRecord = typeof rateLimitOpts === "object" && rateLimitOpts !== null ? rateLimitOpts : void 0;
|
|
1636
1931
|
const hasStore = rateLimitRecord !== void 0 && (rateLimitRecord.store != null || rateLimitRecord.redis != null);
|
|
@@ -1721,12 +2016,7 @@ async function registerUtilityPlugins(fastify, config) {
|
|
|
1721
2016
|
* resources: [productResource, orderResource],
|
|
1722
2017
|
* });
|
|
1723
2018
|
*/
|
|
1724
|
-
var createApp_exports = /* @__PURE__ */ __exportAll({
|
|
1725
|
-
ArcFactory: () => ArcFactory,
|
|
1726
|
-
DEFAULT_LOGGER_REDACT_PATHS: () => DEFAULT_LOGGER_REDACT_PATHS,
|
|
1727
|
-
createApp: () => createApp,
|
|
1728
|
-
resolveLoggerConfig: () => resolveLoggerConfig
|
|
1729
|
-
});
|
|
2019
|
+
var createApp_exports = /* @__PURE__ */ __exportAll({ createApp: () => createApp });
|
|
1730
2020
|
/**
|
|
1731
2021
|
* The fail-loud switches — ON by default — and what each one costs when a deployment turns it OFF.
|
|
1732
2022
|
* Reported together at production boot, so an opt-out is never silent.
|
|
@@ -1927,6 +2217,7 @@ async function buildApp(options, loggerScope, onInstance, onBootDisposer) {
|
|
|
1927
2217
|
...config.requestTimeout !== void 0 ? { requestTimeout: config.requestTimeout } : {},
|
|
1928
2218
|
...config.connectionTimeout !== void 0 ? { connectionTimeout: config.connectionTimeout } : {},
|
|
1929
2219
|
...config.keepAliveTimeout !== void 0 ? { keepAliveTimeout: config.keepAliveTimeout } : {},
|
|
2220
|
+
...config.http !== void 0 ? { http: { ...config.http } } : {},
|
|
1930
2221
|
allowErrorHandlerOverride: true,
|
|
1931
2222
|
routerOptions: {
|
|
1932
2223
|
querystringParser: (str) => qs.parse(str, {
|
|
@@ -1937,7 +2228,8 @@ async function buildApp(options, loggerScope, onInstance, onBootDisposer) {
|
|
|
1937
2228
|
}),
|
|
1938
2229
|
maxParamLength: config.maxParamLength ?? 400
|
|
1939
2230
|
},
|
|
1940
|
-
ajv: { customOptions: arcAjvCustomOptions(config.ajv?.keywords) }
|
|
2231
|
+
ajv: { customOptions: arcAjvCustomOptions(config.ajv?.keywords) },
|
|
2232
|
+
schemaController: { compilersFactory: { buildValidator: arcValidatorBuilder({ coerceBody: config.ajv?.coerceBody === true }) } }
|
|
1941
2233
|
});
|
|
1942
2234
|
markArcRootValidator(fastify);
|
|
1943
2235
|
onInstance(fastify);
|
|
@@ -1999,7 +2291,7 @@ async function buildApp(options, loggerScope, onInstance, onBootDisposer) {
|
|
|
1999
2291
|
await registerErrorHandler(fastify, config, trackPlugin, moduleErrorMappers);
|
|
2000
2292
|
await registerResources(fastify, config, resolvedModules, skippedBridges);
|
|
2001
2293
|
if (config.replyHelpers) {
|
|
2002
|
-
const { replyHelpersPlugin } = await import("./replyHelpers-
|
|
2294
|
+
const { replyHelpersPlugin } = await import("./replyHelpers-CUbeUc5q.mjs").then((n) => n.n);
|
|
2003
2295
|
await fastify.register(replyHelpersPlugin);
|
|
2004
2296
|
}
|
|
2005
2297
|
if (config.serializeBigInt) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { _ as ToolDefinition, c as McpAuthResult, r as CreateMcpServerConfig } from "./types-
|
|
2
|
+
import { _ as ToolDefinition, c as McpAuthResult, r as CreateMcpServerConfig } from "./types-B4E0sc6D.mjs";
|
|
3
3
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
4
4
|
/**
|
|
5
5
|
* Mutable auth ref — updated per-request by mcpPlugin.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
/*! @classytic/arc v2.50.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as arcLog } from "./logger-BagW7_YA.mjs";
|
|
3
|
+
import { C as isWriteVerbCapable, S as detectOverriddenWriteSlots, f as BaseController, i as resolveOpenApiSchemas, l as autoInjectTenantFieldRules, t as buildResourcePlugin } from "./plugin-DsLr6L4O.mjs";
|
|
4
|
+
import { m as MUTATION_OPERATIONS, t as CRUD_OPERATIONS } from "./constants-BZFsZwJh.mjs";
|
|
5
|
+
import { B as requireAuth } from "./permissions-BJylQopQ.mjs";
|
|
6
|
+
import { n as getAvailablePresets, t as applyPresets } from "./presets-D_suT4OY.mjs";
|
|
7
|
+
import { t as pluralize } from "./pluralize-CX4ZvwCa.mjs";
|
|
8
|
+
import { a as isZodSchema, i as isJsonSchema } from "./schemaConverter-JEmU21fu.mjs";
|
|
9
9
|
import { isReadOnlyRepo } from "@classytic/repo-core/repository";
|
|
10
10
|
import { readEnv } from "@classytic/primitives/environment";
|
|
11
11
|
// src/core/defineResource/writeVerbs.ts
|
package/dist/discovery/index.mjs
CHANGED
package/dist/docs/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { o as RegistryEntry } from "../index-Cy2-QffW.mjs";
|
|
3
2
|
import { t as ExternalOpenApiPaths } from "../externalPaths-BOqdq5wr.mjs";
|
|
3
|
+
import { o as RegistryEntry } from "../index-DLCcLUQT.mjs";
|
|
4
4
|
import { FastifyPluginAsync } from "fastify";
|
|
5
5
|
/**
|
|
6
6
|
* OpenAPI 3.0 type primitives used by arc's spec emitter.
|
package/dist/docs/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as
|
|
3
|
-
import { n as
|
|
1
|
+
/*! @classytic/arc v2.50.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as openapi_default, t as buildOpenApiSpec } from "../openapi-DXNbadgd.mjs";
|
|
3
|
+
import { n as getUserRoles } from "../userHelpers-D4m_pLSC.mjs";
|
|
4
4
|
import fp from "fastify-plugin";
|
|
5
5
|
// src/docs/scalar.ts
|
|
6
6
|
const scalarPlugin = async (fastify, opts = {}) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { t as arcLog } from "./logger-
|
|
4
|
-
import { n as requireSingleHeaderValue } from "./headers-
|
|
5
|
-
import { n as getUserRoles } from "./userHelpers-
|
|
1
|
+
/*! @classytic/arc v2.50.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-Ck1Tj4Ax.mjs";
|
|
3
|
+
import { t as arcLog } from "./logger-BagW7_YA.mjs";
|
|
4
|
+
import { n as requireSingleHeaderValue } from "./headers-BROW65-r.mjs";
|
|
5
|
+
import { n as getUserRoles } from "./userHelpers-D4m_pLSC.mjs";
|
|
6
6
|
import { ARC_ERROR_CODES } from "@classytic/repo-core/errors";
|
|
7
7
|
import fp from "fastify-plugin";
|
|
8
8
|
// src/scope/elevation.ts
|
|
@@ -36,10 +36,7 @@ import fp from "fastify-plugin";
|
|
|
36
36
|
* });
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
var elevation_exports = /* @__PURE__ */ __exportAll({
|
|
40
|
-
default: () => elevation_default,
|
|
41
|
-
elevationPlugin: () => elevationPlugin
|
|
42
|
-
});
|
|
39
|
+
var elevation_exports = /* @__PURE__ */ __exportAll({ elevationPlugin: () => elevationPlugin });
|
|
43
40
|
const log = arcLog("elevation");
|
|
44
41
|
const elevationPlugin = async (fastify, opts = {}) => {
|
|
45
42
|
const { platformRoles = ["superadmin"], scopeHeader = "x-arc-scope", orgHeader = "x-organization-id", onElevation } = opts;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as ArcError } from "../errors-
|
|
3
|
-
import { t as parseJsonBody } from "../jsonBody-
|
|
1
|
+
/*! @classytic/arc v2.50.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as ArcError } from "../errors-3xaK0i9n.mjs";
|
|
3
|
+
import { t as parseJsonBody } from "../jsonBody-C0oREwUc.mjs";
|
|
4
4
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
5
5
|
import fp from "fastify-plugin";
|
|
6
6
|
// src/encryption/fieldCipher.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { m as statusToArcCode, p as isArcError } from "./errors-
|
|
1
|
+
/*! @classytic/arc v2.50.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-Ck1Tj4Ax.mjs";
|
|
3
|
+
import { m as statusToArcCode, p as isArcError } from "./errors-3xaK0i9n.mjs";
|
|
4
4
|
import { isHttpError, toErrorContract } from "@classytic/repo-core/errors";
|
|
5
5
|
import { isProductionEnv } from "@classytic/primitives/environment";
|
|
6
6
|
import fp from "fastify-plugin";
|
|
@@ -30,10 +30,7 @@ import fp from "fastify-plugin";
|
|
|
30
30
|
* onError: (err) => Sentry.captureException(err),
|
|
31
31
|
* });
|
|
32
32
|
*/
|
|
33
|
-
var errorHandler_exports = /* @__PURE__ */ __exportAll({
|
|
34
|
-
defaultIsDuplicateKeyError: () => defaultIsDuplicateKeyError,
|
|
35
|
-
errorHandlerPlugin: () => errorHandlerPlugin
|
|
36
|
-
});
|
|
33
|
+
var errorHandler_exports = /* @__PURE__ */ __exportAll({ errorHandlerPlugin: () => errorHandlerPlugin });
|
|
37
34
|
/** Canonical 404 body for a request that matched no route. */
|
|
38
35
|
function notFoundContract(request) {
|
|
39
36
|
const correlationId = request.id;
|