-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MWPW-156672: refactor commerce & optimize pandora dependencies #2723
Changes from 7 commits
9c9fdd6
2b70d6f
4f7e010
6fcdf15
2f534e2
96f32a4
fa60658
a0f98fa
535afeb
06f7a7e
dcb5f23
459b1e9
9d9b317
a69a3a7
9b527b2
72c998d
7ea8bf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
// This file aliases and re-exports commonly used external dependencies | ||
Check warning on line 1 in libs/features/mas/commerce/src/external.js GitHub Actions / Running eslint
|
||
import { | ||
CheckoutType, | ||
WorkflowStep, | ||
buildCheckoutUrl, | ||
} from '@pandora/commerce-checkout-url-builder'; | ||
import { Term, Commitment } from '@pandora/data-models-odm'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need these imports/we can replace them, I propose to remove them as well. |
||
import { | ||
Environment, | ||
Landscape, | ||
ProviderEnvironment, | ||
} from '@pandora/data-source-utils'; | ||
import { webCommerceArtifact } from '@pandora/data-source-wcs'; | ||
|
||
import { | ||
price, | ||
|
@@ -33,25 +27,25 @@ | |
omitProperties, | ||
toBoolean, | ||
toEnumeration, | ||
toKebabCase, | ||
toPositiveFiniteInteger, | ||
} from '@dexter/tacocat-core'; | ||
import { | ||
applyPlanType, | ||
forceTaxExclusivePrice, | ||
PlanType, | ||
} from '@dexter/tacocat-wcs-client'; | ||
} from '@dexter/tacocat-core'; | ||
|
||
const { freeze } = Object; | ||
|
||
/** @type {Commerce.Checkout.CheckoutWorkflow} */ | ||
const CheckoutWorkflow = freeze({ ...CheckoutType }); | ||
/** @type {Commerce.Checkout.CheckoutWorkflowStep} */ | ||
const CheckoutWorkflowStep = freeze({ ...WorkflowStep }); | ||
const Env = freeze({ ...ProviderEnvironment }); | ||
const Env = { | ||
STAGE: "STAGE", | ||
PRODUCTION: "PRODUCTION", | ||
LOCAL: "LOCAL" | ||
}; | ||
/** @type {Commerce.Wcs.WcsCommitment} */ | ||
const WcsCommitment = freeze({ ...Commitment }); | ||
const WcsEnv = freeze({ ...Environment }); | ||
/** @type {Commerce.Wcs.WcsPlanType} */ | ||
const WcsPlanType = freeze({ ...PlanType }); | ||
/** @type {Commerce.Wcs.WcsTerm} */ | ||
|
@@ -62,8 +56,6 @@ | |
CheckoutWorkflowStep, | ||
Env, | ||
WcsCommitment, | ||
WcsEnv, | ||
Landscape, | ||
WcsTerm, | ||
WcsPlanType, | ||
applyPlanType, | ||
|
@@ -87,7 +79,5 @@ | |
discount, | ||
toBoolean, | ||
toEnumeration, | ||
toKebabCase, | ||
toPositiveFiniteInteger, | ||
webCommerceArtifact, | ||
}; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { PARAM_ENV, PARAM_LANDSCAPE } from './constants.js'; | ||
import { PARAM_ENV, PARAM_LANDSCAPE, Landscape } from './constants.js'; | ||
Check warning on line 1 in libs/features/mas/commerce/src/settings.js GitHub Actions / Running eslint
|
||
import { Defaults } from './defaults.js'; | ||
import { | ||
CheckoutWorkflow, | ||
CheckoutWorkflowStep, | ||
Env, | ||
WcsEnv, | ||
Landscape, | ||
getParameter, | ||
toBoolean, | ||
toEnumeration, | ||
|
@@ -135,15 +133,18 @@ | |
// TODO: add alias names for meta, search and storage | ||
// See https://git.corp.adobe.com/wcms/tacocat.js/pull/348#discussion_r6557570 | ||
const { commerce = {}, locale = undefined } = config; | ||
const hostEnv = | ||
config.env?.name === HostEnv.PROD | ||
? HostEnv.PROD | ||
: toEnumeration( | ||
getParameter(PARAM_ENV, commerce, { metadata: false }), | ||
HostEnv, | ||
HostEnv.PROD, | ||
); | ||
const env = hostEnv === HostEnv.STAGE ? Env.STAGE : Env.PRODUCTION; | ||
const lowHostEnv = ['local', 'stage'].includes(config.env?.name); | ||
let env = Env.PRODUCTION; | ||
let wcsURL = 'https://www.adobe.com/web_commerce_artifact'; | ||
if (lowHostEnv) { | ||
wcsURL = 'https://www.stage.adobe.com/web_commerce_artifact'; | ||
3ch023 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: maybe string repetition could be avoided by determining the environment and then using a template literal to form the URL? Or maybe even a simple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refactored a bit |
||
const forceWcsStage = getParameter(PARAM_ENV, commerce, { metadata: false }) === 'stage'; | ||
if (forceWcsStage) { | ||
env = Env.STAGE; | ||
wcsURL = `${wcsURL}_stage`; | ||
} | ||
} | ||
|
||
const checkoutClientId = | ||
getParameter('checkoutClientId', commerce) ?? Defaults.checkoutClientId; | ||
const checkoutWorkflow = toEnumeration( | ||
|
@@ -204,7 +205,6 @@ | |
getParameter('wcsBufferLimit', commerce), | ||
Defaults.wcsBufferLimit, | ||
); | ||
const domainSwitch = toBoolean(getParameter('domain.switch', commerce), false); | ||
|
||
return { | ||
...getLocaleSettings({ locale }), | ||
|
@@ -227,9 +227,8 @@ | |
wcsApiKey, | ||
wcsBufferDelay, | ||
wcsBufferLimit, | ||
wcsEnv: env === Env.STAGE ? WcsEnv.STAGE : WcsEnv.PRODUCTION, | ||
wcsURL, | ||
landscape, | ||
domainSwitch, | ||
}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.