@jrpool/kilotest 24.0.4

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 (69) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/DEVELOPMENT.md +5860 -0
  3. package/LICENSE +21 -0
  4. package/README.md +44 -0
  5. package/SERVICE.md +268 -0
  6. package/aceconfig.js +28 -0
  7. package/ai0BalanceForm/index.html +30 -0
  8. package/ai0BalanceForm/index.js +79 -0
  9. package/alerts.js +73 -0
  10. package/diagnoses/index.html +46 -0
  11. package/diagnoses/index.js +140 -0
  12. package/env.example +21 -0
  13. package/env.testaro +17 -0
  14. package/error.html +18 -0
  15. package/eslint.config.mjs +53 -0
  16. package/favicon.ico +0 -0
  17. package/index.html +39 -0
  18. package/index.js +639 -0
  19. package/issues/index.html +20 -0
  20. package/issues/index.js +173 -0
  21. package/job.json +100 -0
  22. package/manage/index.html +32 -0
  23. package/manage/index.js +22 -0
  24. package/package.json +38 -0
  25. package/pm2.config.js +15 -0
  26. package/reannotate/index.html +19 -0
  27. package/reannotate/index.js +39 -0
  28. package/reannotateForm/index.html +29 -0
  29. package/reannotateForm/index.js +114 -0
  30. package/recActionForm/index.html +33 -0
  31. package/recActionForm/index.js +49 -0
  32. package/reportHideForm/index.html +29 -0
  33. package/reportHideForm/index.js +89 -0
  34. package/reportIssue/index.html +38 -0
  35. package/reportIssue/index.js +181 -0
  36. package/reportIssues/index.html +47 -0
  37. package/reportIssues/index.js +259 -0
  38. package/reportUnhideForm/index.html +29 -0
  39. package/reportUnhideForm/index.js +89 -0
  40. package/reportsExpungeForm/index.html +29 -0
  41. package/reportsExpungeForm/index.js +105 -0
  42. package/reportsPruneForm/index.html +29 -0
  43. package/reportsPruneForm/index.js +105 -0
  44. package/reportsRewindForm/index.html +29 -0
  45. package/reportsRewindForm/index.js +105 -0
  46. package/retestRec/index.html +23 -0
  47. package/retestRec/index.js +19 -0
  48. package/retestRecForm/index.html +27 -0
  49. package/retestRecForm/index.js +36 -0
  50. package/rules/index.html +28 -0
  51. package/rules/index.js +71 -0
  52. package/style.css +196 -0
  53. package/targets/index.html +37 -0
  54. package/targets/index.js +170 -0
  55. package/testOrder/index.html +23 -0
  56. package/testOrder/index.js +62 -0
  57. package/testRec/index.html +23 -0
  58. package/testRec/index.js +25 -0
  59. package/testRecForm/index.html +34 -0
  60. package/testRecForm/index.js +22 -0
  61. package/tutorial/images/newsletter-form.png +0 -0
  62. package/tutorial/index.html +796 -0
  63. package/tutorial/index.js +53 -0
  64. package/util.js +686 -0
  65. package/wcagMap.json +102 -0
  66. package/wcagRenew/index.html +19 -0
  67. package/wcagRenew/index.js +70 -0
  68. package/wcagRenewForm/index.html +25 -0
  69. package/wcagRenewForm/index.js +22 -0
@@ -0,0 +1,53 @@
1
+ /*
2
+ index.js
3
+ Answers the tutorial request and saves tutorial comments.
4
+ */
5
+
6
+ // IMPORTS
7
+
8
+ const {getJSON} = require('../util');
9
+ const fs = require('fs/promises');
10
+ const path = require('path');
11
+
12
+ // CONSTANTS
13
+
14
+ const commentsPath = path.join(__dirname, 'comments.json');
15
+
16
+ // FUNCTIONS
17
+
18
+ // Strips HTML tags and control characters, trims, and limits to 500 characters.
19
+ const sanitize = str => str
20
+ .replace(/<[^>]*>/g, '')
21
+ .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '')
22
+ .trim()
23
+ .slice(0, 500);
24
+
25
+ // Returns the tutorial page.
26
+ exports.answer = async () => {
27
+ let answerPage = await fs.readFile(path.join(__dirname, 'index.html'), 'utf8');
28
+ return {
29
+ status: 'ok',
30
+ answerPage
31
+ };
32
+ };
33
+ // Sanitizes and saves a tutorial comment to comments.json.
34
+ exports.saveComment = async content => {
35
+ if (!content || typeof content !== 'string') {
36
+ return {status: 'error', error: 'No content provided'};
37
+ }
38
+ const sanitized = sanitize(content);
39
+ if (!sanitized) {
40
+ return {status: 'error', error: 'Comment is empty after sanitization'};
41
+ }
42
+ let comments = [];
43
+ try {
44
+ const existing = await fs.readFile(commentsPath, 'utf8');
45
+ comments = JSON.parse(existing);
46
+ }
47
+ catch (_) {
48
+ // File absent or unparseable; start a fresh array.
49
+ }
50
+ comments.push({timeStamp: new Date().toISOString(), content: sanitized});
51
+ await fs.writeFile(commentsPath, getJSON(comments));
52
+ return {status: 'ok'};
53
+ };