@useinsider/guido 3.19.0-beta.5794c8d → 3.19.0-beta.5c63bc8
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/dist/composables/useLegacyStrategyConversion.js +19 -23
- package/dist/extensions/Blocks/Recommendation/block.js +22 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +108 -84
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +51 -16
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +13 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/package.json +2 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { useToaster as
|
|
1
|
+
import { useRecommendation as I } from "./useRecommendation.js";
|
|
2
|
+
import { useToaster as C } from "./useToaster.js";
|
|
3
3
|
import { useTranslations as v } from "./useTranslations.js";
|
|
4
4
|
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
5
|
import "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
6
6
|
import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
7
7
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
8
|
-
import { resolveMigrationTarget as
|
|
9
|
-
import { commitBlockChangeOutsidePanel as
|
|
10
|
-
import { useConfigStore as
|
|
8
|
+
import { resolveMigrationTarget as R, buildLegacyMigrationPayload as T } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
|
|
9
|
+
import { commitBlockChangeOutsidePanel as h } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
|
|
10
|
+
import { useConfigStore as k } from "../stores/config.js";
|
|
11
11
|
const F = () => {
|
|
12
|
-
const e = b(), r =
|
|
12
|
+
const e = b(), r = k(), { buildCampaignUrl: m } = I(), { showToaster: i } = C(), c = v();
|
|
13
13
|
return { convertLegacyStrategy: async () => {
|
|
14
14
|
const t = e.currentRecommendationId;
|
|
15
15
|
if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
|
|
16
16
|
return "";
|
|
17
|
-
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s =
|
|
17
|
+
const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = R({
|
|
18
18
|
campaignId: r.campaignId,
|
|
19
19
|
templateLibraryId: r.templateLibraryId
|
|
20
|
-
}), S =
|
|
20
|
+
}), S = T({
|
|
21
21
|
blockId: t,
|
|
22
22
|
url: m(String(t)),
|
|
23
23
|
campaignId: r.campaignId,
|
|
@@ -29,34 +29,30 @@ const F = () => {
|
|
|
29
29
|
let o;
|
|
30
30
|
try {
|
|
31
31
|
o = await e.convertLegacyStrategy(S, s);
|
|
32
|
-
} catch (
|
|
33
|
-
return console.error("[useLegacyStrategyConversion] migration failed",
|
|
32
|
+
} catch (n) {
|
|
33
|
+
return console.error("[useLegacyStrategyConversion] migration failed", n), i({
|
|
34
34
|
type: g.Error,
|
|
35
|
-
message:
|
|
36
|
-
actionButton: {
|
|
37
|
-
text: a("ds-steps.create-recommendation-strategy"),
|
|
38
|
-
onClick: () => e.openStrategyCreation()
|
|
39
|
-
}
|
|
35
|
+
message: c("email-editor.legacy-strategy-update-failed")
|
|
40
36
|
}), "";
|
|
41
37
|
}
|
|
42
38
|
try {
|
|
43
39
|
await e.fetchStrategyProductsForBlock(t);
|
|
44
|
-
} catch (
|
|
45
|
-
console.error("[useLegacyStrategyConversion] product refetch failed",
|
|
40
|
+
} catch (n) {
|
|
41
|
+
console.error("[useLegacyStrategyConversion] product refetch failed", n);
|
|
46
42
|
}
|
|
47
|
-
const
|
|
48
|
-
return
|
|
43
|
+
const a = e.blockStates[t];
|
|
44
|
+
return a ? h(
|
|
49
45
|
t,
|
|
50
46
|
{
|
|
51
47
|
strategyId: o,
|
|
52
|
-
size:
|
|
48
|
+
size: a.recommendationConfigs.size,
|
|
53
49
|
configVersion: L
|
|
54
50
|
},
|
|
55
|
-
|
|
51
|
+
a.recommendationProducts,
|
|
56
52
|
"Converted legacy recommendation strategy"
|
|
57
|
-
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f),
|
|
53
|
+
) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), i({
|
|
58
54
|
type: g.Error,
|
|
59
|
-
message:
|
|
55
|
+
message: c("email-editor.legacy-strategy-update-failed")
|
|
60
56
|
}), "") : o;
|
|
61
57
|
} };
|
|
62
58
|
};
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var C = (l, c, t) => c in l ? b(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var d = (l, c, t) => C(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
4
|
import { useConfig as h } from "../../../composables/useConfig.js";
|
|
5
5
|
import { BlockId as D } from "../../../enums/block.js";
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
6
|
+
import { getMigrationBannerHtml as A } from "../../../utils/migrationBannerHtml.js";
|
|
7
7
|
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
8
|
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
10
|
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
11
|
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
13
|
+
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
14
14
|
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
15
|
import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import { registerNodeConfigWriter as H } from "./utils/nodeConfigWriter.js";
|
|
17
|
+
import { refreshDuplicatedStrategyBlocks as $ } from "./utils/strategyCommit.js";
|
|
18
|
+
const k = D.Recommendation, u = "recommendation-block-v2", y = "hide-price";
|
|
19
|
+
let B = !1;
|
|
20
|
+
class Y extends E {
|
|
19
21
|
constructor() {
|
|
20
22
|
super();
|
|
21
23
|
/**
|
|
22
24
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
25
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
d(this, "_pendingBlockId", null);
|
|
26
28
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
-
|
|
29
|
+
d(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
28
30
|
}
|
|
29
31
|
getId() {
|
|
30
32
|
return k;
|
|
@@ -44,7 +46,7 @@ class j extends E {
|
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
48
|
getSettingsPanelTitleHtml() {
|
|
47
|
-
return
|
|
49
|
+
return A(
|
|
48
50
|
k,
|
|
49
51
|
this.api.translate("Recommendation Block"),
|
|
50
52
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
@@ -102,7 +104,7 @@ class j extends E {
|
|
|
102
104
|
// at save for a block the user never configured.
|
|
103
105
|
...o ? { strategy: "" } : {}
|
|
104
106
|
}
|
|
105
|
-
), f =
|
|
107
|
+
), f = g();
|
|
106
108
|
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
107
109
|
I(this.api);
|
|
108
110
|
const _ = this._getBlockElement(t);
|
|
@@ -133,7 +135,7 @@ class j extends E {
|
|
|
133
135
|
}
|
|
134
136
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
135
137
|
try {
|
|
136
|
-
|
|
138
|
+
B || (I(this.api), B = !0);
|
|
137
139
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
138
140
|
if (i) {
|
|
139
141
|
const n = !e.mobileLayoutEnabled;
|
|
@@ -151,7 +153,7 @@ class j extends E {
|
|
|
151
153
|
*/
|
|
152
154
|
onDelete(t) {
|
|
153
155
|
const e = this._getRecommendationId(t);
|
|
154
|
-
e &&
|
|
156
|
+
e && g().removeBlockState(e);
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
157
159
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -199,7 +201,7 @@ class j extends E {
|
|
|
199
201
|
_scheduleArrivalReset(t) {
|
|
200
202
|
h().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
203
|
const e = this._getRecommendationId(t);
|
|
202
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
204
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && g().resetArrivedBlock(e);
|
|
203
205
|
}, 0);
|
|
204
206
|
}
|
|
205
207
|
/**
|
|
@@ -255,8 +257,8 @@ class j extends E {
|
|
|
255
257
|
}
|
|
256
258
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
257
259
|
_handleDuplicate(t, e) {
|
|
258
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
259
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e),
|
|
260
|
+
const i = this._reassignDuplicateId(t, e), n = g();
|
|
261
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), H(this.api), $(e, i, s.getConfig(t)).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o))), this._warnIfMultipleBlocks();
|
|
260
262
|
}
|
|
261
263
|
/**
|
|
262
264
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -312,7 +314,7 @@ class j extends E {
|
|
|
312
314
|
*/
|
|
313
315
|
_stampHidePrice(t, e) {
|
|
314
316
|
const i = this._getBlockElement(t);
|
|
315
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
317
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(y, String(e)).apply(new p("Stamp hide-price"));
|
|
316
318
|
}
|
|
317
319
|
/**
|
|
318
320
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -320,7 +322,7 @@ class j extends E {
|
|
|
320
322
|
*/
|
|
321
323
|
_healHidePriceAttr(t) {
|
|
322
324
|
const e = this._getBlockElement(t);
|
|
323
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
325
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(y) !== null)
|
|
324
326
|
return;
|
|
325
327
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
326
328
|
this._stampHidePrice(t, i);
|
|
@@ -358,5 +360,5 @@ class j extends E {
|
|
|
358
360
|
}
|
|
359
361
|
export {
|
|
360
362
|
k as BLOCK_ID,
|
|
361
|
-
|
|
363
|
+
Y as RecommendationBlock
|
|
362
364
|
};
|