@basis-theory-labs/cli 1.0.3 → 1.1.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 +81 -14
- package/dist/commands/proxies/index.d.ts +11 -0
- package/dist/commands/proxies/index.js +54 -0
- package/dist/commands/{logs.d.ts → proxies/logs.d.ts} +3 -2
- package/dist/commands/proxies/logs.js +32 -0
- package/dist/commands/reactors/index.d.ts +11 -0
- package/dist/commands/reactors/index.js +54 -0
- package/dist/commands/reactors/logs.d.ts +13 -0
- package/dist/commands/reactors/logs.js +32 -0
- package/dist/logs/index.d.ts +4 -0
- package/dist/logs/index.js +15 -0
- package/dist/logs/management.d.ts +4 -8
- package/dist/logs/management.js +10 -17
- package/dist/logs/server.d.ts +1 -2
- package/dist/logs/server.js +1 -1
- package/dist/proxies/management.d.ts +4 -0
- package/dist/proxies/management.js +57 -0
- package/dist/reactors/management.d.ts +4 -0
- package/dist/reactors/management.js +38 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +44 -0
- package/oclif.manifest.json +108 -13
- package/package.json +4 -1
- package/dist/commands/logs.js +0 -43
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm install -g @basis-theory-labs/cli
|
|
|
16
16
|
$ bt COMMAND
|
|
17
17
|
running command...
|
|
18
18
|
$ bt (--version)
|
|
19
|
-
@basis-theory-labs/cli/1.0
|
|
19
|
+
@basis-theory-labs/cli/1.1.0 linux-x64 node-v18.16.0
|
|
20
20
|
$ bt --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ bt COMMAND
|
|
@@ -25,31 +25,98 @@ USAGE
|
|
|
25
25
|
<!-- usagestop -->
|
|
26
26
|
# Commands
|
|
27
27
|
<!-- commands -->
|
|
28
|
-
* [`bt
|
|
28
|
+
* [`bt proxies`](#bt-proxies)
|
|
29
|
+
* [`bt proxies logs ID`](#bt-proxies-logs-id)
|
|
30
|
+
* [`bt reactors`](#bt-reactors)
|
|
31
|
+
* [`bt reactors logs ID`](#bt-reactors-logs-id)
|
|
29
32
|
|
|
30
|
-
## `bt
|
|
33
|
+
## `bt proxies`
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
list proxies
|
|
33
36
|
|
|
34
37
|
```
|
|
35
38
|
USAGE
|
|
36
|
-
$ bt
|
|
39
|
+
$ bt proxies -x <value> [-p <value>]
|
|
37
40
|
|
|
38
41
|
FLAGS
|
|
39
|
-
-p, --
|
|
40
|
-
--management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
41
|
-
--proxy-id=<value> proxy id to connect to
|
|
42
|
-
--reactor-id=<value> reactor id to connect to
|
|
42
|
+
-p, --page=<value> [default: 1] proxies list page to fetch
|
|
43
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
43
44
|
|
|
44
45
|
DESCRIPTION
|
|
45
|
-
|
|
46
|
-
`proxy:update` Management Application permissions
|
|
46
|
+
list proxies
|
|
47
47
|
|
|
48
48
|
EXAMPLES
|
|
49
|
-
$ bt
|
|
49
|
+
$ bt proxies
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.1.0/dist/commands/proxies/index.ts)_
|
|
53
|
+
|
|
54
|
+
## `bt proxies logs ID`
|
|
55
|
+
|
|
56
|
+
Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
USAGE
|
|
60
|
+
$ bt proxies logs ID -x <value> [-p <value>]
|
|
61
|
+
|
|
62
|
+
ARGUMENTS
|
|
63
|
+
ID Proxy id to connect to
|
|
64
|
+
|
|
65
|
+
FLAGS
|
|
66
|
+
-p, --port=<value> [default: 8220] port to listen for incoming logs
|
|
67
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
68
|
+
|
|
69
|
+
DESCRIPTION
|
|
70
|
+
Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions
|
|
71
|
+
|
|
72
|
+
EXAMPLES
|
|
73
|
+
$ bt proxies logs
|
|
74
|
+
|
|
75
|
+
$ bt proxies logs -p 3000
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## `bt reactors`
|
|
79
|
+
|
|
80
|
+
list reactors
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
USAGE
|
|
84
|
+
$ bt reactors -x <value> [-p <value>]
|
|
85
|
+
|
|
86
|
+
FLAGS
|
|
87
|
+
-p, --page=<value> [default: 1] reactors list page to fetch
|
|
88
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
89
|
+
|
|
90
|
+
DESCRIPTION
|
|
91
|
+
list reactors
|
|
92
|
+
|
|
93
|
+
EXAMPLES
|
|
94
|
+
$ bt reactors
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.1.0/dist/commands/reactors/index.ts)_
|
|
98
|
+
|
|
99
|
+
## `bt reactors logs ID`
|
|
100
|
+
|
|
101
|
+
Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions
|
|
50
102
|
|
|
51
|
-
$ bt logs -p 3000
|
|
52
103
|
```
|
|
104
|
+
USAGE
|
|
105
|
+
$ bt reactors logs ID -x <value> [-p <value>]
|
|
106
|
+
|
|
107
|
+
ARGUMENTS
|
|
108
|
+
ID Reactor id to connect to
|
|
109
|
+
|
|
110
|
+
FLAGS
|
|
111
|
+
-p, --port=<value> [default: 8220] port to listen for incoming logs
|
|
112
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
53
113
|
|
|
54
|
-
|
|
114
|
+
DESCRIPTION
|
|
115
|
+
Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions
|
|
116
|
+
|
|
117
|
+
EXAMPLES
|
|
118
|
+
$ bt reactors logs
|
|
119
|
+
|
|
120
|
+
$ bt reactors logs -p 3000
|
|
121
|
+
```
|
|
55
122
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Proxies extends Command {
|
|
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
|
+
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static args: {};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const logs_1 = require("../../logs");
|
|
6
|
+
const management_1 = require("../../proxies/management");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
class Proxies extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags: { 'management-key': managementKey, page }, } = await this.parse(Proxies);
|
|
11
|
+
const bt = await (0, utils_1.createBt)(managementKey);
|
|
12
|
+
const proxy = await (0, management_1.selectProxy)(bt, page);
|
|
13
|
+
const action = await (0, prompts_1.select)({
|
|
14
|
+
message: 'Select action to perform',
|
|
15
|
+
choices: [
|
|
16
|
+
{
|
|
17
|
+
name: 'Logs',
|
|
18
|
+
value: 'logs',
|
|
19
|
+
description: 'See Proxy Transforms real-time logs',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'Exit',
|
|
23
|
+
value: 'exit',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
if (action === 'logs') {
|
|
28
|
+
const sPort = await (0, prompts_1.input)({
|
|
29
|
+
message: 'Enter port to start Logs Server (1-65535)',
|
|
30
|
+
default: String(utils_1.DEFAULT_LOGS_SERVER_PORT),
|
|
31
|
+
validate: (data) => {
|
|
32
|
+
const port = Number(data);
|
|
33
|
+
if (port >= 1 && port <= 65535) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return 'Please enter a valid port (1-65535)';
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
await (0, logs_1.showProxyLogs)(bt, Number(sPort), proxy.id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = Proxies;
|
|
44
|
+
Proxies.description = 'list proxies';
|
|
45
|
+
Proxies.examples = ['<%= config.bin %> <%= command.id %>'];
|
|
46
|
+
Proxies.flags = {
|
|
47
|
+
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
48
|
+
page: core_1.Flags.integer({
|
|
49
|
+
char: 'p',
|
|
50
|
+
description: 'proxies list page to fetch',
|
|
51
|
+
default: 1,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
Proxies.args = {};
|
|
@@ -2,11 +2,12 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
export default class Logs extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
5
8
|
static flags: {
|
|
6
9
|
port: import("@oclif/core/lib/interfaces/parser").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
10
|
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
-
'proxy-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
-
'reactor-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
};
|
|
11
12
|
run(): Promise<void>;
|
|
12
13
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const logs_1 = require("../../logs");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
class Logs extends core_1.Command {
|
|
7
|
+
async run() {
|
|
8
|
+
const { flags: { port, 'management-key': managementKey }, args: { id }, } = await this.parse(Logs);
|
|
9
|
+
const bt = await (0, utils_1.createBt)(managementKey);
|
|
10
|
+
await (0, logs_1.showProxyLogs)(bt, port, id);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = Logs;
|
|
14
|
+
Logs.description = 'Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions';
|
|
15
|
+
Logs.examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %>',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> -p 3000',
|
|
18
|
+
];
|
|
19
|
+
Logs.args = {
|
|
20
|
+
id: core_1.Args.string({
|
|
21
|
+
required: true,
|
|
22
|
+
description: 'Proxy id to connect to',
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
Logs.flags = {
|
|
26
|
+
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
27
|
+
port: core_1.Flags.integer({
|
|
28
|
+
char: 'p',
|
|
29
|
+
description: 'port to listen for incoming logs',
|
|
30
|
+
default: utils_1.DEFAULT_LOGS_SERVER_PORT,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Reactors extends Command {
|
|
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
|
+
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static args: {};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const logs_1 = require("../../logs");
|
|
6
|
+
const management_1 = require("../../reactors/management");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
class Reactors extends core_1.Command {
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags: { 'management-key': managementKey, page }, } = await this.parse(Reactors);
|
|
11
|
+
const bt = await (0, utils_1.createBt)(managementKey);
|
|
12
|
+
const reactor = await (0, management_1.selectReactor)(bt, page);
|
|
13
|
+
const action = await (0, prompts_1.select)({
|
|
14
|
+
message: 'Select action to perform',
|
|
15
|
+
choices: [
|
|
16
|
+
{
|
|
17
|
+
name: 'Logs',
|
|
18
|
+
value: 'logs',
|
|
19
|
+
description: 'See Reactor real-time logs',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'Exit',
|
|
23
|
+
value: 'exit',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
if (action === 'logs') {
|
|
28
|
+
const sPort = await (0, prompts_1.input)({
|
|
29
|
+
message: 'Enter port to start Logs Server (1-65535)',
|
|
30
|
+
default: String(utils_1.DEFAULT_LOGS_SERVER_PORT),
|
|
31
|
+
validate: (data) => {
|
|
32
|
+
const port = Number(data);
|
|
33
|
+
if (port >= 1 && port <= 65535) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return 'Please enter a valid port (1-65535)';
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
await (0, logs_1.showReactorLogs)(bt, Number(sPort), reactor.id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = Reactors;
|
|
44
|
+
Reactors.description = 'list reactors';
|
|
45
|
+
Reactors.examples = ['<%= config.bin %> <%= command.id %>'];
|
|
46
|
+
Reactors.flags = {
|
|
47
|
+
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
48
|
+
page: core_1.Flags.integer({
|
|
49
|
+
char: 'p',
|
|
50
|
+
description: 'reactors list page to fetch',
|
|
51
|
+
default: 1,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
Reactors.args = {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Logs extends Command {
|
|
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
|
+
port: import("@oclif/core/lib/interfaces/parser").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const logs_1 = require("../../logs");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
class Logs extends core_1.Command {
|
|
7
|
+
async run() {
|
|
8
|
+
const { flags: { port, 'management-key': managementKey }, args: { id }, } = await this.parse(Logs);
|
|
9
|
+
const bt = await (0, utils_1.createBt)(managementKey);
|
|
10
|
+
await (0, logs_1.showReactorLogs)(bt, port, id);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = Logs;
|
|
14
|
+
Logs.description = 'Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions';
|
|
15
|
+
Logs.examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %>',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> -p 3000',
|
|
18
|
+
];
|
|
19
|
+
Logs.args = {
|
|
20
|
+
id: core_1.Args.string({
|
|
21
|
+
required: true,
|
|
22
|
+
description: 'Reactor id to connect to',
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
Logs.flags = {
|
|
26
|
+
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
27
|
+
port: core_1.Flags.integer({
|
|
28
|
+
char: 'p',
|
|
29
|
+
description: 'port to listen for incoming logs',
|
|
30
|
+
default: utils_1.DEFAULT_LOGS_SERVER_PORT,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
|
+
declare const showProxyLogs: (bt: BasisTheory, port: number, id: string) => Promise<void>;
|
|
3
|
+
declare const showReactorLogs: (bt: BasisTheory, port: number, id: string) => Promise<void>;
|
|
4
|
+
export { showProxyLogs, showReactorLogs };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showReactorLogs = exports.showProxyLogs = void 0;
|
|
4
|
+
const management_1 = require("./management");
|
|
5
|
+
const server_1 = require("./server");
|
|
6
|
+
const showProxyLogs = async (bt, port, id) => {
|
|
7
|
+
const url = await (0, server_1.createLogServer)(port);
|
|
8
|
+
await (0, management_1.connectToProxy)(bt, id, url);
|
|
9
|
+
};
|
|
10
|
+
exports.showProxyLogs = showProxyLogs;
|
|
11
|
+
const showReactorLogs = async (bt, port, id) => {
|
|
12
|
+
const url = await (0, server_1.createLogServer)(port);
|
|
13
|
+
await (0, management_1.connectToReactor)(bt, id, url);
|
|
14
|
+
};
|
|
15
|
+
exports.showReactorLogs = showReactorLogs;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
url: string;
|
|
6
|
-
}
|
|
7
|
-
declare const connectToResource: ({ managementKey, reactorId, proxyId, url, }: ConnectParams) => Promise<void>;
|
|
8
|
-
export { connectToResource };
|
|
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 connectToProxy: (bt: IBasisTheory, id: string, url: string) => Promise<void>;
|
|
4
|
+
export { connectToProxy, connectToReactor };
|
package/dist/logs/management.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
|
|
3
|
+
exports.connectToReactor = exports.connectToProxy = void 0;
|
|
5
4
|
const core_1 = require("@oclif/core");
|
|
6
5
|
const BT_LOGGING_CONFIGURATION = 'BT_REMOTE_LOGGING';
|
|
7
6
|
const createConfiguration = (url, current = {}) => ({
|
|
@@ -11,20 +10,21 @@ const createConfiguration = (url, current = {}) => ({
|
|
|
11
10
|
date: Date.now(),
|
|
12
11
|
}),
|
|
13
12
|
});
|
|
14
|
-
const connectToReactor = async (bt,
|
|
13
|
+
const connectToReactor = async (bt, id, url) => {
|
|
15
14
|
core_1.ux.action.start('Connecting to Reactor');
|
|
16
|
-
const reactor = await bt.reactors.retrieve(
|
|
17
|
-
await bt.reactors.update(
|
|
15
|
+
const reactor = await bt.reactors.retrieve(id);
|
|
16
|
+
await bt.reactors.update(id, {
|
|
18
17
|
name: reactor.name,
|
|
19
18
|
configuration: createConfiguration(url, reactor.configuration),
|
|
20
19
|
application: reactor.application,
|
|
21
20
|
});
|
|
22
21
|
core_1.ux.action.stop('✅\t');
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
await bt.proxies.
|
|
23
|
+
exports.connectToReactor = connectToReactor;
|
|
24
|
+
const connectToProxy = async (bt, id, url) => {
|
|
25
|
+
core_1.ux.action.start(`Connecting to Proxy (${id})`);
|
|
26
|
+
const proxy = await bt.proxies.retrieve(id);
|
|
27
|
+
await bt.proxies.update(id, {
|
|
28
28
|
...proxy,
|
|
29
29
|
...(proxy.applicationId
|
|
30
30
|
? {
|
|
@@ -37,11 +37,4 @@ const connectToProxy = async (bt, proxyId, url) => {
|
|
|
37
37
|
});
|
|
38
38
|
core_1.ux.action.stop('✅\t');
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
const bt = await new basis_theory_js_1.BasisTheory().init(managementKey);
|
|
42
|
-
if (typeof reactorId === 'string') {
|
|
43
|
-
return connectToReactor(bt, reactorId, url);
|
|
44
|
-
}
|
|
45
|
-
return connectToProxy(bt, proxyId, url);
|
|
46
|
-
};
|
|
47
|
-
exports.connectToResource = connectToResource;
|
|
40
|
+
exports.connectToProxy = connectToProxy;
|
package/dist/logs/server.d.ts
CHANGED
package/dist/logs/server.js
CHANGED
|
@@ -22,7 +22,7 @@ const runTunnel = async (port) => {
|
|
|
22
22
|
debug(`tunnel started at ${url}`);
|
|
23
23
|
return url;
|
|
24
24
|
};
|
|
25
|
-
const createLogServer = async (
|
|
25
|
+
const createLogServer = async (port) => {
|
|
26
26
|
core_1.ux.action.start('Starting log server');
|
|
27
27
|
const logger = (0, pino_1.default)({
|
|
28
28
|
transport: {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectProxy = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const listProxies = async (bt, page) => {
|
|
7
|
+
const size = 5;
|
|
8
|
+
const proxies = await bt.proxies.list({
|
|
9
|
+
size,
|
|
10
|
+
page,
|
|
11
|
+
});
|
|
12
|
+
const last = (proxies.pagination.pageNumber - 1) * size;
|
|
13
|
+
const data = proxies.data.map((proxy, index) => ({
|
|
14
|
+
'#': last + (index + 1),
|
|
15
|
+
...proxy,
|
|
16
|
+
}));
|
|
17
|
+
core_1.ux.table(data, {
|
|
18
|
+
'#': {},
|
|
19
|
+
id: {},
|
|
20
|
+
name: {},
|
|
21
|
+
key: {},
|
|
22
|
+
/* eslint-disable camelcase */
|
|
23
|
+
destination_url: {
|
|
24
|
+
header: 'Destination URL',
|
|
25
|
+
get: (proxy) => proxy.destinationUrl,
|
|
26
|
+
},
|
|
27
|
+
require_auth: {
|
|
28
|
+
header: 'Require Auth',
|
|
29
|
+
get: (proxy) => (proxy.requireAuth ? 'yes' : 'no'),
|
|
30
|
+
},
|
|
31
|
+
request_transform: {
|
|
32
|
+
header: 'Request Transform',
|
|
33
|
+
get: (proxy) => { var _a; return (((_a = proxy.requestTransform) === null || _a === void 0 ? void 0 : _a.code) ? 'yes' : 'no'); },
|
|
34
|
+
},
|
|
35
|
+
response_transform: {
|
|
36
|
+
header: 'Response Transform',
|
|
37
|
+
get: (proxy) => { var _a; return (((_a = proxy.responseTransform) === null || _a === void 0 ? void 0 : _a.code) ? 'yes' : 'no'); },
|
|
38
|
+
},
|
|
39
|
+
/* eslint-enable camelcase */
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
data,
|
|
43
|
+
pagination: proxies.pagination,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const selectProxy = async (bt, page) => {
|
|
47
|
+
const proxies = await listProxies(bt, page);
|
|
48
|
+
const selection = await (0, utils_1.selectOrNavigate)(proxies, '#');
|
|
49
|
+
if (selection === 'previous') {
|
|
50
|
+
return selectProxy(bt, page - 1);
|
|
51
|
+
}
|
|
52
|
+
if (selection === 'next') {
|
|
53
|
+
return selectProxy(bt, page + 1);
|
|
54
|
+
}
|
|
55
|
+
return selection;
|
|
56
|
+
};
|
|
57
|
+
exports.selectProxy = selectProxy;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Reactor } 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>;
|
|
4
|
+
export { selectReactor };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectReactor = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const listReactors = async (bt, page) => {
|
|
7
|
+
const size = 5;
|
|
8
|
+
const reactors = await bt.reactors.list({
|
|
9
|
+
size,
|
|
10
|
+
page,
|
|
11
|
+
});
|
|
12
|
+
const last = (reactors.pagination.pageNumber - 1) * size;
|
|
13
|
+
const data = reactors.data.map((reactor, index) => ({
|
|
14
|
+
'#': last + (index + 1),
|
|
15
|
+
...reactor,
|
|
16
|
+
}));
|
|
17
|
+
core_1.ux.table(data, {
|
|
18
|
+
'#': {},
|
|
19
|
+
id: {},
|
|
20
|
+
name: {},
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
data,
|
|
24
|
+
pagination: reactors.pagination,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const selectReactor = async (bt, page) => {
|
|
28
|
+
const reactors = await listReactors(bt, page);
|
|
29
|
+
const selection = await (0, utils_1.selectOrNavigate)(reactors, '#');
|
|
30
|
+
if (selection === 'previous') {
|
|
31
|
+
return selectReactor(bt, page - 1);
|
|
32
|
+
}
|
|
33
|
+
if (selection === 'next') {
|
|
34
|
+
return selectReactor(bt, page + 1);
|
|
35
|
+
}
|
|
36
|
+
return selection;
|
|
37
|
+
};
|
|
38
|
+
exports.selectReactor = selectReactor;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
|
+
import { PaginatedList } from '@basis-theory/basis-theory-js/types/sdk';
|
|
3
|
+
declare const createBt: (managementKey: string) => Promise<IBasisTheory>;
|
|
4
|
+
declare const FLAG_MANAGEMENT_KEY: {
|
|
5
|
+
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
|
+
};
|
|
7
|
+
declare const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
8
|
+
declare const selectOrNavigate: <T>(list: PaginatedList<T>, prop: string) => Promise<T | "previous" | "next">;
|
|
9
|
+
export { createBt, FLAG_MANAGEMENT_KEY, DEFAULT_LOGS_SERVER_PORT, selectOrNavigate, };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectOrNavigate = exports.DEFAULT_LOGS_SERVER_PORT = exports.FLAG_MANAGEMENT_KEY = exports.createBt = void 0;
|
|
4
|
+
const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const createBt = (managementKey) => new basis_theory_js_1.BasisTheory().init(managementKey);
|
|
7
|
+
exports.createBt = createBt;
|
|
8
|
+
const FLAG_MANAGEMENT_KEY = {
|
|
9
|
+
'management-key': core_1.Flags.string({
|
|
10
|
+
char: 'x',
|
|
11
|
+
env: 'BT_MANAGEMENT_KEY',
|
|
12
|
+
description: 'management key used for connecting with the reactor / proxy',
|
|
13
|
+
required: true,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
exports.FLAG_MANAGEMENT_KEY = FLAG_MANAGEMENT_KEY;
|
|
17
|
+
const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
18
|
+
exports.DEFAULT_LOGS_SERVER_PORT = DEFAULT_LOGS_SERVER_PORT;
|
|
19
|
+
const selectOrNavigate = async (list, prop) => {
|
|
20
|
+
const { data, pagination } = list;
|
|
21
|
+
let prompt = `Select one (${prop})`;
|
|
22
|
+
const hasNext = pagination.totalPages > pagination.pageNumber;
|
|
23
|
+
const hasPrevious = pagination.pageNumber > 1;
|
|
24
|
+
if (hasPrevious) {
|
|
25
|
+
prompt += " or 'p' for previous page ";
|
|
26
|
+
}
|
|
27
|
+
if (hasNext) {
|
|
28
|
+
prompt += " or 'n' for next page ";
|
|
29
|
+
}
|
|
30
|
+
const selection = await core_1.ux.prompt(prompt);
|
|
31
|
+
if (selection === 'p' && hasPrevious) {
|
|
32
|
+
return 'previous';
|
|
33
|
+
}
|
|
34
|
+
if (selection === 'n' && hasNext) {
|
|
35
|
+
return 'next';
|
|
36
|
+
}
|
|
37
|
+
const found = data.find((item) => selection === String(item[prop]));
|
|
38
|
+
if (found) {
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
core_1.ux.info('Invalid option.');
|
|
42
|
+
return selectOrNavigate(list, prop);
|
|
43
|
+
};
|
|
44
|
+
exports.selectOrNavigate = selectOrNavigate;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0
|
|
2
|
+
"version": "1.1.0",
|
|
3
3
|
"commands": {
|
|
4
|
-
"
|
|
5
|
-
"id": "
|
|
6
|
-
"description": "
|
|
4
|
+
"proxies": {
|
|
5
|
+
"id": "proxies",
|
|
6
|
+
"description": "list proxies",
|
|
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
|
+
"page": {
|
|
25
|
+
"name": "page",
|
|
26
|
+
"type": "option",
|
|
27
|
+
"char": "p",
|
|
28
|
+
"description": "proxies list page to fetch",
|
|
29
|
+
"multiple": false,
|
|
30
|
+
"default": 1
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"args": {}
|
|
34
|
+
},
|
|
35
|
+
"proxies:logs": {
|
|
36
|
+
"id": "proxies:logs",
|
|
37
|
+
"description": "Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions",
|
|
7
38
|
"strict": true,
|
|
8
39
|
"pluginName": "@basis-theory-labs/cli",
|
|
9
40
|
"pluginAlias": "@basis-theory-labs/cli",
|
|
@@ -14,6 +45,14 @@
|
|
|
14
45
|
"<%= config.bin %> <%= command.id %> -p 3000"
|
|
15
46
|
],
|
|
16
47
|
"flags": {
|
|
48
|
+
"management-key": {
|
|
49
|
+
"name": "management-key",
|
|
50
|
+
"type": "option",
|
|
51
|
+
"char": "x",
|
|
52
|
+
"description": "management key used for connecting with the reactor / proxy",
|
|
53
|
+
"required": true,
|
|
54
|
+
"multiple": false
|
|
55
|
+
},
|
|
17
56
|
"port": {
|
|
18
57
|
"name": "port",
|
|
19
58
|
"type": "option",
|
|
@@ -21,28 +60,84 @@
|
|
|
21
60
|
"description": "port to listen for incoming logs",
|
|
22
61
|
"multiple": false,
|
|
23
62
|
"default": 8220
|
|
24
|
-
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"args": {
|
|
66
|
+
"id": {
|
|
67
|
+
"name": "id",
|
|
68
|
+
"description": "Proxy id to connect to",
|
|
69
|
+
"required": true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"reactors": {
|
|
74
|
+
"id": "reactors",
|
|
75
|
+
"description": "list reactors",
|
|
76
|
+
"strict": true,
|
|
77
|
+
"pluginName": "@basis-theory-labs/cli",
|
|
78
|
+
"pluginAlias": "@basis-theory-labs/cli",
|
|
79
|
+
"pluginType": "core",
|
|
80
|
+
"aliases": [],
|
|
81
|
+
"examples": [
|
|
82
|
+
"<%= config.bin %> <%= command.id %>"
|
|
83
|
+
],
|
|
84
|
+
"flags": {
|
|
25
85
|
"management-key": {
|
|
26
86
|
"name": "management-key",
|
|
27
87
|
"type": "option",
|
|
88
|
+
"char": "x",
|
|
28
89
|
"description": "management key used for connecting with the reactor / proxy",
|
|
29
90
|
"required": true,
|
|
30
91
|
"multiple": false
|
|
31
92
|
},
|
|
32
|
-
"
|
|
33
|
-
"name": "
|
|
93
|
+
"page": {
|
|
94
|
+
"name": "page",
|
|
95
|
+
"type": "option",
|
|
96
|
+
"char": "p",
|
|
97
|
+
"description": "reactors list page to fetch",
|
|
98
|
+
"multiple": false,
|
|
99
|
+
"default": 1
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"args": {}
|
|
103
|
+
},
|
|
104
|
+
"reactors:logs": {
|
|
105
|
+
"id": "reactors:logs",
|
|
106
|
+
"description": "Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions",
|
|
107
|
+
"strict": true,
|
|
108
|
+
"pluginName": "@basis-theory-labs/cli",
|
|
109
|
+
"pluginAlias": "@basis-theory-labs/cli",
|
|
110
|
+
"pluginType": "core",
|
|
111
|
+
"aliases": [],
|
|
112
|
+
"examples": [
|
|
113
|
+
"<%= config.bin %> <%= command.id %>",
|
|
114
|
+
"<%= config.bin %> <%= command.id %> -p 3000"
|
|
115
|
+
],
|
|
116
|
+
"flags": {
|
|
117
|
+
"management-key": {
|
|
118
|
+
"name": "management-key",
|
|
34
119
|
"type": "option",
|
|
35
|
-
"
|
|
120
|
+
"char": "x",
|
|
121
|
+
"description": "management key used for connecting with the reactor / proxy",
|
|
122
|
+
"required": true,
|
|
36
123
|
"multiple": false
|
|
37
124
|
},
|
|
38
|
-
"
|
|
39
|
-
"name": "
|
|
125
|
+
"port": {
|
|
126
|
+
"name": "port",
|
|
40
127
|
"type": "option",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
128
|
+
"char": "p",
|
|
129
|
+
"description": "port to listen for incoming logs",
|
|
130
|
+
"multiple": false,
|
|
131
|
+
"default": 8220
|
|
43
132
|
}
|
|
44
133
|
},
|
|
45
|
-
"args": {
|
|
134
|
+
"args": {
|
|
135
|
+
"id": {
|
|
136
|
+
"name": "id",
|
|
137
|
+
"description": "Reactor id to connect to",
|
|
138
|
+
"required": true
|
|
139
|
+
}
|
|
140
|
+
}
|
|
46
141
|
}
|
|
47
142
|
}
|
|
48
143
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory-labs/cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Basis Theory CLI tool",
|
|
5
5
|
"author": "Davi Aquino @djejaquino",
|
|
6
6
|
"bin": {
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@basis-theory/basis-theory-js": "^1.77.0",
|
|
21
|
+
"@inquirer/input": "^1.2.1",
|
|
22
|
+
"@inquirer/prompts": "^2.1.1",
|
|
23
|
+
"@inquirer/select": "^1.2.1",
|
|
21
24
|
"@oclif/core": "^2",
|
|
22
25
|
"@oclif/plugin-help": "^5",
|
|
23
26
|
"@oclif/plugin-plugins": "^2.4.7",
|
package/dist/commands/logs.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const management_1 = require("../logs/management");
|
|
5
|
-
const server_1 = require("../logs/server");
|
|
6
|
-
class Logs extends core_1.Command {
|
|
7
|
-
async run() {
|
|
8
|
-
const { flags: { port, 'management-key': managementKey, 'reactor-id': reactorId, 'proxy-id': proxyId, }, } = await this.parse(Logs);
|
|
9
|
-
const url = await (0, server_1.createLogServer)(this, port);
|
|
10
|
-
await (0, management_1.connectToResource)({
|
|
11
|
-
managementKey,
|
|
12
|
-
proxyId,
|
|
13
|
-
reactorId,
|
|
14
|
-
url,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = Logs;
|
|
19
|
-
Logs.description = 'Display live Reactor / Proxy Transform logs output. Requires `reactor:read`, `reactor:update`, `proxy:read` and `proxy:update` Management Application permissions';
|
|
20
|
-
Logs.examples = [
|
|
21
|
-
'<%= config.bin %> <%= command.id %>',
|
|
22
|
-
'<%= config.bin %> <%= command.id %> -p 3000',
|
|
23
|
-
];
|
|
24
|
-
Logs.flags = {
|
|
25
|
-
port: core_1.Flags.integer({
|
|
26
|
-
char: 'p',
|
|
27
|
-
description: 'port to listen for incoming logs',
|
|
28
|
-
default: 8220,
|
|
29
|
-
}),
|
|
30
|
-
'management-key': core_1.Flags.string({
|
|
31
|
-
env: 'BT_MANAGEMENT_KEY',
|
|
32
|
-
description: 'management key used for connecting with the reactor / proxy',
|
|
33
|
-
required: true,
|
|
34
|
-
}),
|
|
35
|
-
'proxy-id': core_1.Flags.string({
|
|
36
|
-
description: 'proxy id to connect to',
|
|
37
|
-
exactlyOne: ['proxy-id', 'reactor-id'],
|
|
38
|
-
}),
|
|
39
|
-
'reactor-id': core_1.Flags.string({
|
|
40
|
-
description: 'reactor id to connect to',
|
|
41
|
-
exactlyOne: ['proxy-id', 'reactor-id'],
|
|
42
|
-
}),
|
|
43
|
-
};
|