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