@paid-ai/paid-node 0.0.5

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 (383) hide show
  1. package/README.md +166 -0
  2. package/dist/cjs/Client.d.ts +44 -0
  3. package/dist/cjs/Client.js +79 -0
  4. package/dist/cjs/api/index.d.ts +2 -0
  5. package/dist/cjs/api/index.js +18 -0
  6. package/dist/cjs/api/resources/agents/client/Client.d.ts +107 -0
  7. package/dist/cjs/api/resources/agents/client/Client.js +464 -0
  8. package/dist/cjs/api/resources/agents/client/index.d.ts +1 -0
  9. package/dist/cjs/api/resources/agents/client/index.js +17 -0
  10. package/dist/cjs/api/resources/agents/client/requests/AgentCreate.d.ts +16 -0
  11. package/dist/cjs/api/resources/agents/client/requests/AgentCreate.js +5 -0
  12. package/dist/cjs/api/resources/agents/client/requests/index.d.ts +1 -0
  13. package/dist/cjs/api/resources/agents/client/requests/index.js +2 -0
  14. package/dist/cjs/api/resources/agents/index.d.ts +1 -0
  15. package/dist/cjs/api/resources/agents/index.js +17 -0
  16. package/dist/cjs/api/resources/contacts/client/Client.d.ts +93 -0
  17. package/dist/cjs/api/resources/contacts/client/Client.js +366 -0
  18. package/dist/cjs/api/resources/contacts/client/index.d.ts +1 -0
  19. package/dist/cjs/api/resources/contacts/client/index.js +17 -0
  20. package/dist/cjs/api/resources/contacts/client/requests/ContactCreate.d.ts +32 -0
  21. package/dist/cjs/api/resources/contacts/client/requests/ContactCreate.js +5 -0
  22. package/dist/cjs/api/resources/contacts/client/requests/index.d.ts +1 -0
  23. package/dist/cjs/api/resources/contacts/client/requests/index.js +2 -0
  24. package/dist/cjs/api/resources/contacts/index.d.ts +1 -0
  25. package/dist/cjs/api/resources/contacts/index.js +17 -0
  26. package/dist/cjs/api/resources/customers/client/Client.d.ts +106 -0
  27. package/dist/cjs/api/resources/customers/client/Client.js +463 -0
  28. package/dist/cjs/api/resources/customers/client/index.d.ts +1 -0
  29. package/dist/cjs/api/resources/customers/client/index.js +17 -0
  30. package/dist/cjs/api/resources/customers/client/requests/CustomerCreate.d.ts +21 -0
  31. package/dist/cjs/api/resources/customers/client/requests/CustomerCreate.js +5 -0
  32. package/dist/cjs/api/resources/customers/client/requests/index.d.ts +1 -0
  33. package/dist/cjs/api/resources/customers/client/requests/index.js +2 -0
  34. package/dist/cjs/api/resources/customers/index.d.ts +1 -0
  35. package/dist/cjs/api/resources/customers/index.js +17 -0
  36. package/dist/cjs/api/resources/index.d.ts +10 -0
  37. package/dist/cjs/api/resources/index.js +49 -0
  38. package/dist/cjs/api/resources/orders/client/Client.d.ts +84 -0
  39. package/dist/cjs/api/resources/orders/client/Client.js +320 -0
  40. package/dist/cjs/api/resources/orders/client/index.d.ts +1 -0
  41. package/dist/cjs/api/resources/orders/client/index.js +17 -0
  42. package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +25 -0
  43. package/dist/cjs/api/resources/orders/client/requests/OrderCreate.js +5 -0
  44. package/dist/cjs/api/resources/orders/client/requests/index.d.ts +1 -0
  45. package/dist/cjs/api/resources/orders/client/requests/index.js +2 -0
  46. package/dist/cjs/api/resources/orders/index.d.ts +2 -0
  47. package/dist/cjs/api/resources/orders/index.js +18 -0
  48. package/dist/cjs/api/resources/orders/resources/index.d.ts +2 -0
  49. package/dist/cjs/api/resources/orders/resources/index.js +41 -0
  50. package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +41 -0
  51. package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +119 -0
  52. package/dist/cjs/api/resources/orders/resources/lines/client/index.d.ts +1 -0
  53. package/dist/cjs/api/resources/orders/resources/lines/client/index.js +17 -0
  54. package/dist/cjs/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.ts +11 -0
  55. package/dist/cjs/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.js +5 -0
  56. package/dist/cjs/api/resources/orders/resources/lines/client/requests/index.d.ts +1 -0
  57. package/dist/cjs/api/resources/orders/resources/lines/client/requests/index.js +2 -0
  58. package/dist/cjs/api/resources/orders/resources/lines/index.d.ts +1 -0
  59. package/dist/cjs/api/resources/orders/resources/lines/index.js +17 -0
  60. package/dist/cjs/api/resources/usage/client/Client.d.ts +40 -0
  61. package/dist/cjs/api/resources/usage/client/Client.js +118 -0
  62. package/dist/cjs/api/resources/usage/client/index.d.ts +1 -0
  63. package/dist/cjs/api/resources/usage/client/index.js +17 -0
  64. package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkRequest.d.ts +11 -0
  65. package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkRequest.js +5 -0
  66. package/dist/cjs/api/resources/usage/client/requests/index.d.ts +1 -0
  67. package/dist/cjs/api/resources/usage/client/requests/index.js +2 -0
  68. package/dist/cjs/api/resources/usage/index.d.ts +1 -0
  69. package/dist/cjs/api/resources/usage/index.js +17 -0
  70. package/dist/cjs/api/types/Address.d.ts +11 -0
  71. package/dist/cjs/api/types/Address.js +5 -0
  72. package/dist/cjs/api/types/Agent.d.ts +14 -0
  73. package/dist/cjs/api/types/Agent.js +5 -0
  74. package/dist/cjs/api/types/AgentAttribute.d.ts +9 -0
  75. package/dist/cjs/api/types/AgentAttribute.js +5 -0
  76. package/dist/cjs/api/types/AgentPricePoint.d.ts +10 -0
  77. package/dist/cjs/api/types/AgentPricePoint.js +5 -0
  78. package/dist/cjs/api/types/AgentPricePointTiers.d.ts +8 -0
  79. package/dist/cjs/api/types/AgentPricePointTiers.js +5 -0
  80. package/dist/cjs/api/types/AgentUpdate.d.ts +12 -0
  81. package/dist/cjs/api/types/AgentUpdate.js +5 -0
  82. package/dist/cjs/api/types/ApiError.d.ts +12 -0
  83. package/dist/cjs/api/types/ApiError.js +5 -0
  84. package/dist/cjs/api/types/BillingFrequency.d.ts +9 -0
  85. package/dist/cjs/api/types/BillingFrequency.js +11 -0
  86. package/dist/cjs/api/types/ChargeType.d.ts +10 -0
  87. package/dist/cjs/api/types/ChargeType.js +12 -0
  88. package/dist/cjs/api/types/Contact.d.ts +21 -0
  89. package/dist/cjs/api/types/Contact.js +5 -0
  90. package/dist/cjs/api/types/CreationSource.d.ts +10 -0
  91. package/dist/cjs/api/types/CreationSource.js +12 -0
  92. package/dist/cjs/api/types/CreationState.d.ts +8 -0
  93. package/dist/cjs/api/types/CreationState.js +10 -0
  94. package/dist/cjs/api/types/Customer.d.ts +18 -0
  95. package/dist/cjs/api/types/Customer.js +5 -0
  96. package/dist/cjs/api/types/CustomerUpdate.d.ts +15 -0
  97. package/dist/cjs/api/types/CustomerUpdate.js +5 -0
  98. package/dist/cjs/api/types/Error_.d.ts +10 -0
  99. package/dist/cjs/api/types/Error_.js +5 -0
  100. package/dist/cjs/api/types/Order.d.ts +22 -0
  101. package/dist/cjs/api/types/Order.js +5 -0
  102. package/dist/cjs/api/types/OrderLine.d.ts +20 -0
  103. package/dist/cjs/api/types/OrderLine.js +5 -0
  104. package/dist/cjs/api/types/OrderLineAttribute.d.ts +10 -0
  105. package/dist/cjs/api/types/OrderLineAttribute.js +5 -0
  106. package/dist/cjs/api/types/OrderLineAttributePricing.d.ts +11 -0
  107. package/dist/cjs/api/types/OrderLineAttributePricing.js +5 -0
  108. package/dist/cjs/api/types/OrderLineCreate.d.ts +9 -0
  109. package/dist/cjs/api/types/OrderLineCreate.js +5 -0
  110. package/dist/cjs/api/types/PricePoint.d.ts +10 -0
  111. package/dist/cjs/api/types/PricePoint.js +5 -0
  112. package/dist/cjs/api/types/Pricing.d.ts +12 -0
  113. package/dist/cjs/api/types/Pricing.js +5 -0
  114. package/dist/cjs/api/types/PricingModelType.d.ts +9 -0
  115. package/dist/cjs/api/types/PricingModelType.js +11 -0
  116. package/dist/cjs/api/types/Salutation.d.ts +12 -0
  117. package/dist/cjs/api/types/Salutation.js +14 -0
  118. package/dist/cjs/api/types/Signal.d.ts +9 -0
  119. package/dist/cjs/api/types/Signal.js +5 -0
  120. package/dist/cjs/api/types/TaxExemptStatus.d.ts +9 -0
  121. package/dist/cjs/api/types/TaxExemptStatus.js +11 -0
  122. package/dist/cjs/api/types/Tier.d.ts +8 -0
  123. package/dist/cjs/api/types/Tier.js +5 -0
  124. package/dist/cjs/api/types/index.d.ts +27 -0
  125. package/dist/cjs/api/types/index.js +43 -0
  126. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  127. package/dist/cjs/core/auth/BasicAuth.js +26 -0
  128. package/dist/cjs/core/auth/BearerToken.d.ts +5 -0
  129. package/dist/cjs/core/auth/BearerToken.js +15 -0
  130. package/dist/cjs/core/auth/index.d.ts +2 -0
  131. package/dist/cjs/core/auth/index.js +7 -0
  132. package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
  133. package/dist/cjs/core/fetcher/APIResponse.js +2 -0
  134. package/dist/cjs/core/fetcher/Fetcher.d.ts +40 -0
  135. package/dist/cjs/core/fetcher/Fetcher.js +120 -0
  136. package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
  137. package/dist/cjs/core/fetcher/Headers.js +84 -0
  138. package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
  139. package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
  140. package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
  141. package/dist/cjs/core/fetcher/RawResponse.js +44 -0
  142. package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
  143. package/dist/cjs/core/fetcher/Supplier.js +22 -0
  144. package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
  145. package/dist/cjs/core/fetcher/createRequestUrl.js +12 -0
  146. package/dist/cjs/core/fetcher/getFetchFn.d.ts +4 -0
  147. package/dist/cjs/core/fetcher/getFetchFn.js +68 -0
  148. package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
  149. package/dist/cjs/core/fetcher/getHeader.js +11 -0
  150. package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
  151. package/dist/cjs/core/fetcher/getRequestBody.js +23 -0
  152. package/dist/cjs/core/fetcher/getResponseBody.d.ts +1 -0
  153. package/dist/cjs/core/fetcher/getResponseBody.js +54 -0
  154. package/dist/cjs/core/fetcher/index.d.ts +8 -0
  155. package/dist/cjs/core/fetcher/index.js +15 -0
  156. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -0
  157. package/dist/cjs/core/fetcher/makeRequest.js +42 -0
  158. package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
  159. package/dist/cjs/core/fetcher/requestWithRetries.js +40 -0
  160. package/dist/cjs/core/fetcher/signals.d.ts +11 -0
  161. package/dist/cjs/core/fetcher/signals.js +36 -0
  162. package/dist/cjs/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
  163. package/dist/cjs/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
  164. package/dist/cjs/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
  165. package/dist/cjs/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
  166. package/dist/cjs/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
  167. package/dist/cjs/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
  168. package/dist/cjs/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
  169. package/dist/cjs/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
  170. package/dist/cjs/core/headers.d.ts +3 -0
  171. package/dist/cjs/core/headers.js +29 -0
  172. package/dist/cjs/core/index.d.ts +3 -0
  173. package/dist/cjs/core/index.js +19 -0
  174. package/dist/cjs/core/json.d.ts +15 -0
  175. package/dist/cjs/core/json.js +24 -0
  176. package/dist/cjs/core/runtime/index.d.ts +1 -0
  177. package/dist/cjs/core/runtime/index.js +5 -0
  178. package/dist/cjs/core/runtime/runtime.d.ts +9 -0
  179. package/dist/cjs/core/runtime/runtime.js +103 -0
  180. package/dist/cjs/environments.d.ts +7 -0
  181. package/dist/cjs/environments.js +9 -0
  182. package/dist/cjs/errors/PaidApiError.d.ts +15 -0
  183. package/dist/cjs/errors/PaidApiError.js +30 -0
  184. package/dist/cjs/errors/PaidApiTimeoutError.d.ts +6 -0
  185. package/dist/cjs/errors/PaidApiTimeoutError.js +13 -0
  186. package/dist/cjs/errors/index.d.ts +2 -0
  187. package/dist/cjs/errors/index.js +7 -0
  188. package/dist/cjs/index.d.ts +4 -0
  189. package/dist/cjs/index.js +44 -0
  190. package/dist/cjs/version.d.ts +1 -0
  191. package/dist/cjs/version.js +4 -0
  192. package/dist/esm/Client.d.mts +44 -0
  193. package/dist/esm/Client.mjs +42 -0
  194. package/dist/esm/api/index.d.mts +2 -0
  195. package/dist/esm/api/index.mjs +2 -0
  196. package/dist/esm/api/resources/agents/client/Client.d.mts +107 -0
  197. package/dist/esm/api/resources/agents/client/Client.mjs +424 -0
  198. package/dist/esm/api/resources/agents/client/index.d.mts +1 -0
  199. package/dist/esm/api/resources/agents/client/index.mjs +1 -0
  200. package/dist/esm/api/resources/agents/client/requests/AgentCreate.d.mts +16 -0
  201. package/dist/esm/api/resources/agents/client/requests/AgentCreate.mjs +4 -0
  202. package/dist/esm/api/resources/agents/client/requests/index.d.mts +1 -0
  203. package/dist/esm/api/resources/agents/client/requests/index.mjs +1 -0
  204. package/dist/esm/api/resources/agents/index.d.mts +1 -0
  205. package/dist/esm/api/resources/agents/index.mjs +1 -0
  206. package/dist/esm/api/resources/contacts/client/Client.d.mts +93 -0
  207. package/dist/esm/api/resources/contacts/client/Client.mjs +326 -0
  208. package/dist/esm/api/resources/contacts/client/index.d.mts +1 -0
  209. package/dist/esm/api/resources/contacts/client/index.mjs +1 -0
  210. package/dist/esm/api/resources/contacts/client/requests/ContactCreate.d.mts +32 -0
  211. package/dist/esm/api/resources/contacts/client/requests/ContactCreate.mjs +4 -0
  212. package/dist/esm/api/resources/contacts/client/requests/index.d.mts +1 -0
  213. package/dist/esm/api/resources/contacts/client/requests/index.mjs +1 -0
  214. package/dist/esm/api/resources/contacts/index.d.mts +1 -0
  215. package/dist/esm/api/resources/contacts/index.mjs +1 -0
  216. package/dist/esm/api/resources/customers/client/Client.d.mts +106 -0
  217. package/dist/esm/api/resources/customers/client/Client.mjs +423 -0
  218. package/dist/esm/api/resources/customers/client/index.d.mts +1 -0
  219. package/dist/esm/api/resources/customers/client/index.mjs +1 -0
  220. package/dist/esm/api/resources/customers/client/requests/CustomerCreate.d.mts +21 -0
  221. package/dist/esm/api/resources/customers/client/requests/CustomerCreate.mjs +4 -0
  222. package/dist/esm/api/resources/customers/client/requests/index.d.mts +1 -0
  223. package/dist/esm/api/resources/customers/client/requests/index.mjs +1 -0
  224. package/dist/esm/api/resources/customers/index.d.mts +1 -0
  225. package/dist/esm/api/resources/customers/index.mjs +1 -0
  226. package/dist/esm/api/resources/index.d.mts +10 -0
  227. package/dist/esm/api/resources/index.mjs +10 -0
  228. package/dist/esm/api/resources/orders/client/Client.d.mts +84 -0
  229. package/dist/esm/api/resources/orders/client/Client.mjs +280 -0
  230. package/dist/esm/api/resources/orders/client/index.d.mts +1 -0
  231. package/dist/esm/api/resources/orders/client/index.mjs +1 -0
  232. package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +25 -0
  233. package/dist/esm/api/resources/orders/client/requests/OrderCreate.mjs +4 -0
  234. package/dist/esm/api/resources/orders/client/requests/index.d.mts +1 -0
  235. package/dist/esm/api/resources/orders/client/requests/index.mjs +1 -0
  236. package/dist/esm/api/resources/orders/index.d.mts +2 -0
  237. package/dist/esm/api/resources/orders/index.mjs +2 -0
  238. package/dist/esm/api/resources/orders/resources/index.d.mts +2 -0
  239. package/dist/esm/api/resources/orders/resources/index.mjs +2 -0
  240. package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +41 -0
  241. package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +79 -0
  242. package/dist/esm/api/resources/orders/resources/lines/client/index.d.mts +1 -0
  243. package/dist/esm/api/resources/orders/resources/lines/client/index.mjs +1 -0
  244. package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.mts +11 -0
  245. package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.mjs +4 -0
  246. package/dist/esm/api/resources/orders/resources/lines/client/requests/index.d.mts +1 -0
  247. package/dist/esm/api/resources/orders/resources/lines/client/requests/index.mjs +1 -0
  248. package/dist/esm/api/resources/orders/resources/lines/index.d.mts +1 -0
  249. package/dist/esm/api/resources/orders/resources/lines/index.mjs +1 -0
  250. package/dist/esm/api/resources/usage/client/Client.d.mts +40 -0
  251. package/dist/esm/api/resources/usage/client/Client.mjs +78 -0
  252. package/dist/esm/api/resources/usage/client/index.d.mts +1 -0
  253. package/dist/esm/api/resources/usage/client/index.mjs +1 -0
  254. package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkRequest.d.mts +11 -0
  255. package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkRequest.mjs +4 -0
  256. package/dist/esm/api/resources/usage/client/requests/index.d.mts +1 -0
  257. package/dist/esm/api/resources/usage/client/requests/index.mjs +1 -0
  258. package/dist/esm/api/resources/usage/index.d.mts +1 -0
  259. package/dist/esm/api/resources/usage/index.mjs +1 -0
  260. package/dist/esm/api/types/Address.d.mts +11 -0
  261. package/dist/esm/api/types/Address.mjs +4 -0
  262. package/dist/esm/api/types/Agent.d.mts +14 -0
  263. package/dist/esm/api/types/Agent.mjs +4 -0
  264. package/dist/esm/api/types/AgentAttribute.d.mts +9 -0
  265. package/dist/esm/api/types/AgentAttribute.mjs +4 -0
  266. package/dist/esm/api/types/AgentPricePoint.d.mts +10 -0
  267. package/dist/esm/api/types/AgentPricePoint.mjs +4 -0
  268. package/dist/esm/api/types/AgentPricePointTiers.d.mts +8 -0
  269. package/dist/esm/api/types/AgentPricePointTiers.mjs +4 -0
  270. package/dist/esm/api/types/AgentUpdate.d.mts +12 -0
  271. package/dist/esm/api/types/AgentUpdate.mjs +4 -0
  272. package/dist/esm/api/types/ApiError.d.mts +12 -0
  273. package/dist/esm/api/types/ApiError.mjs +4 -0
  274. package/dist/esm/api/types/BillingFrequency.d.mts +9 -0
  275. package/dist/esm/api/types/BillingFrequency.mjs +8 -0
  276. package/dist/esm/api/types/ChargeType.d.mts +10 -0
  277. package/dist/esm/api/types/ChargeType.mjs +9 -0
  278. package/dist/esm/api/types/Contact.d.mts +21 -0
  279. package/dist/esm/api/types/Contact.mjs +4 -0
  280. package/dist/esm/api/types/CreationSource.d.mts +10 -0
  281. package/dist/esm/api/types/CreationSource.mjs +9 -0
  282. package/dist/esm/api/types/CreationState.d.mts +8 -0
  283. package/dist/esm/api/types/CreationState.mjs +7 -0
  284. package/dist/esm/api/types/Customer.d.mts +18 -0
  285. package/dist/esm/api/types/Customer.mjs +4 -0
  286. package/dist/esm/api/types/CustomerUpdate.d.mts +15 -0
  287. package/dist/esm/api/types/CustomerUpdate.mjs +4 -0
  288. package/dist/esm/api/types/Error_.d.mts +10 -0
  289. package/dist/esm/api/types/Error_.mjs +4 -0
  290. package/dist/esm/api/types/Order.d.mts +22 -0
  291. package/dist/esm/api/types/Order.mjs +4 -0
  292. package/dist/esm/api/types/OrderLine.d.mts +20 -0
  293. package/dist/esm/api/types/OrderLine.mjs +4 -0
  294. package/dist/esm/api/types/OrderLineAttribute.d.mts +10 -0
  295. package/dist/esm/api/types/OrderLineAttribute.mjs +4 -0
  296. package/dist/esm/api/types/OrderLineAttributePricing.d.mts +11 -0
  297. package/dist/esm/api/types/OrderLineAttributePricing.mjs +4 -0
  298. package/dist/esm/api/types/OrderLineCreate.d.mts +9 -0
  299. package/dist/esm/api/types/OrderLineCreate.mjs +4 -0
  300. package/dist/esm/api/types/PricePoint.d.mts +10 -0
  301. package/dist/esm/api/types/PricePoint.mjs +4 -0
  302. package/dist/esm/api/types/Pricing.d.mts +12 -0
  303. package/dist/esm/api/types/Pricing.mjs +4 -0
  304. package/dist/esm/api/types/PricingModelType.d.mts +9 -0
  305. package/dist/esm/api/types/PricingModelType.mjs +8 -0
  306. package/dist/esm/api/types/Salutation.d.mts +12 -0
  307. package/dist/esm/api/types/Salutation.mjs +11 -0
  308. package/dist/esm/api/types/Signal.d.mts +9 -0
  309. package/dist/esm/api/types/Signal.mjs +4 -0
  310. package/dist/esm/api/types/TaxExemptStatus.d.mts +9 -0
  311. package/dist/esm/api/types/TaxExemptStatus.mjs +8 -0
  312. package/dist/esm/api/types/Tier.d.mts +8 -0
  313. package/dist/esm/api/types/Tier.mjs +4 -0
  314. package/dist/esm/api/types/index.d.mts +27 -0
  315. package/dist/esm/api/types/index.mjs +27 -0
  316. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  317. package/dist/esm/core/auth/BasicAuth.mjs +23 -0
  318. package/dist/esm/core/auth/BearerToken.d.mts +5 -0
  319. package/dist/esm/core/auth/BearerToken.mjs +12 -0
  320. package/dist/esm/core/auth/index.d.mts +2 -0
  321. package/dist/esm/core/auth/index.mjs +2 -0
  322. package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
  323. package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
  324. package/dist/esm/core/fetcher/Fetcher.d.mts +40 -0
  325. package/dist/esm/core/fetcher/Fetcher.mjs +116 -0
  326. package/dist/esm/core/fetcher/Headers.d.mts +2 -0
  327. package/dist/esm/core/fetcher/Headers.mjs +82 -0
  328. package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
  329. package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
  330. package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
  331. package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
  332. package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
  333. package/dist/esm/core/fetcher/Supplier.mjs +19 -0
  334. package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
  335. package/dist/esm/core/fetcher/createRequestUrl.mjs +6 -0
  336. package/dist/esm/core/fetcher/getFetchFn.d.mts +4 -0
  337. package/dist/esm/core/fetcher/getFetchFn.mjs +32 -0
  338. package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
  339. package/dist/esm/core/fetcher/getHeader.mjs +8 -0
  340. package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
  341. package/dist/esm/core/fetcher/getRequestBody.mjs +20 -0
  342. package/dist/esm/core/fetcher/getResponseBody.d.mts +1 -0
  343. package/dist/esm/core/fetcher/getResponseBody.mjs +51 -0
  344. package/dist/esm/core/fetcher/index.d.mts +8 -0
  345. package/dist/esm/core/fetcher/index.mjs +5 -0
  346. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -0
  347. package/dist/esm/core/fetcher/makeRequest.mjs +38 -0
  348. package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
  349. package/dist/esm/core/fetcher/requestWithRetries.mjs +37 -0
  350. package/dist/esm/core/fetcher/signals.d.mts +11 -0
  351. package/dist/esm/core/fetcher/signals.mjs +32 -0
  352. package/dist/esm/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.mts +30 -0
  353. package/dist/esm/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.mjs +243 -0
  354. package/dist/esm/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.mts +21 -0
  355. package/dist/esm/core/fetcher/stream-wrappers/NodePre18StreamWrapper.mjs +122 -0
  356. package/dist/esm/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.mts +31 -0
  357. package/dist/esm/core/fetcher/stream-wrappers/UndiciStreamWrapper.mjs +225 -0
  358. package/dist/esm/core/fetcher/stream-wrappers/chooseStreamWrapper.d.mts +18 -0
  359. package/dist/esm/core/fetcher/stream-wrappers/chooseStreamWrapper.mjs +23 -0
  360. package/dist/esm/core/headers.d.mts +3 -0
  361. package/dist/esm/core/headers.mjs +25 -0
  362. package/dist/esm/core/index.d.mts +3 -0
  363. package/dist/esm/core/index.mjs +3 -0
  364. package/dist/esm/core/json.d.mts +15 -0
  365. package/dist/esm/core/json.mjs +19 -0
  366. package/dist/esm/core/runtime/index.d.mts +1 -0
  367. package/dist/esm/core/runtime/index.mjs +1 -0
  368. package/dist/esm/core/runtime/runtime.d.mts +9 -0
  369. package/dist/esm/core/runtime/runtime.mjs +100 -0
  370. package/dist/esm/environments.d.mts +7 -0
  371. package/dist/esm/environments.mjs +6 -0
  372. package/dist/esm/errors/PaidApiError.d.mts +15 -0
  373. package/dist/esm/errors/PaidApiError.mjs +26 -0
  374. package/dist/esm/errors/PaidApiTimeoutError.d.mts +6 -0
  375. package/dist/esm/errors/PaidApiTimeoutError.mjs +9 -0
  376. package/dist/esm/errors/index.d.mts +2 -0
  377. package/dist/esm/errors/index.mjs +2 -0
  378. package/dist/esm/index.d.mts +4 -0
  379. package/dist/esm/index.mjs +4 -0
  380. package/dist/esm/version.d.mts +1 -0
  381. package/dist/esm/version.mjs +1 -0
  382. package/package.json +70 -0
  383. package/reference.md +1433 -0
@@ -0,0 +1,23 @@
1
+ import { Base64 } from "js-base64";
2
+ const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
3
+ export const BasicAuth = {
4
+ toAuthorizationHeader: (basicAuth) => {
5
+ if (basicAuth == null) {
6
+ return undefined;
7
+ }
8
+ const token = Base64.encode(`${basicAuth.username}:${basicAuth.password}`);
9
+ return `Basic ${token}`;
10
+ },
11
+ fromAuthorizationHeader: (header) => {
12
+ const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
13
+ const decoded = Base64.decode(credentials);
14
+ const [username, password] = decoded.split(":", 2);
15
+ if (username == null || password == null) {
16
+ throw new Error("Invalid basic auth");
17
+ }
18
+ return {
19
+ username,
20
+ password,
21
+ };
22
+ },
23
+ };
@@ -0,0 +1,5 @@
1
+ export type BearerToken = string;
2
+ export declare const BearerToken: {
3
+ toAuthorizationHeader: (token: BearerToken | undefined) => string | undefined;
4
+ fromAuthorizationHeader: (header: string) => BearerToken;
5
+ };
@@ -0,0 +1,12 @@
1
+ const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
2
+ export const BearerToken = {
3
+ toAuthorizationHeader: (token) => {
4
+ if (token == null) {
5
+ return undefined;
6
+ }
7
+ return `Bearer ${token}`;
8
+ },
9
+ fromAuthorizationHeader: (header) => {
10
+ return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
11
+ },
12
+ };
@@ -0,0 +1,2 @@
1
+ export { BasicAuth } from "./BasicAuth.mjs";
2
+ export { BearerToken } from "./BearerToken.mjs";
@@ -0,0 +1,2 @@
1
+ export { BasicAuth } from "./BasicAuth.mjs";
2
+ export { BearerToken } from "./BearerToken.mjs";
@@ -0,0 +1,20 @@
1
+ import { RawResponse } from "./RawResponse.mjs";
2
+ /**
3
+ * The response of an API call.
4
+ * It is a successful response or a failed response.
5
+ */
6
+ export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
7
+ export interface SuccessfulResponse<T> {
8
+ ok: true;
9
+ body: T;
10
+ /**
11
+ * @deprecated Use `rawResponse` instead
12
+ */
13
+ headers?: Record<string, any>;
14
+ rawResponse: RawResponse;
15
+ }
16
+ export interface FailedResponse<T> {
17
+ ok: false;
18
+ error: T;
19
+ rawResponse: RawResponse;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { APIResponse } from "./APIResponse.mjs";
2
+ import { Supplier } from "./Supplier.mjs";
3
+ export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
4
+ export declare namespace Fetcher {
5
+ interface Args {
6
+ url: string;
7
+ method: string;
8
+ contentType?: string;
9
+ headers?: Record<string, string | Supplier<string | undefined> | undefined>;
10
+ queryParameters?: Record<string, string | string[] | object | object[] | null>;
11
+ body?: unknown;
12
+ timeoutMs?: number;
13
+ maxRetries?: number;
14
+ withCredentials?: boolean;
15
+ abortSignal?: AbortSignal;
16
+ requestType?: "json" | "file" | "bytes";
17
+ responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer";
18
+ duplex?: "half";
19
+ }
20
+ type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
21
+ interface FailedStatusCodeError {
22
+ reason: "status-code";
23
+ statusCode: number;
24
+ body: unknown;
25
+ }
26
+ interface NonJsonError {
27
+ reason: "non-json";
28
+ statusCode: number;
29
+ rawBody: string;
30
+ }
31
+ interface TimeoutError {
32
+ reason: "timeout";
33
+ }
34
+ interface UnknownError {
35
+ reason: "unknown";
36
+ errorMessage: string;
37
+ }
38
+ }
39
+ export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
40
+ export declare const fetcher: FetchFunction;
@@ -0,0 +1,116 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { toJson } from "../json.mjs";
11
+ import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
12
+ import { Supplier } from "./Supplier.mjs";
13
+ import { createRequestUrl } from "./createRequestUrl.mjs";
14
+ import { getFetchFn } from "./getFetchFn.mjs";
15
+ import { getRequestBody } from "./getRequestBody.mjs";
16
+ import { getResponseBody } from "./getResponseBody.mjs";
17
+ import { makeRequest } from "./makeRequest.mjs";
18
+ import { requestWithRetries } from "./requestWithRetries.mjs";
19
+ function getHeaders(args) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const newHeaders = {};
22
+ if (args.body !== undefined && args.contentType != null) {
23
+ newHeaders["Content-Type"] = args.contentType;
24
+ }
25
+ if (args.headers == null) {
26
+ return newHeaders;
27
+ }
28
+ for (const [key, value] of Object.entries(args.headers)) {
29
+ const result = yield Supplier.get(value);
30
+ if (typeof result === "string") {
31
+ newHeaders[key] = result;
32
+ continue;
33
+ }
34
+ if (result == null) {
35
+ continue;
36
+ }
37
+ newHeaders[key] = `${result}`;
38
+ }
39
+ return newHeaders;
40
+ });
41
+ }
42
+ export function fetcherImpl(args) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const url = createRequestUrl(args.url, args.queryParameters);
45
+ const requestBody = yield getRequestBody({
46
+ body: args.body,
47
+ type: args.requestType === "json" ? "json" : "other",
48
+ });
49
+ const fetchFn = yield getFetchFn();
50
+ try {
51
+ const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
52
+ return makeRequest(fetchFn, url, args.method, yield getHeaders(args), requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
53
+ }), args.maxRetries);
54
+ const responseBody = yield getResponseBody(response, args.responseType);
55
+ if (response.status >= 200 && response.status < 400) {
56
+ return {
57
+ ok: true,
58
+ body: responseBody,
59
+ headers: response.headers,
60
+ rawResponse: toRawResponse(response),
61
+ };
62
+ }
63
+ else {
64
+ return {
65
+ ok: false,
66
+ error: {
67
+ reason: "status-code",
68
+ statusCode: response.status,
69
+ body: responseBody,
70
+ },
71
+ rawResponse: toRawResponse(response),
72
+ };
73
+ }
74
+ }
75
+ catch (error) {
76
+ if (args.abortSignal != null && args.abortSignal.aborted) {
77
+ return {
78
+ ok: false,
79
+ error: {
80
+ reason: "unknown",
81
+ errorMessage: "The user aborted a request",
82
+ },
83
+ rawResponse: abortRawResponse,
84
+ };
85
+ }
86
+ else if (error instanceof Error && error.name === "AbortError") {
87
+ return {
88
+ ok: false,
89
+ error: {
90
+ reason: "timeout",
91
+ },
92
+ rawResponse: abortRawResponse,
93
+ };
94
+ }
95
+ else if (error instanceof Error) {
96
+ return {
97
+ ok: false,
98
+ error: {
99
+ reason: "unknown",
100
+ errorMessage: error.message,
101
+ },
102
+ rawResponse: unknownRawResponse,
103
+ };
104
+ }
105
+ return {
106
+ ok: false,
107
+ error: {
108
+ reason: "unknown",
109
+ errorMessage: toJson(error),
110
+ },
111
+ rawResponse: unknownRawResponse,
112
+ };
113
+ }
114
+ });
115
+ }
116
+ export const fetcher = fetcherImpl;
@@ -0,0 +1,2 @@
1
+ declare let Headers: typeof globalThis.Headers;
2
+ export { Headers };
@@ -0,0 +1,82 @@
1
+ let Headers;
2
+ if (typeof globalThis.Headers !== "undefined") {
3
+ Headers = globalThis.Headers;
4
+ }
5
+ else {
6
+ Headers = class Headers {
7
+ constructor(init) {
8
+ this.headers = new Map();
9
+ if (init) {
10
+ if (init instanceof Headers) {
11
+ init.forEach((value, key) => this.append(key, value));
12
+ }
13
+ else if (Array.isArray(init)) {
14
+ for (const [key, value] of init) {
15
+ if (typeof key === "string" && typeof value === "string") {
16
+ this.append(key, value);
17
+ }
18
+ else {
19
+ throw new TypeError("Each header entry must be a [string, string] tuple");
20
+ }
21
+ }
22
+ }
23
+ else {
24
+ for (const [key, value] of Object.entries(init)) {
25
+ if (typeof value === "string") {
26
+ this.append(key, value);
27
+ }
28
+ else {
29
+ throw new TypeError("Header values must be strings");
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ append(name, value) {
36
+ const key = name.toLowerCase();
37
+ const existing = this.headers.get(key) || [];
38
+ this.headers.set(key, [...existing, value]);
39
+ }
40
+ delete(name) {
41
+ const key = name.toLowerCase();
42
+ this.headers.delete(key);
43
+ }
44
+ get(name) {
45
+ const key = name.toLowerCase();
46
+ const values = this.headers.get(key);
47
+ return values ? values.join(", ") : null;
48
+ }
49
+ has(name) {
50
+ const key = name.toLowerCase();
51
+ return this.headers.has(key);
52
+ }
53
+ set(name, value) {
54
+ const key = name.toLowerCase();
55
+ this.headers.set(key, [value]);
56
+ }
57
+ forEach(callbackfn, thisArg) {
58
+ const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
59
+ this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
60
+ }
61
+ getSetCookie() {
62
+ return this.headers.get("set-cookie") || [];
63
+ }
64
+ *entries() {
65
+ for (const [key, values] of this.headers.entries()) {
66
+ yield [key, values.join(", ")];
67
+ }
68
+ }
69
+ *keys() {
70
+ yield* this.headers.keys();
71
+ }
72
+ *values() {
73
+ for (const values of this.headers.values()) {
74
+ yield values.join(", ");
75
+ }
76
+ }
77
+ [Symbol.iterator]() {
78
+ return this.entries();
79
+ }
80
+ };
81
+ }
82
+ export { Headers };
@@ -0,0 +1,58 @@
1
+ import { WithRawResponse } from "./RawResponse.mjs";
2
+ /**
3
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
4
+ */
5
+ export declare class HttpResponsePromise<T> extends Promise<T> {
6
+ private innerPromise;
7
+ private unwrappedPromise;
8
+ private constructor();
9
+ /**
10
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
11
+ *
12
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
13
+ * @param args - Arguments to pass to the function.
14
+ * @returns An `HttpResponsePromise` instance.
15
+ */
16
+ static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
17
+ /**
18
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
19
+ *
20
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
21
+ * @returns A function that returns an `HttpResponsePromise` instance.
22
+ */
23
+ static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
24
+ /**
25
+ * Creates an `HttpResponsePromise` from an existing promise.
26
+ *
27
+ * @param promise - A promise resolving to a `WithRawResponse` object.
28
+ * @returns An `HttpResponsePromise` instance.
29
+ */
30
+ static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
31
+ /**
32
+ * Creates an `HttpResponsePromise` from an executor function.
33
+ *
34
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
35
+ * @returns An `HttpResponsePromise` instance.
36
+ */
37
+ static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
38
+ /**
39
+ * Creates an `HttpResponsePromise` from a resolved result.
40
+ *
41
+ * @param result - A `WithRawResponse` object to resolve immediately.
42
+ * @returns An `HttpResponsePromise` instance.
43
+ */
44
+ static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
45
+ private unwrap;
46
+ /** @inheritdoc */
47
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
48
+ /** @inheritdoc */
49
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
50
+ /** @inheritdoc */
51
+ finally(onfinally?: (() => void) | null): Promise<T>;
52
+ /**
53
+ * Retrieves the data and raw response.
54
+ *
55
+ * @returns A promise resolving to a `WithRawResponse` object.
56
+ */
57
+ withRawResponse(): Promise<WithRawResponse<T>>;
58
+ }
@@ -0,0 +1,99 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
12
+ */
13
+ export class HttpResponsePromise extends Promise {
14
+ constructor(promise) {
15
+ // Initialize with a no-op to avoid premature parsing
16
+ super((resolve) => {
17
+ resolve(undefined);
18
+ });
19
+ this.innerPromise = promise;
20
+ }
21
+ /**
22
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
23
+ *
24
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
25
+ * @param args - Arguments to pass to the function.
26
+ * @returns An `HttpResponsePromise` instance.
27
+ */
28
+ static fromFunction(fn, ...args) {
29
+ return new HttpResponsePromise(fn(...args));
30
+ }
31
+ /**
32
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
33
+ *
34
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
35
+ * @returns A function that returns an `HttpResponsePromise` instance.
36
+ */
37
+ static interceptFunction(fn) {
38
+ return (...args) => {
39
+ return HttpResponsePromise.fromPromise(fn(...args));
40
+ };
41
+ }
42
+ /**
43
+ * Creates an `HttpResponsePromise` from an existing promise.
44
+ *
45
+ * @param promise - A promise resolving to a `WithRawResponse` object.
46
+ * @returns An `HttpResponsePromise` instance.
47
+ */
48
+ static fromPromise(promise) {
49
+ return new HttpResponsePromise(promise);
50
+ }
51
+ /**
52
+ * Creates an `HttpResponsePromise` from an executor function.
53
+ *
54
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
55
+ * @returns An `HttpResponsePromise` instance.
56
+ */
57
+ static fromExecutor(executor) {
58
+ const promise = new Promise(executor);
59
+ return new HttpResponsePromise(promise);
60
+ }
61
+ /**
62
+ * Creates an `HttpResponsePromise` from a resolved result.
63
+ *
64
+ * @param result - A `WithRawResponse` object to resolve immediately.
65
+ * @returns An `HttpResponsePromise` instance.
66
+ */
67
+ static fromResult(result) {
68
+ const promise = Promise.resolve(result);
69
+ return new HttpResponsePromise(promise);
70
+ }
71
+ unwrap() {
72
+ if (!this.unwrappedPromise) {
73
+ this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
74
+ }
75
+ return this.unwrappedPromise;
76
+ }
77
+ /** @inheritdoc */
78
+ then(onfulfilled, onrejected) {
79
+ return this.unwrap().then(onfulfilled, onrejected);
80
+ }
81
+ /** @inheritdoc */
82
+ catch(onrejected) {
83
+ return this.unwrap().catch(onrejected);
84
+ }
85
+ /** @inheritdoc */
86
+ finally(onfinally) {
87
+ return this.unwrap().finally(onfinally);
88
+ }
89
+ /**
90
+ * Retrieves the data and raw response.
91
+ *
92
+ * @returns A promise resolving to a `WithRawResponse` object.
93
+ */
94
+ withRawResponse() {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ return yield this.innerPromise;
97
+ });
98
+ }
99
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The raw response from the fetch call excluding the body.
3
+ */
4
+ export type RawResponse = Omit<{
5
+ [K in keyof Response as Response[K] extends Function ? never : K]: Response[K];
6
+ }, "ok" | "body" | "bodyUsed">;
7
+ /**
8
+ * A raw response indicating that the request was aborted.
9
+ */
10
+ export declare const abortRawResponse: RawResponse;
11
+ /**
12
+ * A raw response indicating an unknown error.
13
+ */
14
+ export declare const unknownRawResponse: RawResponse;
15
+ /**
16
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
17
+ * excluding the `body` and `bodyUsed` fields.
18
+ *
19
+ * @param response - The `RawResponse` object to convert.
20
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
21
+ */
22
+ export declare function toRawResponse(response: Response): RawResponse;
23
+ /**
24
+ * Creates a `RawResponse` from a standard `Response` object.
25
+ */
26
+ export interface WithRawResponse<T> {
27
+ readonly data: T;
28
+ readonly rawResponse: RawResponse;
29
+ }
@@ -0,0 +1,40 @@
1
+ import { Headers } from "./Headers.mjs";
2
+ /**
3
+ * A raw response indicating that the request was aborted.
4
+ */
5
+ export const abortRawResponse = {
6
+ headers: new Headers(),
7
+ redirected: false,
8
+ status: 499,
9
+ statusText: "Client Closed Request",
10
+ type: "error",
11
+ url: "",
12
+ };
13
+ /**
14
+ * A raw response indicating an unknown error.
15
+ */
16
+ export const unknownRawResponse = {
17
+ headers: new Headers(),
18
+ redirected: false,
19
+ status: 0,
20
+ statusText: "Unknown Error",
21
+ type: "error",
22
+ url: "",
23
+ };
24
+ /**
25
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
26
+ * excluding the `body` and `bodyUsed` fields.
27
+ *
28
+ * @param response - The `RawResponse` object to convert.
29
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
30
+ */
31
+ export function toRawResponse(response) {
32
+ return {
33
+ headers: response.headers,
34
+ redirected: response.redirected,
35
+ status: response.status,
36
+ statusText: response.statusText,
37
+ type: response.type,
38
+ url: response.url,
39
+ };
40
+ }
@@ -0,0 +1,4 @@
1
+ export type Supplier<T> = T | Promise<T> | (() => T | Promise<T>);
2
+ export declare const Supplier: {
3
+ get: <T>(supplier: Supplier<T>) => Promise<T>;
4
+ };
@@ -0,0 +1,19 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const Supplier = {
11
+ get: (supplier) => __awaiter(void 0, void 0, void 0, function* () {
12
+ if (typeof supplier === "function") {
13
+ return supplier();
14
+ }
15
+ else {
16
+ return supplier;
17
+ }
18
+ }),
19
+ };
@@ -0,0 +1 @@
1
+ export declare function createRequestUrl(baseUrl: string, queryParameters?: Record<string, string | string[] | object | object[] | null>): string;
@@ -0,0 +1,6 @@
1
+ import qs from "qs";
2
+ export function createRequestUrl(baseUrl, queryParameters) {
3
+ return Object.keys(queryParameters !== null && queryParameters !== void 0 ? queryParameters : {}).length > 0
4
+ ? `${baseUrl}?${qs.stringify(queryParameters, { arrayFormat: "repeat" })}`
5
+ : baseUrl;
6
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns a fetch function based on the runtime
3
+ */
4
+ export declare function getFetchFn(): Promise<any>;
@@ -0,0 +1,32 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { RUNTIME } from "../runtime/index.mjs";
11
+ /**
12
+ * Returns a fetch function based on the runtime
13
+ */
14
+ export function getFetchFn() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ // In Node.js 18+ environments, use native fetch
17
+ if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
18
+ return fetch;
19
+ }
20
+ // In Node.js 18 or lower environments, the SDK always uses`node-fetch`.
21
+ if (RUNTIME.type === "node") {
22
+ return (yield import("node-fetch")).default;
23
+ }
24
+ // Otherwise the SDK uses global fetch if available,
25
+ // and falls back to node-fetch.
26
+ if (typeof fetch == "function") {
27
+ return fetch;
28
+ }
29
+ // Defaults to node `node-fetch` if global fetch isn't available
30
+ return (yield import("node-fetch")).default;
31
+ });
32
+ }
@@ -0,0 +1 @@
1
+ export declare function getHeader(headers: Record<string, any>, header: string): string | undefined;
@@ -0,0 +1,8 @@
1
+ export function getHeader(headers, header) {
2
+ for (const [headerKey, headerValue] of Object.entries(headers)) {
3
+ if (headerKey.toLowerCase() === header.toLowerCase()) {
4
+ return headerValue;
5
+ }
6
+ }
7
+ return undefined;
8
+ }
@@ -0,0 +1,7 @@
1
+ export declare namespace GetRequestBody {
2
+ interface Args {
3
+ body: unknown;
4
+ type: "json" | "file" | "bytes" | "other";
5
+ }
6
+ }
7
+ export declare function getRequestBody({ body, type }: GetRequestBody.Args): Promise<BodyInit | undefined>;
@@ -0,0 +1,20 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { toJson } from "../json.mjs";
11
+ export function getRequestBody(_a) {
12
+ return __awaiter(this, arguments, void 0, function* ({ body, type }) {
13
+ if (type.includes("json")) {
14
+ return toJson(body);
15
+ }
16
+ else {
17
+ return body;
18
+ }
19
+ });
20
+ }