accessibility-checker 4.0.1 → 4.0.2

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.
Files changed (209) hide show
  1. package/bin/achecker.js +213 -262
  2. package/bin/achecker.js.map +1 -1
  3. package/cjs/bin/achecker.d.ts +2 -0
  4. package/cjs/bin/achecker.js +306 -0
  5. package/cjs/bin/achecker.js.map +1 -0
  6. package/cjs/index.d.ts +319 -0
  7. package/cjs/index.js +402 -0
  8. package/cjs/index.js.map +1 -0
  9. package/cjs/lib/ACBrowserManager.d.ts +22 -0
  10. package/cjs/lib/ACBrowserManager.js +172 -0
  11. package/cjs/lib/ACBrowserManager.js.map +1 -0
  12. package/cjs/lib/ACEngineManager.d.ts +19 -0
  13. package/cjs/lib/ACEngineManager.js +457 -0
  14. package/cjs/lib/ACEngineManager.js.map +1 -0
  15. package/cjs/lib/ACHelper.d.ts +2 -0
  16. package/cjs/lib/ACHelper.js +678 -0
  17. package/cjs/lib/ACHelper.js.map +1 -0
  18. package/cjs/lib/api/IChecker.d.ts +28 -0
  19. package/cjs/lib/api/IChecker.js +11 -0
  20. package/cjs/lib/api/IChecker.js.map +1 -0
  21. package/cjs/lib/api/IMapper.d.ts +37 -0
  22. package/cjs/lib/api/IMapper.js +18 -0
  23. package/cjs/lib/api/IMapper.js.map +1 -0
  24. package/cjs/lib/common/api-ext/Fetch.d.ts +17 -0
  25. package/cjs/lib/common/api-ext/Fetch.js +95 -0
  26. package/cjs/lib/common/api-ext/Fetch.js.map +1 -0
  27. package/cjs/lib/common/api-ext/IAbstractAPI.d.ts +33 -0
  28. package/cjs/lib/common/api-ext/IAbstractAPI.js +18 -0
  29. package/cjs/lib/common/api-ext/IAbstractAPI.js.map +1 -0
  30. package/cjs/lib/common/config/ACConfigManager.d.ts +13 -0
  31. package/cjs/lib/common/config/ACConfigManager.js +483 -0
  32. package/cjs/lib/common/config/ACConfigManager.js.map +1 -0
  33. package/cjs/lib/common/config/ACConstants.d.ts +17 -0
  34. package/cjs/lib/common/config/ACConstants.js +111 -0
  35. package/cjs/lib/common/config/ACConstants.js.map +1 -0
  36. package/cjs/lib/common/config/IArchive.d.ts +37 -0
  37. package/cjs/lib/common/config/IArchive.js +18 -0
  38. package/cjs/lib/common/config/IArchive.js.map +1 -0
  39. package/cjs/lib/common/config/IConfig.d.ts +152 -0
  40. package/cjs/lib/common/config/IConfig.js +36 -0
  41. package/cjs/lib/common/config/IConfig.js.map +1 -0
  42. package/cjs/lib/common/engine/IBounds.d.ts +21 -0
  43. package/cjs/lib/common/engine/IBounds.js +18 -0
  44. package/cjs/lib/common/engine/IBounds.js.map +1 -0
  45. package/cjs/lib/common/engine/IChecker.d.ts +23 -0
  46. package/cjs/lib/common/engine/IChecker.js +18 -0
  47. package/cjs/lib/common/engine/IChecker.js.map +1 -0
  48. package/cjs/lib/common/engine/IEngine.d.ts +39 -0
  49. package/cjs/lib/common/engine/IEngine.js +18 -0
  50. package/cjs/lib/common/engine/IEngine.js.map +1 -0
  51. package/cjs/lib/common/engine/IGuideline.d.ts +53 -0
  52. package/cjs/lib/common/engine/IGuideline.js +37 -0
  53. package/cjs/lib/common/engine/IGuideline.js.map +1 -0
  54. package/cjs/lib/common/engine/IMapper.d.ts +32 -0
  55. package/cjs/lib/common/engine/IMapper.js +18 -0
  56. package/cjs/lib/common/engine/IMapper.js.map +1 -0
  57. package/cjs/lib/common/engine/IReport.d.ts +143 -0
  58. package/cjs/lib/common/engine/IReport.js +44 -0
  59. package/cjs/lib/common/engine/IReport.js.map +1 -0
  60. package/cjs/lib/common/engine/IRule.d.ts +100 -0
  61. package/cjs/lib/common/engine/IRule.js +87 -0
  62. package/cjs/lib/common/engine/IRule.js.map +1 -0
  63. package/cjs/lib/common/engine/IRuleset.d.ts +20 -0
  64. package/cjs/lib/common/engine/IRuleset.js +18 -0
  65. package/cjs/lib/common/engine/IRuleset.js.map +1 -0
  66. package/cjs/lib/common/report/ACReporterCSV.d.ts +28 -0
  67. package/cjs/lib/common/report/ACReporterCSV.js +75 -0
  68. package/cjs/lib/common/report/ACReporterCSV.js.map +1 -0
  69. package/cjs/lib/common/report/ACReporterHTML.d.ts +27 -0
  70. package/cjs/lib/common/report/ACReporterHTML.js +61 -0
  71. package/cjs/lib/common/report/ACReporterHTML.js.map +1 -0
  72. package/cjs/lib/common/report/ACReporterJSON.d.ts +36 -0
  73. package/cjs/lib/common/report/ACReporterJSON.js +109 -0
  74. package/cjs/lib/common/report/ACReporterJSON.js.map +1 -0
  75. package/cjs/lib/common/report/ACReporterMetrics.d.ts +78 -0
  76. package/cjs/lib/common/report/ACReporterMetrics.js +135 -0
  77. package/cjs/lib/common/report/ACReporterMetrics.js.map +1 -0
  78. package/cjs/lib/common/report/ACReporterXLSX.d.ts +38 -0
  79. package/cjs/lib/common/report/ACReporterXLSX.js +996 -0
  80. package/cjs/lib/common/report/ACReporterXLSX.js.map +1 -0
  81. package/cjs/lib/common/report/BaselineManager.d.ts +169 -0
  82. package/cjs/lib/common/report/BaselineManager.js +382 -0
  83. package/cjs/lib/common/report/BaselineManager.js.map +1 -0
  84. package/cjs/lib/common/report/ReporterManager.d.ts +79 -0
  85. package/cjs/lib/common/report/ReporterManager.js +469 -0
  86. package/cjs/lib/common/report/ReporterManager.js.map +1 -0
  87. package/cjs/lib/common/report/genReport.d.ts +1 -0
  88. package/cjs/lib/common/report/genReport.js +12 -0
  89. package/cjs/lib/common/report/genReport.js.map +1 -0
  90. package/cjs/package.json +3 -0
  91. package/index.js +21 -63
  92. package/index.js.map +1 -1
  93. package/lib/ACBrowserManager.js +138 -203
  94. package/lib/ACBrowserManager.js.map +1 -1
  95. package/lib/ACEngineManager.js +395 -402
  96. package/lib/ACEngineManager.js.map +1 -1
  97. package/lib/ACHelper.js +581 -642
  98. package/lib/ACHelper.js.map +1 -1
  99. package/lib/common/api-ext/Fetch.js +58 -78
  100. package/lib/common/api-ext/Fetch.js.map +1 -1
  101. package/lib/common/config/ACConfigManager.js +271 -281
  102. package/lib/common/config/ACConfigManager.js.map +1 -1
  103. package/lib/common/config/ACConstants.js +38 -4
  104. package/lib/common/config/ACConstants.js.map +1 -1
  105. package/lib/common/config/IConfig.d.ts +1 -1
  106. package/lib/common/report/ACReporterCSV.js +42 -77
  107. package/lib/common/report/ACReporterCSV.js.map +1 -1
  108. package/lib/common/report/ACReporterHTML.js +15 -48
  109. package/lib/common/report/ACReporterHTML.js.map +1 -1
  110. package/lib/common/report/ACReporterJSON.js +59 -94
  111. package/lib/common/report/ACReporterJSON.js.map +1 -1
  112. package/lib/common/report/ACReporterMetrics.js +45 -108
  113. package/lib/common/report/ACReporterMetrics.js.map +1 -1
  114. package/lib/common/report/ACReporterXLSX.js +282 -300
  115. package/lib/common/report/ACReporterXLSX.js.map +1 -1
  116. package/lib/common/report/BaselineManager.js +82 -56
  117. package/lib/common/report/BaselineManager.js.map +1 -1
  118. package/lib/common/report/ReporterManager.js +125 -190
  119. package/lib/common/report/ReporterManager.js.map +1 -1
  120. package/lib/common/report/genReport.js +2 -2
  121. package/mjs/bin/achecker.d.ts +2 -0
  122. package/mjs/bin/achecker.js +236 -0
  123. package/mjs/bin/achecker.js.map +1 -0
  124. package/mjs/index.d.ts +319 -0
  125. package/mjs/index.js +368 -0
  126. package/mjs/index.js.map +1 -0
  127. package/mjs/lib/ACBrowserManager.d.ts +22 -0
  128. package/mjs/lib/ACBrowserManager.js +121 -0
  129. package/mjs/lib/ACBrowserManager.js.map +1 -0
  130. package/mjs/lib/ACEngineManager.d.ts +19 -0
  131. package/mjs/lib/ACEngineManager.js +397 -0
  132. package/mjs/lib/ACEngineManager.js.map +1 -0
  133. package/mjs/lib/ACHelper.d.ts +2 -0
  134. package/mjs/lib/ACHelper.js +614 -0
  135. package/mjs/lib/ACHelper.js.map +1 -0
  136. package/mjs/lib/api/IChecker.d.ts +28 -0
  137. package/mjs/lib/api/IChecker.js +8 -0
  138. package/mjs/lib/api/IChecker.js.map +1 -0
  139. package/mjs/lib/api/IMapper.d.ts +37 -0
  140. package/mjs/lib/api/IMapper.js +17 -0
  141. package/mjs/lib/api/IMapper.js.map +1 -0
  142. package/mjs/lib/common/api-ext/Fetch.d.ts +17 -0
  143. package/mjs/lib/common/api-ext/Fetch.js +45 -0
  144. package/mjs/lib/common/api-ext/Fetch.js.map +1 -0
  145. package/mjs/lib/common/api-ext/IAbstractAPI.d.ts +33 -0
  146. package/mjs/lib/common/api-ext/IAbstractAPI.js +17 -0
  147. package/mjs/lib/common/api-ext/IAbstractAPI.js.map +1 -0
  148. package/mjs/lib/common/config/ACConfigManager.d.ts +13 -0
  149. package/mjs/lib/common/config/ACConfigManager.js +421 -0
  150. package/mjs/lib/common/config/ACConfigManager.js.map +1 -0
  151. package/mjs/lib/common/config/ACConstants.d.ts +17 -0
  152. package/mjs/lib/common/config/ACConstants.js +75 -0
  153. package/mjs/lib/common/config/ACConstants.js.map +1 -0
  154. package/mjs/lib/common/config/IArchive.d.ts +37 -0
  155. package/mjs/lib/common/config/IArchive.js +17 -0
  156. package/mjs/lib/common/config/IArchive.js.map +1 -0
  157. package/mjs/lib/common/config/IConfig.d.ts +152 -0
  158. package/mjs/lib/common/config/IConfig.js +33 -0
  159. package/mjs/lib/common/config/IConfig.js.map +1 -0
  160. package/mjs/lib/common/engine/IBounds.d.ts +21 -0
  161. package/mjs/lib/common/engine/IBounds.js +17 -0
  162. package/mjs/lib/common/engine/IBounds.js.map +1 -0
  163. package/mjs/lib/common/engine/IChecker.d.ts +23 -0
  164. package/mjs/lib/common/engine/IChecker.js +17 -0
  165. package/mjs/lib/common/engine/IChecker.js.map +1 -0
  166. package/mjs/lib/common/engine/IEngine.d.ts +39 -0
  167. package/mjs/lib/common/engine/IEngine.js +17 -0
  168. package/mjs/lib/common/engine/IEngine.js.map +1 -0
  169. package/mjs/lib/common/engine/IGuideline.d.ts +53 -0
  170. package/mjs/lib/common/engine/IGuideline.js +34 -0
  171. package/mjs/lib/common/engine/IGuideline.js.map +1 -0
  172. package/mjs/lib/common/engine/IMapper.d.ts +32 -0
  173. package/mjs/lib/common/engine/IMapper.js +17 -0
  174. package/mjs/lib/common/engine/IMapper.js.map +1 -0
  175. package/mjs/lib/common/engine/IReport.d.ts +143 -0
  176. package/mjs/lib/common/engine/IReport.js +36 -0
  177. package/mjs/lib/common/engine/IReport.js.map +1 -0
  178. package/mjs/lib/common/engine/IRule.d.ts +100 -0
  179. package/mjs/lib/common/engine/IRule.js +79 -0
  180. package/mjs/lib/common/engine/IRule.js.map +1 -0
  181. package/mjs/lib/common/engine/IRuleset.d.ts +20 -0
  182. package/mjs/lib/common/engine/IRuleset.js +17 -0
  183. package/mjs/lib/common/engine/IRuleset.js.map +1 -0
  184. package/mjs/lib/common/report/ACReporterCSV.d.ts +28 -0
  185. package/mjs/lib/common/report/ACReporterCSV.js +60 -0
  186. package/mjs/lib/common/report/ACReporterCSV.js.map +1 -0
  187. package/mjs/lib/common/report/ACReporterHTML.d.ts +27 -0
  188. package/mjs/lib/common/report/ACReporterHTML.js +46 -0
  189. package/mjs/lib/common/report/ACReporterHTML.js.map +1 -0
  190. package/mjs/lib/common/report/ACReporterJSON.d.ts +36 -0
  191. package/mjs/lib/common/report/ACReporterJSON.js +94 -0
  192. package/mjs/lib/common/report/ACReporterJSON.js.map +1 -0
  193. package/mjs/lib/common/report/ACReporterMetrics.d.ts +78 -0
  194. package/mjs/lib/common/report/ACReporterMetrics.js +122 -0
  195. package/mjs/lib/common/report/ACReporterMetrics.js.map +1 -0
  196. package/mjs/lib/common/report/ACReporterXLSX.d.ts +38 -0
  197. package/mjs/lib/common/report/ACReporterXLSX.js +948 -0
  198. package/mjs/lib/common/report/ACReporterXLSX.js.map +1 -0
  199. package/mjs/lib/common/report/BaselineManager.d.ts +169 -0
  200. package/mjs/lib/common/report/BaselineManager.js +348 -0
  201. package/mjs/lib/common/report/BaselineManager.js.map +1 -0
  202. package/mjs/lib/common/report/ReporterManager.d.ts +79 -0
  203. package/mjs/lib/common/report/ReporterManager.js +469 -0
  204. package/mjs/lib/common/report/ReporterManager.js.map +1 -0
  205. package/mjs/lib/common/report/genReport.d.ts +1 -0
  206. package/mjs/lib/common/report/genReport.js +9 -0
  207. package/mjs/lib/common/report/genReport.js.map +1 -0
  208. package/mjs/package.json +3 -0
  209. package/package.json +10 -4
@@ -0,0 +1,996 @@
1
+ "use strict";
2
+ /******************************************************************************
3
+ Copyright:: 2020- IBM, Inc
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ *****************************************************************************/
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
51
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
52
+ return new (P || (P = Promise))(function (resolve, reject) {
53
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
54
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
55
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
56
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
57
+ });
58
+ };
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.ACReporterXLSX = void 0;
61
+ const IConfig_js_1 = require("../config/IConfig.js");
62
+ const IGuideline_js_1 = require("../engine/IGuideline.js");
63
+ const IRule_js_1 = require("../engine/IRule.js");
64
+ const ReporterManager_js_1 = require("./ReporterManager.js");
65
+ const ExcelJS = __importStar(require("exceljs"));
66
+ function dropDupes(arr) {
67
+ let dupes = {};
68
+ return arr.filter(item => {
69
+ if (item.toString() in dupes) {
70
+ return false;
71
+ }
72
+ {
73
+ return dupes[item.toString()] = true;
74
+ }
75
+ });
76
+ }
77
+ class ACReporterXLSX {
78
+ name() {
79
+ return "xlsx";
80
+ }
81
+ generateReport(_reportData) {
82
+ }
83
+ generateSummary(config, rulesets, endReport, summaryData) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ let storedReport = ReporterManager_js_1.ReporterManager.uncompressReport(summaryData[0]);
86
+ let cfgRulesets = rulesets.filter(rs => config.policies.includes(rs.id));
87
+ let policyInfo = {};
88
+ for (const rs of cfgRulesets) {
89
+ for (const cp of rs.checkpoints) {
90
+ for (const rule of cp.rules) {
91
+ policyInfo[rule.id] = policyInfo[rule.id] || {
92
+ tkLevels: [],
93
+ cps: []
94
+ };
95
+ policyInfo[rule.id].tkLevels.push(rule.toolkitLevel);
96
+ policyInfo[rule.id].cps.push(cp);
97
+ }
98
+ }
99
+ }
100
+ for (const ruleId in policyInfo) {
101
+ policyInfo[ruleId].tkLevels = dropDupes(policyInfo[ruleId].tkLevels);
102
+ policyInfo[ruleId].tkLevels.sort();
103
+ }
104
+ // const buffer: any = await workbook.xlsx.writeBuffer();
105
+ let startScan = new Date(storedReport.engineReport.summary.startScan);
106
+ let reportFilename = `results_${startScan.toISOString().replace(/:/g, "-")}.xlsx`;
107
+ if (config.outputFilenameTimestamp === false) {
108
+ reportFilename = `results.xlsx`;
109
+ }
110
+ return {
111
+ summaryPath: reportFilename,
112
+ summary: (filename) => __awaiter(this, void 0, void 0, function* () {
113
+ // @ts-ignore
114
+ const workbook = new ExcelJS.stream.xlsx.WorkbookWriter({ filename, useStyles: true });
115
+ // const workbook = new ExcelJS.Workbook({ useStyles: true });
116
+ ACReporterXLSX.createOverviewSheet(config, summaryData, workbook);
117
+ ACReporterXLSX.createScanSummarySheet(config, summaryData, workbook);
118
+ ACReporterXLSX.createIssueSummarySheet(config, policyInfo, summaryData, workbook);
119
+ ACReporterXLSX.createIssuesSheet(config, policyInfo, summaryData, workbook);
120
+ ACReporterXLSX.createDefinitionsSheet(workbook);
121
+ workbook.commit();
122
+ })
123
+ };
124
+ });
125
+ }
126
+ static createOverviewSheet(config, compressedScans, workbook) {
127
+ let violations = 0;
128
+ let needsReviews = 0;
129
+ let recommendations = 0;
130
+ let archived = 0;
131
+ let totalIssues = 0;
132
+ let startScan = 0;
133
+ // BIG QUESTION: is report
134
+ // 1. for current scan (from menu)
135
+ // 2. all stored scans (from menu)
136
+ // 3. selected stored scans (from scan manager)
137
+ for (const compressedScan of compressedScans) {
138
+ let storedScan = ReporterManager_js_1.ReporterManager.uncompressReport(compressedScan);
139
+ if (startScan === 0)
140
+ startScan = storedScan.engineReport.summary.startScan;
141
+ const counts = storedScan.engineReport.summary.counts;
142
+ violations += counts.violation;
143
+ needsReviews += counts.potentialviolation + counts.manual;
144
+ recommendations += counts.recommendation + counts.potentialrecommendation;
145
+ archived += counts.ignored;
146
+ }
147
+ totalIssues = violations + needsReviews + recommendations + archived;
148
+ const worksheet = workbook.addWorksheet("Overview");
149
+ // Report Title
150
+ worksheet.mergeCells('A1', "E1");
151
+ const titleRow = worksheet.getRow(1);
152
+ titleRow.height = 27;
153
+ const cellA1 = worksheet.getCell('A1');
154
+ cellA1.value = "Accessibility Scan Report";
155
+ cellA1.alignment = { vertical: "middle", horizontal: "left" };
156
+ cellA1.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
157
+ cellA1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
158
+ // what are column widths - can't get it till you set it
159
+ const colWidthData = [
160
+ { col: 'A', width: 15.1 },
161
+ { col: 'B', width: 15.9 },
162
+ { col: 'C', width: 16.23 },
163
+ { col: 'D', width: 19.4 },
164
+ ];
165
+ for (let i = 0; i < 4; i++) {
166
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
167
+ }
168
+ // note except for Report Date this is the same for all scans
169
+ const rowData = [
170
+ { key1: 'Tool:', key2: 'IBM Equal Access Accessibility Checker' },
171
+ // {key1: 'Version:', key2: "chrome.runtime.getManifest().version"},
172
+ { key1: 'Version:', key2: config.toolID },
173
+ //@ts-ignore
174
+ // {key1: 'Rule set:', key2: (theCurrentScan.ruleSet === "Latest Deployment") ? archives[1].name : theCurrentScan.ruleSet },
175
+ { key1: 'Rule set:', key2: config.ruleArchiveLabel },
176
+ { key1: 'Guidelines:', key2: config.policies.join(", ") },
177
+ { key1: 'Report date:', key2: new Date(startScan).toLocaleString() }, // do we need to get actual date?
178
+ { key1: 'Scans:', key2: "" + compressedScans.length }, // *** NEED TO FIX FOR selected
179
+ // { key1: 'Pages:', key2: "" }
180
+ ];
181
+ for (let idx = 0; idx < rowData.length; ++idx) {
182
+ worksheet.mergeCells(`B${idx + 2}`, `E${idx + 2}`);
183
+ let i = idx + 2;
184
+ worksheet.getRow(i).height = 12; // results in a row height of 16
185
+ worksheet.getRow(i).getCell(1).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
186
+ worksheet.getRow(i).getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
187
+ worksheet.getRow(i).getCell(1).alignment = { horizontal: "left" };
188
+ worksheet.getRow(i).getCell(2).alignment = { horizontal: "left" };
189
+ // if (i == 7) {
190
+ // worksheet.getRow(i).getCell(1).alignment = { vertical: "top" };
191
+ // worksheet.getRow(i).getCell(2).alignment = { wrapText: true };
192
+ // }
193
+ worksheet.getRow(i).getCell(1).value = rowData[i - 2].key1;
194
+ worksheet.getRow(i).getCell(2).value = rowData[i - 2].key2;
195
+ }
196
+ // Summary Title
197
+ worksheet.mergeCells('A11', "E11");
198
+ const summaryRow = worksheet.getRow(11);
199
+ summaryRow.height = 27;
200
+ const cellA11 = worksheet.getCell('A11');
201
+ cellA11.value = "Summary";
202
+ cellA11.alignment = { vertical: "middle", horizontal: "left" };
203
+ cellA11.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
204
+ cellA11.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
205
+ // Scans info Headers
206
+ worksheet.getRow(12).height = 16; // actual height is
207
+ const cellA12 = worksheet.getCell('A12');
208
+ cellA12.value = "Total issues";
209
+ const cellB12 = worksheet.getCell('B12');
210
+ cellB12.value = "Violations";
211
+ const cellC12 = worksheet.getCell('C12');
212
+ cellC12.value = "Needs review";
213
+ const cellD12 = worksheet.getCell('D12');
214
+ cellD12.value = "Recommendations";
215
+ const cellE12 = worksheet.getCell('E12');
216
+ cellE12.value = "Archived";
217
+ const cellObjects1 = [cellA12, cellB12, cellC12, cellD12, cellE12];
218
+ for (let i = 0; i < cellObjects1.length; i++) {
219
+ cellObjects1[i].alignment = { vertical: "middle", horizontal: "center" };
220
+ if (i == 1 || i == 2 || i == 3 || i === 4) {
221
+ cellObjects1[i].font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
222
+ }
223
+ else {
224
+ cellObjects1[i].font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
225
+ }
226
+ // cellObjects1[i].fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFC65911'} };
227
+ cellObjects1[i].border = {
228
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
229
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
230
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
231
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
232
+ };
233
+ }
234
+ cellA12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
235
+ cellB12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE4AAAF' } };
236
+ cellC12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF4E08A' } };
237
+ cellD12.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF96A9D7' } };
238
+ // Scans info Values
239
+ worksheet.getRow(13).height = 27; // actual height is
240
+ const cellA13 = worksheet.getCell('A13');
241
+ cellA13.value = totalIssues;
242
+ const cellB13 = worksheet.getCell('B13');
243
+ cellB13.value = violations;
244
+ const cellC13 = worksheet.getCell('C13');
245
+ cellC13.value = needsReviews;
246
+ const cellD13 = worksheet.getCell('D13');
247
+ cellD13.value = recommendations;
248
+ const cellE13 = worksheet.getCell('E13');
249
+ cellE13.value = archived;
250
+ const cellObjects2 = [cellA13, cellB13, cellC13, cellD13, cellE13];
251
+ for (let i = 0; i < cellObjects2.length; i++) {
252
+ cellObjects2[i].alignment = { vertical: "middle", horizontal: "center" };
253
+ cellObjects2[i].font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
254
+ // cellObjects2[i].fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
255
+ cellObjects2[i].border = {
256
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
257
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
258
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
259
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
260
+ };
261
+ }
262
+ }
263
+ static createScanSummarySheet(config, compressedScans, workbook) {
264
+ const worksheet = workbook.addWorksheet("Scan summary");
265
+ // Scans info Headers
266
+ worksheet.getRow(1).height = 39; // actual height is 52
267
+ const colWidthData = [
268
+ { col: 'A', width: 27.0 },
269
+ { col: 'B', width: 46.0 },
270
+ { col: 'C', width: 20.17 },
271
+ { col: 'D', width: 18.5 },
272
+ { col: 'E', width: 17.17 },
273
+ { col: 'F', width: 17.17 },
274
+ { col: 'G', width: 17.17 },
275
+ { col: 'H', width: 17.17 },
276
+ { col: 'I', width: 17.17 },
277
+ ];
278
+ for (let i = 0; i < 9; i++) {
279
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
280
+ }
281
+ const cellA1 = worksheet.getCell('A1');
282
+ cellA1.value = "Page title";
283
+ const cellB1 = worksheet.getCell('B1');
284
+ cellB1.value = "Page url";
285
+ const cellC1 = worksheet.getCell('C1');
286
+ cellC1.value = "Scan label";
287
+ const cellObjects1 = [cellA1, cellB1, cellC1];
288
+ for (let i = 0; i < cellObjects1.length; i++) {
289
+ cellObjects1[i].alignment = { vertical: "middle", horizontal: "left" };
290
+ cellObjects1[i].font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
291
+ cellObjects1[i].fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
292
+ cellObjects1[i].border = {
293
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
294
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
295
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
296
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
297
+ };
298
+ }
299
+ const cellD1 = worksheet.getCell('D1');
300
+ cellD1.value = "Violations";
301
+ const cellE1 = worksheet.getCell('E1');
302
+ cellE1.value = "Needs review";
303
+ const cellF1 = worksheet.getCell('F1');
304
+ cellF1.value = "Recommendations";
305
+ const cellG1 = worksheet.getCell('G1');
306
+ cellG1.value = "Archived";
307
+ const cellH1 = worksheet.getCell('H1');
308
+ cellH1.value = "% elements without violations";
309
+ const cellI1 = worksheet.getCell('I1');
310
+ cellI1.value = "% elements without violations or items to review";
311
+ const cellObjects2 = [cellD1, cellE1, cellF1, cellG1, cellH1, cellI1];
312
+ for (let i = 0; i < cellObjects2.length; i++) {
313
+ cellObjects2[i].alignment = { vertical: "middle", horizontal: "center", wrapText: true };
314
+ if (i == 0 || i == 1 || i == 2 || i == 3) {
315
+ cellObjects2[i].font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
316
+ }
317
+ else {
318
+ cellObjects2[i].font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
319
+ }
320
+ // cellObjects2[i].fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFC65911'} };
321
+ cellObjects2[i].border = {
322
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
323
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
324
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
325
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
326
+ };
327
+ }
328
+ cellD1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE4AAAF' } };
329
+ cellE1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF4E08A' } };
330
+ cellF1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF96A9D7' } };
331
+ cellG1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFFFFFFF' } };
332
+ cellH1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
333
+ cellI1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
334
+ for (const compressedScan of compressedScans) {
335
+ let storedScan = ReporterManager_js_1.ReporterManager.uncompressReport(compressedScan);
336
+ let counts = storedScan.engineReport.summary.counts;
337
+ let row = worksheet.addRow([
338
+ storedScan.pageTitle,
339
+ storedScan.engineReport.summary.URL,
340
+ storedScan.label,
341
+ counts.violation,
342
+ counts.potentialviolation + counts.manual,
343
+ counts.recommendation + counts.potentialrecommendation,
344
+ counts.ignored,
345
+ (100 * (counts.elements - counts.elementsViolation) / counts.elements).toFixed(0),
346
+ (100 * (counts.elements - counts.elementsViolationReview) / counts.elements).toFixed(0),
347
+ ]);
348
+ row.height = 37; // actual height is
349
+ for (let i = 1; i < 4; i++) {
350
+ row.getCell(i).alignment = { vertical: "middle", horizontal: "left", wrapText: true };
351
+ row.getCell(i).font = { name: "Calibri", color: { argb: "00000000" }, size: 12 };
352
+ }
353
+ for (let i = 4; i < 10; i++) {
354
+ row.getCell(i).alignment = { vertical: "middle", horizontal: "center", wrapText: true };
355
+ row.getCell(i).font = { name: "Calibri", color: { argb: "00000000" }, size: 12 };
356
+ // row.getCell(i).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
357
+ row.getCell(i).border = {
358
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
359
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
360
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
361
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
362
+ };
363
+ }
364
+ row.commit();
365
+ }
366
+ worksheet.commit();
367
+ }
368
+ static buildIssueSummaryLevel(worksheet, fillColor, title, levelCount, levelrowValues) {
369
+ // Level 1 Violation title
370
+ const level1ViolationRow = worksheet.addRow(["", 0]);
371
+ level1ViolationRow.height = 18; // target is 21
372
+ const cellA6 = level1ViolationRow.getCell(1);
373
+ cellA6.value = ` ${title}`;
374
+ cellA6.alignment = { vertical: "middle", horizontal: "left" };
375
+ cellA6.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
376
+ cellA6.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: fillColor } };
377
+ level1ViolationRow.getCell(1).border = {
378
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
379
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
380
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
381
+ // right: {style:'thin', color: {argb: 'FFA6A6A6'}}
382
+ };
383
+ const cellB6 = level1ViolationRow.getCell(2);
384
+ cellB6.value = levelCount; // total level violations
385
+ cellB6.alignment = { vertical: "middle", horizontal: "right" };
386
+ cellB6.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
387
+ cellB6.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: fillColor } };
388
+ level1ViolationRow.getCell(2).border = {
389
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
390
+ // left: {style:'thin', color: {argb: 'FFA6A6A6'}},
391
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
392
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
393
+ };
394
+ // Level 1 Violation Rows
395
+ // build rows
396
+ let rowArray = [];
397
+ // let row:any =[];
398
+ for (const property in levelrowValues) {
399
+ let row = [" " + `${property}`, parseInt(`${levelrowValues[property]}`)
400
+ ];
401
+ rowArray.push(row);
402
+ }
403
+ // sort array according to count
404
+ rowArray.sort((a, b) => (a[1] < b[1]) ? 1 : -1);
405
+ // add array of rows
406
+ for (const rowInfo of rowArray) {
407
+ const row = worksheet.addRow(rowInfo);
408
+ row.height = 14;
409
+ row.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
410
+ row.getCell(2).alignment = { vertical: "middle", horizontal: "right" };
411
+ row.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
412
+ // row.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
413
+ // row.getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFf8cbad'} };
414
+ row.getCell(1).border = {
415
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
416
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
417
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
418
+ // right: {style:'thin', color: {argb: 'FFA6A6A6'}}
419
+ };
420
+ row.getCell(2).border = {
421
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
422
+ // left: {style:'thin', color: {argb: 'FFA6A6A6'}},
423
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
424
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
425
+ };
426
+ row.commit();
427
+ }
428
+ }
429
+ static buildIssueSummaryTKLevel(worksheet, title, levelCounts, levelVrowValues, levelNRrowValues, levelRrowValues, levelArowValues) {
430
+ /////////////////////////////
431
+ // build Level title
432
+ /////////////////////////////
433
+ const level1Row = worksheet.addRow(["", 0]);
434
+ level1Row.height = 27; // actual is 36
435
+ const cellA5 = level1Row.getCell(1);
436
+ cellA5.value = title;
437
+ cellA5.alignment = { vertical: "middle", horizontal: "left" };
438
+ cellA5.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
439
+ cellA5.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
440
+ const cellB5 = level1Row.getCell(2);
441
+ cellB5.value = levelCounts[0]; // total Level 1 issues
442
+ cellB5.alignment = { vertical: "middle", horizontal: "right" };
443
+ cellB5.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
444
+ cellB5.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
445
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FFE4AAAF", "Violation", levelCounts[1], levelVrowValues);
446
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FFF4E08A", "Needs review", levelCounts[2], levelNRrowValues);
447
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FF96A9D7", "Recommendation", levelCounts[3], levelRrowValues);
448
+ if (levelCounts[4] > 0) {
449
+ ACReporterXLSX.buildIssueSummaryLevel(worksheet, "FFCCCCCC", "Archived", levelCounts[4], levelArowValues);
450
+ }
451
+ }
452
+ static createIssueSummarySheet(config, policyInfo, compressedScans, workbook) {
453
+ let violations = 0;
454
+ let needsReviews = 0;
455
+ let recommendations = 0;
456
+ let archive = 0;
457
+ let totalIssues = 0;
458
+ for (let i = 0; i < compressedScans.length; i++) {
459
+ let storedScan = ReporterManager_js_1.ReporterManager.uncompressReport(compressedScans[i]);
460
+ let counts = storedScan.engineReport.summary.counts;
461
+ violations += counts.violation;
462
+ needsReviews += counts.potentialviolation + counts.manual;
463
+ recommendations += counts.recommendation + counts.potentialrecommendation;
464
+ archive += counts.ignored;
465
+ }
466
+ totalIssues = violations + needsReviews + recommendations;
467
+ // counts
468
+ let level1Counts = [0, 0, 0, 0, 0]; // level 1 total issues, violations, needs reviews, recommendations
469
+ let level2Counts = [0, 0, 0, 0, 0];
470
+ let level3Counts = [0, 0, 0, 0, 0];
471
+ let level4Counts = [0, 0, 0, 0, 0];
472
+ let level1V = [];
473
+ let level2V = [];
474
+ let level3V = [];
475
+ let level4V = [];
476
+ let level1NR = [];
477
+ let level2NR = [];
478
+ let level3NR = [];
479
+ let level4NR = [];
480
+ let level1R = [];
481
+ let level2R = [];
482
+ let level3R = [];
483
+ let level4R = [];
484
+ let level1A = [];
485
+ let level2A = [];
486
+ let level3A = [];
487
+ let level4A = [];
488
+ for (const compressedScan of compressedScans) {
489
+ let scan = ReporterManager_js_1.ReporterManager.uncompressReport(compressedScan);
490
+ for (const issue of scan.engineReport.results) {
491
+ if (!(issue.ruleId in policyInfo)) {
492
+ policyInfo[issue.ruleId] = {
493
+ tkLevels: [],
494
+ cps: []
495
+ };
496
+ }
497
+ let levelCounts, levelV, levelNR, levelR, levelA;
498
+ const issuePolicyInfo = policyInfo[issue.ruleId];
499
+ if (issuePolicyInfo.tkLevels.includes(IGuideline_js_1.eToolkitLevel.LEVEL_ONE)) {
500
+ levelCounts = level1Counts;
501
+ levelV = level1V;
502
+ levelNR = level1NR;
503
+ levelR = level1R;
504
+ levelA = level1A;
505
+ }
506
+ else if (issuePolicyInfo.tkLevels.includes(IGuideline_js_1.eToolkitLevel.LEVEL_TWO)) {
507
+ levelCounts = level2Counts;
508
+ levelV = level2V;
509
+ levelNR = level2NR;
510
+ levelR = level2R;
511
+ levelA = level2A;
512
+ }
513
+ else if (issuePolicyInfo.tkLevels.includes(IGuideline_js_1.eToolkitLevel.LEVEL_THREE)) {
514
+ levelCounts = level3Counts;
515
+ levelV = level3V;
516
+ levelNR = level3NR;
517
+ levelR = level3R;
518
+ levelA = level3A;
519
+ }
520
+ else if (issuePolicyInfo.tkLevels.includes(IGuideline_js_1.eToolkitLevel.LEVEL_FOUR)) {
521
+ levelCounts = level4Counts;
522
+ levelV = level4V;
523
+ levelNR = level4NR;
524
+ levelR = level4R;
525
+ levelA = level4A;
526
+ }
527
+ if (issue.value[1] !== IRule_js_1.eRuleConfidence.PASS) {
528
+ ++levelCounts[0];
529
+ }
530
+ if (issue.ignored) {
531
+ ++levelCounts[4];
532
+ levelA.push(issue.message.substring(0, 32767));
533
+ }
534
+ else if (issue.level === IConfig_js_1.eRuleLevel.violation) {
535
+ ++levelCounts[1];
536
+ levelV.push(issue.message.substring(0, 32767));
537
+ }
538
+ else if (issue.level === IConfig_js_1.eRuleLevel.potentialviolation || issue.level === IConfig_js_1.eRuleLevel.manual) {
539
+ ++levelCounts[2];
540
+ levelNR.push(issue.message.substring(0, 32767));
541
+ }
542
+ else if (issue.level === IConfig_js_1.eRuleLevel.recommendation || issue.level === IConfig_js_1.eRuleLevel.potentialrecommendation) {
543
+ ++levelCounts[3];
544
+ levelR.push(issue.message.substring(0, 32767));
545
+ }
546
+ }
547
+ }
548
+ // @ts-ignore
549
+ let level1VrowValues = this.countDuplicatesInArray(level1V); // note this returns an object
550
+ // @ts-ignore
551
+ let level1NRrowValues = this.countDuplicatesInArray(level1NR);
552
+ // @ts-ignore
553
+ let level1RrowValues = this.countDuplicatesInArray(level1R);
554
+ // @ts-ignore
555
+ let level1ArowValues = this.countDuplicatesInArray(level1A);
556
+ // @ts-ignore
557
+ let level2VrowValues = this.countDuplicatesInArray(level2V); // note this returns an object
558
+ // @ts-ignore
559
+ let level2NRrowValues = this.countDuplicatesInArray(level2NR);
560
+ // @ts-ignore
561
+ let level2RrowValues = this.countDuplicatesInArray(level2R);
562
+ // @ts-ignore
563
+ let level2ArowValues = this.countDuplicatesInArray(level2A);
564
+ // @ts-ignore
565
+ let level3VrowValues = this.countDuplicatesInArray(level3V); // note this returns an object
566
+ // @ts-ignore
567
+ let level3NRrowValues = this.countDuplicatesInArray(level3NR);
568
+ // @ts-ignore
569
+ let level3RrowValues = this.countDuplicatesInArray(level3R);
570
+ // @ts-ignore
571
+ let level3ArowValues = this.countDuplicatesInArray(level3A);
572
+ // @ts-ignore
573
+ let level4VrowValues = this.countDuplicatesInArray(level4V); // note this returns an object
574
+ // @ts-ignore
575
+ let level4NRrowValues = this.countDuplicatesInArray(level4NR);
576
+ // @ts-ignore
577
+ let level4RrowValues = this.countDuplicatesInArray(level4R);
578
+ // @ts-ignore
579
+ let level4ArowValues = this.countDuplicatesInArray(level4A);
580
+ const worksheet = workbook.addWorksheet("Issue summary");
581
+ // Approach:
582
+ // 1. sort by levels
583
+ // 2. for each level sort by V, NR and R
584
+ // 3. for each V, NR, and R in a level get issue dup counts
585
+ // 4. build the rows
586
+ // build Issue summary title
587
+ worksheet.mergeCells('A1', "B1");
588
+ const titleRow = worksheet.getRow(1);
589
+ titleRow.height = 27; // actual is 36
590
+ const cellA1 = worksheet.getCell('A1');
591
+ cellA1.value = "Issue summary";
592
+ cellA1.alignment = { vertical: "middle", horizontal: "left" };
593
+ cellA1.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
594
+ cellA1.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
595
+ const colWidthData = [
596
+ { col: 'A', width: 155.51 }, // note .84 added to actual width
597
+ { col: 'B', width: 21.16 },
598
+ ];
599
+ for (let i = 0; i < 2; i++) {
600
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
601
+ }
602
+ // build Description title
603
+ worksheet.mergeCells('A2', "B2");
604
+ const descriptionRow = worksheet.getRow(2);
605
+ descriptionRow.height = 20.25; // actual is 27
606
+ const cellA2 = worksheet.getCell("A2");
607
+ cellA2.value = " In the IBM Equal Access Toolkit, issues are divided into three levels (1-3). Tackle the levels in order to address some of the most impactful issues first.";
608
+ cellA2.alignment = { vertical: "middle", horizontal: "left" };
609
+ cellA2.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
610
+ // cellA2.fill = { type: 'pattern', pattern: 'solid', fgColor:{argb:'FFCCC0DA'} };
611
+ // build Total issues found: title
612
+ // worksheet.mergeCells('A3', "B3");
613
+ const totalIssuesRow = worksheet.getRow(3);
614
+ totalIssuesRow.height = 27; // actual is 36
615
+ const cellA3 = worksheet.getCell("A3");
616
+ cellA3.value = "Total issues found:";
617
+ cellA3.alignment = { vertical: "middle", horizontal: "left" };
618
+ cellA3.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
619
+ cellA3.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
620
+ const cellB3 = worksheet.getCell("B3");
621
+ cellB3.value = totalIssues;
622
+ cellB3.alignment = { vertical: "middle", horizontal: "right" };
623
+ cellB3.font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
624
+ cellB3.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF000000' } };
625
+ // build Number of issues title
626
+ const numberOfIssuesRow = worksheet.getRow(4);
627
+ numberOfIssuesRow.height = 20.25; // actual is 27
628
+ const cellA4 = worksheet.getCell("A4");
629
+ // no value
630
+ cellA4.alignment = { vertical: "middle", horizontal: "left" };
631
+ cellA4.border = {
632
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
633
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
634
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
635
+ right: { style: 'thin', color: { argb: 'FFFFFFFF' } }
636
+ };
637
+ const cellB4 = worksheet.getCell("B4");
638
+ cellB4.value = "Number of issues";
639
+ cellB4.alignment = { vertical: "middle", horizontal: "right" };
640
+ cellB4.font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
641
+ cellB4.border = {
642
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
643
+ left: { style: 'thin', color: { argb: 'FFFFFFFF' } },
644
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
645
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
646
+ };
647
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 1 - the most essential issues to address", level1Counts, level1VrowValues, level1NRrowValues, level1RrowValues, level1ArowValues);
648
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 2 - the next most important issues", level2Counts, level2VrowValues, level2NRrowValues, level2RrowValues, level2ArowValues);
649
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 3 - necessary to meet requirements", level3Counts, level3VrowValues, level3NRrowValues, level3RrowValues, level3ArowValues);
650
+ ACReporterXLSX.buildIssueSummaryTKLevel(worksheet, "Level 4 - further recommended improvements to accessibility", level4Counts, level4VrowValues, level4NRrowValues, level4RrowValues, level4ArowValues);
651
+ worksheet.commit();
652
+ }
653
+ static createIssuesSheet(config, policyInfo, compressedScans, workbook) {
654
+ const valueMap = {
655
+ "VIOLATION": {
656
+ "POTENTIAL": "Needs review",
657
+ "FAIL": "Violation",
658
+ "PASS": "Pass",
659
+ "MANUAL": "Needs review"
660
+ },
661
+ "RECOMMENDATION": {
662
+ "POTENTIAL": "Recommendation",
663
+ "FAIL": "Recommendation",
664
+ "PASS": "Pass",
665
+ "MANUAL": "Recommendation"
666
+ },
667
+ "INFORMATION": {
668
+ "POTENTIAL": "Needs review",
669
+ "FAIL": "Violation",
670
+ "PASS": "Pass",
671
+ "MANUAL": "Recommendation"
672
+ }
673
+ };
674
+ const worksheet = workbook.addWorksheet("Issues");
675
+ // build rows
676
+ let rowArray = [];
677
+ for (const compressedScan of compressedScans) {
678
+ let storedScan = ReporterManager_js_1.ReporterManager.uncompressReport(compressedScan);
679
+ for (const item of storedScan.engineReport.results) {
680
+ if (!(item.ruleId in policyInfo)) {
681
+ policyInfo[item.ruleId] = {
682
+ tkLevels: [],
683
+ cps: []
684
+ };
685
+ }
686
+ let polInfo = policyInfo[item.ruleId];
687
+ let cps = polInfo.cps.filter(cp => {
688
+ let ruleInfo = cp.rules.find(ruleInfo => ruleInfo.id === item.ruleId && (!ruleInfo.reasonCodes || ruleInfo.reasonCodes.includes("" + item.reasonId)));
689
+ return !!ruleInfo;
690
+ });
691
+ let wcagLevels = dropDupes(cps.map(cp => cp.wcagLevel));
692
+ wcagLevels.sort();
693
+ let cpStrs = dropDupes(cps.map(cp => `${cp.num} ${cp.name}`));
694
+ cpStrs.sort();
695
+ let row = [
696
+ storedScan.pageTitle,
697
+ storedScan.engineReport.summary.URL,
698
+ storedScan.label,
699
+ this.stringHash(item.ruleId + item.path.dom),
700
+ `${valueMap[item.value[0]][item.value[1]]}${item.ignored ? ` (Archived)` : ``}`,
701
+ polInfo.tkLevels.join(", "),
702
+ cpStrs.join("; "),
703
+ wcagLevels.join(", "),
704
+ item.ruleId,
705
+ item.message.substring(0, 32767), //max ength for MS Excel 32767 characters
706
+ this.get_element(item.snippet),
707
+ item.snippet.substring(0, 32767),
708
+ item.path.dom,
709
+ item.help
710
+ // engine_end_point + '/tools/help/' + item.ruleId
711
+ ];
712
+ // let row = [myStoredData[i][0], myStoredData[i][1], storedScans[j].label,
713
+ // myStoredData[i][3], myStoredData[i][4], Number.isNaN(myStoredData[i][5]) ? "n/a" : myStoredData[i][5],
714
+ // myStoredData[i][6], Number.isNaN(myStoredData[i][5]) ? "n/a" : myStoredData[i][7], myStoredData[i][8],
715
+ // myStoredData[i][9], myStoredData[i][10], myStoredData[i][11],
716
+ // myStoredData[i][12], myStoredData[i][13]
717
+ // ];
718
+ rowArray.push(row);
719
+ }
720
+ }
721
+ // column widths
722
+ const colWidthData = [
723
+ { col: 'A', width: 18.0, alignment: { vertical: "middle", horizontal: "left" } },
724
+ { col: 'B', width: 20.5, alignment: { vertical: "middle", horizontal: "left" } },
725
+ { col: 'C', width: 21.0, alignment: { vertical: "middle", horizontal: "center" } },
726
+ { col: 'D', width: 18.5, alignment: { vertical: "middle", horizontal: "left" } },
727
+ { col: 'E', width: 17.0, alignment: { vertical: "middle", horizontal: "center" } },
728
+ { col: 'F', width: 17.17, alignment: { vertical: "middle", horizontal: "center" } },
729
+ { col: 'G', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
730
+ { col: 'H', width: 17.17, alignment: { vertical: "middle", horizontal: "center" } },
731
+ { col: 'I', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
732
+ { col: 'J', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
733
+ { col: 'K', width: 14.00, alignment: { vertical: "middle", horizontal: "center" } },
734
+ { col: 'L', width: 17.17, alignment: { vertical: "middle", horizontal: "left" } },
735
+ { col: 'M', width: 43.00, alignment: { vertical: "middle", horizontal: "left" } },
736
+ { col: 'N', width: 17.17, alignment: { vertical: "middle", horizontal: "fill" } },
737
+ ];
738
+ for (let i = 0; i < 14; i++) {
739
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
740
+ worksheet.getColumn(colWidthData[i].col).alignment = colWidthData[i].alignment;
741
+ }
742
+ // add table to a sheet
743
+ let headRow = worksheet.addRow([
744
+ "Page title",
745
+ "Page URL",
746
+ "Scan label",
747
+ "Issue ID",
748
+ "Issue type",
749
+ "Toolkit level",
750
+ "Checkpoint",
751
+ "WCAG level",
752
+ "Rule",
753
+ "Issue",
754
+ "Element",
755
+ "Code",
756
+ "Xpath",
757
+ "Help",
758
+ ""
759
+ ]);
760
+ // set font and alignment for the header cells
761
+ for (let i = 1; i < 15; i++) {
762
+ headRow.getCell(i).alignment = { vertical: "middle", horizontal: "center", wrapText: true };
763
+ headRow.getCell(i).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 12 };
764
+ headRow.getCell(i).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
765
+ headRow.getCell(i).border = {
766
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
767
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
768
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
769
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
770
+ };
771
+ }
772
+ // height for header row
773
+ headRow.height = 24;
774
+ headRow.commit();
775
+ for (const rowInfo of rowArray) {
776
+ const row = worksheet.addRow(rowInfo);
777
+ row.height = 14;
778
+ for (let j = 1; j <= 14; j++) {
779
+ row.getCell(j).border = {
780
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
781
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
782
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
783
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
784
+ };
785
+ }
786
+ row.commit();
787
+ }
788
+ for (const key in worksheet) {
789
+ if (typeof worksheet[key] === "function") {
790
+ console.log(key);
791
+ }
792
+ }
793
+ // worksheet.addTable({
794
+ // name: 'MyTable',
795
+ // ref: 'A1',
796
+ // headerRow: true,
797
+ // // totalsRow: true,
798
+ // style: {
799
+ // theme: 'TableStyleMedium2',
800
+ // showRowStripes: true,
801
+ // },
802
+ // columns: [
803
+ // { name: 'Page title', filterButton: true },
804
+ // { name: 'Page URL', filterButton: true },
805
+ // { name: 'Scan label', filterButton: true },
806
+ // { name: 'Issue ID', filterButton: true },
807
+ // { name: 'Issue type', filterButton: true },
808
+ // { name: 'Toolkit level', filterButton: true },
809
+ // { name: 'Checkpoint', filterButton: true },
810
+ // { name: 'WCAG level', filterButton: true },
811
+ // { name: 'Rule', filterButton: true },
812
+ // { name: 'Issue', filterButton: true },
813
+ // { name: 'Element', filterButton: true },
814
+ // { name: 'Code', filterButton: true },
815
+ // { name: 'Xpath', filterButton: true },
816
+ // { name: 'Help', filterButton: true },
817
+ // ],
818
+ // rows: rowArray
819
+ // });
820
+ // for (let i = 2; i <= rowArray.length + 1; i++) {
821
+ // worksheet.getRow(i).height = 14;
822
+ // for (let j = 1; j <= 14; j++) {
823
+ // worksheet.getRow(i).getCell(j).border = {
824
+ // top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
825
+ // left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
826
+ // bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
827
+ // right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
828
+ // }
829
+ // }
830
+ // worksheet.getRow(i).commit();
831
+ // }
832
+ worksheet.commit();
833
+ }
834
+ static createDefinitionsSheet(workbook) {
835
+ const worksheet = workbook.addWorksheet("Definition of fields");
836
+ // "Definition of fields" title
837
+ worksheet.mergeCells('A1', "B1");
838
+ const titleRow = worksheet.getRow(1);
839
+ titleRow.height = 36; // actual is 48
840
+ titleRow.getCell(1).value = "Definition of fields";
841
+ titleRow.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
842
+ titleRow.getCell(1).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: "20" };
843
+ titleRow.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
844
+ const colWidthData = [
845
+ { col: 'A', width: '41.51' }, // note .84 added to actual width
846
+ { col: 'B', width: '119.51' },
847
+ ];
848
+ for (let i = 0; i < 2; i++) {
849
+ worksheet.getColumn(colWidthData[i].col).width = colWidthData[i].width;
850
+ }
851
+ // blank row
852
+ worksheet.mergeCells('A2', "B2");
853
+ const blankRow = worksheet.getRow(2);
854
+ blankRow.height = 12; // actual is 16
855
+ // "Scan summary and Issue summary" title
856
+ worksheet.mergeCells('A3', "B3");
857
+ const summaryRow = worksheet.getRow(3);
858
+ summaryRow.height = 20; // actual is 26.75
859
+ summaryRow.getCell(1).value = "Scan summary and Issue summary";
860
+ summaryRow.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
861
+ summaryRow.getCell(1).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
862
+ summaryRow.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
863
+ // row 4 Field / Definition
864
+ const row4 = worksheet.getRow(4);
865
+ row4.height = 16; // actual is
866
+ row4.getCell(1).value = "Field";
867
+ row4.getCell(2).value = "Definition";
868
+ row4.getCell(1).alignment = row4.getCell(2).alignment = { vertical: "middle", horizontal: "left" };
869
+ row4.getCell(1).font = row4.getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 16 };
870
+ row4.getCell(1).fill = row4.getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFCCC0DA' } };
871
+ row4.getCell(1).border = row4.getCell(2).border = {
872
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
873
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
874
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
875
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
876
+ };
877
+ // rows 5-13
878
+ // set row height for rows 5-13
879
+ for (let i = 5; i < 14; i++) {
880
+ worksheet.getRow(i).height = 12; // results in a row height of 16
881
+ }
882
+ let rowData = [
883
+ { key1: 'Page', key2: 'Identifies the page or html file that was scanned.' },
884
+ { key1: 'Scan label', key2: 'Label for the scan. Default values can be edited in the Accessibility Checker before saving this report, or programmatically assigned in automated testing.' },
885
+ { key1: 'Violations', key2: 'Accessibility failures that need to be corrected.' },
886
+ { key1: 'Needs review', key2: 'Issues that may not be a violation. These need a manual review to identify whether there is an accessibility problem.' },
887
+ { key1: 'Recommendations', key2: 'Opportunities to apply best practices to further improve accessibility.' },
888
+ { key1: '% elements without violations', key2: 'Percentage of elements on the page that had no violations found.' },
889
+ { key1: '% elements without violations or items to review', key2: 'Percentage of elements on the page that had no violations found and no items to review.' },
890
+ { key1: 'Level 1,2,3', key2: 'Priority level defined by the IBM Equal Access Toolkit. See https://www.ibm.com/able/toolkit/plan/overview#pace-of-completion for details.' }
891
+ ];
892
+ for (let i = 5; i < rowData.length + 5; i++) {
893
+ worksheet.getRow(i).getCell(1).font = worksheet.getRow(i).getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
894
+ worksheet.getRow(i).getCell(1).alignment = worksheet.getRow(i).getCell(2).alignment = { horizontal: "left" };
895
+ }
896
+ for (let i = 5; i < rowData.length + 5; i++) {
897
+ worksheet.getRow(i).getCell(1).value = rowData[i - 5].key1;
898
+ worksheet.getRow(i).getCell(2).value = rowData[i - 5].key2;
899
+ }
900
+ // "Scan summary and Issue summary" title
901
+ worksheet.mergeCells('A14', "B14");
902
+ const issuesRow = worksheet.getRow(14);
903
+ issuesRow.height = 20; // actual is 26.75
904
+ issuesRow.getCell(1).value = "Issues";
905
+ issuesRow.getCell(1).alignment = { vertical: "middle", horizontal: "left" };
906
+ issuesRow.getCell(1).font = { name: "Calibri", color: { argb: "FFFFFFFF" }, size: 16 };
907
+ issuesRow.getCell(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF403151' } };
908
+ // row 15 Field / Definition
909
+ const row15 = worksheet.getRow(15);
910
+ row15.height = 16; // actual is
911
+ row15.getCell(1).value = "Field";
912
+ row15.getCell(2).value = "Definition";
913
+ row15.getCell(1).alignment = row15.getCell(2).alignment = { vertical: "middle", horizontal: "left" };
914
+ row15.getCell(1).font = row15.getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 16 };
915
+ row15.getCell(1).fill = row15.getCell(2).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFCCC0DA' } };
916
+ row15.getCell(1).border = row15.getCell(2).border = {
917
+ top: { style: 'thin', color: { argb: 'FFA6A6A6' } },
918
+ left: { style: 'thin', color: { argb: 'FFA6A6A6' } },
919
+ bottom: { style: 'thin', color: { argb: 'FFA6A6A6' } },
920
+ right: { style: 'thin', color: { argb: 'FFA6A6A6' } }
921
+ };
922
+ // rows 16-28
923
+ // set row height for rows 16-28
924
+ for (let i = 16; i < 29; i++) {
925
+ worksheet.getRow(i).height = 12; // results in a row height of 16
926
+ }
927
+ rowData = [];
928
+ rowData = [
929
+ { key1: 'Page', key2: 'Identifies the page or html file that was scanned.' },
930
+ { key1: 'Scan label', key2: 'Label for the scan. Default values can be edited in the Accessibility Checker before saving this report, or programmatically assigned in automated testing.' },
931
+ { key1: 'Issue ID', key2: 'Identifier for this issue within this page. Rescanning the same page will produce the same issue ID. ' },
932
+ { key1: 'Issue type', key2: 'Violation, needs review, or recommendation' },
933
+ { key1: 'Toolkit level', key2: '1, 2 or 3. Priority level defined by the IBM Equal Access Toolkit. See https://www.ibm.com/able/toolkit/plan/overview#pace-of-completion for details' },
934
+ { key1: 'Checkpoint', key2: 'Web Content Accessibility Guidelines (WCAG) checkpoints this issue falls into.' },
935
+ { key1: 'WCAG level', key2: 'A, AA or AAA. WCAG level for this issue.' },
936
+ { key1: 'Rule', key2: 'Name of the accessibility test rule that detected this issue.' },
937
+ { key1: 'Issue', key2: 'Message describing the issue.' },
938
+ { key1: 'Element', key2: 'Type of HTML element where the issue is found.' },
939
+ { key1: 'Code', key2: 'Actual HTML element where the issue is found.' },
940
+ { key1: 'Xpath', key2: 'Xpath of the HTML element where the issue is found.' },
941
+ { key1: 'Help', key2: 'Link to a more detailed description of the issue and suggested solutions.' },
942
+ ];
943
+ for (let i = 16; i < 29; i++) {
944
+ worksheet.getRow(i).getCell(1).font = worksheet.getRow(i).getCell(2).font = { name: "Calibri", color: { argb: "FF000000" }, size: 12 };
945
+ worksheet.getRow(i).getCell(1).alignment = worksheet.getRow(i).getCell(2).alignment = { horizontal: "left" };
946
+ }
947
+ for (let i = 16; i < 29; i++) {
948
+ worksheet.getRow(i).getCell(1).value = rowData[i - 16].key1;
949
+ worksheet.getRow(i).getCell(2).value = rowData[i - 16].key2;
950
+ }
951
+ worksheet.commit();
952
+ }
953
+ static countDuplicatesInArray(array) {
954
+ let count = {};
955
+ // let result = [];
956
+ array.forEach(item => {
957
+ if (count[item]) {
958
+ //@ts-ignore
959
+ count[item] += 1;
960
+ return;
961
+ }
962
+ //@ts-ignore
963
+ count[item] = 1;
964
+ });
965
+ return count;
966
+ }
967
+ static get_element(code) {
968
+ if (code) {
969
+ const ind_s = code.indexOf(' ');
970
+ const ind_br = code.indexOf('>');
971
+ return (ind_s > 0 && ind_s < ind_br) ? code.substring(1, ind_s) : code.substring(1, ind_br);
972
+ }
973
+ return '';
974
+ }
975
+ static format_date(timestamp) {
976
+ var date = new Date(timestamp);
977
+ return date.getFullYear() + '-' + ("00" + (date.getMonth() + 1)).slice(-2) + "-" +
978
+ ("00" + date.getDate()).slice(-2) + "-" +
979
+ ("00" + date.getHours()).slice(-2) + "-" +
980
+ ("00" + date.getMinutes()).slice(-2) + "-" +
981
+ ("00" + date.getSeconds()).slice(-2);
982
+ }
983
+ // From https://github.com/darkskyapp/string-hash/blob/master/index.js
984
+ static stringHash(str) {
985
+ var hash = 5381, i = str.length;
986
+ while (i) {
987
+ hash = (hash * 33) ^ str.charCodeAt(--i);
988
+ }
989
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
990
+ * integers. Since we want the results to be always positive, convert the
991
+ * signed int to an unsigned by doing an unsigned bitshift. */
992
+ return hash >>> 0;
993
+ }
994
+ }
995
+ exports.ACReporterXLSX = ACReporterXLSX;
996
+ //# sourceMappingURL=ACReporterXLSX.js.map