@intuned/runtime 1.1.6 → 1.2.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/.npmrc.d +1 -0
- package/CHANGELOG.md +5 -1
- package/WebTemplate.zip +0 -0
- package/bin/intuned +2 -0
- package/dist/commands/api/run.js +2 -1
- 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 +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 +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/{common/cli/constants.d.ts → commands/intuned-cli/constants/index.d.ts} +5 -6
- package/dist/{common/cli/constants.js → commands/intuned-cli/constants/index.js} +27 -7
- package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
- package/dist/commands/intuned-cli/constants/readme.js +150 -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} +114 -107
- 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/controller/init.d.ts +5 -0
- package/dist/commands/intuned-cli/controller/init.js +136 -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 +2 -33
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/runApi/index.d.ts +3 -0
- package/dist/common/runApi/index.js +0 -1
- package/dist/common/runApi/types.d.ts +142 -11
- package/dist/common/runApi/types.js +28 -27
- package/package.json +9 -10
- 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 -284
- 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 -175
- 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/utils.d.ts +0 -6
- /package/dist/{common/cli → commands/intuned-cli}/types.js +0 -0
|
@@ -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
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
2
|
-
export declare const ProjectDeploymentStatus:
|
|
3
|
-
export declare const PROJECT_DEPLOY_TIMEOUT
|
|
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;
|
|
4
5
|
export declare const userCLIScripts: {
|
|
5
6
|
"dev:local": string;
|
|
6
7
|
dev: string;
|
|
@@ -9,15 +10,12 @@ export declare const userCLIScripts: {
|
|
|
9
10
|
"pre-publish": string;
|
|
10
11
|
start: string;
|
|
11
12
|
"run-api": string;
|
|
12
|
-
"cli-build": string;
|
|
13
|
-
deploy: string;
|
|
14
|
-
"cli-create-auth-session": string;
|
|
15
|
-
"cli-check-auth-session": string;
|
|
16
13
|
"browser-save-state": string;
|
|
17
14
|
"auth-session-check": string;
|
|
18
15
|
"auth-session-create": string;
|
|
19
16
|
"auth-session-refresh": string;
|
|
20
17
|
"auth-session-load": string;
|
|
18
|
+
intuned: string;
|
|
21
19
|
};
|
|
22
20
|
export declare const tsConfigCli: {
|
|
23
21
|
compilerOptions: {
|
|
@@ -32,3 +30,4 @@ export declare const tsConfigCli: {
|
|
|
32
30
|
include: string[];
|
|
33
31
|
exclude: string[];
|
|
34
32
|
};
|
|
33
|
+
export * from "./readme";
|
|
@@ -3,10 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
CURRENT_PLAYWRIGHT_VERSION: true,
|
|
8
|
+
ProjectDeploymentStatus: true,
|
|
9
|
+
PROJECT_DEPLOY_TIMEOUT: true,
|
|
10
|
+
PROJECT_DEPLOY_CHECK_PERIOD: true,
|
|
11
|
+
userCLIScripts: true,
|
|
12
|
+
tsConfigCli: true
|
|
13
|
+
};
|
|
14
|
+
exports.userCLIScripts = exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_CHECK_PERIOD = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
|
|
15
|
+
var _ms = _interopRequireDefault(require("ms"));
|
|
16
|
+
var _readme = require("./readme");
|
|
17
|
+
Object.keys(_readme).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _readme[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _readme[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
29
|
const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
8
30
|
const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
|
|
9
|
-
const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT =
|
|
31
|
+
const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = (0, _ms.default)("10 minutes");
|
|
32
|
+
const PROJECT_DEPLOY_CHECK_PERIOD = exports.PROJECT_DEPLOY_CHECK_PERIOD = (0, _ms.default)("5 seconds");
|
|
10
33
|
const userCLIScripts = exports.userCLIScripts = {
|
|
11
34
|
"dev:local": "intuned-api-run sample playwright -j '{}'",
|
|
12
35
|
dev: "intuned-api-run",
|
|
@@ -15,15 +38,12 @@ const userCLIScripts = exports.userCLIScripts = {
|
|
|
15
38
|
"pre-publish": "intuned-ts-check && intuned-build",
|
|
16
39
|
start: "node ./output/bundle_v2.js",
|
|
17
40
|
"run-api": "run-api",
|
|
18
|
-
"cli-build": "cli-build",
|
|
19
|
-
deploy: "deploy",
|
|
20
|
-
"cli-create-auth-session": "create-auth-session",
|
|
21
|
-
"cli-check-auth-session": "check-auth-session",
|
|
22
41
|
"browser-save-state": "intuned-browser-save-state",
|
|
23
42
|
"auth-session-check": "intuned-auth-session-check",
|
|
24
43
|
"auth-session-create": "intuned-auth-session-create",
|
|
25
44
|
"auth-session-refresh": "intuned-auth-session-refresh",
|
|
26
|
-
"auth-session-load": "intuned-auth-session-load"
|
|
45
|
+
"auth-session-load": "intuned-auth-session-load",
|
|
46
|
+
intuned: "intuned"
|
|
27
47
|
};
|
|
28
48
|
const tsConfigCli = exports.tsConfigCli = {
|
|
29
49
|
compilerOptions: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readme = "# Intuned CLI\n## Development Commands\n\nFor each command, add `--help` to see more details and options.\n\n### Initialize a Project\n`npx -p @intuned/runtime intuned init`\n\n### Run an API\n`yarn intuned run api <api-name> <parameters>`\nor\n`npm run intuned run api <api-name> <parameters>`\n\n\n### Build a Project\n`yarn intuned build`\n\n### Deploy a Project\n`yarn intuned deploy [project-name]`\nor\n`npm run intuned deploy [project-name]`\n\n\n\n### Create an auth session\n`yarn intuned run authsession create <parameters>`\nor\n`npm run intuned run authsession create <parameters>`\n\n\n\n### Validate an auth session\n`yarn intuned run authsession validate <auth-session-name>`\nor\n`npm run intuned run authsession validate <auth-session-name>`\n\n## Configuration\n\n### Environment Variables and Settings\n- `workspaceId`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))\n - Set in `intuned.json` file under the `workspaceId` property\n - Or provide via CLI with `--workspace-id` flag during deployment\n \n- `projectName`: The name of your Intuned project\n - Set in `intuned.json` file under the `projectName` property\n - Or override via command line when deploying with `yarn intuned deploy my-project-name` or `npm run intuned deploy my-project-name`\n\n- `INTUNED_API_KEY`: Your Intuned API key\n - Set as an environment variable: `export INTUNED_API_KEY=your_api_key_here`\n - Or include in your .env file for development\n - Or provide via CLI with `--api-key` flag during deployment\n\n## Project Structure\n\n### Generated Artifacts\n- `./intuned.json`: Project configuration file\n- `./api`: Folder containing API implementation files\n- `./auth-sessions`: Folder containing auth-session APIs if you use them\n- `./auth-sessions-instances`: Folder containing auth session instances\n\n## Types of auth sessions\n- `MANUAL`: Manual auth session, records the session using a recorder and stores it in the `auth-sessions-instances` folder\n- `API`: Auth session created via create API, stores the session in the `auth-sessions-instances` folder\n\n### Notes\n- You can use either `yarn` or `npm run` to execute commands\n- All commands must be run from the project root directory\n- Verify you're in the correct location by confirming the presence of package.json and intuned.json\n- Running commands from subdirectories may result in errors\n- You can manage your deployed projects through the Intuned platform\n- \u26A0\uFE0F WARNING: Changes to TS Config may break some Intuned functionalities\n\n## `Intuned.json` Reference\n```jsonc\n{\n // Your Intuned workspace ID. \n // Optional - If not provided here, it must be supplied via the `--workspace-id` flag during deployment.\n \"workspaceId\": \"your_workspace_id\",\n\n // The name of your Intuned project. \n // Optional - If not provided here, it must be supplied via the command line when deploying.\n \"projectName\": \"your_project_name\",\n\n // Replication settings\n \"replication\": {\n // The maximum number of concurrent executions allowed via Intuned API. This does not affect jobs.\n // A number of machines equal to this will be allocated to handle API requests.\n // Not applicable if api access is disabled.\n \"maxConcurrentRequests\": 1,\n\n // The machine size to use for this project. This is applicable for both API requests and jobs.\n // \"standard\": Standard machine size (6 shared vCPUs, 2GB RAM)\n // \"large\": Large machine size (8 shared vCPUs, 4GB RAM)\n // \"xlarge\": Extra large machine size (1 performance vCPU, 8GB RAM)\n \"size\": \"standard\"\n }\n\n // Auth session settings\n \"authSessions\": {\n // Whether auth sessions are enabled for this project.\n // If enabled, \"auth-sessions/check.ts\" API must be implemented to validate the auth session.\n \"enabled\": true,\n\n // Whether to save Playwright traces for auth session runs.\n \"saveTraces\": false,\n\n // The type of auth session to use.\n // \"API\" type requires implementing \"auth-sessions/create.ts\" API to create/recreate the auth session programmatically.\n // \"MANUAL\" type uses a recorder to manually create the auth session.\n \"type\": \"API\",\n \n\n // Recorder start URL for the recorder to navigate to when creating the auth session.\n // Required if \"type\" is \"MANUAL\". Not used if \"type\" is \"API\".\n \"startUrl\": \"https://example.com/login\",\n\n // Recorder finish URL for the recorder. Once this URL is reached, the recorder stops and saves the auth session.\n // Required if \"type\" is \"MANUAL\". Not used if \"type\" is \"API\".\n \"finishUrl\": \"https://example.com/dashboard\",\n\n // Recorder browser mode\n // \"fullscreen\": Launches the browser in fullscreen mode.\n // \"kiosk\": Launches the browser in kiosk mode (no address bar, no navigation controls).\n // Only applicable for \"MANUAL\" type.\n \"browserMode\": \"fullscreen\"\n }\n \n // API access settings\n \"apiAccess\": {\n // Whether to enable consumption through Intuned API. If this is false, the project can only be consumed through jobs.\n // This is required for projects that use auth sessions.\n \"enabled\": true\n },\n\n // Whether to run the deployed API in a headful browser. Running in headful can help with some anti-bot detections. However, it requires more resources and may work slower or crash if the machine size is \"standard\".\n \"headful\": false,\n\n // The region where your Intuned project is hosted.\n // For a list of available regions, contact support or refer to the documentation.\n // Optional - Default: \"us\"\n \"region\": \"us\"\n}\n```\n";
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.readme = void 0;
|
|
7
|
+
const readme = exports.readme = `# Intuned CLI
|
|
8
|
+
## Development Commands
|
|
9
|
+
|
|
10
|
+
For each command, add \`--help\` to see more details and options.
|
|
11
|
+
|
|
12
|
+
### Initialize a Project
|
|
13
|
+
\`npx -p @intuned/runtime intuned init\`
|
|
14
|
+
|
|
15
|
+
### Run an API
|
|
16
|
+
\`yarn intuned run api <api-name> <parameters>\`
|
|
17
|
+
or
|
|
18
|
+
\`npm run intuned run api <api-name> <parameters>\`
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Build a Project
|
|
22
|
+
\`yarn intuned build\`
|
|
23
|
+
|
|
24
|
+
### Deploy a Project
|
|
25
|
+
\`yarn intuned deploy [project-name]\`
|
|
26
|
+
or
|
|
27
|
+
\`npm run intuned deploy [project-name]\`
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Create an auth session
|
|
32
|
+
\`yarn intuned run authsession create <parameters>\`
|
|
33
|
+
or
|
|
34
|
+
\`npm run intuned run authsession create <parameters>\`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Validate an auth session
|
|
39
|
+
\`yarn intuned run authsession validate <auth-session-name>\`
|
|
40
|
+
or
|
|
41
|
+
\`npm run intuned run authsession validate <auth-session-name>\`
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
### Environment Variables and Settings
|
|
46
|
+
- \`workspaceId\`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))
|
|
47
|
+
- Set in \`intuned.json\` file under the \`workspaceId\` property
|
|
48
|
+
- Or provide via CLI with \`--workspace-id\` flag during deployment
|
|
49
|
+
|
|
50
|
+
- \`projectName\`: The name of your Intuned project
|
|
51
|
+
- Set in \`intuned.json\` file under the \`projectName\` property
|
|
52
|
+
- Or override via command line when deploying with \`yarn intuned deploy my-project-name\` or \`npm run intuned deploy my-project-name\`
|
|
53
|
+
|
|
54
|
+
- \`INTUNED_API_KEY\`: Your Intuned API key
|
|
55
|
+
- Set as an environment variable: \`export INTUNED_API_KEY=your_api_key_here\`
|
|
56
|
+
- Or include in your .env file for development
|
|
57
|
+
- Or provide via CLI with \`--api-key\` flag during deployment
|
|
58
|
+
|
|
59
|
+
## Project Structure
|
|
60
|
+
|
|
61
|
+
### Generated Artifacts
|
|
62
|
+
- \`./intuned.json\`: Project configuration file
|
|
63
|
+
- \`./api\`: Folder containing API implementation files
|
|
64
|
+
- \`./auth-sessions\`: Folder containing auth-session APIs if you use them
|
|
65
|
+
- \`./auth-sessions-instances\`: Folder containing auth session instances
|
|
66
|
+
|
|
67
|
+
## Types of auth sessions
|
|
68
|
+
- \`MANUAL\`: Manual auth session, records the session using a recorder and stores it in the \`auth-sessions-instances\` folder
|
|
69
|
+
- \`API\`: Auth session created via create API, stores the session in the \`auth-sessions-instances\` folder
|
|
70
|
+
|
|
71
|
+
### Notes
|
|
72
|
+
- You can use either \`yarn\` or \`npm run\` to execute commands
|
|
73
|
+
- All commands must be run from the project root directory
|
|
74
|
+
- Verify you're in the correct location by confirming the presence of package.json and intuned.json
|
|
75
|
+
- Running commands from subdirectories may result in errors
|
|
76
|
+
- You can manage your deployed projects through the Intuned platform
|
|
77
|
+
- ⚠️ WARNING: Changes to TS Config may break some Intuned functionalities
|
|
78
|
+
|
|
79
|
+
## \`Intuned.json\` Reference
|
|
80
|
+
\`\`\`jsonc
|
|
81
|
+
{
|
|
82
|
+
// Your Intuned workspace ID.
|
|
83
|
+
// Optional - If not provided here, it must be supplied via the \`--workspace-id\` flag during deployment.
|
|
84
|
+
"workspaceId": "your_workspace_id",
|
|
85
|
+
|
|
86
|
+
// The name of your Intuned project.
|
|
87
|
+
// Optional - If not provided here, it must be supplied via the command line when deploying.
|
|
88
|
+
"projectName": "your_project_name",
|
|
89
|
+
|
|
90
|
+
// Replication settings
|
|
91
|
+
"replication": {
|
|
92
|
+
// The maximum number of concurrent executions allowed via Intuned API. This does not affect jobs.
|
|
93
|
+
// A number of machines equal to this will be allocated to handle API requests.
|
|
94
|
+
// Not applicable if api access is disabled.
|
|
95
|
+
"maxConcurrentRequests": 1,
|
|
96
|
+
|
|
97
|
+
// The machine size to use for this project. This is applicable for both API requests and jobs.
|
|
98
|
+
// "standard": Standard machine size (6 shared vCPUs, 2GB RAM)
|
|
99
|
+
// "large": Large machine size (8 shared vCPUs, 4GB RAM)
|
|
100
|
+
// "xlarge": Extra large machine size (1 performance vCPU, 8GB RAM)
|
|
101
|
+
"size": "standard"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Auth session settings
|
|
105
|
+
"authSessions": {
|
|
106
|
+
// Whether auth sessions are enabled for this project.
|
|
107
|
+
// If enabled, "auth-sessions/check.ts" API must be implemented to validate the auth session.
|
|
108
|
+
"enabled": true,
|
|
109
|
+
|
|
110
|
+
// Whether to save Playwright traces for auth session runs.
|
|
111
|
+
"saveTraces": false,
|
|
112
|
+
|
|
113
|
+
// The type of auth session to use.
|
|
114
|
+
// "API" type requires implementing "auth-sessions/create.ts" API to create/recreate the auth session programmatically.
|
|
115
|
+
// "MANUAL" type uses a recorder to manually create the auth session.
|
|
116
|
+
"type": "API",
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Recorder start URL for the recorder to navigate to when creating the auth session.
|
|
120
|
+
// Required if "type" is "MANUAL". Not used if "type" is "API".
|
|
121
|
+
"startUrl": "https://example.com/login",
|
|
122
|
+
|
|
123
|
+
// Recorder finish URL for the recorder. Once this URL is reached, the recorder stops and saves the auth session.
|
|
124
|
+
// Required if "type" is "MANUAL". Not used if "type" is "API".
|
|
125
|
+
"finishUrl": "https://example.com/dashboard",
|
|
126
|
+
|
|
127
|
+
// Recorder browser mode
|
|
128
|
+
// "fullscreen": Launches the browser in fullscreen mode.
|
|
129
|
+
// "kiosk": Launches the browser in kiosk mode (no address bar, no navigation controls).
|
|
130
|
+
// Only applicable for "MANUAL" type.
|
|
131
|
+
"browserMode": "fullscreen"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// API access settings
|
|
135
|
+
"apiAccess": {
|
|
136
|
+
// Whether to enable consumption through Intuned API. If this is false, the project can only be consumed through jobs.
|
|
137
|
+
// This is required for projects that use auth sessions.
|
|
138
|
+
"enabled": true
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
// Whether to run the deployed API in a headful browser. Running in headful can help with some anti-bot detections. However, it requires more resources and may work slower or crash if the machine size is "standard".
|
|
142
|
+
"headful": false,
|
|
143
|
+
|
|
144
|
+
// The region where your Intuned project is hosted.
|
|
145
|
+
// For a list of available regions, contact support or refer to the documentation.
|
|
146
|
+
// Optional - Default: "us"
|
|
147
|
+
"region": "us"
|
|
148
|
+
}
|
|
149
|
+
\`\`\`
|
|
150
|
+
`;
|
|
@@ -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
|
+
});
|