@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16
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/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/authSessions/create.ts +2 -2
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +14 -12
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +53 -1
- package/api/test2.ts +6 -1
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +109 -170
- package/dist/commands/auth-sessions/load.js +28 -26
- package/dist/commands/auth-sessions/run-check.js +54 -53
- package/dist/commands/auth-sessions/run-create.js +93 -96
- package/dist/commands/browser/save-state.js +14 -16
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/build.js +79 -109
- package/dist/commands/common/browserUtils.js +53 -51
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
- package/dist/commands/common/sendMessageToClient.js +9 -4
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/tsNodeImport.js +18 -0
- package/dist/commands/common/utils/fileUtils.js +32 -22
- package/dist/commands/common/utils/settings.js +27 -19
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/webTemplate.js +30 -28
- package/dist/commands/interface/run.js +162 -139
- package/dist/commands/ts-check.js +50 -50
- package/dist/common/Logger/Logger/index.js +55 -42
- package/dist/common/Logger/Logger/types.js +5 -1
- package/dist/common/Logger/index.js +55 -42
- package/dist/common/Logger/types.js +5 -1
- package/dist/common/asyncLocalStorage/index.js +16 -8
- package/dist/common/cleanEnvironmentVariables.js +16 -12
- package/dist/common/constants.js +7 -1
- package/dist/common/contextStorageStateHelpers.js +47 -38
- package/dist/common/getPlaywrightConstructs.js +178 -197
- package/dist/common/jwtTokenManager.js +76 -79
- package/dist/common/runApi/errors.js +159 -150
- package/dist/common/runApi/index.js +240 -232
- package/dist/common/runApi/types.d.ts +19 -5
- package/dist/common/runApi/types.js +53 -56
- package/dist/common/settingsSchema.js +15 -10
- package/dist/common/telemetry.js +28 -30
- package/dist/index.js +69 -4
- package/dist/runtime/RunError.js +18 -11
- package/dist/runtime/downloadDirectory.js +19 -13
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -1
- package/dist/runtime/enums.js +18 -12
- package/dist/runtime/executionHelpers.test.js +53 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +202 -1
- package/dist/runtime/extendPayload.js +21 -15
- package/dist/runtime/extendTimeout.js +28 -21
- package/dist/runtime/index.js +53 -6
- package/dist/runtime/requestMoreInfo.js +23 -16
- package/dist/runtime/runInfo.js +21 -14
- package/package.json +4 -7
- package/dist/commands/api/run.ts +0 -105
- package/dist/commands/auth-sessions/load.ts +0 -30
- package/dist/commands/auth-sessions/run-check.ts +0 -51
- package/dist/commands/auth-sessions/run-create.ts +0 -91
- package/dist/commands/browser/save-state.ts +0 -14
- package/dist/commands/browser/start-browser.ts +0 -11
- package/dist/commands/build.ts +0 -79
- package/dist/commands/common/browserUtils.ts +0 -45
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -12
- package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
- package/dist/commands/common/getFirstLineNumber.ts +0 -96
- package/dist/commands/common/sendMessageToClient.ts +0 -3
- package/dist/commands/common/utils/fileUtils.ts +0 -23
- package/dist/commands/common/utils/settings.ts +0 -22
- package/dist/commands/common/utils/unixSocket.ts +0 -38
- package/dist/commands/common/utils/webTemplate.ts +0 -23
- package/dist/commands/interface/run.ts +0 -156
- package/dist/commands/ts-check.ts +0 -51
- package/dist/common/Logger/Logger/index.ts +0 -53
- package/dist/common/Logger/Logger/types.ts +0 -1
- package/dist/common/Logger/index.ts +0 -53
- package/dist/common/Logger/types.ts +0 -1
- package/dist/common/asyncLocalStorage/index.ts +0 -9
- package/dist/common/cleanEnvironmentVariables.ts +0 -10
- package/dist/common/constants.ts +0 -1
- package/dist/common/contextStorageStateHelpers.ts +0 -43
- package/dist/common/getPlaywrightConstructs.ts +0 -182
- package/dist/common/jwtTokenManager.ts +0 -71
- package/dist/common/runApi/errors.ts +0 -154
- package/dist/common/runApi/index.ts +0 -253
- package/dist/common/runApi/types.ts +0 -43
- package/dist/common/settingsSchema.ts +0 -9
- package/dist/common/telemetry.ts +0 -23
- package/dist/index.ts +0 -4
- package/dist/runtime/RunError.ts +0 -12
- package/dist/runtime/downloadDirectory.ts +0 -13
- package/dist/runtime/enums.ts +0 -12
- package/dist/runtime/executionHelpers.test.ts +0 -51
- package/dist/runtime/extendPayload.ts +0 -15
- package/dist/runtime/extendTimeout.ts +0 -24
- package/dist/runtime/index.ts +0 -6
- package/dist/runtime/requestMoreInfo.ts +0 -18
- package/dist/runtime/runInfo.ts +0 -15
|
@@ -1,84 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
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 }; }
|
|
5
14
|
class JwtTokenManager {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
constructor(refreshTokenPath) {
|
|
16
|
+
this.refreshTokenPath = refreshTokenPath;
|
|
17
|
+
this._token = undefined;
|
|
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();
|
|
9
26
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
});
|
|
27
|
+
}
|
|
28
|
+
get timeToRefresh() {
|
|
29
|
+
if (!this._token) return;
|
|
30
|
+
const payload = jwt.decode(this._token);
|
|
31
|
+
if (!payload || typeof payload == "string") return;
|
|
32
|
+
const expiry = payload.expiry;
|
|
33
|
+
if (!expiry || typeof expiry !== "number") return;
|
|
34
|
+
const timeWindow = 60 * 1000;
|
|
35
|
+
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
36
|
+
return Math.max(timeToRefresh, timeWindow);
|
|
37
|
+
}
|
|
38
|
+
async scheduleTokenRefresh() {
|
|
39
|
+
var _process$env$RUN_ENVI;
|
|
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;
|
|
41
|
+
const timeToRefresh = this.timeToRefresh;
|
|
42
|
+
if (timeToRefresh === undefined) return;
|
|
43
|
+
if (this.tokenRefreshTimeout) 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
|
+
var _process$env$RUN_ENVI2;
|
|
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;
|
|
56
|
+
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
57
|
+
method: "GET"
|
|
58
|
+
});
|
|
59
|
+
if (res.status === 401) {
|
|
60
|
+
return (0, _neverthrow.err)("Unauthorized");
|
|
76
61
|
}
|
|
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
|
+
}
|
|
77
75
|
}
|
|
78
76
|
const backendFunctionsPath = `${process.env.FUNCTIONS_DOMAIN}/api/${process.env.INTUNED_WORKSPACE_ID}/functions/${process.env.INTUNED_INTEGRATION_ID}`;
|
|
79
|
-
|
|
80
|
-
backendFunctionsTokenManager.token =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
77
|
+
const backendFunctionsTokenManager = exports.backendFunctionsTokenManager = new JwtTokenManager(`${backendFunctionsPath}/refreshBackendFunctionsToken`);
|
|
78
|
+
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
79
|
+
function callBackendFunctionWithToken(path, init) {
|
|
80
|
+
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsPath}/${path}`, init);
|
|
81
|
+
}
|
|
@@ -1,163 +1,172 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
body: {
|
|
32
|
-
status: this.statusCode,
|
|
33
|
-
error: this.code,
|
|
34
|
-
message: this.message,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
|
+
var _runtime = require("../../runtime");
|
|
8
|
+
var playwright = _interopRequireWildcard(require("@intuned/playwright-core"));
|
|
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 && 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; }
|
|
11
|
+
const apiNotFoundErrorCode = exports.apiNotFoundErrorCode = "APINotFoundError";
|
|
12
|
+
const invalidApiErrorCode = exports.invalidApiErrorCode = "InvalidAPIError";
|
|
13
|
+
const invalidCheckErrorCode = exports.invalidCheckErrorCode = "InvalidCheckError";
|
|
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 {
|
|
22
|
+
wrapped = false;
|
|
23
|
+
get apiResponse() {
|
|
24
|
+
if (this.wrapped) {
|
|
25
|
+
return {
|
|
26
|
+
status: 200,
|
|
27
|
+
body: {
|
|
28
|
+
status: this.statusCode,
|
|
29
|
+
error: this.code,
|
|
30
|
+
message: this.message
|
|
37
31
|
}
|
|
38
|
-
|
|
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
|
-
};
|
|
32
|
+
};
|
|
52
33
|
}
|
|
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
|
+
}
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
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
|
+
}
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
60
|
+
exports.ApiNotFoundError = ApiNotFoundError;
|
|
61
|
+
class InvalidApiError extends RunAutomationError {
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super();
|
|
64
|
+
this.code = invalidApiErrorCode;
|
|
65
|
+
this.statusCode = 400;
|
|
66
|
+
this.message = `API is invalid: ${message}`;
|
|
67
|
+
}
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
exports.InvalidApiError = InvalidApiError;
|
|
70
|
+
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
|
+
}
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
exports.InvalidCheckError = InvalidCheckError;
|
|
80
|
+
class AbortedError extends RunAutomationError {
|
|
81
|
+
constructor() {
|
|
82
|
+
super();
|
|
83
|
+
this.code = abortedErrorCode;
|
|
84
|
+
this.statusCode = 200;
|
|
85
|
+
this.message = "Operation was aborted";
|
|
86
|
+
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
exports.AbortedError = AbortedError;
|
|
89
|
+
class AuthRequiredError extends RunAutomationError {
|
|
90
|
+
constructor() {
|
|
91
|
+
super();
|
|
92
|
+
this.code = authRequiredErrorCode;
|
|
93
|
+
this.statusCode = 401;
|
|
94
|
+
this.message = "Authentication is required";
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
exports.AuthRequiredError = AuthRequiredError;
|
|
98
|
+
class AuthCheckNotFoundError extends RunAutomationError {
|
|
99
|
+
constructor() {
|
|
100
|
+
super();
|
|
101
|
+
this.code = authCheckNotFoundErrorCode;
|
|
102
|
+
this.statusCode = 404;
|
|
103
|
+
this.message = "Auth check not found";
|
|
104
|
+
}
|
|
102
105
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
106
|
+
exports.AuthCheckNotFoundError = AuthCheckNotFoundError;
|
|
107
|
+
class AuthCheckFailedError extends RunAutomationError {
|
|
108
|
+
constructor() {
|
|
109
|
+
super();
|
|
110
|
+
this.code = authCheckFailedErrorCode;
|
|
111
|
+
this.statusCode = 401;
|
|
112
|
+
this.message = "auth session check failed";
|
|
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
|
+
}
|
|
120
124
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
exports.AuthCheckFailedError = AuthCheckFailedError;
|
|
126
|
+
class MaxLevelsExceededError extends RunAutomationError {
|
|
127
|
+
constructor(levels) {
|
|
128
|
+
super();
|
|
129
|
+
this.code = maxLevelsExceededErrorCode;
|
|
130
|
+
this.statusCode = 400;
|
|
131
|
+
this.message = `Max levels exceeded. Only ${levels} levels are supported`;
|
|
132
|
+
this.details = {
|
|
133
|
+
levels
|
|
134
|
+
};
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
};
|
|
137
|
+
exports.MaxLevelsExceededError = MaxLevelsExceededError;
|
|
138
|
+
class AutomationError extends RunAutomationError {
|
|
139
|
+
constructor(error) {
|
|
140
|
+
super();
|
|
141
|
+
this.error = error;
|
|
142
|
+
this.code = automationError;
|
|
143
|
+
if (error instanceof playwright.errors.TimeoutError) {
|
|
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;
|
|
151
|
+
}
|
|
152
|
+
if (error instanceof _runtime.RunError) {
|
|
153
|
+
this.wrapped = true;
|
|
154
|
+
this.statusCode = error.options.status_code ?? 500;
|
|
155
|
+
this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
|
|
156
|
+
this.details = {
|
|
157
|
+
name: error.name,
|
|
158
|
+
statusCode: error.options.status_code,
|
|
159
|
+
errorCode: error.options.error_code,
|
|
160
|
+
message: error.message,
|
|
161
|
+
options: error.options
|
|
162
|
+
};
|
|
162
163
|
}
|
|
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
|
+
}
|
|
163
171
|
}
|
|
172
|
+
exports.AutomationError = AutomationError;
|