@basis-theory-labs/cli 1.13.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -87
- package/dist/applications/management.d.ts +8 -10
- package/dist/applications/management.js +14 -10
- package/dist/base.d.ts +2 -2
- package/dist/base.js +27 -14
- package/dist/commands/applications/create.js +6 -3
- package/dist/commands/applications/index.js +3 -1
- package/dist/commands/proxies/create.d.ts +17 -1
- package/dist/commands/proxies/create.js +84 -8
- package/dist/commands/proxies/index.js +3 -2
- package/dist/commands/proxies/logs.js +2 -1
- package/dist/commands/proxies/update.d.ts +17 -1
- package/dist/commands/proxies/update.js +66 -6
- package/dist/commands/reactors/create.d.ts +11 -1
- package/dist/commands/reactors/create.js +70 -8
- package/dist/commands/reactors/index.js +3 -2
- package/dist/commands/reactors/logs.js +2 -1
- package/dist/commands/reactors/update.d.ts +11 -1
- package/dist/commands/reactors/update.js +45 -5
- package/dist/logs/connect.d.ts +5 -5
- package/dist/logs/connect.js +1 -2
- package/dist/logs/index.d.ts +3 -3
- package/dist/logs/server.js +1 -2
- package/dist/proxies/management.d.ts +7 -7
- package/dist/proxies/management.js +16 -9
- package/dist/proxies/runtime.d.ts +5 -0
- package/dist/proxies/runtime.js +66 -0
- package/dist/proxies/utils.d.ts +26 -5
- package/dist/proxies/utils.js +78 -7
- package/dist/reactors/management.d.ts +7 -7
- package/dist/reactors/management.js +16 -9
- package/dist/reactors/runtime.d.ts +3 -0
- package/dist/reactors/runtime.js +27 -0
- package/dist/reactors/utils.d.ts +16 -5
- package/dist/reactors/utils.js +4 -1
- package/dist/runtime/flags.d.ts +10 -0
- package/dist/runtime/flags.js +37 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +20 -0
- package/dist/runtime/state.d.ts +6 -0
- package/dist/runtime/state.js +86 -0
- package/dist/runtime/utils.d.ts +34 -0
- package/dist/runtime/utils.js +132 -0
- package/dist/utils.d.ts +12 -2
- package/dist/utils.js +44 -4
- package/oclif.manifest.json +333 -122
- package/package.json +4 -3
- package/dist/commands/reactorFormulas/index.d.ts +0 -10
- package/dist/commands/reactorFormulas/index.js +0 -27
- package/dist/commands/reactorFormulas/update.d.ts +0 -18
- package/dist/commands/reactorFormulas/update.js +0 -71
- package/dist/reactorFormulas/management.d.ts +0 -5
- package/dist/reactorFormulas/management.js +0 -54
- package/dist/reactorFormulas/utils.d.ts +0 -26
- package/dist/reactorFormulas/utils.js +0 -49
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
export { selectProxy, createProxy, patchProxy, deleteProxy };
|
|
1
|
+
import type { BasisTheory, BasisTheoryClient } from '@basis-theory/node-sdk';
|
|
2
|
+
declare const selectProxy: (bt: BasisTheoryClient, page: number) => Promise<BasisTheory.Proxy | undefined>;
|
|
3
|
+
declare const createProxy: (bt: BasisTheoryClient, model: BasisTheory.CreateProxyRequest) => Promise<BasisTheory.Proxy>;
|
|
4
|
+
declare const deleteProxy: (bt: BasisTheoryClient, id: string, force?: boolean) => Promise<boolean>;
|
|
5
|
+
declare const patchProxy: (bt: BasisTheoryClient, id: string, model: BasisTheory.PatchProxyRequest) => Promise<void>;
|
|
6
|
+
declare const getProxy: (bt: BasisTheoryClient, id: string) => Promise<BasisTheory.Proxy>;
|
|
7
|
+
export { selectProxy, createProxy, patchProxy, deleteProxy, getProxy };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteProxy = exports.patchProxy = exports.createProxy = exports.selectProxy = void 0;
|
|
3
|
+
exports.getProxy = exports.deleteProxy = exports.patchProxy = exports.createProxy = exports.selectProxy = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const confirm_1 = tslib_1.__importDefault(require("@inquirer/confirm"));
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
@@ -9,14 +9,14 @@ const debug = require('debug')('proxies:management');
|
|
|
9
9
|
const listProxies = async (bt, page) => {
|
|
10
10
|
const size = 5;
|
|
11
11
|
debug('Listing proxies', `page: ${page}`, `size: ${size}`);
|
|
12
|
-
const
|
|
12
|
+
const proxiesPage = await bt.proxies.list({
|
|
13
13
|
size,
|
|
14
14
|
page,
|
|
15
15
|
});
|
|
16
16
|
let data = [];
|
|
17
|
-
if (
|
|
18
|
-
const last = (
|
|
19
|
-
data =
|
|
17
|
+
if (proxiesPage.data.length) {
|
|
18
|
+
const last = (page - 1) * size;
|
|
19
|
+
data = proxiesPage.data.map((proxy, index) => ({
|
|
20
20
|
'#': last + (index + 1),
|
|
21
21
|
...proxy,
|
|
22
22
|
}));
|
|
@@ -25,6 +25,7 @@ const listProxies = async (bt, page) => {
|
|
|
25
25
|
id: {},
|
|
26
26
|
name: {},
|
|
27
27
|
key: {},
|
|
28
|
+
state: {},
|
|
28
29
|
/* eslint-disable camelcase */
|
|
29
30
|
destination_url: {
|
|
30
31
|
header: 'Destination URL',
|
|
@@ -54,12 +55,13 @@ const listProxies = async (bt, page) => {
|
|
|
54
55
|
}
|
|
55
56
|
return {
|
|
56
57
|
data,
|
|
57
|
-
|
|
58
|
+
page,
|
|
59
|
+
hasNextPage: proxiesPage.hasNextPage(),
|
|
58
60
|
};
|
|
59
61
|
};
|
|
60
62
|
const selectProxy = async (bt, page) => {
|
|
61
63
|
const proxies = await listProxies(bt, page);
|
|
62
|
-
if (proxies.
|
|
64
|
+
if (!proxies.data.length) {
|
|
63
65
|
return undefined;
|
|
64
66
|
}
|
|
65
67
|
const selection = await (0, utils_1.selectOrNavigate)(proxies, '#');
|
|
@@ -92,8 +94,13 @@ const deleteProxy = async (bt, id, force = false) => {
|
|
|
92
94
|
return true;
|
|
93
95
|
};
|
|
94
96
|
exports.deleteProxy = deleteProxy;
|
|
95
|
-
const patchProxy = (bt, id, model) => {
|
|
97
|
+
const patchProxy = async (bt, id, model) => {
|
|
96
98
|
debug(`Patching Proxy ${id}`, JSON.stringify(model, undefined, 2));
|
|
97
|
-
|
|
99
|
+
await bt.proxies.patch(id, model);
|
|
98
100
|
};
|
|
99
101
|
exports.patchProxy = patchProxy;
|
|
102
|
+
const getProxy = (bt, id) => {
|
|
103
|
+
debug(`Getting Proxy ${id}`);
|
|
104
|
+
return bt.proxies.get(id);
|
|
105
|
+
};
|
|
106
|
+
exports.getProxy = getProxy;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BasisTheory } from '@basis-theory/node-sdk';
|
|
2
|
+
declare const validateTransformRuntimeFlags: (prefix: 'request-transform' | 'response-transform', flags: Record<string, unknown>, image: string | undefined) => void;
|
|
3
|
+
declare const validateProxyApplicationId: (applicationId: string | undefined, flags: Record<string, unknown>) => void;
|
|
4
|
+
declare const promptTransformRuntime: (prefix: 'request' | 'response', flags: Record<string, unknown>, transformCode: string | undefined, image: string | undefined) => Promise<BasisTheory.Runtime | undefined>;
|
|
5
|
+
export { validateTransformRuntimeFlags, validateProxyApplicationId, promptTransformRuntime, };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promptTransformRuntime = exports.validateProxyApplicationId = exports.validateTransformRuntimeFlags = void 0;
|
|
4
|
+
const runtime_1 = require("../runtime");
|
|
5
|
+
const validateTransformRuntimeFlags = (prefix, flags, image) => {
|
|
6
|
+
const setFlags = [];
|
|
7
|
+
for (const flag of runtime_1.CONFIGURABLE_RUNTIME_FLAGS) {
|
|
8
|
+
const fullFlag = `${prefix}-${flag}`;
|
|
9
|
+
const value = flags[fullFlag];
|
|
10
|
+
const isSet = value !== undefined && !(Array.isArray(value) && value.length === 0);
|
|
11
|
+
if (isSet) {
|
|
12
|
+
setFlags.push(fullFlag);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (setFlags.length && (0, runtime_1.isLegacyRuntimeImage)(image)) {
|
|
16
|
+
const flagNames = setFlags.map((f) => `--${f}`).join(', ');
|
|
17
|
+
throw new Error(`Configurable runtime flags (${flagNames}) require --${prefix}-image ${runtime_1.CONFIGURABLE_RUNTIME_IMAGES.join(' | ')}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.validateTransformRuntimeFlags = validateTransformRuntimeFlags;
|
|
21
|
+
const hasTransformWithRuntime = (flags, runtimes) => {
|
|
22
|
+
const requestImage = flags['request-transform-image'];
|
|
23
|
+
const responseImage = flags['response-transform-image'];
|
|
24
|
+
const isMatch = (image) => {
|
|
25
|
+
if (image === undefined) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return typeof runtimes === 'string'
|
|
29
|
+
? image === runtimes
|
|
30
|
+
: runtimes.includes(image);
|
|
31
|
+
};
|
|
32
|
+
return isMatch(requestImage) || isMatch(responseImage);
|
|
33
|
+
};
|
|
34
|
+
const validateProxyApplicationId = (applicationId, flags) => {
|
|
35
|
+
if (!applicationId) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const hasConfigurable = hasTransformWithRuntime(flags, runtime_1.CONFIGURABLE_RUNTIME_IMAGES);
|
|
39
|
+
const hasLegacy = hasTransformWithRuntime(flags, runtime_1.LEGACY_RUNTIME_IMAGE);
|
|
40
|
+
if (hasConfigurable && !hasLegacy) {
|
|
41
|
+
throw new Error(`--application-id is only valid when at least one transform uses a legacy runtime (${runtime_1.LEGACY_RUNTIME_IMAGE}). Use --{request,response}-transform-permissions instead.`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.validateProxyApplicationId = validateProxyApplicationId;
|
|
45
|
+
const promptTransformRuntime = async (prefix, flags, transformCode, image) => {
|
|
46
|
+
if (!transformCode) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if ((0, runtime_1.isLegacyRuntimeImage)(image)) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const transformFlags = {
|
|
53
|
+
timeout: flags[`${prefix}-transform-timeout`],
|
|
54
|
+
'warm-concurrency': flags[`${prefix}-transform-warm-concurrency`],
|
|
55
|
+
resources: flags[`${prefix}-transform-resources`],
|
|
56
|
+
dependencies: flags[`${prefix}-transform-dependencies`],
|
|
57
|
+
permissions: flags[`${prefix}-transform-permissions`],
|
|
58
|
+
};
|
|
59
|
+
const labelPrefix = `${prefix.charAt(0).toUpperCase()}${prefix.slice(1)} transform`;
|
|
60
|
+
const runtimeOptions = await (0, runtime_1.promptRuntimeOptions)(transformFlags, labelPrefix);
|
|
61
|
+
return (0, runtime_1.buildRuntime)({
|
|
62
|
+
image,
|
|
63
|
+
...runtimeOptions,
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
exports.promptTransformRuntime = promptTransformRuntime;
|
package/dist/proxies/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { BasisTheory } from '@basis-theory/node-sdk';
|
|
3
3
|
declare const PROXY_FLAGS: {
|
|
4
4
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
5
5
|
'destination-url': import("@oclif/core/lib/interfaces/parser").OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -8,6 +8,19 @@ declare const PROXY_FLAGS: {
|
|
|
8
8
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
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
|
+
'request-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
'request-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
'request-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
'request-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
'request-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
|
+
'request-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
|
+
'response-transform-image': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
|
+
'response-transform-dependencies': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
|
+
'response-transform-timeout': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
|
+
'response-transform-warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
+
'response-transform-resources': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
22
|
+
'response-transform-permissions': import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
23
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
11
24
|
};
|
|
12
25
|
interface ProxyFlagProps {
|
|
13
26
|
/**
|
|
@@ -26,9 +39,17 @@ interface ProxyFlagProps {
|
|
|
26
39
|
* Path to .env file
|
|
27
40
|
*/
|
|
28
41
|
configuration?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Request transform runtime
|
|
44
|
+
*/
|
|
45
|
+
requestTransformRuntime?: BasisTheory.Runtime;
|
|
46
|
+
/**
|
|
47
|
+
* Response transform runtime
|
|
48
|
+
*/
|
|
49
|
+
responseTransformRuntime?: BasisTheory.Runtime;
|
|
29
50
|
}
|
|
30
|
-
type CreateProxy = ProxyFlagProps & Omit<
|
|
31
|
-
type PatchProxy = ProxyFlagProps & Omit<
|
|
32
|
-
declare function createModelFromFlags(payload: CreateProxy):
|
|
33
|
-
declare function createModelFromFlags(payload: PatchProxy):
|
|
51
|
+
type CreateProxy = ProxyFlagProps & Omit<BasisTheory.CreateProxyRequest, 'application' | 'configuration' | 'requestTransforms' | 'responseTransforms'>;
|
|
52
|
+
type PatchProxy = ProxyFlagProps & Omit<BasisTheory.PatchProxyRequest, 'application' | 'configuration' | 'requestTransforms' | 'responseTransforms'>;
|
|
53
|
+
declare function createModelFromFlags(payload: CreateProxy): BasisTheory.CreateProxyRequest;
|
|
54
|
+
declare function createModelFromFlags(payload: PatchProxy): BasisTheory.PatchProxyRequest;
|
|
34
55
|
export { PROXY_FLAGS, createModelFromFlags };
|
package/dist/proxies/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.createModelFromFlags = exports.PROXY_FLAGS = void 0;
|
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const dotenv_1 = require("dotenv");
|
|
6
6
|
const files_1 = require("../files");
|
|
7
|
+
const runtime_1 = require("../runtime");
|
|
7
8
|
const PROXY_FLAGS = {
|
|
8
9
|
name: core_1.Flags.string({
|
|
9
10
|
char: 'n',
|
|
@@ -35,19 +36,89 @@ const PROXY_FLAGS = {
|
|
|
35
36
|
allowNo: true,
|
|
36
37
|
default: true,
|
|
37
38
|
}),
|
|
39
|
+
'request-transform-image': core_1.Flags.string({
|
|
40
|
+
description: `request-transform runtime image (${runtime_1.VALID_RUNTIME_IMAGES.join('|')})`,
|
|
41
|
+
options: [...runtime_1.VALID_RUNTIME_IMAGES],
|
|
42
|
+
}),
|
|
43
|
+
'request-transform-dependencies': core_1.Flags.file({
|
|
44
|
+
description: 'path to JSON file with npm dependencies, e.g. {"axios": "1.7.9", "lodash": "4.17.21"} (node22 only)',
|
|
45
|
+
}),
|
|
46
|
+
'request-transform-timeout': core_1.Flags.integer({
|
|
47
|
+
description: 'request-transform timeout in seconds, 1-30 (node22 only)',
|
|
48
|
+
min: 1,
|
|
49
|
+
max: 30,
|
|
50
|
+
}),
|
|
51
|
+
'request-transform-warm-concurrency': core_1.Flags.integer({
|
|
52
|
+
description: 'request-transform warm concurrency, 0-1 (node22 only)',
|
|
53
|
+
min: 0,
|
|
54
|
+
max: 1,
|
|
55
|
+
}),
|
|
56
|
+
'request-transform-resources': core_1.Flags.string({
|
|
57
|
+
description: 'request-transform resource tier (node22 only)',
|
|
58
|
+
options: ['standard', 'large', 'xlarge'],
|
|
59
|
+
}),
|
|
60
|
+
'request-transform-permissions': core_1.Flags.string({
|
|
61
|
+
description: 'request-transform permission to grant, repeatable (node22 only)',
|
|
62
|
+
multiple: true,
|
|
63
|
+
}),
|
|
64
|
+
'response-transform-image': core_1.Flags.string({
|
|
65
|
+
description: `response-transform runtime image (${runtime_1.VALID_RUNTIME_IMAGES.join('|')})`,
|
|
66
|
+
options: [...runtime_1.VALID_RUNTIME_IMAGES],
|
|
67
|
+
}),
|
|
68
|
+
'response-transform-dependencies': core_1.Flags.file({
|
|
69
|
+
description: 'path to JSON file with npm dependencies, e.g. {"axios": "1.7.9", "lodash": "4.17.21"} (node22 only)',
|
|
70
|
+
}),
|
|
71
|
+
'response-transform-timeout': core_1.Flags.integer({
|
|
72
|
+
description: 'response-transform timeout in seconds, 1-30 (node22 only)',
|
|
73
|
+
min: 1,
|
|
74
|
+
max: 30,
|
|
75
|
+
}),
|
|
76
|
+
'response-transform-warm-concurrency': core_1.Flags.integer({
|
|
77
|
+
description: 'response-transform warm concurrency, 0-1 (node22 only)',
|
|
78
|
+
min: 0,
|
|
79
|
+
max: 1,
|
|
80
|
+
}),
|
|
81
|
+
'response-transform-resources': core_1.Flags.string({
|
|
82
|
+
description: 'response-transform resource tier (node22 only)',
|
|
83
|
+
options: ['standard', 'large', 'xlarge'],
|
|
84
|
+
}),
|
|
85
|
+
'response-transform-permissions': core_1.Flags.string({
|
|
86
|
+
description: 'response-transform permission to grant, repeatable (node22 only)',
|
|
87
|
+
multiple: true,
|
|
88
|
+
}),
|
|
89
|
+
async: core_1.Flags.boolean({
|
|
90
|
+
description: 'do not wait for proxy to be ready (requires at least one transform with node22)',
|
|
91
|
+
default: false,
|
|
92
|
+
}),
|
|
38
93
|
};
|
|
39
94
|
exports.PROXY_FLAGS = PROXY_FLAGS;
|
|
40
95
|
// eslint-disable-next-line get-off-my-lawn/prefer-arrow-functions
|
|
41
|
-
function createModelFromFlags({ name, destinationUrl, requestTransformCode, responseTransformCode, applicationId, configuration, requireAuth, }) {
|
|
96
|
+
function createModelFromFlags({ name, destinationUrl, requestTransformCode, responseTransformCode, applicationId, configuration, requireAuth, requestTransformRuntime, responseTransformRuntime, }) {
|
|
97
|
+
let requestTransform;
|
|
98
|
+
if (requestTransformCode) {
|
|
99
|
+
requestTransform = {
|
|
100
|
+
type: 'code',
|
|
101
|
+
code: (0, files_1.readFileContents)(requestTransformCode),
|
|
102
|
+
};
|
|
103
|
+
if (requestTransformRuntime) {
|
|
104
|
+
requestTransform.options = { runtime: requestTransformRuntime };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
let responseTransform;
|
|
108
|
+
if (responseTransformCode) {
|
|
109
|
+
responseTransform = {
|
|
110
|
+
type: 'code',
|
|
111
|
+
code: (0, files_1.readFileContents)(responseTransformCode),
|
|
112
|
+
};
|
|
113
|
+
if (responseTransformRuntime) {
|
|
114
|
+
responseTransform.options = { runtime: responseTransformRuntime };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
42
117
|
return {
|
|
43
118
|
name,
|
|
44
119
|
destinationUrl,
|
|
45
|
-
requestTransform:
|
|
46
|
-
|
|
47
|
-
: undefined,
|
|
48
|
-
responseTransform: responseTransformCode
|
|
49
|
-
? { code: (0, files_1.readFileContents)(responseTransformCode) }
|
|
50
|
-
: undefined,
|
|
120
|
+
requestTransforms: requestTransform ? [requestTransform] : undefined,
|
|
121
|
+
responseTransforms: responseTransform ? [responseTransform] : undefined,
|
|
51
122
|
application: applicationId ? { id: applicationId } : undefined,
|
|
52
123
|
configuration: configuration
|
|
53
124
|
? (0, dotenv_1.parse)((0, files_1.readFileContents)(configuration))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
export { selectReactor, createReactor, patchReactor, deleteReactor };
|
|
1
|
+
import type { BasisTheory, BasisTheoryClient } from '@basis-theory/node-sdk';
|
|
2
|
+
declare const selectReactor: (bt: BasisTheoryClient, page: number) => Promise<BasisTheory.Reactor | undefined>;
|
|
3
|
+
declare const createReactor: (bt: BasisTheoryClient, model: BasisTheory.CreateReactorRequest) => Promise<BasisTheory.Reactor>;
|
|
4
|
+
declare const deleteReactor: (bt: BasisTheoryClient, id: string, force?: boolean) => Promise<boolean>;
|
|
5
|
+
declare const patchReactor: (bt: BasisTheoryClient, id: string, model: BasisTheory.PatchReactorRequest) => Promise<void>;
|
|
6
|
+
declare const getReactor: (bt: BasisTheoryClient, id: string) => Promise<BasisTheory.Reactor>;
|
|
7
|
+
export { selectReactor, createReactor, patchReactor, deleteReactor, getReactor, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteReactor = exports.patchReactor = exports.createReactor = exports.selectReactor = void 0;
|
|
3
|
+
exports.getReactor = exports.deleteReactor = exports.patchReactor = exports.createReactor = exports.selectReactor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const confirm_1 = tslib_1.__importDefault(require("@inquirer/confirm"));
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
@@ -9,14 +9,14 @@ const debug = require('debug')('reactors:management');
|
|
|
9
9
|
const listReactors = async (bt, page) => {
|
|
10
10
|
const size = 5;
|
|
11
11
|
debug('Listing reactors', `page: ${page}`, `size: ${size}`);
|
|
12
|
-
const
|
|
12
|
+
const reactorsPage = await bt.reactors.list({
|
|
13
13
|
size,
|
|
14
14
|
page,
|
|
15
15
|
});
|
|
16
16
|
let data = [];
|
|
17
|
-
if (
|
|
18
|
-
const last = (
|
|
19
|
-
data =
|
|
17
|
+
if (reactorsPage.data.length) {
|
|
18
|
+
const last = (page - 1) * size;
|
|
19
|
+
data = reactorsPage.data.map((reactor, index) => ({
|
|
20
20
|
'#': last + (index + 1),
|
|
21
21
|
...reactor,
|
|
22
22
|
}));
|
|
@@ -24,6 +24,7 @@ const listReactors = async (bt, page) => {
|
|
|
24
24
|
'#': {},
|
|
25
25
|
id: {},
|
|
26
26
|
name: {},
|
|
27
|
+
state: {},
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
@@ -31,12 +32,13 @@ const listReactors = async (bt, page) => {
|
|
|
31
32
|
}
|
|
32
33
|
return {
|
|
33
34
|
data,
|
|
34
|
-
|
|
35
|
+
page,
|
|
36
|
+
hasNextPage: reactorsPage.hasNextPage(),
|
|
35
37
|
};
|
|
36
38
|
};
|
|
37
39
|
const selectReactor = async (bt, page) => {
|
|
38
40
|
const reactors = await listReactors(bt, page);
|
|
39
|
-
if (reactors.
|
|
41
|
+
if (!reactors.data.length) {
|
|
40
42
|
return undefined;
|
|
41
43
|
}
|
|
42
44
|
const selection = await (0, utils_1.selectOrNavigate)(reactors, '#');
|
|
@@ -69,8 +71,13 @@ const deleteReactor = async (bt, id, force = false) => {
|
|
|
69
71
|
return true;
|
|
70
72
|
};
|
|
71
73
|
exports.deleteReactor = deleteReactor;
|
|
72
|
-
const patchReactor = (bt, id, model) => {
|
|
74
|
+
const patchReactor = async (bt, id, model) => {
|
|
73
75
|
debug(`Patching Reactor ${id}`, JSON.stringify(model, undefined, 2));
|
|
74
|
-
|
|
76
|
+
await bt.reactors.patch(id, model);
|
|
75
77
|
};
|
|
76
78
|
exports.patchReactor = patchReactor;
|
|
79
|
+
const getReactor = (bt, id) => {
|
|
80
|
+
debug(`Getting Reactor ${id}`);
|
|
81
|
+
return bt.reactors.get(id);
|
|
82
|
+
};
|
|
83
|
+
exports.getReactor = getReactor;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const validateReactorRuntimeFlags: (flags: Record<string, unknown>, image: string | undefined) => void;
|
|
2
|
+
declare const validateReactorApplicationId: (applicationId: string | undefined, image: string | undefined) => void;
|
|
3
|
+
export { validateReactorRuntimeFlags, validateReactorApplicationId };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateReactorApplicationId = exports.validateReactorRuntimeFlags = void 0;
|
|
4
|
+
const runtime_1 = require("../runtime");
|
|
5
|
+
const validateReactorRuntimeFlags = (flags, image) => {
|
|
6
|
+
const setFlags = [];
|
|
7
|
+
for (const flag of runtime_1.CONFIGURABLE_RUNTIME_FLAGS) {
|
|
8
|
+
const value = flags[flag];
|
|
9
|
+
const isSet = value !== undefined &&
|
|
10
|
+
value !== false &&
|
|
11
|
+
!(Array.isArray(value) && value.length === 0);
|
|
12
|
+
if (isSet) {
|
|
13
|
+
setFlags.push(flag);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (setFlags.length && (0, runtime_1.isLegacyRuntimeImage)(image)) {
|
|
17
|
+
const flagNames = setFlags.map((f) => `--${f}`).join(', ');
|
|
18
|
+
throw new Error(`Configurable runtime flags (${flagNames}) require --image ${runtime_1.CONFIGURABLE_RUNTIME_IMAGES.join(' | ')}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.validateReactorRuntimeFlags = validateReactorRuntimeFlags;
|
|
22
|
+
const validateReactorApplicationId = (applicationId, image) => {
|
|
23
|
+
if (applicationId && !(0, runtime_1.isLegacyRuntimeImage)(image)) {
|
|
24
|
+
throw new Error(`--application-id is not allowed with configurable runtimes (${runtime_1.CONFIGURABLE_RUNTIME_IMAGES.join(' | ')}). Use --permissions to grant specific access instead.`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.validateReactorApplicationId = validateReactorApplicationId;
|
package/dist/reactors/utils.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BasisTheory } from '@basis-theory/node-sdk';
|
|
2
2
|
declare const REACTOR_FLAGS: {
|
|
3
|
+
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
4
|
+
dependencies: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
5
|
+
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
|
+
'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
|
+
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
3
10
|
name: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
4
11
|
configuration: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
5
12
|
'application-id': import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
@@ -18,9 +25,13 @@ interface ReactorFlagProps {
|
|
|
18
25
|
* Path to .env file
|
|
19
26
|
*/
|
|
20
27
|
configuration?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Runtime configuration
|
|
30
|
+
*/
|
|
31
|
+
runtime?: BasisTheory.Runtime;
|
|
21
32
|
}
|
|
22
|
-
type CreateReactor = ReactorFlagProps & Omit<
|
|
23
|
-
type PatchReactor = ReactorFlagProps & Omit<
|
|
24
|
-
declare function createModelFromFlags(payload: CreateReactor):
|
|
25
|
-
declare function createModelFromFlags(payload: PatchReactor):
|
|
33
|
+
type CreateReactor = ReactorFlagProps & Omit<BasisTheory.CreateReactorRequest, 'application' | 'configuration' | 'runtime'>;
|
|
34
|
+
type PatchReactor = ReactorFlagProps & Omit<BasisTheory.PatchReactorRequest, 'application' | 'configuration' | 'runtime'>;
|
|
35
|
+
declare function createModelFromFlags(payload: CreateReactor): BasisTheory.CreateReactorRequest;
|
|
36
|
+
declare function createModelFromFlags(payload: PatchReactor): BasisTheory.PatchReactorRequest;
|
|
26
37
|
export { REACTOR_FLAGS, createModelFromFlags };
|
package/dist/reactors/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.createModelFromFlags = exports.REACTOR_FLAGS = void 0;
|
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const dotenv_1 = require("dotenv");
|
|
6
6
|
const files_1 = require("../files");
|
|
7
|
+
const runtime_1 = require("../runtime");
|
|
7
8
|
const REACTOR_FLAGS = {
|
|
8
9
|
name: core_1.Flags.string({
|
|
9
10
|
char: 'n',
|
|
@@ -21,10 +22,11 @@ const REACTOR_FLAGS = {
|
|
|
21
22
|
char: 'r',
|
|
22
23
|
description: 'path to JavaScript file containing the Reactor code',
|
|
23
24
|
}),
|
|
25
|
+
...runtime_1.RUNTIME_FLAGS,
|
|
24
26
|
};
|
|
25
27
|
exports.REACTOR_FLAGS = REACTOR_FLAGS;
|
|
26
28
|
// eslint-disable-next-line get-off-my-lawn/prefer-arrow-functions
|
|
27
|
-
function createModelFromFlags({ name, applicationId, code, configuration, }) {
|
|
29
|
+
function createModelFromFlags({ name, applicationId, code, configuration, runtime, }) {
|
|
28
30
|
return {
|
|
29
31
|
name,
|
|
30
32
|
code: code ? (0, files_1.readFileContents)(code) : undefined,
|
|
@@ -32,6 +34,7 @@ function createModelFromFlags({ name, applicationId, code, configuration, }) {
|
|
|
32
34
|
configuration: configuration
|
|
33
35
|
? (0, dotenv_1.parse)((0, files_1.readFileContents)(configuration))
|
|
34
36
|
: undefined,
|
|
37
|
+
runtime,
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
exports.createModelFromFlags = createModelFromFlags;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const RUNTIME_FLAGS: {
|
|
2
|
+
image: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
3
|
+
dependencies: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
4
|
+
timeout: import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
5
|
+
'warm-concurrency': import("@oclif/core/lib/interfaces/parser").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
|
+
resources: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
permissions: import("@oclif/core/lib/interfaces/parser").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
async: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
export { RUNTIME_FLAGS };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME_FLAGS = void 0;
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const RUNTIME_FLAGS = {
|
|
7
|
+
image: core_1.Flags.string({
|
|
8
|
+
description: `runtime image (${utils_1.VALID_RUNTIME_IMAGES.join('|')})`,
|
|
9
|
+
options: [...utils_1.VALID_RUNTIME_IMAGES],
|
|
10
|
+
}),
|
|
11
|
+
dependencies: core_1.Flags.file({
|
|
12
|
+
description: 'path to JSON file with npm dependencies, e.g. {"axios": "1.7.9", "lodash": "4.17.21"} (node22 only)',
|
|
13
|
+
}),
|
|
14
|
+
timeout: core_1.Flags.integer({
|
|
15
|
+
description: 'timeout in seconds, 1-30 (node22 only, default: 10)',
|
|
16
|
+
min: 1,
|
|
17
|
+
max: 30,
|
|
18
|
+
}),
|
|
19
|
+
'warm-concurrency': core_1.Flags.integer({
|
|
20
|
+
description: 'number of warm instances, 0-1 (node22 only, default: 0)',
|
|
21
|
+
min: 0,
|
|
22
|
+
max: 1,
|
|
23
|
+
}),
|
|
24
|
+
resources: core_1.Flags.string({
|
|
25
|
+
description: 'resource tier (node22 only, default: standard)',
|
|
26
|
+
options: ['standard', 'large', 'xlarge'],
|
|
27
|
+
}),
|
|
28
|
+
permissions: core_1.Flags.string({
|
|
29
|
+
description: 'permission to grant, repeatable (node22 only)',
|
|
30
|
+
multiple: true,
|
|
31
|
+
}),
|
|
32
|
+
async: core_1.Flags.boolean({
|
|
33
|
+
description: 'do not wait for resource to be ready (node22 only)',
|
|
34
|
+
default: false,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
exports.RUNTIME_FLAGS = RUNTIME_FLAGS;
|
|
@@ -0,0 +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';
|
|
2
|
+
export { RUNTIME_FLAGS } from './flags';
|
|
3
|
+
export { waitForResourceState, needsPolling, POLL_INTERVAL, POLL_TIMEOUT, } from './state';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
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;
|
|
4
|
+
var utils_1 = require("./utils");
|
|
5
|
+
Object.defineProperty(exports, "LEGACY_RUNTIME_IMAGE", { enumerable: true, get: function () { return utils_1.LEGACY_RUNTIME_IMAGE; } });
|
|
6
|
+
Object.defineProperty(exports, "CONFIGURABLE_RUNTIME_IMAGES", { enumerable: true, get: function () { return utils_1.CONFIGURABLE_RUNTIME_IMAGES; } });
|
|
7
|
+
Object.defineProperty(exports, "VALID_RUNTIME_IMAGES", { enumerable: true, get: function () { return utils_1.VALID_RUNTIME_IMAGES; } });
|
|
8
|
+
Object.defineProperty(exports, "CONFIGURABLE_RUNTIME_FLAGS", { enumerable: true, get: function () { return utils_1.CONFIGURABLE_RUNTIME_FLAGS; } });
|
|
9
|
+
Object.defineProperty(exports, "isLegacyRuntimeImage", { enumerable: true, get: function () { return utils_1.isLegacyRuntimeImage; } });
|
|
10
|
+
Object.defineProperty(exports, "validateRuntimeImage", { enumerable: true, get: function () { return utils_1.validateRuntimeImage; } });
|
|
11
|
+
Object.defineProperty(exports, "buildRuntime", { enumerable: true, get: function () { return utils_1.buildRuntime; } });
|
|
12
|
+
Object.defineProperty(exports, "promptRuntimeOptions", { enumerable: true, get: function () { return utils_1.promptRuntimeOptions; } });
|
|
13
|
+
Object.defineProperty(exports, "promptRuntimeImage", { enumerable: true, get: function () { return utils_1.promptRuntimeImage; } });
|
|
14
|
+
var flags_1 = require("./flags");
|
|
15
|
+
Object.defineProperty(exports, "RUNTIME_FLAGS", { enumerable: true, get: function () { return flags_1.RUNTIME_FLAGS; } });
|
|
16
|
+
var state_1 = require("./state");
|
|
17
|
+
Object.defineProperty(exports, "waitForResourceState", { enumerable: true, get: function () { return state_1.waitForResourceState; } });
|
|
18
|
+
Object.defineProperty(exports, "needsPolling", { enumerable: true, get: function () { return state_1.needsPolling; } });
|
|
19
|
+
Object.defineProperty(exports, "POLL_INTERVAL", { enumerable: true, get: function () { return state_1.POLL_INTERVAL; } });
|
|
20
|
+
Object.defineProperty(exports, "POLL_TIMEOUT", { enumerable: true, get: function () { return state_1.POLL_TIMEOUT; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BasisTheoryClient } from '@basis-theory/node-sdk';
|
|
2
|
+
declare const POLL_INTERVAL = 2000;
|
|
3
|
+
declare const POLL_TIMEOUT = 600000;
|
|
4
|
+
declare const needsPolling: (state: string | undefined) => boolean;
|
|
5
|
+
declare const waitForResourceState: (bt: BasisTheoryClient, resourceType: 'reactor' | 'proxy', id: string, initialState?: string) => Promise<void>;
|
|
6
|
+
export { waitForResourceState, needsPolling, POLL_INTERVAL, POLL_TIMEOUT };
|