@tryfinch/finch-api 5.1.0 → 5.2.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 (360) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +28 -21
  3. package/_shims/MultipartBody.d.ts +9 -0
  4. package/_shims/MultipartBody.d.ts.map +1 -0
  5. package/_shims/MultipartBody.js +16 -0
  6. package/_shims/MultipartBody.js.map +1 -0
  7. package/_shims/MultipartBody.mjs +12 -0
  8. package/_shims/MultipartBody.mjs.map +1 -0
  9. package/_shims/README.md +46 -0
  10. package/{src/_shims/ReadableStream-node.ts → _shims/auto/runtime-bun.d.ts} +2 -3
  11. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  12. package/_shims/auto/runtime-bun.js +21 -0
  13. package/_shims/auto/runtime-bun.js.map +1 -0
  14. package/_shims/auto/runtime-bun.mjs +2 -0
  15. package/_shims/auto/runtime-bun.mjs.map +1 -0
  16. package/_shims/auto/runtime-node.d.ts +5 -0
  17. package/_shims/auto/runtime-node.d.ts.map +1 -0
  18. package/_shims/auto/runtime-node.js +21 -0
  19. package/_shims/auto/runtime-node.js.map +1 -0
  20. package/_shims/auto/runtime-node.mjs +2 -0
  21. package/_shims/auto/runtime-node.mjs.map +1 -0
  22. package/_shims/auto/runtime.d.ts +5 -0
  23. package/_shims/auto/runtime.d.ts.map +1 -0
  24. package/_shims/auto/runtime.js +21 -0
  25. package/_shims/auto/runtime.js.map +1 -0
  26. package/_shims/auto/runtime.mjs +2 -0
  27. package/_shims/auto/runtime.mjs.map +1 -0
  28. package/_shims/auto/types-node.d.ts +5 -0
  29. package/_shims/auto/types-node.d.ts.map +1 -0
  30. package/_shims/auto/types-node.js +21 -0
  31. package/_shims/auto/types-node.js.map +1 -0
  32. package/_shims/auto/types-node.mjs +2 -0
  33. package/_shims/auto/types-node.mjs.map +1 -0
  34. package/_shims/auto/types.d.ts +99 -0
  35. package/_shims/{ReadableStream.js → auto/types.js} +0 -2
  36. package/{src/_shims/ReadableStream.js → _shims/auto/types.mjs} +0 -2
  37. package/_shims/bun-runtime.d.ts +6 -0
  38. package/_shims/bun-runtime.d.ts.map +1 -0
  39. package/_shims/bun-runtime.js +14 -0
  40. package/_shims/bun-runtime.js.map +1 -0
  41. package/_shims/bun-runtime.mjs +10 -0
  42. package/_shims/bun-runtime.mjs.map +1 -0
  43. package/_shims/index.d.ts +79 -0
  44. package/_shims/index.js +13 -0
  45. package/_shims/index.mjs +7 -0
  46. package/_shims/manual-types.d.ts +12 -0
  47. package/_shims/manual-types.js +3 -0
  48. package/_shims/manual-types.mjs +3 -0
  49. package/_shims/node-runtime.d.ts +3 -0
  50. package/_shims/node-runtime.d.ts.map +1 -0
  51. package/_shims/node-runtime.js +87 -0
  52. package/_shims/node-runtime.js.map +1 -0
  53. package/_shims/node-runtime.mjs +54 -0
  54. package/_shims/node-runtime.mjs.map +1 -0
  55. package/_shims/node-types.d.ts +42 -0
  56. package/_shims/node-types.js +3 -0
  57. package/_shims/node-types.mjs +3 -0
  58. package/_shims/registry.d.ts +35 -0
  59. package/_shims/registry.d.ts.map +1 -0
  60. package/_shims/registry.js +39 -0
  61. package/_shims/registry.js.map +1 -0
  62. package/_shims/registry.mjs +35 -0
  63. package/_shims/registry.mjs.map +1 -0
  64. package/_shims/web-runtime.d.ts +5 -0
  65. package/_shims/web-runtime.d.ts.map +1 -0
  66. package/_shims/web-runtime.js +70 -0
  67. package/_shims/web-runtime.js.map +1 -0
  68. package/_shims/web-runtime.mjs +63 -0
  69. package/_shims/web-runtime.mjs.map +1 -0
  70. package/_shims/web-types.d.ts +82 -0
  71. package/_shims/web-types.js +3 -0
  72. package/_shims/web-types.mjs +3 -0
  73. package/core.d.ts +170 -223
  74. package/core.d.ts.map +1 -1
  75. package/core.js +673 -729
  76. package/core.js.map +1 -1
  77. package/core.mjs +667 -680
  78. package/core.mjs.map +1 -1
  79. package/error.d.ts +29 -31
  80. package/error.js +91 -105
  81. package/error.js.map +1 -1
  82. package/error.mjs +88 -90
  83. package/error.mjs.map +1 -1
  84. package/index.d.mts +144 -178
  85. package/index.d.ts +144 -178
  86. package/index.d.ts.map +1 -1
  87. package/index.js +144 -201
  88. package/index.js.map +1 -1
  89. package/index.mjs +122 -149
  90. package/index.mjs.map +1 -1
  91. package/package.json +31 -23
  92. package/pagination.d.ts +47 -167
  93. package/pagination.d.ts.map +1 -1
  94. package/pagination.js +72 -202
  95. package/pagination.js.map +1 -1
  96. package/pagination.mjs +68 -187
  97. package/pagination.mjs.map +1 -1
  98. package/resource.d.ts +10 -10
  99. package/resource.js +12 -12
  100. package/resource.mjs +10 -10
  101. package/resources/account.d.ts +44 -44
  102. package/resources/account.js +20 -19
  103. package/resources/account.mjs +17 -16
  104. package/resources/hris/benefits/benefits.d.ts +127 -154
  105. package/resources/hris/benefits/benefits.js +74 -89
  106. package/resources/hris/benefits/benefits.mjs +50 -48
  107. package/resources/hris/benefits/index.d.ts +3 -28
  108. package/resources/hris/benefits/index.js +13 -55
  109. package/resources/hris/benefits/index.mjs +3 -8
  110. package/resources/hris/benefits/individuals.d.ts +129 -147
  111. package/resources/hris/benefits/individuals.js +59 -59
  112. package/resources/hris/benefits/individuals.mjs +53 -49
  113. package/resources/hris/company.d.ts +80 -80
  114. package/resources/hris/company.js +12 -13
  115. package/resources/hris/company.mjs +9 -8
  116. package/resources/hris/directory.d.ts +53 -55
  117. package/resources/hris/directory.js +13 -12
  118. package/resources/hris/directory.mjs +8 -7
  119. package/resources/hris/employments.d.ts +124 -126
  120. package/resources/hris/employments.js +23 -21
  121. package/resources/hris/employments.mjs +19 -17
  122. package/resources/hris/hris.d.ts +113 -123
  123. package/resources/hris/hris.js +54 -71
  124. package/resources/hris/hris.mjs +32 -32
  125. package/resources/hris/index.d.ts +9 -41
  126. package/resources/hris/index.js +26 -110
  127. package/resources/hris/index.mjs +9 -9
  128. package/resources/hris/individuals.d.ts +65 -67
  129. package/resources/hris/individuals.js +19 -17
  130. package/resources/hris/individuals.mjs +14 -12
  131. package/resources/hris/pay-statements.d.ts +146 -162
  132. package/resources/hris/pay-statements.js +22 -20
  133. package/resources/hris/pay-statements.mjs +18 -16
  134. package/resources/hris/payments.d.ts +47 -49
  135. package/resources/hris/payments.js +15 -13
  136. package/resources/hris/payments.mjs +11 -9
  137. package/resources/index.d.ts +6 -7
  138. package/resources/index.d.ts.map +1 -1
  139. package/resources/index.js +13 -51
  140. package/resources/index.js.map +1 -1
  141. package/resources/index.mjs +5 -6
  142. package/resources/index.mjs.map +1 -1
  143. package/resources/providers.d.ts +43 -42
  144. package/resources/providers.js +15 -13
  145. package/resources/providers.mjs +11 -9
  146. package/resources/top-level.d.ts +1 -1
  147. package/resources/top-level.js +3 -3
  148. package/resources/top-level.mjs +1 -1
  149. package/resources/webhooks.d.ts +18 -18
  150. package/resources/webhooks.js +103 -107
  151. package/resources/webhooks.mjs +98 -102
  152. package/shims/node.d.ts +29 -0
  153. package/shims/node.d.ts.map +1 -0
  154. package/shims/node.js +31 -0
  155. package/shims/node.js.map +1 -0
  156. package/shims/node.mjs +5 -0
  157. package/shims/node.mjs.map +1 -0
  158. package/shims/web.d.ts +26 -0
  159. package/shims/web.d.ts.map +1 -0
  160. package/shims/web.js +31 -0
  161. package/shims/web.js.map +1 -0
  162. package/shims/web.mjs +5 -0
  163. package/shims/web.mjs.map +1 -0
  164. package/src/_shims/MultipartBody.ts +9 -0
  165. package/src/_shims/README.md +46 -0
  166. package/src/_shims/auto/runtime-bun.ts +4 -0
  167. package/src/_shims/auto/runtime-node.ts +4 -0
  168. package/src/_shims/auto/runtime.ts +4 -0
  169. package/src/_shims/auto/types-node.ts +4 -0
  170. package/src/_shims/auto/types.d.ts +99 -0
  171. package/src/_shims/auto/types.js +3 -0
  172. package/src/_shims/auto/types.mjs +3 -0
  173. package/src/_shims/bun-runtime.ts +14 -0
  174. package/src/_shims/index.d.ts +79 -0
  175. package/src/_shims/index.js +13 -0
  176. package/src/_shims/index.mjs +7 -0
  177. package/src/_shims/manual-types.d.ts +12 -0
  178. package/src/_shims/manual-types.js +3 -0
  179. package/src/_shims/manual-types.mjs +3 -0
  180. package/src/_shims/node-runtime.ts +79 -0
  181. package/src/_shims/node-types.d.ts +42 -0
  182. package/src/_shims/node-types.js +3 -0
  183. package/src/_shims/node-types.mjs +3 -0
  184. package/src/_shims/registry.ts +64 -0
  185. package/src/_shims/web-runtime.ts +91 -0
  186. package/src/_shims/web-types.d.ts +82 -0
  187. package/src/_shims/web-types.js +3 -0
  188. package/src/_shims/web-types.mjs +3 -0
  189. package/src/core.ts +37 -17
  190. package/src/error.ts +3 -3
  191. package/src/index.ts +6 -25
  192. package/src/pagination.ts +2 -261
  193. package/src/resource.ts +1 -1
  194. package/src/resources/account.ts +3 -3
  195. package/src/resources/hris/benefits/benefits.ts +6 -6
  196. package/src/resources/hris/benefits/index.ts +2 -2
  197. package/src/resources/hris/benefits/individuals.ts +6 -6
  198. package/src/resources/hris/company.ts +4 -4
  199. package/src/resources/hris/directory.ts +5 -5
  200. package/src/resources/hris/employments.ts +5 -5
  201. package/src/resources/hris/hris.ts +9 -9
  202. package/src/resources/hris/index.ts +8 -8
  203. package/src/resources/hris/individuals.ts +6 -6
  204. package/src/resources/hris/pay-statements.ts +6 -6
  205. package/src/resources/hris/payments.ts +5 -5
  206. package/src/resources/index.ts +5 -6
  207. package/src/resources/providers.ts +4 -4
  208. package/src/resources/webhooks.ts +2 -2
  209. package/src/shims/node.ts +50 -0
  210. package/src/shims/web.ts +50 -0
  211. package/src/uploads.ts +12 -16
  212. package/src/version.ts +1 -1
  213. package/uploads.d.ts +23 -39
  214. package/uploads.d.ts.map +1 -1
  215. package/uploads.js +115 -157
  216. package/uploads.js.map +1 -1
  217. package/uploads.mjs +111 -133
  218. package/uploads.mjs.map +1 -1
  219. package/version.d.ts +2 -2
  220. package/version.js +4 -4
  221. package/version.mjs +2 -2
  222. package/_shims/ReadableStream-node.d.ts +0 -6
  223. package/_shims/ReadableStream-node.d.ts.map +0 -1
  224. package/_shims/ReadableStream-node.js +0 -14
  225. package/_shims/ReadableStream-node.js.map +0 -1
  226. package/_shims/ReadableStream-node.mjs +0 -3
  227. package/_shims/ReadableStream-node.mjs.map +0 -1
  228. package/_shims/ReadableStream.d.ts +0 -38
  229. package/_shims/ReadableStream.mjs +0 -7
  230. package/_shims/agent-node.d.ts +0 -7
  231. package/_shims/agent-node.d.ts.map +0 -1
  232. package/_shims/agent-node.js +0 -28
  233. package/_shims/agent-node.js.map +0 -1
  234. package/_shims/agent-node.mjs +0 -16
  235. package/_shims/agent-node.mjs.map +0 -1
  236. package/_shims/agent.d.ts +0 -9
  237. package/_shims/agent.d.ts.map +0 -1
  238. package/_shims/agent.js +0 -14
  239. package/_shims/agent.js.map +0 -1
  240. package/_shims/agent.mjs +0 -10
  241. package/_shims/agent.mjs.map +0 -1
  242. package/_shims/fetch-node.d.ts +0 -64
  243. package/_shims/fetch-node.js +0 -12
  244. package/_shims/fetch-node.mjs +0 -14
  245. package/_shims/fetch.d.ts +0 -60
  246. package/_shims/fetch.js +0 -13
  247. package/_shims/fetch.mjs +0 -15
  248. package/_shims/fileFromPath-node.d.ts +0 -17
  249. package/_shims/fileFromPath-node.d.ts.map +0 -1
  250. package/_shims/fileFromPath-node.js +0 -17
  251. package/_shims/fileFromPath-node.js.map +0 -1
  252. package/_shims/fileFromPath-node.mjs +0 -13
  253. package/_shims/fileFromPath-node.mjs.map +0 -1
  254. package/_shims/fileFromPath.d.ts +0 -22
  255. package/_shims/fileFromPath.d.ts.map +0 -1
  256. package/_shims/fileFromPath.js +0 -16
  257. package/_shims/fileFromPath.js.map +0 -1
  258. package/_shims/fileFromPath.mjs +0 -12
  259. package/_shims/fileFromPath.mjs.map +0 -1
  260. package/_shims/form-data-node.d.ts +0 -45
  261. package/_shims/form-data-node.js +0 -11
  262. package/_shims/form-data-node.mjs +0 -9
  263. package/_shims/form-data.d.ts +0 -43
  264. package/_shims/form-data.js +0 -17
  265. package/_shims/form-data.mjs +0 -20
  266. package/_shims/getMultipartRequestOptions-node.d.ts +0 -10
  267. package/_shims/getMultipartRequestOptions-node.d.ts.map +0 -1
  268. package/_shims/getMultipartRequestOptions-node.js +0 -22
  269. package/_shims/getMultipartRequestOptions-node.js.map +0 -1
  270. package/_shims/getMultipartRequestOptions-node.mjs +0 -18
  271. package/_shims/getMultipartRequestOptions-node.mjs.map +0 -1
  272. package/_shims/getMultipartRequestOptions.d.ts +0 -10
  273. package/_shims/getMultipartRequestOptions.d.ts.map +0 -1
  274. package/_shims/getMultipartRequestOptions.js +0 -12
  275. package/_shims/getMultipartRequestOptions.js.map +0 -1
  276. package/_shims/getMultipartRequestOptions.mjs +0 -8
  277. package/_shims/getMultipartRequestOptions.mjs.map +0 -1
  278. package/_shims/node-readable-node.d.ts +0 -8
  279. package/_shims/node-readable-node.d.ts.map +0 -1
  280. package/_shims/node-readable-node.js +0 -9
  281. package/_shims/node-readable-node.js.map +0 -1
  282. package/_shims/node-readable-node.mjs +0 -5
  283. package/_shims/node-readable-node.mjs.map +0 -1
  284. package/_shims/node-readable.d.ts +0 -23
  285. package/_shims/node-readable.d.ts.map +0 -1
  286. package/_shims/node-readable.js +0 -11
  287. package/_shims/node-readable.js.map +0 -1
  288. package/_shims/node-readable.mjs +0 -7
  289. package/_shims/node-readable.mjs.map +0 -1
  290. package/resources/ats/applications.d.ts +0 -39
  291. package/resources/ats/applications.d.ts.map +0 -1
  292. package/resources/ats/applications.js +0 -24
  293. package/resources/ats/applications.js.map +0 -1
  294. package/resources/ats/applications.mjs +0 -20
  295. package/resources/ats/applications.mjs.map +0 -1
  296. package/resources/ats/ats.d.ts +0 -32
  297. package/resources/ats/ats.d.ts.map +0 -1
  298. package/resources/ats/ats.js +0 -71
  299. package/resources/ats/ats.js.map +0 -1
  300. package/resources/ats/ats.mjs +0 -27
  301. package/resources/ats/ats.mjs.map +0 -1
  302. package/resources/ats/candidates.d.ts +0 -53
  303. package/resources/ats/candidates.d.ts.map +0 -1
  304. package/resources/ats/candidates.js +0 -25
  305. package/resources/ats/candidates.js.map +0 -1
  306. package/resources/ats/candidates.mjs +0 -21
  307. package/resources/ats/candidates.mjs.map +0 -1
  308. package/resources/ats/index.d.ts +0 -7
  309. package/resources/ats/index.d.ts.map +0 -1
  310. package/resources/ats/index.js +0 -60
  311. package/resources/ats/index.js.map +0 -1
  312. package/resources/ats/index.mjs +0 -8
  313. package/resources/ats/index.mjs.map +0 -1
  314. package/resources/ats/jobs.d.ts +0 -47
  315. package/resources/ats/jobs.d.ts.map +0 -1
  316. package/resources/ats/jobs.js +0 -24
  317. package/resources/ats/jobs.js.map +0 -1
  318. package/resources/ats/jobs.mjs +0 -20
  319. package/resources/ats/jobs.mjs.map +0 -1
  320. package/resources/ats/offers.d.ts +0 -39
  321. package/resources/ats/offers.d.ts.map +0 -1
  322. package/resources/ats/offers.js +0 -24
  323. package/resources/ats/offers.js.map +0 -1
  324. package/resources/ats/offers.mjs +0 -20
  325. package/resources/ats/offers.mjs.map +0 -1
  326. package/resources/ats/stages.d.ts +0 -30
  327. package/resources/ats/stages.d.ts.map +0 -1
  328. package/resources/ats/stages.js +0 -22
  329. package/resources/ats/stages.js.map +0 -1
  330. package/resources/ats/stages.mjs +0 -17
  331. package/resources/ats/stages.mjs.map +0 -1
  332. package/src/_shims/ReadableStream.d.ts +0 -38
  333. package/src/_shims/ReadableStream.mjs +0 -7
  334. package/src/_shims/agent-node.ts +0 -22
  335. package/src/_shims/agent.ts +0 -12
  336. package/src/_shims/fetch-node.d.ts +0 -64
  337. package/src/_shims/fetch-node.js +0 -12
  338. package/src/_shims/fetch-node.mjs +0 -14
  339. package/src/_shims/fetch.d.ts +0 -60
  340. package/src/_shims/fetch.js +0 -13
  341. package/src/_shims/fetch.mjs +0 -15
  342. package/src/_shims/fileFromPath-node.ts +0 -29
  343. package/src/_shims/fileFromPath.ts +0 -29
  344. package/src/_shims/form-data-node.d.ts +0 -45
  345. package/src/_shims/form-data-node.js +0 -11
  346. package/src/_shims/form-data-node.mjs +0 -9
  347. package/src/_shims/form-data.d.ts +0 -43
  348. package/src/_shims/form-data.js +0 -17
  349. package/src/_shims/form-data.mjs +0 -20
  350. package/src/_shims/getMultipartRequestOptions-node.ts +0 -25
  351. package/src/_shims/getMultipartRequestOptions.ts +0 -14
  352. package/src/_shims/node-readable-node.ts +0 -10
  353. package/src/_shims/node-readable.ts +0 -30
  354. package/src/resources/ats/applications.ts +0 -64
  355. package/src/resources/ats/ats.ts +0 -39
  356. package/src/resources/ats/candidates.ts +0 -83
  357. package/src/resources/ats/index.ts +0 -8
  358. package/src/resources/ats/jobs.ts +0 -76
  359. package/src/resources/ats/offers.ts +0 -63
  360. package/src/resources/ats/stages.ts +0 -39
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ const shims = require('./registry');
5
+ const auto = require('@tryfinch/finch-api/_shims/auto/runtime');
6
+ if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
7
+ for (const property of Object.keys(shims)) {
8
+ Object.defineProperty(exports, property, {
9
+ get() {
10
+ return shims[property];
11
+ },
12
+ });
13
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ import * as shims from './registry.mjs';
5
+ import * as auto from "../ch/finch-api/_shims/auto/runtime";
6
+ if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
7
+ export * from './registry.mjs';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ /**
5
+ * Types will get added to this namespace when you import one of the following:
6
+ *
7
+ * import '@tryfinch/finch-api/shims/node'
8
+ * import '@tryfinch/finch-api/shims/web'
9
+ *
10
+ * Importing more than one will cause type and runtime errors.
11
+ */
12
+ export namespace manual {}
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ import * as nf from 'node-fetch';
5
+ import * as fd from 'formdata-node';
6
+ import { type File, type FilePropertyBag } from 'formdata-node';
7
+ import KeepAliveAgent from 'agentkeepalive';
8
+ import { AbortController as AbortControllerPolyfill } from 'abort-controller';
9
+ import { ReadStream as FsReadStream } from 'node:fs';
10
+ import { type Agent } from 'node:http';
11
+ import { FormDataEncoder } from 'form-data-encoder';
12
+ import { Readable } from 'node:stream';
13
+ import { type RequestOptions } from '../core';
14
+ import { MultipartBody } from './MultipartBody';
15
+ import { type Shims } from './registry';
16
+
17
+ type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
18
+
19
+ let fileFromPathWarned = false;
20
+
21
+ /**
22
+ * @deprecated use fs.createReadStream('./my/file.txt') instead
23
+ */
24
+ async function fileFromPath(path: string): Promise<File>;
25
+ async function fileFromPath(path: string, filename?: string): Promise<File>;
26
+ async function fileFromPath(path: string, options?: FileFromPathOptions): Promise<File>;
27
+ async function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>;
28
+ async function fileFromPath(path: string, ...args: any[]): Promise<File> {
29
+ // this import fails in environments that don't handle export maps correctly, like old versions of Jest
30
+ const { fileFromPath: _fileFromPath } = await import('formdata-node/file-from-path');
31
+
32
+ if (!fileFromPathWarned) {
33
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
34
+ fileFromPathWarned = true;
35
+ }
36
+ // @ts-ignore
37
+ return await _fileFromPath(path, ...args);
38
+ }
39
+
40
+ const defaultHttpAgent: Agent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
41
+ const defaultHttpsAgent: Agent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
42
+
43
+ async function getMultipartRequestOptions<T extends {} = Record<string, unknown>>(
44
+ form: fd.FormData,
45
+ opts: RequestOptions<T>,
46
+ ): Promise<RequestOptions<T>> {
47
+ const encoder = new FormDataEncoder(form);
48
+ const readable = Readable.from(encoder);
49
+ const body = new MultipartBody(readable);
50
+ const headers = {
51
+ ...opts.headers,
52
+ ...encoder.headers,
53
+ 'Content-Length': encoder.contentLength,
54
+ };
55
+
56
+ return { ...opts, body: body as any, headers };
57
+ }
58
+
59
+ export function getRuntime(): Shims {
60
+ // Polyfill global object if needed.
61
+ if (typeof AbortController === 'undefined') {
62
+ // @ts-ignore
63
+ AbortController = AbortControllerPolyfill;
64
+ }
65
+ return {
66
+ kind: 'node',
67
+ fetch: nf.default,
68
+ Request: nf.Request,
69
+ Response: nf.Response,
70
+ Headers: nf.Headers,
71
+ FormData: fd.FormData,
72
+ Blob: fd.Blob,
73
+ File: fd.File,
74
+ getMultipartRequestOptions,
75
+ getDefaultAgent: (url: string): Agent => (url.startsWith('https') ? defaultHttpsAgent : defaultHttpAgent),
76
+ fileFromPath,
77
+ isFsReadStream: (value: any): value is FsReadStream => value instanceof FsReadStream,
78
+ };
79
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ import * as nf from 'node-fetch';
5
+ import * as fd from 'formdata-node';
6
+
7
+ export { type Agent } from 'node:http';
8
+ export { type Readable } from 'node:stream';
9
+ export { type ReadStream as FsReadStream } from 'node:fs';
10
+ export { type ReadableStream } from 'web-streams-polyfill';
11
+
12
+ export const fetch: typeof nf.default;
13
+
14
+ export type Request = nf.Request;
15
+ export type RequestInfo = nf.RequestInfo;
16
+ export type RequestInit = nf.RequestInit;
17
+
18
+ export type Response = nf.Response;
19
+ export type ResponseInit = nf.ResponseInit;
20
+ export type ResponseType = nf.ResponseType;
21
+ export type BodyInit = nf.BodyInit;
22
+ export type Headers = nf.Headers;
23
+ export type HeadersInit = nf.HeadersInit;
24
+
25
+ type EndingType = 'native' | 'transparent';
26
+ export interface BlobPropertyBag {
27
+ endings?: EndingType;
28
+ type?: string;
29
+ }
30
+
31
+ export interface FilePropertyBag extends BlobPropertyBag {
32
+ lastModified?: number;
33
+ }
34
+
35
+ export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
36
+
37
+ export type FormData = fd.FormData;
38
+ export const FormData: typeof fd.FormData;
39
+ export type File = fd.File;
40
+ export const File: typeof fd.File;
41
+ export type Blob = fd.Blob;
42
+ export const Blob: typeof fd.Blob;
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ import { type RequestOptions } from '../core';
5
+
6
+ export interface Shims {
7
+ kind: string;
8
+ fetch: any;
9
+ Request: any;
10
+ Response: any;
11
+ Headers: any;
12
+ FormData: any;
13
+ Blob: any;
14
+ File: any;
15
+ getMultipartRequestOptions: <T extends {} = Record<string, unknown>>(
16
+ form: Shims['FormData'],
17
+ opts: RequestOptions<T>,
18
+ ) => Promise<RequestOptions<T>>;
19
+ getDefaultAgent: (url: string) => any;
20
+ fileFromPath:
21
+ | ((path: string, filename?: string, options?: {}) => Promise<Shims['File']>)
22
+ | ((path: string, options?: {}) => Promise<Shims['File']>);
23
+ isFsReadStream: (value: any) => boolean;
24
+ }
25
+
26
+ export let auto = false;
27
+ export let kind: Shims['kind'] | undefined = undefined;
28
+ export let fetch: Shims['fetch'] | undefined = undefined;
29
+ export let Request: Shims['Request'] | undefined = undefined;
30
+ export let Response: Shims['Response'] | undefined = undefined;
31
+ export let Headers: Shims['Headers'] | undefined = undefined;
32
+ export let FormData: Shims['FormData'] | undefined = undefined;
33
+ export let Blob: Shims['Blob'] | undefined = undefined;
34
+ export let File: Shims['File'] | undefined = undefined;
35
+ export let getMultipartRequestOptions: Shims['getMultipartRequestOptions'] | undefined = undefined;
36
+ export let getDefaultAgent: Shims['getDefaultAgent'] | undefined = undefined;
37
+ export let fileFromPath: Shims['fileFromPath'] | undefined = undefined;
38
+ export let isFsReadStream: Shims['isFsReadStream'] | undefined = undefined;
39
+
40
+ export function setShims(shims: Shims, options: { auto: boolean } = { auto: false }) {
41
+ if (auto) {
42
+ throw new Error(
43
+ `you must \`import '@tryfinch/finch-api/shims/${shims.kind}'\` before importing anything else from @tryfinch/finch-api`,
44
+ );
45
+ }
46
+ if (kind) {
47
+ throw new Error(
48
+ `can't \`import '@tryfinch/finch-api/shims/${shims.kind}'\` after \`import '@tryfinch/finch-api/shims/${kind}'\``,
49
+ );
50
+ }
51
+ auto = options.auto;
52
+ kind = shims.kind;
53
+ fetch = shims.fetch;
54
+ Request = shims.Request;
55
+ Response = shims.Response;
56
+ Headers = shims.Headers;
57
+ FormData = shims.FormData;
58
+ Blob = shims.Blob;
59
+ File = shims.File;
60
+ getMultipartRequestOptions = shims.getMultipartRequestOptions;
61
+ getDefaultAgent = shims.getDefaultAgent;
62
+ fileFromPath = shims.fileFromPath;
63
+ isFsReadStream = shims.isFsReadStream;
64
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ import { MultipartBody } from './MultipartBody';
5
+ import { type RequestOptions } from '../core';
6
+ import { type Shims } from './registry';
7
+
8
+ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } = {}): Shims {
9
+ const recommendation =
10
+ manuallyImported ?
11
+ `You may need to use polyfills`
12
+ : `Add one of these imports before your first \`import … from '@tryfinch/finch-api'\`:
13
+ - \`import '@tryfinch/finch-api/shims/node'\` (if you're running on Node)
14
+ - \`import '@tryfinch/finch-api/shims/web'\` (otherwise)
15
+ `;
16
+
17
+ let _fetch, _Request, _Response, _Headers;
18
+ try {
19
+ // @ts-ignore
20
+ _fetch = fetch;
21
+ // @ts-ignore
22
+ _Request = Request;
23
+ // @ts-ignore
24
+ _Response = Response;
25
+ // @ts-ignore
26
+ _Headers = Headers;
27
+ } catch (error) {
28
+ throw new Error(
29
+ `this environment is missing the following Web Fetch API type: ${
30
+ (error as any).message
31
+ }. ${recommendation}`,
32
+ );
33
+ }
34
+
35
+ return {
36
+ kind: 'web',
37
+ fetch: _fetch,
38
+ Request: _Request,
39
+ Response: _Response,
40
+ Headers: _Headers,
41
+ FormData:
42
+ // @ts-ignore
43
+ typeof FormData !== 'undefined' ? FormData : (
44
+ class FormData {
45
+ // @ts-ignore
46
+ constructor() {
47
+ throw new Error(
48
+ `file uploads aren't supported in this environment yet as 'FormData' is undefined. ${recommendation}`,
49
+ );
50
+ }
51
+ }
52
+ ),
53
+ Blob:
54
+ typeof Blob !== 'undefined' ? Blob : (
55
+ class Blob {
56
+ constructor() {
57
+ throw new Error(
58
+ `file uploads aren't supported in this environment yet as 'Blob' is undefined. ${recommendation}`,
59
+ );
60
+ }
61
+ }
62
+ ),
63
+ File:
64
+ // @ts-ignore
65
+ typeof File !== 'undefined' ? File : (
66
+ class File {
67
+ // @ts-ignore
68
+ constructor() {
69
+ throw new Error(
70
+ `file uploads aren't supported in this environment yet as 'File' is undefined. ${recommendation}`,
71
+ );
72
+ }
73
+ }
74
+ ),
75
+ getMultipartRequestOptions: async <T extends {} = Record<string, unknown>>(
76
+ // @ts-ignore
77
+ form: FormData,
78
+ opts: RequestOptions<T>,
79
+ ): Promise<RequestOptions<T>> => ({
80
+ ...opts,
81
+ body: new MultipartBody(form) as any,
82
+ }),
83
+ getDefaultAgent: (url: string) => undefined,
84
+ fileFromPath: () => {
85
+ throw new Error(
86
+ 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/Finch-API/finch-api-node#file-uploads',
87
+ );
88
+ },
89
+ isFsReadStream: (value: any) => false,
90
+ };
91
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
4
+ export type Agent = any;
5
+
6
+ declare const _fetch: typeof fetch;
7
+ export { _fetch as fetch };
8
+
9
+ type _Request = Request;
10
+ export { _Request as Request };
11
+
12
+ type _RequestInfo = RequestInfo;
13
+ export { type _RequestInfo as RequestInfo };
14
+
15
+ type _RequestInit = RequestInit;
16
+ export { type _RequestInit as RequestInit };
17
+
18
+ type _Response = Response;
19
+ export { _Response as Response };
20
+
21
+ type _ResponseInit = ResponseInit;
22
+ export { type _ResponseInit as ResponseInit };
23
+
24
+ type _ResponseType = ResponseType;
25
+ export { type _ResponseType as ResponseType };
26
+
27
+ type _BodyInit = BodyInit;
28
+ export { type _BodyInit as BodyInit };
29
+
30
+ type _Headers = Headers;
31
+ export { _Headers as Headers };
32
+
33
+ type _HeadersInit = HeadersInit;
34
+ export { type _HeadersInit as HeadersInit };
35
+
36
+ type EndingType = 'native' | 'transparent';
37
+
38
+ export interface BlobPropertyBag {
39
+ endings?: EndingType;
40
+ type?: string;
41
+ }
42
+
43
+ export interface FilePropertyBag extends BlobPropertyBag {
44
+ lastModified?: number;
45
+ }
46
+
47
+ export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
48
+
49
+ type _FormData = FormData;
50
+ declare const _FormData: typeof FormData;
51
+ export { _FormData as FormData };
52
+
53
+ type _File = File;
54
+ declare const _File: typeof File;
55
+ export { _File as File };
56
+
57
+ type _Blob = Blob;
58
+ declare const _Blob: typeof Blob;
59
+ export { _Blob as Blob };
60
+
61
+ export declare class Readable {
62
+ readable: boolean;
63
+ readonly readableEnded: boolean;
64
+ readonly readableFlowing: boolean | null;
65
+ readonly readableHighWaterMark: number;
66
+ readonly readableLength: number;
67
+ readonly readableObjectMode: boolean;
68
+ destroyed: boolean;
69
+ read(size?: number): any;
70
+ pause(): this;
71
+ resume(): this;
72
+ isPaused(): boolean;
73
+ destroy(error?: Error): this;
74
+ [Symbol.asyncIterator](): AsyncIterableIterator<any>;
75
+ }
76
+
77
+ export declare class FsReadStream extends Readable {
78
+ path: {}; // node type is string | Buffer
79
+ }
80
+
81
+ type _ReadableStream<R = any> = ReadableStream<R>;
82
+ export { type _ReadableStream as ReadableStream };
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Disclaimer: modules in _shims aren't intended to be imported by SDK users.
3
+ */
package/src/core.ts CHANGED
@@ -1,23 +1,24 @@
1
- import { VERSION } from './version.js';
2
- import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error.js';
3
- import type { Readable } from './_shims/node-readable.js';
4
- import { getDefaultAgent, type Agent } from './_shims/agent.js';
1
+ import { VERSION } from './version';
2
+ import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error';
5
3
  import {
4
+ kind as shimsKind,
5
+ type Readable,
6
+ getDefaultAgent,
7
+ type Agent,
6
8
  fetch,
7
- isPolyfilled as fetchIsPolyfilled,
8
9
  type RequestInfo,
9
10
  type RequestInit,
10
11
  type Response,
11
12
  type HeadersInit,
12
- } from './_shims/fetch.js';
13
+ } from './_shims/index';
13
14
  export { type Response };
14
- import { isMultipartBody } from './uploads.js';
15
+ import { isMultipartBody } from './uploads';
15
16
  export {
16
17
  maybeMultipartFormRequestOptions,
17
18
  multipartFormRequestOptions,
18
19
  createForm,
19
20
  type Uploadable,
20
- } from './uploads.js';
21
+ } from './uploads';
21
22
 
22
23
  const MAX_RETRIES = 2;
23
24
 
@@ -77,6 +78,12 @@ export class APIPromise<T> extends Promise<T> {
77
78
  *
78
79
  * If you want to parse the response body but still get the `Response`
79
80
  * instance, you can use {@link withResponse()}.
81
+ *
82
+ * 👋 Getting the wrong TypeScript type for `Response`?
83
+ * Try setting `"moduleResolution": "NodeNext"` if you can,
84
+ * or add one of these imports before your first `import … from '@tryfinch/finch-api'`:
85
+ * - `import '@tryfinch/finch-api/shims/node'` (if you're running on Node)
86
+ * - `import '@tryfinch/finch-api/shims/web'` (otherwise)
80
87
  */
81
88
  asResponse(): Promise<Response> {
82
89
  return this.responsePromise.then((p) => p.response);
@@ -86,6 +93,13 @@ export class APIPromise<T> extends Promise<T> {
86
93
  *
87
94
  * If you just want to get the raw `Response` instance without parsing it,
88
95
  * you can use {@link asResponse()}.
96
+ *
97
+ *
98
+ * 👋 Getting the wrong TypeScript type for `Response`?
99
+ * Try setting `"moduleResolution": "NodeNext"` if you can,
100
+ * or add one of these imports before your first `import … from '@tryfinch/finch-api'`:
101
+ * - `import '@tryfinch/finch-api/shims/node'` (if you're running on Node)
102
+ * - `import '@tryfinch/finch-api/shims/web'` (otherwise)
89
103
  */
90
104
  async withResponse(): Promise<{ data: T; response: Response }> {
91
105
  const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
@@ -270,7 +284,7 @@ export abstract class APIClient {
270
284
  ...headers,
271
285
  };
272
286
  // let builtin fetch set the Content-Type for multipart bodies
273
- if (isMultipartBody(options.body) && !fetchIsPolyfilled) {
287
+ if (isMultipartBody(options.body) && shimsKind !== 'node') {
274
288
  delete reqHeaders['Content-Type'];
275
289
  }
276
290
 
@@ -370,7 +384,7 @@ export abstract class APIClient {
370
384
  return this.retryRequest(options, retriesRemaining, responseHeaders);
371
385
  }
372
386
 
373
- const errText = await response.text().catch(() => 'Unknown');
387
+ const errText = await response.text().catch((e) => castToError(e).message);
374
388
  const errJSON = safeJSON(errText);
375
389
  const errMessage = errJSON ? undefined : errText;
376
390
 
@@ -437,11 +451,14 @@ export abstract class APIClient {
437
451
 
438
452
  const timeout = setTimeout(() => controller.abort(), ms);
439
453
 
440
- return this.getRequestClient()
441
- .fetch(url, { signal: controller.signal as any, ...options })
442
- .finally(() => {
443
- clearTimeout(timeout);
444
- });
454
+ return (
455
+ this.getRequestClient()
456
+ // use undefined this binding; fetch errors if bound to something else in browser/cloudflare
457
+ .fetch.call(undefined, url, { signal: controller.signal as any, ...options })
458
+ .finally(() => {
459
+ clearTimeout(timeout);
460
+ })
461
+ );
445
462
  }
446
463
 
447
464
  protected getRequestClient(): RequestClient {
@@ -456,6 +473,9 @@ export abstract class APIClient {
456
473
  if (shouldRetryHeader === 'true') return true;
457
474
  if (shouldRetryHeader === 'false') return false;
458
475
 
476
+ // Retry on request timeouts.
477
+ if (response.status === 408) return true;
478
+
459
479
  // Retry on lock timeouts.
460
480
  if (response.status === 409) return true;
461
481
 
@@ -582,7 +602,7 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
582
602
  } else if ('url' in nextInfo) {
583
603
  const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()];
584
604
  for (const [key, value] of params) {
585
- nextInfo.url.searchParams.set(key, value);
605
+ nextInfo.url.searchParams.set(key, value as any);
586
606
  }
587
607
  nextOptions.query = undefined;
588
608
  nextOptions.path = nextInfo.url.toString();
@@ -708,7 +728,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
708
728
  idempotencyKey: true,
709
729
  };
710
730
 
711
- export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
731
+ export const isRequestOptions = (obj: unknown): obj is RequestOptions<Record<string, unknown> | Readable> => {
712
732
  return (
713
733
  typeof obj === 'object' &&
714
734
  obj !== null &&
package/src/error.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import { castToError, Headers } from './core.js';
3
+ import { castToError, Headers } from './core';
4
4
 
5
5
  export class APIError extends Error {
6
6
  readonly status: number | undefined;
@@ -13,7 +13,7 @@ export class APIError extends Error {
13
13
  message: string | undefined,
14
14
  headers: Headers | undefined,
15
15
  ) {
16
- super(APIError.makeMessage(error, message));
16
+ super(`${status} ${APIError.makeMessage(error, message)}`);
17
17
  this.status = status;
18
18
  this.headers = headers;
19
19
  this.error = error;
@@ -25,7 +25,7 @@ export class APIError extends Error {
25
25
  typeof error.message === 'string' ? error.message
26
26
  : JSON.stringify(error.message)
27
27
  : error ? JSON.stringify(error)
28
- : message || 'Unknown error occurred'
28
+ : message || 'status code (no body)'
29
29
  );
30
30
  }
31
31
 
package/src/index.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from './core.js';
4
- import * as Pagination from './pagination.js';
5
- import * as API from './resources/index.js';
6
- import * as Errors from './error.js';
7
- import type { Agent } from './_shims/agent.js';
8
- import * as Uploads from './uploads.js';
3
+ import * as Core from './core';
4
+ import * as Pagination from './pagination';
5
+ import * as API from './resources/index';
6
+ import * as Errors from './error';
7
+ import { type Agent } from './_shims/index';
8
+ import * as Uploads from './uploads';
9
9
 
10
10
  export interface ClientOptions {
11
11
  /**
@@ -130,7 +130,6 @@ export class Finch extends Core.APIClient {
130
130
  }
131
131
 
132
132
  hris: API.HRIS = new API.HRIS(this);
133
- ats: API.ATS = new API.ATS(this);
134
133
  providers: API.Providers = new API.Providers(this);
135
134
  account: API.Account = new API.Account(this);
136
135
  webhooks: API.Webhooks = new API.Webhooks(this);
@@ -270,30 +269,12 @@ export namespace Finch {
270
269
  export import IndividualsPageParams = Pagination.IndividualsPageParams;
271
270
  export import IndividualsPageResponse = Pagination.IndividualsPageResponse;
272
271
 
273
- export import CandidatesPage = Pagination.CandidatesPage;
274
- export import CandidatesPageParams = Pagination.CandidatesPageParams;
275
- export import CandidatesPageResponse = Pagination.CandidatesPageResponse;
276
-
277
- export import ApplicationsPage = Pagination.ApplicationsPage;
278
- export import ApplicationsPageParams = Pagination.ApplicationsPageParams;
279
- export import ApplicationsPageResponse = Pagination.ApplicationsPageResponse;
280
-
281
- export import JobsPage = Pagination.JobsPage;
282
- export import JobsPageParams = Pagination.JobsPageParams;
283
- export import JobsPageResponse = Pagination.JobsPageResponse;
284
-
285
- export import OffersPage = Pagination.OffersPage;
286
- export import OffersPageParams = Pagination.OffersPageParams;
287
- export import OffersPageResponse = Pagination.OffersPageResponse;
288
-
289
272
  export import HRIS = API.HRIS;
290
273
  export import Income = API.Income;
291
274
  export import Location = API.Location;
292
275
  export import Money = API.Money;
293
276
  export import Paging = API.Paging;
294
277
 
295
- export import ATS = API.ATS;
296
-
297
278
  export import Providers = API.Providers;
298
279
  export import Provider = API.Provider;
299
280
  export import ProvidersSinglePage = API.ProvidersSinglePage;