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