@basis-theory-labs/cli 3.0.0 → 4.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 +31 -22
- package/dist/commands/proxies/create.d.ts +1 -1
- package/dist/commands/proxies/create.js +1 -1
- package/dist/commands/proxies/update.d.ts +1 -1
- package/dist/commands/proxies/update.js +2 -2
- package/dist/commands/reactors/create.d.ts +2 -1
- package/dist/commands/reactors/create.js +12 -4
- package/dist/commands/reactors/update.d.ts +2 -1
- package/dist/commands/reactors/update.js +129 -30
- package/dist/files.d.ts +2 -1
- package/dist/files.js +31 -1
- package/dist/logs/connect.js +3 -3
- package/dist/logs/http.d.ts +2 -2
- package/dist/logs/http.js +20 -10
- package/dist/logs/server.js +5 -3
- package/dist/proxies/utils.d.ts +1 -1
- package/dist/proxies/utils.js +5 -5
- package/dist/reactors/runtime.d.ts +2 -1
- package/dist/reactors/runtime.js +8 -5
- package/dist/reactors/utils.d.ts +6 -3
- package/dist/reactors/utils.js +4 -0
- package/dist/runtime/flags.d.ts +1 -1
- package/dist/runtime/flags.js +5 -5
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +5 -1
- package/dist/runtime/state.js +6 -4
- package/dist/runtime/utils.d.ts +9 -2
- package/dist/runtime/utils.js +38 -6
- package/oclif.manifest.json +34 -18
- package/package.json +9 -10
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/
|
|
22
|
+
@basis-theory-labs/cli/4.1.0 linux-x64 node-v22.23.1
|
|
23
23
|
$ bt --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ bt COMMAND
|
|
@@ -62,7 +62,7 @@ EXAMPLES
|
|
|
62
62
|
$ bt applications
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
_See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/
|
|
65
|
+
_See code: [dist/commands/applications/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v4.1.0/dist/commands/applications/index.ts)_
|
|
66
66
|
|
|
67
67
|
## `bt applications create`
|
|
68
68
|
|
|
@@ -151,7 +151,7 @@ EXAMPLES
|
|
|
151
151
|
$ bt proxies
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/
|
|
154
|
+
_See code: [dist/commands/proxies/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v4.1.0/dist/commands/proxies/index.ts)_
|
|
155
155
|
|
|
156
156
|
## `bt proxies create`
|
|
157
157
|
|
|
@@ -165,7 +165,7 @@ USAGE
|
|
|
165
165
|
[--request-transform-permissions <value>] [--response-transform-image node-bt|node22]
|
|
166
166
|
[--response-transform-package-json <value>] [--response-transform-timeout <value>]
|
|
167
167
|
[--response-transform-warm-concurrency <value>] [--response-transform-resources standard|large|xlarge]
|
|
168
|
-
[--response-transform-permissions <value>] [--
|
|
168
|
+
[--response-transform-permissions <value>] [--no-wait]
|
|
169
169
|
|
|
170
170
|
FLAGS
|
|
171
171
|
-a, --[no-]require-auth whether the Proxy requires Basis Theory authentication to be invoked.
|
|
@@ -177,7 +177,7 @@ FLAGS
|
|
|
177
177
|
-s, --response-transform-code=<value> path to JavaScript file containing a Response Transform code
|
|
178
178
|
-u, --destination-url=<value> URL to which requests will be proxied
|
|
179
179
|
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
180
|
-
--
|
|
180
|
+
--no-wait do not wait for proxy to be ready (requires at least one transform with
|
|
181
181
|
node22)
|
|
182
182
|
--request-transform-image=<option> request-transform runtime image (node-bt|node22)
|
|
183
183
|
<options: node-bt|node22>
|
|
@@ -187,7 +187,7 @@ FLAGS
|
|
|
187
187
|
--request-transform-permissions=<value>... request-transform permission to grant, repeatable (node22 only)
|
|
188
188
|
--request-transform-resources=<option> request-transform resource tier (node22 only)
|
|
189
189
|
<options: standard|large|xlarge>
|
|
190
|
-
--request-transform-timeout=<value> request-transform timeout in seconds,
|
|
190
|
+
--request-transform-timeout=<value> request-transform timeout in seconds, 10-30 (node22 only)
|
|
191
191
|
--request-transform-warm-concurrency=<value> request-transform warm concurrency, 0-1 (node22 only)
|
|
192
192
|
--response-transform-image=<option> response-transform runtime image (node-bt|node22)
|
|
193
193
|
<options: node-bt|node22>
|
|
@@ -197,7 +197,7 @@ FLAGS
|
|
|
197
197
|
--response-transform-permissions=<value>... response-transform permission to grant, repeatable (node22 only)
|
|
198
198
|
--response-transform-resources=<option> response-transform resource tier (node22 only)
|
|
199
199
|
<options: standard|large|xlarge>
|
|
200
|
-
--response-transform-timeout=<value> response-transform timeout in seconds,
|
|
200
|
+
--response-transform-timeout=<value> response-transform timeout in seconds, 10-30 (node22 only)
|
|
201
201
|
--response-transform-warm-concurrency=<value> response-transform warm concurrency, 0-1 (node22 only)
|
|
202
202
|
|
|
203
203
|
DESCRIPTION
|
|
@@ -290,7 +290,7 @@ USAGE
|
|
|
290
290
|
standard|large|xlarge] [--request-transform-permissions <value>] [--response-transform-image node-bt|node22]
|
|
291
291
|
[--response-transform-package-json <value>] [--response-transform-timeout <value>]
|
|
292
292
|
[--response-transform-warm-concurrency <value>] [--response-transform-resources standard|large|xlarge]
|
|
293
|
-
[--response-transform-permissions <value>] [--
|
|
293
|
+
[--response-transform-permissions <value>] [--no-wait] [-w] [-l]
|
|
294
294
|
|
|
295
295
|
ARGUMENTS
|
|
296
296
|
ID Proxy id to update
|
|
@@ -307,7 +307,7 @@ FLAGS
|
|
|
307
307
|
-u, --destination-url=<value> URL to which requests will be proxied
|
|
308
308
|
-w, --watch Watch for changes in informed files
|
|
309
309
|
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
310
|
-
--
|
|
310
|
+
--no-wait do not wait for proxy to be ready (requires at least one transform with
|
|
311
311
|
node22)
|
|
312
312
|
--request-transform-image=<option> request-transform runtime image (node-bt|node22)
|
|
313
313
|
<options: node-bt|node22>
|
|
@@ -317,7 +317,7 @@ FLAGS
|
|
|
317
317
|
--request-transform-permissions=<value>... request-transform permission to grant, repeatable (node22 only)
|
|
318
318
|
--request-transform-resources=<option> request-transform resource tier (node22 only)
|
|
319
319
|
<options: standard|large|xlarge>
|
|
320
|
-
--request-transform-timeout=<value> request-transform timeout in seconds,
|
|
320
|
+
--request-transform-timeout=<value> request-transform timeout in seconds, 10-30 (node22 only)
|
|
321
321
|
--request-transform-warm-concurrency=<value> request-transform warm concurrency, 0-1 (node22 only)
|
|
322
322
|
--response-transform-image=<option> response-transform runtime image (node-bt|node22)
|
|
323
323
|
<options: node-bt|node22>
|
|
@@ -327,7 +327,7 @@ FLAGS
|
|
|
327
327
|
--response-transform-permissions=<value>... response-transform permission to grant, repeatable (node22 only)
|
|
328
328
|
--response-transform-resources=<option> response-transform resource tier (node22 only)
|
|
329
329
|
<options: standard|large|xlarge>
|
|
330
|
-
--response-transform-timeout=<value> response-transform timeout in seconds,
|
|
330
|
+
--response-transform-timeout=<value> response-transform timeout in seconds, 10-30 (node22 only)
|
|
331
331
|
--response-transform-warm-concurrency=<value> response-transform warm concurrency, 0-1 (node22 only)
|
|
332
332
|
|
|
333
333
|
DESCRIPTION
|
|
@@ -378,7 +378,7 @@ EXAMPLES
|
|
|
378
378
|
$ bt reactors
|
|
379
379
|
```
|
|
380
380
|
|
|
381
|
-
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/
|
|
381
|
+
_See code: [dist/commands/reactors/index.ts](https://github.com/Basis-Theory-Labs/basistheory-cli/blob/v4.1.0/dist/commands/reactors/index.ts)_
|
|
382
382
|
|
|
383
383
|
## `bt reactors create`
|
|
384
384
|
|
|
@@ -388,7 +388,7 @@ Creates a new Reactor. Requires `reactor:create` Management Application permissi
|
|
|
388
388
|
USAGE
|
|
389
389
|
$ bt reactors create -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [--image node-bt|node22]
|
|
390
390
|
[--package-json <value>] [--timeout <value>] [--warm-concurrency <value>] [--resources standard|large|xlarge]
|
|
391
|
-
[--permissions <value>] [--async]
|
|
391
|
+
[--permissions <value>] [--no-wait] [--async]
|
|
392
392
|
|
|
393
393
|
FLAGS
|
|
394
394
|
-c, --configuration=<value> path to configuration file (.env format) to use in the Reactor
|
|
@@ -396,15 +396,17 @@ FLAGS
|
|
|
396
396
|
-n, --name=<value> name of the Reactor
|
|
397
397
|
-r, --code=<value> path to JavaScript file containing the Reactor code
|
|
398
398
|
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
399
|
-
--async
|
|
399
|
+
--[no-]async execute Reactor invocations asynchronously (node22 only)
|
|
400
400
|
--image=<option> runtime image (node-bt|node22)
|
|
401
401
|
<options: node-bt|node22>
|
|
402
|
+
--no-wait do not wait for resource provisioning to complete
|
|
402
403
|
--package-json=<value> path to runtime package.json JSON file (top-level dependencies required; supports
|
|
403
404
|
resolutions or overrides fallback; pinned versions required) (node22 only)
|
|
404
405
|
--permissions=<value>... permission to grant, repeatable (node22 only)
|
|
405
406
|
--resources=<option> resource tier (node22 only, default: standard)
|
|
406
407
|
<options: standard|large|xlarge>
|
|
407
|
-
--timeout=<value> timeout in seconds,
|
|
408
|
+
--timeout=<value> timeout in seconds, 10-900 (node22 only; maximum 30 when runtime async is disabled;
|
|
409
|
+
default: 10)
|
|
408
410
|
--warm-concurrency=<value> number of warm instances, 0-1 (node22 only, default: 0)
|
|
409
411
|
|
|
410
412
|
DESCRIPTION
|
|
@@ -421,7 +423,7 @@ EXAMPLES
|
|
|
421
423
|
|
|
422
424
|
Create a reactor with node22 and all runtime options
|
|
423
425
|
|
|
424
|
-
$ bt reactors create --name "My Reactor" --code ./reactor.js --configuration ./config.env --image node22 \
|
|
426
|
+
$ bt reactors create --name "My Reactor" --code ./reactor.js --configuration ./config.env --image node22 --async \
|
|
425
427
|
--timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions token:read \
|
|
426
428
|
--permissions token:create
|
|
427
429
|
```
|
|
@@ -482,7 +484,7 @@ Updates an existing Reactor. Requires `reactor:update` Management Application pe
|
|
|
482
484
|
USAGE
|
|
483
485
|
$ bt reactors update ID -x <value> [-n <value>] [-c <value>] [-i <value>] [-r <value>] [--image node-bt|node22]
|
|
484
486
|
[--package-json <value>] [--timeout <value>] [--warm-concurrency <value>] [--resources standard|large|xlarge]
|
|
485
|
-
[--permissions <value>] [--async] [-w] [-l]
|
|
487
|
+
[--permissions <value>] [--no-wait] [--async] [-w] [-l]
|
|
486
488
|
|
|
487
489
|
ARGUMENTS
|
|
488
490
|
ID Reactor id to update
|
|
@@ -493,17 +495,19 @@ FLAGS
|
|
|
493
495
|
-l, --logs Start logs server after update
|
|
494
496
|
-n, --name=<value> name of the Reactor
|
|
495
497
|
-r, --code=<value> path to JavaScript file containing the Reactor code
|
|
496
|
-
-w, --watch Watch for changes in
|
|
498
|
+
-w, --watch Watch for changes in supplied code, configuration, and runtime package files
|
|
497
499
|
-x, --management-key=<value> (required) management key used for connecting with the reactor / proxy
|
|
498
|
-
--async
|
|
500
|
+
--[no-]async execute Reactor invocations asynchronously (node22 only)
|
|
499
501
|
--image=<option> runtime image (node-bt|node22)
|
|
500
502
|
<options: node-bt|node22>
|
|
503
|
+
--no-wait do not wait for resource provisioning to complete
|
|
501
504
|
--package-json=<value> path to runtime package.json JSON file (top-level dependencies required; supports
|
|
502
505
|
resolutions or overrides fallback; pinned versions required) (node22 only)
|
|
503
506
|
--permissions=<value>... permission to grant, repeatable (node22 only)
|
|
504
507
|
--resources=<option> resource tier (node22 only, default: standard)
|
|
505
508
|
<options: standard|large|xlarge>
|
|
506
|
-
--timeout=<value> timeout in seconds,
|
|
509
|
+
--timeout=<value> timeout in seconds, 10-900 (node22 only; maximum 30 when runtime async is disabled;
|
|
510
|
+
default: 10)
|
|
507
511
|
--warm-concurrency=<value> number of warm instances, 0-1 (node22 only, default: 0)
|
|
508
512
|
|
|
509
513
|
DESCRIPTION
|
|
@@ -518,10 +522,15 @@ EXAMPLES
|
|
|
518
522
|
|
|
519
523
|
$ bt reactors update <reactor-id> --code ./reactor.js --image node22
|
|
520
524
|
|
|
525
|
+
Watch a node22 reactor for code, configuration, and dependency changes
|
|
526
|
+
|
|
527
|
+
$ bt reactors update <reactor-id> --code ./reactor.js --configuration ./config.env --package-json ./package.json \
|
|
528
|
+
--image node22 --watch
|
|
529
|
+
|
|
521
530
|
Update a reactor with node22 and all runtime options
|
|
522
531
|
|
|
523
532
|
$ bt reactors update <reactor-id> --name "My Reactor" --code ./reactor.js --configuration ./config.env --image \
|
|
524
|
-
node22 --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json
|
|
525
|
-
token:read --permissions token:create
|
|
533
|
+
node22 --async --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json \
|
|
534
|
+
--permissions token:read --permissions token:create
|
|
526
535
|
```
|
|
527
536
|
<!-- commandsstop -->
|
|
@@ -26,7 +26,7 @@ export default class Create extends BaseCommand {
|
|
|
26
26
|
'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
27
27
|
'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
28
28
|
'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
29
|
-
|
|
29
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
30
30
|
};
|
|
31
31
|
run(): Promise<void>;
|
|
32
32
|
}
|
|
@@ -67,7 +67,7 @@ class Create extends base_1.BaseCommand {
|
|
|
67
67
|
responseTransformRuntime,
|
|
68
68
|
});
|
|
69
69
|
const proxy = await (0, management_1.createProxy)(bt, model);
|
|
70
|
-
if (!flags
|
|
70
|
+
if (!flags['no-wait'] && proxy.id) {
|
|
71
71
|
try {
|
|
72
72
|
await (0, runtime_2.waitForResourceState)(bt, 'proxy', proxy.id, proxy.state);
|
|
73
73
|
this.log('Proxy created successfully!');
|
|
@@ -28,7 +28,7 @@ export default class Update extends BaseCommand {
|
|
|
28
28
|
'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
29
29
|
'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
30
30
|
'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
31
|
-
|
|
31
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
32
32
|
};
|
|
33
33
|
static args: {
|
|
34
34
|
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
@@ -12,7 +12,7 @@ class Update extends base_1.BaseCommand {
|
|
|
12
12
|
async run() {
|
|
13
13
|
var _a, _b;
|
|
14
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-package-json': requestTransformPackageJson, 'request-transform-timeout': requestTransformTimeout, 'request-transform-warm-concurrency': requestTransformWarmConcurrency, 'request-transform-resources': requestTransformResources, 'request-transform-permissions': requestTransformPermissions, 'response-transform-image': responseTransformImage, 'response-transform-package-json': responseTransformPackageJson, 'response-transform-timeout': responseTransformTimeout, 'response-transform-warm-concurrency': responseTransformWarmConcurrency, 'response-transform-resources': responseTransformResources, 'response-transform-permissions': responseTransformPermissions,
|
|
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-package-json': requestTransformPackageJson, 'request-transform-timeout': requestTransformTimeout, 'request-transform-warm-concurrency': requestTransformWarmConcurrency, 'request-transform-resources': requestTransformResources, 'request-transform-permissions': requestTransformPermissions, 'response-transform-image': responseTransformImage, 'response-transform-package-json': responseTransformPackageJson, 'response-transform-timeout': responseTransformTimeout, 'response-transform-warm-concurrency': responseTransformWarmConcurrency, 'response-transform-resources': responseTransformResources, 'response-transform-permissions': responseTransformPermissions, 'no-wait': noWait, watch, logs, } = flags;
|
|
16
16
|
(0, runtime_1.validateProxyApplicationId)(applicationId, flags);
|
|
17
17
|
const requestTransformRuntime = (0, runtime_2.buildRuntime)({
|
|
18
18
|
image: requestTransformImage,
|
|
@@ -46,7 +46,7 @@ class Update extends base_1.BaseCommand {
|
|
|
46
46
|
await (0, management_1.patchProxy)(bt, id, model);
|
|
47
47
|
const proxy = await (0, management_1.getProxy)(bt, id);
|
|
48
48
|
const isConfigurableRuntime = (0, runtime_2.needsPolling)(proxy.state);
|
|
49
|
-
if (!
|
|
49
|
+
if (!noWait) {
|
|
50
50
|
await (0, runtime_2.waitForResourceState)(bt, 'proxy', id, proxy.state);
|
|
51
51
|
}
|
|
52
52
|
this.log('Proxy updated successfully!');
|
|
@@ -6,13 +6,14 @@ export default class Create extends BaseCommand {
|
|
|
6
6
|
command: string;
|
|
7
7
|
}[];
|
|
8
8
|
static flags: {
|
|
9
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
9
10
|
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
'package-json': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
13
|
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
14
|
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
15
|
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
-
|
|
16
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
16
17
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
18
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
19
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -9,7 +9,7 @@ const utils_2 = require("../../utils");
|
|
|
9
9
|
class Create extends base_1.BaseCommand {
|
|
10
10
|
async run() {
|
|
11
11
|
const { flags, bt } = await this.parse(Create);
|
|
12
|
-
const { timeout, 'warm-concurrency': warmConcurrency, resources, 'package-json': packageJson, permissions, 'application-id': applicationId, async:
|
|
12
|
+
const { timeout, 'warm-concurrency': warmConcurrency, resources, 'package-json': packageJson, permissions, 'application-id': applicationId, 'no-wait': noWait, async: runtimeAsyncFlag, } = flags;
|
|
13
13
|
const image = await (0, runtime_2.promptRuntimeImage)(flags.image);
|
|
14
14
|
(0, runtime_1.validateReactorRuntimeFlags)(flags, image);
|
|
15
15
|
(0, runtime_1.validateReactorApplicationId)(applicationId, image);
|
|
@@ -32,15 +32,22 @@ class Create extends base_1.BaseCommand {
|
|
|
32
32
|
}
|
|
33
33
|
let runtime;
|
|
34
34
|
if (!(0, runtime_2.isLegacyRuntimeImage)(image)) {
|
|
35
|
+
const runtimeAsync = await (0, utils_2.promptBooleanIfUndefined)(runtimeAsyncFlag, {
|
|
36
|
+
message: 'Execute Reactor invocations asynchronously?',
|
|
37
|
+
default: false,
|
|
38
|
+
});
|
|
39
|
+
(0, runtime_2.validateRuntimeTimeout)(timeout, runtimeAsync);
|
|
35
40
|
const runtimeOptions = await (0, runtime_2.promptRuntimeOptions)({
|
|
36
41
|
timeout,
|
|
37
42
|
'warm-concurrency': warmConcurrency,
|
|
38
43
|
resources,
|
|
39
44
|
'package-json': packageJson,
|
|
40
45
|
permissions,
|
|
41
|
-
});
|
|
42
|
-
|
|
46
|
+
}, undefined, (0, runtime_2.getMaxRuntimeTimeout)(runtimeAsync));
|
|
47
|
+
(0, runtime_2.validateRuntimeTimeout)(runtimeOptions.timeout, runtimeAsync);
|
|
48
|
+
runtime = (0, runtime_2.buildReactorRuntime)({
|
|
43
49
|
image,
|
|
50
|
+
async: runtimeAsync,
|
|
44
51
|
...runtimeOptions,
|
|
45
52
|
});
|
|
46
53
|
}
|
|
@@ -52,7 +59,7 @@ class Create extends base_1.BaseCommand {
|
|
|
52
59
|
runtime,
|
|
53
60
|
});
|
|
54
61
|
const reactor = await (0, management_1.createReactor)(bt, model);
|
|
55
|
-
if (!
|
|
62
|
+
if (!noWait && reactor.id) {
|
|
56
63
|
try {
|
|
57
64
|
await (0, runtime_2.waitForResourceState)(bt, 'reactor', reactor.id, reactor.state);
|
|
58
65
|
this.log('Reactor created successfully!');
|
|
@@ -89,6 +96,7 @@ Create.examples = [
|
|
|
89
96
|
'--code ./reactor.js ' +
|
|
90
97
|
'--configuration ./config.env ' +
|
|
91
98
|
'--image node22 ' +
|
|
99
|
+
'--async ' +
|
|
92
100
|
'--timeout 10 ' +
|
|
93
101
|
'--warm-concurrency 0 ' +
|
|
94
102
|
'--resources standard ' +
|
|
@@ -8,13 +8,14 @@ export default class Update extends BaseCommand {
|
|
|
8
8
|
static flags: {
|
|
9
9
|
watch: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
10
10
|
logs: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
11
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
11
12
|
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
13
|
'package-json': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
14
|
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
15
|
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
16
|
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
17
|
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
|
-
|
|
18
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
18
19
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
20
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
21
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -10,16 +10,31 @@ const utils_1 = require("../../reactors/utils");
|
|
|
10
10
|
const runtime_2 = require("../../runtime");
|
|
11
11
|
class Update extends base_1.BaseCommand {
|
|
12
12
|
async run() {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
13
14
|
const { bt, args: { id }, flags, } = await this.parse(Update);
|
|
14
|
-
const { name, code, 'application-id': applicationId, configuration, image, 'package-json': packageJson, timeout, 'warm-concurrency': warmConcurrency, resources, permissions, async:
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const { name, code, 'application-id': applicationId, configuration, image, 'package-json': packageJson, timeout, 'warm-concurrency': warmConcurrency, resources, permissions, 'no-wait': noWait, async: runtimeAsync, watch, logs, } = flags;
|
|
16
|
+
const existingReactor = watch ||
|
|
17
|
+
(0, runtime_1.hasReactorRuntimeFlags)(flags) ||
|
|
18
|
+
(applicationId !== undefined && image === undefined)
|
|
19
|
+
? await (0, management_1.getReactor)(bt, id)
|
|
20
|
+
: undefined;
|
|
21
|
+
const effectiveImage = image !== null && image !== void 0 ? image : (_a = existingReactor === null || existingReactor === void 0 ? void 0 : existingReactor.runtime) === null || _a === void 0 ? void 0 : _a.image;
|
|
22
|
+
const effectiveRuntimeAsync = (_c = runtimeAsync !== null && runtimeAsync !== void 0 ? runtimeAsync : (_b = existingReactor === null || existingReactor === void 0 ? void 0 : existingReactor.runtime) === null || _b === void 0 ? void 0 : _b.async) !== null && _c !== void 0 ? _c : false;
|
|
23
|
+
const effectiveTimeout = timeout !== null && timeout !== void 0 ? timeout : (_d = existingReactor === null || existingReactor === void 0 ? void 0 : existingReactor.runtime) === null || _d === void 0 ? void 0 : _d.timeout;
|
|
24
|
+
const isConfigurableRuntime = !(0, runtime_2.isLegacyRuntimeImage)(effectiveImage);
|
|
25
|
+
(0, runtime_1.validateReactorRuntimeFlags)(flags, effectiveImage);
|
|
26
|
+
(0, runtime_1.validateReactorApplicationId)(applicationId, effectiveImage);
|
|
27
|
+
if (timeout !== undefined || runtimeAsync !== undefined) {
|
|
28
|
+
(0, runtime_2.validateRuntimeTimeout)(effectiveTimeout, effectiveRuntimeAsync);
|
|
29
|
+
}
|
|
30
|
+
const runtime = (0, runtime_2.buildReactorRuntime)({
|
|
17
31
|
image,
|
|
18
32
|
packageJson,
|
|
19
33
|
timeout,
|
|
20
34
|
warmConcurrency,
|
|
21
35
|
resources,
|
|
22
36
|
permissions,
|
|
37
|
+
async: runtimeAsync,
|
|
23
38
|
});
|
|
24
39
|
const model = (0, utils_1.createModelFromFlags)({
|
|
25
40
|
name,
|
|
@@ -29,36 +44,110 @@ class Update extends base_1.BaseCommand {
|
|
|
29
44
|
runtime,
|
|
30
45
|
});
|
|
31
46
|
await (0, management_1.patchReactor)(bt, id, model);
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
await (0, logs_1.showReactorLogs)(bt, id);
|
|
40
|
-
}
|
|
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) {
|
|
45
|
-
const entries = Object.entries({
|
|
46
|
-
code,
|
|
47
|
-
configuration,
|
|
48
|
-
}).filter(([, value]) => Boolean(value));
|
|
49
|
-
const files = entries.reduce((arr, [, file]) => [...arr, file], []);
|
|
47
|
+
const watchedEntries = Object.entries({
|
|
48
|
+
code,
|
|
49
|
+
configuration,
|
|
50
|
+
...(isConfigurableRuntime ? { packageJson } : {}),
|
|
51
|
+
}).filter(([, value]) => Boolean(value));
|
|
52
|
+
const startWatching = (initialUpdateCompleted) => {
|
|
53
|
+
const files = watchedEntries.reduce((arr, [, file]) => [...arr, file], []);
|
|
50
54
|
if (files.length) {
|
|
51
55
|
this.log(`Watching files for changes: ${files.join(', ')} `);
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
await (0, management_1.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (isConfigurableRuntime) {
|
|
58
|
+
const waitUntilReactorIsAvailable = async () => {
|
|
59
|
+
await initialUpdateCompleted;
|
|
60
|
+
const currentReactor = await (0, management_1.getReactor)(bt, id);
|
|
61
|
+
if (!(0, runtime_2.needsPolling)(currentReactor.state)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
await (0, runtime_2.waitForResourceState)(bt, 'reactor', id, currentReactor.state);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const latestReactor = await (0, management_1.getReactor)(bt, id);
|
|
69
|
+
if (latestReactor.state !== 'failed' &&
|
|
70
|
+
latestReactor.state !== 'outdated') {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const pushLatestChanges = (0, files_1.createCoalescingHandler)(async (markLatestStateCaptured) => {
|
|
76
|
+
await waitUntilReactorIsAvailable();
|
|
77
|
+
core_1.ux.action.start('Pushing latest watched changes');
|
|
78
|
+
try {
|
|
79
|
+
markLatestStateCaptured();
|
|
80
|
+
await (0, management_1.patchReactor)(bt, id, (0, utils_1.createModelFromFlags)({
|
|
81
|
+
code,
|
|
82
|
+
configuration,
|
|
83
|
+
runtime: (0, runtime_2.buildReactorRuntime)({ packageJson }),
|
|
84
|
+
}));
|
|
85
|
+
core_1.ux.action.stop('✅\t');
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
core_1.ux.action.stop('failed ❌');
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
const updatedReactor = await (0, management_1.getReactor)(bt, id);
|
|
92
|
+
await (0, runtime_2.waitForResourceState)(bt, 'reactor', id, updatedReactor.state);
|
|
93
|
+
}, (error) => {
|
|
94
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
95
|
+
this.warn(`Failed to push watched Reactor changes: ${message}`);
|
|
96
|
+
});
|
|
97
|
+
watchedEntries.forEach(([, file]) => {
|
|
98
|
+
(0, files_1.watchForChanges)(file, () => {
|
|
99
|
+
this.log(`Detected change in ${file}. Queuing latest files`);
|
|
100
|
+
return pushLatestChanges();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
watchedEntries.forEach(([prop, file]) => {
|
|
106
|
+
(0, files_1.watchForChanges)(file, async () => {
|
|
107
|
+
core_1.ux.action.start(`Detected change in ${file}. Pushing changes`);
|
|
108
|
+
await (0, management_1.patchReactor)(bt, id, (0, utils_1.createModelFromFlags)({
|
|
109
|
+
[prop]: file,
|
|
110
|
+
}));
|
|
111
|
+
core_1.ux.action.stop('✅\t');
|
|
112
|
+
});
|
|
60
113
|
});
|
|
61
|
-
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
let initialUpdateError;
|
|
117
|
+
const completeInitialUpdate = async () => {
|
|
118
|
+
if (!noWait) {
|
|
119
|
+
try {
|
|
120
|
+
const initialState = isConfigurableRuntime
|
|
121
|
+
? 'updating'
|
|
122
|
+
: (await (0, management_1.getReactor)(bt, id)).state;
|
|
123
|
+
await (0, runtime_2.waitForResourceState)(bt, 'reactor', id, initialState);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (!watch || !isConfigurableRuntime) {
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
initialUpdateError = error;
|
|
130
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
131
|
+
this.warn(`Initial Reactor update failed: ${message}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (initialUpdateError) {
|
|
135
|
+
this.log('Watch remains active. Save a watched file to retry the latest snapshot.');
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.log('Reactor updated successfully!');
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const initialUpdateCompleted = completeInitialUpdate();
|
|
142
|
+
if (watch && isConfigurableRuntime) {
|
|
143
|
+
startWatching(initialUpdateCompleted);
|
|
144
|
+
}
|
|
145
|
+
await initialUpdateCompleted;
|
|
146
|
+
if (logs && !initialUpdateError) {
|
|
147
|
+
await (0, logs_1.showReactorLogs)(bt, id);
|
|
148
|
+
}
|
|
149
|
+
if (watch && !isConfigurableRuntime) {
|
|
150
|
+
startWatching();
|
|
62
151
|
}
|
|
63
152
|
}
|
|
64
153
|
}
|
|
@@ -73,6 +162,15 @@ Update.examples = [
|
|
|
73
162
|
description: 'Update a reactor with node22 runtime',
|
|
74
163
|
command: '<%= config.bin %> <%= command.id %> <reactor-id> --code ./reactor.js --image node22',
|
|
75
164
|
},
|
|
165
|
+
{
|
|
166
|
+
description: 'Watch a node22 reactor for code, configuration, and dependency changes',
|
|
167
|
+
command: '<%= config.bin %> <%= command.id %> <reactor-id> ' +
|
|
168
|
+
'--code ./reactor.js ' +
|
|
169
|
+
'--configuration ./config.env ' +
|
|
170
|
+
'--package-json ./package.json ' +
|
|
171
|
+
'--image node22 ' +
|
|
172
|
+
'--watch',
|
|
173
|
+
},
|
|
76
174
|
{
|
|
77
175
|
description: 'Update a reactor with node22 and all runtime options',
|
|
78
176
|
command: '<%= config.bin %> <%= command.id %> <reactor-id> ' +
|
|
@@ -80,6 +178,7 @@ Update.examples = [
|
|
|
80
178
|
'--code ./reactor.js ' +
|
|
81
179
|
'--configuration ./config.env ' +
|
|
82
180
|
'--image node22 ' +
|
|
181
|
+
'--async ' +
|
|
83
182
|
'--timeout 10 ' +
|
|
84
183
|
'--warm-concurrency 0 ' +
|
|
85
184
|
'--resources standard ' +
|
|
@@ -92,7 +191,7 @@ Update.flags = {
|
|
|
92
191
|
...utils_1.REACTOR_FLAGS,
|
|
93
192
|
watch: core_1.Flags.boolean({
|
|
94
193
|
char: 'w',
|
|
95
|
-
description: 'Watch for changes in
|
|
194
|
+
description: 'Watch for changes in supplied code, configuration, and runtime package files',
|
|
96
195
|
default: false,
|
|
97
196
|
required: false,
|
|
98
197
|
}),
|
package/dist/files.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
declare const readFileContents: (filePath: string) => string;
|
|
3
|
+
declare const createCoalescingHandler: (handler: (markLatestStateCaptured: () => void) => Promise<void>, onError: (error: unknown) => void) => (() => Promise<void>);
|
|
3
4
|
declare const watchForChanges: (filePath: string, handler: (contents: string) => unknown) => fs.FSWatcher;
|
|
4
|
-
export { readFileContents, watchForChanges };
|
|
5
|
+
export { createCoalescingHandler, readFileContents, watchForChanges };
|
package/dist/files.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.watchForChanges = exports.readFileContents = void 0;
|
|
3
|
+
exports.watchForChanges = exports.readFileContents = exports.createCoalescingHandler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const lodash_debounce_1 = tslib_1.__importDefault(require("lodash.debounce"));
|
|
@@ -8,6 +8,36 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
8
8
|
const readFileContents = (filePath) => fs.readFileSync(path.resolve(process.cwd(), filePath)).toString();
|
|
9
9
|
exports.readFileContents = readFileContents;
|
|
10
10
|
const FILE_WATCH_DEBOUNCE_DELAY = 1000;
|
|
11
|
+
const createCoalescingHandler = (handler, onError) => {
|
|
12
|
+
let pending = false;
|
|
13
|
+
let running;
|
|
14
|
+
const markLatestStateCaptured = () => {
|
|
15
|
+
pending = false;
|
|
16
|
+
};
|
|
17
|
+
/* eslint-disable no-await-in-loop */
|
|
18
|
+
const drain = async () => {
|
|
19
|
+
while (pending) {
|
|
20
|
+
pending = false;
|
|
21
|
+
try {
|
|
22
|
+
await handler(markLatestStateCaptured);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
onError(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/* eslint-enable no-await-in-loop */
|
|
30
|
+
return () => {
|
|
31
|
+
pending = true;
|
|
32
|
+
if (!running) {
|
|
33
|
+
running = drain().finally(() => {
|
|
34
|
+
running = undefined;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return running;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
exports.createCoalescingHandler = createCoalescingHandler;
|
|
11
41
|
const watchForChanges = (filePath, handler) => {
|
|
12
42
|
let lastContents = '';
|
|
13
43
|
const debounced = (0, lodash_debounce_1.default)(() => {
|
package/dist/logs/connect.js
CHANGED
|
@@ -7,8 +7,8 @@ const management_2 = require("../reactors/management");
|
|
|
7
7
|
const BT_LOGGING_CONFIGURATION = 'BT_LOGGING_CONFIGURATION';
|
|
8
8
|
/**
|
|
9
9
|
* Creates configuration object to connect/disconnect to a resource
|
|
10
|
-
* @param url - server url for the resource to connect to.
|
|
11
|
-
* the logging configuration
|
|
10
|
+
* @param url - server url for the resource to connect to. An empty string
|
|
11
|
+
* removes the logging configuration when disconnecting.
|
|
12
12
|
*/
|
|
13
13
|
const createConfiguration = (url) => ({
|
|
14
14
|
[BT_LOGGING_CONFIGURATION]: url
|
|
@@ -16,7 +16,7 @@ const createConfiguration = (url) => ({
|
|
|
16
16
|
destination: url,
|
|
17
17
|
date: Date.now(),
|
|
18
18
|
})
|
|
19
|
-
:
|
|
19
|
+
: '',
|
|
20
20
|
});
|
|
21
21
|
const connectToReactor = async (bt, id, url) => {
|
|
22
22
|
core_1.ux.action.start(`Connecting to Reactor (${id})`);
|
package/dist/logs/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import http from 'http';
|
|
2
2
|
import type { Logger } from 'pino';
|
|
3
|
-
declare const createHttpServer: (logger: Logger) =>
|
|
3
|
+
declare const createHttpServer: (logger: Logger) => http.Server;
|
|
4
4
|
export { createHttpServer };
|
package/dist/logs/http.js
CHANGED
|
@@ -2,19 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createHttpServer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fastify_1 = tslib_1.__importDefault(require("fastify"));
|
|
6
5
|
const http_1 = tslib_1.__importDefault(require("http"));
|
|
7
6
|
const parse_1 = require("./parse");
|
|
8
7
|
const debug = require('debug')('logs:http');
|
|
9
|
-
const createHttpServer = (logger) => {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const createHttpServer = (logger) => http_1.default.createServer((request, response) => {
|
|
9
|
+
if (request.method !== 'POST' || request.url !== '/logs') {
|
|
10
|
+
response.writeHead(404).end();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
debug('received "log" request');
|
|
14
|
+
const chunks = [];
|
|
15
|
+
request.on('data', (chunk) => chunks.push(chunk));
|
|
16
|
+
request.on('end', () => {
|
|
17
|
+
response.writeHead(204).end();
|
|
18
|
+
try {
|
|
19
|
+
(0, parse_1.parseLogEvent)(logger, JSON.parse(Buffer.concat(chunks).toString('utf8')));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
debug('failed to parse log event', error);
|
|
23
|
+
}
|
|
12
24
|
});
|
|
13
|
-
|
|
14
|
-
debug('
|
|
15
|
-
|
|
16
|
-
(0, parse_1.parseLogEvent)(logger, request.body);
|
|
25
|
+
request.on('error', (error) => {
|
|
26
|
+
debug('request error', error);
|
|
27
|
+
response.writeHead(400).end();
|
|
17
28
|
});
|
|
18
|
-
|
|
19
|
-
};
|
|
29
|
+
});
|
|
20
30
|
exports.createHttpServer = createHttpServer;
|
package/dist/logs/server.js
CHANGED
|
@@ -40,11 +40,13 @@ const createLogServer = async (_port) => {
|
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
42
|
debug('creating http server');
|
|
43
|
-
const
|
|
43
|
+
const server = (0, http_1.createHttpServer)(logger);
|
|
44
44
|
debug('creating socket server');
|
|
45
|
-
(0, socket_1.createSocketServer)(
|
|
45
|
+
(0, socket_1.createSocketServer)(server, logger);
|
|
46
46
|
debug(`server listening on port ${port}`);
|
|
47
|
-
await
|
|
47
|
+
await new Promise((resolve) => {
|
|
48
|
+
server.listen(port, resolve);
|
|
49
|
+
});
|
|
48
50
|
core_1.ux.action.stop(`✅\tListening at http://localhost:${port}`);
|
|
49
51
|
core_1.ux.action.start('Creating tunnel');
|
|
50
52
|
const url = await runTunnel(port);
|
package/dist/proxies/utils.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare const PROXY_FLAGS: {
|
|
|
20
20
|
'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
21
|
'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
22
22
|
'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
23
|
-
|
|
23
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
24
24
|
};
|
|
25
25
|
interface ProxyFlagProps {
|
|
26
26
|
/**
|
package/dist/proxies/utils.js
CHANGED
|
@@ -44,8 +44,8 @@ const PROXY_FLAGS = {
|
|
|
44
44
|
description: 'path to runtime package.json JSON file (top-level dependencies required; supports resolutions or overrides fallback; pinned versions required) (node22 only)',
|
|
45
45
|
}),
|
|
46
46
|
'request-transform-timeout': core_1.Flags.integer({
|
|
47
|
-
description: 'request-transform timeout in seconds,
|
|
48
|
-
min:
|
|
47
|
+
description: 'request-transform timeout in seconds, 10-30 (node22 only)',
|
|
48
|
+
min: 10,
|
|
49
49
|
max: 30,
|
|
50
50
|
}),
|
|
51
51
|
'request-transform-warm-concurrency': core_1.Flags.integer({
|
|
@@ -69,8 +69,8 @@ const PROXY_FLAGS = {
|
|
|
69
69
|
description: 'path to runtime package.json JSON file (top-level dependencies required; supports resolutions or overrides fallback; pinned versions required) (node22 only)',
|
|
70
70
|
}),
|
|
71
71
|
'response-transform-timeout': core_1.Flags.integer({
|
|
72
|
-
description: 'response-transform timeout in seconds,
|
|
73
|
-
min:
|
|
72
|
+
description: 'response-transform timeout in seconds, 10-30 (node22 only)',
|
|
73
|
+
min: 10,
|
|
74
74
|
max: 30,
|
|
75
75
|
}),
|
|
76
76
|
'response-transform-warm-concurrency': core_1.Flags.integer({
|
|
@@ -86,7 +86,7 @@ const PROXY_FLAGS = {
|
|
|
86
86
|
description: 'response-transform permission to grant, repeatable (node22 only)',
|
|
87
87
|
multiple: true,
|
|
88
88
|
}),
|
|
89
|
-
|
|
89
|
+
'no-wait': core_1.Flags.boolean({
|
|
90
90
|
description: 'do not wait for proxy to be ready (requires at least one transform with node22)',
|
|
91
91
|
default: false,
|
|
92
92
|
}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare const hasReactorRuntimeFlags: (flags: Record<string, unknown>) => boolean;
|
|
1
2
|
declare const validateReactorRuntimeFlags: (flags: Record<string, unknown>, image: string | undefined) => void;
|
|
2
3
|
declare const validateReactorApplicationId: (applicationId: string | undefined, image: string | undefined) => void;
|
|
3
|
-
export { validateReactorRuntimeFlags, validateReactorApplicationId };
|
|
4
|
+
export { hasReactorRuntimeFlags, validateReactorRuntimeFlags, validateReactorApplicationId, };
|
package/dist/reactors/runtime.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateReactorApplicationId = exports.validateReactorRuntimeFlags = void 0;
|
|
3
|
+
exports.validateReactorApplicationId = exports.validateReactorRuntimeFlags = exports.hasReactorRuntimeFlags = void 0;
|
|
4
4
|
const runtime_1 = require("../runtime");
|
|
5
|
+
const hasReactorRuntimeFlags = (flags) => runtime_1.REACTOR_CONFIGURABLE_RUNTIME_FLAGS.some((flag) => {
|
|
6
|
+
const value = flags[flag];
|
|
7
|
+
return value !== undefined && !(Array.isArray(value) && value.length === 0);
|
|
8
|
+
});
|
|
9
|
+
exports.hasReactorRuntimeFlags = hasReactorRuntimeFlags;
|
|
5
10
|
const validateReactorRuntimeFlags = (flags, image) => {
|
|
6
11
|
const setFlags = [];
|
|
7
|
-
for (const flag of runtime_1.
|
|
12
|
+
for (const flag of runtime_1.REACTOR_CONFIGURABLE_RUNTIME_FLAGS) {
|
|
8
13
|
const value = flags[flag];
|
|
9
|
-
const isSet = value !== undefined &&
|
|
10
|
-
value !== false &&
|
|
11
|
-
!(Array.isArray(value) && value.length === 0);
|
|
14
|
+
const isSet = value !== undefined && !(Array.isArray(value) && value.length === 0);
|
|
12
15
|
if (isSet) {
|
|
13
16
|
setFlags.push(flag);
|
|
14
17
|
}
|
package/dist/reactors/utils.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { BasisTheory } from '@basis-theory/node-sdk';
|
|
2
2
|
declare const REACTOR_FLAGS: {
|
|
3
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
3
4
|
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
4
5
|
'package-json': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
5
6
|
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
-
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>; /**
|
|
9
|
+
* Path to code file
|
|
10
|
+
*/
|
|
8
11
|
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
-
|
|
12
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
10
13
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
14
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
15
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -28,7 +31,7 @@ interface ReactorFlagProps {
|
|
|
28
31
|
/**
|
|
29
32
|
* Runtime configuration
|
|
30
33
|
*/
|
|
31
|
-
runtime?: BasisTheory.
|
|
34
|
+
runtime?: BasisTheory.ReactorRuntime;
|
|
32
35
|
}
|
|
33
36
|
type CreateReactor = ReactorFlagProps & Omit<BasisTheory.CreateReactorRequest, 'application' | 'configuration' | 'runtime'>;
|
|
34
37
|
type PatchReactor = ReactorFlagProps & Omit<BasisTheory.PatchReactorRequest, 'application' | 'configuration' | 'runtime'>;
|
package/dist/reactors/utils.js
CHANGED
|
@@ -23,6 +23,10 @@ const REACTOR_FLAGS = {
|
|
|
23
23
|
description: 'path to JavaScript file containing the Reactor code',
|
|
24
24
|
}),
|
|
25
25
|
...runtime_1.RUNTIME_FLAGS,
|
|
26
|
+
async: core_1.Flags.boolean({
|
|
27
|
+
description: 'execute Reactor invocations asynchronously (node22 only)',
|
|
28
|
+
allowNo: true,
|
|
29
|
+
}),
|
|
26
30
|
};
|
|
27
31
|
exports.REACTOR_FLAGS = REACTOR_FLAGS;
|
|
28
32
|
// eslint-disable-next-line get-off-my-lawn/prefer-arrow-functions
|
package/dist/runtime/flags.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ declare const RUNTIME_FLAGS: {
|
|
|
5
5
|
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
6
|
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
7
|
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
-
|
|
8
|
+
'no-wait': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
9
9
|
};
|
|
10
10
|
export { RUNTIME_FLAGS };
|
package/dist/runtime/flags.js
CHANGED
|
@@ -12,9 +12,9 @@ const RUNTIME_FLAGS = {
|
|
|
12
12
|
description: 'path to runtime package.json JSON file (top-level dependencies required; supports resolutions or overrides fallback; pinned versions required) (node22 only)',
|
|
13
13
|
}),
|
|
14
14
|
timeout: core_1.Flags.integer({
|
|
15
|
-
description: 'timeout in seconds,
|
|
16
|
-
min:
|
|
17
|
-
max:
|
|
15
|
+
description: 'timeout in seconds, 10-900 (node22 only; maximum 30 when runtime async is disabled; default: 10)',
|
|
16
|
+
min: 10,
|
|
17
|
+
max: 900,
|
|
18
18
|
}),
|
|
19
19
|
'warm-concurrency': core_1.Flags.integer({
|
|
20
20
|
description: 'number of warm instances, 0-1 (node22 only, default: 0)',
|
|
@@ -29,8 +29,8 @@ const RUNTIME_FLAGS = {
|
|
|
29
29
|
description: 'permission to grant, repeatable (node22 only)',
|
|
30
30
|
multiple: true,
|
|
31
31
|
}),
|
|
32
|
-
|
|
33
|
-
description: 'do not wait for resource to
|
|
32
|
+
'no-wait': core_1.Flags.boolean({
|
|
33
|
+
description: 'do not wait for resource provisioning to complete',
|
|
34
34
|
default: false,
|
|
35
35
|
}),
|
|
36
36
|
};
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { LEGACY_RUNTIME_IMAGE, CONFIGURABLE_RUNTIME_IMAGES, VALID_RUNTIME_IMAGES, CONFIGURABLE_RUNTIME_FLAGS, isLegacyRuntimeImage, validateRuntimeImage, parseRuntimePackageJsonFile, buildRuntime, promptRuntimeOptions, promptRuntimeImage, type ConfigurableRuntimeOptions, type RuntimeFlagProps, type RuntimeFlags, } from './utils';
|
|
1
|
+
export { LEGACY_RUNTIME_IMAGE, CONFIGURABLE_RUNTIME_IMAGES, VALID_RUNTIME_IMAGES, CONFIGURABLE_RUNTIME_FLAGS, REACTOR_CONFIGURABLE_RUNTIME_FLAGS, isLegacyRuntimeImage, validateRuntimeImage, parseRuntimePackageJsonFile, buildRuntime, buildReactorRuntime, getMaxRuntimeTimeout, validateRuntimeTimeout, promptRuntimeOptions, promptRuntimeImage, type ConfigurableRuntimeOptions, type RuntimeFlagProps, type RuntimeFlags, } from './utils';
|
|
2
2
|
export { RUNTIME_FLAGS } from './flags';
|
|
3
3
|
export { waitForResourceState, needsPolling, POLL_INTERVAL, POLL_TIMEOUT, } from './state';
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.POLL_TIMEOUT = exports.POLL_INTERVAL = exports.needsPolling = exports.waitForResourceState = exports.RUNTIME_FLAGS = exports.promptRuntimeImage = exports.promptRuntimeOptions = exports.buildRuntime = exports.parseRuntimePackageJsonFile = exports.validateRuntimeImage = exports.isLegacyRuntimeImage = exports.CONFIGURABLE_RUNTIME_FLAGS = exports.VALID_RUNTIME_IMAGES = exports.CONFIGURABLE_RUNTIME_IMAGES = exports.LEGACY_RUNTIME_IMAGE = void 0;
|
|
3
|
+
exports.POLL_TIMEOUT = exports.POLL_INTERVAL = exports.needsPolling = exports.waitForResourceState = exports.RUNTIME_FLAGS = exports.promptRuntimeImage = exports.promptRuntimeOptions = exports.validateRuntimeTimeout = exports.getMaxRuntimeTimeout = exports.buildReactorRuntime = exports.buildRuntime = exports.parseRuntimePackageJsonFile = exports.validateRuntimeImage = exports.isLegacyRuntimeImage = exports.REACTOR_CONFIGURABLE_RUNTIME_FLAGS = exports.CONFIGURABLE_RUNTIME_FLAGS = exports.VALID_RUNTIME_IMAGES = exports.CONFIGURABLE_RUNTIME_IMAGES = exports.LEGACY_RUNTIME_IMAGE = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
Object.defineProperty(exports, "LEGACY_RUNTIME_IMAGE", { enumerable: true, get: function () { return utils_1.LEGACY_RUNTIME_IMAGE; } });
|
|
6
6
|
Object.defineProperty(exports, "CONFIGURABLE_RUNTIME_IMAGES", { enumerable: true, get: function () { return utils_1.CONFIGURABLE_RUNTIME_IMAGES; } });
|
|
7
7
|
Object.defineProperty(exports, "VALID_RUNTIME_IMAGES", { enumerable: true, get: function () { return utils_1.VALID_RUNTIME_IMAGES; } });
|
|
8
8
|
Object.defineProperty(exports, "CONFIGURABLE_RUNTIME_FLAGS", { enumerable: true, get: function () { return utils_1.CONFIGURABLE_RUNTIME_FLAGS; } });
|
|
9
|
+
Object.defineProperty(exports, "REACTOR_CONFIGURABLE_RUNTIME_FLAGS", { enumerable: true, get: function () { return utils_1.REACTOR_CONFIGURABLE_RUNTIME_FLAGS; } });
|
|
9
10
|
Object.defineProperty(exports, "isLegacyRuntimeImage", { enumerable: true, get: function () { return utils_1.isLegacyRuntimeImage; } });
|
|
10
11
|
Object.defineProperty(exports, "validateRuntimeImage", { enumerable: true, get: function () { return utils_1.validateRuntimeImage; } });
|
|
11
12
|
Object.defineProperty(exports, "parseRuntimePackageJsonFile", { enumerable: true, get: function () { return utils_1.parseRuntimePackageJsonFile; } });
|
|
12
13
|
Object.defineProperty(exports, "buildRuntime", { enumerable: true, get: function () { return utils_1.buildRuntime; } });
|
|
14
|
+
Object.defineProperty(exports, "buildReactorRuntime", { enumerable: true, get: function () { return utils_1.buildReactorRuntime; } });
|
|
15
|
+
Object.defineProperty(exports, "getMaxRuntimeTimeout", { enumerable: true, get: function () { return utils_1.getMaxRuntimeTimeout; } });
|
|
16
|
+
Object.defineProperty(exports, "validateRuntimeTimeout", { enumerable: true, get: function () { return utils_1.validateRuntimeTimeout; } });
|
|
13
17
|
Object.defineProperty(exports, "promptRuntimeOptions", { enumerable: true, get: function () { return utils_1.promptRuntimeOptions; } });
|
|
14
18
|
Object.defineProperty(exports, "promptRuntimeImage", { enumerable: true, get: function () { return utils_1.promptRuntimeImage; } });
|
|
15
19
|
var flags_1 = require("./flags");
|
package/dist/runtime/state.js
CHANGED
|
@@ -64,9 +64,11 @@ const waitForResourceState = async (bt, resourceType, id, initialState) => {
|
|
|
64
64
|
}
|
|
65
65
|
const deadline = Date.now() + POLL_TIMEOUT;
|
|
66
66
|
const startTime = Date.now();
|
|
67
|
-
let currentState;
|
|
67
|
+
let currentState = initialState;
|
|
68
68
|
const timer = createTimer(startTime, () => currentState);
|
|
69
|
-
core_1.ux.action.start('Status'
|
|
69
|
+
core_1.ux.action.start('Status', currentState
|
|
70
|
+
? `${currentState} (${formatElapsedTime(startTime)})`
|
|
71
|
+
: undefined);
|
|
70
72
|
/* eslint-disable no-await-in-loop */
|
|
71
73
|
try {
|
|
72
74
|
while (Date.now() < deadline) {
|
|
@@ -83,11 +85,11 @@ const waitForResourceState = async (bt, resourceType, id, initialState) => {
|
|
|
83
85
|
currentState = resource.state;
|
|
84
86
|
core_1.ux.action.status = `${currentState} (${formatElapsedTime(startTime)})`;
|
|
85
87
|
if (currentState === 'active') {
|
|
86
|
-
core_1.ux.action.stop(`ready (${formatElapsedTime(startTime)})
|
|
88
|
+
core_1.ux.action.stop(`ready (${formatElapsedTime(startTime)}) ✅`);
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
91
|
if (currentState === 'failed' || currentState === 'outdated') {
|
|
90
|
-
core_1.ux.action.stop(`failed (${formatElapsedTime(startTime)})
|
|
92
|
+
core_1.ux.action.stop(`failed (${formatElapsedTime(startTime)}) ❌`);
|
|
91
93
|
throw new Error(formatErrorMessage(resource, resourceType));
|
|
92
94
|
}
|
|
93
95
|
await new Promise((resolve) => {
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare const VALID_RUNTIME_IMAGES: readonly ["node-bt", "node22"];
|
|
|
5
5
|
declare const isLegacyRuntimeImage: (image: string | undefined) => boolean;
|
|
6
6
|
declare const validateRuntimeImage: (image: string | undefined) => void;
|
|
7
7
|
declare const CONFIGURABLE_RUNTIME_FLAGS: readonly ["timeout", "resources", "warm-concurrency", "permissions", "package-json"];
|
|
8
|
+
declare const REACTOR_CONFIGURABLE_RUNTIME_FLAGS: readonly ["timeout", "resources", "warm-concurrency", "permissions", "package-json", "async"];
|
|
8
9
|
interface RuntimeFlagProps {
|
|
9
10
|
image?: string;
|
|
10
11
|
packageJson?: string;
|
|
@@ -13,6 +14,9 @@ interface RuntimeFlagProps {
|
|
|
13
14
|
resources?: string;
|
|
14
15
|
permissions?: string[];
|
|
15
16
|
}
|
|
17
|
+
interface ReactorRuntimeFlagProps extends RuntimeFlagProps {
|
|
18
|
+
async?: boolean;
|
|
19
|
+
}
|
|
16
20
|
interface RuntimeFlags {
|
|
17
21
|
image?: string;
|
|
18
22
|
timeout?: number;
|
|
@@ -34,6 +38,9 @@ interface ParsedRuntimePackageFile {
|
|
|
34
38
|
}
|
|
35
39
|
declare const parseRuntimePackageJsonFile: (packageJsonPath: string) => ParsedRuntimePackageFile;
|
|
36
40
|
declare const buildRuntime: (props: RuntimeFlagProps) => BasisTheory.Runtime | undefined;
|
|
37
|
-
declare const
|
|
41
|
+
declare const buildReactorRuntime: (props: ReactorRuntimeFlagProps) => BasisTheory.ReactorRuntime | undefined;
|
|
42
|
+
declare const getMaxRuntimeTimeout: (runtimeAsync: boolean) => number;
|
|
43
|
+
declare const validateRuntimeTimeout: (timeout: number | undefined, runtimeAsync: boolean) => void;
|
|
44
|
+
declare const promptRuntimeOptions: (flags: RuntimeFlags, labelPrefix?: string, timeoutMax?: number) => Promise<ConfigurableRuntimeOptions>;
|
|
38
45
|
declare const promptRuntimeImage: (image: string | undefined, message?: string) => Promise<string>;
|
|
39
|
-
export { LEGACY_RUNTIME_IMAGE, CONFIGURABLE_RUNTIME_IMAGES, VALID_RUNTIME_IMAGES, CONFIGURABLE_RUNTIME_FLAGS, isLegacyRuntimeImage, validateRuntimeImage, parseRuntimePackageJsonFile, buildRuntime, promptRuntimeOptions, promptRuntimeImage, type RuntimeFlagProps, type RuntimeFlags, type ConfigurableRuntimeOptions, };
|
|
46
|
+
export { LEGACY_RUNTIME_IMAGE, CONFIGURABLE_RUNTIME_IMAGES, VALID_RUNTIME_IMAGES, CONFIGURABLE_RUNTIME_FLAGS, REACTOR_CONFIGURABLE_RUNTIME_FLAGS, isLegacyRuntimeImage, validateRuntimeImage, parseRuntimePackageJsonFile, buildRuntime, buildReactorRuntime, getMaxRuntimeTimeout, validateRuntimeTimeout, promptRuntimeOptions, promptRuntimeImage, type RuntimeFlagProps, type RuntimeFlags, type ConfigurableRuntimeOptions, };
|
package/dist/runtime/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promptRuntimeImage = exports.promptRuntimeOptions = exports.buildRuntime = exports.parseRuntimePackageJsonFile = exports.validateRuntimeImage = exports.isLegacyRuntimeImage = exports.CONFIGURABLE_RUNTIME_FLAGS = exports.VALID_RUNTIME_IMAGES = exports.CONFIGURABLE_RUNTIME_IMAGES = exports.LEGACY_RUNTIME_IMAGE = void 0;
|
|
3
|
+
exports.promptRuntimeImage = exports.promptRuntimeOptions = exports.validateRuntimeTimeout = exports.getMaxRuntimeTimeout = exports.buildReactorRuntime = exports.buildRuntime = exports.parseRuntimePackageJsonFile = exports.validateRuntimeImage = exports.isLegacyRuntimeImage = exports.REACTOR_CONFIGURABLE_RUNTIME_FLAGS = exports.CONFIGURABLE_RUNTIME_FLAGS = exports.VALID_RUNTIME_IMAGES = exports.CONFIGURABLE_RUNTIME_IMAGES = exports.LEGACY_RUNTIME_IMAGE = void 0;
|
|
4
4
|
const files_1 = require("../files");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const LEGACY_RUNTIME_IMAGE = 'node-bt';
|
|
@@ -12,6 +12,9 @@ const VALID_RUNTIME_IMAGES = [
|
|
|
12
12
|
...CONFIGURABLE_RUNTIME_IMAGES,
|
|
13
13
|
];
|
|
14
14
|
exports.VALID_RUNTIME_IMAGES = VALID_RUNTIME_IMAGES;
|
|
15
|
+
const MIN_RUNTIME_TIMEOUT = 10;
|
|
16
|
+
const MAX_SYNC_RUNTIME_TIMEOUT = 30;
|
|
17
|
+
const MAX_ASYNC_RUNTIME_TIMEOUT = 900;
|
|
15
18
|
const isLegacyRuntimeImage = (image) => image === undefined || image === LEGACY_RUNTIME_IMAGE;
|
|
16
19
|
exports.isLegacyRuntimeImage = isLegacyRuntimeImage;
|
|
17
20
|
const validateRuntimeImage = (image) => {
|
|
@@ -31,6 +34,11 @@ const CONFIGURABLE_RUNTIME_FLAGS = [
|
|
|
31
34
|
'package-json',
|
|
32
35
|
];
|
|
33
36
|
exports.CONFIGURABLE_RUNTIME_FLAGS = CONFIGURABLE_RUNTIME_FLAGS;
|
|
37
|
+
const REACTOR_CONFIGURABLE_RUNTIME_FLAGS = [
|
|
38
|
+
...CONFIGURABLE_RUNTIME_FLAGS,
|
|
39
|
+
'async',
|
|
40
|
+
];
|
|
41
|
+
exports.REACTOR_CONFIGURABLE_RUNTIME_FLAGS = REACTOR_CONFIGURABLE_RUNTIME_FLAGS;
|
|
34
42
|
const isStringRecord = (value) => typeof value === 'object' &&
|
|
35
43
|
Boolean(value) &&
|
|
36
44
|
!Array.isArray(value) &&
|
|
@@ -77,7 +85,7 @@ const buildRuntime = (props) => {
|
|
|
77
85
|
if (!image &&
|
|
78
86
|
!packageJson &&
|
|
79
87
|
!timeout &&
|
|
80
|
-
|
|
88
|
+
warmConcurrency === undefined &&
|
|
81
89
|
!resources &&
|
|
82
90
|
!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
83
91
|
return undefined;
|
|
@@ -111,12 +119,36 @@ const buildRuntime = (props) => {
|
|
|
111
119
|
return runtime;
|
|
112
120
|
};
|
|
113
121
|
exports.buildRuntime = buildRuntime;
|
|
114
|
-
const
|
|
122
|
+
const buildReactorRuntime = (props) => {
|
|
123
|
+
const { async: runtimeAsync, ...runtimeProps } = props;
|
|
124
|
+
const runtime = buildRuntime(runtimeProps);
|
|
125
|
+
if (!runtime && runtimeAsync === undefined) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
...runtime,
|
|
130
|
+
...(runtimeAsync !== undefined ? { async: runtimeAsync } : {}),
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
exports.buildReactorRuntime = buildReactorRuntime;
|
|
134
|
+
const getMaxRuntimeTimeout = (runtimeAsync) => runtimeAsync ? MAX_ASYNC_RUNTIME_TIMEOUT : MAX_SYNC_RUNTIME_TIMEOUT;
|
|
135
|
+
exports.getMaxRuntimeTimeout = getMaxRuntimeTimeout;
|
|
136
|
+
const validateRuntimeTimeout = (timeout, runtimeAsync) => {
|
|
137
|
+
if (timeout === undefined) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const max = getMaxRuntimeTimeout(runtimeAsync);
|
|
141
|
+
if (timeout < MIN_RUNTIME_TIMEOUT || timeout > max) {
|
|
142
|
+
throw new Error(`Runtime timeout must be between ${MIN_RUNTIME_TIMEOUT} and ${max} seconds when runtime async is ${runtimeAsync ? 'enabled' : 'disabled'}.`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
exports.validateRuntimeTimeout = validateRuntimeTimeout;
|
|
146
|
+
const promptRuntimeOptions = async (flags, labelPrefix, timeoutMax = MAX_SYNC_RUNTIME_TIMEOUT) => {
|
|
115
147
|
const prefix = labelPrefix ? `${labelPrefix}: ` : '';
|
|
116
148
|
const timeout = await (0, utils_1.promptIntegerIfUndefined)(flags.timeout, {
|
|
117
|
-
message: `${prefix}Timeout in seconds (
|
|
118
|
-
min:
|
|
119
|
-
max:
|
|
149
|
+
message: `${prefix}Timeout in seconds (${MIN_RUNTIME_TIMEOUT}-${timeoutMax}, press Enter for default: 10):`,
|
|
150
|
+
min: MIN_RUNTIME_TIMEOUT,
|
|
151
|
+
max: timeoutMax,
|
|
120
152
|
});
|
|
121
153
|
const warmConcurrency = await (0, utils_1.promptIntegerIfUndefined)(flags['warm-concurrency'], {
|
|
122
154
|
message: `${prefix}Warm concurrency (0-1, press Enter for default: 0):`,
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "4.1.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"applications:create": {
|
|
5
5
|
"id": "applications:create",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"request-transform-timeout": {
|
|
306
306
|
"name": "request-transform-timeout",
|
|
307
307
|
"type": "option",
|
|
308
|
-
"description": "request-transform timeout in seconds,
|
|
308
|
+
"description": "request-transform timeout in seconds, 10-30 (node22 only)",
|
|
309
309
|
"multiple": false
|
|
310
310
|
},
|
|
311
311
|
"request-transform-warm-concurrency": {
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
"response-transform-timeout": {
|
|
351
351
|
"name": "response-transform-timeout",
|
|
352
352
|
"type": "option",
|
|
353
|
-
"description": "response-transform timeout in seconds,
|
|
353
|
+
"description": "response-transform timeout in seconds, 10-30 (node22 only)",
|
|
354
354
|
"multiple": false
|
|
355
355
|
},
|
|
356
356
|
"response-transform-warm-concurrency": {
|
|
@@ -376,8 +376,8 @@
|
|
|
376
376
|
"description": "response-transform permission to grant, repeatable (node22 only)",
|
|
377
377
|
"multiple": true
|
|
378
378
|
},
|
|
379
|
-
"
|
|
380
|
-
"name": "
|
|
379
|
+
"no-wait": {
|
|
380
|
+
"name": "no-wait",
|
|
381
381
|
"type": "boolean",
|
|
382
382
|
"description": "do not wait for proxy to be ready (requires at least one transform with node22)",
|
|
383
383
|
"allowNo": false
|
|
@@ -621,7 +621,7 @@
|
|
|
621
621
|
"request-transform-timeout": {
|
|
622
622
|
"name": "request-transform-timeout",
|
|
623
623
|
"type": "option",
|
|
624
|
-
"description": "request-transform timeout in seconds,
|
|
624
|
+
"description": "request-transform timeout in seconds, 10-30 (node22 only)",
|
|
625
625
|
"multiple": false
|
|
626
626
|
},
|
|
627
627
|
"request-transform-warm-concurrency": {
|
|
@@ -666,7 +666,7 @@
|
|
|
666
666
|
"response-transform-timeout": {
|
|
667
667
|
"name": "response-transform-timeout",
|
|
668
668
|
"type": "option",
|
|
669
|
-
"description": "response-transform timeout in seconds,
|
|
669
|
+
"description": "response-transform timeout in seconds, 10-30 (node22 only)",
|
|
670
670
|
"multiple": false
|
|
671
671
|
},
|
|
672
672
|
"response-transform-warm-concurrency": {
|
|
@@ -692,8 +692,8 @@
|
|
|
692
692
|
"description": "response-transform permission to grant, repeatable (node22 only)",
|
|
693
693
|
"multiple": true
|
|
694
694
|
},
|
|
695
|
-
"
|
|
696
|
-
"name": "
|
|
695
|
+
"no-wait": {
|
|
696
|
+
"name": "no-wait",
|
|
697
697
|
"type": "boolean",
|
|
698
698
|
"description": "do not wait for proxy to be ready (requires at least one transform with node22)",
|
|
699
699
|
"allowNo": false
|
|
@@ -742,7 +742,7 @@
|
|
|
742
742
|
},
|
|
743
743
|
{
|
|
744
744
|
"description": "Create a reactor with node22 and all runtime options",
|
|
745
|
-
"command": "<%= config.bin %> <%= command.id %> --name \"My Reactor\" --code ./reactor.js --configuration ./config.env --image node22 --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions token:read --permissions token:create"
|
|
745
|
+
"command": "<%= config.bin %> <%= command.id %> --name \"My Reactor\" --code ./reactor.js --configuration ./config.env --image node22 --async --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions token:read --permissions token:create"
|
|
746
746
|
}
|
|
747
747
|
],
|
|
748
748
|
"flags": {
|
|
@@ -808,7 +808,7 @@
|
|
|
808
808
|
"timeout": {
|
|
809
809
|
"name": "timeout",
|
|
810
810
|
"type": "option",
|
|
811
|
-
"description": "timeout in seconds,
|
|
811
|
+
"description": "timeout in seconds, 10-900 (node22 only; maximum 30 when runtime async is disabled; default: 10)",
|
|
812
812
|
"multiple": false
|
|
813
813
|
},
|
|
814
814
|
"warm-concurrency": {
|
|
@@ -834,11 +834,17 @@
|
|
|
834
834
|
"description": "permission to grant, repeatable (node22 only)",
|
|
835
835
|
"multiple": true
|
|
836
836
|
},
|
|
837
|
+
"no-wait": {
|
|
838
|
+
"name": "no-wait",
|
|
839
|
+
"type": "boolean",
|
|
840
|
+
"description": "do not wait for resource provisioning to complete",
|
|
841
|
+
"allowNo": false
|
|
842
|
+
},
|
|
837
843
|
"async": {
|
|
838
844
|
"name": "async",
|
|
839
845
|
"type": "boolean",
|
|
840
|
-
"description": "
|
|
841
|
-
"allowNo":
|
|
846
|
+
"description": "execute Reactor invocations asynchronously (node22 only)",
|
|
847
|
+
"allowNo": true
|
|
842
848
|
}
|
|
843
849
|
},
|
|
844
850
|
"args": {}
|
|
@@ -986,9 +992,13 @@
|
|
|
986
992
|
"description": "Update a reactor with node22 runtime",
|
|
987
993
|
"command": "<%= config.bin %> <%= command.id %> <reactor-id> --code ./reactor.js --image node22"
|
|
988
994
|
},
|
|
995
|
+
{
|
|
996
|
+
"description": "Watch a node22 reactor for code, configuration, and dependency changes",
|
|
997
|
+
"command": "<%= config.bin %> <%= command.id %> <reactor-id> --code ./reactor.js --configuration ./config.env --package-json ./package.json --image node22 --watch"
|
|
998
|
+
},
|
|
989
999
|
{
|
|
990
1000
|
"description": "Update a reactor with node22 and all runtime options",
|
|
991
|
-
"command": "<%= config.bin %> <%= command.id %> <reactor-id> --name \"My Reactor\" --code ./reactor.js --configuration ./config.env --image node22 --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions token:read --permissions token:create"
|
|
1001
|
+
"command": "<%= config.bin %> <%= command.id %> <reactor-id> --name \"My Reactor\" --code ./reactor.js --configuration ./config.env --image node22 --async --timeout 10 --warm-concurrency 0 --resources standard --package-json ./package.json --permissions token:read --permissions token:create"
|
|
992
1002
|
}
|
|
993
1003
|
],
|
|
994
1004
|
"flags": {
|
|
@@ -1054,7 +1064,7 @@
|
|
|
1054
1064
|
"timeout": {
|
|
1055
1065
|
"name": "timeout",
|
|
1056
1066
|
"type": "option",
|
|
1057
|
-
"description": "timeout in seconds,
|
|
1067
|
+
"description": "timeout in seconds, 10-900 (node22 only; maximum 30 when runtime async is disabled; default: 10)",
|
|
1058
1068
|
"multiple": false
|
|
1059
1069
|
},
|
|
1060
1070
|
"warm-concurrency": {
|
|
@@ -1080,17 +1090,23 @@
|
|
|
1080
1090
|
"description": "permission to grant, repeatable (node22 only)",
|
|
1081
1091
|
"multiple": true
|
|
1082
1092
|
},
|
|
1093
|
+
"no-wait": {
|
|
1094
|
+
"name": "no-wait",
|
|
1095
|
+
"type": "boolean",
|
|
1096
|
+
"description": "do not wait for resource provisioning to complete",
|
|
1097
|
+
"allowNo": false
|
|
1098
|
+
},
|
|
1083
1099
|
"async": {
|
|
1084
1100
|
"name": "async",
|
|
1085
1101
|
"type": "boolean",
|
|
1086
|
-
"description": "
|
|
1087
|
-
"allowNo":
|
|
1102
|
+
"description": "execute Reactor invocations asynchronously (node22 only)",
|
|
1103
|
+
"allowNo": true
|
|
1088
1104
|
},
|
|
1089
1105
|
"watch": {
|
|
1090
1106
|
"name": "watch",
|
|
1091
1107
|
"type": "boolean",
|
|
1092
1108
|
"char": "w",
|
|
1093
|
-
"description": "Watch for changes in
|
|
1109
|
+
"description": "Watch for changes in supplied code, configuration, and runtime package files",
|
|
1094
1110
|
"required": false,
|
|
1095
1111
|
"allowNo": false
|
|
1096
1112
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory-labs/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Basis Theory CLI tool",
|
|
5
5
|
"author": "Davi Aquino @djejaquino",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"/oclif.manifest.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@basis-theory/node-sdk": "^
|
|
20
|
+
"@basis-theory/node-sdk": "^6.1.1",
|
|
21
21
|
"@inquirer/checkbox": "^1.5.0",
|
|
22
22
|
"@inquirer/confirm": "^2.0.15",
|
|
23
23
|
"@inquirer/input": "^1.2.14",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"debug": "^4.3.4",
|
|
30
30
|
"detect-port": "^1.5.1",
|
|
31
31
|
"dotenv": "^16.3.1",
|
|
32
|
-
"fastify": "^4.19.2",
|
|
33
32
|
"lodash.debounce": "^4.0.8",
|
|
34
33
|
"lodash.groupby": "^4.6.0",
|
|
35
34
|
"pino": "^8.14.1",
|
|
@@ -41,18 +40,18 @@
|
|
|
41
40
|
"@basis-theory/eslint-config": "^1.2.0",
|
|
42
41
|
"@oclif/test": "^2.3.22",
|
|
43
42
|
"@semantic-release/changelog": "^6.0.3",
|
|
44
|
-
"@semantic-release/commit-analyzer": "^
|
|
43
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
45
44
|
"@semantic-release/git": "^10.0.1",
|
|
46
|
-
"@semantic-release/github": "^
|
|
47
|
-
"@semantic-release/npm": "^
|
|
48
|
-
"@semantic-release/release-notes-generator": "^
|
|
45
|
+
"@semantic-release/github": "^12.0.0",
|
|
46
|
+
"@semantic-release/npm": "^13.1.5",
|
|
47
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
49
48
|
"@types/chai": "^4",
|
|
50
49
|
"@types/debug": "^4.1.8",
|
|
51
50
|
"@types/detect-port": "^1.3.3",
|
|
52
51
|
"@types/lodash.debounce": "^4.0.7",
|
|
53
52
|
"@types/lodash.groupby": "^4.6.9",
|
|
54
53
|
"@types/mocha": "^9.0.0",
|
|
55
|
-
"@types/node": "^
|
|
54
|
+
"@types/node": "^18.19.0",
|
|
56
55
|
"@types/sinon": "^21.0.0",
|
|
57
56
|
"chai": "^4",
|
|
58
57
|
"eslint": "^7.32.0",
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"mocha": "^9.2.2",
|
|
62
61
|
"oclif": "^3",
|
|
63
62
|
"prettier": "^2.8.8",
|
|
64
|
-
"semantic-release": "^
|
|
63
|
+
"semantic-release": "^25.0.7",
|
|
65
64
|
"shx": "^0.3.3",
|
|
66
65
|
"sinon": "^21.0.1",
|
|
67
66
|
"ts-node": "^10.9.1",
|
|
@@ -93,7 +92,7 @@
|
|
|
93
92
|
"release": "semantic-release"
|
|
94
93
|
},
|
|
95
94
|
"engines": {
|
|
96
|
-
"node": ">=
|
|
95
|
+
"node": ">=18.0.0"
|
|
97
96
|
},
|
|
98
97
|
"bugs": "https://github.com/Basis-Theory-Labs/basistheory-cli/issues",
|
|
99
98
|
"keywords": [
|