@classytic/arc 2.31.0 → 2.33.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 +1 -1
- package/bin/arc.js +58 -17
- package/dist/{BaseController-De7GqHck.mjs → BaseController-CaQC5EXX.mjs} +298 -35
- package/dist/{EventTransport-2uVV34WU.d.mts → EventTransport-BEVP50ka.d.mts} +16 -0
- package/dist/{EventTransport-9mlTgqzE.mjs → EventTransport-tq4CEB-q.mjs} +39 -2
- package/dist/{HookSystem-BcmPyq5I.mjs → HookSystem-DqXkMXkB.mjs} +2 -2
- package/dist/{ResourceRegistry-qq0mn2s9.mjs → ResourceRegistry-DoALUlOO.mjs} +18 -15
- package/dist/{actionPermissions-BE5NwaQk.mjs → actionPermissions-CUeCmpUd.mjs} +1 -1
- package/dist/audit/index.d.mts +2 -2
- package/dist/audit/index.mjs +2 -2
- package/dist/auth/audit.mjs +1 -1
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.mjs +44 -11
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/{authorizationDecision-ChvUQGG1.mjs → authorizationDecision-B3mP_QTy.mjs} +2 -2
- package/dist/{types-B7XeLEgK.d.mts → base-Csjc2oF-.d.mts} +74 -74
- package/dist/{buildHandler-CDrCJzmB.mjs → buildHandler-DLE9xX-V.mjs} +6 -5
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-BFHA6Scf.mjs → caching-BcGmvnHh.mjs} +2 -2
- package/dist/cleanup/index.d.mts +52 -18
- package/dist/cleanup/index.mjs +281 -32
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/describe.mjs +4 -6
- 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-D3Dv4LAV.mjs → constants-BxCoxmiN.mjs} +1 -1
- package/dist/context/index.mjs +3 -3
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +7 -7
- package/dist/{core-BGpIxINN.mjs → core-dxhcHhUD.mjs} +3 -3
- package/dist/{createActionRouter-CDXEdasl.mjs → createActionRouter-DVpoA0do.mjs} +14 -11
- package/dist/{createAggregationRouter-KrQDzx-k.mjs → createAggregationRouter-B_B48JZ-.mjs} +10 -8
- package/dist/{createApp-Df89BEni.mjs → createApp-CLGegqiG.mjs} +287 -62
- package/dist/{defineAggregation-DbPPS8RI.mjs → defineAggregation-Nv-DwfOf.mjs} +1 -1
- package/dist/{defineResource-Bv6EtN1x.mjs → defineResource-DR9vsUYy.mjs} +318 -35
- 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-D2l1mh4g.mjs → elevation-B0tlY8y1.mjs} +4 -4
- package/dist/encryption/index.mjs +5 -4
- package/dist/{errorHandler-C5NeD6bT.mjs → errorHandler-C7xBqHsI.mjs} +42 -5
- package/dist/{errorHandler-CpYUJmPA.d.mts → errorHandler-DI5AN2b5.d.mts} +14 -3
- package/dist/{errors-Cj42AntO.mjs → errors-Cd_yy7aW.mjs} +1 -1
- package/dist/{eventPlugin-GF5nnBIq.d.mts → eventPlugin-DSNEZWfV.d.mts} +29 -1
- package/dist/{eventPlugin-CkffEihm.mjs → eventPlugin-Dar8qRaj.mjs} +68 -11
- package/dist/events/index.d.mts +18 -297
- package/dist/events/index.mjs +7 -758
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +14 -10
- package/dist/events/transports/redis.d.mts +1 -1
- package/dist/events/transports/redis.mjs +1 -1
- package/dist/factory/index.d.mts +20 -5
- package/dist/factory/index.mjs +131 -8
- package/dist/fastify-augmentation-DVsTAy6X.d.mts +179 -0
- package/dist/{fields-CB5Cuzk9.mjs → fields-CojeUkS4.mjs} +6 -11
- package/dist/{generate-EcA6ui4i.mjs → generate-DiB0nHPR.mjs} +2 -2
- package/dist/{headers-3zvE0rM3.mjs → headers-CveNO9gR.mjs} +2 -2
- package/dist/{health-DjZYjM7H.mjs → health-CasG2A28.mjs} +1 -1
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/idempotency/index.d.mts +45 -1
- package/dist/idempotency/index.mjs +95 -11
- package/dist/idempotency/redis.mjs +1 -1
- package/dist/{index-CEJNZFtX.d.mts → index-B-DvUzsr.d.mts} +82 -3
- package/dist/{index-CpzxqePp.d.mts → index-BcR2bFZQ.d.mts} +707 -373
- package/dist/{index-Bc2ox8_U.d.mts → index-Brin0ODU.d.mts} +4 -4
- package/dist/{index-CFThn1K9.d.mts → index-C5NnMEKF.d.mts} +70 -4
- package/dist/{index-C-481Zf2.d.mts → index-ugr1tQlW.d.mts} +17 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +11 -11
- package/dist/{init-BEiNZBsJ.mjs → init-mdJ-v4Xp.mjs} +24 -16
- package/dist/integrations/event-gateway.d.mts +1 -1
- package/dist/integrations/event-gateway.mjs +2 -2
- package/dist/integrations/index.d.mts +2 -2
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs/index.d.mts +1 -1
- package/dist/integrations/jobs/index.mjs +100 -98
- package/dist/integrations/mcp/index.d.mts +12 -3
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +2 -2
- package/dist/integrations/streamline.mjs +3 -3
- package/dist/integrations/webhooks.d.mts +124 -1
- package/dist/integrations/webhooks.mjs +180 -2
- package/dist/integrations/websocket-pushref-redis.mjs +1 -1
- package/dist/integrations/websocket-redis.mjs +1 -1
- package/dist/integrations/websocket.mjs +38 -35
- package/dist/{interface-DYzM0q-u.mjs → interface-DznJrm9R.mjs} +1 -1
- package/dist/{jsonBody-BYbLDi5D.mjs → jsonBody-CfGH-GxO.mjs} +2 -2
- package/dist/{keys-C0_pa1tY.mjs → keys-WeKvY1dE.mjs} +1 -1
- package/dist/{loadResources-yawi9tAE.mjs → loadResources-Bj-aSsXi.mjs} +4 -3
- package/dist/{loadResourcesFromEntry-BAjYZonx.mjs → loadResourcesFromEntry-DwaxNcE2.mjs} +2 -2
- package/dist/logger/index.mjs +1 -1
- package/dist/{mcpPlugin-B_es0hiF.mjs → mcpPlugin-aJg5TqHi.mjs} +76 -36
- package/dist/{memory-DR6wpa9F.mjs → memory-qYSB7rMQ.mjs} +5 -5
- package/dist/{metrics-CUdw_wLB.mjs → metrics-D7uchLjN.mjs} +2 -2
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.mjs +3 -3
- package/dist/migrations/index.mjs +3 -3
- package/dist/{module-0pFJA6YW.mjs → module-CwKsgZXp.mjs} +1 -1
- package/dist/{multipartBody-wOgj_fnj.mjs → multipartBody-4w-S3-PU.mjs} +3 -3
- package/dist/{openapi-B2L4js1v.mjs → openapi-BN5cQaO2.mjs} +6 -6
- package/dist/outbox-admin/index.d.mts +85 -0
- package/dist/outbox-admin/index.mjs +115 -0
- package/dist/outbox-module-CXB79bvt.mjs +839 -0
- package/dist/outbox-module-D-VFq37T.d.mts +368 -0
- package/dist/permissions/index.d.mts +3 -3
- package/dist/permissions/index.mjs +6 -6
- package/dist/{permissions-L--QDAir.mjs → permissions-BAfwgBxc.mjs} +120 -8
- package/dist/{pipe-DRDNsI2T.mjs → pipe-BzzoEhHj.mjs} +3 -5
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +2 -2
- package/dist/{pipeline-UPQFatit.mjs → pipeline-q69DZzgG.mjs} +17 -15
- package/dist/plugins/index.d.mts +6 -6
- package/dist/plugins/index.mjs +16 -16
- package/dist/plugins/response-cache.mjs +2 -2
- package/dist/plugins/tracing-entry.mjs +2 -2
- package/dist/{pluralize-O0FZgESl.mjs → pluralize-B7xf8qZF.mjs} +1 -1
- package/dist/{preloadResources-Dz6BjzM6.mjs → preloadResources-BkyqeTDz.mjs} +1 -1
- package/dist/{preloadResources-CyoJMSiO.d.mts → preloadResources-g07ldtzh.d.mts} +30 -7
- package/dist/presets/filesUpload.d.mts +2 -2
- package/dist/presets/filesUpload.mjs +6 -6
- 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 +3 -3
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +2 -2
- package/dist/{presets-C4-g4_4P.mjs → presets-D-h0uWtP.mjs} +6 -5
- package/dist/projection-BKM0Ui-s.mjs +42 -0
- package/dist/{queryCachePlugin-BZr8v46E.mjs → queryCachePlugin-DhsZ0ZIc.mjs} +50 -8
- package/dist/{rateLimit-CMPY5Qms.mjs → rateLimit-D4-ASwsI.mjs} +2 -2
- package/dist/{rateLimitKey-Dn5JNmkj.mjs → rateLimitKey-XngqVNEV.mjs} +1 -1
- package/dist/{realtime-C5NoxWFY.mjs → realtime-CTkv3O59.mjs} +10 -10
- package/dist/{redis-stream-qN6A-RFv.d.mts → redis-stream-mwLWlfHG.d.mts} +1 -1
- package/dist/{registerRoute-CBN84fc7.mjs → registerRoute-DNnd3vkz.mjs} +10 -8
- package/dist/registry/index.d.mts +3 -3
- package/dist/registry/index.mjs +3 -3
- package/dist/{registry-4213U4zb.mjs → registry-CLxCR5LF.mjs} +2 -2
- package/dist/{renewingLease-Dll8mGgc.mjs → renewingLease-BnWtbA2U.mjs} +1 -1
- package/dist/{replyHelpers-DIiZKGUt.mjs → replyHelpers-BSBVCwL3.mjs} +2 -2
- package/dist/{repositoryFilter-f9eAfq_l.mjs → repositoryFilter-DKny7PDn.mjs} +1 -1
- package/dist/{requestContext-2TxXOJ7T.mjs → requestContext-uYE35JxI.mjs} +1 -1
- package/dist/{rolldown-runtime-CUsjNX9R.mjs → rolldown-runtime-DNg-KNCk.mjs} +1 -1
- package/dist/runtimeCapabilities-Dm88DaTW.mjs +49 -0
- package/dist/{schedules-DdtlICTf.mjs → schedules-CAcZgia0.mjs} +3 -3
- package/dist/{schemaConverter-D--wdJM-.mjs → schemaConverter-XH1RZRyu.mjs} +1 -1
- package/dist/{schemaIR-Bm2enbnh.mjs → schemaIR-CDvclAew.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-DHx5Fous.mjs → scope-BaWcqBvr.mjs} +4 -4
- package/dist/{simpleEqualityMatcher-DjQJ7FKA.mjs → simpleEqualityMatcher-Se8VrsaP.mjs} +1 -1
- package/dist/{sse-CUTo9y0X.mjs → sse-Cf0jUHsh.mjs} +7 -6
- package/dist/{sseStream-B_5XcVVd.mjs → sseStream-Bvpi-UXQ.mjs} +2 -2
- package/dist/{store-helpers-D1MP_gRG.mjs → store-helpers-B88p99Z2.mjs} +1 -1
- package/dist/{streaming-PSZwi8JV.mjs → streaming-DsT1B5zJ.mjs} +1 -1
- package/dist/{subscribe-helpers-C0Tb2aUp.mjs → subscribe-helpers-CLIOHsOK.mjs} +2 -2
- package/dist/sync/changelog.mjs +1 -1
- package/dist/testing/cleanupStoreContract.d.mts +1 -1
- package/dist/testing/cleanupStoreContract.mjs +12 -6
- package/dist/testing/index.d.mts +52 -13
- package/dist/testing/index.mjs +110 -40
- package/dist/testing/outboxStoreContract.d.mts +11 -2
- package/dist/testing/outboxStoreContract.mjs +110 -21
- package/dist/testing/storageContract.mjs +11 -6
- package/dist/{transactionContext-dAfBVUrk.mjs → transactionContext-BYtWnwAS.mjs} +1 -1
- package/dist/{typeGuards-B0ryPo3I.mjs → typeGuards-jjKJDN13.mjs} +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.mjs +1 -1
- package/dist/types/storage.mjs +1 -1
- package/dist/{types-CBgvkp8O.d.mts → types-BcTumAz_.d.mts} +128 -18
- package/dist/{types-CwcUQ610.d.mts → types-BfC83KsP.d.mts} +15 -1
- package/dist/{types-Cys0ko9Z.mjs → types-CoqIRrkY.mjs} +4 -4
- package/dist/{types-C4QE8qnm.d.mts → types-DVLddu2q.d.mts} +144 -1
- package/dist/usage/index.d.mts +1 -1
- package/dist/usage/index.mjs +0 -0
- package/dist/{userHelpers-ChYJ6CdK.mjs → userHelpers-CWF5pbZD.mjs} +1 -1
- package/dist/utils/index.d.mts +57 -5
- package/dist/utils/index.mjs +12 -11
- package/dist/{utils-vL8BrDE2.mjs → utils-h1V_sT-t.mjs} +38 -7
- package/dist/{validate-_KbifpHF.mjs → validate-CdQlz52F.mjs} +2 -2
- package/dist/{versioning-D_rhHfZm.d.mts → versioning-DEs-_hFi.d.mts} +1 -1
- package/dist/{versioning-CHDTor3P.mjs → versioning-rZbyLVD-.mjs} +4 -4
- package/package.json +31 -20
- package/skills/arc/SKILL.md +96 -4
- package/skills/arc/references/api-reference.md +19 -0
- package/skills/arc/references/production.md +2 -2
- package/dist/fastify-augmentation-zh0_AYHa.d.mts +0 -85
- package/dist/projection-BHw6xlOQ.mjs +0 -18
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { n as RedisStreamTransport, r as RedisStreamTransportOptions, t as RedisStreamLike } from "../../redis-stream-
|
|
2
|
+
import { n as RedisStreamTransport, r as RedisStreamTransportOptions, t as RedisStreamLike } from "../../redis-stream-mwLWlfHG.mjs";
|
|
3
3
|
export { type RedisStreamLike, RedisStreamTransport, type RedisStreamTransportOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
|
|
2
2
|
import sjson from "secure-json-parse";
|
|
3
3
|
//#region src/events/transports/redis-stream.ts
|
|
4
4
|
/**
|
|
@@ -184,13 +184,15 @@ var RedisStreamTransport = class {
|
|
|
184
184
|
this.handlers.clear();
|
|
185
185
|
this.failureContext.clear();
|
|
186
186
|
if (this.pollPromise) {
|
|
187
|
-
if (await Promise.race([this.pollPromise.then(() => "drained"), this.sleep(this.closeTimeoutMs).then(() => "timeout")]) === "timeout")
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
this.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
if (await Promise.race([this.pollPromise.then(() => "drained"), this.sleep(this.closeTimeoutMs).then(() => "timeout")]) === "timeout") {
|
|
188
|
+
if (!this.externalLifecycle) {
|
|
189
|
+
if (typeof this.redis.disconnect === "function") this.redis.disconnect();
|
|
190
|
+
else await this.redis.quit().catch((err) => {
|
|
191
|
+
this.logger.error("[RedisStreamTransport] quit() during close raced:", err);
|
|
192
|
+
});
|
|
193
|
+
await this.pollPromise.catch(() => void 0);
|
|
194
|
+
} else this.pollPromise.catch(() => void 0);
|
|
195
|
+
}
|
|
194
196
|
this.pollPromise = null;
|
|
195
197
|
}
|
|
196
198
|
if (!this.externalLifecycle) await this.redis.quit().catch(() => void 0);
|
|
@@ -251,8 +253,10 @@ var RedisStreamTransport = class {
|
|
|
251
253
|
const overRetryIds = [];
|
|
252
254
|
for (const entry of pending) {
|
|
253
255
|
const [id, , idleTime, deliveryCount] = entry;
|
|
254
|
-
if (idleTime > this.claimTimeoutMs)
|
|
255
|
-
|
|
256
|
+
if (idleTime > this.claimTimeoutMs) {
|
|
257
|
+
if (deliveryCount >= this.maxRetries) overRetryIds.push(id);
|
|
258
|
+
else staleIds.push(id);
|
|
259
|
+
}
|
|
256
260
|
}
|
|
257
261
|
if (overRetryIds.length > 0) await this.moveToDlq(overRetryIds);
|
|
258
262
|
if (staleIds.length > 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler } from "../../EventTransport-
|
|
2
|
+
import { a as EventTransport, i as EventLogger, n as DomainEvent, r as EventHandler } from "../../EventTransport-BEVP50ka.mjs";
|
|
3
3
|
//#region src/events/transports/redis.d.ts
|
|
4
4
|
interface RedisLike {
|
|
5
5
|
publish(channel: string, message: string): Promise<number>;
|
package/dist/factory/index.d.mts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as ModuleContribution, c as
|
|
3
|
-
import { a as lazyModuleExports, c as getModuleState, d as resolveModule, f as orderModules, g as
|
|
4
|
-
import "../fastify-augmentation-
|
|
5
|
-
import { a as RawBodyOptions, c as BetterAuthOption, d as JwtAuthOption, i as MultipartOptions, l as CustomAuthenticatorOption, n as preloadResourcesAsync, o as UnderPressureOptions, r as CreateAppOptions, s as AuthOption, t as preloadResources, u as CustomPluginAuthOption } from "../preloadResources-
|
|
2
|
+
import { _ as HealthCheck, a as ModuleContribution, c as LoadResourcesOptions, d as loadResources, i as EventHandlerDefinition, l as ResourceLike, n as ArcModuleInput, o as ModuleDisposer, r as ArcModuleRegistry, s as ModuleSetupContext, t as ArcModule, u as ResourceModule } from "../types-BcTumAz_.mjs";
|
|
3
|
+
import { _ as collectModuleScheduledJobs, a as lazyModuleExports, c as getModuleState, d as resolveModule, f as orderModules, g as collectModuleHealthChecks, h as extendModule, i as hasModuleExports, l as hasModule, m as ModuleExtension, n as getModuleExports, o as lazyRequiredModuleExports, p as subscribeModuleEventHandlers, r as getOptionalModuleExports, s as ModuleState, t as defineModule, u as resolveContribution, v as collectModuleWorkflows } from "../index-C5NnMEKF.mjs";
|
|
4
|
+
import { c as ResolvedResourceDescriptor, l as describeResolvedModule, o as ResolvedModuleDescriptor, s as ResolvedModuleLifecycle } from "../fastify-augmentation-DVsTAy6X.mjs";
|
|
5
|
+
import { a as RawBodyOptions, c as BetterAuthOption, d as JwtAuthOption, i as MultipartOptions, l as CustomAuthenticatorOption, n as preloadResourcesAsync, o as UnderPressureOptions, r as CreateAppOptions, s as AuthOption, t as preloadResources, u as CustomPluginAuthOption } from "../preloadResources-g07ldtzh.mjs";
|
|
6
6
|
import { FastifyInstance, FastifyServerOptions } from "fastify";
|
|
7
7
|
//#region src/factory/createApp.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Default redact paths layered into Fastify's pino logger when the host
|
|
10
|
+
* doesn't supply a `logger.redact` of their own. Covers the common token /
|
|
11
|
+
* cookie / password leak surfaces — `Authorization` and `Cookie` headers
|
|
12
|
+
* (and their case-variants because Node lower-cases incoming headers but
|
|
13
|
+
* outgoing logs may carry either), API-key headers, and any nested
|
|
14
|
+
* `password` / `token` / `secret` / `apiKey` fields anywhere in the log
|
|
15
|
+
* tree.
|
|
16
|
+
*
|
|
17
|
+
* Hosts that need NO redaction (test fixtures, security audits) opt out
|
|
18
|
+
* with `logger: { redact: [] }`. Hosts that need MORE redaction supply
|
|
19
|
+
* their own `redact` and arc steps aside — this default never overrides
|
|
20
|
+
* an explicit setting. (2.15.1)
|
|
21
|
+
*/
|
|
22
|
+
declare const DEFAULT_LOGGER_REDACT_PATHS: readonly ["req.headers.authorization", 'req.headers["x-api-key"]', 'req.headers["x-internal-api-key"]', "req.headers.cookie", 'req.headers["set-cookie"]', 'res.headers["set-cookie"]', "*.password", "*.passwordHash", "*.token", "*.accessToken", "*.refreshToken", "*.secret", "*.apiKey"];
|
|
8
23
|
/**
|
|
9
24
|
* Create a production-ready Fastify application with Arc framework.
|
|
10
25
|
*
|
|
@@ -137,4 +152,4 @@ declare const testingPreset: Partial<CreateAppOptions>;
|
|
|
137
152
|
declare const edgePreset: Partial<CreateAppOptions>;
|
|
138
153
|
declare function getPreset(name: "production" | "development" | "testing" | "edge" | "worker"): Partial<CreateAppOptions>;
|
|
139
154
|
//#endregion
|
|
140
|
-
export { ArcFactory, type ArcModule, type ArcModuleInput, type ArcModuleRegistry, type ArcWorker, type AuthOption, type BetterAuthOption, type CreateAppOptions, type CreateWorkerOptions, type CustomAuthenticatorOption, type CustomPluginAuthOption, type EventHandlerDefinition, type FetchHandlerOptions, type JwtAuthOption, type LoadResourcesOptions, type ModuleContribution, type ModuleState, type MultipartOptions, type RawBodyOptions, type ResourceLike, type ResourceModule, type UnderPressureOptions, type WorkerHealthOptions, collectModuleHealthChecks, collectModuleScheduledJobs, collectModuleWorkflows, createApp, createWorker, defineModule, developmentPreset, edgePreset, getModuleExports, getModuleState, getOptionalModuleExports, getPreset, hasModule, hasModuleExports, lazyModuleExports, lazyRequiredModuleExports, loadResources, orderModules, preloadResources, preloadResourcesAsync, productionPreset, resolveContribution, resolveModule, subscribeModuleEventHandlers, testingPreset, toFetchHandler };
|
|
155
|
+
export { ArcFactory, type ArcModule, type ArcModuleInput, type ArcModuleRegistry, type ArcWorker, type AuthOption, type BetterAuthOption, type CreateAppOptions, type CreateWorkerOptions, type CustomAuthenticatorOption, type CustomPluginAuthOption, DEFAULT_LOGGER_REDACT_PATHS, type EventHandlerDefinition, type FetchHandlerOptions, type JwtAuthOption, type LoadResourcesOptions, type ModuleContribution, type ModuleDisposer, type ModuleExtension, type ModuleSetupContext, type ModuleState, type MultipartOptions, type RawBodyOptions, type ResolvedModuleDescriptor, type ResolvedModuleLifecycle, type ResolvedResourceDescriptor, type ResourceLike, type ResourceModule, type UnderPressureOptions, type WorkerHealthOptions, collectModuleHealthChecks, collectModuleScheduledJobs, collectModuleWorkflows, createApp, createWorker, defineModule, describeResolvedModule, developmentPreset, edgePreset, extendModule, getModuleExports, getModuleState, getOptionalModuleExports, getPreset, hasModule, hasModuleExports, lazyModuleExports, lazyRequiredModuleExports, loadResources, orderModules, preloadResources, preloadResourcesAsync, productionPreset, resolveContribution, resolveModule, subscribeModuleEventHandlers, testingPreset, toFetchHandler };
|
package/dist/factory/index.mjs
CHANGED
|
@@ -1,9 +1,131 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { r as mergeHealthChecks, t as healthPlugin } from "../health-
|
|
3
|
-
import { _ as
|
|
4
|
-
import { a as lazyModuleExports, i as hasModuleExports, n as getModuleExports, o as lazyRequiredModuleExports, r as getOptionalModuleExports, t as defineModule } from "../module-
|
|
5
|
-
import { t as loadResources } from "../loadResources-
|
|
6
|
-
import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-
|
|
1
|
+
/*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
|
|
2
|
+
import { r as mergeHealthChecks, t as healthPlugin } from "../health-CasG2A28.mjs";
|
|
3
|
+
import { _ as collectModuleScheduledJobs, a as developmentPreset, b as resolveModule, c as productionPreset, d as getModuleState, f as hasModule, g as collectModuleHealthChecks, h as describeResolvedModule, l as testingPreset, m as subscribeModuleEventHandlers, n as DEFAULT_LOGGER_REDACT_PATHS, o as edgePreset, p as orderModules, r as createApp, s as getPreset, t as ArcFactory, u as workerPreset, v as collectModuleWorkflows, y as resolveContribution } from "../createApp-CLGegqiG.mjs";
|
|
4
|
+
import { a as lazyModuleExports, i as hasModuleExports, n as getModuleExports, o as lazyRequiredModuleExports, r as getOptionalModuleExports, t as defineModule } from "../module-CwKsgZXp.mjs";
|
|
5
|
+
import { t as loadResources } from "../loadResources-Bj-aSsXi.mjs";
|
|
6
|
+
import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-BkyqeTDz.mjs";
|
|
7
|
+
//#region src/factory/module/extend.ts
|
|
8
|
+
/** Concatenate two contributions, resolving factories only when arc asks. */
|
|
9
|
+
function mergeContribution(own, extra) {
|
|
10
|
+
if (own === void 0) return extra;
|
|
11
|
+
if (extra === void 0) return own;
|
|
12
|
+
return async (fastify) => {
|
|
13
|
+
const a = typeof own === "function" ? await own(fastify) : own;
|
|
14
|
+
const b = typeof extra === "function" ? await extra(fastify) : extra;
|
|
15
|
+
return [...a, ...b];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Plain-array concat, for the arms that are NOT `ModuleContribution`.
|
|
20
|
+
*
|
|
21
|
+
* `healthChecks` and `errorMappers` are declared as arrays only — arc reads
|
|
22
|
+
* them directly and never calls them. Routing them through the factory merge
|
|
23
|
+
* above would hand arc a function where it expects a list, which does not fail
|
|
24
|
+
* loudly: the arm reads as non-empty and contributes nothing.
|
|
25
|
+
*/
|
|
26
|
+
function mergeArray(own, extra) {
|
|
27
|
+
if (own === void 0) return extra;
|
|
28
|
+
if (extra === void 0) return own;
|
|
29
|
+
return [...own, ...extra];
|
|
30
|
+
}
|
|
31
|
+
/** Order-preserving union — a duplicate edge or claim is not an error. */
|
|
32
|
+
function mergeNames(own, extra) {
|
|
33
|
+
if (own === void 0) return extra;
|
|
34
|
+
if (extra === void 0) return own;
|
|
35
|
+
return [.../* @__PURE__ */ new Set([...own, ...extra])];
|
|
36
|
+
}
|
|
37
|
+
function mergeOwns(own, extra) {
|
|
38
|
+
if (own === "provided" || extra === "provided") return "provided";
|
|
39
|
+
return mergeNames(own, extra);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run both lifecycle hooks, module's first, composing whatever disposers they
|
|
43
|
+
* return. Teardown runs in REVERSE, matching arc's own module teardown order.
|
|
44
|
+
*/
|
|
45
|
+
function mergeHook(own, extra) {
|
|
46
|
+
if (own === void 0) return extra;
|
|
47
|
+
if (extra === void 0) return own;
|
|
48
|
+
return async (fastify, context) => {
|
|
49
|
+
const d1 = await own(fastify, context);
|
|
50
|
+
const d2 = await extra(fastify, context);
|
|
51
|
+
if (!d1 && !d2) return void 0;
|
|
52
|
+
const disposer = async () => {
|
|
53
|
+
if (d2) await d2();
|
|
54
|
+
if (d1) await d1();
|
|
55
|
+
};
|
|
56
|
+
return disposer;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Close the MODULE first, then the host — the opposite of the disposer order
|
|
61
|
+
* above, and deliberately so.
|
|
62
|
+
*
|
|
63
|
+
* A disposer pair is symmetric setup/teardown, so it unwinds LIFO. `onClose` is
|
|
64
|
+
* not: the resource whose lifetime encloses everything is usually the ENGINE,
|
|
65
|
+
* and in a bring-your-own-engine composition the HOST owns it and hands it to
|
|
66
|
+
* the module. Running the host's `onClose` first would destroy the engine while
|
|
67
|
+
* the module is still draining work against it.
|
|
68
|
+
*
|
|
69
|
+
* be-prod's planning module states exactly this order in prose and implements
|
|
70
|
+
* it by hand — "the module's own onClose first (drains its built-in inFlight),
|
|
71
|
+
* then our host-side fallback inFlight, then destroy the BYO engine". Encoding
|
|
72
|
+
* it here is what stops the next host from getting it backwards.
|
|
73
|
+
*/
|
|
74
|
+
function mergeOnClose(own, extra) {
|
|
75
|
+
if (own === void 0) return extra;
|
|
76
|
+
if (extra === void 0) return own;
|
|
77
|
+
return async (fastify) => {
|
|
78
|
+
await own(fastify);
|
|
79
|
+
await extra(fastify);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Merge a host's additions onto a module. Nothing the module declared is lost.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* return extendModule(createOrderModule({ … }), {
|
|
87
|
+
* eventHandlers: () => hostHandlers(), // appended after the module's
|
|
88
|
+
* dependsOn: ["outbox"], // unioned
|
|
89
|
+
* bootstrap: (inner) => async (f, c) => { // wraps, never replaces
|
|
90
|
+
* const exports = await inner?.(f, c);
|
|
91
|
+
* return decorate(exports);
|
|
92
|
+
* },
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
function extendModule(mod, extension) {
|
|
97
|
+
const out = { ...mod };
|
|
98
|
+
/**
|
|
99
|
+
* Assign only when the merge produced something.
|
|
100
|
+
*
|
|
101
|
+
* An absent arm must stay ABSENT rather than become `[]` or `undefined` —
|
|
102
|
+
* arc distinguishes "contributes nothing" from "contributes an empty list"
|
|
103
|
+
* when deciding whether a module participates in an arm at all.
|
|
104
|
+
*
|
|
105
|
+
* Each merge is therefore evaluated ONCE, into this call. Writing the
|
|
106
|
+
* condition and the value as two separate calls would leave twelve pairs of
|
|
107
|
+
* duplicated expressions, where editing one half and not the other changes
|
|
108
|
+
* nothing visible and produces a module whose arm silently disagrees with the
|
|
109
|
+
* check that decided to set it.
|
|
110
|
+
*/
|
|
111
|
+
const set = (key, value) => {
|
|
112
|
+
if (value !== void 0) out[key] = value;
|
|
113
|
+
};
|
|
114
|
+
set("dependsOn", mergeNames(mod.dependsOn, extension.dependsOn));
|
|
115
|
+
set("owns", mergeOwns(mod.owns, extension.owns));
|
|
116
|
+
set("resources", mergeContribution(mod.resources, extension.resources));
|
|
117
|
+
set("eventHandlers", mergeContribution(mod.eventHandlers, extension.eventHandlers));
|
|
118
|
+
set("scheduledJobs", mergeContribution(mod.scheduledJobs, extension.scheduledJobs));
|
|
119
|
+
set("workflows", mergeContribution(mod.workflows, extension.workflows));
|
|
120
|
+
set("healthChecks", mergeArray(mod.healthChecks, extension.healthChecks));
|
|
121
|
+
set("errorMappers", mergeArray(mod.errorMappers, extension.errorMappers));
|
|
122
|
+
set("plugins", mergeHook(mod.plugins, extension.plugins));
|
|
123
|
+
set("afterResources", mergeHook(mod.afterResources, extension.afterResources));
|
|
124
|
+
set("onClose", mergeOnClose(mod.onClose, extension.onClose));
|
|
125
|
+
if (extension.bootstrap) out.bootstrap = extension.bootstrap(mod.bootstrap);
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
7
129
|
//#region src/factory/createWorker.ts
|
|
8
130
|
async function createWorker(options, workerOptions = {}) {
|
|
9
131
|
const { auth: _auth, helmet: _helmet, cors: _cors, rateLimit: _rateLimit, multipart: _multipart, rawBody: _rawBody, sensible: _sensible, underPressure: _underPressure, replyHelpers: _replyHelpers, ...runtimeOptions } = options;
|
|
@@ -20,10 +142,11 @@ async function createWorker(options, workerOptions = {}) {
|
|
|
20
142
|
});
|
|
21
143
|
if (workerOptions.health) {
|
|
22
144
|
const { port, host = "0.0.0.0", checks = [] } = workerOptions.health;
|
|
145
|
+
const moduleChecks = app.arc?.healthChecks ?? [];
|
|
23
146
|
const mergedChecks = mergeHealthChecks([
|
|
24
147
|
{
|
|
25
148
|
owner: "the module graph",
|
|
26
|
-
checks:
|
|
149
|
+
checks: moduleChecks
|
|
27
150
|
},
|
|
28
151
|
{
|
|
29
152
|
owner: "shared arcPlugins.health",
|
|
@@ -121,4 +244,4 @@ function payloadTooLarge(limit) {
|
|
|
121
244
|
});
|
|
122
245
|
}
|
|
123
246
|
//#endregion
|
|
124
|
-
export { ArcFactory, collectModuleHealthChecks, collectModuleScheduledJobs, collectModuleWorkflows, createApp, createWorker, defineModule, developmentPreset, edgePreset, getModuleExports, getModuleState, getOptionalModuleExports, getPreset, hasModule, hasModuleExports, lazyModuleExports, lazyRequiredModuleExports, loadResources, orderModules, preloadResources, preloadResourcesAsync, productionPreset, resolveContribution, resolveModule, subscribeModuleEventHandlers, testingPreset, toFetchHandler };
|
|
247
|
+
export { ArcFactory, DEFAULT_LOGGER_REDACT_PATHS, collectModuleHealthChecks, collectModuleScheduledJobs, collectModuleWorkflows, createApp, createWorker, defineModule, describeResolvedModule, developmentPreset, edgePreset, extendModule, getModuleExports, getModuleState, getOptionalModuleExports, getPreset, hasModule, hasModuleExports, lazyModuleExports, lazyRequiredModuleExports, loadResources, orderModules, preloadResources, preloadResourcesAsync, productionPreset, resolveContribution, resolveModule, subscribeModuleEventHandlers, testingPreset, toFetchHandler };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
|
|
2
|
+
import { on as HookSystem, z as ResourceRegistry } from "./index-BcR2bFZQ.mjs";
|
|
3
|
+
import { t as ExternalOpenApiPaths } from "./externalPaths-CmGOxOtD.mjs";
|
|
4
|
+
import { _ as HealthCheck, f as ScheduleDefinition, r as ArcModuleRegistry, t as ArcModule } from "./types-BcTumAz_.mjs";
|
|
5
|
+
import { s as ModuleState } from "./index-C5NnMEKF.mjs";
|
|
6
|
+
import { FastifyPluginAsync } from "fastify";
|
|
7
|
+
//#region src/factory/module/descriptor.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Resolved module introspection — what a module ACTUALLY composed to.
|
|
10
|
+
*
|
|
11
|
+
* `ArcModule` is the authoring shape: `resources` may be an array or a factory,
|
|
12
|
+
* `owns` may be a list or `"provided"`, and neither tells you what the module
|
|
13
|
+
* ended up mounting. Consumers that needed the resolved answer were reduced to
|
|
14
|
+
* inspecting that shape — a downstream conformance suite had to treat every
|
|
15
|
+
* resource FACTORY as a violation, because it could not distinguish "late-bound
|
|
16
|
+
* and legitimate" from "unresolvable", and so rejected valid modules.
|
|
17
|
+
*
|
|
18
|
+
* A descriptor is the resolved, read-only answer, published after arc has done
|
|
19
|
+
* the work exactly once. It lets tooling assert on the real graph without
|
|
20
|
+
* touching arc internals:
|
|
21
|
+
*
|
|
22
|
+
* - conformance suites verify what a module provides and supersedes;
|
|
23
|
+
* - `doctor` surfaces duplicate resources and unmet dependencies;
|
|
24
|
+
* - tests assert the composed graph instead of re-deriving it;
|
|
25
|
+
* - operators inspect a large installation;
|
|
26
|
+
* - documentation generators read one stable contract.
|
|
27
|
+
*
|
|
28
|
+
* Deliberately DATA — no functions, no live handles. It survives
|
|
29
|
+
* `structuredClone`, so it can cross a worker boundary or be written to a file
|
|
30
|
+
* as-is, and holding one cannot keep a closed app alive.
|
|
31
|
+
*/
|
|
32
|
+
/** One resource as arc resolved it. */
|
|
33
|
+
interface ResolvedResourceDescriptor {
|
|
34
|
+
/** Resource name; absent for an anonymous resource (participates in no dedup). */
|
|
35
|
+
readonly name?: string;
|
|
36
|
+
/** Route prefix, when the resource declared one. */
|
|
37
|
+
readonly prefix?: string;
|
|
38
|
+
/** Whether the resource opted out of the app-wide `resourcePrefix`. */
|
|
39
|
+
readonly skipGlobalPrefix: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Lifecycle surface a module ended up with — counts, not handles. */
|
|
42
|
+
interface ResolvedModuleLifecycle {
|
|
43
|
+
/** Does the module tear anything down? */
|
|
44
|
+
readonly hasClose: boolean;
|
|
45
|
+
/** Event-handler subscriptions arc owns for this module. */
|
|
46
|
+
readonly subscriptions: number;
|
|
47
|
+
/** Recurring schedules contributed. */
|
|
48
|
+
readonly scheduledJobs: number;
|
|
49
|
+
/** Readiness checks contributed. */
|
|
50
|
+
readonly healthChecks: number;
|
|
51
|
+
/** Whether the module contributed a public export at `arc.modules[name]`. */
|
|
52
|
+
readonly exports: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** The resolved, read-only description of one composed module. */
|
|
55
|
+
interface ResolvedModuleDescriptor {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
/** Declared composition edges, in the order the module listed them. */
|
|
58
|
+
readonly dependsOn: readonly string[];
|
|
59
|
+
/** Resources this module actually mounted, in registration order. */
|
|
60
|
+
readonly resources: readonly ResolvedResourceDescriptor[];
|
|
61
|
+
/**
|
|
62
|
+
* The EFFECTIVE supersession list — already derived when the module declared
|
|
63
|
+
* `owns: "provided"`, so callers never re-implement that resolution.
|
|
64
|
+
*/
|
|
65
|
+
readonly owns: readonly string[];
|
|
66
|
+
readonly lifecycle: ResolvedModuleLifecycle;
|
|
67
|
+
}
|
|
68
|
+
/** Minimal resource shape the descriptor reads. Structural — matches `ResourceLike`. */
|
|
69
|
+
interface DescribableResource {
|
|
70
|
+
readonly name?: string | undefined;
|
|
71
|
+
readonly prefix?: string | undefined;
|
|
72
|
+
readonly skipGlobalPrefix?: boolean | undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build a descriptor. Called by `registerResources` once per module, after
|
|
76
|
+
* resources are resolved and `owns` is effective.
|
|
77
|
+
*
|
|
78
|
+
* Frozen at every level: a descriptor is a snapshot of a completed decision,
|
|
79
|
+
* and a consumer mutating it would silently disagree with the running app.
|
|
80
|
+
*/
|
|
81
|
+
declare function describeResolvedModule(input: {
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly dependsOn?: readonly string[] | undefined;
|
|
84
|
+
readonly resources: readonly DescribableResource[];
|
|
85
|
+
readonly owns: readonly string[];
|
|
86
|
+
readonly lifecycle: ResolvedModuleLifecycle;
|
|
87
|
+
}): ResolvedModuleDescriptor;
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/core/arcCorePlugin.d.ts
|
|
90
|
+
interface ArcCorePluginOptions {
|
|
91
|
+
/** Enable event emission for CRUD operations (requires eventPlugin) */
|
|
92
|
+
emitEvents?: boolean;
|
|
93
|
+
/** Hook system instance (for testing/custom setup) */
|
|
94
|
+
hookSystem?: HookSystem;
|
|
95
|
+
/** Resource registry instance (for testing/custom setup) */
|
|
96
|
+
registry?: ResourceRegistry;
|
|
97
|
+
}
|
|
98
|
+
interface PluginMeta {
|
|
99
|
+
name: string;
|
|
100
|
+
version?: string;
|
|
101
|
+
options?: Record<string, unknown>;
|
|
102
|
+
registeredAt: string;
|
|
103
|
+
}
|
|
104
|
+
interface ArcCore {
|
|
105
|
+
/** Instance-scoped hook system */
|
|
106
|
+
hooks: HookSystem;
|
|
107
|
+
/** Instance-scoped resource registry */
|
|
108
|
+
registry: ResourceRegistry;
|
|
109
|
+
/** Whether event emission is enabled */
|
|
110
|
+
emitEvents: boolean;
|
|
111
|
+
/** External OpenAPI paths contributed by auth adapters or third-party integrations */
|
|
112
|
+
externalOpenApiPaths: ExternalOpenApiPaths[];
|
|
113
|
+
/** Registered plugins for introspection */
|
|
114
|
+
plugins: Map<string, PluginMeta>;
|
|
115
|
+
/**
|
|
116
|
+
* Module public exports — `bootstrap()` return values keyed by module name
|
|
117
|
+
* (see `src/factory/module.ts`). Read via `getModuleExports(fastify, name)`:
|
|
118
|
+
* augment `ArcModuleRegistry` once and the name infers the export type;
|
|
119
|
+
* otherwise pass it inline. `Partial<ArcModuleRegistry>` gives augmented
|
|
120
|
+
* apps typed direct access (`fastify.arc.modules.order`), while the
|
|
121
|
+
* `Record<string, unknown>` intersection keeps un-augmented reads open.
|
|
122
|
+
* Populated lazily by `registerResources` — absent until a module exports.
|
|
123
|
+
*/
|
|
124
|
+
modules?: Partial<ArcModuleRegistry> & Record<string, unknown>;
|
|
125
|
+
/**
|
|
126
|
+
* Lifecycle state per composed module (null-proto map, populated by
|
|
127
|
+
* `registerResources` the moment the graph is validated — so it answers
|
|
128
|
+
* "is this module composed?" even for resource-only modules that never
|
|
129
|
+
* record an export). Read via `hasModule(fastify, name)` /
|
|
130
|
+
* `getModuleState(fastify, name)`; the map itself is internal.
|
|
131
|
+
*/
|
|
132
|
+
moduleStates?: Record<string, ModuleState>;
|
|
133
|
+
/**
|
|
134
|
+
* Module-contributed readiness checks, collected in dependency order and
|
|
135
|
+
* frozen by `createApp`. The API role merges these into its `healthPlugin`;
|
|
136
|
+
* `createWorker` reads this to give its probe listener the identical union
|
|
137
|
+
* (the worker preset disables the main health plugin, so this is how module
|
|
138
|
+
* checks reach the probe without a double registration). Empty until
|
|
139
|
+
* `createApp` populates it.
|
|
140
|
+
*/
|
|
141
|
+
healthChecks?: readonly HealthCheck[];
|
|
142
|
+
/**
|
|
143
|
+
* The resolved, dependency-ordered module definitions (frozen by createApp).
|
|
144
|
+
* Integrations that collect a module arm at their OWN init time — e.g. the
|
|
145
|
+
* streamline integration calling `collectModuleWorkflows(fastify, defs)` after
|
|
146
|
+
* it has created + decorated its container — read the list from here. Empty
|
|
147
|
+
* until createApp populates it.
|
|
148
|
+
*/
|
|
149
|
+
moduleDefinitions?: readonly ArcModule[];
|
|
150
|
+
/**
|
|
151
|
+
* RESOLVED module descriptors — what each module actually composed to
|
|
152
|
+
* (resources mounted, effective `owns`, lifecycle counts), published once
|
|
153
|
+
* boot has settled them.
|
|
154
|
+
*
|
|
155
|
+
* Read this rather than `moduleDefinitions` for anything that needs the real
|
|
156
|
+
* graph: a definition's `resources` may still be an unresolved factory and
|
|
157
|
+
* its `owns` may be `"provided"`, so the authoring shape cannot answer "what
|
|
158
|
+
* did this module actually mount?". Frozen, plain data — safe to clone, log,
|
|
159
|
+
* or hand to tooling.
|
|
160
|
+
*/
|
|
161
|
+
moduleDescriptors?: readonly ResolvedModuleDescriptor[];
|
|
162
|
+
/**
|
|
163
|
+
* Module-contributed recurring schedules, resolved once in dependency order
|
|
164
|
+
* and frozen after bootstraps. The same definitions are executed by Arc's
|
|
165
|
+
* schedules plugin and exposed here for introspection. Empty until collection.
|
|
166
|
+
*/
|
|
167
|
+
scheduledJobs?: readonly Readonly<ScheduleDefinition>[];
|
|
168
|
+
}
|
|
169
|
+
declare const arcCorePlugin: FastifyPluginAsync<ArcCorePluginOptions>;
|
|
170
|
+
declare const _default: FastifyPluginAsync<ArcCorePluginOptions>;
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/types/fastify-augmentation.d.ts
|
|
173
|
+
declare module "fastify" {
|
|
174
|
+
interface FastifyInstance {
|
|
175
|
+
arc?: ArcCore;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { arcCorePlugin as a, ResolvedResourceDescriptor as c, _default as i, describeResolvedModule as l, ArcCorePluginOptions as n, ResolvedModuleDescriptor as o, PluginMeta as r, ResolvedModuleLifecycle as s, ArcCore as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
|
|
2
2
|
//#region src/permissions/fields.ts
|
|
3
3
|
/**
|
|
4
4
|
* Field-Level Permissions
|
|
@@ -111,10 +111,7 @@ function applyFieldReadPermissions(data, fieldPermissions, userRoles) {
|
|
|
111
111
|
case "visibleTo":
|
|
112
112
|
if (!perm.roles?.some((r) => userRoles.includes(r))) delete result[field];
|
|
113
113
|
break;
|
|
114
|
-
case "redactFor":
|
|
115
|
-
if (perm.roles?.some((r) => userRoles.includes(r))) result[field] = perm.redactValue ?? "***";
|
|
116
|
-
break;
|
|
117
|
-
case "writableBy": break;
|
|
114
|
+
case "redactFor": if (perm.roles?.some((r) => userRoles.includes(r))) result[field] = perm.redactValue ?? "***";
|
|
118
115
|
}
|
|
119
116
|
return result;
|
|
120
117
|
}
|
|
@@ -140,12 +137,10 @@ function applyFieldWritePermissions(body, fieldPermissions, userRoles) {
|
|
|
140
137
|
delete result[field];
|
|
141
138
|
}
|
|
142
139
|
break;
|
|
143
|
-
case "writableBy":
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
break;
|
|
140
|
+
case "writableBy": if (field in result && !perm.roles?.some((r) => userRoles.includes(r))) {
|
|
141
|
+
deniedFields.push(field);
|
|
142
|
+
delete result[field];
|
|
143
|
+
}
|
|
149
144
|
}
|
|
150
145
|
return {
|
|
151
146
|
body: result,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { t as pluralize } from "./pluralize-
|
|
1
|
+
/*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
|
|
2
|
+
import { t as pluralize } from "./pluralize-B7xf8qZF.mjs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
//#region src/cli/commands/generate/name-helpers.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { u as ValidationError } from "./errors-
|
|
1
|
+
/*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
|
|
2
|
+
import { u as ValidationError } from "./errors-Cd_yy7aW.mjs";
|
|
3
3
|
//#region src/utils/headers.ts
|
|
4
4
|
/**
|
|
5
5
|
* Canonical header typing + accessor.
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { an as HookRegistration, cn as afterCreate, dn as beforeCreate, en as DefineHookOptions, fn as beforeDelete, hn as defineHook, in as HookPhase, ln as afterDelete, mn as createHookSystem, nn as HookHandler, on as HookSystem, pn as beforeUpdate, rn as HookOperation, sn as HookSystemOptions, tn as HookContext, un as afterUpdate } from "../index-BcR2bFZQ.mjs";
|
|
3
3
|
export { type DefineHookOptions, type HookContext, type HookHandler, type HookOperation, type HookPhase, type HookRegistration, HookSystem, type HookSystemOptions, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { a as beforeCreate, c as createHookSystem, i as afterUpdate, l as defineHook, n as afterCreate, o as beforeDelete, r as afterDelete, s as beforeUpdate, t as HookSystem } from "../HookSystem-
|
|
1
|
+
/*! @classytic/arc v2.34.0 | MIT | https://classytic.com */
|
|
2
|
+
import { a as beforeCreate, c as createHookSystem, i as afterUpdate, l as defineHook, n as afterCreate, o as beforeDelete, r as afterDelete, s as beforeUpdate, t as HookSystem } from "../HookSystem-DqXkMXkB.mjs";
|
|
3
3
|
export { HookSystem, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
|
|
@@ -47,6 +47,22 @@ interface IdempotencyPluginOptions {
|
|
|
47
47
|
* Omit for the common case where the store is per-deployment.
|
|
48
48
|
*/
|
|
49
49
|
namespace?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Boot-time store self-check (default: true). Writes one probe entry,
|
|
52
|
+
* verifies it reads back under ITS OWN key and NOT under a different key,
|
|
53
|
+
* then deletes it. Registration THROWS if the store fails — because the
|
|
54
|
+
* failure mode this catches is silent and catastrophic: a repository
|
|
55
|
+
* whose schema strips the key filter (observed live: a pathless Mongoose
|
|
56
|
+
* schema under `strictQuery: true`) collapses every idempotency key onto
|
|
57
|
+
* one shared row, and every request then replays the most recent cached
|
|
58
|
+
* response across keys AND across users. A store that cannot round-trip
|
|
59
|
+
* a key must never be allowed to serve traffic.
|
|
60
|
+
*
|
|
61
|
+
* Disable only for a store that genuinely cannot accept a probe write at
|
|
62
|
+
* boot — and if you disable it, the adapter's per-read identity checks
|
|
63
|
+
* remain as the runtime backstop.
|
|
64
|
+
*/
|
|
65
|
+
selfCheck?: boolean;
|
|
50
66
|
}
|
|
51
67
|
declare module "fastify" {
|
|
52
68
|
interface FastifyRequest {
|
|
@@ -92,6 +108,34 @@ declare const idempotencyPlugin: FastifyPluginAsync<IdempotencyPluginOptions>;
|
|
|
92
108
|
declare const _default: FastifyPluginAsync<IdempotencyPluginOptions>;
|
|
93
109
|
//#endregion
|
|
94
110
|
//#region src/idempotency/repository-idempotency-adapter.d.ts
|
|
111
|
+
/**
|
|
112
|
+
* The backing repository returned a document whose key does not match the
|
|
113
|
+
* key that was asked for — which means the repository is NOT applying the
|
|
114
|
+
* key filter. Concretely observed (2026-08-14, be-prod): a Mongoose schema
|
|
115
|
+
* with no declared paths (`new Schema({}, { _id: false })`) under a global
|
|
116
|
+
* `mongoose.set('strictQuery', true)` strips EVERY filter key as an
|
|
117
|
+
* "unknown path", so `getOne({ _id: key })` becomes `getOne({})` — one
|
|
118
|
+
* shared document then absorbs every idempotency key, and every request
|
|
119
|
+
* replays the most recent cached response ACROSS KEYS AND ACROSS USERS
|
|
120
|
+
* (a cancel response for order A was served as "success" for order B,
|
|
121
|
+
* which was never actually canceled).
|
|
122
|
+
*
|
|
123
|
+
* That failure mode is silent by construction — every read "succeeds" with
|
|
124
|
+
* a plausible document — so the adapter verifies the identity of every
|
|
125
|
+
* document it gets back and THROWS this instead of trusting it. Returning
|
|
126
|
+
* `undefined` (treat as miss) would be worse, not safer: the very next
|
|
127
|
+
* `tryLock`/`set` on the same broken repository would corrupt the shared
|
|
128
|
+
* document again.
|
|
129
|
+
*
|
|
130
|
+
* Fix on the host side: declare the key path on the schema (e.g.
|
|
131
|
+
* `_id: String`) and/or set `strictQuery: false` in the SCHEMA options so
|
|
132
|
+
* filters on it are never stripped — see `idempotencyPlugin`'s
|
|
133
|
+
* `repository` option docs.
|
|
134
|
+
*/
|
|
135
|
+
declare class IdempotencyStoreMisconfiguredError extends Error {
|
|
136
|
+
readonly code = "IDEMPOTENCY_STORE_MISCONFIGURED";
|
|
137
|
+
constructor(operation: string, expectedKey: string, actualKey: unknown);
|
|
138
|
+
}
|
|
95
139
|
declare function repositoryAsIdempotencyStore(repository: RepositoryLike, defaultTtlMs: number): IdempotencyStore;
|
|
96
140
|
//#endregion
|
|
97
141
|
//#region src/idempotency/stores/memory.d.ts
|
|
@@ -129,4 +173,4 @@ declare class MemoryIdempotencyStore implements IdempotencyStore {
|
|
|
129
173
|
private evictOldest;
|
|
130
174
|
}
|
|
131
175
|
//#endregion
|
|
132
|
-
export { type IdempotencyLock, type IdempotencyPluginOptions, type IdempotencyResult, type IdempotencyStore, MemoryIdempotencyStore, type MemoryIdempotencyStoreOptions, type RedisClient, type RedisIdempotencyStoreOptions, createIdempotencyResult, _default as idempotencyPlugin, idempotencyPlugin as idempotencyPluginFn, repositoryAsIdempotencyStore };
|
|
176
|
+
export { type IdempotencyLock, type IdempotencyPluginOptions, type IdempotencyResult, type IdempotencyStore, IdempotencyStoreMisconfiguredError, MemoryIdempotencyStore, type MemoryIdempotencyStoreOptions, type RedisClient, type RedisIdempotencyStoreOptions, createIdempotencyResult, _default as idempotencyPlugin, idempotencyPlugin as idempotencyPluginFn, repositoryAsIdempotencyStore };
|