@classytic/arc 2.23.0 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BaseController-BQ8KNvWC.mjs → BaseController--M8EMzt0.mjs} +90 -21
- package/dist/QueryCache-DOMT_iq7.d.mts +72 -0
- package/dist/actionPermissions-CAphcmUG.mjs +24 -0
- package/dist/audit/index.d.mts +32 -3
- package/dist/audit/index.mjs +7 -4
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.mjs +263 -259
- package/dist/{buildHandler-D_2ULWxZ.mjs → buildHandler-Dtwd8fdz.mjs} +1 -1
- package/dist/cache/index.d.mts +41 -3
- package/dist/cache/index.mjs +33 -4
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/docs.mjs +1 -1
- package/dist/cli/commands/generate.mjs +1 -1
- package/dist/cli/commands/init.mjs +1 -1
- package/dist/cli/index.mjs +2 -2
- package/dist/context/index.mjs +2 -64
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +4 -4
- package/dist/{core-DQ6rDTyH.mjs → core-EUNu0u07.mjs} +296 -11
- package/dist/{createActionRouter-BuOv-m4Y.mjs → createActionRouter-B6GvAuAX.mjs} +3 -2
- package/dist/{createAggregationRouter-CgJv_BU_.mjs → createAggregationRouter-wzwFa_dW.mjs} +3 -3
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +2 -2
- package/dist/{elevation-COpYKt2h.mjs → elevation-CIz1GjGm.mjs} +4 -3
- package/dist/{eventPlugin-A6EbthXR.d.mts → eventPlugin-Bg3cP2_u.d.mts} +38 -3
- package/dist/{eventPlugin-DJG2D7sy.mjs → eventPlugin-DrQ_FesK.mjs} +22 -4
- package/dist/events/index.d.mts +57 -314
- package/dist/events/index.mjs +163 -91
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +24 -2
- package/dist/factory/index.d.mts +4 -5
- package/dist/factory/index.mjs +28 -8
- package/dist/{fastify-augmentation-g_f9omSc.d.mts → fastify-augmentation-dPNBVeIj.d.mts} +25 -2
- package/dist/{generate-usRSdQmP.mjs → generate-D0wZupBg.mjs} +1 -1
- package/dist/headers-BvlQSDMB.mjs +45 -0
- package/dist/health-CB_m4S32.mjs +377 -0
- package/dist/hooks/index.d.mts +1 -1
- package/dist/idempotency/index.mjs +27 -3
- package/dist/{index-wMoWBLkn.d.mts → index-BMnbzvtO.d.mts} +3 -3
- package/dist/{integrations/jobs.d.mts → index-CG4yqMDB.d.mts} +82 -2
- package/dist/{index-BBsvQt7U.d.mts → index-DPRH0Cme.d.mts} +36 -106
- package/dist/{module-B4u10iOJ.d.mts → index-KUoxjIq1.d.mts} +263 -23
- package/dist/{index-CC5ruDGh.d.mts → index-f4PTrk3B.d.mts} +37 -5
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/{init-CjO4p_q1.mjs → init-tlRSt667.mjs} +206 -208
- package/dist/integrations/event-gateway.d.mts +1 -1
- package/dist/integrations/event-gateway.mjs +1 -1
- package/dist/integrations/index.d.mts +3 -3
- package/dist/integrations/jobs/index.d.mts +2 -0
- package/dist/integrations/{jobs.mjs → jobs/index.mjs} +110 -67
- package/dist/integrations/mcp/index.d.mts +4 -4
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +1 -1
- package/dist/integrations/webhooks.d.mts +37 -30
- package/dist/integrations/webhooks.mjs +51 -62
- package/dist/integrations/websocket-redis.d.mts +1 -1
- package/dist/integrations/websocket.d.mts +1 -1
- package/dist/integrations/websocket.mjs +41 -14
- package/dist/{interface-C1_WLTMK.d.mts → interface-BGZCzOGL.d.mts} +24 -31
- package/dist/{mcpPlugin-BtzIL_kM.mjs → mcpPlugin-Cb7olw0j.mjs} +11 -9
- package/dist/{memory-CLXA2VeJ.mjs → memory-CmnzXE5Z.mjs} +29 -0
- package/dist/middleware/index.d.mts +17 -1
- package/dist/middleware/index.mjs +1 -1
- package/dist/migrations/index.d.mts +94 -44
- package/dist/migrations/index.mjs +196 -44
- package/dist/{multipartBody-CHEQSZ6G.mjs → multipartBody-D0eBvkeq.mjs} +17 -0
- package/dist/{openapi-jSDx-VDv.mjs → openapi-DrLtog_B.mjs} +3 -3
- package/dist/permissions/index.d.mts +2 -2
- package/dist/permissions/index.mjs +2 -2
- package/dist/{permissions-tbxFHxjZ.mjs → permissions-BrtiBKGs.mjs} +229 -229
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/{actionPermissions-lszoJle1.mjs → pipeline-BN5G05rd.mjs} +3 -26
- package/dist/plugins/index.d.mts +6 -77
- package/dist/plugins/index.mjs +11 -95
- package/dist/plugins/response-cache.mjs +1 -0
- package/dist/plugins/tracing-entry.mjs +1 -1
- package/dist/{index-Ba10fdKp.d.mts → preloadResources-0oe-JSSS.d.mts} +50 -50
- package/dist/{createApp-CjOeWJ9_.mjs → preloadResources-DfyngIN9.mjs} +233 -70
- package/dist/presets/filesUpload.d.mts +3 -3
- package/dist/presets/filesUpload.mjs +3 -3
- package/dist/presets/index.d.mts +2 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +1 -1
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +1 -1
- package/dist/{presets-BOe4Ugkl.mjs → presets-DwFDVKP0.mjs} +2 -2
- package/dist/{queryCachePlugin-DzqLN904.mjs → queryCachePlugin-DSGuSVLW.mjs} +39 -8
- package/dist/{queryCachePlugin-CfYWq-Ak.d.mts → queryCachePlugin-br4otiqF.d.mts} +2 -2
- package/dist/{registerRoute-CWO6mdYe.mjs → rateLimit-DrED-C4v.mjs} +2 -109
- package/dist/{realtime-I8OrfnMR.mjs → realtime-Cuw_deA-.mjs} +2 -2
- package/dist/{redis-stream-iVR2l7aS.d.mts → redis-stream-uIaauNpZ.d.mts} +22 -0
- package/dist/registerRoute-v0Wb6Plt.mjs +108 -0
- package/dist/registry/index.d.mts +2 -2
- package/dist/renewingLease-3cuQH7h8.mjs +44 -0
- package/dist/{requestContext-BZKOr13H.mjs → requestContext-MrlJwECf.mjs} +2 -2
- package/dist/schedules-CjOd2MG9.mjs +113 -0
- package/dist/schemas/index.d.mts +67 -67
- package/dist/schemas/index.mjs +2 -3
- package/dist/scim/index.mjs +1 -2
- package/dist/scope/index.d.mts +2 -2
- package/dist/scope/index.mjs +4 -4
- package/dist/{scope-LONQ3mfZ.mjs → scope-DfaPntpo.mjs} +4 -5
- package/dist/{sse-0u4P4-OI.mjs → sse-BQ1w0dfl.mjs} +1 -1
- package/dist/testing/index.d.mts +4 -3
- package/dist/testing/index.mjs +2 -2
- package/dist/transactionContext-PNdoyLLm.mjs +64 -0
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-bHblZ9YN.mjs → types-CSyCxl2V.mjs} +38 -7
- package/dist/{types-DH0GupI7.d.mts → types-DjC-KUCz.d.mts} +118 -20
- package/dist/{types-Csxga7d3.d.mts → types-Dmw-6Qeo.d.mts} +96 -4
- package/dist/{types-5OuqeTDX.d.mts → types-QFGc3Cjv.d.mts} +1 -1
- package/dist/usage/index.d.mts +3 -52
- package/dist/usage/index.mjs +0 -0
- package/dist/userHelpers-Cg_y3fBz.mjs +29 -0
- package/dist/utils/index.d.mts +58 -85
- package/dist/utils/index.mjs +4 -2
- package/dist/{utils-CZyeRXTh.mjs → utils-taUVD4p3.mjs} +47 -337
- package/dist/{validate-C2mGgSXg.mjs → validate-Bk44F2yT.mjs} +1 -1
- package/dist/{versioning-D6PvCwpq.d.mts → versioning-DXgY5BUm.d.mts} +11 -29
- package/dist/{versioning-Dk-71iIz.mjs → versioning-gKWyryT3.mjs} +8 -1
- package/dist/{websocket-uuWqM6UY.d.mts → websocket-_Pd0CgR0.d.mts} +15 -1
- package/package.json +526 -513
- package/skills/arc/references/api-reference.md +3 -1
- package/skills/arc/references/integrations.md +20 -11
- package/dist/QueryCache-Z1B38koh.d.mts +0 -40
- package/dist/betterAuthOpenApi-CV1lxpRX.mjs +0 -2
- package/dist/health-ScyjIVo5.mjs +0 -202
- package/dist/requestId-5BhTVzBv.mjs +0 -113
- package/dist/types-XTApa8b6.mjs +0 -24
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { p as MUTATION_OPERATIONS } from "../constants-DNre0wRg.mjs";
|
|
2
|
-
import { c as getOrgId } from "../types-
|
|
3
|
-
import { n as requestContext } from "../requestContext-
|
|
2
|
+
import { c as getOrgId } from "../types-CSyCxl2V.mjs";
|
|
3
|
+
import { n as requestContext } from "../requestContext-MrlJwECf.mjs";
|
|
4
4
|
import { t as hasEvents } from "../typeGuards-C9KXUly6.mjs";
|
|
5
5
|
import { t as HookSystem } from "../HookSystem-C1vB_Gc9.mjs";
|
|
6
6
|
import { t as ResourceRegistry } from "../ResourceRegistry-y9Hnypus.mjs";
|
|
7
|
-
import { i as
|
|
8
|
-
import { n as health_default, t as healthPlugin } from "../health-ScyjIVo5.mjs";
|
|
7
|
+
import { a as requestIdPlugin, i as createRequestIdGenerator, n as health_default, o as requestId_default, s as sanitizeRequestId, t as healthPlugin } from "../health-CB_m4S32.mjs";
|
|
9
8
|
import { n as caching_default, t as cachingPlugin } from "../caching-_NJeDd1_.mjs";
|
|
10
9
|
import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-Bq2OeEQL.mjs";
|
|
11
10
|
import { n as metrics_default, t as metricsPlugin } from "../metrics-fdxI5mn_.mjs";
|
|
12
|
-
import { n as realtime_default, t as realtimePlugin } from "../realtime-
|
|
11
|
+
import { n as realtime_default, t as realtimePlugin } from "../realtime-Cuw_deA-.mjs";
|
|
13
12
|
import { t as replyHelpersPlugin } from "../replyHelpers-67tRawQZ.mjs";
|
|
14
|
-
import { n as
|
|
15
|
-
import { n as
|
|
13
|
+
import { n as schedules_default, t as schedulesPlugin } from "../schedules-CjOd2MG9.mjs";
|
|
14
|
+
import { n as sse_default, t as ssePlugin } from "../sse-BQ1w0dfl.mjs";
|
|
15
|
+
import { n as versioning_default, t as versioningPlugin } from "../versioning-gKWyryT3.mjs";
|
|
16
16
|
import fp from "fastify-plugin";
|
|
17
17
|
//#region src/core/arcCorePlugin.ts
|
|
18
18
|
const arcCorePlugin = async (fastify, opts = {}) => {
|
|
@@ -24,7 +24,10 @@ const arcCorePlugin = async (fastify, opts = {}) => {
|
|
|
24
24
|
registry: actualRegistry,
|
|
25
25
|
emitEvents,
|
|
26
26
|
externalOpenApiPaths: [],
|
|
27
|
-
plugins: /* @__PURE__ */ new Map()
|
|
27
|
+
plugins: /* @__PURE__ */ new Map(),
|
|
28
|
+
healthChecks: [],
|
|
29
|
+
moduleDefinitions: [],
|
|
30
|
+
scheduledJobs: []
|
|
28
31
|
});
|
|
29
32
|
for (const field of [
|
|
30
33
|
"_policyFilters",
|
|
@@ -201,91 +204,4 @@ var gracefulShutdown_default = fp(gracefulShutdownPlugin, {
|
|
|
201
204
|
fastify: "5.x"
|
|
202
205
|
});
|
|
203
206
|
//#endregion
|
|
204
|
-
//#region src/plugins/schedules.ts
|
|
205
|
-
const MIN_SAFE_INTERVAL_MS = 1e3;
|
|
206
|
-
const MAX_DEFAULT_LEASE_MS = 3e5;
|
|
207
|
-
const schedulesPlugin = async (fastify, opts) => {
|
|
208
|
-
const { schedules, lock, enabled = true } = opts;
|
|
209
|
-
const holderId = opts.holderId ?? `arc-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
|
|
210
|
-
const stats = /* @__PURE__ */ new Map();
|
|
211
|
-
fastify.decorate("getScheduleStats", () => [...stats.values()].map((s) => ({ ...s })));
|
|
212
|
-
if (!enabled) {
|
|
213
|
-
fastify.log.debug("schedulesPlugin disabled — registered as no-op");
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const seen = /* @__PURE__ */ new Set();
|
|
217
|
-
for (const s of schedules) {
|
|
218
|
-
if (!s.name) throw new TypeError("[arc-schedules] every schedule needs a name");
|
|
219
|
-
if (seen.has(s.name)) throw new TypeError(`[arc-schedules] duplicate schedule name "${s.name}"`);
|
|
220
|
-
seen.add(s.name);
|
|
221
|
-
if (!Number.isFinite(s.every) || s.every <= 0) throw new TypeError(`[arc-schedules] "${s.name}": \`every\` must be a positive number of ms`);
|
|
222
|
-
if (s.every < MIN_SAFE_INTERVAL_MS) fastify.log.warn(`[arc-schedules] "${s.name}" runs every ${s.every}ms — sub-second schedules are almost always a bug in production (DB pressure, lock churn). Intended for tests only.`);
|
|
223
|
-
}
|
|
224
|
-
const timers = /* @__PURE__ */ new Map();
|
|
225
|
-
const inFlight = /* @__PURE__ */ new Map();
|
|
226
|
-
let closing = false;
|
|
227
|
-
async function tick(s) {
|
|
228
|
-
const stat = stats.get(s.name);
|
|
229
|
-
if (!stat) return;
|
|
230
|
-
try {
|
|
231
|
-
if (lock) {
|
|
232
|
-
const leaseMs = s.leaseMs ?? Math.min(Math.floor(s.every * .9), MAX_DEFAULT_LEASE_MS);
|
|
233
|
-
if (!await lock.tryAcquire(`arc:schedule:${s.name}`, holderId, leaseMs)) {
|
|
234
|
-
stat.skippedByLock++;
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
stat.runs++;
|
|
239
|
-
stat.lastRunAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
240
|
-
await s.handler(fastify);
|
|
241
|
-
stat.lastError = null;
|
|
242
|
-
} catch (err) {
|
|
243
|
-
stat.failures++;
|
|
244
|
-
stat.lastError = err instanceof Error ? err.message : String(err);
|
|
245
|
-
fastify.log.error({
|
|
246
|
-
err,
|
|
247
|
-
schedule: s.name
|
|
248
|
-
}, "[arc-schedules] schedule run failed");
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function scheduleNext(s, delay) {
|
|
252
|
-
if (closing) return;
|
|
253
|
-
const timer = setTimeout(() => {
|
|
254
|
-
const run = tick(s).finally(() => {
|
|
255
|
-
inFlight.delete(s.name);
|
|
256
|
-
scheduleNext(s, s.every);
|
|
257
|
-
});
|
|
258
|
-
inFlight.set(s.name, run);
|
|
259
|
-
}, delay);
|
|
260
|
-
timer.unref?.();
|
|
261
|
-
timers.set(s.name, timer);
|
|
262
|
-
}
|
|
263
|
-
fastify.addHook("onReady", async () => {
|
|
264
|
-
for (const s of schedules) {
|
|
265
|
-
if (s.enabled === false) continue;
|
|
266
|
-
stats.set(s.name, {
|
|
267
|
-
name: s.name,
|
|
268
|
-
runs: 0,
|
|
269
|
-
failures: 0,
|
|
270
|
-
skippedByLock: 0,
|
|
271
|
-
lastRunAt: null,
|
|
272
|
-
lastError: null
|
|
273
|
-
});
|
|
274
|
-
const jitter = !s.runOnStart && s.jitterMs ? Math.floor(Math.random() * s.jitterMs) : 0;
|
|
275
|
-
scheduleNext(s, s.runOnStart ? 0 : s.every + jitter);
|
|
276
|
-
}
|
|
277
|
-
if (stats.size > 0) fastify.log.debug(`[arc-schedules] ${stats.size} schedule(s) armed${lock ? ` (leader-safe, holder ${holderId})` : ""}`);
|
|
278
|
-
});
|
|
279
|
-
fastify.addHook("onClose", async () => {
|
|
280
|
-
closing = true;
|
|
281
|
-
for (const timer of timers.values()) clearTimeout(timer);
|
|
282
|
-
timers.clear();
|
|
283
|
-
await Promise.allSettled([...inFlight.values()]);
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
var schedules_default = fp(schedulesPlugin, {
|
|
287
|
-
name: "arc-schedules",
|
|
288
|
-
fastify: "5.x"
|
|
289
|
-
});
|
|
290
|
-
//#endregion
|
|
291
207
|
export { arcCorePlugin_default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, caching_default as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, gracefulShutdown_default as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, health_default as healthPlugin, healthPlugin as healthPluginFn, metrics_default as metricsPlugin, metricsPlugin as metricsPluginFn, realtime_default as realtimePlugin, realtimePlugin as realtimePluginFn, replyHelpersPlugin, requestId_default as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sanitizeRequestId, schedules_default as schedulesPlugin, schedulesPlugin as schedulesPluginFn, sse_default as ssePlugin, ssePlugin as ssePluginFn, versioning_default as versioningPlugin, versioningPlugin as versioningPluginFn };
|
|
@@ -92,6 +92,7 @@ const responseCachePluginImpl = async (fastify, opts = {}) => {
|
|
|
92
92
|
"PATCH",
|
|
93
93
|
"DELETE"
|
|
94
94
|
], xCacheHeader = true, statsPath = null, keyFn } = opts;
|
|
95
|
+
if (maxEntries > 5e3) fastify.log.warn(`[arc] responseCache maxEntries=${maxEntries}: prefix invalidation scans all entries synchronously on every mutating request — expect event-loop pauses at this size. This cache is an instance-local micro-cache; for large shared caching use the queryCache with a Redis store instead.`);
|
|
95
96
|
const cache = new LRUCache(maxEntries);
|
|
96
97
|
const invalidateMethods = new Set(invalidateOn.map((m) => m.toUpperCase()));
|
|
97
98
|
if (!fastify.hasRequestDecorator("__arcCacheTTL")) fastify.decorateRequest("__arcCacheTTL", void 0);
|
|
@@ -58,7 +58,7 @@ try {
|
|
|
58
58
|
function createTracerProvider(options) {
|
|
59
59
|
if (!isAvailable || !NodeTracerProvider || !BatchSpanProcessor || !OTLPTraceExporter) return null;
|
|
60
60
|
const { serviceName = "@classytic/arc", serviceVersion, exporterUrl = "http://localhost:4318/v1/traces" } = options;
|
|
61
|
-
const resolvedVersion = serviceVersion ?? "2.
|
|
61
|
+
const resolvedVersion = serviceVersion ?? "2.25.0";
|
|
62
62
|
const exporter = new OTLPTraceExporter({ url: exporterUrl });
|
|
63
63
|
const provider = new NodeTracerProvider({ resource: { attributes: {
|
|
64
64
|
"service.name": serviceName,
|
|
@@ -1,38 +1,15 @@
|
|
|
1
|
-
import { Wt as Authenticator } from "./index-
|
|
2
|
-
import { r as CacheStore } from "./interface-
|
|
1
|
+
import { Wt as Authenticator } from "./index-DPRH0Cme.mjs";
|
|
2
|
+
import { r as CacheStore } from "./interface-BGZCzOGL.mjs";
|
|
3
3
|
import { n as ElevationOptions } from "./elevation-C9s5hFP_.mjs";
|
|
4
4
|
import { a as EventTransport } from "./EventTransport-QmY7A258.mjs";
|
|
5
5
|
import { t as ExternalOpenApiPaths } from "./externalPaths-BE6wFpYv.mjs";
|
|
6
|
-
import { r as QueryCachePluginOptions } from "./queryCachePlugin-
|
|
6
|
+
import { r as QueryCachePluginOptions } from "./queryCachePlugin-br4otiqF.mjs";
|
|
7
7
|
import { t as ErrorHandlerOptions } from "./errorHandler-C6yv4ZTW.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { t as EventPluginOptions } from "./eventPlugin-
|
|
10
|
-
import { g as CachingOptions, o as MetricsOptions, p as SSEOptions, t as VersioningOptions, u as RealtimeOptions
|
|
8
|
+
import { T as HealthOptions, d as ArcModuleInput, g as ResourceLike, x as SchedulesPluginOptions } from "./index-KUoxjIq1.mjs";
|
|
9
|
+
import { t as EventPluginOptions } from "./eventPlugin-Bg3cP2_u.mjs";
|
|
10
|
+
import { g as CachingOptions, o as MetricsOptions, p as SSEOptions, t as VersioningOptions, u as RealtimeOptions } from "./versioning-DXgY5BUm.mjs";
|
|
11
11
|
import { r as IdempotencyStore } from "./interface-Uk8ONJv7.mjs";
|
|
12
12
|
import { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, FastifyServerOptions } from "fastify";
|
|
13
|
-
//#region src/testing/preloadResources.d.ts
|
|
14
|
-
/** Eager glob result: `{ '/path/to/file.ts': resourceModule }` */
|
|
15
|
-
type EagerGlobResult = Record<string, unknown>;
|
|
16
|
-
/** Lazy glob result: `{ '/path/to/file.ts': () => Promise<unknown> }` */
|
|
17
|
-
type LazyGlobResult = Record<string, () => Promise<unknown>>;
|
|
18
|
-
/**
|
|
19
|
-
* Normalize an eager `import.meta.glob` result into a `ResourceLike[]`.
|
|
20
|
-
*
|
|
21
|
-
* Accepts either:
|
|
22
|
-
* - `{ import: 'default' }` form: values are the resource directly
|
|
23
|
-
* - default form: values are the full module — picks first export with `toPlugin()`
|
|
24
|
-
*
|
|
25
|
-
* Throws if any module doesn't yield a valid `ResourceLike`.
|
|
26
|
-
*/
|
|
27
|
-
declare function preloadResources(globResult: EagerGlobResult): ResourceLike[];
|
|
28
|
-
/**
|
|
29
|
-
* Normalize a lazy `import.meta.glob` result into a `Promise<ResourceLike[]>`.
|
|
30
|
-
*
|
|
31
|
-
* Use this when resources depend on prior bootstrap (e.g., engine init) and
|
|
32
|
-
* cannot be evaluated at import time of the preload file.
|
|
33
|
-
*/
|
|
34
|
-
declare function preloadResourcesAsync(globResult: LazyGlobResult): Promise<ResourceLike[]>;
|
|
35
|
-
//#endregion
|
|
36
13
|
//#region src/factory/types/auth.d.ts
|
|
37
14
|
/**
|
|
38
15
|
* Arc's built-in JWT auth
|
|
@@ -238,6 +215,8 @@ interface UnderPressureOptions {
|
|
|
238
215
|
exposeStatusRoute?: boolean;
|
|
239
216
|
/** Event loop lag threshold in ms — requests rejected above this (default: 1000) */
|
|
240
217
|
maxEventLoopDelay?: number;
|
|
218
|
+
/** Event loop utilization threshold (0–1) — requests rejected above this */
|
|
219
|
+
maxEventLoopUtilization?: number;
|
|
241
220
|
/** V8 heap usage threshold in bytes — requests rejected above this */
|
|
242
221
|
maxHeapUsedBytes?: number;
|
|
243
222
|
/** RSS memory threshold in bytes — requests rejected above this */
|
|
@@ -445,6 +424,12 @@ interface CreateAppOptions {
|
|
|
445
424
|
* - `'10.0.0.0/8'` / `['10.0.0.0/8', '172.16.0.0/12']` — trust only these
|
|
446
425
|
* CIDR ranges
|
|
447
426
|
*
|
|
427
|
+
* Default: `false` everywhere, including `preset: 'production'` (2.24
|
|
428
|
+
* flip — fail-closed; the preset previously trusted every proxy). Apps
|
|
429
|
+
* behind a proxy/LB must set this explicitly or `request.ip` is the
|
|
430
|
+
* proxy's address; a boot warning fires when the production preset's
|
|
431
|
+
* default is inherited without an explicit choice.
|
|
432
|
+
*
|
|
448
433
|
* @example
|
|
449
434
|
* ```ts
|
|
450
435
|
* createApp({ preset: 'production', trustProxy: 1 }); // one LB hop
|
|
@@ -661,6 +646,18 @@ interface CreateAppOptions {
|
|
|
661
646
|
* ```
|
|
662
647
|
*/
|
|
663
648
|
events?: Omit<EventPluginOptions, "transport"> | boolean;
|
|
649
|
+
/**
|
|
650
|
+
* Runtime options for module-contributed `scheduledJobs`. Module schedules
|
|
651
|
+
* automatically use Arc's existing schedules plugin. Pass lock/holder
|
|
652
|
+
* options for multi-replica safety, `true` for single-instance defaults,
|
|
653
|
+
* or `false` to reject any module that declares schedules.
|
|
654
|
+
*
|
|
655
|
+
* `enabled: false` registers the scheduler as a NO-OP — the host's runtime
|
|
656
|
+
* kill switch (e.g. an ops instance that must run zero background work
|
|
657
|
+
* against a shared DB). Unlike `schedules: false`, it does NOT reject
|
|
658
|
+
* modules that declare schedules; they are collected but never armed.
|
|
659
|
+
*/
|
|
660
|
+
schedules?: Omit<SchedulesPluginOptions, "schedules"> | boolean;
|
|
664
661
|
/**
|
|
665
662
|
* Caching headers (ETag + Cache-Control). Default: false (opt-in).
|
|
666
663
|
* Set to true for defaults, or pass CachingOptions for fine control.
|
|
@@ -698,26 +695,6 @@ interface CreateAppOptions {
|
|
|
698
695
|
*/
|
|
699
696
|
versioning?: VersioningOptions;
|
|
700
697
|
};
|
|
701
|
-
/**
|
|
702
|
-
* Type provider for schema inference.
|
|
703
|
-
*
|
|
704
|
-
* When set to `'typebox'`, enables TypeBox type provider for
|
|
705
|
-
* automatic TypeScript inference from route schemas.
|
|
706
|
-
*
|
|
707
|
-
* Requires `@sinclair/typebox` and `@fastify/type-provider-typebox` installed.
|
|
708
|
-
*
|
|
709
|
-
* @example
|
|
710
|
-
* ```typescript
|
|
711
|
-
* import { Type } from '@classytic/arc/schemas';
|
|
712
|
-
*
|
|
713
|
-
* const app = await createApp({
|
|
714
|
-
* typeProvider: 'typebox',
|
|
715
|
-
* });
|
|
716
|
-
*
|
|
717
|
-
* // Now route schemas built with Type.* give full TS inference
|
|
718
|
-
* ```
|
|
719
|
-
*/
|
|
720
|
-
typeProvider?: "typebox";
|
|
721
698
|
/**
|
|
722
699
|
* Error handler plugin. Normalizes AJV, Mongoose, and ArcError responses
|
|
723
700
|
* into a consistent JSON envelope. Enabled by default.
|
|
@@ -1092,4 +1069,27 @@ interface CreateAppOptions {
|
|
|
1092
1069
|
onClose?: (fastify: FastifyInstance) => void | Promise<void>;
|
|
1093
1070
|
}
|
|
1094
1071
|
//#endregion
|
|
1095
|
-
|
|
1072
|
+
//#region src/factory/preloadResources.d.ts
|
|
1073
|
+
/** Eager glob result: `{ '/path/to/file.ts': resourceModule }` */
|
|
1074
|
+
type EagerGlobResult = Record<string, unknown>;
|
|
1075
|
+
/** Lazy glob result: `{ '/path/to/file.ts': () => Promise<unknown> }` */
|
|
1076
|
+
type LazyGlobResult = Record<string, () => Promise<unknown>>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Normalize an eager `import.meta.glob` result into a `ResourceLike[]`.
|
|
1079
|
+
*
|
|
1080
|
+
* Accepts either:
|
|
1081
|
+
* - `{ import: 'default' }` form: values are the resource directly
|
|
1082
|
+
* - default form: values are the full module — picks first export with `toPlugin()`
|
|
1083
|
+
*
|
|
1084
|
+
* Throws if any module doesn't yield a valid `ResourceLike`.
|
|
1085
|
+
*/
|
|
1086
|
+
declare function preloadResources(globResult: EagerGlobResult): ResourceLike[];
|
|
1087
|
+
/**
|
|
1088
|
+
* Normalize a lazy `import.meta.glob` result into a `Promise<ResourceLike[]>`.
|
|
1089
|
+
*
|
|
1090
|
+
* Use this when resources depend on prior bootstrap (e.g., engine init) and
|
|
1091
|
+
* cannot be evaluated at import time of the preload file.
|
|
1092
|
+
*/
|
|
1093
|
+
declare function preloadResourcesAsync(globResult: LazyGlobResult): Promise<ResourceLike[]>;
|
|
1094
|
+
//#endregion
|
|
1095
|
+
export { RawBodyOptions as a, BetterAuthOption as c, JwtAuthOption as d, MultipartOptions as i, CustomAuthenticatorOption as l, preloadResourcesAsync as n, UnderPressureOptions as o, CreateAppOptions as r, AuthOption as s, preloadResources as t, CustomPluginAuthOption as u };
|