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