@emesoft_company/playwright-core 2.1.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.
Files changed (92) hide show
  1. package/README.md +62 -0
  2. package/dist/api/index.cjs +248 -0
  3. package/dist/api/index.cjs.map +1 -0
  4. package/dist/api/index.d.cts +12 -0
  5. package/dist/api/index.d.ts +12 -0
  6. package/dist/api/index.js +245 -0
  7. package/dist/api/index.js.map +1 -0
  8. package/dist/api-client-C_StjpPX.d.ts +58 -0
  9. package/dist/api-client-CpXo_NOU.d.cts +58 -0
  10. package/dist/auth/index.cjs +310 -0
  11. package/dist/auth/index.cjs.map +1 -0
  12. package/dist/auth/index.d.cts +98 -0
  13. package/dist/auth/index.d.ts +98 -0
  14. package/dist/auth/index.js +304 -0
  15. package/dist/auth/index.js.map +1 -0
  16. package/dist/config/index.cjs +268 -0
  17. package/dist/config/index.cjs.map +1 -0
  18. package/dist/config/index.d.cts +105 -0
  19. package/dist/config/index.d.ts +105 -0
  20. package/dist/config/index.js +254 -0
  21. package/dist/config/index.js.map +1 -0
  22. package/dist/data/index.cjs +59 -0
  23. package/dist/data/index.cjs.map +1 -0
  24. package/dist/data/index.d.cts +25 -0
  25. package/dist/data/index.d.ts +25 -0
  26. package/dist/data/index.js +50 -0
  27. package/dist/data/index.js.map +1 -0
  28. package/dist/di/index.cjs +47 -0
  29. package/dist/di/index.cjs.map +1 -0
  30. package/dist/di/index.d.cts +19 -0
  31. package/dist/di/index.d.ts +19 -0
  32. package/dist/di/index.js +45 -0
  33. package/dist/di/index.js.map +1 -0
  34. package/dist/errors/index.cjs +90 -0
  35. package/dist/errors/index.cjs.map +1 -0
  36. package/dist/errors/index.d.cts +38 -0
  37. package/dist/errors/index.d.ts +38 -0
  38. package/dist/errors/index.js +83 -0
  39. package/dist/errors/index.js.map +1 -0
  40. package/dist/expect/index.cjs +36 -0
  41. package/dist/expect/index.cjs.map +1 -0
  42. package/dist/expect/index.d.cts +30 -0
  43. package/dist/expect/index.d.ts +30 -0
  44. package/dist/expect/index.js +34 -0
  45. package/dist/expect/index.js.map +1 -0
  46. package/dist/fixtures/index.cjs +660 -0
  47. package/dist/fixtures/index.cjs.map +1 -0
  48. package/dist/fixtures/index.d.cts +68 -0
  49. package/dist/fixtures/index.d.ts +68 -0
  50. package/dist/fixtures/index.js +651 -0
  51. package/dist/fixtures/index.js.map +1 -0
  52. package/dist/index.cjs +1322 -0
  53. package/dist/index.cjs.map +1 -0
  54. package/dist/index.d.cts +21 -0
  55. package/dist/index.d.ts +21 -0
  56. package/dist/index.js +1248 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/logging/index.cjs +32 -0
  59. package/dist/logging/index.cjs.map +1 -0
  60. package/dist/logging/index.d.cts +18 -0
  61. package/dist/logging/index.d.ts +18 -0
  62. package/dist/logging/index.js +25 -0
  63. package/dist/logging/index.js.map +1 -0
  64. package/dist/reporting/index.cjs +59 -0
  65. package/dist/reporting/index.cjs.map +1 -0
  66. package/dist/reporting/index.d.cts +63 -0
  67. package/dist/reporting/index.d.ts +63 -0
  68. package/dist/reporting/index.js +52 -0
  69. package/dist/reporting/index.js.map +1 -0
  70. package/dist/retry-XqnSC8YL.d.cts +27 -0
  71. package/dist/retry-XqnSC8YL.d.ts +27 -0
  72. package/dist/schema-y5w2hbT-.d.cts +292 -0
  73. package/dist/schema-y5w2hbT-.d.ts +292 -0
  74. package/dist/types-CbWnSYEK.d.cts +5 -0
  75. package/dist/types-CbWnSYEK.d.ts +5 -0
  76. package/dist/types-CopwwpSW.d.cts +8 -0
  77. package/dist/types-CopwwpSW.d.ts +8 -0
  78. package/dist/types-hInbkPXf.d.cts +59 -0
  79. package/dist/types-hInbkPXf.d.ts +59 -0
  80. package/dist/ui/index.cjs +366 -0
  81. package/dist/ui/index.cjs.map +1 -0
  82. package/dist/ui/index.d.cts +190 -0
  83. package/dist/ui/index.d.ts +190 -0
  84. package/dist/ui/index.js +348 -0
  85. package/dist/ui/index.js.map +1 -0
  86. package/dist/utils/index.cjs +72 -0
  87. package/dist/utils/index.cjs.map +1 -0
  88. package/dist/utils/index.d.cts +27 -0
  89. package/dist/utils/index.d.ts +27 -0
  90. package/dist/utils/index.js +66 -0
  91. package/dist/utils/index.js.map +1 -0
  92. package/package.json +133 -0
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ // src/utils/sleep.ts
4
+ function sleep(ms) {
5
+ return new Promise((resolve) => setTimeout(resolve, ms));
6
+ }
7
+
8
+ // src/errors/app-error.ts
9
+ var AppError = class extends Error {
10
+ code;
11
+ context;
12
+ constructor(message, options) {
13
+ super(message, { cause: options.cause });
14
+ this.name = new.target.name;
15
+ this.code = options.code;
16
+ this.context = options.context;
17
+ Object.setPrototypeOf(this, new.target.prototype);
18
+ }
19
+ };
20
+
21
+ // src/utils/wait.ts
22
+ async function waitForCondition(predicate, options = {}) {
23
+ const { timeoutMs = 3e4, intervalMs = 500, message = "Condition was not met within timeout" } = options;
24
+ const deadline = Date.now() + timeoutMs;
25
+ for (; ; ) {
26
+ if (await predicate()) return;
27
+ if (Date.now() >= deadline) {
28
+ throw new AppError(message, { code: "WAIT_TIMEOUT", context: { timeoutMs, intervalMs } });
29
+ }
30
+ await sleep(intervalMs);
31
+ }
32
+ }
33
+
34
+ // src/utils/deep-merge.ts
35
+ function isPlainObject(value) {
36
+ return typeof value === "object" && value !== null && !Array.isArray(value);
37
+ }
38
+ function deepMerge(base, override) {
39
+ if (override === void 0) return base;
40
+ if (!isPlainObject(base) || !isPlainObject(override)) {
41
+ return override;
42
+ }
43
+ const result = { ...base };
44
+ for (const [key, value] of Object.entries(override)) {
45
+ if (value === void 0) continue;
46
+ const baseValue = base[key];
47
+ result[key] = isPlainObject(baseValue) && isPlainObject(value) ? deepMerge(baseValue, value) : value;
48
+ }
49
+ return result;
50
+ }
51
+ function pruneUndefined(value) {
52
+ if (Array.isArray(value)) return value.map(pruneUndefined);
53
+ if (isPlainObject(value)) {
54
+ const result = {};
55
+ for (const [key, val] of Object.entries(value)) {
56
+ if (val === void 0) continue;
57
+ const pruned = pruneUndefined(val);
58
+ if (isPlainObject(pruned) && Object.keys(pruned).length === 0) continue;
59
+ result[key] = pruned;
60
+ }
61
+ return result;
62
+ }
63
+ return value;
64
+ }
65
+
66
+ exports.deepMerge = deepMerge;
67
+ exports.isPlainObject = isPlainObject;
68
+ exports.pruneUndefined = pruneUndefined;
69
+ exports.sleep = sleep;
70
+ exports.waitForCondition = waitForCondition;
71
+ //# sourceMappingURL=index.cjs.map
72
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/sleep.ts","../../src/errors/app-error.ts","../../src/utils/wait.ts","../../src/utils/deep-merge.ts"],"names":[],"mappings":";;;AAAO,SAAS,MAAM,EAAA,EAA2B;AAC/C,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,YAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAC,CAAA;AACzD;;;ACSO,IAAM,QAAA,GAAN,cAAuB,KAAA,CAAM;AAAA,EACzB,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CAAY,SAAiB,OAAA,EAA0B;AACrD,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AACvC,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF,CAAA;;;ACNA,eAAsB,gBAAA,CACpB,SAAA,EACA,OAAA,GAAmC,EAAC,EACrB;AACf,EAAA,MAAM,EAAE,SAAA,GAAY,GAAA,EAAQ,aAAa,GAAA,EAAK,OAAA,GAAU,wCAAuC,GAAI,OA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Q,KAAK,GAAG,OAAO,KAAA,CAAM,IAAI,cAAc,CAAA;AACzD,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,MAAM,SAAkC,EAAC;AACzC,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,GAAG,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC9C,MAAA,IAAI,QAAQ,MAAA,EAAW;AACvB,MAAA,MAAM,MAAA,GAAS,eAAe,GAAG,CAAA;AACjC,MAAA,IAAI,aAAA,CAAc,MAAM,CAAA,IAAK,MAAA,CAAO,KAAK,MAAM,CAAA,CAAE,WAAW,CAAA,EAAG;AAC/D,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA;AAAA,IAChB;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT","file":"index.cjs","sourcesContent":["export function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","export interface AppErrorOptions {\n code: string;\n cause?: unknown;\n context?: Record<string, unknown>;\n}\n\n/**\n * Base error class for the framework. Every error thrown by core carries a\n * machine-readable `code` and optional `context`, so callers can branch on\n * `error.code` instead of parsing messages.\n */\nexport class AppError extends Error {\n readonly code: string;\n readonly context?: Record<string, unknown>;\n\n constructor(message: string, options: AppErrorOptions) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code;\n this.context = options.context;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ConfigValidationError extends AppError {\n constructor(message: string, issues: unknown, context?: Record<string, unknown>) {\n super(message, { code: \"CONFIG_VALIDATION_ERROR\", context: { issues, ...context } });\n }\n}\n\nexport class ApiError extends AppError {\n readonly status?: number;\n readonly method?: string;\n readonly url?: string;\n\n constructor(\n message: string,\n options: AppErrorOptions & { status?: number; method?: string; url?: string },\n ) {\n super(message, options);\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n }\n}\n\nexport class AuthError extends AppError {\n constructor(message: string, options: Omit<AppErrorOptions, \"code\"> = {}) {\n super(message, { code: \"AUTH_ERROR\", ...options });\n }\n}\n\nexport class ConfigMissingError extends AppError {\n constructor(name: string) {\n super(`Required environment variable \"${name}\" is not set`, {\n code: \"ENV_VAR_MISSING\",\n context: { name },\n });\n }\n}\n","import { AppError } from \"../errors/app-error.js\";\nimport { sleep } from \"./sleep.js\";\n\nexport interface WaitForConditionOptions {\n timeoutMs?: number;\n intervalMs?: number;\n /** Included in the thrown error when the timeout is reached. */\n message?: string;\n}\n\n/**\n * Polls `predicate` until it returns truthy, or throws `AppError` after `timeoutMs`.\n * For waiting on state that has no built-in Playwright wait — e.g. an async job's status\n * via `apiClient`, a queue draining, a background process finishing — as opposed to UI\n * state, which should use Playwright locator assertions/`waitFor` directly.\n */\nexport async function waitForCondition(\n predicate: () => Promise<boolean> | boolean,\n options: WaitForConditionOptions = {},\n): Promise<void> {\n const { timeoutMs = 30_000, intervalMs = 500, message = \"Condition was not met within timeout\" } = options;\n const deadline = Date.now() + timeoutMs;\n\n for (;;) {\n if (await predicate()) return;\n if (Date.now() >= deadline) {\n throw new AppError(message, { code: \"WAIT_TIMEOUT\", context: { timeoutMs, intervalMs } });\n }\n await sleep(intervalMs);\n }\n}\n","export function isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Recursively merges `override` onto `base`. Arrays and primitives replace wholesale;\n * only plain objects are merged key by key. `undefined` values in `override` are ignored,\n * so a partial object never accidentally erases a configured value.\n */\nexport function deepMerge<T>(base: T, override: unknown): T {\n if (override === undefined) return base;\n if (!isPlainObject(base) || !isPlainObject(override)) {\n return override as T;\n }\n const result: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const baseValue = (base as Record<string, unknown>)[key];\n result[key] = isPlainObject(baseValue) && isPlainObject(value) ? deepMerge(baseValue, value) : value;\n }\n return result as T;\n}\n\n/** Strips `undefined` values and empty nested objects, so zod defaults apply instead. */\nexport function pruneUndefined(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(pruneUndefined);\n if (isPlainObject(value)) {\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n if (val === undefined) continue;\n const pruned = pruneUndefined(val);\n if (isPlainObject(pruned) && Object.keys(pruned).length === 0) continue;\n result[key] = pruned;\n }\n return result;\n }\n return value;\n}\n"]}
@@ -0,0 +1,27 @@
1
+ declare function sleep(ms: number): Promise<void>;
2
+
3
+ interface WaitForConditionOptions {
4
+ timeoutMs?: number;
5
+ intervalMs?: number;
6
+ /** Included in the thrown error when the timeout is reached. */
7
+ message?: string;
8
+ }
9
+ /**
10
+ * Polls `predicate` until it returns truthy, or throws `AppError` after `timeoutMs`.
11
+ * For waiting on state that has no built-in Playwright wait — e.g. an async job's status
12
+ * via `apiClient`, a queue draining, a background process finishing — as opposed to UI
13
+ * state, which should use Playwright locator assertions/`waitFor` directly.
14
+ */
15
+ declare function waitForCondition(predicate: () => Promise<boolean> | boolean, options?: WaitForConditionOptions): Promise<void>;
16
+
17
+ declare function isPlainObject(value: unknown): value is Record<string, unknown>;
18
+ /**
19
+ * Recursively merges `override` onto `base`. Arrays and primitives replace wholesale;
20
+ * only plain objects are merged key by key. `undefined` values in `override` are ignored,
21
+ * so a partial object never accidentally erases a configured value.
22
+ */
23
+ declare function deepMerge<T>(base: T, override: unknown): T;
24
+ /** Strips `undefined` values and empty nested objects, so zod defaults apply instead. */
25
+ declare function pruneUndefined(value: unknown): unknown;
26
+
27
+ export { type WaitForConditionOptions, deepMerge, isPlainObject, pruneUndefined, sleep, waitForCondition };
@@ -0,0 +1,27 @@
1
+ declare function sleep(ms: number): Promise<void>;
2
+
3
+ interface WaitForConditionOptions {
4
+ timeoutMs?: number;
5
+ intervalMs?: number;
6
+ /** Included in the thrown error when the timeout is reached. */
7
+ message?: string;
8
+ }
9
+ /**
10
+ * Polls `predicate` until it returns truthy, or throws `AppError` after `timeoutMs`.
11
+ * For waiting on state that has no built-in Playwright wait — e.g. an async job's status
12
+ * via `apiClient`, a queue draining, a background process finishing — as opposed to UI
13
+ * state, which should use Playwright locator assertions/`waitFor` directly.
14
+ */
15
+ declare function waitForCondition(predicate: () => Promise<boolean> | boolean, options?: WaitForConditionOptions): Promise<void>;
16
+
17
+ declare function isPlainObject(value: unknown): value is Record<string, unknown>;
18
+ /**
19
+ * Recursively merges `override` onto `base`. Arrays and primitives replace wholesale;
20
+ * only plain objects are merged key by key. `undefined` values in `override` are ignored,
21
+ * so a partial object never accidentally erases a configured value.
22
+ */
23
+ declare function deepMerge<T>(base: T, override: unknown): T;
24
+ /** Strips `undefined` values and empty nested objects, so zod defaults apply instead. */
25
+ declare function pruneUndefined(value: unknown): unknown;
26
+
27
+ export { type WaitForConditionOptions, deepMerge, isPlainObject, pruneUndefined, sleep, waitForCondition };
@@ -0,0 +1,66 @@
1
+ // src/utils/sleep.ts
2
+ function sleep(ms) {
3
+ return new Promise((resolve) => setTimeout(resolve, ms));
4
+ }
5
+
6
+ // src/errors/app-error.ts
7
+ var AppError = class extends Error {
8
+ code;
9
+ context;
10
+ constructor(message, options) {
11
+ super(message, { cause: options.cause });
12
+ this.name = new.target.name;
13
+ this.code = options.code;
14
+ this.context = options.context;
15
+ Object.setPrototypeOf(this, new.target.prototype);
16
+ }
17
+ };
18
+
19
+ // src/utils/wait.ts
20
+ async function waitForCondition(predicate, options = {}) {
21
+ const { timeoutMs = 3e4, intervalMs = 500, message = "Condition was not met within timeout" } = options;
22
+ const deadline = Date.now() + timeoutMs;
23
+ for (; ; ) {
24
+ if (await predicate()) return;
25
+ if (Date.now() >= deadline) {
26
+ throw new AppError(message, { code: "WAIT_TIMEOUT", context: { timeoutMs, intervalMs } });
27
+ }
28
+ await sleep(intervalMs);
29
+ }
30
+ }
31
+
32
+ // src/utils/deep-merge.ts
33
+ function isPlainObject(value) {
34
+ return typeof value === "object" && value !== null && !Array.isArray(value);
35
+ }
36
+ function deepMerge(base, override) {
37
+ if (override === void 0) return base;
38
+ if (!isPlainObject(base) || !isPlainObject(override)) {
39
+ return override;
40
+ }
41
+ const result = { ...base };
42
+ for (const [key, value] of Object.entries(override)) {
43
+ if (value === void 0) continue;
44
+ const baseValue = base[key];
45
+ result[key] = isPlainObject(baseValue) && isPlainObject(value) ? deepMerge(baseValue, value) : value;
46
+ }
47
+ return result;
48
+ }
49
+ function pruneUndefined(value) {
50
+ if (Array.isArray(value)) return value.map(pruneUndefined);
51
+ if (isPlainObject(value)) {
52
+ const result = {};
53
+ for (const [key, val] of Object.entries(value)) {
54
+ if (val === void 0) continue;
55
+ const pruned = pruneUndefined(val);
56
+ if (isPlainObject(pruned) && Object.keys(pruned).length === 0) continue;
57
+ result[key] = pruned;
58
+ }
59
+ return result;
60
+ }
61
+ return value;
62
+ }
63
+
64
+ export { deepMerge, isPlainObject, pruneUndefined, sleep, waitForCondition };
65
+ //# sourceMappingURL=index.js.map
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/sleep.ts","../../src/errors/app-error.ts","../../src/utils/wait.ts","../../src/utils/deep-merge.ts"],"names":[],"mappings":";AAAO,SAAS,MAAM,EAAA,EAA2B;AAC/C,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,YAAY,UAAA,CAAW,OAAA,EAAS,EAAE,CAAC,CAAA;AACzD;;;ACSO,IAAM,QAAA,GAAN,cAAuB,KAAA,CAAM;AAAA,EACzB,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CAAY,SAAiB,OAAA,EAA0B;AACrD,IAAA,KAAA,CAAM,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AACvC,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,IAAA;AACpB,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,O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AiC,GAAG,CAAA;AACvD,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,aAAA,CAAc,SAAS,CAAA,IAAK,aAAA,CAAc,KAAK,CAAA,GAAI,SAAA,CAAU,SAAA,EAAW,KAAK,CAAA,GAAI,KAAA;AAAA,EACjG;AACA,EAAA,OAAO,MAAA;AACT;AAGO,SAAS,eAAe,KAAA,EAAyB;AACtD,EAAA,IAAI,MAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,KAAA,CAAM,IAAI,cAAc,CAAA;AACzD,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,MAAM,SAAkC,EAAC;AACzC,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,GAAG,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC9C,MAAA,IAAI,QAAQ,MAAA,EAAW;AACvB,MAAA,MAAM,MAAA,GAAS,eAAe,GAAG,CAAA;AACjC,MAAA,IAAI,aAAA,CAAc,MAAM,CAAA,IAAK,MAAA,CAAO,KAAK,MAAM,CAAA,CAAE,WAAW,CAAA,EAAG;AAC/D,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA;AAAA,IAChB;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT","file":"index.js","sourcesContent":["export function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","export interface AppErrorOptions {\n code: string;\n cause?: unknown;\n context?: Record<string, unknown>;\n}\n\n/**\n * Base error class for the framework. Every error thrown by core carries a\n * machine-readable `code` and optional `context`, so callers can branch on\n * `error.code` instead of parsing messages.\n */\nexport class AppError extends Error {\n readonly code: string;\n readonly context?: Record<string, unknown>;\n\n constructor(message: string, options: AppErrorOptions) {\n super(message, { cause: options.cause });\n this.name = new.target.name;\n this.code = options.code;\n this.context = options.context;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ConfigValidationError extends AppError {\n constructor(message: string, issues: unknown, context?: Record<string, unknown>) {\n super(message, { code: \"CONFIG_VALIDATION_ERROR\", context: { issues, ...context } });\n }\n}\n\nexport class ApiError extends AppError {\n readonly status?: number;\n readonly method?: string;\n readonly url?: string;\n\n constructor(\n message: string,\n options: AppErrorOptions & { status?: number; method?: string; url?: string },\n ) {\n super(message, options);\n this.status = options.status;\n this.method = options.method;\n this.url = options.url;\n }\n}\n\nexport class AuthError extends AppError {\n constructor(message: string, options: Omit<AppErrorOptions, \"code\"> = {}) {\n super(message, { code: \"AUTH_ERROR\", ...options });\n }\n}\n\nexport class ConfigMissingError extends AppError {\n constructor(name: string) {\n super(`Required environment variable \"${name}\" is not set`, {\n code: \"ENV_VAR_MISSING\",\n context: { name },\n });\n }\n}\n","import { AppError } from \"../errors/app-error.js\";\nimport { sleep } from \"./sleep.js\";\n\nexport interface WaitForConditionOptions {\n timeoutMs?: number;\n intervalMs?: number;\n /** Included in the thrown error when the timeout is reached. */\n message?: string;\n}\n\n/**\n * Polls `predicate` until it returns truthy, or throws `AppError` after `timeoutMs`.\n * For waiting on state that has no built-in Playwright wait — e.g. an async job's status\n * via `apiClient`, a queue draining, a background process finishing — as opposed to UI\n * state, which should use Playwright locator assertions/`waitFor` directly.\n */\nexport async function waitForCondition(\n predicate: () => Promise<boolean> | boolean,\n options: WaitForConditionOptions = {},\n): Promise<void> {\n const { timeoutMs = 30_000, intervalMs = 500, message = \"Condition was not met within timeout\" } = options;\n const deadline = Date.now() + timeoutMs;\n\n for (;;) {\n if (await predicate()) return;\n if (Date.now() >= deadline) {\n throw new AppError(message, { code: \"WAIT_TIMEOUT\", context: { timeoutMs, intervalMs } });\n }\n await sleep(intervalMs);\n }\n}\n","export function isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Recursively merges `override` onto `base`. Arrays and primitives replace wholesale;\n * only plain objects are merged key by key. `undefined` values in `override` are ignored,\n * so a partial object never accidentally erases a configured value.\n */\nexport function deepMerge<T>(base: T, override: unknown): T {\n if (override === undefined) return base;\n if (!isPlainObject(base) || !isPlainObject(override)) {\n return override as T;\n }\n const result: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const baseValue = (base as Record<string, unknown>)[key];\n result[key] = isPlainObject(baseValue) && isPlainObject(value) ? deepMerge(baseValue, value) : value;\n }\n return result as T;\n}\n\n/** Strips `undefined` values and empty nested objects, so zod defaults apply instead. */\nexport function pruneUndefined(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(pruneUndefined);\n if (isPlainObject(value)) {\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n if (val === undefined) continue;\n const pruned = pruneUndefined(val);\n if (isPlainObject(pruned) && Object.keys(pruned).length === 0) continue;\n result[key] = pruned;\n }\n return result;\n }\n return value;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,133 @@
1
+ {
2
+ "name": "@emesoft_company/playwright-core",
3
+ "version": "2.1.0",
4
+ "description": "Shared Playwright automation core: fixtures, API client abstraction, config loader, auth helpers, reporting integration.",
5
+ "license": "UNLICENSED",
6
+ "private": false,
7
+ "type": "module",
8
+ "keywords": [
9
+ "playwright",
10
+ "e2e",
11
+ "testing",
12
+ "automation",
13
+ "test-framework"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/emesoft/playwright-core.git"
18
+ },
19
+ "homepage": "https://github.com/emesoft/playwright-core#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/emesoft/playwright-core/issues"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js",
36
+ "require": "./dist/index.cjs"
37
+ },
38
+ "./config": {
39
+ "types": "./dist/config/index.d.ts",
40
+ "import": "./dist/config/index.js",
41
+ "require": "./dist/config/index.cjs"
42
+ },
43
+ "./fixtures": {
44
+ "types": "./dist/fixtures/index.d.ts",
45
+ "import": "./dist/fixtures/index.js",
46
+ "require": "./dist/fixtures/index.cjs"
47
+ },
48
+ "./api": {
49
+ "types": "./dist/api/index.d.ts",
50
+ "import": "./dist/api/index.js",
51
+ "require": "./dist/api/index.cjs"
52
+ },
53
+ "./auth": {
54
+ "types": "./dist/auth/index.d.ts",
55
+ "import": "./dist/auth/index.js",
56
+ "require": "./dist/auth/index.cjs"
57
+ },
58
+ "./ui": {
59
+ "types": "./dist/ui/index.d.ts",
60
+ "import": "./dist/ui/index.js",
61
+ "require": "./dist/ui/index.cjs"
62
+ },
63
+ "./logging": {
64
+ "types": "./dist/logging/index.d.ts",
65
+ "import": "./dist/logging/index.js",
66
+ "require": "./dist/logging/index.cjs"
67
+ },
68
+ "./errors": {
69
+ "types": "./dist/errors/index.d.ts",
70
+ "import": "./dist/errors/index.js",
71
+ "require": "./dist/errors/index.cjs"
72
+ },
73
+ "./reporting": {
74
+ "types": "./dist/reporting/index.d.ts",
75
+ "import": "./dist/reporting/index.js",
76
+ "require": "./dist/reporting/index.cjs"
77
+ },
78
+ "./di": {
79
+ "types": "./dist/di/index.d.ts",
80
+ "import": "./dist/di/index.js",
81
+ "require": "./dist/di/index.cjs"
82
+ },
83
+ "./utils": {
84
+ "types": "./dist/utils/index.d.ts",
85
+ "import": "./dist/utils/index.js",
86
+ "require": "./dist/utils/index.cjs"
87
+ },
88
+ "./data": {
89
+ "types": "./dist/data/index.d.ts",
90
+ "import": "./dist/data/index.js",
91
+ "require": "./dist/data/index.cjs"
92
+ },
93
+ "./expect": {
94
+ "types": "./dist/expect/index.d.ts",
95
+ "import": "./dist/expect/index.js",
96
+ "require": "./dist/expect/index.cjs"
97
+ },
98
+ "./package.json": "./package.json"
99
+ },
100
+ "scripts": {
101
+ "build": "tsup",
102
+ "prepare": "tsup",
103
+ "dev": "tsup --watch",
104
+ "typecheck": "tsc --noEmit",
105
+ "test": "vitest run",
106
+ "test:watch": "vitest",
107
+ "lint": "eslint ."
108
+ },
109
+ "peerDependencies": {
110
+ "@playwright/test": ">=1.40.0"
111
+ },
112
+ "dependencies": {
113
+ "dotenv": "^16.4.0",
114
+ "pino": "^9.0.0",
115
+ "zod": "^3.23.0"
116
+ },
117
+ "optionalDependencies": {
118
+ "allure-js-commons": "^3.0.0",
119
+ "allure-playwright": "^3.0.0"
120
+ },
121
+ "devDependencies": {
122
+ "@playwright/test": "^1.47.0",
123
+ "@types/node": "^20.14.0",
124
+ "eslint": "^9.9.0",
125
+ "tsup": "^8.2.0",
126
+ "typescript": "^5.5.0",
127
+ "typescript-eslint": "^8.0.0",
128
+ "vitest": "^2.0.0"
129
+ },
130
+ "publishConfig": {
131
+ "access": "public"
132
+ }
133
+ }