@teamnovu/kit-shopware-composables 0.0.17 → 0.0.18

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/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { inject as Y, unref as i, computed as c, reactive as Z, watch as H, toRef as W } from "vue";
2
2
  import { until as J } from "@vueuse/core";
3
- import { queryOptions as P, useQuery as Q, useQueryClient as C, useMutation as v } from "@tanstack/vue-query";
3
+ import { queryOptions as P, useQuery as Q, useQueryClient as C, useMutation as h } from "@tanstack/vue-query";
4
4
  import "@teamnovu/kit-shopware-api-client";
5
5
  const _ = Symbol("shopwareClient");
6
6
  function g() {
@@ -76,7 +76,7 @@ const F = {
76
76
  body: e
77
77
  }
78
78
  ]
79
- }, I = {
79
+ }, x = {
80
80
  get: () => ["cart"]
81
81
  }, L = {
82
82
  all: () => ["customer"],
@@ -185,7 +185,7 @@ const V = (e) => {
185
185
  const s = e.replace(/\/?$/, "");
186
186
  return s.startsWith("/") ? s.slice(1) : s;
187
187
  }, ft = (e) => `/${V(e)}`;
188
- function vt(e, s, t) {
188
+ function ht(e, s, t) {
189
189
  const n = C();
190
190
  return {
191
191
  onMutate: async (r) => {
@@ -228,7 +228,7 @@ function k(e) {
228
228
  const ue = "updateContext patch /context";
229
229
  function $(e) {
230
230
  const s = g(), t = C();
231
- return v({
231
+ return h({
232
232
  ...e,
233
233
  mutationFn: async (n) => (t.cancelQueries({ queryKey: F.all() }), s.query(ue, {
234
234
  body: n
@@ -239,7 +239,7 @@ function $(e) {
239
239
  }
240
240
  });
241
241
  }
242
- function ht() {
242
+ function vt() {
243
243
  const e = $(), s = k(), t = se(), n = c(() => s.isFetching.value || e.isPending.value), r = async (d) => {
244
244
  await e.mutateAsync({
245
245
  billingAddressId: d.id
@@ -319,8 +319,8 @@ function qt(e, s) {
319
319
  }
320
320
  };
321
321
  }), n = ce(t.value), r = c(() => {
322
- var l, m, q, x;
323
- return (x = (q = (m = (l = n.data) == null ? void 0 : l.value) == null ? void 0 : m.orders) == null ? void 0 : q.elements) == null ? void 0 : x[0];
322
+ var l, m, q, I;
323
+ return (I = (q = (m = (l = n.data) == null ? void 0 : l.value) == null ? void 0 : m.orders) == null ? void 0 : q.elements) == null ? void 0 : I[0];
324
324
  }), a = c(() => {
325
325
  var l, m;
326
326
  return ((m = (l = n.data) == null ? void 0 : l.value) == null ? void 0 : m.paymentChangeable) || {};
@@ -340,18 +340,18 @@ function qt(e, s) {
340
340
  var l;
341
341
  return (l = r.value) == null ? void 0 : l.shippingTotal;
342
342
  }), M = c(() => {
343
- var l, m, q, x, z, G;
343
+ var l, m, q, I, z, G;
344
344
  return {
345
345
  email: (m = (l = r.value) == null ? void 0 : l.orderCustomer) == null ? void 0 : m.email,
346
- firstName: (x = (q = r.value) == null ? void 0 : q.orderCustomer) == null ? void 0 : x.firstName,
346
+ firstName: (I = (q = r.value) == null ? void 0 : q.orderCustomer) == null ? void 0 : I.firstName,
347
347
  lastName: (G = (z = r.value) == null ? void 0 : z.orderCustomer) == null ? void 0 : G.lastName
348
348
  };
349
349
  }), O = c(() => {
350
350
  var l, m;
351
351
  return (m = (l = r.value) == null ? void 0 : l.addresses) == null ? void 0 : m.find(
352
352
  ({ id: q }) => {
353
- var x;
354
- return q === ((x = r.value) == null ? void 0 : x.billingAddressId);
353
+ var I;
354
+ return q === ((I = r.value) == null ? void 0 : I.billingAddressId);
355
355
  }
356
356
  );
357
357
  }), y = c(
@@ -359,7 +359,7 @@ function qt(e, s) {
359
359
  var l, m, q;
360
360
  return (q = (m = (l = r.value) == null ? void 0 : l.deliveries) == null ? void 0 : m[0]) == null ? void 0 : q.shippingOrderAddress;
361
361
  }
362
- ), h = c(() => {
362
+ ), v = c(() => {
363
363
  var m, q;
364
364
  const l = (m = r.value) == null ? void 0 : m.transactions;
365
365
  if (l != null && l.length)
@@ -385,7 +385,7 @@ function qt(e, s) {
385
385
  billingAddress: O,
386
386
  personalDetails: M,
387
387
  shippingMethod: K,
388
- paymentMethod: h,
388
+ paymentMethod: v,
389
389
  paymentChangeable: A,
390
390
  orderQuery: n
391
391
  };
@@ -413,7 +413,7 @@ function Ct(e) {
413
413
  const le = "createCustomerAddress post /account/address";
414
414
  function St(e) {
415
415
  const s = g(), t = C();
416
- return v({
416
+ return h({
417
417
  ...e,
418
418
  mutationFn: async (n) => s.query(le, p(n)),
419
419
  onSuccess: async (n, r, a) => {
@@ -425,7 +425,7 @@ function St(e) {
425
425
  const de = "deleteCustomerAddress delete /account/address/{addressId}";
426
426
  function Pt(e) {
427
427
  const s = g(), t = C();
428
- return v({
428
+ return h({
429
429
  ...e,
430
430
  mutationFn: async (n) => s.query(de, p(n)),
431
431
  onSuccess: async (n, r, a) => {
@@ -437,7 +437,7 @@ function Pt(e) {
437
437
  const ye = "updateCustomerAddress patch /account/address/{addressId}";
438
438
  function Qt(e) {
439
439
  const s = g(), t = C();
440
- return v({
440
+ return h({
441
441
  ...e,
442
442
  mutationFn: async (n) => s.query(ye, p(n)),
443
443
  onSuccess: async (n, r, a) => {
@@ -456,20 +456,20 @@ function Qt(e) {
456
456
  const pe = "addLineItem post /checkout/cart/line-item";
457
457
  function Mt(e) {
458
458
  const s = g(), t = C();
459
- return v({
459
+ return h({
460
460
  ...e,
461
461
  mutationFn: async (n) => s.query(pe, {
462
462
  body: n
463
463
  }),
464
464
  onSuccess: async (n, r, a) => {
465
465
  var u, o;
466
- t.setQueryData(I.get(), n), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
466
+ t.setQueryData(x.get(), n), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
467
467
  }
468
468
  });
469
469
  }
470
470
  const ge = "readCart get /checkout/cart";
471
471
  function me(e) {
472
- const s = g(), t = I.get();
472
+ const s = g(), t = x.get();
473
473
  return P({
474
474
  queryKey: t,
475
475
  queryFn: async ({ signal: n }) => s.query(ge, {
@@ -484,42 +484,40 @@ function Ot() {
484
484
  const fe = "removeLineItem post /checkout/cart/line-item/delete";
485
485
  function Kt(e) {
486
486
  const s = g(), t = C();
487
- return v({
487
+ return h({
488
488
  ...e,
489
489
  mutationFn: async (n) => s.query(fe, {
490
490
  body: n
491
491
  }),
492
492
  onSuccess: async (n, r, a) => {
493
493
  var u, o;
494
- t.setQueryData(I.get(), n), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
494
+ t.setQueryData(x.get(), n), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
495
495
  }
496
496
  });
497
497
  }
498
- const ve = "updateLineItem patch /checkout/cart/line-item";
498
+ const he = "updateLineItem patch /checkout/cart/line-item";
499
499
  function At(e) {
500
500
  const s = g(), t = C();
501
- return v({
501
+ return h({
502
502
  ...e,
503
- mutationFn: async (n) => s.query(ve, {
503
+ mutationFn: async (n) => s.query(he, {
504
504
  body: n
505
505
  }),
506
506
  onSuccess: async (n, r, a) => {
507
507
  var u, o;
508
- t.setQueryData(I.get(), n), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
508
+ t.setQueryData(x.get(), n), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
509
509
  }
510
510
  });
511
511
  }
512
- const he = "createOrder post /checkout/order";
512
+ const ve = "createOrder post /checkout/order";
513
513
  function wt(e) {
514
514
  const s = g(), t = C();
515
- return v({
515
+ return h({
516
516
  ...e,
517
- mutationFn: async (n) => s.query(he, p(n)),
517
+ mutationFn: async (n) => s.query(ve, p(n)),
518
518
  onSuccess: async (n, r, a) => {
519
519
  var u, o;
520
520
  await Promise.all([
521
- // Clear cart after successful order creation
522
- t.invalidateQueries({ queryKey: I.get() }),
523
521
  // Invalidate order list to refetch data
524
522
  t.invalidateQueries({ queryKey: U.lists() })
525
523
  ]), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
@@ -559,7 +557,7 @@ function Ft(e) {
559
557
  const Qe = "changeEmail post /account/change-email";
560
558
  function Lt(e) {
561
559
  const s = g(), t = C();
562
- return v({
560
+ return h({
563
561
  ...e,
564
562
  mutationFn: async (n) => s.query(Qe, p(n)),
565
563
  onSuccess: async (n, r, a) => {
@@ -571,7 +569,7 @@ function Lt(e) {
571
569
  const Me = "changeProfile post /account/change-profile";
572
570
  function It(e) {
573
571
  const s = g(), t = C();
574
- return v({
572
+ return h({
575
573
  ...e,
576
574
  mutationFn: async (n) => s.query(Me, p(n)),
577
575
  onSuccess: async (n, r, a) => {
@@ -586,7 +584,7 @@ function It(e) {
586
584
  const Oe = "loginCustomer post /account/login";
587
585
  function xt(e) {
588
586
  const s = g(), t = C();
589
- return v({
587
+ return h({
590
588
  ...e,
591
589
  mutationFn: async (n) => {
592
590
  const r = await s.queryRaw(Oe, {
@@ -598,7 +596,7 @@ function xt(e) {
598
596
  var u, o;
599
597
  await Promise.all([
600
598
  t.resetQueries({ queryKey: F.all() }),
601
- t.invalidateQueries({ queryKey: I.get() }),
599
+ t.invalidateQueries({ queryKey: x.get() }),
602
600
  t.invalidateQueries({ queryKey: L.all() })
603
601
  ]), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
604
602
  }
@@ -607,14 +605,14 @@ function xt(e) {
607
605
  const Ke = "logoutCustomer post /account/logout";
608
606
  function Ut(e) {
609
607
  const s = g(), t = C();
610
- return v({
608
+ return h({
611
609
  ...e,
612
610
  mutationFn: async (n) => s.query(Ke, p(n)),
613
611
  onSuccess: async (n, r, a) => {
614
612
  var u, o;
615
613
  await Promise.all([
616
614
  t.resetQueries({ queryKey: F.all() }),
617
- t.invalidateQueries({ queryKey: I.get() }),
615
+ t.invalidateQueries({ queryKey: x.get() }),
618
616
  t.invalidateQueries({ queryKey: L.all() })
619
617
  ]), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
620
618
  }
@@ -634,7 +632,7 @@ function Re(e) {
634
632
  const Fe = "register post /account/register";
635
633
  function bt(e) {
636
634
  const s = g(), t = C();
637
- return v({
635
+ return h({
638
636
  ...e,
639
637
  mutationFn: async (n) => s.query(Fe, p(n)),
640
638
  onSuccess: async (n, r, a) => {
@@ -646,7 +644,7 @@ function bt(e) {
646
644
  const Le = "defaultBillingAddress patch /account/address/default-billing/{addressId}";
647
645
  function kt(e) {
648
646
  const s = g(), t = C();
649
- return v({
647
+ return h({
650
648
  ...e,
651
649
  mutationFn: async (n) => s.query(Le, p(n)),
652
650
  onSuccess: async (n, r, a) => {
@@ -661,7 +659,7 @@ function kt(e) {
661
659
  const Ie = "defaultShippingAddress patch /account/address/default-shipping/{addressId}";
662
660
  function Bt(e) {
663
661
  const s = g(), t = C();
664
- return v({
662
+ return h({
665
663
  ...e,
666
664
  mutationFn: async (n) => s.query(Ie, p(n)),
667
665
  onSuccess: async (n, r, a) => {
@@ -676,7 +674,7 @@ function Bt(e) {
676
674
  const xe = "deleteCustomer delete /account/customer";
677
675
  function Dt(e) {
678
676
  const s = g(), t = C();
679
- return v({
677
+ return h({
680
678
  ...e,
681
679
  mutationFn: async (n) => s.query(xe, p(n)),
682
680
  onSuccess: async (n, r, a) => {
@@ -684,7 +682,7 @@ function Dt(e) {
684
682
  await Promise.all([
685
683
  t.resetQueries({ queryKey: L.all() }),
686
684
  t.resetQueries({ queryKey: F.all() }),
687
- t.resetQueries({ queryKey: I.get() })
685
+ t.resetQueries({ queryKey: x.get() })
688
686
  ]), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
689
687
  }
690
688
  });
@@ -692,7 +690,7 @@ function Dt(e) {
692
690
  const Ue = "registerConfirm post /account/register-confirm";
693
691
  function Nt(e) {
694
692
  const s = g();
695
- return v({
693
+ return h({
696
694
  ...e,
697
695
  mutationFn: async (t) => {
698
696
  const n = await s.queryRaw(Ue, {
@@ -709,7 +707,7 @@ function Nt(e) {
709
707
  const be = "sendRecoveryMail post /account/recovery-password";
710
708
  function Tt(e) {
711
709
  const s = g();
712
- return v({
710
+ return h({
713
711
  ...e,
714
712
  mutationFn: async (t) => s.query(be, p(t)),
715
713
  onSuccess: async (t, n, r) => {
@@ -721,7 +719,7 @@ function Tt(e) {
721
719
  const ke = "changePassword post /account/change-password";
722
720
  function Et(e) {
723
721
  const s = g();
724
- return v({
722
+ return h({
725
723
  ...e,
726
724
  mutationFn: async (t) => s.query(ke, p(t)),
727
725
  onSuccess: async (t, n, r) => {
@@ -744,7 +742,7 @@ function jt(e) {
744
742
  const Ne = "recoveryPassword post /account/recovery-password-confirm";
745
743
  function Vt(e) {
746
744
  const s = g();
747
- return v({
745
+ return h({
748
746
  ...e,
749
747
  mutationFn: async (t) => s.query(Ne, p(t)),
750
748
  onSuccess: async (t, n, r) => {
@@ -793,19 +791,19 @@ function $e(e) {
793
791
  const ze = "handlePaymentMethod post /handle-payment";
794
792
  function zt(e) {
795
793
  const s = g(), t = C();
796
- return v({
794
+ return h({
797
795
  ...e,
798
796
  mutationFn: async (n) => s.query(ze, p(n)),
799
797
  onSuccess: async (n, r, a) => {
800
798
  var u, o;
801
- await t.invalidateQueries({ queryKey: I.get() }), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
799
+ await t.invalidateQueries({ queryKey: x.get() }), await ((o = i((u = i(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : o(n, r, a));
802
800
  }
803
801
  });
804
802
  }
805
803
  const Ge = "orderSetPayment post /order/payment";
806
804
  function Gt(e) {
807
805
  const s = g(), t = C();
808
- return v({
806
+ return h({
809
807
  ...e,
810
808
  mutationFn: async (n) => s.query(Ge, p(n)),
811
809
  onSuccess: async (n, r, a) => {
@@ -1076,24 +1074,24 @@ function rn(e) {
1076
1074
  return (y = e.value) == null ? void 0 : y.calculatedCheapestPrice;
1077
1075
  }), t = c(
1078
1076
  () => {
1079
- var y, h, K, A, l;
1080
- return (((h = (y = e.value) == null ? void 0 : y.calculatedPrices) == null ? void 0 : h.length) ?? 0) > 0 ? (A = (K = e.value) == null ? void 0 : K.calculatedPrices) == null ? void 0 : A[0] : (l = e.value) == null ? void 0 : l.calculatedPrice;
1077
+ var y, v, K, A, l;
1078
+ return (((v = (y = e.value) == null ? void 0 : y.calculatedPrices) == null ? void 0 : v.length) ?? 0) > 0 ? (A = (K = e.value) == null ? void 0 : K.calculatedPrices) == null ? void 0 : A[0] : (l = e.value) == null ? void 0 : l.calculatedPrice;
1081
1079
  }
1082
1080
  ), n = c(() => {
1083
1081
  var y;
1084
1082
  return (y = t == null ? void 0 : t.value) == null ? void 0 : y.referencePrice;
1085
1083
  }), r = c(() => {
1086
- var y, h;
1087
- return (((h = (y = e.value) == null ? void 0 : y.calculatedPrices) == null ? void 0 : h.length) ?? 0) > 1;
1084
+ var y, v;
1085
+ return (((v = (y = e.value) == null ? void 0 : y.calculatedPrices) == null ? void 0 : v.length) ?? 0) > 1;
1088
1086
  }), a = c(
1089
1087
  () => {
1090
- var y, h, K, A, l, m;
1091
- return !!((y = e.value) != null && y.parentId) && ((K = (h = e.value) == null ? void 0 : h.calculatedCheapestPrice) == null ? void 0 : K.hasRange) && ((A = t == null ? void 0 : t.value) == null ? void 0 : A.unitPrice) !== ((l = s == null ? void 0 : s.value) == null ? void 0 : l.unitPrice) && ((m = s == null ? void 0 : s.value) == null ? void 0 : m.unitPrice);
1088
+ var y, v, K, A, l, m;
1089
+ return !!((y = e.value) != null && y.parentId) && ((K = (v = e.value) == null ? void 0 : v.calculatedCheapestPrice) == null ? void 0 : K.hasRange) && ((A = t == null ? void 0 : t.value) == null ? void 0 : A.unitPrice) !== ((l = s == null ? void 0 : s.value) == null ? void 0 : l.unitPrice) && ((m = s == null ? void 0 : s.value) == null ? void 0 : m.unitPrice);
1092
1090
  }
1093
1091
  ), u = c(
1094
1092
  () => {
1095
- var y, h;
1096
- return r.value && X(e.value).length > 1 ? (h = (y = e.value) == null ? void 0 : y.calculatedPrices) == null ? void 0 : h.reduce((K, A) => A.unitPrice < K.unitPrice ? A : K) : t.value;
1093
+ var y, v;
1094
+ return r.value && X(e.value).length > 1 ? (v = (y = e.value) == null ? void 0 : y.calculatedPrices) == null ? void 0 : v.reduce((K, A) => A.unitPrice < K.unitPrice ? A : K) : t.value;
1097
1095
  }
1098
1096
  ), o = c(
1099
1097
  () => {
@@ -1108,12 +1106,12 @@ function rn(e) {
1108
1106
  ), S = c(
1109
1107
  () => u.value
1110
1108
  ), d = c(() => {
1111
- var y, h;
1112
- return !!((h = (y = u.value) == null ? void 0 : y.listPrice) != null && h.percentage);
1109
+ var y, v;
1110
+ return !!((v = (y = u.value) == null ? void 0 : y.listPrice) != null && v.percentage);
1113
1111
  }), M = c(
1114
1112
  () => {
1115
- var y, h, K;
1116
- return (K = (h = (y = e.value) == null ? void 0 : y.calculatedPrice) == null ? void 0 : h.regulationPrice) == null ? void 0 : K.price;
1113
+ var y, v, K;
1114
+ return (K = (v = (y = e.value) == null ? void 0 : y.calculatedPrice) == null ? void 0 : v.regulationPrice) == null ? void 0 : K.price;
1117
1115
  }
1118
1116
  ), O = c(() => X(e.value));
1119
1117
  return {
@@ -1203,7 +1201,7 @@ function on(e) {
1203
1201
  export {
1204
1202
  ft as absolutizeSeoUrl,
1205
1203
  R as addressKeys,
1206
- I as cartKeys,
1204
+ x as cartKeys,
1207
1205
  B as categoryKeys,
1208
1206
  F as contextKeys,
1209
1207
  j as countryKeys,
@@ -1226,7 +1224,7 @@ export {
1226
1224
  Lt as useChangeEmailMutation,
1227
1225
  Et as useChangePasswordMutation,
1228
1226
  It as useChangeProfileMutation,
1229
- ht as useCheckoutAddresses,
1227
+ vt as useCheckoutAddresses,
1230
1228
  St as useCreateCustomerAddressMutation,
1231
1229
  wt as useCreateOrderMutation,
1232
1230
  kt as useDefaultBillingAddressMutation,
@@ -1241,7 +1239,7 @@ export {
1241
1239
  ne as useListAddressQueryOptions,
1242
1240
  xt as useLoginCustomerMutation,
1243
1241
  Ut as useLogoutCustomerMutation,
1244
- vt as useOptimistic,
1242
+ ht as useOptimistic,
1245
1243
  qt as useOrderDetails,
1246
1244
  Ct as useOrderPayment,
1247
1245
  Gt as useOrderSetPaymentMutation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-shopware-composables",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "A collection of composables for the Shopware API",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient, type UseMutationOptions } from '@tanstack/
2
2
  import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
3
3
  import { unref } from 'vue'
4
4
  import { useShopwareQueryClient } from '../../inject'
5
- import { cartKeys, orderKeys } from '../../keys'
5
+ import { orderKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
7
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
8
8
 
@@ -25,9 +25,6 @@ export function useCreateOrderMutation(
25
25
  },
26
26
  onSuccess: async (data, variables, context) => {
27
27
  await Promise.all([
28
- // Clear cart after successful order creation
29
- queryClient.invalidateQueries({ queryKey: cartKeys.get() }),
30
-
31
28
  // Invalidate order list to refetch data
32
29
  queryClient.invalidateQueries({ queryKey: orderKeys.lists() }),
33
30
  ])