@rainapi/rain-sdk 0.1.0-alpha.3

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 (678) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE +201 -0
  3. package/README.md +412 -0
  4. package/api-promise.d.mts +2 -0
  5. package/api-promise.d.mts.map +1 -0
  6. package/api-promise.d.ts +2 -0
  7. package/api-promise.d.ts.map +1 -0
  8. package/api-promise.js +6 -0
  9. package/api-promise.js.map +1 -0
  10. package/api-promise.mjs +2 -0
  11. package/api-promise.mjs.map +1 -0
  12. package/client.d.mts +222 -0
  13. package/client.d.mts.map +1 -0
  14. package/client.d.ts +222 -0
  15. package/client.d.ts.map +1 -0
  16. package/client.js +501 -0
  17. package/client.js.map +1 -0
  18. package/client.mjs +497 -0
  19. package/client.mjs.map +1 -0
  20. package/core/api-promise.d.mts +46 -0
  21. package/core/api-promise.d.mts.map +1 -0
  22. package/core/api-promise.d.ts +46 -0
  23. package/core/api-promise.d.ts.map +1 -0
  24. package/core/api-promise.js +74 -0
  25. package/core/api-promise.js.map +1 -0
  26. package/core/api-promise.mjs +70 -0
  27. package/core/api-promise.mjs.map +1 -0
  28. package/core/error.d.mts +46 -0
  29. package/core/error.d.mts.map +1 -0
  30. package/core/error.d.ts +46 -0
  31. package/core/error.d.ts.map +1 -0
  32. package/core/error.js +113 -0
  33. package/core/error.js.map +1 -0
  34. package/core/error.mjs +97 -0
  35. package/core/error.mjs.map +1 -0
  36. package/core/resource.d.mts +6 -0
  37. package/core/resource.d.mts.map +1 -0
  38. package/core/resource.d.ts +6 -0
  39. package/core/resource.d.ts.map +1 -0
  40. package/core/resource.js +11 -0
  41. package/core/resource.js.map +1 -0
  42. package/core/resource.mjs +7 -0
  43. package/core/resource.mjs.map +1 -0
  44. package/core/uploads.d.mts +3 -0
  45. package/core/uploads.d.mts.map +1 -0
  46. package/core/uploads.d.ts +3 -0
  47. package/core/uploads.d.ts.map +1 -0
  48. package/core/uploads.js +6 -0
  49. package/core/uploads.js.map +1 -0
  50. package/core/uploads.mjs +2 -0
  51. package/core/uploads.mjs.map +1 -0
  52. package/error.d.mts +2 -0
  53. package/error.d.mts.map +1 -0
  54. package/error.d.ts +2 -0
  55. package/error.d.ts.map +1 -0
  56. package/error.js +6 -0
  57. package/error.js.map +1 -0
  58. package/error.mjs +2 -0
  59. package/error.mjs.map +1 -0
  60. package/index.d.mts +6 -0
  61. package/index.d.mts.map +1 -0
  62. package/index.d.ts +6 -0
  63. package/index.d.ts.map +1 -0
  64. package/index.js +30 -0
  65. package/index.js.map +1 -0
  66. package/index.mjs +7 -0
  67. package/index.mjs.map +1 -0
  68. package/internal/builtin-types.d.mts +73 -0
  69. package/internal/builtin-types.d.mts.map +1 -0
  70. package/internal/builtin-types.d.ts +73 -0
  71. package/internal/builtin-types.d.ts.map +1 -0
  72. package/internal/builtin-types.js +4 -0
  73. package/internal/builtin-types.js.map +1 -0
  74. package/internal/builtin-types.mjs +3 -0
  75. package/internal/builtin-types.mjs.map +1 -0
  76. package/internal/detect-platform.d.mts +15 -0
  77. package/internal/detect-platform.d.mts.map +1 -0
  78. package/internal/detect-platform.d.ts +15 -0
  79. package/internal/detect-platform.d.ts.map +1 -0
  80. package/internal/detect-platform.js +162 -0
  81. package/internal/detect-platform.js.map +1 -0
  82. package/internal/detect-platform.mjs +157 -0
  83. package/internal/detect-platform.mjs.map +1 -0
  84. package/internal/errors.d.mts +3 -0
  85. package/internal/errors.d.mts.map +1 -0
  86. package/internal/errors.d.ts +3 -0
  87. package/internal/errors.d.ts.map +1 -0
  88. package/internal/errors.js +41 -0
  89. package/internal/errors.js.map +1 -0
  90. package/internal/errors.mjs +36 -0
  91. package/internal/errors.mjs.map +1 -0
  92. package/internal/headers.d.mts +20 -0
  93. package/internal/headers.d.mts.map +1 -0
  94. package/internal/headers.d.ts +20 -0
  95. package/internal/headers.d.ts.map +1 -0
  96. package/internal/headers.js +79 -0
  97. package/internal/headers.js.map +1 -0
  98. package/internal/headers.mjs +74 -0
  99. package/internal/headers.mjs.map +1 -0
  100. package/internal/parse.d.mts +12 -0
  101. package/internal/parse.d.mts.map +1 -0
  102. package/internal/parse.d.ts +12 -0
  103. package/internal/parse.d.ts.map +1 -0
  104. package/internal/parse.js +40 -0
  105. package/internal/parse.js.map +1 -0
  106. package/internal/parse.mjs +37 -0
  107. package/internal/parse.mjs.map +1 -0
  108. package/internal/qs/formats.d.mts +7 -0
  109. package/internal/qs/formats.d.mts.map +1 -0
  110. package/internal/qs/formats.d.ts +7 -0
  111. package/internal/qs/formats.d.ts.map +1 -0
  112. package/internal/qs/formats.js +13 -0
  113. package/internal/qs/formats.js.map +1 -0
  114. package/internal/qs/formats.mjs +9 -0
  115. package/internal/qs/formats.mjs.map +1 -0
  116. package/internal/qs/index.d.mts +10 -0
  117. package/internal/qs/index.d.mts.map +1 -0
  118. package/internal/qs/index.d.ts +10 -0
  119. package/internal/qs/index.d.ts.map +1 -0
  120. package/internal/qs/index.js +14 -0
  121. package/internal/qs/index.js.map +1 -0
  122. package/internal/qs/index.mjs +10 -0
  123. package/internal/qs/index.mjs.map +1 -0
  124. package/internal/qs/stringify.d.mts +3 -0
  125. package/internal/qs/stringify.d.mts.map +1 -0
  126. package/internal/qs/stringify.d.ts +3 -0
  127. package/internal/qs/stringify.d.ts.map +1 -0
  128. package/internal/qs/stringify.js +277 -0
  129. package/internal/qs/stringify.js.map +1 -0
  130. package/internal/qs/stringify.mjs +274 -0
  131. package/internal/qs/stringify.mjs.map +1 -0
  132. package/internal/qs/types.d.mts +57 -0
  133. package/internal/qs/types.d.mts.map +1 -0
  134. package/internal/qs/types.d.ts +57 -0
  135. package/internal/qs/types.d.ts.map +1 -0
  136. package/internal/qs/types.js +3 -0
  137. package/internal/qs/types.js.map +1 -0
  138. package/internal/qs/types.mjs +2 -0
  139. package/internal/qs/types.mjs.map +1 -0
  140. package/internal/qs/utils.d.mts +15 -0
  141. package/internal/qs/utils.d.mts.map +1 -0
  142. package/internal/qs/utils.d.ts +15 -0
  143. package/internal/qs/utils.d.ts.map +1 -0
  144. package/internal/qs/utils.js +230 -0
  145. package/internal/qs/utils.js.map +1 -0
  146. package/internal/qs/utils.mjs +217 -0
  147. package/internal/qs/utils.mjs.map +1 -0
  148. package/internal/request-options.d.mts +75 -0
  149. package/internal/request-options.d.mts.map +1 -0
  150. package/internal/request-options.d.ts +75 -0
  151. package/internal/request-options.d.ts.map +1 -0
  152. package/internal/request-options.js +14 -0
  153. package/internal/request-options.js.map +1 -0
  154. package/internal/request-options.mjs +10 -0
  155. package/internal/request-options.mjs.map +1 -0
  156. package/internal/shim-types.d.mts +17 -0
  157. package/internal/shim-types.d.mts.map +1 -0
  158. package/internal/shim-types.d.ts +17 -0
  159. package/internal/shim-types.d.ts.map +1 -0
  160. package/internal/shim-types.js +4 -0
  161. package/internal/shim-types.js.map +1 -0
  162. package/internal/shim-types.mjs +3 -0
  163. package/internal/shim-types.mjs.map +1 -0
  164. package/internal/shims.d.mts +20 -0
  165. package/internal/shims.d.mts.map +1 -0
  166. package/internal/shims.d.ts +20 -0
  167. package/internal/shims.d.ts.map +1 -0
  168. package/internal/shims.js +92 -0
  169. package/internal/shims.js.map +1 -0
  170. package/internal/shims.mjs +85 -0
  171. package/internal/shims.mjs.map +1 -0
  172. package/internal/to-file.d.mts +45 -0
  173. package/internal/to-file.d.mts.map +1 -0
  174. package/internal/to-file.d.ts +45 -0
  175. package/internal/to-file.d.ts.map +1 -0
  176. package/internal/to-file.js +91 -0
  177. package/internal/to-file.js.map +1 -0
  178. package/internal/to-file.mjs +88 -0
  179. package/internal/to-file.mjs.map +1 -0
  180. package/internal/tslib.js +81 -0
  181. package/internal/tslib.mjs +17 -0
  182. package/internal/types.d.mts +69 -0
  183. package/internal/types.d.mts.map +1 -0
  184. package/internal/types.d.ts +69 -0
  185. package/internal/types.d.ts.map +1 -0
  186. package/internal/types.js +4 -0
  187. package/internal/types.js.map +1 -0
  188. package/internal/types.mjs +3 -0
  189. package/internal/types.mjs.map +1 -0
  190. package/internal/uploads.d.mts +42 -0
  191. package/internal/uploads.d.mts.map +1 -0
  192. package/internal/uploads.d.ts +42 -0
  193. package/internal/uploads.d.ts.map +1 -0
  194. package/internal/uploads.js +141 -0
  195. package/internal/uploads.js.map +1 -0
  196. package/internal/uploads.mjs +131 -0
  197. package/internal/uploads.mjs.map +1 -0
  198. package/internal/utils/base64.d.mts +3 -0
  199. package/internal/utils/base64.d.mts.map +1 -0
  200. package/internal/utils/base64.d.ts +3 -0
  201. package/internal/utils/base64.d.ts.map +1 -0
  202. package/internal/utils/base64.js +38 -0
  203. package/internal/utils/base64.js.map +1 -0
  204. package/internal/utils/base64.mjs +33 -0
  205. package/internal/utils/base64.mjs.map +1 -0
  206. package/internal/utils/bytes.d.mts +4 -0
  207. package/internal/utils/bytes.d.mts.map +1 -0
  208. package/internal/utils/bytes.d.ts +4 -0
  209. package/internal/utils/bytes.d.ts.map +1 -0
  210. package/internal/utils/bytes.js +31 -0
  211. package/internal/utils/bytes.js.map +1 -0
  212. package/internal/utils/bytes.mjs +26 -0
  213. package/internal/utils/bytes.mjs.map +1 -0
  214. package/internal/utils/env.d.mts +9 -0
  215. package/internal/utils/env.d.mts.map +1 -0
  216. package/internal/utils/env.d.ts +9 -0
  217. package/internal/utils/env.d.ts.map +1 -0
  218. package/internal/utils/env.js +22 -0
  219. package/internal/utils/env.js.map +1 -0
  220. package/internal/utils/env.mjs +18 -0
  221. package/internal/utils/env.mjs.map +1 -0
  222. package/internal/utils/log.d.mts +37 -0
  223. package/internal/utils/log.d.mts.map +1 -0
  224. package/internal/utils/log.d.ts +37 -0
  225. package/internal/utils/log.d.ts.map +1 -0
  226. package/internal/utils/log.js +86 -0
  227. package/internal/utils/log.js.map +1 -0
  228. package/internal/utils/log.mjs +80 -0
  229. package/internal/utils/log.mjs.map +1 -0
  230. package/internal/utils/path.d.mts +15 -0
  231. package/internal/utils/path.d.mts.map +1 -0
  232. package/internal/utils/path.d.ts +15 -0
  233. package/internal/utils/path.d.ts.map +1 -0
  234. package/internal/utils/path.js +79 -0
  235. package/internal/utils/path.js.map +1 -0
  236. package/internal/utils/path.mjs +74 -0
  237. package/internal/utils/path.mjs.map +1 -0
  238. package/internal/utils/sleep.d.mts +2 -0
  239. package/internal/utils/sleep.d.mts.map +1 -0
  240. package/internal/utils/sleep.d.ts +2 -0
  241. package/internal/utils/sleep.d.ts.map +1 -0
  242. package/internal/utils/sleep.js +7 -0
  243. package/internal/utils/sleep.js.map +1 -0
  244. package/internal/utils/sleep.mjs +3 -0
  245. package/internal/utils/sleep.mjs.map +1 -0
  246. package/internal/utils/uuid.d.mts +5 -0
  247. package/internal/utils/uuid.d.mts.map +1 -0
  248. package/internal/utils/uuid.d.ts +5 -0
  249. package/internal/utils/uuid.d.ts.map +1 -0
  250. package/internal/utils/uuid.js +19 -0
  251. package/internal/utils/uuid.js.map +1 -0
  252. package/internal/utils/uuid.mjs +15 -0
  253. package/internal/utils/uuid.mjs.map +1 -0
  254. package/internal/utils/values.d.mts +18 -0
  255. package/internal/utils/values.d.mts.map +1 -0
  256. package/internal/utils/values.d.ts +18 -0
  257. package/internal/utils/values.d.ts.map +1 -0
  258. package/internal/utils/values.js +112 -0
  259. package/internal/utils/values.js.map +1 -0
  260. package/internal/utils/values.mjs +94 -0
  261. package/internal/utils/values.mjs.map +1 -0
  262. package/internal/utils.d.mts +7 -0
  263. package/internal/utils.d.mts.map +1 -0
  264. package/internal/utils.d.ts +7 -0
  265. package/internal/utils.d.ts.map +1 -0
  266. package/internal/utils.js +11 -0
  267. package/internal/utils.js.map +1 -0
  268. package/internal/utils.mjs +8 -0
  269. package/internal/utils.mjs.map +1 -0
  270. package/package.json +138 -0
  271. package/resource.d.mts +2 -0
  272. package/resource.d.mts.map +1 -0
  273. package/resource.d.ts +2 -0
  274. package/resource.d.ts.map +1 -0
  275. package/resource.js +6 -0
  276. package/resource.js.map +1 -0
  277. package/resource.mjs +2 -0
  278. package/resource.mjs.map +1 -0
  279. package/resources/applications/applications.d.mts +14 -0
  280. package/resources/applications/applications.d.mts.map +1 -0
  281. package/resources/applications/applications.d.ts +14 -0
  282. package/resources/applications/applications.d.ts.map +1 -0
  283. package/resources/applications/applications.js +21 -0
  284. package/resources/applications/applications.js.map +1 -0
  285. package/resources/applications/applications.mjs +16 -0
  286. package/resources/applications/applications.mjs.map +1 -0
  287. package/resources/applications/company/company.d.mts +584 -0
  288. package/resources/applications/company/company.d.mts.map +1 -0
  289. package/resources/applications/company/company.d.ts +584 -0
  290. package/resources/applications/company/company.d.ts.map +1 -0
  291. package/resources/applications/company/company.js +138 -0
  292. package/resources/applications/company/company.js.map +1 -0
  293. package/resources/applications/company/company.mjs +133 -0
  294. package/resources/applications/company/company.mjs.map +1 -0
  295. package/resources/applications/company/index.d.mts +3 -0
  296. package/resources/applications/company/index.d.mts.map +1 -0
  297. package/resources/applications/company/index.d.ts +3 -0
  298. package/resources/applications/company/index.d.ts.map +1 -0
  299. package/resources/applications/company/index.js +9 -0
  300. package/resources/applications/company/index.js.map +1 -0
  301. package/resources/applications/company/index.mjs +4 -0
  302. package/resources/applications/company/index.mjs.map +1 -0
  303. package/resources/applications/company/ubo/document.d.mts +50 -0
  304. package/resources/applications/company/ubo/document.d.mts.map +1 -0
  305. package/resources/applications/company/ubo/document.d.ts +50 -0
  306. package/resources/applications/company/ubo/document.d.ts.map +1 -0
  307. package/resources/applications/company/ubo/document.js +32 -0
  308. package/resources/applications/company/ubo/document.js.map +1 -0
  309. package/resources/applications/company/ubo/document.mjs +28 -0
  310. package/resources/applications/company/ubo/document.mjs.map +1 -0
  311. package/resources/applications/company/ubo/index.d.mts +3 -0
  312. package/resources/applications/company/ubo/index.d.mts.map +1 -0
  313. package/resources/applications/company/ubo/index.d.ts +3 -0
  314. package/resources/applications/company/ubo/index.d.ts.map +1 -0
  315. package/resources/applications/company/ubo/index.js +9 -0
  316. package/resources/applications/company/ubo/index.js.map +1 -0
  317. package/resources/applications/company/ubo/index.mjs +4 -0
  318. package/resources/applications/company/ubo/index.mjs.map +1 -0
  319. package/resources/applications/company/ubo/ubo.d.mts +96 -0
  320. package/resources/applications/company/ubo/ubo.d.mts.map +1 -0
  321. package/resources/applications/company/ubo/ubo.d.ts +96 -0
  322. package/resources/applications/company/ubo/ubo.d.ts.map +1 -0
  323. package/resources/applications/company/ubo/ubo.js +48 -0
  324. package/resources/applications/company/ubo/ubo.js.map +1 -0
  325. package/resources/applications/company/ubo/ubo.mjs +43 -0
  326. package/resources/applications/company/ubo/ubo.mjs.map +1 -0
  327. package/resources/applications/company/ubo.d.mts +2 -0
  328. package/resources/applications/company/ubo.d.mts.map +1 -0
  329. package/resources/applications/company/ubo.d.ts +2 -0
  330. package/resources/applications/company/ubo.d.ts.map +1 -0
  331. package/resources/applications/company/ubo.js +6 -0
  332. package/resources/applications/company/ubo.js.map +1 -0
  333. package/resources/applications/company/ubo.mjs +3 -0
  334. package/resources/applications/company/ubo.mjs.map +1 -0
  335. package/resources/applications/company.d.mts +2 -0
  336. package/resources/applications/company.d.mts.map +1 -0
  337. package/resources/applications/company.d.ts +2 -0
  338. package/resources/applications/company.d.ts.map +1 -0
  339. package/resources/applications/company.js +6 -0
  340. package/resources/applications/company.js.map +1 -0
  341. package/resources/applications/company.mjs +3 -0
  342. package/resources/applications/company.mjs.map +1 -0
  343. package/resources/applications/index.d.mts +4 -0
  344. package/resources/applications/index.d.mts.map +1 -0
  345. package/resources/applications/index.d.ts +4 -0
  346. package/resources/applications/index.d.ts.map +1 -0
  347. package/resources/applications/index.js +11 -0
  348. package/resources/applications/index.js.map +1 -0
  349. package/resources/applications/index.mjs +5 -0
  350. package/resources/applications/index.mjs.map +1 -0
  351. package/resources/applications/user.d.mts +507 -0
  352. package/resources/applications/user.d.mts.map +1 -0
  353. package/resources/applications/user.d.ts +507 -0
  354. package/resources/applications/user.d.ts.map +1 -0
  355. package/resources/applications/user.js +103 -0
  356. package/resources/applications/user.js.map +1 -0
  357. package/resources/applications/user.mjs +99 -0
  358. package/resources/applications/user.mjs.map +1 -0
  359. package/resources/applications.d.mts +2 -0
  360. package/resources/applications.d.mts.map +1 -0
  361. package/resources/applications.d.ts +2 -0
  362. package/resources/applications.d.ts.map +1 -0
  363. package/resources/applications.js +6 -0
  364. package/resources/applications.js.map +1 -0
  365. package/resources/applications.mjs +3 -0
  366. package/resources/applications.mjs.map +1 -0
  367. package/resources/balances.d.mts +37 -0
  368. package/resources/balances.d.mts.map +1 -0
  369. package/resources/balances.d.ts +37 -0
  370. package/resources/balances.d.ts.map +1 -0
  371. package/resources/balances.js +17 -0
  372. package/resources/balances.js.map +1 -0
  373. package/resources/balances.mjs +13 -0
  374. package/resources/balances.mjs.map +1 -0
  375. package/resources/cards/cards.d.mts +188 -0
  376. package/resources/cards/cards.d.mts.map +1 -0
  377. package/resources/cards/cards.d.ts +188 -0
  378. package/resources/cards/cards.d.ts.map +1 -0
  379. package/resources/cards/cards.js +50 -0
  380. package/resources/cards/cards.js.map +1 -0
  381. package/resources/cards/cards.mjs +45 -0
  382. package/resources/cards/cards.mjs.map +1 -0
  383. package/resources/cards/index.d.mts +3 -0
  384. package/resources/cards/index.d.mts.map +1 -0
  385. package/resources/cards/index.d.ts +3 -0
  386. package/resources/cards/index.d.ts.map +1 -0
  387. package/resources/cards/index.js +9 -0
  388. package/resources/cards/index.js.map +1 -0
  389. package/resources/cards/index.mjs +4 -0
  390. package/resources/cards/index.mjs.map +1 -0
  391. package/resources/cards/pin.d.mts +73 -0
  392. package/resources/cards/pin.d.mts.map +1 -0
  393. package/resources/cards/pin.d.ts +73 -0
  394. package/resources/cards/pin.d.ts.map +1 -0
  395. package/resources/cards/pin.js +32 -0
  396. package/resources/cards/pin.js.map +1 -0
  397. package/resources/cards/pin.mjs +28 -0
  398. package/resources/cards/pin.mjs.map +1 -0
  399. package/resources/cards.d.mts +2 -0
  400. package/resources/cards.d.mts.map +1 -0
  401. package/resources/cards.d.ts +2 -0
  402. package/resources/cards.d.ts.map +1 -0
  403. package/resources/cards.js +6 -0
  404. package/resources/cards.js.map +1 -0
  405. package/resources/cards.mjs +3 -0
  406. package/resources/cards.mjs.map +1 -0
  407. package/resources/companies/companies.d.mts +252 -0
  408. package/resources/companies/companies.d.mts.map +1 -0
  409. package/resources/companies/companies.d.ts +252 -0
  410. package/resources/companies/companies.d.ts.map +1 -0
  411. package/resources/companies/companies.js +69 -0
  412. package/resources/companies/companies.js.map +1 -0
  413. package/resources/companies/companies.mjs +64 -0
  414. package/resources/companies/companies.mjs.map +1 -0
  415. package/resources/companies/index.d.mts +3 -0
  416. package/resources/companies/index.d.mts.map +1 -0
  417. package/resources/companies/index.d.ts +3 -0
  418. package/resources/companies/index.d.ts.map +1 -0
  419. package/resources/companies/index.js +9 -0
  420. package/resources/companies/index.js.map +1 -0
  421. package/resources/companies/index.mjs +4 -0
  422. package/resources/companies/index.mjs.map +1 -0
  423. package/resources/companies/signatures.d.mts +122 -0
  424. package/resources/companies/signatures.d.mts.map +1 -0
  425. package/resources/companies/signatures.d.ts +122 -0
  426. package/resources/companies/signatures.d.ts.map +1 -0
  427. package/resources/companies/signatures.js +24 -0
  428. package/resources/companies/signatures.js.map +1 -0
  429. package/resources/companies/signatures.mjs +20 -0
  430. package/resources/companies/signatures.mjs.map +1 -0
  431. package/resources/companies.d.mts +2 -0
  432. package/resources/companies.d.mts.map +1 -0
  433. package/resources/companies.d.ts +2 -0
  434. package/resources/companies.d.ts.map +1 -0
  435. package/resources/companies.js +6 -0
  436. package/resources/companies.js.map +1 -0
  437. package/resources/companies.mjs +3 -0
  438. package/resources/companies.mjs.map +1 -0
  439. package/resources/contracts.d.mts +15 -0
  440. package/resources/contracts.d.mts.map +1 -0
  441. package/resources/contracts.d.ts +15 -0
  442. package/resources/contracts.d.ts.map +1 -0
  443. package/resources/contracts.js +15 -0
  444. package/resources/contracts.js.map +1 -0
  445. package/resources/contracts.mjs +11 -0
  446. package/resources/contracts.mjs.map +1 -0
  447. package/resources/disputes/disputes.d.mts +88 -0
  448. package/resources/disputes/disputes.d.mts.map +1 -0
  449. package/resources/disputes/disputes.d.ts +88 -0
  450. package/resources/disputes/disputes.d.ts.map +1 -0
  451. package/resources/disputes/disputes.js +42 -0
  452. package/resources/disputes/disputes.js.map +1 -0
  453. package/resources/disputes/disputes.mjs +37 -0
  454. package/resources/disputes/disputes.mjs.map +1 -0
  455. package/resources/disputes/evidence.d.mts +32 -0
  456. package/resources/disputes/evidence.d.mts.map +1 -0
  457. package/resources/disputes/evidence.d.ts +32 -0
  458. package/resources/disputes/evidence.d.ts.map +1 -0
  459. package/resources/disputes/evidence.js +28 -0
  460. package/resources/disputes/evidence.js.map +1 -0
  461. package/resources/disputes/evidence.mjs +24 -0
  462. package/resources/disputes/evidence.mjs.map +1 -0
  463. package/resources/disputes/index.d.mts +3 -0
  464. package/resources/disputes/index.d.mts.map +1 -0
  465. package/resources/disputes/index.d.ts +3 -0
  466. package/resources/disputes/index.d.ts.map +1 -0
  467. package/resources/disputes/index.js +9 -0
  468. package/resources/disputes/index.js.map +1 -0
  469. package/resources/disputes/index.mjs +4 -0
  470. package/resources/disputes/index.mjs.map +1 -0
  471. package/resources/disputes.d.mts +2 -0
  472. package/resources/disputes.d.mts.map +1 -0
  473. package/resources/disputes.d.ts +2 -0
  474. package/resources/disputes.d.ts.map +1 -0
  475. package/resources/disputes.js +6 -0
  476. package/resources/disputes.js.map +1 -0
  477. package/resources/disputes.mjs +3 -0
  478. package/resources/disputes.mjs.map +1 -0
  479. package/resources/index.d.mts +12 -0
  480. package/resources/index.d.mts.map +1 -0
  481. package/resources/index.d.ts +12 -0
  482. package/resources/index.d.ts.map +1 -0
  483. package/resources/index.js +27 -0
  484. package/resources/index.js.map +1 -0
  485. package/resources/index.mjs +13 -0
  486. package/resources/index.mjs.map +1 -0
  487. package/resources/keys.d.mts +51 -0
  488. package/resources/keys.d.mts.map +1 -0
  489. package/resources/keys.d.ts +51 -0
  490. package/resources/keys.d.ts.map +1 -0
  491. package/resources/keys.js +28 -0
  492. package/resources/keys.js.map +1 -0
  493. package/resources/keys.mjs +24 -0
  494. package/resources/keys.mjs.map +1 -0
  495. package/resources/payments.d.mts +35 -0
  496. package/resources/payments.d.mts.map +1 -0
  497. package/resources/payments.d.ts +35 -0
  498. package/resources/payments.d.ts.map +1 -0
  499. package/resources/payments.js +17 -0
  500. package/resources/payments.js.map +1 -0
  501. package/resources/payments.mjs +13 -0
  502. package/resources/payments.mjs.map +1 -0
  503. package/resources/signatures.d.mts +65 -0
  504. package/resources/signatures.d.mts.map +1 -0
  505. package/resources/signatures.d.ts +65 -0
  506. package/resources/signatures.d.ts.map +1 -0
  507. package/resources/signatures.js +23 -0
  508. package/resources/signatures.js.map +1 -0
  509. package/resources/signatures.mjs +19 -0
  510. package/resources/signatures.mjs.map +1 -0
  511. package/resources/transactions/index.d.mts +3 -0
  512. package/resources/transactions/index.d.mts.map +1 -0
  513. package/resources/transactions/index.d.ts +3 -0
  514. package/resources/transactions/index.d.ts.map +1 -0
  515. package/resources/transactions/index.js +9 -0
  516. package/resources/transactions/index.js.map +1 -0
  517. package/resources/transactions/index.mjs +4 -0
  518. package/resources/transactions/index.mjs.map +1 -0
  519. package/resources/transactions/receipt.d.mts +26 -0
  520. package/resources/transactions/receipt.d.mts.map +1 -0
  521. package/resources/transactions/receipt.d.ts +26 -0
  522. package/resources/transactions/receipt.d.ts.map +1 -0
  523. package/resources/transactions/receipt.js +30 -0
  524. package/resources/transactions/receipt.js.map +1 -0
  525. package/resources/transactions/receipt.mjs +26 -0
  526. package/resources/transactions/receipt.mjs.map +1 -0
  527. package/resources/transactions/transactions.d.mts +401 -0
  528. package/resources/transactions/transactions.d.mts.map +1 -0
  529. package/resources/transactions/transactions.d.ts +401 -0
  530. package/resources/transactions/transactions.d.ts.map +1 -0
  531. package/resources/transactions/transactions.js +52 -0
  532. package/resources/transactions/transactions.js.map +1 -0
  533. package/resources/transactions/transactions.mjs +47 -0
  534. package/resources/transactions/transactions.mjs.map +1 -0
  535. package/resources/transactions.d.mts +2 -0
  536. package/resources/transactions.d.mts.map +1 -0
  537. package/resources/transactions.d.ts +2 -0
  538. package/resources/transactions.d.ts.map +1 -0
  539. package/resources/transactions.js +6 -0
  540. package/resources/transactions.js.map +1 -0
  541. package/resources/transactions.mjs +3 -0
  542. package/resources/transactions.mjs.map +1 -0
  543. package/resources/users/index.d.mts +3 -0
  544. package/resources/users/index.d.mts.map +1 -0
  545. package/resources/users/index.d.ts +3 -0
  546. package/resources/users/index.d.ts.map +1 -0
  547. package/resources/users/index.js +9 -0
  548. package/resources/users/index.js.map +1 -0
  549. package/resources/users/index.mjs +4 -0
  550. package/resources/users/index.mjs.map +1 -0
  551. package/resources/users/signatures.d.mts +92 -0
  552. package/resources/users/signatures.d.mts.map +1 -0
  553. package/resources/users/signatures.d.ts +92 -0
  554. package/resources/users/signatures.d.ts.map +1 -0
  555. package/resources/users/signatures.js +51 -0
  556. package/resources/users/signatures.js.map +1 -0
  557. package/resources/users/signatures.mjs +47 -0
  558. package/resources/users/signatures.mjs.map +1 -0
  559. package/resources/users/users.d.mts +349 -0
  560. package/resources/users/users.d.mts.map +1 -0
  561. package/resources/users/users.d.ts +349 -0
  562. package/resources/users/users.d.ts.map +1 -0
  563. package/resources/users/users.js +174 -0
  564. package/resources/users/users.js.map +1 -0
  565. package/resources/users/users.mjs +169 -0
  566. package/resources/users/users.mjs.map +1 -0
  567. package/resources/users.d.mts +2 -0
  568. package/resources/users.d.mts.map +1 -0
  569. package/resources/users.d.ts +2 -0
  570. package/resources/users.d.ts.map +1 -0
  571. package/resources/users.js +6 -0
  572. package/resources/users.js.map +1 -0
  573. package/resources/users.mjs +3 -0
  574. package/resources/users.mjs.map +1 -0
  575. package/resources.d.mts +2 -0
  576. package/resources.d.mts.map +1 -0
  577. package/resources.d.ts +2 -0
  578. package/resources.d.ts.map +1 -0
  579. package/resources.js +5 -0
  580. package/resources.js.map +1 -0
  581. package/resources.mjs +2 -0
  582. package/resources.mjs.map +1 -0
  583. package/src/api-promise.ts +2 -0
  584. package/src/client.ts +914 -0
  585. package/src/core/README.md +3 -0
  586. package/src/core/api-promise.ts +92 -0
  587. package/src/core/error.ts +130 -0
  588. package/src/core/resource.ts +11 -0
  589. package/src/core/uploads.ts +2 -0
  590. package/src/error.ts +2 -0
  591. package/src/index.ts +22 -0
  592. package/src/internal/README.md +3 -0
  593. package/src/internal/builtin-types.ts +93 -0
  594. package/src/internal/detect-platform.ts +196 -0
  595. package/src/internal/errors.ts +33 -0
  596. package/src/internal/headers.ts +97 -0
  597. package/src/internal/parse.ts +56 -0
  598. package/src/internal/qs/LICENSE.md +13 -0
  599. package/src/internal/qs/README.md +3 -0
  600. package/src/internal/qs/formats.ts +10 -0
  601. package/src/internal/qs/index.ts +13 -0
  602. package/src/internal/qs/stringify.ts +385 -0
  603. package/src/internal/qs/types.ts +71 -0
  604. package/src/internal/qs/utils.ts +265 -0
  605. package/src/internal/request-options.ts +91 -0
  606. package/src/internal/shim-types.ts +26 -0
  607. package/src/internal/shims.ts +107 -0
  608. package/src/internal/to-file.ts +154 -0
  609. package/src/internal/types.ts +95 -0
  610. package/src/internal/uploads.ts +187 -0
  611. package/src/internal/utils/base64.ts +40 -0
  612. package/src/internal/utils/bytes.ts +32 -0
  613. package/src/internal/utils/env.ts +18 -0
  614. package/src/internal/utils/log.ts +127 -0
  615. package/src/internal/utils/path.ts +88 -0
  616. package/src/internal/utils/sleep.ts +3 -0
  617. package/src/internal/utils/uuid.ts +17 -0
  618. package/src/internal/utils/values.ts +105 -0
  619. package/src/internal/utils.ts +8 -0
  620. package/src/lib/.keep +4 -0
  621. package/src/resource.ts +2 -0
  622. package/src/resources/applications/applications.ts +61 -0
  623. package/src/resources/applications/company/company.ts +750 -0
  624. package/src/resources/applications/company/index.ts +15 -0
  625. package/src/resources/applications/company/ubo/document.ts +89 -0
  626. package/src/resources/applications/company/ubo/index.ts +4 -0
  627. package/src/resources/applications/company/ubo/ubo.ts +158 -0
  628. package/src/resources/applications/company/ubo.ts +3 -0
  629. package/src/resources/applications/company.ts +3 -0
  630. package/src/resources/applications/index.ts +25 -0
  631. package/src/resources/applications/user.ts +666 -0
  632. package/src/resources/applications.ts +3 -0
  633. package/src/resources/balances.ts +47 -0
  634. package/src/resources/cards/cards.ts +274 -0
  635. package/src/resources/cards/index.ts +14 -0
  636. package/src/resources/cards/pin.ts +108 -0
  637. package/src/resources/cards.ts +3 -0
  638. package/src/resources/companies/companies.ts +371 -0
  639. package/src/resources/companies/index.ts +23 -0
  640. package/src/resources/companies/signatures.ts +162 -0
  641. package/src/resources/companies.ts +3 -0
  642. package/src/resources/contracts.ts +21 -0
  643. package/src/resources/disputes/disputes.ts +135 -0
  644. package/src/resources/disputes/evidence.ts +56 -0
  645. package/src/resources/disputes/index.ts +10 -0
  646. package/src/resources/disputes.ts +3 -0
  647. package/src/resources/index.ts +66 -0
  648. package/src/resources/keys.ts +70 -0
  649. package/src/resources/payments.ts +47 -0
  650. package/src/resources/signatures.ts +91 -0
  651. package/src/resources/transactions/index.ts +11 -0
  652. package/src/resources/transactions/receipt.ts +48 -0
  653. package/src/resources/transactions/transactions.ts +522 -0
  654. package/src/resources/transactions.ts +3 -0
  655. package/src/resources/users/index.ts +20 -0
  656. package/src/resources/users/signatures.ts +121 -0
  657. package/src/resources/users/users.ts +471 -0
  658. package/src/resources/users.ts +3 -0
  659. package/src/resources.ts +1 -0
  660. package/src/tsconfig.json +11 -0
  661. package/src/uploads.ts +2 -0
  662. package/src/version.ts +1 -0
  663. package/uploads.d.mts +2 -0
  664. package/uploads.d.mts.map +1 -0
  665. package/uploads.d.ts +2 -0
  666. package/uploads.d.ts.map +1 -0
  667. package/uploads.js +6 -0
  668. package/uploads.js.map +1 -0
  669. package/uploads.mjs +2 -0
  670. package/uploads.mjs.map +1 -0
  671. package/version.d.mts +2 -0
  672. package/version.d.mts.map +1 -0
  673. package/version.d.ts +2 -0
  674. package/version.d.ts.map +1 -0
  675. package/version.js +5 -0
  676. package/version.js.map +1 -0
  677. package/version.mjs +2 -0
  678. package/version.mjs.map +1 -0
package/README.md ADDED
@@ -0,0 +1,412 @@
1
+ # Rain TypeScript API Library
2
+
3
+ [![NPM version](<https://img.shields.io/npm/v/@rainapi/rain-sdk.svg?label=npm%20(stable)>)](https://npmjs.org/package/@rainapi/rain-sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@rainapi/rain-sdk)
4
+
5
+ This library provides convenient access to the Rain REST API from server-side TypeScript or JavaScript.
6
+
7
+ The full API of this library can be found in [api.md](api.md).
8
+
9
+ It is generated with [Stainless](https://www.stainless.com/).
10
+
11
+ ## Installation
12
+
13
+ ```sh
14
+ npm install @rainapi/rain-sdk
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ The full API of this library can be found in [api.md](api.md).
20
+
21
+ <!-- prettier-ignore -->
22
+ ```js
23
+ import Rain from '@rainapi/rain-sdk';
24
+
25
+ const client = new Rain({
26
+ apiKey: process.env['RAIN_API_KEY'], // This is the default and can be omitted
27
+ environment: 'production', // defaults to 'dev'
28
+ });
29
+
30
+ const issuingChargeCreateResponse = await client.companies.charge(
31
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
32
+ { amount: 123, description: 'Custom fee charge' },
33
+ );
34
+
35
+ console.log(issuingChargeCreateResponse.id);
36
+ ```
37
+
38
+ ### Request & Response types
39
+
40
+ This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
41
+
42
+ <!-- prettier-ignore -->
43
+ ```ts
44
+ import Rain from '@rainapi/rain-sdk';
45
+
46
+ const client = new Rain({
47
+ apiKey: process.env['RAIN_API_KEY'], // This is the default and can be omitted
48
+ environment: 'production', // defaults to 'dev'
49
+ });
50
+
51
+ const params: Rain.CompanyChargeParams = { amount: 123, description: 'Custom fee charge' };
52
+ const issuingChargeCreateResponse: Rain.IssuingChargeCreateResponse = await client.companies.charge(
53
+ '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
54
+ params,
55
+ );
56
+ ```
57
+
58
+ Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
59
+
60
+ ## File uploads
61
+
62
+ Request parameters that correspond to file uploads can be passed in many different forms:
63
+
64
+ - `File` (or an object with the same structure)
65
+ - a `fetch` `Response` (or an object with the same structure)
66
+ - an `fs.ReadStream`
67
+ - the return value of our `toFile` helper
68
+
69
+ ```ts
70
+ import fs from 'fs';
71
+ import Rain, { toFile } from '@rainapi/rain-sdk';
72
+
73
+ const client = new Rain();
74
+
75
+ // If you have access to Node `fs` we recommend using `fs.createReadStream()`:
76
+ await client.applications.company.uploadDocument('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
77
+ document: fs.createReadStream('/path/to/file'),
78
+ });
79
+
80
+ // Or if you have the web `File` API you can pass a `File` instance:
81
+ await client.applications.company.uploadDocument('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
82
+ document: new File(['my bytes'], 'file'),
83
+ });
84
+
85
+ // You can also pass a `fetch` `Response`:
86
+ await client.applications.company.uploadDocument('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
87
+ document: await fetch('https://somesite/file'),
88
+ });
89
+
90
+ // Finally, if none of the above are convenient, you can use our `toFile` helper:
91
+ await client.applications.company.uploadDocument('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
92
+ document: await toFile(Buffer.from('my bytes'), 'file'),
93
+ });
94
+ await client.applications.company.uploadDocument('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
95
+ document: await toFile(new Uint8Array([0, 1, 2]), 'file'),
96
+ });
97
+ ```
98
+
99
+ ## Handling errors
100
+
101
+ When the library is unable to connect to the API,
102
+ or if the API returns a non-success status code (i.e., 4xx or 5xx response),
103
+ a subclass of `APIError` will be thrown:
104
+
105
+ <!-- prettier-ignore -->
106
+ ```ts
107
+ const issuingChargeCreateResponse = await client.companies
108
+ .charge('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { amount: 123, description: 'Custom fee charge' })
109
+ .catch(async (err) => {
110
+ if (err instanceof Rain.APIError) {
111
+ console.log(err.status); // 400
112
+ console.log(err.name); // BadRequestError
113
+ console.log(err.headers); // {server: 'nginx', ...}
114
+ } else {
115
+ throw err;
116
+ }
117
+ });
118
+ ```
119
+
120
+ Error codes are as follows:
121
+
122
+ | Status Code | Error Type |
123
+ | ----------- | -------------------------- |
124
+ | 400 | `BadRequestError` |
125
+ | 401 | `AuthenticationError` |
126
+ | 403 | `PermissionDeniedError` |
127
+ | 404 | `NotFoundError` |
128
+ | 422 | `UnprocessableEntityError` |
129
+ | 429 | `RateLimitError` |
130
+ | >=500 | `InternalServerError` |
131
+ | N/A | `APIConnectionError` |
132
+
133
+ ### Retries
134
+
135
+ Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
136
+ Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
137
+ 429 Rate Limit, and >=500 Internal errors will all be retried by default.
138
+
139
+ You can use the `maxRetries` option to configure or disable this:
140
+
141
+ <!-- prettier-ignore -->
142
+ ```js
143
+ // Configure the default for all requests:
144
+ const client = new Rain({
145
+ maxRetries: 0, // default is 2
146
+ });
147
+
148
+ // Or, configure per-request:
149
+ await client.companies.charge('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { amount: 123, description: 'Custom fee charge' }, {
150
+ maxRetries: 5,
151
+ });
152
+ ```
153
+
154
+ ### Timeouts
155
+
156
+ Requests time out after 1 minute by default. You can configure this with a `timeout` option:
157
+
158
+ <!-- prettier-ignore -->
159
+ ```ts
160
+ // Configure the default for all requests:
161
+ const client = new Rain({
162
+ timeout: 20 * 1000, // 20 seconds (default is 1 minute)
163
+ });
164
+
165
+ // Override per-request:
166
+ await client.companies.charge('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { amount: 123, description: 'Custom fee charge' }, {
167
+ timeout: 5 * 1000,
168
+ });
169
+ ```
170
+
171
+ On timeout, an `APIConnectionTimeoutError` is thrown.
172
+
173
+ Note that requests which time out will be [retried twice by default](#retries).
174
+
175
+ ## Advanced Usage
176
+
177
+ ### Accessing raw Response data (e.g., headers)
178
+
179
+ The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
180
+ This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.
181
+
182
+ You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
183
+ Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
184
+
185
+ <!-- prettier-ignore -->
186
+ ```ts
187
+ const client = new Rain();
188
+
189
+ const response = await client.companies
190
+ .charge('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { amount: 123, description: 'Custom fee charge' })
191
+ .asResponse();
192
+ console.log(response.headers.get('X-My-Header'));
193
+ console.log(response.statusText); // access the underlying Response object
194
+
195
+ const { data: issuingChargeCreateResponse, response: raw } = await client.companies
196
+ .charge('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { amount: 123, description: 'Custom fee charge' })
197
+ .withResponse();
198
+ console.log(raw.headers.get('X-My-Header'));
199
+ console.log(issuingChargeCreateResponse.id);
200
+ ```
201
+
202
+ ### Logging
203
+
204
+ > [!IMPORTANT]
205
+ > All log messages are intended for debugging only. The format and content of log messages
206
+ > may change between releases.
207
+
208
+ #### Log levels
209
+
210
+ The log level can be configured in two ways:
211
+
212
+ 1. Via the `RAIN_LOG` environment variable
213
+ 2. Using the `logLevel` client option (overrides the environment variable if set)
214
+
215
+ ```ts
216
+ import Rain from '@rainapi/rain-sdk';
217
+
218
+ const client = new Rain({
219
+ logLevel: 'debug', // Show all log messages
220
+ });
221
+ ```
222
+
223
+ Available log levels, from most to least verbose:
224
+
225
+ - `'debug'` - Show debug messages, info, warnings, and errors
226
+ - `'info'` - Show info messages, warnings, and errors
227
+ - `'warn'` - Show warnings and errors (default)
228
+ - `'error'` - Show only errors
229
+ - `'off'` - Disable all logging
230
+
231
+ At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
232
+ Some authentication-related headers are redacted, but sensitive data in request and response bodies
233
+ may still be visible.
234
+
235
+ #### Custom logger
236
+
237
+ By default, this library logs to `globalThis.console`. You can also provide a custom logger.
238
+ Most logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.
239
+
240
+ When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
241
+ below the configured level will not be sent to your logger.
242
+
243
+ ```ts
244
+ import Rain from '@rainapi/rain-sdk';
245
+ import pino from 'pino';
246
+
247
+ const logger = pino();
248
+
249
+ const client = new Rain({
250
+ logger: logger.child({ name: 'Rain' }),
251
+ logLevel: 'debug', // Send all messages to pino, allowing it to filter
252
+ });
253
+ ```
254
+
255
+ ### Making custom/undocumented requests
256
+
257
+ This library is typed for convenient access to the documented API. If you need to access undocumented
258
+ endpoints, params, or response properties, the library can still be used.
259
+
260
+ #### Undocumented endpoints
261
+
262
+ To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
263
+ Options on the client, such as retries, will be respected when making these requests.
264
+
265
+ ```ts
266
+ await client.post('/some/path', {
267
+ body: { some_prop: 'foo' },
268
+ query: { some_query_arg: 'bar' },
269
+ });
270
+ ```
271
+
272
+ #### Undocumented request params
273
+
274
+ To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
275
+ parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
276
+ send will be sent as-is.
277
+
278
+ ```ts
279
+ client.companies.charge({
280
+ // ...
281
+ // @ts-expect-error baz is not yet public
282
+ baz: 'undocumented option',
283
+ });
284
+ ```
285
+
286
+ For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
287
+ extra param in the body.
288
+
289
+ If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
290
+ options.
291
+
292
+ #### Undocumented response properties
293
+
294
+ To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
295
+ the response object, or cast the response object to the requisite type. Like the request params, we do not
296
+ validate or strip extra properties from the response from the API.
297
+
298
+ ### Customizing the fetch client
299
+
300
+ By default, this library expects a global `fetch` function is defined.
301
+
302
+ If you want to use a different `fetch` function, you can either polyfill the global:
303
+
304
+ ```ts
305
+ import fetch from 'my-fetch';
306
+
307
+ globalThis.fetch = fetch;
308
+ ```
309
+
310
+ Or pass it to the client:
311
+
312
+ ```ts
313
+ import Rain from '@rainapi/rain-sdk';
314
+ import fetch from 'my-fetch';
315
+
316
+ const client = new Rain({ fetch });
317
+ ```
318
+
319
+ ### Fetch options
320
+
321
+ If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
322
+
323
+ ```ts
324
+ import Rain from '@rainapi/rain-sdk';
325
+
326
+ const client = new Rain({
327
+ fetchOptions: {
328
+ // `RequestInit` options
329
+ },
330
+ });
331
+ ```
332
+
333
+ #### Configuring proxies
334
+
335
+ To modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy
336
+ options to requests:
337
+
338
+ <img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
339
+
340
+ ```ts
341
+ import Rain from '@rainapi/rain-sdk';
342
+ import * as undici from 'undici';
343
+
344
+ const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
345
+ const client = new Rain({
346
+ fetchOptions: {
347
+ dispatcher: proxyAgent,
348
+ },
349
+ });
350
+ ```
351
+
352
+ <img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
353
+
354
+ ```ts
355
+ import Rain from '@rainapi/rain-sdk';
356
+
357
+ const client = new Rain({
358
+ fetchOptions: {
359
+ proxy: 'http://localhost:8888',
360
+ },
361
+ });
362
+ ```
363
+
364
+ <img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
365
+
366
+ ```ts
367
+ import Rain from 'npm:@rainapi/rain-sdk';
368
+
369
+ const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
370
+ const client = new Rain({
371
+ fetchOptions: {
372
+ client: httpClient,
373
+ },
374
+ });
375
+ ```
376
+
377
+ ## Frequently Asked Questions
378
+
379
+ ## Semantic versioning
380
+
381
+ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
382
+
383
+ 1. Changes that only affect static types, without breaking runtime behavior.
384
+ 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
385
+ 3. Changes that we do not expect to impact the vast majority of users in practice.
386
+
387
+ We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
388
+
389
+ We are keen for your feedback; please open an [issue](https://www.github.com/SignifyHQ/rain-sdk-typescript/issues) with questions, bugs, or suggestions.
390
+
391
+ ## Requirements
392
+
393
+ TypeScript >= 4.9 is supported.
394
+
395
+ The following runtimes are supported:
396
+
397
+ - Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
398
+ - Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
399
+ - Deno v1.28.0 or higher.
400
+ - Bun 1.0 or later.
401
+ - Cloudflare Workers.
402
+ - Vercel Edge Runtime.
403
+ - Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
404
+ - Nitro v2.6 or greater.
405
+
406
+ Note that React Native is not supported at this time.
407
+
408
+ If you are interested in other runtime environments, please open or upvote an issue on GitHub.
409
+
410
+ ## Contributing
411
+
412
+ See [the contributing documentation](./CONTRIBUTING.md).
@@ -0,0 +1,2 @@
1
+ export * from "./core/api-promise.mjs";
2
+ //# sourceMappingURL=api-promise.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.d.mts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "./core/api-promise.js";
2
+ //# sourceMappingURL=api-promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.d.ts","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
package/api-promise.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("./internal/tslib.js");
4
+ /** @deprecated Import from ./core/api-promise instead */
5
+ tslib_1.__exportStar(require("./core/api-promise.js"), exports);
6
+ //# sourceMappingURL=api-promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,gEAAmC"}
@@ -0,0 +1,2 @@
1
+ export * from "./core/api-promise.mjs";
2
+ //# sourceMappingURL=api-promise.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":""}
package/client.d.mts ADDED
@@ -0,0 +1,222 @@
1
+ import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs";
2
+ import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.mjs";
3
+ export type { Logger, LogLevel } from "./internal/utils/log.mjs";
4
+ import * as Opts from "./internal/request-options.mjs";
5
+ import * as Errors from "./core/error.mjs";
6
+ import * as Uploads from "./core/uploads.mjs";
7
+ import * as API from "./resources/index.mjs";
8
+ import { APIPromise } from "./core/api-promise.mjs";
9
+ import { BalanceRetrieveResponse, Balances } from "./resources/balances.mjs";
10
+ import { ContractListResponse, Contracts } from "./resources/contracts.mjs";
11
+ import { KeyCreateParams, KeyCreateResponse, Keys } from "./resources/keys.mjs";
12
+ import { PaymentInitiateParams, PaymentInitiateResponse, Payments } from "./resources/payments.mjs";
13
+ import { SignatureRetrievePaymentSignatureParams, SignatureRetrieveWithdrawalSignatureParams, Signatures } from "./resources/signatures.mjs";
14
+ import { Applications } from "./resources/applications/applications.mjs";
15
+ import { CardListParams, CardListResponse, CardRetrieveSecretsParams, CardRetrieveSecretsResponse, CardUpdateParams, Cards, IssuingCard, IssuingCardLimit, IssuingCardStatus } from "./resources/cards/cards.mjs";
16
+ import { Companies, CompanyChargeParams, CompanyCreateUserParams, CompanyInitiatePaymentParams, CompanyInitiatePaymentResponse, CompanyListParams, CompanyListResponse, CompanyRetrieveBalancesResponse, CompanyRetrieveContractsResponse, CompanyUpdateParams, IssuingChargeCreateBody, IssuingChargeCreateResponse, IssuingContract } from "./resources/companies/companies.mjs";
17
+ import { DisputeListParams, DisputeListResponse, DisputeUpdateParams, Disputes, IssuingDispute } from "./resources/disputes/disputes.mjs";
18
+ import { IssuingTransaction, TransactionCreateDisputeParams, TransactionListParams, TransactionListResponse, TransactionUpdateParams, Transactions } from "./resources/transactions/transactions.mjs";
19
+ import { UserCreateCardParams, UserCreateChargeParams, UserCreateParams, UserInitiatePaymentParams, UserInitiatePaymentResponse, UserListParams, UserListResponse, UserRetrieveBalancesResponse, UserRetrieveContractsResponse, UserUpdateParams, Users } from "./resources/users/users.mjs";
20
+ import { type Fetch } from "./internal/builtin-types.mjs";
21
+ import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
22
+ import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
23
+ import { type LogLevel, type Logger } from "./internal/utils/log.mjs";
24
+ declare const environments: {
25
+ dev: string;
26
+ production: string;
27
+ };
28
+ type Environment = keyof typeof environments;
29
+ export interface ClientOptions {
30
+ /**
31
+ * Defaults to process.env['RAIN_API_KEY'].
32
+ */
33
+ apiKey?: string | undefined;
34
+ /**
35
+ * Specifies the environment to use for the API.
36
+ *
37
+ * Each environment maps to a different base URL:
38
+ * - `dev` corresponds to `https://api-dev.raincards.xyz/v1/issuing`
39
+ * - `production` corresponds to `https://api.raincards.xyz/v1/issuing`
40
+ */
41
+ environment?: Environment | undefined;
42
+ /**
43
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
44
+ *
45
+ * Defaults to process.env['RAIN_BASE_URL'].
46
+ */
47
+ baseURL?: string | null | undefined;
48
+ /**
49
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
50
+ * from the server before timing out a single request.
51
+ *
52
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
53
+ * much longer than this timeout before the promise succeeds or fails.
54
+ *
55
+ * @unit milliseconds
56
+ */
57
+ timeout?: number | undefined;
58
+ /**
59
+ * Additional `RequestInit` options to be passed to `fetch` calls.
60
+ * Properties will be overridden by per-request `fetchOptions`.
61
+ */
62
+ fetchOptions?: MergedRequestInit | undefined;
63
+ /**
64
+ * Specify a custom `fetch` function implementation.
65
+ *
66
+ * If not provided, we expect that `fetch` is defined globally.
67
+ */
68
+ fetch?: Fetch | undefined;
69
+ /**
70
+ * The maximum number of times that the client will retry a request in case of a
71
+ * temporary failure, like a network error or a 5XX error from the server.
72
+ *
73
+ * @default 2
74
+ */
75
+ maxRetries?: number | undefined;
76
+ /**
77
+ * Default headers to include with every request to the API.
78
+ *
79
+ * These can be removed in individual requests by explicitly setting the
80
+ * header to `null` in request options.
81
+ */
82
+ defaultHeaders?: HeadersLike | undefined;
83
+ /**
84
+ * Default query parameters to include with every request to the API.
85
+ *
86
+ * These can be removed in individual requests by explicitly setting the
87
+ * param to `undefined` in request options.
88
+ */
89
+ defaultQuery?: Record<string, string | undefined> | undefined;
90
+ /**
91
+ * Set the log level.
92
+ *
93
+ * Defaults to process.env['RAIN_LOG'] or 'warn' if it isn't set.
94
+ */
95
+ logLevel?: LogLevel | undefined;
96
+ /**
97
+ * Set the logger.
98
+ *
99
+ * Defaults to globalThis.console.
100
+ */
101
+ logger?: Logger | undefined;
102
+ }
103
+ /**
104
+ * API Client for interfacing with the Rain API.
105
+ */
106
+ export declare class Rain {
107
+ #private;
108
+ apiKey: string;
109
+ baseURL: string;
110
+ maxRetries: number;
111
+ timeout: number;
112
+ logger: Logger;
113
+ logLevel: LogLevel | undefined;
114
+ fetchOptions: MergedRequestInit | undefined;
115
+ private fetch;
116
+ protected idempotencyHeader?: string;
117
+ private _options;
118
+ /**
119
+ * API Client for interfacing with the Rain API.
120
+ *
121
+ * @param {string | undefined} [opts.apiKey=process.env['RAIN_API_KEY'] ?? undefined]
122
+ * @param {Environment} [opts.environment=dev] - Specifies the environment URL to use for the API.
123
+ * @param {string} [opts.baseURL=process.env['RAIN_BASE_URL'] ?? https://api-dev.raincards.xyz/v1/issuing] - Override the default base URL for the API.
124
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
125
+ * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
126
+ * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
127
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
128
+ * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
129
+ * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
130
+ */
131
+ constructor({ baseURL, apiKey, ...opts }?: ClientOptions);
132
+ /**
133
+ * Create a new client instance re-using the same options given to the current client with optional overriding.
134
+ */
135
+ withOptions(options: Partial<ClientOptions>): this;
136
+ protected defaultQuery(): Record<string, string | undefined> | undefined;
137
+ protected validateHeaders({ values, nulls }: NullableHeaders): void;
138
+ protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
139
+ protected stringifyQuery(query: Record<string, unknown>): string;
140
+ private getUserAgent;
141
+ protected defaultIdempotencyKey(): string;
142
+ protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
143
+ buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
144
+ /**
145
+ * Used as a callback for mutating the given `FinalRequestOptions` object.
146
+ */
147
+ protected prepareOptions(options: FinalRequestOptions): Promise<void>;
148
+ /**
149
+ * Used as a callback for mutating the given `RequestInit` object.
150
+ *
151
+ * This is useful for cases where you want to add certain headers based off of
152
+ * the request properties, e.g. `method` or `url`.
153
+ */
154
+ protected prepareRequest(request: RequestInit, { url, options }: {
155
+ url: string;
156
+ options: FinalRequestOptions;
157
+ }): Promise<void>;
158
+ get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
159
+ post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
160
+ patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
161
+ put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
162
+ delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
163
+ private methodRequest;
164
+ request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
165
+ private makeRequest;
166
+ fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
167
+ private shouldRetry;
168
+ private retryRequest;
169
+ private calculateDefaultRetryTimeoutMillis;
170
+ buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
171
+ retryCount?: number;
172
+ }): Promise<{
173
+ req: FinalizedRequestInit;
174
+ url: string;
175
+ timeout: number;
176
+ }>;
177
+ private buildHeaders;
178
+ private _makeAbort;
179
+ private buildBody;
180
+ static Rain: typeof Rain;
181
+ static DEFAULT_TIMEOUT: number;
182
+ static RainError: typeof Errors.RainError;
183
+ static APIError: typeof Errors.APIError;
184
+ static APIConnectionError: typeof Errors.APIConnectionError;
185
+ static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
186
+ static APIUserAbortError: typeof Errors.APIUserAbortError;
187
+ static NotFoundError: typeof Errors.NotFoundError;
188
+ static ConflictError: typeof Errors.ConflictError;
189
+ static RateLimitError: typeof Errors.RateLimitError;
190
+ static BadRequestError: typeof Errors.BadRequestError;
191
+ static AuthenticationError: typeof Errors.AuthenticationError;
192
+ static InternalServerError: typeof Errors.InternalServerError;
193
+ static PermissionDeniedError: typeof Errors.PermissionDeniedError;
194
+ static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
195
+ static toFile: typeof Uploads.toFile;
196
+ applications: API.Applications;
197
+ balances: API.Balances;
198
+ cards: API.Cards;
199
+ companies: API.Companies;
200
+ contracts: API.Contracts;
201
+ disputes: API.Disputes;
202
+ keys: API.Keys;
203
+ payments: API.Payments;
204
+ signatures: API.Signatures;
205
+ transactions: API.Transactions;
206
+ users: API.Users;
207
+ }
208
+ export declare namespace Rain {
209
+ export type RequestOptions = Opts.RequestOptions;
210
+ export { Applications as Applications };
211
+ export { Balances as Balances, type BalanceRetrieveResponse as BalanceRetrieveResponse };
212
+ export { Cards as Cards, type IssuingCard as IssuingCard, type IssuingCardLimit as IssuingCardLimit, type IssuingCardStatus as IssuingCardStatus, type CardListResponse as CardListResponse, type CardRetrieveSecretsResponse as CardRetrieveSecretsResponse, type CardUpdateParams as CardUpdateParams, type CardListParams as CardListParams, type CardRetrieveSecretsParams as CardRetrieveSecretsParams, };
213
+ export { Companies as Companies, type IssuingChargeCreateBody as IssuingChargeCreateBody, type IssuingChargeCreateResponse as IssuingChargeCreateResponse, type IssuingContract as IssuingContract, type CompanyListResponse as CompanyListResponse, type CompanyInitiatePaymentResponse as CompanyInitiatePaymentResponse, type CompanyRetrieveBalancesResponse as CompanyRetrieveBalancesResponse, type CompanyRetrieveContractsResponse as CompanyRetrieveContractsResponse, type CompanyUpdateParams as CompanyUpdateParams, type CompanyListParams as CompanyListParams, type CompanyChargeParams as CompanyChargeParams, type CompanyCreateUserParams as CompanyCreateUserParams, type CompanyInitiatePaymentParams as CompanyInitiatePaymentParams, };
214
+ export { Contracts as Contracts, type ContractListResponse as ContractListResponse };
215
+ export { Disputes as Disputes, type IssuingDispute as IssuingDispute, type DisputeListResponse as DisputeListResponse, type DisputeUpdateParams as DisputeUpdateParams, type DisputeListParams as DisputeListParams, };
216
+ export { Keys as Keys, type KeyCreateResponse as KeyCreateResponse, type KeyCreateParams as KeyCreateParams, };
217
+ export { Payments as Payments, type PaymentInitiateResponse as PaymentInitiateResponse, type PaymentInitiateParams as PaymentInitiateParams, };
218
+ export { Signatures as Signatures, type SignatureRetrievePaymentSignatureParams as SignatureRetrievePaymentSignatureParams, type SignatureRetrieveWithdrawalSignatureParams as SignatureRetrieveWithdrawalSignatureParams, };
219
+ export { Transactions as Transactions, type IssuingTransaction as IssuingTransaction, type TransactionListResponse as TransactionListResponse, type TransactionUpdateParams as TransactionUpdateParams, type TransactionListParams as TransactionListParams, type TransactionCreateDisputeParams as TransactionCreateDisputeParams, };
220
+ export { Users as Users, type UserListResponse as UserListResponse, type UserInitiatePaymentResponse as UserInitiatePaymentResponse, type UserRetrieveBalancesResponse as UserRetrieveBalancesResponse, type UserRetrieveContractsResponse as UserRetrieveContractsResponse, type UserCreateParams as UserCreateParams, type UserUpdateParams as UserUpdateParams, type UserListParams as UserListParams, type UserCreateCardParams as UserCreateCardParams, type UserCreateChargeParams as UserCreateChargeParams, type UserInitiatePaymentParams as UserInitiatePaymentParams, };
221
+ }
222
+ //# sourceMappingURL=client.d.mts.map