eaa-kit 0.7.0 → 0.9.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 (66) hide show
  1. package/README.md +30 -8
  2. package/dist/astro/index.js +1 -1
  3. package/dist/audit-CJDCQaFY.js +2 -0
  4. package/dist/{audit-DRjAY2iY.js → audit-J2jeLo-y.js} +38 -198
  5. package/dist/{baseline-rtnj3RHB.js → baseline-477B1CZ_.js} +1 -1
  6. package/dist/baseline-D9ihb-wk.js +2 -0
  7. package/dist/{baseline-BpE7DbDq.js → baseline-DrFh7joZ.js} +14 -3
  8. package/dist/baseline-wyJsSIFQ.js +127 -0
  9. package/dist/{checklist-DDd9jewi.js → checklist-Gx2g3LFC.js} +6 -6
  10. package/dist/cli/index.js +83 -143
  11. package/dist/{collect-Cu1q9NTB.js → collect-BJYk7_pJ.js} +1 -1
  12. package/dist/{command-3r4fht5f.js → command-BGGMf4vn.js} +30 -4
  13. package/dist/countries-DRTBubeE.js +25 -0
  14. package/dist/countries-Dg0BdytB.js +156 -0
  15. package/dist/{coverage-n1X9CkiG.js → coverage-GvaMpV64.js} +1 -1
  16. package/dist/{coverage-cb5kPp48.js → coverage-zdzgSKjz.js} +1 -1
  17. package/dist/{crawl-BHkJmUkA.js → crawl-DwdqiljK.js} +5 -3
  18. package/dist/{load-BaWMa-G_.js → define-Ctf2uOEh.js} +41 -94
  19. package/dist/eleventy/index.js +1 -1
  20. package/dist/entry-CjqjrUBY.js +174 -0
  21. package/dist/{html-BIxxF3FC.js → html-whingnfj.js} +6 -4
  22. package/dist/index.d.ts +42 -5
  23. package/dist/index.js +3 -2
  24. package/dist/init-CPbFVMuk.js +293 -0
  25. package/dist/{json-CrQmoTj6.js → json-CyLmvF5P.js} +1 -1
  26. package/dist/{json-Bus6YhxB.js → json-SGCgxSPT.js} +1 -1
  27. package/dist/load-CH-ltdlq.js +99 -0
  28. package/dist/load-D7lBeOsq.js +2 -0
  29. package/dist/nuxt/index.js +1 -1
  30. package/dist/pages-DxY5Z0gl.js +300 -0
  31. package/dist/{project-MFrXcw1M.js → project-BLFdCbOq.js} +1 -1
  32. package/dist/{project-CzOnkLH6.js → project-v2PoRw70.js} +18 -1
  33. package/dist/{remediation-C0klJblu.js → remediation-Bbs4KcX1.js} +18 -1
  34. package/dist/{render-C1sUZZI_.js → render-C6zYfaba.js} +29 -5
  35. package/dist/{review-CdMK2GpQ.js → review-Bz0fO9_I.js} +9 -1
  36. package/dist/{review-DIbOTmOM.js → review-a-2ghjQ5.js} +1 -1
  37. package/dist/{routes-CmdRUuOs.js → routes-CSctpS1P.js} +1 -1
  38. package/dist/{run-DrS0Komf.js → run-DzVEOkiF.js} +1 -1
  39. package/dist/{sarif-BNCE0PNT.js → sarif-9BAgNiOa.js} +3 -2
  40. package/dist/site-BHMtf3q2.js +72 -0
  41. package/dist/start-DzOM0p6I.js +101 -0
  42. package/dist/statement/templates/be.de.md +148 -0
  43. package/dist/statement/templates/be.en.md +142 -0
  44. package/dist/statement/templates/be.fr.md +146 -0
  45. package/dist/statement/templates/be.nl.md +147 -0
  46. package/dist/statement/templates/cz.cs.md +137 -0
  47. package/dist/statement/templates/cz.en.md +139 -0
  48. package/dist/statement/templates/dk.da.md +141 -0
  49. package/dist/statement/templates/dk.en.md +141 -0
  50. package/dist/statement/templates/fi.en.md +139 -0
  51. package/dist/statement/templates/fi.fi.md +141 -0
  52. package/dist/statement/templates/ie.en.md +144 -0
  53. package/dist/statement/templates/pl.en.md +143 -0
  54. package/dist/statement/templates/pl.pl.md +144 -0
  55. package/dist/statement/templates/pt.en.md +142 -0
  56. package/dist/statement/templates/pt.pt.md +145 -0
  57. package/dist/statement/templates/se.en.md +139 -0
  58. package/dist/statement/templates/se.sv.md +142 -0
  59. package/dist/vite/index.js +1 -1
  60. package/dist/watch-B2RoUbo0.js +122 -0
  61. package/dist/webpack/index.js +1 -1
  62. package/dist/{worksheet-BIxMtbUd.js → worksheet-B_kQ1pxq.js} +1 -1
  63. package/package.json +2 -2
  64. package/dist/audit-Bwm1xBdJ.js +0 -2
  65. package/dist/init-DrFfzjvm.js +0 -119
  66. package/dist/load-n62iXDq_.js +0 -2
@@ -1,19 +1,26 @@
1
1
  import { n as IMPACT_LEVELS } from "./impact-luGCnN8F.js";
2
2
  import { _ as union, a as integer, d as optional, f as pipe, g as transform, h as string, i as enumeration, m as safeParse, n as boolean, o as isoDate, r as email, t as array, u as object, v as url, y as withDefault } from "./schema-DJSF4K05.js";
3
- import { r as isFile } from "./fs-BmPtmFke.js";
4
- import { readFile } from "node:fs/promises";
5
- import path from "node:path";
6
- import { pathToFileURL } from "node:url";
7
3
  //#region src/config/define.ts
8
- /** Countries with their own supervisory body and statute text. */
4
+ /**
5
+ * Countries with their own supervisory body and statute text. What is known
6
+ * about each one is in `countries.ts`.
7
+ */
9
8
  const COUNTRIES = [
10
9
  "AT",
11
- "DE",
10
+ "BE",
12
11
  "CH",
12
+ "CZ",
13
+ "DE",
14
+ "DK",
13
15
  "ES",
16
+ "FI",
14
17
  "FR",
18
+ "IE",
15
19
  "IT",
16
- "NL"
20
+ "NL",
21
+ "PL",
22
+ "PT",
23
+ "SE"
17
24
  ];
18
25
  /**
19
26
  * Languages a statement can be rendered in.
@@ -24,12 +31,18 @@ const COUNTRIES = [
24
31
  * ones a country has when asked for one it does not.
25
32
  */
26
33
  const STATEMENT_LOCALES = [
34
+ "cs",
35
+ "da",
27
36
  "de",
28
37
  "en",
29
38
  "es",
39
+ "fi",
30
40
  "fr",
31
41
  "it",
32
- "nl"
42
+ "nl",
43
+ "pl",
44
+ "pt",
45
+ "sv"
33
46
  ];
34
47
  /**
35
48
  * Wording follows the EU model statement: fully, partially, or not conformant
@@ -70,6 +83,20 @@ const knownIssueObject = object({
70
83
  */
71
84
  const knownIssueSchema = union([pipe(transform(string({ min: 1 }), (description) => ({ description })), knownIssueObject), knownIssueObject], "expected a description, or an object with one");
72
85
  /**
86
+ * What a crawl does when its entry URL redirects to another site.
87
+ *
88
+ * `ask` puts the question to whoever is at the terminal and, with nobody there,
89
+ * stops. `follow` goes on to the new address, and every report says so. `stop`
90
+ * never goes on, not even to the same site at another address. A redirect
91
+ * within the same host, give or take `www.` and http or https, is followed
92
+ * under `ask` and `follow` without a question, and is still reported.
93
+ */
94
+ const REDIRECT_MODES = [
95
+ "ask",
96
+ "follow",
97
+ "stop"
98
+ ];
99
+ /**
73
100
  * Defaults for `eaa-kit audit` and `eaa-kit baseline`, so a project says once
74
101
  * what every invocation would otherwise repeat.
75
102
  *
@@ -96,6 +123,8 @@ const auditSchema = object({
96
123
  ignoreRobots: optional(boolean()),
97
124
  /** Where the site lists its pages, when that is not /sitemap.xml. */
98
125
  sitemap: optional(string({ min: 1 })),
126
+ /** What to do when the entry URL redirects to another site. */
127
+ redirects: optional(enumeration(REDIRECT_MODES)),
99
128
  maxPages: optional(integer({ min: 1 })),
100
129
  /** 0 audits the entry page alone. */
101
130
  maxDepth: optional(integer({ min: 0 })),
@@ -203,10 +232,12 @@ function defineConfig(config) {
203
232
  }
204
233
  var ConfigError = class extends Error {
205
234
  issues;
235
+ next;
206
236
  name = "ConfigError";
207
- constructor(message, issues = []) {
237
+ constructor(message, issues = [], next) {
208
238
  super(message);
209
239
  this.issues = issues;
240
+ this.next = next;
210
241
  }
211
242
  };
212
243
  /** Validate an already-loaded config object. */
@@ -233,88 +264,4 @@ function parse(schema, value, source) {
233
264
  throw new ConfigError(`${source} is not valid`, issues);
234
265
  }
235
266
  //#endregion
236
- //#region src/config/load.ts
237
- /** Checked in this order, first match wins. */
238
- const CONFIG_FILENAMES = [
239
- "eaa.config.ts",
240
- "eaa.config.mts",
241
- "eaa.config.js",
242
- "eaa.config.mjs",
243
- "eaa.config.json"
244
- ];
245
- /**
246
- * Find and load `eaa.config.{ts,mts,js,mjs,json}`.
247
- *
248
- * TypeScript configs are imported directly: Node strips types natively from
249
- * 22.18 onwards, which is below this package's floor, so no bundler or loader
250
- * dependency is needed. The failure mode that remains is a project with no
251
- * package.json at all, where Node cannot tell ESM from CommonJS; the error says
252
- * so rather than surfacing "Unexpected token 'export'".
253
- */
254
- async function loadConfig(options = {}) {
255
- const cwd = path.resolve(options.cwd ?? process.cwd());
256
- const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
257
- if (!file) throw new ConfigError(`No config file found in ${cwd} or its parent directories`, CONFIG_FILENAMES.map((name) => `looked for ${name}`));
258
- if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`);
259
- return {
260
- config: parseConfig(await readConfigFile(file), path.basename(file)),
261
- path: file
262
- };
263
- }
264
- /**
265
- * Find the config file and read its `audit` block, for the commands that take
266
- * defaults from it.
267
- *
268
- * Returns undefined when there is no config file at all. That is not an error
269
- * here as it is for `statement`: `eaa-kit audit` has always run against a
270
- * project that has never heard of a config file, and it must keep doing so. An
271
- * explicit path that is not there is still an error, because somebody named it.
272
- */
273
- async function loadAuditConfig(options = {}) {
274
- const cwd = path.resolve(options.cwd ?? process.cwd());
275
- const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
276
- if (!file) return void 0;
277
- if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`);
278
- return {
279
- audit: parseAuditConfig(await readConfigFile(file), path.basename(file)),
280
- path: file
281
- };
282
- }
283
- function readConfigFile(file) {
284
- return file.endsWith(".json") ? importJson(file) : importModule(file);
285
- }
286
- /** Walks up from `cwd`, so the CLI works from a subdirectory of the project. */
287
- async function findConfigFile(cwd) {
288
- let directory = path.resolve(cwd);
289
- while (true) {
290
- for (const name of CONFIG_FILENAMES) {
291
- const candidate = path.join(directory, name);
292
- if (await isFile(candidate)) return candidate;
293
- }
294
- const parent = path.dirname(directory);
295
- if (parent === directory) return void 0;
296
- directory = parent;
297
- }
298
- }
299
- async function importJson(file) {
300
- const raw = await readFile(file, "utf8");
301
- try {
302
- return JSON.parse(raw);
303
- } catch (cause) {
304
- throw new ConfigError(`${path.basename(file)} is not valid JSON`, [cause instanceof Error ? cause.message : String(cause)]);
305
- }
306
- }
307
- async function importModule(file) {
308
- let module;
309
- try {
310
- module = await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
311
- } catch (cause) {
312
- const message = cause instanceof Error ? cause.message : String(cause);
313
- const hint = message.includes("Unexpected token") ? "If the project has no package.json, Node cannot tell ESM from CommonJS. Add one with \"type\": \"module\", or use eaa.config.json." : message;
314
- throw new ConfigError(`Could not load ${path.basename(file)}`, [hint]);
315
- }
316
- if (module.default === void 0) throw new ConfigError(`${path.basename(file)} has no default export`, ["Expected: export default defineConfig({ … })"]);
317
- return module.default;
318
- }
319
- //#endregion
320
- export { ASSESSMENT_METHODS as a, ConfigError as c, configSchema as d, defineConfig as f, loadConfig as i, ISSUE_REASONS as l, findConfigFile as n, COMPLIANCE_STATUSES as o, parseConfig as p, loadAuditConfig as r, COUNTRIES as s, CONFIG_FILENAMES as t, STATEMENT_LOCALES as u };
267
+ export { ISSUE_REASONS as a, configSchema as c, parseConfig as d, ConfigError as i, defineConfig as l, COMPLIANCE_STATUSES as n, REDIRECT_MODES as o, COUNTRIES as r, STATEMENT_LOCALES as s, ASSESSMENT_METHODS as t, parseAuditConfig as u };
@@ -1,4 +1,4 @@
1
- import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-DrS0Komf.js";
1
+ import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-DzVEOkiF.js";
2
2
  import path from "node:path";
3
3
  //#region src/eleventy/index.ts
4
4
  /**
@@ -0,0 +1,174 @@
1
+ //#region src/audit/entry.ts
2
+ /**
3
+ * What the entry URL of a crawl actually leads to, found before any page is
4
+ * crawled.
5
+ *
6
+ * Two things can put a run somewhere other than where it was sent, and both
7
+ * used to be discovered too late or not at all:
8
+ *
9
+ * - **A redirect to another site.** `https://www.gtainside.de` answers with a
10
+ * 301 to `https://www.gtainside.com`. The crawl refused every page as
11
+ * "redirected off", and the run ended with an error that did not say what to
12
+ * do about it. The run should stop and say where the site went, and it should
13
+ * only go on there when somebody agrees to.
14
+ * - **A sign-in wall.** A preview deployment or a staging CMS answers 401, or
15
+ * sends every request to a login form. The crawl then audited the login form
16
+ * and reported it as the site, which is the failure this tool is written
17
+ * against: a clean result for pages nobody looked at.
18
+ *
19
+ * So the entry is fetched first, one hop at a time, with redirects not
20
+ * followed automatically. That gives the whole chain, the status of each hop,
21
+ * and the page at the end of it. What to do with a redirect is the caller's
22
+ * decision. It depends on flags and on whether there is a terminal to ask at.
23
+ * This module only establishes the facts.
24
+ */
25
+ /** How many redirects to follow before calling it a loop. */
26
+ const MAX_HOPS = 10;
27
+ /** The origins that sign people in for other sites. Suffix-matched. */
28
+ const IDENTITY_PROVIDERS = [
29
+ "accounts.google.com",
30
+ "login.microsoftonline.com",
31
+ "login.live.com",
32
+ "login.windows.net",
33
+ "b2clogin.com",
34
+ "okta.com",
35
+ "oktapreview.com",
36
+ "auth0.com",
37
+ "onelogin.com",
38
+ "amazoncognito.com",
39
+ "appleid.apple.com",
40
+ "id.atlassian.com"
41
+ ];
42
+ /**
43
+ * Paths that are a sign-in page by name: `/login`, `/sign-in`, `/wp-login.php`,
44
+ * Keycloak's `/protocol/openid-connect/auth`, and a few other languages' words.
45
+ */
46
+ const SIGN_IN_PATH = /(?:^|\/)(?:log-?in|sign-?in|signin|sso|oauth2?|authorize|auth|anmelden|connexion|accedi|inloggen|logowanie|wp-login\.php|users\/sign_in|openid-connect\/auth)(?:[/.?]|$)/i;
47
+ function isIdentityProvider(url) {
48
+ const host = url.hostname.toLowerCase();
49
+ return IDENTITY_PROVIDERS.some((provider) => host === provider || host.endsWith(`.${provider}`));
50
+ }
51
+ function isSignInPath(url) {
52
+ return SIGN_IN_PATH.test(url.pathname);
53
+ }
54
+ /** A form somebody types a password into. The shape every sign-in page has. */
55
+ function hasPasswordField(html) {
56
+ return /<input\b[^>]*\btype\s*=\s*["']?password\b/i.test(html);
57
+ }
58
+ /**
59
+ * Whether two URLs are the same site in the sense a reader means it: the same
60
+ * host, give or take a leading `www.`, over http or https. A redirect between
61
+ * two of these is the site tidying its own address, not a different site.
62
+ */
63
+ function isSameSite(a, b) {
64
+ const host = (url) => url.hostname.toLowerCase().replace(/^www\./, "");
65
+ return host(a) === host(b) && a.port === b.port;
66
+ }
67
+ /** Follow the entry's redirects one at a time, and look at where they end. */
68
+ async function probeEntry(entry, options) {
69
+ const impl = options.fetchImpl ?? fetch;
70
+ const hops = [];
71
+ let current = new URL(entry.href);
72
+ for (let hop = 0; hop <= MAX_HOPS; hop += 1) {
73
+ let response;
74
+ const controller = new AbortController();
75
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs);
76
+ try {
77
+ response = await impl(current.href, {
78
+ signal: controller.signal,
79
+ redirect: "manual",
80
+ headers: {
81
+ accept: "text/html,application/xhtml+xml",
82
+ "user-agent": "eaa-kit",
83
+ ...current.origin === entry.origin ? options.headers : {}
84
+ }
85
+ });
86
+ } catch (cause) {
87
+ clearTimeout(timer);
88
+ const reason = controller.signal.aborted ? `timed out after ${options.timeoutMs}ms` : cause instanceof Error ? cause.message : String(cause);
89
+ return {
90
+ hops,
91
+ final: current,
92
+ status: 0,
93
+ error: reason
94
+ };
95
+ }
96
+ clearTimeout(timer);
97
+ hops.push({
98
+ url: current.href,
99
+ status: response.status
100
+ });
101
+ const location = response.headers.get("location");
102
+ if (response.status >= 300 && response.status < 400 && location !== null) {
103
+ await discard(response);
104
+ current = new URL(location, current);
105
+ current.hash = "";
106
+ continue;
107
+ }
108
+ const result = {
109
+ hops,
110
+ final: current,
111
+ status: response.status
112
+ };
113
+ const signIn = await signInEvidence(entry, current, response, options.maxBodyBytes);
114
+ if (signIn !== void 0) result.signIn = signIn;
115
+ await discard(response);
116
+ return result;
117
+ }
118
+ return {
119
+ hops,
120
+ final: current,
121
+ status: 0,
122
+ error: `more than ${MAX_HOPS} redirects, which is a loop or close enough to one`
123
+ };
124
+ }
125
+ async function signInEvidence(entry, final, response, maxBodyBytes) {
126
+ if (response.status === 401) return "http-401";
127
+ if (response.status === 403) return "http-403";
128
+ if (final.href === entry.href) return void 0;
129
+ if (isIdentityProvider(final)) return "identity-provider";
130
+ if (isSignInPath(final)) return "sign-in-path";
131
+ if (!response.ok) return void 0;
132
+ const type = response.headers.get("content-type") ?? "";
133
+ if (!/\b(?:text\/html|application\/xhtml\+xml)\b/i.test(type)) return void 0;
134
+ return hasPasswordField(await readUpTo(response, maxBodyBytes)) ? "password-field" : void 0;
135
+ }
136
+ /**
137
+ * Let go of a body that was not read, so the connection is released. One that
138
+ * was read is locked to its reader and already finished with.
139
+ */
140
+ async function discard(response) {
141
+ if (response.body === null || response.body.locked) return;
142
+ await response.body.cancel();
143
+ }
144
+ /** A body, cut off at a limit rather than refused: this only looks for a form. */
145
+ async function readUpTo(response, limit) {
146
+ const reader = response.body?.getReader();
147
+ if (reader === void 0) return "";
148
+ const decoder = new TextDecoder();
149
+ let text = "";
150
+ let size = 0;
151
+ for (;;) {
152
+ const { done, value } = await reader.read();
153
+ if (done) break;
154
+ size += value.byteLength;
155
+ text += decoder.decode(value, { stream: true });
156
+ if (size >= limit) {
157
+ await reader.cancel();
158
+ break;
159
+ }
160
+ }
161
+ return text;
162
+ }
163
+ /** What each piece of evidence is, in words, for the message and the report. */
164
+ function describeSignIn(evidence, at) {
165
+ switch (evidence) {
166
+ case "http-401": return `${at} answered 401: it asks for credentials before it shows any page`;
167
+ case "http-403": return `${at} answered 403: it refuses requests that are not signed in`;
168
+ case "identity-provider": return `it sends visitors to sign in at ${new URL(at).origin}`;
169
+ case "sign-in-path": return `it sends visitors to a sign-in page at ${at}`;
170
+ case "password-field": return `it sends visitors to ${at}, a page with a password field on it`;
171
+ }
172
+ }
173
+ //#endregion
174
+ export { describeSignIn, hasPasswordField, isSameSite, probeEntry };
@@ -2,11 +2,11 @@ import { a as impactLabel, r as byImpactThenRule } from "./impact-luGCnN8F.js";
2
2
  import { i as escapeText, n as count, r as escapeAttribute, s as standardsReference, t as collapse } from "./text-BF1LHMiV.js";
3
3
  import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
4
4
  import { u as runEngine } from "./result-B7_zVxAX.js";
5
- import { l as reviewSentence } from "./review-CdMK2GpQ.js";
6
- import { a as isShared, c as missedParts, i as groupIssues, l as reusedPart, n as blindRules, o as issueTotals, r as coverageParts, s as discoveryLabel, t as remediationFor } from "./remediation-C0klJblu.js";
5
+ import { l as reviewSentence } from "./review-Bz0fO9_I.js";
6
+ import { a as isShared, c as missedParts, i as groupIssues, l as redirectPart, n as blindRules, o as issueTotals, r as coverageParts, s as discoveryLabel, t as remediationFor, u as reusedPart } from "./remediation-Bbs4KcX1.js";
7
7
  import { r as componentPath } from "./component-ChisoFyY.js";
8
- import { a as manualCheckFor, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-cb5kPp48.js";
9
- import { n as buildSummary } from "./json-Bus6YhxB.js";
8
+ import { a as manualCheckFor, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-zdzgSKjz.js";
9
+ import { n as buildSummary } from "./json-SGCgxSPT.js";
10
10
  import axe from "axe-core";
11
11
  //#region src/audit/report/html.ts
12
12
  /**
@@ -105,6 +105,8 @@ function runDetails(audits, engine, generatedAt, options) {
105
105
  if (options.completeness) rows.splice(2, 0, ["Pages found via", discoveryLabel(options.completeness.discovery)]);
106
106
  const reused = options.completeness ? reusedPart(options.completeness) : void 0;
107
107
  if (reused !== void 0) rows.push(["Reused", reused]);
108
+ const redirected = options.completeness ? redirectPart(options.completeness) : void 0;
109
+ if (redirected !== void 0) rows.splice(1, 0, ["Redirected", redirected]);
108
110
  return `<h2>The run</h2>\n<dl class="run">\n${rows.map(([term, value]) => ` <div><dt>${escapeText(term)}</dt><dd>${escapeText(value)}</dd></div>`).join("\n")}\n</dl>`;
109
111
  }
110
112
  /** Pages named individually before the rest are counted. */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,25 @@
1
1
  import { t as ImpactLevel } from "./impact-EEB9ZXmC.js";
2
+ //#region src/next.d.ts
3
+ /**
4
+ * The command that gets somebody past an error.
5
+ *
6
+ * An error the reader cannot act on without opening the docs is half an error.
7
+ * Every error class a command can stop on carries one of these where there is a
8
+ * command that fixes it, and `fail` prints it under the message. That keeps
9
+ * "what went wrong" and "what to type" apart, so the second one can be copied
10
+ * as it is.
11
+ *
12
+ * Only where the fix is a command. An invalid field in a config file is fixed
13
+ * by editing the field, and the issues printed under that error already name
14
+ * it, so pointing at a command there would send somebody somewhere else.
15
+ */
16
+ interface NextStep {
17
+ /** Exactly what to type. */
18
+ command: string;
19
+ /** What it does, in a few words. */
20
+ why: string;
21
+ }
22
+ //#endregion
2
23
  //#region src/schema.d.ts
3
24
  /**
4
25
  * The small amount of schema validation this package actually needs.
@@ -59,8 +80,11 @@ type DefaultedSchema<T> = Schema<T> & {
59
80
  };
60
81
  //#endregion
61
82
  //#region src/config/define.d.ts
62
- /** Countries with their own supervisory body and statute text. */
63
- declare const COUNTRIES: readonly ['AT', 'DE', 'CH', 'ES', 'FR', 'IT', 'NL'];
83
+ /**
84
+ * Countries with their own supervisory body and statute text. What is known
85
+ * about each one is in `countries.ts`.
86
+ */
87
+ declare const COUNTRIES: readonly ['AT', 'BE', 'CH', 'CZ', 'DE', 'DK', 'ES', 'FI', 'FR', 'IE', 'IT', 'NL', 'PL', 'PT', 'SE'];
64
88
  type Country = (typeof COUNTRIES)[number];
65
89
  /**
66
90
  * Languages a statement can be rendered in.
@@ -70,7 +94,7 @@ type Country = (typeof COUNTRIES)[number];
70
94
  * has the language it is published in and English. `renderStatement` says which
71
95
  * ones a country has when asked for one it does not.
72
96
  */
73
- declare const STATEMENT_LOCALES: readonly ['de', 'en', 'es', 'fr', 'it', 'nl'];
97
+ declare const STATEMENT_LOCALES: readonly ['cs', 'da', 'de', 'en', 'es', 'fi', 'fr', 'it', 'nl', 'pl', 'pt', 'sv'];
74
98
  type StatementLocale = (typeof STATEMENT_LOCALES)[number];
75
99
  /**
76
100
  * Wording follows the EU model statement: fully, partially, or not conformant
@@ -115,6 +139,8 @@ declare const auditSchema: Schema<ObjectOf<{
115
139
  ignoreRobots: OptionalSchema<boolean>;
116
140
  /** Where the site lists its pages, when that is not /sitemap.xml. */
117
141
  sitemap: OptionalSchema<string>;
142
+ /** What to do when the entry URL redirects to another site. */
143
+ redirects: OptionalSchema<"ask" | "follow" | "stop">;
118
144
  maxPages: OptionalSchema<number>;
119
145
  /** 0 audits the entry page alone. */
120
146
  maxDepth: OptionalSchema<number>;
@@ -203,7 +229,7 @@ declare const configSchema: Schema<ObjectOf<{
203
229
  }>>;
204
230
  enforcement: Schema<ObjectOf<{
205
231
  /** Drives which supervisory body and statute the template names. */
206
- country: Schema<"AT" | "CH" | "DE" | "ES" | "FR" | "IT" | "NL">;
232
+ country: Schema<"AT" | "BE" | "CH" | "CZ" | "DE" | "DK" | "ES" | "FI" | "FR" | "IE" | "IT" | "NL" | "PL" | "PT" | "SE">;
207
233
  }>>;
208
234
  /** Defaults for the audit commands. Nothing here reaches the statement. */
209
235
  audit: OptionalSchema<ObjectOf<{
@@ -220,6 +246,8 @@ declare const configSchema: Schema<ObjectOf<{
220
246
  ignoreRobots: OptionalSchema<boolean>;
221
247
  /** Where the site lists its pages, when that is not /sitemap.xml. */
222
248
  sitemap: OptionalSchema<string>;
249
+ /** What to do when the entry URL redirects to another site. */
250
+ redirects: OptionalSchema<"ask" | "follow" | "stop">;
223
251
  maxPages: OptionalSchema<number>;
224
252
  /** 0 audits the entry page alone. */
225
253
  maxDepth: OptionalSchema<number>;
@@ -320,8 +348,12 @@ type AuditConfig = { [K in keyof Infer<typeof auditSchema>]?: Exclude<Infer<type
320
348
  declare function defineConfig(config: EaaConfigInput): EaaConfigInput;
321
349
  declare class ConfigError extends Error {
322
350
  readonly issues: string[];
351
+ /** The command that fixes it, printed under the message and the issues. */
352
+ readonly next?: NextStep | undefined;
323
353
  readonly name = "ConfigError";
324
- constructor(message: string, issues?: string[]);
354
+ constructor(message: string, issues?: string[],
355
+ /** The command that fixes it, printed under the message and the issues. */
356
+ next?: NextStep | undefined);
325
357
  }
326
358
  /** Validate an already-loaded config object. */
327
359
  declare function parseConfig(value: unknown, source?: string): EaaConfig;
@@ -364,7 +396,12 @@ declare function findConfigFile(cwd: string): Promise<string | undefined>;
364
396
  * it — nothing is emitted at all.
365
397
  */
366
398
  declare class StatementError extends Error {
399
+ /** The command that fixes it, printed under the message. */
400
+ readonly next?: NextStep | undefined;
367
401
  readonly name = "StatementError";
402
+ constructor(message: string,
403
+ /** The command that fixes it, printed under the message. */
404
+ next?: NextStep | undefined);
368
405
  }
369
406
  //#endregion
370
407
  //#region src/audit/review.d.ts
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- import { a as ASSESSMENT_METHODS, c as ConfigError, d as configSchema, f as defineConfig, i as loadConfig, l as ISSUE_REASONS, n as findConfigFile, o as COMPLIANCE_STATUSES, p as parseConfig, s as COUNTRIES, t as CONFIG_FILENAMES, u as STATEMENT_LOCALES } from "./load-BaWMa-G_.js";
2
- import { a as summariseAuditReport, c as StatementError, i as readAuditReport, n as toHtmlBody, o as checkStatementEvidence, r as toHtmlDocument, s as refuses, t as renderStatement } from "./render-C1sUZZI_.js";
1
+ import { a as ISSUE_REASONS, c as configSchema, d as parseConfig, i as ConfigError, l as defineConfig, n as COMPLIANCE_STATUSES, r as COUNTRIES, s as STATEMENT_LOCALES, t as ASSESSMENT_METHODS } from "./define-Ctf2uOEh.js";
2
+ import { i as loadConfig, n as findConfigFile, t as CONFIG_FILENAMES } from "./load-CH-ltdlq.js";
3
+ import { a as summariseAuditReport, c as StatementError, i as readAuditReport, n as toHtmlBody, o as checkStatementEvidence, r as toHtmlDocument, s as refuses, t as renderStatement } from "./render-C6zYfaba.js";
3
4
  export { ASSESSMENT_METHODS, COMPLIANCE_STATUSES, CONFIG_FILENAMES, COUNTRIES, ConfigError, ISSUE_REASONS, STATEMENT_LOCALES, StatementError, checkStatementEvidence, configSchema, defineConfig, findConfigFile, loadConfig, parseConfig, readAuditReport, refuses, renderStatement, summariseAuditReport, toHtmlBody, toHtmlDocument };