@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
package/README.md CHANGED
@@ -1 +1 @@
1
- # common
1
+ # common
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FetchImageError = void 0;
7
- /**
8
- * Custom error class for image fetching operations
9
- * Includes context information for better debugging
7
+ /**
8
+ * Custom error class for image fetching operations
9
+ * Includes context information for better debugging
10
10
  */
11
11
  class FetchImageError extends Error {
12
12
  constructor(message, context = {}) {
@@ -176,13 +176,13 @@ function formatBase64Image({
176
176
  return fullDataUrl;
177
177
  }
178
178
 
179
- /**
180
- * Parses a URL-like string into path and query parameters
181
- * @param {string} urlString - String like "https://example.cloudfront.net/<applicationId>/<path>/filename.jpeg?width=100&height=100"
182
- * @returns {Object} - Object with { path: string, queryString: string, searchParamsObject: Object }
183
- * @example
184
- * parseUrlString("https://example.cloudfront.net/abc123/folder/image.jpeg?width=100&height=100")
185
- * // Returns: { path: "abc123/folder/image.jpeg", queryString: "width=100,t=456", searchParamsObject: { width: "100", height: "100" } }
179
+ /**
180
+ * Parses a URL-like string into path and query parameters
181
+ * @param {string} urlString - String like "https://example.cloudfront.net/<applicationId>/<path>/filename.jpeg?width=100&height=100"
182
+ * @returns {Object} - Object with { path: string, queryString: string, searchParamsObject: Object }
183
+ * @example
184
+ * parseUrlString("https://example.cloudfront.net/abc123/folder/image.jpeg?width=100&height=100")
185
+ * // Returns: { path: "abc123/folder/image.jpeg", queryString: "width=100,t=456", searchParamsObject: { width: "100", height: "100" } }
186
186
  */
187
187
  function parseUrlString(urlString) {
188
188
  if (!urlString || typeof urlString !== 'string') {
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = floatify;
7
- /**
8
- * floatify
9
- * Accepts a number and returns a float rounded to the expected precision,
10
- * avoiding floating point errors
11
- * https://stackoverflow.com/questions/588004/is-floating-point-math-broken/51723472#51723472
12
- * @param {Number} number
7
+ /**
8
+ * floatify
9
+ * Accepts a number and returns a float rounded to the expected precision,
10
+ * avoiding floating point errors
11
+ * https://stackoverflow.com/questions/588004/is-floating-point-math-broken/51723472#51723472
12
+ * @param {Number} number
13
13
  */
14
14
  function floatify(number) {
15
15
  return parseFloat(number.toFixed(10));
@@ -53,42 +53,53 @@ function getAuditItemsData(items, data) {
53
53
  const hasScore = item.score !== null && item.score !== -1;
54
54
  const rawAssets = item.assets || [];
55
55
  const assetCount = rawAssets.length;
56
- const assets = rawAssets.map((asset, assetIndex) => {
57
- const assetUrl = (0, _.buildFetchUrl)(asset, {
58
- awsS3BaseUrl,
59
- cloudfrontBaseUrl,
60
- cloudinaryBaseUrl,
61
- height: 400,
62
- width: 600,
63
- quality: 50,
64
- fit: true,
65
- shouldUseCloudfront,
66
- Policy,
67
- KeyPairId,
68
- Signature
69
- });
70
- const link = shouldUseCloudfront ? `${cloudfrontBaseUrl}/${item.signedAssets?.[assetIndex] || asset}` : `${awsS3BaseUrl}/${asset}`;
71
- const thumbnailUrl = (0, _.buildFetchUrl)(asset, {
72
- awsS3BaseUrl,
73
- cloudfrontBaseUrl,
74
- cloudinaryBaseUrl,
75
- shouldUseCloudfront,
76
- width: 100,
77
- quality: 50,
78
- fit: true,
79
- shouldUseCloudfront,
80
- Policy,
81
- KeyPairId,
82
- Signature
83
- });
84
- const key = `${groupIndex}-item-asset-${assetIndex}`;
85
- return {
86
- assetUrl,
87
- key,
88
- link,
89
- thumbnailUrl
90
- };
91
- });
56
+ const assets = rawAssets.reduce((acc, asset, assetIndex) => {
57
+ try {
58
+ const assetUrl = (0, _.buildFetchUrl)(asset, {
59
+ awsS3BaseUrl,
60
+ cloudfrontBaseUrl,
61
+ cloudinaryBaseUrl,
62
+ height: 400,
63
+ width: 600,
64
+ quality: 50,
65
+ fit: true,
66
+ shouldUseCloudfront,
67
+ Policy,
68
+ KeyPairId,
69
+ Signature
70
+ });
71
+ const link = shouldUseCloudfront ? `${cloudfrontBaseUrl}/${item.signedAssets[assetIndex]}` : `${awsS3BaseUrl}/${asset}`;
72
+ const thumbnailUrl = (0, _.buildFetchUrl)(asset, {
73
+ awsS3BaseUrl,
74
+ cloudfrontBaseUrl,
75
+ cloudinaryBaseUrl,
76
+ shouldUseCloudfront,
77
+ width: 100,
78
+ quality: 50,
79
+ fit: true,
80
+ shouldUseCloudfront,
81
+ Policy,
82
+ KeyPairId,
83
+ Signature
84
+ });
85
+ const key = `${groupIndex}-item-asset-${assetIndex}`;
86
+ acc.push({
87
+ assetUrl,
88
+ key,
89
+ link,
90
+ thumbnailUrl
91
+ });
92
+ } catch (error) {
93
+ console.error({
94
+ message: 'Failed to build asset URL',
95
+ asset,
96
+ assetIndex,
97
+ groupIndex,
98
+ error: error.message
99
+ });
100
+ }
101
+ return acc;
102
+ }, []);
92
103
  const comments = item.comments;
93
104
  const label = item.label;
94
105
  const score = item.score;
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isAbsoluteUrl = isAbsoluteUrl;
7
- /**
8
- * Checks if a URL is absolute (starts with http:// or https://)
9
- * @param {string} url - The URL to validate
10
- * @returns {boolean} - True if URL is absolute, false otherwise
7
+ /**
8
+ * Checks if a URL is absolute (starts with http:// or https://)
9
+ * @param {string} url - The URL to validate
10
+ * @returns {boolean} - True if URL is absolute, false otherwise
11
11
  */
12
12
  function isAbsoluteUrl(url) {
13
13
  if (!url || typeof url !== 'string') return false;
@@ -15,38 +15,38 @@ const DEFAULT_MAX_SCANS = 200;
15
15
  const MAX_ATTACHMENTS = 100;
16
16
  const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
17
17
 
18
- /**
19
- * buildActivityPdf
20
- *
21
- * @param {object} pdfOptions - the pdf options
22
- * @param {string} pdfOptions.fileTitle - pdf file title
23
- * @param {function} pdfOptions.footer - function executed to generate footer
24
- * @param {function} pdfOptions.header - function executed to generate header
25
- * @param {string} pdfOptions.logoUrl - pdf logo url
26
- * @param {array} pdfOptions.pageMargins - pdf page margins
27
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
28
- * @param {string} pdfOptions.pageSize - pdf page size
29
- * @param {object} pdfOptions.styles - pdf styles
30
- * @param {object} pdfOptions.title - pdf title
31
- * @param {object} data - pdf data
32
- * @param {array} data.audits - audit documents
33
- * @param {string} data.end - end datetime of summary report
34
- * @param {array} data.events - event documents
35
- * @param {object} data.location - location document
36
- * @param {array} data.locations - location documents
37
- * @param {array} data.issues - issue documents
38
- * @param {bool} data.maxScans - max scans to include in standard report
39
- * @param {bool} data.showAlternate - show alternate summary report
40
- * @param {string} data.start - start datetime of summary report
41
- * @param {object} data.settings - settings properties
42
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
43
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
44
- * @param {array} data.tasks - task documents
45
- * @param {string} data.timestamp - timestamp string
46
- * @param {string} data.timezone - timezone string
47
- * @param {array} data.zones - zone documents
48
- * @param {array} data.users - user documents
49
- * @returns {Promise} returns pdfmake definition object
18
+ /**
19
+ * buildActivityPdf
20
+ *
21
+ * @param {object} pdfOptions - the pdf options
22
+ * @param {string} pdfOptions.fileTitle - pdf file title
23
+ * @param {function} pdfOptions.footer - function executed to generate footer
24
+ * @param {function} pdfOptions.header - function executed to generate header
25
+ * @param {string} pdfOptions.logoUrl - pdf logo url
26
+ * @param {array} pdfOptions.pageMargins - pdf page margins
27
+ * @param {string} pdfOptions.pageOrientation - pdf page orientation
28
+ * @param {string} pdfOptions.pageSize - pdf page size
29
+ * @param {object} pdfOptions.styles - pdf styles
30
+ * @param {object} pdfOptions.title - pdf title
31
+ * @param {object} data - pdf data
32
+ * @param {array} data.audits - audit documents
33
+ * @param {string} data.end - end datetime of summary report
34
+ * @param {array} data.events - event documents
35
+ * @param {object} data.location - location document
36
+ * @param {array} data.locations - location documents
37
+ * @param {array} data.issues - issue documents
38
+ * @param {bool} data.maxScans - max scans to include in standard report
39
+ * @param {bool} data.showAlternate - show alternate summary report
40
+ * @param {string} data.start - start datetime of summary report
41
+ * @param {object} data.settings - settings properties
42
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
43
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
44
+ * @param {array} data.tasks - task documents
45
+ * @param {string} data.timestamp - timestamp string
46
+ * @param {string} data.timezone - timezone string
47
+ * @param {array} data.zones - zone documents
48
+ * @param {array} data.users - user documents
49
+ * @returns {Promise} returns pdfmake definition object
50
50
  */
51
51
  async function buildActivityPdf(pdfOptions, data) {
52
52
  const {
@@ -10,29 +10,29 @@ var _lodash = require("lodash");
10
10
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
11
11
  var _helpers = require("../helpers");
12
12
  var _helpers2 = require("../../helpers");
13
- /**
14
- * buildAuditPdf
15
- *
16
- * @param {object} pdfOptions - the pdf options
17
- * @param {string} pdfOptions.fileTitle - pdf file title
18
- * @param {function} pdfOptions.footer - function executed to generate footer
19
- * @param {function} pdfOptions.header - function executed to generate header
20
- * @param {string} pdfOptions.logoUrl - pdf logo url
21
- * @param {array} pdfOptions.pageMargins - pdf page margins
22
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
23
- * @param {string} pdfOptions.pageSize - pdf page size
24
- * @param {object} pdfOptions.styles - pdf styles
25
- * @param {object} pdfOptions.title - pdf title
26
- * @param {object} pdfOptions.flags - flags to conditionally render parts of the pdf
27
- * @param {object} data - pdf data
28
- * @param {object} data.entity - audit document
29
- * @param {object} data.locations - locations documents
30
- * @param {object} data.settings - settings properties
31
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
32
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
33
- * @param {string} data.timezone - timezone string
34
- * @param {object} data.users - application user documents
35
- * @returns {Promise} returns pdfmake definition object
13
+ /**
14
+ * buildAuditPdf
15
+ *
16
+ * @param {object} pdfOptions - the pdf options
17
+ * @param {string} pdfOptions.fileTitle - pdf file title
18
+ * @param {function} pdfOptions.footer - function executed to generate footer
19
+ * @param {function} pdfOptions.header - function executed to generate header
20
+ * @param {string} pdfOptions.logoUrl - pdf logo url
21
+ * @param {array} pdfOptions.pageMargins - pdf page margins
22
+ * @param {string} pdfOptions.pageOrientation - pdf page orientation
23
+ * @param {string} pdfOptions.pageSize - pdf page size
24
+ * @param {object} pdfOptions.styles - pdf styles
25
+ * @param {object} pdfOptions.title - pdf title
26
+ * @param {object} pdfOptions.flags - flags to conditionally render parts of the pdf
27
+ * @param {object} data - pdf data
28
+ * @param {object} data.entity - audit document
29
+ * @param {object} data.locations - locations documents
30
+ * @param {object} data.settings - settings properties
31
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
32
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
33
+ * @param {string} data.timezone - timezone string
34
+ * @param {object} data.users - application user documents
35
+ * @returns {Promise} returns pdfmake definition object
36
36
  */
37
37
  function buildAuditPdf(pdfOptions, data) {
38
38
  const {
@@ -61,32 +61,49 @@ function buildImage(options) {
61
61
  link
62
62
  };
63
63
  }
64
- const url = (0, _helpers.buildFetchUrl)(filepath, {
65
- awsS3BaseUrl,
66
- cloudfrontBaseUrl,
67
- cloudinaryBaseUrl,
68
- fit: true,
69
- height: 400,
70
- width: 600,
71
- quality: 50,
72
- shouldUseCloudfront
73
- });
64
+ const normalizedPath = typeof filepath === 'object' && filepath !== null ? filepath.path || filepath.url || String(filepath) : filepath;
65
+ try {
66
+ const url = (0, _helpers.buildFetchUrl)(normalizedPath, {
67
+ awsS3BaseUrl,
68
+ cloudfrontBaseUrl,
69
+ cloudinaryBaseUrl,
70
+ fit: true,
71
+ height: 400,
72
+ width: 600,
73
+ quality: 50,
74
+ shouldUseCloudfront
75
+ });
74
76
 
75
- // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context
76
- return (0, _helpers.fetchImage)(url, {
77
- ...settings,
78
- context: {
79
- stage: 'field',
77
+ // NOTE: shouldUseCloudfront, Signature, Policy and KeyPairId from settings are used in this context
78
+ return (0, _helpers.fetchImage)(url, {
79
+ ...settings,
80
+ context: {
81
+ stage: 'field',
82
+ fieldLabel,
83
+ fieldType,
84
+ filepath: normalizedPath
85
+ }
86
+ }).then(base64String => ({
87
+ alignment,
88
+ fit: [width, height],
89
+ image: base64String,
90
+ link
91
+ }));
92
+ } catch (error) {
93
+ console.error({
94
+ message: 'Failed to build image URL',
95
+ filepath,
80
96
  fieldLabel,
81
97
  fieldType,
82
- filepath
83
- }
84
- }).then(base64String => ({
85
- alignment,
86
- fit: [width, height],
87
- image: base64String,
88
- link
89
- }));
98
+ error: error.message
99
+ });
100
+ return {
101
+ alignment,
102
+ fit: [width, height],
103
+ image: _images.imageNotFound,
104
+ link: ''
105
+ };
106
+ }
90
107
  }
91
108
  function buildSummaryField({
92
109
  field,
@@ -147,15 +164,16 @@ function buildSummaryField({
147
164
  });
148
165
  }
149
166
  if (isPhotoField) {
150
- const filepath = (0, _lodash.first)(value);
167
+ const rawFilepath = (0, _lodash.first)(value);
151
168
 
152
169
  // NOTE: if no filepath return empty text as user has not uploaded an image
153
170
  // for this field
154
- if (!filepath) {
171
+ if (!rawFilepath) {
155
172
  return {
156
173
  text: ''
157
174
  };
158
175
  }
176
+ const filepath = typeof rawFilepath === 'object' && rawFilepath !== null ? rawFilepath.path || rawFilepath.url || rawFilepath : rawFilepath;
159
177
  const image = buildImage({
160
178
  alignment: 'left',
161
179
  filepath,
@@ -287,7 +305,8 @@ function buildTemplateFieldRow({
287
305
 
288
306
  // Ensure value is always treated as an array of filepaths
289
307
  const filepaths = (0, _lodash.isArray)(value) ? value : [value];
290
- return _bluebird.default.map(filepaths, (filepath, index) => {
308
+ return _bluebird.default.map(filepaths, (rawFilepath, index) => {
309
+ const filepath = typeof rawFilepath === 'object' && rawFilepath !== null ? rawFilepath.path || rawFilepath.url || rawFilepath : rawFilepath;
291
310
  const signedAssetValue = (0, _lodash.isArray)(signedAssets) ? signedAssets[index] : signedAssets;
292
311
  return buildImage({
293
312
  filepath,
@@ -305,7 +324,8 @@ function buildTemplateFieldRow({
305
324
  text: ''
306
325
  }];
307
326
  }
308
- return _bluebird.default.map(value, (filepath, index) => {
327
+ return _bluebird.default.map(value, (rawFilepath, index) => {
328
+ const filepath = typeof rawFilepath === 'object' && rawFilepath !== null ? rawFilepath.path || rawFilepath.url || rawFilepath : rawFilepath;
309
329
  const signedAssetValue = (0, _lodash.isArray)(signedAssets) ? signedAssets[index] : signedAssets;
310
330
  return buildImage({
311
331
  filepath,
@@ -9,29 +9,29 @@ var _lodash = require("lodash");
9
9
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
10
10
  var _helpers = require("../helpers");
11
11
  var _helpers2 = require("../../helpers");
12
- /**
13
- * buildIssuePdf
14
- *
15
- * @param {object} pdfOptions - the pdf options
16
- * @param {string} pdfOptions.fileTitle - pdf file title
17
- * @param {function} pdfOptions.footer - function executed to generate footer
18
- * @param {function} pdfOptions.header - function executed to generate header
19
- * @param {string} pdfOptions.logoUrl - pdf logo url
20
- * @param {array} pdfOptions.pageMargins - pdf page margins
21
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
22
- * @param {string} pdfOptions.pageSize - pdf page size
23
- * @param {object} pdfOptions.styles - pdf styles
24
- * @param {object} pdfOptions.title - pdf title
25
- * @param {object} data - pdf data
26
- * @param {object} data.entity - issue document
27
- * @param {object} data.locations - locations documents
28
- * @param {object} data.settings - settings properties
29
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
30
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
31
- * @param {string} data.timezone - timezone string
32
- * @param {object} data.users - application user documents
33
- * @param {object} data.zones - zone documents
34
- * @returns {Promise} returns pdfmake definition object
12
+ /**
13
+ * buildIssuePdf
14
+ *
15
+ * @param {object} pdfOptions - the pdf options
16
+ * @param {string} pdfOptions.fileTitle - pdf file title
17
+ * @param {function} pdfOptions.footer - function executed to generate footer
18
+ * @param {function} pdfOptions.header - function executed to generate header
19
+ * @param {string} pdfOptions.logoUrl - pdf logo url
20
+ * @param {array} pdfOptions.pageMargins - pdf page margins
21
+ * @param {string} pdfOptions.pageOrientation - pdf page orientation
22
+ * @param {string} pdfOptions.pageSize - pdf page size
23
+ * @param {object} pdfOptions.styles - pdf styles
24
+ * @param {object} pdfOptions.title - pdf title
25
+ * @param {object} data - pdf data
26
+ * @param {object} data.entity - issue document
27
+ * @param {object} data.locations - locations documents
28
+ * @param {object} data.settings - settings properties
29
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
30
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
31
+ * @param {string} data.timezone - timezone string
32
+ * @param {object} data.users - application user documents
33
+ * @param {object} data.zones - zone documents
34
+ * @returns {Promise} returns pdfmake definition object
35
35
  */
36
36
 
37
37
  const publicSubmissionTextColor = '#FF8C2F';
@@ -32,28 +32,28 @@ const ACTIVITY_COLUMN_HEADERS = [{
32
32
  bold: true
33
33
  }];
34
34
 
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.cloudfrontBaseUrl - cloudfront base url
54
- * @param {string} data.timezone - timezone string
55
- * @param {object} data.users - application user documents
56
- * @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
57
57
  */
58
58
  function buildJobPdf(pdfOptions, data) {
59
59
  const {
@@ -15,34 +15,34 @@ var _helpers2 = require("../helpers");
15
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
16
  const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
17
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.cloudfrontBaseUrl - cloudfront 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
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
46
46
  */
47
47
 
48
48
  async function buildShiftPdf(pdfOptions, data) {
@@ -9,29 +9,29 @@ var _lodash = require("lodash");
9
9
  var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
10
10
  var _helpers = require("../helpers");
11
11
  var _helpers2 = require("../../helpers");
12
- /**
13
- * buildTaskPdf
14
- *
15
- * @param {object} pdfOptions - the pdf options
16
- * @param {string} pdfOptions.fileTitle - pdf file title
17
- * @param {function} pdfOptions.footer - function executed to generate footer
18
- * @param {function} pdfOptions.header - function executed to generate header
19
- * @param {string} pdfOptions.logoUrl - pdf logo url
20
- * @param {array} pdfOptions.pageMargins - pdf page margins
21
- * @param {string} pdfOptions.pageOrientation - pdf page orientation
22
- * @param {string} pdfOptions.pageSize - pdf page size
23
- * @param {object} pdfOptions.styles - pdf styles
24
- * @param {object} pdfOptions.title - pdf title
25
- * @param {object} data - pdf data
26
- * @param {object} data.entity - task document
27
- * @param {object} data.locations - locations documents
28
- * @param {object} data.settings - settings properties
29
- * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
30
- * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url
31
- * @param {string} data.timezone - timezone string
32
- * @param {object} data.users - application user documents
33
- * @param {object} data.zones - zone documents
34
- * @returns {Promise} returns pdfmake definition object
12
+ /**
13
+ * buildTaskPdf
14
+ *
15
+ * @param {object} pdfOptions - the pdf options
16
+ * @param {string} pdfOptions.fileTitle - pdf file title
17
+ * @param {function} pdfOptions.footer - function executed to generate footer
18
+ * @param {function} pdfOptions.header - function executed to generate header
19
+ * @param {string} pdfOptions.logoUrl - pdf logo url
20
+ * @param {array} pdfOptions.pageMargins - pdf page margins
21
+ * @param {string} pdfOptions.pageOrientation - pdf page orientation
22
+ * @param {string} pdfOptions.pageSize - pdf page size
23
+ * @param {object} pdfOptions.styles - pdf styles
24
+ * @param {object} pdfOptions.title - pdf title
25
+ * @param {object} data - pdf data
26
+ * @param {object} data.entity - task document
27
+ * @param {object} data.locations - locations documents
28
+ * @param {object} data.settings - settings properties
29
+ * @param {string} data.settings.awsS3BaseUrl - aws S3 base url
30
+ * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
31
+ * @param {string} data.timezone - timezone string
32
+ * @param {object} data.users - application user documents
33
+ * @param {object} data.zones - zone documents
34
+ * @returns {Promise} returns pdfmake definition object
35
35
  */
36
36
  function buildTaskPdf(pdfOptions, data) {
37
37
  const {
@@ -17,8 +17,8 @@ const strategyTypeMap = exports.strategyTypeMap = {
17
17
  [_scheduling.StrategyTypes.Window]: _strategies.getNext,
18
18
  [_scheduling.StrategyTypes.XDayOfXWeekOfMonth]: _strategies.getNextXDayOfXWeekOfMonth
19
19
  };
20
- /**
21
- * Generates occurrence intervals for service intervals using strategy
20
+ /**
21
+ * Generates occurrence intervals for service intervals using strategy
22
22
  */
23
23
  function* occurrenceIntervalsGenerator(props) {
24
24
  const {