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