@basis-theory-labs/cli 1.8.0 → 1.9.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.8.0 linux-x64 node-v18.18.0
22
+ @basis-theory-labs/cli/1.9.0 linux-x64 node-v18.18.2
23
23
  $ bt --help [COMMAND]
24
24
  USAGE
25
25
  $ bt COMMAND
@@ -28,6 +28,10 @@ USAGE
28
28
  <!-- usagestop -->
29
29
  # Commands
30
30
  <!-- commands -->
31
+ * [`bt applications`](#bt-applications)
32
+ * [`bt applications create`](#bt-applications-create)
33
+ * [`bt applications delete ID`](#bt-applications-delete-id)
34
+ * [`bt applications update ID`](#bt-applications-update-id)
31
35
  * [`bt proxies`](#bt-proxies)
32
36
  * [`bt proxies create`](#bt-proxies-create)
33
37
  * [`bt proxies delete ID`](#bt-proxies-delete-id)
@@ -41,6 +45,94 @@ USAGE
41
45
  * [`bt reactors logs [ID]`](#bt-reactors-logs-id)
42
46
  * [`bt reactors update ID`](#bt-reactors-update-id)
43
47
 
48
+ ## `bt applications`
49
+
50
+ List Applications. Requires `application:read` Management Application permission
51
+
52
+ ```
53
+ USAGE
54
+ $ bt applications -x <value> [-p <value>]
55
+
56
+ FLAGS
57
+ -p, --page=<value> [default: 1] Applications list page to fetch
58
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
59
+
60
+ DESCRIPTION
61
+ List Applications. Requires `application:read` Management Application permission
62
+
63
+ EXAMPLES
64
+ $ bt applications
65
+ ```
66
+
67
+ _See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.9.0/dist/commands/applications/index.ts)_
68
+
69
+ ## `bt applications create`
70
+
71
+ Creates a new Application. Requires `application:create` Management Application permission
72
+
73
+ ```
74
+ USAGE
75
+ $ bt applications create -x <value> [-n <value>] [-p <value>] [-t private|public|management]
76
+
77
+ FLAGS
78
+ -n, --name=<value> name of the Application
79
+ -p, --permission=<value>... permission(s) to use in the Application
80
+ -t, --type=<option> type of the Application
81
+ <options: private|public|management>
82
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
83
+
84
+ DESCRIPTION
85
+ Creates a new Application. Requires `application:create` Management Application permission
86
+
87
+ EXAMPLES
88
+ $ bt applications create
89
+ ```
90
+
91
+ ## `bt applications delete ID`
92
+
93
+ Deletes a Application. Requires `application:delete` Management Application permissions
94
+
95
+ ```
96
+ USAGE
97
+ $ bt applications delete ID -x <value> [-y]
98
+
99
+ ARGUMENTS
100
+ ID Application id to delete
101
+
102
+ FLAGS
103
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
104
+ -y, --yes auto confirm the operation
105
+
106
+ DESCRIPTION
107
+ Deletes a Application. Requires `application:delete` Management Application permissions
108
+
109
+ EXAMPLES
110
+ $ bt applications delete 03858bf5-32d3-4a2e-b74b-daeea0883bca
111
+ ```
112
+
113
+ ## `bt applications update ID`
114
+
115
+ Updates a new Application. Requires `application:update` Management Application permission
116
+
117
+ ```
118
+ USAGE
119
+ $ bt applications update ID -x <value> [-n <value>] [-p <value>]
120
+
121
+ ARGUMENTS
122
+ ID Application id to update
123
+
124
+ FLAGS
125
+ -n, --name=<value> name of the Application
126
+ -p, --permission=<value>... permission(s) to use in the Application
127
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
128
+
129
+ DESCRIPTION
130
+ Updates a new Application. Requires `application:update` Management Application permission
131
+
132
+ EXAMPLES
133
+ $ bt applications update
134
+ ```
135
+
44
136
  ## `bt proxies`
45
137
 
46
138
  List Proxies. Requires `proxy:read` Management Application permission
@@ -50,7 +142,7 @@ USAGE
50
142
  $ bt proxies -x <value> [-p <value>]
51
143
 
52
144
  FLAGS
53
- -p, --page=<value> [default: 1] proxies list page to fetch
145
+ -p, --page=<value> [default: 1] Proxies list page to fetch
54
146
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
55
147
 
56
148
  DESCRIPTION
@@ -60,7 +152,7 @@ EXAMPLES
60
152
  $ bt proxies
61
153
  ```
62
154
 
63
- _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.8.0/dist/commands/proxies/index.ts)_
155
+ _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.9.0/dist/commands/proxies/index.ts)_
64
156
 
65
157
  ## `bt proxies create`
66
158
 
@@ -90,7 +182,7 @@ EXAMPLES
90
182
 
91
183
  ## `bt proxies delete ID`
92
184
 
93
- Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions
185
+ Deletes a Proxy. Requires `proxy:delete` Management Application permissions
94
186
 
95
187
  ```
96
188
  USAGE
@@ -104,7 +196,7 @@ FLAGS
104
196
  -y, --yes auto confirm the operation
105
197
 
106
198
  DESCRIPTION
107
- Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions
199
+ Deletes a Proxy. Requires `proxy:delete` Management Application permissions
108
200
 
109
201
  EXAMPLES
110
202
  $ bt proxies delete 03858bf5-32d3-4a2e-b74b-daeea0883bca
@@ -183,7 +275,7 @@ USAGE
183
275
  $ bt reactorFormulas -x <value> [-p <value>]
184
276
 
185
277
  FLAGS
186
- -p, --page=<value> [default: 1] reactors formulas list page to fetch
278
+ -p, --page=<value> [default: 1] Reactors formulas list page to fetch
187
279
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
188
280
 
189
281
  DESCRIPTION
@@ -193,7 +285,7 @@ EXAMPLES
193
285
  $ bt reactorFormulas
194
286
  ```
195
287
 
196
- _See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.8.0/dist/commands/reactorFormulas/index.ts)_
288
+ _See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.9.0/dist/commands/reactorFormulas/index.ts)_
197
289
 
198
290
  ## `bt reactorFormulas update ID`
199
291
 
@@ -236,7 +328,7 @@ USAGE
236
328
  $ bt reactors -x <value> [-p <value>]
237
329
 
238
330
  FLAGS
239
- -p, --page=<value> [default: 1] reactors list page to fetch
331
+ -p, --page=<value> [default: 1] Reactors list page to fetch
240
332
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
241
333
 
242
334
  DESCRIPTION
@@ -246,7 +338,7 @@ EXAMPLES
246
338
  $ bt reactors
247
339
  ```
248
340
 
249
- _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.8.0/dist/commands/reactors/index.ts)_
341
+ _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.9.0/dist/commands/reactors/index.ts)_
250
342
 
251
343
  ## `bt reactors create`
252
344
 
@@ -272,7 +364,7 @@ EXAMPLES
272
364
 
273
365
  ## `bt reactors delete ID`
274
366
 
275
- Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions
367
+ Deletes a Reactor. Requires `reactor:delete` Management Application permissions
276
368
 
277
369
  ```
278
370
  USAGE
@@ -286,7 +378,7 @@ FLAGS
286
378
  -y, --yes auto confirm the operation
287
379
 
288
380
  DESCRIPTION
289
- Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions
381
+ Deletes a Reactor. Requires `reactor:delete` Management Application permissions
290
382
 
291
383
  EXAMPLES
292
384
  $ bt reactors delete 03858bf5-32d3-4a2e-b74b-daeea0883bca
@@ -0,0 +1,8 @@
1
+ import type { Application, ApplicationType, CreateApplication, Permission, UpdateApplication } 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 listPermissions: (bt: IBasisTheory, type: ApplicationType) => Promise<Permission[]>;
4
+ declare const selectApplication: (bt: IBasisTheory, page: number) => Promise<Application | undefined>;
5
+ declare const createApplication: (bt: IBasisTheory, model: CreateApplication) => Promise<Application>;
6
+ declare const updateApplication: (bt: IBasisTheory, id: string, model: UpdateApplication) => Promise<Application>;
7
+ declare const deleteApplication: (bt: IBasisTheory, id: string, force?: boolean) => Promise<boolean>;
8
+ export { listPermissions, createApplication, updateApplication, selectApplication, deleteApplication, };
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteApplication = exports.selectApplication = exports.updateApplication = exports.createApplication = exports.listPermissions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const confirm_1 = tslib_1.__importDefault(require("@inquirer/confirm"));
6
+ const core_1 = require("@oclif/core");
7
+ const utils_1 = require("../utils");
8
+ const debug = require('debug')('applications:management');
9
+ const listPermissions = (bt, type) => bt.permissions
10
+ .list({
11
+ applicationType: type,
12
+ })
13
+ .then((permissions) => permissions.sort((p1, p2) => p1.type.localeCompare(p2.type)));
14
+ exports.listPermissions = listPermissions;
15
+ const listApplications = async (bt, page) => {
16
+ const size = 5;
17
+ debug('Listing applications', `page: ${page}`, `size: ${size}`);
18
+ const applications = await bt.applications.list({
19
+ size,
20
+ page,
21
+ });
22
+ let data = [];
23
+ if (applications.pagination.totalItems > 0) {
24
+ const last = (applications.pagination.pageNumber - 1) * size;
25
+ data = applications.data.map((application, index) => ({
26
+ '#': last + (index + 1),
27
+ ...application,
28
+ }));
29
+ core_1.ux.table(data, {
30
+ '#': {},
31
+ id: {},
32
+ name: {},
33
+ type: {},
34
+ });
35
+ }
36
+ else {
37
+ core_1.ux.log('No applications found.');
38
+ }
39
+ return {
40
+ data,
41
+ pagination: applications.pagination,
42
+ };
43
+ };
44
+ const retrieveApplication = (bt, id) => {
45
+ debug(`Retrieving Application ${id}`);
46
+ return bt.applications.retrieve(id);
47
+ };
48
+ const selectApplication = async (bt, page) => {
49
+ const applications = await listApplications(bt, page);
50
+ if (applications.pagination.totalItems === 0) {
51
+ return undefined;
52
+ }
53
+ const selection = await (0, utils_1.selectOrNavigate)(applications, '#');
54
+ if (selection === 'previous') {
55
+ return selectApplication(bt, page - 1);
56
+ }
57
+ if (selection === 'next') {
58
+ return selectApplication(bt, page + 1);
59
+ }
60
+ return selection;
61
+ };
62
+ exports.selectApplication = selectApplication;
63
+ const createApplication = (bt, model) => {
64
+ debug('Creating Application', JSON.stringify(model, undefined, 2));
65
+ return bt.applications.create(model);
66
+ };
67
+ exports.createApplication = createApplication;
68
+ const updateApplication = async (bt, id, model) => {
69
+ const application = await retrieveApplication(bt, id);
70
+ debug(`Updating Application ${id}`, JSON.stringify(model, undefined, 2));
71
+ return bt.applications.update(id, {
72
+ name: model.name || application.name,
73
+ permissions: model.permissions || application.permissions,
74
+ rules: model.permissions ? undefined : application.rules, // if permissions were passed, overwrite rules
75
+ });
76
+ };
77
+ exports.updateApplication = updateApplication;
78
+ const deleteApplication = async (bt, id, force = false) => {
79
+ if (!force) {
80
+ const proceed = await (0, confirm_1.default)({
81
+ message: `Are you sure you want to delete this Application (${id})?`,
82
+ default: false,
83
+ });
84
+ if (!proceed) {
85
+ return false;
86
+ }
87
+ }
88
+ debug(`Deleting Application`, id);
89
+ await bt.applications.delete(id);
90
+ return true;
91
+ };
92
+ exports.deleteApplication = deleteApplication;
@@ -0,0 +1,5 @@
1
+ declare const APPLICATION_FLAGS: {
2
+ name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
3
+ permission: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
4
+ };
5
+ export { APPLICATION_FLAGS };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APPLICATION_FLAGS = void 0;
4
+ const core_1 = require("@oclif/core");
5
+ const APPLICATION_FLAGS = {
6
+ name: core_1.Flags.string({
7
+ char: 'n',
8
+ description: 'name of the Application',
9
+ }),
10
+ permission: core_1.Flags.string({
11
+ char: 'p',
12
+ description: 'permission(s) to use in the Application',
13
+ multiple: true,
14
+ }),
15
+ };
16
+ exports.APPLICATION_FLAGS = APPLICATION_FLAGS;
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class Create extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ type: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ permission: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const models_1 = require("@basis-theory/basis-theory-js/types/models");
4
+ const core_1 = require("@oclif/core");
5
+ const management_1 = require("../../applications/management");
6
+ const utils_1 = require("../../applications/utils");
7
+ const base_1 = require("../../base");
8
+ const utils_2 = require("../../utils");
9
+ class Create extends base_1.BaseCommand {
10
+ async run() {
11
+ const { flags, bt } = await this.parse(Create);
12
+ const name = await (0, utils_2.promptStringIfUndefined)(flags.name, {
13
+ message: 'What is the Application name?',
14
+ validate: (value) => Boolean(value),
15
+ });
16
+ const type = (await (0, utils_2.promptSelectIfUndefined)(flags.type, {
17
+ message: 'What is the Application type?',
18
+ choices: models_1.APPLICATION_TYPES.map((t) => ({ value: t })),
19
+ }));
20
+ const available = await (0, management_1.listPermissions)(bt, type);
21
+ const permissions = await (0, utils_2.promptCheckboxIfUndefined)(flags.permission, {
22
+ message: 'Select the permissions for the Application',
23
+ choices: available.map((p) => ({
24
+ value: p.type,
25
+ })),
26
+ loop: false,
27
+ });
28
+ const { id, key } = await (0, management_1.createApplication)(bt, {
29
+ name,
30
+ type,
31
+ permissions,
32
+ });
33
+ this.log('Application created successfully!');
34
+ this.log(`id: ${id}`);
35
+ this.log(`key: ${key}`);
36
+ }
37
+ }
38
+ exports.default = Create;
39
+ Create.description = 'Creates a new Application. Requires `application:create` Management Application permission';
40
+ Create.examples = ['<%= config.bin %> <%= command.id %> '];
41
+ Create.flags = {
42
+ ...utils_1.APPLICATION_FLAGS,
43
+ type: core_1.Flags.string({
44
+ char: 't',
45
+ description: 'type of the Application',
46
+ options: [...models_1.APPLICATION_TYPES],
47
+ }),
48
+ };
@@ -0,0 +1,12 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class Delete extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ yes: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const management_1 = require("../../applications/management");
5
+ const base_1 = require("../../base");
6
+ class Delete extends base_1.BaseCommand {
7
+ async run() {
8
+ const { bt, flags: { yes }, args: { id }, } = await this.parse(Delete);
9
+ if (await (0, management_1.deleteApplication)(bt, id, yes)) {
10
+ this.log('Application deleted successfully!');
11
+ }
12
+ }
13
+ }
14
+ exports.default = Delete;
15
+ Delete.description = 'Deletes a Application. Requires `application:delete` Management Application permissions';
16
+ Delete.examples = [
17
+ '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
18
+ ];
19
+ Delete.args = {
20
+ id: core_1.Args.string({
21
+ description: 'Application id to delete',
22
+ required: true,
23
+ }),
24
+ };
25
+ Delete.flags = {
26
+ yes: core_1.Flags.boolean({
27
+ char: 'y',
28
+ description: 'auto confirm the operation',
29
+ default: false,
30
+ allowNo: false,
31
+ }),
32
+ };
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class Applications 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
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const select_1 = tslib_1.__importDefault(require("@inquirer/select"));
5
+ const core_1 = require("@oclif/core");
6
+ const management_1 = require("../../applications/management");
7
+ const base_1 = require("../../base");
8
+ class Applications extends base_1.BaseCommand {
9
+ async run() {
10
+ const { bt, flags: { page }, } = await this.parse(Applications);
11
+ const application = await (0, management_1.selectApplication)(bt, page);
12
+ if (!application) {
13
+ return undefined;
14
+ }
15
+ const action = await (0, select_1.default)({
16
+ message: 'Select action to perform',
17
+ choices: [
18
+ {
19
+ name: 'See details',
20
+ value: 'details',
21
+ },
22
+ {
23
+ name: 'Delete',
24
+ value: 'delete',
25
+ },
26
+ ],
27
+ });
28
+ if (action === 'details') {
29
+ this.logJson(application);
30
+ return undefined;
31
+ }
32
+ if (action === 'delete' && (await (0, management_1.deleteApplication)(bt, application.id))) {
33
+ return this.log('Application deleted successfully!');
34
+ }
35
+ return undefined;
36
+ }
37
+ }
38
+ exports.default = Applications;
39
+ Applications.description = 'List Applications. Requires `application:read` Management Application permission';
40
+ Applications.examples = ['<%= config.bin %> <%= command.id %>'];
41
+ Applications.flags = {
42
+ page: core_1.Flags.integer({
43
+ char: 'p',
44
+ description: 'Applications list page to fetch',
45
+ default: 1,
46
+ }),
47
+ };
@@ -0,0 +1,13 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class Update extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ permission: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ };
9
+ static args: {
10
+ id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const management_1 = require("../../applications/management");
5
+ const utils_1 = require("../../applications/utils");
6
+ const base_1 = require("../../base");
7
+ class Update extends base_1.BaseCommand {
8
+ async run() {
9
+ const { bt, args: { id }, flags: { name, permission: permissions }, } = await this.parse(Update);
10
+ await (0, management_1.updateApplication)(bt, id, {
11
+ name,
12
+ permissions,
13
+ });
14
+ this.log('Application updated successfully!');
15
+ }
16
+ }
17
+ exports.default = Update;
18
+ Update.description = 'Updates a new Application. Requires `application:update` Management Application permission';
19
+ Update.examples = ['<%= config.bin %> <%= command.id %> '];
20
+ Update.flags = {
21
+ ...utils_1.APPLICATION_FLAGS,
22
+ };
23
+ Update.args = {
24
+ id: core_1.Args.string({
25
+ description: 'Application id to update',
26
+ required: true,
27
+ }),
28
+ };
@@ -12,7 +12,7 @@ class Delete extends base_1.BaseCommand {
12
12
  }
13
13
  }
14
14
  exports.default = Delete;
15
- Delete.description = 'Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions';
15
+ Delete.description = 'Deletes a Proxy. Requires `proxy:delete` Management Application permissions';
16
16
  Delete.examples = [
17
17
  '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
18
18
  ];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const prompts_1 = require("@inquirer/prompts");
3
+ const tslib_1 = require("tslib");
4
+ const select_1 = tslib_1.__importDefault(require("@inquirer/select"));
4
5
  const core_1 = require("@oclif/core");
5
6
  const base_1 = require("../../base");
6
7
  const logs_1 = require("../../logs");
@@ -12,7 +13,7 @@ class Proxies extends base_1.BaseCommand {
12
13
  if (!proxy) {
13
14
  return undefined;
14
15
  }
15
- const action = await (0, prompts_1.select)({
16
+ const action = await (0, select_1.default)({
16
17
  message: 'Select action to perform',
17
18
  choices: [
18
19
  {
@@ -49,7 +50,7 @@ Proxies.examples = ['<%= config.bin %> <%= command.id %>'];
49
50
  Proxies.flags = {
50
51
  page: core_1.Flags.integer({
51
52
  char: 'p',
52
- description: 'proxies list page to fetch',
53
+ description: 'Proxies list page to fetch',
53
54
  default: 1,
54
55
  }),
55
56
  };
@@ -20,7 +20,7 @@ ReactorFormulas.examples = ['<%= config.bin %> <%= command.id %>'];
20
20
  ReactorFormulas.flags = {
21
21
  page: core_1.Flags.integer({
22
22
  char: 'p',
23
- description: 'reactors formulas list page to fetch',
23
+ description: 'Reactors formulas list page to fetch',
24
24
  default: 1,
25
25
  }),
26
26
  };
@@ -12,7 +12,7 @@ class Delete extends base_1.BaseCommand {
12
12
  }
13
13
  }
14
14
  exports.default = Delete;
15
- Delete.description = 'Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions';
15
+ Delete.description = 'Deletes a Reactor. Requires `reactor:delete` Management Application permissions';
16
16
  Delete.examples = [
17
17
  '<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
18
18
  ];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const prompts_1 = require("@inquirer/prompts");
3
+ const tslib_1 = require("tslib");
4
+ const select_1 = tslib_1.__importDefault(require("@inquirer/select"));
4
5
  const core_1 = require("@oclif/core");
5
6
  const base_1 = require("../../base");
6
7
  const logs_1 = require("../../logs");
@@ -12,7 +13,7 @@ class Reactors extends base_1.BaseCommand {
12
13
  if (!reactor) {
13
14
  return undefined;
14
15
  }
15
- const action = await (0, prompts_1.select)({
16
+ const action = await (0, select_1.default)({
16
17
  message: 'Select action to perform',
17
18
  choices: [
18
19
  {
@@ -49,7 +50,7 @@ Reactors.examples = ['<%= config.bin %> <%= command.id %>'];
49
50
  Reactors.flags = {
50
51
  page: core_1.Flags.integer({
51
52
  char: 'p',
52
- description: 'reactors list page to fetch',
53
+ description: 'Reactors list page to fetch',
53
54
  default: 1,
54
55
  }),
55
56
  };
package/dist/utils.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import { PaginatedList } from '@basis-theory/basis-theory-js/types/sdk';
4
+ import checkbox from '@inquirer/checkbox';
4
5
  import confirm from '@inquirer/confirm';
5
6
  import input from '@inquirer/input';
7
+ import select from '@inquirer/select';
6
8
  declare const selectOrNavigate: <T>(list: PaginatedList<T>, prop: string) => Promise<T | "previous" | "next">;
7
9
  declare const promptStringIfUndefined: (value: string | undefined, options: Parameters<typeof input>[0]) => Promise<string>;
10
+ declare const promptSelectIfUndefined: (value: string | undefined, options: Parameters<typeof select>[0]) => Promise<string>;
11
+ declare const promptCheckboxIfUndefined: (value: string[] | undefined, options: Parameters<typeof checkbox>[0]) => Promise<string[]>;
8
12
  declare const promptUrlIfUndefined: (value: URL | undefined, options: Parameters<typeof input>[0]) => Promise<URL>;
9
13
  declare const promptBooleanIfUndefined: (value: boolean | undefined, options: Parameters<typeof confirm>[0]) => Promise<boolean>;
10
14
  declare const cleanUpOnExit: (action: () => unknown) => typeof process;
11
- export { selectOrNavigate, promptStringIfUndefined, promptUrlIfUndefined, promptBooleanIfUndefined, cleanUpOnExit, };
15
+ export { selectOrNavigate, promptStringIfUndefined, promptSelectIfUndefined, promptCheckboxIfUndefined, promptUrlIfUndefined, promptBooleanIfUndefined, cleanUpOnExit, };
package/dist/utils.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanUpOnExit = exports.promptBooleanIfUndefined = exports.promptUrlIfUndefined = exports.promptStringIfUndefined = exports.selectOrNavigate = void 0;
3
+ exports.cleanUpOnExit = exports.promptBooleanIfUndefined = exports.promptUrlIfUndefined = exports.promptCheckboxIfUndefined = exports.promptSelectIfUndefined = exports.promptStringIfUndefined = exports.selectOrNavigate = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const checkbox_1 = tslib_1.__importDefault(require("@inquirer/checkbox"));
5
6
  const confirm_1 = tslib_1.__importDefault(require("@inquirer/confirm"));
6
7
  const input_1 = tslib_1.__importDefault(require("@inquirer/input"));
8
+ const select_1 = tslib_1.__importDefault(require("@inquirer/select"));
7
9
  const core_1 = require("@oclif/core");
8
10
  const selectOrNavigate = async (list, prop) => {
9
11
  const { data, pagination } = list;
@@ -40,6 +42,20 @@ const promptStringIfUndefined = (value, options) => {
40
42
  return (0, input_1.default)(options);
41
43
  };
42
44
  exports.promptStringIfUndefined = promptStringIfUndefined;
45
+ const promptSelectIfUndefined = (value, options) => {
46
+ if (value) {
47
+ return Promise.resolve(value);
48
+ }
49
+ return (0, select_1.default)(options);
50
+ };
51
+ exports.promptSelectIfUndefined = promptSelectIfUndefined;
52
+ const promptCheckboxIfUndefined = (value, options) => {
53
+ if (value) {
54
+ return Promise.resolve(value);
55
+ }
56
+ return (0, checkbox_1.default)(options);
57
+ };
58
+ exports.promptCheckboxIfUndefined = promptCheckboxIfUndefined;
43
59
  const promptUrlIfUndefined = async (value, options) => {
44
60
  if (value) {
45
61
  return Promise.resolve(value);
@@ -1,6 +1,193 @@
1
1
  {
2
- "version": "1.8.0",
2
+ "version": "1.9.0",
3
3
  "commands": {
4
+ "applications:create": {
5
+ "id": "applications:create",
6
+ "description": "Creates a new Application. Requires `application:create` Management Application permission",
7
+ "strict": true,
8
+ "pluginName": "@basis-theory-labs/cli",
9
+ "pluginAlias": "@basis-theory-labs/cli",
10
+ "pluginType": "core",
11
+ "aliases": [],
12
+ "examples": [
13
+ "<%= config.bin %> <%= command.id %> "
14
+ ],
15
+ "flags": {
16
+ "management-key": {
17
+ "name": "management-key",
18
+ "type": "option",
19
+ "char": "x",
20
+ "description": "management key used for connecting with the reactor / proxy",
21
+ "required": true,
22
+ "multiple": false
23
+ },
24
+ "api-base-url": {
25
+ "name": "api-base-url",
26
+ "type": "option",
27
+ "description": "base API URL to use in Basis Theory SDK",
28
+ "hidden": true,
29
+ "multiple": false
30
+ },
31
+ "name": {
32
+ "name": "name",
33
+ "type": "option",
34
+ "char": "n",
35
+ "description": "name of the Application",
36
+ "multiple": false
37
+ },
38
+ "permission": {
39
+ "name": "permission",
40
+ "type": "option",
41
+ "char": "p",
42
+ "description": "permission(s) to use in the Application",
43
+ "multiple": true
44
+ },
45
+ "type": {
46
+ "name": "type",
47
+ "type": "option",
48
+ "char": "t",
49
+ "description": "type of the Application",
50
+ "multiple": false,
51
+ "options": [
52
+ "private",
53
+ "public",
54
+ "management"
55
+ ]
56
+ }
57
+ },
58
+ "args": {}
59
+ },
60
+ "applications:delete": {
61
+ "id": "applications:delete",
62
+ "description": "Deletes a Application. Requires `application:delete` Management Application permissions",
63
+ "strict": true,
64
+ "pluginName": "@basis-theory-labs/cli",
65
+ "pluginAlias": "@basis-theory-labs/cli",
66
+ "pluginType": "core",
67
+ "aliases": [],
68
+ "examples": [
69
+ "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca"
70
+ ],
71
+ "flags": {
72
+ "management-key": {
73
+ "name": "management-key",
74
+ "type": "option",
75
+ "char": "x",
76
+ "description": "management key used for connecting with the reactor / proxy",
77
+ "required": true,
78
+ "multiple": false
79
+ },
80
+ "api-base-url": {
81
+ "name": "api-base-url",
82
+ "type": "option",
83
+ "description": "base API URL to use in Basis Theory SDK",
84
+ "hidden": true,
85
+ "multiple": false
86
+ },
87
+ "yes": {
88
+ "name": "yes",
89
+ "type": "boolean",
90
+ "char": "y",
91
+ "description": "auto confirm the operation",
92
+ "allowNo": false
93
+ }
94
+ },
95
+ "args": {
96
+ "id": {
97
+ "name": "id",
98
+ "description": "Application id to delete",
99
+ "required": true
100
+ }
101
+ }
102
+ },
103
+ "applications": {
104
+ "id": "applications",
105
+ "description": "List Applications. Requires `application:read` Management Application permission",
106
+ "strict": true,
107
+ "pluginName": "@basis-theory-labs/cli",
108
+ "pluginAlias": "@basis-theory-labs/cli",
109
+ "pluginType": "core",
110
+ "aliases": [],
111
+ "examples": [
112
+ "<%= config.bin %> <%= command.id %>"
113
+ ],
114
+ "flags": {
115
+ "management-key": {
116
+ "name": "management-key",
117
+ "type": "option",
118
+ "char": "x",
119
+ "description": "management key used for connecting with the reactor / proxy",
120
+ "required": true,
121
+ "multiple": false
122
+ },
123
+ "api-base-url": {
124
+ "name": "api-base-url",
125
+ "type": "option",
126
+ "description": "base API URL to use in Basis Theory SDK",
127
+ "hidden": true,
128
+ "multiple": false
129
+ },
130
+ "page": {
131
+ "name": "page",
132
+ "type": "option",
133
+ "char": "p",
134
+ "description": "Applications list page to fetch",
135
+ "multiple": false,
136
+ "default": 1
137
+ }
138
+ },
139
+ "args": {}
140
+ },
141
+ "applications:update": {
142
+ "id": "applications:update",
143
+ "description": "Updates a new Application. Requires `application:update` Management Application permission",
144
+ "strict": true,
145
+ "pluginName": "@basis-theory-labs/cli",
146
+ "pluginAlias": "@basis-theory-labs/cli",
147
+ "pluginType": "core",
148
+ "aliases": [],
149
+ "examples": [
150
+ "<%= config.bin %> <%= command.id %> "
151
+ ],
152
+ "flags": {
153
+ "management-key": {
154
+ "name": "management-key",
155
+ "type": "option",
156
+ "char": "x",
157
+ "description": "management key used for connecting with the reactor / proxy",
158
+ "required": true,
159
+ "multiple": false
160
+ },
161
+ "api-base-url": {
162
+ "name": "api-base-url",
163
+ "type": "option",
164
+ "description": "base API URL to use in Basis Theory SDK",
165
+ "hidden": true,
166
+ "multiple": false
167
+ },
168
+ "name": {
169
+ "name": "name",
170
+ "type": "option",
171
+ "char": "n",
172
+ "description": "name of the Application",
173
+ "multiple": false
174
+ },
175
+ "permission": {
176
+ "name": "permission",
177
+ "type": "option",
178
+ "char": "p",
179
+ "description": "permission(s) to use in the Application",
180
+ "multiple": true
181
+ }
182
+ },
183
+ "args": {
184
+ "id": {
185
+ "name": "id",
186
+ "description": "Application id to update",
187
+ "required": true
188
+ }
189
+ }
190
+ },
4
191
  "proxies:create": {
5
192
  "id": "proxies:create",
6
193
  "description": "Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission",
@@ -82,7 +269,7 @@
82
269
  },
83
270
  "proxies:delete": {
84
271
  "id": "proxies:delete",
85
- "description": "Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions",
272
+ "description": "Deletes a Proxy. Requires `proxy:delete` Management Application permissions",
86
273
  "strict": true,
87
274
  "pluginName": "@basis-theory-labs/cli",
88
275
  "pluginAlias": "@basis-theory-labs/cli",
@@ -154,7 +341,7 @@
154
341
  "name": "page",
155
342
  "type": "option",
156
343
  "char": "p",
157
- "description": "proxies list page to fetch",
344
+ "description": "Proxies list page to fetch",
158
345
  "multiple": false,
159
346
  "default": 1
160
347
  }
@@ -341,7 +528,7 @@
341
528
  "name": "page",
342
529
  "type": "option",
343
530
  "char": "p",
344
- "description": "reactors formulas list page to fetch",
531
+ "description": "Reactors formulas list page to fetch",
345
532
  "multiple": false,
346
533
  "default": 1
347
534
  }
@@ -500,7 +687,7 @@
500
687
  },
501
688
  "reactors:delete": {
502
689
  "id": "reactors:delete",
503
- "description": "Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions",
690
+ "description": "Deletes a Reactor. Requires `reactor:delete` Management Application permissions",
504
691
  "strict": true,
505
692
  "pluginName": "@basis-theory-labs/cli",
506
693
  "pluginAlias": "@basis-theory-labs/cli",
@@ -572,7 +759,7 @@
572
759
  "name": "page",
573
760
  "type": "option",
574
761
  "char": "p",
575
- "description": "reactors list page to fetch",
762
+ "description": "Reactors list page to fetch",
576
763
  "multiple": false,
577
764
  "default": 1
578
765
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory-labs/cli",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Basis Theory CLI tool",
5
5
  "author": "Davi Aquino @djejaquino",
6
6
  "bin": {
@@ -17,11 +17,11 @@
17
17
  "/oclif.manifest.json"
18
18
  ],
19
19
  "dependencies": {
20
- "@basis-theory/basis-theory-js": "^2.3.1",
21
- "@inquirer/confirm": "^2.0.3",
22
- "@inquirer/input": "^1.2.1",
23
- "@inquirer/prompts": "^2.1.1",
24
- "@inquirer/select": "^1.2.1",
20
+ "@basis-theory/basis-theory-js": "^2.4.0",
21
+ "@inquirer/checkbox": "^1.5.0",
22
+ "@inquirer/confirm": "^2.0.15",
23
+ "@inquirer/input": "^1.2.14",
24
+ "@inquirer/select": "^1.3.1",
25
25
  "@oclif/core": "^2",
26
26
  "@oclif/plugin-help": "^5",
27
27
  "@oclif/plugin-plugins": "^2.4.7",