@qualweb/earl-reporter 0.4.3 → 0.4.6

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- /// <reference types="@qualweb/types" />
2
- import { Evaluations } from '@qualweb/core';
3
- import { EarlEvaluations, Assertion, EarlOptions, Report } from '@qualweb/earl-reporter';
4
- declare function generateEARLAssertions(report: Report, date?: string): Array<Assertion>;
5
- declare function generateEARLReport(reports: Evaluations, options?: EarlOptions): EarlEvaluations;
6
- export { generateEARLAssertions, generateEARLReport };
1
+ /// <reference types="@qualweb/types" />
2
+ import { Evaluations } from '@qualweb/core';
3
+ import { EarlEvaluations, Assertion, EarlOptions, Report } from '@qualweb/earl-reporter';
4
+ declare function generateEARLAssertions(report: Report, date?: string): Array<Assertion>;
5
+ declare function generateEARLReport(reports: Evaluations, options?: EarlOptions): EarlEvaluations;
6
+ export { generateEARLAssertions, generateEARLReport };
7
7
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,156 +1,156 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateEARLReport = exports.generateEARLAssertions = void 0;
7
- const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
8
- const constants_1 = require("./constants");
9
- function generateEARLAssertions(report, date) {
10
- var _a;
11
- const assertions = new Array();
12
- for (const name in report.assertions || {}) {
13
- if (report.assertions[name]) {
14
- const test = report.assertions[name];
15
- if (test) {
16
- const sources = generateSources(test);
17
- const sCriterias = test.metadata['success-criteria'];
18
- const isPartOf = convertSC(sCriterias);
19
- const result = {
20
- '@type': 'TestResult',
21
- outcome: 'earl:' + (test.metadata.outcome !== 'warning' ? test.metadata.outcome : 'cantTell'),
22
- source: sources,
23
- description: test.metadata.description,
24
- date: date !== null && date !== void 0 ? date : new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')
25
- };
26
- const assertion = {
27
- '@type': 'Assertion',
28
- test: {
29
- '@id': (_a = test.metadata.url) !== null && _a !== void 0 ? _a : test.name,
30
- '@type': 'TestCase',
31
- title: test.name,
32
- description: test.description,
33
- isPartOf
34
- },
35
- mode: 'earl:automatic',
36
- result
37
- };
38
- assertions.push(assertion);
39
- }
40
- }
41
- }
42
- return assertions;
43
- }
44
- exports.generateEARLAssertions = generateEARLAssertions;
45
- function convertSC(scList) {
46
- if (scList)
47
- return scList.map((sc) => {
48
- var _a;
49
- const name = sc.name;
50
- return (_a = constants_1.SC[name]) === null || _a === void 0 ? void 0 : _a.scId;
51
- });
52
- else
53
- return [];
54
- }
55
- function generateSources(test) {
56
- var _a;
57
- const sources = new Array();
58
- for (const result of test.results || []) {
59
- const source = {
60
- result: {
61
- pointer: (_a = result.elements) === null || _a === void 0 ? void 0 : _a.filter((e) => e.pointer !== undefined).map((e) => e.pointer).join(', '),
62
- outcome: 'earl:' + (result.verdict !== 'warning' ? result.verdict : 'cantTell')
63
- }
64
- };
65
- sources.push(source);
66
- }
67
- return sources;
68
- }
69
- function reportModule(module, options) {
70
- if (!options || !options.modules) {
71
- return true;
72
- }
73
- else {
74
- switch (module) {
75
- case 'act':
76
- return !!options.modules.act;
77
- case 'wcag':
78
- return !!options.modules.wcag;
79
- case 'best-practices':
80
- return !!options.modules['best-practices'];
81
- default:
82
- return false;
83
- }
84
- }
85
- }
86
- function generateSingleEarlReport(report, options) {
87
- var _a, _b;
88
- const earlReport = {
89
- '@context': 'https://act-rules.github.io/earl-context.json',
90
- '@graph': new Array()
91
- };
92
- const assertor = {
93
- '@id': report.system.name,
94
- '@type': 'Software',
95
- title: report.system.name,
96
- description: report.system.description,
97
- hasVersion: report.system.version,
98
- homepage: report.system.homepage
99
- };
100
- const testSubject = {
101
- '@type': 'TestSubject',
102
- source: (_b = (_a = report.system.url) === null || _a === void 0 ? void 0 : _a.inputUrl) !== null && _b !== void 0 ? _b : '',
103
- assertor,
104
- assertions: new Array()
105
- };
106
- if (report.system.url && report.system.url.inputUrl !== report.system.url.completeUrl) {
107
- testSubject.redirectedTo = report.system.url.completeUrl;
108
- }
109
- if (report.modules['act-rules'] && reportModule('act', options)) {
110
- testSubject.assertions = [
111
- ...testSubject.assertions,
112
- ...generateEARLAssertions(report.modules['act-rules'], report.system.date)
113
- ];
114
- }
115
- if (report.modules['wcag-techniques'] && reportModule('wcag', options)) {
116
- testSubject.assertions = [
117
- ...testSubject.assertions,
118
- ...generateEARLAssertions(report.modules['wcag-techniques'], report.system.date)
119
- ];
120
- }
121
- if (report.modules['best-practices'] && reportModule('best-practices', options)) {
122
- testSubject.assertions = [
123
- ...testSubject.assertions,
124
- ...generateEARLAssertions(report.modules['best-practices'], report.system.date)
125
- ];
126
- }
127
- earlReport['@graph'].push(lodash_clonedeep_1.default(testSubject));
128
- return earlReport;
129
- }
130
- function generateAggregatedEarlReport(reports, options) {
131
- const aggregatedReport = {
132
- '@context': 'https://act-rules.github.io/earl-context.json',
133
- '@graph': new Array()
134
- };
135
- for (const report of reports || []) {
136
- const earlReport = generateSingleEarlReport(report, options);
137
- aggregatedReport['@graph'].push(lodash_clonedeep_1.default(earlReport['@graph'][0]));
138
- }
139
- return aggregatedReport;
140
- }
141
- function generateEARLReport(reports, options) {
142
- const earlReports = {};
143
- if (options && options.aggregated) {
144
- const firstUrl = Object.keys(reports)[0];
145
- earlReports[options.aggregatedName || firstUrl] = generateAggregatedEarlReport(Object.values(reports), options);
146
- }
147
- else {
148
- for (const url in reports || {}) {
149
- const earlReport = generateSingleEarlReport(reports[url], options);
150
- earlReports[url] = lodash_clonedeep_1.default(earlReport);
151
- }
152
- }
153
- return lodash_clonedeep_1.default(earlReports);
154
- }
155
- exports.generateEARLReport = generateEARLReport;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateEARLReport = exports.generateEARLAssertions = void 0;
7
+ const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
8
+ const constants_1 = require("./constants");
9
+ function generateEARLAssertions(report, date) {
10
+ var _a;
11
+ const assertions = new Array();
12
+ for (const name in report.assertions || {}) {
13
+ if (report.assertions[name]) {
14
+ const test = report.assertions[name];
15
+ if (test) {
16
+ const sources = generateSources(test);
17
+ const sCriterias = test.metadata['success-criteria'];
18
+ const isPartOf = convertSC(sCriterias);
19
+ const result = {
20
+ '@type': 'TestResult',
21
+ outcome: 'earl:' + (test.metadata.outcome !== 'warning' ? test.metadata.outcome : 'cantTell'),
22
+ source: sources,
23
+ description: test.metadata.description,
24
+ date: date !== null && date !== void 0 ? date : new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')
25
+ };
26
+ const assertion = {
27
+ '@type': 'Assertion',
28
+ test: {
29
+ '@id': (_a = test.metadata.url) !== null && _a !== void 0 ? _a : test.name,
30
+ '@type': 'TestCase',
31
+ title: test.name,
32
+ description: test.description,
33
+ isPartOf
34
+ },
35
+ mode: 'earl:automatic',
36
+ result
37
+ };
38
+ assertions.push(assertion);
39
+ }
40
+ }
41
+ }
42
+ return assertions;
43
+ }
44
+ exports.generateEARLAssertions = generateEARLAssertions;
45
+ function convertSC(scList) {
46
+ if (scList)
47
+ return scList.map((sc) => {
48
+ var _a;
49
+ const name = sc.name;
50
+ return (_a = constants_1.SC[name]) === null || _a === void 0 ? void 0 : _a.scId;
51
+ });
52
+ else
53
+ return [];
54
+ }
55
+ function generateSources(test) {
56
+ var _a;
57
+ const sources = new Array();
58
+ for (const result of test.results || []) {
59
+ const source = {
60
+ result: {
61
+ pointer: (_a = result.elements) === null || _a === void 0 ? void 0 : _a.filter((e) => e.pointer !== undefined).map((e) => e.pointer).join(', '),
62
+ outcome: 'earl:' + (result.verdict !== 'warning' ? result.verdict : 'cantTell')
63
+ }
64
+ };
65
+ sources.push(source);
66
+ }
67
+ return sources;
68
+ }
69
+ function reportModule(module, options) {
70
+ if (!options || !options.modules) {
71
+ return true;
72
+ }
73
+ else {
74
+ switch (module) {
75
+ case 'act':
76
+ return !!options.modules.act;
77
+ case 'wcag':
78
+ return !!options.modules.wcag;
79
+ case 'best-practices':
80
+ return !!options.modules['best-practices'];
81
+ default:
82
+ return false;
83
+ }
84
+ }
85
+ }
86
+ function generateSingleEarlReport(report, options) {
87
+ var _a, _b;
88
+ const earlReport = {
89
+ '@context': 'https://act-rules.github.io/earl-context.json',
90
+ '@graph': new Array()
91
+ };
92
+ const assertor = {
93
+ '@id': report.system.name,
94
+ '@type': 'Software',
95
+ title: report.system.name,
96
+ description: report.system.description,
97
+ hasVersion: report.system.version,
98
+ homepage: report.system.homepage
99
+ };
100
+ const testSubject = {
101
+ '@type': 'TestSubject',
102
+ source: (_b = (_a = report.system.url) === null || _a === void 0 ? void 0 : _a.inputUrl) !== null && _b !== void 0 ? _b : '',
103
+ assertor,
104
+ assertions: new Array()
105
+ };
106
+ if (report.system.url && report.system.url.inputUrl !== report.system.url.completeUrl) {
107
+ testSubject.redirectedTo = report.system.url.completeUrl;
108
+ }
109
+ if (report.modules['act-rules'] && reportModule('act', options)) {
110
+ testSubject.assertions = [
111
+ ...testSubject.assertions,
112
+ ...generateEARLAssertions(report.modules['act-rules'], report.system.date)
113
+ ];
114
+ }
115
+ if (report.modules['wcag-techniques'] && reportModule('wcag', options)) {
116
+ testSubject.assertions = [
117
+ ...testSubject.assertions,
118
+ ...generateEARLAssertions(report.modules['wcag-techniques'], report.system.date)
119
+ ];
120
+ }
121
+ if (report.modules['best-practices'] && reportModule('best-practices', options)) {
122
+ testSubject.assertions = [
123
+ ...testSubject.assertions,
124
+ ...generateEARLAssertions(report.modules['best-practices'], report.system.date)
125
+ ];
126
+ }
127
+ earlReport['@graph'].push(lodash_clonedeep_1.default(testSubject));
128
+ return earlReport;
129
+ }
130
+ function generateAggregatedEarlReport(reports, options) {
131
+ const aggregatedReport = {
132
+ '@context': 'https://act-rules.github.io/earl-context.json',
133
+ '@graph': new Array()
134
+ };
135
+ for (const report of reports || []) {
136
+ const earlReport = generateSingleEarlReport(report, options);
137
+ aggregatedReport['@graph'].push(lodash_clonedeep_1.default(earlReport['@graph'][0]));
138
+ }
139
+ return aggregatedReport;
140
+ }
141
+ function generateEARLReport(reports, options) {
142
+ const earlReports = {};
143
+ if (options && options.aggregated) {
144
+ const firstUrl = Object.keys(reports)[0];
145
+ earlReports[options.aggregatedName || firstUrl] = generateAggregatedEarlReport(Object.values(reports), options);
146
+ }
147
+ else {
148
+ for (const url in reports || {}) {
149
+ const earlReport = generateSingleEarlReport(reports[url], options);
150
+ earlReports[url] = lodash_clonedeep_1.default(earlReport);
151
+ }
152
+ }
153
+ return lodash_clonedeep_1.default(earlReports);
154
+ }
155
+ exports.generateEARLReport = generateEARLReport;
156
156
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,63 +1,58 @@
1
- {
2
- "name": "@qualweb/earl-reporter",
3
- "version": "0.4.3",
4
- "description": "Qualweb earl reporter",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/*"
8
- ],
9
- "scripts": {
10
- "tsc": "tsc",
11
- "test": "mocha --require esm",
12
- "prebuild": "rimraf dist",
13
- "lint": "eslint src --ext .ts",
14
- "lint:fix": "eslint src --ext .ts --fix",
15
- "format": "prettier --config .prettierrc 'src/**/*.ts' --write",
16
- "build": "npm run prebuild && tsc --build",
17
- "prepare": "npm run build"
18
- },
19
- "keywords": [
20
- "earl",
21
- "json-ld",
22
- "a11y",
23
- "normalized",
24
- "report",
25
- "accessibility"
26
- ],
27
- "homepage": "https://github.com/qualweb/earl-reporter#readme",
28
- "bugs": {
29
- "url": "https://github.com/qualweb/earl-reporter/issues",
30
- "email": "qualweb@fc.ul.pt"
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/qualweb/earl-reporter.git"
35
- },
36
- "engines": {
37
- "node": ">=12.0.0"
38
- },
39
- "author": "João Vicente",
40
- "license": "ISC",
41
- "devDependencies": {
42
- "@qualweb/types": "^0.7.18",
43
- "@tsconfig/recommended": "^1.0.1",
44
- "@types/lodash.clonedeep": "^4.5.6",
45
- "@types/node": "^14.14.35",
46
- "@typescript-eslint/eslint-plugin": "^4.19.0",
47
- "@typescript-eslint/parser": "^4.19.0",
48
- "chai": "^4.3.4",
49
- "eslint": "^7.22.0",
50
- "eslint-config-prettier": "^8.1.0",
51
- "eslint-plugin-prettier": "^3.3.1",
52
- "eslint-plugin-sonarjs": "^0.6.0",
53
- "esm": "^3.2.25",
54
- "mocha": "^8.3.2",
55
- "prettier": "^2.2.1",
56
- "rimraf": "^3.0.2",
57
- "typedoc": "^0.20.33",
58
- "typescript": "^4.2.3"
59
- },
60
- "dependencies": {
61
- "lodash.clonedeep": "^4.5.0"
62
- }
63
- }
1
+ {
2
+ "name": "@qualweb/earl-reporter",
3
+ "version": "0.4.6",
4
+ "description": "Qualweb earl reporter",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/*"
8
+ ],
9
+ "scripts": {
10
+ "tsc": "tsc",
11
+ "test": "mocha --require esm",
12
+ "prebuild": "rimraf dist",
13
+ "lint": "eslint src --ext .ts",
14
+ "lint:fix": "eslint src --ext .ts --fix",
15
+ "format": "prettier src/**/*.ts --write",
16
+ "build": "npm run prebuild && tsc --build",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "keywords": [
20
+ "earl",
21
+ "json-ld",
22
+ "a11y",
23
+ "normalized",
24
+ "report",
25
+ "accessibility"
26
+ ],
27
+ "homepage": "https://github.com/qualweb/earl-reporter#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/qualweb/earl-reporter/issues",
30
+ "email": "qualweb@fc.ul.pt"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/qualweb/earl-reporter.git"
35
+ },
36
+ "engines": {
37
+ "node": ">=12.0.0"
38
+ },
39
+ "author": "João Vicente",
40
+ "license": "ISC",
41
+ "devDependencies": {
42
+ "@qualweb/types": "0.7.25",
43
+ "@tsconfig/recommended": "^1.0.3",
44
+ "@types/lodash.clonedeep": "^4.5.9",
45
+ "@types/node": "^14.14.35",
46
+ "chai": "^5.0.0",
47
+ "eslint": "^8.56.0",
48
+ "esm": "^3.2.25",
49
+ "mocha": "^10.2.0",
50
+ "prettier": "^3.1.1",
51
+ "rimraf": "^5.0.5",
52
+ "typedoc": "^0.25.6",
53
+ "typescript": "^4.2.3"
54
+ },
55
+ "dependencies": {
56
+ "lodash.clonedeep": "^4.5.0"
57
+ }
58
+ }
package/LICENSE DELETED
@@ -1,15 +0,0 @@
1
- ISC License
2
-
3
- Copyright (c) 2021, FCUL
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.