@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.
- package/_shims/agent.d.ts +9 -0
- package/_shims/agent.d.ts.map +1 -0
- package/_shims/agent.js +14 -0
- package/_shims/agent.js.map +1 -0
- package/_shims/agent.mjs +10 -0
- package/_shims/agent.mjs.map +1 -0
- package/_shims/agent.node.d.ts +7 -0
- package/_shims/agent.node.d.ts.map +1 -0
- package/_shims/agent.node.js +28 -0
- package/_shims/agent.node.js.map +1 -0
- package/_shims/agent.node.mjs +16 -0
- package/_shims/agent.node.mjs.map +1 -0
- package/_shims/fetch.d.ts +52 -0
- package/_shims/fetch.js +13 -0
- package/_shims/fetch.mjs +15 -0
- package/_shims/fetch.node.d.ts +53 -0
- package/_shims/fetch.node.js +12 -0
- package/_shims/fetch.node.mjs +14 -0
- package/_shims/fileFromPath.d.ts +22 -0
- package/_shims/fileFromPath.d.ts.map +1 -0
- package/_shims/fileFromPath.js +16 -0
- package/_shims/fileFromPath.js.map +1 -0
- package/_shims/fileFromPath.mjs +12 -0
- package/_shims/fileFromPath.mjs.map +1 -0
- package/_shims/fileFromPath.node.d.ts +17 -0
- package/_shims/fileFromPath.node.d.ts.map +1 -0
- package/_shims/fileFromPath.node.js +17 -0
- package/_shims/fileFromPath.node.js.map +1 -0
- package/_shims/fileFromPath.node.mjs +13 -0
- package/_shims/fileFromPath.node.mjs.map +1 -0
- package/_shims/formdata.d.ts +43 -0
- package/_shims/formdata.js +9 -0
- package/_shims/formdata.mjs +11 -0
- package/_shims/formdata.node.d.ts +44 -0
- package/_shims/formdata.node.js +11 -0
- package/_shims/formdata.node.mjs +9 -0
- package/_shims/getMultipartRequestOptions.d.ts +10 -0
- package/_shims/getMultipartRequestOptions.d.ts.map +1 -0
- package/_shims/getMultipartRequestOptions.js +12 -0
- package/_shims/getMultipartRequestOptions.js.map +1 -0
- package/_shims/getMultipartRequestOptions.mjs +8 -0
- package/_shims/getMultipartRequestOptions.mjs.map +1 -0
- package/_shims/getMultipartRequestOptions.node.d.ts +10 -0
- package/_shims/getMultipartRequestOptions.node.d.ts.map +1 -0
- package/_shims/getMultipartRequestOptions.node.js +22 -0
- package/_shims/getMultipartRequestOptions.node.js.map +1 -0
- package/_shims/getMultipartRequestOptions.node.mjs +18 -0
- package/_shims/getMultipartRequestOptions.node.mjs.map +1 -0
- package/_shims/node-readable.d.ts +23 -0
- package/_shims/node-readable.d.ts.map +1 -0
- package/_shims/node-readable.js +11 -0
- package/_shims/node-readable.js.map +1 -0
- package/_shims/node-readable.mjs +7 -0
- package/_shims/node-readable.mjs.map +1 -0
- package/_shims/node-readable.node.d.ts +8 -0
- package/_shims/node-readable.node.d.ts.map +1 -0
- package/_shims/node-readable.node.js +9 -0
- package/_shims/node-readable.node.js.map +1 -0
- package/_shims/node-readable.node.mjs +5 -0
- package/_shims/node-readable.node.mjs.map +1 -0
- package/{dist/cjs/core.d.ts → core.d.ts} +18 -68
- package/core.d.ts.map +1 -0
- package/core.js +683 -0
- package/core.js.map +1 -0
- package/core.mjs +587 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +48 -0
- package/error.d.ts.map +1 -0
- package/error.js +126 -0
- package/error.js.map +1 -0
- package/error.mjs +101 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +160 -0
- package/index.d.ts +160 -0
- package/index.d.ts.map +1 -0
- package/{dist/cjs/index.js → index.js} +55 -44
- package/index.js.map +1 -0
- package/index.mjs +157 -0
- package/index.mjs.map +1 -0
- package/package.json +57 -20
- package/{dist/cjs/pagination.d.ts → pagination.d.ts} +6 -4
- package/pagination.d.ts.map +1 -0
- package/{dist/cjs/pagination.js → pagination.js} +1 -1
- package/pagination.js.map +1 -0
- package/pagination.mjs +198 -0
- package/pagination.mjs.map +1 -0
- package/{dist/cjs/resource.d.ts → resource.d.ts} +1 -1
- package/resource.d.ts.map +1 -0
- package/resource.js.map +1 -0
- package/resource.mjs +13 -0
- package/resource.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/account.d.ts +7 -2
- package/resources/account.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/account.js +2 -1
- package/resources/account.js.map +1 -0
- package/resources/account.mjs +20 -0
- package/resources/account.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/ats/applications.d.ts +10 -5
- package/resources/ats/applications.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/ats/applications.js +5 -8
- package/resources/ats/applications.js.map +1 -0
- package/resources/ats/applications.mjs +20 -0
- package/resources/ats/applications.mjs.map +1 -0
- package/resources/ats/ats.d.ts +32 -0
- package/resources/ats/ats.d.ts.map +1 -0
- package/resources/ats/ats.js +71 -0
- package/resources/ats/ats.js.map +1 -0
- package/resources/ats/ats.mjs +27 -0
- package/resources/ats/ats.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/ats/candidates.d.ts +13 -8
- package/resources/ats/candidates.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/ats/candidates.js +5 -4
- package/resources/ats/candidates.js.map +1 -0
- package/resources/ats/candidates.mjs +21 -0
- package/resources/ats/candidates.mjs.map +1 -0
- package/resources/ats/index.d.ts +7 -0
- package/resources/ats/index.d.ts.map +1 -0
- package/resources/ats/index.js +60 -0
- package/resources/ats/index.js.map +1 -0
- package/resources/ats/index.mjs +8 -0
- package/resources/ats/index.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/ats/jobs.d.ts +13 -8
- package/resources/ats/jobs.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/ats/jobs.js +5 -4
- package/resources/ats/jobs.js.map +1 -0
- package/resources/ats/jobs.mjs +20 -0
- package/resources/ats/jobs.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/ats/offers.d.ts +9 -4
- package/resources/ats/offers.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/ats/offers.js +5 -4
- package/resources/ats/offers.js.map +1 -0
- package/resources/ats/offers.mjs +20 -0
- package/resources/ats/offers.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/ats/stages.d.ts +10 -3
- package/resources/ats/stages.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/ats/stages.js +3 -2
- package/resources/ats/stages.js.map +1 -0
- package/resources/ats/stages.mjs +17 -0
- package/resources/ats/stages.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/benefits/benefits.d.ts +32 -4
- package/resources/hris/benefits/benefits.d.ts.map +1 -0
- package/resources/hris/benefits/benefits.js +104 -0
- package/resources/hris/benefits/benefits.js.map +1 -0
- package/resources/hris/benefits/benefits.mjs +58 -0
- package/resources/hris/benefits/benefits.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/benefits/index.d.ts +4 -2
- package/resources/hris/benefits/index.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/benefits/index.js +17 -3
- package/resources/hris/benefits/index.js.map +1 -0
- package/resources/hris/benefits/index.mjs +9 -0
- package/resources/hris/benefits/index.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/benefits/individuals.d.ts +21 -4
- package/resources/hris/benefits/individuals.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/benefits/individuals.js +18 -18
- package/resources/hris/benefits/individuals.js.map +1 -0
- package/resources/hris/benefits/individuals.mjs +57 -0
- package/resources/hris/benefits/individuals.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/company.d.ts +42 -38
- package/resources/hris/company.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/company.js +4 -1
- package/resources/hris/company.js.map +1 -0
- package/resources/hris/company.mjs +12 -0
- package/resources/hris/company.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/directory.d.ts +20 -15
- package/resources/hris/directory.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/directory.js +5 -8
- package/resources/hris/directory.js.map +1 -0
- package/resources/hris/directory.mjs +14 -0
- package/resources/hris/directory.mjs.map +1 -0
- package/resources/hris/hris.d.ts +134 -0
- package/resources/hris/hris.d.ts.map +1 -0
- package/resources/hris/hris.js +78 -0
- package/resources/hris/hris.js.map +1 -0
- package/resources/hris/hris.mjs +34 -0
- package/resources/hris/hris.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/index.d.ts +10 -7
- package/resources/hris/index.d.ts.map +1 -0
- package/resources/hris/index.js +96 -0
- package/resources/hris/index.js.map +1 -0
- package/resources/hris/index.mjs +9 -0
- package/resources/hris/index.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/individuals/employment-data.d.ts +28 -19
- package/resources/hris/individuals/employment-data.d.ts.map +1 -0
- package/resources/hris/individuals/employment-data.js +70 -0
- package/resources/hris/individuals/employment-data.js.map +1 -0
- package/resources/hris/individuals/employment-data.mjs +25 -0
- package/resources/hris/individuals/employment-data.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/individuals/index.d.ts +3 -2
- package/resources/hris/individuals/index.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/individuals/index.js +10 -3
- package/resources/hris/individuals/index.js.map +1 -0
- package/resources/hris/individuals/index.mjs +4 -0
- package/resources/hris/individuals/index.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/individuals/individuals.d.ts +28 -15
- package/resources/hris/individuals/individuals.d.ts.map +1 -0
- package/resources/hris/individuals/individuals.js +73 -0
- package/resources/hris/individuals/individuals.js.map +1 -0
- package/resources/hris/individuals/individuals.mjs +28 -0
- package/resources/hris/individuals/individuals.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/pay-statements.d.ts +45 -35
- package/resources/hris/pay-statements.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/pay-statements.js +8 -7
- package/resources/hris/pay-statements.js.map +1 -0
- package/resources/hris/pay-statements.mjs +21 -0
- package/resources/hris/pay-statements.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/hris/payments.d.ts +16 -8
- package/resources/hris/payments.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/hris/payments.js +4 -3
- package/resources/hris/payments.js.map +1 -0
- package/resources/hris/payments.mjs +14 -0
- package/resources/hris/payments.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/index.d.ts +4 -4
- package/resources/index.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/index.js +4 -4
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +6 -0
- package/resources/index.mjs.map +1 -0
- package/{dist/cjs/resources → resources}/providers.d.ts +14 -7
- package/resources/providers.d.ts.map +1 -0
- package/{dist/cjs/resources → resources}/providers.js +3 -2
- package/resources/providers.js.map +1 -0
- package/resources/providers.mjs +14 -0
- package/resources/providers.mjs.map +1 -0
- package/resources/top-level.d.ts.map +1 -0
- package/resources/top-level.js.map +1 -0
- package/resources/top-level.mjs +3 -0
- package/resources/top-level.mjs.map +1 -0
- package/src/_shims/agent.node.ts +22 -0
- package/src/_shims/agent.ts +12 -0
- package/src/_shims/fetch.d.ts +52 -0
- package/src/_shims/fetch.js +13 -0
- package/src/_shims/fetch.mjs +15 -0
- package/src/_shims/fetch.node.d.ts +53 -0
- package/src/_shims/fetch.node.js +12 -0
- package/src/_shims/fetch.node.mjs +14 -0
- package/src/_shims/fileFromPath.node.ts +29 -0
- package/src/_shims/fileFromPath.ts +29 -0
- package/src/_shims/formdata.d.ts +43 -0
- package/src/_shims/formdata.js +9 -0
- package/src/_shims/formdata.mjs +11 -0
- package/src/_shims/formdata.node.d.ts +44 -0
- package/src/_shims/formdata.node.js +11 -0
- package/src/_shims/formdata.node.mjs +9 -0
- package/src/_shims/getMultipartRequestOptions.node.ts +25 -0
- package/src/_shims/getMultipartRequestOptions.ts +14 -0
- package/src/_shims/node-readable.node.ts +10 -0
- package/src/_shims/node-readable.ts +30 -0
- package/{core.ts → src/core.ts} +69 -177
- package/src/error.ts +115 -0
- package/{index.ts → src/index.ts} +78 -27
- package/{pagination.ts → src/pagination.ts} +4 -1
- package/{resources → src/resources}/account.ts +8 -2
- package/{resources → src/resources}/ats/applications.ts +13 -7
- package/src/resources/ats/ats.ts +39 -0
- package/{resources → src/resources}/ats/candidates.ts +16 -10
- package/src/resources/ats/index.ts +8 -0
- package/{resources → src/resources}/ats/jobs.ts +16 -10
- package/{resources → src/resources}/ats/offers.ts +12 -6
- package/{resources → src/resources}/ats/stages.ts +11 -3
- package/{resources → src/resources}/hris/benefits/benefits.ts +35 -4
- package/{resources → src/resources}/hris/benefits/index.ts +2 -0
- package/{resources → src/resources}/hris/benefits/individuals.ts +25 -5
- package/{resources → src/resources}/hris/company.ts +47 -42
- package/{resources → src/resources}/hris/directory.ts +23 -17
- package/{resources → src/resources}/hris/hris.ts +47 -1
- package/{resources → src/resources}/hris/index.ts +7 -4
- package/{resources → src/resources}/hris/individuals/employment-data.ts +31 -21
- package/{resources → src/resources}/hris/individuals/index.ts +1 -0
- package/{resources → src/resources}/hris/individuals/individuals.ts +31 -16
- package/{resources → src/resources}/hris/pay-statements.ts +47 -36
- package/{resources → src/resources}/hris/payments.ts +18 -9
- package/{resources → src/resources}/providers.ts +16 -8
- package/src/streaming.ts +204 -0
- package/src/uploads.ts +248 -0
- package/src/version.ts +1 -0
- package/{dist/cjs/streaming.d.ts → streaming.d.ts} +4 -3
- package/streaming.d.ts.map +1 -0
- package/streaming.js +155 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +151 -0
- package/streaming.mjs.map +1 -0
- package/uploads.d.ts +90 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +207 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +174 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/{dist/cjs/version.js → version.js} +1 -1
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
- package/.eslintrc.js +0 -10
- package/.github/workflows/publish-npm.yml +0 -28
- package/.github/workflows/release-doctor.yml +0 -20
- package/.github/workflows/release.yml +0 -38
- package/.prettierignore +0 -1
- package/.prettierrc +0 -6
- package/.release-please-manifest.json +0 -3
- package/.stats.yml +0 -1
- package/CHANGELOG.md +0 -40
- package/LICENSE +0 -201
- package/README.md +0 -219
- package/api.md +0 -186
- package/bin/check-release-environment +0 -25
- package/bin/check-test-server +0 -50
- package/bin/publish-npm +0 -6
- package/build +0 -12
- package/check-version.ts +0 -18
- package/dist/cjs/check-version.d.ts +0 -2
- package/dist/cjs/check-version.d.ts.map +0 -1
- package/dist/cjs/check-version.js +0 -23
- package/dist/cjs/check-version.js.map +0 -1
- package/dist/cjs/core.d.ts.map +0 -1
- package/dist/cjs/core.js +0 -950
- package/dist/cjs/core.js.map +0 -1
- package/dist/cjs/fetch-polyfill.d.ts +0 -6
- package/dist/cjs/fetch-polyfill.d.ts.map +0 -1
- package/dist/cjs/fetch-polyfill.js +0 -57
- package/dist/cjs/fetch-polyfill.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -118
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/pagination.d.ts.map +0 -1
- package/dist/cjs/pagination.js.map +0 -1
- package/dist/cjs/resource.d.ts.map +0 -1
- package/dist/cjs/resource.js.map +0 -1
- package/dist/cjs/resources/account.d.ts.map +0 -1
- package/dist/cjs/resources/account.js.map +0 -1
- package/dist/cjs/resources/ats/applications.d.ts.map +0 -1
- package/dist/cjs/resources/ats/applications.js.map +0 -1
- package/dist/cjs/resources/ats/ats.d.ts +0 -14
- package/dist/cjs/resources/ats/ats.d.ts.map +0 -1
- package/dist/cjs/resources/ats/ats.js +0 -22
- package/dist/cjs/resources/ats/ats.js.map +0 -1
- package/dist/cjs/resources/ats/candidates.d.ts.map +0 -1
- package/dist/cjs/resources/ats/candidates.js.map +0 -1
- package/dist/cjs/resources/ats/index.d.ts +0 -6
- package/dist/cjs/resources/ats/index.d.ts.map +0 -1
- package/dist/cjs/resources/ats/index.js +0 -12
- package/dist/cjs/resources/ats/index.js.map +0 -1
- package/dist/cjs/resources/ats/jobs.d.ts.map +0 -1
- package/dist/cjs/resources/ats/jobs.js.map +0 -1
- package/dist/cjs/resources/ats/offers.d.ts.map +0 -1
- package/dist/cjs/resources/ats/offers.js.map +0 -1
- package/dist/cjs/resources/ats/stages.d.ts.map +0 -1
- package/dist/cjs/resources/ats/stages.js.map +0 -1
- package/dist/cjs/resources/hris/benefits/benefits.d.ts.map +0 -1
- package/dist/cjs/resources/hris/benefits/benefits.js +0 -57
- package/dist/cjs/resources/hris/benefits/benefits.js.map +0 -1
- package/dist/cjs/resources/hris/benefits/index.d.ts.map +0 -1
- package/dist/cjs/resources/hris/benefits/index.js.map +0 -1
- package/dist/cjs/resources/hris/benefits/individuals.d.ts.map +0 -1
- package/dist/cjs/resources/hris/benefits/individuals.js.map +0 -1
- package/dist/cjs/resources/hris/company.d.ts.map +0 -1
- package/dist/cjs/resources/hris/company.js.map +0 -1
- package/dist/cjs/resources/hris/directory.d.ts.map +0 -1
- package/dist/cjs/resources/hris/directory.js.map +0 -1
- package/dist/cjs/resources/hris/hris.d.ts +0 -95
- package/dist/cjs/resources/hris/hris.d.ts.map +0 -1
- package/dist/cjs/resources/hris/hris.js +0 -24
- package/dist/cjs/resources/hris/hris.js.map +0 -1
- package/dist/cjs/resources/hris/index.d.ts.map +0 -1
- package/dist/cjs/resources/hris/index.js +0 -44
- package/dist/cjs/resources/hris/index.js.map +0 -1
- package/dist/cjs/resources/hris/individuals/employment-data.d.ts.map +0 -1
- package/dist/cjs/resources/hris/individuals/employment-data.js +0 -26
- package/dist/cjs/resources/hris/individuals/employment-data.js.map +0 -1
- package/dist/cjs/resources/hris/individuals/index.d.ts.map +0 -1
- package/dist/cjs/resources/hris/individuals/index.js.map +0 -1
- package/dist/cjs/resources/hris/individuals/individuals.d.ts.map +0 -1
- package/dist/cjs/resources/hris/individuals/individuals.js +0 -28
- package/dist/cjs/resources/hris/individuals/individuals.js.map +0 -1
- package/dist/cjs/resources/hris/pay-statements.d.ts.map +0 -1
- package/dist/cjs/resources/hris/pay-statements.js.map +0 -1
- package/dist/cjs/resources/hris/payments.d.ts.map +0 -1
- package/dist/cjs/resources/hris/payments.js.map +0 -1
- package/dist/cjs/resources/index.d.ts.map +0 -1
- package/dist/cjs/resources/index.js.map +0 -1
- package/dist/cjs/resources/providers.d.ts.map +0 -1
- package/dist/cjs/resources/providers.js.map +0 -1
- package/dist/cjs/resources/top-level.d.ts.map +0 -1
- package/dist/cjs/resources/top-level.js.map +0 -1
- package/dist/cjs/streaming.d.ts.map +0 -1
- package/dist/cjs/streaming.js +0 -220
- package/dist/cjs/streaming.js.map +0 -1
- package/dist/cjs/tests/api-resources/account.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/account.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/account.test.js +0 -66
- package/dist/cjs/tests/api-resources/account.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/ats/applications.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/ats/applications.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/ats/applications.test.js +0 -73
- package/dist/cjs/tests/api-resources/ats/applications.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/ats/candidates.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/ats/candidates.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/ats/candidates.test.js +0 -73
- package/dist/cjs/tests/api-resources/ats/candidates.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/ats/jobs.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/ats/jobs.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/ats/jobs.test.js +0 -73
- package/dist/cjs/tests/api-resources/ats/jobs.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/ats/offers.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/ats/offers.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/ats/offers.test.js +0 -73
- package/dist/cjs/tests/api-resources/ats/offers.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/ats/stages.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/ats/stages.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/ats/stages.test.js +0 -55
- package/dist/cjs/tests/api-resources/ats/stages.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.js +0 -116
- package/dist/cjs/tests/api-resources/hris/benefits/benefits.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.js +0 -111
- package/dist/cjs/tests/api-resources/hris/benefits/individuals.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/company.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/company.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/company.test.js +0 -55
- package/dist/cjs/tests/api-resources/hris/company.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/directory.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/directory.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/directory.test.js +0 -62
- package/dist/cjs/tests/api-resources/hris/directory.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.js +0 -56
- package/dist/cjs/tests/api-resources/hris/individuals/employment-data.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.js +0 -68
- package/dist/cjs/tests/api-resources/hris/individuals/individuals.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/pay-statements.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/pay-statements.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/pay-statements.test.js +0 -64
- package/dist/cjs/tests/api-resources/hris/pay-statements.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/hris/payments.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/hris/payments.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/hris/payments.test.js +0 -52
- package/dist/cjs/tests/api-resources/hris/payments.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/providers.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/providers.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/providers.test.js +0 -55
- package/dist/cjs/tests/api-resources/providers.test.js.map +0 -1
- package/dist/cjs/tests/api-resources/top-level.test.d.ts +0 -2
- package/dist/cjs/tests/api-resources/top-level.test.d.ts.map +0 -1
- package/dist/cjs/tests/api-resources/top-level.test.js +0 -52
- package/dist/cjs/tests/api-resources/top-level.test.js.map +0 -1
- package/dist/cjs/tests/form.test.d.ts +0 -2
- package/dist/cjs/tests/form.test.d.ts.map +0 -1
- package/dist/cjs/tests/form.test.js +0 -61
- package/dist/cjs/tests/form.test.js.map +0 -1
- package/dist/cjs/tests/index.test.d.ts +0 -2
- package/dist/cjs/tests/index.test.d.ts.map +0 -1
- package/dist/cjs/tests/index.test.js +0 -65
- package/dist/cjs/tests/index.test.js.map +0 -1
- package/dist/cjs/tests/responses.test.d.ts +0 -2
- package/dist/cjs/tests/responses.test.d.ts.map +0 -1
- package/dist/cjs/tests/responses.test.js +0 -60
- package/dist/cjs/tests/responses.test.js.map +0 -1
- package/dist/cjs/version.d.ts +0 -2
- package/dist/cjs/version.d.ts.map +0 -1
- package/dist/cjs/version.js.map +0 -1
- package/fetch-polyfill.ts +0 -69
- package/jest.config.js +0 -8
- package/release-please-config.json +0 -61
- package/resources/ats/ats.ts +0 -16
- package/resources/ats/index.ts +0 -7
- package/streaming.ts +0 -122
- package/tests/api-resources/account.test.ts +0 -29
- package/tests/api-resources/ats/applications.test.ts +0 -36
- package/tests/api-resources/ats/candidates.test.ts +0 -36
- package/tests/api-resources/ats/jobs.test.ts +0 -36
- package/tests/api-resources/ats/offers.test.ts +0 -36
- package/tests/api-resources/ats/stages.test.ts +0 -18
- package/tests/api-resources/hris/benefits/benefits.test.ts +0 -79
- package/tests/api-resources/hris/benefits/individuals.test.ts +0 -74
- package/tests/api-resources/hris/company.test.ts +0 -18
- package/tests/api-resources/hris/directory.test.ts +0 -25
- package/tests/api-resources/hris/individuals/employment-data.test.ts +0 -19
- package/tests/api-resources/hris/individuals/individuals.test.ts +0 -31
- package/tests/api-resources/hris/pay-statements.test.ts +0 -27
- package/tests/api-resources/hris/payments.test.ts +0 -15
- package/tests/api-resources/providers.test.ts +0 -18
- package/tests/api-resources/top-level.test.ts +0 -15
- package/tests/form.test.ts +0 -27
- package/tests/index.test.ts +0 -72
- package/tests/responses.test.ts +0 -25
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.json +0 -39
- package/typings/digest-fetch/index.d.ts +0 -33
- package/version.ts +0 -1
- /package/{dist/cjs/resource.js → resource.js} +0 -0
- /package/{dist/cjs/resources → resources}/top-level.d.ts +0 -0
- /package/{dist/cjs/resources → resources}/top-level.js +0 -0
- /package/{resource.ts → src/resource.ts} +0 -0
- /package/{resources → src/resources}/index.ts +0 -0
- /package/{resources → src/resources}/top-level.ts +0 -0
package/{core.ts → src/core.ts}
RENAMED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
import qs from 'qs';
|
|
2
|
-
|
|
3
|
-
import type { Agent } from 'http';
|
|
4
|
-
import type { RequestInfo, RequestInit, Response } from 'node-fetch';
|
|
5
|
-
import { FormData, File, Blob } from 'formdata-node';
|
|
6
|
-
import { FormDataEncoder } from 'form-data-encoder';
|
|
7
|
-
import { Readable } from 'stream';
|
|
8
|
-
|
|
1
|
+
import * as qs from 'qs';
|
|
9
2
|
import { VERSION } from './version';
|
|
10
3
|
import { Stream } from './streaming';
|
|
11
|
-
import {
|
|
4
|
+
import { APIError, APIConnectionError, APIConnectionTimeoutError } from './error';
|
|
5
|
+
import type { Readable } from '@tryfinch/finch-api/_shims/node-readable';
|
|
6
|
+
import { getDefaultAgent, type Agent } from '@tryfinch/finch-api/_shims/agent';
|
|
7
|
+
import {
|
|
8
|
+
fetch,
|
|
9
|
+
isPolyfilled as fetchIsPolyfilled,
|
|
10
|
+
type RequestInfo,
|
|
11
|
+
type RequestInit,
|
|
12
|
+
type Response,
|
|
13
|
+
} from '@tryfinch/finch-api/_shims/fetch';
|
|
14
|
+
import { isMultipartBody } from './uploads';
|
|
15
|
+
export {
|
|
16
|
+
maybeMultipartFormRequestOptions,
|
|
17
|
+
multipartFormRequestOptions,
|
|
18
|
+
createForm,
|
|
19
|
+
type Uploadable,
|
|
20
|
+
} from './uploads';
|
|
12
21
|
|
|
13
22
|
const MAX_RETRIES = 2;
|
|
14
23
|
|
|
24
|
+
type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
25
|
+
|
|
15
26
|
export abstract class APIClient {
|
|
16
27
|
baseURL: string;
|
|
17
28
|
maxRetries: number;
|
|
@@ -37,7 +48,7 @@ export abstract class APIClient {
|
|
|
37
48
|
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
38
49
|
this.httpAgent = httpAgent;
|
|
39
50
|
|
|
40
|
-
this.fetch =
|
|
51
|
+
this.fetch = fetch;
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
protected authHeaders(): Headers {
|
|
@@ -62,6 +73,8 @@ export abstract class APIClient {
|
|
|
62
73
|
};
|
|
63
74
|
}
|
|
64
75
|
|
|
76
|
+
protected abstract defaultQuery(): DefaultQuery | undefined;
|
|
77
|
+
|
|
65
78
|
/**
|
|
66
79
|
* Override this to add your own headers validation:
|
|
67
80
|
*/
|
|
@@ -111,8 +124,9 @@ export abstract class APIClient {
|
|
|
111
124
|
options: FinalRequestOptions<Req>,
|
|
112
125
|
): { req: RequestInit; url: string; timeout: number } {
|
|
113
126
|
const { method, path, query, headers: headers = {} } = options;
|
|
127
|
+
|
|
114
128
|
const body =
|
|
115
|
-
options.body
|
|
129
|
+
isMultipartBody(options.body) ? options.body.body
|
|
116
130
|
: options.body ? JSON.stringify(options.body, null, 2)
|
|
117
131
|
: null;
|
|
118
132
|
const contentLength = typeof body === 'string' ? body.length.toString() : null;
|
|
@@ -132,18 +146,23 @@ export abstract class APIClient {
|
|
|
132
146
|
...this.defaultHeaders(),
|
|
133
147
|
...headers,
|
|
134
148
|
};
|
|
149
|
+
// let builtin fetch set the Content-Type for multipart bodies
|
|
150
|
+
if (isMultipartBody(options.body) && !fetchIsPolyfilled) {
|
|
151
|
+
delete reqHeaders['Content-Type'];
|
|
152
|
+
}
|
|
135
153
|
|
|
136
154
|
// Strip any headers being explicitly omitted with null
|
|
137
155
|
Object.keys(reqHeaders).forEach((key) => reqHeaders[key] === null && delete reqHeaders[key]);
|
|
138
156
|
|
|
139
157
|
const req: RequestInit = {
|
|
140
158
|
method,
|
|
141
|
-
...(body && { body }),
|
|
159
|
+
...(body && { body: body as any }),
|
|
142
160
|
headers: reqHeaders,
|
|
143
161
|
...(httpAgent && { agent: httpAgent }),
|
|
144
162
|
};
|
|
145
163
|
|
|
146
164
|
this.validateHeaders(reqHeaders, headers);
|
|
165
|
+
|
|
147
166
|
return { req, url, timeout };
|
|
148
167
|
}
|
|
149
168
|
|
|
@@ -243,6 +262,11 @@ export abstract class APIClient {
|
|
|
243
262
|
new URL(path)
|
|
244
263
|
: new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
245
264
|
|
|
265
|
+
const defaultQuery = this.defaultQuery();
|
|
266
|
+
if (!isEmptyObj(defaultQuery)) {
|
|
267
|
+
query = { ...defaultQuery, ...query } as Req;
|
|
268
|
+
}
|
|
269
|
+
|
|
246
270
|
if (query) {
|
|
247
271
|
url.search = qs.stringify(query, this.qsOptions());
|
|
248
272
|
}
|
|
@@ -252,11 +276,12 @@ export abstract class APIClient {
|
|
|
252
276
|
|
|
253
277
|
async fetchWithTimeout(
|
|
254
278
|
url: RequestInfo,
|
|
255
|
-
|
|
279
|
+
init: RequestInit | undefined,
|
|
256
280
|
ms: number,
|
|
257
281
|
controller: AbortController,
|
|
258
|
-
) {
|
|
259
|
-
|
|
282
|
+
): Promise<Response> {
|
|
283
|
+
const { signal, ...options } = init || {};
|
|
284
|
+
if (signal) signal.addEventListener('abort', () => controller.abort());
|
|
260
285
|
|
|
261
286
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
262
287
|
|
|
@@ -341,7 +366,7 @@ export abstract class APIClient {
|
|
|
341
366
|
}
|
|
342
367
|
|
|
343
368
|
private debug(action: string, ...args: any[]) {
|
|
344
|
-
if (process.env['DEBUG'] === 'true') {
|
|
369
|
+
if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') {
|
|
345
370
|
console.log(`${this.constructor.name}:DEBUG:${action}`, ...args);
|
|
346
371
|
}
|
|
347
372
|
}
|
|
@@ -480,18 +505,25 @@ export class PagePromise<
|
|
|
480
505
|
export const createResponseHeaders = (
|
|
481
506
|
headers: Awaited<ReturnType<Fetch>>['headers'],
|
|
482
507
|
): Record<string, string> => {
|
|
483
|
-
return new Proxy(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
508
|
+
return new Proxy(
|
|
509
|
+
Object.fromEntries(
|
|
510
|
+
// @ts-ignore
|
|
511
|
+
headers.entries(),
|
|
512
|
+
),
|
|
513
|
+
{
|
|
514
|
+
get(target, name) {
|
|
515
|
+
const key = name.toString();
|
|
516
|
+
return target[key.toLowerCase()] || target[key];
|
|
517
|
+
},
|
|
487
518
|
},
|
|
488
|
-
|
|
519
|
+
);
|
|
489
520
|
};
|
|
490
521
|
|
|
491
522
|
type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
492
523
|
|
|
493
524
|
export type RequestClient = { fetch: Fetch };
|
|
494
525
|
export type Headers = Record<string, string | null | undefined>;
|
|
526
|
+
export type DefaultQuery = Record<string, string | undefined>;
|
|
495
527
|
export type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
|
496
528
|
|
|
497
529
|
export type RequestOptions<Req extends {} = Record<string, unknown> | Readable> = {
|
|
@@ -540,88 +572,12 @@ export type FinalRequestOptions<Req extends {} = Record<string, unknown> | Reada
|
|
|
540
572
|
};
|
|
541
573
|
|
|
542
574
|
export type APIResponse<T> = T & {
|
|
575
|
+
/** @deprecated - we plan to add a different way to access raw response information shortly. */
|
|
543
576
|
responseHeaders: Headers;
|
|
544
577
|
};
|
|
545
578
|
|
|
546
|
-
export class APIError extends Error {
|
|
547
|
-
readonly status: number | undefined;
|
|
548
|
-
readonly headers: Headers | undefined;
|
|
549
|
-
readonly error: Object | undefined;
|
|
550
|
-
|
|
551
|
-
constructor(
|
|
552
|
-
status: number | undefined,
|
|
553
|
-
error: Object | undefined,
|
|
554
|
-
message: string | undefined,
|
|
555
|
-
headers: Headers | undefined,
|
|
556
|
-
) {
|
|
557
|
-
super(message || (error as any)?.message);
|
|
558
|
-
this.status = status;
|
|
559
|
-
this.headers = headers;
|
|
560
|
-
this.error = error;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
static generate(
|
|
564
|
-
status: number | undefined,
|
|
565
|
-
error: Object | undefined,
|
|
566
|
-
message: string | undefined,
|
|
567
|
-
headers: Headers | undefined,
|
|
568
|
-
) {
|
|
569
|
-
if (!status) return new APIConnectionError({ cause: castToError(error) });
|
|
570
|
-
|
|
571
|
-
if (status === 400) return new BadRequestError(status, error, message, headers);
|
|
572
|
-
if (status === 401) return new AuthenticationError(status, error, message, headers);
|
|
573
|
-
if (status === 403) return new PermissionDeniedError(status, error, message, headers);
|
|
574
|
-
if (status === 404) return new NotFoundError(status, error, message, headers);
|
|
575
|
-
if (status === 409) return new ConflictError(status, error, message, headers);
|
|
576
|
-
if (status === 422) return new UnprocessableEntityError(status, error, message, headers);
|
|
577
|
-
if (status === 429) return new RateLimitError(status, error, message, headers);
|
|
578
|
-
if (status >= 500) return new InternalServerError(status, error, message, headers);
|
|
579
|
-
|
|
580
|
-
return new APIError(status, error, message, headers);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
export class BadRequestError extends APIError {
|
|
585
|
-
override readonly status: 400 = 400;
|
|
586
|
-
}
|
|
587
|
-
export class AuthenticationError extends APIError {
|
|
588
|
-
override readonly status: 401 = 401;
|
|
589
|
-
}
|
|
590
|
-
export class PermissionDeniedError extends APIError {
|
|
591
|
-
override readonly status: 403 = 403;
|
|
592
|
-
}
|
|
593
|
-
export class NotFoundError extends APIError {
|
|
594
|
-
override readonly status: 404 = 404;
|
|
595
|
-
}
|
|
596
|
-
export class ConflictError extends APIError {
|
|
597
|
-
override readonly status: 409 = 409;
|
|
598
|
-
}
|
|
599
|
-
export class UnprocessableEntityError extends APIError {
|
|
600
|
-
override readonly status: 422 = 422;
|
|
601
|
-
}
|
|
602
|
-
export class RateLimitError extends APIError {
|
|
603
|
-
override readonly status: 429 = 429;
|
|
604
|
-
}
|
|
605
|
-
export class InternalServerError extends APIError {}
|
|
606
|
-
|
|
607
|
-
export class APIConnectionError extends APIError {
|
|
608
|
-
override readonly status: undefined = undefined;
|
|
609
|
-
|
|
610
|
-
constructor({ message, cause }: { message?: string; cause?: Error | undefined }) {
|
|
611
|
-
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
612
|
-
// eslint-disable-next-line
|
|
613
|
-
// @ts-ignore
|
|
614
|
-
if (cause) this.cause = cause;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
619
|
-
constructor() {
|
|
620
|
-
super({ message: 'Request timed out.' });
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
579
|
declare const Deno: any;
|
|
580
|
+
declare const EdgeRuntime: any;
|
|
625
581
|
type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | `other:${string}` | 'unknown';
|
|
626
582
|
type PlatformName =
|
|
627
583
|
| 'MacOS'
|
|
@@ -638,7 +594,7 @@ type PlatformProperties = {
|
|
|
638
594
|
'X-Stainless-Package-Version': string;
|
|
639
595
|
'X-Stainless-OS': PlatformName;
|
|
640
596
|
'X-Stainless-Arch': Arch;
|
|
641
|
-
'X-Stainless-Runtime': 'node' | 'deno' | 'unknown';
|
|
597
|
+
'X-Stainless-Runtime': 'node' | 'deno' | 'edge' | 'unknown';
|
|
642
598
|
'X-Stainless-Runtime-Version': string;
|
|
643
599
|
};
|
|
644
600
|
const getPlatformProperties = (): PlatformProperties => {
|
|
@@ -652,7 +608,18 @@ const getPlatformProperties = (): PlatformProperties => {
|
|
|
652
608
|
'X-Stainless-Runtime-Version': Deno.version,
|
|
653
609
|
};
|
|
654
610
|
}
|
|
655
|
-
if (typeof
|
|
611
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
612
|
+
return {
|
|
613
|
+
'X-Stainless-Lang': 'js',
|
|
614
|
+
'X-Stainless-Package-Version': VERSION,
|
|
615
|
+
'X-Stainless-OS': 'Unknown',
|
|
616
|
+
'X-Stainless-Arch': `other:${EdgeRuntime}`,
|
|
617
|
+
'X-Stainless-Runtime': 'edge',
|
|
618
|
+
'X-Stainless-Runtime-Version': process.version,
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
// Check if Node.js
|
|
622
|
+
if (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') {
|
|
656
623
|
return {
|
|
657
624
|
'X-Stainless-Lang': 'js',
|
|
658
625
|
'X-Stainless-Package-Version': VERSION,
|
|
@@ -741,86 +708,11 @@ const validatePositiveInteger = (name: string, n: number) => {
|
|
|
741
708
|
return n;
|
|
742
709
|
};
|
|
743
710
|
|
|
744
|
-
const castToError = (err: any): Error => {
|
|
711
|
+
export const castToError = (err: any): Error => {
|
|
745
712
|
if (err instanceof Error) return err;
|
|
746
713
|
return new Error(err);
|
|
747
714
|
};
|
|
748
715
|
|
|
749
|
-
/**
|
|
750
|
-
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
751
|
-
* Otherwise returns the request as is.
|
|
752
|
-
*/
|
|
753
|
-
export const maybeMultipartFormRequestOptions = <T extends {} = Record<string, unknown>>(
|
|
754
|
-
opts: RequestOptions<T>,
|
|
755
|
-
): RequestOptions<T | Readable> => {
|
|
756
|
-
// TODO: does this add unreasonable overhead in the case where we shouldn't use multipart/form-data?
|
|
757
|
-
const form = createForm(opts.body);
|
|
758
|
-
|
|
759
|
-
for (const [_, entry] of form.entries()) {
|
|
760
|
-
const value = entry.valueOf();
|
|
761
|
-
if (value instanceof File || value instanceof Blob) {
|
|
762
|
-
return getMultipartRequestOptions(form, opts);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
return opts;
|
|
767
|
-
};
|
|
768
|
-
|
|
769
|
-
export const multipartFormRequestOptions = <T extends {} = Record<string, unknown>>(
|
|
770
|
-
opts: RequestOptions<T>,
|
|
771
|
-
): RequestOptions<T | Readable> => {
|
|
772
|
-
return getMultipartRequestOptions(createForm(opts.body), opts);
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
const createForm = <T = Record<string, unknown>>(body: T | undefined): FormData => {
|
|
776
|
-
const form = new FormData();
|
|
777
|
-
Object.entries(body || {}).forEach(([key, value]) => addFormValue(form, key, value));
|
|
778
|
-
return form;
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
const getMultipartRequestOptions = <T extends {} = Record<string, unknown>>(
|
|
782
|
-
form: FormData,
|
|
783
|
-
opts: RequestOptions<T>,
|
|
784
|
-
): RequestOptions<T | Readable> => {
|
|
785
|
-
const encoder = new FormDataEncoder(form);
|
|
786
|
-
return {
|
|
787
|
-
...opts,
|
|
788
|
-
headers: { ...opts.headers, ...encoder.headers, 'Content-Length': encoder.contentLength },
|
|
789
|
-
body: Readable.from(encoder),
|
|
790
|
-
};
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
const addFormValue = (form: FormData, key: string, value: unknown) => {
|
|
794
|
-
if (value == null) {
|
|
795
|
-
throw new TypeError(
|
|
796
|
-
`null is not a valid form data value, if you want to pass null then you need to use the string 'null'`,
|
|
797
|
-
);
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
// TODO: make nested formats configurable
|
|
801
|
-
if (
|
|
802
|
-
typeof value === 'string' ||
|
|
803
|
-
typeof value === 'number' ||
|
|
804
|
-
typeof value === 'boolean' ||
|
|
805
|
-
value instanceof File ||
|
|
806
|
-
value instanceof Blob
|
|
807
|
-
) {
|
|
808
|
-
form.append(key, value);
|
|
809
|
-
} else if (Array.isArray(value)) {
|
|
810
|
-
value.forEach((entry) => {
|
|
811
|
-
addFormValue(form, key + '[]', entry);
|
|
812
|
-
});
|
|
813
|
-
} else if (typeof value === 'object') {
|
|
814
|
-
Object.entries(value).forEach(([name, prop]) => {
|
|
815
|
-
addFormValue(form, `${key}[${name}]`, prop);
|
|
816
|
-
});
|
|
817
|
-
} else {
|
|
818
|
-
throw new TypeError(
|
|
819
|
-
`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`,
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
};
|
|
823
|
-
|
|
824
716
|
export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
825
717
|
if (value == null) throw new Error(`Expected a value to be given but received ${value} instead.`);
|
|
826
718
|
return value;
|
package/src/error.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless.
|
|
2
|
+
|
|
3
|
+
import { castToError, Headers } from './core';
|
|
4
|
+
|
|
5
|
+
export class APIError extends Error {
|
|
6
|
+
readonly status: number | undefined;
|
|
7
|
+
readonly headers: Headers | undefined;
|
|
8
|
+
readonly error: Object | undefined;
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
status: number | undefined,
|
|
12
|
+
error: Object | undefined,
|
|
13
|
+
message: string | undefined,
|
|
14
|
+
headers: Headers | undefined,
|
|
15
|
+
) {
|
|
16
|
+
super(message || (error as any)?.message || 'Unknown error occurred.');
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.headers = headers;
|
|
19
|
+
this.error = error;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static generate(
|
|
23
|
+
status: number | undefined,
|
|
24
|
+
errorResponse: Object | undefined,
|
|
25
|
+
message: string | undefined,
|
|
26
|
+
headers: Headers | undefined,
|
|
27
|
+
) {
|
|
28
|
+
if (!status) {
|
|
29
|
+
return new APIConnectionError({ cause: castToError(errorResponse) });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const error = errorResponse as Record<string, any>;
|
|
33
|
+
|
|
34
|
+
if (status === 400) {
|
|
35
|
+
return new BadRequestError(status, error, message, headers);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (status === 401) {
|
|
39
|
+
return new AuthenticationError(status, error, message, headers);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (status === 403) {
|
|
43
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (status === 404) {
|
|
47
|
+
return new NotFoundError(status, error, message, headers);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (status === 409) {
|
|
51
|
+
return new ConflictError(status, error, message, headers);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (status === 422) {
|
|
55
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (status === 429) {
|
|
59
|
+
return new RateLimitError(status, error, message, headers);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (status >= 500) {
|
|
63
|
+
return new InternalServerError(status, error, message, headers);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return new APIError(status, error, message, headers);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class APIConnectionError extends APIError {
|
|
71
|
+
override readonly status: undefined = undefined;
|
|
72
|
+
|
|
73
|
+
constructor({ message, cause }: { message?: string; cause?: Error | undefined }) {
|
|
74
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
75
|
+
// in some environments the 'cause' property is already declared
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
if (cause) this.cause = cause;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
82
|
+
constructor() {
|
|
83
|
+
super({ message: 'Request timed out.' });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class BadRequestError extends APIError {
|
|
88
|
+
override readonly status: 400 = 400;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class AuthenticationError extends APIError {
|
|
92
|
+
override readonly status: 401 = 401;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class PermissionDeniedError extends APIError {
|
|
96
|
+
override readonly status: 403 = 403;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class NotFoundError extends APIError {
|
|
100
|
+
override readonly status: 404 = 404;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class ConflictError extends APIError {
|
|
104
|
+
override readonly status: 409 = 409;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class UnprocessableEntityError extends APIError {
|
|
108
|
+
override readonly status: 422 = 422;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class RateLimitError extends APIError {
|
|
112
|
+
override readonly status: 429 = 429;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class InternalServerError extends APIError {}
|
|
@@ -1,23 +1,67 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import qs from 'qs';
|
|
3
|
+
import * as qs from 'qs';
|
|
4
4
|
import * as Core from './core';
|
|
5
5
|
import * as Pagination from './pagination';
|
|
6
|
-
import * as API from './resources';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import * as API from './resources/index';
|
|
7
|
+
import * as Errors from './error';
|
|
8
|
+
import type { Agent } from '@tryfinch/finch-api/_shims/agent';
|
|
9
|
+
import * as Uploads from './uploads';
|
|
9
10
|
|
|
10
11
|
type Config = {
|
|
11
12
|
/**
|
|
12
13
|
* Set it to null if you want to send unauthenticated requests.
|
|
13
14
|
*/
|
|
14
15
|
accessToken?: string | null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
19
|
+
*/
|
|
15
20
|
baseURL?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
24
|
+
* from the server before timing out a single request.
|
|
25
|
+
*
|
|
26
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
27
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
28
|
+
*/
|
|
16
29
|
timeout?: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
33
|
+
*
|
|
34
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
35
|
+
* otherwise no agent is used.
|
|
36
|
+
*/
|
|
17
37
|
httpAgent?: Agent;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
41
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
42
|
+
*
|
|
43
|
+
* @default 2
|
|
44
|
+
*/
|
|
18
45
|
maxRetries?: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Default headers to include with every request to the API.
|
|
49
|
+
*
|
|
50
|
+
* These can be removed in individual requests by explicitly setting the
|
|
51
|
+
* header to `undefined` or `null` in request options.
|
|
52
|
+
*/
|
|
19
53
|
defaultHeaders?: Core.Headers;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Default query parameters to include with every request to the API.
|
|
57
|
+
*
|
|
58
|
+
* These can be removed in individual requests by explicitly setting the
|
|
59
|
+
* param to `undefined` in request options.
|
|
60
|
+
*/
|
|
61
|
+
defaultQuery?: Core.DefaultQuery;
|
|
62
|
+
|
|
20
63
|
clientId?: string | null;
|
|
64
|
+
|
|
21
65
|
clientSecret?: string | null;
|
|
22
66
|
};
|
|
23
67
|
|
|
@@ -78,6 +122,7 @@ export class Finch extends Core.APIClient {
|
|
|
78
122
|
},
|
|
79
123
|
}).then((response) => response.access_token);
|
|
80
124
|
}
|
|
125
|
+
|
|
81
126
|
/**
|
|
82
127
|
* Returns the authorization url which can be visited in order to obtain an
|
|
83
128
|
* authorization code from Finch. The autorization code can then be exchanged for
|
|
@@ -108,6 +153,10 @@ export class Finch extends Core.APIClient {
|
|
|
108
153
|
return url.toString();
|
|
109
154
|
}
|
|
110
155
|
|
|
156
|
+
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
157
|
+
return this._options.defaultQuery;
|
|
158
|
+
}
|
|
159
|
+
|
|
111
160
|
protected override defaultHeaders(): Core.Headers {
|
|
112
161
|
return {
|
|
113
162
|
...super.defaultHeaders(),
|
|
@@ -140,42 +189,40 @@ export class Finch extends Core.APIClient {
|
|
|
140
189
|
return { arrayFormat: 'comma' };
|
|
141
190
|
}
|
|
142
191
|
|
|
143
|
-
static APIError =
|
|
144
|
-
|
|
145
|
-
static
|
|
146
|
-
static
|
|
147
|
-
|
|
148
|
-
static
|
|
149
|
-
static
|
|
150
|
-
static
|
|
151
|
-
static
|
|
152
|
-
static
|
|
153
|
-
static UnprocessableEntityError =
|
|
154
|
-
static RateLimitError = Core.RateLimitError;
|
|
155
|
-
static InternalServerError = Core.InternalServerError;
|
|
192
|
+
static APIError = Errors.APIError;
|
|
193
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
194
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
195
|
+
static NotFoundError = Errors.NotFoundError;
|
|
196
|
+
static ConflictError = Errors.ConflictError;
|
|
197
|
+
static RateLimitError = Errors.RateLimitError;
|
|
198
|
+
static BadRequestError = Errors.BadRequestError;
|
|
199
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
200
|
+
static InternalServerError = Errors.InternalServerError;
|
|
201
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
202
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
156
203
|
}
|
|
157
204
|
|
|
158
205
|
export const {
|
|
159
206
|
APIError,
|
|
160
|
-
|
|
161
207
|
APIConnectionError,
|
|
162
208
|
APIConnectionTimeoutError,
|
|
163
|
-
|
|
164
|
-
BadRequestError,
|
|
165
|
-
AuthenticationError,
|
|
166
|
-
PermissionDeniedError,
|
|
167
209
|
NotFoundError,
|
|
168
210
|
ConflictError,
|
|
169
|
-
UnprocessableEntityError,
|
|
170
211
|
RateLimitError,
|
|
212
|
+
BadRequestError,
|
|
213
|
+
AuthenticationError,
|
|
171
214
|
InternalServerError,
|
|
172
|
-
|
|
215
|
+
PermissionDeniedError,
|
|
216
|
+
UnprocessableEntityError,
|
|
217
|
+
} = Errors;
|
|
173
218
|
|
|
174
|
-
export import
|
|
219
|
+
export import toFile = Uploads.toFile;
|
|
220
|
+
export import fileFromPath = Uploads.fileFromPath;
|
|
175
221
|
|
|
176
222
|
export namespace Finch {
|
|
177
223
|
// Helper functions
|
|
178
|
-
export import
|
|
224
|
+
export import toFile = Uploads.toFile;
|
|
225
|
+
export import fileFromPath = Uploads.fileFromPath;
|
|
179
226
|
|
|
180
227
|
export import SinglePage = Pagination.SinglePage;
|
|
181
228
|
export import SinglePageResponse = Pagination.SinglePageResponse;
|
|
@@ -203,17 +250,21 @@ export namespace Finch {
|
|
|
203
250
|
export import OffersPageParams = Pagination.OffersPageParams;
|
|
204
251
|
export import OffersPageResponse = Pagination.OffersPageResponse;
|
|
205
252
|
|
|
253
|
+
export import ATS = API.ATS;
|
|
254
|
+
|
|
255
|
+
export import HRIS = API.HRIS;
|
|
206
256
|
export import Income = API.Income;
|
|
207
257
|
export import Location = API.Location;
|
|
208
258
|
export import Money = API.Money;
|
|
209
259
|
export import Paging = API.Paging;
|
|
210
260
|
|
|
261
|
+
export import Providers = API.Providers;
|
|
211
262
|
export import Provider = API.Provider;
|
|
212
263
|
export import ProvidersSinglePage = API.ProvidersSinglePage;
|
|
213
264
|
|
|
265
|
+
export import Account = API.Account;
|
|
214
266
|
export import DisconnectResponse = API.DisconnectResponse;
|
|
215
267
|
export import Introspection = API.Introspection;
|
|
216
268
|
}
|
|
217
269
|
|
|
218
|
-
exports = module.exports = Finch;
|
|
219
270
|
export default Finch;
|
|
@@ -98,7 +98,10 @@ export class IndividualsPage
|
|
|
98
98
|
implements IndividualsPageResponse
|
|
99
99
|
{
|
|
100
100
|
paging: HRIS.Paging;
|
|
101
|
-
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The array of employees.
|
|
104
|
+
*/
|
|
102
105
|
individuals: Array<HRIS.IndividualInDirectory>;
|
|
103
106
|
|
|
104
107
|
constructor(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
3
|
+
import * as Core from '@tryfinch/finch-api/core';
|
|
4
|
+
import { APIResource } from '@tryfinch/finch-api/resource';
|
|
5
|
+
import * as API from './';
|
|
5
6
|
|
|
6
7
|
export class Account extends APIResource {
|
|
7
8
|
/**
|
|
@@ -61,3 +62,8 @@ export interface Introspection {
|
|
|
61
62
|
*/
|
|
62
63
|
username: string;
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
export namespace Account {
|
|
67
|
+
export import DisconnectResponse = API.DisconnectResponse;
|
|
68
|
+
export import Introspection = API.Introspection;
|
|
69
|
+
}
|