@basis-theory-labs/cli 1.1.1 → 1.2.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 +43 -9
- package/dist/commands/proxies/create.d.ts +17 -0
- package/dist/commands/proxies/create.js +85 -0
- package/dist/commands/proxies/index.js +10 -12
- package/dist/commands/proxies/logs.d.ts +1 -1
- package/dist/commands/proxies/logs.js +7 -2
- package/dist/commands/reactors/index.js +10 -12
- package/dist/commands/reactors/logs.d.ts +1 -1
- package/dist/commands/reactors/logs.js +7 -2
- package/dist/logs/index.d.ts +2 -2
- package/dist/logs/index.js +3 -2
- package/dist/proxies/management.d.ts +21 -2
- package/dist/proxies/management.js +29 -1
- package/dist/utils.d.ts +7 -1
- package/dist/utils.js +40 -1
- package/oclif.manifest.json +77 -5
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
Basis Theory CLI
|
|
2
2
|
=================
|
|
3
3
|
|
|
4
|
+
[](https://www.npmjs.org/package/@basis-theory-labs/cli)
|
|
5
|
+
[](https://github.com/Basis-Theory-Labs/basistheory-cli/actions/workflows/release.yml)
|
|
6
|
+
|
|
4
7
|
Basis Theory CLI tool
|
|
5
8
|
|
|
6
9
|
Make sure to either have a `BT_MANAGEMENT_KEY` env var exported or pass a `management-key` flag to the commands.
|
|
@@ -16,7 +19,7 @@ $ npm install -g @basis-theory-labs/cli
|
|
|
16
19
|
$ bt COMMAND
|
|
17
20
|
running command...
|
|
18
21
|
$ bt (--version)
|
|
19
|
-
@basis-theory-labs/cli/1.
|
|
22
|
+
@basis-theory-labs/cli/1.2.0 linux-x64 node-v18.16.0
|
|
20
23
|
$ bt --help [COMMAND]
|
|
21
24
|
USAGE
|
|
22
25
|
$ bt COMMAND
|
|
@@ -26,9 +29,10 @@ USAGE
|
|
|
26
29
|
# Commands
|
|
27
30
|
<!-- commands -->
|
|
28
31
|
* [`bt proxies`](#bt-proxies)
|
|
29
|
-
* [`bt proxies
|
|
32
|
+
* [`bt proxies create`](#bt-proxies-create)
|
|
33
|
+
* [`bt proxies logs [ID]`](#bt-proxies-logs-id)
|
|
30
34
|
* [`bt reactors`](#bt-reactors)
|
|
31
|
-
* [`bt reactors logs ID`](#bt-reactors-logs-id)
|
|
35
|
+
* [`bt reactors logs [ID]`](#bt-reactors-logs-id)
|
|
32
36
|
|
|
33
37
|
## `bt proxies`
|
|
34
38
|
|
|
@@ -49,15 +53,41 @@ EXAMPLES
|
|
|
49
53
|
$ bt proxies
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
56
|
+
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.2.0/dist/commands/proxies/index.ts)_
|
|
57
|
+
|
|
58
|
+
## `bt proxies create`
|
|
59
|
+
|
|
60
|
+
Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
USAGE
|
|
64
|
+
$ bt proxies create -x <value> [-n <value>] [-u <value>] [-q <value>] [-s <value>] [-i <value>] [-c <value>] [-a]
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
FLAGS
|
|
67
|
+
-a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked. Default:
|
|
68
|
+
true
|
|
69
|
+
-c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
|
|
70
|
+
-i, --application-id=<value> application ID to use in the Proxy
|
|
71
|
+
-n, --name=<value> name of the Proxy
|
|
72
|
+
-q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
|
|
73
|
+
-s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
|
|
74
|
+
-u, --destination-url=<value> URL to which requests will be proxied
|
|
75
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
76
|
+
|
|
77
|
+
DESCRIPTION
|
|
78
|
+
Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission
|
|
79
|
+
|
|
80
|
+
EXAMPLES
|
|
81
|
+
$ bt proxies create
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## `bt proxies logs [ID]`
|
|
55
85
|
|
|
56
86
|
Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions
|
|
57
87
|
|
|
58
88
|
```
|
|
59
89
|
USAGE
|
|
60
|
-
$ bt proxies logs ID -x <value> [-p <value>]
|
|
90
|
+
$ bt proxies logs [ID] -x <value> [-p <value>]
|
|
61
91
|
|
|
62
92
|
ARGUMENTS
|
|
63
93
|
ID Proxy id to connect to
|
|
@@ -70,6 +100,8 @@ DESCRIPTION
|
|
|
70
100
|
Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions
|
|
71
101
|
|
|
72
102
|
EXAMPLES
|
|
103
|
+
$ bt proxies logs
|
|
104
|
+
|
|
73
105
|
$ bt proxies logs 03858bf5-32d3-4a2e-b74b-daeea0883bca
|
|
74
106
|
|
|
75
107
|
$ bt proxies logs 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000
|
|
@@ -94,15 +126,15 @@ EXAMPLES
|
|
|
94
126
|
$ bt reactors
|
|
95
127
|
```
|
|
96
128
|
|
|
97
|
-
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
129
|
+
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.2.0/dist/commands/reactors/index.ts)_
|
|
98
130
|
|
|
99
|
-
## `bt reactors logs ID`
|
|
131
|
+
## `bt reactors logs [ID]`
|
|
100
132
|
|
|
101
133
|
Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions
|
|
102
134
|
|
|
103
135
|
```
|
|
104
136
|
USAGE
|
|
105
|
-
$ bt reactors logs ID -x <value> [-p <value>]
|
|
137
|
+
$ bt reactors logs [ID] -x <value> [-p <value>]
|
|
106
138
|
|
|
107
139
|
ARGUMENTS
|
|
108
140
|
ID Reactor id to connect to
|
|
@@ -115,6 +147,8 @@ DESCRIPTION
|
|
|
115
147
|
Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions
|
|
116
148
|
|
|
117
149
|
EXAMPLES
|
|
150
|
+
$ bt reactors logs
|
|
151
|
+
|
|
118
152
|
$ bt reactors logs 03858bf5-32d3-4a2e-b74b-daeea0883bca
|
|
119
153
|
|
|
120
154
|
$ bt reactors logs 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Command } from '@oclif/core';
|
|
3
|
+
export default class Create extends Command {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
'destination-url': import("@oclif/core/lib/interfaces/parser").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
'request-transform-code': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
'response-transform-code': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
'require-auth': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
14
|
+
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const management_1 = require("../../proxies/management");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
class Create extends core_1.Command {
|
|
7
|
+
async run() {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const { flags, metadata } = await this.parse(Create);
|
|
10
|
+
const name = await (0, utils_1.promptStringIfUndefined)(flags.name, {
|
|
11
|
+
message: 'What is the Proxy name?',
|
|
12
|
+
validate: (value) => Boolean(value),
|
|
13
|
+
});
|
|
14
|
+
const destinationUrl = (await (0, utils_1.promptUrlIfUndefined)(flags['destination-url'], {
|
|
15
|
+
message: 'What is the Proxy destination URL?',
|
|
16
|
+
})).toString();
|
|
17
|
+
const requestTransformCode = await (0, utils_1.promptStringIfUndefined)(flags['request-transform-code'], {
|
|
18
|
+
message: '(Optional) Enter the Request Transform code file path:',
|
|
19
|
+
});
|
|
20
|
+
const responseTransformCode = await (0, utils_1.promptStringIfUndefined)(flags['response-transform-code'], {
|
|
21
|
+
message: '(Optional) Enter the Response Transform code file path:',
|
|
22
|
+
});
|
|
23
|
+
const applicationId = await (0, utils_1.promptStringIfUndefined)(flags['application-id'], {
|
|
24
|
+
message: '(Optional) Enter the Application ID to use in the Proxy:',
|
|
25
|
+
});
|
|
26
|
+
const configuration = await (0, utils_1.promptStringIfUndefined)(flags.configuration, {
|
|
27
|
+
message: '(Optional) Enter the configuration file path (.env format):',
|
|
28
|
+
});
|
|
29
|
+
const requireAuth = await (0, utils_1.promptBooleanIfUndefined)(((_b = (_a = metadata.flags) === null || _a === void 0 ? void 0 : _a['require-auth']) === null || _b === void 0 ? void 0 : _b.setFromDefault)
|
|
30
|
+
? undefined
|
|
31
|
+
: flags['require-auth'], {
|
|
32
|
+
message: 'Does the Proxy require Basis Theory authentication?',
|
|
33
|
+
default: true,
|
|
34
|
+
});
|
|
35
|
+
const bt = await (0, utils_1.createBt)(flags['management-key']);
|
|
36
|
+
const { id, key } = await (0, management_1.createProxy)(bt, {
|
|
37
|
+
name,
|
|
38
|
+
destinationUrl,
|
|
39
|
+
requestTransformCode,
|
|
40
|
+
responseTransformCode,
|
|
41
|
+
applicationId,
|
|
42
|
+
configuration,
|
|
43
|
+
requireAuth,
|
|
44
|
+
});
|
|
45
|
+
this.log('Proxy created successfully!');
|
|
46
|
+
this.log(`id: ${id}`);
|
|
47
|
+
this.log(`key: ${key}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = Create;
|
|
51
|
+
Create.description = 'Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission';
|
|
52
|
+
Create.examples = ['<%= config.bin %> <%= command.id %> '];
|
|
53
|
+
Create.flags = {
|
|
54
|
+
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
55
|
+
name: core_1.Flags.string({
|
|
56
|
+
char: 'n',
|
|
57
|
+
description: 'name of the Proxy',
|
|
58
|
+
}),
|
|
59
|
+
'destination-url': core_1.Flags.url({
|
|
60
|
+
char: 'u',
|
|
61
|
+
description: 'URL to which requests will be proxied',
|
|
62
|
+
}),
|
|
63
|
+
'request-transform-code': core_1.Flags.file({
|
|
64
|
+
char: 'q',
|
|
65
|
+
description: 'path to JavaScript file containing a Request Transform code',
|
|
66
|
+
}),
|
|
67
|
+
'response-transform-code': core_1.Flags.file({
|
|
68
|
+
char: 's',
|
|
69
|
+
description: 'path to JavaScript file containing a Response Transform code',
|
|
70
|
+
}),
|
|
71
|
+
'application-id': core_1.Flags.string({
|
|
72
|
+
char: 'i',
|
|
73
|
+
description: 'application ID to use in the Proxy',
|
|
74
|
+
}),
|
|
75
|
+
configuration: core_1.Flags.file({
|
|
76
|
+
char: 'c',
|
|
77
|
+
description: 'path to configuration file (.env format) to use in the Proxy',
|
|
78
|
+
}),
|
|
79
|
+
'require-auth': core_1.Flags.boolean({
|
|
80
|
+
char: 'a',
|
|
81
|
+
description: 'whether the Proxy requires Basis Theory authentication to be invoked. Default: true',
|
|
82
|
+
allowNo: true,
|
|
83
|
+
default: true,
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
@@ -13,6 +13,10 @@ class Proxies extends core_1.Command {
|
|
|
13
13
|
const action = await (0, prompts_1.select)({
|
|
14
14
|
message: 'Select action to perform',
|
|
15
15
|
choices: [
|
|
16
|
+
{
|
|
17
|
+
name: 'See details',
|
|
18
|
+
value: 'details',
|
|
19
|
+
},
|
|
16
20
|
{
|
|
17
21
|
name: 'Logs',
|
|
18
22
|
value: 'logs',
|
|
@@ -24,20 +28,14 @@ class Proxies extends core_1.Command {
|
|
|
24
28
|
},
|
|
25
29
|
],
|
|
26
30
|
});
|
|
31
|
+
if (action === 'details') {
|
|
32
|
+
this.log(JSON.stringify(proxy, undefined, 2));
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
27
35
|
if (action === 'logs') {
|
|
28
|
-
|
|
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);
|
|
36
|
+
return (0, logs_1.showProxyLogs)(bt, proxy.id);
|
|
40
37
|
}
|
|
38
|
+
return undefined;
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
exports.default = Proxies;
|
|
@@ -3,7 +3,7 @@ export default class Logs extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
6
|
-
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
6
|
+
id: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
static flags: {
|
|
9
9
|
port: import("@oclif/core/lib/interfaces/parser").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -2,23 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const logs_1 = require("../../logs");
|
|
5
|
+
const management_1 = require("../../proxies/management");
|
|
5
6
|
const utils_1 = require("../../utils");
|
|
6
7
|
class Logs extends core_1.Command {
|
|
7
8
|
async run() {
|
|
8
9
|
const { flags: { port, 'management-key': managementKey }, args: { id }, } = await this.parse(Logs);
|
|
9
10
|
const bt = await (0, utils_1.createBt)(managementKey);
|
|
10
|
-
|
|
11
|
+
if (id) {
|
|
12
|
+
return (0, logs_1.showProxyLogs)(bt, id, port);
|
|
13
|
+
}
|
|
14
|
+
const proxy = await (0, management_1.selectProxy)(bt, 1);
|
|
15
|
+
return (0, logs_1.showProxyLogs)(bt, proxy.id, port);
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
18
|
exports.default = Logs;
|
|
14
19
|
Logs.description = 'Display live Proxy Transform logs output. Requires `proxy:read` and `proxy:update` Management Application permissions';
|
|
15
20
|
Logs.examples = [
|
|
21
|
+
'<%= config.bin %> <%= command.id %>',
|
|
16
22
|
'<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
|
|
17
23
|
'<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000',
|
|
18
24
|
];
|
|
19
25
|
Logs.args = {
|
|
20
26
|
id: core_1.Args.string({
|
|
21
|
-
required: true,
|
|
22
27
|
description: 'Proxy id to connect to',
|
|
23
28
|
}),
|
|
24
29
|
};
|
|
@@ -13,6 +13,10 @@ class Reactors extends core_1.Command {
|
|
|
13
13
|
const action = await (0, prompts_1.select)({
|
|
14
14
|
message: 'Select action to perform',
|
|
15
15
|
choices: [
|
|
16
|
+
{
|
|
17
|
+
name: 'See details',
|
|
18
|
+
value: 'details',
|
|
19
|
+
},
|
|
16
20
|
{
|
|
17
21
|
name: 'Logs',
|
|
18
22
|
value: 'logs',
|
|
@@ -24,20 +28,14 @@ class Reactors extends core_1.Command {
|
|
|
24
28
|
},
|
|
25
29
|
],
|
|
26
30
|
});
|
|
31
|
+
if (action === 'details') {
|
|
32
|
+
this.log(JSON.stringify(reactor, undefined, 2));
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
27
35
|
if (action === 'logs') {
|
|
28
|
-
|
|
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);
|
|
36
|
+
return (0, logs_1.showReactorLogs)(bt, reactor.id);
|
|
40
37
|
}
|
|
38
|
+
return undefined;
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
exports.default = Reactors;
|
|
@@ -3,7 +3,7 @@ export default class Logs extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
6
|
-
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
6
|
+
id: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
static flags: {
|
|
9
9
|
port: import("@oclif/core/lib/interfaces/parser").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -2,23 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const logs_1 = require("../../logs");
|
|
5
|
+
const management_1 = require("../../reactors/management");
|
|
5
6
|
const utils_1 = require("../../utils");
|
|
6
7
|
class Logs extends core_1.Command {
|
|
7
8
|
async run() {
|
|
8
9
|
const { flags: { port, 'management-key': managementKey }, args: { id }, } = await this.parse(Logs);
|
|
9
10
|
const bt = await (0, utils_1.createBt)(managementKey);
|
|
10
|
-
|
|
11
|
+
if (id) {
|
|
12
|
+
return (0, logs_1.showReactorLogs)(bt, id, port);
|
|
13
|
+
}
|
|
14
|
+
const reactor = await (0, management_1.selectReactor)(bt, 1);
|
|
15
|
+
return (0, logs_1.showReactorLogs)(bt, reactor.id, port);
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
18
|
exports.default = Logs;
|
|
14
19
|
Logs.description = 'Display live Reactor logs output. Requires `reactor:read` and `reactor:update` Management Application permissions';
|
|
15
20
|
Logs.examples = [
|
|
21
|
+
'<%= config.bin %> <%= command.id %>',
|
|
16
22
|
'<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca',
|
|
17
23
|
'<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000',
|
|
18
24
|
];
|
|
19
25
|
Logs.args = {
|
|
20
26
|
id: core_1.Args.string({
|
|
21
|
-
required: true,
|
|
22
27
|
description: 'Reactor id to connect to',
|
|
23
28
|
}),
|
|
24
29
|
};
|
package/dist/logs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { BasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
|
-
declare const showProxyLogs: (bt: BasisTheory,
|
|
3
|
-
declare const showReactorLogs: (bt: BasisTheory,
|
|
2
|
+
declare const showProxyLogs: (bt: BasisTheory, id: string, port?: number) => Promise<void>;
|
|
3
|
+
declare const showReactorLogs: (bt: BasisTheory, id: string, port?: number) => Promise<void>;
|
|
4
4
|
export { showProxyLogs, showReactorLogs };
|
package/dist/logs/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.showReactorLogs = exports.showProxyLogs = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
4
5
|
const management_1 = require("./management");
|
|
5
6
|
const server_1 = require("./server");
|
|
6
|
-
const showProxyLogs = async (bt,
|
|
7
|
+
const showProxyLogs = async (bt, id, port = utils_1.DEFAULT_LOGS_SERVER_PORT) => {
|
|
7
8
|
const url = await (0, server_1.createLogServer)(port);
|
|
8
9
|
await (0, management_1.connectToProxy)(bt, id, url);
|
|
9
10
|
};
|
|
10
11
|
exports.showProxyLogs = showProxyLogs;
|
|
11
|
-
const showReactorLogs = async (bt,
|
|
12
|
+
const showReactorLogs = async (bt, id, port = utils_1.DEFAULT_LOGS_SERVER_PORT) => {
|
|
12
13
|
const url = await (0, server_1.createLogServer)(port);
|
|
13
14
|
await (0, management_1.connectToReactor)(bt, id, url);
|
|
14
15
|
};
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
import type { Proxy } from '@basis-theory/basis-theory-js/types/models';
|
|
1
|
+
import type { CreateProxy, Proxy } from '@basis-theory/basis-theory-js/types/models';
|
|
2
2
|
import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
3
3
|
declare const selectProxy: (bt: IBasisTheory, page: number) => Promise<Proxy>;
|
|
4
|
-
|
|
4
|
+
interface CreateProxyModel extends Omit<CreateProxy, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'> {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
applicationId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Path to code file
|
|
11
|
+
*/
|
|
12
|
+
requestTransformCode?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Path to code file
|
|
15
|
+
*/
|
|
16
|
+
responseTransformCode?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Path to .env file
|
|
19
|
+
*/
|
|
20
|
+
configuration?: string;
|
|
21
|
+
}
|
|
22
|
+
declare const createProxy: (bt: IBasisTheory, { name, destinationUrl, applicationId, requestTransformCode, responseTransformCode, configuration, requireAuth, }: CreateProxyModel) => Promise<Proxy>;
|
|
23
|
+
export { selectProxy, createProxy };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectProxy = void 0;
|
|
3
|
+
exports.createProxy = exports.selectProxy = void 0;
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
+
const dotenv_1 = require("dotenv");
|
|
5
6
|
const utils_1 = require("../utils");
|
|
6
7
|
const listProxies = async (bt, page) => {
|
|
7
8
|
const size = 5;
|
|
@@ -36,6 +37,9 @@ const listProxies = async (bt, page) => {
|
|
|
36
37
|
header: 'Response Transform',
|
|
37
38
|
get: (proxy) => { var _a; return (((_a = proxy.responseTransform) === null || _a === void 0 ? void 0 : _a.code) ? 'yes' : 'no'); },
|
|
38
39
|
},
|
|
40
|
+
application_id: {
|
|
41
|
+
header: 'Application Id',
|
|
42
|
+
},
|
|
39
43
|
/* eslint-enable camelcase */
|
|
40
44
|
});
|
|
41
45
|
return {
|
|
@@ -55,3 +59,27 @@ const selectProxy = async (bt, page) => {
|
|
|
55
59
|
return selection;
|
|
56
60
|
};
|
|
57
61
|
exports.selectProxy = selectProxy;
|
|
62
|
+
const createProxy = (bt, { name, destinationUrl, applicationId, requestTransformCode, responseTransformCode, configuration, requireAuth, }) => bt.proxies.create({
|
|
63
|
+
name,
|
|
64
|
+
destinationUrl: destinationUrl.toString(),
|
|
65
|
+
requestTransform: requestTransformCode
|
|
66
|
+
? {
|
|
67
|
+
code: (0, utils_1.readFileContents)(requestTransformCode),
|
|
68
|
+
}
|
|
69
|
+
: undefined,
|
|
70
|
+
responseTransform: responseTransformCode
|
|
71
|
+
? {
|
|
72
|
+
code: (0, utils_1.readFileContents)(responseTransformCode),
|
|
73
|
+
}
|
|
74
|
+
: undefined,
|
|
75
|
+
application: applicationId
|
|
76
|
+
? {
|
|
77
|
+
id: applicationId,
|
|
78
|
+
}
|
|
79
|
+
: undefined,
|
|
80
|
+
configuration: configuration
|
|
81
|
+
? (0, dotenv_1.parse)((0, utils_1.readFileContents)(configuration))
|
|
82
|
+
: undefined,
|
|
83
|
+
requireAuth,
|
|
84
|
+
});
|
|
85
|
+
exports.createProxy = createProxy;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
2
|
import { PaginatedList } from '@basis-theory/basis-theory-js/types/sdk';
|
|
3
|
+
import confirm from '@inquirer/confirm';
|
|
4
|
+
import input from '@inquirer/input';
|
|
3
5
|
declare const createBt: (managementKey: string) => Promise<IBasisTheory>;
|
|
4
6
|
declare const FLAG_MANAGEMENT_KEY: {
|
|
5
7
|
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
8
|
};
|
|
7
9
|
declare const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
8
10
|
declare const selectOrNavigate: <T>(list: PaginatedList<T>, prop: string) => Promise<T | "previous" | "next">;
|
|
9
|
-
|
|
11
|
+
declare const promptStringIfUndefined: (value: string | undefined, options: Parameters<typeof input>[0]) => Promise<string>;
|
|
12
|
+
declare const promptUrlIfUndefined: (value: URL | undefined, options: Parameters<typeof input>[0]) => Promise<URL>;
|
|
13
|
+
declare const promptBooleanIfUndefined: (value: boolean | undefined, options: Parameters<typeof confirm>[0]) => Promise<boolean>;
|
|
14
|
+
declare const readFileContents: (filePath: string) => string;
|
|
15
|
+
export { createBt, FLAG_MANAGEMENT_KEY, DEFAULT_LOGS_SERVER_PORT, selectOrNavigate, promptStringIfUndefined, promptUrlIfUndefined, promptBooleanIfUndefined, readFileContents, };
|
package/dist/utils.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectOrNavigate = exports.DEFAULT_LOGS_SERVER_PORT = exports.FLAG_MANAGEMENT_KEY = exports.createBt = void 0;
|
|
3
|
+
exports.readFileContents = exports.promptBooleanIfUndefined = exports.promptUrlIfUndefined = exports.promptStringIfUndefined = exports.selectOrNavigate = exports.DEFAULT_LOGS_SERVER_PORT = exports.FLAG_MANAGEMENT_KEY = exports.createBt = void 0;
|
|
4
4
|
const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
|
|
5
|
+
const confirm_1 = require("@inquirer/confirm");
|
|
6
|
+
const input_1 = require("@inquirer/input");
|
|
5
7
|
const core_1 = require("@oclif/core");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
6
10
|
const createBt = (managementKey) => new basis_theory_js_1.BasisTheory().init(managementKey);
|
|
7
11
|
exports.createBt = createBt;
|
|
8
12
|
const FLAG_MANAGEMENT_KEY = {
|
|
@@ -42,3 +46,38 @@ const selectOrNavigate = async (list, prop) => {
|
|
|
42
46
|
return selectOrNavigate(list, prop);
|
|
43
47
|
};
|
|
44
48
|
exports.selectOrNavigate = selectOrNavigate;
|
|
49
|
+
const promptStringIfUndefined = (value, options) => {
|
|
50
|
+
if (value) {
|
|
51
|
+
return Promise.resolve(value);
|
|
52
|
+
}
|
|
53
|
+
return (0, input_1.default)(options);
|
|
54
|
+
};
|
|
55
|
+
exports.promptStringIfUndefined = promptStringIfUndefined;
|
|
56
|
+
const promptUrlIfUndefined = async (value, options) => {
|
|
57
|
+
if (value) {
|
|
58
|
+
return Promise.resolve(value);
|
|
59
|
+
}
|
|
60
|
+
return new URL(await (0, input_1.default)({
|
|
61
|
+
validate: (val) => {
|
|
62
|
+
try {
|
|
63
|
+
// eslint-disable-next-line no-new
|
|
64
|
+
new URL(val);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return 'Please enter a valid URL';
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
...options,
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
exports.promptUrlIfUndefined = promptUrlIfUndefined;
|
|
75
|
+
const promptBooleanIfUndefined = (value, options) => {
|
|
76
|
+
if (value !== undefined) {
|
|
77
|
+
return Promise.resolve(value);
|
|
78
|
+
}
|
|
79
|
+
return (0, confirm_1.default)(options);
|
|
80
|
+
};
|
|
81
|
+
exports.promptBooleanIfUndefined = promptBooleanIfUndefined;
|
|
82
|
+
const readFileContents = (filePath) => fs.readFileSync(path.resolve(process.cwd(), filePath)).toString();
|
|
83
|
+
exports.readFileContents = readFileContents;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.2.0",
|
|
3
3
|
"commands": {
|
|
4
|
+
"proxies:create": {
|
|
5
|
+
"id": "proxies:create",
|
|
6
|
+
"description": "Creates a new Pre-Configured Proxy. Requires `proxy: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
|
+
"name": {
|
|
25
|
+
"name": "name",
|
|
26
|
+
"type": "option",
|
|
27
|
+
"char": "n",
|
|
28
|
+
"description": "name of the Proxy",
|
|
29
|
+
"multiple": false
|
|
30
|
+
},
|
|
31
|
+
"destination-url": {
|
|
32
|
+
"name": "destination-url",
|
|
33
|
+
"type": "option",
|
|
34
|
+
"char": "u",
|
|
35
|
+
"description": "URL to which requests will be proxied",
|
|
36
|
+
"multiple": false
|
|
37
|
+
},
|
|
38
|
+
"request-transform-code": {
|
|
39
|
+
"name": "request-transform-code",
|
|
40
|
+
"type": "option",
|
|
41
|
+
"char": "q",
|
|
42
|
+
"description": "path to JavaScript file containing a Request Transform code",
|
|
43
|
+
"multiple": false
|
|
44
|
+
},
|
|
45
|
+
"response-transform-code": {
|
|
46
|
+
"name": "response-transform-code",
|
|
47
|
+
"type": "option",
|
|
48
|
+
"char": "s",
|
|
49
|
+
"description": "path to JavaScript file containing a Response Transform code",
|
|
50
|
+
"multiple": false
|
|
51
|
+
},
|
|
52
|
+
"application-id": {
|
|
53
|
+
"name": "application-id",
|
|
54
|
+
"type": "option",
|
|
55
|
+
"char": "i",
|
|
56
|
+
"description": "application ID to use in the Proxy",
|
|
57
|
+
"multiple": false
|
|
58
|
+
},
|
|
59
|
+
"configuration": {
|
|
60
|
+
"name": "configuration",
|
|
61
|
+
"type": "option",
|
|
62
|
+
"char": "c",
|
|
63
|
+
"description": "path to configuration file (.env format) to use in the Proxy",
|
|
64
|
+
"multiple": false
|
|
65
|
+
},
|
|
66
|
+
"require-auth": {
|
|
67
|
+
"name": "require-auth",
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"char": "a",
|
|
70
|
+
"description": "whether the Proxy requires Basis Theory authentication to be invoked. Default: true",
|
|
71
|
+
"allowNo": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"args": {}
|
|
75
|
+
},
|
|
4
76
|
"proxies": {
|
|
5
77
|
"id": "proxies",
|
|
6
78
|
"description": "List Proxies. Requires `proxy:read` Management Application permission",
|
|
@@ -41,6 +113,7 @@
|
|
|
41
113
|
"pluginType": "core",
|
|
42
114
|
"aliases": [],
|
|
43
115
|
"examples": [
|
|
116
|
+
"<%= config.bin %> <%= command.id %>",
|
|
44
117
|
"<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca",
|
|
45
118
|
"<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000"
|
|
46
119
|
],
|
|
@@ -65,8 +138,7 @@
|
|
|
65
138
|
"args": {
|
|
66
139
|
"id": {
|
|
67
140
|
"name": "id",
|
|
68
|
-
"description": "Proxy id to connect to"
|
|
69
|
-
"required": true
|
|
141
|
+
"description": "Proxy id to connect to"
|
|
70
142
|
}
|
|
71
143
|
}
|
|
72
144
|
},
|
|
@@ -110,6 +182,7 @@
|
|
|
110
182
|
"pluginType": "core",
|
|
111
183
|
"aliases": [],
|
|
112
184
|
"examples": [
|
|
185
|
+
"<%= config.bin %> <%= command.id %>",
|
|
113
186
|
"<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca",
|
|
114
187
|
"<%= config.bin %> <%= command.id %> 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000"
|
|
115
188
|
],
|
|
@@ -134,8 +207,7 @@
|
|
|
134
207
|
"args": {
|
|
135
208
|
"id": {
|
|
136
209
|
"name": "id",
|
|
137
|
-
"description": "Reactor id to connect to"
|
|
138
|
-
"required": true
|
|
210
|
+
"description": "Reactor id to connect to"
|
|
139
211
|
}
|
|
140
212
|
}
|
|
141
213
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory-labs/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Basis Theory CLI tool",
|
|
5
5
|
"author": "Davi Aquino @djejaquino",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"/oclif.manifest.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@basis-theory/basis-theory-js": "^1.77.
|
|
20
|
+
"@basis-theory/basis-theory-js": "^1.77.1",
|
|
21
|
+
"@inquirer/confirm": "^2.0.3",
|
|
21
22
|
"@inquirer/input": "^1.2.1",
|
|
22
23
|
"@inquirer/prompts": "^2.1.1",
|
|
23
24
|
"@inquirer/select": "^1.2.1",
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
"@oclif/plugin-plugins": "^2.4.7",
|
|
27
28
|
"cloudflared": "^0.4.0",
|
|
28
29
|
"debug": "^4.3.4",
|
|
30
|
+
"dotenv": "^16.3.1",
|
|
29
31
|
"pino": "^8.14.1",
|
|
30
32
|
"pino-pretty": "^10.0.0",
|
|
31
33
|
"serialize-error": "^11.0.0",
|