@soma-vertical-web/multi-lib 0.0.28 → 0.0.30

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