@tryfinch/finch-api 3.0.0 → 3.1.1
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/CHANGELOG.md +181 -0
- package/LICENSE +201 -0
- package/README.md +225 -0
- package/_shims/formdata.node.d.ts +1 -0
- package/core.d.ts +9 -1
- package/core.d.ts.map +1 -1
- package/core.js +61 -18
- package/core.js.map +1 -1
- package/core.mjs +59 -18
- package/core.mjs.map +1 -1
- package/error.d.ts +4 -0
- package/error.d.ts.map +1 -1
- package/error.js +8 -0
- package/error.js.map +1 -1
- package/error.mjs +6 -0
- package/error.mjs.map +1 -1
- package/index.d.mts +10 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -1
- package/index.js +7 -0
- package/index.js.map +1 -1
- package/index.mjs +6 -0
- package/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_shims/fileFromPath.node.ts +1 -1
- package/src/_shims/fileFromPath.ts +1 -1
- package/src/_shims/formdata.node.d.ts +1 -0
- package/src/_shims/getMultipartRequestOptions.node.ts +1 -1
- package/src/_shims/getMultipartRequestOptions.ts +1 -1
- package/src/core.ts +63 -18
- package/src/error.ts +8 -0
- package/src/index.ts +14 -1
- package/src/resources/account.ts +3 -3
- package/src/resources/ats/applications.ts +6 -6
- package/src/resources/ats/ats.ts +2 -2
- package/src/resources/ats/candidates.ts +5 -5
- package/src/resources/ats/jobs.ts +5 -5
- package/src/resources/ats/offers.ts +5 -5
- package/src/resources/ats/stages.ts +4 -4
- package/src/resources/hris/benefits/benefits.ts +5 -5
- package/src/resources/hris/benefits/individuals.ts +6 -6
- package/src/resources/hris/company.ts +4 -4
- package/src/resources/hris/directory.ts +5 -5
- package/src/resources/hris/hris.ts +2 -2
- package/src/resources/hris/individuals/employment-data.ts +5 -5
- package/src/resources/hris/individuals/individuals.ts +6 -6
- package/src/resources/hris/pay-statements.ts +6 -6
- package/src/resources/hris/payments.ts +5 -5
- package/src/resources/providers.ts +4 -4
- package/src/uploads.ts +11 -10
- package/src/version.ts +1 -1
- package/uploads.d.ts +2 -2
- package/uploads.d.ts.map +1 -1
- package/uploads.js +3 -2
- package/uploads.js.map +1 -1
- package/uploads.mjs +3 -2
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/src/streaming.ts +0 -204
- package/streaming.d.ts +0 -14
- package/streaming.d.ts.map +0 -1
- package/streaming.js +0 -155
- package/streaming.js.map +0 -1
- package/streaming.mjs +0 -151
- package/streaming.mjs.map +0 -1
package/index.d.mts
CHANGED
|
@@ -29,6 +29,13 @@ type Config = {
|
|
|
29
29
|
* otherwise no agent is used.
|
|
30
30
|
*/
|
|
31
31
|
httpAgent?: Agent;
|
|
32
|
+
/**
|
|
33
|
+
* Specify a custom `fetch` function implementation.
|
|
34
|
+
*
|
|
35
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
36
|
+
* defined globally.
|
|
37
|
+
*/
|
|
38
|
+
fetch?: Core.Fetch | undefined;
|
|
32
39
|
/**
|
|
33
40
|
* The maximum number of times that the client will retry a request in case of a
|
|
34
41
|
* temporary failure, like a network error or a 5XX error from the server.
|
|
@@ -96,9 +103,11 @@ export declare class Finch extends Core.APIClient {
|
|
|
96
103
|
protected validateHeaders(headers: Core.Headers, customHeaders: Core.Headers): void;
|
|
97
104
|
protected authHeaders(): Core.Headers;
|
|
98
105
|
protected qsOptions(): qs.IStringifyOptions;
|
|
106
|
+
static Finch: typeof Finch;
|
|
99
107
|
static APIError: typeof Errors.APIError;
|
|
100
108
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
101
109
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
110
|
+
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
102
111
|
static NotFoundError: typeof Errors.NotFoundError;
|
|
103
112
|
static ConflictError: typeof Errors.ConflictError;
|
|
104
113
|
static RateLimitError: typeof Errors.RateLimitError;
|
|
@@ -111,6 +120,7 @@ export declare class Finch extends Core.APIClient {
|
|
|
111
120
|
export declare const APIError: typeof Errors.APIError,
|
|
112
121
|
APIConnectionError: typeof Errors.APIConnectionError,
|
|
113
122
|
APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError,
|
|
123
|
+
APIUserAbortError: typeof Errors.APIUserAbortError,
|
|
114
124
|
NotFoundError: typeof Errors.NotFoundError,
|
|
115
125
|
ConflictError: typeof Errors.ConflictError,
|
|
116
126
|
RateLimitError: typeof Errors.RateLimitError,
|
package/index.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ type Config = {
|
|
|
29
29
|
* otherwise no agent is used.
|
|
30
30
|
*/
|
|
31
31
|
httpAgent?: Agent;
|
|
32
|
+
/**
|
|
33
|
+
* Specify a custom `fetch` function implementation.
|
|
34
|
+
*
|
|
35
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
36
|
+
* defined globally.
|
|
37
|
+
*/
|
|
38
|
+
fetch?: Core.Fetch | undefined;
|
|
32
39
|
/**
|
|
33
40
|
* The maximum number of times that the client will retry a request in case of a
|
|
34
41
|
* temporary failure, like a network error or a 5XX error from the server.
|
|
@@ -96,9 +103,11 @@ export declare class Finch extends Core.APIClient {
|
|
|
96
103
|
protected validateHeaders(headers: Core.Headers, customHeaders: Core.Headers): void;
|
|
97
104
|
protected authHeaders(): Core.Headers;
|
|
98
105
|
protected qsOptions(): qs.IStringifyOptions;
|
|
106
|
+
static Finch: typeof Finch;
|
|
99
107
|
static APIError: typeof Errors.APIError;
|
|
100
108
|
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
101
109
|
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
110
|
+
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
102
111
|
static NotFoundError: typeof Errors.NotFoundError;
|
|
103
112
|
static ConflictError: typeof Errors.ConflictError;
|
|
104
113
|
static RateLimitError: typeof Errors.RateLimitError;
|
|
@@ -111,6 +120,7 @@ export declare class Finch extends Core.APIClient {
|
|
|
111
120
|
export declare const APIError: typeof Errors.APIError,
|
|
112
121
|
APIConnectionError: typeof Errors.APIConnectionError,
|
|
113
122
|
APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError,
|
|
123
|
+
APIUserAbortError: typeof Errors.APIUserAbortError,
|
|
114
124
|
NotFoundError: typeof Errors.NotFoundError,
|
|
115
125
|
ConflictError: typeof Errors.ConflictError,
|
|
116
126
|
RateLimitError: typeof Errors.RateLimitError,
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,KAAK,MAAM,GAAG;IACZ;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAElB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC;IAE9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;IAEjC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,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,OAAO,CAAC;IACpC,MAAM,QAAQ,kBAAkB,GAAG,GAAG,CAAC,kBAAkB,CAAC;IAC1D,MAAM,QAAQ,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;CACjD;AAED,eAAe,KAAK,CAAC"}
|
package/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var __importStar =
|
|
|
40
40
|
__setModuleDefault(result, mod);
|
|
41
41
|
return result;
|
|
42
42
|
};
|
|
43
|
+
var _a;
|
|
43
44
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
44
45
|
exports.fileFromPath =
|
|
45
46
|
exports.toFile =
|
|
@@ -51,6 +52,7 @@ exports.fileFromPath =
|
|
|
51
52
|
exports.RateLimitError =
|
|
52
53
|
exports.ConflictError =
|
|
53
54
|
exports.NotFoundError =
|
|
55
|
+
exports.APIUserAbortError =
|
|
54
56
|
exports.APIConnectionTimeoutError =
|
|
55
57
|
exports.APIConnectionError =
|
|
56
58
|
exports.APIError =
|
|
@@ -75,6 +77,7 @@ class Finch extends Core.APIClient {
|
|
|
75
77
|
timeout: options.timeout,
|
|
76
78
|
httpAgent: options.httpAgent,
|
|
77
79
|
maxRetries: options.maxRetries,
|
|
80
|
+
fetch: options.fetch,
|
|
78
81
|
});
|
|
79
82
|
this.ats = new API.ATS(this);
|
|
80
83
|
this.hris = new API.HRIS(this);
|
|
@@ -168,9 +171,12 @@ class Finch extends Core.APIClient {
|
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
exports.Finch = Finch;
|
|
174
|
+
_a = Finch;
|
|
175
|
+
Finch.Finch = _a;
|
|
171
176
|
Finch.APIError = Errors.APIError;
|
|
172
177
|
Finch.APIConnectionError = Errors.APIConnectionError;
|
|
173
178
|
Finch.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
179
|
+
Finch.APIUserAbortError = Errors.APIUserAbortError;
|
|
174
180
|
Finch.NotFoundError = Errors.NotFoundError;
|
|
175
181
|
Finch.ConflictError = Errors.ConflictError;
|
|
176
182
|
Finch.RateLimitError = Errors.RateLimitError;
|
|
@@ -182,6 +188,7 @@ Finch.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
|
182
188
|
(exports.APIError = Errors.APIError),
|
|
183
189
|
(exports.APIConnectionError = Errors.APIConnectionError),
|
|
184
190
|
(exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError),
|
|
191
|
+
(exports.APIUserAbortError = Errors.APIUserAbortError),
|
|
185
192
|
(exports.NotFoundError = Errors.NotFoundError),
|
|
186
193
|
(exports.ConflictError = Errors.ConflictError),
|
|
187
194
|
(exports.RateLimitError = Errors.RateLimitError),
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,qDAAqD
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,uCAAyB;AACzB,gDAA+B;AAC/B,4DAA2C;AAC3C,0DAAyC;AACzC,mDAAkC;AAElC,sDAAqC;AAmErC,kCAAkC;AAClC,MAAa,KAAM,SAAQ,IAAI,CAAC,SAAS;IAOvC,YAAY,MAAe;QACzB,MAAM,OAAO,GAAW;YACtB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,0BAA0B;YACnC,GAAG,MAAM;SACV,CAAC;QAEF,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;QAQL,QAAG,GAAY,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,SAAI,GAAa,IAAI,GAAG,CAAC,IAAI,CAAC,IA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CAAC;IAI7C,oBAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAI3C,sBAAgB,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAI/C,cAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IAI/B,gBAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IAInC,SAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IAEd,UAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAMhB,eAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAE1B,yBAAmB,GAAG,GAAG,CAAC,mBAAmB,CAAC;IAE9C,aAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AAGtC,CAAC,EA9CgB,KAAK,GAAL,aAAK,KAAL,aAAK,QA8CrB;AAED,kBAAe,KAAK,CAAC"}
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
|
+
var _a;
|
|
2
3
|
import * as qs from 'qs';
|
|
3
4
|
import * as Core from './core.mjs';
|
|
4
5
|
import * as Pagination from './pagination.mjs';
|
|
@@ -18,6 +19,7 @@ export class Finch extends Core.APIClient {
|
|
|
18
19
|
timeout: options.timeout,
|
|
19
20
|
httpAgent: options.httpAgent,
|
|
20
21
|
maxRetries: options.maxRetries,
|
|
22
|
+
fetch: options.fetch,
|
|
21
23
|
});
|
|
22
24
|
this.ats = new API.ATS(this);
|
|
23
25
|
this.hris = new API.HRIS(this);
|
|
@@ -110,9 +112,12 @@ export class Finch extends Core.APIClient {
|
|
|
110
112
|
return { arrayFormat: 'comma' };
|
|
111
113
|
}
|
|
112
114
|
}
|
|
115
|
+
_a = Finch;
|
|
116
|
+
Finch.Finch = _a;
|
|
113
117
|
Finch.APIError = Errors.APIError;
|
|
114
118
|
Finch.APIConnectionError = Errors.APIConnectionError;
|
|
115
119
|
Finch.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
120
|
+
Finch.APIUserAbortError = Errors.APIUserAbortError;
|
|
116
121
|
Finch.NotFoundError = Errors.NotFoundError;
|
|
117
122
|
Finch.ConflictError = Errors.ConflictError;
|
|
118
123
|
Finch.RateLimitError = Errors.RateLimitError;
|
|
@@ -125,6 +130,7 @@ export const {
|
|
|
125
130
|
APIError,
|
|
126
131
|
APIConnectionError,
|
|
127
132
|
APIConnectionTimeoutError,
|
|
133
|
+
APIUserAbortError,
|
|
128
134
|
NotFoundError,
|
|
129
135
|
ConflictError,
|
|
130
136
|
RateLimitError,
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;;OAE9C,KAAK,EAAE,MAAM,IAAI;OACjB,KAAK,IAAI;OACT,KAAK,UAAU;OACf,KAAK,GAAG;OACR,KAAK,MAAM;OAEX,KAAK,OAAO;AAmEnB,kCAAkC;AAClC,MAAM,OAAO,KAAM,SAAQ,IAAI,CAAC,SAAS;IAOvC,YAAY,MAAe;QACzB,MAAM,OAAO,GAAW;YACtB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,0BAA0B;YACnC,GAAG,MAAM;SACV,CAAC;QAEF,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;QAQL,QAAG,GAAY,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,SAAI,GAAa,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,cAAS,GAAkB,IAAI,GAAG,CAAC,SAAS,CAA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,SAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IAEd,UAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAMhB,eAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAE1B,yBAAmB,GAAG,GAAG,CAAC,mBAAmB,CAAC;IAE9C,aAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AAGtC,CAAC,EA9CgB,KAAK,KAAL,KAAK,QA8CrB;AAED,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryfinch/finch-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Client library for the Finch API",
|
|
5
5
|
"author": "Finch <founders@tryfinch.com>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"scripts": {
|
|
66
66
|
"test": "bin/check-test-server && yarn jest",
|
|
67
67
|
"build": "bash ./build",
|
|
68
|
-
"format": "prettier --write .",
|
|
68
|
+
"format": "prettier --write --cache --cache-strategy metadata . !dist",
|
|
69
69
|
"tsn": "ts-node -r tsconfig-paths/register",
|
|
70
70
|
"fix": "eslint --fix --ext ts,js ."
|
|
71
71
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { fileFromPath as _fileFromPath } from 'formdata-node/file-from-path';
|
|
6
|
-
import type { File, FilePropertyBag } from './formdata.node';
|
|
6
|
+
import type { File, FilePropertyBag } from './formdata.node.js';
|
|
7
7
|
|
|
8
8
|
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { FormData } from './formdata.node';
|
|
5
|
+
import { FormData } from './formdata.node.js';
|
|
6
6
|
import type { RequestOptions } from '../core';
|
|
7
7
|
import { Readable } from 'node:stream';
|
|
8
8
|
import { FormDataEncoder } from 'form-data-encoder';
|
package/src/core.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as qs from 'qs';
|
|
2
2
|
import { VERSION } from './version';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type
|
|
6
|
-
import { getDefaultAgent, type Agent } from '@tryfinch/finch-api/_shims/agent';
|
|
3
|
+
import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error';
|
|
4
|
+
import type { Readable } from './_shims/node-readable';
|
|
5
|
+
import { getDefaultAgent, type Agent } from './_shims/agent';
|
|
7
6
|
import {
|
|
8
7
|
fetch,
|
|
9
8
|
isPolyfilled as fetchIsPolyfilled,
|
|
10
9
|
type RequestInfo,
|
|
11
10
|
type RequestInit,
|
|
12
11
|
type Response,
|
|
13
|
-
} from '
|
|
12
|
+
} from './_shims/fetch.js';
|
|
14
13
|
import { isMultipartBody } from './uploads';
|
|
15
14
|
export {
|
|
16
15
|
maybeMultipartFormRequestOptions,
|
|
@@ -21,7 +20,7 @@ export {
|
|
|
21
20
|
|
|
22
21
|
const MAX_RETRIES = 2;
|
|
23
22
|
|
|
24
|
-
type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
23
|
+
export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
25
24
|
|
|
26
25
|
export abstract class APIClient {
|
|
27
26
|
baseURL: string;
|
|
@@ -37,18 +36,20 @@ export abstract class APIClient {
|
|
|
37
36
|
maxRetries,
|
|
38
37
|
timeout = 60 * 1000, // 60s
|
|
39
38
|
httpAgent,
|
|
39
|
+
fetch: overridenFetch,
|
|
40
40
|
}: {
|
|
41
41
|
baseURL: string;
|
|
42
42
|
maxRetries?: number | undefined;
|
|
43
43
|
timeout: number | undefined;
|
|
44
44
|
httpAgent: Agent | undefined;
|
|
45
|
+
fetch: Fetch | undefined;
|
|
45
46
|
}) {
|
|
46
47
|
this.baseURL = baseURL;
|
|
47
48
|
this.maxRetries = validatePositiveInteger('maxRetries', maxRetries ?? MAX_RETRIES);
|
|
48
49
|
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
49
50
|
this.httpAgent = httpAgent;
|
|
50
51
|
|
|
51
|
-
this.fetch = fetch;
|
|
52
|
+
this.fetch = overridenFetch ?? fetch;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
protected authHeaders(): Headers {
|
|
@@ -120,6 +121,20 @@ export abstract class APIClient {
|
|
|
120
121
|
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
121
122
|
}
|
|
122
123
|
|
|
124
|
+
private calculateContentLength(body: unknown): string | null {
|
|
125
|
+
if (typeof body === 'string') {
|
|
126
|
+
if (typeof Buffer !== 'undefined') {
|
|
127
|
+
return Buffer.byteLength(body, 'utf8').toString();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const encoder = new TextEncoder();
|
|
131
|
+
const encoded = encoder.encode(body);
|
|
132
|
+
return encoded.length.toString();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
123
138
|
buildRequest<Req extends {}>(
|
|
124
139
|
options: FinalRequestOptions<Req>,
|
|
125
140
|
): { req: RequestInit; url: string; timeout: number } {
|
|
@@ -129,12 +144,20 @@ export abstract class APIClient {
|
|
|
129
144
|
isMultipartBody(options.body) ? options.body.body
|
|
130
145
|
: options.body ? JSON.stringify(options.body, null, 2)
|
|
131
146
|
: null;
|
|
132
|
-
const contentLength =
|
|
147
|
+
const contentLength = this.calculateContentLength(body);
|
|
133
148
|
|
|
134
149
|
const url = this.buildURL(path!, query);
|
|
135
|
-
|
|
150
|
+
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
136
151
|
const timeout = options.timeout ?? this.timeout;
|
|
137
|
-
|
|
152
|
+
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
|
|
153
|
+
const minAgentTimeout = timeout + 1000;
|
|
154
|
+
if ((httpAgent as any)?.options && minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)) {
|
|
155
|
+
// Allow any given request to bump our agent active socket timeout.
|
|
156
|
+
// This may seem strange, but leaking active sockets should be rare and not particularly problematic,
|
|
157
|
+
// and without mutating agent we would need to create more of them.
|
|
158
|
+
// This tradeoff optimizes for performance.
|
|
159
|
+
(httpAgent as any).options.timeout = minAgentTimeout;
|
|
160
|
+
}
|
|
138
161
|
|
|
139
162
|
if (this.idempotencyHeader && method !== 'get') {
|
|
140
163
|
if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
|
|
@@ -159,6 +182,9 @@ export abstract class APIClient {
|
|
|
159
182
|
...(body && { body: body as any }),
|
|
160
183
|
headers: reqHeaders,
|
|
161
184
|
...(httpAgent && { agent: httpAgent }),
|
|
185
|
+
// @ts-ignore node-fetch uses a custom AbortSignal type that is
|
|
186
|
+
// not compatible with standard web types
|
|
187
|
+
signal: options.signal ?? null,
|
|
162
188
|
};
|
|
163
189
|
|
|
164
190
|
this.validateHeaders(reqHeaders, headers);
|
|
@@ -196,8 +222,15 @@ export abstract class APIClient {
|
|
|
196
222
|
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
|
197
223
|
|
|
198
224
|
if (response instanceof Error) {
|
|
199
|
-
if (
|
|
200
|
-
|
|
225
|
+
if (options.signal?.aborted) {
|
|
226
|
+
throw new APIUserAbortError();
|
|
227
|
+
}
|
|
228
|
+
if (retriesRemaining) {
|
|
229
|
+
return this.retryRequest(options, retriesRemaining);
|
|
230
|
+
}
|
|
231
|
+
if (response.name === 'AbortError') {
|
|
232
|
+
throw new APIConnectionTimeoutError();
|
|
233
|
+
}
|
|
201
234
|
throw new APIConnectionError({ cause: response });
|
|
202
235
|
}
|
|
203
236
|
|
|
@@ -218,12 +251,6 @@ export abstract class APIClient {
|
|
|
218
251
|
throw err;
|
|
219
252
|
}
|
|
220
253
|
|
|
221
|
-
if (options.stream) {
|
|
222
|
-
// Note: there is an invariant here that isn't represented in the type system
|
|
223
|
-
// that if you set `stream: true` the response type must also be `Stream<T>`
|
|
224
|
-
return new Stream<Rsp>(response, controller) as any;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
254
|
const contentType = response.headers.get('content-type');
|
|
228
255
|
if (contentType?.includes('application/json')) {
|
|
229
256
|
const json = await response.json();
|
|
@@ -537,6 +564,7 @@ export type RequestOptions<Req extends {} = Record<string, unknown> | Readable>
|
|
|
537
564
|
stream?: boolean | undefined;
|
|
538
565
|
timeout?: number;
|
|
539
566
|
httpAgent?: Agent;
|
|
567
|
+
signal?: AbortSignal | undefined | null;
|
|
540
568
|
idempotencyKey?: string;
|
|
541
569
|
};
|
|
542
570
|
|
|
@@ -554,6 +582,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
|
|
|
554
582
|
stream: true,
|
|
555
583
|
timeout: true,
|
|
556
584
|
httpAgent: true,
|
|
585
|
+
signal: true,
|
|
557
586
|
idempotencyKey: true,
|
|
558
587
|
};
|
|
559
588
|
|
|
@@ -781,3 +810,19 @@ export const getHeader = (headers: HeadersLike, key: string): string | null | un
|
|
|
781
810
|
}
|
|
782
811
|
return value;
|
|
783
812
|
};
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Encodes a string to Base64 format.
|
|
816
|
+
*/
|
|
817
|
+
export const toBase64 = (str: string | null | undefined): string => {
|
|
818
|
+
if (!str) return '';
|
|
819
|
+
if (typeof Buffer !== 'undefined') {
|
|
820
|
+
return Buffer.from(str).toString('base64');
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (typeof btoa !== 'undefined') {
|
|
824
|
+
return btoa(str);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
throw new Error('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined');
|
|
828
|
+
};
|
package/src/error.ts
CHANGED
|
@@ -67,6 +67,14 @@ export class APIError extends Error {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
export class APIUserAbortError extends APIError {
|
|
71
|
+
override readonly status: undefined = undefined;
|
|
72
|
+
|
|
73
|
+
constructor({ message }: { message?: string } = {}) {
|
|
74
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
export class APIConnectionError extends APIError {
|
|
71
79
|
override readonly status: undefined = undefined;
|
|
72
80
|
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as Core from './core';
|
|
|
5
5
|
import * as Pagination from './pagination';
|
|
6
6
|
import * as API from './resources/index';
|
|
7
7
|
import * as Errors from './error';
|
|
8
|
-
import type { Agent } from '
|
|
8
|
+
import type { Agent } from './_shims/agent';
|
|
9
9
|
import * as Uploads from './uploads';
|
|
10
10
|
|
|
11
11
|
type Config = {
|
|
@@ -36,6 +36,14 @@ type Config = {
|
|
|
36
36
|
*/
|
|
37
37
|
httpAgent?: Agent;
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Specify a custom `fetch` function implementation.
|
|
41
|
+
*
|
|
42
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
43
|
+
* defined globally.
|
|
44
|
+
*/
|
|
45
|
+
fetch?: Core.Fetch | undefined;
|
|
46
|
+
|
|
39
47
|
/**
|
|
40
48
|
* The maximum number of times that the client will retry a request in case of a
|
|
41
49
|
* temporary failure, like a network error or a 5XX error from the server.
|
|
@@ -85,6 +93,7 @@ export class Finch extends Core.APIClient {
|
|
|
85
93
|
timeout: options.timeout,
|
|
86
94
|
httpAgent: options.httpAgent,
|
|
87
95
|
maxRetries: options.maxRetries,
|
|
96
|
+
fetch: options.fetch,
|
|
88
97
|
});
|
|
89
98
|
this.accessToken = options.accessToken || null;
|
|
90
99
|
this._options = options;
|
|
@@ -189,9 +198,12 @@ export class Finch extends Core.APIClient {
|
|
|
189
198
|
return { arrayFormat: 'comma' };
|
|
190
199
|
}
|
|
191
200
|
|
|
201
|
+
static Finch = this;
|
|
202
|
+
|
|
192
203
|
static APIError = Errors.APIError;
|
|
193
204
|
static APIConnectionError = Errors.APIConnectionError;
|
|
194
205
|
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
206
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
195
207
|
static NotFoundError = Errors.NotFoundError;
|
|
196
208
|
static ConflictError = Errors.ConflictError;
|
|
197
209
|
static RateLimitError = Errors.RateLimitError;
|
|
@@ -206,6 +218,7 @@ export const {
|
|
|
206
218
|
APIError,
|
|
207
219
|
APIConnectionError,
|
|
208
220
|
APIConnectionTimeoutError,
|
|
221
|
+
APIUserAbortError,
|
|
209
222
|
NotFoundError,
|
|
210
223
|
ConflictError,
|
|
211
224
|
RateLimitError,
|
package/src/resources/account.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import * as API from '
|
|
3
|
+
import * as Core from '../core';
|
|
4
|
+
import { APIResource } from '../resource';
|
|
5
|
+
import * as API from '.';
|
|
6
6
|
|
|
7
7
|
export class Account extends APIResource {
|
|
8
8
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import { isRequestOptions } from '
|
|
6
|
-
import * as Stages from '
|
|
7
|
-
import * as API from '
|
|
8
|
-
import { ApplicationsPage, ApplicationsPageParams } from '
|
|
3
|
+
import * as Core from '../../core';
|
|
4
|
+
import { APIResource } from '../../resource';
|
|
5
|
+
import { isRequestOptions } from '../../core';
|
|
6
|
+
import * as Stages from './stages';
|
|
7
|
+
import * as API from '.';
|
|
8
|
+
import { ApplicationsPage, ApplicationsPageParams } from '../../pagination';
|
|
9
9
|
|
|
10
10
|
export class Applications extends APIResource {
|
|
11
11
|
/**
|
package/src/resources/ats/ats.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '
|
|
3
|
+
import { APIResource } from '../../resource';
|
|
4
4
|
import { Candidates } from './candidates';
|
|
5
5
|
import { Applications } from './applications';
|
|
6
6
|
import { Stages } from './stages';
|
|
7
7
|
import { Jobs } from './jobs';
|
|
8
8
|
import { Offers } from './offers';
|
|
9
|
-
import * as API from '
|
|
9
|
+
import * as API from '.';
|
|
10
10
|
|
|
11
11
|
export class ATS extends APIResource {
|
|
12
12
|
candidates: Candidates = new Candidates(this.client);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import { isRequestOptions } from '
|
|
6
|
-
import * as API from '
|
|
7
|
-
import { CandidatesPage, CandidatesPageParams } from '
|
|
3
|
+
import * as Core from '../../core';
|
|
4
|
+
import { APIResource } from '../../resource';
|
|
5
|
+
import { isRequestOptions } from '../../core';
|
|
6
|
+
import * as API from '.';
|
|
7
|
+
import { CandidatesPage, CandidatesPageParams } from '../../pagination';
|
|
8
8
|
|
|
9
9
|
export class Candidates extends APIResource {
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import { isRequestOptions } from '
|
|
6
|
-
import * as API from '
|
|
7
|
-
import { JobsPage, JobsPageParams } from '
|
|
3
|
+
import * as Core from '../../core';
|
|
4
|
+
import { APIResource } from '../../resource';
|
|
5
|
+
import { isRequestOptions } from '../../core';
|
|
6
|
+
import * as API from '.';
|
|
7
|
+
import { JobsPage, JobsPageParams } from '../../pagination';
|
|
8
8
|
|
|
9
9
|
export class Jobs extends APIResource {
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import { isRequestOptions } from '
|
|
6
|
-
import * as API from '
|
|
7
|
-
import { OffersPage, OffersPageParams } from '
|
|
3
|
+
import * as Core from '../../core';
|
|
4
|
+
import { APIResource } from '../../resource';
|
|
5
|
+
import { isRequestOptions } from '../../core';
|
|
6
|
+
import * as API from '.';
|
|
7
|
+
import { OffersPage, OffersPageParams } from '../../pagination';
|
|
8
8
|
|
|
9
9
|
export class Offers extends APIResource {
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import * as API from '
|
|
6
|
-
import { SinglePage } from '
|
|
3
|
+
import * as Core from '../../core';
|
|
4
|
+
import { APIResource } from '../../resource';
|
|
5
|
+
import * as API from '.';
|
|
6
|
+
import { SinglePage } from '../../pagination';
|
|
7
7
|
|
|
8
8
|
export class Stages extends APIResource {
|
|
9
9
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '
|
|
4
|
-
import { APIResource } from '
|
|
5
|
-
import { isRequestOptions } from '
|
|
3
|
+
import * as Core from '../../../core';
|
|
4
|
+
import { APIResource } from '../../../resource';
|
|
5
|
+
import { isRequestOptions } from '../../../core';
|
|
6
6
|
import { Individuals } from './individuals';
|
|
7
|
-
import * as API from '
|
|
8
|
-
import { SinglePage } from '
|
|
7
|
+
import * as API from '.';
|
|
8
|
+
import { SinglePage } from '../../../pagination';
|
|
9
9
|
|
|
10
10
|
export class Benefits extends APIResource {
|
|
11
11
|
individuals: Individuals = new Individuals(this.client);
|