mavenagi 0.0.0-alpha.11 → 0.0.0-alpha.14

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 (289) hide show
  1. package/Client.d.ts +9 -0
  2. package/README.md +49 -5
  3. package/api/resources/actions/client/Client.d.ts +9 -0
  4. package/api/resources/actions/client/Client.js +18 -15
  5. package/api/resources/commons/types/AppUser.d.ts +3 -2
  6. package/api/resources/commons/types/AppUserIdentifier.d.ts +1 -1
  7. package/api/resources/commons/types/AppUserRequest.d.ts +19 -1
  8. package/api/resources/commons/types/AppUserResponse.d.ts +34 -2
  9. package/api/resources/commons/types/EntityType.d.ts +2 -1
  10. package/api/resources/commons/types/EntityType.js +1 -0
  11. package/api/resources/commons/types/Feedback.d.ts +4 -8
  12. package/api/resources/commons/types/FeedbackBase.d.ts +10 -0
  13. package/api/resources/commons/types/UserData.d.ts +1 -1
  14. package/api/resources/commons/types/index.d.ts +4 -2
  15. package/api/resources/commons/types/index.js +4 -2
  16. package/api/resources/conversation/client/Client.d.ts +39 -22
  17. package/api/resources/conversation/client/Client.js +97 -77
  18. package/api/resources/conversation/types/AskRequest.d.ts +2 -4
  19. package/api/resources/conversation/types/ConversationBase.d.ts +12 -0
  20. package/api/resources/conversation/types/ConversationMessageBase.d.ts +4 -3
  21. package/api/resources/conversation/types/ConversationRequest.d.ts +0 -2
  22. package/api/resources/conversation/types/ConversationResponse.d.ts +0 -2
  23. package/api/resources/conversation/types/FeedbackRequest.d.ts +8 -1
  24. package/api/resources/conversation/types/SubmitActionFormRequest.d.ts +1 -3
  25. package/api/resources/conversation/types/UserMessageBase.d.ts +2 -0
  26. package/api/resources/conversation/types/index.d.ts +0 -2
  27. package/api/resources/conversation/types/index.js +0 -2
  28. package/api/resources/knowledge/client/Client.d.ts +9 -0
  29. package/api/resources/knowledge/client/Client.js +44 -37
  30. package/api/resources/triggers/client/Client.d.ts +9 -0
  31. package/api/resources/triggers/client/Client.js +18 -15
  32. package/api/resources/triggers/types/index.d.ts +0 -3
  33. package/api/resources/triggers/types/index.js +0 -3
  34. package/api/resources/users/client/Client.d.ts +27 -14
  35. package/api/resources/users/client/Client.js +32 -26
  36. package/core/fetcher/Fetcher.d.ts +4 -1
  37. package/core/fetcher/Fetcher.js +18 -159
  38. package/core/fetcher/createRequestUrl.d.ts +1 -0
  39. package/core/fetcher/createRequestUrl.js +6 -0
  40. package/core/fetcher/getFetchFn.d.ts +4 -0
  41. package/core/fetcher/getFetchFn.js +32 -0
  42. package/core/fetcher/getRequestBody.d.ts +7 -0
  43. package/core/fetcher/getRequestBody.js +19 -0
  44. package/core/fetcher/getResponseBody.d.ts +1 -0
  45. package/core/fetcher/getResponseBody.js +48 -0
  46. package/core/fetcher/makeRequest.d.ts +1 -0
  47. package/core/fetcher/makeRequest.js +38 -0
  48. package/core/fetcher/requestWithRetries.d.ts +1 -0
  49. package/core/fetcher/requestWithRetries.js +28 -0
  50. package/core/fetcher/signals.d.ts +12 -0
  51. package/core/fetcher/signals.js +32 -0
  52. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  53. package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +222 -0
  54. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
  55. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +104 -0
  56. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +30 -0
  57. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +204 -0
  58. package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +17 -0
  59. package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +23 -0
  60. package/core/runtime/runtime.d.ts +1 -0
  61. package/core/runtime/runtime.js +1 -0
  62. package/core/schemas/Schema.d.ts +7 -4
  63. package/core/schemas/builders/lazy/lazy.d.ts +2 -2
  64. package/core/schemas/builders/lazy/lazy.js +8 -19
  65. package/core/schemas/builders/lazy/lazyObject.js +1 -10
  66. package/core/schemas/builders/list/list.js +31 -44
  67. package/core/schemas/builders/object/object.js +90 -111
  68. package/core/schemas/builders/object/types.d.ts +2 -2
  69. package/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
  70. package/core/schemas/builders/record/record.js +49 -60
  71. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
  72. package/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
  73. package/core/schemas/builders/set/set.js +6 -15
  74. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
  75. package/core/schemas/builders/union/union.js +51 -62
  76. package/core/schemas/utils/maybeSkipValidation.js +3 -12
  77. package/dist/Client.d.ts +9 -0
  78. package/dist/api/resources/actions/client/Client.d.ts +9 -0
  79. package/dist/api/resources/actions/client/Client.js +18 -15
  80. package/dist/api/resources/commons/types/AppUser.d.ts +3 -2
  81. package/dist/api/resources/commons/types/AppUserIdentifier.d.ts +1 -1
  82. package/dist/api/resources/commons/types/AppUserRequest.d.ts +19 -1
  83. package/dist/api/resources/commons/types/AppUserResponse.d.ts +34 -2
  84. package/dist/api/resources/commons/types/EntityType.d.ts +2 -1
  85. package/dist/api/resources/commons/types/EntityType.js +1 -0
  86. package/dist/api/resources/commons/types/Feedback.d.ts +4 -8
  87. package/dist/api/resources/commons/types/FeedbackBase.d.ts +10 -0
  88. package/dist/api/resources/commons/types/UserData.d.ts +1 -1
  89. package/dist/api/resources/commons/types/index.d.ts +4 -2
  90. package/dist/api/resources/commons/types/index.js +4 -2
  91. package/dist/api/resources/conversation/client/Client.d.ts +39 -22
  92. package/dist/api/resources/conversation/client/Client.js +97 -77
  93. package/dist/api/resources/conversation/types/AskRequest.d.ts +2 -4
  94. package/dist/api/resources/conversation/types/ConversationBase.d.ts +12 -0
  95. package/dist/api/resources/conversation/types/ConversationMessageBase.d.ts +4 -3
  96. package/dist/api/resources/conversation/types/ConversationRequest.d.ts +0 -2
  97. package/dist/api/resources/conversation/types/ConversationResponse.d.ts +0 -2
  98. package/dist/api/resources/conversation/types/FeedbackRequest.d.ts +8 -1
  99. package/dist/api/resources/conversation/types/SubmitActionFormRequest.d.ts +1 -3
  100. package/dist/api/resources/conversation/types/UserMessageBase.d.ts +2 -0
  101. package/dist/api/resources/conversation/types/index.d.ts +0 -2
  102. package/dist/api/resources/conversation/types/index.js +0 -2
  103. package/dist/api/resources/knowledge/client/Client.d.ts +9 -0
  104. package/dist/api/resources/knowledge/client/Client.js +44 -37
  105. package/dist/api/resources/triggers/client/Client.d.ts +9 -0
  106. package/dist/api/resources/triggers/client/Client.js +18 -15
  107. package/dist/api/resources/triggers/types/index.d.ts +0 -3
  108. package/dist/api/resources/triggers/types/index.js +0 -3
  109. package/dist/api/resources/users/client/Client.d.ts +27 -14
  110. package/dist/api/resources/users/client/Client.js +32 -26
  111. package/dist/core/fetcher/Fetcher.d.ts +4 -1
  112. package/dist/core/fetcher/Fetcher.js +18 -159
  113. package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
  114. package/dist/core/fetcher/createRequestUrl.js +6 -0
  115. package/dist/core/fetcher/getFetchFn.d.ts +4 -0
  116. package/dist/core/fetcher/getFetchFn.js +32 -0
  117. package/dist/core/fetcher/getRequestBody.d.ts +7 -0
  118. package/dist/core/fetcher/getRequestBody.js +19 -0
  119. package/dist/core/fetcher/getResponseBody.d.ts +1 -0
  120. package/dist/core/fetcher/getResponseBody.js +48 -0
  121. package/dist/core/fetcher/makeRequest.d.ts +1 -0
  122. package/dist/core/fetcher/makeRequest.js +38 -0
  123. package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
  124. package/dist/core/fetcher/requestWithRetries.js +28 -0
  125. package/dist/core/fetcher/signals.d.ts +12 -0
  126. package/dist/core/fetcher/signals.js +32 -0
  127. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  128. package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +222 -0
  129. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
  130. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +104 -0
  131. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +30 -0
  132. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +204 -0
  133. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +17 -0
  134. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +23 -0
  135. package/dist/core/runtime/runtime.d.ts +1 -0
  136. package/dist/core/runtime/runtime.js +1 -0
  137. package/dist/core/schemas/Schema.d.ts +7 -4
  138. package/dist/core/schemas/builders/lazy/lazy.d.ts +2 -2
  139. package/dist/core/schemas/builders/lazy/lazy.js +8 -19
  140. package/dist/core/schemas/builders/lazy/lazyObject.js +1 -10
  141. package/dist/core/schemas/builders/list/list.js +31 -44
  142. package/dist/core/schemas/builders/object/object.js +90 -111
  143. package/dist/core/schemas/builders/object/types.d.ts +2 -2
  144. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
  145. package/dist/core/schemas/builders/record/record.js +49 -60
  146. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
  147. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
  148. package/dist/core/schemas/builders/set/set.js +6 -15
  149. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
  150. package/dist/core/schemas/builders/union/union.js +51 -62
  151. package/dist/core/schemas/utils/maybeSkipValidation.js +3 -12
  152. package/dist/serialization/resources/commons/types/AppUser.d.ts +3 -3
  153. package/dist/serialization/resources/commons/types/AppUser.js +3 -3
  154. package/dist/serialization/resources/commons/types/AppUserIdentifier.d.ts +1 -1
  155. package/dist/serialization/resources/commons/types/AppUserIdentifier.js +1 -1
  156. package/dist/serialization/resources/commons/types/AppUserRequest.d.ts +1 -1
  157. package/dist/serialization/resources/commons/types/AppUserRequest.js +1 -1
  158. package/dist/serialization/resources/commons/types/AppUserResponse.d.ts +2 -1
  159. package/dist/serialization/resources/commons/types/AppUserResponse.js +2 -1
  160. package/dist/serialization/resources/commons/types/EntityType.d.ts +1 -1
  161. package/dist/serialization/resources/commons/types/EntityType.js +1 -0
  162. package/{serialization/resources/triggers → dist/serialization/resources/commons}/types/EventTriggerResponse.d.ts +1 -1
  163. package/{serialization/resources/triggers → dist/serialization/resources/commons}/types/EventTriggerResponse.js +1 -1
  164. package/dist/serialization/resources/commons/types/Feedback.d.ts +6 -7
  165. package/dist/serialization/resources/commons/types/Feedback.js +9 -8
  166. package/dist/serialization/resources/commons/types/FeedbackBase.d.ts +14 -0
  167. package/dist/serialization/resources/commons/types/FeedbackBase.js +9 -0
  168. package/dist/serialization/resources/commons/types/UserData.d.ts +1 -1
  169. package/dist/serialization/resources/commons/types/UserData.js +1 -1
  170. package/dist/serialization/resources/commons/types/index.d.ts +4 -2
  171. package/dist/serialization/resources/commons/types/index.js +4 -2
  172. package/dist/serialization/resources/conversation/types/AskRequest.d.ts +1 -4
  173. package/dist/serialization/resources/conversation/types/AskRequest.js +1 -4
  174. package/dist/serialization/resources/conversation/types/ConversationBase.d.ts +6 -0
  175. package/dist/serialization/resources/conversation/types/ConversationBase.js +6 -0
  176. package/dist/serialization/resources/conversation/types/ConversationMessageBase.d.ts +2 -2
  177. package/dist/serialization/resources/conversation/types/ConversationMessageBase.js +2 -2
  178. package/dist/serialization/resources/conversation/types/ConversationRequest.d.ts +0 -2
  179. package/dist/serialization/resources/conversation/types/ConversationRequest.js +0 -2
  180. package/dist/serialization/resources/conversation/types/ConversationResponse.d.ts +0 -2
  181. package/dist/serialization/resources/conversation/types/ConversationResponse.js +0 -2
  182. package/dist/serialization/resources/conversation/types/FeedbackRequest.d.ts +7 -2
  183. package/dist/serialization/resources/conversation/types/FeedbackRequest.js +10 -2
  184. package/dist/serialization/resources/conversation/types/SubmitActionFormRequest.d.ts +0 -2
  185. package/dist/serialization/resources/conversation/types/SubmitActionFormRequest.js +0 -2
  186. package/dist/serialization/resources/conversation/types/UserMessageBase.d.ts +2 -0
  187. package/dist/serialization/resources/conversation/types/UserMessageBase.js +2 -0
  188. package/dist/serialization/resources/conversation/types/index.d.ts +0 -2
  189. package/dist/serialization/resources/conversation/types/index.js +0 -2
  190. package/dist/serialization/resources/triggers/types/EventTriggerRequest.d.ts +1 -1
  191. package/dist/serialization/resources/triggers/types/EventTriggerRequest.js +1 -1
  192. package/dist/serialization/resources/triggers/types/index.d.ts +0 -3
  193. package/dist/serialization/resources/triggers/types/index.js +0 -3
  194. package/package.json +7 -2
  195. package/reference.md +1732 -0
  196. package/serialization/resources/commons/types/AppUser.d.ts +3 -3
  197. package/serialization/resources/commons/types/AppUser.js +3 -3
  198. package/serialization/resources/commons/types/AppUserIdentifier.d.ts +1 -1
  199. package/serialization/resources/commons/types/AppUserIdentifier.js +1 -1
  200. package/serialization/resources/commons/types/AppUserRequest.d.ts +1 -1
  201. package/serialization/resources/commons/types/AppUserRequest.js +1 -1
  202. package/serialization/resources/commons/types/AppUserResponse.d.ts +2 -1
  203. package/serialization/resources/commons/types/AppUserResponse.js +2 -1
  204. package/serialization/resources/commons/types/EntityType.d.ts +1 -1
  205. package/serialization/resources/commons/types/EntityType.js +1 -0
  206. package/{dist/serialization/resources/triggers → serialization/resources/commons}/types/EventTriggerResponse.d.ts +1 -1
  207. package/{dist/serialization/resources/triggers → serialization/resources/commons}/types/EventTriggerResponse.js +1 -1
  208. package/serialization/resources/commons/types/Feedback.d.ts +6 -7
  209. package/serialization/resources/commons/types/Feedback.js +9 -8
  210. package/serialization/resources/commons/types/FeedbackBase.d.ts +14 -0
  211. package/serialization/resources/commons/types/FeedbackBase.js +9 -0
  212. package/serialization/resources/commons/types/UserData.d.ts +1 -1
  213. package/serialization/resources/commons/types/UserData.js +1 -1
  214. package/serialization/resources/commons/types/index.d.ts +4 -2
  215. package/serialization/resources/commons/types/index.js +4 -2
  216. package/serialization/resources/conversation/types/AskRequest.d.ts +1 -4
  217. package/serialization/resources/conversation/types/AskRequest.js +1 -4
  218. package/serialization/resources/conversation/types/ConversationBase.d.ts +6 -0
  219. package/serialization/resources/conversation/types/ConversationBase.js +6 -0
  220. package/serialization/resources/conversation/types/ConversationMessageBase.d.ts +2 -2
  221. package/serialization/resources/conversation/types/ConversationMessageBase.js +2 -2
  222. package/serialization/resources/conversation/types/ConversationRequest.d.ts +0 -2
  223. package/serialization/resources/conversation/types/ConversationRequest.js +0 -2
  224. package/serialization/resources/conversation/types/ConversationResponse.d.ts +0 -2
  225. package/serialization/resources/conversation/types/ConversationResponse.js +0 -2
  226. package/serialization/resources/conversation/types/FeedbackRequest.d.ts +7 -2
  227. package/serialization/resources/conversation/types/FeedbackRequest.js +10 -2
  228. package/serialization/resources/conversation/types/SubmitActionFormRequest.d.ts +0 -2
  229. package/serialization/resources/conversation/types/SubmitActionFormRequest.js +0 -2
  230. package/serialization/resources/conversation/types/UserMessageBase.d.ts +2 -0
  231. package/serialization/resources/conversation/types/UserMessageBase.js +2 -0
  232. package/serialization/resources/conversation/types/index.d.ts +0 -2
  233. package/serialization/resources/conversation/types/index.js +0 -2
  234. package/serialization/resources/triggers/types/EventTriggerRequest.d.ts +1 -1
  235. package/serialization/resources/triggers/types/EventTriggerRequest.js +1 -1
  236. package/serialization/resources/triggers/types/index.d.ts +0 -3
  237. package/serialization/resources/triggers/types/index.js +0 -3
  238. package/api/resources/commons/types/AppUserIdentification.d.ts +0 -8
  239. package/api/resources/commons/types/User.d.ts +0 -10
  240. package/api/resources/conversation/types/ConversationContext.d.ts +0 -20
  241. package/api/resources/conversation/types/ConversationContext.js +0 -4
  242. package/api/resources/conversation/types/ConversationMessageContext.d.ts +0 -12
  243. package/api/resources/conversation/types/ConversationMessageContext.js +0 -4
  244. package/dist/api/resources/commons/types/AppUserIdentification.d.ts +0 -8
  245. package/dist/api/resources/commons/types/AppUserIdentification.js +0 -4
  246. package/dist/api/resources/commons/types/User.d.ts +0 -10
  247. package/dist/api/resources/commons/types/User.js +0 -4
  248. package/dist/api/resources/conversation/types/ConversationContext.d.ts +0 -20
  249. package/dist/api/resources/conversation/types/ConversationContext.js +0 -4
  250. package/dist/api/resources/conversation/types/ConversationMessageContext.d.ts +0 -12
  251. package/dist/api/resources/conversation/types/ConversationMessageContext.js +0 -4
  252. package/dist/serialization/resources/commons/types/AppUserIdentification.d.ts +0 -13
  253. package/dist/serialization/resources/commons/types/AppUserIdentification.js +0 -8
  254. package/dist/serialization/resources/commons/types/User.d.ts +0 -15
  255. package/dist/serialization/resources/commons/types/User.js +0 -10
  256. package/dist/serialization/resources/conversation/types/ConversationContext.d.ts +0 -20
  257. package/dist/serialization/resources/conversation/types/ConversationContext.js +0 -15
  258. package/dist/serialization/resources/conversation/types/ConversationMessageContext.d.ts +0 -16
  259. package/dist/serialization/resources/conversation/types/ConversationMessageContext.js +0 -11
  260. package/serialization/resources/commons/types/AppUserIdentification.d.ts +0 -13
  261. package/serialization/resources/commons/types/AppUserIdentification.js +0 -8
  262. package/serialization/resources/commons/types/User.d.ts +0 -15
  263. package/serialization/resources/commons/types/User.js +0 -10
  264. package/serialization/resources/conversation/types/ConversationContext.d.ts +0 -20
  265. package/serialization/resources/conversation/types/ConversationContext.js +0 -15
  266. package/serialization/resources/conversation/types/ConversationMessageContext.d.ts +0 -16
  267. package/serialization/resources/conversation/types/ConversationMessageContext.js +0 -11
  268. /package/api/resources/{triggers → commons}/types/EventTriggerBase.d.ts +0 -0
  269. /package/api/resources/{triggers → commons}/types/EventTriggerBase.js +0 -0
  270. /package/api/resources/{triggers → commons}/types/EventTriggerResponse.d.ts +0 -0
  271. /package/api/resources/{triggers → commons}/types/EventTriggerResponse.js +0 -0
  272. /package/api/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
  273. /package/api/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
  274. /package/api/resources/commons/types/{AppUserIdentification.js → FeedbackBase.js} +0 -0
  275. /package/dist/api/resources/{triggers → commons}/types/EventTriggerBase.d.ts +0 -0
  276. /package/dist/api/resources/{triggers → commons}/types/EventTriggerBase.js +0 -0
  277. /package/dist/api/resources/{triggers → commons}/types/EventTriggerResponse.d.ts +0 -0
  278. /package/dist/api/resources/{triggers → commons}/types/EventTriggerResponse.js +0 -0
  279. /package/dist/api/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
  280. /package/dist/api/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
  281. /package/{api/resources/commons/types/User.js → dist/api/resources/commons/types/FeedbackBase.js} +0 -0
  282. /package/dist/serialization/resources/{triggers → commons}/types/EventTriggerBase.d.ts +0 -0
  283. /package/dist/serialization/resources/{triggers → commons}/types/EventTriggerBase.js +0 -0
  284. /package/dist/serialization/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
  285. /package/dist/serialization/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
  286. /package/serialization/resources/{triggers → commons}/types/EventTriggerBase.d.ts +0 -0
  287. /package/serialization/resources/{triggers → commons}/types/EventTriggerBase.js +0 -0
  288. /package/serialization/resources/{triggers → commons}/types/EventTriggerType.d.ts +0 -0
  289. /package/serialization/resources/{triggers → commons}/types/EventTriggerType.js +0 -0
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ import type { Writable } from "stream";
3
+ import { EventCallback, StreamWrapper } from "./chooseStreamWrapper";
4
+ export declare class Node18UniversalStreamWrapper implements StreamWrapper<Node18UniversalStreamWrapper | Writable | WritableStream<Uint8Array>, Uint8Array> {
5
+ private readableStream;
6
+ private reader;
7
+ private events;
8
+ private paused;
9
+ private resumeCallback;
10
+ private encoding;
11
+ constructor(readableStream: ReadableStream<Uint8Array>);
12
+ on(event: string, callback: EventCallback): void;
13
+ off(event: string, callback: EventCallback): void;
14
+ pipe(dest: Node18UniversalStreamWrapper | Writable | WritableStream<Uint8Array>): Node18UniversalStreamWrapper | Writable | WritableStream<Uint8Array>;
15
+ pipeTo(dest: Node18UniversalStreamWrapper | Writable | WritableStream<Uint8Array>): Node18UniversalStreamWrapper | Writable | WritableStream<Uint8Array>;
16
+ unpipe(dest: Node18UniversalStreamWrapper | Writable | WritableStream<Uint8Array>): void;
17
+ destroy(error?: Error): void;
18
+ pause(): void;
19
+ resume(): void;
20
+ get isPaused(): boolean;
21
+ read(): Promise<Uint8Array | undefined>;
22
+ setEncoding(encoding: string): void;
23
+ text(): Promise<string>;
24
+ json<T>(): Promise<T>;
25
+ private _write;
26
+ private _end;
27
+ private _error;
28
+ private _emit;
29
+ private _startReading;
30
+ }
@@ -0,0 +1,222 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export class Node18UniversalStreamWrapper {
11
+ constructor(readableStream) {
12
+ this.readableStream = readableStream;
13
+ this.reader = this.readableStream.getReader();
14
+ this.events = {
15
+ data: [],
16
+ end: [],
17
+ error: [],
18
+ readable: [],
19
+ close: [],
20
+ pause: [],
21
+ resume: [],
22
+ };
23
+ this.paused = false;
24
+ this.resumeCallback = null;
25
+ this.encoding = null;
26
+ }
27
+ on(event, callback) {
28
+ var _a;
29
+ (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(callback);
30
+ }
31
+ off(event, callback) {
32
+ var _a;
33
+ this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((cb) => cb !== callback);
34
+ }
35
+ pipe(dest) {
36
+ this.on("data", (chunk) => __awaiter(this, void 0, void 0, function* () {
37
+ if (dest instanceof Node18UniversalStreamWrapper) {
38
+ dest._write(chunk);
39
+ }
40
+ else if (dest instanceof WritableStream) {
41
+ const writer = dest.getWriter();
42
+ writer.write(chunk).then(() => writer.releaseLock());
43
+ }
44
+ else {
45
+ dest.write(chunk);
46
+ }
47
+ }));
48
+ this.on("end", () => __awaiter(this, void 0, void 0, function* () {
49
+ if (dest instanceof Node18UniversalStreamWrapper) {
50
+ dest._end();
51
+ }
52
+ else if (dest instanceof WritableStream) {
53
+ const writer = dest.getWriter();
54
+ writer.close();
55
+ }
56
+ else {
57
+ dest.end();
58
+ }
59
+ }));
60
+ this.on("error", (error) => __awaiter(this, void 0, void 0, function* () {
61
+ if (dest instanceof Node18UniversalStreamWrapper) {
62
+ dest._error(error);
63
+ }
64
+ else if (dest instanceof WritableStream) {
65
+ const writer = dest.getWriter();
66
+ writer.abort(error);
67
+ }
68
+ else {
69
+ dest.destroy(error);
70
+ }
71
+ }));
72
+ this._startReading();
73
+ return dest;
74
+ }
75
+ pipeTo(dest) {
76
+ return this.pipe(dest);
77
+ }
78
+ unpipe(dest) {
79
+ this.off("data", (chunk) => __awaiter(this, void 0, void 0, function* () {
80
+ if (dest instanceof Node18UniversalStreamWrapper) {
81
+ dest._write(chunk);
82
+ }
83
+ else if (dest instanceof WritableStream) {
84
+ const writer = dest.getWriter();
85
+ writer.write(chunk).then(() => writer.releaseLock());
86
+ }
87
+ else {
88
+ dest.write(chunk);
89
+ }
90
+ }));
91
+ this.off("end", () => __awaiter(this, void 0, void 0, function* () {
92
+ if (dest instanceof Node18UniversalStreamWrapper) {
93
+ dest._end();
94
+ }
95
+ else if (dest instanceof WritableStream) {
96
+ const writer = dest.getWriter();
97
+ writer.close();
98
+ }
99
+ else {
100
+ dest.end();
101
+ }
102
+ }));
103
+ this.off("error", (error) => __awaiter(this, void 0, void 0, function* () {
104
+ if (dest instanceof Node18UniversalStreamWrapper) {
105
+ dest._error(error);
106
+ }
107
+ else if (dest instanceof WritableStream) {
108
+ const writer = dest.getWriter();
109
+ writer.abort(error);
110
+ }
111
+ else {
112
+ dest.destroy(error);
113
+ }
114
+ }));
115
+ }
116
+ destroy(error) {
117
+ this.reader
118
+ .cancel(error)
119
+ .then(() => {
120
+ this._emit("close");
121
+ })
122
+ .catch((err) => {
123
+ this._emit("error", err);
124
+ });
125
+ }
126
+ pause() {
127
+ this.paused = true;
128
+ this._emit("pause");
129
+ }
130
+ resume() {
131
+ if (this.paused) {
132
+ this.paused = false;
133
+ this._emit("resume");
134
+ if (this.resumeCallback) {
135
+ this.resumeCallback();
136
+ this.resumeCallback = null;
137
+ }
138
+ }
139
+ }
140
+ get isPaused() {
141
+ return this.paused;
142
+ }
143
+ read() {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ if (this.paused) {
146
+ yield new Promise((resolve) => {
147
+ this.resumeCallback = resolve;
148
+ });
149
+ }
150
+ const { done, value } = yield this.reader.read();
151
+ if (done) {
152
+ return undefined;
153
+ }
154
+ return value;
155
+ });
156
+ }
157
+ setEncoding(encoding) {
158
+ this.encoding = encoding;
159
+ }
160
+ text() {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const chunks = [];
163
+ while (true) {
164
+ const { done, value } = yield this.reader.read();
165
+ if (done)
166
+ break;
167
+ if (value)
168
+ chunks.push(value);
169
+ }
170
+ const decoder = new TextDecoder(this.encoding || "utf-8");
171
+ return decoder.decode(yield new Blob(chunks).arrayBuffer());
172
+ });
173
+ }
174
+ json() {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ const text = yield this.text();
177
+ return JSON.parse(text);
178
+ });
179
+ }
180
+ _write(chunk) {
181
+ this._emit("data", chunk);
182
+ }
183
+ _end() {
184
+ this._emit("end");
185
+ }
186
+ _error(error) {
187
+ this._emit("error", error);
188
+ }
189
+ _emit(event, data) {
190
+ if (this.events[event]) {
191
+ for (const callback of this.events[event] || []) {
192
+ callback(data);
193
+ }
194
+ }
195
+ }
196
+ _startReading() {
197
+ return __awaiter(this, void 0, void 0, function* () {
198
+ try {
199
+ this._emit("readable");
200
+ while (true) {
201
+ if (this.paused) {
202
+ yield new Promise((resolve) => {
203
+ this.resumeCallback = resolve;
204
+ });
205
+ }
206
+ const { done, value } = yield this.reader.read();
207
+ if (done) {
208
+ this._emit("end");
209
+ this._emit("close");
210
+ break;
211
+ }
212
+ if (value) {
213
+ this._emit("data", value);
214
+ }
215
+ }
216
+ }
217
+ catch (error) {
218
+ this._emit("error", error);
219
+ }
220
+ });
221
+ }
222
+ }
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import type { Readable, Writable } from "stream";
3
+ import { EventCallback, StreamWrapper } from "./chooseStreamWrapper";
4
+ export declare class NodePre18StreamWrapper implements StreamWrapper<Writable, Buffer> {
5
+ private readableStream;
6
+ private encoding;
7
+ constructor(readableStream: Readable);
8
+ on(event: string, callback: EventCallback): void;
9
+ off(event: string, callback: EventCallback): void;
10
+ pipe(dest: Writable): Writable;
11
+ pipeTo(dest: Writable): Writable;
12
+ unpipe(dest?: Writable): void;
13
+ destroy(error?: Error): void;
14
+ pause(): void;
15
+ resume(): void;
16
+ get isPaused(): boolean;
17
+ read(): Promise<Buffer | undefined>;
18
+ setEncoding(encoding?: string): void;
19
+ text(): Promise<string>;
20
+ json<T>(): Promise<T>;
21
+ }
@@ -0,0 +1,104 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
11
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12
+ var m = o[Symbol.asyncIterator], i;
13
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
14
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
15
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
16
+ };
17
+ export class NodePre18StreamWrapper {
18
+ constructor(readableStream) {
19
+ this.readableStream = readableStream;
20
+ }
21
+ on(event, callback) {
22
+ this.readableStream.on(event, callback);
23
+ }
24
+ off(event, callback) {
25
+ this.readableStream.off(event, callback);
26
+ }
27
+ pipe(dest) {
28
+ this.readableStream.pipe(dest);
29
+ return dest;
30
+ }
31
+ pipeTo(dest) {
32
+ return this.pipe(dest);
33
+ }
34
+ unpipe(dest) {
35
+ if (dest) {
36
+ this.readableStream.unpipe(dest);
37
+ }
38
+ else {
39
+ this.readableStream.unpipe();
40
+ }
41
+ }
42
+ destroy(error) {
43
+ this.readableStream.destroy(error);
44
+ }
45
+ pause() {
46
+ this.readableStream.pause();
47
+ }
48
+ resume() {
49
+ this.readableStream.resume();
50
+ }
51
+ get isPaused() {
52
+ return this.readableStream.isPaused();
53
+ }
54
+ read() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ return new Promise((resolve, reject) => {
57
+ const chunk = this.readableStream.read();
58
+ if (chunk) {
59
+ resolve(chunk);
60
+ }
61
+ else {
62
+ this.readableStream.once("readable", () => {
63
+ const chunk = this.readableStream.read();
64
+ resolve(chunk);
65
+ });
66
+ this.readableStream.once("error", reject);
67
+ }
68
+ });
69
+ });
70
+ }
71
+ setEncoding(encoding) {
72
+ this.readableStream.setEncoding(encoding);
73
+ this.encoding = encoding;
74
+ }
75
+ text() {
76
+ var e_1, _a;
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const chunks = [];
79
+ const encoder = new TextEncoder();
80
+ this.readableStream.setEncoding((this.encoding || "utf-8"));
81
+ try {
82
+ for (var _b = __asyncValues(this.readableStream), _c; _c = yield _b.next(), !_c.done;) {
83
+ const chunk = _c.value;
84
+ chunks.push(encoder.encode(chunk));
85
+ }
86
+ }
87
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
88
+ finally {
89
+ try {
90
+ if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
91
+ }
92
+ finally { if (e_1) throw e_1.error; }
93
+ }
94
+ const decoder = new TextDecoder(this.encoding || "utf-8");
95
+ return decoder.decode(Buffer.concat(chunks));
96
+ });
97
+ }
98
+ json() {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const text = yield this.text();
101
+ return JSON.parse(text);
102
+ });
103
+ }
104
+ }
@@ -0,0 +1,30 @@
1
+ import { StreamWrapper } from "./chooseStreamWrapper";
2
+ declare type EventCallback = (data?: any) => void;
3
+ export declare class UndiciStreamWrapper<ReadFormat extends Uint8Array | Uint16Array | Uint32Array> implements StreamWrapper<UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>, ReadFormat> {
4
+ private readableStream;
5
+ private reader;
6
+ private events;
7
+ private paused;
8
+ private resumeCallback;
9
+ private encoding;
10
+ constructor(readableStream: ReadableStream<ReadFormat>);
11
+ on(event: string, callback: EventCallback): void;
12
+ off(event: string, callback: EventCallback): void;
13
+ pipe(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>): UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>;
14
+ pipeTo(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>): UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>;
15
+ unpipe(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<any>): void;
16
+ destroy(error?: Error): void;
17
+ pause(): void;
18
+ resume(): void;
19
+ get isPaused(): boolean;
20
+ read(): Promise<ReadFormat | undefined>;
21
+ setEncoding(encoding: string): void;
22
+ text(): Promise<string>;
23
+ json<T>(): Promise<T>;
24
+ private _write;
25
+ private _end;
26
+ private _error;
27
+ private _emit;
28
+ private _startReading;
29
+ }
30
+ export {};
@@ -0,0 +1,204 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export class UndiciStreamWrapper {
11
+ constructor(readableStream) {
12
+ this.readableStream = readableStream;
13
+ this.reader = this.readableStream.getReader();
14
+ this.events = {
15
+ data: [],
16
+ end: [],
17
+ error: [],
18
+ readable: [],
19
+ close: [],
20
+ pause: [],
21
+ resume: [],
22
+ };
23
+ this.paused = false;
24
+ this.resumeCallback = null;
25
+ this.encoding = null;
26
+ }
27
+ on(event, callback) {
28
+ var _a;
29
+ (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(callback);
30
+ }
31
+ off(event, callback) {
32
+ var _a;
33
+ this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((cb) => cb !== callback);
34
+ }
35
+ pipe(dest) {
36
+ this.on("data", (chunk) => {
37
+ if (dest instanceof UndiciStreamWrapper) {
38
+ dest._write(chunk);
39
+ }
40
+ else {
41
+ const writer = dest.getWriter();
42
+ writer.write(chunk).then(() => writer.releaseLock());
43
+ }
44
+ });
45
+ this.on("end", () => {
46
+ if (dest instanceof UndiciStreamWrapper) {
47
+ dest._end();
48
+ }
49
+ else {
50
+ const writer = dest.getWriter();
51
+ writer.close();
52
+ }
53
+ });
54
+ this.on("error", (error) => {
55
+ if (dest instanceof UndiciStreamWrapper) {
56
+ dest._error(error);
57
+ }
58
+ else {
59
+ const writer = dest.getWriter();
60
+ writer.abort(error);
61
+ }
62
+ });
63
+ this._startReading();
64
+ return dest;
65
+ }
66
+ pipeTo(dest) {
67
+ return this.pipe(dest);
68
+ }
69
+ unpipe(dest) {
70
+ this.off("data", (chunk) => {
71
+ if (dest instanceof UndiciStreamWrapper) {
72
+ dest._write(chunk);
73
+ }
74
+ else {
75
+ const writer = dest.getWriter();
76
+ writer.write(chunk).then(() => writer.releaseLock());
77
+ }
78
+ });
79
+ this.off("end", () => {
80
+ if (dest instanceof UndiciStreamWrapper) {
81
+ dest._end();
82
+ }
83
+ else {
84
+ const writer = dest.getWriter();
85
+ writer.close();
86
+ }
87
+ });
88
+ this.off("error", (error) => {
89
+ if (dest instanceof UndiciStreamWrapper) {
90
+ dest._error(error);
91
+ }
92
+ else {
93
+ const writer = dest.getWriter();
94
+ writer.abort(error);
95
+ }
96
+ });
97
+ }
98
+ destroy(error) {
99
+ this.reader
100
+ .cancel(error)
101
+ .then(() => {
102
+ this._emit("close");
103
+ })
104
+ .catch((err) => {
105
+ this._emit("error", err);
106
+ });
107
+ }
108
+ pause() {
109
+ this.paused = true;
110
+ this._emit("pause");
111
+ }
112
+ resume() {
113
+ if (this.paused) {
114
+ this.paused = false;
115
+ this._emit("resume");
116
+ if (this.resumeCallback) {
117
+ this.resumeCallback();
118
+ this.resumeCallback = null;
119
+ }
120
+ }
121
+ }
122
+ get isPaused() {
123
+ return this.paused;
124
+ }
125
+ read() {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ if (this.paused) {
128
+ yield new Promise((resolve) => {
129
+ this.resumeCallback = resolve;
130
+ });
131
+ }
132
+ const { done, value } = yield this.reader.read();
133
+ if (done) {
134
+ return undefined;
135
+ }
136
+ return value;
137
+ });
138
+ }
139
+ setEncoding(encoding) {
140
+ this.encoding = encoding;
141
+ }
142
+ text() {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ const chunks = [];
145
+ while (true) {
146
+ const { done, value } = yield this.reader.read();
147
+ if (done)
148
+ break;
149
+ if (value)
150
+ chunks.push(value);
151
+ }
152
+ const decoder = new TextDecoder(this.encoding || "utf-8");
153
+ return decoder.decode(yield new Blob(chunks).arrayBuffer());
154
+ });
155
+ }
156
+ json() {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const text = yield this.text();
159
+ return JSON.parse(text);
160
+ });
161
+ }
162
+ _write(chunk) {
163
+ this._emit("data", chunk);
164
+ }
165
+ _end() {
166
+ this._emit("end");
167
+ }
168
+ _error(error) {
169
+ this._emit("error", error);
170
+ }
171
+ _emit(event, data) {
172
+ if (this.events[event]) {
173
+ for (const callback of this.events[event] || []) {
174
+ callback(data);
175
+ }
176
+ }
177
+ }
178
+ _startReading() {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ try {
181
+ this._emit("readable");
182
+ while (true) {
183
+ if (this.paused) {
184
+ yield new Promise((resolve) => {
185
+ this.resumeCallback = resolve;
186
+ });
187
+ }
188
+ const { done, value } = yield this.reader.read();
189
+ if (done) {
190
+ this._emit("end");
191
+ this._emit("close");
192
+ break;
193
+ }
194
+ if (value) {
195
+ this._emit("data", value);
196
+ }
197
+ }
198
+ }
199
+ catch (error) {
200
+ this._emit("error", error);
201
+ }
202
+ });
203
+ }
204
+ }
@@ -0,0 +1,17 @@
1
+ export declare type EventCallback = (data?: any) => void;
2
+ export interface StreamWrapper<WritableStream, ReadFormat> {
3
+ setEncoding(encoding?: string): void;
4
+ on(event: string, callback: EventCallback): void;
5
+ off(event: string, callback: EventCallback): void;
6
+ pipe(dest: WritableStream): WritableStream;
7
+ pipeTo(dest: WritableStream): WritableStream;
8
+ unpipe(dest?: WritableStream): void;
9
+ destroy(error?: Error): void;
10
+ pause(): void;
11
+ resume(): void;
12
+ get isPaused(): boolean;
13
+ read(): Promise<ReadFormat | undefined>;
14
+ text(): Promise<string>;
15
+ json<T>(): Promise<T>;
16
+ }
17
+ export declare function chooseStreamWrapper(responseBody: any): Promise<Promise<StreamWrapper<any, any>>>;
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { RUNTIME } from "../../runtime";
11
+ export function chooseStreamWrapper(responseBody) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
14
+ return new (yield import("./Node18UniversalStreamWrapper")).Node18UniversalStreamWrapper(responseBody);
15
+ }
16
+ else if (RUNTIME.type !== "node" && typeof fetch == "function") {
17
+ return new (yield import("./UndiciStreamWrapper")).UndiciStreamWrapper(responseBody);
18
+ }
19
+ else {
20
+ return new (yield import("./NodePre18StreamWrapper")).NodePre18StreamWrapper(responseBody);
21
+ }
22
+ });
23
+ }
@@ -5,4 +5,5 @@ export declare const RUNTIME: Runtime;
5
5
  export interface Runtime {
6
6
  type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd";
7
7
  version?: string;
8
+ parsedVersion?: number;
8
9
  }
@@ -76,6 +76,7 @@ function evaluateRuntime() {
76
76
  return {
77
77
  type: "node",
78
78
  version: process.versions.node,
79
+ parsedVersion: Number(process.versions.node.split(".")[0]),
79
80
  };
80
81
  }
81
82
  if (isReactNative) {