@soma-vertical-web/multi-lib 0.0.32 → 0.0.34
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/__vite-browser-external-CpdIDx9o.mjs +79 -0
- package/__vite-browser-external-DDWPeg5L.js +1 -0
- package/constants.d.ts +32 -0
- package/contexts/contexts/search/Facets.d.ts +5 -0
- package/contexts/contexts/search/Products.d.ts +5 -0
- package/contexts/contexts/search/Root.d.ts +5 -0
- package/contexts/contexts/search/Search.d.ts +5 -0
- package/contexts/contexts/search/SuggestedTerms.d.ts +5 -0
- package/contexts/contexts/search/TopSearches.d.ts +6 -0
- package/contexts/index.d.ts +24 -0
- package/data/api/fetchVtex.d.ts +2 -1
- package/data/api/search/autoCompleteSuggestions/index.d.ts +11 -0
- package/data/api/search/crosseling/index.d.ts +91 -0
- package/data/api/search/facets/index.d.ts +4 -0
- package/data/api/search/index.d.ts +6 -0
- package/data/api/search/product/index.d.ts +3 -0
- package/data/api/search/searchFetch.d.ts +3 -0
- package/data/api/search/suggestedTerms/index.d.ts +12 -0
- package/data/api/search/topSearch/index.d.ts +3 -0
- package/data/helpers/search/facets.d.ts +48 -0
- package/data/helpers/search/index.d.ts +12 -0
- package/data/helpers/search/product/index.d.ts +279 -0
- package/data/helpers/search/product/utils/canonical.d.ts +1 -0
- package/data/helpers/search/product/utils/enhanceSku.d.ts +9 -0
- package/data/helpers/search/product/utils/images.d.ts +7 -0
- package/data/helpers/search/product/utils/index.d.ts +8 -0
- package/data/helpers/search/product/utils/productStock.d.ts +7 -0
- package/data/helpers/search/product/utils/propertyValue.d.ts +20 -0
- package/data/helpers/search/product/utils/sanitizeHtml.d.ts +18 -0
- package/data/helpers/search/product/utils/sku.d.ts +5 -0
- package/data/helpers/search/product/utils/slugify.d.ts +1 -0
- package/data/helpers/search/root.d.ts +11 -0
- package/data/helpers/search/search.d.ts +7 -0
- package/index.js +19 -19
- package/index.mjs +4336 -3979
- package/index2.js +1 -1
- package/index2.mjs +891 -400
- package/package.json +1 -1
- package/server.d.ts +13 -0
- package/types/constants.d.ts +9 -15
- package/types/contexts/contexts/plp.d.ts +13 -0
- package/types/contexts/contexts/search.d.ts +10 -4
- package/types/data/api/index.d.ts +5 -2
- package/types/data/api/search/facets/index.d.ts +13 -13
- package/types/data/api/search/index.d.ts +25 -12
- package/types/data/api/search/product/index.d.ts +1 -8
- package/types/data/events/index.d.ts +0 -4
- package/types/data/helpers/index.d.ts +9 -1
- package/types/global/product/index.d.ts +5 -4
- package/types/layout/team-components/AddToCart/index.d.ts +2 -2
- package/types/layout/team-components/Sort/index.d.ts +2 -3
- package/types/data/api/search/autoCompleteSuggestions/index.d.ts +0 -7
- package/types/data/api/search/suggestedTerms/index.d.ts +0 -7
package/index2.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { f as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as n from "yup";
|
|
2
|
+
import { f as Z, a as ee, b as te, d as re, e as oe, c as ne, p as ae } from "./__vite-browser-external-CpdIDx9o.mjs";
|
|
3
|
+
import se from "sanitize-html";
|
|
4
|
+
const u = async (e, t = {}) => {
|
|
5
|
+
const { method: o = "GET", body: r, headers: s = {}, priority: a = "auto", cache: i = "default" } = t;
|
|
6
|
+
return fetch(e, {
|
|
6
7
|
method: o,
|
|
7
8
|
headers: {
|
|
8
9
|
...s,
|
|
@@ -10,49 +11,69 @@ const l = async (t, e = {}) => {
|
|
|
10
11
|
"Content-Type": "application/json"
|
|
11
12
|
},
|
|
12
13
|
priority: a,
|
|
13
|
-
|
|
14
|
+
cache: i,
|
|
15
|
+
...r ? { body: JSON.stringify(r) } : {}
|
|
14
16
|
// not body in get
|
|
15
|
-
}).then((
|
|
16
|
-
console.error("[ERROR FETCH VTEX]",
|
|
17
|
+
}).then((c) => c.json()).catch((c) => {
|
|
18
|
+
console.error("[ERROR FETCH VTEX]", c);
|
|
17
19
|
});
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
}, O = /* @__PURE__ */ new Map();
|
|
21
|
+
async function ie(e, t = {}) {
|
|
22
|
+
var o;
|
|
23
|
+
try {
|
|
24
|
+
const { abort: r = !1 } = t, s = new AbortController();
|
|
25
|
+
r && (O.has(e) && ((o = O.get(e)) == null || o.abort(), O.delete(e)), O.set(e, s));
|
|
26
|
+
const a = u(e, {
|
|
27
|
+
...t,
|
|
28
|
+
...r ? { signal: s.signal } : {}
|
|
29
|
+
});
|
|
30
|
+
return r && O.delete(e), a;
|
|
31
|
+
} catch (r) {
|
|
32
|
+
if (r.name === "AbortError") {
|
|
33
|
+
console.log(`[REQUEST CANCELLED]: ${e}`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
throw console.error(`[ERROR API]: ${r.message}`), r;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const ce = n.object({
|
|
40
|
+
country: n.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
41
|
+
postalCode: n.string().nullable()
|
|
21
42
|
});
|
|
22
|
-
async function
|
|
23
|
-
if (!
|
|
43
|
+
async function le({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
44
|
+
if (!t) {
|
|
24
45
|
console.error("[ERROR FETCHING] Body is required");
|
|
25
46
|
return;
|
|
26
47
|
}
|
|
27
|
-
await
|
|
28
|
-
const { country:
|
|
29
|
-
return await
|
|
30
|
-
`${
|
|
48
|
+
await ce.validate(t);
|
|
49
|
+
const { country: r, postalCode: s } = t;
|
|
50
|
+
return await u(
|
|
51
|
+
`${e}/api/checkout/pub/postal-code/${r}/${s}`,
|
|
31
52
|
{
|
|
32
53
|
method: "POST",
|
|
33
|
-
body:
|
|
54
|
+
body: t,
|
|
34
55
|
...o
|
|
35
56
|
}
|
|
36
57
|
);
|
|
37
58
|
}
|
|
38
|
-
const
|
|
39
|
-
orderFormId:
|
|
40
|
-
sellerCode:
|
|
41
|
-
sellerName:
|
|
59
|
+
const ue = n.object({
|
|
60
|
+
orderFormId: n.string().nullable(),
|
|
61
|
+
sellerCode: n.string().nullable(),
|
|
62
|
+
sellerName: n.string().nullable()
|
|
42
63
|
});
|
|
43
|
-
async function
|
|
44
|
-
apiUrl:
|
|
45
|
-
body:
|
|
64
|
+
async function B({
|
|
65
|
+
apiUrl: e,
|
|
66
|
+
body: t,
|
|
46
67
|
fetchOptions: o
|
|
47
68
|
}) {
|
|
48
|
-
if (!
|
|
69
|
+
if (!t) {
|
|
49
70
|
console.error("[ERROR FETCHING] Body is required");
|
|
50
71
|
return;
|
|
51
72
|
}
|
|
52
|
-
await
|
|
53
|
-
const { orderFormId:
|
|
54
|
-
return
|
|
55
|
-
`${
|
|
73
|
+
await ue.validate(t);
|
|
74
|
+
const { orderFormId: r, sellerCode: s, sellerName: a } = t, i = s ? `${s.trim()} - ${a}` : null;
|
|
75
|
+
return u(
|
|
76
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/openTextField`,
|
|
56
77
|
{
|
|
57
78
|
method: "POST",
|
|
58
79
|
body: {
|
|
@@ -62,23 +83,23 @@ async function b({
|
|
|
62
83
|
}
|
|
63
84
|
);
|
|
64
85
|
}
|
|
65
|
-
const
|
|
66
|
-
orderFormId:
|
|
67
|
-
sellerCode:
|
|
68
|
-
marketingData:
|
|
86
|
+
const de = n.object({
|
|
87
|
+
orderFormId: n.string().nullable(),
|
|
88
|
+
sellerCode: n.string().nullable(),
|
|
89
|
+
marketingData: n.object()
|
|
69
90
|
});
|
|
70
|
-
async function
|
|
71
|
-
if (!
|
|
91
|
+
async function U({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
92
|
+
if (!t) {
|
|
72
93
|
console.error("[ERROR FETCHING] Body is required");
|
|
73
94
|
return;
|
|
74
95
|
}
|
|
75
|
-
await
|
|
76
|
-
const { orderFormId:
|
|
96
|
+
await de.validate(t);
|
|
97
|
+
const { orderFormId: r, sellerCode: s, marketingData: a } = t, i = s ? {
|
|
77
98
|
utmCampaign: s ? s.toUpperCase() : "",
|
|
78
99
|
utmiCampaign: s ? "codigodavendedora" : "semcodigo"
|
|
79
100
|
} : {};
|
|
80
|
-
return
|
|
81
|
-
`${
|
|
101
|
+
return u(
|
|
102
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/marketingData`,
|
|
82
103
|
{
|
|
83
104
|
method: "POST",
|
|
84
105
|
body: {
|
|
@@ -89,104 +110,104 @@ async function F({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
89
110
|
}
|
|
90
111
|
);
|
|
91
112
|
}
|
|
92
|
-
const
|
|
93
|
-
orderFormId:
|
|
94
|
-
sellerCode:
|
|
95
|
-
sellerName:
|
|
113
|
+
const me = n.object({
|
|
114
|
+
orderFormId: n.string().nullable(),
|
|
115
|
+
sellerCode: n.string().nullable(),
|
|
116
|
+
sellerName: n.string().nullable()
|
|
96
117
|
});
|
|
97
|
-
async function
|
|
98
|
-
if (!
|
|
118
|
+
async function pe({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
119
|
+
if (!t) {
|
|
99
120
|
console.error("[ERROR FETCHING] Body is required");
|
|
100
121
|
return;
|
|
101
122
|
}
|
|
102
|
-
await
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
apiUrl:
|
|
123
|
+
await me.validate(t);
|
|
124
|
+
const r = await B({ apiUrl: e, body: t, fetchOptions: o });
|
|
125
|
+
return U({
|
|
126
|
+
apiUrl: e,
|
|
106
127
|
body: {
|
|
107
|
-
...
|
|
108
|
-
marketingData:
|
|
128
|
+
...t,
|
|
129
|
+
marketingData: r == null ? void 0 : r.marketingData
|
|
109
130
|
},
|
|
110
131
|
fetchOptions: o
|
|
111
132
|
});
|
|
112
133
|
}
|
|
113
|
-
const
|
|
114
|
-
orderFormId:
|
|
115
|
-
coupon:
|
|
134
|
+
const ge = n.object({
|
|
135
|
+
orderFormId: n.string().nullable(),
|
|
136
|
+
coupon: n.string().nullable()
|
|
116
137
|
});
|
|
117
|
-
async function
|
|
118
|
-
apiUrl:
|
|
119
|
-
body:
|
|
138
|
+
async function fe({
|
|
139
|
+
apiUrl: e,
|
|
140
|
+
body: t,
|
|
120
141
|
fetchOptions: o
|
|
121
142
|
}) {
|
|
122
|
-
if (!
|
|
143
|
+
if (!t) {
|
|
123
144
|
console.error("[ERROR FETCHING] Body is required");
|
|
124
145
|
return;
|
|
125
146
|
}
|
|
126
|
-
await
|
|
127
|
-
const { coupon:
|
|
128
|
-
return
|
|
129
|
-
`${
|
|
147
|
+
await ge.validate(t);
|
|
148
|
+
const { coupon: r = "", orderFormId: s } = t;
|
|
149
|
+
return u(
|
|
150
|
+
`${e}/api/checkout/pub/orderForm/${s}/coupons`,
|
|
130
151
|
{
|
|
131
152
|
method: "POST",
|
|
132
|
-
body: { text:
|
|
153
|
+
body: { text: r },
|
|
133
154
|
...o
|
|
134
155
|
}
|
|
135
156
|
);
|
|
136
157
|
}
|
|
137
|
-
const
|
|
138
|
-
appId:
|
|
139
|
-
orderFormId:
|
|
140
|
-
key:
|
|
158
|
+
const he = n.object({
|
|
159
|
+
appId: n.string().required("App ID is required"),
|
|
160
|
+
orderFormId: n.string().nullable(),
|
|
161
|
+
key: n.array().of(n.string())
|
|
141
162
|
});
|
|
142
|
-
async function
|
|
143
|
-
apiUrl:
|
|
144
|
-
body:
|
|
163
|
+
async function Ie({
|
|
164
|
+
apiUrl: e,
|
|
165
|
+
body: t,
|
|
145
166
|
fetchOptions: o
|
|
146
167
|
}) {
|
|
147
|
-
if (!
|
|
168
|
+
if (!t) {
|
|
148
169
|
console.error("[ERROR FETCHING] Body is required");
|
|
149
170
|
return;
|
|
150
171
|
}
|
|
151
|
-
await
|
|
152
|
-
const { appId:
|
|
153
|
-
return
|
|
154
|
-
`${
|
|
172
|
+
await he.validate(t);
|
|
173
|
+
const { appId: r = "faststore", orderFormId: s, key: a } = t;
|
|
174
|
+
return u(
|
|
175
|
+
`${e}/api/checkout/pub/orderForm/${s}/customData/${r}/${a}`,
|
|
155
176
|
{
|
|
156
177
|
method: "PUT",
|
|
157
178
|
...o
|
|
158
179
|
}
|
|
159
180
|
);
|
|
160
181
|
}
|
|
161
|
-
const
|
|
162
|
-
name:
|
|
163
|
-
content:
|
|
182
|
+
const be = n.object().shape({
|
|
183
|
+
name: n.string().required("Attachment name is required"),
|
|
184
|
+
content: n.object().nullable()
|
|
164
185
|
});
|
|
165
|
-
var
|
|
166
|
-
const
|
|
167
|
-
attachments: (
|
|
168
|
-
id:
|
|
169
|
-
index:
|
|
170
|
-
quantity:
|
|
171
|
-
seller:
|
|
172
|
-
price:
|
|
173
|
-
}),
|
|
174
|
-
orderFormId:
|
|
175
|
-
orderItems:
|
|
186
|
+
var H;
|
|
187
|
+
const Ce = n.object().shape({
|
|
188
|
+
attachments: (H = n.array().of(be)) == null ? void 0 : H.nullable(),
|
|
189
|
+
id: n.string().required("ID of SKU is required"),
|
|
190
|
+
index: n.number().integer().nullable(),
|
|
191
|
+
quantity: n.number().integer().nullable(),
|
|
192
|
+
seller: n.string().required("Seller is required"),
|
|
193
|
+
price: n.number().integer()
|
|
194
|
+
}), Re = n.object({
|
|
195
|
+
orderFormId: n.string().required("OrderFormId is required"),
|
|
196
|
+
orderItems: n.array().of(Ce)
|
|
176
197
|
});
|
|
177
|
-
async function
|
|
178
|
-
apiUrl:
|
|
179
|
-
body:
|
|
198
|
+
async function ye({
|
|
199
|
+
apiUrl: e,
|
|
200
|
+
body: t,
|
|
180
201
|
fetchOptions: o
|
|
181
202
|
}) {
|
|
182
|
-
if (!
|
|
203
|
+
if (!t) {
|
|
183
204
|
console.error("[ERROR FETCHING] Body is required");
|
|
184
205
|
return;
|
|
185
206
|
}
|
|
186
|
-
await
|
|
187
|
-
const { orderFormId:
|
|
188
|
-
return
|
|
189
|
-
`${
|
|
207
|
+
await Re.validate(t);
|
|
208
|
+
const { orderFormId: r, orderItems: s } = t;
|
|
209
|
+
return u(
|
|
210
|
+
`${e}/api/checkout/pub/orderForm/${r}/items`,
|
|
190
211
|
{
|
|
191
212
|
method: "POST",
|
|
192
213
|
body: { orderItems: s },
|
|
@@ -194,57 +215,57 @@ async function D({
|
|
|
194
215
|
}
|
|
195
216
|
);
|
|
196
217
|
}
|
|
197
|
-
const
|
|
198
|
-
orderFormId:
|
|
218
|
+
const Fe = n.object({
|
|
219
|
+
orderFormId: n.string().nullable()
|
|
199
220
|
});
|
|
200
|
-
async function
|
|
201
|
-
apiUrl:
|
|
202
|
-
body:
|
|
221
|
+
async function Oe({
|
|
222
|
+
apiUrl: e,
|
|
223
|
+
body: t,
|
|
203
224
|
fetchOptions: o
|
|
204
225
|
}) {
|
|
205
|
-
if (!
|
|
226
|
+
if (!t) {
|
|
206
227
|
console.error("[ERROR FETCHING] Body is required");
|
|
207
228
|
return;
|
|
208
229
|
}
|
|
209
|
-
await
|
|
210
|
-
const { orderFormId:
|
|
211
|
-
return
|
|
212
|
-
`${
|
|
230
|
+
await Fe.validate(t);
|
|
231
|
+
const { orderFormId: r } = t;
|
|
232
|
+
return u(
|
|
233
|
+
`${e}/api/checkout/pub/orderForm/${r}/items/removeAll`,
|
|
213
234
|
{
|
|
214
235
|
method: "POST",
|
|
215
236
|
...o
|
|
216
237
|
}
|
|
217
238
|
);
|
|
218
239
|
}
|
|
219
|
-
const
|
|
220
|
-
name:
|
|
221
|
-
content:
|
|
240
|
+
const $e = n.object().shape({
|
|
241
|
+
name: n.string().required("Attachment name is required"),
|
|
242
|
+
content: n.object().nullable()
|
|
222
243
|
});
|
|
223
|
-
var
|
|
224
|
-
const
|
|
225
|
-
attachments: (
|
|
226
|
-
id:
|
|
227
|
-
index:
|
|
228
|
-
quantity:
|
|
229
|
-
seller:
|
|
230
|
-
price:
|
|
231
|
-
}),
|
|
232
|
-
orderFormId:
|
|
233
|
-
orderItems:
|
|
244
|
+
var G;
|
|
245
|
+
const ve = n.object().shape({
|
|
246
|
+
attachments: (G = n.array().of($e)) == null ? void 0 : G.nullable(),
|
|
247
|
+
id: n.string().required("ID of SKU is required"),
|
|
248
|
+
index: n.number().integer().nullable(),
|
|
249
|
+
quantity: n.number().integer().nullable(),
|
|
250
|
+
seller: n.string().required("Seller is required"),
|
|
251
|
+
price: n.number().integer()
|
|
252
|
+
}), Se = n.object({
|
|
253
|
+
orderFormId: n.string().nullable(),
|
|
254
|
+
orderItems: n.array().of(ve)
|
|
234
255
|
});
|
|
235
|
-
async function
|
|
236
|
-
apiUrl:
|
|
237
|
-
body:
|
|
256
|
+
async function Ee({
|
|
257
|
+
apiUrl: e,
|
|
258
|
+
body: t,
|
|
238
259
|
fetchOptions: o
|
|
239
260
|
}) {
|
|
240
|
-
if (!
|
|
261
|
+
if (!t) {
|
|
241
262
|
console.error("[ERROR FETCHING] Body is required");
|
|
242
263
|
return;
|
|
243
264
|
}
|
|
244
|
-
await
|
|
245
|
-
const { orderFormId:
|
|
246
|
-
return
|
|
247
|
-
`${
|
|
265
|
+
await Se.validate(t);
|
|
266
|
+
const { orderFormId: r, orderItems: s } = t;
|
|
267
|
+
return u(
|
|
268
|
+
`${e}/api/checkout/pub/orderForm/${r}/items/update`,
|
|
248
269
|
{
|
|
249
270
|
method: "POST",
|
|
250
271
|
body: { orderItems: s },
|
|
@@ -252,90 +273,90 @@ async function M({
|
|
|
252
273
|
}
|
|
253
274
|
);
|
|
254
275
|
}
|
|
255
|
-
const
|
|
256
|
-
orderFormId:
|
|
276
|
+
const qe = n.object({
|
|
277
|
+
orderFormId: n.string().nullable()
|
|
257
278
|
});
|
|
258
|
-
async function
|
|
259
|
-
apiUrl:
|
|
260
|
-
body:
|
|
279
|
+
async function Te({
|
|
280
|
+
apiUrl: e,
|
|
281
|
+
body: t,
|
|
261
282
|
fetchOptions: o
|
|
262
283
|
}) {
|
|
263
|
-
if (!
|
|
284
|
+
if (!t) {
|
|
264
285
|
console.error("[ERROR FETCHING] Body is required");
|
|
265
286
|
return;
|
|
266
287
|
}
|
|
267
|
-
await
|
|
268
|
-
const { orderFormId:
|
|
269
|
-
return
|
|
270
|
-
`${
|
|
288
|
+
await qe.validate(t);
|
|
289
|
+
const { orderFormId: r } = t;
|
|
290
|
+
return u(
|
|
291
|
+
`${e}/api/checkout/pub/orderForm/${r}/messages/clear`,
|
|
271
292
|
{
|
|
272
293
|
method: "POST",
|
|
273
294
|
...o
|
|
274
295
|
}
|
|
275
296
|
);
|
|
276
297
|
}
|
|
277
|
-
const
|
|
278
|
-
id:
|
|
298
|
+
const Ae = n.object({
|
|
299
|
+
id: n.string().nullable(),
|
|
279
300
|
// id offering
|
|
280
|
-
itemIndex:
|
|
281
|
-
orderFormId:
|
|
282
|
-
remove:
|
|
301
|
+
itemIndex: n.number().nullable(),
|
|
302
|
+
orderFormId: n.string().nullable(),
|
|
303
|
+
remove: n.boolean().nullable()
|
|
283
304
|
});
|
|
284
|
-
async function
|
|
285
|
-
if (!
|
|
305
|
+
async function Pe({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
306
|
+
if (!t) {
|
|
286
307
|
console.error("[ERROR FETCHING] Body is required");
|
|
287
308
|
return;
|
|
288
309
|
}
|
|
289
|
-
await
|
|
290
|
-
const { itemIndex:
|
|
291
|
-
return l
|
|
310
|
+
await Ae.validate(t);
|
|
311
|
+
const { itemIndex: r, orderFormId: s, id: a, remove: i } = t, c = i ? `/${a}/remove` : "", l = `${e}/api/checkout/pub/orderForm/${s}/items/${r}/offerings${c}`;
|
|
312
|
+
return u(l, {
|
|
292
313
|
method: "POST",
|
|
293
314
|
body: { id: a },
|
|
294
315
|
...o
|
|
295
316
|
});
|
|
296
317
|
}
|
|
297
|
-
const
|
|
298
|
-
orderFormId:
|
|
318
|
+
const Ne = n.object({
|
|
319
|
+
orderFormId: n.string().nullable()
|
|
299
320
|
});
|
|
300
|
-
async function
|
|
301
|
-
apiUrl:
|
|
302
|
-
body:
|
|
321
|
+
async function je({
|
|
322
|
+
apiUrl: e,
|
|
323
|
+
body: t,
|
|
303
324
|
fetchOptions: o,
|
|
304
|
-
extraData:
|
|
325
|
+
extraData: r
|
|
305
326
|
}) {
|
|
306
327
|
var i;
|
|
307
|
-
if (!
|
|
328
|
+
if (!t) {
|
|
308
329
|
console.error("[ERROR FETCHING] Body is required");
|
|
309
330
|
return;
|
|
310
331
|
}
|
|
311
|
-
await
|
|
332
|
+
await Ne.validate(t);
|
|
312
333
|
const s = new URLSearchParams({
|
|
313
334
|
refreshOutdatedData: "true"
|
|
314
|
-
}), a =
|
|
315
|
-
return
|
|
316
|
-
}
|
|
317
|
-
const
|
|
318
|
-
orderFormId:
|
|
319
|
-
email:
|
|
320
|
-
firstName:
|
|
321
|
-
lastName:
|
|
322
|
-
documentType:
|
|
323
|
-
document:
|
|
324
|
-
phone:
|
|
335
|
+
}), a = t.orderFormId && ((i = r.orderFormPurchaseId) == null ? void 0 : i.value) !== t.orderFormId ? `${e}/api/checkout/pub/orderForm/${t.orderFormId}?${String(s)}` : `${e}/api/checkout/pub/orderForm`;
|
|
336
|
+
return u(a, { method: "GET", ...o });
|
|
337
|
+
}
|
|
338
|
+
const ke = n.object({
|
|
339
|
+
orderFormId: n.string().nullable(),
|
|
340
|
+
email: n.string().email().required(),
|
|
341
|
+
firstName: n.string().required(),
|
|
342
|
+
lastName: n.string().required(),
|
|
343
|
+
documentType: n.string().required(),
|
|
344
|
+
document: n.string().required(),
|
|
345
|
+
phone: n.string().matches(/^\+\d{1,3}\d{10,11}$/)
|
|
325
346
|
});
|
|
326
|
-
async function
|
|
327
|
-
apiUrl:
|
|
328
|
-
body:
|
|
347
|
+
async function we({
|
|
348
|
+
apiUrl: e,
|
|
349
|
+
body: t,
|
|
329
350
|
fetchOptions: o
|
|
330
351
|
}) {
|
|
331
|
-
if (!
|
|
352
|
+
if (!t) {
|
|
332
353
|
console.error("[ERROR FETCHING] Body is required");
|
|
333
354
|
return;
|
|
334
355
|
}
|
|
335
|
-
await
|
|
336
|
-
const { orderFormId:
|
|
337
|
-
return
|
|
338
|
-
`${
|
|
356
|
+
await ke.validate(t);
|
|
357
|
+
const { orderFormId: r, ...s } = t;
|
|
358
|
+
return u(
|
|
359
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/clientProfileData`,
|
|
339
360
|
{
|
|
340
361
|
method: "POST",
|
|
341
362
|
body: { ...s },
|
|
@@ -343,22 +364,22 @@ async function Y({
|
|
|
343
364
|
}
|
|
344
365
|
);
|
|
345
366
|
}
|
|
346
|
-
const
|
|
347
|
-
sellerCode:
|
|
367
|
+
const De = n.object({
|
|
368
|
+
sellerCode: n.string().nullable()
|
|
348
369
|
});
|
|
349
|
-
async function
|
|
350
|
-
apiUrl:
|
|
351
|
-
body:
|
|
370
|
+
async function _e({
|
|
371
|
+
apiUrl: e,
|
|
372
|
+
body: t,
|
|
352
373
|
fetchOptions: o
|
|
353
374
|
}) {
|
|
354
|
-
if (!
|
|
375
|
+
if (!t) {
|
|
355
376
|
console.error("[ERROR FETCHING] Body is required");
|
|
356
377
|
return;
|
|
357
378
|
}
|
|
358
|
-
await
|
|
359
|
-
const { sellerCode:
|
|
360
|
-
return
|
|
361
|
-
`${
|
|
379
|
+
await De.validate(t);
|
|
380
|
+
const { sellerCode: r = "" } = t;
|
|
381
|
+
return u(
|
|
382
|
+
`${e}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${r}`,
|
|
362
383
|
{
|
|
363
384
|
method: "GET",
|
|
364
385
|
headers: {
|
|
@@ -368,33 +389,33 @@ async function X({
|
|
|
368
389
|
}
|
|
369
390
|
);
|
|
370
391
|
}
|
|
371
|
-
const
|
|
372
|
-
country:
|
|
373
|
-
orderFormId:
|
|
374
|
-
postalCode:
|
|
392
|
+
const He = n.object().shape({
|
|
393
|
+
country: n.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
394
|
+
orderFormId: n.string().nullable(),
|
|
395
|
+
postalCode: n.string().nullable()
|
|
375
396
|
});
|
|
376
|
-
async function
|
|
377
|
-
apiUrl:
|
|
378
|
-
body:
|
|
397
|
+
async function Ge({
|
|
398
|
+
apiUrl: e,
|
|
399
|
+
body: t,
|
|
379
400
|
fetchOptions: o
|
|
380
401
|
}) {
|
|
381
|
-
if (!
|
|
402
|
+
if (!t) {
|
|
382
403
|
console.error("[ERROR FETCHING] Body is required");
|
|
383
404
|
return;
|
|
384
405
|
}
|
|
385
|
-
await
|
|
386
|
-
const { country:
|
|
406
|
+
await He.validate(t);
|
|
407
|
+
const { country: r, orderFormId: s, postalCode: a } = t, i = a ? {
|
|
387
408
|
address: {
|
|
388
409
|
addressType: "residential",
|
|
389
410
|
postalCode: a,
|
|
390
|
-
country:
|
|
411
|
+
country: r
|
|
391
412
|
}
|
|
392
413
|
} : {
|
|
393
414
|
logisticsInfo: [],
|
|
394
415
|
clearAddressIfPostalCodeNotFound: !0
|
|
395
416
|
};
|
|
396
|
-
return
|
|
397
|
-
`${
|
|
417
|
+
return u(
|
|
418
|
+
`${e}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,
|
|
398
419
|
{
|
|
399
420
|
method: "POST",
|
|
400
421
|
body: i,
|
|
@@ -402,43 +423,43 @@ async function Z({
|
|
|
402
423
|
}
|
|
403
424
|
);
|
|
404
425
|
}
|
|
405
|
-
const
|
|
406
|
-
orderFormId:
|
|
407
|
-
options:
|
|
408
|
-
|
|
409
|
-
itemIndex:
|
|
410
|
-
selectedDeliveryChannel:
|
|
411
|
-
selectedSla:
|
|
426
|
+
const Be = n.object().shape({
|
|
427
|
+
orderFormId: n.string().nullable(),
|
|
428
|
+
options: n.array().of(
|
|
429
|
+
n.object().shape({
|
|
430
|
+
itemIndex: n.number(),
|
|
431
|
+
selectedDeliveryChannel: n.string(),
|
|
432
|
+
selectedSla: n.string()
|
|
412
433
|
})
|
|
413
434
|
),
|
|
414
|
-
selectedAddresses:
|
|
415
|
-
|
|
416
|
-
addressId:
|
|
417
|
-
addressType:
|
|
418
|
-
city:
|
|
419
|
-
complement:
|
|
420
|
-
country:
|
|
421
|
-
geoCoordinates:
|
|
422
|
-
isDisposable:
|
|
423
|
-
neighborhood:
|
|
424
|
-
number:
|
|
425
|
-
postalCode:
|
|
426
|
-
receiverName:
|
|
427
|
-
reference:
|
|
428
|
-
state:
|
|
429
|
-
street:
|
|
435
|
+
selectedAddresses: n.array().of(
|
|
436
|
+
n.object().shape({
|
|
437
|
+
addressId: n.string().required(),
|
|
438
|
+
addressType: n.string().required(),
|
|
439
|
+
city: n.string().nullable(),
|
|
440
|
+
complement: n.string().nullable(),
|
|
441
|
+
country: n.string().required().length(3),
|
|
442
|
+
geoCoordinates: n.array().of(n.number()).required().min(0),
|
|
443
|
+
isDisposable: n.boolean().required(),
|
|
444
|
+
neighborhood: n.string().nullable(),
|
|
445
|
+
number: n.string().nullable(),
|
|
446
|
+
postalCode: n.string().required(),
|
|
447
|
+
receiverName: n.string().nullable(),
|
|
448
|
+
reference: n.string().nullable(),
|
|
449
|
+
state: n.string().nullable(),
|
|
450
|
+
street: n.string().nullable()
|
|
430
451
|
})
|
|
431
452
|
)
|
|
432
453
|
});
|
|
433
|
-
async function
|
|
434
|
-
if (!
|
|
454
|
+
async function Ue({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
455
|
+
if (!t) {
|
|
435
456
|
console.error("[ERROR FETCHING] Body is required");
|
|
436
457
|
return;
|
|
437
458
|
}
|
|
438
|
-
await
|
|
439
|
-
const { orderFormId:
|
|
440
|
-
return
|
|
441
|
-
`${
|
|
459
|
+
await Be.validate(t);
|
|
460
|
+
const { orderFormId: r, options: s, selectedAddresses: a } = t;
|
|
461
|
+
return u(
|
|
462
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/shippingData`,
|
|
442
463
|
{
|
|
443
464
|
method: "POST",
|
|
444
465
|
body: {
|
|
@@ -450,215 +471,215 @@ async function re({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
450
471
|
}
|
|
451
472
|
);
|
|
452
473
|
}
|
|
453
|
-
const
|
|
454
|
-
country:
|
|
455
|
-
postalCode:
|
|
456
|
-
geoCoordinates:
|
|
457
|
-
longitude:
|
|
458
|
-
latitude:
|
|
474
|
+
const Ve = n.object({
|
|
475
|
+
country: n.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
476
|
+
postalCode: n.string().nullable(),
|
|
477
|
+
geoCoordinates: n.object().shape({
|
|
478
|
+
longitude: n.number().required(),
|
|
479
|
+
latitude: n.number().required()
|
|
459
480
|
})
|
|
460
481
|
});
|
|
461
|
-
async function
|
|
462
|
-
if (!
|
|
482
|
+
async function Le({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
483
|
+
if (!t) {
|
|
463
484
|
console.error("[ERROR FETCHING] Body is required");
|
|
464
485
|
return;
|
|
465
486
|
}
|
|
466
|
-
await
|
|
467
|
-
const { country:
|
|
487
|
+
await Ve.validate(t);
|
|
488
|
+
const { country: r = "", geoCoordinates: s, postalCode: a = "" } = t, i = new URLSearchParams({ country: String(r) });
|
|
468
489
|
return a ? i.append("postalCode", a) : i.append(
|
|
469
490
|
"geoCoordinates",
|
|
470
491
|
`${s == null ? void 0 : s.longitude};${s == null ? void 0 : s.latitude}`
|
|
471
|
-
), await
|
|
472
|
-
`${
|
|
492
|
+
), await u(
|
|
493
|
+
`${e}/api/checkout/pub/regions/?${i.toString()}`,
|
|
473
494
|
{
|
|
474
495
|
method: "GET",
|
|
475
496
|
...o
|
|
476
497
|
}
|
|
477
498
|
);
|
|
478
499
|
}
|
|
479
|
-
const
|
|
480
|
-
id:
|
|
481
|
-
quantity:
|
|
482
|
-
seller:
|
|
483
|
-
}),
|
|
484
|
-
items:
|
|
485
|
-
country:
|
|
486
|
-
postalCode:
|
|
487
|
-
geoCoordinates:
|
|
500
|
+
const Me = n.object({
|
|
501
|
+
id: n.string().required("ID of SKU is required"),
|
|
502
|
+
quantity: n.number().integer().required("Quantity of item is required"),
|
|
503
|
+
seller: n.string()
|
|
504
|
+
}), xe = n.object({
|
|
505
|
+
items: n.array().of(Me),
|
|
506
|
+
country: n.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
507
|
+
postalCode: n.string().nullable(),
|
|
508
|
+
geoCoordinates: n.array().nullable().of(n.number()).length(2)
|
|
488
509
|
});
|
|
489
|
-
async function
|
|
490
|
-
if (!
|
|
510
|
+
async function ze({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
511
|
+
if (!t) {
|
|
491
512
|
console.error("[ERROR FETCHING] Body is required");
|
|
492
513
|
return;
|
|
493
514
|
}
|
|
494
|
-
return await
|
|
495
|
-
`${
|
|
515
|
+
return await xe.validate(t), u(
|
|
516
|
+
`${e}/api/checkout/pub/orderForms/simulation`,
|
|
496
517
|
{
|
|
497
518
|
method: "POST",
|
|
498
|
-
body:
|
|
519
|
+
body: t,
|
|
499
520
|
...o
|
|
500
521
|
}
|
|
501
522
|
);
|
|
502
523
|
}
|
|
503
|
-
const
|
|
524
|
+
const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
504
525
|
__proto__: null,
|
|
505
|
-
getMasterDataSellerCode:
|
|
506
|
-
getOrderForm:
|
|
507
|
-
postOrderFormAddCoupon:
|
|
508
|
-
postOrderFormAttachClientProfileData:
|
|
509
|
-
postOrderFormAttachOrderFormData:
|
|
510
|
-
postOrderFormAttachShippingData:
|
|
511
|
-
postOrderFormAttachmentsMarketingData:
|
|
512
|
-
postOrderFormAttachmentsOpenTextField:
|
|
513
|
-
postOrderFormClearMessages:
|
|
514
|
-
postOrderFormFreightSimulation:
|
|
515
|
-
postOrderFormItems:
|
|
516
|
-
postOrderFormRegion:
|
|
517
|
-
postOrderFormRemoveAllItems:
|
|
518
|
-
postOrderFormUpdateItems:
|
|
519
|
-
postOrderFormUpdateShippingData:
|
|
520
|
-
postOrderformAddress:
|
|
521
|
-
putOrderFormCustomData:
|
|
522
|
-
updateOrderFormOffering:
|
|
523
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
524
|
-
skuId:
|
|
526
|
+
getMasterDataSellerCode: _e,
|
|
527
|
+
getOrderForm: je,
|
|
528
|
+
postOrderFormAddCoupon: fe,
|
|
529
|
+
postOrderFormAttachClientProfileData: we,
|
|
530
|
+
postOrderFormAttachOrderFormData: pe,
|
|
531
|
+
postOrderFormAttachShippingData: Ge,
|
|
532
|
+
postOrderFormAttachmentsMarketingData: U,
|
|
533
|
+
postOrderFormAttachmentsOpenTextField: B,
|
|
534
|
+
postOrderFormClearMessages: Te,
|
|
535
|
+
postOrderFormFreightSimulation: ze,
|
|
536
|
+
postOrderFormItems: ye,
|
|
537
|
+
postOrderFormRegion: Le,
|
|
538
|
+
postOrderFormRemoveAllItems: Oe,
|
|
539
|
+
postOrderFormUpdateItems: Ee,
|
|
540
|
+
postOrderFormUpdateShippingData: Ue,
|
|
541
|
+
postOrderformAddress: le,
|
|
542
|
+
putOrderFormCustomData: Ie,
|
|
543
|
+
updateOrderFormOffering: Pe
|
|
544
|
+
}, Symbol.toStringTag, { value: "Module" })), Je = n.object({
|
|
545
|
+
skuId: n.string()
|
|
525
546
|
});
|
|
526
|
-
async function
|
|
527
|
-
if (!
|
|
547
|
+
async function Ke({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
548
|
+
if (!t) {
|
|
528
549
|
console.error("[ERROR FETCHING] Body is required");
|
|
529
550
|
return;
|
|
530
551
|
}
|
|
531
|
-
await
|
|
532
|
-
const { skuId:
|
|
533
|
-
return
|
|
534
|
-
`${
|
|
552
|
+
await Je.validate(t);
|
|
553
|
+
const { skuId: r } = t;
|
|
554
|
+
return u(
|
|
555
|
+
`${e}/api/catalog/pvt/stockkeepingunitkit?parentSkuId=${r}`,
|
|
535
556
|
{
|
|
536
557
|
...o
|
|
537
558
|
}
|
|
538
559
|
);
|
|
539
560
|
}
|
|
540
|
-
const
|
|
541
|
-
ids:
|
|
561
|
+
const Ye = n.object({
|
|
562
|
+
ids: n.array().of(n.string().required("ID are required")).required("IDs are required")
|
|
542
563
|
});
|
|
543
|
-
async function
|
|
544
|
-
if (!
|
|
564
|
+
async function We({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
565
|
+
if (!t) {
|
|
545
566
|
console.error("[ERROR FETCHING] Body is required");
|
|
546
567
|
return;
|
|
547
568
|
}
|
|
548
|
-
await
|
|
549
|
-
const { ids:
|
|
550
|
-
return
|
|
551
|
-
`${
|
|
569
|
+
await Ye.validate(t);
|
|
570
|
+
const { ids: r } = t;
|
|
571
|
+
return u(
|
|
572
|
+
`${e}/api/catalog_system/pub/products/search?fq=${r.map((s) => `productId:${s}`).join("&fq=")}`,
|
|
552
573
|
{
|
|
553
574
|
...o
|
|
554
575
|
}
|
|
555
576
|
);
|
|
556
577
|
}
|
|
557
|
-
const
|
|
558
|
-
productId:
|
|
578
|
+
const Xe = n.object({
|
|
579
|
+
productId: n.number().required("Product ID is required")
|
|
559
580
|
});
|
|
560
|
-
async function
|
|
561
|
-
if (!
|
|
581
|
+
async function Ze({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
582
|
+
if (!t) {
|
|
562
583
|
console.error("[ERROR FETCHING] Body is required");
|
|
563
584
|
return;
|
|
564
585
|
}
|
|
565
|
-
await
|
|
566
|
-
const { productId:
|
|
567
|
-
return
|
|
568
|
-
`${
|
|
586
|
+
await Xe.validate(t);
|
|
587
|
+
const { productId: r } = t;
|
|
588
|
+
return u(
|
|
589
|
+
`${e}/api/catalog_system/pub/products/crossselling/similars/${r.toString()}`,
|
|
569
590
|
{
|
|
570
591
|
...o
|
|
571
592
|
}
|
|
572
593
|
);
|
|
573
594
|
}
|
|
574
|
-
const
|
|
595
|
+
const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
575
596
|
__proto__: null,
|
|
576
|
-
getCatalogKitProducts:
|
|
577
|
-
getCatalogProducts:
|
|
578
|
-
getCatalogSimilars:
|
|
579
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
580
|
-
const
|
|
597
|
+
getCatalogKitProducts: Ke,
|
|
598
|
+
getCatalogProducts: We,
|
|
599
|
+
getCatalogSimilars: Ze
|
|
600
|
+
}, Symbol.toStringTag, { value: "Module" })), tt = (e = "") => e.charAt(0).toUpperCase() + e.slice(1), w = (e, t = " ") => !e || typeof e == "string" && e.length === 0 ? e : (Array.isArray(e) ? e : e.split("-")).map(tt).join(t), rt = ({ canonical: e, seo: t, slug: o }) => {
|
|
601
|
+
const r = Array.isArray(o) ? o.join(", ") : o;
|
|
581
602
|
return {
|
|
582
603
|
id: 0,
|
|
583
|
-
Title: `${Array.isArray(o) ? o.map((a) =>
|
|
584
|
-
MetaTagDescription:
|
|
585
|
-
name:
|
|
604
|
+
Title: `${Array.isArray(o) ? o.map((a) => w(a)).join(",") : w(o)} - ${t.title}`,
|
|
605
|
+
MetaTagDescription: t.description,
|
|
606
|
+
name: r,
|
|
586
607
|
hasChildren: !1,
|
|
587
|
-
url:
|
|
608
|
+
url: e,
|
|
588
609
|
children: []
|
|
589
610
|
};
|
|
590
|
-
},
|
|
591
|
-
category: String(
|
|
592
|
-
title: (
|
|
593
|
-
description: (
|
|
594
|
-
alternates: { canonical:
|
|
611
|
+
}, ot = ({ canonical: e, category: t, previousImages: o, seo: r }) => ({
|
|
612
|
+
category: String(t == null ? void 0 : t.id),
|
|
613
|
+
title: (t == null ? void 0 : t.Title) ?? r.title,
|
|
614
|
+
description: (t == null ? void 0 : t.MetaTagDescription) ?? r.description,
|
|
615
|
+
alternates: { canonical: e },
|
|
595
616
|
openGraph: {
|
|
596
617
|
type: "website",
|
|
597
|
-
title: (
|
|
598
|
-
description: (
|
|
618
|
+
title: (t == null ? void 0 : t.Title) ?? r.title,
|
|
619
|
+
description: (t == null ? void 0 : t.MetaTagDescription) ?? r.description,
|
|
599
620
|
images: Array.isArray(o) ? [...o] : []
|
|
600
621
|
}
|
|
601
|
-
}),
|
|
602
|
-
const s =
|
|
603
|
-
(i) => i.url.replace(o, "") === decodeURIComponent(
|
|
622
|
+
}), nt = ({ items: e, parent: t, apiUrl: o, find: r }) => {
|
|
623
|
+
const s = e.find(
|
|
624
|
+
(i) => i.url.replace(o, "") === decodeURIComponent(t.toLowerCase())
|
|
604
625
|
);
|
|
605
626
|
return (s == null ? void 0 : s.children.find(
|
|
606
|
-
(i) => i.name.toLowerCase() === decodeURIComponent(String(
|
|
627
|
+
(i) => i.name.toLowerCase() === decodeURIComponent(String(r))
|
|
607
628
|
)) ?? s;
|
|
608
|
-
},
|
|
609
|
-
|
|
610
|
-
},
|
|
629
|
+
}, at = (e) => {
|
|
630
|
+
e instanceof Error ? (console.error(`[ERROR CATEGORY INFO]: ${e.message}`), console.error(e.stack)) : console.error("[ERROR CATEGORY INFO]: Unknown error", e);
|
|
631
|
+
}, st = /* @__PURE__ */ new Set([
|
|
611
632
|
"brand",
|
|
612
633
|
"category",
|
|
613
634
|
"department",
|
|
614
635
|
"subcategory",
|
|
615
636
|
"collection",
|
|
616
637
|
"cluster"
|
|
617
|
-
]),
|
|
618
|
-
collection:
|
|
619
|
-
categoryId:
|
|
620
|
-
current_collection:
|
|
621
|
-
items:
|
|
622
|
-
}),
|
|
623
|
-
if (
|
|
624
|
-
(i) => i.sellers.find((
|
|
625
|
-
).length === 0 || (o == null ? void 0 : o.find((i) => (i == null ? void 0 : i.productId) === (
|
|
638
|
+
]), it = (e) => typeof (e == null ? void 0 : e.pageType) == "string" && st.has(e == null ? void 0 : e.pageType.toLowerCase()), ct = (e) => ({
|
|
639
|
+
collection: e.Coleção,
|
|
640
|
+
categoryId: e.categoryId,
|
|
641
|
+
current_collection: e["Coleção Atual"],
|
|
642
|
+
items: e.items
|
|
643
|
+
}), lt = (e, t) => e.reduce((o, r) => {
|
|
644
|
+
if (r.items.filter(
|
|
645
|
+
(i) => i.sellers.find((c) => c.commertialOffer.IsAvailable)
|
|
646
|
+
).length === 0 || (o == null ? void 0 : o.find((i) => (i == null ? void 0 : i.productId) === (r == null ? void 0 : r.productId))) !== void 0)
|
|
626
647
|
return o;
|
|
627
|
-
const a =
|
|
628
|
-
(i) =>
|
|
648
|
+
const a = r.items[0].images.find(
|
|
649
|
+
(i) => t.includes(i.imageLabel)
|
|
629
650
|
);
|
|
630
651
|
return o.push({
|
|
631
|
-
slug: `/${
|
|
632
|
-
productId:
|
|
652
|
+
slug: `/${r.linkText}/p`,
|
|
653
|
+
productId: r == null ? void 0 : r.productId,
|
|
633
654
|
textureImage: (a == null ? void 0 : a.imageUrl) ?? "",
|
|
634
655
|
textureAlt: (a == null ? void 0 : a.imageText) ?? ""
|
|
635
656
|
}), o;
|
|
636
|
-
}, []),
|
|
657
|
+
}, []), ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
637
658
|
__proto__: null,
|
|
638
|
-
createEmptySeoCategory:
|
|
639
|
-
createSeoCategory:
|
|
640
|
-
findCategory:
|
|
641
|
-
formattedSimilars:
|
|
642
|
-
isCollectionPageType:
|
|
643
|
-
notFindCategoryError:
|
|
644
|
-
responseAdapter:
|
|
659
|
+
createEmptySeoCategory: rt,
|
|
660
|
+
createSeoCategory: ot,
|
|
661
|
+
findCategory: nt,
|
|
662
|
+
formattedSimilars: lt,
|
|
663
|
+
isCollectionPageType: it,
|
|
664
|
+
notFindCategoryError: at,
|
|
665
|
+
responseAdapter: ct
|
|
645
666
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
646
|
-
async function
|
|
647
|
-
const s = await
|
|
648
|
-
contentType:
|
|
649
|
-
storeId:
|
|
667
|
+
async function dt({ contentType: e, storeId: t, CMS_PROJECT_NAME: o, NextCookies: r }) {
|
|
668
|
+
const s = await V({
|
|
669
|
+
contentType: e,
|
|
670
|
+
storeId: t,
|
|
650
671
|
CMS_PROJECT_NAME: o,
|
|
651
|
-
NextCookies:
|
|
672
|
+
NextCookies: r
|
|
652
673
|
});
|
|
653
674
|
if (s.status === 200) {
|
|
654
675
|
const a = {
|
|
655
676
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
656
|
-
contentType:
|
|
677
|
+
contentType: e,
|
|
657
678
|
data: s.data
|
|
658
679
|
};
|
|
659
680
|
console.log("Resultado da chamada:", s);
|
|
660
|
-
const i = `backup-${
|
|
661
|
-
return await
|
|
681
|
+
const i = `backup-${e}-${Date.now()}.json`;
|
|
682
|
+
return await Z.writeFile(
|
|
662
683
|
`./backups/${i}`,
|
|
663
684
|
JSON.stringify(a, null, 2),
|
|
664
685
|
"utf-8"
|
|
@@ -666,96 +687,566 @@ async function qe({ contentType: t, storeId: e, CMS_PROJECT_NAME: o, NextCookies
|
|
|
666
687
|
}
|
|
667
688
|
return { success: !1, error: s.error || "No data to backup" };
|
|
668
689
|
}
|
|
669
|
-
async function
|
|
670
|
-
return
|
|
690
|
+
async function mt(e) {
|
|
691
|
+
return dt(e);
|
|
671
692
|
}
|
|
672
|
-
async function
|
|
673
|
-
contentType:
|
|
674
|
-
documentId:
|
|
693
|
+
async function pt({
|
|
694
|
+
contentType: e,
|
|
695
|
+
documentId: t,
|
|
675
696
|
versionId: o,
|
|
676
|
-
storeId:
|
|
697
|
+
storeId: r,
|
|
677
698
|
CMS_PROJECT_NAME: s
|
|
678
699
|
}) {
|
|
679
|
-
const a =
|
|
700
|
+
const a = t && t.length ? `/${t}` : "", i = o && o.length ? `?versionId=${o}` : "";
|
|
680
701
|
return fetch(
|
|
681
|
-
`https://${
|
|
702
|
+
`https://${r}.myvtex.com/_v/cms/api/${s}/${e}${a}${i}`,
|
|
682
703
|
{ cache: "no-cache" }
|
|
683
704
|
);
|
|
684
705
|
}
|
|
685
|
-
async function
|
|
686
|
-
contentType:
|
|
687
|
-
documents:
|
|
706
|
+
async function gt({
|
|
707
|
+
contentType: e,
|
|
708
|
+
documents: t,
|
|
688
709
|
NextCookies: o,
|
|
689
|
-
CMS_PROJECT_NAME:
|
|
710
|
+
CMS_PROJECT_NAME: r,
|
|
690
711
|
storeId: s
|
|
691
712
|
}) {
|
|
692
713
|
var i;
|
|
693
714
|
const a = JSON.parse(
|
|
694
715
|
((i = o().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
|
|
695
716
|
);
|
|
696
|
-
if (a && (a == null ? void 0 : a.contentType) ===
|
|
697
|
-
const
|
|
698
|
-
`https://${s}.myvtex.com/_v/cms/api/${
|
|
717
|
+
if (a && (a == null ? void 0 : a.contentType) === e) {
|
|
718
|
+
const c = a.documentId && a.documentId.length ? `/${a.documentId}` : "", l = a != null && a.versionId && (a != null && a.versionId.length) ? `?versionId=${a == null ? void 0 : a.versionId}` : "", p = await (await fetch(
|
|
719
|
+
`https://${s}.myvtex.com/_v/cms/api/${r}/${e}${c}${l}`,
|
|
699
720
|
{ cache: "no-store" }
|
|
700
|
-
)).json(),
|
|
701
|
-
(
|
|
721
|
+
)).json(), d = t.filter(
|
|
722
|
+
(m) => p.id !== m.documentId
|
|
702
723
|
);
|
|
703
|
-
return
|
|
724
|
+
return d.unshift(p), d;
|
|
704
725
|
}
|
|
705
|
-
return
|
|
726
|
+
return t;
|
|
706
727
|
}
|
|
707
|
-
async function
|
|
708
|
-
contentType:
|
|
709
|
-
NextCookies:
|
|
728
|
+
async function V({
|
|
729
|
+
contentType: e,
|
|
730
|
+
NextCookies: t,
|
|
710
731
|
CMS_PROJECT_NAME: o,
|
|
711
|
-
storeId:
|
|
732
|
+
storeId: r
|
|
712
733
|
}) {
|
|
713
734
|
var g, p;
|
|
714
735
|
const s = JSON.parse(
|
|
715
|
-
((g =
|
|
736
|
+
((g = t().get("cms_preview_data")) == null ? void 0 : g.value) ?? "{}"
|
|
716
737
|
), a = [];
|
|
717
|
-
let i = 1,
|
|
738
|
+
let i = 1, c = 0, l = !0;
|
|
718
739
|
try {
|
|
719
740
|
do {
|
|
720
|
-
const
|
|
721
|
-
`https://${
|
|
741
|
+
const m = await (await fetch(
|
|
742
|
+
`https://${r}.myvtex.com/_v/cms/api/${o}/${e}?page=${i}`
|
|
722
743
|
)).json();
|
|
723
|
-
i === 1 && (
|
|
724
|
-
} while (
|
|
744
|
+
i === 1 && (c = m.totalItems), (p = m == null ? void 0 : m.data) != null && p.length && a.push(...m.data), l = m.hasNextPage, i++;
|
|
745
|
+
} while (l && a.length < c);
|
|
725
746
|
if (s.previewMode && a.length) {
|
|
726
|
-
const
|
|
727
|
-
contentType:
|
|
747
|
+
const d = await gt({
|
|
748
|
+
contentType: e,
|
|
728
749
|
documents: a,
|
|
729
|
-
NextCookies:
|
|
750
|
+
NextCookies: t,
|
|
730
751
|
CMS_PROJECT_NAME: o,
|
|
731
|
-
storeId:
|
|
752
|
+
storeId: r
|
|
732
753
|
});
|
|
733
754
|
return {
|
|
734
|
-
status:
|
|
735
|
-
data:
|
|
755
|
+
status: d.length > 0 ? 200 : 404,
|
|
756
|
+
data: d ?? []
|
|
736
757
|
};
|
|
737
758
|
}
|
|
738
759
|
return {
|
|
739
760
|
status: a.length ? 200 : 404,
|
|
740
761
|
data: a
|
|
741
762
|
};
|
|
742
|
-
} catch (
|
|
743
|
-
return { status: "error", data: [], error:
|
|
763
|
+
} catch (d) {
|
|
764
|
+
return { status: "error", data: [], error: d };
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
768
|
+
__proto__: null,
|
|
769
|
+
cmsBackup: mt,
|
|
770
|
+
getCMSContentType: pt,
|
|
771
|
+
getContentType: V
|
|
772
|
+
}, Symbol.toStringTag, { value: "Module" })), ht = n.object({
|
|
773
|
+
query: n.string()
|
|
774
|
+
});
|
|
775
|
+
async function It({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
776
|
+
if (!t) {
|
|
777
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
778
|
+
return;
|
|
744
779
|
}
|
|
780
|
+
await ht.validate(t);
|
|
781
|
+
const { query: r = "" } = t, s = new URLSearchParams({ query: r });
|
|
782
|
+
return u(
|
|
783
|
+
`${e}/api/io/_v/api/intelligent-search/autocomplete_suggestions?${s.toString()}`,
|
|
784
|
+
{
|
|
785
|
+
...o
|
|
786
|
+
}
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
const bt = (e, t) => se(e, t), Ct = (e) => ({
|
|
790
|
+
...e,
|
|
791
|
+
description: e.description ? bt(e.description) : e.description
|
|
792
|
+
}), Rt = ({
|
|
793
|
+
offer: e,
|
|
794
|
+
seller: t,
|
|
795
|
+
product: o
|
|
796
|
+
}) => ({
|
|
797
|
+
...e,
|
|
798
|
+
product: o,
|
|
799
|
+
seller: t
|
|
800
|
+
}), L = (e, t) => ({
|
|
801
|
+
...e,
|
|
802
|
+
isVariantOf: Ct(t)
|
|
803
|
+
}), yt = (e) => e ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", S = (e) => e.AvailableQuantity > 0, D = (e) => e.spotPrice ?? 0, Ft = (e) => e.Price ?? 0, M = (e, t) => S(e) && !S(t) ? -1 : !S(e) && S(t) ? 1 : D(e) - D(t), Ot = (e, t) => {
|
|
804
|
+
let o = 0;
|
|
805
|
+
for (let r = 1; r < e.length; r++)
|
|
806
|
+
t(e[o], e[r]) > 0 && (o = r);
|
|
807
|
+
return e[o];
|
|
808
|
+
}, x = (e) => {
|
|
809
|
+
const t = e.flatMap(
|
|
810
|
+
(r) => r.sellers.map((s) => ({
|
|
811
|
+
offer: s.commertialOffer,
|
|
812
|
+
sku: r
|
|
813
|
+
}))
|
|
814
|
+
), o = Ot(
|
|
815
|
+
t,
|
|
816
|
+
({ offer: r }, { offer: s }) => M(r, s)
|
|
817
|
+
);
|
|
818
|
+
return o ? o.sku : e[0];
|
|
819
|
+
}, z = (e) => e.map(
|
|
820
|
+
({ imageUrl: t, imageText: o, imageLabel: r }) => ({
|
|
821
|
+
alternateName: o ?? "",
|
|
822
|
+
url: t.replace("vteximg.com.br", "vtexassets.com"),
|
|
823
|
+
keywords: r
|
|
824
|
+
})
|
|
825
|
+
), E = {
|
|
826
|
+
attachment: "ATTACHMENT",
|
|
827
|
+
specification: "SPECIFICATION",
|
|
828
|
+
attribute: "ATTRIBUTE"
|
|
829
|
+
}, $t = (e) => ({
|
|
830
|
+
name: e.name,
|
|
831
|
+
value: e.content,
|
|
832
|
+
valueReference: E.attachment
|
|
833
|
+
}), vt = (e) => ({
|
|
834
|
+
propertyID: e.id,
|
|
835
|
+
name: e.name,
|
|
836
|
+
value: e.value,
|
|
837
|
+
valueReference: {
|
|
838
|
+
valueReference: E.attribute,
|
|
839
|
+
visible: e.visible
|
|
840
|
+
}
|
|
841
|
+
}), q = (e, t, o) => {
|
|
842
|
+
const r = e.flatMap(({ name: i, values: c }) => c ? c.map((l) => ({
|
|
843
|
+
name: i,
|
|
844
|
+
value: l,
|
|
845
|
+
valueReference: E.specification
|
|
846
|
+
})) : {
|
|
847
|
+
name: i,
|
|
848
|
+
value: "",
|
|
849
|
+
valueReference: E.specification
|
|
850
|
+
}), s = Array.isArray(o) ? o.map($t) : [], a = t ? t.map(vt) : [];
|
|
851
|
+
return [
|
|
852
|
+
...r,
|
|
853
|
+
...s,
|
|
854
|
+
...a
|
|
855
|
+
];
|
|
856
|
+
}, _ = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", St = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", Et = (e) => {
|
|
857
|
+
let t = e.slice(0);
|
|
858
|
+
for (let o = 0; o < _.length; o++)
|
|
859
|
+
t = t.replace(
|
|
860
|
+
new RegExp(_.charAt(o), "g"),
|
|
861
|
+
St.charAt(o)
|
|
862
|
+
);
|
|
863
|
+
return t;
|
|
864
|
+
}, qt = (e) => e.replace(/[·/_,:]/, "-"), Q = (e) => {
|
|
865
|
+
const o = e.replace(/,/g, "").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}|><=_^]/g, "-");
|
|
866
|
+
return qt(Et(o)).toLowerCase();
|
|
867
|
+
}, J = (e) => `/${e}/p`, K = (e) => {
|
|
868
|
+
const t = Math.max(
|
|
869
|
+
...e.map((r) => r.NumberOfInstallments)
|
|
870
|
+
), o = e.find(
|
|
871
|
+
(r) => r.NumberOfInstallments === t
|
|
872
|
+
);
|
|
873
|
+
return {
|
|
874
|
+
count: (o == null ? void 0 : o.NumberOfInstallments) ?? 0,
|
|
875
|
+
value: (o == null ? void 0 : o.Value) ?? 0
|
|
876
|
+
};
|
|
877
|
+
}, Y = (e, t) => {
|
|
878
|
+
const o = {
|
|
879
|
+
price: 0,
|
|
880
|
+
listPrice: 0,
|
|
881
|
+
sellerDefault: !1
|
|
882
|
+
}, s = e.map(
|
|
883
|
+
(a) => Rt({
|
|
884
|
+
offer: a.commertialOffer,
|
|
885
|
+
seller: a,
|
|
886
|
+
product: t
|
|
887
|
+
})
|
|
888
|
+
).sort(M).map((a) => (a.seller.sellerId === "1" && a.AvailableQuantity > 0 && (o.price = a.Price, o.listPrice = a.ListPrice, o.sellerDefault = !0), {
|
|
889
|
+
availability: a.AvailableQuantity > 0,
|
|
890
|
+
listPrice: a.ListPrice,
|
|
891
|
+
price: Ft(a),
|
|
892
|
+
priceValidUntil: a.PriceValidUntil,
|
|
893
|
+
priceCurrency: "BRL",
|
|
894
|
+
installments: a.Installments,
|
|
895
|
+
lowPrice: a.spotPrice,
|
|
896
|
+
quantity: a.AvailableQuantity,
|
|
897
|
+
seller: {
|
|
898
|
+
identifier: a.seller.sellerId
|
|
899
|
+
}
|
|
900
|
+
}));
|
|
901
|
+
return {
|
|
902
|
+
lowPrice: o.sellerDefault ? o.price : s[0].price,
|
|
903
|
+
highPrice: o.sellerDefault ? o.listPrice : s[0].listPrice,
|
|
904
|
+
offers: s
|
|
905
|
+
};
|
|
906
|
+
}, W = (e) => {
|
|
907
|
+
const { attributes: t, itemId: o, name: r, sellers: s, variations: a } = e;
|
|
908
|
+
return {
|
|
909
|
+
additionalProperty: q(a, t, []),
|
|
910
|
+
name: r,
|
|
911
|
+
offers: {
|
|
912
|
+
offers: s.map(({ sellerId: i, commertialOffer: c }) => ({
|
|
913
|
+
availability: yt(c.AvailableQuantity > 0),
|
|
914
|
+
listPrice: c.ListPrice,
|
|
915
|
+
price: c.Price,
|
|
916
|
+
quantity: c.AvailableQuantity,
|
|
917
|
+
seller: {
|
|
918
|
+
identifier: i
|
|
919
|
+
}
|
|
920
|
+
}))
|
|
921
|
+
},
|
|
922
|
+
sku: o
|
|
923
|
+
// slug: getSlug('', itemId), // getSlug('', itemId) que tipo de slug é esse?
|
|
924
|
+
};
|
|
925
|
+
}, Tt = (e) => {
|
|
926
|
+
var y;
|
|
927
|
+
const {
|
|
928
|
+
attributes: t,
|
|
929
|
+
referenceId: o,
|
|
930
|
+
isVariantOf: r,
|
|
931
|
+
images: s,
|
|
932
|
+
itemId: a,
|
|
933
|
+
name: i,
|
|
934
|
+
sellers: c,
|
|
935
|
+
videos: l,
|
|
936
|
+
variations: g
|
|
937
|
+
} = e, {
|
|
938
|
+
brand: p,
|
|
939
|
+
categories: d,
|
|
940
|
+
categoriesIds: m,
|
|
941
|
+
description: b,
|
|
942
|
+
linkText: f,
|
|
943
|
+
productClusters: T,
|
|
944
|
+
clusterHighlights: $,
|
|
945
|
+
productName: v,
|
|
946
|
+
properties: A,
|
|
947
|
+
productId: P
|
|
948
|
+
} = r, N = d.slice().reverse(), C = Y(c, e.isVariantOf), j = K(C.offers[0].installments);
|
|
949
|
+
return {
|
|
950
|
+
sku: a,
|
|
951
|
+
gtin: ((y = o[0]) == null ? void 0 : y.Value) ?? "",
|
|
952
|
+
name: v ?? i,
|
|
953
|
+
description: b,
|
|
954
|
+
releaseDate: r.releaseDate ?? "",
|
|
955
|
+
slug: f,
|
|
956
|
+
video: l[0],
|
|
957
|
+
categories: d,
|
|
958
|
+
categoriesIds: m,
|
|
959
|
+
id: P,
|
|
960
|
+
brand: { name: p, brandName: p },
|
|
961
|
+
seo: {
|
|
962
|
+
description: b,
|
|
963
|
+
title: v,
|
|
964
|
+
canonical: J(f)
|
|
965
|
+
},
|
|
966
|
+
cluster: {
|
|
967
|
+
generals: T,
|
|
968
|
+
highlights: $
|
|
969
|
+
},
|
|
970
|
+
properties: A,
|
|
971
|
+
availability: { status: C.offers[0].availability },
|
|
972
|
+
breadcrumbList: {
|
|
973
|
+
itemListElement: [
|
|
974
|
+
...N.map((h, F) => {
|
|
975
|
+
const I = h.split("/"), R = I[I.length - 2], k = I.map(Q).join("/");
|
|
976
|
+
return {
|
|
977
|
+
name: R,
|
|
978
|
+
item: k,
|
|
979
|
+
position: F + 1
|
|
980
|
+
};
|
|
981
|
+
}),
|
|
982
|
+
{
|
|
983
|
+
name: r.productName,
|
|
984
|
+
item: f,
|
|
985
|
+
position: d.length + 1
|
|
986
|
+
}
|
|
987
|
+
],
|
|
988
|
+
numberOfItems: d.length
|
|
989
|
+
},
|
|
990
|
+
image: z(s),
|
|
991
|
+
offers: C,
|
|
992
|
+
additionalProperty: q(g, t, []),
|
|
993
|
+
isVariantOf: {
|
|
994
|
+
productGroupID: r.productId,
|
|
995
|
+
hasVariant: r.items.map((h) => W(h))
|
|
996
|
+
},
|
|
997
|
+
installments: j
|
|
998
|
+
};
|
|
999
|
+
}, At = (e) => {
|
|
1000
|
+
var y;
|
|
1001
|
+
const {
|
|
1002
|
+
attributes: t,
|
|
1003
|
+
referenceId: o,
|
|
1004
|
+
isVariantOf: r,
|
|
1005
|
+
images: s,
|
|
1006
|
+
itemId: a,
|
|
1007
|
+
name: i,
|
|
1008
|
+
sellers: c,
|
|
1009
|
+
Videos: l,
|
|
1010
|
+
variations: g
|
|
1011
|
+
} = e, {
|
|
1012
|
+
brand: p,
|
|
1013
|
+
categories: d,
|
|
1014
|
+
categoriesIds: m,
|
|
1015
|
+
description: b,
|
|
1016
|
+
linkText: f,
|
|
1017
|
+
productClusters: T,
|
|
1018
|
+
productName: $,
|
|
1019
|
+
Coleção: v,
|
|
1020
|
+
"ID Coleção": A,
|
|
1021
|
+
productId: P
|
|
1022
|
+
} = r, N = d.slice().reverse(), C = Y(c, e.isVariantOf), j = K(C.offers[0].installments);
|
|
1023
|
+
return {
|
|
1024
|
+
sku: a,
|
|
1025
|
+
gtin: ((y = o[0]) == null ? void 0 : y.Value) ?? "",
|
|
1026
|
+
name: $ ?? i,
|
|
1027
|
+
description: b,
|
|
1028
|
+
releaseDate: r.releaseDate ?? "",
|
|
1029
|
+
slug: f,
|
|
1030
|
+
video: l[0],
|
|
1031
|
+
categories: d,
|
|
1032
|
+
categoriesIds: m,
|
|
1033
|
+
collection: v,
|
|
1034
|
+
collectionId: A,
|
|
1035
|
+
id: P,
|
|
1036
|
+
brand: { name: p, brandName: p },
|
|
1037
|
+
seo: {
|
|
1038
|
+
description: b,
|
|
1039
|
+
title: $,
|
|
1040
|
+
canonical: J(f)
|
|
1041
|
+
},
|
|
1042
|
+
cluster: {
|
|
1043
|
+
generals: T,
|
|
1044
|
+
highlights: []
|
|
1045
|
+
// TODO: add highlights
|
|
1046
|
+
},
|
|
1047
|
+
availability: { status: C.offers[0].availability },
|
|
1048
|
+
breadcrumbList: {
|
|
1049
|
+
itemListElement: [
|
|
1050
|
+
...N.map((h, F) => {
|
|
1051
|
+
const I = h.split("/"), R = I[I.length - 2], k = I.map(Q).join("/");
|
|
1052
|
+
return {
|
|
1053
|
+
name: R,
|
|
1054
|
+
item: k,
|
|
1055
|
+
position: F + 1
|
|
1056
|
+
};
|
|
1057
|
+
}),
|
|
1058
|
+
{
|
|
1059
|
+
name: r.productName,
|
|
1060
|
+
item: f,
|
|
1061
|
+
position: d.length + 1
|
|
1062
|
+
}
|
|
1063
|
+
],
|
|
1064
|
+
numberOfItems: d.length
|
|
1065
|
+
},
|
|
1066
|
+
image: z(s),
|
|
1067
|
+
offers: C,
|
|
1068
|
+
additionalProperty: q(g, t, []),
|
|
1069
|
+
isVariantOf: {
|
|
1070
|
+
productGroupID: r.productId,
|
|
1071
|
+
hasVariant: r.items.map((h) => {
|
|
1072
|
+
const { variations: F } = h, I = F.map((R) => ({
|
|
1073
|
+
name: R,
|
|
1074
|
+
values: h[R]
|
|
1075
|
+
}));
|
|
1076
|
+
return {
|
|
1077
|
+
...W(h),
|
|
1078
|
+
additionalProperty: q(
|
|
1079
|
+
I,
|
|
1080
|
+
t,
|
|
1081
|
+
[]
|
|
1082
|
+
)
|
|
1083
|
+
};
|
|
1084
|
+
})
|
|
1085
|
+
},
|
|
1086
|
+
installments: j
|
|
1087
|
+
};
|
|
1088
|
+
}, Pt = n.array().of(n.object({
|
|
1089
|
+
key: n.string().required(),
|
|
1090
|
+
value: n.string().required()
|
|
1091
|
+
})).required("Facets are required");
|
|
1092
|
+
async function Nt({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
1093
|
+
if (!t) {
|
|
1094
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
await Pt.validate(t);
|
|
1098
|
+
const r = new URLSearchParams({}), s = t.map(({ key: i, value: c }) => `${i}/${c}`).join("/");
|
|
1099
|
+
ee(t, r);
|
|
1100
|
+
const a = `${e}/api/catalog_system/pub/products/crossselling/${s}`;
|
|
1101
|
+
return u(a, {
|
|
1102
|
+
cache: "no-store",
|
|
1103
|
+
...o
|
|
1104
|
+
}).then((i) => i.map((l) => {
|
|
1105
|
+
const g = x(l.items);
|
|
1106
|
+
return g && L(g, l);
|
|
1107
|
+
}).filter((l) => !!l).map((l) => ({
|
|
1108
|
+
node: At(l)
|
|
1109
|
+
})));
|
|
1110
|
+
}
|
|
1111
|
+
const X = ({
|
|
1112
|
+
apiUrl: e,
|
|
1113
|
+
body: t,
|
|
1114
|
+
fetchOptions: o,
|
|
1115
|
+
extraData: r
|
|
1116
|
+
}) => {
|
|
1117
|
+
if (!t) {
|
|
1118
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
const {
|
|
1122
|
+
query: s = "",
|
|
1123
|
+
page: a = 1,
|
|
1124
|
+
count: i,
|
|
1125
|
+
sort: c = "",
|
|
1126
|
+
facets: l = [],
|
|
1127
|
+
type: g,
|
|
1128
|
+
hideUnavailableItems: p = !0,
|
|
1129
|
+
locale: d = ""
|
|
1130
|
+
} = t, m = new URLSearchParams({
|
|
1131
|
+
page: a.toString(),
|
|
1132
|
+
count: (i == null ? void 0 : i.toString()) ?? (r == null ? void 0 : r.ITEMS_PER_PAGE) ?? 24,
|
|
1133
|
+
query: s,
|
|
1134
|
+
sort: c,
|
|
1135
|
+
locale: d
|
|
1136
|
+
});
|
|
1137
|
+
p !== void 0 && m.append("hideUnavailableItems", p.toString());
|
|
1138
|
+
const b = l.map((f) => `${f.key}/${f.value}`).join("/") ?? "";
|
|
1139
|
+
return ie(
|
|
1140
|
+
`${e}/api/io/_v/api/intelligent-search/${g}/${b}?${m.toString()}`,
|
|
1141
|
+
{
|
|
1142
|
+
headers: {
|
|
1143
|
+
Accept: "application/json",
|
|
1144
|
+
"content-type": "application/json"
|
|
1145
|
+
},
|
|
1146
|
+
...o
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
};
|
|
1150
|
+
async function jt({ body: e, extraData: t, ...o }) {
|
|
1151
|
+
if (!e) {
|
|
1152
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
const r = await X({
|
|
1156
|
+
body: {
|
|
1157
|
+
...e,
|
|
1158
|
+
type: "product_search"
|
|
1159
|
+
},
|
|
1160
|
+
extraData: t,
|
|
1161
|
+
...o
|
|
1162
|
+
}), s = (r == null ? void 0 : r.products.map((c) => {
|
|
1163
|
+
const l = x(c.items);
|
|
1164
|
+
return l && L(l, c);
|
|
1165
|
+
}).filter((c) => !!c)) ?? [], {
|
|
1166
|
+
pagination: a,
|
|
1167
|
+
recordsFiltered: i
|
|
1168
|
+
} = r;
|
|
1169
|
+
return {
|
|
1170
|
+
data: {
|
|
1171
|
+
pagination: {
|
|
1172
|
+
nextPage: a.after.length > 0,
|
|
1173
|
+
previousPage: a.before.length > 0,
|
|
1174
|
+
startCursor: "0",
|
|
1175
|
+
endCursor: i.toString(),
|
|
1176
|
+
count: i,
|
|
1177
|
+
total: a.count
|
|
1178
|
+
},
|
|
1179
|
+
products: s.map((c, l) => ({
|
|
1180
|
+
node: Tt(c),
|
|
1181
|
+
cursor: l.toString()
|
|
1182
|
+
}))
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
async function kt({ body: e, extraData: t, ...o }) {
|
|
1187
|
+
if (!e) {
|
|
1188
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
const r = await X({
|
|
1192
|
+
body: {
|
|
1193
|
+
...e,
|
|
1194
|
+
type: "facets"
|
|
1195
|
+
},
|
|
1196
|
+
extraData: t,
|
|
1197
|
+
...o
|
|
1198
|
+
});
|
|
1199
|
+
return !r || !r.facets ? (console.error("[ERROR FETCHING] No facets found"), { data: { facets: [] } }) : {
|
|
1200
|
+
data: {
|
|
1201
|
+
...r,
|
|
1202
|
+
facets: te(r, e == null ? void 0 : e.selectedFacets, (e == null ? void 0 : e.query) ?? "")
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
const wt = n.object({
|
|
1207
|
+
query: n.string().optional(),
|
|
1208
|
+
locale: n.string().optional()
|
|
1209
|
+
});
|
|
1210
|
+
async function Dt({ apiUrl: e, body: t, fetchOptions: o }) {
|
|
1211
|
+
if (!t) {
|
|
1212
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
await wt.validate(t);
|
|
1216
|
+
const { query: r = "", locale: s = "default_locale" } = t, a = new URLSearchParams({ query: r, locale: s });
|
|
1217
|
+
return u(
|
|
1218
|
+
`${e}/api/io/_v/api/intelligent-search/search_suggestions?${a.toString()}`,
|
|
1219
|
+
{
|
|
1220
|
+
...o
|
|
1221
|
+
}
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
async function _t({ apiUrl: e }) {
|
|
1225
|
+
return u(`${e}/api/io/_v/api/intelligent-search/top_searches`);
|
|
745
1226
|
}
|
|
746
|
-
const
|
|
1227
|
+
const Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
747
1228
|
__proto__: null,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1229
|
+
getSearchAutoCompleteSuggestions: It,
|
|
1230
|
+
getSearchCrossellingProducts: Nt,
|
|
1231
|
+
getSearchFacets: kt,
|
|
1232
|
+
getSearchProducts: jt,
|
|
1233
|
+
getSearchSuggestedTerms: Dt,
|
|
1234
|
+
getSearchTopSearchs: _t
|
|
1235
|
+
}, Symbol.toStringTag, { value: "Module" })), Gt = {
|
|
1236
|
+
parseSearchState: ae,
|
|
1237
|
+
convertSearchParams: ne,
|
|
1238
|
+
filterNonRootFacets: oe,
|
|
1239
|
+
filterNonCategorySelected: re
|
|
1240
|
+
}, Vt = {
|
|
1241
|
+
checkout: Qe,
|
|
1242
|
+
catalog: et,
|
|
1243
|
+
cms: ft,
|
|
1244
|
+
search: Ht
|
|
1245
|
+
}, Lt = {
|
|
1246
|
+
catalog: ut,
|
|
1247
|
+
search: Gt
|
|
757
1248
|
};
|
|
758
1249
|
export {
|
|
759
|
-
|
|
760
|
-
|
|
1250
|
+
Vt as serverAPIs,
|
|
1251
|
+
Lt as serverHelpers
|
|
761
1252
|
};
|