@basis-theory-labs/cli 1.12.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install -g @basis-theory-labs/cli
19
19
  $ bt COMMAND
20
20
  running command...
21
21
  $ bt (--version)
22
- @basis-theory-labs/cli/1.12.0 linux-x64 node-v18.20.7
22
+ @basis-theory-labs/cli/2.0.0 linux-x64 node-v18.20.8
23
23
  $ bt --help [COMMAND]
24
24
  USAGE
25
25
  $ bt COMMAND
@@ -37,8 +37,6 @@ USAGE
37
37
  * [`bt proxies delete ID`](#bt-proxies-delete-id)
38
38
  * [`bt proxies logs [ID]`](#bt-proxies-logs-id)
39
39
  * [`bt proxies update ID`](#bt-proxies-update-id)
40
- * [`bt reactorFormulas`](#bt-reactorformulas)
41
- * [`bt reactorFormulas update ID`](#bt-reactorformulas-update-id)
42
40
  * [`bt reactors`](#bt-reactors)
43
41
  * [`bt reactors create`](#bt-reactors-create)
44
42
  * [`bt reactors delete ID`](#bt-reactors-delete-id)
@@ -64,7 +62,7 @@ EXAMPLES
64
62
  $ bt applications
65
63
  ```
66
64
 
67
- _See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.12.0/dist/commands/applications/index.ts)_
65
+ _See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.0.0/dist/commands/applications/index.ts)_
68
66
 
69
67
  ## `bt applications create`
70
68
 
@@ -153,7 +151,7 @@ EXAMPLES
153
151
  $ bt proxies
154
152
  ```
155
153
 
156
- _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.12.0/dist/commands/proxies/index.ts)_
154
+ _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.0.0/dist/commands/proxies/index.ts)_
157
155
 
158
156
  ## `bt proxies create`
159
157
 
@@ -267,59 +265,6 @@ EXAMPLES
267
265
  $ bt proxies update 03858bf5-32d3-4a2e-b74b-daeea0883bca --configuration ./.env.proxy
268
266
  ```
269
267
 
270
- ## `bt reactorFormulas`
271
-
272
- [Deprecated] List Reactor Formulas. Requires `reactor:read` Management Application permission
273
-
274
- ```
275
- USAGE
276
- $ bt reactorFormulas -x <value> [-p <value>]
277
-
278
- FLAGS
279
- -p, --page=<value> [default: 1] Reactors formulas list page to fetch
280
- -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
281
-
282
- DESCRIPTION
283
- [Deprecated] List Reactor Formulas. Requires `reactor:read` Management Application permission
284
-
285
- EXAMPLES
286
- $ bt reactorFormulas
287
- ```
288
-
289
- _See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.12.0/dist/commands/reactorFormulas/index.ts)_
290
-
291
- ## `bt reactorFormulas update ID`
292
-
293
- [Deprecated] Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission
294
-
295
- ```
296
- USAGE
297
- $ bt reactorFormulas update ID -x <value> -n <value> -s <value> -c <value> -p <value> [-d <value>] [-i <value>] [-w]
298
-
299
- ARGUMENTS
300
- ID Reactor Formula id to update
301
-
302
- FLAGS
303
- -c, --configuration=<value> (required) path to configuration definition to use in the Reactor Formula
304
- -d, --description=<value> description of the Reactor Formula
305
- -i, --icon=<value> icon of the Reactor Formula
306
- -n, --name=<value> (required) name of the Reactor Formula
307
- -p, --request-parameters=<value> (required) path to request params definition to use in the Reactor Formula
308
- -s, --code=<value> (required) path to JavaScript file containing code
309
- -w, --watch Watch for changes in informed files
310
- -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
311
-
312
- DESCRIPTION
313
- [Deprecated] Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission
314
-
315
- EXAMPLES
316
- $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca
317
-
318
- $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js
319
-
320
- $ bt reactorFormulas update 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w
321
- ```
322
-
323
268
  ## `bt reactors`
324
269
 
325
270
  List Reactors. Requires `reactor:read` Management Application permission
@@ -339,7 +284,7 @@ EXAMPLES
339
284
  $ bt reactors
340
285
  ```
341
286
 
342
- _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.12.0/dist/commands/reactors/index.ts)_
287
+ _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v2.0.0/dist/commands/reactors/index.ts)_
343
288
 
344
289
  ## `bt reactors create`
345
290
 
@@ -1,11 +1,9 @@
1
- import type { Application, ApplicationType, CreateApplication, Permission, UpdateApplication } from '@basis-theory/basis-theory-js/types/models';
2
- import { ApplicationTemplate } from '@basis-theory/basis-theory-js/types/models/application-templates';
3
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
4
- declare const listPermissions: (bt: IBasisTheory, type: ApplicationType) => Promise<Permission[]>;
5
- declare const selectApplication: (bt: IBasisTheory, page: number) => Promise<Application | undefined>;
6
- declare const createApplication: (bt: IBasisTheory, model: CreateApplication) => Promise<Application>;
7
- declare const updateApplication: (bt: IBasisTheory, id: string, model: UpdateApplication) => Promise<Application>;
8
- declare const deleteApplication: (bt: IBasisTheory, id: string, force?: boolean) => Promise<boolean>;
9
- declare const createApplicationFromTemplate: (bt: IBasisTheory, templateId: string) => Promise<Application>;
10
- declare const promptTemplate: (bt: IBasisTheory) => Promise<ApplicationTemplate | undefined>;
1
+ import type { BasisTheory, BasisTheoryClient } from '@basis-theory/node-sdk';
2
+ declare const listPermissions: (bt: BasisTheoryClient, type: string) => Promise<BasisTheory.Permission[]>;
3
+ declare const selectApplication: (bt: BasisTheoryClient, page: number) => Promise<BasisTheory.Application | undefined>;
4
+ declare const createApplication: (bt: BasisTheoryClient, model: BasisTheory.CreateApplicationRequest) => Promise<BasisTheory.Application>;
5
+ declare const updateApplication: (bt: BasisTheoryClient, id: string, model: Partial<BasisTheory.UpdateApplicationRequest>) => Promise<BasisTheory.Application>;
6
+ declare const deleteApplication: (bt: BasisTheoryClient, id: string, force?: boolean) => Promise<boolean>;
7
+ declare const createApplicationFromTemplate: (bt: BasisTheoryClient, templateId: string) => Promise<BasisTheory.Application>;
8
+ declare const promptTemplate: (bt: BasisTheoryClient) => Promise<BasisTheory.ApplicationTemplate | undefined>;
11
9
  export { listPermissions, createApplication, updateApplication, selectApplication, deleteApplication, createApplicationFromTemplate, promptTemplate, };
@@ -12,19 +12,19 @@ const listPermissions = (bt, type) => bt.permissions
12
12
  .list({
13
13
  applicationType: type,
14
14
  })
15
- .then((permissions) => permissions.sort((p1, p2) => p1.type.localeCompare(p2.type)));
15
+ .then((permissions) => permissions.sort((p1, p2) => { var _a, _b; return ((_a = p1.type) !== null && _a !== void 0 ? _a : '').localeCompare((_b = p2.type) !== null && _b !== void 0 ? _b : ''); }));
16
16
  exports.listPermissions = listPermissions;
17
17
  const listApplications = async (bt, page) => {
18
18
  const size = 5;
19
19
  debug('Listing applications', `page: ${page}`, `size: ${size}`);
20
- const applications = await bt.applications.list({
20
+ const applicationsPage = await bt.applications.list({
21
21
  size,
22
22
  page,
23
23
  });
24
24
  let data = [];
25
- if (applications.pagination.totalItems > 0) {
26
- const last = (applications.pagination.pageNumber - 1) * size;
27
- data = applications.data.map((application, index) => ({
25
+ if (applicationsPage.data.length) {
26
+ const last = (page - 1) * size;
27
+ data = applicationsPage.data.map((application, index) => ({
28
28
  '#': last + (index + 1),
29
29
  ...application,
30
30
  }));
@@ -40,16 +40,17 @@ const listApplications = async (bt, page) => {
40
40
  }
41
41
  return {
42
42
  data,
43
- pagination: applications.pagination,
43
+ page,
44
+ hasNextPage: applicationsPage.hasNextPage(),
44
45
  };
45
46
  };
46
47
  const retrieveApplication = (bt, id) => {
47
48
  debug(`Retrieving Application ${id}`);
48
- return bt.applications.retrieve(id);
49
+ return bt.applications.get(id);
49
50
  };
50
51
  const selectApplication = async (bt, page) => {
51
52
  const applications = await listApplications(bt, page);
52
- if (applications.pagination.totalItems === 0) {
53
+ if (!applications.data.length) {
53
54
  return undefined;
54
55
  }
55
56
  const selection = await (0, utils_1.selectOrNavigate)(applications, '#');
@@ -71,7 +72,7 @@ const updateApplication = async (bt, id, model) => {
71
72
  const application = await retrieveApplication(bt, id);
72
73
  debug(`Updating Application ${id}`, JSON.stringify(model, undefined, 2));
73
74
  return bt.applications.update(id, {
74
- name: model.name || application.name,
75
+ name: model.name || application.name || '',
75
76
  permissions: model.permissions || application.permissions,
76
77
  rules: model.permissions ? undefined : application.rules, // if permissions were passed, overwrite rules
77
78
  });
@@ -93,7 +94,10 @@ const deleteApplication = async (bt, id, force = false) => {
93
94
  };
94
95
  exports.deleteApplication = deleteApplication;
95
96
  const createApplicationFromTemplate = async (bt, templateId) => {
96
- const template = await bt.applicationTemplates.retrieve(templateId);
97
+ const template = await bt.applicationTemplates.get(templateId);
98
+ if (!template.name || !template.applicationType) {
99
+ throw new Error('Invalid template: missing name or applicationType');
100
+ }
97
101
  return createApplication(bt, {
98
102
  name: template.name,
99
103
  type: template.applicationType,
package/dist/base.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
1
+ import { BasisTheoryClient } from '@basis-theory/node-sdk';
2
2
  import { Command } from '@oclif/core';
3
3
  import type { ArgOutput, FlagOutput, Input, ParserOutput } from '@oclif/core/lib/interfaces/parser';
4
4
  export declare abstract class BaseCommand extends Command {
@@ -7,7 +7,7 @@ export declare abstract class BaseCommand extends Command {
7
7
  'api-base-url': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
8
  };
9
9
  protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, B, A> & {
10
- bt: IBasisTheory;
10
+ bt: BasisTheoryClient;
11
11
  }>;
12
12
  protected catch(err: unknown): Promise<unknown>;
13
13
  }
package/dist/base.js CHANGED
@@ -1,23 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseCommand = void 0;
4
- const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
5
- const common_1 = require("@basis-theory/basis-theory-js/common");
4
+ const node_sdk_1 = require("@basis-theory/node-sdk");
6
5
  const core_1 = require("@oclif/core");
7
6
  class BaseCommand extends core_1.Command {
8
7
  async parse(options, argv) {
9
8
  const { flags, ...parsed } = await super.parse(options, argv);
10
9
  const { 'management-key': managementKey, 'api-base-url': apiBaseUrl } = flags;
11
- const bt = await new basis_theory_js_1.BasisTheory().init(managementKey, {
12
- appInfo: {
13
- name: this.config.userAgent,
14
- version: this.config.version,
15
- },
16
- ...(apiBaseUrl
17
- ? {
18
- apiBaseUrl,
19
- }
20
- : {}),
10
+ const bt = new node_sdk_1.BasisTheoryClient({
11
+ apiKey: managementKey,
12
+ ...(apiBaseUrl ? { environment: apiBaseUrl } : {}),
21
13
  });
22
14
  return {
23
15
  ...parsed,
@@ -26,8 +18,8 @@ class BaseCommand extends core_1.Command {
26
18
  };
27
19
  }
28
20
  catch(err) {
29
- if (err instanceof common_1.BasisTheoryApiError) {
30
- this.logJson(err.data);
21
+ if (err instanceof node_sdk_1.BasisTheoryError && err.body) {
22
+ this.logJson(err.body);
31
23
  }
32
24
  return super.catch(err);
33
25
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const models_1 = require("@basis-theory/basis-theory-js/types/models");
4
3
  const core_1 = require("@oclif/core");
5
4
  const management_1 = require("../../applications/management");
6
5
  const utils_1 = require("../../applications/utils");
7
6
  const base_1 = require("../../base");
8
7
  const utils_2 = require("../../utils");
8
+ const APPLICATION_TYPES = ['private', 'public', 'management'];
9
9
  class Create extends base_1.BaseCommand {
10
10
  async run() {
11
11
  const { flags, bt } = await this.parse(Create);
@@ -35,7 +35,7 @@ class Create extends base_1.BaseCommand {
35
35
  else {
36
36
  type = (await (0, utils_2.promptSelectIfUndefined)(flags.type, {
37
37
  message: 'What is the Application type?',
38
- choices: models_1.APPLICATION_TYPES.map((t) => ({ value: t })),
38
+ choices: APPLICATION_TYPES.map((t) => ({ value: t })),
39
39
  }));
40
40
  const available = await (0, management_1.listPermissions)(bt, type);
41
41
  permissions = await (0, utils_2.promptCheckboxIfUndefined)(flags.permission, {
@@ -46,6 +46,9 @@ class Create extends base_1.BaseCommand {
46
46
  loop: false,
47
47
  });
48
48
  }
49
+ if (!type) {
50
+ throw new Error('Application type is required');
51
+ }
49
52
  application = await (0, management_1.createApplication)(bt, {
50
53
  name,
51
54
  type,
@@ -66,7 +69,7 @@ Create.flags = {
66
69
  type: core_1.Flags.string({
67
70
  char: 't',
68
71
  description: 'type of the Application',
69
- options: [...models_1.APPLICATION_TYPES],
72
+ options: [...APPLICATION_TYPES],
70
73
  }),
71
74
  template: core_1.Flags.string({
72
75
  description: 'template ID to create the application with',
@@ -7,6 +7,7 @@ const management_1 = require("../../applications/management");
7
7
  const base_1 = require("../../base");
8
8
  class Applications extends base_1.BaseCommand {
9
9
  async run() {
10
+ var _a;
10
11
  const { bt, flags: { page }, } = await this.parse(Applications);
11
12
  const application = await (0, management_1.selectApplication)(bt, page);
12
13
  if (!application) {
@@ -29,7 +30,8 @@ class Applications extends base_1.BaseCommand {
29
30
  this.logJson(application);
30
31
  return undefined;
31
32
  }
32
- if (action === 'delete' && (await (0, management_1.deleteApplication)(bt, application.id))) {
33
+ if (action === 'delete' &&
34
+ (await (0, management_1.deleteApplication)(bt, (_a = application.id) !== null && _a !== void 0 ? _a : ''))) {
33
35
  return this.log('Application deleted successfully!');
34
36
  }
35
37
  return undefined;
@@ -8,6 +8,7 @@ const logs_1 = require("../../logs");
8
8
  const management_1 = require("../../proxies/management");
9
9
  class Proxies extends base_1.BaseCommand {
10
10
  async run() {
11
+ var _a, _b;
11
12
  const { flags: { page }, bt, } = await this.parse(Proxies);
12
13
  const proxy = await (0, management_1.selectProxy)(bt, page);
13
14
  if (!proxy) {
@@ -36,9 +37,9 @@ class Proxies extends base_1.BaseCommand {
36
37
  return undefined;
37
38
  }
38
39
  if (action === 'logs') {
39
- return (0, logs_1.showProxyLogs)(bt, proxy.id);
40
+ return (0, logs_1.showProxyLogs)(bt, (_a = proxy.id) !== null && _a !== void 0 ? _a : '');
40
41
  }
41
- if (action === 'delete' && (await (0, management_1.deleteProxy)(bt, proxy.id))) {
42
+ if (action === 'delete' && (await (0, management_1.deleteProxy)(bt, (_b = proxy.id) !== null && _b !== void 0 ? _b : ''))) {
42
43
  return this.log('Proxy deleted successfully!');
43
44
  }
44
45
  return undefined;
@@ -6,6 +6,7 @@ const logs_1 = require("../../logs");
6
6
  const management_1 = require("../../proxies/management");
7
7
  class Logs extends base_1.BaseCommand {
8
8
  async run() {
9
+ var _a;
9
10
  const { bt, flags: { port }, args: { id }, } = await this.parse(Logs);
10
11
  if (id) {
11
12
  return (0, logs_1.showProxyLogs)(bt, id, port);
@@ -14,7 +15,7 @@ class Logs extends base_1.BaseCommand {
14
15
  if (!proxy) {
15
16
  return undefined;
16
17
  }
17
- return (0, logs_1.showProxyLogs)(bt, proxy.id, port);
18
+ return (0, logs_1.showProxyLogs)(bt, (_a = proxy.id) !== null && _a !== void 0 ? _a : '', port);
18
19
  }
19
20
  }
20
21
  exports.default = Logs;
@@ -8,6 +8,7 @@ const logs_1 = require("../../logs");
8
8
  const management_1 = require("../../reactors/management");
9
9
  class Reactors extends base_1.BaseCommand {
10
10
  async run() {
11
+ var _a, _b;
11
12
  const { bt, flags: { page }, } = await this.parse(Reactors);
12
13
  const reactor = await (0, management_1.selectReactor)(bt, page);
13
14
  if (!reactor) {
@@ -36,9 +37,9 @@ class Reactors extends base_1.BaseCommand {
36
37
  return undefined;
37
38
  }
38
39
  if (action === 'logs') {
39
- return (0, logs_1.showReactorLogs)(bt, reactor.id);
40
+ return (0, logs_1.showReactorLogs)(bt, (_a = reactor.id) !== null && _a !== void 0 ? _a : '');
40
41
  }
41
- if (action === 'delete' && (await (0, management_1.deleteReactor)(bt, reactor.id))) {
42
+ if (action === 'delete' && (await (0, management_1.deleteReactor)(bt, (_b = reactor.id) !== null && _b !== void 0 ? _b : ''))) {
42
43
  return this.log('Reactor deleted successfully!');
43
44
  }
44
45
  return undefined;
@@ -6,6 +6,7 @@ const logs_1 = require("../../logs");
6
6
  const management_1 = require("../../reactors/management");
7
7
  class Logs extends base_1.BaseCommand {
8
8
  async run() {
9
+ var _a;
9
10
  const { bt, flags: { port }, args: { id }, } = await this.parse(Logs);
10
11
  if (id) {
11
12
  return (0, logs_1.showReactorLogs)(bt, id, port);
@@ -14,7 +15,7 @@ class Logs extends base_1.BaseCommand {
14
15
  if (!reactor) {
15
16
  return undefined;
16
17
  }
17
- return (0, logs_1.showReactorLogs)(bt, reactor.id, port);
18
+ return (0, logs_1.showReactorLogs)(bt, (_a = reactor.id) !== null && _a !== void 0 ? _a : '', port);
18
19
  }
19
20
  }
20
21
  exports.default = Logs;
@@ -1,6 +1,6 @@
1
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk/sdk';
2
- declare const connectToReactor: (bt: IBasisTheory, id: string, url: string) => Promise<void>;
3
- declare const disconnectFromReactor: (bt: IBasisTheory, id: string) => Promise<void>;
4
- declare const connectToProxy: (bt: IBasisTheory, id: string, url: string) => Promise<void>;
5
- declare const disconnectFromProxy: (bt: IBasisTheory, id: string) => Promise<void>;
1
+ import type { BasisTheoryClient } from '@basis-theory/node-sdk';
2
+ declare const connectToReactor: (bt: BasisTheoryClient, id: string, url: string) => Promise<void>;
3
+ declare const disconnectFromReactor: (bt: BasisTheoryClient, id: string) => Promise<void>;
4
+ declare const connectToProxy: (bt: BasisTheoryClient, id: string, url: string) => Promise<void>;
5
+ declare const disconnectFromProxy: (bt: BasisTheoryClient, id: string) => Promise<void>;
6
6
  export { connectToReactor, disconnectFromReactor, connectToProxy, disconnectFromProxy, };
@@ -16,8 +16,7 @@ const createConfiguration = (url) => ({
16
16
  destination: url,
17
17
  date: Date.now(),
18
18
  })
19
- : // eslint-disable-next-line unicorn/no-null
20
- null,
19
+ : undefined,
21
20
  });
22
21
  const connectToReactor = async (bt, id, url) => {
23
22
  core_1.ux.action.start(`Connecting to Reactor (${id})`);
@@ -1,5 +1,5 @@
1
- import type { BasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
1
+ import type { BasisTheoryClient } from '@basis-theory/node-sdk';
2
2
  declare const DEFAULT_LOGS_SERVER_PORT = 8220;
3
- declare const showProxyLogs: (bt: BasisTheory, id: string, port?: number) => Promise<void>;
4
- declare const showReactorLogs: (bt: BasisTheory, id: string, port?: number) => Promise<void>;
3
+ declare const showProxyLogs: (bt: BasisTheoryClient, id: string, port?: number) => Promise<void>;
4
+ declare const showReactorLogs: (bt: BasisTheoryClient, id: string, port?: number) => Promise<void>;
5
5
  export { showProxyLogs, showReactorLogs, DEFAULT_LOGS_SERVER_PORT };
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLogServer = void 0;
4
4
  const tslib_1 = require("tslib");
5
- // eslint-disable-next-line eslint-comments/disable-enable-pair
6
- /* eslint-disable no-promise-executor-return */
5
+ /* eslint-disable no-promise-executor-return, eslint-comments/disable-enable-pair */
7
6
  const core_1 = require("@oclif/core");
8
7
  const cloudflared_1 = require("cloudflared");
9
8
  const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
@@ -47,9 +46,12 @@ const createLogServer = async (_port) => {
47
46
  debug(`server listening on port ${port}`);
48
47
  await fastify.listen({ port });
49
48
  core_1.ux.action.stop(`✅\tListening at http://localhost:${port}`);
50
- core_1.ux.action.start('Starting tunnel');
49
+ core_1.ux.action.start('Creating tunnel');
51
50
  const url = await runTunnel(port);
52
- core_1.ux.action.stop(`✅\t\tListening at ${url}`);
51
+ core_1.ux.action.stop(`✅\t\tTunnel created at ${url}`);
52
+ core_1.ux.action.start('Waiting for tunnel to be ready (this may take 5 seconds)');
53
+ await new Promise((resolve) => setTimeout(resolve, 5000));
54
+ core_1.ux.action.stop('✅\t\tTunnel is now ready');
53
55
  return url;
54
56
  };
55
57
  exports.createLogServer = createLogServer;
@@ -1,7 +1,6 @@
1
- import type { CreateProxy, PatchProxy, Proxy } from '@basis-theory/basis-theory-js/types/models';
2
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
3
- declare const selectProxy: (bt: IBasisTheory, page: number) => Promise<Proxy | undefined>;
4
- declare const createProxy: (bt: IBasisTheory, model: CreateProxy) => Promise<Proxy>;
5
- declare const deleteProxy: (bt: IBasisTheory, id: string, force?: boolean) => Promise<boolean>;
6
- declare const patchProxy: (bt: IBasisTheory, id: string, model: PatchProxy) => Promise<void>;
1
+ import type { BasisTheory, BasisTheoryClient } from '@basis-theory/node-sdk';
2
+ declare const selectProxy: (bt: BasisTheoryClient, page: number) => Promise<BasisTheory.Proxy | undefined>;
3
+ declare const createProxy: (bt: BasisTheoryClient, model: BasisTheory.CreateProxyRequest) => Promise<BasisTheory.Proxy>;
4
+ declare const deleteProxy: (bt: BasisTheoryClient, id: string, force?: boolean) => Promise<boolean>;
5
+ declare const patchProxy: (bt: BasisTheoryClient, id: string, model: BasisTheory.PatchProxyRequest) => Promise<void>;
7
6
  export { selectProxy, createProxy, patchProxy, deleteProxy };
@@ -9,14 +9,14 @@ const debug = require('debug')('proxies:management');
9
9
  const listProxies = async (bt, page) => {
10
10
  const size = 5;
11
11
  debug('Listing proxies', `page: ${page}`, `size: ${size}`);
12
- const proxies = await bt.proxies.list({
12
+ const proxiesPage = await bt.proxies.list({
13
13
  size,
14
14
  page,
15
15
  });
16
16
  let data = [];
17
- if (proxies.pagination.totalItems > 0) {
18
- const last = (proxies.pagination.pageNumber - 1) * size;
19
- data = proxies.data.map((proxy, index) => ({
17
+ if (proxiesPage.data.length) {
18
+ const last = (page - 1) * size;
19
+ data = proxiesPage.data.map((proxy, index) => ({
20
20
  '#': last + (index + 1),
21
21
  ...proxy,
22
22
  }));
@@ -54,12 +54,13 @@ const listProxies = async (bt, page) => {
54
54
  }
55
55
  return {
56
56
  data,
57
- pagination: proxies.pagination,
57
+ page,
58
+ hasNextPage: proxiesPage.hasNextPage(),
58
59
  };
59
60
  };
60
61
  const selectProxy = async (bt, page) => {
61
62
  const proxies = await listProxies(bt, page);
62
- if (proxies.pagination.totalItems === 0) {
63
+ if (!proxies.data.length) {
63
64
  return undefined;
64
65
  }
65
66
  const selection = await (0, utils_1.selectOrNavigate)(proxies, '#');
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { CreateProxy as CreateProxyModel, PatchProxy as PatchProxyModel } from '@basis-theory/basis-theory-js/types/models/proxies';
2
+ import type { BasisTheory } from '@basis-theory/node-sdk';
3
3
  declare const PROXY_FLAGS: {
4
4
  name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
5
5
  'destination-url': import("@oclif/core/lib/interfaces/parser").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
@@ -27,8 +27,8 @@ interface ProxyFlagProps {
27
27
  */
28
28
  configuration?: string;
29
29
  }
30
- type CreateProxy = ProxyFlagProps & Omit<CreateProxyModel, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'>;
31
- type PatchProxy = ProxyFlagProps & Omit<PatchProxyModel, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'>;
32
- declare function createModelFromFlags(payload: CreateProxy): CreateProxyModel;
33
- declare function createModelFromFlags(payload: PatchProxy): PatchProxyModel;
30
+ type CreateProxy = ProxyFlagProps & Omit<BasisTheory.CreateProxyRequest, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'>;
31
+ type PatchProxy = ProxyFlagProps & Omit<BasisTheory.PatchProxyRequest, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'>;
32
+ declare function createModelFromFlags(payload: CreateProxy): BasisTheory.CreateProxyRequest;
33
+ declare function createModelFromFlags(payload: PatchProxy): BasisTheory.PatchProxyRequest;
34
34
  export { PROXY_FLAGS, createModelFromFlags };
@@ -1,7 +1,6 @@
1
- import type { Reactor, PatchReactor, CreateReactor } from '@basis-theory/basis-theory-js/types/models';
2
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
3
- declare const selectReactor: (bt: IBasisTheory, page: number) => Promise<Reactor | undefined>;
4
- declare const createReactor: (bt: IBasisTheory, model: CreateReactor) => Promise<Reactor>;
5
- declare const deleteReactor: (bt: IBasisTheory, id: string, force?: boolean) => Promise<boolean>;
6
- declare const patchReactor: (bt: IBasisTheory, id: string, model: PatchReactor) => Promise<void>;
1
+ import type { BasisTheory, BasisTheoryClient } from '@basis-theory/node-sdk';
2
+ declare const selectReactor: (bt: BasisTheoryClient, page: number) => Promise<BasisTheory.Reactor | undefined>;
3
+ declare const createReactor: (bt: BasisTheoryClient, model: BasisTheory.CreateReactorRequest) => Promise<BasisTheory.Reactor>;
4
+ declare const deleteReactor: (bt: BasisTheoryClient, id: string, force?: boolean) => Promise<boolean>;
5
+ declare const patchReactor: (bt: BasisTheoryClient, id: string, model: BasisTheory.PatchReactorRequest) => Promise<void>;
7
6
  export { selectReactor, createReactor, patchReactor, deleteReactor };
@@ -9,14 +9,14 @@ const debug = require('debug')('reactors:management');
9
9
  const listReactors = async (bt, page) => {
10
10
  const size = 5;
11
11
  debug('Listing reactors', `page: ${page}`, `size: ${size}`);
12
- const reactors = await bt.reactors.list({
12
+ const reactorsPage = await bt.reactors.list({
13
13
  size,
14
14
  page,
15
15
  });
16
16
  let data = [];
17
- if (reactors.pagination.totalItems > 0) {
18
- const last = (reactors.pagination.pageNumber - 1) * size;
19
- data = reactors.data.map((reactor, index) => ({
17
+ if (reactorsPage.data.length) {
18
+ const last = (page - 1) * size;
19
+ data = reactorsPage.data.map((reactor, index) => ({
20
20
  '#': last + (index + 1),
21
21
  ...reactor,
22
22
  }));
@@ -31,12 +31,13 @@ const listReactors = async (bt, page) => {
31
31
  }
32
32
  return {
33
33
  data,
34
- pagination: reactors.pagination,
34
+ page,
35
+ hasNextPage: reactorsPage.hasNextPage(),
35
36
  };
36
37
  };
37
38
  const selectReactor = async (bt, page) => {
38
39
  const reactors = await listReactors(bt, page);
39
- if (reactors.pagination.totalItems === 0) {
40
+ if (!reactors.data.length) {
40
41
  return undefined;
41
42
  }
42
43
  const selection = await (0, utils_1.selectOrNavigate)(reactors, '#');
@@ -1,4 +1,4 @@
1
- import type { CreateReactor as CreateReactorModel, PatchReactor as PatchReactorModel } from '@basis-theory/basis-theory-js/types/models/reactors';
1
+ import type { BasisTheory } from '@basis-theory/node-sdk';
2
2
  declare const REACTOR_FLAGS: {
3
3
  name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
4
4
  configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
@@ -19,8 +19,8 @@ interface ReactorFlagProps {
19
19
  */
20
20
  configuration?: string;
21
21
  }
22
- type CreateReactor = ReactorFlagProps & Omit<CreateReactorModel, 'application' | 'configuration'>;
23
- type PatchReactor = ReactorFlagProps & Omit<PatchReactorModel, 'application' | 'configuration'>;
24
- declare function createModelFromFlags(payload: CreateReactor): CreateReactorModel;
25
- declare function createModelFromFlags(payload: PatchReactor): PatchReactorModel;
22
+ type CreateReactor = ReactorFlagProps & Omit<BasisTheory.CreateReactorRequest, 'application' | 'configuration'>;
23
+ type PatchReactor = ReactorFlagProps & Omit<BasisTheory.PatchReactorRequest, 'application' | 'configuration'>;
24
+ declare function createModelFromFlags(payload: CreateReactor): BasisTheory.CreateReactorRequest;
25
+ declare function createModelFromFlags(payload: PatchReactor): BasisTheory.PatchReactorRequest;
26
26
  export { REACTOR_FLAGS, createModelFromFlags };
package/dist/utils.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { PaginatedList } from '@basis-theory/basis-theory-js/types/sdk';
4
3
  import checkbox from '@inquirer/checkbox';
5
4
  import confirm from '@inquirer/confirm';
6
5
  import input from '@inquirer/input';
7
6
  import select from '@inquirer/select';
7
+ interface PaginatedList<T> {
8
+ data: T[];
9
+ page: number;
10
+ hasNextPage: boolean;
11
+ }
8
12
  declare const selectOrNavigate: <T>(list: PaginatedList<T>, prop: string) => Promise<T | "previous" | "next">;
9
13
  declare const promptStringIfUndefined: (value: string | undefined, options: Parameters<typeof input>[0]) => Promise<string>;
10
14
  declare const promptSelectIfUndefined: (value: string | undefined, options: Parameters<typeof select>[0]) => Promise<string>;
@@ -12,4 +16,4 @@ declare const promptCheckboxIfUndefined: (value: string[] | undefined, options:
12
16
  declare const promptUrlIfUndefined: (value: URL | undefined, options: Parameters<typeof input>[0]) => Promise<URL>;
13
17
  declare const promptBooleanIfUndefined: (value: boolean | undefined, options: Parameters<typeof confirm>[0]) => Promise<boolean>;
14
18
  declare const cleanUpOnExit: (action: () => unknown) => typeof process;
15
- export { selectOrNavigate, promptStringIfUndefined, promptSelectIfUndefined, promptCheckboxIfUndefined, promptUrlIfUndefined, promptBooleanIfUndefined, cleanUpOnExit, };
19
+ export { selectOrNavigate, promptStringIfUndefined, promptSelectIfUndefined, promptCheckboxIfUndefined, promptUrlIfUndefined, promptBooleanIfUndefined, cleanUpOnExit, PaginatedList, };
package/dist/utils.js CHANGED
@@ -8,10 +8,10 @@ const input_1 = tslib_1.__importDefault(require("@inquirer/input"));
8
8
  const select_1 = tslib_1.__importDefault(require("@inquirer/select"));
9
9
  const core_1 = require("@oclif/core");
10
10
  const selectOrNavigate = async (list, prop) => {
11
- const { data, pagination } = list;
11
+ const { data, page, hasNextPage } = list;
12
12
  let prompt = `Select one (${prop})`;
13
- const hasNext = pagination.totalPages > pagination.pageNumber;
14
- const hasPrevious = pagination.pageNumber > 1;
13
+ const hasNext = hasNextPage;
14
+ const hasPrevious = page > 1;
15
15
  if (hasPrevious) {
16
16
  prompt += " or 'p' for previous page ";
17
17
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.12.0",
2
+ "version": "2.0.0",
3
3
  "commands": {
4
4
  "applications:create": {
5
5
  "id": "applications:create",
@@ -504,136 +504,6 @@
504
504
  }
505
505
  }
506
506
  },
507
- "reactorFormulas": {
508
- "id": "reactorFormulas",
509
- "description": "[Deprecated] List Reactor Formulas. Requires `reactor:read` Management Application permission",
510
- "strict": true,
511
- "pluginName": "@basis-theory-labs/cli",
512
- "pluginAlias": "@basis-theory-labs/cli",
513
- "pluginType": "core",
514
- "aliases": [],
515
- "examples": [
516
- "<%= config.bin %> <%= command.id %>"
517
- ],
518
- "flags": {
519
- "management-key": {
520
- "name": "management-key",
521
- "type": "option",
522
- "char": "x",
523
- "description": "management key used for connecting with the reactor / proxy",
524
- "required": true,
525
- "multiple": false
526
- },
527
- "api-base-url": {
528
- "name": "api-base-url",
529
- "type": "option",
530
- "description": "base API URL to use in Basis Theory SDK",
531
- "hidden": true,
532
- "multiple": false
533
- },
534
- "page": {
535
- "name": "page",
536
- "type": "option",
537
- "char": "p",
538
- "description": "Reactors formulas list page to fetch",
539
- "multiple": false,
540
- "default": 1
541
- }
542
- },
543
- "args": {}
544
- },
545
- "reactorFormulas:update": {
546
- "id": "reactorFormulas:update",
547
- "description": "[Deprecated] Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission",
548
- "strict": true,
549
- "pluginName": "@basis-theory-labs/cli",
550
- "pluginAlias": "@basis-theory-labs/cli",
551
- "pluginType": "core",
552
- "aliases": [],
553
- "examples": [
554
- "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca",
555
- "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js",
556
- "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w"
557
- ],
558
- "flags": {
559
- "management-key": {
560
- "name": "management-key",
561
- "type": "option",
562
- "char": "x",
563
- "description": "management key used for connecting with the reactor / proxy",
564
- "required": true,
565
- "multiple": false
566
- },
567
- "api-base-url": {
568
- "name": "api-base-url",
569
- "type": "option",
570
- "description": "base API URL to use in Basis Theory SDK",
571
- "hidden": true,
572
- "multiple": false
573
- },
574
- "name": {
575
- "name": "name",
576
- "type": "option",
577
- "char": "n",
578
- "description": "name of the Reactor Formula",
579
- "required": true,
580
- "multiple": false
581
- },
582
- "description": {
583
- "name": "description",
584
- "type": "option",
585
- "char": "d",
586
- "description": "description of the Reactor Formula",
587
- "multiple": false
588
- },
589
- "icon": {
590
- "name": "icon",
591
- "type": "option",
592
- "char": "i",
593
- "description": "icon of the Reactor Formula",
594
- "multiple": false
595
- },
596
- "code": {
597
- "name": "code",
598
- "type": "option",
599
- "char": "s",
600
- "description": "path to JavaScript file containing code",
601
- "required": true,
602
- "multiple": false
603
- },
604
- "configuration": {
605
- "name": "configuration",
606
- "type": "option",
607
- "char": "c",
608
- "description": "path to configuration definition to use in the Reactor Formula",
609
- "required": true,
610
- "multiple": false
611
- },
612
- "request-parameters": {
613
- "name": "request-parameters",
614
- "type": "option",
615
- "char": "p",
616
- "description": "path to request params definition to use in the Reactor Formula",
617
- "required": true,
618
- "multiple": false
619
- },
620
- "watch": {
621
- "name": "watch",
622
- "type": "boolean",
623
- "char": "w",
624
- "description": "Watch for changes in informed files",
625
- "required": false,
626
- "allowNo": false
627
- }
628
- },
629
- "args": {
630
- "id": {
631
- "name": "id",
632
- "description": "Reactor Formula id to update",
633
- "required": true
634
- }
635
- }
636
- },
637
507
  "reactors:create": {
638
508
  "id": "reactors:create",
639
509
  "description": "Creates a new Reactor. Requires `reactor:create` Management Application permission",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory-labs/cli",
3
- "version": "1.12.0",
3
+ "version": "2.0.0",
4
4
  "description": "Basis Theory CLI tool",
5
5
  "author": "Davi Aquino @djejaquino",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "/oclif.manifest.json"
18
18
  ],
19
19
  "dependencies": {
20
- "@basis-theory/basis-theory-js": "^2.7.0",
20
+ "@basis-theory/node-sdk": "^4.4.0",
21
21
  "@inquirer/checkbox": "^1.5.0",
22
22
  "@inquirer/confirm": "^2.0.15",
23
23
  "@inquirer/input": "^1.2.14",
@@ -53,6 +53,7 @@
53
53
  "@types/lodash.groupby": "^4.6.9",
54
54
  "@types/mocha": "^9.0.0",
55
55
  "@types/node": "^16.18.36",
56
+ "@types/sinon": "^21.0.0",
56
57
  "chai": "^4",
57
58
  "eslint": "^7.32.0",
58
59
  "eslint-config-oclif": "^4",
@@ -62,6 +63,7 @@
62
63
  "prettier": "^2.8.8",
63
64
  "semantic-release": "^21.0.5",
64
65
  "shx": "^0.3.3",
66
+ "sinon": "^21.0.1",
65
67
  "ts-node": "^10.9.1",
66
68
  "tslib": "^2.5.3",
67
69
  "typescript": "^4.9.5"
@@ -85,7 +87,6 @@
85
87
  "build": "shx rm -rf dist && tsc -b",
86
88
  "lint": "eslint . --ext .ts --config .eslintrc",
87
89
  "postpack": "shx rm -f oclif.manifest.json",
88
- "posttest": "yarn lint",
89
90
  "prepack": "yarn build && oclif manifest && oclif readme",
90
91
  "version": "yarn build && oclif readme",
91
92
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
@@ -1,10 +0,0 @@
1
- import { BaseCommand } from '../../base';
2
- export default class ReactorFormulas extends BaseCommand {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- page: import("@oclif/core/lib/interfaces/parser").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
- };
8
- static args: {};
9
- run(): Promise<void>;
10
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
4
- const base_1 = require("../../base");
5
- const management_1 = require("../../reactorFormulas/management");
6
- class ReactorFormulas extends base_1.BaseCommand {
7
- async run() {
8
- this.log('WARNING: Reactor Formulas are being deprecated and will be removed in a future release.');
9
- const { bt, flags: { page }, } = await this.parse(ReactorFormulas);
10
- const formula = await (0, management_1.selectReactorFormula)(bt, page);
11
- if (!formula) {
12
- return undefined;
13
- }
14
- return undefined;
15
- }
16
- }
17
- exports.default = ReactorFormulas;
18
- ReactorFormulas.description = '[Deprecated] List Reactor Formulas. Requires `reactor:read` Management Application permission';
19
- ReactorFormulas.examples = ['<%= config.bin %> <%= command.id %>'];
20
- ReactorFormulas.flags = {
21
- page: core_1.Flags.integer({
22
- char: 'p',
23
- description: 'Reactors formulas list page to fetch',
24
- default: 1,
25
- }),
26
- };
27
- ReactorFormulas.args = {};
@@ -1,18 +0,0 @@
1
- import { BaseCommand } from '../../base';
2
- export default class Update extends BaseCommand {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- watch: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
7
- name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- description: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- icon: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
- code: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
- configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
- 'request-parameters': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
- };
14
- static args: {
15
- id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
16
- };
17
- run(): Promise<void>;
18
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
4
- const base_1 = require("../../base");
5
- const files_1 = require("../../files");
6
- const management_1 = require("../../reactorFormulas/management");
7
- const utils_1 = require("../../reactorFormulas/utils");
8
- class Update extends base_1.BaseCommand {
9
- async run() {
10
- this.log('WARNING: Reactor Formulas are being deprecated and will be removed in a future release.');
11
- const { bt, args: { id }, flags: { name, description, code, configuration = '', 'request-parameters': requestParameters = '', watch, }, } = await this.parse(Update);
12
- const model = (0, utils_1.createModelFromFlags)({
13
- name,
14
- description,
15
- type: 'private',
16
- code,
17
- configuration,
18
- requestParameters,
19
- });
20
- await (0, management_1.updateReactorFormula)(bt, id, model);
21
- this.log('Reactor Formula updated successfully!');
22
- if (watch) {
23
- const entries = Object.entries({
24
- code,
25
- configuration,
26
- requestParameters,
27
- }).filter(([, value]) => Boolean(value));
28
- const files = entries.reduce((arr, [, file]) => [...arr, file], []);
29
- if (files.length) {
30
- this.log(`Watching files for changes: ${files.join(', ')} `);
31
- }
32
- entries.forEach(([prop, file]) => {
33
- (0, files_1.watchForChanges)(file, async () => {
34
- core_1.ux.action.start(`Detected change in ${file}. Pushing changes`);
35
- await (0, management_1.updateReactorFormula)(bt, id, (0, utils_1.createModelFromFlags)({
36
- name,
37
- description,
38
- type: 'private',
39
- code,
40
- configuration,
41
- requestParameters,
42
- [prop]: file,
43
- }));
44
- core_1.ux.action.stop('✅\t');
45
- });
46
- });
47
- }
48
- }
49
- }
50
- exports.default = Update;
51
- Update.description = '[Deprecated] Updates an existing Reactor Formula. Requires `reactor:update` Management Application permission';
52
- Update.examples = [
53
- '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
54
- '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js',
55
- '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca --code ./formula.js -w',
56
- ];
57
- Update.flags = {
58
- ...utils_1.REACTOR_FORMULA_FLAGS,
59
- watch: core_1.Flags.boolean({
60
- char: 'w',
61
- description: 'Watch for changes in informed files',
62
- default: false,
63
- required: false,
64
- }),
65
- };
66
- Update.args = {
67
- id: core_1.Args.string({
68
- description: 'Reactor Formula id to update',
69
- required: true,
70
- }),
71
- };
@@ -1,5 +0,0 @@
1
- import type { ReactorFormula, CreateReactorFormula } from '@basis-theory/basis-theory-js/types/models';
2
- import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
3
- declare const selectReactorFormula: (bt: IBasisTheory, page: number) => Promise<ReactorFormula | undefined>;
4
- declare const updateReactorFormula: (bt: IBasisTheory, id: string, model: CreateReactorFormula) => Promise<ReactorFormula>;
5
- export { selectReactorFormula, updateReactorFormula };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateReactorFormula = exports.selectReactorFormula = void 0;
4
- const core_1 = require("@oclif/core");
5
- const utils_1 = require("../utils");
6
- const debug = require('debug')('reactor-formulas:management');
7
- const listReactorFormulas = async (bt, page) => {
8
- const size = 5;
9
- debug('Listing reactor formulas', `page: ${page}`, `size: ${size}`);
10
- const reactorFormulas = await bt.reactorFormulas.list({
11
- size,
12
- page,
13
- });
14
- let data = [];
15
- if (reactorFormulas.pagination.totalItems > 0) {
16
- const last = (reactorFormulas.pagination.pageNumber - 1) * size;
17
- data = reactorFormulas.data.map((reactorFormula, index) => ({
18
- '#': last + (index + 1),
19
- ...reactorFormula,
20
- }));
21
- core_1.ux.table(data, {
22
- '#': {},
23
- id: {},
24
- name: {},
25
- });
26
- }
27
- else {
28
- core_1.ux.log('No reactor formulas found.');
29
- }
30
- return {
31
- data,
32
- pagination: reactorFormulas.pagination,
33
- };
34
- };
35
- const selectReactorFormula = async (bt, page) => {
36
- const reactors = await listReactorFormulas(bt, page);
37
- if (reactors.pagination.totalItems === 0) {
38
- return undefined;
39
- }
40
- const selection = await (0, utils_1.selectOrNavigate)(reactors, '#');
41
- if (selection === 'previous') {
42
- return selectReactorFormula(bt, page - 1);
43
- }
44
- if (selection === 'next') {
45
- return selectReactorFormula(bt, page + 1);
46
- }
47
- return selection;
48
- };
49
- exports.selectReactorFormula = selectReactorFormula;
50
- const updateReactorFormula = (bt, id, model) => {
51
- debug(`Updating Reactor Formula ${id}`, JSON.stringify(model, undefined, 2));
52
- return bt.reactorFormulas.update(id, model);
53
- };
54
- exports.updateReactorFormula = updateReactorFormula;
@@ -1,26 +0,0 @@
1
- import type { CreateReactorFormula as CreateReactorFormulaModel } from '@basis-theory/basis-theory-js/types/models/reactor-formulas';
2
- declare const REACTOR_FORMULA_FLAGS: {
3
- name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
4
- description: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
5
- icon: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
- code: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
- configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- 'request-parameters': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- };
10
- interface ReactorFormulaFlagProps {
11
- /**
12
- * Path to code file
13
- */
14
- code?: string;
15
- /**
16
- * Path to code file
17
- */
18
- requestParameters: string;
19
- /**
20
- * Path to .env file
21
- */
22
- configuration: string;
23
- }
24
- type CreateReactorFormula = ReactorFormulaFlagProps & Omit<CreateReactorFormulaModel, 'configuration' | 'requestParameters' | 'code'>;
25
- declare function createModelFromFlags(payload: CreateReactorFormula): CreateReactorFormulaModel;
26
- export { REACTOR_FORMULA_FLAGS, createModelFromFlags };
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createModelFromFlags = exports.REACTOR_FORMULA_FLAGS = void 0;
4
- const core_1 = require("@oclif/core");
5
- const files_1 = require("../files");
6
- const REACTOR_FORMULA_FLAGS = {
7
- name: core_1.Flags.string({
8
- char: 'n',
9
- description: 'name of the Reactor Formula',
10
- required: true,
11
- }),
12
- description: core_1.Flags.string({
13
- char: 'd',
14
- description: 'description of the Reactor Formula',
15
- }),
16
- icon: core_1.Flags.string({
17
- char: 'i',
18
- description: 'icon of the Reactor Formula',
19
- }),
20
- code: core_1.Flags.file({
21
- char: 's',
22
- description: 'path to JavaScript file containing code',
23
- required: true,
24
- }),
25
- configuration: core_1.Flags.file({
26
- char: 'c',
27
- description: 'path to configuration definition to use in the Reactor Formula',
28
- required: true,
29
- }),
30
- 'request-parameters': core_1.Flags.file({
31
- char: 'p',
32
- description: 'path to request params definition to use in the Reactor Formula',
33
- required: true,
34
- }),
35
- };
36
- exports.REACTOR_FORMULA_FLAGS = REACTOR_FORMULA_FLAGS;
37
- // eslint-disable-next-line get-off-my-lawn/prefer-arrow-functions
38
- function createModelFromFlags({ name, description, icon, code, type, configuration, requestParameters, }) {
39
- return {
40
- name,
41
- description,
42
- icon,
43
- type,
44
- code: code ? (0, files_1.readFileContents)(code) : '',
45
- configuration: JSON.parse((0, files_1.readFileContents)(configuration)),
46
- requestParameters: JSON.parse((0, files_1.readFileContents)(requestParameters)),
47
- };
48
- }
49
- exports.createModelFromFlags = createModelFromFlags;