@tryfinch/finch-api 5.14.3 → 5.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +1 -1
  3. package/_shims/index.d.ts +1 -1
  4. package/_shims/registry.d.ts +1 -1
  5. package/_shims/registry.d.ts.map +1 -1
  6. package/core.d.ts +14 -12
  7. package/core.d.ts.map +1 -1
  8. package/core.js +43 -15
  9. package/core.js.map +1 -1
  10. package/core.mjs +43 -15
  11. package/core.mjs.map +1 -1
  12. package/index.d.mts +27 -1
  13. package/index.d.ts +27 -1
  14. package/index.d.ts.map +1 -1
  15. package/index.js +50 -5
  16. package/index.js.map +1 -1
  17. package/index.mjs +50 -5
  18. package/index.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/resources/access-tokens.d.ts +23 -0
  21. package/resources/access-tokens.d.ts.map +1 -0
  22. package/resources/access-tokens.js +17 -0
  23. package/resources/access-tokens.js.map +1 -0
  24. package/resources/access-tokens.mjs +13 -0
  25. package/resources/access-tokens.mjs.map +1 -0
  26. package/resources/account.d.ts +14 -0
  27. package/resources/account.d.ts.map +1 -1
  28. package/resources/account.js.map +1 -1
  29. package/resources/account.mjs.map +1 -1
  30. package/resources/index.d.ts +2 -0
  31. package/resources/index.d.ts.map +1 -1
  32. package/resources/index.js +5 -1
  33. package/resources/index.js.map +1 -1
  34. package/resources/index.mjs +2 -0
  35. package/resources/index.mjs.map +1 -1
  36. package/resources/sandbox/company.d.ts +195 -0
  37. package/resources/sandbox/company.d.ts.map +1 -0
  38. package/resources/sandbox/company.js +17 -0
  39. package/resources/sandbox/company.js.map +1 -0
  40. package/resources/sandbox/company.mjs +13 -0
  41. package/resources/sandbox/company.mjs.map +1 -0
  42. package/resources/sandbox/connections/accounts.d.ts +51 -0
  43. package/resources/sandbox/connections/accounts.d.ts.map +1 -0
  44. package/resources/sandbox/connections/accounts.js +24 -0
  45. package/resources/sandbox/connections/accounts.js.map +1 -0
  46. package/resources/sandbox/connections/accounts.mjs +20 -0
  47. package/resources/sandbox/connections/accounts.mjs.map +1 -0
  48. package/resources/sandbox/connections/connections.d.ts +39 -0
  49. package/resources/sandbox/connections/connections.d.ts.map +1 -0
  50. package/resources/sandbox/connections/connections.js +46 -0
  51. package/resources/sandbox/connections/connections.js.map +1 -0
  52. package/resources/sandbox/connections/connections.mjs +19 -0
  53. package/resources/sandbox/connections/connections.mjs.map +1 -0
  54. package/resources/sandbox/connections/index.d.ts +3 -0
  55. package/resources/sandbox/connections/index.d.ts.map +1 -0
  56. package/resources/sandbox/connections/index.js +9 -0
  57. package/resources/sandbox/connections/index.js.map +1 -0
  58. package/resources/sandbox/connections/index.mjs +4 -0
  59. package/resources/sandbox/connections/index.mjs.map +1 -0
  60. package/resources/sandbox/directory.d.ts +156 -0
  61. package/resources/sandbox/directory.d.ts.map +1 -0
  62. package/resources/sandbox/directory.js +17 -0
  63. package/resources/sandbox/directory.js.map +1 -0
  64. package/resources/sandbox/directory.mjs +13 -0
  65. package/resources/sandbox/directory.mjs.map +1 -0
  66. package/resources/sandbox/employment.d.ts +216 -0
  67. package/resources/sandbox/employment.d.ts.map +1 -0
  68. package/resources/sandbox/employment.js +18 -0
  69. package/resources/sandbox/employment.js.map +1 -0
  70. package/resources/sandbox/employment.mjs +14 -0
  71. package/resources/sandbox/employment.mjs.map +1 -0
  72. package/resources/sandbox/index.d.ts +9 -0
  73. package/resources/sandbox/index.d.ts.map +1 -0
  74. package/resources/sandbox/index.js +21 -0
  75. package/resources/sandbox/index.js.map +1 -0
  76. package/resources/sandbox/index.mjs +10 -0
  77. package/resources/sandbox/index.mjs.map +1 -0
  78. package/resources/sandbox/individual.d.ts +124 -0
  79. package/resources/sandbox/individual.d.ts.map +1 -0
  80. package/resources/sandbox/individual.js +18 -0
  81. package/resources/sandbox/individual.js.map +1 -0
  82. package/resources/sandbox/individual.mjs +14 -0
  83. package/resources/sandbox/individual.mjs.map +1 -0
  84. package/resources/sandbox/jobs/configuration.d.ts +28 -0
  85. package/resources/sandbox/jobs/configuration.d.ts.map +1 -0
  86. package/resources/sandbox/jobs/configuration.js +23 -0
  87. package/resources/sandbox/jobs/configuration.js.map +1 -0
  88. package/resources/sandbox/jobs/configuration.mjs +19 -0
  89. package/resources/sandbox/jobs/configuration.mjs.map +1 -0
  90. package/resources/sandbox/jobs/index.d.ts +3 -0
  91. package/resources/sandbox/jobs/index.d.ts.map +1 -0
  92. package/resources/sandbox/jobs/index.js +9 -0
  93. package/resources/sandbox/jobs/index.js.map +1 -0
  94. package/resources/sandbox/jobs/index.mjs +4 -0
  95. package/resources/sandbox/jobs/index.mjs.map +1 -0
  96. package/resources/sandbox/jobs/jobs.d.ts +12 -0
  97. package/resources/sandbox/jobs/jobs.d.ts.map +1 -0
  98. package/resources/sandbox/jobs/jobs.js +40 -0
  99. package/resources/sandbox/jobs/jobs.js.map +1 -0
  100. package/resources/sandbox/jobs/jobs.mjs +13 -0
  101. package/resources/sandbox/jobs/jobs.mjs.map +1 -0
  102. package/resources/sandbox/payment.d.ts +154 -0
  103. package/resources/sandbox/payment.d.ts.map +1 -0
  104. package/resources/sandbox/payment.js +18 -0
  105. package/resources/sandbox/payment.js.map +1 -0
  106. package/resources/sandbox/payment.mjs +14 -0
  107. package/resources/sandbox/payment.mjs.map +1 -0
  108. package/resources/sandbox/sandbox.d.ts +39 -0
  109. package/resources/sandbox/sandbox.d.ts.map +1 -0
  110. package/resources/sandbox/sandbox.js +58 -0
  111. package/resources/sandbox/sandbox.js.map +1 -0
  112. package/resources/sandbox/sandbox.mjs +31 -0
  113. package/resources/sandbox/sandbox.mjs.map +1 -0
  114. package/resources/shared.d.ts +1 -0
  115. package/resources/shared.d.ts.map +1 -1
  116. package/src/_shims/index.d.ts +1 -1
  117. package/src/_shims/node-runtime.ts +1 -1
  118. package/src/_shims/registry.ts +1 -1
  119. package/src/_shims/web-runtime.ts +1 -1
  120. package/src/core.ts +69 -32
  121. package/src/index.ts +76 -4
  122. package/src/lib/.keep +4 -0
  123. package/src/resources/access-tokens.ts +36 -0
  124. package/src/resources/account.ts +19 -0
  125. package/src/resources/index.ts +2 -0
  126. package/src/resources/sandbox/company.ts +252 -0
  127. package/src/resources/sandbox/connections/accounts.ts +83 -0
  128. package/src/resources/sandbox/connections/connections.ts +58 -0
  129. package/src/resources/sandbox/connections/index.ts +10 -0
  130. package/src/resources/sandbox/directory.ts +210 -0
  131. package/src/resources/sandbox/employment.ts +279 -0
  132. package/src/resources/sandbox/index.ts +10 -0
  133. package/src/resources/sandbox/individual.ts +193 -0
  134. package/src/resources/sandbox/jobs/configuration.ts +44 -0
  135. package/src/resources/sandbox/jobs/index.ts +9 -0
  136. package/src/resources/sandbox/jobs/jobs.ts +15 -0
  137. package/src/resources/sandbox/payment.ts +215 -0
  138. package/src/resources/sandbox/sandbox.ts +42 -0
  139. package/src/resources/shared.ts +8 -0
  140. package/src/uploads.ts +2 -2
  141. package/src/version.ts +1 -1
  142. package/uploads.d.ts +2 -2
  143. package/uploads.d.ts.map +1 -1
  144. package/version.d.ts +1 -1
  145. package/version.js +1 -1
  146. package/version.mjs +1 -1
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.Sandbox = void 0;
28
+ const resource_1 = require("@tryfinch/finch-api/resource");
29
+ const CompanyAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/company"));
30
+ const DirectoryAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/directory"));
31
+ const EmploymentAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/employment"));
32
+ const IndividualAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/individual"));
33
+ const PaymentAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/payment"));
34
+ const ConnectionsAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/connections/connections"));
35
+ const JobsAPI = __importStar(require("@tryfinch/finch-api/resources/sandbox/jobs/jobs"));
36
+ class Sandbox extends resource_1.APIResource {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.connections = new ConnectionsAPI.Connections(this._client);
40
+ this.company = new CompanyAPI.Company(this._client);
41
+ this.directory = new DirectoryAPI.Directory(this._client);
42
+ this.individual = new IndividualAPI.Individual(this._client);
43
+ this.employment = new EmploymentAPI.Employment(this._client);
44
+ this.payment = new PaymentAPI.Payment(this._client);
45
+ this.jobs = new JobsAPI.Jobs(this._client);
46
+ }
47
+ }
48
+ exports.Sandbox = Sandbox;
49
+ (function (Sandbox) {
50
+ Sandbox.Connections = ConnectionsAPI.Connections;
51
+ Sandbox.Company = CompanyAPI.Company;
52
+ Sandbox.Directory = DirectoryAPI.Directory;
53
+ Sandbox.Individual = IndividualAPI.Individual;
54
+ Sandbox.Employment = EmploymentAPI.Employment;
55
+ Sandbox.Payment = PaymentAPI.Payment;
56
+ Sandbox.Jobs = JobsAPI.Jobs;
57
+ })(Sandbox = exports.Sandbox || (exports.Sandbox = {}));
58
+ //# sourceMappingURL=sandbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../src/resources/sandbox/sandbox.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,2DAA2D;AAC3D,0FAA4E;AAC5E,8FAAgF;AAChF,gGAAkF;AAClF,gGAAkF;AAClF,0FAA4E;AAC5E,8GAAgG;AAChG,yFAA2E;AAE3E,MAAa,OAAQ,SAAQ,sBAAW;IAAxC;;QACE,gBAAW,GAA+B,IAAI,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvF,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7E,eAAU,GAA6B,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,eAAU,GAA6B,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;CAAA;AARD,0BAQC;AAED,WAAiB,OAAO;IACR,mBAAW,GAAG,cAAc,CAAC,WAAW,CAAC;IAGzC,eAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAG7B,iBAAS,GAAG,YAAY,CAAC,SAAS,CAAC;IAGnC,kBAAU,GAAG,aAAa,CAAC,UAAU,CAAC;IAGtC,kBAAU,GAAG,aAAa,CAAC,UAAU,CAAC;IAGtC,eAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAG7B,YAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AACpC,CAAC,EApBgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAoBvB"}
@@ -0,0 +1,31 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ import { APIResource } from '@tryfinch/finch-api/resource';
3
+ import * as CompanyAPI from '@tryfinch/finch-api/resources/sandbox/company';
4
+ import * as DirectoryAPI from '@tryfinch/finch-api/resources/sandbox/directory';
5
+ import * as EmploymentAPI from '@tryfinch/finch-api/resources/sandbox/employment';
6
+ import * as IndividualAPI from '@tryfinch/finch-api/resources/sandbox/individual';
7
+ import * as PaymentAPI from '@tryfinch/finch-api/resources/sandbox/payment';
8
+ import * as ConnectionsAPI from '@tryfinch/finch-api/resources/sandbox/connections/connections';
9
+ import * as JobsAPI from '@tryfinch/finch-api/resources/sandbox/jobs/jobs';
10
+ export class Sandbox extends APIResource {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.connections = new ConnectionsAPI.Connections(this._client);
14
+ this.company = new CompanyAPI.Company(this._client);
15
+ this.directory = new DirectoryAPI.Directory(this._client);
16
+ this.individual = new IndividualAPI.Individual(this._client);
17
+ this.employment = new EmploymentAPI.Employment(this._client);
18
+ this.payment = new PaymentAPI.Payment(this._client);
19
+ this.jobs = new JobsAPI.Jobs(this._client);
20
+ }
21
+ }
22
+ (function (Sandbox) {
23
+ Sandbox.Connections = ConnectionsAPI.Connections;
24
+ Sandbox.Company = CompanyAPI.Company;
25
+ Sandbox.Directory = DirectoryAPI.Directory;
26
+ Sandbox.Individual = IndividualAPI.Individual;
27
+ Sandbox.Employment = EmploymentAPI.Employment;
28
+ Sandbox.Payment = PaymentAPI.Payment;
29
+ Sandbox.Jobs = JobsAPI.Jobs;
30
+ })(Sandbox || (Sandbox = {}));
31
+ //# sourceMappingURL=sandbox.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.mjs","sourceRoot":"","sources":["../../src/resources/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAE9C,EAAE,WAAW,EAAE,MAAM,8BAA8B;OACnD,KAAK,UAAU,MAAM,+CAA+C;OACpE,KAAK,YAAY,MAAM,iDAAiD;OACxE,KAAK,aAAa,MAAM,kDAAkD;OAC1E,KAAK,aAAa,MAAM,kDAAkD;OAC1E,KAAK,UAAU,MAAM,+CAA+C;OACpE,KAAK,cAAc,MAAM,+DAA+D;OACxF,KAAK,OAAO,MAAM,iDAAiD;AAE1E,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAAxC;;QACE,gBAAW,GAA+B,IAAI,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvF,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7E,eAAU,GAA6B,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,eAAU,GAA6B,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,SAAI,GAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;CAAA;AAED,WAAiB,OAAO;IACR,mBAAW,GAAG,cAAc,CAAC,WAAW,CAAC;IAGzC,eAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAG7B,iBAAS,GAAG,YAAY,CAAC,SAAS,CAAC;IAGnC,kBAAU,GAAG,aAAa,CAAC,UAAU,CAAC;IAGtC,kBAAU,GAAG,aAAa,CAAC,UAAU,CAAC;IAGtC,eAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAG7B,YAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AACpC,CAAC,EApBgB,OAAO,KAAP,OAAO,QAoBvB"}
@@ -1,3 +1,4 @@
1
+ export type ConnectionStatusType = 'pending' | 'processing' | 'connected' | 'error_no_account_setup' | 'error_permissions' | 'reauth';
1
2
  /**
2
3
  * - `supported`: This operation is supported by both the provider and Finch
3
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,wBAAwB,GACxB,2BAA2B,GAC3B,oBAAoB,CAAC;AAEzB,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAC5B,SAAS,GACT,YAAY,GACZ,WAAW,GACX,wBAAwB,GACxB,mBAAmB,GACnB,QAAQ,CAAC;AAEb;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,wBAAwB,GACxB,2BAA2B,GAC3B,oBAAoB,CAAC;AAEzB,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -65,7 +65,7 @@ export type ReadableStream = SelectType<manual.ReadableStream, auto.ReadableStre
65
65
  // @ts-ignore
66
66
  export const ReadableStream: SelectType<typeof manual.ReadableStream, typeof auto.ReadableStream>;
67
67
 
68
- export function getMultipartRequestOptions<T extends {} = Record<string, unknown>>(
68
+ export function getMultipartRequestOptions<T = Record<string, unknown>>(
69
69
  form: FormData,
70
70
  opts: RequestOptions<T>,
71
71
  ): Promise<RequestOptions<T>>;
@@ -43,7 +43,7 @@ async function fileFromPath(path: string, ...args: any[]): Promise<File> {
43
43
  const defaultHttpAgent: Agent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
44
44
  const defaultHttpsAgent: Agent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
45
45
 
46
- async function getMultipartRequestOptions<T extends {} = Record<string, unknown>>(
46
+ async function getMultipartRequestOptions<T = Record<string, unknown>>(
47
47
  form: fd.FormData,
48
48
  opts: RequestOptions<T>,
49
49
  ): Promise<RequestOptions<T>> {
@@ -13,7 +13,7 @@ export interface Shims {
13
13
  Blob: any;
14
14
  File: any;
15
15
  ReadableStream: any;
16
- getMultipartRequestOptions: <T extends {} = Record<string, unknown>>(
16
+ getMultipartRequestOptions: <T = Record<string, unknown>>(
17
17
  form: Shims['FormData'],
18
18
  opts: RequestOptions<T>,
19
19
  ) => Promise<RequestOptions<T>>;
@@ -84,7 +84,7 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean }
84
84
  }
85
85
  }
86
86
  ),
87
- getMultipartRequestOptions: async <T extends {} = Record<string, unknown>>(
87
+ getMultipartRequestOptions: async <T = Record<string, unknown>>(
88
88
  // @ts-ignore
89
89
  form: FormData,
90
90
  opts: RequestOptions<T>,
package/src/core.ts CHANGED
@@ -208,27 +208,27 @@ export abstract class APIClient {
208
208
  return `stainless-node-retry-${uuid4()}`;
209
209
  }
210
210
 
211
- get<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
211
+ get<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
212
212
  return this.methodRequest('get', path, opts);
213
213
  }
214
214
 
215
- post<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
215
+ post<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
216
216
  return this.methodRequest('post', path, opts);
217
217
  }
218
218
 
219
- patch<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
219
+ patch<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
220
220
  return this.methodRequest('patch', path, opts);
221
221
  }
222
222
 
223
- put<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
223
+ put<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
224
224
  return this.methodRequest('put', path, opts);
225
225
  }
226
226
 
227
- delete<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
227
+ delete<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
228
228
  return this.methodRequest('delete', path, opts);
229
229
  }
230
230
 
231
- private methodRequest<Req extends {}, Rsp>(
231
+ private methodRequest<Req, Rsp>(
232
232
  method: HTTPMethod,
233
233
  path: string,
234
234
  opts?: PromiseOrValue<RequestOptions<Req>>,
@@ -260,9 +260,7 @@ export abstract class APIClient {
260
260
  return null;
261
261
  }
262
262
 
263
- buildRequest<Req extends {}>(
264
- options: FinalRequestOptions<Req>,
265
- ): { req: RequestInit; url: string; timeout: number } {
263
+ buildRequest<Req>(options: FinalRequestOptions<Req>): { req: RequestInit; url: string; timeout: number } {
266
264
  const { method, path, query, headers: headers = {} } = options;
267
265
 
268
266
  const body =
@@ -292,18 +290,7 @@ export abstract class APIClient {
292
290
  headers[this.idempotencyHeader] = options.idempotencyKey;
293
291
  }
294
292
 
295
- const reqHeaders: Record<string, string> = {
296
- ...(contentLength && { 'Content-Length': contentLength }),
297
- ...this.defaultHeaders(options),
298
- ...headers,
299
- };
300
- // let builtin fetch set the Content-Type for multipart bodies
301
- if (isMultipartBody(options.body) && shimsKind !== 'node') {
302
- delete reqHeaders['Content-Type'];
303
- }
304
-
305
- // Strip any headers being explicitly omitted with null
306
- Object.keys(reqHeaders).forEach((key) => reqHeaders[key] === null && delete reqHeaders[key]);
293
+ const reqHeaders = this.buildHeaders({ options, headers, contentLength });
307
294
 
308
295
  const req: RequestInit = {
309
296
  method,
@@ -315,9 +302,35 @@ export abstract class APIClient {
315
302
  signal: options.signal ?? null,
316
303
  };
317
304
 
305
+ return { req, url, timeout };
306
+ }
307
+
308
+ private buildHeaders({
309
+ options,
310
+ headers,
311
+ contentLength,
312
+ }: {
313
+ options: FinalRequestOptions;
314
+ headers: Record<string, string | null | undefined>;
315
+ contentLength: string | null | undefined;
316
+ }): Record<string, string> {
317
+ const reqHeaders: Record<string, string> = {};
318
+ if (contentLength) {
319
+ reqHeaders['content-length'] = contentLength;
320
+ }
321
+
322
+ const defaultHeaders = this.defaultHeaders(options);
323
+ applyHeadersMut(reqHeaders, defaultHeaders);
324
+ applyHeadersMut(reqHeaders, headers);
325
+
326
+ // let builtin fetch set the Content-Type for multipart bodies
327
+ if (isMultipartBody(options.body) && shimsKind !== 'node') {
328
+ delete reqHeaders['content-type'];
329
+ }
330
+
318
331
  this.validateHeaders(reqHeaders, headers);
319
332
 
320
- return { req, url, timeout };
333
+ return reqHeaders;
321
334
  }
322
335
 
323
336
  /**
@@ -349,15 +362,15 @@ export abstract class APIClient {
349
362
  return APIError.generate(status, error, message, headers);
350
363
  }
351
364
 
352
- request<Req extends {}, Rsp>(
365
+ request<Req, Rsp>(
353
366
  options: PromiseOrValue<FinalRequestOptions<Req>>,
354
367
  remainingRetries: number | null = null,
355
368
  ): APIPromise<Rsp> {
356
369
  return new APIPromise(this.makeRequest(options, remainingRetries));
357
370
  }
358
371
 
359
- private async makeRequest(
360
- optionsInput: PromiseOrValue<FinalRequestOptions>,
372
+ private async makeRequest<Req>(
373
+ optionsInput: PromiseOrValue<FinalRequestOptions<Req>>,
361
374
  retriesRemaining: number | null,
362
375
  ): Promise<APIResponseProps> {
363
376
  const options = await optionsInput;
@@ -419,7 +432,7 @@ export abstract class APIClient {
419
432
  return new PagePromise<PageClass, Item>(this, request, Page);
420
433
  }
421
434
 
422
- buildURL<Req extends Record<string, unknown>>(path: string, query: Req | null | undefined): string {
435
+ buildURL<Req>(path: string, query: Req | null | undefined): string {
423
436
  const url =
424
437
  isAbsoluteURL(path) ?
425
438
  new URL(path)
@@ -593,7 +606,7 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
593
606
  );
594
607
  }
595
608
  const nextOptions = { ...this.options };
596
- if ('params' in nextInfo) {
609
+ if ('params' in nextInfo && typeof nextOptions.query === 'object') {
597
610
  nextOptions.query = { ...nextOptions.query, ...nextInfo.params };
598
611
  } else if ('url' in nextInfo) {
599
612
  const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()];
@@ -691,7 +704,7 @@ export type Headers = Record<string, string | null | undefined>;
691
704
  export type DefaultQuery = Record<string, string | undefined>;
692
705
  export type KeysEnum<T> = { [P in keyof Required<T>]: true };
693
706
 
694
- export type RequestOptions<Req extends {} = Record<string, unknown> | Readable> = {
707
+ export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> = {
695
708
  method?: HTTPMethod;
696
709
  path?: string;
697
710
  query?: Req | undefined;
@@ -728,7 +741,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
728
741
  __binaryResponse: true,
729
742
  };
730
743
 
731
- export const isRequestOptions = (obj: unknown): obj is RequestOptions<Record<string, unknown> | Readable> => {
744
+ export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
732
745
  return (
733
746
  typeof obj === 'object' &&
734
747
  obj !== null &&
@@ -737,7 +750,7 @@ export const isRequestOptions = (obj: unknown): obj is RequestOptions<Record<str
737
750
  );
738
751
  };
739
752
 
740
- export type FinalRequestOptions<Req extends {} = Record<string, unknown> | Readable> = RequestOptions<Req> & {
753
+ export type FinalRequestOptions<Req = unknown | Record<string, unknown> | Readable> = RequestOptions<Req> & {
741
754
  method: HTTPMethod;
742
755
  path: string;
743
756
  };
@@ -939,14 +952,16 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
939
952
  /**
940
953
  * Read an environment variable.
941
954
  *
955
+ * Trims beginning and trailing whitespace.
956
+ *
942
957
  * Will return undefined if the environment variable doesn't exist or cannot be accessed.
943
958
  */
944
959
  export const readEnv = (env: string): string | undefined => {
945
960
  if (typeof process !== 'undefined') {
946
- return process.env?.[env] ?? undefined;
961
+ return process.env?.[env]?.trim() ?? undefined;
947
962
  }
948
963
  if (typeof Deno !== 'undefined') {
949
- return Deno.env?.get?.(env);
964
+ return Deno.env?.get?.(env)?.trim();
950
965
  }
951
966
  return undefined;
952
967
  };
@@ -1004,6 +1019,28 @@ export function hasOwn(obj: Object, key: string): boolean {
1004
1019
  return Object.prototype.hasOwnProperty.call(obj, key);
1005
1020
  }
1006
1021
 
1022
+ /**
1023
+ * Copies headers from "newHeaders" onto "targetHeaders",
1024
+ * using lower-case for all properties,
1025
+ * ignoring any keys with undefined values,
1026
+ * and deleting any keys with null values.
1027
+ */
1028
+ function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void {
1029
+ for (const k in newHeaders) {
1030
+ if (!hasOwn(newHeaders, k)) continue;
1031
+ const lowerKey = k.toLowerCase();
1032
+ if (!lowerKey) continue;
1033
+
1034
+ const val = newHeaders[k];
1035
+
1036
+ if (val === null) {
1037
+ delete targetHeaders[lowerKey];
1038
+ } else if (val !== undefined) {
1039
+ targetHeaders[lowerKey] = val;
1040
+ }
1041
+ }
1042
+ }
1043
+
1007
1044
  export function debug(action: string, ...args: any[]) {
1008
1045
  if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') {
1009
1046
  console.log(`Finch:DEBUG:${action}`, ...args);
package/src/index.ts CHANGED
@@ -20,6 +20,16 @@ export interface ClientOptions {
20
20
  */
21
21
  clientSecret?: string | null;
22
22
 
23
+ /**
24
+ * Defaults to process.env['FINCH_SANDBOX_CLIENT_ID'].
25
+ */
26
+ sandboxClientId?: string | null;
27
+
28
+ /**
29
+ * Defaults to process.env['FINCH_SANDBOX_CLIENT_SECRET'].
30
+ */
31
+ sandboxClientSecret?: string | null;
32
+
23
33
  /**
24
34
  * Defaults to process.env['FINCH_WEBHOOK_SECRET'].
25
35
  */
@@ -87,6 +97,8 @@ export class Finch extends Core.APIClient {
87
97
  accessToken: string | null;
88
98
  clientId: string | null;
89
99
  clientSecret: string | null;
100
+ sandboxClientId: string | null;
101
+ sandboxClientSecret: string | null;
90
102
  webhookSecret: string | null;
91
103
 
92
104
  private _options: ClientOptions;
@@ -97,6 +109,8 @@ export class Finch extends Core.APIClient {
97
109
  * @param {string | null} [opts.accessToken]
98
110
  * @param {string | null} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
99
111
  * @param {string | null} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
112
+ * @param {string | null} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
113
+ * @param {string | null} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
100
114
  * @param {string | null} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
101
115
  * @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
102
116
  * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
@@ -111,6 +125,8 @@ export class Finch extends Core.APIClient {
111
125
  accessToken = null,
112
126
  clientId = Core.readEnv('FINCH_CLIENT_ID') ?? null,
113
127
  clientSecret = Core.readEnv('FINCH_CLIENT_SECRET') ?? null,
128
+ sandboxClientId = Core.readEnv('FINCH_SANDBOX_CLIENT_ID') ?? null,
129
+ sandboxClientSecret = Core.readEnv('FINCH_SANDBOX_CLIENT_SECRET') ?? null,
114
130
  webhookSecret = Core.readEnv('FINCH_WEBHOOK_SECRET') ?? null,
115
131
  ...opts
116
132
  }: ClientOptions = {}) {
@@ -118,9 +134,11 @@ export class Finch extends Core.APIClient {
118
134
  accessToken,
119
135
  clientId,
120
136
  clientSecret,
137
+ sandboxClientId,
138
+ sandboxClientSecret,
121
139
  webhookSecret,
122
140
  ...opts,
123
- baseURL: baseURL ?? `https://api.tryfinch.com`,
141
+ baseURL: baseURL || `https://api.tryfinch.com`,
124
142
  };
125
143
 
126
144
  super({
@@ -135,15 +153,19 @@ export class Finch extends Core.APIClient {
135
153
  this.accessToken = accessToken;
136
154
  this.clientId = clientId;
137
155
  this.clientSecret = clientSecret;
156
+ this.sandboxClientId = sandboxClientId;
157
+ this.sandboxClientSecret = sandboxClientSecret;
138
158
  this.webhookSecret = webhookSecret;
139
159
  }
140
160
 
161
+ accessTokens: API.AccessTokens = new API.AccessTokens(this);
141
162
  hris: API.HRIS = new API.HRIS(this);
142
163
  providers: API.Providers = new API.Providers(this);
143
164
  account: API.Account = new API.Account(this);
144
165
  webhooks: API.Webhooks = new API.Webhooks(this);
145
166
  requestForwarding: API.RequestForwarding = new API.RequestForwarding(this);
146
167
  jobs: API.Jobs = new API.Jobs(this);
168
+ sandbox: API.Sandbox = new API.Sandbox(this);
147
169
 
148
170
  /**
149
171
  * Returns an access token for the Finch API given an authorization code. An
@@ -196,6 +218,14 @@ export class Finch extends Core.APIClient {
196
218
  return url.toString();
197
219
  }
198
220
 
221
+ /**
222
+ * Returns a copy of the current Finch client with the given access token for
223
+ * authentication.
224
+ */
225
+ withAccessToken(accessToken: string): Finch {
226
+ return new Finch({ ...this._options, accessToken });
227
+ }
228
+
199
229
  protected override defaultQuery(): Core.DefaultQuery | undefined {
200
230
  return this._options.defaultQuery;
201
231
  }
@@ -209,25 +239,60 @@ export class Finch extends Core.APIClient {
209
239
  }
210
240
 
211
241
  protected override validateHeaders(headers: Core.Headers, customHeaders: Core.Headers) {
212
- if (this.accessToken && headers['Authorization']) {
242
+ if (this.accessToken && headers['authorization']) {
243
+ return;
244
+ }
245
+ if (customHeaders['authorization'] === null) {
213
246
  return;
214
247
  }
215
- if (customHeaders['Authorization'] === null) {
248
+
249
+ if (this.sandboxClientId && this.sandboxClientSecret && headers['authorization']) {
250
+ return;
251
+ }
252
+ if (customHeaders['authorization'] === null) {
216
253
  return;
217
254
  }
218
255
 
219
256
  throw new Error(
220
- 'Could not resolve authentication method. Expected the accessToken to be set. Or for the "Authorization" headers to be explicitly omitted',
257
+ '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',
221
258
  );
222
259
  }
223
260
 
224
261
  protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
262
+ const bearerAuth = this.bearerAuth(opts);
263
+ const basicAuth = this.basicAuth(opts);
264
+
265
+ if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
266
+ return bearerAuth;
267
+ }
268
+
269
+ if (basicAuth != null && !Core.isEmptyObj(basicAuth)) {
270
+ return basicAuth;
271
+ }
272
+ return {};
273
+ }
274
+
275
+ protected bearerAuth(opts: Core.FinalRequestOptions): Core.Headers {
225
276
  if (this.accessToken == null) {
226
277
  return {};
227
278
  }
228
279
  return { Authorization: `Bearer ${this.accessToken}` };
229
280
  }
230
281
 
282
+ protected basicAuth(opts: Core.FinalRequestOptions): Core.Headers {
283
+ if (!this.sandboxClientId) {
284
+ return {};
285
+ }
286
+
287
+ if (!this.sandboxClientSecret) {
288
+ return {};
289
+ }
290
+
291
+ const credentials = `${this.sandboxClientId}:${this.sandboxClientSecret}`;
292
+ const Authorization = `Basic ${Core.toBase64(credentials)}`;
293
+ return { Authorization };
294
+ }
295
+
231
296
  static Finch = this;
232
297
 
233
298
  static FinchError = Errors.FinchError;
@@ -285,6 +350,10 @@ export namespace Finch {
285
350
  export import PageParams = Pagination.PageParams;
286
351
  export import PageResponse = Pagination.PageResponse;
287
352
 
353
+ export import AccessTokens = API.AccessTokens;
354
+ export import CreateAccessTokenResponse = API.CreateAccessTokenResponse;
355
+ export import AccessTokenCreateParams = API.AccessTokenCreateParams;
356
+
288
357
  export import HRIS = API.HRIS;
289
358
  export import Income = API.Income;
290
359
  export import Location = API.Location;
@@ -306,6 +375,9 @@ export namespace Finch {
306
375
 
307
376
  export import Jobs = API.Jobs;
308
377
 
378
+ export import Sandbox = API.Sandbox;
379
+
380
+ export import ConnectionStatusType = API.ConnectionStatusType;
309
381
  export import OperationSupport = API.OperationSupport;
310
382
  export import OperationSupportMatrix = API.OperationSupportMatrix;
311
383
  export import Paging = API.Paging;
package/src/lib/.keep ADDED
@@ -0,0 +1,4 @@
1
+ File generated from our OpenAPI spec by Stainless.
2
+
3
+ This directory can be used to store custom files to expand the SDK.
4
+ It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
@@ -0,0 +1,36 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ import * as Core from "../core";
4
+ import { APIResource } from "../resource";
5
+ import * as AccessTokensAPI from "./access-tokens";
6
+
7
+ export class AccessTokens extends APIResource {
8
+ /**
9
+ * Exchange the authorization code for an access token
10
+ */
11
+ create(
12
+ body: AccessTokenCreateParams,
13
+ options?: Core.RequestOptions,
14
+ ): Core.APIPromise<CreateAccessTokenResponse> {
15
+ return this._client.post('/auth/token', { body, ...options });
16
+ }
17
+ }
18
+
19
+ export interface CreateAccessTokenResponse {
20
+ access_token: string;
21
+ }
22
+
23
+ export interface AccessTokenCreateParams {
24
+ client_id: string;
25
+
26
+ client_secret: string;
27
+
28
+ code: string;
29
+
30
+ redirect_uri: string;
31
+ }
32
+
33
+ export namespace AccessTokens {
34
+ export import CreateAccessTokenResponse = AccessTokensAPI.CreateAccessTokenResponse;
35
+ export import AccessTokenCreateParams = AccessTokensAPI.AccessTokenCreateParams;
36
+ }
@@ -3,6 +3,7 @@
3
3
  import * as Core from "../core";
4
4
  import { APIResource } from "../resource";
5
5
  import * as AccountAPI from "./account";
6
+ import * as Shared from "./shared";
6
7
 
7
8
  export class Account extends APIResource {
8
9
  /**
@@ -35,6 +36,8 @@ export interface Introspection {
35
36
  */
36
37
  account_id: string;
37
38
 
39
+ authentication_methods: Introspection.AuthenticationMethods;
40
+
38
41
  /**
39
42
  * The client id of the application associated with the `access_token`.
40
43
  */
@@ -82,6 +85,22 @@ export interface Introspection {
82
85
  username: string;
83
86
  }
84
87
 
88
+ export namespace Introspection {
89
+ export interface AuthenticationMethods {
90
+ connection_status?: AuthenticationMethods.ConnectionStatus;
91
+
92
+ type?: string;
93
+ }
94
+
95
+ export namespace AuthenticationMethods {
96
+ export interface ConnectionStatus {
97
+ message?: string;
98
+
99
+ status?: Shared.ConnectionStatusType;
100
+ }
101
+ }
102
+ }
103
+
85
104
  export namespace Account {
86
105
  export import DisconnectResponse = AccountAPI.DisconnectResponse;
87
106
  export import Introspection = AccountAPI.Introspection;
@@ -1,6 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
3
  export * from './shared';
4
+ export { CreateAccessTokenResponse, AccessTokenCreateParams, AccessTokens } from './access-tokens';
4
5
  export { DisconnectResponse, Introspection, Account } from './account';
5
6
  export { Income, Location, Money, HRIS } from './hris/hris';
6
7
  export { Jobs } from './jobs/jobs';
@@ -10,4 +11,5 @@ export {
10
11
  RequestForwardingForwardParams,
11
12
  RequestForwarding,
12
13
  } from './request-forwarding';
14
+ export { Sandbox } from './sandbox/sandbox';
13
15
  export { Webhooks } from './webhooks';