Skip to content

Commit

Permalink
Merge branch 'main' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea authored Oct 2, 2024
2 parents 70d7071 + fd7b6ab commit ac566e8
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 37 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

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

7 changes: 7 additions & 0 deletions packages/spacecat-shared-content-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [@adobe/spacecat-shared-content-client-v1.1.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.1.6...@adobe/spacecat-shared-content-client-v1.1.7) (2024-10-02)


### Bug Fixes

* content client should use the hlxConfig ([8e74827](https://github.com/adobe/spacecat-shared/commit/8e74827613421828eaef29cf1372d329433526cc))

# [@adobe/spacecat-shared-content-client-v1.1.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-content-client-v1.1.5...@adobe/spacecat-shared-content-client-v1.1.6) (2024-10-01)


Expand Down
3 changes: 2 additions & 1 deletion packages/spacecat-shared-content-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/spacecat-shared-content-client",
"version": "1.1.6",
"version": "1.1.7",
"description": "Shared modules of the Spacecat Services - Content Client",
"type": "module",
"engines": {
Expand Down Expand Up @@ -40,6 +40,7 @@
"graph-data-structure": "4.0.0"
},
"devDependencies": {
"@adobe/spacecat-shared-data-access": "1.45.5",
"chai": "5.1.1",
"chai-as-promised": "8.0.0",
"esmock": "2.6.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const validateSite = (site) => {
throw new Error('Site is required');
}

const contentSource = site.getConfig()?.getHlxContentConfig()?.source;
const contentSource = site.getHlxConfig()?.content?.source;
if (!isObject(contentSource)) {
throw new Error('Site must have a valid content source');
}
Expand Down Expand Up @@ -181,7 +181,7 @@ export default class ContentClient {
const { log = console, env } = context;

const config = {};
const contentSourceType = site.getConfig()?.getHlxContentConfig()?.source?.type;
const contentSourceType = site.getHlxConfig()?.content?.source?.type;
const envMapping = SUPPORTED_CONTENT_SOURCES.get(contentSourceType);

if (envMapping) {
Expand All @@ -195,11 +195,11 @@ export default class ContentClient {

constructor(config, site, log) {
validateSite(site);
validateConfiguration(config, site.getConfig()?.getHlxContentConfig()?.source?.type);
validateConfiguration(config, site.getHlxConfig()?.content.source?.type);

this.log = log;
this.config = config;
this.contentSource = site.getConfig()?.getHlxContentConfig()?.source;
this.contentSource = site.getHlxConfig()?.content?.source;
this.site = site;
this.rawClient = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import chaiAsPromised from 'chai-as-promised';
import esmock from 'esmock';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import { createSite } from '@adobe/spacecat-shared-data-access/src/models/site.js';

use(chaiAsPromised);
use(sinonChai);
Expand All @@ -29,15 +30,21 @@ describe('ContentClient', () => {

let ContentClient;

const siteConfigGoogleDrive = {
getId: () => 'test-site',
getConfig: () => ({ getHlxContentConfig: () => ({ source: { type: 'drive.google' } }) }),
};
const siteConfigGoogleDrive = createSite(
{
id: 'test-site',
hlxConfig: { content: { source: { type: 'drive.google' } } },
baseURL: 'https://base.spacecat',
},
);

const siteConfigOneDrive = {
getId: () => 'test-site',
getConfig: () => ({ getHlxContentConfig: () => ({ source: { type: 'onedrive' } }) }),
};
const siteConfigOneDrive = createSite(
{
id: 'test-site',
hlxConfig: { content: { source: { type: 'onedrive' } } },
baseURL: 'https://base.spacecat',
},
);

const sampleMetadata = new Map(
[['title', { value: 'Test Page', type: 'text' }],
Expand Down Expand Up @@ -166,12 +173,12 @@ describe('ContentClient', () => {
});

it('throws an error if site has no content source', () => {
const invalidSite = { getConfig: () => ({ getHlxContentConfig: () => ({ }) }) };
const invalidSite = { getHlxConfig: () => ({ }) };
expect(() => new ContentClient(env, invalidSite, log)).to.throw('Site must have a valid content source');
});

it('throws an error if site\'s content source type is unsupported', () => {
const invalidSite = { getConfig: () => ({ getHlxContentConfig: () => ({ source: {} }) }) };
const invalidSite = { getHlxConfig: () => ({ content: { source: {} } }) };
expect(() => new ContentClient(env, invalidSite, log)).to.throw('Unsupported content source type: undefined');
});

Expand Down
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.45.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.45.5...@adobe/spacecat-shared-data-access-v1.45.6) (2024-10-02)


### Bug Fixes

* content client should use the hlxConfig ([8e74827](https://github.com/adobe/spacecat-shared/commit/8e74827613421828eaef29cf1372d329433526cc))

# [@adobe/spacecat-shared-data-access-v1.45.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.45.4...@adobe/spacecat-shared-data-access-v1.45.5) (2024-09-30)


Expand Down
2 changes: 1 addition & 1 deletion 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.45.5",
"version": "1.45.6",
"description": "Shared modules of the Spacecat Services - Data Access",
"type": "module",
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const Config = (data = {}) => {
self.getSlackMentions = (type) => state?.handlers[type]?.mentions?.slack;
self.getHandlerConfig = (type) => state?.handlers[type];
self.getHandlers = () => state.handlers;
self.getHlxContentConfig = () => state.content;
self.getImports = () => state.imports;
self.getExcludedURLs = (type) => state?.handlers[type]?.excludedURLs;
self.getManualOverwrites = (type) => state?.handlers[type]?.manualOverwrites;
Expand All @@ -75,13 +74,6 @@ export const Config = (data = {}) => {
};
};

self.updateHlxContentConfig = (source, path) => {
state.content = {
source,
path,
};
};

self.updateImports = (imports) => {
state.imports = imports;
};
Expand Down Expand Up @@ -118,7 +110,6 @@ Config.fromDynamoItem = (dynamoItem) => Config(dynamoItem);

Config.toDynamoItem = (config) => ({
slack: config.getSlackConfig(),
content: config.getHlxContentConfig(),
handlers: config.getHandlers(),
imports: config.getImports(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,6 @@ describe('Config Tests', () => {
const updatedImports = config.getImports();
expect(updatedImports).to.deep.equal(imports);
});

it('correctly updates the hlx content configuration', () => {
const config = Config();
const source = 'source1';
const path = 'path1';
config.updateHlxContentConfig(source, path);

const hlxContentConfig = config.getHlxContentConfig();
expect(hlxContentConfig.source).to.equal(source);
expect(hlxContentConfig.path).to.equal(path);
});
});

describe('fromDynamoItem Static Method', () => {
Expand Down

0 comments on commit ac566e8

Please sign in to comment.