@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
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const cliReadme = "# Intuned CLI\n## Introduction\nThe Intuned CLI exposes a
|
|
1
|
+
export declare const cliReadme = "# Intuned CLI\n## Introduction\nThe Intuned CLI exposes a variety of commands to develop your Intuned projects locally\n\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 init`\n\n### Run an API\n`yarn intuned run <api-name>`\nor\n`npm run intuned run <api-name>`\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 authsession create <parameters>`\nor\n`npm intuned authsession create <parameters>`\n\n\n\n### Validate an auth session\n`yarn intuned authsession validate <auth-session-name>`\nor\n`npm intuned 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 deploy my-project-name` or `npm run 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 APIs\n- `./parameters`: Folder for API parameters injection\n- `./output`: Folder containing generated output files\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- WARNING: \u26A0\uFE0F Changes to TS Config may break some Intuned functionalities\n";
|
|
@@ -6,51 +6,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.cliReadme = void 0;
|
|
7
7
|
const cliReadme = exports.cliReadme = `# Intuned CLI
|
|
8
8
|
## Introduction
|
|
9
|
-
The Intuned CLI exposes a
|
|
9
|
+
The Intuned CLI exposes a variety of commands to develop your Intuned projects locally
|
|
10
10
|
|
|
11
11
|
## Development Commands
|
|
12
12
|
|
|
13
|
+
For each command, add \`--help\` to see more details and options.
|
|
14
|
+
|
|
13
15
|
### Initialize a Project
|
|
14
16
|
\`npx -p @intuned/runtime init\`
|
|
15
17
|
|
|
16
18
|
### Run an API
|
|
17
|
-
\`yarn run
|
|
19
|
+
\`yarn intuned run <api-name>\`
|
|
18
20
|
or
|
|
19
|
-
\`npm run run
|
|
21
|
+
\`npm run intuned run <api-name>\`
|
|
20
22
|
|
|
21
|
-
Options:
|
|
22
|
-
- \`-i, --parameters-file file-path\`: JSON file containing API parameters
|
|
23
|
-
- \`-s, --store-results\`: Store the results in \`./output/[runId]/results.json\` and \`./output/[runId]/extendedPayloads.json\`
|
|
24
|
-
- \`-a, --auth-session <session>\`: Name of the auth session instance to use if project is auth-enabled
|
|
25
23
|
|
|
26
24
|
### Build a Project
|
|
27
|
-
\`yarn
|
|
25
|
+
\`yarn intuned build\`
|
|
28
26
|
|
|
29
27
|
### Deploy a Project
|
|
30
|
-
\`yarn deploy
|
|
28
|
+
\`yarn intuned deploy [project-name]\`
|
|
31
29
|
or
|
|
32
|
-
\`npm run deploy
|
|
30
|
+
\`npm run intuned deploy [project-name]\`
|
|
33
31
|
|
|
34
|
-
- \`project-name\`: Optional name that overrides the one in intuned.json
|
|
35
|
-
- Options:
|
|
36
|
-
- \`--workspace-id\`: Overrides the workspace ID in intuned.json
|
|
37
|
-
- \`--api-key\`: Overrides the API key from environment variables
|
|
38
32
|
|
|
39
33
|
|
|
40
34
|
### Create an auth session
|
|
41
|
-
\`yarn create
|
|
35
|
+
\`yarn intuned authsession create <parameters>\`
|
|
42
36
|
or
|
|
43
|
-
\`npm create
|
|
37
|
+
\`npm intuned authsession create <parameters>\`
|
|
38
|
+
|
|
44
39
|
|
|
45
|
-
- \`auth-session-name\`: Optional name/id of the auth session instance to use, if not provided, a name will be generated with the current timestamp
|
|
46
|
-
- Options:
|
|
47
|
-
- \`--input\`: Auth session input parameters file path
|
|
48
40
|
|
|
49
|
-
###
|
|
50
|
-
\`yarn
|
|
41
|
+
### Validate an auth session
|
|
42
|
+
\`yarn intuned authsession validate <auth-session-name>\`
|
|
51
43
|
or
|
|
52
|
-
\`npm
|
|
53
|
-
- \`auth-session-name\`: Name/id of the auth session instance to check, required
|
|
44
|
+
\`npm intuned authsession validate <auth-session-name>\`
|
|
54
45
|
|
|
55
46
|
## Configuration
|
|
56
47
|
|
|
@@ -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;
|
|
@@ -22,6 +23,7 @@ export declare const userCLIScripts: {
|
|
|
22
23
|
export declare const tsConfigCli: {
|
|
23
24
|
compilerOptions: {
|
|
24
25
|
moduleResolution: string;
|
|
26
|
+
module: string;
|
|
25
27
|
target: string;
|
|
26
28
|
outDir: string;
|
|
27
29
|
sourceMap: boolean;
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.userCLIScripts = exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
|
|
6
|
+
exports.userCLIScripts = 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 }; }
|
|
7
9
|
const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
|
|
8
10
|
const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
|
|
9
|
-
const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT =
|
|
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");
|
|
10
13
|
const userCLIScripts = exports.userCLIScripts = {
|
|
11
14
|
"dev:local": "intuned-api-run sample playwright -j '{}'",
|
|
12
15
|
dev: "intuned-api-run",
|
|
@@ -27,7 +30,8 @@ const userCLIScripts = exports.userCLIScripts = {
|
|
|
27
30
|
};
|
|
28
31
|
const tsConfigCli = exports.tsConfigCli = {
|
|
29
32
|
compilerOptions: {
|
|
30
|
-
moduleResolution: "
|
|
33
|
+
moduleResolution: "NodeNext",
|
|
34
|
+
module: "NodeNext",
|
|
31
35
|
target: "ES2021",
|
|
32
36
|
outDir: "./dist",
|
|
33
37
|
sourceMap: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const templateIds:
|
|
1
|
+
export declare const templateIds: readonly ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
2
2
|
export type TemplateId = typeof templateIds[number];
|
|
3
3
|
/**
|
|
4
4
|
* A simple, tree-like structure to describe the contents of a folder to be mounted.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export declare function getAuthCredentials(options:
|
|
1
|
+
export declare function getAuthCredentials(options: {
|
|
2
|
+
workspaceId?: string;
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
}): Promise<{
|
|
2
5
|
workspaceId: any;
|
|
3
|
-
apiKey:
|
|
6
|
+
apiKey: string;
|
|
4
7
|
}>;
|
|
5
8
|
export declare function getBaseUrl(): string;
|
|
6
9
|
export declare function getSettingIntunedJSON(key: string): Promise<any>;
|
package/dist/common/cli/utils.js
CHANGED
|
@@ -8,14 +8,18 @@ exports.getBaseUrl = getBaseUrl;
|
|
|
8
8
|
exports.getSettingIntunedJSON = getSettingIntunedJSON;
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
+
var _helpers = require("../../commands/intuned-cli/commands/helpers");
|
|
11
12
|
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); }
|
|
12
13
|
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; }
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
async function getAuthCredentials(options) {
|
|
15
16
|
const workspaceId = options.workspaceId || (await getSettingIntunedJSON("workspaceId"));
|
|
16
17
|
const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
|
|
17
|
-
if (!workspaceId
|
|
18
|
-
throw new
|
|
18
|
+
if (!workspaceId) {
|
|
19
|
+
throw new _helpers.CLIError("Workspace ID is required. Please provide it via command line options or Intuned.json");
|
|
20
|
+
}
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
throw new _helpers.CLIError("API key is required. Please provide it via command line options or INTUNED_API_KEY environment variable.");
|
|
19
23
|
}
|
|
20
24
|
return {
|
|
21
25
|
workspaceId,
|
package/dist/common/constants.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
6
|
+
exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = exports.API_FOLDER_NAME = void 0;
|
|
7
|
+
const API_FOLDER_NAME = exports.API_FOLDER_NAME = "api";
|
|
7
8
|
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
8
9
|
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
@@ -43,19 +43,12 @@ async function getProductionPlaywrightConstructs({
|
|
|
43
43
|
if (headless) {
|
|
44
44
|
extraArgs.push("--headless=new");
|
|
45
45
|
}
|
|
46
|
-
const executablePath = playwright.chromium.executablePath();
|
|
47
|
-
const chromium127Path = executablePath.replace("chromium-1117", "chromium-1124");
|
|
48
|
-
const isChrome127There = await (0, _fsExtra.exists)(chromium127Path);
|
|
49
|
-
const userAgent = `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${isChrome127There ? 127 : 125}.0.0.0 Safari/537.36`;
|
|
50
46
|
const userDataDir = await createUserDirWithPreferences();
|
|
51
47
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
52
48
|
headless,
|
|
53
|
-
|
|
49
|
+
viewport: null,
|
|
54
50
|
proxy,
|
|
55
|
-
|
|
56
|
-
args: extraArgs,
|
|
57
|
-
downloadsPath,
|
|
58
|
-
userAgent
|
|
51
|
+
downloadsPath
|
|
59
52
|
});
|
|
60
53
|
context.once("close", async () => {
|
|
61
54
|
try {
|
|
@@ -91,7 +84,6 @@ async function getProductionPlaywrightConstructs({
|
|
|
91
84
|
context
|
|
92
85
|
};
|
|
93
86
|
}
|
|
94
|
-
const getChromiumLaunchArgsToIgnore = () => ["--disable-field-trial-config", "--disable-background-networking", "--enable-features=NetworkService,NetworkServiceInProcess", "--disable-background-timer-throttling", "--disable-backgrounding-occluded-windows", "--disable-back-forward-cache", "--disable-breakpad", "--disable-client-side-phishing-detection", "--disable-component-extensions-with-background-pages", "--disable-component-update", "--no-default-browser-check", "--disable-default-apps", "--disable-dev-shm-usage", "--disable-extensions", "--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,TranslateUI", "--allow-pre-commit-input", "--disable-hang-monitor", "--disable-ipc-flooding-protection", "--disable-prompt-on-repost", "--disable-renderer-backgrounding", "--force-color-profile=srgb", "--metrics-recording-only", "--no-first-run", "--enable-automation", "--password-store=basic", "--use-mock-keychain", "--no-service-autorun", "--export-tagged-pdf", "--enable-use-zoom-for-dsf=false"];
|
|
95
87
|
async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
96
88
|
if (mode == "playwright-standalone") {
|
|
97
89
|
if (!cdpAddress) {
|
|
@@ -36,8 +36,7 @@ class JwtTokenManager {
|
|
|
36
36
|
return Math.max(timeToRefresh, timeWindow);
|
|
37
37
|
}
|
|
38
38
|
async scheduleTokenRefresh() {
|
|
39
|
-
|
|
40
|
-
if (((_process$env$RUN_ENVI = process.env.RUN_ENVIRONMENT) === null || _process$env$RUN_ENVI === void 0 ? void 0 : _process$env$RUN_ENVI.toLowerCase()) !== "authoring") return;
|
|
39
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
41
40
|
const timeToRefresh = this.timeToRefresh;
|
|
42
41
|
if (timeToRefresh === undefined) return;
|
|
43
42
|
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
@@ -51,8 +50,7 @@ class JwtTokenManager {
|
|
|
51
50
|
}, timeToRefresh);
|
|
52
51
|
}
|
|
53
52
|
async refreshToken() {
|
|
54
|
-
|
|
55
|
-
if (((_process$env$RUN_ENVI2 = process.env.RUN_ENVIRONMENT) === null || _process$env$RUN_ENVI2 === void 0 ? void 0 : _process$env$RUN_ENVI2.toLowerCase()) !== "authoring") return;
|
|
53
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
56
54
|
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
57
55
|
method: "GET"
|
|
58
56
|
});
|
|
@@ -65,7 +63,7 @@ class JwtTokenManager {
|
|
|
65
63
|
if (newToken) this._token = newToken;
|
|
66
64
|
}
|
|
67
65
|
fetchWithToken(...[input, init]) {
|
|
68
|
-
const headers = new Headers(init
|
|
66
|
+
const headers = new Headers(init?.headers);
|
|
69
67
|
headers.set("Authorization", `Bearer ${this.token}`);
|
|
70
68
|
return (0, _crossFetch.default)(input, {
|
|
71
69
|
...init,
|
|
@@ -10,7 +10,7 @@ export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
|
10
10
|
export declare const automationError = "AutomationError";
|
|
11
11
|
export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
12
12
|
export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError"];
|
|
13
|
-
export type RunAutomationErrorCode =
|
|
13
|
+
export type RunAutomationErrorCode = typeof runAutomationErrorCodes[number];
|
|
14
14
|
export declare abstract class RunAutomationError<T = any> {
|
|
15
15
|
code: RunAutomationErrorCode;
|
|
16
16
|
statusCode: number;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
7
|
var _runtime = require("../../runtime");
|
|
8
|
-
var playwright = _interopRequireWildcard(require("playwright"));
|
|
8
|
+
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
9
9
|
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); }
|
|
10
10
|
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; }
|
|
11
11
|
const apiNotFoundErrorCode = exports.apiNotFoundErrorCode = "APINotFoundError";
|
|
@@ -22,11 +22,10 @@ const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundEr
|
|
|
22
22
|
class RunAutomationError {
|
|
23
23
|
wrapped = false;
|
|
24
24
|
get json() {
|
|
25
|
-
var _this$cause;
|
|
26
25
|
return {
|
|
27
26
|
code: this.code,
|
|
28
27
|
details: this.details,
|
|
29
|
-
cause:
|
|
28
|
+
cause: this.cause?.json
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
31
|
}
|
|
@@ -136,10 +135,10 @@ class AutomationError extends RunAutomationError {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
this.statusCode = 500;
|
|
139
|
-
this.message = `[${
|
|
138
|
+
this.message = `[${error?.name ?? error}] ${error?.message}`;
|
|
140
139
|
this.details = {
|
|
141
|
-
name: error
|
|
142
|
-
message: error
|
|
140
|
+
name: error?.name,
|
|
141
|
+
message: error?.message
|
|
143
142
|
};
|
|
144
143
|
}
|
|
145
144
|
}
|
|
@@ -8,6 +8,9 @@ export declare function runApiGenerator<ResultType = any, _YieldType = any, _Nex
|
|
|
8
8
|
retrieveSession: true;
|
|
9
9
|
}): AsyncGenerator<_YieldType, RunApiResult<ResultType, RunApiResultWithSessionOk>, _NextType>;
|
|
10
10
|
export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters): AsyncGenerator<_YieldType, RunApiResult<ResultType>, _NextType>;
|
|
11
|
+
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters & {
|
|
12
|
+
retrieveSession: true;
|
|
13
|
+
}): Promise<RunApiResult<ResultType, RunApiResultWithSessionOk>>;
|
|
11
14
|
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
|
|
12
15
|
export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, checkFn: (..._: any) => Promise<boolean>, retries?: number): Promise<Result<boolean, RunAutomationError>>;
|
|
13
16
|
export type ImportFunction = ExtendedRunApiParameters["importFunction"];
|
|
@@ -80,17 +80,15 @@ async function* runApiGenerator({
|
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
try {
|
|
83
|
-
|
|
84
|
-
await ((_context = context) === null || _context === void 0 ? void 0 : _context.tracing.stop({
|
|
83
|
+
await context?.tracing.stop({
|
|
85
84
|
path: tracing.filePath
|
|
86
|
-
})
|
|
85
|
+
});
|
|
87
86
|
} catch (error) {
|
|
88
|
-
console.log(errorMessage, error
|
|
87
|
+
console.log(errorMessage, error?.message);
|
|
89
88
|
await (0, _fsExtra.remove)(tracing.filePath);
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
async function* runAutomation() {
|
|
93
|
-
var _getExecutionContext;
|
|
94
92
|
let page;
|
|
95
93
|
const validatedModuleResult = await importUsingImportFunction(automationFunction.name, importFunction);
|
|
96
94
|
if (validatedModuleResult.isErr()) {
|
|
@@ -98,7 +96,7 @@ async function* runApiGenerator({
|
|
|
98
96
|
}
|
|
99
97
|
const importedModule = validatedModuleResult.value;
|
|
100
98
|
let checkFn;
|
|
101
|
-
if (auth
|
|
99
|
+
if (auth?.runCheck) {
|
|
102
100
|
if (!auth.session) {
|
|
103
101
|
return (0, _neverthrow.err)(new _errors.AuthRequiredError());
|
|
104
102
|
}
|
|
@@ -130,7 +128,7 @@ async function* runApiGenerator({
|
|
|
130
128
|
headless,
|
|
131
129
|
proxy,
|
|
132
130
|
downloadsPath,
|
|
133
|
-
storageState: auth
|
|
131
|
+
storageState: auth?.session
|
|
134
132
|
}));
|
|
135
133
|
} else {
|
|
136
134
|
const {
|
|
@@ -140,7 +138,7 @@ async function* runApiGenerator({
|
|
|
140
138
|
({
|
|
141
139
|
page,
|
|
142
140
|
context
|
|
143
|
-
} = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth
|
|
141
|
+
} = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth?.session));
|
|
144
142
|
}
|
|
145
143
|
if (tracing.enabled) {
|
|
146
144
|
await context.tracing.start({
|
|
@@ -152,20 +150,23 @@ async function* runApiGenerator({
|
|
|
152
150
|
}
|
|
153
151
|
(0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
|
|
154
152
|
if (checkFn !== undefined) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
try {
|
|
154
|
+
console.log("Running auth check");
|
|
155
|
+
const authCheckResult = await checkAuthSessionWithRetries(page, context, checkFn, 2);
|
|
156
|
+
if (authCheckResult.isErr()) {
|
|
157
|
+
const error = authCheckResult.error;
|
|
158
|
+
if (["APINotFoundError", "InvalidAPIError"].includes(error.code)) {
|
|
159
|
+
return (0, _neverthrow.err)(new _errors.InvalidCheckError(`Auth session check function failed`, error));
|
|
160
|
+
}
|
|
161
|
+
return authCheckResult;
|
|
161
162
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
if (!authCheckResult.value) {
|
|
164
|
+
return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
|
|
165
|
+
}
|
|
166
|
+
} catch (error) {
|
|
165
167
|
return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
|
-
console.log("Running automation");
|
|
169
170
|
const automationFunctionParameters = [...(automationFunction.params !== undefined ? [automationFunction.params] : []), page, context];
|
|
170
171
|
let result;
|
|
171
172
|
if (importedModule.type === "async-generator") {
|
|
@@ -185,7 +186,7 @@ async function* runApiGenerator({
|
|
|
185
186
|
}
|
|
186
187
|
return (0, _neverthrow.ok)({
|
|
187
188
|
result,
|
|
188
|
-
extendedPayloads: (
|
|
189
|
+
extendedPayloads: (0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads,
|
|
189
190
|
session: retrieveSession ? await (0, _contextStorageStateHelpers.getStorageState)(context) : undefined
|
|
190
191
|
});
|
|
191
192
|
}
|
|
@@ -206,11 +207,10 @@ async function* runApiGenerator({
|
|
|
206
207
|
} catch (error) {
|
|
207
208
|
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
208
209
|
} finally {
|
|
209
|
-
var _context2;
|
|
210
210
|
await saveTraceIfNeeded({
|
|
211
211
|
errorMessage: "failed to save trace"
|
|
212
212
|
});
|
|
213
|
-
await
|
|
213
|
+
await context?.close();
|
|
214
214
|
if (downloadsPath !== undefined) {
|
|
215
215
|
await fs.remove(downloadsPath);
|
|
216
216
|
}
|
|
@@ -24,13 +24,12 @@ var _enums = require("./enums");
|
|
|
24
24
|
runId: "test-run-id",
|
|
25
25
|
extendedPayloads: []
|
|
26
26
|
}, () => {
|
|
27
|
-
|
|
28
|
-
(0, _vitest.expect)((_getExecutionContext = (0, _asyncLocalStorage.getExecutionContext)()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads).toEqual([]);
|
|
27
|
+
(0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([]);
|
|
29
28
|
(0, _.extendPayload)({
|
|
30
29
|
api: "test-api",
|
|
31
30
|
parameters: {}
|
|
32
31
|
});
|
|
33
|
-
(0, _vitest.expect)((
|
|
32
|
+
(0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([{
|
|
34
33
|
api: "test-api",
|
|
35
34
|
parameters: {}
|
|
36
35
|
}]);
|
|
@@ -47,7 +46,7 @@ var _enums = require("./enums");
|
|
|
47
46
|
parameters: {}
|
|
48
47
|
});
|
|
49
48
|
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
50
|
-
(0, _vitest.expect)(context
|
|
49
|
+
(0, _vitest.expect)(context?.extendedPayloads).toHaveLength(4);
|
|
51
50
|
});
|
|
52
51
|
});
|
|
53
52
|
});
|
package/dist/runtime/export.d.ts
CHANGED
|
@@ -201,3 +201,18 @@ export declare function requestMultipleChoice(
|
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
203
|
export declare function requestOTP(message: string): unknown;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves the parameters for the authentication session currently being used.
|
|
207
|
+
*
|
|
208
|
+
* @returns {AuthSessionParameters} An object containing the parameters for the current authentication session.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript getAuthSessionParameters
|
|
212
|
+
* import { getAuthSessionParameters } from "@intuned/sdk/runtime"
|
|
213
|
+
*
|
|
214
|
+
* const authSessionParams = getAuthSessionParameters();
|
|
215
|
+
* console.log(authSessionParams);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -16,6 +16,6 @@ function extendPayload(payload) {
|
|
|
16
16
|
context.extendedPayloads = [...items];
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
context
|
|
19
|
+
context?.extendedPayloads.push(...items);
|
|
20
20
|
(0, _extendTimeout.extendTimeout)();
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-cli.0",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"intuned-auth-session-refresh": "vite-node ./src/commands/auth/run-refresh.ts",
|
|
30
30
|
"intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
|
|
31
31
|
"intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
|
|
32
|
+
"intuned": "vite-node ./src/commands/intuned-cli/main.ts",
|
|
32
33
|
"build": "rm -rf dist && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && cp -r ./src/common/assets dist/common/assets",
|
|
33
34
|
"test": "vitest run",
|
|
34
35
|
"test:watch": "vitest",
|
|
@@ -55,7 +56,8 @@
|
|
|
55
56
|
"deploy": "./bin/deploy",
|
|
56
57
|
"cli-build": "./bin/cli-build",
|
|
57
58
|
"create-auth-session": "./bin/create-auth-session",
|
|
58
|
-
"check-auth-session": "./bin/check-auth-session"
|
|
59
|
+
"check-auth-session": "./bin/check-auth-session",
|
|
60
|
+
"intuned": "./bin/intuned"
|
|
59
61
|
},
|
|
60
62
|
"dependencies": {
|
|
61
63
|
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
|
@@ -69,9 +71,8 @@
|
|
|
69
71
|
"@types/node": "20.4.1",
|
|
70
72
|
"applicationinsights": "2.9.2",
|
|
71
73
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
72
|
-
"boxen": "8.0.1",
|
|
73
74
|
"chalk": "^4.1.2",
|
|
74
|
-
"commander": "
|
|
75
|
+
"commander": "14.0.0",
|
|
75
76
|
"cross-fetch": "^4.0.0",
|
|
76
77
|
"dotenv": "^16.3.1",
|
|
77
78
|
"fs-extra": "^11.3.0",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
"promptly": "3.2.0",
|
|
89
90
|
"rollup": "3.26.2",
|
|
90
91
|
"source-map": "0.7.4",
|
|
92
|
+
"terminal-kit": "^3.1.2",
|
|
91
93
|
"ts-morph": "21.0.1",
|
|
92
94
|
"ts-node": "10.9.1",
|
|
93
95
|
"tslib": "2.6.0",
|
|
@@ -106,7 +108,9 @@
|
|
|
106
108
|
"@ngneat/falso": "^7.2.0",
|
|
107
109
|
"@types/jest": "^29.5.3",
|
|
108
110
|
"@types/jsdom": "^21.1.1",
|
|
111
|
+
"@types/ms": "^2.1.0",
|
|
109
112
|
"@types/promptly": "^3.0.4",
|
|
113
|
+
"@types/terminal-kit": "^2.5.7",
|
|
110
114
|
"@types/wait-on": "^5.3.4",
|
|
111
115
|
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
112
116
|
"@typescript-eslint/parser": "^7.5.0",
|
|
@@ -132,4 +136,4 @@
|
|
|
132
136
|
"peerDependencies": {
|
|
133
137
|
"playwright": "*"
|
|
134
138
|
}
|
|
135
|
-
}
|
|
139
|
+
}
|