@adobe/spacecat-shared-data-access 1.24.0 → 1.25.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.25.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.24.0...@adobe/spacecat-shared-data-access-v1.25.0) (2024-06-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add update queries for import-job and import-url entites ([#254](https://github.com/adobe/spacecat-shared/issues/254)) ([d1cba93](https://github.com/adobe/spacecat-shared/commit/d1cba93c2ce1073426dc8333142a8d8fd81017ea))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-data-access-v1.24.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.23.6...@adobe/spacecat-shared-data-access-v1.24.0) (2024-06-06)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -610,12 +610,18 @@ export interface DataAccess {
|
|
|
610
610
|
createNewImportJob: (
|
|
611
611
|
importJobData: object,
|
|
612
612
|
) => Promise<ImportJob>;
|
|
613
|
+
updateImportJob: (
|
|
614
|
+
importJob: ImportJob,
|
|
615
|
+
) => Promise<ImportJob>;
|
|
613
616
|
getImportUrlByID: (
|
|
614
617
|
id: string,
|
|
615
618
|
) => Promise<ImportUrl | null>;
|
|
616
619
|
createNewImportUrl: (
|
|
617
620
|
importUrlData: object,
|
|
618
621
|
) => Promise<ImportUrl>;
|
|
622
|
+
updateImportUrl: (
|
|
623
|
+
importUrl: ImportUrl,
|
|
624
|
+
) => Promise<ImportUrl>;
|
|
619
625
|
|
|
620
626
|
// site candidate functions
|
|
621
627
|
getSiteCandidateByBaseURL: (baseURL: string) => Promise<SiteCandidate>;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { isObject } from '@adobe/spacecat-shared-utils';
|
|
13
14
|
import { ImportJobDto } from '../../dto/import-job.js';
|
|
14
15
|
import { createImportJob } from '../../models/importer/import-job.js';
|
|
15
16
|
|
|
@@ -63,3 +64,22 @@ export const createNewImportJob = async (dynamoClient, config, log, importJobDat
|
|
|
63
64
|
await dynamoClient.putItem(config.tableNameImportJobs, ImportJobDto.toDynamoItem(importJob));
|
|
64
65
|
return importJob;
|
|
65
66
|
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Updates an Import Job
|
|
70
|
+
* @param {DynamoClient} dynamoClient
|
|
71
|
+
* @param {Object} config
|
|
72
|
+
* @param {Logger} log
|
|
73
|
+
* @param {ImportJobDto} importJob
|
|
74
|
+
*/
|
|
75
|
+
export const updateImportJob = async (dynamoClient, config, log, importJob) => {
|
|
76
|
+
const existingImportJob = await getImportJobByID(dynamoClient, config, log, importJob.getId());
|
|
77
|
+
|
|
78
|
+
if (!isObject(existingImportJob)) {
|
|
79
|
+
throw new Error(`Import Job with id: ${importJob.getId()} does not exist`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
await dynamoClient.putItem(config.tableNameImportJobs, ImportJobDto.toDynamoItem(importJob));
|
|
83
|
+
|
|
84
|
+
return importJob;
|
|
85
|
+
};
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
createNewImportJob,
|
|
15
15
|
getImportJobByID,
|
|
16
16
|
getImportJobsByStatus,
|
|
17
|
+
updateImportJob,
|
|
17
18
|
} from './accessPatterns.js';
|
|
18
19
|
|
|
19
20
|
export const importJobFunctions = (dynamoClient, config, log) => ({
|
|
@@ -35,4 +36,10 @@ export const importJobFunctions = (dynamoClient, config, log) => ({
|
|
|
35
36
|
log,
|
|
36
37
|
importJobData,
|
|
37
38
|
),
|
|
39
|
+
updateImportJob: (importJobData) => updateImportJob(
|
|
40
|
+
dynamoClient,
|
|
41
|
+
config,
|
|
42
|
+
log,
|
|
43
|
+
importJobData,
|
|
44
|
+
),
|
|
38
45
|
});
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { isObject } from '@adobe/spacecat-shared-utils';
|
|
13
14
|
import { ImportUrlDto } from '../../dto/import-url.js';
|
|
14
15
|
import { createImportUrl } from '../../models/importer/import-url.js';
|
|
15
16
|
|
|
@@ -45,3 +46,28 @@ export const createNewImportUrl = async (dynamoClient, config, log, importUrlDat
|
|
|
45
46
|
);
|
|
46
47
|
return importUrl;
|
|
47
48
|
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Update an existing Import Url
|
|
52
|
+
* @param {DynamoClient} dynamoClient
|
|
53
|
+
* @param {Object} config
|
|
54
|
+
* @param {Logger} log
|
|
55
|
+
* @param {Object} importUrl
|
|
56
|
+
* @returns {ImportUrlDto}
|
|
57
|
+
*/
|
|
58
|
+
export const updateImportUrl = async (dynamoClient, config, log, importUrl) => {
|
|
59
|
+
const existingImportUrl = await getImportUrlById(
|
|
60
|
+
dynamoClient,
|
|
61
|
+
config,
|
|
62
|
+
log,
|
|
63
|
+
importUrl.getId(),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (!isObject(existingImportUrl)) {
|
|
67
|
+
throw new Error(`Import Url with ID:${importUrl.getId()} does not exist`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await dynamoClient.putItem(config.tableNameImportUrls, ImportUrlDto.toDynamoItem(importUrl));
|
|
71
|
+
|
|
72
|
+
return importUrl;
|
|
73
|
+
};
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
getImportUrlById,
|
|
15
|
+
createNewImportUrl,
|
|
16
|
+
updateImportUrl,
|
|
17
|
+
} from './accessPatterns.js';
|
|
14
18
|
|
|
15
19
|
export const importUrlFunctions = (dynamoClient, config, log) => ({
|
|
16
20
|
getImportUrlById: (id) => getImportUrlById(
|
|
@@ -25,4 +29,10 @@ export const importUrlFunctions = (dynamoClient, config, log) => ({
|
|
|
25
29
|
log,
|
|
26
30
|
importUrlData,
|
|
27
31
|
),
|
|
32
|
+
updateImportUrl: (importUrl) => updateImportUrl(
|
|
33
|
+
dynamoClient,
|
|
34
|
+
config,
|
|
35
|
+
log,
|
|
36
|
+
importUrl,
|
|
37
|
+
),
|
|
28
38
|
});
|