@lorikeetai/node-sdk 1.8.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (572) hide show
  1. package/CHANGELOG.md +38 -787
  2. package/README.md +114 -44
  3. package/api-promise.d.mts +2 -0
  4. package/api-promise.d.mts.map +1 -0
  5. package/api-promise.d.ts +2 -0
  6. package/api-promise.d.ts.map +1 -0
  7. package/api-promise.js +6 -0
  8. package/api-promise.js.map +1 -0
  9. package/api-promise.mjs +2 -0
  10. package/api-promise.mjs.map +1 -0
  11. package/bin/cli +53 -0
  12. package/bin/migration-config.json +50 -0
  13. package/client.d.mts +197 -0
  14. package/client.d.mts.map +1 -0
  15. package/client.d.ts +197 -0
  16. package/client.d.ts.map +1 -0
  17. package/client.js +504 -0
  18. package/client.js.map +1 -0
  19. package/client.mjs +500 -0
  20. package/client.mjs.map +1 -0
  21. package/core/api-promise.d.mts +46 -0
  22. package/core/api-promise.d.mts.map +1 -0
  23. package/core/api-promise.d.ts +46 -0
  24. package/core/api-promise.d.ts.map +1 -0
  25. package/core/api-promise.js +74 -0
  26. package/core/api-promise.js.map +1 -0
  27. package/core/api-promise.mjs +70 -0
  28. package/core/api-promise.mjs.map +1 -0
  29. package/core/error.d.mts +46 -0
  30. package/core/error.d.mts.map +1 -0
  31. package/core/error.d.ts +46 -0
  32. package/core/error.d.ts.map +1 -0
  33. package/core/error.js +113 -0
  34. package/core/error.js.map +1 -0
  35. package/core/error.mjs +97 -0
  36. package/core/error.mjs.map +1 -0
  37. package/core/resource.d.mts +6 -0
  38. package/core/resource.d.mts.map +1 -0
  39. package/core/resource.d.ts +6 -0
  40. package/core/resource.d.ts.map +1 -0
  41. package/core/resource.js +11 -0
  42. package/core/resource.js.map +1 -0
  43. package/core/resource.mjs +7 -0
  44. package/core/resource.mjs.map +1 -0
  45. package/core/uploads.d.mts +3 -0
  46. package/core/uploads.d.mts.map +1 -0
  47. package/core/uploads.d.ts +3 -0
  48. package/core/uploads.d.ts.map +1 -0
  49. package/core/uploads.js +6 -0
  50. package/core/uploads.js.map +1 -0
  51. package/core/uploads.mjs +2 -0
  52. package/core/uploads.mjs.map +1 -0
  53. package/error.d.mts +2 -0
  54. package/error.d.mts.map +1 -0
  55. package/error.d.ts +1 -46
  56. package/error.d.ts.map +1 -1
  57. package/error.js +3 -110
  58. package/error.js.map +1 -1
  59. package/error.mjs +1 -96
  60. package/error.mjs.map +1 -1
  61. package/index.d.mts +7 -131
  62. package/index.d.mts.map +1 -0
  63. package/index.d.ts +6 -130
  64. package/index.d.ts.map +1 -1
  65. package/index.js +14 -142
  66. package/index.js.map +1 -1
  67. package/index.mjs +6 -114
  68. package/index.mjs.map +1 -1
  69. package/internal/builtin-types.d.mts +73 -0
  70. package/internal/builtin-types.d.mts.map +1 -0
  71. package/internal/builtin-types.d.ts +73 -0
  72. package/internal/builtin-types.d.ts.map +1 -0
  73. package/internal/builtin-types.js +4 -0
  74. package/internal/builtin-types.js.map +1 -0
  75. package/internal/builtin-types.mjs +3 -0
  76. package/internal/builtin-types.mjs.map +1 -0
  77. package/internal/detect-platform.d.mts +15 -0
  78. package/internal/detect-platform.d.mts.map +1 -0
  79. package/internal/detect-platform.d.ts +15 -0
  80. package/internal/detect-platform.d.ts.map +1 -0
  81. package/internal/detect-platform.js +162 -0
  82. package/internal/detect-platform.js.map +1 -0
  83. package/internal/detect-platform.mjs +157 -0
  84. package/internal/detect-platform.mjs.map +1 -0
  85. package/internal/errors.d.mts +3 -0
  86. package/internal/errors.d.mts.map +1 -0
  87. package/internal/errors.d.ts +3 -0
  88. package/internal/errors.d.ts.map +1 -0
  89. package/internal/errors.js +41 -0
  90. package/internal/errors.js.map +1 -0
  91. package/internal/errors.mjs +36 -0
  92. package/internal/errors.mjs.map +1 -0
  93. package/internal/headers.d.mts +20 -0
  94. package/internal/headers.d.mts.map +1 -0
  95. package/internal/headers.d.ts +20 -0
  96. package/internal/headers.d.ts.map +1 -0
  97. package/internal/headers.js +79 -0
  98. package/internal/headers.js.map +1 -0
  99. package/internal/headers.mjs +74 -0
  100. package/internal/headers.mjs.map +1 -0
  101. package/internal/parse.d.mts +12 -0
  102. package/internal/parse.d.mts.map +1 -0
  103. package/internal/parse.d.ts +12 -0
  104. package/internal/parse.d.ts.map +1 -0
  105. package/internal/parse.js +40 -0
  106. package/internal/parse.js.map +1 -0
  107. package/internal/parse.mjs +37 -0
  108. package/internal/parse.mjs.map +1 -0
  109. package/internal/request-options.d.mts +75 -0
  110. package/internal/request-options.d.mts.map +1 -0
  111. package/internal/request-options.d.ts +75 -0
  112. package/internal/request-options.d.ts.map +1 -0
  113. package/internal/request-options.js +14 -0
  114. package/internal/request-options.js.map +1 -0
  115. package/internal/request-options.mjs +10 -0
  116. package/internal/request-options.mjs.map +1 -0
  117. package/internal/shim-types.d.mts +17 -0
  118. package/internal/shim-types.d.mts.map +1 -0
  119. package/internal/shim-types.d.ts +17 -0
  120. package/internal/shim-types.d.ts.map +1 -0
  121. package/internal/shim-types.js +4 -0
  122. package/internal/shim-types.js.map +1 -0
  123. package/internal/shim-types.mjs +3 -0
  124. package/internal/shim-types.mjs.map +1 -0
  125. package/internal/shims.d.mts +20 -0
  126. package/internal/shims.d.mts.map +1 -0
  127. package/internal/shims.d.ts +20 -0
  128. package/internal/shims.d.ts.map +1 -0
  129. package/internal/shims.js +92 -0
  130. package/internal/shims.js.map +1 -0
  131. package/internal/shims.mjs +85 -0
  132. package/internal/shims.mjs.map +1 -0
  133. package/internal/to-file.d.mts +45 -0
  134. package/internal/to-file.d.mts.map +1 -0
  135. package/internal/to-file.d.ts +45 -0
  136. package/internal/to-file.d.ts.map +1 -0
  137. package/internal/to-file.js +92 -0
  138. package/internal/to-file.js.map +1 -0
  139. package/internal/to-file.mjs +89 -0
  140. package/internal/to-file.mjs.map +1 -0
  141. package/internal/tslib.js +81 -0
  142. package/internal/tslib.mjs +17 -0
  143. package/internal/types.d.mts +69 -0
  144. package/internal/types.d.mts.map +1 -0
  145. package/internal/types.d.ts +69 -0
  146. package/internal/types.d.ts.map +1 -0
  147. package/internal/types.js +4 -0
  148. package/internal/types.js.map +1 -0
  149. package/internal/types.mjs +3 -0
  150. package/internal/types.mjs.map +1 -0
  151. package/internal/uploads.d.mts +42 -0
  152. package/internal/uploads.d.mts.map +1 -0
  153. package/internal/uploads.d.ts +42 -0
  154. package/internal/uploads.d.ts.map +1 -0
  155. package/internal/uploads.js +141 -0
  156. package/internal/uploads.js.map +1 -0
  157. package/internal/uploads.mjs +131 -0
  158. package/internal/uploads.mjs.map +1 -0
  159. package/internal/utils/base64.d.mts +3 -0
  160. package/internal/utils/base64.d.mts.map +1 -0
  161. package/internal/utils/base64.d.ts +3 -0
  162. package/internal/utils/base64.d.ts.map +1 -0
  163. package/internal/utils/base64.js +38 -0
  164. package/internal/utils/base64.js.map +1 -0
  165. package/internal/utils/base64.mjs +33 -0
  166. package/internal/utils/base64.mjs.map +1 -0
  167. package/internal/utils/bytes.d.mts +4 -0
  168. package/internal/utils/bytes.d.mts.map +1 -0
  169. package/internal/utils/bytes.d.ts +4 -0
  170. package/internal/utils/bytes.d.ts.map +1 -0
  171. package/internal/utils/bytes.js +31 -0
  172. package/internal/utils/bytes.js.map +1 -0
  173. package/internal/utils/bytes.mjs +26 -0
  174. package/internal/utils/bytes.mjs.map +1 -0
  175. package/internal/utils/env.d.mts +9 -0
  176. package/internal/utils/env.d.mts.map +1 -0
  177. package/internal/utils/env.d.ts +9 -0
  178. package/internal/utils/env.d.ts.map +1 -0
  179. package/internal/utils/env.js +22 -0
  180. package/internal/utils/env.js.map +1 -0
  181. package/internal/utils/env.mjs +18 -0
  182. package/internal/utils/env.mjs.map +1 -0
  183. package/internal/utils/log.d.mts +37 -0
  184. package/internal/utils/log.d.mts.map +1 -0
  185. package/internal/utils/log.d.ts +37 -0
  186. package/internal/utils/log.d.ts.map +1 -0
  187. package/internal/utils/log.js +86 -0
  188. package/internal/utils/log.js.map +1 -0
  189. package/internal/utils/log.mjs +80 -0
  190. package/internal/utils/log.mjs.map +1 -0
  191. package/internal/utils/path.d.mts +15 -0
  192. package/internal/utils/path.d.mts.map +1 -0
  193. package/internal/utils/path.d.ts +15 -0
  194. package/internal/utils/path.d.ts.map +1 -0
  195. package/internal/utils/path.js +79 -0
  196. package/internal/utils/path.js.map +1 -0
  197. package/internal/utils/path.mjs +74 -0
  198. package/internal/utils/path.mjs.map +1 -0
  199. package/internal/utils/sleep.d.mts +2 -0
  200. package/internal/utils/sleep.d.mts.map +1 -0
  201. package/internal/utils/sleep.d.ts +2 -0
  202. package/internal/utils/sleep.d.ts.map +1 -0
  203. package/internal/utils/sleep.js +7 -0
  204. package/internal/utils/sleep.js.map +1 -0
  205. package/internal/utils/sleep.mjs +3 -0
  206. package/internal/utils/sleep.mjs.map +1 -0
  207. package/internal/utils/uuid.d.mts +5 -0
  208. package/internal/utils/uuid.d.mts.map +1 -0
  209. package/internal/utils/uuid.d.ts +5 -0
  210. package/internal/utils/uuid.d.ts.map +1 -0
  211. package/internal/utils/uuid.js +19 -0
  212. package/internal/utils/uuid.js.map +1 -0
  213. package/internal/utils/uuid.mjs +15 -0
  214. package/internal/utils/uuid.mjs.map +1 -0
  215. package/internal/utils/values.d.mts +18 -0
  216. package/internal/utils/values.d.mts.map +1 -0
  217. package/internal/utils/values.d.ts +18 -0
  218. package/internal/utils/values.d.ts.map +1 -0
  219. package/internal/utils/values.js +112 -0
  220. package/internal/utils/values.js.map +1 -0
  221. package/internal/utils/values.mjs +94 -0
  222. package/internal/utils/values.mjs.map +1 -0
  223. package/internal/utils.d.mts +7 -0
  224. package/internal/utils.d.mts.map +1 -0
  225. package/internal/utils.d.ts +7 -0
  226. package/internal/utils.d.ts.map +1 -0
  227. package/internal/utils.js +11 -0
  228. package/internal/utils.js.map +1 -0
  229. package/internal/utils.mjs +8 -0
  230. package/internal/utils.mjs.map +1 -0
  231. package/lib/generate-signature.d.mts +7 -0
  232. package/lib/generate-signature.d.mts.map +1 -0
  233. package/lib/generate-signature.d.ts +1 -1
  234. package/lib/generate-signature.d.ts.map +1 -1
  235. package/lib/generate-signature.js +3 -3
  236. package/lib/generate-signature.js.map +1 -1
  237. package/lib/generate-signature.mjs +1 -1
  238. package/lib/generate-signature.mjs.map +1 -1
  239. package/lib/poll-until.d.mts +20 -0
  240. package/lib/poll-until.d.mts.map +1 -0
  241. package/lib/poll-until.d.ts.map +1 -1
  242. package/lib/promise.d.mts +55 -0
  243. package/lib/promise.d.mts.map +1 -0
  244. package/package.json +125 -74
  245. package/resource.d.mts +2 -0
  246. package/resource.d.mts.map +1 -0
  247. package/resource.d.ts +1 -5
  248. package/resource.d.ts.map +1 -1
  249. package/resource.js +3 -8
  250. package/resource.js.map +1 -1
  251. package/resource.mjs +1 -6
  252. package/resource.mjs.map +1 -1
  253. package/resources/api-keys.d.mts +130 -0
  254. package/resources/api-keys.d.mts.map +1 -0
  255. package/resources/api-keys.d.ts +7 -6
  256. package/resources/api-keys.d.ts.map +1 -1
  257. package/resources/api-keys.js +6 -4
  258. package/resources/api-keys.js.map +1 -1
  259. package/resources/api-keys.mjs +6 -4
  260. package/resources/api-keys.mjs.map +1 -1
  261. package/resources/conversation/chat.d.mts +312 -0
  262. package/resources/conversation/chat.d.mts.map +1 -0
  263. package/resources/conversation/chat.d.ts +45 -77
  264. package/resources/conversation/chat.d.ts.map +1 -1
  265. package/resources/conversation/chat.js +14 -48
  266. package/resources/conversation/chat.js.map +1 -1
  267. package/resources/conversation/chat.mjs +14 -48
  268. package/resources/conversation/chat.mjs.map +1 -1
  269. package/resources/conversation/conversation.d.mts +77 -0
  270. package/resources/conversation/conversation.d.mts.map +1 -0
  271. package/resources/conversation/conversation.d.ts +1 -1
  272. package/resources/conversation/conversation.d.ts.map +1 -1
  273. package/resources/conversation/conversation.js +5 -27
  274. package/resources/conversation/conversation.js.map +1 -1
  275. package/resources/conversation/conversation.mjs +1 -1
  276. package/resources/conversation/email.d.mts +257 -0
  277. package/resources/conversation/email.d.mts.map +1 -0
  278. package/resources/conversation/email.d.ts +10 -8
  279. package/resources/conversation/email.d.ts.map +1 -1
  280. package/resources/conversation/email.js +6 -6
  281. package/resources/conversation/email.js.map +1 -1
  282. package/resources/conversation/email.mjs +6 -6
  283. package/resources/conversation/email.mjs.map +1 -1
  284. package/resources/conversation/index.d.mts +5 -0
  285. package/resources/conversation/index.d.mts.map +1 -0
  286. package/resources/conversation/index.d.ts +1 -1
  287. package/resources/conversation/index.d.ts.map +1 -1
  288. package/resources/conversation/index.js.map +1 -1
  289. package/resources/conversation/index.mjs.map +1 -1
  290. package/resources/conversation/voice.d.mts +45 -0
  291. package/resources/conversation/voice.d.mts.map +1 -0
  292. package/resources/conversation/voice.d.ts +4 -3
  293. package/resources/conversation/voice.d.ts.map +1 -1
  294. package/resources/conversation/voice.js +3 -2
  295. package/resources/conversation/voice.js.map +1 -1
  296. package/resources/conversation/voice.mjs +3 -2
  297. package/resources/conversation/voice.mjs.map +1 -1
  298. package/resources/conversation.d.mts +2 -0
  299. package/resources/conversation.d.mts.map +1 -0
  300. package/resources/conversation.d.ts.map +1 -1
  301. package/resources/conversation.js +2 -15
  302. package/resources/conversation.js.map +1 -1
  303. package/resources/customer/customer.d.mts +333 -0
  304. package/resources/customer/customer.d.mts.map +1 -0
  305. package/resources/customer/customer.d.ts +7 -7
  306. package/resources/customer/customer.d.ts.map +1 -1
  307. package/resources/customer/customer.js +12 -31
  308. package/resources/customer/customer.js.map +1 -1
  309. package/resources/customer/customer.mjs +9 -6
  310. package/resources/customer/customer.mjs.map +1 -1
  311. package/resources/customer/index.d.mts +4 -0
  312. package/resources/customer/index.d.mts.map +1 -0
  313. package/resources/customer/index.d.ts.map +1 -1
  314. package/resources/customer/profile.d.mts +30 -0
  315. package/resources/customer/profile.d.mts.map +1 -0
  316. package/resources/customer/profile.d.ts +4 -3
  317. package/resources/customer/profile.d.ts.map +1 -1
  318. package/resources/customer/profile.js +3 -2
  319. package/resources/customer/profile.js.map +1 -1
  320. package/resources/customer/profile.mjs +3 -2
  321. package/resources/customer/profile.mjs.map +1 -1
  322. package/resources/customer/remote.d.mts +164 -0
  323. package/resources/customer/remote.d.mts.map +1 -0
  324. package/resources/customer/remote.d.ts +5 -4
  325. package/resources/customer/remote.d.ts.map +1 -1
  326. package/resources/customer/remote.js +6 -5
  327. package/resources/customer/remote.js.map +1 -1
  328. package/resources/customer/remote.mjs +6 -5
  329. package/resources/customer/remote.mjs.map +1 -1
  330. package/resources/customer.d.mts +2 -0
  331. package/resources/customer.d.mts.map +1 -0
  332. package/resources/customer.d.ts.map +1 -1
  333. package/resources/customer.js +2 -15
  334. package/resources/customer.js.map +1 -1
  335. package/resources/index.d.mts +5 -0
  336. package/resources/index.d.mts.map +1 -0
  337. package/resources/index.d.ts +1 -1
  338. package/resources/index.d.ts.map +1 -1
  339. package/resources/index.js.map +1 -1
  340. package/resources/index.mjs.map +1 -1
  341. package/resources/ingest.d.mts +27 -0
  342. package/resources/ingest.d.mts.map +1 -0
  343. package/resources/ingest.d.ts +12 -6
  344. package/resources/ingest.d.ts.map +1 -1
  345. package/resources/ingest.js +11 -8
  346. package/resources/ingest.js.map +1 -1
  347. package/resources/ingest.mjs +11 -8
  348. package/resources/ingest.mjs.map +1 -1
  349. package/resources.d.mts +2 -0
  350. package/resources.d.mts.map +1 -0
  351. package/resources.d.ts.map +1 -1
  352. package/resources.js +2 -15
  353. package/resources.js.map +1 -1
  354. package/src/api-promise.ts +2 -0
  355. package/src/client.ts +835 -0
  356. package/src/core/README.md +3 -0
  357. package/src/core/api-promise.ts +92 -0
  358. package/src/core/error.ts +130 -0
  359. package/src/core/resource.ts +11 -0
  360. package/src/core/uploads.ts +2 -0
  361. package/src/error.ts +2 -130
  362. package/src/index.ts +6 -275
  363. package/src/internal/README.md +3 -0
  364. package/src/internal/builtin-types.ts +93 -0
  365. package/src/internal/detect-platform.ts +196 -0
  366. package/src/internal/errors.ts +33 -0
  367. package/src/internal/headers.ts +97 -0
  368. package/src/internal/parse.ts +56 -0
  369. package/src/internal/request-options.ts +91 -0
  370. package/src/internal/shim-types.ts +26 -0
  371. package/src/internal/shims.ts +107 -0
  372. package/src/internal/to-file.ts +156 -0
  373. package/src/internal/types.ts +95 -0
  374. package/src/internal/uploads.ts +187 -0
  375. package/src/internal/utils/base64.ts +40 -0
  376. package/src/internal/utils/bytes.ts +32 -0
  377. package/src/internal/utils/env.ts +18 -0
  378. package/src/internal/utils/log.ts +127 -0
  379. package/src/internal/utils/path.ts +88 -0
  380. package/src/internal/utils/sleep.ts +3 -0
  381. package/src/internal/utils/uuid.ts +17 -0
  382. package/src/internal/utils/values.ts +105 -0
  383. package/src/internal/utils.ts +8 -0
  384. package/src/lib/generate-signature.ts +2 -2
  385. package/src/resource.ts +2 -11
  386. package/src/resources/api-keys.ts +12 -9
  387. package/src/resources/conversation/chat.ts +60 -95
  388. package/src/resources/conversation/conversation.ts +1 -1
  389. package/src/resources/conversation/email.ts +13 -12
  390. package/src/resources/conversation/index.ts +5 -0
  391. package/src/resources/conversation/voice.ts +6 -4
  392. package/src/resources/customer/customer.ts +12 -16
  393. package/src/resources/customer/profile.ts +6 -8
  394. package/src/resources/customer/remote.ts +10 -8
  395. package/src/resources/index.ts +1 -1
  396. package/src/resources/ingest.ts +23 -17
  397. package/src/tsconfig.json +2 -2
  398. package/src/uploads.ts +2 -256
  399. package/src/version.ts +1 -1
  400. package/uploads.d.mts +2 -0
  401. package/uploads.d.mts.map +1 -0
  402. package/uploads.d.ts +1 -74
  403. package/uploads.d.ts.map +1 -1
  404. package/uploads.js +3 -167
  405. package/uploads.js.map +1 -1
  406. package/uploads.mjs +1 -156
  407. package/uploads.mjs.map +1 -1
  408. package/version.d.mts +2 -0
  409. package/version.d.mts.map +1 -0
  410. package/version.d.ts +1 -1
  411. package/version.js +1 -1
  412. package/version.mjs +1 -1
  413. package/_shims/MultipartBody.d.ts +0 -9
  414. package/_shims/MultipartBody.d.ts.map +0 -1
  415. package/_shims/MultipartBody.js +0 -16
  416. package/_shims/MultipartBody.js.map +0 -1
  417. package/_shims/MultipartBody.mjs +0 -12
  418. package/_shims/MultipartBody.mjs.map +0 -1
  419. package/_shims/README.md +0 -46
  420. package/_shims/auto/runtime-bun.d.ts +0 -5
  421. package/_shims/auto/runtime-bun.d.ts.map +0 -1
  422. package/_shims/auto/runtime-bun.js +0 -21
  423. package/_shims/auto/runtime-bun.js.map +0 -1
  424. package/_shims/auto/runtime-bun.mjs +0 -2
  425. package/_shims/auto/runtime-bun.mjs.map +0 -1
  426. package/_shims/auto/runtime-node.d.ts +0 -5
  427. package/_shims/auto/runtime-node.d.ts.map +0 -1
  428. package/_shims/auto/runtime-node.js +0 -21
  429. package/_shims/auto/runtime-node.js.map +0 -1
  430. package/_shims/auto/runtime-node.mjs +0 -2
  431. package/_shims/auto/runtime-node.mjs.map +0 -1
  432. package/_shims/auto/runtime.d.ts +0 -5
  433. package/_shims/auto/runtime.d.ts.map +0 -1
  434. package/_shims/auto/runtime.js +0 -21
  435. package/_shims/auto/runtime.js.map +0 -1
  436. package/_shims/auto/runtime.mjs +0 -2
  437. package/_shims/auto/runtime.mjs.map +0 -1
  438. package/_shims/auto/types-node.d.ts +0 -5
  439. package/_shims/auto/types-node.d.ts.map +0 -1
  440. package/_shims/auto/types-node.js +0 -21
  441. package/_shims/auto/types-node.js.map +0 -1
  442. package/_shims/auto/types-node.mjs +0 -2
  443. package/_shims/auto/types-node.mjs.map +0 -1
  444. package/_shims/auto/types.d.ts +0 -101
  445. package/_shims/auto/types.js +0 -3
  446. package/_shims/auto/types.mjs +0 -3
  447. package/_shims/bun-runtime.d.ts +0 -6
  448. package/_shims/bun-runtime.d.ts.map +0 -1
  449. package/_shims/bun-runtime.js +0 -13
  450. package/_shims/bun-runtime.js.map +0 -1
  451. package/_shims/bun-runtime.mjs +0 -10
  452. package/_shims/bun-runtime.mjs.map +0 -1
  453. package/_shims/index.d.ts +0 -83
  454. package/_shims/index.js +0 -17
  455. package/_shims/index.mjs +0 -11
  456. package/_shims/manual-types.d.ts +0 -12
  457. package/_shims/manual-types.js +0 -3
  458. package/_shims/manual-types.mjs +0 -3
  459. package/_shims/node-runtime.d.ts +0 -3
  460. package/_shims/node-runtime.d.ts.map +0 -1
  461. package/_shims/node-runtime.js +0 -88
  462. package/_shims/node-runtime.js.map +0 -1
  463. package/_shims/node-runtime.mjs +0 -56
  464. package/_shims/node-runtime.mjs.map +0 -1
  465. package/_shims/node-types.d.ts +0 -42
  466. package/_shims/node-types.js +0 -3
  467. package/_shims/node-types.mjs +0 -3
  468. package/_shims/registry.d.ts +0 -37
  469. package/_shims/registry.d.ts.map +0 -1
  470. package/_shims/registry.js +0 -41
  471. package/_shims/registry.js.map +0 -1
  472. package/_shims/registry.mjs +0 -37
  473. package/_shims/registry.mjs.map +0 -1
  474. package/_shims/web-runtime.d.ts +0 -5
  475. package/_shims/web-runtime.d.ts.map +0 -1
  476. package/_shims/web-runtime.js +0 -77
  477. package/_shims/web-runtime.js.map +0 -1
  478. package/_shims/web-runtime.mjs +0 -71
  479. package/_shims/web-runtime.mjs.map +0 -1
  480. package/_shims/web-types.d.ts +0 -83
  481. package/_shims/web-types.js +0 -3
  482. package/_shims/web-types.mjs +0 -3
  483. package/core.d.ts +0 -253
  484. package/core.d.ts.map +0 -1
  485. package/core.js +0 -929
  486. package/core.js.map +0 -1
  487. package/core.mjs +0 -897
  488. package/core.mjs.map +0 -1
  489. package/internal/qs/formats.d.ts +0 -6
  490. package/internal/qs/formats.d.ts.map +0 -1
  491. package/internal/qs/formats.js +0 -11
  492. package/internal/qs/formats.js.map +0 -1
  493. package/internal/qs/formats.mjs +0 -8
  494. package/internal/qs/formats.mjs.map +0 -1
  495. package/internal/qs/index.d.ts +0 -10
  496. package/internal/qs/index.d.ts.map +0 -1
  497. package/internal/qs/index.js +0 -14
  498. package/internal/qs/index.js.map +0 -1
  499. package/internal/qs/index.mjs +0 -10
  500. package/internal/qs/index.mjs.map +0 -1
  501. package/internal/qs/stringify.d.ts +0 -3
  502. package/internal/qs/stringify.d.ts.map +0 -1
  503. package/internal/qs/stringify.js +0 -279
  504. package/internal/qs/stringify.js.map +0 -1
  505. package/internal/qs/stringify.mjs +0 -276
  506. package/internal/qs/stringify.mjs.map +0 -1
  507. package/internal/qs/types.d.ts +0 -57
  508. package/internal/qs/types.d.ts.map +0 -1
  509. package/internal/qs/types.js +0 -3
  510. package/internal/qs/types.js.map +0 -1
  511. package/internal/qs/types.mjs +0 -2
  512. package/internal/qs/types.mjs.map +0 -1
  513. package/internal/qs/utils.d.ts +0 -14
  514. package/internal/qs/utils.d.ts.map +0 -1
  515. package/internal/qs/utils.js +0 -229
  516. package/internal/qs/utils.js.map +0 -1
  517. package/internal/qs/utils.mjs +0 -217
  518. package/internal/qs/utils.mjs.map +0 -1
  519. package/resources/ticket.d.ts +0 -14
  520. package/resources/ticket.d.ts.map +0 -1
  521. package/resources/ticket.js +0 -16
  522. package/resources/ticket.js.map +0 -1
  523. package/resources/ticket.mjs +0 -12
  524. package/resources/ticket.mjs.map +0 -1
  525. package/shims/node.d.ts +0 -26
  526. package/shims/node.d.ts.map +0 -1
  527. package/shims/node.js +0 -6
  528. package/shims/node.js.map +0 -1
  529. package/shims/node.mjs +0 -4
  530. package/shims/node.mjs.map +0 -1
  531. package/shims/web.d.ts +0 -26
  532. package/shims/web.d.ts.map +0 -1
  533. package/shims/web.js +0 -6
  534. package/shims/web.js.map +0 -1
  535. package/shims/web.mjs +0 -4
  536. package/shims/web.mjs.map +0 -1
  537. package/src/_shims/MultipartBody.ts +0 -9
  538. package/src/_shims/README.md +0 -46
  539. package/src/_shims/auto/runtime-bun.ts +0 -4
  540. package/src/_shims/auto/runtime-node.ts +0 -4
  541. package/src/_shims/auto/runtime.ts +0 -4
  542. package/src/_shims/auto/types-node.ts +0 -4
  543. package/src/_shims/auto/types.d.ts +0 -101
  544. package/src/_shims/auto/types.js +0 -3
  545. package/src/_shims/auto/types.mjs +0 -3
  546. package/src/_shims/bun-runtime.ts +0 -14
  547. package/src/_shims/index.d.ts +0 -83
  548. package/src/_shims/index.js +0 -17
  549. package/src/_shims/index.mjs +0 -11
  550. package/src/_shims/manual-types.d.ts +0 -12
  551. package/src/_shims/manual-types.js +0 -3
  552. package/src/_shims/manual-types.mjs +0 -3
  553. package/src/_shims/node-runtime.ts +0 -81
  554. package/src/_shims/node-types.d.ts +0 -42
  555. package/src/_shims/node-types.js +0 -3
  556. package/src/_shims/node-types.mjs +0 -3
  557. package/src/_shims/registry.ts +0 -67
  558. package/src/_shims/web-runtime.ts +0 -103
  559. package/src/_shims/web-types.d.ts +0 -83
  560. package/src/_shims/web-types.js +0 -3
  561. package/src/_shims/web-types.mjs +0 -3
  562. package/src/core.ts +0 -1242
  563. package/src/internal/qs/LICENSE.md +0 -13
  564. package/src/internal/qs/README.md +0 -3
  565. package/src/internal/qs/formats.ts +0 -9
  566. package/src/internal/qs/index.ts +0 -13
  567. package/src/internal/qs/stringify.ts +0 -388
  568. package/src/internal/qs/types.ts +0 -71
  569. package/src/internal/qs/utils.ts +0 -265
  570. package/src/resources/ticket.ts +0 -30
  571. package/src/shims/node.ts +0 -50
  572. package/src/shims/web.ts +0 -50
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../resource';
3
+ import { APIResource } from '../../core/resource';
4
4
  import * as ChatAPI from './chat';
5
5
  import {
6
6
  Chat,
@@ -1,9 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../resource';
4
- import * as Core from '../../core';
5
- import { pollUntil } from "../../lib/poll-until";
3
+ import { APIResource } from '../../core/resource';
6
4
  import * as ConversationAPI from './conversation';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { pollUntil } from '../../lib/poll-until';
7
8
 
8
9
  export class Email extends APIResource {
9
10
  /**
@@ -22,7 +23,7 @@ export class Email extends APIResource {
22
23
  * });
23
24
  * ```
24
25
  */
25
- generate(body: EmailGenerateParams, options?: Core.RequestOptions): Core.APIPromise<EmailGenerateResponse> {
26
+ generate(body: EmailGenerateParams, options?: RequestOptions): APIPromise<EmailGenerateResponse> {
26
27
  return this._client.post('/v1/conversation/email/message', { body, ...options });
27
28
  }
28
29
 
@@ -34,7 +35,7 @@ export class Email extends APIResource {
34
35
  * });
35
36
  * ```
36
37
  */
37
- get(query: EmailGetParams, options?: Core.RequestOptions): Core.APIPromise<EmailGetResponse> {
38
+ get(query: EmailGetParams, options?: RequestOptions): APIPromise<EmailGetResponse> {
38
39
  return this._client.get('/v1/conversation/email/message', { query, ...options });
39
40
  }
40
41
 
@@ -47,23 +48,23 @@ export class Email extends APIResource {
47
48
  * });
48
49
  * ```
49
50
  */
50
- start(body: EmailStartParams, options?: Core.RequestOptions): Core.APIPromise<EmailStartResponse> {
51
+ start(body: EmailStartParams, options?: RequestOptions): APIPromise<EmailStartResponse> {
51
52
  return this._client.post('/v1/conversation/email/create', { body, ...options });
52
53
  }
53
54
 
54
55
  /**
55
- * __chat.get__
56
+ * Poll until the conversation has a bot response ready.
56
57
  *
57
- * Polls until it returns a BOT chat message for a conversation.
58
+ * Stops when `latestMessageType` is `BOT_RESPONSE` or `PENDING_RESPONSE`,
59
+ * or when `status` is `Escalated` or `Error`.
58
60
  */
59
- poll(query: EmailGetParams, options?: Core.RequestOptions): Core.APIPromise<EmailGetResponse> {
61
+ poll(query: EmailGetParams, options?: RequestOptions): APIPromise<EmailGetResponse> {
60
62
  return pollUntil<EmailGetResponse>(
61
- () => this._client.get('/v1/conversation/chat/message', { query, ...options }),
63
+ () => this._client.get('/v1/conversation/email/message', { query, ...options }),
62
64
  {
63
65
  timeout: options?.timeout || 180_000,
64
66
  interval: 2_000,
65
67
  condition: (conversation) => {
66
- // Don't poll if the conversation is escalated or in error
67
68
  if (conversation.status === 'Escalated' || conversation.status === 'Error') {
68
69
  return true;
69
70
  }
@@ -78,7 +79,7 @@ export class Email extends APIResource {
78
79
  return false;
79
80
  },
80
81
  },
81
- ) as Core.APIPromise<EmailGetResponse>;
82
+ ) as APIPromise<EmailGetResponse>;
82
83
  }
83
84
  }
84
85
 
@@ -8,6 +8,11 @@ export {
8
8
  type ChatGenerateParams,
9
9
  type ChatGetParams,
10
10
  type ChatStartParams,
11
+ type ChatStreamParams,
12
+ type ChatStreamEvent,
13
+ type ChatStreamNewMessageEvent,
14
+ type ChatStreamMessageChunkEvent,
15
+ type ChatStreamMessageCompleteEvent,
11
16
  } from './chat';
12
17
  export { Conversation, type AttachmentDto, type TicketEvent, type TicketMessageDto } from './conversation';
13
18
  export {
@@ -1,7 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../resource';
4
- import * as Core from '../../core';
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { buildHeaders } from '../../internal/headers';
6
+ import { RequestOptions } from '../../internal/request-options';
5
7
 
6
8
  export class Voice extends APIResource {
7
9
  /**
@@ -12,11 +14,11 @@ export class Voice extends APIResource {
12
14
  * });
13
15
  * ```
14
16
  */
15
- outbound(body: VoiceOutboundParams, options?: Core.RequestOptions): Core.APIPromise<void> {
17
+ outbound(body: VoiceOutboundParams, options?: RequestOptions): APIPromise<void> {
16
18
  return this._client.post('/v1/conversation/voice/outbound', {
17
19
  body,
18
20
  ...options,
19
- headers: { Accept: '*/*', ...options?.headers },
21
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
20
22
  });
21
23
  }
22
24
  }
@@ -1,12 +1,13 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../resource';
4
- import { isRequestOptions } from '../../core';
5
- import * as Core from '../../core';
3
+ import { APIResource } from '../../core/resource';
6
4
  import * as ProfileAPI from './profile';
7
5
  import { Profile, ProfileSyncParams, ProfileSyncResponse } from './profile';
8
6
  import * as RemoteAPI from './remote';
9
7
  import { Remote, RemoteGetResponse, RemoteUpdateParams, RemoteUpdateResponse } from './remote';
8
+ import { APIPromise } from '../../core/api-promise';
9
+ import { RequestOptions } from '../../internal/request-options';
10
+ import { path } from '../../internal/utils/path';
10
11
 
11
12
  export class Customer extends APIResource {
12
13
  remote: RemoteAPI.Remote = new RemoteAPI.Remote(this._client);
@@ -18,7 +19,7 @@ export class Customer extends APIResource {
18
19
  * const customer = await client.customer.create();
19
20
  * ```
20
21
  */
21
- create(body: CustomerCreateParams, options?: Core.RequestOptions): Core.APIPromise<CustomerCreateResponse> {
22
+ create(body: CustomerCreateParams, options?: RequestOptions): APIPromise<CustomerCreateResponse> {
22
23
  return this._client.post('/v1/customer', { body, ...options });
23
24
  }
24
25
 
@@ -33,9 +34,9 @@ export class Customer extends APIResource {
33
34
  update(
34
35
  id: string,
35
36
  body: CustomerUpdateParams,
36
- options?: Core.RequestOptions,
37
- ): Core.APIPromise<CustomerUpdateResponse> {
38
- return this._client.put(`/v1/customer/${id}`, { body, ...options });
37
+ options?: RequestOptions,
38
+ ): APIPromise<CustomerUpdateResponse> {
39
+ return this._client.put(path`/v1/customer/${id}`, { body, ...options });
39
40
  }
40
41
 
41
42
  /**
@@ -44,15 +45,10 @@ export class Customer extends APIResource {
44
45
  * const customer = await client.customer.get();
45
46
  * ```
46
47
  */
47
- get(query?: CustomerGetParams, options?: Core.RequestOptions): Core.APIPromise<CustomerGetResponse>;
48
- get(options?: Core.RequestOptions): Core.APIPromise<CustomerGetResponse>;
49
48
  get(
50
- query: CustomerGetParams | Core.RequestOptions = {},
51
- options?: Core.RequestOptions,
52
- ): Core.APIPromise<CustomerGetResponse> {
53
- if (isRequestOptions(query)) {
54
- return this.get({}, query);
55
- }
49
+ query: CustomerGetParams | null | undefined = {},
50
+ options?: RequestOptions,
51
+ ): APIPromise<CustomerGetResponse> {
56
52
  return this._client.get('/v1/customer', { query, ...options });
57
53
  }
58
54
 
@@ -62,7 +58,7 @@ export class Customer extends APIResource {
62
58
  * const response = await client.customer.token();
63
59
  * ```
64
60
  */
65
- token(body: CustomerTokenParams, options?: Core.RequestOptions): Core.APIPromise<string> {
61
+ token(body: CustomerTokenParams, options?: RequestOptions): APIPromise<string> {
66
62
  return this._client.post('/v1/customer/token', { body, ...options });
67
63
  }
68
64
  }
@@ -1,7 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../resource';
4
- import * as Core from '../../core';
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { RequestOptions } from '../../internal/request-options';
6
+ import { path } from '../../internal/utils/path';
5
7
 
6
8
  export class Profile extends APIResource {
7
9
  /**
@@ -13,12 +15,8 @@ export class Profile extends APIResource {
13
15
  * );
14
16
  * ```
15
17
  */
16
- sync(
17
- id: string,
18
- body: ProfileSyncParams,
19
- options?: Core.RequestOptions,
20
- ): Core.APIPromise<ProfileSyncResponse> {
21
- return this._client.put(`/v1/customer/profile/${id}`, { body, ...options });
18
+ sync(id: string, body: ProfileSyncParams, options?: RequestOptions): APIPromise<ProfileSyncResponse> {
19
+ return this._client.put(path`/v1/customer/profile/${id}`, { body, ...options });
22
20
  }
23
21
  }
24
22
 
@@ -1,7 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../resource';
4
- import * as Core from '../../core';
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { RequestOptions } from '../../internal/request-options';
6
+ import { path } from '../../internal/utils/path';
5
7
 
6
8
  export class Remote extends APIResource {
7
9
  /**
@@ -13,11 +15,11 @@ export class Remote extends APIResource {
13
15
  * ```
14
16
  */
15
17
  update(
16
- pathRemoteId: string,
18
+ remoteID: string,
17
19
  body: RemoteUpdateParams,
18
- options?: Core.RequestOptions,
19
- ): Core.APIPromise<RemoteUpdateResponse> {
20
- return this._client.patch(`/v1/customer/remote/${pathRemoteId}`, { body, ...options });
20
+ options?: RequestOptions,
21
+ ): APIPromise<RemoteUpdateResponse> {
22
+ return this._client.patch(path`/v1/customer/remote/${remoteID}`, { body, ...options });
21
23
  }
22
24
 
23
25
  /**
@@ -26,8 +28,8 @@ export class Remote extends APIResource {
26
28
  * const remote = await client.customer.remote.get('remoteId');
27
29
  * ```
28
30
  */
29
- get(remoteId: string, options?: Core.RequestOptions): Core.APIPromise<RemoteGetResponse> {
30
- return this._client.get(`/v1/customer/remote/${remoteId}`, options);
31
+ get(remoteID: string, options?: RequestOptions): APIPromise<RemoteGetResponse> {
32
+ return this._client.get(path`/v1/customer/remote/${remoteID}`, options);
31
33
  }
32
34
  }
33
35
 
@@ -24,4 +24,4 @@ export {
24
24
  type CustomerGetParams,
25
25
  type CustomerTokenParams,
26
26
  } from './customer/customer';
27
- export { Ingest, type IngestTestParams } from './ingest';
27
+ export { Ingest, type IngestSubmitParams, type IngestTestParams } from './ingest';
@@ -1,38 +1,44 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../resource';
4
- import * as Core from '../core';
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { buildHeaders } from '../internal/headers';
6
+ import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
5
8
 
6
9
  export class Ingest extends APIResource {
7
- submit(
8
- toolId: string,
9
- ticketId: string,
10
- inputHash: string,
11
- workflowId: string,
12
- options?: Core.RequestOptions,
13
- ): Core.APIPromise<void> {
14
- return this._client.post(`/ingest/${toolId}/${ticketId}/${inputHash}/${workflowId}`, {
10
+ submit(workflowID: string, params: IngestSubmitParams, options?: RequestOptions): APIPromise<void> {
11
+ const { toolId, ticketId, inputHash } = params;
12
+ return this._client.post(path`/ingest/${toolId}/${ticketId}/${inputHash}/${workflowID}`, {
15
13
  ...options,
16
- headers: { Accept: '*/*', ...options?.headers },
14
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
17
15
  });
18
16
  }
19
17
 
20
- test(toolId: unknown, body: IngestTestParams, options?: Core.RequestOptions): Core.APIPromise<void> {
21
- return this._client.post(`/ingest/test/${toolId}`, {
18
+ test(toolID: string, body: IngestTestParams, options?: RequestOptions): APIPromise<void> {
19
+ return this._client.post(path`/ingest/test/${toolID}`, {
22
20
  body,
23
21
  ...options,
24
- headers: { Accept: '*/*', ...options?.headers },
22
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
25
23
  });
26
24
  }
27
25
 
28
- validate(options?: Core.RequestOptions): Core.APIPromise<void> {
26
+ validate(options?: RequestOptions): APIPromise<void> {
29
27
  return this._client.post('/ingest/validate', {
30
28
  ...options,
31
- headers: { Accept: '*/*', ...options?.headers },
29
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
32
30
  });
33
31
  }
34
32
  }
35
33
 
34
+ export interface IngestSubmitParams {
35
+ toolId: string;
36
+
37
+ ticketId: string;
38
+
39
+ inputHash: string;
40
+ }
41
+
36
42
  export interface IngestTestParams {
37
43
  /**
38
44
  * The input data to simulate a test response for.
@@ -46,5 +52,5 @@ export interface IngestTestParams {
46
52
  }
47
53
 
48
54
  export declare namespace Ingest {
49
- export { type IngestTestParams as IngestTestParams };
55
+ export { type IngestSubmitParams as IngestSubmitParams, type IngestTestParams as IngestTestParams };
50
56
  }
package/src/tsconfig.json CHANGED
@@ -4,8 +4,8 @@
4
4
  // via declaration maps
5
5
  "include": ["index.ts"],
6
6
  "compilerOptions": {
7
- "target": "es2015",
8
- "lib": ["DOM"],
7
+ "target": "ES2015",
8
+ "lib": ["DOM", "DOM.Iterable", "ES2018"],
9
9
  "moduleResolution": "node"
10
10
  }
11
11
  }
package/src/uploads.ts CHANGED
@@ -1,256 +1,2 @@
1
- import { type RequestOptions } from './core';
2
- import {
3
- FormData,
4
- File,
5
- type Blob,
6
- type FilePropertyBag,
7
- getMultipartRequestOptions,
8
- type FsReadStream,
9
- isFsReadStream,
10
- } from './_shims/index';
11
- import { MultipartBody } from './_shims/MultipartBody';
12
- export { fileFromPath } from './_shims/index';
13
-
14
- type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
15
- export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
16
-
17
- /**
18
- * Typically, this is a native "File" class.
19
- *
20
- * We provide the {@link toFile} utility to convert a variety of objects
21
- * into the File class.
22
- *
23
- * For convenience, you can also pass a fetch Response, or in Node,
24
- * the result of fs.createReadStream().
25
- */
26
- export type Uploadable = FileLike | ResponseLike | FsReadStream;
27
-
28
- /**
29
- * Intended to match web.Blob, node.Blob, node-fetch.Blob, etc.
30
- */
31
- export interface BlobLike {
32
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
33
- readonly size: number;
34
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
35
- readonly type: string;
36
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
37
- text(): Promise<string>;
38
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
39
- slice(start?: number, end?: number): BlobLike;
40
- // unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method
41
- }
42
-
43
- /**
44
- * Intended to match web.File, node.File, node-fetch.File, etc.
45
- */
46
- export interface FileLike extends BlobLike {
47
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
48
- readonly lastModified: number;
49
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
50
- readonly name: string;
51
- }
52
-
53
- /**
54
- * Intended to match web.Response, node.Response, node-fetch.Response, etc.
55
- */
56
- export interface ResponseLike {
57
- url: string;
58
- blob(): Promise<BlobLike>;
59
- }
60
-
61
- export const isResponseLike = (value: any): value is ResponseLike =>
62
- value != null &&
63
- typeof value === 'object' &&
64
- typeof value.url === 'string' &&
65
- typeof value.blob === 'function';
66
-
67
- export const isFileLike = (value: any): value is FileLike =>
68
- value != null &&
69
- typeof value === 'object' &&
70
- typeof value.name === 'string' &&
71
- typeof value.lastModified === 'number' &&
72
- isBlobLike(value);
73
-
74
- /**
75
- * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
76
- * adds the arrayBuffer() method type because it is available and used at runtime
77
- */
78
- export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise<ArrayBuffer> } =>
79
- value != null &&
80
- typeof value === 'object' &&
81
- typeof value.size === 'number' &&
82
- typeof value.type === 'string' &&
83
- typeof value.text === 'function' &&
84
- typeof value.slice === 'function' &&
85
- typeof value.arrayBuffer === 'function';
86
-
87
- export const isUploadable = (value: any): value is Uploadable => {
88
- return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
89
- };
90
-
91
- export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
92
-
93
- /**
94
- * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
95
- * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
96
- * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
97
- * @param {Object=} options additional properties
98
- * @param {string=} options.type the MIME type of the content
99
- * @param {number=} options.lastModified the last modified timestamp
100
- * @returns a {@link File} with the given properties
101
- */
102
- export async function toFile(
103
- value: ToFileInput | PromiseLike<ToFileInput>,
104
- name?: string | null | undefined,
105
- options?: FilePropertyBag | undefined,
106
- ): Promise<FileLike> {
107
- // If it's a promise, resolve it.
108
- value = await value;
109
-
110
- // If we've been given a `File` we don't need to do anything
111
- if (isFileLike(value)) {
112
- return value;
113
- }
114
-
115
- if (isResponseLike(value)) {
116
- const blob = await value.blob();
117
- name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';
118
-
119
- // we need to convert the `Blob` into an array buffer because the `Blob` class
120
- // that `node-fetch` defines is incompatible with the web standard which results
121
- // in `new File` interpreting it as a string instead of binary data.
122
- const data = isBlobLike(blob) ? [(await blob.arrayBuffer()) as any] : [blob];
123
-
124
- return new File(data, name, options);
125
- }
126
-
127
- const bits = await getBytes(value);
128
-
129
- name ||= getName(value) ?? 'unknown_file';
130
-
131
- if (!options?.type) {
132
- const type = (bits[0] as any)?.type;
133
- if (typeof type === 'string') {
134
- options = { ...options, type };
135
- }
136
- }
137
-
138
- return new File(bits, name, options);
139
- }
140
-
141
- async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
142
- let parts: Array<BlobPart> = [];
143
- if (
144
- typeof value === 'string' ||
145
- ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
146
- value instanceof ArrayBuffer
147
- ) {
148
- parts.push(value);
149
- } else if (isBlobLike(value)) {
150
- parts.push(await value.arrayBuffer());
151
- } else if (
152
- isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
153
- ) {
154
- for await (const chunk of value) {
155
- parts.push(chunk as BlobPart); // TODO, consider validating?
156
- }
157
- } else {
158
- throw new Error(
159
- `Unexpected data type: ${typeof value}; constructor: ${
160
- value?.constructor?.name
161
- }; props: ${propsForError(value)}`,
162
- );
163
- }
164
-
165
- return parts;
166
- }
167
-
168
- function propsForError(value: any): string {
169
- const props = Object.getOwnPropertyNames(value);
170
- return `[${props.map((p) => `"${p}"`).join(', ')}]`;
171
- }
172
-
173
- function getName(value: any): string | undefined {
174
- return (
175
- getStringFromMaybeBuffer(value.name) ||
176
- getStringFromMaybeBuffer(value.filename) ||
177
- // For fs.ReadStream
178
- getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop()
179
- );
180
- }
181
-
182
- const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => {
183
- if (typeof x === 'string') return x;
184
- if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x);
185
- return undefined;
186
- };
187
-
188
- const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator<unknown> =>
189
- value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
190
-
191
- export const isMultipartBody = (body: any): body is MultipartBody =>
192
- body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody';
193
-
194
- /**
195
- * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
196
- * Otherwise returns the request as is.
197
- */
198
- export const maybeMultipartFormRequestOptions = async <T = Record<string, unknown>>(
199
- opts: RequestOptions<T>,
200
- ): Promise<RequestOptions<T | MultipartBody>> => {
201
- if (!hasUploadableValue(opts.body)) return opts;
202
-
203
- const form = await createForm(opts.body);
204
- return getMultipartRequestOptions(form, opts);
205
- };
206
-
207
- export const multipartFormRequestOptions = async <T = Record<string, unknown>>(
208
- opts: RequestOptions<T>,
209
- ): Promise<RequestOptions<T | MultipartBody>> => {
210
- const form = await createForm(opts.body);
211
- return getMultipartRequestOptions(form, opts);
212
- };
213
-
214
- export const createForm = async <T = Record<string, unknown>>(body: T | undefined): Promise<FormData> => {
215
- const form = new FormData();
216
- await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
217
- return form;
218
- };
219
-
220
- const hasUploadableValue = (value: unknown): boolean => {
221
- if (isUploadable(value)) return true;
222
- if (Array.isArray(value)) return value.some(hasUploadableValue);
223
- if (value && typeof value === 'object') {
224
- for (const k in value) {
225
- if (hasUploadableValue((value as any)[k])) return true;
226
- }
227
- }
228
- return false;
229
- };
230
-
231
- const addFormValue = async (form: FormData, key: string, value: unknown): Promise<void> => {
232
- if (value === undefined) return;
233
- if (value == null) {
234
- throw new TypeError(
235
- `Received null for "${key}"; to pass null in FormData, you must use the string 'null'`,
236
- );
237
- }
238
-
239
- // TODO: make nested formats configurable
240
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
241
- form.append(key, String(value));
242
- } else if (isUploadable(value)) {
243
- const file = await toFile(value);
244
- form.append(key, file as File);
245
- } else if (Array.isArray(value)) {
246
- await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
247
- } else if (typeof value === 'object') {
248
- await Promise.all(
249
- Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)),
250
- );
251
- } else {
252
- throw new TypeError(
253
- `Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`,
254
- );
255
- }
256
- };
1
+ /** @deprecated Import from ./core/uploads instead */
2
+ export * from './core/uploads';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.8.1'; // x-release-please-version
1
+ export const VERSION = '0.1.0'; // x-release-please-version
package/uploads.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./core/uploads.mjs";
2
+ //# sourceMappingURL=uploads.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.d.mts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":""}