diff --git a/package-lock.json b/package-lock.json index 61fe9e8..6a4b54d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4070,6 +4070,24 @@ "node": ">=18" } }, + "node_modules/@release-it/conventional-changelog/node_modules/conventional-commits-parser": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.2.1.tgz", + "integrity": "sha512-20pyHgnO40rvfI0NGF/xiEoFMkXDtkF8FwHvk5BokoFoCuTQRI8vrNCNFWUOfuolKJMm1tPCHc8GgYEtr1XRNA==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "meow": "^13.0.0" + }, + "bin": { + "conventional-commits-parser": "dist/cli/index.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@release-it/conventional-changelog/node_modules/semver": { "version": "7.7.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", @@ -15493,7 +15511,7 @@ }, "proxy": { "name": "fsxa-proxy-api", - "version": "10.24.0", + "version": "11.0.0", "license": "Apache-2.0", "engines": { "node": ">=14.0.0" diff --git a/src/modules/CaaSMapper.spec.ts b/src/modules/CaaSMapper.spec.ts index 88ab340..c05639f 100644 --- a/src/modules/CaaSMapper.spec.ts +++ b/src/modules/CaaSMapper.spec.ts @@ -101,7 +101,9 @@ describe('CaaSMapper', () => { }) }) it('should register a remote reference and return its remote reference key', () => { - const remotes = { someName: { id: 'remoteId', locale: 'de' } } + const remotes = { + someName: { id: 'remoteId', locale: 'de', contentMode: undefined }, + } const api = createApi() api.remotes = remotes const mapper = new CaaSMapper(api, 'de', {}, createLogger()) @@ -1659,9 +1661,9 @@ describe('CaaSMapper', () => { it('should call resolveReferencesPerProject for all remote projects', async () => { const api = createApi() api.remotes = { - 'remote-id1': { id: 'remote-id1', locale: 'de' }, - 'remote-id2': { id: 'remote-id2', locale: 'de' }, - 'remote-id3': { id: 'remote-id3', locale: 'de' }, + 'remote-id1': { id: 'remote-id1', locale: 'de', contentMode: undefined }, + 'remote-id2': { id: 'remote-id2', locale: 'de', contentMode: undefined }, + 'remote-id3': { id: 'remote-id3', locale: 'de', contentMode: undefined }, } const mapper = new CaaSMapper(api, 'de', {}, createLogger()) mapper.resolveReferencesPerProject = jest.fn() @@ -1696,7 +1698,9 @@ describe('CaaSMapper', () => { }) it('should resolve remote media references', async () => { const api = createApi() - api.remotes = { 'remote-id1': { id: 'remote-id1', locale: 'de' } } + api.remotes = { + 'remote-id1': { id: 'remote-id1', locale: 'de', contentMode: undefined }, + } const mapper = new CaaSMapper(api, 'de', {}, createLogger()) const mediaPictures = await Promise.all([ mapper.mapMediaPicture(createMediaPicture('id1')), diff --git a/src/modules/FSXARemoteApi.spec.ts b/src/modules/FSXARemoteApi.spec.ts index ef6a620..cd09208 100644 --- a/src/modules/FSXARemoteApi.spec.ts +++ b/src/modules/FSXARemoteApi.spec.ts @@ -1,5 +1,5 @@ import { faker } from '@faker-js/faker' -import { FSXAApiErrors, HttpStatus } from '../enums' +import { FSXAApiErrors, FSXAContentMode, HttpStatus } from '../enums' import { FetchResponse, QueryBuilderQuery, SortParams } from '../types' import { FSXARemoteApi } from './FSXARemoteApi' import { @@ -118,6 +118,20 @@ describe('FSXARemoteAPI', () => { const expectedCaaSUrl = `${config.caasURL}/${config.tenantID}/${remoteProjectId}.${config.contentMode}.content` expect(actualCaaSUrl).toStrictEqual(expectedCaaSUrl) }) + it('should use the remote contentMode if provided', () => { + const config = generateRandomConfig() + const remoteProjectId = config.remotes.remote.id + + config.contentMode = FSXAContentMode.RELEASE + ;(config.remotes.remote as any).contentMode = FSXAContentMode.PREVIEW + + const remoteApi = new FSXARemoteApi(config) + const actualCaaSUrl = remoteApi.buildCaaSUrl({ + remoteProject: remoteProjectId, + }) + const expectedCaaSUrl = `${config.caasURL}/${config.tenantID}/${remoteProjectId}.preview.content` + expect(actualCaaSUrl).toStrictEqual(expectedCaaSUrl) + }) it('should return the correct caas url with a locale but no id', () => { const locale = `${faker.location.countryCode().toLowerCase()}_${faker.location.countryCode().toLowerCase()}` const config = generateRandomConfig() diff --git a/src/modules/FSXARemoteApi.ts b/src/modules/FSXARemoteApi.ts index b555d08..dbc572a 100644 --- a/src/modules/FSXARemoteApi.ts +++ b/src/modules/FSXARemoteApi.ts @@ -191,7 +191,13 @@ export class FSXARemoteApi implements FSXAApi { projectId = remoteProjectId } - let baseURL = `${this.caasURL}/${this.tenantID}/${projectId}.${this.contentMode}.content` + let contentMode = this.contentMode + if (remoteProjectId) { + const remoteConfig = this.getRemoteConfigById(remoteProjectId) + contentMode = remoteConfig.contentMode || contentMode + } + + let baseURL = `${this.caasURL}/${this.tenantID}/${projectId}.${contentMode}.content` let encodedBaseURL = encodeURI(baseURL) if (id) { diff --git a/src/types.ts b/src/types.ts index 26b5ff8..0bea3c5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -987,6 +987,7 @@ export type RemoteProjectConfiguration = { [name: string]: { id: string locale: string + contentMode?: 'preview' | 'release' } }