@@ -6,7 +6,7 @@ import { readFile } from "fs/promises";
6
6
import { basename } from "path" ;
7
7
8
8
import { flattenDomFromFile , load } from "./cheerio" ;
9
- import { generateId } from "./common" ;
9
+ import { generateId , resolveDecimalVersion } from "./common" ;
10
10
11
11
export type WcagVersion = "20" | "21" | "22" ;
12
12
export function assertIsWcagVersion ( v : string ) : asserts v is WcagVersion {
@@ -29,10 +29,9 @@ type ActMapping = {
29
29
"act-rules" : ActRule [ ] ;
30
30
} ;
31
31
32
- /** Data used for test-rules sections, from act-mapping.json */
33
- export const actRules = (
34
- JSON . parse ( await readFile ( "guidelines/act-mapping.json" , "utf8" ) ) as ActMapping
35
- ) [ "act-rules" ] ;
32
+ /** Retrieves act-mapping.json data for test-rules sections. */
33
+ export const getActRules = async ( ) =>
34
+ ( JSON . parse ( await readFile ( "guidelines/act-mapping.json" , "utf8" ) ) as ActMapping ) [ "act-rules" ] ;
36
35
37
36
/**
38
37
* Flattened object hash, mapping each WCAG 2 SC slug to the earliest WCAG version it applies to.
@@ -281,6 +280,16 @@ export const getAcknowledgementsForVersion = async (version: WcagVersion) => {
281
280
return subsections ;
282
281
} ;
283
282
283
+ /**
284
+ * Retrieves act-mapping.json data for test-rules sections, pinned to an earlier WCAG version.
285
+ */
286
+ export const getActRulesForVersion = async ( version : WcagVersion ) =>
287
+ (
288
+ await axios . get < ActMapping > (
289
+ `https://raw.githubusercontent.com/w3c/wcag/refs/heads/WCAG-${ resolveDecimalVersion ( version ) } /guidelines/act-mapping.json`
290
+ )
291
+ ) . data [ "act-rules" ] ;
292
+
284
293
/**
285
294
* Retrieves and processes a pinned WCAG version using published guidelines.
286
295
*/
0 commit comments