@classytic/arc 2.11.1 → 2.11.3

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 (70) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +143 -673
  3. package/bin/arc.js +2 -2
  4. package/dist/{BaseController-JNV08qOT.mjs → BaseController-swXruJ2_.mjs} +2 -2
  5. package/dist/{actionPermissions-C8YYU92K.mjs → actionPermissions-sUUKDhtP.mjs} +4 -2
  6. package/dist/adapters/index.d.mts +2 -2
  7. package/dist/audit/index.d.mts +1 -1
  8. package/dist/auth/index.d.mts +1 -1
  9. package/dist/auth/index.mjs +1 -1
  10. package/dist/cli/commands/docs.mjs +1 -1
  11. package/dist/cli/commands/generate.d.mts +0 -2
  12. package/dist/cli/commands/generate.mjs +15 -15
  13. package/dist/cli/commands/init.mjs +24 -22
  14. package/dist/context/index.mjs +1 -1
  15. package/dist/core/index.d.mts +2 -2
  16. package/dist/core/index.mjs +3 -3
  17. package/dist/{core-DXdSSFW-.mjs → core-DnUsRpuX.mjs} +20 -8
  18. package/dist/{createActionRouter-BwaSM0No.mjs → createActionRouter-u3ql2EDo.mjs} +73 -13
  19. package/dist/{createApp-P1d6rjPy.mjs → createApp-BFxtdKy6.mjs} +1 -1
  20. package/dist/docs/index.d.mts +1 -1
  21. package/dist/docs/index.mjs +1 -1
  22. package/dist/{eventPlugin--5HIkdPU.mjs → eventPlugin-KrFIQ097.mjs} +1 -1
  23. package/dist/events/index.d.mts +1 -1
  24. package/dist/events/index.mjs +11 -3
  25. package/dist/factory/index.d.mts +1 -1
  26. package/dist/factory/index.mjs +1 -1
  27. package/dist/hooks/index.d.mts +1 -1
  28. package/dist/idempotency/index.d.mts +1 -1
  29. package/dist/{index-C_bgx9o4.d.mts → index-6u4_Gg6G.d.mts} +34 -0
  30. package/dist/{index-CvM1e09j.d.mts → index-BbMrcvGp.d.mts} +1 -1
  31. package/dist/{index-pUczGjO0.d.mts → index-BdXnTPRj.d.mts} +1 -1
  32. package/dist/{index-smCAoA5W.d.mts → index-DdQ3O9Pg.d.mts} +1 -1
  33. package/dist/index.d.mts +4 -4
  34. package/dist/index.mjs +6 -6
  35. package/dist/integrations/index.d.mts +1 -1
  36. package/dist/integrations/mcp/index.d.mts +2 -2
  37. package/dist/integrations/mcp/index.mjs +1 -1
  38. package/dist/integrations/mcp/testing.d.mts +1 -1
  39. package/dist/integrations/mcp/testing.mjs +1 -1
  40. package/dist/middleware/index.d.mts +1 -1
  41. package/dist/{openapi-C0L9ar7m.mjs → openapi-BGUn7Ki1.mjs} +2 -2
  42. package/dist/org/index.d.mts +1 -1
  43. package/dist/permissions/index.mjs +1 -1
  44. package/dist/{permissions-B4vU9L0Q.mjs → permissions-gd_aUWrR.mjs} +42 -0
  45. package/dist/pipeline/index.d.mts +1 -1
  46. package/dist/plugins/index.d.mts +1 -1
  47. package/dist/plugins/index.mjs +1 -1
  48. package/dist/plugins/tracing-entry.mjs +1 -1
  49. package/dist/presets/filesUpload.d.mts +1 -1
  50. package/dist/presets/filesUpload.mjs +1 -1
  51. package/dist/presets/index.d.mts +1 -1
  52. package/dist/presets/index.mjs +1 -1
  53. package/dist/presets/multiTenant.d.mts +1 -1
  54. package/dist/presets/search.d.mts +1 -1
  55. package/dist/presets/search.mjs +1 -1
  56. package/dist/{presets-k604Lj99.mjs → presets-Z7P5w4gF.mjs} +1 -1
  57. package/dist/registry/index.d.mts +1 -1
  58. package/dist/{requestContext-CfRkaxwf.mjs → requestContext-C5XeK3VA.mjs} +15 -0
  59. package/dist/{resourceToTools--okX6QBr.mjs → resourceToTools-ByZpgjeH.mjs} +5 -4
  60. package/dist/{routerShared-DeESFp4a.mjs → routerShared-BqLRb5l7.mjs} +60 -3
  61. package/dist/testing/index.d.mts +2 -2
  62. package/dist/testing/index.mjs +1 -1
  63. package/dist/types/index.d.mts +1 -1
  64. package/dist/{types-Bh_gEJBi.d.mts → types-9beEMe25.d.mts} +1 -1
  65. package/dist/{types-BdA4uMBV.d.mts → types-BH7dEGvU.d.mts} +1 -1
  66. package/dist/utils/index.d.mts +1 -1
  67. package/dist/utils/index.mjs +1 -1
  68. package/dist/{utils-D3Yxnrwr.mjs → utils-CcYTj09l.mjs} +1 -1
  69. package/package.json +5 -1
  70. package/skills/arc/references/events.md +489 -489
@@ -1776,6 +1776,40 @@ interface RouteSchemaOptions extends SchemaBuilderOptions {
1776
1776
  * post-kit by `mergeFieldRuleConstraints`.
1777
1777
  */
1778
1778
  fieldRules?: Record<string, ArcFieldRule>;
1779
+ /**
1780
+ * Query-time security whitelists + the kit's `filterableFields`.
1781
+ *
1782
+ * Extends repo-core's `SchemaBuilderOptions['query']` with arc-specific
1783
+ * runtime features that `QueryResolver` reads at request time:
1784
+ *
1785
+ * - **`allowedPopulate`** — populate-path whitelist consumed by
1786
+ * `QueryResolver.sanitizePopulate` / `sanitizeAdvancedPopulate`.
1787
+ * When set, only paths in the list pass through; everything else is
1788
+ * stripped silently. Shrinks the auto-wired `?populate=` attack surface.
1789
+ *
1790
+ * - **`allowedLookups`** — lookup-collection whitelist consumed by
1791
+ * `QueryResolver.sanitizeLookups`. When set, only the listed
1792
+ * collections may be `$lookup`'d into the pipeline.
1793
+ *
1794
+ * Both are pre-2.11.2 runtime features — the type was missing them, so
1795
+ * hosts wrote `as Record<string, unknown>` at every call site. Arc's own
1796
+ * `QueryResolver` had to cast its own input via `as AnyRecord` for the
1797
+ * same reason. Adding the type dropped both casts.
1798
+ */
1799
+ query?: SchemaBuilderOptions["query"] & {
1800
+ /**
1801
+ * Populate-path whitelist. When set, `QueryResolver.sanitizePopulate`
1802
+ * strips any `?populate=<path>` not in this list. Omit to allow all
1803
+ * paths the kit recognizes.
1804
+ */
1805
+ allowedPopulate?: string[];
1806
+ /**
1807
+ * Lookup-collection whitelist for `QueryResolver.sanitizeLookups`.
1808
+ * When set, only the listed collections may be `$lookup`'d. Omit to
1809
+ * disable the whitelist (kit-level rules still apply).
1810
+ */
1811
+ allowedLookups?: string[];
1812
+ };
1779
1813
  }
1780
1814
  interface FieldRule$1 {
1781
1815
  field: string;
@@ -1,4 +1,4 @@
1
- import { $ as OpenApiSchemas, Dn as AdapterSchemaContext, Mn as SchemaMetadata, Nn as ValidationResult, On as DataAdapter, S as QueryParserInterface, b as ParsedQuery, ft as RouteSchemaOptions, jn as RepositoryLike } from "./index-C_bgx9o4.mjs";
1
+ import { $ as OpenApiSchemas, Dn as AdapterSchemaContext, Mn as SchemaMetadata, Nn as ValidationResult, On as DataAdapter, S as QueryParserInterface, b as ParsedQuery, ft as RouteSchemaOptions, jn as RepositoryLike } from "./index-6u4_Gg6G.mjs";
2
2
  import { StandardRepo } from "@classytic/repo-core/repository";
3
3
  import { Model } from "mongoose";
4
4
 
@@ -1,4 +1,4 @@
1
- import { B as ResourceDefinition, C as RequestContext, F as FastifyWithDecorators, Pt as AnyRecord, T as CrudRouterOptions, _t as IControllerResponse, at as ResourceConfig, gt as IController, q as CrudController, vt as IRequestContext } from "./index-C_bgx9o4.mjs";
1
+ import { B as ResourceDefinition, C as RequestContext, F as FastifyWithDecorators, Pt as AnyRecord, T as CrudRouterOptions, _t as IControllerResponse, at as ResourceConfig, gt as IController, q as CrudController, vt as IRequestContext } from "./index-6u4_Gg6G.mjs";
2
2
  import { r as RequestScope } from "./types-tgR4Pt8F.mjs";
3
3
  import { c as PermissionCheck } from "./fields-C8Y0XLAu.mjs";
4
4
  import { FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
@@ -1,4 +1,4 @@
1
- import { $ as OpenApiSchemas, Pt as AnyRecord, S as QueryParserInterface, at as ResourceConfig, b as ParsedQuery, zt as UserLike } from "./index-C_bgx9o4.mjs";
1
+ import { $ as OpenApiSchemas, Pt as AnyRecord, S as QueryParserInterface, at as ResourceConfig, b as ParsedQuery, zt as UserLike } from "./index-6u4_Gg6G.mjs";
2
2
  import { n as ErrorMapper } from "./errorHandler-Co3lnVmJ.mjs";
3
3
  import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
4
4
 
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { $t as ArcListResult, A as RequestIdOptions, An as RelationMetadata, B as ResourceDefinition, Bt as UserOrganization, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, Ft as ApiResponse, Gt as TreeMixin, Ht as SoftDeleteExt, It as ArcRequest, J as CrudRouteKey, Jt as BulkExt, Kt as SlugExt, L as RequestWithExtras, Lt as JWTPayload, Mn as SchemaMetadata, N as FastifyRequestExtras, Nn as ValidationResult, O as HealthOptions, On as DataAdapter, P as FastifyWithAuth, Pt as AnyRecord, Q as MiddlewareConfig, Qt as ArcGetResult, S as QueryParserInterface, T as CrudRouterOptions, Ut as SoftDeleteMixin, V as defineResource, Vt as BaseController, Wt as TreeExt, X as EventDefinition, Xt as ArcCreateResult, Y as CrudSchemas, Yt as BulkMixin, Z as FieldRule, Zt as ArcDeleteResult, _t as IControllerResponse, a as InferAdapterDoc, at as ResourceConfig, c as TypedController, d as PaginationResult, en as ArcUpdateResult, et as PresetFunction, f as IntrospectionData, ft as RouteSchemaOptions, g as ArcInternalMetadata, gt as IController, h as ResourceMetadata, i as ValidationResult$1, jn as RepositoryLike, k as IntrospectionPluginOptions, kn as FieldMetadata, kt as AuthPluginOptions, l as TypedRepository, m as RegistryStats, mt as ControllerLike, n as ConfigError, nn as BaseCrudController, nt as PresetResult, o as InferDocType, p as RegistryEntry, q as CrudController, qt as SlugMixin, r as ValidateOptions, rn as ListResult, rt as RateLimitConfig, s as InferResourceDoc, t as RouteHandlerMethod, tn as BaseControllerOptions, u as TypedResourceConfig, vt as IRequestContext, w as ServiceContext, y as OwnershipCheck, yt as RouteHandler } from "./index-C_bgx9o4.mjs";
1
+ import { $t as ArcListResult, A as RequestIdOptions, An as RelationMetadata, B as ResourceDefinition, Bt as UserOrganization, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, Ft as ApiResponse, Gt as TreeMixin, Ht as SoftDeleteExt, It as ArcRequest, J as CrudRouteKey, Jt as BulkExt, Kt as SlugExt, L as RequestWithExtras, Lt as JWTPayload, Mn as SchemaMetadata, N as FastifyRequestExtras, Nn as ValidationResult, O as HealthOptions, On as DataAdapter, P as FastifyWithAuth, Pt as AnyRecord, Q as MiddlewareConfig, Qt as ArcGetResult, S as QueryParserInterface, T as CrudRouterOptions, Ut as SoftDeleteMixin, V as defineResource, Vt as BaseController, Wt as TreeExt, X as EventDefinition, Xt as ArcCreateResult, Y as CrudSchemas, Yt as BulkMixin, Z as FieldRule, Zt as ArcDeleteResult, _t as IControllerResponse, a as InferAdapterDoc, at as ResourceConfig, c as TypedController, d as PaginationResult, en as ArcUpdateResult, et as PresetFunction, f as IntrospectionData, ft as RouteSchemaOptions, g as ArcInternalMetadata, gt as IController, h as ResourceMetadata, i as ValidationResult$1, jn as RepositoryLike, k as IntrospectionPluginOptions, kn as FieldMetadata, kt as AuthPluginOptions, l as TypedRepository, m as RegistryStats, mt as ControllerLike, n as ConfigError, nn as BaseCrudController, nt as PresetResult, o as InferDocType, p as RegistryEntry, q as CrudController, qt as SlugMixin, r as ValidateOptions, rn as ListResult, rt as RateLimitConfig, s as InferResourceDoc, t as RouteHandlerMethod, tn as BaseControllerOptions, u as TypedResourceConfig, vt as IRequestContext, w as ServiceContext, y as OwnershipCheck, yt as RouteHandler } from "./index-6u4_Gg6G.mjs";
2
2
  import { a as applyFieldWritePermissions, c as PermissionCheck, d as UserBase, i as applyFieldReadPermissions, l as PermissionContext, n as FieldPermissionMap, o as fields, t as FieldPermission, u as PermissionResult } from "./fields-C8Y0XLAu.mjs";
3
- import { l as createMongooseAdapter, o as createPrismaAdapter, s as MongooseAdapter, t as PrismaAdapter } from "./index-CvM1e09j.mjs";
4
- import { C as MAX_REGEX_LENGTH, D as RESERVED_QUERY_PARAMS, E as MutationOperation, O as SYSTEM_FIELDS, S as MAX_FILTER_DEPTH, T as MUTATION_OPERATIONS, _ as DEFAULT_UPDATE_METHOD, a as getControllerScope, b as HookOperation, d as CrudOperation, f as DEFAULT_ID_FIELD, g as DEFAULT_TENANT_FIELD, h as DEFAULT_SORT, m as DEFAULT_MAX_LIMIT, p as DEFAULT_LIMIT, s as defineResourceVariants, u as CRUD_OPERATIONS, v as HOOK_OPERATIONS, w as MAX_SEARCH_LENGTH, x as HookPhase, y as HOOK_PHASES } from "./index-pUczGjO0.mjs";
3
+ import { l as createMongooseAdapter, o as createPrismaAdapter, s as MongooseAdapter, t as PrismaAdapter } from "./index-BbMrcvGp.mjs";
4
+ import { C as MAX_REGEX_LENGTH, D as RESERVED_QUERY_PARAMS, E as MutationOperation, O as SYSTEM_FIELDS, S as MAX_FILTER_DEPTH, T as MUTATION_OPERATIONS, _ as DEFAULT_UPDATE_METHOD, a as getControllerScope, b as HookOperation, d as CrudOperation, f as DEFAULT_ID_FIELD, g as DEFAULT_TENANT_FIELD, h as DEFAULT_SORT, m as DEFAULT_MAX_LIMIT, p as DEFAULT_LIMIT, s as defineResourceVariants, u as CRUD_OPERATIONS, v as HOOK_OPERATIONS, w as MAX_SEARCH_LENGTH, x as HookPhase, y as HOOK_PHASES } from "./index-BdXnTPRj.mjs";
5
5
  import { A as requireRoles, C as allOf, E as denyAll, M as when, O as requireAuth, S as createOrgPermissions, T as anyOf, a as presets_d_exports, c as readOnly, d as requireOrgRole, f as requireScopeContext, i as ownerWithAdminBypass, k as requireOwnership, l as requireOrgInScope, m as requireTeamMembership, n as authenticated, o as publicRead, p as requireServiceScope, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as requireOrgMembership, v as DynamicPermissionMatrix, w as allowPublic, x as createDynamicPermissionMatrix, y as DynamicPermissionMatrixConfig } from "./index-BYCqHCVu.mjs";
6
- import { ft as UnauthorizedError, j as envelope, mt as createDomainError, ot as ForbiddenError, pt as ValidationError, rt as ArcError, st as NotFoundError, t as getUserId } from "./index-smCAoA5W.mjs";
6
+ import { ft as UnauthorizedError, j as envelope, mt as createDomainError, ot as ForbiddenError, pt as ValidationError, rt as ArcError, st as NotFoundError, t as getUserId } from "./index-DdQ3O9Pg.mjs";
7
7
 
8
8
  //#region src/index.d.ts
9
9
  declare const version: string;
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { a as createMongooseAdapter, i as MongooseAdapter, r as createPrismaAdapter, t as PrismaAdapter } from "./adapters-D0tT2Tyo.mjs";
2
2
  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-BhY1OHoH.mjs";
3
- import { j as getUserId, r as envelope } from "./utils-D3Yxnrwr.mjs";
4
- import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-JNV08qOT.mjs";
5
- import { C as requireAuth, D as when, M as applyFieldWritePermissions, N as fields, T as requireRoles, _ as requireTeamMembership, a as presets_exports, b as anyOf, c as readOnly, d as createOrgPermissions, f as requireOrgInScope, g as requireServiceScope, h as requireScopeContext, i as ownerWithAdminBypass, j as applyFieldReadPermissions, m as requireOrgRole, n as authenticated, o as publicRead, p as requireOrgMembership, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as createDynamicPermissionMatrix, v as allOf, w as requireOwnership, x as denyAll, y as allowPublic } from "./permissions-B4vU9L0Q.mjs";
3
+ import { j as getUserId, r as envelope } from "./utils-CcYTj09l.mjs";
4
+ import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-swXruJ2_.mjs";
5
+ import { C as requireAuth, D as when, M as applyFieldWritePermissions, N as fields, T as requireRoles, _ as requireTeamMembership, a as presets_exports, b as anyOf, c as readOnly, d as createOrgPermissions, f as requireOrgInScope, g as requireServiceScope, h as requireScopeContext, i as ownerWithAdminBypass, j as applyFieldReadPermissions, m as requireOrgRole, n as authenticated, o as publicRead, p as requireOrgMembership, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as createDynamicPermissionMatrix, v as allOf, w as requireOwnership, x as denyAll, y as allowPublic } from "./permissions-gd_aUWrR.mjs";
6
6
  import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-D5c-5BJL.mjs";
7
- import { _ as getControllerScope } from "./routerShared-DeESFp4a.mjs";
8
- import { n as ResourceDefinition, r as defineResource, t as defineResourceVariants } from "./core-DXdSSFW-.mjs";
7
+ import { v as getControllerScope } from "./routerShared-BqLRb5l7.mjs";
8
+ import { n as ResourceDefinition, r as defineResource, t as defineResourceVariants } from "./core-DnUsRpuX.mjs";
9
9
  //#region src/index.ts
10
- const version = "2.11.1";
10
+ const version = "2.11.3";
11
11
  //#endregion
12
12
  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, MongooseAdapter, NotFoundError, PrismaAdapter, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createMongooseAdapter, createOrgPermissions, createPrismaAdapter, defineResource, defineResourceVariants, denyAll, envelope, fields, fullPublic, getControllerScope, getUserId, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
@@ -1,7 +1,7 @@
1
1
  import { a as WebSocketMessage, i as WebSocketClient, o as WebSocketPluginOptions } from "../websocket-CyJ1VIFI.mjs";
2
2
  import { EventGatewayOptions } from "./event-gateway.mjs";
3
3
  import { JobDefinition, JobDispatchOptions, JobDispatcher, JobMeta, JobsPluginOptions, QueueStats } from "./jobs.mjs";
4
- import { c as McpResourceConfig, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler } from "../types-Bh_gEJBi.mjs";
4
+ import { c as McpResourceConfig, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler } from "../types-9beEMe25.mjs";
5
5
  import { StreamlinePluginOptions, WorkflowLike, WorkflowRunLike } from "./streamline.mjs";
6
6
  import { WebhookDeliveryRecord, WebhookManager, WebhookPluginOptions, WebhookStore, WebhookSubscription } from "./webhooks.mjs";
7
7
  export { type BetterAuthHandler, type CallToolResult, type CreateMcpServerConfig, type CrudOperation, type EventGatewayOptions, type JobDefinition, type JobDispatchOptions, type JobDispatcher, type JobMeta, type JobsPluginOptions, type McpAuthResult, type McpPluginOptions, type McpResourceConfig, type PromptDefinition, type QueueStats, type StreamlinePluginOptions, type ToolAnnotations, type ToolContext, type ToolDefinition, type WebSocketClient, type WebSocketMessage, type WebSocketPluginOptions, type WebhookDeliveryRecord, type WebhookManager, type WebhookPluginOptions, type WebhookStore, type WebhookSubscription, type WorkflowLike, type WorkflowRunLike };
@@ -1,5 +1,5 @@
1
- import { B as ResourceDefinition } from "../../index-C_bgx9o4.mjs";
2
- import { a as McpAuthResolver, c as McpResourceConfig, d as SessionEntry, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler, u as PromptResult } from "../../types-Bh_gEJBi.mjs";
1
+ import { B as ResourceDefinition } from "../../index-6u4_Gg6G.mjs";
2
+ import { a as McpAuthResolver, c as McpResourceConfig, d as SessionEntry, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler, u as PromptResult } from "../../types-9beEMe25.mjs";
3
3
  import { FastifyPluginAsync } from "fastify";
4
4
  import { z } from "zod";
5
5
 
@@ -1,4 +1,4 @@
1
- import { n as fieldRulesToZod, r as createMcpServer, t as resourceToTools } from "../../resourceToTools--okX6QBr.mjs";
1
+ import { n as fieldRulesToZod, r as createMcpServer, t as resourceToTools } from "../../resourceToTools-ByZpgjeH.mjs";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/integrations/mcp/defineTool.ts
@@ -1,4 +1,4 @@
1
- import { o as McpAuthResult, s as McpPluginOptions } from "../../types-Bh_gEJBi.mjs";
1
+ import { o as McpAuthResult, s as McpPluginOptions } from "../../types-9beEMe25.mjs";
2
2
 
3
3
  //#region src/integrations/mcp/testing.d.ts
4
4
  interface TestMcpClientOptions {
@@ -1,4 +1,4 @@
1
- import { r as createMcpServer, t as resourceToTools } from "../../resourceToTools--okX6QBr.mjs";
1
+ import { r as createMcpServer, t as resourceToTools } from "../../resourceToTools-ByZpgjeH.mjs";
2
2
  //#region src/integrations/mcp/testing.ts
3
3
  /**
4
4
  * @classytic/arc/mcp/testing — MCP Test Utilities
@@ -1,4 +1,4 @@
1
- import { I as MiddlewareHandler, L as RequestWithExtras, Q as MiddlewareConfig } from "../index-C_bgx9o4.mjs";
1
+ import { I as MiddlewareHandler, L as RequestWithExtras, Q as MiddlewareConfig } from "../index-6u4_Gg6G.mjs";
2
2
  import { RouteHandlerMethod } from "fastify";
3
3
 
4
4
  //#region src/middleware/middleware.d.ts
@@ -1,7 +1,7 @@
1
1
  import { t as getUserRoles } from "./types-DV9WDfeg.mjs";
2
2
  import { n as convertRouteSchema } from "./schemaConverter-B0oKLuqI.mjs";
3
- import { t as resolveActionPermission } from "./actionPermissions-C8YYU92K.mjs";
4
- import { t as buildActionBodySchema } from "./createActionRouter-BwaSM0No.mjs";
3
+ import { t as resolveActionPermission } from "./actionPermissions-sUUKDhtP.mjs";
4
+ import { t as buildActionBodySchema } from "./createActionRouter-u3ql2EDo.mjs";
5
5
  import fp from "fastify-plugin";
6
6
  //#region src/docs/openapi.ts
7
7
  const openApiPlugin = async (fastify, opts = {}) => {
@@ -1,4 +1,4 @@
1
- import { yt as RouteHandler } from "../index-C_bgx9o4.mjs";
1
+ import { yt as RouteHandler } from "../index-6u4_Gg6G.mjs";
2
2
  import { d as UserBase } from "../fields-C8Y0XLAu.mjs";
3
3
  import { InvitationAdapter, InvitationDoc, MemberDoc, OrgAdapter, OrgDoc, OrgPermissionStatement, OrgRole, OrganizationPluginOptions } from "./types.mjs";
4
4
  import { FastifyPluginAsync, RouteHandlerMethod } from "fastify";
@@ -1,3 +1,3 @@
1
- import { A as normalizePermissionResult, C as requireAuth, D as when, E as roles, M as applyFieldWritePermissions, N as fields, O as applyPermissionResult, P as resolveEffectiveRoles, S as not, T as requireRoles, _ as requireTeamMembership, a as presets_exports, b as anyOf, c as readOnly, d as createOrgPermissions, f as requireOrgInScope, g as requireServiceScope, h as requireScopeContext, i as ownerWithAdminBypass, j as applyFieldReadPermissions, l as createRoleHierarchy, m as requireOrgRole, n as authenticated, o as publicRead, p as requireOrgMembership, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as createDynamicPermissionMatrix, v as allOf, w as requireOwnership, x as denyAll, y as allowPublic } from "../permissions-B4vU9L0Q.mjs";
1
+ import { A as normalizePermissionResult, C as requireAuth, D as when, E as roles, M as applyFieldWritePermissions, N as fields, O as applyPermissionResult, P as resolveEffectiveRoles, S as not, T as requireRoles, _ as requireTeamMembership, a as presets_exports, b as anyOf, c as readOnly, d as createOrgPermissions, f as requireOrgInScope, g as requireServiceScope, h as requireScopeContext, i as ownerWithAdminBypass, j as applyFieldReadPermissions, l as createRoleHierarchy, m as requireOrgRole, n as authenticated, o as publicRead, p as requireOrgMembership, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as createDynamicPermissionMatrix, v as allOf, w as requireOwnership, x as denyAll, y as allowPublic } from "../permissions-gd_aUWrR.mjs";
2
2
  import { n as normalizeRoles, t as getUserRoles } from "../types-DV9WDfeg.mjs";
3
3
  export { adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, applyPermissionResult, authenticated, createDynamicPermissionMatrix, createOrgPermissions, createRoleHierarchy, denyAll, fields, fullPublic, getUserRoles, normalizePermissionResult, normalizeRoles, not, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, resolveEffectiveRoles, roles, when };
@@ -31,21 +31,63 @@ function isMongooseDoc(obj) {
31
31
  return !!obj && typeof obj === "object" && "toObject" in obj && typeof obj.toObject === "function";
32
32
  }
33
33
  const fields = {
34
+ /**
35
+ * Field is never included in responses. Not writable via API.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * fields: { password: fields.hidden() }
40
+ * ```
41
+ */
34
42
  hidden() {
35
43
  return { _type: "hidden" };
36
44
  },
45
+ /**
46
+ * Field is only visible to users with specified roles.
47
+ * Other users don't see the field at all.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * fields: { salary: fields.visibleTo(['admin', 'hr']) }
52
+ * ```
53
+ */
37
54
  visibleTo(roles) {
38
55
  return {
39
56
  _type: "visibleTo",
40
57
  roles
41
58
  };
42
59
  },
60
+ /**
61
+ * Field is only writable by users with specified roles.
62
+ * All users can still read the field. Users without the role
63
+ * have the field silently stripped from write operations.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * fields: { role: fields.writableBy(['admin']) }
68
+ * ```
69
+ */
43
70
  writableBy(roles) {
44
71
  return {
45
72
  _type: "writableBy",
46
73
  roles
47
74
  };
48
75
  },
76
+ /**
77
+ * Field is redacted (replaced with a placeholder) for specified roles.
78
+ * Other users see the real value.
79
+ *
80
+ * @param roles - Roles that see the redacted value
81
+ * @param redactValue - Replacement value (default: '***')
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * fields: {
86
+ * email: fields.redactFor(['viewer']),
87
+ * ssn: fields.redactFor(['basic'], '***-**-****'),
88
+ * }
89
+ * ```
90
+ */
49
91
  redactFor(roles, redactValue = "***") {
50
92
  return {
51
93
  _type: "redactFor",
@@ -1,4 +1,4 @@
1
- import { Ct as OperationFilter, Dt as Transform, Et as PipelineStep, St as NextFunction, Tt as PipelineContext, _t as IControllerResponse, bt as Guard, wt as PipelineConfig, xt as Interceptor } from "../index-C_bgx9o4.mjs";
1
+ import { Ct as OperationFilter, Dt as Transform, Et as PipelineStep, St as NextFunction, Tt as PipelineContext, _t as IControllerResponse, bt as Guard, wt as PipelineConfig, xt as Interceptor } from "../index-6u4_Gg6G.mjs";
2
2
 
3
3
  //#region src/pipeline/guard.d.ts
4
4
  interface GuardOptions {
@@ -1,4 +1,4 @@
1
- import { Pt as AnyRecord, Q as MiddlewareConfig, ft as RouteSchemaOptions, gn as HookSystem, lt as RouteDefinition, tt as PresetHook, z as ResourceRegistry } from "../index-C_bgx9o4.mjs";
1
+ import { Pt as AnyRecord, Q as MiddlewareConfig, ft as RouteSchemaOptions, gn as HookSystem, lt as RouteDefinition, tt as PresetHook, z as ResourceRegistry } from "../index-6u4_Gg6G.mjs";
2
2
  import { t as ExternalOpenApiPaths } from "../externalPaths-Bapitwvd.mjs";
3
3
  import { a as MetricsCollector, c as metricsPlugin, d as ssePlugin, f as CachingOptions, h as cachingPlugin, i as MetricEntry, l as SSEOptions, m as _default$1, n as _default$7, o as MetricsOptions, p as CachingRule, r as versioningPlugin, s as _default$4, t as VersioningOptions, u as _default$6 } from "../versioning-M9lNLhO8.mjs";
4
4
  import { i as errorHandlerPlugin, n as ErrorMapper, r as defaultIsDuplicateKeyError, t as ErrorHandlerOptions } from "../errorHandler-Co3lnVmJ.mjs";
@@ -1,6 +1,6 @@
1
1
  import { p as MUTATION_OPERATIONS } from "../constants-BhY1OHoH.mjs";
2
2
  import { o as getOrgId } from "../types-AOD8fxIw.mjs";
3
- import { t as requestContext } from "../requestContext-CfRkaxwf.mjs";
3
+ import { t as requestContext } from "../requestContext-C5XeK3VA.mjs";
4
4
  import { t as hasEvents } from "../typeGuards-CcFZXgU7.mjs";
5
5
  import { t as HookSystem } from "../HookSystem-CGsMd6oK.mjs";
6
6
  import { t as ResourceRegistry } from "../ResourceRegistry-DkAeAuTX.mjs";
@@ -58,7 +58,7 @@ try {
58
58
  function createTracerProvider(options) {
59
59
  if (!isAvailable || !NodeTracerProvider || !BatchSpanProcessor || !OTLPTraceExporter) return null;
60
60
  const { serviceName = "@classytic/arc", serviceVersion, exporterUrl = "http://localhost:4318/v1/traces" } = options;
61
- const resolvedVersion = serviceVersion ?? "2.11.1";
61
+ const resolvedVersion = serviceVersion ?? "2.11.3";
62
62
  const exporter = new OTLPTraceExporter({ url: exporterUrl });
63
63
  const provider = new NodeTracerProvider({ resource: { attributes: {
64
64
  "service.name": serviceName,
@@ -1,4 +1,4 @@
1
- import { nt as PresetResult } from "../index-C_bgx9o4.mjs";
1
+ import { nt as PresetResult } from "../index-6u4_Gg6G.mjs";
2
2
  import { r as RequestScope } from "../types-tgR4Pt8F.mjs";
3
3
  import { c as PermissionCheck } from "../fields-C8Y0XLAu.mjs";
4
4
  import { a as StorageReadResult, i as StorageReadRange, n as StorageContext, o as StorageUploadInput, r as StorageFile, t as Storage } from "../storage-BwGQXUpd.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as getOrgId, p as getUserId } from "../types-AOD8fxIw.mjs";
2
- import { C as requireAuth, y as allowPublic } from "../permissions-B4vU9L0Q.mjs";
2
+ import { C as requireAuth, y as allowPublic } from "../permissions-gd_aUWrR.mjs";
3
3
  import { i as NotFoundError, u as ValidationError } from "../errors-D5c-5BJL.mjs";
4
4
  import { t as multipartBody } from "../multipartBody-CvTR1Un6.mjs";
5
5
  //#region src/presets/filesUpload.ts
@@ -1,4 +1,4 @@
1
- import { Pt as AnyRecord, _t as IControllerResponse, at as ResourceConfig, d as PaginationResult, nt as PresetResult, vt as IRequestContext } from "../index-C_bgx9o4.mjs";
1
+ import { Pt as AnyRecord, _t as IControllerResponse, at as ResourceConfig, d as PaginationResult, nt as PresetResult, vt as IRequestContext } from "../index-6u4_Gg6G.mjs";
2
2
  import { FilesUploadPresetOptions, FilesUploadPresetPermissions, FilesUploadPresetRoutes, filesUploadPreset } from "./filesUpload.mjs";
3
3
  import { MultiTenantOptions, TenantFieldSpec, multiTenantPreset } from "./multiTenant.mjs";
4
4
  import { SearchHandler, SearchPresetOptions, SearchRouteConfig, searchPreset } from "./search.mjs";
@@ -1,5 +1,5 @@
1
1
  import { multiTenantPreset } from "./multiTenant.mjs";
2
- import { a as registerPreset, c as auditedPreset, d as ownedByUserPreset, i as getPreset, l as softDeletePreset, n as flexibleMultiTenantPreset, o as treePreset, r as getAvailablePresets, s as bulkPreset, t as applyPresets, u as slugLookupPreset } from "../presets-k604Lj99.mjs";
2
+ import { a as registerPreset, c as auditedPreset, d as ownedByUserPreset, i as getPreset, l as softDeletePreset, n as flexibleMultiTenantPreset, o as treePreset, r as getAvailablePresets, s as bulkPreset, t as applyPresets, u as slugLookupPreset } from "../presets-Z7P5w4gF.mjs";
3
3
  import { filesUploadPreset } from "./filesUpload.mjs";
4
4
  import { searchPreset } from "./search.mjs";
5
5
  export { applyPresets, auditedPreset, bulkPreset, filesUploadPreset, flexibleMultiTenantPreset, getAvailablePresets, getPreset, multiTenantPreset, ownedByUserPreset, registerPreset, searchPreset, slugLookupPreset, softDeletePreset, treePreset };
@@ -1,4 +1,4 @@
1
- import { J as CrudRouteKey, nt as PresetResult } from "../index-C_bgx9o4.mjs";
1
+ import { J as CrudRouteKey, nt as PresetResult } from "../index-6u4_Gg6G.mjs";
2
2
 
3
3
  //#region src/presets/multiTenant.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { lt as RouteDefinition, nt as PresetResult, pt as ControllerHandler, ut as RouteMcpConfig } from "../index-C_bgx9o4.mjs";
1
+ import { lt as RouteDefinition, nt as PresetResult, pt as ControllerHandler, ut as RouteMcpConfig } from "../index-6u4_Gg6G.mjs";
2
2
  import { c as PermissionCheck } from "../fields-C8Y0XLAu.mjs";
3
3
 
4
4
  //#region src/presets/search.d.ts
@@ -1,4 +1,4 @@
1
- import { C as requireAuth, y as allowPublic } from "../permissions-B4vU9L0Q.mjs";
1
+ import { C as requireAuth, y as allowPublic } from "../permissions-gd_aUWrR.mjs";
2
2
  //#region src/presets/search.ts
3
3
  const BUILTINS = [
4
4
  {
@@ -1,5 +1,5 @@
1
1
  import { _ as isElevated, n as PUBLIC_SCOPE } from "./types-AOD8fxIw.mjs";
2
- import { C as requireAuth, T as requireRoles, y as allowPublic } from "./permissions-B4vU9L0Q.mjs";
2
+ import { C as requireAuth, T as requireRoles, y as allowPublic } from "./permissions-gd_aUWrR.mjs";
3
3
  import { multiTenantPreset } from "./presets/multiTenant.mjs";
4
4
  //#region src/presets/ownedByUser.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { R as RegisterOptions, k as IntrospectionPluginOptions, z as ResourceRegistry } from "../index-C_bgx9o4.mjs";
1
+ import { R as RegisterOptions, k as IntrospectionPluginOptions, z as ResourceRegistry } from "../index-6u4_Gg6G.mjs";
2
2
  import { FastifyPluginAsync } from "fastify";
3
3
 
4
4
  //#region src/registry/introspectionPlugin.d.ts
@@ -38,15 +38,30 @@ const storage = new AsyncLocalStorage();
38
38
  * - `getStore()` — alias for get() (matches Node.js API naming)
39
39
  */
40
40
  const requestContext = {
41
+ /**
42
+ * Get the current request context.
43
+ * Returns undefined if called outside a request lifecycle.
44
+ */
41
45
  get() {
42
46
  return storage.getStore();
43
47
  },
48
+ /**
49
+ * Alias for get() — matches Node.js AsyncLocalStorage API naming.
50
+ */
44
51
  getStore() {
45
52
  return storage.getStore();
46
53
  },
54
+ /**
55
+ * Run a function within a specific request context.
56
+ * Used internally by Arc's onRequest hook.
57
+ */
47
58
  run(store, fn) {
48
59
  return storage.run(store, fn);
49
60
  },
61
+ /**
62
+ * The underlying AsyncLocalStorage instance.
63
+ * Exposed for advanced use cases (testing, custom integrations).
64
+ */
50
65
  storage
51
66
  };
52
67
  //#endregion
@@ -1,8 +1,8 @@
1
- import { t as BaseController } from "./BaseController-JNV08qOT.mjs";
2
- import { A as normalizePermissionResult } from "./permissions-B4vU9L0Q.mjs";
3
- import { u as resolvePipelineSteps } from "./routerShared-DeESFp4a.mjs";
1
+ import { t as BaseController } from "./BaseController-swXruJ2_.mjs";
2
+ import { A as normalizePermissionResult } from "./permissions-gd_aUWrR.mjs";
3
+ import { u as resolvePipelineSteps } from "./routerShared-BqLRb5l7.mjs";
4
4
  import { t as executePipeline } from "./pipe-DVoIheVC.mjs";
5
- import { t as resolveActionPermission } from "./actionPermissions-C8YYU92K.mjs";
5
+ import { t as resolveActionPermission } from "./actionPermissions-sUUKDhtP.mjs";
6
6
  import { i as shouldRejectAdditionalProperties, r as schemaIRToZodShape, t as normalizeSchemaIR } from "./schemaIR-BlG9bY7v.mjs";
7
7
  import { t as pluralize } from "./pluralize-BneOJkpi.mjs";
8
8
  import { z } from "zod";
@@ -1145,6 +1145,7 @@ function resourceToTools(resource, config = {}) {
1145
1145
  resourcePermissions: resource.permissions,
1146
1146
  resourceActionPermissions: resource.actionPermissions
1147
1147
  });
1148
+ if (!actionPerms) throw new Error(`[Arc/MCP] Resource '${resource.name}': action '${actionName}' has no permission gate and the resource defines no \`permissions.update\` fallback. Declare one of:\n - \`actions.${actionName}.permissions: <PermissionCheck>\` (per-action)\n - \`actionPermissions: <PermissionCheck>\` (resource-wide)\n - \`permissions.update: <PermissionCheck>\` (inherited by actions)\nUse \`allowPublic()\` if you genuinely want the action unauthenticated.`);
1148
1149
  tools.push({
1149
1150
  name: toolName,
1150
1151
  description: String(description),
@@ -1,7 +1,7 @@
1
1
  import { _ as isElevated, n as PUBLIC_SCOPE, o as getOrgId, p as getUserId, v as isMember } from "./types-AOD8fxIw.mjs";
2
- import { P as resolveEffectiveRoles, j as applyFieldReadPermissions, k as evaluateAndApplyPermission } from "./permissions-B4vU9L0Q.mjs";
2
+ import { P as resolveEffectiveRoles, j as applyFieldReadPermissions, k as evaluateAndApplyPermission } from "./permissions-gd_aUWrR.mjs";
3
3
  import { t as getUserRoles } from "./types-DV9WDfeg.mjs";
4
- import { t as requestContext } from "./requestContext-CfRkaxwf.mjs";
4
+ import { t as requestContext } from "./requestContext-C5XeK3VA.mjs";
5
5
  import { t as executePipeline } from "./pipe-DVoIheVC.mjs";
6
6
  //#region src/scope/projection.ts
7
7
  /**
@@ -511,5 +511,62 @@ function buildPreHandlerChain(parts) {
511
511
  ...parts.customMws ?? []
512
512
  ].filter(Boolean);
513
513
  }
514
+ /**
515
+ * `RouteDefinition.preHandler` accepts two shapes:
516
+ *
517
+ * 1. **Array form** — `RouteHandlerMethod[]`. Used directly.
518
+ * 2. **Factory form** — `(fastify) => RouteHandlerMethod[]`. Called once at
519
+ * route-registration time with the Fastify instance, so handlers can
520
+ * capture decorators (`fastify.authenticate`, `fastify.events`, etc.)
521
+ * that aren't on the request.
522
+ *
523
+ * The two forms are equally idiomatic, but the discrimination is by
524
+ * `typeof preHandler === "function"`. Single-function shapes such as
525
+ * `multipartBody({...})` (a `RouteHandlerMethod`) **structurally satisfy
526
+ * the factory branch** at the call site, then fail with a cryptic
527
+ * `Cannot read properties of undefined (reading 'content-type')` once the
528
+ * handler runs with `fastify` in the request slot.
529
+ *
530
+ * This resolver:
531
+ * 1. Distinguishes the two valid shapes.
532
+ * 2. Validates the factory's RETURN — must be an array of functions.
533
+ * 3. Throws an actionable error pointing at the route + the fix when
534
+ * a single `RouteHandlerMethod` was passed instead of an array, OR
535
+ * when a factory returned the wrong shape.
536
+ *
537
+ * The error message names the route (`{method} {path}`) and the
538
+ * canonical fix (`preHandler: [yourHandler]`) so the failure mode is
539
+ * obvious instead of debug-archaeology.
540
+ *
541
+ * @param preHandler The `route.preHandler` value (any of the valid shapes
542
+ * plus the common bare-handler mistake).
543
+ * @param fastify Passed to factory-form preHandlers.
544
+ * @param routeId `"GET /todos/:id/attach"` (or similar) — used in the
545
+ * error message so a multi-route file points at the
546
+ * actual offender.
547
+ */
548
+ function resolveRoutePreHandlers(preHandler, fastify, routeId) {
549
+ if (preHandler === void 0 || preHandler === null) return [];
550
+ if (Array.isArray(preHandler)) return preHandler.filter((h) => typeof h === "function");
551
+ if (typeof preHandler === "function") {
552
+ let result;
553
+ try {
554
+ result = preHandler(fastify);
555
+ } catch (err) {
556
+ const msg = err instanceof Error ? err.message : String(err);
557
+ throw new TypeError(`Route ${routeId}: preHandler factory threw during route registration: ${msg}.\nIf you intended to pass a single handler (e.g. \`multipartBody({...})\`), wrap it in an array: \`preHandler: [yourHandler]\`. The factory form is \`(fastify) => RouteHandlerMethod[]\` — it must return an array.`, { cause: err instanceof Error ? err : void 0 });
558
+ }
559
+ if (!Array.isArray(result)) throw new TypeError(`Route ${routeId}: preHandler factory must return an array of handlers, got ${describeValue(result)}.\nCommon cause: passing a single \`RouteHandlerMethod\` (e.g. \`multipartBody({...})\`) where an array was expected. Wrap it: \`preHandler: [yourHandler]\`. The factory form \`(fastify) => RouteHandlerMethod[]\` is for cases that need the Fastify instance — e.g. \`(fastify) => [fastify.authenticate, myHandler]\`.`);
560
+ return result.filter((h) => typeof h === "function");
561
+ }
562
+ throw new TypeError(`Route ${routeId}: preHandler must be an array of handlers OR a factory \`(fastify) => RouteHandlerMethod[]\`. Got ${describeValue(preHandler)}.`);
563
+ }
564
+ function describeValue(v) {
565
+ if (v === null) return "null";
566
+ if (v === void 0) return "undefined";
567
+ if (typeof v === "function") return "a function (single handler — wrap in array)";
568
+ if (Array.isArray(v)) return `an array of length ${v.length}`;
569
+ return `${typeof v} (${JSON.stringify(v).slice(0, 80)})`;
570
+ }
514
571
  //#endregion
515
- export { getControllerScope as _, buildAuthMiddlewareForPermissions as a, buildPreHandlerChain as c, resolveRouterPluginMw as d, selectPluginMw as f, getControllerContext as g, createRequestContext as h, buildAuthMiddleware as i, buildRateLimitConfig as l, createFastifyHandler as m, buildActionPipelineHandler as n, buildCrudPermissionMw as o, createCrudHandlers as p, buildArcDecorator as r, buildPipelineHandler as s, buildActionPermissionMw as t, resolvePipelineSteps as u, sendControllerResponse as v, buildRequestScopeProjection as y };
572
+ export { getControllerContext as _, buildAuthMiddlewareForPermissions as a, buildRequestScopeProjection as b, buildPreHandlerChain as c, resolveRoutePreHandlers as d, resolveRouterPluginMw as f, createRequestContext as g, createFastifyHandler as h, buildAuthMiddleware as i, buildRateLimitConfig as l, createCrudHandlers as m, buildActionPipelineHandler as n, buildCrudPermissionMw as o, selectPluginMw as p, buildArcDecorator as r, buildPipelineHandler as s, buildActionPermissionMw as t, resolvePipelineSteps as u, getControllerScope as v, sendControllerResponse as y };
@@ -1,5 +1,5 @@
1
- import { B as ResourceDefinition, Pt as AnyRecord } from "../index-C_bgx9o4.mjs";
2
- import { d as ResourceLike, r as CreateAppOptions } from "../types-BdA4uMBV.mjs";
1
+ import { B as ResourceDefinition, Pt as AnyRecord } from "../index-6u4_Gg6G.mjs";
2
+ import { d as ResourceLike, r as CreateAppOptions } from "../types-BH7dEGvU.mjs";
3
3
  import { StorageContractSetup, StorageContractSetupResult, runStorageContract } from "./storageContract.mjs";
4
4
  import { FastifyInstance, FastifyServerOptions } from "fastify";
5
5
  import { Mock } from "vitest";
@@ -1081,7 +1081,7 @@ function pickDefaultAuth(authMode, callerAuth) {
1081
1081
  };
1082
1082
  }
1083
1083
  async function createTestApp(options = {}) {
1084
- const { createApp } = await import("../createApp-P1d6rjPy.mjs").then((n) => n.r);
1084
+ const { createApp } = await import("../createApp-BFxtdKy6.mjs").then((n) => n.r);
1085
1085
  const { resources = [], db = "in-memory", connectMongoose = false, authMode = "jwt", defaultOrgId, plugins, auth: callerAuth, ...appOptions } = options;
1086
1086
  let dbHandle;
1087
1087
  let dbUri;
@@ -1,4 +1,4 @@
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";
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-6u4_Gg6G.mjs";
2
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";
@@ -1,4 +1,4 @@
1
- import { B as ResourceDefinition } from "./index-C_bgx9o4.mjs";
1
+ import { B as ResourceDefinition } from "./index-6u4_Gg6G.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/integrations/mcp/types.d.ts
@@ -1,4 +1,4 @@
1
- import { At as Authenticator } from "./index-C_bgx9o4.mjs";
1
+ import { At as Authenticator } from "./index-6u4_Gg6G.mjs";
2
2
  import { r as CacheStore } from "./interface-Da0r7Lna.mjs";
3
3
  import { n as ElevationOptions } from "./elevation-s5ykdNHr.mjs";
4
4
  import { o as EventTransport } from "./EventTransport-CfVEGaEl.mjs";
@@ -1,2 +1,2 @@
1
- import { $ as ValidationResult, A as handleRaw, B as CompensationStep, C as queryParams, D as ArcQueryParser, E as wrapResponse, F as defineErrorMapper, G as CircuitBreakerOptions, H as withCompensation, I as CompensationDefinition, J as CircuitState, K as CircuitBreakerRegistry, L as CompensationError, M as Guard, N as GuardConfig, O as ArcQueryParserOptions, P as defineGuard, Q as ValidateOptions, R as CompensationHooks, S as paginationSchema, T as successResponseSchema, U as CircuitBreaker, V as defineCompensation, W as CircuitBreakerError, X as createCircuitBreakerRegistry, Y as createCircuitBreaker, Z as ConfigError, _ as getDefaultCrudSchemas, a as TransitionConfig, at as ErrorDetails, b as listResponse, c as JsonSchemaTarget, ct as OrgAccessDeniedError, d as isJsonSchema, dt as ServiceUnavailableError, et as assertValidConfig, f as isZodSchema, ft as UnauthorizedError, g as errorResponseSchema, gt as isArcError, h as deleteResponse, ht as createError, i as StateMachine, it as ConflictError, j as envelope, k as createQueryParser, l as convertOpenApiSchemas, lt as OrgRequiredError, m as JsonSchema, mt as createDomainError, n as EventsDecorator, nt as validateResourceConfig, o as createStateMachine, ot as ForbiddenError, p as toJsonSchema, pt as ValidationError, q as CircuitBreakerStats, r as hasEvents, rt as ArcError, s as simpleEqualityMatcher, st as NotFoundError, t as getUserId, tt as formatValidationErrors, u as convertRouteSchema, ut as RateLimitError, v as getListQueryParams, w as responses, x as mutationResponse, y as itemResponse, z as CompensationResult } from "../index-smCAoA5W.mjs";
1
+ import { $ as ValidationResult, A as handleRaw, B as CompensationStep, C as queryParams, D as ArcQueryParser, E as wrapResponse, F as defineErrorMapper, G as CircuitBreakerOptions, H as withCompensation, I as CompensationDefinition, J as CircuitState, K as CircuitBreakerRegistry, L as CompensationError, M as Guard, N as GuardConfig, O as ArcQueryParserOptions, P as defineGuard, Q as ValidateOptions, R as CompensationHooks, S as paginationSchema, T as successResponseSchema, U as CircuitBreaker, V as defineCompensation, W as CircuitBreakerError, X as createCircuitBreakerRegistry, Y as createCircuitBreaker, Z as ConfigError, _ as getDefaultCrudSchemas, a as TransitionConfig, at as ErrorDetails, b as listResponse, c as JsonSchemaTarget, ct as OrgAccessDeniedError, d as isJsonSchema, dt as ServiceUnavailableError, et as assertValidConfig, f as isZodSchema, ft as UnauthorizedError, g as errorResponseSchema, gt as isArcError, h as deleteResponse, ht as createError, i as StateMachine, it as ConflictError, j as envelope, k as createQueryParser, l as convertOpenApiSchemas, lt as OrgRequiredError, m as JsonSchema, mt as createDomainError, n as EventsDecorator, nt as validateResourceConfig, o as createStateMachine, ot as ForbiddenError, p as toJsonSchema, pt as ValidationError, q as CircuitBreakerStats, r as hasEvents, rt as ArcError, s as simpleEqualityMatcher, st as NotFoundError, t as getUserId, tt as formatValidationErrors, u as convertRouteSchema, ut as RateLimitError, v as getListQueryParams, w as responses, x as mutationResponse, y as itemResponse, z as CompensationResult } from "../index-DdQ3O9Pg.mjs";
2
2
  export { ArcError, ArcQueryParser, ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, CircuitBreakerOptions, CircuitBreakerRegistry, CircuitBreakerStats, CircuitState, CompensationDefinition, CompensationError, CompensationHooks, CompensationResult, CompensationStep, ConfigError, ConflictError, ErrorDetails, EventsDecorator, ForbiddenError, Guard, GuardConfig, JsonSchema, JsonSchemaTarget, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, StateMachine, TransitionConfig, UnauthorizedError, ValidateOptions, ValidationError, ValidationResult, assertValidConfig, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, envelope, errorResponseSchema, formatValidationErrors, getDefaultCrudSchemas, getListQueryParams, getUserId, handleRaw, hasEvents, isArcError, isJsonSchema, isZodSchema, itemResponse, listResponse, mutationResponse, paginationSchema, queryParams, responses, simpleEqualityMatcher, successResponseSchema, toJsonSchema, validateResourceConfig, withCompensation, wrapResponse };
@@ -1,4 +1,4 @@
1
- import { A as createQueryParser, C as mutationResponse, D as successResponseSchema, E as responses, M as simpleEqualityMatcher, O as wrapResponse, S as listResponse, T as queryParams, _ as deleteResponse, a as defineErrorMapper, b as getListQueryParams, c as CircuitBreaker, d as CircuitState, f as createCircuitBreaker, g as validateResourceConfig, h as formatValidationErrors, i as defineGuard, j as getUserId, k as ArcQueryParser, l as CircuitBreakerError, m as assertValidConfig, n as handleRaw, o as defineCompensation, p as createCircuitBreakerRegistry, r as envelope, s as withCompensation, t as createStateMachine, u as CircuitBreakerRegistry, v as errorResponseSchema, w as paginationSchema, x as itemResponse, y as getDefaultCrudSchemas } from "../utils-D3Yxnrwr.mjs";
1
+ import { A as createQueryParser, C as mutationResponse, D as successResponseSchema, E as responses, M as simpleEqualityMatcher, O as wrapResponse, S as listResponse, T as queryParams, _ as deleteResponse, a as defineErrorMapper, b as getListQueryParams, c as CircuitBreaker, d as CircuitState, f as createCircuitBreaker, g as validateResourceConfig, h as formatValidationErrors, i as defineGuard, j as getUserId, k as ArcQueryParser, l as CircuitBreakerError, m as assertValidConfig, n as handleRaw, o as defineCompensation, p as createCircuitBreakerRegistry, r as envelope, s as withCompensation, t as createStateMachine, u as CircuitBreakerRegistry, v as errorResponseSchema, w as paginationSchema, x as itemResponse, y as getDefaultCrudSchemas } from "../utils-CcYTj09l.mjs";
2
2
  import { a as OrgAccessDeniedError, c as ServiceUnavailableError, d as createDomainError, f as createError, i as NotFoundError, l as UnauthorizedError, n as ConflictError, o as OrgRequiredError, p as isArcError, r as ForbiddenError, s as RateLimitError, t as ArcError, u as ValidationError } from "../errors-D5c-5BJL.mjs";
3
3
  import { a as toJsonSchema, i as isZodSchema, n as convertRouteSchema, r as isJsonSchema, t as convertOpenApiSchemas } from "../schemaConverter-B0oKLuqI.mjs";
4
4
  import { t as hasEvents } from "../typeGuards-CcFZXgU7.mjs";
@@ -1,7 +1,7 @@
1
1
  import { m as RESERVED_QUERY_PARAMS, t as CRUD_OPERATIONS } from "./constants-BhY1OHoH.mjs";
2
2
  import { arcLog } from "./logger/index.mjs";
3
3
  import { t as ArcError } from "./errors-D5c-5BJL.mjs";
4
- import { r as getAvailablePresets } from "./presets-k604Lj99.mjs";
4
+ import { r as getAvailablePresets } from "./presets-Z7P5w4gF.mjs";
5
5
  //#region src/utils/simpleEqualityMatcher.ts
6
6
  /**
7
7
  * `simpleEqualityMatcher` — a minimal, dialect-agnostic flat-key equality