@classytic/arc 2.10.8 → 2.11.1

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 (136) hide show
  1. package/dist/{BaseController-DVNKvoX4.mjs → BaseController-JNV08qOT.mjs} +480 -442
  2. package/dist/{queryCachePlugin-Dumka73q.d.mts → QueryCache-DOBNHBE0.d.mts} +2 -32
  3. package/dist/adapters/index.d.mts +2 -2
  4. package/dist/adapters/index.mjs +1 -1
  5. package/dist/{adapters-BXY4i-hw.mjs → adapters-D0tT2Tyo.mjs} +54 -0
  6. package/dist/audit/index.d.mts +1 -1
  7. package/dist/auth/index.d.mts +1 -1
  8. package/dist/auth/index.mjs +5 -5
  9. package/dist/{betterAuthOpenApi--rdY15Ld.mjs → betterAuthOpenApi-DwxtK3uG.mjs} +1 -1
  10. package/dist/cache/index.d.mts +3 -2
  11. package/dist/cache/index.mjs +3 -3
  12. package/dist/cli/commands/docs.mjs +2 -2
  13. package/dist/cli/commands/generate.mjs +37 -27
  14. package/dist/cli/commands/init.mjs +46 -33
  15. package/dist/cli/commands/introspect.mjs +1 -1
  16. package/dist/context/index.mjs +1 -1
  17. package/dist/core/index.d.mts +3 -3
  18. package/dist/core/index.mjs +4 -3
  19. package/dist/core-DXdSSFW-.mjs +1037 -0
  20. package/dist/createActionRouter-BwaSM0No.mjs +166 -0
  21. package/dist/{createApp-BwnEAO2h.mjs → createApp-P1d6rjPy.mjs} +75 -27
  22. package/dist/docs/index.d.mts +1 -1
  23. package/dist/docs/index.mjs +2 -2
  24. package/dist/{elevation-Dci0AYLT.mjs → elevation-DOFoxoDs.mjs} +1 -1
  25. package/dist/{errorHandler-CSxe7KIM.mjs → errorHandler-BQm8ZxTK.mjs} +1 -1
  26. package/dist/{eventPlugin-ByU4Cv0e.mjs → eventPlugin--5HIkdPU.mjs} +1 -1
  27. package/dist/events/index.d.mts +3 -3
  28. package/dist/events/index.mjs +2 -2
  29. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  30. package/dist/factory/index.d.mts +2 -2
  31. package/dist/factory/index.mjs +2 -2
  32. package/dist/hooks/index.d.mts +1 -1
  33. package/dist/hooks/index.mjs +1 -1
  34. package/dist/idempotency/index.d.mts +3 -3
  35. package/dist/idempotency/index.mjs +1 -1
  36. package/dist/idempotency/redis.d.mts +1 -1
  37. package/dist/{index-C_Noptz-.d.mts → index-BYCqHCVu.d.mts} +2 -2
  38. package/dist/{index-BGbpGVyM.d.mts → index-C_bgx9o4.d.mts} +712 -500
  39. package/dist/{index-BziRPS4H.d.mts → index-CvM1e09j.d.mts} +29 -10
  40. package/dist/{index-EqQN6p0W.d.mts → index-pUczGjO0.d.mts} +11 -8
  41. package/dist/index-smCAoA5W.d.mts +1179 -0
  42. package/dist/index.d.mts +6 -38
  43. package/dist/index.mjs +9 -9
  44. package/dist/integrations/event-gateway.d.mts +1 -1
  45. package/dist/integrations/event-gateway.mjs +1 -1
  46. package/dist/integrations/index.d.mts +2 -2
  47. package/dist/integrations/mcp/index.d.mts +2 -2
  48. package/dist/integrations/mcp/index.mjs +1 -1
  49. package/dist/integrations/mcp/testing.d.mts +1 -1
  50. package/dist/integrations/mcp/testing.mjs +1 -1
  51. package/dist/integrations/streamline.d.mts +46 -5
  52. package/dist/integrations/streamline.mjs +50 -21
  53. package/dist/integrations/websocket-redis.d.mts +1 -1
  54. package/dist/integrations/websocket.d.mts +2 -154
  55. package/dist/integrations/websocket.mjs +292 -224
  56. package/dist/{keys-nWQGUTu1.mjs → keys-CARyUjiR.mjs} +2 -0
  57. package/dist/{loadResources-Bksk8ydA.mjs → loadResources-CPpkyKfM.mjs} +32 -8
  58. package/dist/middleware/index.d.mts +1 -1
  59. package/dist/middleware/index.mjs +1 -1
  60. package/dist/{openapi-DpNpqBmo.mjs → openapi-C0L9ar7m.mjs} +4 -4
  61. package/dist/org/index.d.mts +1 -1
  62. package/dist/permissions/index.d.mts +1 -1
  63. package/dist/permissions/index.mjs +2 -4
  64. package/dist/{permissions-wkqRwicB.mjs → permissions-B4vU9L0Q.mjs} +221 -3
  65. package/dist/{pipe-CGJxqDGx.mjs → pipe-DVoIheVC.mjs} +1 -1
  66. package/dist/pipeline/index.d.mts +1 -1
  67. package/dist/pipeline/index.mjs +1 -1
  68. package/dist/plugins/index.d.mts +4 -4
  69. package/dist/plugins/index.mjs +10 -10
  70. package/dist/plugins/response-cache.mjs +1 -1
  71. package/dist/plugins/tracing-entry.d.mts +1 -1
  72. package/dist/plugins/tracing-entry.mjs +42 -24
  73. package/dist/presets/filesUpload.d.mts +1 -1
  74. package/dist/presets/filesUpload.mjs +3 -3
  75. package/dist/presets/index.d.mts +1 -1
  76. package/dist/presets/index.mjs +1 -1
  77. package/dist/presets/multiTenant.d.mts +1 -1
  78. package/dist/presets/multiTenant.mjs +6 -0
  79. package/dist/presets/search.d.mts +1 -1
  80. package/dist/presets/search.mjs +1 -1
  81. package/dist/{presets-CrwOvuXI.mjs → presets-k604Lj99.mjs} +1 -1
  82. package/dist/queryCachePlugin-BUXBSm4F.d.mts +34 -0
  83. package/dist/{queryCachePlugin-ChLNZvFT.mjs → queryCachePlugin-Bq6bO6vc.mjs} +3 -3
  84. package/dist/{redis-MXLp1oOf.d.mts → redis-Cm1gnRDf.d.mts} +1 -1
  85. package/dist/registry/index.d.mts +1 -1
  86. package/dist/registry/index.mjs +2 -2
  87. package/dist/{resourceToTools-BhF3JV5p.mjs → resourceToTools--okX6QBr.mjs} +534 -420
  88. package/dist/routerShared-DeESFp4a.mjs +515 -0
  89. package/dist/schemaIR-BlG9bY7v.mjs +137 -0
  90. package/dist/scope/index.mjs +2 -2
  91. package/dist/testing/index.d.mts +367 -711
  92. package/dist/testing/index.mjs +637 -1434
  93. package/dist/{tracing-xqXzWeaf.d.mts → tracing-DokiEsuz.d.mts} +9 -4
  94. package/dist/types/index.d.mts +3 -3
  95. package/dist/types/index.mjs +1 -3
  96. package/dist/{types-CVdgPXBW.d.mts → types-BdA4uMBV.d.mts} +191 -28
  97. package/dist/{types-CVKBssX5.d.mts → types-Bh_gEJBi.d.mts} +1 -1
  98. package/dist/utils/index.d.mts +2 -968
  99. package/dist/utils/index.mjs +5 -6
  100. package/dist/utils-D3Yxnrwr.mjs +1639 -0
  101. package/dist/websocket-CyJ1VIFI.d.mts +186 -0
  102. package/package.json +7 -5
  103. package/skills/arc/SKILL.md +124 -39
  104. package/skills/arc/references/testing.md +212 -183
  105. package/dist/applyPermissionResult-QhV1Pa-g.mjs +0 -37
  106. package/dist/core-3MWJosCH.mjs +0 -1459
  107. package/dist/createActionRouter-C8UUB3Px.mjs +0 -249
  108. package/dist/errors-BI8kEKsO.d.mts +0 -140
  109. package/dist/fields-CTMWOUDt.mjs +0 -126
  110. package/dist/queryParser-NR__Qiju.mjs +0 -419
  111. package/dist/types-CDnTEpga.mjs +0 -27
  112. package/dist/utils-LMwVidKy.mjs +0 -947
  113. /package/dist/{HookSystem-BjFu7zf1.mjs → HookSystem-CGsMd6oK.mjs} +0 -0
  114. /package/dist/{ResourceRegistry-CcN2LVrc.mjs → ResourceRegistry-DkAeAuTX.mjs} +0 -0
  115. /package/dist/{actionPermissions-TUVR3uiZ.mjs → actionPermissions-C8YYU92K.mjs} +0 -0
  116. /package/dist/{caching-3h93rkJM.mjs → caching-CheW3m-S.mjs} +0 -0
  117. /package/dist/{errorHandler-2ii4RIYr.d.mts → errorHandler-Co3lnVmJ.d.mts} +0 -0
  118. /package/dist/{errors-BqdUDja_.mjs → errors-D5c-5BJL.mjs} +0 -0
  119. /package/dist/{eventPlugin-D1ThQ1Pp.d.mts → eventPlugin-CUNjYYRY.d.mts} +0 -0
  120. /package/dist/{interface-B-pe8fhj.d.mts → interface-CkkWm5uR.d.mts} +0 -0
  121. /package/dist/{interface-yhyb_pLY.d.mts → interface-Da0r7Lna.d.mts} +0 -0
  122. /package/dist/{memory-DqI-449b.mjs → memory-DikHSvWa.mjs} +0 -0
  123. /package/dist/{metrics-TuOmguhi.mjs → metrics-Csh4nsvv.mjs} +0 -0
  124. /package/dist/{multipartBody-CUQGVlM_.mjs → multipartBody-CvTR1Un6.mjs} +0 -0
  125. /package/dist/{pluralize-CWP6MB39.mjs → pluralize-BneOJkpi.mjs} +0 -0
  126. /package/dist/{redis-stream-bkO88VHx.d.mts → redis-stream-CM8TXTix.d.mts} +0 -0
  127. /package/dist/{registry-B0Wl7uVV.mjs → registry-D63ee7fl.mjs} +0 -0
  128. /package/dist/{replyHelpers-BLojtuvR.mjs → replyHelpers-ByllIXXV.mjs} +0 -0
  129. /package/dist/{requestContext-C38GskNt.mjs → requestContext-CfRkaxwf.mjs} +0 -0
  130. /package/dist/{schemaConverter-BxFDdtXu.mjs → schemaConverter-B0oKLuqI.mjs} +0 -0
  131. /package/dist/{sse-D8UeDwis.mjs → sse-V7aXc3bW.mjs} +0 -0
  132. /package/dist/{store-helpers-DYYUQbQN.mjs → store-helpers-BhrzxvyQ.mjs} +0 -0
  133. /package/dist/{typeGuards-Cj5Rgvlg.mjs → typeGuards-CcFZXgU7.mjs} +0 -0
  134. /package/dist/{types-D57iXYb8.mjs → types-DV9WDfeg.mjs} +0 -0
  135. /package/dist/{versioning-B6mimogM.mjs → versioning-CGPjkqAg.mjs} +0 -0
  136. /package/dist/{versioning-CeUXHfjw.d.mts → versioning-M9lNLhO8.d.mts} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { FastifyInstance, FastifyRequest } from "fastify";
2
+ import { Span, Tracer } from "@opentelemetry/api";
2
3
 
3
4
  //#region src/plugins/tracing.d.ts
4
5
  interface TracingOptions {
@@ -28,8 +29,8 @@ interface TracingOptions {
28
29
  sampleRate?: number;
29
30
  }
30
31
  interface TracerContext {
31
- tracer: any;
32
- currentSpan: any;
32
+ tracer: Tracer;
33
+ currentSpan: Span;
33
34
  }
34
35
  declare module "fastify" {
35
36
  interface FastifyRequest {
@@ -53,7 +54,7 @@ declare function tracingPlugin(fastify: FastifyInstance, options?: TracingOption
53
54
  * });
54
55
  * }
55
56
  */
56
- declare function createSpan<T>(request: FastifyRequest, name: string, fn: (span: any) => Promise<T>, attributes?: Record<string, any>): Promise<T>;
57
+ declare function createSpan<T>(request: FastifyRequest, name: string, fn: (span: Span | null) => Promise<T>, attributes?: Record<string, string | number | boolean>): Promise<T>;
57
58
  /**
58
59
  * Decorator to automatically trace repository methods
59
60
  *
@@ -65,7 +66,11 @@ declare function createSpan<T>(request: FastifyRequest, name: string, fn: (span:
65
66
  * }
66
67
  * }
67
68
  */
68
- declare function traced(spanName?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
69
+ declare function traced(spanName?: string): (target: {
70
+ constructor: {
71
+ name: string;
72
+ };
73
+ }, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
69
74
  /**
70
75
  * Check if OpenTelemetry is available
71
76
  */
@@ -1,5 +1,5 @@
1
- import { $t as ObjectId, A as RequestIdOptions, At as FastifyHandler, C as RequestContext, Ct as ResourcePermissions, D as HealthCheck, Dt as RouteSchemaOptions, E as GracefulShutdownOptions, Et as RouteMethod, F as FastifyWithDecorators, Gt as Authenticator, I as MiddlewareHandler, Jt as TokenPair, Kt as AuthenticatorContext, L as RequestWithExtras, M as EventsDecorator, Mt as IControllerResponse, N as FastifyRequestExtras, Nt as IRequestContext, O as HealthOptions, Ot as ControllerHandler, P as FastifyWithAuth, Pt as RouteHandler, Qt as JWTPayload, S as QueryParserInterface, St as ResourceHooks, T as CrudRouterOptions, Tt as RouteMcpConfig, Ut as AuthHelpers, Wt as AuthPluginOptions, Xt as ApiResponse, Yt as AnyRecord, Zt as ArcRequest, _ as ControllerQueryOptions, _t as PresetResult, a as InferAdapterDoc, an as BaseControllerOptions, at as ActionEntry, b as ParsedQuery, bt as ResourceConfig, c as TypedController, ct as CrudController, d as PaginationResult, dt as EventDefinition, en as UserLike, f as IntrospectionData, ft as FieldRule, g as ArcInternalMetadata, gt as PresetHook, h as ResourceMetadata, ht as PresetFunction, i as ValidationResult, it as ActionDefinition, j as ArcDecorator, jt as IController, k as IntrospectionPluginOptions, kt as ControllerLike, l as TypedRepository, lt as CrudRouteKey, m as RegistryStats, mt as OpenApiSchemas, n as ConfigError, nn as envelope, o as InferDocType, ot as ActionHandlerFn, p as RegistryEntry, pt as MiddlewareConfig, qt as JwtContext, r as ValidateOptions, rn as getUserId, s as InferResourceDoc, st as ActionsMap, t as RouteHandlerMethod, tn as UserOrganization, u as TypedResourceConfig, ut as CrudSchemas, v as LookupOption, vt as RateLimitConfig, w as ServiceContext, wt as RouteDefinition, x as PopulateOption, xt as ResourceHookContext, y as OwnershipCheck, yt as ResourceCacheConfig } from "../index-BGbpGVyM.mjs";
2
- import { _ as isAuthenticated, c as getOrgRoles, g as hasOrgAccess, n as PUBLIC_SCOPE, p as getTeamId, r as RequestScope, s as getOrgId, t as AUTHENTICATED_SCOPE, v as isElevated, y as isMember } from "../types-tgR4Pt8F.mjs";
1
+ import { $ as OpenApiSchemas, A as RequestIdOptions, At as Authenticator, Bt as UserOrganization, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, Ft as ApiResponse, G as ActionsMap, H as ActionDefinition, I as MiddlewareHandler, It as ArcRequest, J as CrudRouteKey, K as ArcFieldRule, L as RequestWithExtras, Lt as JWTPayload, M as EventsDecorator, Mt as JwtContext, N as FastifyRequestExtras, Nt as TokenPair, O as HealthOptions, Ot as AuthHelpers, P as FastifyWithAuth, Pt as AnyRecord, Q as MiddlewareConfig, Rt as ObjectId, S as QueryParserInterface, T as CrudRouterOptions, U as ActionEntry, W as ActionHandlerFn, X as EventDefinition, Y as CrudSchemas, Z as FieldRule, _ as ControllerQueryOptions, _t as IControllerResponse, a as InferAdapterDoc, at as ResourceConfig, b as ParsedQuery, c as TypedController, ct as ResourcePermissions, d as PaginationResult, dt as RouteMethod, et as PresetFunction, f as IntrospectionData, ft as RouteSchemaOptions, g as ArcInternalMetadata, gt as IController, h as ResourceMetadata, ht as FastifyHandler, i as ValidationResult, it as ResourceCacheConfig, j as ArcDecorator, jt as AuthenticatorContext, k as IntrospectionPluginOptions, kt as AuthPluginOptions, l as TypedRepository, lt as RouteDefinition, m as RegistryStats, mt as ControllerLike, n as ConfigError, nt as PresetResult, o as InferDocType, ot as ResourceHookContext, p as RegistryEntry, pt as ControllerHandler, q as CrudController, r as ValidateOptions, rt as RateLimitConfig, s as InferResourceDoc, st as ResourceHooks, t as RouteHandlerMethod, tn as BaseControllerOptions, tt as PresetHook, u as TypedResourceConfig, ut as RouteMcpConfig, v as LookupOption, vt as IRequestContext, w as ServiceContext, x as PopulateOption, y as OwnershipCheck, yt as RouteHandler, zt as UserLike } from "../index-C_bgx9o4.mjs";
2
+ import { r as RequestScope } from "../types-tgR4Pt8F.mjs";
3
3
  import { c as PermissionCheck, d as UserBase, l as PermissionContext, u as PermissionResult } from "../fields-C8Y0XLAu.mjs";
4
4
  import { n as ElevationOptions, t as ElevationEvent } from "../elevation-s5ykdNHr.mjs";
5
- export { AUTHENTICATED_SCOPE, ActionDefinition, ActionEntry, ActionHandlerFn, ActionsMap, AnyRecord, ApiResponse, ArcDecorator, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRouteKey, CrudRouterOptions, CrudSchemas, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, ObjectId, OpenApiSchemas, OwnershipCheck, PUBLIC_SCOPE, PaginationResult, ParsedQuery, PermissionCheck, PermissionContext, PermissionResult, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryParserInterface, RateLimitConfig, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResourceCacheConfig, ResourceConfig, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, RouteDefinition, RouteHandler, RouteHandlerMethod, RouteMcpConfig, RouteMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult, envelope, getOrgId, getOrgRoles, getTeamId, getUserId, hasOrgAccess, isAuthenticated, isElevated, isMember };
5
+ export { ActionDefinition, ActionEntry, ActionHandlerFn, ActionsMap, AnyRecord, ApiResponse, ArcDecorator, ArcFieldRule, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRouteKey, CrudRouterOptions, CrudSchemas, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, ObjectId, OpenApiSchemas, OwnershipCheck, PaginationResult, ParsedQuery, PermissionCheck, PermissionContext, PermissionResult, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryParserInterface, RateLimitConfig, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResourceCacheConfig, ResourceConfig, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, RouteDefinition, RouteHandler, RouteHandlerMethod, RouteMcpConfig, RouteMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult };
@@ -1,3 +1 @@
1
- import { _ as isElevated, f as getTeamId, g as isAuthenticated, h as hasOrgAccess, n as PUBLIC_SCOPE, o as getOrgId, s as getOrgRoles, t as AUTHENTICATED_SCOPE, v as isMember } from "../types-AOD8fxIw.mjs";
2
- import { n as getUserId, t as envelope } from "../types-CDnTEpga.mjs";
3
- export { AUTHENTICATED_SCOPE, PUBLIC_SCOPE, envelope, getOrgId, getOrgRoles, getTeamId, getUserId, hasOrgAccess, isAuthenticated, isElevated, isMember };
1
+ export {};
@@ -1,13 +1,13 @@
1
- import { Gt as Authenticator } from "./index-BGbpGVyM.mjs";
1
+ import { At as Authenticator } from "./index-C_bgx9o4.mjs";
2
+ import { r as CacheStore } from "./interface-Da0r7Lna.mjs";
2
3
  import { n as ElevationOptions } from "./elevation-s5ykdNHr.mjs";
3
4
  import { o as EventTransport } from "./EventTransport-CfVEGaEl.mjs";
4
5
  import { t as ExternalOpenApiPaths } from "./externalPaths-Bapitwvd.mjs";
5
- import { r as CacheStore } from "./interface-yhyb_pLY.mjs";
6
- import { r as QueryCachePluginOptions } from "./queryCachePlugin-Dumka73q.mjs";
7
- import { t as EventPluginOptions } from "./eventPlugin-D1ThQ1Pp.mjs";
8
- import { f as CachingOptions, l as SSEOptions, o as MetricsOptions, t as VersioningOptions } from "./versioning-CeUXHfjw.mjs";
9
- import { t as ErrorHandlerOptions } from "./errorHandler-2ii4RIYr.mjs";
10
- import { r as IdempotencyStore } from "./interface-B-pe8fhj.mjs";
6
+ import { r as QueryCachePluginOptions } from "./queryCachePlugin-BUXBSm4F.mjs";
7
+ import { t as EventPluginOptions } from "./eventPlugin-CUNjYYRY.mjs";
8
+ import { f as CachingOptions, l as SSEOptions, o as MetricsOptions, t as VersioningOptions } from "./versioning-M9lNLhO8.mjs";
9
+ import { t as ErrorHandlerOptions } from "./errorHandler-Co3lnVmJ.mjs";
10
+ import { r as IdempotencyStore } from "./interface-CkkWm5uR.mjs";
11
11
  import { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, FastifyServerOptions } from "fastify";
12
12
 
13
13
  //#region src/factory/loadResources.d.ts
@@ -74,11 +74,63 @@ interface ResourceLike {
74
74
  /** Applied preset names */
75
75
  _appliedPresets?: string[];
76
76
  }
77
- interface LoadResourcesOptions {
77
+ /**
78
+ * Resource module — what a `.resource.ts` file's default (or named) export
79
+ * may resolve to.
80
+ *
81
+ * Two shapes accepted:
82
+ * 1. **Plain `ResourceLike`** — the result of `defineResource({...})`.
83
+ * Used as-is; no engine wiring needed.
84
+ * 2. **Factory `(ctx: TContext) => ResourceLike | Promise<ResourceLike>`**
85
+ * — a function arc calls with the `context` from `LoadResourcesOptions`.
86
+ * Eliminates the parallel `createXResource(engine)` factory files +
87
+ * `exclude: [...]` bookkeeping that engine-bound resources used to need.
88
+ *
89
+ * Detection is by `typeof === 'function'`: `ResourceDefinition` instances
90
+ * (returned by `defineResource()`) are class instances (`typeof === 'object'`),
91
+ * so the two shapes are unambiguous in practice.
92
+ */
93
+ type ResourceModule<TContext = unknown> = ResourceLike | ((ctx: TContext) => ResourceLike | Promise<ResourceLike>);
94
+ interface LoadResourcesOptions<TContext = unknown> {
78
95
  /** File pattern suffix (default: '.resource'). Matches `*.resource.{ts,js,mts,mjs}`. */
79
96
  suffix?: string;
80
97
  /** Recurse into subdirectories (default: true) */
81
98
  recursive?: boolean;
99
+ /**
100
+ * Context passed to factory-style default exports. Resources whose default
101
+ * export is a function `(ctx) => ResourceLike` are called with this value;
102
+ * plain `ResourceLike` exports are returned unchanged.
103
+ *
104
+ * Use this to thread engine handles into engine-bound resources without
105
+ * creating parallel factory files outside `loadResources`'s sweep:
106
+ *
107
+ * ```ts
108
+ * // category.resource.ts
109
+ * import type { AppContext } from '#core/app/context.js';
110
+ * export default (ctx: AppContext) =>
111
+ * defineResource({
112
+ * name: 'category',
113
+ * adapter: createMongooseAdapter(
114
+ * ctx.catalog.models.Category,
115
+ * ctx.catalog.repositories.category,
116
+ * ),
117
+ * });
118
+ *
119
+ * // create-arc-app-options.ts
120
+ * resources: async () => {
121
+ * const [catalog, flow] = await Promise.all([
122
+ * ensureCatalogEngine(),
123
+ * ensureFlowEngine(),
124
+ * ]);
125
+ * return loadResources(import.meta.url, { context: { catalog, flow } });
126
+ * }
127
+ * ```
128
+ *
129
+ * Backwards compatible — pre-2.11.1 callers omit `context`, plain exports
130
+ * keep working unchanged. Factories that need a context but receive
131
+ * `undefined` should narrow defensively.
132
+ */
133
+ context?: TContext;
82
134
  /**
83
135
  * Resource names to exclude. Matched against the resource's `.name` property
84
136
  * after import, so you use the resource name (not the filename).
@@ -101,14 +153,26 @@ interface LoadResourcesOptions {
101
153
  */
102
154
  include?: string[];
103
155
  /**
104
- * Suppress warning logs for skipped/failed files.
105
- * Useful when your resources directory contains factory files or helpers
106
- * that don't export a resource (e.g., `account.resource.ts` exporting a factory).
156
+ * Optional logger override for diagnostics. When omitted, warnings flow
157
+ * through arc's standard logger (`arcLog('loadResources')`) same path
158
+ * as every other arc-internal warning, controlled by `ARC_SUPPRESS_WARNINGS=1`
159
+ * and routable via `configureArcLogger({ writer })`.
107
160
  *
108
- * @default false
161
+ * Pass any object with `warn(msg)` to override (e.g. `fastify.log` —
162
+ * which is what `registerResources` passes automatically when arc's
163
+ * factory triggers auto-discovery via `resourceDir`).
164
+ *
165
+ * Pre-2.11.1 had a `silent: boolean` flag and "silent by default" semantics;
166
+ * both removed. Migration:
167
+ *
168
+ * ```ts
169
+ * // Pre-2.11.1 // 2.11.1+
170
+ * loadResources(url, { silent: true }); // ARC_SUPPRESS_WARNINGS=1 (env)
171
+ * // OR configureArcLogger({ writer })
172
+ * loadResources(url, { silent: !isDev }); // ARC_SUPPRESS_WARNINGS=1 in prod
173
+ * loadResources(url, { logger: pinoAdapter }); // unchanged — still works
174
+ * ```
109
175
  */
110
- silent?: boolean;
111
- /** Optional logger for diagnostics. No output when omitted (silent by default). */
112
176
  logger?: {
113
177
  warn: (msg: string) => void;
114
178
  };
@@ -137,7 +201,7 @@ interface LoadResourcesOptions {
137
201
  * await loadResources('./src/resources');
138
202
  * ```
139
203
  */
140
- declare function loadResources(dir: string, options?: LoadResourcesOptions): Promise<ResourceLike[]>;
204
+ declare function loadResources<TContext = unknown>(dir: string, options?: LoadResourcesOptions<TContext>): Promise<ResourceLike[]>;
141
205
  //#endregion
142
206
  //#region src/factory/types.d.ts
143
207
  type CorsOptions = Record<string, unknown> & {
@@ -653,18 +717,70 @@ interface CreateAppOptions {
653
717
  */
654
718
  serializeBigInt?: boolean;
655
719
  /**
656
- * Resources to register automatically.
657
- * Each resource's `.toPlugin()` is called and registered for you.
720
+ * Resources to register automatically. Accepts two shapes:
658
721
  *
659
- * @example
722
+ * 1. **Array** — each resource's `.toPlugin()` is called and registered.
723
+ * Defined at module-import time, so the resource's adapter must be
724
+ * constructible without any async state.
725
+ *
726
+ * 2. **Factory function** (sync or async) — called AFTER `bootstrap[]`
727
+ * but BEFORE routes are wired. Use this when a resource's adapter
728
+ * depends on an engine / singleton that boots asynchronously
729
+ * (e.g. `await ensureCatalogEngine()` / `await createFlowEngine()`).
730
+ * The factory receives the Fastify instance for symmetry with
731
+ * `plugins` and `bootstrap`.
732
+ *
733
+ * Arc's lifecycle contract:
734
+ * ```
735
+ * 1. Arc core (security, auth, events)
736
+ * 2. plugins() ← infra (DB, SSE, docs)
737
+ * 3. bootstrap[] ← domain init (engines, singletons)
738
+ * 4. resources resolution ← (factory form: call it here)
739
+ * 5. resources registered ← plugins mounted on Fastify
740
+ * 6. afterResources() ← post-registration wiring
741
+ * ```
742
+ *
743
+ * The factory form is the canonical answer to "my repository lives in an
744
+ * engine that boots asynchronously." Before this shape existed, hosts had
745
+ * to write per-resource lazy-bridge adapters that awaited the engine on
746
+ * every CRUD call — pure boilerplate. With a factory, `defineResource(...)`
747
+ * runs with the engine already live, so `createMongooseAdapter(engine.models.X, engine.repositories.X)`
748
+ * works directly.
749
+ *
750
+ * @example Static array (most resources)
660
751
  * ```ts
661
752
  * const app = await createApp({
662
753
  * resources: [productResource, orderResource, userResource],
663
754
  * auth: { type: 'jwt', jwt: { secret: 'xxx' } },
664
755
  * });
665
756
  * ```
757
+ *
758
+ * @example Factory with async-booted engine
759
+ * ```ts
760
+ * const app = await createApp({
761
+ * bootstrap: [async () => { await ensureCatalogEngine(); }],
762
+ * resources: async () => {
763
+ * const cat = await ensureCatalogEngine();
764
+ * return [
765
+ * defineResource({
766
+ * name: 'product',
767
+ * adapter: createMongooseAdapter(cat.models.Product, cat.repositories.product),
768
+ * // ...
769
+ * }),
770
+ * ];
771
+ * },
772
+ * });
773
+ * ```
774
+ *
775
+ * @example Factory delegating to auto-discovery
776
+ * ```ts
777
+ * const app = await createApp({
778
+ * bootstrap: [async () => { await ensureCatalogEngine(); }],
779
+ * resources: async () => loadResources(import.meta.url),
780
+ * });
781
+ * ```
666
782
  */
667
- resources?: Array<ResourceLike>;
783
+ resources?: ReadonlyArray<ResourceLike> | ((fastify: FastifyInstance) => ReadonlyArray<ResourceLike> | Promise<ReadonlyArray<ResourceLike>>);
668
784
  /**
669
785
  * URL prefix for all auto-registered resources.
670
786
  * Applied only to resources in the `resources` array — not to `plugins()`.
@@ -681,25 +797,72 @@ interface CreateAppOptions {
681
797
  resourcePrefix?: string;
682
798
  /**
683
799
  * Auto-discover resources from a directory instead of passing an explicit
684
- * `resources` array. Resolves relative to `process.cwd()`.
800
+ * `resources` array.
685
801
  *
686
- * This replaces the common pattern:
687
- * ```ts
688
- * resources: await loadResources(import.meta.url)
689
- * ```
802
+ * Accepts either a filesystem path OR `import.meta.url` (a `file://` URL).
803
+ * **Prefer the URL form in production** — bare strings resolve relative to
804
+ * `process.cwd()`, which diverges from `dist/` at runtime and was the root
805
+ * cause of a reported "deployed app serves 404 on every route" incident.
690
806
  *
691
- * When both `resourceDir` and `resources` are provided, `resources` wins
692
- * (explicit always beats convention).
807
+ * When both `resourceDir` and `resources` are provided, `resources` wins
808
+ * explicit always beats convention, **including an explicit empty array**.
809
+ * `resources: []` disables resource registration entirely even with
810
+ * `resourceDir` set, which is the common case for shared base configs
811
+ * that turn resource loading off in test / CLI / health-check subprocesses.
812
+ * Auto-discovery from `resourceDir` fires only when `resources` is
813
+ * `undefined` (absent).
693
814
  *
694
815
  * @example
695
816
  * ```ts
817
+ * // Recommended (v2.10.9+): URL form works in both src/ and dist/
696
818
  * const app = await createApp({
697
- * resourceDir: 'src/resources',
819
+ * resourceDir: import.meta.url,
698
820
  * resourcePrefix: '/api/v1',
699
821
  * });
822
+ *
823
+ * // String form — resolves against process.cwd(), mind the dist/ gap
824
+ * const app = await createApp({
825
+ * resourceDir: 'src/resources',
826
+ * });
700
827
  * ```
701
828
  */
702
829
  resourceDir?: string;
830
+ /**
831
+ * Throw instead of silently booting with zero resources when `resourceDir`
832
+ * yields an empty result. Off by default to preserve back-compat — turning
833
+ * it on in production catches the "typoed path / stale dist/ layout"
834
+ * failure mode before the app accepts traffic.
835
+ *
836
+ * Only takes effect when `resourceDir` is set.
837
+ *
838
+ * @example
839
+ * ```ts
840
+ * await createApp({
841
+ * resourceDir: import.meta.url,
842
+ * strictResourceDir: process.env.NODE_ENV === 'production',
843
+ * });
844
+ * ```
845
+ *
846
+ * @default false
847
+ */
848
+ strictResourceDir?: boolean;
849
+ /**
850
+ * Throw instead of warn when two resources share the same `name`. Off by
851
+ * default to preserve back-compat; turn on in production to catch stale
852
+ * `dist/` files (a common source of `Mongoose model already exists`
853
+ * collisions downstream of arc's own registry).
854
+ *
855
+ * @example
856
+ * ```ts
857
+ * await createApp({
858
+ * resources: await loadResources(import.meta.url),
859
+ * strictResources: process.env.NODE_ENV === 'production',
860
+ * });
861
+ * ```
862
+ *
863
+ * @default false
864
+ */
865
+ strictResources?: boolean;
703
866
  /**
704
867
  * Custom plugin registration — runs after Arc core (security, auth, events)
705
868
  * but before `bootstrap` and `resources`.
@@ -771,4 +934,4 @@ interface RawBodyOptions {
771
934
  runFirst?: boolean;
772
935
  }
773
936
  //#endregion
774
- export { CustomPluginAuthOption as a, RawBodyOptions as c, ResourceLike as d, loadResources as f, CustomAuthenticatorOption as i, UnderPressureOptions as l, BetterAuthOption as n, JwtAuthOption as o, CreateAppOptions as r, MultipartOptions as s, AuthOption as t, LoadResourcesOptions as u };
937
+ export { CustomPluginAuthOption as a, RawBodyOptions as c, ResourceLike as d, ResourceModule as f, CustomAuthenticatorOption as i, UnderPressureOptions as l, BetterAuthOption as n, JwtAuthOption as o, loadResources as p, CreateAppOptions as r, MultipartOptions as s, AuthOption as t, LoadResourcesOptions as u };
@@ -1,4 +1,4 @@
1
- import { B as ResourceDefinition } from "./index-BGbpGVyM.mjs";
1
+ import { B as ResourceDefinition } from "./index-C_bgx9o4.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/integrations/mcp/types.d.ts