@adobe/spacecat-shared-data-access 1.58.2 → 1.59.0

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.59.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.58.2...@adobe/spacecat-shared-data-access-v1.59.0) (2024-12-11)
2
+
3
+
4
+ ### Features
5
+
6
+ * **data-access:** get site candidates ([#486](https://github.com/adobe/spacecat-shared/issues/486)) ([f45032d](https://github.com/adobe/spacecat-shared/commit/f45032dbcd3ea1e8cdfc2066f523b4a1690b5da4))
7
+
1
8
  # [@adobe/spacecat-shared-data-access-v1.58.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.58.1...@adobe/spacecat-shared-data-access-v1.58.2) (2024-12-07)
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.58.2",
3
+ "version": "1.59.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@adobe/spacecat-shared-dynamo": "1.3.50",
37
+ "@adobe/spacecat-shared-dynamo": "1.4.0",
38
38
  "@adobe/spacecat-shared-utils": "1.23.1",
39
39
  "@aws-sdk/client-dynamodb": "3.705.0",
40
40
  "@aws-sdk/lib-dynamodb": "3.705.0",
package/src/index.d.ts CHANGED
@@ -872,6 +872,7 @@ export interface DataAccess {
872
872
  ) => Promise<ApiKey | null>;
873
873
 
874
874
  // site candidate functions
875
+ getSiteCandidates: () => Promise<SiteCandidate[]>;
875
876
  getSiteCandidateByBaseURL: (baseURL: string) => Promise<SiteCandidate>;
876
877
  upsertSiteCandidate: (siteCandidateDate: object) => Promise<SiteCandidate>;
877
878
  siteCandidateExists: (baseURL: string) => Promise<boolean>;
@@ -14,6 +14,21 @@ import { isObject } from '@adobe/spacecat-shared-utils';
14
14
  import { createSiteCandidate } from '../../models/site-candidate.js';
15
15
  import { SiteCandidateDto } from '../../dto/site-candidate.js';
16
16
 
17
+ /**
18
+ * Retrieves all site candidates.
19
+ *
20
+ * @param {DynamoDbClient} dynamoClient - The DynamoDB client.
21
+ * @param {DataAccessConfig} config - The data access config.
22
+ * @returns {Promise<Readonly<Site>[]>} A promise that resolves to an array of all site candidates.
23
+ */
24
+ export const getSiteCandidates = async (dynamoClient, config) => {
25
+ const dynamoItems = await dynamoClient.scan({
26
+ TableName: config.tableNameSites,
27
+ });
28
+
29
+ return dynamoItems.map((dynamoItem) => SiteCandidateDto.fromDynamoItem(dynamoItem));
30
+ };
31
+
17
32
  /**
18
33
  * Checks if a site candidate exists in site candidates table using base url
19
34
  * @param {DynamoDbClient} dynamoClient - The DynamoDB client.
@@ -11,6 +11,7 @@
11
11
  */
12
12
 
13
13
  import {
14
+ getSiteCandidates,
14
15
  getSiteCandidateByBaseURL,
15
16
  upsertSiteCandidate,
16
17
  exists,
@@ -18,6 +19,10 @@ import {
18
19
  } from './accessPatterns.js';
19
20
 
20
21
  export const siteCandidateFunctions = (dynamoClient, config, log) => ({
22
+ getSiteCandidates: () => getSiteCandidates(
23
+ dynamoClient,
24
+ config,
25
+ ),
21
26
  getSiteCandidateByBaseURL: (baseURL) => getSiteCandidateByBaseURL(
22
27
  dynamoClient,
23
28
  config,