Skip to content

Commit

Permalink
feat: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea committed Feb 15, 2024
2 parents fcccb84 + 607ac36 commit b461acf
Show file tree
Hide file tree
Showing 41 changed files with 11,982 additions and 3,632 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ jobs:
node-version: '20.x'
- name: Install Dependencies
run: npm ci
- name: publish
run: |
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm publish -w packages/spacecat-shared-data-access
env:
GITHUB_TOKEN: ${{ secrets.ADOBE_BOT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
- name: Linting
run: npm run lint
- name: Unit Tests
Expand Down
14,516 changes: 11,054 additions & 3,462 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/npm": "11.0.2",
"@typescript-eslint/eslint-plugin": "6.20.0",
"@typescript-eslint/parser": "6.20.0",
"@typescript-eslint/eslint-plugin": "7.0.1",
"@typescript-eslint/parser": "7.0.1",
"ajv": "8.12.0",
"c8": "9.1.0",
"eslint": "8.56.0",
"husky": "9.0.10",
"jsdoc-to-markdown": "8.0.1",
"lint-staged": "15.2.1",
"mocha": "10.2.0",
"lint-staged": "15.2.2",
"mocha": "10.3.0",
"mocha-multi-reporters": "1.5.1",
"nock": "13.5.1",
"semantic-release": "23.0.0",
"semantic-release-monorepo": "8.0.1",
"semantic-release": "23.0.2",
"semantic-release-monorepo": "8.0.2",
"typescript": "5.3.3"
},
"lint-staged": {
Expand Down
42 changes: 42 additions & 0 deletions packages/spacecat-shared-data-access/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# [@adobe/spacecat-shared-data-access-v1.17.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.16.0...@adobe/spacecat-shared-data-access-v1.17.0) (2024-02-14)


### Features

* get organization by IMS org ID ([#153](https://github.com/adobe/spacecat-shared/issues/153)) ([541e7e7](https://github.com/adobe/spacecat-shared/commit/541e7e721cb21e977b59b19cf53dfb7ba460905f))

# [@adobe/spacecat-shared-data-access-v1.16.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.15.6...@adobe/spacecat-shared-data-access-v1.16.0) (2024-02-14)


### Features

* add configurations data access ([65bdc25](https://github.com/adobe/spacecat-shared/commit/65bdc2581e150cb32eb51d4d2bf03c8172ec2247))

# [@adobe/spacecat-shared-data-access-v1.15.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.15.5...@adobe/spacecat-shared-data-access-v1.15.6) (2024-02-12)


### Bug Fixes

* return empty sites for getSitesByOrganizationIDWithLatestAudit ([1caaa39](https://github.com/adobe/spacecat-shared/commit/1caaa39f20d2c73b9a195d43c57d320fb009fba7))

# [@adobe/spacecat-shared-data-access-v1.15.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.15.4...@adobe/spacecat-shared-data-access-v1.15.5) (2024-02-12)


### Bug Fixes

* **deps:** update external fixes ([#148](https://github.com/adobe/spacecat-shared/issues/148)) ([a32b5ce](https://github.com/adobe/spacecat-shared/commit/a32b5ce7c57e06d9b27250a8e59b666198945f72))

# [@adobe/spacecat-shared-data-access-v1.15.4](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.15.3...@adobe/spacecat-shared-data-access-v1.15.4) (2024-02-09)


### Bug Fixes

* add experimentation type audit ([#147](https://github.com/adobe/spacecat-shared/issues/147)) ([221fa29](https://github.com/adobe/spacecat-shared/commit/221fa296799a9004c991a9f3656e735d4babd612))

# [@adobe/spacecat-shared-data-access-v1.15.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.15.2...@adobe/spacecat-shared-data-access-v1.15.3) (2024-02-08)


### Bug Fixes

* site-candidate should not have id ([#144](https://github.com/adobe/spacecat-shared/issues/144)) ([9d0ebe8](https://github.com/adobe/spacecat-shared/commit/9d0ebe85c993ea428a845ce417b1e9c727b13b52))

# [@adobe/spacecat-shared-data-access-v1.15.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.15.1...@adobe/spacecat-shared-data-access-v1.15.2) (2024-02-07)


Expand Down
74 changes: 74 additions & 0 deletions packages/spacecat-shared-data-access/docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@
"AttributeName": "name",
"AttributeType": "S"
},
{
"AttributeName": "imsOrgId",
"AttributeType": "S"
},
{
"AttributeName": "GSI1PK",
"AttributeType": "S"
Expand Down Expand Up @@ -200,6 +204,18 @@
"Projection": {
"ProjectionType": "ALL"
}
},
{
"IndexName": "spacecat-services-all-organizations-by-ims-org-id",
"KeyAttributes": {
"PartitionKey": {
"AttributeName": "imsOrgId",
"AttributeType": "S"
}
},
"Projection": {
"ProjectionType": "ALL"
}
}
],
"DataAccess": {
Expand Down Expand Up @@ -525,6 +541,64 @@
}
}
}
},
{
"TableName": "spacecat-services-configurations",
"KeyAttributes": {
"PartitionKey": {
"AttributeName": "PK",
"AttributeType": "S"
},
"SortKey": {
"AttributeName": "version",
"AttributeType": "S"
}
},
"NonKeyAttributes": [
{
"AttributeName": "queues",
"AttributeType": "M"
},
{
"AttributeName": "jobs",
"AttributeType": "L"
}
],
"DataAccess": {
"MySql": {}
},
"SampleDataFormats": {
"version": [
"identifiers"
]
},
"BillingMode": "PROVISIONED",
"ProvisionedCapacitySettings": {
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"AutoScalingRead": {
"ScalableTargetRequest": {
"MinCapacity": 1,
"MaxCapacity": 10,
"ServiceRole": "AWSServiceRoleForApplicationAutoScaling_DynamoDBTable"
},
"ScalingPolicyConfiguration": {
"TargetValue": 70
}
},
"AutoScalingWrite": {
"ScalableTargetRequest": {
"MinCapacity": 1,
"MaxCapacity": 10,
"ServiceRole": "AWSServiceRoleForApplicationAutoScaling_DynamoDBTable"
},
"ScalingPolicyConfiguration": {
"TargetValue": 70
}
}
}
}
]
}
6 changes: 3 additions & 3 deletions packages/spacecat-shared-data-access/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/spacecat-shared-data-access",
"version": "1.15.2-test",
"version": "1.17.0",
"description": "Shared modules of the Spacecat Services - Data Access",
"type": "module",
"main": "src/index.js",
Expand Down Expand Up @@ -31,8 +31,8 @@
"dependencies": {
"@adobe/spacecat-shared-dynamo": "1.2.5",
"@adobe/spacecat-shared-utils": "1.2.0",
"@aws-sdk/client-dynamodb": "3.506.0",
"@aws-sdk/lib-dynamodb": "3.506.0",
"@aws-sdk/client-dynamodb": "3.511.0",
"@aws-sdk/lib-dynamodb": "3.511.0",
"@types/joi": "17.2.3",
"joi": "17.12.1",
"uuid": "9.0.1"
Expand Down
33 changes: 33 additions & 0 deletions packages/spacecat-shared-data-access/src/dto/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import { createConfiguration } from '../models/configuration.js';

/**
* Data transfer object for Configuration.
*/
export const ConfigurationDto = {
/**
* Converts a DynamoDB item into a Configuration object.
* @param {object } dynamoItem - DynamoDB item.
* @returns {Readonly<Configuration>} Configuration object.
*/
fromDynamoItem: (dynamoItem) => {
const configurationData = {
version: dynamoItem.version,
queues: dynamoItem.queues,
jobs: dynamoItem.jobs,
};

return createConfiguration(configurationData);
},
};
31 changes: 31 additions & 0 deletions packages/spacecat-shared-data-access/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ export interface Organization {
getConfig: () => Config;
}

export interface Configuration {
/**
* Retrieves the configuration version.
* @returns {string} The configuration version.
*/
getVersion: () => string;

/**
* Retrieves the queues configuration.
* @returns {object} The queues configuration.
*/
getQueues: () => object;

/**
* Retrieves the jobs configuration.
* @returns {Array} The jobs configurations.
*/
getJobs: () => Array<object>;

}

export interface DataAccess {
getAuditForSite: (
sitedId: string,
Expand Down Expand Up @@ -392,6 +413,9 @@ export interface DataAccess {
getOrganizationByID: (
organizationID: string,
) => Promise<Organization | null>;
getOrganizationByImsOrgID: (
imsOrgID: string,
) => Promise<Organization | null>;
addOrganization: (
organizationData: object,
) => Promise<Organization>;
Expand All @@ -407,6 +431,10 @@ export interface DataAccess {
upsertSiteCandidate: (siteCandidateDate: object) => Promise<SiteCandidate>;
siteCandidateExists: (baseURL: string) => Promise<boolean>;
updateSiteCandidate: (siteCandidate: SiteCandidate) => Promise<SiteCandidate>;

// configuration functions
getConfiguration: () => Promise<Configuration>
getConfigurationByVersion: (version: string) => Promise<Configuration>
}

interface DataAccessConfig {
Expand All @@ -415,14 +443,17 @@ interface DataAccessConfig {
tableNameOrganizations: string,
tableNameSites: string;
tableNameSiteCandidates: string;
tableNameConfigurations: string;
indexNameAllSites: string;
indexNameAllSitesOrganizations: string,
indexNameAllSitesByDeliveryType: string;
indexNameAllLatestAuditScores: string;
indexNameAllOrganizations: string,
indexNameAllOrganizationsByImsOrgId: string,
pkAllSites: string;
pkAllLatestAudits: string;
pkAllOrganizations: string;
pkAllConfigurations: string;
}

export function createDataAccess(
Expand Down
9 changes: 9 additions & 0 deletions packages/spacecat-shared-data-access/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ const TABLE_NAME_LATEST_AUDITS = 'spacecat-services-latest-audits-dev';
const TABLE_NAME_SITES = 'spacecat-services-sites-dev';
const TABLE_NAME_SITE_CANDIDATES = 'spacecat-services-site-candidates-dev';
const TABLE_NAME_ORGANIZATIONS = 'spacecat-services-organizations-dev';
const TABLE_NAME_CONFIGURATIONS = 'spacecat-services-configurations-dev';

const INDEX_NAME_ALL_SITES = 'spacecat-services-all-sites-dev';
const INDEX_NAME_ALL_ORGANIZATIONS = 'spacecat-services-all-organizations-dev';
const INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID = 'spacecat-services-all-organizations-by-ims-org-id-dev';
const INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = 'spacecat-services-all-sites-by-delivery-type-dev';
const INDEX_NAME_ALL_LATEST_AUDIT_SCORES = 'spacecat-services-all-latest-audit-scores-dev';
const INDEX_NAME_ALL_SITES_ORGANIZATIONS = 'spacecat-services-all-sites-organizations-dev';

const PK_ALL_SITES = 'ALL_SITES';
const PK_ALL_CONFIGURATIONS = 'ALL_CONFIGURATIONS';
const PK_ALL_ORGANIZATIONS = 'ALL_ORGANIZATIONS';
const PK_ALL_LATEST_AUDITS = 'ALL_LATEST_AUDITS';

Expand All @@ -39,10 +42,13 @@ export default function dataAccessWrapper(fn) {
DYNAMO_TABLE_NAME_SITES = TABLE_NAME_SITES,
DYNAMO_TABLE_NAME_SITE_CANDIDATES = TABLE_NAME_SITE_CANDIDATES,
DYNAMO_TABLE_NAME_ORGANIZATIONS = TABLE_NAME_ORGANIZATIONS,
DYNAMO_TABLE_NAME_CONFIGURATIONS = TABLE_NAME_CONFIGURATIONS,
DYNAMO_INDEX_NAME_ALL_SITES = INDEX_NAME_ALL_SITES,
DYNAMO_INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE = INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE,
DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES = INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS = INDEX_NAME_ALL_ORGANIZATIONS,
// eslint-disable-next-line max-len
DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID = INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID,
DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS = INDEX_NAME_ALL_SITES_ORGANIZATIONS,
} = context.env;

Expand All @@ -52,14 +58,17 @@ export default function dataAccessWrapper(fn) {
tableNameOrganizations: DYNAMO_TABLE_NAME_ORGANIZATIONS,
tableNameSites: DYNAMO_TABLE_NAME_SITES,
tableNameSiteCandidates: DYNAMO_TABLE_NAME_SITE_CANDIDATES,
tableNameConfigurations: DYNAMO_TABLE_NAME_CONFIGURATIONS,
indexNameAllSites: DYNAMO_INDEX_NAME_ALL_SITES,
indexNameAllOrganizations: DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS,
indexNameAllOrganizationsByImsOrgId: DYNAMO_INDEX_NAME_ALL_ORGANIZATIONS_BY_IMS_ORG_ID,
indexNameAllSitesByDeliveryType: DYNAMO_INDEX_NAME_ALL_SITES_BY_DELIVERY_TYPE,
indexNameAllLatestAuditScores: DYNAMO_INDEX_NAME_ALL_LATEST_AUDIT_SCORES,
indexNameAllSitesOrganizations: DYNAMO_INDEX_NAME_ALL_SITES_ORGANIZATIONS,
pkAllSites: PK_ALL_SITES,
pkAllOrganizations: PK_ALL_ORGANIZATIONS,
pkAllLatestAudits: PK_ALL_LATEST_AUDITS,
pkAllConfigurations: PK_ALL_CONFIGURATIONS,
}, log);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/spacecat-shared-data-access/src/models/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Base } from './base.js';

export const AUDIT_TYPE_404 = '404';
export const AUDIT_TYPE_BROKEN_BACKLINKS = 'broken-backlinks';
export const AUDIT_TYPE_EXPERIMENTATION = 'experimentation';
export const AUDIT_TYPE_ORGANIC_KEYWORDS = 'organic-keywords';
export const AUDIT_TYPE_ORGANIC_TRAFFIC = 'organic-traffic';
export const AUDIT_TYPE_CWV = 'cwv';
Expand All @@ -26,6 +27,7 @@ const EXPIRES_IN_DAYS = 30;
const AUDIT_TYPE_PROPERTIES = {
[AUDIT_TYPE_404]: [],
[AUDIT_TYPE_BROKEN_BACKLINKS]: [],
[AUDIT_TYPE_EXPERIMENTATION]: [],
[AUDIT_TYPE_ORGANIC_KEYWORDS]: [],
[AUDIT_TYPE_ORGANIC_TRAFFIC]: [],
[AUDIT_TYPE_CWV]: [],
Expand Down
Loading

0 comments on commit b461acf

Please sign in to comment.