@adobe/spacecat-shared-data-access 1.1.6 → 1.2.1
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.2.1](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.2.0...@adobe/spacecat-shared-data-access-v1.2.1) (2023-12-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* export getLatestAuditsForSite ([#39](https://github.com/adobe-rnd/spacecat-shared/issues/39)) ([e9c9130](https://github.com/adobe-rnd/spacecat-shared/commit/e9c9130b940122714be76e3df6e96e44bbde5348))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v1.2.0](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.1.6...@adobe/spacecat-shared-data-access-v1.2.0) (2023-12-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* introduce getSiteByID ([#36](https://github.com/adobe-rnd/spacecat-shared/issues/36)) ([5677f76](https://github.com/adobe-rnd/spacecat-shared/commit/5677f76d11d97f2a2afd878e0ada7cad22fd1f03))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v1.1.6](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.1.5...@adobe/spacecat-shared-data-access-v1.1.6) (2023-12-05)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
|
-
addAudit,
|
|
14
|
+
addAudit,
|
|
15
|
+
getAuditForSite,
|
|
15
16
|
getAuditsForSite,
|
|
16
17
|
getLatestAuditForSite,
|
|
17
18
|
getLatestAudits,
|
|
19
|
+
getLatestAuditsForSite,
|
|
18
20
|
removeAuditsForSite,
|
|
19
21
|
} from './accessPatterns.js';
|
|
20
22
|
|
|
@@ -48,6 +50,12 @@ export const auditFunctions = (dynamoClient, config, log) => ({
|
|
|
48
50
|
siteId,
|
|
49
51
|
auditType,
|
|
50
52
|
),
|
|
53
|
+
getLatestAuditsForSite: (siteId) => getLatestAuditsForSite(
|
|
54
|
+
dynamoClient,
|
|
55
|
+
config,
|
|
56
|
+
log,
|
|
57
|
+
siteId,
|
|
58
|
+
),
|
|
51
59
|
addAudit: (auditData) => addAudit(
|
|
52
60
|
dynamoClient,
|
|
53
61
|
config,
|
|
@@ -42,16 +42,16 @@ export const getSites = async (dynamoClient, config) => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Retrieves a list of
|
|
45
|
+
* Retrieves a list of site IDs of all sites.
|
|
46
46
|
*
|
|
47
47
|
* @param {DynamoDbClient} dynamoClient - The DynamoDB client.
|
|
48
48
|
* @param {DataAccessConfig} config - The data access config.
|
|
49
|
-
* @returns {Promise<Array<string>>} A promise that resolves to an array of
|
|
49
|
+
* @returns {Promise<Array<string>>} A promise that resolves to an array of site IDs of all sites.
|
|
50
50
|
*/
|
|
51
51
|
export const getSitesToAudit = async (dynamoClient, config) => {
|
|
52
52
|
const sites = await getSites(dynamoClient, config);
|
|
53
53
|
|
|
54
|
-
return sites.map((site) => site.
|
|
54
|
+
return sites.map((site) => site.getId());
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -117,11 +117,7 @@ export const getSiteByBaseURL = async (
|
|
|
117
117
|
Limit: 1,
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return SiteDto.fromDynamoItem(dynamoItems[0]);
|
|
120
|
+
return dynamoItems.length > 0 ? SiteDto.fromDynamoItem(dynamoItems[0]) : null;
|
|
125
121
|
};
|
|
126
122
|
|
|
127
123
|
/**
|
|
@@ -209,6 +205,27 @@ export const getSiteByBaseURLWithLatestAudit = async (
|
|
|
209
205
|
auditType,
|
|
210
206
|
) => getSiteByBaseURLWithAuditInfo(dynamoClient, config, log, baseUrl, auditType, true);
|
|
211
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Retrieves a site by its ID.
|
|
210
|
+
*
|
|
211
|
+
* @param {DynamoDbClient} dynamoClient - The DynamoDB client.
|
|
212
|
+
* @param {DataAccessConfig} config - The data access config.
|
|
213
|
+
* @param {Logger} log - The logger.
|
|
214
|
+
* @param {string} siteId - The ID of the site to retrieve.
|
|
215
|
+
* @returns {Promise<Readonly<Site>|null>} A promise that resolves to the site object if found,
|
|
216
|
+
* otherwise null.
|
|
217
|
+
*/
|
|
218
|
+
export const getSiteByID = async (
|
|
219
|
+
dynamoClient,
|
|
220
|
+
config,
|
|
221
|
+
log,
|
|
222
|
+
siteId,
|
|
223
|
+
) => {
|
|
224
|
+
const dynamoItem = await dynamoClient.getItem(config.tableNameSites, { id: siteId });
|
|
225
|
+
|
|
226
|
+
return isObject(dynamoItem) ? SiteDto.fromDynamoItem(dynamoItem) : null;
|
|
227
|
+
};
|
|
228
|
+
|
|
212
229
|
/**
|
|
213
230
|
* Adds a site.
|
|
214
231
|
*
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
getSiteByBaseURLWithAuditInfo,
|
|
17
17
|
getSiteByBaseURLWithAudits,
|
|
18
18
|
getSiteByBaseURLWithLatestAudit,
|
|
19
|
+
getSiteByID,
|
|
19
20
|
getSites,
|
|
20
21
|
getSitesToAudit,
|
|
21
22
|
getSitesWithLatestAudit, removeSite,
|
|
@@ -44,6 +45,12 @@ export const siteFunctions = (dynamoClient, config, log) => ({
|
|
|
44
45
|
log,
|
|
45
46
|
baseUrl,
|
|
46
47
|
),
|
|
48
|
+
getSiteByID: (siteId) => getSiteByID(
|
|
49
|
+
dynamoClient,
|
|
50
|
+
config,
|
|
51
|
+
log,
|
|
52
|
+
siteId,
|
|
53
|
+
),
|
|
47
54
|
getSiteByBaseURLWithAuditInfo: (baseUrl, auditType, latestOnly) => getSiteByBaseURLWithAuditInfo(
|
|
48
55
|
dynamoClient,
|
|
49
56
|
config,
|