@a11ied/earl 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/README.md +7 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +60 -0
- package/package.json +42 -1
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hypothesi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @a11ied/earl
|
|
2
|
+
|
|
3
|
+
W3C EARL 1.0 reports as JSON-LD.
|
|
4
|
+
|
|
5
|
+
## internal package
|
|
6
|
+
|
|
7
|
+
This is an internal package of [`a11ied`](https://www.npmjs.com/package/a11ied). It is published because `a11ied` depends on it, and its API can change in any release. Install `a11ied` instead.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EarlAssertionInput, EarlAssertor, EarlReport, EarlAssertion } from '@a11ied/contracts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The JSON-LD context the W3C ACT report reader expects. It binds `earl:`, `WCAG2:`,
|
|
5
|
+
* `sch:`, and `doap:` so the report's short property names resolve.
|
|
6
|
+
*/
|
|
7
|
+
declare const ACT_EARL_CONTEXT_URL = "https://www.w3.org/WAI/content-assets/wcag-act-rules/earl-context.json";
|
|
8
|
+
interface BuildEarlReportInput {
|
|
9
|
+
assertions: EarlAssertionInput[];
|
|
10
|
+
assertor: EarlAssertor;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Builds an EARL 1.0 report as JSON-LD.
|
|
14
|
+
*
|
|
15
|
+
* The graph is a flat list of assertions, each carrying its own `subject` and
|
|
16
|
+
* `assertedBy`. That is the layout of every report the W3C has accepted, including
|
|
17
|
+
* axe-core's. Grouping assertions under a `TestSubject` is legal JSON-LD but no accepted
|
|
18
|
+
* report uses it.
|
|
19
|
+
*/
|
|
20
|
+
declare function buildEarlReport(input: BuildEarlReportInput): EarlReport;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The prefix the ACT EARL context binds to `http://www.w3.org/TR/WCAG21/#`, so
|
|
24
|
+
* `WCAG2:non-text-content` resolves to the success criterion's own section.
|
|
25
|
+
*/
|
|
26
|
+
declare const WCAG2_PREFIX = "WCAG2:";
|
|
27
|
+
/**
|
|
28
|
+
* Turns one result into an EARL assertion. An input with no `procedure` becomes an
|
|
29
|
+
* assertion with no `test`, which is how a report says it ran nothing applicable to the
|
|
30
|
+
* subject.
|
|
31
|
+
*/
|
|
32
|
+
declare function toEarlAssertion(input: EarlAssertionInput, assertor: EarlAssertor): EarlAssertion;
|
|
33
|
+
|
|
34
|
+
export { ACT_EARL_CONTEXT_URL, type BuildEarlReportInput, WCAG2_PREFIX, buildEarlReport, toEarlAssertion };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/report.ts
|
|
2
|
+
import {
|
|
3
|
+
earlReportSchema
|
|
4
|
+
} from "@a11ied/contracts";
|
|
5
|
+
|
|
6
|
+
// src/assertion.ts
|
|
7
|
+
var WCAG2_PREFIX = "WCAG2:";
|
|
8
|
+
function buildSubjectType() {
|
|
9
|
+
return ["earl:TestSubject", "sch:WebPage"];
|
|
10
|
+
}
|
|
11
|
+
function buildTest(input) {
|
|
12
|
+
const { procedure } = input;
|
|
13
|
+
if (!procedure) {
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
"@type": "TestCase",
|
|
18
|
+
title: procedure.title,
|
|
19
|
+
...procedure.url === void 0 ? {} : { "@id": procedure.url },
|
|
20
|
+
...procedure.criterionSlugs === void 0 ? {} : {
|
|
21
|
+
isPartOf: procedure.criterionSlugs.map((slug) => `${WCAG2_PREFIX}${slug}`)
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function buildResult(input) {
|
|
26
|
+
return {
|
|
27
|
+
"@type": "TestResult",
|
|
28
|
+
outcome: `earl:${input.outcome}`,
|
|
29
|
+
...input.pointer === void 0 ? {} : { pointer: input.pointer },
|
|
30
|
+
...input.info === void 0 ? {} : { info: input.info }
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function toEarlAssertion(input, assertor) {
|
|
34
|
+
const test = buildTest(input);
|
|
35
|
+
return {
|
|
36
|
+
"@type": "Assertion",
|
|
37
|
+
...input.mode === void 0 ? {} : { mode: `earl:${input.mode}` },
|
|
38
|
+
subject: { "@type": buildSubjectType(), source: input.subject },
|
|
39
|
+
assertedBy: assertor.url,
|
|
40
|
+
result: buildResult(input),
|
|
41
|
+
...test === void 0 ? {} : { test }
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/report.ts
|
|
46
|
+
var ACT_EARL_CONTEXT_URL = "https://www.w3.org/WAI/content-assets/wcag-act-rules/earl-context.json";
|
|
47
|
+
function buildEarlReport(input) {
|
|
48
|
+
return earlReportSchema.parse({
|
|
49
|
+
"@context": ACT_EARL_CONTEXT_URL,
|
|
50
|
+
"@graph": input.assertions.map(
|
|
51
|
+
(assertion) => toEarlAssertion(assertion, input.assertor)
|
|
52
|
+
)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
ACT_EARL_CONTEXT_URL,
|
|
57
|
+
WCAG2_PREFIX,
|
|
58
|
+
buildEarlReport,
|
|
59
|
+
toEarlAssertion
|
|
60
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +1,42 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@a11ied/earl",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "W3C EARL 1.0 reports as JSON-LD. Internal package of a11ied, published because the a1 CLI depends on it. Its API can change in any release; install a11ied instead.",
|
|
5
|
+
"homepage": "https://github.com/hypothesi/a11ied/tree/master/packages/earl#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/hypothesi/a11ied/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/hypothesi/a11ied.git",
|
|
13
|
+
"directory": "packages/earl"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"CHANGELOG.md"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
33
|
+
"prepack": "npm run build",
|
|
34
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@a11ied/contracts": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=24"
|
|
41
|
+
}
|
|
42
|
+
}
|