@soma-vertical-web/multi-lib 0.0.31 → 0.0.32

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