@intuned/runtime-dev 0.1.0-test.1 → 0.1.0-test.11
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 +3 -1
- package/Intuned.json +1 -1
- package/api/test2.ts +1 -4
- package/dist/commands/api/run.js +27 -35
- package/dist/commands/auth-sessions/load.js +11 -13
- package/dist/commands/auth-sessions/run-check.js +14 -19
- package/dist/commands/auth-sessions/run-create.js +23 -28
- package/dist/commands/browser/save-state.js +7 -10
- package/dist/commands/browser/start-browser.js +7 -10
- package/dist/commands/build.js +25 -30
- package/dist/commands/common/browserUtils.js +15 -28
- package/dist/commands/common/getDefaultExportFromFile.js +2 -10
- package/dist/commands/common/getFirstLineNumber.js +13 -20
- package/dist/commands/common/getFirstLineNumber.test.js +46 -51
- package/dist/commands/common/sendMessageToClient.js +2 -9
- package/dist/commands/common/utils/fileUtils.js +6 -16
- package/dist/commands/common/utils/settings.js +7 -13
- package/dist/commands/common/utils/unixSocket.js +2 -9
- package/dist/commands/common/utils/webTemplate.js +7 -16
- package/dist/commands/interface/run.js +34 -39
- package/dist/commands/ts-check.js +8 -12
- package/dist/common/Logger/Logger/index.js +9 -16
- package/dist/common/Logger/Logger/types.js +1 -5
- package/dist/common/Logger/index.js +9 -16
- package/dist/common/Logger/types.js +1 -5
- package/dist/common/asyncLocalStorage/index.js +4 -12
- package/dist/common/cleanEnvironmentVariables.js +1 -7
- package/dist/common/constants.js +1 -7
- package/dist/common/contextStorageStateHelpers.js +2 -9
- package/dist/common/getPlaywrightConstructs.js +28 -39
- package/dist/common/jwtTokenManager.js +8 -18
- package/dist/common/runApi/errors.js +24 -42
- package/dist/common/runApi/index.js +53 -88
- package/dist/common/runApi/types.js +31 -38
- package/dist/common/settingsSchema.js +2 -10
- package/dist/common/telemetry.js +3 -12
- package/dist/index.js +4 -69
- package/dist/runtime/RunError.js +1 -8
- package/dist/runtime/downloadDirectory.js +5 -11
- package/dist/runtime/enums.d.js +1 -5
- package/dist/runtime/enums.js +2 -8
- package/dist/runtime/executionHelpers.test.js +20 -22
- package/dist/runtime/export.d.js +1 -5
- package/dist/runtime/extendPayload.js +5 -11
- package/dist/runtime/extendTimeout.js +3 -9
- package/dist/runtime/index.js +6 -53
- package/dist/runtime/requestMoreInfo.js +2 -9
- package/dist/runtime/runInfo.js +5 -11
- package/package.json +3 -1
- package/preserve-dynamic-imports.js +16 -0
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.asyncLocalStorage = void 0;
|
|
7
|
-
exports.getExecutionContext = getExecutionContext;
|
|
8
|
-
exports.runWithContext = runWithContext;
|
|
9
|
-
var _async_hooks = require("async_hooks");
|
|
10
|
-
const asyncLocalStorage = exports.asyncLocalStorage = new _async_hooks.AsyncLocalStorage();
|
|
11
|
-
function runWithContext(contextData, callback, ...args) {
|
|
1
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
2
|
+
export const asyncLocalStorage = new AsyncLocalStorage();
|
|
3
|
+
export function runWithContext(contextData, callback, ...args) {
|
|
12
4
|
return asyncLocalStorage.run(contextData, callback, ...args);
|
|
13
5
|
}
|
|
14
|
-
function getExecutionContext() {
|
|
6
|
+
export function getExecutionContext() {
|
|
15
7
|
const contextData = asyncLocalStorage.getStore();
|
|
16
8
|
return contextData;
|
|
17
9
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cleanEnvironmentVariables = cleanEnvironmentVariables;
|
|
7
|
-
function cleanEnvironmentVariables() {
|
|
1
|
+
export function cleanEnvironmentVariables() {
|
|
8
2
|
Object.keys(process.env).filter(i => {
|
|
9
3
|
if (i.toLocaleLowerCase().startsWith("npm")) {
|
|
10
4
|
return true;
|
package/dist/common/constants.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
7
|
-
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
1
|
+
export const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getContextStorageState = getContextStorageState;
|
|
7
|
-
exports.setContextStorageState = setContextStorageState;
|
|
8
1
|
function sessionStorageToArray(storage) {
|
|
9
2
|
const result = [];
|
|
10
3
|
for (const key in storage) {
|
|
@@ -15,7 +8,7 @@ function sessionStorageToArray(storage) {
|
|
|
15
8
|
}
|
|
16
9
|
return result;
|
|
17
10
|
}
|
|
18
|
-
async function getContextStorageState(context) {
|
|
11
|
+
export async function getContextStorageState(context) {
|
|
19
12
|
const cookiesAndLocalStorage = await context.storageState();
|
|
20
13
|
const pages = context.pages();
|
|
21
14
|
const pagesSessions = [];
|
|
@@ -34,7 +27,7 @@ async function getContextStorageState(context) {
|
|
|
34
27
|
sessionStorage: pagesSessions
|
|
35
28
|
};
|
|
36
29
|
}
|
|
37
|
-
async function setContextStorageState(context, storage) {
|
|
30
|
+
export async function setContextStorageState(context, storage) {
|
|
38
31
|
await context.intunedSetStorageState(storage);
|
|
39
32
|
const sessionStorage = storage.sessionStorage;
|
|
40
33
|
await context.addInitScript(storage => {
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var playwright = _interopRequireWildcard(require("@intuned/playwright-core"));
|
|
11
|
-
var _fsExtra = _interopRequireWildcard(require("fs-extra"));
|
|
12
|
-
var fs = _fsExtra;
|
|
13
|
-
var _contextStorageStateHelpers = require("./contextStorageStateHelpers");
|
|
14
|
-
var _path = _interopRequireWildcard(require("path"));
|
|
15
|
-
var _fileUtils = require("../commands/common/utils/fileUtils");
|
|
16
|
-
var _waitOn = _interopRequireDefault(require("wait-on"));
|
|
17
|
-
var _runtime = require("../runtime");
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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 && Object.prototype.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; }
|
|
1
|
+
import * as playwright from "@intuned/playwright-core";
|
|
2
|
+
import { existsSync, mkdir, mkdtemp, rm, writeFile, readFile } from "fs-extra";
|
|
3
|
+
import { setContextStorageState } from "./contextStorageStateHelpers";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import * as fs from "fs-extra";
|
|
7
|
+
import { getFullPathInProject } from "../commands/common/utils/fileUtils";
|
|
8
|
+
import waitOn from "wait-on";
|
|
9
|
+
import { getDownloadDirectoryPath } from "../runtime";
|
|
21
10
|
async function createUserDirWithPreferences() {
|
|
22
|
-
const playwrightTempDir = await
|
|
23
|
-
const userDir =
|
|
24
|
-
const defaultDir =
|
|
25
|
-
await
|
|
11
|
+
const playwrightTempDir = await mkdtemp("/tmp/pw-");
|
|
12
|
+
const userDir = join(playwrightTempDir, "userdir");
|
|
13
|
+
const defaultDir = join(userDir, "Default");
|
|
14
|
+
await mkdir(defaultDir, {
|
|
26
15
|
recursive: true
|
|
27
16
|
});
|
|
28
17
|
const preferences = {
|
|
@@ -30,10 +19,10 @@ async function createUserDirWithPreferences() {
|
|
|
30
19
|
always_open_pdf_externally: true
|
|
31
20
|
}
|
|
32
21
|
};
|
|
33
|
-
await
|
|
22
|
+
await writeFile(join(defaultDir, "Preferences"), JSON.stringify(preferences));
|
|
34
23
|
return userDir;
|
|
35
24
|
}
|
|
36
|
-
async function getProductionPlaywrightConstructs({
|
|
25
|
+
export async function getProductionPlaywrightConstructs({
|
|
37
26
|
proxy,
|
|
38
27
|
headless = true,
|
|
39
28
|
storageState,
|
|
@@ -45,7 +34,7 @@ async function getProductionPlaywrightConstructs({
|
|
|
45
34
|
}
|
|
46
35
|
const executablePath = playwright.chromium.executablePath();
|
|
47
36
|
const chromium127Path = executablePath.replace("chromium-1117", "chromium-1124");
|
|
48
|
-
const isChrome127There =
|
|
37
|
+
const isChrome127There = existsSync(chromium127Path);
|
|
49
38
|
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
39
|
const userDataDir = await createUserDirWithPreferences();
|
|
51
40
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
@@ -59,7 +48,7 @@ async function getProductionPlaywrightConstructs({
|
|
|
59
48
|
});
|
|
60
49
|
context.once("close", async () => {
|
|
61
50
|
try {
|
|
62
|
-
await
|
|
51
|
+
await rm(userDataDir, {
|
|
63
52
|
recursive: true,
|
|
64
53
|
force: true,
|
|
65
54
|
retryDelay: 1000,
|
|
@@ -75,13 +64,13 @@ async function getProductionPlaywrightConstructs({
|
|
|
75
64
|
session: storageState
|
|
76
65
|
});
|
|
77
66
|
}
|
|
78
|
-
const assetsFile =
|
|
67
|
+
const assetsFile = path.join(__dirname, "./assets/browser_scripts.js");
|
|
79
68
|
await context.addInitScript({
|
|
80
69
|
path: assetsFile
|
|
81
70
|
});
|
|
82
71
|
let page = context.pages().at(0);
|
|
83
72
|
if (page) {
|
|
84
|
-
const scriptString = await
|
|
73
|
+
const scriptString = await readFile(assetsFile, "utf8");
|
|
85
74
|
await page.evaluate(scriptString);
|
|
86
75
|
} else {
|
|
87
76
|
page = await context.newPage();
|
|
@@ -92,7 +81,7 @@ async function getProductionPlaywrightConstructs({
|
|
|
92
81
|
};
|
|
93
82
|
}
|
|
94
83
|
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
|
-
async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
84
|
+
export async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
96
85
|
if (mode == "playwright-standalone") {
|
|
97
86
|
if (!cdpAddress) {
|
|
98
87
|
throw new Error("cdpAddress is required");
|
|
@@ -103,7 +92,7 @@ async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
|
103
92
|
if (!context) {
|
|
104
93
|
throw new Error("no context found");
|
|
105
94
|
}
|
|
106
|
-
const assetsFile =
|
|
95
|
+
const assetsFile = path.join(__dirname, "./assets/browser_scripts.js");
|
|
107
96
|
await context.addInitScript({
|
|
108
97
|
path: assetsFile
|
|
109
98
|
});
|
|
@@ -127,7 +116,7 @@ async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
|
127
116
|
context
|
|
128
117
|
};
|
|
129
118
|
}
|
|
130
|
-
const downloadsPath =
|
|
119
|
+
const downloadsPath = getDownloadDirectoryPath();
|
|
131
120
|
if (mode === "playwright" || mode === "playwright-headless") {
|
|
132
121
|
const productionConstructs = await getProductionPlaywrightConstructs({
|
|
133
122
|
headless: mode === "playwright-headless",
|
|
@@ -145,7 +134,7 @@ async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
|
145
134
|
}
|
|
146
135
|
throw "invalid mode";
|
|
147
136
|
}
|
|
148
|
-
async function loadSessionToContext({
|
|
137
|
+
export async function loadSessionToContext({
|
|
149
138
|
context,
|
|
150
139
|
session
|
|
151
140
|
}) {
|
|
@@ -153,20 +142,20 @@ async function loadSessionToContext({
|
|
|
153
142
|
if (session.type === "state") {
|
|
154
143
|
sessionToLoad = session.state;
|
|
155
144
|
} else {
|
|
156
|
-
const fullPath =
|
|
145
|
+
const fullPath = getFullPathInProject(session.path);
|
|
157
146
|
sessionToLoad = await fs.readJson(fullPath);
|
|
158
147
|
}
|
|
159
|
-
await
|
|
148
|
+
await setContextStorageState(context, sessionToLoad);
|
|
160
149
|
}
|
|
161
|
-
async function getRemotePlaywrightContext(cdpAddress) {
|
|
162
|
-
const playwright = await
|
|
150
|
+
export async function getRemotePlaywrightContext(cdpAddress) {
|
|
151
|
+
const playwright = await import("@intuned/playwright-core");
|
|
163
152
|
let browser = null;
|
|
164
153
|
if (!cdpAddress) {
|
|
165
154
|
throw new Error("cdpAddress is required");
|
|
166
155
|
}
|
|
167
156
|
const cdpAddressWithoutProtocol = cdpAddress.replace("http://", "").replace("https://", "").replace("localhost", "127.0.0.1");
|
|
168
157
|
try {
|
|
169
|
-
await (
|
|
158
|
+
await waitOn({
|
|
170
159
|
resources: [`http-get://${cdpAddressWithoutProtocol}/json/version`],
|
|
171
160
|
delay: 100,
|
|
172
161
|
interval: 100,
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.backendFunctionsTokenManager = void 0;
|
|
7
|
-
exports.callBackendFunctionWithToken = callBackendFunctionWithToken;
|
|
8
|
-
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
9
|
-
var jwt = _interopRequireWildcard(require("jsonwebtoken"));
|
|
10
|
-
var _neverthrow = require("neverthrow");
|
|
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 && Object.prototype.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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import fetch from "cross-fetch";
|
|
2
|
+
import * as jwt from "jsonwebtoken";
|
|
3
|
+
import { err, ResultAsync } from "neverthrow";
|
|
14
4
|
class JwtTokenManager {
|
|
15
5
|
constructor(refreshTokenPath) {
|
|
16
6
|
this.refreshTokenPath = refreshTokenPath;
|
|
@@ -57,9 +47,9 @@ class JwtTokenManager {
|
|
|
57
47
|
method: "GET"
|
|
58
48
|
});
|
|
59
49
|
if (res.status === 401) {
|
|
60
|
-
return
|
|
50
|
+
return err("Unauthorized");
|
|
61
51
|
}
|
|
62
|
-
const jsonResult = await
|
|
52
|
+
const jsonResult = await ResultAsync.fromPromise(res.json(), () => "not json");
|
|
63
53
|
if (jsonResult.isErr()) return;
|
|
64
54
|
const newToken = jsonResult.value.token;
|
|
65
55
|
if (newToken) this._token = newToken;
|
|
@@ -67,15 +57,15 @@ class JwtTokenManager {
|
|
|
67
57
|
fetchWithToken(...[input, init]) {
|
|
68
58
|
const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
|
|
69
59
|
headers.set("Authorization", `Bearer ${this.token}`);
|
|
70
|
-
return (
|
|
60
|
+
return fetch(input, {
|
|
71
61
|
...init,
|
|
72
62
|
headers
|
|
73
63
|
});
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
66
|
const backendFunctionsPath = `${process.env.FUNCTIONS_DOMAIN}/api/${process.env.INTUNED_WORKSPACE_ID}/functions/${process.env.INTUNED_INTEGRATION_ID}`;
|
|
77
|
-
const backendFunctionsTokenManager =
|
|
67
|
+
export const backendFunctionsTokenManager = new JwtTokenManager(`${backendFunctionsPath}/refreshBackendFunctionsToken`);
|
|
78
68
|
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
79
|
-
function callBackendFunctionWithToken(path, init) {
|
|
69
|
+
export function callBackendFunctionWithToken(path, init) {
|
|
80
70
|
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsPath}/${path}`, init);
|
|
81
71
|
}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const abortedErrorCode = exports.abortedErrorCode = "AbortedError";
|
|
15
|
-
const authRequiredErrorCode = exports.authRequiredErrorCode = "AuthRequiredError";
|
|
16
|
-
const authCheckNotFoundErrorCode = exports.authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
|
|
17
|
-
const authCheckFailedErrorCode = exports.authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
18
|
-
const maxLevelsExceededErrorCode = exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
19
|
-
const automationError = exports.automationError = "AutomationError";
|
|
20
|
-
const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError];
|
|
21
|
-
class RunAutomationError {
|
|
1
|
+
import { RunError } from "../../runtime";
|
|
2
|
+
import * as playwright from "@intuned/playwright-core";
|
|
3
|
+
export const apiNotFoundErrorCode = "APINotFoundError";
|
|
4
|
+
export const invalidApiErrorCode = "InvalidAPIError";
|
|
5
|
+
export const invalidCheckErrorCode = "InvalidCheckError";
|
|
6
|
+
export const abortedErrorCode = "AbortedError";
|
|
7
|
+
export const authRequiredErrorCode = "AuthRequiredError";
|
|
8
|
+
export const authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
|
|
9
|
+
export const authCheckFailedErrorCode = "AuthCheckFailedError";
|
|
10
|
+
export const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
11
|
+
export const automationError = "AutomationError";
|
|
12
|
+
export const runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError];
|
|
13
|
+
export class RunAutomationError {
|
|
22
14
|
wrapped = false;
|
|
23
15
|
get apiResponse() {
|
|
24
16
|
if (this.wrapped) {
|
|
@@ -48,8 +40,7 @@ class RunAutomationError {
|
|
|
48
40
|
};
|
|
49
41
|
}
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
class ApiNotFoundError extends RunAutomationError {
|
|
43
|
+
export class ApiNotFoundError extends RunAutomationError {
|
|
53
44
|
constructor(apiName) {
|
|
54
45
|
super();
|
|
55
46
|
this.code = apiNotFoundErrorCode;
|
|
@@ -57,8 +48,7 @@ class ApiNotFoundError extends RunAutomationError {
|
|
|
57
48
|
this.message = `API ${apiName} not found`;
|
|
58
49
|
}
|
|
59
50
|
}
|
|
60
|
-
|
|
61
|
-
class InvalidApiError extends RunAutomationError {
|
|
51
|
+
export class InvalidApiError extends RunAutomationError {
|
|
62
52
|
constructor(message) {
|
|
63
53
|
super();
|
|
64
54
|
this.code = invalidApiErrorCode;
|
|
@@ -66,8 +56,7 @@ class InvalidApiError extends RunAutomationError {
|
|
|
66
56
|
this.message = `API is invalid: ${message}`;
|
|
67
57
|
}
|
|
68
58
|
}
|
|
69
|
-
|
|
70
|
-
class InvalidCheckError extends RunAutomationError {
|
|
59
|
+
export class InvalidCheckError extends RunAutomationError {
|
|
71
60
|
constructor(message, cause) {
|
|
72
61
|
super();
|
|
73
62
|
this.code = invalidCheckErrorCode;
|
|
@@ -76,8 +65,7 @@ class InvalidCheckError extends RunAutomationError {
|
|
|
76
65
|
this.cause = cause;
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
|
-
|
|
80
|
-
class AbortedError extends RunAutomationError {
|
|
68
|
+
export class AbortedError extends RunAutomationError {
|
|
81
69
|
constructor() {
|
|
82
70
|
super();
|
|
83
71
|
this.code = abortedErrorCode;
|
|
@@ -85,8 +73,7 @@ class AbortedError extends RunAutomationError {
|
|
|
85
73
|
this.message = "Operation was aborted";
|
|
86
74
|
}
|
|
87
75
|
}
|
|
88
|
-
|
|
89
|
-
class AuthRequiredError extends RunAutomationError {
|
|
76
|
+
export class AuthRequiredError extends RunAutomationError {
|
|
90
77
|
constructor() {
|
|
91
78
|
super();
|
|
92
79
|
this.code = authRequiredErrorCode;
|
|
@@ -94,8 +81,7 @@ class AuthRequiredError extends RunAutomationError {
|
|
|
94
81
|
this.message = "Authentication is required";
|
|
95
82
|
}
|
|
96
83
|
}
|
|
97
|
-
|
|
98
|
-
class AuthCheckNotFoundError extends RunAutomationError {
|
|
84
|
+
export class AuthCheckNotFoundError extends RunAutomationError {
|
|
99
85
|
constructor() {
|
|
100
86
|
super();
|
|
101
87
|
this.code = authCheckNotFoundErrorCode;
|
|
@@ -103,8 +89,7 @@ class AuthCheckNotFoundError extends RunAutomationError {
|
|
|
103
89
|
this.message = "Auth check not found";
|
|
104
90
|
}
|
|
105
91
|
}
|
|
106
|
-
|
|
107
|
-
class AuthCheckFailedError extends RunAutomationError {
|
|
92
|
+
export class AuthCheckFailedError extends RunAutomationError {
|
|
108
93
|
constructor() {
|
|
109
94
|
super();
|
|
110
95
|
this.code = authCheckFailedErrorCode;
|
|
@@ -122,8 +107,7 @@ class AuthCheckFailedError extends RunAutomationError {
|
|
|
122
107
|
};
|
|
123
108
|
}
|
|
124
109
|
}
|
|
125
|
-
|
|
126
|
-
class MaxLevelsExceededError extends RunAutomationError {
|
|
110
|
+
export class MaxLevelsExceededError extends RunAutomationError {
|
|
127
111
|
constructor(levels) {
|
|
128
112
|
super();
|
|
129
113
|
this.code = maxLevelsExceededErrorCode;
|
|
@@ -134,8 +118,7 @@ class MaxLevelsExceededError extends RunAutomationError {
|
|
|
134
118
|
};
|
|
135
119
|
}
|
|
136
120
|
}
|
|
137
|
-
|
|
138
|
-
class AutomationError extends RunAutomationError {
|
|
121
|
+
export class AutomationError extends RunAutomationError {
|
|
139
122
|
constructor(error) {
|
|
140
123
|
super();
|
|
141
124
|
this.error = error;
|
|
@@ -149,7 +132,7 @@ class AutomationError extends RunAutomationError {
|
|
|
149
132
|
};
|
|
150
133
|
return;
|
|
151
134
|
}
|
|
152
|
-
if (error instanceof
|
|
135
|
+
if (error instanceof RunError) {
|
|
153
136
|
this.wrapped = true;
|
|
154
137
|
this.statusCode = error.options.status_code ?? 500;
|
|
155
138
|
this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
|
|
@@ -168,5 +151,4 @@ class AutomationError extends RunAutomationError {
|
|
|
168
151
|
message: error === null || error === void 0 ? void 0 : error.message
|
|
169
152
|
};
|
|
170
153
|
}
|
|
171
|
-
}
|
|
172
|
-
exports.AutomationError = AutomationError;
|
|
154
|
+
}
|