@adobe/spacecat-shared-data-access 1.26.1 → 1.28.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,17 @@
1
+ # [@adobe/spacecat-shared-data-access-v1.28.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.27.0...@adobe/spacecat-shared-data-access-v1.28.0) (2024-06-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * opt-out broken-backlinks ([#263](https://github.com/adobe/spacecat-shared/issues/263)) ([14402cb](https://github.com/adobe/spacecat-shared/commit/14402cbda51bf54b2928ca1d66afac00ca2444ed))
7
+
8
+ # [@adobe/spacecat-shared-data-access-v1.27.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.26.1...@adobe/spacecat-shared-data-access-v1.27.0) (2024-06-12)
9
+
10
+
11
+ ### Features
12
+
13
+ * query for URLs for a given jobID matching status ([#262](https://github.com/adobe/spacecat-shared/issues/262)) ([a74b629](https://github.com/adobe/spacecat-shared/commit/a74b629b78b100c140515efd072807f628de4a2a))
14
+
1
15
  # [@adobe/spacecat-shared-data-access-v1.26.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.26.0...@adobe/spacecat-shared-data-access-v1.26.1) (2024-06-10)
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.26.1",
3
+ "version": "1.28.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -35,13 +35,13 @@
35
35
  "@aws-sdk/lib-dynamodb": "3.592.0",
36
36
  "@types/joi": "17.2.3",
37
37
  "joi": "17.13.1",
38
- "uuid": "9.0.1"
38
+ "uuid": "10.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "chai": "4.4.1",
42
- "chai-as-promised": "7.1.2",
42
+ "chai-as-promised": "8.0.0",
43
43
  "dynamo-db-local": "8.0.0",
44
- "sinon": "17.0.2",
44
+ "sinon": "18.0.0",
45
45
  "sinon-chai": "3.7.0"
46
46
  }
47
47
  }
package/src/index.d.ts CHANGED
@@ -622,6 +622,10 @@ export interface DataAccess {
622
622
  updateImportUrl: (
623
623
  importUrl: ImportUrl,
624
624
  ) => Promise<ImportUrl>;
625
+ getImportUrlsByJobIdAndStatus: (
626
+ jobId: string,
627
+ status: string,
628
+ ) => Promise<ImportUrl[]>;
625
629
 
626
630
  // site candidate functions
627
631
  getSiteCandidateByBaseURL: (baseURL: string) => Promise<SiteCandidate>;
@@ -666,6 +670,7 @@ interface DataAccessConfig {
666
670
  indexNameAllOrganizations: string,
667
671
  indexNameAllOrganizationsByImsOrgId: string,
668
672
  indexNameAllImportJobsByStatus: string,
673
+ indexNameAllImportUrlsByJobIdAndStatus: string,
669
674
  pkAllSites: string;
670
675
  pkAllLatestAudits: string;
671
676
  pkAllOrganizations: string;
package/src/index.js CHANGED
@@ -33,6 +33,7 @@ const INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = 'spacecat-services-all-sites-by-de
33
33
  const INDEX_NAME_ALL_LATEST_AUDIT_SCORES = 'spacecat-services-all-latest-audit-scores-dev';
34
34
  const INDEX_NAME_ALL_SITES_ORGANIZATIONS = 'spacecat-services-all-sites-organizations-dev';
35
35
  const INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS = 'spacecat-services-all-import-jobs-by-status-dev';
36
+ const INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS = 'spacecat-services-all-import-urls-by-job-id-and-status-dev';
36
37
 
37
38
  const PK_ALL_SITES = 'ALL_SITES';
38
39
  const PK_ALL_CONFIGURATIONS = 'ALL_CONFIGURATIONS';
@@ -65,6 +66,8 @@ export default function dataAccessWrapper(fn) {
65
66
  DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID = INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID,
66
67
  DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS = INDEX_NAME_ALL_SITES_ORGANIZATIONS,
67
68
  DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS = INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS,
69
+ DYNAMO_INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS =
70
+ INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS,
68
71
  } = context.env;
69
72
 
70
73
  context.dataAccess = createDataAccess({
@@ -86,6 +89,7 @@ export default function dataAccessWrapper(fn) {
86
89
  indexNameAllLatestAuditScores: DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
87
90
  indexNameAllSitesOrganizations: DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS,
88
91
  indexNameAllImportJobsByStatus: DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS,
92
+ indexNameImportUrlsByJobIdAndStatus: DYNAMO_INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS,
89
93
  pkAllSites: PK_ALL_SITES,
90
94
  pkAllOrganizations: PK_ALL_ORGANIZATIONS,
91
95
  pkAllLatestAudits: PK_ALL_LATEST_AUDITS,
@@ -13,10 +13,12 @@
13
13
  const AuditConfigType = (data = {}) => {
14
14
  const state = {
15
15
  disabled: data.disabled || false,
16
+ excludedURLs: data.excludedURLs || [],
16
17
  };
17
18
 
18
19
  const self = {
19
20
  disabled: () => state.disabled,
21
+ excludedURLs: () => state.excludedURLs,
20
22
 
21
23
  updateDisabled: (newValue) => {
22
24
  state.disabled = newValue;
@@ -29,12 +31,14 @@ const AuditConfigType = (data = {}) => {
29
31
  AuditConfigType.fromDynamoItem = (dynamoItem) => {
30
32
  const auditConfigTypeData = {
31
33
  disabled: dynamoItem.disabled,
34
+ excludedURLs: dynamoItem.excludedURLs,
32
35
  };
33
36
  return AuditConfigType(auditConfigTypeData);
34
37
  };
35
38
 
36
39
  AuditConfigType.toDynamoItem = (auditConfigType) => ({
37
40
  disabled: auditConfigType.disabled(),
41
+ excludedURLs: auditConfigType.excludedURLs(),
38
42
  });
39
43
 
40
44
  export default AuditConfigType;
@@ -30,6 +30,7 @@ export const configSchema = Joi.object({
30
30
  Joi.string(),
31
31
  Joi.object({
32
32
  disabled: Joi.boolean().optional(),
33
+ excludedURLs: Joi.array().items(Joi.string()).optional(),
33
34
  }).unknown(true),
34
35
  ).unknown(true),
35
36
  }).unknown(true),
@@ -71,3 +71,28 @@ export const updateImportUrl = async (dynamoClient, config, log, importUrl) => {
71
71
 
72
72
  return importUrl;
73
73
  };
74
+
75
+ /**
76
+ * Get Import Urls by Job ID and Status
77
+ * @param {DynamoClient} dynamoClient
78
+ * @param {Object} config
79
+ * @param {Logger} log
80
+ * @param {string} jobId
81
+ * @param {string} status
82
+ * @returns {Promise<ImportUrlDto[]>}
83
+ */
84
+ export const getImportUrlsByJobIdAndStatus = async (dynamoClient, config, log, jobId, status) => {
85
+ const items = await dynamoClient.query({
86
+ TableName: config.tableNameImportUrls,
87
+ IndexName: config.indexNameImportUrlsByJobIdAndStatus,
88
+ KeyConditionExpression: 'jobId = :jobId AND #status = :status',
89
+ ExpressionAttributeNames: {
90
+ '#status': 'status',
91
+ },
92
+ ExpressionAttributeValues: {
93
+ ':jobId': jobId,
94
+ ':status': status,
95
+ },
96
+ });
97
+ return items.map((item) => ImportUrlDto.fromDynamoItem(item));
98
+ };
@@ -14,6 +14,7 @@ import {
14
14
  getImportUrlById,
15
15
  createNewImportUrl,
16
16
  updateImportUrl,
17
+ getImportUrlsByJobIdAndStatus,
17
18
  } from './accessPatterns.js';
18
19
 
19
20
  export const importUrlFunctions = (dynamoClient, config, log) => ({
@@ -35,4 +36,11 @@ export const importUrlFunctions = (dynamoClient, config, log) => ({
35
36
  log,
36
37
  importUrl,
37
38
  ),
39
+ getImportUrlsByJobIdAndStatus: (jobId, status) => getImportUrlsByJobIdAndStatus(
40
+ dynamoClient,
41
+ config,
42
+ log,
43
+ jobId,
44
+ status,
45
+ ),
38
46
  });