@tryfinch/finch-api 1.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/_shims/agent.d.ts +9 -0
  2. package/_shims/agent.d.ts.map +1 -0
  3. package/_shims/agent.js +14 -0
  4. package/_shims/agent.js.map +1 -0
  5. package/_shims/agent.mjs +10 -0
  6. package/_shims/agent.mjs.map +1 -0
  7. package/_shims/agent.node.d.ts +7 -0
  8. package/_shims/agent.node.d.ts.map +1 -0
  9. package/_shims/agent.node.js +28 -0
  10. package/_shims/agent.node.js.map +1 -0
  11. package/_shims/agent.node.mjs +16 -0
  12. package/_shims/agent.node.mjs.map +1 -0
  13. package/_shims/fetch.d.ts +52 -0
  14. package/_shims/fetch.js +13 -0
  15. package/_shims/fetch.mjs +15 -0
  16. package/_shims/fetch.node.d.ts +53 -0
  17. package/_shims/fetch.node.js +12 -0
  18. package/_shims/fetch.node.mjs +14 -0
  19. package/_shims/fileFromPath.d.ts +22 -0
  20. package/_shims/fileFromPath.d.ts.map +1 -0
  21. package/_shims/fileFromPath.js +16 -0
  22. package/_shims/fileFromPath.js.map +1 -0
  23. package/_shims/fileFromPath.mjs +12 -0
  24. package/_shims/fileFromPath.mjs.map +1 -0
  25. package/_shims/fileFromPath.node.d.ts +17 -0
  26. package/_shims/fileFromPath.node.d.ts.map +1 -0
  27. package/_shims/fileFromPath.node.js +17 -0
  28. package/_shims/fileFromPath.node.js.map +1 -0
  29. package/_shims/fileFromPath.node.mjs +13 -0
  30. package/_shims/fileFromPath.node.mjs.map +1 -0
  31. package/_shims/formdata.d.ts +43 -0
  32. package/_shims/formdata.js +9 -0
  33. package/_shims/formdata.mjs +11 -0
  34. package/_shims/formdata.node.d.ts +44 -0
  35. package/_shims/formdata.node.js +11 -0
  36. package/_shims/formdata.node.mjs +9 -0
  37. package/_shims/getMultipartRequestOptions.d.ts +10 -0
  38. package/_shims/getMultipartRequestOptions.d.ts.map +1 -0
  39. package/_shims/getMultipartRequestOptions.js +12 -0
  40. package/_shims/getMultipartRequestOptions.js.map +1 -0
  41. package/_shims/getMultipartRequestOptions.mjs +8 -0
  42. package/_shims/getMultipartRequestOptions.mjs.map +1 -0
  43. package/_shims/getMultipartRequestOptions.node.d.ts +10 -0
  44. package/_shims/getMultipartRequestOptions.node.d.ts.map +1 -0
  45. package/_shims/getMultipartRequestOptions.node.js +22 -0
  46. package/_shims/getMultipartRequestOptions.node.js.map +1 -0
  47. package/_shims/getMultipartRequestOptions.node.mjs +18 -0
  48. package/_shims/getMultipartRequestOptions.node.mjs.map +1 -0
  49. package/_shims/node-readable.d.ts +23 -0
  50. package/_shims/node-readable.d.ts.map +1 -0
  51. package/_shims/node-readable.js +11 -0
  52. package/_shims/node-readable.js.map +1 -0
  53. package/_shims/node-readable.mjs +7 -0
  54. package/_shims/node-readable.mjs.map +1 -0
  55. package/_shims/node-readable.node.d.ts +8 -0
  56. package/_shims/node-readable.node.d.ts.map +1 -0
  57. package/_shims/node-readable.node.js +9 -0
  58. package/_shims/node-readable.node.js.map +1 -0
  59. package/_shims/node-readable.node.mjs +5 -0
  60. package/_shims/node-readable.node.mjs.map +1 -0
  61. package/{dist/cjs/core.d.ts → core.d.ts} +18 -68
  62. package/core.d.ts.map +1 -0
  63. package/core.js +683 -0
  64. package/core.js.map +1 -0
  65. package/core.mjs +587 -0
  66. package/core.mjs.map +1 -0
  67. package/error.d.ts +48 -0
  68. package/error.d.ts.map +1 -0
  69. package/error.js +126 -0
  70. package/error.js.map +1 -0
  71. package/error.mjs +101 -0
  72. package/error.mjs.map +1 -0
  73. package/index.d.mts +160 -0
  74. package/index.d.ts +160 -0
  75. package/index.d.ts.map +1 -0
  76. package/{dist/cjs/index.js → index.js} +55 -44
  77. package/index.js.map +1 -0
  78. package/index.mjs +157 -0
  79. package/index.mjs.map +1 -0
  80. package/package.json +57 -20
  81. package/{dist/cjs/pagination.d.ts → pagination.d.ts} +6 -4
  82. package/pagination.d.ts.map +1 -0
  83. package/{dist/cjs/pagination.js → pagination.js} +1 -1
  84. package/pagination.js.map +1 -0
  85. package/pagination.mjs +198 -0
  86. package/pagination.mjs.map +1 -0
  87. package/{dist/cjs/resource.d.ts → resource.d.ts} +1 -1
  88. package/resource.d.ts.map +1 -0
  89. package/resource.js.map +1 -0
  90. package/resource.mjs +13 -0
  91. package/resource.mjs.map +1 -0
  92. package/{dist/cjs/resources → resources}/account.d.ts +7 -2
  93. package/resources/account.d.ts.map +1 -0
  94. package/{dist/cjs/resources → resources}/account.js +2 -1
  95. package/resources/account.js.map +1 -0
  96. package/resources/account.mjs +20 -0
  97. package/resources/account.mjs.map +1 -0
  98. package/{dist/cjs/resources → resources}/ats/applications.d.ts +10 -5
  99. package/resources/ats/applications.d.ts.map +1 -0
  100. package/{dist/cjs/resources → resources}/ats/applications.js +5 -8
  101. package/resources/ats/applications.js.map +1 -0
  102. package/resources/ats/applications.mjs +20 -0
  103. package/resources/ats/applications.mjs.map +1 -0
  104. package/resources/ats/ats.d.ts +32 -0
  105. package/resources/ats/ats.d.ts.map +1 -0
  106. package/resources/ats/ats.js +71 -0
  107. package/resources/ats/ats.js.map +1 -0
  108. package/resources/ats/ats.mjs +27 -0
  109. package/resources/ats/ats.mjs.map +1 -0
  110. package/{dist/cjs/resources → resources}/ats/candidates.d.ts +13 -8
  111. package/resources/ats/candidates.d.ts.map +1 -0
  112. package/{dist/cjs/resources → resources}/ats/candidates.js +5 -4
  113. package/resources/ats/candidates.js.map +1 -0
  114. package/resources/ats/candidates.mjs +21 -0
  115. package/resources/ats/candidates.mjs.map +1 -0
  116. package/resources/ats/index.d.ts +7 -0
  117. package/resources/ats/index.d.ts.map +1 -0
  118. package/resources/ats/index.js +60 -0
  119. package/resources/ats/index.js.map +1 -0
  120. package/resources/ats/index.mjs +8 -0
  121. package/resources/ats/index.mjs.map +1 -0
  122. package/{dist/cjs/resources → resources}/ats/jobs.d.ts +13 -8
  123. package/resources/ats/jobs.d.ts.map +1 -0
  124. package/{dist/cjs/resources → resources}/ats/jobs.js +5 -4
  125. package/resources/ats/jobs.js.map +1 -0
  126. package/resources/ats/jobs.mjs +20 -0
  127. package/resources/ats/jobs.mjs.map +1 -0
  128. package/{dist/cjs/resources → resources}/ats/offers.d.ts +9 -4
  129. package/resources/ats/offers.d.ts.map +1 -0
  130. package/{dist/cjs/resources → resources}/ats/offers.js +5 -4
  131. package/resources/ats/offers.js.map +1 -0
  132. package/resources/ats/offers.mjs +20 -0
  133. package/resources/ats/offers.mjs.map +1 -0
  134. package/{dist/cjs/resources → resources}/ats/stages.d.ts +10 -3
  135. package/resources/ats/stages.d.ts.map +1 -0
  136. package/{dist/cjs/resources → resources}/ats/stages.js +3 -2
  137. package/resources/ats/stages.js.map +1 -0
  138. package/resources/ats/stages.mjs +17 -0
  139. package/resources/ats/stages.mjs.map +1 -0
  140. package/{dist/cjs/resources → resources}/hris/benefits/benefits.d.ts +32 -4
  141. package/resources/hris/benefits/benefits.d.ts.map +1 -0
  142. package/resources/hris/benefits/benefits.js +104 -0
  143. package/resources/hris/benefits/benefits.js.map +1 -0
  144. package/resources/hris/benefits/benefits.mjs +58 -0
  145. package/resources/hris/benefits/benefits.mjs.map +1 -0
  146. package/{dist/cjs/resources → resources}/hris/benefits/index.d.ts +4 -2
  147. package/resources/hris/benefits/index.d.ts.map +1 -0
  148. package/{dist/cjs/resources → resources}/hris/benefits/index.js +17 -3
  149. package/resources/hris/benefits/index.js.map +1 -0
  150. package/resources/hris/benefits/index.mjs +9 -0
  151. package/resources/hris/benefits/index.mjs.map +1 -0
  152. package/{dist/cjs/resources → resources}/hris/benefits/individuals.d.ts +21 -4
  153. package/resources/hris/benefits/individuals.d.ts.map +1 -0
  154. package/{dist/cjs/resources → resources}/hris/benefits/individuals.js +18 -18
  155. package/resources/hris/benefits/individuals.js.map +1 -0
  156. package/resources/hris/benefits/individuals.mjs +57 -0
  157. package/resources/hris/benefits/individuals.mjs.map +1 -0
  158. package/{dist/cjs/resources → resources}/hris/company.d.ts +42 -38
  159. package/resources/hris/company.d.ts.map +1 -0
  160. package/{dist/cjs/resources → resources}/hris/company.js +4 -1
  161. package/resources/hris/company.js.map +1 -0
  162. package/resources/hris/company.mjs +12 -0
  163. package/resources/hris/company.mjs.map +1 -0
  164. package/{dist/cjs/resources → resources}/hris/directory.d.ts +20 -15
  165. package/resources/hris/directory.d.ts.map +1 -0
  166. package/{dist/cjs/resources → resources}/hris/directory.js +5 -8
  167. package/resources/hris/directory.js.map +1 -0
  168. package/resources/hris/directory.mjs +14 -0
  169. package/resources/hris/directory.mjs.map +1 -0
  170. package/resources/hris/hris.d.ts +134 -0
  171. package/resources/hris/hris.d.ts.map +1 -0
  172. package/resources/hris/hris.js +78 -0
  173. package/resources/hris/hris.js.map +1 -0
  174. package/resources/hris/hris.mjs +34 -0
  175. package/resources/hris/hris.mjs.map +1 -0
  176. package/{dist/cjs/resources → resources}/hris/index.d.ts +10 -7
  177. package/resources/hris/index.d.ts.map +1 -0
  178. package/resources/hris/index.js +96 -0
  179. package/resources/hris/index.js.map +1 -0
  180. package/resources/hris/index.mjs +9 -0
  181. package/resources/hris/index.mjs.map +1 -0
  182. package/{dist/cjs/resources → resources}/hris/individuals/employment-data.d.ts +28 -19
  183. package/resources/hris/individuals/employment-data.d.ts.map +1 -0
  184. package/resources/hris/individuals/employment-data.js +70 -0
  185. package/resources/hris/individuals/employment-data.js.map +1 -0
  186. package/resources/hris/individuals/employment-data.mjs +25 -0
  187. package/resources/hris/individuals/employment-data.mjs.map +1 -0
  188. package/{dist/cjs/resources → resources}/hris/individuals/index.d.ts +3 -2
  189. package/resources/hris/individuals/index.d.ts.map +1 -0
  190. package/{dist/cjs/resources → resources}/hris/individuals/index.js +10 -3
  191. package/resources/hris/individuals/index.js.map +1 -0
  192. package/resources/hris/individuals/index.mjs +4 -0
  193. package/resources/hris/individuals/index.mjs.map +1 -0
  194. package/{dist/cjs/resources → resources}/hris/individuals/individuals.d.ts +28 -15
  195. package/resources/hris/individuals/individuals.d.ts.map +1 -0
  196. package/resources/hris/individuals/individuals.js +73 -0
  197. package/resources/hris/individuals/individuals.js.map +1 -0
  198. package/resources/hris/individuals/individuals.mjs +28 -0
  199. package/resources/hris/individuals/individuals.mjs.map +1 -0
  200. package/{dist/cjs/resources → resources}/hris/pay-statements.d.ts +45 -35
  201. package/resources/hris/pay-statements.d.ts.map +1 -0
  202. package/{dist/cjs/resources → resources}/hris/pay-statements.js +8 -7
  203. package/resources/hris/pay-statements.js.map +1 -0
  204. package/resources/hris/pay-statements.mjs +21 -0
  205. package/resources/hris/pay-statements.mjs.map +1 -0
  206. package/{dist/cjs/resources → resources}/hris/payments.d.ts +16 -8
  207. package/resources/hris/payments.d.ts.map +1 -0
  208. package/{dist/cjs/resources → resources}/hris/payments.js +4 -3
  209. package/resources/hris/payments.js.map +1 -0
  210. package/resources/hris/payments.mjs +14 -0
  211. package/resources/hris/payments.mjs.map +1 -0
  212. package/{dist/cjs/resources → resources}/index.d.ts +4 -4
  213. package/resources/index.d.ts.map +1 -0
  214. package/{dist/cjs/resources → resources}/index.js +4 -4
  215. package/resources/index.js.map +1 -0
  216. package/resources/index.mjs +6 -0
  217. package/resources/index.mjs.map +1 -0
  218. package/{dist/cjs/resources → resources}/providers.d.ts +14 -7
  219. package/resources/providers.d.ts.map +1 -0
  220. package/{dist/cjs/resources → resources}/providers.js +3 -2
  221. package/resources/providers.js.map +1 -0
  222. package/resources/providers.mjs +14 -0
  223. package/resources/providers.mjs.map +1 -0
  224. package/resources/top-level.d.ts.map +1 -0
  225. package/resources/top-level.js.map +1 -0
  226. package/resources/top-level.mjs +3 -0
  227. package/resources/top-level.mjs.map +1 -0
  228. package/src/_shims/agent.node.ts +22 -0
  229. package/src/_shims/agent.ts +12 -0
  230. package/src/_shims/fetch.d.ts +52 -0
  231. package/src/_shims/fetch.js +13 -0
  232. package/src/_shims/fetch.mjs +15 -0
  233. package/src/_shims/fetch.node.d.ts +53 -0
  234. package/src/_shims/fetch.node.js +12 -0
  235. package/src/_shims/fetch.node.mjs +14 -0
  236. package/src/_shims/fileFromPath.node.ts +29 -0
  237. package/src/_shims/fileFromPath.ts +29 -0
  238. package/src/_shims/formdata.d.ts +43 -0
  239. package/src/_shims/formdata.js +9 -0
  240. package/src/_shims/formdata.mjs +11 -0
  241. package/src/_shims/formdata.node.d.ts +44 -0
  242. package/src/_shims/formdata.node.js +11 -0
  243. package/src/_shims/formdata.node.mjs +9 -0
  244. package/src/_shims/getMultipartRequestOptions.node.ts +25 -0
  245. package/src/_shims/getMultipartRequestOptions.ts +14 -0
  246. package/src/_shims/node-readable.node.ts +10 -0
  247. package/src/_shims/node-readable.ts +30 -0
  248. package/{core.ts → src/core.ts} +69 -177
  249. package/src/error.ts +115 -0
  250. package/{index.ts → src/index.ts} +78 -27
  251. package/{pagination.ts → src/pagination.ts} +4 -1
  252. package/{resources → src/resources}/account.ts +8 -2
  253. package/{resources → src/resources}/ats/applications.ts +13 -7
  254. package/src/resources/ats/ats.ts +39 -0
  255. package/{resources → src/resources}/ats/candidates.ts +16 -10
  256. package/src/resources/ats/index.ts +8 -0
  257. package/{resources → src/resources}/ats/jobs.ts +16 -10
  258. package/{resources → src/resources}/ats/offers.ts +12 -6
  259. package/{resources → src/resources}/ats/stages.ts +11 -3
  260. package/{resources → src/resources}/hris/benefits/benefits.ts +35 -4
  261. package/{resources → src/resources}/hris/benefits/index.ts +2 -0
  262. package/{resources → src/resources}/hris/benefits/individuals.ts +25 -5
  263. package/{resources → src/resources}/hris/company.ts +47 -42
  264. package/{resources → src/resources}/hris/directory.ts +23 -17
  265. package/{resources → src/resources}/hris/hris.ts +47 -1
  266. package/{resources → src/resources}/hris/index.ts +7 -4
  267. package/{resources → src/resources}/hris/individuals/employment-data.ts +31 -21
  268. package/{resources → src/resources}/hris/individuals/index.ts +1 -0
  269. package/{resources → src/resources}/hris/individuals/individuals.ts +31 -16
  270. package/{resources → src/resources}/hris/pay-statements.ts +47 -36
  271. package/{resources → src/resources}/hris/payments.ts +18 -9
  272. package/{resources → src/resources}/providers.ts +16 -8
  273. package/src/streaming.ts +204 -0
  274. package/src/uploads.ts +248 -0
  275. package/src/version.ts +1 -0
  276. package/{dist/cjs/streaming.d.ts → streaming.d.ts} +4 -3
  277. package/streaming.d.ts.map +1 -0
  278. package/streaming.js +155 -0
  279. package/streaming.js.map +1 -0
  280. package/streaming.mjs +151 -0
  281. package/streaming.mjs.map +1 -0
  282. package/uploads.d.ts +90 -0
  283. package/uploads.d.ts.map +1 -0
  284. package/uploads.js +207 -0
  285. package/uploads.js.map +1 -0
  286. package/uploads.mjs +174 -0
  287. package/uploads.mjs.map +1 -0
  288. package/version.d.ts +2 -0
  289. package/version.d.ts.map +1 -0
  290. package/{dist/cjs/version.js → version.js} +1 -1
  291. package/version.js.map +1 -0
  292. package/version.mjs +2 -0
  293. package/version.mjs.map +1 -0
  294. package/.eslintrc.js +0 -10
  295. package/.github/workflows/publish-npm.yml +0 -28
  296. package/.github/workflows/release-doctor.yml +0 -20
  297. package/.github/workflows/release.yml +0 -38
  298. package/.prettierignore +0 -1
  299. package/.prettierrc +0 -6
  300. package/.release-please-manifest.json +0 -3
  301. package/.stats.yml +0 -1
  302. package/CHANGELOG.md +0 -40
  303. package/LICENSE +0 -201
  304. package/README.md +0 -219
  305. package/api.md +0 -186
  306. package/bin/check-release-environment +0 -25
  307. package/bin/check-test-server +0 -50
  308. package/bin/publish-npm +0 -6
  309. package/build +0 -12
  310. package/check-version.ts +0 -18
  311. package/dist/cjs/check-version.d.ts +0 -2
  312. package/dist/cjs/check-version.d.ts.map +0 -1
  313. package/dist/cjs/check-version.js +0 -23
  314. package/dist/cjs/check-version.js.map +0 -1
  315. package/dist/cjs/core.d.ts.map +0 -1
  316. package/dist/cjs/core.js +0 -950
  317. package/dist/cjs/core.js.map +0 -1
  318. package/dist/cjs/fetch-polyfill.d.ts +0 -6
  319. package/dist/cjs/fetch-polyfill.d.ts.map +0 -1
  320. package/dist/cjs/fetch-polyfill.js +0 -57
  321. package/dist/cjs/fetch-polyfill.js.map +0 -1
  322. package/dist/cjs/index.d.ts +0 -118
  323. package/dist/cjs/index.d.ts.map +0 -1
  324. package/dist/cjs/index.js.map +0 -1
  325. package/dist/cjs/pagination.d.ts.map +0 -1
  326. package/dist/cjs/pagination.js.map +0 -1
  327. package/dist/cjs/resource.d.ts.map +0 -1
  328. package/dist/cjs/resource.js.map +0 -1
  329. package/dist/cjs/resources/account.d.ts.map +0 -1
  330. package/dist/cjs/resources/account.js.map +0 -1
  331. package/dist/cjs/resources/ats/applications.d.ts.map +0 -1
  332. package/dist/cjs/resources/ats/applications.js.map +0 -1
  333. package/dist/cjs/resources/ats/ats.d.ts +0 -14
  334. package/dist/cjs/resources/ats/ats.d.ts.map +0 -1
  335. package/dist/cjs/resources/ats/ats.js +0 -22
  336. package/dist/cjs/resources/ats/ats.js.map +0 -1
  337. package/dist/cjs/resources/ats/candidates.d.ts.map +0 -1
  338. package/dist/cjs/resources/ats/candidates.js.map +0 -1
  339. package/dist/cjs/resources/ats/index.d.ts +0 -6
  340. package/dist/cjs/resources/ats/index.d.ts.map +0 -1
  341. package/dist/cjs/resources/ats/index.js +0 -12
  342. package/dist/cjs/resources/ats/index.js.map +0 -1
  343. package/dist/cjs/resources/ats/jobs.d.ts.map +0 -1
  344. package/dist/cjs/resources/ats/jobs.js.map +0 -1
  345. package/dist/cjs/resources/ats/offers.d.ts.map +0 -1
  346. package/dist/cjs/resources/ats/offers.js.map +0 -1
  347. package/dist/cjs/resources/ats/stages.d.ts.map +0 -1
  348. package/dist/cjs/resources/ats/stages.js.map +0 -1
  349. package/dist/cjs/resources/hris/benefits/benefits.d.ts.map +0 -1
  350. package/dist/cjs/resources/hris/benefits/benefits.js +0 -57
  351. package/dist/cjs/resources/hris/benefits/benefits.js.map +0 -1
  352. package/dist/cjs/resources/hris/benefits/index.d.ts.map +0 -1
  353. package/dist/cjs/resources/hris/benefits/index.js.map +0 -1
  354. package/dist/cjs/resources/hris/benefits/individuals.d.ts.map +0 -1
  355. package/dist/cjs/resources/hris/benefits/individuals.js.map +0 -1
  356. package/dist/cjs/resources/hris/company.d.ts.map +0 -1
  357. package/dist/cjs/resources/hris/company.js.map +0 -1
  358. package/dist/cjs/resources/hris/directory.d.ts.map +0 -1
  359. package/dist/cjs/resources/hris/directory.js.map +0 -1
  360. package/dist/cjs/resources/hris/hris.d.ts +0 -95
  361. package/dist/cjs/resources/hris/hris.d.ts.map +0 -1
  362. package/dist/cjs/resources/hris/hris.js +0 -24
  363. package/dist/cjs/resources/hris/hris.js.map +0 -1
  364. package/dist/cjs/resources/hris/index.d.ts.map +0 -1
  365. package/dist/cjs/resources/hris/index.js +0 -44
  366. package/dist/cjs/resources/hris/index.js.map +0 -1
  367. package/dist/cjs/resources/hris/individuals/employment-data.d.ts.map +0 -1
  368. package/dist/cjs/resources/hris/individuals/employment-data.js +0 -26
  369. package/dist/cjs/resources/hris/individuals/employment-data.js.map +0 -1
  370. package/dist/cjs/resources/hris/individuals/index.d.ts.map +0 -1
  371. package/dist/cjs/resources/hris/individuals/index.js.map +0 -1
  372. package/dist/cjs/resources/hris/individuals/individuals.d.ts.map +0 -1
  373. package/dist/cjs/resources/hris/individuals/individuals.js +0 -28
  374. package/dist/cjs/resources/hris/individuals/individuals.js.map +0 -1
  375. package/dist/cjs/resources/hris/pay-statements.d.ts.map +0 -1
  376. package/dist/cjs/resources/hris/pay-statements.js.map +0 -1
  377. package/dist/cjs/resources/hris/payments.d.ts.map +0 -1
  378. package/dist/cjs/resources/hris/payments.js.map +0 -1
  379. package/dist/cjs/resources/index.d.ts.map +0 -1
  380. package/dist/cjs/resources/index.js.map +0 -1
  381. package/dist/cjs/resources/providers.d.ts.map +0 -1
  382. package/dist/cjs/resources/providers.js.map +0 -1
  383. package/dist/cjs/resources/top-level.d.ts.map +0 -1
  384. package/dist/cjs/resources/top-level.js.map +0 -1
  385. package/dist/cjs/streaming.d.ts.map +0 -1
  386. package/dist/cjs/streaming.js +0 -220
  387. package/dist/cjs/streaming.js.map +0 -1
  388. package/dist/cjs/tests/api-resources/account.test.d.ts +0 -2
  389. package/dist/cjs/tests/api-resources/account.test.d.ts.map +0 -1
  390. package/dist/cjs/tests/api-resources/account.test.js +0 -66
  391. package/dist/cjs/tests/api-resources/account.test.js.map +0 -1
  392. package/dist/cjs/tests/api-resources/ats/applications.test.d.ts +0 -2
  393. package/dist/cjs/tests/api-resources/ats/applications.test.d.ts.map +0 -1
  394. package/dist/cjs/tests/api-resources/ats/applications.test.js +0 -73
  395. package/dist/cjs/tests/api-resources/ats/applications.test.js.map +0 -1
  396. package/dist/cjs/tests/api-resources/ats/candidates.test.d.ts +0 -2
  397. package/dist/cjs/tests/api-resources/ats/candidates.test.d.ts.map +0 -1
  398. package/dist/cjs/tests/api-resources/ats/candidates.test.js +0 -73
  399. package/dist/cjs/tests/api-resources/ats/candidates.test.js.map +0 -1
  400. package/dist/cjs/tests/api-resources/ats/jobs.test.d.ts +0 -2
  401. package/dist/cjs/tests/api-resources/ats/jobs.test.d.ts.map +0 -1
  402. package/dist/cjs/tests/api-resources/ats/jobs.test.js +0 -73
  403. package/dist/cjs/tests/api-resources/ats/jobs.test.js.map +0 -1
  404. package/dist/cjs/tests/api-resources/ats/offers.test.d.ts +0 -2
  405. package/dist/cjs/tests/api-resources/ats/offers.test.d.ts.map +0 -1
  406. package/dist/cjs/tests/api-resources/ats/offers.test.js +0 -73
  407. package/dist/cjs/tests/api-resources/ats/offers.test.js.map +0 -1
  408. package/dist/cjs/tests/api-resources/ats/stages.test.d.ts +0 -2
  409. package/dist/cjs/tests/api-resources/ats/stages.test.d.ts.map +0 -1
  410. package/dist/cjs/tests/api-resources/ats/stages.test.js +0 -55
  411. package/dist/cjs/tests/api-resources/ats/stages.test.js.map +0 -1
  412. package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.d.ts +0 -2
  413. package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.d.ts.map +0 -1
  414. package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.js +0 -116
  415. package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.js.map +0 -1
  416. package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.d.ts +0 -2
  417. package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.d.ts.map +0 -1
  418. package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.js +0 -111
  419. package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.js.map +0 -1
  420. package/dist/cjs/tests/api-resources/hris/company.test.d.ts +0 -2
  421. package/dist/cjs/tests/api-resources/hris/company.test.d.ts.map +0 -1
  422. package/dist/cjs/tests/api-resources/hris/company.test.js +0 -55
  423. package/dist/cjs/tests/api-resources/hris/company.test.js.map +0 -1
  424. package/dist/cjs/tests/api-resources/hris/directory.test.d.ts +0 -2
  425. package/dist/cjs/tests/api-resources/hris/directory.test.d.ts.map +0 -1
  426. package/dist/cjs/tests/api-resources/hris/directory.test.js +0 -62
  427. package/dist/cjs/tests/api-resources/hris/directory.test.js.map +0 -1
  428. package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.d.ts +0 -2
  429. package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.d.ts.map +0 -1
  430. package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.js +0 -56
  431. package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.js.map +0 -1
  432. package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.d.ts +0 -2
  433. package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.d.ts.map +0 -1
  434. package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.js +0 -68
  435. package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.js.map +0 -1
  436. package/dist/cjs/tests/api-resources/hris/pay-statements.test.d.ts +0 -2
  437. package/dist/cjs/tests/api-resources/hris/pay-statements.test.d.ts.map +0 -1
  438. package/dist/cjs/tests/api-resources/hris/pay-statements.test.js +0 -64
  439. package/dist/cjs/tests/api-resources/hris/pay-statements.test.js.map +0 -1
  440. package/dist/cjs/tests/api-resources/hris/payments.test.d.ts +0 -2
  441. package/dist/cjs/tests/api-resources/hris/payments.test.d.ts.map +0 -1
  442. package/dist/cjs/tests/api-resources/hris/payments.test.js +0 -52
  443. package/dist/cjs/tests/api-resources/hris/payments.test.js.map +0 -1
  444. package/dist/cjs/tests/api-resources/providers.test.d.ts +0 -2
  445. package/dist/cjs/tests/api-resources/providers.test.d.ts.map +0 -1
  446. package/dist/cjs/tests/api-resources/providers.test.js +0 -55
  447. package/dist/cjs/tests/api-resources/providers.test.js.map +0 -1
  448. package/dist/cjs/tests/api-resources/top-level.test.d.ts +0 -2
  449. package/dist/cjs/tests/api-resources/top-level.test.d.ts.map +0 -1
  450. package/dist/cjs/tests/api-resources/top-level.test.js +0 -52
  451. package/dist/cjs/tests/api-resources/top-level.test.js.map +0 -1
  452. package/dist/cjs/tests/form.test.d.ts +0 -2
  453. package/dist/cjs/tests/form.test.d.ts.map +0 -1
  454. package/dist/cjs/tests/form.test.js +0 -61
  455. package/dist/cjs/tests/form.test.js.map +0 -1
  456. package/dist/cjs/tests/index.test.d.ts +0 -2
  457. package/dist/cjs/tests/index.test.d.ts.map +0 -1
  458. package/dist/cjs/tests/index.test.js +0 -65
  459. package/dist/cjs/tests/index.test.js.map +0 -1
  460. package/dist/cjs/tests/responses.test.d.ts +0 -2
  461. package/dist/cjs/tests/responses.test.d.ts.map +0 -1
  462. package/dist/cjs/tests/responses.test.js +0 -60
  463. package/dist/cjs/tests/responses.test.js.map +0 -1
  464. package/dist/cjs/version.d.ts +0 -2
  465. package/dist/cjs/version.d.ts.map +0 -1
  466. package/dist/cjs/version.js.map +0 -1
  467. package/fetch-polyfill.ts +0 -69
  468. package/jest.config.js +0 -8
  469. package/release-please-config.json +0 -61
  470. package/resources/ats/ats.ts +0 -16
  471. package/resources/ats/index.ts +0 -7
  472. package/streaming.ts +0 -122
  473. package/tests/api-resources/account.test.ts +0 -29
  474. package/tests/api-resources/ats/applications.test.ts +0 -36
  475. package/tests/api-resources/ats/candidates.test.ts +0 -36
  476. package/tests/api-resources/ats/jobs.test.ts +0 -36
  477. package/tests/api-resources/ats/offers.test.ts +0 -36
  478. package/tests/api-resources/ats/stages.test.ts +0 -18
  479. package/tests/api-resources/hris/benefits/benefits.test.ts +0 -79
  480. package/tests/api-resources/hris/benefits/individuals.test.ts +0 -74
  481. package/tests/api-resources/hris/company.test.ts +0 -18
  482. package/tests/api-resources/hris/directory.test.ts +0 -25
  483. package/tests/api-resources/hris/individuals/employment-data.test.ts +0 -19
  484. package/tests/api-resources/hris/individuals/individuals.test.ts +0 -31
  485. package/tests/api-resources/hris/pay-statements.test.ts +0 -27
  486. package/tests/api-resources/hris/payments.test.ts +0 -15
  487. package/tests/api-resources/providers.test.ts +0 -18
  488. package/tests/api-resources/top-level.test.ts +0 -15
  489. package/tests/form.test.ts +0 -27
  490. package/tests/index.test.ts +0 -72
  491. package/tests/responses.test.ts +0 -25
  492. package/tsconfig.cjs.json +0 -8
  493. package/tsconfig.json +0 -39
  494. package/typings/digest-fetch/index.d.ts +0 -33
  495. package/version.ts +0 -1
  496. /package/{dist/cjs/resource.js → resource.js} +0 -0
  497. /package/{dist/cjs/resources → resources}/top-level.d.ts +0 -0
  498. /package/{dist/cjs/resources → resources}/top-level.js +0 -0
  499. /package/{resource.ts → src/resource.ts} +0 -0
  500. /package/{resources → src/resources}/index.ts +0 -0
  501. /package/{resources → src/resources}/top-level.ts +0 -0
package/core.js ADDED
@@ -0,0 +1,683 @@
1
+ 'use strict';
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create ?
5
+ function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }
18
+ : function (o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ });
22
+ var __setModuleDefault =
23
+ (this && this.__setModuleDefault) ||
24
+ (Object.create ?
25
+ function (o, v) {
26
+ Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
+ }
28
+ : function (o, v) {
29
+ o['default'] = v;
30
+ });
31
+ var __importStar =
32
+ (this && this.__importStar) ||
33
+ function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null)
37
+ for (var k in mod)
38
+ if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
+ __setModuleDefault(result, mod);
40
+ return result;
41
+ };
42
+ var __classPrivateFieldSet =
43
+ (this && this.__classPrivateFieldSet) ||
44
+ function (receiver, state, value, kind, f) {
45
+ if (kind === 'm') throw new TypeError('Private method is not writable');
46
+ if (kind === 'a' && !f) throw new TypeError('Private accessor was defined without a setter');
47
+ if (typeof state === 'function' ? receiver !== state || !f : !state.has(receiver))
48
+ throw new TypeError('Cannot write private member to an object whose class did not declare it');
49
+ return (
50
+ kind === 'a' ? f.call(receiver, value)
51
+ : f ? (f.value = value)
52
+ : state.set(receiver, value),
53
+ value
54
+ );
55
+ };
56
+ var __classPrivateFieldGet =
57
+ (this && this.__classPrivateFieldGet) ||
58
+ function (receiver, state, kind, f) {
59
+ if (kind === 'a' && !f) throw new TypeError('Private accessor was defined without a getter');
60
+ if (typeof state === 'function' ? receiver !== state || !f : !state.has(receiver))
61
+ throw new TypeError('Cannot read private member from an object whose class did not declare it');
62
+ return (
63
+ kind === 'm' ? f
64
+ : kind === 'a' ? f.call(receiver)
65
+ : f ? f.value
66
+ : state.get(receiver)
67
+ );
68
+ };
69
+ var _AbstractPage_client;
70
+ Object.defineProperty(exports, '__esModule', { value: true });
71
+ exports.getHeader =
72
+ exports.isHeadersProtocol =
73
+ exports.hasOwn =
74
+ exports.isEmptyObj =
75
+ exports.coerceBoolean =
76
+ exports.coerceFloat =
77
+ exports.coerceInteger =
78
+ exports.ensurePresent =
79
+ exports.castToError =
80
+ exports.safeJSON =
81
+ exports.isRequestOptions =
82
+ exports.createResponseHeaders =
83
+ exports.PagePromise =
84
+ exports.AbstractPage =
85
+ exports.APIResource =
86
+ exports.APIClient =
87
+ exports.createForm =
88
+ exports.multipartFormRequestOptions =
89
+ exports.maybeMultipartFormRequestOptions =
90
+ void 0;
91
+ const qs = __importStar(require('qs'));
92
+ const version_1 = require('./version.js');
93
+ const streaming_1 = require('./streaming.js');
94
+ const error_1 = require('./error.js');
95
+ const agent_1 = require('@tryfinch/finch-api/_shims/agent');
96
+ const fetch_1 = require('@tryfinch/finch-api/_shims/fetch');
97
+ const uploads_1 = require('./uploads.js');
98
+ var uploads_2 = require('./uploads.js');
99
+ Object.defineProperty(exports, 'maybeMultipartFormRequestOptions', {
100
+ enumerable: true,
101
+ get: function () {
102
+ return uploads_2.maybeMultipartFormRequestOptions;
103
+ },
104
+ });
105
+ Object.defineProperty(exports, 'multipartFormRequestOptions', {
106
+ enumerable: true,
107
+ get: function () {
108
+ return uploads_2.multipartFormRequestOptions;
109
+ },
110
+ });
111
+ Object.defineProperty(exports, 'createForm', {
112
+ enumerable: true,
113
+ get: function () {
114
+ return uploads_2.createForm;
115
+ },
116
+ });
117
+ const MAX_RETRIES = 2;
118
+ class APIClient {
119
+ constructor({
120
+ baseURL,
121
+ maxRetries,
122
+ timeout = 60 * 1000, // 60s
123
+ httpAgent,
124
+ }) {
125
+ this.baseURL = baseURL;
126
+ this.maxRetries = validatePositiveInteger(
127
+ 'maxRetries',
128
+ maxRetries !== null && maxRetries !== void 0 ? maxRetries : MAX_RETRIES,
129
+ );
130
+ this.timeout = validatePositiveInteger('timeout', timeout);
131
+ this.httpAgent = httpAgent;
132
+ this.fetch = fetch_1.fetch;
133
+ }
134
+ authHeaders() {
135
+ return {};
136
+ }
137
+ /**
138
+ * Override this to add your own default headers, for example:
139
+ *
140
+ * {
141
+ * ...super.defaultHeaders(),
142
+ * Authorization: 'Bearer 123',
143
+ * }
144
+ */
145
+ defaultHeaders() {
146
+ return {
147
+ Accept: 'application/json',
148
+ 'Content-Type': 'application/json',
149
+ 'User-Agent': this.getUserAgent(),
150
+ ...getPlatformHeaders(),
151
+ ...this.authHeaders(),
152
+ };
153
+ }
154
+ /**
155
+ * Override this to add your own headers validation:
156
+ */
157
+ validateHeaders(headers, customHeaders) {}
158
+ /**
159
+ * Override this to add your own qs.stringify options, for example:
160
+ *
161
+ * {
162
+ * ...super.qsOptions(),
163
+ * strictNullHandling: true,
164
+ * }
165
+ */
166
+ qsOptions() {
167
+ return {};
168
+ }
169
+ defaultIdempotencyKey() {
170
+ return `stainless-node-retry-${uuid4()}`;
171
+ }
172
+ get(path, opts) {
173
+ return this.request({ method: 'get', path, ...opts });
174
+ }
175
+ post(path, opts) {
176
+ return this.request({ method: 'post', path, ...opts });
177
+ }
178
+ patch(path, opts) {
179
+ return this.request({ method: 'patch', path, ...opts });
180
+ }
181
+ put(path, opts) {
182
+ return this.request({ method: 'put', path, ...opts });
183
+ }
184
+ delete(path, opts) {
185
+ return this.request({ method: 'delete', path, ...opts });
186
+ }
187
+ getAPIList(path, Page, opts) {
188
+ return this.requestAPIList(Page, { method: 'get', path, ...opts });
189
+ }
190
+ buildRequest(options) {
191
+ var _a, _b, _c;
192
+ const { method, path, query, headers: headers = {} } = options;
193
+ const body =
194
+ (0, uploads_1.isMultipartBody)(options.body) ? options.body.body
195
+ : options.body ? JSON.stringify(options.body, null, 2)
196
+ : null;
197
+ const contentLength = typeof body === 'string' ? body.length.toString() : null;
198
+ const url = this.buildURL(path, query);
199
+ const httpAgent =
200
+ (
201
+ (_b = (_a = options.httpAgent) !== null && _a !== void 0 ? _a : this.httpAgent) !== null &&
202
+ _b !== void 0
203
+ ) ?
204
+ _b
205
+ : (0, agent_1.getDefaultAgent)(url);
206
+ const timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : this.timeout;
207
+ validatePositiveInteger('timeout', timeout);
208
+ if (this.idempotencyHeader && method !== 'get') {
209
+ if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
210
+ headers[this.idempotencyHeader] = options.idempotencyKey;
211
+ }
212
+ const reqHeaders = {
213
+ ...(contentLength && { 'Content-Length': contentLength }),
214
+ ...this.defaultHeaders(),
215
+ ...headers,
216
+ };
217
+ // let builtin fetch set the Content-Type for multipart bodies
218
+ if ((0, uploads_1.isMultipartBody)(options.body) && !fetch_1.isPolyfilled) {
219
+ delete reqHeaders['Content-Type'];
220
+ }
221
+ // Strip any headers being explicitly omitted with null
222
+ Object.keys(reqHeaders).forEach((key) => reqHeaders[key] === null && delete reqHeaders[key]);
223
+ const req = {
224
+ method,
225
+ ...(body && { body: body }),
226
+ headers: reqHeaders,
227
+ ...(httpAgent && { agent: httpAgent }),
228
+ };
229
+ this.validateHeaders(reqHeaders, headers);
230
+ return { req, url, timeout };
231
+ }
232
+ /**
233
+ * Used as a callback for mutating the given `RequestInit` object.
234
+ *
235
+ * This is useful for cases where you want to add certain headers based off of
236
+ * the request properties, e.g. `method` or `url`.
237
+ */
238
+ async prepareRequest(request, { url }) {}
239
+ makeStatusError(status, error, message, headers) {
240
+ return error_1.APIError.generate(status, error, message, headers);
241
+ }
242
+ async request(options, retriesRemaining) {
243
+ var _a;
244
+ if (retriesRemaining === void 0) {
245
+ retriesRemaining = (_a = options.maxRetries) !== null && _a !== void 0 ? _a : this.maxRetries;
246
+ }
247
+ const { req, url, timeout } = this.buildRequest(options);
248
+ await this.prepareRequest(req, { url });
249
+ this.debug('request', url, options, req.headers);
250
+ const controller = new AbortController();
251
+ const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(exports.castToError);
252
+ if (response instanceof Error) {
253
+ if (retriesRemaining) return this.retryRequest(options, retriesRemaining);
254
+ if (response.name === 'AbortError') throw new error_1.APIConnectionTimeoutError();
255
+ throw new error_1.APIConnectionError({ cause: response });
256
+ }
257
+ const responseHeaders = (0, exports.createResponseHeaders)(response.headers);
258
+ if (!response.ok) {
259
+ if (retriesRemaining && this.shouldRetry(response)) {
260
+ return this.retryRequest(options, retriesRemaining, responseHeaders);
261
+ }
262
+ const errText = await response.text().catch(() => 'Unknown');
263
+ const errJSON = (0, exports.safeJSON)(errText);
264
+ const errMessage = errJSON ? undefined : errText;
265
+ this.debug('response', response.status, url, responseHeaders, errMessage);
266
+ const err = this.makeStatusError(response.status, errJSON, errMessage, responseHeaders);
267
+ throw err;
268
+ }
269
+ if (options.stream) {
270
+ // Note: there is an invariant here that isn't represented in the type system
271
+ // that if you set `stream: true` the response type must also be `Stream<T>`
272
+ return new streaming_1.Stream(response, controller);
273
+ }
274
+ const contentType = response.headers.get('content-type');
275
+ if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('application/json')) {
276
+ const json = await response.json();
277
+ if (typeof json === 'object' && json != null) {
278
+ /** @deprecated – we expect to change this interface in the near future. */
279
+ Object.defineProperty(json, 'responseHeaders', {
280
+ enumerable: false,
281
+ writable: false,
282
+ value: responseHeaders,
283
+ });
284
+ }
285
+ this.debug('response', response.status, url, responseHeaders, json);
286
+ return json;
287
+ }
288
+ // TODO handle blob, arraybuffer, other content types, etc.
289
+ const text = response.text();
290
+ this.debug('response', response.status, url, responseHeaders, text);
291
+ return text;
292
+ }
293
+ requestAPIList(Page, options) {
294
+ const requestPromise = this.request(options);
295
+ return new PagePromise(this, requestPromise, options, Page);
296
+ }
297
+ buildURL(path, query) {
298
+ const url =
299
+ isAbsoluteURL(path) ?
300
+ new URL(path)
301
+ : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
302
+ const defaultQuery = this.defaultQuery();
303
+ if (!isEmptyObj(defaultQuery)) {
304
+ query = { ...defaultQuery, ...query };
305
+ }
306
+ if (query) {
307
+ url.search = qs.stringify(query, this.qsOptions());
308
+ }
309
+ return url.toString();
310
+ }
311
+ async fetchWithTimeout(url, init, ms, controller) {
312
+ const { signal, ...options } = init || {};
313
+ if (signal) signal.addEventListener('abort', () => controller.abort());
314
+ const timeout = setTimeout(() => controller.abort(), ms);
315
+ return this.getRequestClient()
316
+ .fetch(url, { signal: controller.signal, ...options })
317
+ .finally(() => {
318
+ clearTimeout(timeout);
319
+ });
320
+ }
321
+ getRequestClient() {
322
+ return { fetch: this.fetch };
323
+ }
324
+ shouldRetry(response) {
325
+ // Note this is not a standard header.
326
+ const shouldRetryHeader = response.headers.get('x-should-retry');
327
+ // If the server explicitly says whether or not to retry, obey.
328
+ if (shouldRetryHeader === 'true') return true;
329
+ if (shouldRetryHeader === 'false') return false;
330
+ // Retry on lock timeouts.
331
+ if (response.status === 409) return true;
332
+ // Retry on rate limits.
333
+ if (response.status === 429) return true;
334
+ // Retry internal errors.
335
+ if (response.status >= 500) return true;
336
+ return false;
337
+ }
338
+ async retryRequest(options, retriesRemaining, responseHeaders) {
339
+ var _a;
340
+ retriesRemaining -= 1;
341
+ // About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
342
+ //
343
+ // TODO: we may want to handle the case where the header is using the http-date syntax: "Retry-After: <http-date>".
344
+ // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#syntax for details.
345
+ const retryAfter = parseInt(
346
+ (responseHeaders === null || responseHeaders === void 0 ? void 0 : responseHeaders['retry-after']) ||
347
+ '',
348
+ );
349
+ const maxRetries = (_a = options.maxRetries) !== null && _a !== void 0 ? _a : this.maxRetries;
350
+ const timeout = this.calculateRetryTimeoutSeconds(retriesRemaining, retryAfter, maxRetries) * 1000;
351
+ await sleep(timeout);
352
+ return this.request(options, retriesRemaining);
353
+ }
354
+ calculateRetryTimeoutSeconds(retriesRemaining, retryAfter, maxRetries) {
355
+ const initialRetryDelay = 0.5;
356
+ const maxRetryDelay = 2;
357
+ // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
358
+ // just do what it says.
359
+ if (Number.isInteger(retryAfter) && retryAfter <= 60) {
360
+ return retryAfter;
361
+ }
362
+ const numRetries = maxRetries - retriesRemaining;
363
+ // Apply exponential backoff, but not more than the max.
364
+ const sleepSeconds = Math.min(initialRetryDelay * Math.pow(numRetries - 1, 2), maxRetryDelay);
365
+ // Apply some jitter, plus-or-minus half a second.
366
+ const jitter = Math.random() - 0.5;
367
+ return sleepSeconds + jitter;
368
+ }
369
+ getUserAgent() {
370
+ return `${this.constructor.name}/JS ${version_1.VERSION}`;
371
+ }
372
+ debug(action, ...args) {
373
+ if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') {
374
+ console.log(`${this.constructor.name}:DEBUG:${action}`, ...args);
375
+ }
376
+ }
377
+ }
378
+ exports.APIClient = APIClient;
379
+ class APIResource {
380
+ constructor(client) {
381
+ this.client = client;
382
+ this.get = client.get.bind(client);
383
+ this.post = client.post.bind(client);
384
+ this.patch = client.patch.bind(client);
385
+ this.put = client.put.bind(client);
386
+ this.delete = client.delete.bind(client);
387
+ this.getAPIList = client.getAPIList.bind(client);
388
+ }
389
+ }
390
+ exports.APIResource = APIResource;
391
+ class AbstractPage {
392
+ constructor(client, response, options) {
393
+ _AbstractPage_client.set(this, void 0);
394
+ __classPrivateFieldSet(this, _AbstractPage_client, client, 'f');
395
+ this.options = options;
396
+ }
397
+ hasNextPage() {
398
+ const items = this.getPaginatedItems();
399
+ if (!items.length) return false;
400
+ return this.nextPageInfo() != null;
401
+ }
402
+ async getNextPage() {
403
+ const nextInfo = this.nextPageInfo();
404
+ if (!nextInfo) {
405
+ throw new Error(
406
+ 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
407
+ );
408
+ }
409
+ const nextOptions = { ...this.options };
410
+ if ('params' in nextInfo) {
411
+ nextOptions.query = { ...nextOptions.query, ...nextInfo.params };
412
+ } else if ('url' in nextInfo) {
413
+ const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()];
414
+ for (const [key, value] of params) {
415
+ nextInfo.url.searchParams.set(key, value);
416
+ }
417
+ nextOptions.query = undefined;
418
+ nextOptions.path = nextInfo.url.toString();
419
+ }
420
+ return await __classPrivateFieldGet(this, _AbstractPage_client, 'f').requestAPIList(
421
+ this.constructor,
422
+ nextOptions,
423
+ );
424
+ }
425
+ async *iterPages() {
426
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
427
+ let page = this;
428
+ yield page;
429
+ while (page.hasNextPage()) {
430
+ page = await page.getNextPage();
431
+ yield page;
432
+ }
433
+ }
434
+ async *[((_AbstractPage_client = new WeakMap()), Symbol.asyncIterator)]() {
435
+ for await (const page of this.iterPages()) {
436
+ for (const item of page.getPaginatedItems()) {
437
+ yield item;
438
+ }
439
+ }
440
+ }
441
+ }
442
+ exports.AbstractPage = AbstractPage;
443
+ class PagePromise extends Promise {
444
+ /**
445
+ * This subclass of Promise will resolve to an instantiated Page once the request completes.
446
+ */
447
+ constructor(client, requestPromise, options, Page) {
448
+ super((resolve, reject) =>
449
+ requestPromise.then((response) => resolve(new Page(client, response, options))).catch(reject),
450
+ );
451
+ }
452
+ /**
453
+ * Enable subclassing Promise.
454
+ * Ref: https://stackoverflow.com/a/60328122
455
+ */
456
+ static get [Symbol.species]() {
457
+ return Promise;
458
+ }
459
+ /**
460
+ * Allow auto-paginating iteration on an unawaited list call, eg:
461
+ *
462
+ * for await (const item of client.items.list()) {
463
+ * console.log(item)
464
+ * }
465
+ */
466
+ async *[Symbol.asyncIterator]() {
467
+ const page = await this;
468
+ for await (const item of page) {
469
+ yield item;
470
+ }
471
+ }
472
+ }
473
+ exports.PagePromise = PagePromise;
474
+ const createResponseHeaders = (headers) => {
475
+ return new Proxy(
476
+ Object.fromEntries(
477
+ // @ts-ignore
478
+ headers.entries(),
479
+ ),
480
+ {
481
+ get(target, name) {
482
+ const key = name.toString();
483
+ return target[key.toLowerCase()] || target[key];
484
+ },
485
+ },
486
+ );
487
+ };
488
+ exports.createResponseHeaders = createResponseHeaders;
489
+ // This is required so that we can determine if a given object matches the RequestOptions
490
+ // type at runtime. While this requires duplication, it is enforced by the TypeScript
491
+ // compiler such that any missing / extraneous keys will cause an error.
492
+ const requestOptionsKeys = {
493
+ method: true,
494
+ path: true,
495
+ query: true,
496
+ body: true,
497
+ headers: true,
498
+ maxRetries: true,
499
+ stream: true,
500
+ timeout: true,
501
+ httpAgent: true,
502
+ idempotencyKey: true,
503
+ };
504
+ const isRequestOptions = (obj) => {
505
+ return (
506
+ typeof obj === 'object' &&
507
+ obj !== null &&
508
+ !isEmptyObj(obj) &&
509
+ Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k))
510
+ );
511
+ };
512
+ exports.isRequestOptions = isRequestOptions;
513
+ const getPlatformProperties = () => {
514
+ if (typeof Deno !== 'undefined' && Deno.build != null) {
515
+ return {
516
+ 'X-Stainless-Lang': 'js',
517
+ 'X-Stainless-Package-Version': version_1.VERSION,
518
+ 'X-Stainless-OS': normalizePlatform(Deno.build.os),
519
+ 'X-Stainless-Arch': normalizeArch(Deno.build.arch),
520
+ 'X-Stainless-Runtime': 'deno',
521
+ 'X-Stainless-Runtime-Version': Deno.version,
522
+ };
523
+ }
524
+ if (typeof EdgeRuntime !== 'undefined') {
525
+ return {
526
+ 'X-Stainless-Lang': 'js',
527
+ 'X-Stainless-Package-Version': version_1.VERSION,
528
+ 'X-Stainless-OS': 'Unknown',
529
+ 'X-Stainless-Arch': `other:${EdgeRuntime}`,
530
+ 'X-Stainless-Runtime': 'edge',
531
+ 'X-Stainless-Runtime-Version': process.version,
532
+ };
533
+ }
534
+ // Check if Node.js
535
+ if (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') {
536
+ return {
537
+ 'X-Stainless-Lang': 'js',
538
+ 'X-Stainless-Package-Version': version_1.VERSION,
539
+ 'X-Stainless-OS': normalizePlatform(process.platform),
540
+ 'X-Stainless-Arch': normalizeArch(process.arch),
541
+ 'X-Stainless-Runtime': 'node',
542
+ 'X-Stainless-Runtime-Version': process.version,
543
+ };
544
+ }
545
+ // TODO add support for Cloudflare workers, browsers, etc.
546
+ return {
547
+ 'X-Stainless-Lang': 'js',
548
+ 'X-Stainless-Package-Version': version_1.VERSION,
549
+ 'X-Stainless-OS': 'Unknown',
550
+ 'X-Stainless-Arch': 'unknown',
551
+ 'X-Stainless-Runtime': 'unknown',
552
+ 'X-Stainless-Runtime-Version': 'unknown',
553
+ };
554
+ };
555
+ const normalizeArch = (arch) => {
556
+ // Node docs:
557
+ // - https://nodejs.org/api/process.html#processarch
558
+ // Deno docs:
559
+ // - https://doc.deno.land/deno/stable/~/Deno.build
560
+ if (arch === 'x32') return 'x32';
561
+ if (arch === 'x86_64' || arch === 'x64') return 'x64';
562
+ if (arch === 'arm') return 'arm';
563
+ if (arch === 'aarch64' || arch === 'arm64') return 'arm64';
564
+ if (arch) return `other:${arch}`;
565
+ return 'unknown';
566
+ };
567
+ const normalizePlatform = (platform) => {
568
+ // Node platforms:
569
+ // - https://nodejs.org/api/process.html#processplatform
570
+ // Deno platforms:
571
+ // - https://doc.deno.land/deno/stable/~/Deno.build
572
+ // - https://github.com/denoland/deno/issues/14799
573
+ platform = platform.toLowerCase();
574
+ // NOTE: this iOS check is untested and may not work
575
+ // Node does not work natively on IOS, there is a fork at
576
+ // https://github.com/nodejs-mobile/nodejs-mobile
577
+ // however it is unknown at the time of writing how to detect if it is running
578
+ if (platform.includes('ios')) return 'iOS';
579
+ if (platform === 'android') return 'Android';
580
+ if (platform === 'darwin') return 'MacOS';
581
+ if (platform === 'win32') return 'Windows';
582
+ if (platform === 'freebsd') return 'FreeBSD';
583
+ if (platform === 'openbsd') return 'OpenBSD';
584
+ if (platform === 'linux') return 'Linux';
585
+ if (platform) return `Other:${platform}`;
586
+ return 'Unknown';
587
+ };
588
+ let _platformHeaders;
589
+ const getPlatformHeaders = () => {
590
+ return _platformHeaders !== null && _platformHeaders !== void 0 ?
591
+ _platformHeaders
592
+ : (_platformHeaders = getPlatformProperties());
593
+ };
594
+ const safeJSON = (text) => {
595
+ try {
596
+ return JSON.parse(text);
597
+ } catch (err) {
598
+ return undefined;
599
+ }
600
+ };
601
+ exports.safeJSON = safeJSON;
602
+ // https://stackoverflow.com/a/19709846
603
+ const startsWithSchemeRegexp = new RegExp('^(?:[a-z]+:)?//', 'i');
604
+ const isAbsoluteURL = (url) => {
605
+ return startsWithSchemeRegexp.test(url);
606
+ };
607
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
608
+ const validatePositiveInteger = (name, n) => {
609
+ if (!Number.isInteger(n)) {
610
+ throw new Error(`${name} must be an integer`);
611
+ }
612
+ if (n < 0) {
613
+ throw new Error(`${name} must be a positive integer`);
614
+ }
615
+ return n;
616
+ };
617
+ const castToError = (err) => {
618
+ if (err instanceof Error) return err;
619
+ return new Error(err);
620
+ };
621
+ exports.castToError = castToError;
622
+ const ensurePresent = (value) => {
623
+ if (value == null) throw new Error(`Expected a value to be given but received ${value} instead.`);
624
+ return value;
625
+ };
626
+ exports.ensurePresent = ensurePresent;
627
+ const coerceInteger = (value) => {
628
+ if (typeof value === 'number') return Math.round(value);
629
+ if (typeof value === 'string') return parseInt(value, 10);
630
+ throw new Error(`Could not coerce ${value} (type: ${typeof value}) into a number`);
631
+ };
632
+ exports.coerceInteger = coerceInteger;
633
+ const coerceFloat = (value) => {
634
+ if (typeof value === 'number') return value;
635
+ if (typeof value === 'string') return parseFloat(value);
636
+ throw new Error(`Could not coerce ${value} (type: ${typeof value}) into a number`);
637
+ };
638
+ exports.coerceFloat = coerceFloat;
639
+ const coerceBoolean = (value) => {
640
+ if (typeof value === 'boolean') return value;
641
+ if (typeof value === 'string') return value === 'true';
642
+ return Boolean(value);
643
+ };
644
+ exports.coerceBoolean = coerceBoolean;
645
+ // https://stackoverflow.com/a/34491287
646
+ function isEmptyObj(obj) {
647
+ if (!obj) return true;
648
+ for (const _k in obj) return false;
649
+ return true;
650
+ }
651
+ exports.isEmptyObj = isEmptyObj;
652
+ // https://eslint.org/docs/latest/rules/no-prototype-builtins
653
+ function hasOwn(obj, key) {
654
+ return Object.prototype.hasOwnProperty.call(obj, key);
655
+ }
656
+ exports.hasOwn = hasOwn;
657
+ /**
658
+ * https://stackoverflow.com/a/2117523
659
+ */
660
+ const uuid4 = () => {
661
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
662
+ const r = (Math.random() * 16) | 0;
663
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
664
+ return v.toString(16);
665
+ });
666
+ };
667
+ const isHeadersProtocol = (headers) => {
668
+ return typeof (headers === null || headers === void 0 ? void 0 : headers.get) === 'function';
669
+ };
670
+ exports.isHeadersProtocol = isHeadersProtocol;
671
+ const getHeader = (headers, key) => {
672
+ const lowerKey = key.toLowerCase();
673
+ if ((0, exports.isHeadersProtocol)(headers)) return headers.get(key) || headers.get(lowerKey);
674
+ const value = headers[key] || headers[lowerKey];
675
+ if (Array.isArray(value)) {
676
+ if (value.length <= 1) return value[0];
677
+ console.warn(`Received ${value.length} entries for the ${key} header, using the first entry.`);
678
+ return value[0];
679
+ }
680
+ return value;
681
+ };
682
+ exports.getHeader = getHeader;
683
+ //# sourceMappingURL=core.js.map