@intuned/runtime-dev 1.1.7-dev-52 → 1.2.0-cli.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/.babelrc +2 -2
- package/CHANGELOG.md +5 -1
- package/WebTemplate.zip +0 -0
- package/bin/intuned +2 -0
- package/dist/commands/api/run.js +2 -2
- package/dist/commands/cli-auth-sessions/create.js +1 -1
- package/dist/commands/cli-auth-sessions/utils.d.ts +1 -1
- package/dist/commands/cli-auth-sessions/utils.js +2 -3
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- package/dist/commands/deploy/utils.js +1 -2
- package/dist/commands/init/utils.js +1 -7
- package/dist/commands/interface/run.js +5 -6
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +47 -0
- package/dist/commands/intuned-cli/commands/helpers.d.ts +26 -0
- package/dist/commands/intuned-cli/commands/helpers.js +126 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
- package/dist/commands/intuned-cli/commands/index.js +170 -0
- package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/init.command.js +14 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/types.js +21 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +19 -0
- package/dist/commands/intuned-cli/controller/api.js +179 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +32 -0
- package/dist/commands/intuned-cli/controller/authSession.js +295 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
- package/dist/commands/intuned-cli/controller/deploy.js +397 -0
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +45 -0
- package/dist/commands/intuned-cli/controller/init.d.ts +5 -0
- package/dist/commands/intuned-cli/controller/init.js +139 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/dist/commands/intuned-cli/main.js +12 -0
- package/dist/commands/intuned-cli/terminal.d.ts +1 -0
- package/dist/commands/intuned-cli/terminal.js +12 -0
- package/dist/commands/run-api-cli/utils.js +6 -6
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/cli/cliReadme.d.ts +1 -1
- package/dist/common/cli/cliReadme.js +14 -23
- package/dist/common/cli/constants.d.ts +4 -2
- package/dist/common/cli/constants.js +7 -3
- package/dist/common/cli/types.d.ts +1 -1
- package/dist/common/cli/utils.d.ts +5 -2
- package/dist/common/cli/utils.js +6 -2
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/getPlaywrightConstructs.js +2 -10
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +5 -6
- package/dist/common/runApi/index.d.ts +3 -0
- package/dist/common/runApi/index.js +21 -21
- package/dist/runtime/executionHelpers.test.js +3 -4
- package/dist/runtime/export.d.ts +15 -0
- package/dist/runtime/extendPayload.js +1 -1
- package/package.json +9 -5
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _command = require("./command");
|
|
7
|
+
Object.keys(_command).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _command[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _command[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _build = require("./build.command");
|
|
18
|
+
Object.keys(_build).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _build[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _build[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _deploy = require("./deploy.command");
|
|
29
|
+
Object.keys(_deploy).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _deploy[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _deploy[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _init = require("./init.command");
|
|
40
|
+
Object.keys(_init).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _init[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _init[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _run = require("./run.command");
|
|
51
|
+
Object.keys(_run).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _run[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _run[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _run_api = require("./run_api.command");
|
|
62
|
+
Object.keys(_run_api).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _run_api[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _run_api[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _run_authsession = require("./run_authsession.command");
|
|
73
|
+
Object.keys(_run_authsession).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _run_authsession[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _run_authsession[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _run_authsession_create = require("./run_authsession_create.command");
|
|
84
|
+
Object.keys(_run_authsession_create).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _run_authsession_create[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _run_authsession_create[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _run_authsession_update = require("./run_authsession_update.command");
|
|
95
|
+
Object.keys(_run_authsession_update).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _run_authsession_update[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _run_authsession_update[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _run_authsession_validate = require("./run_authsession_validate.command");
|
|
106
|
+
Object.keys(_run_authsession_validate).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _run_authsession_validate[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _run_authsession_validate[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _attempt = require("./attempt.command");
|
|
117
|
+
Object.keys(_attempt).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _attempt[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _attempt[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _attempt_api = require("./attempt_api.command");
|
|
128
|
+
Object.keys(_attempt_api).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _attempt_api[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _attempt_api[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
var _attempt_authsession = require("./attempt_authsession.command");
|
|
139
|
+
Object.keys(_attempt_authsession).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _attempt_authsession[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _attempt_authsession[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
var _attempt_authsession_create = require("./attempt_authsession_create.command");
|
|
150
|
+
Object.keys(_attempt_authsession_create).forEach(function (key) {
|
|
151
|
+
if (key === "default" || key === "__esModule") return;
|
|
152
|
+
if (key in exports && exports[key] === _attempt_authsession_create[key]) return;
|
|
153
|
+
Object.defineProperty(exports, key, {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function () {
|
|
156
|
+
return _attempt_authsession_create[key];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
var _attempt_authsession_check = require("./attempt_authsession_check.command");
|
|
161
|
+
Object.keys(_attempt_authsession_check).forEach(function (key) {
|
|
162
|
+
if (key === "default" || key === "__esModule") return;
|
|
163
|
+
if (key in exports && exports[key] === _attempt_authsession_check[key]) return;
|
|
164
|
+
Object.defineProperty(exports, key, {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () {
|
|
167
|
+
return _attempt_authsession_check[key];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const initCommand: import("commander").Command;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initCommand = void 0;
|
|
7
|
+
var _init = require("../controller/init");
|
|
8
|
+
var _command = require("./command");
|
|
9
|
+
var _helpers = require("./helpers");
|
|
10
|
+
const initCommand = exports.initCommand = _command.program.command("init").description("Initialize a new Intuned project from a template").argument("[template-name]", "Name of the template to use").action((0, _helpers.withErrorLogging)(async templateName => {
|
|
11
|
+
const template = await (0, _init.selectTemplate)(templateName);
|
|
12
|
+
const isTargetDirectoryEmpty = await (0, _init.checkEmptyDirectory)();
|
|
13
|
+
await (0, _init.scaffoldProject)(template, isTargetDirectoryEmpty);
|
|
14
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runCommand: import("commander").Command;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runCommand = void 0;
|
|
7
|
+
var _command = require("./command");
|
|
8
|
+
const runCommand = exports.runCommand = _command.program.command("run").description("Execute an Intuned run");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runApiCommand: import("commander").Command;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runApiCommand = void 0;
|
|
7
|
+
var _run = require("./run.command");
|
|
8
|
+
var _api = require("../controller/api");
|
|
9
|
+
var _controller = require("../controller");
|
|
10
|
+
var _zod = require("zod");
|
|
11
|
+
var _types = require("./types");
|
|
12
|
+
var _helpers = require("./helpers");
|
|
13
|
+
const runApiCommandInputSchema = _zod.z.tuple([_zod.z.string().min(1, "API name is required"), _zod.z.string().min(1, "Parameters are required"), _types.baseCommandOptionsSchema.extend({
|
|
14
|
+
retries: _zod.z.coerce.number().default(1),
|
|
15
|
+
authSession: _zod.z.string().optional(),
|
|
16
|
+
authSessionAutoRecreate: _zod.z.boolean().default(true),
|
|
17
|
+
outputFile: _zod.z.string().optional(),
|
|
18
|
+
authSessionCheckAttempts: _types.authSessionCheckAttemptsSchema,
|
|
19
|
+
authSessionCreateAttempts: _types.authSessionCreateAttemptsSchema
|
|
20
|
+
})]);
|
|
21
|
+
const runApiCommand = exports.runApiCommand = _run.runCommand.command("api").description("Execute an Intuned API run with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>").option("--retries <number>", "Number of retries for the API call", "1").option("--proxy <url>", "proxy URL to use").option("--no-auth-session-auto-recreate", "disable auto recreate for auth session").option("--auth-session-check-attempts <number>", "auth session check attempts", "1").option("--auth-session-create-attempts <number>", "auth session create attempts", "1").option("--timeout <time>", "timeout - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").option("-o, --output-file <path>", "output file path").action((0, _helpers.withErrorLogging)(async (inputApiName, inputParameters, inputOptions) => {
|
|
22
|
+
const parseResult = runApiCommandInputSchema.safeParse([inputApiName, inputParameters, inputOptions]);
|
|
23
|
+
if (!parseResult.success) {
|
|
24
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
25
|
+
}
|
|
26
|
+
const [apiName, parameters, {
|
|
27
|
+
retries,
|
|
28
|
+
headless,
|
|
29
|
+
timeout,
|
|
30
|
+
outputFile,
|
|
31
|
+
proxy,
|
|
32
|
+
authSession,
|
|
33
|
+
authSessionAutoRecreate,
|
|
34
|
+
authSessionCreateAttempts,
|
|
35
|
+
authSessionCheckAttempts
|
|
36
|
+
}] = parseResult.data;
|
|
37
|
+
await (0, _helpers.assertAuthConsistent)(authSession);
|
|
38
|
+
const inputData = await (0, _controller.loadParameters)(parameters);
|
|
39
|
+
await (0, _api.executeRunApiCLI)({
|
|
40
|
+
apiName,
|
|
41
|
+
inputData: inputData,
|
|
42
|
+
authSession: authSession ? {
|
|
43
|
+
id: authSession,
|
|
44
|
+
autoRecreate: authSessionAutoRecreate,
|
|
45
|
+
checkRetries: authSessionCheckAttempts,
|
|
46
|
+
createRetries: authSessionCreateAttempts
|
|
47
|
+
} : undefined,
|
|
48
|
+
retries,
|
|
49
|
+
outputFile,
|
|
50
|
+
proxy,
|
|
51
|
+
headless,
|
|
52
|
+
timeout
|
|
53
|
+
});
|
|
54
|
+
}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="ms" />
|
|
2
|
+
export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodObject<{
|
|
3
|
+
proxy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
4
|
+
headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
5
|
+
timeout: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, import("ms").StringValue, string | undefined>, number, string | undefined>;
|
|
6
|
+
checkAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
7
|
+
createAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
8
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
9
|
+
headless: boolean;
|
|
10
|
+
timeout: number;
|
|
11
|
+
checkAttempts: number;
|
|
12
|
+
createAttempts: number;
|
|
13
|
+
proxy?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
proxy?: string | undefined;
|
|
16
|
+
headless?: boolean | undefined;
|
|
17
|
+
timeout?: string | undefined;
|
|
18
|
+
checkAttempts?: number | undefined;
|
|
19
|
+
createAttempts?: number | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const runAuthSessionCommand: import("commander").Command;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runAuthSessionCommand = exports.baseRunAuthSessionCommandOptionsSchema = void 0;
|
|
7
|
+
var _types = require("./types");
|
|
8
|
+
var _run = require("./run.command");
|
|
9
|
+
const baseRunAuthSessionCommandOptionsSchema = exports.baseRunAuthSessionCommandOptionsSchema = _types.baseCommandOptionsSchema.extend({
|
|
10
|
+
checkAttempts: _types.authSessionCheckAttemptsSchema,
|
|
11
|
+
createAttempts: _types.authSessionCreateAttemptsSchema
|
|
12
|
+
});
|
|
13
|
+
const runAuthSessionCommand = exports.runAuthSessionCommand = _run.runCommand.command("authsession").description("Manage authentication sessions");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runAuthSessionCreateCommand: import("commander").Command;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runAuthSessionCreateCommand = void 0;
|
|
7
|
+
var _controller = require("../controller");
|
|
8
|
+
var _zod = require("zod");
|
|
9
|
+
var _authSession = require("../controller/authSession");
|
|
10
|
+
var _run_authsession = require("./run_authsession.command");
|
|
11
|
+
var _helpers = require("./helpers");
|
|
12
|
+
const runAuthSessionCreateInputSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required"), _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
|
|
13
|
+
id: _zod.z.string().optional()
|
|
14
|
+
})]);
|
|
15
|
+
const runAuthSessionCreateCommand = exports.runAuthSessionCreateCommand = _run_authsession.runAuthSessionCommand.command("create").description("Create a new auth session").argument("<parameters>", "Parameters for the auth session command").option("--id <id>", "ID of the auth session to use for the command. Defaults to auth-session-[current timestamp]").option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1").option("--create-attempts <number>", "Number of attempts to create a new auth session if it is invalid", "1").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputParameters, inputOptions) => {
|
|
16
|
+
const parseResult = runAuthSessionCreateInputSchema.safeParse([inputParameters, inputOptions]);
|
|
17
|
+
if (!parseResult.success) {
|
|
18
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
19
|
+
}
|
|
20
|
+
const [parameters, {
|
|
21
|
+
checkAttempts,
|
|
22
|
+
createAttempts,
|
|
23
|
+
id,
|
|
24
|
+
proxy,
|
|
25
|
+
timeout,
|
|
26
|
+
headless
|
|
27
|
+
}] = parseResult.data;
|
|
28
|
+
await (0, _helpers.assertAuthEnabled)();
|
|
29
|
+
const authSessionInput = (await (0, _controller.loadParameters)(parameters)) ?? {};
|
|
30
|
+
await (0, _authSession.executeRunCreateAuthSessionCLI)({
|
|
31
|
+
id,
|
|
32
|
+
checkRetries: checkAttempts,
|
|
33
|
+
createRetries: createAttempts,
|
|
34
|
+
input: authSessionInput,
|
|
35
|
+
headless,
|
|
36
|
+
proxy,
|
|
37
|
+
timeout
|
|
38
|
+
});
|
|
39
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runAuthSessionUpdateCommand: import("commander").Command;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runAuthSessionUpdateCommand = void 0;
|
|
7
|
+
var _controller = require("../controller");
|
|
8
|
+
var _zod = require("zod");
|
|
9
|
+
var _authSession = require("../controller/authSession");
|
|
10
|
+
var _run_authsession = require("./run_authsession.command");
|
|
11
|
+
var _helpers = require("./helpers");
|
|
12
|
+
const runAuthSessionUpdateSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
|
|
13
|
+
parameters: _zod.z.string().optional()
|
|
14
|
+
})]);
|
|
15
|
+
const runAuthSessionUpdateCommand = exports.runAuthSessionUpdateCommand = _run_authsession.runAuthSessionCommand.command("update").description("Update an existing auth session").argument("<id>", "ID of the auth session to update").option("--parameters <parameters>", "Parameters for the auth session command. If not provided, it will use the existing parameters").option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1").option("--create-attempts <number>", "Number of attempts to create a new auth session if it is invalid", "1").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputId, inputOptions) => {
|
|
16
|
+
const parseResult = runAuthSessionUpdateSchema.safeParse([inputId, inputOptions]);
|
|
17
|
+
if (!parseResult.success) {
|
|
18
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
19
|
+
}
|
|
20
|
+
const [id, {
|
|
21
|
+
checkAttempts,
|
|
22
|
+
createAttempts,
|
|
23
|
+
parameters,
|
|
24
|
+
proxy,
|
|
25
|
+
timeout,
|
|
26
|
+
headless
|
|
27
|
+
}] = parseResult.data;
|
|
28
|
+
await (0, _helpers.assertAuthEnabled)();
|
|
29
|
+
const authSessionInput = parameters ? await (0, _controller.loadParameters)(parameters) : undefined;
|
|
30
|
+
await (0, _authSession.executeRunUpdateAuthSessionCLI)({
|
|
31
|
+
id,
|
|
32
|
+
input: authSessionInput,
|
|
33
|
+
checkRetries: checkAttempts,
|
|
34
|
+
createRetries: createAttempts,
|
|
35
|
+
headless,
|
|
36
|
+
proxy,
|
|
37
|
+
timeout
|
|
38
|
+
});
|
|
39
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runAuthSessionValidateCommand: import("commander").Command;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runAuthSessionValidateCommand = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _authSession = require("../controller/authSession");
|
|
9
|
+
var _run_authsession = require("./run_authsession.command");
|
|
10
|
+
var _helpers = require("./helpers");
|
|
11
|
+
const runAuthSessionValidateSchema = _zod.z.tuple([_zod.z.string().min(1, "ID of the auth session is required"), _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
|
|
12
|
+
autoRecreate: _zod.z.boolean().default(true)
|
|
13
|
+
})]);
|
|
14
|
+
const runAuthSessionValidateCommand = exports.runAuthSessionValidateCommand = _run_authsession.runAuthSessionCommand.command("validate").description("Validate an existing auth session").argument("<id>", "ID of the auth session to validate").option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1").option("--create-attempts <number>", "Number of attempts to create a new auth session if it is invalid", "1").option("--proxy <url>", "Proxy URL to use for the auth session command").option("--timeout <time>", "Timeout for the auth session command - milliseconds or ms-formatted string", "10 mins").option("--no-auto-recreate", "Disable auto recreation of the auth session if it is invalid").option("--headless", "Run the API in headless mode (default: false). This will not open a browser window.").action((0, _helpers.withErrorLogging)(async (inputId, inputOptions) => {
|
|
15
|
+
const parseResult = runAuthSessionValidateSchema.safeParse([inputId, inputOptions]);
|
|
16
|
+
if (!parseResult.success) {
|
|
17
|
+
return (0, _helpers.logInvalidInput)(parseResult);
|
|
18
|
+
}
|
|
19
|
+
const [id, {
|
|
20
|
+
autoRecreate,
|
|
21
|
+
checkAttempts,
|
|
22
|
+
createAttempts,
|
|
23
|
+
headless,
|
|
24
|
+
proxy,
|
|
25
|
+
timeout
|
|
26
|
+
}] = parseResult.data;
|
|
27
|
+
await (0, _helpers.assertAuthEnabled)();
|
|
28
|
+
await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
29
|
+
id,
|
|
30
|
+
autoRecreate,
|
|
31
|
+
checkRetries: checkAttempts,
|
|
32
|
+
createRetries: createAttempts,
|
|
33
|
+
headless,
|
|
34
|
+
proxy,
|
|
35
|
+
timeout
|
|
36
|
+
});
|
|
37
|
+
}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ms from "ms";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const authSessionCheckAttemptsSchema: z.ZodDefault<z.ZodNumber>;
|
|
4
|
+
export declare const authSessionCreateAttemptsSchema: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
export declare const proxySchema: z.ZodOptional<z.ZodString>;
|
|
6
|
+
export declare const timeoutSchema: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodString>, ms.StringValue, string | undefined>, number, string | undefined>;
|
|
7
|
+
export declare const headlessSchema: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
export declare const baseCommandOptionsSchema: z.ZodObject<{
|
|
9
|
+
proxy: z.ZodOptional<z.ZodString>;
|
|
10
|
+
timeout: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodString>, ms.StringValue, string | undefined>, number, string | undefined>;
|
|
11
|
+
headless: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
headless: boolean;
|
|
14
|
+
timeout: number;
|
|
15
|
+
proxy?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
proxy?: string | undefined;
|
|
18
|
+
timeout?: string | undefined;
|
|
19
|
+
headless?: boolean | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type BaseCommandOptions = z.infer<typeof baseCommandOptionsSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.timeoutSchema = exports.proxySchema = exports.headlessSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
|
|
7
|
+
var _ms = _interopRequireDefault(require("ms"));
|
|
8
|
+
var _zod = require("zod");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const authSessionCheckAttemptsSchema = exports.authSessionCheckAttemptsSchema = _zod.z.coerce.number().int().min(1, "Auth session check attempts must be at least 1").default(1);
|
|
11
|
+
const authSessionCreateAttemptsSchema = exports.authSessionCreateAttemptsSchema = _zod.z.coerce.number().int().min(1, "Auth session create attempts must be at least 1").default(1);
|
|
12
|
+
const proxySchema = exports.proxySchema = _zod.z.string().url("--proxy must be a valid URL").optional();
|
|
13
|
+
const timeoutSchema = exports.timeoutSchema = _zod.z.string().default("10 mins").refine(val => {
|
|
14
|
+
return (0, _ms.default)(val) !== undefined;
|
|
15
|
+
}, "--timeout must be a valid integer or ms-formatted string").transform(val => (0, _ms.default)(val));
|
|
16
|
+
const headlessSchema = exports.headlessSchema = _zod.z.boolean().default(false);
|
|
17
|
+
const baseCommandOptionsSchema = exports.baseCommandOptionsSchema = _zod.z.object({
|
|
18
|
+
proxy: proxySchema,
|
|
19
|
+
timeout: timeoutSchema,
|
|
20
|
+
headless: headlessSchema
|
|
21
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseCommandOptions } from "../commands/types";
|
|
2
|
+
export declare function executeRunApiCLI({ apiName, inputData, retries, authSession, outputFile, ...rest }: {
|
|
3
|
+
apiName: string;
|
|
4
|
+
inputData: object | null | undefined;
|
|
5
|
+
retries: number;
|
|
6
|
+
authSession?: {
|
|
7
|
+
id: string;
|
|
8
|
+
autoRecreate: boolean;
|
|
9
|
+
checkRetries: number;
|
|
10
|
+
createRetries: number;
|
|
11
|
+
};
|
|
12
|
+
outputFile?: string;
|
|
13
|
+
} & BaseCommandOptions): Promise<void>;
|
|
14
|
+
export declare function executeAttemptApiCLI({ apiName, inputData, authSessionId, outputFile, ...rest }: {
|
|
15
|
+
apiName: string;
|
|
16
|
+
inputData: object | null | undefined;
|
|
17
|
+
authSessionId?: string;
|
|
18
|
+
outputFile?: string;
|
|
19
|
+
} & BaseCommandOptions): Promise<void>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.executeAttemptApiCLI = executeAttemptApiCLI;
|
|
7
|
+
exports.executeRunApiCLI = executeRunApiCLI;
|
|
8
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
9
|
+
var _runApi = require("../../../common/runApi");
|
|
10
|
+
var _tsNodeImport = require("../../common/tsNodeImport");
|
|
11
|
+
var _authSession = require("./authSession");
|
|
12
|
+
var _utils = require("../../cli-auth-sessions/utils");
|
|
13
|
+
var _helpers = require("../commands/helpers");
|
|
14
|
+
var _terminal = require("../terminal");
|
|
15
|
+
var _constants = require("../../../common/constants");
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
async function executeRunApiCLI({
|
|
19
|
+
apiName,
|
|
20
|
+
inputData,
|
|
21
|
+
retries,
|
|
22
|
+
authSession,
|
|
23
|
+
outputFile,
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
|
|
27
|
+
(0, _terminal.terminal)(`^+Running API ^c${apiName}^:\n`);
|
|
28
|
+
const apiResult = await (0, _helpers.withCLIContext)(async () => {
|
|
29
|
+
for (let i = 0; i < retries; i++) {
|
|
30
|
+
(0, _terminal.terminal)(`\n^+Executing ^c${apiName} ^/(Attempt ${i + 1}) ^:...\n`);
|
|
31
|
+
let authSessionPathToUse;
|
|
32
|
+
if (authSession) {
|
|
33
|
+
authSessionPathToUse = await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
34
|
+
...authSession,
|
|
35
|
+
useExistingContext: true,
|
|
36
|
+
...rest
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return await attemptApi({
|
|
41
|
+
apiName,
|
|
42
|
+
inputData,
|
|
43
|
+
auth: authSessionPathToUse ? {
|
|
44
|
+
session: {
|
|
45
|
+
type: "file",
|
|
46
|
+
path: authSessionPathToUse
|
|
47
|
+
},
|
|
48
|
+
runCheck: false
|
|
49
|
+
} : undefined,
|
|
50
|
+
...rest
|
|
51
|
+
});
|
|
52
|
+
} catch (error) {
|
|
53
|
+
(0, _terminal.terminal)(`^r^+Failed to run API ^:^+${apiName}^:: ^R${error.message}^:\n`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})();
|
|
58
|
+
if (apiResult === undefined) {
|
|
59
|
+
throw new _helpers.CLIError(`^r^+Failed to run API ^:^+${apiName}^:: ^RExceeded maximum retries of ^+${retries}^:\n`, {
|
|
60
|
+
autoColor: false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return handleApiResult({
|
|
64
|
+
apiResult,
|
|
65
|
+
outputFile
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function executeAttemptApiCLI({
|
|
69
|
+
apiName,
|
|
70
|
+
inputData,
|
|
71
|
+
authSessionId,
|
|
72
|
+
outputFile,
|
|
73
|
+
...rest
|
|
74
|
+
}) {
|
|
75
|
+
(0, _terminal.terminal)(`^+Execute API attempt for ^c${apiName}^:\n`);
|
|
76
|
+
await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
|
|
77
|
+
let authSessionInstance;
|
|
78
|
+
if (authSessionId) {
|
|
79
|
+
({
|
|
80
|
+
authSessionInstance
|
|
81
|
+
} = await (0, _utils.retrieveAuthSessionInstance)(authSessionId));
|
|
82
|
+
}
|
|
83
|
+
return await (0, _helpers.withCLIContext)(async () => {
|
|
84
|
+
const apiResult = await attemptApi({
|
|
85
|
+
apiName,
|
|
86
|
+
inputData,
|
|
87
|
+
auth: authSessionInstance ? {
|
|
88
|
+
session: {
|
|
89
|
+
type: "state",
|
|
90
|
+
state: authSessionInstance
|
|
91
|
+
},
|
|
92
|
+
runCheck: false
|
|
93
|
+
} : undefined,
|
|
94
|
+
...rest
|
|
95
|
+
});
|
|
96
|
+
return await handleApiResult({
|
|
97
|
+
apiResult,
|
|
98
|
+
outputFile
|
|
99
|
+
});
|
|
100
|
+
})();
|
|
101
|
+
}
|
|
102
|
+
async function handleApiResult({
|
|
103
|
+
apiResult,
|
|
104
|
+
outputFile
|
|
105
|
+
}) {
|
|
106
|
+
const {
|
|
107
|
+
result,
|
|
108
|
+
payloadToAppend
|
|
109
|
+
} = apiResult;
|
|
110
|
+
(0, _terminal.terminal)(`^+^gAPI executed successfully^:\n`);
|
|
111
|
+
if (!outputFile) {
|
|
112
|
+
if (!result) {
|
|
113
|
+
(0, _terminal.terminal)(`^+^yNo result returned from the API^:\n`);
|
|
114
|
+
} else {
|
|
115
|
+
(0, _terminal.terminal)(`^+^gResult:^:\n`);
|
|
116
|
+
(0, _terminal.terminal)(`${JSON.stringify(result, null, 2)}\n`);
|
|
117
|
+
}
|
|
118
|
+
if (payloadToAppend && payloadToAppend.length > 0) {
|
|
119
|
+
(0, _terminal.terminal)(`^+^gExtended payloads:^ ^/^G(This will only take effect if this API run was part of a job.)^:\n:\n`);
|
|
120
|
+
(0, _terminal.terminal)(`${JSON.stringify(payloadToAppend, null, 2)}\n`);
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
await writeResultToFile(outputFile, result, payloadToAppend);
|
|
125
|
+
}
|
|
126
|
+
async function writeResultToFile(outputFile, result, payloadToAppend) {
|
|
127
|
+
const resultToWrite = {
|
|
128
|
+
result
|
|
129
|
+
};
|
|
130
|
+
if (payloadToAppend && payloadToAppend.length > 0) {
|
|
131
|
+
resultToWrite["extendedPayloads"] = payloadToAppend;
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
await fs.writeJSON(outputFile, resultToWrite, {
|
|
135
|
+
spaces: 2
|
|
136
|
+
});
|
|
137
|
+
(0, _terminal.terminal)(`^+^gResults written to^ ^_${outputFile}^:\n`);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new _helpers.CLIError(`Failed to write result to file: ${error.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function attemptApi({
|
|
143
|
+
apiName,
|
|
144
|
+
inputData,
|
|
145
|
+
auth,
|
|
146
|
+
proxy,
|
|
147
|
+
headless,
|
|
148
|
+
timeout
|
|
149
|
+
}) {
|
|
150
|
+
return await (0, _helpers.withTimeout)(async () => {
|
|
151
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
152
|
+
automationFunction: {
|
|
153
|
+
name: `api/${apiName}`,
|
|
154
|
+
params: inputData
|
|
155
|
+
},
|
|
156
|
+
runOptions: {
|
|
157
|
+
headless,
|
|
158
|
+
environment: "standalone",
|
|
159
|
+
proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
|
|
160
|
+
},
|
|
161
|
+
auth,
|
|
162
|
+
importFunction: _tsNodeImport.tsNodeImport
|
|
163
|
+
});
|
|
164
|
+
if (runApiResult.isErr()) {
|
|
165
|
+
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
166
|
+
throw runApiResult.error.error;
|
|
167
|
+
}
|
|
168
|
+
throw new _helpers.CLIError(`An error occurred while running the API: ${runApiResult.error.message}`);
|
|
169
|
+
}
|
|
170
|
+
const {
|
|
171
|
+
result,
|
|
172
|
+
extendedPayloads: payloadToAppend
|
|
173
|
+
} = runApiResult.value;
|
|
174
|
+
return {
|
|
175
|
+
result,
|
|
176
|
+
payloadToAppend
|
|
177
|
+
};
|
|
178
|
+
}, timeout)();
|
|
179
|
+
}
|