@useinsider/guido 3.19.0 → 3.20.0-beta.0849ec7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/dist/@types/config/schemas.js +76 -53
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +102 -86
- package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/organisms/base/Toaster.vue2.js +13 -12
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
- package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
- package/dist/components/organisms/header/EditorActions.vue.js +5 -5
- package/dist/components/organisms/header/EditorActions.vue2.js +90 -57
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +49 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useCustomInterfaceAppearance.js +65 -51
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/composables/useHtmlCompiler.js +37 -26
- package/dist/composables/useHtmlValidator.js +89 -82
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +65 -0
- package/dist/composables/useRecommendation.js +40 -35
- package/dist/composables/useSave.js +90 -45
- package/dist/composables/useSaveValidation.js +282 -0
- package/dist/composables/useSaveValidationRollout.js +9 -0
- package/dist/composables/useStripo.js +43 -39
- package/dist/composables/useToaster.js +18 -22
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +51 -34
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/block.js +65 -45
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -90
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +150 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +274 -92
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +5 -3
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
- package/dist/guido.css +1 -1
- package/dist/services/recommendationApi.js +46 -37
- package/dist/src/@types/config/schemas.d.ts +36 -0
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useConfig.d.ts +8 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHtmlValidator.d.ts +21 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +7 -1
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/services/recommendationApi.d.ts +2 -1
- package/dist/src/stores/config.d.ts +374 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +812 -10
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
- package/dist/static/assets/icons/line-info.svg.js +5 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +113 -9
- package/dist/static/styles/components/skeleton.css.js +23 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/config.js +55 -24
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +50 -36
- package/dist/stores/save-validation.js +30 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/stripoEditorApi.js +11 -0
- package/dist/utils/templatePreparation.js +54 -51
- package/package.json +2 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var p = (g, u, t) => u in g ? C(g, u, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[u] = t;
|
|
3
|
+
var i = (g, u, t) => p(g, typeof u != "symbol" ? u + "" : u, t);
|
|
4
|
+
import { useConfig as h } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as N } from "../../../common-control.js";
|
|
7
|
-
import {
|
|
7
|
+
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
8
|
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
9
|
import { RecommendationConfigService as c } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
@@ -12,16 +12,16 @@ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
13
|
import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
15
|
+
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as ft } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
20
|
import { LocaleControl as L } from "./locale.js";
|
|
21
21
|
import { LOCALE_CONTROL_ID as yt } from "./locale.js";
|
|
22
|
-
import { PricePlacementControl as
|
|
22
|
+
import { PricePlacementControl as k } from "./pricePlacement.js";
|
|
23
23
|
import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
|
|
24
|
-
import { ProductCountControl as
|
|
24
|
+
import { ProductCountControl as E } from "./productCount.js";
|
|
25
25
|
import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
|
|
26
26
|
import { ProductLayoutControl as F } from "./productLayout.js";
|
|
27
27
|
import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
|
|
@@ -29,36 +29,36 @@ import { ShuffleControl as D } from "./shuffle.js";
|
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as
|
|
32
|
+
import { setCurrencyAttributes as v, getBlockElement as A, isPartnerManagedBlock as B, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as vt, regenerateMobileProductRows as At, updatePricesInPlace as Bt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
34
|
import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
|
-
const
|
|
35
|
+
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
i(this, "store", R());
|
|
40
|
+
i(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
43
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
i(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
i(this, "pendingConfigFlushTimer", null);
|
|
46
46
|
// Sub-control instances for lifecycle management
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
i(this, "algorithmControl", null);
|
|
48
|
+
i(this, "localeControl", null);
|
|
49
|
+
i(this, "currencyControl", null);
|
|
50
|
+
i(this, "productCountControl", null);
|
|
51
|
+
i(this, "productLayoutControl", null);
|
|
52
|
+
i(this, "filtersControl", null);
|
|
53
|
+
i(this, "shuffleControl", null);
|
|
54
|
+
i(this, "pricePlacementControl", null);
|
|
55
|
+
i(this, "layoutOrientationControl", null);
|
|
56
|
+
i(this, "strategyControl", null);
|
|
57
|
+
i(this, "rrsEnabled", !1);
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
i(this, "_debouncedFetchProducts", f(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,16 +76,16 @@ class at extends N {
|
|
|
76
76
|
* count. The store pads products to the configured size, so in-place only
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", f(() => {
|
|
80
80
|
const t = this.store.recommendationProducts;
|
|
81
81
|
if (!this.currentNode || !this.api)
|
|
82
82
|
return;
|
|
83
83
|
const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
|
|
84
|
-
if (
|
|
84
|
+
if (B(this.currentNode)) {
|
|
85
85
|
o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
x({
|
|
89
89
|
currentNode: this.currentNode,
|
|
90
90
|
documentModifier: e,
|
|
91
91
|
products: t
|
|
@@ -97,7 +97,7 @@ class at extends N {
|
|
|
97
97
|
}, 100));
|
|
98
98
|
}
|
|
99
99
|
getId() {
|
|
100
|
-
return
|
|
100
|
+
return W;
|
|
101
101
|
}
|
|
102
102
|
get _subControls() {
|
|
103
103
|
return [
|
|
@@ -115,10 +115,10 @@ class at extends N {
|
|
|
115
115
|
}
|
|
116
116
|
getTemplate() {
|
|
117
117
|
var t;
|
|
118
|
-
return this.rrsEnabled =
|
|
118
|
+
return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
|
|
119
119
|
var o;
|
|
120
120
|
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
121
|
-
}), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new
|
|
121
|
+
}), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new k(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
|
|
122
122
|
e && (e.api = this.api);
|
|
123
123
|
}), `
|
|
124
124
|
<div class="recommendation-controls-container">
|
|
@@ -136,18 +136,18 @@ class at extends N {
|
|
|
136
136
|
`;
|
|
137
137
|
}
|
|
138
138
|
_showControlsForBlock(t) {
|
|
139
|
-
var
|
|
140
|
-
const e = (
|
|
139
|
+
var r;
|
|
140
|
+
const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
141
141
|
if (!e)
|
|
142
142
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t),
|
|
144
|
-
e.classList.toggle("strategy-block",
|
|
143
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
144
|
+
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
145
145
|
}
|
|
146
146
|
async onRender() {
|
|
147
147
|
var o;
|
|
148
148
|
b(this.api);
|
|
149
149
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
150
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
150
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), t !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
151
151
|
this._initializeSubControls();
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
@@ -159,9 +159,9 @@ class at extends N {
|
|
|
159
159
|
const e = this._getRecommendationIdFromNode(t);
|
|
160
160
|
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
|
|
161
161
|
this._initializeSubControls();
|
|
162
|
-
}), this._subControls.forEach((
|
|
163
|
-
var
|
|
164
|
-
|
|
162
|
+
}), this._subControls.forEach((n) => {
|
|
163
|
+
var s;
|
|
164
|
+
n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
onDestroy() {
|
|
@@ -209,18 +209,30 @@ class at extends N {
|
|
|
209
209
|
const e = this.store.blockStates[t];
|
|
210
210
|
if (!e)
|
|
211
211
|
return;
|
|
212
|
-
const o = JSON.stringify(c.getConfig(this.currentNode)),
|
|
213
|
-
e.syncedConfigFingerprint = o,
|
|
212
|
+
const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
|
+
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
|
+
}
|
|
215
|
+
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
|
+
_isPendingStrategyIdChange() {
|
|
217
|
+
const t = this.pendingNodeConfigWrite;
|
|
218
|
+
return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
214
219
|
}
|
|
215
220
|
_capturePendingNodeConfigWrite() {
|
|
216
221
|
const t = this.store.currentRecommendationId;
|
|
217
222
|
if (!this.currentNode || !this.api || t === null)
|
|
218
223
|
return;
|
|
219
|
-
const { filters: e,
|
|
224
|
+
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs, { partnerName: l } = h();
|
|
220
225
|
this.pendingNodeConfigWrite = {
|
|
221
226
|
blockId: t,
|
|
222
227
|
node: this.currentNode,
|
|
223
|
-
updates: {
|
|
228
|
+
updates: {
|
|
229
|
+
filters: e,
|
|
230
|
+
strategy: o,
|
|
231
|
+
strategyId: n,
|
|
232
|
+
size: s,
|
|
233
|
+
configVersion: r,
|
|
234
|
+
...l.value ? { partnerName: l.value } : {}
|
|
235
|
+
}
|
|
224
236
|
};
|
|
225
237
|
}
|
|
226
238
|
/**
|
|
@@ -260,14 +272,15 @@ class at extends N {
|
|
|
260
272
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
261
273
|
return;
|
|
262
274
|
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
|
|
263
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
275
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
264
276
|
}
|
|
265
277
|
_syncNodeConfigToStore() {
|
|
266
|
-
var
|
|
267
|
-
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((
|
|
278
|
+
var n;
|
|
279
|
+
const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
268
280
|
this.store.patchCurrentBlockConfig({
|
|
269
281
|
strategy: t.strategy,
|
|
270
282
|
strategyId: t.strategyId,
|
|
283
|
+
nodeConfigVersion: t.configVersion,
|
|
271
284
|
language: t.language,
|
|
272
285
|
size: t.size,
|
|
273
286
|
productIds: t.productIds,
|
|
@@ -306,8 +319,8 @@ class at extends N {
|
|
|
306
319
|
t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
|
|
307
320
|
this.store.fetchRecommendationCreateData(),
|
|
308
321
|
this.store.fetchRecommendationFilters()
|
|
309
|
-
])).forEach((o,
|
|
310
|
-
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][
|
|
322
|
+
])).forEach((o, n) => {
|
|
323
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
|
|
311
324
|
}), this._applySmartDefaults();
|
|
312
325
|
try {
|
|
313
326
|
await this.store.fetchRecommendationProducts();
|
|
@@ -329,35 +342,35 @@ class at extends N {
|
|
|
329
342
|
if (!this.currentNode || !this.api)
|
|
330
343
|
return;
|
|
331
344
|
const t = c.getConfig(this.currentNode), e = {};
|
|
332
|
-
let o = null,
|
|
345
|
+
let o = null, n = null, s = null;
|
|
333
346
|
if (t.currency.code === a.currency.code) {
|
|
334
|
-
const { currencyList:
|
|
335
|
-
|
|
347
|
+
const { currencyList: r } = this.store;
|
|
348
|
+
r.length > 0 && (r.some(
|
|
336
349
|
(d) => d.value === `price.${a.currency.code}`
|
|
337
|
-
) || (o =
|
|
350
|
+
) || (o = r[0].value.replace("price.", ""), e.currency = {
|
|
338
351
|
...a.currency,
|
|
339
352
|
code: o,
|
|
340
353
|
symbol: o
|
|
341
354
|
}));
|
|
342
355
|
}
|
|
343
356
|
if (t.strategy === a.strategy) {
|
|
344
|
-
const
|
|
345
|
-
|
|
357
|
+
const r = this.store.getActivePredictiveAlgorithms;
|
|
358
|
+
r.length > 0 && (r.some(
|
|
346
359
|
(d) => d.value === a.strategy
|
|
347
|
-
) || (
|
|
360
|
+
) || (n = r[0].value, e.strategy = n));
|
|
348
361
|
}
|
|
349
362
|
if (t.language === a.language) {
|
|
350
|
-
const
|
|
351
|
-
|
|
363
|
+
const r = this.store.getLanguages;
|
|
364
|
+
r.length > 0 && (r.some(
|
|
352
365
|
(d) => d.value === a.language
|
|
353
|
-
) || (
|
|
366
|
+
) || (s = r[0].value, e.language = s));
|
|
354
367
|
}
|
|
355
|
-
!o && !
|
|
368
|
+
!o && !n && !s || (c.updateConfig(
|
|
356
369
|
this.api,
|
|
357
370
|
this.currentNode,
|
|
358
371
|
e,
|
|
359
372
|
"Applied smart defaults"
|
|
360
|
-
), o && e.currency &&
|
|
373
|
+
), o && e.currency && v({
|
|
361
374
|
currentNode: this.currentNode,
|
|
362
375
|
documentModifier: this.api.getDocumentModifier(),
|
|
363
376
|
currency: e.currency
|
|
@@ -373,22 +386,22 @@ class at extends N {
|
|
|
373
386
|
thousandSeparator: a.currency.thousandSeparator
|
|
374
387
|
}
|
|
375
388
|
} : {},
|
|
376
|
-
...
|
|
377
|
-
...
|
|
389
|
+
...n ? { strategy: n } : {},
|
|
390
|
+
...s ? { language: s } : {}
|
|
378
391
|
}, { triggerRefetch: !1 }));
|
|
379
392
|
}
|
|
380
393
|
/**
|
|
381
394
|
* Reads the recommendation-id attribute from the block element within the node
|
|
382
395
|
*/
|
|
383
396
|
_getRecommendationIdFromNode(t) {
|
|
384
|
-
const e =
|
|
397
|
+
const e = A(t);
|
|
385
398
|
if (!e || !("getAttribute" in e))
|
|
386
399
|
return null;
|
|
387
400
|
const o = e.getAttribute(I);
|
|
388
401
|
if (!o)
|
|
389
402
|
return null;
|
|
390
|
-
const
|
|
391
|
-
return Number.isNaN(
|
|
403
|
+
const n = parseInt(o);
|
|
404
|
+
return Number.isNaN(n) ? null : n;
|
|
392
405
|
}
|
|
393
406
|
/**
|
|
394
407
|
* Listen to store changes that require product refresh or regeneration.
|
|
@@ -405,27 +418,27 @@ class at extends N {
|
|
|
405
418
|
*/
|
|
406
419
|
_listenStateUpdates() {
|
|
407
420
|
const { store: t } = this;
|
|
408
|
-
let e = t.recommendationProducts, o = t.$state.configVersion,
|
|
421
|
+
let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
|
|
409
422
|
this.storeUnsubscription = t.$subscribe(() => {
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
412
|
-
|
|
423
|
+
const s = t.currentRecommendationId;
|
|
424
|
+
if (s !== n) {
|
|
425
|
+
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
413
426
|
return;
|
|
414
427
|
}
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
d &&
|
|
428
|
+
const r = t.$state.configVersion;
|
|
429
|
+
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
430
|
+
const l = t.recommendationProducts, d = l !== e, m = Array.isArray(l) && l.length > 0;
|
|
431
|
+
d && m && (e = l, this._debouncedRegenerateWithProducts());
|
|
419
432
|
});
|
|
420
433
|
}
|
|
421
434
|
}
|
|
422
435
|
export {
|
|
423
436
|
ut as ALGORITHM_CONTROL_ID,
|
|
424
437
|
T as AlgorithmControl,
|
|
425
|
-
|
|
426
|
-
|
|
438
|
+
W as CONTROL_BLOCK_ID,
|
|
439
|
+
gt as CURRENCY_CONTROL_ID,
|
|
427
440
|
P as CurrencyControl,
|
|
428
|
-
|
|
441
|
+
ft as FILTERS_CONTROL_ID,
|
|
429
442
|
S as FiltersControl,
|
|
430
443
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
431
444
|
yt as LOCALE_CONTROL_ID,
|
|
@@ -434,25 +447,25 @@ export {
|
|
|
434
447
|
_t as PRICE_PLACEMENT_CONTROL_ID,
|
|
435
448
|
Rt as PRODUCT_COUNT_CONTROL_ID,
|
|
436
449
|
Tt as PRODUCT_LAYOUT_CONTROL_ID,
|
|
437
|
-
|
|
438
|
-
|
|
450
|
+
k as PricePlacementControl,
|
|
451
|
+
E as ProductCountControl,
|
|
439
452
|
F as ProductLayoutControl,
|
|
440
453
|
at as RecommendationBlockControl,
|
|
441
454
|
St as SHUFFLE_CONTROL_ID,
|
|
442
455
|
Lt as STRATEGY_CONTROL_ID,
|
|
443
456
|
D as ShuffleControl,
|
|
444
457
|
w as StrategyControl,
|
|
445
|
-
|
|
458
|
+
Et as adjustProductsToSize,
|
|
446
459
|
Ft as formatProductPrice,
|
|
447
|
-
|
|
460
|
+
A as getBlockElement,
|
|
448
461
|
Dt as getCardComposition,
|
|
449
462
|
wt as getCurrentLayout,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
463
|
+
vt as getMainContainerTbody,
|
|
464
|
+
B as isPartnerManagedBlock,
|
|
465
|
+
At as regenerateMobileProductRows,
|
|
453
466
|
U as regenerateProductRowsWithStyles,
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
467
|
+
v as setCurrencyAttributes,
|
|
468
|
+
Bt as updatePricesInPlace,
|
|
469
|
+
x as updateProductContentInPlace,
|
|
470
|
+
xt as updateSingleProductContent
|
|
458
471
|
};
|