@soma-vertical-web/multi-lib 0.0.32 → 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/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/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/index2.js +1 -1
- package/index2.mjs +984 -426
- 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/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,444 +1,465 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { f as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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,
|
|
7
8
|
headers: {
|
|
8
9
|
...s,
|
|
9
10
|
Accept: "application/json",
|
|
10
11
|
"Content-Type": "application/json"
|
|
11
12
|
},
|
|
12
13
|
priority: a,
|
|
13
|
-
|
|
14
|
+
cache: i,
|
|
15
|
+
...r ? { body: JSON.stringify(r) } : {}
|
|
14
16
|
// not body in get
|
|
15
|
-
}).then((
|
|
16
|
-
console.error("[ERROR FETCH VTEX]",
|
|
17
|
+
}).then((c) => c.json()).catch((c) => {
|
|
18
|
+
console.error("[ERROR FETCH VTEX]", c);
|
|
17
19
|
});
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
}, 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()
|
|
21
42
|
});
|
|
22
|
-
async function
|
|
23
|
-
if (!
|
|
43
|
+
async function se({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
44
|
+
if (!t) {
|
|
24
45
|
console.error("[ERROR FETCHING] Body is required");
|
|
25
46
|
return;
|
|
26
47
|
}
|
|
27
|
-
await
|
|
28
|
-
const { country:
|
|
48
|
+
await ae.validate(t);
|
|
49
|
+
const { country: r, postalCode: s } = t;
|
|
29
50
|
return await l(
|
|
30
|
-
`${
|
|
51
|
+
`${e}/api/checkout/pub/postal-code/${r}/${s}`,
|
|
31
52
|
{
|
|
32
53
|
method: "POST",
|
|
33
|
-
body:
|
|
34
|
-
...
|
|
54
|
+
body: t,
|
|
55
|
+
...n
|
|
35
56
|
}
|
|
36
57
|
);
|
|
37
58
|
}
|
|
38
|
-
const
|
|
39
|
-
orderFormId:
|
|
40
|
-
sellerCode:
|
|
41
|
-
sellerName:
|
|
59
|
+
const ie = o.object({
|
|
60
|
+
orderFormId: o.string().nullable(),
|
|
61
|
+
sellerCode: o.string().nullable(),
|
|
62
|
+
sellerName: o.string().nullable()
|
|
42
63
|
});
|
|
43
|
-
async function
|
|
44
|
-
apiUrl:
|
|
45
|
-
body:
|
|
46
|
-
fetchOptions:
|
|
64
|
+
async function L({
|
|
65
|
+
apiUrl: e,
|
|
66
|
+
body: t,
|
|
67
|
+
fetchOptions: n
|
|
47
68
|
}) {
|
|
48
|
-
if (!
|
|
69
|
+
if (!t) {
|
|
49
70
|
console.error("[ERROR FETCHING] Body is required");
|
|
50
71
|
return;
|
|
51
72
|
}
|
|
52
|
-
await
|
|
53
|
-
const { orderFormId:
|
|
73
|
+
await ie.validate(t);
|
|
74
|
+
const { orderFormId: r, sellerCode: s, sellerName: a } = t, i = s ? `${s.trim()} - ${a}` : null;
|
|
54
75
|
return l(
|
|
55
|
-
`${
|
|
76
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/openTextField`,
|
|
56
77
|
{
|
|
57
78
|
method: "POST",
|
|
58
79
|
body: {
|
|
59
80
|
value: i
|
|
60
81
|
},
|
|
61
|
-
...
|
|
82
|
+
...n
|
|
62
83
|
}
|
|
63
84
|
);
|
|
64
85
|
}
|
|
65
|
-
const
|
|
66
|
-
orderFormId:
|
|
67
|
-
sellerCode:
|
|
68
|
-
marketingData:
|
|
86
|
+
const ce = o.object({
|
|
87
|
+
orderFormId: o.string().nullable(),
|
|
88
|
+
sellerCode: o.string().nullable(),
|
|
89
|
+
marketingData: o.object()
|
|
69
90
|
});
|
|
70
|
-
async function
|
|
71
|
-
if (!
|
|
91
|
+
async function V({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
92
|
+
if (!t) {
|
|
72
93
|
console.error("[ERROR FETCHING] Body is required");
|
|
73
94
|
return;
|
|
74
95
|
}
|
|
75
|
-
await
|
|
76
|
-
const { orderFormId:
|
|
96
|
+
await ce.validate(t);
|
|
97
|
+
const { orderFormId: r, sellerCode: s, marketingData: a } = t, i = s ? {
|
|
77
98
|
utmCampaign: s ? s.toUpperCase() : "",
|
|
78
99
|
utmiCampaign: s ? "codigodavendedora" : "semcodigo"
|
|
79
100
|
} : {};
|
|
80
101
|
return l(
|
|
81
|
-
`${
|
|
102
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/marketingData`,
|
|
82
103
|
{
|
|
83
104
|
method: "POST",
|
|
84
105
|
body: {
|
|
85
106
|
...a,
|
|
86
107
|
...i
|
|
87
108
|
},
|
|
88
|
-
...
|
|
109
|
+
...n
|
|
89
110
|
}
|
|
90
111
|
);
|
|
91
112
|
}
|
|
92
|
-
const
|
|
93
|
-
orderFormId:
|
|
94
|
-
sellerCode:
|
|
95
|
-
sellerName:
|
|
113
|
+
const le = o.object({
|
|
114
|
+
orderFormId: o.string().nullable(),
|
|
115
|
+
sellerCode: o.string().nullable(),
|
|
116
|
+
sellerName: o.string().nullable()
|
|
96
117
|
});
|
|
97
|
-
async function
|
|
98
|
-
if (!
|
|
118
|
+
async function ue({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
119
|
+
if (!t) {
|
|
99
120
|
console.error("[ERROR FETCHING] Body is required");
|
|
100
121
|
return;
|
|
101
122
|
}
|
|
102
|
-
await
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
apiUrl:
|
|
123
|
+
await le.validate(t);
|
|
124
|
+
const r = await L({ apiUrl: e, body: t, fetchOptions: n });
|
|
125
|
+
return V({
|
|
126
|
+
apiUrl: e,
|
|
106
127
|
body: {
|
|
107
|
-
...
|
|
108
|
-
marketingData:
|
|
128
|
+
...t,
|
|
129
|
+
marketingData: r == null ? void 0 : r.marketingData
|
|
109
130
|
},
|
|
110
|
-
fetchOptions:
|
|
131
|
+
fetchOptions: n
|
|
111
132
|
});
|
|
112
133
|
}
|
|
113
|
-
const
|
|
114
|
-
orderFormId:
|
|
115
|
-
coupon:
|
|
134
|
+
const de = o.object({
|
|
135
|
+
orderFormId: o.string().nullable(),
|
|
136
|
+
coupon: o.string().nullable()
|
|
116
137
|
});
|
|
117
|
-
async function
|
|
118
|
-
apiUrl:
|
|
119
|
-
body:
|
|
120
|
-
fetchOptions:
|
|
138
|
+
async function me({
|
|
139
|
+
apiUrl: e,
|
|
140
|
+
body: t,
|
|
141
|
+
fetchOptions: n
|
|
121
142
|
}) {
|
|
122
|
-
if (!
|
|
143
|
+
if (!t) {
|
|
123
144
|
console.error("[ERROR FETCHING] Body is required");
|
|
124
145
|
return;
|
|
125
146
|
}
|
|
126
|
-
await
|
|
127
|
-
const { coupon:
|
|
147
|
+
await de.validate(t);
|
|
148
|
+
const { coupon: r = "", orderFormId: s } = t;
|
|
128
149
|
return l(
|
|
129
|
-
`${
|
|
150
|
+
`${e}/api/checkout/pub/orderForm/${s}/coupons`,
|
|
130
151
|
{
|
|
131
152
|
method: "POST",
|
|
132
|
-
body: { text:
|
|
133
|
-
...
|
|
153
|
+
body: { text: r },
|
|
154
|
+
...n
|
|
134
155
|
}
|
|
135
156
|
);
|
|
136
157
|
}
|
|
137
|
-
const
|
|
138
|
-
appId:
|
|
139
|
-
orderFormId:
|
|
140
|
-
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())
|
|
141
162
|
});
|
|
142
|
-
async function
|
|
143
|
-
apiUrl:
|
|
144
|
-
body:
|
|
145
|
-
fetchOptions:
|
|
163
|
+
async function fe({
|
|
164
|
+
apiUrl: e,
|
|
165
|
+
body: t,
|
|
166
|
+
fetchOptions: n
|
|
146
167
|
}) {
|
|
147
|
-
if (!
|
|
168
|
+
if (!t) {
|
|
148
169
|
console.error("[ERROR FETCHING] Body is required");
|
|
149
170
|
return;
|
|
150
171
|
}
|
|
151
|
-
await
|
|
152
|
-
const { appId:
|
|
172
|
+
await pe.validate(t);
|
|
173
|
+
const { appId: r = "faststore", orderFormId: s, key: a } = t;
|
|
153
174
|
return l(
|
|
154
|
-
`${
|
|
175
|
+
`${e}/api/checkout/pub/orderForm/${s}/customData/${r}/${a}`,
|
|
155
176
|
{
|
|
156
177
|
method: "PUT",
|
|
157
|
-
...
|
|
178
|
+
...n
|
|
158
179
|
}
|
|
159
180
|
);
|
|
160
181
|
}
|
|
161
|
-
const
|
|
162
|
-
name:
|
|
163
|
-
content:
|
|
182
|
+
const ge = o.object().shape({
|
|
183
|
+
name: o.string().required("Attachment name is required"),
|
|
184
|
+
content: o.object().nullable()
|
|
164
185
|
});
|
|
165
|
-
var
|
|
166
|
-
const
|
|
167
|
-
attachments: (
|
|
168
|
-
id:
|
|
169
|
-
index:
|
|
170
|
-
quantity:
|
|
171
|
-
seller:
|
|
172
|
-
price:
|
|
173
|
-
}),
|
|
174
|
-
orderFormId:
|
|
175
|
-
orderItems:
|
|
186
|
+
var 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)
|
|
176
197
|
});
|
|
177
|
-
async function
|
|
178
|
-
apiUrl:
|
|
179
|
-
body:
|
|
180
|
-
fetchOptions:
|
|
198
|
+
async function be({
|
|
199
|
+
apiUrl: e,
|
|
200
|
+
body: t,
|
|
201
|
+
fetchOptions: n
|
|
181
202
|
}) {
|
|
182
|
-
if (!
|
|
203
|
+
if (!t) {
|
|
183
204
|
console.error("[ERROR FETCHING] Body is required");
|
|
184
205
|
return;
|
|
185
206
|
}
|
|
186
|
-
await
|
|
187
|
-
const { orderFormId:
|
|
207
|
+
await Ie.validate(t);
|
|
208
|
+
const { orderFormId: r, orderItems: s } = t;
|
|
188
209
|
return l(
|
|
189
|
-
`${
|
|
210
|
+
`${e}/api/checkout/pub/orderForm/${r}/items`,
|
|
190
211
|
{
|
|
191
212
|
method: "POST",
|
|
192
213
|
body: { orderItems: s },
|
|
193
|
-
...
|
|
214
|
+
...n
|
|
194
215
|
}
|
|
195
216
|
);
|
|
196
217
|
}
|
|
197
|
-
const
|
|
198
|
-
orderFormId:
|
|
218
|
+
const ye = o.object({
|
|
219
|
+
orderFormId: o.string().nullable()
|
|
199
220
|
});
|
|
200
|
-
async function
|
|
201
|
-
apiUrl:
|
|
202
|
-
body:
|
|
203
|
-
fetchOptions:
|
|
221
|
+
async function Re({
|
|
222
|
+
apiUrl: e,
|
|
223
|
+
body: t,
|
|
224
|
+
fetchOptions: n
|
|
204
225
|
}) {
|
|
205
|
-
if (!
|
|
226
|
+
if (!t) {
|
|
206
227
|
console.error("[ERROR FETCHING] Body is required");
|
|
207
228
|
return;
|
|
208
229
|
}
|
|
209
|
-
await
|
|
210
|
-
const { orderFormId:
|
|
230
|
+
await ye.validate(t);
|
|
231
|
+
const { orderFormId: r } = t;
|
|
211
232
|
return l(
|
|
212
|
-
`${
|
|
233
|
+
`${e}/api/checkout/pub/orderForm/${r}/items/removeAll`,
|
|
213
234
|
{
|
|
214
235
|
method: "POST",
|
|
215
|
-
...
|
|
236
|
+
...n
|
|
216
237
|
}
|
|
217
238
|
);
|
|
218
239
|
}
|
|
219
|
-
const
|
|
220
|
-
name:
|
|
221
|
-
content:
|
|
240
|
+
const Ce = o.object().shape({
|
|
241
|
+
name: o.string().required("Attachment name is required"),
|
|
242
|
+
content: o.object().nullable()
|
|
222
243
|
});
|
|
223
|
-
var
|
|
224
|
-
const
|
|
225
|
-
attachments: (
|
|
226
|
-
id:
|
|
227
|
-
index:
|
|
228
|
-
quantity:
|
|
229
|
-
seller:
|
|
230
|
-
price:
|
|
231
|
-
}),
|
|
232
|
-
orderFormId:
|
|
233
|
-
orderItems:
|
|
244
|
+
var 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)
|
|
234
255
|
});
|
|
235
|
-
async function
|
|
236
|
-
apiUrl:
|
|
237
|
-
body:
|
|
238
|
-
fetchOptions:
|
|
256
|
+
async function Oe({
|
|
257
|
+
apiUrl: e,
|
|
258
|
+
body: t,
|
|
259
|
+
fetchOptions: n
|
|
239
260
|
}) {
|
|
240
|
-
if (!
|
|
261
|
+
if (!t) {
|
|
241
262
|
console.error("[ERROR FETCHING] Body is required");
|
|
242
263
|
return;
|
|
243
264
|
}
|
|
244
|
-
await
|
|
245
|
-
const { orderFormId:
|
|
265
|
+
await ve.validate(t);
|
|
266
|
+
const { orderFormId: r, orderItems: s } = t;
|
|
246
267
|
return l(
|
|
247
|
-
`${
|
|
268
|
+
`${e}/api/checkout/pub/orderForm/${r}/items/update`,
|
|
248
269
|
{
|
|
249
270
|
method: "POST",
|
|
250
271
|
body: { orderItems: s },
|
|
251
|
-
...
|
|
272
|
+
...n
|
|
252
273
|
}
|
|
253
274
|
);
|
|
254
275
|
}
|
|
255
|
-
const
|
|
256
|
-
orderFormId:
|
|
276
|
+
const $e = o.object({
|
|
277
|
+
orderFormId: o.string().nullable()
|
|
257
278
|
});
|
|
258
|
-
async function
|
|
259
|
-
apiUrl:
|
|
260
|
-
body:
|
|
261
|
-
fetchOptions:
|
|
279
|
+
async function Ee({
|
|
280
|
+
apiUrl: e,
|
|
281
|
+
body: t,
|
|
282
|
+
fetchOptions: n
|
|
262
283
|
}) {
|
|
263
|
-
if (!
|
|
284
|
+
if (!t) {
|
|
264
285
|
console.error("[ERROR FETCHING] Body is required");
|
|
265
286
|
return;
|
|
266
287
|
}
|
|
267
|
-
await
|
|
268
|
-
const { orderFormId:
|
|
288
|
+
await $e.validate(t);
|
|
289
|
+
const { orderFormId: r } = t;
|
|
269
290
|
return l(
|
|
270
|
-
`${
|
|
291
|
+
`${e}/api/checkout/pub/orderForm/${r}/messages/clear`,
|
|
271
292
|
{
|
|
272
293
|
method: "POST",
|
|
273
|
-
...
|
|
294
|
+
...n
|
|
274
295
|
}
|
|
275
296
|
);
|
|
276
297
|
}
|
|
277
|
-
const
|
|
278
|
-
id:
|
|
298
|
+
const Se = o.object({
|
|
299
|
+
id: o.string().nullable(),
|
|
279
300
|
// id offering
|
|
280
|
-
itemIndex:
|
|
281
|
-
orderFormId:
|
|
282
|
-
remove:
|
|
301
|
+
itemIndex: o.number().nullable(),
|
|
302
|
+
orderFormId: o.string().nullable(),
|
|
303
|
+
remove: o.boolean().nullable()
|
|
283
304
|
});
|
|
284
|
-
async function
|
|
285
|
-
if (!
|
|
305
|
+
async function Te({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
306
|
+
if (!t) {
|
|
286
307
|
console.error("[ERROR FETCHING] Body is required");
|
|
287
308
|
return;
|
|
288
309
|
}
|
|
289
|
-
await
|
|
290
|
-
const { itemIndex:
|
|
291
|
-
return l(
|
|
310
|
+
await 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, {
|
|
292
313
|
method: "POST",
|
|
293
314
|
body: { id: a },
|
|
294
|
-
...
|
|
315
|
+
...n
|
|
295
316
|
});
|
|
296
317
|
}
|
|
297
|
-
const
|
|
298
|
-
orderFormId:
|
|
318
|
+
const qe = o.object({
|
|
319
|
+
orderFormId: o.string().nullable()
|
|
299
320
|
});
|
|
300
|
-
async function
|
|
301
|
-
apiUrl:
|
|
302
|
-
body:
|
|
303
|
-
fetchOptions:
|
|
304
|
-
extraData:
|
|
321
|
+
async function Ae({
|
|
322
|
+
apiUrl: e,
|
|
323
|
+
body: t,
|
|
324
|
+
fetchOptions: n,
|
|
325
|
+
extraData: r
|
|
305
326
|
}) {
|
|
306
327
|
var i;
|
|
307
|
-
if (!
|
|
328
|
+
if (!t) {
|
|
308
329
|
console.error("[ERROR FETCHING] Body is required");
|
|
309
330
|
return;
|
|
310
331
|
}
|
|
311
|
-
await
|
|
332
|
+
await qe.validate(t);
|
|
312
333
|
const s = new URLSearchParams({
|
|
313
334
|
refreshOutdatedData: "true"
|
|
314
|
-
}), a =
|
|
315
|
-
return l(a, { method: "GET", ...
|
|
316
|
-
}
|
|
317
|
-
const
|
|
318
|
-
orderFormId:
|
|
319
|
-
email:
|
|
320
|
-
firstName:
|
|
321
|
-
lastName:
|
|
322
|
-
documentType:
|
|
323
|
-
document:
|
|
324
|
-
phone:
|
|
335
|
+
}), a = t.orderFormId && ((i = r.orderFormPurchaseId) == null ? void 0 : i.value) !== t.orderFormId ? `${e}/api/checkout/pub/orderForm/${t.orderFormId}?${String(s)}` : `${e}/api/checkout/pub/orderForm`;
|
|
336
|
+
return 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}$/)
|
|
325
346
|
});
|
|
326
|
-
async function
|
|
327
|
-
apiUrl:
|
|
328
|
-
body:
|
|
329
|
-
fetchOptions:
|
|
347
|
+
async function ke({
|
|
348
|
+
apiUrl: e,
|
|
349
|
+
body: t,
|
|
350
|
+
fetchOptions: n
|
|
330
351
|
}) {
|
|
331
|
-
if (!
|
|
352
|
+
if (!t) {
|
|
332
353
|
console.error("[ERROR FETCHING] Body is required");
|
|
333
354
|
return;
|
|
334
355
|
}
|
|
335
|
-
await
|
|
336
|
-
const { orderFormId:
|
|
356
|
+
await Pe.validate(t);
|
|
357
|
+
const { orderFormId: r, ...s } = t;
|
|
337
358
|
return l(
|
|
338
|
-
`${
|
|
359
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/clientProfileData`,
|
|
339
360
|
{
|
|
340
361
|
method: "POST",
|
|
341
362
|
body: { ...s },
|
|
342
|
-
...
|
|
363
|
+
...n
|
|
343
364
|
}
|
|
344
365
|
);
|
|
345
366
|
}
|
|
346
|
-
const
|
|
347
|
-
sellerCode:
|
|
367
|
+
const Ne = o.object({
|
|
368
|
+
sellerCode: o.string().nullable()
|
|
348
369
|
});
|
|
349
|
-
async function
|
|
350
|
-
apiUrl:
|
|
351
|
-
body:
|
|
352
|
-
fetchOptions:
|
|
370
|
+
async function je({
|
|
371
|
+
apiUrl: e,
|
|
372
|
+
body: t,
|
|
373
|
+
fetchOptions: n
|
|
353
374
|
}) {
|
|
354
|
-
if (!
|
|
375
|
+
if (!t) {
|
|
355
376
|
console.error("[ERROR FETCHING] Body is required");
|
|
356
377
|
return;
|
|
357
378
|
}
|
|
358
|
-
await
|
|
359
|
-
const { sellerCode:
|
|
379
|
+
await Ne.validate(t);
|
|
380
|
+
const { sellerCode: r = "" } = t;
|
|
360
381
|
return l(
|
|
361
|
-
`${
|
|
382
|
+
`${e}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${r}`,
|
|
362
383
|
{
|
|
363
384
|
method: "GET",
|
|
364
385
|
headers: {
|
|
365
386
|
Accept: "application/vnd.vtex.ds.v10+json"
|
|
366
387
|
},
|
|
367
|
-
...
|
|
388
|
+
...n
|
|
368
389
|
}
|
|
369
390
|
);
|
|
370
391
|
}
|
|
371
|
-
const
|
|
372
|
-
country:
|
|
373
|
-
orderFormId:
|
|
374
|
-
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()
|
|
375
396
|
});
|
|
376
|
-
async function
|
|
377
|
-
apiUrl:
|
|
378
|
-
body:
|
|
379
|
-
fetchOptions:
|
|
397
|
+
async function _e({
|
|
398
|
+
apiUrl: e,
|
|
399
|
+
body: t,
|
|
400
|
+
fetchOptions: n
|
|
380
401
|
}) {
|
|
381
|
-
if (!
|
|
402
|
+
if (!t) {
|
|
382
403
|
console.error("[ERROR FETCHING] Body is required");
|
|
383
404
|
return;
|
|
384
405
|
}
|
|
385
|
-
await
|
|
386
|
-
const { country:
|
|
406
|
+
await we.validate(t);
|
|
407
|
+
const { country: r, orderFormId: s, postalCode: a } = t, i = a ? {
|
|
387
408
|
address: {
|
|
388
409
|
addressType: "residential",
|
|
389
410
|
postalCode: a,
|
|
390
|
-
country:
|
|
411
|
+
country: r
|
|
391
412
|
}
|
|
392
413
|
} : {
|
|
393
414
|
logisticsInfo: [],
|
|
394
415
|
clearAddressIfPostalCodeNotFound: !0
|
|
395
416
|
};
|
|
396
417
|
return l(
|
|
397
|
-
`${
|
|
418
|
+
`${e}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,
|
|
398
419
|
{
|
|
399
420
|
method: "POST",
|
|
400
421
|
body: i,
|
|
401
|
-
...
|
|
422
|
+
...n
|
|
402
423
|
}
|
|
403
424
|
);
|
|
404
425
|
}
|
|
405
|
-
const
|
|
406
|
-
orderFormId:
|
|
407
|
-
options:
|
|
408
|
-
|
|
409
|
-
itemIndex:
|
|
410
|
-
selectedDeliveryChannel:
|
|
411
|
-
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()
|
|
412
433
|
})
|
|
413
434
|
),
|
|
414
|
-
selectedAddresses:
|
|
415
|
-
|
|
416
|
-
addressId:
|
|
417
|
-
addressType:
|
|
418
|
-
city:
|
|
419
|
-
complement:
|
|
420
|
-
country:
|
|
421
|
-
geoCoordinates:
|
|
422
|
-
isDisposable:
|
|
423
|
-
neighborhood:
|
|
424
|
-
number:
|
|
425
|
-
postalCode:
|
|
426
|
-
receiverName:
|
|
427
|
-
reference:
|
|
428
|
-
state:
|
|
429
|
-
street:
|
|
435
|
+
selectedAddresses: 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()
|
|
430
451
|
})
|
|
431
452
|
)
|
|
432
453
|
});
|
|
433
|
-
async function
|
|
434
|
-
if (!
|
|
454
|
+
async function Be({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
455
|
+
if (!t) {
|
|
435
456
|
console.error("[ERROR FETCHING] Body is required");
|
|
436
457
|
return;
|
|
437
458
|
}
|
|
438
|
-
await
|
|
439
|
-
const { orderFormId:
|
|
459
|
+
await De.validate(t);
|
|
460
|
+
const { orderFormId: r, options: s, selectedAddresses: a } = t;
|
|
440
461
|
return l(
|
|
441
|
-
`${
|
|
462
|
+
`${e}/api/checkout/pub/orderForm/${r}/attachments/shippingData`,
|
|
442
463
|
{
|
|
443
464
|
method: "POST",
|
|
444
465
|
body: {
|
|
@@ -446,219 +467,219 @@ async function re({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
446
467
|
clearAddressIfPostalCodeNotFound: !1,
|
|
447
468
|
logisticsInfo: s
|
|
448
469
|
},
|
|
449
|
-
...
|
|
470
|
+
...n
|
|
450
471
|
}
|
|
451
472
|
);
|
|
452
473
|
}
|
|
453
|
-
const
|
|
454
|
-
country:
|
|
455
|
-
postalCode:
|
|
456
|
-
geoCoordinates:
|
|
457
|
-
longitude:
|
|
458
|
-
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()
|
|
459
480
|
})
|
|
460
481
|
});
|
|
461
|
-
async function
|
|
462
|
-
if (!
|
|
482
|
+
async function Ge({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
483
|
+
if (!t) {
|
|
463
484
|
console.error("[ERROR FETCHING] Body is required");
|
|
464
485
|
return;
|
|
465
486
|
}
|
|
466
|
-
await
|
|
467
|
-
const { country:
|
|
487
|
+
await He.validate(t);
|
|
488
|
+
const { country: r = "", geoCoordinates: s, postalCode: a = "" } = t, i = new URLSearchParams({ country: String(r) });
|
|
468
489
|
return a ? i.append("postalCode", a) : i.append(
|
|
469
490
|
"geoCoordinates",
|
|
470
491
|
`${s == null ? void 0 : s.longitude};${s == null ? void 0 : s.latitude}`
|
|
471
492
|
), await l(
|
|
472
|
-
`${
|
|
493
|
+
`${e}/api/checkout/pub/regions/?${i.toString()}`,
|
|
473
494
|
{
|
|
474
495
|
method: "GET",
|
|
475
|
-
...
|
|
496
|
+
...n
|
|
476
497
|
}
|
|
477
498
|
);
|
|
478
499
|
}
|
|
479
|
-
const
|
|
480
|
-
id:
|
|
481
|
-
quantity:
|
|
482
|
-
seller:
|
|
483
|
-
}),
|
|
484
|
-
items:
|
|
485
|
-
country:
|
|
486
|
-
postalCode:
|
|
487
|
-
geoCoordinates:
|
|
500
|
+
const 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)
|
|
488
509
|
});
|
|
489
|
-
async function
|
|
490
|
-
if (!
|
|
510
|
+
async function Ve({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
511
|
+
if (!t) {
|
|
491
512
|
console.error("[ERROR FETCHING] Body is required");
|
|
492
513
|
return;
|
|
493
514
|
}
|
|
494
|
-
return await
|
|
495
|
-
`${
|
|
515
|
+
return await Le.validate(t), l(
|
|
516
|
+
`${e}/api/checkout/pub/orderForms/simulation`,
|
|
496
517
|
{
|
|
497
518
|
method: "POST",
|
|
498
|
-
body:
|
|
499
|
-
...
|
|
519
|
+
body: t,
|
|
520
|
+
...n
|
|
500
521
|
}
|
|
501
522
|
);
|
|
502
523
|
}
|
|
503
|
-
const
|
|
524
|
+
const Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
504
525
|
__proto__: null,
|
|
505
|
-
getMasterDataSellerCode:
|
|
506
|
-
getOrderForm:
|
|
507
|
-
postOrderFormAddCoupon:
|
|
508
|
-
postOrderFormAttachClientProfileData:
|
|
509
|
-
postOrderFormAttachOrderFormData:
|
|
510
|
-
postOrderFormAttachShippingData:
|
|
511
|
-
postOrderFormAttachmentsMarketingData:
|
|
512
|
-
postOrderFormAttachmentsOpenTextField:
|
|
513
|
-
postOrderFormClearMessages:
|
|
514
|
-
postOrderFormFreightSimulation:
|
|
515
|
-
postOrderFormItems:
|
|
516
|
-
postOrderFormRegion:
|
|
517
|
-
postOrderFormRemoveAllItems:
|
|
518
|
-
postOrderFormUpdateItems:
|
|
519
|
-
postOrderFormUpdateShippingData:
|
|
520
|
-
postOrderformAddress:
|
|
521
|
-
putOrderFormCustomData:
|
|
522
|
-
updateOrderFormOffering:
|
|
523
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
524
|
-
skuId:
|
|
526
|
+
getMasterDataSellerCode: 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()
|
|
525
546
|
});
|
|
526
|
-
async function
|
|
527
|
-
if (!
|
|
547
|
+
async function xe({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
548
|
+
if (!t) {
|
|
528
549
|
console.error("[ERROR FETCHING] Body is required");
|
|
529
550
|
return;
|
|
530
551
|
}
|
|
531
|
-
await
|
|
532
|
-
const { skuId:
|
|
552
|
+
await ze.validate(t);
|
|
553
|
+
const { skuId: r } = t;
|
|
533
554
|
return l(
|
|
534
|
-
`${
|
|
555
|
+
`${e}/api/catalog/pvt/stockkeepingunitkit?parentSkuId=${r}`,
|
|
535
556
|
{
|
|
536
|
-
...
|
|
557
|
+
...n
|
|
537
558
|
}
|
|
538
559
|
);
|
|
539
560
|
}
|
|
540
|
-
const
|
|
541
|
-
ids:
|
|
561
|
+
const Qe = o.object({
|
|
562
|
+
ids: o.array().of(o.string().required("ID are required")).required("IDs are required")
|
|
542
563
|
});
|
|
543
|
-
async function
|
|
544
|
-
if (!
|
|
564
|
+
async function Ye({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
565
|
+
if (!t) {
|
|
545
566
|
console.error("[ERROR FETCHING] Body is required");
|
|
546
567
|
return;
|
|
547
568
|
}
|
|
548
|
-
await
|
|
549
|
-
const { ids:
|
|
569
|
+
await Qe.validate(t);
|
|
570
|
+
const { ids: r } = t;
|
|
550
571
|
return l(
|
|
551
|
-
`${
|
|
572
|
+
`${e}/api/catalog_system/pub/products/search?fq=${r.map((s) => `productId:${s}`).join("&fq=")}`,
|
|
552
573
|
{
|
|
553
|
-
...
|
|
574
|
+
...n
|
|
554
575
|
}
|
|
555
576
|
);
|
|
556
577
|
}
|
|
557
|
-
const
|
|
558
|
-
productId:
|
|
578
|
+
const Ke = o.object({
|
|
579
|
+
productId: o.number().required("Product ID is required")
|
|
559
580
|
});
|
|
560
|
-
async function
|
|
561
|
-
if (!
|
|
581
|
+
async function Je({ apiUrl: e, body: t, fetchOptions: n }) {
|
|
582
|
+
if (!t) {
|
|
562
583
|
console.error("[ERROR FETCHING] Body is required");
|
|
563
584
|
return;
|
|
564
585
|
}
|
|
565
|
-
await
|
|
566
|
-
const { productId:
|
|
586
|
+
await Ke.validate(t);
|
|
587
|
+
const { productId: r } = t;
|
|
567
588
|
return l(
|
|
568
|
-
`${
|
|
589
|
+
`${e}/api/catalog_system/pub/products/crossselling/similars/${r.toString()}`,
|
|
569
590
|
{
|
|
570
|
-
...
|
|
591
|
+
...n
|
|
571
592
|
}
|
|
572
593
|
);
|
|
573
594
|
}
|
|
574
|
-
const
|
|
595
|
+
const Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
575
596
|
__proto__: null,
|
|
576
|
-
getCatalogKitProducts:
|
|
577
|
-
getCatalogProducts:
|
|
578
|
-
getCatalogSimilars:
|
|
579
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
580
|
-
const
|
|
597
|
+
getCatalogKitProducts: 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;
|
|
581
602
|
return {
|
|
582
603
|
id: 0,
|
|
583
|
-
Title: `${Array.isArray(
|
|
584
|
-
MetaTagDescription:
|
|
585
|
-
name:
|
|
604
|
+
Title: `${Array.isArray(n) ? n.map((a) => w(a)).join(",") : w(n)} - ${t.title}`,
|
|
605
|
+
MetaTagDescription: t.description,
|
|
606
|
+
name: r,
|
|
586
607
|
hasChildren: !1,
|
|
587
|
-
url:
|
|
608
|
+
url: e,
|
|
588
609
|
children: []
|
|
589
610
|
};
|
|
590
|
-
},
|
|
591
|
-
category: String(
|
|
592
|
-
title: (
|
|
593
|
-
description: (
|
|
594
|
-
alternates: { canonical:
|
|
611
|
+
}, 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 },
|
|
595
616
|
openGraph: {
|
|
596
617
|
type: "website",
|
|
597
|
-
title: (
|
|
598
|
-
description: (
|
|
599
|
-
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] : []
|
|
600
621
|
}
|
|
601
|
-
}),
|
|
602
|
-
const s =
|
|
603
|
-
(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())
|
|
604
625
|
);
|
|
605
626
|
return (s == null ? void 0 : s.children.find(
|
|
606
|
-
(i) => i.name.toLowerCase() === decodeURIComponent(String(
|
|
627
|
+
(i) => i.name.toLowerCase() === decodeURIComponent(String(r))
|
|
607
628
|
)) ?? s;
|
|
608
|
-
},
|
|
609
|
-
|
|
610
|
-
},
|
|
629
|
+
}, 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([
|
|
611
632
|
"brand",
|
|
612
633
|
"category",
|
|
613
634
|
"department",
|
|
614
635
|
"subcategory",
|
|
615
636
|
"collection",
|
|
616
637
|
"cluster"
|
|
617
|
-
]),
|
|
618
|
-
collection:
|
|
619
|
-
categoryId:
|
|
620
|
-
current_collection:
|
|
621
|
-
items:
|
|
622
|
-
}),
|
|
623
|
-
if (
|
|
624
|
-
(i) => i.sellers.find((
|
|
625
|
-
).length === 0 || (
|
|
626
|
-
return
|
|
627
|
-
const a =
|
|
628
|
-
(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)
|
|
629
650
|
);
|
|
630
|
-
return
|
|
631
|
-
slug: `/${
|
|
632
|
-
productId:
|
|
651
|
+
return n.push({
|
|
652
|
+
slug: `/${r.linkText}/p`,
|
|
653
|
+
productId: r == null ? void 0 : r.productId,
|
|
633
654
|
textureImage: (a == null ? void 0 : a.imageUrl) ?? "",
|
|
634
655
|
textureAlt: (a == null ? void 0 : a.imageText) ?? ""
|
|
635
|
-
}),
|
|
636
|
-
}, []),
|
|
656
|
+
}), n;
|
|
657
|
+
}, []), it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
637
658
|
__proto__: null,
|
|
638
|
-
createEmptySeoCategory:
|
|
639
|
-
createSeoCategory:
|
|
640
|
-
findCategory:
|
|
641
|
-
formattedSimilars:
|
|
642
|
-
isCollectionPageType:
|
|
643
|
-
notFindCategoryError:
|
|
644
|
-
responseAdapter:
|
|
659
|
+
createEmptySeoCategory: We,
|
|
660
|
+
createSeoCategory: et,
|
|
661
|
+
findCategory: tt,
|
|
662
|
+
formattedSimilars: st,
|
|
663
|
+
isCollectionPageType: ot,
|
|
664
|
+
notFindCategoryError: rt,
|
|
665
|
+
responseAdapter: at
|
|
645
666
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
646
|
-
async function
|
|
647
|
-
const s = await
|
|
648
|
-
contentType:
|
|
649
|
-
storeId:
|
|
650
|
-
CMS_PROJECT_NAME:
|
|
651
|
-
NextCookies:
|
|
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
|
|
652
673
|
});
|
|
653
674
|
if (s.status === 200) {
|
|
654
675
|
const a = {
|
|
655
676
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
656
|
-
contentType:
|
|
677
|
+
contentType: e,
|
|
657
678
|
data: s.data
|
|
658
679
|
};
|
|
659
680
|
console.log("Resultado da chamada:", s);
|
|
660
|
-
const i = `backup-${
|
|
661
|
-
return await
|
|
681
|
+
const i = `backup-${e}-${Date.now()}.json`;
|
|
682
|
+
return await re.writeFile(
|
|
662
683
|
`./backups/${i}`,
|
|
663
684
|
JSON.stringify(a, null, 2),
|
|
664
685
|
"utf-8"
|
|
@@ -666,96 +687,633 @@ async function qe({ contentType: t, storeId: e, CMS_PROJECT_NAME: o, NextCookies
|
|
|
666
687
|
}
|
|
667
688
|
return { success: !1, error: s.error || "No data to backup" };
|
|
668
689
|
}
|
|
669
|
-
async function
|
|
670
|
-
return
|
|
690
|
+
async function lt(e) {
|
|
691
|
+
return ct(e);
|
|
671
692
|
}
|
|
672
|
-
async function
|
|
673
|
-
contentType:
|
|
674
|
-
documentId:
|
|
675
|
-
versionId:
|
|
676
|
-
storeId:
|
|
693
|
+
async function ut({
|
|
694
|
+
contentType: e,
|
|
695
|
+
documentId: t,
|
|
696
|
+
versionId: n,
|
|
697
|
+
storeId: r,
|
|
677
698
|
CMS_PROJECT_NAME: s
|
|
678
699
|
}) {
|
|
679
|
-
const a =
|
|
700
|
+
const a = t && t.length ? `/${t}` : "", i = n && n.length ? `?versionId=${n}` : "";
|
|
680
701
|
return fetch(
|
|
681
|
-
`https://${
|
|
702
|
+
`https://${r}.myvtex.com/_v/cms/api/${s}/${e}${a}${i}`,
|
|
682
703
|
{ cache: "no-cache" }
|
|
683
704
|
);
|
|
684
705
|
}
|
|
685
|
-
async function
|
|
686
|
-
contentType:
|
|
687
|
-
documents:
|
|
688
|
-
NextCookies:
|
|
689
|
-
CMS_PROJECT_NAME:
|
|
706
|
+
async function dt({
|
|
707
|
+
contentType: e,
|
|
708
|
+
documents: t,
|
|
709
|
+
NextCookies: n,
|
|
710
|
+
CMS_PROJECT_NAME: r,
|
|
690
711
|
storeId: s
|
|
691
712
|
}) {
|
|
692
713
|
var i;
|
|
693
714
|
const a = JSON.parse(
|
|
694
|
-
((i =
|
|
715
|
+
((i = n().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
|
|
695
716
|
);
|
|
696
|
-
if (a && (a == null ? void 0 : a.contentType) ===
|
|
697
|
-
const
|
|
698
|
-
`https://${s}.myvtex.com/_v/cms/api/${
|
|
717
|
+
if (a && (a == null ? void 0 : a.contentType) === e) {
|
|
718
|
+
const c = a.documentId && a.documentId.length ? `/${a.documentId}` : "", 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}`,
|
|
699
720
|
{ cache: "no-store" }
|
|
700
|
-
)).json(),
|
|
701
|
-
(
|
|
721
|
+
)).json(), d = t.filter(
|
|
722
|
+
(f) => m.id !== f.documentId
|
|
702
723
|
);
|
|
703
|
-
return
|
|
724
|
+
return d.unshift(m), d;
|
|
704
725
|
}
|
|
705
|
-
return
|
|
726
|
+
return t;
|
|
706
727
|
}
|
|
707
|
-
async function
|
|
708
|
-
contentType:
|
|
709
|
-
NextCookies:
|
|
710
|
-
CMS_PROJECT_NAME:
|
|
711
|
-
storeId:
|
|
728
|
+
async function M({
|
|
729
|
+
contentType: e,
|
|
730
|
+
NextCookies: t,
|
|
731
|
+
CMS_PROJECT_NAME: n,
|
|
732
|
+
storeId: r
|
|
712
733
|
}) {
|
|
713
|
-
var
|
|
734
|
+
var p, m;
|
|
714
735
|
const s = JSON.parse(
|
|
715
|
-
((
|
|
736
|
+
((p = t().get("cms_preview_data")) == null ? void 0 : p.value) ?? "{}"
|
|
716
737
|
), a = [];
|
|
717
|
-
let i = 1,
|
|
738
|
+
let i = 1, c = 0, u = !0;
|
|
718
739
|
try {
|
|
719
740
|
do {
|
|
720
|
-
const
|
|
721
|
-
`https://${
|
|
741
|
+
const f = await (await fetch(
|
|
742
|
+
`https://${r}.myvtex.com/_v/cms/api/${n}/${e}?page=${i}`
|
|
722
743
|
)).json();
|
|
723
|
-
i === 1 && (
|
|
724
|
-
} 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);
|
|
725
746
|
if (s.previewMode && a.length) {
|
|
726
|
-
const
|
|
727
|
-
contentType:
|
|
747
|
+
const d = await dt({
|
|
748
|
+
contentType: e,
|
|
728
749
|
documents: a,
|
|
729
|
-
NextCookies:
|
|
730
|
-
CMS_PROJECT_NAME:
|
|
731
|
-
storeId:
|
|
750
|
+
NextCookies: t,
|
|
751
|
+
CMS_PROJECT_NAME: n,
|
|
752
|
+
storeId: r
|
|
732
753
|
});
|
|
733
754
|
return {
|
|
734
|
-
status:
|
|
735
|
-
data:
|
|
755
|
+
status: d.length > 0 ? 200 : 404,
|
|
756
|
+
data: d ?? []
|
|
736
757
|
};
|
|
737
758
|
}
|
|
738
759
|
return {
|
|
739
760
|
status: a.length ? 200 : 404,
|
|
740
761
|
data: a
|
|
741
762
|
};
|
|
742
|
-
} catch (
|
|
743
|
-
return { status: "error", data: [], error:
|
|
763
|
+
} catch (d) {
|
|
764
|
+
return { status: "error", data: [], error: d };
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const 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;
|
|
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
|
+
})));
|
|
1163
|
+
}
|
|
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;
|
|
744
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
|
+
};
|
|
745
1238
|
}
|
|
746
|
-
|
|
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({
|
|
747
1281
|
__proto__: null,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
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
|
|
757
1315
|
};
|
|
758
1316
|
export {
|
|
759
|
-
|
|
760
|
-
|
|
1317
|
+
Xt as serverAPIs,
|
|
1318
|
+
Wt as serverHelpers
|
|
761
1319
|
};
|