@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.
Files changed (132) hide show
  1. package/dist/{BaseController-BQ8KNvWC.mjs → BaseController--M8EMzt0.mjs} +90 -21
  2. package/dist/QueryCache-DOMT_iq7.d.mts +72 -0
  3. package/dist/actionPermissions-CAphcmUG.mjs +24 -0
  4. package/dist/audit/index.d.mts +32 -3
  5. package/dist/audit/index.mjs +7 -4
  6. package/dist/auth/index.d.mts +2 -2
  7. package/dist/auth/index.mjs +263 -259
  8. package/dist/{buildHandler-D_2ULWxZ.mjs → buildHandler-Dtwd8fdz.mjs} +1 -1
  9. package/dist/cache/index.d.mts +41 -3
  10. package/dist/cache/index.mjs +33 -4
  11. package/dist/cli/commands/describe.d.mts +1 -1
  12. package/dist/cli/commands/docs.mjs +1 -1
  13. package/dist/cli/commands/generate.mjs +1 -1
  14. package/dist/cli/commands/init.mjs +1 -1
  15. package/dist/cli/index.mjs +2 -2
  16. package/dist/context/index.mjs +2 -64
  17. package/dist/core/index.d.mts +3 -3
  18. package/dist/core/index.mjs +4 -4
  19. package/dist/{core-DQ6rDTyH.mjs → core-EUNu0u07.mjs} +296 -11
  20. package/dist/{createActionRouter-BuOv-m4Y.mjs → createActionRouter-B6GvAuAX.mjs} +3 -2
  21. package/dist/{createAggregationRouter-CgJv_BU_.mjs → createAggregationRouter-wzwFa_dW.mjs} +3 -3
  22. package/dist/docs/index.d.mts +1 -1
  23. package/dist/docs/index.mjs +2 -2
  24. package/dist/{elevation-COpYKt2h.mjs → elevation-CIz1GjGm.mjs} +4 -3
  25. package/dist/{eventPlugin-A6EbthXR.d.mts → eventPlugin-Bg3cP2_u.d.mts} +38 -3
  26. package/dist/{eventPlugin-DJG2D7sy.mjs → eventPlugin-DrQ_FesK.mjs} +22 -4
  27. package/dist/events/index.d.mts +57 -314
  28. package/dist/events/index.mjs +163 -91
  29. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  30. package/dist/events/transports/redis-stream-entry.mjs +24 -2
  31. package/dist/factory/index.d.mts +4 -5
  32. package/dist/factory/index.mjs +28 -8
  33. package/dist/{fastify-augmentation-g_f9omSc.d.mts → fastify-augmentation-dPNBVeIj.d.mts} +25 -2
  34. package/dist/{generate-usRSdQmP.mjs → generate-D0wZupBg.mjs} +1 -1
  35. package/dist/headers-BvlQSDMB.mjs +45 -0
  36. package/dist/health-CB_m4S32.mjs +377 -0
  37. package/dist/hooks/index.d.mts +1 -1
  38. package/dist/idempotency/index.mjs +27 -3
  39. package/dist/{index-wMoWBLkn.d.mts → index-BMnbzvtO.d.mts} +3 -3
  40. package/dist/{integrations/jobs.d.mts → index-CG4yqMDB.d.mts} +82 -2
  41. package/dist/{index-BBsvQt7U.d.mts → index-DPRH0Cme.d.mts} +36 -106
  42. package/dist/{module-B4u10iOJ.d.mts → index-KUoxjIq1.d.mts} +263 -23
  43. package/dist/{index-CC5ruDGh.d.mts → index-f4PTrk3B.d.mts} +37 -5
  44. package/dist/index.d.mts +6 -6
  45. package/dist/index.mjs +5 -5
  46. package/dist/{init-CjO4p_q1.mjs → init-tlRSt667.mjs} +206 -208
  47. package/dist/integrations/event-gateway.d.mts +1 -1
  48. package/dist/integrations/event-gateway.mjs +1 -1
  49. package/dist/integrations/index.d.mts +3 -3
  50. package/dist/integrations/jobs/index.d.mts +2 -0
  51. package/dist/integrations/{jobs.mjs → jobs/index.mjs} +110 -67
  52. package/dist/integrations/mcp/index.d.mts +4 -4
  53. package/dist/integrations/mcp/index.mjs +2 -2
  54. package/dist/integrations/mcp/testing.d.mts +1 -1
  55. package/dist/integrations/mcp/testing.mjs +1 -1
  56. package/dist/integrations/webhooks.d.mts +37 -30
  57. package/dist/integrations/webhooks.mjs +51 -62
  58. package/dist/integrations/websocket-redis.d.mts +1 -1
  59. package/dist/integrations/websocket.d.mts +1 -1
  60. package/dist/integrations/websocket.mjs +41 -14
  61. package/dist/{interface-C1_WLTMK.d.mts → interface-BGZCzOGL.d.mts} +24 -31
  62. package/dist/{mcpPlugin-BtzIL_kM.mjs → mcpPlugin-Cb7olw0j.mjs} +11 -9
  63. package/dist/{memory-CLXA2VeJ.mjs → memory-CmnzXE5Z.mjs} +29 -0
  64. package/dist/middleware/index.d.mts +17 -1
  65. package/dist/middleware/index.mjs +1 -1
  66. package/dist/migrations/index.d.mts +94 -44
  67. package/dist/migrations/index.mjs +196 -44
  68. package/dist/{multipartBody-CHEQSZ6G.mjs → multipartBody-D0eBvkeq.mjs} +17 -0
  69. package/dist/{openapi-jSDx-VDv.mjs → openapi-DrLtog_B.mjs} +3 -3
  70. package/dist/permissions/index.d.mts +2 -2
  71. package/dist/permissions/index.mjs +2 -2
  72. package/dist/{permissions-tbxFHxjZ.mjs → permissions-BrtiBKGs.mjs} +229 -229
  73. package/dist/pipeline/index.d.mts +1 -1
  74. package/dist/{actionPermissions-lszoJle1.mjs → pipeline-BN5G05rd.mjs} +3 -26
  75. package/dist/plugins/index.d.mts +6 -77
  76. package/dist/plugins/index.mjs +11 -95
  77. package/dist/plugins/response-cache.mjs +1 -0
  78. package/dist/plugins/tracing-entry.mjs +1 -1
  79. package/dist/{index-Ba10fdKp.d.mts → preloadResources-0oe-JSSS.d.mts} +50 -50
  80. package/dist/{createApp-CjOeWJ9_.mjs → preloadResources-DfyngIN9.mjs} +233 -70
  81. package/dist/presets/filesUpload.d.mts +3 -3
  82. package/dist/presets/filesUpload.mjs +3 -3
  83. package/dist/presets/index.d.mts +2 -1
  84. package/dist/presets/index.mjs +1 -1
  85. package/dist/presets/multiTenant.d.mts +1 -1
  86. package/dist/presets/multiTenant.mjs +1 -1
  87. package/dist/presets/search.d.mts +2 -2
  88. package/dist/presets/search.mjs +1 -1
  89. package/dist/{presets-BOe4Ugkl.mjs → presets-DwFDVKP0.mjs} +2 -2
  90. package/dist/{queryCachePlugin-DzqLN904.mjs → queryCachePlugin-DSGuSVLW.mjs} +39 -8
  91. package/dist/{queryCachePlugin-CfYWq-Ak.d.mts → queryCachePlugin-br4otiqF.d.mts} +2 -2
  92. package/dist/{registerRoute-CWO6mdYe.mjs → rateLimit-DrED-C4v.mjs} +2 -109
  93. package/dist/{realtime-I8OrfnMR.mjs → realtime-Cuw_deA-.mjs} +2 -2
  94. package/dist/{redis-stream-iVR2l7aS.d.mts → redis-stream-uIaauNpZ.d.mts} +22 -0
  95. package/dist/registerRoute-v0Wb6Plt.mjs +108 -0
  96. package/dist/registry/index.d.mts +2 -2
  97. package/dist/renewingLease-3cuQH7h8.mjs +44 -0
  98. package/dist/{requestContext-BZKOr13H.mjs → requestContext-MrlJwECf.mjs} +2 -2
  99. package/dist/schedules-CjOd2MG9.mjs +113 -0
  100. package/dist/schemas/index.d.mts +67 -67
  101. package/dist/schemas/index.mjs +2 -3
  102. package/dist/scim/index.mjs +1 -2
  103. package/dist/scope/index.d.mts +2 -2
  104. package/dist/scope/index.mjs +4 -4
  105. package/dist/{scope-LONQ3mfZ.mjs → scope-DfaPntpo.mjs} +4 -5
  106. package/dist/{sse-0u4P4-OI.mjs → sse-BQ1w0dfl.mjs} +1 -1
  107. package/dist/testing/index.d.mts +4 -3
  108. package/dist/testing/index.mjs +2 -2
  109. package/dist/transactionContext-PNdoyLLm.mjs +64 -0
  110. package/dist/types/index.d.mts +4 -4
  111. package/dist/{types-bHblZ9YN.mjs → types-CSyCxl2V.mjs} +38 -7
  112. package/dist/{types-DH0GupI7.d.mts → types-DjC-KUCz.d.mts} +118 -20
  113. package/dist/{types-Csxga7d3.d.mts → types-Dmw-6Qeo.d.mts} +96 -4
  114. package/dist/{types-5OuqeTDX.d.mts → types-QFGc3Cjv.d.mts} +1 -1
  115. package/dist/usage/index.d.mts +3 -52
  116. package/dist/usage/index.mjs +0 -0
  117. package/dist/userHelpers-Cg_y3fBz.mjs +29 -0
  118. package/dist/utils/index.d.mts +58 -85
  119. package/dist/utils/index.mjs +4 -2
  120. package/dist/{utils-CZyeRXTh.mjs → utils-taUVD4p3.mjs} +47 -337
  121. package/dist/{validate-C2mGgSXg.mjs → validate-Bk44F2yT.mjs} +1 -1
  122. package/dist/{versioning-D6PvCwpq.d.mts → versioning-DXgY5BUm.d.mts} +11 -29
  123. package/dist/{versioning-Dk-71iIz.mjs → versioning-gKWyryT3.mjs} +8 -1
  124. package/dist/{websocket-uuWqM6UY.d.mts → websocket-_Pd0CgR0.d.mts} +15 -1
  125. package/package.json +526 -513
  126. package/skills/arc/references/api-reference.md +3 -1
  127. package/skills/arc/references/integrations.md +20 -11
  128. package/dist/QueryCache-Z1B38koh.d.mts +0 -40
  129. package/dist/betterAuthOpenApi-CV1lxpRX.mjs +0 -2
  130. package/dist/health-ScyjIVo5.mjs +0 -202
  131. package/dist/requestId-5BhTVzBv.mjs +0 -113
  132. package/dist/types-XTApa8b6.mjs +0 -24
@@ -1,6 +1,6 @@
1
- import { a as QueryCacheConfig } from "./QueryCache-Z1B38koh.mjs";
2
- import { i as RequestScope } from "./types-DH0GupI7.mjs";
3
- import { i as UserBase, t as PermissionCheck } from "./types-Csxga7d3.mjs";
1
+ import { a as QueryCacheConfig } from "./QueryCache-DOMT_iq7.mjs";
2
+ import { P as ArcHeaders, i as RequestScope } from "./types-DjC-KUCz.mjs";
3
+ import { c as AnyRecord, i as UserBase, t as PermissionCheck } from "./types-Dmw-6Qeo.mjs";
4
4
  import "./elevation-C9s5hFP_.mjs";
5
5
  import { n as FieldPermissionMap } from "./fields-D3lhgzhD.mjs";
6
6
  import { n as EncryptionDirective } from "./types-Cc91nXuA.mjs";
@@ -620,9 +620,9 @@ declare class QueryResolver {
620
620
  /** Sanitize advanced populate options against allowedPopulate */
621
621
  private sanitizePopulateOptions;
622
622
  /**
623
- * Sanitize lookup/join options.
624
- * If schemaOptions.query.allowedLookups is set, only those collections are allowed.
625
- * Validates lookup structure to prevent injection.
623
+ * Sanitize lookup/join options. Deny-by-default: `allowedLookups` must be
624
+ * configured for any client-driven lookup to pass; listed collections are
625
+ * then structurally validated to prevent injection.
626
626
  */
627
627
  private sanitizeLookups;
628
628
  /**
@@ -833,6 +833,26 @@ declare class BaseCrudController<TDoc = AnyRecord, TRepository extends Repositor
833
833
  * create/update, the original input (`existing`) for delete.
834
834
  */
835
835
  protected runAfterHook(req: IRequestContext, op: "create" | "update" | "delete", data: AnyRecord, meta?: Record<string, unknown>): Promise<void>;
836
+ /**
837
+ * Per-instance single-flight for cache fills — concurrent requests for
838
+ * the SAME cache key coalesce onto one repository query instead of each
839
+ * issuing its own (a popular entry expiring under 1,000 concurrent
840
+ * readers must produce 1 DB query, not 1,000). Keys already encode the
841
+ * resolved query + user/org scope + resource version, so coalescing can
842
+ * never cross tenants, scopes, or invalidation generations. Per-process
843
+ * by design; distributed refresh leases are a store-level concern
844
+ * (planned with the repo-core CacheEngine façade, which ships
845
+ * single-flight natively).
846
+ */
847
+ private readonly inFlightCacheFills;
848
+ private cacheSingleFlight;
849
+ /**
850
+ * Register a background SWR refresh for `key` unless one is already in
851
+ * flight. Registration is SYNCHRONOUS (before the deferred tick) so a
852
+ * burst of stale readers arriving in the same tick schedules exactly one
853
+ * revalidation.
854
+ */
855
+ private scheduleCacheRefresh;
836
856
  /** Cached `list()` flow with SWR semantics. Returns null when cache is disabled. */
837
857
  protected withListCache(req: IRequestContext, options: ParsedQuery): Promise<IControllerResponse<ListResult<TDoc>> | null>;
838
858
  /** Cached `get()` flow with SWR semantics. Returns null when cache is disabled. */
@@ -1044,96 +1064,6 @@ declare class BaseController<TDoc extends AnyRecord = AnyRecord, _TRepository ex
1044
1064
  readonly _phantom?: [TDoc, _TRepository];
1045
1065
  }
1046
1066
  //#endregion
1047
- //#region src/types/base.d.ts
1048
- declare module "fastify" {
1049
- interface FastifyRequest {
1050
- /** Request scope — set by auth adapter, read by permissions/presets/guards */
1051
- scope: RequestScope;
1052
- /**
1053
- * Current user — set by auth adapter (Better Auth, JWT, custom).
1054
- * `undefined` on public routes (`auth: false`) or unauthenticated requests.
1055
- * Guard with `if (request.user)` on routes that allow anonymous access.
1056
- *
1057
- * Kept as required (not `user?`) because `@fastify/jwt` declares it
1058
- * as required — declaration merges must have identical modifiers.
1059
- * The `| undefined` in the type achieves the same DX.
1060
- */
1061
- user: Record<string, unknown> | undefined;
1062
- /** Policy-injected query filters (e.g. ownership, org-scoping) */
1063
- _policyFilters?: Record<string, unknown>;
1064
- /** Field mask — fields to include/exclude in responses */
1065
- fieldMask?: {
1066
- include?: string[];
1067
- exclude?: string[];
1068
- };
1069
- /** Arbitrary policy metadata for downstream consumers */
1070
- policyMetadata?: Record<string, unknown>;
1071
- /** Document loaded by policy middleware for ownership checks */
1072
- document?: unknown;
1073
- /** Ownership check context (field name + user field) */
1074
- _ownershipCheck?: Record<string, unknown>;
1075
- }
1076
- }
1077
- type AnyRecord = Record<string, unknown>;
1078
- /** MongoDB ObjectId — accepts string or any object with a `toString()` (e.g. mongoose ObjectId). */
1079
- type ObjectId = string | {
1080
- toString(): string;
1081
- };
1082
- /**
1083
- * Flexible user type that accepts any object with id/_id properties.
1084
- * The actual user structure is defined by your app's auth system.
1085
- */
1086
- type UserLike = UserBase & {
1087
- /** User email (optional) */
1088
- email?: string;
1089
- };
1090
- interface UserOrganization {
1091
- userId: string;
1092
- organizationId: string;
1093
- [key: string]: unknown;
1094
- }
1095
- interface JWTPayload {
1096
- sub: string;
1097
- [key: string]: unknown;
1098
- }
1099
- /**
1100
- * @deprecated LEGACY envelope — arc's actual wire contract has not used
1101
- * `{ success, data, error, message }` for a long time. Successes return
1102
- * DIRECT data (see `IControllerResponse` — `{ data, meta?, status?, headers? }`
1103
- * flattened onto the wire), and errors return the canonical `ErrorContract`
1104
- * (`{ code, message, status, details? }` from `@classytic/repo-core/errors`)
1105
- * emitted by the global error handler. Keeping this type visible teaches new
1106
- * applications and AI agents to generate an obsolete shape. Scheduled for
1107
- * removal in v3. Do NOT build new response handling against it.
1108
- */
1109
- interface ApiResponse<T = unknown> {
1110
- success: boolean;
1111
- data?: T;
1112
- error?: string;
1113
- message?: string;
1114
- meta?: Record<string, unknown>;
1115
- }
1116
- /**
1117
- * Typed Fastify request with Arc decorations. Use in `raw: true` handlers
1118
- * instead of `(req as any).user`.
1119
- *
1120
- * @example
1121
- * ```typescript
1122
- * import type { ArcRequest } from '@classytic/arc';
1123
- *
1124
- * handler: async (req: ArcRequest, reply) => {
1125
- * req.user?.id; // typed
1126
- * req.scope.organizationId; // typed (when member)
1127
- * req.signal; // AbortSignal (Fastify 5)
1128
- * }
1129
- * ```
1130
- */
1131
- type ArcRequest = FastifyRequest & {
1132
- scope: RequestScope;
1133
- user: Record<string, unknown> | undefined;
1134
- signal: AbortSignal;
1135
- };
1136
- //#endregion
1137
1067
  //#region src/types/auth.d.ts
1138
1068
  /**
1139
1069
  * JWT utilities provided to authenticator. Arc provides the helpers;
@@ -1430,15 +1360,15 @@ interface IRequestContext<TBody = unknown, TParams extends Record<string, string
1430
1360
  /** Authenticated user or null */
1431
1361
  user: TUser | null;
1432
1362
  /**
1433
- * Request headers.
1434
- *
1435
- * ⚠ Declared narrow for ergonomics, but on the HTTP path this is
1436
- * Fastify's headers object passed through — repeated headers arrive as
1437
- * `string[]` at RUNTIME behind this type. Read via `getHeader(ctx.headers,
1438
- * name)` from `@classytic/arc/utils` for array-safe, duplicate-deterministic
1439
- * access. The declared type widens to `ArcHeaders` in v3.
1363
+ * Request headers — `ArcHeaders` (`string | string[] | undefined` per
1364
+ * name), the HONEST type: on the HTTP path this is Fastify's headers
1365
+ * object passed through, and repeated headers arrive as `string[]` at
1366
+ * runtime (2.24 widening — the previous `Record<string, string |
1367
+ * undefined>` lied about that). Read via `getHeader(ctx.headers, name)`
1368
+ * from `@classytic/arc/utils` for array-safe, duplicate-deterministic
1369
+ * access, or `requireSingleHeaderValue` for security-sensitive headers.
1440
1370
  */
1441
- headers: Record<string, string | undefined>;
1371
+ headers: ArcHeaders;
1442
1372
  /** Organization ID (for multi-tenant apps) */
1443
1373
  organizationId?: string;
1444
1374
  /** Team ID (for team-scoped resources) */
@@ -1666,7 +1596,7 @@ interface RouteDefinition {
1666
1596
  * compiler to catch typos. `handler` stays optional when `controllerMethod`
1667
1597
  * is set — exactly one of the two must be declared.
1668
1598
  */
1669
- readonly handler?: string | ControllerHandler | RouteHandlerMethod | ((request: FastifyRequest<Record<string, unknown>>, reply: FastifyReply) => unknown);
1599
+ readonly handler?: string | ControllerHandler | RouteHandlerMethod | ((request: never, reply: never) => unknown);
1670
1600
  /**
1671
1601
  * Typed function-reference handler (2.16). Receives the live controller
1672
1602
  * instance and returns the method to invoke — TypeScript catches typos
@@ -4259,4 +4189,4 @@ interface ValidateOptions {
4259
4189
  strict?: boolean;
4260
4190
  }
4261
4191
  //#endregion
4262
- export { OpenApiSchemas as $, UserLike as $t, RequestIdOptions as A, defineHook as An, RouteDefinition as At, defineResource as B, BodySanitizer as Bn, RouteHandler as Bt, RequestContext as C, afterCreate as Cn, PipelineStep as Ct, HealthCheck as D, beforeDelete as Dn, ActionEntry as Dt, GracefulShutdownOptions as E, beforeCreate as En, ActionDefinition as Et, FastifyWithDecorators as F, ArcUpdateResult as Fn, ControllerLike as Ft, OnTenantDeleteConfig as G, AuthenticatorContext as Gt, CrudController as H, AuthHelpers as Ht, MiddlewareHandler as I, BaseControllerOptions as In, FastifyHandler as It, PresetHook as J, AnyRecord as Jt, ResolvedTenantPurge as K, JwtContext as Kt, RequestWithExtras as L, ControllerConfigurableOptions as Ln, IController as Lt, EventsDecorator as M, ArcDeleteResult as Mn, RouteMethod as Mt, FastifyRequestExtras as N, ArcGetResult as Nn, RateLimitConfig as Nt, HealthOptions as O, beforeUpdate as On, ActionHandlerFn as Ot, FastifyWithAuth as P, ArcListResult as Pn, ControllerHandler as Pt, MiddlewareConfig as Q, ObjectId as Qt, RegisterOptions as R, ControllerConstructionOptions as Rn, IControllerResponse as Rt, QueryParserInterface as S, HookSystemOptions as Sn, PipelineContext as St, CrudRouterOptions as T, afterUpdate as Tn, ResourceCacheConfig as Tt, ResourceConfig as U, AuthPluginOptions as Ut, ResourceDefinition as V, BodySanitizerConfig as Vn, ServerAccessor as Vt, ResourcePermissions as W, Authenticator as Wt, CrudRouteKey as X, ArcRequest as Xt, PresetResult as Y, ApiResponse as Yt, CrudSchemas as Z, JWTPayload as Zt, ControllerQueryOptions as _, HookHandler as _n, Guard as _t, InferAdapterDoc as a, TreeMixin as an, ResourceExtensions as at, ParsedQuery as b, HookRegistration as bn, OperationFilter as bt, TypedController as c, BulkExt as cn, AggMeasureShorthand as ct, PaginationResult as d, QueryResolver as dn, AggregationDateRangeRequirement as dt, UserOrganization as en, RouteSchemaOptions as et, IntrospectionData as f, QueryResolverConfig as fn, AggregationIndexHint as ft, ArcInternalMetadata as g, HookContext as gn, AggregationsMap as gt, ResourceMetadata as h, DefineHookOptions as hn, AggregationRateLimit as ht, ValidationResult as i, TreeExt as in, ResourceHooks as it, ArcDecorator as j, ArcCreateResult as jn, RouteMcpConfig as jt, IntrospectionPluginOptions as k, createHookSystem as kn, ActionsMap as kt, TypedRepository as l, BulkMixin as ln, AggregationCacheConfig as lt, RegistryStats as m, AccessControlConfig as mn, AggregationMaterializedResult as mt, ConfigError as n, SoftDeleteExt as nn, FieldRule$1 as nt, InferDocType as o, SlugExt as on, EventDefinition as ot, RegistryEntry as p, AccessControl as pn, AggregationMaterializedContext as pt, PresetFunction as q, TokenPair as qt, ValidateOptions as r, SoftDeleteMixin as rn, ResourceHookContext as rt, InferResourceDoc as s, SlugMixin as sn, AggMeasureInput as st, RouteHandlerMethod$1 as t, BaseController as tn, ArcFieldRule as tt, TypedResourceConfig as u, BaseCrudController as un, AggregationConfig as ut, LookupOption as v, HookOperation as vn, Interceptor as vt, ServiceContext as w, afterDelete as wn, Transform as wt, PopulateOption as x, HookSystem as xn, PipelineConfig as xt, OwnershipCheck as y, HookPhase as yn, NextFunction as yt, ResourceRegistry as z, ListResult as zn, IRequestContext as zt };
4192
+ export { OpenApiSchemas as $, SlugExt as $t, RequestIdOptions as A, ControllerConfigurableOptions as An, RouteDefinition as At, defineResource as B, RouteHandler as Bt, RequestContext as C, defineHook as Cn, PipelineStep as Ct, HealthCheck as D, ArcListResult as Dn, ActionEntry as Dt, GracefulShutdownOptions as E, ArcGetResult as En, ActionDefinition as Et, FastifyWithDecorators as F, ControllerLike as Ft, OnTenantDeleteConfig as G, AuthenticatorContext as Gt, CrudController as H, AuthHelpers as Ht, MiddlewareHandler as I, FastifyHandler as It, PresetHook as J, BaseController as Jt, ResolvedTenantPurge as K, JwtContext as Kt, RequestWithExtras as L, IController as Lt, EventsDecorator as M, ListResult as Mn, RouteMethod as Mt, FastifyRequestExtras as N, BodySanitizer as Nn, RateLimitConfig as Nt, HealthOptions as O, ArcUpdateResult as On, ActionHandlerFn as Ot, FastifyWithAuth as P, BodySanitizerConfig as Pn, ControllerHandler as Pt, MiddlewareConfig as Q, TreeMixin as Qt, RegisterOptions as R, IControllerResponse as Rt, QueryParserInterface as S, createHookSystem as Sn, PipelineContext as St, CrudRouterOptions as T, ArcDeleteResult as Tn, ResourceCacheConfig as Tt, ResourceConfig as U, AuthPluginOptions as Ut, ResourceDefinition as V, ServerAccessor as Vt, ResourcePermissions as W, Authenticator as Wt, CrudRouteKey as X, SoftDeleteMixin as Xt, PresetResult as Y, SoftDeleteExt as Yt, CrudSchemas as Z, TreeExt as Zt, ControllerQueryOptions as _, afterDelete as _n, Guard as _t, InferAdapterDoc as a, QueryResolverConfig as an, ResourceExtensions as at, ParsedQuery as b, beforeDelete as bn, OperationFilter as bt, TypedController as c, DefineHookOptions as cn, AggMeasureShorthand as ct, PaginationResult as d, HookOperation as dn, AggregationDateRangeRequirement as dt, SlugMixin as en, RouteSchemaOptions as et, IntrospectionData as f, HookPhase as fn, AggregationIndexHint as ft, ArcInternalMetadata as g, afterCreate as gn, AggregationsMap as gt, ResourceMetadata as h, HookSystemOptions as hn, AggregationRateLimit as ht, ValidationResult as i, QueryResolver as in, ResourceHooks as it, ArcDecorator as j, ControllerConstructionOptions as jn, RouteMcpConfig as jt, IntrospectionPluginOptions as k, BaseControllerOptions as kn, ActionsMap as kt, TypedRepository as l, HookContext as ln, AggregationCacheConfig as lt, RegistryStats as m, HookSystem as mn, AggregationMaterializedResult as mt, ConfigError as n, BulkMixin as nn, FieldRule$1 as nt, InferDocType as o, AccessControl as on, EventDefinition as ot, RegistryEntry as p, HookRegistration as pn, AggregationMaterializedContext as pt, PresetFunction as q, TokenPair as qt, ValidateOptions as r, BaseCrudController as rn, ResourceHookContext as rt, InferResourceDoc as s, AccessControlConfig as sn, AggMeasureInput as st, RouteHandlerMethod$1 as t, BulkExt as tn, ArcFieldRule as tt, TypedResourceConfig as u, HookHandler as un, AggregationConfig as ut, LookupOption as v, afterUpdate as vn, Interceptor as vt, ServiceContext as w, ArcCreateResult as wn, Transform as wt, PopulateOption as x, beforeUpdate as xn, PipelineConfig as xt, OwnershipCheck as y, beforeCreate as yn, NextFunction as yt, ResourceRegistry as z, IRequestContext as zt };
@@ -1,5 +1,106 @@
1
+ import { r as EventHandler } from "./EventTransport-QmY7A258.mjs";
1
2
  import { n as ErrorMapper } from "./errorHandler-C6yv4ZTW.mjs";
2
- import { FastifyInstance } from "fastify";
3
+ import { FastifyInstance, FastifyPluginAsync } from "fastify";
4
+ import { LockAdapter } from "@classytic/repo-core/lock";
5
+ //#region src/plugins/health.d.ts
6
+ interface HealthCheck {
7
+ /** Name of the dependency */
8
+ name: string;
9
+ /**
10
+ * Function that returns true if healthy, false otherwise.
11
+ *
12
+ * Receives an `AbortSignal` aborted when the check's timeout elapses —
13
+ * pass it to fetch/driver calls so a stalled dependency probe actually
14
+ * STOPS instead of accumulating an abandoned operation per readiness
15
+ * poll. Ignoring the parameter is fine (back-compat): the timeout still
16
+ * bounds how long the PROBE waits, just not the underlying work.
17
+ */
18
+ check: (signal?: AbortSignal) => Promise<boolean> | boolean;
19
+ /** Optional timeout in ms (default: 5000) */
20
+ timeout?: number;
21
+ /** Whether this check is critical for readiness (default: true) */
22
+ critical?: boolean;
23
+ }
24
+ interface HealthOptions {
25
+ /** Route prefix (default: '/_health') */
26
+ prefix?: string;
27
+ /** Health check dependencies */
28
+ checks?: readonly HealthCheck[];
29
+ /** Enable metrics endpoint (default: false) */
30
+ metrics?: boolean;
31
+ /** Custom metrics collector function */
32
+ metricsCollector?: () => Promise<string> | string;
33
+ /** Version info to include in responses */
34
+ version?: string;
35
+ /** Collect HTTP request metrics (default: true if metrics enabled) */
36
+ collectHttpMetrics?: boolean;
37
+ }
38
+ declare const healthPlugin: FastifyPluginAsync<HealthOptions>;
39
+ declare const _default$1: FastifyPluginAsync<HealthOptions>;
40
+ //#endregion
41
+ //#region src/plugins/schedules.d.ts
42
+ interface ScheduleDefinition {
43
+ /** Unique name — also the lock key (`arc:schedule:<name>`). */
44
+ name: string;
45
+ /** Interval in milliseconds between the END of one run and the next tick. */
46
+ every: number;
47
+ /** The work. Receives the Fastify instance; errors are logged, never fatal. */
48
+ handler: (fastify: FastifyInstance) => void | Promise<void>;
49
+ /** Fire once immediately when the app becomes ready (default: false). */
50
+ runOnStart?: boolean;
51
+ /**
52
+ * Random extra delay in `[0, jitterMs)` added to the FIRST tick only.
53
+ * Spreads boot-aligned jobs so multiple same-cadence schedules don't all
54
+ * fire at exactly `boot + every` after every restart (and, with a lock,
55
+ * de-synchronizes replicas competing for the same lease). Ignored when
56
+ * `runOnStart` is true.
57
+ */
58
+ jitterMs?: number;
59
+ /**
60
+ * Lease duration when a `lock` is configured. Default: `every * 0.9`
61
+ * (capped at 5 minutes) — long enough that other replicas skip the same
62
+ * tick, short enough that a crashed leader fails over within one cycle.
63
+ */
64
+ leaseMs?: number;
65
+ /** Per-schedule kill switch (default: true). */
66
+ enabled?: boolean;
67
+ }
68
+ interface SchedulesPluginOptions {
69
+ schedules: readonly ScheduleDefinition[];
70
+ /**
71
+ * Ecosystem lock adapter (`LockAdapter` from `@classytic/repo-core/lock`)
72
+ * for multi-replica deployments. Omit for single-instance apps — every
73
+ * tick runs locally.
74
+ */
75
+ lock?: LockAdapter;
76
+ /**
77
+ * Identity of this replica for lease ownership. Default: a random id per
78
+ * process (repo-core's `getInstanceId()` is a good explicit value).
79
+ */
80
+ holderId?: string;
81
+ /**
82
+ * Master switch — `false` registers a typed no-op (config-gated
83
+ * environments), same pattern as `idempotencyPlugin`.
84
+ */
85
+ enabled?: boolean;
86
+ }
87
+ /** Per-schedule runtime counters, readable via `fastify.getScheduleStats()`. */
88
+ interface ScheduleStats {
89
+ name: string;
90
+ runs: number;
91
+ failures: number;
92
+ skippedByLock: number;
93
+ lastRunAt: string | null;
94
+ lastError: string | null;
95
+ }
96
+ declare module "fastify" {
97
+ interface FastifyInstance {
98
+ getScheduleStats?: () => ScheduleStats[];
99
+ }
100
+ }
101
+ declare const schedulesPlugin: FastifyPluginAsync<SchedulesPluginOptions>;
102
+ declare const _default: FastifyPluginAsync<SchedulesPluginOptions>;
103
+ //#endregion
3
104
  //#region src/factory/loadResources.d.ts
4
105
  /**
5
106
  * loadResources — Auto-discover resource files from a directory.
@@ -218,7 +319,31 @@ interface LoadResourcesOptions<TContext = unknown> {
218
319
  */
219
320
  declare function loadResources<TContext = unknown>(dir: string, options?: LoadResourcesOptions<TContext>): Promise<ResourceLike[]>;
220
321
  //#endregion
221
- //#region src/factory/module.d.ts
322
+ //#region src/factory/module/types.d.ts
323
+ /**
324
+ * A module's contribution of some arm (event handlers, scheduled jobs, …).
325
+ * Either a static array or a factory resolved AFTER all module bootstraps, so a
326
+ * contribution can close over booted engines / the Fastify instance instead of
327
+ * reaching for a global getter (the coupling the module contract removes).
328
+ */
329
+ type ModuleContribution<T> = readonly T[] | ((fastify: FastifyInstance) => readonly T[] | Promise<readonly T[]>);
330
+ /**
331
+ * A domain-event subscription a module owns. Subscribed in dependency order
332
+ * during the `afterResources` phase (routes mounted, engines booted) and
333
+ * auto-unsubscribed at shutdown BEFORE module `onClose` (deps still alive).
334
+ */
335
+ interface EventHandlerDefinition {
336
+ /** Event pattern(s) to subscribe — same matcher as `fastify.events.subscribe`. */
337
+ event: string | readonly string[];
338
+ /** The subscriber. */
339
+ handler: EventHandler;
340
+ /**
341
+ * Optional stable name — enables duplicate detection + teardown diagnostics.
342
+ * Third-party modules should prefix it with their module name, for example
343
+ * `inventory.order-created`; Arc does not silently rewrite public names.
344
+ */
345
+ name?: string;
346
+ }
222
347
  interface ArcModule<TExports = unknown> {
223
348
  /** Stable identifier — appears in boot logs and duplicate-module detection. */
224
349
  readonly name: string;
@@ -344,6 +469,74 @@ interface ArcModule<TExports = unknown> {
344
469
  * module owns.
345
470
  */
346
471
  afterResources?: (fastify: FastifyInstance) => void | Promise<void>;
472
+ /**
473
+ * Readiness checks this module contributes to the app's
474
+ * `healthPlugin` (`/_health/ready`). Collected across ALL modules in
475
+ * dependency order and merged BEFORE the host's app-level `arcPlugins.health`
476
+ * checks (modules-first, host-last) — the same additive convention arc uses
477
+ * for resources and error mappers. Check `name`s must be unique across the
478
+ * module graph (arc fails at boot on a collision, attributing both owners).
479
+ *
480
+ * STATIC by design (not a factory): declare the check up front and let its
481
+ * `check()` closure resolve dependencies LAZILY at probe time, so collection
482
+ * can happen before the health plugin registers and the worker probe
483
+ * (`createWorker`) receives the identical union without a second registration.
484
+ *
485
+ * ```ts
486
+ * defineModule({ name: "inventory", healthChecks: [
487
+ * { name: "flow-engine", check: () => flow.isReady() },
488
+ * ] })
489
+ * ```
490
+ */
491
+ readonly healthChecks?: readonly HealthCheck[];
492
+ /**
493
+ * Domain-event subscriptions this module owns — the declarative replacement
494
+ * for imperative `fastify.events.subscribe(...)` calls inside
495
+ * `afterResources`. Subscribed in dependency order during the
496
+ * `afterResources` phase (routes mounted, engines booted), and arc RETAINS
497
+ * every unsubscribe and invokes it at shutdown BEFORE module `onClose` (while
498
+ * module deps are still alive). Named handlers must be unique across the
499
+ * module graph; a module that declares handlers while the event subsystem is
500
+ * disabled (`arcPlugins.events: false`) fails at boot. Array or factory (the
501
+ * factory runs after bootstraps, so it can close over booted engines).
502
+ *
503
+ * ```ts
504
+ * defineModule({ name: "party", eventHandlers: [
505
+ * { name: "party.link-customer", event: ["customer:created"], handler: onCustomer },
506
+ * ] })
507
+ * ```
508
+ */
509
+ readonly eventHandlers?: ModuleContribution<EventHandlerDefinition>;
510
+ /**
511
+ * Durable workflows this module owns. OPAQUE to arc core — arc never imports
512
+ * `@classytic/streamline`; the value flows through untouched and the
513
+ * streamline integration (`@classytic/arc/integrations/streamline`, a peer)
514
+ * gives it meaning (name/shape validation, registration). Collected via
515
+ * `collectModuleWorkflows` at integration-init time (after module bootstraps),
516
+ * so a factory can close over the shared workflow container the integration
517
+ * decorates on the instance.
518
+ *
519
+ * ```ts
520
+ * defineModule({ name: "invoice",
521
+ * workflows: (f) => createInvoiceWorkflows(f.streamlineContainer) })
522
+ * ```
523
+ */
524
+ readonly workflows?: ModuleContribution<unknown>;
525
+ /**
526
+ * Recurring interval schedules this module owns. Arc composes them into its
527
+ * existing `schedulesPlugin` after bootstraps, in dependency order. Names
528
+ * must be unique across the module graph. Configure multi-replica locking via
529
+ * `arcPlugins.schedules`; explicitly disabling that runner while a module
530
+ * declares schedules fails boot instead of silently dropping work. Array or
531
+ * factory (the factory runs once after bootstraps and may close over engines).
532
+ *
533
+ * ```ts
534
+ * defineModule({ name: "loyalty", scheduledJobs: [
535
+ * { name: "loyalty.point.expiration", every: 3_600_000, handler: () => sweep() },
536
+ * ] })
537
+ * ```
538
+ */
539
+ readonly scheduledJobs?: ModuleContribution<ScheduleDefinition>;
347
540
  /**
348
541
  * Teardown — registered as a Fastify `onClose` hook. Destroy engines, stop
349
542
  * timers, flush the module's outbox. Modules close in REVERSE list order
@@ -376,11 +569,64 @@ interface ArcModule<TExports = unknown> {
376
569
  */
377
570
  type ArcModuleInput<TExports = unknown> = ArcModule<TExports> | Promise<ArcModule<TExports>> | (() => ArcModule<TExports> | Promise<ArcModule<TExports>>);
378
571
  /**
379
- * Resolve any module-input form to a concrete `ArcModule`. A thunk is invoked
380
- * (this is where a dynamic `import()` fires); a promise (or plain module) is
381
- * awaited. Called once per module at the start of the bootstrap phase.
572
+ * Typed module registry — hosts augment this via declaration merging so
573
+ * `getModuleExports(f, "order")` infers the export type without a manual type
574
+ * argument (the fastify / awilix pattern):
575
+ *
576
+ * ```ts
577
+ * declare module "@classytic/arc/factory" {
578
+ * interface ArcModuleRegistry {
579
+ * order: OrderEngine;
580
+ * accounting: AccountingEngine;
581
+ * }
582
+ * }
583
+ * ```
584
+ *
585
+ * Left empty here so the fallback `getModuleExports<T>(f, name: string)` stays
586
+ * available for apps that don't augment it.
382
587
  */
383
- declare function resolveModule(input: ArcModuleInput): Promise<ArcModule>;
588
+ interface ArcModuleRegistry {}
589
+ //#endregion
590
+ //#region src/factory/module/contributions.d.ts
591
+ /**
592
+ * Collect every module's `healthChecks` in the caller's order. Fails at boot
593
+ * on a duplicate check `name` across modules, naming BOTH owning modules.
594
+ * The host's app-level checks are appended AFTER this (modules-first,
595
+ * host-last) by the caller.
596
+ */
597
+ declare function collectModuleHealthChecks(modules: readonly ArcModule[]): HealthCheck[];
598
+ /**
599
+ * Collect every module's `workflows`. Resolves factory contributions (so a
600
+ * factory can close over a container the caller has already decorated on
601
+ * `fastify`) and flattens to a single opaque array. Arc core deliberately
602
+ * does NOT validate or interpret the values — the streamline integration
603
+ * owns name/shape checks and registration. Called by the integration at init
604
+ * time, not by arc's boot pipeline (workflows depend on the integration's
605
+ * container).
606
+ */
607
+ declare function collectModuleWorkflows(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<unknown[]>;
608
+ /**
609
+ * Collect every module's `scheduledJobs`. Resolves factory contributions
610
+ * (after bootstraps) and fails at boot on a duplicate job `name` across
611
+ * modules. The caller passes the returned definitions to the canonical
612
+ * schedules plugin; factories must therefore be resolved only once.
613
+ */
614
+ declare function collectModuleScheduledJobs(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<ScheduleDefinition[]>;
615
+ //#endregion
616
+ //#region src/factory/module/lifecycle.d.ts
617
+ /**
618
+ * Subscribe every module's `eventHandlers` in dependency order (pass the
619
+ * `orderModules`-sorted list). Returns the ordered list of unsubscribe
620
+ * functions so the caller can tear them down at shutdown BEFORE module
621
+ * `onClose` (while module deps are still alive). Fails at boot on:
622
+ * - a duplicate NAMED handler across modules (attributing both owners);
623
+ * - a module declaring handlers while the event subsystem is unavailable.
624
+ * Resolves factory contributions (after bootstraps) so a handler can close over
625
+ * booted engines rather than a global getter.
626
+ */
627
+ declare function subscribeModuleEventHandlers(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<Array<() => void | Promise<void>>>;
628
+ //#endregion
629
+ //#region src/factory/module/order.d.ts
384
630
  /**
385
631
  * Order modules for composition by their `dependsOn` edges — a STABLE
386
632
  * topological sort. Called once at the start of the bootstrap phase; every
@@ -400,24 +646,18 @@ declare function resolveModule(input: ArcModuleInput): Promise<ArcModule>;
400
646
  * - a dependency cycle (reports the concrete `a → b → … → a` path)
401
647
  */
402
648
  declare function orderModules(modules: readonly ArcModule[]): ArcModule[];
649
+ //#endregion
650
+ //#region src/factory/module/resolve.d.ts
403
651
  /**
404
- * Typed module registry — hosts augment this via declaration merging so
405
- * `getModuleExports(f, "order")` infers the export type without a manual type
406
- * argument (the fastify / awilix pattern):
407
- *
408
- * ```ts
409
- * declare module "@classytic/arc/factory" {
410
- * interface ArcModuleRegistry {
411
- * order: OrderEngine;
412
- * accounting: AccountingEngine;
413
- * }
414
- * }
415
- * ```
416
- *
417
- * Left empty here so the fallback `getModuleExports<T>(f, name: string)` stays
418
- * available for apps that don't augment it.
652
+ * Resolve any module-input form to a concrete `ArcModule`. A thunk is invoked
653
+ * (this is where a dynamic `import()` fires); a promise (or plain module) is
654
+ * awaited. Called once per module at the start of the bootstrap phase.
419
655
  */
420
- interface ArcModuleRegistry {}
656
+ declare function resolveModule(input: ArcModuleInput): Promise<ArcModule>;
657
+ /** Resolve a `ModuleContribution` to a concrete array (array passthrough or factory call). */
658
+ declare function resolveContribution<T>(contribution: ModuleContribution<T> | undefined, fastify: FastifyInstance): Promise<readonly T[]>;
659
+ //#endregion
660
+ //#region src/factory/module/index.d.ts
421
661
  /**
422
662
  * Identity helper for authoring a typed module — mirrors `defineResource`.
423
663
  * Gives inference + a single obvious construction site; does no work.
@@ -451,4 +691,4 @@ declare function defineModule<TExports = unknown>(module: ArcModule<TExports>):
451
691
  declare function getModuleExports<K extends keyof ArcModuleRegistry>(fastify: FastifyInstance, name: K): ArcModuleRegistry[K];
452
692
  declare function getModuleExports<TExports = unknown>(fastify: FastifyInstance, name: string): TExports;
453
693
  //#endregion
454
- export { getModuleExports as a, LoadResourcesOptions as c, loadResources as d, defineModule as i, ResourceLike as l, ArcModuleInput as n, orderModules as o, ArcModuleRegistry as r, resolveModule as s, ArcModule as t, ResourceModule as u };
694
+ export { schedulesPlugin as C, healthPlugin as D, _default$1 as E, _default as S, HealthOptions as T, ResourceModule as _, orderModules as a, ScheduleStats as b, collectModuleScheduledJobs as c, ArcModuleInput as d, ArcModuleRegistry as f, ResourceLike as g, LoadResourcesOptions as h, resolveModule as i, collectModuleWorkflows as l, ModuleContribution as m, getModuleExports as n, subscribeModuleEventHandlers as o, EventHandlerDefinition as p, resolveContribution as r, collectModuleHealthChecks as s, defineModule as t, ArcModule as u, loadResources as v, HealthCheck as w, SchedulesPluginOptions as x, ScheduleDefinition as y };
@@ -1,7 +1,7 @@
1
- import { C as RequestContext, Et as ActionDefinition, F as FastifyWithDecorators, H as CrudController, Jt as AnyRecord, L as RequestWithExtras, Lt as IController, Rt as IControllerResponse, T as CrudRouterOptions, U as ResourceConfig, V as ResourceDefinition, et as RouteSchemaOptions, jt as RouteMcpConfig, tt as ArcFieldRule, ut as AggregationConfig, zt as IRequestContext } from "./index-BBsvQt7U.mjs";
2
- import { i as RequestScope } from "./types-DH0GupI7.mjs";
3
- import { t as PermissionCheck } from "./types-Csxga7d3.mjs";
4
- import "./fastify-augmentation-g_f9omSc.mjs";
1
+ import { C as RequestContext, Et as ActionDefinition, F as FastifyWithDecorators, H as CrudController, L as RequestWithExtras, Lt as IController, Rt as IControllerResponse, T as CrudRouterOptions, U as ResourceConfig, V as ResourceDefinition, et as RouteSchemaOptions, jt as RouteMcpConfig, tt as ArcFieldRule, ut as AggregationConfig, zt as IRequestContext } from "./index-DPRH0Cme.mjs";
2
+ import { i as RequestScope } from "./types-DjC-KUCz.mjs";
3
+ import { c as AnyRecord, t as PermissionCheck } from "./types-Dmw-6Qeo.mjs";
4
+ import "./fastify-augmentation-dPNBVeIj.mjs";
5
5
  import { FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
6
6
  import { z } from "zod";
7
7
  import { DataAdapter } from "@classytic/repo-core/adapter";
@@ -425,4 +425,36 @@ declare function isFieldReadable(rule: ArcFieldRule | undefined): boolean;
425
425
  */
426
426
  declare function collectReadBlockedFields(schemaOptions: RouteSchemaOptions | undefined): Set<string> | null;
427
427
  //#endregion
428
- export { HOOK_OPERATIONS as A, SYSTEM_FIELDS as B, CrudOperation as C, DEFAULT_SORT as D, DEFAULT_MAX_LIMIT as E, MAX_REGEX_LENGTH as F, MAX_SEARCH_LENGTH as I, MUTATION_OPERATIONS as L, HookOperation as M, HookPhase as N, DEFAULT_TENANT_FIELD as O, MAX_FILTER_DEPTH as P, MutationOperation as R, CRUD_OPERATIONS as S, DEFAULT_LIMIT as T, DefineActionConfig as _, createRequestContext as a, createPermissionMiddleware as b, sendControllerResponse as c, getEntityQuery as d, defineResourceVariants as f, mergeResourceConfig as g, SeamedResourceConfig as h, createFastifyHandler as i, HOOK_PHASES as j, DEFAULT_UPDATE_METHOD as k, getEntityId as l, ResourceSeams as m, isFieldReadable as n, getControllerContext as o, AdapterLike as p, createCrudHandlers as r, getControllerScope as s, collectReadBlockedFields as t, getEntityIdField as u, defineAction as v, DEFAULT_ID_FIELD as w, defineAggregation as x, createCrudRouter as y, RESERVED_QUERY_PARAMS as z };
428
+ //#region src/core/validateResourceConfig.d.ts
429
+ interface ConfigError {
430
+ field: string;
431
+ message: string;
432
+ suggestion?: string;
433
+ }
434
+ interface ValidationResult {
435
+ valid: boolean;
436
+ errors: ConfigError[];
437
+ warnings: ConfigError[];
438
+ }
439
+ interface ValidateOptions {
440
+ /** Skip controller method validation (for testing) */
441
+ skipControllerCheck?: boolean;
442
+ /** Allow unknown preset names */
443
+ allowUnknownPresets?: boolean;
444
+ /** Custom valid permission keys beyond CRUD */
445
+ additionalPermissionKeys?: string[];
446
+ }
447
+ /**
448
+ * Validate a resource configuration
449
+ */
450
+ declare function validateResourceConfig(config: ResourceConfig, options?: ValidateOptions): ValidationResult;
451
+ /**
452
+ * Format validation errors for display
453
+ */
454
+ declare function formatValidationErrors(resourceName: string, result: ValidationResult): string;
455
+ /**
456
+ * Validate and throw if invalid
457
+ */
458
+ declare function assertValidConfig(config: ResourceConfig, options?: ValidateOptions): void;
459
+ //#endregion
460
+ export { DEFAULT_ID_FIELD as A, MAX_FILTER_DEPTH as B, DefineActionConfig as C, defineAggregation as D, createPermissionMiddleware as E, DEFAULT_UPDATE_METHOD as F, RESERVED_QUERY_PARAMS as G, MAX_SEARCH_LENGTH as H, HOOK_OPERATIONS as I, SYSTEM_FIELDS as K, HOOK_PHASES as L, DEFAULT_MAX_LIMIT as M, DEFAULT_SORT as N, CRUD_OPERATIONS as O, DEFAULT_TENANT_FIELD as P, HookOperation as R, mergeResourceConfig as S, createCrudRouter as T, MUTATION_OPERATIONS as U, MAX_REGEX_LENGTH as V, MutationOperation as W, getEntityQuery as _, formatValidationErrors as a, ResourceSeams as b, isFieldReadable as c, createRequestContext as d, getControllerContext as f, getEntityIdField as g, getEntityId as h, assertValidConfig as i, DEFAULT_LIMIT as j, CrudOperation as k, createCrudHandlers as l, sendControllerResponse as m, ValidateOptions as n, validateResourceConfig as o, getControllerScope as p, ValidationResult as r, collectReadBlockedFields as s, ConfigError as t, createFastifyHandler as u, defineResourceVariants as v, defineAction as w, SeamedResourceConfig as x, AdapterLike as y, HookPhase as z };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- import { A as RequestIdOptions, B as defineResource, Bt as RouteHandler, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, Fn as ArcUpdateResult, Ft as ControllerLike, H as CrudController, In as BaseControllerOptions, Jt as AnyRecord, L as RequestWithExtras, Ln as ControllerConfigurableOptions, Lt as IController, Mn as ArcDeleteResult, N as FastifyRequestExtras, Nn as ArcGetResult, Nt as RateLimitConfig, O as HealthOptions, P as FastifyWithAuth, Pn as ArcListResult, Q as MiddlewareConfig, Rn as ControllerConstructionOptions, Rt as IControllerResponse, S as QueryParserInterface, T as CrudRouterOptions, U as ResourceConfig, Ut as AuthPluginOptions, V as ResourceDefinition, X as CrudRouteKey, Xt as ArcRequest, Y as PresetResult, Yt as ApiResponse, Z as CrudSchemas, Zt as JWTPayload, a as InferAdapterDoc, an as TreeMixin, c as TypedController, cn as BulkExt, ct as AggMeasureShorthand, d as PaginationResult, dt as AggregationDateRangeRequirement, en as UserOrganization, et as RouteSchemaOptions, f as IntrospectionData, ft as AggregationIndexHint, g as ArcInternalMetadata, gt as AggregationsMap, h as ResourceMetadata, ht as AggregationRateLimit, i as ValidationResult, in as TreeExt, jn as ArcCreateResult, k as IntrospectionPluginOptions, l as TypedRepository, ln as BulkMixin, lt as AggregationCacheConfig, m as RegistryStats, mt as AggregationMaterializedResult, n as ConfigError, nn as SoftDeleteExt, nt as FieldRule, o as InferDocType, on as SlugExt, ot as EventDefinition, p as RegistryEntry, pt as AggregationMaterializedContext, q as PresetFunction, r as ValidateOptions, rn as SoftDeleteMixin, s as InferResourceDoc, sn as SlugMixin, st as AggMeasureInput, t as RouteHandlerMethod, tn as BaseController, u as TypedResourceConfig, un as BaseCrudController, ut as AggregationConfig, w as ServiceContext, y as OwnershipCheck, zn as ListResult, zt as IRequestContext } from "./index-BBsvQt7U.mjs";
2
- import { i as UserBase, n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "./types-Csxga7d3.mjs";
1
+ import { $t as SlugExt, A as RequestIdOptions, An as ControllerConfigurableOptions, B as defineResource, Bt as RouteHandler, C as RequestContext, D as HealthCheck, Dn as ArcListResult, E as GracefulShutdownOptions, En as ArcGetResult, F as FastifyWithDecorators, Ft as ControllerLike, H as CrudController, Jt as BaseController, L as RequestWithExtras, Lt as IController, Mn as ListResult, N as FastifyRequestExtras, Nt as RateLimitConfig, O as HealthOptions, On as ArcUpdateResult, P as FastifyWithAuth, Q as MiddlewareConfig, Qt as TreeMixin, Rt as IControllerResponse, S as QueryParserInterface, T as CrudRouterOptions, Tn as ArcDeleteResult, U as ResourceConfig, Ut as AuthPluginOptions, V as ResourceDefinition, X as CrudRouteKey, Xt as SoftDeleteMixin, Y as PresetResult, Yt as SoftDeleteExt, Z as CrudSchemas, Zt as TreeExt, a as InferAdapterDoc, c as TypedController, ct as AggMeasureShorthand, d as PaginationResult, dt as AggregationDateRangeRequirement, en as SlugMixin, et as RouteSchemaOptions, f as IntrospectionData, ft as AggregationIndexHint, g as ArcInternalMetadata, gt as AggregationsMap, h as ResourceMetadata, ht as AggregationRateLimit, i as ValidationResult, jn as ControllerConstructionOptions, k as IntrospectionPluginOptions, kn as BaseControllerOptions, l as TypedRepository, lt as AggregationCacheConfig, m as RegistryStats, mt as AggregationMaterializedResult, n as ConfigError, nn as BulkMixin, nt as FieldRule, o as InferDocType, ot as EventDefinition, p as RegistryEntry, pt as AggregationMaterializedContext, q as PresetFunction, r as ValidateOptions, rn as BaseCrudController, s as InferResourceDoc, st as AggMeasureInput, t as RouteHandlerMethod, tn as BulkExt, u as TypedResourceConfig, ut as AggregationConfig, w as ServiceContext, wn as ArcCreateResult, y as OwnershipCheck, zt as IRequestContext } from "./index-DPRH0Cme.mjs";
2
+ import { c as AnyRecord, i as UserBase, l as ArcRequest, n as PermissionContext, p as UserOrganization, r as PermissionResult, t as PermissionCheck, u as JWTPayload } from "./types-Dmw-6Qeo.mjs";
3
3
  import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, t as FieldPermission } from "./fields-D3lhgzhD.mjs";
4
- import "./fastify-augmentation-g_f9omSc.mjs";
5
- import { A as HOOK_OPERATIONS, B as SYSTEM_FIELDS, C as CrudOperation, D as DEFAULT_SORT, E as DEFAULT_MAX_LIMIT, F as MAX_REGEX_LENGTH, I as MAX_SEARCH_LENGTH, L as MUTATION_OPERATIONS, M as HookOperation, N as HookPhase, O as DEFAULT_TENANT_FIELD, P as MAX_FILTER_DEPTH, R as MutationOperation, S as CRUD_OPERATIONS, T as DEFAULT_LIMIT, f as defineResourceVariants, g as mergeResourceConfig, h as SeamedResourceConfig, j as HOOK_PHASES, k as DEFAULT_UPDATE_METHOD, m as ResourceSeams, p as AdapterLike, s as getControllerScope, v as defineAction, w as DEFAULT_ID_FIELD, x as defineAggregation, z as RESERVED_QUERY_PARAMS } from "./index-CC5ruDGh.mjs";
6
- import { A as allOf, E as DynamicPermissionMatrixConfig, F as requireAuth, I as requireOwnership, L as requireRoles, M as anyOf, N as denyAll, O as createDynamicPermissionMatrix, T as DynamicPermissionMatrix, c as publicReadAdminWrite, d as requireOrgMembership, f as requireOrgRole, h as requireTeamMembership, i as ownerWithAdminBypass, j as allowPublic, k as createOrgPermissions, l as readOnly, m as requireServiceScope, n as authenticated, o as presets_d_exports, p as requireScopeContext, r as fullPublic, s as publicRead, t as adminOnly, u as requireOrgInScope, z as when } from "./index-wMoWBLkn.mjs";
4
+ import "./fastify-augmentation-dPNBVeIj.mjs";
5
+ import { A as DEFAULT_ID_FIELD, B as MAX_FILTER_DEPTH, D as defineAggregation, F as DEFAULT_UPDATE_METHOD, G as RESERVED_QUERY_PARAMS, H as MAX_SEARCH_LENGTH, I as HOOK_OPERATIONS, K as SYSTEM_FIELDS, L as HOOK_PHASES, M as DEFAULT_MAX_LIMIT, N as DEFAULT_SORT, O as CRUD_OPERATIONS, P as DEFAULT_TENANT_FIELD, R as HookOperation, S as mergeResourceConfig, U as MUTATION_OPERATIONS, V as MAX_REGEX_LENGTH, W as MutationOperation, b as ResourceSeams, j as DEFAULT_LIMIT, k as CrudOperation, p as getControllerScope, v as defineResourceVariants, w as defineAction, x as SeamedResourceConfig, y as AdapterLike, z as HookPhase } from "./index-f4PTrk3B.mjs";
6
+ import { A as allOf, E as DynamicPermissionMatrixConfig, F as requireAuth, I as requireOwnership, L as requireRoles, M as anyOf, N as denyAll, O as createDynamicPermissionMatrix, T as DynamicPermissionMatrix, c as publicReadAdminWrite, d as requireOrgMembership, f as requireOrgRole, h as requireTeamMembership, i as ownerWithAdminBypass, j as allowPublic, k as createOrgPermissions, l as readOnly, m as requireServiceScope, n as authenticated, o as presets_d_exports, p as requireScopeContext, r as fullPublic, s as publicRead, t as adminOnly, u as requireOrgInScope, z as when } from "./index-BMnbzvtO.mjs";
7
7
  import { a as NotFoundError, d as ValidationError, f as createDomainError, i as ForbiddenError, t as ArcError, u as UnauthorizedError } from "./errors-DHcHVAgk.mjs";
8
8
  //#region src/index.d.ts
9
9
  declare const version: string;
10
10
  //#endregion
11
- export { type AdapterLike, type AggMeasureInput, type AggMeasureShorthand, type AggregationCacheConfig, type AggregationConfig, type AggregationDateRangeRequirement, type AggregationIndexHint, type AggregationMaterializedContext, type AggregationMaterializedResult, type AggregationRateLimit, type AggregationsMap, type AnyRecord, type ApiResponse, type ArcCreateResult, type ArcDeleteResult, ArcError, type ArcGetResult, type ArcInternalMetadata, type ArcListResult, type ArcRequest, type ArcUpdateResult, type AuthPluginOptions, BaseController, type BaseControllerOptions, BaseCrudController, type BulkExt, BulkMixin, CRUD_OPERATIONS, type ConfigError, type ControllerConfigurableOptions, type ControllerConstructionOptions, type ControllerLike, type CrudController, type CrudOperation, type CrudRouteKey, type CrudRouterOptions, type CrudSchemas, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, type DynamicPermissionMatrix, type DynamicPermissionMatrixConfig, type EventDefinition, type FastifyRequestExtras, type FastifyWithAuth, type FastifyWithDecorators, type FieldPermission, type FieldPermissionMap, type FieldRule, ForbiddenError, type GracefulShutdownOptions, HOOK_OPERATIONS, HOOK_PHASES, type HealthCheck, type HealthOptions, type HookOperation, type HookPhase, type IController, type IControllerResponse, type IRequestContext, type InferAdapterDoc, type InferDocType, type InferResourceDoc, type IntrospectionData, type IntrospectionPluginOptions, type JWTPayload, type ListResult, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, type MiddlewareConfig, type MutationOperation, NotFoundError, type OwnershipCheck, type PaginationResult, type PermissionCheck, type PermissionContext, type PermissionResult, type PresetFunction, type PresetResult, type QueryParserInterface, RESERVED_QUERY_PARAMS, type RateLimitConfig, type RegistryEntry, type RegistryStats, type RequestContext, type RequestIdOptions, type RequestWithExtras, type ResourceConfig, ResourceDefinition, type ResourceMetadata, type ResourceSeams, type RouteHandler, type RouteHandlerMethod, type RouteSchemaOptions, SYSTEM_FIELDS, type SeamedResourceConfig, type ServiceContext, type SlugExt, SlugMixin, type SoftDeleteExt, SoftDeleteMixin, type TreeExt, TreeMixin, type TypedController, type TypedRepository, type TypedResourceConfig, UnauthorizedError, type UserBase, type UserOrganization, type ValidateOptions, ValidationError, type ValidationResult, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, mergeResourceConfig, ownerWithAdminBypass, presets_d_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
11
+ export { type AdapterLike, type AggMeasureInput, type AggMeasureShorthand, type AggregationCacheConfig, type AggregationConfig, type AggregationDateRangeRequirement, type AggregationIndexHint, type AggregationMaterializedContext, type AggregationMaterializedResult, type AggregationRateLimit, type AggregationsMap, type AnyRecord, type ArcCreateResult, type ArcDeleteResult, ArcError, type ArcGetResult, type ArcInternalMetadata, type ArcListResult, type ArcRequest, type ArcUpdateResult, type AuthPluginOptions, BaseController, type BaseControllerOptions, BaseCrudController, type BulkExt, BulkMixin, CRUD_OPERATIONS, type ConfigError, type ControllerConfigurableOptions, type ControllerConstructionOptions, type ControllerLike, type CrudController, type CrudOperation, type CrudRouteKey, type CrudRouterOptions, type CrudSchemas, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, type DynamicPermissionMatrix, type DynamicPermissionMatrixConfig, type EventDefinition, type FastifyRequestExtras, type FastifyWithAuth, type FastifyWithDecorators, type FieldPermission, type FieldPermissionMap, type FieldRule, ForbiddenError, type GracefulShutdownOptions, HOOK_OPERATIONS, HOOK_PHASES, type HealthCheck, type HealthOptions, type HookOperation, type HookPhase, type IController, type IControllerResponse, type IRequestContext, type InferAdapterDoc, type InferDocType, type InferResourceDoc, type IntrospectionData, type IntrospectionPluginOptions, type JWTPayload, type ListResult, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, type MiddlewareConfig, type MutationOperation, NotFoundError, type OwnershipCheck, type PaginationResult, type PermissionCheck, type PermissionContext, type PermissionResult, type PresetFunction, type PresetResult, type QueryParserInterface, RESERVED_QUERY_PARAMS, type RateLimitConfig, type RegistryEntry, type RegistryStats, type RequestContext, type RequestIdOptions, type RequestWithExtras, type ResourceConfig, ResourceDefinition, type ResourceMetadata, type ResourceSeams, type RouteHandler, type RouteHandlerMethod, type RouteSchemaOptions, SYSTEM_FIELDS, type SeamedResourceConfig, type ServiceContext, type SlugExt, SlugMixin, type SoftDeleteExt, SoftDeleteMixin, type TreeExt, TreeMixin, type TypedController, type TypedRepository, type TypedResourceConfig, UnauthorizedError, type UserBase, type UserOrganization, type ValidateOptions, ValidationError, type ValidationResult, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, mergeResourceConfig, ownerWithAdminBypass, presets_d_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { a as DEFAULT_SORT, c as HOOK_OPERATIONS, d as MAX_REGEX_LENGTH, f as MAX_SEARCH_LENGTH, h as SYSTEM_FIELDS, i as DEFAULT_MAX_LIMIT, l as HOOK_PHASES, m as RESERVED_QUERY_PARAMS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MUTATION_OPERATIONS, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as MAX_FILTER_DEPTH } from "./constants-DNre0wRg.mjs";
2
2
  import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-DkO8Nk6-.mjs";
3
- import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-BQ8KNvWC.mjs";
3
+ import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController--M8EMzt0.mjs";
4
4
  import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, o as fields } from "./applyPermissionResult-Tw4iXtlf.mjs";
5
- import { a as defineResource, c as defineAction, d as defineAggregation, i as defineResourceVariants, o as ResourceDefinition, s as mergeResourceConfig } from "./core-DQ6rDTyH.mjs";
6
- import { C as allowPublic, D as requireAuth, O as requireOwnership, S as allOf, T as denyAll, _ as requireOrgMembership, b as requireServiceScope, c as publicReadAdminWrite, g as requireOrgInScope, h as createOrgPermissions, i as ownerWithAdminBypass, j as when, k as requireRoles, l as readOnly, m as createDynamicPermissionMatrix, n as authenticated, o as presets_exports, r as fullPublic, s as publicRead, t as adminOnly, v as requireOrgRole, w as anyOf, x as requireTeamMembership, y as requireScopeContext } from "./permissions-tbxFHxjZ.mjs";
7
- import { l as getControllerScope } from "./actionPermissions-lszoJle1.mjs";
5
+ import { a as defineResource, d as defineAction, i as defineResourceVariants, l as ResourceDefinition, m as defineAggregation, u as mergeResourceConfig } from "./core-EUNu0u07.mjs";
6
+ import { c as getControllerScope } from "./pipeline-BN5G05rd.mjs";
7
+ import { A as requireAuth, D as anyOf, E as allowPublic, M as requireRoles, O as denyAll, P as when, T as allOf, _ as requireOrgMembership, b as requireServiceScope, c as publicReadAdminWrite, g as requireOrgInScope, h as createOrgPermissions, i as ownerWithAdminBypass, j as requireOwnership, l as readOnly, m as createDynamicPermissionMatrix, n as authenticated, o as presets_exports, r as fullPublic, s as publicRead, t as adminOnly, v as requireOrgRole, x as requireTeamMembership, y as requireScopeContext } from "./permissions-BrtiBKGs.mjs";
8
8
  //#region src/index.ts
9
- const version = "2.23.0";
9
+ const version = "2.25.0";
10
10
  //#endregion
11
11
  export { ArcError, BaseController, BaseCrudController, BulkMixin, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, ForbiddenError, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, NotFoundError, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, mergeResourceConfig, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };