@classytic/arc 2.51.0 → 2.53.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/README.md +2 -1
- package/dist/{EventTransport-K7Q9WPjm.mjs → EventTransport-B3jTKMQH.mjs} +2 -2
- package/dist/{HookSystem-DBAu9uNT.mjs → HookSystem-DNwxV463.mjs} +2 -2
- package/dist/{ResourceRegistry-BelzCRMy.mjs → ResourceRegistry-Ck7RFodL.mjs} +2 -2
- package/dist/{acquire-B0zhfGSm.mjs → acquire-DkLruwhL.mjs} +1 -1
- package/dist/audit/index.d.mts +1 -1
- package/dist/audit/index.mjs +4 -4
- package/dist/auth/audit.mjs +1 -1
- package/dist/auth/index.d.mts +1 -1
- package/dist/auth/index.mjs +7 -7
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/auth/social/index.mjs +1 -1
- package/dist/{authorizationDecision-Dxj_cy6N.mjs → authorizationDecision-gB5-bHDp.mjs} +9 -7
- package/dist/bootError-BT3z3cvX.mjs +38 -0
- package/dist/{boundedMap-DOBai-H3.mjs → boundedMap-Ddw2yGb2.mjs} +1 -1
- package/dist/{buildHandler-Dyl8P9j0.mjs → buildHandler-B8IDGmhD.mjs} +5 -5
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-CUmaNL8Y.mjs → caching-BitJDAY0.mjs} +2 -2
- package/dist/{claimed-DJPk4VZr.mjs → claimed-CM_-lFHX.mjs} +1 -1
- package/dist/cleanup/index.d.mts +2 -2
- package/dist/cleanup/index.mjs +4 -4
- package/dist/cli/commands/describe.d.mts +18 -1
- package/dist/cli/commands/describe.mjs +39 -7
- package/dist/cli/commands/docs.mjs +3 -3
- package/dist/cli/commands/doctor.d.mts +3 -1
- package/dist/cli/commands/doctor.mjs +135 -22
- 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-DH41jnNT.mjs → constants-D9EiaO5s.mjs} +1 -1
- package/dist/context/index.d.mts +5 -2
- 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-DPmRWlpx.mjs → core-B_06Fcn0.mjs} +3 -3
- package/dist/{createActionRouter-B1xhER6i.mjs → createActionRouter-DtxUXOCI.mjs} +5 -5
- package/dist/{createAggregationRouter-CNntJL-z.mjs → createAggregationRouter-BMiKyDoW.mjs} +7 -7
- package/dist/{createApp-DpG26bCu.mjs → createApp-CEdGZtkP.mjs} +207 -44
- package/dist/{createMcpServer-CS2KOVP6.d.mts → createMcpServer-Bk3ls5jS.d.mts} +1 -1
- package/dist/{defineAggregation-rI3EbZUg.mjs → defineAggregation-DUsrGcsm.mjs} +1 -1
- package/dist/{defineResource-5DcG_wlI.mjs → defineResource-q8TsJpOm.mjs} +92 -36
- package/dist/deprecation-DX625dth.mjs +27 -0
- 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-XFu7J3aj.mjs → elevation-NJ3908pJ.mjs} +5 -5
- package/dist/encryption/index.d.mts +26 -1
- package/dist/encryption/index.mjs +56 -6
- package/dist/{errorHandler-xDVUWOMu.mjs → errorHandler-Ke6PGvF7.mjs} +7 -4
- package/dist/{errors-KBZ3tQk5.mjs → errors-Ukhmfmmx.mjs} +1 -1
- package/dist/{eventPlugin-BY38F6yK.d.mts → eventPlugin-BeJasppx.d.mts} +7 -18
- package/dist/{eventPlugin-C4lNj2Dw.mjs → eventPlugin-DTKAgSvb.mjs} +10 -8
- package/dist/{eventTypes-DZRoUAdk.mjs → eventTypes-DpDQtyR6.mjs} +2 -2
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +8 -8
- package/dist/events/transports/redis-stream-entry.mjs +4 -4
- package/dist/events/transports/redis.mjs +2 -2
- package/dist/factory/index.d.mts +28 -5
- package/dist/factory/index.mjs +12 -7
- package/dist/{fastify-augmentation-baQc3MaO.d.mts → fastify-augmentation-DjxuSRG4.d.mts} +4 -3
- package/dist/{fieldTypes-DrXUW1jc.mjs → fieldTypes-BtFpQO6I.mjs} +2 -2
- package/dist/{fields-C5J8WTd2.mjs → fields-B7fuROWK.mjs} +1 -1
- package/dist/{filter-merge-DTjYoDrj.mjs → filter-merge-BuzZ-r9z.mjs} +1 -1
- package/dist/{generate-SA8oMlLB.mjs → generate-c4F39pk1.mjs} +4 -4
- package/dist/{headers-D5wrBLOk.mjs → headers-Ib7BDgRI.mjs} +2 -2
- package/dist/{health-BLal039H.mjs → health-22T82HAa.mjs} +1 -1
- package/dist/health-skjSwNaC.d.mts +36 -0
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/http-cache/index.mjs +4 -4
- package/dist/http-cache/purgers/cloudflare.mjs +2 -2
- package/dist/http-cache/purgers/fastly.mjs +2 -2
- package/dist/http-cache/testing/index.mjs +1 -1
- package/dist/idempotency/index.d.mts +7 -1
- package/dist/idempotency/index.mjs +9 -7
- package/dist/idempotency/redis.mjs +2 -2
- package/dist/{index-CMNpMBtW.d.mts → index-BzUyno-u.d.mts} +14 -5
- package/dist/{index-Dhrks-hM.d.mts → index-CXqYFGoH.d.mts} +13 -4
- package/dist/{index-DexdFs1a.d.mts → index-CaBFPmnu.d.mts} +29 -7
- package/dist/{index-DKM2p5w5.d.mts → index-DWn0o4U7.d.mts} +2 -2
- package/dist/{index-DLCcLUQT.d.mts → index-DtHACefu.d.mts} +109 -116
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +12 -12
- package/dist/{init-DeKHaNZn.mjs → init-XY5slyuS.mjs} +3 -3
- 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 +9 -4
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +2 -2
- package/dist/integrations/mcp/testing.mjs +2 -2
- package/dist/integrations/streamline.mjs +3 -3
- package/dist/integrations/webhooks.d.mts +1 -1
- package/dist/integrations/webhooks.mjs +4 -4
- package/dist/integrations/websocket-pushref-redis.mjs +1 -1
- package/dist/integrations/websocket-redis.mjs +1 -1
- package/dist/integrations/websocket.mjs +2 -2
- package/dist/invariants-COekUeoh.mjs +120 -0
- package/dist/{jsonBody-rDPGT5A9.mjs → jsonBody-BNlcGUnb.mjs} +2 -2
- package/dist/{keys-t7i-lJ2r.mjs → keys-DwvXJwUX.mjs} +1 -1
- package/dist/{loadResources-CcupAVJH.mjs → loadResources-izEeQLO_.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-BpjYlaoj.mjs → loadResourcesFromEntry-CijqjbHE.mjs} +2 -2
- package/dist/logger/index.mjs +2 -2
- package/dist/{logger-IL7Btm-N.mjs → logger-DdMS0XC_.mjs} +1 -1
- package/dist/{mcpPlugin-BsdH7Vot.mjs → mcpPlugin-D0tSZqKk.mjs} +24 -22
- package/dist/{memory-Dkp6ZD3F.mjs → memory-Ay0haw9n.mjs} +3 -3
- package/dist/{metrics-CDPqgdKr.mjs → metrics-Bpgf4UL6.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-KFxT1Iuk.mjs → module-BLrTmMyk.mjs} +17 -2
- package/dist/{multiTenant-QtDzxx_K.d.mts → multiTenant-Cf0Ye-Wu.d.mts} +1 -1
- package/dist/{multipartBody-BHktuarE.mjs → multipartBody-L2gr96df.mjs} +1 -1
- package/dist/{observeSend-CY-sLanc.mjs → observeSend-B7FEdk_g.mjs} +1 -1
- package/dist/{openapi-DbeXiy2v.mjs → openapi-COrL_33P.mjs} +6 -6
- package/dist/outbox-admin/index.d.mts +1 -1
- package/dist/outbox-admin/index.mjs +6 -6
- package/dist/{outbox-module-BWqkTE8-.mjs → outbox-module-BY2HtnjU.mjs} +7 -7
- package/dist/{outbox-module-DzW6zwWJ.d.mts → outbox-module-C1QWMloZ.d.mts} +5 -8
- package/dist/permissions/index.d.mts +2 -2
- package/dist/permissions/index.mjs +8 -8
- package/dist/{permissions-e5YMrFbm.mjs → permissions-CEyeDHtT.mjs} +36 -17
- package/dist/{pipe-CMnKfdF4.mjs → pipe-DIAr91at.mjs} +2 -2
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +2 -2
- package/dist/{plan-BvLJGm3U.mjs → plan-BhKHIkFl.mjs} +75 -20
- package/dist/{plugin-DYmu8uT4.mjs → plugin-D6hrdx-j.mjs} +72 -38
- package/dist/plugins/index.d.mts +4 -3
- package/dist/plugins/index.mjs +18 -18
- package/dist/plugins/response-cache.mjs +4 -4
- package/dist/plugins/tracing-entry.mjs +177 -85
- package/dist/{pluralize-ClwfBdIx.mjs → pluralize-CJKgYkVc.mjs} +1 -1
- package/dist/presetPermission-2pcRVYRG.mjs +23 -0
- package/dist/presets/filesUpload.d.mts +4 -2
- package/dist/presets/filesUpload.mjs +11 -6
- package/dist/presets/index.d.mts +6 -4
- 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 +2 -2
- package/dist/presets/search.mjs +54 -38
- package/dist/{presets-DX_lPabi.mjs → presets-st11ePNn.mjs} +150 -41
- package/dist/{projection-DnZiFPPE.mjs → projection-B4rqiJTi.mjs} +2 -2
- package/dist/{purger.types-BEzTVDOU.mjs → purger.types-BcHeAhY_.mjs} +1 -1
- package/dist/{queryCachePlugin-C57-Nj-g.mjs → queryCachePlugin-BgSc2bga.mjs} +6 -6
- package/dist/rateLimitKey-DLGdeFd2.mjs +138 -0
- package/dist/{realtime-C-VIoXMg.mjs → realtime-CpYpIFsm.mjs} +11 -11
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +3 -3
- package/dist/{registry-DbQvODPH.mjs → registry-BQsdAlZ_.mjs} +2 -2
- package/dist/{relay-B61seKq1.mjs → relay-CmT3gtkP.mjs} +11 -12
- package/dist/{renewingLease-Dp7wmzNN.mjs → renewingLease-DaoP0K-e.mjs} +1 -1
- package/dist/{replyHelpers-CHii_jIO.mjs → replyHelpers-SiLr1wK4.mjs} +2 -2
- package/dist/{requestContext-C_mbAm8o.mjs → requestContext-B-TjFpWt.mjs} +8 -3
- package/dist/{health-vEo3fni4.mjs → requestId-ClcKoWLq.mjs} +154 -116
- package/dist/{requirement-C8OsWLYp.mjs → requirement-BygDzjDS.mjs} +1 -1
- package/dist/{resourceRateLimit-DhbQZjE2.mjs → resourceRateLimit-DdIYis3m.mjs} +2 -2
- package/dist/{rolldown-runtime-HTi8KV7V.mjs → rolldown-runtime-Cy6j0m8_.mjs} +1 -1
- package/dist/{routeValidator-DnQ2BGnH.mjs → routeValidator-Bn-x2gaJ.mjs} +1 -1
- package/dist/{runtimeCapabilities-G9QXHov1.mjs → runtimeCapabilities-DY20Pibh.mjs} +7 -2
- package/dist/{schedules-DAthT5O3.mjs → schedules-CwqC0Mp0.mjs} +5 -5
- package/dist/{schemaConverter-BOt_ed78.mjs → schemaConverter-XoLKVpzG.mjs} +2 -2
- package/dist/{schemaIR-MZVVj6Cw.mjs → schemaIR-DP7mMj7c.mjs} +16 -16
- package/dist/schemas/index.mjs +1 -1
- package/dist/scim/index.mjs +2 -2
- package/dist/scope/index.d.mts +6 -2
- package/dist/scope/index.mjs +5 -5
- package/dist/{scope-btg-225w.mjs → scope-B0vgM2Zw.mjs} +4 -4
- package/dist/{shutdown-Dfy8La90.mjs → shutdown-C76Hn-Th.mjs} +1 -1
- package/dist/{simpleEqualityMatcher-D5dOqbbj.mjs → simpleEqualityMatcher-Qbl-11cE.mjs} +1 -1
- package/dist/{sse-DivxX1m6.mjs → sse-eyb8lNuI.mjs} +7 -7
- package/dist/{sseStream-hQxQjvre.mjs → sseStream-BsBesrfw.mjs} +2 -2
- package/dist/{store-helpers-DfqfssAw.mjs → store-helpers-D1yIVa91.mjs} +1 -1
- package/dist/{streaming-CQiOktsh.mjs → streaming-DKziqs1Z.mjs} +1 -1
- package/dist/{subscriberIdentity-Bf8VLqA7.mjs → subscriberIdentity-DpdSQMQq.mjs} +1 -1
- package/dist/{tenancy-Btmaf1MB.mjs → tenancy-YuRYsOPr.mjs} +2 -2
- package/dist/{tenantPreparation-4e3qyb6q.mjs → tenantPreparation-Bk8ouRB3.mjs} +17 -5
- package/dist/testing/cleanupStoreContract.mjs +1 -1
- package/dist/testing/index.d.mts +4 -4
- package/dist/testing/index.mjs +11 -11
- package/dist/testing/outboxStoreContract.mjs +2 -2
- package/dist/testing/requiredPorts.d.mts +1 -1
- package/dist/testing/requiredPorts.mjs +2 -2
- package/dist/testing/storageContract.mjs +1 -1
- package/dist/{timing-DXx0IWyi.mjs → timing-BtIDIdQz.mjs} +1 -1
- package/dist/{transactionContext-DperjON1.mjs → transactionContext-BsQ5ortM.mjs} +1 -1
- package/dist/{typeGuards-eoQLIOh6.mjs → typeGuards-Cr2_zEW0.mjs} +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +1 -1
- package/dist/types/storage.mjs +1 -1
- package/dist/{types-BeEJm-DV.d.mts → types-CQhHTZXs.d.mts} +48 -35
- package/dist/{types-B4E0sc6D.d.mts → types-DWFgq8EP.d.mts} +1 -1
- package/dist/{types-CcpISJe8.mjs → types-ZvdR7MVa.mjs} +4 -4
- package/dist/usage/index.mjs +4 -4
- package/dist/{userHelpers-Cp5zqlEN.mjs → userHelpers-CwpEK36a.mjs} +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +12 -12
- package/dist/{utils-dKN-_315.mjs → utils-CnrfcYMq.mjs} +6 -6
- package/dist/{validate-BZHaAdgy.mjs → validate-BTQBh-Dr.mjs} +3 -3
- package/dist/{versioning-CPLP0VbB.mjs → versioning-DiLykI6U.mjs} +3 -3
- package/dist/{workScope-BI72KXsI.mjs → workScope-C3tPz_Gt.mjs} +2 -2
- package/package.json +34 -9
- package/skills/arc/SKILL.md +5 -5
- package/skills/arc/references/api-reference.md +1 -1
- package/skills/arc/references/boot.md +17 -2
- package/skills/arc/references/events.md +0 -1
- package/skills/arc/references/mcp-setup.md +3 -2
- package/skills/arc/references/multi-tenancy.md +1 -1
- package/skills/arc/references/production-api.md +19 -12
- package/skills/arc/references/production-audit.md +1 -1
- package/skills/arc/references/production-boot.md +3 -3
- package/skills/arc/references/production-idempotency.md +2 -2
- package/skills/arc/references/production-observability.md +14 -2
- package/skills/arc/references/production-reliability.md +1 -1
- package/skills/arc/references/querying.md +1 -2
- package/skills/arc/references/resources.md +8 -6
- package/skills/arc/references/testing.md +1 -1
- package/skills/arc-code-review/references/arc-cheatsheet.md +1 -1
- package/skills/arc-code-review/references/recipe-scope-permissions.md +1 -1
- package/skills/arc-module-publishing/references/resource-assembly.md +2 -2
- package/dist/rateLimitKey-B1RxyGt3.mjs +0 -40
|
@@ -1,115 +1,7 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as bootError } from "./bootError-BT3z3cvX.mjs";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
4
|
import fp from "fastify-plugin";
|
|
4
|
-
// src/plugins/requestId.ts
|
|
5
|
-
/**
|
|
6
|
-
* Request ID Plugin
|
|
7
|
-
*
|
|
8
|
-
* Propagates request IDs for distributed tracing.
|
|
9
|
-
* - Accepts incoming x-request-id header (sanitized)
|
|
10
|
-
* - Generates UUID if not provided
|
|
11
|
-
* - Echoes the id on the response header + W3C trace-context propagation
|
|
12
|
-
*
|
|
13
|
-
* ID RESOLUTION LIVES AT THE SERVER LEVEL, NOT HERE. Fastify binds
|
|
14
|
-
* `request.log = logger.child({ reqId: request.id })` at request
|
|
15
|
-
* construction — before any hook runs — so an id assigned inside a hook
|
|
16
|
-
* never reaches the logs. `createApp` therefore wires
|
|
17
|
-
* {@link createRequestIdGenerator} into Fastify's `genReqId` option, and
|
|
18
|
-
* this plugin simply adopts `request.id`. Standalone registration on a
|
|
19
|
-
* bare Fastify instance falls back to the legacy in-hook resolution
|
|
20
|
-
* (header echo / UUID), with the documented limitation that
|
|
21
|
-
* `request.log`'s `reqId` binding predates the overwrite — pass
|
|
22
|
-
* `genReqId: createRequestIdGenerator()` to `Fastify()` to fix that.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* import { requestIdPlugin, createRequestIdGenerator } from '@classytic/arc';
|
|
26
|
-
*
|
|
27
|
-
* const fastify = Fastify({ genReqId: createRequestIdGenerator() });
|
|
28
|
-
* await fastify.register(requestIdPlugin);
|
|
29
|
-
*
|
|
30
|
-
* fastify.get('/', async (request) => {
|
|
31
|
-
* request.log.info('traced'); // carries the same reqId as the header
|
|
32
|
-
* return { id: request.id };
|
|
33
|
-
* });
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* Sanitize an incoming request-id header value: max 128 chars, alphanumeric
|
|
37
|
-
* plus dashes/underscores/dots/colons only. Returns `undefined` for anything
|
|
38
|
-
* else (crafted values could pollute logs or response headers). Array values
|
|
39
|
-
* (repeated headers) are rejected outright — a client sending multiple
|
|
40
|
-
* request-id headers is not tracing in good faith.
|
|
41
|
-
*/
|
|
42
|
-
function sanitizeRequestId(value) {
|
|
43
|
-
if (typeof value !== "string") return void 0;
|
|
44
|
-
const trimmed = value.trim();
|
|
45
|
-
return trimmed.length > 0 && trimmed.length <= 128 && /^[\w.:-]+$/.test(trimmed) ? trimmed : void 0;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Build a Fastify `genReqId` function: adopt a sanitized incoming request-id
|
|
49
|
-
* header, or generate one. Wire this into the `Fastify()` constructor so
|
|
50
|
-
* `request.id`, `request.log`'s `reqId` binding, and the echoed response
|
|
51
|
-
* header all agree — `createApp` does this automatically.
|
|
52
|
-
*/
|
|
53
|
-
function createRequestIdGenerator(opts = {}) {
|
|
54
|
-
const { header = "x-request-id", generator = randomUUID } = opts;
|
|
55
|
-
const headerName = header.toLowerCase();
|
|
56
|
-
return (req) => sanitizeRequestId(req.headers[headerName]) ?? generator();
|
|
57
|
-
}
|
|
58
|
-
/** Fastify's default request ids are `req-<base36 counter>`. */
|
|
59
|
-
const FASTIFY_DEFAULT_ID = /^req-[0-9a-z]+$/;
|
|
60
|
-
/** W3C traceparent format: `version-traceid-parentid-flags` */
|
|
61
|
-
const TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;
|
|
62
|
-
/** W3C spec: version ff is reserved and invalid; trace/parent IDs must not be all zeros */
|
|
63
|
-
const TRACEID_ZEROS = "0".repeat(32);
|
|
64
|
-
const PARENTID_ZEROS = "0".repeat(16);
|
|
65
|
-
/** tracestate: printable ASCII, <= 512 bytes */
|
|
66
|
-
const TRACESTATE_MAX = 512;
|
|
67
|
-
function isValidTraceparent(tp) {
|
|
68
|
-
const m = TRACEPARENT_RE.exec(tp);
|
|
69
|
-
if (!m) return false;
|
|
70
|
-
const version = m[1] ?? "";
|
|
71
|
-
const traceId = m[2] ?? "";
|
|
72
|
-
const parentId = m[3] ?? "";
|
|
73
|
-
if (version.toLowerCase() === "ff") return false;
|
|
74
|
-
if (traceId.toLowerCase() === TRACEID_ZEROS) return false;
|
|
75
|
-
if (parentId.toLowerCase() === PARENTID_ZEROS) return false;
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
const requestIdPlugin = async (fastify, opts = {}) => {
|
|
79
|
-
const { header = "x-request-id", generator = randomUUID, setResponseHeader = true, propagateTraceContext = true } = opts;
|
|
80
|
-
if (!fastify.hasRequestDecorator("requestId")) fastify.decorateRequest("requestId", "");
|
|
81
|
-
if (!fastify.hasRequestDecorator("traceContext")) fastify.decorateRequest("traceContext", void 0);
|
|
82
|
-
fastify.addHook("onRequest", async (request, reply) => {
|
|
83
|
-
const incoming = sanitizeRequestId(request.headers[header]);
|
|
84
|
-
let requestId = String(request.id);
|
|
85
|
-
if (incoming && incoming !== requestId) requestId = incoming;
|
|
86
|
-
else if (!incoming && FASTIFY_DEFAULT_ID.test(requestId)) requestId = generator();
|
|
87
|
-
if (requestId !== request.id) request.id = requestId;
|
|
88
|
-
request.requestId = requestId;
|
|
89
|
-
if (setResponseHeader) reply.header(header, requestId);
|
|
90
|
-
if (propagateTraceContext) {
|
|
91
|
-
const rawTraceparent = request.headers.traceparent;
|
|
92
|
-
const rawTracestate = request.headers.tracestate;
|
|
93
|
-
if (typeof rawTraceparent === "string") {
|
|
94
|
-
const tp = rawTraceparent.trim();
|
|
95
|
-
if (isValidTraceparent(tp)) {
|
|
96
|
-
const ts = typeof rawTracestate === "string" && rawTracestate.length > 0 && rawTracestate.length <= TRACESTATE_MAX ? rawTracestate : void 0;
|
|
97
|
-
request.traceContext = {
|
|
98
|
-
traceparent: tp,
|
|
99
|
-
...ts ? { tracestate: ts } : {}
|
|
100
|
-
};
|
|
101
|
-
reply.header("traceparent", tp);
|
|
102
|
-
if (ts) reply.header("tracestate", ts);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
fastify.log?.debug?.("Request ID plugin registered");
|
|
108
|
-
};
|
|
109
|
-
var requestId_default = fp(requestIdPlugin, {
|
|
110
|
-
name: "arc-request-id",
|
|
111
|
-
fastify: "5.x"
|
|
112
|
-
});
|
|
113
5
|
// src/utils/metricSeries.ts
|
|
114
6
|
/** Retains a fixed number of label sets; excess observations share one overflow series. */
|
|
115
7
|
var MetricSeries = class {
|
|
@@ -231,7 +123,11 @@ function mergeHealthChecks(groups) {
|
|
|
231
123
|
const merged = [];
|
|
232
124
|
for (const group of groups) for (const check of group.checks ?? []) {
|
|
233
125
|
const prior = owners.get(check.name);
|
|
234
|
-
if (prior !== void 0) throw
|
|
126
|
+
if (prior !== void 0) throw bootError({
|
|
127
|
+
code: "duplicate-health-check",
|
|
128
|
+
message: `[arc] duplicate health-check name "${check.name}" — declared by ${prior} and ${group.owner}. Health-check names must be unique.`,
|
|
129
|
+
fix: `rename one of the "${check.name}" health checks`
|
|
130
|
+
});
|
|
235
131
|
owners.set(check.name, group.owner);
|
|
236
132
|
merged.push(check);
|
|
237
133
|
}
|
|
@@ -312,8 +208,7 @@ const healthPlugin = async (fastify, opts = {}) => {
|
|
|
312
208
|
properties: {
|
|
313
209
|
name: { type: "string" },
|
|
314
210
|
healthy: { type: "boolean" },
|
|
315
|
-
duration: { type: "number" }
|
|
316
|
-
error: { type: "string" }
|
|
211
|
+
duration: { type: "number" }
|
|
317
212
|
}
|
|
318
213
|
}
|
|
319
214
|
}
|
|
@@ -331,7 +226,7 @@ const healthPlugin = async (fastify, opts = {}) => {
|
|
|
331
226
|
}
|
|
332
227
|
}
|
|
333
228
|
}
|
|
334
|
-
} }, async (
|
|
229
|
+
} }, async (request, reply) => {
|
|
335
230
|
if (fastify.hasDecorator("shutdownState") && fastify.shutdownState.draining) {
|
|
336
231
|
reply.code(503);
|
|
337
232
|
return {
|
|
@@ -342,10 +237,19 @@ const healthPlugin = async (fastify, opts = {}) => {
|
|
|
342
237
|
}
|
|
343
238
|
const results = await runChecks(readinessChecks);
|
|
344
239
|
const criticalFailed = results.some((result, index) => !result.healthy && (readinessChecks[index]?.critical ?? true));
|
|
240
|
+
const failed = results.filter((r) => r.error !== void 0);
|
|
241
|
+
if (failed.length > 0) request.log.warn({ checks: failed.map(({ name, error }) => ({
|
|
242
|
+
name,
|
|
243
|
+
error
|
|
244
|
+
})) }, "[arc] readiness check failed");
|
|
345
245
|
const response = {
|
|
346
246
|
status: criticalFailed ? "not_ready" : "ready",
|
|
347
247
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
348
|
-
checks: results
|
|
248
|
+
checks: results.map(({ name, healthy, duration }) => ({
|
|
249
|
+
name,
|
|
250
|
+
healthy,
|
|
251
|
+
duration
|
|
252
|
+
}))
|
|
349
253
|
};
|
|
350
254
|
if (criticalFailed) reply.code(503);
|
|
351
255
|
return response;
|
|
@@ -436,8 +340,142 @@ async function runChecks(checks) {
|
|
|
436
340
|
}
|
|
437
341
|
}));
|
|
438
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Run every readiness check once and log ONE line: names, pass/fail, duration. Never throws
|
|
345
|
+
* and never fails boot — a dependency that is down at boot is the readiness probe's business.
|
|
346
|
+
* `production` adds a note when no check is critical (readiness can then never go not-ready).
|
|
347
|
+
*/
|
|
348
|
+
async function logBootHealthSummary(log, checks, options = {}) {
|
|
349
|
+
const critical = checks.filter((c) => c.critical ?? true).length;
|
|
350
|
+
const noCritical = options.production === true && critical === 0;
|
|
351
|
+
if (checks.length === 0 && !noCritical) return;
|
|
352
|
+
try {
|
|
353
|
+
const start = Date.now();
|
|
354
|
+
const results = await runChecks(checks);
|
|
355
|
+
const failed = results.filter((r) => !r.healthy);
|
|
356
|
+
const summary = results.map((r) => `${r.name} ${r.healthy ? "ok" : "FAILED"} (${r.duration}ms)`).join(", ");
|
|
357
|
+
const note = noCritical ? " — no critical readiness check is registered, so /ready can never report not_ready" : "";
|
|
358
|
+
const line = `[arc] boot health: ${results.length - failed.length}/${results.length} passing${summary ? ` — ${summary}` : ""}${note}`;
|
|
359
|
+
const fields = {
|
|
360
|
+
durationMs: Date.now() - start,
|
|
361
|
+
criticalChecks: critical,
|
|
362
|
+
checks: results
|
|
363
|
+
};
|
|
364
|
+
if (failed.length > 0) log.warn(fields, line);
|
|
365
|
+
else log.info(fields, line);
|
|
366
|
+
} catch {}
|
|
367
|
+
}
|
|
439
368
|
var health_default = fp(healthPlugin, {
|
|
440
369
|
name: "arc-health",
|
|
441
370
|
fastify: "5.x"
|
|
442
371
|
});
|
|
443
|
-
|
|
372
|
+
// src/plugins/requestId.ts
|
|
373
|
+
/**
|
|
374
|
+
* Request ID Plugin
|
|
375
|
+
*
|
|
376
|
+
* Propagates request IDs for distributed tracing.
|
|
377
|
+
* - Accepts incoming x-request-id header (sanitized)
|
|
378
|
+
* - Generates UUID if not provided
|
|
379
|
+
* - Echoes the id on the response header + W3C trace-context propagation
|
|
380
|
+
*
|
|
381
|
+
* ID RESOLUTION LIVES AT THE SERVER LEVEL, NOT HERE. Fastify binds
|
|
382
|
+
* `request.log = logger.child({ reqId: request.id })` at request
|
|
383
|
+
* construction — before any hook runs — so an id assigned inside a hook
|
|
384
|
+
* never reaches the logs. `createApp` therefore wires
|
|
385
|
+
* {@link createRequestIdGenerator} into Fastify's `genReqId` option, and
|
|
386
|
+
* this plugin simply adopts `request.id`. Standalone registration on a
|
|
387
|
+
* bare Fastify instance falls back to the legacy in-hook resolution
|
|
388
|
+
* (header echo / UUID), with the documented limitation that
|
|
389
|
+
* `request.log`'s `reqId` binding predates the overwrite — pass
|
|
390
|
+
* `genReqId: createRequestIdGenerator()` to `Fastify()` to fix that.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* import { requestIdPlugin, createRequestIdGenerator } from '@classytic/arc';
|
|
394
|
+
*
|
|
395
|
+
* const fastify = Fastify({ genReqId: createRequestIdGenerator() });
|
|
396
|
+
* await fastify.register(requestIdPlugin);
|
|
397
|
+
*
|
|
398
|
+
* fastify.get('/', async (request) => {
|
|
399
|
+
* request.log.info('traced'); // carries the same reqId as the header
|
|
400
|
+
* return { id: request.id };
|
|
401
|
+
* });
|
|
402
|
+
*/
|
|
403
|
+
/**
|
|
404
|
+
* Sanitize an incoming request-id header value: max 128 chars, alphanumeric
|
|
405
|
+
* plus dashes/underscores/dots/colons only. Returns `undefined` for anything
|
|
406
|
+
* else (crafted values could pollute logs or response headers). Array values
|
|
407
|
+
* (repeated headers) are rejected outright — a client sending multiple
|
|
408
|
+
* request-id headers is not tracing in good faith.
|
|
409
|
+
*/
|
|
410
|
+
function sanitizeRequestId(value) {
|
|
411
|
+
if (typeof value !== "string") return void 0;
|
|
412
|
+
const trimmed = value.trim();
|
|
413
|
+
return trimmed.length > 0 && trimmed.length <= 128 && /^[\w.:-]+$/.test(trimmed) ? trimmed : void 0;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Build a Fastify `genReqId` function: adopt a sanitized incoming request-id
|
|
417
|
+
* header, or generate one. Wire this into the `Fastify()` constructor so
|
|
418
|
+
* `request.id`, `request.log`'s `reqId` binding, and the echoed response
|
|
419
|
+
* header all agree — `createApp` does this automatically.
|
|
420
|
+
*/
|
|
421
|
+
function createRequestIdGenerator(opts = {}) {
|
|
422
|
+
const { header = "x-request-id", generator = randomUUID } = opts;
|
|
423
|
+
const headerName = header.toLowerCase();
|
|
424
|
+
return (req) => sanitizeRequestId(req.headers[headerName]) ?? generator();
|
|
425
|
+
}
|
|
426
|
+
/** Fastify's default request ids are `req-<base36 counter>`. */
|
|
427
|
+
const FASTIFY_DEFAULT_ID = /^req-[0-9a-z]+$/;
|
|
428
|
+
/** W3C traceparent format: `version-traceid-parentid-flags` */
|
|
429
|
+
const TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;
|
|
430
|
+
/** W3C spec: version ff is reserved and invalid; trace/parent IDs must not be all zeros */
|
|
431
|
+
const TRACEID_ZEROS = "0".repeat(32);
|
|
432
|
+
const PARENTID_ZEROS = "0".repeat(16);
|
|
433
|
+
/** tracestate: printable ASCII, <= 512 bytes */
|
|
434
|
+
const TRACESTATE_MAX = 512;
|
|
435
|
+
function isValidTraceparent(tp) {
|
|
436
|
+
const m = TRACEPARENT_RE.exec(tp);
|
|
437
|
+
if (!m) return false;
|
|
438
|
+
const version = m[1] ?? "";
|
|
439
|
+
const traceId = m[2] ?? "";
|
|
440
|
+
const parentId = m[3] ?? "";
|
|
441
|
+
if (version.toLowerCase() === "ff") return false;
|
|
442
|
+
if (traceId.toLowerCase() === TRACEID_ZEROS) return false;
|
|
443
|
+
if (parentId.toLowerCase() === PARENTID_ZEROS) return false;
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
const requestIdPlugin = async (fastify, opts = {}) => {
|
|
447
|
+
const { header = "x-request-id", generator = randomUUID, setResponseHeader = true, propagateTraceContext = true } = opts;
|
|
448
|
+
if (!fastify.hasRequestDecorator("requestId")) fastify.decorateRequest("requestId", "");
|
|
449
|
+
if (!fastify.hasRequestDecorator("traceContext")) fastify.decorateRequest("traceContext", void 0);
|
|
450
|
+
fastify.addHook("onRequest", async (request, reply) => {
|
|
451
|
+
const incoming = sanitizeRequestId(request.headers[header]);
|
|
452
|
+
let requestId = String(request.id);
|
|
453
|
+
if (incoming && incoming !== requestId) requestId = incoming;
|
|
454
|
+
else if (!incoming && FASTIFY_DEFAULT_ID.test(requestId)) requestId = generator();
|
|
455
|
+
if (requestId !== request.id) request.id = requestId;
|
|
456
|
+
request.requestId = requestId;
|
|
457
|
+
if (setResponseHeader) reply.header(header, requestId);
|
|
458
|
+
if (propagateTraceContext) {
|
|
459
|
+
const rawTraceparent = request.headers.traceparent;
|
|
460
|
+
const rawTracestate = request.headers.tracestate;
|
|
461
|
+
if (typeof rawTraceparent === "string") {
|
|
462
|
+
const tp = rawTraceparent.trim();
|
|
463
|
+
if (isValidTraceparent(tp)) {
|
|
464
|
+
const ts = typeof rawTracestate === "string" && rawTracestate.length > 0 && rawTracestate.length <= TRACESTATE_MAX ? rawTracestate : void 0;
|
|
465
|
+
request.traceContext = {
|
|
466
|
+
traceparent: tp,
|
|
467
|
+
...ts ? { tracestate: ts } : {}
|
|
468
|
+
};
|
|
469
|
+
reply.header("traceparent", tp);
|
|
470
|
+
if (ts) reply.header("tracestate", ts);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
fastify.log?.debug?.("Request ID plugin registered");
|
|
476
|
+
};
|
|
477
|
+
var requestId_default = fp(requestIdPlugin, {
|
|
478
|
+
name: "arc-request-id",
|
|
479
|
+
fastify: "5.x"
|
|
480
|
+
});
|
|
481
|
+
export { health_default as a, DURATION_BUCKETS_SECONDS as c, renderMetricSample as d, healthPlugin as i, MetricHistogram as l, requestId_default as n, logBootHealthSummary as o, sanitizeRequestId as r, mergeHealthChecks as s, createRequestIdGenerator as t, MetricSeries as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
2
|
// src/idempotency/requirement.ts
|
|
3
3
|
/** What is wrong with a route's idempotency declaration, or `undefined` when it is sound. */
|
|
4
4
|
function idempotencyConfigProblem(config) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as createTenantKeyGenerator } from "./rateLimitKey-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as createTenantKeyGenerator } from "./rateLimitKey-DLGdeFd2.mjs";
|
|
3
3
|
// src/permissions/resourceRateLimit.ts
|
|
4
4
|
function decision(allowed, max, remaining, ttlSeconds) {
|
|
5
5
|
const reset = Math.max(1, ttlSeconds);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as ArcBootError } from "./bootError-BT3z3cvX.mjs";
|
|
2
3
|
// src/utils/runtimeCapabilities.ts
|
|
3
4
|
/**
|
|
4
5
|
* `Symbol.for` so declarations from two arc copies in one dependency graph
|
|
@@ -68,7 +69,11 @@ function auditRuntimeCapabilities(fastify, runtime) {
|
|
|
68
69
|
if (acceptedMemory.length > 0) fastify.log.info({ accepted: acceptedMemory.map((d) => d.subsystem) }, "[arc] per-process state accepted by design under runtime: 'distributed'");
|
|
69
70
|
if (violations.length > 0) {
|
|
70
71
|
const lines = violations.map((d) => ` - ${d.subsystem}${d.detail ? ` — ${d.detail}` : ""}`).join("\n");
|
|
71
|
-
throw new
|
|
72
|
+
throw new ArcBootError(`runtime: 'distributed' — ${violations.length} subsystem(s) hold PER-PROCESS state that multi-replica deployment breaks:\n${lines}\nWire a shared store for each, or — where per-process is genuinely intended — have the declarant pass \`accepted: true\` with a reason.`, violations.map((d) => ({
|
|
73
|
+
code: "runtime-memory-state",
|
|
74
|
+
message: `${d.subsystem} holds per-process state${d.detail ? ` — ${d.detail}` : ""}`,
|
|
75
|
+
fix: `wire a shared store for ${d.subsystem}, or declare it with accepted: true and a reason`
|
|
76
|
+
})));
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
export { declareRuntimeCapability as n, initRuntimeCapabilityRegistry as r, auditRuntimeCapabilities as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { t as runWorkScope } from "./workScope-
|
|
4
|
-
import { t as startRenewingLease } from "./renewingLease-
|
|
5
|
-
import { a as runShutdown, i as runAdmittedWork, r as registerShutdownParticipant } from "./shutdown-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-Cy6j0m8_.mjs";
|
|
3
|
+
import { t as runWorkScope } from "./workScope-C3tPz_Gt.mjs";
|
|
4
|
+
import { t as startRenewingLease } from "./renewingLease-DaoP0K-e.mjs";
|
|
5
|
+
import { a as runShutdown, i as runAdmittedWork, r as registerShutdownParticipant } from "./shutdown-C76Hn-Th.mjs";
|
|
6
6
|
import fp from "fastify-plugin";
|
|
7
7
|
import { civilDateOf, civilDateToInstant, isValidTimeZone, localTimeParts } from "@classytic/primitives/timezone";
|
|
8
8
|
// src/plugins/dailyGate.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as arcLog } from "./logger-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as arcLog } from "./logger-DdMS0XC_.mjs";
|
|
3
3
|
// src/utils/schemaConverter.ts
|
|
4
4
|
/**
|
|
5
5
|
* Schema Converter — Detect-First, Convert-Only-When-Needed
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { f as createError } from "./errors-
|
|
3
|
-
import { n as getUserRoles } from "./userHelpers-
|
|
4
|
-
import { b as isElevated, n as PUBLIC_SCOPE, u as getRequestScope, x as isMember } from "./types-
|
|
5
|
-
import { a as resolveEffectiveRoles, r as deriveHiddenFieldPermissions, t as applyFieldReadPermissions } from "./fields-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { n as
|
|
10
|
-
import { n as evaluateAndApplyPermission } from "./authorizationDecision-
|
|
11
|
-
import { t as executePipeline } from "./pipe-
|
|
12
|
-
import { n as idempotencyConfigProblem, t as declaresIdempotencyFence } from "./requirement-
|
|
13
|
-
import { i as resolveResourceRateLimiter, r as recordUnenforcedRateLimit } from "./resourceRateLimit-
|
|
14
|
-
import { n as arcRouteValidatorCompiler } from "./routeValidator-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { f as createError } from "./errors-Ukhmfmmx.mjs";
|
|
3
|
+
import { n as getUserRoles } from "./userHelpers-CwpEK36a.mjs";
|
|
4
|
+
import { b as isElevated, n as PUBLIC_SCOPE, u as getRequestScope, x as isMember } from "./types-ZvdR7MVa.mjs";
|
|
5
|
+
import { a as resolveEffectiveRoles, r as deriveHiddenFieldPermissions, t as applyFieldReadPermissions } from "./fields-B7fuROWK.mjs";
|
|
6
|
+
import { n as isTenantPreparation } from "./tenantPreparation-Bk8ouRB3.mjs";
|
|
7
|
+
import { o as toJsonSchema } from "./schemaConverter-XoLKVpzG.mjs";
|
|
8
|
+
import { t as buildRequestScopeProjection } from "./projection-B4rqiJTi.mjs";
|
|
9
|
+
import { n as requestContext } from "./requestContext-B-TjFpWt.mjs";
|
|
10
|
+
import { n as evaluateAndApplyPermission } from "./authorizationDecision-gB5-bHDp.mjs";
|
|
11
|
+
import { t as executePipeline } from "./pipe-DIAr91at.mjs";
|
|
12
|
+
import { n as idempotencyConfigProblem, t as declaresIdempotencyFence } from "./requirement-BygDzjDS.mjs";
|
|
13
|
+
import { i as resolveResourceRateLimiter, r as recordUnenforcedRateLimit } from "./resourceRateLimit-DdIYis3m.mjs";
|
|
14
|
+
import { n as arcRouteValidatorCompiler } from "./routeValidator-Bn-x2gaJ.mjs";
|
|
15
15
|
import { isPaginatedResult, toCanonicalList } from "@classytic/repo-core/pagination";
|
|
16
16
|
// src/core/fastifyAdapter.ts
|
|
17
17
|
/** Type guard for Mongoose-like documents with toObject() */
|
|
@@ -683,7 +683,7 @@ const groupLimits = /* @__PURE__ */ new WeakMap();
|
|
|
683
683
|
* mounting two resources at the same prefix, custom routes that share a
|
|
684
684
|
* URL with another plugin. Fastify's default message ("Method 'GET'
|
|
685
685
|
* already declared for route '/'") gives no hint at the resource-shaped
|
|
686
|
-
* fix —
|
|
686
|
+
* fix — leave the op out of `crud` — so wrap it with one.
|
|
687
687
|
*/
|
|
688
688
|
function tryRegisterRoute(fastify, opts, context) {
|
|
689
689
|
const ratePolicy = opts.config?.rateLimit;
|
|
@@ -777,7 +777,7 @@ function tryRegisterRoute(fastify, opts, context) {
|
|
|
777
777
|
"create",
|
|
778
778
|
"update",
|
|
779
779
|
"delete"
|
|
780
|
-
].includes(context.op) ? ` Suppress the auto-CRUD route
|
|
780
|
+
].includes(context.op) ? ` Suppress the auto-CRUD route by leaving '${context.op}' out of the \`crud\` allow-list.` : " If a custom route in `routes:` collides with auto-CRUD, leave the matching op out of the `crud` allow-list (`crud: { list: true, get: true, ... }`) in `defineResource()` to suppress the auto-CRUD route.";
|
|
781
781
|
const enhanced = /* @__PURE__ */ new Error(`[arc] Duplicate route ${method} ${url} on resource "${context.resourceName}"${opHint}.${fixHint} Original: ${fastifyErr.message ?? "FST_ERR_DUPLICATED_ROUTE"}`);
|
|
782
782
|
enhanced.code = "FST_ERR_DUPLICATED_ROUTE";
|
|
783
783
|
enhanced.cause = err;
|
package/dist/schemas/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
2
|
import { errorContractSchema, errorDetailSchema } from "@classytic/repo-core/errors";
|
|
3
3
|
import { Type, Type as Type$1 } from "typebox";
|
|
4
4
|
// src/schemas/index.ts
|
package/dist/scim/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as parseJsonBody } from "../jsonBody-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as parseJsonBody } from "../jsonBody-BNlcGUnb.mjs";
|
|
3
3
|
import fp from "fastify-plugin";
|
|
4
4
|
// src/scim/errors.ts
|
|
5
5
|
var ScimError = class extends Error {
|
package/dist/scope/index.d.mts
CHANGED
|
@@ -7,8 +7,12 @@ interface RateLimitKeyContext {
|
|
|
7
7
|
scope?: RequestScope;
|
|
8
8
|
}
|
|
9
9
|
interface TenantKeyGeneratorOptions {
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `'organization'` (the default when omitted) — one bucket per organisation, see the
|
|
12
|
+
* module docblock for the full chain. `'user'` — one bucket per signed-in user, IP when
|
|
13
|
+
* anonymous (`createApp`'s default key). A function — your own key.
|
|
14
|
+
*/
|
|
15
|
+
strategy?: "organization" | "user" | ((ctx: RateLimitKeyContext) => string);
|
|
12
16
|
}
|
|
13
17
|
export declare function createTenantKeyGenerator(opts?: TenantKeyGeneratorOptions): (ctx: RateLimitKeyContext) => string;
|
|
14
18
|
interface ResolveOrgFromHeaderOptions {
|
package/dist/scope/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { C as isService, D as requireUserId, E as requireTeamId, O as scopeFirstCtx, S as isOrgInScope, T as requireOrgId, _ as getUserRoles, a as getDPoPJkt, b as isElevated, c as getOrgId, d as getScopeContext, f as getScopeContextMap, g as getUserId, h as getTenantFromRequest, i as getClientId, l as getOrgRoles, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, r as getAncestorOrgIds, s as getOrgContext, t as AUTHENTICATED_SCOPE, u as getRequestScope, v as hasOrgAccess, w as requireClientId, x as isMember, y as isAuthenticated } from "../types-
|
|
3
|
-
import { t as createTenantKeyGenerator } from "../rateLimitKey-
|
|
4
|
-
import { t as elevation_default } from "../elevation-
|
|
5
|
-
import { t as resolveOrgFromHeader } from "../scope-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { C as isService, D as requireUserId, E as requireTeamId, O as scopeFirstCtx, S as isOrgInScope, T as requireOrgId, _ as getUserRoles, a as getDPoPJkt, b as isElevated, c as getOrgId, d as getScopeContext, f as getScopeContextMap, g as getUserId, h as getTenantFromRequest, i as getClientId, l as getOrgRoles, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, r as getAncestorOrgIds, s as getOrgContext, t as AUTHENTICATED_SCOPE, u as getRequestScope, v as hasOrgAccess, w as requireClientId, x as isMember, y as isAuthenticated } from "../types-ZvdR7MVa.mjs";
|
|
3
|
+
import { t as createTenantKeyGenerator } from "../rateLimitKey-DLGdeFd2.mjs";
|
|
4
|
+
import { t as elevation_default } from "../elevation-NJ3908pJ.mjs";
|
|
5
|
+
import { t as resolveOrgFromHeader } from "../scope-B0vgM2Zw.mjs";
|
|
6
6
|
export { AUTHENTICATED_SCOPE, PUBLIC_SCOPE, createTenantKeyGenerator, elevation_default as elevationPlugin, getAncestorOrgIds, getClientId, getDPoPJkt, getMandate, getOrgContext, getOrgId, getOrgRoles, getRequestScope, getScopeContext, getScopeContextMap, getServiceScopes, getTeamId, getTenantFromRequest, getUserId, getUserRoles, hasOrgAccess, isAuthenticated, isElevated, isMember, isOrgInScope, isService, requireClientId, requireOrgId, requireTeamId, requireUserId, resolveOrgFromHeader, scopeFirstCtx };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { a as OrgAccessDeniedError, l as UnauthorizedError } from "./errors-
|
|
3
|
-
import { n as requireSingleHeaderValue } from "./headers-
|
|
4
|
-
import { n as getUserRoles } from "./userHelpers-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { a as OrgAccessDeniedError, l as UnauthorizedError } from "./errors-Ukhmfmmx.mjs";
|
|
3
|
+
import { n as requireSingleHeaderValue } from "./headers-Ib7BDgRI.mjs";
|
|
4
|
+
import { n as getUserRoles } from "./userHelpers-CwpEK36a.mjs";
|
|
5
5
|
// src/scope/resolveOrgFromHeader.ts
|
|
6
6
|
/**
|
|
7
7
|
* Create a preHandler hook that resolves org scope from a header.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
// src/utils/shutdown.ts
|
|
4
4
|
/** Stop admissions across every runtime before draining work and disposing domain engines. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
3
|
-
import { n as isEventVisible, t as eventAudienceOf } from "./tenancy-
|
|
4
|
-
import { t as arcLog } from "./logger-
|
|
5
|
-
import { g as getUserId, n as PUBLIC_SCOPE } from "./types-
|
|
6
|
-
import { a as registerSseStats, r as openSseStream } from "./sseStream-
|
|
7
|
-
import { a as promoteStreamTokenToHeader } from "./streaming-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-Cy6j0m8_.mjs";
|
|
3
|
+
import { n as isEventVisible, t as eventAudienceOf } from "./tenancy-YuRYsOPr.mjs";
|
|
4
|
+
import { t as arcLog } from "./logger-DdMS0XC_.mjs";
|
|
5
|
+
import { g as getUserId, n as PUBLIC_SCOPE } from "./types-ZvdR7MVa.mjs";
|
|
6
|
+
import { a as registerSseStats, r as openSseStream } from "./sseStream-BsBesrfw.mjs";
|
|
7
|
+
import { a as promoteStreamTokenToHeader } from "./streaming-DKziqs1Z.mjs";
|
|
8
8
|
import fp from "fastify-plugin";
|
|
9
9
|
// src/plugins/sse.ts
|
|
10
10
|
var sse_exports = /* @__PURE__ */ __exportAll({ default: () => sse_default });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as forwardedStreamHeaders } from "./streaming-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as forwardedStreamHeaders } from "./streaming-DKziqs1Z.mjs";
|
|
3
3
|
// src/utils/sseStats.ts
|
|
4
4
|
/** Per-instance stats providers behind one `sseStats` decorator. */
|
|
5
5
|
const statsProviders = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
2
|
// src/events/subscriberIdentity.ts
|
|
3
3
|
const SUBSCRIBER_ID = Symbol.for("@classytic/arc/subscriber-id");
|
|
4
4
|
/** Assign a deployment-stable identity for durable per-handler progress; never use an index. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { b as isElevated, c as getOrgId } from "./types-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { b as isElevated, c as getOrgId } from "./types-ZvdR7MVa.mjs";
|
|
3
3
|
// src/core/tenancy.ts
|
|
4
4
|
function eventAudienceOf(scope) {
|
|
5
5
|
const tenancy = resolveTenancy({ _scope: scope }, "organizationId");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as conjoinPolicyFilters } from "./filter-merge-
|
|
3
|
-
import { b as isElevated, c as getOrgId, d as getScopeContext, m as getTeamId, v as hasOrgAccess } from "./types-
|
|
4
|
-
import { d as createDomainError } from "./errors-
|
|
1
|
+
/*! @classytic/arc v2.53.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as conjoinPolicyFilters } from "./filter-merge-BuzZ-r9z.mjs";
|
|
3
|
+
import { b as isElevated, c as getOrgId, d as getScopeContext, m as getTeamId, v as hasOrgAccess } from "./types-ZvdR7MVa.mjs";
|
|
4
|
+
import { d as createDomainError } from "./errors-Ukhmfmmx.mjs";
|
|
5
5
|
// src/permissions/tenantPreparation.ts
|
|
6
6
|
/** Tenant preparation shared by HTTP middleware and direct transport invocation. */
|
|
7
7
|
const PREPARATION = Symbol.for("arc.tenantPreparation");
|
|
@@ -23,6 +23,18 @@ function withoutTenantInjection(middlewares) {
|
|
|
23
23
|
return !(typeof preparation === "object" && preparation !== null && "mode" in preparation && preparation.mode === "inject");
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The tenant middlewares a custom or preset route runs, per `RouteDefinition.tenantScope`.
|
|
28
|
+
* The one rule HTTP and MCP share; empty when the resource has no multiTenant preset.
|
|
29
|
+
*/
|
|
30
|
+
function routeTenantMiddlewares(route, middlewares) {
|
|
31
|
+
const scoped = middlewares?.tenantScope;
|
|
32
|
+
if (!scoped?.length || route.tenantScope === false) return [];
|
|
33
|
+
if (route.tenantScope === true) return [...scoped];
|
|
34
|
+
if (route.rawHandler !== void 0) return [];
|
|
35
|
+
if (route._tenantSlot) return (middlewares?.[route._tenantSlot] ?? []).filter((mw) => isTenantPreparation(mw));
|
|
36
|
+
return withoutTenantInjection(scoped);
|
|
37
|
+
}
|
|
26
38
|
function prepareTenancy(scope, preparation) {
|
|
27
39
|
if (preparation.mode === "crossTenant") return { crossTenant: true };
|
|
28
40
|
const elevated = isElevated(scope);
|
|
@@ -63,4 +75,4 @@ function prepareTenantContext(ctx, middlewares) {
|
|
|
63
75
|
if (meta._tenantFields) ctx._tenantFields = meta._tenantFields;
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
|
-
export {
|
|
78
|
+
export { tagTenantPreparation as a, routeTenantMiddlewares as i, isTenantPreparation as n, withoutTenantInjection as o, prepareTenantContext as r, applyTenantPreparation as t };
|