@a11ied/wcag-data 0.0.0-placeholder → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/NOTICE.md +94 -0
- package/README.md +79 -0
- package/data/generated/.gitkeep +1 -0
- package/data/generated/act-rules.2.1.json +663 -0
- package/data/generated/act-rules.2.2.json +663 -0
- package/data/generated/apg-patterns.json +11549 -0
- package/data/generated/axe-rules.2.1.json +1331 -0
- package/data/generated/axe-rules.2.2.json +1331 -0
- package/data/generated/criteria-by-level.2.1.json +89 -0
- package/data/generated/criteria-by-level.2.2.json +97 -0
- package/data/generated/criteria.2.1.json +9744 -0
- package/data/generated/criteria.2.2.json +10222 -0
- package/data/generated/documents-content.json +981 -0
- package/data/generated/failure-index.2.1.json +839 -0
- package/data/generated/failure-index.2.2.json +866 -0
- package/data/generated/generated-provenance.json +330 -0
- package/data/generated/mobile-guidance.json +850 -0
- package/data/generated/slug-index.2.1.json +83 -0
- package/data/generated/slug-index.2.2.json +91 -0
- package/data/generated/strategy.2.1.json +3217 -0
- package/data/generated/strategy.2.2.json +3460 -0
- package/data/generated/technique-bodies.2.1.json +3659 -0
- package/data/generated/technique-bodies.2.2.json +3686 -0
- package/data/generated/technique-index.2.1.json +3239 -0
- package/data/generated/technique-index.2.2.json +3293 -0
- package/data/generated/test-method-summary.2.1.json +129 -0
- package/data/generated/test-method-summary.2.2.json +137 -0
- package/data/generated/test-methods.2.1.json +882 -0
- package/data/generated/test-methods.2.2.json +966 -0
- package/data/generated/understanding.2.1.json +785 -0
- package/data/generated/understanding.2.2.json +865 -0
- package/dist/index.d.ts +320 -0
- package/dist/index.js +23795 -0
- package/package.json +55 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { WcagVersion, TestMethod, NormalizedCriteriaArtifact, CriteriaByLevelArtifact, SlugIndexArtifact, TechniqueIndexArtifact, FailureIndexArtifact } from '@a11ied/contracts';
|
|
2
|
+
|
|
3
|
+
type SourceFormat = 'json' | 'yaml' | 'derived-json';
|
|
4
|
+
type RemoteSourceId = 'wcag22' | 'wcag21' | 'act-mapping' | 'quickref-tags';
|
|
5
|
+
type LocalSourceId = 'axe-rules';
|
|
6
|
+
type RawSourceId = RemoteSourceId | LocalSourceId;
|
|
7
|
+
type FetchLike = typeof fetch;
|
|
8
|
+
interface WcagDataDirectories {
|
|
9
|
+
packageRoot: string;
|
|
10
|
+
raw: string;
|
|
11
|
+
generated: string;
|
|
12
|
+
scripts: string;
|
|
13
|
+
test: string;
|
|
14
|
+
}
|
|
15
|
+
interface RawSourceDefinition {
|
|
16
|
+
id: RawSourceId;
|
|
17
|
+
fileName: string;
|
|
18
|
+
format: SourceFormat;
|
|
19
|
+
primaryUrl: string;
|
|
20
|
+
fallbackUrls?: string[];
|
|
21
|
+
upstreamVersion?: string;
|
|
22
|
+
validate: (payload: unknown) => void;
|
|
23
|
+
}
|
|
24
|
+
interface CriterionPayload {
|
|
25
|
+
id: string;
|
|
26
|
+
num: string;
|
|
27
|
+
alt_id?: string[];
|
|
28
|
+
content: string;
|
|
29
|
+
handle: string;
|
|
30
|
+
title: string;
|
|
31
|
+
versions: string[];
|
|
32
|
+
level: 'A' | 'AA' | 'AAA';
|
|
33
|
+
details?: unknown[];
|
|
34
|
+
techniques?: {
|
|
35
|
+
sufficient?: TechniqueOrGroupPayload[];
|
|
36
|
+
advisory?: TechniqueOrGroupPayload[];
|
|
37
|
+
failure?: TechniquePayload[];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface GuidelinePayload {
|
|
41
|
+
id: string;
|
|
42
|
+
num: string;
|
|
43
|
+
handle: string;
|
|
44
|
+
title: string;
|
|
45
|
+
successcriteria: CriterionPayload[];
|
|
46
|
+
}
|
|
47
|
+
interface PrinciplePayload {
|
|
48
|
+
id: string;
|
|
49
|
+
num: string;
|
|
50
|
+
handle: string;
|
|
51
|
+
title: string;
|
|
52
|
+
guidelines: GuidelinePayload[];
|
|
53
|
+
}
|
|
54
|
+
interface TechniqueGroupPayload {
|
|
55
|
+
title?: string;
|
|
56
|
+
note?: string;
|
|
57
|
+
techniques?: TechniquePayload[];
|
|
58
|
+
}
|
|
59
|
+
interface TechniquePayload {
|
|
60
|
+
id?: string;
|
|
61
|
+
title: string;
|
|
62
|
+
technology?: string;
|
|
63
|
+
suffix?: string;
|
|
64
|
+
using?: TechniquePayload[];
|
|
65
|
+
and?: TechniquePayload[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A `sufficient`/`advisory` entry is either a `{title, techniques}` "Situation" group, or
|
|
69
|
+
* a technique node placed directly at the top level (a real technique, or a synthetic
|
|
70
|
+
* OR/AND wrapper with `using`/`and` children and no `techniques` list of its own).
|
|
71
|
+
*/
|
|
72
|
+
type TechniqueOrGroupPayload = TechniqueGroupPayload | TechniquePayload;
|
|
73
|
+
type QuickrefTagsPayload = Record<string, Record<string, string>>;
|
|
74
|
+
interface WcagPayload {
|
|
75
|
+
principles: PrinciplePayload[];
|
|
76
|
+
terms: unknown;
|
|
77
|
+
}
|
|
78
|
+
interface RawSourceProvenance {
|
|
79
|
+
sourceId: RawSourceId;
|
|
80
|
+
sourceUrl: string;
|
|
81
|
+
resolvedUrl: string;
|
|
82
|
+
syncedAt: string;
|
|
83
|
+
upstreamVersion?: string;
|
|
84
|
+
sha256: string;
|
|
85
|
+
contentType: SourceFormat;
|
|
86
|
+
etag?: string;
|
|
87
|
+
lastModified?: string;
|
|
88
|
+
fallbackUsed: boolean;
|
|
89
|
+
}
|
|
90
|
+
interface RawArtifactWriteResult {
|
|
91
|
+
sourceId: RawSourceId;
|
|
92
|
+
fileName: string;
|
|
93
|
+
filePath: string;
|
|
94
|
+
provenancePath: string;
|
|
95
|
+
provenance: RawSourceProvenance;
|
|
96
|
+
}
|
|
97
|
+
interface SyncRawSourcesResult {
|
|
98
|
+
fetchList: string[];
|
|
99
|
+
artifacts: RawArtifactWriteResult[];
|
|
100
|
+
axeRuleCount: number;
|
|
101
|
+
}
|
|
102
|
+
interface GeneratedArtifactWriteResult {
|
|
103
|
+
fileName: string;
|
|
104
|
+
filePath: string;
|
|
105
|
+
}
|
|
106
|
+
interface NormalizedArtifactsResult {
|
|
107
|
+
generatedArtifacts: GeneratedArtifactWriteResult[];
|
|
108
|
+
criteriaCountByVersion: Record<WcagVersion, number>;
|
|
109
|
+
testMethodCountsByVersion: Record<WcagVersion, Record<TestMethod, number>>;
|
|
110
|
+
}
|
|
111
|
+
interface GeneratedArtifactProvenance {
|
|
112
|
+
fileName: string;
|
|
113
|
+
sha256: string;
|
|
114
|
+
wcagVersion?: WcagVersion;
|
|
115
|
+
sourceFileNames: string[];
|
|
116
|
+
sourceUrls: string[];
|
|
117
|
+
}
|
|
118
|
+
interface GeneratedProvenanceManifest {
|
|
119
|
+
generatedAt: string;
|
|
120
|
+
rawSources: Array<RawSourceProvenance & {
|
|
121
|
+
fileName: string;
|
|
122
|
+
}>;
|
|
123
|
+
artifacts: GeneratedArtifactProvenance[];
|
|
124
|
+
}
|
|
125
|
+
interface DerivedAxeRule {
|
|
126
|
+
ruleId: string;
|
|
127
|
+
description: string;
|
|
128
|
+
help: string;
|
|
129
|
+
helpUrl: string;
|
|
130
|
+
tags: string[];
|
|
131
|
+
actIds: string[];
|
|
132
|
+
}
|
|
133
|
+
/** Raised when raw or generated WCAG data fails local validation. */
|
|
134
|
+
declare class SyncValidationError extends Error {
|
|
135
|
+
readonly exitCode = 3;
|
|
136
|
+
readonly sourceId: RawSourceId;
|
|
137
|
+
readonly sourceUrl: string;
|
|
138
|
+
constructor(sourceId: RawSourceId, sourceUrl: string, message: string);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Returns the directory layout used by the WCAG data package. */
|
|
142
|
+
declare function getWcagDataDirectories(): WcagDataDirectories;
|
|
143
|
+
/** Creates the WCAG data directory layout when it does not exist yet. */
|
|
144
|
+
declare function ensureWcagDataDirectories(): Promise<WcagDataDirectories>;
|
|
145
|
+
/** Lists the approved upstream URLs this package syncs from. */
|
|
146
|
+
declare function listApprovedUpstreamSourceUrls(): string[];
|
|
147
|
+
/** Lists the raw source definitions used by the sync pipeline. */
|
|
148
|
+
declare function listRawSourceDefinitions(): RawSourceDefinition[];
|
|
149
|
+
|
|
150
|
+
/** Derives local axe rule metadata from the installed axe-core package. */
|
|
151
|
+
declare function deriveAxeRuleMetadata(): DerivedAxeRule[];
|
|
152
|
+
/** Fetches, validates, and writes the approved raw upstream WCAG sources. */
|
|
153
|
+
declare function syncRawSources(options?: {
|
|
154
|
+
directories?: WcagDataDirectories;
|
|
155
|
+
fetchImpl?: FetchLike;
|
|
156
|
+
syncedAt?: string;
|
|
157
|
+
}): Promise<SyncRawSourcesResult>;
|
|
158
|
+
|
|
159
|
+
/** Normalizes raw WCAG source payloads into the generated criterion artifacts. */
|
|
160
|
+
declare function normalizeCriteriaArtifacts(input: {
|
|
161
|
+
version: WcagVersion;
|
|
162
|
+
wcag: WcagPayload;
|
|
163
|
+
quickrefTags: QuickrefTagsPayload;
|
|
164
|
+
}): {
|
|
165
|
+
criteriaArtifact: NormalizedCriteriaArtifact;
|
|
166
|
+
criteriaByLevelArtifact: CriteriaByLevelArtifact;
|
|
167
|
+
slugIndexArtifact: SlugIndexArtifact;
|
|
168
|
+
techniqueIndexArtifact: TechniqueIndexArtifact;
|
|
169
|
+
failureIndexArtifact: FailureIndexArtifact;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/** Generates the committed WCAG artifact set from the synced raw sources. */
|
|
173
|
+
declare function generateNormalizedArtifacts(directories?: WcagDataDirectories): Promise<NormalizedArtifactsResult>;
|
|
174
|
+
/** Runs the full WCAG data sync pipeline from raw fetch through generated artifacts. */
|
|
175
|
+
declare function runWcagDataSync(options?: {
|
|
176
|
+
directories?: WcagDataDirectories;
|
|
177
|
+
fetchImpl?: FetchLike;
|
|
178
|
+
syncedAt?: string;
|
|
179
|
+
}): Promise<{
|
|
180
|
+
fetchList: string[];
|
|
181
|
+
rawArtifacts: GeneratedArtifactWriteResult[];
|
|
182
|
+
axeRuleCount: number;
|
|
183
|
+
generatedArtifacts: GeneratedArtifactWriteResult[];
|
|
184
|
+
criteriaCountByVersion: Record<WcagVersion, number>;
|
|
185
|
+
testMethodCountsByVersion: Record<WcagVersion, Record<TestMethod, number>>;
|
|
186
|
+
}>;
|
|
187
|
+
|
|
188
|
+
type DocumentExtractMode = 'full' | 'core-sections';
|
|
189
|
+
|
|
190
|
+
type DocumentRequestKind = 'understanding' | 'technique';
|
|
191
|
+
/** One page to fetch: an Understanding document (by criterion) or a technique body. */
|
|
192
|
+
interface DocumentRequest {
|
|
193
|
+
kind: DocumentRequestKind;
|
|
194
|
+
id: string;
|
|
195
|
+
title: string;
|
|
196
|
+
version: WcagVersion;
|
|
197
|
+
url: string;
|
|
198
|
+
criterionId?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface FailedDocumentFetch {
|
|
202
|
+
request: DocumentRequest;
|
|
203
|
+
message: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
interface SyncDocumentArtifactsResult {
|
|
207
|
+
generated: GeneratedArtifactWriteResult[];
|
|
208
|
+
understandingCount: number;
|
|
209
|
+
techniqueBodyCount: number;
|
|
210
|
+
uniqueBodyCount: number;
|
|
211
|
+
requestCount: number;
|
|
212
|
+
failures: FailedDocumentFetch[];
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Fetches every Understanding document and technique/failure body for both pinned WCAG
|
|
216
|
+
* versions, converts each to Markdown, and writes the deduplicated generated artifacts.
|
|
217
|
+
* Run after `runWcagDataSync`, which writes the criteria and technique indexes this step
|
|
218
|
+
* reads to build its request list. Concurrency stays low by default so the sync does not
|
|
219
|
+
* open many connections to w3.org at once. A document that still fails after every retry
|
|
220
|
+
* is reported in the result's `failures` list rather than aborting the whole sync, so a
|
|
221
|
+
* transient failure on one page does not cost the rest of the corpus.
|
|
222
|
+
*/
|
|
223
|
+
declare function syncDocumentArtifacts(options?: {
|
|
224
|
+
directories?: WcagDataDirectories;
|
|
225
|
+
fetchImpl?: FetchLike;
|
|
226
|
+
syncedAt?: string;
|
|
227
|
+
concurrency?: number;
|
|
228
|
+
paceMs?: number;
|
|
229
|
+
understandingMode?: DocumentExtractMode;
|
|
230
|
+
}): Promise<SyncDocumentArtifactsResult>;
|
|
231
|
+
|
|
232
|
+
interface MobileGuidanceFetchFailure {
|
|
233
|
+
criterionId: string;
|
|
234
|
+
url: string;
|
|
235
|
+
message: string;
|
|
236
|
+
}
|
|
237
|
+
interface SyncMobileGuidanceResult {
|
|
238
|
+
generated: GeneratedArtifactWriteResult;
|
|
239
|
+
requestCount: number;
|
|
240
|
+
guidanceCount: number;
|
|
241
|
+
placeholderCount: number;
|
|
242
|
+
failures: MobileGuidanceFetchFailure[];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Fetches WCAG2Mobile's per-criterion guidance and writes it as one generated artifact.
|
|
246
|
+
* Run after `runWcagDataSync`, which writes the criteria artifacts this step reads to
|
|
247
|
+
* build its request list. Fresh entries are merged onto whatever is already committed, so
|
|
248
|
+
* a run that fails partway only ever adds to the data instead of shrinking it.
|
|
249
|
+
*/
|
|
250
|
+
declare function syncMobileGuidance(options?: {
|
|
251
|
+
directories?: WcagDataDirectories;
|
|
252
|
+
fetchImpl?: FetchLike;
|
|
253
|
+
syncedAt?: string;
|
|
254
|
+
concurrency?: number;
|
|
255
|
+
}): Promise<SyncMobileGuidanceResult>;
|
|
256
|
+
|
|
257
|
+
interface ApgFetchFailure {
|
|
258
|
+
/** The example whose source did not arrive, or the pattern whose page did not. */
|
|
259
|
+
exampleId?: string;
|
|
260
|
+
patternId?: string;
|
|
261
|
+
url: string;
|
|
262
|
+
message: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
interface SyncApgPatternsResult {
|
|
266
|
+
generated: GeneratedArtifactWriteResult;
|
|
267
|
+
requestCount: number;
|
|
268
|
+
patternCount: number;
|
|
269
|
+
exampleCount: number;
|
|
270
|
+
keyboardRowCount: number;
|
|
271
|
+
attributeRowCount: number;
|
|
272
|
+
/** Examples the APG documents with prose and no tables, such as the landmark examples. */
|
|
273
|
+
tablelessExampleCount: number;
|
|
274
|
+
failures: ApgFetchFailure[];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Fetches the APG example index, the pattern index, and every example source file, and
|
|
278
|
+
* writes the keyboard and attribute tables as one generated artifact.
|
|
279
|
+
*
|
|
280
|
+
* The artifact is not scoped to a WCAG version. The APG describes ARIA patterns, which do
|
|
281
|
+
* not change between WCAG 2.1 and 2.2, so one file serves both the way
|
|
282
|
+
* `mobile-guidance.json` does.
|
|
283
|
+
*/
|
|
284
|
+
declare function syncApgPatterns(options?: {
|
|
285
|
+
directories?: WcagDataDirectories;
|
|
286
|
+
fetchImpl?: FetchLike;
|
|
287
|
+
concurrency?: number;
|
|
288
|
+
}): Promise<SyncApgPatternsResult>;
|
|
289
|
+
|
|
290
|
+
/** Validates that the raw synced WCAG sources are present and structurally sound. */
|
|
291
|
+
declare function validateRawSyncState(directories?: WcagDataDirectories): Promise<RawArtifactWriteResult[]>;
|
|
292
|
+
|
|
293
|
+
/** Validates that the generated WCAG artifacts are present and internally consistent. */
|
|
294
|
+
declare function validateGeneratedArtifacts(directories?: WcagDataDirectories): Promise<GeneratedArtifactWriteResult[]>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Validates the Understanding documents and technique bodies: every stored document has a
|
|
298
|
+
* non-empty title, url, and status (enforced by the schema), and every `bodyHash`
|
|
299
|
+
* resolves to a non-empty body in the shared content store.
|
|
300
|
+
*/
|
|
301
|
+
declare function validateDocumentArtifacts(directories?: WcagDataDirectories): Promise<GeneratedArtifactWriteResult[]>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Validates the WCAG2Mobile artifact: it parses against the schema, every entry is filed
|
|
305
|
+
* under its own criterion id, and an entry the document says it has written carries the
|
|
306
|
+
* guidance text to prove it.
|
|
307
|
+
*/
|
|
308
|
+
declare function validateMobileGuidanceArtifact(directories?: WcagDataDirectories): Promise<GeneratedArtifactWriteResult>;
|
|
309
|
+
|
|
310
|
+
interface ApgValidationResult extends GeneratedArtifactWriteResult {
|
|
311
|
+
patternCount: number;
|
|
312
|
+
exampleCount: number;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Validates the APG artifact: it parses against the schema, every example is filed under
|
|
316
|
+
* its own id, and every pattern and index entry points at an example the artifact holds.
|
|
317
|
+
*/
|
|
318
|
+
declare function validateApgPatternsArtifact(directories?: WcagDataDirectories): Promise<ApgValidationResult>;
|
|
319
|
+
|
|
320
|
+
export { type ApgFetchFailure, type ApgValidationResult, type DerivedAxeRule, type GeneratedArtifactProvenance, type GeneratedArtifactWriteResult, type GeneratedProvenanceManifest, type NormalizedArtifactsResult, type RawArtifactWriteResult, type RawSourceProvenance, type SyncApgPatternsResult, type SyncDocumentArtifactsResult, type SyncMobileGuidanceResult, type SyncRawSourcesResult, SyncValidationError, type WcagDataDirectories, deriveAxeRuleMetadata, ensureWcagDataDirectories, generateNormalizedArtifacts, getWcagDataDirectories, listApprovedUpstreamSourceUrls, listRawSourceDefinitions, normalizeCriteriaArtifacts, runWcagDataSync, syncApgPatterns, syncDocumentArtifacts, syncMobileGuidance, syncRawSources, validateApgPatternsArtifact, validateDocumentArtifacts, validateGeneratedArtifacts, validateMobileGuidanceArtifact, validateRawSyncState };
|