@intuned/runtime-dev 1.3.0-dev-52 → 1.3.0-responseLimits.1
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/bin/intuned +2 -0
- package/dist/commands/api/run.js +4 -3
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- 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 +46 -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 +13 -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 +20 -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/constants/index.d.ts +17 -0
- package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
- package/dist/commands/intuned-cli/controller/api.js +181 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
- package/dist/commands/intuned-cli/controller/authSession.js +292 -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/{deploy/utils.js → intuned-cli/controller/deploy.js} +115 -109
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
- package/dist/commands/intuned-cli/helpers/auth.js +129 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +26 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/errors.js +55 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
- package/dist/commands/intuned-cli/helpers/index.js +115 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
- package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +12 -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 +15 -0
- package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -34
- package/dist/{common/cli → commands/intuned-cli}/types.js +1 -2
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +4 -12
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +9 -2
- package/dist/common/runApi/errors.js +21 -8
- package/dist/common/runApi/index.d.ts +4 -1
- package/dist/common/runApi/index.js +33 -21
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- 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 +14 -13
- package/tsconfig.json +2 -1
- package/bin/check-auth-session +0 -3
- package/bin/cli-build +0 -3
- package/bin/create-auth-session +0 -3
- package/bin/deploy +0 -3
- package/bin/init +0 -3
- package/bin/run-api +0 -3
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/check.js +0 -40
- package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/create.js +0 -53
- package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
- package/dist/commands/cli-auth-sessions/utils.js +0 -285
- package/dist/commands/cli-build/cli-build.d.ts +0 -2
- package/dist/commands/cli-build/cli-build.js +0 -20
- package/dist/commands/deploy/deploy.d.ts +0 -2
- package/dist/commands/deploy/deploy.js +0 -47
- package/dist/commands/deploy/utils.d.ts +0 -16
- package/dist/commands/init/init.d.ts +0 -2
- package/dist/commands/init/init.js +0 -22
- package/dist/commands/init/utils.d.ts +0 -11
- package/dist/commands/init/utils.js +0 -181
- package/dist/commands/run-api-cli/run-api.d.ts +0 -2
- package/dist/commands/run-api-cli/run-api.js +0 -57
- package/dist/commands/run-api-cli/utils.d.ts +0 -9
- package/dist/commands/run-api-cli/utils.js +0 -144
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +0 -92
- package/dist/common/cli/constants.d.ts +0 -33
- package/dist/common/cli/constants.js +0 -39
- package/dist/common/cli/utils.d.ts +0 -6
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodObject<{
|
|
2
|
+
proxy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
3
|
+
headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
4
|
+
timeout: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, import("ms").StringValue, string | undefined>, number, string | undefined>;
|
|
5
|
+
checkAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
6
|
+
createAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
7
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
8
|
+
headless: boolean;
|
|
9
|
+
timeout: number;
|
|
10
|
+
checkAttempts: number;
|
|
11
|
+
createAttempts: number;
|
|
12
|
+
proxy?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
proxy?: string | undefined;
|
|
15
|
+
headless?: boolean | undefined;
|
|
16
|
+
timeout?: string | undefined;
|
|
17
|
+
checkAttempts?: number | undefined;
|
|
18
|
+
createAttempts?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
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,17 @@
|
|
|
1
|
+
export declare const CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
2
|
+
export declare const ProjectDeploymentStatus: readonly ["completed", "failed", "pending", "not_found"];
|
|
3
|
+
export declare const PROJECT_DEPLOY_TIMEOUT: number;
|
|
4
|
+
export declare const PROJECT_DEPLOY_CHECK_PERIOD: number;
|
|
5
|
+
export declare const tsConfigCli: {
|
|
6
|
+
compilerOptions: {
|
|
7
|
+
moduleResolution: string;
|
|
8
|
+
module: string;
|
|
9
|
+
target: string;
|
|
10
|
+
outDir: string;
|
|
11
|
+
sourceMap: boolean;
|
|
12
|
+
declaration: boolean;
|
|
13
|
+
esModuleInterop: boolean;
|
|
14
|
+
};
|
|
15
|
+
include: string[];
|
|
16
|
+
exclude: string[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_CHECK_PERIOD = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
|
|
7
|
+
var _ms = _interopRequireDefault(require("ms"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
10
|
+
const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
|
|
11
|
+
const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = (0, _ms.default)("10 minutes");
|
|
12
|
+
const PROJECT_DEPLOY_CHECK_PERIOD = exports.PROJECT_DEPLOY_CHECK_PERIOD = (0, _ms.default)("5 seconds");
|
|
13
|
+
const tsConfigCli = exports.tsConfigCli = {
|
|
14
|
+
compilerOptions: {
|
|
15
|
+
moduleResolution: "NodeNext",
|
|
16
|
+
module: "NodeNext",
|
|
17
|
+
target: "ES2021",
|
|
18
|
+
outDir: "./dist",
|
|
19
|
+
sourceMap: false,
|
|
20
|
+
declaration: true,
|
|
21
|
+
esModuleInterop: true
|
|
22
|
+
},
|
|
23
|
+
include: ["**/*.ts"],
|
|
24
|
+
exclude: ["node_modules", "dist"]
|
|
25
|
+
};
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _api = require("../api");
|
|
5
|
+
var _authSession = require("../authSession");
|
|
6
|
+
var _helpers = require("../../helpers");
|
|
7
|
+
var _neverthrow = require("neverthrow");
|
|
8
|
+
var _runApi = require("../../../../common/runApi");
|
|
9
|
+
var _fsExtra = require("fs-extra");
|
|
10
|
+
function getTerminal() {
|
|
11
|
+
return new Proxy(() => ({}), {
|
|
12
|
+
get: () => getTerminal(),
|
|
13
|
+
apply: () => ({})
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_vitest.vi.mock("fs-extra", () => ({
|
|
17
|
+
writeJSON: _vitest.vi.fn()
|
|
18
|
+
}));
|
|
19
|
+
_vitest.vi.mock("../authSession", async importOriginal => {
|
|
20
|
+
const original = await importOriginal();
|
|
21
|
+
return {
|
|
22
|
+
...original,
|
|
23
|
+
executeRunValidateAuthSessionCLI: _vitest.vi.fn()
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
_vitest.vi.mock("../../../../common/runApi", async importOriginal => {
|
|
27
|
+
const original = await importOriginal();
|
|
28
|
+
return {
|
|
29
|
+
...original,
|
|
30
|
+
runApi: _vitest.vi.fn().mockImplementation(() => (0, _neverthrow.ok)({}))
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
_vitest.vi.mock("../../helpers/terminal", () => ({
|
|
34
|
+
terminal: getTerminal()
|
|
35
|
+
}));
|
|
36
|
+
_vitest.vi.mock("../../helpers", async importOriginal => {
|
|
37
|
+
const original = await importOriginal();
|
|
38
|
+
return {
|
|
39
|
+
...original,
|
|
40
|
+
terminal: getTerminal(),
|
|
41
|
+
assertApiFileExists: _vitest.vi.fn(),
|
|
42
|
+
withCLIContext: _vitest.vi.fn(fn => fn()),
|
|
43
|
+
withTimeout: _vitest.vi.fn(fn => fn()),
|
|
44
|
+
parseUrlProxy: _vitest.vi.fn(),
|
|
45
|
+
registerGetAuthSessionParameters: _vitest.vi.fn()
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
(0, _vitest.describe)("API controller", () => {
|
|
49
|
+
(0, _vitest.beforeEach)(() => {
|
|
50
|
+
_vitest.vi.clearAllMocks();
|
|
51
|
+
});
|
|
52
|
+
(0, _vitest.describe)("attemptApi", () => {
|
|
53
|
+
(0, _vitest.it)("calls timeout middleware with timeout", async () => {
|
|
54
|
+
await (0, _api._attemptApi)({
|
|
55
|
+
apiName: "testApi",
|
|
56
|
+
inputData: {},
|
|
57
|
+
headless: false,
|
|
58
|
+
timeout: 6000
|
|
59
|
+
});
|
|
60
|
+
(0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
|
|
61
|
+
});
|
|
62
|
+
(0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
|
|
63
|
+
_vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
|
|
64
|
+
await (0, _api._attemptApi)({
|
|
65
|
+
apiName: "testApi",
|
|
66
|
+
inputData: "inputData",
|
|
67
|
+
headless: "headless",
|
|
68
|
+
auth: "auth",
|
|
69
|
+
proxy: "proxy",
|
|
70
|
+
timeout: 999999999
|
|
71
|
+
});
|
|
72
|
+
(0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
|
|
73
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
74
|
+
automationFunction: {
|
|
75
|
+
name: "api/testApi",
|
|
76
|
+
params: "inputData"
|
|
77
|
+
},
|
|
78
|
+
runOptions: {
|
|
79
|
+
headless: "headless",
|
|
80
|
+
environment: "standalone",
|
|
81
|
+
proxy: "parsed-proxy"
|
|
82
|
+
},
|
|
83
|
+
auth: {
|
|
84
|
+
session: {
|
|
85
|
+
type: "state",
|
|
86
|
+
state: "auth"
|
|
87
|
+
},
|
|
88
|
+
runCheck: false
|
|
89
|
+
},
|
|
90
|
+
importFunction: _vitest.expect.anything()
|
|
91
|
+
}));
|
|
92
|
+
});
|
|
93
|
+
(0, _vitest.it)("returns the result and extended payloads if runApi succeeds", async () => {
|
|
94
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.ok)({
|
|
95
|
+
result: "result",
|
|
96
|
+
extendedPayloads: "extendedPayloads"
|
|
97
|
+
}));
|
|
98
|
+
const result = await (0, _api._attemptApi)({
|
|
99
|
+
apiName: "testApi",
|
|
100
|
+
inputData: "inputData",
|
|
101
|
+
headless: "headless",
|
|
102
|
+
auth: "auth",
|
|
103
|
+
timeout: 999999999
|
|
104
|
+
});
|
|
105
|
+
(0, _vitest.expect)(result).toEqual({
|
|
106
|
+
result: "result",
|
|
107
|
+
payloadToAppend: "extendedPayloads"
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
(0, _vitest.it)("throws the error runApi fails with an error", async () => {
|
|
111
|
+
const error = new Error("runApi failed");
|
|
112
|
+
_vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
|
|
113
|
+
await (0, _vitest.expect)((0, _api._attemptApi)({
|
|
114
|
+
apiName: "testApi",
|
|
115
|
+
inputData: "inputData",
|
|
116
|
+
headless: "headless",
|
|
117
|
+
auth: "auth",
|
|
118
|
+
timeout: 999999999
|
|
119
|
+
})).rejects.toThrow(error);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
(0, _vitest.describe)("executeRunApiCLI", () => {
|
|
123
|
+
(0, _vitest.it)("calls attemptApi once if success", async () => {
|
|
124
|
+
await (0, _api.executeRunApiCLI)({
|
|
125
|
+
apiName: "testApi",
|
|
126
|
+
inputData: {},
|
|
127
|
+
retries: 3
|
|
128
|
+
});
|
|
129
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
130
|
+
});
|
|
131
|
+
(0, _vitest.it)("stops retrying after max retries", async () => {
|
|
132
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
|
|
133
|
+
await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
|
|
134
|
+
apiName: "testApi",
|
|
135
|
+
inputData: {},
|
|
136
|
+
retries: 10
|
|
137
|
+
})).rejects.toThrow(_helpers.CLIError);
|
|
138
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(10);
|
|
139
|
+
});
|
|
140
|
+
(0, _vitest.it)("stops retrying on non-automation errors", async () => {
|
|
141
|
+
_vitest.vi.mocked(_runApi.runApi).mockRejectedValue(new Error("runApi failed"));
|
|
142
|
+
await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
|
|
143
|
+
apiName: "testApi",
|
|
144
|
+
inputData: {},
|
|
145
|
+
retries: 3
|
|
146
|
+
})).rejects.toThrow("runApi failed");
|
|
147
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
148
|
+
});
|
|
149
|
+
(0, _vitest.it)("stops retrying on success", async () => {
|
|
150
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
|
|
151
|
+
result: "success"
|
|
152
|
+
}));
|
|
153
|
+
await (0, _api.executeRunApiCLI)({
|
|
154
|
+
apiName: "testApi",
|
|
155
|
+
inputData: {},
|
|
156
|
+
retries: 10
|
|
157
|
+
});
|
|
158
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
|
|
159
|
+
});
|
|
160
|
+
(0, _vitest.it)("validates auth session before each attempt if provided", async () => {
|
|
161
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
|
|
162
|
+
result: "success"
|
|
163
|
+
}));
|
|
164
|
+
await (0, _api.executeRunApiCLI)({
|
|
165
|
+
apiName: "testApi",
|
|
166
|
+
inputData: {},
|
|
167
|
+
authSession: {
|
|
168
|
+
id: "authSessionId",
|
|
169
|
+
autoRecreate: false,
|
|
170
|
+
checkRetries: 1,
|
|
171
|
+
createRetries: 2
|
|
172
|
+
},
|
|
173
|
+
retries: 10
|
|
174
|
+
});
|
|
175
|
+
(0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toBeCalledTimes(2);
|
|
176
|
+
(0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith({
|
|
177
|
+
id: "authSessionId",
|
|
178
|
+
autoRecreate: false,
|
|
179
|
+
checkRetries: 1,
|
|
180
|
+
createRetries: 2
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
(0, _vitest.it)("doesn't validate auth session if not provided", async () => {
|
|
184
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
|
|
185
|
+
result: "success"
|
|
186
|
+
}));
|
|
187
|
+
await (0, _api.executeRunApiCLI)({
|
|
188
|
+
apiName: "testApi",
|
|
189
|
+
inputData: {},
|
|
190
|
+
retries: 1
|
|
191
|
+
});
|
|
192
|
+
(0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).not.toHaveBeenCalled();
|
|
193
|
+
});
|
|
194
|
+
(0, _vitest.it)("fails if auth session is provided but not valid", async () => {
|
|
195
|
+
_vitest.vi.mocked(_authSession.executeRunValidateAuthSessionCLI).mockRejectedValue(new _helpers.CLIError("Auth session validation failed"));
|
|
196
|
+
await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
|
|
197
|
+
apiName: "testApi",
|
|
198
|
+
inputData: {},
|
|
199
|
+
authSession: {
|
|
200
|
+
id: "authSessionId",
|
|
201
|
+
autoRecreate: false,
|
|
202
|
+
checkRetries: 1,
|
|
203
|
+
createRetries: 2
|
|
204
|
+
},
|
|
205
|
+
retries: 10
|
|
206
|
+
})).rejects.toThrow("Auth session validation failed");
|
|
207
|
+
(0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith({
|
|
208
|
+
id: "authSessionId",
|
|
209
|
+
autoRecreate: false,
|
|
210
|
+
checkRetries: 1,
|
|
211
|
+
createRetries: 2
|
|
212
|
+
});
|
|
213
|
+
(0, _vitest.expect)(_runApi.runApi).not.toHaveBeenCalled();
|
|
214
|
+
});
|
|
215
|
+
(0, _vitest.it)("writes result to file if outputFile is provided", async () => {
|
|
216
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
|
|
217
|
+
result: "result",
|
|
218
|
+
extendedPayloads: "extendedPayloads"
|
|
219
|
+
}));
|
|
220
|
+
await (0, _api.executeRunApiCLI)({
|
|
221
|
+
apiName: "testApi",
|
|
222
|
+
inputData: {},
|
|
223
|
+
outputFile: "output.json",
|
|
224
|
+
retries: 1
|
|
225
|
+
});
|
|
226
|
+
(0, _vitest.expect)(_fsExtra.writeJSON).toHaveBeenCalledWith("output.json", {
|
|
227
|
+
result: "result",
|
|
228
|
+
extendedPayloads: "extendedPayloads"
|
|
229
|
+
}, _vitest.expect.anything());
|
|
230
|
+
});
|
|
231
|
+
(0, _vitest.it)("asserts API file exists", async () => {
|
|
232
|
+
await (0, _api.executeRunApiCLI)({
|
|
233
|
+
apiName: "testApi",
|
|
234
|
+
inputData: {},
|
|
235
|
+
retries: 1
|
|
236
|
+
});
|
|
237
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("api", "testApi");
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
(0, _vitest.describe)("executeAttemptApiCLI", () => {
|
|
241
|
+
(0, _vitest.it)("calls attemptApi once", async () => {
|
|
242
|
+
await (0, _api.executeAttemptApiCLI)({
|
|
243
|
+
apiName: "testApi",
|
|
244
|
+
inputData: {},
|
|
245
|
+
retries: 3
|
|
246
|
+
});
|
|
247
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
248
|
+
_vitest.vi.mocked(_runApi.runApi).mockReset();
|
|
249
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
|
|
250
|
+
await (0, _vitest.expect)((0, _api.executeAttemptApiCLI)({
|
|
251
|
+
apiName: "testApi",
|
|
252
|
+
inputData: {}
|
|
253
|
+
})).rejects.toThrow(_runApi.AutomationError);
|
|
254
|
+
(0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
|
|
255
|
+
});
|
|
256
|
+
(0, _vitest.it)("writes result to file if outputFile is provided", async () => {
|
|
257
|
+
_vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
|
|
258
|
+
result: "result",
|
|
259
|
+
extendedPayloads: "extendedPayloads"
|
|
260
|
+
}));
|
|
261
|
+
await (0, _api.executeAttemptApiCLI)({
|
|
262
|
+
apiName: "testApi",
|
|
263
|
+
inputData: {},
|
|
264
|
+
outputFile: "output.json"
|
|
265
|
+
});
|
|
266
|
+
(0, _vitest.expect)(_fsExtra.writeJSON).toHaveBeenCalledWith("output.json", {
|
|
267
|
+
result: "result",
|
|
268
|
+
extendedPayloads: "extendedPayloads"
|
|
269
|
+
}, _vitest.expect.anything());
|
|
270
|
+
});
|
|
271
|
+
(0, _vitest.it)("asserts API file exists", async () => {
|
|
272
|
+
await (0, _api.executeRunApiCLI)({
|
|
273
|
+
apiName: "testApi",
|
|
274
|
+
inputData: {},
|
|
275
|
+
retries: 1
|
|
276
|
+
});
|
|
277
|
+
(0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("api", "testApi");
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|