New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@qualweb/earl-reporter

Package Overview
Dependencies
Maintainers
4
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qualweb/earl-reporter - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

CHANGELOG.md

8

dist/index.d.ts
/// <reference types="@qualweb/types" />
import { EvaluationReport } from '@qualweb/core';
import { Report, EarlReport, Assertion, EarlOptions } from '@qualweb/earl-reporter';
declare function generateEARLAssertions(report: Report | undefined, date?: string): Promise<Assertion[]>;
import { EarlReport, Assertion, EarlOptions, Report } from '@qualweb/earl-reporter';
declare function generateEARLAssertions(report: Report, date?: string): Array<Assertion>;
declare function generateEARLReport(reports: {
[url: string]: EvaluationReport;
}, options?: EarlOptions): Promise<{
}, options?: EarlOptions): {
[url: string]: EarlReport;
}>;
};
export { generateEARLAssertions, generateEARLReport };
//# sourceMappingURL=index.d.ts.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -17,27 +8,49 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
const act_rules_reporter_1 = __importDefault(require("./lib/act-rules.reporter"));
const wcag_techniques_reporter_1 = __importDefault(require("./lib/wcag-techniques.reporter"));
const best_practices_reporter_1 = __importDefault(require("./lib/best-practices.reporter"));
const wcagTechniques = 'wcag-techniques';
const bestPractices = 'best-practices';
function generateEARLAssertions(report, date) {
return __awaiter(this, void 0, void 0, function* () {
if (report) {
switch (report.type) {
case 'act-rules':
return yield act_rules_reporter_1.default(report, date);
case wcagTechniques:
return yield wcag_techniques_reporter_1.default(report, date);
case bestPractices:
return yield best_practices_reporter_1.default(report, date);
default:
throw new Error('Invalid report type');
var _a;
const assertions = new Array();
for (const name in report.assertions || {}) {
if (report.assertions[name]) {
const test = report.assertions[name];
if (test) {
const sources = generateSources(test);
const result = {
'@type': 'TestResult',
outcome: 'earl:' + (test.metadata.outcome !== 'warning' ? test.metadata.outcome : 'cantTell'),
source: sources,
description: test.metadata.description,
date: date !== null && date !== void 0 ? date : new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')
};
const assertion = {
'@type': 'Assertion',
test: {
'@id': (_a = test.metadata.url) !== null && _a !== void 0 ? _a : test.name,
'@type': 'TestCase',
title: test.name,
description: test.description
},
mode: 'earl:automatic',
result
};
assertions.push(assertion);
}
}
else {
throw new Error('Report is not defined');
}
});
}
return assertions;
}
exports.generateEARLAssertions = generateEARLAssertions;
function generateSources(test) {
var _a;
const sources = new Array();
for (const result of test.results || []) {
const source = {
result: {
pointer: (_a = result.elements) === null || _a === void 0 ? void 0 : _a.filter((e) => e.pointer !== undefined).map((e) => e.pointer).join(', '),
outcome: 'earl:' + (result.verdict !== 'warning' ? result.verdict : 'cantTell')
}
};
sources.push(source);
}
return sources;
}
function reportModule(module, options) {

@@ -53,4 +66,4 @@ if (!options || !options.modules) {

return !!options.modules.wcag;
case bestPractices:
return !!options.modules[bestPractices];
case 'best-practices':
return !!options.modules['best-practices'];
default:

@@ -62,77 +75,71 @@ return false;

function generateSingleEarlReport(report, options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const earlReport = {
'@context': 'https://act-rules.github.io/earl-context.json',
'@graph': new Array()
};
const assertor = {
'@id': report.system.name,
'@type': 'Software',
title: report.system.name,
description: report.system.description,
hasVersion: report.system.version,
homepage: report.system.homepage
};
const testSubject = {
'@type': 'TestSubject',
source: ((_a = report.system.url) === null || _a === void 0 ? void 0 : _a.inputUrl) || '',
assertor,
assertions: new Array()
};
if (report.system.url && report.system.url.inputUrl !== report.system.url.completeUrl) {
testSubject.redirectedTo = report.system.url.completeUrl;
}
if (report.modules['act-rules'] && reportModule('act', options)) {
testSubject.assertions = [
...testSubject.assertions,
...(yield generateEARLAssertions(report.modules['act-rules'], report.system.date))
];
}
if (report.modules[wcagTechniques] && reportModule('wcag', options)) {
testSubject.assertions = [
...testSubject.assertions,
...(yield generateEARLAssertions(report.modules[wcagTechniques], report.system.date))
];
}
if (report.modules[bestPractices] && reportModule(bestPractices, options)) {
testSubject.assertions = [
...testSubject.assertions,
...(yield generateEARLAssertions(report.modules[bestPractices], report.system.date))
];
}
earlReport['@graph'].push(lodash_clonedeep_1.default(testSubject));
return earlReport;
});
var _a, _b;
const earlReport = {
'@context': 'https://act-rules.github.io/earl-context.json',
'@graph': new Array()
};
const assertor = {
'@id': report.system.name,
'@type': 'Software',
title: report.system.name,
description: report.system.description,
hasVersion: report.system.version,
homepage: report.system.homepage
};
const testSubject = {
'@type': 'TestSubject',
source: (_b = (_a = report.system.url) === null || _a === void 0 ? void 0 : _a.inputUrl) !== null && _b !== void 0 ? _b : '',
assertor,
assertions: new Array()
};
if (report.system.url && report.system.url.inputUrl !== report.system.url.completeUrl) {
testSubject.redirectedTo = report.system.url.completeUrl;
}
if (report.modules['act-rules'] && reportModule('act', options)) {
testSubject.assertions = [
...testSubject.assertions,
...generateEARLAssertions(report.modules['act-rules'], report.system.date)
];
}
if (report.modules['wcag-techniques'] && reportModule('wcag', options)) {
testSubject.assertions = [
...testSubject.assertions,
...generateEARLAssertions(report.modules['wcag-techniques'], report.system.date)
];
}
if (report.modules['best-practices'] && reportModule('best-practices', options)) {
testSubject.assertions = [
...testSubject.assertions,
...generateEARLAssertions(report.modules['best-practices'], report.system.date)
];
}
earlReport['@graph'].push(lodash_clonedeep_1.default(testSubject));
return earlReport;
}
function generateAggregatedEarlReport(reports, options) {
return __awaiter(this, void 0, void 0, function* () {
const aggregatedReport = {
'@context': 'https://act-rules.github.io/earl-context.json',
'@graph': new Array()
};
for (const report of reports || []) {
const earlReport = yield generateSingleEarlReport(report, options);
aggregatedReport['@graph'].push(lodash_clonedeep_1.default(earlReport['@graph'][0]));
}
return aggregatedReport;
});
const aggregatedReport = {
'@context': 'https://act-rules.github.io/earl-context.json',
'@graph': new Array()
};
for (const report of reports || []) {
const earlReport = generateSingleEarlReport(report, options);
aggregatedReport['@graph'].push(lodash_clonedeep_1.default(earlReport['@graph'][0]));
}
return aggregatedReport;
}
function generateEARLReport(reports, options) {
return __awaiter(this, void 0, void 0, function* () {
const earlReports = {};
if (options && options.aggregated) {
const firstUrl = Object.keys(reports)[0];
earlReports[options.aggregatedName || firstUrl] = yield generateAggregatedEarlReport(Object.values(reports), options);
const earlReports = {};
if (options && options.aggregated) {
const firstUrl = Object.keys(reports)[0];
earlReports[options.aggregatedName || firstUrl] = generateAggregatedEarlReport(Object.values(reports), options);
}
else {
for (const url in reports || {}) {
const earlReport = generateSingleEarlReport(reports[url], options);
earlReports[url] = lodash_clonedeep_1.default(earlReport);
}
else {
for (const url in reports || {}) {
const earlReport = yield generateSingleEarlReport(reports[url], options);
earlReports[url] = lodash_clonedeep_1.default(earlReport);
}
}
return lodash_clonedeep_1.default(earlReports);
});
}
return lodash_clonedeep_1.default(earlReports);
}
exports.generateEARLReport = generateEARLReport;
//# sourceMappingURL=index.js.map
{
"name": "@qualweb/earl-reporter",
"version": "0.3.0",
"version": "0.4.0",
"description": "Qualweb earl reporter",
"main": "dist/index.js",
"types": "./dist",
"files": [
"dist/*"
],
"scripts": {

@@ -15,3 +17,3 @@ "tsc": "tsc",

"build": "npm run format && npm run lint && npm run prebuild && tsc --build",
"pub": "npm run build && npm publish"
"prepare": "npm run build"
},

@@ -23,4 +25,10 @@ "keywords": [

"normalized",
"report"
"report",
"accessibility"
],
"homepage": "https://github.com/qualweb/earl-reporter#readme",
"bugs": {
"url": "https://github.com/qualweb/earl-reporter/issues",
"email": "qualweb@fc.ul.pt"
},
"repository": {

@@ -30,21 +38,25 @@ "type": "git",

},
"engines": {
"node": ">=12.0.0"
},
"author": "João Vicente",
"license": "ISC",
"devDependencies": {
"@qualweb/types": "^0.4.52",
"@qualweb/types": "^0.4.63",
"@tsconfig/recommended": "^1.0.1",
"@types/lodash.clonedeep": "^4.5.6",
"@types/node": "^14.14.14",
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"chai": "^4.2.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-sonarjs": "^0.5.0",
"@types/node": "^14.14.35",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"chai": "^4.3.4",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-sonarjs": "^0.6.0",
"esm": "^3.2.25",
"mocha": "^8.2.1",
"mocha": "^8.3.2",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"typescript": "^4.1.3"
"typedoc": "^0.20.33",
"typescript": "^4.2.3"
},

@@ -51,0 +63,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc