@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
|
@@ -0,0 +1,154 @@
|
|
|
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 {
|
|
14
|
+
wrapped = false;
|
|
15
|
+
get apiResponse() {
|
|
16
|
+
if (this.wrapped) {
|
|
17
|
+
return {
|
|
18
|
+
status: 200,
|
|
19
|
+
body: {
|
|
20
|
+
status: this.statusCode,
|
|
21
|
+
error: this.code,
|
|
22
|
+
message: this.message
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
status: this.statusCode,
|
|
28
|
+
body: {
|
|
29
|
+
error: this.code,
|
|
30
|
+
message: this.message
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
get json() {
|
|
35
|
+
var _this$cause;
|
|
36
|
+
return {
|
|
37
|
+
code: this.code,
|
|
38
|
+
details: this.details,
|
|
39
|
+
cause: (_this$cause = this.cause) === null || _this$cause === void 0 ? void 0 : _this$cause.json
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class ApiNotFoundError extends RunAutomationError {
|
|
44
|
+
constructor(apiName) {
|
|
45
|
+
super();
|
|
46
|
+
this.code = apiNotFoundErrorCode;
|
|
47
|
+
this.statusCode = 404;
|
|
48
|
+
this.message = `API ${apiName} not found`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class InvalidApiError extends RunAutomationError {
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super();
|
|
54
|
+
this.code = invalidApiErrorCode;
|
|
55
|
+
this.statusCode = 400;
|
|
56
|
+
this.message = `API is invalid: ${message}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class InvalidCheckError extends RunAutomationError {
|
|
60
|
+
constructor(message, cause) {
|
|
61
|
+
super();
|
|
62
|
+
this.code = invalidCheckErrorCode;
|
|
63
|
+
this.statusCode = 400;
|
|
64
|
+
this.message = message;
|
|
65
|
+
this.cause = cause;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class AbortedError extends RunAutomationError {
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
this.code = abortedErrorCode;
|
|
72
|
+
this.statusCode = 200;
|
|
73
|
+
this.message = "Operation was aborted";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class AuthRequiredError extends RunAutomationError {
|
|
77
|
+
constructor() {
|
|
78
|
+
super();
|
|
79
|
+
this.code = authRequiredErrorCode;
|
|
80
|
+
this.statusCode = 401;
|
|
81
|
+
this.message = "Authentication is required";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class AuthCheckNotFoundError extends RunAutomationError {
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
this.code = authCheckNotFoundErrorCode;
|
|
88
|
+
this.statusCode = 404;
|
|
89
|
+
this.message = "Auth check not found";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class AuthCheckFailedError extends RunAutomationError {
|
|
93
|
+
constructor() {
|
|
94
|
+
super();
|
|
95
|
+
this.code = authCheckFailedErrorCode;
|
|
96
|
+
this.statusCode = 401;
|
|
97
|
+
this.message = "auth session check failed";
|
|
98
|
+
}
|
|
99
|
+
get apiResponse() {
|
|
100
|
+
return {
|
|
101
|
+
status: 200,
|
|
102
|
+
body: {
|
|
103
|
+
status: this.statusCode,
|
|
104
|
+
error: "AUTH_SESSION_CHECK_FAILED",
|
|
105
|
+
message: this.message
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export class MaxLevelsExceededError extends RunAutomationError {
|
|
111
|
+
constructor(levels) {
|
|
112
|
+
super();
|
|
113
|
+
this.code = maxLevelsExceededErrorCode;
|
|
114
|
+
this.statusCode = 400;
|
|
115
|
+
this.message = `Max levels exceeded. Only ${levels} levels are supported`;
|
|
116
|
+
this.details = {
|
|
117
|
+
levels
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export class AutomationError extends RunAutomationError {
|
|
122
|
+
constructor(error) {
|
|
123
|
+
super();
|
|
124
|
+
this.error = error;
|
|
125
|
+
this.code = automationError;
|
|
126
|
+
if (error instanceof playwright.errors.TimeoutError) {
|
|
127
|
+
this.statusCode = 500;
|
|
128
|
+
this.message = `[${error.name}] ${error.message}`;
|
|
129
|
+
this.details = {
|
|
130
|
+
name: error.name,
|
|
131
|
+
message: error.message
|
|
132
|
+
};
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (error instanceof RunError) {
|
|
136
|
+
this.wrapped = true;
|
|
137
|
+
this.statusCode = error.options.status_code ?? 500;
|
|
138
|
+
this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
|
|
139
|
+
this.details = {
|
|
140
|
+
name: error.name,
|
|
141
|
+
statusCode: error.options.status_code,
|
|
142
|
+
errorCode: error.options.error_code,
|
|
143
|
+
message: error.message,
|
|
144
|
+
options: error.options
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
this.statusCode = 500;
|
|
148
|
+
this.message = `[${(error === null || error === void 0 ? void 0 : error.name) ?? error}] ${error === null || error === void 0 ? void 0 : error.message}`;
|
|
149
|
+
this.details = {
|
|
150
|
+
name: error === null || error === void 0 ? void 0 : error.name,
|
|
151
|
+
message: error === null || error === void 0 ? void 0 : error.message
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
|
-
import { RunAutomationError } from "./errors";
|
|
2
|
+
import { RunAutomationError } from "./errors.js";
|
|
3
3
|
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
4
|
-
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
|
|
5
|
-
export * from "./types";
|
|
6
|
-
export * from "./errors";
|
|
4
|
+
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types.js";
|
|
5
|
+
export * from "./types.js";
|
|
6
|
+
export * from "./errors.js";
|
|
7
7
|
export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters & {
|
|
8
8
|
retrieveSession: true;
|
|
9
9
|
}): AsyncGenerator<_YieldType, RunApiResult<ResultType, RunApiResultWithSessionOk>, _NextType>;
|