@classytic/arc 2.7.1 → 2.7.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 (94) hide show
  1. package/README.md +14 -2
  2. package/dist/adapters/index.d.mts +2 -2
  3. package/dist/audit/index.d.mts +1 -1
  4. package/dist/audit/index.mjs +1 -1
  5. package/dist/audit/mongodb.d.mts +1 -1
  6. package/dist/audit/mongodb.mjs +1 -1
  7. package/dist/auth/index.d.mts +4 -4
  8. package/dist/auth/redis-session.d.mts +1 -1
  9. package/dist/cache/index.d.mts +2 -2
  10. package/dist/cli/commands/docs.mjs +1 -1
  11. package/dist/cli/commands/generate.mjs +1 -1
  12. package/dist/core/index.d.mts +2 -2
  13. package/dist/{createApp-B_nvKNAQ.mjs → createApp-D7e77m8C.mjs} +18 -7
  14. package/dist/docs/index.d.mts +2 -2
  15. package/dist/docs/index.mjs +1 -1
  16. package/dist/dynamic/index.d.mts +2 -2
  17. package/dist/{errorHandler-DXUttWEO.mjs → errorHandler-CH8wk1eD.mjs} +16 -1
  18. package/dist/{errorHandler-COa51ho_.d.mts → errorHandler-pCpEtNd7.d.mts} +46 -2
  19. package/dist/{eventPlugin-DsaNNXzZ.mjs → eventPlugin-B6U_nCFU.mjs} +3 -2
  20. package/dist/{eventPlugin-BgLxJkIB.d.mts → eventPlugin-CdvUoUna.d.mts} +1 -1
  21. package/dist/events/index.d.mts +3 -3
  22. package/dist/events/index.mjs +1 -1
  23. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  24. package/dist/events/transports/redis.d.mts +1 -1
  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 +3 -3
  29. package/dist/idempotency/mongodb.d.mts +1 -1
  30. package/dist/idempotency/redis.d.mts +1 -1
  31. package/dist/{index-BYpRGXif.d.mts → index-B0extFr4.d.mts} +3 -3
  32. package/dist/{index-KXM8_JmQ.d.mts → index-BjShrzoj.d.mts} +3 -3
  33. package/dist/{index-StgFaQKD.d.mts → index-C9eYNjGR.d.mts} +1 -1
  34. package/dist/index.d.mts +8 -7
  35. package/dist/index.mjs +1 -1
  36. package/dist/integrations/event-gateway.d.mts +1 -1
  37. package/dist/integrations/event-gateway.mjs +1 -1
  38. package/dist/integrations/index.d.mts +1 -1
  39. package/dist/integrations/mcp/index.d.mts +2 -2
  40. package/dist/integrations/mcp/index.mjs +8 -5
  41. package/dist/integrations/mcp/testing.d.mts +1 -1
  42. package/dist/integrations/mcp/testing.mjs +1 -1
  43. package/dist/integrations/webhooks.d.mts +58 -1
  44. package/dist/integrations/webhooks.mjs +78 -7
  45. package/dist/integrations/websocket.d.mts +7 -1
  46. package/dist/integrations/websocket.mjs +7 -1
  47. package/dist/{interface-Dwzqt4mn.d.mts → interface-B91alUzq.d.mts} +4 -4
  48. package/dist/{mongodb-Bq90j-Uj.d.mts → mongodb-B7zupyck.d.mts} +1 -1
  49. package/dist/{mongodb-DdyYlIXg.d.mts → mongodb-Cgu9F1Nd.d.mts} +1 -1
  50. package/dist/org/index.d.mts +2 -2
  51. package/dist/permissions/index.d.mts +3 -3
  52. package/dist/plugins/index.d.mts +52 -5
  53. package/dist/plugins/index.mjs +5 -4
  54. package/dist/plugins/tracing-entry.d.mts +1 -1
  55. package/dist/plugins/tracing-entry.mjs +1 -1
  56. package/dist/policies/index.d.mts +1 -1
  57. package/dist/presets/index.d.mts +1 -1
  58. package/dist/presets/multiTenant.d.mts +1 -1
  59. package/dist/{queryCachePlugin-Bw8XyJpX.d.mts → queryCachePlugin-Ckl71mkc.d.mts} +1 -1
  60. package/dist/{redis-CyCntzTO.d.mts → redis-3TQxm2VZ.d.mts} +1 -1
  61. package/dist/{redis-stream-We_Ucl9-.d.mts → redis-stream-Dag5LFa9.d.mts} +1 -1
  62. package/dist/registry/index.d.mts +1 -1
  63. package/dist/replyHelpers-uDUIYh7u.mjs +40 -0
  64. package/dist/{resourceToTools-CkVSSzKg.mjs → resourceToTools-BJkoQoUP.mjs} +11 -5
  65. package/dist/rpc/index.d.mts +1 -1
  66. package/dist/scope/index.d.mts +2 -2
  67. package/dist/testing/index.d.mts +2 -2
  68. package/dist/testing/index.mjs +1 -1
  69. package/dist/types/index.d.mts +4 -4
  70. package/dist/{types-D0qf0Mf4.d.mts → types-2FlNl0mL.d.mts} +44 -9
  71. package/dist/{types-DPsC0taJ.d.mts → types-B4BNthET.d.mts} +1 -1
  72. package/dist/{types-ClmkMDK1.d.mts → types-C5g2oRC7.d.mts} +18 -2
  73. package/dist/utils/index.d.mts +3 -3
  74. package/package.json +5 -2
  75. package/skills/arc/SKILL.md +62 -1
  76. package/skills/arc/references/integrations.md +32 -7
  77. package/skills/arc/references/mcp.md +31 -7
  78. package/skills/arc/references/production.md +69 -0
  79. /package/dist/{EventTransport-CUpRK_Lg.d.mts → EventTransport-C4VheKeC.d.mts} +0 -0
  80. /package/dist/{circuitBreaker-DwxrljLB.d.mts → circuitBreaker-BBPDt-J_.d.mts} +0 -0
  81. /package/dist/{elevation-Dm-HTBCt.d.mts → elevation-D7WK0RXq.d.mts} +0 -0
  82. /package/dist/{errors-CCSsMpXE.d.mts → errors-BS6lZvWy.d.mts} +0 -0
  83. /package/dist/{externalPaths-Dg7OLsKo.d.mts → externalPaths-iba7jD3d.d.mts} +0 -0
  84. /package/dist/{fields-CYuLMJPD.d.mts → fields-D4nMDqnK.d.mts} +0 -0
  85. /package/dist/{interface-CnluRL4_.d.mts → interface-CG7oRZjX.d.mts} +0 -0
  86. /package/dist/{interface-B9rHWPxD.d.mts → interface-CSbZdv_3.d.mts} +0 -0
  87. /package/dist/{mongodb-mlgxkYI3.mjs → mongodb-B7X7P1P8.mjs} +0 -0
  88. /package/dist/{openapi-C5UhIeWu.mjs → openapi-BBSTVcMm.mjs} +0 -0
  89. /package/dist/{pluralize-COpOVar8.mjs → pluralize-Dckfq6US.mjs} +0 -0
  90. /package/dist/{sessionManager-IW4sbIea.d.mts → sessionManager-CEo9jwPI.d.mts} +0 -0
  91. /package/dist/{sse-Bp3dabF1.mjs → sse-6W0hjVS_.mjs} +0 -0
  92. /package/dist/{tracing-65B51Dw3.d.mts → tracing-DEqdGkr-.d.mts} +0 -0
  93. /package/dist/{types-CNEbix8T.d.mts → types--D3vvfdt.d.mts} +0 -0
  94. /package/dist/{versioning-aUUVziBY.mjs → versioning-CdBbFefk.mjs} +0 -0
@@ -37,6 +37,8 @@ interface WebhookPluginOptions {
37
37
  timeout?: number;
38
38
  /** Max delivery log entries kept in memory (default: 1000) */
39
39
  maxLogEntries?: number;
40
+ /** Max concurrent deliveries per event (default: 5). Set to 1 for sequential. */
41
+ concurrency?: number;
40
42
  }
41
43
  interface WebhookManager {
42
44
  register(sub: WebhookSubscription): Promise<void> | void;
@@ -49,8 +51,63 @@ declare module "fastify" {
49
51
  webhooks: WebhookManager;
50
52
  }
51
53
  }
54
+ /**
55
+ * Sign a payload with HMAC-SHA256 for outbound webhook delivery.
56
+ *
57
+ * @returns `sha256=<hex>` — the format written to `x-webhook-signature`
58
+ */
52
59
  declare function signPayload(payload: string, secret: string): string;
60
+ /** Options for `verifySignature` — customize for non-Arc webhook senders */
61
+ interface VerifySignatureOptions {
62
+ /**
63
+ * Expected prefix before the hex digest (default: `'sha256='`).
64
+ * Set to `''` for bare hex signatures.
65
+ */
66
+ prefix?: string;
67
+ /**
68
+ * HMAC algorithm (default: `'sha256'`).
69
+ * Must match what the sender uses — Arc's `signPayload` always uses sha256.
70
+ */
71
+ algorithm?: string;
72
+ }
73
+ /**
74
+ * Verify an inbound webhook signature using timing-safe comparison.
75
+ *
76
+ * Works with Arc's own `signPayload` format by default (`sha256=<hex>`),
77
+ * but configurable for any HMAC scheme via options.
78
+ *
79
+ * @param body - Raw request body (string or Buffer — must be the exact bytes the sender signed)
80
+ * @param secret - Shared secret between sender and receiver
81
+ * @param signature - The signature header value (e.g. `req.headers['x-webhook-signature']`)
82
+ * @param options - Override prefix/algorithm for non-Arc senders
83
+ * @returns `true` if valid, `false` otherwise — never throws
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * import { verifySignature } from '@classytic/arc/integrations/webhooks';
88
+ *
89
+ * // Arc-to-Arc (default headers + format)
90
+ * fastify.post('/webhooks/incoming', async (req, reply) => {
91
+ * const sig = req.headers['x-webhook-signature'] as string;
92
+ * if (!verifySignature(req.rawBody, secret, sig)) {
93
+ * return reply.status(401).send({ error: 'Invalid signature' });
94
+ * }
95
+ * // handle event via req.headers['x-webhook-event']
96
+ * });
97
+ *
98
+ * // Third-party sender with custom header + bare hex
99
+ * const valid = verifySignature(body, secret, req.headers['x-hub-signature'], {
100
+ * prefix: 'sha256=', // GitHub format
101
+ * });
102
+ *
103
+ * // Stripe-style (bare hex, different header)
104
+ * const valid = verifySignature(body, stripeSecret, req.headers['stripe-signature'], {
105
+ * prefix: '',
106
+ * });
107
+ * ```
108
+ */
109
+ declare function verifySignature(body: string | Buffer, secret: string, signature: string | undefined, options?: VerifySignatureOptions): boolean;
53
110
  declare const webhookPlugin: FastifyPluginAsync<WebhookPluginOptions>;
54
111
  declare const _default: FastifyPluginAsync<WebhookPluginOptions>;
55
112
  //#endregion
56
- export { WebhookDeliveryRecord, WebhookManager, WebhookPluginOptions, WebhookStore, WebhookSubscription, _default as default, signPayload, webhookPlugin };
113
+ export { VerifySignatureOptions, WebhookDeliveryRecord, WebhookManager, WebhookPluginOptions, WebhookStore, WebhookSubscription, _default as default, signPayload, verifySignature, webhookPlugin };
@@ -1,4 +1,4 @@
1
- import { createHmac } from "node:crypto";
1
+ import { createHmac, timingSafeEqual } from "node:crypto";
2
2
  import fp from "fastify-plugin";
3
3
  //#region src/integrations/webhooks.ts
4
4
  /**
@@ -30,11 +30,69 @@ import fp from "fastify-plugin";
30
30
  * // → POST https://customer.com/webhook with HMAC signature
31
31
  * ```
32
32
  */
33
+ /**
34
+ * Sign a payload with HMAC-SHA256 for outbound webhook delivery.
35
+ *
36
+ * @returns `sha256=<hex>` — the format written to `x-webhook-signature`
37
+ */
33
38
  function signPayload(payload, secret) {
34
39
  const hmac = createHmac("sha256", secret);
35
40
  hmac.update(payload);
36
41
  return `sha256=${hmac.digest("hex")}`;
37
42
  }
43
+ /**
44
+ * Verify an inbound webhook signature using timing-safe comparison.
45
+ *
46
+ * Works with Arc's own `signPayload` format by default (`sha256=<hex>`),
47
+ * but configurable for any HMAC scheme via options.
48
+ *
49
+ * @param body - Raw request body (string or Buffer — must be the exact bytes the sender signed)
50
+ * @param secret - Shared secret between sender and receiver
51
+ * @param signature - The signature header value (e.g. `req.headers['x-webhook-signature']`)
52
+ * @param options - Override prefix/algorithm for non-Arc senders
53
+ * @returns `true` if valid, `false` otherwise — never throws
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * import { verifySignature } from '@classytic/arc/integrations/webhooks';
58
+ *
59
+ * // Arc-to-Arc (default headers + format)
60
+ * fastify.post('/webhooks/incoming', async (req, reply) => {
61
+ * const sig = req.headers['x-webhook-signature'] as string;
62
+ * if (!verifySignature(req.rawBody, secret, sig)) {
63
+ * return reply.status(401).send({ error: 'Invalid signature' });
64
+ * }
65
+ * // handle event via req.headers['x-webhook-event']
66
+ * });
67
+ *
68
+ * // Third-party sender with custom header + bare hex
69
+ * const valid = verifySignature(body, secret, req.headers['x-hub-signature'], {
70
+ * prefix: 'sha256=', // GitHub format
71
+ * });
72
+ *
73
+ * // Stripe-style (bare hex, different header)
74
+ * const valid = verifySignature(body, stripeSecret, req.headers['stripe-signature'], {
75
+ * prefix: '',
76
+ * });
77
+ * ```
78
+ */
79
+ function verifySignature(body, secret, signature, options) {
80
+ if (!signature) return false;
81
+ const prefix = options?.prefix ?? "sha256=";
82
+ const algorithm = options?.algorithm ?? "sha256";
83
+ if (prefix && !signature.startsWith(prefix)) return false;
84
+ const providedHex = signature.slice(prefix.length);
85
+ if (!providedHex) return false;
86
+ const hmac = createHmac(algorithm, secret);
87
+ hmac.update(typeof body === "string" ? body : body);
88
+ const expectedHex = hmac.digest("hex");
89
+ if (providedHex.length !== expectedHex.length) return false;
90
+ try {
91
+ return timingSafeEqual(Buffer.from(providedHex, "hex"), Buffer.from(expectedHex, "hex"));
92
+ } catch {
93
+ return false;
94
+ }
95
+ }
38
96
  function matchesPattern(patterns, eventType) {
39
97
  for (const pattern of patterns) {
40
98
  if (pattern === "*") return true;
@@ -64,6 +122,7 @@ const webhookPlugin = async (fastify, opts = {}) => {
64
122
  const fetchFn = opts.fetch ?? globalThis.fetch;
65
123
  const timeout = opts.timeout ?? 1e4;
66
124
  const maxLogEntries = opts.maxLogEntries ?? 1e3;
125
+ const concurrency = opts.concurrency ?? 5;
67
126
  let subscriptions = [];
68
127
  const log = [];
69
128
  subscriptions = await store.getAll();
@@ -75,7 +134,7 @@ const webhookPlugin = async (fastify, opts = {}) => {
75
134
  payload: event.payload,
76
135
  meta: event.meta
77
136
  });
78
- for (const sub of matching) {
137
+ async function deliverToSubscription(sub) {
79
138
  const record = {
80
139
  subscriptionId: sub.id,
81
140
  eventType: event.type,
@@ -84,8 +143,8 @@ const webhookPlugin = async (fastify, opts = {}) => {
84
143
  };
85
144
  try {
86
145
  const signature = signPayload(body, sub.secret);
87
- const controller = new AbortController();
88
- const timer = setTimeout(() => controller.abort(), timeout);
146
+ const ac = new AbortController();
147
+ const timer = setTimeout(() => ac.abort(), timeout);
89
148
  try {
90
149
  const response = await fetchFn(sub.url, {
91
150
  method: "POST",
@@ -96,7 +155,7 @@ const webhookPlugin = async (fastify, opts = {}) => {
96
155
  "x-webhook-event": event.type
97
156
  },
98
157
  body,
99
- signal: controller.signal
158
+ signal: ac.signal
100
159
  });
101
160
  record.success = response.ok;
102
161
  record.status = response.status;
@@ -109,8 +168,14 @@ const webhookPlugin = async (fastify, opts = {}) => {
109
168
  log.push(record);
110
169
  if (log.length > maxLogEntries) log.splice(0, log.length - maxLogEntries);
111
170
  }
171
+ const pending = [...matching];
172
+ while (pending.length > 0) {
173
+ const batch = pending.splice(0, concurrency);
174
+ await Promise.allSettled(batch.map(deliverToSubscription));
175
+ }
112
176
  }
113
- if (fastify.events) await fastify.events.subscribe("*", dispatchEvent);
177
+ let unsubscribe;
178
+ if (fastify.events) unsubscribe = await fastify.events.subscribe("*", dispatchEvent);
114
179
  fastify.decorate("webhooks", {
115
180
  async register(sub) {
116
181
  await store.save(sub);
@@ -129,6 +194,12 @@ const webhookPlugin = async (fastify, opts = {}) => {
129
194
  return [...log];
130
195
  }
131
196
  });
197
+ fastify.addHook("onClose", async () => {
198
+ if (unsubscribe) {
199
+ unsubscribe();
200
+ unsubscribe = void 0;
201
+ }
202
+ });
132
203
  };
133
204
  var webhooks_default = fp(webhookPlugin, {
134
205
  name: "arc-webhooks",
@@ -136,4 +207,4 @@ var webhooks_default = fp(webhookPlugin, {
136
207
  dependencies: ["arc-events"]
137
208
  });
138
209
  //#endregion
139
- export { webhooks_default as default, signPayload, webhookPlugin };
210
+ export { webhooks_default as default, signPayload, verifySignature, webhookPlugin };
@@ -11,6 +11,10 @@ interface WebSocketClient {
11
11
  subscriptions: Set<string>;
12
12
  userId?: string;
13
13
  organizationId?: string;
14
+ /** OAuth client ID — present for service/machine-to-machine connections */
15
+ clientId?: string;
16
+ /** OAuth scopes — present for service/machine-to-machine connections */
17
+ scopes?: readonly string[];
14
18
  metadata?: Record<string, unknown>;
15
19
  }
16
20
  interface WebSocketMessage {
@@ -31,7 +35,9 @@ interface WebSocketPluginOptions {
31
35
  /** Custom authentication function for WebSocket upgrade */
32
36
  authenticate?: (request: unknown) => Promise<{
33
37
  userId?: string;
34
- organizationId?: string;
38
+ organizationId?: string; /** Set for machine-to-machine / service account auth */
39
+ clientId?: string; /** OAuth scopes for service accounts */
40
+ scopes?: readonly string[];
35
41
  } | null>;
36
42
  /** Max clients per resource subscription (default: 10000) */
37
43
  maxClientsPerRoom?: number;
@@ -165,6 +165,8 @@ const websocketPluginImpl = async (fastify, options) => {
165
165
  const clientId = `ws_${++clientCounter}_${Date.now()}`;
166
166
  let userId;
167
167
  let organizationId;
168
+ let serviceClientId;
169
+ let serviceScopes;
168
170
  if (auth) if (customAuth) {
169
171
  const result = await customAuth(request);
170
172
  if (!result) {
@@ -173,6 +175,8 @@ const websocketPluginImpl = async (fastify, options) => {
173
175
  }
174
176
  userId = result.userId;
175
177
  organizationId = result.organizationId;
178
+ serviceClientId = result.clientId;
179
+ serviceScopes = result.scopes;
176
180
  } else {
177
181
  if (fastify.authenticate) try {
178
182
  let rejected = false;
@@ -208,7 +212,9 @@ const websocketPluginImpl = async (fastify, options) => {
208
212
  socket,
209
213
  subscriptions: /* @__PURE__ */ new Set(),
210
214
  userId,
211
- organizationId
215
+ organizationId,
216
+ ...serviceClientId ? { clientId: serviceClientId } : {},
217
+ ...serviceScopes ? { scopes: serviceScopes } : {}
212
218
  };
213
219
  rooms.addClient(client);
214
220
  await onConnect?.(client);
@@ -1,6 +1,6 @@
1
- import { r as RequestScope } from "./types-CNEbix8T.mjs";
2
- import { n as FieldPermissionMap } from "./fields-CYuLMJPD.mjs";
3
- import { i as UserBase, t as PermissionCheck } from "./types-DPsC0taJ.mjs";
1
+ import { r as RequestScope } from "./types--D3vvfdt.mjs";
2
+ import { n as FieldPermissionMap } from "./fields-D4nMDqnK.mjs";
3
+ import { i as UserBase, t as PermissionCheck } from "./types-B4BNthET.mjs";
4
4
  import { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, RouteHandlerMethod, RouteHandlerMethod as RouteHandlerMethod$1 } from "fastify";
5
5
 
6
6
  //#region src/hooks/HookSystem.d.ts
@@ -795,7 +795,7 @@ type ControllerHandler<TResponse = unknown, TBody = unknown, TParams extends Rec
795
795
  * }]
796
796
  * ```
797
797
  */
798
- type FastifyHandler = (request: FastifyRequest, reply: FastifyReply) => Promise<void> | void;
798
+ type FastifyHandler<RouteGeneric extends Record<string, unknown> = Record<string, unknown>> = (request: FastifyRequest<RouteGeneric>, reply: FastifyReply) => Promise<unknown> | unknown;
799
799
  /**
800
800
  * Union type for route handlers
801
801
  */
@@ -1,4 +1,4 @@
1
- import { n as IdempotencyResult, r as IdempotencyStore } from "./interface-B9rHWPxD.mjs";
1
+ import { n as IdempotencyResult, r as IdempotencyStore } from "./interface-CSbZdv_3.mjs";
2
2
 
3
3
  //#region src/idempotency/stores/mongodb.d.ts
4
4
  interface MongoConnection {
@@ -1,4 +1,4 @@
1
- import { i as UserBase } from "./types-DPsC0taJ.mjs";
1
+ import { i as UserBase } from "./types-B4BNthET.mjs";
2
2
 
3
3
  //#region src/audit/stores/interface.d.ts
4
4
  type AuditAction = "create" | "update" | "delete" | "restore" | "custom";
@@ -1,5 +1,5 @@
1
- import { Rt as RouteHandler } from "../interface-Dwzqt4mn.mjs";
2
- import { i as UserBase } from "../types-DPsC0taJ.mjs";
1
+ import { Rt as RouteHandler } from "../interface-B91alUzq.mjs";
2
+ import { i as UserBase } from "../types-B4BNthET.mjs";
3
3
  import { InvitationAdapter, InvitationDoc, MemberDoc, OrgAdapter, OrgDoc, OrgPermissionStatement, OrgRole, OrganizationPluginOptions } from "./types.mjs";
4
4
  import { FastifyPluginAsync, RouteHandlerMethod } from "fastify";
5
5
 
@@ -1,4 +1,4 @@
1
- import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, r as FieldPermissionType, s as resolveEffectiveRoles, t as FieldPermission } from "../fields-CYuLMJPD.mjs";
2
- import { a as getUserRoles, i as UserBase, n as PermissionContext, o as normalizeRoles, r as PermissionResult, t as PermissionCheck } from "../types-DPsC0taJ.mjs";
3
- import { A as RoleHierarchy, C as authenticated, D as publicRead, E as presets_d_exports, M as applyPermissionResult, N as normalizePermissionResult, O as publicReadAdminWrite, S as adminOnly, T as ownerWithAdminBypass, _ as requireScopeContext, a as allOf, b as roles, c as createDynamicPermissionMatrix, d as requireAuth, f as requireOrgInScope, g as requireRoles, h as requireOwnership, i as PermissionEventBus, j as createRoleHierarchy, k as readOnly, l as createOrgPermissions, m as requireOrgRole, n as DynamicPermissionMatrix, o as allowPublic, p as requireOrgMembership, r as DynamicPermissionMatrixConfig, s as anyOf, t as ConnectEventsOptions, u as denyAll, v as requireServiceScope, w as fullPublic, x as when, y as requireTeamMembership } from "../index-BYpRGXif.mjs";
1
+ import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, r as FieldPermissionType, s as resolveEffectiveRoles, t as FieldPermission } from "../fields-D4nMDqnK.mjs";
2
+ import { a as getUserRoles, i as UserBase, n as PermissionContext, o as normalizeRoles, r as PermissionResult, t as PermissionCheck } from "../types-B4BNthET.mjs";
3
+ import { A as RoleHierarchy, C as authenticated, D as publicRead, E as presets_d_exports, M as applyPermissionResult, N as normalizePermissionResult, O as publicReadAdminWrite, S as adminOnly, T as ownerWithAdminBypass, _ as requireScopeContext, a as allOf, b as roles, c as createDynamicPermissionMatrix, d as requireAuth, f as requireOrgInScope, g as requireRoles, h as requireOwnership, i as PermissionEventBus, j as createRoleHierarchy, k as readOnly, l as createOrgPermissions, m as requireOrgRole, n as DynamicPermissionMatrix, o as allowPublic, p as requireOrgMembership, r as DynamicPermissionMatrixConfig, s as anyOf, t as ConnectEventsOptions, u as denyAll, v as requireServiceScope, w as fullPublic, x as when, y as requireTeamMembership } from "../index-B0extFr4.mjs";
4
4
  export { ConnectEventsOptions, DynamicPermissionMatrix, DynamicPermissionMatrixConfig, FieldPermission, FieldPermissionMap, FieldPermissionType, PermissionCheck, PermissionContext, PermissionEventBus, PermissionResult, RoleHierarchy, UserBase, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, applyPermissionResult, authenticated, createDynamicPermissionMatrix, createOrgPermissions, createRoleHierarchy, denyAll, fields, fullPublic, getUserRoles, normalizePermissionResult, normalizeRoles, ownerWithAdminBypass, presets_d_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, resolveEffectiveRoles, roles, when };
@@ -1,8 +1,9 @@
1
- import { Bt as ResourceRegistry, H as MiddlewareConfig, X as PresetHook, cn as HookSystem, ft as RouteSchemaOptions, l as AdditionalRoute, u as AnyRecord } from "../interface-Dwzqt4mn.mjs";
2
- import { t as ExternalOpenApiPaths } from "../externalPaths-Dg7OLsKo.mjs";
3
- import { _ as cachingPlugin, a as versioningPlugin, c as MetricsOptions, d as SSEOptions, f as _default$6, g as _default$1, h as CachingRule, i as _default$7, l as _default$4, m as CachingOptions, n as errorHandlerPlugin, o as MetricEntry, p as ssePlugin, r as VersioningOptions, s as MetricsCollector, t as ErrorHandlerOptions, u as metricsPlugin } from "../errorHandler-COa51ho_.mjs";
4
- import { t as TracingOptions } from "../tracing-65B51Dw3.mjs";
1
+ import { Bt as ResourceRegistry, H as MiddlewareConfig, X as PresetHook, cn as HookSystem, ft as RouteSchemaOptions, l as AdditionalRoute, u as AnyRecord } from "../interface-B91alUzq.mjs";
2
+ import { t as ExternalOpenApiPaths } from "../externalPaths-iba7jD3d.mjs";
3
+ import { _ as cachingPlugin, a as versioningPlugin, c as MetricsOptions, d as SSEOptions, f as _default$6, g as _default$1, h as CachingRule, i as _default$7, l as _default$4, m as CachingOptions, n as errorHandlerPlugin, o as MetricEntry, p as ssePlugin, r as VersioningOptions, s as MetricsCollector, t as ErrorHandlerOptions, u as metricsPlugin } from "../errorHandler-pCpEtNd7.mjs";
4
+ import { t as TracingOptions } from "../tracing-DEqdGkr-.mjs";
5
5
  import { FastifyInstance, FastifyPluginAsync } from "fastify";
6
+ import * as _$node_stream0 from "node:stream";
6
7
 
7
8
  //#region src/core/arcCorePlugin.d.ts
8
9
  interface ArcCorePluginOptions {
@@ -148,6 +149,52 @@ interface HealthOptions {
148
149
  declare const healthPlugin: FastifyPluginAsync<HealthOptions>;
149
150
  declare const _default$3: FastifyPluginAsync<HealthOptions>;
150
151
  //#endregion
152
+ //#region src/plugins/replyHelpers.d.ts
153
+ declare module "fastify" {
154
+ interface FastifyReply {
155
+ /** Send a success response with data */
156
+ ok<T>(data: T, statusCode?: number): FastifyReply;
157
+ /** Send an error response */
158
+ fail(error: string | string[], statusCode?: number): FastifyReply;
159
+ /** Send a paginated list response */
160
+ paginated<T>(result: {
161
+ docs: T[];
162
+ total: number;
163
+ page: number;
164
+ limit: number;
165
+ [key: string]: unknown;
166
+ }): FastifyReply;
167
+ /**
168
+ * Stream a readable source as a file download or raw stream.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * // CSV export
173
+ * return reply.stream(csvReadableStream, {
174
+ * contentType: 'text/csv',
175
+ * filename: 'export.csv',
176
+ * });
177
+ *
178
+ * // PDF download
179
+ * return reply.stream(pdfBuffer, {
180
+ * contentType: 'application/pdf',
181
+ * filename: 'report.pdf',
182
+ * });
183
+ *
184
+ * // Raw stream (no Content-Disposition)
185
+ * return reply.stream(dataStream, { contentType: 'application/octet-stream' });
186
+ * ```
187
+ */
188
+ stream(source: _$node_stream0.Readable | Buffer | AsyncIterable<unknown>, options: {
189
+ contentType: string;
190
+ filename?: string;
191
+ statusCode?: number;
192
+ }): FastifyReply;
193
+ }
194
+ }
195
+ declare function replyHelpersPluginFn(fastify: FastifyInstance): Promise<void>;
196
+ declare const replyHelpersPlugin: typeof replyHelpersPluginFn;
197
+ //#endregion
151
198
  //#region src/plugins/requestId.d.ts
152
199
  interface RequestIdOptions {
153
200
  /** Header name to read/write request ID (default: 'x-request-id') */
@@ -166,4 +213,4 @@ declare module "fastify" {
166
213
  declare const requestIdPlugin: FastifyPluginAsync<RequestIdOptions>;
167
214
  declare const _default$5: FastifyPluginAsync<RequestIdOptions>;
168
215
  //#endregion
169
- export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type CreatePluginDefinition, type ErrorHandlerOptions, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type RequestIdOptions, type SSEOptions, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, _default$1 as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, _default$2 as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, _default$3 as healthPlugin, healthPlugin as healthPluginFn, _default$4 as metricsPlugin, metricsPlugin as metricsPluginFn, _default$5 as requestIdPlugin, requestIdPlugin as requestIdPluginFn, _default$6 as ssePlugin, ssePlugin as ssePluginFn, _default$7 as versioningPlugin, versioningPlugin as versioningPluginFn };
216
+ export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type CreatePluginDefinition, type ErrorHandlerOptions, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type RequestIdOptions, type SSEOptions, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, _default$1 as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, _default$2 as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, _default$3 as healthPlugin, healthPlugin as healthPluginFn, _default$4 as metricsPlugin, metricsPlugin as metricsPluginFn, replyHelpersPlugin, _default$5 as requestIdPlugin, requestIdPlugin as requestIdPluginFn, _default$6 as ssePlugin, ssePlugin as ssePluginFn, _default$7 as versioningPlugin, versioningPlugin as versioningPluginFn };
@@ -5,10 +5,11 @@ import { t as hasEvents } from "../typeGuards-CcFZXgU7.mjs";
5
5
  import { t as HookSystem } from "../HookSystem-D7lfx--K.mjs";
6
6
  import { t as ResourceRegistry } from "../ResourceRegistry-DsHiG9cL.mjs";
7
7
  import { n as caching_default, t as cachingPlugin } from "../caching-5DtLwIqb.mjs";
8
- import { t as errorHandlerPlugin } from "../errorHandler-DXUttWEO.mjs";
8
+ import { t as errorHandlerPlugin } from "../errorHandler-CH8wk1eD.mjs";
9
9
  import { n as metrics_default, t as metricsPlugin } from "../metrics-Qnvwc-LQ.mjs";
10
- import { n as sse_default, t as ssePlugin } from "../sse-Bp3dabF1.mjs";
11
- import { n as versioning_default, t as versioningPlugin } from "../versioning-aUUVziBY.mjs";
10
+ import { t as replyHelpersPlugin } from "../replyHelpers-uDUIYh7u.mjs";
11
+ import { n as sse_default, t as ssePlugin } from "../sse-6W0hjVS_.mjs";
12
+ import { n as versioning_default, t as versioningPlugin } from "../versioning-CdBbFefk.mjs";
12
13
  import { randomUUID } from "node:crypto";
13
14
  import fp from "fastify-plugin";
14
15
  //#region src/core/arcCorePlugin.ts
@@ -409,4 +410,4 @@ var requestId_default = fp(requestIdPlugin, {
409
410
  fastify: "5.x"
410
411
  });
411
412
  //#endregion
412
- export { arcCorePlugin_default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, caching_default as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, gracefulShutdown_default as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, health_default as healthPlugin, healthPlugin as healthPluginFn, metrics_default as metricsPlugin, metricsPlugin as metricsPluginFn, requestId_default as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sse_default as ssePlugin, ssePlugin as ssePluginFn, versioning_default as versioningPlugin, versioningPlugin as versioningPluginFn };
413
+ export { arcCorePlugin_default as arcCorePlugin, arcCorePlugin as arcCorePluginFn, caching_default as cachingPlugin, cachingPlugin as cachingPluginFn, createPlugin, errorHandlerPlugin, errorHandlerPlugin as errorHandlerPluginFn, gracefulShutdown_default as gracefulShutdownPlugin, gracefulShutdownPlugin as gracefulShutdownPluginFn, health_default as healthPlugin, healthPlugin as healthPluginFn, metrics_default as metricsPlugin, metricsPlugin as metricsPluginFn, replyHelpersPlugin, requestId_default as requestIdPlugin, requestIdPlugin as requestIdPluginFn, sse_default as ssePlugin, ssePlugin as ssePluginFn, versioning_default as versioningPlugin, versioningPlugin as versioningPluginFn };
@@ -1,2 +1,2 @@
1
- import { a as traced, i as isTracingAvailable, n as _default, r as createSpan, t as TracingOptions } from "../tracing-65B51Dw3.mjs";
1
+ import { a as traced, i as isTracingAvailable, n as _default, r as createSpan, t as TracingOptions } from "../tracing-DEqdGkr-.mjs";
2
2
  export { type TracingOptions, createSpan, isTracingAvailable, traced, _default as tracingPlugin };
@@ -44,7 +44,7 @@ try {
44
44
  function createTracerProvider(options) {
45
45
  if (!isAvailable) return null;
46
46
  const { serviceName = "@classytic/arc", serviceVersion, exporterUrl = "http://localhost:4318/v1/traces" } = options;
47
- const resolvedVersion = serviceVersion ?? "2.7.1";
47
+ const resolvedVersion = serviceVersion ?? "2.7.3";
48
48
  const exporter = new OTLPTraceExporter({ url: exporterUrl });
49
49
  const provider = new NodeTracerProvider({ resource: { attributes: {
50
50
  "service.name": serviceName,
@@ -1,4 +1,4 @@
1
- import { t as PermissionCheck } from "../types-DPsC0taJ.mjs";
1
+ import { t as PermissionCheck } from "../types-B4BNthET.mjs";
2
2
  import { FastifyReply, FastifyRequest } from "fastify";
3
3
 
4
4
  //#region src/policies/PolicyInterface.d.ts
@@ -1,4 +1,4 @@
1
- import { Gt as PaginatedResult, It as IControllerResponse, Lt as IRequestContext, Z as PresetResult, ot as ResourceConfig, u as AnyRecord } from "../interface-Dwzqt4mn.mjs";
1
+ import { Gt as PaginatedResult, It as IControllerResponse, Lt as IRequestContext, Z as PresetResult, ot as ResourceConfig, u as AnyRecord } from "../interface-B91alUzq.mjs";
2
2
  import { MultiTenantOptions, TenantFieldSpec, multiTenantPreset } from "./multiTenant.mjs";
3
3
 
4
4
  //#region src/presets/ownedByUser.d.ts
@@ -1,4 +1,4 @@
1
- import { S as CrudRouteKey, Z as PresetResult } from "../interface-Dwzqt4mn.mjs";
1
+ import { S as CrudRouteKey, Z as PresetResult } from "../interface-B91alUzq.mjs";
2
2
 
3
3
  //#region src/presets/multiTenant.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { i as CacheStore } from "./interface-CnluRL4_.mjs";
1
+ import { i as CacheStore } from "./interface-CG7oRZjX.mjs";
2
2
  import { FastifyPluginAsync } from "fastify";
3
3
 
4
4
  //#region src/cache/QueryCache.d.ts
@@ -1,4 +1,4 @@
1
- import { n as IdempotencyResult, r as IdempotencyStore } from "./interface-B9rHWPxD.mjs";
1
+ import { n as IdempotencyResult, r as IdempotencyStore } from "./interface-CSbZdv_3.mjs";
2
2
 
3
3
  //#region src/idempotency/stores/redis.d.ts
4
4
  interface RedisClient {
@@ -1,4 +1,4 @@
1
- import { i as EventTransport, n as EventHandler, r as EventLogger, t as DomainEvent } from "./EventTransport-CUpRK_Lg.mjs";
1
+ import { i as EventTransport, n as EventHandler, r as EventLogger, t as DomainEvent } from "./EventTransport-C4VheKeC.mjs";
2
2
 
3
3
  //#region src/events/transports/redis-stream.d.ts
4
4
  interface RedisStreamLike {
@@ -1,4 +1,4 @@
1
- import { Bt as ResourceRegistry, R as IntrospectionPluginOptions, zt as RegisterOptions } from "../interface-Dwzqt4mn.mjs";
1
+ import { Bt as ResourceRegistry, R as IntrospectionPluginOptions, zt as RegisterOptions } from "../interface-B91alUzq.mjs";
2
2
  import { FastifyPluginAsync } from "fastify";
3
3
 
4
4
  //#region src/registry/introspectionPlugin.d.ts
@@ -0,0 +1,40 @@
1
+ import { t as __exportAll } from "./chunk-BpYLSNr0.mjs";
2
+ import fp from "fastify-plugin";
3
+ //#region src/plugins/replyHelpers.ts
4
+ var replyHelpers_exports = /* @__PURE__ */ __exportAll({ replyHelpersPlugin: () => replyHelpersPlugin });
5
+ async function replyHelpersPluginFn(fastify) {
6
+ fastify.decorateReply("ok", function(data, statusCode = 200) {
7
+ return this.code(statusCode).send({
8
+ success: true,
9
+ data
10
+ });
11
+ });
12
+ fastify.decorateReply("fail", function(error, statusCode = 400) {
13
+ if (Array.isArray(error)) return this.code(statusCode).send({
14
+ success: false,
15
+ errors: error
16
+ });
17
+ return this.code(statusCode).send({
18
+ success: false,
19
+ error
20
+ });
21
+ });
22
+ fastify.decorateReply("paginated", function(result) {
23
+ return this.code(200).send({
24
+ success: true,
25
+ ...result
26
+ });
27
+ });
28
+ fastify.decorateReply("stream", function(source, options) {
29
+ this.code(options.statusCode ?? 200);
30
+ this.header("content-type", options.contentType);
31
+ if (options.filename) this.header("content-disposition", `attachment; filename="${options.filename}"`);
32
+ return this.send(source);
33
+ });
34
+ }
35
+ const replyHelpersPlugin = fp(replyHelpersPluginFn, {
36
+ name: "arc-reply-helpers",
37
+ fastify: "5.x"
38
+ });
39
+ //#endregion
40
+ export { replyHelpers_exports as n, replyHelpersPlugin as t };
@@ -1,6 +1,6 @@
1
1
  import { t as BaseController } from "./BaseController-CpMfCXdn.mjs";
2
2
  import { n as normalizePermissionResult } from "./applyPermissionResult-D6GPMsvh.mjs";
3
- import { t as pluralize } from "./pluralize-COpOVar8.mjs";
3
+ import { t as pluralize } from "./pluralize-Dckfq6US.mjs";
4
4
  import { z } from "zod";
5
5
  //#region src/integrations/mcp/createMcpServer.ts
6
6
  /**
@@ -228,7 +228,7 @@ function buildRequestContext(input, auth, operation, policyFilters, scopeOverrid
228
228
  const sessionScope = buildScope(auth);
229
229
  const scope = scopeOverride && sessionScope.kind === "public" ? scopeOverride : sessionScope;
230
230
  const base = {
231
- user: auth ? {
231
+ user: auth?.userId ? {
232
232
  id: auth.userId,
233
233
  _id: auth.userId,
234
234
  ...auth
@@ -344,17 +344,23 @@ function expandOperatorKeys(input) {
344
344
  }
345
345
  function buildScope(auth) {
346
346
  if (!auth) return { kind: "public" };
347
+ if (auth.clientId && auth.organizationId) return {
348
+ kind: "service",
349
+ clientId: auth.clientId,
350
+ organizationId: auth.organizationId,
351
+ scopes: auth.scopes
352
+ };
347
353
  if (auth.organizationId) return {
348
354
  kind: "member",
349
355
  userId: auth.userId,
350
- userRoles: [],
356
+ userRoles: auth.roles ?? [],
351
357
  organizationId: auth.organizationId,
352
- orgRoles: []
358
+ orgRoles: auth.orgRoles ?? []
353
359
  };
354
360
  return {
355
361
  kind: "authenticated",
356
362
  userId: auth.userId,
357
- userRoles: []
363
+ userRoles: auth.roles ?? []
358
364
  };
359
365
  }
360
366
  //#endregion
@@ -1,4 +1,4 @@
1
- import { r as CircuitBreakerOptions } from "../circuitBreaker-DwxrljLB.mjs";
1
+ import { r as CircuitBreakerOptions } from "../circuitBreaker-BBPDt-J_.mjs";
2
2
 
3
3
  //#region src/rpc/serviceClient.d.ts
4
4
  interface RetryConfig {
@@ -1,5 +1,5 @@
1
- import { _ as isAuthenticated, a as getClientId, b as isOrgInScope, c as getOrgRoles, d as getScopeContextMap, f as getServiceScopes, g as hasOrgAccess, h as getUserRoles, i as getAncestorOrgIds, l as getRequestScope, m as getUserId, n as PUBLIC_SCOPE, o as getOrgContext, p as getTeamId, r as RequestScope, s as getOrgId, t as AUTHENTICATED_SCOPE, u as getScopeContext, v as isElevated, x as isService, y as isMember } from "../types-CNEbix8T.mjs";
2
- import { i as elevationPlugin, n as ElevationOptions, r as _default, t as ElevationEvent } from "../elevation-Dm-HTBCt.mjs";
1
+ import { _ as isAuthenticated, a as getClientId, b as isOrgInScope, c as getOrgRoles, d as getScopeContextMap, f as getServiceScopes, g as hasOrgAccess, h as getUserRoles, i as getAncestorOrgIds, l as getRequestScope, m as getUserId, n as PUBLIC_SCOPE, o as getOrgContext, p as getTeamId, r as RequestScope, s as getOrgId, t as AUTHENTICATED_SCOPE, u as getScopeContext, v as isElevated, x as isService, y as isMember } from "../types--D3vvfdt.mjs";
2
+ import { i as elevationPlugin, n as ElevationOptions, r as _default, t as ElevationEvent } from "../elevation-D7WK0RXq.mjs";
3
3
  import { FastifyReply, FastifyRequest } from "fastify";
4
4
 
5
5
  //#region src/scope/rateLimitKey.d.ts
@@ -1,5 +1,5 @@
1
- import { Ut as CrudRepository, Vt as ResourceDefinition, u as AnyRecord } from "../interface-Dwzqt4mn.mjs";
2
- import { d as ResourceLike, r as CreateAppOptions } from "../types-D0qf0Mf4.mjs";
1
+ import { Ut as CrudRepository, Vt as ResourceDefinition, u as AnyRecord } from "../interface-B91alUzq.mjs";
2
+ import { d as ResourceLike, r as CreateAppOptions } from "../types-2FlNl0mL.mjs";
3
3
  import Fastify, { FastifyInstance, FastifyServerOptions } from "fastify";
4
4
  import { Connection } from "mongoose";
5
5
  import { Mock } from "vitest";
@@ -1796,7 +1796,7 @@ function runEventTests(resourceName, displayName, events) {
1796
1796
  * ```
1797
1797
  */
1798
1798
  async function createTestApp(options = {}) {
1799
- const { createApp } = await import("../createApp-B_nvKNAQ.mjs").then((n) => n.r);
1799
+ const { createApp } = await import("../createApp-D7e77m8C.mjs").then((n) => n.r);
1800
1800
  const { useInMemoryDb = true, mongoUri: providedMongoUri, ...appOptions } = options;
1801
1801
  const defaultAuth = {
1802
1802
  type: "jwt",
@@ -1,5 +1,5 @@
1
- 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-CNEbix8T.mjs";
2
- import { $ as RateLimitConfig, A as FieldRule, B as JwtContext, C as CrudRouterOptions, Ct as getUserId, D as FastifyRequestExtras, E as EventsDecorator, F as InferDocType, Ft as IController, G as OpenApiSchemas, Gt as PaginatedResult, H as MiddlewareConfig, I as InferResourceDoc, It as IControllerResponse, J as PopulateOption, K as OwnershipCheck, Kt as PaginationParams, L as IntrospectionData, Lt as IRequestContext, M as HealthCheck, Mt as ControllerHandler, N as HealthOptions, Nt as ControllerLike, O as FastifyWithAuth, P as InferAdapterDoc, Pt as FastifyHandler, Q as QueryParserInterface, R as IntrospectionPluginOptions, Rt as RouteHandler, S as CrudRouteKey, St as envelope, T as EventDefinition, Tt as BaseControllerOptions, U as MiddlewareHandler, Ut as CrudRepository, V as LookupOption, W as ObjectId, Wt as InferDoc, X as PresetHook, Y as PresetFunction, Z as PresetResult, _ as Authenticator, _t as TypedResourceConfig, at as ResourceCacheConfig, b as ControllerQueryOptions, bt as ValidateOptions, ct as ResourceHooks, d as ApiResponse, dt as RouteHandlerMethod, et as RegistryEntry, f as ArcDecorator, ft as RouteSchemaOptions, g as AuthPluginOptions, gt as TypedRepository, h as AuthHelpers, ht as TypedController, it as RequestWithExtras, j as GracefulShutdownOptions, k as FastifyWithDecorators, l as AdditionalRoute, lt as ResourceMetadata, m as ArcRequest, mt as TokenPair, nt as RequestContext, ot as ResourceConfig, p as ArcInternalMetadata, pt as ServiceContext, q as ParsedQuery, qt as QueryOptions, rt as RequestIdOptions, st as ResourceHookContext, tt as RegistryStats, u as AnyRecord, ut as ResourcePermissions, v as AuthenticatorContext, vt as UserLike, w as CrudSchemas, x as CrudController, xt as ValidationResult, y as ConfigError, yt as UserOrganization, z as JWTPayload } from "../interface-Dwzqt4mn.mjs";
3
- import { i as UserBase, n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "../types-DPsC0taJ.mjs";
4
- import { n as ElevationOptions, t as ElevationEvent } from "../elevation-Dm-HTBCt.mjs";
1
+ 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--D3vvfdt.mjs";
2
+ import { $ as RateLimitConfig, A as FieldRule, B as JwtContext, C as CrudRouterOptions, Ct as getUserId, D as FastifyRequestExtras, E as EventsDecorator, F as InferDocType, Ft as IController, G as OpenApiSchemas, Gt as PaginatedResult, H as MiddlewareConfig, I as InferResourceDoc, It as IControllerResponse, J as PopulateOption, K as OwnershipCheck, Kt as PaginationParams, L as IntrospectionData, Lt as IRequestContext, M as HealthCheck, Mt as ControllerHandler, N as HealthOptions, Nt as ControllerLike, O as FastifyWithAuth, P as InferAdapterDoc, Pt as FastifyHandler, Q as QueryParserInterface, R as IntrospectionPluginOptions, Rt as RouteHandler, S as CrudRouteKey, St as envelope, T as EventDefinition, Tt as BaseControllerOptions, U as MiddlewareHandler, Ut as CrudRepository, V as LookupOption, W as ObjectId, Wt as InferDoc, X as PresetHook, Y as PresetFunction, Z as PresetResult, _ as Authenticator, _t as TypedResourceConfig, at as ResourceCacheConfig, b as ControllerQueryOptions, bt as ValidateOptions, ct as ResourceHooks, d as ApiResponse, dt as RouteHandlerMethod, et as RegistryEntry, f as ArcDecorator, ft as RouteSchemaOptions, g as AuthPluginOptions, gt as TypedRepository, h as AuthHelpers, ht as TypedController, it as RequestWithExtras, j as GracefulShutdownOptions, k as FastifyWithDecorators, l as AdditionalRoute, lt as ResourceMetadata, m as ArcRequest, mt as TokenPair, nt as RequestContext, ot as ResourceConfig, p as ArcInternalMetadata, pt as ServiceContext, q as ParsedQuery, qt as QueryOptions, rt as RequestIdOptions, st as ResourceHookContext, tt as RegistryStats, u as AnyRecord, ut as ResourcePermissions, v as AuthenticatorContext, vt as UserLike, w as CrudSchemas, x as CrudController, xt as ValidationResult, y as ConfigError, yt as UserOrganization, z as JWTPayload } from "../interface-B91alUzq.mjs";
3
+ import { i as UserBase, n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "../types-B4BNthET.mjs";
4
+ import { n as ElevationOptions, t as ElevationEvent } from "../elevation-D7WK0RXq.mjs";
5
5
  export { AUTHENTICATED_SCOPE, AdditionalRoute, AnyRecord, ApiResponse, ArcDecorator, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRepository, CrudRouteKey, CrudRouterOptions, CrudSchemas, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, ObjectId, OpenApiSchemas, OwnershipCheck, PUBLIC_SCOPE, PaginatedResult, PaginationParams, ParsedQuery, PermissionCheck, PermissionContext, PermissionResult, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryOptions, QueryParserInterface, RateLimitConfig, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResourceCacheConfig, ResourceConfig, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, RouteHandler, RouteHandlerMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult, envelope, getOrgId, getOrgRoles, getTeamId, getUserId, hasOrgAccess, isAuthenticated, isElevated, isMember };