@tryfinch/finch-api 5.22.4 → 5.22.6
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 +16 -0
- package/client.d.ts +204 -0
- package/client.d.ts.map +1 -0
- package/client.js +218 -0
- package/client.js.map +1 -0
- package/client.mjs +191 -0
- package/client.mjs.map +1 -0
- package/index.d.mts +2 -203
- package/index.d.ts +2 -203
- package/index.d.ts.map +1 -1
- package/index.js +6 -192
- package/index.js.map +1 -1
- package/index.mjs +2 -189
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +369 -0
- package/src/index.ts +4 -367
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/client.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"AAAA,sFAAsF;;OAE/E,KAAK,IAAI;OACT,KAAK,MAAM;OAEX,KAAK,OAAO;OACZ,KAAK,UAAU,MAAM,gCAAgC;OACrD,KAAK,GAAG,MAAM,qCAAqC;AAuF1D,qDAAqD;AACrD,MAAM,OAAO,KAAM,SAAQ,IAAI,CAAC,SAAS;IAUvC;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,EACV,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACxC,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAClD,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,IAAI,EAC1D,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,IAAI,EACjE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,IAAI,EACzE,aAAa,GAAG,IAAI,CAAC,OAAO,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GnC,mBAAa,GAAG,UAAU,CAAC,aAAa,CAAC;IAGzC,qBAAe,GAAG,UAAU,CAAC,eAAe,CAAC;IAI7C,UAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAIvB,kBAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAIhC,UAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAKhB,eAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAE1B,yBAAmB,GAAG,GAAG,CAAC,mBAAmB,CAAC;IAE9C,aAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAItB,cAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAYxB,uBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC;IAI1C,UAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEhB,aAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AAMtC,CAAC,EA1DgB,KAAK,KAAL,KAAK,QA0DrB"}
|
package/index.d.mts
CHANGED
|
@@ -1,208 +1,7 @@
|
|
|
1
|
-
import * as Core from "./core.js";
|
|
2
1
|
import * as Errors from "./error.js";
|
|
3
|
-
import { type Agent } from "./_shims/index.js";
|
|
4
2
|
import * as Uploads from "./uploads.js";
|
|
5
|
-
import * as Pagination from '@tryfinch/finch-api/pagination';
|
|
6
|
-
import * as API from '@tryfinch/finch-api/resources/index';
|
|
7
|
-
export interface ClientOptions {
|
|
8
|
-
accessToken?: string | null | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Defaults to process.env['FINCH_CLIENT_ID'].
|
|
11
|
-
*/
|
|
12
|
-
clientId?: string | null | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Defaults to process.env['FINCH_CLIENT_SECRET'].
|
|
15
|
-
*/
|
|
16
|
-
clientSecret?: string | null | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Defaults to process.env['FINCH_SANDBOX_CLIENT_ID'].
|
|
19
|
-
*/
|
|
20
|
-
sandboxClientId?: string | null | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Defaults to process.env['FINCH_SANDBOX_CLIENT_SECRET'].
|
|
23
|
-
*/
|
|
24
|
-
sandboxClientSecret?: string | null | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Defaults to process.env['FINCH_WEBHOOK_SECRET'].
|
|
27
|
-
*/
|
|
28
|
-
webhookSecret?: string | null | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
31
|
-
*
|
|
32
|
-
* Defaults to process.env['FINCH_BASE_URL'].
|
|
33
|
-
*/
|
|
34
|
-
baseURL?: string | null | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
37
|
-
* from the server before timing out a single request.
|
|
38
|
-
*
|
|
39
|
-
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
40
|
-
* much longer than this timeout before the promise succeeds or fails.
|
|
41
|
-
*/
|
|
42
|
-
timeout?: number;
|
|
43
|
-
/**
|
|
44
|
-
* An HTTP agent used to manage HTTP(S) connections.
|
|
45
|
-
*
|
|
46
|
-
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
47
|
-
* otherwise no agent is used.
|
|
48
|
-
*/
|
|
49
|
-
httpAgent?: Agent;
|
|
50
|
-
/**
|
|
51
|
-
* Specify a custom `fetch` function implementation.
|
|
52
|
-
*
|
|
53
|
-
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
54
|
-
* defined globally.
|
|
55
|
-
*/
|
|
56
|
-
fetch?: Core.Fetch | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* The maximum number of times that the client will retry a request in case of a
|
|
59
|
-
* temporary failure, like a network error or a 5XX error from the server.
|
|
60
|
-
*
|
|
61
|
-
* @default 2
|
|
62
|
-
*/
|
|
63
|
-
maxRetries?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Default headers to include with every request to the API.
|
|
66
|
-
*
|
|
67
|
-
* These can be removed in individual requests by explicitly setting the
|
|
68
|
-
* header to `undefined` or `null` in request options.
|
|
69
|
-
*/
|
|
70
|
-
defaultHeaders?: Core.Headers;
|
|
71
|
-
/**
|
|
72
|
-
* Default query parameters to include with every request to the API.
|
|
73
|
-
*
|
|
74
|
-
* These can be removed in individual requests by explicitly setting the
|
|
75
|
-
* param to `undefined` in request options.
|
|
76
|
-
*/
|
|
77
|
-
defaultQuery?: Core.DefaultQuery;
|
|
78
|
-
}
|
|
79
|
-
/** API Client for interfacing with the Finch API. */
|
|
80
|
-
export declare class Finch extends Core.APIClient {
|
|
81
|
-
accessToken: string | null;
|
|
82
|
-
clientId: string | null;
|
|
83
|
-
clientSecret: string | null;
|
|
84
|
-
sandboxClientId: string | null;
|
|
85
|
-
sandboxClientSecret: string | null;
|
|
86
|
-
webhookSecret: string | null;
|
|
87
|
-
private _options;
|
|
88
|
-
/**
|
|
89
|
-
* API Client for interfacing with the Finch API.
|
|
90
|
-
*
|
|
91
|
-
* @param {string | null | undefined} [opts.accessToken]
|
|
92
|
-
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
93
|
-
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
94
|
-
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
95
|
-
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
96
|
-
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
97
|
-
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
98
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
99
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
100
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
101
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
102
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
103
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
104
|
-
*/
|
|
105
|
-
constructor({ baseURL, accessToken, clientId, clientSecret, sandboxClientId, sandboxClientSecret, webhookSecret, ...opts }?: ClientOptions);
|
|
106
|
-
accessTokens: API.AccessTokens;
|
|
107
|
-
hris: API.HRIS;
|
|
108
|
-
providers: API.Providers;
|
|
109
|
-
account: API.Account;
|
|
110
|
-
webhooks: API.Webhooks;
|
|
111
|
-
requestForwarding: API.RequestForwarding;
|
|
112
|
-
jobs: API.Jobs;
|
|
113
|
-
sandbox: API.Sandbox;
|
|
114
|
-
/**
|
|
115
|
-
* DEPRECATED: use client.accessTokens.create instead.
|
|
116
|
-
*/
|
|
117
|
-
getAccessToken(code: string, options?: {
|
|
118
|
-
redirectUri: string;
|
|
119
|
-
}): Promise<string>;
|
|
120
|
-
/**
|
|
121
|
-
* Returns the authorization url which can be visited in order to obtain an
|
|
122
|
-
* authorization code from Finch. The authorization code can then be exchanged for
|
|
123
|
-
* an access token for the Finch api by calling get_access_token().
|
|
124
|
-
*/
|
|
125
|
-
getAuthURL({ products, redirectUri, sandbox, }: {
|
|
126
|
-
products: string;
|
|
127
|
-
redirectUri: string;
|
|
128
|
-
sandbox: boolean;
|
|
129
|
-
}): string;
|
|
130
|
-
/**
|
|
131
|
-
* Returns a copy of the current Finch client with the given access token for
|
|
132
|
-
* authentication.
|
|
133
|
-
*/
|
|
134
|
-
withAccessToken(accessToken: string): Finch;
|
|
135
|
-
protected defaultQuery(): Core.DefaultQuery | undefined;
|
|
136
|
-
protected defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers;
|
|
137
|
-
protected validateHeaders(headers: Core.Headers, customHeaders: Core.Headers): void;
|
|
138
|
-
protected authHeaders(opts: Core.FinalRequestOptions): Core.Headers;
|
|
139
|
-
protected bearerAuth(opts: Core.FinalRequestOptions): Core.Headers;
|
|
140
|
-
protected basicAuth(opts: Core.FinalRequestOptions): Core.Headers;
|
|
141
|
-
static Finch: typeof Finch;
|
|
142
|
-
static FinchError: typeof Errors.FinchError;
|
|
143
|
-
static APIError: typeof Errors.APIError;
|
|
144
|
-
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
145
|
-
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
146
|
-
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
147
|
-
static NotFoundError: typeof Errors.NotFoundError;
|
|
148
|
-
static ConflictError: typeof Errors.ConflictError;
|
|
149
|
-
static RateLimitError: typeof Errors.RateLimitError;
|
|
150
|
-
static BadRequestError: typeof Errors.BadRequestError;
|
|
151
|
-
static AuthenticationError: typeof Errors.AuthenticationError;
|
|
152
|
-
static InternalServerError: typeof Errors.InternalServerError;
|
|
153
|
-
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
154
|
-
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
155
|
-
static toFile: typeof Uploads.toFile;
|
|
156
|
-
static fileFromPath: typeof Uploads.fileFromPath;
|
|
157
|
-
}
|
|
158
|
-
export declare const FinchError: typeof Errors.FinchError, APIError: typeof Errors.APIError, APIConnectionError: typeof Errors.APIConnectionError, APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError, APIUserAbortError: typeof Errors.APIUserAbortError, NotFoundError: typeof Errors.NotFoundError, ConflictError: typeof Errors.ConflictError, RateLimitError: typeof Errors.RateLimitError, BadRequestError: typeof Errors.BadRequestError, AuthenticationError: typeof Errors.AuthenticationError, InternalServerError: typeof Errors.InternalServerError, PermissionDeniedError: typeof Errors.PermissionDeniedError, UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
159
3
|
export import toFile = Uploads.toFile;
|
|
160
4
|
export import fileFromPath = Uploads.fileFromPath;
|
|
161
|
-
export declare
|
|
162
|
-
|
|
163
|
-
export import SinglePage = Pagination.SinglePage;
|
|
164
|
-
export import SinglePageResponse = Pagination.SinglePageResponse;
|
|
165
|
-
export import ResponsesPage = Pagination.ResponsesPage;
|
|
166
|
-
export import ResponsesPageResponse = Pagination.ResponsesPageResponse;
|
|
167
|
-
export import IndividualsPage = Pagination.IndividualsPage;
|
|
168
|
-
export import IndividualsPageParams = Pagination.IndividualsPageParams;
|
|
169
|
-
export import IndividualsPageResponse = Pagination.IndividualsPageResponse;
|
|
170
|
-
export import Page = Pagination.Page;
|
|
171
|
-
export import PageParams = Pagination.PageParams;
|
|
172
|
-
export import PageResponse = Pagination.PageResponse;
|
|
173
|
-
export import AccessTokens = API.AccessTokens;
|
|
174
|
-
export import CreateAccessTokenResponse = API.CreateAccessTokenResponse;
|
|
175
|
-
export import AccessTokenCreateParams = API.AccessTokenCreateParams;
|
|
176
|
-
export import HRIS = API.HRIS;
|
|
177
|
-
export import Income = API.Income;
|
|
178
|
-
export import Location = API.Location;
|
|
179
|
-
export import Money = API.Money;
|
|
180
|
-
export import Providers = API.Providers;
|
|
181
|
-
export import Provider = API.Provider;
|
|
182
|
-
export import ProvidersSinglePage = API.ProvidersSinglePage;
|
|
183
|
-
export import Account = API.Account;
|
|
184
|
-
export import DisconnectResponse = API.DisconnectResponse;
|
|
185
|
-
export import Introspection = API.Introspection;
|
|
186
|
-
export import Webhooks = API.Webhooks;
|
|
187
|
-
export import AccountUpdateEvent = API.AccountUpdateEvent;
|
|
188
|
-
export import BaseWebhookEvent = API.BaseWebhookEvent;
|
|
189
|
-
export import CompanyEvent = API.CompanyEvent;
|
|
190
|
-
export import DirectoryEvent = API.DirectoryEvent;
|
|
191
|
-
export import EmploymentEvent = API.EmploymentEvent;
|
|
192
|
-
export import IndividualEvent = API.IndividualEvent;
|
|
193
|
-
export import JobCompletionEvent = API.JobCompletionEvent;
|
|
194
|
-
export import PayStatementEvent = API.PayStatementEvent;
|
|
195
|
-
export import PaymentEvent = API.PaymentEvent;
|
|
196
|
-
export import WebhookEvent = API.WebhookEvent;
|
|
197
|
-
export import RequestForwarding = API.RequestForwarding;
|
|
198
|
-
export import RequestForwardingForwardResponse = API.RequestForwardingForwardResponse;
|
|
199
|
-
export import RequestForwardingForwardParams = API.RequestForwardingForwardParams;
|
|
200
|
-
export import Jobs = API.Jobs;
|
|
201
|
-
export import Sandbox = API.Sandbox;
|
|
202
|
-
export import ConnectionStatusType = API.ConnectionStatusType;
|
|
203
|
-
export import OperationSupport = API.OperationSupport;
|
|
204
|
-
export import OperationSupportMatrix = API.OperationSupportMatrix;
|
|
205
|
-
export import Paging = API.Paging;
|
|
206
|
-
}
|
|
207
|
-
export default Finch;
|
|
5
|
+
export declare const FinchError: typeof Errors.FinchError, APIError: typeof Errors.APIError, APIConnectionError: typeof Errors.APIConnectionError, APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError, APIUserAbortError: typeof Errors.APIUserAbortError, NotFoundError: typeof Errors.NotFoundError, ConflictError: typeof Errors.ConflictError, RateLimitError: typeof Errors.RateLimitError, BadRequestError: typeof Errors.BadRequestError, AuthenticationError: typeof Errors.AuthenticationError, InternalServerError: typeof Errors.InternalServerError, PermissionDeniedError: typeof Errors.PermissionDeniedError, UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
6
|
+
export * from "./client.js";
|
|
208
7
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts
CHANGED
|
@@ -1,208 +1,7 @@
|
|
|
1
|
-
import * as Core from "./core.js";
|
|
2
1
|
import * as Errors from "./error.js";
|
|
3
|
-
import { type Agent } from "./_shims/index.js";
|
|
4
2
|
import * as Uploads from "./uploads.js";
|
|
5
|
-
import * as Pagination from '@tryfinch/finch-api/pagination';
|
|
6
|
-
import * as API from '@tryfinch/finch-api/resources/index';
|
|
7
|
-
export interface ClientOptions {
|
|
8
|
-
accessToken?: string | null | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Defaults to process.env['FINCH_CLIENT_ID'].
|
|
11
|
-
*/
|
|
12
|
-
clientId?: string | null | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Defaults to process.env['FINCH_CLIENT_SECRET'].
|
|
15
|
-
*/
|
|
16
|
-
clientSecret?: string | null | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Defaults to process.env['FINCH_SANDBOX_CLIENT_ID'].
|
|
19
|
-
*/
|
|
20
|
-
sandboxClientId?: string | null | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Defaults to process.env['FINCH_SANDBOX_CLIENT_SECRET'].
|
|
23
|
-
*/
|
|
24
|
-
sandboxClientSecret?: string | null | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Defaults to process.env['FINCH_WEBHOOK_SECRET'].
|
|
27
|
-
*/
|
|
28
|
-
webhookSecret?: string | null | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
31
|
-
*
|
|
32
|
-
* Defaults to process.env['FINCH_BASE_URL'].
|
|
33
|
-
*/
|
|
34
|
-
baseURL?: string | null | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
37
|
-
* from the server before timing out a single request.
|
|
38
|
-
*
|
|
39
|
-
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
40
|
-
* much longer than this timeout before the promise succeeds or fails.
|
|
41
|
-
*/
|
|
42
|
-
timeout?: number;
|
|
43
|
-
/**
|
|
44
|
-
* An HTTP agent used to manage HTTP(S) connections.
|
|
45
|
-
*
|
|
46
|
-
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
47
|
-
* otherwise no agent is used.
|
|
48
|
-
*/
|
|
49
|
-
httpAgent?: Agent;
|
|
50
|
-
/**
|
|
51
|
-
* Specify a custom `fetch` function implementation.
|
|
52
|
-
*
|
|
53
|
-
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
54
|
-
* defined globally.
|
|
55
|
-
*/
|
|
56
|
-
fetch?: Core.Fetch | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* The maximum number of times that the client will retry a request in case of a
|
|
59
|
-
* temporary failure, like a network error or a 5XX error from the server.
|
|
60
|
-
*
|
|
61
|
-
* @default 2
|
|
62
|
-
*/
|
|
63
|
-
maxRetries?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Default headers to include with every request to the API.
|
|
66
|
-
*
|
|
67
|
-
* These can be removed in individual requests by explicitly setting the
|
|
68
|
-
* header to `undefined` or `null` in request options.
|
|
69
|
-
*/
|
|
70
|
-
defaultHeaders?: Core.Headers;
|
|
71
|
-
/**
|
|
72
|
-
* Default query parameters to include with every request to the API.
|
|
73
|
-
*
|
|
74
|
-
* These can be removed in individual requests by explicitly setting the
|
|
75
|
-
* param to `undefined` in request options.
|
|
76
|
-
*/
|
|
77
|
-
defaultQuery?: Core.DefaultQuery;
|
|
78
|
-
}
|
|
79
|
-
/** API Client for interfacing with the Finch API. */
|
|
80
|
-
export declare class Finch extends Core.APIClient {
|
|
81
|
-
accessToken: string | null;
|
|
82
|
-
clientId: string | null;
|
|
83
|
-
clientSecret: string | null;
|
|
84
|
-
sandboxClientId: string | null;
|
|
85
|
-
sandboxClientSecret: string | null;
|
|
86
|
-
webhookSecret: string | null;
|
|
87
|
-
private _options;
|
|
88
|
-
/**
|
|
89
|
-
* API Client for interfacing with the Finch API.
|
|
90
|
-
*
|
|
91
|
-
* @param {string | null | undefined} [opts.accessToken]
|
|
92
|
-
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
93
|
-
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
94
|
-
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
95
|
-
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
96
|
-
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
97
|
-
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
98
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
99
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
100
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
101
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
102
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
103
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
104
|
-
*/
|
|
105
|
-
constructor({ baseURL, accessToken, clientId, clientSecret, sandboxClientId, sandboxClientSecret, webhookSecret, ...opts }?: ClientOptions);
|
|
106
|
-
accessTokens: API.AccessTokens;
|
|
107
|
-
hris: API.HRIS;
|
|
108
|
-
providers: API.Providers;
|
|
109
|
-
account: API.Account;
|
|
110
|
-
webhooks: API.Webhooks;
|
|
111
|
-
requestForwarding: API.RequestForwarding;
|
|
112
|
-
jobs: API.Jobs;
|
|
113
|
-
sandbox: API.Sandbox;
|
|
114
|
-
/**
|
|
115
|
-
* DEPRECATED: use client.accessTokens.create instead.
|
|
116
|
-
*/
|
|
117
|
-
getAccessToken(code: string, options?: {
|
|
118
|
-
redirectUri: string;
|
|
119
|
-
}): Promise<string>;
|
|
120
|
-
/**
|
|
121
|
-
* Returns the authorization url which can be visited in order to obtain an
|
|
122
|
-
* authorization code from Finch. The authorization code can then be exchanged for
|
|
123
|
-
* an access token for the Finch api by calling get_access_token().
|
|
124
|
-
*/
|
|
125
|
-
getAuthURL({ products, redirectUri, sandbox, }: {
|
|
126
|
-
products: string;
|
|
127
|
-
redirectUri: string;
|
|
128
|
-
sandbox: boolean;
|
|
129
|
-
}): string;
|
|
130
|
-
/**
|
|
131
|
-
* Returns a copy of the current Finch client with the given access token for
|
|
132
|
-
* authentication.
|
|
133
|
-
*/
|
|
134
|
-
withAccessToken(accessToken: string): Finch;
|
|
135
|
-
protected defaultQuery(): Core.DefaultQuery | undefined;
|
|
136
|
-
protected defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers;
|
|
137
|
-
protected validateHeaders(headers: Core.Headers, customHeaders: Core.Headers): void;
|
|
138
|
-
protected authHeaders(opts: Core.FinalRequestOptions): Core.Headers;
|
|
139
|
-
protected bearerAuth(opts: Core.FinalRequestOptions): Core.Headers;
|
|
140
|
-
protected basicAuth(opts: Core.FinalRequestOptions): Core.Headers;
|
|
141
|
-
static Finch: typeof Finch;
|
|
142
|
-
static FinchError: typeof Errors.FinchError;
|
|
143
|
-
static APIError: typeof Errors.APIError;
|
|
144
|
-
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
145
|
-
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
146
|
-
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
147
|
-
static NotFoundError: typeof Errors.NotFoundError;
|
|
148
|
-
static ConflictError: typeof Errors.ConflictError;
|
|
149
|
-
static RateLimitError: typeof Errors.RateLimitError;
|
|
150
|
-
static BadRequestError: typeof Errors.BadRequestError;
|
|
151
|
-
static AuthenticationError: typeof Errors.AuthenticationError;
|
|
152
|
-
static InternalServerError: typeof Errors.InternalServerError;
|
|
153
|
-
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
154
|
-
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
155
|
-
static toFile: typeof Uploads.toFile;
|
|
156
|
-
static fileFromPath: typeof Uploads.fileFromPath;
|
|
157
|
-
}
|
|
158
|
-
export declare const FinchError: typeof Errors.FinchError, APIError: typeof Errors.APIError, APIConnectionError: typeof Errors.APIConnectionError, APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError, APIUserAbortError: typeof Errors.APIUserAbortError, NotFoundError: typeof Errors.NotFoundError, ConflictError: typeof Errors.ConflictError, RateLimitError: typeof Errors.RateLimitError, BadRequestError: typeof Errors.BadRequestError, AuthenticationError: typeof Errors.AuthenticationError, InternalServerError: typeof Errors.InternalServerError, PermissionDeniedError: typeof Errors.PermissionDeniedError, UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
159
3
|
export import toFile = Uploads.toFile;
|
|
160
4
|
export import fileFromPath = Uploads.fileFromPath;
|
|
161
|
-
export declare
|
|
162
|
-
|
|
163
|
-
export import SinglePage = Pagination.SinglePage;
|
|
164
|
-
export import SinglePageResponse = Pagination.SinglePageResponse;
|
|
165
|
-
export import ResponsesPage = Pagination.ResponsesPage;
|
|
166
|
-
export import ResponsesPageResponse = Pagination.ResponsesPageResponse;
|
|
167
|
-
export import IndividualsPage = Pagination.IndividualsPage;
|
|
168
|
-
export import IndividualsPageParams = Pagination.IndividualsPageParams;
|
|
169
|
-
export import IndividualsPageResponse = Pagination.IndividualsPageResponse;
|
|
170
|
-
export import Page = Pagination.Page;
|
|
171
|
-
export import PageParams = Pagination.PageParams;
|
|
172
|
-
export import PageResponse = Pagination.PageResponse;
|
|
173
|
-
export import AccessTokens = API.AccessTokens;
|
|
174
|
-
export import CreateAccessTokenResponse = API.CreateAccessTokenResponse;
|
|
175
|
-
export import AccessTokenCreateParams = API.AccessTokenCreateParams;
|
|
176
|
-
export import HRIS = API.HRIS;
|
|
177
|
-
export import Income = API.Income;
|
|
178
|
-
export import Location = API.Location;
|
|
179
|
-
export import Money = API.Money;
|
|
180
|
-
export import Providers = API.Providers;
|
|
181
|
-
export import Provider = API.Provider;
|
|
182
|
-
export import ProvidersSinglePage = API.ProvidersSinglePage;
|
|
183
|
-
export import Account = API.Account;
|
|
184
|
-
export import DisconnectResponse = API.DisconnectResponse;
|
|
185
|
-
export import Introspection = API.Introspection;
|
|
186
|
-
export import Webhooks = API.Webhooks;
|
|
187
|
-
export import AccountUpdateEvent = API.AccountUpdateEvent;
|
|
188
|
-
export import BaseWebhookEvent = API.BaseWebhookEvent;
|
|
189
|
-
export import CompanyEvent = API.CompanyEvent;
|
|
190
|
-
export import DirectoryEvent = API.DirectoryEvent;
|
|
191
|
-
export import EmploymentEvent = API.EmploymentEvent;
|
|
192
|
-
export import IndividualEvent = API.IndividualEvent;
|
|
193
|
-
export import JobCompletionEvent = API.JobCompletionEvent;
|
|
194
|
-
export import PayStatementEvent = API.PayStatementEvent;
|
|
195
|
-
export import PaymentEvent = API.PaymentEvent;
|
|
196
|
-
export import WebhookEvent = API.WebhookEvent;
|
|
197
|
-
export import RequestForwarding = API.RequestForwarding;
|
|
198
|
-
export import RequestForwardingForwardResponse = API.RequestForwardingForwardResponse;
|
|
199
|
-
export import RequestForwardingForwardParams = API.RequestForwardingForwardParams;
|
|
200
|
-
export import Jobs = API.Jobs;
|
|
201
|
-
export import Sandbox = API.Sandbox;
|
|
202
|
-
export import ConnectionStatusType = API.ConnectionStatusType;
|
|
203
|
-
export import OperationSupport = API.OperationSupport;
|
|
204
|
-
export import OperationSupportMatrix = API.OperationSupportMatrix;
|
|
205
|
-
export import Paging = API.Paging;
|
|
206
|
-
}
|
|
207
|
-
export default Finch;
|
|
5
|
+
export declare const FinchError: typeof Errors.FinchError, APIError: typeof Errors.APIError, APIConnectionError: typeof Errors.APIConnectionError, APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError, APIUserAbortError: typeof Errors.APIUserAbortError, NotFoundError: typeof Errors.NotFoundError, ConflictError: typeof Errors.ConflictError, RateLimitError: typeof Errors.RateLimitError, BadRequestError: typeof Errors.BadRequestError, AuthenticationError: typeof Errors.AuthenticationError, InternalServerError: typeof Errors.InternalServerError, PermissionDeniedError: typeof Errors.PermissionDeniedError, UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
6
|
+
export * from "./client.js";
|
|
208
7
|
//# sourceMappingURL=index.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAIrC,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACtC,MAAM,QAAQ,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAElD,eAAO,MACL,UAAU,4BACV,QAAQ,0BACR,kBAAkB,oCAClB,yBAAyB,2CACzB,iBAAiB,mCACjB,aAAa,+BACb,aAAa,+BACb,cAAc,gCACd,eAAe,iCACf,mBAAmB,qCACnB,mBAAmB,qCACnB,qBAAqB,uCACrB,wBAAwB,wCAChB,CAAC;AAEX,cAAc,UAAU,CAAC"}
|
package/index.js
CHANGED
|
@@ -23,201 +23,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
__setModuleDefault(result, mod);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
|
-
var
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
27
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
const Core = __importStar(require("./core.js"));
|
|
30
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.FinchError = exports.fileFromPath = exports.toFile = void 0;
|
|
30
31
|
const Errors = __importStar(require("./error.js"));
|
|
31
32
|
const Uploads = __importStar(require("./uploads.js"));
|
|
32
|
-
const Pagination = __importStar(require("@tryfinch/finch-api/pagination"));
|
|
33
|
-
const API = __importStar(require("@tryfinch/finch-api/resources/index"));
|
|
34
|
-
/** API Client for interfacing with the Finch API. */
|
|
35
|
-
class Finch extends Core.APIClient {
|
|
36
|
-
/**
|
|
37
|
-
* API Client for interfacing with the Finch API.
|
|
38
|
-
*
|
|
39
|
-
* @param {string | null | undefined} [opts.accessToken]
|
|
40
|
-
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
41
|
-
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
42
|
-
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
43
|
-
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
44
|
-
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
45
|
-
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
46
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
47
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
48
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
49
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
50
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
51
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
52
|
-
*/
|
|
53
|
-
constructor({ baseURL = Core.readEnv('FINCH_BASE_URL'), accessToken = null, clientId = Core.readEnv('FINCH_CLIENT_ID') ?? null, clientSecret = Core.readEnv('FINCH_CLIENT_SECRET') ?? null, sandboxClientId = Core.readEnv('FINCH_SANDBOX_CLIENT_ID') ?? null, sandboxClientSecret = Core.readEnv('FINCH_SANDBOX_CLIENT_SECRET') ?? null, webhookSecret = Core.readEnv('FINCH_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
|
|
54
|
-
const options = {
|
|
55
|
-
accessToken,
|
|
56
|
-
clientId,
|
|
57
|
-
clientSecret,
|
|
58
|
-
sandboxClientId,
|
|
59
|
-
sandboxClientSecret,
|
|
60
|
-
webhookSecret,
|
|
61
|
-
...opts,
|
|
62
|
-
baseURL: baseURL || `https://api.tryfinch.com`,
|
|
63
|
-
};
|
|
64
|
-
super({
|
|
65
|
-
baseURL: options.baseURL,
|
|
66
|
-
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
67
|
-
httpAgent: options.httpAgent,
|
|
68
|
-
maxRetries: options.maxRetries,
|
|
69
|
-
fetch: options.fetch,
|
|
70
|
-
});
|
|
71
|
-
this.accessTokens = new API.AccessTokens(this);
|
|
72
|
-
this.hris = new API.HRIS(this);
|
|
73
|
-
this.providers = new API.Providers(this);
|
|
74
|
-
this.account = new API.Account(this);
|
|
75
|
-
this.webhooks = new API.Webhooks(this);
|
|
76
|
-
this.requestForwarding = new API.RequestForwarding(this);
|
|
77
|
-
this.jobs = new API.Jobs(this);
|
|
78
|
-
this.sandbox = new API.Sandbox(this);
|
|
79
|
-
this._options = options;
|
|
80
|
-
this.accessToken = accessToken;
|
|
81
|
-
this.clientId = clientId;
|
|
82
|
-
this.clientSecret = clientSecret;
|
|
83
|
-
this.sandboxClientId = sandboxClientId;
|
|
84
|
-
this.sandboxClientSecret = sandboxClientSecret;
|
|
85
|
-
this.webhookSecret = webhookSecret;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* DEPRECATED: use client.accessTokens.create instead.
|
|
89
|
-
*/
|
|
90
|
-
getAccessToken(code, options) {
|
|
91
|
-
if (!this.clientId) {
|
|
92
|
-
throw new Error('Expected the clientId to be set in order to call getAccessToken');
|
|
93
|
-
}
|
|
94
|
-
if (!this.clientSecret) {
|
|
95
|
-
throw new Error('Expected the clientSecret to be set in order to call getAccessToken');
|
|
96
|
-
}
|
|
97
|
-
return this.post('/auth/token', {
|
|
98
|
-
body: {
|
|
99
|
-
client_id: this.clientId,
|
|
100
|
-
client_secret: this.clientSecret,
|
|
101
|
-
code: code,
|
|
102
|
-
redirect_uri: options?.redirectUri,
|
|
103
|
-
},
|
|
104
|
-
headers: {
|
|
105
|
-
authorization: null,
|
|
106
|
-
},
|
|
107
|
-
}).then((response) => response.access_token);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns the authorization url which can be visited in order to obtain an
|
|
111
|
-
* authorization code from Finch. The authorization code can then be exchanged for
|
|
112
|
-
* an access token for the Finch api by calling get_access_token().
|
|
113
|
-
*/
|
|
114
|
-
getAuthURL({ products, redirectUri, sandbox, }) {
|
|
115
|
-
if (!this.clientId) {
|
|
116
|
-
throw new Error('Expected the clientId to be set in order to call getAuthUrl');
|
|
117
|
-
}
|
|
118
|
-
const url = new URL('/authorize', 'https://connect.tryfinch.com/authorize');
|
|
119
|
-
url.search = this.stringifyQuery({
|
|
120
|
-
client_id: this.clientId,
|
|
121
|
-
products: products,
|
|
122
|
-
redirect_uri: redirectUri,
|
|
123
|
-
sandbox: sandbox,
|
|
124
|
-
});
|
|
125
|
-
return url.toString();
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns a copy of the current Finch client with the given access token for
|
|
129
|
-
* authentication.
|
|
130
|
-
*/
|
|
131
|
-
withAccessToken(accessToken) {
|
|
132
|
-
return new Finch({ ...this._options, accessToken });
|
|
133
|
-
}
|
|
134
|
-
defaultQuery() {
|
|
135
|
-
return this._options.defaultQuery;
|
|
136
|
-
}
|
|
137
|
-
defaultHeaders(opts) {
|
|
138
|
-
return {
|
|
139
|
-
...super.defaultHeaders(opts),
|
|
140
|
-
'Finch-API-Version': '2020-09-17',
|
|
141
|
-
...this._options.defaultHeaders,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
validateHeaders(headers, customHeaders) {
|
|
145
|
-
if (this.accessToken && headers['authorization']) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (customHeaders['authorization'] === null) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (this.sandboxClientId && this.sandboxClientSecret && headers['authorization']) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (customHeaders['authorization'] === null) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
throw new Error('Could not resolve authentication method. Expected either accessToken, sandboxClientId or sandboxClientSecret to be set. Or for one of the "Authorization" or "Authorization" headers to be explicitly omitted');
|
|
158
|
-
}
|
|
159
|
-
authHeaders(opts) {
|
|
160
|
-
const bearerAuth = this.bearerAuth(opts);
|
|
161
|
-
const basicAuth = this.basicAuth(opts);
|
|
162
|
-
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
163
|
-
return bearerAuth;
|
|
164
|
-
}
|
|
165
|
-
return {};
|
|
166
|
-
}
|
|
167
|
-
bearerAuth(opts) {
|
|
168
|
-
if (this.accessToken == null) {
|
|
169
|
-
return {};
|
|
170
|
-
}
|
|
171
|
-
return { Authorization: `Bearer ${this.accessToken}` };
|
|
172
|
-
}
|
|
173
|
-
basicAuth(opts) {
|
|
174
|
-
if (!this.sandboxClientId) {
|
|
175
|
-
return {};
|
|
176
|
-
}
|
|
177
|
-
if (!this.sandboxClientSecret) {
|
|
178
|
-
return {};
|
|
179
|
-
}
|
|
180
|
-
const credentials = `${this.sandboxClientId}:${this.sandboxClientSecret}`;
|
|
181
|
-
const Authorization = `Basic ${Core.toBase64(credentials)}`;
|
|
182
|
-
return { Authorization };
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
exports.Finch = Finch;
|
|
186
|
-
_a = Finch;
|
|
187
|
-
Finch.Finch = _a;
|
|
188
|
-
Finch.FinchError = Errors.FinchError;
|
|
189
|
-
Finch.APIError = Errors.APIError;
|
|
190
|
-
Finch.APIConnectionError = Errors.APIConnectionError;
|
|
191
|
-
Finch.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
192
|
-
Finch.APIUserAbortError = Errors.APIUserAbortError;
|
|
193
|
-
Finch.NotFoundError = Errors.NotFoundError;
|
|
194
|
-
Finch.ConflictError = Errors.ConflictError;
|
|
195
|
-
Finch.RateLimitError = Errors.RateLimitError;
|
|
196
|
-
Finch.BadRequestError = Errors.BadRequestError;
|
|
197
|
-
Finch.AuthenticationError = Errors.AuthenticationError;
|
|
198
|
-
Finch.InternalServerError = Errors.InternalServerError;
|
|
199
|
-
Finch.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
200
|
-
Finch.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
201
|
-
Finch.toFile = Uploads.toFile;
|
|
202
|
-
Finch.fileFromPath = Uploads.fileFromPath;
|
|
203
|
-
exports.FinchError = Errors.FinchError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
204
33
|
exports.toFile = Uploads.toFile;
|
|
205
34
|
exports.fileFromPath = Uploads.fileFromPath;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
Finch.ResponsesPage = Pagination.ResponsesPage;
|
|
209
|
-
Finch.IndividualsPage = Pagination.IndividualsPage;
|
|
210
|
-
Finch.Page = Pagination.Page;
|
|
211
|
-
Finch.AccessTokens = API.AccessTokens;
|
|
212
|
-
Finch.HRIS = API.HRIS;
|
|
213
|
-
Finch.Providers = API.Providers;
|
|
214
|
-
Finch.ProvidersSinglePage = API.ProvidersSinglePage;
|
|
215
|
-
Finch.Account = API.Account;
|
|
216
|
-
Finch.Webhooks = API.Webhooks;
|
|
217
|
-
Finch.RequestForwarding = API.RequestForwarding;
|
|
218
|
-
Finch.Jobs = API.Jobs;
|
|
219
|
-
Finch.Sandbox = API.Sandbox;
|
|
220
|
-
})(Finch = exports.Finch || (exports.Finch = {}));
|
|
221
|
-
exports = module.exports = Finch;
|
|
222
|
-
exports.default = Finch;
|
|
35
|
+
exports.FinchError = Errors.FinchError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
36
|
+
__exportStar(require("./client.js"), exports);
|
|
223
37
|
//# sourceMappingURL=index.js.map
|