@anthropic-ai/claude-code 0.2.29 → 0.2.31

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 (415) hide show
  1. package/cli.mjs +443 -692
  2. package/package.json +1 -5
  3. package/vendor/sdk/CHANGELOG.md +0 -1421
  4. package/vendor/sdk/LICENSE +0 -8
  5. package/vendor/sdk/README.md +0 -536
  6. package/vendor/sdk/_shims/MultipartBody.d.ts +0 -9
  7. package/vendor/sdk/_shims/MultipartBody.d.ts.map +0 -1
  8. package/vendor/sdk/_shims/MultipartBody.js +0 -16
  9. package/vendor/sdk/_shims/MultipartBody.js.map +0 -1
  10. package/vendor/sdk/_shims/MultipartBody.mjs +0 -12
  11. package/vendor/sdk/_shims/MultipartBody.mjs.map +0 -1
  12. package/vendor/sdk/_shims/README.md +0 -46
  13. package/vendor/sdk/_shims/auto/runtime-bun.d.ts +0 -5
  14. package/vendor/sdk/_shims/auto/runtime-bun.d.ts.map +0 -1
  15. package/vendor/sdk/_shims/auto/runtime-bun.js +0 -21
  16. package/vendor/sdk/_shims/auto/runtime-bun.js.map +0 -1
  17. package/vendor/sdk/_shims/auto/runtime-bun.mjs +0 -2
  18. package/vendor/sdk/_shims/auto/runtime-bun.mjs.map +0 -1
  19. package/vendor/sdk/_shims/auto/runtime-node.d.ts +0 -5
  20. package/vendor/sdk/_shims/auto/runtime-node.d.ts.map +0 -1
  21. package/vendor/sdk/_shims/auto/runtime-node.js +0 -21
  22. package/vendor/sdk/_shims/auto/runtime-node.js.map +0 -1
  23. package/vendor/sdk/_shims/auto/runtime-node.mjs +0 -2
  24. package/vendor/sdk/_shims/auto/runtime-node.mjs.map +0 -1
  25. package/vendor/sdk/_shims/auto/runtime.d.ts +0 -5
  26. package/vendor/sdk/_shims/auto/runtime.d.ts.map +0 -1
  27. package/vendor/sdk/_shims/auto/runtime.js +0 -21
  28. package/vendor/sdk/_shims/auto/runtime.js.map +0 -1
  29. package/vendor/sdk/_shims/auto/runtime.mjs +0 -2
  30. package/vendor/sdk/_shims/auto/runtime.mjs.map +0 -1
  31. package/vendor/sdk/_shims/auto/types-node.d.ts +0 -5
  32. package/vendor/sdk/_shims/auto/types-node.d.ts.map +0 -1
  33. package/vendor/sdk/_shims/auto/types-node.js +0 -21
  34. package/vendor/sdk/_shims/auto/types-node.js.map +0 -1
  35. package/vendor/sdk/_shims/auto/types-node.mjs +0 -2
  36. package/vendor/sdk/_shims/auto/types-node.mjs.map +0 -1
  37. package/vendor/sdk/_shims/auto/types.d.ts +0 -101
  38. package/vendor/sdk/_shims/auto/types.js +0 -3
  39. package/vendor/sdk/_shims/auto/types.mjs +0 -3
  40. package/vendor/sdk/_shims/bun-runtime.d.ts +0 -6
  41. package/vendor/sdk/_shims/bun-runtime.d.ts.map +0 -1
  42. package/vendor/sdk/_shims/bun-runtime.js +0 -14
  43. package/vendor/sdk/_shims/bun-runtime.js.map +0 -1
  44. package/vendor/sdk/_shims/bun-runtime.mjs +0 -10
  45. package/vendor/sdk/_shims/bun-runtime.mjs.map +0 -1
  46. package/vendor/sdk/_shims/index.d.ts +0 -81
  47. package/vendor/sdk/_shims/index.js +0 -13
  48. package/vendor/sdk/_shims/index.mjs +0 -7
  49. package/vendor/sdk/_shims/manual-types.d.ts +0 -12
  50. package/vendor/sdk/_shims/manual-types.js +0 -3
  51. package/vendor/sdk/_shims/manual-types.mjs +0 -3
  52. package/vendor/sdk/_shims/node-runtime.d.ts +0 -3
  53. package/vendor/sdk/_shims/node-runtime.d.ts.map +0 -1
  54. package/vendor/sdk/_shims/node-runtime.js +0 -89
  55. package/vendor/sdk/_shims/node-runtime.js.map +0 -1
  56. package/vendor/sdk/_shims/node-runtime.mjs +0 -56
  57. package/vendor/sdk/_shims/node-runtime.mjs.map +0 -1
  58. package/vendor/sdk/_shims/node-types.d.ts +0 -42
  59. package/vendor/sdk/_shims/node-types.js +0 -3
  60. package/vendor/sdk/_shims/node-types.mjs +0 -3
  61. package/vendor/sdk/_shims/registry.d.ts +0 -37
  62. package/vendor/sdk/_shims/registry.d.ts.map +0 -1
  63. package/vendor/sdk/_shims/registry.js +0 -41
  64. package/vendor/sdk/_shims/registry.js.map +0 -1
  65. package/vendor/sdk/_shims/registry.mjs +0 -37
  66. package/vendor/sdk/_shims/registry.mjs.map +0 -1
  67. package/vendor/sdk/_shims/web-runtime.d.ts +0 -5
  68. package/vendor/sdk/_shims/web-runtime.d.ts.map +0 -1
  69. package/vendor/sdk/_shims/web-runtime.js +0 -78
  70. package/vendor/sdk/_shims/web-runtime.js.map +0 -1
  71. package/vendor/sdk/_shims/web-runtime.mjs +0 -71
  72. package/vendor/sdk/_shims/web-runtime.mjs.map +0 -1
  73. package/vendor/sdk/_shims/web-types.d.ts +0 -83
  74. package/vendor/sdk/_shims/web-types.js +0 -3
  75. package/vendor/sdk/_shims/web-types.mjs +0 -3
  76. package/vendor/sdk/_vendor/partial-json-parser/parser.d.ts +0 -3
  77. package/vendor/sdk/_vendor/partial-json-parser/parser.d.ts.map +0 -1
  78. package/vendor/sdk/_vendor/partial-json-parser/parser.js +0 -226
  79. package/vendor/sdk/_vendor/partial-json-parser/parser.js.map +0 -1
  80. package/vendor/sdk/_vendor/partial-json-parser/parser.mjs +0 -223
  81. package/vendor/sdk/_vendor/partial-json-parser/parser.mjs.map +0 -1
  82. package/vendor/sdk/core.d.ts +0 -248
  83. package/vendor/sdk/core.d.ts.map +0 -1
  84. package/vendor/sdk/core.js +0 -935
  85. package/vendor/sdk/core.js.map +0 -1
  86. package/vendor/sdk/core.mjs +0 -903
  87. package/vendor/sdk/core.mjs.map +0 -1
  88. package/vendor/sdk/error.d.ts +0 -48
  89. package/vendor/sdk/error.d.ts.map +0 -1
  90. package/vendor/sdk/error.js +0 -114
  91. package/vendor/sdk/error.js.map +0 -1
  92. package/vendor/sdk/error.mjs +0 -98
  93. package/vendor/sdk/error.mjs.map +0 -1
  94. package/vendor/sdk/index.d.mts +0 -152
  95. package/vendor/sdk/index.d.ts +0 -152
  96. package/vendor/sdk/index.d.ts.map +0 -1
  97. package/vendor/sdk/index.js +0 -179
  98. package/vendor/sdk/index.js.map +0 -1
  99. package/vendor/sdk/index.mjs +0 -136
  100. package/vendor/sdk/index.mjs.map +0 -1
  101. package/vendor/sdk/internal/decoders/jsonl.d.ts +0 -12
  102. package/vendor/sdk/internal/decoders/jsonl.d.ts.map +0 -1
  103. package/vendor/sdk/internal/decoders/jsonl.js +0 -35
  104. package/vendor/sdk/internal/decoders/jsonl.js.map +0 -1
  105. package/vendor/sdk/internal/decoders/jsonl.mjs +0 -31
  106. package/vendor/sdk/internal/decoders/jsonl.mjs.map +0 -1
  107. package/vendor/sdk/internal/decoders/line.d.ts +0 -20
  108. package/vendor/sdk/internal/decoders/line.d.ts.map +0 -1
  109. package/vendor/sdk/internal/decoders/line.js +0 -123
  110. package/vendor/sdk/internal/decoders/line.js.map +0 -1
  111. package/vendor/sdk/internal/decoders/line.mjs +0 -119
  112. package/vendor/sdk/internal/decoders/line.mjs.map +0 -1
  113. package/vendor/sdk/internal/stream-utils.d.ts +0 -8
  114. package/vendor/sdk/internal/stream-utils.d.ts.map +0 -1
  115. package/vendor/sdk/internal/stream-utils.js +0 -39
  116. package/vendor/sdk/internal/stream-utils.js.map +0 -1
  117. package/vendor/sdk/internal/stream-utils.mjs +0 -35
  118. package/vendor/sdk/internal/stream-utils.mjs.map +0 -1
  119. package/vendor/sdk/lib/BetaMessageStream.d.ts +0 -114
  120. package/vendor/sdk/lib/BetaMessageStream.d.ts.map +0 -1
  121. package/vendor/sdk/lib/BetaMessageStream.js +0 -547
  122. package/vendor/sdk/lib/BetaMessageStream.js.map +0 -1
  123. package/vendor/sdk/lib/BetaMessageStream.mjs +0 -543
  124. package/vendor/sdk/lib/BetaMessageStream.mjs.map +0 -1
  125. package/vendor/sdk/lib/MessageStream.d.ts +0 -114
  126. package/vendor/sdk/lib/MessageStream.d.ts.map +0 -1
  127. package/vendor/sdk/lib/MessageStream.js +0 -547
  128. package/vendor/sdk/lib/MessageStream.js.map +0 -1
  129. package/vendor/sdk/lib/MessageStream.mjs +0 -543
  130. package/vendor/sdk/lib/MessageStream.mjs.map +0 -1
  131. package/vendor/sdk/node_modules/@types/node/LICENSE +0 -21
  132. package/vendor/sdk/node_modules/@types/node/README.md +0 -15
  133. package/vendor/sdk/node_modules/@types/node/assert/strict.d.ts +0 -8
  134. package/vendor/sdk/node_modules/@types/node/assert.d.ts +0 -985
  135. package/vendor/sdk/node_modules/@types/node/async_hooks.d.ts +0 -522
  136. package/vendor/sdk/node_modules/@types/node/buffer.buffer.d.ts +0 -385
  137. package/vendor/sdk/node_modules/@types/node/buffer.d.ts +0 -1903
  138. package/vendor/sdk/node_modules/@types/node/child_process.d.ts +0 -1549
  139. package/vendor/sdk/node_modules/@types/node/cluster.d.ts +0 -578
  140. package/vendor/sdk/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  141. package/vendor/sdk/node_modules/@types/node/compatibility/index.d.ts +0 -9
  142. package/vendor/sdk/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  143. package/vendor/sdk/node_modules/@types/node/compatibility/iterators.d.ts +0 -20
  144. package/vendor/sdk/node_modules/@types/node/console.d.ts +0 -452
  145. package/vendor/sdk/node_modules/@types/node/constants.d.ts +0 -19
  146. package/vendor/sdk/node_modules/@types/node/crypto.d.ts +0 -4453
  147. package/vendor/sdk/node_modules/@types/node/dgram.d.ts +0 -596
  148. package/vendor/sdk/node_modules/@types/node/diagnostics_channel.d.ts +0 -546
  149. package/vendor/sdk/node_modules/@types/node/dns/promises.d.ts +0 -475
  150. package/vendor/sdk/node_modules/@types/node/dns.d.ts +0 -853
  151. package/vendor/sdk/node_modules/@types/node/dom-events.d.ts +0 -124
  152. package/vendor/sdk/node_modules/@types/node/domain.d.ts +0 -170
  153. package/vendor/sdk/node_modules/@types/node/events.d.ts +0 -819
  154. package/vendor/sdk/node_modules/@types/node/fs/promises.d.ts +0 -1205
  155. package/vendor/sdk/node_modules/@types/node/fs.d.ts +0 -4237
  156. package/vendor/sdk/node_modules/@types/node/globals.d.ts +0 -442
  157. package/vendor/sdk/node_modules/@types/node/globals.typedarray.d.ts +0 -21
  158. package/vendor/sdk/node_modules/@types/node/http.d.ts +0 -1839
  159. package/vendor/sdk/node_modules/@types/node/http2.d.ts +0 -2517
  160. package/vendor/sdk/node_modules/@types/node/https.d.ts +0 -544
  161. package/vendor/sdk/node_modules/@types/node/index.d.ts +0 -90
  162. package/vendor/sdk/node_modules/@types/node/inspector.d.ts +0 -2775
  163. package/vendor/sdk/node_modules/@types/node/module.d.ts +0 -291
  164. package/vendor/sdk/node_modules/@types/node/net.d.ts +0 -924
  165. package/vendor/sdk/node_modules/@types/node/os.d.ts +0 -473
  166. package/vendor/sdk/node_modules/@types/node/package.json +0 -225
  167. package/vendor/sdk/node_modules/@types/node/path.d.ts +0 -191
  168. package/vendor/sdk/node_modules/@types/node/perf_hooks.d.ts +0 -753
  169. package/vendor/sdk/node_modules/@types/node/process.d.ts +0 -1553
  170. package/vendor/sdk/node_modules/@types/node/punycode.d.ts +0 -117
  171. package/vendor/sdk/node_modules/@types/node/querystring.d.ts +0 -141
  172. package/vendor/sdk/node_modules/@types/node/readline/promises.d.ts +0 -154
  173. package/vendor/sdk/node_modules/@types/node/readline.d.ts +0 -715
  174. package/vendor/sdk/node_modules/@types/node/repl.d.ts +0 -430
  175. package/vendor/sdk/node_modules/@types/node/stream/consumers.d.ts +0 -12
  176. package/vendor/sdk/node_modules/@types/node/stream/promises.d.ts +0 -90
  177. package/vendor/sdk/node_modules/@types/node/stream/web.d.ts +0 -523
  178. package/vendor/sdk/node_modules/@types/node/stream.d.ts +0 -1731
  179. package/vendor/sdk/node_modules/@types/node/string_decoder.d.ts +0 -67
  180. package/vendor/sdk/node_modules/@types/node/test.d.ts +0 -1245
  181. package/vendor/sdk/node_modules/@types/node/timers/promises.d.ts +0 -93
  182. package/vendor/sdk/node_modules/@types/node/timers.d.ts +0 -126
  183. package/vendor/sdk/node_modules/@types/node/tls.d.ts +0 -1203
  184. package/vendor/sdk/node_modules/@types/node/trace_events.d.ts +0 -171
  185. package/vendor/sdk/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -385
  186. package/vendor/sdk/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -19
  187. package/vendor/sdk/node_modules/@types/node/ts5.6/index.d.ts +0 -90
  188. package/vendor/sdk/node_modules/@types/node/tty.d.ts +0 -206
  189. package/vendor/sdk/node_modules/@types/node/url.d.ts +0 -957
  190. package/vendor/sdk/node_modules/@types/node/util.d.ts +0 -2083
  191. package/vendor/sdk/node_modules/@types/node/v8.d.ts +0 -753
  192. package/vendor/sdk/node_modules/@types/node/vm.d.ts +0 -666
  193. package/vendor/sdk/node_modules/@types/node/wasi.d.ts +0 -160
  194. package/vendor/sdk/node_modules/@types/node/worker_threads.d.ts +0 -695
  195. package/vendor/sdk/node_modules/@types/node/zlib.d.ts +0 -517
  196. package/vendor/sdk/node_modules/undici-types/README.md +0 -6
  197. package/vendor/sdk/node_modules/undici-types/agent.d.ts +0 -31
  198. package/vendor/sdk/node_modules/undici-types/api.d.ts +0 -43
  199. package/vendor/sdk/node_modules/undici-types/balanced-pool.d.ts +0 -18
  200. package/vendor/sdk/node_modules/undici-types/cache.d.ts +0 -36
  201. package/vendor/sdk/node_modules/undici-types/client.d.ts +0 -97
  202. package/vendor/sdk/node_modules/undici-types/connector.d.ts +0 -34
  203. package/vendor/sdk/node_modules/undici-types/content-type.d.ts +0 -21
  204. package/vendor/sdk/node_modules/undici-types/cookies.d.ts +0 -28
  205. package/vendor/sdk/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
  206. package/vendor/sdk/node_modules/undici-types/dispatcher.d.ts +0 -241
  207. package/vendor/sdk/node_modules/undici-types/errors.d.ts +0 -128
  208. package/vendor/sdk/node_modules/undici-types/fetch.d.ts +0 -209
  209. package/vendor/sdk/node_modules/undici-types/file.d.ts +0 -39
  210. package/vendor/sdk/node_modules/undici-types/filereader.d.ts +0 -54
  211. package/vendor/sdk/node_modules/undici-types/formdata.d.ts +0 -108
  212. package/vendor/sdk/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  213. package/vendor/sdk/node_modules/undici-types/global-origin.d.ts +0 -7
  214. package/vendor/sdk/node_modules/undici-types/handlers.d.ts +0 -9
  215. package/vendor/sdk/node_modules/undici-types/header.d.ts +0 -4
  216. package/vendor/sdk/node_modules/undici-types/index.d.ts +0 -63
  217. package/vendor/sdk/node_modules/undici-types/interceptors.d.ts +0 -5
  218. package/vendor/sdk/node_modules/undici-types/mock-agent.d.ts +0 -50
  219. package/vendor/sdk/node_modules/undici-types/mock-client.d.ts +0 -25
  220. package/vendor/sdk/node_modules/undici-types/mock-errors.d.ts +0 -12
  221. package/vendor/sdk/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  222. package/vendor/sdk/node_modules/undici-types/mock-pool.d.ts +0 -25
  223. package/vendor/sdk/node_modules/undici-types/package.json +0 -55
  224. package/vendor/sdk/node_modules/undici-types/patch.d.ts +0 -71
  225. package/vendor/sdk/node_modules/undici-types/pool-stats.d.ts +0 -19
  226. package/vendor/sdk/node_modules/undici-types/pool.d.ts +0 -28
  227. package/vendor/sdk/node_modules/undici-types/proxy-agent.d.ts +0 -30
  228. package/vendor/sdk/node_modules/undici-types/readable.d.ts +0 -61
  229. package/vendor/sdk/node_modules/undici-types/webidl.d.ts +0 -220
  230. package/vendor/sdk/node_modules/undici-types/websocket.d.ts +0 -131
  231. package/vendor/sdk/package.json +0 -124
  232. package/vendor/sdk/pagination.d.ts +0 -27
  233. package/vendor/sdk/pagination.d.ts.map +0 -1
  234. package/vendor/sdk/pagination.js +0 -60
  235. package/vendor/sdk/pagination.js.map +0 -1
  236. package/vendor/sdk/pagination.mjs +0 -56
  237. package/vendor/sdk/pagination.mjs.map +0 -1
  238. package/vendor/sdk/resource.d.ts +0 -6
  239. package/vendor/sdk/resource.d.ts.map +0 -1
  240. package/vendor/sdk/resource.js +0 -11
  241. package/vendor/sdk/resource.js.map +0 -1
  242. package/vendor/sdk/resource.mjs +0 -7
  243. package/vendor/sdk/resource.mjs.map +0 -1
  244. package/vendor/sdk/resources/beta/beta.d.ts +0 -57
  245. package/vendor/sdk/resources/beta/beta.d.ts.map +0 -1
  246. package/vendor/sdk/resources/beta/beta.js +0 -44
  247. package/vendor/sdk/resources/beta/beta.js.map +0 -1
  248. package/vendor/sdk/resources/beta/beta.mjs +0 -17
  249. package/vendor/sdk/resources/beta/beta.mjs.map +0 -1
  250. package/vendor/sdk/resources/beta/index.d.ts +0 -4
  251. package/vendor/sdk/resources/beta/index.d.ts.map +0 -1
  252. package/vendor/sdk/resources/beta/index.js +0 -12
  253. package/vendor/sdk/resources/beta/index.js.map +0 -1
  254. package/vendor/sdk/resources/beta/index.mjs +0 -5
  255. package/vendor/sdk/resources/beta/index.mjs.map +0 -1
  256. package/vendor/sdk/resources/beta/messages/batches.d.ts +0 -289
  257. package/vendor/sdk/resources/beta/messages/batches.d.ts.map +0 -1
  258. package/vendor/sdk/resources/beta/messages/batches.js +0 -112
  259. package/vendor/sdk/resources/beta/messages/batches.js.map +0 -1
  260. package/vendor/sdk/resources/beta/messages/batches.mjs +0 -107
  261. package/vendor/sdk/resources/beta/messages/batches.mjs.map +0 -1
  262. package/vendor/sdk/resources/beta/messages/index.d.ts +0 -3
  263. package/vendor/sdk/resources/beta/messages/index.d.ts.map +0 -1
  264. package/vendor/sdk/resources/beta/messages/index.js +0 -10
  265. package/vendor/sdk/resources/beta/messages/index.js.map +0 -1
  266. package/vendor/sdk/resources/beta/messages/index.mjs +0 -4
  267. package/vendor/sdk/resources/beta/messages/index.mjs.map +0 -1
  268. package/vendor/sdk/resources/beta/messages/messages.d.ts +0 -1038
  269. package/vendor/sdk/resources/beta/messages/messages.d.ts.map +0 -1
  270. package/vendor/sdk/resources/beta/messages/messages.js +0 -93
  271. package/vendor/sdk/resources/beta/messages/messages.js.map +0 -1
  272. package/vendor/sdk/resources/beta/messages/messages.mjs +0 -66
  273. package/vendor/sdk/resources/beta/messages/messages.mjs.map +0 -1
  274. package/vendor/sdk/resources/beta/models.d.ts +0 -49
  275. package/vendor/sdk/resources/beta/models.d.ts.map +0 -1
  276. package/vendor/sdk/resources/beta/models.js +0 -30
  277. package/vendor/sdk/resources/beta/models.js.map +0 -1
  278. package/vendor/sdk/resources/beta/models.mjs +0 -25
  279. package/vendor/sdk/resources/beta/models.mjs.map +0 -1
  280. package/vendor/sdk/resources/completions.d.ts +0 -166
  281. package/vendor/sdk/resources/completions.d.ts.map +0 -1
  282. package/vendor/sdk/resources/completions.js +0 -17
  283. package/vendor/sdk/resources/completions.js.map +0 -1
  284. package/vendor/sdk/resources/completions.mjs +0 -13
  285. package/vendor/sdk/resources/completions.mjs.map +0 -1
  286. package/vendor/sdk/resources/index.d.ts +0 -6
  287. package/vendor/sdk/resources/index.d.ts.map +0 -1
  288. package/vendor/sdk/resources/index.js +0 -29
  289. package/vendor/sdk/resources/index.js.map +0 -1
  290. package/vendor/sdk/resources/index.mjs +0 -7
  291. package/vendor/sdk/resources/index.mjs.map +0 -1
  292. package/vendor/sdk/resources/messages/batches.d.ts +0 -253
  293. package/vendor/sdk/resources/messages/batches.d.ts.map +0 -1
  294. package/vendor/sdk/resources/messages/batches.js +0 -102
  295. package/vendor/sdk/resources/messages/batches.js.map +0 -1
  296. package/vendor/sdk/resources/messages/batches.mjs +0 -97
  297. package/vendor/sdk/resources/messages/batches.mjs.map +0 -1
  298. package/vendor/sdk/resources/messages/index.d.ts +0 -3
  299. package/vendor/sdk/resources/messages/index.d.ts.map +0 -1
  300. package/vendor/sdk/resources/messages/index.js +0 -10
  301. package/vendor/sdk/resources/messages/index.js.map +0 -1
  302. package/vendor/sdk/resources/messages/index.mjs +0 -4
  303. package/vendor/sdk/resources/messages/index.mjs.map +0 -1
  304. package/vendor/sdk/resources/messages/messages.d.ts +0 -1028
  305. package/vendor/sdk/resources/messages/messages.d.ts.map +0 -1
  306. package/vendor/sdk/resources/messages/messages.js +0 -82
  307. package/vendor/sdk/resources/messages/messages.js.map +0 -1
  308. package/vendor/sdk/resources/messages/messages.mjs +0 -54
  309. package/vendor/sdk/resources/messages/messages.mjs.map +0 -1
  310. package/vendor/sdk/resources/models.d.ts +0 -49
  311. package/vendor/sdk/resources/models.d.ts.map +0 -1
  312. package/vendor/sdk/resources/models.js +0 -30
  313. package/vendor/sdk/resources/models.js.map +0 -1
  314. package/vendor/sdk/resources/models.mjs +0 -25
  315. package/vendor/sdk/resources/models.mjs.map +0 -1
  316. package/vendor/sdk/resources/shared.d.ts +0 -42
  317. package/vendor/sdk/resources/shared.d.ts.map +0 -1
  318. package/vendor/sdk/resources/shared.js +0 -4
  319. package/vendor/sdk/resources/shared.js.map +0 -1
  320. package/vendor/sdk/resources/shared.mjs +0 -3
  321. package/vendor/sdk/resources/shared.mjs.map +0 -1
  322. package/vendor/sdk/resources/top-level.d.ts +0 -2
  323. package/vendor/sdk/resources/top-level.d.ts.map +0 -1
  324. package/vendor/sdk/resources/top-level.js +0 -4
  325. package/vendor/sdk/resources/top-level.js.map +0 -1
  326. package/vendor/sdk/resources/top-level.mjs +0 -3
  327. package/vendor/sdk/resources/top-level.mjs.map +0 -1
  328. package/vendor/sdk/shims/node.d.ts +0 -30
  329. package/vendor/sdk/shims/node.d.ts.map +0 -1
  330. package/vendor/sdk/shims/node.js +0 -31
  331. package/vendor/sdk/shims/node.js.map +0 -1
  332. package/vendor/sdk/shims/node.mjs +0 -5
  333. package/vendor/sdk/shims/node.mjs.map +0 -1
  334. package/vendor/sdk/shims/web.d.ts +0 -26
  335. package/vendor/sdk/shims/web.d.ts.map +0 -1
  336. package/vendor/sdk/shims/web.js +0 -31
  337. package/vendor/sdk/shims/web.js.map +0 -1
  338. package/vendor/sdk/shims/web.mjs +0 -5
  339. package/vendor/sdk/shims/web.mjs.map +0 -1
  340. package/vendor/sdk/src/_shims/MultipartBody.ts +0 -9
  341. package/vendor/sdk/src/_shims/README.md +0 -46
  342. package/vendor/sdk/src/_shims/auto/runtime-bun.ts +0 -4
  343. package/vendor/sdk/src/_shims/auto/runtime-node.ts +0 -4
  344. package/vendor/sdk/src/_shims/auto/runtime.ts +0 -4
  345. package/vendor/sdk/src/_shims/auto/types-node.ts +0 -4
  346. package/vendor/sdk/src/_shims/auto/types.d.ts +0 -101
  347. package/vendor/sdk/src/_shims/auto/types.js +0 -3
  348. package/vendor/sdk/src/_shims/auto/types.mjs +0 -3
  349. package/vendor/sdk/src/_shims/bun-runtime.ts +0 -14
  350. package/vendor/sdk/src/_shims/index.d.ts +0 -81
  351. package/vendor/sdk/src/_shims/index.js +0 -13
  352. package/vendor/sdk/src/_shims/index.mjs +0 -7
  353. package/vendor/sdk/src/_shims/manual-types.d.ts +0 -12
  354. package/vendor/sdk/src/_shims/manual-types.js +0 -3
  355. package/vendor/sdk/src/_shims/manual-types.mjs +0 -3
  356. package/vendor/sdk/src/_shims/node-runtime.ts +0 -81
  357. package/vendor/sdk/src/_shims/node-types.d.ts +0 -42
  358. package/vendor/sdk/src/_shims/node-types.js +0 -3
  359. package/vendor/sdk/src/_shims/node-types.mjs +0 -3
  360. package/vendor/sdk/src/_shims/registry.ts +0 -67
  361. package/vendor/sdk/src/_shims/web-runtime.ts +0 -103
  362. package/vendor/sdk/src/_shims/web-types.d.ts +0 -83
  363. package/vendor/sdk/src/_shims/web-types.js +0 -3
  364. package/vendor/sdk/src/_shims/web-types.mjs +0 -3
  365. package/vendor/sdk/src/_vendor/partial-json-parser/README.md +0 -3
  366. package/vendor/sdk/src/_vendor/partial-json-parser/parser.ts +0 -264
  367. package/vendor/sdk/src/core.ts +0 -1250
  368. package/vendor/sdk/src/error.ts +0 -133
  369. package/vendor/sdk/src/index.ts +0 -465
  370. package/vendor/sdk/src/internal/decoders/jsonl.ts +0 -41
  371. package/vendor/sdk/src/internal/decoders/line.ts +0 -145
  372. package/vendor/sdk/src/internal/stream-utils.ts +0 -32
  373. package/vendor/sdk/src/lib/.keep +0 -4
  374. package/vendor/sdk/src/lib/BetaMessageStream.ts +0 -661
  375. package/vendor/sdk/src/lib/MessageStream.ts +0 -662
  376. package/vendor/sdk/src/pagination.ts +0 -92
  377. package/vendor/sdk/src/resource.ts +0 -11
  378. package/vendor/sdk/src/resources/beta/beta.ts +0 -249
  379. package/vendor/sdk/src/resources/beta/index.ts +0 -83
  380. package/vendor/sdk/src/resources/beta/messages/batches.ts +0 -486
  381. package/vendor/sdk/src/resources/beta/messages/index.ts +0 -87
  382. package/vendor/sdk/src/resources/beta/messages/messages.ts +0 -1444
  383. package/vendor/sdk/src/resources/beta/models.ts +0 -78
  384. package/vendor/sdk/src/resources/completions.ts +0 -210
  385. package/vendor/sdk/src/resources/index.ts +0 -95
  386. package/vendor/sdk/src/resources/messages/batches.ts +0 -352
  387. package/vendor/sdk/src/resources/messages/index.ts +0 -85
  388. package/vendor/sdk/src/resources/messages/messages.ts +0 -1412
  389. package/vendor/sdk/src/resources/models.ts +0 -75
  390. package/vendor/sdk/src/resources/shared.ts +0 -72
  391. package/vendor/sdk/src/resources/top-level.ts +0 -3
  392. package/vendor/sdk/src/shims/node.ts +0 -50
  393. package/vendor/sdk/src/shims/web.ts +0 -50
  394. package/vendor/sdk/src/streaming.ts +0 -372
  395. package/vendor/sdk/src/tsconfig.json +0 -11
  396. package/vendor/sdk/src/uploads.ts +0 -255
  397. package/vendor/sdk/src/version.ts +0 -1
  398. package/vendor/sdk/streaming.d.ts +0 -36
  399. package/vendor/sdk/streaming.d.ts.map +0 -1
  400. package/vendor/sdk/streaming.js +0 -316
  401. package/vendor/sdk/streaming.js.map +0 -1
  402. package/vendor/sdk/streaming.mjs +0 -310
  403. package/vendor/sdk/streaming.mjs.map +0 -1
  404. package/vendor/sdk/uploads.d.ts +0 -75
  405. package/vendor/sdk/uploads.d.ts.map +0 -1
  406. package/vendor/sdk/uploads.js +0 -171
  407. package/vendor/sdk/uploads.js.map +0 -1
  408. package/vendor/sdk/uploads.mjs +0 -158
  409. package/vendor/sdk/uploads.mjs.map +0 -1
  410. package/vendor/sdk/version.d.ts +0 -2
  411. package/vendor/sdk/version.d.ts.map +0 -1
  412. package/vendor/sdk/version.js +0 -5
  413. package/vendor/sdk/version.js.map +0 -1
  414. package/vendor/sdk/version.mjs +0 -2
  415. package/vendor/sdk/version.mjs.map +0 -1
@@ -1,310 +0,0 @@
1
- import { ReadableStream } from "./_shims/index.mjs";
2
- import { AnthropicError } from "./error.mjs";
3
- import { LineDecoder } from "./internal/decoders/line.mjs";
4
- import { ReadableStreamToAsyncIterable } from "./internal/stream-utils.mjs";
5
- import { createResponseHeaders } from "./core.mjs";
6
- import { APIError } from "./error.mjs";
7
- export class Stream {
8
- constructor(iterator, controller) {
9
- this.iterator = iterator;
10
- this.controller = controller;
11
- }
12
- static fromSSEResponse(response, controller) {
13
- let consumed = false;
14
- async function* iterator() {
15
- if (consumed) {
16
- throw new Error('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
17
- }
18
- consumed = true;
19
- let done = false;
20
- try {
21
- for await (const sse of _iterSSEMessages(response, controller)) {
22
- if (sse.event === 'completion') {
23
- try {
24
- yield JSON.parse(sse.data);
25
- }
26
- catch (e) {
27
- console.error(`Could not parse message into JSON:`, sse.data);
28
- console.error(`From chunk:`, sse.raw);
29
- throw e;
30
- }
31
- }
32
- if (sse.event === 'message_start' ||
33
- sse.event === 'message_delta' ||
34
- sse.event === 'message_stop' ||
35
- sse.event === 'content_block_start' ||
36
- sse.event === 'content_block_delta' ||
37
- sse.event === 'content_block_stop') {
38
- try {
39
- yield JSON.parse(sse.data);
40
- }
41
- catch (e) {
42
- console.error(`Could not parse message into JSON:`, sse.data);
43
- console.error(`From chunk:`, sse.raw);
44
- throw e;
45
- }
46
- }
47
- if (sse.event === 'ping') {
48
- continue;
49
- }
50
- if (sse.event === 'error') {
51
- throw APIError.generate(undefined, `SSE Error: ${sse.data}`, sse.data, createResponseHeaders(response.headers));
52
- }
53
- }
54
- done = true;
55
- }
56
- catch (e) {
57
- // If the user calls `stream.controller.abort()`, we should exit without throwing.
58
- if (e instanceof Error && e.name === 'AbortError')
59
- return;
60
- throw e;
61
- }
62
- finally {
63
- // If the user `break`s, abort the ongoing request.
64
- if (!done)
65
- controller.abort();
66
- }
67
- }
68
- return new Stream(iterator, controller);
69
- }
70
- /**
71
- * Generates a Stream from a newline-separated ReadableStream
72
- * where each item is a JSON value.
73
- */
74
- static fromReadableStream(readableStream, controller) {
75
- let consumed = false;
76
- async function* iterLines() {
77
- const lineDecoder = new LineDecoder();
78
- const iter = ReadableStreamToAsyncIterable(readableStream);
79
- for await (const chunk of iter) {
80
- for (const line of lineDecoder.decode(chunk)) {
81
- yield line;
82
- }
83
- }
84
- for (const line of lineDecoder.flush()) {
85
- yield line;
86
- }
87
- }
88
- async function* iterator() {
89
- if (consumed) {
90
- throw new Error('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
91
- }
92
- consumed = true;
93
- let done = false;
94
- try {
95
- for await (const line of iterLines()) {
96
- if (done)
97
- continue;
98
- if (line)
99
- yield JSON.parse(line);
100
- }
101
- done = true;
102
- }
103
- catch (e) {
104
- // If the user calls `stream.controller.abort()`, we should exit without throwing.
105
- if (e instanceof Error && e.name === 'AbortError')
106
- return;
107
- throw e;
108
- }
109
- finally {
110
- // If the user `break`s, abort the ongoing request.
111
- if (!done)
112
- controller.abort();
113
- }
114
- }
115
- return new Stream(iterator, controller);
116
- }
117
- [Symbol.asyncIterator]() {
118
- return this.iterator();
119
- }
120
- /**
121
- * Splits the stream into two streams which can be
122
- * independently read from at different speeds.
123
- */
124
- tee() {
125
- const left = [];
126
- const right = [];
127
- const iterator = this.iterator();
128
- const teeIterator = (queue) => {
129
- return {
130
- next: () => {
131
- if (queue.length === 0) {
132
- const result = iterator.next();
133
- left.push(result);
134
- right.push(result);
135
- }
136
- return queue.shift();
137
- },
138
- };
139
- };
140
- return [
141
- new Stream(() => teeIterator(left), this.controller),
142
- new Stream(() => teeIterator(right), this.controller),
143
- ];
144
- }
145
- /**
146
- * Converts this stream to a newline-separated ReadableStream of
147
- * JSON stringified values in the stream
148
- * which can be turned back into a Stream with `Stream.fromReadableStream()`.
149
- */
150
- toReadableStream() {
151
- const self = this;
152
- let iter;
153
- const encoder = new TextEncoder();
154
- return new ReadableStream({
155
- async start() {
156
- iter = self[Symbol.asyncIterator]();
157
- },
158
- async pull(ctrl) {
159
- try {
160
- const { value, done } = await iter.next();
161
- if (done)
162
- return ctrl.close();
163
- const bytes = encoder.encode(JSON.stringify(value) + '\n');
164
- ctrl.enqueue(bytes);
165
- }
166
- catch (err) {
167
- ctrl.error(err);
168
- }
169
- },
170
- async cancel() {
171
- await iter.return?.();
172
- },
173
- });
174
- }
175
- }
176
- export async function* _iterSSEMessages(response, controller) {
177
- if (!response.body) {
178
- controller.abort();
179
- throw new AnthropicError(`Attempted to iterate over a response with no body`);
180
- }
181
- const sseDecoder = new SSEDecoder();
182
- const lineDecoder = new LineDecoder();
183
- const iter = ReadableStreamToAsyncIterable(response.body);
184
- for await (const sseChunk of iterSSEChunks(iter)) {
185
- for (const line of lineDecoder.decode(sseChunk)) {
186
- const sse = sseDecoder.decode(line);
187
- if (sse)
188
- yield sse;
189
- }
190
- }
191
- for (const line of lineDecoder.flush()) {
192
- const sse = sseDecoder.decode(line);
193
- if (sse)
194
- yield sse;
195
- }
196
- }
197
- /**
198
- * Given an async iterable iterator, iterates over it and yields full
199
- * SSE chunks, i.e. yields when a double new-line is encountered.
200
- */
201
- async function* iterSSEChunks(iterator) {
202
- let data = new Uint8Array();
203
- for await (const chunk of iterator) {
204
- if (chunk == null) {
205
- continue;
206
- }
207
- const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
208
- : typeof chunk === 'string' ? new TextEncoder().encode(chunk)
209
- : chunk;
210
- let newData = new Uint8Array(data.length + binaryChunk.length);
211
- newData.set(data);
212
- newData.set(binaryChunk, data.length);
213
- data = newData;
214
- let patternIndex;
215
- while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
216
- yield data.slice(0, patternIndex);
217
- data = data.slice(patternIndex);
218
- }
219
- }
220
- if (data.length > 0) {
221
- yield data;
222
- }
223
- }
224
- function findDoubleNewlineIndex(buffer) {
225
- // This function searches the buffer for the end patterns (\r\r, \n\n, \r\n\r\n)
226
- // and returns the index right after the first occurrence of any pattern,
227
- // or -1 if none of the patterns are found.
228
- const newline = 0x0a; // \n
229
- const carriage = 0x0d; // \r
230
- for (let i = 0; i < buffer.length - 2; i++) {
231
- if (buffer[i] === newline && buffer[i + 1] === newline) {
232
- // \n\n
233
- return i + 2;
234
- }
235
- if (buffer[i] === carriage && buffer[i + 1] === carriage) {
236
- // \r\r
237
- return i + 2;
238
- }
239
- if (buffer[i] === carriage &&
240
- buffer[i + 1] === newline &&
241
- i + 3 < buffer.length &&
242
- buffer[i + 2] === carriage &&
243
- buffer[i + 3] === newline) {
244
- // \r\n\r\n
245
- return i + 4;
246
- }
247
- }
248
- return -1;
249
- }
250
- class SSEDecoder {
251
- constructor() {
252
- this.event = null;
253
- this.data = [];
254
- this.chunks = [];
255
- }
256
- decode(line) {
257
- if (line.endsWith('\r')) {
258
- line = line.substring(0, line.length - 1);
259
- }
260
- if (!line) {
261
- // empty line and we didn't previously encounter any messages
262
- if (!this.event && !this.data.length)
263
- return null;
264
- const sse = {
265
- event: this.event,
266
- data: this.data.join('\n'),
267
- raw: this.chunks,
268
- };
269
- this.event = null;
270
- this.data = [];
271
- this.chunks = [];
272
- return sse;
273
- }
274
- this.chunks.push(line);
275
- if (line.startsWith(':')) {
276
- return null;
277
- }
278
- let [fieldname, _, value] = partition(line, ':');
279
- if (value.startsWith(' ')) {
280
- value = value.substring(1);
281
- }
282
- if (fieldname === 'event') {
283
- this.event = value;
284
- }
285
- else if (fieldname === 'data') {
286
- this.data.push(value);
287
- }
288
- return null;
289
- }
290
- }
291
- /** This is an internal helper function that's just used for testing */
292
- export function _decodeChunks(chunks, { flush } = { flush: false }) {
293
- const decoder = new LineDecoder();
294
- const lines = [];
295
- for (const chunk of chunks) {
296
- lines.push(...decoder.decode(chunk));
297
- }
298
- if (flush) {
299
- lines.push(...decoder.flush());
300
- }
301
- return lines;
302
- }
303
- function partition(str, delimiter) {
304
- const index = str.indexOf(delimiter);
305
- if (index !== -1) {
306
- return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
307
- }
308
- return [str, '', ''];
309
- }
310
- //# sourceMappingURL=streaming.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streaming.mjs","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"OAAO,EAAE,cAAc,EAAiB;OACjC,EAAE,cAAc,EAAE;OAClB,EAAE,WAAW,EAAE;OACf,EAAE,6BAA6B,EAAE;OAEjC,EAAE,qBAAqB,EAAE;OACzB,EAAE,QAAQ,EAAE;AAUnB,MAAM,OAAO,MAAM;IAGjB,YACU,QAAmC,EAC3C,UAA2B;QADnB,aAAQ,GAAR,QAAQ,CAA2B;QAG3C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,eAAe,CAAO,QAAkB,EAAE,UAA2B;QAC1E,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,KAAK,SAAS,CAAC,CAAC,QAAQ;YACtB,IAAI,QAAQ,EAAE;gBACZ,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;aAC7F;YACD,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,IAAI,GAAG,KAAK,CAAC;YACjB,IAAI;gBACF,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE;oBAC9D,IAAI,GAAG,CAAC,KAAK,KAAK,YAAY,EAAE;wBAC9B,IAAI;4BACF,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;yBAC5B;wBAAC,OAAO,CAAC,EAAE;4BACV,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,I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K,EAAE;IAC9F,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACtC;IAED,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;KAChC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,SAAiB;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;KACtF;IAED,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACvB,CAAC"}
@@ -1,75 +0,0 @@
1
- import { type RequestOptions } from "./core.js";
2
- import { FormData, type Blob, type FilePropertyBag, type FsReadStream } from "./_shims/index.js";
3
- import { MultipartBody } from "./_shims/MultipartBody.js";
4
- export { fileFromPath } from "./_shims/index.js";
5
- type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
6
- export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
7
- /**
8
- * Typically, this is a native "File" class.
9
- *
10
- * We provide the {@link toFile} utility to convert a variety of objects
11
- * into the File class.
12
- *
13
- * For convenience, you can also pass a fetch Response, or in Node,
14
- * the result of fs.createReadStream().
15
- */
16
- export type Uploadable = FileLike | ResponseLike | FsReadStream;
17
- /**
18
- * Intended to match web.Blob, node.Blob, node-fetch.Blob, etc.
19
- */
20
- export interface BlobLike {
21
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
22
- readonly size: number;
23
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
24
- readonly type: string;
25
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
26
- text(): Promise<string>;
27
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
28
- slice(start?: number, end?: number): BlobLike;
29
- }
30
- /**
31
- * Intended to match web.File, node.File, node-fetch.File, etc.
32
- */
33
- export interface FileLike extends BlobLike {
34
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
35
- readonly lastModified: number;
36
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
37
- readonly name: string;
38
- }
39
- /**
40
- * Intended to match web.Response, node.Response, node-fetch.Response, etc.
41
- */
42
- export interface ResponseLike {
43
- url: string;
44
- blob(): Promise<BlobLike>;
45
- }
46
- export declare const isResponseLike: (value: any) => value is ResponseLike;
47
- export declare const isFileLike: (value: any) => value is FileLike;
48
- /**
49
- * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
50
- * adds the arrayBuffer() method type because it is available and used at runtime
51
- */
52
- export declare const isBlobLike: (value: any) => value is BlobLike & {
53
- arrayBuffer(): Promise<ArrayBuffer>;
54
- };
55
- export declare const isUploadable: (value: any) => value is Uploadable;
56
- export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
57
- /**
58
- * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
59
- * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
60
- * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
61
- * @param {Object=} options additional properties
62
- * @param {string=} options.type the MIME type of the content
63
- * @param {number=} options.lastModified the last modified timestamp
64
- * @returns a {@link File} with the given properties
65
- */
66
- export declare function toFile(value: ToFileInput | PromiseLike<ToFileInput>, name?: string | null | undefined, options?: FilePropertyBag | undefined): Promise<FileLike>;
67
- export declare const isMultipartBody: (body: any) => body is MultipartBody;
68
- /**
69
- * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
70
- * Otherwise returns the request as is.
71
- */
72
- export declare const maybeMultipartFormRequestOptions: <T = Record<string, unknown>>(opts: RequestOptions<T>) => Promise<RequestOptions<MultipartBody | T>>;
73
- export declare const multipartFormRequestOptions: <T = Record<string, unknown>>(opts: RequestOptions<T>) => Promise<RequestOptions<MultipartBody | T>>;
74
- export declare const createForm: <T = Record<string, unknown>>(body: T | undefined) => Promise<FormData>;
75
- //# sourceMappingURL=uploads.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EACL,QAAQ,EAER,KAAK,IAAI,EACT,KAAK,eAAe,EAEpB,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAC9F,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE7F;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,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AO,MAAM,2BAA2B,sGAKvC,CAAC;AAEF,eAAO,MAAM,UAAU,wDAA6D,QAAQ,QAAQ,CAInG,CAAC"}
@@ -1,171 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createForm = exports.multipartFormRequestOptions = exports.maybeMultipartFormRequestOptions = exports.isMultipartBody = exports.toFile = exports.isUploadable = exports.isBlobLike = exports.isFileLike = exports.isResponseLike = exports.fileFromPath = void 0;
4
- const index_1 = require("./_shims/index.js");
5
- var index_2 = require("./_shims/index.js");
6
- Object.defineProperty(exports, "fileFromPath", { enumerable: true, get: function () { return index_2.fileFromPath; } });
7
- const isResponseLike = (value) => value != null &&
8
- typeof value === 'object' &&
9
- typeof value.url === 'string' &&
10
- typeof value.blob === 'function';
11
- exports.isResponseLike = isResponseLike;
12
- const isFileLike = (value) => value != null &&
13
- typeof value === 'object' &&
14
- typeof value.name === 'string' &&
15
- typeof value.lastModified === 'number' &&
16
- (0, exports.isBlobLike)(value);
17
- exports.isFileLike = isFileLike;
18
- /**
19
- * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
20
- * adds the arrayBuffer() method type because it is available and used at runtime
21
- */
22
- const isBlobLike = (value) => value != null &&
23
- typeof value === 'object' &&
24
- typeof value.size === 'number' &&
25
- typeof value.type === 'string' &&
26
- typeof value.text === 'function' &&
27
- typeof value.slice === 'function' &&
28
- typeof value.arrayBuffer === 'function';
29
- exports.isBlobLike = isBlobLike;
30
- const isUploadable = (value) => {
31
- return (0, exports.isFileLike)(value) || (0, exports.isResponseLike)(value) || (0, index_1.isFsReadStream)(value);
32
- };
33
- exports.isUploadable = isUploadable;
34
- /**
35
- * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
36
- * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
37
- * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
38
- * @param {Object=} options additional properties
39
- * @param {string=} options.type the MIME type of the content
40
- * @param {number=} options.lastModified the last modified timestamp
41
- * @returns a {@link File} with the given properties
42
- */
43
- async function toFile(value, name, options) {
44
- // If it's a promise, resolve it.
45
- value = await value;
46
- // If we've been given a `File` we don't need to do anything
47
- if ((0, exports.isFileLike)(value)) {
48
- return value;
49
- }
50
- if ((0, exports.isResponseLike)(value)) {
51
- const blob = await value.blob();
52
- name || (name = new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file');
53
- // we need to convert the `Blob` into an array buffer because the `Blob` class
54
- // that `node-fetch` defines is incompatible with the web standard which results
55
- // in `new File` interpreting it as a string instead of binary data.
56
- const data = (0, exports.isBlobLike)(blob) ? [(await blob.arrayBuffer())] : [blob];
57
- return new index_1.File(data, name, options);
58
- }
59
- const bits = await getBytes(value);
60
- name || (name = getName(value) ?? 'unknown_file');
61
- if (!options?.type) {
62
- const type = bits[0]?.type;
63
- if (typeof type === 'string') {
64
- options = { ...options, type };
65
- }
66
- }
67
- return new index_1.File(bits, name, options);
68
- }
69
- exports.toFile = toFile;
70
- async function getBytes(value) {
71
- let parts = [];
72
- if (typeof value === 'string' ||
73
- ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
74
- value instanceof ArrayBuffer) {
75
- parts.push(value);
76
- }
77
- else if ((0, exports.isBlobLike)(value)) {
78
- parts.push(await value.arrayBuffer());
79
- }
80
- else if (isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
81
- ) {
82
- for await (const chunk of value) {
83
- parts.push(chunk); // TODO, consider validating?
84
- }
85
- }
86
- else {
87
- throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor
88
- ?.name}; props: ${propsForError(value)}`);
89
- }
90
- return parts;
91
- }
92
- function propsForError(value) {
93
- const props = Object.getOwnPropertyNames(value);
94
- return `[${props.map((p) => `"${p}"`).join(', ')}]`;
95
- }
96
- function getName(value) {
97
- return (getStringFromMaybeBuffer(value.name) ||
98
- getStringFromMaybeBuffer(value.filename) ||
99
- // For fs.ReadStream
100
- getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop());
101
- }
102
- const getStringFromMaybeBuffer = (x) => {
103
- if (typeof x === 'string')
104
- return x;
105
- if (typeof Buffer !== 'undefined' && x instanceof Buffer)
106
- return String(x);
107
- return undefined;
108
- };
109
- const isAsyncIterableIterator = (value) => value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
110
- const isMultipartBody = (body) => body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody';
111
- exports.isMultipartBody = isMultipartBody;
112
- /**
113
- * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
114
- * Otherwise returns the request as is.
115
- */
116
- const maybeMultipartFormRequestOptions = async (opts) => {
117
- if (!hasUploadableValue(opts.body))
118
- return opts;
119
- const form = await (0, exports.createForm)(opts.body);
120
- return (0, index_1.getMultipartRequestOptions)(form, opts);
121
- };
122
- exports.maybeMultipartFormRequestOptions = maybeMultipartFormRequestOptions;
123
- const multipartFormRequestOptions = async (opts) => {
124
- const form = await (0, exports.createForm)(opts.body);
125
- return (0, index_1.getMultipartRequestOptions)(form, opts);
126
- };
127
- exports.multipartFormRequestOptions = multipartFormRequestOptions;
128
- const createForm = async (body) => {
129
- const form = new index_1.FormData();
130
- await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
131
- return form;
132
- };
133
- exports.createForm = createForm;
134
- const hasUploadableValue = (value) => {
135
- if ((0, exports.isUploadable)(value))
136
- return true;
137
- if (Array.isArray(value))
138
- return value.some(hasUploadableValue);
139
- if (value && typeof value === 'object') {
140
- for (const k in value) {
141
- if (hasUploadableValue(value[k]))
142
- return true;
143
- }
144
- }
145
- return false;
146
- };
147
- const addFormValue = async (form, key, value) => {
148
- if (value === undefined)
149
- return;
150
- if (value == null) {
151
- throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
152
- }
153
- // TODO: make nested formats configurable
154
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
155
- form.append(key, String(value));
156
- }
157
- else if ((0, exports.isUploadable)(value)) {
158
- const file = await toFile(value);
159
- form.append(key, file);
160
- }
161
- else if (Array.isArray(value)) {
162
- await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
163
- }
164
- else if (typeof value === 'object') {
165
- await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
166
- }
167
- else {
168
- throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
169
- }
170
- };
171
- //# sourceMappingURL=uploads.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploads.js","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":";;;AACA,6CAQwB;AAExB,2CAA8C;AAArC,qGAAA,YAAY,OAAA;AAiDd,MAAM,cAAc,GAAG,CAAC,KAAU,EAAyB,EAAE,CAClE,KAAK,IAAI,IAAI;IACb,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;IAC7B,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;AAJtB,QAAA,cAAc,kBAIQ;AAE5B,MAAM,UAAU,GAAG,CAAC,KAAU,EAAqB,EAAE,CAC1D,KAAK,IAAI,IAAI;IACb,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ;IACtC,IAAA,kBAAU,EAAC,KAAK,CAAC,CAAC;AALP,QAAA,UAAU,cAKH;AAEpB;;;GAGG;AACI,MAAM,UAAU,GAAG,CAAC,KAAU,EAA+D,EAAE,CACpG,KAAK,IAAI,IAAI;IACb,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;IAC9B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