@classytic/arc 2.2.5 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +187 -18
  2. package/bin/arc.js +11 -3
  3. package/dist/BaseController-CkM5dUh_.mjs +1031 -0
  4. package/dist/{EventTransport-BkUDYZEb.d.mts → EventTransport-wc5hSLik.d.mts} +1 -1
  5. package/dist/{HookSystem-BsGV-j2l.mjs → HookSystem-COkyWztM.mjs} +2 -3
  6. package/dist/{ResourceRegistry-7Ic20ZMw.mjs → ResourceRegistry-DeCIFlix.mjs} +8 -5
  7. package/dist/adapters/index.d.mts +3 -5
  8. package/dist/adapters/index.mjs +2 -3
  9. package/dist/{prisma-DJbMt3yf.mjs → adapters-DTC4Ug66.mjs} +45 -12
  10. package/dist/audit/index.d.mts +4 -7
  11. package/dist/audit/index.mjs +2 -29
  12. package/dist/audit/mongodb.d.mts +1 -4
  13. package/dist/audit/mongodb.mjs +2 -3
  14. package/dist/auth/index.d.mts +7 -9
  15. package/dist/auth/index.mjs +65 -63
  16. package/dist/auth/redis-session.d.mts +1 -1
  17. package/dist/auth/redis-session.mjs +1 -2
  18. package/dist/{betterAuthOpenApi-DjWDddNc.mjs → betterAuthOpenApi-lz0IRbXJ.mjs} +4 -6
  19. package/dist/cache/index.d.mts +23 -23
  20. package/dist/cache/index.mjs +4 -6
  21. package/dist/{caching-GSDJcA6-.mjs → caching-BSXB-Xr7.mjs} +2 -24
  22. package/dist/chunk-BpYLSNr0.mjs +14 -0
  23. package/dist/circuitBreaker-BOBOpN2w.mjs +284 -0
  24. package/dist/circuitBreaker-JP2GdJ4b.d.mts +206 -0
  25. package/dist/cli/commands/describe.mjs +24 -7
  26. package/dist/cli/commands/docs.mjs +6 -7
  27. package/dist/cli/commands/doctor.d.mts +10 -0
  28. package/dist/cli/commands/doctor.mjs +156 -0
  29. package/dist/cli/commands/generate.mjs +66 -17
  30. package/dist/cli/commands/init.mjs +315 -45
  31. package/dist/cli/commands/introspect.mjs +2 -4
  32. package/dist/cli/index.d.mts +1 -10
  33. package/dist/cli/index.mjs +4 -153
  34. package/dist/{constants-DdXFXQtN.mjs → constants-Cxde4rpC.mjs} +1 -2
  35. package/dist/core/index.d.mts +3 -5
  36. package/dist/core/index.mjs +5 -4
  37. package/dist/core-C1XCMtqM.mjs +185 -0
  38. package/dist/{createApp-BKHSl2nT.mjs → createApp-ByWNRsZj.mjs} +65 -36
  39. package/dist/{defineResource-DO9ONe_D.mjs → defineResource-D9aY5Cy6.mjs} +154 -1165
  40. package/dist/discovery/index.mjs +37 -5
  41. package/dist/docs/index.d.mts +6 -9
  42. package/dist/docs/index.mjs +3 -21
  43. package/dist/dynamic/index.d.mts +93 -0
  44. package/dist/dynamic/index.mjs +122 -0
  45. package/dist/{elevation-DSTbVvYj.mjs → elevation-BEdACOLB.mjs} +5 -36
  46. package/dist/{elevation-DGo5shaX.d.mts → elevation-Ca_yveIO.d.mts} +41 -7
  47. package/dist/{errorHandler-C3GY3_ow.mjs → errorHandler--zp54tGc.mjs} +3 -5
  48. package/dist/errorHandler-Do4vVQ1f.d.mts +139 -0
  49. package/dist/{errors-DBANPbGr.mjs → errors-rxhfP7Hf.mjs} +1 -2
  50. package/dist/{eventPlugin-BEOvaDqo.mjs → eventPlugin-Ba00swHF.mjs} +25 -27
  51. package/dist/{eventPlugin-H6wDDjGO.d.mts → eventPlugin-iGrSEmwJ.d.mts} +105 -5
  52. package/dist/events/index.d.mts +72 -7
  53. package/dist/events/index.mjs +216 -4
  54. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  55. package/dist/events/transports/redis-stream-entry.mjs +19 -7
  56. package/dist/events/transports/redis.d.mts +1 -1
  57. package/dist/events/transports/redis.mjs +3 -4
  58. package/dist/factory/index.d.mts +23 -9
  59. package/dist/factory/index.mjs +48 -3
  60. package/dist/{fields-Bi_AVKSo.d.mts → fields-DFwdaWCq.d.mts} +1 -1
  61. package/dist/{fields-CTd_CrKr.mjs → fields-ipsbIRPK.mjs} +1 -2
  62. package/dist/hooks/index.d.mts +1 -3
  63. package/dist/hooks/index.mjs +2 -3
  64. package/dist/idempotency/index.d.mts +5 -5
  65. package/dist/idempotency/index.mjs +3 -7
  66. package/dist/idempotency/mongodb.d.mts +1 -1
  67. package/dist/idempotency/mongodb.mjs +4 -5
  68. package/dist/idempotency/redis.d.mts +1 -1
  69. package/dist/idempotency/redis.mjs +2 -5
  70. package/dist/{fastifyAdapter-CyAA2zlB.d.mts → index-BL8CaQih.d.mts} +56 -57
  71. package/dist/index-Diqcm14c.d.mts +369 -0
  72. package/dist/{prisma-xjhMEq_S.d.mts → index-yhxyjqNb.d.mts} +4 -5
  73. package/dist/index.d.mts +100 -105
  74. package/dist/index.mjs +85 -58
  75. package/dist/integrations/event-gateway.d.mts +1 -1
  76. package/dist/integrations/event-gateway.mjs +8 -4
  77. package/dist/integrations/index.d.mts +4 -2
  78. package/dist/integrations/index.mjs +1 -1
  79. package/dist/integrations/jobs.d.mts +2 -2
  80. package/dist/integrations/jobs.mjs +63 -14
  81. package/dist/integrations/mcp/index.d.mts +219 -0
  82. package/dist/integrations/mcp/index.mjs +572 -0
  83. package/dist/integrations/mcp/testing.d.mts +53 -0
  84. package/dist/integrations/mcp/testing.mjs +104 -0
  85. package/dist/integrations/streamline.mjs +39 -19
  86. package/dist/integrations/webhooks.d.mts +56 -0
  87. package/dist/integrations/webhooks.mjs +139 -0
  88. package/dist/integrations/websocket-redis.d.mts +46 -0
  89. package/dist/integrations/websocket-redis.mjs +50 -0
  90. package/dist/integrations/websocket.d.mts +68 -2
  91. package/dist/integrations/websocket.mjs +96 -13
  92. package/dist/{interface-CSNjltAc.d.mts → interface-B4awm1RJ.d.mts} +2 -2
  93. package/dist/interface-DGmPxakH.d.mts +2213 -0
  94. package/dist/{keys-DhqDRxv3.mjs → keys-qcD-TVJl.mjs} +3 -4
  95. package/dist/{logger-ByrvQWZO.mjs → logger-Dz3j1ItV.mjs} +2 -4
  96. package/dist/{memory-B2v7KrCB.mjs → memory-Cb_7iy9e.mjs} +2 -4
  97. package/dist/metrics-Csh4nsvv.mjs +224 -0
  98. package/dist/migrations/index.mjs +3 -7
  99. package/dist/{mongodb-DNKEExbf.mjs → mongodb-BuQ7fNTg.mjs} +1 -4
  100. package/dist/{mongodb-ClykrfGo.d.mts → mongodb-CUpYfxfD.d.mts} +2 -3
  101. package/dist/{mongodb-Dg8O_gvd.d.mts → mongodb-bga9AbkD.d.mts} +2 -2
  102. package/dist/{openapi-9nB_kiuR.mjs → openapi-CBmZ6EQN.mjs} +4 -21
  103. package/dist/org/index.d.mts +12 -14
  104. package/dist/org/index.mjs +92 -119
  105. package/dist/org/types.d.mts +2 -2
  106. package/dist/org/types.mjs +1 -1
  107. package/dist/permissions/index.d.mts +4 -278
  108. package/dist/permissions/index.mjs +4 -579
  109. package/dist/permissions-CA5zg0yK.mjs +751 -0
  110. package/dist/plugins/index.d.mts +104 -107
  111. package/dist/plugins/index.mjs +203 -313
  112. package/dist/plugins/response-cache.mjs +4 -69
  113. package/dist/plugins/tracing-entry.d.mts +1 -1
  114. package/dist/plugins/tracing-entry.mjs +24 -11
  115. package/dist/{pluralize-CM-jZg7p.mjs → pluralize-CcT6qF0a.mjs} +12 -13
  116. package/dist/policies/index.d.mts +2 -2
  117. package/dist/policies/index.mjs +80 -83
  118. package/dist/presets/index.d.mts +26 -19
  119. package/dist/presets/index.mjs +2 -142
  120. package/dist/presets/multiTenant.d.mts +1 -4
  121. package/dist/presets/multiTenant.mjs +4 -6
  122. package/dist/presets-C9QXJV1u.mjs +422 -0
  123. package/dist/{queryCachePlugin-B6R0d4av.mjs → queryCachePlugin-ClosZdNS.mjs} +6 -27
  124. package/dist/{queryCachePlugin-Q6SYuHZ6.d.mts → queryCachePlugin-DcmETvcB.d.mts} +3 -3
  125. package/dist/queryParser-CgCtsjti.mjs +352 -0
  126. package/dist/{redis-UwjEp8Ea.d.mts → redis-CQ5YxMC5.d.mts} +2 -2
  127. package/dist/{redis-stream-CBg0upHI.d.mts → redis-stream-BW9UKLZM.d.mts} +9 -2
  128. package/dist/registry/index.d.mts +1 -4
  129. package/dist/registry/index.mjs +3 -4
  130. package/dist/{introspectionPlugin-B3JkrjwU.mjs → registry-I-ogLgL9.mjs} +1 -8
  131. package/dist/{requestContext-xi6OKBL-.mjs → requestContext-DYtmNpm5.mjs} +1 -3
  132. package/dist/resourceToTools-B6ZN9Ing.mjs +489 -0
  133. package/dist/rpc/index.d.mts +90 -0
  134. package/dist/rpc/index.mjs +248 -0
  135. package/dist/{schemaConverter-Dtg0Kt9T.mjs → schemaConverter-DjzHpFam.mjs} +1 -2
  136. package/dist/schemas/index.d.mts +30 -30
  137. package/dist/schemas/index.mjs +4 -6
  138. package/dist/scope/index.d.mts +13 -2
  139. package/dist/scope/index.mjs +18 -5
  140. package/dist/{sessionManager-D_iEHjQl.d.mts → sessionManager-wbkYj2HL.d.mts} +2 -2
  141. package/dist/{sse-DkqQ1uxb.mjs → sse-BkViJPlT.mjs} +4 -25
  142. package/dist/testing/index.d.mts +551 -567
  143. package/dist/testing/index.mjs +1744 -1799
  144. package/dist/{tracing-8CEbhF0w.d.mts → tracing-bz_U4EM1.d.mts} +6 -1
  145. package/dist/{typeGuards-DwxA1t_L.mjs → typeGuards-Cj5Rgvlg.mjs} +1 -2
  146. package/dist/types/index.d.mts +4 -946
  147. package/dist/types/index.mjs +2 -4
  148. package/dist/types-BJmgxNbF.d.mts +275 -0
  149. package/dist/{types-RLkFVgaw.d.mts → types-BNUccdcf.d.mts} +2 -2
  150. package/dist/{types-Beqn1Un7.mjs → types-C6TQjtdi.mjs} +30 -2
  151. package/dist/{types-DMSBMkaZ.d.mts → types-Dt0-AI6E.d.mts} +85 -27
  152. package/dist/{types-DelU6kln.mjs → types-ZUu_h0jp.mjs} +1 -2
  153. package/dist/utils/index.d.mts +255 -352
  154. package/dist/utils/index.mjs +7 -6
  155. package/dist/utils-Dc0WhlIl.mjs +594 -0
  156. package/dist/versioning-BzfeHmhj.mjs +37 -0
  157. package/package.json +46 -12
  158. package/skills/arc/SKILL.md +506 -0
  159. package/skills/arc/references/auth.md +250 -0
  160. package/skills/arc/references/events.md +272 -0
  161. package/skills/arc/references/integrations.md +385 -0
  162. package/skills/arc/references/mcp.md +386 -0
  163. package/skills/arc/references/production.md +610 -0
  164. package/skills/arc/references/testing.md +183 -0
  165. package/dist/audited-CGdLiSlE.mjs +0 -140
  166. package/dist/chunk-C7Uep-_p.mjs +0 -20
  167. package/dist/circuitBreaker-DYhWBW_D.mjs +0 -1096
  168. package/dist/errorHandler-CW3OOeYq.d.mts +0 -72
  169. package/dist/interface-DZYNK9bb.d.mts +0 -1112
  170. package/dist/presets-BTeYbw7h.d.mts +0 -57
  171. package/dist/presets-CeFtfDR8.mjs +0 -119
  172. /package/dist/{errors-DAWRdiYP.d.mts → errors-CPpvPHT0.d.mts} +0 -0
  173. /package/dist/{externalPaths-SyPF2tgK.d.mts → externalPaths-DpO-s7r8.d.mts} +0 -0
  174. /package/dist/{interface-DTbsvIWe.d.mts → interface-D_BWALyZ.d.mts} +0 -0
@@ -52,7 +52,7 @@ var RedisEventTransport = class {
52
52
  if (this.isGlob(redisPattern)) await this.sub.psubscribe(redisPattern);
53
53
  else await this.sub.subscribe(redisPattern);
54
54
  }
55
- this.handlers.get(redisPattern).add(handler);
55
+ this.handlers.get(redisPattern)?.add(handler);
56
56
  return () => {
57
57
  const set = this.handlers.get(redisPattern);
58
58
  if (set) set.delete(handler);
@@ -92,7 +92,7 @@ var RedisEventTransport = class {
92
92
  }
93
93
  for (const handler of handlers) try {
94
94
  const result = handler(event);
95
- if (result && typeof result.catch === "function") result.catch((err) => {
95
+ if (result && typeof result === "object" && "catch" in result) result.catch((err) => {
96
96
  this.logger.error(`[RedisEventTransport] Handler error for ${event.type}:`, err);
97
97
  });
98
98
  } catch (err) {
@@ -119,6 +119,5 @@ var RedisEventTransport = class {
119
119
  return pattern.includes("*") || pattern.includes("?") || pattern.includes("[");
120
120
  }
121
121
  };
122
-
123
122
  //#endregion
124
- export { RedisEventTransport, RedisEventTransport as default };
123
+ export { RedisEventTransport, RedisEventTransport as default };
@@ -1,10 +1,4 @@
1
- import "../elevation-DGo5shaX.mjs";
2
- import "../interface-DZYNK9bb.mjs";
3
- import "../types-RLkFVgaw.mjs";
4
- import "../queryCachePlugin-Q6SYuHZ6.mjs";
5
- import "../eventPlugin-H6wDDjGO.mjs";
6
- import "../errorHandler-CW3OOeYq.mjs";
7
- import { a as CustomPluginAuthOption, c as RawBodyOptions, i as CustomAuthenticatorOption, l as UnderPressureOptions, n as BetterAuthOption, o as JwtAuthOption, r as CreateAppOptions, s as MultipartOptions, t as AuthOption } from "../types-DMSBMkaZ.mjs";
1
+ import { a as CustomPluginAuthOption, c as RawBodyOptions, i as CustomAuthenticatorOption, l as UnderPressureOptions, n as BetterAuthOption, o as JwtAuthOption, r as CreateAppOptions, s as MultipartOptions, t as AuthOption } from "../types-Dt0-AI6E.mjs";
8
2
  import { FastifyInstance } from "fastify";
9
3
 
10
4
  //#region src/factory/createApp.d.ts
@@ -42,6 +36,26 @@ declare const ArcFactory: {
42
36
  testing(options: Omit<CreateAppOptions, "preset">): Promise<FastifyInstance>;
43
37
  };
44
38
  //#endregion
39
+ //#region src/factory/edge.d.ts
40
+ interface FetchHandlerOptions {
41
+ /**
42
+ * Whether to call `app.ready()` on the first request.
43
+ * Set to `false` if you've already called it during module init.
44
+ * @default true
45
+ */
46
+ autoReady?: boolean;
47
+ }
48
+ /**
49
+ * Convert a Fastify app into a Web Standards fetch handler.
50
+ *
51
+ * The returned function accepts a Web Standard `Request` and returns
52
+ * a Web Standard `Response` — the universal serverless/edge contract.
53
+ *
54
+ * Internally uses `app.inject()` which processes the request through
55
+ * the full Fastify pipeline (hooks, plugins, routes) without TCP.
56
+ */
57
+ declare function toFetchHandler(app: FastifyInstance, options?: FetchHandlerOptions): (request: Request) => Promise<Response>;
58
+ //#endregion
45
59
  //#region src/factory/presets.d.ts
46
60
  /**
47
61
  * Production preset - strict security, performance optimized
@@ -58,6 +72,6 @@ declare const testingPreset: Partial<CreateAppOptions>;
58
72
  /**
59
73
  * Get preset by name
60
74
  */
61
- declare function getPreset(name: 'production' | 'development' | 'testing' | 'edge'): Partial<CreateAppOptions>;
75
+ declare function getPreset(name: "production" | "development" | "testing" | "edge"): Partial<CreateAppOptions>;
62
76
  //#endregion
63
- export { ArcFactory, type AuthOption, type BetterAuthOption, type CreateAppOptions, type CustomAuthenticatorOption, type CustomPluginAuthOption, type JwtAuthOption, type MultipartOptions, type RawBodyOptions, type UnderPressureOptions, createApp, developmentPreset, getPreset, productionPreset, testingPreset };
77
+ export { ArcFactory, type AuthOption, type BetterAuthOption, type CreateAppOptions, type CustomAuthenticatorOption, type CustomPluginAuthOption, type FetchHandlerOptions, type JwtAuthOption, type MultipartOptions, type RawBodyOptions, type UnderPressureOptions, createApp, developmentPreset, getPreset, productionPreset, testingPreset, toFetchHandler };
@@ -1,3 +1,48 @@
1
- import { a as getPreset, i as developmentPreset, n as createApp, o as productionPreset, s as testingPreset, t as ArcFactory } from "../createApp-BKHSl2nT.mjs";
2
-
3
- export { ArcFactory, createApp, developmentPreset, getPreset, productionPreset, testingPreset };
1
+ import { a as getPreset, i as developmentPreset, n as createApp, o as productionPreset, s as testingPreset, t as ArcFactory } from "../createApp-ByWNRsZj.mjs";
2
+ //#region src/factory/edge.ts
3
+ /**
4
+ * Convert a Fastify app into a Web Standards fetch handler.
5
+ *
6
+ * The returned function accepts a Web Standard `Request` and returns
7
+ * a Web Standard `Response` — the universal serverless/edge contract.
8
+ *
9
+ * Internally uses `app.inject()` which processes the request through
10
+ * the full Fastify pipeline (hooks, plugins, routes) without TCP.
11
+ */
12
+ function toFetchHandler(app, options = {}) {
13
+ const { autoReady = true } = options;
14
+ let ready = false;
15
+ return async (request) => {
16
+ if (autoReady && !ready) {
17
+ await app.ready();
18
+ ready = true;
19
+ }
20
+ const url = new URL(request.url);
21
+ const headers = {};
22
+ request.headers.forEach((value, key) => {
23
+ headers[key] = value;
24
+ });
25
+ let payload;
26
+ if (request.method !== "GET" && request.method !== "HEAD") try {
27
+ payload = await request.text();
28
+ } catch {}
29
+ const response = await app.inject({
30
+ method: request.method,
31
+ url: url.pathname + url.search,
32
+ headers,
33
+ ...payload ? { payload } : {}
34
+ });
35
+ const responseHeaders = new Headers();
36
+ for (const [key, value] of Object.entries(response.headers)) {
37
+ if (value === void 0) continue;
38
+ if (Array.isArray(value)) for (const v of value) responseHeaders.append(key, v);
39
+ else responseHeaders.set(key, String(value));
40
+ }
41
+ return new Response(response.payload, {
42
+ status: response.statusCode,
43
+ headers: responseHeaders
44
+ });
45
+ };
46
+ }
47
+ //#endregion
48
+ export { ArcFactory, createApp, developmentPreset, getPreset, productionPreset, testingPreset, toFetchHandler };
@@ -21,7 +21,7 @@
21
21
  * });
22
22
  * ```
23
23
  */
24
- type FieldPermissionType = 'hidden' | 'visibleTo' | 'writableBy' | 'redactFor';
24
+ type FieldPermissionType = "hidden" | "visibleTo" | "writableBy" | "redactFor";
25
25
  interface FieldPermission {
26
26
  readonly _type: FieldPermissionType;
27
27
  readonly roles?: readonly string[];
@@ -109,6 +109,5 @@ function resolveEffectiveRoles(userRoles, orgRoles) {
109
109
  if (userRoles.length === 0) return [...orgRoles];
110
110
  return [...new Set([...userRoles, ...orgRoles])];
111
111
  }
112
-
113
112
  //#endregion
114
- export { resolveEffectiveRoles as i, applyFieldWritePermissions as n, fields as r, applyFieldReadPermissions as t };
113
+ export { resolveEffectiveRoles as i, applyFieldWritePermissions as n, fields as r, applyFieldReadPermissions as t };
@@ -1,4 +1,2 @@
1
- import "../elevation-DGo5shaX.mjs";
2
- import { $ as beforeUpdate, B as DefineHookOptions, G as HookRegistration, H as HookHandler, J as afterCreate, K as HookSystem, Q as beforeDelete, U as HookOperation, V as HookContext, W as HookPhase, X as afterUpdate, Y as afterDelete, Z as beforeCreate, et as createHookSystem, q as HookSystemOptions, tt as defineHook } from "../interface-DZYNK9bb.mjs";
3
- import "../types-RLkFVgaw.mjs";
1
+ import { $t as HookContext, Qt as DefineHookOptions, an as HookSystemOptions, cn as afterUpdate, dn as beforeUpdate, en as HookHandler, fn as createHookSystem, in as HookSystem, ln as beforeCreate, nn as HookPhase, on as afterCreate, pn as defineHook, rn as HookRegistration, sn as afterDelete, tn as HookOperation, un as beforeDelete } from "../interface-DGmPxakH.mjs";
4
2
  export { type DefineHookOptions, type HookContext, type HookHandler, type HookOperation, type HookPhase, type HookRegistration, HookSystem, type HookSystemOptions, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
@@ -1,3 +1,2 @@
1
- import { a as beforeCreate, c as createHookSystem, i as afterUpdate, l as defineHook, n as afterCreate, o as beforeDelete, r as afterDelete, s as beforeUpdate, t as HookSystem } from "../HookSystem-BsGV-j2l.mjs";
2
-
3
- export { HookSystem, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
1
+ import { a as beforeCreate, c as createHookSystem, i as afterUpdate, l as defineHook, n as afterCreate, o as beforeDelete, r as afterDelete, s as beforeUpdate, t as HookSystem } from "../HookSystem-COkyWztM.mjs";
2
+ export { HookSystem, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
@@ -1,6 +1,6 @@
1
- import { i as createIdempotencyResult, n as IdempotencyResult, r as IdempotencyStore, t as IdempotencyLock } from "../interface-CSNjltAc.mjs";
2
- import { r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-UwjEp8Ea.mjs";
3
- import { n as MongoIdempotencyStoreOptions } from "../mongodb-Dg8O_gvd.mjs";
1
+ import { i as createIdempotencyResult, n as IdempotencyResult, r as IdempotencyStore, t as IdempotencyLock } from "../interface-B4awm1RJ.mjs";
2
+ import { n as MongoIdempotencyStoreOptions } from "../mongodb-bga9AbkD.mjs";
3
+ import { r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-CQ5YxMC5.mjs";
4
4
  import { FastifyPluginAsync } from "fastify";
5
5
 
6
6
  //#region src/idempotency/idempotencyPlugin.d.ts
@@ -24,7 +24,7 @@ interface IdempotencyPluginOptions {
24
24
  /** Retry-After header value in seconds when request is in-flight (default: 1) */
25
25
  retryAfterSeconds?: number;
26
26
  }
27
- declare module 'fastify' {
27
+ declare module "fastify" {
28
28
  interface FastifyRequest {
29
29
  /** The idempotency key for this request (if present) */
30
30
  idempotencyKey?: string;
@@ -76,7 +76,7 @@ declare class MemoryIdempotencyStore implements IdempotencyStore {
76
76
  private cleanupInterval;
77
77
  constructor(options?: MemoryIdempotencyStoreOptions);
78
78
  get(key: string): Promise<IdempotencyResult | undefined>;
79
- set(key: string, result: Omit<IdempotencyResult, 'key'>): Promise<void>;
79
+ set(key: string, result: Omit<IdempotencyResult, "key">): Promise<void>;
80
80
  tryLock(key: string, requestId: string, ttlMs: number): Promise<boolean>;
81
81
  unlock(key: string, requestId: string): Promise<void>;
82
82
  isLocked(key: string): Promise<boolean>;
@@ -1,6 +1,5 @@
1
+ import { createHash } from "node:crypto";
1
2
  import fp from "fastify-plugin";
2
- import { createHash } from "crypto";
3
-
4
3
  //#region src/idempotency/stores/interface.ts
5
4
  /**
6
5
  * Helper to create a result object
@@ -15,7 +14,6 @@ function createIdempotencyResult(statusCode, body, headers, ttlMs) {
15
14
  expiresAt: new Date(now.getTime() + ttlMs)
16
15
  };
17
16
  }
18
-
19
17
  //#endregion
20
18
  //#region src/idempotency/stores/memory.ts
21
19
  var MemoryIdempotencyStore = class {
@@ -127,7 +125,6 @@ var MemoryIdempotencyStore = class {
127
125
  }
128
126
  }
129
127
  };
130
-
131
128
  //#endregion
132
129
  //#region src/idempotency/idempotencyPlugin.ts
133
130
  /**
@@ -224,7 +221,7 @@ const idempotencyPlugin = async (fastify, opts = {}) => {
224
221
  const normalized = normalizeBody(request.body);
225
222
  const bodyString = JSON.stringify(normalized);
226
223
  bodyHash = createHash("sha256").update(bodyString).digest("hex").substring(0, 16);
227
- if (request.log && request.log.debug) request.log.debug({ bodyHash }, "Generated body hash");
224
+ if (request.log?.debug) request.log.debug({ bodyHash }, "Generated body hash");
228
225
  }
229
226
  const user = request.user;
230
227
  const userId = user?.id ?? user?._id ?? "anon";
@@ -314,6 +311,5 @@ var idempotencyPlugin_default = fp(idempotencyPlugin, {
314
311
  name: "arc-idempotency",
315
312
  fastify: "5.x"
316
313
  });
317
-
318
314
  //#endregion
319
- export { MemoryIdempotencyStore, createIdempotencyResult, idempotencyPlugin_default as idempotencyPlugin, idempotencyPlugin as idempotencyPluginFn };
315
+ export { MemoryIdempotencyStore, createIdempotencyResult, idempotencyPlugin_default as idempotencyPlugin, idempotencyPlugin as idempotencyPluginFn };
@@ -1,2 +1,2 @@
1
- import { n as MongoIdempotencyStoreOptions, t as MongoIdempotencyStore } from "../mongodb-Dg8O_gvd.mjs";
1
+ import { n as MongoIdempotencyStoreOptions, t as MongoIdempotencyStore } from "../mongodb-bga9AbkD.mjs";
2
2
  export { MongoIdempotencyStore, type MongoIdempotencyStoreOptions };
@@ -27,7 +27,7 @@ var MongoIdempotencyStore = class {
27
27
  }
28
28
  async get(key) {
29
29
  const doc = await this.collection.findOne({ _id: key });
30
- if (!doc || !doc.result) return void 0;
30
+ if (!doc?.result) return void 0;
31
31
  if (new Date(doc.expiresAt) < /* @__PURE__ */ new Date()) return;
32
32
  return {
33
33
  key,
@@ -82,7 +82,7 @@ var MongoIdempotencyStore = class {
82
82
  }
83
83
  async isLocked(key) {
84
84
  const doc = await this.collection.findOne({ _id: key });
85
- if (!doc || !doc.lock) return false;
85
+ if (!doc?.lock) return false;
86
86
  return new Date(doc.lock.expiresAt) > /* @__PURE__ */ new Date();
87
87
  }
88
88
  async delete(key) {
@@ -97,7 +97,7 @@ var MongoIdempotencyStore = class {
97
97
  result: { $exists: true },
98
98
  expiresAt: { $gt: /* @__PURE__ */ new Date() }
99
99
  });
100
- if (!doc || !doc.result) return void 0;
100
+ if (!doc?.result) return void 0;
101
101
  return {
102
102
  key: doc._id,
103
103
  statusCode: doc.result.statusCode,
@@ -109,6 +109,5 @@ var MongoIdempotencyStore = class {
109
109
  }
110
110
  async close() {}
111
111
  };
112
-
113
112
  //#endregion
114
- export { MongoIdempotencyStore };
113
+ export { MongoIdempotencyStore };
@@ -1,2 +1,2 @@
1
- import { n as RedisIdempotencyStore, r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-UwjEp8Ea.mjs";
1
+ import { n as RedisIdempotencyStore, r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-CQ5YxMC5.mjs";
2
2
  export { type RedisClient, RedisIdempotencyStore, type RedisIdempotencyStoreOptions };
@@ -79,9 +79,7 @@ var RedisIdempotencyStore = class {
79
79
  createdAt: new Date(result.createdAt),
80
80
  expiresAt: new Date(result.expiresAt)
81
81
  };
82
- } catch {
83
- continue;
84
- }
82
+ } catch {}
85
83
  }
86
84
  }
87
85
  /** Scan Redis keys matching a prefix pattern. Falls back to empty if SCAN unavailable. */
@@ -98,6 +96,5 @@ var RedisIdempotencyStore = class {
98
96
  }
99
97
  async close() {}
100
98
  };
101
-
102
99
  //#endregion
103
- export { RedisIdempotencyStore };
100
+ export { RedisIdempotencyStore };
@@ -1,23 +1,56 @@
1
- import { s as RequestScope } from "./elevation-DGo5shaX.mjs";
2
- import { b as IControllerResponse, x as IRequestContext, y as IController } from "./interface-DZYNK9bb.mjs";
3
- import { t as PermissionCheck } from "./types-RLkFVgaw.mjs";
4
- import { CrudController, CrudRouterOptions, FastifyWithDecorators, RequestContext, RequestWithExtras } from "./types/index.mjs";
1
+ import { s as RequestScope } from "./elevation-Ca_yveIO.mjs";
2
+ import { D as FastifyWithDecorators, Mt as IControllerResponse, Nt as IRequestContext, et as RequestContext, jt as IController, nt as RequestWithExtras, x as CrudRouterOptions, y as CrudController } from "./interface-DGmPxakH.mjs";
3
+ import { t as PermissionCheck } from "./types-BNUccdcf.mjs";
5
4
  import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
6
5
 
7
- //#region src/core/createCrudRouter.d.ts
6
+ //#region src/constants.d.ts
8
7
  /**
9
- * Create CRUD routes for a controller
8
+ * Arc Framework Constants Single Source of Truth
10
9
  *
11
- * @param fastify - Fastify instance with Arc decorators
12
- * @param controller - CRUD controller with handler methods
13
- * @param options - Router configuration
10
+ * Every default value, magic string, and framework constant lives here.
11
+ * Import from this module instead of hard-coding values inline.
12
+ *
13
+ * All exported values are deeply frozen (Object.freeze) to prevent
14
+ * accidental mutation at runtime — inspired by Go's const blocks
15
+ * and Rust's immutable-by-default philosophy.
14
16
  */
15
- declare function createCrudRouter<TDoc = unknown>(fastify: FastifyWithDecorators, controller: CrudController<TDoc> | undefined, options?: CrudRouterOptions): void;
17
+ /** Standard CRUD operation names */
18
+ declare const CRUD_OPERATIONS: readonly ["list", "get", "create", "update", "delete"];
19
+ type CrudOperation = (typeof CRUD_OPERATIONS)[number];
20
+ /** Mutation operations that emit events */
21
+ declare const MUTATION_OPERATIONS: readonly ["create", "update", "delete"];
22
+ type MutationOperation = (typeof MUTATION_OPERATIONS)[number];
23
+ /** Lifecycle hook phases */
24
+ declare const HOOK_PHASES: readonly ["before", "around", "after"];
25
+ type HookPhase = (typeof HOOK_PHASES)[number];
26
+ /** Hook operations (superset of CRUD — includes 'read' alias for 'get') */
27
+ declare const HOOK_OPERATIONS: readonly ["create", "update", "delete", "read", "list"];
28
+ type HookOperation = (typeof HOOK_OPERATIONS)[number];
29
+ /** Default items per page */
30
+ declare const DEFAULT_LIMIT: 20;
31
+ /** Maximum items per page (framework-wide ceiling) */
32
+ declare const DEFAULT_MAX_LIMIT: 1000;
33
+ /** Default sort field (descending creation date) */
34
+ declare const DEFAULT_SORT: "-createdAt";
35
+ /** Default primary key field name */
36
+ declare const DEFAULT_ID_FIELD: "_id";
37
+ /** Default multi-tenant scoping field */
38
+ declare const DEFAULT_TENANT_FIELD: "organizationId";
39
+ /** Default HTTP method for update routes */
40
+ declare const DEFAULT_UPDATE_METHOD: "PATCH";
41
+ /** System-managed fields that cannot be set via request body */
42
+ declare const SYSTEM_FIELDS: readonly ["_id", "__v", "createdAt", "updatedAt", "deletedAt"];
43
+ /** Maximum regex pattern length (ReDoS mitigation) */
44
+ declare const MAX_REGEX_LENGTH: 200;
45
+ /** Maximum search query length */
46
+ declare const MAX_SEARCH_LENGTH: 200;
47
+ /** Maximum filter nesting depth (prevents filter bombs) */
48
+ declare const MAX_FILTER_DEPTH: 10;
16
49
  /**
17
- * Create permission middleware from PermissionCheck
18
- * Useful for custom route registration
50
+ * Query parameters consumed by the framework — never treated as filters.
51
+ * Shared by all query parsers (Arc built-in, Prisma, custom).
19
52
  */
20
- declare function createPermissionMiddleware(permission: PermissionCheck, resourceName: string, action: string): RouteHandlerMethod | null;
53
+ declare const RESERVED_QUERY_PARAMS: Readonly<Set<string>>;
21
54
  //#endregion
22
55
  //#region src/core/createActionRouter.d.ts
23
56
  /**
@@ -96,54 +129,20 @@ interface IdempotencyService {
96
129
  */
97
130
  declare function createActionRouter(fastify: FastifyInstance, config: ActionRouterConfig): void;
98
131
  //#endregion
99
- //#region src/constants.d.ts
132
+ //#region src/core/createCrudRouter.d.ts
100
133
  /**
101
- * Arc Framework Constants Single Source of Truth
102
- *
103
- * Every default value, magic string, and framework constant lives here.
104
- * Import from this module instead of hard-coding values inline.
134
+ * Create CRUD routes for a controller
105
135
  *
106
- * All exported values are deeply frozen (Object.freeze) to prevent
107
- * accidental mutation at runtime inspired by Go's const blocks
108
- * and Rust's immutable-by-default philosophy.
136
+ * @param fastify - Fastify instance with Arc decorators
137
+ * @param controller - CRUD controller with handler methods
138
+ * @param options - Router configuration
109
139
  */
110
- /** Standard CRUD operation names */
111
- declare const CRUD_OPERATIONS: readonly ["list", "get", "create", "update", "delete"];
112
- type CrudOperation = (typeof CRUD_OPERATIONS)[number];
113
- /** Mutation operations that emit events */
114
- declare const MUTATION_OPERATIONS: readonly ["create", "update", "delete"];
115
- type MutationOperation = (typeof MUTATION_OPERATIONS)[number];
116
- /** Lifecycle hook phases */
117
- declare const HOOK_PHASES: readonly ["before", "around", "after"];
118
- type HookPhase = (typeof HOOK_PHASES)[number];
119
- /** Hook operations (superset of CRUD — includes 'read' alias for 'get') */
120
- declare const HOOK_OPERATIONS: readonly ["create", "update", "delete", "read", "list"];
121
- type HookOperation = (typeof HOOK_OPERATIONS)[number];
122
- /** Default items per page */
123
- declare const DEFAULT_LIMIT: 20;
124
- /** Maximum items per page (framework-wide ceiling) */
125
- declare const DEFAULT_MAX_LIMIT: 1000;
126
- /** Default sort field (descending creation date) */
127
- declare const DEFAULT_SORT: "-createdAt";
128
- /** Default primary key field name */
129
- declare const DEFAULT_ID_FIELD: "_id";
130
- /** Default multi-tenant scoping field */
131
- declare const DEFAULT_TENANT_FIELD: "organizationId";
132
- /** Default HTTP method for update routes */
133
- declare const DEFAULT_UPDATE_METHOD: "PATCH";
134
- /** System-managed fields that cannot be set via request body */
135
- declare const SYSTEM_FIELDS: readonly ["_id", "__v", "createdAt", "updatedAt", "deletedAt"];
136
- /** Maximum regex pattern length (ReDoS mitigation) */
137
- declare const MAX_REGEX_LENGTH: 200;
138
- /** Maximum search query length */
139
- declare const MAX_SEARCH_LENGTH: 200;
140
- /** Maximum filter nesting depth (prevents filter bombs) */
141
- declare const MAX_FILTER_DEPTH: 10;
140
+ declare function createCrudRouter<TDoc = unknown>(fastify: FastifyWithDecorators, controller: CrudController<TDoc> | undefined, options?: CrudRouterOptions): void;
142
141
  /**
143
- * Query parameters consumed by the framework — never treated as filters.
144
- * Shared by all query parsers (Arc built-in, Prisma, custom).
142
+ * Create permission middleware from PermissionCheck
143
+ * Useful for custom route registration
145
144
  */
146
- declare const RESERVED_QUERY_PARAMS: Readonly<Set<string>>;
145
+ declare function createPermissionMiddleware(permission: PermissionCheck, resourceName: string, action: string): RouteHandlerMethod | null;
147
146
  //#endregion
148
147
  //#region src/core/fastifyAdapter.d.ts
149
148
  /**
@@ -213,4 +212,4 @@ declare function createCrudHandlers<TDoc>(controller: IController<TDoc>): {
213
212
  delete: (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
214
213
  };
215
214
  //#endregion
216
- export { createCrudRouter as A, MutationOperation as C, ActionRouterConfig as D, ActionHandler as E, IdempotencyService as O, MUTATION_OPERATIONS as S, SYSTEM_FIELDS as T, HookOperation as _, getControllerScope as a, MAX_REGEX_LENGTH as b, CrudOperation as c, DEFAULT_MAX_LIMIT as d, DEFAULT_SORT as f, HOOK_PHASES as g, HOOK_OPERATIONS as h, getControllerContext as i, createPermissionMiddleware as j, createActionRouter as k, DEFAULT_ID_FIELD as l, DEFAULT_UPDATE_METHOD as m, createFastifyHandler as n, sendControllerResponse as o, DEFAULT_TENANT_FIELD as p, createRequestContext as r, CRUD_OPERATIONS as s, createCrudHandlers as t, DEFAULT_LIMIT as u, HookPhase as v, RESERVED_QUERY_PARAMS as w, MAX_SEARCH_LENGTH as x, MAX_FILTER_DEPTH as y };
215
+ export { RESERVED_QUERY_PARAMS as A, HookOperation as C, MAX_SEARCH_LENGTH as D, MAX_REGEX_LENGTH as E, MUTATION_OPERATIONS as O, HOOK_PHASES as S, MAX_FILTER_DEPTH as T, DEFAULT_MAX_LIMIT as _, getControllerScope as a, DEFAULT_UPDATE_METHOD as b, createPermissionMiddleware as c, IdempotencyService as d, createActionRouter as f, DEFAULT_LIMIT as g, DEFAULT_ID_FIELD as h, getControllerContext as i, SYSTEM_FIELDS as j, MutationOperation as k, ActionHandler as l, CrudOperation as m, createFastifyHandler as n, sendControllerResponse as o, CRUD_OPERATIONS as p, createRequestContext as r, createCrudRouter as s, createCrudHandlers as t, ActionRouterConfig as u, DEFAULT_SORT as v, HookPhase as w, HOOK_OPERATIONS as x, DEFAULT_TENANT_FIELD as y };