@classytic/arc 2.46.0 → 2.47.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-BHKy4_Bi.mjs} +4 -4
- package/dist/{HookSystem-DRbPzEcP.mjs → HookSystem-CAIDVoKC.mjs} +2 -2
- package/dist/{ResourceRegistry-Douk51fa.mjs → ResourceRegistry-23Ml6FNe.mjs} +2 -2
- package/dist/{acquire-RbtvDg9s.mjs → acquire-DoFX06fm.mjs} +1 -1
- package/dist/{actionPermissions-De0AJ7hm.mjs → actionPermissions-DXrlWHHK.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-DYiubkYw.mjs} +4 -4
- package/dist/{boundedMap-2WBh3gM9.mjs → boundedMap-CtdzpJ3X.mjs} +1 -1
- package/dist/{buildHandler-DxVOOBpw.mjs → buildHandler-CARdmPNo.mjs} +4 -4
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-BYRwYrUo.mjs → caching-QRiryDLs.mjs} +2 -2
- package/dist/{claimed-DYlELdnm.mjs → claimed-BLecr1j3.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-Cx7BcnHT.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-0WyMuo0f.mjs} +3 -3
- package/dist/{createActionRouter-0qkCRzTL.mjs → createActionRouter-mLAGbpDV.mjs} +6 -6
- package/dist/{createAggregationRouter-CUf5Esd9.mjs → createAggregationRouter-BEAjn3dA.mjs} +7 -7
- package/dist/{createApp-DZIXfDKD.mjs → createApp-QDP4vYWH.mjs} +29 -29
- package/dist/{createMcpServer-DeVpqQF-.d.mts → createMcpServer-DzXHX0SO.d.mts} +1 -1
- package/dist/{defineAggregation-bmKQ4NmC.mjs → defineAggregation-CFNfvz-C.mjs} +1 -1
- package/dist/{defineResource-CGmdmGwh.mjs → defineResource-BROJmhzJ.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-DrXeEWWk.mjs} +5 -5
- package/dist/encryption/index.mjs +3 -3
- package/dist/{errorHandler-dFyGOEoB.mjs → errorHandler-BiBXtxj4.mjs} +3 -3
- package/dist/{errors-BY8vzlP4.mjs → errors-DnrUChAy.mjs} +1 -1
- package/dist/{eventPlugin-eMhAPtQA.mjs → eventPlugin-BhKLUe7H.mjs} +8 -8
- package/dist/{eventTypes-Do2KYeJx.mjs → eventTypes-CCIRGakw.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-CYdpcV73.mjs} +1 -1
- package/dist/{filter-merge-BAWi019Q.mjs → filter-merge-6kasezRH.mjs} +1 -1
- package/dist/{generate-oXoDnpJf.mjs → generate-DUkcbc4r.mjs} +2 -2
- package/dist/{headers-DBd3Qheo.mjs → headers-KxhrKevA.mjs} +2 -2
- package/dist/{health-BlJu9GXS.mjs → health-CRJg3IIq.mjs} +1 -1
- package/dist/{health-Dp-3EC9o.mjs → health-jkYNdobJ.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-CACwpktI.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 +3 -3
- 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 -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-CzDBkCme.mjs} +2 -2
- package/dist/{keys-FBz6Ull-.mjs → keys-Cbwf6r1B.mjs} +1 -1
- package/dist/{loadResources-Bx1sKPnF.mjs → loadResources-Kr6vuljv.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-b_jcqbxh.mjs → loadResourcesFromEntry-D2e0qoDR.mjs} +2 -2
- package/dist/logger/index.mjs +2 -2
- package/dist/{logger-CbFcIEBZ.mjs → logger-C110X5Yz.mjs} +1 -1
- package/dist/{mcpPlugin-yix548XX.mjs → mcpPlugin-4lIPr9OJ.mjs} +22 -22
- package/dist/{memory-Bgw5dn8N.mjs → memory-D9qkhXiB.mjs} +3 -3
- package/dist/{metrics-CZDQWVjS.mjs → metrics-B-qrrWfI.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-BD8xHgrz.mjs} +1 -1
- package/dist/{multiTenant-XCxAUlru.d.mts → multiTenant-KZj8j1uJ.d.mts} +1 -1
- package/dist/{multipartBody-B85ek8Kj.mjs → multipartBody-qU7KCn1l.mjs} +1 -1
- package/dist/{observeSend-BK-JN1jK.mjs → observeSend-BnPtTotW.mjs} +1 -1
- package/dist/{openapi-Co7hl073.mjs → openapi-DoVa5SVP.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-DyITEIop.mjs +297 -0
- package/dist/permissions/index.mjs +7 -7
- package/dist/{permissions-A1oKtpiC.mjs → permissions-BBy4bOGi.mjs} +9 -9
- package/dist/{pipe-Czpw9U2n.mjs → pipe-BOm2o4UA.mjs} +2 -2
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +2 -2
- package/dist/{plan-KVseuBCL.mjs → plan-DDIGwuxr.mjs} +1 -1
- package/dist/{plugin-DTWt_8C3.mjs → plugin-Bn4D_0XK.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-ClEjcKlG.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-DK2jh5YR.mjs} +4 -4
- package/dist/{projection-ClBqtsIw.mjs → projection-BHH-sXyS.mjs} +2 -2
- package/dist/purger.types-2wNJK_89.mjs +24 -0
- package/dist/purger.types-DvPp4-yd.d.mts +26 -0
- package/dist/{queryCachePlugin-3gJj5Rbz.mjs → queryCachePlugin-Ckqe98AM.mjs} +6 -6
- package/dist/{rateLimitKey-Kro---xl.mjs → rateLimitKey-CWAjlqcN.mjs} +1 -1
- package/dist/{realtime-Ber8uJN2.mjs → realtime-BIJi9USY.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-y9ZA-R_J.mjs} +2 -2
- package/dist/{outbox-module-mg9kDYkd.mjs → relay-BNrC1CEP.mjs} +5 -299
- package/dist/{renewingLease-CMY8YOcc.mjs → renewingLease-CS43br5E.mjs} +1 -1
- package/dist/{replyHelpers-DK9P_XSz.mjs → replyHelpers-oZDzakGb.mjs} +2 -2
- package/dist/{requestContext-GYO_0gEw.mjs → requestContext-fWb_YaV2.mjs} +1 -1
- package/dist/{requirement-DeNjZIH3.mjs → requirement--2hWyyHi.mjs} +1 -1
- package/dist/{resourceRateLimit-tHLbrtWc.mjs → resourceRateLimit-1WbcyMZY.mjs} +2 -2
- package/dist/{rolldown-runtime-Kv1fZdLg.mjs → rolldown-runtime-yH2lHMo_.mjs} +1 -1
- package/dist/{routeValidator-C_H5NanI.mjs → routeValidator-BSlRIA5c.mjs} +1 -1
- package/dist/{runtimeCapabilities-DWqbxkyw.mjs → runtimeCapabilities-CYCEtU1W.mjs} +1 -1
- package/dist/{schedules-eO_RzhCU.mjs → schedules-B5WGlYIT.mjs} +5 -5
- package/dist/{schemaConverter-DBJrPZN4.mjs → schemaConverter-DtNvts-6.mjs} +2 -2
- package/dist/{schemaIR-CEScKT2v.mjs → schemaIR-uS_RHqa3.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-BwVLSyNG.mjs} +4 -4
- package/dist/{shutdown-DzLFbe27.mjs → shutdown-BJiJN7FT.mjs} +1 -1
- package/dist/{simpleEqualityMatcher-DOJhwQ8g.mjs → simpleEqualityMatcher-DGRLq-1k.mjs} +1 -1
- package/dist/{sse-2972pVwV.mjs → sse-B_50llZu.mjs} +7 -7
- package/dist/{sseStream-AWLEeNV-.mjs → sseStream-BjSo9Ult.mjs} +2 -2
- package/dist/{store-helpers-VzjgVTkM.mjs → store-helpers-D-n5cwy5.mjs} +1 -1
- package/dist/{streaming-DvraWW6x.mjs → streaming-Dcgqa-hH.mjs} +1 -1
- package/dist/{subscriberIdentity-Bya56jsg.mjs → subscriberIdentity-C9KhIXTF.mjs} +1 -1
- package/dist/{tenancy-DSa_0hhw.mjs → tenancy-COrhjPRZ.mjs} +2 -2
- package/dist/{tenantPreparation-BrpkQre3.mjs → tenantPreparation-BElWHytd.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-CaxKbRk_.mjs} +1 -1
- package/dist/{transactionContext-DaxYUEgH.mjs → transactionContext-8qKON0Nk.mjs} +1 -1
- package/dist/{typeGuards-UKnX8wPX.mjs → typeGuards-DVjVSsXO.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-CuGjhn83.mjs → types-DZHqOuJE.mjs} +4 -4
- package/dist/{types-BYEb_dLW.d.mts → types-DeLiuaNv.d.mts} +1 -1
- package/dist/usage/index.mjs +4 -4
- package/dist/{userHelpers-oX5_mOVs.mjs → userHelpers-_eGj6kf0.mjs} +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +12 -12
- package/dist/{utils-CjjGOT4E.mjs → utils-Dd6MWpye.mjs} +5 -5
- package/dist/{validate-4RlTKOJb.mjs → validate-BaF5wd0x.mjs} +3 -3
- package/dist/{versioning-Dk2-19La.mjs → versioning-DyV7mwtK.mjs} +3 -3
- package/dist/{workScope-DoBsoVo4.mjs → workScope-CmCBUmPR.mjs} +2 -2
- package/package.json +48 -20
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as CachePurgeError } from "../../purger.types-2wNJK_89.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.47.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.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { d as createDomainError } from "../errors-DnrUChAy.mjs";
|
|
3
|
+
import { n as requireSingleHeaderValue } from "../headers-KxhrKevA.mjs";
|
|
4
|
+
import { i as requestRequiresIdempotencyKey, n as idempotencyConfigProblem, r as requestDedupedByHandler, t as declaresIdempotencyFence } from "../requirement--2hWyyHi.mjs";
|
|
5
|
+
import { n as createSafeGetOne, t as createIsDuplicateKeyError } from "../store-helpers-D-n5cwy5.mjs";
|
|
6
|
+
import { n as createIdempotencyResult, r as operationIdentity, t as resolveIdempotencyTiming } from "../timing-CaxKbRk_.mjs";
|
|
7
|
+
import { n as acquireIdempotencyKey, r as releaseIdempotencyLock } from "../acquire-DoFX06fm.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.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as acquireBySteps } from "../acquire-DoFX06fm.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.47.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-Cx7BcnHT.mjs";
|
|
3
|
+
import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-DnrUChAy.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-Bn4D_0XK.mjs";
|
|
5
|
+
import { t as defineAggregation } from "./defineAggregation-CFNfvz-C.mjs";
|
|
6
|
+
import { i as fields, n as applyFieldWritePermissions, t as applyFieldReadPermissions } from "./fields-CYdpcV73.mjs";
|
|
7
|
+
import { S as getControllerScope } from "./actionPermissions-DXrlWHHK.mjs";
|
|
8
|
+
import { a as defineResourceVariants, o as mergeResourceConfig, s as defineAction } from "./core-0WyMuo0f.mjs";
|
|
9
|
+
import { a as ResourceDefinition, t as defineResource } from "./defineResource-BROJmhzJ.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-BBy4bOGi.mjs";
|
|
11
11
|
// src/index.ts
|
|
12
|
-
const version = "2.
|
|
12
|
+
const version = "2.47.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.47.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-B_50llZu.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, f as PromptDefinition, g as ToolContext, h as ToolAnnotations, n as CallToolResult, o as CrudOperation, r as CreateMcpServerConfig, t as BetterAuthHandler, u as McpPluginOptions } from "../types-
|
|
5
|
+
import { _ as ToolDefinition, c as McpAuthResult, d as McpResourceConfig, f as PromptDefinition, g as ToolContext, h as ToolAnnotations, n as CallToolResult, o as CrudOperation, r as CreateMcpServerConfig, t as BetterAuthHandler, u as McpPluginOptions } from "../types-DeLiuaNv.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.47.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.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as evaluateAndApplyPermission } from "../../authorizationDecision-DYiubkYw.mjs";
|
|
3
|
+
import { i as runAdmittedWork, r as registerShutdownParticipant } from "../../shutdown-BJiJN7FT.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 PromptDefinition, g as ToolContext, h as ToolAnnotations, i as CrudDescriptionMeta, l as McpExecutionWiring, m as SessionEntry, n as CallToolResult, o as CrudOperation, p as PromptResult, r as CreateMcpServerConfig, s as McpAuthResolver, t as BetterAuthHandler, u as McpPluginOptions, v as ToolInputSchema } from "../../types-
|
|
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 PromptDefinition, g as ToolContext, h as ToolAnnotations, i as CrudDescriptionMeta, l as McpExecutionWiring, m as SessionEntry, n as CallToolResult, o as CrudOperation, p as PromptResult, r as CreateMcpServerConfig, s as McpAuthResolver, t as BetterAuthHandler, u as McpPluginOptions, v as ToolInputSchema } from "../../types-DeLiuaNv.mjs";
|
|
8
|
+
import { i as resolveToolCollisions, n as McpServerInstance, r as createMcpServer, t as AuthRef } from "../../createMcpServer-DzXHX0SO.mjs";
|
|
9
9
|
import { ErrorContract } from "@classytic/repo-core/errors";
|
|
10
10
|
import { FastifyPluginAsync } from "fastify";
|
|
11
11
|
import { z } from "zod";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { _ as resolveToolCollisions, a as toolInputShape, c as resolveCrudDescription, d as permissionDeniedResult, f as toCallToolError, g as createMcpServer, h as buildRequestContext, i as isZodTypeSchema, l as invokeController, m as toCallToolSuccess, n as mcpPlugin, o as fieldRulesToZod, p as toCallToolResult, r as resourceToTools, s as defaultCrudDescription, t as filterResourcesForMcp, u as mcpHandlerAdapter } from "../../mcpPlugin-
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { _ as resolveToolCollisions, a as toolInputShape, c as resolveCrudDescription, d as permissionDeniedResult, f as toCallToolError, g as createMcpServer, h as buildRequestContext, i as isZodTypeSchema, l as invokeController, m as toCallToolSuccess, n as mcpPlugin, o as fieldRulesToZod, p as toCallToolResult, r as resourceToTools, s as defaultCrudDescription, t as filterResourcesForMcp, u as mcpHandlerAdapter } from "../../mcpPlugin-4lIPr9OJ.mjs";
|
|
3
3
|
// src/integrations/mcp/defineTool.ts
|
|
4
4
|
/**
|
|
5
5
|
* Define a type-safe MCP tool.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { c as McpAuthResult, u as McpPluginOptions } from "../../types-
|
|
3
|
-
import { n as McpServerInstance } from "../../createMcpServer-
|
|
2
|
+
import { c as McpAuthResult, u as McpPluginOptions } from "../../types-DeLiuaNv.mjs";
|
|
3
|
+
import { n as McpServerInstance } from "../../createMcpServer-DzXHX0SO.mjs";
|
|
4
4
|
import { Client } from "@modelcontextprotocol/client";
|
|
5
5
|
/** An MCP client bound to a live loopback server, plus its teardown. */
|
|
6
6
|
export interface ConnectedMcpTestClient {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { g as createMcpServer, r as resourceToTools, t as filterResourcesForMcp } from "../../mcpPlugin-
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { g as createMcpServer, r as resourceToTools, t as filterResourcesForMcp } from "../../mcpPlugin-4lIPr9OJ.mjs";
|
|
3
3
|
// src/integrations/mcp/testing.ts
|
|
4
4
|
/**
|
|
5
5
|
* Serve an already-built `McpServer` on an ephemeral loopback port and connect
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { f as createError, i as NotFoundError, r as ForbiddenError } from "../errors-
|
|
3
|
-
import { a as promoteStreamTokenToHeader, n as forwardedStreamHeaders } from "../streaming-
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { f as createError, i as NotFoundError, r as ForbiddenError } from "../errors-DnrUChAy.mjs";
|
|
3
|
+
import { a as promoteStreamTokenToHeader, n as forwardedStreamHeaders } from "../streaming-Dcgqa-hH.mjs";
|
|
4
4
|
import { ARC_ERROR_CODES } from "@classytic/repo-core/errors";
|
|
5
5
|
import fp from "fastify-plugin";
|
|
6
6
|
// src/integrations/streamline.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { a as EventTransport, n as DomainEvent } from "../EventTransport-CYEoCJGe.mjs";
|
|
3
|
-
import { i as createOutboxModule, r as OutboxModuleOptions } from "../outbox-module-
|
|
3
|
+
import { i as createOutboxModule, r as OutboxModuleOptions } from "../outbox-module-5Mnwcycy.mjs";
|
|
4
4
|
import { FastifyPluginAsync } from "fastify";
|
|
5
5
|
import { OutboxFailurePolicy, OutboxStore } from "@classytic/primitives/outbox";
|
|
6
6
|
export interface WebhookSubscription {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as declareRuntimeCapability } from "../runtimeCapabilities-
|
|
3
|
-
import {
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as declareRuntimeCapability } from "../runtimeCapabilities-CYCEtU1W.mjs";
|
|
3
|
+
import { r as exponentialBackoff } from "../relay-BNrC1CEP.mjs";
|
|
4
|
+
import { t as createOutboxModule } from "../outbox-module-DyITEIop.mjs";
|
|
4
5
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
5
6
|
import fp from "fastify-plugin";
|
|
6
7
|
import { createChildEvent, matchEventPattern } from "@classytic/primitives/events";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as declareRuntimeCapability } from "../runtimeCapabilities-
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as declareRuntimeCapability } from "../runtimeCapabilities-CYCEtU1W.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import sjson from "secure-json-parse";
|
|
5
5
|
import fp from "fastify-plugin";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as ArcError } from "./errors-
|
|
1
|
+
/*! @classytic/arc v2.47.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as ArcError } from "./errors-DnrUChAy.mjs";
|
|
3
3
|
import sjson from "secure-json-parse";
|
|
4
4
|
// src/utils/jsonBody.ts
|
|
5
5
|
/**
|