Skip to content

Commit

Permalink
Merge branch 'main' into blefebvr/scoped-api-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
blefebvre authored Aug 21, 2024
2 parents 6e51aac + e1ff12a commit 6ed6df0
Show file tree
Hide file tree
Showing 34 changed files with 195 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- name: Use Node.js 20.x
- name: Use Node.js 20.16.0 (LTS)
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '20.16.0'
- name: Install Dependencies
run: npm ci
- name: Linting
Expand Down Expand Up @@ -47,10 +47,10 @@ jobs:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js 20.x
- name: Use Node.js 20.16.0 (LTS)
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '20.16.0'
- run: npm ci
- name: Semantic Release
run: npm run semantic-release
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
56 changes: 52 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"version": "0.0.0-semantic-release",
"description": "Shared modules of the Spacecat Services - monorepo",
"type": "module",
"engines": {
"node": "^20.0.0 <21.0.0",
"npm": "^10.0.0 <11.0.0"
},
"scripts": {
"docs:api": "jsdoc2md -c .jsdoc.json --files packages/*/src/*.js > docs/API.md",
"docs": "npm run docs:api",
Expand Down
1 change: 1 addition & 0 deletions packages/spacecat-shared-ahrefs-client/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions packages/spacecat-shared-ahrefs-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "1.5.0",
"description": "Shared modules of the Spacecat Services - Ahrefs Client",
"type": "module",
"engines": {
"node": "^20.0.0 <21.0.0",
"npm": "^10.0.0 <11.0.0"
},
"main": "src/index.js",
"types": "src/index.d.ts",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/spacecat-shared-data-access/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
7 changes: 7 additions & 0 deletions packages/spacecat-shared-data-access/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@adobe/spacecat-shared-data-access-v1.43.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.42.0...@adobe/spacecat-shared-data-access-v1.43.0) (2024-08-21)


### Features

* add initiatedBy attribute to import job ([#341](https://github.com/adobe/spacecat-shared/issues/341)) ([8a7634c](https://github.com/adobe/spacecat-shared/commit/8a7634c68cf0df01a71abc5d99a17519869f3c45))

# [@adobe/spacecat-shared-data-access-v1.42.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.41.8...@adobe/spacecat-shared-data-access-v1.42.0) (2024-08-20)


Expand Down
4 changes: 4 additions & 0 deletions packages/spacecat-shared-data-access/docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,10 @@
{
"AttributeName": "urlCount",
"AttributeType": "N"
},
{
"AttributeName": "initiatedBy",
"AttributeType": "M"
}
],
"GlobalSecondaryIndexes": [
Expand Down
6 changes: 5 additions & 1 deletion packages/spacecat-shared-data-access/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "@adobe/spacecat-shared-data-access",
"version": "1.42.0",
"version": "1.43.0",
"description": "Shared modules of the Spacecat Services - Data Access",
"type": "module",
"engines": {
"node": "^20.0.0 <21.0.0",
"npm": "^10.0.0 <11.0.0"
},
"main": "src/index.js",
"types": "src/index.d.ts",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions packages/spacecat-shared-data-access/src/dto/import-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const ImportJobDto = {
successCount: importJob.getSuccessCount(),
failedCount: importJob.getFailedCount(),
importQueueId: importJob.getImportQueueId(),
initiatedBy: importJob.getInitiatedBy(),
GSI1PK: 'ALL_IMPORT_JOBS',
}),

Expand All @@ -58,6 +59,7 @@ export const ImportJobDto = {
successCount: dynamoItem.successCount,
failedCount: dynamoItem.failedCount,
importQueueId: dynamoItem.importQueueId,
initiatedBy: dynamoItem.initiatedBy,
};

return createImportJob(importJobData);
Expand Down
5 changes: 5 additions & 0 deletions packages/spacecat-shared-data-access/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ export interface ImportJob {
*/
getImportQueueId: () => string;

/**
* Retrieves the initiatedBy metadata (name, imsOrgId, imsUserId, userAgent) of the import job.
*/
getInitiatedBy: () => object;

}

export interface ImportUrl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ImportJob = (data) => {
self.getSuccessCount = () => self.state.successCount;
self.getFailedCount = () => self.state.failedCount;
self.getImportQueueId = () => self.state.importQueueId;
self.getInitiatedBy = () => self.state.initiatedBy;

/**
* Updates the end time of the ImportJob.
Expand Down
16 changes: 4 additions & 12 deletions packages/spacecat-shared-data-access/test/it/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('DynamoDB Integration Test', async () => {
sharedDb: true,
});

await sleep(5000); // give db time to start up
await sleep(10000); // give db time to start up

try {
await generateSampleData(
Expand All @@ -169,24 +169,16 @@ describe('DynamoDB Integration Test', async () => {
});

it('get all key events for a site', async () => {
const siteId = (await dataAccess.getSites())[0].getId();
const siteId = (await dataAccess.getSiteByBaseURL('https://example0.com')).getId();

const keyEvents = await dataAccess.getKeyEventsForSite(siteId);

expect(keyEvents.length).to.equal(NUMBER_OF_KEY_EVENTS_PER_SITE);
expect(keyEvents[0].getSiteId()).to.equal(siteId);

// check if the key events are returned in descending order
for (let i = 1; i < keyEvents.length; i += 1) {
const prev = keyEvents[i - 1];
const next = keyEvents[i];
const desc = prev.getCreatedAt() >= next.getCreatedAt();
expect(desc).to.be.true;
}
});

it('add a new key event for a site', async () => {
const siteId = (await dataAccess.getSites())[0].getId();
const siteId = (await dataAccess.getSiteByBaseURL('https://example0.com')).getId();

await dataAccess.createKeyEvent({
siteId,
Expand All @@ -200,7 +192,7 @@ describe('DynamoDB Integration Test', async () => {
});

it('remove a key event', async () => {
const siteId = (await dataAccess.getSites())[0].getId();
const siteId = (await dataAccess.getSiteByBaseURL('https://example0.com')).getId();
const keyEvents = await dataAccess.getKeyEventsForSite(siteId);

await dataAccess.removeKeyEvent(keyEvents[0].getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const validImportJob = {
enableJavascript: true,
enableCss: true,
},
initiatedBy: {
apiKeyName: 'test',
},
};
describe('ImportJob Model tests', () => {
describe('Validation Tests', () => {
Expand All @@ -50,7 +53,7 @@ describe('ImportJob Model tests', () => {

it('creates an import job object with a startTime', () => {
const importJob = createImportJob({ ...validImportJob, startTime: '' });
expect(importJob.getStartTime()).is.not.empty;
expect(importJob.getStartTime()).to.match(/^20/);
});
});

Expand Down
Loading

0 comments on commit 6ed6df0

Please sign in to comment.