@basis-theory-labs/cli 1.9.0 → 1.12.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 +7 -6
- package/dist/applications/management.d.ts +4 -1
- package/dist/applications/management.js +37 -1
- package/dist/commands/applications/create.d.ts +1 -0
- package/dist/commands/applications/create.js +50 -23
- package/dist/logs/server.js +6 -4
- package/oclif.manifest.json +8 -1
- package/package.json +5 -3
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.
|
|
22
|
+
@basis-theory-labs/cli/1.12.0 linux-x64 node-v18.20.7
|
|
23
23
|
$ bt --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ bt COMMAND
|
|
@@ -64,7 +64,7 @@ EXAMPLES
|
|
|
64
64
|
$ bt applications
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
_See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
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)_
|
|
68
68
|
|
|
69
69
|
## `bt applications create`
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ Creates a new Application. Requires `application:create` Management Application
|
|
|
72
72
|
|
|
73
73
|
```
|
|
74
74
|
USAGE
|
|
75
|
-
$ bt applications create -x <value> [-n <value>] [-p <value>] [-t private|public|management]
|
|
75
|
+
$ bt applications create -x <value> [-n <value>] [-p <value>] [-t private|public|management] [-z <value>]
|
|
76
76
|
|
|
77
77
|
FLAGS
|
|
78
78
|
-n, --name=<value> name of the Application
|
|
@@ -80,6 +80,7 @@ FLAGS
|
|
|
80
80
|
-t, --type=<option> type of the Application
|
|
81
81
|
<options: private|public|management>
|
|
82
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
|
|
83
84
|
|
|
84
85
|
DESCRIPTION
|
|
85
86
|
Creates a new Application. Requires `application:create` Management Application permission
|
|
@@ -152,7 +153,7 @@ EXAMPLES
|
|
|
152
153
|
$ bt proxies
|
|
153
154
|
```
|
|
154
155
|
|
|
155
|
-
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
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)_
|
|
156
157
|
|
|
157
158
|
## `bt proxies create`
|
|
158
159
|
|
|
@@ -285,7 +286,7 @@ EXAMPLES
|
|
|
285
286
|
$ bt reactorFormulas
|
|
286
287
|
```
|
|
287
288
|
|
|
288
|
-
_See code: [dist/commands/reactorFormulas/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
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)_
|
|
289
290
|
|
|
290
291
|
## `bt reactorFormulas update ID`
|
|
291
292
|
|
|
@@ -338,7 +339,7 @@ EXAMPLES
|
|
|
338
339
|
$ bt reactors
|
|
339
340
|
```
|
|
340
341
|
|
|
341
|
-
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
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)_
|
|
342
343
|
|
|
343
344
|
## `bt reactors create`
|
|
344
345
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
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';
|
|
2
3
|
import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
3
4
|
declare const listPermissions: (bt: IBasisTheory, type: ApplicationType) => Promise<Permission[]>;
|
|
4
5
|
declare const selectApplication: (bt: IBasisTheory, page: number) => Promise<Application | undefined>;
|
|
5
6
|
declare const createApplication: (bt: IBasisTheory, model: CreateApplication) => Promise<Application>;
|
|
6
7
|
declare const updateApplication: (bt: IBasisTheory, id: string, model: UpdateApplication) => Promise<Application>;
|
|
7
8
|
declare const deleteApplication: (bt: IBasisTheory, id: string, force?: boolean) => Promise<boolean>;
|
|
8
|
-
|
|
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, };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteApplication = exports.selectApplication = exports.updateApplication = exports.createApplication = exports.listPermissions = void 0;
|
|
3
|
+
exports.promptTemplate = exports.createApplicationFromTemplate = exports.deleteApplication = exports.selectApplication = exports.updateApplication = exports.createApplication = exports.listPermissions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const confirm_1 = tslib_1.__importDefault(require("@inquirer/confirm"));
|
|
6
|
+
const select_1 = tslib_1.__importDefault(require("@inquirer/select"));
|
|
6
7
|
const core_1 = require("@oclif/core");
|
|
8
|
+
const lodash_groupby_1 = tslib_1.__importDefault(require("lodash.groupby"));
|
|
7
9
|
const utils_1 = require("../utils");
|
|
8
10
|
const debug = require('debug')('applications:management');
|
|
9
11
|
const listPermissions = (bt, type) => bt.permissions
|
|
@@ -90,3 +92,37 @@ const deleteApplication = async (bt, id, force = false) => {
|
|
|
90
92
|
return true;
|
|
91
93
|
};
|
|
92
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;
|
|
@@ -4,6 +4,7 @@ export default class Create extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
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>;
|
|
7
8
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
permission: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -9,30 +9,53 @@ const utils_2 = require("../../utils");
|
|
|
9
9
|
class Create extends base_1.BaseCommand {
|
|
10
10
|
async run() {
|
|
11
11
|
const { flags, bt } = await this.parse(Create);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
}
|
|
33
56
|
this.log('Application created successfully!');
|
|
34
|
-
this.log(`id: ${id}`);
|
|
35
|
-
this.log(`key: ${key}`);
|
|
57
|
+
this.log(`id: ${application.id}`);
|
|
58
|
+
this.log(`key: ${application.key}`);
|
|
36
59
|
}
|
|
37
60
|
}
|
|
38
61
|
exports.default = Create;
|
|
@@ -45,4 +68,8 @@ Create.flags = {
|
|
|
45
68
|
description: 'type of the Application',
|
|
46
69
|
options: [...models_1.APPLICATION_TYPES],
|
|
47
70
|
}),
|
|
71
|
+
template: core_1.Flags.string({
|
|
72
|
+
description: 'template ID to create the application with',
|
|
73
|
+
char: 'z',
|
|
74
|
+
}),
|
|
48
75
|
};
|
package/dist/logs/server.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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
7
|
const core_1 = require("@oclif/core");
|
|
6
8
|
const cloudflared_1 = require("cloudflared");
|
|
7
9
|
const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
|
|
@@ -15,11 +17,11 @@ const runTunnel = async (port) => {
|
|
|
15
17
|
await (0, cloudflared_1.install)(cloudflared_1.bin);
|
|
16
18
|
}
|
|
17
19
|
debug('starting tunnel');
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
const url = await urlPromise;
|
|
20
|
+
const tunnel = cloudflared_1.Tunnel.quick(`localhost:${port}`);
|
|
21
|
+
const url = await new Promise((resolve) => tunnel.once('url', resolve));
|
|
22
22
|
debug(`tunnel started at ${url}`);
|
|
23
|
+
const connection = await new Promise((resolve) => tunnel.once('connected', resolve));
|
|
24
|
+
debug(`tunnel connection is ready`, connection);
|
|
23
25
|
return url;
|
|
24
26
|
};
|
|
25
27
|
const createLogServer = async (_port) => {
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.12.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"applications:create": {
|
|
5
5
|
"id": "applications:create",
|
|
@@ -53,6 +53,13 @@
|
|
|
53
53
|
"public",
|
|
54
54
|
"management"
|
|
55
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
|
|
56
63
|
}
|
|
57
64
|
},
|
|
58
65
|
"args": {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory-labs/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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.
|
|
20
|
+
"@basis-theory/basis-theory-js": "^2.7.0",
|
|
21
21
|
"@inquirer/checkbox": "^1.5.0",
|
|
22
22
|
"@inquirer/confirm": "^2.0.15",
|
|
23
23
|
"@inquirer/input": "^1.2.14",
|
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"@oclif/core": "^2",
|
|
26
26
|
"@oclif/plugin-help": "^5",
|
|
27
27
|
"@oclif/plugin-plugins": "^2.4.7",
|
|
28
|
-
"cloudflared": "^0.
|
|
28
|
+
"cloudflared": "^0.7.0",
|
|
29
29
|
"debug": "^4.3.4",
|
|
30
30
|
"detect-port": "^1.5.1",
|
|
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",
|