@basis-theory-labs/cli 1.8.0 → 1.10.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.10.0 linux-x64 node-v18.19.0
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,95 @@ 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.10.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] [-z <value>]
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
+ -z, --template=<value> template ID to create the application with
84
+
85
+ DESCRIPTION
86
+ Creates a new Application. Requires `application:create` Management Application permission
87
+
88
+ EXAMPLES
89
+ $ bt applications create
90
+ ```
91
+
92
+ ## `bt applications delete ID`
93
+
94
+ Deletes a Application. Requires `application:delete` Management Application permissions
95
+
96
+ ```
97
+ USAGE
98
+ $ bt applications delete ID -x <value> [-y]
99
+
100
+ ARGUMENTS
101
+ ID Application id to delete
102
+
103
+ FLAGS
104
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
105
+ -y, --yes auto confirm the operation
106
+
107
+ DESCRIPTION
108
+ Deletes a Application. Requires `application:delete` Management Application permissions
109
+
110
+ EXAMPLES
111
+ $ bt applications delete 03858bf5-32d3-4a2e-b74b-daeea0883bca
112
+ ```
113
+
114
+ ## `bt applications update ID`
115
+
116
+ Updates a new Application. Requires `application:update` Management Application permission
117
+
118
+ ```
119
+ USAGE
120
+ $ bt applications update ID -x <value> [-n <value>] [-p <value>]
121
+
122
+ ARGUMENTS
123
+ ID Application id to update
124
+
125
+ FLAGS
126
+ -n, --name=<value> name of the Application
127
+ -p, --permission=<value>... permission(s) to use in the Application
128
+ -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
129
+
130
+ DESCRIPTION
131
+ Updates a new Application. Requires `application:update` Management Application permission
132
+
133
+ EXAMPLES
134
+ $ bt applications update
135
+ ```
136
+
44
137
  ## `bt proxies`
45
138
 
46
139
  List Proxies. Requires `proxy:read` Management Application permission
@@ -50,7 +143,7 @@ USAGE
50
143
  $ bt proxies -x <value> [-p <value>]
51
144
 
52
145
  FLAGS
53
- -p, --page=<value> [default: 1] proxies list page to fetch
146
+ -p, --page=<value> [default: 1] Proxies list page to fetch
54
147
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
55
148
 
56
149
  DESCRIPTION
@@ -60,7 +153,7 @@ EXAMPLES
60
153
  $ bt proxies
61
154
  ```
62
155
 
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)_
156
+ _See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.10.0/dist/commands/proxies/index.ts)_
64
157
 
65
158
  ## `bt proxies create`
66
159
 
@@ -90,7 +183,7 @@ EXAMPLES
90
183
 
91
184
  ## `bt proxies delete ID`
92
185
 
93
- Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions
186
+ Deletes a Proxy. Requires `proxy:delete` Management Application permissions
94
187
 
95
188
  ```
96
189
  USAGE
@@ -104,7 +197,7 @@ FLAGS
104
197
  -y, --yes auto confirm the operation
105
198
 
106
199
  DESCRIPTION
107
- Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions
200
+ Deletes a Proxy. Requires `proxy:delete` Management Application permissions
108
201
 
109
202
  EXAMPLES
110
203
  $ bt proxies delete 03858bf5-32d3-4a2e-b74b-daeea0883bca
@@ -183,7 +276,7 @@ USAGE
183
276
  $ bt reactorFormulas -x <value> [-p <value>]
184
277
 
185
278
  FLAGS
186
- -p, --page=<value> [default: 1] reactors formulas list page to fetch
279
+ -p, --page=<value> [default: 1] Reactors formulas list page to fetch
187
280
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
188
281
 
189
282
  DESCRIPTION
@@ -193,7 +286,7 @@ EXAMPLES
193
286
  $ bt reactorFormulas
194
287
  ```
195
288
 
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)_
289
+ _See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.10.0/dist/commands/reactorFormulas/index.ts)_
197
290
 
198
291
  ## `bt reactorFormulas update ID`
199
292
 
@@ -236,7 +329,7 @@ USAGE
236
329
  $ bt reactors -x <value> [-p <value>]
237
330
 
238
331
  FLAGS
239
- -p, --page=<value> [default: 1] reactors list page to fetch
332
+ -p, --page=<value> [default: 1] Reactors list page to fetch
240
333
  -x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
241
334
 
242
335
  DESCRIPTION
@@ -246,7 +339,7 @@ EXAMPLES
246
339
  $ bt reactors
247
340
  ```
248
341
 
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)_
342
+ _See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.10.0/dist/commands/reactors/index.ts)_
250
343
 
251
344
  ## `bt reactors create`
252
345
 
@@ -272,7 +365,7 @@ EXAMPLES
272
365
 
273
366
  ## `bt reactors delete ID`
274
367
 
275
- Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions
368
+ Deletes a Reactor. Requires `reactor:delete` Management Application permissions
276
369
 
277
370
  ```
278
371
  USAGE
@@ -286,7 +379,7 @@ FLAGS
286
379
  -y, --yes auto confirm the operation
287
380
 
288
381
  DESCRIPTION
289
- Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions
382
+ Deletes a Reactor. Requires `reactor:delete` Management Application permissions
290
383
 
291
384
  EXAMPLES
292
385
  $ bt reactors delete 03858bf5-32d3-4a2e-b74b-daeea0883bca
@@ -0,0 +1,11 @@
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>;
11
+ export { listPermissions, createApplication, updateApplication, selectApplication, deleteApplication, createApplicationFromTemplate, promptTemplate, };
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promptTemplate = exports.createApplicationFromTemplate = 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 select_1 = tslib_1.__importDefault(require("@inquirer/select"));
7
+ const core_1 = require("@oclif/core");
8
+ const lodash_groupby_1 = tslib_1.__importDefault(require("lodash.groupby"));
9
+ const utils_1 = require("../utils");
10
+ const debug = require('debug')('applications:management');
11
+ const listPermissions = (bt, type) => bt.permissions
12
+ .list({
13
+ applicationType: type,
14
+ })
15
+ .then((permissions) => permissions.sort((p1, p2) => p1.type.localeCompare(p2.type)));
16
+ exports.listPermissions = listPermissions;
17
+ const listApplications = async (bt, page) => {
18
+ const size = 5;
19
+ debug('Listing applications', `page: ${page}`, `size: ${size}`);
20
+ const applications = await bt.applications.list({
21
+ size,
22
+ page,
23
+ });
24
+ let data = [];
25
+ if (applications.pagination.totalItems > 0) {
26
+ const last = (applications.pagination.pageNumber - 1) * size;
27
+ data = applications.data.map((application, index) => ({
28
+ '#': last + (index + 1),
29
+ ...application,
30
+ }));
31
+ core_1.ux.table(data, {
32
+ '#': {},
33
+ id: {},
34
+ name: {},
35
+ type: {},
36
+ });
37
+ }
38
+ else {
39
+ core_1.ux.log('No applications found.');
40
+ }
41
+ return {
42
+ data,
43
+ pagination: applications.pagination,
44
+ };
45
+ };
46
+ const retrieveApplication = (bt, id) => {
47
+ debug(`Retrieving Application ${id}`);
48
+ return bt.applications.retrieve(id);
49
+ };
50
+ const selectApplication = async (bt, page) => {
51
+ const applications = await listApplications(bt, page);
52
+ if (applications.pagination.totalItems === 0) {
53
+ return undefined;
54
+ }
55
+ const selection = await (0, utils_1.selectOrNavigate)(applications, '#');
56
+ if (selection === 'previous') {
57
+ return selectApplication(bt, page - 1);
58
+ }
59
+ if (selection === 'next') {
60
+ return selectApplication(bt, page + 1);
61
+ }
62
+ return selection;
63
+ };
64
+ exports.selectApplication = selectApplication;
65
+ const createApplication = (bt, model) => {
66
+ debug('Creating Application', JSON.stringify(model, undefined, 2));
67
+ return bt.applications.create(model);
68
+ };
69
+ exports.createApplication = createApplication;
70
+ const updateApplication = async (bt, id, model) => {
71
+ const application = await retrieveApplication(bt, id);
72
+ debug(`Updating Application ${id}`, JSON.stringify(model, undefined, 2));
73
+ return bt.applications.update(id, {
74
+ name: model.name || application.name,
75
+ permissions: model.permissions || application.permissions,
76
+ rules: model.permissions ? undefined : application.rules, // if permissions were passed, overwrite rules
77
+ });
78
+ };
79
+ exports.updateApplication = updateApplication;
80
+ const deleteApplication = async (bt, id, force = false) => {
81
+ if (!force) {
82
+ const proceed = await (0, confirm_1.default)({
83
+ message: `Are you sure you want to delete this Application (${id})?`,
84
+ default: false,
85
+ });
86
+ if (!proceed) {
87
+ return false;
88
+ }
89
+ }
90
+ debug(`Deleting Application`, id);
91
+ await bt.applications.delete(id);
92
+ return true;
93
+ };
94
+ exports.deleteApplication = deleteApplication;
95
+ const createApplicationFromTemplate = async (bt, templateId) => {
96
+ const template = await bt.applicationTemplates.retrieve(templateId);
97
+ return createApplication(bt, {
98
+ name: template.name,
99
+ type: template.applicationType,
100
+ permissions: template.permissions,
101
+ rules: template.rules,
102
+ });
103
+ };
104
+ exports.createApplicationFromTemplate = createApplicationFromTemplate;
105
+ const promptTemplate = async (bt) => {
106
+ const useTemplate = await (0, confirm_1.default)({
107
+ message: 'Do you want to use an application template?',
108
+ });
109
+ if (!useTemplate) {
110
+ return undefined;
111
+ }
112
+ const templates = (0, lodash_groupby_1.default)(await bt.applicationTemplates.list(), 'templateType');
113
+ const type = await (0, select_1.default)({
114
+ message: 'Which template type do you want to use?',
115
+ choices: Object.keys(templates).map((t) => ({
116
+ value: t,
117
+ })),
118
+ });
119
+ return (0, select_1.default)({
120
+ message: 'Choose a template',
121
+ choices: templates[type].map((t) => ({
122
+ name: t.name,
123
+ value: t,
124
+ description: t.description,
125
+ })),
126
+ });
127
+ };
128
+ exports.promptTemplate = promptTemplate;
@@ -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,12 @@
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
+ template: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ permission: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,75 @@
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
+ let application;
13
+ if (flags.template) {
14
+ // template passed as flag
15
+ application = await (0, management_1.createApplicationFromTemplate)(bt, flags.template);
16
+ }
17
+ else {
18
+ let template;
19
+ let rules, permissions, type;
20
+ if (!flags.name && !flags.type && !flags.permission) {
21
+ // no other flags where passed, prompt template
22
+ template = await (0, management_1.promptTemplate)(bt);
23
+ }
24
+ const name = await (0, utils_2.promptStringIfUndefined)(flags.name, {
25
+ message: 'What is the Application name?',
26
+ default: template === null || template === void 0 ? void 0 : template.name,
27
+ validate: (value) => Boolean(value),
28
+ });
29
+ if (template) {
30
+ // template has been picked, so type and permissions/rules are defined
31
+ type = template.applicationType;
32
+ rules = template.rules;
33
+ permissions = template.permissions;
34
+ }
35
+ else {
36
+ type = (await (0, utils_2.promptSelectIfUndefined)(flags.type, {
37
+ message: 'What is the Application type?',
38
+ choices: models_1.APPLICATION_TYPES.map((t) => ({ value: t })),
39
+ }));
40
+ const available = await (0, management_1.listPermissions)(bt, type);
41
+ permissions = await (0, utils_2.promptCheckboxIfUndefined)(flags.permission, {
42
+ message: 'Select the permissions for the Application',
43
+ choices: available.map((p) => ({
44
+ value: p.type,
45
+ })),
46
+ loop: false,
47
+ });
48
+ }
49
+ application = await (0, management_1.createApplication)(bt, {
50
+ name,
51
+ type,
52
+ permissions,
53
+ rules,
54
+ });
55
+ }
56
+ this.log('Application created successfully!');
57
+ this.log(`id: ${application.id}`);
58
+ this.log(`key: ${application.key}`);
59
+ }
60
+ }
61
+ exports.default = Create;
62
+ Create.description = 'Creates a new Application. Requires `application:create` Management Application permission';
63
+ Create.examples = ['<%= config.bin %> <%= command.id %> '];
64
+ Create.flags = {
65
+ ...utils_1.APPLICATION_FLAGS,
66
+ type: core_1.Flags.string({
67
+ char: 't',
68
+ description: 'type of the Application',
69
+ options: [...models_1.APPLICATION_TYPES],
70
+ }),
71
+ template: core_1.Flags.string({
72
+ description: 'template ID to create the application with',
73
+ char: 'z',
74
+ }),
75
+ };
@@ -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,200 @@
1
1
  {
2
- "version": "1.8.0",
2
+ "version": "1.10.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
+ "template": {
58
+ "name": "template",
59
+ "type": "option",
60
+ "char": "z",
61
+ "description": "template ID to create the application with",
62
+ "multiple": false
63
+ }
64
+ },
65
+ "args": {}
66
+ },
67
+ "applications:delete": {
68
+ "id": "applications:delete",
69
+ "description": "Deletes a Application. Requires `application:delete` Management Application permissions",
70
+ "strict": true,
71
+ "pluginName": "@basis-theory-labs/cli",
72
+ "pluginAlias": "@basis-theory-labs/cli",
73
+ "pluginType": "core",
74
+ "aliases": [],
75
+ "examples": [
76
+ "<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca"
77
+ ],
78
+ "flags": {
79
+ "management-key": {
80
+ "name": "management-key",
81
+ "type": "option",
82
+ "char": "x",
83
+ "description": "management key used for connecting with the reactor / proxy",
84
+ "required": true,
85
+ "multiple": false
86
+ },
87
+ "api-base-url": {
88
+ "name": "api-base-url",
89
+ "type": "option",
90
+ "description": "base API URL to use in Basis Theory SDK",
91
+ "hidden": true,
92
+ "multiple": false
93
+ },
94
+ "yes": {
95
+ "name": "yes",
96
+ "type": "boolean",
97
+ "char": "y",
98
+ "description": "auto confirm the operation",
99
+ "allowNo": false
100
+ }
101
+ },
102
+ "args": {
103
+ "id": {
104
+ "name": "id",
105
+ "description": "Application id to delete",
106
+ "required": true
107
+ }
108
+ }
109
+ },
110
+ "applications": {
111
+ "id": "applications",
112
+ "description": "List Applications. Requires `application:read` Management Application permission",
113
+ "strict": true,
114
+ "pluginName": "@basis-theory-labs/cli",
115
+ "pluginAlias": "@basis-theory-labs/cli",
116
+ "pluginType": "core",
117
+ "aliases": [],
118
+ "examples": [
119
+ "<%= config.bin %> <%= command.id %>"
120
+ ],
121
+ "flags": {
122
+ "management-key": {
123
+ "name": "management-key",
124
+ "type": "option",
125
+ "char": "x",
126
+ "description": "management key used for connecting with the reactor / proxy",
127
+ "required": true,
128
+ "multiple": false
129
+ },
130
+ "api-base-url": {
131
+ "name": "api-base-url",
132
+ "type": "option",
133
+ "description": "base API URL to use in Basis Theory SDK",
134
+ "hidden": true,
135
+ "multiple": false
136
+ },
137
+ "page": {
138
+ "name": "page",
139
+ "type": "option",
140
+ "char": "p",
141
+ "description": "Applications list page to fetch",
142
+ "multiple": false,
143
+ "default": 1
144
+ }
145
+ },
146
+ "args": {}
147
+ },
148
+ "applications:update": {
149
+ "id": "applications:update",
150
+ "description": "Updates a new Application. Requires `application:update` Management Application permission",
151
+ "strict": true,
152
+ "pluginName": "@basis-theory-labs/cli",
153
+ "pluginAlias": "@basis-theory-labs/cli",
154
+ "pluginType": "core",
155
+ "aliases": [],
156
+ "examples": [
157
+ "<%= config.bin %> <%= command.id %> "
158
+ ],
159
+ "flags": {
160
+ "management-key": {
161
+ "name": "management-key",
162
+ "type": "option",
163
+ "char": "x",
164
+ "description": "management key used for connecting with the reactor / proxy",
165
+ "required": true,
166
+ "multiple": false
167
+ },
168
+ "api-base-url": {
169
+ "name": "api-base-url",
170
+ "type": "option",
171
+ "description": "base API URL to use in Basis Theory SDK",
172
+ "hidden": true,
173
+ "multiple": false
174
+ },
175
+ "name": {
176
+ "name": "name",
177
+ "type": "option",
178
+ "char": "n",
179
+ "description": "name of the Application",
180
+ "multiple": false
181
+ },
182
+ "permission": {
183
+ "name": "permission",
184
+ "type": "option",
185
+ "char": "p",
186
+ "description": "permission(s) to use in the Application",
187
+ "multiple": true
188
+ }
189
+ },
190
+ "args": {
191
+ "id": {
192
+ "name": "id",
193
+ "description": "Application id to update",
194
+ "required": true
195
+ }
196
+ }
197
+ },
4
198
  "proxies:create": {
5
199
  "id": "proxies:create",
6
200
  "description": "Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission",
@@ -82,7 +276,7 @@
82
276
  },
83
277
  "proxies:delete": {
84
278
  "id": "proxies:delete",
85
- "description": "Deletes a Proxy. Requires `proxy:delete` and `proxy:read` Management Application permissions",
279
+ "description": "Deletes a Proxy. Requires `proxy:delete` Management Application permissions",
86
280
  "strict": true,
87
281
  "pluginName": "@basis-theory-labs/cli",
88
282
  "pluginAlias": "@basis-theory-labs/cli",
@@ -154,7 +348,7 @@
154
348
  "name": "page",
155
349
  "type": "option",
156
350
  "char": "p",
157
- "description": "proxies list page to fetch",
351
+ "description": "Proxies list page to fetch",
158
352
  "multiple": false,
159
353
  "default": 1
160
354
  }
@@ -341,7 +535,7 @@
341
535
  "name": "page",
342
536
  "type": "option",
343
537
  "char": "p",
344
- "description": "reactors formulas list page to fetch",
538
+ "description": "Reactors formulas list page to fetch",
345
539
  "multiple": false,
346
540
  "default": 1
347
541
  }
@@ -500,7 +694,7 @@
500
694
  },
501
695
  "reactors:delete": {
502
696
  "id": "reactors:delete",
503
- "description": "Deletes a Reactor. Requires `reactor:delete` and `reactor:read` Management Application permissions",
697
+ "description": "Deletes a Reactor. Requires `reactor:delete` Management Application permissions",
504
698
  "strict": true,
505
699
  "pluginName": "@basis-theory-labs/cli",
506
700
  "pluginAlias": "@basis-theory-labs/cli",
@@ -572,7 +766,7 @@
572
766
  "name": "page",
573
767
  "type": "option",
574
768
  "char": "p",
575
- "description": "reactors list page to fetch",
769
+ "description": "Reactors list page to fetch",
576
770
  "multiple": false,
577
771
  "default": 1
578
772
  }
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.10.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.7.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",
@@ -31,6 +31,7 @@
31
31
  "dotenv": "^16.3.1",
32
32
  "fastify": "^4.19.2",
33
33
  "lodash.debounce": "^4.0.8",
34
+ "lodash.groupby": "^4.6.0",
34
35
  "pino": "^8.14.1",
35
36
  "pino-pretty": "^10.0.0",
36
37
  "serialize-error": "^11.0.0",
@@ -49,6 +50,7 @@
49
50
  "@types/debug": "^4.1.8",
50
51
  "@types/detect-port": "^1.3.3",
51
52
  "@types/lodash.debounce": "^4.0.7",
53
+ "@types/lodash.groupby": "^4.6.9",
52
54
  "@types/mocha": "^9.0.0",
53
55
  "@types/node": "^16.18.36",
54
56
  "chai": "^4",