@useinsider/guido 3.30.0-beta.06d87f9 → 3.30.0-beta.0c48424
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/useAuthError.js +15 -12
- package/dist/composables/useHtmlValidator.js +138 -130
- package/dist/composables/useHttp.js +70 -61
- package/dist/composables/useSave.js +1 -1
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +59 -57
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +37 -33
- package/dist/services/templateLibraryApi.js +35 -33
- package/dist/src/composables/useAuthError.d.ts +1 -0
- package/dist/src/composables/useHtmlValidator.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +14 -0
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import { useToaster as L } from "../../../../composables/useToaster.js";
|
|
2
2
|
import { useTranslations as U } from "../../../../composables/useTranslations.js";
|
|
3
|
-
import { getRecommendationFeedSourceMaps as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import { useRecommendationApi as
|
|
3
|
+
import { getRecommendationFeedSourceMaps as F, strategyEditPath as z, strategyCreatePath as B, getOperatorOptions as M, PriceAttributes as A } from "../../../../enums/extensions/recommendationBlock.js";
|
|
4
|
+
import { ToasterTypeOptions as N } from "../../../../enums/toaster.js";
|
|
5
|
+
import { useRecommendationApi as E } from "../../../../services/recommendationApi.js";
|
|
6
6
|
import { useConfigStore as R } from "../../../../stores/config.js";
|
|
7
|
+
import { isPlainObject as O } from "../../../../utils/genericUtil.js";
|
|
7
8
|
import { defineStore as V } from "pinia";
|
|
8
9
|
import "../constants/selectors.js";
|
|
9
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as
|
|
10
|
-
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as
|
|
11
|
-
import { getDefaultProducts as
|
|
10
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as x, DEFAULT_CARDS_IN_ROW as T } from "../constants/layout.js";
|
|
11
|
+
import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as j, EXCLUDED_ALGORITHM_IDS as $ } from "../constants/defaultConfig.js";
|
|
12
|
+
import { getDefaultProducts as w } from "../templates/utils.js";
|
|
12
13
|
import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
|
|
13
|
-
import { isLegacyStrategyConfig as
|
|
14
|
-
import { getPartnerRecommendationParams as
|
|
15
|
-
import { sanitizeProductIds as
|
|
16
|
-
import { isFilterValid as
|
|
17
|
-
import { getInvalidFields as
|
|
18
|
-
const u =
|
|
19
|
-
let
|
|
14
|
+
import { isLegacyStrategyConfig as q } from "../utils/legacyStrategyMigration.js";
|
|
15
|
+
import { getPartnerRecommendationParams as K } from "../utils/partnerCustomizations.js";
|
|
16
|
+
import { sanitizeProductIds as H } from "../utils/productIds.js";
|
|
17
|
+
import { isFilterValid as J } from "../validation/filterSchema.js";
|
|
18
|
+
import { getInvalidFields as Q, isConfigValid as W } from "../validation/requiredFields.js";
|
|
19
|
+
const u = E();
|
|
20
|
+
let y = null, p = null;
|
|
20
21
|
const I = /* @__PURE__ */ new Map();
|
|
21
22
|
let k = null, b = 0;
|
|
22
|
-
const m = /* @__PURE__ */ new Map(),
|
|
23
|
-
function
|
|
24
|
-
const e =
|
|
23
|
+
const m = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
|
|
24
|
+
function X(t) {
|
|
25
|
+
const e = D.get(t);
|
|
25
26
|
return e && e.token === m.get(t) ? e.outcome : !1;
|
|
26
27
|
}
|
|
27
28
|
let l = null;
|
|
28
|
-
const
|
|
29
|
+
const Y = () => {
|
|
29
30
|
l == null || l();
|
|
30
31
|
};
|
|
31
|
-
function
|
|
32
|
+
function _() {
|
|
32
33
|
return {
|
|
33
|
-
cardsInRow:
|
|
34
|
+
cardsInRow: T,
|
|
34
35
|
currencySettings: {
|
|
35
36
|
name: "USD",
|
|
36
37
|
value: "USD",
|
|
@@ -44,7 +45,7 @@ function D() {
|
|
|
44
45
|
productIds: [],
|
|
45
46
|
id: 1,
|
|
46
47
|
language: "en_US",
|
|
47
|
-
mobileCardsInRow:
|
|
48
|
+
mobileCardsInRow: x,
|
|
48
49
|
mobileLayoutEnabled: !1,
|
|
49
50
|
orientation: "grid",
|
|
50
51
|
recommendedProducts: [],
|
|
@@ -67,7 +68,7 @@ function D() {
|
|
|
67
68
|
}
|
|
68
69
|
function G() {
|
|
69
70
|
return {
|
|
70
|
-
recommendationConfigs:
|
|
71
|
+
recommendationConfigs: _(),
|
|
71
72
|
recommendationProducts: [],
|
|
72
73
|
filterStatus: !1,
|
|
73
74
|
filterSelectionDrawerStatus: !1,
|
|
@@ -84,12 +85,13 @@ function G() {
|
|
|
84
85
|
drawnProducts: null
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
|
-
const
|
|
88
|
+
const Z = () => ({
|
|
88
89
|
recommendationCampaignUrls: {},
|
|
89
90
|
activePredictiveAlgorithms: [],
|
|
90
91
|
languages: {},
|
|
91
92
|
currencyList: [],
|
|
92
93
|
filterList: {},
|
|
94
|
+
isCreateDataFetched: !1,
|
|
93
95
|
strategies: [],
|
|
94
96
|
strategiesLoading: !1,
|
|
95
97
|
strategyUrlTemplates: {},
|
|
@@ -99,8 +101,8 @@ const Y = () => ({
|
|
|
99
101
|
currentRecommendationId: null,
|
|
100
102
|
strategyPanelOpen: !1,
|
|
101
103
|
configVersion: 0
|
|
102
|
-
}),
|
|
103
|
-
state: () =>
|
|
104
|
+
}), pt = V("guidoRecommendationExtension", {
|
|
105
|
+
state: () => Z(),
|
|
104
106
|
getters: {
|
|
105
107
|
// ====================================================================
|
|
106
108
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -110,7 +112,7 @@ const Y = () => ({
|
|
|
110
112
|
* This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
|
|
111
113
|
*/
|
|
112
114
|
recommendationConfigs(t) {
|
|
113
|
-
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs :
|
|
115
|
+
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : _();
|
|
114
116
|
},
|
|
115
117
|
/**
|
|
116
118
|
* Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
|
|
@@ -131,7 +133,7 @@ const Y = () => ({
|
|
|
131
133
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
|
|
132
134
|
},
|
|
133
135
|
isLegacyStrategyBlock() {
|
|
134
|
-
return R().isFeatureEnabled("reusableRecommendationStrategy") &&
|
|
136
|
+
return R().isFeatureEnabled("reusableRecommendationStrategy") && q(this.recommendationConfigs);
|
|
135
137
|
},
|
|
136
138
|
legacyConversionLoading(t) {
|
|
137
139
|
return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
|
|
@@ -174,8 +176,8 @@ const Y = () => ({
|
|
|
174
176
|
return [...new Set(t.map((e) => e.filterGroup))].sort((e, n) => e - n);
|
|
175
177
|
},
|
|
176
178
|
getActivePredictiveAlgorithms: (t) => {
|
|
177
|
-
const e =
|
|
178
|
-
return t.activePredictiveAlgorithms.filter((r) =>
|
|
179
|
+
const e = F(), n = [];
|
|
180
|
+
return t.activePredictiveAlgorithms.filter((r) => !$.includes(r)).forEach((r) => {
|
|
179
181
|
n.push(...e.filter((o) => o.id === r));
|
|
180
182
|
}), n.map((r) => ({
|
|
181
183
|
text: r.name,
|
|
@@ -193,7 +195,7 @@ const Y = () => ({
|
|
|
193
195
|
getFilterList() {
|
|
194
196
|
return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
|
|
195
197
|
let e;
|
|
196
|
-
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` :
|
|
198
|
+
return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : A.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
|
|
197
199
|
text: t.displayName,
|
|
198
200
|
value: e,
|
|
199
201
|
type: t.attributeType
|
|
@@ -450,7 +452,7 @@ const Y = () => ({
|
|
|
450
452
|
const e = window.open(t, "_blank");
|
|
451
453
|
if (!e)
|
|
452
454
|
return L().showToaster({
|
|
453
|
-
type:
|
|
455
|
+
type: N.Error,
|
|
454
456
|
message: U()("discovery-strategy.error-description")
|
|
455
457
|
}), !1;
|
|
456
458
|
e.opener = null, l == null || l();
|
|
@@ -479,7 +481,7 @@ const Y = () => ({
|
|
|
479
481
|
},
|
|
480
482
|
/** Lets the editor tear the return listeners down when it unmounts. */
|
|
481
483
|
disposeStrategyPageReturn() {
|
|
482
|
-
|
|
484
|
+
Y();
|
|
483
485
|
},
|
|
484
486
|
/**
|
|
485
487
|
* Opens Smart Recommender's strategy creation page. Every return refreshes the list so the
|
|
@@ -548,7 +550,7 @@ const Y = () => ({
|
|
|
548
550
|
this.patchCurrentBlockConfig({
|
|
549
551
|
strategyId: "",
|
|
550
552
|
strategy: "",
|
|
551
|
-
size:
|
|
553
|
+
size: j.size,
|
|
552
554
|
nodeConfigVersion: C
|
|
553
555
|
});
|
|
554
556
|
},
|
|
@@ -556,44 +558,44 @@ const Y = () => ({
|
|
|
556
558
|
// Shared Data Fetching (fetched once, used by all blocks)
|
|
557
559
|
// ====================================================================
|
|
558
560
|
async fetchRecommendationCreateData() {
|
|
559
|
-
if (!this.
|
|
560
|
-
if (
|
|
561
|
-
await
|
|
561
|
+
if (!this.isCreateDataFetched) {
|
|
562
|
+
if (y) {
|
|
563
|
+
await y;
|
|
562
564
|
return;
|
|
563
565
|
}
|
|
564
|
-
|
|
566
|
+
y = (async () => {
|
|
565
567
|
const {
|
|
566
568
|
activePredictiveAlgorithms: t,
|
|
567
569
|
languages: e,
|
|
568
570
|
currencies: n
|
|
569
571
|
} = await u.fetchRecommendationCreateData();
|
|
570
|
-
if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
572
|
+
if (this.activePredictiveAlgorithms = Array.isArray(t) ? t : [], this.languages = O(e) ? e : {}, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
|
|
571
573
|
const r = this.blockStates[this.currentRecommendationId];
|
|
572
574
|
r.filterStatus = !!r.recommendationConfigs.filters.length;
|
|
573
575
|
}
|
|
574
|
-
this.currencyList = n;
|
|
576
|
+
this.currencyList = Array.isArray(n) ? n : [], this.isCreateDataFetched = Array.isArray(t);
|
|
575
577
|
})();
|
|
576
578
|
try {
|
|
577
|
-
await
|
|
579
|
+
await y;
|
|
578
580
|
} finally {
|
|
579
|
-
|
|
581
|
+
y = null;
|
|
580
582
|
}
|
|
581
583
|
}
|
|
582
584
|
},
|
|
583
585
|
async fetchRecommendationFilters() {
|
|
584
586
|
if (!Object.keys(this.filterList).length) {
|
|
585
|
-
if (
|
|
586
|
-
await
|
|
587
|
+
if (p) {
|
|
588
|
+
await p;
|
|
587
589
|
return;
|
|
588
590
|
}
|
|
589
|
-
|
|
591
|
+
p = (async () => {
|
|
590
592
|
const t = await u.fetchRecommendationFilters();
|
|
591
593
|
this.filterList = t;
|
|
592
594
|
})();
|
|
593
595
|
try {
|
|
594
|
-
await
|
|
596
|
+
await p;
|
|
595
597
|
} finally {
|
|
596
|
-
|
|
598
|
+
p = null;
|
|
597
599
|
}
|
|
598
600
|
}
|
|
599
601
|
},
|
|
@@ -622,7 +624,7 @@ const Y = () => ({
|
|
|
622
624
|
const r = [...e.recommendationConfigs.filters];
|
|
623
625
|
r[n] = {
|
|
624
626
|
...t,
|
|
625
|
-
isValid:
|
|
627
|
+
isValid: J(t)
|
|
626
628
|
}, e.recommendationConfigs.filters = r;
|
|
627
629
|
}
|
|
628
630
|
},
|
|
@@ -668,14 +670,14 @@ const Y = () => ({
|
|
|
668
670
|
* every block's recommendationConfigs across user edits.
|
|
669
671
|
*/
|
|
670
672
|
hasInvalidBlock() {
|
|
671
|
-
return Object.values(this.blockStates).some((t) => !
|
|
673
|
+
return Object.values(this.blockStates).some((t) => !W(t.recommendationConfigs, this));
|
|
672
674
|
},
|
|
673
675
|
/**
|
|
674
676
|
* Which required fields are missing across the design's blocks, so the save
|
|
675
677
|
* toaster can name the cause instead of always showing the generic message.
|
|
676
678
|
*/
|
|
677
679
|
invalidBlockFields() {
|
|
678
|
-
return Object.values(this.blockStates).flatMap((t) =>
|
|
680
|
+
return Object.values(this.blockStates).flatMap((t) => Q(t.recommendationConfigs, this));
|
|
679
681
|
},
|
|
680
682
|
// ====================================================================
|
|
681
683
|
// Per-Block Product Fetching
|
|
@@ -720,7 +722,7 @@ const Y = () => ({
|
|
|
720
722
|
this._setBlockProducts(e, [], s);
|
|
721
723
|
return;
|
|
722
724
|
}
|
|
723
|
-
const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S =
|
|
725
|
+
const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S = F().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", c = {
|
|
724
726
|
locale: r.language,
|
|
725
727
|
currency: r.currencySettings.value,
|
|
726
728
|
partnerName: o.partnerName,
|
|
@@ -728,9 +730,9 @@ const Y = () => ({
|
|
|
728
730
|
details: !0,
|
|
729
731
|
campaignId: o.variationId
|
|
730
732
|
};
|
|
731
|
-
r.strategy === "manualMerchandising" ? c.productId =
|
|
733
|
+
r.strategy === "manualMerchandising" ? c.productId = H(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), d && (c.filter = d), r.shuffleProducts && (c.shuffle = !0), Object.assign(
|
|
732
734
|
c,
|
|
733
|
-
|
|
735
|
+
K(o.partnerName, r.strategy)
|
|
734
736
|
);
|
|
735
737
|
let g;
|
|
736
738
|
try {
|
|
@@ -780,7 +782,7 @@ const Y = () => ({
|
|
|
780
782
|
const n = (m.get(t) ?? 0) + 1;
|
|
781
783
|
m.set(t, n);
|
|
782
784
|
const r = this._loadStrategyProducts(t, n, e);
|
|
783
|
-
return
|
|
785
|
+
return D.set(t, { token: n, outcome: r }), r;
|
|
784
786
|
},
|
|
785
787
|
async _loadStrategyProducts(t, e, { keepOnFailure: n = !1 }) {
|
|
786
788
|
const { recommendationConfigs: r } = this.blockStates[t];
|
|
@@ -798,20 +800,20 @@ const Y = () => ({
|
|
|
798
800
|
} catch {
|
|
799
801
|
o = [];
|
|
800
802
|
}
|
|
801
|
-
return m.get(t) !== e ?
|
|
803
|
+
return m.get(t) !== e ? X(t) : !o.length && n ? !1 : (this._setBlockProducts(t, o, i), o.length > 0);
|
|
802
804
|
},
|
|
803
805
|
_setBlockProducts(t, e, n) {
|
|
804
806
|
if (!this.blockStates[t])
|
|
805
807
|
return;
|
|
806
|
-
const r = e.length > 0 ? e :
|
|
808
|
+
const r = e.length > 0 ? e : w(n);
|
|
807
809
|
this.blockStates[t].recommendationProducts = [
|
|
808
810
|
...r.slice(0, n),
|
|
809
|
-
...
|
|
811
|
+
...w(Math.max(0, n - r.length))
|
|
810
812
|
];
|
|
811
813
|
}
|
|
812
814
|
}
|
|
813
815
|
});
|
|
814
816
|
export {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
+
Y as disposeStrategyPageReturnListeners,
|
|
818
|
+
pt as useRecommendationExtensionStore
|
|
817
819
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { useHttp as y } from "../composables/useHttp.js";
|
|
2
|
-
import { MIGRATION_PATHS as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { MIGRATION_PATHS as g, URLS as i, QUERY_PARAMS as u } from "../enums/extensions/recommendationBlock.js";
|
|
3
|
+
import { isPlainObject as l } from "../utils/genericUtil.js";
|
|
4
|
+
const R = "[sr_strategies.status][=][active]*[sr_strategies.suitable_channels][~][EMAIL]", h = (r) => r.reduce(
|
|
5
|
+
(s, n, d) => (s[d] = {
|
|
6
|
+
attributeName: n.attributeName,
|
|
7
|
+
attributeJs: n.attributeJs,
|
|
8
|
+
attributeType: n.attributeType,
|
|
9
|
+
type: n.type,
|
|
10
|
+
displayName: n.displayName,
|
|
11
|
+
isFilterable: n.isFilterable
|
|
11
12
|
}, s),
|
|
12
13
|
{}
|
|
13
|
-
),
|
|
14
|
-
const { get: r, post: s } = y(), { get:
|
|
14
|
+
), p = (r) => r && typeof r == "object" && "data" in r ? r.data : r, b = () => {
|
|
15
|
+
const { get: r, post: s } = y(), { get: n } = y({ headers: {} }), d = "6KcLM9TwheVB1mgK";
|
|
15
16
|
return {
|
|
16
17
|
fetchRecommendationCreateData: async () => {
|
|
17
18
|
try {
|
|
18
|
-
|
|
19
|
+
const e = await r(`${i.NEWSLETTER_RECOMMENDATIONS_PATH}/create-data`);
|
|
20
|
+
if (!l(e.data) || !Array.isArray(e.data.activePredictiveAlgorithms))
|
|
21
|
+
throw new Error("[Guido] create-data returned an unexpected body");
|
|
22
|
+
return e.data;
|
|
19
23
|
} catch (e) {
|
|
20
24
|
throw console.error("fetchUserModalState error:", e), e;
|
|
21
25
|
}
|
|
@@ -24,34 +28,34 @@ const g = "[sr_strategies.status][=][active]*[sr_strategies.suitable_channels][~
|
|
|
24
28
|
try {
|
|
25
29
|
const { data: e } = await r(
|
|
26
30
|
i.PRODUCT_ATTRIBUTES_PATH
|
|
27
|
-
),
|
|
28
|
-
return
|
|
31
|
+
), o = Array.isArray(e) ? e : (e == null ? void 0 : e.data) ?? [];
|
|
32
|
+
return h(o);
|
|
29
33
|
} catch (e) {
|
|
30
34
|
throw console.error("fetchRecommendationFilters error:", e), e;
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
|
-
fetchRecommendationProducts: async (e,
|
|
37
|
+
fetchRecommendationProducts: async (e, o) => {
|
|
34
38
|
var t;
|
|
35
39
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const m = decodeURIComponent(
|
|
40
|
+
const a = new URLSearchParams(Object.entries(o));
|
|
41
|
+
a.set(u.CLIENT_ID, d);
|
|
42
|
+
const m = decodeURIComponent(a.toString());
|
|
39
43
|
console.debug("🏁 Recommendation API Query:", m);
|
|
40
|
-
const c = await
|
|
44
|
+
const c = await n(
|
|
41
45
|
`${i.RECOMMENDATION_API_URL}/v2/${e}?${m}`
|
|
42
46
|
);
|
|
43
47
|
return ((t = c == null ? void 0 : c.data) == null ? void 0 : t.data) ?? [];
|
|
44
|
-
} catch (
|
|
45
|
-
throw console.error("fetchRecommendationProducts error:",
|
|
48
|
+
} catch (a) {
|
|
49
|
+
throw console.error("fetchRecommendationProducts error:", a), a;
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
52
|
fetchRecommendationProductsByUrl: async (e) => {
|
|
49
|
-
var
|
|
53
|
+
var o;
|
|
50
54
|
try {
|
|
51
|
-
const t = new RegExp(`[?&]${u.CLIENT_ID}=`).test(e),
|
|
55
|
+
const t = new RegExp(`[?&]${u.CLIENT_ID}=`).test(e), a = e.includes("?") ? "&" : "?", m = t ? e : `${e}${a}${u.CLIENT_ID}=${d}`, c = await n(
|
|
52
56
|
m
|
|
53
57
|
);
|
|
54
|
-
return ((
|
|
58
|
+
return ((o = c == null ? void 0 : c.data) == null ? void 0 : o.data) ?? [];
|
|
55
59
|
} catch (t) {
|
|
56
60
|
return console.error("fetchRecommendationProductsByUrl error:", t), [];
|
|
57
61
|
}
|
|
@@ -59,14 +63,14 @@ const g = "[sr_strategies.status][=][active]*[sr_strategies.suitable_channels][~
|
|
|
59
63
|
fetchRecommendationStrategies: async () => {
|
|
60
64
|
try {
|
|
61
65
|
const { data: e } = await r(
|
|
62
|
-
`${i.RECOMMENDATION_STRATEGIES_PATH}?filters=${encodeURIComponent(
|
|
66
|
+
`${i.RECOMMENDATION_STRATEGIES_PATH}?filters=${encodeURIComponent(R)}`
|
|
63
67
|
);
|
|
64
68
|
return Array.isArray(e) ? e : (e == null ? void 0 : e.data) ?? [];
|
|
65
69
|
} catch (e) {
|
|
66
70
|
throw console.error("fetchRecommendationStrategies error:", e), e;
|
|
67
71
|
}
|
|
68
72
|
},
|
|
69
|
-
generateStrategyEndpoint: async (e,
|
|
73
|
+
generateStrategyEndpoint: async (e, o) => {
|
|
70
74
|
try {
|
|
71
75
|
const { data: t } = await s(
|
|
72
76
|
`${i.RECOMMENDATION_STRATEGIES_PATH}/endpoint-generate`,
|
|
@@ -76,7 +80,7 @@ const g = "[sr_strategies.status][=][active]*[sr_strategies.suitable_channels][~
|
|
|
76
80
|
isPreviewer: !1,
|
|
77
81
|
strategy: e,
|
|
78
82
|
userId: "",
|
|
79
|
-
currency:
|
|
83
|
+
currency: o
|
|
80
84
|
}
|
|
81
85
|
);
|
|
82
86
|
return !t || typeof t != "object" || !("full_path" in t || "data" in t) ? (console.error("generateStrategyEndpoint unexpected response shape:", t), null) : "full_path" in t ? t : t.data;
|
|
@@ -84,17 +88,17 @@ const g = "[sr_strategies.status][=][active]*[sr_strategies.suitable_channels][~
|
|
|
84
88
|
return console.error("generateStrategyEndpoint error:", t), null;
|
|
85
89
|
}
|
|
86
90
|
},
|
|
87
|
-
migrateLegacyStrategy: async (e,
|
|
91
|
+
migrateLegacyStrategy: async (e, o = { scope: "campaign" }) => {
|
|
88
92
|
const { data: t } = await s(
|
|
89
|
-
|
|
93
|
+
g[o.scope],
|
|
90
94
|
e
|
|
91
|
-
), { strategyId:
|
|
92
|
-
if (
|
|
95
|
+
), { strategyId: a } = p(t) ?? {};
|
|
96
|
+
if (a == null || a === "")
|
|
93
97
|
throw new Error("[Guido] migrate-strategies returned no strategyId");
|
|
94
|
-
return String(
|
|
98
|
+
return String(a);
|
|
95
99
|
}
|
|
96
100
|
};
|
|
97
101
|
};
|
|
98
102
|
export {
|
|
99
|
-
|
|
103
|
+
b as useRecommendationApi
|
|
100
104
|
};
|
|
@@ -6,58 +6,60 @@ import { useTranslations as P } from "../composables/useTranslations.js";
|
|
|
6
6
|
import { useHtmlDocumentCountValidator as L } from "../composables/validators/useHtmlDocumentCountValidator.js";
|
|
7
7
|
import { useLiquidValidator as N } from "../composables/validators/useLiquidValidator.js";
|
|
8
8
|
import { EditorType as H } from "../enums/defaults.js";
|
|
9
|
-
import { ToasterTypeOptions as
|
|
9
|
+
import { ToasterTypeOptions as w } from "../enums/toaster.js";
|
|
10
10
|
import { useRecommendationExtensionStore as D } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
|
-
import { useSaveAsTemplateStore as
|
|
11
|
+
import { useSaveAsTemplateStore as F } from "../stores/save-as-template.js";
|
|
12
12
|
import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
|
|
13
|
-
import { isPlainObject as
|
|
14
|
-
import { useTemplatePreparation as
|
|
13
|
+
import { isPlainObject as c } from "../utils/genericUtil.js";
|
|
14
|
+
import { useTemplatePreparation as q } from "../utils/templatePreparation.js";
|
|
15
15
|
const Z = () => {
|
|
16
|
-
const { get:
|
|
16
|
+
const { get: p, post: u } = E(), { handleError: s, showToaster: i } = x(), { config: d, isFeatureEnabled: y } = S(), { validateLiquidSyntax: b } = N(), { validateSingleHtmlDocument: h } = L(), { getTemplateData: C } = A(), n = P();
|
|
17
17
|
return {
|
|
18
18
|
getCategories: async () => {
|
|
19
19
|
try {
|
|
20
|
-
const { data: e } = await
|
|
21
|
-
return Array.isArray(e) ? e : ((!
|
|
20
|
+
const { data: e } = await p("/newsletter/template-library/get-template-categories");
|
|
21
|
+
return Array.isArray(e) ? e : ((!c(e) || e.type !== "alert") && console.error("[TEMPLATE_LIBRARY_API] Unexpected get-template-categories response", e), i({
|
|
22
22
|
message: n("newsletter.template-library-service-error"),
|
|
23
|
-
type:
|
|
23
|
+
type: w.Error
|
|
24
24
|
}), []);
|
|
25
25
|
} catch (e) {
|
|
26
|
-
return
|
|
26
|
+
return s(e, "Failed to fetch template categories"), [];
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
checkTemplateNameAvailability: async (e) => {
|
|
30
|
-
|
|
31
|
-
`/newsletter/template-library/template-name-exists?name=${e}`
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
try {
|
|
31
|
+
const { data: t } = await p(`/newsletter/template-library/template-name-exists?name=${e}`);
|
|
32
|
+
return !(c(t) ? !!t.status : !1);
|
|
33
|
+
} catch (t) {
|
|
34
|
+
return s(t, "Failed to check template name"), !1;
|
|
35
|
+
}
|
|
34
36
|
},
|
|
35
37
|
createCategory: async (e) => {
|
|
36
38
|
try {
|
|
37
|
-
const { data: { id: t } } = await
|
|
39
|
+
const { data: { id: t } } = await u(
|
|
38
40
|
"/newsletter/template-library/create-category",
|
|
39
41
|
{ name: e }
|
|
40
42
|
);
|
|
41
43
|
return t.toString();
|
|
42
44
|
} catch (t) {
|
|
43
|
-
return
|
|
45
|
+
return s(t, "Failed to create category"), "";
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
48
|
createTemplate: async () => {
|
|
47
|
-
var e, t,
|
|
49
|
+
var e, t, m, g;
|
|
48
50
|
try {
|
|
49
|
-
const { prepareTemplateDetails:
|
|
50
|
-
if (!
|
|
51
|
+
const { prepareTemplateDetails: l } = q(), o = F(), f = await C();
|
|
52
|
+
if (!h(f.html))
|
|
51
53
|
return !1;
|
|
52
|
-
const a = await
|
|
53
|
-
if (
|
|
54
|
+
const a = await l(f);
|
|
55
|
+
if (y("liquidSyntax") && !await b(a.compiledHtml))
|
|
54
56
|
return !1;
|
|
55
57
|
const v = {
|
|
56
|
-
name:
|
|
57
|
-
categories:
|
|
58
|
-
productId: ((t = (e =
|
|
58
|
+
name: o.getTemplateName,
|
|
59
|
+
categories: o.getSelectedCategoryIds,
|
|
60
|
+
productId: ((t = (e = d.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
|
|
59
61
|
editorType: H,
|
|
60
|
-
messageType: ((
|
|
62
|
+
messageType: ((g = (m = d.value) == null ? void 0 : m.partner) == null ? void 0 : g.messageType) || 0,
|
|
61
63
|
content: r(a.compiledHtml),
|
|
62
64
|
css: r(a.css),
|
|
63
65
|
unsubscriptionPreferencePageStatus: !1,
|
|
@@ -68,34 +70,34 @@ const Z = () => {
|
|
|
68
70
|
recommendationConfigs: r({}),
|
|
69
71
|
isGuido: !0,
|
|
70
72
|
// eslint-disable-next-line camelcase
|
|
71
|
-
template_engine:
|
|
73
|
+
template_engine: y("liquidSyntax") ? 1 : 0,
|
|
72
74
|
stripoConfig: r({
|
|
73
75
|
editor: "stripo",
|
|
74
76
|
html: a.rawHtml,
|
|
75
77
|
css: a.css,
|
|
76
78
|
dynamicContentList: a.dynamicContentList
|
|
77
79
|
})
|
|
78
|
-
}, { data:
|
|
80
|
+
}, { data: T } = await u(
|
|
79
81
|
"/newsletter/template-library/create-template",
|
|
80
82
|
v
|
|
81
83
|
);
|
|
82
|
-
if (!
|
|
84
|
+
if (!c(T))
|
|
83
85
|
throw new Error("Unexpected create-template response");
|
|
84
|
-
return
|
|
86
|
+
return T.type === "alert" ? (i({
|
|
85
87
|
message: n(
|
|
86
88
|
"newsletter.template-library-save-alert",
|
|
87
|
-
{ templateName:
|
|
89
|
+
{ templateName: o.getTemplateName }
|
|
88
90
|
),
|
|
89
|
-
type:
|
|
91
|
+
type: w.Error
|
|
90
92
|
}), !1) : (i({
|
|
91
93
|
message: n(
|
|
92
94
|
"newsletter.template-library-save-success",
|
|
93
|
-
{ templateName:
|
|
95
|
+
{ templateName: o.getTemplateName }
|
|
94
96
|
),
|
|
95
97
|
type: "success"
|
|
96
98
|
}), !0);
|
|
97
|
-
} catch (
|
|
98
|
-
return
|
|
99
|
+
} catch (l) {
|
|
100
|
+
return s(l, "Failed to create template"), !1;
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
};
|
|
@@ -4,6 +4,7 @@ export interface AuthErrorState {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const isPanelOrigin: (url: string) => boolean;
|
|
6
6
|
export declare const reportAuthError: (status: number, body: string, url: string) => void;
|
|
7
|
+
export declare const reportProductRefusal: (data: Record<string, unknown>) => void;
|
|
7
8
|
export declare const useAuthError: () => {
|
|
8
9
|
authError: import("vue").Ref<{
|
|
9
10
|
status: number;
|
|
@@ -49,5 +49,5 @@ export declare function findInvalidCustomFields(html: string, validCustomFields:
|
|
|
49
49
|
*/
|
|
50
50
|
export declare function getInvalidDynamicContentTags(html: string): string[];
|
|
51
51
|
export declare const useHtmlValidator: () => {
|
|
52
|
-
validateHtml: (html: string, customFields: DynamicContent[], isOnSaveValidation?: boolean) => Promise<boolean>;
|
|
52
|
+
validateHtml: (html: string, customFields: DynamicContent[], isOnSaveValidation?: boolean, silent?: boolean) => Promise<boolean>;
|
|
53
53
|
};
|