@speleotica/frcsdata 5.0.0-beta.1 → 5.0.0-beta.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 (88) hide show
  1. package/ParseIssue.js +4 -4
  2. package/ParseIssue.js.map +1 -1
  3. package/SourceLoc.js +5 -5
  4. package/SourceLoc.js.map +1 -1
  5. package/chunksToLines.js +29 -131
  6. package/chunksToLines.js.map +1 -1
  7. package/cli/check-survey-correspondence.d.ts +2 -0
  8. package/cli/check-survey-correspondence.d.ts.map +1 -0
  9. package/cli/check-survey-correspondence.js +44 -0
  10. package/cli/check-survey-correspondence.js.map +1 -0
  11. package/cli/check-survey.d.ts.map +1 -1
  12. package/cli/check-survey.js +14 -75
  13. package/cli/check-survey.js.map +1 -1
  14. package/cli/parse-survey.js +4 -26
  15. package/cli/parse-survey.js.map +1 -1
  16. package/cli/summarize-survey.d.ts +2 -0
  17. package/cli/summarize-survey.d.ts.map +1 -0
  18. package/cli/summarize-survey.js +33 -0
  19. package/cli/summarize-survey.js.map +1 -0
  20. package/cli.js +61 -72
  21. package/cli.js.map +1 -1
  22. package/formatFrcsTripSummaryFile.d.ts +3 -0
  23. package/formatFrcsTripSummaryFile.d.ts.map +1 -0
  24. package/formatFrcsTripSummaryFile.js +33 -0
  25. package/formatFrcsTripSummaryFile.js.map +1 -0
  26. package/formatIssues.d.ts +10 -0
  27. package/formatIssues.d.ts.map +1 -0
  28. package/formatIssues.js +52 -0
  29. package/formatIssues.js.map +1 -0
  30. package/index.js +13 -13
  31. package/node/index.d.ts +3 -1
  32. package/node/index.d.ts.map +1 -1
  33. package/node/index.js +5 -19
  34. package/node/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/parseFrcsPlotFile.js +112 -245
  37. package/parseFrcsPlotFile.js.map +1 -1
  38. package/parseFrcsTripSummaryFile.d.ts +3 -1
  39. package/parseFrcsTripSummaryFile.d.ts.map +1 -1
  40. package/parseFrcsTripSummaryFile.js +53 -119
  41. package/parseFrcsTripSummaryFile.js.map +1 -1
  42. package/src/cli/check-survey-correspondence.ts +49 -0
  43. package/src/cli/check-survey.ts +8 -69
  44. package/src/cli/summarize-survey.ts +28 -0
  45. package/src/cli.ts +33 -0
  46. package/src/formatFrcsTripSummaryFile.ts +45 -0
  47. package/src/formatIssues.ts +97 -0
  48. package/src/parseFrcsTripSummaryFile.ts +8 -2
  49. package/src/survey/normalizeTeamMemberName.ts +3 -6
  50. package/src/survey/parseFrcsSurveyFile.ts +3 -17
  51. package/src/survey/summarizeSurvey.ts +51 -0
  52. package/src/unwrapInvalid.ts +3 -0
  53. package/string/index.d.ts +3 -1
  54. package/string/index.d.ts.map +1 -1
  55. package/string/index.js +7 -41
  56. package/string/index.js.map +1 -1
  57. package/survey/FrcsSurveyFile.js +1 -1
  58. package/survey/FrcsSurveyFile.js.map +1 -1
  59. package/survey/ZodFrcsSurveyFileJson.js +84 -86
  60. package/survey/ZodFrcsSurveyFileJson.js.map +1 -1
  61. package/survey/ZodFrcsSurveyFileToJson.js +78 -88
  62. package/survey/ZodFrcsSurveyFileToJson.js.map +1 -1
  63. package/survey/formatFrcsShot.js +45 -43
  64. package/survey/formatFrcsShot.js.map +1 -1
  65. package/survey/formatFrcsSurveyFile.js +52 -130
  66. package/survey/formatFrcsSurveyFile.js.map +1 -1
  67. package/survey/getColumnRanges.js +11 -19
  68. package/survey/getColumnRanges.js.map +1 -1
  69. package/survey/normalizeTeamMemberName.d.ts.map +1 -1
  70. package/survey/normalizeTeamMemberName.js +1 -5
  71. package/survey/normalizeTeamMemberName.js.map +1 -1
  72. package/survey/parseFrcsSurveyFile.d.ts.map +1 -1
  73. package/survey/parseFrcsSurveyFile.js +558 -750
  74. package/survey/parseFrcsSurveyFile.js.map +1 -1
  75. package/survey/parsers.js +20 -20
  76. package/survey/parsers.js.map +1 -1
  77. package/survey/summarizeSurvey.d.ts +6 -0
  78. package/survey/summarizeSurvey.d.ts.map +1 -0
  79. package/survey/summarizeSurvey.js +58 -0
  80. package/survey/summarizeSurvey.js.map +1 -0
  81. package/underlineSource.js +9 -17
  82. package/underlineSource.js.map +1 -1
  83. package/unwrapInvalid.d.ts +4 -0
  84. package/unwrapInvalid.d.ts.map +1 -0
  85. package/unwrapInvalid.js +10 -0
  86. package/unwrapInvalid.js.map +1 -0
  87. package/web/index.js +56 -116
  88. package/web/index.js.map +1 -1
package/ParseIssue.js CHANGED
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ParseIssueSeverity = exports.ParseIssue = void 0;
8
8
  var _SourceLoc = require("./SourceLoc.js");
9
9
  var _zod = _interopRequireDefault(require("zod"));
10
- var ParseIssueSeverity = exports.ParseIssueSeverity = _zod["default"]["enum"](['error', 'warning']);
11
- var ParseIssue = exports.ParseIssue = _zod["default"].strictObject({
10
+ const ParseIssueSeverity = exports.ParseIssueSeverity = _zod.default.enum(['error', 'warning']);
11
+ const ParseIssue = exports.ParseIssue = _zod.default.strictObject({
12
12
  type: ParseIssueSeverity,
13
- code: _zod["default"].string().nonempty(),
14
- message: _zod["default"].string().optional(),
13
+ code: _zod.default.string().nonempty(),
14
+ message: _zod.default.string().optional(),
15
15
  loc: _SourceLoc.SourceLoc.optional()
16
16
  });
17
17
  //# sourceMappingURL=ParseIssue.js.map
package/ParseIssue.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ParseIssue.js","names":["_SourceLoc","require","_zod","_interopRequireDefault","ParseIssueSeverity","exports","z","ParseIssue","strictObject","type","code","string","nonempty","message","optional","loc","SourceLoc"],"sources":["src/ParseIssue.ts"],"sourcesContent":["import { SourceLoc } from './SourceLoc'\nimport z from 'zod'\n\nexport const ParseIssueSeverity = z.enum(['error', 'warning'])\nexport type ParseIssueSeverity = z.output<typeof ParseIssueSeverity>\n\nexport const ParseIssue = z.strictObject({\n type: ParseIssueSeverity,\n code: z.string().nonempty(),\n message: z.string().optional(),\n loc: SourceLoc.optional(),\n})\n\nexport type ParseIssue = {\n type: ParseIssueSeverity\n code: string\n message?: string\n loc?: SourceLoc\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,IAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,eAAC,QAAK,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAGvD,IAAMC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAGD,eAAC,CAACE,YAAY,CAAC;EACvCC,IAAI,EAAEL,kBAAkB;EACxBM,IAAI,EAAEJ,eAAC,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC3BC,OAAO,EAAEP,eAAC,CAACK,MAAM,CAAC,CAAC,CAACG,QAAQ,CAAC,CAAC;EAC9BC,GAAG,EAAEC,oBAAS,CAACF,QAAQ,CAAC;AAC1B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ParseIssue.js","names":["_SourceLoc","require","_zod","_interopRequireDefault","ParseIssueSeverity","exports","z","enum","ParseIssue","strictObject","type","code","string","nonempty","message","optional","loc","SourceLoc"],"sources":["src/ParseIssue.ts"],"sourcesContent":["import { SourceLoc } from './SourceLoc'\nimport z from 'zod'\n\nexport const ParseIssueSeverity = z.enum(['error', 'warning'])\nexport type ParseIssueSeverity = z.output<typeof ParseIssueSeverity>\n\nexport const ParseIssue = z.strictObject({\n type: ParseIssueSeverity,\n code: z.string().nonempty(),\n message: z.string().optional(),\n loc: SourceLoc.optional(),\n})\n\nexport type ParseIssue = {\n type: ParseIssueSeverity\n code: string\n message?: string\n loc?: SourceLoc\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,YAAC,CAACC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAGvD,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAGF,YAAC,CAACG,YAAY,CAAC;EACvCC,IAAI,EAAEN,kBAAkB;EACxBO,IAAI,EAAEL,YAAC,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC3BC,OAAO,EAAER,YAAC,CAACM,MAAM,CAAC,CAAC,CAACG,QAAQ,CAAC,CAAC;EAC9BC,GAAG,EAAEC,oBAAS,CAACF,QAAQ,CAAC;AAC1B,CAAC,CAAC","ignoreList":[]}
package/SourceLoc.js CHANGED
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.SourcePos = exports.SourceLoc = void 0;
8
8
  var _zod = _interopRequireDefault(require("zod"));
9
- var SourcePos = exports.SourcePos = _zod["default"].object({
10
- line: _zod["default"].number()["int"]().nonnegative(),
11
- column: _zod["default"].number()["int"]().nonnegative(),
12
- index: _zod["default"].number()["int"]().nonnegative()
9
+ const SourcePos = exports.SourcePos = _zod.default.object({
10
+ line: _zod.default.number().int().nonnegative(),
11
+ column: _zod.default.number().int().nonnegative(),
12
+ index: _zod.default.number().int().nonnegative()
13
13
  });
14
- var SourceLoc = exports.SourceLoc = _zod["default"].object({
14
+ const SourceLoc = exports.SourceLoc = _zod.default.object({
15
15
  start: SourcePos,
16
16
  end: SourcePos
17
17
  });
package/SourceLoc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"SourceLoc.js","names":["_zod","_interopRequireDefault","require","SourcePos","exports","z","object","line","number","nonnegative","column","index","SourceLoc","start","end"],"sources":["src/SourceLoc.ts"],"sourcesContent":["import z from 'zod'\n\nexport const SourcePos = z.object({\n line: z.number().int().nonnegative(),\n column: z.number().int().nonnegative(),\n index: z.number().int().nonnegative(),\n})\n\nexport type SourcePos = z.output<typeof SourcePos>\n\nexport const SourceLoc = z.object({ start: SourcePos, end: SourcePos })\n\nexport type SourceLoc = z.output<typeof SourceLoc>\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,IAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAGE,eAAC,CAACC,MAAM,CAAC;EAChCC,IAAI,EAAEF,eAAC,CAACG,MAAM,CAAC,CAAC,OAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACpCC,MAAM,EAAEL,eAAC,CAACG,MAAM,CAAC,CAAC,OAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACtCE,KAAK,EAAEN,eAAC,CAACG,MAAM,CAAC,CAAC,OAAI,CAAC,CAAC,CAACC,WAAW,CAAC;AACtC,CAAC,CAAC;AAIK,IAAMG,SAAS,GAAAR,OAAA,CAAAQ,SAAA,GAAGP,eAAC,CAACC,MAAM,CAAC;EAAEO,KAAK,EAAEV,SAAS;EAAEW,GAAG,EAAEX;AAAU,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SourceLoc.js","names":["_zod","_interopRequireDefault","require","SourcePos","exports","z","object","line","number","int","nonnegative","column","index","SourceLoc","start","end"],"sources":["src/SourceLoc.ts"],"sourcesContent":["import z from 'zod'\n\nexport const SourcePos = z.object({\n line: z.number().int().nonnegative(),\n column: z.number().int().nonnegative(),\n index: z.number().int().nonnegative(),\n})\n\nexport type SourcePos = z.output<typeof SourcePos>\n\nexport const SourceLoc = z.object({ start: SourcePos, end: SourcePos })\n\nexport type SourceLoc = z.output<typeof SourceLoc>\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAGE,YAAC,CAACC,MAAM,CAAC;EAChCC,IAAI,EAAEF,YAAC,CAACG,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACpCC,MAAM,EAAEN,YAAC,CAACG,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACtCE,KAAK,EAAEP,YAAC,CAACG,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,WAAW,CAAC;AACtC,CAAC,CAAC;AAIK,MAAMG,SAAS,GAAAT,OAAA,CAAAS,SAAA,GAAGR,YAAC,CAACC,MAAM,CAAC;EAAEQ,KAAK,EAAEX,SAAS;EAAEY,GAAG,EAAEZ;AAAU,CAAC,CAAC","ignoreList":[]}
package/chunksToLines.js CHANGED
@@ -1,139 +1,37 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.chunksToLines = chunksToLines;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
10
- var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
11
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
12
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
- function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
15
- function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
16
- function chunksToLines(_x) {
17
- return _chunksToLines.apply(this, arguments);
18
- }
19
- function _chunksToLines() {
20
- _chunksToLines = (0, _wrapAsyncGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(chunks) {
21
- var chunkStartIndex, remainder, prevChunkEndedWithCarriageReturn, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, end, rx, _iterator2, _step2, match, line;
22
- return _regenerator["default"].wrap(function _callee$(_context) {
23
- while (1) switch (_context.prev = _context.next) {
24
- case 0:
25
- chunkStartIndex = 0;
26
- remainder = '';
27
- prevChunkEndedWithCarriageReturn = false;
28
- _iteratorAbruptCompletion = false;
29
- _didIteratorError = false;
30
- _context.prev = 5;
31
- _iterator = _asyncIterator(chunks);
32
- case 7:
33
- _context.next = 9;
34
- return (0, _awaitAsyncGenerator2["default"])(_iterator.next());
35
- case 9:
36
- if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
37
- _context.next = 42;
38
- break;
39
- }
40
- chunk = _step.value;
41
- if (chunk.length) {
42
- _context.next = 13;
43
- break;
44
- }
45
- return _context.abrupt("continue", 39);
46
- case 13:
47
- if (remainder) {
48
- chunk = remainder + chunk;
49
- remainder = '';
50
- }
51
- end = prevChunkEndedWithCarriageReturn && chunk[0] === '\n' ? 1 : 0;
52
- rx = /\r\n?|\n/gm;
53
- rx.lastIndex = end;
54
- _iterator2 = _createForOfIteratorHelper(chunk.matchAll(rx));
55
- _context.prev = 18;
56
- _iterator2.s();
57
- case 20:
58
- if ((_step2 = _iterator2.n()).done) {
59
- _context.next = 28;
60
- break;
61
- }
62
- match = _step2.value;
63
- line = chunk.substring(end, match.index);
64
- _context.next = 25;
65
- return {
66
- line: line,
67
- startIndex: chunkStartIndex + end
68
- };
69
- case 25:
70
- end = match.index + match[0].length;
71
- case 26:
72
- _context.next = 20;
73
- break;
74
- case 28:
75
- _context.next = 33;
76
- break;
77
- case 30:
78
- _context.prev = 30;
79
- _context.t0 = _context["catch"](18);
80
- _iterator2.e(_context.t0);
81
- case 33:
82
- _context.prev = 33;
83
- _iterator2.f();
84
- return _context.finish(33);
85
- case 36:
86
- if (end < chunk.length) remainder = chunk.substring(end);
87
- chunkStartIndex += end;
88
- prevChunkEndedWithCarriageReturn = chunk[chunk.length - 1] === '\r';
89
- case 39:
90
- _iteratorAbruptCompletion = false;
91
- _context.next = 7;
92
- break;
93
- case 42:
94
- _context.next = 48;
95
- break;
96
- case 44:
97
- _context.prev = 44;
98
- _context.t1 = _context["catch"](5);
99
- _didIteratorError = true;
100
- _iteratorError = _context.t1;
101
- case 48:
102
- _context.prev = 48;
103
- _context.prev = 49;
104
- if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
105
- _context.next = 53;
106
- break;
107
- }
108
- _context.next = 53;
109
- return (0, _awaitAsyncGenerator2["default"])(_iterator["return"]());
110
- case 53:
111
- _context.prev = 53;
112
- if (!_didIteratorError) {
113
- _context.next = 56;
114
- break;
115
- }
116
- throw _iteratorError;
117
- case 56:
118
- return _context.finish(53);
119
- case 57:
120
- return _context.finish(48);
121
- case 58:
122
- if (!remainder) {
123
- _context.next = 61;
124
- break;
125
- }
126
- _context.next = 61;
127
- return {
128
- line: remainder,
129
- startIndex: chunkStartIndex
130
- };
131
- case 61:
132
- case "end":
133
- return _context.stop();
134
- }
135
- }, _callee, null, [[5, 44, 48, 58], [18, 30, 33, 36], [49,, 53, 57]]);
136
- }));
137
- return _chunksToLines.apply(this, arguments);
7
+ async function* chunksToLines(chunks) {
8
+ let chunkStartIndex = 0;
9
+ let remainder = '';
10
+ let prevChunkEndedWithCarriageReturn = false;
11
+ for await (let chunk of chunks) {
12
+ if (!chunk.length) continue;
13
+ if (remainder) {
14
+ chunk = remainder + chunk;
15
+ remainder = '';
16
+ }
17
+ let end = prevChunkEndedWithCarriageReturn && chunk[0] === '\n' ? 1 : 0;
18
+ const rx = /\r\n?|\n/gm;
19
+ rx.lastIndex = end;
20
+ for (const match of chunk.matchAll(rx)) {
21
+ const line = chunk.substring(end, match.index);
22
+ yield {
23
+ line,
24
+ startIndex: chunkStartIndex + end
25
+ };
26
+ end = match.index + match[0].length;
27
+ }
28
+ if (end < chunk.length) remainder = chunk.substring(end);
29
+ chunkStartIndex += end;
30
+ prevChunkEndedWithCarriageReturn = chunk[chunk.length - 1] === '\r';
31
+ }
32
+ if (remainder) yield {
33
+ line: remainder,
34
+ startIndex: chunkStartIndex
35
+ };
138
36
  }
139
37
  //# sourceMappingURL=chunksToLines.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunksToLines.js","names":["chunksToLines","_x","_chunksToLines","apply","arguments","_wrapAsyncGenerator2","_regenerator","mark","_callee","chunks","chunkStartIndex","remainder","prevChunkEndedWithCarriageReturn","_iteratorAbruptCompletion","_didIteratorError","_iteratorError","_iterator","_step","chunk","end","rx","_iterator2","_step2","match","line","wrap","_callee$","_context","prev","next","_asyncIterator","_awaitAsyncGenerator2","sent","done","value","length","abrupt","lastIndex","_createForOfIteratorHelper","matchAll","s","n","substring","index","startIndex","t0","e","f","finish","t1","stop"],"sources":["src/chunksToLines.ts"],"sourcesContent":["export async function* chunksToLines(\n chunks: Iterable<string> | AsyncIterable<string>\n) {\n let chunkStartIndex = 0\n let remainder = ''\n let prevChunkEndedWithCarriageReturn = false\n for await (let chunk of chunks) {\n if (!chunk.length) continue\n if (remainder) {\n chunk = remainder + chunk\n remainder = ''\n }\n let end = prevChunkEndedWithCarriageReturn && chunk[0] === '\\n' ? 1 : 0\n const rx = /\\r\\n?|\\n/gm\n rx.lastIndex = end\n for (const match of chunk.matchAll(rx)) {\n const line = chunk.substring(end, match.index)\n yield { line, startIndex: chunkStartIndex + end }\n end = match.index + match[0].length\n }\n if (end < chunk.length) remainder = chunk.substring(end)\n chunkStartIndex += end\n prevChunkEndedWithCarriageReturn = chunk[chunk.length - 1] === '\\r'\n }\n if (remainder) yield { line: remainder, startIndex: chunkStartIndex }\n}\n"],"mappings":";;;;;;;;;;;;;;;SAAuBA,aAAaA,CAAAC,EAAA;EAAA,OAAAC,cAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAAA,SAAAF,eAAA;EAAAA,cAAA,OAAAG,oBAAA,2BAAAC,YAAA,YAAAC,IAAA,CAA7B,SAAAC,QACLC,MAAgD;IAAA,IAAAC,eAAA,EAAAC,SAAA,EAAAC,gCAAA,EAAAC,yBAAA,EAAAC,iBAAA,EAAAC,cAAA,EAAAC,SAAA,EAAAC,KAAA,EAAAC,KAAA,EAAAC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E,qBAAA,aAAAf,SAAA;QAAA;UAAAW,QAAA,CAAAC,IAAA;UAAA,KAAAd,iBAAA;YAAAa,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,MAAAd,cAAA;QAAA;UAAA,OAAAY,QAAA,CAAAqB,MAAA;QAAA;UAAA,OAAArB,QAAA,CAAAqB,MAAA;QAAA;UAAA,KAEjErC,SAAS;YAAAgB,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAAF,QAAA,CAAAE,IAAA;UAAE,OAAM;YAAEL,IAAI,EAAEb,SAAS;YAAEiC,UAAU,EAAElC;UAAgB,CAAC;QAAA;QAAA;UAAA,OAAAiB,QAAA,CAAAuB,IAAA;MAAA;IAAA,GAAA1C,OAAA;EAAA,CACtE;EAAA,OAAAN,cAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"chunksToLines.js","names":["chunksToLines","chunks","chunkStartIndex","remainder","prevChunkEndedWithCarriageReturn","chunk","length","end","rx","lastIndex","match","matchAll","line","substring","index","startIndex"],"sources":["src/chunksToLines.ts"],"sourcesContent":["export async function* chunksToLines(\n chunks: Iterable<string> | AsyncIterable<string>\n) {\n let chunkStartIndex = 0\n let remainder = ''\n let prevChunkEndedWithCarriageReturn = false\n for await (let chunk of chunks) {\n if (!chunk.length) continue\n if (remainder) {\n chunk = remainder + chunk\n remainder = ''\n }\n let end = prevChunkEndedWithCarriageReturn && chunk[0] === '\\n' ? 1 : 0\n const rx = /\\r\\n?|\\n/gm\n rx.lastIndex = end\n for (const match of chunk.matchAll(rx)) {\n const line = chunk.substring(end, match.index)\n yield { line, startIndex: chunkStartIndex + end }\n end = match.index + match[0].length\n }\n if (end < chunk.length) remainder = chunk.substring(end)\n chunkStartIndex += end\n prevChunkEndedWithCarriageReturn = chunk[chunk.length - 1] === '\\r'\n }\n if (remainder) yield { line: remainder, startIndex: chunkStartIndex }\n}\n"],"mappings":";;;;;;AAAO,gBAAgBA,aAAaA,CAClCC,MAAgD,EAChD;EACA,IAAIC,eAAe,GAAG,CAAC;EACvB,IAAIC,SAAS,GAAG,EAAE;EAClB,IAAIC,gCAAgC,GAAG,KAAK;EAC5C,WAAW,IAAIC,KAAK,IAAIJ,MAAM,EAAE;IAC9B,IAAI,CAACI,KAAK,CAACC,MAAM,EAAE;IACnB,IAAIH,SAAS,EAAE;MACbE,KAAK,GAAGF,SAAS,GAAGE,KAAK;MACzBF,SAAS,GAAG,EAAE;IAChB;IACA,IAAII,GAAG,GAAGH,gCAAgC,IAAIC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC;IACvE,MAAMG,EAAE,GAAG,YAAY;IACvBA,EAAE,CAACC,SAAS,GAAGF,GAAG;IAClB,KAAK,MAAMG,KAAK,IAAIL,KAAK,CAACM,QAAQ,CAACH,EAAE,CAAC,EAAE;MACtC,MAAMI,IAAI,GAAGP,KAAK,CAACQ,SAAS,CAACN,GAAG,EAAEG,KAAK,CAACI,KAAK,CAAC;MAC9C,MAAM;QAAEF,IAAI;QAAEG,UAAU,EAAEb,eAAe,GAAGK;MAAI,CAAC;MACjDA,GAAG,GAAGG,KAAK,CAACI,KAAK,GAAGJ,KAAK,CAAC,CAAC,CAAC,CAACJ,MAAM;IACrC;IACA,IAAIC,GAAG,GAAGF,KAAK,CAACC,MAAM,EAAEH,SAAS,GAAGE,KAAK,CAACQ,SAAS,CAACN,GAAG,CAAC;IACxDL,eAAe,IAAIK,GAAG;IACtBH,gCAAgC,GAAGC,KAAK,CAACA,KAAK,CAACC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI;EACrE;EACA,IAAIH,SAAS,EAAE,MAAM;IAAES,IAAI,EAAET,SAAS;IAAEY,UAAU,EAAEb;EAAgB,CAAC;AACvE","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function checkSurveyCorrespondence(surveyFile: string, summaryFile: string): Promise<void>;
2
+ //# sourceMappingURL=check-survey-correspondence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-survey-correspondence.d.ts","sourceRoot":"","sources":["../../src/cli/check-survey-correspondence.ts"],"names":[],"mappings":"AASA,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,iBAqCpB"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.checkSurveyCorrespondence = checkSurveyCorrespondence;
8
+ var _chalk = _interopRequireDefault(require("chalk"));
9
+ var _index = require("../string/index.js");
10
+ var _promises = _interopRequireDefault(require("fs/promises"));
11
+ var _summarizeSurvey = require("../survey/summarizeSurvey.js");
12
+ var _index2 = require("../node/index.js");
13
+ var _formatFrcsTripSummaryFile = require("../formatFrcsTripSummaryFile.js");
14
+ var _util = require("util");
15
+ /* eslint-disable no-console */
16
+
17
+ async function checkSurveyCorrespondence(surveyFile, summaryFile) {
18
+ const source = await _promises.default.readFile(surveyFile, 'utf8');
19
+ const parsedSurvey = await (0, _index.parseFrcsSurveyFile)(surveyFile, source);
20
+ const parsedSummaries = (await (0, _index2.parseFrcsTripSummaryFile)(summaryFile, {
21
+ indexBy: 'occurrence'
22
+ })).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0));
23
+ const convertedSummaries = (0, _summarizeSurvey.summarizeSurvey)(parsedSurvey, {
24
+ ignoreVerticalOfHShots: true
25
+ }).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0));
26
+ let errored = false;
27
+ for (let i = 0; i < Math.max(parsedSummaries.length, convertedSummaries.length); i++) {
28
+ const parsed = parsedSummaries[i];
29
+ const converted = convertedSummaries[i];
30
+ const parsedLines = [...(0, _formatFrcsTripSummaryFile.formatFrcsTripSummaryFile)({
31
+ tripSummaries: [parsed]
32
+ })].slice(0, 2);
33
+ const convertedLines = [...(0, _formatFrcsTripSummaryFile.formatFrcsTripSummaryFile)({
34
+ tripSummaries: [converted]
35
+ })].slice(0, 2);
36
+ if (!(0, _util.isDeepStrictEqual)(parsedLines, convertedLines)) {
37
+ errored = true;
38
+ console.log(convertedLines.map(line => _chalk.default.green('+' + line)).join('\n'));
39
+ console.log(parsedLines.map(line => _chalk.default.red('-' + line)).join('\n'));
40
+ }
41
+ }
42
+ process.exit(errored ? 1 : 0);
43
+ }
44
+ //# sourceMappingURL=check-survey-correspondence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-survey-correspondence.js","names":["_chalk","_interopRequireDefault","require","_index","_promises","_summarizeSurvey","_index2","_formatFrcsTripSummaryFile","_util","checkSurveyCorrespondence","surveyFile","summaryFile","source","fs","readFile","parsedSurvey","parseFrcsSurveyFile","parsedSummaries","parseFrcsTripSummaryFile","indexBy","tripSummaries","sort","a","b","tripNumber","convertedSummaries","summarizeSurvey","ignoreVerticalOfHShots","errored","i","Math","max","length","parsed","converted","parsedLines","formatFrcsTripSummaryFile","slice","convertedLines","isDeepStrictEqual","console","log","map","line","chalk","green","join","red","process","exit"],"sources":["../../src/cli/check-survey-correspondence.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport chalk from 'chalk'\nimport { parseFrcsSurveyFile } from '../string/index'\nimport fs from 'fs/promises'\nimport { summarizeSurvey } from '../survey/summarizeSurvey'\nimport { parseFrcsTripSummaryFile } from '../node/index.js'\nimport { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile.js'\nimport { isDeepStrictEqual } from 'util'\n\nexport async function checkSurveyCorrespondence(\n surveyFile: string,\n summaryFile: string\n) {\n const source = await fs.readFile(surveyFile, 'utf8')\n const parsedSurvey = await parseFrcsSurveyFile(surveyFile, source)\n const parsedSummaries = (\n await parseFrcsTripSummaryFile(summaryFile, { indexBy: 'occurrence' })\n ).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))\n const convertedSummaries = summarizeSurvey(parsedSurvey, {\n ignoreVerticalOfHShots: true,\n }).tripSummaries.sort((a, b) => (a?.tripNumber ?? 0) - (b?.tripNumber ?? 0))\n\n let errored = false\n\n for (\n let i = 0;\n i < Math.max(parsedSummaries.length, convertedSummaries.length);\n i++\n ) {\n const parsed = parsedSummaries[i]\n const converted = convertedSummaries[i]\n\n const parsedLines = [\n ...formatFrcsTripSummaryFile({ tripSummaries: [parsed] }),\n ].slice(0, 2)\n const convertedLines = [\n ...formatFrcsTripSummaryFile({ tripSummaries: [converted] }),\n ].slice(0, 2)\n\n if (!isDeepStrictEqual(parsedLines, convertedLines)) {\n errored = true\n console.log(\n convertedLines.map((line) => chalk.green('+' + line)).join('\\n')\n )\n console.log(parsedLines.map((line) => chalk.red('-' + line)).join('\\n'))\n }\n }\n process.exit(errored ? 1 : 0)\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,0BAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAPA;;AASO,eAAeO,yBAAyBA,CAC7CC,UAAkB,EAClBC,WAAmB,EACnB;EACA,MAAMC,MAAM,GAAG,MAAMC,iBAAE,CAACC,QAAQ,CAACJ,UAAU,EAAE,MAAM,CAAC;EACpD,MAAMK,YAAY,GAAG,MAAM,IAAAC,0BAAmB,EAACN,UAAU,EAAEE,MAAM,CAAC;EAClE,MAAMK,eAAe,GAAG,CACtB,MAAM,IAAAC,gCAAwB,EAACP,WAAW,EAAE;IAAEQ,OAAO,EAAE;EAAa,CAAC,CAAC,EACtEC,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK,CAACD,CAAC,EAAEE,UAAU,IAAI,CAAC,KAAKD,CAAC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CAACG,GAAG,CAAC,GAAG,GAAGJ,IAAI,CAAC,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E;EACF;EACAE,OAAO,CAACC,IAAI,CAACrB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAC/B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"check-survey.d.ts","sourceRoot":"","sources":["../../src/cli/check-survey.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,iBA6E7C"}
1
+ {"version":3,"file":"check-survey.d.ts","sourceRoot":"","sources":["../../src/cli/check-survey.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,iBAgB7C"}
@@ -5,84 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.checkSurvey = checkSurvey;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
8
  var _promises = _interopRequireDefault(require("fs/promises"));
11
9
  var _parseFrcsSurveyFile = _interopRequireDefault(require("../survey/parseFrcsSurveyFile.js"));
12
- var _underlineSource = require("../underlineSource.js");
13
10
  var _chalk = _interopRequireDefault(require("chalk"));
14
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
15
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
16
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /* eslint-disable no-console */
17
- function checkSurvey(_x) {
18
- return _checkSurvey.apply(this, arguments);
19
- }
20
- function _checkSurvey() {
21
- _checkSurvey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
22
- var source, parsed, issues, _iterator, _step, _loc$start, _loc$start2, issue, type, loc, message, style, errorCount, warningCount, trips, tripCount, shotCount, fmtErrorCount, fmtWarningCount, fmtTripCount, fmtShotCount, countWidth;
23
- return _regenerator["default"].wrap(function _callee$(_context) {
24
- while (1) switch (_context.prev = _context.next) {
25
- case 0:
26
- _context.next = 2;
27
- return _promises["default"].readFile(file, 'utf8');
28
- case 2:
29
- source = _context.sent;
30
- _context.next = 5;
31
- return (0, _parseFrcsSurveyFile["default"])(file, [source]);
32
- case 5:
33
- parsed = _context.sent;
34
- issues = parsed.issues || [];
35
- _iterator = _createForOfIteratorHelper(issues);
36
- try {
37
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
38
- issue = _step.value;
39
- type = issue.type, loc = issue.loc, message = issue.message;
40
- style = type === 'error' ? _chalk["default"].red : _chalk["default"].yellow;
41
- console.log("".concat(style("".concat(type === 'error' ? _chalk["default"].red('✘') : _chalk["default"].yellow('⚠'), " ").concat("".concat(type[0].toUpperCase()).concat(type.substring(1), ":").padEnd(8), " ").concat(message === null || message === void 0 ? void 0 : message.padEnd(40))), " (").concat(file, ":").concat(loc === null || loc === void 0 || (_loc$start = loc.start) === null || _loc$start === void 0 ? void 0 : _loc$start.line, ":").concat(loc === null || loc === void 0 || (_loc$start2 = loc.start) === null || _loc$start2 === void 0 ? void 0 : _loc$start2.column, ")"));
42
- if (loc) {
43
- console.log((0, _underlineSource.underlineSource)(source, loc, {
44
- underlineStyle: style
45
- }));
46
- }
47
- }
48
- } catch (err) {
49
- _iterator.e(err);
50
- } finally {
51
- _iterator.f();
52
- }
53
- errorCount = issues.reduce(function (count, i) {
54
- return i.type === 'error' ? count + 1 : count;
55
- }, 0);
56
- warningCount = issues.reduce(function (count, i) {
57
- return i.type === 'warning' ? count + 1 : count;
58
- }, 0);
59
- trips = 'INVALID' in parsed ? parsed.INVALID.trips : parsed.trips;
60
- tripCount = trips.length;
61
- shotCount = trips.reduce(function (count, trip) {
62
- return count + ('INVALID' in trip ? trip.INVALID.shots.length : trip.shots.length);
63
- }, 0);
64
- fmtErrorCount = "\u2718 ".concat(errorCount);
65
- fmtWarningCount = "\u26A0 ".concat(warningCount);
66
- fmtTripCount = "".concat(tripCount);
67
- fmtShotCount = "".concat(shotCount);
68
- countWidth = Math.max(fmtErrorCount.length, fmtWarningCount.length, fmtTripCount.length, fmtShotCount.length);
69
- if (errorCount) {
70
- console.log(_chalk["default"].red("".concat(fmtErrorCount.padStart(countWidth), " error").concat(errorCount === 1 ? '' : 's')));
71
- }
72
- if (warningCount) {
73
- console.log(_chalk["default"].yellow("".concat(fmtWarningCount.padStart(countWidth), " warning").concat(warningCount === 1 ? '' : 's')));
74
- }
75
- console.log("".concat(fmtTripCount.padStart(countWidth), " trip").concat(tripCount === 1 ? '' : 's'));
76
- console.log("".concat(fmtShotCount.padStart(countWidth), " shot").concat(shotCount === 1 ? '' : 's'));
77
- process.exit(issues.some(function (i) {
78
- return i.type === 'error';
79
- }) ? 1 : 0);
80
- case 24:
81
- case "end":
82
- return _context.stop();
83
- }
84
- }, _callee);
11
+ var _formatIssues = require("../formatIssues.js");
12
+ /* eslint-disable no-console */
13
+
14
+ async function checkSurvey(file) {
15
+ const source = await _promises.default.readFile(file, 'utf8');
16
+ const parsed = await (0, _parseFrcsSurveyFile.default)(file, [source]);
17
+ const issues = parsed.issues || [];
18
+ console.log((0, _formatIssues.formatIssues)({
19
+ file,
20
+ source,
21
+ parsed,
22
+ errorStyle: _chalk.default.red,
23
+ warningStyle: _chalk.default.yellow
85
24
  }));
86
- return _checkSurvey.apply(this, arguments);
25
+ process.exit(issues.some(i => i.type === 'error') ? 1 : 0);
87
26
  }
88
27
  //# sourceMappingURL=check-survey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-survey.js","names":["_promises","_interopRequireDefault","require","_parseFrcsSurveyFile","_underlineSource","_chalk","_createForOfIteratorHelper","r","e","t","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","_n","F","s","n","done","value","f","TypeError","o","a","u","call","next","_arrayLikeToArray","toString","slice","constructor","name","from","test","checkSurvey","_x","_checkSurvey","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","file","source","parsed","issues","_iterator","_step","_loc$start","_loc$start2","issue","type","loc","message","style","errorCount","warningCount","trips","tripCount","shotCount","fmtErrorCount","fmtWarningCount","fmtTripCount","fmtShotCount","countWidth","wrap","_callee$","_context","prev","fs","readFile","sent","parseFrcsSurveyFile","chalk","red","yellow","console","log","concat","toUpperCase","substring","padEnd","start","line","column","underlineSource","underlineStyle","err","reduce","count","i","INVALID","trip","shots","Math","max","padStart","process","exit","some","stop"],"sources":["../../src/cli/check-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs/promises'\nimport parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'\nimport { underlineSource } from '../underlineSource.js'\nimport chalk from 'chalk'\n\nexport async function checkSurvey(file: string) {\n const source = await fs.readFile(file, 'utf8')\n const parsed = await parseFrcsSurveyFile(file, [source])\n\n const issues = parsed.issues || []\n for (const issue of issues) {\n const { type, loc, message } = issue\n const style = type === 'error' ? chalk.red : chalk.yellow\n console.log(\n `${style(\n `${\n type === 'error' ? chalk.red('✘') : chalk.yellow('⚠')\n } ${`${type[0].toUpperCase()}${type.substring(1)}:`.padEnd(\n 8\n )} ${message?.padEnd(40)}`\n )} (${file}:${loc?.start?.line}:${loc?.start?.column})`\n )\n if (loc) {\n console.log(underlineSource(source, loc, { underlineStyle: style }))\n }\n }\n\n const errorCount = issues.reduce(\n (count, i) => (i.type === 'error' ? count + 1 : count),\n 0\n )\n const warningCount = issues.reduce(\n (count, i) => (i.type === 'warning' ? count + 1 : count),\n 0\n )\n const trips = 'INVALID' in parsed ? parsed.INVALID.trips : parsed.trips\n const tripCount = trips.length\n const shotCount = trips.reduce(\n (count, trip) =>\n count +\n ('INVALID' in trip ? trip.INVALID.shots.length : trip.shots.length),\n 0\n )\n\n const fmtErrorCount = `✘ ${errorCount}`\n const fmtWarningCount = `⚠ ${warningCount}`\n const fmtTripCount = `${tripCount}`\n const fmtShotCount = `${shotCount}`\n\n const countWidth = Math.max(\n fmtErrorCount.length,\n fmtWarningCount.length,\n fmtTripCount.length,\n fmtShotCount.length\n )\n\n if (errorCount) {\n console.log(\n chalk.red(\n `${fmtErrorCount.padStart(countWidth)} error${\n errorCount === 1 ? '' : 's'\n }`\n )\n )\n }\n if (warningCount) {\n console.log(\n chalk.yellow(\n `${fmtWarningCount.padStart(countWidth)} warning${\n warningCount === 1 ? '' : 's'\n }`\n )\n )\n }\n console.log(\n `${fmtTripCount.padStart(countWidth)} trip${tripCount === 1 ? '' : 's'}`\n )\n console.log(\n `${fmtShotCount.padStart(countWidth)} shot${shotCount === 1 ? '' : 's'}`\n )\n\n process.exit(issues.some((i) => i.type === 'error') ? 1 : 0)\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,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EAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAAA;QAAA;UAAA,OAAAgB,QAAA,CAAAiC,IAAA;MAAA;IAAA,GAAA3D,OAAA;EAAA,CAC7D;EAAA,OAAAN,YAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"check-survey.js","names":["_promises","_interopRequireDefault","require","_parseFrcsSurveyFile","_chalk","_formatIssues","checkSurvey","file","source","fs","readFile","parsed","parseFrcsSurveyFile","issues","console","log","formatIssues","errorStyle","chalk","red","warningStyle","yellow","process","exit","some","i","type"],"sources":["../../src/cli/check-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport fs from 'fs/promises'\nimport parseFrcsSurveyFile from '../survey/parseFrcsSurveyFile'\nimport chalk from 'chalk'\nimport { formatIssues } from '../formatIssues.js'\n\nexport async function checkSurvey(file: string) {\n const source = await fs.readFile(file, 'utf8')\n const parsed = await parseFrcsSurveyFile(file, [source])\n\n const issues = parsed.issues || []\n console.log(\n formatIssues({\n file,\n source,\n parsed,\n errorStyle: chalk.red,\n warningStyle: chalk.yellow,\n })\n )\n\n process.exit(issues.some((i) => i.type === 'error') ? 1 : 0)\n}\n"],"mappings":";;;;;;;AACA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAJA;;AAMO,eAAeI,WAAWA,CAACC,IAAY,EAAE;EAC9C,MAAMC,MAAM,GAAG,MAAMC,iBAAE,CAACC,QAAQ,CAACH,IAAI,EAAE,MAAM,CAAC;EAC9C,MAAMI,MAAM,GAAG,MAAM,IAAAC,4BAAmB,EAACL,IAAI,EAAE,CAACC,MAAM,CAAC,CAAC;EAExD,MAAMK,MAAM,GAAGF,MAAM,CAACE,MAAM,IAAI,EAAE;EAClCC,OAAO,CAACC,GAAG,CACT,IAAAC,0BAAY,EAAC;IACXT,IAAI;IACJC,MAAM;IACNG,MAAM;IACNM,UAAU,EAAEC,cAAK,CAACC,GAAG;IACrBC,YAAY,EAAEF,cAAK,CAACG;EACtB,CAAC,CACH,CAAC;EAEDC,OAAO,CAACC,IAAI,CAACV,MAAM,CAACW,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC9D","ignoreList":[]}
@@ -1,37 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.parseSurvey = parseSurvey;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
7
  var _index = require("../node/index.js");
11
8
  var _ZodFrcsSurveyFileToJson = require("../survey/ZodFrcsSurveyFileToJson.js");
12
9
  /* eslint-disable no-console */
13
- function parseSurvey(_x) {
14
- return _parseSurvey.apply(this, arguments);
15
- }
16
- function _parseSurvey() {
17
- _parseSurvey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file) {
18
- var parsed;
19
- return _regenerator["default"].wrap(function _callee$(_context) {
20
- while (1) switch (_context.prev = _context.next) {
21
- case 0:
22
- _context.t0 = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson;
23
- _context.next = 3;
24
- return (0, _index.parseFrcsSurveyFile)(file);
25
- case 3:
26
- _context.t1 = _context.sent;
27
- parsed = _context.t0.parse.call(_context.t0, _context.t1);
28
- console.log(JSON.stringify(parsed));
29
- case 6:
30
- case "end":
31
- return _context.stop();
32
- }
33
- }, _callee);
34
- }));
35
- return _parseSurvey.apply(this, arguments);
10
+
11
+ async function parseSurvey(file) {
12
+ const parsed = _ZodFrcsSurveyFileToJson.ZodValidOrInvalidFrcsSurveyFileToJson.parse(await (0, _index.parseFrcsSurveyFile)(file));
13
+ console.log(JSON.stringify(parsed));
36
14
  }
37
15
  //# sourceMappingURL=parse-survey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-survey.js","names":["_index","require","_ZodFrcsSurveyFileToJson","parseSurvey","_x","_parseSurvey","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","file","parsed","wrap","_callee$","_context","prev","next","t0","ZodValidOrInvalidFrcsSurveyFileToJson","parseFrcsSurveyFile","t1","sent","parse","call","console","log","JSON","stringify","stop"],"sources":["../../src/cli/parse-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { parseFrcsSurveyFile } from '../node/index'\nimport { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'\n\nexport async function parseSurvey(file: string) {\n const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(\n await parseFrcsSurveyFile(file)\n )\n console.log(JSON.stringify(parsed))\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAFA;AAAA,SAIsBE,WAAWA,CAAAC,EAAA;EAAA,OAAAC,YAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAAA,SAAAF,aAAA;EAAAA,YAAA,OAAAG,kBAAA,2BAAAC,YAAA,YAAAC,IAAA,CAA1B,SAAAC,QAA2BC,IAAY;IAAA,IAAAC,MAAA;IAAA,OAAAJ,YAAA,YAAAK,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAAF,QAAA,CAAAG,EAAA,GAC7BC,8DAAqC;UAAAJ,QAAA,CAAAE,IAAA;UAAA,OAC5C,IAAAG,0BAAmB,EAACT,IAAI,CAAC;QAAA;UAAAI,QAAA,CAAAM,EAAA,GAAAN,QAAA,CAAAO,IAAA;UAD3BV,MAAM,GAAAG,QAAA,CAAAG,EAAA,CAAyCK,KAAK,CAAAC,IAAA,CAAAT,QAAA,CAAAG,EAAA,EAAAH,QAAA,CAAAM,EAAA;UAG1DI,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAAChB,MAAM,CAAC,CAAC;QAAA;QAAA;UAAA,OAAAG,QAAA,CAAAc,IAAA;MAAA;IAAA,GAAAnB,OAAA;EAAA,CACpC;EAAA,OAAAN,YAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"parse-survey.js","names":["_index","require","_ZodFrcsSurveyFileToJson","parseSurvey","file","parsed","ZodValidOrInvalidFrcsSurveyFileToJson","parse","parseFrcsSurveyFile","console","log","JSON","stringify"],"sources":["../../src/cli/parse-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { parseFrcsSurveyFile } from '../node/index'\nimport { ZodValidOrInvalidFrcsSurveyFileToJson } from '../survey/ZodFrcsSurveyFileToJson'\n\nexport async function parseSurvey(file: string) {\n const parsed = ZodValidOrInvalidFrcsSurveyFileToJson.parse(\n await parseFrcsSurveyFile(file)\n )\n console.log(JSON.stringify(parsed))\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AAFA;;AAIO,eAAeE,WAAWA,CAACC,IAAY,EAAE;EAC9C,MAAMC,MAAM,GAAGC,8DAAqC,CAACC,KAAK,CACxD,MAAM,IAAAC,0BAAmB,EAACJ,IAAI,CAChC,CAAC;EACDK,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACP,MAAM,CAAC,CAAC;AACrC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function summarizeSurvey(file: string): Promise<void>;
2
+ //# sourceMappingURL=summarize-survey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize-survey.d.ts","sourceRoot":"","sources":["../../src/cli/summarize-survey.ts"],"names":[],"mappings":"AAQA,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,iBAmBjD"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.summarizeSurvey = summarizeSurvey;
8
+ var _chalk = _interopRequireDefault(require("chalk"));
9
+ var _formatIssues = require("../formatIssues.js");
10
+ var _index = require("../string/index.js");
11
+ var _promises = _interopRequireDefault(require("fs/promises"));
12
+ var _formatFrcsTripSummaryFile = require("../formatFrcsTripSummaryFile.js");
13
+ var _summarizeSurvey = require("../survey/summarizeSurvey.js");
14
+ /* eslint-disable no-console */
15
+
16
+ async function summarizeSurvey(file) {
17
+ const source = await _promises.default.readFile(file, 'utf8');
18
+ const parsed = await (0, _index.parseFrcsSurveyFile)(file, source);
19
+ if ('INVALID' in parsed) {
20
+ console.log((0, _formatIssues.formatIssues)({
21
+ file,
22
+ source,
23
+ parsed,
24
+ errorStyle: _chalk.default.red,
25
+ warningStyle: _chalk.default.yellow
26
+ }));
27
+ process.exit(1);
28
+ }
29
+ for (const line of (0, _formatFrcsTripSummaryFile.formatFrcsTripSummaryFile)((0, _summarizeSurvey.summarizeSurvey)(parsed))) {
30
+ console.log(line);
31
+ }
32
+ }
33
+ //# sourceMappingURL=summarize-survey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize-survey.js","names":["_chalk","_interopRequireDefault","require","_formatIssues","_index","_promises","_formatFrcsTripSummaryFile","_summarizeSurvey","summarizeSurvey","file","source","fs","readFile","parsed","parseFrcsSurveyFile","console","log","formatIssues","errorStyle","chalk","red","warningStyle","yellow","process","exit","line","formatFrcsTripSummaryFile","baseSummarizeSurvey"],"sources":["../../src/cli/summarize-survey.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport chalk from 'chalk'\nimport { formatIssues } from '../formatIssues'\nimport { parseFrcsSurveyFile } from '../string/index'\nimport fs from 'fs/promises'\nimport { formatFrcsTripSummaryFile } from '../formatFrcsTripSummaryFile'\nimport { summarizeSurvey as baseSummarizeSurvey } from '../survey/summarizeSurvey'\n\nexport async function summarizeSurvey(file: string) {\n const source = await fs.readFile(file, 'utf8')\n const parsed = await parseFrcsSurveyFile(file, source)\n if ('INVALID' in parsed) {\n console.log(\n formatIssues({\n file,\n source,\n parsed,\n errorStyle: chalk.red,\n warningStyle: chalk.yellow,\n })\n )\n process.exit(1)\n }\n\n for (const line of formatFrcsTripSummaryFile(baseSummarizeSurvey(parsed))) {\n console.log(line)\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AANA;;AAQO,eAAeM,eAAeA,CAACC,IAAY,EAAE;EAClD,MAAMC,MAAM,GAAG,MAAMC,iBAAE,CAACC,QAAQ,CAACH,IAAI,EAAE,MAAM,CAAC;EAC9C,MAAMI,MAAM,GAAG,MAAM,IAAAC,0BAAmB,EAACL,IAAI,EAAEC,MAAM,CAAC;EACtD,IAAI,SAAS,IAAIG,MAAM,EAAE;IACvBE,OAAO,CAACC,GAAG,CACT,IAAAC,0BAAY,EAAC;MACXR,IAAI;MACJC,MAAM;MACNG,MAAM;MACNK,UAAU,EAAEC,cAAK,CAACC,GAAG;MACrBC,YAAY,EAAEF,cAAK,CAACG;IACtB,CAAC,CACH,CAAC;IACDC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;EACjB;EAEA,KAAK,MAAMC,IAAI,IAAI,IAAAC,oDAAyB,EAAC,IAAAC,gCAAmB,EAACd,MAAM,CAAC,CAAC,EAAE;IACzEE,OAAO,CAACC,GAAG,CAACS,IAAI,CAAC;EACnB;AACF","ignoreList":[]}