@adobe/spacecat-shared-data-access 1.61.11 → 1.61.13

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.61.13](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.61.12...@adobe/spacecat-shared-data-access-v1.61.13) (2025-01-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * audit result to validate array ([#522](https://github.com/adobe/spacecat-shared/issues/522)) ([a6978d5](https://github.com/adobe/spacecat-shared/commit/a6978d54c52e668ea2336e68c9dcb000ba1a45a3))
7
+
8
+ # [@adobe/spacecat-shared-data-access-v1.61.12](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.61.11...@adobe/spacecat-shared-data-access-v1.61.12) (2024-12-31)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * calling all wrong args ([#520](https://github.com/adobe/spacecat-shared/issues/520)) ([b727e50](https://github.com/adobe/spacecat-shared/commit/b727e50e8375c8b6a33bac101d0a2ecaf8fc8b7e))
14
+
1
15
  # [@adobe/spacecat-shared-data-access-v1.61.11](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.61.10...@adobe/spacecat-shared-data-access-v1.61.11) (2024-12-31)
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.61.11",
3
+ "version": "1.61.13",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { isObject } from '@adobe/spacecat-shared-utils';
13
+ import { isArray, isObject } from '@adobe/spacecat-shared-utils';
14
14
 
15
15
  import { ValidationError } from '../../errors/index.js';
16
16
  import BaseModel from '../base/base.model.js';
@@ -53,7 +53,7 @@ class Audit extends BaseModel {
53
53
  * @returns {boolean} - True if valid, false otherwise.
54
54
  */
55
55
  static validateAuditResult = (auditResult, auditType) => {
56
- if (!isObject(auditResult) && !Array.isArray(auditResult)) {
56
+ if (!isObject(auditResult) && !isArray(auditResult)) {
57
57
  throw new ValidationError('Audit result must be an object or array');
58
58
  }
59
59
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  /* c8 ignore start */
14
14
 
15
- import { isIsoDate, isNonEmptyObject } from '@adobe/spacecat-shared-utils';
15
+ import { isArray, isIsoDate, isNonEmptyObject } from '@adobe/spacecat-shared-utils';
16
16
 
17
17
  import SchemaBuilder from '../base/schema.builder.js';
18
18
  import Audit from './audit.model.js';
@@ -33,7 +33,7 @@ const schema = new SchemaBuilder(Audit, AuditCollection)
33
33
  .addAttribute('auditResult', {
34
34
  type: 'any',
35
35
  required: true,
36
- validate: (value) => isNonEmptyObject(value),
36
+ validate: (value) => isNonEmptyObject(value) || isArray(value),
37
37
  set: (value, attributes) => {
38
38
  // as the electroDb validate function does not provide access to the model instance
39
39
  // we need to call the validate function from the model on setting the value
@@ -17,7 +17,7 @@ import type {
17
17
  export interface Audit extends BaseModel {
18
18
  getAuditedAt(): string;
19
19
  getAuditId(): string;
20
- getAuditResult(): object;
20
+ getAuditResult(): object | [];
21
21
  getAuditType(): string;
22
22
  getFullAuditRef(): string;
23
23
  getIsError(): boolean;
@@ -26,7 +26,7 @@ import Site from './site.model.js';
26
26
  */
27
27
  class SiteCollection extends BaseCollection {
28
28
  async allSitesToAudit() {
29
- return (await this.all({ attributes: ['siteId'] })).map((site) => site.getId());
29
+ return (await this.all({}, { attributes: ['siteId'] })).map((site) => site.getId());
30
30
  }
31
31
 
32
32
  async allWithLatestAudit(auditType, order = 'asc', deliveryType = null) {
@@ -43,7 +43,7 @@ class SiteCollection extends BaseCollection {
43
43
 
44
44
  const [sites, latestAudits] = await Promise.all([
45
45
  sitesQuery,
46
- latestAuditCollection.all([auditType], { order }),
46
+ latestAuditCollection.all({ auditType }, { order }),
47
47
  ]);
48
48
 
49
49
  const sitesMap = new Map(sites.map((site) => [site.getId(), site]));