@classytic/arc 2.18.4 → 2.19.0

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 (160) hide show
  1. package/dist/{BaseController-B-uXzf6I.mjs → BaseController-Dy6EQHjM.mjs} +7 -7
  2. package/dist/{QueryCache-Dsyv2mLS.d.mts → QueryCache-TRfXau3W.d.mts} +1 -1
  3. package/dist/{ResourceRegistry-CWmOggxS.mjs → ResourceRegistry-5fKZwhK_.mjs} +1 -1
  4. package/dist/{pipeline-D4sqiokR.mjs → actionPermissions-D7NGwcAR.mjs} +29 -5
  5. package/dist/audit/index.d.mts +1 -1
  6. package/dist/auth/index.d.mts +4 -4
  7. package/dist/auth/index.mjs +262 -6
  8. package/dist/auth/redis-session.d.mts +1 -1
  9. package/dist/betterAuthOpenApi-CV1lxpRX.mjs +2 -0
  10. package/dist/{buildHandler-Cvrc2p7r.mjs → buildHandler-B0qvAguf.mjs} +1 -1
  11. package/dist/cache/index.d.mts +3 -3
  12. package/dist/cache/index.mjs +3 -3
  13. package/dist/{caching-C0DdKiYB.mjs → caching-_NJeDd1_.mjs} +1 -1
  14. package/dist/cli/commands/describe.d.mts +1 -1
  15. package/dist/cli/commands/describe.mjs +2 -2
  16. package/dist/cli/commands/docs.mjs +2 -2
  17. package/dist/cli/commands/generate.d.mts +2 -2
  18. package/dist/cli/commands/generate.mjs +1 -1
  19. package/dist/cli/commands/init.d.mts +2 -2
  20. package/dist/cli/commands/init.mjs +1 -1
  21. package/dist/cli/commands/introspect.mjs +1 -1
  22. package/dist/cli/index.d.mts +2 -2
  23. package/dist/cli/index.mjs +2 -2
  24. package/dist/context/index.mjs +1 -1
  25. package/dist/core/index.d.mts +3 -3
  26. package/dist/core/index.mjs +4 -4
  27. package/dist/{core-C88uIwd3.mjs → core-Ba-6Sue6.mjs} +67 -63
  28. package/dist/{createActionRouter-DGCCp-kP.mjs → createActionRouter-B_WzBFyf.mjs} +10 -10
  29. package/dist/{createAggregationRouter-Ca77b8iK.mjs → createAggregationRouter-B_G_nIjm.mjs} +4 -4
  30. package/dist/{createApp-J1iPXY9p.mjs → createApp--703hQE1.mjs} +14 -14
  31. package/dist/docs/index.d.mts +2 -2
  32. package/dist/docs/index.mjs +2 -2
  33. package/dist/{elevation-BzhyVWfn.mjs → elevation-COpYKt2h.mjs} +2 -2
  34. package/dist/encryption/index.d.mts +222 -0
  35. package/dist/encryption/index.mjs +270 -0
  36. package/dist/{errorHandler-Bua97SEt.mjs → errorHandler-Dxf6P_kV.mjs} +2 -2
  37. package/dist/{eventPlugin-Bw4bUDEO.mjs → eventPlugin-DJG2D7sy.mjs} +106 -5
  38. package/dist/{eventPlugin-C1W1CRbf.d.mts → eventPlugin-DbBFd3x_.d.mts} +1 -1
  39. package/dist/events/index.d.mts +3 -3
  40. package/dist/events/index.mjs +189 -5
  41. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  42. package/dist/events/transports/redis.d.mts +1 -1
  43. package/dist/factory/index.d.mts +1 -1
  44. package/dist/factory/index.mjs +3 -3
  45. package/dist/{fastify-augmentation-BdCl_eNo.d.mts → fastify-augmentation-D-5_yQJi.d.mts} +2 -2
  46. package/dist/{fields-CKLrhyOb.d.mts → fields-C7ahdGYf.d.mts} +1 -1
  47. package/dist/{generate-BaxDdmJ8.mjs → generate-Brans3fW.mjs} +1 -1
  48. package/dist/hooks/index.d.mts +1 -1
  49. package/dist/hooks/index.mjs +1 -1
  50. package/dist/idempotency/index.d.mts +2 -2
  51. package/dist/idempotency/index.mjs +1 -1
  52. package/dist/idempotency/redis.d.mts +1 -1
  53. package/dist/{index-Cvo1u9n6.d.mts → index-CP6A1Ffj.d.mts} +9 -9
  54. package/dist/{index-vcWUGkwf.d.mts → index-CRKiiP5o.d.mts} +3 -3
  55. package/dist/{index-QYma8mdC.d.mts → index-CUTG2Cuo.d.mts} +88 -7
  56. package/dist/index.d.mts +5 -5
  57. package/dist/index.mjs +7 -7
  58. package/dist/{init-DSsdRfk9.mjs → init-Bqpt1Hxf.mjs} +274 -130
  59. package/dist/integrations/event-gateway.d.mts +2 -2
  60. package/dist/integrations/event-gateway.mjs +1 -1
  61. package/dist/integrations/index.d.mts +3 -3
  62. package/dist/integrations/mcp/index.d.mts +4 -4
  63. package/dist/integrations/mcp/index.mjs +1 -1
  64. package/dist/integrations/mcp/testing.d.mts +1 -1
  65. package/dist/integrations/mcp/testing.mjs +1 -1
  66. package/dist/integrations/streamline.mjs +7 -3
  67. package/dist/integrations/websocket-pushref-redis.d.mts +1 -1
  68. package/dist/integrations/websocket-redis.d.mts +1 -1
  69. package/dist/integrations/websocket.d.mts +3 -3
  70. package/dist/{loadResources-CwXt9MCh.mjs → loadResources-B8UmpITt.mjs} +1 -1
  71. package/dist/{loadResourcesFromEntry-XHNeUWpu.mjs → loadResourcesFromEntry-BTlFEx05.mjs} +1 -1
  72. package/dist/{mcpPlugin-CzKdt3B8.mjs → mcpPlugin-C088Nd-G.mjs} +10 -11
  73. package/dist/{memory-TdTHCS9-.mjs → memory-CLXA2VeJ.mjs} +1 -1
  74. package/dist/{metrics-Da2EUPi9.mjs → metrics-fdxI5mn_.mjs} +1 -1
  75. package/dist/middleware/index.d.mts +1 -1
  76. package/dist/middleware/index.mjs +2 -2
  77. package/dist/{openapi-ButnRyOM.mjs → openapi-DZ-5a5Op.mjs} +5 -5
  78. package/dist/permissions/index.d.mts +3 -3
  79. package/dist/permissions/index.mjs +2 -2
  80. package/dist/{permissions-3uzwkbQt.mjs → permissions-BPB1xqGf.mjs} +4 -4
  81. package/dist/{pipe-9Tl-OAus.mjs → pipe-BOLmGIxa.mjs} +1 -1
  82. package/dist/pipeline/index.d.mts +1 -1
  83. package/dist/pipeline/index.mjs +1 -1
  84. package/dist/plugins/index.d.mts +6 -7
  85. package/dist/plugins/index.mjs +12 -12
  86. package/dist/plugins/response-cache.mjs +1 -1
  87. package/dist/plugins/tracing-entry.d.mts +1 -1
  88. package/dist/plugins/tracing-entry.mjs +1 -1
  89. package/dist/presets/filesUpload.d.mts +4 -4
  90. package/dist/presets/filesUpload.mjs +4 -4
  91. package/dist/presets/index.d.mts +1 -1
  92. package/dist/presets/index.mjs +1 -1
  93. package/dist/presets/multiTenant.d.mts +1 -1
  94. package/dist/presets/multiTenant.mjs +2 -2
  95. package/dist/presets/search.d.mts +2 -2
  96. package/dist/presets/search.mjs +1 -1
  97. package/dist/{presets-CF79RHEo.mjs → presets-BtyFwTO4.mjs} +2 -2
  98. package/dist/{queryCachePlugin-CnAeFqju.mjs → queryCachePlugin-emHb0CuX.mjs} +4 -4
  99. package/dist/{queryCachePlugin-Bd2tYgh5.d.mts → queryCachePlugin-xzFyKAjT.d.mts} +2 -2
  100. package/dist/{redis-3hqH_Qk_.d.mts → redis-C3W0qbz8.d.mts} +1 -1
  101. package/dist/{redis-stream-BtEUtjxZ.d.mts → redis-stream-DsP1vqZB.d.mts} +1 -1
  102. package/dist/{rateLimit-yKvxWAky.mjs → registerRoute-BdV8DDwU.mjs} +127 -2
  103. package/dist/registry/index.d.mts +1 -1
  104. package/dist/registry/index.mjs +2 -2
  105. package/dist/{registry-Br15xdGM.mjs → registry-Bm9LjWKs.mjs} +1 -1
  106. package/dist/{replyHelpers-DXHVxrrj.mjs → replyHelpers-67tRawQZ.mjs} +1 -1
  107. package/dist/{schemaIR-CE6USIRi.mjs → schemaIR-D1MJwqmp.mjs} +1 -1
  108. package/dist/schemas/index.d.mts +64 -65
  109. package/dist/scope/index.d.mts +2 -2
  110. package/dist/scope/index.mjs +3 -3
  111. package/dist/{sse-BrY1W6U8.mjs → sse-CfUjwjDk.mjs} +7 -4
  112. package/dist/streaming-BQcW6_Kq.mjs +162 -0
  113. package/dist/testing/index.d.mts +7 -7
  114. package/dist/testing/index.mjs +3 -3
  115. package/dist/testing/storageContract.d.mts +1 -1
  116. package/dist/types/index.d.mts +5 -5
  117. package/dist/types/storage.d.mts +1 -1
  118. package/dist/{types-WVlAVp8T.d.mts → types-9_wtNPsI.d.mts} +10 -10
  119. package/dist/{types-BWBcb88c.d.mts → types-DpvSF5Hh.d.mts} +1 -1
  120. package/dist/{types-Bi0r0vjG.mjs → types-bHblZ9YN.mjs} +1 -1
  121. package/dist/utils/index.d.mts +42 -4
  122. package/dist/utils/index.mjs +6 -5
  123. package/dist/{utils-xAQeDyU_.mjs → utils-C6QQ9-hd.mjs} +1415 -1524
  124. package/dist/{validate-0__MuUsK.mjs → validate-CRcaWzp2.mjs} +1 -1
  125. package/dist/{versioning-BSEDGXKC.d.mts → versioning-D_eBCfNr.d.mts} +8 -1
  126. package/dist/{versioning-C0K8KQLx.mjs → versioning-Dk-71iIz.mjs} +1 -1
  127. package/dist/{websocket-BFBT5rH-.d.mts → websocket-MlYlrYq0.d.mts} +1 -1
  128. package/package.json +45 -30
  129. package/dist/EventTransport-7LPXLEUX.mjs +0 -103
  130. package/dist/actionPermissions-CX9QIMTd.mjs +0 -24
  131. package/dist/betterAuthOpenApi-DAAhMZff.mjs +0 -251
  132. package/dist/defineEvent-DC981g-o.mjs +0 -188
  133. package/dist/registerRoute-BEYn0ylk.mjs +0 -108
  134. /package/dist/{EventTransport-CaaXM5Y1.d.mts → EventTransport-IEn7Tn-Q.d.mts} +0 -0
  135. /package/dist/{HookSystem-BfCpWbwM.mjs → HookSystem-C1vB_Gc9.mjs} +0 -0
  136. /package/dist/{constants-TrJVIJl0.mjs → constants-gaEeMlz-.mjs} +0 -0
  137. /package/dist/{elevation-DW90z5bT.d.mts → elevation-xGUBq6p_.d.mts} +0 -0
  138. /package/dist/{errorHandler-_Lp2k9M3.d.mts → errorHandler-BtUUDPEa.d.mts} +0 -0
  139. /package/dist/{errors-DZOemeGa.d.mts → errors-DOHkjQlD.d.mts} +0 -0
  140. /package/dist/{errors-j4aJm1Wg.mjs → errors-DkO8Nk6-.mjs} +0 -0
  141. /package/dist/{externalPaths-DLle0R07.d.mts → externalPaths-BE6wFpYv.d.mts} +0 -0
  142. /package/dist/{generate-Dmk8cfvX.d.mts → generate-BnsL9GBm.d.mts} +0 -0
  143. /package/dist/{init-BS4Daqnv.d.mts → init-BPEu8cs-.d.mts} +0 -0
  144. /package/dist/{interface-DL7LlWS5.d.mts → interface-C1_WLTMK.d.mts} +0 -0
  145. /package/dist/{interface-CsrGR8LF.d.mts → interface-Uk8ONJv7.d.mts} +0 -0
  146. /package/dist/{keys-B3yyBEyH.mjs → keys-Cd316u_y.mjs} +0 -0
  147. /package/dist/{multipartBody-709YcXi1.mjs → multipartBody-CHEQSZ6G.mjs} +0 -0
  148. /package/dist/{pluralize-BxdUl2P4.mjs → pluralize-DccFV9R7.mjs} +0 -0
  149. /package/dist/{preloadResources-B-j-iqo-.mjs → preloadResources-CHw3_oA_.mjs} +0 -0
  150. /package/dist/{pushref-registry-Dqclzjy7.d.mts → pushref-registry-DnCqL3aa.d.mts} +0 -0
  151. /package/dist/{requestContext-DDLS3NVU.mjs → requestContext-BZKOr13H.mjs} +0 -0
  152. /package/dist/{chunk-BpYLSNr0.mjs → rolldown-runtime-8H4AJuhK.mjs} +0 -0
  153. /package/dist/{schemaConverter-DatAaVNj.mjs → schemaConverter-U0MnO9vd.mjs} +0 -0
  154. /package/dist/{sessionManager-CyHpYXoB.d.mts → sessionManager-BXG-HGwG.d.mts} +0 -0
  155. /package/dist/{storage-C5q8fuEt.d.mts → storage-Co_PQpeQ.d.mts} +0 -0
  156. /package/dist/{store-helpers-DjSYI2uP.mjs → store-helpers-DY6xq4sM.mjs} +0 -0
  157. /package/dist/{tracing-Bnb1-YVd.d.mts → tracing-D8jlGXP7.d.mts} +0 -0
  158. /package/dist/{typeGuards-CcFZXgU7.mjs → typeGuards-C9KXUly6.mjs} +0 -0
  159. /package/dist/{types-BJwJN2Pg.d.mts → types-LNebCoJx.d.mts} +0 -0
  160. /package/dist/{types-D57iXYb8.mjs → types-XTApa8b6.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- import { a as toJsonSchema } from "./schemaConverter-DatAaVNj.mjs";
1
+ import { a as toJsonSchema } from "./schemaConverter-U0MnO9vd.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/core/schemaIR.ts
4
4
  /**
@@ -1,6 +1,5 @@
1
1
  import { ErrorContract, ErrorDetail } from "@classytic/repo-core/errors";
2
2
  import { FastifyPluginAsyncTypebox, FastifyPluginCallbackTypebox, TypeBoxTypeProvider, TypeBoxValidatorCompiler } from "@fastify/type-provider-typebox";
3
- import * as _$_sinclair_typebox0 from "@sinclair/typebox";
4
3
  import { Static, TObject, TSchema, TSchema as TSchema$1, Type } from "@sinclair/typebox";
5
4
 
6
5
  //#region src/schemas/index.d.ts
@@ -18,74 +17,74 @@ import { Static, TObject, TSchema, TSchema as TSchema$1, Type } from "@sinclair/
18
17
  * variant when your endpoint never emits the others. HTTP status
19
18
  * discriminates success vs error — no `success` field.
20
19
  */
21
- declare function ArcListResponse<T extends TSchema$1>(itemSchema: T): _$_sinclair_typebox0.TUnion<[_$_sinclair_typebox0.TObject<{
22
- method: _$_sinclair_typebox0.TLiteral<"offset">;
23
- data: _$_sinclair_typebox0.TArray<T>;
24
- page: _$_sinclair_typebox0.TInteger;
25
- limit: _$_sinclair_typebox0.TInteger;
26
- total: _$_sinclair_typebox0.TInteger;
27
- pages: _$_sinclair_typebox0.TInteger;
28
- hasNext: _$_sinclair_typebox0.TBoolean;
29
- hasPrev: _$_sinclair_typebox0.TBoolean;
30
- }>, _$_sinclair_typebox0.TObject<{
31
- method: _$_sinclair_typebox0.TLiteral<"keyset">;
32
- data: _$_sinclair_typebox0.TArray<T>;
33
- limit: _$_sinclair_typebox0.TInteger;
34
- hasMore: _$_sinclair_typebox0.TBoolean;
35
- next: _$_sinclair_typebox0.TUnion<[_$_sinclair_typebox0.TString, _$_sinclair_typebox0.TNull]>;
36
- }>, _$_sinclair_typebox0.TObject<{
37
- method: _$_sinclair_typebox0.TLiteral<"aggregate">;
38
- data: _$_sinclair_typebox0.TArray<T>;
39
- page: _$_sinclair_typebox0.TInteger;
40
- limit: _$_sinclair_typebox0.TInteger;
41
- total: _$_sinclair_typebox0.TInteger;
42
- pages: _$_sinclair_typebox0.TInteger;
43
- hasNext: _$_sinclair_typebox0.TBoolean;
44
- hasPrev: _$_sinclair_typebox0.TBoolean;
45
- }>, _$_sinclair_typebox0.TObject<{
46
- data: _$_sinclair_typebox0.TArray<T>;
20
+ declare function ArcListResponse<T extends TSchema$1>(itemSchema: T): import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
21
+ method: import("@sinclair/typebox").TLiteral<"offset">;
22
+ data: import("@sinclair/typebox").TArray<T>;
23
+ page: import("@sinclair/typebox").TInteger;
24
+ limit: import("@sinclair/typebox").TInteger;
25
+ total: import("@sinclair/typebox").TInteger;
26
+ pages: import("@sinclair/typebox").TInteger;
27
+ hasNext: import("@sinclair/typebox").TBoolean;
28
+ hasPrev: import("@sinclair/typebox").TBoolean;
29
+ }>, import("@sinclair/typebox").TObject<{
30
+ method: import("@sinclair/typebox").TLiteral<"keyset">;
31
+ data: import("@sinclair/typebox").TArray<T>;
32
+ limit: import("@sinclair/typebox").TInteger;
33
+ hasMore: import("@sinclair/typebox").TBoolean;
34
+ next: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
35
+ }>, import("@sinclair/typebox").TObject<{
36
+ method: import("@sinclair/typebox").TLiteral<"aggregate">;
37
+ data: import("@sinclair/typebox").TArray<T>;
38
+ page: import("@sinclair/typebox").TInteger;
39
+ limit: import("@sinclair/typebox").TInteger;
40
+ total: import("@sinclair/typebox").TInteger;
41
+ pages: import("@sinclair/typebox").TInteger;
42
+ hasNext: import("@sinclair/typebox").TBoolean;
43
+ hasPrev: import("@sinclair/typebox").TBoolean;
44
+ }>, import("@sinclair/typebox").TObject<{
45
+ data: import("@sinclair/typebox").TArray<T>;
47
46
  }>]>;
48
47
  /** Offset variant — `{ method: 'offset', data, page, limit, total, pages, hasNext, hasPrev }`. */
49
- declare function ArcOffsetListResponse<T extends TSchema$1>(itemSchema: T): _$_sinclair_typebox0.TObject<{
50
- method: _$_sinclair_typebox0.TLiteral<"offset">;
51
- data: _$_sinclair_typebox0.TArray<T>;
52
- page: _$_sinclair_typebox0.TInteger;
53
- limit: _$_sinclair_typebox0.TInteger;
54
- total: _$_sinclair_typebox0.TInteger;
55
- pages: _$_sinclair_typebox0.TInteger;
56
- hasNext: _$_sinclair_typebox0.TBoolean;
57
- hasPrev: _$_sinclair_typebox0.TBoolean;
48
+ declare function ArcOffsetListResponse<T extends TSchema$1>(itemSchema: T): import("@sinclair/typebox").TObject<{
49
+ method: import("@sinclair/typebox").TLiteral<"offset">;
50
+ data: import("@sinclair/typebox").TArray<T>;
51
+ page: import("@sinclair/typebox").TInteger;
52
+ limit: import("@sinclair/typebox").TInteger;
53
+ total: import("@sinclair/typebox").TInteger;
54
+ pages: import("@sinclair/typebox").TInteger;
55
+ hasNext: import("@sinclair/typebox").TBoolean;
56
+ hasPrev: import("@sinclair/typebox").TBoolean;
58
57
  }>;
59
58
  /** Keyset variant — `{ method: 'keyset', data, limit, hasMore, next: string | null }`. */
60
- declare function ArcKeysetListResponse<T extends TSchema$1>(itemSchema: T): _$_sinclair_typebox0.TObject<{
61
- method: _$_sinclair_typebox0.TLiteral<"keyset">;
62
- data: _$_sinclair_typebox0.TArray<T>;
63
- limit: _$_sinclair_typebox0.TInteger;
64
- hasMore: _$_sinclair_typebox0.TBoolean;
65
- next: _$_sinclair_typebox0.TUnion<[_$_sinclair_typebox0.TString, _$_sinclair_typebox0.TNull]>;
59
+ declare function ArcKeysetListResponse<T extends TSchema$1>(itemSchema: T): import("@sinclair/typebox").TObject<{
60
+ method: import("@sinclair/typebox").TLiteral<"keyset">;
61
+ data: import("@sinclair/typebox").TArray<T>;
62
+ limit: import("@sinclair/typebox").TInteger;
63
+ hasMore: import("@sinclair/typebox").TBoolean;
64
+ next: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
66
65
  }>;
67
66
  /** Aggregate variant — `{ method: 'aggregate', ...same as offset }`. */
68
- declare function ArcAggregateListResponse<T extends TSchema$1>(itemSchema: T): _$_sinclair_typebox0.TObject<{
69
- method: _$_sinclair_typebox0.TLiteral<"aggregate">;
70
- data: _$_sinclair_typebox0.TArray<T>;
71
- page: _$_sinclair_typebox0.TInteger;
72
- limit: _$_sinclair_typebox0.TInteger;
73
- total: _$_sinclair_typebox0.TInteger;
74
- pages: _$_sinclair_typebox0.TInteger;
75
- hasNext: _$_sinclair_typebox0.TBoolean;
76
- hasPrev: _$_sinclair_typebox0.TBoolean;
67
+ declare function ArcAggregateListResponse<T extends TSchema$1>(itemSchema: T): import("@sinclair/typebox").TObject<{
68
+ method: import("@sinclair/typebox").TLiteral<"aggregate">;
69
+ data: import("@sinclair/typebox").TArray<T>;
70
+ page: import("@sinclair/typebox").TInteger;
71
+ limit: import("@sinclair/typebox").TInteger;
72
+ total: import("@sinclair/typebox").TInteger;
73
+ pages: import("@sinclair/typebox").TInteger;
74
+ hasNext: import("@sinclair/typebox").TBoolean;
75
+ hasPrev: import("@sinclair/typebox").TBoolean;
77
76
  }>;
78
77
  /** Bare variant — `{ data }`, no `method` discriminant. */
79
- declare function ArcBareListResponse<T extends TSchema$1>(itemSchema: T): _$_sinclair_typebox0.TObject<{
80
- data: _$_sinclair_typebox0.TArray<T>;
78
+ declare function ArcBareListResponse<T extends TSchema$1>(itemSchema: T): import("@sinclair/typebox").TObject<{
79
+ data: import("@sinclair/typebox").TArray<T>;
81
80
  }>;
82
81
  /**
83
82
  * Delete response — `{ message, id?, soft? }` raw at the top level.
84
83
  */
85
- declare function ArcDeleteResponse(): _$_sinclair_typebox0.TObject<{
86
- message: _$_sinclair_typebox0.TString;
87
- id: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TString>;
88
- soft: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TBoolean>;
84
+ declare function ArcDeleteResponse(): import("@sinclair/typebox").TObject<{
85
+ message: import("@sinclair/typebox").TString;
86
+ id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
87
+ soft: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
89
88
  }>;
90
89
  /**
91
90
  * Single field-scoped error detail — `Type.Unsafe<ErrorDetail>` over the
@@ -97,7 +96,7 @@ declare function ArcDeleteResponse(): _$_sinclair_typebox0.TObject<{
97
96
  * Exported standalone so hosts can embed it in custom 422 / 409 response
98
97
  * schemas.
99
98
  */
100
- declare function ArcErrorDetail(): _$_sinclair_typebox0.TUnsafe<ErrorDetail>;
99
+ declare function ArcErrorDetail(): import("@sinclair/typebox").TUnsafe<ErrorDetail>;
101
100
  /**
102
101
  * Error response schema — `Type.Unsafe<ErrorContract>` over the canonical
103
102
  * JSON Schema `errorContractSchema` from `@classytic/repo-core/errors`.
@@ -106,7 +105,7 @@ declare function ArcErrorDetail(): _$_sinclair_typebox0.TUnsafe<ErrorDetail>;
106
105
  * (`errorContractSchema`) and this TypeBox helper cannot drift —
107
106
  * literally one source.
108
107
  */
109
- declare function ArcErrorResponse(): _$_sinclair_typebox0.TUnsafe<ErrorContract>;
108
+ declare function ArcErrorResponse(): import("@sinclair/typebox").TUnsafe<ErrorContract>;
110
109
  /**
111
110
  * Standard pagination + sorting + filtering query parameters.
112
111
  * Matches Arc's list endpoint conventions.
@@ -122,12 +121,12 @@ declare function ArcErrorResponse(): _$_sinclair_typebox0.TUnsafe<ErrorContract>
122
121
  * projection forms at the request-validation gate even though arc passes
123
122
  * them through unchanged.
124
123
  */
125
- declare function ArcPaginationQuery(): _$_sinclair_typebox0.TObject<{
126
- page: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TInteger>;
127
- limit: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TInteger>;
128
- sort: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TString>;
129
- select: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TUnion<[_$_sinclair_typebox0.TString, _$_sinclair_typebox0.TArray<_$_sinclair_typebox0.TString>, _$_sinclair_typebox0.TRecord<_$_sinclair_typebox0.TString, _$_sinclair_typebox0.TUnion<[_$_sinclair_typebox0.TLiteral<0>, _$_sinclair_typebox0.TLiteral<1>]>>]>>;
130
- populate: _$_sinclair_typebox0.TOptional<_$_sinclair_typebox0.TAny>;
124
+ declare function ArcPaginationQuery(): import("@sinclair/typebox").TObject<{
125
+ page: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
126
+ limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
127
+ sort: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
128
+ select: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<0>, import("@sinclair/typebox").TLiteral<1>]>>]>>;
129
+ populate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
131
130
  }>;
132
131
  //#endregion
133
132
  export { ArcAggregateListResponse, ArcBareListResponse, ArcDeleteResponse, ArcErrorDetail, ArcErrorResponse, ArcKeysetListResponse, ArcListResponse, ArcOffsetListResponse, ArcPaginationQuery, type FastifyPluginAsyncTypebox, type FastifyPluginCallbackTypebox, type Static, type TObject, type TSchema, Type, type TypeBoxTypeProvider, TypeBoxValidatorCompiler };
@@ -1,5 +1,5 @@
1
- import { C as isMember, D as requireOrgId, E as requireClientId, O as requireTeamId, S as isElevated, T as isService, _ as getTenantFromRequest, a as getAncestorOrgIds, b as hasOrgAccess, c as getMandate, d as getOrgRoles, f as getRequestScope, g as getTeamId, h as getServiceScopes, i as RequestScope, k as requireUserId, l as getOrgContext, m as getScopeContextMap, n as Mandate, o as getClientId, p as getScopeContext, r as PUBLIC_SCOPE, s as getDPoPJkt, t as AUTHENTICATED_SCOPE, u as getOrgId, v as getUserId, w as isOrgInScope, x as isAuthenticated, y as getUserRoles } from "../types-BJwJN2Pg.mjs";
2
- import { i as elevationPlugin, n as ElevationOptions, r as _default, t as ElevationEvent } from "../elevation-DW90z5bT.mjs";
1
+ import { C as isMember, D as requireOrgId, E as requireClientId, O as requireTeamId, S as isElevated, T as isService, _ as getTenantFromRequest, a as getAncestorOrgIds, b as hasOrgAccess, c as getMandate, d as getOrgRoles, f as getRequestScope, g as getTeamId, h as getServiceScopes, i as RequestScope, k as requireUserId, l as getOrgContext, m as getScopeContextMap, n as Mandate, o as getClientId, p as getScopeContext, r as PUBLIC_SCOPE, s as getDPoPJkt, t as AUTHENTICATED_SCOPE, u as getOrgId, v as getUserId, w as isOrgInScope, x as isAuthenticated, y as getUserRoles } from "../types-LNebCoJx.mjs";
2
+ import { i as elevationPlugin, n as ElevationOptions, r as _default, t as ElevationEvent } from "../elevation-xGUBq6p_.mjs";
3
3
  import { FastifyReply, FastifyRequest } from "fastify";
4
4
 
5
5
  //#region src/scope/rateLimitKey.d.ts
@@ -1,6 +1,6 @@
1
- import { C as isService, D as requireUserId, E as requireTeamId, S as isOrgInScope, T as requireOrgId, _ as getUserRoles, a as getDPoPJkt, b as isElevated, c as getOrgId, d as getScopeContext, f as getScopeContextMap, g as getUserId, h as getTenantFromRequest, i as getClientId, l as getOrgRoles, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, r as getAncestorOrgIds, s as getOrgContext, t as AUTHENTICATED_SCOPE, u as getRequestScope, v as hasOrgAccess, w as requireClientId, x as isMember, y as isAuthenticated } from "../types-Bi0r0vjG.mjs";
2
- import { n as normalizeRoles } from "../types-D57iXYb8.mjs";
3
- import { n as elevation_default, t as elevationPlugin } from "../elevation-BzhyVWfn.mjs";
1
+ import { C as isService, D as requireUserId, E as requireTeamId, S as isOrgInScope, T as requireOrgId, _ as getUserRoles, a as getDPoPJkt, b as isElevated, c as getOrgId, d as getScopeContext, f as getScopeContextMap, g as getUserId, h as getTenantFromRequest, i as getClientId, l as getOrgRoles, m as getTeamId, n as PUBLIC_SCOPE, o as getMandate, p as getServiceScopes, r as getAncestorOrgIds, s as getOrgContext, t as AUTHENTICATED_SCOPE, u as getRequestScope, v as hasOrgAccess, w as requireClientId, x as isMember, y as isAuthenticated } from "../types-bHblZ9YN.mjs";
2
+ import { n as normalizeRoles } from "../types-XTApa8b6.mjs";
3
+ import { n as elevation_default, t as elevationPlugin } from "../elevation-COpYKt2h.mjs";
4
4
  //#region src/scope/rateLimitKey.ts
5
5
  function createTenantKeyGenerator(opts) {
6
6
  if (opts?.strategy) return opts.strategy;
@@ -1,6 +1,7 @@
1
- import { t as __exportAll } from "./chunk-BpYLSNr0.mjs";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { arcLog } from "./logger/index.mjs";
3
- import { c as getOrgId, n as PUBLIC_SCOPE } from "./types-Bi0r0vjG.mjs";
3
+ import { c as getOrgId, n as PUBLIC_SCOPE } from "./types-bHblZ9YN.mjs";
4
+ import { a as promoteStreamTokenToHeader, n as forwardedStreamHeaders } from "./streaming-BQcW6_Kq.mjs";
4
5
  import fp from "fastify-plugin";
5
6
  //#region src/plugins/sse.ts
6
7
  var sse_exports = /* @__PURE__ */ __exportAll({
@@ -9,7 +10,7 @@ var sse_exports = /* @__PURE__ */ __exportAll({
9
10
  });
10
11
  const log = arcLog("sse");
11
12
  const ssePlugin = async (fastify, opts = {}) => {
12
- const { path = "/events/stream", requireAuth = true, patterns = ["*"], heartbeat = 3e4, orgScoped = false, filter: customFilter } = opts;
13
+ const { path = "/events/stream", requireAuth = true, patterns = ["*"], heartbeat = 3e4, orgScoped = false, filter: customFilter, tokenQueryParam = "token" } = opts;
13
14
  if (!fastify.hasDecorator("events")) {
14
15
  log.warn("Events plugin (arc-events) not registered. SSE plugin will not function. Register eventPlugin before ssePlugin.");
15
16
  return;
@@ -33,7 +34,8 @@ const ssePlugin = async (fastify, opts = {}) => {
33
34
  "content-type": "text/event-stream",
34
35
  "cache-control": "no-cache",
35
36
  connection: "keep-alive",
36
- "x-accel-buffering": "no"
37
+ "x-accel-buffering": "no",
38
+ ...forwardedStreamHeaders(reply)
37
39
  });
38
40
  reply.raw.flushHeaders();
39
41
  const unsubscribers = [];
@@ -80,6 +82,7 @@ const ssePlugin = async (fastify, opts = {}) => {
80
82
  };
81
83
  if (requireAuth) {
82
84
  routeOpts.preHandler = (request, reply) => {
85
+ if (tokenQueryParam) promoteStreamTokenToHeader(request, tokenQueryParam);
83
86
  const authenticate = fastify.authenticate;
84
87
  if (typeof authenticate !== "function") {
85
88
  reply.code(401).send({ error: "Unauthorized" });
@@ -0,0 +1,162 @@
1
+ import { Readable } from "node:stream";
2
+ //#region src/utils/streaming.ts
3
+ /**
4
+ * Streaming helpers — adapters between Web `ReadableStream` producers
5
+ * (Vercel AI SDK, OpenAI SDK, `fetch().body`, hand-built `TransformStream`s)
6
+ * and Fastify's raw Node-stream reply.
7
+ *
8
+ * Why this exists: returning a `ReadableStream<UIMessageChunk>` from a
9
+ * `streamResponse: true` arc route used to crash with
10
+ * `chunk must be a string or Buffer` because Fastify cannot serialise
11
+ * `UIMessageChunk` JSON objects directly. Every arc-ai host (sniffer,
12
+ * spawn, downstream) reimplemented the same `JsonToSseTransformStream` +
13
+ * SSE header boilerplate. `pipeUIMessageStreamToReply()` is that
14
+ * boilerplate, owned once.
15
+ *
16
+ * arc stays peer-coupled to nothing: the helper accepts any
17
+ * `ReadableStream<unknown>` and JSON-stringifies each chunk. It works
18
+ * with `UIMessageChunk` from the AI SDK without importing it.
19
+ */
20
+ /**
21
+ * Canonical SSE headers for AI-SDK-style UI message streams.
22
+ *
23
+ * `x-vercel-ai-ui-message-stream: v1` is the marker the Vercel AI SDK
24
+ * client uses to detect the v1 UI message stream protocol (vs the older
25
+ * data stream protocol). Surfaced as a constant so hosts don't memorise it.
26
+ */
27
+ const UI_MESSAGE_STREAM_HEADERS = {
28
+ "content-type": "text/event-stream",
29
+ "cache-control": "no-cache",
30
+ connection: "keep-alive",
31
+ "x-accel-buffering": "no",
32
+ "x-vercel-ai-ui-message-stream": "v1"
33
+ };
34
+ /**
35
+ * Pipe a Web `ReadableStream` of JSON-serialisable chunks (typically
36
+ * `UIMessageChunk` from the Vercel AI SDK) into a Fastify reply as an
37
+ * SSE event stream.
38
+ *
39
+ * - Sets {@link UI_MESSAGE_STREAM_HEADERS} (or the caller's override)
40
+ * before the first chunk.
41
+ * - Writes each chunk as `data: ${JSON.stringify(chunk)}\n\n`.
42
+ * - Cancels the source and closes the reply when the client disconnects.
43
+ * - Resolves once the stream is fully written.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { pipeUIMessageStreamToReply } from '@classytic/arc/utils';
48
+ * import { streamText, convertToUIMessageStream } from 'ai';
49
+ *
50
+ * defineResource({
51
+ * name: 'chat',
52
+ * routes: [{
53
+ * method: 'POST', path: '/', streamResponse: true,
54
+ * handler: async (req, reply) => {
55
+ * const result = streamText({ model, messages: req.body.messages });
56
+ * await pipeUIMessageStreamToReply(reply, result.toUIMessageStream());
57
+ * },
58
+ * }],
59
+ * });
60
+ * ```
61
+ */
62
+ async function pipeUIMessageStreamToReply(reply, stream, options = {}) {
63
+ const serialize = options.serialize ?? defaultSerialize;
64
+ const headers = options.headers ?? UI_MESSAGE_STREAM_HEADERS;
65
+ for (const [key, value] of Object.entries(headers)) reply.header(key, value);
66
+ const reader = stream.getReader();
67
+ let cancelled = false;
68
+ const onAbort = () => {
69
+ cancelled = true;
70
+ reader.cancel().catch(() => {});
71
+ };
72
+ reply.request.raw.once("close", onAbort);
73
+ options.signal?.addEventListener("abort", onAbort, { once: true });
74
+ async function* sseFrames() {
75
+ try {
76
+ while (true) {
77
+ const { value, done } = await reader.read();
78
+ if (done) break;
79
+ yield `data: ${serialize(value)}\n\n`;
80
+ }
81
+ } catch (err) {
82
+ if (!cancelled) yield `event: error\ndata: ${JSON.stringify({ message: String(err) })}\n\n`;
83
+ } finally {
84
+ reply.request.raw.removeListener("close", onAbort);
85
+ options.signal?.removeEventListener("abort", onAbort);
86
+ reader.releaseLock?.();
87
+ }
88
+ }
89
+ const nodeStream = Readable.from(sseFrames());
90
+ await reply.send(nodeStream);
91
+ }
92
+ function defaultSerialize(chunk) {
93
+ return typeof chunk === "string" ? chunk : JSON.stringify(chunk);
94
+ }
95
+ /**
96
+ * Promote a stream auth token from the query string into the `Authorization`
97
+ * header, in place, so the standard `fastify.authenticate` decorator can read it.
98
+ *
99
+ * Why: the browser `EventSource` (and `WebSocket`) API **cannot set request
100
+ * headers** — there is no header channel on the constructor. So arc-next's
101
+ * `buildStreamUrl` (bearer mode) appends the token as `?token=<jwt>` on stream
102
+ * URLs. Server auth reads the `Authorization` header, so without this promotion
103
+ * EVERY browser SSE/WS stream is 401 in bearer mode (cookie mode is unaffected —
104
+ * arc-next omits the query token there and relies on the cookie).
105
+ *
106
+ * Safe by construction:
107
+ * - No-op when an `Authorization` header is already present → normal `fetch`
108
+ * requests (which send the header) are never touched.
109
+ * - The token still goes through full authentication downstream, so a forged or
110
+ * stale value simply 401s. This only relocates WHERE the bearer is read from;
111
+ * it grants no trust on its own.
112
+ *
113
+ * Parsed from `request.raw.url` (not `request.query`) so it's robust to route
114
+ * querystring schemas that would otherwise strip an undeclared `token` param.
115
+ *
116
+ * @param queryParam name of the query parameter carrying the token (default `token`).
117
+ */
118
+ function promoteStreamTokenToHeader(request, queryParam = "token") {
119
+ if (request.headers.authorization) return;
120
+ const url = request.raw.url ?? "";
121
+ const q = url.indexOf("?");
122
+ if (q < 0) return;
123
+ const token = new URLSearchParams(url.slice(q + 1)).get(queryParam);
124
+ if (token) request.headers.authorization = `Bearer ${token}`;
125
+ }
126
+ /**
127
+ * Collect the CORS / `Vary` headers a plugin (e.g. `@fastify/cors`, whose default
128
+ * `onRequest` hook runs BEFORE the route handler) has already set on the reply, so
129
+ * a hijacked SSE handler that writes straight to `reply.raw.writeHead(...)` can
130
+ * merge them onto the raw response.
131
+ *
132
+ * Why: `reply.hijack()` + `reply.raw.writeHead()` bypass Fastify's `onSend`
133
+ * serialization, which is where reply-level headers reach the wire. A cross-origin
134
+ * `EventSource` therefore receives no `Access-Control-Allow-Origin` and the browser
135
+ * blocks the (authenticated) stream. Re-emitting the already-computed CORS headers
136
+ * honors the host's configured policy (origin allowlist, credentials) rather than
137
+ * re-deriving it. Returns lowercased header names suitable for `writeHead`.
138
+ */
139
+ function forwardedStreamHeaders(reply) {
140
+ const out = {};
141
+ for (const [key, value] of Object.entries(reply.getHeaders())) {
142
+ if (value == null) continue;
143
+ if (key.startsWith("access-control-") || key === "vary") out[key] = Array.isArray(value) ? value.join(", ") : String(value);
144
+ }
145
+ return out;
146
+ }
147
+ /**
148
+ * Heuristic — does this value look like a Web `ReadableStream`?
149
+ *
150
+ * Used by `createCrudRouter` to auto-pipe `streamResponse: true` handlers
151
+ * that return a UI message stream instead of writing to `reply.raw`
152
+ * directly. Cross-realm safe (no `instanceof`) — checks the duck shape
153
+ * the Streams spec mandates: `getReader`, `cancel`, and the `locked`
154
+ * getter.
155
+ */
156
+ function isReadableStream(value) {
157
+ if (value === null || typeof value !== "object") return false;
158
+ const obj = value;
159
+ return typeof obj.getReader === "function" && typeof obj.cancel === "function" && typeof obj.locked === "boolean";
160
+ }
161
+ //#endregion
162
+ export { promoteStreamTokenToHeader as a, pipeUIMessageStreamToReply as i, forwardedStreamHeaders as n, isReadableStream as r, UI_MESSAGE_STREAM_HEADERS as t };
@@ -1,5 +1,5 @@
1
- import { Kt as AnyRecord, V as ResourceDefinition } from "../index-QYma8mdC.mjs";
2
- import { d as preloadResourcesAsync, r as CreateAppOptions, u as preloadResources } from "../types-WVlAVp8T.mjs";
1
+ import { V as ResourceDefinition, qt as AnyRecord } from "../index-CUTG2Cuo.mjs";
2
+ import { d as preloadResourcesAsync, r as CreateAppOptions, u as preloadResources } from "../types-9_wtNPsI.mjs";
3
3
  import { StorageContractSetup, StorageContractSetupResult, runStorageContract } from "./storageContract.mjs";
4
4
  import { FastifyInstance, FastifyServerOptions } from "fastify";
5
5
  import { Mock } from "vitest";
@@ -412,11 +412,11 @@ declare function createMockReply(): unknown;
412
412
  */
413
413
  declare function createMockController(repository: StandardRepo<AnyRecord>): {
414
414
  repository: StandardRepo<AnyRecord>;
415
- list: Mock<(...args: any[]) => any>;
416
- get: Mock<(...args: any[]) => any>;
417
- create: Mock<(...args: any[]) => any>;
418
- update: Mock<(...args: any[]) => any>;
419
- delete: Mock<(...args: any[]) => any>;
415
+ list: Mock<import("@vitest/spy").Procedure>;
416
+ get: Mock<import("@vitest/spy").Procedure>;
417
+ create: Mock<import("@vitest/spy").Procedure>;
418
+ update: Mock<import("@vitest/spy").Procedure>;
419
+ delete: Mock<import("@vitest/spy").Procedure>;
420
420
  };
421
421
  /**
422
422
  * Create mock data factory
@@ -1,5 +1,5 @@
1
- import { t as CRUD_OPERATIONS } from "../constants-TrJVIJl0.mjs";
2
- import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-B-j-iqo-.mjs";
1
+ import { t as CRUD_OPERATIONS } from "../constants-gaEeMlz-.mjs";
2
+ import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-CHw3_oA_.mjs";
3
3
  import { runStorageContract } from "./storageContract.mjs";
4
4
  import Fastify from "fastify";
5
5
  import { afterAll, describe, expect, it, vi } from "vitest";
@@ -1046,7 +1046,7 @@ function pickDefaultAuth(authMode, callerAuth) {
1046
1046
  };
1047
1047
  }
1048
1048
  async function createTestApp(options = {}) {
1049
- const { createApp } = await import("../createApp-J1iPXY9p.mjs").then((n) => n.r);
1049
+ const { createApp } = await import("../createApp--703hQE1.mjs").then((n) => n.r);
1050
1050
  const { resources = [], db = "in-memory", connectMongoose = false, authMode = "jwt", defaultOrgId, plugins, auth: callerAuth, ...appOptions } = options;
1051
1051
  let dbHandle;
1052
1052
  let dbUri;
@@ -1,4 +1,4 @@
1
- import { t as Storage } from "../storage-C5q8fuEt.mjs";
1
+ import { t as Storage } from "../storage-Co_PQpeQ.mjs";
2
2
 
3
3
  //#region src/testing/storageContract.d.ts
4
4
  interface StorageContractSetupResult {
@@ -1,5 +1,5 @@
1
- import { $ as OnTenantDeleteConfig, A as RequestIdOptions, Bt as AuthHelpers, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, G as ActionsMap, Gt as TokenPair, H as ActionDefinition, Ht as Authenticator, I as MiddlewareHandler, J as CrudRouteKey, Jt as ArcRequest, K as ArcFieldRule, Kt as AnyRecord, L as RequestWithExtras, M as EventsDecorator, N as FastifyRequestExtras, O as HealthOptions, P as FastifyWithAuth, Pn as BaseControllerOptions, Q as MiddlewareConfig, Qt as UserOrganization, S as QueryParserInterface, T as CrudRouterOptions, U as ActionEntry, Ut as AuthenticatorContext, Vt as AuthPluginOptions, W as ActionHandlerFn, Wt as JwtContext, X as EventDefinition, Xt as ObjectId, Y as CrudSchemas, Yt as JWTPayload, Z as FieldRule, Zt as UserLike, _ as ControllerQueryOptions, _t as FastifyHandler, a as InferAdapterDoc, at as ResolvedTenantPurge, b as ParsedQuery, bt as IRequestContext, c as TypedController, ct as ResourceHookContext, d as PaginationResult, dt as RouteDefinition, et as OpenApiSchemas, f as IntrospectionData, ft as RouteMcpConfig, g as ArcInternalMetadata, gt as ControllerLike, h as ResourceMetadata, ht as ControllerHandler, i as ValidationResult, it as RateLimitConfig, j as ArcDecorator, k as IntrospectionPluginOptions, l as TypedRepository, lt as ResourceHooks, m as RegistryStats, mt as RouteSchemaOptions, n as ConfigError, nt as PresetHook, o as InferDocType, ot as ResourceCacheConfig, p as RegistryEntry, pt as RouteMethod, q as CrudController, qt as ApiResponse, r as ValidateOptions, rt as PresetResult, s as InferResourceDoc, st as ResourceConfig, t as RouteHandlerMethod, tt as PresetFunction, u as TypedResourceConfig, ut as ResourcePermissions, v as LookupOption, vt as IController, w as ServiceContext, x as PopulateOption, xt as RouteHandler, y as OwnershipCheck, yt as IControllerResponse } from "../index-QYma8mdC.mjs";
2
- import { i as RequestScope } from "../types-BJwJN2Pg.mjs";
3
- import { c as PermissionCheck, d as UserBase, l as PermissionContext, u as PermissionResult } from "../fields-CKLrhyOb.mjs";
4
- import { n as ElevationOptions, t as ElevationEvent } from "../elevation-DW90z5bT.mjs";
5
- export { ActionDefinition, ActionEntry, ActionHandlerFn, ActionsMap, AnyRecord, ApiResponse, ArcDecorator, ArcFieldRule, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRouteKey, CrudRouterOptions, CrudSchemas, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, ObjectId, OnTenantDeleteConfig, OpenApiSchemas, OwnershipCheck, PaginationResult, ParsedQuery, PermissionCheck, PermissionContext, PermissionResult, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryParserInterface, RateLimitConfig, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResolvedTenantPurge, ResourceCacheConfig, ResourceConfig, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, RouteDefinition, RouteHandler, RouteHandlerMethod, RouteMcpConfig, RouteMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult };
1
+ import { $ as OnTenantDeleteConfig, $t as UserOrganization, A as RequestIdOptions, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, Fn as BaseControllerOptions, G as ActionsMap, Gt as JwtContext, H as ActionDefinition, Ht as AuthPluginOptions, I as MiddlewareHandler, J as CrudRouteKey, Jt as ApiResponse, K as ArcFieldRule, Kt as TokenPair, L as RequestWithExtras, M as EventsDecorator, N as FastifyRequestExtras, O as HealthOptions, P as FastifyWithAuth, Q as MiddlewareConfig, Qt as UserLike, S as QueryParserInterface, St as RouteHandler, T as CrudRouterOptions, U as ActionEntry, Ut as Authenticator, Vt as AuthHelpers, W as ActionHandlerFn, Wt as AuthenticatorContext, X as EventDefinition, Xt as JWTPayload, Y as CrudSchemas, Yt as ArcRequest, Z as FieldRule, Zt as ObjectId, _ as ControllerQueryOptions, _t as ControllerLike, a as InferAdapterDoc, at as ResolvedTenantPurge, b as ParsedQuery, bt as IControllerResponse, c as TypedController, ct as ResourceExtensions, d as PaginationResult, dt as ResourcePermissions, et as OpenApiSchemas, f as IntrospectionData, ft as RouteDefinition, g as ArcInternalMetadata, gt as ControllerHandler, h as ResourceMetadata, ht as RouteSchemaOptions, i as ValidationResult, it as RateLimitConfig, j as ArcDecorator, k as IntrospectionPluginOptions, l as TypedRepository, lt as ResourceHookContext, m as RegistryStats, mt as RouteMethod, n as ConfigError, nt as PresetHook, o as InferDocType, ot as ResourceCacheConfig, p as RegistryEntry, pt as RouteMcpConfig, q as CrudController, qt as AnyRecord, r as ValidateOptions, rt as PresetResult, s as InferResourceDoc, st as ResourceConfig, t as RouteHandlerMethod, tt as PresetFunction, u as TypedResourceConfig, ut as ResourceHooks, v as LookupOption, vt as FastifyHandler, w as ServiceContext, x as PopulateOption, xt as IRequestContext, y as OwnershipCheck, yt as IController } from "../index-CUTG2Cuo.mjs";
2
+ import { i as RequestScope } from "../types-LNebCoJx.mjs";
3
+ import { c as PermissionCheck, d as UserBase, l as PermissionContext, u as PermissionResult } from "../fields-C7ahdGYf.mjs";
4
+ import { n as ElevationOptions, t as ElevationEvent } from "../elevation-xGUBq6p_.mjs";
5
+ export type { ActionDefinition, ActionEntry, ActionHandlerFn, ActionsMap, AnyRecord, ApiResponse, ArcDecorator, ArcFieldRule, ArcInternalMetadata, ArcRequest, AuthHelpers, AuthPluginOptions, Authenticator, AuthenticatorContext, BaseControllerOptions, ConfigError, ControllerHandler, ControllerLike, ControllerQueryOptions, CrudController, CrudRouteKey, CrudRouterOptions, CrudSchemas, ElevationEvent, ElevationOptions, EventDefinition, EventsDecorator, FastifyHandler, FastifyRequestExtras, FastifyWithAuth, FastifyWithDecorators, FieldRule, GracefulShutdownOptions, HealthCheck, HealthOptions, IController, IControllerResponse, IRequestContext, InferAdapterDoc, InferDocType, InferResourceDoc, IntrospectionData, IntrospectionPluginOptions, JWTPayload, JwtContext, LookupOption, MiddlewareConfig, MiddlewareHandler, ObjectId, OnTenantDeleteConfig, OpenApiSchemas, OwnershipCheck, PaginationResult, ParsedQuery, PermissionCheck, PermissionContext, PermissionResult, PopulateOption, PresetFunction, PresetHook, PresetResult, QueryParserInterface, RateLimitConfig, RegistryEntry, RegistryStats, RequestContext, RequestIdOptions, RequestScope, RequestWithExtras, ResolvedTenantPurge, ResourceCacheConfig, ResourceConfig, ResourceExtensions, ResourceHookContext, ResourceHooks, ResourceMetadata, ResourcePermissions, RouteDefinition, RouteHandler, RouteHandlerMethod, RouteMcpConfig, RouteMethod, RouteSchemaOptions, ServiceContext, TokenPair, TypedController, TypedRepository, TypedResourceConfig, UserBase, UserLike, UserOrganization, ValidateOptions, ValidationResult };
@@ -1,2 +1,2 @@
1
- import { a as StorageReadResult, i as StorageReadRange, n as StorageContext, o as StorageUploadInput, r as StorageFile, t as Storage } from "../storage-C5q8fuEt.mjs";
1
+ import { a as StorageReadResult, i as StorageReadRange, n as StorageContext, o as StorageUploadInput, r as StorageFile, t as Storage } from "../storage-Co_PQpeQ.mjs";
2
2
  export { Storage, StorageContext, StorageFile, StorageReadRange, StorageReadResult, StorageUploadInput };
@@ -1,13 +1,13 @@
1
- import { Ht as Authenticator } from "./index-QYma8mdC.mjs";
2
- import { r as CacheStore } from "./interface-DL7LlWS5.mjs";
3
- import { n as ElevationOptions } from "./elevation-DW90z5bT.mjs";
4
- import { a as EventTransport } from "./EventTransport-CaaXM5Y1.mjs";
5
- import { t as ExternalOpenApiPaths } from "./externalPaths-DLle0R07.mjs";
6
- import { r as QueryCachePluginOptions } from "./queryCachePlugin-Bd2tYgh5.mjs";
7
- import { t as EventPluginOptions } from "./eventPlugin-C1W1CRbf.mjs";
8
- import { _ as HealthOptions, f as CachingOptions, l as SSEOptions, o as MetricsOptions, t as VersioningOptions } from "./versioning-BSEDGXKC.mjs";
9
- import { t as ErrorHandlerOptions } from "./errorHandler-_Lp2k9M3.mjs";
10
- import { r as IdempotencyStore } from "./interface-CsrGR8LF.mjs";
1
+ import { Ut as Authenticator } from "./index-CUTG2Cuo.mjs";
2
+ import { r as CacheStore } from "./interface-C1_WLTMK.mjs";
3
+ import { n as ElevationOptions } from "./elevation-xGUBq6p_.mjs";
4
+ import { a as EventTransport } from "./EventTransport-IEn7Tn-Q.mjs";
5
+ import { t as ExternalOpenApiPaths } from "./externalPaths-BE6wFpYv.mjs";
6
+ import { r as QueryCachePluginOptions } from "./queryCachePlugin-xzFyKAjT.mjs";
7
+ import { t as EventPluginOptions } from "./eventPlugin-DbBFd3x_.mjs";
8
+ import { _ as HealthOptions, f as CachingOptions, l as SSEOptions, o as MetricsOptions, t as VersioningOptions } from "./versioning-D_eBCfNr.mjs";
9
+ import { t as ErrorHandlerOptions } from "./errorHandler-BtUUDPEa.mjs";
10
+ import { r as IdempotencyStore } from "./interface-Uk8ONJv7.mjs";
11
11
  import { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, FastifyServerOptions } from "fastify";
12
12
 
13
13
  //#region src/factory/loadResources.d.ts
@@ -1,4 +1,4 @@
1
- import { V as ResourceDefinition } from "./index-QYma8mdC.mjs";
1
+ import { V as ResourceDefinition } from "./index-CUTG2Cuo.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/integrations/mcp/types.d.ts
@@ -1,4 +1,4 @@
1
- import { l as UnauthorizedError, o as OrgRequiredError } from "./errors-j4aJm1Wg.mjs";
1
+ import { l as UnauthorizedError, o as OrgRequiredError } from "./errors-DkO8Nk6-.mjs";
2
2
  //#region src/scope/types.ts
3
3
  /**
4
4
  * Request Scope — The One Standard
@@ -1,6 +1,6 @@
1
- import { Kt as AnyRecord, S as QueryParserInterface, Zt as UserLike, b as ParsedQuery, et as OpenApiSchemas, st as ResourceConfig } from "../index-QYma8mdC.mjs";
2
- import { n as ErrorMapper } from "../errorHandler-_Lp2k9M3.mjs";
3
- import { a as NotFoundError, c as RateLimitError, d as ValidationError, f as createDomainError, i as ForbiddenError, l as ServiceUnavailableError, m as isArcError, n as ConflictError, o as OrgAccessDeniedError, p as createError, r as ErrorOptions, s as OrgRequiredError, t as ArcError, u as UnauthorizedError } from "../errors-DZOemeGa.mjs";
1
+ import { Qt as UserLike, S as QueryParserInterface, b as ParsedQuery, et as OpenApiSchemas, qt as AnyRecord, st as ResourceConfig } from "../index-CUTG2Cuo.mjs";
2
+ import { n as ErrorMapper } from "../errorHandler-BtUUDPEa.mjs";
3
+ import { a as NotFoundError, c as RateLimitError, d as ValidationError, f as createDomainError, i as ForbiddenError, l as ServiceUnavailableError, m as isArcError, n as ConflictError, o as OrgAccessDeniedError, p as createError, r as ErrorOptions, s as OrgRequiredError, t as ArcError, u as UnauthorizedError } from "../errors-DOHkjQlD.mjs";
4
4
  import { errorContractSchema, errorDetailSchema } from "@classytic/repo-core/errors";
5
5
  import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
6
6
 
@@ -1321,6 +1321,44 @@ interface PipeUIMessageStreamOptions {
1321
1321
  * ```
1322
1322
  */
1323
1323
  declare function pipeUIMessageStreamToReply(reply: FastifyReply, stream: ReadableStream<unknown>, options?: PipeUIMessageStreamOptions): Promise<void>;
1324
+ /**
1325
+ * Promote a stream auth token from the query string into the `Authorization`
1326
+ * header, in place, so the standard `fastify.authenticate` decorator can read it.
1327
+ *
1328
+ * Why: the browser `EventSource` (and `WebSocket`) API **cannot set request
1329
+ * headers** — there is no header channel on the constructor. So arc-next's
1330
+ * `buildStreamUrl` (bearer mode) appends the token as `?token=<jwt>` on stream
1331
+ * URLs. Server auth reads the `Authorization` header, so without this promotion
1332
+ * EVERY browser SSE/WS stream is 401 in bearer mode (cookie mode is unaffected —
1333
+ * arc-next omits the query token there and relies on the cookie).
1334
+ *
1335
+ * Safe by construction:
1336
+ * - No-op when an `Authorization` header is already present → normal `fetch`
1337
+ * requests (which send the header) are never touched.
1338
+ * - The token still goes through full authentication downstream, so a forged or
1339
+ * stale value simply 401s. This only relocates WHERE the bearer is read from;
1340
+ * it grants no trust on its own.
1341
+ *
1342
+ * Parsed from `request.raw.url` (not `request.query`) so it's robust to route
1343
+ * querystring schemas that would otherwise strip an undeclared `token` param.
1344
+ *
1345
+ * @param queryParam name of the query parameter carrying the token (default `token`).
1346
+ */
1347
+ declare function promoteStreamTokenToHeader(request: FastifyRequest, queryParam?: string): void;
1348
+ /**
1349
+ * Collect the CORS / `Vary` headers a plugin (e.g. `@fastify/cors`, whose default
1350
+ * `onRequest` hook runs BEFORE the route handler) has already set on the reply, so
1351
+ * a hijacked SSE handler that writes straight to `reply.raw.writeHead(...)` can
1352
+ * merge them onto the raw response.
1353
+ *
1354
+ * Why: `reply.hijack()` + `reply.raw.writeHead()` bypass Fastify's `onSend`
1355
+ * serialization, which is where reply-level headers reach the wire. A cross-origin
1356
+ * `EventSource` therefore receives no `Access-Control-Allow-Origin` and the browser
1357
+ * blocks the (authenticated) stream. Re-emitting the already-computed CORS headers
1358
+ * honors the host's configured policy (origin allowlist, credentials) rather than
1359
+ * re-deriving it. Returns lowercased header names suitable for `writeHead`.
1360
+ */
1361
+ declare function forwardedStreamHeaders(reply: FastifyReply): Record<string, string>;
1324
1362
  /**
1325
1363
  * Heuristic — does this value look like a Web `ReadableStream`?
1326
1364
  *
@@ -1361,4 +1399,4 @@ declare function hasEvents(instance: FastifyInstance): instance is FastifyInstan
1361
1399
  */
1362
1400
  declare function getUserId(user: UserLike | null | undefined): string | undefined;
1363
1401
  //#endregion
1364
- export { ArcError, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type CompensationDefinition, type CompensationError, type CompensationHooks, type CompensationResult, type CompensationStep, type ConfigError, ConflictError, type ErrorOptions, type EventsDecorator, ForbiddenError, type Guard, type GuardConfig, type JsonSchema, type JsonSchemaTarget, NotFoundError, OrgAccessDeniedError, OrgRequiredError, type PipeUIMessageStreamOptions, RateLimitError, ServiceUnavailableError, type StateMachine, type TransitionConfig, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, type ValidateOptions, ValidationError, type ValidationResult, aggregateListResponse, assertValidConfig, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, formatValidationErrors, getDefaultCrudSchemas, getListQueryParams, getUserId, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, offsetListResponse, paginationSchema, pipeUIMessageStreamToReply, queryParams, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, validateResourceConfig, withCompensation };
1402
+ export { ArcError, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type CompensationDefinition, type CompensationError, type CompensationHooks, type CompensationResult, type CompensationStep, type ConfigError, ConflictError, type ErrorOptions, type EventsDecorator, ForbiddenError, type Guard, type GuardConfig, type JsonSchema, type JsonSchemaTarget, NotFoundError, OrgAccessDeniedError, OrgRequiredError, type PipeUIMessageStreamOptions, RateLimitError, ServiceUnavailableError, type StateMachine, type TransitionConfig, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, type ValidateOptions, ValidationError, type ValidationResult, aggregateListResponse, assertValidConfig, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, formatValidationErrors, forwardedStreamHeaders, getDefaultCrudSchemas, getListQueryParams, getUserId, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, offsetListResponse, paginationSchema, pipeUIMessageStreamToReply, promoteStreamTokenToHeader, queryParams, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, validateResourceConfig, withCompensation };
@@ -1,5 +1,6 @@
1
- import { a as OrgAccessDeniedError, c as ServiceUnavailableError, d as createDomainError, f as createError, i as NotFoundError, l as UnauthorizedError, n as ConflictError, o as OrgRequiredError, p as isArcError, r as ForbiddenError, s as RateLimitError, t as ArcError, u as ValidationError } from "../errors-j4aJm1Wg.mjs";
2
- import { A as CircuitState, C as defineGuard, D as CircuitBreaker, E as withCompensation, F as validateResourceConfig, I as simpleEqualityMatcher, M as createCircuitBreakerRegistry, N as assertValidConfig, O as CircuitBreakerError, P as formatValidationErrors, S as handleRaw, T as defineCompensation, _ as paginationSchema, a as createStateMachine, b as ArcQueryParser, c as bareListResponse, d as errorDetailSchema, f as getDefaultCrudSchemas, g as offsetListResponse, h as listResponse, i as pipeUIMessageStreamToReply, j as createCircuitBreaker, k as CircuitBreakerRegistry, l as deleteResponse, m as keysetListResponse, n as UI_MESSAGE_STREAM_HEADERS, o as scheduleBackground, p as getListQueryParams, r as isReadableStream, s as aggregateListResponse, t as getUserId, u as errorContractSchema, v as queryParams, w as defineErrorMapper, x as createQueryParser, y as responses } from "../utils-xAQeDyU_.mjs";
3
- import { a as toJsonSchema, i as isZodSchema, n as convertRouteSchema, r as isJsonSchema, t as convertOpenApiSchemas } from "../schemaConverter-DatAaVNj.mjs";
4
- import { t as hasEvents } from "../typeGuards-CcFZXgU7.mjs";
5
- export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse, assertValidConfig, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, formatValidationErrors, getDefaultCrudSchemas, getListQueryParams, getUserId, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, offsetListResponse, paginationSchema, pipeUIMessageStreamToReply, queryParams, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, validateResourceConfig, withCompensation };
1
+ import { a as OrgAccessDeniedError, c as ServiceUnavailableError, d as createDomainError, f as createError, i as NotFoundError, l as UnauthorizedError, n as ConflictError, o as OrgRequiredError, p as isArcError, r as ForbiddenError, s as RateLimitError, t as ArcError, u as ValidationError } from "../errors-DkO8Nk6-.mjs";
2
+ import { A as createQueryParser, C as keysetListResponse, D as queryParams, E as paginationSchema, M as scheduleBackground, N as simpleEqualityMatcher, O as responses, S as getListQueryParams, T as offsetListResponse, _ as bareListResponse, a as defineCompensation, b as errorDetailSchema, c as CircuitBreakerError, d as createCircuitBreaker, f as createCircuitBreakerRegistry, g as aggregateListResponse, h as validateResourceConfig, i as defineErrorMapper, j as getUserId, k as ArcQueryParser, l as CircuitBreakerRegistry, m as formatValidationErrors, n as handleRaw, o as withCompensation, p as assertValidConfig, r as defineGuard, s as CircuitBreaker, t as createStateMachine, u as CircuitState, v as deleteResponse, w as listResponse, x as getDefaultCrudSchemas, y as errorContractSchema } from "../utils-C6QQ9-hd.mjs";
3
+ import { a as toJsonSchema, i as isZodSchema, n as convertRouteSchema, r as isJsonSchema, t as convertOpenApiSchemas } from "../schemaConverter-U0MnO9vd.mjs";
4
+ import { a as promoteStreamTokenToHeader, i as pipeUIMessageStreamToReply, n as forwardedStreamHeaders, r as isReadableStream, t as UI_MESSAGE_STREAM_HEADERS } from "../streaming-BQcW6_Kq.mjs";
5
+ import { t as hasEvents } from "../typeGuards-C9KXUly6.mjs";
6
+ export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse, assertValidConfig, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, formatValidationErrors, forwardedStreamHeaders, getDefaultCrudSchemas, getListQueryParams, getUserId, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, offsetListResponse, paginationSchema, pipeUIMessageStreamToReply, promoteStreamTokenToHeader, queryParams, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, validateResourceConfig, withCompensation };