@geonosis/walk 2.13.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/geonosis-walk.mjs +1 -1
  3. package/dist/browser.d.ts +124 -0
  4. package/dist/browser.js +242 -0
  5. package/dist/config.d.ts +16 -0
  6. package/dist/config.js +100 -0
  7. package/dist/index.d.ts +7 -153
  8. package/dist/index.js +5 -13
  9. package/dist/options.d.ts +19 -0
  10. package/dist/options.js +64 -0
  11. package/dist/probes/buy-box-above-fold.d.ts +14 -0
  12. package/dist/probes/buy-box-above-fold.js +54 -0
  13. package/dist/probes/empty-section.d.ts +16 -0
  14. package/dist/probes/empty-section.js +29 -0
  15. package/dist/probes/error-page-status.d.ts +20 -0
  16. package/dist/probes/error-page-status.js +37 -0
  17. package/dist/probes/fabricated-claim.d.ts +14 -0
  18. package/dist/probes/fabricated-claim.js +29 -0
  19. package/dist/probes/fake-session.d.ts +14 -0
  20. package/dist/probes/fake-session.js +45 -0
  21. package/dist/probes/index.d.ts +9 -0
  22. package/dist/probes/index.js +42 -0
  23. package/dist/probes/light-on-light.d.ts +15 -0
  24. package/dist/probes/light-on-light.js +26 -0
  25. package/dist/probes/link-integrity.d.ts +14 -0
  26. package/dist/probes/link-integrity.js +69 -0
  27. package/dist/probes/money-format.d.ts +14 -0
  28. package/dist/probes/money-format.js +33 -0
  29. package/dist/probes/ops-leakage.d.ts +13 -0
  30. package/dist/probes/ops-leakage.js +29 -0
  31. package/dist/probes/orphan-url.d.ts +13 -0
  32. package/dist/probes/orphan-url.js +54 -0
  33. package/dist/probes/placeholder-asset.d.ts +14 -0
  34. package/dist/probes/placeholder-asset.js +40 -0
  35. package/dist/probes/stub-only-entity.d.ts +14 -0
  36. package/dist/probes/stub-only-entity.js +30 -0
  37. package/dist/probes/thin-page.d.ts +14 -0
  38. package/dist/probes/thin-page.js +30 -0
  39. package/dist/types.d.ts +104 -0
  40. package/dist/types.js +10 -0
  41. package/dist/walk-cli.js +41 -47
  42. package/dist/walk.d.ts +23 -0
  43. package/dist/walk.js +93 -0
  44. package/package.json +5 -4
  45. package/dist/chunk-VCGYSFL5.js +0 -956
@@ -0,0 +1,19 @@
1
+ export declare const stringOption: (probe: string, options: Record<string, unknown>, name: string, fallback?: string) => string;
2
+ export declare const stringsOption: (options: Record<string, unknown>, name: string, fallback: string[]) => string[];
3
+ export declare const numberOption: (options: Record<string, unknown>, name: string, fallback: number) => number;
4
+ export declare const flagOption: (options: Record<string, unknown>, name: string, fallback: boolean) => boolean;
5
+ /** The refusal half of D-031, as one line at the top of a probe that cannot work without a list. */
6
+ export declare const requireStrings: (probe: string, options: Record<string, unknown>, name: string) => string[];
7
+ /** The same refusal for a number a probe cannot invent: a floor, a threshold, a count. */
8
+ export declare const requireNumber: (probe: string, options: Record<string, unknown>, name: string) => number;
9
+ /**
10
+ * The `flags` option, validated, with `g` left out on purpose: every use of these patterns is a
11
+ * scan for all matches, and `g` belongs to the call that scans — a shared `g` regex carries a
12
+ * `lastIndex` between calls, which is how a scan silently skips half a page.
13
+ */
14
+ export declare const patternFlags: (probe: string, options: Record<string, unknown>) => string;
15
+ /**
16
+ * Compiled at the top of the run, never at the point of use, so a typo in one entry is a refusal
17
+ * naming the pattern rather than a crash inside a page evaluation three URLs later.
18
+ */
19
+ export declare const assertPatterns: (probe: string, patterns: string[], flags: string) => void;
@@ -0,0 +1,64 @@
1
+ // src/options.ts
2
+ import { WalkError } from "./types.js";
3
+ var stringOption = (probe, options, name, fallback) => {
4
+ const value = options[name];
5
+ if (typeof value === "string" && value !== "")
6
+ return value;
7
+ if (fallback !== undefined)
8
+ return fallback;
9
+ throw new WalkError(`${probe}: needs a "${name}" in the walk options`);
10
+ };
11
+ var stringsOption = (options, name, fallback) => {
12
+ const value = options[name];
13
+ if (!Array.isArray(value))
14
+ return fallback;
15
+ return value.filter((one) => typeof one === "string");
16
+ };
17
+ var numberOption = (options, name, fallback) => {
18
+ const value = options[name];
19
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
20
+ };
21
+ var flagOption = (options, name, fallback) => typeof options[name] === "boolean" ? options[name] : fallback;
22
+ var requireStrings = (probe, options, name) => {
23
+ const value = stringsOption(options, name, []);
24
+ if (value.length === 0) {
25
+ throw new WalkError(`${probe}: needs a non-empty "${name}" in the walk options`);
26
+ }
27
+ return value;
28
+ };
29
+ var requireNumber = (probe, options, name) => {
30
+ const value = options[name];
31
+ if (typeof value !== "number" || !Number.isFinite(value)) {
32
+ throw new WalkError(`${probe}: needs a "${name}" number in the walk options`);
33
+ }
34
+ return value;
35
+ };
36
+ var ALLOWED_FLAGS = new Set(["i", "m", "s", "u"]);
37
+ var patternFlags = (probe, options) => {
38
+ const flags = stringOption(probe, options, "flags", "");
39
+ for (const flag of flags) {
40
+ if (!ALLOWED_FLAGS.has(flag)) {
41
+ throw new WalkError(`${probe}: "${flags}" is not a set of regex flags (i, m, s, u)`);
42
+ }
43
+ }
44
+ return flags;
45
+ };
46
+ var assertPatterns = (probe, patterns, flags) => {
47
+ for (const pattern of patterns) {
48
+ try {
49
+ RegExp(pattern, `${flags}g`);
50
+ } catch {
51
+ throw new WalkError(`${probe}: "${pattern}" is not a regular expression`);
52
+ }
53
+ }
54
+ };
55
+ export {
56
+ assertPatterns,
57
+ flagOption,
58
+ numberOption,
59
+ patternFlags,
60
+ requireNumber,
61
+ requireStrings,
62
+ stringOption,
63
+ stringsOption
64
+ };
@@ -0,0 +1,14 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * The thing a buyer came to do, below the thing they did not.
4
+ *
5
+ * A Medusa storefront's phone PDP ordered gallery → full-screen 3D preview → (scroll) → name →
6
+ * price → … → Add to cart: the buy box was two screens down behind a decoration. This is the one
7
+ * class of the eight that is pure geometry — `getBoundingClientRect()` at a stated viewport, which
8
+ * is why a viewport is part of the walk's input and not a probe option.
9
+ *
10
+ * A page with no buy box says nothing by default: a home page is not a defect, and a probe that
11
+ * fired on every other URL of a walk would be turned off. `required: true` inverts that for a walk
12
+ * whose URLs are all product pages.
13
+ */
14
+ export declare const buyBoxAboveFold: Probe;
@@ -0,0 +1,54 @@
1
+ // src/probes/buy-box-above-fold.ts
2
+ import { collect } from "../browser.js";
3
+ import { flagOption, numberOption, stringOption } from "../options.js";
4
+ var buyBoxAboveFold = {
5
+ class: "buy-box-above-fold",
6
+ id: "buy-box-above-fold",
7
+ needs: (options) => {
8
+ stringOption("buy-box-above-fold", options, "selector");
9
+ },
10
+ run: async (page, { options, url }) => {
11
+ const selector = stringOption("buy-box-above-fold", options, "selector");
12
+ const above = stringOption("buy-box-above-fold", options, "above", "");
13
+ const { rects, viewportHeight } = await collect(page, {
14
+ kind: "geometry",
15
+ selectors: above === "" ? [selector] : [selector, above]
16
+ });
17
+ const buyBox = rects.find((one) => one.selector === selector)?.rect ?? null;
18
+ if (buyBox === null) {
19
+ return flagOption(options, "required", false) ? [
20
+ {
21
+ class: "buy-box-above-fold",
22
+ evidence: `no element matches "${selector}" on a page the walk requires one on`,
23
+ severity: "major",
24
+ url
25
+ }
26
+ ] : [];
27
+ }
28
+ const fold = numberOption(options, "maxTop", viewportHeight);
29
+ const other = above === "" ? null : rects.find((one) => one.selector === above)?.rect ?? null;
30
+ const found = [];
31
+ if (other !== null && buyBox.top > other.top) {
32
+ found.push({
33
+ class: "buy-box-above-fold",
34
+ evidence: `the buy box starts at ${Math.round(buyBox.top)}px, below "${above}" at ${Math.round(other.top)}px`,
35
+ selector,
36
+ severity: "major",
37
+ url
38
+ });
39
+ }
40
+ if (buyBox.top >= fold) {
41
+ found.push({
42
+ class: "buy-box-above-fold",
43
+ evidence: `the buy box starts at ${Math.round(buyBox.top)}px, below the fold at ${Math.round(fold)}px`,
44
+ selector,
45
+ severity: "major",
46
+ url
47
+ });
48
+ }
49
+ return found;
50
+ }
51
+ };
52
+ export {
53
+ buyBoxAboveFold
54
+ };
@@ -0,0 +1,16 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * A section that promises something in its heading and delivers nothing under it.
4
+ *
5
+ * The heading is the promise: "Care and repair", "How it works", "Shipping". A section carrying one
6
+ * and no body is a heading a reader scrolls to and then leaves — and it renders exactly like a
7
+ * section that is merely short, so nothing that looks at pixels or at status codes sees it.
8
+ *
9
+ * Media counts as a body. An illustrated section with a caption in the image is a section that says
10
+ * something, and a probe that fired on it would be switched off.
11
+ *
12
+ * `selector` is REQUIRED (D-031): which containers are sections is a fact about a repo's markup —
13
+ * `section`, `[data-block]`, a grid child — and defaulting to `section` would assume semantic HTML
14
+ * and then report a clean page for every repo that does not write it.
15
+ */
16
+ export declare const emptySection: Probe;
@@ -0,0 +1,29 @@
1
+ // src/probes/empty-section.ts
2
+ import { collect } from "../browser.js";
3
+ import { stringOption } from "../options.js";
4
+ var emptySection = {
5
+ class: "content-integrity",
6
+ id: "empty-section",
7
+ needs: (options) => {
8
+ stringOption("empty-section", options, "selector");
9
+ },
10
+ run: async (page, { options, url }) => {
11
+ const headingSelector = stringOption("empty-section", options, "headingSelector", "h1,h2,h3,h4,h5,h6");
12
+ const hits = await collect(page, {
13
+ headingSelector,
14
+ kind: "prose",
15
+ mediaSelector: stringOption("empty-section", options, "mediaSelector", "img,svg,video,iframe,canvas"),
16
+ selector: stringOption("empty-section", options, "selector")
17
+ });
18
+ return hits.filter((hit) => hit.headingWords > 0 && hit.words <= hit.headingWords && hit.media === 0).map((hit) => ({
19
+ class: "content-integrity",
20
+ evidence: `the section renders ${hit.headingWords} heading word(s) and nothing else — no body text, no media`,
21
+ selector: hit.selector,
22
+ severity: "major",
23
+ url
24
+ }));
25
+ }
26
+ };
27
+ export {
28
+ emptySection
29
+ };
@@ -0,0 +1,20 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * A page that renders an error and answers 200.
4
+ *
5
+ * From a production incident: a framework error boundary was served with a 200, so every
6
+ * curl-style health check, every uptime monitor and every load balancer read the surface as
7
+ * healthy while nobody could use it. The status is the only thing those readers look at, and it
8
+ * was the one thing that was wrong.
9
+ *
10
+ * The status comes from the page's OWN response, which is why it is on the context rather than
11
+ * re-requested here: a second request asks a different question of a server that may not answer
12
+ * twice the same way. A page that answered 400 or worse is a server that told the truth, and this
13
+ * probe says nothing about it — `walk` itself refuses that URL, which is the other half of the
14
+ * same rule.
15
+ *
16
+ * What an error surface LOOKS like is a framework's and a repo's own vocabulary — a digest line, a
17
+ * boundary's copy, a status page's wording, in a language the kit does not know — so `patterns` is
18
+ * required and the probe refuses without it (D-031).
19
+ */
20
+ export declare const errorPageStatus: Probe;
@@ -0,0 +1,37 @@
1
+ // src/probes/error-page-status.ts
2
+ import { collect } from "../browser.js";
3
+ import {
4
+ assertPatterns,
5
+ numberOption,
6
+ patternFlags,
7
+ requireStrings,
8
+ stringOption
9
+ } from "../options.js";
10
+ var errorPageStatus = {
11
+ class: "error-page-status",
12
+ id: "error-page-status",
13
+ needs: (options) => {
14
+ const patterns = requireStrings("error-page-status", options, "patterns");
15
+ assertPatterns("error-page-status", patterns, patternFlags("error-page-status", options));
16
+ },
17
+ run: async (page, { options, status, url }) => {
18
+ if (status >= numberOption(options, "honestFrom", 400))
19
+ return [];
20
+ const hits = await collect(page, {
21
+ flags: patternFlags("error-page-status", options),
22
+ kind: "text",
23
+ patterns: requireStrings("error-page-status", options, "patterns"),
24
+ scope: stringOption("error-page-status", options, "scope", "")
25
+ });
26
+ return hits.map((hit) => ({
27
+ class: "error-page-status",
28
+ evidence: `"${hit.text}" is on a page that answered ${status} — every health check reads that as healthy`,
29
+ selector: hit.selector,
30
+ severity: "blocking",
31
+ url
32
+ }));
33
+ }
34
+ };
35
+ export {
36
+ errorPageStatus
37
+ };
@@ -0,0 +1,14 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * Claims the repo has said it cannot stand behind, in the text a reader can actually read.
4
+ *
5
+ * A Medusa storefront's home page carried "4.9/5 average rating", "2,400+ brands ship with us" and
6
+ * "12M+ units printed to date" on a business that had not shipped a unit. Which sentences those are
7
+ * is a fact about a company, never about a kit, so `claims` is required and the probe refuses
8
+ * without it (D-031): a claim scanner that ran with an empty list would report a clean page for
9
+ * every repo that had not configured it.
10
+ *
11
+ * `innerText`, not the markup: a claim in a comment or in a `hidden` element is a claim nobody was
12
+ * shown, and reporting it sends the fixer to a string that is already dead.
13
+ */
14
+ export declare const fabricatedClaim: Probe;
@@ -0,0 +1,29 @@
1
+ // src/probes/fabricated-claim.ts
2
+ import { collect } from "../browser.js";
3
+ import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
+ var fabricatedClaim = {
5
+ class: "fabricated-claim",
6
+ id: "fabricated-claim",
7
+ needs: (options) => {
8
+ const claims = requireStrings("fabricated-claim", options, "claims");
9
+ assertPatterns("fabricated-claim", claims, patternFlags("fabricated-claim", options));
10
+ },
11
+ run: async (page, { options, url }) => {
12
+ const hits = await collect(page, {
13
+ flags: patternFlags("fabricated-claim", options),
14
+ kind: "text",
15
+ patterns: requireStrings("fabricated-claim", options, "claims"),
16
+ scope: stringOption("fabricated-claim", options, "scope", "")
17
+ });
18
+ return hits.map((hit) => ({
19
+ class: "fabricated-claim",
20
+ evidence: `"${hit.text}" is on the page, matching /${hit.pattern}/`,
21
+ selector: hit.selector,
22
+ severity: "blocking",
23
+ url
24
+ }));
25
+ }
26
+ };
27
+ export {
28
+ fabricatedClaim
29
+ };
@@ -0,0 +1,14 @@
1
+ import { type Probe } from '../types.js';
2
+ /**
3
+ * A visitor who never signed in, shown somebody's session.
4
+ *
5
+ * A Medusa storefront's default session object carried a profile, so an anonymous first-time
6
+ * visitor with no cookies was shown "Your account — Dana Reyes · 4 orders · Sign out". `walk` gives
7
+ * every page a context with no cookies and no storage, which is what makes the reading mean
8
+ * anything: whatever is on the page was rendered for somebody who is not signed in.
9
+ *
10
+ * What "signed in" LOOKS like is a repo's own vocabulary — a `data-` attribute, a menu, a word in a
11
+ * language the kit does not know — so the probe refuses until it is told (D-031), by selector or by
12
+ * text or both.
13
+ */
14
+ export declare const fakeSession: Probe;
@@ -0,0 +1,45 @@
1
+ // src/probes/fake-session.ts
2
+ import { collect } from "../browser.js";
3
+ import { stringsOption } from "../options.js";
4
+ import { WalkError } from "../types.js";
5
+ var escapeForRegex = (value) => value.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
6
+ var fakeSession = {
7
+ class: "fake-session",
8
+ id: "fake-session",
9
+ needs: (options) => {
10
+ const selectors = stringsOption(options, "selectors", []);
11
+ const text = stringsOption(options, "text", []);
12
+ if (selectors.length === 0 && text.length === 0) {
13
+ throw new WalkError('fake-session: needs "selectors" or "text" — what a signed-in page looks like here');
14
+ }
15
+ },
16
+ run: async (page, { options, url }) => {
17
+ const selectors = stringsOption(options, "selectors", []);
18
+ const text = stringsOption(options, "text", []);
19
+ const present = selectors.length === 0 ? [] : await collect(page, { kind: "present", selectors });
20
+ const said = text.length === 0 ? [] : await collect(page, {
21
+ flags: "",
22
+ kind: "text",
23
+ patterns: text.map(escapeForRegex),
24
+ scope: ""
25
+ });
26
+ const bySelector = present.filter((hit) => hit.present).map((hit) => ({
27
+ class: "fake-session",
28
+ evidence: `a context nobody signed in to renders ${hit.selector}`,
29
+ selector: hit.selector,
30
+ severity: "blocking",
31
+ url
32
+ }));
33
+ const byText = said.map((hit) => ({
34
+ class: "fake-session",
35
+ evidence: `a context nobody signed in to reads "${hit.text}"`,
36
+ selector: hit.selector,
37
+ severity: "blocking",
38
+ url
39
+ }));
40
+ return [...bySelector, ...byText];
41
+ }
42
+ };
43
+ export {
44
+ fakeSession
45
+ };
@@ -0,0 +1,9 @@
1
+ import type { Probe } from '../types.js';
2
+ export declare const PROBES: Probe[];
3
+ export declare const probeById: (id: string) => Probe;
4
+ /**
5
+ * The probes a walk runs when nobody named any: the ones whose reading is a property of any page.
6
+ * The other five need a repo's own list to mean anything (D-031) and would refuse the run, so a
7
+ * default set that included them would make `geonosis-walk <url>` fail on every repo.
8
+ */
9
+ export declare const DEFAULT_PROBES: Probe[];
@@ -0,0 +1,42 @@
1
+ // src/probes/index.ts
2
+ import { buyBoxAboveFold } from "./buy-box-above-fold.js";
3
+ import { emptySection } from "./empty-section.js";
4
+ import { errorPageStatus } from "./error-page-status.js";
5
+ import { fabricatedClaim } from "./fabricated-claim.js";
6
+ import { fakeSession } from "./fake-session.js";
7
+ import { lightOnLight } from "./light-on-light.js";
8
+ import { linkIntegrity } from "./link-integrity.js";
9
+ import { moneyFormat } from "./money-format.js";
10
+ import { opsLeakage } from "./ops-leakage.js";
11
+ import { orphanUrl } from "./orphan-url.js";
12
+ import { placeholderAsset } from "./placeholder-asset.js";
13
+ import { stubOnlyEntity } from "./stub-only-entity.js";
14
+ import { thinPage } from "./thin-page.js";
15
+ var PROBES = [
16
+ buyBoxAboveFold,
17
+ emptySection,
18
+ errorPageStatus,
19
+ fabricatedClaim,
20
+ fakeSession,
21
+ lightOnLight,
22
+ linkIntegrity,
23
+ moneyFormat,
24
+ opsLeakage,
25
+ orphanUrl,
26
+ placeholderAsset,
27
+ stubOnlyEntity,
28
+ thinPage
29
+ ];
30
+ var probeById = (id) => {
31
+ const probe = PROBES.find((one) => one.id === id);
32
+ if (probe === undefined) {
33
+ throw new Error(`no probe called "${id}" — known probes: ${PROBES.map((one) => one.id).join(", ")}`);
34
+ }
35
+ return probe;
36
+ };
37
+ var DEFAULT_PROBES = PROBES.filter((one) => one.needs === undefined);
38
+ export {
39
+ DEFAULT_PROBES,
40
+ PROBES,
41
+ probeById
42
+ };
@@ -0,0 +1,15 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * An element that declares its own surface, and is invisible on the one behind it.
4
+ *
5
+ * A Medusa storefront's t34 shipped a "cream" chip on a cream page and t22 a skeleton on paper;
6
+ * both passed a screenshot review, because a JPEG of two colours a reader cannot tell apart looks
7
+ * exactly like a JPEG of a surface that is there. The DOM tells the truth, so the probe reads
8
+ * painted backgrounds and computes the WCAG ratio rather than looking at pixels.
9
+ *
10
+ * It only judges an element that is trying to be a distinct surface and is distinguished by nothing
11
+ * else: an opaque background of its own, no background image, no border, no shadow, no outline, and
12
+ * a box that does not simply repaint the one behind it. Every one of those exclusions is a shape a
13
+ * designer used deliberately, and a probe that fired on them would be switched off within a week.
14
+ */
15
+ export declare const lightOnLight: Probe;
@@ -0,0 +1,26 @@
1
+ // src/probes/light-on-light.ts
2
+ import { collect } from "../browser.js";
3
+ import { numberOption, stringOption, stringsOption } from "../options.js";
4
+ var lightOnLight = {
5
+ class: "light-on-light",
6
+ id: "light-on-light",
7
+ run: async (page, { options, url }) => {
8
+ const minContrast = numberOption(options, "minContrast", 1.05);
9
+ const hits = await collect(page, {
10
+ ignore: stringsOption(options, "ignore", []),
11
+ kind: "contrast",
12
+ minContrast,
13
+ selector: stringOption("light-on-light", options, "selector", "*")
14
+ });
15
+ return hits.map((hit) => ({
16
+ class: "light-on-light",
17
+ evidence: `${hit.background} on ${hit.container} (${hit.containerSelector}) — contrast ${hit.contrast.toFixed(2)}, floor ${minContrast}`,
18
+ selector: hit.selector,
19
+ severity: "major",
20
+ url
21
+ }));
22
+ }
23
+ };
24
+ export {
25
+ lightOnLight
26
+ };
@@ -0,0 +1,14 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * Controls that go nowhere, and links that go somewhere gone.
4
+ *
5
+ * The dead half is a DOM read: an `href` that is absent, empty, `#` or `javascript:` is a control a
6
+ * buyer will click and nothing will happen — a Medusa storefront shipped a kit default's "Looking
7
+ * for a gift?" pointing at `#` on every category page. The broken half is a request: same-origin
8
+ * links are HEAD-ed (GET when a server answers 405 or 501, which some do), and anything from 400 up
9
+ * is a link that 404s in front of the buyer.
10
+ *
11
+ * Another origin is left alone unless asked for: a gate that fails because someone else's site was
12
+ * down is a gate that gets disabled, and it would make the walk a crawler of the whole internet.
13
+ */
14
+ export declare const linkIntegrity: Probe;
@@ -0,0 +1,69 @@
1
+ // src/probes/link-integrity.ts
2
+ import { collect } from "../browser.js";
3
+ import { flagOption, stringOption, stringsOption } from "../options.js";
4
+ var DEAD = ["", "#"];
5
+ var linkIntegrity = {
6
+ class: "link-integrity",
7
+ id: "link-integrity",
8
+ run: async (page, { memo, options, url }) => {
9
+ const dead = stringsOption(options, "deadHrefs", DEAD);
10
+ const ignore = stringsOption(options, "ignore", []);
11
+ const checkExternal = flagOption(options, "checkExternal", false);
12
+ const origin = new URL(url).origin;
13
+ const hits = await collect(page, {
14
+ kind: "links",
15
+ selector: stringOption("link-integrity", options, "selector", 'a,[role="link"]')
16
+ });
17
+ const found = [];
18
+ for (const hit of hits) {
19
+ const href = hit.href;
20
+ if (href === null || dead.includes(href.trim()) || href.trim().startsWith("javascript:")) {
21
+ found.push({
22
+ class: "link-integrity",
23
+ evidence: `dead control: href ${href === null ? "absent" : `"${href}"`} on "${hit.text}"`,
24
+ selector: hit.selector,
25
+ severity: "major",
26
+ url
27
+ });
28
+ continue;
29
+ }
30
+ const target = hit.resolved;
31
+ if (!target.startsWith("http"))
32
+ continue;
33
+ if (ignore.some((pattern) => new RegExp(pattern).test(target)))
34
+ continue;
35
+ if (!checkExternal && new URL(target).origin !== origin)
36
+ continue;
37
+ const status = await statusOf(page, memo, target);
38
+ if (status < 400)
39
+ continue;
40
+ found.push({
41
+ class: "link-integrity",
42
+ evidence: `${target} answered ${status}`,
43
+ selector: hit.selector,
44
+ severity: "blocking",
45
+ url
46
+ });
47
+ }
48
+ return found;
49
+ }
50
+ };
51
+ var statusOf = async (page, memo, target) => {
52
+ const key = `link-integrity:${target}`;
53
+ const seen = memo.get(key);
54
+ if (typeof seen === "number")
55
+ return seen;
56
+ let status;
57
+ try {
58
+ const head = await page.request.head(target, { failOnStatusCode: false });
59
+ status = head.status() === 405 || head.status() === 501 ? (await page.request.get(target, { failOnStatusCode: false })).status() : head.status();
60
+ } catch (error) {
61
+ status = 599;
62
+ memo.set(`${key}:why`, error.message);
63
+ }
64
+ memo.set(key, status);
65
+ return status;
66
+ };
67
+ export {
68
+ linkIntegrity
69
+ };
@@ -0,0 +1,14 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * A price on the page in a shape this repo does not write.
4
+ *
5
+ * `£24` beside `£24.00` is not a rendering bug and not a broken page; it is two answers to "what
6
+ * does a price look like here", and the one a reader meets is whichever component happened to
7
+ * format it. A currency that lost its minor units, a thousands separator that appears on one page
8
+ * and not the next, a bare number where every other price carries a symbol.
9
+ *
10
+ * `accept` is REQUIRED (D-031): what a correct price looks like is a fact about a business, never
11
+ * about a kit, and a probe that ran with no accepted shape would report a clean page for every repo
12
+ * that had not configured it.
13
+ */
14
+ export declare const moneyFormat: Probe;
@@ -0,0 +1,33 @@
1
+ // src/probes/money-format.ts
2
+ import { collect } from "../browser.js";
3
+ import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
+ var AMOUNT = String.raw`\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{1,2})?`;
5
+ var MONEY = String.raw`[€$£¥₺]\s?${AMOUNT}|${AMOUNT}\s?(?:USD|EUR|GBP|TRY|JPY)\b`;
6
+ var moneyFormat = {
7
+ class: "content-integrity",
8
+ id: "money-format",
9
+ needs: (options) => {
10
+ const accept = requireStrings("money-format", options, "accept");
11
+ assertPatterns("money-format", accept, patternFlags("money-format", options));
12
+ },
13
+ run: async (page, { options, url }) => {
14
+ const flags = patternFlags("money-format", options);
15
+ const accept = requireStrings("money-format", options, "accept").map((pattern) => new RegExp(`^(?:${pattern})$`, flags));
16
+ const hits = await collect(page, {
17
+ flags,
18
+ kind: "matches",
19
+ patterns: [stringOption("money-format", options, "find", MONEY)],
20
+ scope: stringOption("money-format", options, "scope", "")
21
+ });
22
+ return hits.filter((hit) => !accept.some((one) => one.test(hit.text.trim()))).map((hit) => ({
23
+ class: "content-integrity",
24
+ evidence: `"${hit.text}" is money in a shape this repo does not accept`,
25
+ selector: hit.selector,
26
+ severity: "major",
27
+ url
28
+ }));
29
+ }
30
+ };
31
+ export {
32
+ moneyFormat
33
+ };
@@ -0,0 +1,13 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * The operations side, showing through into what a customer is offered.
4
+ *
5
+ * A Medusa storefront's checkout offered a US buyer of 5,000 mailer boxes four ocean-freight options — the
6
+ * INBOUND freight the logistics side books, registered in the same seed as store-visible shipping.
7
+ * The words that mean "internal" are a repo's own vocabulary, so `patterns` is required (D-031).
8
+ *
9
+ * `scope` is what separates this from a page-wide word hunt: the same words in a footnote about how
10
+ * the company sources board are not a leak. The probe's own fixture pair is exactly that — the same
11
+ * two phrases inside the delivery fieldset and outside it.
12
+ */
13
+ export declare const opsLeakage: Probe;
@@ -0,0 +1,29 @@
1
+ // src/probes/ops-leakage.ts
2
+ import { collect } from "../browser.js";
3
+ import { assertPatterns, patternFlags, requireStrings, stringOption } from "../options.js";
4
+ var opsLeakage = {
5
+ class: "ops-leakage",
6
+ id: "ops-leakage",
7
+ needs: (options) => {
8
+ const patterns = requireStrings("ops-leakage", options, "patterns");
9
+ assertPatterns("ops-leakage", patterns, patternFlags("ops-leakage", options));
10
+ },
11
+ run: async (page, { options, url }) => {
12
+ const hits = await collect(page, {
13
+ flags: patternFlags("ops-leakage", options),
14
+ kind: "text",
15
+ patterns: requireStrings("ops-leakage", options, "patterns"),
16
+ scope: stringOption("ops-leakage", options, "scope", "")
17
+ });
18
+ return hits.map((hit) => ({
19
+ class: "ops-leakage",
20
+ evidence: `"${hit.text}" is offered to the customer, matching /${hit.pattern}/`,
21
+ selector: hit.selector,
22
+ severity: "blocking",
23
+ url
24
+ }));
25
+ }
26
+ };
27
+ export {
28
+ opsLeakage
29
+ };
@@ -0,0 +1,13 @@
1
+ import type { Probe } from '../types.js';
2
+ /**
3
+ * A page the walk was told about that nothing on the walk links to.
4
+ *
5
+ * It answers 200, it renders, every per-page probe passes it — and the only way a reader reaches it
6
+ * is by being handed the URL. That is not a fact any one page can know, which is why this is the
7
+ * probe with a report-level half: `run` records what each page links to, and `finish` names the
8
+ * walked URLs nothing pointed at.
9
+ *
10
+ * A page that is deliberately unlinked — a campaign landing page, a print view — goes in `entry`,
11
+ * which is the repo's list and empty by default.
12
+ */
13
+ export declare const orphanUrl: Probe;