@adobe/spacecat-shared-data-access 1.3.1 → 1.3.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-data-access-v1.3.2](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.3.1...@adobe/spacecat-shared-data-access-v1.3.2) (2023-12-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * GSI sort key when error ([#62](https://github.com/adobe-rnd/spacecat-shared/issues/62)) ([dbb6a91](https://github.com/adobe-rnd/spacecat-shared/commit/dbb6a91f75fa9492a621de7b258cbebe38fe3ac7))
7
+
1
8
  # [@adobe/spacecat-shared-data-access-v1.3.1](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.3.0...@adobe/spacecat-shared-data-access-v1.3.1) (2023-12-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/dto/audit.js CHANGED
@@ -32,10 +32,16 @@ export const AuditDto = {
32
32
  * @returns {{siteId, auditedAt, auditResult, auditType, expiresAt, fullAuditRef, SK: string}}
33
33
  */
34
34
  toDynamoItem: (audit, latestAudit = false) => {
35
- const latestAuditProps = latestAudit ? {
36
- GSI1PK: 'ALL_LATEST_AUDITS',
37
- GSI1SK: `${audit.getAuditType()}#${Object.values(audit.getScores()).join('#')}`,
38
- } : {};
35
+ const GSI1PK = 'ALL_LATEST_AUDITS';
36
+ let GSI1SK;
37
+
38
+ if (audit.isError()) {
39
+ GSI1SK = `${audit.getAuditType()}#error`;
40
+ } else {
41
+ GSI1SK = `${audit.getAuditType()}#${Object.values(audit.getScores()).join('#')}`;
42
+ }
43
+
44
+ const latestAuditProps = latestAudit ? { GSI1PK, GSI1SK } : {};
39
45
 
40
46
  return {
41
47
  siteId: audit.getSiteId(),
@@ -32,6 +32,10 @@ const AUDIT_TYPE_PROPERTIES = {
32
32
  * @returns {boolean} - True if valid, false otherwise.
33
33
  */
34
34
  const validateScores = (auditResult, auditType) => {
35
+ if (isObject(auditResult.runtimeError)) {
36
+ return true;
37
+ }
38
+
35
39
  const expectedProperties = AUDIT_TYPE_PROPERTIES[auditType];
36
40
  if (!expectedProperties) {
37
41
  throw new Error(`Unknown audit type: ${auditType}`);