@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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as CachePurgeError } from "../../purger.types-f83fTzGy.mjs";
|
|
3
|
+
// src/http-cache/purgers/fastly.ts
|
|
4
|
+
/**
|
|
5
|
+
* Fastly surrogate-key purge, with soft purge (`Fastly-Soft-Purge: 1`). Responses must carry the tags in
|
|
6
|
+
* `Surrogate-Key`, space-separated: register the plugin with `tagHeader: { name: 'Surrogate-Key', separator: ' ' }`.
|
|
7
|
+
* Fastly accepts 256 keys per bulk call. Failures throw `CachePurgeError`, never the API key.
|
|
8
|
+
*/
|
|
9
|
+
function createFastlyPurger(options) {
|
|
10
|
+
if (!options.serviceId?.trim()) throw new Error("[arc] createFastlyPurger: serviceId is required");
|
|
11
|
+
if (!options.apiKey?.trim()) throw new Error("[arc] createFastlyPurger: apiKey is required");
|
|
12
|
+
const size = options.maxTagsPerCall ?? 256;
|
|
13
|
+
if (!Number.isInteger(size) || size < 1) throw new Error("[arc] createFastlyPurger: maxTagsPerCall must be a positive integer");
|
|
14
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
15
|
+
if (typeof doFetch !== "function") throw new Error("[arc] createFastlyPurger: no fetch implementation available");
|
|
16
|
+
const url = `${options.apiBase ?? "https://api.fastly.com"}/service/${encodeURIComponent(options.serviceId)}/purge`;
|
|
17
|
+
return {
|
|
18
|
+
name: "fastly",
|
|
19
|
+
capabilities: {
|
|
20
|
+
softPurge: true,
|
|
21
|
+
maxTagsPerCall: size
|
|
22
|
+
},
|
|
23
|
+
async purgeTags(tags, { mode }) {
|
|
24
|
+
let res;
|
|
25
|
+
try {
|
|
26
|
+
res = await doFetch(url, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
"fastly-key": options.apiKey,
|
|
30
|
+
"content-type": "application/json",
|
|
31
|
+
accept: "application/json",
|
|
32
|
+
...mode === "soft" ? { "fastly-soft-purge": "1" } : {}
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify({ surrogate_keys: tags })
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
throw new CachePurgeError("fastly", "Fastly purge request could not be sent");
|
|
38
|
+
}
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
const body = await res.json().catch(() => void 0);
|
|
41
|
+
const code = typeof body?.msg === "string" ? [body.msg] : [];
|
|
42
|
+
throw new CachePurgeError("fastly", `Fastly purge refused (HTTP ${res.status})`, res.status, code);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export { createFastlyPurger };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
import { n as CachePurger } from "../../purger.types-DvPp4-yd.mjs";
|
|
3
|
+
import { FastifyInstance } from "fastify";
|
|
4
|
+
type CacheStatus = "HIT" | "MISS" | "EXPIRED" | "STALE" | "BYPASS" | "DYNAMIC";
|
|
5
|
+
interface CdnResponse {
|
|
6
|
+
status: number;
|
|
7
|
+
headers: Record<string, string>;
|
|
8
|
+
body: string;
|
|
9
|
+
cacheStatus: CacheStatus;
|
|
10
|
+
json<T = unknown>(): T;
|
|
11
|
+
}
|
|
12
|
+
interface CdnRequest {
|
|
13
|
+
method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
14
|
+
url: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
payload?: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface FakeCdnOptions {
|
|
19
|
+
/** The Cache Rule's bypass condition. Default: an `Authorization` header. */
|
|
20
|
+
bypass?: (headers: Record<string, string>) => boolean;
|
|
21
|
+
/** The tag header the origin sends. Default `{ name: 'Cache-Tag', separator: ',' }`. */
|
|
22
|
+
tagHeader?: {
|
|
23
|
+
name: string;
|
|
24
|
+
separator: string;
|
|
25
|
+
};
|
|
26
|
+
/** Whether this CDN supports soft purge. Default true. */
|
|
27
|
+
softPurge?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** The edge's reading of a response: TTL and stale windows, or 0 when it must not store. */
|
|
30
|
+
export declare function edgeFreshness(headers: Record<string, string>): {
|
|
31
|
+
ttl: number;
|
|
32
|
+
swr: number;
|
|
33
|
+
sie: number;
|
|
34
|
+
};
|
|
35
|
+
export declare function createFakeCdn(origin: () => FastifyInstance, opts?: FakeCdnOptions): {
|
|
36
|
+
request: (req: CdnRequest) => Promise<CdnResponse>;
|
|
37
|
+
purger: CachePurger;
|
|
38
|
+
stats: {
|
|
39
|
+
originRequests: number;
|
|
40
|
+
purges: Array<{
|
|
41
|
+
tags: string[];
|
|
42
|
+
mode: "hard" | "soft";
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
/** Move the edge clock forward. */
|
|
46
|
+
advance(ms: number): void;
|
|
47
|
+
/** URLs currently stored. */
|
|
48
|
+
keys: () => string[];
|
|
49
|
+
size: () => number;
|
|
50
|
+
};
|
|
51
|
+
type FakeCdn = ReturnType<typeof createFakeCdn>;
|
|
52
|
+
type HeaderBag = {
|
|
53
|
+
headers: Record<string, string | string[] | number | undefined>;
|
|
54
|
+
};
|
|
55
|
+
/** The response may be stored by a shared cache, optionally carrying these tags. */
|
|
56
|
+
export declare function expectCacheable(res: HeaderBag, opts?: {
|
|
57
|
+
tags?: readonly string[];
|
|
58
|
+
tagHeader?: string;
|
|
59
|
+
}): void;
|
|
60
|
+
/** No shared cache may store the response, and it carries no tags. */
|
|
61
|
+
export declare function expectPrivate(res: HeaderBag, opts?: {
|
|
62
|
+
tagHeader?: string;
|
|
63
|
+
}): void;
|
|
64
|
+
/** The edge served this request without reaching the origin. */
|
|
65
|
+
export declare function expectHit(res: CdnResponse): void;
|
|
66
|
+
/** These tags were purged (in any call, any mode). */
|
|
67
|
+
export declare function expectPurged(cdn: FakeCdn, tags: readonly string[]): void;
|
|
68
|
+
export type { CacheStatus, CdnRequest, CdnResponse, FakeCdn, FakeCdnOptions };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
// src/http-cache/testing/assertions.ts
|
|
3
|
+
const header = (res, name) => {
|
|
4
|
+
const v = res.headers[name];
|
|
5
|
+
return v === void 0 ? void 0 : Array.isArray(v) ? v.join(", ") : String(v);
|
|
6
|
+
};
|
|
7
|
+
/** The response may be stored by a shared cache, optionally carrying these tags. */
|
|
8
|
+
function expectCacheable(res, opts = {}) {
|
|
9
|
+
const cc = header(res, "cache-control") ?? "";
|
|
10
|
+
if (!/\bpublic\b/.test(cc)) throw new Error(`expected a public Cache-Control, got "${cc}"`);
|
|
11
|
+
if (opts.tags) {
|
|
12
|
+
const raw = header(res, (opts.tagHeader ?? "cache-tag").toLowerCase()) ?? "";
|
|
13
|
+
const got = new Set(raw.split(/[,\s]+/).filter(Boolean));
|
|
14
|
+
const missing = opts.tags.filter((t) => !got.has(t));
|
|
15
|
+
if (missing.length) throw new Error(`expected tags [${missing.join(", ")}] in "${raw}"`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** No shared cache may store the response, and it carries no tags. */
|
|
19
|
+
function expectPrivate(res, opts = {}) {
|
|
20
|
+
const cc = header(res, "cache-control") ?? "";
|
|
21
|
+
if (!/\bno-store\b/.test(cc)) throw new Error(`expected no-store, got "${cc}"`);
|
|
22
|
+
if (header(res, (opts.tagHeader ?? "cache-tag").toLowerCase())) throw new Error("a private response carried a tag header");
|
|
23
|
+
}
|
|
24
|
+
/** The edge served this request without reaching the origin. */
|
|
25
|
+
function expectHit(res) {
|
|
26
|
+
if (res.cacheStatus !== "HIT") throw new Error(`expected HIT, got ${res.cacheStatus}`);
|
|
27
|
+
}
|
|
28
|
+
/** These tags were purged (in any call, any mode). */
|
|
29
|
+
function expectPurged(cdn, tags) {
|
|
30
|
+
const sent = new Set(cdn.stats.purges.flatMap((p) => p.tags));
|
|
31
|
+
const missing = tags.filter((t) => !sent.has(t));
|
|
32
|
+
if (missing.length) throw new Error(`expected purge of [${missing.join(", ")}]; purged [${[...sent].join(", ")}]`);
|
|
33
|
+
}
|
|
34
|
+
// src/http-cache/testing/fake-cdn.ts
|
|
35
|
+
const directive = (cc, name) => {
|
|
36
|
+
const m = new RegExp(`(?:^|[,\\s])${name}=(\\d+)`).exec(cc);
|
|
37
|
+
return m ? Number(m[1]) : void 0;
|
|
38
|
+
};
|
|
39
|
+
/** The edge's reading of a response: TTL and stale windows, or 0 when it must not store. */
|
|
40
|
+
function edgeFreshness(headers) {
|
|
41
|
+
const target = headers["cdn-cache-control"];
|
|
42
|
+
const cc = (target ?? headers["cache-control"] ?? "").toLowerCase();
|
|
43
|
+
if (!cc || /\b(private|no-store|no-cache)\b/.test(cc)) return {
|
|
44
|
+
ttl: 0,
|
|
45
|
+
swr: 0,
|
|
46
|
+
sie: 0
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
ttl: target ? directive(cc, "max-age") ?? 0 : directive(cc, "s-maxage") ?? directive(cc, "max-age") ?? 0,
|
|
50
|
+
swr: directive(cc, "stale-while-revalidate") ?? 0,
|
|
51
|
+
sie: directive(cc, "stale-if-error") ?? 0
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function createFakeCdn(origin, opts = {}) {
|
|
55
|
+
const bypass = opts.bypass ?? ((h) => h.authorization !== void 0);
|
|
56
|
+
const tagName = (opts.tagHeader?.name ?? "Cache-Tag").toLowerCase();
|
|
57
|
+
const separator = opts.tagHeader?.separator ?? ",";
|
|
58
|
+
const store = /* @__PURE__ */ new Map();
|
|
59
|
+
const stats = {
|
|
60
|
+
originRequests: 0,
|
|
61
|
+
purges: []
|
|
62
|
+
};
|
|
63
|
+
let now = 0;
|
|
64
|
+
const visible = (headers) => {
|
|
65
|
+
const out = { ...headers };
|
|
66
|
+
delete out[tagName];
|
|
67
|
+
return out;
|
|
68
|
+
};
|
|
69
|
+
const respond = (status, headers, body, cacheStatus) => ({
|
|
70
|
+
status,
|
|
71
|
+
headers: {
|
|
72
|
+
...visible(headers),
|
|
73
|
+
"cf-cache-status": cacheStatus
|
|
74
|
+
},
|
|
75
|
+
body,
|
|
76
|
+
cacheStatus,
|
|
77
|
+
json: () => JSON.parse(body)
|
|
78
|
+
});
|
|
79
|
+
async function fetchOrigin(req, headers) {
|
|
80
|
+
stats.originRequests++;
|
|
81
|
+
const res = await origin().inject({
|
|
82
|
+
method: req.method ?? "GET",
|
|
83
|
+
url: req.url,
|
|
84
|
+
headers,
|
|
85
|
+
...req.payload !== void 0 ? { payload: req.payload } : {}
|
|
86
|
+
});
|
|
87
|
+
const out = Object.fromEntries(Object.entries(res.headers).map(([k, v]) => [k, Array.isArray(v) ? v.join(", ") : String(v)]));
|
|
88
|
+
return {
|
|
89
|
+
status: res.statusCode,
|
|
90
|
+
headers: out,
|
|
91
|
+
body: res.body
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function storeEntry(key, res) {
|
|
95
|
+
const fresh = res.status >= 200 && res.status < 300 && res.headers["set-cookie"] === void 0 ? edgeFreshness(res.headers) : void 0;
|
|
96
|
+
if (!fresh || fresh.ttl <= 0) {
|
|
97
|
+
store.delete(key);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const tags = new Set((res.headers[tagName] ?? "").split(separator).map((t) => t.trim()).filter(Boolean));
|
|
101
|
+
store.set(key, {
|
|
102
|
+
...res,
|
|
103
|
+
tags,
|
|
104
|
+
storedAt: now,
|
|
105
|
+
...fresh,
|
|
106
|
+
stale: false
|
|
107
|
+
});
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
async function request(req) {
|
|
111
|
+
const method = req.method ?? "GET";
|
|
112
|
+
const headers = Object.fromEntries(Object.entries(req.headers ?? {}).map(([k, v]) => [k.toLowerCase(), v]));
|
|
113
|
+
const key = `GET ${req.url}`;
|
|
114
|
+
if (!(method === "GET" || method === "HEAD")) {
|
|
115
|
+
const res = await fetchOrigin(req, headers);
|
|
116
|
+
return respond(res.status, res.headers, res.body, "DYNAMIC");
|
|
117
|
+
}
|
|
118
|
+
if (bypass(headers)) {
|
|
119
|
+
const res = await fetchOrigin(req, headers);
|
|
120
|
+
return respond(res.status, res.headers, res.body, "BYPASS");
|
|
121
|
+
}
|
|
122
|
+
const entry = store.get(key);
|
|
123
|
+
if (entry) {
|
|
124
|
+
const age = (now - entry.storedAt) / 1e3;
|
|
125
|
+
if (!(entry.stale || age >= entry.ttl)) return respond(entry.status, entry.headers, entry.body, "HIT");
|
|
126
|
+
if (age < entry.ttl + entry.swr || entry.stale) {
|
|
127
|
+
const served = respond(entry.status, entry.headers, entry.body, "STALE");
|
|
128
|
+
const res = await fetchOrigin(req, headers);
|
|
129
|
+
if (res.status < 500) storeEntry(key, res);
|
|
130
|
+
return served;
|
|
131
|
+
}
|
|
132
|
+
const res = await fetchOrigin(req, headers);
|
|
133
|
+
if (res.status >= 500 && age < entry.ttl + entry.sie) return respond(entry.status, entry.headers, entry.body, "STALE");
|
|
134
|
+
if (storeEntry(key, res)) return respond(res.status, res.headers, res.body, "EXPIRED");
|
|
135
|
+
return respond(res.status, res.headers, res.body, res.headers["set-cookie"] !== void 0 ? "BYPASS" : "DYNAMIC");
|
|
136
|
+
}
|
|
137
|
+
const res = await fetchOrigin(req, headers);
|
|
138
|
+
if (storeEntry(key, res)) return respond(res.status, res.headers, res.body, "MISS");
|
|
139
|
+
return respond(res.status, res.headers, res.body, res.headers["set-cookie"] !== void 0 ? "BYPASS" : "DYNAMIC");
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
request,
|
|
143
|
+
purger: {
|
|
144
|
+
name: "fake-cdn",
|
|
145
|
+
capabilities: { softPurge: opts.softPurge !== false },
|
|
146
|
+
async purgeTags(tags, { mode }) {
|
|
147
|
+
stats.purges.push({
|
|
148
|
+
tags: [...tags],
|
|
149
|
+
mode
|
|
150
|
+
});
|
|
151
|
+
for (const [key, entry] of store) {
|
|
152
|
+
if (!tags.some((t) => entry.tags.has(t))) continue;
|
|
153
|
+
if (mode === "soft" && opts.softPurge !== false) entry.stale = true;
|
|
154
|
+
else store.delete(key);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
stats,
|
|
159
|
+
/** Move the edge clock forward. */
|
|
160
|
+
advance(ms) {
|
|
161
|
+
now += ms;
|
|
162
|
+
},
|
|
163
|
+
/** URLs currently stored. */
|
|
164
|
+
keys: () => [...store.keys()].map((k) => k.slice(4)),
|
|
165
|
+
size: () => store.size
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export { createFakeCdn, edgeFreshness, expectCacheable, expectHit, expectPrivate, expectPurged };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { d as createDomainError } from "../errors-
|
|
3
|
-
import { n as requireSingleHeaderValue } from "../headers-
|
|
4
|
-
import { i as requestRequiresIdempotencyKey, n as idempotencyConfigProblem, r as requestDedupedByHandler, t as declaresIdempotencyFence } from "../requirement-
|
|
5
|
-
import { n as createSafeGetOne, t as createIsDuplicateKeyError } from "../store-helpers-
|
|
6
|
-
import { n as createIdempotencyResult, r as operationIdentity, t as resolveIdempotencyTiming } from "../timing-
|
|
7
|
-
import { n as acquireIdempotencyKey, r as releaseIdempotencyLock } from "../acquire-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { d as createDomainError } from "../errors-DyY48oRi.mjs";
|
|
3
|
+
import { n as requireSingleHeaderValue } from "../headers-CHSOqpcY.mjs";
|
|
4
|
+
import { i as requestRequiresIdempotencyKey, n as idempotencyConfigProblem, r as requestDedupedByHandler, t as declaresIdempotencyFence } from "../requirement-CxDxjB6V.mjs";
|
|
5
|
+
import { n as createSafeGetOne, t as createIsDuplicateKeyError } from "../store-helpers-rx-F2ZGR.mjs";
|
|
6
|
+
import { n as createIdempotencyResult, r as operationIdentity, t as resolveIdempotencyTiming } from "../timing-Dsteq59c.mjs";
|
|
7
|
+
import { n as acquireIdempotencyKey, r as releaseIdempotencyLock } from "../acquire-D2yj6Zzl.mjs";
|
|
8
8
|
import { ARC_ERROR_CODES } from "@classytic/repo-core/errors";
|
|
9
9
|
import { and, eq, exists, gt, lt, or, startsWith } from "@classytic/repo-core/filter";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import fp from "fastify-plugin";
|
|
12
|
-
import { IdempotencyError, fingerprintRequest } from "@classytic/repo-core/idempotency";
|
|
13
12
|
import { update } from "@classytic/repo-core/update";
|
|
13
|
+
import { IdempotencyError, fingerprintRequest } from "@classytic/repo-core/idempotency";
|
|
14
14
|
// src/idempotency/repository-idempotency-adapter.ts
|
|
15
15
|
/**
|
|
16
16
|
* The backing repository returned a document whose key does not match the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as acquireBySteps } from "../acquire-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as acquireBySteps } from "../acquire-D2yj6Zzl.mjs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
// src/idempotency/stores/redis.ts
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { i as RequestScope } from "./types-DnkIALZ8.mjs";
|
|
3
3
|
import { l as PermissionCheck, t as AnyRecord } from "./base-HXNgPQww.mjs";
|
|
4
|
-
import { A as RequestWithExtras, Dt as RouteMcpConfig, F as ResourceDefinition, Hn as IRequestContext, I as CrudController, L as ResourceConfig, O as FastifyWithDecorators, St as ActionDefinition, Vn as IControllerResponse, X as RouteSchemaOptions, Z as ArcFieldRule, g as RequestContext, k as MiddlewareHandler, ot as AggregationConfig, v as CrudRouterOptions } from "./index-
|
|
5
|
-
import "./fastify-augmentation-
|
|
4
|
+
import { A as RequestWithExtras, Dt as RouteMcpConfig, F as ResourceDefinition, Hn as IRequestContext, I as CrudController, L as ResourceConfig, O as FastifyWithDecorators, St as ActionDefinition, Vn as IControllerResponse, X as RouteSchemaOptions, Z as ArcFieldRule, g as RequestContext, k as MiddlewareHandler, ot as AggregationConfig, v as CrudRouterOptions } from "./index-Cy2-QffW.mjs";
|
|
5
|
+
import "./fastify-augmentation-bzkWPt1f.mjs";
|
|
6
6
|
import { Filter } from "@classytic/repo-core/filter";
|
|
7
7
|
import { FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
|
|
8
8
|
import { z } from "zod";
|
|
@@ -5,6 +5,7 @@ import { a as QueryCacheConfig } from "./QueryCache-DdvrGG8Q.mjs";
|
|
|
5
5
|
import "./elevation-DPD0hcU-.mjs";
|
|
6
6
|
import "./requirement-CTRQjjQx.mjs";
|
|
7
7
|
import { n as FieldPermissionMap } from "./fields-JTkrtO-r.mjs";
|
|
8
|
+
import { s as ResourceHttpCacheConfig } from "./policy.types-DPqToKG1.mjs";
|
|
8
9
|
import { n as EncryptionDirective } from "./types-0Dqlbgn8.mjs";
|
|
9
10
|
import { n as DomainEvent } from "./EventTransport-CYEoCJGe.mjs";
|
|
10
11
|
import { Filter } from "@classytic/repo-core/filter";
|
|
@@ -3489,6 +3490,11 @@ interface ResourceConfig<TDoc = AnyRecord> {
|
|
|
3489
3490
|
rateLimit?: RateLimitConfig | false;
|
|
3490
3491
|
/** Idempotency-key fence for the built-in write routes. See `ResourceIdempotencyConfig`. */
|
|
3491
3492
|
idempotency?: ResourceIdempotencyConfig;
|
|
3493
|
+
/**
|
|
3494
|
+
* HTTP caching for the built-in `list` / `get` routes: tags `<name>` and `<name>:<id>` are derived, and
|
|
3495
|
+
* the resource's CRUD events purge them. Requires `httpCachePlugin` (`@classytic/arc/http-cache`).
|
|
3496
|
+
*/
|
|
3497
|
+
httpCache?: ResourceHttpCacheConfig;
|
|
3492
3498
|
/**
|
|
3493
3499
|
* QueryCache configuration for this resource. Enables
|
|
3494
3500
|
* stale-while-revalidate and auto-invalidation. Requires
|
|
@@ -3637,6 +3643,7 @@ declare class ResourceDefinition<TDoc = AnyRecord> {
|
|
|
3637
3643
|
readonly events: Record<string, EventDefinition>;
|
|
3638
3644
|
readonly rateLimit?: RateLimitConfig | false;
|
|
3639
3645
|
readonly idempotency?: ResourceIdempotencyConfig;
|
|
3646
|
+
readonly httpCache?: ResourceHttpCacheConfig;
|
|
3640
3647
|
readonly lookupFields?: readonly string[];
|
|
3641
3648
|
readonly audit?: boolean | {
|
|
3642
3649
|
operations?: ("create" | "update" | "delete")[];
|
|
@@ -4120,6 +4127,8 @@ interface CrudRouterOptions {
|
|
|
4120
4127
|
rateLimit?: RateLimitConfig | false;
|
|
4121
4128
|
/** Idempotency-key fence for the built-in write routes. */
|
|
4122
4129
|
idempotency?: ResourceIdempotencyConfig;
|
|
4130
|
+
/** HTTP caching for the built-in list/get routes. */
|
|
4131
|
+
httpCache?: ResourceHttpCacheConfig;
|
|
4123
4132
|
/** PreHandler guards applied to every route (CRUD + custom + preset). */
|
|
4124
4133
|
routeGuards?: RouteHandlerMethod[];
|
|
4125
4134
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { Mt as Authenticator } from "./index-
|
|
2
|
+
import { Mt as Authenticator } from "./index-Cy2-QffW.mjs";
|
|
3
3
|
import { r as CacheStore } from "./interface-WR1U0K7t.mjs";
|
|
4
4
|
import { n as ElevationOptions } from "./elevation-DPD0hcU-.mjs";
|
|
5
5
|
import { a as EventTransport } from "./EventTransport-CYEoCJGe.mjs";
|
|
@@ -7,7 +7,7 @@ import { t as ExternalOpenApiPaths } from "./externalPaths-BOqdq5wr.mjs";
|
|
|
7
7
|
import { r as QueryCachePluginOptions } from "./queryCachePlugin-DYQUyeJ9.mjs";
|
|
8
8
|
import { t as ErrorHandlerOptions } from "./errorHandler-B9r88jZV.mjs";
|
|
9
9
|
import { I as HealthOptions, _ as ResourceLike, o as ArcPorts, r as ArcModuleInput, w as SchedulesPluginOptions } from "./types-BeEJm-DV.mjs";
|
|
10
|
-
import { H as ModuleGraphOptions } from "./index-
|
|
10
|
+
import { H as ModuleGraphOptions } from "./index-DFCCQ9AE.mjs";
|
|
11
11
|
import { t as EventPluginOptions } from "./eventPlugin-BY38F6yK.mjs";
|
|
12
12
|
import { a as MetricsOptions, c as RealtimeOptions, g as GracefulShutdownOptions, p as CachingOptions, t as VersioningOptions, u as SSEOptions } from "./versioning-S18y2-0C.mjs";
|
|
13
13
|
import { i as IdempotencyStore } from "./interface-BmExzQRD.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { F as ResourceDefinition } from "./index-
|
|
2
|
+
import { F as ResourceDefinition } from "./index-Cy2-QffW.mjs";
|
|
3
3
|
import { h as ModuleSetupContext, i as ArcModuleRegistry, l as ModuleContribution, n as ArcModule, o as ArcPorts, p as PortName, r as ArcModuleInput, u as ModuleName } from "./types-BeEJm-DV.mjs";
|
|
4
4
|
import { FastifyInstance } from "fastify";
|
|
5
5
|
type ModuleKind = "domain" | "bridge" | "platform" | "aggregator";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { c as DataPolicy, d as UserBase, l as PermissionCheck, n as ArcRequest, o as UserOrganization, r as JWTPayload, s as AuthorizationDecision, t as AnyRecord, u as PermissionContext } from "./base-HXNgPQww.mjs";
|
|
3
|
-
import { A as RequestWithExtras, Bn as IController, Bt as TreeMixin, C as RequestIdOptions, Cn as ArcGetResult, D as FastifyWithAuth, Dn as ControllerConfigurableOptions, E as FastifyRequestExtras, En as BaseControllerOptions, F as ResourceDefinition, Fn as WriteContext, G as CrudRouteKey, Gt as BaseCrudController, H as PresetFunction, Hn as IRequestContext, Ht as SlugMixin, I as CrudController, In as WriteVerbKey, It as BaseController, J as MiddlewareConfig, K as CrudSchemas, L as ResourceConfig, Lt as SoftDeleteExt, Nn as MutationWriteContext, O as FastifyWithDecorators, On as ControllerConstructionOptions, P as defineResource, Pn as ResourceWrites, Q as FieldRule, Rn as ControllerLike, Rt as SoftDeleteMixin, S as IntrospectionPluginOptions, Sn as ArcDeleteResult, Tn as ArcUpdateResult, Un as RawRouteHandler, Ut as BulkExt, Vn as IControllerResponse, Vt as SlugExt, W as PresetResult, Wn as RouteHandler, Wt as BulkMixin, X as RouteSchemaOptions, _ as ServiceContext, a as IntrospectionData, at as AggregationCacheConfig, b as HealthCheck, c as ResourceMetadata, ct as AggregationIndexHint, dt as AggregationRateLimit, f as OwnershipCheck, ft as AggregationsMap, g as RequestContext, h as QueryParserInterface, i as PaginationResult, it as AggMeasureShorthand, jt as AuthPluginOptions, kn as ListResult, kt as RateLimitConfig, l as ArcInternalMetadata, lt as AggregationMaterializedContext, n as InferDocType, nt as EventDefinition, o as RegistryEntry, ot as AggregationConfig, r as InferResourceDoc, rt as AggMeasureInput, s as RegistryStats, st as AggregationDateRangeRequirement, t as InferAdapterDoc, ut as AggregationMaterializedResult, v as CrudRouterOptions, wn as ArcListResult, x as HealthOptions, xn as ArcCreateResult, y as GracefulShutdownOptions, zt as TreeExt } from "./index-
|
|
3
|
+
import { A as RequestWithExtras, Bn as IController, Bt as TreeMixin, C as RequestIdOptions, Cn as ArcGetResult, D as FastifyWithAuth, Dn as ControllerConfigurableOptions, E as FastifyRequestExtras, En as BaseControllerOptions, F as ResourceDefinition, Fn as WriteContext, G as CrudRouteKey, Gt as BaseCrudController, H as PresetFunction, Hn as IRequestContext, Ht as SlugMixin, I as CrudController, In as WriteVerbKey, It as BaseController, J as MiddlewareConfig, K as CrudSchemas, L as ResourceConfig, Lt as SoftDeleteExt, Nn as MutationWriteContext, O as FastifyWithDecorators, On as ControllerConstructionOptions, P as defineResource, Pn as ResourceWrites, Q as FieldRule, Rn as ControllerLike, Rt as SoftDeleteMixin, S as IntrospectionPluginOptions, Sn as ArcDeleteResult, Tn as ArcUpdateResult, Un as RawRouteHandler, Ut as BulkExt, Vn as IControllerResponse, Vt as SlugExt, W as PresetResult, Wn as RouteHandler, Wt as BulkMixin, X as RouteSchemaOptions, _ as ServiceContext, a as IntrospectionData, at as AggregationCacheConfig, b as HealthCheck, c as ResourceMetadata, ct as AggregationIndexHint, dt as AggregationRateLimit, f as OwnershipCheck, ft as AggregationsMap, g as RequestContext, h as QueryParserInterface, i as PaginationResult, it as AggMeasureShorthand, jt as AuthPluginOptions, kn as ListResult, kt as RateLimitConfig, l as ArcInternalMetadata, lt as AggregationMaterializedContext, n as InferDocType, nt as EventDefinition, o as RegistryEntry, ot as AggregationConfig, r as InferResourceDoc, rt as AggMeasureInput, s as RegistryStats, st as AggregationDateRangeRequirement, t as InferAdapterDoc, ut as AggregationMaterializedResult, v as CrudRouterOptions, wn as ArcListResult, x as HealthOptions, xn as ArcCreateResult, y as GracefulShutdownOptions, zt as TreeExt } from "./index-Cy2-QffW.mjs";
|
|
4
4
|
import { a as applyFieldReadPermissions, n as FieldPermissionMap, o as applyFieldWritePermissions, s as fields, t as FieldPermission } from "./fields-JTkrtO-r.mjs";
|
|
5
|
-
import "./fastify-augmentation-
|
|
6
|
-
import { $ as RESERVED_QUERY_PARAMS, B as DEFAULT_SORT, D as ResourceSeams, E as AdapterLike, F as CRUD_OPERATIONS, G as HOOK_PHASES, H as DEFAULT_UPDATE_METHOD, I as CrudOperation, J as MAX_FILTER_DEPTH, K as HookOperation, L as DEFAULT_ID_FIELD, O as SeamedResourceConfig, P as defineAggregation, Q as MutationOperation, R as DEFAULT_LIMIT, T as defineResourceVariants, V as DEFAULT_TENANT_FIELD, W as HOOK_OPERATIONS, X as MAX_SEARCH_LENGTH, Y as MAX_REGEX_LENGTH, Z as MUTATION_OPERATIONS, b as getControllerScope, et as SYSTEM_FIELDS, j as defineAction, k as mergeResourceConfig, m as nativePolicyFilter, p as NativePolicyFilter, q as HookPhase, z as DEFAULT_MAX_LIMIT } from "./index-
|
|
5
|
+
import "./fastify-augmentation-bzkWPt1f.mjs";
|
|
6
|
+
import { $ as RESERVED_QUERY_PARAMS, B as DEFAULT_SORT, D as ResourceSeams, E as AdapterLike, F as CRUD_OPERATIONS, G as HOOK_PHASES, H as DEFAULT_UPDATE_METHOD, I as CrudOperation, J as MAX_FILTER_DEPTH, K as HookOperation, L as DEFAULT_ID_FIELD, O as SeamedResourceConfig, P as defineAggregation, Q as MutationOperation, R as DEFAULT_LIMIT, T as defineResourceVariants, V as DEFAULT_TENANT_FIELD, W as HOOK_OPERATIONS, X as MAX_SEARCH_LENGTH, Y as MAX_REGEX_LENGTH, Z as MUTATION_OPERATIONS, b as getControllerScope, et as SYSTEM_FIELDS, j as defineAction, k as mergeResourceConfig, m as nativePolicyFilter, p as NativePolicyFilter, q as HookPhase, z as DEFAULT_MAX_LIMIT } from "./index-BxZS-8So.mjs";
|
|
7
7
|
import { C as requireScopeContext, G as createDynamicPermissionMatrix, H as DynamicPermissionMatrix, J as PublicPolicy, K as createOrgPermissions, Q as anyOf, S as requireOrgRole, T as requireTeamMembership, U as DynamicPermissionMatrixConfig, Y as allOf, Z as allowPublic, _ as publicRead, at as requireRoles, b as requireOrgInScope, d as adminOnly, et as denyAll, f as authenticated, g as presets_d_exports, m as ownerWithAdminBypass, nt as requireAuth, p as fullPublic, q as AllowPublicOptions, rt as requireOwnership, st as when, v as publicReadAdminWrite, w as requireServiceScope, x as requireOrgMembership, y as readOnly } from "./index-B5i9-vuP.mjs";
|
|
8
8
|
import { a as NotFoundError, d as ValidationError, f as createDomainError, i as ForbiddenError, t as ArcError, u as UnauthorizedError } from "./errors-DTo0me1o.mjs";
|
|
9
9
|
export declare const version: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { a as DEFAULT_SORT, d as MAX_FILTER_DEPTH, f as MAX_REGEX_LENGTH, g as SYSTEM_FIELDS, h as RESERVED_QUERY_PARAMS, i as DEFAULT_MAX_LIMIT, l as HOOK_OPERATIONS, m as MUTATION_OPERATIONS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MAX_SEARCH_LENGTH, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as HOOK_PHASES } from "./constants-
|
|
3
|
-
import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-
|
|
4
|
-
import { E as nativePolicyFilter, _ as BaseCrudController, f as BaseController, g as BulkMixin, h as SlugMixin, m as SoftDeleteMixin, p as TreeMixin } from "./plugin-
|
|
5
|
-
import { t as defineAggregation } from "./defineAggregation-
|
|
6
|
-
import { i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "./fields-
|
|
7
|
-
import { S as getControllerScope } from "./actionPermissions-
|
|
8
|
-
import { a as defineResourceVariants, o as mergeResourceConfig, s as defineAction } from "./core-
|
|
9
|
-
import { a as ResourceDefinition, t as defineResource } from "./defineResource-
|
|
10
|
-
import { B as requireAuth, C as createOrgPermissions, D as requireScopeContext, E as requireOrgRole, F as allowPublic, G as when, I as anyOf, N as allOf, O as requireServiceScope, R as denyAll, S as createDynamicPermissionMatrix, T as requireOrgMembership, U as requireRoles, V as requireOwnership, a as adminOnly, c as ownerWithAdminBypass, d as publicRead, f as publicReadAdminWrite, k as requireTeamMembership, o as authenticated, p as readOnly, s as fullPublic, u as presets_exports, w as requireOrgInScope } from "./permissions-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { a as DEFAULT_SORT, d as MAX_FILTER_DEPTH, f as MAX_REGEX_LENGTH, g as SYSTEM_FIELDS, h as RESERVED_QUERY_PARAMS, i as DEFAULT_MAX_LIMIT, l as HOOK_OPERATIONS, m as MUTATION_OPERATIONS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MAX_SEARCH_LENGTH, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as HOOK_PHASES } from "./constants-D-faL5SX.mjs";
|
|
3
|
+
import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-DyY48oRi.mjs";
|
|
4
|
+
import { E as nativePolicyFilter, _ as BaseCrudController, f as BaseController, g as BulkMixin, h as SlugMixin, m as SoftDeleteMixin, p as TreeMixin } from "./plugin-BJcVOX5r.mjs";
|
|
5
|
+
import { t as defineAggregation } from "./defineAggregation-DH2L6_v9.mjs";
|
|
6
|
+
import { i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "./fields-rfsl26Ov.mjs";
|
|
7
|
+
import { S as getControllerScope } from "./actionPermissions-Dha8sAz2.mjs";
|
|
8
|
+
import { a as defineResourceVariants, o as mergeResourceConfig, s as defineAction } from "./core-NSu1peyq.mjs";
|
|
9
|
+
import { a as ResourceDefinition, t as defineResource } from "./defineResource-zYCrhNaN.mjs";
|
|
10
|
+
import { B as requireAuth, C as createOrgPermissions, D as requireScopeContext, E as requireOrgRole, F as allowPublic, G as when, I as anyOf, N as allOf, O as requireServiceScope, R as denyAll, S as createDynamicPermissionMatrix, T as requireOrgMembership, U as requireRoles, V as requireOwnership, a as adminOnly, c as ownerWithAdminBypass, d as publicRead, f as publicReadAdminWrite, k as requireTeamMembership, o as authenticated, p as readOnly, s as fullPublic, u as presets_exports, w as requireOrgInScope } from "./permissions-R9T2G1PH.mjs";
|
|
11
11
|
// src/index.ts
|
|
12
|
-
const version = "2.
|
|
12
|
+
const version = "2.48.0";
|
|
13
13
|
export { ArcError, BaseController, BaseCrudController, BulkMixin, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, ForbiddenError, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, NotFoundError, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, mergeResourceConfig, nativePolicyFilter, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
2
|
import fp from "fastify-plugin";
|
|
3
3
|
// src/integrations/event-gateway.ts
|
|
4
4
|
const eventGatewayPluginImpl = async (fastify, opts = {}) => {
|
|
5
5
|
const { auth = true, orgScoped, roomPolicy, maxMessageBytes, maxSubscriptionsPerClient, authenticate } = opts;
|
|
6
6
|
if (auth && !authenticate && !fastify.hasDecorator("authenticate")) throw new Error("[arc-event-gateway] auth is true but fastify.authenticate is not registered. Register an auth plugin first, provide a custom authenticate function, or set auth: false.");
|
|
7
7
|
if (opts.sse !== false) {
|
|
8
|
-
const { default: ssePlugin } = await import("../sse-
|
|
8
|
+
const { default: ssePlugin } = await import("../sse-BqM359f1.mjs").then((n) => n.n);
|
|
9
9
|
await fastify.register(ssePlugin, {
|
|
10
10
|
path: opts.sse?.path ?? "/events/stream",
|
|
11
11
|
requireAuth: auth,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { c as WebSocketClient, l as WebSocketMessage, u as WebSocketPluginOptions } from "../websocket-BGuc-WVZ.mjs";
|
|
3
3
|
import { EventGatewayOptions } from "./event-gateway.mjs";
|
|
4
4
|
import { a as JobMeta, c as JobsPluginOptions, i as JobDispatcher, l as QueueStats, n as JobDefinition, r as JobDispatchOptions } from "../index-BAXDo5eE.mjs";
|
|
5
|
-
import { _ as ToolDefinition, c as McpAuthResult, d as McpResourceConfig,
|
|
5
|
+
import { _ as ToolDefinition, c as McpAuthResult, d as McpResourceConfig, g as ToolContext, h as ToolAnnotations, n as CallToolResult, o as CrudOperation, p as PromptDefinition, r as CreateMcpServerConfig, t as BetterAuthHandler, u as McpPluginOptions } from "../types-DduBiYaI.mjs";
|
|
6
6
|
import { StreamlinePluginOptions, WorkflowLike, WorkflowRunLike } from "./streamline.mjs";
|
|
7
7
|
import { WebhookDeliveryRecord, WebhookManager, WebhookPluginOptions, WebhookStore, WebhookSubscription } from "./webhooks.mjs";
|
|
8
8
|
export type { BetterAuthHandler, CallToolResult, CreateMcpServerConfig, CrudOperation, EventGatewayOptions, JobDefinition, JobDispatchOptions, JobDispatcher, JobMeta, JobsPluginOptions, McpAuthResult, McpPluginOptions, McpResourceConfig, PromptDefinition, QueueStats, StreamlinePluginOptions, ToolAnnotations, ToolContext, ToolDefinition, WebSocketClient, WebSocketMessage, WebSocketPluginOptions, WebhookDeliveryRecord, WebhookManager, WebhookPluginOptions, WebhookStore, WebhookSubscription, WorkflowLike, WorkflowRunLike };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
2
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as evaluateAndApplyPermission } from "../../authorizationDecision-
|
|
3
|
-
import { i as runAdmittedWork, r as registerShutdownParticipant } from "../../shutdown-
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as evaluateAndApplyPermission } from "../../authorizationDecision-BZSJcPNE.mjs";
|
|
3
|
+
import { i as runAdmittedWork, r as registerShutdownParticipant } from "../../shutdown-Bi19vH0z.mjs";
|
|
4
4
|
import fp from "fastify-plugin";
|
|
5
5
|
// src/integrations/jobs/execution.ts
|
|
6
6
|
async function executeTimedHandler(options) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { i as RequestScope } from "../../types-DnkIALZ8.mjs";
|
|
3
3
|
import { l as PermissionCheck } from "../../base-HXNgPQww.mjs";
|
|
4
|
-
import { F as ResourceDefinition, Gn as ServerAccessor, Hn as IRequestContext, Vn as IControllerResponse } from "../../index-
|
|
4
|
+
import { F as ResourceDefinition, Gn as ServerAccessor, Hn as IRequestContext, Vn as IControllerResponse } from "../../index-Cy2-QffW.mjs";
|
|
5
5
|
import { n as FieldPermissionMap } from "../../fields-JTkrtO-r.mjs";
|
|
6
6
|
import "../../resourceRateLimit-DCWglD7V.mjs";
|
|
7
|
-
import { _ as ToolDefinition, a as CrudDescriptionOverride, c as McpAuthResult, d as McpResourceConfig, f as
|
|
8
|
-
import { i as resolveToolCollisions, n as McpServerInstance, r as createMcpServer, t as AuthRef } from "../../createMcpServer-
|
|
7
|
+
import { _ as ToolDefinition, a as CrudDescriptionOverride, c as McpAuthResult, d as McpResourceConfig, f as McpToolLogger, g as ToolContext, h as ToolAnnotations, i as CrudDescriptionMeta, l as McpExecutionWiring, m as PromptResult, n as CallToolResult, o as CrudOperation, p as PromptDefinition, r as CreateMcpServerConfig, s as McpAuthResolver, t as BetterAuthHandler, u as McpPluginOptions, v as ToolInputSchema } from "../../types-DduBiYaI.mjs";
|
|
8
|
+
import { i as resolveToolCollisions, n as McpServerInstance, r as createMcpServer, t as AuthRef } from "../../createMcpServer-hSFeqRUb.mjs";
|
|
9
9
|
import { ErrorContract } from "@classytic/repo-core/errors";
|
|
10
10
|
import { FastifyPluginAsync } from "fastify";
|
|
11
11
|
import { z } from "zod";
|
|
@@ -422,34 +422,6 @@ export declare function invokeController(controller: unknown, op: McpOperation,
|
|
|
422
422
|
* ```
|
|
423
423
|
*/
|
|
424
424
|
export declare function mcpHandlerAdapter<TSession = McpAuthResult>(fn: (input: Record<string, unknown>, ctx: ToolContext<TSession>) => Promise<unknown>): ToolDefinition<TSession>["handler"];
|
|
425
|
-
declare class McpSessionCache {
|
|
426
|
-
private sessions;
|
|
427
|
-
private ttlMs;
|
|
428
|
-
private maxSessions;
|
|
429
|
-
private cleanupTimer;
|
|
430
|
-
constructor(opts?: {
|
|
431
|
-
ttlMs?: number;
|
|
432
|
-
maxSessions?: number;
|
|
433
|
-
});
|
|
434
|
-
/** Get an existing session by ID */
|
|
435
|
-
get(sessionId: string): SessionEntry | undefined;
|
|
436
|
-
/** Store a new session */
|
|
437
|
-
set(sessionId: string, entry: SessionEntry): void;
|
|
438
|
-
/** Refresh the TTL on a session */
|
|
439
|
-
touch(sessionId: string): void;
|
|
440
|
-
/** Remove and close a session */
|
|
441
|
-
remove(sessionId: string): void;
|
|
442
|
-
/** Remove all expired sessions */
|
|
443
|
-
cleanup(): void;
|
|
444
|
-
/** Close all sessions and stop cleanup timer */
|
|
445
|
-
close(): void;
|
|
446
|
-
/** Current session count */
|
|
447
|
-
get size(): number;
|
|
448
|
-
/** Evict the oldest (least recently accessed) session */
|
|
449
|
-
private evictOldest;
|
|
450
|
-
/** Safely close a transport */
|
|
451
|
-
private closeTransport;
|
|
452
|
-
}
|
|
453
425
|
/**
|
|
454
426
|
* Per-prefix MCP registration info. A single fastify instance can register
|
|
455
427
|
* mcpPlugin multiple times under different prefixes (e.g. `/mcp/catalog`,
|
|
@@ -457,19 +429,15 @@ declare class McpSessionCache {
|
|
|
457
429
|
* setups can inspect any endpoint's tool list, not just the first one.
|
|
458
430
|
*/
|
|
459
431
|
interface McpRegistration {
|
|
460
|
-
sessions: McpSessionCache | null;
|
|
461
432
|
toolNames: string[];
|
|
462
433
|
resourceNames: string[];
|
|
463
|
-
stateful: boolean;
|
|
464
434
|
}
|
|
465
435
|
interface McpDecorator {
|
|
466
436
|
/** Map of prefix → registration info. Iterate for all endpoints. */
|
|
467
437
|
registrations: Map<string, McpRegistration>;
|
|
468
438
|
/** Shortcut for the first registered prefix (back-compat for single-endpoint apps) */
|
|
469
|
-
readonly sessions: McpSessionCache | null;
|
|
470
439
|
readonly toolNames: string[];
|
|
471
440
|
readonly resourceNames: string[];
|
|
472
|
-
readonly stateful: boolean;
|
|
473
441
|
/** Look up a specific prefix */
|
|
474
442
|
get(prefix: string): McpRegistration | undefined;
|
|
475
443
|
}
|
|
@@ -627,4 +595,4 @@ export declare function permissionDeniedResult(args: {
|
|
|
627
595
|
reason?: string;
|
|
628
596
|
session: McpAuthResult | null;
|
|
629
597
|
}): CallToolResult;
|
|
630
|
-
export { type AuthRef, type BetterAuthHandler, type BuildMcpToolsFromBridgesOptions, type CallToolResult, type CreateMcpAuthFromBetterAuthApiKeyOptions, type CreateMcpServerConfig, type CrudDescriptionMeta, type CrudDescriptionOverride, type CrudOperation, type DefinePromptConfig, type DefineToolConfig, type DispatchOptions, type FieldRuleEntry, type FieldRulesToZodOptions, type InvokeControllerOptions, type McpAuthResolver, type McpAuthResult, type McpBridge, type McpContextExtras, type McpGuard, type McpOperation, type McpPluginOptions, type McpResourceConfig, type McpServerInstance, type PromptDefinition, type PromptResult, type RealtimeToolCall, type RealtimeToolResponse, type ResourceToToolsConfig, type ToolAnnotations, type ToolContext, type ToolDefinition, type ToolInputSchema, createMcpServer, resolveToolCollisions };
|
|
598
|
+
export { type AuthRef, type BetterAuthHandler, type BuildMcpToolsFromBridgesOptions, type CallToolResult, type CreateMcpAuthFromBetterAuthApiKeyOptions, type CreateMcpServerConfig, type CrudDescriptionMeta, type CrudDescriptionOverride, type CrudOperation, type DefinePromptConfig, type DefineToolConfig, type DispatchOptions, type FieldRuleEntry, type FieldRulesToZodOptions, type InvokeControllerOptions, type McpAuthResolver, type McpAuthResult, type McpBridge, type McpContextExtras, type McpGuard, type McpOperation, type McpPluginOptions, type McpResourceConfig, type McpServerInstance, type McpToolLogger, type PromptDefinition, type PromptResult, type RealtimeToolCall, type RealtimeToolResponse, type ResourceToToolsConfig, type ToolAnnotations, type ToolContext, type ToolDefinition, type ToolInputSchema, createMcpServer, resolveToolCollisions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { _ as
|
|
1
|
+
/*! @classytic/arc v2.48.0 | MIT | https://classytic.com */
|
|
2
|
+
import { _ as createMcpServer, a as isZodTypeSchema, c as defaultCrudDescription, d as mcpHandlerAdapter, f as permissionDeniedResult, g as buildRequestContext, h as toCallToolSuccess, i as resourceToTools, l as resolveCrudDescription, m as toCallToolResult, n as filterResourcesForMcp, o as toolInputShape, p as toCallToolError, r as mcpPlugin, s as fieldRulesToZod, u as invokeController, v as resolveToolCollisions } from "../../mcpPlugin-DQACaqVu.mjs";
|
|
3
3
|
// src/integrations/mcp/defineTool.ts
|
|
4
4
|
/**
|
|
5
5
|
* Define a type-safe MCP tool.
|