@basis-theory-labs/cli 1.2.1 → 1.3.1
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 +40 -3
- package/dist/base.d.ts +12 -0
- package/dist/base.js +41 -0
- package/dist/commands/proxies/create.d.ts +2 -3
- package/dist/commands/proxies/create.js +15 -44
- package/dist/commands/proxies/index.d.ts +2 -3
- package/dist/commands/proxies/index.js +3 -5
- package/dist/commands/proxies/logs.d.ts +2 -3
- package/dist/commands/proxies/logs.js +4 -6
- package/dist/commands/proxies/update.d.ts +19 -0
- package/dist/commands/proxies/update.js +42 -0
- package/dist/commands/reactors/index.d.ts +2 -3
- package/dist/commands/reactors/index.js +3 -5
- package/dist/commands/reactors/logs.d.ts +2 -3
- package/dist/commands/reactors/logs.js +4 -6
- package/dist/logs/{management.js → connect.js} +5 -3
- package/dist/logs/index.d.ts +2 -1
- package/dist/logs/index.js +8 -7
- package/dist/logs/{parser.d.ts → parse.d.ts} +1 -1
- package/dist/logs/{parser.js → parse.js} +2 -3
- package/dist/logs/server.js +11 -3
- package/dist/proxies/management.d.ts +4 -21
- package/dist/proxies/management.js +12 -25
- package/dist/proxies/utils.d.ts +36 -0
- package/dist/proxies/utils.js +58 -0
- package/dist/reactors/management.d.ts +3 -2
- package/dist/reactors/management.js +8 -1
- package/dist/utils.d.ts +1 -7
- package/dist/utils.js +1 -15
- package/oclif.manifest.json +124 -1
- package/package.json +2 -2
- /package/dist/logs/{management.d.ts → connect.d.ts} +0 -0
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.3.1 linux-x64 node-v18.16.1
|
|
23
23
|
$ bt --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ bt COMMAND
|
|
@@ -31,6 +31,7 @@ USAGE
|
|
|
31
31
|
* [`bt proxies`](#bt-proxies)
|
|
32
32
|
* [`bt proxies create`](#bt-proxies-create)
|
|
33
33
|
* [`bt proxies logs [ID]`](#bt-proxies-logs-id)
|
|
34
|
+
* [`bt proxies update ID`](#bt-proxies-update-id)
|
|
34
35
|
* [`bt reactors`](#bt-reactors)
|
|
35
36
|
* [`bt reactors logs [ID]`](#bt-reactors-logs-id)
|
|
36
37
|
|
|
@@ -53,7 +54,7 @@ EXAMPLES
|
|
|
53
54
|
$ bt proxies
|
|
54
55
|
```
|
|
55
56
|
|
|
56
|
-
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
57
|
+
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.3.1/dist/commands/proxies/index.ts)_
|
|
57
58
|
|
|
58
59
|
## `bt proxies create`
|
|
59
60
|
|
|
@@ -107,6 +108,42 @@ EXAMPLES
|
|
|
107
108
|
$ bt proxies logs 03858bf5-32d3-4a2e-b74b-daeea0883bca -p 3000
|
|
108
109
|
```
|
|
109
110
|
|
|
111
|
+
## `bt proxies update ID`
|
|
112
|
+
|
|
113
|
+
Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
USAGE
|
|
117
|
+
$ bt proxies update ID -x <value> [-n <value>] [-u <value>] [-q <value>] [-s <value>] [-i <value>] [-c <value>]
|
|
118
|
+
[-a]
|
|
119
|
+
|
|
120
|
+
ARGUMENTS
|
|
121
|
+
ID Proxy id to update
|
|
122
|
+
|
|
123
|
+
FLAGS
|
|
124
|
+
-a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked. Default:
|
|
125
|
+
true
|
|
126
|
+
-c, --configuration=<value> path to configuration file (.env format) to use in the Proxy
|
|
127
|
+
-i, --application-id=<value> application ID to use in the Proxy
|
|
128
|
+
-n, --name=<value> name of the Proxy
|
|
129
|
+
-q, --request-transform-code=<value> path to JavaScript file containing a Request Transform code
|
|
130
|
+
-s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
|
|
131
|
+
-u, --destination-url=<value> URL to which requests will be proxied
|
|
132
|
+
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
133
|
+
|
|
134
|
+
DESCRIPTION
|
|
135
|
+
Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission
|
|
136
|
+
|
|
137
|
+
EXAMPLES
|
|
138
|
+
$ bt proxies update
|
|
139
|
+
|
|
140
|
+
$ bt proxies update --destination-url https://echo.basistheory.com
|
|
141
|
+
|
|
142
|
+
$ bt proxies update --request-transform-code ./myRequestTransform.js
|
|
143
|
+
|
|
144
|
+
$ bt proxies update --configuration ./.env.proxy
|
|
145
|
+
```
|
|
146
|
+
|
|
110
147
|
## `bt reactors`
|
|
111
148
|
|
|
112
149
|
List Reactors. Requires `reactor:read` Management Application permission
|
|
@@ -126,7 +163,7 @@ EXAMPLES
|
|
|
126
163
|
$ bt reactors
|
|
127
164
|
```
|
|
128
165
|
|
|
129
|
-
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.
|
|
166
|
+
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v1.3.1/dist/commands/reactors/index.ts)_
|
|
130
167
|
|
|
131
168
|
## `bt reactors logs [ID]`
|
|
132
169
|
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
|
+
import { Command } from '@oclif/core';
|
|
3
|
+
import type { ArgOutput, FlagOutput, Input, ParserOutput } from '@oclif/core/lib/interfaces/parser';
|
|
4
|
+
export declare abstract class BaseCommand extends Command {
|
|
5
|
+
static baseFlags: {
|
|
6
|
+
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
'api-base-url': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, B, A> & {
|
|
10
|
+
bt: IBasisTheory;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCommand = void 0;
|
|
4
|
+
const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
class BaseCommand extends core_1.Command {
|
|
7
|
+
async parse(options, argv) {
|
|
8
|
+
const { flags, ...parsed } = await super.parse(options, argv);
|
|
9
|
+
const { 'management-key': managementKey, 'api-base-url': apiBaseUrl } = flags;
|
|
10
|
+
const bt = await new basis_theory_js_1.BasisTheory().init(managementKey, {
|
|
11
|
+
appInfo: {
|
|
12
|
+
name: this.config.userAgent,
|
|
13
|
+
version: this.config.version,
|
|
14
|
+
},
|
|
15
|
+
...(apiBaseUrl
|
|
16
|
+
? {
|
|
17
|
+
apiBaseUrl,
|
|
18
|
+
}
|
|
19
|
+
: {}),
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
...parsed,
|
|
23
|
+
flags,
|
|
24
|
+
bt,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.BaseCommand = BaseCommand;
|
|
29
|
+
BaseCommand.baseFlags = {
|
|
30
|
+
'management-key': core_1.Flags.string({
|
|
31
|
+
char: 'x',
|
|
32
|
+
env: 'BT_MANAGEMENT_KEY',
|
|
33
|
+
description: 'management key used for connecting with the reactor / proxy',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
'api-base-url': core_1.Flags.string({
|
|
37
|
+
env: 'BT_API_BASE_URL',
|
|
38
|
+
description: 'base API URL to use in Basis Theory SDK',
|
|
39
|
+
hidden: true,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
export default class Create extends
|
|
2
|
+
import { BaseCommand } from '../../base';
|
|
3
|
+
export default class Create extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
@@ -11,7 +11,6 @@ export default class Create extends Command {
|
|
|
11
11
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
12
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
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
14
|
};
|
|
16
15
|
run(): Promise<void>;
|
|
17
16
|
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const base_1 = require("../../base");
|
|
4
4
|
const management_1 = require("../../proxies/management");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
|
|
5
|
+
const utils_1 = require("../../proxies/utils");
|
|
6
|
+
const utils_2 = require("../../utils");
|
|
7
|
+
class Create extends base_1.BaseCommand {
|
|
7
8
|
async run() {
|
|
8
9
|
var _a, _b;
|
|
9
|
-
const { flags, metadata } = await this.parse(Create);
|
|
10
|
-
const name = await (0,
|
|
10
|
+
const { flags, metadata, bt } = await this.parse(Create);
|
|
11
|
+
const name = await (0, utils_2.promptStringIfUndefined)(flags.name, {
|
|
11
12
|
message: 'What is the Proxy name?',
|
|
12
13
|
validate: (value) => Boolean(value),
|
|
13
14
|
});
|
|
14
|
-
const destinationUrl = (await (0,
|
|
15
|
+
const destinationUrl = (await (0, utils_2.promptUrlIfUndefined)(flags['destination-url'], {
|
|
15
16
|
message: 'What is the Proxy destination URL?',
|
|
16
17
|
})).toString();
|
|
17
|
-
const requestTransformCode = await (0,
|
|
18
|
+
const requestTransformCode = await (0, utils_2.promptStringIfUndefined)(flags['request-transform-code'], {
|
|
18
19
|
message: '(Optional) Enter the Request Transform code file path:',
|
|
19
20
|
});
|
|
20
|
-
const responseTransformCode = await (0,
|
|
21
|
+
const responseTransformCode = await (0, utils_2.promptStringIfUndefined)(flags['response-transform-code'], {
|
|
21
22
|
message: '(Optional) Enter the Response Transform code file path:',
|
|
22
23
|
});
|
|
23
|
-
const applicationId = await (0,
|
|
24
|
+
const applicationId = await (0, utils_2.promptStringIfUndefined)(flags['application-id'], {
|
|
24
25
|
message: '(Optional) Enter the Application ID to use in the Proxy:',
|
|
25
26
|
});
|
|
26
|
-
const configuration = await (0,
|
|
27
|
+
const configuration = await (0, utils_2.promptStringIfUndefined)(flags.configuration, {
|
|
27
28
|
message: '(Optional) Enter the configuration file path (.env format):',
|
|
28
29
|
});
|
|
29
|
-
const requireAuth = await (0,
|
|
30
|
+
const requireAuth = await (0, utils_2.promptBooleanIfUndefined)(((_b = (_a = metadata.flags) === null || _a === void 0 ? void 0 : _a['require-auth']) === null || _b === void 0 ? void 0 : _b.setFromDefault)
|
|
30
31
|
? undefined
|
|
31
32
|
: flags['require-auth'], {
|
|
32
33
|
message: 'Does the Proxy require Basis Theory authentication?',
|
|
33
34
|
default: true,
|
|
34
35
|
});
|
|
35
|
-
const
|
|
36
|
-
const { id, key } = await (0, management_1.createProxy)(bt, {
|
|
36
|
+
const model = (0, utils_1.createModelFromFlags)({
|
|
37
37
|
name,
|
|
38
38
|
destinationUrl,
|
|
39
39
|
requestTransformCode,
|
|
@@ -42,6 +42,7 @@ class Create extends core_1.Command {
|
|
|
42
42
|
configuration,
|
|
43
43
|
requireAuth,
|
|
44
44
|
});
|
|
45
|
+
const { id, key } = await (0, management_1.createProxy)(bt, model);
|
|
45
46
|
this.log('Proxy created successfully!');
|
|
46
47
|
this.log(`id: ${id}`);
|
|
47
48
|
this.log(`key: ${key}`);
|
|
@@ -51,35 +52,5 @@ exports.default = Create;
|
|
|
51
52
|
Create.description = 'Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission';
|
|
52
53
|
Create.examples = ['<%= config.bin %> <%= command.id %> '];
|
|
53
54
|
Create.flags = {
|
|
54
|
-
...utils_1.
|
|
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
|
-
}),
|
|
55
|
+
...utils_1.PROXY_FLAGS,
|
|
85
56
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class Proxies extends
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class Proxies extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
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
7
|
};
|
|
9
8
|
static args: {};
|
|
10
9
|
run(): Promise<void>;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const prompts_1 = require("@inquirer/prompts");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
+
const base_1 = require("../../base");
|
|
5
6
|
const logs_1 = require("../../logs");
|
|
6
7
|
const management_1 = require("../../proxies/management");
|
|
7
|
-
|
|
8
|
-
class Proxies extends core_1.Command {
|
|
8
|
+
class Proxies extends base_1.BaseCommand {
|
|
9
9
|
async run() {
|
|
10
|
-
const { flags: {
|
|
11
|
-
const bt = await (0, utils_1.createBt)(managementKey);
|
|
10
|
+
const { flags: { page }, bt, } = await this.parse(Proxies);
|
|
12
11
|
const proxy = await (0, management_1.selectProxy)(bt, page);
|
|
13
12
|
const action = await (0, prompts_1.select)({
|
|
14
13
|
message: 'Select action to perform',
|
|
@@ -42,7 +41,6 @@ exports.default = Proxies;
|
|
|
42
41
|
Proxies.description = 'List Proxies. Requires `proxy:read` Management Application permission';
|
|
43
42
|
Proxies.examples = ['<%= config.bin %> <%= command.id %>'];
|
|
44
43
|
Proxies.flags = {
|
|
45
|
-
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
46
44
|
page: core_1.Flags.integer({
|
|
47
45
|
char: 'p',
|
|
48
46
|
description: 'proxies list page to fetch',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class Logs extends
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class Logs extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
@@ -7,7 +7,6 @@ export default class Logs extends Command {
|
|
|
7
7
|
};
|
|
8
8
|
static flags: {
|
|
9
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
10
|
};
|
|
12
11
|
run(): Promise<void>;
|
|
13
12
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
4
5
|
const logs_1 = require("../../logs");
|
|
5
6
|
const management_1 = require("../../proxies/management");
|
|
6
|
-
|
|
7
|
-
class Logs extends core_1.Command {
|
|
7
|
+
class Logs extends base_1.BaseCommand {
|
|
8
8
|
async run() {
|
|
9
|
-
const { flags: { port
|
|
10
|
-
const bt = await (0, utils_1.createBt)(managementKey);
|
|
9
|
+
const { bt, flags: { port }, args: { id }, } = await this.parse(Logs);
|
|
11
10
|
if (id) {
|
|
12
11
|
return (0, logs_1.showProxyLogs)(bt, id, port);
|
|
13
12
|
}
|
|
@@ -28,10 +27,9 @@ Logs.args = {
|
|
|
28
27
|
}),
|
|
29
28
|
};
|
|
30
29
|
Logs.flags = {
|
|
31
|
-
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
32
30
|
port: core_1.Flags.integer({
|
|
33
31
|
char: 'p',
|
|
34
32
|
description: 'port to listen for incoming logs',
|
|
35
|
-
default:
|
|
33
|
+
default: logs_1.DEFAULT_LOGS_SERVER_PORT,
|
|
36
34
|
}),
|
|
37
35
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BaseCommand } from '../../base';
|
|
3
|
+
export default class Update extends BaseCommand {
|
|
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
|
+
};
|
|
15
|
+
static args: {
|
|
16
|
+
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const management_1 = require("../../proxies/management");
|
|
6
|
+
const utils_1 = require("../../proxies/utils");
|
|
7
|
+
class Update extends base_1.BaseCommand {
|
|
8
|
+
async run() {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const { bt, args: { id }, flags: { name, 'destination-url': destinationUrl, 'response-transform-code': responseTransformCode, 'request-transform-code': requestTransformCode, 'application-id': applicationId, configuration, 'require-auth': requireAuth, }, metadata, } = await this.parse(Update);
|
|
11
|
+
const model = (0, utils_1.createModelFromFlags)({
|
|
12
|
+
name,
|
|
13
|
+
destinationUrl: destinationUrl === null || destinationUrl === void 0 ? void 0 : destinationUrl.toString(),
|
|
14
|
+
requestTransformCode,
|
|
15
|
+
responseTransformCode,
|
|
16
|
+
applicationId,
|
|
17
|
+
configuration,
|
|
18
|
+
requireAuth: ((_b = (_a = metadata.flags) === null || _a === void 0 ? void 0 : _a['require-auth']) === null || _b === void 0 ? void 0 : _b.setFromDefault)
|
|
19
|
+
? undefined
|
|
20
|
+
: requireAuth,
|
|
21
|
+
});
|
|
22
|
+
await (0, management_1.patchProxy)(bt, id, model);
|
|
23
|
+
this.log('Proxy updated successfully!');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = Update;
|
|
27
|
+
Update.description = 'Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission';
|
|
28
|
+
Update.examples = [
|
|
29
|
+
'<%= config.bin %> <%= command.id %> ',
|
|
30
|
+
'<%= config.bin %> <%= command.id %> --destination-url https://echo.basistheory.com',
|
|
31
|
+
'<%= config.bin %> <%= command.id %> --request-transform-code ./myRequestTransform.js',
|
|
32
|
+
'<%= config.bin %> <%= command.id %> --configuration ./.env.proxy',
|
|
33
|
+
];
|
|
34
|
+
Update.flags = {
|
|
35
|
+
...utils_1.PROXY_FLAGS,
|
|
36
|
+
};
|
|
37
|
+
Update.args = {
|
|
38
|
+
id: core_1.Args.string({
|
|
39
|
+
description: 'Proxy id to update',
|
|
40
|
+
required: true,
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class Reactors extends
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class Reactors extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
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
7
|
};
|
|
9
8
|
static args: {};
|
|
10
9
|
run(): Promise<void>;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const prompts_1 = require("@inquirer/prompts");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
+
const base_1 = require("../../base");
|
|
5
6
|
const logs_1 = require("../../logs");
|
|
6
7
|
const management_1 = require("../../reactors/management");
|
|
7
|
-
|
|
8
|
-
class Reactors extends core_1.Command {
|
|
8
|
+
class Reactors extends base_1.BaseCommand {
|
|
9
9
|
async run() {
|
|
10
|
-
const { flags: {
|
|
11
|
-
const bt = await (0, utils_1.createBt)(managementKey);
|
|
10
|
+
const { bt, flags: { page }, } = await this.parse(Reactors);
|
|
12
11
|
const reactor = await (0, management_1.selectReactor)(bt, page);
|
|
13
12
|
const action = await (0, prompts_1.select)({
|
|
14
13
|
message: 'Select action to perform',
|
|
@@ -42,7 +41,6 @@ exports.default = Reactors;
|
|
|
42
41
|
Reactors.description = 'List Reactors. Requires `reactor:read` Management Application permission';
|
|
43
42
|
Reactors.examples = ['<%= config.bin %> <%= command.id %>'];
|
|
44
43
|
Reactors.flags = {
|
|
45
|
-
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
46
44
|
page: core_1.Flags.integer({
|
|
47
45
|
char: 'p',
|
|
48
46
|
description: 'reactors list page to fetch',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class Logs extends
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class Logs extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
@@ -7,7 +7,6 @@ export default class Logs extends Command {
|
|
|
7
7
|
};
|
|
8
8
|
static flags: {
|
|
9
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
10
|
};
|
|
12
11
|
run(): Promise<void>;
|
|
13
12
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
4
5
|
const logs_1 = require("../../logs");
|
|
5
6
|
const management_1 = require("../../reactors/management");
|
|
6
|
-
|
|
7
|
-
class Logs extends core_1.Command {
|
|
7
|
+
class Logs extends base_1.BaseCommand {
|
|
8
8
|
async run() {
|
|
9
|
-
const { flags: { port
|
|
10
|
-
const bt = await (0, utils_1.createBt)(managementKey);
|
|
9
|
+
const { bt, flags: { port }, args: { id }, } = await this.parse(Logs);
|
|
11
10
|
if (id) {
|
|
12
11
|
return (0, logs_1.showReactorLogs)(bt, id, port);
|
|
13
12
|
}
|
|
@@ -28,10 +27,9 @@ Logs.args = {
|
|
|
28
27
|
}),
|
|
29
28
|
};
|
|
30
29
|
Logs.flags = {
|
|
31
|
-
...utils_1.FLAG_MANAGEMENT_KEY,
|
|
32
30
|
port: core_1.Flags.integer({
|
|
33
31
|
char: 'p',
|
|
34
32
|
description: 'port to listen for incoming logs',
|
|
35
|
-
default:
|
|
33
|
+
default: logs_1.DEFAULT_LOGS_SERVER_PORT,
|
|
36
34
|
}),
|
|
37
35
|
};
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.connectToReactor = exports.connectToProxy = void 0;
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const
|
|
5
|
+
const management_1 = require("../proxies/management");
|
|
6
|
+
const management_2 = require("../reactors/management");
|
|
7
|
+
const BT_LOGGING_CONFIGURATION = 'BT_LOGGING_CONFIGURATION';
|
|
6
8
|
const createConfiguration = (url) => ({
|
|
7
9
|
[BT_LOGGING_CONFIGURATION]: JSON.stringify({
|
|
8
10
|
destination: url,
|
|
@@ -11,7 +13,7 @@ const createConfiguration = (url) => ({
|
|
|
11
13
|
});
|
|
12
14
|
const connectToReactor = async (bt, id, url) => {
|
|
13
15
|
core_1.ux.action.start(`Connecting to Reactor (${id})`);
|
|
14
|
-
await
|
|
16
|
+
await (0, management_2.patchReactor)(bt, id, {
|
|
15
17
|
configuration: createConfiguration(url),
|
|
16
18
|
});
|
|
17
19
|
core_1.ux.action.stop('✅\t');
|
|
@@ -19,7 +21,7 @@ const connectToReactor = async (bt, id, url) => {
|
|
|
19
21
|
exports.connectToReactor = connectToReactor;
|
|
20
22
|
const connectToProxy = async (bt, id, url) => {
|
|
21
23
|
core_1.ux.action.start(`Connecting to Proxy (${id})`);
|
|
22
|
-
await
|
|
24
|
+
await (0, management_1.patchProxy)(bt, id, {
|
|
23
25
|
configuration: createConfiguration(url),
|
|
24
26
|
});
|
|
25
27
|
core_1.ux.action.stop('✅\t');
|
package/dist/logs/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
|
+
declare const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
2
3
|
declare const showProxyLogs: (bt: BasisTheory, id: string, port?: number) => Promise<void>;
|
|
3
4
|
declare const showReactorLogs: (bt: BasisTheory, id: string, port?: number) => Promise<void>;
|
|
4
|
-
export { showProxyLogs, showReactorLogs };
|
|
5
|
+
export { showProxyLogs, showReactorLogs, DEFAULT_LOGS_SERVER_PORT };
|
package/dist/logs/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.showReactorLogs = exports.showProxyLogs = void 0;
|
|
4
|
-
const
|
|
5
|
-
const management_1 = require("./management");
|
|
3
|
+
exports.DEFAULT_LOGS_SERVER_PORT = exports.showReactorLogs = exports.showProxyLogs = void 0;
|
|
4
|
+
const connect_1 = require("./connect");
|
|
6
5
|
const server_1 = require("./server");
|
|
7
|
-
const
|
|
6
|
+
const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
7
|
+
exports.DEFAULT_LOGS_SERVER_PORT = DEFAULT_LOGS_SERVER_PORT;
|
|
8
|
+
const showProxyLogs = async (bt, id, port = DEFAULT_LOGS_SERVER_PORT) => {
|
|
8
9
|
const url = await (0, server_1.createLogServer)(port);
|
|
9
|
-
await (0,
|
|
10
|
+
await (0, connect_1.connectToProxy)(bt, id, url);
|
|
10
11
|
};
|
|
11
12
|
exports.showProxyLogs = showProxyLogs;
|
|
12
|
-
const showReactorLogs = async (bt, id, port =
|
|
13
|
+
const showReactorLogs = async (bt, id, port = DEFAULT_LOGS_SERVER_PORT) => {
|
|
13
14
|
const url = await (0, server_1.createLogServer)(port);
|
|
14
|
-
await (0,
|
|
15
|
+
await (0, connect_1.connectToReactor)(bt, id, url);
|
|
15
16
|
};
|
|
16
17
|
exports.showReactorLogs = showReactorLogs;
|
|
@@ -6,5 +6,5 @@ interface LogEvent {
|
|
|
6
6
|
level: 'INFO' | 'WARN' | 'ERROR';
|
|
7
7
|
time: number;
|
|
8
8
|
}
|
|
9
|
-
declare const parseLogEvent: (logger: pino.Logger
|
|
9
|
+
declare const parseLogEvent: (logger: pino.Logger, event: LogEvent) => Promise<void>;
|
|
10
10
|
export { parseLogEvent };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseLogEvent = void 0;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const parseLogEvent = (logger) => async (event) => {
|
|
4
|
+
const debug = require('debug')('logs:parse');
|
|
5
|
+
const parseLogEvent = async (logger, event) => {
|
|
7
6
|
debug(event);
|
|
8
7
|
const { deserializeError } = await import('serialize-error');
|
|
9
8
|
const [arg1, arg2, ...args] = event.args.map((arg) => {
|
package/dist/logs/server.js
CHANGED
|
@@ -7,8 +7,7 @@ const fs = require("node:fs");
|
|
|
7
7
|
const node_http_1 = require("node:http");
|
|
8
8
|
const pino_1 = require("pino");
|
|
9
9
|
const socket_io_1 = require("socket.io");
|
|
10
|
-
const
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const parse_1 = require("./parse");
|
|
12
11
|
const debug = require('debug')('logs:server');
|
|
13
12
|
const runTunnel = async (port) => {
|
|
14
13
|
if (!fs.existsSync(cloudflared_1.bin)) {
|
|
@@ -40,7 +39,16 @@ const createLogServer = async (port) => {
|
|
|
40
39
|
const io = new socket_io_1.Server(server);
|
|
41
40
|
io.on('connection', (client) => {
|
|
42
41
|
debug(`socket client connected: ${client.handshake.address}`);
|
|
43
|
-
client.on('log', (
|
|
42
|
+
client.on('log', (data, callback) => {
|
|
43
|
+
debug('received "log" event');
|
|
44
|
+
if (typeof callback === 'function') {
|
|
45
|
+
debug('ack expected');
|
|
46
|
+
// eslint-disable-next-line node/callback-return,node/no-callback-literal
|
|
47
|
+
callback('ack');
|
|
48
|
+
debug('ack sent');
|
|
49
|
+
}
|
|
50
|
+
(0, parse_1.parseLogEvent)(logger, data);
|
|
51
|
+
});
|
|
44
52
|
client.on('disconnect', (reason) => {
|
|
45
53
|
debug(`socket client disconnected ${client.handshake.address}: ${reason}`);
|
|
46
54
|
});
|
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import type { CreateProxy, Proxy } from '@basis-theory/basis-theory-js/types/models';
|
|
1
|
+
import type { CreateProxy, PatchProxy, 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
|
-
|
|
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 };
|
|
4
|
+
declare const createProxy: (bt: IBasisTheory, model: CreateProxy) => Promise<Proxy>;
|
|
5
|
+
declare const patchProxy: (bt: IBasisTheory, id: string, model: PatchProxy) => Promise<void>;
|
|
6
|
+
export { selectProxy, createProxy, patchProxy };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProxy = exports.selectProxy = void 0;
|
|
3
|
+
exports.patchProxy = exports.createProxy = exports.selectProxy = void 0;
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const dotenv_1 = require("dotenv");
|
|
6
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const debug = require('debug')('proxies:management');
|
|
7
7
|
const listProxies = async (bt, page) => {
|
|
8
8
|
const size = 5;
|
|
9
|
+
debug('Listing proxies', `page: ${page}`, `size: ${size}`);
|
|
9
10
|
const proxies = await bt.proxies.list({
|
|
10
11
|
size,
|
|
11
12
|
page,
|
|
@@ -59,27 +60,13 @@ const selectProxy = async (bt, page) => {
|
|
|
59
60
|
return selection;
|
|
60
61
|
};
|
|
61
62
|
exports.selectProxy = selectProxy;
|
|
62
|
-
const createProxy = (bt,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
});
|
|
63
|
+
const createProxy = (bt, model) => {
|
|
64
|
+
debug(`Creating Proxy`, JSON.stringify(model, undefined, 2));
|
|
65
|
+
return bt.proxies.create(model);
|
|
66
|
+
};
|
|
85
67
|
exports.createProxy = createProxy;
|
|
68
|
+
const patchProxy = (bt, id, model) => {
|
|
69
|
+
debug(`Patching Proxy ${id}`, JSON.stringify(model, undefined, 2));
|
|
70
|
+
return bt.proxies.patch(id, model);
|
|
71
|
+
};
|
|
72
|
+
exports.patchProxy = patchProxy;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CreateProxy as CreateProxyModel, PatchProxy as PatchProxyModel } from '@basis-theory/basis-theory-js/types/models/proxies';
|
|
3
|
+
declare const PROXY_FLAGS: {
|
|
4
|
+
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
5
|
+
'destination-url': import("@oclif/core/lib/interfaces/parser").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
|
+
'request-transform-code': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
'response-transform-code': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
'require-auth': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
interface ProxyFlagProps {
|
|
13
|
+
/**
|
|
14
|
+
* Proxy's application id
|
|
15
|
+
*/
|
|
16
|
+
applicationId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Path to code file
|
|
19
|
+
*/
|
|
20
|
+
requestTransformCode?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Path to code file
|
|
23
|
+
*/
|
|
24
|
+
responseTransformCode?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Path to .env file
|
|
27
|
+
*/
|
|
28
|
+
configuration?: string;
|
|
29
|
+
}
|
|
30
|
+
interface CreateProxy extends Omit<CreateProxyModel, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'>, ProxyFlagProps {
|
|
31
|
+
}
|
|
32
|
+
interface PatchProxy extends Omit<PatchProxyModel, 'application' | 'configuration' | 'requestTransform' | 'responseTransform'>, ProxyFlagProps {
|
|
33
|
+
}
|
|
34
|
+
declare function createModelFromFlags(payload: CreateProxy): CreateProxyModel;
|
|
35
|
+
declare function createModelFromFlags(payload: PatchProxy): PatchProxyModel;
|
|
36
|
+
export { PROXY_FLAGS, createModelFromFlags };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createModelFromFlags = exports.PROXY_FLAGS = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const dotenv_1 = require("dotenv");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const PROXY_FLAGS = {
|
|
8
|
+
name: core_1.Flags.string({
|
|
9
|
+
char: 'n',
|
|
10
|
+
description: 'name of the Proxy',
|
|
11
|
+
}),
|
|
12
|
+
'destination-url': core_1.Flags.url({
|
|
13
|
+
char: 'u',
|
|
14
|
+
description: 'URL to which requests will be proxied',
|
|
15
|
+
}),
|
|
16
|
+
'request-transform-code': core_1.Flags.file({
|
|
17
|
+
char: 'q',
|
|
18
|
+
description: 'path to JavaScript file containing a Request Transform code',
|
|
19
|
+
}),
|
|
20
|
+
'response-transform-code': core_1.Flags.file({
|
|
21
|
+
char: 's',
|
|
22
|
+
description: 'path to JavaScript file containing a Response Transform code',
|
|
23
|
+
}),
|
|
24
|
+
'application-id': core_1.Flags.string({
|
|
25
|
+
char: 'i',
|
|
26
|
+
description: 'application ID to use in the Proxy',
|
|
27
|
+
}),
|
|
28
|
+
configuration: core_1.Flags.file({
|
|
29
|
+
char: 'c',
|
|
30
|
+
description: 'path to configuration file (.env format) to use in the Proxy',
|
|
31
|
+
}),
|
|
32
|
+
'require-auth': core_1.Flags.boolean({
|
|
33
|
+
char: 'a',
|
|
34
|
+
description: 'whether the Proxy requires Basis Theory authentication to be invoked. Default: true',
|
|
35
|
+
allowNo: true,
|
|
36
|
+
default: true,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
exports.PROXY_FLAGS = PROXY_FLAGS;
|
|
40
|
+
// eslint-disable-next-line get-off-my-lawn/prefer-arrow-functions
|
|
41
|
+
function createModelFromFlags({ name, destinationUrl, requestTransformCode, responseTransformCode, applicationId, configuration, requireAuth, }) {
|
|
42
|
+
return {
|
|
43
|
+
name,
|
|
44
|
+
destinationUrl,
|
|
45
|
+
requestTransform: requestTransformCode
|
|
46
|
+
? { code: (0, utils_1.readFileContents)(requestTransformCode) }
|
|
47
|
+
: undefined,
|
|
48
|
+
responseTransform: responseTransformCode
|
|
49
|
+
? { code: (0, utils_1.readFileContents)(responseTransformCode) }
|
|
50
|
+
: undefined,
|
|
51
|
+
application: applicationId ? { id: applicationId } : undefined,
|
|
52
|
+
configuration: configuration
|
|
53
|
+
? (0, dotenv_1.parse)((0, utils_1.readFileContents)(configuration))
|
|
54
|
+
: undefined,
|
|
55
|
+
requireAuth,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.createModelFromFlags = createModelFromFlags;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Reactor } from '@basis-theory/basis-theory-js/types/models';
|
|
1
|
+
import type { Reactor, PatchReactor } 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 selectReactor: (bt: IBasisTheory, page: number) => Promise<Reactor>;
|
|
4
|
-
|
|
4
|
+
declare const patchReactor: (bt: IBasisTheory, id: string, model: PatchReactor) => Promise<void>;
|
|
5
|
+
export { selectReactor, patchReactor };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectReactor = void 0;
|
|
3
|
+
exports.patchReactor = exports.selectReactor = void 0;
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const debug = require('debug')('reactors:management');
|
|
6
7
|
const listReactors = async (bt, page) => {
|
|
7
8
|
const size = 5;
|
|
9
|
+
debug('Listing reactors', `page: ${page}`, `size: ${size}`);
|
|
8
10
|
const reactors = await bt.reactors.list({
|
|
9
11
|
size,
|
|
10
12
|
page,
|
|
@@ -36,3 +38,8 @@ const selectReactor = async (bt, page) => {
|
|
|
36
38
|
return selection;
|
|
37
39
|
};
|
|
38
40
|
exports.selectReactor = selectReactor;
|
|
41
|
+
const patchReactor = (bt, id, model) => {
|
|
42
|
+
debug(`Patching Reactor ${id}`, JSON.stringify(model, undefined, 2));
|
|
43
|
+
return bt.reactors.patch(id, model);
|
|
44
|
+
};
|
|
45
|
+
exports.patchReactor = patchReactor;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
|
|
2
1
|
import { PaginatedList } from '@basis-theory/basis-theory-js/types/sdk';
|
|
3
2
|
import confirm from '@inquirer/confirm';
|
|
4
3
|
import input from '@inquirer/input';
|
|
5
|
-
declare const createBt: (managementKey: string) => Promise<IBasisTheory>;
|
|
6
|
-
declare const FLAG_MANAGEMENT_KEY: {
|
|
7
|
-
'management-key': import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
-
};
|
|
9
|
-
declare const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
10
4
|
declare const selectOrNavigate: <T>(list: PaginatedList<T>, prop: string) => Promise<T | "previous" | "next">;
|
|
11
5
|
declare const promptStringIfUndefined: (value: string | undefined, options: Parameters<typeof input>[0]) => Promise<string>;
|
|
12
6
|
declare const promptUrlIfUndefined: (value: URL | undefined, options: Parameters<typeof input>[0]) => Promise<URL>;
|
|
13
7
|
declare const promptBooleanIfUndefined: (value: boolean | undefined, options: Parameters<typeof confirm>[0]) => Promise<boolean>;
|
|
14
8
|
declare const readFileContents: (filePath: string) => string;
|
|
15
|
-
export {
|
|
9
|
+
export { selectOrNavigate, promptStringIfUndefined, promptUrlIfUndefined, promptBooleanIfUndefined, readFileContents, };
|
package/dist/utils.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readFileContents = exports.promptBooleanIfUndefined = exports.promptUrlIfUndefined = exports.promptStringIfUndefined = exports.selectOrNavigate =
|
|
4
|
-
const basis_theory_js_1 = require("@basis-theory/basis-theory-js");
|
|
3
|
+
exports.readFileContents = exports.promptBooleanIfUndefined = exports.promptUrlIfUndefined = exports.promptStringIfUndefined = exports.selectOrNavigate = void 0;
|
|
5
4
|
const confirm_1 = require("@inquirer/confirm");
|
|
6
5
|
const input_1 = require("@inquirer/input");
|
|
7
6
|
const core_1 = require("@oclif/core");
|
|
8
7
|
const fs = require("fs");
|
|
9
8
|
const path = require("path");
|
|
10
|
-
const createBt = (managementKey) => new basis_theory_js_1.BasisTheory().init(managementKey);
|
|
11
|
-
exports.createBt = createBt;
|
|
12
|
-
const FLAG_MANAGEMENT_KEY = {
|
|
13
|
-
'management-key': core_1.Flags.string({
|
|
14
|
-
char: 'x',
|
|
15
|
-
env: 'BT_MANAGEMENT_KEY',
|
|
16
|
-
description: 'management key used for connecting with the reactor / proxy',
|
|
17
|
-
required: true,
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
exports.FLAG_MANAGEMENT_KEY = FLAG_MANAGEMENT_KEY;
|
|
21
|
-
const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
22
|
-
exports.DEFAULT_LOGS_SERVER_PORT = DEFAULT_LOGS_SERVER_PORT;
|
|
23
9
|
const selectOrNavigate = async (list, prop) => {
|
|
24
10
|
const { data, pagination } = list;
|
|
25
11
|
let prompt = `Select one (${prop})`;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.3.1",
|
|
3
3
|
"commands": {
|
|
4
4
|
"proxies:create": {
|
|
5
5
|
"id": "proxies:create",
|
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
"required": true,
|
|
22
22
|
"multiple": false
|
|
23
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
|
+
},
|
|
24
31
|
"name": {
|
|
25
32
|
"name": "name",
|
|
26
33
|
"type": "option",
|
|
@@ -93,6 +100,13 @@
|
|
|
93
100
|
"required": true,
|
|
94
101
|
"multiple": false
|
|
95
102
|
},
|
|
103
|
+
"api-base-url": {
|
|
104
|
+
"name": "api-base-url",
|
|
105
|
+
"type": "option",
|
|
106
|
+
"description": "base API URL to use in Basis Theory SDK",
|
|
107
|
+
"hidden": true,
|
|
108
|
+
"multiple": false
|
|
109
|
+
},
|
|
96
110
|
"page": {
|
|
97
111
|
"name": "page",
|
|
98
112
|
"type": "option",
|
|
@@ -126,6 +140,13 @@
|
|
|
126
140
|
"required": true,
|
|
127
141
|
"multiple": false
|
|
128
142
|
},
|
|
143
|
+
"api-base-url": {
|
|
144
|
+
"name": "api-base-url",
|
|
145
|
+
"type": "option",
|
|
146
|
+
"description": "base API URL to use in Basis Theory SDK",
|
|
147
|
+
"hidden": true,
|
|
148
|
+
"multiple": false
|
|
149
|
+
},
|
|
129
150
|
"port": {
|
|
130
151
|
"name": "port",
|
|
131
152
|
"type": "option",
|
|
@@ -142,6 +163,94 @@
|
|
|
142
163
|
}
|
|
143
164
|
}
|
|
144
165
|
},
|
|
166
|
+
"proxies:update": {
|
|
167
|
+
"id": "proxies:update",
|
|
168
|
+
"description": "Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission",
|
|
169
|
+
"strict": true,
|
|
170
|
+
"pluginName": "@basis-theory-labs/cli",
|
|
171
|
+
"pluginAlias": "@basis-theory-labs/cli",
|
|
172
|
+
"pluginType": "core",
|
|
173
|
+
"aliases": [],
|
|
174
|
+
"examples": [
|
|
175
|
+
"<%= config.bin %> <%= command.id %> ",
|
|
176
|
+
"<%= config.bin %> <%= command.id %> --destination-url https://echo.basistheory.com",
|
|
177
|
+
"<%= config.bin %> <%= command.id %> --request-transform-code ./myRequestTransform.js",
|
|
178
|
+
"<%= config.bin %> <%= command.id %> --configuration ./.env.proxy"
|
|
179
|
+
],
|
|
180
|
+
"flags": {
|
|
181
|
+
"management-key": {
|
|
182
|
+
"name": "management-key",
|
|
183
|
+
"type": "option",
|
|
184
|
+
"char": "x",
|
|
185
|
+
"description": "management key used for connecting with the reactor / proxy",
|
|
186
|
+
"required": true,
|
|
187
|
+
"multiple": false
|
|
188
|
+
},
|
|
189
|
+
"api-base-url": {
|
|
190
|
+
"name": "api-base-url",
|
|
191
|
+
"type": "option",
|
|
192
|
+
"description": "base API URL to use in Basis Theory SDK",
|
|
193
|
+
"hidden": true,
|
|
194
|
+
"multiple": false
|
|
195
|
+
},
|
|
196
|
+
"name": {
|
|
197
|
+
"name": "name",
|
|
198
|
+
"type": "option",
|
|
199
|
+
"char": "n",
|
|
200
|
+
"description": "name of the Proxy",
|
|
201
|
+
"multiple": false
|
|
202
|
+
},
|
|
203
|
+
"destination-url": {
|
|
204
|
+
"name": "destination-url",
|
|
205
|
+
"type": "option",
|
|
206
|
+
"char": "u",
|
|
207
|
+
"description": "URL to which requests will be proxied",
|
|
208
|
+
"multiple": false
|
|
209
|
+
},
|
|
210
|
+
"request-transform-code": {
|
|
211
|
+
"name": "request-transform-code",
|
|
212
|
+
"type": "option",
|
|
213
|
+
"char": "q",
|
|
214
|
+
"description": "path to JavaScript file containing a Request Transform code",
|
|
215
|
+
"multiple": false
|
|
216
|
+
},
|
|
217
|
+
"response-transform-code": {
|
|
218
|
+
"name": "response-transform-code",
|
|
219
|
+
"type": "option",
|
|
220
|
+
"char": "s",
|
|
221
|
+
"description": "path to JavaScript file containing a Response Transform code",
|
|
222
|
+
"multiple": false
|
|
223
|
+
},
|
|
224
|
+
"application-id": {
|
|
225
|
+
"name": "application-id",
|
|
226
|
+
"type": "option",
|
|
227
|
+
"char": "i",
|
|
228
|
+
"description": "application ID to use in the Proxy",
|
|
229
|
+
"multiple": false
|
|
230
|
+
},
|
|
231
|
+
"configuration": {
|
|
232
|
+
"name": "configuration",
|
|
233
|
+
"type": "option",
|
|
234
|
+
"char": "c",
|
|
235
|
+
"description": "path to configuration file (.env format) to use in the Proxy",
|
|
236
|
+
"multiple": false
|
|
237
|
+
},
|
|
238
|
+
"require-auth": {
|
|
239
|
+
"name": "require-auth",
|
|
240
|
+
"type": "boolean",
|
|
241
|
+
"char": "a",
|
|
242
|
+
"description": "whether the Proxy requires Basis Theory authentication to be invoked. Default: true",
|
|
243
|
+
"allowNo": true
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"args": {
|
|
247
|
+
"id": {
|
|
248
|
+
"name": "id",
|
|
249
|
+
"description": "Proxy id to update",
|
|
250
|
+
"required": true
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
145
254
|
"reactors": {
|
|
146
255
|
"id": "reactors",
|
|
147
256
|
"description": "List Reactors. Requires `reactor:read` Management Application permission",
|
|
@@ -162,6 +271,13 @@
|
|
|
162
271
|
"required": true,
|
|
163
272
|
"multiple": false
|
|
164
273
|
},
|
|
274
|
+
"api-base-url": {
|
|
275
|
+
"name": "api-base-url",
|
|
276
|
+
"type": "option",
|
|
277
|
+
"description": "base API URL to use in Basis Theory SDK",
|
|
278
|
+
"hidden": true,
|
|
279
|
+
"multiple": false
|
|
280
|
+
},
|
|
165
281
|
"page": {
|
|
166
282
|
"name": "page",
|
|
167
283
|
"type": "option",
|
|
@@ -195,6 +311,13 @@
|
|
|
195
311
|
"required": true,
|
|
196
312
|
"multiple": false
|
|
197
313
|
},
|
|
314
|
+
"api-base-url": {
|
|
315
|
+
"name": "api-base-url",
|
|
316
|
+
"type": "option",
|
|
317
|
+
"description": "base API URL to use in Basis Theory SDK",
|
|
318
|
+
"hidden": true,
|
|
319
|
+
"multiple": false
|
|
320
|
+
},
|
|
198
321
|
"port": {
|
|
199
322
|
"name": "port",
|
|
200
323
|
"type": "option",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory-labs/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Basis Theory CLI tool",
|
|
5
5
|
"author": "Davi Aquino @djejaquino",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"pino": "^8.14.1",
|
|
32
32
|
"pino-pretty": "^10.0.0",
|
|
33
33
|
"serialize-error": "^11.0.0",
|
|
34
|
-
"socket.io": "^4.
|
|
34
|
+
"socket.io": "^4.7.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@basis-theory/eslint-config": "^1.2.0",
|
|
File without changes
|