@classytic/arc 2.22.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.
Files changed (147) hide show
  1. package/dist/{BaseController-C6FlRWxF.mjs → BaseController--M8EMzt0.mjs} +92 -22
  2. package/dist/QueryCache-DOMT_iq7.d.mts +72 -0
  3. package/dist/{ResourceRegistry-7RnrEWNP.mjs → ResourceRegistry-y9Hnypus.mjs} +1 -0
  4. package/dist/actionPermissions-CAphcmUG.mjs +24 -0
  5. package/dist/applyPermissionResult-Tw4iXtlf.mjs +264 -0
  6. package/dist/audit/index.d.mts +32 -3
  7. package/dist/audit/index.mjs +7 -4
  8. package/dist/auth/index.d.mts +2 -2
  9. package/dist/auth/index.mjs +264 -260
  10. package/dist/{buildHandler-D_2ULWxZ.mjs → buildHandler-Dtwd8fdz.mjs} +1 -1
  11. package/dist/cache/index.d.mts +41 -3
  12. package/dist/cache/index.mjs +33 -4
  13. package/dist/cli/commands/describe.d.mts +1 -1
  14. package/dist/cli/commands/describe.mjs +1 -1
  15. package/dist/cli/commands/docs.mjs +2 -2
  16. package/dist/cli/commands/generate.mjs +1 -1
  17. package/dist/cli/commands/init.mjs +1 -1
  18. package/dist/cli/commands/introspect.mjs +1 -1
  19. package/dist/cli/index.mjs +2 -2
  20. package/dist/context/index.mjs +2 -64
  21. package/dist/core/index.d.mts +3 -3
  22. package/dist/core/index.mjs +4 -4
  23. package/dist/{core-b6fgFgnd.mjs → core-EUNu0u07.mjs} +298 -12
  24. package/dist/{createActionRouter-h1cEEaEX.mjs → createActionRouter-B6GvAuAX.mjs} +4 -3
  25. package/dist/{createAggregationRouter-B1C0kvTL.mjs → createAggregationRouter-wzwFa_dW.mjs} +3 -3
  26. package/dist/docs/index.d.mts +1 -1
  27. package/dist/docs/index.mjs +2 -2
  28. package/dist/{elevation-COpYKt2h.mjs → elevation-CIz1GjGm.mjs} +4 -3
  29. package/dist/{errorHandler-BTzXSwIg.mjs → errorHandler-Bq2OeEQL.mjs} +10 -7
  30. package/dist/{eventPlugin-A6EbthXR.d.mts → eventPlugin-Bg3cP2_u.d.mts} +38 -3
  31. package/dist/{eventPlugin-DJG2D7sy.mjs → eventPlugin-DrQ_FesK.mjs} +22 -4
  32. package/dist/events/index.d.mts +57 -314
  33. package/dist/events/index.mjs +168 -93
  34. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  35. package/dist/events/transports/redis-stream-entry.mjs +24 -2
  36. package/dist/factory/index.d.mts +21 -6
  37. package/dist/factory/index.mjs +58 -18
  38. package/dist/{fastify-augmentation-9_fuetB4.d.mts → fastify-augmentation-dPNBVeIj.d.mts} +25 -2
  39. package/dist/{generate-usRSdQmP.mjs → generate-D0wZupBg.mjs} +1 -1
  40. package/dist/headers-BvlQSDMB.mjs +45 -0
  41. package/dist/health-CB_m4S32.mjs +377 -0
  42. package/dist/hooks/index.d.mts +1 -1
  43. package/dist/idempotency/index.d.mts +7 -0
  44. package/dist/idempotency/index.mjs +32 -20
  45. package/dist/{index-ogIHvOjo.d.mts → index-BMnbzvtO.d.mts} +70 -4
  46. package/dist/{integrations/jobs.d.mts → index-CG4yqMDB.d.mts} +82 -2
  47. package/dist/{index-DbtgCOCj.d.mts → index-DPRH0Cme.d.mts} +46 -94
  48. package/dist/{module-B4u10iOJ.d.mts → index-KUoxjIq1.d.mts} +263 -23
  49. package/dist/{index-D8MKYGDa.d.mts → index-f4PTrk3B.d.mts} +37 -5
  50. package/dist/index.d.mts +6 -6
  51. package/dist/index.mjs +6 -5
  52. package/dist/{init-DleK3p9f.mjs → init-tlRSt667.mjs} +206 -205
  53. package/dist/integrations/event-gateway.d.mts +1 -1
  54. package/dist/integrations/event-gateway.mjs +1 -1
  55. package/dist/integrations/index.d.mts +3 -3
  56. package/dist/integrations/jobs/index.d.mts +2 -0
  57. package/dist/integrations/{jobs.mjs → jobs/index.mjs} +110 -67
  58. package/dist/integrations/mcp/index.d.mts +68 -5
  59. package/dist/integrations/mcp/index.mjs +2 -2
  60. package/dist/integrations/mcp/testing.d.mts +1 -1
  61. package/dist/integrations/mcp/testing.mjs +1 -1
  62. package/dist/integrations/webhooks.d.mts +149 -22
  63. package/dist/integrations/webhooks.mjs +186 -42
  64. package/dist/integrations/websocket-redis.d.mts +1 -1
  65. package/dist/integrations/websocket.d.mts +1 -1
  66. package/dist/integrations/websocket.mjs +41 -14
  67. package/dist/{interface-C1_WLTMK.d.mts → interface-BGZCzOGL.d.mts} +24 -31
  68. package/dist/interface-n5hpKg1d.mjs +16 -0
  69. package/dist/{loadResourcesFromEntry-OMCvIEE7.mjs → loadResourcesFromEntry-kvGT6EcO.mjs} +1 -1
  70. package/dist/{mcpPlugin-ByA2tf6D.mjs → mcpPlugin-Cb7olw0j.mjs} +316 -45
  71. package/dist/{memory-CLXA2VeJ.mjs → memory-CmnzXE5Z.mjs} +29 -0
  72. package/dist/middleware/index.d.mts +17 -1
  73. package/dist/middleware/index.mjs +1 -1
  74. package/dist/migrations/index.d.mts +94 -44
  75. package/dist/migrations/index.mjs +196 -44
  76. package/dist/{multipartBody-CHEQSZ6G.mjs → multipartBody-D0eBvkeq.mjs} +17 -0
  77. package/dist/{openapi-BRpMZD7C.mjs → openapi-DrLtog_B.mjs} +4 -4
  78. package/dist/permissions/index.d.mts +3 -3
  79. package/dist/permissions/index.mjs +4 -3
  80. package/dist/{permissions-BJMuKMl7.mjs → permissions-BrtiBKGs.mjs} +305 -492
  81. package/dist/pipeline/index.d.mts +1 -1
  82. package/dist/{actionPermissions-ze70xXJi.mjs → pipeline-BN5G05rd.mjs} +4 -27
  83. package/dist/plugins/index.d.mts +7 -78
  84. package/dist/plugins/index.mjs +14 -97
  85. package/dist/plugins/response-cache.mjs +1 -0
  86. package/dist/plugins/tracing-entry.mjs +1 -1
  87. package/dist/{index-BEu4wjbL.d.mts → preloadResources-0oe-JSSS.d.mts} +59 -50
  88. package/dist/{createApp-Ci7yG5gv.mjs → preloadResources-DfyngIN9.mjs} +240 -68
  89. package/dist/presets/filesUpload.d.mts +3 -3
  90. package/dist/presets/filesUpload.mjs +3 -3
  91. package/dist/presets/index.d.mts +2 -1
  92. package/dist/presets/index.mjs +1 -1
  93. package/dist/presets/multiTenant.d.mts +1 -1
  94. package/dist/presets/multiTenant.mjs +1 -1
  95. package/dist/presets/search.d.mts +2 -2
  96. package/dist/presets/search.mjs +1 -1
  97. package/dist/{presets-gw0ciIUD.mjs → presets-DwFDVKP0.mjs} +2 -2
  98. package/dist/{queryCachePlugin-DzqLN904.mjs → queryCachePlugin-DSGuSVLW.mjs} +39 -8
  99. package/dist/{queryCachePlugin-CfYWq-Ak.d.mts → queryCachePlugin-br4otiqF.d.mts} +2 -2
  100. package/dist/{registerRoute-xHc42fwB.mjs → rateLimit-DrED-C4v.mjs} +2 -109
  101. package/dist/realtime-Cuw_deA-.mjs +375 -0
  102. package/dist/{redis-stream-iVR2l7aS.d.mts → redis-stream-uIaauNpZ.d.mts} +22 -0
  103. package/dist/registerRoute-v0Wb6Plt.mjs +108 -0
  104. package/dist/registry/index.d.mts +2 -2
  105. package/dist/registry/index.mjs +1 -1
  106. package/dist/renewingLease-3cuQH7h8.mjs +44 -0
  107. package/dist/{requestContext-BZKOr13H.mjs → requestContext-MrlJwECf.mjs} +2 -2
  108. package/dist/schedules-CjOd2MG9.mjs +113 -0
  109. package/dist/{schemaConverter-Ds5reSGs.mjs → schemaConverter-DJvodiHj.mjs} +4 -1
  110. package/dist/{schemaIR-B-6SPe7g.mjs → schemaIR-Ca7ySNPx.mjs} +1 -1
  111. package/dist/schemas/index.d.mts +67 -67
  112. package/dist/schemas/index.mjs +2 -3
  113. package/dist/scim/index.mjs +1 -2
  114. package/dist/scope/index.d.mts +2 -2
  115. package/dist/scope/index.mjs +4 -4
  116. package/dist/scope-DfaPntpo.mjs +36 -0
  117. package/dist/simpleEqualityMatcher-Cg05HPsn.mjs +68 -0
  118. package/dist/{sse-CfUjwjDk.mjs → sse-BQ1w0dfl.mjs} +8 -31
  119. package/dist/sseStream-BQ7Qaynp.mjs +57 -0
  120. package/dist/testing/index.d.mts +4 -3
  121. package/dist/testing/index.mjs +2 -2
  122. package/dist/transactionContext-PNdoyLLm.mjs +64 -0
  123. package/dist/types/index.d.mts +4 -4
  124. package/dist/{types-bHblZ9YN.mjs → types-CSyCxl2V.mjs} +38 -7
  125. package/dist/{types-DH0GupI7.d.mts → types-DjC-KUCz.d.mts} +118 -20
  126. package/dist/{types-Csxga7d3.d.mts → types-Dmw-6Qeo.d.mts} +96 -4
  127. package/dist/{types-Bc42CUyk.d.mts → types-QFGc3Cjv.d.mts} +37 -2
  128. package/dist/usage/index.d.mts +3 -52
  129. package/dist/usage/index.mjs +0 -0
  130. package/dist/userHelpers-Cg_y3fBz.mjs +29 -0
  131. package/dist/utils/index.d.mts +90 -57
  132. package/dist/utils/index.mjs +7 -3
  133. package/dist/{utils-FhJ88TJE.mjs → utils-taUVD4p3.mjs} +47 -385
  134. package/dist/{validate-C2mGgSXg.mjs → validate-Bk44F2yT.mjs} +1 -1
  135. package/dist/{versioning-DLwklPlG.d.mts → versioning-DXgY5BUm.d.mts} +52 -31
  136. package/dist/{versioning-Dk-71iIz.mjs → versioning-gKWyryT3.mjs} +8 -1
  137. package/dist/{websocket-uuWqM6UY.d.mts → websocket-_Pd0CgR0.d.mts} +15 -1
  138. package/package.json +526 -453
  139. package/skills/arc/references/api-reference.md +3 -1
  140. package/skills/arc/references/integrations.md +20 -11
  141. package/skills/arc/references/production.md +734 -696
  142. package/dist/QueryCache-Z1B38koh.d.mts +0 -40
  143. package/dist/betterAuthOpenApi-CV1lxpRX.mjs +0 -2
  144. package/dist/health-ScyjIVo5.mjs +0 -202
  145. package/dist/requestId-5BhTVzBv.mjs +0 -113
  146. package/dist/scope-k15RXfcq.mjs +0 -64
  147. package/dist/types-XTApa8b6.mjs +0 -24
@@ -1,4 +1,4 @@
1
- import { Ct as PipelineStep, Rt as IControllerResponse, St as PipelineContext, _t as Guard, bt as OperationFilter, vt as Interceptor, wt as Transform, xt as PipelineConfig, yt as NextFunction } from "../index-DbtgCOCj.mjs";
1
+ import { Ct as PipelineStep, Rt as IControllerResponse, St as PipelineContext, _t as Guard, bt as OperationFilter, vt as Interceptor, wt as Transform, xt as PipelineConfig, yt as NextFunction } from "../index-DPRH0Cme.mjs";
2
2
  //#region src/pipeline/guard.d.ts
3
3
  interface GuardOptions {
4
4
  operations?: OperationFilter;
@@ -1,6 +1,6 @@
1
- import { b as isElevated, c as getOrgId, g as getUserId, n as PUBLIC_SCOPE, x as isMember } from "./types-bHblZ9YN.mjs";
2
- import { F as applyFieldReadPermissions, R as resolveEffectiveRoles } from "./permissions-BJMuKMl7.mjs";
3
- import { t as getUserRoles } from "./types-XTApa8b6.mjs";
1
+ import { n as getUserRoles } from "./userHelpers-Cg_y3fBz.mjs";
2
+ import { b as isElevated, c as getOrgId, g as getUserId, n as PUBLIC_SCOPE, x as isMember } from "./types-CSyCxl2V.mjs";
3
+ import { i as applyFieldReadPermissions, s as resolveEffectiveRoles } from "./applyPermissionResult-Tw4iXtlf.mjs";
4
4
  import { t as executePipeline } from "./pipe-BOLmGIxa.mjs";
5
5
  import { isPaginatedResult, toCanonicalList } from "@classytic/repo-core/pagination";
6
6
  //#region src/scope/projection.ts
@@ -334,27 +334,4 @@ function buildActionPipelineHandler(handler, steps, operation, resourceName) {
334
334
  };
335
335
  }
336
336
  //#endregion
337
- //#region src/core/actionPermissions.ts
338
- /**
339
- * Return the effective `PermissionCheck` for a single action, or `undefined`
340
- * when the resource declares no gate at any level.
341
- *
342
- * Callers decide what "no gate" means:
343
- * - HTTP: boot-time throw in `normalizeActionsToRouterConfig`.
344
- * - MCP: tool-generation throw in `resourceToTools` (mirrors HTTP — the
345
- * two surfaces fail closed identically so MCP can't expose an
346
- * unauthenticated mutating tool when the HTTP plugin lifecycle hasn't
347
- * run).
348
- * - OpenAPI: docs advertise the endpoint as unauthenticated.
349
- */
350
- function resolveActionPermission(input) {
351
- const { action, resourcePermissions, resourceActionPermissions, globalAuth } = input;
352
- const explicit = typeof action !== "function" && action.permissions ? action.permissions : void 0;
353
- if (explicit) return explicit;
354
- if (resourceActionPermissions) return resourceActionPermissions;
355
- if (globalAuth) return globalAuth;
356
- const updateFallback = resourcePermissions?.update;
357
- if (updateFallback) return updateFallback;
358
- }
359
- //#endregion
360
- export { createCrudHandlers as a, getControllerContext as c, buildRequestScopeProjection as d, resolvePipelineSteps as i, getControllerScope as l, buildActionPipelineHandler as n, createFastifyHandler as o, buildPipelineHandler as r, createRequestContext as s, resolveActionPermission as t, sendControllerResponse as u };
337
+ export { createFastifyHandler as a, getControllerScope as c, createCrudHandlers as i, sendControllerResponse as l, buildPipelineHandler as n, createRequestContext as o, resolvePipelineSteps as r, getControllerContext as s, buildActionPipelineHandler as t, buildRequestScopeProjection as u };
@@ -1,7 +1,9 @@
1
- import { At as RouteDefinition, J as PresetHook, Q as MiddlewareConfig, et as RouteSchemaOptions, qt as AnyRecord } from "../index-DbtgCOCj.mjs";
1
+ import { At as RouteDefinition, J as PresetHook, Q as MiddlewareConfig, et as RouteSchemaOptions } from "../index-DPRH0Cme.mjs";
2
+ import { c as AnyRecord } from "../types-Dmw-6Qeo.mjs";
2
3
  import { i as errorHandlerPlugin, n as ErrorMapper, r as defaultIsDuplicateKeyError, t as ErrorHandlerOptions } from "../errorHandler-C6yv4ZTW.mjs";
3
- import { a as arcCorePlugin, i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-9_fuetB4.mjs";
4
- import { _ as HealthOptions, a as MetricsCollector, c as metricsPlugin, d as ssePlugin, f as CachingOptions, g as HealthCheck, h as cachingPlugin, i as MetricEntry, l as SSEOptions, m as _default$1, n as _default$8, o as MetricsOptions, p as CachingRule, r as versioningPlugin, s as _default$4, t as VersioningOptions, u as _default$7, v as _default$3, y as healthPlugin } from "../versioning-DLwklPlG.mjs";
4
+ import { C as schedulesPlugin, D as healthPlugin, E as _default$3, S as _default$7, T as HealthOptions, b as ScheduleStats, w as HealthCheck, x as SchedulesPluginOptions, y as ScheduleDefinition } from "../index-KUoxjIq1.mjs";
5
+ import { a as arcCorePlugin, i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-dPNBVeIj.mjs";
6
+ import { _ as CachingRule, a as MetricsCollector, c as metricsPlugin, d as _default$5, f as realtimePlugin, g as CachingOptions, h as ssePlugin, i as MetricEntry, l as ChangeOperation, m as _default$8, n as _default$9, o as MetricsOptions, p as SSEOptions, r as versioningPlugin, s as _default$4, t as VersioningOptions, u as RealtimeOptions, v as _default$1, y as cachingPlugin } from "../versioning-DXgY5BUm.mjs";
5
7
  import { t as TracingOptions } from "../tracing-CsGKQJGg.mjs";
6
8
  import { PaginatedResult } from "@classytic/repo-core/pagination";
7
9
  import { FastifyInstance, FastifyPluginAsync } from "fastify";
@@ -163,79 +165,6 @@ declare function createRequestIdGenerator(opts?: Pick<RequestIdOptions, "header"
163
165
  headers: Record<string, string | string[] | undefined>;
164
166
  }) => string;
165
167
  declare const requestIdPlugin: FastifyPluginAsync<RequestIdOptions>;
166
- declare const _default$5: FastifyPluginAsync<RequestIdOptions>;
168
+ declare const _default$6: FastifyPluginAsync<RequestIdOptions>;
167
169
  //#endregion
168
- //#region src/plugins/schedules.d.ts
169
- /**
170
- * Structural view of the ecosystem lock contract — matches
171
- * `LockAdapter` from `@classytic/repo-core/lock` (and every kit
172
- * implementation) WITHOUT importing the subpath, so arc's emitted
173
- * declarations carry no repo-core@>=0.8 subpath reference and the
174
- * peer floor stays honest. Any conforming adapter assigns.
175
- */
176
- interface ScheduleLockLike {
177
- tryAcquire(name: string, holderId: string, leaseMs: number): Promise<boolean> | boolean;
178
- release(name: string, holderId: string): Promise<boolean> | boolean;
179
- }
180
- interface ScheduleDefinition {
181
- /** Unique name — also the lock key (`arc:schedule:<name>`). */
182
- name: string;
183
- /** Interval in milliseconds between the END of one run and the next tick. */
184
- every: number;
185
- /** The work. Receives the Fastify instance; errors are logged, never fatal. */
186
- handler: (fastify: FastifyInstance) => void | Promise<void>;
187
- /** Fire once immediately when the app becomes ready (default: false). */
188
- runOnStart?: boolean;
189
- /**
190
- * Random extra delay in `[0, jitterMs)` added to the FIRST tick only.
191
- * Spreads boot-aligned jobs so multiple same-cadence schedules don't all
192
- * fire at exactly `boot + every` after every restart (and, with a lock,
193
- * de-synchronizes replicas competing for the same lease). Ignored when
194
- * `runOnStart` is true.
195
- */
196
- jitterMs?: number;
197
- /**
198
- * Lease duration when a `lock` is configured. Default: `every * 0.9`
199
- * (capped at 5 minutes) — long enough that other replicas skip the same
200
- * tick, short enough that a crashed leader fails over within one cycle.
201
- */
202
- leaseMs?: number;
203
- /** Per-schedule kill switch (default: true). */
204
- enabled?: boolean;
205
- }
206
- interface SchedulesPluginOptions {
207
- schedules: ScheduleDefinition[];
208
- /**
209
- * Ecosystem lock adapter for multi-replica deployments. Omit for
210
- * single-instance apps — every tick runs locally.
211
- */
212
- lock?: ScheduleLockLike;
213
- /**
214
- * Identity of this replica for lease ownership. Default: a random id per
215
- * process (repo-core's `getInstanceId()` is a good explicit value).
216
- */
217
- holderId?: string;
218
- /**
219
- * Master switch — `false` registers a typed no-op (config-gated
220
- * environments), same pattern as `idempotencyPlugin`.
221
- */
222
- enabled?: boolean;
223
- }
224
- /** Per-schedule runtime counters, readable via `fastify.getScheduleStats()`. */
225
- interface ScheduleStats {
226
- name: string;
227
- runs: number;
228
- failures: number;
229
- skippedByLock: number;
230
- lastRunAt: string | null;
231
- lastError: string | null;
232
- }
233
- declare module "fastify" {
234
- interface FastifyInstance {
235
- getScheduleStats?: () => ScheduleStats[];
236
- }
237
- }
238
- declare const schedulesPlugin: FastifyPluginAsync<SchedulesPluginOptions>;
239
- declare const _default$6: FastifyPluginAsync<SchedulesPluginOptions>;
240
- //#endregion
241
- export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type CreatePluginDefinition, type ErrorHandlerOptions, type ErrorMapper, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type RequestIdOptions, type SSEOptions, type ScheduleDefinition, type ScheduleLockLike, type ScheduleStats, type SchedulesPluginOptions, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, _default$1 as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, _default$2 as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, _default$3 as healthPlugin, healthPlugin as healthPluginFn, _default$4 as metricsPlugin, metricsPlugin as metricsPluginFn, replyHelpersPlugin, _default$5 as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sanitizeRequestId, _default$6 as schedulesPlugin, schedulesPlugin as schedulesPluginFn, _default$7 as ssePlugin, ssePlugin as ssePluginFn, _default$8 as versioningPlugin, versioningPlugin as versioningPluginFn };
170
+ export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type ChangeOperation, type CreatePluginDefinition, type ErrorHandlerOptions, type ErrorMapper, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type RealtimeOptions, type RequestIdOptions, type SSEOptions, type ScheduleDefinition, type ScheduleStats, type SchedulesPluginOptions, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, _default$1 as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, _default$2 as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, _default$3 as healthPlugin, healthPlugin as healthPluginFn, _default$4 as metricsPlugin, metricsPlugin as metricsPluginFn, _default$5 as realtimePlugin, realtimePlugin as realtimePluginFn, replyHelpersPlugin, _default$6 as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sanitizeRequestId, _default$7 as schedulesPlugin, schedulesPlugin as schedulesPluginFn, _default$8 as ssePlugin, ssePlugin as ssePluginFn, _default$9 as versioningPlugin, versioningPlugin as versioningPluginFn };
@@ -1,17 +1,18 @@
1
1
  import { p as MUTATION_OPERATIONS } from "../constants-DNre0wRg.mjs";
2
- import { c as getOrgId } from "../types-bHblZ9YN.mjs";
3
- import { n as requestContext } from "../requestContext-BZKOr13H.mjs";
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
- import { t as ResourceRegistry } from "../ResourceRegistry-7RnrEWNP.mjs";
7
- import { i as sanitizeRequestId, n as requestIdPlugin, r as requestId_default, t as createRequestIdGenerator } from "../requestId-5BhTVzBv.mjs";
8
- import { n as health_default, t as healthPlugin } from "../health-ScyjIVo5.mjs";
6
+ import { t as ResourceRegistry } from "../ResourceRegistry-y9Hnypus.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
- import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-BTzXSwIg.mjs";
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";
11
+ import { n as realtime_default, t as realtimePlugin } from "../realtime-Cuw_deA-.mjs";
12
12
  import { t as replyHelpersPlugin } from "../replyHelpers-67tRawQZ.mjs";
13
- import { n as sse_default, t as ssePlugin } from "../sse-CfUjwjDk.mjs";
14
- import { n as versioning_default, t as versioningPlugin } from "../versioning-Dk-71iIz.mjs";
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";
15
16
  import fp from "fastify-plugin";
16
17
  //#region src/core/arcCorePlugin.ts
17
18
  const arcCorePlugin = async (fastify, opts = {}) => {
@@ -23,7 +24,10 @@ const arcCorePlugin = async (fastify, opts = {}) => {
23
24
  registry: actualRegistry,
24
25
  emitEvents,
25
26
  externalOpenApiPaths: [],
26
- plugins: /* @__PURE__ */ new Map()
27
+ plugins: /* @__PURE__ */ new Map(),
28
+ healthChecks: [],
29
+ moduleDefinitions: [],
30
+ scheduledJobs: []
27
31
  });
28
32
  for (const field of [
29
33
  "_policyFilters",
@@ -200,91 +204,4 @@ var gracefulShutdown_default = fp(gracefulShutdownPlugin, {
200
204
  fastify: "5.x"
201
205
  });
202
206
  //#endregion
203
- //#region src/plugins/schedules.ts
204
- const MIN_SAFE_INTERVAL_MS = 1e3;
205
- const MAX_DEFAULT_LEASE_MS = 3e5;
206
- const schedulesPlugin = async (fastify, opts) => {
207
- const { schedules, lock, enabled = true } = opts;
208
- const holderId = opts.holderId ?? `arc-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
209
- const stats = /* @__PURE__ */ new Map();
210
- fastify.decorate("getScheduleStats", () => [...stats.values()].map((s) => ({ ...s })));
211
- if (!enabled) {
212
- fastify.log.debug("schedulesPlugin disabled — registered as no-op");
213
- return;
214
- }
215
- const seen = /* @__PURE__ */ new Set();
216
- for (const s of schedules) {
217
- if (!s.name) throw new TypeError("[arc-schedules] every schedule needs a name");
218
- if (seen.has(s.name)) throw new TypeError(`[arc-schedules] duplicate schedule name "${s.name}"`);
219
- seen.add(s.name);
220
- if (!Number.isFinite(s.every) || s.every <= 0) throw new TypeError(`[arc-schedules] "${s.name}": \`every\` must be a positive number of ms`);
221
- 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.`);
222
- }
223
- const timers = /* @__PURE__ */ new Map();
224
- const inFlight = /* @__PURE__ */ new Map();
225
- let closing = false;
226
- async function tick(s) {
227
- const stat = stats.get(s.name);
228
- if (!stat) return;
229
- try {
230
- if (lock) {
231
- const leaseMs = s.leaseMs ?? Math.min(Math.floor(s.every * .9), MAX_DEFAULT_LEASE_MS);
232
- if (!await lock.tryAcquire(`arc:schedule:${s.name}`, holderId, leaseMs)) {
233
- stat.skippedByLock++;
234
- return;
235
- }
236
- }
237
- stat.runs++;
238
- stat.lastRunAt = (/* @__PURE__ */ new Date()).toISOString();
239
- await s.handler(fastify);
240
- stat.lastError = null;
241
- } catch (err) {
242
- stat.failures++;
243
- stat.lastError = err instanceof Error ? err.message : String(err);
244
- fastify.log.error({
245
- err,
246
- schedule: s.name
247
- }, "[arc-schedules] schedule run failed");
248
- }
249
- }
250
- function scheduleNext(s, delay) {
251
- if (closing) return;
252
- const timer = setTimeout(() => {
253
- const run = tick(s).finally(() => {
254
- inFlight.delete(s.name);
255
- scheduleNext(s, s.every);
256
- });
257
- inFlight.set(s.name, run);
258
- }, delay);
259
- timer.unref?.();
260
- timers.set(s.name, timer);
261
- }
262
- fastify.addHook("onReady", async () => {
263
- for (const s of schedules) {
264
- if (s.enabled === false) continue;
265
- stats.set(s.name, {
266
- name: s.name,
267
- runs: 0,
268
- failures: 0,
269
- skippedByLock: 0,
270
- lastRunAt: null,
271
- lastError: null
272
- });
273
- const jitter = !s.runOnStart && s.jitterMs ? Math.floor(Math.random() * s.jitterMs) : 0;
274
- scheduleNext(s, s.runOnStart ? 0 : s.every + jitter);
275
- }
276
- if (stats.size > 0) fastify.log.debug(`[arc-schedules] ${stats.size} schedule(s) armed${lock ? ` (leader-safe, holder ${holderId})` : ""}`);
277
- });
278
- fastify.addHook("onClose", async () => {
279
- closing = true;
280
- for (const timer of timers.values()) clearTimeout(timer);
281
- timers.clear();
282
- await Promise.allSettled([...inFlight.values()]);
283
- });
284
- };
285
- var schedules_default = fp(schedulesPlugin, {
286
- name: "arc-schedules",
287
- fastify: "5.x"
288
- });
289
- //#endregion
290
- 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, 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 };
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.22.0";
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 { Ut as Authenticator } from "./index-DbtgCOCj.mjs";
2
- import { r as CacheStore } from "./interface-C1_WLTMK.mjs";
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-CfYWq-Ak.mjs";
6
+ import { r as QueryCachePluginOptions } from "./queryCachePlugin-br4otiqF.mjs";
7
7
  import { t as ErrorHandlerOptions } from "./errorHandler-C6yv4ZTW.mjs";
8
- import { l as ResourceLike, n as ArcModuleInput } from "./module-B4u10iOJ.mjs";
9
- import { t as EventPluginOptions } from "./eventPlugin-A6EbthXR.mjs";
10
- import { _ as HealthOptions, f as CachingOptions, l as SSEOptions, o as MetricsOptions, t as VersioningOptions } from "./versioning-DLwklPlG.mjs";
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.
@@ -672,6 +669,15 @@ interface CreateAppOptions {
672
669
  * Requires emitEvents to be enabled (or events plugin registered).
673
670
  */
674
671
  sse?: SSEOptions | boolean;
672
+ /**
673
+ * Realtime resource change feed (2.22) — `GET /realtime/:resource`
674
+ * streams that resource's created/updated/deleted events over SSE,
675
+ * gated by its own `list` permission with per-event row filtering,
676
+ * tenant scoping, and field-level masking. Default: false (opt-in).
677
+ * Set true for defaults, or pass RealtimeOptions (path, heartbeat,
678
+ * resource allowlist, operations). Requires events.
679
+ */
680
+ realtime?: RealtimeOptions | boolean;
675
681
  /**
676
682
  * QueryCache — TanStack Query-inspired server cache with SWR.
677
683
  * Default: false (opt-in). Set to true for memory store defaults.
@@ -689,26 +695,6 @@ interface CreateAppOptions {
689
695
  */
690
696
  versioning?: VersioningOptions;
691
697
  };
692
- /**
693
- * Type provider for schema inference.
694
- *
695
- * When set to `'typebox'`, enables TypeBox type provider for
696
- * automatic TypeScript inference from route schemas.
697
- *
698
- * Requires `@sinclair/typebox` and `@fastify/type-provider-typebox` installed.
699
- *
700
- * @example
701
- * ```typescript
702
- * import { Type } from '@classytic/arc/schemas';
703
- *
704
- * const app = await createApp({
705
- * typeProvider: 'typebox',
706
- * });
707
- *
708
- * // Now route schemas built with Type.* give full TS inference
709
- * ```
710
- */
711
- typeProvider?: "typebox";
712
698
  /**
713
699
  * Error handler plugin. Normalizes AJV, Mongoose, and ArcError responses
714
700
  * into a consistent JSON envelope. Enabled by default.
@@ -1083,4 +1069,27 @@ interface CreateAppOptions {
1083
1069
  onClose?: (fastify: FastifyInstance) => void | Promise<void>;
1084
1070
  }
1085
1071
  //#endregion
1086
- export { AuthOption as a, CustomPluginAuthOption as c, preloadResourcesAsync as d, UnderPressureOptions as i, JwtAuthOption as l, MultipartOptions as n, BetterAuthOption as o, RawBodyOptions as r, CustomAuthenticatorOption as s, CreateAppOptions as t, preloadResources as u };
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 };