@adobe/spacecat-shared-data-access 1.5.2 → 1.6.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 +33 -15
- package/CODE_OF_CONDUCT.md +74 -0
- package/CONTRIBUTING.md +74 -0
- package/package.json +4 -4
- package/src/dto/site.js +2 -0
- package/src/index.d.ts +12 -4
- package/src/index.js +3 -0
- package/src/models/site.js +25 -0
- package/src/service/sites/accessPatterns.js +22 -0
- package/src/service/sites/index.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,58 +1,76 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v1.6.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.6.0...@adobe/spacecat-shared-data-access-v1.6.1) (2024-01-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* github org ([02f86c3](https://github.com/adobe/spacecat-shared/commit/02f86c351b2b1ab99ce5aca7fd5e6af2246c0efd))
|
|
7
|
+
|
|
8
|
+
<<<<<<< Updated upstream
|
|
9
|
+
# [@adobe/spacecat-shared-data-access-v1.6.0](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.5.2...@adobe/spacecat-shared-data-access-v1.6.0) (2024-01-12)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* site delivery type ([#77](https://github.com/adobe-rnd/spacecat-shared/issues/77)) ([005bc38](https://github.com/adobe-rnd/spacecat-shared/commit/005bc388ed6ab0f82c8b0f562d4c1f4c0d1e2894))
|
|
15
|
+
|
|
1
16
|
# [@adobe/spacecat-shared-data-access-v1.5.2](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.5.1...@adobe/spacecat-shared-data-access-v1.5.2) (2023-12-30)
|
|
17
|
+
=======
|
|
18
|
+
# [@adobe/spacecat-shared-data-access-v1.5.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.5.1...@adobe/spacecat-shared-data-access-v1.5.2) (2023-12-30)
|
|
19
|
+
>>>>>>> Stashed changes
|
|
2
20
|
|
|
3
21
|
|
|
4
22
|
### Bug Fixes
|
|
5
23
|
|
|
6
|
-
* **deps:** update external fixes ([#76](https://github.com/adobe
|
|
24
|
+
* **deps:** update external fixes ([#76](https://github.com/adobe/spacecat-shared/issues/76)) ([5b74623](https://github.com/adobe/spacecat-shared/commit/5b74623a4accfb601b607170f9bd67fb380f5c84))
|
|
7
25
|
|
|
8
|
-
# [@adobe/spacecat-shared-data-access-v1.5.1](https://github.com/adobe
|
|
26
|
+
# [@adobe/spacecat-shared-data-access-v1.5.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.5.0...@adobe/spacecat-shared-data-access-v1.5.1) (2023-12-27)
|
|
9
27
|
|
|
10
28
|
|
|
11
29
|
### Bug Fixes
|
|
12
30
|
|
|
13
|
-
* include audit ref and audited at ([#75](https://github.com/adobe
|
|
31
|
+
* include audit ref and audited at ([#75](https://github.com/adobe/spacecat-shared/issues/75)) ([e573c90](https://github.com/adobe/spacecat-shared/commit/e573c903851d88c7293caa5e5a9af763987edb3a))
|
|
14
32
|
|
|
15
|
-
# [@adobe/spacecat-shared-data-access-v1.5.0](https://github.com/adobe
|
|
33
|
+
# [@adobe/spacecat-shared-data-access-v1.5.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.4.4...@adobe/spacecat-shared-data-access-v1.5.0) (2023-12-26)
|
|
16
34
|
|
|
17
35
|
|
|
18
36
|
### Features
|
|
19
37
|
|
|
20
|
-
* store previous latest audit result ([#74](https://github.com/adobe
|
|
38
|
+
* store previous latest audit result ([#74](https://github.com/adobe/spacecat-shared/issues/74)) ([4663c43](https://github.com/adobe/spacecat-shared/commit/4663c4344e260f85c4e64691e0685260d36629e5))
|
|
21
39
|
|
|
22
|
-
# [@adobe/spacecat-shared-data-access-v1.4.4](https://github.com/adobe
|
|
40
|
+
# [@adobe/spacecat-shared-data-access-v1.4.4](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.4.3...@adobe/spacecat-shared-data-access-v1.4.4) (2023-12-25)
|
|
23
41
|
|
|
24
42
|
|
|
25
43
|
### Bug Fixes
|
|
26
44
|
|
|
27
|
-
* add missing pattern to interface ([#72](https://github.com/adobe
|
|
45
|
+
* add missing pattern to interface ([#72](https://github.com/adobe/spacecat-shared/issues/72)) ([0eacbff](https://github.com/adobe/spacecat-shared/commit/0eacbff39dbc12d604e40ae94285533f7804ca0a))
|
|
28
46
|
|
|
29
|
-
# [@adobe/spacecat-shared-data-access-v1.4.3](https://github.com/adobe
|
|
47
|
+
# [@adobe/spacecat-shared-data-access-v1.4.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.4.2...@adobe/spacecat-shared-data-access-v1.4.3) (2023-12-23)
|
|
30
48
|
|
|
31
49
|
|
|
32
50
|
### Bug Fixes
|
|
33
51
|
|
|
34
|
-
* **deps:** update external fixes ([#71](https://github.com/adobe
|
|
52
|
+
* **deps:** update external fixes ([#71](https://github.com/adobe/spacecat-shared/issues/71)) ([b9a6679](https://github.com/adobe/spacecat-shared/commit/b9a667966e7b0f013f46c62f6cc4a85f80623c61))
|
|
35
53
|
|
|
36
|
-
# [@adobe/spacecat-shared-data-access-v1.4.2](https://github.com/adobe
|
|
54
|
+
# [@adobe/spacecat-shared-data-access-v1.4.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.4.1...@adobe/spacecat-shared-data-access-v1.4.2) (2023-12-20)
|
|
37
55
|
|
|
38
56
|
|
|
39
57
|
### Bug Fixes
|
|
40
58
|
|
|
41
|
-
* **deps:** update aws-sdk-js-v3 monorepo to v3.477.0 ([#68](https://github.com/adobe
|
|
59
|
+
* **deps:** update aws-sdk-js-v3 monorepo to v3.477.0 ([#68](https://github.com/adobe/spacecat-shared/issues/68)) ([492913f](https://github.com/adobe/spacecat-shared/commit/492913f0011d557b7c91ba631c13ced171bc2ce9))
|
|
42
60
|
|
|
43
|
-
# [@adobe/spacecat-shared-data-access-v1.4.1](https://github.com/adobe
|
|
61
|
+
# [@adobe/spacecat-shared-data-access-v1.4.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.4.0...@adobe/spacecat-shared-data-access-v1.4.1) (2023-12-18)
|
|
44
62
|
|
|
45
63
|
|
|
46
64
|
### Bug Fixes
|
|
47
65
|
|
|
48
|
-
* update dynamo client ([#65](https://github.com/adobe
|
|
66
|
+
* update dynamo client ([#65](https://github.com/adobe/spacecat-shared/issues/65)) ([cc09041](https://github.com/adobe/spacecat-shared/commit/cc09041200dfe23c0a83c384fc9695ac972564e9))
|
|
49
67
|
|
|
50
|
-
# [@adobe/spacecat-shared-data-access-v1.4.0](https://github.com/adobe
|
|
68
|
+
# [@adobe/spacecat-shared-data-access-v1.4.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.3.2...@adobe/spacecat-shared-data-access-v1.4.0) (2023-12-16)
|
|
51
69
|
|
|
52
70
|
|
|
53
71
|
### Features
|
|
54
72
|
|
|
55
|
-
* update audit config ([#63](https://github.com/adobe
|
|
73
|
+
* update audit config ([#63](https://github.com/adobe/spacecat-shared/issues/63)) ([00a468e](https://github.com/adobe-rnd/spacecat-shared/commit/00a468e9404676212ec9441c8a7fccf1a93c636f))
|
|
56
74
|
|
|
57
75
|
# [@adobe/spacecat-shared-data-access-v1.3.2](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.3.1...@adobe/spacecat-shared-data-access-v1.3.2) (2023-12-16)
|
|
58
76
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Adobe Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at Grp-opensourceoffice@adobe.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributing to Project Franklin
|
|
2
|
+
|
|
3
|
+
This project (like almost all of Project Franklin) is an Open Development project and welcomes contributions from everyone who finds it useful or lacking.
|
|
4
|
+
|
|
5
|
+
## Code Of Conduct
|
|
6
|
+
|
|
7
|
+
This project adheres to the Adobe [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to cstaub at adobe dot com.
|
|
8
|
+
|
|
9
|
+
## Contributor License Agreement
|
|
10
|
+
|
|
11
|
+
All third-party contributions to this project must be accompanied by a signed contributor license. This gives Adobe permission to redistribute your contributions as part of the project. [Sign our CLA](http://opensource.adobe.com/cla.html)! You only need to submit an Adobe CLA one time, so if you have submitted one previously, you are good to go!
|
|
12
|
+
|
|
13
|
+
## Things to Keep in Mind
|
|
14
|
+
|
|
15
|
+
This project uses a **commit then review** process, which means that for approved maintainers, changes can be merged immediately, but will be reviewed by others.
|
|
16
|
+
|
|
17
|
+
For other contributors, a maintainer of the project has to approve the pull request.
|
|
18
|
+
|
|
19
|
+
# Before You Contribute
|
|
20
|
+
|
|
21
|
+
* Check that there is an existing issue in GitHub issues
|
|
22
|
+
* Check if there are other pull requests that might overlap or conflict with your intended contribution
|
|
23
|
+
|
|
24
|
+
# How to Contribute
|
|
25
|
+
|
|
26
|
+
1. Fork the repository
|
|
27
|
+
2. Make some changes on a branch on your fork
|
|
28
|
+
3. Create a pull request from your branch
|
|
29
|
+
|
|
30
|
+
In your pull request, outline:
|
|
31
|
+
|
|
32
|
+
* What the changes intend
|
|
33
|
+
* How they change the existing code
|
|
34
|
+
* If (and what) they breaks
|
|
35
|
+
* Start the pull request with the GitHub issue ID, e.g. #123
|
|
36
|
+
|
|
37
|
+
Lastly, please follow the [pull request template](.github/pull_request_template.md) when submitting a pull request!
|
|
38
|
+
|
|
39
|
+
Each commit message that is not part of a pull request:
|
|
40
|
+
|
|
41
|
+
* Should contain the issue ID like `#123`
|
|
42
|
+
* Can contain the tag `[trivial]` for trivial changes that don't relate to an issue
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Coding Styleguides
|
|
47
|
+
|
|
48
|
+
We enforce a coding styleguide using `eslint`. As part of your build, run `npm run lint` to check if your code is conforming to the style guide. We do the same for every PR in our CI, so PRs will get rejected if they don't follow the style guide.
|
|
49
|
+
|
|
50
|
+
You can fix some of the issues automatically by running `npx eslint . --fix`.
|
|
51
|
+
|
|
52
|
+
## Commit Message Format
|
|
53
|
+
|
|
54
|
+
This project uses a structured commit changelog format that should be used for every commit. Use `npm run commit` instead of your usual `git commit` to generate commit messages using a wizard.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# either add all changed files
|
|
58
|
+
$ git add -A
|
|
59
|
+
# or selectively add files
|
|
60
|
+
$ git add package.json
|
|
61
|
+
# then commit using the wizard
|
|
62
|
+
$ npm run commit
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
# How Contributions get Reviewed
|
|
66
|
+
|
|
67
|
+
One of the maintainers will look at the pull request within one week. Feedback on the pull request will be given in writing, in GitHub.
|
|
68
|
+
|
|
69
|
+
# Release Management
|
|
70
|
+
|
|
71
|
+
The project's committers will release to the [Adobe organization on npmjs.org](https://www.npmjs.com/org/adobe).
|
|
72
|
+
Please contact the [Adobe Open Source Advisory Board](https://git.corp.adobe.com/OpenSourceAdvisoryBoard/discuss/issues) to get access to the npmjs organization.
|
|
73
|
+
|
|
74
|
+
The release process is fully automated using `semantic-release`, increasing the version numbers, etc. based on the contents of the commit messages found.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-data-access",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Data Access",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/adobe
|
|
20
|
+
"url": "https://github.com/adobe/spacecat-shared.git"
|
|
21
21
|
},
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"bugs": {
|
|
25
|
-
"url": "https://github.com/adobe
|
|
25
|
+
"url": "https://github.com/adobe/spacecat-shared/issues"
|
|
26
26
|
},
|
|
27
|
-
"homepage": "https://github.com/adobe
|
|
27
|
+
"homepage": "https://github.com/adobe/spacecat-shared#readme",
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
package/src/dto/site.js
CHANGED
|
@@ -25,6 +25,7 @@ export const SiteDto = {
|
|
|
25
25
|
toDynamoItem: (site) => ({
|
|
26
26
|
id: site.getId(),
|
|
27
27
|
baseURL: site.getBaseURL(),
|
|
28
|
+
deliveryType: site.getDeliveryType(),
|
|
28
29
|
gitHubURL: site.getGitHubURL() || '',
|
|
29
30
|
imsOrgId: site.getImsOrgId() || '',
|
|
30
31
|
isLive: site.isLive(),
|
|
@@ -43,6 +44,7 @@ export const SiteDto = {
|
|
|
43
44
|
const siteData = {
|
|
44
45
|
id: dynamoItem.id,
|
|
45
46
|
baseURL: dynamoItem.baseURL,
|
|
47
|
+
deliveryType: dynamoItem.deliveryType,
|
|
46
48
|
gitHubURL: dynamoItem.gitHubURL,
|
|
47
49
|
imsOrgId: dynamoItem.imsOrgId,
|
|
48
50
|
isLive: dynamoItem.isLive,
|
package/src/index.d.ts
CHANGED
|
@@ -41,10 +41,10 @@ export interface Audit {
|
|
|
41
41
|
*/
|
|
42
42
|
getPreviousAuditResult: () => object | null;
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Sets the result of the previous audit.
|
|
46
|
+
* @param {object} result The parsed audit result.
|
|
47
|
+
*/
|
|
48
48
|
setPreviousAuditResult: (result: object) => void;
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -137,6 +137,12 @@ export interface Site {
|
|
|
137
137
|
*/
|
|
138
138
|
getBaseURL: () => string;
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves the delivery type of the site.
|
|
142
|
+
* @returns {string} The delivery type.
|
|
143
|
+
*/
|
|
144
|
+
getDeliveryType: () => string;
|
|
145
|
+
|
|
140
146
|
/**
|
|
141
147
|
* Retrieves the GitHub URL associated with the site.
|
|
142
148
|
* @returns {string} The GitHub URL.
|
|
@@ -236,6 +242,7 @@ export interface DataAccess {
|
|
|
236
242
|
siteId: string,
|
|
237
243
|
) => Promise<void>;
|
|
238
244
|
getSites: () => Promise<Site[]>;
|
|
245
|
+
getSitesByDeliveryType: () => Promise<Site[]>;
|
|
239
246
|
getSitesToAudit: () => Promise<string[]>;
|
|
240
247
|
getSitesWithLatestAudit: (
|
|
241
248
|
auditType: string,
|
|
@@ -276,6 +283,7 @@ interface DataAccessConfig {
|
|
|
276
283
|
tableNameLatestAudits: string;
|
|
277
284
|
tableNameSites: string;
|
|
278
285
|
indexNameAllSites: string;
|
|
286
|
+
indexNameAllSitesByDeliveryType: string;
|
|
279
287
|
indexNameAllLatestAuditScores: string;
|
|
280
288
|
pkAllSites: string;
|
|
281
289
|
pkAllLatestAudits: string;
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const TABLE_NAME_LATEST_AUDITS = 'spacecat-services-latest-audits-dev';
|
|
|
17
17
|
const TABLE_NAME_SITES = 'spacecat-services-sites-dev';
|
|
18
18
|
|
|
19
19
|
const INDEX_NAME_ALL_SITES = 'spacecat-services-all-sites-dev';
|
|
20
|
+
const INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = 'spacecat-services-all-sites-by-delivery-type-dev';
|
|
20
21
|
const INDEX_NAME_ALL_LATEST_AUDIT_SCORES = 'spacecat-services-all-latest-audit-scores-dev';
|
|
21
22
|
|
|
22
23
|
const PK_ALL_SITES = 'ALL_SITES';
|
|
@@ -32,6 +33,7 @@ export default function dataAccessWrapper(fn) {
|
|
|
32
33
|
DYNAMO_TABLE_NAME_LATEST_AUDITS = TABLE_NAME_LATEST_AUDITS,
|
|
33
34
|
DYNAMO_TABLE_NAME_SITES = TABLE_NAME_SITES,
|
|
34
35
|
DYNAMO_INDEX_NAME_ALL_SITES = INDEX_NAME_ALL_SITES,
|
|
36
|
+
DYNAMO_INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE,
|
|
35
37
|
DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES = INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
|
|
36
38
|
} = context.env;
|
|
37
39
|
|
|
@@ -40,6 +42,7 @@ export default function dataAccessWrapper(fn) {
|
|
|
40
42
|
tableNameLatestAudits: DYNAMO_TABLE_NAME_LATEST_AUDITS,
|
|
41
43
|
tableNameSites: DYNAMO_TABLE_NAME_SITES,
|
|
42
44
|
indexNameAllSites: DYNAMO_INDEX_NAME_ALL_SITES,
|
|
45
|
+
indexNameAllSitesByDeliveryType: DYNAMO_INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE,
|
|
43
46
|
indexNameAllLatestAuditScores: DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
|
|
44
47
|
pkAllSites: PK_ALL_SITES,
|
|
45
48
|
pkAllLatestAudits: PK_ALL_LATEST_AUDITS,
|
package/src/models/site.js
CHANGED
|
@@ -15,6 +15,14 @@ import { hasText, isObject, isValidUrl } from '@adobe/spacecat-shared-utils';
|
|
|
15
15
|
import { Base } from './base.js';
|
|
16
16
|
import AuditConfig from './site/audit-config.js';
|
|
17
17
|
|
|
18
|
+
export const DELIVERY_TYPES = {
|
|
19
|
+
AEM_CS: 'aem_cs',
|
|
20
|
+
AEM_EDGE: 'aem_edge',
|
|
21
|
+
OTHER: 'other',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const DEFAULT_DELIVERY_TYPE = DELIVERY_TYPES.AEM_EDGE;
|
|
25
|
+
|
|
18
26
|
/**
|
|
19
27
|
* Creates a new Site.
|
|
20
28
|
*
|
|
@@ -27,6 +35,7 @@ const Site = (data = {}) => {
|
|
|
27
35
|
self.getAuditConfig = () => self.state.auditConfig;
|
|
28
36
|
self.getAudits = () => self.state.audits;
|
|
29
37
|
self.getBaseURL = () => self.state.baseURL;
|
|
38
|
+
self.getDeliveryType = () => self.state.deliveryType;
|
|
30
39
|
self.getGitHubURL = () => self.state.gitHubURL;
|
|
31
40
|
self.getImsOrgId = () => self.state.imsOrgId;
|
|
32
41
|
self.isLive = () => self.state.isLive;
|
|
@@ -80,6 +89,17 @@ const Site = (data = {}) => {
|
|
|
80
89
|
return self;
|
|
81
90
|
};
|
|
82
91
|
|
|
92
|
+
self.updateDeliveryType = (deliveryType) => {
|
|
93
|
+
if (!Object.values(DELIVERY_TYPES).includes(deliveryType)) {
|
|
94
|
+
throw new Error(`Invalid delivery type: ${deliveryType}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
self.state.deliveryType = deliveryType;
|
|
98
|
+
self.touch();
|
|
99
|
+
|
|
100
|
+
return self;
|
|
101
|
+
};
|
|
102
|
+
|
|
83
103
|
/**
|
|
84
104
|
* Updates the GitHub URL belonging to the site.
|
|
85
105
|
* @param {string} gitHubURL - The GitHub URL.
|
|
@@ -142,6 +162,11 @@ export const createSite = (data) => {
|
|
|
142
162
|
throw new Error('Base URL must be a valid URL');
|
|
143
163
|
}
|
|
144
164
|
|
|
165
|
+
newState.deliveryType = newState.deliveryType || DEFAULT_DELIVERY_TYPE;
|
|
166
|
+
if (!Object.values(DELIVERY_TYPES).includes(newState.deliveryType)) {
|
|
167
|
+
throw new Error(`Invalid delivery type: ${newState.deliveryType}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
145
170
|
if (!Object.prototype.hasOwnProperty.call(newState, 'isLive')) {
|
|
146
171
|
newState.isLive = false;
|
|
147
172
|
}
|
|
@@ -41,6 +41,28 @@ export const getSites = async (dynamoClient, config) => {
|
|
|
41
41
|
return dynamoItems.map((dynamoItem) => SiteDto.fromDynamoItem(dynamoItem));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves all sites of a specific delivery type.
|
|
46
|
+
* @param {DynamoDbClient} dynamoClient - The DynamoDB client.
|
|
47
|
+
* @param {DataAccessConfig} config - The data access config.
|
|
48
|
+
* @param {string} deliveryType - The delivery type.
|
|
49
|
+
* @return {Promise<Readonly<Site>[]>} A promise that resolves to an array of all sites of the
|
|
50
|
+
* specified delivery type.
|
|
51
|
+
*/
|
|
52
|
+
export const getSitesByDeliveryType = async (dynamoClient, config, deliveryType) => {
|
|
53
|
+
const dynamoItems = await dynamoClient.query({
|
|
54
|
+
TableName: config.tableNameSites,
|
|
55
|
+
IndexName: config.indexNameAllSitesByDeliveryType,
|
|
56
|
+
KeyConditionExpression: 'GSI1PK = :gsi1pk AND deliveryType = :deliveryType',
|
|
57
|
+
ExpressionAttributeValues: {
|
|
58
|
+
':gsi1pk': config.pkAllSites,
|
|
59
|
+
':deliveryType': deliveryType,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return dynamoItems.map((dynamoItem) => SiteDto.fromDynamoItem(dynamoItem));
|
|
64
|
+
};
|
|
65
|
+
|
|
44
66
|
/**
|
|
45
67
|
* Retrieves a list of site IDs of all sites.
|
|
46
68
|
*
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
getSiteByBaseURLWithAudits,
|
|
18
18
|
getSiteByBaseURLWithLatestAudit,
|
|
19
19
|
getSiteByID,
|
|
20
|
-
getSites,
|
|
20
|
+
getSites, getSitesByDeliveryType,
|
|
21
21
|
getSitesToAudit,
|
|
22
22
|
getSitesWithLatestAudit, removeSite,
|
|
23
23
|
updateSite,
|
|
@@ -28,6 +28,11 @@ export const siteFunctions = (dynamoClient, config, log) => ({
|
|
|
28
28
|
dynamoClient,
|
|
29
29
|
config,
|
|
30
30
|
),
|
|
31
|
+
getSitesByDeliveryType: (deliveryType) => getSitesByDeliveryType(
|
|
32
|
+
dynamoClient,
|
|
33
|
+
config,
|
|
34
|
+
deliveryType,
|
|
35
|
+
),
|
|
31
36
|
getSitesToAudit: () => getSitesToAudit(
|
|
32
37
|
dynamoClient,
|
|
33
38
|
config,
|