playwright-automation-core 1.0.0
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/LICENSE +21 -0
- package/README.md +225 -0
- package/dist/api/api.assertions.d.ts +196 -0
- package/dist/api/api.assertions.d.ts.map +1 -0
- package/dist/api/api.assertions.js +462 -0
- package/dist/api/api.assertions.js.map +1 -0
- package/dist/api/api.builder.d.ts +134 -0
- package/dist/api/api.builder.d.ts.map +1 -0
- package/dist/api/api.builder.js +273 -0
- package/dist/api/api.builder.js.map +1 -0
- package/dist/api/api.client.d.ts +157 -0
- package/dist/api/api.client.d.ts.map +1 -0
- package/dist/api/api.client.js +493 -0
- package/dist/api/api.client.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +17 -0
- package/dist/api/index.js.map +1 -0
- package/dist/core/base.driver.d.ts +130 -0
- package/dist/core/base.driver.d.ts.map +1 -0
- package/dist/core/base.driver.js +264 -0
- package/dist/core/base.driver.js.map +1 -0
- package/dist/core/driver.factory.d.ts +120 -0
- package/dist/core/driver.factory.d.ts.map +1 -0
- package/dist/core/driver.factory.js +222 -0
- package/dist/core/driver.factory.js.map +1 -0
- package/dist/core/element.actions.d.ts +119 -0
- package/dist/core/element.actions.d.ts.map +1 -0
- package/dist/core/element.actions.js +379 -0
- package/dist/core/element.actions.js.map +1 -0
- package/dist/core/hook.manager.d.ts +186 -0
- package/dist/core/hook.manager.d.ts.map +1 -0
- package/dist/core/hook.manager.js +297 -0
- package/dist/core/hook.manager.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/mobile/index.d.ts +7 -0
- package/dist/mobile/index.d.ts.map +1 -0
- package/dist/mobile/index.js +14 -0
- package/dist/mobile/index.js.map +1 -0
- package/dist/mobile/mobile.assertions.d.ts +146 -0
- package/dist/mobile/mobile.assertions.d.ts.map +1 -0
- package/dist/mobile/mobile.assertions.js +333 -0
- package/dist/mobile/mobile.assertions.js.map +1 -0
- package/dist/mobile/mobile.driver.d.ts +297 -0
- package/dist/mobile/mobile.driver.d.ts.map +1 -0
- package/dist/mobile/mobile.driver.js +808 -0
- package/dist/mobile/mobile.driver.js.map +1 -0
- package/dist/types/common.types.d.ts +200 -0
- package/dist/types/common.types.d.ts.map +1 -0
- package/dist/types/common.types.js +3 -0
- package/dist/types/common.types.js.map +1 -0
- package/dist/types/config.types.d.ts +192 -0
- package/dist/types/config.types.d.ts.map +1 -0
- package/dist/types/config.types.js +3 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/driver.types.d.ts +500 -0
- package/dist/types/driver.types.d.ts.map +1 -0
- package/dist/types/driver.types.js +3 -0
- package/dist/types/driver.types.js.map +1 -0
- package/dist/types/enums.d.ts +53 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +62 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +15 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.manager.d.ts +144 -0
- package/dist/utils/config.manager.d.ts.map +1 -0
- package/dist/utils/config.manager.js +473 -0
- package/dist/utils/config.manager.js.map +1 -0
- package/dist/utils/errors.d.ts +149 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +290 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/helpers.d.ts +124 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +421 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +78 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +145 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +235 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/wait.utils.d.ts +95 -0
- package/dist/utils/wait.utils.d.ts.map +1 -0
- package/dist/utils/wait.utils.js +306 -0
- package/dist/utils/wait.utils.js.map +1 -0
- package/dist/web/index.d.ts +8 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +16 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/web.assertions.d.ts +164 -0
- package/dist/web/web.assertions.d.ts.map +1 -0
- package/dist/web/web.assertions.js +427 -0
- package/dist/web/web.assertions.js.map +1 -0
- package/dist/web/web.driver.d.ts +174 -0
- package/dist/web/web.driver.d.ts.map +1 -0
- package/dist/web/web.driver.js +571 -0
- package/dist/web/web.driver.js.map +1 -0
- package/dist/web/web.page.d.ts +286 -0
- package/dist/web/web.page.d.ts.map +1 -0
- package/dist/web/web.page.js +570 -0
- package/dist/web/web.page.js.map +1 -0
- package/package.json +115 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Platform } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Base error class for all framework errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class FrameworkError extends Error {
|
|
6
|
+
/** Error code for categorization */
|
|
7
|
+
readonly code: string;
|
|
8
|
+
/** Timestamp when error occurred */
|
|
9
|
+
readonly timestamp: Date;
|
|
10
|
+
/** Additional context/metadata */
|
|
11
|
+
readonly context?: Record<string, unknown>;
|
|
12
|
+
constructor(message: string, code?: string, context?: Record<string, unknown>);
|
|
13
|
+
/**
|
|
14
|
+
* Convert error to JSON format
|
|
15
|
+
*/
|
|
16
|
+
toJSON(): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Create formatted string representation
|
|
19
|
+
*/
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when driver initialization fails
|
|
24
|
+
*/
|
|
25
|
+
export declare class DriverInitializationError extends FrameworkError {
|
|
26
|
+
readonly platform: Platform;
|
|
27
|
+
constructor(platform: Platform, message: string, context?: Record<string, unknown>);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error thrown when driver is not initialized
|
|
31
|
+
*/
|
|
32
|
+
export declare class DriverNotInitializedError extends FrameworkError {
|
|
33
|
+
readonly platform: Platform;
|
|
34
|
+
constructor(platform: Platform, operation: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown when element is not found
|
|
38
|
+
*/
|
|
39
|
+
export declare class ElementNotFoundError extends FrameworkError {
|
|
40
|
+
readonly locator: string;
|
|
41
|
+
readonly timeout: number;
|
|
42
|
+
constructor(locator: string, timeout: number, context?: Record<string, unknown>);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when element is not interactable
|
|
46
|
+
*/
|
|
47
|
+
export declare class ElementNotInteractableError extends FrameworkError {
|
|
48
|
+
readonly locator: string;
|
|
49
|
+
readonly action: string;
|
|
50
|
+
constructor(locator: string, action: string, reason?: string);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Error thrown when navigation fails
|
|
54
|
+
*/
|
|
55
|
+
export declare class NavigationError extends FrameworkError {
|
|
56
|
+
readonly url: string;
|
|
57
|
+
constructor(url: string, reason: string, context?: Record<string, unknown>);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when API request fails
|
|
61
|
+
*/
|
|
62
|
+
export declare class ApiRequestError extends FrameworkError {
|
|
63
|
+
readonly method: string;
|
|
64
|
+
readonly url: string;
|
|
65
|
+
readonly statusCode?: number;
|
|
66
|
+
readonly responseBody?: unknown;
|
|
67
|
+
constructor(method: string, url: string, message: string, statusCode?: number, responseBody?: unknown);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Error thrown when API response validation fails
|
|
71
|
+
*/
|
|
72
|
+
export declare class ApiValidationError extends FrameworkError {
|
|
73
|
+
readonly endpoint: string;
|
|
74
|
+
readonly validationErrors: string[];
|
|
75
|
+
constructor(endpoint: string, validationErrors: string[]);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Error thrown when mobile operation fails
|
|
79
|
+
*/
|
|
80
|
+
export declare class MobileOperationError extends FrameworkError {
|
|
81
|
+
readonly operation: string;
|
|
82
|
+
readonly platform: Platform;
|
|
83
|
+
constructor(operation: string, platform: Platform, message: string, context?: Record<string, unknown>);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Error thrown when configuration is invalid
|
|
87
|
+
*/
|
|
88
|
+
export declare class ConfigurationError extends FrameworkError {
|
|
89
|
+
readonly configKey?: string;
|
|
90
|
+
constructor(message: string, configKey?: string);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Error thrown when screenshot capture fails
|
|
94
|
+
*/
|
|
95
|
+
export declare class ScreenshotError extends FrameworkError {
|
|
96
|
+
readonly path?: string;
|
|
97
|
+
constructor(message: string, path?: string);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Error thrown when session is invalid or expired
|
|
101
|
+
*/
|
|
102
|
+
export declare class SessionError extends FrameworkError {
|
|
103
|
+
readonly sessionId?: string;
|
|
104
|
+
constructor(message: string, sessionId?: string);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Error thrown when context switching fails
|
|
108
|
+
*/
|
|
109
|
+
export declare class ContextError extends FrameworkError {
|
|
110
|
+
readonly targetContext: string;
|
|
111
|
+
readonly availableContexts?: string[];
|
|
112
|
+
constructor(message: string, targetContext: string, availableContexts?: string[]);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Error thrown when assertion fails
|
|
116
|
+
*/
|
|
117
|
+
export declare class AssertionError extends FrameworkError {
|
|
118
|
+
readonly expected: unknown;
|
|
119
|
+
readonly actual: unknown;
|
|
120
|
+
constructor(message: string, expected: unknown, actual: unknown);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Error thrown when network operation fails
|
|
124
|
+
*/
|
|
125
|
+
export declare class NetworkError extends FrameworkError {
|
|
126
|
+
readonly requestUrl?: string;
|
|
127
|
+
constructor(message: string, requestUrl?: string, context?: Record<string, unknown>);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Error thrown when file operation fails
|
|
131
|
+
*/
|
|
132
|
+
export declare class FileOperationError extends FrameworkError {
|
|
133
|
+
readonly filePath: string;
|
|
134
|
+
readonly operation: "read" | "write" | "delete" | "upload" | "download";
|
|
135
|
+
constructor(operation: "read" | "write" | "delete" | "upload" | "download", filePath: string, reason: string);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Utility function to wrap an error with additional context
|
|
139
|
+
*/
|
|
140
|
+
export declare function wrapError(error: Error, context: Record<string, unknown>): FrameworkError;
|
|
141
|
+
/**
|
|
142
|
+
* Check if error is a framework error
|
|
143
|
+
*/
|
|
144
|
+
export declare function isFrameworkError(error: unknown): error is FrameworkError;
|
|
145
|
+
/**
|
|
146
|
+
* Check if error is a specific type of framework error
|
|
147
|
+
*/
|
|
148
|
+
export declare function isErrorOfType<T extends FrameworkError>(error: unknown, errorClass: new (...args: unknown[]) => T): error is T;
|
|
149
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,oCAAoC;IACpC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,oCAAoC;IACpC,SAAgB,SAAS,EAAE,IAAI,CAAC;IAChC,kCAAkC;IAClC,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGhD,OAA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,EAAE,OAAO,EACd,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,GACxC,KAAK,IAAI,CAAC,CAEZ"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileOperationError = exports.NetworkError = exports.AssertionError = exports.ContextError = exports.SessionError = exports.ScreenshotError = exports.ConfigurationError = exports.MobileOperationError = exports.ApiValidationError = exports.ApiRequestError = exports.NavigationError = exports.ElementNotInteractableError = exports.ElementNotFoundError = exports.DriverNotInitializedError = exports.DriverInitializationError = exports.FrameworkError = void 0;
|
|
4
|
+
exports.wrapError = wrapError;
|
|
5
|
+
exports.isFrameworkError = isFrameworkError;
|
|
6
|
+
exports.isErrorOfType = isErrorOfType;
|
|
7
|
+
/**
|
|
8
|
+
* Base error class for all framework errors
|
|
9
|
+
*/
|
|
10
|
+
class FrameworkError extends Error {
|
|
11
|
+
/** Error code for categorization */
|
|
12
|
+
code;
|
|
13
|
+
/** Timestamp when error occurred */
|
|
14
|
+
timestamp;
|
|
15
|
+
/** Additional context/metadata */
|
|
16
|
+
context;
|
|
17
|
+
constructor(message, code = "FRAMEWORK_ERROR", context) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "FrameworkError";
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.timestamp = new Date();
|
|
22
|
+
this.context = context;
|
|
23
|
+
// Maintains proper stack trace for where our error was thrown
|
|
24
|
+
Error.captureStackTrace(this, this.constructor);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert error to JSON format
|
|
28
|
+
*/
|
|
29
|
+
toJSON() {
|
|
30
|
+
return {
|
|
31
|
+
name: this.name,
|
|
32
|
+
message: this.message,
|
|
33
|
+
code: this.code,
|
|
34
|
+
timestamp: this.timestamp.toISOString(),
|
|
35
|
+
context: this.context,
|
|
36
|
+
stack: this.stack,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create formatted string representation
|
|
41
|
+
*/
|
|
42
|
+
toString() {
|
|
43
|
+
let str = `${this.name} [${this.code}]: ${this.message}`;
|
|
44
|
+
if (this.context) {
|
|
45
|
+
str += `\nContext: ${JSON.stringify(this.context, null, 2)}`;
|
|
46
|
+
}
|
|
47
|
+
return str;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.FrameworkError = FrameworkError;
|
|
51
|
+
/**
|
|
52
|
+
* Error thrown when driver initialization fails
|
|
53
|
+
*/
|
|
54
|
+
class DriverInitializationError extends FrameworkError {
|
|
55
|
+
platform;
|
|
56
|
+
constructor(platform, message, context) {
|
|
57
|
+
super(message, "DRIVER_INIT_ERROR", { platform, ...context });
|
|
58
|
+
this.name = "DriverInitializationError";
|
|
59
|
+
this.platform = platform;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.DriverInitializationError = DriverInitializationError;
|
|
63
|
+
/**
|
|
64
|
+
* Error thrown when driver is not initialized
|
|
65
|
+
*/
|
|
66
|
+
class DriverNotInitializedError extends FrameworkError {
|
|
67
|
+
platform;
|
|
68
|
+
constructor(platform, operation) {
|
|
69
|
+
super(`Driver not initialized. Cannot perform operation: ${operation}`, "DRIVER_NOT_INITIALIZED", { platform, operation });
|
|
70
|
+
this.name = "DriverNotInitializedError";
|
|
71
|
+
this.platform = platform;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.DriverNotInitializedError = DriverNotInitializedError;
|
|
75
|
+
/**
|
|
76
|
+
* Error thrown when element is not found
|
|
77
|
+
*/
|
|
78
|
+
class ElementNotFoundError extends FrameworkError {
|
|
79
|
+
locator;
|
|
80
|
+
timeout;
|
|
81
|
+
constructor(locator, timeout, context) {
|
|
82
|
+
super(`Element not found: ${locator} (timeout: ${timeout}ms)`, "ELEMENT_NOT_FOUND", { locator, timeout, ...context });
|
|
83
|
+
this.name = "ElementNotFoundError";
|
|
84
|
+
this.locator = locator;
|
|
85
|
+
this.timeout = timeout;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.ElementNotFoundError = ElementNotFoundError;
|
|
89
|
+
/**
|
|
90
|
+
* Error thrown when element is not interactable
|
|
91
|
+
*/
|
|
92
|
+
class ElementNotInteractableError extends FrameworkError {
|
|
93
|
+
locator;
|
|
94
|
+
action;
|
|
95
|
+
constructor(locator, action, reason) {
|
|
96
|
+
super(`Element not interactable for ${action}: ${locator}${reason ? ` - ${reason}` : ""}`, "ELEMENT_NOT_INTERACTABLE", { locator, action, reason });
|
|
97
|
+
this.name = "ElementNotInteractableError";
|
|
98
|
+
this.locator = locator;
|
|
99
|
+
this.action = action;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.ElementNotInteractableError = ElementNotInteractableError;
|
|
103
|
+
/**
|
|
104
|
+
* Error thrown when navigation fails
|
|
105
|
+
*/
|
|
106
|
+
class NavigationError extends FrameworkError {
|
|
107
|
+
url;
|
|
108
|
+
constructor(url, reason, context) {
|
|
109
|
+
super(`Navigation failed to ${url}: ${reason}`, "NAVIGATION_ERROR", {
|
|
110
|
+
url,
|
|
111
|
+
reason,
|
|
112
|
+
...context,
|
|
113
|
+
});
|
|
114
|
+
this.name = "NavigationError";
|
|
115
|
+
this.url = url;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.NavigationError = NavigationError;
|
|
119
|
+
/**
|
|
120
|
+
* Error thrown when API request fails
|
|
121
|
+
*/
|
|
122
|
+
class ApiRequestError extends FrameworkError {
|
|
123
|
+
method;
|
|
124
|
+
url;
|
|
125
|
+
statusCode;
|
|
126
|
+
responseBody;
|
|
127
|
+
constructor(method, url, message, statusCode, responseBody) {
|
|
128
|
+
super(`API request failed: ${method} ${url} - ${message}`, "API_REQUEST_ERROR", { method, url, statusCode, responseBody });
|
|
129
|
+
this.name = "ApiRequestError";
|
|
130
|
+
this.method = method;
|
|
131
|
+
this.url = url;
|
|
132
|
+
this.statusCode = statusCode;
|
|
133
|
+
this.responseBody = responseBody;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.ApiRequestError = ApiRequestError;
|
|
137
|
+
/**
|
|
138
|
+
* Error thrown when API response validation fails
|
|
139
|
+
*/
|
|
140
|
+
class ApiValidationError extends FrameworkError {
|
|
141
|
+
endpoint;
|
|
142
|
+
validationErrors;
|
|
143
|
+
constructor(endpoint, validationErrors) {
|
|
144
|
+
super(`API response validation failed for ${endpoint}: ${validationErrors.join(", ")}`, "API_VALIDATION_ERROR", { endpoint, validationErrors });
|
|
145
|
+
this.name = "ApiValidationError";
|
|
146
|
+
this.endpoint = endpoint;
|
|
147
|
+
this.validationErrors = validationErrors;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.ApiValidationError = ApiValidationError;
|
|
151
|
+
/**
|
|
152
|
+
* Error thrown when mobile operation fails
|
|
153
|
+
*/
|
|
154
|
+
class MobileOperationError extends FrameworkError {
|
|
155
|
+
operation;
|
|
156
|
+
platform;
|
|
157
|
+
constructor(operation, platform, message, context) {
|
|
158
|
+
super(`Mobile operation failed: ${operation} - ${message}`, "MOBILE_OPERATION_ERROR", { operation, platform, ...context });
|
|
159
|
+
this.name = "MobileOperationError";
|
|
160
|
+
this.operation = operation;
|
|
161
|
+
this.platform = platform;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.MobileOperationError = MobileOperationError;
|
|
165
|
+
/**
|
|
166
|
+
* Error thrown when configuration is invalid
|
|
167
|
+
*/
|
|
168
|
+
class ConfigurationError extends FrameworkError {
|
|
169
|
+
configKey;
|
|
170
|
+
constructor(message, configKey) {
|
|
171
|
+
super(message, "CONFIGURATION_ERROR", { configKey });
|
|
172
|
+
this.name = "ConfigurationError";
|
|
173
|
+
this.configKey = configKey;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.ConfigurationError = ConfigurationError;
|
|
177
|
+
/**
|
|
178
|
+
* Error thrown when screenshot capture fails
|
|
179
|
+
*/
|
|
180
|
+
class ScreenshotError extends FrameworkError {
|
|
181
|
+
path;
|
|
182
|
+
constructor(message, path) {
|
|
183
|
+
super(`Screenshot capture failed: ${message}`, "SCREENSHOT_ERROR", {
|
|
184
|
+
path,
|
|
185
|
+
});
|
|
186
|
+
this.name = "ScreenshotError";
|
|
187
|
+
this.path = path;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.ScreenshotError = ScreenshotError;
|
|
191
|
+
/**
|
|
192
|
+
* Error thrown when session is invalid or expired
|
|
193
|
+
*/
|
|
194
|
+
class SessionError extends FrameworkError {
|
|
195
|
+
sessionId;
|
|
196
|
+
constructor(message, sessionId) {
|
|
197
|
+
super(`Session error: ${message}`, "SESSION_ERROR", { sessionId });
|
|
198
|
+
this.name = "SessionError";
|
|
199
|
+
this.sessionId = sessionId;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.SessionError = SessionError;
|
|
203
|
+
/**
|
|
204
|
+
* Error thrown when context switching fails
|
|
205
|
+
*/
|
|
206
|
+
class ContextError extends FrameworkError {
|
|
207
|
+
targetContext;
|
|
208
|
+
availableContexts;
|
|
209
|
+
constructor(message, targetContext, availableContexts) {
|
|
210
|
+
super(`Context switch failed: ${message}`, "CONTEXT_ERROR", {
|
|
211
|
+
targetContext,
|
|
212
|
+
availableContexts,
|
|
213
|
+
});
|
|
214
|
+
this.name = "ContextError";
|
|
215
|
+
this.targetContext = targetContext;
|
|
216
|
+
this.availableContexts = availableContexts;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.ContextError = ContextError;
|
|
220
|
+
/**
|
|
221
|
+
* Error thrown when assertion fails
|
|
222
|
+
*/
|
|
223
|
+
class AssertionError extends FrameworkError {
|
|
224
|
+
expected;
|
|
225
|
+
actual;
|
|
226
|
+
constructor(message, expected, actual) {
|
|
227
|
+
super(message, "ASSERTION_ERROR", { expected, actual });
|
|
228
|
+
this.name = "AssertionError";
|
|
229
|
+
this.expected = expected;
|
|
230
|
+
this.actual = actual;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.AssertionError = AssertionError;
|
|
234
|
+
/**
|
|
235
|
+
* Error thrown when network operation fails
|
|
236
|
+
*/
|
|
237
|
+
class NetworkError extends FrameworkError {
|
|
238
|
+
requestUrl;
|
|
239
|
+
constructor(message, requestUrl, context) {
|
|
240
|
+
super(`Network error: ${message}`, "NETWORK_ERROR", {
|
|
241
|
+
requestUrl,
|
|
242
|
+
...context,
|
|
243
|
+
});
|
|
244
|
+
this.name = "NetworkError";
|
|
245
|
+
this.requestUrl = requestUrl;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
exports.NetworkError = NetworkError;
|
|
249
|
+
/**
|
|
250
|
+
* Error thrown when file operation fails
|
|
251
|
+
*/
|
|
252
|
+
class FileOperationError extends FrameworkError {
|
|
253
|
+
filePath;
|
|
254
|
+
operation;
|
|
255
|
+
constructor(operation, filePath, reason) {
|
|
256
|
+
super(`File ${operation} failed for ${filePath}: ${reason}`, "FILE_OPERATION_ERROR", { operation, filePath });
|
|
257
|
+
this.name = "FileOperationError";
|
|
258
|
+
this.filePath = filePath;
|
|
259
|
+
this.operation = operation;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
exports.FileOperationError = FileOperationError;
|
|
263
|
+
/**
|
|
264
|
+
* Utility function to wrap an error with additional context
|
|
265
|
+
*/
|
|
266
|
+
function wrapError(error, context) {
|
|
267
|
+
if (error instanceof FrameworkError) {
|
|
268
|
+
return new FrameworkError(error.message, error.code, {
|
|
269
|
+
...error.context,
|
|
270
|
+
...context,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return new FrameworkError(error.message, "WRAPPED_ERROR", {
|
|
274
|
+
originalName: error.name,
|
|
275
|
+
...context,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Check if error is a framework error
|
|
280
|
+
*/
|
|
281
|
+
function isFrameworkError(error) {
|
|
282
|
+
return error instanceof FrameworkError;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Check if error is a specific type of framework error
|
|
286
|
+
*/
|
|
287
|
+
function isErrorOfType(error, errorClass) {
|
|
288
|
+
return error instanceof errorClass;
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;AAgWA,8BAcC;AAKD,4CAEC;AAKD,sCAKC;AA7XD;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,oCAAoC;IACpB,IAAI,CAAS;IAC7B,oCAAoC;IACpB,SAAS,CAAO;IAChC,kCAAkC;IAClB,OAAO,CAA2B;IAElD,YACE,OAAe,EACf,OAAe,iBAAiB,EAChC,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,8DAA8D;QAC9D,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,IAAI,GAAG,GAAG,GAAG,IAAI,CA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AO,EAAE,KAAK,CAAC,IAAI,EAAE;YACnD,GAAG,KAAK,CAAC,OAAO;YAChB,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE;QACxD,YAAY,EAAE,KAAK,CAAC,IAAI;QACxB,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,YAAY,cAAc,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAC3B,KAAc,EACd,UAAyC;IAEzC,OAAO,KAAK,YAAY,UAAU,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep merge two objects
|
|
3
|
+
*/
|
|
4
|
+
export declare function deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>): T;
|
|
5
|
+
/**
|
|
6
|
+
* Check if value is a plain object
|
|
7
|
+
*/
|
|
8
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Deep clone an object
|
|
11
|
+
*/
|
|
12
|
+
export declare function deepClone<T>(obj: T): T;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a unique ID
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateId(prefix?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a UUID v4
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateUUID(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format a timestamp
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatTimestamp(date?: Date, format?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Ensure directory exists, create if not
|
|
27
|
+
*/
|
|
28
|
+
export declare function ensureDir(dirPath: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Save data to a JSON file
|
|
31
|
+
*/
|
|
32
|
+
export declare function saveJson(filePath: string, data: unknown, pretty?: boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* Load data from a JSON file
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadJson<T>(filePath: string): T | null;
|
|
37
|
+
/**
|
|
38
|
+
* Convert bytes to human readable string
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatBytes(bytes: number, decimals?: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Format duration in milliseconds to human readable string
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatDuration(ms: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* Truncate string to specified length
|
|
47
|
+
*/
|
|
48
|
+
export declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Escape special regex characters
|
|
51
|
+
*/
|
|
52
|
+
export declare function escapeRegex(str: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Convert camelCase to kebab-case
|
|
55
|
+
*/
|
|
56
|
+
export declare function camelToKebab(str: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Convert kebab-case to camelCase
|
|
59
|
+
*/
|
|
60
|
+
export declare function kebabToCamel(str: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Convert string to title case
|
|
63
|
+
*/
|
|
64
|
+
export declare function toTitleCase(str: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Check if running in CI environment
|
|
67
|
+
*/
|
|
68
|
+
export declare function isCI(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get OS platform
|
|
71
|
+
*/
|
|
72
|
+
export declare function getOSPlatform(): "windows" | "macos" | "linux";
|
|
73
|
+
/**
|
|
74
|
+
* Safely parse JSON with error handling
|
|
75
|
+
*/
|
|
76
|
+
export declare function safeJsonParse<T>(json: string, defaultValue: T): T;
|
|
77
|
+
/**
|
|
78
|
+
* Create a debounced function
|
|
79
|
+
*/
|
|
80
|
+
export declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Create a throttled function
|
|
83
|
+
*/
|
|
84
|
+
export declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, limit: number): (...args: Parameters<T>) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Measure execution time of an async function
|
|
87
|
+
*/
|
|
88
|
+
export declare function measureTime<T>(fn: () => Promise<T>): Promise<{
|
|
89
|
+
result: T;
|
|
90
|
+
duration: number;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* Convert Map to plain object
|
|
94
|
+
*/
|
|
95
|
+
export declare function mapToObject<K extends string | number | symbol, V>(map: Map<K, V>): Record<K, V>;
|
|
96
|
+
/**
|
|
97
|
+
* Convert object to Map
|
|
98
|
+
*/
|
|
99
|
+
export declare function objectToMap<K extends string | number | symbol, V>(obj: Record<K, V>): Map<K, V>;
|
|
100
|
+
/**
|
|
101
|
+
* Pick specific keys from an object
|
|
102
|
+
*/
|
|
103
|
+
export declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
104
|
+
/**
|
|
105
|
+
* Omit specific keys from an object
|
|
106
|
+
*/
|
|
107
|
+
export declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
108
|
+
/**
|
|
109
|
+
* Check if two objects are deeply equal
|
|
110
|
+
*/
|
|
111
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Flatten a nested object
|
|
114
|
+
*/
|
|
115
|
+
export declare function flattenObject(obj: Record<string, unknown>, prefix?: string, separator?: string): Record<string, unknown>;
|
|
116
|
+
/**
|
|
117
|
+
* Get nested value from object using dot notation path
|
|
118
|
+
*/
|
|
119
|
+
export declare function getNestedValue<T>(obj: Record<string, unknown>, path: string, defaultValue?: T): T | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Set nested value in object using dot notation path
|
|
122
|
+
*/
|
|
123
|
+
export declare function setNestedValue(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
124
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjB,CAAC,CAkBH;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAetC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAItD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,GAAE,IAAiB,EACvB,MAAM,GAAE,MAA8B,GACrC,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAK/C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,MAAM,GAAE,OAAc,GACrB,IAAI,CAKN;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAOtD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAWvE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAgBjD;AAED;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