@basis-theory-labs/cli 2.1.0 → 4.0.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 +52 -44
- package/dist/commands/proxies/create.d.ts +3 -3
- package/dist/commands/proxies/create.js +3 -3
- package/dist/commands/proxies/update.d.ts +3 -3
- package/dist/commands/proxies/update.js +6 -6
- package/dist/commands/reactors/create.d.ts +3 -2
- package/dist/commands/reactors/create.js +14 -6
- package/dist/commands/reactors/update.d.ts +3 -2
- package/dist/commands/reactors/update.js +20 -6
- 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/runtime.js +1 -1
- package/dist/proxies/utils.d.ts +3 -3
- package/dist/proxies/utils.js +9 -9
- package/dist/reactors/runtime.d.ts +2 -1
- package/dist/reactors/runtime.js +8 -5
- package/dist/reactors/utils.d.ts +7 -4
- package/dist/reactors/utils.js +4 -0
- package/dist/runtime/flags.d.ts +2 -2
- package/dist/runtime/flags.js +7 -7
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +6 -1
- package/dist/runtime/state.js +20 -1
- package/dist/runtime/utils.d.ts +18 -6
- package/dist/runtime/utils.js +93 -22
- package/oclif.manifest.json +49 -37
- package/package.json +9 -10
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/runtime.js
CHANGED
|
@@ -53,7 +53,7 @@ const promptTransformRuntime = async (prefix, flags, transformCode, image) => {
|
|
|
53
53
|
timeout: flags[`${prefix}-transform-timeout`],
|
|
54
54
|
'warm-concurrency': flags[`${prefix}-transform-warm-concurrency`],
|
|
55
55
|
resources: flags[`${prefix}-transform-resources`],
|
|
56
|
-
|
|
56
|
+
'package-json': flags[`${prefix}-transform-package-json`],
|
|
57
57
|
permissions: flags[`${prefix}-transform-permissions`],
|
|
58
58
|
};
|
|
59
59
|
const labelPrefix = `${prefix.charAt(0).toUpperCase()}${prefix.slice(1)} transform`;
|
package/dist/proxies/utils.d.ts
CHANGED
|
@@ -9,18 +9,18 @@ declare const PROXY_FLAGS: {
|
|
|
9
9
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
10
|
'require-auth': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
11
11
|
'request-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
-
'request-transform-
|
|
12
|
+
'request-transform-package-json': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
13
|
'request-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
14
|
'request-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
15
|
'request-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
16
|
'request-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
17
|
'response-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
|
-
'response-transform-
|
|
18
|
+
'response-transform-package-json': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
19
|
'response-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
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
|
@@ -40,12 +40,12 @@ const PROXY_FLAGS = {
|
|
|
40
40
|
description: `request-transform runtime image (${runtime_1.VALID_RUNTIME_IMAGES.join('|')})`,
|
|
41
41
|
options: [...runtime_1.VALID_RUNTIME_IMAGES],
|
|
42
42
|
}),
|
|
43
|
-
'request-transform-
|
|
44
|
-
description: 'path to JSON file
|
|
43
|
+
'request-transform-package-json': core_1.Flags.file({
|
|
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({
|
|
@@ -65,12 +65,12 @@ const PROXY_FLAGS = {
|
|
|
65
65
|
description: `response-transform runtime image (${runtime_1.VALID_RUNTIME_IMAGES.join('|')})`,
|
|
66
66
|
options: [...runtime_1.VALID_RUNTIME_IMAGES],
|
|
67
67
|
}),
|
|
68
|
-
'response-transform-
|
|
69
|
-
description: 'path to JSON file
|
|
68
|
+
'response-transform-package-json': core_1.Flags.file({
|
|
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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare const RUNTIME_FLAGS: {
|
|
2
2
|
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
3
|
-
|
|
3
|
+
'package-json': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
4
4
|
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
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
|
@@ -8,13 +8,13 @@ const RUNTIME_FLAGS = {
|
|
|
8
8
|
description: `runtime image (${utils_1.VALID_RUNTIME_IMAGES.join('|')})`,
|
|
9
9
|
options: [...utils_1.VALID_RUNTIME_IMAGES],
|
|
10
10
|
}),
|
|
11
|
-
|
|
12
|
-
description: 'path to JSON file
|
|
11
|
+
'package-json': core_1.Flags.file({
|
|
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, 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,14 +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.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; } });
|
|
12
|
+
Object.defineProperty(exports, "parseRuntimePackageJsonFile", { enumerable: true, get: function () { return utils_1.parseRuntimePackageJsonFile; } });
|
|
11
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; } });
|
|
12
17
|
Object.defineProperty(exports, "promptRuntimeOptions", { enumerable: true, get: function () { return utils_1.promptRuntimeOptions; } });
|
|
13
18
|
Object.defineProperty(exports, "promptRuntimeImage", { enumerable: true, get: function () { return utils_1.promptRuntimeImage; } });
|
|
14
19
|
var flags_1 = require("./flags");
|
package/dist/runtime/state.js
CHANGED
|
@@ -6,6 +6,25 @@ const POLL_INTERVAL = 2000; // 2 seconds
|
|
|
6
6
|
exports.POLL_INTERVAL = POLL_INTERVAL;
|
|
7
7
|
const POLL_TIMEOUT = 600000; // 10 minutes
|
|
8
8
|
exports.POLL_TIMEOUT = POLL_TIMEOUT;
|
|
9
|
+
const formatErrorDetails = (value) => {
|
|
10
|
+
if (typeof value === 'string') {
|
|
11
|
+
try {
|
|
12
|
+
return JSON.stringify(JSON.parse(value), undefined, 2);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === 'object' && Boolean(value)) {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.stringify(value, undefined, 2);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return String(value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return String(value);
|
|
27
|
+
};
|
|
9
28
|
const formatErrorMessage = (resource, resourceType) => {
|
|
10
29
|
const { state, requested } = resource;
|
|
11
30
|
const resourceName = resourceType === 'reactor' ? 'Reactor' : 'Proxy';
|
|
@@ -17,7 +36,7 @@ const formatErrorMessage = (resource, resourceType) => {
|
|
|
17
36
|
parts.push(`errorMessage: ${requested.errorMessage}`);
|
|
18
37
|
}
|
|
19
38
|
if (requested === null || requested === void 0 ? void 0 : requested.errorDetails) {
|
|
20
|
-
parts.push(`errorDetails: ${
|
|
39
|
+
parts.push(`errorDetails: ${formatErrorDetails(requested.errorDetails)}`);
|
|
21
40
|
}
|
|
22
41
|
return parts.join('\n');
|
|
23
42
|
};
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -4,31 +4,43 @@ declare const CONFIGURABLE_RUNTIME_IMAGES: readonly ["node22"];
|
|
|
4
4
|
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
|
-
declare const CONFIGURABLE_RUNTIME_FLAGS: readonly ["timeout", "resources", "warm-concurrency", "permissions", "
|
|
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;
|
|
11
12
|
timeout?: number;
|
|
12
13
|
warmConcurrency?: number;
|
|
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;
|
|
19
23
|
'warm-concurrency'?: number;
|
|
20
24
|
resources?: string;
|
|
21
|
-
|
|
25
|
+
'package-json'?: string;
|
|
22
26
|
permissions?: string[];
|
|
23
27
|
}
|
|
24
28
|
interface ConfigurableRuntimeOptions {
|
|
25
29
|
timeout?: number;
|
|
26
30
|
warmConcurrency?: number;
|
|
27
31
|
resources?: string;
|
|
28
|
-
|
|
32
|
+
packageJson?: string;
|
|
29
33
|
permissions?: string[];
|
|
30
34
|
}
|
|
35
|
+
interface ParsedRuntimePackageFile {
|
|
36
|
+
dependencies: Record<string, string>;
|
|
37
|
+
resolutions?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
declare const parseRuntimePackageJsonFile: (packageJsonPath: string) => ParsedRuntimePackageFile;
|
|
31
40
|
declare const buildRuntime: (props: RuntimeFlagProps) => BasisTheory.Runtime | undefined;
|
|
32
|
-
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>;
|
|
33
45
|
declare const promptRuntimeImage: (image: string | undefined, message?: string) => Promise<string>;
|
|
34
|
-
export { LEGACY_RUNTIME_IMAGE, CONFIGURABLE_RUNTIME_IMAGES, VALID_RUNTIME_IMAGES, CONFIGURABLE_RUNTIME_FLAGS, isLegacyRuntimeImage, validateRuntimeImage, 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.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) => {
|
|
@@ -28,34 +31,78 @@ const CONFIGURABLE_RUNTIME_FLAGS = [
|
|
|
28
31
|
'resources',
|
|
29
32
|
'warm-concurrency',
|
|
30
33
|
'permissions',
|
|
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;
|
|
42
|
+
const isStringRecord = (value) => typeof value === 'object' &&
|
|
43
|
+
Boolean(value) &&
|
|
44
|
+
!Array.isArray(value) &&
|
|
45
|
+
Object.values(value).every((item) => typeof item === 'string');
|
|
46
|
+
const parseRuntimePackageJsonFile = (packageJsonPath) => {
|
|
47
|
+
let parsedFile;
|
|
48
|
+
try {
|
|
49
|
+
parsedFile = JSON.parse((0, files_1.readFileContents)(packageJsonPath));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(`Failed to parse package.json file "${packageJsonPath}": ${error.message}`);
|
|
53
|
+
}
|
|
54
|
+
if (!parsedFile ||
|
|
55
|
+
typeof parsedFile !== 'object' ||
|
|
56
|
+
Array.isArray(parsedFile)) {
|
|
57
|
+
throw new Error(`Runtime package file "${packageJsonPath}" must include a top-level "dependencies" object.`);
|
|
58
|
+
}
|
|
59
|
+
const file = parsedFile;
|
|
60
|
+
const dependencies = file.dependencies;
|
|
61
|
+
if (!isStringRecord(dependencies)) {
|
|
62
|
+
throw new Error(`Runtime package file "${packageJsonPath}" has invalid "dependencies": expected an object of package names to pinned version strings.`);
|
|
63
|
+
}
|
|
64
|
+
let resolutions;
|
|
65
|
+
if (file.resolutions !== undefined) {
|
|
66
|
+
if (!isStringRecord(file.resolutions)) {
|
|
67
|
+
throw new Error(`Runtime package file "${packageJsonPath}" has invalid "resolutions": expected an object of package names to pinned version strings.`);
|
|
68
|
+
}
|
|
69
|
+
resolutions = file.resolutions;
|
|
70
|
+
}
|
|
71
|
+
else if (file.overrides !== undefined) {
|
|
72
|
+
if (!isStringRecord(file.overrides)) {
|
|
73
|
+
throw new Error(`Runtime package file "${packageJsonPath}" has unsupported "overrides" values for runtime resolutions; only string values are supported.`);
|
|
74
|
+
}
|
|
75
|
+
resolutions = file.overrides;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
dependencies,
|
|
79
|
+
resolutions,
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.parseRuntimePackageJsonFile = parseRuntimePackageJsonFile;
|
|
34
83
|
const buildRuntime = (props) => {
|
|
35
|
-
const { image,
|
|
84
|
+
const { image, packageJson, timeout, warmConcurrency, resources, permissions, } = props;
|
|
36
85
|
if (!image &&
|
|
37
|
-
!
|
|
86
|
+
!packageJson &&
|
|
38
87
|
!timeout &&
|
|
39
|
-
|
|
88
|
+
warmConcurrency === undefined &&
|
|
40
89
|
!resources &&
|
|
41
90
|
!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
42
91
|
return undefined;
|
|
43
92
|
}
|
|
44
|
-
let
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
parsedDependencies = JSON.parse((0, files_1.readFileContents)(dependencies));
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
throw new Error(`Failed to parse dependencies file "${dependencies}": ${error.message}`);
|
|
51
|
-
}
|
|
93
|
+
let parsedPackageFile;
|
|
94
|
+
if (packageJson) {
|
|
95
|
+
parsedPackageFile = parseRuntimePackageJsonFile(packageJson);
|
|
52
96
|
}
|
|
53
97
|
const runtime = {};
|
|
54
98
|
if (image) {
|
|
55
99
|
runtime.image = image;
|
|
56
100
|
}
|
|
57
|
-
if (
|
|
58
|
-
runtime.dependencies =
|
|
101
|
+
if (parsedPackageFile) {
|
|
102
|
+
runtime.dependencies = parsedPackageFile.dependencies;
|
|
103
|
+
}
|
|
104
|
+
if (parsedPackageFile === null || parsedPackageFile === void 0 ? void 0 : parsedPackageFile.resolutions) {
|
|
105
|
+
runtime.resolutions = parsedPackageFile.resolutions;
|
|
59
106
|
}
|
|
60
107
|
if (timeout !== undefined) {
|
|
61
108
|
runtime.timeout = timeout;
|
|
@@ -72,12 +119,36 @@ const buildRuntime = (props) => {
|
|
|
72
119
|
return runtime;
|
|
73
120
|
};
|
|
74
121
|
exports.buildRuntime = buildRuntime;
|
|
75
|
-
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) => {
|
|
76
147
|
const prefix = labelPrefix ? `${labelPrefix}: ` : '';
|
|
77
148
|
const timeout = await (0, utils_1.promptIntegerIfUndefined)(flags.timeout, {
|
|
78
|
-
message: `${prefix}Timeout in seconds (
|
|
79
|
-
min:
|
|
80
|
-
max:
|
|
149
|
+
message: `${prefix}Timeout in seconds (${MIN_RUNTIME_TIMEOUT}-${timeoutMax}, press Enter for default: 10):`,
|
|
150
|
+
min: MIN_RUNTIME_TIMEOUT,
|
|
151
|
+
max: timeoutMax,
|
|
81
152
|
});
|
|
82
153
|
const warmConcurrency = await (0, utils_1.promptIntegerIfUndefined)(flags['warm-concurrency'], {
|
|
83
154
|
message: `${prefix}Warm concurrency (0-1, press Enter for default: 0):`,
|
|
@@ -101,8 +172,8 @@ const promptRuntimeOptions = async (flags, labelPrefix) => {
|
|
|
101
172
|
},
|
|
102
173
|
],
|
|
103
174
|
});
|
|
104
|
-
const
|
|
105
|
-
message: `${prefix}(Optional)
|
|
175
|
+
const packageJson = await (0, utils_1.promptStringIfUndefined)(flags['package-json'], {
|
|
176
|
+
message: `${prefix}(Optional) Runtime package.json file path (JSON format):`,
|
|
106
177
|
});
|
|
107
178
|
const permissions = await (0, utils_1.promptCommaSeparatedIfUndefined)(flags.permissions, {
|
|
108
179
|
message: `${prefix}(Optional) Permissions (comma-separated, e.g. token:read, token:create):`,
|
|
@@ -111,7 +182,7 @@ const promptRuntimeOptions = async (flags, labelPrefix) => {
|
|
|
111
182
|
timeout,
|
|
112
183
|
warmConcurrency,
|
|
113
184
|
resources,
|
|
114
|
-
|
|
185
|
+
packageJson: packageJson || undefined,
|
|
115
186
|
permissions,
|
|
116
187
|
};
|
|
117
188
|
};
|