@lighthouse/common 6.10.0 → 6.10.1-canary.0

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 (229) hide show
  1. package/.mise.toml +6 -6
  2. package/CHANGELOG.md +758 -758
  3. package/README.md +1 -1
  4. package/dist/errors/FetchImageError.js +3 -3
  5. package/dist/helpers/fetch-image-for-pdf-generator-service/index.js +7 -7
  6. package/dist/helpers/floatify/index.js +6 -6
  7. package/dist/helpers/get-audit-items-data/index.js +47 -36
  8. package/dist/helpers/validate-url/index.js +4 -4
  9. package/dist/pdf/activity-report/index.js +32 -32
  10. package/dist/pdf/audit/index.js +23 -23
  11. package/dist/pdf/helpers/fields/index.js +47 -27
  12. package/dist/pdf/issue/index.js +23 -23
  13. package/dist/pdf/job/index.js +22 -22
  14. package/dist/pdf/shift-report/index.js +28 -28
  15. package/dist/pdf/task/index.js +23 -23
  16. package/dist/scheduling/generators/occurrenceIntervalsGenerator.js +2 -2
  17. package/dist/scheduling/generators/scheduleIntervalsGenerator.js +2 -2
  18. package/dist/scheduling/generators/serviceIntervalsGenerator.js +2 -2
  19. package/dist/scheduling/helpers/convertToTimezone.js +6 -6
  20. package/dist/scheduling/helpers/generateNonRepeatingSchedule.js +2 -2
  21. package/dist/scheduling/helpers/generateRepeatingSchedule.js +2 -2
  22. package/dist/scheduling/helpers/generateScheduleEnd.js +2 -2
  23. package/dist/scheduling/helpers/hasValidStartAndEnd.js +5 -5
  24. package/dist/scheduling/helpers/intervalCovers.js +6 -6
  25. package/dist/scheduling/helpers/intervalIntersectsEnd.js +6 -6
  26. package/dist/scheduling/helpers/intervalIntersectsStart.js +6 -6
  27. package/dist/scheduling/helpers/intervalOnlyIntersectsEnd.js +6 -6
  28. package/dist/scheduling/helpers/intervalOnlyIntersectsStart.js +6 -6
  29. package/dist/scheduling/helpers/intervalOutside.js +6 -6
  30. package/dist/scheduling/helpers/intervalWithin.js +6 -6
  31. package/dist/scheduling/helpers/mergeIntervals.js +6 -6
  32. package/dist/scheduling/helpers/splitIntervals.js +6 -6
  33. package/dist/scheduling/strategies/getNext.js +2 -2
  34. package/dist/scheduling/strategies/getNextExactDateOfMonth.js +2 -2
  35. package/dist/scheduling/strategies/getNextLastDayOfMonth.js +2 -2
  36. package/dist/scheduling/strategies/getNextLastWeekdayOfMonth.js +2 -2
  37. package/dist/scheduling/strategies/getNextNoRepeat.js +2 -2
  38. package/dist/scheduling/strategies/getNextWeekday.js +2 -2
  39. package/dist/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +2 -2
  40. package/dist/service-hours/__helpers__/calculate-hours.js +4 -4
  41. package/dist/service-hours/__helpers__/isOpen.js +2 -2
  42. package/dist/service-hours/schema.js +4 -4
  43. package/lib/constants.js +12 -6
  44. package/lib/constants.js.map +1 -1
  45. package/lib/errors/DomainError.js +14 -21
  46. package/lib/errors/DomainError.js.map +1 -1
  47. package/lib/errors/FetchImageError.js +17 -24
  48. package/lib/errors/FetchImageError.js.map +1 -1
  49. package/lib/errors/ValidationError.js +30 -36
  50. package/lib/errors/ValidationError.js.map +1 -1
  51. package/lib/errors/index.js +23 -5
  52. package/lib/errors/index.js.map +1 -1
  53. package/lib/helpers/build-fetch-url/index.js +43 -47
  54. package/lib/helpers/build-fetch-url/index.js.map +1 -1
  55. package/lib/helpers/fetch-image/index.js +83 -82
  56. package/lib/helpers/fetch-image/index.js.map +1 -1
  57. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js +168 -243
  58. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js.map +1 -1
  59. package/lib/helpers/fetch-image-for-web/index.js +71 -94
  60. package/lib/helpers/fetch-image-for-web/index.js.map +1 -1
  61. package/lib/helpers/fetch-lighthouse-logo/index.js +36 -61
  62. package/lib/helpers/fetch-lighthouse-logo/index.js.map +1 -1
  63. package/lib/helpers/floatify/index.js +13 -7
  64. package/lib/helpers/floatify/index.js.map +1 -1
  65. package/lib/helpers/get-assignees-full-names/index.js +11 -7
  66. package/lib/helpers/get-assignees-full-names/index.js.map +1 -1
  67. package/lib/helpers/get-audit-entry-details/index.js +42 -32
  68. package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
  69. package/lib/helpers/get-audit-items-data/index.js +104 -83
  70. package/lib/helpers/get-audit-items-data/index.js.map +1 -1
  71. package/lib/helpers/get-geometry-geocoded-string/index.js +10 -5
  72. package/lib/helpers/get-geometry-geocoded-string/index.js.map +1 -1
  73. package/lib/helpers/get-issue-details/index.js +53 -43
  74. package/lib/helpers/get-issue-details/index.js.map +1 -1
  75. package/lib/helpers/get-job-details/index.js +49 -41
  76. package/lib/helpers/get-job-details/index.js.map +1 -1
  77. package/lib/helpers/get-location-reference/index.js +32 -34
  78. package/lib/helpers/get-location-reference/index.js.map +1 -1
  79. package/lib/helpers/get-pretty-duration/index.js +16 -10
  80. package/lib/helpers/get-pretty-duration/index.js.map +1 -1
  81. package/lib/helpers/get-reference-details/index.js +20 -10
  82. package/lib/helpers/get-reference-details/index.js.map +1 -1
  83. package/lib/helpers/get-status-details/index.js +8 -2
  84. package/lib/helpers/get-status-details/index.js.map +1 -1
  85. package/lib/helpers/get-task-entry-details/index.js +32 -23
  86. package/lib/helpers/get-task-entry-details/index.js.map +1 -1
  87. package/lib/helpers/get-timezone-abbr/index.js +11 -4
  88. package/lib/helpers/get-timezone-abbr/index.js.map +1 -1
  89. package/lib/helpers/get-timezone-datetime/index.js +20 -13
  90. package/lib/helpers/get-timezone-datetime/index.js.map +1 -1
  91. package/lib/helpers/get-user-full-name/index.js +9 -3
  92. package/lib/helpers/get-user-full-name/index.js.map +1 -1
  93. package/lib/helpers/get-value-as-percentage/index.js +9 -4
  94. package/lib/helpers/get-value-as-percentage/index.js.map +1 -1
  95. package/lib/helpers/image-validators/index.js +18 -12
  96. package/lib/helpers/image-validators/index.js.map +1 -1
  97. package/lib/helpers/index.js +130 -18
  98. package/lib/helpers/index.js.map +1 -1
  99. package/lib/helpers/validate-url/index.js +11 -5
  100. package/lib/helpers/validate-url/index.js.map +1 -1
  101. package/lib/images/index.js +10 -4
  102. package/lib/images/index.js.map +1 -1
  103. package/lib/index.js +66 -10
  104. package/lib/index.js.map +1 -1
  105. package/lib/pdf/activity-report/index.js +407 -537
  106. package/lib/pdf/activity-report/index.js.map +1 -1
  107. package/lib/pdf/audit/index.js +137 -134
  108. package/lib/pdf/audit/index.js.map +1 -1
  109. package/lib/pdf/fonts/index.js +4 -2
  110. package/lib/pdf/fonts/index.js.map +1 -1
  111. package/lib/pdf/helpers/build-audit-content/index.js +57 -51
  112. package/lib/pdf/helpers/build-audit-content/index.js.map +1 -1
  113. package/lib/pdf/helpers/build-audit-follow-ups/index.js +52 -50
  114. package/lib/pdf/helpers/build-audit-follow-ups/index.js.map +1 -1
  115. package/lib/pdf/helpers/build-location-scans-content/index.js +22 -16
  116. package/lib/pdf/helpers/build-location-scans-content/index.js.map +1 -1
  117. package/lib/pdf/helpers/build-template-content/index.js +52 -51
  118. package/lib/pdf/helpers/build-template-content/index.js.map +1 -1
  119. package/lib/pdf/helpers/default-footer/index.js +38 -35
  120. package/lib/pdf/helpers/default-footer/index.js.map +1 -1
  121. package/lib/pdf/helpers/default-header/index.js +40 -35
  122. package/lib/pdf/helpers/default-header/index.js.map +1 -1
  123. package/lib/pdf/helpers/default-styles/index.js +7 -1
  124. package/lib/pdf/helpers/default-styles/index.js.map +1 -1
  125. package/lib/pdf/helpers/fields/index.js +225 -214
  126. package/lib/pdf/helpers/fields/index.js.map +1 -1
  127. package/lib/pdf/helpers/format-location-address/index.js +14 -8
  128. package/lib/pdf/helpers/format-location-address/index.js.map +1 -1
  129. package/lib/pdf/helpers/generate-definition/index.js +60 -65
  130. package/lib/pdf/helpers/generate-definition/index.js.map +1 -1
  131. package/lib/pdf/helpers/horizontal-line/index.js +14 -14
  132. package/lib/pdf/helpers/horizontal-line/index.js.map +1 -1
  133. package/lib/pdf/helpers/html-transformer/index.js +45 -35
  134. package/lib/pdf/helpers/html-transformer/index.js.map +1 -1
  135. package/lib/pdf/helpers/index.js +194 -15
  136. package/lib/pdf/helpers/index.js.map +1 -1
  137. package/lib/pdf/helpers/parse-value/index.js +10 -4
  138. package/lib/pdf/helpers/parse-value/index.js.map +1 -1
  139. package/lib/pdf/helpers/table/index.js +136 -205
  140. package/lib/pdf/helpers/table/index.js.map +1 -1
  141. package/lib/pdf/helpers/text/index.js +11 -8
  142. package/lib/pdf/helpers/text/index.js.map +1 -1
  143. package/lib/pdf/icons/index.js +8 -2
  144. package/lib/pdf/icons/index.js.map +1 -1
  145. package/lib/pdf/index.js +47 -6
  146. package/lib/pdf/index.js.map +1 -1
  147. package/lib/pdf/issue/index.js +141 -135
  148. package/lib/pdf/issue/index.js.map +1 -1
  149. package/lib/pdf/job/index.js +95 -81
  150. package/lib/pdf/job/index.js.map +1 -1
  151. package/lib/pdf/shift-report/emptyFixtures.js +8 -2
  152. package/lib/pdf/shift-report/emptyFixtures.js.map +1 -1
  153. package/lib/pdf/shift-report/index.js +399 -521
  154. package/lib/pdf/shift-report/index.js.map +1 -1
  155. package/lib/pdf/task/index.js +89 -83
  156. package/lib/pdf/task/index.js.map +1 -1
  157. package/lib/scheduling/generators/index.js +38 -3
  158. package/lib/scheduling/generators/index.js.map +1 -1
  159. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js +44 -37
  160. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js.map +1 -1
  161. package/lib/scheduling/generators/scheduleIntervalsGenerator.js +20 -28
  162. package/lib/scheduling/generators/scheduleIntervalsGenerator.js.map +1 -1
  163. package/lib/scheduling/generators/serviceIntervalsGenerator.js +120 -150
  164. package/lib/scheduling/generators/serviceIntervalsGenerator.js.map +1 -1
  165. package/lib/scheduling/helpers/convertToTimezone.js +18 -11
  166. package/lib/scheduling/helpers/convertToTimezone.js.map +1 -1
  167. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js +57 -95
  168. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js.map +1 -1
  169. package/lib/scheduling/helpers/generateRepeatingSchedule.js +80 -119
  170. package/lib/scheduling/helpers/generateRepeatingSchedule.js.map +1 -1
  171. package/lib/scheduling/helpers/generateScheduleEnd.js +24 -14
  172. package/lib/scheduling/helpers/generateScheduleEnd.js.map +1 -1
  173. package/lib/scheduling/helpers/hasValidStartAndEnd.js +19 -11
  174. package/lib/scheduling/helpers/hasValidStartAndEnd.js.map +1 -1
  175. package/lib/scheduling/helpers/index.js +159 -14
  176. package/lib/scheduling/helpers/index.js.map +1 -1
  177. package/lib/scheduling/helpers/intervalCovers.js +13 -7
  178. package/lib/scheduling/helpers/intervalCovers.js.map +1 -1
  179. package/lib/scheduling/helpers/intervalIntersectsEnd.js +13 -7
  180. package/lib/scheduling/helpers/intervalIntersectsEnd.js.map +1 -1
  181. package/lib/scheduling/helpers/intervalIntersectsStart.js +13 -7
  182. package/lib/scheduling/helpers/intervalIntersectsStart.js.map +1 -1
  183. package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js +15 -10
  184. package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js.map +1 -1
  185. package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js +15 -10
  186. package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js.map +1 -1
  187. package/lib/scheduling/helpers/intervalOutside.js +15 -9
  188. package/lib/scheduling/helpers/intervalOutside.js.map +1 -1
  189. package/lib/scheduling/helpers/intervalWithin.js +13 -7
  190. package/lib/scheduling/helpers/intervalWithin.js.map +1 -1
  191. package/lib/scheduling/helpers/mergeIntervals.js +21 -17
  192. package/lib/scheduling/helpers/mergeIntervals.js.map +1 -1
  193. package/lib/scheduling/helpers/splitIntervals.js +24 -23
  194. package/lib/scheduling/helpers/splitIntervals.js.map +1 -1
  195. package/lib/scheduling/index.js +38 -3
  196. package/lib/scheduling/index.js.map +1 -1
  197. package/lib/scheduling/scheduling.types.js +9 -3
  198. package/lib/scheduling/scheduling.types.js.map +1 -1
  199. package/lib/scheduling/strategies/getNext.js +57 -63
  200. package/lib/scheduling/strategies/getNext.js.map +1 -1
  201. package/lib/scheduling/strategies/getNextExactDateOfMonth.js +47 -56
  202. package/lib/scheduling/strategies/getNextExactDateOfMonth.js.map +1 -1
  203. package/lib/scheduling/strategies/getNextLastDayOfMonth.js +43 -51
  204. package/lib/scheduling/strategies/getNextLastDayOfMonth.js.map +1 -1
  205. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js +49 -56
  206. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js.map +1 -1
  207. package/lib/scheduling/strategies/getNextNoRepeat.js +25 -36
  208. package/lib/scheduling/strategies/getNextNoRepeat.js.map +1 -1
  209. package/lib/scheduling/strategies/getNextWeekday.js +47 -79
  210. package/lib/scheduling/strategies/getNextWeekday.js.map +1 -1
  211. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +52 -58
  212. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js.map +1 -1
  213. package/lib/scheduling/strategies/index.js +82 -7
  214. package/lib/scheduling/strategies/index.js.map +1 -1
  215. package/lib/schema/index.js +16 -1
  216. package/lib/schema/index.js.map +1 -1
  217. package/lib/schema/schema.js +28 -34
  218. package/lib/schema/schema.js.map +1 -1
  219. package/lib/service-hours/__helpers__/calculate-hours.js +24 -22
  220. package/lib/service-hours/__helpers__/calculate-hours.js.map +1 -1
  221. package/lib/service-hours/__helpers__/isOpen.js +25 -24
  222. package/lib/service-hours/__helpers__/isOpen.js.map +1 -1
  223. package/lib/service-hours/index.js +27 -2
  224. package/lib/service-hours/index.js.map +1 -1
  225. package/lib/service-hours/schema.js +68 -55
  226. package/lib/service-hours/schema.js.map +1 -1
  227. package/package.json +86 -86
  228. package/vitest.config.ts +23 -23
  229. package/vitest.setup.js +7 -7
@@ -1,657 +1,527 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- import { filter, find, groupBy, isEmpty, map, size, sortBy, take, toString, reduce } from 'lodash';
8
- import moment from 'moment-timezone';
9
- import Promise from 'bluebird';
10
- import { generateDefinition, buildLocationScansContent, buildLocationScansBoundaries, horizontalLine, summaryStatTable, summaryWrapperTable, table, summaryFieldsTable, text, zebraFillColor } from '../helpers';
11
- import { getLocationReference, getTimezoneAbbr, getTimezoneDatetime } from '../../helpers';
12
- import { launchIcon } from '../../images';
13
- var DEFAULT_MAX_SCANS = 200;
14
- var MAX_ATTACHMENTS = 100;
15
- var LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
1
+ "use strict";
16
2
 
17
- /**
18
- * buildActivityPdf
19
- *
20
- * @param {object} pdfOptions - the pdf options
21
- * @param {string} pdfOptions.fileTitle - pdf file title
22
- * @param {function} pdfOptions.footer - function executed to generate footer
23
- * @param {function} pdfOptions.header - function executed to generate header
24
- * @param {string} pdfOptions.logoUrl - pdf logo url
25
- * @param {array} pdfOptions.pageMargins - pdf page margins
26
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
27
- * @param {string} pdfOptions.pageSize - pdf page size
28
- * @param {object} pdfOptions.styles - pdf styles
29
- * @param {object} pdfOptions.title - pdf title
30
- * @param {object} data - pdf data
31
- * @param {array} data.audits - audit documents
32
- * @param {string} data.end - end datetime of summary report
33
- * @param {array} data.events - event documents
34
- * @param {object} data.location - location document
35
- * @param {array} data.locations - location documents
36
- * @param {array} data.issues - issue documents
37
- * @param {bool} data.maxScans - max scans to include in standard report
38
- * @param {bool} data.showAlternate - show alternate summary report
39
- * @param {string} data.start - start datetime of summary report
40
- * @param {object} data.settings - settings properties
41
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
42
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
43
- * @param {array} data.tasks - task documents
44
- * @param {string} data.timestamp - timestamp string
45
- * @param {string} data.timezone - timezone string
46
- * @param {array} data.zones - zone documents
47
- * @param {array} data.users - user documents
48
- * @returns {Promise} returns pdfmake definition object
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.buildActivityPdf = buildActivityPdf;
8
+ var _lodash = require("lodash");
9
+ var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
10
+ var _bluebird = _interopRequireDefault(require("bluebird"));
11
+ var _helpers = require("../helpers");
12
+ var _helpers2 = require("../../helpers");
13
+ var _images = require("../../images");
14
+ const DEFAULT_MAX_SCANS = 200;
15
+ const MAX_ATTACHMENTS = 100;
16
+ const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
17
+
18
+ /**
19
+ * buildActivityPdf
20
+ *
21
+ * @param {object} pdfOptions - the pdf options
22
+ * @param {string} pdfOptions.fileTitle - pdf file title
23
+ * @param {function} pdfOptions.footer - function executed to generate footer
24
+ * @param {function} pdfOptions.header - function executed to generate header
25
+ * @param {string} pdfOptions.logoUrl - pdf logo url
26
+ * @param {array} pdfOptions.pageMargins - pdf page margins
27
+ * @param {string} pdfOptions.pageOrientation - pdf page orientation
28
+ * @param {string} pdfOptions.pageSize - pdf page size
29
+ * @param {object} pdfOptions.styles - pdf styles
30
+ * @param {object} pdfOptions.title - pdf title
31
+ * @param {object} data - pdf data
32
+ * @param {array} data.audits - audit documents
33
+ * @param {string} data.end - end datetime of summary report
34
+ * @param {array} data.events - event documents
35
+ * @param {object} data.location - location document
36
+ * @param {array} data.locations - location documents
37
+ * @param {array} data.issues - issue documents
38
+ * @param {bool} data.maxScans - max scans to include in standard report
39
+ * @param {bool} data.showAlternate - show alternate summary report
40
+ * @param {string} data.start - start datetime of summary report
41
+ * @param {object} data.settings - settings properties
42
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
43
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
44
+ * @param {array} data.tasks - task documents
45
+ * @param {string} data.timestamp - timestamp string
46
+ * @param {string} data.timezone - timezone string
47
+ * @param {array} data.zones - zone documents
48
+ * @param {array} data.users - user documents
49
+ * @returns {Promise} returns pdfmake definition object
49
50
  */
50
- export function buildActivityPdf(_x, _x2) {
51
- return _buildActivityPdf.apply(this, arguments);
52
- }
53
- function _buildActivityPdf() {
54
- _buildActivityPdf = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(pdfOptions, data) {
55
- var timestamp, timezone, title, content;
56
- return _regeneratorRuntime.wrap(function (_context) {
57
- while (1) switch (_context.prev = _context.next) {
58
- case 0:
59
- timestamp = data.timestamp, timezone = data.timezone;
60
- title = 'Daily Activity Report';
61
- _context.next = 1;
62
- return generateContent(data);
63
- case 1:
64
- content = _context.sent;
65
- return _context.abrupt("return", generateDefinition(_objectSpread({
66
- content: content,
67
- fileTitle: title,
68
- timestamp: timestamp,
69
- timezone: timezone,
70
- type: 'Activity Summary'
71
- }, pdfOptions)));
72
- case 2:
73
- case "end":
74
- return _context.stop();
75
- }
76
- }, _callee);
77
- }));
78
- return _buildActivityPdf.apply(this, arguments);
79
- }
80
- function generateContent(_x3) {
81
- return _generateContent.apply(this, arguments);
82
- }
83
- function _generateContent() {
84
- _generateContent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
85
- var activitySection, summarySection, titleTable;
86
- return _regeneratorRuntime.wrap(function (_context2) {
87
- while (1) switch (_context2.prev = _context2.next) {
88
- case 0:
89
- _context2.next = 1;
90
- return buildActivitySection(data);
91
- case 1:
92
- activitySection = _context2.sent;
93
- summarySection = buildSummarySection(data);
94
- titleTable = buildTitleTable(data);
95
- return _context2.abrupt("return", [titleTable, summarySection, activitySection]);
96
- case 2:
97
- case "end":
98
- return _context2.stop();
99
- }
100
- }, _callee2);
101
- }));
102
- return _generateContent.apply(this, arguments);
103
- }
104
- function buildActivitySection(_x4) {
105
- return _buildActivitySection.apply(this, arguments);
106
- }
107
- function _buildActivitySection() {
108
- _buildActivitySection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
109
- var _data$showAlternate, showAlternate, locationScans, otherActivity, activitySummary;
110
- return _regeneratorRuntime.wrap(function (_context3) {
111
- while (1) switch (_context3.prev = _context3.next) {
112
- case 0:
113
- _data$showAlternate = data.showAlternate, showAlternate = _data$showAlternate === void 0 ? false : _data$showAlternate;
114
- if (!showAlternate) {
115
- _context3.next = 2;
116
- break;
117
- }
118
- locationScans = buildLocationScansSection(data);
119
- _context3.next = 1;
120
- return buildOtherActivitySection(data);
121
- case 1:
122
- otherActivity = _context3.sent;
123
- return _context3.abrupt("return", [locationScans, otherActivity]);
124
- case 2:
125
- _context3.next = 3;
126
- return buildActivitySummarySection(data);
127
- case 3:
128
- activitySummary = _context3.sent;
129
- return _context3.abrupt("return", [activitySummary]);
130
- case 4:
131
- case "end":
132
- return _context3.stop();
133
- }
134
- }, _callee3);
135
- }));
136
- return _buildActivitySection.apply(this, arguments);
51
+ async function buildActivityPdf(pdfOptions, data) {
52
+ const {
53
+ timestamp,
54
+ timezone
55
+ } = data;
56
+ const title = 'Daily Activity Report';
57
+ const content = await generateContent(data);
58
+ return (0, _helpers.generateDefinition)({
59
+ content,
60
+ fileTitle: title,
61
+ timestamp,
62
+ timezone,
63
+ type: 'Activity Summary',
64
+ ...pdfOptions
65
+ });
137
66
  }
138
- function buildActivitySummarySection(_x5) {
139
- return _buildActivitySummarySection.apply(this, arguments);
67
+ async function generateContent(data) {
68
+ const activitySection = await buildActivitySection(data);
69
+ const summarySection = buildSummarySection(data);
70
+ const titleTable = buildTitleTable(data);
71
+ return [titleTable, summarySection, activitySection];
140
72
  }
141
- function _buildActivitySummarySection() {
142
- _buildActivitySummarySection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
143
- var audits, events, issues, _data$maxScans, maxScans, settings, tasks, timezone, enterEvents, exceedsMaxScans, scans, auditRows, issueRows, scanRows, taskRows, formCount, exceedsMaxForms, rows, sortedRows, title, header, hLine, activityTable, activitySummarySection, maxScansText, maxFormsText;
144
- return _regeneratorRuntime.wrap(function (_context4) {
145
- while (1) switch (_context4.prev = _context4.next) {
146
- case 0:
147
- audits = data.audits, events = data.events, issues = data.issues, _data$maxScans = data.maxScans, maxScans = _data$maxScans === void 0 ? DEFAULT_MAX_SCANS : _data$maxScans, settings = data.settings, tasks = data.tasks, timezone = data.timezone;
148
- enterEvents = filter(events, function (event) {
149
- return event.type === 'enter';
150
- });
151
- exceedsMaxScans = size(enterEvents) > maxScans;
152
- scans = take(enterEvents, maxScans);
153
- auditRows = map(audits, getFormRowData('audits', data));
154
- issueRows = map(issues, getFormRowData('issues', data));
155
- scanRows = map(scans, getScanRowData(data));
156
- taskRows = map(tasks, getFormRowData('tasks', data));
157
- formCount = size([].concat(_toConsumableArray(auditRows), _toConsumableArray(issueRows), _toConsumableArray(taskRows)));
158
- exceedsMaxForms = formCount > MAX_ATTACHMENTS;
159
- rows = [].concat(_toConsumableArray(auditRows), _toConsumableArray(issueRows), _toConsumableArray(scanRows), _toConsumableArray(taskRows));
160
- sortedRows = sortBy(rows, ['timestamp'], ['asc']);
161
- title = text('Activity Summary', {
162
- style: 'summarySectionHeader'
163
- });
164
- header = table({
165
- body: [[title]],
166
- layout: 'noBorders',
167
- style: 'summaryHeaderTable'
168
- });
169
- hLine = horizontalLine();
170
- _context4.next = 1;
171
- return buildActivityTable({
172
- rows: sortedRows,
173
- settings: settings,
174
- timezone: timezone
175
- });
176
- case 1:
177
- activityTable = _context4.sent;
178
- activitySummarySection = [header, hLine, activityTable];
179
- if (exceedsMaxScans) {
180
- maxScansText = {
181
- text: [text("Location Scans in the Daily Activity Report are limited to a total of ".concat(maxScans, ".")), text(' To view all Location Scans visit '), text('the Events Report', {
182
- link: "".concat(LIGHTHOUSE_BASE_URL, "/reports/events")
183
- }), text(' in the Lighthouse Management Console.')],
184
- style: 'small',
185
- margin: [0, 10, 0, 10]
186
- };
187
- activitySummarySection.push(maxScansText);
188
- }
189
- if (exceedsMaxForms) {
190
- maxFormsText = {
191
- text: [text("Detailed Form Submissions in the Daily Activity Report are limited to a total of ".concat(MAX_ATTACHMENTS, ". ")), text('To access individual Form Submissions, open the hyperlink next to the respective submission within the Activity Summary table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
192
- style: 'small',
193
- margin: [0, 10, 0, 10]
194
- };
195
- activitySummarySection.push(maxFormsText);
196
- }
197
- return _context4.abrupt("return", activitySummarySection);
198
- case 2:
199
- case "end":
200
- return _context4.stop();
201
- }
202
- }, _callee4);
203
- }));
204
- return _buildActivitySummarySection.apply(this, arguments);
73
+ async function buildActivitySection(data) {
74
+ const {
75
+ showAlternate = false
76
+ } = data;
77
+ if (showAlternate) {
78
+ const locationScans = buildLocationScansSection(data);
79
+ const otherActivity = await buildOtherActivitySection(data);
80
+ return [locationScans, otherActivity];
81
+ }
82
+ const activitySummary = await buildActivitySummarySection(data);
83
+ return [activitySummary];
205
84
  }
206
- function buildActivityTable(_x6) {
207
- return _buildActivityTable.apply(this, arguments);
85
+ async function buildActivitySummarySection(data) {
86
+ const {
87
+ audits,
88
+ events,
89
+ issues,
90
+ maxScans = DEFAULT_MAX_SCANS,
91
+ settings,
92
+ tasks,
93
+ timezone
94
+ } = data;
95
+ const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
96
+ const exceedsMaxScans = (0, _lodash.size)(enterEvents) > maxScans;
97
+ const scans = (0, _lodash.take)(enterEvents, maxScans);
98
+ const auditRows = (0, _lodash.map)(audits, getFormRowData('audits', data));
99
+ const issueRows = (0, _lodash.map)(issues, getFormRowData('issues', data));
100
+ const scanRows = (0, _lodash.map)(scans, getScanRowData(data));
101
+ const taskRows = (0, _lodash.map)(tasks, getFormRowData('tasks', data));
102
+ const formCount = (0, _lodash.size)([...auditRows, ...issueRows, ...taskRows]);
103
+ const exceedsMaxForms = formCount > MAX_ATTACHMENTS;
104
+ const rows = [...auditRows, ...issueRows, ...scanRows, ...taskRows];
105
+ const sortedRows = (0, _lodash.sortBy)(rows, ['timestamp'], ['asc']);
106
+ const title = (0, _helpers.text)('Activity Summary', {
107
+ style: 'summarySectionHeader'
108
+ });
109
+ const header = (0, _helpers.table)({
110
+ body: [[title]],
111
+ layout: 'noBorders',
112
+ style: 'summaryHeaderTable'
113
+ });
114
+ const hLine = (0, _helpers.horizontalLine)();
115
+ const activityTable = await buildActivityTable({
116
+ rows: sortedRows,
117
+ settings,
118
+ timezone
119
+ });
120
+ const activitySummarySection = [header, hLine, activityTable];
121
+ if (exceedsMaxScans) {
122
+ const maxScansText = {
123
+ text: [(0, _helpers.text)(`Location Scans in the Daily Activity Report are limited to a total of ${maxScans}.`), (0, _helpers.text)(' To view all Location Scans visit '), (0, _helpers.text)('the Events Report', {
124
+ link: `${LIGHTHOUSE_BASE_URL}/reports/events`
125
+ }), (0, _helpers.text)(' in the Lighthouse Management Console.')],
126
+ style: 'small',
127
+ margin: [0, 10, 0, 10]
128
+ };
129
+ activitySummarySection.push(maxScansText);
130
+ }
131
+ if (exceedsMaxForms) {
132
+ const maxFormsText = {
133
+ text: [(0, _helpers.text)(`Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `), (0, _helpers.text)('To access individual Form Submissions, open the hyperlink next to the respective submission within the Activity Summary table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
134
+ style: 'small',
135
+ margin: [0, 10, 0, 10]
136
+ };
137
+ activitySummarySection.push(maxFormsText);
138
+ }
139
+ return activitySummarySection;
208
140
  }
209
- function _buildActivityTable() {
210
- _buildActivityTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref) {
211
- var rows, settings, timezone, timezoneAbbr, activityTableHeader, activityTableRows, activityTableBody, activityTable;
212
- return _regeneratorRuntime.wrap(function (_context6) {
213
- while (1) switch (_context6.prev = _context6.next) {
214
- case 0:
215
- rows = _ref.rows, settings = _ref.settings, timezone = _ref.timezone;
216
- timezoneAbbr = getTimezoneAbbr(timezone);
217
- activityTableHeader = [text('Activity', {
218
- bold: true
219
- }), {
220
- text: ''
221
- },
222
- // icon column
223
- text('Location', {
224
- bold: true
225
- }), text('User', {
226
- bold: true
227
- }), text("Timestamp (".concat(timezoneAbbr, ")"), {
228
- alignment: 'right',
229
- bold: true
230
- })];
231
- _context6.next = 1;
232
- return Promise.map(rows, /*#__PURE__*/function () {
233
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data) {
234
- var link, location, icon, name, summaryFields, timestamp, title, timezoneHour, iconCell, rows, hasSummaryFields, fieldsTable, activityTableRow;
235
- return _regeneratorRuntime.wrap(function (_context5) {
236
- while (1) switch (_context5.prev = _context5.next) {
237
- case 0:
238
- link = data.link, location = data.location, icon = data.icon, name = data.name, summaryFields = data.summaryFields, timestamp = data.timestamp, title = data.title;
239
- timezoneHour = getTimezoneDatetime({
240
- format: 'ddd DD h:mm a',
241
- showTzAbbr: false,
242
- timestamp: timestamp,
243
- timezone: timezone
244
- });
245
- iconCell = icon ? {
246
- alignment: 'center',
247
- fit: [8, 8],
248
- image: icon,
249
- link: link
250
- } : {
251
- text: ''
252
- }; // NOTE: pass link to each column as
253
- // we can't wrap the entire table row
254
- rows = [[text(title, {
255
- link: link
256
- }), iconCell, text(location, {
257
- link: link
258
- }), text(name, {
259
- link: link
260
- }), text(timezoneHour, {
261
- alignment: 'right',
262
- link: link
263
- })]];
264
- hasSummaryFields = !isEmpty(summaryFields);
265
- if (!hasSummaryFields) {
266
- _context5.next = 2;
267
- break;
268
- }
269
- _context5.next = 1;
270
- return summaryFieldsTable({
271
- fields: summaryFields,
272
- settings: settings,
273
- timezone: timezone
274
- });
275
- case 1:
276
- fieldsTable = _context5.sent;
277
- rows.push([fieldsTable]);
278
- case 2:
279
- // NOTE: we return a table per row which includes the entry details and the
280
- // summary fields if relevant
281
- activityTableRow = [table({
282
- body: [].concat(rows),
283
- colSpan: 5,
284
- dontBreakRows: true,
285
- headerRow: 0,
286
- layout: {
287
- hLineWidth: function hLineWidth() {
288
- return 0;
289
- },
290
- paddingLeft: function paddingLeft() {
291
- return 0;
292
- },
293
- paddingRight: function paddingRight() {
294
- return 0;
295
- },
296
- paddingTop: function paddingTop() {
297
- return 5;
298
- },
299
- paddingBottom: function paddingBottom() {
300
- return 5;
301
- },
302
- vLineWidth: function vLineWidth() {
303
- return 0;
304
- }
305
- },
306
- // NOTE: the timestamp must fill up the rest of the table space as
307
- // otherwise the padding would be off between this table and the parent
308
- // table that wraps it
309
- widths: [130, 25, 110, 110, '*']
310
- })];
311
- return _context5.abrupt("return", activityTableRow);
312
- case 3:
313
- case "end":
314
- return _context5.stop();
315
- }
316
- }, _callee5);
317
- }));
318
- return function (_x8) {
319
- return _ref4.apply(this, arguments);
320
- };
321
- }());
322
- case 1:
323
- activityTableRows = _context6.sent;
324
- activityTableBody = isEmpty(activityTableRows) ? [[text('No other activity', {
325
- colSpan: 5
326
- })]] : activityTableRows;
327
- activityTable = table({
328
- body: [activityTableHeader].concat(_toConsumableArray(activityTableBody)),
329
- dontBreakRows: true,
330
- layout: {
331
- hLineWidth: function hLineWidth() {
332
- return 0;
333
- },
334
- fillColor: zebraFillColor,
335
- paddingLeft: function paddingLeft() {
336
- return 5;
337
- },
338
- paddingRight: function paddingRight() {
339
- return 5;
340
- },
341
- paddingTop: function paddingTop() {
342
- return 5;
343
- },
344
- paddingBottom: function paddingBottom() {
345
- return 5;
346
- },
347
- vLineWidth: function vLineWidth() {
348
- return 0;
349
- }
350
- },
351
- widths: [120, 15, 100, 100, '*']
352
- });
353
- return _context6.abrupt("return", activityTable);
354
- case 2:
355
- case "end":
356
- return _context6.stop();
357
- }
358
- }, _callee6);
359
- }));
360
- return _buildActivityTable.apply(this, arguments);
141
+ async function buildActivityTable({
142
+ rows,
143
+ settings,
144
+ timezone
145
+ }) {
146
+ const timezoneAbbr = (0, _helpers2.getTimezoneAbbr)(timezone);
147
+ const activityTableHeader = [(0, _helpers.text)('Activity', {
148
+ bold: true
149
+ }), {
150
+ text: ''
151
+ },
152
+ // icon column
153
+ (0, _helpers.text)('Location', {
154
+ bold: true
155
+ }), (0, _helpers.text)('User', {
156
+ bold: true
157
+ }), (0, _helpers.text)(`Timestamp (${timezoneAbbr})`, {
158
+ alignment: 'right',
159
+ bold: true
160
+ })];
161
+ const activityTableRows = await _bluebird.default.map(rows, async function (data) {
162
+ const {
163
+ link,
164
+ location,
165
+ icon,
166
+ name,
167
+ summaryFields,
168
+ timestamp,
169
+ title
170
+ } = data;
171
+ const timezoneHour = (0, _helpers2.getTimezoneDatetime)({
172
+ format: 'ddd DD h:mm a',
173
+ showTzAbbr: false,
174
+ timestamp,
175
+ timezone
176
+ });
177
+ const iconCell = icon ? {
178
+ alignment: 'center',
179
+ fit: [8, 8],
180
+ image: icon,
181
+ link
182
+ } : {
183
+ text: ''
184
+ };
185
+
186
+ // NOTE: pass link to each column as
187
+ // we can't wrap the entire table row
188
+ const rows = [[(0, _helpers.text)(title, {
189
+ link
190
+ }), iconCell, (0, _helpers.text)(location, {
191
+ link
192
+ }), (0, _helpers.text)(name, {
193
+ link
194
+ }), (0, _helpers.text)(timezoneHour, {
195
+ alignment: 'right',
196
+ link
197
+ })]];
198
+ const hasSummaryFields = !(0, _lodash.isEmpty)(summaryFields);
199
+ if (hasSummaryFields) {
200
+ const fieldsTable = await (0, _helpers.summaryFieldsTable)({
201
+ fields: summaryFields,
202
+ settings,
203
+ timezone
204
+ });
205
+ rows.push([fieldsTable]);
206
+ }
207
+
208
+ // NOTE: we return a table per row which includes the entry details and the
209
+ // summary fields if relevant
210
+ const activityTableRow = [(0, _helpers.table)({
211
+ body: [...rows],
212
+ colSpan: 5,
213
+ dontBreakRows: true,
214
+ headerRow: 0,
215
+ layout: {
216
+ hLineWidth: () => 0,
217
+ paddingLeft: () => 0,
218
+ paddingRight: () => 0,
219
+ paddingTop: () => 5,
220
+ paddingBottom: () => 5,
221
+ vLineWidth: () => 0
222
+ },
223
+ // NOTE: the timestamp must fill up the rest of the table space as
224
+ // otherwise the padding would be off between this table and the parent
225
+ // table that wraps it
226
+ widths: [130, 25, 110, 110, '*']
227
+ })];
228
+ return activityTableRow;
229
+ });
230
+ const activityTableBody = (0, _lodash.isEmpty)(activityTableRows) ? [[(0, _helpers.text)('No other activity', {
231
+ colSpan: 5
232
+ })]] : activityTableRows;
233
+ const activityTable = (0, _helpers.table)({
234
+ body: [activityTableHeader, ...activityTableBody],
235
+ dontBreakRows: true,
236
+ layout: {
237
+ hLineWidth: () => 0,
238
+ fillColor: _helpers.zebraFillColor,
239
+ paddingLeft: () => 5,
240
+ paddingRight: () => 5,
241
+ paddingTop: () => 5,
242
+ paddingBottom: () => 5,
243
+ vLineWidth: () => 0
244
+ },
245
+ widths: [120, 15, 100, 100, '*']
246
+ });
247
+ return activityTable;
361
248
  }
362
249
  function buildLocationScansSection(data) {
363
- var events = data.events,
364
- start = data.start,
365
- timezone = data.timezone,
366
- zones = data.zones;
367
- var title = text('Location Scans', {
250
+ const {
251
+ events,
252
+ start,
253
+ timezone,
254
+ zones
255
+ } = data;
256
+ const title = (0, _helpers.text)('Location Scans', {
368
257
  style: 'summarySectionHeader'
369
258
  });
370
- var header = table({
259
+ const header = (0, _helpers.table)({
371
260
  body: [[title]],
372
261
  layout: 'noBorders',
373
262
  style: 'summaryHeaderTable'
374
263
  });
375
264
 
376
265
  // use start time and timezone to figure out the interval boundaries
377
- var hourIntervalBoundaries = buildLocationScansBoundaries(start, timezone);
266
+ const hourIntervalBoundaries = (0, _helpers.buildLocationScansBoundaries)(start, timezone);
378
267
 
379
268
  // pair interval boundaries into column headers for the table
380
- var hourIntervalColumnHeaders = hourIntervalBoundaries.reduce(function (columns, interval, index, intervals) {
381
- if (index < size(intervals) - 1)
269
+ const hourIntervalColumnHeaders = hourIntervalBoundaries.reduce((columns, interval, index, intervals) => {
270
+ if (index < (0, _lodash.size)(intervals) - 1)
382
271
  // skip the final iteration as it's just the end of the last interval
383
- columns.push(text("".concat(interval.format('h'), "-").concat(intervals[index + 1].format('hA')), {
272
+ columns.push((0, _helpers.text)(`${interval.format('h')}-${intervals[index + 1].format('hA')}`, {
384
273
  alignment: 'center',
385
274
  bold: true
386
275
  }));
387
276
  return columns;
388
277
  }, []);
389
- var scansTableHeader = [text('Location', {
278
+ const scansTableHeader = [(0, _helpers.text)('Location', {
390
279
  bold: true
391
- })].concat(_toConsumableArray(hourIntervalColumnHeaders), [text('Total', {
280
+ }), ...hourIntervalColumnHeaders, (0, _helpers.text)('Total', {
392
281
  alignment: 'right',
393
282
  bold: true
394
- })]);
395
- var hLine = horizontalLine();
283
+ })];
284
+ const hLine = (0, _helpers.horizontalLine)();
396
285
 
397
286
  // NOTE: only show the enter events within the summary table
398
- var enterEvents = filter(events, function (event) {
399
- return event.type === 'enter';
400
- });
401
- var sortedZones = sortBy(zones, ['name']);
402
- var groupedEventsByZone = reduce(sortedZones, function (memo, zone) {
403
- var zoneEvents = filter(enterEvents, function (event) {
404
- return event.zone && event.zone.toString() === zone._id.toString();
405
- });
287
+ const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
288
+ const sortedZones = (0, _lodash.sortBy)(zones, ['name']);
289
+ const groupedEventsByZone = (0, _lodash.reduce)(sortedZones, (memo, zone) => {
290
+ const zoneEvents = (0, _lodash.filter)(enterEvents, event => event.zone && event.zone.toString() === zone._id.toString());
406
291
  memo[zone._id] = zoneEvents;
407
292
  return memo;
408
293
  }, {});
409
- var scansTableRows = map(groupedEventsByZone, function (events) {
410
- var zone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
411
- var sortedGroup = sortBy(events, ['timestamp'], ['asc']);
294
+ const scansTableRows = (0, _lodash.map)(groupedEventsByZone, (events, zone = '') => {
295
+ const sortedGroup = (0, _lodash.sortBy)(events, ['timestamp'], ['asc']);
412
296
 
413
297
  // put events into interval buckets
414
- var locationScansByInterval = buildLocationScansContent(hourIntervalBoundaries, events);
298
+ const locationScansByInterval = (0, _helpers.buildLocationScansContent)(hourIntervalBoundaries, events);
415
299
  // map the interval buckets to a format fit for the table
416
- var locationScansByIntervalContent = locationScansByInterval.map(function (interval) {
300
+ const locationScansByIntervalContent = locationScansByInterval.map(interval => {
417
301
  return {
418
302
  alignment: 'center',
419
- text: size(interval)
303
+ text: (0, _lodash.size)(interval)
420
304
  };
421
305
  });
422
- var totalEvents = size(sortedGroup);
423
- var zoneDoc = zone && find(zones, function (doc) {
424
- return doc._id.toString() === zone.toString();
425
- });
426
- var zoneName = zoneDoc && zoneDoc.name || 'Unknown Location';
427
- return [zoneName].concat(_toConsumableArray(locationScansByIntervalContent), [{
306
+ const totalEvents = (0, _lodash.size)(sortedGroup);
307
+ const zoneDoc = zone && (0, _lodash.find)(zones, doc => doc._id.toString() === zone.toString());
308
+ const zoneName = zoneDoc && zoneDoc.name || 'Unknown Location';
309
+ return [zoneName, ...locationScansByIntervalContent, {
428
310
  alignment: 'right',
429
311
  bold: true,
430
312
  text: totalEvents
431
- }]);
313
+ }];
432
314
  });
433
- var scansTableBody = isEmpty(scansTableRows) ? [[text('No location scans', {
315
+ const scansTableBody = (0, _lodash.isEmpty)(scansTableRows) ? [[(0, _helpers.text)('No location scans', {
434
316
  colSpan: 10
435
317
  })]] : scansTableRows;
436
- var scansTable = table({
437
- body: [scansTableHeader].concat(_toConsumableArray(scansTableBody)),
318
+ const scansTable = (0, _helpers.table)({
319
+ body: [scansTableHeader, ...scansTableBody],
438
320
  widths: [100, '*', '*', '*', '*', '*', '*', '*', '*', '*']
439
321
  });
440
322
  return [header, hLine, scansTable];
441
323
  }
442
324
  function buildSummarySection(data) {
443
- var audits = data.audits,
444
- events = data.events,
445
- issues = data.issues,
446
- tasks = data.tasks;
325
+ const {
326
+ audits,
327
+ events,
328
+ issues,
329
+ tasks
330
+ } = data;
447
331
 
448
332
  //const userEvents = groupBy(events, 'user')
449
- var eventsByType = groupBy(events, 'type');
450
- var enterEventsCount = size(eventsByType.enter);
333
+ const eventsByType = (0, _lodash.groupBy)(events, 'type');
334
+ const enterEventsCount = (0, _lodash.size)(eventsByType.enter);
451
335
  //const geoEventsCount = size(eventsByType.geo)
452
- var issuesCount = size(issues);
453
- var tasksCount = size(tasks);
454
- var auditsCount = size(audits);
336
+ const issuesCount = (0, _lodash.size)(issues);
337
+ const tasksCount = (0, _lodash.size)(tasks);
338
+ const auditsCount = (0, _lodash.size)(audits);
455
339
  //const uniqueUsers = size(userEvents)
456
340
 
457
- var auditsText = text('AUDITS', {
341
+ const auditsText = (0, _helpers.text)('AUDITS', {
458
342
  style: 'summaryText'
459
343
  });
460
344
  //const geoText = text('GPS', { style: 'summaryText' })
461
- var issuesText = text('ISSUES', {
345
+ const issuesText = (0, _helpers.text)('ISSUES', {
462
346
  style: 'summaryText'
463
347
  });
464
348
  //const peopleText = text('PEOPLE', { style: 'summaryText' })
465
- var scansText = text('SCANS', {
349
+ const scansText = (0, _helpers.text)('SCANS', {
466
350
  style: 'summaryText'
467
351
  });
468
- var tasksText = text('TASKS', {
352
+ const tasksText = (0, _helpers.text)('TASKS', {
469
353
  style: 'summaryText'
470
354
  });
471
- var auditsCountText = text(toString(auditsCount), {
355
+ const auditsCountText = (0, _helpers.text)((0, _lodash.toString)(auditsCount), {
472
356
  style: 'summaryCount'
473
357
  });
474
358
  //const peopleCountText = text(toString(uniqueUsers), { style: 'summaryCount' })
475
- var scansCountText = text(toString(enterEventsCount), {
359
+ const scansCountText = (0, _helpers.text)((0, _lodash.toString)(enterEventsCount), {
476
360
  style: 'summaryCount'
477
361
  });
478
362
  //const geoCountText = text(toString(geoEventsCount), { style: 'summaryCount' })
479
- var issuesCountText = text(toString(issuesCount), {
363
+ const issuesCountText = (0, _helpers.text)((0, _lodash.toString)(issuesCount), {
480
364
  style: 'summaryCount'
481
365
  });
482
- var tasksCountText = text(toString(tasksCount), {
366
+ const tasksCountText = (0, _helpers.text)((0, _lodash.toString)(tasksCount), {
483
367
  style: 'summaryCount'
484
368
  });
485
- var auditTable = summaryStatTable({
369
+ const auditTable = (0, _helpers.summaryStatTable)({
486
370
  body: [[auditsText], [auditsCountText]]
487
371
  });
488
372
  //const peopleTable = summaryStatTable({
489
373
  // body: [[peopleText], [peopleCountText]],
490
374
  //})
491
375
  //const gpsTable = summaryStatTable({ body: [[geoText], [geoCountText]] })
492
- var scanTable = summaryStatTable({
376
+ const scanTable = (0, _helpers.summaryStatTable)({
493
377
  body: [[scansText], [scansCountText]]
494
378
  });
495
- var issueTable = summaryStatTable({
379
+ const issueTable = (0, _helpers.summaryStatTable)({
496
380
  body: [[issuesText], [issuesCountText]]
497
381
  });
498
- var taskTables = summaryStatTable({
382
+ const taskTables = (0, _helpers.summaryStatTable)({
499
383
  body: [[tasksText], [tasksCountText]]
500
384
  });
501
- var wrapperTable = summaryWrapperTable({
385
+ const wrapperTable = (0, _helpers.summaryWrapperTable)({
502
386
  body: [[/*peopleTable,*/
503
387
  /*gpsTable,*/
504
388
  scanTable, issueTable, taskTables, auditTable]]
505
389
  });
506
390
  return wrapperTable;
507
391
  }
508
- function buildOtherActivitySection(_x7) {
509
- return _buildOtherActivitySection.apply(this, arguments);
510
- }
511
- function _buildOtherActivitySection() {
512
- _buildOtherActivitySection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data) {
513
- var audits, issues, tasks, settings, timezone, auditRows, issueRows, taskRows, rows, sortedRows, title, header, hLine, activityTable, otherActivitySummarySection, formCount, exceedsMaxForms, maxFormsText;
514
- return _regeneratorRuntime.wrap(function (_context7) {
515
- while (1) switch (_context7.prev = _context7.next) {
516
- case 0:
517
- audits = data.audits, issues = data.issues, tasks = data.tasks, settings = data.settings, timezone = data.timezone;
518
- auditRows = map(audits, getFormRowData('audits', data));
519
- issueRows = map(issues, getFormRowData('issues', data));
520
- taskRows = map(tasks, getFormRowData('tasks', data));
521
- rows = [].concat(_toConsumableArray(auditRows), _toConsumableArray(issueRows), _toConsumableArray(taskRows));
522
- sortedRows = sortBy(rows, ['timestamp'], ['asc']);
523
- title = text('Other Activity', {
524
- style: 'summarySectionHeader'
525
- });
526
- header = table({
527
- body: [[title]],
528
- layout: 'noBorders',
529
- style: 'summaryHeaderTable'
530
- });
531
- hLine = horizontalLine();
532
- _context7.next = 1;
533
- return buildActivityTable({
534
- rows: sortedRows,
535
- settings: settings,
536
- timezone: timezone
537
- });
538
- case 1:
539
- activityTable = _context7.sent;
540
- otherActivitySummarySection = [header, hLine, activityTable];
541
- formCount = size(rows);
542
- exceedsMaxForms = formCount > MAX_ATTACHMENTS;
543
- if (exceedsMaxForms) {
544
- maxFormsText = {
545
- text: [text("Detailed Form Submissions in the Daily Activity Report are limited to a total of ".concat(MAX_ATTACHMENTS, ". ")), text('To access individual Form Submissions, open the hyperlink next to the respective submission within the Other Activity table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
546
- style: 'small',
547
- margin: [0, 10, 0, 10]
548
- };
549
- otherActivitySummarySection.push(maxFormsText);
550
- }
551
- return _context7.abrupt("return", otherActivitySummarySection);
552
- case 2:
553
- case "end":
554
- return _context7.stop();
555
- }
556
- }, _callee7);
557
- }));
558
- return _buildOtherActivitySection.apply(this, arguments);
392
+ async function buildOtherActivitySection(data) {
393
+ const {
394
+ audits,
395
+ issues,
396
+ tasks,
397
+ settings,
398
+ timezone
399
+ } = data;
400
+ const auditRows = (0, _lodash.map)(audits, getFormRowData('audits', data));
401
+ const issueRows = (0, _lodash.map)(issues, getFormRowData('issues', data));
402
+ const taskRows = (0, _lodash.map)(tasks, getFormRowData('tasks', data));
403
+ const rows = [...auditRows, ...issueRows, ...taskRows];
404
+ const sortedRows = (0, _lodash.sortBy)(rows, ['timestamp'], ['asc']);
405
+ const title = (0, _helpers.text)('Other Activity', {
406
+ style: 'summarySectionHeader'
407
+ });
408
+ const header = (0, _helpers.table)({
409
+ body: [[title]],
410
+ layout: 'noBorders',
411
+ style: 'summaryHeaderTable'
412
+ });
413
+ const hLine = (0, _helpers.horizontalLine)();
414
+ const activityTable = await buildActivityTable({
415
+ rows: sortedRows,
416
+ settings,
417
+ timezone
418
+ });
419
+ const otherActivitySummarySection = [header, hLine, activityTable];
420
+ const formCount = (0, _lodash.size)(rows);
421
+ const exceedsMaxForms = formCount > MAX_ATTACHMENTS;
422
+ if (exceedsMaxForms) {
423
+ const maxFormsText = {
424
+ text: [(0, _helpers.text)(`Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `), (0, _helpers.text)('To access individual Form Submissions, open the hyperlink next to the respective submission within the Other Activity table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
425
+ style: 'small',
426
+ margin: [0, 10, 0, 10]
427
+ };
428
+ otherActivitySummarySection.push(maxFormsText);
429
+ }
430
+ return otherActivitySummarySection;
559
431
  }
560
432
  function buildTitleTable(data) {
561
- var location = data.location,
562
- start = data.start,
563
- end = data.end,
564
- timezone = data.timezone;
565
- var _location$address = location.address,
566
- address = _location$address === void 0 ? {} : _location$address;
567
- var headerTitle = text('Daily Activity Report', {
433
+ const {
434
+ location,
435
+ start,
436
+ end,
437
+ timezone
438
+ } = data;
439
+ const {
440
+ address = {}
441
+ } = location;
442
+ const headerTitle = (0, _helpers.text)('Daily Activity Report', {
568
443
  style: 'title'
569
444
  });
570
- var headerSubTitle = text(location.name, {
445
+ const headerSubTitle = (0, _helpers.text)(location.name, {
571
446
  style: 'subTitle'
572
447
  });
573
- var addressText = !isEmpty(address) ? "".concat(address.street, ", ").concat(address.city || '', " ").concat(address.state || '', " ").concat(address.postalCode || '') : '';
574
- var headerAddress = text(addressText, {
448
+ const addressText = !(0, _lodash.isEmpty)(address) ? `${address.street}, ${address.city || ''} ${address.state || ''} ${address.postalCode || ''}` : '';
449
+ const headerAddress = (0, _helpers.text)(addressText, {
575
450
  style: 'small'
576
451
  });
577
- var mTimezoneStart = moment.tz(start, timezone);
578
- var mTimezoneEnd = moment.tz(end, timezone);
579
- var timezoneAbbr = getTimezoneAbbr(timezone);
580
- var rangeStart = moment(mTimezoneStart).format('MMM DD h:mma');
581
- var rangeEnd = moment(mTimezoneEnd).add(1, 'hour').startOf('hour').format('MMM DD h:mma');
582
- var headerRange = text("".concat(rangeStart, " - ").concat(rangeEnd, " (").concat(timezoneAbbr, ")"), {
452
+ const mTimezoneStart = _momentTimezone.default.tz(start, timezone);
453
+ const mTimezoneEnd = _momentTimezone.default.tz(end, timezone);
454
+ const timezoneAbbr = (0, _helpers2.getTimezoneAbbr)(timezone);
455
+ const rangeStart = (0, _momentTimezone.default)(mTimezoneStart).format('MMM DD h:mma');
456
+ const rangeEnd = (0, _momentTimezone.default)(mTimezoneEnd).add(1, 'hour').startOf('hour').format('MMM DD h:mma');
457
+ const headerRange = (0, _helpers.text)(`${rangeStart} - ${rangeEnd} (${timezoneAbbr})`, {
583
458
  style: 'subTitle2'
584
459
  });
585
- var body = !isEmpty(address) ? [[headerTitle], [headerSubTitle], [headerAddress], [headerRange]] : [[headerTitle], [headerSubTitle], [headerRange]];
586
- return table({
587
- body: body,
460
+ const body = !(0, _lodash.isEmpty)(address) ? [[headerTitle], [headerSubTitle], [headerAddress], [headerRange]] : [[headerTitle], [headerSubTitle], [headerRange]];
461
+ return (0, _helpers.table)({
462
+ body,
588
463
  layout: 'noBorders',
589
464
  style: 'titleTable'
590
465
  });
591
466
  }
592
- function getFormRowData(collection, _ref2) {
593
- var locations = _ref2.locations,
594
- users = _ref2.users,
595
- zones = _ref2.zones;
596
- return function (document) {
597
- var _id = document._id,
598
- createdAt = document.createdAt,
599
- _document$entry = document.entry,
600
- entry = _document$entry === void 0 ? {} : _document$entry,
601
- _document$title = document.title,
602
- title = _document$title === void 0 ? 'Unknown' : _document$title,
603
- _document$user = document.user,
604
- user = _document$user === void 0 ? '' : _document$user;
605
- var location = getLocationReference({
467
+ function getFormRowData(collection, {
468
+ locations,
469
+ users,
470
+ zones
471
+ }) {
472
+ return document => {
473
+ const {
474
+ _id,
475
+ createdAt,
476
+ entry = {},
477
+ title = 'Unknown',
478
+ user = ''
479
+ } = document;
480
+ const location = (0, _helpers2.getLocationReference)({
606
481
  entity: document,
607
- locations: locations,
608
- zones: zones
609
- });
610
- var link = "".concat(LIGHTHOUSE_BASE_URL, "/reports/").concat(collection, "/").concat(_id);
611
- var timestamp = createdAt;
612
- var userDoc = find(users, function (doc) {
613
- return doc._id.toString() === user.toString();
482
+ locations,
483
+ zones
614
484
  });
615
- var name = userDoc && "".concat(userDoc.firstName, " ").concat(userDoc.lastName) || 'Unknown User';
485
+ const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`;
486
+ const timestamp = createdAt;
487
+ const userDoc = (0, _lodash.find)(users, doc => doc._id.toString() === user.toString());
488
+ const name = userDoc && `${userDoc.firstName} ${userDoc.lastName}` || 'Unknown User';
616
489
 
617
490
  // NOTE: currently only issues and tasks will return summary fields, audits
618
491
  // aren't supported and will return an empty array here
619
- var summaryFields = entry.summaryFields || [];
492
+ const summaryFields = entry.summaryFields || [];
620
493
  return {
621
- icon: launchIcon,
622
- location: location,
623
- link: link,
624
- name: name,
625
- summaryFields: summaryFields,
626
- timestamp: timestamp,
627
- title: title
494
+ icon: _images.launchIcon,
495
+ location,
496
+ link,
497
+ name,
498
+ summaryFields,
499
+ timestamp,
500
+ title
628
501
  };
629
502
  };
630
503
  }
631
- function getScanRowData(_ref3) {
632
- var users = _ref3.users,
633
- zones = _ref3.zones;
634
- return function (document) {
635
- var timestamp = document.timestamp,
636
- _document$user2 = document.user,
637
- user = _document$user2 === void 0 ? '' : _document$user2,
638
- _document$zone = document.zone,
639
- zone = _document$zone === void 0 ? '' : _document$zone;
640
- var userDoc = user && find(users, function (doc) {
641
- return doc._id.toString() === user.toString();
642
- });
643
- var zoneDoc = zone && find(zones, function (doc) {
644
- return doc._id.toString() === zone.toString();
645
- });
646
- var zoneName = zoneDoc && zoneDoc.name;
647
- var location = zoneName || 'Unknown Location';
648
- var name = userDoc && "".concat(userDoc.firstName, " ").concat(userDoc.lastName) || 'Unknown User';
649
- var title = 'Location Scan';
504
+ function getScanRowData({
505
+ users,
506
+ zones
507
+ }) {
508
+ return document => {
509
+ const {
510
+ timestamp,
511
+ user = '',
512
+ zone = ''
513
+ } = document;
514
+ const userDoc = user && (0, _lodash.find)(users, doc => doc._id.toString() === user.toString());
515
+ const zoneDoc = zone && (0, _lodash.find)(zones, doc => doc._id.toString() === zone.toString());
516
+ const zoneName = zoneDoc && zoneDoc.name;
517
+ const location = zoneName || 'Unknown Location';
518
+ const name = userDoc && `${userDoc.firstName} ${userDoc.lastName}` || 'Unknown User';
519
+ const title = 'Location Scan';
650
520
  return {
651
- location: location,
652
- timestamp: timestamp,
653
- name: name,
654
- title: title
521
+ location,
522
+ timestamp,
523
+ name,
524
+ title
655
525
  };
656
526
  };
657
527
  }