@simplysf/simply-utam-core 0.2.0 → 0.3.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 +72 -16
- package/lib/forceignore/forceignore-manager.d.ts +30 -0
- package/lib/forceignore/forceignore-manager.js +28 -10
- package/lib/forceignore/forceignore-manager.js.map +1 -1
- package/lib/forceignore/index.d.ts +1 -1
- package/lib/forceignore/index.js +1 -1
- package/lib/forceignore/index.js.map +1 -1
- package/lib/gitignore/gitignore-manager.d.ts +64 -0
- package/lib/gitignore/gitignore-manager.js +96 -0
- package/lib/gitignore/gitignore-manager.js.map +1 -0
- package/lib/gitignore/index.d.ts +1 -0
- package/lib/gitignore/index.js +17 -0
- package/lib/gitignore/index.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/namespaces/namespace-map.d.ts +18 -0
- package/lib/namespaces/namespace-map.js +75 -0
- package/lib/namespaces/namespace-map.js.map +1 -0
- package/lib/namespaces/namespace-rewriter.js +2 -47
- package/lib/namespaces/namespace-rewriter.js.map +1 -1
- package/lib/scaffold/project-scaffolder.d.ts +26 -1
- package/lib/scaffold/project-scaffolder.js +81 -11
- package/lib/scaffold/project-scaffolder.js.map +1 -1
- package/lib/snapshot/capture.d.ts +56 -0
- package/lib/snapshot/capture.js +115 -0
- package/lib/snapshot/capture.js.map +1 -0
- package/lib/snapshot/console.d.ts +25 -0
- package/lib/snapshot/console.js +74 -0
- package/lib/snapshot/console.js.map +1 -0
- package/lib/snapshot/describe.d.ts +27 -0
- package/lib/snapshot/describe.js +76 -0
- package/lib/snapshot/describe.js.map +1 -0
- package/lib/snapshot/files.d.ts +85 -0
- package/lib/snapshot/files.js +185 -0
- package/lib/snapshot/files.js.map +1 -0
- package/lib/snapshot/find.d.ts +36 -0
- package/lib/snapshot/find.js +186 -0
- package/lib/snapshot/find.js.map +1 -0
- package/lib/snapshot/format.d.ts +96 -0
- package/lib/snapshot/format.js +100 -0
- package/lib/snapshot/format.js.map +1 -0
- package/lib/snapshot/header.d.ts +38 -0
- package/lib/snapshot/header.js +120 -0
- package/lib/snapshot/header.js.map +1 -0
- package/lib/snapshot/index.d.ts +13 -0
- package/lib/snapshot/index.js +28 -0
- package/lib/snapshot/index.js.map +1 -0
- package/lib/snapshot/locate.d.ts +61 -0
- package/lib/snapshot/locate.js +110 -0
- package/lib/snapshot/locate.js.map +1 -0
- package/lib/snapshot/lookup.d.ts +53 -0
- package/lib/snapshot/lookup.js +188 -0
- package/lib/snapshot/lookup.js.map +1 -0
- package/lib/snapshot/page-object-index.d.ts +149 -0
- package/lib/snapshot/page-object-index.js +806 -0
- package/lib/snapshot/page-object-index.js.map +1 -0
- package/lib/snapshot/page-object-packages.d.ts +41 -0
- package/lib/snapshot/page-object-packages.js +115 -0
- package/lib/snapshot/page-object-packages.js.map +1 -0
- package/lib/snapshot/path.d.ts +102 -0
- package/lib/snapshot/path.js +381 -0
- package/lib/snapshot/path.js.map +1 -0
- package/lib/snapshot/query-result.d.ts +20 -0
- package/lib/snapshot/query-result.js +32 -0
- package/lib/snapshot/query-result.js.map +1 -0
- package/lib/snapshot/selector.d.ts +103 -0
- package/lib/snapshot/selector.js +280 -0
- package/lib/snapshot/selector.js.map +1 -0
- package/lib/snapshot/tree.d.ts +76 -0
- package/lib/snapshot/tree.js +201 -0
- package/lib/snapshot/tree.js.map +1 -0
- package/lib/snapshot/walker.js +532 -0
- package/package.json +11 -3
- package/templates/dom-snapshot.steps.mjs +34 -0
- package/templates/wdio.conf.mjs +81 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export { DOM_SNAPSHOT_FORMAT, DOM_SNAPSHOT_VERSION, DomSnapshotError, parseDomSnapshot, readDomSnapshot, serializeDomSnapshot, } from './format.js';
|
|
17
|
+
export { SNAPSHOT_MASK_ENV, captureDomSnapshot, } from './capture.js';
|
|
18
|
+
export { domSnapshotSnippet, importDomSnapshot, } from './console.js';
|
|
19
|
+
export { LATEST_SNAPSHOT, MANUAL_RUN_ID, SNAPSHOT_RUN_ID_ENV, pruneDomSnapshots, snapshotRunId, writeDomSnapshot, } from './files.js';
|
|
20
|
+
export { DEFAULT_OUTPUT_LIMIT } from './query-result.js';
|
|
21
|
+
export { buildPageObjectIndex, } from './page-object-index.js';
|
|
22
|
+
export { lookupPageObject, searchPageObjects, } from './lookup.js';
|
|
23
|
+
export { findNodes } from './find.js';
|
|
24
|
+
export { querySnapshot } from './selector.js';
|
|
25
|
+
export { componentPath, componentPathByText, } from './path.js';
|
|
26
|
+
export { nodeAncestors, nodeDetails, subtree, } from './tree.js';
|
|
27
|
+
export { snapshotHeader, utamErrorHint } from './header.js';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/snapshot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GAOrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GAInB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,GAIjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAA6C,MAAM,mBAAmB,CAAC;AACpG,OAAO,EACL,oBAAoB,GAQrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAIlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAqC,MAAM,WAAW,CAAC;AAEzE,OAAO,EAAE,aAAa,EAA4C,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,aAAa,EACb,mBAAmB,GAQpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,aAAa,EACb,WAAW,EACX,OAAO,GAKR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAkD,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type DomNode, type DomSnapshot } from './format.js';
|
|
2
|
+
/** A node with what the queries need around it. */
|
|
3
|
+
export type Located = {
|
|
4
|
+
node: DomNode;
|
|
5
|
+
parent?: Located;
|
|
6
|
+
/** Reached by stepping into the parent's shadow root. */
|
|
7
|
+
viaShadow: boolean;
|
|
8
|
+
/** The nearest node, itself included, marked `hidden`. */
|
|
9
|
+
hiddenTop?: Located;
|
|
10
|
+
/** The node's place in the walk: shadow root first, then light children, as `tree` prints them. */
|
|
11
|
+
order: number;
|
|
12
|
+
light: Located[];
|
|
13
|
+
shadow: Located[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Every node by its handle, in walk order.
|
|
17
|
+
*
|
|
18
|
+
* @param snapshot The snapshot.
|
|
19
|
+
*/
|
|
20
|
+
export declare function locate(snapshot: DomSnapshot): Map<string, Located>;
|
|
21
|
+
/**
|
|
22
|
+
* One node by its handle. An address (`0.1.2…`) is refused with the handle it stands for, so
|
|
23
|
+
* the caller learns which form commands take.
|
|
24
|
+
*
|
|
25
|
+
* @param snapshot The snapshot.
|
|
26
|
+
* @param nodeId The node's handle, such as `n4821`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getNode(snapshot: DomSnapshot, nodeId: string): Located;
|
|
29
|
+
/** A matched node, as queries report it. */
|
|
30
|
+
export type FoundNode = {
|
|
31
|
+
id: string;
|
|
32
|
+
tag: string;
|
|
33
|
+
attrs?: Record<string, string>;
|
|
34
|
+
text?: string;
|
|
35
|
+
shadowText?: string;
|
|
36
|
+
hidden: boolean;
|
|
37
|
+
/** For a hidden match: the top of the hidden subtree it's in. */
|
|
38
|
+
hiddenUnder?: {
|
|
39
|
+
id: string;
|
|
40
|
+
node: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A located node as queries report it.
|
|
45
|
+
*
|
|
46
|
+
* @param entry The node.
|
|
47
|
+
*/
|
|
48
|
+
export declare function toFound(entry: Located): FoundNode;
|
|
49
|
+
/**
|
|
50
|
+
* The shadow host whose shadow tree a node is in, or undefined for the document's tree.
|
|
51
|
+
*
|
|
52
|
+
* @param entry The node.
|
|
53
|
+
*/
|
|
54
|
+
export declare function treeHost(entry: Located): Located | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Whether `entry` is a descendant of `ancestor`, across shadow roots.
|
|
57
|
+
*
|
|
58
|
+
* @param entry The node.
|
|
59
|
+
* @param ancestor The possible ancestor.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isUnder(entry: Located, ancestor: Located): boolean;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { describePlain } from './describe.js';
|
|
17
|
+
import { DomSnapshotError } from './format.js';
|
|
18
|
+
const indexes = new WeakMap();
|
|
19
|
+
function build(snapshot) {
|
|
20
|
+
const cached = indexes.get(snapshot);
|
|
21
|
+
if (cached)
|
|
22
|
+
return cached;
|
|
23
|
+
const byId = new Map();
|
|
24
|
+
const byAddress = new Map();
|
|
25
|
+
let order = 0;
|
|
26
|
+
const visit = (node, parent, viaShadow) => {
|
|
27
|
+
const entry = { node, parent, viaShadow, order: order++, light: [], shadow: [] };
|
|
28
|
+
entry.hiddenTop = node.hidden ? entry : parent?.hiddenTop;
|
|
29
|
+
byId.set(node.id, entry);
|
|
30
|
+
if (node.address)
|
|
31
|
+
byAddress.set(node.address, entry);
|
|
32
|
+
for (const child of node.shadow?.children ?? [])
|
|
33
|
+
entry.shadow.push(visit(child, entry, true));
|
|
34
|
+
for (const child of node.children ?? [])
|
|
35
|
+
entry.light.push(visit(child, entry, false));
|
|
36
|
+
return entry;
|
|
37
|
+
};
|
|
38
|
+
visit(snapshot.root, undefined, false);
|
|
39
|
+
const built = { byId, byAddress };
|
|
40
|
+
indexes.set(snapshot, built);
|
|
41
|
+
return built;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Every node by its handle, in walk order.
|
|
45
|
+
*
|
|
46
|
+
* @param snapshot The snapshot.
|
|
47
|
+
*/
|
|
48
|
+
export function locate(snapshot) {
|
|
49
|
+
return build(snapshot).byId;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* One node by its handle. An address (`0.1.2…`) is refused with the handle it stands for, so
|
|
53
|
+
* the caller learns which form commands take.
|
|
54
|
+
*
|
|
55
|
+
* @param snapshot The snapshot.
|
|
56
|
+
* @param nodeId The node's handle, such as `n4821`.
|
|
57
|
+
*/
|
|
58
|
+
export function getNode(snapshot, nodeId) {
|
|
59
|
+
const { byId, byAddress } = build(snapshot);
|
|
60
|
+
const found = byId.get(nodeId);
|
|
61
|
+
if (found)
|
|
62
|
+
return found;
|
|
63
|
+
if (/^0(\.|$)/.test(nodeId)) {
|
|
64
|
+
const byAddr = byAddress.get(nodeId);
|
|
65
|
+
throw new DomSnapshotError(`${nodeId} is an address, not a node handle. Commands take the n number printed next to each node${byAddr ? `; in this snapshot that's ${byAddr.node.id}` : ''}.`);
|
|
66
|
+
}
|
|
67
|
+
throw new DomSnapshotError(`No node ${nodeId} in this snapshot.`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A located node as queries report it.
|
|
71
|
+
*
|
|
72
|
+
* @param entry The node.
|
|
73
|
+
*/
|
|
74
|
+
export function toFound(entry) {
|
|
75
|
+
const { node } = entry;
|
|
76
|
+
const found = { id: node.id, tag: node.tag, hidden: entry.hiddenTop !== undefined };
|
|
77
|
+
if (node.attrs)
|
|
78
|
+
found.attrs = node.attrs;
|
|
79
|
+
if (node.text)
|
|
80
|
+
found.text = node.text;
|
|
81
|
+
if (node.shadow?.text)
|
|
82
|
+
found.shadowText = node.shadow.text;
|
|
83
|
+
if (entry.hiddenTop)
|
|
84
|
+
found.hiddenUnder = { id: entry.hiddenTop.node.id, node: describePlain(entry.hiddenTop.node) };
|
|
85
|
+
return found;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The shadow host whose shadow tree a node is in, or undefined for the document's tree.
|
|
89
|
+
*
|
|
90
|
+
* @param entry The node.
|
|
91
|
+
*/
|
|
92
|
+
export function treeHost(entry) {
|
|
93
|
+
for (let up = entry; up.parent; up = up.parent)
|
|
94
|
+
if (up.viaShadow)
|
|
95
|
+
return up.parent;
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether `entry` is a descendant of `ancestor`, across shadow roots.
|
|
100
|
+
*
|
|
101
|
+
* @param entry The node.
|
|
102
|
+
* @param ancestor The possible ancestor.
|
|
103
|
+
*/
|
|
104
|
+
export function isUnder(entry, ancestor) {
|
|
105
|
+
for (let up = entry.parent; up; up = up.parent)
|
|
106
|
+
if (up === ancestor)
|
|
107
|
+
return true;
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=locate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locate.js","sourceRoot":"","sources":["../../src/snapshot/locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAkC,MAAM,aAAa,CAAC;AAgB/E,MAAM,OAAO,GAAG,IAAI,OAAO,EAAgF,CAAC;AAE5G,SAAS,KAAK,CAAC,QAAqB;IAClC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmB,CAAC;IACxC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC7C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,MAA2B,EAAE,SAAkB,EAAW,EAAE;QACxF,MAAM,KAAK,GAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAC1F,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAA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EAAE,EAAE,GAAG,EAAE,CAAC,MAAM;QAAE,IAAI,EAAE,CAAC,SAAS;YAAE,OAAO,EAAE,CAAC,MAAM,CAAC;IAC5F,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,QAAiB;IACvD,KAAK,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM;QAAE,IAAI,EAAE,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;IACjF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type PageObjectArg, type PageObjectElement, type PageObjectIndex, type PageObjectMatch } from './page-object-index.js';
|
|
2
|
+
import { type QueryOutputOptions, type QueryResult } from './query-result.js';
|
|
3
|
+
/** `lookup`'s answer as data: the query and every page object it matched. */
|
|
4
|
+
export type LookupResult = {
|
|
5
|
+
query: string;
|
|
6
|
+
matches: PageObjectMatch[];
|
|
7
|
+
};
|
|
8
|
+
/** One page object in `lookup --search`'s answer. */
|
|
9
|
+
export type SearchResultLine = {
|
|
10
|
+
importPath: string;
|
|
11
|
+
name: string;
|
|
12
|
+
root: boolean;
|
|
13
|
+
interface: boolean;
|
|
14
|
+
tags: string[];
|
|
15
|
+
description?: string;
|
|
16
|
+
};
|
|
17
|
+
/** `lookup --search`'s answer as data. */
|
|
18
|
+
export type SearchResult = {
|
|
19
|
+
query: string;
|
|
20
|
+
results: SearchResultLine[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A getter's or method's parameter list, such as `fieldLabel: string`.
|
|
24
|
+
*
|
|
25
|
+
* @param args The parameters.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatParams(args: PageObjectArg[] | undefined): string;
|
|
28
|
+
/**
|
|
29
|
+
* How test code reaches a public element: its getter, with parameters. A container's getter also
|
|
30
|
+
* takes the page object type to load inside it.
|
|
31
|
+
*
|
|
32
|
+
* @param element A public element.
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatGetter(element: PageObjectElement): string;
|
|
35
|
+
/**
|
|
36
|
+
* The page objects for a tag, or one page object by name, with their import paths, methods and
|
|
37
|
+
* elements. A tag maps to a page object through a root selector, an element typed as that page
|
|
38
|
+
* object, or the naming convention; an implementation is reported as the interface test code loads.
|
|
39
|
+
*
|
|
40
|
+
* @param index The page-object index.
|
|
41
|
+
* @param query A custom element's tag, or a page object's name, import path or short name.
|
|
42
|
+
* @param options The text output limit.
|
|
43
|
+
*/
|
|
44
|
+
export declare function lookupPageObject(index: PageObjectIndex, query: string, options?: QueryOutputOptions): QueryResult<LookupResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Page objects whose name, import path, tags or description contain every word of `query`
|
|
47
|
+
* (case-insensitive): name matches first, then tag matches, then description matches.
|
|
48
|
+
*
|
|
49
|
+
* @param index The page-object index.
|
|
50
|
+
* @param query One or more words.
|
|
51
|
+
* @param options The text output limit.
|
|
52
|
+
*/
|
|
53
|
+
export declare function searchPageObjects(index: PageObjectIndex, query: string, options?: QueryOutputOptions): QueryResult<SearchResult>;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { displayName, findPageObjects, matchPageObjects, } from './page-object-index.js';
|
|
17
|
+
import { DEFAULT_OUTPUT_LIMIT, limitLines } from './query-result.js';
|
|
18
|
+
/**
|
|
19
|
+
* A getter's or method's parameter list, such as `fieldLabel: string`.
|
|
20
|
+
*
|
|
21
|
+
* @param args The parameters.
|
|
22
|
+
*/
|
|
23
|
+
export function formatParams(args) {
|
|
24
|
+
return (args ?? []).map((arg) => `${arg.name}: ${arg.type}`).join(', ');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* How test code reaches a public element: its getter, with parameters. A container's getter also
|
|
28
|
+
* takes the page object type to load inside it.
|
|
29
|
+
*
|
|
30
|
+
* @param element A public element.
|
|
31
|
+
*/
|
|
32
|
+
export function formatGetter(element) {
|
|
33
|
+
const last = element.name.split('.').at(-1) ?? element.name;
|
|
34
|
+
const args = element.type === 'container'
|
|
35
|
+
? [...(element.args ?? []), { name: 'pageObjectType', type: 'constructor' }]
|
|
36
|
+
: element.args;
|
|
37
|
+
return `get${last[0].toUpperCase()}${last.slice(1)}(${formatParams(args)})`;
|
|
38
|
+
}
|
|
39
|
+
/** A compose summary on as many lines as it needs, broken before each `→ chain` or `;` statement. */
|
|
40
|
+
function wrapCompose(compose, indent, width = 110) {
|
|
41
|
+
const pieces = compose.split(/(?=; | → chain )/);
|
|
42
|
+
const lines = [];
|
|
43
|
+
let current = '';
|
|
44
|
+
for (const piece of pieces) {
|
|
45
|
+
if (current && current.length + piece.length > width) {
|
|
46
|
+
lines.push(indent + current);
|
|
47
|
+
current = piece.trimStart();
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
current += piece;
|
|
51
|
+
}
|
|
52
|
+
if (current)
|
|
53
|
+
lines.push(indent + current);
|
|
54
|
+
return lines.map((line, i) => (i === 0 ? line : `${indent} ${line.trimStart()}`));
|
|
55
|
+
}
|
|
56
|
+
/** Drops the boilerplate the shipped page objects start their descriptions with. */
|
|
57
|
+
function shortDescription(description) {
|
|
58
|
+
return description.replace(/Represents the \S+ (Lightning web|Aura) component\.?\s*/i, '').trim();
|
|
59
|
+
}
|
|
60
|
+
function matchedBy(match) {
|
|
61
|
+
if (match.via === 'name')
|
|
62
|
+
return undefined;
|
|
63
|
+
if (match.via !== 'typed element')
|
|
64
|
+
return ` matched by: ${match.via}`;
|
|
65
|
+
const more = (match.declaredByCount ?? 0) - (match.declaredBy?.length ?? 0);
|
|
66
|
+
return ` matched by: typed element in ${(match.declaredBy ?? []).join(', ')}${more > 0 ? ` and ${more} more` : ''}`;
|
|
67
|
+
}
|
|
68
|
+
function describeHeader(index, match) {
|
|
69
|
+
const { entry } = match;
|
|
70
|
+
const flags = [entry.root ? 'root' : 'not root', entry.interface ? 'interface' : '', entry.source].filter(Boolean);
|
|
71
|
+
const lines = [`${displayName(index, entry.name)} (${flags.join(', ')})`];
|
|
72
|
+
if (entry.importPath && entry.name !== entry.importPath)
|
|
73
|
+
lines.push(` name: ${entry.name} (manifest name; a .utam.json "type" uses ${entry.importPath})`);
|
|
74
|
+
if (!entry.importPath)
|
|
75
|
+
lines.push(" import path: none found; no compiled page object for it resolves from the project's node_modules");
|
|
76
|
+
if (entry.outputFile) {
|
|
77
|
+
const how = entry.exported
|
|
78
|
+
? `import it as ${entry.importPath ?? entry.name}, which package.json "exports" maps to it, or by relative path`
|
|
79
|
+
: 'import it by relative path from test code';
|
|
80
|
+
lines.push(` compiled to: ${entry.outputFile} (${how})`);
|
|
81
|
+
}
|
|
82
|
+
const via = matchedBy(match);
|
|
83
|
+
if (via)
|
|
84
|
+
lines.push(via);
|
|
85
|
+
if (match.matchedImplementation)
|
|
86
|
+
lines.push(` matched implementation: ${match.matchedImplementation}; test code loads the interface`);
|
|
87
|
+
if (entry.description)
|
|
88
|
+
lines.push(` description: ${shortDescription(entry.description)}`);
|
|
89
|
+
if (entry.selector)
|
|
90
|
+
lines.push(` root selector: ${entry.selector}`);
|
|
91
|
+
if (entry.implements)
|
|
92
|
+
lines.push(` implements: ${displayName(index, entry.implements)}`);
|
|
93
|
+
if (entry.implementations)
|
|
94
|
+
lines.push(` implementations: ${entry.implementations.map((name) => displayName(index, name)).join(', ')}`);
|
|
95
|
+
return lines;
|
|
96
|
+
}
|
|
97
|
+
function describeMethods(index, entry) {
|
|
98
|
+
if (entry.methods.length === 0)
|
|
99
|
+
return [];
|
|
100
|
+
const lines = [' methods:'];
|
|
101
|
+
for (const method of entry.methods) {
|
|
102
|
+
const returns = method.returns ? ` → ${displayName(index, method.returns)}` : '';
|
|
103
|
+
lines.push(` ${method.name}(${formatParams(method.args)})${returns}`);
|
|
104
|
+
if (method.compose)
|
|
105
|
+
lines.push(...wrapCompose(method.compose, ' '));
|
|
106
|
+
}
|
|
107
|
+
return lines;
|
|
108
|
+
}
|
|
109
|
+
function describeElements(index, entry) {
|
|
110
|
+
if (entry.publicElements.length === 0 && entry.privateElements.length === 0)
|
|
111
|
+
return [];
|
|
112
|
+
const describe = (element) => {
|
|
113
|
+
const type = element.type ? ` → ${displayName(index, element.type)}` : '';
|
|
114
|
+
return `${element.name}${element.list ? '[]' : ''}: "${element.selector}" [${element.scope}]${type}`;
|
|
115
|
+
};
|
|
116
|
+
const lines = [
|
|
117
|
+
" [light]: declared in elements, searched in its parent's light DOM; [shadow]: in shadow.elements, searched in its parent's shadow root.",
|
|
118
|
+
];
|
|
119
|
+
if (entry.publicElements.length > 0) {
|
|
120
|
+
lines.push(' public elements:');
|
|
121
|
+
for (const element of entry.publicElements)
|
|
122
|
+
lines.push(` ${formatGetter(element)} ${describe(element)}`);
|
|
123
|
+
}
|
|
124
|
+
if (entry.privateElements.length > 0) {
|
|
125
|
+
lines.push(' private elements:');
|
|
126
|
+
for (const element of entry.privateElements) {
|
|
127
|
+
const used = element.usedBy?.length ? ` (used by ${element.usedBy.map((m) => `${m}()`).join(', ')})` : '';
|
|
128
|
+
lines.push(` ${describe(element)}${used}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return lines;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The page objects for a tag, or one page object by name, with their import paths, methods and
|
|
135
|
+
* elements. A tag maps to a page object through a root selector, an element typed as that page
|
|
136
|
+
* object, or the naming convention; an implementation is reported as the interface test code loads.
|
|
137
|
+
*
|
|
138
|
+
* @param index The page-object index.
|
|
139
|
+
* @param query A custom element's tag, or a page object's name, import path or short name.
|
|
140
|
+
* @param options The text output limit.
|
|
141
|
+
*/
|
|
142
|
+
export function lookupPageObject(index, query, options = {}) {
|
|
143
|
+
const matches = matchPageObjects(index, query);
|
|
144
|
+
const lines = [];
|
|
145
|
+
if (matches.length === 0) {
|
|
146
|
+
lines.push(`No page object found for "${query}". This doesn't prove none exists, only that the index found no match by tag or name. Try lookup --search <words>.`);
|
|
147
|
+
}
|
|
148
|
+
for (const match of matches) {
|
|
149
|
+
lines.push(...describeHeader(index, match), ...describeMethods(index, match.entry), ...describeElements(index, match.entry));
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
lines: limitLines(lines, options.limit ?? DEFAULT_OUTPUT_LIMIT, 'Look up one page object by its name, or raise --limit.'),
|
|
153
|
+
json: { query, matches },
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Page objects whose name, import path, tags or description contain every word of `query`
|
|
158
|
+
* (case-insensitive): name matches first, then tag matches, then description matches.
|
|
159
|
+
*
|
|
160
|
+
* @param index The page-object index.
|
|
161
|
+
* @param query One or more words.
|
|
162
|
+
* @param options The text output limit.
|
|
163
|
+
*/
|
|
164
|
+
export function searchPageObjects(index, query, options = {}) {
|
|
165
|
+
const results = findPageObjects(index, query).map(({ entry, tags }) => ({
|
|
166
|
+
importPath: displayName(index, entry.name),
|
|
167
|
+
name: entry.name,
|
|
168
|
+
root: entry.root,
|
|
169
|
+
interface: entry.interface,
|
|
170
|
+
tags,
|
|
171
|
+
...(entry.description ? { description: entry.description } : {}),
|
|
172
|
+
}));
|
|
173
|
+
const lines = [`${results.length} page objects match "${query}" (name matches first, then tag, then description):`];
|
|
174
|
+
for (const result of results) {
|
|
175
|
+
const flags = [result.root ? 'root' : '', result.interface ? 'interface' : ''].filter(Boolean).join(', ');
|
|
176
|
+
const tags = result.tags.length > 0 ? ` tags: ${result.tags.slice(0, 4).join(', ')}` : '';
|
|
177
|
+
lines.push(`${result.importPath}${flags ? ` (${flags})` : ''}${tags}`);
|
|
178
|
+
if (result.description)
|
|
179
|
+
lines.push(` ${shortDescription(result.description)}`);
|
|
180
|
+
}
|
|
181
|
+
if (results.length > 0)
|
|
182
|
+
lines.push("Run lookup <name or tag> for one page object's methods and elements.");
|
|
183
|
+
return {
|
|
184
|
+
lines: limitLines(lines, options.limit ?? DEFAULT_OUTPUT_LIMIT, 'Add words to narrow the search, or raise --limit.'),
|
|
185
|
+
json: { query, results },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/snapshot/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,WAAW,EACX,eAAe,EACf,gBAAgB,GAMjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAA6C,MAAM,mBAAmB,CAAC;AAkBhH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAiC;IAC5D,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAA0B;IACrD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO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C;IACpH,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1G,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3F,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QACvE,IAAI,MAAM,CAAC,WAAW;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;IAC3G,OAAO;QACL,KAAK,EAAE,UAAU,CACf,KAAK,EACL,OAAO,CAAC,KAAK,IAAI,oBAAoB,EACrC,mDAAmD,CACpD;QACD,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** An element declared in a page object. */
|
|
2
|
+
export type PageObjectElement = {
|
|
3
|
+
/** The element's name; nested elements are written `parent.child`. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** The page object it returns (import path when known), or its basic type. */
|
|
6
|
+
type?: string;
|
|
7
|
+
selector: string;
|
|
8
|
+
/** The tags the selector names (the last part of each comma-separated alternative). */
|
|
9
|
+
tags: string[];
|
|
10
|
+
/** The last compound of each comma-separated alternative, such as `[slot='secondaryFields']`. */
|
|
11
|
+
lastParts: string[];
|
|
12
|
+
/** `shadow` when declared under `shadow.elements`, so UTAM searches its parent's shadow root. */
|
|
13
|
+
scope: 'light' | 'shadow';
|
|
14
|
+
/** `returnAll`: the getter returns a list. */
|
|
15
|
+
list?: true;
|
|
16
|
+
/**
|
|
17
|
+
* For a private element: the public methods whose `compose` uses it, or an element nested in it,
|
|
18
|
+
* and the getters of public elements nested in it.
|
|
19
|
+
*/
|
|
20
|
+
usedBy?: string[];
|
|
21
|
+
/** `wait: true`: UTAM also generates a `waitFor…` method for it. */
|
|
22
|
+
wait?: true;
|
|
23
|
+
/** The getter's parameters: selector arguments (`%s`, `%d`) of this element and the elements it's nested in. */
|
|
24
|
+
args?: PageObjectArg[];
|
|
25
|
+
};
|
|
26
|
+
export type PageObjectArg = {
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
export type PageObjectMethod = {
|
|
31
|
+
name: string;
|
|
32
|
+
returns?: string;
|
|
33
|
+
args?: PageObjectArg[];
|
|
34
|
+
/** One line on what its `compose` statements do, such as `getText on title ".title"`; none for an interface. */
|
|
35
|
+
compose?: string;
|
|
36
|
+
};
|
|
37
|
+
export type PageObjectEntry = {
|
|
38
|
+
/** Manifest name, or the import path where there's no manifest. */
|
|
39
|
+
name: string;
|
|
40
|
+
/** What test code imports, or what `type` names in the project's own `.utam.json` files. */
|
|
41
|
+
importPath?: string;
|
|
42
|
+
/** For the project's own page objects: the compiled file, relative to the project. */
|
|
43
|
+
outputFile?: string;
|
|
44
|
+
/**
|
|
45
|
+
* For the project's own page objects: package.json `exports` maps the import path to the compiled
|
|
46
|
+
* file, so test code can import it by that path instead of a relative one.
|
|
47
|
+
*/
|
|
48
|
+
exported?: true;
|
|
49
|
+
/** Whether `utam.load` can load it directly. */
|
|
50
|
+
root: boolean;
|
|
51
|
+
interface: boolean;
|
|
52
|
+
/** For an implementation: the interface it implements. */
|
|
53
|
+
implements?: string;
|
|
54
|
+
/** For an interface: its implementations (profiles aren't read). */
|
|
55
|
+
implementations?: string[];
|
|
56
|
+
/** `project`, or the package it came from. */
|
|
57
|
+
source: string;
|
|
58
|
+
/** The root selector, for a root page object. */
|
|
59
|
+
selector?: string;
|
|
60
|
+
publicElements: PageObjectElement[];
|
|
61
|
+
privateElements: PageObjectElement[];
|
|
62
|
+
methods: PageObjectMethod[];
|
|
63
|
+
/** The `.utam.json` file it was read from. */
|
|
64
|
+
file: string;
|
|
65
|
+
/** The page object's own description, joined into one line. */
|
|
66
|
+
description?: string;
|
|
67
|
+
};
|
|
68
|
+
/** Why a tag or name maps to a page object. */
|
|
69
|
+
export type PageObjectMatch = {
|
|
70
|
+
entry: PageObjectEntry;
|
|
71
|
+
via: 'root selector' | 'typed element' | 'convention' | 'name';
|
|
72
|
+
/** For `typed element`: up to a few `pageObject.element` names that declare it. */
|
|
73
|
+
declaredBy?: string[];
|
|
74
|
+
declaredByCount?: number;
|
|
75
|
+
/** Set when the tag matched an implementation and the interface is reported instead. */
|
|
76
|
+
matchedImplementation?: string;
|
|
77
|
+
};
|
|
78
|
+
export type PageObjectIndex = {
|
|
79
|
+
entries: Map<string, PageObjectEntry>;
|
|
80
|
+
/** Import path or manifest name → entry name. */
|
|
81
|
+
aliases: Map<string, string>;
|
|
82
|
+
tags: Map<string, Array<{
|
|
83
|
+
name: string;
|
|
84
|
+
via: 'root selector' | 'typed element';
|
|
85
|
+
declaredBy?: string;
|
|
86
|
+
}>>;
|
|
87
|
+
namespaces: Record<string, string>;
|
|
88
|
+
warnings: string[];
|
|
89
|
+
};
|
|
90
|
+
export type BuildPageObjectIndexOptions = {
|
|
91
|
+
/** The test project. Defaults to the current directory. */
|
|
92
|
+
projectDir?: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* The tags a CSS selector names: the tag of the last compound in each comma-separated alternative.
|
|
96
|
+
*
|
|
97
|
+
* @param selector A CSS selector, possibly with `%s` placeholders.
|
|
98
|
+
*/
|
|
99
|
+
export declare function selectorTags(selector: string): string[];
|
|
100
|
+
/**
|
|
101
|
+
* The last compound of each comma-separated alternative: what the element itself must match.
|
|
102
|
+
*
|
|
103
|
+
* @param selector A CSS selector.
|
|
104
|
+
*/
|
|
105
|
+
export declare function selectorLastParts(selector: string): string[];
|
|
106
|
+
/**
|
|
107
|
+
* Index the project's own page objects, and the page-object packages its namespace configuration
|
|
108
|
+
* maps to, by the tags they cover.
|
|
109
|
+
*
|
|
110
|
+
* @param options Where the project is.
|
|
111
|
+
*/
|
|
112
|
+
export declare function buildPageObjectIndex(options?: BuildPageObjectIndexOptions): PageObjectIndex;
|
|
113
|
+
/** A page object's last path segment, for compact output. */
|
|
114
|
+
export declare function shortName(entry: PageObjectEntry): string;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve a page object by manifest name, import path, or its short name when that is unique.
|
|
117
|
+
*
|
|
118
|
+
* @param index The index.
|
|
119
|
+
* @param name Any of the names a page object goes by.
|
|
120
|
+
*/
|
|
121
|
+
export declare function resolvePageObject(index: PageObjectIndex, name: string): PageObjectEntry[];
|
|
122
|
+
/**
|
|
123
|
+
* The page objects for a tag: by root selector, by typed element, or by naming convention. A query
|
|
124
|
+
* that isn't a tag (it has a `/`, or no `-`) is looked up as a page object's name, import path or
|
|
125
|
+
* short name.
|
|
126
|
+
*
|
|
127
|
+
* @param index The index.
|
|
128
|
+
* @param query A custom element's tag, or a page object's name.
|
|
129
|
+
*/
|
|
130
|
+
export declare function matchPageObjects(index: PageObjectIndex, query: string): PageObjectMatch[];
|
|
131
|
+
export type PageObjectSearchMatch = {
|
|
132
|
+
entry: PageObjectEntry;
|
|
133
|
+
tags: string[];
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Page objects whose name, import path, tags or description contain every word of `query`
|
|
137
|
+
* (case-insensitive). Name matches come first, then tag matches, then description matches.
|
|
138
|
+
*
|
|
139
|
+
* @param index The index.
|
|
140
|
+
* @param query One or more words.
|
|
141
|
+
*/
|
|
142
|
+
export declare function findPageObjects(index: PageObjectIndex, query: string): PageObjectSearchMatch[];
|
|
143
|
+
/**
|
|
144
|
+
* Show a page object reference as test code would import it.
|
|
145
|
+
*
|
|
146
|
+
* @param index The index.
|
|
147
|
+
* @param name A manifest name or import path.
|
|
148
|
+
*/
|
|
149
|
+
export declare function displayName(index: PageObjectIndex, name: string): string;
|