@soma-vertical-web/multi-lib 0.0.30 → 0.0.31
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/checkout/address/index.d.ts +1 -1
- package/data/api/checkout/order-form/attachments/index.d.ts +1 -1
- package/data/api/checkout/order-form/index.d.ts +1 -0
- package/data/api/checkout/order-form/items/index.d.ts +23 -0
- package/data/api/checkout/order-form/items/update/index.d.ts +0 -18
- package/data/helpers/cart/index.d.ts +1 -1
- package/index.js +14 -14
- package/index.mjs +1 -1
- package/index2.js +1 -1
- package/index2.mjs +294 -259
- package/package.json +1 -1
- package/types/constants.d.ts +0 -8
- package/types/data/api/checkout/index.d.ts +0 -3
package/index2.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
const l = async (t,
|
|
3
|
-
const { method: o = "GET", body: n, headers: s = {}, priority: a = "auto" } =
|
|
1
|
+
import * as e from "yup";
|
|
2
|
+
const l = async (t, r = {}) => {
|
|
3
|
+
const { method: o = "GET", body: n, headers: s = {}, priority: a = "auto" } = r;
|
|
4
4
|
return fetch(t, {
|
|
5
5
|
method: o,
|
|
6
6
|
headers: {
|
|
@@ -14,42 +14,42 @@ const l = async (t, e = {}) => {
|
|
|
14
14
|
}).then((i) => i.json()).catch((i) => {
|
|
15
15
|
console.error("[ERROR FETCH VTEX]", i);
|
|
16
16
|
});
|
|
17
|
-
},
|
|
18
|
-
country:
|
|
19
|
-
postalCode:
|
|
17
|
+
}, C = e.object({
|
|
18
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
19
|
+
postalCode: e.string().nullable()
|
|
20
20
|
});
|
|
21
|
-
async function R({ apiUrl: t, body:
|
|
22
|
-
if (!
|
|
21
|
+
async function R({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
22
|
+
if (!r) {
|
|
23
23
|
console.error("[ERROR FETCHING] Body is required");
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
await
|
|
27
|
-
const { country: n, postalCode: s } =
|
|
26
|
+
await C.validate(r);
|
|
27
|
+
const { country: n, postalCode: s } = r;
|
|
28
28
|
return await l(
|
|
29
29
|
`${t}/api/checkout/pub/postal-code/${n}/${s}`,
|
|
30
30
|
{
|
|
31
31
|
method: "POST",
|
|
32
|
-
body:
|
|
32
|
+
body: r,
|
|
33
33
|
...o
|
|
34
34
|
}
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
|
-
const O =
|
|
38
|
-
orderFormId:
|
|
39
|
-
sellerCode:
|
|
40
|
-
sellerName:
|
|
37
|
+
const O = e.object({
|
|
38
|
+
orderFormId: e.string().nullable(),
|
|
39
|
+
sellerCode: e.string().nullable(),
|
|
40
|
+
sellerName: e.string().nullable()
|
|
41
41
|
});
|
|
42
42
|
async function b({
|
|
43
43
|
apiUrl: t,
|
|
44
|
-
body:
|
|
44
|
+
body: r,
|
|
45
45
|
fetchOptions: o
|
|
46
46
|
}) {
|
|
47
|
-
if (!
|
|
47
|
+
if (!r) {
|
|
48
48
|
console.error("[ERROR FETCHING] Body is required");
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
await O.validate(
|
|
52
|
-
const { orderFormId: n, sellerCode: s, sellerName: a } =
|
|
51
|
+
await O.validate(r);
|
|
52
|
+
const { orderFormId: n, sellerCode: s, sellerName: a } = r, i = s ? `${s.trim()} - ${a}` : null;
|
|
53
53
|
return l(
|
|
54
54
|
`${t}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,
|
|
55
55
|
{
|
|
@@ -61,18 +61,18 @@ async function b({
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
const $ =
|
|
65
|
-
orderFormId:
|
|
66
|
-
sellerCode:
|
|
67
|
-
marketingData:
|
|
64
|
+
const $ = e.object({
|
|
65
|
+
orderFormId: e.string().nullable(),
|
|
66
|
+
sellerCode: e.string().nullable(),
|
|
67
|
+
marketingData: e.object()
|
|
68
68
|
});
|
|
69
|
-
async function F({ apiUrl: t, body:
|
|
70
|
-
if (!
|
|
69
|
+
async function F({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
70
|
+
if (!r) {
|
|
71
71
|
console.error("[ERROR FETCHING] Body is required");
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
await $.validate(
|
|
75
|
-
const { orderFormId: n, sellerCode: s, marketingData: a } =
|
|
74
|
+
await $.validate(r);
|
|
75
|
+
const { orderFormId: n, sellerCode: s, marketingData: a } = r, i = s ? {
|
|
76
76
|
utmCampaign: s ? s.toUpperCase() : "",
|
|
77
77
|
utmiCampaign: s ? "codigodavendedora" : "semcodigo"
|
|
78
78
|
} : {};
|
|
@@ -88,41 +88,42 @@ async function F({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
orderFormId:
|
|
93
|
-
sellerCode:
|
|
94
|
-
sellerName:
|
|
91
|
+
const q = e.object({
|
|
92
|
+
orderFormId: e.string().nullable(),
|
|
93
|
+
sellerCode: e.string().nullable(),
|
|
94
|
+
sellerName: e.string().nullable()
|
|
95
95
|
});
|
|
96
|
-
async function
|
|
97
|
-
if (!
|
|
96
|
+
async function y({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
97
|
+
if (!r) {
|
|
98
98
|
console.error("[ERROR FETCHING] Body is required");
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
await q.validate(r);
|
|
102
|
+
const n = await b({ apiUrl: t, body: r, fetchOptions: o });
|
|
102
103
|
return F({
|
|
103
104
|
apiUrl: t,
|
|
104
105
|
body: {
|
|
105
|
-
...
|
|
106
|
+
...r,
|
|
106
107
|
marketingData: n == null ? void 0 : n.marketingData
|
|
107
108
|
},
|
|
108
109
|
fetchOptions: o
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
|
-
const T =
|
|
112
|
-
orderFormId:
|
|
113
|
-
coupon:
|
|
112
|
+
const T = e.object({
|
|
113
|
+
orderFormId: e.string().nullable(),
|
|
114
|
+
coupon: e.string().nullable()
|
|
114
115
|
});
|
|
115
116
|
async function v({
|
|
116
117
|
apiUrl: t,
|
|
117
|
-
body:
|
|
118
|
+
body: r,
|
|
118
119
|
fetchOptions: o
|
|
119
120
|
}) {
|
|
120
|
-
if (!
|
|
121
|
+
if (!r) {
|
|
121
122
|
console.error("[ERROR FETCHING] Body is required");
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
|
-
await T.validate(
|
|
125
|
-
const { coupon: n = "", orderFormId: s } =
|
|
125
|
+
await T.validate(r);
|
|
126
|
+
const { coupon: n = "", orderFormId: s } = r;
|
|
126
127
|
return l(
|
|
127
128
|
`${t}/api/checkout/pub/orderForm/${s}/coupons`,
|
|
128
129
|
{
|
|
@@ -132,22 +133,22 @@ async function v({
|
|
|
132
133
|
}
|
|
133
134
|
);
|
|
134
135
|
}
|
|
135
|
-
const E =
|
|
136
|
-
appId:
|
|
137
|
-
orderFormId:
|
|
138
|
-
key:
|
|
136
|
+
const E = e.object({
|
|
137
|
+
appId: e.string().required("App ID is required"),
|
|
138
|
+
orderFormId: e.string().nullable(),
|
|
139
|
+
key: e.array().of(e.string())
|
|
139
140
|
});
|
|
140
141
|
async function S({
|
|
141
142
|
apiUrl: t,
|
|
142
|
-
body:
|
|
143
|
+
body: r,
|
|
143
144
|
fetchOptions: o
|
|
144
145
|
}) {
|
|
145
|
-
if (!
|
|
146
|
+
if (!r) {
|
|
146
147
|
console.error("[ERROR FETCHING] Body is required");
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
|
-
await E.validate(
|
|
150
|
-
const { appId: n = "faststore", orderFormId: s, key: a } =
|
|
150
|
+
await E.validate(r);
|
|
151
|
+
const { appId: n = "faststore", orderFormId: s, key: a } = r;
|
|
151
152
|
return l(
|
|
152
153
|
`${t}/api/checkout/pub/orderForm/${s}/customData/${n}/${a}`,
|
|
153
154
|
{
|
|
@@ -156,20 +157,56 @@ async function S({
|
|
|
156
157
|
}
|
|
157
158
|
);
|
|
158
159
|
}
|
|
159
|
-
const j =
|
|
160
|
-
|
|
160
|
+
const j = e.object().shape({
|
|
161
|
+
name: e.string().required("Attachment name is required"),
|
|
162
|
+
content: e.object().nullable()
|
|
161
163
|
});
|
|
162
|
-
|
|
164
|
+
var f;
|
|
165
|
+
const A = e.object().shape({
|
|
166
|
+
attachments: (f = e.array().of(j)) == null ? void 0 : f.nullable(),
|
|
167
|
+
id: e.string().required("ID of SKU is required"),
|
|
168
|
+
index: e.number().integer().nullable(),
|
|
169
|
+
quantity: e.number().integer().nullable(),
|
|
170
|
+
seller: e.string().required("Seller is required"),
|
|
171
|
+
price: e.number().integer()
|
|
172
|
+
}), w = e.object({
|
|
173
|
+
orderFormId: e.string().required("OrderFormId is required"),
|
|
174
|
+
orderItems: e.array().of(A)
|
|
175
|
+
});
|
|
176
|
+
async function k({
|
|
177
|
+
apiUrl: t,
|
|
178
|
+
body: r,
|
|
179
|
+
fetchOptions: o
|
|
180
|
+
}) {
|
|
181
|
+
if (!r) {
|
|
182
|
+
console.error("[ERROR FETCHING] Body is required");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
await w.validate(r);
|
|
186
|
+
const { orderFormId: n, orderItems: s } = r;
|
|
187
|
+
return l(
|
|
188
|
+
`${t}/api/checkout/pub/orderForm/${n}/items`,
|
|
189
|
+
{
|
|
190
|
+
method: "POST",
|
|
191
|
+
body: { orderItems: s },
|
|
192
|
+
...o
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
const N = e.object({
|
|
197
|
+
orderFormId: e.string().nullable()
|
|
198
|
+
});
|
|
199
|
+
async function G({
|
|
163
200
|
apiUrl: t,
|
|
164
|
-
body:
|
|
201
|
+
body: r,
|
|
165
202
|
fetchOptions: o
|
|
166
203
|
}) {
|
|
167
|
-
if (!
|
|
204
|
+
if (!r) {
|
|
168
205
|
console.error("[ERROR FETCHING] Body is required");
|
|
169
206
|
return;
|
|
170
207
|
}
|
|
171
|
-
await
|
|
172
|
-
const { orderFormId: n } =
|
|
208
|
+
await N.validate(r);
|
|
209
|
+
const { orderFormId: n } = r;
|
|
173
210
|
return l(
|
|
174
211
|
`${t}/api/checkout/pub/orderForm/${n}/items/removeAll`,
|
|
175
212
|
{
|
|
@@ -178,33 +215,33 @@ async function A({
|
|
|
178
215
|
}
|
|
179
216
|
);
|
|
180
217
|
}
|
|
181
|
-
const
|
|
182
|
-
name:
|
|
183
|
-
content:
|
|
218
|
+
const P = e.object().shape({
|
|
219
|
+
name: e.string().required("Attachment name is required"),
|
|
220
|
+
content: e.object().nullable()
|
|
184
221
|
});
|
|
185
|
-
var
|
|
186
|
-
const
|
|
187
|
-
attachments: (
|
|
188
|
-
id:
|
|
189
|
-
index:
|
|
190
|
-
quantity:
|
|
191
|
-
seller:
|
|
192
|
-
price:
|
|
193
|
-
}),
|
|
194
|
-
orderFormId:
|
|
195
|
-
orderItems:
|
|
222
|
+
var I;
|
|
223
|
+
const D = e.object().shape({
|
|
224
|
+
attachments: (I = e.array().of(P)) == null ? void 0 : I.nullable(),
|
|
225
|
+
id: e.string().required("ID of SKU is required"),
|
|
226
|
+
index: e.number().integer().nullable(),
|
|
227
|
+
quantity: e.number().integer().nullable(),
|
|
228
|
+
seller: e.string().required("Seller is required"),
|
|
229
|
+
price: e.number().integer()
|
|
230
|
+
}), H = e.object({
|
|
231
|
+
orderFormId: e.string().nullable(),
|
|
232
|
+
orderItems: e.array().of(D)
|
|
196
233
|
});
|
|
197
|
-
async function
|
|
234
|
+
async function _({
|
|
198
235
|
apiUrl: t,
|
|
199
|
-
body:
|
|
236
|
+
body: r,
|
|
200
237
|
fetchOptions: o
|
|
201
238
|
}) {
|
|
202
|
-
if (!
|
|
239
|
+
if (!r) {
|
|
203
240
|
console.error("[ERROR FETCHING] Body is required");
|
|
204
241
|
return;
|
|
205
242
|
}
|
|
206
|
-
await
|
|
207
|
-
const { orderFormId: n, orderItems: s } =
|
|
243
|
+
await H.validate(r);
|
|
244
|
+
const { orderFormId: n, orderItems: s } = r;
|
|
208
245
|
return l(
|
|
209
246
|
`${t}/api/checkout/pub/orderForm/${n}/items/update`,
|
|
210
247
|
{
|
|
@@ -214,20 +251,20 @@ async function N({
|
|
|
214
251
|
}
|
|
215
252
|
);
|
|
216
253
|
}
|
|
217
|
-
const
|
|
218
|
-
orderFormId:
|
|
254
|
+
const B = e.object({
|
|
255
|
+
orderFormId: e.string().nullable()
|
|
219
256
|
});
|
|
220
|
-
async function
|
|
257
|
+
async function M({
|
|
221
258
|
apiUrl: t,
|
|
222
|
-
body:
|
|
259
|
+
body: r,
|
|
223
260
|
fetchOptions: o
|
|
224
261
|
}) {
|
|
225
|
-
if (!
|
|
262
|
+
if (!r) {
|
|
226
263
|
console.error("[ERROR FETCHING] Body is required");
|
|
227
264
|
return;
|
|
228
265
|
}
|
|
229
|
-
await
|
|
230
|
-
const { orderFormId: n } =
|
|
266
|
+
await B.validate(r);
|
|
267
|
+
const { orderFormId: n } = r;
|
|
231
268
|
return l(
|
|
232
269
|
`${t}/api/checkout/pub/orderForm/${n}/messages/clear`,
|
|
233
270
|
{
|
|
@@ -236,66 +273,66 @@ async function P({
|
|
|
236
273
|
}
|
|
237
274
|
);
|
|
238
275
|
}
|
|
239
|
-
const
|
|
240
|
-
id:
|
|
276
|
+
const U = e.object({
|
|
277
|
+
id: e.string().nullable(),
|
|
241
278
|
// id offering
|
|
242
|
-
itemIndex:
|
|
243
|
-
orderFormId:
|
|
244
|
-
remove:
|
|
279
|
+
itemIndex: e.number().nullable(),
|
|
280
|
+
orderFormId: e.string().nullable(),
|
|
281
|
+
remove: e.boolean().nullable()
|
|
245
282
|
});
|
|
246
|
-
async function
|
|
247
|
-
if (!
|
|
283
|
+
async function x({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
284
|
+
if (!r) {
|
|
248
285
|
console.error("[ERROR FETCHING] Body is required");
|
|
249
286
|
return;
|
|
250
287
|
}
|
|
251
|
-
await
|
|
252
|
-
const { itemIndex: n, orderFormId: s, id: a, remove: i } =
|
|
288
|
+
await U.validate(r);
|
|
289
|
+
const { itemIndex: n, orderFormId: s, id: a, remove: i } = r, d = i ? `/${a}/remove` : "", m = `${t}/api/checkout/pub/orderForm/${s}/items/${n}/offerings${d}`;
|
|
253
290
|
return l(m, {
|
|
254
291
|
method: "POST",
|
|
255
292
|
body: { id: a },
|
|
256
293
|
...o
|
|
257
294
|
});
|
|
258
295
|
}
|
|
259
|
-
const
|
|
260
|
-
orderFormId:
|
|
296
|
+
const z = e.object({
|
|
297
|
+
orderFormId: e.string().nullable()
|
|
261
298
|
});
|
|
262
|
-
async function
|
|
299
|
+
async function L({
|
|
263
300
|
apiUrl: t,
|
|
264
|
-
body:
|
|
301
|
+
body: r,
|
|
265
302
|
fetchOptions: o,
|
|
266
303
|
extraData: n
|
|
267
304
|
}) {
|
|
268
305
|
var i;
|
|
269
|
-
if (!
|
|
306
|
+
if (!r) {
|
|
270
307
|
console.error("[ERROR FETCHING] Body is required");
|
|
271
308
|
return;
|
|
272
309
|
}
|
|
273
|
-
await
|
|
310
|
+
await z.validate(r);
|
|
274
311
|
const s = new URLSearchParams({
|
|
275
312
|
refreshOutdatedData: "true"
|
|
276
|
-
}), a =
|
|
313
|
+
}), a = r.orderFormId && ((i = n.orderFormPurchaseId) == null ? void 0 : i.value) !== r.orderFormId ? `${t}/api/checkout/pub/orderForm/${r.orderFormId}?${String(s)}` : `${t}/api/checkout/pub/orderForm`;
|
|
277
314
|
return l(a, { method: "GET", ...o });
|
|
278
315
|
}
|
|
279
|
-
const
|
|
280
|
-
orderFormId:
|
|
281
|
-
email:
|
|
282
|
-
firstName:
|
|
283
|
-
lastName:
|
|
284
|
-
documentType:
|
|
285
|
-
document:
|
|
286
|
-
phone:
|
|
316
|
+
const K = e.object({
|
|
317
|
+
orderFormId: e.string().nullable(),
|
|
318
|
+
email: e.string().email().required(),
|
|
319
|
+
firstName: e.string().required(),
|
|
320
|
+
lastName: e.string().required(),
|
|
321
|
+
documentType: e.string().required(),
|
|
322
|
+
document: e.string().required(),
|
|
323
|
+
phone: e.string().matches(/^\+\d{1,3}\d{10,11}$/)
|
|
287
324
|
});
|
|
288
|
-
async function
|
|
325
|
+
async function V({
|
|
289
326
|
apiUrl: t,
|
|
290
|
-
body:
|
|
327
|
+
body: r,
|
|
291
328
|
fetchOptions: o
|
|
292
329
|
}) {
|
|
293
|
-
if (!
|
|
330
|
+
if (!r) {
|
|
294
331
|
console.error("[ERROR FETCHING] Body is required");
|
|
295
332
|
return;
|
|
296
333
|
}
|
|
297
|
-
await
|
|
298
|
-
const { orderFormId: n, ...s } =
|
|
334
|
+
await K.validate(r);
|
|
335
|
+
const { orderFormId: n, ...s } = r;
|
|
299
336
|
return l(
|
|
300
337
|
`${t}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,
|
|
301
338
|
{
|
|
@@ -305,20 +342,20 @@ async function U({
|
|
|
305
342
|
}
|
|
306
343
|
);
|
|
307
344
|
}
|
|
308
|
-
const
|
|
309
|
-
sellerCode:
|
|
345
|
+
const J = e.object({
|
|
346
|
+
sellerCode: e.string().nullable()
|
|
310
347
|
});
|
|
311
|
-
async function
|
|
348
|
+
async function Y({
|
|
312
349
|
apiUrl: t,
|
|
313
|
-
body:
|
|
350
|
+
body: r,
|
|
314
351
|
fetchOptions: o
|
|
315
352
|
}) {
|
|
316
|
-
if (!
|
|
353
|
+
if (!r) {
|
|
317
354
|
console.error("[ERROR FETCHING] Body is required");
|
|
318
355
|
return;
|
|
319
356
|
}
|
|
320
|
-
await
|
|
321
|
-
const { sellerCode: n = "" } =
|
|
357
|
+
await J.validate(r);
|
|
358
|
+
const { sellerCode: n = "" } = r;
|
|
322
359
|
return l(
|
|
323
360
|
`${t}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,
|
|
324
361
|
{
|
|
@@ -330,22 +367,22 @@ async function L({
|
|
|
330
367
|
}
|
|
331
368
|
);
|
|
332
369
|
}
|
|
333
|
-
const
|
|
334
|
-
country:
|
|
335
|
-
orderFormId:
|
|
336
|
-
postalCode:
|
|
370
|
+
const Q = e.object().shape({
|
|
371
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
372
|
+
orderFormId: e.string().nullable(),
|
|
373
|
+
postalCode: e.string().nullable()
|
|
337
374
|
});
|
|
338
|
-
async function
|
|
375
|
+
async function X({
|
|
339
376
|
apiUrl: t,
|
|
340
|
-
body:
|
|
377
|
+
body: r,
|
|
341
378
|
fetchOptions: o
|
|
342
379
|
}) {
|
|
343
|
-
if (!
|
|
380
|
+
if (!r) {
|
|
344
381
|
console.error("[ERROR FETCHING] Body is required");
|
|
345
382
|
return;
|
|
346
383
|
}
|
|
347
|
-
await
|
|
348
|
-
const { country: n, orderFormId: s, postalCode: a } =
|
|
384
|
+
await Q.validate(r);
|
|
385
|
+
const { country: n, orderFormId: s, postalCode: a } = r, i = a ? {
|
|
349
386
|
address: {
|
|
350
387
|
addressType: "residential",
|
|
351
388
|
postalCode: a,
|
|
@@ -364,41 +401,41 @@ async function V({
|
|
|
364
401
|
}
|
|
365
402
|
);
|
|
366
403
|
}
|
|
367
|
-
const
|
|
368
|
-
orderFormId:
|
|
369
|
-
options:
|
|
370
|
-
|
|
371
|
-
itemIndex:
|
|
372
|
-
selectedDeliveryChannel:
|
|
373
|
-
selectedSla:
|
|
404
|
+
const W = e.object().shape({
|
|
405
|
+
orderFormId: e.string().nullable(),
|
|
406
|
+
options: e.array().of(
|
|
407
|
+
e.object().shape({
|
|
408
|
+
itemIndex: e.number(),
|
|
409
|
+
selectedDeliveryChannel: e.string(),
|
|
410
|
+
selectedSla: e.string()
|
|
374
411
|
})
|
|
375
412
|
),
|
|
376
|
-
selectedAddresses:
|
|
377
|
-
|
|
378
|
-
addressId:
|
|
379
|
-
addressType:
|
|
380
|
-
city:
|
|
381
|
-
complement:
|
|
382
|
-
country:
|
|
383
|
-
geoCoordinates:
|
|
384
|
-
isDisposable:
|
|
385
|
-
neighborhood:
|
|
386
|
-
number:
|
|
387
|
-
postalCode:
|
|
388
|
-
receiverName:
|
|
389
|
-
reference:
|
|
390
|
-
state:
|
|
391
|
-
street:
|
|
413
|
+
selectedAddresses: e.array().of(
|
|
414
|
+
e.object().shape({
|
|
415
|
+
addressId: e.string().required(),
|
|
416
|
+
addressType: e.string().required(),
|
|
417
|
+
city: e.string().nullable(),
|
|
418
|
+
complement: e.string().nullable(),
|
|
419
|
+
country: e.string().required().length(3),
|
|
420
|
+
geoCoordinates: e.array().of(e.number()).required().min(0),
|
|
421
|
+
isDisposable: e.boolean().required(),
|
|
422
|
+
neighborhood: e.string().nullable(),
|
|
423
|
+
number: e.string().nullable(),
|
|
424
|
+
postalCode: e.string().required(),
|
|
425
|
+
receiverName: e.string().nullable(),
|
|
426
|
+
reference: e.string().nullable(),
|
|
427
|
+
state: e.string().nullable(),
|
|
428
|
+
street: e.string().nullable()
|
|
392
429
|
})
|
|
393
430
|
)
|
|
394
431
|
});
|
|
395
|
-
async function
|
|
396
|
-
if (!
|
|
432
|
+
async function Z({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
433
|
+
if (!r) {
|
|
397
434
|
console.error("[ERROR FETCHING] Body is required");
|
|
398
435
|
return;
|
|
399
436
|
}
|
|
400
|
-
await
|
|
401
|
-
const { orderFormId: n, options: s, selectedAddresses: a } =
|
|
437
|
+
await W.validate(r);
|
|
438
|
+
const { orderFormId: n, options: s, selectedAddresses: a } = r;
|
|
402
439
|
return l(
|
|
403
440
|
`${t}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,
|
|
404
441
|
{
|
|
@@ -412,21 +449,21 @@ async function K({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
412
449
|
}
|
|
413
450
|
);
|
|
414
451
|
}
|
|
415
|
-
const
|
|
416
|
-
country:
|
|
417
|
-
postalCode:
|
|
418
|
-
geoCoordinates:
|
|
419
|
-
longitude:
|
|
420
|
-
latitude:
|
|
452
|
+
const ee = e.object({
|
|
453
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
454
|
+
postalCode: e.string().nullable(),
|
|
455
|
+
geoCoordinates: e.object().shape({
|
|
456
|
+
longitude: e.number().required(),
|
|
457
|
+
latitude: e.number().required()
|
|
421
458
|
})
|
|
422
459
|
});
|
|
423
|
-
async function
|
|
424
|
-
if (!
|
|
460
|
+
async function re({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
461
|
+
if (!r) {
|
|
425
462
|
console.error("[ERROR FETCHING] Body is required");
|
|
426
463
|
return;
|
|
427
464
|
}
|
|
428
|
-
await
|
|
429
|
-
const { country: n = "", geoCoordinates: s, postalCode: a = "" } =
|
|
465
|
+
await ee.validate(r);
|
|
466
|
+
const { country: n = "", geoCoordinates: s, postalCode: a = "" } = r, i = new URLSearchParams({ country: String(n) });
|
|
430
467
|
return a ? i.append("postalCode", a) : i.append(
|
|
431
468
|
"geoCoordinates",
|
|
432
469
|
`${s == null ? void 0 : s.longitude};${s == null ? void 0 : s.latitude}`
|
|
@@ -438,62 +475,60 @@ async function Q({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
438
475
|
}
|
|
439
476
|
);
|
|
440
477
|
}
|
|
441
|
-
const
|
|
442
|
-
id:
|
|
443
|
-
quantity:
|
|
444
|
-
seller:
|
|
445
|
-
}),
|
|
446
|
-
items:
|
|
447
|
-
country:
|
|
448
|
-
postalCode:
|
|
449
|
-
geoCoordinates:
|
|
478
|
+
const te = e.object({
|
|
479
|
+
id: e.string().required("ID of SKU is required"),
|
|
480
|
+
quantity: e.number().integer().required("Quantity of item is required"),
|
|
481
|
+
seller: e.string()
|
|
482
|
+
}), oe = e.object({
|
|
483
|
+
items: e.array().of(te),
|
|
484
|
+
country: e.string().length(3, "Country code must be 3 characters long").required("Country is required"),
|
|
485
|
+
postalCode: e.string().nullable(),
|
|
486
|
+
geoCoordinates: e.array().nullable().of(e.number()).length(2)
|
|
450
487
|
});
|
|
451
|
-
async function
|
|
452
|
-
if (!
|
|
488
|
+
async function ne({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
489
|
+
if (!r) {
|
|
453
490
|
console.error("[ERROR FETCHING] Body is required");
|
|
454
491
|
return;
|
|
455
492
|
}
|
|
456
|
-
return await
|
|
493
|
+
return await oe.validate(r), l(
|
|
457
494
|
`${t}/api/checkout/pub/orderForms/simulation`,
|
|
458
495
|
{
|
|
459
496
|
method: "POST",
|
|
460
|
-
body:
|
|
497
|
+
body: r,
|
|
461
498
|
...o
|
|
462
499
|
}
|
|
463
500
|
);
|
|
464
501
|
}
|
|
465
|
-
const
|
|
502
|
+
const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
466
503
|
__proto__: null,
|
|
467
|
-
getMasterDataSellerCode:
|
|
468
|
-
getOrderForm:
|
|
504
|
+
getMasterDataSellerCode: Y,
|
|
505
|
+
getOrderForm: L,
|
|
469
506
|
postOrderFormAddCoupon: v,
|
|
470
|
-
postOrderFormAttachClientProfileData:
|
|
471
|
-
postOrderFormAttachOrderFormData:
|
|
472
|
-
postOrderFormAttachShippingData:
|
|
507
|
+
postOrderFormAttachClientProfileData: V,
|
|
508
|
+
postOrderFormAttachOrderFormData: y,
|
|
509
|
+
postOrderFormAttachShippingData: X,
|
|
473
510
|
postOrderFormAttachmentsMarketingData: F,
|
|
474
511
|
postOrderFormAttachmentsOpenTextField: b,
|
|
475
|
-
postOrderFormClearMessages:
|
|
476
|
-
postOrderFormFreightSimulation:
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
512
|
+
postOrderFormClearMessages: M,
|
|
513
|
+
postOrderFormFreightSimulation: ne,
|
|
514
|
+
postOrderFormItems: k,
|
|
515
|
+
postOrderFormRegion: re,
|
|
516
|
+
postOrderFormRemoveAllItems: G,
|
|
517
|
+
postOrderFormUpdateItems: _,
|
|
518
|
+
postOrderFormUpdateShippingData: Z,
|
|
481
519
|
postOrderformAddress: R,
|
|
482
520
|
putOrderFormCustomData: S,
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
updateOrderFormOffering: _
|
|
487
|
-
}, Symbol.toStringTag, { value: "Module" })), re = r.object({
|
|
488
|
-
skuId: r.string()
|
|
521
|
+
updateOrderFormOffering: x
|
|
522
|
+
}, Symbol.toStringTag, { value: "Module" })), se = e.object({
|
|
523
|
+
skuId: e.string()
|
|
489
524
|
});
|
|
490
|
-
async function
|
|
491
|
-
if (!
|
|
525
|
+
async function ie({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
526
|
+
if (!r) {
|
|
492
527
|
console.error("[ERROR FETCHING] Body is required");
|
|
493
528
|
return;
|
|
494
529
|
}
|
|
495
|
-
await
|
|
496
|
-
const { skuId: n } =
|
|
530
|
+
await se.validate(r);
|
|
531
|
+
const { skuId: n } = r;
|
|
497
532
|
return l(
|
|
498
533
|
`${t}/api/catalog/pvt/stockkeepingunitkit?parentSkuId=${n}`,
|
|
499
534
|
{
|
|
@@ -501,16 +536,16 @@ async function te({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
501
536
|
}
|
|
502
537
|
);
|
|
503
538
|
}
|
|
504
|
-
const
|
|
505
|
-
ids:
|
|
539
|
+
const le = e.object({
|
|
540
|
+
ids: e.array().of(e.string().required("ID are required")).required("IDs are required")
|
|
506
541
|
});
|
|
507
|
-
async function
|
|
508
|
-
if (!
|
|
542
|
+
async function de({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
543
|
+
if (!r) {
|
|
509
544
|
console.error("[ERROR FETCHING] Body is required");
|
|
510
545
|
return;
|
|
511
546
|
}
|
|
512
|
-
await
|
|
513
|
-
const { ids: n } =
|
|
547
|
+
await le.validate(r);
|
|
548
|
+
const { ids: n } = r;
|
|
514
549
|
return l(
|
|
515
550
|
`${t}/api/catalog_system/pub/products/search?fq=${n.map((s) => `productId:${s}`).join("&fq=")}`,
|
|
516
551
|
{
|
|
@@ -518,16 +553,16 @@ async function ne({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
518
553
|
}
|
|
519
554
|
);
|
|
520
555
|
}
|
|
521
|
-
const
|
|
522
|
-
productId:
|
|
556
|
+
const ce = e.object({
|
|
557
|
+
productId: e.number().required("Product ID is required")
|
|
523
558
|
});
|
|
524
|
-
async function
|
|
525
|
-
if (!
|
|
559
|
+
async function ue({ apiUrl: t, body: r, fetchOptions: o }) {
|
|
560
|
+
if (!r) {
|
|
526
561
|
console.error("[ERROR FETCHING] Body is required");
|
|
527
562
|
return;
|
|
528
563
|
}
|
|
529
|
-
await
|
|
530
|
-
const { productId: n } =
|
|
564
|
+
await ce.validate(r);
|
|
565
|
+
const { productId: n } = r;
|
|
531
566
|
return l(
|
|
532
567
|
`${t}/api/catalog_system/pub/products/crossselling/similars/${n.toString()}`,
|
|
533
568
|
{
|
|
@@ -535,61 +570,61 @@ async function se({ apiUrl: t, body: e, fetchOptions: o }) {
|
|
|
535
570
|
}
|
|
536
571
|
);
|
|
537
572
|
}
|
|
538
|
-
const
|
|
573
|
+
const me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
539
574
|
__proto__: null,
|
|
540
|
-
getCatalogKitProducts:
|
|
541
|
-
getCatalogProducts:
|
|
542
|
-
getCatalogSimilars:
|
|
543
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
575
|
+
getCatalogKitProducts: ie,
|
|
576
|
+
getCatalogProducts: de,
|
|
577
|
+
getCatalogSimilars: ue
|
|
578
|
+
}, Symbol.toStringTag, { value: "Module" })), pe = (t = "") => t.charAt(0).toUpperCase() + t.slice(1), h = (t, r = " ") => !t || typeof t == "string" && t.length === 0 ? t : (Array.isArray(t) ? t : t.split("-")).map(pe).join(r), ge = ({ canonical: t, seo: r, slug: o }) => {
|
|
544
579
|
const n = Array.isArray(o) ? o.join(", ") : o;
|
|
545
580
|
return {
|
|
546
581
|
id: 0,
|
|
547
|
-
Title: `${Array.isArray(o) ? o.map((a) => h(a)).join(",") : h(o)} - ${
|
|
548
|
-
MetaTagDescription:
|
|
582
|
+
Title: `${Array.isArray(o) ? o.map((a) => h(a)).join(",") : h(o)} - ${r.title}`,
|
|
583
|
+
MetaTagDescription: r.description,
|
|
549
584
|
name: n,
|
|
550
585
|
hasChildren: !1,
|
|
551
586
|
url: t,
|
|
552
587
|
children: []
|
|
553
588
|
};
|
|
554
|
-
},
|
|
555
|
-
category: String(
|
|
556
|
-
title: (
|
|
557
|
-
description: (
|
|
589
|
+
}, he = ({ canonical: t, category: r, previousImages: o, seo: n }) => ({
|
|
590
|
+
category: String(r == null ? void 0 : r.id),
|
|
591
|
+
title: (r == null ? void 0 : r.Title) ?? n.title,
|
|
592
|
+
description: (r == null ? void 0 : r.MetaTagDescription) ?? n.description,
|
|
558
593
|
alternates: { canonical: t },
|
|
559
594
|
openGraph: {
|
|
560
595
|
type: "website",
|
|
561
|
-
title: (
|
|
562
|
-
description: (
|
|
596
|
+
title: (r == null ? void 0 : r.Title) ?? n.title,
|
|
597
|
+
description: (r == null ? void 0 : r.MetaTagDescription) ?? n.description,
|
|
563
598
|
images: Array.isArray(o) ? [...o] : []
|
|
564
599
|
}
|
|
565
|
-
}),
|
|
600
|
+
}), fe = ({ items: t, parent: r, apiUrl: o, find: n }) => {
|
|
566
601
|
const s = t.find(
|
|
567
|
-
(i) => i.url.replace(o, "") === decodeURIComponent(
|
|
602
|
+
(i) => i.url.replace(o, "") === decodeURIComponent(r.toLowerCase())
|
|
568
603
|
);
|
|
569
604
|
return (s == null ? void 0 : s.children.find(
|
|
570
605
|
(i) => i.name.toLowerCase() === decodeURIComponent(String(n))
|
|
571
606
|
)) ?? s;
|
|
572
|
-
},
|
|
607
|
+
}, Ie = (t) => {
|
|
573
608
|
t instanceof Error ? (console.error(`[ERROR CATEGORY INFO]: ${t.message}`), console.error(t.stack)) : console.error("[ERROR CATEGORY INFO]: Unknown error", t);
|
|
574
|
-
},
|
|
609
|
+
}, be = /* @__PURE__ */ new Set([
|
|
575
610
|
"brand",
|
|
576
611
|
"category",
|
|
577
612
|
"department",
|
|
578
613
|
"subcategory",
|
|
579
614
|
"collection",
|
|
580
615
|
"cluster"
|
|
581
|
-
]),
|
|
616
|
+
]), Fe = (t) => typeof (t == null ? void 0 : t.pageType) == "string" && be.has(t == null ? void 0 : t.pageType.toLowerCase()), Ce = (t) => ({
|
|
582
617
|
collection: t.Coleção,
|
|
583
618
|
categoryId: t.categoryId,
|
|
584
619
|
current_collection: t["Coleção Atual"],
|
|
585
620
|
items: t.items
|
|
586
|
-
}),
|
|
621
|
+
}), Re = (t, r) => t.reduce((o, n) => {
|
|
587
622
|
if (n.items.filter(
|
|
588
623
|
(i) => i.sellers.find((d) => d.commertialOffer.IsAvailable)
|
|
589
624
|
).length === 0 || (o == null ? void 0 : o.find((i) => (i == null ? void 0 : i.productId) === (n == null ? void 0 : n.productId))) !== void 0)
|
|
590
625
|
return o;
|
|
591
626
|
const a = n.items[0].images.find(
|
|
592
|
-
(i) =>
|
|
627
|
+
(i) => r.includes(i.imageLabel)
|
|
593
628
|
);
|
|
594
629
|
return o.push({
|
|
595
630
|
slug: `/${n.linkText}/p`,
|
|
@@ -597,19 +632,19 @@ const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
597
632
|
textureImage: (a == null ? void 0 : a.imageUrl) ?? "",
|
|
598
633
|
textureAlt: (a == null ? void 0 : a.imageText) ?? ""
|
|
599
634
|
}), o;
|
|
600
|
-
}, []),
|
|
635
|
+
}, []), Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
601
636
|
__proto__: null,
|
|
602
|
-
createEmptySeoCategory:
|
|
603
|
-
createSeoCategory:
|
|
604
|
-
findCategory:
|
|
605
|
-
formattedSimilars:
|
|
606
|
-
isCollectionPageType:
|
|
607
|
-
notFindCategoryError:
|
|
608
|
-
responseAdapter:
|
|
637
|
+
createEmptySeoCategory: ge,
|
|
638
|
+
createSeoCategory: he,
|
|
639
|
+
findCategory: fe,
|
|
640
|
+
formattedSimilars: Re,
|
|
641
|
+
isCollectionPageType: Fe,
|
|
642
|
+
notFindCategoryError: Ie,
|
|
643
|
+
responseAdapter: Ce
|
|
609
644
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
610
|
-
async function
|
|
645
|
+
async function $e({
|
|
611
646
|
contentType: t,
|
|
612
|
-
documents:
|
|
647
|
+
documents: r,
|
|
613
648
|
NextCookies: o,
|
|
614
649
|
CMS_PROJECT_NAME: n,
|
|
615
650
|
storeId: s
|
|
@@ -622,22 +657,22 @@ async function be({
|
|
|
622
657
|
const d = a.documentId && a.documentId.length ? `/${a.documentId}` : "", m = a != null && a.versionId && (a != null && a.versionId.length) ? `?versionId=${a == null ? void 0 : a.versionId}` : "", p = await (await fetch(
|
|
623
658
|
`https://${s}.myvtex.com/_v/cms/api/${n}/${t}${d}${m}`,
|
|
624
659
|
{ cache: "no-store" }
|
|
625
|
-
)).json(), c =
|
|
660
|
+
)).json(), c = r.filter(
|
|
626
661
|
(u) => p.id !== u.documentId
|
|
627
662
|
);
|
|
628
663
|
return c.unshift(p), c;
|
|
629
664
|
}
|
|
630
|
-
return
|
|
665
|
+
return r;
|
|
631
666
|
}
|
|
632
|
-
async function
|
|
667
|
+
async function qe({
|
|
633
668
|
contentType: t,
|
|
634
|
-
NextCookies:
|
|
669
|
+
NextCookies: r,
|
|
635
670
|
CMS_PROJECT_NAME: o,
|
|
636
671
|
storeId: n
|
|
637
672
|
}) {
|
|
638
673
|
var g, p;
|
|
639
674
|
const s = JSON.parse(
|
|
640
|
-
((g =
|
|
675
|
+
((g = r().get("cms_preview_data")) == null ? void 0 : g.value) ?? "{}"
|
|
641
676
|
), a = [];
|
|
642
677
|
let i = 1, d = 0, m = !0;
|
|
643
678
|
try {
|
|
@@ -648,10 +683,10 @@ async function Fe({
|
|
|
648
683
|
i === 1 && (d = u.totalItems), (p = u == null ? void 0 : u.data) != null && p.length && a.push(...u.data), m = u.hasNextPage, i++;
|
|
649
684
|
} while (m && a.length < d);
|
|
650
685
|
if (s.previewMode && a.length) {
|
|
651
|
-
const c = await
|
|
686
|
+
const c = await $e({
|
|
652
687
|
contentType: t,
|
|
653
688
|
documents: a,
|
|
654
|
-
NextCookies:
|
|
689
|
+
NextCookies: r,
|
|
655
690
|
CMS_PROJECT_NAME: o,
|
|
656
691
|
storeId: n
|
|
657
692
|
});
|
|
@@ -668,17 +703,17 @@ async function Fe({
|
|
|
668
703
|
return { status: "error", data: [], error: c };
|
|
669
704
|
}
|
|
670
705
|
}
|
|
671
|
-
const
|
|
706
|
+
const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
672
707
|
__proto__: null,
|
|
673
|
-
getContentType:
|
|
674
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
675
|
-
checkout:
|
|
676
|
-
catalog:
|
|
677
|
-
cms:
|
|
678
|
-
},
|
|
679
|
-
catalog:
|
|
708
|
+
getContentType: qe
|
|
709
|
+
}, Symbol.toStringTag, { value: "Module" })), Te = {
|
|
710
|
+
checkout: ae,
|
|
711
|
+
catalog: me,
|
|
712
|
+
cms: ye
|
|
713
|
+
}, ve = {
|
|
714
|
+
catalog: Oe
|
|
680
715
|
};
|
|
681
716
|
export {
|
|
682
|
-
|
|
683
|
-
|
|
717
|
+
Te as serverAPIs,
|
|
718
|
+
ve as serverHelpers
|
|
684
719
|
};
|