@useinsider/guido 3.15.0-beta.0b5dc39 → 3.15.0-beta.0cbd17f
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/useRecommendation.js +20 -19
- package/dist/composables/useStripo.js +29 -30
- package/dist/extensions/Blocks/Items/block.js +44 -42
- package/dist/extensions/Blocks/Items/template.js +86 -86
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +21 -21
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -12
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/utils/pairProductVariables.js +105 -99
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
|
|
2
2
|
import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
|
|
3
3
|
import { useConfigStore as G } from "../../../../stores/config.js";
|
|
4
|
-
import { defineStore as
|
|
4
|
+
import { defineStore as P } from "pinia";
|
|
5
5
|
import "../constants/selectors.js";
|
|
6
|
-
import { DEFAULT_MOBILE_CARDS_IN_ROW as
|
|
6
|
+
import { DEFAULT_MOBILE_CARDS_IN_ROW as F, DEFAULT_CARDS_IN_ROW as D } from "../constants/layout.js";
|
|
7
7
|
import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
|
|
8
8
|
import { getDefaultProducts as S } from "../templates/utils.js";
|
|
9
9
|
import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
|
|
10
10
|
import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { sanitizeProductIds as N } from "../utils/productIds.js";
|
|
12
|
+
import { isFilterValid as x } from "../validation/filterSchema.js";
|
|
13
|
+
import { isConfigValid as L } from "../validation/requiredFields.js";
|
|
13
14
|
const h = y();
|
|
14
15
|
let m = null, u = null, d = null;
|
|
15
16
|
function k() {
|
|
@@ -28,7 +29,7 @@ function k() {
|
|
|
28
29
|
productIds: [],
|
|
29
30
|
id: 1,
|
|
30
31
|
language: "en_US",
|
|
31
|
-
mobileCardsInRow:
|
|
32
|
+
mobileCardsInRow: F,
|
|
32
33
|
mobileLayoutEnabled: !1,
|
|
33
34
|
orientation: "grid",
|
|
34
35
|
recommendedProducts: [],
|
|
@@ -54,7 +55,7 @@ function I() {
|
|
|
54
55
|
filterSnapshot: null
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
const
|
|
58
|
+
const U = () => ({
|
|
58
59
|
recommendationCampaignUrls: {},
|
|
59
60
|
activePredictiveAlgorithms: [],
|
|
60
61
|
languages: {},
|
|
@@ -63,8 +64,8 @@ const L = () => ({
|
|
|
63
64
|
blockStates: {},
|
|
64
65
|
currentRecommendationId: null,
|
|
65
66
|
configVersion: 0
|
|
66
|
-
}),
|
|
67
|
-
state: () =>
|
|
67
|
+
}), H = P("guidoRecommendationExtension", {
|
|
68
|
+
state: () => U(),
|
|
68
69
|
getters: {
|
|
69
70
|
// ====================================================================
|
|
70
71
|
// Proxy Getters — Backward Compatible Access to Current Block State
|
|
@@ -383,7 +384,7 @@ const L = () => ({
|
|
|
383
384
|
const n = [...e.recommendationConfigs.filters];
|
|
384
385
|
n[r] = {
|
|
385
386
|
...t,
|
|
386
|
-
isValid:
|
|
387
|
+
isValid: x(t)
|
|
387
388
|
}, e.recommendationConfigs.filters = n;
|
|
388
389
|
}
|
|
389
390
|
},
|
|
@@ -429,7 +430,7 @@ const L = () => ({
|
|
|
429
430
|
* every block's recommendationConfigs across user edits.
|
|
430
431
|
*/
|
|
431
432
|
hasInvalidBlock() {
|
|
432
|
-
return Object.values(this.blockStates).some((t) => !
|
|
433
|
+
return Object.values(this.blockStates).some((t) => !L(t.recommendationConfigs, this));
|
|
433
434
|
},
|
|
434
435
|
// ====================================================================
|
|
435
436
|
// Per-Block Product Fetching
|
|
@@ -458,7 +459,7 @@ const L = () => ({
|
|
|
458
459
|
details: !0,
|
|
459
460
|
campaignId: o.variationId
|
|
460
461
|
};
|
|
461
|
-
r.strategy === "manualMerchandising" ? a.productId = r.productIds
|
|
462
|
+
r.strategy === "manualMerchandising" ? a.productId = N(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
|
|
462
463
|
a,
|
|
463
464
|
v(o.partnerName, r.strategy)
|
|
464
465
|
);
|
|
@@ -479,5 +480,5 @@ const L = () => ({
|
|
|
479
480
|
}
|
|
480
481
|
});
|
|
481
482
|
export {
|
|
482
|
-
|
|
483
|
+
H as useRecommendationExtensionStore
|
|
483
484
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the request/URL `productId` value from raw product ID segments.
|
|
3
|
+
* Trimming happens here — NOT on input change — so the user's in-progress
|
|
4
|
+
* text (trailing commas, spaces) is never rewritten under the caret (SD-147111).
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizeProductIds(ids: readonly (string | number | null | undefined)[]): string;
|
|
@@ -1,88 +1,100 @@
|
|
|
1
|
-
import { productPairs as
|
|
2
|
-
import { DefaultConfigValues as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
2
|
+
import { DefaultConfigValues as V } from "../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
3
|
+
import { escapeReplacement as G } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
|
+
import { preserveTextStyles as F } from "./preserveTextStyles.js";
|
|
5
|
+
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
6
|
+
const x = {
|
|
7
|
+
CART_ITEMS: "ins_apr",
|
|
8
|
+
BROWSED_ITEMS: "browsed_item",
|
|
9
|
+
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
+
}, N = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(S, H, g) {
|
|
12
|
+
let $ = H;
|
|
13
|
+
for (; $ > 0 && /\s/.test(S[$ - 1]); )
|
|
14
|
+
$ -= 1;
|
|
15
|
+
return g.some((I) => S.endsWith(I, $));
|
|
16
|
+
}
|
|
17
|
+
function J(S) {
|
|
18
|
+
const H = N(S), g = new DOMParser().parseFromString(H, "text/html");
|
|
19
|
+
X(g);
|
|
20
|
+
const $ = L.PAIRS_FOR_EXTENSION;
|
|
21
|
+
Object.entries($).forEach(([n, d]) => {
|
|
22
|
+
g.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
23
|
+
const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
|
|
24
|
+
r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
|
|
25
|
+
var T, P, D;
|
|
26
|
+
const R = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, f = d[R];
|
|
27
|
+
if (f)
|
|
28
|
+
switch (n) {
|
|
17
29
|
case "imageSrc": {
|
|
18
|
-
let e = null,
|
|
19
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
30
|
+
let e = null, s = null;
|
|
31
|
+
if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
|
|
20
32
|
break;
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
}) && (e.src = `{{${
|
|
33
|
+
const a = f.DEFAULT, l = f.ATTR;
|
|
34
|
+
if (a && e.src) {
|
|
35
|
+
const i = e.src;
|
|
36
|
+
a.some((b) => {
|
|
37
|
+
const u = b.split("/").pop() || "", y = i.split("/").pop() || "";
|
|
38
|
+
return i.includes(b) || i.includes(u) || y === u;
|
|
39
|
+
}) && (e.src = `{{${l}_${o}}}`);
|
|
28
40
|
}
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
const
|
|
34
|
-
(
|
|
41
|
+
const c = (P = (T = $.name) == null ? void 0 : T[R]) == null ? void 0 : P.ATTR;
|
|
42
|
+
if (c && e.setAttribute("alt", `{{${c}_${o}}}`), s) {
|
|
43
|
+
const i = (D = $.itemLink) == null ? void 0 : D[R];
|
|
44
|
+
if (i) {
|
|
45
|
+
const _ = i.HREF, b = i.DEFAULT_HREF || "#!", u = s.href;
|
|
46
|
+
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(b) || u === `${window.location.href}${b}` || !u || u === window.location.href) && (s.href = `{{${_}_${o}}}`);
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
49
|
break;
|
|
38
50
|
}
|
|
39
51
|
case "name": {
|
|
40
|
-
const e =
|
|
41
|
-
t.textContent && (t.innerHTML =
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
(
|
|
52
|
+
const e = f, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
|
|
53
|
+
t.textContent && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
54
|
+
const c = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
55
|
+
if (c && l) {
|
|
56
|
+
const i = c.href, _ = `${window.location.href}${a}`;
|
|
57
|
+
(i === _ || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
|
|
46
58
|
}
|
|
47
59
|
break;
|
|
48
60
|
}
|
|
49
61
|
case "price":
|
|
50
62
|
case "originalPrice": {
|
|
51
|
-
const e =
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
const
|
|
57
|
-
let
|
|
58
|
-
|
|
63
|
+
const e = f, s = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), l = s === "true", c = a === "true", i = t.getAttribute("data-curency") || "before";
|
|
64
|
+
let _;
|
|
65
|
+
c ? _ = l ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : _ = l ? e.PRICE_FORMATTED : e.PRICE;
|
|
66
|
+
const b = e.CURRENCY;
|
|
67
|
+
let u = `{{${_}_${o}}}`;
|
|
68
|
+
const y = (t.getAttribute("data-currency_symbol") || "").trim(), W = y !== "" && y !== V.productPriceCurrencySymbolControlValue;
|
|
69
|
+
let C = "";
|
|
70
|
+
W ? C = y : b && (C = `{{${b}_${o}}}`), C && (u = i === "after" ? `${u} ${C}` : `${C} ${u}`), t.innerHTML = F(t, u);
|
|
59
71
|
break;
|
|
60
72
|
}
|
|
61
73
|
case "quantity": {
|
|
62
|
-
const e =
|
|
63
|
-
t.textContent && t.textContent.trim() ===
|
|
74
|
+
const e = f, s = e.ATTR, a = e.DEFAULT;
|
|
75
|
+
t.textContent && t.textContent.trim() === a && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
64
76
|
break;
|
|
65
77
|
}
|
|
66
78
|
case "button": {
|
|
67
|
-
const e =
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
(
|
|
79
|
+
const e = f, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
|
|
80
|
+
if (l) {
|
|
81
|
+
const c = l.href || "", i = `${window.location.href}${a}`;
|
|
82
|
+
(c === "" || c === "#" || c === i || c.endsWith(a) || c.endsWith("#!") || c === window.location.href) && (l.href = `{{${s}_${o}}}`);
|
|
71
83
|
}
|
|
72
84
|
break;
|
|
73
85
|
}
|
|
74
86
|
case "itemLink": {
|
|
75
|
-
const e =
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
(
|
|
87
|
+
const e = f, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
|
|
88
|
+
if (l.href) {
|
|
89
|
+
const c = l.href, i = `${window.location.href}${a}`;
|
|
90
|
+
(c === i || c.endsWith(a)) && (l.href = `{{${s}_${o}}}`);
|
|
79
91
|
}
|
|
80
92
|
break;
|
|
81
93
|
}
|
|
82
94
|
default: {
|
|
83
|
-
if ("ATTR" in
|
|
84
|
-
const e =
|
|
85
|
-
t.textContent && (t.innerHTML =
|
|
95
|
+
if ("ATTR" in f) {
|
|
96
|
+
const e = f.ATTR;
|
|
97
|
+
t.textContent && (t.innerHTML = F(t, `{{${e}_${o}}}`));
|
|
86
98
|
}
|
|
87
99
|
break;
|
|
88
100
|
}
|
|
@@ -90,55 +102,49 @@ function Y(L) {
|
|
|
90
102
|
});
|
|
91
103
|
});
|
|
92
104
|
});
|
|
93
|
-
const
|
|
94
|
-
` : "",
|
|
95
|
-
|
|
96
|
-
const
|
|
105
|
+
const I = H.match(/<!DOCTYPE[^>]*>/i), O = I ? `${I[0]}
|
|
106
|
+
` : "", q = g.querySelectorAll(".ins-product-td"), M = [];
|
|
107
|
+
q.forEach((n) => {
|
|
108
|
+
const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
|
|
97
109
|
M.push({
|
|
98
|
-
element:
|
|
99
|
-
outerHtml:
|
|
100
|
-
type:
|
|
110
|
+
element: n,
|
|
111
|
+
outerHtml: r,
|
|
112
|
+
type: d,
|
|
101
113
|
number: p
|
|
102
114
|
});
|
|
103
115
|
});
|
|
104
|
-
let
|
|
105
|
-
M.reverse().forEach(({ outerHtml:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
break;
|
|
111
|
-
case "BROWSED_ITEMS":
|
|
112
|
-
l = "browsed_item_total_product_kind";
|
|
113
|
-
break;
|
|
114
|
-
case "PURCHASED_ITEMS":
|
|
115
|
-
l = "purchased_item_total_product_kind";
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (l) {
|
|
119
|
-
const $ = parseInt(p) - 1, T = `${`{% if ${l} > ${$} %}`}${r}{% endif %}`;
|
|
120
|
-
_ = _.replace(r, T);
|
|
116
|
+
let A = O + g.documentElement.outerHTML;
|
|
117
|
+
M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
|
|
118
|
+
const r = x[d], E = r ? `${r}_total_product_kind` : "";
|
|
119
|
+
if (E) {
|
|
120
|
+
const h = parseInt(p) - 1, o = `${`{% if ${E} > ${h} %}`}${n}{% endif %}`;
|
|
121
|
+
A = A.replace(n, G(o));
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
|
-
const
|
|
124
|
-
return
|
|
125
|
-
var
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
124
|
+
const U = g.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
|
|
125
|
+
return U.forEach((n) => {
|
|
126
|
+
var t;
|
|
127
|
+
const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
|
|
128
|
+
if (!d || !x[p])
|
|
128
129
|
return;
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
130
|
+
const r = n.closest(".product-original-price-class");
|
|
131
|
+
if (!r || k.has(r))
|
|
132
|
+
return;
|
|
133
|
+
k.add(r);
|
|
134
|
+
const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), h = w.get(E) ?? { number: d, type: p, wrap: [] };
|
|
135
|
+
h.wrap.push(m !== "false"), w.set(E, h);
|
|
136
|
+
}), w.forEach(({ number: n, type: d, wrap: p }, r) => {
|
|
137
|
+
if (r.includes("{% if") || !p.some(Boolean))
|
|
138
|
+
return;
|
|
139
|
+
const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, h = `{% if ${E}_${n} != ${m}_${n} %}`, t = [h, N(h)];
|
|
140
|
+
let R = "", o = 0, f = 0, T = A.indexOf(r);
|
|
141
|
+
for (; T !== -1; ) {
|
|
142
|
+
const P = p[f] === !0 && !v(A, T, t);
|
|
143
|
+
R += A.slice(o, T) + (P ? `${h}${r}{% endif %}` : r), o = T + r.length, f += 1, T = A.indexOf(r, o);
|
|
139
144
|
}
|
|
140
|
-
|
|
145
|
+
A = R + A.slice(o);
|
|
146
|
+
}), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
141
147
|
}
|
|
142
148
|
export {
|
|
143
|
-
|
|
149
|
+
J as pairProductVariables
|
|
144
150
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.15.0-beta.
|
|
3
|
+
"version": "3.15.0-beta.0cbd17f",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|