@basis-theory/basis-theory-js 1.75.0 → 1.77.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 (54) hide show
  1. package/BasisTheory.d.ts +9 -0
  2. package/BasisTheory.js +33 -0
  3. package/README.md +15 -2
  4. package/applications/BasisTheoryApplications.d.ts +5 -5
  5. package/common/BasisTheoryClient.d.ts +9 -0
  6. package/common/BasisTheoryClient.js +65 -0
  7. package/common/HttpClientError.d.ts +6 -0
  8. package/common/HttpClientError.js +45 -0
  9. package/common/constants.d.ts +2 -1
  10. package/common/constants.js +5 -2
  11. package/common/index.d.ts +1 -0
  12. package/common/index.js +11 -2
  13. package/common/utils.d.ts +4 -3
  14. package/common/utils.js +5 -0
  15. package/elements/load.d.ts +1 -1
  16. package/elements/services/proxy.d.ts +1 -1
  17. package/elements/services/tokenize.d.ts +1 -1
  18. package/elements/services/tokens.d.ts +1 -1
  19. package/logs/BasisTheoryLogs.d.ts +1 -1
  20. package/package.json +1 -1
  21. package/reactor-formulas/BasisTheoryReactorFormulas.d.ts +3 -3
  22. package/reactors/BasisTheoryReactors.d.ts +2 -2
  23. package/service/CrudBuilder.d.ts +6 -6
  24. package/service/types.d.ts +1 -1
  25. package/tenants/BasisTheoryTenants.d.ts +12 -12
  26. package/tokens/BasisTheoryTokens.d.ts +6 -6
  27. package/transactions/BasisTheoryTransactions.d.ts +10 -0
  28. package/transactions/BasisTheoryTransactions.js +41 -0
  29. package/transactions/index.d.ts +1 -0
  30. package/transactions/index.js +18 -0
  31. package/types/elements/elements.d.ts +16 -7
  32. package/types/elements/events.d.ts +15 -15
  33. package/types/elements/options.d.ts +15 -15
  34. package/types/elements/services/tokenize.d.ts +1 -1
  35. package/types/elements/services/tokens.d.ts +3 -3
  36. package/types/elements/shared.d.ts +7 -7
  37. package/types/elements/styles.d.ts +11 -11
  38. package/types/models/applications.d.ts +5 -5
  39. package/types/models/proxies.d.ts +2 -2
  40. package/types/models/reactor-formulas.d.ts +3 -3
  41. package/types/models/reactors.d.ts +2 -2
  42. package/types/models/shared.d.ts +2 -2
  43. package/types/models/tenants.d.ts +2 -2
  44. package/types/models/tokenize.d.ts +3 -3
  45. package/types/models/tokens.d.ts +11 -11
  46. package/types/sdk/sdk.d.ts +5 -3
  47. package/types/sdk/services/index.d.ts +1 -0
  48. package/types/sdk/services/index.js +13 -0
  49. package/types/sdk/services/logs.d.ts +1 -1
  50. package/types/sdk/services/proxy.d.ts +4 -4
  51. package/types/sdk/services/sessions.d.ts +2 -2
  52. package/types/sdk/services/shared.d.ts +7 -6
  53. package/types/sdk/services/transactions.d.ts +13 -0
  54. package/types/sdk/services/transactions.js +1 -0
package/BasisTheory.d.ts CHANGED
@@ -1,6 +1,8 @@
1
+ import { Config } from './common/BasisTheoryClient';
1
2
  import type { BasisTheoryElements, CardElement, CardNumberElement, CardExpirationDateElement, CardVerificationCodeElement, CreateCardElementOptions, CreateCardNumberElementOptions, CreateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, TextElement, TokenizeData as ElementsTokenizeData, Tokens as ElementsTokens } from './types/elements';
2
3
  import type { TokenizeData } from './types/models';
3
4
  import type { Applications, BasisTheory as IBasisTheory, BasisTheoryInit, Logs, Permissions, ReactorFormulas, Reactors, RequestOptions, Tenants, Tokens, BasisTheoryInitOptions, BasisTheoryInitOptionsWithElements, BasisTheoryInitOptionsWithoutElements, Proxies, Proxy, Sessions } from './types/sdk';
5
+ import { Transactions } from './types/sdk/services/transactions';
4
6
  export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, BasisTheoryElements {
5
7
  private _initStatus;
6
8
  private _initOptions?;
@@ -16,6 +18,7 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
16
18
  private _proxies?;
17
19
  private _proxy?;
18
20
  private _sessions?;
21
+ private _transactions?;
19
22
  init(apiKey: string | undefined, options?: BasisTheoryInitOptionsWithoutElements): Promise<IBasisTheory>;
20
23
  init(apiKey: string | undefined, options: BasisTheoryInitOptionsWithElements): Promise<IBasisTheory & BasisTheoryElements>;
21
24
  createElement(type: 'card', options?: CreateCardElementOptions): CardElement;
@@ -24,6 +27,11 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
24
27
  createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): CardExpirationDateElement;
25
28
  createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): CardVerificationCodeElement;
26
29
  tokenize(tokens: TokenizeData & ElementsTokenizeData, options?: RequestOptions): Promise<TokenizeData>;
30
+ post(url: string, payload: unknown, config?: Config): Promise<unknown>;
31
+ put(url: string, payload: unknown, config?: Config): Promise<unknown>;
32
+ patch(url: string, payload: unknown, config?: Config): Promise<unknown>;
33
+ get(url: string, config?: Config): Promise<unknown>;
34
+ delete(url: string, config?: Config): Promise<unknown>;
27
35
  private loadElements;
28
36
  get initOptions(): Required<BasisTheoryInitOptions>;
29
37
  get tokens(): Tokens & ElementsTokens;
@@ -36,6 +44,7 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
36
44
  get proxies(): Proxies;
37
45
  get proxy(): Proxy;
38
46
  get sessions(): Sessions;
47
+ get transactions(): Transactions;
39
48
  /**
40
49
  * @deprecated
41
50
  */
package/BasisTheory.js CHANGED
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BasisTheory = void 0;
7
7
 
8
+ var _BasisTheoryClient = require("./common/BasisTheoryClient");
9
+
10
+ var _transactions = require("./transactions");
11
+
8
12
  var _applications = require("./applications");
9
13
 
10
14
  var _common = require("./common");
@@ -128,6 +132,11 @@ class BasisTheory {
128
132
  baseURL: new URL(_common.CLIENT_BASE_PATHS.sessions, baseUrl).toString(),
129
133
  appInfo
130
134
  });
135
+ this._transactions = new _transactions.BasisTheoryTransactions({
136
+ apiKey,
137
+ baseURL: new URL(_common.CLIENT_BASE_PATHS.transactions, baseUrl).toString(),
138
+ appInfo
139
+ });
131
140
  this._initStatus = 'done';
132
141
  } catch (error) {
133
142
  this._initStatus = 'error';
@@ -149,6 +158,26 @@ class BasisTheory {
149
158
  return (0, _common.assertInit)(this._tokenize).tokenize(tokens, options);
150
159
  }
151
160
 
161
+ post(url, payload, config) {
162
+ return (0, _BasisTheoryClient.makeRequestWithElementsPayloadCheck)(this._elements, 'post', url, payload, config);
163
+ }
164
+
165
+ put(url, payload, config) {
166
+ return (0, _BasisTheoryClient.makeRequestWithElementsPayloadCheck)(this._elements, 'put', url, payload, config);
167
+ }
168
+
169
+ patch(url, payload, config) {
170
+ return (0, _BasisTheoryClient.makeRequestWithElementsPayloadCheck)(this._elements, 'patch', url, payload, config);
171
+ }
172
+
173
+ get(url, config) {
174
+ return (0, _BasisTheoryClient.makeRequestWithoutElementsPayloadCheck)(this._elements, 'get', url, config);
175
+ }
176
+
177
+ delete(url, config) {
178
+ return (0, _BasisTheoryClient.makeRequestWithoutElementsPayloadCheck)(this._elements, 'delete', url, config);
179
+ }
180
+
152
181
  async loadElements(apiKey) {
153
182
  let elementsBaseUrl;
154
183
 
@@ -209,6 +238,10 @@ class BasisTheory {
209
238
  get sessions() {
210
239
  return (0, _common.assertInit)(this._sessions);
211
240
  }
241
+
242
+ get transactions() {
243
+ return (0, _common.assertInit)(this._transactions);
244
+ }
212
245
  /* eslint-enable accessor-pairs */
213
246
 
214
247
  /**
package/README.md CHANGED
@@ -36,8 +36,8 @@ const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED'); // replac
36
36
 
37
37
  ### Per-request configuration
38
38
 
39
- All of the service methods accept an optional `RequestOptions` object. This is used if you want to set a per-request `BT-TRACE-ID`, `BT-API-KEY` and/or
40
- `BT-IDEMPOTENCY-KEY`.
39
+ All of the service methods accept an optional `RequestOptions` object. This is used if you want to set a per-request `BT-TRACE-ID`, `BT-API-KEY`, `BT-IDEMPOTENCY-KEY`
40
+ and/or `BT-TRANSACTION-ID`.
41
41
 
42
42
  ```javascript
43
43
  import { v4 as uuid } from 'uuid';
@@ -50,6 +50,19 @@ await bt.applications.list(
50
50
  idempotencyKey: 'bb5d3379-6385-4ef4-9fdb-ca1341572154',
51
51
  }
52
52
  );
53
+
54
+ await bt.tokens.create(
55
+ {
56
+ type: "token",
57
+ data: "Sensitive Value",
58
+ },
59
+ {
60
+ apiKey: 'key_N88mVGsp3sCXkykyN2EFED',
61
+ correlationId: 'aa5d3379-6385-4ef4-9fdb-ca1341572153',
62
+ idempotencyKey: 'bb5d3379-6385-4ef4-9fdb-ca1341572154',
63
+ transactionId: 'cc5d3379-3921-4ef4-9fdb-ca1341572169',
64
+ }
65
+ );
53
66
  ```
54
67
 
55
68
  ### Setting a custom API Url
@@ -1,4 +1,4 @@
1
- import type { Application } from '../types/models';
1
+ import type { Application, CreateApplication, UpdateApplication } from '../types/models';
2
2
  import type { ListApplicationsQuery, RequestOptions } from '../types/sdk';
3
3
  export declare const BasisTheoryApplications: {
4
4
  new (options: import("../service/types").BasisTheoryServiceOptions): {
@@ -6,9 +6,9 @@ export declare const BasisTheoryApplications: {
6
6
  * @deprecated use {@link retrieveByKey} instead
7
7
  */
8
8
  getApplicationByKey(): Promise<Application>;
9
- retrieveByKey(options?: RequestOptions | undefined): Promise<Application>;
10
- regenerateKey(id: string, options?: RequestOptions | undefined): Promise<Application>;
9
+ retrieveByKey(options?: RequestOptions): Promise<Application>;
10
+ regenerateKey(id: string, options?: RequestOptions): Promise<Application>;
11
11
  readonly client: import("axios").AxiosInstance;
12
12
  };
13
- } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Application, Pick<Application, "type" | "expiresAt" | "name" | "permissions" | "rules">>) & (new (...args: any[]) => import("../types/sdk/services/shared").Retrieve<Application>) & (new (...args: any[]) => import("../types/sdk/services/shared").Update<Application, Pick<Application, "name" | "permissions" | "rules">>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Application, ListApplicationsQuery>);
14
- export declare type BasisTheoryApplications = InstanceType<typeof BasisTheoryApplications>;
13
+ } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Application, CreateApplication>) & (new (...args: any[]) => import("../types/sdk/services/shared").Retrieve<Application>) & (new (...args: any[]) => import("../types/sdk/services/shared").Update<Application, UpdateApplication>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Application, ListApplicationsQuery>);
14
+ export type BasisTheoryApplications = InstanceType<typeof BasisTheoryApplications>;
@@ -0,0 +1,9 @@
1
+ import type { BasisTheoryElementsInternal } from '../types/elements';
2
+ type Config = {
3
+ headers?: Record<string, string>;
4
+ };
5
+ type MethodWithPayloads = 'post' | 'put' | 'patch';
6
+ type MethodWithoutPayloads = 'get' | 'delete';
7
+ declare const makeRequestWithElementsPayloadCheck: (elements: BasisTheoryElementsInternal | undefined, method: MethodWithPayloads, url: string, payload: unknown, config?: Config) => Promise<unknown>;
8
+ declare const makeRequestWithoutElementsPayloadCheck: (elements: BasisTheoryElementsInternal | undefined, method: MethodWithoutPayloads, url: string, config?: Config) => Promise<unknown>;
9
+ export { Config, makeRequestWithElementsPayloadCheck, makeRequestWithoutElementsPayloadCheck, };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.makeRequestWithoutElementsPayloadCheck = exports.makeRequestWithElementsPayloadCheck = void 0;
7
+
8
+ function _extendableBuiltin(cls) {
9
+ function ExtendableBuiltin() {
10
+ var instance = Reflect.construct(cls, Array.from(arguments));
11
+ Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
12
+ return instance;
13
+ }
14
+
15
+ ExtendableBuiltin.prototype = Object.create(cls.prototype, {
16
+ constructor: {
17
+ value: cls,
18
+ enumerable: false,
19
+ writable: true,
20
+ configurable: true
21
+ }
22
+ });
23
+
24
+ if (Object.setPrototypeOf) {
25
+ Object.setPrototypeOf(ExtendableBuiltin, cls);
26
+ } else {
27
+ ExtendableBuiltin.__proto__ = cls;
28
+ }
29
+
30
+ return ExtendableBuiltin;
31
+ }
32
+
33
+ class NoElementsError extends _extendableBuiltin(Error) {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = 'NoElementsError';
37
+ }
38
+
39
+ }
40
+
41
+ const makeRequestWithElementsPayloadCheck = (elements, method, url, payload, config = {}) => {
42
+ if (elements !== null && elements !== void 0 && elements.hasElement(payload)) {
43
+ return elements.client[method](url, payload, config);
44
+ }
45
+
46
+ let errorMessageStart = 'Elements not initialized.';
47
+
48
+ if (elements) {
49
+ errorMessageStart = 'Element not found in payload.';
50
+ }
51
+
52
+ throw new NoElementsError(`${errorMessageStart} Use a regular HTTP client if no elements are needed.`);
53
+ };
54
+
55
+ exports.makeRequestWithElementsPayloadCheck = makeRequestWithElementsPayloadCheck;
56
+
57
+ const makeRequestWithoutElementsPayloadCheck = (elements, method, url, config = {}) => {
58
+ if (elements) {
59
+ return elements.client[method](url, config);
60
+ }
61
+
62
+ throw new NoElementsError('Elements not initialized. Use a regular HTTP client if no elements are needed.');
63
+ };
64
+
65
+ exports.makeRequestWithoutElementsPayloadCheck = makeRequestWithoutElementsPayloadCheck;
@@ -0,0 +1,6 @@
1
+ export declare class HttpClientError extends Error {
2
+ readonly status: number;
3
+ readonly data?: unknown;
4
+ readonly headers?: unknown;
5
+ constructor(message: string, status: number, data?: unknown, headers?: unknown);
6
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.HttpClientError = void 0;
7
+
8
+ function _extendableBuiltin(cls) {
9
+ function ExtendableBuiltin() {
10
+ var instance = Reflect.construct(cls, Array.from(arguments));
11
+ Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
12
+ return instance;
13
+ }
14
+
15
+ ExtendableBuiltin.prototype = Object.create(cls.prototype, {
16
+ constructor: {
17
+ value: cls,
18
+ enumerable: false,
19
+ writable: true,
20
+ configurable: true
21
+ }
22
+ });
23
+
24
+ if (Object.setPrototypeOf) {
25
+ Object.setPrototypeOf(ExtendableBuiltin, cls);
26
+ } else {
27
+ ExtendableBuiltin.__proto__ = cls;
28
+ }
29
+
30
+ return ExtendableBuiltin;
31
+ }
32
+
33
+ class HttpClientError extends _extendableBuiltin(Error) {
34
+ constructor(message, status, data, headers) {
35
+ super(message);
36
+ this.name = 'HttpClientError';
37
+ this.status = status;
38
+ this.data = data;
39
+ this.headers = headers;
40
+ Object.setPrototypeOf(this, HttpClientError.prototype);
41
+ }
42
+
43
+ }
44
+
45
+ exports.HttpClientError = HttpClientError;
@@ -3,6 +3,7 @@ declare const API_KEY_HEADER = "BT-API-KEY";
3
3
  declare const BT_TRACE_ID_HEADER = "bt-trace-id";
4
4
  declare const BT_IDEMPOTENCY_KEY_HEADER = "bt-idempotency-key";
5
5
  declare const BT_EXPOSE_PROXY_RESPONSE_HEADER = "BT-EXPOSE-RAW-PROXY-RESPONSE";
6
+ declare const BT_TRANSACTION_ID_HEADER = "BT-TRANSACTION-ID";
6
7
  declare const CONTENT_TYPE_HEADER = "Content-Type";
7
8
  declare const USER_AGENT_HEADER = "User-Agent";
8
9
  declare const CLIENT_USER_AGENT_HEADER = "BT-CLIENT-USER-AGENT";
@@ -14,4 +15,4 @@ declare const BROWSER_LIST: {
14
15
  browserName: string;
15
16
  browserUA: string;
16
17
  }[];
17
- export { API_KEY_HEADER, BT_TRACE_ID_HEADER, BT_IDEMPOTENCY_KEY_HEADER, CONTENT_TYPE_HEADER, USER_AGENT_HEADER, CLIENT_USER_AGENT_HEADER, USER_AGENT_CLIENT, BT_EXPOSE_PROXY_RESPONSE_HEADER, DEFAULT_BASE_URL, DEFAULT_ELEMENTS_BASE_URL, CLIENT_BASE_PATHS, BROWSER_LIST, };
18
+ export { API_KEY_HEADER, BT_TRACE_ID_HEADER, BT_IDEMPOTENCY_KEY_HEADER, CONTENT_TYPE_HEADER, USER_AGENT_HEADER, CLIENT_USER_AGENT_HEADER, USER_AGENT_CLIENT, BT_EXPOSE_PROXY_RESPONSE_HEADER, DEFAULT_BASE_URL, DEFAULT_ELEMENTS_BASE_URL, CLIENT_BASE_PATHS, BROWSER_LIST, BT_TRANSACTION_ID_HEADER, };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.USER_AGENT_HEADER = exports.USER_AGENT_CLIENT = exports.DEFAULT_ELEMENTS_BASE_URL = exports.DEFAULT_BASE_URL = exports.CONTENT_TYPE_HEADER = exports.CLIENT_USER_AGENT_HEADER = exports.CLIENT_BASE_PATHS = exports.BT_TRACE_ID_HEADER = exports.BT_IDEMPOTENCY_KEY_HEADER = exports.BT_EXPOSE_PROXY_RESPONSE_HEADER = exports.BROWSER_LIST = exports.API_KEY_HEADER = void 0;
6
+ exports.USER_AGENT_HEADER = exports.USER_AGENT_CLIENT = exports.DEFAULT_ELEMENTS_BASE_URL = exports.DEFAULT_BASE_URL = exports.CONTENT_TYPE_HEADER = exports.CLIENT_USER_AGENT_HEADER = exports.CLIENT_BASE_PATHS = exports.BT_TRANSACTION_ID_HEADER = exports.BT_TRACE_ID_HEADER = exports.BT_IDEMPOTENCY_KEY_HEADER = exports.BT_EXPOSE_PROXY_RESPONSE_HEADER = exports.BROWSER_LIST = exports.API_KEY_HEADER = void 0;
7
7
  const API_KEY_HEADER = 'BT-API-KEY';
8
8
  exports.API_KEY_HEADER = API_KEY_HEADER;
9
9
  const BT_TRACE_ID_HEADER = 'bt-trace-id';
@@ -12,6 +12,8 @@ const BT_IDEMPOTENCY_KEY_HEADER = 'bt-idempotency-key';
12
12
  exports.BT_IDEMPOTENCY_KEY_HEADER = BT_IDEMPOTENCY_KEY_HEADER;
13
13
  const BT_EXPOSE_PROXY_RESPONSE_HEADER = 'BT-EXPOSE-RAW-PROXY-RESPONSE';
14
14
  exports.BT_EXPOSE_PROXY_RESPONSE_HEADER = BT_EXPOSE_PROXY_RESPONSE_HEADER;
15
+ const BT_TRANSACTION_ID_HEADER = 'BT-TRANSACTION-ID';
16
+ exports.BT_TRANSACTION_ID_HEADER = BT_TRANSACTION_ID_HEADER;
15
17
  const CONTENT_TYPE_HEADER = 'Content-Type';
16
18
  exports.CONTENT_TYPE_HEADER = CONTENT_TYPE_HEADER;
17
19
  const USER_AGENT_HEADER = 'User-Agent';
@@ -35,7 +37,8 @@ const CLIENT_BASE_PATHS = {
35
37
  permissions: 'permissions',
36
38
  proxies: 'proxies',
37
39
  proxy: 'proxy',
38
- sessions: 'sessions'
40
+ sessions: 'sessions',
41
+ transactions: 'transactions'
39
42
  };
40
43
  exports.CLIENT_BASE_PATHS = CLIENT_BASE_PATHS;
41
44
  const BROWSER_LIST = [{
package/common/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './constants';
2
2
  export * from './utils';
3
3
  export { BasisTheoryApiError } from './BasisTheoryApiError';
4
4
  export { BasisTheoryValidationError } from './BasisTheoryValidationError';
5
+ export { HttpClientError } from './HttpClientError';
package/common/index.js CHANGED
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  BasisTheoryApiError: true,
8
- BasisTheoryValidationError: true
8
+ BasisTheoryValidationError: true,
9
+ HttpClientError: true
9
10
  };
10
11
  Object.defineProperty(exports, "BasisTheoryApiError", {
11
12
  enumerable: true,
@@ -19,6 +20,12 @@ Object.defineProperty(exports, "BasisTheoryValidationError", {
19
20
  return _BasisTheoryValidationError.BasisTheoryValidationError;
20
21
  }
21
22
  });
23
+ Object.defineProperty(exports, "HttpClientError", {
24
+ enumerable: true,
25
+ get: function () {
26
+ return _HttpClientError.HttpClientError;
27
+ }
28
+ });
22
29
 
23
30
  var _constants = require("./constants");
24
31
 
@@ -50,4 +57,6 @@ Object.keys(_utils).forEach(function (key) {
50
57
 
51
58
  var _BasisTheoryApiError = require("./BasisTheoryApiError");
52
59
 
53
- var _BasisTheoryValidationError = require("./BasisTheoryValidationError");
60
+ var _BasisTheoryValidationError = require("./BasisTheoryValidationError");
61
+
62
+ var _HttpClientError = require("./HttpClientError");
package/common/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AxiosRequestConfig, AxiosResponse, AxiosTransformer } from 'axios';
2
+ import type { RequestTransformers } from '../service';
2
3
  import type { ApplicationInfo, ProxyRequestOptions, RequestOptions } from '../types/sdk';
3
4
  declare const assertInit: <T>(prop: T) => NonNullable<T>;
4
5
  declare const transformRequestSnakeCase: AxiosTransformer;
@@ -16,12 +17,12 @@ declare const dataExtractor: <T>(res: AxiosResponse<T>) => T;
16
17
  declare const dataAndHeadersExtractor: <T>(res: AxiosResponse<T>) => Pick<AxiosResponse<T>, "data" | "headers">;
17
18
  declare const concatRequestTransformerWithDefault: (requestTransformer: AxiosTransformer | AxiosTransformer[]) => AxiosTransformer | AxiosTransformer[] | undefined;
18
19
  declare const concatResponseTransformerWithDefault: (responseTransformer: AxiosTransformer | AxiosTransformer[]) => AxiosTransformer | AxiosTransformer[] | undefined;
19
- declare const createRequestConfig: (options?: RequestOptions | ProxyRequestOptions | undefined, transformers?: Pick<AxiosRequestConfig, "transformRequest" | "transformResponse"> | undefined) => AxiosRequestConfig | undefined;
20
+ declare const createRequestConfig: (options?: ProxyRequestOptions | RequestOptions, transformers?: RequestTransformers) => AxiosRequestConfig | undefined;
20
21
  declare const errorInterceptor: (error: any) => void;
21
22
  declare const getQueryParams: <Q>(query?: Q) => string;
22
- declare const buildUserAgentString: (appInfo?: ApplicationInfo | undefined) => string;
23
+ declare const buildUserAgentString: (appInfo?: ApplicationInfo) => string;
23
24
  declare const getBrowser: () => string;
24
25
  declare const getOSVersion: () => string;
25
26
  declare const getRuntime: () => string;
26
- declare const buildClientUserAgentString: (appInfo?: ApplicationInfo | undefined) => string;
27
+ declare const buildClientUserAgentString: (appInfo?: ApplicationInfo) => string;
27
28
  export { assertInit, transformRequestSnakeCase, proxyRaw, dataAndHeadersExtractor, transformReactorRequestSnakeCase, transformProxyRequestSnakeCase, transformAtomicRequestSnakeCase, transformTokenRequestSnakeCase, transformTokenResponseCamelCase, transformReactorResponseCamelCase, transformProxyResponseCamelCase, transformResponseCamelCase, transformAtomicResponseCamelCase, dataExtractor, createRequestConfig, concatRequestTransformerWithDefault, concatResponseTransformerWithDefault, errorInterceptor, getQueryParams, buildUserAgentString, buildClientUserAgentString, getOSVersion, getRuntime, getBrowser, };
package/common/utils.js CHANGED
@@ -232,6 +232,7 @@ const createRequestConfig = (options, transformers) => {
232
232
  apiKey,
233
233
  correlationId,
234
234
  idempotencyKey,
235
+ transactionId,
235
236
  query,
236
237
  headers
237
238
  } = options;
@@ -244,10 +245,14 @@ const createRequestConfig = (options, transformers) => {
244
245
  const idempotencyKeyHeader = idempotencyKey ? {
245
246
  [_constants.BT_IDEMPOTENCY_KEY_HEADER]: idempotencyKey
246
247
  } : {};
248
+ const transactionIdHeader = transactionId ? {
249
+ [_constants.BT_TRANSACTION_ID_HEADER]: transactionId
250
+ } : {};
247
251
  return {
248
252
  headers: { ...apiKeyHeader,
249
253
  ...correlationIdHeader,
250
254
  ...idempotencyKeyHeader,
255
+ ...transactionIdHeader,
251
256
  ...(typeof headers !== 'undefined' && { ...headers
252
257
  })
253
258
  },
@@ -1,3 +1,3 @@
1
1
  import type { BasisTheoryElements } from '../types/elements';
2
- declare const loadElements: (elementsClientUrl?: string | undefined) => Promise<BasisTheoryElements>;
2
+ declare const loadElements: (elementsClientUrl?: string) => Promise<BasisTheoryElements>;
3
3
  export { loadElements };
@@ -1,5 +1,5 @@
1
1
  import { BasisTheoryProxy } from '../../proxy';
2
2
  import type { Proxy as ElementsProxy, BasisTheoryElementsInternal } from '../../types/elements';
3
3
  import type { Proxy } from '../../types/sdk';
4
- declare const delegateProxy: (elements?: BasisTheoryElementsInternal | undefined) => new (options: import("../../service/types").BasisTheoryServiceOptions) => ElementsProxy & Proxy;
4
+ declare const delegateProxy: (elements?: BasisTheoryElementsInternal) => new (options: import("../../service/types").BasisTheoryServiceOptions) => ElementsProxy & Proxy;
5
5
  export { delegateProxy };
@@ -1,5 +1,5 @@
1
1
  import { BasisTheoryTokenize } from '../../tokenize';
2
2
  import type { Tokenize as ElementsTokenize, BasisTheoryElementsInternal } from '../../types/elements';
3
3
  import type { Tokenize } from '../../types/sdk';
4
- declare const delegateTokenize: (elements?: BasisTheoryElementsInternal | undefined) => new (options: import("../../service/types").BasisTheoryServiceOptions) => ElementsTokenize & Tokenize;
4
+ declare const delegateTokenize: (elements?: BasisTheoryElementsInternal) => new (options: import("../../service/types").BasisTheoryServiceOptions) => ElementsTokenize & Tokenize;
5
5
  export { delegateTokenize };
@@ -1,5 +1,5 @@
1
1
  import { BasisTheoryTokens } from '../../tokens';
2
2
  import type { Tokens as ElementsTokens, BasisTheoryElementsInternal } from '../../types/elements';
3
3
  import type { Tokens } from '../../types/sdk';
4
- declare const delegateTokens: (elements?: BasisTheoryElementsInternal | undefined) => new (options: import("../../service/types").BasisTheoryServiceOptions) => ElementsTokens & Tokens;
4
+ declare const delegateTokens: (elements?: BasisTheoryElementsInternal) => new (options: import("../../service/types").BasisTheoryServiceOptions) => ElementsTokens & Tokens;
5
5
  export { delegateTokens };
@@ -5,4 +5,4 @@ export declare const BasisTheoryLogs: {
5
5
  readonly client: import("axios").AxiosInstance;
6
6
  };
7
7
  } & (new (...args: any[]) => import("../types/sdk/services/shared").List<Log, ListLogQuery>);
8
- export declare type BasisTheoryLogs = InstanceType<typeof BasisTheoryLogs>;
8
+ export type BasisTheoryLogs = InstanceType<typeof BasisTheoryLogs>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/basis-theory-js",
3
- "version": "1.75.0",
3
+ "version": "1.77.0",
4
4
  "repository": "https://github.com/Basis-Theory/basis-theory-js",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -1,8 +1,8 @@
1
- import type { ReactorFormula } from '../types/models';
1
+ import type { CreateReactorFormula, ReactorFormula } from '../types/models';
2
2
  import type { ListReactorFormulaQuery } from '../types/sdk';
3
3
  export declare const BasisTheoryReactorFormulas: {
4
4
  new (options: import("../service/types").BasisTheoryServiceOptions): {
5
5
  readonly client: import("axios").AxiosInstance;
6
6
  };
7
- } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<ReactorFormula, Pick<ReactorFormula, "code" | "type" | "name" | "description" | "icon" | "configuration" | "requestParameters">>) & (new (...args: any[]) => import("../types/sdk/services/shared").Retrieve<ReactorFormula>) & (new (...args: any[]) => import("../types/sdk/services/shared").Update<ReactorFormula, Pick<ReactorFormula, "code" | "type" | "name" | "description" | "icon" | "configuration" | "requestParameters">>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<ReactorFormula, ListReactorFormulaQuery>);
8
- export declare type BasisTheoryReactorFormulas = InstanceType<typeof BasisTheoryReactorFormulas>;
7
+ } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<ReactorFormula, CreateReactorFormula>) & (new (...args: any[]) => import("../types/sdk/services/shared").Retrieve<ReactorFormula>) & (new (...args: any[]) => import("../types/sdk/services/shared").Update<ReactorFormula, CreateReactorFormula>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<ReactorFormula, ListReactorFormulaQuery>);
8
+ export type BasisTheoryReactorFormulas = InstanceType<typeof BasisTheoryReactorFormulas>;
@@ -3,8 +3,8 @@ import type { Reactor, CreateReactor, UpdateReactor, ReactResponse } from '../ty
3
3
  import type { ListReactorQuery, ReactRequest, RequestOptions } from '../types/sdk';
4
4
  export declare const BasisTheoryReactors: {
5
5
  new (options: BasisTheoryServiceOptions): {
6
- react(reactorId: string, request: ReactRequest, options?: RequestOptions | undefined): Promise<ReactResponse>;
6
+ react(reactorId: string, request: ReactRequest, options?: RequestOptions): Promise<ReactResponse>;
7
7
  readonly client: import("axios").AxiosInstance;
8
8
  };
9
9
  } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Reactor, CreateReactor>) & (new (...args: any[]) => import("../types/sdk/services/shared").Retrieve<Reactor>) & (new (...args: any[]) => import("../types/sdk/services/shared").Update<Reactor, UpdateReactor>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Reactor, ListReactorQuery>);
10
- export declare type BasisTheoryReactors = InstanceType<typeof BasisTheoryReactors>;
10
+ export type BasisTheoryReactors = InstanceType<typeof BasisTheoryReactors>;
@@ -1,11 +1,11 @@
1
1
  import type { PaginatedQuery, Create as ICreate, Retrieve as IRetrieve, Update as IUpdate, Delete as IDelete, List as IList } from '../types/sdk';
2
2
  import { BasisTheoryService } from './BasisTheoryService';
3
- declare type BasisTheoryServiceConstructor<T extends BasisTheoryService = BasisTheoryService> = new (...params: any[]) => T;
4
- declare type ICreateConstructor<T, C> = new (...args: any[]) => ICreate<T, C>;
5
- declare type IRetrieveConstructor<T> = new (...args: any[]) => IRetrieve<T>;
6
- declare type IUpdateConstructor<T, U> = new (...args: any[]) => IUpdate<T, U>;
7
- declare type IDeleteConstructor = new (...args: any[]) => IDelete;
8
- declare type IListConstructor<T, Q extends PaginatedQuery> = new (...args: any[]) => IList<T, Q>;
3
+ type BasisTheoryServiceConstructor<T extends BasisTheoryService = BasisTheoryService> = new (...params: any[]) => T;
4
+ type ICreateConstructor<T, C> = new (...args: any[]) => ICreate<T, C>;
5
+ type IRetrieveConstructor<T> = new (...args: any[]) => IRetrieve<T>;
6
+ type IUpdateConstructor<T, U> = new (...args: any[]) => IUpdate<T, U>;
7
+ type IDeleteConstructor = new (...args: any[]) => IDelete;
8
+ type IListConstructor<T, Q extends PaginatedQuery> = new (...args: any[]) => IList<T, Q>;
9
9
  declare class CrudBuilder<Class extends BasisTheoryServiceConstructor> {
10
10
  private BaseService;
11
11
  constructor(baseService: Class);
@@ -5,5 +5,5 @@ interface BasisTheoryServiceOptions extends Pick<AxiosRequestConfig, 'transformR
5
5
  baseURL: string;
6
6
  appInfo?: ApplicationInfo;
7
7
  }
8
- declare type RequestTransformers = Pick<AxiosRequestConfig, 'transformRequest' | 'transformResponse'>;
8
+ type RequestTransformers = Pick<AxiosRequestConfig, 'transformRequest' | 'transformResponse'>;
9
9
  export type { BasisTheoryServiceOptions, RequestTransformers };
@@ -4,18 +4,18 @@ import type { PaginatedList } from '../types/sdk/services/shared';
4
4
  import type { ListTenantInvitationsQuery, ListTenantMembersQuery } from '../types/sdk/services/tenants';
5
5
  export declare const BasisTheoryTenants: {
6
6
  new (options: import("../service/types").BasisTheoryServiceOptions): {
7
- retrieve(options?: RequestOptions | undefined): Promise<Tenant>;
8
- update(model: UpdateTenant, options?: RequestOptions | undefined): Promise<Tenant>;
9
- delete(options?: RequestOptions | undefined): Promise<void>;
10
- retrieveUsageReport(options?: RequestOptions | undefined): Promise<TenantUsageReport>;
11
- createInvitation(model: CreateTenantInvitation, options?: RequestOptions | undefined): Promise<TenantInvitation>;
12
- resendInvitation(invitationId: string, options?: RequestOptions | undefined): Promise<TenantInvitation>;
13
- listInvitations(query?: ListTenantInvitationsQuery | undefined, options?: RequestOptions | undefined): Promise<PaginatedList<TenantInvitation>>;
14
- retrieveInvitation(invitationId: string, options?: RequestOptions | undefined): Promise<TenantInvitation>;
15
- deleteInvitation(invitationId: string, options?: RequestOptions | undefined): Promise<void>;
16
- listMembers(query?: ListTenantMembersQuery | undefined, options?: RequestOptions | undefined): Promise<PaginatedList<TenantMember>>;
17
- deleteMember(memberId: string, options?: RequestOptions | undefined): Promise<void>;
7
+ retrieve(options?: RequestOptions): Promise<Tenant>;
8
+ update(model: UpdateTenant, options?: RequestOptions): Promise<Tenant>;
9
+ delete(options?: RequestOptions): Promise<void>;
10
+ retrieveUsageReport(options?: RequestOptions): Promise<TenantUsageReport>;
11
+ createInvitation(model: CreateTenantInvitation, options?: RequestOptions): Promise<TenantInvitation>;
12
+ resendInvitation(invitationId: string, options?: RequestOptions): Promise<TenantInvitation>;
13
+ listInvitations(query?: ListTenantInvitationsQuery, options?: RequestOptions): Promise<PaginatedList<TenantInvitation>>;
14
+ retrieveInvitation(invitationId: string, options?: RequestOptions): Promise<TenantInvitation>;
15
+ deleteInvitation(invitationId: string, options?: RequestOptions): Promise<void>;
16
+ listMembers(query?: ListTenantMembersQuery, options?: RequestOptions): Promise<PaginatedList<TenantMember>>;
17
+ deleteMember(memberId: string, options?: RequestOptions): Promise<void>;
18
18
  readonly client: import("axios").AxiosInstance;
19
19
  };
20
20
  };
21
- export declare type BasisTheoryTenants = InstanceType<typeof BasisTheoryTenants>;
21
+ export type BasisTheoryTenants = InstanceType<typeof BasisTheoryTenants>;
@@ -5,12 +5,12 @@ export declare const BasisTheoryTokens: {
5
5
  new (options: BasisTheoryServiceOptions): {
6
6
  retrieve(id: string, options?: RequestOptions): Promise<Token<any>>;
7
7
  update(id: string, model: UpdateToken, options?: RequestOptions): Promise<Token>;
8
- createAssociation(parentId: string, childId: string, options?: RequestOptions | undefined): Promise<void>;
9
- deleteAssociation(parentId: string, childId: string, options?: RequestOptions | undefined): Promise<void>;
10
- createChild(parentId: string, token: CreateToken, options?: RequestOptions | undefined): Promise<Token>;
8
+ createAssociation(parentId: string, childId: string, options?: RequestOptions): Promise<void>;
9
+ deleteAssociation(parentId: string, childId: string, options?: RequestOptions): Promise<void>;
10
+ createChild(parentId: string, token: CreateToken, options?: RequestOptions): Promise<Token>;
11
11
  listChildren(parentId: string, query?: ListTokensQuery, options?: RequestOptions): Promise<PaginatedList<Token>>;
12
- search(searchRequest: SearchTokensRequest, options?: RequestOptions | undefined): Promise<PaginatedList<Token>>;
12
+ search(searchRequest: SearchTokensRequest, options?: RequestOptions): Promise<PaginatedList<Token>>;
13
13
  readonly client: import("axios").AxiosInstance;
14
14
  };
15
- } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Token<import("../types/models/shared").Primitive>, CreateToken<import("../types/models/shared").Primitive>>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Token<import("../types/models/shared").Primitive>, ListTokensQuery>);
16
- export declare type BasisTheoryTokens = InstanceType<typeof BasisTheoryTokens>;
15
+ } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Token<import("../types/models/shared").Primitive>, CreateToken>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Token<import("../types/models/shared").Primitive>, ListTokensQuery>);
16
+ export type BasisTheoryTokens = InstanceType<typeof BasisTheoryTokens>;
@@ -0,0 +1,10 @@
1
+ import { BasisTheoryService } from '../service';
2
+ import type { BasisTheoryServiceOptions } from '../service';
3
+ import type { RequestOptions } from '../types/sdk';
4
+ import { CreateTransactionResponse, Transactions } from '../types/sdk/services/transactions';
5
+ export declare class BasisTheoryTransactions extends BasisTheoryService implements Transactions {
6
+ constructor(options: BasisTheoryServiceOptions);
7
+ create(options?: RequestOptions): Promise<CreateTransactionResponse>;
8
+ commit(id: string, options?: RequestOptions): Promise<void>;
9
+ rollback(id: string, options?: RequestOptions): Promise<void>;
10
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BasisTheoryTransactions = void 0;
7
+
8
+ var _common = require("./../common");
9
+
10
+ var _utils = require("./../common/utils");
11
+
12
+ var _service = require("./../service");
13
+
14
+ class BasisTheoryTransactions extends _service.BasisTheoryService {
15
+ constructor(options) {
16
+ const _options = { ...options
17
+ }; // eslint-disable-next-line unicorn/prefer-spread
18
+
19
+ _options.transformRequest = [].concat(_utils.transformProxyRequestSnakeCase, options.transformRequest || []); // eslint-disable-next-line unicorn/prefer-spread
20
+
21
+ _options.transformResponse = [].concat(_utils.transformProxyResponseCamelCase, options.transformResponse || []);
22
+ super(_options);
23
+ }
24
+
25
+ create(options = {}) {
26
+ return this.client.post('/', undefined, (0, _common.createRequestConfig)(options)).then(_utils.dataExtractor);
27
+ }
28
+
29
+ commit(id, options = {}) {
30
+ const url = `/${id}/commit`;
31
+ return this.client.post(url, undefined, (0, _common.createRequestConfig)(options)).then(_utils.dataExtractor);
32
+ }
33
+
34
+ rollback(id, options = {}) {
35
+ const url = `/${id}/rollback`;
36
+ return this.client.post(url, undefined, (0, _common.createRequestConfig)(options)).then(_utils.dataExtractor);
37
+ }
38
+
39
+ }
40
+
41
+ exports.BasisTheoryTransactions = BasisTheoryTransactions;
@@ -0,0 +1 @@
1
+ export * from './BasisTheoryTransactions';