@basis-theory-labs/cli 1.13.0 → 2.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 +166 -87
- package/dist/applications/management.d.ts +8 -10
- package/dist/applications/management.js +14 -10
- package/dist/base.d.ts +2 -2
- package/dist/base.js +27 -14
- package/dist/commands/applications/create.js +6 -3
- package/dist/commands/applications/index.js +3 -1
- package/dist/commands/proxies/create.d.ts +17 -1
- package/dist/commands/proxies/create.js +84 -8
- package/dist/commands/proxies/index.js +3 -2
- package/dist/commands/proxies/logs.js +2 -1
- package/dist/commands/proxies/update.d.ts +17 -1
- package/dist/commands/proxies/update.js +66 -6
- package/dist/commands/reactors/create.d.ts +11 -1
- package/dist/commands/reactors/create.js +70 -8
- package/dist/commands/reactors/index.js +3 -2
- package/dist/commands/reactors/logs.js +2 -1
- package/dist/commands/reactors/update.d.ts +11 -1
- package/dist/commands/reactors/update.js +45 -5
- package/dist/logs/connect.d.ts +5 -5
- package/dist/logs/connect.js +1 -2
- package/dist/logs/index.d.ts +3 -3
- package/dist/logs/server.js +1 -2
- package/dist/proxies/management.d.ts +7 -7
- package/dist/proxies/management.js +16 -9
- package/dist/proxies/runtime.d.ts +5 -0
- package/dist/proxies/runtime.js +66 -0
- package/dist/proxies/utils.d.ts +26 -5
- package/dist/proxies/utils.js +78 -7
- package/dist/reactors/management.d.ts +7 -7
- package/dist/reactors/management.js +16 -9
- package/dist/reactors/runtime.d.ts +3 -0
- package/dist/reactors/runtime.js +27 -0
- package/dist/reactors/utils.d.ts +16 -5
- package/dist/reactors/utils.js +4 -1
- package/dist/runtime/flags.d.ts +10 -0
- package/dist/runtime/flags.js +37 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +20 -0
- package/dist/runtime/state.d.ts +6 -0
- package/dist/runtime/state.js +86 -0
- package/dist/runtime/utils.d.ts +34 -0
- package/dist/runtime/utils.js +132 -0
- package/dist/utils.d.ts +12 -2
- package/dist/utils.js +44 -4
- package/oclif.manifest.json +333 -122
- package/package.json +4 -3
- package/dist/commands/reactorFormulas/index.d.ts +0 -10
- package/dist/commands/reactorFormulas/index.js +0 -27
- package/dist/commands/reactorFormulas/update.d.ts +0 -18
- package/dist/commands/reactorFormulas/update.js +0 -71
- package/dist/reactorFormulas/management.d.ts +0 -5
- package/dist/reactorFormulas/management.js +0 -54
- package/dist/reactorFormulas/utils.d.ts +0 -26
- package/dist/reactorFormulas/utils.js +0 -49
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const base_1 = require("../../base");
|
|
4
4
|
const management_1 = require("../../proxies/management");
|
|
5
|
+
const runtime_1 = require("../../proxies/runtime");
|
|
5
6
|
const utils_1 = require("../../proxies/utils");
|
|
7
|
+
const runtime_2 = require("../../runtime");
|
|
6
8
|
const utils_2 = require("../../utils");
|
|
7
9
|
class Create extends base_1.BaseCommand {
|
|
8
10
|
async run() {
|
|
9
11
|
var _a, _b;
|
|
10
12
|
const { flags, metadata, bt } = await this.parse(Create);
|
|
13
|
+
(0, runtime_1.validateTransformRuntimeFlags)('request-transform', flags, flags['request-transform-image']);
|
|
14
|
+
(0, runtime_1.validateTransformRuntimeFlags)('response-transform', flags, flags['response-transform-image']);
|
|
11
15
|
const name = await (0, utils_2.promptStringIfUndefined)(flags.name, {
|
|
12
16
|
message: 'What is the Proxy name?',
|
|
13
17
|
validate: (value) => Boolean(value),
|
|
@@ -18,12 +22,22 @@ class Create extends base_1.BaseCommand {
|
|
|
18
22
|
const requestTransformCode = await (0, utils_2.promptStringIfUndefined)(flags['request-transform-code'], {
|
|
19
23
|
message: '(Optional) Enter the Request Transform code file path:',
|
|
20
24
|
});
|
|
25
|
+
const requestTransformImage = requestTransformCode
|
|
26
|
+
? await (0, runtime_2.promptRuntimeImage)(flags['request-transform-image'], 'Which runtime do you want for the request transform?')
|
|
27
|
+
: flags['request-transform-image'];
|
|
21
28
|
const responseTransformCode = await (0, utils_2.promptStringIfUndefined)(flags['response-transform-code'], {
|
|
22
29
|
message: '(Optional) Enter the Response Transform code file path:',
|
|
23
30
|
});
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
const responseTransformImage = responseTransformCode
|
|
32
|
+
? await (0, runtime_2.promptRuntimeImage)(flags['response-transform-image'], 'Which runtime do you want for the response transform?')
|
|
33
|
+
: flags['response-transform-image'];
|
|
34
|
+
const hasLegacyTransform = (0, runtime_2.isLegacyRuntimeImage)(requestTransformImage) ||
|
|
35
|
+
(0, runtime_2.isLegacyRuntimeImage)(responseTransformImage);
|
|
36
|
+
const applicationId = hasLegacyTransform
|
|
37
|
+
? await (0, utils_2.promptStringIfUndefined)(flags['application-id'], {
|
|
38
|
+
message: '(Optional) Enter the Application ID to use in the Proxy:',
|
|
39
|
+
})
|
|
40
|
+
: flags['application-id'];
|
|
27
41
|
const configuration = await (0, utils_2.promptStringIfUndefined)(flags.configuration, {
|
|
28
42
|
message: '(Optional) Enter the configuration file path (.env format):',
|
|
29
43
|
});
|
|
@@ -33,6 +47,14 @@ class Create extends base_1.BaseCommand {
|
|
|
33
47
|
message: 'Does the Proxy require Basis Theory authentication?',
|
|
34
48
|
default: true,
|
|
35
49
|
});
|
|
50
|
+
const updatedFlags = {
|
|
51
|
+
...flags,
|
|
52
|
+
'request-transform-image': requestTransformImage,
|
|
53
|
+
'response-transform-image': responseTransformImage,
|
|
54
|
+
};
|
|
55
|
+
(0, runtime_1.validateProxyApplicationId)(applicationId, updatedFlags);
|
|
56
|
+
const requestTransformRuntime = await (0, runtime_1.promptTransformRuntime)('request', flags, requestTransformCode, requestTransformImage);
|
|
57
|
+
const responseTransformRuntime = await (0, runtime_1.promptTransformRuntime)('response', flags, responseTransformCode, responseTransformImage);
|
|
36
58
|
const model = (0, utils_1.createModelFromFlags)({
|
|
37
59
|
name,
|
|
38
60
|
destinationUrl,
|
|
@@ -41,16 +63,70 @@ class Create extends base_1.BaseCommand {
|
|
|
41
63
|
applicationId,
|
|
42
64
|
configuration,
|
|
43
65
|
requireAuth,
|
|
66
|
+
requestTransformRuntime,
|
|
67
|
+
responseTransformRuntime,
|
|
44
68
|
});
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
69
|
+
const proxy = await (0, management_1.createProxy)(bt, model);
|
|
70
|
+
if (!flags.async && proxy.id) {
|
|
71
|
+
try {
|
|
72
|
+
await (0, runtime_2.waitForResourceState)(bt, 'proxy', proxy.id, proxy.state);
|
|
73
|
+
this.log('Proxy created successfully!');
|
|
74
|
+
this.log(`id: ${proxy.id}`);
|
|
75
|
+
this.log(`key: ${proxy.key}`);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.log('Proxy created but failed to become ready.');
|
|
79
|
+
this.log(`id: ${proxy.id}`);
|
|
80
|
+
this.log(`key: ${proxy.key}`);
|
|
81
|
+
this.log(`You can retry by running: bt proxies update ${proxy.id} [OPTIONS]`);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.log('Proxy created successfully!');
|
|
87
|
+
this.log(`id: ${proxy.id}`);
|
|
88
|
+
this.log(`key: ${proxy.key}`);
|
|
89
|
+
}
|
|
49
90
|
}
|
|
50
91
|
}
|
|
51
92
|
exports.default = Create;
|
|
52
93
|
Create.description = 'Creates a new Pre-Configured Proxy. Requires `proxy:create` Management Application permission';
|
|
53
|
-
Create.examples = [
|
|
94
|
+
Create.examples = [
|
|
95
|
+
{
|
|
96
|
+
description: 'Create a proxy without transforms',
|
|
97
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Proxy" --destination-url https://api.example.com',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
description: 'Create a proxy with legacy runtime transforms',
|
|
101
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Proxy" --destination-url https://api.example.com --request-transform-code ./request.js --request-transform-image node-bt --application-id <application-id>',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
description: 'Create a proxy with node22 transforms',
|
|
105
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Proxy" --destination-url https://api.example.com --request-transform-code ./request.js --request-transform-image node22 --response-transform-code ./response.js --response-transform-image node22',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
description: 'Create a proxy with node22 transforms and all runtime options',
|
|
109
|
+
command: '<%= config.bin %> <%= command.id %> ' +
|
|
110
|
+
'--name "My Proxy" ' +
|
|
111
|
+
'--destination-url https://api.example.com ' +
|
|
112
|
+
'--configuration ./config.env ' +
|
|
113
|
+
'--require-auth ' +
|
|
114
|
+
'--request-transform-code ./request.js ' +
|
|
115
|
+
'--request-transform-image node22 ' +
|
|
116
|
+
'--request-transform-timeout 10 ' +
|
|
117
|
+
'--request-transform-warm-concurrency 0 ' +
|
|
118
|
+
'--request-transform-resources standard ' +
|
|
119
|
+
'--request-transform-dependencies ./deps.json ' +
|
|
120
|
+
'--request-transform-permissions token:read ' +
|
|
121
|
+
'--response-transform-code ./response.js ' +
|
|
122
|
+
'--response-transform-image node22 ' +
|
|
123
|
+
'--response-transform-timeout 10 ' +
|
|
124
|
+
'--response-transform-warm-concurrency 0 ' +
|
|
125
|
+
'--response-transform-resources standard ' +
|
|
126
|
+
'--response-transform-dependencies ./deps.json ' +
|
|
127
|
+
'--response-transform-permissions token:read',
|
|
128
|
+
},
|
|
129
|
+
];
|
|
54
130
|
Create.flags = {
|
|
55
131
|
...utils_1.PROXY_FLAGS,
|
|
56
132
|
};
|
|
@@ -8,6 +8,7 @@ const logs_1 = require("../../logs");
|
|
|
8
8
|
const management_1 = require("../../proxies/management");
|
|
9
9
|
class Proxies extends base_1.BaseCommand {
|
|
10
10
|
async run() {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
const { flags: { page }, bt, } = await this.parse(Proxies);
|
|
12
13
|
const proxy = await (0, management_1.selectProxy)(bt, page);
|
|
13
14
|
if (!proxy) {
|
|
@@ -36,9 +37,9 @@ class Proxies extends base_1.BaseCommand {
|
|
|
36
37
|
return undefined;
|
|
37
38
|
}
|
|
38
39
|
if (action === 'logs') {
|
|
39
|
-
return (0, logs_1.showProxyLogs)(bt, proxy.id);
|
|
40
|
+
return (0, logs_1.showProxyLogs)(bt, (_a = proxy.id) !== null && _a !== void 0 ? _a : '');
|
|
40
41
|
}
|
|
41
|
-
if (action === 'delete' && (await (0, management_1.deleteProxy)(bt, proxy.id))) {
|
|
42
|
+
if (action === 'delete' && (await (0, management_1.deleteProxy)(bt, (_b = proxy.id) !== null && _b !== void 0 ? _b : ''))) {
|
|
42
43
|
return this.log('Proxy deleted successfully!');
|
|
43
44
|
}
|
|
44
45
|
return undefined;
|
|
@@ -6,6 +6,7 @@ const logs_1 = require("../../logs");
|
|
|
6
6
|
const management_1 = require("../../proxies/management");
|
|
7
7
|
class Logs extends base_1.BaseCommand {
|
|
8
8
|
async run() {
|
|
9
|
+
var _a;
|
|
9
10
|
const { bt, flags: { port }, args: { id }, } = await this.parse(Logs);
|
|
10
11
|
if (id) {
|
|
11
12
|
return (0, logs_1.showProxyLogs)(bt, id, port);
|
|
@@ -14,7 +15,7 @@ class Logs extends base_1.BaseCommand {
|
|
|
14
15
|
if (!proxy) {
|
|
15
16
|
return undefined;
|
|
16
17
|
}
|
|
17
|
-
return (0, logs_1.showProxyLogs)(bt, proxy.id, port);
|
|
18
|
+
return (0, logs_1.showProxyLogs)(bt, (_a = proxy.id) !== null && _a !== void 0 ? _a : '', port);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
exports.default = Logs;
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { BaseCommand } from '../../base';
|
|
3
3
|
export default class Update extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
|
-
static examples:
|
|
5
|
+
static examples: {
|
|
6
|
+
description: string;
|
|
7
|
+
command: string;
|
|
8
|
+
}[];
|
|
6
9
|
static flags: {
|
|
7
10
|
watch: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
8
11
|
logs: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
@@ -13,6 +16,19 @@ export default class Update extends BaseCommand {
|
|
|
13
16
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
17
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
18
|
'require-auth': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
19
|
+
'request-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
|
+
'request-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
+
'request-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
22
|
+
'request-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
23
|
+
'request-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
24
|
+
'request-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
25
|
+
'response-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
26
|
+
'response-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
27
|
+
'response-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
28
|
+
'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
29
|
+
'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
30
|
+
'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
31
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
16
32
|
};
|
|
17
33
|
static args: {
|
|
18
34
|
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
@@ -5,11 +5,31 @@ const base_1 = require("../../base");
|
|
|
5
5
|
const files_1 = require("../../files");
|
|
6
6
|
const logs_1 = require("../../logs");
|
|
7
7
|
const management_1 = require("../../proxies/management");
|
|
8
|
+
const runtime_1 = require("../../proxies/runtime");
|
|
8
9
|
const utils_1 = require("../../proxies/utils");
|
|
10
|
+
const runtime_2 = require("../../runtime");
|
|
9
11
|
class Update extends base_1.BaseCommand {
|
|
10
12
|
async run() {
|
|
11
13
|
var _a, _b;
|
|
12
|
-
const { bt, args: { id }, flags
|
|
14
|
+
const { bt, args: { id }, flags, metadata, } = await this.parse(Update);
|
|
15
|
+
const { name, 'destination-url': destinationUrl, 'response-transform-code': responseTransformCode, 'request-transform-code': requestTransformCode, 'application-id': applicationId, configuration, 'require-auth': requireAuth, 'request-transform-image': requestTransformImage, 'request-transform-dependencies': requestTransformDependencies, 'request-transform-timeout': requestTransformTimeout, 'request-transform-warm-concurrency': requestTransformWarmConcurrency, 'request-transform-resources': requestTransformResources, 'request-transform-permissions': requestTransformPermissions, 'response-transform-image': responseTransformImage, 'response-transform-dependencies': responseTransformDependencies, 'response-transform-timeout': responseTransformTimeout, 'response-transform-warm-concurrency': responseTransformWarmConcurrency, 'response-transform-resources': responseTransformResources, 'response-transform-permissions': responseTransformPermissions, async: asyncFlag, watch, logs, } = flags;
|
|
16
|
+
(0, runtime_1.validateProxyApplicationId)(applicationId, flags);
|
|
17
|
+
const requestTransformRuntime = (0, runtime_2.buildRuntime)({
|
|
18
|
+
image: requestTransformImage,
|
|
19
|
+
dependencies: requestTransformDependencies,
|
|
20
|
+
timeout: requestTransformTimeout,
|
|
21
|
+
warmConcurrency: requestTransformWarmConcurrency,
|
|
22
|
+
resources: requestTransformResources,
|
|
23
|
+
permissions: requestTransformPermissions,
|
|
24
|
+
});
|
|
25
|
+
const responseTransformRuntime = (0, runtime_2.buildRuntime)({
|
|
26
|
+
image: responseTransformImage,
|
|
27
|
+
dependencies: responseTransformDependencies,
|
|
28
|
+
timeout: responseTransformTimeout,
|
|
29
|
+
warmConcurrency: responseTransformWarmConcurrency,
|
|
30
|
+
resources: responseTransformResources,
|
|
31
|
+
permissions: responseTransformPermissions,
|
|
32
|
+
});
|
|
13
33
|
const model = (0, utils_1.createModelFromFlags)({
|
|
14
34
|
name,
|
|
15
35
|
destinationUrl: destinationUrl === null || destinationUrl === void 0 ? void 0 : destinationUrl.toString(),
|
|
@@ -20,13 +40,23 @@ class Update extends base_1.BaseCommand {
|
|
|
20
40
|
requireAuth: ((_b = (_a = metadata.flags) === null || _a === void 0 ? void 0 : _a['require-auth']) === null || _b === void 0 ? void 0 : _b.setFromDefault)
|
|
21
41
|
? undefined
|
|
22
42
|
: requireAuth,
|
|
43
|
+
requestTransformRuntime,
|
|
44
|
+
responseTransformRuntime,
|
|
23
45
|
});
|
|
24
46
|
await (0, management_1.patchProxy)(bt, id, model);
|
|
47
|
+
const proxy = await (0, management_1.getProxy)(bt, id);
|
|
48
|
+
const isConfigurableRuntime = (0, runtime_2.needsPolling)(proxy.state);
|
|
49
|
+
if (!asyncFlag) {
|
|
50
|
+
await (0, runtime_2.waitForResourceState)(bt, 'proxy', id, proxy.state);
|
|
51
|
+
}
|
|
25
52
|
this.log('Proxy updated successfully!');
|
|
26
53
|
if (logs) {
|
|
27
54
|
await (0, logs_1.showProxyLogs)(bt, id);
|
|
28
55
|
}
|
|
29
|
-
if (watch) {
|
|
56
|
+
if (watch && isConfigurableRuntime) {
|
|
57
|
+
this.warn(`--watch is not supported for configurable runtimes (${runtime_2.CONFIGURABLE_RUNTIME_IMAGES.join(' | ')}). Skipping watch.`);
|
|
58
|
+
}
|
|
59
|
+
else if (watch) {
|
|
30
60
|
const entries = Object.entries({
|
|
31
61
|
requestTransformCode,
|
|
32
62
|
responseTransformCode,
|
|
@@ -51,10 +81,40 @@ class Update extends base_1.BaseCommand {
|
|
|
51
81
|
exports.default = Update;
|
|
52
82
|
Update.description = 'Updates an existing Pre-Configured Proxy. Requires `proxy:update` Management Application permission';
|
|
53
83
|
Update.examples = [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
{
|
|
85
|
+
description: 'Update a proxy destination URL',
|
|
86
|
+
command: '<%= config.bin %> <%= command.id %> <proxy-id> --destination-url https://api.example.com',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
description: 'Update a proxy with legacy runtime transforms',
|
|
90
|
+
command: '<%= config.bin %> <%= command.id %> <proxy-id> --request-transform-code ./request.js --request-transform-image node-bt --application-id <application-id>',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
description: 'Update a proxy with node22 transforms',
|
|
94
|
+
command: '<%= config.bin %> <%= command.id %> <proxy-id> --request-transform-code ./request.js --request-transform-image node22 --response-transform-code ./response.js --response-transform-image node22',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
description: 'Update a proxy with node22 transforms and all runtime options',
|
|
98
|
+
command: '<%= config.bin %> <%= command.id %> <proxy-id> ' +
|
|
99
|
+
'--name "My Proxy" ' +
|
|
100
|
+
'--destination-url https://api.example.com ' +
|
|
101
|
+
'--configuration ./config.env ' +
|
|
102
|
+
'--require-auth ' +
|
|
103
|
+
'--request-transform-code ./request.js ' +
|
|
104
|
+
'--request-transform-image node22 ' +
|
|
105
|
+
'--request-transform-timeout 10 ' +
|
|
106
|
+
'--request-transform-warm-concurrency 0 ' +
|
|
107
|
+
'--request-transform-resources standard ' +
|
|
108
|
+
'--request-transform-dependencies ./deps.json ' +
|
|
109
|
+
'--request-transform-permissions token:read ' +
|
|
110
|
+
'--response-transform-code ./response.js ' +
|
|
111
|
+
'--response-transform-image node22 ' +
|
|
112
|
+
'--response-transform-timeout 10 ' +
|
|
113
|
+
'--response-transform-warm-concurrency 0 ' +
|
|
114
|
+
'--response-transform-resources standard ' +
|
|
115
|
+
'--response-transform-dependencies ./deps.json ' +
|
|
116
|
+
'--response-transform-permissions token:read',
|
|
117
|
+
},
|
|
58
118
|
];
|
|
59
119
|
Update.flags = {
|
|
60
120
|
...utils_1.PROXY_FLAGS,
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base';
|
|
2
2
|
export default class Create extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
static examples:
|
|
4
|
+
static examples: {
|
|
5
|
+
description: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}[];
|
|
5
8
|
static flags: {
|
|
9
|
+
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
dependencies: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
6
16
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
17
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
18
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const base_1 = require("../../base");
|
|
4
4
|
const management_1 = require("../../reactors/management");
|
|
5
|
+
const runtime_1 = require("../../reactors/runtime");
|
|
5
6
|
const utils_1 = require("../../reactors/utils");
|
|
7
|
+
const runtime_2 = require("../../runtime");
|
|
6
8
|
const utils_2 = require("../../utils");
|
|
7
9
|
class Create extends base_1.BaseCommand {
|
|
8
10
|
async run() {
|
|
9
11
|
const { flags, bt } = await this.parse(Create);
|
|
12
|
+
const { timeout, 'warm-concurrency': warmConcurrency, resources, dependencies, permissions, 'application-id': applicationId, async: asyncFlag, } = flags;
|
|
13
|
+
const image = await (0, runtime_2.promptRuntimeImage)(flags.image);
|
|
14
|
+
(0, runtime_1.validateReactorRuntimeFlags)(flags, image);
|
|
15
|
+
(0, runtime_1.validateReactorApplicationId)(applicationId, image);
|
|
10
16
|
const name = await (0, utils_2.promptStringIfUndefined)(flags.name, {
|
|
11
17
|
message: 'What is the Reactor name?',
|
|
12
18
|
validate: (value) => Boolean(value),
|
|
@@ -15,26 +21,82 @@ class Create extends base_1.BaseCommand {
|
|
|
15
21
|
message: 'Enter the Reactor code file path:',
|
|
16
22
|
validate: (value) => Boolean(value),
|
|
17
23
|
});
|
|
18
|
-
const applicationId = await (0, utils_2.promptStringIfUndefined)(flags['application-id'], {
|
|
19
|
-
message: '(Optional) Enter the Application ID to use in the Reactor:',
|
|
20
|
-
});
|
|
21
24
|
const configuration = await (0, utils_2.promptStringIfUndefined)(flags.configuration, {
|
|
22
25
|
message: '(Optional) Enter the configuration file path (.env format):',
|
|
23
26
|
});
|
|
27
|
+
let promptedApplicationId;
|
|
28
|
+
if ((0, runtime_2.isLegacyRuntimeImage)(image)) {
|
|
29
|
+
promptedApplicationId = await (0, utils_2.promptStringIfUndefined)(applicationId, {
|
|
30
|
+
message: '(Optional) Enter the Application ID to use in the Reactor:',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
let runtime;
|
|
34
|
+
if (!(0, runtime_2.isLegacyRuntimeImage)(image)) {
|
|
35
|
+
const runtimeOptions = await (0, runtime_2.promptRuntimeOptions)({
|
|
36
|
+
timeout,
|
|
37
|
+
'warm-concurrency': warmConcurrency,
|
|
38
|
+
resources,
|
|
39
|
+
dependencies,
|
|
40
|
+
permissions,
|
|
41
|
+
});
|
|
42
|
+
runtime = (0, runtime_2.buildRuntime)({
|
|
43
|
+
image,
|
|
44
|
+
...runtimeOptions,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
24
47
|
const model = (0, utils_1.createModelFromFlags)({
|
|
25
48
|
name,
|
|
26
49
|
code,
|
|
27
|
-
applicationId,
|
|
50
|
+
applicationId: promptedApplicationId,
|
|
28
51
|
configuration,
|
|
52
|
+
runtime,
|
|
29
53
|
});
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
const reactor = await (0, management_1.createReactor)(bt, model);
|
|
55
|
+
if (!asyncFlag && reactor.id) {
|
|
56
|
+
try {
|
|
57
|
+
await (0, runtime_2.waitForResourceState)(bt, 'reactor', reactor.id, reactor.state);
|
|
58
|
+
this.log('Reactor created successfully!');
|
|
59
|
+
this.log(`id: ${reactor.id}`);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.log('Reactor created but failed to become ready.');
|
|
63
|
+
this.log(`id: ${reactor.id}`);
|
|
64
|
+
this.log(`You can retry by running: bt reactors update ${reactor.id} [OPTIONS]`);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.log('Reactor created successfully!');
|
|
70
|
+
this.log(`id: ${reactor.id}`);
|
|
71
|
+
}
|
|
33
72
|
}
|
|
34
73
|
}
|
|
35
74
|
exports.default = Create;
|
|
36
75
|
Create.description = 'Creates a new Reactor. Requires `reactor:create` Management Application permission';
|
|
37
|
-
Create.examples = [
|
|
76
|
+
Create.examples = [
|
|
77
|
+
{
|
|
78
|
+
description: 'Create a reactor with legacy runtime',
|
|
79
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Reactor" --code ./reactor.js --image node-bt --application-id <application-id>',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
description: 'Create a reactor with node22 runtime',
|
|
83
|
+
command: '<%= config.bin %> <%= command.id %> --name "My Reactor" --code ./reactor.js --image node22',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
description: 'Create a reactor with node22 and all runtime options',
|
|
87
|
+
command: '<%= config.bin %> <%= command.id %> ' +
|
|
88
|
+
'--name "My Reactor" ' +
|
|
89
|
+
'--code ./reactor.js ' +
|
|
90
|
+
'--configuration ./config.env ' +
|
|
91
|
+
'--image node22 ' +
|
|
92
|
+
'--timeout 10 ' +
|
|
93
|
+
'--warm-concurrency 0 ' +
|
|
94
|
+
'--resources standard ' +
|
|
95
|
+
'--dependencies ./deps.json ' +
|
|
96
|
+
'--permissions token:read ' +
|
|
97
|
+
'--permissions token:create',
|
|
98
|
+
},
|
|
99
|
+
];
|
|
38
100
|
Create.flags = {
|
|
39
101
|
...utils_1.REACTOR_FLAGS,
|
|
40
102
|
};
|
|
@@ -8,6 +8,7 @@ const logs_1 = require("../../logs");
|
|
|
8
8
|
const management_1 = require("../../reactors/management");
|
|
9
9
|
class Reactors extends base_1.BaseCommand {
|
|
10
10
|
async run() {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
const { bt, flags: { page }, } = await this.parse(Reactors);
|
|
12
13
|
const reactor = await (0, management_1.selectReactor)(bt, page);
|
|
13
14
|
if (!reactor) {
|
|
@@ -36,9 +37,9 @@ class Reactors extends base_1.BaseCommand {
|
|
|
36
37
|
return undefined;
|
|
37
38
|
}
|
|
38
39
|
if (action === 'logs') {
|
|
39
|
-
return (0, logs_1.showReactorLogs)(bt, reactor.id);
|
|
40
|
+
return (0, logs_1.showReactorLogs)(bt, (_a = reactor.id) !== null && _a !== void 0 ? _a : '');
|
|
40
41
|
}
|
|
41
|
-
if (action === 'delete' && (await (0, management_1.deleteReactor)(bt, reactor.id))) {
|
|
42
|
+
if (action === 'delete' && (await (0, management_1.deleteReactor)(bt, (_b = reactor.id) !== null && _b !== void 0 ? _b : ''))) {
|
|
42
43
|
return this.log('Reactor deleted successfully!');
|
|
43
44
|
}
|
|
44
45
|
return undefined;
|
|
@@ -6,6 +6,7 @@ const logs_1 = require("../../logs");
|
|
|
6
6
|
const management_1 = require("../../reactors/management");
|
|
7
7
|
class Logs extends base_1.BaseCommand {
|
|
8
8
|
async run() {
|
|
9
|
+
var _a;
|
|
9
10
|
const { bt, flags: { port }, args: { id }, } = await this.parse(Logs);
|
|
10
11
|
if (id) {
|
|
11
12
|
return (0, logs_1.showReactorLogs)(bt, id, port);
|
|
@@ -14,7 +15,7 @@ class Logs extends base_1.BaseCommand {
|
|
|
14
15
|
if (!reactor) {
|
|
15
16
|
return undefined;
|
|
16
17
|
}
|
|
17
|
-
return (0, logs_1.showReactorLogs)(bt, reactor.id, port);
|
|
18
|
+
return (0, logs_1.showReactorLogs)(bt, (_a = reactor.id) !== null && _a !== void 0 ? _a : '', port);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
exports.default = Logs;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base';
|
|
2
2
|
export default class Update extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
static examples:
|
|
4
|
+
static examples: {
|
|
5
|
+
description: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}[];
|
|
5
8
|
static flags: {
|
|
6
9
|
watch: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
7
10
|
logs: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
11
|
+
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
dependencies: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
|
+
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
8
18
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
19
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
20
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -5,22 +5,43 @@ const base_1 = require("../../base");
|
|
|
5
5
|
const files_1 = require("../../files");
|
|
6
6
|
const logs_1 = require("../../logs");
|
|
7
7
|
const management_1 = require("../../reactors/management");
|
|
8
|
+
const runtime_1 = require("../../reactors/runtime");
|
|
8
9
|
const utils_1 = require("../../reactors/utils");
|
|
10
|
+
const runtime_2 = require("../../runtime");
|
|
9
11
|
class Update extends base_1.BaseCommand {
|
|
10
12
|
async run() {
|
|
11
|
-
const { bt, args: { id }, flags
|
|
13
|
+
const { bt, args: { id }, flags, } = await this.parse(Update);
|
|
14
|
+
const { name, code, 'application-id': applicationId, configuration, image, dependencies, timeout, 'warm-concurrency': warmConcurrency, resources, permissions, async: asyncFlag, watch, logs, } = flags;
|
|
15
|
+
(0, runtime_1.validateReactorApplicationId)(applicationId, image);
|
|
16
|
+
const runtime = (0, runtime_2.buildRuntime)({
|
|
17
|
+
image,
|
|
18
|
+
dependencies,
|
|
19
|
+
timeout,
|
|
20
|
+
warmConcurrency,
|
|
21
|
+
resources,
|
|
22
|
+
permissions,
|
|
23
|
+
});
|
|
12
24
|
const model = (0, utils_1.createModelFromFlags)({
|
|
13
25
|
name,
|
|
14
26
|
code,
|
|
15
27
|
applicationId,
|
|
16
28
|
configuration,
|
|
29
|
+
runtime,
|
|
17
30
|
});
|
|
18
31
|
await (0, management_1.patchReactor)(bt, id, model);
|
|
32
|
+
const reactor = await (0, management_1.getReactor)(bt, id);
|
|
33
|
+
const isConfigurableRuntime = (0, runtime_2.needsPolling)(reactor.state);
|
|
34
|
+
if (!asyncFlag) {
|
|
35
|
+
await (0, runtime_2.waitForResourceState)(bt, 'reactor', id, reactor.state);
|
|
36
|
+
}
|
|
19
37
|
this.log('Reactor updated successfully!');
|
|
20
38
|
if (logs) {
|
|
21
39
|
await (0, logs_1.showReactorLogs)(bt, id);
|
|
22
40
|
}
|
|
23
|
-
if (watch) {
|
|
41
|
+
if (watch && isConfigurableRuntime) {
|
|
42
|
+
this.warn(`--watch is not supported for configurable runtimes (${runtime_2.CONFIGURABLE_RUNTIME_IMAGES.join(' | ')}). Skipping watch.`);
|
|
43
|
+
}
|
|
44
|
+
else if (watch) {
|
|
24
45
|
const entries = Object.entries({
|
|
25
46
|
code,
|
|
26
47
|
configuration,
|
|
@@ -44,9 +65,28 @@ class Update extends base_1.BaseCommand {
|
|
|
44
65
|
exports.default = Update;
|
|
45
66
|
Update.description = 'Updates an existing Reactor. Requires `reactor:update` Management Application permission';
|
|
46
67
|
Update.examples = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
68
|
+
{
|
|
69
|
+
description: 'Update a reactor with legacy runtime',
|
|
70
|
+
command: '<%= config.bin %> <%= command.id %> <reactor-id> --code ./reactor.js --image node-bt --application-id <application-id>',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
description: 'Update a reactor with node22 runtime',
|
|
74
|
+
command: '<%= config.bin %> <%= command.id %> <reactor-id> --code ./reactor.js --image node22',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
description: 'Update a reactor with node22 and all runtime options',
|
|
78
|
+
command: '<%= config.bin %> <%= command.id %> <reactor-id> ' +
|
|
79
|
+
'--name "My Reactor" ' +
|
|
80
|
+
'--code ./reactor.js ' +
|
|
81
|
+
'--configuration ./config.env ' +
|
|
82
|
+
'--image node22 ' +
|
|
83
|
+
'--timeout 10 ' +
|
|
84
|
+
'--warm-concurrency 0 ' +
|
|
85
|
+
'--resources standard ' +
|
|
86
|
+
'--dependencies ./deps.json ' +
|
|
87
|
+
'--permissions token:read ' +
|
|
88
|
+
'--permissions token:create',
|
|
89
|
+
},
|
|
50
90
|
];
|
|
51
91
|
Update.flags = {
|
|
52
92
|
...utils_1.REACTOR_FLAGS,
|
package/dist/logs/connect.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const connectToReactor: (bt:
|
|
3
|
-
declare const disconnectFromReactor: (bt:
|
|
4
|
-
declare const connectToProxy: (bt:
|
|
5
|
-
declare const disconnectFromProxy: (bt:
|
|
1
|
+
import type { BasisTheoryClient } from '@basis-theory/node-sdk';
|
|
2
|
+
declare const connectToReactor: (bt: BasisTheoryClient, id: string, url: string) => Promise<void>;
|
|
3
|
+
declare const disconnectFromReactor: (bt: BasisTheoryClient, id: string) => Promise<void>;
|
|
4
|
+
declare const connectToProxy: (bt: BasisTheoryClient, id: string, url: string) => Promise<void>;
|
|
5
|
+
declare const disconnectFromProxy: (bt: BasisTheoryClient, id: string) => Promise<void>;
|
|
6
6
|
export { connectToReactor, disconnectFromReactor, connectToProxy, disconnectFromProxy, };
|
package/dist/logs/connect.js
CHANGED
|
@@ -16,8 +16,7 @@ const createConfiguration = (url) => ({
|
|
|
16
16
|
destination: url,
|
|
17
17
|
date: Date.now(),
|
|
18
18
|
})
|
|
19
|
-
:
|
|
20
|
-
null,
|
|
19
|
+
: undefined,
|
|
21
20
|
});
|
|
22
21
|
const connectToReactor = async (bt, id, url) => {
|
|
23
22
|
core_1.ux.action.start(`Connecting to Reactor (${id})`);
|
package/dist/logs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BasisTheoryClient } from '@basis-theory/node-sdk';
|
|
2
2
|
declare const DEFAULT_LOGS_SERVER_PORT = 8220;
|
|
3
|
-
declare const showProxyLogs: (bt:
|
|
4
|
-
declare const showReactorLogs: (bt:
|
|
3
|
+
declare const showProxyLogs: (bt: BasisTheoryClient, id: string, port?: number) => Promise<void>;
|
|
4
|
+
declare const showReactorLogs: (bt: BasisTheoryClient, id: string, port?: number) => Promise<void>;
|
|
5
5
|
export { showProxyLogs, showReactorLogs, DEFAULT_LOGS_SERVER_PORT };
|
package/dist/logs/server.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLogServer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
|
|
6
|
-
/* eslint-disable no-promise-executor-return */
|
|
5
|
+
/* eslint-disable no-promise-executor-return, eslint-comments/disable-enable-pair */
|
|
7
6
|
const core_1 = require("@oclif/core");
|
|
8
7
|
const cloudflared_1 = require("cloudflared");
|
|
9
8
|
const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
|