Skip to content
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

Merged
merged 17 commits into from
Sep 2, 2024
Merged
6 changes: 0 additions & 6 deletions libs/deps/commerce.js

This file was deleted.

4 changes: 2 additions & 2 deletions libs/deps/mas/commerce.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions libs/deps/mas/mas.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed libs/features/mas/commerce/internal/fetch-1.3.4.tgz
Binary file not shown.
Binary file removed libs/features/mas/commerce/internal/logger-1.3.0.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 3 additions & 10 deletions libs/features/mas/commerce/libs/commerce.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import {
CheckoutType,
WorkflowStep,
} from '@pandora/commerce-checkout-url-builder';
import {
ProviderEnvironment,
Landscape,
Environment,
} from '@pandora/data-source-utils';
import {
PriceDetails,
ResolvedOffer,
Expand Down Expand Up @@ -131,8 +126,8 @@ declare global {

interface Settings {
country: string;
env: ProviderEnvironment;
landscape: Landscape;
env: string;
landscape: string;
// TODO: ideally, this setting should be processed by price template and belong to price settings
forceTaxExclusive: boolean;
language: string;
Expand Down Expand Up @@ -334,7 +329,6 @@ declare global {
checkoutWorkflow: CheckoutType;
checkoutWorkflowStep: WorkflowStep;
entitlement: boolean;
upgrade: boolean;
modal: boolean;
extraOptions: Partial<Record<keyof CheckoutLinkParameter, any>>;
}
Expand Down Expand Up @@ -575,8 +569,7 @@ declare global {
wcsApiKey: string;
wcsBufferDelay: number;
wcsBufferLimit: number;
wcsEnv: Environment;
domainSwitch: boolean;
wcsURL: string;
}
}
}
Expand Down
12 changes: 2 additions & 10 deletions libs/features/mas/commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,9 @@
},
"dependencies": {
"@dexter/tacocat-consonant-templates": "file:./internal/tacocat-consonant-templates-1.13.0.tgz",
"@dexter/tacocat-core": "file:./internal/tacocat-core-1.12.2.tgz",
"@dexter/tacocat-wcs-client": "file:./internal/tacocat-wcs-client-1.17.0.tgz",
"@dexter/tacocat-core": "file:./internal/tacocat-core-1.13.0.tgz",
"@pandora/commerce-checkout-url-builder": "file:./internal/commerce-checkout-url-builder-1.6.0.tgz",
"@pandora/data-models-odm": "file:./internal/data-models-odm-0.5.4.tgz",
"@pandora/data-source-wcs": "file:./internal/data-source-wcs-0.2.8.tgz",
"@pandora/data-source-utils": "file:./internal/data-source-utils-0.3.1.tgz",
"@pandora/fetch": "file:./internal/fetch-1.3.4.tgz",
"@pandora/react-auth-provider": "file:./internal/react-auth-provider-1.2.1.tgz",
"@pandora/react-env-provider": "file:./internal/react-env-provider-1.2.2.tgz",
"@pandora/react-fetch-provider": "file:./internal/react-fetch-provider-1.2.2.tgz",
"@pandora/logger": "file:./internal/logger-1.3.0.tgz"
"@pandora/data-models-odm": "file:./internal/data-models-odm-0.5.4.tgz"
},
"devDependencies": {
"@web/dev-server-import-maps": "^0.1.1",
Expand Down
8 changes: 8 additions & 0 deletions libs/features/mas/commerce/src/constants.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ export const PARAM_LANDSCAPE = 'commerce.landscape';
export const PARAM_AOS_API_KEY = 'commerce.aosKey';
export const PARAM_WCS_API_KEY = 'commerce.wcsKey';

export const WCS_PROD_URL = 'https://www.adobe.com/web_commerce_artifact';
export const WCS_STAGE_URL = 'https://www.stage.adobe.com/web_commerce_artifact_stage';

export const STATE_FAILED = 'failed';
export const STATE_PENDING = 'pending';
export const STATE_RESOLVED = 'resolved';

export const TAG_NAME_SERVICE = 'wcms-commerce';

export const Landscape = {
DRAFT: "DRAFT",
PUBLISHED: "PUBLISHED"
}
6 changes: 2 additions & 4 deletions libs/features/mas/commerce/src/defaults.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import {
CheckoutWorkflow,
CheckoutWorkflowStep,
Env,
Landscape,
WcsEnv,
} from './external.js';
import { Landscape } from './constants.js';

/** @type {Commerce.Defaults} */
export const Defaults = Object.freeze({
Expand All @@ -16,7 +15,6 @@ export const Defaults = Object.freeze({
displayPerUnit: false,
displayRecurrence: true,
displayTax: false,
domainSwitch: false,
env: Env.PRODUCTION,
forceTaxExclusive: false,
language: 'en',
Expand All @@ -27,7 +25,7 @@ export const Defaults = Object.freeze({
quantity: 1,
wcsApiKey: 'wcms-commerce-ims-ro-user-milo',
wcsBufferDelay: 1,
wcsEnv: WcsEnv.PRODUCTION,
wcsURL: 'https://www.adobe.com/web_commerce_artifact',
landscape: Landscape.PUBLISHED,
wcsBufferLimit: 1,
});
22 changes: 6 additions & 16 deletions libs/features/mas/commerce/src/external.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import {
buildCheckoutUrl,
} from '@pandora/commerce-checkout-url-builder';
import { Term, Commitment } from '@pandora/data-models-odm';
Copy link
Contributor

Choose a reason for hiding this comment

The 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,
Expand All @@ -33,25 +27,25 @@ import {
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} */
Expand All @@ -62,8 +56,6 @@ export {
CheckoutWorkflowStep,
Env,
WcsCommitment,
WcsEnv,
Landscape,
WcsTerm,
WcsPlanType,
applyPlanType,
Expand All @@ -87,7 +79,5 @@ export {
discount,
toBoolean,
toEnumeration,
toKebabCase,
toPositiveFiniteInteger,
webCommerceArtifact,
};
13 changes: 3 additions & 10 deletions libs/features/mas/commerce/src/index.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import {
CheckoutType,
WorkflowStep,
} from '@pandora/commerce-checkout-url-builder';
import {
ProviderEnvironment,
Landscape,
Environment,
} from '@pandora/data-source-utils';
import {
PriceDetails,
ResolvedOffer,
Expand Down Expand Up @@ -131,8 +126,8 @@ declare global {

interface Settings {
country: string;
env: ProviderEnvironment;
landscape: Landscape;
env: string;
landscape: string;
// TODO: ideally, this setting should be processed by price template and belong to price settings
forceTaxExclusive: boolean;
language: string;
Expand Down Expand Up @@ -334,7 +329,6 @@ declare global {
checkoutWorkflow: CheckoutType;
checkoutWorkflowStep: WorkflowStep;
entitlement: boolean;
upgrade: boolean;
modal: boolean;
extraOptions: Partial<Record<keyof CheckoutLinkParameter, any>>;
}
Expand Down Expand Up @@ -575,8 +569,7 @@ declare global {
wcsApiKey: string;
wcsBufferDelay: number;
wcsBufferLimit: number;
wcsEnv: Environment;
domainSwitch: boolean;
wcsURL: string;
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions libs/features/mas/commerce/src/index.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { CheckoutLink } from './checkout-link.js';
import { TAG_NAME_SERVICE } from './constants.js';
import { TAG_NAME_SERVICE, Landscape } from './constants.js';
import { Defaults } from './defaults.js';
import {
CheckoutWorkflow,
CheckoutWorkflowStep,
WcsCommitment,
WcsEnv,
Landscape,
WcsTerm,
WcsPlanType,
applyPlanType,
Expand All @@ -25,7 +23,6 @@ export {
InlinePrice,
Log,
WcsCommitment,
WcsEnv,
Landscape,
WcsTerm,
WcsPlanType,
Expand Down
27 changes: 12 additions & 15 deletions libs/features/mas/commerce/src/settings.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

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, WCS_PROD_URL, WCS_STAGE_URL } from './constants.js';
import { Defaults } from './defaults.js';
import {
CheckoutWorkflow,
CheckoutWorkflowStep,
Env,
WcsEnv,
Landscape,
getParameter,
toBoolean,
toEnumeration,
Expand Down Expand Up @@ -135,15 +133,16 @@ function getSettings(config = {}) {
// 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;
let env = Env.PRODUCTION;
let wcsURL = WCS_PROD_URL;

const lowHostEnv = ['local', 'stage'].includes(config.env?.name);
const forceWcsStage = getParameter(PARAM_ENV, commerce, { metadata: false }) === 'stage';
if (lowHostEnv && forceWcsStage) {
env = Env.STAGE;
wcsURL = WCS_STAGE_URL;
}

const checkoutClientId =
getParameter('checkoutClientId', commerce) ?? Defaults.checkoutClientId;
const checkoutWorkflow = toEnumeration(
Expand Down Expand Up @@ -204,7 +203,6 @@ function getSettings(config = {}) {
getParameter('wcsBufferLimit', commerce),
Defaults.wcsBufferLimit,
);
const domainSwitch = toBoolean(getParameter('domain.switch', commerce), false);

return {
...getLocaleSettings({ locale }),
Expand All @@ -227,9 +225,8 @@ function getSettings(config = {}) {
wcsApiKey,
wcsBufferDelay,
wcsBufferLimit,
wcsEnv: env === Env.STAGE ? WcsEnv.STAGE : WcsEnv.PRODUCTION,
wcsURL,
landscape,
domainSwitch,
};
}

Expand Down
Loading
Loading