@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,12 +1,15 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- 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; }
4
- 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; }
5
- import { get, isEmpty, map } from 'lodash';
6
- import moment from 'moment-timezone';
7
- import { generateDefinition, horizontalLine, table, text, twoColumnTable } from '../helpers';
8
- import { getJobDetails, getPrettyDuration, getTimezoneDatetime, getUserFullName } from '../../helpers';
9
- var ACTIVITY_COLUMN_HEADERS = [{
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.buildJobPdf = buildJobPdf;
8
+ var _lodash = require("lodash");
9
+ var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
10
+ var _helpers = require("../helpers");
11
+ var _helpers2 = require("../../helpers");
12
+ const ACTIVITY_COLUMN_HEADERS = [{
10
13
  text: 'Type',
11
14
  bold: true
12
15
  }, {
@@ -29,50 +32,57 @@ var ACTIVITY_COLUMN_HEADERS = [{
29
32
  bold: true
30
33
  }];
31
34
 
32
- /**
33
- * buildJobPdf
34
- *
35
- * @param {object} pdfOptions - the pdf options
36
- * @param {string} pdfOptions.fileTitle - pdf file title
37
- * @param {function} pdfOptions.footer - function executed to generate footer
38
- * @param {function} pdfOptions.header - function executed to generate header
39
- * @param {string} pdfOptions.logoUrl - pdf logo url
40
- * @param {array} pdfOptions.pageMargins - pdf page margins
41
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
42
- * @param {string} pdfOptions.pageSize - pdf page size
43
- * @param {object} pdfOptions.styles - pdf styles
44
- * @param {object} pdfOptions.title - pdf title
45
- * @param {object} data - pdf data
46
- * @param {object} data.entity - job document
47
- * @param {array} data.jobActivities - job activities documents
48
- * @param {object} data.settings - settings properties
49
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
50
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
51
- * @param {string} data.timezone - timezone string
52
- * @param {object} data.users - application user documents
53
- * @returns {Promise} returns pdfmake definition object
35
+ /**
36
+ * buildJobPdf
37
+ *
38
+ * @param {object} pdfOptions - the pdf options
39
+ * @param {string} pdfOptions.fileTitle - pdf file title
40
+ * @param {function} pdfOptions.footer - function executed to generate footer
41
+ * @param {function} pdfOptions.header - function executed to generate header
42
+ * @param {string} pdfOptions.logoUrl - pdf logo url
43
+ * @param {array} pdfOptions.pageMargins - pdf page margins
44
+ * @param {string} pdfOptions.pageOrientation - pdf page orientation
45
+ * @param {string} pdfOptions.pageSize - pdf page size
46
+ * @param {object} pdfOptions.styles - pdf styles
47
+ * @param {object} pdfOptions.title - pdf title
48
+ * @param {object} data - pdf data
49
+ * @param {object} data.entity - job document
50
+ * @param {array} data.jobActivities - job activities documents
51
+ * @param {object} data.settings - settings properties
52
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
53
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
54
+ * @param {string} data.timezone - timezone string
55
+ * @param {object} data.users - application user documents
56
+ * @returns {Promise} returns pdfmake definition object
54
57
  */
55
- export function buildJobPdf(pdfOptions, data) {
56
- var entity = data.entity,
57
- timezone = data.timezone;
58
- var timestamp = entity.createdAt;
59
- var title = entity.title || 'Unknown';
60
- var fileTitle = "Job Report - ".concat(title);
61
- var content = generateContent(data);
62
- return generateDefinition(_objectSpread({
63
- content: content,
64
- fileTitle: fileTitle,
58
+ function buildJobPdf(pdfOptions, data) {
59
+ const {
60
+ entity,
61
+ timezone
62
+ } = data;
63
+ const timestamp = entity.createdAt;
64
+ const title = entity.title || 'Unknown';
65
+ const fileTitle = `Job Report - ${title}`;
66
+ const content = generateContent(data);
67
+ return (0, _helpers.generateDefinition)({
68
+ content,
69
+ fileTitle,
65
70
  pageOrientation: 'landscape',
66
- timestamp: timestamp,
67
- timezone: timezone,
68
- type: 'Job'
69
- }, pdfOptions));
71
+ timestamp,
72
+ timezone,
73
+ type: 'Job',
74
+ ...pdfOptions
75
+ });
70
76
  }
71
77
  function generateContent(data) {
72
- var entity = data.entity;
73
- var title = entity.title;
74
- var entityDetails = getJobDetails(data);
75
- var metaTableData = [[{
78
+ const {
79
+ entity
80
+ } = data;
81
+ const {
82
+ title
83
+ } = entity;
84
+ const entityDetails = (0, _helpers2.getJobDetails)(data);
85
+ const metaTableData = [[{
76
86
  text: 'Location',
77
87
  bold: true
78
88
  }, entityDetails.locationText], [{
@@ -103,68 +113,72 @@ function generateContent(data) {
103
113
  text: 'Timezone',
104
114
  bold: true
105
115
  }, entityDetails.timezoneAbbrText]];
106
- var headerTitle = text("Job Report: ".concat(title), {
116
+ const headerTitle = (0, _helpers.text)(`Job Report: ${title}`, {
107
117
  style: 'title'
108
118
  });
109
- var titleTable = table({
119
+ const titleTable = (0, _helpers.table)({
110
120
  body: [[headerTitle]],
111
121
  layout: 'noBorders',
112
122
  style: 'titleTable'
113
123
  });
114
- var metaDataTable = twoColumnTable({
124
+ const metaDataTable = (0, _helpers.twoColumnTable)({
115
125
  body: metaTableData,
116
126
  widths: [150, '*']
117
127
  });
118
- var activitiesTitleTable = table({
128
+ const activitiesTitleTable = (0, _helpers.table)({
119
129
  body: [['Job Activities']],
120
130
  layout: 'noBorders',
121
131
  style: 'activitiesTable'
122
132
  });
123
- var activityTableData = buildActivitiesContent(data);
124
- var activityTable = table(activityTableData);
125
- var hLine = horizontalLine();
133
+ const activityTableData = buildActivitiesContent(data);
134
+ const activityTable = (0, _helpers.table)(activityTableData);
135
+ const hLine = (0, _helpers.horizontalLine)();
126
136
  return [titleTable, metaDataTable, activitiesTitleTable, hLine, activityTable, hLine];
127
137
  }
128
138
  function buildActivitiesContent(data) {
129
- var jobActivities = data.jobActivities,
130
- timezone = data.timezone,
131
- users = data.users;
132
- if (isEmpty(jobActivities)) {
139
+ const {
140
+ jobActivities,
141
+ timezone,
142
+ users
143
+ } = data;
144
+ if ((0, _lodash.isEmpty)(jobActivities)) {
133
145
  return {
134
146
  body: [['No Job Activities']],
135
147
  widths: '*'
136
148
  };
137
149
  }
138
- var activityRows = map(jobActivities, function (activity) {
139
- var entity = activity.entity;
140
- var type = entity.type,
141
- duration = entity.duration,
142
- user = entity.user,
143
- _entity$start = entity.start,
144
- start = _entity$start === void 0 ? {} : _entity$start,
145
- _entity$end = entity.end,
146
- end = _entity$end === void 0 ? {} : _entity$end;
147
- var authorText = getUserFullName(users, user);
148
- var mDuration = moment.duration(duration, 'minutes');
149
- var durationText = duration ? getPrettyDuration(mDuration) : '';
150
- var startTime = start.time;
151
- var startLocation = get(start, 'geometryReverseGeocoded.label', '');
152
- var endTime = end.time;
153
- var endLocation = get(end, 'geometryReverseGeocoded.label', '');
154
- var startTimeText = startTime ? getTimezoneDatetime({
150
+ const activityRows = (0, _lodash.map)(jobActivities, activity => {
151
+ const {
152
+ entity
153
+ } = activity;
154
+ const {
155
+ type,
156
+ duration,
157
+ user,
158
+ start = {},
159
+ end = {}
160
+ } = entity;
161
+ const authorText = (0, _helpers2.getUserFullName)(users, user);
162
+ const mDuration = _momentTimezone.default.duration(duration, 'minutes');
163
+ const durationText = duration ? (0, _helpers2.getPrettyDuration)(mDuration) : '';
164
+ const startTime = start.time;
165
+ const startLocation = (0, _lodash.get)(start, 'geometryReverseGeocoded.label', '');
166
+ const endTime = end.time;
167
+ const endLocation = (0, _lodash.get)(end, 'geometryReverseGeocoded.label', '');
168
+ const startTimeText = startTime ? (0, _helpers2.getTimezoneDatetime)({
155
169
  showTzAbbr: false,
156
170
  timestamp: startTime,
157
- timezone: timezone
171
+ timezone
158
172
  }) : '';
159
- var endTimeText = endTime ? getTimezoneDatetime({
173
+ const endTimeText = endTime ? (0, _helpers2.getTimezoneDatetime)({
160
174
  showTzAbbr: false,
161
175
  timestamp: endTime,
162
- timezone: timezone
176
+ timezone
163
177
  }) : '';
164
178
  return [type, authorText, startTimeText, startLocation, endTimeText, endLocation, durationText];
165
179
  });
166
180
  return {
167
- body: [ACTIVITY_COLUMN_HEADERS].concat(_toConsumableArray(activityRows)),
181
+ body: [ACTIVITY_COLUMN_HEADERS, ...activityRows],
168
182
  widths: [70, 80, 60, '*', 60, '*', 50]
169
183
  };
170
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["get","isEmpty","map","moment","generateDefinition","horizontalLine","table","text","twoColumnTable","getJobDetails","getPrettyDuration","getTimezoneDatetime","getUserFullName","ACTIVITY_COLUMN_HEADERS","bold","buildJobPdf","pdfOptions","data","entity","timezone","timestamp","createdAt","title","fileTitle","concat","content","generateContent","_objectSpread","pageOrientation","type","entityDetails","metaTableData","locationText","authorFullName","reference","description","dueDateTimezoneDateTime","assigneeNames","statusText","color","statusColor","createdTimezoneDateTime","timezoneAbbrText","headerTitle","style","titleTable","body","layout","metaDataTable","widths","activitiesTitleTable","activityTableData","buildActivitiesContent","activityTable","hLine","jobActivities","users","activityRows","activity","duration","user","_entity$start","start","_entity$end","end","authorText","mDuration","durationText","startTime","time","startLocation","endTime","endLocation","startTimeText","showTzAbbr","endTimeText","_toConsumableArray"],"sources":["../../../src/pdf/job/index.js"],"sourcesContent":["import { get, isEmpty, map } from 'lodash'\nimport moment from 'moment-timezone'\n\nimport {\n generateDefinition,\n horizontalLine,\n table,\n text,\n twoColumnTable,\n} from '../helpers'\n\nimport {\n getJobDetails,\n getPrettyDuration,\n getTimezoneDatetime,\n getUserFullName,\n} from '../../helpers'\n\nconst ACTIVITY_COLUMN_HEADERS = [\n { text: 'Type', bold: true },\n { text: 'User', bold: true },\n { text: 'Start Time', bold: true },\n { text: 'Start Location', bold: true },\n { text: 'End Time', bold: true },\n { text: 'End Location', bold: true },\n { text: 'Duration', bold: true },\n]\n\n/**\n * buildJobPdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} data - pdf data\n * @param {object} data.entity - job document\n * @param {array} data.jobActivities - job activities documents\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url\n * @param {string} data.timezone - timezone string\n * @param {object} data.users - application user documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport function buildJobPdf(pdfOptions, data) {\n const { entity, timezone } = data\n\n const timestamp = entity.createdAt\n const title = entity.title || 'Unknown'\n\n const fileTitle = `Job Report - ${title}`\n\n const content = generateContent(data)\n\n return generateDefinition({\n content,\n fileTitle,\n pageOrientation: 'landscape',\n timestamp,\n timezone,\n type: 'Job',\n ...pdfOptions,\n })\n}\n\nfunction generateContent(data) {\n const { entity } = data\n const { title } = entity\n\n const entityDetails = getJobDetails(data)\n\n const metaTableData = [\n [{ text: 'Location', bold: true }, entityDetails.locationText],\n [{ text: 'Author', bold: true }, entityDetails.authorFullName],\n [{ text: 'Reference', bold: true }, entityDetails.reference],\n [{ text: 'Description', bold: true }, entityDetails.description],\n [{ text: 'Due Date', bold: true }, entityDetails.dueDateTimezoneDateTime],\n [{ text: 'Assignees', bold: true }, entityDetails.assigneeNames],\n [\n { text: 'Status', bold: true },\n { text: entityDetails.statusText, color: entityDetails.statusColor },\n ],\n [{ text: 'Created', bold: true }, entityDetails.createdTimezoneDateTime],\n [{ text: 'Timezone', bold: true }, entityDetails.timezoneAbbrText],\n ]\n\n const headerTitle = text(`Job Report: ${title}`, { style: 'title' })\n\n const titleTable = table({\n body: [[headerTitle]],\n layout: 'noBorders',\n style: 'titleTable',\n })\n\n const metaDataTable = twoColumnTable({\n body: metaTableData,\n widths: [150, '*'],\n })\n\n const activitiesTitleTable = table({\n body: [['Job Activities']],\n layout: 'noBorders',\n style: 'activitiesTable',\n })\n\n const activityTableData = buildActivitiesContent(data)\n const activityTable = table(activityTableData)\n const hLine = horizontalLine()\n\n return [\n titleTable,\n metaDataTable,\n activitiesTitleTable,\n hLine,\n activityTable,\n hLine,\n ]\n}\n\nfunction buildActivitiesContent(data) {\n const { jobActivities, timezone, users } = data\n\n if (isEmpty(jobActivities)) {\n return {\n body: [['No Job Activities']],\n widths: '*',\n }\n }\n\n const activityRows = map(jobActivities, (activity) => {\n const { entity } = activity\n\n const { type, duration, user, start = {}, end = {} } = entity\n\n const authorText = getUserFullName(users, user)\n\n const mDuration = moment.duration(duration, 'minutes')\n const durationText = duration ? getPrettyDuration(mDuration) : ''\n\n const startTime = start.time\n const startLocation = get(start, 'geometryReverseGeocoded.label', '')\n\n const endTime = end.time\n const endLocation = get(end, 'geometryReverseGeocoded.label', '')\n\n const startTimeText = startTime\n ? getTimezoneDatetime({\n showTzAbbr: false,\n timestamp: startTime,\n timezone,\n })\n : ''\n\n const endTimeText = endTime\n ? getTimezoneDatetime({\n showTzAbbr: false,\n timestamp: endTime,\n timezone,\n })\n : ''\n\n return [\n type,\n authorText,\n startTimeText,\n startLocation,\n endTimeText,\n endLocation,\n durationText,\n ]\n })\n\n return {\n body: [ACTIVITY_COLUMN_HEADERS, ...activityRows],\n widths: [70, 80, 60, '*', 60, '*', 50],\n }\n}\n"],"mappings":";;;;AAAA,SAASA,GAAG,EAAEC,OAAO,EAAEC,GAAG,QAAQ,QAAQ;AAC1C,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SACEC,kBAAkB,EAClBC,cAAc,EACdC,KAAK,EACLC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,aAAa,EACbH,aAAa,EACbK,WAAW,EACXH,WAAW,EACXL,YAAY,CACb;EACH,CAAC,CAAC;EAEF,OAAO;IACLrB,IAAI,GAAGjC,uBAAuB,EAAAW,MAAA,CAAAoD,kBAAA,CAAKnB,YAAY,EAAC;IAChDR,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;EACvC,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_lodash","require","_momentTimezone","_interopRequireDefault","_helpers","_helpers2","ACTIVITY_COLUMN_HEADERS","text","bold","buildJobPdf","pdfOptions","data","entity","timezone","timestamp","createdAt","title","fileTitle","content","generateContent","generateDefinition","pageOrientation","type","entityDetails","getJobDetails","metaTableData","locationText","authorFullName","reference","description","dueDateTimezoneDateTime","assigneeNames","statusText","color","statusColor","createdTimezoneDateTime","timezoneAbbrText","headerTitle","style","titleTable","table","body","layout","metaDataTable","twoColumnTable","widths","activitiesTitleTable","activityTableData","buildActivitiesContent","activityTable","hLine","horizontalLine","jobActivities","users","isEmpty","activityRows","map","activity","duration","user","start","end","authorText","getUserFullName","mDuration","moment","durationText","getPrettyDuration","startTime","time","startLocation","get","endTime","endLocation","startTimeText","getTimezoneDatetime","showTzAbbr","endTimeText"],"sources":["../../../src/pdf/job/index.js"],"sourcesContent":["import { get, isEmpty, map } from 'lodash'\r\nimport moment from 'moment-timezone'\r\n\r\nimport {\r\n generateDefinition,\r\n horizontalLine,\r\n table,\r\n text,\r\n twoColumnTable,\r\n} from '../helpers'\r\n\r\nimport {\r\n getJobDetails,\r\n getPrettyDuration,\r\n getTimezoneDatetime,\r\n getUserFullName,\r\n} from '../../helpers'\r\n\r\nconst ACTIVITY_COLUMN_HEADERS = [\r\n { text: 'Type', bold: true },\r\n { text: 'User', bold: true },\r\n { text: 'Start Time', bold: true },\r\n { text: 'Start Location', bold: true },\r\n { text: 'End Time', bold: true },\r\n { text: 'End Location', bold: true },\r\n { text: 'Duration', bold: true },\r\n]\r\n\r\n/**\r\n * buildJobPdf\r\n *\r\n * @param {object} pdfOptions - the pdf options\r\n * @param {string} pdfOptions.fileTitle - pdf file title\r\n * @param {function} pdfOptions.footer - function executed to generate footer\r\n * @param {function} pdfOptions.header - function executed to generate header\r\n * @param {string} pdfOptions.logoUrl - pdf logo url\r\n * @param {array} pdfOptions.pageMargins - pdf page margins\r\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\r\n * @param {string} pdfOptions.pageSize - pdf page size\r\n * @param {object} pdfOptions.styles - pdf styles\r\n * @param {object} pdfOptions.title - pdf title\r\n * @param {object} data - pdf data\r\n * @param {object} data.entity - job document\r\n * @param {array} data.jobActivities - job activities documents\r\n * @param {object} data.settings - settings properties\r\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\r\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\r\n * @param {string} data.timezone - timezone string\r\n * @param {object} data.users - application user documents\r\n * @returns {Promise} returns pdfmake definition object\r\n */\r\nexport function buildJobPdf(pdfOptions, data) {\r\n const { entity, timezone } = data\r\n\r\n const timestamp = entity.createdAt\r\n const title = entity.title || 'Unknown'\r\n\r\n const fileTitle = `Job Report - ${title}`\r\n\r\n const content = generateContent(data)\r\n\r\n return generateDefinition({\r\n content,\r\n fileTitle,\r\n pageOrientation: 'landscape',\r\n timestamp,\r\n timezone,\r\n type: 'Job',\r\n ...pdfOptions,\r\n })\r\n}\r\n\r\nfunction generateContent(data) {\r\n const { entity } = data\r\n const { title } = entity\r\n\r\n const entityDetails = getJobDetails(data)\r\n\r\n const metaTableData = [\r\n [{ text: 'Location', bold: true }, entityDetails.locationText],\r\n [{ text: 'Author', bold: true }, entityDetails.authorFullName],\r\n [{ text: 'Reference', bold: true }, entityDetails.reference],\r\n [{ text: 'Description', bold: true }, entityDetails.description],\r\n [{ text: 'Due Date', bold: true }, entityDetails.dueDateTimezoneDateTime],\r\n [{ text: 'Assignees', bold: true }, entityDetails.assigneeNames],\r\n [\r\n { text: 'Status', bold: true },\r\n { text: entityDetails.statusText, color: entityDetails.statusColor },\r\n ],\r\n [{ text: 'Created', bold: true }, entityDetails.createdTimezoneDateTime],\r\n [{ text: 'Timezone', bold: true }, entityDetails.timezoneAbbrText],\r\n ]\r\n\r\n const headerTitle = text(`Job Report: ${title}`, { style: 'title' })\r\n\r\n const titleTable = table({\r\n body: [[headerTitle]],\r\n layout: 'noBorders',\r\n style: 'titleTable',\r\n })\r\n\r\n const metaDataTable = twoColumnTable({\r\n body: metaTableData,\r\n widths: [150, '*'],\r\n })\r\n\r\n const activitiesTitleTable = table({\r\n body: [['Job Activities']],\r\n layout: 'noBorders',\r\n style: 'activitiesTable',\r\n })\r\n\r\n const activityTableData = buildActivitiesContent(data)\r\n const activityTable = table(activityTableData)\r\n const hLine = horizontalLine()\r\n\r\n return [\r\n titleTable,\r\n metaDataTable,\r\n activitiesTitleTable,\r\n hLine,\r\n activityTable,\r\n hLine,\r\n ]\r\n}\r\n\r\nfunction buildActivitiesContent(data) {\r\n const { jobActivities, timezone, users } = data\r\n\r\n if (isEmpty(jobActivities)) {\r\n return {\r\n body: [['No Job Activities']],\r\n widths: '*',\r\n }\r\n }\r\n\r\n const activityRows = map(jobActivities, activity => {\r\n const { entity } = activity\r\n\r\n const { type, duration, user, start = {}, end = {} } = entity\r\n\r\n const authorText = getUserFullName(users, user)\r\n\r\n const mDuration = moment.duration(duration, 'minutes')\r\n const durationText = duration ? getPrettyDuration(mDuration) : ''\r\n\r\n const startTime = start.time\r\n const startLocation = get(start, 'geometryReverseGeocoded.label', '')\r\n\r\n const endTime = end.time\r\n const endLocation = get(end, 'geometryReverseGeocoded.label', '')\r\n\r\n const startTimeText = startTime\r\n ? getTimezoneDatetime({\r\n showTzAbbr: false,\r\n timestamp: startTime,\r\n timezone,\r\n })\r\n : ''\r\n\r\n const endTimeText = endTime\r\n ? getTimezoneDatetime({\r\n showTzAbbr: false,\r\n timestamp: endTime,\r\n timezone,\r\n })\r\n : ''\r\n\r\n return [\r\n type,\r\n authorText,\r\n startTimeText,\r\n startLocation,\r\n endTimeText,\r\n endLocation,\r\n durationText,\r\n ]\r\n })\r\n\r\n return {\r\n body: [ACTIVITY_COLUMN_HEADERS, ...activityRows],\r\n widths: [70, 80, 60, '*', 60, '*', 50],\r\n }\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAQA,IAAAI,SAAA,GAAAJ,OAAA;AAOA,MAAMK,uBAAuB,GAAG,CAC9B;EAAEC,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE;AAAK,CAAC,EAC5B;EAAED,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE;AAAK,CAAC,EAC5B;EAAED,IAAI,EAAE,YAAY;EAAEC,IAAI,EAAE;AAAK,CAAC,EAClC;EAAED,IAAI,EAAE,gBAAgB;EAAEC,IAAI,EAAE;AAAK,CAAC,EACtC;EAAED,IAAI,EAAE,UAAU;EAAEC,IAAI,EAAE;AAAK,CAAC,EAChC;EAAED,IAAI,EAAE,cAAc;EAAEC,IAAI,EAAE;AAAK,CAAC,EACpC;EAAED,IAAI,EAAE,UAAU;EAAEC,IAAI,EAAE;AAAK,CAAC,CACjC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAACC,UAAU,EAAEC,IAAI,EAAE;EAC5C,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAGF,IAAI;EAEjC,MAAMG,SAAS,GAAGF,MAAM,CAACG,SAAS;EAClC,MAAMC,KAAK,GAAGJ,MAAM,CAACI,KAAK,IAAI,SAAS;EAEvC,MAAMC,SAAS,GAAG,gBAAgBD,KAAK,EAAE;EAEzC,M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C,CAAC;EAEF,OAAO;IACLzB,IAAI,EAAE,CAACnC,uBAAuB,EAAE,GAAGiD,YAAY,CAAC;IAChDV,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;EACvC,CAAC;AACH","ignoreList":[]}
@@ -1,9 +1,15 @@
1
- export var user = {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.user = exports.shift = void 0;
7
+ const user = exports.user = {
2
8
  _id: '5bb7d1c618c1bb0001e8028a',
3
9
  firstName: 'John',
4
10
  lastName: 'Doe'
5
11
  };
6
- export var shift = {
12
+ const shift = exports.shift = {
7
13
  end: {
8
14
  time: '2019-09-19T20:00:00.000+0000'
9
15
  },
@@ -1 +1 @@
1
- {"version":3,"file":"emptyFixtures.js","names":["user","_id","firstName","lastName","shift","end","time","start"],"sources":["../../../src/pdf/shift-report/emptyFixtures.js"],"sourcesContent":["export const user = {\n _id: '5bb7d1c618c1bb0001e8028a',\n firstName: 'John',\n lastName: 'Doe',\n}\n\nexport const shift = {\n end: {\n time: '2019-09-19T20:00:00.000+0000',\n },\n start: {\n time: '2019-09-19T14:00:00.000+0000',\n },\n}\n"],"mappings":"AAAA,OAAO,IAAMA,IAAI,GAAG;EAClBC,GAAG,EAAE,0BAA0B;EAC/BC,SAAS,EAAE,MAAM;EACjBC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,IAAMC,KAAK,GAAG;EACnBC,GAAG,EAAE;IACHC,IAAI,EAAE;EACR,CAAC;EACDC,KAAK,EAAE;IACLD,IAAI,EAAE;EACR;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"emptyFixtures.js","names":["user","exports","_id","firstName","lastName","shift","end","time","start"],"sources":["../../../src/pdf/shift-report/emptyFixtures.js"],"sourcesContent":["export const user = {\r\n _id: '5bb7d1c618c1bb0001e8028a',\r\n firstName: 'John',\r\n lastName: 'Doe',\r\n}\r\n\r\nexport const shift = {\r\n end: {\r\n time: '2019-09-19T20:00:00.000+0000',\r\n },\r\n start: {\r\n time: '2019-09-19T14:00:00.000+0000',\r\n },\r\n}\r\n"],"mappings":";;;;;;AAAO,MAAMA,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAClBE,GAAG,EAAE,0BAA0B;EAC/BC,SAAS,EAAE,MAAM;EACjBC,QAAQ,EAAE;AACZ,CAAC;AAEM,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAG;EACnBC,GAAG,EAAE;IACHC,IAAI,EAAE;EACR,CAAC;EACDC,KAAK,EAAE;IACLD,IAAI,EAAE;EACR;AACF,CAAC","ignoreList":[]}