@intuned/runtime-dev 1.0.4-stuck.1 → 1.0.6-cli-auth.0.0.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/InterfaceTemplate/utils.ts +53 -31
- package/bin/cli-build +3 -0
- package/bin/create-auth-session +3 -0
- package/bin/deploy +3 -0
- package/bin/init +3 -0
- package/bin/run-api +3 -0
- package/dist/commands/api/run.js +2 -2
- package/dist/commands/auth-sessions/load.js +1 -1
- package/dist/commands/auth-sessions/run-check.js +2 -2
- package/dist/commands/auth-sessions/run-create.js +2 -2
- package/dist/commands/browser/save-state.js +1 -1
- package/dist/commands/browser/start-browser.js +1 -1
- package/dist/commands/build.js +4 -4
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -0
- package/dist/commands/cli-auth-sessions/check.js +1 -0
- package/dist/commands/cli-auth-sessions/create.d.ts +2 -0
- package/dist/commands/cli-auth-sessions/create.js +28 -0
- package/dist/commands/cli-auth-sessions/utils.d.ts +4 -0
- package/dist/commands/cli-auth-sessions/utils.js +55 -0
- package/dist/commands/cli-build/cli-build.d.ts +2 -0
- package/dist/commands/cli-build/cli-build.js +20 -0
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +3 -3
- package/dist/commands/common/getFirstLineNumber.test.js +2 -2
- package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/dist/commands/common/projectExclusions.js +8 -0
- package/dist/commands/common/tsNodeImport.d.ts +2 -1
- package/dist/commands/common/tsNodeImport.js +20 -6
- package/dist/commands/common/utils/fileUtils.js +2 -2
- package/dist/commands/common/utils/settings.js +1 -1
- package/dist/commands/common/utils/template.d.ts +1 -1
- package/dist/commands/common/utils/template.js +1 -1
- package/dist/commands/deploy/deploy.d.ts +2 -0
- package/dist/commands/deploy/deploy.js +47 -0
- package/dist/commands/deploy/utils.d.ts +16 -0
- package/dist/commands/deploy/utils.js +350 -0
- package/dist/commands/init/init.d.ts +2 -0
- package/dist/commands/init/init.js +22 -0
- package/dist/commands/init/utils.d.ts +9 -0
- package/dist/commands/init/utils.js +179 -0
- package/dist/commands/interface/run.js +141 -94
- package/dist/commands/run-api-cli/run-api.d.ts +2 -0
- package/dist/commands/run-api-cli/run-api.js +48 -0
- package/dist/commands/run-api-cli/utils.d.ts +10 -0
- package/dist/commands/run-api-cli/utils.js +98 -0
- package/dist/commands/ts-check.js +2 -2
- package/dist/common/Logger/Logger/index.js +1 -1
- package/dist/common/Logger/index.js +1 -1
- package/dist/common/asyncLocalStorage/index.d.ts +1 -1
- package/dist/common/asyncLocalStorage/index.js +2 -2
- package/dist/common/cli/cliReadme.d.ts +1 -0
- package/dist/common/cli/cliReadme.js +69 -0
- package/dist/common/cli/constants.d.ts +24 -0
- package/dist/common/cli/constants.js +30 -0
- package/dist/common/cli/types.d.ts +52 -0
- package/dist/common/cli/types.js +7 -0
- package/dist/common/cli/utils.d.ts +6 -0
- package/dist/common/cli/utils.js +35 -0
- package/dist/common/contextStorageStateHelpers.d.ts +20 -13
- package/dist/common/contextStorageStateHelpers.js +69 -42
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +5 -5
- package/dist/common/jwtTokenManager.js +2 -2
- package/dist/common/runApi/errors.d.ts +0 -11
- package/dist/common/runApi/errors.js +2 -41
- package/dist/common/runApi/index.d.ts +2 -1
- package/dist/common/runApi/index.js +11 -4
- package/dist/common/runApi/types.d.ts +82 -76
- package/dist/common/runApi/types.js +1 -1
- package/dist/common/settingsSchema.js +1 -1
- package/dist/common/telemetry.js +1 -1
- package/package.json +14 -6
- package/WebTemplate/accessKeyHelpers.ts +0 -28
- package/WebTemplate/api.ts +0 -139
- package/WebTemplate/app.ts +0 -18
- package/WebTemplate/controllers/async.ts +0 -142
- package/WebTemplate/controllers/authSessions/check.ts +0 -61
- package/WebTemplate/controllers/authSessions/create.ts +0 -101
- package/WebTemplate/controllers/authSessions/index.ts +0 -41
- package/WebTemplate/controllers/authSessions/killOperation.ts +0 -35
- package/WebTemplate/controllers/authSessions/resumeOperation.ts +0 -56
- package/WebTemplate/controllers/authSessions/store.ts +0 -19
- package/WebTemplate/controllers/controllers.ts +0 -73
- package/WebTemplate/controllers/runApi/helpers.ts +0 -128
- package/WebTemplate/controllers/runApi/index.ts +0 -68
- package/WebTemplate/controllers/runApi/types.ts +0 -13
- package/WebTemplate/controllers/traces.ts +0 -151
- package/WebTemplate/features.ts +0 -8
- package/WebTemplate/headers.ts +0 -6
- package/WebTemplate/index.playwright.ts +0 -47
- package/WebTemplate/index.vanilla.ts +0 -26
- package/WebTemplate/jobs.ts +0 -356
- package/WebTemplate/shutdown.ts +0 -64
- package/WebTemplate/utils.ts +0 -257
- package/WebTemplate.zip +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const templateIds: string[];
|
|
2
|
+
export type TemplateId = (typeof templateIds)[number];
|
|
3
|
+
/**
|
|
4
|
+
* A simple, tree-like structure to describe the contents of a folder to be mounted.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```
|
|
8
|
+
* const tree = {
|
|
9
|
+
* myproject: {
|
|
10
|
+
* directory: {
|
|
11
|
+
* 'foo.js': {
|
|
12
|
+
* file: {
|
|
13
|
+
* contents: 'const x = 1;',
|
|
14
|
+
* },
|
|
15
|
+
* },
|
|
16
|
+
* .envrc: {
|
|
17
|
+
* file: {
|
|
18
|
+
* contents: 'ENVIRONMENT=staging'
|
|
19
|
+
* }
|
|
20
|
+
* },
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* emptyFolder: {
|
|
24
|
+
* directory: {}
|
|
25
|
+
* },
|
|
26
|
+
* };
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface FileSystemTree {
|
|
30
|
+
[name: string]: DirectoryNode | FileNode;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents a directory, see {@link FileSystemTree}.
|
|
34
|
+
*/
|
|
35
|
+
export interface DirectoryNode {
|
|
36
|
+
directory: FileSystemTree;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Represents a file, see {@link FileSystemTree}.
|
|
40
|
+
*/
|
|
41
|
+
export interface FileNode {
|
|
42
|
+
file: {
|
|
43
|
+
/**
|
|
44
|
+
* The contents of the file, either as a UTF-8 string or as raw binary.
|
|
45
|
+
*/
|
|
46
|
+
contents: string | Uint8Array;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface AuthCredentials {
|
|
50
|
+
workspaceId: string;
|
|
51
|
+
apiKey: string;
|
|
52
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.templateIds = void 0;
|
|
7
|
+
const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAuthCredentials = getAuthCredentials;
|
|
7
|
+
exports.getBaseUrl = getBaseUrl;
|
|
8
|
+
exports.getSettingIntunedJSON = getSettingIntunedJSON;
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
11
|
+
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
|
+
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
async function getAuthCredentials(options) {
|
|
15
|
+
const workspaceId = options.workspaceId || (await getSettingIntunedJSON("workspaceId"));
|
|
16
|
+
const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
|
|
17
|
+
if (!workspaceId || !apiKey) {
|
|
18
|
+
throw new Error("Authentication details are required. Please provide them via command line options(api key, workspace id), intuned.json(workspace id) or environment variables(api key).");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
workspaceId,
|
|
22
|
+
apiKey
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getBaseUrl() {
|
|
26
|
+
return process.env.INTUNED_API_DOMAIN || `https://app.intuned.io`;
|
|
27
|
+
}
|
|
28
|
+
async function getSettingIntunedJSON(key) {
|
|
29
|
+
const intunedJsonPath = _path.default.join(process.cwd(), "Intuned.json");
|
|
30
|
+
const intunedJson = await fs.readJSON(intunedJsonPath);
|
|
31
|
+
if (intunedJson && intunedJson[key]) {
|
|
32
|
+
return intunedJson[key];
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as playwright from "playwright-core";
|
|
2
|
+
interface StorageEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
interface LocalStorageState {
|
|
7
|
+
origin: string;
|
|
8
|
+
localStorage: StorageEntry[];
|
|
9
|
+
}
|
|
10
|
+
interface SessionStorageState {
|
|
4
11
|
origin: string;
|
|
5
|
-
sessionStorage:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare function
|
|
14
|
-
export
|
|
12
|
+
sessionStorage: StorageEntry[];
|
|
13
|
+
}
|
|
14
|
+
export interface StorageState {
|
|
15
|
+
cookies?: playwright.Cookie[] | null;
|
|
16
|
+
origins?: LocalStorageState[] | null;
|
|
17
|
+
sessionStorage?: SessionStorageState[] | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function setStorageState(context: playwright.BrowserContext, state: StorageState): Promise<void>;
|
|
20
|
+
export declare function getStorageState(context: playwright.BrowserContext): Promise<StorageState>;
|
|
21
|
+
export {};
|
|
@@ -3,52 +3,79 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
result.push({
|
|
12
|
-
name: key,
|
|
13
|
-
value: storage[key]
|
|
14
|
-
});
|
|
6
|
+
exports.getStorageState = getStorageState;
|
|
7
|
+
exports.setStorageState = setStorageState;
|
|
8
|
+
async function setStorageState(context, state) {
|
|
9
|
+
if ("cookies" in state && state.cookies) {
|
|
10
|
+
await context.addCookies(state.cookies);
|
|
15
11
|
}
|
|
16
|
-
|
|
12
|
+
const page = await context.newPage();
|
|
13
|
+
if ("origins" in state && state.origins) {
|
|
14
|
+
for (const originData of state.origins || []) {
|
|
15
|
+
const origin = originData.origin;
|
|
16
|
+
await page.route(`${origin}/*`, route => route.fulfill({
|
|
17
|
+
body: "<html><head><title>Set Storage</title></head><body><h1>Set Storage</h1></body></html>",
|
|
18
|
+
contentType: "text/html",
|
|
19
|
+
status: 200
|
|
20
|
+
}));
|
|
21
|
+
try {
|
|
22
|
+
await page.goto(origin);
|
|
23
|
+
for (const item of originData.localStorage) {
|
|
24
|
+
await page.evaluate(([key, value]) => {
|
|
25
|
+
window.localStorage.setItem(key, value);
|
|
26
|
+
}, [item.name, item.value]);
|
|
27
|
+
}
|
|
28
|
+
} finally {
|
|
29
|
+
await page.unroute(`${origin}/*`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if ("sessionStorage" in state && state.sessionStorage) {
|
|
34
|
+
await context.addInitScript(storage => {
|
|
35
|
+
for (const {
|
|
36
|
+
origin,
|
|
37
|
+
sessionStorage
|
|
38
|
+
} of storage) {
|
|
39
|
+
if (window.location.origin === origin) {
|
|
40
|
+
for (const item of sessionStorage) {
|
|
41
|
+
const value = window.sessionStorage.getItem(item.name);
|
|
42
|
+
if (!value) {
|
|
43
|
+
window.sessionStorage.setItem(item.name, item.value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, state.sessionStorage);
|
|
49
|
+
}
|
|
50
|
+
await page.close();
|
|
17
51
|
}
|
|
18
|
-
async function
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
52
|
+
async function getStorageState(context) {
|
|
53
|
+
const result = {};
|
|
54
|
+
const storageState = await context.storageState();
|
|
55
|
+
result.cookies = storageState.cookies;
|
|
56
|
+
result.origins = storageState.origins;
|
|
57
|
+
const sessionDataList = [];
|
|
58
|
+
const pages = await context.pages();
|
|
22
59
|
for (const page of pages) {
|
|
60
|
+
if (page.isClosed()) continue;
|
|
23
61
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
62
|
+
const sessionData = await page.evaluate(() => {
|
|
63
|
+
const items = {
|
|
64
|
+
...window.sessionStorage
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
origin: window.location.origin,
|
|
68
|
+
sessionStorage: Object.entries(items).map(([name, value]) => ({
|
|
69
|
+
name,
|
|
70
|
+
value
|
|
71
|
+
}))
|
|
72
|
+
};
|
|
29
73
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...cookiesAndLocalStorage,
|
|
34
|
-
sessionStorage: pagesSessions
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async function setContextStorageState(context, storage) {
|
|
38
|
-
await context.intunedSetStorageState(storage);
|
|
39
|
-
const sessionStorage = storage.sessionStorage;
|
|
40
|
-
await context.addInitScript(storage => {
|
|
41
|
-
for (const {
|
|
42
|
-
origin,
|
|
43
|
-
sessionStorage
|
|
44
|
-
} of storage) {
|
|
45
|
-
if (window.location.origin === origin) {
|
|
46
|
-
for (const item of sessionStorage) {
|
|
47
|
-
const existingValue = window.sessionStorage.getItem(item.name);
|
|
48
|
-
if (existingValue !== null) continue;
|
|
49
|
-
window.sessionStorage.setItem(item.name, item.value);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
74
|
+
sessionDataList.push(sessionData);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error("Error getting sessionStorage:", error);
|
|
52
77
|
}
|
|
53
|
-
}
|
|
78
|
+
}
|
|
79
|
+
result["sessionStorage"] = sessionDataList;
|
|
80
|
+
return result;
|
|
54
81
|
}
|
|
@@ -7,7 +7,7 @@ exports.getPlaywrightConstructsForMode = getPlaywrightConstructsForMode;
|
|
|
7
7
|
exports.getProductionPlaywrightConstructs = getProductionPlaywrightConstructs;
|
|
8
8
|
exports.getRemotePlaywrightContext = getRemotePlaywrightContext;
|
|
9
9
|
exports.loadSessionToContext = loadSessionToContext;
|
|
10
|
-
var playwright = _interopRequireWildcard(require("
|
|
10
|
+
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
11
11
|
var _fsExtra = _interopRequireWildcard(require("fs-extra"));
|
|
12
12
|
var fs = _fsExtra;
|
|
13
13
|
var _contextStorageStateHelpers = require("./contextStorageStateHelpers");
|
|
@@ -15,9 +15,9 @@ var _path = _interopRequireWildcard(require("path"));
|
|
|
15
15
|
var _fileUtils = require("../commands/common/utils/fileUtils");
|
|
16
16
|
var _waitOn = _interopRequireDefault(require("wait-on"));
|
|
17
17
|
var _runtime = require("../runtime");
|
|
18
|
-
function _interopRequireDefault(
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
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); }
|
|
20
|
-
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 &&
|
|
20
|
+
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; }
|
|
21
21
|
async function createUserDirWithPreferences() {
|
|
22
22
|
const playwrightTempDir = await (0, _fsExtra.mkdtemp)("/tmp/pw-");
|
|
23
23
|
const userDir = (0, _path.join)(playwrightTempDir, "userdir");
|
|
@@ -160,10 +160,10 @@ async function loadSessionToContext({
|
|
|
160
160
|
const fullPath = (0, _fileUtils.getFullPathInProject)(session.path);
|
|
161
161
|
sessionToLoad = await fs.readJson(fullPath);
|
|
162
162
|
}
|
|
163
|
-
await (0, _contextStorageStateHelpers.
|
|
163
|
+
await (0, _contextStorageStateHelpers.setStorageState)(context, sessionToLoad);
|
|
164
164
|
}
|
|
165
165
|
async function getRemotePlaywrightContext(cdpAddress) {
|
|
166
|
-
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("
|
|
166
|
+
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("playwright-core")));
|
|
167
167
|
let browser = null;
|
|
168
168
|
if (!cdpAddress) {
|
|
169
169
|
throw new Error("cdpAddress is required");
|
|
@@ -9,8 +9,8 @@ var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
|
9
9
|
var jwt = _interopRequireWildcard(require("jsonwebtoken"));
|
|
10
10
|
var _neverthrow = require("neverthrow");
|
|
11
11
|
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
|
-
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 &&
|
|
13
|
-
function _interopRequireDefault(
|
|
12
|
+
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
class JwtTokenManager {
|
|
15
15
|
constructor(refreshTokenPath) {
|
|
16
16
|
this.refreshTokenPath = refreshTokenPath;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { RunAutomationResponse } from "./types";
|
|
2
1
|
import { RunErrorOptions } from "../../runtime/export";
|
|
3
2
|
export declare const apiNotFoundErrorCode = "APINotFoundError";
|
|
4
3
|
export declare const invalidApiErrorCode = "InvalidAPIError";
|
|
@@ -19,7 +18,6 @@ export declare abstract class RunAutomationError<T = any> {
|
|
|
19
18
|
message: string;
|
|
20
19
|
cause?: RunAutomationError;
|
|
21
20
|
details?: T;
|
|
22
|
-
get apiResponse(): RunAutomationResponse;
|
|
23
21
|
get json(): {
|
|
24
22
|
code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError";
|
|
25
23
|
details: T | undefined;
|
|
@@ -46,14 +44,6 @@ export declare class AuthCheckNotFoundError extends RunAutomationError {
|
|
|
46
44
|
}
|
|
47
45
|
export declare class AuthCheckFailedError extends RunAutomationError {
|
|
48
46
|
constructor();
|
|
49
|
-
get apiResponse(): {
|
|
50
|
-
status: number;
|
|
51
|
-
body: {
|
|
52
|
-
status: number;
|
|
53
|
-
error: string;
|
|
54
|
-
message: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
47
|
}
|
|
58
48
|
export declare class MaxLevelsExceededError extends RunAutomationError<{
|
|
59
49
|
levels: number;
|
|
@@ -72,5 +62,4 @@ export declare class AutomationError extends RunAutomationError<{
|
|
|
72
62
|
}
|
|
73
63
|
export declare class InternalInvalidInputError extends RunAutomationError {
|
|
74
64
|
constructor(message: string, details?: any);
|
|
75
|
-
get apiResponse(): RunAutomationResponse;
|
|
76
65
|
}
|
|
@@ -5,9 +5,9 @@ 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("
|
|
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
|
-
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 &&
|
|
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";
|
|
12
12
|
const invalidApiErrorCode = exports.invalidApiErrorCode = "InvalidAPIError";
|
|
13
13
|
const invalidCheckErrorCode = exports.invalidCheckErrorCode = "InvalidCheckError";
|
|
@@ -21,25 +21,6 @@ const internalInvalidInputErrorCode = exports.internalInvalidInputErrorCode = "I
|
|
|
21
21
|
const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError, internalInvalidInputErrorCode];
|
|
22
22
|
class RunAutomationError {
|
|
23
23
|
wrapped = false;
|
|
24
|
-
get apiResponse() {
|
|
25
|
-
if (this.wrapped) {
|
|
26
|
-
return {
|
|
27
|
-
status: 200,
|
|
28
|
-
body: {
|
|
29
|
-
status: this.statusCode,
|
|
30
|
-
error: this.code,
|
|
31
|
-
message: this.message
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
status: this.statusCode,
|
|
37
|
-
body: {
|
|
38
|
-
error: this.code,
|
|
39
|
-
message: this.message
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
24
|
get json() {
|
|
44
25
|
var _this$cause;
|
|
45
26
|
return {
|
|
@@ -114,16 +95,6 @@ class AuthCheckFailedError extends RunAutomationError {
|
|
|
114
95
|
this.message = "auth session check failed";
|
|
115
96
|
this.wrapped = true;
|
|
116
97
|
}
|
|
117
|
-
get apiResponse() {
|
|
118
|
-
return {
|
|
119
|
-
status: 200,
|
|
120
|
-
body: {
|
|
121
|
-
status: this.statusCode,
|
|
122
|
-
error: "AUTH_SESSION_CHECK_FAILED",
|
|
123
|
-
message: this.message
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
98
|
}
|
|
128
99
|
exports.AuthCheckFailedError = AuthCheckFailedError;
|
|
129
100
|
class MaxLevelsExceededError extends RunAutomationError {
|
|
@@ -181,15 +152,5 @@ class InternalInvalidInputError extends RunAutomationError {
|
|
|
181
152
|
this.message = message;
|
|
182
153
|
this.details = details;
|
|
183
154
|
}
|
|
184
|
-
get apiResponse() {
|
|
185
|
-
return {
|
|
186
|
-
status: 500,
|
|
187
|
-
body: {
|
|
188
|
-
error: "InternalServerError",
|
|
189
|
-
message: `Internal error: ${this.message}. Please report this issue to the Intuned team.`,
|
|
190
|
-
details: this.details
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
155
|
}
|
|
195
156
|
exports.InternalInvalidInputError = InternalInvalidInputError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { RunAutomationError } from "./errors";
|
|
3
|
-
import { Page, BrowserContext } from "
|
|
3
|
+
import { Page, BrowserContext } from "playwright-core";
|
|
4
4
|
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export * from "./errors";
|
|
@@ -10,3 +10,4 @@ export declare function runApiGenerator<ResultType = any, _YieldType = any, _Nex
|
|
|
10
10
|
export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters): AsyncGenerator<_YieldType, RunApiResult<ResultType>, _NextType>;
|
|
11
11
|
export declare function runApi<ResultType = any>(params: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
|
|
12
12
|
export declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, checkFn: (..._: any) => Promise<boolean>, retries?: number): Promise<Result<boolean, RunAutomationError>>;
|
|
13
|
+
export type ImportFunction = ExtendedRunApiParameters["importFunction"];
|
|
@@ -46,7 +46,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
46
46
|
var _formatZodError = require("../formatZodError");
|
|
47
47
|
var _cleanEnvironmentVariables = require("../cleanEnvironmentVariables");
|
|
48
48
|
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); }
|
|
49
|
-
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 &&
|
|
49
|
+
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; }
|
|
50
50
|
async function* runApiGenerator({
|
|
51
51
|
retrieveSession = false,
|
|
52
52
|
abortSignal,
|
|
@@ -186,7 +186,7 @@ async function* runApiGenerator({
|
|
|
186
186
|
return (0, _neverthrow.ok)({
|
|
187
187
|
result,
|
|
188
188
|
extendedPayloads: (_getExecutionContext = (0, _asyncLocalStorage.getExecutionContext)()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads,
|
|
189
|
-
session: retrieveSession ? await (0, _contextStorageStateHelpers.
|
|
189
|
+
session: retrieveSession ? await (0, _contextStorageStateHelpers.getStorageState)(context) : undefined
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
try {
|
|
@@ -242,7 +242,14 @@ async function checkAuthSessionWithRetries(page, context, checkFn, retries = 3)
|
|
|
242
242
|
}
|
|
243
243
|
async function importUsingImportFunction(path, importFunction) {
|
|
244
244
|
try {
|
|
245
|
-
const
|
|
245
|
+
const importedResult = await importFunction(path);
|
|
246
|
+
if (importedResult.isErr()) {
|
|
247
|
+
if (importedResult.error.type === "not_found") {
|
|
248
|
+
return (0, _neverthrow.err)(new _errors.ApiNotFoundError(path));
|
|
249
|
+
}
|
|
250
|
+
return (0, _neverthrow.err)(new _errors.AutomationError(importedResult.error.error));
|
|
251
|
+
}
|
|
252
|
+
const imported = importedResult.value;
|
|
246
253
|
if (!imported || !imported.default || !imported.default.constructor) {
|
|
247
254
|
return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default export"));
|
|
248
255
|
}
|
|
@@ -260,6 +267,6 @@ async function importUsingImportFunction(path, importFunction) {
|
|
|
260
267
|
}
|
|
261
268
|
return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default async function/generator export"));
|
|
262
269
|
} catch (error) {
|
|
263
|
-
return (0, _neverthrow.err)(new _errors.
|
|
270
|
+
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
264
271
|
}
|
|
265
272
|
}
|