@lighthouse/common 5.0.0-canary-5 → 5.0.0-canary-7

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 (244) hide show
  1. package/dist/constants.js +7 -13
  2. package/dist/errors/DomainError.js +2 -4
  3. package/dist/errors/ValidationError.js +0 -8
  4. package/dist/errors/index.js +1 -5
  5. package/dist/helpers/array-buffer-to-base-64/index.js +0 -1
  6. package/dist/helpers/build-fetch-url/index.js +0 -3
  7. package/dist/helpers/fetch-image/index.js +14 -31
  8. package/dist/helpers/fetch-image-for-pdf-generator-service/index.js +26 -34
  9. package/dist/helpers/fetch-image-for-web/index.js +3 -18
  10. package/dist/helpers/fetch-lighthouse-logo/index.js +2 -13
  11. package/dist/helpers/floatify/index.js +0 -1
  12. package/dist/helpers/get-assignees-full-names/index.js +0 -4
  13. package/dist/helpers/get-audit-entry-details/index.js +0 -3
  14. package/dist/helpers/get-audit-items-data/index.js +2 -6
  15. package/dist/helpers/get-geometry-geocoded-string/index.js +0 -3
  16. package/dist/helpers/get-issue-details/index.js +0 -7
  17. package/dist/helpers/get-job-details/index.js +0 -7
  18. package/dist/helpers/get-location-reference/index.js +18 -21
  19. package/dist/helpers/get-pretty-duration/index.js +0 -5
  20. package/dist/helpers/get-reference-details/index.js +0 -4
  21. package/dist/helpers/get-status-details/index.js +2 -9
  22. package/dist/helpers/get-task-entry-details/index.js +0 -3
  23. package/dist/helpers/get-timezone-abbr/index.js +0 -4
  24. package/dist/helpers/get-timezone-datetime/index.js +0 -5
  25. package/dist/helpers/get-user-full-name/index.js +0 -1
  26. package/dist/helpers/get-value-as-percentage/index.js +0 -1
  27. package/dist/helpers/image-validators/index.js +7 -9
  28. package/dist/helpers/index.js +16 -33
  29. package/dist/images/index.js +5 -9
  30. package/dist/index.js +4 -20
  31. package/dist/pdf/activity-report/index.js +41 -62
  32. package/dist/pdf/audit/index.js +0 -12
  33. package/dist/pdf/helpers/build-audit-content/index.js +4 -15
  34. package/dist/pdf/helpers/build-audit-follow-ups/index.js +4 -14
  35. package/dist/pdf/helpers/build-location-scans-content/index.js +4 -17
  36. package/dist/pdf/helpers/build-template-content/index.js +5 -14
  37. package/dist/pdf/helpers/default-footer/index.js +2 -3
  38. package/dist/pdf/helpers/default-header/index.js +0 -2
  39. package/dist/pdf/helpers/default-styles/index.js +2 -3
  40. package/dist/pdf/helpers/fields/index.js +15 -45
  41. package/dist/pdf/helpers/format-location-address/index.js +0 -3
  42. package/dist/pdf/helpers/generate-definition/index.js +0 -12
  43. package/dist/pdf/helpers/horizontal-line/index.js +0 -1
  44. package/dist/pdf/helpers/html-transformer/index.js +11 -23
  45. package/dist/pdf/helpers/index.js +40 -55
  46. package/dist/pdf/helpers/parse-value/index.js +2 -6
  47. package/dist/pdf/helpers/table/index.js +13 -31
  48. package/dist/pdf/helpers/text/index.js +0 -1
  49. package/dist/pdf/icons/index.js +3 -5
  50. package/dist/pdf/index.js +4 -10
  51. package/dist/pdf/issue/index.js +0 -12
  52. package/dist/pdf/job/index.js +1 -13
  53. package/dist/pdf/shift-report/emptyFixtures.js +4 -6
  54. package/dist/pdf/shift-report/index.js +2 -25
  55. package/dist/pdf/task/index.js +0 -11
  56. package/dist/scheduling/generators/index.js +0 -6
  57. package/dist/scheduling/generators/occurrenceIntervalsGenerator.js +1 -6
  58. package/dist/scheduling/generators/scheduleIntervalsGenerator.js +0 -5
  59. package/dist/scheduling/generators/serviceIntervalsGenerator.js +13 -27
  60. package/dist/scheduling/helpers/convertToTimezone.js +1 -6
  61. package/dist/scheduling/helpers/generateNonRepeatingSchedule.js +3 -9
  62. package/dist/scheduling/helpers/generateRepeatingSchedule.js +11 -18
  63. package/dist/scheduling/helpers/generateScheduleEnd.js +2 -8
  64. package/dist/scheduling/helpers/hasValidStartAndEnd.js +0 -6
  65. package/dist/scheduling/helpers/index.js +0 -28
  66. package/dist/scheduling/helpers/intervalCovers.js +0 -1
  67. package/dist/scheduling/helpers/intervalIntersectsEnd.js +0 -1
  68. package/dist/scheduling/helpers/intervalIntersectsStart.js +0 -1
  69. package/dist/scheduling/helpers/intervalOnlyIntersectsEnd.js +1 -3
  70. package/dist/scheduling/helpers/intervalOnlyIntersectsStart.js +0 -3
  71. package/dist/scheduling/helpers/intervalOutside.js +0 -1
  72. package/dist/scheduling/helpers/intervalWithin.js +0 -1
  73. package/dist/scheduling/helpers/mergeIntervals.js +0 -4
  74. package/dist/scheduling/helpers/splitIntervals.js +0 -3
  75. package/dist/scheduling/index.js +0 -6
  76. package/dist/scheduling/scheduling.types.js +4 -12
  77. package/dist/scheduling/strategies/getNext.js +2 -13
  78. package/dist/scheduling/strategies/getNextExactDateOfMonth.js +0 -12
  79. package/dist/scheduling/strategies/getNextLastDayOfMonth.js +0 -10
  80. package/dist/scheduling/strategies/getNextLastWeekdayOfMonth.js +0 -11
  81. package/dist/scheduling/strategies/getNextNoRepeat.js +0 -7
  82. package/dist/scheduling/strategies/getNextWeekday.js +0 -10
  83. package/dist/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +0 -12
  84. package/dist/scheduling/strategies/index.js +0 -14
  85. package/dist/schema/index.js +0 -2
  86. package/dist/schema/schema.js +2 -7
  87. package/dist/service-hours/__helpers__/calculate-hours.js +4 -13
  88. package/dist/service-hours/__helpers__/isOpen.js +0 -9
  89. package/dist/service-hours/index.js +0 -4
  90. package/dist/service-hours/schema.js +12 -35
  91. package/lib/constants.js.map +1 -1
  92. package/lib/errors/DomainError.js +5 -40
  93. package/lib/errors/DomainError.js.map +1 -1
  94. package/lib/errors/ValidationError.js +6 -45
  95. package/lib/errors/ValidationError.js.map +1 -1
  96. package/lib/errors/index.js.map +1 -1
  97. package/lib/helpers/array-buffer-to-base-64/index.js.map +1 -1
  98. package/lib/helpers/build-fetch-url/index.js +7 -13
  99. package/lib/helpers/build-fetch-url/index.js.map +1 -1
  100. package/lib/helpers/fetch-image/index.js +19 -30
  101. package/lib/helpers/fetch-image/index.js.map +1 -1
  102. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js +43 -67
  103. package/lib/helpers/fetch-image-for-pdf-generator-service/index.js.map +1 -1
  104. package/lib/helpers/fetch-image-for-web/index.js +4 -21
  105. package/lib/helpers/fetch-image-for-web/index.js.map +1 -1
  106. package/lib/helpers/fetch-lighthouse-logo/index.js +6 -16
  107. package/lib/helpers/fetch-lighthouse-logo/index.js.map +1 -1
  108. package/lib/helpers/floatify/index.js.map +1 -1
  109. package/lib/helpers/get-assignees-full-names/index.js +0 -1
  110. package/lib/helpers/get-assignees-full-names/index.js.map +1 -1
  111. package/lib/helpers/get-audit-entry-details/index.js +7 -7
  112. package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
  113. package/lib/helpers/get-audit-items-data/index.js +5 -6
  114. package/lib/helpers/get-audit-items-data/index.js.map +1 -1
  115. package/lib/helpers/get-geometry-geocoded-string/index.js.map +1 -1
  116. package/lib/helpers/get-issue-details/index.js +8 -8
  117. package/lib/helpers/get-issue-details/index.js.map +1 -1
  118. package/lib/helpers/get-job-details/index.js +12 -12
  119. package/lib/helpers/get-job-details/index.js.map +1 -1
  120. package/lib/helpers/get-location-reference/index.js +27 -33
  121. package/lib/helpers/get-location-reference/index.js.map +1 -1
  122. package/lib/helpers/get-pretty-duration/index.js +0 -4
  123. package/lib/helpers/get-pretty-duration/index.js.map +1 -1
  124. package/lib/helpers/get-reference-details/index.js +1 -3
  125. package/lib/helpers/get-reference-details/index.js.map +1 -1
  126. package/lib/helpers/get-status-details/index.js +0 -4
  127. package/lib/helpers/get-status-details/index.js.map +1 -1
  128. package/lib/helpers/get-task-entry-details/index.js +4 -4
  129. package/lib/helpers/get-task-entry-details/index.js.map +1 -1
  130. package/lib/helpers/get-timezone-abbr/index.js.map +1 -1
  131. package/lib/helpers/get-timezone-datetime/index.js +6 -6
  132. package/lib/helpers/get-timezone-datetime/index.js.map +1 -1
  133. package/lib/helpers/get-user-full-name/index.js.map +1 -1
  134. package/lib/helpers/get-value-as-percentage/index.js.map +1 -1
  135. package/lib/helpers/image-validators/index.js +7 -7
  136. package/lib/helpers/image-validators/index.js.map +1 -1
  137. package/lib/helpers/index.js.map +1 -1
  138. package/lib/images/index.js.map +1 -1
  139. package/lib/index.js.map +1 -1
  140. package/lib/pdf/activity-report/index.js +66 -110
  141. package/lib/pdf/activity-report/index.js.map +1 -1
  142. package/lib/pdf/audit/index.js +25 -31
  143. package/lib/pdf/audit/index.js.map +1 -1
  144. package/lib/pdf/fonts/index.js.map +1 -1
  145. package/lib/pdf/helpers/build-audit-content/index.js +3 -5
  146. package/lib/pdf/helpers/build-audit-content/index.js.map +1 -1
  147. package/lib/pdf/helpers/build-audit-follow-ups/index.js +5 -12
  148. package/lib/pdf/helpers/build-audit-follow-ups/index.js.map +1 -1
  149. package/lib/pdf/helpers/build-location-scans-content/index.js +4 -9
  150. package/lib/pdf/helpers/build-location-scans-content/index.js.map +1 -1
  151. package/lib/pdf/helpers/build-template-content/index.js +7 -9
  152. package/lib/pdf/helpers/build-template-content/index.js.map +1 -1
  153. package/lib/pdf/helpers/default-footer/index.js +9 -8
  154. package/lib/pdf/helpers/default-footer/index.js.map +1 -1
  155. package/lib/pdf/helpers/default-header/index.js +5 -5
  156. package/lib/pdf/helpers/default-header/index.js.map +1 -1
  157. package/lib/pdf/helpers/default-styles/index.js.map +1 -1
  158. package/lib/pdf/helpers/fields/index.js +44 -79
  159. package/lib/pdf/helpers/fields/index.js.map +1 -1
  160. package/lib/pdf/helpers/format-location-address/index.js.map +1 -1
  161. package/lib/pdf/helpers/generate-definition/index.js +22 -29
  162. package/lib/pdf/helpers/generate-definition/index.js.map +1 -1
  163. package/lib/pdf/helpers/horizontal-line/index.js +1 -1
  164. package/lib/pdf/helpers/horizontal-line/index.js.map +1 -1
  165. package/lib/pdf/helpers/html-transformer/index.js +18 -28
  166. package/lib/pdf/helpers/html-transformer/index.js.map +1 -1
  167. package/lib/pdf/helpers/index.js.map +1 -1
  168. package/lib/pdf/helpers/parse-value/index.js +2 -4
  169. package/lib/pdf/helpers/parse-value/index.js.map +1 -1
  170. package/lib/pdf/helpers/table/index.js +15 -19
  171. package/lib/pdf/helpers/table/index.js.map +1 -1
  172. package/lib/pdf/helpers/text/index.js +2 -5
  173. package/lib/pdf/helpers/text/index.js.map +1 -1
  174. package/lib/pdf/icons/index.js.map +1 -1
  175. package/lib/pdf/index.js.map +1 -1
  176. package/lib/pdf/issue/index.js +19 -26
  177. package/lib/pdf/issue/index.js.map +1 -1
  178. package/lib/pdf/job/index.js +12 -19
  179. package/lib/pdf/job/index.js.map +1 -1
  180. package/lib/pdf/shift-report/emptyFixtures.js.map +1 -1
  181. package/lib/pdf/shift-report/index.js +35 -85
  182. package/lib/pdf/shift-report/index.js.map +1 -1
  183. package/lib/pdf/task/index.js +11 -17
  184. package/lib/pdf/task/index.js.map +1 -1
  185. package/lib/scheduling/generators/index.js.map +1 -1
  186. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js +0 -8
  187. package/lib/scheduling/generators/occurrenceIntervalsGenerator.js.map +1 -1
  188. package/lib/scheduling/generators/scheduleIntervalsGenerator.js +0 -9
  189. package/lib/scheduling/generators/scheduleIntervalsGenerator.js.map +1 -1
  190. package/lib/scheduling/generators/serviceIntervalsGenerator.js +31 -71
  191. package/lib/scheduling/generators/serviceIntervalsGenerator.js.map +1 -1
  192. package/lib/scheduling/helpers/convertToTimezone.js +1 -1
  193. package/lib/scheduling/helpers/convertToTimezone.js.map +1 -1
  194. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js +26 -64
  195. package/lib/scheduling/helpers/generateNonRepeatingSchedule.js.map +1 -1
  196. package/lib/scheduling/helpers/generateRepeatingSchedule.js +47 -113
  197. package/lib/scheduling/helpers/generateRepeatingSchedule.js.map +1 -1
  198. package/lib/scheduling/helpers/generateScheduleEnd.js +6 -6
  199. package/lib/scheduling/helpers/generateScheduleEnd.js.map +1 -1
  200. package/lib/scheduling/helpers/hasValidStartAndEnd.js +1 -2
  201. package/lib/scheduling/helpers/hasValidStartAndEnd.js.map +1 -1
  202. package/lib/scheduling/helpers/index.js.map +1 -1
  203. package/lib/scheduling/helpers/intervalCovers.js.map +1 -1
  204. package/lib/scheduling/helpers/intervalIntersectsEnd.js.map +1 -1
  205. package/lib/scheduling/helpers/intervalIntersectsStart.js.map +1 -1
  206. package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js +1 -0
  207. package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js.map +1 -1
  208. package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js +1 -1
  209. package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js.map +1 -1
  210. package/lib/scheduling/helpers/intervalOutside.js.map +1 -1
  211. package/lib/scheduling/helpers/intervalWithin.js.map +1 -1
  212. package/lib/scheduling/helpers/mergeIntervals.js +0 -3
  213. package/lib/scheduling/helpers/mergeIntervals.js.map +1 -1
  214. package/lib/scheduling/helpers/splitIntervals.js +1 -1
  215. package/lib/scheduling/helpers/splitIntervals.js.map +1 -1
  216. package/lib/scheduling/index.js.map +1 -1
  217. package/lib/scheduling/scheduling.types.js +0 -5
  218. package/lib/scheduling/scheduling.types.js.map +1 -1
  219. package/lib/scheduling/strategies/getNext.js +1 -13
  220. package/lib/scheduling/strategies/getNext.js.map +1 -1
  221. package/lib/scheduling/strategies/getNextExactDateOfMonth.js +1 -13
  222. package/lib/scheduling/strategies/getNextExactDateOfMonth.js.map +1 -1
  223. package/lib/scheduling/strategies/getNextLastDayOfMonth.js +1 -11
  224. package/lib/scheduling/strategies/getNextLastDayOfMonth.js.map +1 -1
  225. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js +1 -11
  226. package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js.map +1 -1
  227. package/lib/scheduling/strategies/getNextNoRepeat.js +0 -9
  228. package/lib/scheduling/strategies/getNextNoRepeat.js.map +1 -1
  229. package/lib/scheduling/strategies/getNextWeekday.js +30 -68
  230. package/lib/scheduling/strategies/getNextWeekday.js.map +1 -1
  231. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +1 -11
  232. package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js.map +1 -1
  233. package/lib/scheduling/strategies/index.js.map +1 -1
  234. package/lib/schema/index.js.map +1 -1
  235. package/lib/schema/schema.js +1 -7
  236. package/lib/schema/schema.js.map +1 -1
  237. package/lib/service-hours/__helpers__/calculate-hours.js +4 -13
  238. package/lib/service-hours/__helpers__/calculate-hours.js.map +1 -1
  239. package/lib/service-hours/__helpers__/isOpen.js +3 -7
  240. package/lib/service-hours/__helpers__/isOpen.js.map +1 -1
  241. package/lib/service-hours/index.js.map +1 -1
  242. package/lib/service-hours/schema.js +7 -24
  243. package/lib/service-hours/schema.js.map +1 -1
  244. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -11,9 +9,7 @@ var _exportNames = {
11
9
  serviceHours: true
12
10
  };
13
11
  exports.serviceHours = exports.schema = exports.scheduling = void 0;
14
-
15
12
  var _constants = require("./constants");
16
-
17
13
  Object.keys(_constants).forEach(function (key) {
18
14
  if (key === "default" || key === "__esModule") return;
19
15
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -25,9 +21,7 @@ Object.keys(_constants).forEach(function (key) {
25
21
  }
26
22
  });
27
23
  });
28
-
29
24
  var _helpers = require("./helpers");
30
-
31
25
  Object.keys(_helpers).forEach(function (key) {
32
26
  if (key === "default" || key === "__esModule") return;
33
27
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -39,9 +33,7 @@ Object.keys(_helpers).forEach(function (key) {
39
33
  }
40
34
  });
41
35
  });
42
-
43
36
  var _images = require("./images");
44
-
45
37
  Object.keys(_images).forEach(function (key) {
46
38
  if (key === "default" || key === "__esModule") return;
47
39
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -53,9 +45,7 @@ Object.keys(_images).forEach(function (key) {
53
45
  }
54
46
  });
55
47
  });
56
-
57
48
  var _pdf = require("./pdf");
58
-
59
49
  Object.keys(_pdf).forEach(function (key) {
60
50
  if (key === "default" || key === "__esModule") return;
61
51
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -67,16 +57,10 @@ Object.keys(_pdf).forEach(function (key) {
67
57
  }
68
58
  });
69
59
  });
70
-
71
60
  var schedulingExports = _interopRequireWildcard(require("./scheduling"));
72
-
73
61
  var schemaExports = _interopRequireWildcard(require("./schema"));
74
-
75
62
  var serviceHoursExports = _interopRequireWildcard(require("./service-hours"));
76
-
77
- const scheduling = schedulingExports;
78
- exports.scheduling = scheduling;
79
- const schema = schemaExports;
80
- exports.schema = schema;
81
- const serviceHours = serviceHoursExports;
82
- exports.serviceHours = serviceHours;
63
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
64
+ const scheduling = exports.scheduling = schedulingExports;
65
+ const schema = exports.schema = schemaExports;
66
+ const serviceHours = exports.serviceHours = serviceHoursExports;
@@ -1,27 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.buildActivityPdf = buildActivityPdf;
9
-
10
8
  var _lodash = require("lodash");
11
-
12
9
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
13
-
14
10
  var _bluebird = _interopRequireDefault(require("bluebird"));
15
-
16
11
  var _helpers = require("../helpers");
17
-
18
12
  var _helpers2 = require("../../helpers");
19
-
20
13
  var _images = require("../../images");
21
-
22
14
  const DEFAULT_MAX_SCANS = 200;
23
15
  const MAX_ATTACHMENTS = 100;
24
16
  const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
17
+
25
18
  /**
26
19
  * buildActivityPdf
27
20
  *
@@ -55,7 +48,6 @@ const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
55
48
  * @param {array} data.users - user documents
56
49
  * @returns {Promise} returns pdfmake definition object
57
50
  */
58
-
59
51
  async function buildActivityPdf(pdfOptions, data) {
60
52
  const {
61
53
  timestamp,
@@ -72,29 +64,24 @@ async function buildActivityPdf(pdfOptions, data) {
72
64
  ...pdfOptions
73
65
  });
74
66
  }
75
-
76
67
  async function generateContent(data) {
77
68
  const activitySection = await buildActivitySection(data);
78
69
  const summarySection = buildSummarySection(data);
79
70
  const titleTable = buildTitleTable(data);
80
71
  return [titleTable, summarySection, activitySection];
81
72
  }
82
-
83
73
  async function buildActivitySection(data) {
84
74
  const {
85
75
  showAlternate = false
86
76
  } = data;
87
-
88
77
  if (showAlternate) {
89
78
  const locationScans = buildLocationScansSection(data);
90
79
  const otherActivity = await buildOtherActivitySection(data);
91
80
  return [locationScans, otherActivity];
92
81
  }
93
-
94
82
  const activitySummary = await buildActivitySummarySection(data);
95
83
  return [activitySummary];
96
84
  }
97
-
98
85
  async function buildActivitySummarySection(data) {
99
86
  const {
100
87
  audits,
@@ -131,7 +118,6 @@ async function buildActivitySummarySection(data) {
131
118
  timezone
132
119
  });
133
120
  const activitySummarySection = [header, hLine, activityTable];
134
-
135
121
  if (exceedsMaxScans) {
136
122
  const maxScansText = {
137
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', {
@@ -142,7 +128,6 @@ async function buildActivitySummarySection(data) {
142
128
  };
143
129
  activitySummarySection.push(maxScansText);
144
130
  }
145
-
146
131
  if (exceedsMaxForms) {
147
132
  const maxFormsText = {
148
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.')],
@@ -151,10 +136,8 @@ async function buildActivitySummarySection(data) {
151
136
  };
152
137
  activitySummarySection.push(maxFormsText);
153
138
  }
154
-
155
139
  return activitySummarySection;
156
140
  }
157
-
158
141
  async function buildActivityTable({
159
142
  rows,
160
143
  settings,
@@ -165,7 +148,8 @@ async function buildActivityTable({
165
148
  bold: true
166
149
  }), {
167
150
  text: ''
168
- }, // icon column
151
+ },
152
+ // icon column
169
153
  (0, _helpers.text)('Location', {
170
154
  bold: true
171
155
  }), (0, _helpers.text)('User', {
@@ -197,9 +181,10 @@ async function buildActivityTable({
197
181
  link
198
182
  } : {
199
183
  text: ''
200
- }; // NOTE: pass link to each column as
201
- // we can't wrap the entire table row
184
+ };
202
185
 
186
+ // NOTE: pass link to each column as
187
+ // we can't wrap the entire table row
203
188
  const rows = [[(0, _helpers.text)(title, {
204
189
  link
205
190
  }), iconCell, (0, _helpers.text)(location, {
@@ -211,7 +196,6 @@ async function buildActivityTable({
211
196
  link
212
197
  })]];
213
198
  const hasSummaryFields = !(0, _lodash.isEmpty)(summaryFields);
214
-
215
199
  if (hasSummaryFields) {
216
200
  const fieldsTable = await (0, _helpers.summaryFieldsTable)({
217
201
  fields: summaryFields,
@@ -219,10 +203,10 @@ async function buildActivityTable({
219
203
  timezone
220
204
  });
221
205
  rows.push([fieldsTable]);
222
- } // NOTE: we return a table per row which includes the entry details and the
223
- // summary fields if relevant
224
-
206
+ }
225
207
 
208
+ // NOTE: we return a table per row which includes the entry details and the
209
+ // summary fields if relevant
226
210
  const activityTableRow = [(0, _helpers.table)({
227
211
  body: [...rows],
228
212
  colSpan: 5,
@@ -262,7 +246,6 @@ async function buildActivityTable({
262
246
  });
263
247
  return activityTable;
264
248
  }
265
-
266
249
  function buildLocationScansSection(data) {
267
250
  const {
268
251
  events,
@@ -277,12 +260,15 @@ function buildLocationScansSection(data) {
277
260
  body: [[title]],
278
261
  layout: 'noBorders',
279
262
  style: 'summaryHeaderTable'
280
- }); // use start time and timezone to figure out the interval boundaries
263
+ });
281
264
 
282
- const hourIntervalBoundaries = (0, _helpers.buildLocationScansBoundaries)(start, timezone); // pair interval boundaries into column headers for the table
265
+ // use start time and timezone to figure out the interval boundaries
266
+ const hourIntervalBoundaries = (0, _helpers.buildLocationScansBoundaries)(start, timezone);
283
267
 
268
+ // pair interval boundaries into column headers for the table
284
269
  const hourIntervalColumnHeaders = hourIntervalBoundaries.reduce((columns, interval, index, intervals) => {
285
- if (index < (0, _lodash.size)(intervals) - 1) // skip the final iteration as it's just the end of the last interval
270
+ if (index < (0, _lodash.size)(intervals) - 1)
271
+ // skip the final iteration as it's just the end of the last interval
286
272
  columns.push((0, _helpers.text)(`${interval.format('h')}-${intervals[index + 1].format('hA')}`, {
287
273
  alignment: 'center',
288
274
  bold: true
@@ -295,8 +281,9 @@ function buildLocationScansSection(data) {
295
281
  alignment: 'right',
296
282
  bold: true
297
283
  })];
298
- const hLine = (0, _helpers.horizontalLine)(); // NOTE: only show the enter events within the summary table
284
+ const hLine = (0, _helpers.horizontalLine)();
299
285
 
286
+ // NOTE: only show the enter events within the summary table
300
287
  const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
301
288
  const sortedZones = (0, _lodash.sortBy)(zones, ['name']);
302
289
  const groupedEventsByZone = (0, _lodash.reduce)(sortedZones, (memo, zone) => {
@@ -305,10 +292,11 @@ function buildLocationScansSection(data) {
305
292
  return memo;
306
293
  }, {});
307
294
  const scansTableRows = (0, _lodash.map)(groupedEventsByZone, (events, zone = '') => {
308
- const sortedGroup = (0, _lodash.sortBy)(events, ['timestamp'], ['asc']); // put events into interval buckets
309
-
310
- const locationScansByInterval = (0, _helpers.buildLocationScansContent)(hourIntervalBoundaries, events); // map the interval buckets to a format fit for the table
295
+ const sortedGroup = (0, _lodash.sortBy)(events, ['timestamp'], ['asc']);
311
296
 
297
+ // put events into interval buckets
298
+ const locationScansByInterval = (0, _helpers.buildLocationScansContent)(hourIntervalBoundaries, events);
299
+ // map the interval buckets to a format fit for the table
312
300
  const locationScansByIntervalContent = locationScansByInterval.map(interval => {
313
301
  return {
314
302
  alignment: 'center',
@@ -333,30 +321,31 @@ function buildLocationScansSection(data) {
333
321
  });
334
322
  return [header, hLine, scansTable];
335
323
  }
336
-
337
324
  function buildSummarySection(data) {
338
325
  const {
339
326
  audits,
340
327
  events,
341
328
  issues,
342
329
  tasks
343
- } = data; //const userEvents = groupBy(events, 'user')
330
+ } = data;
344
331
 
332
+ //const userEvents = groupBy(events, 'user')
345
333
  const eventsByType = (0, _lodash.groupBy)(events, 'type');
346
- const enterEventsCount = (0, _lodash.size)(eventsByType.enter); //const geoEventsCount = size(eventsByType.geo)
347
-
334
+ const enterEventsCount = (0, _lodash.size)(eventsByType.enter);
335
+ //const geoEventsCount = size(eventsByType.geo)
348
336
  const issuesCount = (0, _lodash.size)(issues);
349
337
  const tasksCount = (0, _lodash.size)(tasks);
350
- const auditsCount = (0, _lodash.size)(audits); //const uniqueUsers = size(userEvents)
338
+ const auditsCount = (0, _lodash.size)(audits);
339
+ //const uniqueUsers = size(userEvents)
351
340
 
352
341
  const auditsText = (0, _helpers.text)('AUDITS', {
353
342
  style: 'summaryText'
354
- }); //const geoText = text('GPS', { style: 'summaryText' })
355
-
343
+ });
344
+ //const geoText = text('GPS', { style: 'summaryText' })
356
345
  const issuesText = (0, _helpers.text)('ISSUES', {
357
346
  style: 'summaryText'
358
- }); //const peopleText = text('PEOPLE', { style: 'summaryText' })
359
-
347
+ });
348
+ //const peopleText = text('PEOPLE', { style: 'summaryText' })
360
349
  const scansText = (0, _helpers.text)('SCANS', {
361
350
  style: 'summaryText'
362
351
  });
@@ -365,12 +354,12 @@ function buildSummarySection(data) {
365
354
  });
366
355
  const auditsCountText = (0, _helpers.text)((0, _lodash.toString)(auditsCount), {
367
356
  style: 'summaryCount'
368
- }); //const peopleCountText = text(toString(uniqueUsers), { style: 'summaryCount' })
369
-
357
+ });
358
+ //const peopleCountText = text(toString(uniqueUsers), { style: 'summaryCount' })
370
359
  const scansCountText = (0, _helpers.text)((0, _lodash.toString)(enterEventsCount), {
371
360
  style: 'summaryCount'
372
- }); //const geoCountText = text(toString(geoEventsCount), { style: 'summaryCount' })
373
-
361
+ });
362
+ //const geoCountText = text(toString(geoEventsCount), { style: 'summaryCount' })
374
363
  const issuesCountText = (0, _helpers.text)((0, _lodash.toString)(issuesCount), {
375
364
  style: 'summaryCount'
376
365
  });
@@ -379,11 +368,11 @@ function buildSummarySection(data) {
379
368
  });
380
369
  const auditTable = (0, _helpers.summaryStatTable)({
381
370
  body: [[auditsText], [auditsCountText]]
382
- }); //const peopleTable = summaryStatTable({
371
+ });
372
+ //const peopleTable = summaryStatTable({
383
373
  // body: [[peopleText], [peopleCountText]],
384
374
  //})
385
375
  //const gpsTable = summaryStatTable({ body: [[geoText], [geoCountText]] })
386
-
387
376
  const scanTable = (0, _helpers.summaryStatTable)({
388
377
  body: [[scansText], [scansCountText]]
389
378
  });
@@ -394,15 +383,12 @@ function buildSummarySection(data) {
394
383
  body: [[tasksText], [tasksCountText]]
395
384
  });
396
385
  const wrapperTable = (0, _helpers.summaryWrapperTable)({
397
- body: [[
398
- /*peopleTable,*/
399
-
386
+ body: [[/*peopleTable,*/
400
387
  /*gpsTable,*/
401
388
  scanTable, issueTable, taskTables, auditTable]]
402
389
  });
403
390
  return wrapperTable;
404
391
  }
405
-
406
392
  async function buildOtherActivitySection(data) {
407
393
  const {
408
394
  audits,
@@ -433,7 +419,6 @@ async function buildOtherActivitySection(data) {
433
419
  const otherActivitySummarySection = [header, hLine, activityTable];
434
420
  const formCount = (0, _lodash.size)(rows);
435
421
  const exceedsMaxForms = formCount > MAX_ATTACHMENTS;
436
-
437
422
  if (exceedsMaxForms) {
438
423
  const maxFormsText = {
439
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.')],
@@ -442,10 +427,8 @@ async function buildOtherActivitySection(data) {
442
427
  };
443
428
  otherActivitySummarySection.push(maxFormsText);
444
429
  }
445
-
446
430
  return otherActivitySummarySection;
447
431
  }
448
-
449
432
  function buildTitleTable(data) {
450
433
  const {
451
434
  location,
@@ -466,11 +449,8 @@ function buildTitleTable(data) {
466
449
  const headerAddress = (0, _helpers.text)(addressText, {
467
450
  style: 'small'
468
451
  });
469
-
470
452
  const mTimezoneStart = _momentTimezone.default.tz(start, timezone);
471
-
472
453
  const mTimezoneEnd = _momentTimezone.default.tz(end, timezone);
473
-
474
454
  const timezoneAbbr = (0, _helpers2.getTimezoneAbbr)(timezone);
475
455
  const rangeStart = (0, _momentTimezone.default)(mTimezoneStart).format('MMM DD h:mma');
476
456
  const rangeEnd = (0, _momentTimezone.default)(mTimezoneEnd).add(1, 'hour').startOf('hour').format('MMM DD h:mma');
@@ -484,7 +464,6 @@ function buildTitleTable(data) {
484
464
  style: 'titleTable'
485
465
  });
486
466
  }
487
-
488
467
  function getFormRowData(collection, {
489
468
  locations,
490
469
  users,
@@ -506,9 +485,10 @@ function getFormRowData(collection, {
506
485
  const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`;
507
486
  const timestamp = createdAt;
508
487
  const userDoc = (0, _lodash.find)(users, doc => doc._id.toString() === user.toString());
509
- const name = userDoc && `${userDoc.firstName} ${userDoc.lastName}` || 'Unknown User'; // NOTE: currently only issues and tasks will return summary fields, audits
510
- // aren't supported and will return an empty array here
488
+ const name = userDoc && `${userDoc.firstName} ${userDoc.lastName}` || 'Unknown User';
511
489
 
490
+ // NOTE: currently only issues and tasks will return summary fields, audits
491
+ // aren't supported and will return an empty array here
512
492
  const summaryFields = entry.summaryFields || [];
513
493
  return {
514
494
  icon: _images.launchIcon,
@@ -521,7 +501,6 @@ function getFormRowData(collection, {
521
501
  };
522
502
  };
523
503
  }
524
-
525
504
  function getScanRowData({
526
505
  users,
527
506
  zones
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.buildAuditPdf = buildAuditPdf;
9
-
10
8
  var _bluebird = _interopRequireDefault(require("bluebird"));
11
-
12
9
  var _lodash = require("lodash");
13
-
14
10
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
15
-
16
11
  var _helpers = require("../helpers");
17
-
18
12
  var _helpers2 = require("../../helpers");
19
-
20
13
  /**
21
14
  * buildAuditPdf
22
15
  *
@@ -65,7 +58,6 @@ function buildAuditPdf(pdfOptions, data) {
65
58
  throw new Error(`BuildAuditPdfError: ${err.message}`);
66
59
  });
67
60
  }
68
-
69
61
  function generateContent(data) {
70
62
  const {
71
63
  entity
@@ -117,7 +109,6 @@ function generateContent(data) {
117
109
  });
118
110
  const renderThirdRow = renderHeaderAddress || renderTargetFields;
119
111
  let thirdRow = renderHeaderAddress ? [headerAddress] : [];
120
-
121
112
  if (renderTargetFields) {
122
113
  headerSubTitle = (0, _helpers.text)(subTitle, {
123
114
  style: 'subTitle'
@@ -140,7 +131,6 @@ function generateContent(data) {
140
131
  });
141
132
  thirdRow = renderHeaderAddress ? [headerAddress, scoreTargetSubTitle] : [dummyColumn, scoreTargetSubTitle];
142
133
  }
143
-
144
134
  const scoreBreakdown = (0, _helpers.text)(`${(0, _lodash.round)(score.actual, 2)} / ${(0, _lodash.round)(score.max, 2)}`, {
145
135
  alignment: 'right',
146
136
  style: 'totalScore'
@@ -164,9 +154,7 @@ function generateContent(data) {
164
154
  colSpan: 2,
165
155
  style: 'small'
166
156
  });
167
-
168
157
  const momentDuration = _momentTimezone.default.duration(Math.abs(entity.formDuration));
169
-
170
158
  const days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
171
159
  const hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
172
160
  const minutes = momentDuration.minutes().toString().padStart(2, '0');
@@ -1,23 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.buildAuditContent = void 0;
9
-
10
8
  var _lodash = require("lodash");
11
-
12
9
  var _bluebird = _interopRequireDefault(require("bluebird"));
13
-
14
10
  var _helpers = require("../../../helpers");
15
-
16
11
  var _ = require("../");
17
-
18
12
  var _table = require("../table");
19
-
20
- const buildAuditContent = _bluebird.default.method((items, settings = {}) => {
13
+ const buildAuditContent = exports.buildAuditContent = _bluebird.default.method((items, settings = {}) => {
21
14
  return _bluebird.default.map(items, group => {
22
15
  return _bluebird.default.map(group.items, (item, index) => {
23
16
  return _bluebird.default.map(item.assets, ({
@@ -38,8 +31,9 @@ const buildAuditContent = _bluebird.default.method((items, settings = {}) => {
38
31
  const rows = [];
39
32
  const fillColor = index % 2 === 0 ? _table.WHITE : _table.LIGHT_BLUE;
40
33
  const hasImages = !(0, _lodash.isEmpty)(rowImages);
41
- const hasComments = !(0, _lodash.isEmpty)(item.comments); // Some audits use questionId to link a follow-up issue and its question
34
+ const hasComments = !(0, _lodash.isEmpty)(item.comments);
42
35
 
36
+ // Some audits use questionId to link a follow-up issue and its question
43
37
  const label = {
44
38
  text: item.label,
45
39
  fillColor,
@@ -57,7 +51,6 @@ const buildAuditContent = _bluebird.default.method((items, settings = {}) => {
57
51
  text: item.scoreWeight,
58
52
  fillColor
59
53
  }]);
60
-
61
54
  if (hasImages) {
62
55
  const imageRow = [{
63
56
  colSpan: 4,
@@ -66,7 +59,6 @@ const buildAuditContent = _bluebird.default.method((items, settings = {}) => {
66
59
  }];
67
60
  rows.push(imageRow);
68
61
  }
69
-
70
62
  if (hasComments) {
71
63
  const commentsRow = [{
72
64
  colSpan: 4,
@@ -81,7 +73,6 @@ const buildAuditContent = _bluebird.default.method((items, settings = {}) => {
81
73
  }];
82
74
  rows.push(commentsRow);
83
75
  }
84
-
85
76
  return rows;
86
77
  });
87
78
  }).then(groupTableRows => {
@@ -123,6 +114,4 @@ const buildAuditContent = _bluebird.default.method((items, settings = {}) => {
123
114
  return [groupHeaderTable, hLine, groupTable];
124
115
  });
125
116
  });
126
- });
127
-
128
- exports.buildAuditContent = buildAuditContent;
117
+ });
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.buildAuditFollowUps = buildAuditFollowUps;
9
-
10
8
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
11
-
12
9
  var _helpers = require("../../../helpers");
13
-
14
10
  var _ = require("../");
15
-
16
11
  var _images = require("../../../images");
17
-
18
12
  const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
19
-
20
13
  function buildAuditFollowUps(rawFollowUpIssues = [], options = {}) {
21
14
  const sectionTitle = [{
22
15
  text: 'Follow-up Issues',
@@ -30,7 +23,6 @@ function buildAuditFollowUps(rawFollowUpIssues = [], options = {}) {
30
23
  margin: [0, 0, 0, 0]
31
24
  });
32
25
  const followUpIssues = rawFollowUpIssues.filter(item => !item.errorMessage);
33
-
34
26
  if (!followUpIssues.length) {
35
27
  // Show a `no follow-up issues` message if there are no follow up issues
36
28
  return [sectionTitle, sectionDivider, {
@@ -39,7 +31,6 @@ function buildAuditFollowUps(rawFollowUpIssues = [], options = {}) {
39
31
  margin: [0, 5, 0, 50]
40
32
  }];
41
33
  }
42
-
43
34
  const {
44
35
  timezone = 'America/New_York'
45
36
  } = options;
@@ -48,19 +39,17 @@ function buildAuditFollowUps(rawFollowUpIssues = [], options = {}) {
48
39
  const mappedStatus = (0, _helpers.getStatusDetails)(item.status);
49
40
  const status = {
50
41
  text: mappedStatus.text.toUpperCase(),
51
- style: { ..._.defaultStyles.small,
42
+ style: {
43
+ ..._.defaultStyles.small,
52
44
  color: mappedStatus.style.color,
53
45
  alignment: 'center'
54
46
  }
55
47
  };
56
48
  let updatedAt = '';
57
-
58
49
  if (item.updatedAt) {
59
50
  const format = 'MMM D h:mma'; // e.g. Jan 21 12:59am in the Audit timezone
60
-
61
51
  updatedAt = _momentTimezone.default.tz(item.updatedAt, timezone).format(format);
62
52
  }
63
-
64
53
  const link = `${LIGHTHOUSE_BASE_URL}/reports/issues/${item.issueId}`;
65
54
  const iconLinkCell = _images.launchIcon ? {
66
55
  alignment: 'center',
@@ -80,7 +69,8 @@ function buildAuditFollowUps(rawFollowUpIssues = [], options = {}) {
80
69
  text: ''
81
70
  };
82
71
  const assignees = item.assignees || [];
83
- const assigneeUsername = assignees.length === 0 ? 'Unassigned' : assignees.length === 1 ? // TODO Currently this gives `first last`, I don't think it can fall back to 'Unknown User' here
72
+ const assigneeUsername = assignees.length === 0 ? 'Unassigned' : assignees.length === 1 ?
73
+ // TODO Currently this gives `first last`, I don't think it can fall back to 'Unknown User' here
84
74
  (0, _helpers.getUserFullName)(assignees, 0) : `${assignees.length} users`;
85
75
  tableBody.push([iconLinkCell, {
86
76
  text: item.issueTitle || '',
@@ -1,54 +1,41 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.buildLocationScansContent = exports.buildLocationScansBoundaries = void 0;
9
-
10
8
  var _lodash = require("lodash");
11
-
12
9
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
13
-
14
10
  const buildLocationScansBoundaries = (start, timezone) => {
15
11
  const firstBoundary = _momentTimezone.default.tz(start, timezone);
16
-
17
- const boundaries = []; // add 9 boundaries (3 hours apart) to an array
12
+ const boundaries = [];
13
+ // add 9 boundaries (3 hours apart) to an array
18
14
  // these will mark the edges of 8 3-hour buckets of scan events
19
15
  // ex: [start, start+3hrs, start+6hrs, ..., start+24hrs]
20
-
21
16
  boundaries.push(firstBoundary);
22
-
23
17
  for (let i = 1; i < 9; i++) {
24
18
  const intervalSize = 3 * i;
25
19
  const nextBoundary = (0, _momentTimezone.default)(firstBoundary).add(intervalSize, 'hours');
26
20
  boundaries.push(nextBoundary);
27
21
  }
28
-
29
22
  return boundaries;
30
23
  };
31
-
32
24
  exports.buildLocationScansBoundaries = buildLocationScansBoundaries;
33
-
34
25
  const buildLocationScansContent = (boundaries, events, timezone) => {
35
26
  // loop through boundaries filtering for events between the current boundary and the next one
36
27
  // skip the last one as it's the end and has no "next one"
37
28
  // ex: [interval1Events, interval2Events, ..., interval8Events] where interval1Events is an array
38
29
  // of events that start on or after boundary 1 and before boundary 2
39
30
  const eventsArray = [];
40
-
41
31
  for (let i = 0; i < boundaries.length - 1; i++) {
42
32
  const eventsInThisInterval = (0, _lodash.filter)(events, function (event) {
43
33
  const eventMoment = _momentTimezone.default.tz(event.timestamp, timezone);
44
-
45
34
  return eventMoment.isSameOrAfter(boundaries[i]) && eventMoment.isBefore(boundaries[i + 1]);
46
- }); // add events to interval
47
-
35
+ });
36
+ // add events to interval
48
37
  eventsArray.push(eventsInThisInterval);
49
38
  }
50
-
51
39
  return eventsArray;
52
40
  };
53
-
54
41
  exports.buildLocationScansContent = buildLocationScansContent;