@lighthouse/common 6.0.0-canary-2 → 6.0.0-canary-3
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.
- package/dist/helpers/build-fetch-url/index.js +16 -32
- package/dist/helpers/get-audit-items-data/index.js +19 -25
- package/dist/helpers/index.js +0 -6
- package/lib/helpers/build-fetch-url/index.js +26 -30
- package/lib/helpers/build-fetch-url/index.js.map +1 -1
- package/lib/helpers/get-audit-items-data/index.js +20 -26
- package/lib/helpers/get-audit-items-data/index.js.map +1 -1
- package/lib/helpers/index.js +1 -1
- package/lib/helpers/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.buildCloudfrontFetchUrl = buildCloudfrontFetchUrl;
|
|
7
6
|
exports.buildFetchUrl = buildFetchUrl;
|
|
8
7
|
function buildFetchUrl(url, options) {
|
|
9
8
|
const {
|
|
@@ -14,17 +13,24 @@ function buildFetchUrl(url, options) {
|
|
|
14
13
|
height,
|
|
15
14
|
width,
|
|
16
15
|
quality,
|
|
17
|
-
shouldUseCloudfront
|
|
16
|
+
shouldUseCloudfront,
|
|
17
|
+
Policy,
|
|
18
|
+
KeyPairId,
|
|
19
|
+
Signature
|
|
18
20
|
} = options;
|
|
19
21
|
if (shouldUseCloudfront) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const paramMap = {
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
quality,
|
|
26
|
+
fit: 'contain',
|
|
27
|
+
Policy,
|
|
28
|
+
'Key-Pair-Id': KeyPairId,
|
|
29
|
+
Signature
|
|
30
|
+
};
|
|
31
|
+
const params = Object.entries(paramMap).filter(([, value]) => value != null).map(([key, value]) => `${key}=${value.toString()}`);
|
|
32
|
+
const paramsString = params.join('&');
|
|
33
|
+
return `${cloudfrontBaseUrl}/${url}?${paramsString}`;
|
|
28
34
|
}
|
|
29
35
|
const transformations = [];
|
|
30
36
|
let transformationsString = '';
|
|
@@ -35,26 +41,4 @@ function buildFetchUrl(url, options) {
|
|
|
35
41
|
transformationsString = `${transformations.join(',')}/`;
|
|
36
42
|
const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`;
|
|
37
43
|
return fetchUrl;
|
|
38
|
-
}
|
|
39
|
-
function buildCloudfrontFetchUrl(path, options) {
|
|
40
|
-
const {
|
|
41
|
-
cloudfrontBaseUrl = '',
|
|
42
|
-
height,
|
|
43
|
-
width,
|
|
44
|
-
quality,
|
|
45
|
-
imagesPolicy,
|
|
46
|
-
imagesKeyPairId,
|
|
47
|
-
imagesSignature
|
|
48
|
-
} = options;
|
|
49
|
-
const params = [];
|
|
50
|
-
if (width) params.push(`width=${width.toString()}`);
|
|
51
|
-
if (height) params.push(`height=${height.toString()}`);
|
|
52
|
-
if (quality) params.push(`quality=${quality.toString()}`);
|
|
53
|
-
if (imagesPolicy) params.push(`Policy=${imagesPolicy}`);
|
|
54
|
-
if (imagesKeyPairId) params.push(`Key-Pair-Id=${imagesKeyPairId}`);
|
|
55
|
-
if (imagesSignature) params.push(`Signature=${imagesSignature}`);
|
|
56
|
-
params.push(`fit=contain`);
|
|
57
|
-
const paramsString = params.join('&');
|
|
58
|
-
const fetchUrl = new URL(`${cloudfrontBaseUrl}/${path}?${paramsString}`).toString();
|
|
59
|
-
return fetchUrl;
|
|
60
44
|
}
|
|
@@ -12,15 +12,15 @@ function getAuditItemsData(items, data) {
|
|
|
12
12
|
awsS3BaseUrl,
|
|
13
13
|
cloudinaryBaseUrl,
|
|
14
14
|
cloudfrontBaseUrl,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Policy,
|
|
16
|
+
KeyPairId,
|
|
17
|
+
Signature
|
|
18
18
|
} = {},
|
|
19
19
|
entity: {
|
|
20
20
|
groupScores
|
|
21
21
|
} = {}
|
|
22
22
|
} = data;
|
|
23
|
-
const shouldUseCloudfront = !!cloudfrontBaseUrl && !!
|
|
23
|
+
const shouldUseCloudfront = !!cloudfrontBaseUrl && !!Policy && !!KeyPairId && !!Signature;
|
|
24
24
|
const groupedItems = (0, _lodash.groupBy)(items, 'group.id');
|
|
25
25
|
const auditData = {
|
|
26
26
|
overallActualScore: 0,
|
|
@@ -54,37 +54,31 @@ function getAuditItemsData(items, data) {
|
|
|
54
54
|
const rawAssets = item.assets || [];
|
|
55
55
|
const assetCount = rawAssets.length;
|
|
56
56
|
const assets = rawAssets.map((asset, assetIndex) => {
|
|
57
|
-
const assetUrl =
|
|
58
|
-
cloudfrontBaseUrl,
|
|
59
|
-
height: 400,
|
|
60
|
-
width: 600,
|
|
61
|
-
quality: 50,
|
|
62
|
-
imagesPolicy,
|
|
63
|
-
imagesKeyPairId,
|
|
64
|
-
imagesSignature
|
|
65
|
-
}) : (0, _.buildFetchUrl)(asset, {
|
|
57
|
+
const assetUrl = (0, _.buildFetchUrl)(asset, {
|
|
66
58
|
awsS3BaseUrl,
|
|
67
59
|
cloudfrontBaseUrl,
|
|
68
60
|
cloudinaryBaseUrl,
|
|
69
|
-
fit: true,
|
|
70
61
|
height: 400,
|
|
71
62
|
width: 600,
|
|
72
|
-
quality: 50
|
|
63
|
+
quality: 50,
|
|
64
|
+
fit: !shouldUseCloudfront,
|
|
65
|
+
shouldUseCloudfront,
|
|
66
|
+
Policy,
|
|
67
|
+
KeyPairId,
|
|
68
|
+
Signature
|
|
73
69
|
});
|
|
74
70
|
const link = shouldUseCloudfront ? `${cloudfrontBaseUrl}/${item.signedAssets[assetIndex]}` : `${awsS3BaseUrl}/${asset}`;
|
|
75
|
-
const thumbnailUrl =
|
|
76
|
-
cloudfrontBaseUrl,
|
|
77
|
-
height: 400,
|
|
78
|
-
width: 600,
|
|
79
|
-
quality: 50,
|
|
80
|
-
imagesPolicy,
|
|
81
|
-
imagesKeyPairId,
|
|
82
|
-
imagesSignature
|
|
83
|
-
}) : (0, _.buildFetchUrl)(asset, {
|
|
71
|
+
const thumbnailUrl = (0, _.buildFetchUrl)(asset, {
|
|
84
72
|
awsS3BaseUrl,
|
|
73
|
+
cloudfrontBaseUrl,
|
|
85
74
|
cloudinaryBaseUrl,
|
|
86
75
|
width: 100,
|
|
87
|
-
quality: 50
|
|
76
|
+
quality: 50,
|
|
77
|
+
fit: !shouldUseCloudfront,
|
|
78
|
+
shouldUseCloudfront,
|
|
79
|
+
Policy,
|
|
80
|
+
KeyPairId,
|
|
81
|
+
Signature
|
|
88
82
|
});
|
|
89
83
|
const key = `${groupIndex}-item-asset-${assetIndex}`;
|
|
90
84
|
return {
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "buildCloudfrontFetchUrl", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _buildFetchUrl.buildCloudfrontFetchUrl;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "buildFetchUrl", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function () {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
export function buildFetchUrl(url, options) {
|
|
2
3
|
var awsS3BaseUrl = options.awsS3BaseUrl,
|
|
3
4
|
_options$cloudfrontBa = options.cloudfrontBaseUrl,
|
|
@@ -7,16 +8,32 @@ export function buildFetchUrl(url, options) {
|
|
|
7
8
|
height = options.height,
|
|
8
9
|
width = options.width,
|
|
9
10
|
quality = options.quality,
|
|
10
|
-
shouldUseCloudfront = options.shouldUseCloudfront
|
|
11
|
+
shouldUseCloudfront = options.shouldUseCloudfront,
|
|
12
|
+
Policy = options.Policy,
|
|
13
|
+
KeyPairId = options.KeyPairId,
|
|
14
|
+
Signature = options.Signature;
|
|
11
15
|
if (shouldUseCloudfront) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
var paramMap = {
|
|
17
|
+
width: width,
|
|
18
|
+
height: height,
|
|
19
|
+
quality: quality,
|
|
20
|
+
fit: 'contain',
|
|
21
|
+
Policy: Policy,
|
|
22
|
+
'Key-Pair-Id': KeyPairId,
|
|
23
|
+
Signature: Signature
|
|
24
|
+
};
|
|
25
|
+
var params = Object.entries(paramMap).filter(function (_ref) {
|
|
26
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
27
|
+
value = _ref2[1];
|
|
28
|
+
return value != null;
|
|
29
|
+
}).map(function (_ref3) {
|
|
30
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
31
|
+
key = _ref4[0],
|
|
32
|
+
value = _ref4[1];
|
|
33
|
+
return "".concat(key, "=").concat(value.toString());
|
|
34
|
+
});
|
|
35
|
+
var paramsString = params.join('&');
|
|
36
|
+
return "".concat(cloudfrontBaseUrl, "/").concat(url, "?").concat(paramsString);
|
|
20
37
|
}
|
|
21
38
|
var transformations = [];
|
|
22
39
|
var transformationsString = '';
|
|
@@ -28,25 +45,4 @@ export function buildFetchUrl(url, options) {
|
|
|
28
45
|
var fetchUrl = "".concat(cloudinaryBaseUrl, "/").concat(transformationsString).concat(awsS3BaseUrl, "/").concat(url);
|
|
29
46
|
return fetchUrl;
|
|
30
47
|
}
|
|
31
|
-
export function buildCloudfrontFetchUrl(path, options) {
|
|
32
|
-
var _options$cloudfrontBa2 = options.cloudfrontBaseUrl,
|
|
33
|
-
cloudfrontBaseUrl = _options$cloudfrontBa2 === void 0 ? '' : _options$cloudfrontBa2,
|
|
34
|
-
height = options.height,
|
|
35
|
-
width = options.width,
|
|
36
|
-
quality = options.quality,
|
|
37
|
-
imagesPolicy = options.imagesPolicy,
|
|
38
|
-
imagesKeyPairId = options.imagesKeyPairId,
|
|
39
|
-
imagesSignature = options.imagesSignature;
|
|
40
|
-
var params = [];
|
|
41
|
-
if (width) params.push("width=".concat(width.toString()));
|
|
42
|
-
if (height) params.push("height=".concat(height.toString()));
|
|
43
|
-
if (quality) params.push("quality=".concat(quality.toString()));
|
|
44
|
-
if (imagesPolicy) params.push("Policy=".concat(imagesPolicy));
|
|
45
|
-
if (imagesKeyPairId) params.push("Key-Pair-Id=".concat(imagesKeyPairId));
|
|
46
|
-
if (imagesSignature) params.push("Signature=".concat(imagesSignature));
|
|
47
|
-
params.push("fit=contain");
|
|
48
|
-
var paramsString = params.join('&');
|
|
49
|
-
var fetchUrl = new URL("".concat(cloudfrontBaseUrl, "/").concat(path, "?").concat(paramsString)).toString();
|
|
50
|
-
return fetchUrl;
|
|
51
|
-
}
|
|
52
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildFetchUrl","url","options","awsS3BaseUrl","_options$cloudfrontBa","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","shouldUseCloudfront","
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildFetchUrl","url","options","awsS3BaseUrl","_options$cloudfrontBa","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","shouldUseCloudfront","Policy","KeyPairId","Signature","paramMap","params","Object","entries","filter","_ref","_ref2","_slicedToArray","value","map","_ref3","_ref4","key","concat","toString","paramsString","join","transformations","transformationsString","push","fetchUrl"],"sources":["../../../src/helpers/build-fetch-url/index.js"],"sourcesContent":["export function buildFetchUrl(url, options) {\n const {\n awsS3BaseUrl,\n cloudfrontBaseUrl = '',\n cloudinaryBaseUrl,\n fit,\n height,\n width,\n quality,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n } = options\n\n if (shouldUseCloudfront) {\n const paramMap = {\n width,\n height,\n quality,\n fit: 'contain',\n Policy,\n 'Key-Pair-Id': KeyPairId,\n Signature,\n }\n\n const params = Object.entries(paramMap)\n .filter(([, value]) => value != null)\n .map(([key, value]) => `${key}=${value.toString()}`)\n\n const paramsString = params.join('&')\n return `${cloudfrontBaseUrl}/${url}?${paramsString}`\n }\n\n const transformations = []\n let transformationsString = ''\n\n if (width) transformations.push(`w_${width.toString()}`)\n if (height) transformations.push(`h_${height.toString()}`)\n if (quality) transformations.push(`q_${quality.toString()}`)\n if (fit) transformations.push('c_fit')\n\n transformationsString = `${transformations.join(',')}/`\n\n const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`\n\n return fetchUrl\n}\n"],"mappings":";AAAA,OAAO,SAASA,aAAaA,CAACC,GAAG,EAAEC,OAAO,EAAE;EAC1C,IACEC,YAAY,GAWVD,OAAO,CAXTC,YAAY;IAAAC,qBAAA,GAWVF,OAAO,CAVTG,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,EAAE,GAAAA,qBAAA;IACtBE,iBAAiB,GASfJ,OAAO,CATTI,iBAAiB;IACjBC,GAAG,GAQDL,OAAO,CARTK,GAAG;IACHC,MAAM,GAOJN,OAAO,CAPTM,MAAM;IACNC,KAAK,GAMHP,OAAO,CANTO,KAAK;IACLC,OAAO,GAKLR,OAAO,CALTQ,OAAO;IACPC,mBAAmB,GAIjBT,OAAO,CAJTS,mBAAmB;IACnBC,MAAM,GAGJV,OAAO,CAHTU,MAAM;IACNC,SAAS,GAEPX,OAAO,CAFTW,SAAS;IACTC,SAAS,GACPZ,OAAO,CADTY,SAAS;EAGX,IAAIH,mBAAmB,EAAE;IACvB,IAAMI,QAAQ,GAAG;MACfN,KAAK,EAALA,KAAK;MACLD,MAAM,EAANA,MAAM;MACNE,OAAO,EAAPA,OAAO;MACPH,GAAG,EAAE,SAAS;MACdK,MAAM,EAANA,MAAM;MACN,aAAa,EAAEC,SAAS;MACxBC,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AsB,MAAA,CAAIK,qBAAqB,EAAAL,MAAA,CAAGzB,YAAY,OAAAyB,MAAA,CAAI3B,GAAG,CAAE;EAEtF,OAAOkC,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { find, groupBy, map, get, round } from 'lodash';
|
|
2
|
-
import { buildFetchUrl
|
|
2
|
+
import { buildFetchUrl } from '../';
|
|
3
3
|
export function getAuditItemsData(items, data) {
|
|
4
4
|
var _data$settings = data.settings,
|
|
5
5
|
_data$settings2 = _data$settings === void 0 ? {} : _data$settings,
|
|
6
6
|
awsS3BaseUrl = _data$settings2.awsS3BaseUrl,
|
|
7
7
|
cloudinaryBaseUrl = _data$settings2.cloudinaryBaseUrl,
|
|
8
8
|
cloudfrontBaseUrl = _data$settings2.cloudfrontBaseUrl,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
Policy = _data$settings2.Policy,
|
|
10
|
+
KeyPairId = _data$settings2.KeyPairId,
|
|
11
|
+
Signature = _data$settings2.Signature,
|
|
12
12
|
_data$entity = data.entity,
|
|
13
13
|
_data$entity2 = _data$entity === void 0 ? {} : _data$entity,
|
|
14
14
|
groupScores = _data$entity2.groupScores;
|
|
15
|
-
var shouldUseCloudfront = !!cloudfrontBaseUrl && !!
|
|
15
|
+
var shouldUseCloudfront = !!cloudfrontBaseUrl && !!Policy && !!KeyPairId && !!Signature;
|
|
16
16
|
var groupedItems = groupBy(items, 'group.id');
|
|
17
17
|
var auditData = {
|
|
18
18
|
overallActualScore: 0,
|
|
@@ -46,37 +46,31 @@ export function getAuditItemsData(items, data) {
|
|
|
46
46
|
var rawAssets = item.assets || [];
|
|
47
47
|
var assetCount = rawAssets.length;
|
|
48
48
|
var assets = rawAssets.map(function (asset, assetIndex) {
|
|
49
|
-
var assetUrl =
|
|
50
|
-
cloudfrontBaseUrl: cloudfrontBaseUrl,
|
|
51
|
-
height: 400,
|
|
52
|
-
width: 600,
|
|
53
|
-
quality: 50,
|
|
54
|
-
imagesPolicy: imagesPolicy,
|
|
55
|
-
imagesKeyPairId: imagesKeyPairId,
|
|
56
|
-
imagesSignature: imagesSignature
|
|
57
|
-
}) : buildFetchUrl(asset, {
|
|
49
|
+
var assetUrl = buildFetchUrl(asset, {
|
|
58
50
|
awsS3BaseUrl: awsS3BaseUrl,
|
|
59
51
|
cloudfrontBaseUrl: cloudfrontBaseUrl,
|
|
60
52
|
cloudinaryBaseUrl: cloudinaryBaseUrl,
|
|
61
|
-
fit: true,
|
|
62
53
|
height: 400,
|
|
63
54
|
width: 600,
|
|
64
|
-
quality: 50
|
|
55
|
+
quality: 50,
|
|
56
|
+
fit: !shouldUseCloudfront,
|
|
57
|
+
shouldUseCloudfront: shouldUseCloudfront,
|
|
58
|
+
Policy: Policy,
|
|
59
|
+
KeyPairId: KeyPairId,
|
|
60
|
+
Signature: Signature
|
|
65
61
|
});
|
|
66
62
|
var link = shouldUseCloudfront ? "".concat(cloudfrontBaseUrl, "/").concat(item.signedAssets[assetIndex]) : "".concat(awsS3BaseUrl, "/").concat(asset);
|
|
67
|
-
var thumbnailUrl =
|
|
68
|
-
cloudfrontBaseUrl: cloudfrontBaseUrl,
|
|
69
|
-
height: 400,
|
|
70
|
-
width: 600,
|
|
71
|
-
quality: 50,
|
|
72
|
-
imagesPolicy: imagesPolicy,
|
|
73
|
-
imagesKeyPairId: imagesKeyPairId,
|
|
74
|
-
imagesSignature: imagesSignature
|
|
75
|
-
}) : buildFetchUrl(asset, {
|
|
63
|
+
var thumbnailUrl = buildFetchUrl(asset, {
|
|
76
64
|
awsS3BaseUrl: awsS3BaseUrl,
|
|
65
|
+
cloudfrontBaseUrl: cloudfrontBaseUrl,
|
|
77
66
|
cloudinaryBaseUrl: cloudinaryBaseUrl,
|
|
78
67
|
width: 100,
|
|
79
|
-
quality: 50
|
|
68
|
+
quality: 50,
|
|
69
|
+
fit: !shouldUseCloudfront,
|
|
70
|
+
shouldUseCloudfront: shouldUseCloudfront,
|
|
71
|
+
Policy: Policy,
|
|
72
|
+
KeyPairId: KeyPairId,
|
|
73
|
+
Signature: Signature
|
|
80
74
|
});
|
|
81
75
|
var key = "".concat(groupIndex, "-item-asset-").concat(assetIndex);
|
|
82
76
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["find","groupBy","map","get","round","buildFetchUrl","
|
|
1
|
+
{"version":3,"file":"index.js","names":["find","groupBy","map","get","round","buildFetchUrl","getAuditItemsData","items","data","_data$settings","settings","_data$settings2","awsS3BaseUrl","cloudinaryBaseUrl","cloudfrontBaseUrl","Policy","KeyPairId","Signature","_data$entity","entity","_data$entity2","groupScores","shouldUseCloudfront","groupedItems","auditData","overallActualScore","overallMaximumScore","groupIndex","key","skipped","group","title","label","groupData","groupMaximumScore","groupActualScore","groupResultScore","groupPercentageResultScore","currentGroupScores","max","actual","result","percentageResult","item","itemIndex","hasScore","score","rawAssets","assets","assetCount","length","asset","assetIndex","assetUrl","height","width","quality","fit","link","concat","signedAssets","thumbnailUrl","comments","matchingScore","scores","value","scoreLabel","scoreWeight","weight","questionId","_id"],"sources":["../../../src/helpers/get-audit-items-data/index.js"],"sourcesContent":["import { find, groupBy, map, get, round } from 'lodash'\n\nimport { buildFetchUrl } from '../'\n\nexport function getAuditItemsData(items, data) {\n const {\n settings: {\n awsS3BaseUrl,\n cloudinaryBaseUrl,\n cloudfrontBaseUrl,\n Policy,\n KeyPairId,\n Signature,\n } = {},\n entity: { groupScores } = {},\n } = data\n\n const shouldUseCloudfront =\n !!cloudfrontBaseUrl && !!Policy && !!KeyPairId && !!Signature\n const groupedItems = groupBy(items, 'group.id')\n\n const auditData = {\n overallActualScore: 0,\n overallMaximumScore: 0,\n }\n\n auditData.items = map(groupedItems, (items, groupIndex) => {\n const key = groupIndex\n const skipped = !!items[0].group.skipped\n const title = items[0].group.label\n\n const groupData = {\n key,\n groupMaximumScore: 0,\n groupActualScore: 0,\n groupResultScore: 0,\n groupPercentageResultScore: 0,\n skipped,\n title,\n }\n\n const currentGroupScores = get(groupScores, key)\n\n if (currentGroupScores) {\n groupData.groupMaximumScore = round(currentGroupScores.max, 2)\n groupData.groupActualScore = round(currentGroupScores.actual, 2)\n groupData.groupResultScore = currentGroupScores.result\n groupData.groupPercentageResultScore = currentGroupScores.percentageResult\n }\n\n groupData.items = items.map((item, itemIndex) => {\n // NOTE: we handle scores of -1, 0 and 1\n // -1 scores are skipped from group max and actual score\n // 0 and 1 must be included in the final scores\n const hasScore = item.score !== null && item.score !== -1\n const rawAssets = item.assets || []\n const assetCount = rawAssets.length\n\n const assets = rawAssets.map((asset, assetIndex) => {\n const assetUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n height: 400,\n width: 600,\n quality: 50,\n fit: !shouldUseCloudfront,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n })\n\n const link = shouldUseCloudfront\n ? `${cloudfrontBaseUrl}/${item.signedAssets[assetIndex]}`\n : `${awsS3BaseUrl}/${asset}`\n\n const thumbnailUrl = buildFetchUrl(asset, {\n awsS3BaseUrl,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n width: 100,\n quality: 50,\n fit: !shouldUseCloudfront,\n shouldUseCloudfront,\n Policy,\n KeyPairId,\n Signature,\n })\n\n const key = `${groupIndex}-item-asset-${assetIndex}`\n\n return {\n assetUrl,\n key,\n link,\n thumbnailUrl,\n }\n })\n\n const comments = item.comments\n const label = item.label\n const score = item.score\n const key = `${groupIndex}-item-${itemIndex}`\n const matchingScore = find(item.scores, { value: score })\n\n // NOTE: ensure we have a score otherwise fallback to - value\n const scoreLabel =\n hasScore && matchingScore && !skipped ? matchingScore.label : '-'\n const scoreWeight = hasScore && !skipped ? item.scoreWeight : '-'\n const weight = hasScore ? item.weight : '-'\n\n return {\n assetCount,\n assets,\n comments,\n key,\n label,\n questionId: item._id,\n score,\n scoreLabel,\n scoreWeight,\n weight,\n }\n })\n\n return gro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,KAAK,EAAEnB;MAAM,CAAC,CAAC;;MAEzD;MACA,IAAMoB,UAAU,GACdrB,QAAQ,IAAIkB,aAAa,IAAI,CAAClC,OAAO,GAAGkC,aAAa,CAAC/B,KAAK,GAAG,GAAG;MACnE,IAAMmC,WAAW,GAAGtB,QAAQ,IAAI,CAAChB,OAAO,GAAGc,IAAI,CAACwB,WAAW,GAAG,GAAG;MACjE,IAAMC,MAAM,GAAGvB,QAAQ,GAAGF,IAAI,CAACyB,MAAM,GAAG,GAAG;MAE3C,OAAO;QACLnB,UAAU,EAAVA,UAAU;QACVD,MAAM,EAANA,MAAM;QACNc,QAAQ,EAARA,QAAQ;QACRlC,GAAG,EAAHA,GAAG;QACHI,KAAK,EAALA,KAAK;QACLqC,UAAU,EAAE1B,IAAI,CAAC2B,GAAG;QACpBxB,KAAK,EAALA,KAAK;QACLoB,UAAU,EAAVA,UAAU;QACVC,WAAW,EAAXA,WAAW;QACXC,MAAM,EAANA;MACF,CAAC;IACH,CAAC,CAAC;IAEF,OAAOnC,SAAS;EAClB,CAAC,CAAC;EAEF,OAAOT,SAAS;AAClB","ignoreList":[]}
|
package/lib/helpers/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// NOTE these are global helpers which may used on multiple projects
|
|
2
2
|
export { getAuditEntryDetails } from './get-audit-entry-details';
|
|
3
3
|
export { getAuditItemsData } from './get-audit-items-data';
|
|
4
|
-
export { buildFetchUrl
|
|
4
|
+
export { buildFetchUrl } from './build-fetch-url';
|
|
5
5
|
export { fetchImage, validateBase64Image } from './fetch-image';
|
|
6
6
|
export { getAssigneesFullNames } from './get-assignees-full-names';
|
|
7
7
|
export { getGeometryGeocodedString } from './get-geometry-geocoded-string';
|
package/lib/helpers/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getAuditEntryDetails","getAuditItemsData","buildFetchUrl","
|
|
1
|
+
{"version":3,"file":"index.js","names":["getAuditEntryDetails","getAuditItemsData","buildFetchUrl","fetchImage","validateBase64Image","getAssigneesFullNames","getGeometryGeocodedString","getIssueDetails","getJobDetails","getLocationReference","getPrettyDuration","getReferenceDetails","getStatusDetails","getTaskEntryDetails","getTimezoneAbbr","getTimezoneDatetime","getUserFullName","getValueAsPercentage"],"sources":["../../src/helpers/index.js"],"sourcesContent":["// NOTE these are global helpers which may used on multiple projects\nexport { getAuditEntryDetails } from './get-audit-entry-details'\nexport { getAuditItemsData } from './get-audit-items-data'\nexport { buildFetchUrl } from './build-fetch-url'\nexport { fetchImage, validateBase64Image } from './fetch-image'\nexport { getAssigneesFullNames } from './get-assignees-full-names'\nexport { getGeometryGeocodedString } from './get-geometry-geocoded-string'\nexport { getIssueDetails } from './get-issue-details'\nexport { getJobDetails } from './get-job-details'\nexport { getLocationReference } from './get-location-reference'\nexport { getPrettyDuration } from './get-pretty-duration'\nexport { getReferenceDetails } from './get-reference-details'\nexport { getStatusDetails } from './get-status-details'\nexport { getTaskEntryDetails } from './get-task-entry-details'\nexport { getTimezoneAbbr } from './get-timezone-abbr'\nexport { getTimezoneDatetime } from './get-timezone-datetime'\nexport { getUserFullName } from './get-user-full-name'\nexport { getValueAsPercentage } from './get-value-as-percentage'\n"],"mappings":"AAAA;AACA,SAASA,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,UAAU,EAAEC,mBAAmB,QAAQ,eAAe;AAC/D,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,yBAAyB,QAAQ,gCAAgC;AAC1E,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,oBAAoB,QAAQ,2BAA2B","ignoreList":[]}
|