@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.
Files changed (103) hide show
  1. package/.babelrc +1 -2
  2. package/dist/commands/api/run.js +170 -105
  3. package/dist/commands/api/run.ts +105 -0
  4. package/dist/commands/auth-sessions/load.js +26 -28
  5. package/dist/commands/auth-sessions/load.ts +30 -0
  6. package/dist/commands/auth-sessions/run-check.js +53 -52
  7. package/dist/commands/auth-sessions/run-check.ts +51 -0
  8. package/dist/commands/auth-sessions/run-create.js +96 -91
  9. package/dist/commands/auth-sessions/run-create.ts +91 -0
  10. package/dist/commands/browser/save-state.js +16 -14
  11. package/dist/commands/browser/save-state.ts +14 -0
  12. package/dist/commands/browser/start-browser.js +11 -11
  13. package/dist/commands/browser/start-browser.ts +11 -0
  14. package/dist/commands/build.js +108 -75
  15. package/dist/commands/build.ts +78 -0
  16. package/dist/commands/common/browserUtils.js +51 -53
  17. package/dist/commands/common/browserUtils.ts +45 -0
  18. package/dist/commands/common/getDefaultExportFromFile.js +12 -17
  19. package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
  20. package/dist/commands/common/getFirstLineNumber.js +93 -93
  21. package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
  22. package/dist/commands/common/getFirstLineNumber.ts +96 -0
  23. package/dist/commands/common/sendMessageToClient.js +4 -9
  24. package/dist/commands/common/sendMessageToClient.ts +3 -0
  25. package/dist/commands/common/utils/fileUtils.js +22 -32
  26. package/dist/commands/common/utils/fileUtils.ts +23 -0
  27. package/dist/commands/common/utils/settings.js +19 -27
  28. package/dist/commands/common/utils/settings.ts +22 -0
  29. package/dist/commands/common/utils/unixSocket.js +43 -43
  30. package/dist/commands/common/utils/unixSocket.ts +38 -0
  31. package/dist/commands/common/utils/webTemplate.js +27 -29
  32. package/dist/commands/common/utils/webTemplate.ts +22 -0
  33. package/dist/commands/interface/run.js +151 -150
  34. package/dist/commands/interface/run.ts +156 -0
  35. package/dist/commands/ts-check.js +49 -49
  36. package/dist/commands/ts-check.ts +50 -0
  37. package/dist/common/Logger/Logger/index.d.ts +1 -1
  38. package/dist/common/Logger/Logger/index.js +42 -55
  39. package/dist/common/Logger/Logger/index.ts +53 -0
  40. package/dist/common/Logger/Logger/types.js +1 -5
  41. package/dist/common/Logger/Logger/types.ts +1 -0
  42. package/dist/common/Logger/index.d.ts +1 -1
  43. package/dist/common/Logger/index.js +42 -55
  44. package/dist/common/Logger/index.ts +53 -0
  45. package/dist/common/Logger/types.js +1 -5
  46. package/dist/common/Logger/types.ts +1 -0
  47. package/dist/common/asyncLocalStorage/index.js +8 -16
  48. package/dist/common/asyncLocalStorage/index.ts +9 -0
  49. package/dist/common/cleanEnvironmentVariables.js +12 -16
  50. package/dist/common/cleanEnvironmentVariables.ts +10 -0
  51. package/dist/common/constants.js +1 -7
  52. package/dist/common/constants.ts +1 -0
  53. package/dist/common/contextStorageStateHelpers.js +38 -47
  54. package/dist/common/contextStorageStateHelpers.ts +43 -0
  55. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  56. package/dist/common/getPlaywrightConstructs.js +196 -177
  57. package/dist/common/getPlaywrightConstructs.ts +181 -0
  58. package/dist/common/jwtTokenManager.js +79 -76
  59. package/dist/common/jwtTokenManager.ts +71 -0
  60. package/dist/common/runApi/errors.d.ts +1 -1
  61. package/dist/common/runApi/errors.js +150 -159
  62. package/dist/common/runApi/errors.ts +154 -0
  63. package/dist/common/runApi/index.d.ts +4 -4
  64. package/dist/common/runApi/index.js +220 -269
  65. package/dist/common/runApi/index.ts +253 -0
  66. package/dist/common/runApi/types.d.ts +1 -1
  67. package/dist/common/runApi/types.js +56 -49
  68. package/dist/common/runApi/types.ts +43 -0
  69. package/dist/common/settingsSchema.js +10 -15
  70. package/dist/common/settingsSchema.ts +9 -0
  71. package/dist/common/telemetry.js +30 -28
  72. package/dist/common/telemetry.ts +23 -0
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +4 -69
  75. package/dist/index.ts +4 -0
  76. package/dist/runtime/RunError.d.ts +1 -1
  77. package/dist/runtime/RunError.js +11 -18
  78. package/dist/runtime/RunError.ts +12 -0
  79. package/dist/runtime/downloadDirectory.js +13 -19
  80. package/dist/runtime/downloadDirectory.ts +13 -0
  81. package/dist/runtime/enums.d.ts +1 -11
  82. package/dist/runtime/enums.js +12 -18
  83. package/dist/runtime/enums.ts +12 -0
  84. package/dist/runtime/executionHelpers.test.ts +51 -0
  85. package/dist/runtime/export.d.ts +1 -202
  86. package/dist/runtime/extendPayload.d.ts +1 -1
  87. package/dist/runtime/extendPayload.js +15 -21
  88. package/dist/runtime/extendPayload.ts +15 -0
  89. package/dist/runtime/extendTimeout.js +21 -28
  90. package/dist/runtime/extendTimeout.ts +24 -0
  91. package/dist/runtime/index.d.ts +7 -7
  92. package/dist/runtime/index.js +6 -53
  93. package/dist/runtime/index.ts +6 -0
  94. package/dist/runtime/requestMoreInfo.js +16 -23
  95. package/dist/runtime/requestMoreInfo.ts +18 -0
  96. package/dist/runtime/runInfo.d.ts +1 -1
  97. package/dist/runtime/runInfo.js +14 -21
  98. package/dist/runtime/runInfo.ts +15 -0
  99. package/package.json +3 -2
  100. package/tsconfig.json +1 -1
  101. package/dist/runtime/enums.d.js +0 -5
  102. package/dist/runtime/executionHelpers.test.js +0 -53
  103. package/dist/runtime/export.d.js +0 -5
@@ -1,81 +1,84 @@
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 }; }
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
- 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();
6
+ constructor(refreshTokenPath) {
7
+ this.refreshTokenPath = refreshTokenPath;
8
+ this._token = undefined;
26
9
  }
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");
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 = 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
- }
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
- "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
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- 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;
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
- 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
- };
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;