@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.
Files changed (39) hide show
  1. package/data/api/catalog/index.d.ts +3 -0
  2. package/data/api/catalog/kit/index.d.ts +11 -0
  3. package/data/api/catalog/product/info/index.d.ts +10 -0
  4. package/data/api/catalog/product/similars/index.d.ts +11 -22
  5. package/data/api/checkout/address/index.d.ts +2 -2
  6. package/data/api/checkout/order-form/attachments/index.d.ts +2 -2
  7. package/data/api/checkout/order-form/attachments/marketing-data/index.d.ts +1 -1
  8. package/data/api/checkout/order-form/attachments/open-text-field/index.d.ts +1 -1
  9. package/data/api/checkout/order-form/coupon/index.d.ts +1 -1
  10. package/data/api/checkout/order-form/custom-data/index.d.ts +1 -1
  11. package/data/api/checkout/order-form/index.d.ts +1 -0
  12. package/data/api/checkout/order-form/items/index.d.ts +23 -0
  13. package/data/api/checkout/order-form/items/remove-all/index.d.ts +1 -1
  14. package/data/api/checkout/order-form/items/update/index.d.ts +1 -19
  15. package/data/api/checkout/order-form/messages/remove-all/index.d.ts +1 -1
  16. package/data/api/checkout/order-form/offerings/index.d.ts +1 -1
  17. package/data/api/checkout/order-form/orderform/index.d.ts +1 -1
  18. package/data/api/checkout/order-form/profile/index.d.ts +1 -1
  19. package/data/api/checkout/order-form/seller-code/index.d.ts +1 -1
  20. package/data/api/checkout/order-form/shipping/index.d.ts +1 -1
  21. package/data/api/checkout/order-form/shipping/update/index.d.ts +1 -1
  22. package/data/api/checkout/region/index.d.ts +1 -1
  23. package/data/api/checkout/simulation/index.d.ts +1 -1
  24. package/data/api/fetchVtex.d.ts +2 -1
  25. package/data/helpers/cart/index.d.ts +1 -1
  26. package/data/helpers/catalog/index.d.ts +38 -0
  27. package/index.js +14 -14
  28. package/index.mjs +1954 -1949
  29. package/index2.js +1 -1
  30. package/index2.mjs +463 -262
  31. package/package.json +1 -1
  32. package/server.d.ts +11 -155
  33. package/types/constants.d.ts +0 -8
  34. package/types/data/api/catalog/kit/index.d.ts +0 -0
  35. package/types/data/api/catalog/portal/index.d.ts +26 -0
  36. package/types/data/api/catalog/product/index.d.ts +50 -0
  37. package/types/data/api/index.d.ts +3 -6
  38. package/types/layout/team-components/ProductCard/Selectors/index.d.ts +1 -1
  39. 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 y = [
3
- "allowManualPrice",
4
- "canEditData",
5
- "checkedInPickupPointId",
6
- "clientPreferencesData",
7
- "clientProfileData",
8
- "commercialConditionData",
9
- "giftRegistryData",
10
- "hooksData",
11
- "ignoreProfileData",
12
- "invoiceData",
13
- "isCheckedIn",
14
- "itemsOrdination",
15
- "merchantContextData",
16
- "purchaseAgentsData",
17
- "ratesAndBenefitsData",
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 v({ apiUrl: r, body: t, fetchOptions: a }) {
48
- await b.validate(t);
49
- const { country: n, postalCode: s } = t;
50
- return await c(
51
- `${r}/api/checkout/pub/postal-code/${n}/${s}`,
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: t,
55
- ...a
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 f({
65
- apiUrl: r,
66
- body: t,
67
- fetchOptions: a
42
+ async function b({
43
+ apiUrl: t,
44
+ body: r,
45
+ fetchOptions: o
68
46
  }) {
69
- await O.validate(t);
70
- const { orderFormId: n, sellerCode: s, sellerName: o } = t, i = s ? `${s.trim()} - ${o}` : null;
71
- return c(
72
- `${r}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,
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
- ...a
60
+ ...o
79
61
  }
80
62
  );
81
63
  }
82
- const C = e.object({
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 I({ apiUrl: r, body: t, fetchOptions: a }) {
88
- await C.validate(t);
89
- const { orderFormId: n, sellerCode: s, marketingData: o } = t, i = s ? {
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 c(
94
- `${r}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,
79
+ return l(
80
+ `${t}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,
95
81
  {
96
82
  method: "POST",
97
83
  body: {
98
- ...o,
84
+ ...a,
99
85
  ...i
100
86
  },
101
- ...a
87
+ ...o
102
88
  }
103
89
  );
104
90
  }
105
- const S = e.object({
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 q({ apiUrl: r, body: t, fetchOptions: a }) {
111
- const n = await f({ apiUrl: r, body: t, fetchOptions: a });
112
- return I({
113
- apiUrl: r,
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
- ...t,
116
- marketingData: n.marketingData
106
+ ...r,
107
+ marketingData: n == null ? void 0 : n.marketingData
117
108
  },
118
- fetchOptions: a
109
+ fetchOptions: o
119
110
  });
120
111
  }
121
- const D = e.object({
112
+ const T = e.object({
122
113
  orderFormId: e.string().nullable(),
123
114
  coupon: e.string().nullable()
124
115
  });
125
- async function j({
126
- apiUrl: r,
127
- body: t,
128
- fetchOptions: a
116
+ async function v({
117
+ apiUrl: t,
118
+ body: r,
119
+ fetchOptions: o
129
120
  }) {
130
- await D.validate(t);
131
- const { coupon: n = "", orderFormId: s } = t;
132
- return c(
133
- `${r}/api/checkout/pub/orderForm/${s}/coupons`,
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
- ...a
132
+ ...o
138
133
  }
139
134
  );
140
135
  }
141
- const k = e.object({
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 T({
147
- apiUrl: r,
148
- body: t,
149
- fetchOptions: a
141
+ async function S({
142
+ apiUrl: t,
143
+ body: r,
144
+ fetchOptions: o
150
145
  }) {
151
- await k.validate(t);
152
- const { appId: n = "faststore", orderFormId: s, key: o } = t;
153
- return c(
154
- `${r}/api/checkout/pub/orderForm/${s}/customData/${n}/${o}`,
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
- ...a
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 P = e.object({
196
+ const N = e.object({
162
197
  orderFormId: e.string().nullable()
163
198
  });
164
- async function w({
165
- apiUrl: r,
166
- body: t,
167
- fetchOptions: a
199
+ async function G({
200
+ apiUrl: t,
201
+ body: r,
202
+ fetchOptions: o
168
203
  }) {
169
- await P.validate(t);
170
- const { orderFormId: n } = t;
171
- return c(
172
- `${r}/api/checkout/pub/orderForm/${n}/items/removeAll`,
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
- ...a
214
+ ...o
176
215
  }
177
216
  );
178
217
  }
179
- const A = e.object().shape({
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 g;
184
- const F = e.object().shape({
185
- attachments: (g = e.array().of(A)) == null ? void 0 : g.nullable(),
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
- }), x = e.object({
230
+ }), H = e.object({
192
231
  orderFormId: e.string().nullable(),
193
- orderItems: e.array().of(F)
232
+ orderItems: e.array().of(D)
194
233
  });
195
- async function R({
196
- apiUrl: r,
197
- body: t,
198
- fetchOptions: a
234
+ async function _({
235
+ apiUrl: t,
236
+ body: r,
237
+ fetchOptions: o
199
238
  }) {
200
- await x.validate(t);
201
- const { orderFormId: n, orderItems: s } = t;
202
- return c(
203
- `${r}/api/checkout/pub/orderForm/${n}/items/update`,
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
- ...a
250
+ ...o
208
251
  }
209
252
  );
210
253
  }
211
- const _ = e.object({
254
+ const B = e.object({
212
255
  orderFormId: e.string().nullable()
213
256
  });
214
- async function N({
215
- apiUrl: r,
216
- body: t,
217
- fetchOptions: a
257
+ async function M({
258
+ apiUrl: t,
259
+ body: r,
260
+ fetchOptions: o
218
261
  }) {
219
- await _.validate(t);
220
- const { orderFormId: n } = t;
221
- return c(
222
- `${r}/api/checkout/pub/orderForm/${n}/messages/clear`,
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
- ...a
272
+ ...o
226
273
  }
227
274
  );
228
275
  }
229
- const E = e.object({
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 M({ apiUrl: r, body: t, fetchOptions: a }) {
237
- await E.validate(t);
238
- const { itemIndex: n, orderFormId: s, id: o, remove: i } = t, d = i ? `/${o}/remove` : "", m = `${r}/api/checkout/pub/orderForm/${s}/items/${n}/offerings${d}`;
239
- return c(m, {
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: o },
242
- ...a
292
+ body: { id: a },
293
+ ...o
243
294
  });
244
295
  }
245
- const U = e.object({
296
+ const z = e.object({
246
297
  orderFormId: e.string().nullable()
247
298
  });
248
- async function G({
249
- apiUrl: r,
250
- body: t,
251
- fetchOptions: a,
299
+ async function L({
300
+ apiUrl: t,
301
+ body: r,
302
+ fetchOptions: o,
252
303
  extraData: n
253
304
  }) {
254
305
  var i;
255
- await U.validate(t);
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
- }), o = t.orderFormId && ((i = n.orderFormPurchaseId) == null ? void 0 : i.value) !== t.orderFormId ? `${r}/api/checkout/pub/orderForm/${t.orderFormId}?${String(s)}` : `${r}/api/checkout/pub/orderForm`;
259
- return c(o, { method: "GET", ...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`;
314
+ return l(a, { method: "GET", ...o });
260
315
  }
261
- const V = e.object({
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 z({
271
- apiUrl: r,
272
- body: t,
273
- fetchOptions: a
325
+ async function V({
326
+ apiUrl: t,
327
+ body: r,
328
+ fetchOptions: o
274
329
  }) {
275
- await V.validate(t);
276
- const { orderFormId: n, ...s } = t;
277
- return c(
278
- `${r}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,
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
- ...a
341
+ ...o
283
342
  }
284
343
  );
285
344
  }
286
- const B = e.object({
345
+ const J = e.object({
287
346
  sellerCode: e.string().nullable()
288
347
  });
289
- async function K({
290
- apiUrl: r,
291
- body: t,
292
- fetchOptions: a
348
+ async function Y({
349
+ apiUrl: t,
350
+ body: r,
351
+ fetchOptions: o
293
352
  }) {
294
- await B.validate(t);
295
- const { sellerCode: n = "" } = t;
296
- return c(
297
- `${r}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,
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
- ...a
366
+ ...o
304
367
  }
305
368
  );
306
369
  }
307
- const H = e.object().shape({
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 J({
313
- apiUrl: r,
314
- body: t,
315
- fetchOptions: a
375
+ async function X({
376
+ apiUrl: t,
377
+ body: r,
378
+ fetchOptions: o
316
379
  }) {
317
- await H.validate(t);
318
- const { country: n, orderFormId: s, postalCode: o } = t, i = o ? {
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: o,
388
+ postalCode: a,
322
389
  country: n
323
390
  }
324
391
  } : {
325
392
  logisticsInfo: [],
326
393
  clearAddressIfPostalCodeNotFound: !0
327
394
  };
328
- return c(
329
- `${r}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,
395
+ return l(
396
+ `${t}/api/checkout/pub/orderForm/${s}/attachments/shippingData`,
330
397
  {
331
398
  method: "POST",
332
399
  body: i,
333
- ...a
400
+ ...o
334
401
  }
335
402
  );
336
403
  }
337
- const L = e.object().shape({
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 Q({ apiUrl: r, body: t, fetchOptions: a }) {
366
- await L.validate(t);
367
- const { orderFormId: n, options: s, selectedAddresses: o } = t;
368
- return c(
369
- `${r}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,
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: o,
444
+ selectedAddresses: a,
374
445
  clearAddressIfPostalCodeNotFound: !1,
375
446
  logisticsInfo: s
376
447
  },
377
- ...a
448
+ ...o
378
449
  }
379
450
  );
380
451
  }
381
- const X = e.object({
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 W({ apiUrl: r, body: t, fetchOptions: a }) {
390
- await X.validate(t);
391
- const { country: n = "", geoCoordinates: s, postalCode: o = "" } = t, i = new URLSearchParams({ country: String(n) });
392
- return o ? i.append("postalCode", o) : i.append(
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 c(
396
- `${r}/api/checkout/pub/regions/?${i.toString()}`,
470
+ ), await l(
471
+ `${t}/api/checkout/pub/regions/?${i.toString()}`,
397
472
  {
398
473
  method: "GET",
399
- ...a
474
+ ...o
400
475
  }
401
476
  );
402
477
  }
403
- const Y = e.object({
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
- }), Z = e.object({
408
- items: e.array().of(Y),
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 ee({ apiUrl: r, body: t, fetchOptions: a }) {
414
- return await Z.validate(t), c(
415
- `${r}/api/checkout/pub/orderForms/simulation`,
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: t,
419
- ...a
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 te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
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
- getMasterDataSellerCode: K,
426
- getOrderForm: G,
427
- postOrderFormAddCoupon: j,
428
- postOrderFormAttachClientProfileData: z,
429
- postOrderFormAttachOrderFormData: q,
430
- postOrderFormAttachShippingData: J,
431
- postOrderFormAttachmentsMarketingData: I,
432
- postOrderFormAttachmentsOpenTextField: f,
433
- postOrderFormClearMessages: N,
434
- postOrderFormFreightSimulation: ee,
435
- postOrderFormRegion: W,
436
- postOrderFormRemoveAllItems: w,
437
- postOrderFormUpdateItems: R,
438
- postOrderFormUpdateShippingData: Q,
439
- postOrderformAddress: v,
440
- putOrderFormCustomData: T,
441
- schemaAddress: b,
442
- schemaAttachments: S,
443
- schemaItem: F,
444
- updateOrderFormOffering: M
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 re({
447
- contentType: r,
448
- documents: t,
449
- NextCookies: a,
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 o = JSON.parse(
455
- ((i = a().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
653
+ const a = JSON.parse(
654
+ ((i = o().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
456
655
  );
457
- if (o && (o == null ? void 0 : o.contentType) === r) {
458
- const d = o.documentId && o.documentId.length ? `/${o.documentId}` : "", m = o != null && o.versionId && (o != null && o.versionId.length) ? `?versionId=${o == null ? void 0 : o.versionId}` : "", p = await (await fetch(
459
- `https://${s}.myvtex.com/_v/cms/api/${n}/${r}${d}${m}`,
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(), l = t.filter(
660
+ )).json(), c = r.filter(
462
661
  (u) => p.id !== u.documentId
463
662
  );
464
- return l.unshift(p), l;
663
+ return c.unshift(p), c;
465
664
  }
466
- return t;
665
+ return r;
467
666
  }
468
- async function oe({
469
- contentType: r,
470
- NextCookies: t,
471
- CMS_PROJECT_NAME: a,
667
+ async function qe({
668
+ contentType: t,
669
+ NextCookies: r,
670
+ CMS_PROJECT_NAME: o,
472
671
  storeId: n
473
672
  }) {
474
- var h, p;
673
+ var g, p;
475
674
  const s = JSON.parse(
476
- ((h = t().get("cms_preview_data")) == null ? void 0 : h.value) ?? "{}"
477
- ), o = [];
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/${a}/${r}?page=${i}`
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 && o.push(...u.data), m = u.hasNextPage, i++;
485
- } while (m && o.length < d);
486
- if (s.previewMode && o.length) {
487
- const l = await re({
488
- contentType: r,
489
- documents: o,
490
- NextCookies: t,
491
- CMS_PROJECT_NAME: a,
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: l.length > 0 ? 200 : 404,
496
- data: l ?? []
694
+ status: c.length > 0 ? 200 : 404,
695
+ data: c ?? []
497
696
  };
498
697
  }
499
698
  return {
500
- status: o.length ? 200 : 404,
501
- data: o
699
+ status: a.length ? 200 : 404,
700
+ data: a
502
701
  };
503
- } catch (l) {
504
- return { status: "error", data: [], error: l };
702
+ } catch (c) {
703
+ return { status: "error", data: [], error: c };
505
704
  }
506
705
  }
507
- const ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
706
+ const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
508
707
  __proto__: null,
509
- getContentType: oe
510
- }, Symbol.toStringTag, { value: "Module" })), ne = {
511
- checkout: {
512
- ...te
513
- },
514
- cms: ae
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
- ne as serverAPIs
717
+ Te as serverAPIs,
718
+ ve as serverHelpers
518
719
  };