@classytic/arc 1.1.0 → 2.1.2

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 (322) hide show
  1. package/README.md +247 -794
  2. package/bin/arc.js +91 -52
  3. package/dist/EventTransport-BD2U0BTc.d.mts +100 -0
  4. package/dist/EventTransport-BD2U0BTc.d.mts.map +1 -0
  5. package/dist/HookSystem-BsGV-j2l.mjs +405 -0
  6. package/dist/HookSystem-BsGV-j2l.mjs.map +1 -0
  7. package/dist/ResourceRegistry-DsN4KJjV.mjs +250 -0
  8. package/dist/ResourceRegistry-DsN4KJjV.mjs.map +1 -0
  9. package/dist/adapters/index.d.mts +5 -0
  10. package/dist/adapters/index.mjs +3 -0
  11. package/dist/audit/index.d.mts +82 -0
  12. package/dist/audit/index.d.mts.map +1 -0
  13. package/dist/audit/index.mjs +276 -0
  14. package/dist/audit/index.mjs.map +1 -0
  15. package/dist/audit/mongodb.d.mts +5 -0
  16. package/dist/audit/mongodb.mjs +3 -0
  17. package/dist/audited-C3T5DTUx.mjs +141 -0
  18. package/dist/audited-C3T5DTUx.mjs.map +1 -0
  19. package/dist/auth/index.d.mts +189 -0
  20. package/dist/auth/index.d.mts.map +1 -0
  21. package/dist/auth/index.mjs +1102 -0
  22. package/dist/auth/index.mjs.map +1 -0
  23. package/dist/auth/redis-session.d.mts +44 -0
  24. package/dist/auth/redis-session.d.mts.map +1 -0
  25. package/dist/auth/redis-session.mjs +76 -0
  26. package/dist/auth/redis-session.mjs.map +1 -0
  27. package/dist/betterAuthOpenApi-BrHKeSAx.mjs +250 -0
  28. package/dist/betterAuthOpenApi-BrHKeSAx.mjs.map +1 -0
  29. package/dist/cache/index.d.mts +146 -0
  30. package/dist/cache/index.d.mts.map +1 -0
  31. package/dist/cache/index.mjs +92 -0
  32. package/dist/cache/index.mjs.map +1 -0
  33. package/dist/caching-Bl28lYsR.mjs +94 -0
  34. package/dist/caching-Bl28lYsR.mjs.map +1 -0
  35. package/dist/chunk-C7Uep-_p.mjs +20 -0
  36. package/dist/circuitBreaker-DeY4FCjs.mjs +1097 -0
  37. package/dist/circuitBreaker-DeY4FCjs.mjs.map +1 -0
  38. package/dist/cli/commands/describe.d.mts +19 -0
  39. package/dist/cli/commands/describe.d.mts.map +1 -0
  40. package/dist/cli/commands/describe.mjs +239 -0
  41. package/dist/cli/commands/describe.mjs.map +1 -0
  42. package/dist/cli/commands/docs.d.mts +14 -0
  43. package/dist/cli/commands/docs.d.mts.map +1 -0
  44. package/dist/cli/commands/docs.mjs +53 -0
  45. package/dist/cli/commands/docs.mjs.map +1 -0
  46. package/dist/cli/commands/{generate.d.ts → generate.d.mts} +3 -1
  47. package/dist/cli/commands/generate.d.mts.map +1 -0
  48. package/dist/cli/commands/generate.mjs +358 -0
  49. package/dist/cli/commands/generate.mjs.map +1 -0
  50. package/dist/cli/commands/{init.d.ts → init.d.mts} +12 -8
  51. package/dist/cli/commands/init.d.mts.map +1 -0
  52. package/dist/cli/commands/{init.js → init.mjs} +807 -616
  53. package/dist/cli/commands/init.mjs.map +1 -0
  54. package/dist/cli/commands/introspect.d.mts +11 -0
  55. package/dist/cli/commands/introspect.d.mts.map +1 -0
  56. package/dist/cli/commands/introspect.mjs +76 -0
  57. package/dist/cli/commands/introspect.mjs.map +1 -0
  58. package/dist/cli/index.d.mts +17 -0
  59. package/dist/cli/index.d.mts.map +1 -0
  60. package/dist/cli/index.mjs +157 -0
  61. package/dist/cli/index.mjs.map +1 -0
  62. package/dist/constants-DdXFXQtN.mjs +85 -0
  63. package/dist/constants-DdXFXQtN.mjs.map +1 -0
  64. package/dist/core/index.d.mts +5 -0
  65. package/dist/core/index.mjs +4 -0
  66. package/dist/createApp-CUgNqegw.mjs +560 -0
  67. package/dist/createApp-CUgNqegw.mjs.map +1 -0
  68. package/dist/defineResource-k0_BDn8v.mjs +2197 -0
  69. package/dist/defineResource-k0_BDn8v.mjs.map +1 -0
  70. package/dist/discovery/index.d.mts +47 -0
  71. package/dist/discovery/index.d.mts.map +1 -0
  72. package/dist/discovery/index.mjs +110 -0
  73. package/dist/discovery/index.mjs.map +1 -0
  74. package/dist/docs/index.d.mts +163 -0
  75. package/dist/docs/index.d.mts.map +1 -0
  76. package/dist/docs/index.mjs +73 -0
  77. package/dist/docs/index.mjs.map +1 -0
  78. package/dist/elevation-BRy3yFWT.mjs +113 -0
  79. package/dist/elevation-BRy3yFWT.mjs.map +1 -0
  80. package/dist/elevation-B_2dRLVP.d.mts +88 -0
  81. package/dist/elevation-B_2dRLVP.d.mts.map +1 -0
  82. package/dist/errorHandler-BbcgBmIH.d.mts +73 -0
  83. package/dist/errorHandler-BbcgBmIH.d.mts.map +1 -0
  84. package/dist/errorHandler-C1okiriz.mjs +109 -0
  85. package/dist/errorHandler-C1okiriz.mjs.map +1 -0
  86. package/dist/errors-B9bZok84.mjs +212 -0
  87. package/dist/errors-B9bZok84.mjs.map +1 -0
  88. package/dist/errors-ChKiFz62.d.mts +125 -0
  89. package/dist/errors-ChKiFz62.d.mts.map +1 -0
  90. package/dist/eventPlugin-CTrLH3mt.d.mts +125 -0
  91. package/dist/eventPlugin-CTrLH3mt.d.mts.map +1 -0
  92. package/dist/eventPlugin-DGR_B2on.mjs +230 -0
  93. package/dist/eventPlugin-DGR_B2on.mjs.map +1 -0
  94. package/dist/events/index.d.mts +54 -0
  95. package/dist/events/index.d.mts.map +1 -0
  96. package/dist/events/index.mjs +52 -0
  97. package/dist/events/index.mjs.map +1 -0
  98. package/dist/events/transports/redis-stream-entry.d.mts +2 -0
  99. package/dist/events/transports/redis-stream-entry.mjs +178 -0
  100. package/dist/events/transports/redis-stream-entry.mjs.map +1 -0
  101. package/dist/events/transports/redis.d.mts +77 -0
  102. package/dist/events/transports/redis.d.mts.map +1 -0
  103. package/dist/events/transports/redis.mjs +125 -0
  104. package/dist/events/transports/redis.mjs.map +1 -0
  105. package/dist/externalPaths-DlINfKbP.d.mts +51 -0
  106. package/dist/externalPaths-DlINfKbP.d.mts.map +1 -0
  107. package/dist/factory/index.d.mts +64 -0
  108. package/dist/factory/index.d.mts.map +1 -0
  109. package/dist/factory/index.mjs +3 -0
  110. package/dist/fastifyAdapter-BkrGrlFi.d.mts +217 -0
  111. package/dist/fastifyAdapter-BkrGrlFi.d.mts.map +1 -0
  112. package/dist/fields-DyaDVX4J.d.mts +110 -0
  113. package/dist/fields-DyaDVX4J.d.mts.map +1 -0
  114. package/dist/fields-iagOozy0.mjs +115 -0
  115. package/dist/fields-iagOozy0.mjs.map +1 -0
  116. package/dist/hooks/index.d.mts +4 -0
  117. package/dist/hooks/index.mjs +3 -0
  118. package/dist/idempotency/index.d.mts +97 -0
  119. package/dist/idempotency/index.d.mts.map +1 -0
  120. package/dist/idempotency/index.mjs +320 -0
  121. package/dist/idempotency/index.mjs.map +1 -0
  122. package/dist/idempotency/mongodb.d.mts +2 -0
  123. package/dist/idempotency/mongodb.mjs +115 -0
  124. package/dist/idempotency/mongodb.mjs.map +1 -0
  125. package/dist/idempotency/redis.d.mts +2 -0
  126. package/dist/idempotency/redis.mjs +104 -0
  127. package/dist/idempotency/redis.mjs.map +1 -0
  128. package/dist/index.d.mts +261 -0
  129. package/dist/index.d.mts.map +1 -0
  130. package/dist/index.mjs +105 -0
  131. package/dist/index.mjs.map +1 -0
  132. package/dist/integrations/event-gateway.d.mts +47 -0
  133. package/dist/integrations/event-gateway.d.mts.map +1 -0
  134. package/dist/integrations/event-gateway.mjs +44 -0
  135. package/dist/integrations/event-gateway.mjs.map +1 -0
  136. package/dist/integrations/index.d.mts +5 -0
  137. package/dist/integrations/index.mjs +1 -0
  138. package/dist/integrations/jobs.d.mts +104 -0
  139. package/dist/integrations/jobs.d.mts.map +1 -0
  140. package/dist/integrations/jobs.mjs +124 -0
  141. package/dist/integrations/jobs.mjs.map +1 -0
  142. package/dist/integrations/streamline.d.mts +61 -0
  143. package/dist/integrations/streamline.d.mts.map +1 -0
  144. package/dist/integrations/streamline.mjs +126 -0
  145. package/dist/integrations/streamline.mjs.map +1 -0
  146. package/dist/integrations/websocket.d.mts +83 -0
  147. package/dist/integrations/websocket.d.mts.map +1 -0
  148. package/dist/integrations/websocket.mjs +289 -0
  149. package/dist/integrations/websocket.mjs.map +1 -0
  150. package/dist/interface-B01JvPVc.d.mts +78 -0
  151. package/dist/interface-B01JvPVc.d.mts.map +1 -0
  152. package/dist/interface-CZe8IkMf.d.mts +55 -0
  153. package/dist/interface-CZe8IkMf.d.mts.map +1 -0
  154. package/dist/interface-Ch8HU9uM.d.mts +1098 -0
  155. package/dist/interface-Ch8HU9uM.d.mts.map +1 -0
  156. package/dist/introspectionPlugin-rFdO8ZUa.mjs +54 -0
  157. package/dist/introspectionPlugin-rFdO8ZUa.mjs.map +1 -0
  158. package/dist/keys-BqNejWup.mjs +43 -0
  159. package/dist/keys-BqNejWup.mjs.map +1 -0
  160. package/dist/logger-Df2O2WsW.mjs +79 -0
  161. package/dist/logger-Df2O2WsW.mjs.map +1 -0
  162. package/dist/memory-cQgelFOj.mjs +144 -0
  163. package/dist/memory-cQgelFOj.mjs.map +1 -0
  164. package/dist/migrations/index.d.mts +157 -0
  165. package/dist/migrations/index.d.mts.map +1 -0
  166. package/dist/migrations/index.mjs +261 -0
  167. package/dist/migrations/index.mjs.map +1 -0
  168. package/dist/mongodb-BfJVlUJH.mjs +94 -0
  169. package/dist/mongodb-BfJVlUJH.mjs.map +1 -0
  170. package/dist/mongodb-CGzRbfAK.d.mts +119 -0
  171. package/dist/mongodb-CGzRbfAK.d.mts.map +1 -0
  172. package/dist/mongodb-JN-9JA7K.d.mts +72 -0
  173. package/dist/mongodb-JN-9JA7K.d.mts.map +1 -0
  174. package/dist/openapi-G3Cw7XuM.mjs +524 -0
  175. package/dist/openapi-G3Cw7XuM.mjs.map +1 -0
  176. package/dist/org/index.d.mts +69 -0
  177. package/dist/org/index.d.mts.map +1 -0
  178. package/dist/org/index.mjs +514 -0
  179. package/dist/org/index.mjs.map +1 -0
  180. package/dist/org/types.d.mts +83 -0
  181. package/dist/org/types.d.mts.map +1 -0
  182. package/dist/org/types.mjs +1 -0
  183. package/dist/permissions/index.d.mts +279 -0
  184. package/dist/permissions/index.d.mts.map +1 -0
  185. package/dist/permissions/index.mjs +579 -0
  186. package/dist/permissions/index.mjs.map +1 -0
  187. package/dist/plugins/index.d.mts +173 -0
  188. package/dist/plugins/index.d.mts.map +1 -0
  189. package/dist/plugins/index.mjs +523 -0
  190. package/dist/plugins/index.mjs.map +1 -0
  191. package/dist/plugins/response-cache.d.mts +88 -0
  192. package/dist/plugins/response-cache.d.mts.map +1 -0
  193. package/dist/plugins/response-cache.mjs +284 -0
  194. package/dist/plugins/response-cache.mjs.map +1 -0
  195. package/dist/plugins/tracing-entry.d.mts +2 -0
  196. package/dist/plugins/tracing-entry.mjs +186 -0
  197. package/dist/plugins/tracing-entry.mjs.map +1 -0
  198. package/dist/pluralize-CEweyOEm.mjs +87 -0
  199. package/dist/pluralize-CEweyOEm.mjs.map +1 -0
  200. package/dist/policies/{index.d.ts → index.d.mts} +204 -169
  201. package/dist/policies/index.d.mts.map +1 -0
  202. package/dist/policies/index.mjs +322 -0
  203. package/dist/policies/index.mjs.map +1 -0
  204. package/dist/presets/{index.d.ts → index.d.mts} +63 -131
  205. package/dist/presets/index.d.mts.map +1 -0
  206. package/dist/presets/index.mjs +144 -0
  207. package/dist/presets/index.mjs.map +1 -0
  208. package/dist/presets/multiTenant.d.mts +25 -0
  209. package/dist/presets/multiTenant.d.mts.map +1 -0
  210. package/dist/presets/multiTenant.mjs +114 -0
  211. package/dist/presets/multiTenant.mjs.map +1 -0
  212. package/dist/presets-BITljm96.mjs +120 -0
  213. package/dist/presets-BITljm96.mjs.map +1 -0
  214. package/dist/presets-DzSMwlKj.d.mts +58 -0
  215. package/dist/presets-DzSMwlKj.d.mts.map +1 -0
  216. package/dist/prisma-DJbMt3yf.mjs +628 -0
  217. package/dist/prisma-DJbMt3yf.mjs.map +1 -0
  218. package/dist/prisma-Dg9GoVdj.d.mts +275 -0
  219. package/dist/prisma-Dg9GoVdj.d.mts.map +1 -0
  220. package/dist/queryCachePlugin-7THaI5mt.d.mts +72 -0
  221. package/dist/queryCachePlugin-7THaI5mt.d.mts.map +1 -0
  222. package/dist/queryCachePlugin-DMBnp2Q0.mjs +139 -0
  223. package/dist/queryCachePlugin-DMBnp2Q0.mjs.map +1 -0
  224. package/dist/redis-D-JAeLtm.d.mts +50 -0
  225. package/dist/redis-D-JAeLtm.d.mts.map +1 -0
  226. package/dist/redis-stream-Bdh_vUU8.d.mts +104 -0
  227. package/dist/redis-stream-Bdh_vUU8.d.mts.map +1 -0
  228. package/dist/registry/index.d.mts +12 -0
  229. package/dist/registry/index.d.mts.map +1 -0
  230. package/dist/registry/index.mjs +4 -0
  231. package/dist/requestContext-QQD6ROJc.mjs +56 -0
  232. package/dist/requestContext-QQD6ROJc.mjs.map +1 -0
  233. package/dist/schemaConverter-BwrmWroW.mjs +99 -0
  234. package/dist/schemaConverter-BwrmWroW.mjs.map +1 -0
  235. package/dist/schemas/index.d.mts +64 -0
  236. package/dist/schemas/index.d.mts.map +1 -0
  237. package/dist/schemas/index.mjs +83 -0
  238. package/dist/schemas/index.mjs.map +1 -0
  239. package/dist/scope/index.d.mts +22 -0
  240. package/dist/scope/index.d.mts.map +1 -0
  241. package/dist/scope/index.mjs +66 -0
  242. package/dist/scope/index.mjs.map +1 -0
  243. package/dist/sessionManager-jPKLbHE0.d.mts +187 -0
  244. package/dist/sessionManager-jPKLbHE0.d.mts.map +1 -0
  245. package/dist/sse-B3c3_yZp.mjs +124 -0
  246. package/dist/sse-B3c3_yZp.mjs.map +1 -0
  247. package/dist/testing/index.d.mts +908 -0
  248. package/dist/testing/index.d.mts.map +1 -0
  249. package/dist/testing/index.mjs +1977 -0
  250. package/dist/testing/index.mjs.map +1 -0
  251. package/dist/tracing-Cc7vVQPp.d.mts +71 -0
  252. package/dist/tracing-Cc7vVQPp.d.mts.map +1 -0
  253. package/dist/typeGuards-DhMNLuvU.mjs +10 -0
  254. package/dist/typeGuards-DhMNLuvU.mjs.map +1 -0
  255. package/dist/types/index.d.mts +947 -0
  256. package/dist/types/index.d.mts.map +1 -0
  257. package/dist/types/index.mjs +15 -0
  258. package/dist/types/index.mjs.map +1 -0
  259. package/dist/types-Beqn1Un7.mjs +39 -0
  260. package/dist/types-Beqn1Un7.mjs.map +1 -0
  261. package/dist/types-CIgB7UUl.d.mts +446 -0
  262. package/dist/types-CIgB7UUl.d.mts.map +1 -0
  263. package/dist/types-aYB4V7uN.d.mts +87 -0
  264. package/dist/types-aYB4V7uN.d.mts.map +1 -0
  265. package/dist/utils/index.d.mts +748 -0
  266. package/dist/utils/index.d.mts.map +1 -0
  267. package/dist/utils/index.mjs +6 -0
  268. package/package.json +194 -68
  269. package/dist/BaseController-DVAiHxEQ.d.ts +0 -233
  270. package/dist/adapters/index.d.ts +0 -237
  271. package/dist/adapters/index.js +0 -668
  272. package/dist/arcCorePlugin-CsShQdyP.d.ts +0 -273
  273. package/dist/audit/index.d.ts +0 -195
  274. package/dist/audit/index.js +0 -319
  275. package/dist/auth/index.d.ts +0 -47
  276. package/dist/auth/index.js +0 -174
  277. package/dist/cli/commands/docs.d.ts +0 -11
  278. package/dist/cli/commands/docs.js +0 -474
  279. package/dist/cli/commands/generate.js +0 -334
  280. package/dist/cli/commands/introspect.d.ts +0 -8
  281. package/dist/cli/commands/introspect.js +0 -338
  282. package/dist/cli/index.d.ts +0 -4
  283. package/dist/cli/index.js +0 -3269
  284. package/dist/core/index.d.ts +0 -220
  285. package/dist/core/index.js +0 -2786
  286. package/dist/createApp-Ce9wl8W9.d.ts +0 -77
  287. package/dist/docs/index.d.ts +0 -166
  288. package/dist/docs/index.js +0 -658
  289. package/dist/errors-8WIxGS_6.d.ts +0 -122
  290. package/dist/events/index.d.ts +0 -117
  291. package/dist/events/index.js +0 -89
  292. package/dist/factory/index.d.ts +0 -38
  293. package/dist/factory/index.js +0 -1652
  294. package/dist/hooks/index.d.ts +0 -4
  295. package/dist/hooks/index.js +0 -199
  296. package/dist/idempotency/index.d.ts +0 -323
  297. package/dist/idempotency/index.js +0 -500
  298. package/dist/index-B4t03KQ0.d.ts +0 -1366
  299. package/dist/index.d.ts +0 -135
  300. package/dist/index.js +0 -4756
  301. package/dist/migrations/index.d.ts +0 -185
  302. package/dist/migrations/index.js +0 -274
  303. package/dist/org/index.d.ts +0 -129
  304. package/dist/org/index.js +0 -220
  305. package/dist/permissions/index.d.ts +0 -144
  306. package/dist/permissions/index.js +0 -103
  307. package/dist/plugins/index.d.ts +0 -46
  308. package/dist/plugins/index.js +0 -1069
  309. package/dist/policies/index.js +0 -196
  310. package/dist/presets/index.js +0 -384
  311. package/dist/presets/multiTenant.d.ts +0 -39
  312. package/dist/presets/multiTenant.js +0 -112
  313. package/dist/registry/index.d.ts +0 -16
  314. package/dist/registry/index.js +0 -253
  315. package/dist/testing/index.d.ts +0 -618
  316. package/dist/testing/index.js +0 -48020
  317. package/dist/types/index.d.ts +0 -4
  318. package/dist/types/index.js +0 -8
  319. package/dist/types-B99TBmFV.d.ts +0 -76
  320. package/dist/types-BvckRbs2.d.ts +0 -143
  321. package/dist/utils/index.d.ts +0 -679
  322. package/dist/utils/index.js +0 -931
@@ -1,679 +0,0 @@
1
- export { A as ArcError, C as ConflictError, E as ErrorDetails, F as ForbiddenError, N as NotFoundError, a as OrgAccessDeniedError, O as OrgRequiredError, R as RateLimitError, S as ServiceUnavailableError, U as UnauthorizedError, V as ValidationError, c as createError, i as isArcError } from '../errors-8WIxGS_6.js';
2
- import { A as AnyRecord, Q as QueryParserInterface, ae as ParsedQuery } from '../index-B4t03KQ0.js';
3
- import 'mongoose';
4
- import 'fastify';
5
- import '../types-B99TBmFV.js';
6
-
7
- /**
8
- * Response Schemas
9
- *
10
- * Standard JSON Schema definitions for API responses.
11
- */
12
-
13
- interface JsonSchema {
14
- type: string;
15
- properties?: Record<string, JsonSchema | AnyRecord>;
16
- required?: string[];
17
- items?: JsonSchema | AnyRecord;
18
- additionalProperties?: boolean | JsonSchema;
19
- description?: string;
20
- example?: unknown;
21
- [key: string]: unknown;
22
- }
23
- /**
24
- * Base success response schema
25
- */
26
- declare const successResponseSchema: JsonSchema;
27
- /**
28
- * Error response schema
29
- */
30
- declare const errorResponseSchema: JsonSchema;
31
- /**
32
- * Pagination schema - matches MongoKit/Arc runtime format
33
- *
34
- * Runtime format (flat fields):
35
- * { page, limit, total, pages, hasNext, hasPrev }
36
- */
37
- declare const paginationSchema: JsonSchema;
38
- /**
39
- * Wrap a data schema in a success response
40
- */
41
- declare function wrapResponse(dataSchema: JsonSchema): JsonSchema;
42
- /**
43
- * Create a list response schema with pagination - matches MongoKit/Arc runtime format
44
- *
45
- * Runtime format:
46
- * { success, docs: [...], page, limit, total, pages, hasNext, hasPrev }
47
- *
48
- * Note: Uses 'docs' array (not 'data') with flat pagination fields
49
- */
50
- declare function listResponse(itemSchema: JsonSchema): JsonSchema;
51
- /**
52
- * Alias for listResponse - matches local responseSchemas.js naming
53
- */
54
- declare const paginateWrapper: typeof listResponse;
55
- /**
56
- * Create a single item response schema
57
- *
58
- * Runtime format: { success, data: {...} }
59
- */
60
- declare function itemResponse(itemSchema: JsonSchema): JsonSchema;
61
- /**
62
- * Alias for itemResponse - matches local responseSchemas.js naming
63
- */
64
- declare const itemWrapper: typeof itemResponse;
65
- /**
66
- * Create a create/update response schema
67
- */
68
- declare function mutationResponse(itemSchema: JsonSchema): JsonSchema;
69
- /**
70
- * Create a delete response schema
71
- *
72
- * Runtime format: { success, message }
73
- */
74
- declare function deleteResponse(): JsonSchema;
75
- /**
76
- * Alias for deleteResponse - matches local responseSchemas.js naming
77
- */
78
- declare const messageWrapper: typeof deleteResponse;
79
- declare const responses: {
80
- 200: (schema: JsonSchema) => {
81
- description: string;
82
- content: {
83
- 'application/json': {
84
- schema: JsonSchema;
85
- };
86
- };
87
- };
88
- 201: (schema: JsonSchema) => {
89
- description: string;
90
- content: {
91
- 'application/json': {
92
- schema: JsonSchema;
93
- };
94
- };
95
- };
96
- 400: {
97
- description: string;
98
- content: {
99
- 'application/json': {
100
- schema: {
101
- properties: {
102
- code: {
103
- type: string;
104
- example: string;
105
- };
106
- details: {
107
- type: string;
108
- properties: {
109
- errors: {
110
- type: string;
111
- items: {
112
- type: string;
113
- properties: {
114
- field: {
115
- type: string;
116
- };
117
- message: {
118
- type: string;
119
- };
120
- };
121
- };
122
- };
123
- };
124
- };
125
- };
126
- type: string;
127
- required?: string[];
128
- items?: JsonSchema | AnyRecord;
129
- additionalProperties?: boolean | JsonSchema;
130
- description?: string;
131
- example?: unknown;
132
- };
133
- };
134
- };
135
- };
136
- 401: {
137
- description: string;
138
- content: {
139
- 'application/json': {
140
- schema: {
141
- properties: {
142
- code: {
143
- type: string;
144
- example: string;
145
- };
146
- };
147
- type: string;
148
- required?: string[];
149
- items?: JsonSchema | AnyRecord;
150
- additionalProperties?: boolean | JsonSchema;
151
- description?: string;
152
- example?: unknown;
153
- };
154
- };
155
- };
156
- };
157
- 403: {
158
- description: string;
159
- content: {
160
- 'application/json': {
161
- schema: {
162
- properties: {
163
- code: {
164
- type: string;
165
- example: string;
166
- };
167
- };
168
- type: string;
169
- required?: string[];
170
- items?: JsonSchema | AnyRecord;
171
- additionalProperties?: boolean | JsonSchema;
172
- description?: string;
173
- example?: unknown;
174
- };
175
- };
176
- };
177
- };
178
- 404: {
179
- description: string;
180
- content: {
181
- 'application/json': {
182
- schema: {
183
- properties: {
184
- code: {
185
- type: string;
186
- example: string;
187
- };
188
- };
189
- type: string;
190
- required?: string[];
191
- items?: JsonSchema | AnyRecord;
192
- additionalProperties?: boolean | JsonSchema;
193
- description?: string;
194
- example?: unknown;
195
- };
196
- };
197
- };
198
- };
199
- 409: {
200
- description: string;
201
- content: {
202
- 'application/json': {
203
- schema: {
204
- properties: {
205
- code: {
206
- type: string;
207
- example: string;
208
- };
209
- };
210
- type: string;
211
- required?: string[];
212
- items?: JsonSchema | AnyRecord;
213
- additionalProperties?: boolean | JsonSchema;
214
- description?: string;
215
- example?: unknown;
216
- };
217
- };
218
- };
219
- };
220
- 500: {
221
- description: string;
222
- content: {
223
- 'application/json': {
224
- schema: {
225
- properties: {
226
- code: {
227
- type: string;
228
- example: string;
229
- };
230
- };
231
- type: string;
232
- required?: string[];
233
- items?: JsonSchema | AnyRecord;
234
- additionalProperties?: boolean | JsonSchema;
235
- description?: string;
236
- example?: unknown;
237
- };
238
- };
239
- };
240
- };
241
- };
242
- declare const queryParams: {
243
- pagination: {
244
- page: {
245
- type: string;
246
- minimum: number;
247
- default: number;
248
- description: string;
249
- };
250
- limit: {
251
- type: string;
252
- minimum: number;
253
- maximum: number;
254
- default: number;
255
- description: string;
256
- };
257
- };
258
- sorting: {
259
- sort: {
260
- type: string;
261
- description: string;
262
- example: string;
263
- };
264
- };
265
- filtering: {
266
- select: {
267
- type: string;
268
- description: string;
269
- example: string;
270
- };
271
- populate: {
272
- type: string;
273
- description: string;
274
- example: string;
275
- };
276
- };
277
- };
278
- /**
279
- * Get standard list query parameters schema
280
- */
281
- declare function getListQueryParams(): AnyRecord;
282
-
283
- /**
284
- * State Machine Utility
285
- *
286
- * Pure utility for validating state transitions in workflow systems.
287
- * Zero dependencies, framework-agnostic.
288
- *
289
- * @example
290
- * const orderState = createStateMachine('Order', {
291
- * approve: ['pending', 'draft'],
292
- * cancel: ['pending', 'approved'],
293
- * fulfill: ['approved'],
294
- * });
295
- *
296
- * // Check if transition is allowed
297
- * if (orderState.can('approve', currentStatus)) {
298
- * // Perform approval
299
- * }
300
- *
301
- * // Assert transition (throws if invalid)
302
- * orderState.assert('approve', currentStatus, ValidationError);
303
- */
304
- interface StateMachine {
305
- /**
306
- * Check if action can be performed from current status
307
- */
308
- can(action: string, status: string | null | undefined, context?: any): boolean;
309
- /**
310
- * Assert action can be performed, throw error if invalid
311
- * @param action - Action to perform
312
- * @param status - Current status
313
- * @param errorFactory - Optional error constructor
314
- * @param message - Optional custom error message
315
- */
316
- assert(action: string, status: string | null | undefined, errorFactory?: (msg: string) => Error, message?: string): void;
317
- /**
318
- * Get transition history
319
- */
320
- getHistory?(): TransitionHistoryEntry[];
321
- /**
322
- * Record a transition
323
- */
324
- recordTransition?(from: string, to: string, action: string, metadata?: any): void;
325
- /**
326
- * Clear history
327
- */
328
- clearHistory?(): void;
329
- /**
330
- * Get available actions for current status
331
- */
332
- getAvailableActions?(status: string): string[];
333
- }
334
- interface TransitionHistoryEntry {
335
- from: string;
336
- to: string;
337
- action: string;
338
- timestamp: Date;
339
- metadata?: any;
340
- }
341
- interface TransitionGuard {
342
- (context: {
343
- from: string;
344
- to: string;
345
- action: string;
346
- data?: any;
347
- }): boolean | Promise<boolean>;
348
- }
349
- interface TransitionAction {
350
- (context: {
351
- from: string;
352
- to: string;
353
- action: string;
354
- data?: any;
355
- }): void | Promise<void>;
356
- }
357
- type TransitionConfig = Record<string, string[] | {
358
- from: string[];
359
- to?: string;
360
- guard?: TransitionGuard;
361
- before?: TransitionAction;
362
- after?: TransitionAction;
363
- }>;
364
- /**
365
- * Create a state machine for validating transitions
366
- *
367
- * @param name - Name of the state machine (used in error messages)
368
- * @param transitions - Map of actions to allowed source statuses
369
- * @param options - Additional options (history, guards, actions)
370
- * @returns State machine with can() and assert() methods
371
- *
372
- * @example
373
- * // Basic usage
374
- * const transferState = createStateMachine('Transfer', {
375
- * approve: ['draft'],
376
- * dispatch: ['approved'],
377
- * receive: ['dispatched', 'in_transit'],
378
- * cancel: ['draft', 'approved'],
379
- * });
380
- *
381
- * @example
382
- * // With guards and actions
383
- * const orderState = createStateMachine('Order', {
384
- * approve: {
385
- * from: ['pending'],
386
- * to: 'approved',
387
- * guard: ({ data }) => data.paymentConfirmed,
388
- * before: ({ from, to }) => console.log(`Approving order from ${from} to ${to}`),
389
- * after: ({ data }) => sendApprovalEmail(data.customerId),
390
- * },
391
- * }, { trackHistory: true });
392
- */
393
- declare function createStateMachine(name: string, transitions?: TransitionConfig, options?: {
394
- trackHistory?: boolean;
395
- }): StateMachine;
396
-
397
- /**
398
- * Circuit Breaker Pattern
399
- *
400
- * Wraps external service calls with failure protection.
401
- * Prevents cascading failures by "opening" the circuit when
402
- * a service is failing, allowing it time to recover.
403
- *
404
- * States:
405
- * - CLOSED: Normal operation, requests pass through
406
- * - OPEN: Too many failures, all requests fail fast
407
- * - HALF_OPEN: Testing if service recovered, limited requests
408
- *
409
- * @example
410
- * import { CircuitBreaker } from '@classytic/arc/utils';
411
- *
412
- * const paymentBreaker = new CircuitBreaker(async (amount) => {
413
- * return await stripe.charges.create({ amount });
414
- * }, {
415
- * failureThreshold: 5,
416
- * resetTimeout: 30000,
417
- * timeout: 5000,
418
- * });
419
- *
420
- * try {
421
- * const result = await paymentBreaker.call(100);
422
- * } catch (error) {
423
- * // Handle failure or circuit open
424
- * }
425
- */
426
- declare enum CircuitState {
427
- CLOSED = "CLOSED",
428
- OPEN = "OPEN",
429
- HALF_OPEN = "HALF_OPEN"
430
- }
431
- interface CircuitBreakerOptions {
432
- /**
433
- * Number of failures before opening circuit
434
- * @default 5
435
- */
436
- failureThreshold?: number;
437
- /**
438
- * Time in ms before attempting to close circuit
439
- * @default 60000 (60 seconds)
440
- */
441
- resetTimeout?: number;
442
- /**
443
- * Request timeout in ms
444
- * @default 10000 (10 seconds)
445
- */
446
- timeout?: number;
447
- /**
448
- * Number of successful requests in HALF_OPEN before closing
449
- * @default 1
450
- */
451
- successThreshold?: number;
452
- /**
453
- * Fallback function when circuit is open
454
- */
455
- fallback?: (...args: any[]) => Promise<any>;
456
- /**
457
- * Callback when state changes
458
- */
459
- onStateChange?: (from: CircuitState, to: CircuitState) => void;
460
- /**
461
- * Callback on error
462
- */
463
- onError?: (error: Error) => void;
464
- /**
465
- * Name for logging/monitoring
466
- */
467
- name?: string;
468
- }
469
- interface CircuitBreakerStats {
470
- name?: string;
471
- state: CircuitState;
472
- failures: number;
473
- successes: number;
474
- totalCalls: number;
475
- openedAt: number | null;
476
- lastCallAt: number | null;
477
- }
478
- declare class CircuitBreakerError extends Error {
479
- state: CircuitState;
480
- constructor(message: string, state: CircuitState);
481
- }
482
- declare class CircuitBreaker<T extends (...args: any[]) => Promise<any>> {
483
- private readonly fn;
484
- private state;
485
- private failures;
486
- private successes;
487
- private totalCalls;
488
- private nextAttempt;
489
- private lastCallAt;
490
- private openedAt;
491
- private readonly failureThreshold;
492
- private readonly resetTimeout;
493
- private readonly timeout;
494
- private readonly successThreshold;
495
- private readonly fallback?;
496
- private readonly onStateChange?;
497
- private readonly onError?;
498
- private readonly name;
499
- constructor(fn: T, options?: CircuitBreakerOptions);
500
- /**
501
- * Call the wrapped function with circuit breaker protection
502
- */
503
- call(...args: Parameters<T>): Promise<ReturnType<T>>;
504
- /**
505
- * Execute function with timeout
506
- */
507
- private executeWithTimeout;
508
- /**
509
- * Handle successful call
510
- */
511
- private onSuccess;
512
- /**
513
- * Handle failed call
514
- */
515
- private onFailure;
516
- /**
517
- * Change circuit state
518
- */
519
- private setState;
520
- /**
521
- * Manually open the circuit
522
- */
523
- open(): void;
524
- /**
525
- * Manually close the circuit
526
- */
527
- close(): void;
528
- /**
529
- * Get current statistics
530
- */
531
- getStats(): CircuitBreakerStats;
532
- /**
533
- * Get current state
534
- */
535
- getState(): CircuitState;
536
- /**
537
- * Check if circuit is open
538
- */
539
- isOpen(): boolean;
540
- /**
541
- * Check if circuit is closed
542
- */
543
- isClosed(): boolean;
544
- /**
545
- * Reset statistics
546
- */
547
- reset(): void;
548
- }
549
- /**
550
- * Create a circuit breaker with sensible defaults
551
- *
552
- * @example
553
- * const emailBreaker = createCircuitBreaker(
554
- * async (to, subject, body) => sendEmail(to, subject, body),
555
- * { name: 'email-service' }
556
- * );
557
- */
558
- declare function createCircuitBreaker<T extends (...args: any[]) => Promise<any>>(fn: T, options?: CircuitBreakerOptions): CircuitBreaker<T>;
559
- /**
560
- * Circuit breaker registry for managing multiple breakers
561
- */
562
- declare class CircuitBreakerRegistry {
563
- private breakers;
564
- /**
565
- * Register a circuit breaker
566
- */
567
- register<T extends (...args: any[]) => Promise<any>>(name: string, fn: T, options?: Omit<CircuitBreakerOptions, 'name'>): CircuitBreaker<T>;
568
- /**
569
- * Get a circuit breaker by name
570
- */
571
- get(name: string): CircuitBreaker<any> | undefined;
572
- /**
573
- * Get all breakers
574
- */
575
- getAll(): Map<string, CircuitBreaker<any>>;
576
- /**
577
- * Get statistics for all breakers
578
- */
579
- getAllStats(): Record<string, CircuitBreakerStats>;
580
- /**
581
- * Reset all breakers
582
- */
583
- resetAll(): void;
584
- /**
585
- * Open all breakers
586
- */
587
- openAll(): void;
588
- /**
589
- * Close all breakers
590
- */
591
- closeAll(): void;
592
- }
593
- /**
594
- * Global circuit breaker registry
595
- */
596
- declare const circuitBreakerRegistry: CircuitBreakerRegistry;
597
-
598
- /**
599
- * Arc Query Parser - Default URL-to-Query Parser
600
- *
601
- * Framework-agnostic query parser that converts URL parameters to query options.
602
- * This is Arc's built-in parser; users can swap in MongoKit's QueryParser,
603
- * pgkit's parser, or any custom parser implementing QueryParserInterface.
604
- *
605
- * @example
606
- * // Use Arc default parser (auto-applied if no queryParser option)
607
- * defineResource({ name: 'product', adapter: ... });
608
- *
609
- * // Use MongoKit's QueryParser (recommended for MongoDB - has $lookup, aggregations, etc.)
610
- * import { QueryParser } from '@classytic/mongokit';
611
- * defineResource({
612
- * name: 'product',
613
- * adapter: ...,
614
- * queryParser: new QueryParser(),
615
- * });
616
- *
617
- * // Use custom parser for SQL databases
618
- * defineResource({
619
- * name: 'user',
620
- * adapter: ...,
621
- * queryParser: new PgQueryParser(),
622
- * });
623
- */
624
-
625
- interface ArcQueryParserOptions {
626
- /** Maximum allowed limit value (default: 1000) */
627
- maxLimit?: number;
628
- /** Default limit for pagination (default: 20) */
629
- defaultLimit?: number;
630
- /** Maximum regex pattern length (default: 500) */
631
- maxRegexLength?: number;
632
- /** Maximum search query length (default: 200) */
633
- maxSearchLength?: number;
634
- /** Maximum filter nesting depth (default: 10) */
635
- maxFilterDepth?: number;
636
- }
637
- /**
638
- * Arc's default query parser
639
- *
640
- * Converts URL query parameters to a structured query format:
641
- * - Pagination: ?page=1&limit=20
642
- * - Sorting: ?sort=-createdAt,name (- prefix = descending)
643
- * - Filtering: ?status=active&price[gte]=100&price[lte]=500
644
- * - Search: ?search=keyword
645
- * - Populate: ?populate=author,category
646
- * - Field selection: ?select=name,price,status
647
- * - Keyset pagination: ?after=cursor_value
648
- *
649
- * For advanced MongoDB features ($lookup, aggregations), use MongoKit's QueryParser.
650
- */
651
- declare class ArcQueryParser implements QueryParserInterface {
652
- private readonly maxLimit;
653
- private readonly defaultLimit;
654
- private readonly maxRegexLength;
655
- private readonly maxSearchLength;
656
- private readonly maxFilterDepth;
657
- /** Supported filter operators */
658
- private readonly operators;
659
- constructor(options?: ArcQueryParserOptions);
660
- /**
661
- * Parse URL query parameters into structured query options
662
- */
663
- parse(query: Record<string, unknown> | null | undefined): ParsedQuery;
664
- private parseNumber;
665
- private parseString;
666
- private parseSort;
667
- private parseSearch;
668
- private parseSelect;
669
- private parseFilters;
670
- private parseFilterValue;
671
- private coerceValue;
672
- private sanitizeRegex;
673
- }
674
- /**
675
- * Create a new ArcQueryParser instance
676
- */
677
- declare function createQueryParser(options?: ArcQueryParserOptions): ArcQueryParser;
678
-
679
- export { ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type JsonSchema, type StateMachine, type TransitionConfig, circuitBreakerRegistry, createCircuitBreaker, createQueryParser, createStateMachine, deleteResponse, errorResponseSchema, getListQueryParams, itemResponse, itemWrapper, listResponse, messageWrapper, mutationResponse, paginateWrapper, paginationSchema, queryParams, responses, successResponseSchema, wrapResponse };