@rickcedwhat/playwright-smart-table 4.0.0 → 5.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.
- package/README.md +319 -102
- package/dist/smartRow.js +7 -7
- package/dist/strategies/columns.d.ts +0 -34
- package/dist/strategies/columns.js +1 -34
- package/dist/strategies/headers.d.ts +0 -16
- package/dist/strategies/headers.js +1 -113
- package/dist/strategies/index.d.ts +0 -28
- package/dist/strategies/index.js +0 -3
- package/dist/strategies/pagination.d.ts +0 -21
- package/dist/strategies/pagination.js +1 -23
- package/dist/strategies/validation.d.ts +22 -0
- package/dist/strategies/validation.js +54 -0
- package/dist/typeContext.d.ts +1 -1
- package/dist/typeContext.js +102 -26
- package/dist/types.d.ts +97 -26
- package/dist/useTable.d.ts +2 -9
- package/dist/useTable.js +149 -49
- package/dist/utils/stringUtils.d.ts +22 -0
- package/dist/utils/stringUtils.js +73 -0
- package/dist/utils/traceUtils.d.ts +11 -0
- package/dist/utils/traceUtils.js +47 -0
- package/package.json +2 -2
package/dist/smartRow.js
CHANGED
|
@@ -11,6 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createSmartRow = void 0;
|
|
13
13
|
const fill_1 = require("./strategies/fill");
|
|
14
|
+
const stringUtils_1 = require("./utils/stringUtils");
|
|
15
|
+
const traceUtils_1 = require("./utils/traceUtils");
|
|
14
16
|
/**
|
|
15
17
|
* Factory to create a SmartRow by extending a Playwright Locator.
|
|
16
18
|
* We avoid Class/Proxy to ensure full compatibility with Playwright's expect(locator) matchers.
|
|
@@ -19,13 +21,11 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
19
21
|
const smart = rowLocator;
|
|
20
22
|
// Attach State
|
|
21
23
|
smart.rowIndex = rowIndex;
|
|
22
|
-
smart.getRequestIndex = () => rowIndex;
|
|
23
24
|
// Attach Methods
|
|
24
25
|
smart.getCell = (colName) => {
|
|
25
26
|
const idx = map.get(colName);
|
|
26
27
|
if (idx === undefined) {
|
|
27
|
-
|
|
28
|
-
throw new Error(`Column "${colName}" not found. Available: ${availableColumns.join(', ')}`);
|
|
28
|
+
throw new Error((0, stringUtils_1.buildColumnNotFoundError)(colName, Array.from(map.keys())));
|
|
29
29
|
}
|
|
30
30
|
if (config.strategies.getCellLocator) {
|
|
31
31
|
return config.strategies.getCellLocator({
|
|
@@ -36,6 +36,8 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
36
36
|
page: rootLocator.page()
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
// Add trace event
|
|
40
|
+
(0, traceUtils_1.addTraceEvent)(rootLocator.page(), 'getCell', { column: colName, columnIndex: idx, rowIndex }).catch(() => { });
|
|
39
41
|
return resolve(config.cellSelector, rowLocator).nth(idx);
|
|
40
42
|
};
|
|
41
43
|
smart.toJSON = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -112,8 +114,7 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
112
114
|
}
|
|
113
115
|
return result;
|
|
114
116
|
});
|
|
115
|
-
|
|
116
|
-
smart.fill = (data, fillOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
smart.smartFill = (data, fillOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
118
|
for (const [colName, value] of Object.entries(data)) {
|
|
118
119
|
const colIdx = map.get(colName);
|
|
119
120
|
if (colIdx === undefined) {
|
|
@@ -144,12 +145,11 @@ const createSmartRow = (rowLocator, map, rowIndex, config, rootLocator, resolve,
|
|
|
144
145
|
});
|
|
145
146
|
smart.bringIntoView = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
147
|
if (rowIndex === undefined) {
|
|
147
|
-
throw new Error('Cannot bring row into view - row index is unknown. Use
|
|
148
|
+
throw new Error('Cannot bring row into view - row index is unknown. Use getRowByIndex() instead of getRow().');
|
|
148
149
|
}
|
|
149
150
|
// Scroll row into view using Playwright's built-in method
|
|
150
151
|
yield rowLocator.scrollIntoViewIfNeeded();
|
|
151
152
|
});
|
|
152
|
-
smart.smartFill = smart.fill;
|
|
153
153
|
return smart;
|
|
154
154
|
};
|
|
155
155
|
exports.createSmartRow = createSmartRow;
|
|
@@ -9,44 +9,10 @@ export type CellNavigationStrategy = (context: StrategyContext & {
|
|
|
9
9
|
index: number;
|
|
10
10
|
rowIndex?: number;
|
|
11
11
|
}) => Promise<void>;
|
|
12
|
-
/** @deprecated Use CellNavigationStrategy instead */
|
|
13
|
-
export type ColumnStrategy = CellNavigationStrategy;
|
|
14
12
|
export declare const CellNavigationStrategies: {
|
|
15
13
|
/**
|
|
16
14
|
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
17
15
|
* No specific action taken other than what Playwright's default locator handling does.
|
|
18
16
|
*/
|
|
19
17
|
default: () => Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Strategy that clicks into the table to establish focus and then uses the Right Arrow key
|
|
22
|
-
* to navigate to the target CELL (navigates down to the row, then right to the column).
|
|
23
|
-
*
|
|
24
|
-
* Useful for canvas-based grids like Glide where DOM scrolling might not be enough for interaction
|
|
25
|
-
* or where keyboard navigation is the primary way to move focus.
|
|
26
|
-
*/
|
|
27
|
-
keyboard: (context: StrategyContext & {
|
|
28
|
-
column: string;
|
|
29
|
-
index: number;
|
|
30
|
-
rowIndex?: number;
|
|
31
|
-
}) => Promise<void>;
|
|
32
|
-
};
|
|
33
|
-
/** @deprecated Use CellNavigationStrategies instead */
|
|
34
|
-
export declare const ColumnStrategies: {
|
|
35
|
-
/**
|
|
36
|
-
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
37
|
-
* No specific action taken other than what Playwright's default locator handling does.
|
|
38
|
-
*/
|
|
39
|
-
default: () => Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Strategy that clicks into the table to establish focus and then uses the Right Arrow key
|
|
42
|
-
* to navigate to the target CELL (navigates down to the row, then right to the column).
|
|
43
|
-
*
|
|
44
|
-
* Useful for canvas-based grids like Glide where DOM scrolling might not be enough for interaction
|
|
45
|
-
* or where keyboard navigation is the primary way to move focus.
|
|
46
|
-
*/
|
|
47
|
-
keyboard: (context: StrategyContext & {
|
|
48
|
-
column: string;
|
|
49
|
-
index: number;
|
|
50
|
-
rowIndex?: number;
|
|
51
|
-
}) => Promise<void>;
|
|
52
18
|
};
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.CellNavigationStrategies = void 0;
|
|
13
13
|
exports.CellNavigationStrategies = {
|
|
14
14
|
/**
|
|
15
15
|
* Default strategy: Assumes column is accessible or standard scrolling works.
|
|
@@ -17,38 +17,5 @@ exports.CellNavigationStrategies = {
|
|
|
17
17
|
*/
|
|
18
18
|
default: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
// No-op
|
|
20
|
-
}),
|
|
21
|
-
/**
|
|
22
|
-
* Strategy that clicks into the table to establish focus and then uses the Right Arrow key
|
|
23
|
-
* to navigate to the target CELL (navigates down to the row, then right to the column).
|
|
24
|
-
*
|
|
25
|
-
* Useful for canvas-based grids like Glide where DOM scrolling might not be enough for interaction
|
|
26
|
-
* or where keyboard navigation is the primary way to move focus.
|
|
27
|
-
*/
|
|
28
|
-
keyboard: (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
const { root, page, index, rowLocator, rowIndex } = context;
|
|
30
|
-
if (typeof rowIndex !== 'number') {
|
|
31
|
-
throw new Error('Row index is required for keyboard navigation');
|
|
32
|
-
}
|
|
33
|
-
yield root.focus();
|
|
34
|
-
yield page.waitForTimeout(100);
|
|
35
|
-
// Robust Navigation:
|
|
36
|
-
// 1. Jump to Top-Left (Reset) - Sequence for Cross-OS (Mac/Windows)
|
|
37
|
-
yield page.keyboard.press('Control+Home');
|
|
38
|
-
yield page.keyboard.press('Meta+ArrowUp'); // Mac Go-To-Top
|
|
39
|
-
yield page.keyboard.press('Home'); // Ensure start of row
|
|
40
|
-
yield page.waitForTimeout(150);
|
|
41
|
-
// 2. Move Down to Target Row
|
|
42
|
-
for (let i = 0; i < rowIndex; i++) {
|
|
43
|
-
yield page.keyboard.press('ArrowDown');
|
|
44
|
-
}
|
|
45
|
-
// 3. Move Right to Target Column
|
|
46
|
-
for (let i = 0; i < index; i++) {
|
|
47
|
-
yield page.keyboard.press('ArrowRight');
|
|
48
|
-
}
|
|
49
|
-
yield page.waitForTimeout(50);
|
|
50
20
|
})
|
|
51
21
|
};
|
|
52
|
-
// Backwards compatibility - deprecated
|
|
53
|
-
/** @deprecated Use CellNavigationStrategies instead */
|
|
54
|
-
exports.ColumnStrategies = exports.CellNavigationStrategies;
|
|
@@ -10,20 +10,4 @@ export declare const HeaderStrategies: {
|
|
|
10
10
|
* This is fast but won't find virtualized columns off-screen.
|
|
11
11
|
*/
|
|
12
12
|
visible: ({ config, resolve, root }: StrategyContext) => Promise<string[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Scans for headers by finding a scrollable container and setting scrollLeft.
|
|
15
|
-
*/
|
|
16
|
-
scrollRight: (context: StrategyContext, options?: {
|
|
17
|
-
limit?: number;
|
|
18
|
-
selector?: string;
|
|
19
|
-
scrollAmount?: number;
|
|
20
|
-
}) => Promise<string[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Strategy that clicks into the table to establish focus and then uses the Right Arrow key
|
|
23
|
-
* to navigate cell-by-cell, collecting headers found along the way.
|
|
24
|
-
*/
|
|
25
|
-
keyboard: (context: StrategyContext, options?: {
|
|
26
|
-
limit?: number;
|
|
27
|
-
maxSilentClicks?: number;
|
|
28
|
-
}) => Promise<string[]>;
|
|
29
13
|
};
|
|
@@ -26,117 +26,5 @@ exports.HeaderStrategies = {
|
|
|
26
26
|
}
|
|
27
27
|
const texts = yield headerLoc.allInnerTexts();
|
|
28
28
|
return texts.map(t => t.trim());
|
|
29
|
-
})
|
|
30
|
-
/**
|
|
31
|
-
* Scans for headers by finding a scrollable container and setting scrollLeft.
|
|
32
|
-
*/
|
|
33
|
-
scrollRight: (context, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
var _a, _b;
|
|
35
|
-
const { resolve, config, root, page } = context;
|
|
36
|
-
const limit = (_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 20;
|
|
37
|
-
const scrollAmount = (_b = options === null || options === void 0 ? void 0 : options.scrollAmount) !== null && _b !== void 0 ? _b : 300;
|
|
38
|
-
const collectedHeaders = new Set();
|
|
39
|
-
const getVisible = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
const headerLoc = resolve(config.headerSelector, root);
|
|
41
|
-
const texts = yield headerLoc.allInnerTexts();
|
|
42
|
-
return texts.map(t => t.trim());
|
|
43
|
-
});
|
|
44
|
-
// Initial capture
|
|
45
|
-
let currentHeaders = yield getVisible();
|
|
46
|
-
currentHeaders.forEach(h => collectedHeaders.add(h));
|
|
47
|
-
// Find scroller using JS for better iframe/shadow support
|
|
48
|
-
const scrollerHandle = yield root.evaluateHandle((el, selector) => {
|
|
49
|
-
if (selector && el.matches(selector))
|
|
50
|
-
return el;
|
|
51
|
-
const effectiveSelector = selector || '.dvn-scroller';
|
|
52
|
-
const ancestor = el.closest(effectiveSelector);
|
|
53
|
-
if (ancestor)
|
|
54
|
-
return ancestor;
|
|
55
|
-
return document.querySelector(effectiveSelector);
|
|
56
|
-
}, options === null || options === void 0 ? void 0 : options.selector);
|
|
57
|
-
const isScrollerFound = yield scrollerHandle.evaluate(el => !!el);
|
|
58
|
-
if (isScrollerFound) {
|
|
59
|
-
yield scrollerHandle.evaluate(el => el.scrollLeft = 0);
|
|
60
|
-
yield page.waitForTimeout(200);
|
|
61
|
-
for (let i = 0; i < limit; i++) {
|
|
62
|
-
const sizeBefore = collectedHeaders.size;
|
|
63
|
-
yield scrollerHandle.evaluate((el, amount) => el.scrollLeft += amount, scrollAmount);
|
|
64
|
-
yield page.waitForTimeout(300);
|
|
65
|
-
const newHeaders = yield getVisible();
|
|
66
|
-
newHeaders.forEach(h => collectedHeaders.add(h));
|
|
67
|
-
if (collectedHeaders.size === sizeBefore) {
|
|
68
|
-
yield scrollerHandle.evaluate((el, amount) => el.scrollLeft += amount, scrollAmount);
|
|
69
|
-
yield page.waitForTimeout(300);
|
|
70
|
-
const retryHeaders = yield getVisible();
|
|
71
|
-
retryHeaders.forEach(h => collectedHeaders.add(h));
|
|
72
|
-
if (collectedHeaders.size === sizeBefore)
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
console.warn("HeaderStrategies.scrollRight: Could not find scroller. Returning visible headers.");
|
|
79
|
-
}
|
|
80
|
-
// Scroll back to start
|
|
81
|
-
yield scrollerHandle.evaluate(el => el.scrollLeft = 0);
|
|
82
|
-
yield page.waitForTimeout(200);
|
|
83
|
-
return Array.from(collectedHeaders);
|
|
84
|
-
}),
|
|
85
|
-
/**
|
|
86
|
-
* Strategy that clicks into the table to establish focus and then uses the Right Arrow key
|
|
87
|
-
* to navigate cell-by-cell, collecting headers found along the way.
|
|
88
|
-
*/
|
|
89
|
-
keyboard: (context, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
const { resolve, config, root, page } = context;
|
|
92
|
-
const limit = (_a = options === null || options === void 0 ? void 0 : options.limit) !== null && _a !== void 0 ? _a : 100;
|
|
93
|
-
const maxSilentClicks = (_b = options === null || options === void 0 ? void 0 : options.maxSilentClicks) !== null && _b !== void 0 ? _b : 10;
|
|
94
|
-
const collectedHeaders = new Set();
|
|
95
|
-
const getVisible = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
const headerLoc = resolve(config.headerSelector, root);
|
|
97
|
-
const texts = yield headerLoc.allInnerTexts();
|
|
98
|
-
return texts.map(t => t.trim());
|
|
99
|
-
});
|
|
100
|
-
// 1. Initial capture
|
|
101
|
-
let currentHeaders = yield getVisible();
|
|
102
|
-
currentHeaders.forEach(h => collectedHeaders.add(h));
|
|
103
|
-
// 2. Click to focus
|
|
104
|
-
// Try to find the canvas sibling specifically for Glide, otherwise click root
|
|
105
|
-
const canvas = root.locator('xpath=ancestor::div').locator('canvas').first();
|
|
106
|
-
if ((yield canvas.count()) > 0) {
|
|
107
|
-
// Click lower in the canvas to hit a data cell instead of header
|
|
108
|
-
// Adjusted to y=60 to target Row 1
|
|
109
|
-
yield canvas.click({ position: { x: 50, y: 60 }, force: true }).catch(() => { });
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
yield root.click({ position: { x: 10, y: 10 }, force: true }).catch(() => { });
|
|
113
|
-
}
|
|
114
|
-
// Reset to home
|
|
115
|
-
yield page.keyboard.press('Control+Home');
|
|
116
|
-
yield page.keyboard.press('Home');
|
|
117
|
-
// Wait for potential scroll/focus reset
|
|
118
|
-
yield page.evaluate(() => new Promise(requestAnimationFrame));
|
|
119
|
-
currentHeaders = yield getVisible();
|
|
120
|
-
currentHeaders.forEach(h => collectedHeaders.add(h));
|
|
121
|
-
// 3. Navigate right loop
|
|
122
|
-
let silentCounter = 0;
|
|
123
|
-
for (let i = 0; i < limit; i++) {
|
|
124
|
-
const sizeBefore = collectedHeaders.size;
|
|
125
|
-
yield page.keyboard.press('ArrowRight');
|
|
126
|
-
// Small breathing room for key press to register
|
|
127
|
-
yield page.evaluate(() => new Promise(requestAnimationFrame));
|
|
128
|
-
const newHeaders = yield getVisible();
|
|
129
|
-
newHeaders.forEach(h => collectedHeaders.add(h));
|
|
130
|
-
if (collectedHeaders.size === sizeBefore) {
|
|
131
|
-
silentCounter++;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
silentCounter = 0;
|
|
135
|
-
}
|
|
136
|
-
if (silentCounter >= maxSilentClicks) {
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return Array.from(collectedHeaders);
|
|
141
|
-
}),
|
|
29
|
+
})
|
|
142
30
|
};
|
|
@@ -7,39 +7,16 @@ export * from './resolution';
|
|
|
7
7
|
export declare const Strategies: {
|
|
8
8
|
Pagination: {
|
|
9
9
|
clickNext: (nextButtonSelector: import("..").Selector, timeout?: number) => import("..").PaginationStrategy;
|
|
10
|
-
clickLoadMore: (buttonSelector: import("..").Selector, timeout?: number) => import("..").PaginationStrategy;
|
|
11
10
|
infiniteScroll: (timeout?: number) => import("..").PaginationStrategy;
|
|
12
11
|
};
|
|
13
12
|
Sorting: {
|
|
14
13
|
AriaSort: () => import("..").SortingStrategy;
|
|
15
14
|
};
|
|
16
|
-
Column: {
|
|
17
|
-
default: () => Promise<void>;
|
|
18
|
-
keyboard: (context: import("..").StrategyContext & {
|
|
19
|
-
column: string;
|
|
20
|
-
index: number;
|
|
21
|
-
rowIndex?: number;
|
|
22
|
-
}) => Promise<void>;
|
|
23
|
-
};
|
|
24
15
|
CellNavigation: {
|
|
25
16
|
default: () => Promise<void>;
|
|
26
|
-
keyboard: (context: import("..").StrategyContext & {
|
|
27
|
-
column: string;
|
|
28
|
-
index: number;
|
|
29
|
-
rowIndex?: number;
|
|
30
|
-
}) => Promise<void>;
|
|
31
17
|
};
|
|
32
18
|
Header: {
|
|
33
19
|
visible: ({ config, resolve, root }: import("..").StrategyContext) => Promise<string[]>;
|
|
34
|
-
scrollRight: (context: import("..").StrategyContext, options?: {
|
|
35
|
-
limit?: number;
|
|
36
|
-
selector?: string;
|
|
37
|
-
scrollAmount?: number;
|
|
38
|
-
}) => Promise<string[]>;
|
|
39
|
-
keyboard: (context: import("..").StrategyContext, options?: {
|
|
40
|
-
limit?: number;
|
|
41
|
-
maxSilentClicks?: number;
|
|
42
|
-
}) => Promise<string[]>;
|
|
43
20
|
};
|
|
44
21
|
Fill: {
|
|
45
22
|
default: ({ row, columnName, value, fillOptions }: Parameters<import("..").FillStrategy>[0]) => Promise<void>;
|
|
@@ -47,9 +24,4 @@ export declare const Strategies: {
|
|
|
47
24
|
Resolution: {
|
|
48
25
|
default: import("./resolution").ColumnResolutionStrategy;
|
|
49
26
|
};
|
|
50
|
-
DeprecatedPagination: {
|
|
51
|
-
clickNext: (nextButtonSelector: import("..").Selector, timeout?: number) => import("..").PaginationStrategy;
|
|
52
|
-
clickLoadMore: (buttonSelector: import("..").Selector, timeout?: number) => import("..").PaginationStrategy;
|
|
53
|
-
infiniteScroll: (timeout?: number) => import("..").PaginationStrategy;
|
|
54
|
-
};
|
|
55
27
|
};
|
package/dist/strategies/index.js
CHANGED
|
@@ -30,11 +30,8 @@ __exportStar(require("./resolution"), exports);
|
|
|
30
30
|
exports.Strategies = {
|
|
31
31
|
Pagination: pagination_1.PaginationStrategies,
|
|
32
32
|
Sorting: sorting_1.SortingStrategies,
|
|
33
|
-
Column: columns_1.ColumnStrategies,
|
|
34
33
|
CellNavigation: columns_1.CellNavigationStrategies,
|
|
35
34
|
Header: headers_1.HeaderStrategies,
|
|
36
35
|
Fill: fill_1.FillStrategies,
|
|
37
36
|
Resolution: resolution_1.ResolutionStrategies,
|
|
38
|
-
// Alias for backward compatibility if needed, though we are encouraging the new structure
|
|
39
|
-
DeprecatedPagination: pagination_1.DeprecatedPaginationStrategies
|
|
40
37
|
};
|
|
@@ -4,27 +4,6 @@ export declare const PaginationStrategies: {
|
|
|
4
4
|
* Strategy: Clicks a "Next" button and waits for the first row of data to change.
|
|
5
5
|
*/
|
|
6
6
|
clickNext: (nextButtonSelector: Selector, timeout?: number) => PaginationStrategy;
|
|
7
|
-
/**
|
|
8
|
-
* Strategy: Clicks a "Load More" button and waits for the row count to increase.
|
|
9
|
-
*/
|
|
10
|
-
clickLoadMore: (buttonSelector: Selector, timeout?: number) => PaginationStrategy;
|
|
11
|
-
/**
|
|
12
|
-
* Strategy: Scrolls to the bottom and waits for more rows to appear.
|
|
13
|
-
*/
|
|
14
|
-
infiniteScroll: (timeout?: number) => PaginationStrategy;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `PaginationStrategies` instead. This alias will be removed in a future major version.
|
|
18
|
-
*/
|
|
19
|
-
export declare const DeprecatedPaginationStrategies: {
|
|
20
|
-
/**
|
|
21
|
-
* Strategy: Clicks a "Next" button and waits for the first row of data to change.
|
|
22
|
-
*/
|
|
23
|
-
clickNext: (nextButtonSelector: Selector, timeout?: number) => PaginationStrategy;
|
|
24
|
-
/**
|
|
25
|
-
* Strategy: Clicks a "Load More" button and waits for the row count to increase.
|
|
26
|
-
*/
|
|
27
|
-
clickLoadMore: (buttonSelector: Selector, timeout?: number) => PaginationStrategy;
|
|
28
7
|
/**
|
|
29
8
|
* Strategy: Scrolls to the bottom and waits for more rows to appear.
|
|
30
9
|
*/
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.PaginationStrategies = void 0;
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
exports.PaginationStrategies = {
|
|
15
15
|
/**
|
|
@@ -31,24 +31,6 @@ exports.PaginationStrategies = {
|
|
|
31
31
|
return success;
|
|
32
32
|
});
|
|
33
33
|
},
|
|
34
|
-
/**
|
|
35
|
-
* Strategy: Clicks a "Load More" button and waits for the row count to increase.
|
|
36
|
-
*/
|
|
37
|
-
clickLoadMore: (buttonSelector, timeout = 5000) => {
|
|
38
|
-
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ root, config, resolve, page }) {
|
|
39
|
-
const loadMoreBtn = resolve(buttonSelector, root).first();
|
|
40
|
-
if (!(yield loadMoreBtn.isVisible()) || !(yield loadMoreBtn.isEnabled())) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
const rows = resolve(config.rowSelector, root);
|
|
44
|
-
const oldCount = yield rows.count();
|
|
45
|
-
yield loadMoreBtn.click();
|
|
46
|
-
return yield (0, utils_1.waitForCondition)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const newCount = yield rows.count();
|
|
48
|
-
return newCount > oldCount;
|
|
49
|
-
}), timeout, page);
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
34
|
/**
|
|
53
35
|
* Strategy: Scrolls to the bottom and waits for more rows to appear.
|
|
54
36
|
*/
|
|
@@ -66,7 +48,3 @@ exports.PaginationStrategies = {
|
|
|
66
48
|
});
|
|
67
49
|
}
|
|
68
50
|
};
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated Use `PaginationStrategies` instead. This alias will be removed in a future major version.
|
|
71
|
-
*/
|
|
72
|
-
exports.DeprecatedPaginationStrategies = exports.PaginationStrategies;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PaginationStrategy, SortingStrategy, FillStrategy } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that a pagination strategy returns a boolean.
|
|
4
|
+
* @param result - The result from a pagination strategy
|
|
5
|
+
* @param strategyName - Name of the strategy for error messages
|
|
6
|
+
*/
|
|
7
|
+
export declare function validatePaginationResult(result: any, strategyName?: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Validates that a pagination strategy is properly configured.
|
|
10
|
+
* @param strategy - The pagination strategy to validate
|
|
11
|
+
*/
|
|
12
|
+
export declare function validatePaginationStrategy(strategy: any): strategy is PaginationStrategy;
|
|
13
|
+
/**
|
|
14
|
+
* Validates that a sorting strategy has the required methods.
|
|
15
|
+
* @param strategy - The sorting strategy to validate
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateSortingStrategy(strategy: any): strategy is SortingStrategy;
|
|
18
|
+
/**
|
|
19
|
+
* Validates that a fill strategy is properly configured.
|
|
20
|
+
* @param strategy - The fill strategy to validate
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateFillStrategy(strategy: any): strategy is FillStrategy;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePaginationResult = validatePaginationResult;
|
|
4
|
+
exports.validatePaginationStrategy = validatePaginationStrategy;
|
|
5
|
+
exports.validateSortingStrategy = validateSortingStrategy;
|
|
6
|
+
exports.validateFillStrategy = validateFillStrategy;
|
|
7
|
+
/**
|
|
8
|
+
* Validates that a pagination strategy returns a boolean.
|
|
9
|
+
* @param result - The result from a pagination strategy
|
|
10
|
+
* @param strategyName - Name of the strategy for error messages
|
|
11
|
+
*/
|
|
12
|
+
function validatePaginationResult(result, strategyName = 'Custom Pagination Strategy') {
|
|
13
|
+
if (typeof result !== 'boolean') {
|
|
14
|
+
throw new Error(`[${strategyName}] Pagination strategy must return a boolean (true if paginated, false if no more pages). ` +
|
|
15
|
+
`Received: ${typeof result} (${JSON.stringify(result)})`);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates that a pagination strategy is properly configured.
|
|
21
|
+
* @param strategy - The pagination strategy to validate
|
|
22
|
+
*/
|
|
23
|
+
function validatePaginationStrategy(strategy) {
|
|
24
|
+
if (typeof strategy !== 'function') {
|
|
25
|
+
throw new Error(`Pagination strategy must be a function. Received: ${typeof strategy}`);
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Validates that a sorting strategy has the required methods.
|
|
31
|
+
* @param strategy - The sorting strategy to validate
|
|
32
|
+
*/
|
|
33
|
+
function validateSortingStrategy(strategy) {
|
|
34
|
+
if (!strategy || typeof strategy !== 'object') {
|
|
35
|
+
throw new Error(`Sorting strategy must be an object with 'doSort' and 'getSortState' methods. Received: ${typeof strategy}`);
|
|
36
|
+
}
|
|
37
|
+
if (typeof strategy.doSort !== 'function') {
|
|
38
|
+
throw new Error(`Sorting strategy must have a 'doSort' method. Missing or not a function.`);
|
|
39
|
+
}
|
|
40
|
+
if (typeof strategy.getSortState !== 'function') {
|
|
41
|
+
throw new Error(`Sorting strategy must have a 'getSortState' method. Missing or not a function.`);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validates that a fill strategy is properly configured.
|
|
47
|
+
* @param strategy - The fill strategy to validate
|
|
48
|
+
*/
|
|
49
|
+
function validateFillStrategy(strategy) {
|
|
50
|
+
if (typeof strategy !== 'function') {
|
|
51
|
+
throw new Error(`Fill strategy must be a function. Received: ${typeof strategy}`);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
package/dist/typeContext.d.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* This file is generated by scripts/embed-types.js
|
|
4
4
|
* It contains the raw text of types.ts to provide context for LLM prompts.
|
|
5
5
|
*/
|
|
6
|
-
export declare const TYPE_CONTEXT = "\nexport type Selector = string | ((root: Locator | Page) => Locator);\n\n/**\n * Function to get a cell locator given row, column info.\n * Replaces the old cellResolver.\n */\nexport type GetCellLocatorFn = (args: {\n row: Locator;\n columnName: string;\n columnIndex: number;\n rowIndex?: number;\n page: Page;\n}) => Locator;\n\n/**\n * Function to get the currently active/focused cell.\n * Returns null if no cell is active.\n */\nexport type GetActiveCellFn = (args: TableContext) => Promise<{\n rowIndex: number;\n columnIndex: number;\n columnName?: string;\n locator: Locator;\n} | null>;\n\n\nexport type SmartRow<T = any> = Locator & {\n getRequestIndex(): number | undefined;\n rowIndex?: number;\n getCell(column: string): Locator;\n toJSON(options?: { columns?: string[] }): Promise<T>;\n /**\n * Scrolls/paginates to bring this row into view.\n * Only works if rowIndex is known.\n */\n bringIntoView(): Promise<void>;\n /**\n * Fills the row with data. Automatically detects input types.\n */\n fill: (data: Partial<T> | Record<string, any>, options?: FillOptions) => Promise<void>;\n /**\n * Alias for fill() to avoid conflict with Locator.fill()\n */\n smartFill: (data: Partial<T> | Record<string, any>, options?: FillOptions) => Promise<void>;\n};\n\nexport type StrategyContext = TableContext & { rowLocator?: Locator; rowIndex?: number };\n\n/**\n * Defines the contract for a sorting strategy.\n */\nexport interface SortingStrategy {\n /**\n * Performs the sort action on a column.\n */\n doSort(options: {\n columnName: string;\n direction: 'asc' | 'desc';\n context: StrategyContext;\n }): Promise<void>;\n\n /**\n * Retrieves the current sort state of a column.\n */\n getSortState(options: {\n columnName: string;\n context: StrategyContext;\n }): Promise<'asc' | 'desc' | 'none'>;\n}\n\nexport interface TableContext {\n root: Locator;\n config: FinalTableConfig;\n page: Page;\n resolve: (selector: Selector, parent: Locator | Page) => Locator;\n}\n\nexport type PaginationStrategy = (context: TableContext) => Promise<boolean>;\n\nexport type DedupeStrategy = (row: SmartRow) => string | number | Promise<string | number>;\n\nexport interface PromptOptions {\n /**\n * Output Strategy:\n * - 'error': Throws an error with the prompt (useful for platforms that capture error output cleanly).\n * - 'console': Standard console logs (Default).\n */\n output?: 'console' | 'error';\n includeTypes?: boolean;\n}\n\nexport type FillStrategy = (options: {\n row: SmartRow;\n columnName: string;\n value: any;\n index: number;\n page: Page;\n rootLocator: Locator;\n table: TableResult; // The parent table instance\n fillOptions?: FillOptions;\n}) => Promise<void>;\n\nexport type { HeaderStrategy } from './strategies/headers';\nexport type { CellNavigationStrategy } from './strategies/columns';\n\n/**\n * Strategy to resolve column names (string or regex) to their index.\n */\nexport type { ColumnResolutionStrategy } from './strategies/resolution';\n\n/**\n * Strategy to filter rows based on criteria.\n */\nexport interface FilterStrategy {\n apply(options: {\n rows: Locator;\n filter: { column: string, value: string | RegExp | number };\n colIndex: number;\n tableContext: TableContext;\n }): Locator;\n}\n\n/**\n * Organized container for all table interaction strategies.\n */\nexport interface TableStrategies {\n /** Strategy for discovering/scanning headers */\n header?: HeaderStrategy;\n /** Strategy for navigating to specific cells (row + column) */\n cellNavigation?: CellNavigationStrategy;\n /** Strategy for filling form inputs */\n fill?: FillStrategy;\n /** Strategy for paginating through data */\n pagination?: PaginationStrategy;\n /** Strategy for sorting columns */\n sorting?: SortingStrategy;\n /** Function to get a cell locator */\n getCellLocator?: GetCellLocatorFn;\n /** Function to get the currently active/focused cell */\n getActiveCell?: GetActiveCellFn;\n}\n\n/**\n * Configuration options for useTable.\n */\nexport interface TableConfig {\n /** Selector for the table headers */\n headerSelector?: string;\n /** Selector for the table rows */\n rowSelector?: string;\n /** Selector for the cells within a row */\n cellSelector?: string;\n /** Number of pages to scan for verification */\n maxPages?: number;\n /** Hook to rename columns dynamically */\n headerTransformer?: (args: { text: string, index: number, locator: Locator }) => string | Promise<string>;\n /** Automatically scroll to table on init */\n autoScroll?: boolean;\n /** Enable debug logs */\n debug?: boolean;\n /** Reset hook */\n onReset?: (context: TableContext) => Promise<void>;\n /** All interaction strategies */\n strategies?: TableStrategies;\n}\n\nexport interface FinalTableConfig extends TableConfig {\n headerSelector: string;\n rowSelector: string;\n cellSelector: string;\n maxPages: number;\n autoScroll: boolean;\n debug: boolean;\n headerTransformer: (args: { text: string, index: number, locator: Locator }) => string | Promise<string>;\n onReset: (context: TableContext) => Promise<void>;\n strategies: TableStrategies;\n}\n\n\nexport interface FillOptions {\n /**\n * Custom input mappers for specific columns.\n * Maps column names to functions that return the input locator for that cell.\n */\n inputMappers?: Record<string, (cell: Locator) => Locator>;\n}\n\nexport interface TableResult<T = any> {\n /**\n * Initializes the table by resolving headers. Must be called before using sync methods.\n * @param options Optional timeout for header resolution (default: 3000ms)\n */\n init(options?: { timeout?: number }): Promise<TableResult>;\n\n getHeaders: () => Promise<string[]>;\n getHeaderCell: (columnName: string) => Promise<Locator>;\n\n /**\n * Finds a row by filters on the current page only. Returns immediately (sync).\n * Throws error if table is not initialized.\n */\n getByRow: (\n filters: Record<string, string | RegExp | number>,\n options?: { exact?: boolean }\n ) => SmartRow;\n\n /**\n * Gets a row by 1-based index on the current page.\n * Throws error if table is not initialized.\n * @param index 1-based row index\n * @param options Optional settings including bringIntoView\n */\n getByRowIndex: (\n index: number,\n options?: { bringIntoView?: boolean }\n ) => SmartRow;\n\n /**\n * Searches for a row across all available data using the configured strategy (pagination, scroll, etc.).\n * Auto-initializes if needed.\n */\n searchForRow: (\n filters: Record<string, string | RegExp | number>,\n options?: { exact?: boolean, maxPages?: number }\n ) => Promise<SmartRow>;\n\n /**\n * Navigates to a specific column using the configured CellNavigationStrategy.\n */\n scrollToColumn: (columnName: string) => Promise<void>;\n\n getAllCurrentRows: <T extends { asJSON?: boolean }>(\n options?: { filter?: Record<string, any>, exact?: boolean } & T\n ) => Promise<T['asJSON'] extends true ? Record<string, string>[] : SmartRow[]>;\n\n /**\n * @deprecated Use getAllCurrentRows instead. This method will be removed in a future major version.\n */\n getAllRows: <T extends { asJSON?: boolean }>(\n options?: { filter?: Record<string, any>, exact?: boolean } & T\n ) => Promise<T['asJSON'] extends true ? Record<string, string>[] : SmartRow[]>;\n\n generateConfigPrompt: (options?: PromptOptions) => Promise<void>;\n generateStrategyPrompt: (options?: PromptOptions) => Promise<void>;\n\n /**\n * Resets the table state (clears cache, flags) and invokes the onReset strategy.\n */\n reset: () => Promise<void>;\n\n /**\n * Revalidates the table's structure (headers, columns) without resetting pagination or state.\n * Useful when columns change visibility or order dynamically.\n */\n revalidate: () => Promise<void>;\n\n /**\n * Scans a specific column across all pages and returns the values.\n */\n getColumnValues: <V = string>(column: string, options?: { mapper?: (cell: Locator) => Promise<V> | V, maxPages?: number }) => Promise<V[]>;\n\n /**\n * Provides access to sorting actions and assertions.\n */\n sorting: {\n /**\n * Applies the configured sorting strategy to the specified column.\n * @param columnName The name of the column to sort.\n * @param direction The direction to sort ('asc' or 'desc').\n */\n apply(columnName: string, direction: 'asc' | 'desc'): Promise<void>;\n /**\n * Gets the current sort state of a column using the configured sorting strategy.\n * @param columnName The name of the column to check.\n * @returns A promise that resolves to 'asc', 'desc', or 'none'.\n */\n getState(columnName: string): Promise<'asc' | 'desc' | 'none'>;\n };\n\n /**\n * Iterates through paginated table data, calling the callback for each iteration.\n * Callback return values are automatically appended to allData, which is returned.\n */\n iterateThroughTable: <T = any>(\n callback: (context: {\n index: number;\n isFirst: boolean;\n isLast: boolean;\n rows: SmartRow[];\n allData: T[];\n table: RestrictedTableResult;\n }) => T | Promise<T>,\n options?: {\n pagination?: PaginationStrategy;\n dedupeStrategy?: DedupeStrategy;\n maxIterations?: number;\n getIsFirst?: (context: { index: number }) => boolean;\n getIsLast?: (context: { index: number, paginationResult: boolean }) => boolean;\n onFirst?: (context: { index: number, rows: SmartRow[], allData: any[] }) => void | Promise<void>;\n onLast?: (context: { index: number, rows: SmartRow[], allData: any[] }) => void | Promise<void>;\n }\n ) => Promise<T[]>;\n}\n\n/**\n * Restricted table result that excludes methods that shouldn't be called during iteration.\n */\nexport type RestrictedTableResult<T = any> = Omit<TableResult<T>, 'searchForRow' | 'iterateThroughTable' | 'reset' | 'getAllRows'>;\n";
|
|
6
|
+
export declare const TYPE_CONTEXT = "\n/**\n * Flexible selector type - can be a CSS string, function returning a Locator, or Locator itself.\n * @example\n * // String selector\n * rowSelector: 'tbody tr'\n * \n * // Function selector\n * rowSelector: (root) => root.locator('[role=\"row\"]')\n */\nexport type Selector = string | ((root: Locator | Page) => Locator);\n\n/**\n * Function to get a cell locator given row, column info.\n * Replaces the old cellResolver.\n */\nexport type GetCellLocatorFn = (args: {\n row: Locator;\n columnName: string;\n columnIndex: number;\n rowIndex?: number;\n page: Page;\n}) => Locator;\n\n/**\n * Function to get the currently active/focused cell.\n * Returns null if no cell is active.\n */\nexport type GetActiveCellFn = (args: TableContext) => Promise<{\n rowIndex: number;\n columnIndex: number;\n columnName?: string;\n locator: Locator;\n} | null>;\n\n\n/**\n * SmartRow - A Playwright Locator with table-aware methods.\n * \n * Extends all standard Locator methods (click, isVisible, etc.) with table-specific functionality.\n * \n * @example\n * const row = table.getRow({ Name: 'John Doe' });\n * await row.click(); // Standard Locator method\n * const email = row.getCell('Email'); // Table-aware method\n * const data = await row.toJSON(); // Extract all row data\n * await row.smartFill({ Name: 'Jane', Status: 'Active' }); // Fill form fields\n */\nexport type SmartRow<T = any> = Locator & {\n /** Optional row index (0-based) if known */\n rowIndex?: number;\n\n /**\n * Get a cell locator by column name.\n * @param column - Column name (case-sensitive)\n * @returns Locator for the cell\n * @example\n * const emailCell = row.getCell('Email');\n * await expect(emailCell).toHaveText('john@example.com');\n */\n getCell(column: string): Locator;\n\n /**\n * Extract all cell data as a key-value object.\n * @param options - Optional configuration\n * @param options.columns - Specific columns to extract (extracts all if not specified)\n * @returns Promise resolving to row data\n * @example\n * const data = await row.toJSON();\n * // { Name: 'John', Email: 'john@example.com', ... }\n * \n * const partial = await row.toJSON({ columns: ['Name', 'Email'] });\n * // { Name: 'John', Email: 'john@example.com' }\n */\n toJSON(options?: { columns?: string[] }): Promise<T>;\n\n /**\n * Scrolls/paginates to bring this row into view.\n * Only works if rowIndex is known (e.g., from getRowByIndex).\n * @throws Error if rowIndex is unknown\n */\n bringIntoView(): Promise<void>;\n\n /**\n * Intelligently fills form fields in the row.\n * Automatically detects input types (text, select, checkbox, contenteditable).\n * \n * @param data - Column-value pairs to fill\n * @param options - Optional configuration\n * @param options.inputMappers - Custom input selectors per column\n * @example\n * // Auto-detection\n * await row.smartFill({ Name: 'John', Status: 'Active', Subscribe: true });\n * \n * // Custom input mappers\n * await row.smartFill(\n * { Name: 'John' },\n * { inputMappers: { Name: (cell) => cell.locator('.custom-input') } }\n * );\n */\n smartFill: (data: Partial<T> | Record<string, any>, options?: FillOptions) => Promise<void>;\n};\n\nexport type StrategyContext = TableContext & { rowLocator?: Locator; rowIndex?: number };\n\n/**\n * Defines the contract for a sorting strategy.\n */\nexport interface SortingStrategy {\n /**\n * Performs the sort action on a column.\n */\n doSort(options: {\n columnName: string;\n direction: 'asc' | 'desc';\n context: StrategyContext;\n }): Promise<void>;\n\n /**\n * Retrieves the current sort state of a column.\n */\n getSortState(options: {\n columnName: string;\n context: StrategyContext;\n }): Promise<'asc' | 'desc' | 'none'>;\n}\n\nexport interface TableContext {\n root: Locator;\n config: FinalTableConfig;\n page: Page;\n resolve: (selector: Selector, parent: Locator | Page) => Locator;\n}\n\nexport type PaginationStrategy = (context: TableContext) => Promise<boolean>;\n\nexport type DedupeStrategy = (row: SmartRow) => string | number | Promise<string | number>;\n\nexport interface PromptOptions {\n /**\n * Output Strategy:\n * - 'error': Throws an error with the prompt (useful for platforms that capture error output cleanly).\n * - 'console': Standard console logs (Default).\n */\n output?: 'console' | 'error';\n includeTypes?: boolean;\n}\n\nexport type FillStrategy = (options: {\n row: SmartRow;\n columnName: string;\n value: any;\n index: number;\n page: Page;\n rootLocator: Locator;\n table: TableResult; // The parent table instance\n fillOptions?: FillOptions;\n}) => Promise<void>;\n\nexport type { HeaderStrategy } from './strategies/headers';\nexport type { CellNavigationStrategy } from './strategies/columns';\n\n/**\n * Strategy to resolve column names (string or regex) to their index.\n */\nexport type { ColumnResolutionStrategy } from './strategies/resolution';\n\n/**\n * Strategy to filter rows based on criteria.\n */\nexport interface FilterStrategy {\n apply(options: {\n rows: Locator;\n filter: { column: string, value: string | RegExp | number };\n colIndex: number;\n tableContext: TableContext;\n }): Locator;\n}\n\n/**\n * Organized container for all table interaction strategies.\n */\nexport interface TableStrategies {\n /** Strategy for discovering/scanning headers */\n header?: HeaderStrategy;\n /** Strategy for navigating to specific cells (row + column) */\n cellNavigation?: CellNavigationStrategy;\n /** Strategy for filling form inputs */\n fill?: FillStrategy;\n /** Strategy for paginating through data */\n pagination?: PaginationStrategy;\n /** Strategy for sorting columns */\n sorting?: SortingStrategy;\n /** Function to get a cell locator */\n getCellLocator?: GetCellLocatorFn;\n /** Function to get the currently active/focused cell */\n getActiveCell?: GetActiveCellFn;\n}\n\n/**\n * Configuration options for useTable.\n */\nexport interface TableConfig {\n /** Selector for the table headers */\n headerSelector?: string;\n /** Selector for the table rows */\n rowSelector?: string;\n /** Selector for the cells within a row */\n cellSelector?: string;\n /** Number of pages to scan for verification */\n maxPages?: number;\n /** Hook to rename columns dynamically */\n headerTransformer?: (args: { text: string, index: number, locator: Locator }) => string | Promise<string>;\n /** Automatically scroll to table on init */\n autoScroll?: boolean;\n /** Enable debug logs */\n debug?: boolean;\n /** Reset hook */\n onReset?: (context: TableContext) => Promise<void>;\n /** All interaction strategies */\n strategies?: TableStrategies;\n}\n\nexport interface FinalTableConfig extends TableConfig {\n headerSelector: string;\n rowSelector: string;\n cellSelector: string;\n maxPages: number;\n autoScroll: boolean;\n debug: boolean;\n headerTransformer: (args: { text: string, index: number, locator: Locator }) => string | Promise<string>;\n onReset: (context: TableContext) => Promise<void>;\n strategies: TableStrategies;\n}\n\n\nexport interface FillOptions {\n /**\n * Custom input mappers for specific columns.\n * Maps column names to functions that return the input locator for that cell.\n */\n inputMappers?: Record<string, (cell: Locator) => Locator>;\n}\n\nexport interface TableResult<T = any> {\n /**\n * Initializes the table by resolving headers. Must be called before using sync methods.\n * @param options Optional timeout for header resolution (default: 3000ms)\n */\n init(options?: { timeout?: number }): Promise<TableResult>;\n\n /**\n * SYNC: Checks if the table has been initialized.\n * @returns true if init() has been called and completed, false otherwise\n */\n isInitialized(): boolean;\n\n getHeaders: () => Promise<string[]>;\n getHeaderCell: (columnName: string) => Promise<Locator>;\n\n /**\n * Finds a row by filters on the current page only. Returns immediately (sync).\n * Throws error if table is not initialized.\n */\n getRow: (\n filters: Record<string, string | RegExp | number>,\n options?: { exact?: boolean }\n ) => SmartRow;\n\n /**\n * Gets a row by 1-based index on the current page.\n * Throws error if table is not initialized.\n * @param index 1-based row index\n * @param options Optional settings including bringIntoView\n */\n getRowByIndex: (\n index: number,\n options?: { bringIntoView?: boolean }\n ) => SmartRow;\n\n /**\n * ASYNC: Searches for a single row across pages using pagination.\n * Auto-initializes the table if not already initialized.\n * @param filters - The filter criteria to match\n * @param options - Search options including exact match and max pages\n */\n findRow: (\n filters: Record<string, string | RegExp | number>,\n options?: { exact?: boolean, maxPages?: number }\n ) => Promise<SmartRow>;\n\n /**\n * ASYNC: Searches for all matching rows across pages using pagination.\n * Auto-initializes the table if not already initialized.\n * @param filters - The filter criteria to match\n * @param options - Search options including exact match, max pages, and asJSON\n */\n findRows: <R extends { asJSON?: boolean }>(\n filters: Record<string, string | RegExp | number>,\n options?: { exact?: boolean, maxPages?: number } & R\n ) => Promise<R['asJSON'] extends true ? Record<string, string>[] : SmartRow[]>;\n\n /**\n * Navigates to a specific column using the configured CellNavigationStrategy.\n */\n scrollToColumn: (columnName: string) => Promise<void>;\n\n /**\n * ASYNC: Gets all rows on the current page only (does not paginate).\n * Auto-initializes the table if not already initialized.\n * @param options - Filter and formatting options\n */\n getRows: <R extends { asJSON?: boolean }>(\n options?: { filter?: Record<string, any>, exact?: boolean } & R\n ) => Promise<R['asJSON'] extends true ? Record<string, string>[] : SmartRow[]>;\n\n /**\n * Resets the table state (clears cache, flags) and invokes the onReset strategy.\n */\n reset: () => Promise<void>;\n\n /**\n * Revalidates the table's structure (headers, columns) without resetting pagination or state.\n * Useful when columns change visibility or order dynamically.\n */\n revalidate: () => Promise<void>;\n\n /**\n * Scans a specific column across all pages and returns the values.\n */\n getColumnValues: <V = string>(column: string, options?: { mapper?: (cell: Locator) => Promise<V> | V, maxPages?: number }) => Promise<V[]>;\n\n /**\n * Provides access to sorting actions and assertions.\n */\n sorting: {\n /**\n * Applies the configured sorting strategy to the specified column.\n * @param columnName The name of the column to sort.\n * @param direction The direction to sort ('asc' or 'desc').\n */\n apply(columnName: string, direction: 'asc' | 'desc'): Promise<void>;\n /**\n * Gets the current sort state of a column using the configured sorting strategy.\n * @param columnName The name of the column to check.\n * @returns A promise that resolves to 'asc', 'desc', or 'none'.\n */\n getState(columnName: string): Promise<'asc' | 'desc' | 'none'>;\n };\n\n /**\n * Iterates through paginated table data, calling the callback for each iteration.\n * Callback return values are automatically appended to allData, which is returned.\n */\n iterateThroughTable: <T = any>(\n callback: (context: {\n index: number;\n isFirst: boolean;\n isLast: boolean;\n rows: SmartRow[];\n allData: T[];\n table: RestrictedTableResult;\n batchInfo?: {\n startIndex: number;\n endIndex: number;\n size: number;\n };\n }) => T | Promise<T>,\n options?: {\n pagination?: PaginationStrategy;\n dedupeStrategy?: DedupeStrategy;\n maxIterations?: number;\n batchSize?: number;\n getIsFirst?: (context: { index: number }) => boolean;\n getIsLast?: (context: { index: number, paginationResult: boolean }) => boolean;\n beforeFirst?: (context: { index: number, rows: SmartRow[], allData: any[] }) => void | Promise<void>;\n afterLast?: (context: { index: number, rows: SmartRow[], allData: any[] }) => void | Promise<void>;\n }\n ) => Promise<T[]>;\n}\n\n/**\n * Restricted table result that excludes methods that shouldn't be called during iteration.\n */\nexport type RestrictedTableResult<T = any> = Omit<TableResult<T>, 'searchForRow' | 'iterateThroughTable' | 'reset'>;\n";
|