From d2297557f7cb1fbcd5de96c7c20a871d8e10da9e Mon Sep 17 00:00:00 2001 From: lukianet Date: Mon, 24 Jun 2024 14:53:53 +0200 Subject: [PATCH 1/2] MWPW-152283: add acom wcs endpoint --- commerce/src/defaults.js | 1 + commerce/src/index.d.ts | 1 + commerce/src/settings.js | 4 ++++ commerce/src/wcs.js | 7 ++++--- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/commerce/src/defaults.js b/commerce/src/defaults.js index 75fb888e..8d478637 100644 --- a/commerce/src/defaults.js +++ b/commerce/src/defaults.js @@ -22,6 +22,7 @@ export const Defaults = Object.freeze({ entitlement: false, extraOptions: {}, modal: false, + upgrade: false, promotionCode: '', quantity: 1, wcsApiKey: 'wcms-commerce-ims-ro-user-milo', diff --git a/commerce/src/index.d.ts b/commerce/src/index.d.ts index 49f6e9d2..4f909701 100644 --- a/commerce/src/index.d.ts +++ b/commerce/src/index.d.ts @@ -576,6 +576,7 @@ declare global { wcsBufferDelay: number; wcsBufferLimit: number; wcsEnv: Environment; + domainSwitch: boolean; } } } diff --git a/commerce/src/settings.js b/commerce/src/settings.js index 01106364..0aeb9c85 100644 --- a/commerce/src/settings.js +++ b/commerce/src/settings.js @@ -180,6 +180,7 @@ function getSettings(config = {}) { Defaults.entitlement ); const modal = toBoolean(getParameter('modal', commerce), Defaults.modal); + const upgrade = toBoolean(getParameter('upgrade', commerce), Defaults.upgrade); const forceTaxExclusive = toBoolean( getParameter('forceTaxExclusive', commerce), Defaults.forceTaxExclusive @@ -204,6 +205,7 @@ function getSettings(config = {}) { getParameter('wcsBufferLimit', commerce), Defaults.wcsBufferLimit ); + const domainSwitch = toBoolean(getParameter('domain.switch', commerce), false); return { ...getLocaleSettings({ locale }), @@ -217,6 +219,7 @@ function getSettings(config = {}) { entitlement, extraOptions: Defaults.extraOptions, modal, + upgrade, env, forceTaxExclusive, priceLiteralsURL: commerce.priceLiteralsURL, @@ -228,6 +231,7 @@ function getSettings(config = {}) { wcsBufferLimit, wcsEnv: env === Env.STAGE ? WcsEnv.STAGE : WcsEnv.PRODUCTION, landscape, + domainSwitch, }; } diff --git a/commerce/src/wcs.js b/commerce/src/wcs.js index 9360b337..556ad1a2 100644 --- a/commerce/src/wcs.js +++ b/commerce/src/wcs.js @@ -24,6 +24,7 @@ import { Log } from './log.js'; const WcsBaseUrl = { [Env.PRODUCTION]: 'https://wcs.adobe.com', [Env.STAGE]: 'https://wcs.stage.adobe.com', + ['STAGE_ACOM']: 'https://www.stage.adobe.com', }; /** @@ -32,12 +33,12 @@ const WcsBaseUrl = { */ export function Wcs({ settings }) { const log = Log.module('wcs'); - const { env, wcsApiKey: apiKey } = settings; - + const { env, domainSwitch, wcsApiKey: apiKey } = settings; + const baseUrl = domainSwitch ? WcsBaseUrl['STAGE_ACOM'] : WcsBaseUrl[env]; // Create @pandora Wcs client. const fetchOptions = { apiKey, - baseUrl: WcsBaseUrl[env], + baseUrl, fetch: window.fetch.bind(window), }; const getWcsOffers = webCommerceArtifact(fetchOptions); From c22c3d6a2a2752c5b91dbcfe88a2111ff39cbc67 Mon Sep 17 00:00:00 2001 From: lukianet Date: Mon, 24 Jun 2024 15:11:12 +0200 Subject: [PATCH 2/2] address pr comments --- commerce/src/defaults.js | 1 - commerce/src/settings.js | 2 -- commerce/src/wcs.js | 7 ++++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/commerce/src/defaults.js b/commerce/src/defaults.js index 8d478637..75fb888e 100644 --- a/commerce/src/defaults.js +++ b/commerce/src/defaults.js @@ -22,7 +22,6 @@ export const Defaults = Object.freeze({ entitlement: false, extraOptions: {}, modal: false, - upgrade: false, promotionCode: '', quantity: 1, wcsApiKey: 'wcms-commerce-ims-ro-user-milo', diff --git a/commerce/src/settings.js b/commerce/src/settings.js index 0aeb9c85..e753c2a9 100644 --- a/commerce/src/settings.js +++ b/commerce/src/settings.js @@ -180,7 +180,6 @@ function getSettings(config = {}) { Defaults.entitlement ); const modal = toBoolean(getParameter('modal', commerce), Defaults.modal); - const upgrade = toBoolean(getParameter('upgrade', commerce), Defaults.upgrade); const forceTaxExclusive = toBoolean( getParameter('forceTaxExclusive', commerce), Defaults.forceTaxExclusive @@ -219,7 +218,6 @@ function getSettings(config = {}) { entitlement, extraOptions: Defaults.extraOptions, modal, - upgrade, env, forceTaxExclusive, priceLiteralsURL: commerce.priceLiteralsURL, diff --git a/commerce/src/wcs.js b/commerce/src/wcs.js index 556ad1a2..9970e491 100644 --- a/commerce/src/wcs.js +++ b/commerce/src/wcs.js @@ -20,11 +20,12 @@ import { Log } from './log.js'; * reject: (reason: Error) => void * }>} WcsPromises */ - +const ACOM = '_acom'; const WcsBaseUrl = { [Env.PRODUCTION]: 'https://wcs.adobe.com', [Env.STAGE]: 'https://wcs.stage.adobe.com', - ['STAGE_ACOM']: 'https://www.stage.adobe.com', + [Env.PRODUCTION + ACOM]: 'https://www.adobe.com', + [Env.STAGE + ACOM]: 'https://www.stage.adobe.com', }; /** @@ -34,7 +35,7 @@ const WcsBaseUrl = { export function Wcs({ settings }) { const log = Log.module('wcs'); const { env, domainSwitch, wcsApiKey: apiKey } = settings; - const baseUrl = domainSwitch ? WcsBaseUrl['STAGE_ACOM'] : WcsBaseUrl[env]; + const baseUrl = domainSwitch ? WcsBaseUrl[env + ACOM] : WcsBaseUrl[env]; // Create @pandora Wcs client. const fetchOptions = { apiKey,