@adobe/spacecat-shared-data-access 1.6.2 → 1.6.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-data-access-v1.6.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.6.2...@adobe/spacecat-shared-data-access-v1.6.3) (2024-01-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * get latest audits with delivery type ([#80](https://github.com/adobe/spacecat-shared/issues/80)) ([d823773](https://github.com/adobe/spacecat-shared/commit/d823773d738ebddf2790356750827ae74e66b052))
7
+
1
8
  # [@adobe/spacecat-shared-data-access-v1.6.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.6.1...@adobe/spacecat-shared-data-access-v1.6.2) (2024-01-12)
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.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.d.ts CHANGED
@@ -249,6 +249,7 @@ export interface DataAccess {
249
249
  getSitesWithLatestAudit: (
250
250
  auditType: string,
251
251
  sortAuditsAscending?: boolean,
252
+ deliveryType?: string,
252
253
  ) => Promise<Site[]>;
253
254
  getSiteByBaseURL: (
254
255
  baseUrl: string,
@@ -50,6 +50,10 @@ export const getSites = async (dynamoClient, config) => {
50
50
  * specified delivery type.
51
51
  */
52
52
  export const getSitesByDeliveryType = async (dynamoClient, config, deliveryType) => {
53
+ if (deliveryType === 'all') {
54
+ return getSites(dynamoClient, config);
55
+ }
56
+
53
57
  const dynamoItems = await dynamoClient.query({
54
58
  TableName: config.tableNameSites,
55
59
  IndexName: config.indexNameAllSitesByDeliveryType,
@@ -87,6 +91,9 @@ export const getSitesToAudit = async (dynamoClient, config) => {
87
91
  * @param {Logger} log - The logger.
88
92
  * @param {string} auditType - The type of audits to retrieve for the sites.
89
93
  * @param {boolean} [sortAuditsAscending=true] - Determines if the audits should be sorted in
94
+ * ascending order.
95
+ * @param {string} [deliveryType=DEFAULT_DELIVERY_TYPE] - The delivery type of the sites
96
+ * to retrieve.
90
97
  * @return {Promise<Readonly<Site>[]>} A promise that resolves to an array of sites with their
91
98
  * latest audit.
92
99
  */
@@ -96,9 +103,10 @@ export const getSitesWithLatestAudit = async (
96
103
  log,
97
104
  auditType,
98
105
  sortAuditsAscending = true,
106
+ deliveryType = 'all',
99
107
  ) => {
100
108
  const [sites, latestAudits] = await Promise.all([
101
- getSites(dynamoClient, config),
109
+ getSitesByDeliveryType(dynamoClient, config, deliveryType),
102
110
  getLatestAudits(dynamoClient, config, log, auditType, sortAuditsAscending),
103
111
  ]);
104
112
 
@@ -37,12 +37,17 @@ export const siteFunctions = (dynamoClient, config, log) => ({
37
37
  dynamoClient,
38
38
  config,
39
39
  ),
40
- getSitesWithLatestAudit: (auditType, sortAuditsAscending) => getSitesWithLatestAudit(
40
+ getSitesWithLatestAudit: (
41
+ auditType,
42
+ sortAuditsAscending,
43
+ deliveryType,
44
+ ) => getSitesWithLatestAudit(
41
45
  dynamoClient,
42
46
  config,
43
47
  log,
44
48
  auditType,
45
49
  sortAuditsAscending,
50
+ deliveryType,
46
51
  ),
47
52
  getSiteByBaseURL: (baseUrl) => getSiteByBaseURL(
48
53
  dynamoClient,