@adobe/spacecat-shared-data-access 1.20.2 → 1.20.4

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,17 @@
1
+ # [@adobe/spacecat-shared-data-access-v1.20.4](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.20.3...@adobe/spacecat-shared-data-access-v1.20.4) (2024-03-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * audit result can be an array ([#189](https://github.com/adobe/spacecat-shared/issues/189)) ([6982907](https://github.com/adobe/spacecat-shared/commit/698290744cf15758f0d27c900484ac4949d42224))
7
+
8
+ # [@adobe/spacecat-shared-data-access-v1.20.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.20.2...@adobe/spacecat-shared-data-access-v1.20.3) (2024-03-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#183](https://github.com/adobe/spacecat-shared/issues/183)) ([0c292e5](https://github.com/adobe/spacecat-shared/commit/0c292e5cff5647e1947f4095ff8f28b3a0155ed6))
14
+
1
15
  # [@adobe/spacecat-shared-data-access-v1.20.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.20.1...@adobe/spacecat-shared-data-access-v1.20.2) (2024-03-11)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "1.20.2",
3
+ "version": "1.20.4",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "@adobe/spacecat-shared-dynamo": "1.2.5",
33
33
  "@adobe/spacecat-shared-utils": "1.2.0",
34
- "@aws-sdk/client-dynamodb": "3.529.1",
35
- "@aws-sdk/lib-dynamodb": "3.529.1",
34
+ "@aws-sdk/client-dynamodb": "3.535.0",
35
+ "@aws-sdk/lib-dynamodb": "3.535.0",
36
36
  "@types/joi": "17.2.3",
37
37
  "joi": "17.12.2",
38
38
  "uuid": "9.0.1"
@@ -46,9 +46,7 @@ const validateScores = (auditResult, auditType) => {
46
46
  return true;
47
47
  }
48
48
 
49
- if ((auditType === AUDIT_TYPE_LHS_DESKTOP
50
- || auditType === AUDIT_TYPE_LHS_MOBILE
51
- || auditType === AUDIT_TYPE_CWV)
49
+ if ((auditType === AUDIT_TYPE_LHS_DESKTOP || auditType === AUDIT_TYPE_LHS_MOBILE)
52
50
  && !isObject(auditResult.scores)) {
53
51
  throw new Error(`Missing scores property for audit type '${auditType}'`);
54
52
  }
@@ -93,6 +91,10 @@ const Audit = (data = {}) => {
93
91
  return Object.freeze(self);
94
92
  };
95
93
 
94
+ function isValidAuditResult(auditResult) {
95
+ return isObject(auditResult) || Array.isArray(auditResult);
96
+ }
97
+
96
98
  /**
97
99
  * Creates a new Audit.
98
100
  *
@@ -114,8 +116,8 @@ export const createAudit = (data) => {
114
116
  throw new Error('Audit type must be provided');
115
117
  }
116
118
 
117
- if (!isObject(newState.auditResult)) {
118
- throw new Error('Audit result must be an object');
119
+ if (!isValidAuditResult(newState.auditResult)) {
120
+ throw new Error('Audit result must be an object or an array');
119
121
  }
120
122
 
121
123
  if (!newState.auditResult.scores) {
@@ -123,8 +125,8 @@ export const createAudit = (data) => {
123
125
  }
124
126
  validateScores(data.auditResult, data.auditType);
125
127
 
126
- if (data.previousAuditResult && !isObject(data.previousAuditResult)) {
127
- throw new Error('Previous audit result must be an object');
128
+ if (data.previousAuditResult && !isValidAuditResult(data.previousAuditResult)) {
129
+ throw new Error('Previous audit result must be an object or an array');
128
130
  }
129
131
 
130
132
  if (data.previousAuditResult) {