@intuned/runtime-dev 0.1.0-test.10 → 0.1.0-test.12
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 +1 -2
- package/dist/commands/api/run.js +170 -105
- package/dist/commands/api/run.ts +105 -0
- package/dist/commands/auth-sessions/load.js +26 -28
- package/dist/commands/auth-sessions/load.ts +30 -0
- package/dist/commands/auth-sessions/run-check.js +53 -52
- package/dist/commands/auth-sessions/run-check.ts +51 -0
- package/dist/commands/auth-sessions/run-create.js +96 -91
- package/dist/commands/auth-sessions/run-create.ts +91 -0
- package/dist/commands/browser/save-state.js +16 -14
- package/dist/commands/browser/save-state.ts +14 -0
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/browser/start-browser.ts +11 -0
- package/dist/commands/build.js +108 -75
- package/dist/commands/build.ts +78 -0
- package/dist/commands/common/browserUtils.js +51 -53
- package/dist/commands/common/browserUtils.ts +45 -0
- package/dist/commands/common/getDefaultExportFromFile.js +12 -17
- package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
- package/dist/commands/common/getFirstLineNumber.ts +96 -0
- package/dist/commands/common/sendMessageToClient.js +4 -9
- package/dist/commands/common/sendMessageToClient.ts +3 -0
- package/dist/commands/common/utils/fileUtils.js +22 -32
- package/dist/commands/common/utils/fileUtils.ts +23 -0
- package/dist/commands/common/utils/settings.js +19 -27
- package/dist/commands/common/utils/settings.ts +22 -0
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/unixSocket.ts +38 -0
- package/dist/commands/common/utils/webTemplate.js +27 -29
- package/dist/commands/common/utils/webTemplate.ts +22 -0
- package/dist/commands/interface/run.js +151 -150
- package/dist/commands/interface/run.ts +156 -0
- package/dist/commands/ts-check.js +49 -49
- package/dist/commands/ts-check.ts +50 -0
- package/dist/common/Logger/Logger/index.d.ts +1 -1
- package/dist/common/Logger/Logger/index.js +42 -55
- package/dist/common/Logger/Logger/index.ts +53 -0
- package/dist/common/Logger/Logger/types.js +1 -5
- package/dist/common/Logger/Logger/types.ts +1 -0
- package/dist/common/Logger/index.d.ts +1 -1
- package/dist/common/Logger/index.js +42 -55
- package/dist/common/Logger/index.ts +53 -0
- package/dist/common/Logger/types.js +1 -5
- package/dist/common/Logger/types.ts +1 -0
- package/dist/common/asyncLocalStorage/index.js +8 -16
- package/dist/common/asyncLocalStorage/index.ts +9 -0
- package/dist/common/cleanEnvironmentVariables.js +12 -16
- package/dist/common/cleanEnvironmentVariables.ts +10 -0
- package/dist/common/constants.js +1 -7
- package/dist/common/constants.ts +1 -0
- package/dist/common/contextStorageStateHelpers.js +38 -47
- package/dist/common/contextStorageStateHelpers.ts +43 -0
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +196 -177
- package/dist/common/getPlaywrightConstructs.ts +181 -0
- package/dist/common/jwtTokenManager.js +79 -76
- package/dist/common/jwtTokenManager.ts +71 -0
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +150 -159
- package/dist/common/runApi/errors.ts +154 -0
- package/dist/common/runApi/index.d.ts +4 -4
- package/dist/common/runApi/index.js +220 -269
- package/dist/common/runApi/index.ts +253 -0
- package/dist/common/runApi/types.d.ts +1 -1
- package/dist/common/runApi/types.js +56 -49
- package/dist/common/runApi/types.ts +43 -0
- package/dist/common/settingsSchema.js +10 -15
- package/dist/common/settingsSchema.ts +9 -0
- package/dist/common/telemetry.js +30 -28
- package/dist/common/telemetry.ts +23 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -69
- package/dist/index.ts +4 -0
- package/dist/runtime/RunError.d.ts +1 -1
- package/dist/runtime/RunError.js +11 -18
- package/dist/runtime/RunError.ts +12 -0
- package/dist/runtime/downloadDirectory.js +13 -19
- package/dist/runtime/downloadDirectory.ts +13 -0
- package/dist/runtime/enums.d.ts +1 -11
- package/dist/runtime/enums.js +12 -18
- package/dist/runtime/enums.ts +12 -0
- package/dist/runtime/executionHelpers.test.ts +51 -0
- package/dist/runtime/export.d.ts +1 -202
- package/dist/runtime/extendPayload.d.ts +1 -1
- package/dist/runtime/extendPayload.js +15 -21
- package/dist/runtime/extendPayload.ts +15 -0
- package/dist/runtime/extendTimeout.js +21 -28
- package/dist/runtime/extendTimeout.ts +24 -0
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +6 -53
- package/dist/runtime/index.ts +6 -0
- package/dist/runtime/requestMoreInfo.js +16 -23
- package/dist/runtime/requestMoreInfo.ts +18 -0
- package/dist/runtime/runInfo.d.ts +1 -1
- package/dist/runtime/runInfo.js +14 -21
- package/dist/runtime/runInfo.ts +15 -0
- package/package.json +3 -2
- package/tsconfig.json +1 -1
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/executionHelpers.test.js +0 -53
- package/dist/runtime/export.d.js +0 -5
|
@@ -1,81 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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";
|
|
4
|
+
// Manages JWT token with renewal
|
|
14
5
|
class JwtTokenManager {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
get token() {
|
|
20
|
-
return this._token;
|
|
21
|
-
}
|
|
22
|
-
set token(newToken) {
|
|
23
|
-
if (this._token != newToken) {
|
|
24
|
-
this._token = newToken;
|
|
25
|
-
void this.scheduleTokenRefresh();
|
|
6
|
+
constructor(refreshTokenPath) {
|
|
7
|
+
this.refreshTokenPath = refreshTokenPath;
|
|
8
|
+
this._token = undefined;
|
|
26
9
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
10
|
+
get token() {
|
|
11
|
+
return this._token;
|
|
12
|
+
}
|
|
13
|
+
// When the token is set, the schedule for renewal is issued automatically
|
|
14
|
+
// This is currently being set it two places:
|
|
15
|
+
// 1. Whenever the runner starts, initializes it from the environment variable (set whenever the api is run from the authoring IDE)
|
|
16
|
+
// 2. Whenever a published api is called to run (/api/run/*), it is set to the token received in the run request.
|
|
17
|
+
set token(newToken) {
|
|
18
|
+
if (this._token != newToken) {
|
|
19
|
+
this._token = newToken;
|
|
20
|
+
void this.scheduleTokenRefresh();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
get timeToRefresh() {
|
|
24
|
+
if (!this._token)
|
|
25
|
+
return;
|
|
26
|
+
const payload = jwt.decode(this._token);
|
|
27
|
+
if (!payload || typeof payload == "string")
|
|
28
|
+
return;
|
|
29
|
+
const expiry = payload.expiry;
|
|
30
|
+
if (!expiry || typeof expiry !== "number")
|
|
31
|
+
return;
|
|
32
|
+
const timeWindow = 60 * 1000; // 1 minute
|
|
33
|
+
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
34
|
+
return Math.max(timeToRefresh, timeWindow);
|
|
35
|
+
}
|
|
36
|
+
async scheduleTokenRefresh() {
|
|
37
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring")
|
|
38
|
+
return;
|
|
39
|
+
const timeToRefresh = this.timeToRefresh;
|
|
40
|
+
if (timeToRefresh === undefined)
|
|
41
|
+
return;
|
|
42
|
+
if (this.tokenRefreshTimeout)
|
|
43
|
+
clearTimeout(this.tokenRefreshTimeout);
|
|
44
|
+
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
45
|
+
const result = await this.refreshToken();
|
|
46
|
+
if (result && result.isErr()) {
|
|
47
|
+
console.error(`[Internal Error] ${result.error}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await this.scheduleTokenRefresh();
|
|
51
|
+
}, timeToRefresh);
|
|
52
|
+
}
|
|
53
|
+
async refreshToken() {
|
|
54
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring")
|
|
55
|
+
return;
|
|
56
|
+
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
57
|
+
method: "GET",
|
|
58
|
+
});
|
|
59
|
+
if (res.status === 401) {
|
|
60
|
+
return err("Unauthorized");
|
|
61
|
+
}
|
|
62
|
+
const jsonResult = await ResultAsync.fromPromise(res.json(), () => "not json");
|
|
63
|
+
if (jsonResult.isErr())
|
|
64
|
+
return;
|
|
65
|
+
const newToken = jsonResult.value.token;
|
|
66
|
+
if (newToken)
|
|
67
|
+
this._token = newToken;
|
|
68
|
+
}
|
|
69
|
+
fetchWithToken(...[input, init]) {
|
|
70
|
+
const headers = new Headers(init?.headers);
|
|
71
|
+
headers.set("Authorization", `Bearer ${this.token}`);
|
|
72
|
+
return fetch(input, {
|
|
73
|
+
...init,
|
|
74
|
+
headers,
|
|
75
|
+
});
|
|
61
76
|
}
|
|
62
|
-
const jsonResult = await _neverthrow.ResultAsync.fromPromise(res.json(), () => "not json");
|
|
63
|
-
if (jsonResult.isErr()) return;
|
|
64
|
-
const newToken = jsonResult.value.token;
|
|
65
|
-
if (newToken) this._token = newToken;
|
|
66
|
-
}
|
|
67
|
-
fetchWithToken(...[input, init]) {
|
|
68
|
-
const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
|
|
69
|
-
headers.set("Authorization", `Bearer ${this.token}`);
|
|
70
|
-
return (0, _crossFetch.default)(input, {
|
|
71
|
-
...init,
|
|
72
|
-
headers
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
77
|
}
|
|
76
78
|
const backendFunctionsPath = `${process.env.FUNCTIONS_DOMAIN}/api/${process.env.INTUNED_WORKSPACE_ID}/functions/${process.env.INTUNED_INTEGRATION_ID}`;
|
|
77
|
-
const backendFunctionsTokenManager =
|
|
78
|
-
backendFunctionsTokenManager.token =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
79
|
+
export const backendFunctionsTokenManager = new JwtTokenManager(`${backendFunctionsPath}/refreshBackendFunctionsToken`);
|
|
80
|
+
backendFunctionsTokenManager.token =
|
|
81
|
+
process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
82
|
+
export function callBackendFunctionWithToken(path, init) {
|
|
83
|
+
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsPath}/${path}`, init);
|
|
84
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fetch from "cross-fetch";
|
|
2
|
+
import * as jwt from "jsonwebtoken";
|
|
3
|
+
import { err, ResultAsync } from "neverthrow";
|
|
4
|
+
class JwtTokenManager {
|
|
5
|
+
constructor(refreshTokenPath) {
|
|
6
|
+
this.refreshTokenPath = refreshTokenPath;
|
|
7
|
+
this._token = undefined;
|
|
8
|
+
}
|
|
9
|
+
get token() {
|
|
10
|
+
return this._token;
|
|
11
|
+
}
|
|
12
|
+
set token(newToken) {
|
|
13
|
+
if (this._token != newToken) {
|
|
14
|
+
this._token = newToken;
|
|
15
|
+
void this.scheduleTokenRefresh();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
get timeToRefresh() {
|
|
19
|
+
if (!this._token) return;
|
|
20
|
+
const payload = jwt.decode(this._token);
|
|
21
|
+
if (!payload || typeof payload == "string") return;
|
|
22
|
+
const expiry = payload.expiry;
|
|
23
|
+
if (!expiry || typeof expiry !== "number") return;
|
|
24
|
+
const timeWindow = 60 * 1000;
|
|
25
|
+
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
26
|
+
return Math.max(timeToRefresh, timeWindow);
|
|
27
|
+
}
|
|
28
|
+
async scheduleTokenRefresh() {
|
|
29
|
+
var _process$env$RUN_ENVI;
|
|
30
|
+
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;
|
|
31
|
+
const timeToRefresh = this.timeToRefresh;
|
|
32
|
+
if (timeToRefresh === undefined) return;
|
|
33
|
+
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
34
|
+
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
35
|
+
const result = await this.refreshToken();
|
|
36
|
+
if (result && result.isErr()) {
|
|
37
|
+
console.error(`[Internal Error] ${result.error}`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
await this.scheduleTokenRefresh();
|
|
41
|
+
}, timeToRefresh);
|
|
42
|
+
}
|
|
43
|
+
async refreshToken() {
|
|
44
|
+
var _process$env$RUN_ENVI2;
|
|
45
|
+
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;
|
|
46
|
+
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
47
|
+
method: "GET"
|
|
48
|
+
});
|
|
49
|
+
if (res.status === 401) {
|
|
50
|
+
return err("Unauthorized");
|
|
51
|
+
}
|
|
52
|
+
const jsonResult = await ResultAsync.fromPromise(res.json(), () => "not json");
|
|
53
|
+
if (jsonResult.isErr()) return;
|
|
54
|
+
const newToken = jsonResult.value.token;
|
|
55
|
+
if (newToken) this._token = newToken;
|
|
56
|
+
}
|
|
57
|
+
fetchWithToken(...[input, init]) {
|
|
58
|
+
const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
|
|
59
|
+
headers.set("Authorization", `Bearer ${this.token}`);
|
|
60
|
+
return fetch(input, {
|
|
61
|
+
...init,
|
|
62
|
+
headers
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const backendFunctionsPath = `${process.env.FUNCTIONS_DOMAIN}/api/${process.env.INTUNED_WORKSPACE_ID}/functions/${process.env.INTUNED_INTEGRATION_ID}`;
|
|
67
|
+
export const backendFunctionsTokenManager = new JwtTokenManager(`${backendFunctionsPath}/refreshBackendFunctionsToken`);
|
|
68
|
+
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
69
|
+
export function callBackendFunctionWithToken(path, init) {
|
|
70
|
+
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsPath}/${path}`, init);
|
|
71
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunAutomationResponse } from "./types";
|
|
1
|
+
import { RunAutomationResponse } from "./types.js";
|
|
2
2
|
import { RunErrorOptions } from "src/runtime/export";
|
|
3
3
|
export declare const apiNotFoundErrorCode = "APINotFoundError";
|
|
4
4
|
export declare const invalidApiErrorCode = "InvalidAPIError";
|
|
@@ -1,172 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 = [
|
|
13
|
+
apiNotFoundErrorCode,
|
|
14
|
+
invalidApiErrorCode,
|
|
15
|
+
invalidCheckErrorCode,
|
|
16
|
+
abortedErrorCode,
|
|
17
|
+
authRequiredErrorCode,
|
|
18
|
+
authCheckNotFoundErrorCode,
|
|
19
|
+
authCheckFailedErrorCode,
|
|
20
|
+
maxLevelsExceededErrorCode,
|
|
21
|
+
automationError,
|
|
22
|
+
];
|
|
23
|
+
export class RunAutomationError {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.wrapped = false;
|
|
26
|
+
}
|
|
27
|
+
get apiResponse() {
|
|
28
|
+
if (this.wrapped) {
|
|
29
|
+
return {
|
|
30
|
+
status: 200,
|
|
31
|
+
body: {
|
|
32
|
+
status: this.statusCode,
|
|
33
|
+
error: this.code,
|
|
34
|
+
message: this.message,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
31
37
|
}
|
|
32
|
-
|
|
38
|
+
return {
|
|
39
|
+
status: this.statusCode,
|
|
40
|
+
body: {
|
|
41
|
+
error: this.code,
|
|
42
|
+
message: this.message,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
get json() {
|
|
47
|
+
return {
|
|
48
|
+
code: this.code,
|
|
49
|
+
details: this.details,
|
|
50
|
+
cause: this.cause?.json,
|
|
51
|
+
};
|
|
33
52
|
}
|
|
34
|
-
return {
|
|
35
|
-
status: this.statusCode,
|
|
36
|
-
body: {
|
|
37
|
-
error: this.code,
|
|
38
|
-
message: this.message
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
get json() {
|
|
43
|
-
var _this$cause;
|
|
44
|
-
return {
|
|
45
|
-
code: this.code,
|
|
46
|
-
details: this.details,
|
|
47
|
-
cause: (_this$cause = this.cause) === null || _this$cause === void 0 ? void 0 : _this$cause.json
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.RunAutomationError = RunAutomationError;
|
|
52
|
-
class ApiNotFoundError extends RunAutomationError {
|
|
53
|
-
constructor(apiName) {
|
|
54
|
-
super();
|
|
55
|
-
this.code = apiNotFoundErrorCode;
|
|
56
|
-
this.statusCode = 404;
|
|
57
|
-
this.message = `API ${apiName} not found`;
|
|
58
|
-
}
|
|
59
53
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
54
|
+
export class ApiNotFoundError extends RunAutomationError {
|
|
55
|
+
constructor(apiName) {
|
|
56
|
+
super();
|
|
57
|
+
this.code = apiNotFoundErrorCode;
|
|
58
|
+
this.statusCode = 404;
|
|
59
|
+
this.message = `API ${apiName} not found`;
|
|
60
|
+
}
|
|
68
61
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.cause = cause;
|
|
77
|
-
}
|
|
62
|
+
export class InvalidApiError extends RunAutomationError {
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super();
|
|
65
|
+
this.code = invalidApiErrorCode;
|
|
66
|
+
this.statusCode = 400;
|
|
67
|
+
this.message = `API is invalid: ${message}`;
|
|
68
|
+
}
|
|
78
69
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
export class InvalidCheckError extends RunAutomationError {
|
|
71
|
+
constructor(message, cause) {
|
|
72
|
+
super();
|
|
73
|
+
this.code = invalidCheckErrorCode;
|
|
74
|
+
this.statusCode = 400;
|
|
75
|
+
this.message = message;
|
|
76
|
+
this.cause = cause;
|
|
77
|
+
}
|
|
87
78
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
79
|
+
export class AbortedError extends RunAutomationError {
|
|
80
|
+
constructor() {
|
|
81
|
+
super();
|
|
82
|
+
this.code = abortedErrorCode;
|
|
83
|
+
this.statusCode = 200;
|
|
84
|
+
this.message = "Operation was aborted";
|
|
85
|
+
}
|
|
96
86
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
87
|
+
export class AuthRequiredError extends RunAutomationError {
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
this.code = authRequiredErrorCode;
|
|
91
|
+
this.statusCode = 401;
|
|
92
|
+
this.message = "Authentication is required";
|
|
93
|
+
}
|
|
105
94
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
get apiResponse() {
|
|
115
|
-
return {
|
|
116
|
-
status: 200,
|
|
117
|
-
body: {
|
|
118
|
-
status: this.statusCode,
|
|
119
|
-
error: "AUTH_SESSION_CHECK_FAILED",
|
|
120
|
-
message: this.message
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
95
|
+
export class AuthCheckNotFoundError extends RunAutomationError {
|
|
96
|
+
constructor() {
|
|
97
|
+
super();
|
|
98
|
+
this.code = authCheckNotFoundErrorCode;
|
|
99
|
+
this.statusCode = 404;
|
|
100
|
+
this.message = "Auth check not found";
|
|
101
|
+
}
|
|
124
102
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
103
|
+
export class AuthCheckFailedError extends RunAutomationError {
|
|
104
|
+
constructor() {
|
|
105
|
+
super();
|
|
106
|
+
this.code = authCheckFailedErrorCode;
|
|
107
|
+
this.statusCode = 401;
|
|
108
|
+
this.message = "auth session check failed";
|
|
109
|
+
}
|
|
110
|
+
get apiResponse() {
|
|
111
|
+
return {
|
|
112
|
+
status: 200,
|
|
113
|
+
body: {
|
|
114
|
+
status: this.statusCode,
|
|
115
|
+
error: "AUTH_SESSION_CHECK_FAILED",
|
|
116
|
+
message: this.message,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
136
120
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.statusCode = 500;
|
|
145
|
-
this.message = `[${error.name}] ${error.message}`;
|
|
146
|
-
this.details = {
|
|
147
|
-
name: error.name,
|
|
148
|
-
message: error.message
|
|
149
|
-
};
|
|
150
|
-
return;
|
|
121
|
+
export class MaxLevelsExceededError extends RunAutomationError {
|
|
122
|
+
constructor(levels) {
|
|
123
|
+
super();
|
|
124
|
+
this.code = maxLevelsExceededErrorCode;
|
|
125
|
+
this.statusCode = 400;
|
|
126
|
+
this.message = `Max levels exceeded. Only ${levels} levels are supported`;
|
|
127
|
+
this.details = { levels };
|
|
151
128
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
129
|
+
}
|
|
130
|
+
export class AutomationError extends RunAutomationError {
|
|
131
|
+
constructor(error) {
|
|
132
|
+
super();
|
|
133
|
+
this.error = error;
|
|
134
|
+
this.code = automationError;
|
|
135
|
+
if (error instanceof playwright.errors.TimeoutError) {
|
|
136
|
+
this.statusCode = 500;
|
|
137
|
+
this.message = `[${error.name}] ${error.message}`;
|
|
138
|
+
this.details = {
|
|
139
|
+
name: error.name,
|
|
140
|
+
message: error.message,
|
|
141
|
+
};
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (error instanceof RunError) {
|
|
145
|
+
this.wrapped = true;
|
|
146
|
+
this.statusCode = error.options.status_code ?? 500;
|
|
147
|
+
this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
|
|
148
|
+
this.details = {
|
|
149
|
+
name: error.name,
|
|
150
|
+
statusCode: error.options.status_code,
|
|
151
|
+
errorCode: error.options.error_code,
|
|
152
|
+
message: error.message,
|
|
153
|
+
options: error.options,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
this.statusCode = 500;
|
|
157
|
+
this.message = `[${error?.name ?? error}] ${error?.message}`;
|
|
158
|
+
this.details = {
|
|
159
|
+
name: error?.name,
|
|
160
|
+
message: error?.message,
|
|
161
|
+
};
|
|
163
162
|
}
|
|
164
|
-
this.statusCode = 500;
|
|
165
|
-
this.message = `[${(error === null || error === void 0 ? void 0 : error.name) ?? error}] ${error === null || error === void 0 ? void 0 : error.message}`;
|
|
166
|
-
this.details = {
|
|
167
|
-
name: error === null || error === void 0 ? void 0 : error.name,
|
|
168
|
-
message: error === null || error === void 0 ? void 0 : error.message
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
163
|
}
|
|
172
|
-
exports.AutomationError = AutomationError;
|