-
Notifications
You must be signed in to change notification settings - Fork 12
/
earl.ts
69 lines (61 loc) · 1.89 KB
/
earl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { Serializable, EARL } from "@siteimprove/alfa-earl";
import { Formatter } from "@siteimprove/alfa-formatter";
import { version } from "../package.json";
const { stringify } = JSON;
/**
* @public
*/
export default function <I, T, Q, S>(): Formatter<I, T, Q, S> {
return function EARL(input, rules, outcomes) {
const subject = Serializable.toEARL(input);
const assertor: EARL = {
"@context": {
earl: "http://www.w3.org/ns/earl#",
doap: "http://usefulinc.com/ns/doap#",
foaf: "http://xmlns.com/foaf/spec/#",
},
"@id": "https://alfa.siteimprove.com/",
"@type": ["earl:Assertor", "earl:Software", "doap:Project"],
"doap:name": "Alfa",
"doap:homepage": "https://alfa.siteimprove.com/",
"doap:release": {
"@type": "doap:Version",
"doap:revision": version,
},
"doap:license": "https://spdx.org/licenses/MIT",
"doap:description":
"Suite of open and standards-based tools for performing reliable accessibility conformance testing at scale",
"doap:repository": {
"@type": "doap:GitRepository",
"doap:browse": "https://github.com/siteimprove/alfa",
"doap:location": "https://github.com/siteimprove/alfa.git",
},
"doap:vendor": {
"@id": "https://siteimprove.com/",
"@type": "foaf:Organization",
"foaf:name": "Siteimprove A/S",
},
};
return stringify(
[
assertor,
...subject,
...[...rules].map((rule) => rule.toEARL()),
...[...outcomes].map((outcome) => {
const earl = outcome.toEARL();
for (const _ of subject) {
earl["earl:assertedBy"] = {
"@id": assertor["@id"],
};
earl["earl:subject"] = {
"@id": _["@id"],
};
}
return earl;
}),
],
null,
2
);
};
}