@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,608 +1,486 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
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 Promise from 'bluebird';
8
- import { each, filter, find, groupBy, isEmpty, map, size, sortBy, sum, toString, trim } from 'lodash';
9
- import moment, { duration } from 'moment-timezone';
10
- import { getLocationReference, getTimezoneAbbr, getTimezoneDatetime } from '../../helpers';
11
- import { launchIcon } from '../../images';
12
- import { generateDefinition, horizontalLine, summaryFieldsTable, summaryStatTable, summaryWrapperTable, table, text, threeColumnTable, zebraFillColor } from '../helpers';
13
- var LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
1
+ "use strict";
14
2
 
15
- /**
16
- * buildActivityPdf
17
- * @param {object} pdfOptions - the pdf options
18
- * @param {string} pdfOptions.fileTitle - pdf file title
19
- * @param {function} pdfOptions.footer - function executed to generate footer
20
- * @param {function} pdfOptions.header - function executed to generate header
21
- * @param {string} pdfOptions.logoUrl - pdf logo url
22
- * @param {array} pdfOptions.pageMargins - pdf page margins
23
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
24
- * @param {string} pdfOptions.pageSize - pdf page size
25
- * @param {object} pdfOptions.styles - pdf styles
26
- * @param {object} pdfOptions.title - pdf title
27
- * @param {object} data - pdf data
28
- * @param {array} data.audits - audit documents
29
- * @param {array} data.events - event documents
30
- * @param {array} data.locations - location documents
31
- * @param {array} data.issues - issue documents
32
- * @param {array} data.audits - audit documents
33
- * @param {object} data.shift - shift document
34
- * @param {object} data.settings - settings properties
35
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
36
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
37
- * @param {array} data.tasks - task documents
38
- * @param {string} data.timestamp - timestamp string
39
- * @param {string} data.timezone - timezone string
40
- * @param {array} data.zones - zone documents
41
- * @param {array} data.user - user document
42
- * @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.buildShiftPdf = buildShiftPdf;
8
+ exports.getFineDuration = getFineDuration;
9
+ var _bluebird = _interopRequireDefault(require("bluebird"));
10
+ var _lodash = require("lodash");
11
+ var _momentTimezone = _interopRequireWildcard(require("moment-timezone"));
12
+ var _helpers = require("../../helpers");
13
+ var _images = require("../../images");
14
+ var _helpers2 = require("../helpers");
15
+ 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); }
16
+ const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
17
+
18
+ /**
19
+ * buildActivityPdf
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 {array} data.events - event documents
33
+ * @param {array} data.locations - location documents
34
+ * @param {array} data.issues - issue documents
35
+ * @param {array} data.audits - audit documents
36
+ * @param {object} data.shift - shift document
37
+ * @param {object} data.settings - settings properties
38
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
39
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
40
+ * @param {array} data.tasks - task documents
41
+ * @param {string} data.timestamp - timestamp string
42
+ * @param {string} data.timezone - timezone string
43
+ * @param {array} data.zones - zone documents
44
+ * @param {array} data.user - user document
45
+ * @returns {Promise} returns pdfmake definition object
43
46
  */
44
47
 
45
- export function buildShiftPdf(_x, _x2) {
46
- return _buildShiftPdf.apply(this, arguments);
47
- }
48
- function _buildShiftPdf() {
49
- _buildShiftPdf = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(pdfOptions, data) {
50
- var timestamp, timezone, title, content;
51
- return _regeneratorRuntime.wrap(function (_context) {
52
- while (1) switch (_context.prev = _context.next) {
53
- case 0:
54
- timestamp = data.timestamp, timezone = data.timezone;
55
- title = 'Daily Shift Report';
56
- _context.next = 1;
57
- return generateContent(data);
58
- case 1:
59
- content = _context.sent;
60
- return _context.abrupt("return", generateDefinition(_objectSpread({
61
- content: content,
62
- fileTitle: title,
63
- timestamp: timestamp,
64
- timezone: timezone,
65
- type: 'Shift Report'
66
- }, pdfOptions)));
67
- case 2:
68
- case "end":
69
- return _context.stop();
70
- }
71
- }, _callee);
72
- }));
73
- return _buildShiftPdf.apply(this, arguments);
74
- }
75
- function generateContent(_x3) {
76
- return _generateContent.apply(this, arguments);
77
- }
78
- function _generateContent() {
79
- _generateContent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
80
- var activitySection, summarySection, titleTable;
81
- return _regeneratorRuntime.wrap(function (_context2) {
82
- while (1) switch (_context2.prev = _context2.next) {
83
- case 0:
84
- _context2.next = 1;
85
- return buildActivitySection(data);
86
- case 1:
87
- activitySection = _context2.sent;
88
- summarySection = buildSummarySection(data);
89
- titleTable = buildTitleTable(data);
90
- return _context2.abrupt("return", [titleTable, summarySection, activitySection]);
91
- case 2:
92
- case "end":
93
- return _context2.stop();
94
- }
95
- }, _callee2);
96
- }));
97
- return _generateContent.apply(this, arguments);
48
+ async function buildShiftPdf(pdfOptions, data) {
49
+ const {
50
+ timestamp,
51
+ timezone
52
+ } = data;
53
+ const title = 'Daily Shift Report';
54
+ const content = await generateContent(data);
55
+ return (0, _helpers2.generateDefinition)({
56
+ content,
57
+ fileTitle: title,
58
+ timestamp,
59
+ timezone,
60
+ type: 'Shift Report',
61
+ ...pdfOptions
62
+ });
98
63
  }
99
- function buildActivitySection(_x4) {
100
- return _buildActivitySection.apply(this, arguments);
64
+ async function generateContent(data) {
65
+ const activitySection = await buildActivitySection(data);
66
+ const summarySection = buildSummarySection(data);
67
+ const titleTable = buildTitleTable(data);
68
+ return [titleTable, summarySection, activitySection];
101
69
  }
102
- function _buildActivitySection() {
103
- _buildActivitySection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
104
- var timeline, activitySummary;
105
- return _regeneratorRuntime.wrap(function (_context3) {
106
- while (1) switch (_context3.prev = _context3.next) {
107
- case 0:
108
- _context3.next = 1;
109
- return buildTimelineTable(data);
110
- case 1:
111
- timeline = _context3.sent;
112
- _context3.next = 2;
113
- return buildActivitySummarySection(data);
114
- case 2:
115
- activitySummary = _context3.sent;
116
- return _context3.abrupt("return", [timeline, activitySummary]);
117
- case 3:
118
- case "end":
119
- return _context3.stop();
120
- }
121
- }, _callee3);
122
- }));
123
- return _buildActivitySection.apply(this, arguments);
70
+ async function buildActivitySection(data) {
71
+ const timeline = await buildTimelineTable(data);
72
+ const activitySummary = await buildActivitySummarySection(data);
73
+ return [timeline, activitySummary];
124
74
  }
125
75
  function buildTitleTable(data) {
126
- var shift = data.shift,
127
- timezone = data.timezone,
128
- user = data.user;
129
- var breaks = shift.breaks,
130
- duration = shift.duration,
131
- end = shift.end,
132
- start = shift.start;
133
- var headerTitle = text('Daily Shift Report', {
76
+ const {
77
+ shift,
78
+ timezone,
79
+ user
80
+ } = data;
81
+ const {
82
+ breaks,
83
+ duration,
84
+ end,
85
+ start
86
+ } = shift;
87
+ const headerTitle = (0, _helpers2.text)('Daily Shift Report', {
134
88
  style: 'title'
135
89
  });
136
- var username = "".concat(user.firstName, " ").concat(user.lastName) || 'Unknown User';
137
- var headerSubTitle = text("".concat(username), {
90
+ const username = `${user.firstName} ${user.lastName}` || 'Unknown User';
91
+ const headerSubTitle = (0, _helpers2.text)(`${username}`, {
138
92
  style: 'subTitle'
139
93
  });
140
- var mTimezoneStart = moment(start.time).tz(timezone);
141
- var mTimezoneEnd = moment(end.time).tz(timezone);
142
- var rangeStart = moment(mTimezoneStart).format('MMM DD h:mma');
143
- var rangeEnd = moment(mTimezoneEnd).format('MMM DD h:mma');
144
- var shiftDuration = getFineDuration(duration);
145
- var breakDuration = getBreakDuration(breaks);
146
- var header = !breakDuration ? "".concat(rangeStart, " - ").concat(rangeEnd, " | Duration: ").concat(shiftDuration) : "".concat(rangeStart, " - ").concat(rangeEnd, " | Duration: ").concat(shiftDuration, ", Break: ").concat(breakDuration);
147
- var headerRange = text(header, {
94
+ const mTimezoneStart = (0, _momentTimezone.default)(start.time).tz(timezone);
95
+ const mTimezoneEnd = (0, _momentTimezone.default)(end.time).tz(timezone);
96
+ const rangeStart = (0, _momentTimezone.default)(mTimezoneStart).format('MMM DD h:mma');
97
+ const rangeEnd = (0, _momentTimezone.default)(mTimezoneEnd).format('MMM DD h:mma');
98
+ const shiftDuration = getFineDuration(duration);
99
+ const breakDuration = getBreakDuration(breaks);
100
+ const header = !breakDuration ? `${rangeStart} - ${rangeEnd} | Duration: ${shiftDuration}` : `${rangeStart} - ${rangeEnd} | Duration: ${shiftDuration}, Break: ${breakDuration}`;
101
+ const headerRange = (0, _helpers2.text)(header, {
148
102
  style: 'subTitle2'
149
103
  });
150
- return table({
104
+ return (0, _helpers2.table)({
151
105
  body: [[headerTitle], [headerSubTitle], [headerRange]],
152
106
  layout: 'noBorders',
153
107
  style: 'titleTable'
154
108
  });
155
109
  }
156
110
  function buildSummarySection(data) {
157
- var audits = data.audits,
158
- events = data.events,
159
- issues = data.issues,
160
- tasks = data.tasks;
161
- var eventsByType = groupBy(events, 'type');
162
- var enterEventsCount = size(eventsByType.enter);
163
- var issuesCount = size(issues);
164
- var tasksCount = size(tasks);
165
- var auditsCount = size(audits);
166
- var scansText = text('SCANS', {
111
+ const {
112
+ audits,
113
+ events,
114
+ issues,
115
+ tasks
116
+ } = data;
117
+ const eventsByType = (0, _lodash.groupBy)(events, 'type');
118
+ const enterEventsCount = (0, _lodash.size)(eventsByType.enter);
119
+ const issuesCount = (0, _lodash.size)(issues);
120
+ const tasksCount = (0, _lodash.size)(tasks);
121
+ const auditsCount = (0, _lodash.size)(audits);
122
+ const scansText = (0, _helpers2.text)('SCANS', {
167
123
  style: 'summaryText'
168
124
  });
169
- var issuesText = text('ISSUES', {
125
+ const issuesText = (0, _helpers2.text)('ISSUES', {
170
126
  style: 'summaryText'
171
127
  });
172
- var tasksText = text('TASKS', {
128
+ const tasksText = (0, _helpers2.text)('TASKS', {
173
129
  style: 'summaryText'
174
130
  });
175
- var auditsText = text('AUDITS', {
131
+ const auditsText = (0, _helpers2.text)('AUDITS', {
176
132
  style: 'summaryText'
177
133
  });
178
- var scansCountText = text(toString(enterEventsCount), {
134
+ const scansCountText = (0, _helpers2.text)((0, _lodash.toString)(enterEventsCount), {
179
135
  style: 'summaryCount'
180
136
  });
181
- var issuesCountText = text(toString(issuesCount), {
137
+ const issuesCountText = (0, _helpers2.text)((0, _lodash.toString)(issuesCount), {
182
138
  style: 'summaryCount'
183
139
  });
184
- var tasksCountText = text(toString(tasksCount), {
140
+ const tasksCountText = (0, _helpers2.text)((0, _lodash.toString)(tasksCount), {
185
141
  style: 'summaryCount'
186
142
  });
187
- var auditsCountText = text(toString(auditsCount), {
143
+ const auditsCountText = (0, _helpers2.text)((0, _lodash.toString)(auditsCount), {
188
144
  style: 'summaryCount'
189
145
  });
190
- var scanTable = summaryStatTable({
146
+ const scanTable = (0, _helpers2.summaryStatTable)({
191
147
  body: [[scansText], [scansCountText]]
192
148
  });
193
- var issueTable = summaryStatTable({
149
+ const issueTable = (0, _helpers2.summaryStatTable)({
194
150
  body: [[issuesText], [issuesCountText]]
195
151
  });
196
- var taskTables = summaryStatTable({
152
+ const taskTables = (0, _helpers2.summaryStatTable)({
197
153
  body: [[tasksText], [tasksCountText]]
198
154
  });
199
- var auditTable = summaryStatTable({
155
+ const auditTable = (0, _helpers2.summaryStatTable)({
200
156
  body: [[auditsText], [auditsCountText]]
201
157
  });
202
- var wrapperTable = summaryWrapperTable({
158
+ const wrapperTable = (0, _helpers2.summaryWrapperTable)({
203
159
  body: [[scanTable, issueTable, taskTables, auditTable]]
204
160
  });
205
161
  return wrapperTable;
206
162
  }
207
- function buildActivitySummarySection(_x5) {
208
- return _buildActivitySummarySection.apply(this, arguments);
209
- }
210
- function _buildActivitySummarySection() {
211
- _buildActivitySummarySection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
212
- var audits, events, issues, settings, tasks, timezone, enterEvents, auditRows, issueRows, scanRows, taskRows, rows, sortedRows, title, header, hLine, activityTable, activitySummarySection;
213
- return _regeneratorRuntime.wrap(function (_context4) {
214
- while (1) switch (_context4.prev = _context4.next) {
215
- case 0:
216
- audits = data.audits, events = data.events, issues = data.issues, settings = data.settings, tasks = data.tasks, timezone = data.timezone;
217
- enterEvents = filter(events, function (event) {
218
- return event.type === 'enter';
219
- });
220
- auditRows = map(audits, getFormRowData('audits', data));
221
- issueRows = map(issues, getFormRowData('issues', data));
222
- scanRows = map(enterEvents, getScanRowData(data));
223
- taskRows = map(tasks, getFormRowData('tasks', data));
224
- rows = [].concat(_toConsumableArray(auditRows), _toConsumableArray(issueRows), _toConsumableArray(scanRows), _toConsumableArray(taskRows));
225
- sortedRows = sortBy(rows, ['timestamp'], ['asc']);
226
- title = text('Activity Summary', {
227
- style: 'summarySectionHeader'
228
- });
229
- header = table({
230
- body: [[title]],
231
- layout: 'noBorders',
232
- style: 'summaryHeaderTable'
233
- });
234
- hLine = horizontalLine();
235
- _context4.next = 1;
236
- return buildActivityTable({
237
- rows: sortedRows,
238
- settings: settings,
239
- timezone: timezone
240
- });
241
- case 1:
242
- activityTable = _context4.sent;
243
- activitySummarySection = [header, hLine, activityTable];
244
- return _context4.abrupt("return", activitySummarySection);
245
- case 2:
246
- case "end":
247
- return _context4.stop();
248
- }
249
- }, _callee4);
250
- }));
251
- return _buildActivitySummarySection.apply(this, arguments);
252
- }
253
- function buildActivityTable(_x6) {
254
- return _buildActivityTable.apply(this, arguments);
163
+ async function buildActivitySummarySection(data) {
164
+ const {
165
+ audits,
166
+ events,
167
+ issues,
168
+ settings,
169
+ tasks,
170
+ timezone
171
+ } = data;
172
+ const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
173
+ const auditRows = (0, _lodash.map)(audits, getFormRowData('audits', data));
174
+ const issueRows = (0, _lodash.map)(issues, getFormRowData('issues', data));
175
+ const scanRows = (0, _lodash.map)(enterEvents, getScanRowData(data));
176
+ const taskRows = (0, _lodash.map)(tasks, getFormRowData('tasks', data));
177
+ const rows = [...auditRows, ...issueRows, ...scanRows, ...taskRows];
178
+ const sortedRows = (0, _lodash.sortBy)(rows, ['timestamp'], ['asc']);
179
+ const title = (0, _helpers2.text)('Activity Summary', {
180
+ style: 'summarySectionHeader'
181
+ });
182
+ const header = (0, _helpers2.table)({
183
+ body: [[title]],
184
+ layout: 'noBorders',
185
+ style: 'summaryHeaderTable'
186
+ });
187
+ const hLine = (0, _helpers2.horizontalLine)();
188
+ const activityTable = await buildActivityTable({
189
+ rows: sortedRows,
190
+ settings,
191
+ timezone
192
+ });
193
+ const activitySummarySection = [header, hLine, activityTable];
194
+ return activitySummarySection;
255
195
  }
256
- function _buildActivityTable() {
257
- _buildActivityTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref) {
258
- var rows, settings, timezone, timezoneAbbr, activityTableHeader, activityTableRows, activityTableBody, activityTable;
259
- return _regeneratorRuntime.wrap(function (_context6) {
260
- while (1) switch (_context6.prev = _context6.next) {
261
- case 0:
262
- rows = _ref.rows, settings = _ref.settings, timezone = _ref.timezone;
263
- timezoneAbbr = getTimezoneAbbr(timezone);
264
- activityTableHeader = [text('Activity', {
265
- bold: true
266
- }), {
267
- text: ''
268
- }, text('Location', {
269
- bold: true
270
- }), text("Timestamp (".concat(timezoneAbbr, ")"), {
271
- alignment: 'right',
272
- bold: true
273
- })];
274
- _context6.next = 1;
275
- return Promise.map(rows, /*#__PURE__*/function () {
276
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data) {
277
- var link, location, icon, summaryFields, timestamp, title, timezoneHour, iconCell, rows, hasSummaryFields, fieldsTable, activityTableRow;
278
- return _regeneratorRuntime.wrap(function (_context5) {
279
- while (1) switch (_context5.prev = _context5.next) {
280
- case 0:
281
- link = data.link, location = data.location, icon = data.icon, summaryFields = data.summaryFields, timestamp = data.timestamp, title = data.title;
282
- timezoneHour = getTimezoneDatetime({
283
- format: 'ddd DD h:mm a',
284
- showTzAbbr: false,
285
- timestamp: timestamp,
286
- timezone: timezone
287
- });
288
- iconCell = icon ? {
289
- alignment: 'center',
290
- fit: [8, 8],
291
- image: icon,
292
- link: link
293
- } : {
294
- text: ''
295
- };
296
- rows = [[text(title, {
297
- link: link
298
- }), iconCell, text(location, {
299
- link: link
300
- }), text(timezoneHour, {
301
- alignment: 'right',
302
- link: link
303
- })]];
304
- hasSummaryFields = !isEmpty(summaryFields);
305
- if (!hasSummaryFields) {
306
- _context5.next = 2;
307
- break;
308
- }
309
- _context5.next = 1;
310
- return summaryFieldsTable({
311
- fields: summaryFields,
312
- settings: settings,
313
- timezone: timezone
314
- });
315
- case 1:
316
- fieldsTable = _context5.sent;
317
- rows.push([fieldsTable]);
318
- case 2:
319
- activityTableRow = [table({
320
- body: [].concat(rows),
321
- colSpan: 5,
322
- dontBreakRows: true,
323
- headerRow: 0,
324
- layout: {
325
- hLineWidth: function hLineWidth() {
326
- return 0;
327
- },
328
- paddingLeft: function paddingLeft() {
329
- return 0;
330
- },
331
- paddingRight: function paddingRight() {
332
- return 0;
333
- },
334
- paddingTop: function paddingTop() {
335
- return 5;
336
- },
337
- paddingBottom: function paddingBottom() {
338
- return 5;
339
- },
340
- vLineWidth: function vLineWidth() {
341
- return 0;
342
- }
343
- },
344
- widths: [120, 25, 200, 110, '*']
345
- })];
346
- return _context5.abrupt("return", activityTableRow);
347
- case 3:
348
- case "end":
349
- return _context5.stop();
350
- }
351
- }, _callee5);
352
- }));
353
- return function (_x8) {
354
- return _ref6.apply(this, arguments);
355
- };
356
- }());
357
- case 1:
358
- activityTableRows = _context6.sent;
359
- activityTableBody = isEmpty(activityTableRows) ? [[text('No other activity', {
360
- colSpan: 4
361
- })]] : activityTableRows;
362
- activityTable = table({
363
- body: [activityTableHeader].concat(_toConsumableArray(activityTableBody)),
364
- dontBreakRows: true,
365
- layout: {
366
- hLineWidth: function hLineWidth() {
367
- return 0;
368
- },
369
- fillColor: zebraFillColor,
370
- paddingLeft: function paddingLeft() {
371
- return 5;
372
- },
373
- paddingRight: function paddingRight() {
374
- return 5;
375
- },
376
- paddingTop: function paddingTop() {
377
- return 5;
378
- },
379
- paddingBottom: function paddingBottom() {
380
- return 5;
381
- },
382
- vLineWidth: function vLineWidth() {
383
- return 0;
384
- }
385
- },
386
- widths: [110, 15, 230, 80, '*']
387
- });
388
- return _context6.abrupt("return", activityTable);
389
- case 2:
390
- case "end":
391
- return _context6.stop();
392
- }
393
- }, _callee6);
394
- }));
395
- return _buildActivityTable.apply(this, arguments);
196
+ async function buildActivityTable({
197
+ rows,
198
+ settings,
199
+ timezone
200
+ }) {
201
+ const timezoneAbbr = (0, _helpers.getTimezoneAbbr)(timezone);
202
+ const activityTableHeader = [(0, _helpers2.text)('Activity', {
203
+ bold: true
204
+ }), {
205
+ text: ''
206
+ }, (0, _helpers2.text)('Location', {
207
+ bold: true
208
+ }), (0, _helpers2.text)(`Timestamp (${timezoneAbbr})`, {
209
+ alignment: 'right',
210
+ bold: true
211
+ })];
212
+ const activityTableRows = await _bluebird.default.map(rows, async function (data) {
213
+ const {
214
+ link,
215
+ location,
216
+ icon,
217
+ summaryFields,
218
+ timestamp,
219
+ title
220
+ } = data;
221
+ const timezoneHour = (0, _helpers.getTimezoneDatetime)({
222
+ format: 'ddd DD h:mm a',
223
+ showTzAbbr: false,
224
+ timestamp,
225
+ timezone
226
+ });
227
+ const iconCell = icon ? {
228
+ alignment: 'center',
229
+ fit: [8, 8],
230
+ image: icon,
231
+ link
232
+ } : {
233
+ text: ''
234
+ };
235
+ const rows = [[(0, _helpers2.text)(title, {
236
+ link
237
+ }), iconCell, (0, _helpers2.text)(location, {
238
+ link
239
+ }), (0, _helpers2.text)(timezoneHour, {
240
+ alignment: 'right',
241
+ link
242
+ })]];
243
+ const hasSummaryFields = !(0, _lodash.isEmpty)(summaryFields);
244
+ if (hasSummaryFields) {
245
+ const fieldsTable = await (0, _helpers2.summaryFieldsTable)({
246
+ fields: summaryFields,
247
+ settings,
248
+ timezone
249
+ });
250
+ rows.push([fieldsTable]);
251
+ }
252
+ const activityTableRow = [(0, _helpers2.table)({
253
+ body: [...rows],
254
+ colSpan: 5,
255
+ dontBreakRows: true,
256
+ headerRow: 0,
257
+ layout: {
258
+ hLineWidth: () => 0,
259
+ paddingLeft: () => 0,
260
+ paddingRight: () => 0,
261
+ paddingTop: () => 5,
262
+ paddingBottom: () => 5,
263
+ vLineWidth: () => 0
264
+ },
265
+ widths: [120, 25, 200, 110, '*']
266
+ })];
267
+ return activityTableRow;
268
+ });
269
+ const activityTableBody = (0, _lodash.isEmpty)(activityTableRows) ? [[(0, _helpers2.text)('No other activity', {
270
+ colSpan: 4
271
+ })]] : activityTableRows;
272
+ const activityTable = (0, _helpers2.table)({
273
+ body: [activityTableHeader, ...activityTableBody],
274
+ dontBreakRows: true,
275
+ layout: {
276
+ hLineWidth: () => 0,
277
+ fillColor: _helpers2.zebraFillColor,
278
+ paddingLeft: () => 5,
279
+ paddingRight: () => 5,
280
+ paddingTop: () => 5,
281
+ paddingBottom: () => 5,
282
+ vLineWidth: () => 0
283
+ },
284
+ widths: [110, 15, 230, 80, '*']
285
+ });
286
+ return activityTable;
396
287
  }
397
- function getFormRowData(collection, _ref2) {
398
- var locations = _ref2.locations,
399
- zones = _ref2.zones;
400
- return function (document) {
401
- var _id = document._id,
402
- createdAt = document.createdAt,
403
- _document$entry = document.entry,
404
- entry = _document$entry === void 0 ? {} : _document$entry,
405
- _document$title = document.title,
406
- title = _document$title === void 0 ? 'Unknown' : _document$title;
407
- var location = getLocationReference({
288
+ function getFormRowData(collection, {
289
+ locations,
290
+ zones
291
+ }) {
292
+ return document => {
293
+ const {
294
+ _id,
295
+ createdAt,
296
+ entry = {},
297
+ title = 'Unknown'
298
+ } = document;
299
+ const location = (0, _helpers.getLocationReference)({
408
300
  entity: document,
409
- locations: locations,
410
- zones: zones
301
+ locations,
302
+ zones
411
303
  });
412
- var link = "".concat(LIGHTHOUSE_BASE_URL, "/reports/").concat(collection, "/").concat(_id);
413
- var timestamp = createdAt;
414
- var summaryFields = entry.summaryFields || [];
304
+ const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`;
305
+ const timestamp = createdAt;
306
+ const summaryFields = entry.summaryFields || [];
415
307
  return {
416
- icon: launchIcon,
417
- location: location,
418
- link: link,
419
- summaryFields: summaryFields,
420
- timestamp: timestamp,
421
- title: title
308
+ icon: _images.launchIcon,
309
+ location,
310
+ link,
311
+ summaryFields,
312
+ timestamp,
313
+ title
422
314
  };
423
315
  };
424
316
  }
425
- function getScanRowData(_ref3) {
426
- var zones = _ref3.zones;
427
- return function (document) {
428
- var timestamp = document.timestamp,
429
- _document$zone = document.zone,
430
- zone = _document$zone === void 0 ? '' : _document$zone;
431
- var zoneDoc = zone && find(zones, function (doc) {
432
- return doc._id.toString() === zone.toString();
433
- });
434
- var zoneName = zoneDoc && zoneDoc.name;
435
- var location = zoneName || 'Unknown Location';
436
- var title = 'Location Scan';
317
+ function getScanRowData({
318
+ zones
319
+ }) {
320
+ return document => {
321
+ const {
322
+ timestamp,
323
+ zone = ''
324
+ } = document;
325
+ const zoneDoc = zone && (0, _lodash.find)(zones, doc => doc._id.toString() === zone.toString());
326
+ const zoneName = zoneDoc && zoneDoc.name;
327
+ const location = zoneName || 'Unknown Location';
328
+ const title = 'Location Scan';
437
329
  return {
438
- location: location,
439
- timestamp: timestamp,
440
- title: title
330
+ location,
331
+ timestamp,
332
+ title
441
333
  };
442
334
  };
443
335
  }
444
- function buildTimelineTable(_x7) {
445
- return _buildTimelineTable.apply(this, arguments);
446
- }
447
- function _buildTimelineTable() {
448
- _buildTimelineTable = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(data) {
449
- var timezone, timezoneAbbr, shiftRows, sortedRows, timeline, timelineHeaderRow, timelineTable, title, header, hLine, timelineSection;
450
- return _regeneratorRuntime.wrap(function (_context8) {
451
- while (1) switch (_context8.prev = _context8.next) {
452
- case 0:
453
- timezone = data.timezone;
454
- timezoneAbbr = getTimezoneAbbr(timezone);
455
- shiftRows = getShiftRowData(data);
456
- sortedRows = sortBy(shiftRows, ['timestamp'], ['asc']);
457
- _context8.next = 1;
458
- return Promise.map(sortedRows, /*#__PURE__*/function () {
459
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data) {
460
- var location, timestamp, title, timezoneHour, rows;
461
- return _regeneratorRuntime.wrap(function (_context7) {
462
- while (1) switch (_context7.prev = _context7.next) {
463
- case 0:
464
- location = data.location, timestamp = data.timestamp, title = data.title;
465
- timezoneHour = getTimezoneDatetime({
466
- format: 'ddd DD h:mm a',
467
- showTzAbbr: false,
468
- timestamp: timestamp,
469
- timezone: timezone
470
- });
471
- rows = [text(title), text(location), text(timezoneHour, {
472
- alignment: 'right'
473
- })];
474
- return _context7.abrupt("return", rows);
475
- case 1:
476
- case "end":
477
- return _context7.stop();
478
- }
479
- }, _callee7);
480
- }));
481
- return function (_x9) {
482
- return _ref7.apply(this, arguments);
483
- };
484
- }());
485
- case 1:
486
- timeline = _context8.sent;
487
- timelineHeaderRow = [text('Activity', {
488
- bold: true
489
- }), text('Location', {
490
- bold: true
491
- }), text("Timestamp (".concat(timezoneAbbr, ")"), {
492
- alignment: 'right',
493
- bold: true
494
- })];
495
- timelineTable = threeColumnTable({
496
- body: [timelineHeaderRow].concat(_toConsumableArray(timeline))
497
- });
498
- title = text('Timeline', {
499
- style: 'timelineTitle'
500
- });
501
- header = table({
502
- body: [[title]],
503
- layout: 'noBorders',
504
- style: 'summaryHeaderTable'
505
- });
506
- hLine = horizontalLine();
507
- timelineSection = [header, hLine, timelineTable];
508
- return _context8.abrupt("return", timelineSection);
509
- case 2:
510
- case "end":
511
- return _context8.stop();
512
- }
513
- }, _callee8);
514
- }));
515
- return _buildTimelineTable.apply(this, arguments);
336
+ async function buildTimelineTable(data) {
337
+ const {
338
+ timezone
339
+ } = data;
340
+ const timezoneAbbr = (0, _helpers.getTimezoneAbbr)(timezone);
341
+ const shiftRows = getShiftRowData(data);
342
+ const sortedRows = (0, _lodash.sortBy)(shiftRows, ['timestamp'], ['asc']);
343
+ const timeline = await _bluebird.default.map(sortedRows, async function (data) {
344
+ const {
345
+ location,
346
+ timestamp,
347
+ title
348
+ } = data;
349
+ const timezoneHour = (0, _helpers.getTimezoneDatetime)({
350
+ format: 'ddd DD h:mm a',
351
+ showTzAbbr: false,
352
+ timestamp,
353
+ timezone
354
+ });
355
+ const rows = [(0, _helpers2.text)(title), (0, _helpers2.text)(location), (0, _helpers2.text)(timezoneHour, {
356
+ alignment: 'right'
357
+ })];
358
+ return rows;
359
+ });
360
+ const timelineHeaderRow = [(0, _helpers2.text)('Activity', {
361
+ bold: true
362
+ }), (0, _helpers2.text)('Location', {
363
+ bold: true
364
+ }), (0, _helpers2.text)(`Timestamp (${timezoneAbbr})`, {
365
+ alignment: 'right',
366
+ bold: true
367
+ })];
368
+ const timelineTable = (0, _helpers2.threeColumnTable)({
369
+ body: [timelineHeaderRow, ...timeline]
370
+ });
371
+ const title = (0, _helpers2.text)('Timeline', {
372
+ style: 'timelineTitle'
373
+ });
374
+ const header = (0, _helpers2.table)({
375
+ body: [[title]],
376
+ layout: 'noBorders',
377
+ style: 'summaryHeaderTable'
378
+ });
379
+ const hLine = (0, _helpers2.horizontalLine)();
380
+ const timelineSection = [header, hLine, timelineTable];
381
+ return timelineSection;
516
382
  }
517
- function getShiftRowData(_ref4) {
518
- var locations = _ref4.locations,
519
- shift = _ref4.shift,
520
- zones = _ref4.zones;
521
- var breaks = shift.breaks,
522
- end = shift.end,
523
- start = shift.start;
524
- var startValues = getShiftValues(start, {
525
- locations: locations,
526
- shift: shift,
527
- zones: zones
383
+ function getShiftRowData({
384
+ locations,
385
+ shift,
386
+ zones
387
+ }) {
388
+ const {
389
+ breaks,
390
+ end,
391
+ start
392
+ } = shift;
393
+ const startValues = getShiftValues(start, {
394
+ locations,
395
+ shift,
396
+ zones
528
397
  });
529
- var startShift = _objectSpread({
530
- title: 'Shift Started'
531
- }, startValues);
532
- var endValues = getShiftValues(end, {
533
- locations: locations,
534
- shift: shift,
535
- zones: zones
398
+ const startShift = {
399
+ title: 'Shift Started',
400
+ ...startValues
401
+ };
402
+ const endValues = getShiftValues(end, {
403
+ locations,
404
+ shift,
405
+ zones
536
406
  });
537
- var endShift = _objectSpread({
538
- title: 'Shift Ended'
539
- }, endValues);
540
- var shiftData = [startShift, endShift];
541
- each(breaks, function (data) {
542
- var end = data.end,
543
- start = data.start;
544
- var startValues = getShiftValues(start, {
545
- locations: locations,
546
- shift: shift,
547
- zones: zones
407
+ const endShift = {
408
+ title: 'Shift Ended',
409
+ ...endValues
410
+ };
411
+ const shiftData = [startShift, endShift];
412
+ (0, _lodash.each)(breaks, function (data) {
413
+ const {
414
+ end,
415
+ start
416
+ } = data;
417
+ const startValues = getShiftValues(start, {
418
+ locations,
419
+ shift,
420
+ zones
548
421
  });
549
- var startBreak = _objectSpread({
550
- title: 'Break Started'
551
- }, startValues);
552
- var endValues = getShiftValues(end, {
553
- locations: locations,
554
- shift: shift,
555
- zones: zones
422
+ const startBreak = {
423
+ title: 'Break Started',
424
+ ...startValues
425
+ };
426
+ const endValues = getShiftValues(end, {
427
+ locations,
428
+ shift,
429
+ zones
556
430
  });
557
- var endBreak = _objectSpread({
558
- title: 'Break Ended'
559
- }, endValues);
431
+ const endBreak = {
432
+ title: 'Break Ended',
433
+ ...endValues
434
+ };
560
435
  shiftData.push(startBreak);
561
436
  shiftData.push(endBreak);
562
437
  });
563
438
  return shiftData;
564
439
  }
565
- function getShiftValues(value, _ref5) {
566
- var locations = _ref5.locations,
567
- shift = _ref5.shift,
568
- zones = _ref5.zones;
569
- var locationName = getLocationReference({
440
+ function getShiftValues(value, {
441
+ locations,
442
+ shift,
443
+ zones
444
+ }) {
445
+ const locationName = (0, _helpers.getLocationReference)({
570
446
  entity: value,
571
- locations: locations,
572
- zones: zones
447
+ locations,
448
+ zones
573
449
  });
574
- var location = locationName === 'Unknown Location' ? getLocationReference({
450
+ const location = locationName === 'Unknown Location' ? (0, _helpers.getLocationReference)({
575
451
  entity: shift,
576
- locations: locations,
577
- zones: zones
452
+ locations,
453
+ zones
578
454
  }) : locationName;
579
455
  return {
580
456
  timestamp: value.time,
581
- location: location
457
+ location
582
458
  };
583
459
  }
584
- export function getFineDuration(durationValue) {
585
- var measurement = 'milliseconds';
586
- var durationByMeasurement = duration(durationValue, measurement);
587
- var days = durationByMeasurement.get('days');
588
- var hours = durationByMeasurement.get('hours');
589
- var minutes = durationByMeasurement.get('minutes');
590
- var fineDuration = '';
460
+ function getFineDuration(durationValue) {
461
+ const measurement = 'milliseconds';
462
+ const durationByMeasurement = (0, _momentTimezone.duration)(durationValue, measurement);
463
+ const days = durationByMeasurement.get('days');
464
+ const hours = durationByMeasurement.get('hours');
465
+ const minutes = durationByMeasurement.get('minutes');
466
+ let fineDuration = '';
591
467
  fineDuration += days !== 0 ? days + 'd ' : '';
592
468
  fineDuration += hours !== 0 ? hours + 'h ' : '';
593
469
  fineDuration += minutes !== 0 ? minutes + 'm' : '';
594
- return trim(fineDuration);
470
+ return (0, _lodash.trim)(fineDuration);
595
471
  }
596
472
  function getBreakDuration(breaks) {
597
- var duration = sum(map(breaks, function (data) {
598
- var end = data.end,
599
- start = data.start;
600
- var endBreak = moment(end.time);
601
- var startBreak = moment(start.time);
602
- var breakDuration = endBreak.diff(startBreak);
473
+ const duration = (0, _lodash.sum)((0, _lodash.map)(breaks, function (data) {
474
+ const {
475
+ end,
476
+ start
477
+ } = data;
478
+ const endBreak = (0, _momentTimezone.default)(end.time);
479
+ const startBreak = (0, _momentTimezone.default)(start.time);
480
+ const breakDuration = endBreak.diff(startBreak);
603
481
  return breakDuration;
604
482
  }));
605
- var breakDuration = getFineDuration(duration);
483
+ const breakDuration = getFineDuration(duration);
606
484
  return breakDuration;
607
485
  }
608
486
  //# sourceMappingURL=index.js.map