@adobe/spacecat-shared-data-access 1.61.19 → 2.0.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 +19 -0
- package/package.json +5 -6
- package/src/index.d.ts +4 -934
- package/src/index.js +1 -91
- package/src/{v2 → models}/index.d.ts +14 -3
- package/src/{v2/models → models}/organization/organization.schema.js +1 -1
- package/src/{v2/models → models}/site/site.schema.js +1 -1
- package/src/service/index.d.ts +20 -0
- package/src/service/index.js +6 -46
- package/src/dto/api-key.js +0 -58
- package/src/dto/audit.js +0 -80
- package/src/dto/configuration.js +0 -49
- package/src/dto/dto-utils.js +0 -30
- package/src/dto/experiment.js +0 -66
- package/src/dto/import-job.js +0 -76
- package/src/dto/import-url.js +0 -55
- package/src/dto/key-event.js +0 -52
- package/src/dto/organization.js +0 -54
- package/src/dto/site-candidate.js +0 -54
- package/src/dto/site-top-page.js +0 -52
- package/src/dto/site.js +0 -62
- package/src/models/api-key/api-key.js +0 -182
- package/src/models/audit.js +0 -146
- package/src/models/base.js +0 -42
- package/src/models/configuration.js +0 -194
- package/src/models/experiment.js +0 -67
- package/src/models/importer/import-constants.js +0 -40
- package/src/models/importer/import-job.js +0 -252
- package/src/models/importer/import-url.js +0 -115
- package/src/models/key-event.js +0 -81
- package/src/models/organization.js +0 -120
- package/src/models/site-candidate.js +0 -111
- package/src/models/site-top-page.js +0 -62
- package/src/models/site.js +0 -218
- package/src/service/api-key/accessPatterns.js +0 -110
- package/src/service/api-key/index.js +0 -37
- package/src/service/audits/accessPatterns.js +0 -284
- package/src/service/audits/index.js +0 -72
- package/src/service/configurations/accessPatterns.js +0 -123
- package/src/service/configurations/index.js +0 -38
- package/src/service/experiments/accessPatterns.js +0 -98
- package/src/service/experiments/index.js +0 -40
- package/src/service/import-job/accessPatterns.js +0 -134
- package/src/service/import-job/index.js +0 -60
- package/src/service/import-url/accessPatterns.js +0 -153
- package/src/service/import-url/index.js +0 -53
- package/src/service/key-events/accessPatterns.js +0 -92
- package/src/service/key-events/index.js +0 -38
- package/src/service/organizations/accessPatterns.js +0 -160
- package/src/service/organizations/index.js +0 -51
- package/src/service/site-candidates/accessPatterns.js +0 -112
- package/src/service/site-candidates/index.js +0 -48
- package/src/service/site-top-pages/accessPatterns.js +0 -83
- package/src/service/site-top-pages/index.js +0 -42
- package/src/service/sites/accessPatterns.js +0 -467
- package/src/service/sites/index.js +0 -116
- package/src/v2/index.js +0 -15
- package/src/v2/models/index.d.ts +0 -26
- /package/src/{v2/errors → errors}/data-access.error.js +0 -0
- /package/src/{v2/errors → errors}/index.d.ts +0 -0
- /package/src/{v2/errors → errors}/index.js +0 -0
- /package/src/{v2/errors → errors}/reference.error.js +0 -0
- /package/src/{v2/errors → errors}/schema-validation.error.js +0 -0
- /package/src/{v2/errors → errors}/schema.builder.error.js +0 -0
- /package/src/{v2/errors → errors}/schema.error.js +0 -0
- /package/src/{v2/errors → errors}/validation.error.js +0 -0
- /package/src/{v2/models → models}/api-key/api-key.collection.js +0 -0
- /package/src/{v2/models → models}/api-key/api-key.model.js +0 -0
- /package/src/{v2/models → models}/api-key/api-key.schema.js +0 -0
- /package/src/{v2/models → models}/api-key/index.d.ts +0 -0
- /package/src/{v2/models → models}/api-key/index.js +0 -0
- /package/src/{v2/models → models}/audit/audit.collection.js +0 -0
- /package/src/{v2/models → models}/audit/audit.model.js +0 -0
- /package/src/{v2/models → models}/audit/audit.schema.js +0 -0
- /package/src/{v2/models → models}/audit/index.d.ts +0 -0
- /package/src/{v2/models → models}/audit/index.js +0 -0
- /package/src/{v2/models → models}/base/base.collection.js +0 -0
- /package/src/{v2/models → models}/base/base.model.js +0 -0
- /package/src/{v2/models → models}/base/entity.registry.js +0 -0
- /package/src/{v2/models → models}/base/index.d.ts +0 -0
- /package/src/{v2/models → models}/base/index.js +0 -0
- /package/src/{v2/models → models}/base/reference.js +0 -0
- /package/src/{v2/models → models}/base/schema.builder.js +0 -0
- /package/src/{v2/models → models}/base/schema.js +0 -0
- /package/src/{v2/models → models}/configuration/configuration.collection.js +0 -0
- /package/src/{v2/models → models}/configuration/configuration.model.js +0 -0
- /package/src/{v2/models → models}/configuration/configuration.schema.js +0 -0
- /package/src/{v2/models → models}/configuration/index.d.ts +0 -0
- /package/src/{v2/models → models}/configuration/index.js +0 -0
- /package/src/{v2/models → models}/experiment/experiment.collection.js +0 -0
- /package/src/{v2/models → models}/experiment/experiment.model.js +0 -0
- /package/src/{v2/models → models}/experiment/experiment.schema.js +0 -0
- /package/src/{v2/models → models}/experiment/index.d.ts +0 -0
- /package/src/{v2/models → models}/experiment/index.js +0 -0
- /package/src/{v2/models → models}/import-job/import-job.collection.js +0 -0
- /package/src/{v2/models → models}/import-job/import-job.model.js +0 -0
- /package/src/{v2/models → models}/import-job/import-job.schema.js +0 -0
- /package/src/{v2/models → models}/import-job/index.d.ts +0 -0
- /package/src/{v2/models → models}/import-job/index.js +0 -0
- /package/src/{v2/models → models}/import-url/import-url.collection.js +0 -0
- /package/src/{v2/models → models}/import-url/import-url.model.js +0 -0
- /package/src/{v2/models → models}/import-url/import-url.schema.js +0 -0
- /package/src/{v2/models → models}/import-url/index.d.ts +0 -0
- /package/src/{v2/models → models}/import-url/index.js +0 -0
- /package/src/{v2/models → models}/index.js +0 -0
- /package/src/{v2/models → models}/key-event/index.d.ts +0 -0
- /package/src/{v2/models → models}/key-event/index.js +0 -0
- /package/src/{v2/models → models}/key-event/key-event.collection.js +0 -0
- /package/src/{v2/models → models}/key-event/key-event.model.js +0 -0
- /package/src/{v2/models → models}/key-event/key-event.schema.js +0 -0
- /package/src/{v2/models → models}/latest-audit/index.d.ts +0 -0
- /package/src/{v2/models → models}/latest-audit/index.js +0 -0
- /package/src/{v2/models → models}/latest-audit/latest-audit.collection.js +0 -0
- /package/src/{v2/models → models}/latest-audit/latest-audit.model.js +0 -0
- /package/src/{v2/models → models}/latest-audit/latest-audit.schema.js +0 -0
- /package/src/{v2/models → models}/opportunity/index.d.ts +0 -0
- /package/src/{v2/models → models}/opportunity/index.js +0 -0
- /package/src/{v2/models → models}/opportunity/opportunity.collection.js +0 -0
- /package/src/{v2/models → models}/opportunity/opportunity.model.js +0 -0
- /package/src/{v2/models → models}/opportunity/opportunity.schema.js +0 -0
- /package/src/{v2/models → models}/organization/index.d.ts +0 -0
- /package/src/{v2/models → models}/organization/index.js +0 -0
- /package/src/{v2/models → models}/organization/organization.collection.js +0 -0
- /package/src/{v2/models → models}/organization/organization.model.js +0 -0
- /package/src/{v2/models → models}/site/index.d.ts +0 -0
- /package/src/{v2/models → models}/site/index.js +0 -0
- /package/src/{v2/models → models}/site/site.collection.js +0 -0
- /package/src/{v2/models → models}/site/site.model.js +0 -0
- /package/src/{v2/models → models}/site-candidate/index.d.ts +0 -0
- /package/src/{v2/models → models}/site-candidate/index.js +0 -0
- /package/src/{v2/models → models}/site-candidate/site-candidate.collection.js +0 -0
- /package/src/{v2/models → models}/site-candidate/site-candidate.model.js +0 -0
- /package/src/{v2/models → models}/site-candidate/site-candidate.schema.js +0 -0
- /package/src/{v2/models → models}/site-top-page/index.d.ts +0 -0
- /package/src/{v2/models → models}/site-top-page/index.js +0 -0
- /package/src/{v2/models → models}/site-top-page/site-top-page.collection.js +0 -0
- /package/src/{v2/models → models}/site-top-page/site-top-page.model.js +0 -0
- /package/src/{v2/models → models}/site-top-page/site-top-page.schema.js +0 -0
- /package/src/{v2/models → models}/suggestion/index.d.ts +0 -0
- /package/src/{v2/models → models}/suggestion/index.js +0 -0
- /package/src/{v2/models → models}/suggestion/suggestion.collection.js +0 -0
- /package/src/{v2/models → models}/suggestion/suggestion.model.js +0 -0
- /package/src/{v2/models → models}/suggestion/suggestion.schema.js +0 -0
- /package/src/{v2/readme.md → readme.md} +0 -0
- /package/src/{v2/util → util}/accessor.utils.js +0 -0
- /package/src/{v2/util → util}/guards.d.ts +0 -0
- /package/src/{v2/util → util}/guards.js +0 -0
- /package/src/{v2/util → util}/index.d.ts +0 -0
- /package/src/{v2/util → util}/index.js +0 -0
- /package/src/{v2/util → util}/patcher.js +0 -0
- /package/src/{v2/util → util}/util.js +0 -0
package/src/index.js
CHANGED
|
@@ -12,40 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
import { createDataAccess } from './service/index.js';
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export * from './service/index.js';
|
|
16
16
|
|
|
17
17
|
const TABLE_NAME_DATA = 'spacecat-services-data-dev';
|
|
18
|
-
const TABLE_NAME_AUDITS = 'spacecat-services-audits-dev';
|
|
19
|
-
const TABLE_NAME_KEY_EVENTS = 'spacecat-services-key-events';
|
|
20
|
-
const TABLE_NAME_LATEST_AUDITS = 'spacecat-services-latest-audits-dev';
|
|
21
|
-
const TABLE_NAME_SITES = 'spacecat-services-sites-dev';
|
|
22
|
-
const TABLE_NAME_SITE_CANDIDATES = 'spacecat-services-site-candidates-dev';
|
|
23
|
-
const TABLE_NAME_ORGANIZATIONS = 'spacecat-services-organizations-dev';
|
|
24
|
-
const TABLE_NAME_CONFIGURATIONS = 'spacecat-services-configurations-dev';
|
|
25
|
-
const TABLE_NAME_SITE_TOP_PAGES = 'spacecat-services-site-top-pages-dev';
|
|
26
|
-
const TABLE_NAME_IMPORT_JOBS = 'spacecat-services-import-jobs-dev';
|
|
27
|
-
const TABLE_NAME_IMPORT_URLS = 'spacecat-services-import-urls-dev';
|
|
28
|
-
const TABLE_NAME_EXPERIMENTS = 'spacecat-services-experiments-dev';
|
|
29
|
-
const TABLE_NAME_API_KEYS = 'spacecat-services-api-keys-dev';
|
|
30
|
-
|
|
31
|
-
const INDEX_NAME_ALL_KEY_EVENTS_BY_SITE_ID = 'spacecat-services-key-events-by-site-id';
|
|
32
|
-
const INDEX_NAME_ALL_SITES = 'spacecat-services-all-sites-dev';
|
|
33
|
-
const INDEX_NAME_ALL_ORGANIZATIONS = 'spacecat-services-all-organizations-dev';
|
|
34
|
-
const INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID = 'spacecat-services-all-organizations-by-ims-org-id-dev';
|
|
35
|
-
const INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = 'spacecat-services-all-sites-by-delivery-type-dev';
|
|
36
|
-
const INDEX_NAME_ALL_LATEST_AUDIT_SCORES = 'spacecat-services-all-latest-audit-scores-dev';
|
|
37
|
-
const INDEX_NAME_ALL_SITES_ORGANIZATIONS = 'spacecat-services-all-sites-organizations-dev';
|
|
38
|
-
const INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS = 'spacecat-services-all-import-jobs-by-status-dev';
|
|
39
|
-
const INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE = 'spacecat-services-all-import-jobs-by-date-range-dev';
|
|
40
|
-
const INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS = 'spacecat-services-all-import-urls-by-job-id-and-status-dev';
|
|
41
|
-
const INDEX_NAME_API_KEY_BY_HASHED_API_KEY = 'spacecat-services-api-key-by-hashed-api-key-dev';
|
|
42
|
-
const INDEX_NAME_API_KEY_BY_IMS_USER_ID_AND_IMS_ORG_ID = 'spacecat-services-api-key-by-ims-user-id-and-ims-org-id-dev';
|
|
43
|
-
|
|
44
|
-
const PK_ALL_SITES = 'ALL_SITES';
|
|
45
|
-
const PK_ALL_CONFIGURATIONS = 'ALL_CONFIGURATIONS';
|
|
46
|
-
const PK_ALL_ORGANIZATIONS = 'ALL_ORGANIZATIONS';
|
|
47
|
-
const PK_ALL_LATEST_AUDITS = 'ALL_LATEST_AUDITS';
|
|
48
|
-
const PK_ALL_IMPORT_JOBS = 'ALL_IMPORT_JOBS';
|
|
49
18
|
|
|
50
19
|
export default function dataAccessWrapper(fn) {
|
|
51
20
|
return async (request, context) => {
|
|
@@ -54,72 +23,13 @@ export default function dataAccessWrapper(fn) {
|
|
|
54
23
|
|
|
55
24
|
const {
|
|
56
25
|
DYNAMO_TABLE_NAME_DATA = TABLE_NAME_DATA,
|
|
57
|
-
DYNAMO_TABLE_NAME_AUDITS = TABLE_NAME_AUDITS,
|
|
58
|
-
DYNAMO_TABLE_NAME_KEY_EVENTS = TABLE_NAME_KEY_EVENTS,
|
|
59
|
-
DYNAMO_TABLE_NAME_LATEST_AUDITS = TABLE_NAME_LATEST_AUDITS,
|
|
60
|
-
DYNAMO_TABLE_NAME_SITES = TABLE_NAME_SITES,
|
|
61
|
-
DYNAMO_TABLE_NAME_SITE_CANDIDATES = TABLE_NAME_SITE_CANDIDATES,
|
|
62
|
-
DYNAMO_TABLE_NAME_ORGANIZATIONS = TABLE_NAME_ORGANIZATIONS,
|
|
63
|
-
DYNAMO_TABLE_NAME_CONFIGURATIONS = TABLE_NAME_CONFIGURATIONS,
|
|
64
|
-
DYNAMO_TABLE_NAME_SITE_TOP_PAGES = TABLE_NAME_SITE_TOP_PAGES,
|
|
65
|
-
DYNAMO_TABLE_NAME_IMPORT_JOBS = TABLE_NAME_IMPORT_JOBS,
|
|
66
|
-
DYNAMO_TABLE_NAME_IMPORT_URLS = TABLE_NAME_IMPORT_URLS,
|
|
67
|
-
DYNAMO_TABLE_NAME_EXPERIMENTS = TABLE_NAME_EXPERIMENTS,
|
|
68
|
-
DYNAMO_TABLE_NAME_API_KEYS = TABLE_NAME_API_KEYS,
|
|
69
|
-
DYNAMO_INDEX_NAME_ALL_KEY_EVENTS_BY_SITE_ID = INDEX_NAME_ALL_KEY_EVENTS_BY_SITE_ID,
|
|
70
|
-
DYNAMO_INDEX_NAME_ALL_SITES = INDEX_NAME_ALL_SITES,
|
|
71
|
-
DYNAMO_INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE,
|
|
72
|
-
DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES = INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
|
|
73
|
-
DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS = INDEX_NAME_ALL_ORGANIZATIONS,
|
|
74
|
-
// eslint-disable-next-line max-len
|
|
75
|
-
DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID = INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID,
|
|
76
|
-
DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS = INDEX_NAME_ALL_SITES_ORGANIZATIONS,
|
|
77
|
-
DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS = INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS,
|
|
78
|
-
DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE = INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE,
|
|
79
|
-
DYNAMO_INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS =
|
|
80
|
-
INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS,
|
|
81
|
-
DYNAMO_INDEX_NAME_API_KEY_BY_HASHED_API_KEY = INDEX_NAME_API_KEY_BY_HASHED_API_KEY,
|
|
82
|
-
DYNAMO_INDEX_NAME_API_KEY_BY_IMS_USER_ID_AND_IMS_ORG_ID =
|
|
83
|
-
INDEX_NAME_API_KEY_BY_IMS_USER_ID_AND_IMS_ORG_ID,
|
|
84
26
|
} = context.env;
|
|
85
27
|
|
|
86
28
|
context.dataAccess = createDataAccess({
|
|
87
29
|
tableNameData: DYNAMO_TABLE_NAME_DATA,
|
|
88
|
-
tableNameAudits: DYNAMO_TABLE_NAME_AUDITS,
|
|
89
|
-
tableNameKeyEvents: DYNAMO_TABLE_NAME_KEY_EVENTS,
|
|
90
|
-
tableNameLatestAudits: DYNAMO_TABLE_NAME_LATEST_AUDITS,
|
|
91
|
-
tableNameOrganizations: DYNAMO_TABLE_NAME_ORGANIZATIONS,
|
|
92
|
-
tableNameSites: DYNAMO_TABLE_NAME_SITES,
|
|
93
|
-
tableNameSiteCandidates: DYNAMO_TABLE_NAME_SITE_CANDIDATES,
|
|
94
|
-
tableNameConfigurations: DYNAMO_TABLE_NAME_CONFIGURATIONS,
|
|
95
|
-
tableNameSiteTopPages: DYNAMO_TABLE_NAME_SITE_TOP_PAGES,
|
|
96
|
-
tableNameImportJobs: DYNAMO_TABLE_NAME_IMPORT_JOBS,
|
|
97
|
-
tableNameImportUrls: DYNAMO_TABLE_NAME_IMPORT_URLS,
|
|
98
|
-
tableNameExperiments: DYNAMO_TABLE_NAME_EXPERIMENTS,
|
|
99
|
-
tableNameApiKeys: DYNAMO_TABLE_NAME_API_KEYS,
|
|
100
|
-
indexNameAllKeyEventsBySiteId: DYNAMO_INDEX_NAME_ALL_KEY_EVENTS_BY_SITE_ID,
|
|
101
|
-
indexNameAllSites: DYNAMO_INDEX_NAME_ALL_SITES,
|
|
102
|
-
indexNameAllOrganizations: DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS,
|
|
103
|
-
indexNameAllOrganizationsByImsOrgId: DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID,
|
|
104
|
-
indexNameAllSitesByDeliveryType: DYNAMO_INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE,
|
|
105
|
-
indexNameAllLatestAuditScores: DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
|
|
106
|
-
indexNameAllSitesOrganizations: DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS,
|
|
107
|
-
indexNameAllImportJobsByStatus: DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_STATUS,
|
|
108
|
-
indexNameAllImportJobsByDateRange: DYNAMO_INDEX_NAME_ALL_IMPORT_JOBS_BY_DATE_RANGE,
|
|
109
|
-
indexNameImportUrlsByJobIdAndStatus: DYNAMO_INDEX_NAME_ALL_IMPORT_URLS_BY_JOB_ID_AND_STATUS,
|
|
110
|
-
indexNameApiKeyByHashedApiKey: DYNAMO_INDEX_NAME_API_KEY_BY_HASHED_API_KEY,
|
|
111
|
-
indexNameApiKeyByImsUserIdAndImsOrgId:
|
|
112
|
-
DYNAMO_INDEX_NAME_API_KEY_BY_IMS_USER_ID_AND_IMS_ORG_ID,
|
|
113
|
-
pkAllSites: PK_ALL_SITES,
|
|
114
|
-
pkAllOrganizations: PK_ALL_ORGANIZATIONS,
|
|
115
|
-
pkAllLatestAudits: PK_ALL_LATEST_AUDITS,
|
|
116
|
-
pkAllConfigurations: PK_ALL_CONFIGURATIONS,
|
|
117
|
-
pkAllImportJobs: PK_ALL_IMPORT_JOBS,
|
|
118
30
|
}, log);
|
|
119
31
|
}
|
|
120
32
|
|
|
121
33
|
return fn(request, context);
|
|
122
34
|
};
|
|
123
35
|
}
|
|
124
|
-
|
|
125
|
-
export * from './v2/index.js';
|
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export type * from './
|
|
14
|
-
export type * from './
|
|
15
|
-
export type * from './
|
|
13
|
+
export type * from './audit';
|
|
14
|
+
export type * from './configuration';
|
|
15
|
+
export type * from './base';
|
|
16
|
+
export type * from './experiment';
|
|
17
|
+
export type * from './import-job';
|
|
18
|
+
export type * from './import-url';
|
|
19
|
+
export type * from './key-event';
|
|
20
|
+
export type * from './latest-audit';
|
|
21
|
+
export type * from './opportunity';
|
|
22
|
+
export type * from './organization';
|
|
23
|
+
export type * from './site';
|
|
24
|
+
export type * from './site-candidate';
|
|
25
|
+
export type * from './site-top-page';
|
|
26
|
+
export type * from './suggestion';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { isNonEmptyObject } from '@adobe/spacecat-shared-utils';
|
|
16
16
|
|
|
17
|
-
import { Config, DEFAULT_CONFIG, validateConfiguration } from '
|
|
17
|
+
import { Config, DEFAULT_CONFIG, validateConfiguration } from '../site/config.js';
|
|
18
18
|
import SchemaBuilder from '../base/schema.builder.js';
|
|
19
19
|
import Organization from './organization.model.js';
|
|
20
20
|
import OrganizationCollection from './organization.collection.js';
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
isValidUrl,
|
|
20
20
|
} from '@adobe/spacecat-shared-utils';
|
|
21
21
|
|
|
22
|
-
import { Config, DEFAULT_CONFIG, validateConfiguration } from '
|
|
22
|
+
import { Config, DEFAULT_CONFIG, validateConfiguration } from './config.js';
|
|
23
23
|
import SchemaBuilder from '../base/schema.builder.js';
|
|
24
24
|
|
|
25
25
|
import Site from './site.model.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface DataAccessConfig {
|
|
14
|
+
tableNameData: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createDataAccess(
|
|
18
|
+
config: DataAccessConfig,
|
|
19
|
+
logger: object,
|
|
20
|
+
): object;
|
package/src/service/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -10,26 +10,16 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { createClient } from '@adobe/spacecat-shared-dynamo';
|
|
14
13
|
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
15
14
|
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
16
|
-
|
|
17
15
|
import AWSXray from 'aws-xray-sdk';
|
|
18
16
|
import { Service } from 'electrodb';
|
|
19
17
|
|
|
20
|
-
import EntityRegistry from '../
|
|
18
|
+
import { EntityRegistry } from '../models/index.js';
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import { siteCandidateFunctions } from './site-candidates/index.js';
|
|
26
|
-
import { organizationFunctions } from './organizations/index.js';
|
|
27
|
-
import { configurationFunctions } from './configurations/index.js';
|
|
28
|
-
import { siteTopPagesFunctions } from './site-top-pages/index.js';
|
|
29
|
-
import { importJobFunctions } from './import-job/index.js';
|
|
30
|
-
import { importUrlFunctions } from './import-url/index.js';
|
|
31
|
-
import { experimentFunctions } from './experiments/index.js';
|
|
32
|
-
import { apiKeyFunctions } from './api-key/index.js';
|
|
20
|
+
export * from '../errors/index.js';
|
|
21
|
+
export * from '../models/index.js';
|
|
22
|
+
export * from '../util/index.js';
|
|
33
23
|
|
|
34
24
|
const createRawClient = (client = undefined) => {
|
|
35
25
|
const dbClient = client || AWSXray.captureAWSv3Client(new DynamoDB());
|
|
@@ -74,39 +64,9 @@ const createElectroService = (client, config, log) => {
|
|
|
74
64
|
* @returns {object} data access object
|
|
75
65
|
*/
|
|
76
66
|
export const createDataAccess = (config, log = console, client = undefined) => {
|
|
77
|
-
const dynamoClient = createClient(log, client);
|
|
78
|
-
|
|
79
|
-
const auditFuncs = auditFunctions(dynamoClient, config, log);
|
|
80
|
-
const keyEventFuncs = keyEventFunctions(dynamoClient, config, log);
|
|
81
|
-
const siteFuncs = siteFunctions(dynamoClient, config, log);
|
|
82
|
-
const siteCandidateFuncs = siteCandidateFunctions(dynamoClient, config, log);
|
|
83
|
-
const organizationFuncs = organizationFunctions(dynamoClient, config, log);
|
|
84
|
-
const configurationFuncs = configurationFunctions(dynamoClient, config);
|
|
85
|
-
const siteTopPagesFuncs = siteTopPagesFunctions(dynamoClient, config);
|
|
86
|
-
const importJobFuncs = importJobFunctions(dynamoClient, config, log);
|
|
87
|
-
const importUrlFuncs = importUrlFunctions(dynamoClient, config, log);
|
|
88
|
-
const experimentFuncs = experimentFunctions(dynamoClient, config, log);
|
|
89
|
-
const apiKeyFuncs = apiKeyFunctions(dynamoClient, config, log);
|
|
90
|
-
|
|
91
|
-
// electro-based data access objects
|
|
92
67
|
const rawClient = createRawClient(client);
|
|
93
68
|
const electroService = createElectroService(rawClient, config, log);
|
|
94
69
|
const entityRegistry = new EntityRegistry(electroService, log);
|
|
95
|
-
const collections = entityRegistry.getCollections();
|
|
96
70
|
|
|
97
|
-
return
|
|
98
|
-
...auditFuncs,
|
|
99
|
-
...keyEventFuncs,
|
|
100
|
-
...siteFuncs,
|
|
101
|
-
...siteCandidateFuncs,
|
|
102
|
-
...organizationFuncs,
|
|
103
|
-
...configurationFuncs,
|
|
104
|
-
...siteTopPagesFuncs,
|
|
105
|
-
...importJobFuncs,
|
|
106
|
-
...importUrlFuncs,
|
|
107
|
-
...experimentFuncs,
|
|
108
|
-
...apiKeyFuncs,
|
|
109
|
-
// electro-based data access objects
|
|
110
|
-
...collections,
|
|
111
|
-
};
|
|
71
|
+
return entityRegistry.getCollections();
|
|
112
72
|
};
|
package/src/dto/api-key.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { createApiKey } from '../models/api-key/api-key.js';
|
|
14
|
-
|
|
15
|
-
export const ApiKeyDto = {
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Converts an ApiKey object into a DynamoDB item.
|
|
19
|
-
* @param apiKey
|
|
20
|
-
* @returns {{createdAt: string, name: string, imsUserId: string,
|
|
21
|
-
* scopes: array<object>, revokedAt: string, deletedAt: string,
|
|
22
|
-
* hashedApiKey: string, imsOrgId: string, expiresAt: string}}
|
|
23
|
-
*/
|
|
24
|
-
toDynamoItem: (apiKey) => ({
|
|
25
|
-
id: apiKey.getId(),
|
|
26
|
-
hashedApiKey: apiKey.getHashedApiKey(),
|
|
27
|
-
name: apiKey.getName(),
|
|
28
|
-
imsUserId: apiKey.getImsUserId(),
|
|
29
|
-
imsOrgId: apiKey.getImsOrgId(),
|
|
30
|
-
createdAt: apiKey.getCreatedAt(),
|
|
31
|
-
expiresAt: apiKey.getExpiresAt(),
|
|
32
|
-
revokedAt: apiKey.getRevokedAt(),
|
|
33
|
-
deletedAt: apiKey.getDeletedAt(),
|
|
34
|
-
scopes: apiKey.getScopes(),
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Converts a DynamoDB item into an ApiKey object.
|
|
39
|
-
* @param dynamoItem
|
|
40
|
-
* @returns {ApiKey}
|
|
41
|
-
*/
|
|
42
|
-
fromDynamoItem: (dynamoItem) => {
|
|
43
|
-
const apiKeyData = {
|
|
44
|
-
id: dynamoItem.id,
|
|
45
|
-
hashedApiKey: dynamoItem.hashedApiKey,
|
|
46
|
-
name: dynamoItem.name,
|
|
47
|
-
imsUserId: dynamoItem.imsUserId,
|
|
48
|
-
imsOrgId: dynamoItem.imsOrgId,
|
|
49
|
-
createdAt: dynamoItem.createdAt,
|
|
50
|
-
expiresAt: dynamoItem.expiresAt,
|
|
51
|
-
revokedAt: dynamoItem.revokedAt,
|
|
52
|
-
deletedAt: dynamoItem.deletedAt,
|
|
53
|
-
scopes: dynamoItem.scopes,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return createApiKey(apiKeyData);
|
|
57
|
-
},
|
|
58
|
-
};
|
package/src/dto/audit.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { isObject } from '@adobe/spacecat-shared-utils';
|
|
14
|
-
|
|
15
|
-
import { createAudit } from '../models/audit.js';
|
|
16
|
-
import { convertDateToEpochSeconds, parseEpochToDate } from './dto-utils.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Data transfer object for Audit.
|
|
20
|
-
*/
|
|
21
|
-
export const AuditDto = {
|
|
22
|
-
/**
|
|
23
|
-
* Converts an Audit object into a DynamoDB item.
|
|
24
|
-
* @param {Readonly<Audit>} audit - Audit object.
|
|
25
|
-
* @param {boolean} isLatestAudit - If true, returns the latest audit flavor.
|
|
26
|
-
* @returns {{siteId, auditedAt, auditResult, auditType, expiresAt, fullAuditRef, SK: string}}
|
|
27
|
-
*/
|
|
28
|
-
toDynamoItem: (audit, isLatestAudit = false) => {
|
|
29
|
-
const GSI1PK = 'ALL_LATEST_AUDITS';
|
|
30
|
-
let GSI1SK;
|
|
31
|
-
|
|
32
|
-
if (audit.isError()) {
|
|
33
|
-
GSI1SK = `${audit.getAuditType()}#error`;
|
|
34
|
-
} else {
|
|
35
|
-
GSI1SK = `${audit.getAuditType()}#${Object.values(audit.getScores()).join('#')}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const latestAuditProps = isLatestAudit ? {
|
|
39
|
-
GSI1PK,
|
|
40
|
-
GSI1SK,
|
|
41
|
-
...(isObject(audit.getPreviousAuditResult())
|
|
42
|
-
&& { previousAuditResult: audit.getPreviousAuditResult() }),
|
|
43
|
-
} : {};
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
id: audit.getId(),
|
|
47
|
-
siteId: audit.getSiteId(),
|
|
48
|
-
auditedAt: audit.getAuditedAt(),
|
|
49
|
-
auditResult: audit.getAuditResult(),
|
|
50
|
-
auditType: audit.getAuditType(),
|
|
51
|
-
expiresAt: convertDateToEpochSeconds(audit.getExpiresAt()),
|
|
52
|
-
fullAuditRef: audit.getFullAuditRef(),
|
|
53
|
-
isLive: audit.isLive(),
|
|
54
|
-
SK: `${audit.getAuditType()}#${audit.getAuditedAt()}`,
|
|
55
|
-
...latestAuditProps,
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Converts a DynamoDB item into an Audit object.
|
|
61
|
-
* @param {object} dynamoItem - DynamoDB item.
|
|
62
|
-
* @returns {Readonly<Audit>} Audit object.
|
|
63
|
-
*/
|
|
64
|
-
fromDynamoItem: (dynamoItem) => {
|
|
65
|
-
const auditData = {
|
|
66
|
-
id: dynamoItem.id,
|
|
67
|
-
siteId: dynamoItem.siteId,
|
|
68
|
-
auditedAt: dynamoItem.auditedAt,
|
|
69
|
-
auditResult: dynamoItem.auditResult,
|
|
70
|
-
auditType: dynamoItem.auditType,
|
|
71
|
-
expiresAt: parseEpochToDate(dynamoItem.expiresAt),
|
|
72
|
-
fullAuditRef: dynamoItem.fullAuditRef,
|
|
73
|
-
isLive: dynamoItem.isLive,
|
|
74
|
-
...(isObject(dynamoItem.previousAuditResult)
|
|
75
|
-
&& { previousAuditResult: dynamoItem.previousAuditResult }),
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return createAudit(auditData);
|
|
79
|
-
},
|
|
80
|
-
};
|
package/src/dto/configuration.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { createConfiguration } from '../models/configuration.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Data transfer object for Configuration.
|
|
17
|
-
*/
|
|
18
|
-
export const ConfigurationDto = {
|
|
19
|
-
/**
|
|
20
|
-
* Converts a DynamoDB item into a Configuration object.
|
|
21
|
-
* @param {object } dynamoItem - DynamoDB item.
|
|
22
|
-
* @returns {Readonly<Configuration>} Configuration object.
|
|
23
|
-
*/
|
|
24
|
-
fromDynamoItem: (dynamoItem) => {
|
|
25
|
-
const configurationData = {
|
|
26
|
-
version: dynamoItem.version,
|
|
27
|
-
queues: dynamoItem.queues,
|
|
28
|
-
jobs: dynamoItem.jobs,
|
|
29
|
-
handlers: dynamoItem.handlers,
|
|
30
|
-
slackRoles: dynamoItem.slackRoles,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return createConfiguration(configurationData);
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Converts a Configuration object into a DynamoDB item.
|
|
38
|
-
* @param {Readonly<Configuration>} configuration - Configuration object.
|
|
39
|
-
* @returns {object} DynamoDB item.
|
|
40
|
-
*/
|
|
41
|
-
toDynamoItem: (configuration) => ({
|
|
42
|
-
PK: 'ALL_CONFIGURATIONS',
|
|
43
|
-
version: configuration.getVersion(),
|
|
44
|
-
queues: configuration.getQueues(),
|
|
45
|
-
jobs: configuration.getJobs(),
|
|
46
|
-
handlers: configuration.getHandlers(),
|
|
47
|
-
slackRoles: configuration.getSlackRoles(),
|
|
48
|
-
}),
|
|
49
|
-
};
|
package/src/dto/dto-utils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Parse the given Epoch timestamp, in seconds, to a Date object.
|
|
15
|
-
* @param {number} epochInSeconds - The Epoch timestamp in seconds.
|
|
16
|
-
* @returns {Date} A new Date object set to the given timestamp.
|
|
17
|
-
*/
|
|
18
|
-
export function parseEpochToDate(epochInSeconds) {
|
|
19
|
-
const milliseconds = epochInSeconds * 1000;
|
|
20
|
-
return new Date(milliseconds);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Convert the given Date object to an Epoch timestamp, in seconds.
|
|
25
|
-
* @param {Date} date - The Date object to convert.
|
|
26
|
-
* @returns {number} The Epoch timestamp in seconds.
|
|
27
|
-
*/
|
|
28
|
-
export function convertDateToEpochSeconds(date) {
|
|
29
|
-
return Math.floor(date.getTime() / 1000);
|
|
30
|
-
}
|
package/src/dto/experiment.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { createExperiment } from '../models/experiment.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Data transfer object for Experiment.
|
|
17
|
-
*/
|
|
18
|
-
export const ExperimentDto = {
|
|
19
|
-
/**
|
|
20
|
-
* Converts an Experiment object into a DynamoDB item.
|
|
21
|
-
* @param {Readonly<Experiment>} experiment - Experiment object.
|
|
22
|
-
* @returns {{siteId, id, name, url, status, type, startDate, endDate,
|
|
23
|
-
* variants, updatedAt, updatedBy, conversionEventName, conversionEventValue}}
|
|
24
|
-
*/
|
|
25
|
-
toDynamoItem: (experiment) => ({
|
|
26
|
-
siteId: experiment.getSiteId(),
|
|
27
|
-
experimentId: experiment.getExperimentId(),
|
|
28
|
-
name: experiment.getName(),
|
|
29
|
-
url: experiment.getUrl(),
|
|
30
|
-
status: experiment.getStatus(),
|
|
31
|
-
type: experiment.getType(),
|
|
32
|
-
startDate: experiment.getStartDate(),
|
|
33
|
-
endDate: experiment.getEndDate(),
|
|
34
|
-
variants: experiment.getVariants(),
|
|
35
|
-
updatedAt: experiment.getUpdatedAt(),
|
|
36
|
-
updatedBy: experiment.getUpdatedBy(),
|
|
37
|
-
conversionEventName: experiment.getConversionEventName(),
|
|
38
|
-
conversionEventValue: experiment.getConversionEventValue(),
|
|
39
|
-
SK: `${experiment.getExperimentId()}#${experiment.getUrl()}`,
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Converts a DynamoDB item into Experiment object;
|
|
44
|
-
* @param {object } dynamoItem - DynamoDB item.
|
|
45
|
-
* @returns {Readonly<Experiment>} Experiment object.
|
|
46
|
-
*/
|
|
47
|
-
fromDynamoItem: (dynamoItem) => {
|
|
48
|
-
const experiment = {
|
|
49
|
-
siteId: dynamoItem.siteId,
|
|
50
|
-
experimentId: dynamoItem.experimentId,
|
|
51
|
-
name: dynamoItem.name,
|
|
52
|
-
url: dynamoItem.url,
|
|
53
|
-
status: dynamoItem.status,
|
|
54
|
-
type: dynamoItem.type,
|
|
55
|
-
startDate: dynamoItem.startDate,
|
|
56
|
-
endDate: dynamoItem.endDate,
|
|
57
|
-
variants: dynamoItem.variants,
|
|
58
|
-
updatedAt: dynamoItem.updatedAt,
|
|
59
|
-
updatedBy: dynamoItem.updatedBy,
|
|
60
|
-
conversionEventName: dynamoItem.conversionEventName,
|
|
61
|
-
conversionEventValue: dynamoItem.conversionEventValue,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return createExperiment(experiment);
|
|
65
|
-
},
|
|
66
|
-
};
|
package/src/dto/import-job.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { createImportJob } from '../models/importer/import-job.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The ImportJobDto is a helper that can convert an ImportJob object to a DynamoDB item and
|
|
17
|
-
* vice versa.
|
|
18
|
-
*/
|
|
19
|
-
export const ImportJobDto = {
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Converts an ImportJob object into a DynamoDB item.
|
|
23
|
-
* @param importJob
|
|
24
|
-
* @returns {{duration: *, baseURL: *, failedCount: *, apiKey: *,
|
|
25
|
-
* options: *, successCount: *, importQueueId: *, startTime: *, id: *,
|
|
26
|
-
* endTime: *, status: *}}
|
|
27
|
-
*/
|
|
28
|
-
toDynamoItem: (importJob) => ({
|
|
29
|
-
id: importJob.getId(),
|
|
30
|
-
baseURL: importJob.getBaseURL(),
|
|
31
|
-
hashedApiKey: importJob.getHashedApiKey(),
|
|
32
|
-
options: importJob.getOptions(),
|
|
33
|
-
startTime: importJob.getStartTime(),
|
|
34
|
-
endTime: importJob.getEndTime(),
|
|
35
|
-
duration: importJob.getDuration(),
|
|
36
|
-
status: importJob.getStatus(),
|
|
37
|
-
urlCount: importJob.getUrlCount(),
|
|
38
|
-
successCount: importJob.getSuccessCount(),
|
|
39
|
-
failedCount: importJob.getFailedCount(),
|
|
40
|
-
redirectCount: importJob.getRedirectCount(),
|
|
41
|
-
importQueueId: importJob.getImportQueueId(),
|
|
42
|
-
initiatedBy: importJob.getInitiatedBy(),
|
|
43
|
-
hasCustomHeaders: importJob.hasCustomHeaders(),
|
|
44
|
-
hasCustomImportJs: importJob.hasCustomImportJs(),
|
|
45
|
-
GSI1PK: 'ALL_IMPORT_JOBS',
|
|
46
|
-
}),
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Converts a DynamoDB item into an ImportJob object.
|
|
50
|
-
* @param {object} dynamoItem - The DynamoDB item to convert.
|
|
51
|
-
* @returns {ImportJob} - The ImportJob object.
|
|
52
|
-
*/
|
|
53
|
-
fromDynamoItem: (dynamoItem) => {
|
|
54
|
-
const importJobData = {
|
|
55
|
-
id: dynamoItem.id,
|
|
56
|
-
baseURL: dynamoItem.baseURL,
|
|
57
|
-
hashedApiKey: dynamoItem.hashedApiKey,
|
|
58
|
-
options: dynamoItem.options,
|
|
59
|
-
startTime: dynamoItem.startTime,
|
|
60
|
-
endTime: dynamoItem.endTime,
|
|
61
|
-
duration: dynamoItem.duration,
|
|
62
|
-
status: dynamoItem.status,
|
|
63
|
-
urlCount: dynamoItem.urlCount,
|
|
64
|
-
successCount: dynamoItem.successCount,
|
|
65
|
-
failedCount: dynamoItem.failedCount,
|
|
66
|
-
redirectCount: dynamoItem.redirectCount,
|
|
67
|
-
importQueueId: dynamoItem.importQueueId,
|
|
68
|
-
initiatedBy: dynamoItem.initiatedBy,
|
|
69
|
-
hasCustomHeaders: dynamoItem.hasCustomHeaders,
|
|
70
|
-
hasCustomImportJs: dynamoItem.hasCustomImportJs,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return createImportJob(importJobData);
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
};
|
package/src/dto/import-url.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { createImportUrl } from '../models/importer/import-url.js';
|
|
14
|
-
import { convertDateToEpochSeconds, parseEpochToDate } from './dto-utils.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The ImportUrlDto is a helper that can convert an ImportUrl object to a DynamoDB item and
|
|
18
|
-
* vice versa.
|
|
19
|
-
*/
|
|
20
|
-
export const ImportUrlDto = {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Converts an ImportUrl object to a DynamoDB item.
|
|
24
|
-
* @returns {object} The new DynamoDB item.
|
|
25
|
-
*/
|
|
26
|
-
toDynamoItem: (importUrl) => ({
|
|
27
|
-
id: importUrl.getId(),
|
|
28
|
-
jobId: importUrl.getJobId(),
|
|
29
|
-
url: importUrl.getUrl(),
|
|
30
|
-
status: importUrl.getStatus(),
|
|
31
|
-
reason: importUrl.getReason(),
|
|
32
|
-
path: importUrl.getPath(),
|
|
33
|
-
file: importUrl.getFile(),
|
|
34
|
-
expiresAt: convertDateToEpochSeconds(importUrl.getExpiresAt()),
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Converts a DynamoDB item into an ImportUrl object.
|
|
39
|
-
* @param {object} dynamoItem - The DynamoDB item to convert.
|
|
40
|
-
* @returns {ImportUrl} - The ImportUrl object.
|
|
41
|
-
*/
|
|
42
|
-
fromDynamoItem: (dynamoItem) => {
|
|
43
|
-
const importUrlData = {
|
|
44
|
-
id: dynamoItem.id,
|
|
45
|
-
jobId: dynamoItem.jobId,
|
|
46
|
-
url: dynamoItem.url,
|
|
47
|
-
status: dynamoItem.status,
|
|
48
|
-
reason: dynamoItem.reason,
|
|
49
|
-
path: dynamoItem.path,
|
|
50
|
-
file: dynamoItem.file,
|
|
51
|
-
expiresAt: parseEpochToDate(dynamoItem.expiresAt),
|
|
52
|
-
};
|
|
53
|
-
return createImportUrl(importUrlData);
|
|
54
|
-
},
|
|
55
|
-
};
|