@adobe/spacecat-shared-data-access 1.35.1 → 1.36.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 +14 -0
- package/package.json +3 -3
- package/src/index.d.ts +5 -0
- package/src/index.js +3 -0
- package/src/service/import-job/accessPatterns.js +25 -0
- package/src/service/import-job/index.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v1.36.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.35.2...@adobe/spacecat-shared-data-access-v1.36.0) (2024-07-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Get all import jobs by date range ([#292](https://github.com/adobe/spacecat-shared/issues/292)) ([21accd3](https://github.com/adobe/spacecat-shared/commit/21accd34a543af3ab39aacaa0545f84c7bb50f3b))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v1.35.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.35.1...@adobe/spacecat-shared-data-access-v1.35.2) (2024-07-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update external fixes ([#291](https://github.com/adobe/spacecat-shared/issues/291)) ([5678328](https://github.com/adobe/spacecat-shared/commit/5678328a8efe4c2068b3b796274d8e4392f75c8a))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v1.35.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.35.0...@adobe/spacecat-shared-data-access-v1.35.1) (2024-07-12)
|
|
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.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Data Access",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@adobe/spacecat-shared-dynamo": "1.2.5",
|
|
33
33
|
"@adobe/spacecat-shared-utils": "1.2.0",
|
|
34
|
-
"@aws-sdk/client-dynamodb": "3.
|
|
35
|
-
"@aws-sdk/lib-dynamodb": "3.
|
|
34
|
+
"@aws-sdk/client-dynamodb": "3.614.0",
|
|
35
|
+
"@aws-sdk/lib-dynamodb": "3.614.0",
|
|
36
36
|
"@types/joi": "17.2.3",
|
|
37
37
|
"joi": "17.13.3",
|
|
38
38
|
"uuid": "10.0.0"
|
package/src/index.d.ts
CHANGED
|
@@ -612,6 +612,10 @@ export interface DataAccess {
|
|
|
612
612
|
removeOrganization: (
|
|
613
613
|
organizationId: string,
|
|
614
614
|
) => Promise<void>;
|
|
615
|
+
getImportJobsByDateRange: (
|
|
616
|
+
startDate: string,
|
|
617
|
+
endDate: string,
|
|
618
|
+
) => Promise<ImportJob[]>;
|
|
615
619
|
getImportJobByID: (
|
|
616
620
|
id: string,
|
|
617
621
|
) => Promise<ImportJob | null>;
|
|
@@ -681,6 +685,7 @@ interface DataAccessConfig {
|
|
|
681
685
|
indexNameAllOrganizations: string,
|
|
682
686
|
indexNameAllOrganizationsByImsOrgId: string,
|
|
683
687
|
indexNameAllImportJobsByStatus: string,
|
|
688
|
+
indexNameAllImportJobsByDateRange: string,
|
|
684
689
|
indexNameAllImportUrlsByJobIdAndStatus: string,
|
|
685
690
|
pkAllSites: string;
|
|
686
691
|
pkAllLatestAudits: 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_JOBS_BY_DATE_RANGE = 'spacecat-services-all-import-jobs-by-date-range-dev';
|
|
36
37
|
const INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS = 'spacecat-services-all-import-urls-by-job-id-and-status-dev';
|
|
37
38
|
|
|
38
39
|
const PK_ALL_SITES = 'ALL_SITES';
|
|
@@ -66,6 +67,7 @@ export default function dataAccessWrapper(fn) {
|
|
|
66
67
|
DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID = INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID,
|
|
67
68
|
DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS = INDEX_NAME_ALL_SITES_ORGANIZATIONS,
|
|
68
69
|
DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS = INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS,
|
|
70
|
+
DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE = INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE,
|
|
69
71
|
DYNAMO_INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS =
|
|
70
72
|
INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS,
|
|
71
73
|
} = context.env;
|
|
@@ -89,6 +91,7 @@ export default function dataAccessWrapper(fn) {
|
|
|
89
91
|
indexNameAllLatestAuditScores: DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
|
|
90
92
|
indexNameAllSitesOrganizations: DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS,
|
|
91
93
|
indexNameAllImportJobsByStatus: DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS,
|
|
94
|
+
indexNameAllImportJobsByDateRange: DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE,
|
|
92
95
|
indexNameImportUrlsByJobIdAndStatus: DYNAMO_INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS,
|
|
93
96
|
pkAllSites: PK_ALL_SITES,
|
|
94
97
|
pkAllOrganizations: PK_ALL_ORGANIZATIONS,
|
|
@@ -14,6 +14,31 @@ import { isObject } from '@adobe/spacecat-shared-utils';
|
|
|
14
14
|
import { ImportJobDto } from '../../dto/import-job.js';
|
|
15
15
|
import { createImportJob } from '../../models/importer/import-job.js';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Get all Import Jobs within a specific date range
|
|
19
|
+
* @param {DynamoClient} dynamoClient
|
|
20
|
+
* @param {Object} config
|
|
21
|
+
* @param {Logger} log
|
|
22
|
+
* @param {string} startDate
|
|
23
|
+
* @param {string} endDate
|
|
24
|
+
*/
|
|
25
|
+
export const getImportJobsByDateRange = async (dynamoClient, config, log, startDate, endDate) => {
|
|
26
|
+
const items = await dynamoClient.query({
|
|
27
|
+
TableName: config.tableNameImportJobs,
|
|
28
|
+
IndexName: config.indexNameAllImportJobsByDateRange,
|
|
29
|
+
KeyConditionExpression: 'GSI1PK = :gsi1pk AND #startTime BETWEEN :startDate AND :endDate',
|
|
30
|
+
ExpressionAttributeNames: {
|
|
31
|
+
'#startTime': 'startTime',
|
|
32
|
+
},
|
|
33
|
+
ExpressionAttributeValues: {
|
|
34
|
+
':gsi1pk': config.pkAllImportJobs,
|
|
35
|
+
':startDate': startDate,
|
|
36
|
+
':endDate': endDate,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return items.map((item) => ImportJobDto.fromDynamoItem(item));
|
|
40
|
+
};
|
|
41
|
+
|
|
17
42
|
/**
|
|
18
43
|
* Get Import Job by ID
|
|
19
44
|
* @param {DynamoClient} dynamoClient
|
|
@@ -15,9 +15,17 @@ import {
|
|
|
15
15
|
getImportJobByID,
|
|
16
16
|
getImportJobsByStatus,
|
|
17
17
|
updateImportJob,
|
|
18
|
+
getImportJobsByDateRange,
|
|
18
19
|
} from './accessPatterns.js';
|
|
19
20
|
|
|
20
21
|
export const importJobFunctions = (dynamoClient, config, log) => ({
|
|
22
|
+
getImportJobsByDateRange: (startDate, endDate) => getImportJobsByDateRange(
|
|
23
|
+
dynamoClient,
|
|
24
|
+
config,
|
|
25
|
+
log,
|
|
26
|
+
startDate,
|
|
27
|
+
endDate,
|
|
28
|
+
),
|
|
21
29
|
getImportJobByID: (id) => getImportJobByID(
|
|
22
30
|
dynamoClient,
|
|
23
31
|
config,
|