@teamnovu/kit-shopware-composables 0.0.34 → 0.0.35

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
@@ -9,7 +9,7 @@ function g() {
9
9
  throw new Error("Shopware client not provided!");
10
10
  return e;
11
11
  }
12
- const R = {
12
+ const w = {
13
13
  all: () => ["context"]
14
14
  }, ee = {
15
15
  all: () => ["language"]
@@ -96,18 +96,18 @@ const R = {
96
96
  all: () => ["customer"],
97
97
  detail: (e) => ["customer", { body: e }],
98
98
  imitateLogin: (e) => ["customer", "imitateLogin", { body: e }]
99
- }, A = {
99
+ }, R = {
100
100
  all: () => ["address"],
101
- lists: () => [...A.all(), "list"],
101
+ lists: () => [...R.all(), "list"],
102
102
  list: (e) => [
103
- ...A.all(),
103
+ ...R.all(),
104
104
  "list",
105
105
  {
106
106
  body: e
107
107
  }
108
108
  ],
109
- details: () => [...A.all(), "detail"],
110
- detail: (e, s) => [...A.details(), e, ...s ? [{ body: s }] : []]
109
+ details: () => [...R.all(), "detail"],
110
+ detail: (e, s) => [...R.details(), e, ...s ? [{ body: s }] : []]
111
111
  }, D = {
112
112
  all: () => ["shippingMethod"],
113
113
  lists: () => [...D.all(), "list"],
@@ -179,7 +179,7 @@ function y(e) {
179
179
  }
180
180
  const te = "listAddress post /account/list-address";
181
181
  function ne(e) {
182
- const s = g(), t = A.list(c(() => {
182
+ const s = g(), t = R.list(c(() => {
183
183
  var n;
184
184
  return (n = y(e)) == null ? void 0 : n.body;
185
185
  }));
@@ -228,7 +228,7 @@ const re = "readContext get /context";
228
228
  function ae(e) {
229
229
  const s = g();
230
230
  return h({
231
- queryKey: R.all(),
231
+ queryKey: w.all(),
232
232
  queryFn: ({ signal: t }) => s.query(re, {
233
233
  ...y(e),
234
234
  signal: t
@@ -243,13 +243,13 @@ function $(e) {
243
243
  const s = g(), t = C();
244
244
  return f({
245
245
  ...e,
246
- mutationFn: async (n) => (t.cancelQueries({ queryKey: R.all() }), s.query(ue, {
246
+ mutationFn: async (n) => (t.cancelQueries({ queryKey: w.all() }), s.query(ue, {
247
247
  body: n
248
248
  })),
249
249
  onSuccess: async (n, r, a) => {
250
250
  var u, i;
251
251
  await Promise.all([
252
- t.invalidateQueries({ queryKey: R.all() }),
252
+ t.invalidateQueries({ queryKey: w.all() }),
253
253
  t.invalidateQueries({ queryKey: L.get() }),
254
254
  t.invalidateQueries({ queryKey: b.lists() }),
255
255
  t.invalidateQueries({ queryKey: D.lists() })
@@ -382,7 +382,7 @@ function Pt(e, s) {
382
382
  const l = (m = r.value) == null ? void 0 : m.transactions;
383
383
  if (l != null && l.length)
384
384
  return (S = l.at(-1)) == null ? void 0 : S.paymentMethod;
385
- }), w = c(() => {
385
+ }), A = c(() => {
386
386
  var m, S;
387
387
  const l = (m = r.value) == null ? void 0 : m.deliveries;
388
388
  if (l != null && l.length)
@@ -402,7 +402,7 @@ function Pt(e, s) {
402
402
  shippingAddress: p,
403
403
  billingAddress: M,
404
404
  personalDetails: K,
405
- shippingMethod: w,
405
+ shippingMethod: A,
406
406
  paymentMethod: Q,
407
407
  paymentChangeable: F,
408
408
  orderQuery: n
@@ -433,10 +433,20 @@ function Mt(e) {
433
433
  const s = g(), t = C();
434
434
  return f({
435
435
  ...e,
436
- mutationFn: async (n) => s.query(le, y(n)),
436
+ mutationFn: async (n) => s.query(
437
+ le,
438
+ y(n)
439
+ ),
437
440
  onSuccess: async (n, r, a) => {
438
441
  var u, i;
439
- await t.invalidateQueries({ queryKey: A.lists() }), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
442
+ await Promise.all([
443
+ t.invalidateQueries({ queryKey: R.lists() }),
444
+ t.invalidateQueries({ queryKey: w.all() })
445
+ ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(
446
+ n,
447
+ r,
448
+ a
449
+ ));
440
450
  }
441
451
  });
442
452
  }
@@ -445,10 +455,20 @@ function Ot(e) {
445
455
  const s = g(), t = C();
446
456
  return f({
447
457
  ...e,
448
- mutationFn: async (n) => s.query(de, y(n)),
458
+ mutationFn: async (n) => s.query(
459
+ de,
460
+ y(n)
461
+ ),
449
462
  onSuccess: async (n, r, a) => {
450
463
  var u, i;
451
- await t.invalidateQueries({ queryKey: A.lists() }), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
464
+ await Promise.all([
465
+ t.invalidateQueries({ queryKey: R.lists() }),
466
+ t.invalidateQueries({ queryKey: w.all() })
467
+ ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(
468
+ n,
469
+ r,
470
+ a
471
+ ));
452
472
  }
453
473
  });
454
474
  }
@@ -461,10 +481,11 @@ function wt(e) {
461
481
  onSuccess: async (n, r, a) => {
462
482
  var i, v;
463
483
  const { addressId: u } = y(r).params;
464
- t.setQueryData(A.detail(u), n), await Promise.all([
465
- t.invalidateQueries({ queryKey: A.lists() }),
484
+ t.setQueryData(R.detail(u), n), await Promise.all([
485
+ t.invalidateQueries({ queryKey: w.all() }),
486
+ t.invalidateQueries({ queryKey: R.lists() }),
466
487
  t.invalidateQueries({
467
- queryKey: A.detail(y(r).params.addressId),
488
+ queryKey: R.detail(y(r).params.addressId),
468
489
  predicate: (P) => P.queryKey.at(-1) !== u
469
490
  })
470
491
  ]), await ((v = o((i = o(e)) == null ? void 0 : i.onSuccess)) == null ? void 0 : v(n, r, a));
@@ -596,7 +617,7 @@ function Dt(e) {
596
617
  mutationFn: async (n) => s.query(Pe, y(n)),
597
618
  onSuccess: async (n, r, a) => {
598
619
  var u, i;
599
- await t.invalidateQueries({ queryKey: I.all() }), await t.invalidateQueries({ queryKey: R.all() }), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
620
+ await t.invalidateQueries({ queryKey: I.all() }), await t.invalidateQueries({ queryKey: w.all() }), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
600
621
  }
601
622
  });
602
623
  }
@@ -610,7 +631,7 @@ function bt(e) {
610
631
  var u, i;
611
632
  await Promise.all([
612
633
  t.invalidateQueries({ queryKey: I.all() }),
613
- t.invalidateQueries({ queryKey: R.all() })
634
+ t.invalidateQueries({ queryKey: w.all() })
614
635
  ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
615
636
  }
616
637
  });
@@ -629,7 +650,7 @@ function kt(e) {
629
650
  onSuccess: async (n, r, a) => {
630
651
  var u, i;
631
652
  await Promise.all([
632
- t.resetQueries({ queryKey: R.all() }),
653
+ t.resetQueries({ queryKey: w.all() }),
633
654
  t.invalidateQueries({ queryKey: L.get() }),
634
655
  t.invalidateQueries({ queryKey: I.all() })
635
656
  ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
@@ -645,10 +666,10 @@ function Bt(e) {
645
666
  onSuccess: async (n, r, a) => {
646
667
  var u, i;
647
668
  await Promise.all([
648
- t.resetQueries({ queryKey: R.all() }),
669
+ t.resetQueries({ queryKey: w.all() }),
649
670
  t.invalidateQueries({ queryKey: L.get() }),
650
671
  t.invalidateQueries({ queryKey: I.all() }),
651
- t.invalidateQueries({ queryKey: A.all() }),
672
+ t.invalidateQueries({ queryKey: R.all() }),
652
673
  t.invalidateQueries({ queryKey: D.all() }),
653
674
  t.invalidateQueries({ queryKey: b.all() }),
654
675
  t.invalidateQueries({ queryKey: U.all() })
@@ -676,7 +697,7 @@ function Nt(e) {
676
697
  onSuccess: async (n, r, a) => {
677
698
  var u, i;
678
699
  await Promise.all([
679
- t.resetQueries({ queryKey: R.all() }),
700
+ t.resetQueries({ queryKey: w.all() }),
680
701
  t.invalidateQueries({ queryKey: I.all() })
681
702
  ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
682
703
  }
@@ -692,7 +713,7 @@ function Tt(e) {
692
713
  var u, i;
693
714
  await Promise.all([
694
715
  t.invalidateQueries({ queryKey: I.all() }),
695
- t.invalidateQueries({ queryKey: R.all() })
716
+ t.invalidateQueries({ queryKey: w.all() })
696
717
  ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
697
718
  }
698
719
  });
@@ -707,7 +728,7 @@ function Et(e) {
707
728
  var u, i;
708
729
  await Promise.all([
709
730
  t.invalidateQueries({ queryKey: I.all() }),
710
- t.invalidateQueries({ queryKey: R.all() })
731
+ t.invalidateQueries({ queryKey: w.all() })
711
732
  ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
712
733
  }
713
734
  });
@@ -722,7 +743,7 @@ function jt(e) {
722
743
  var u, i;
723
744
  await Promise.all([
724
745
  t.resetQueries({ queryKey: I.all() }),
725
- t.resetQueries({ queryKey: R.all() }),
746
+ t.resetQueries({ queryKey: w.all() }),
726
747
  t.resetQueries({ queryKey: L.get() })
727
748
  ]), await ((i = o((u = o(e)) == null ? void 0 : u.onSuccess)) == null ? void 0 : i(n, r, a));
728
749
  }
@@ -1153,8 +1174,8 @@ function dn(e) {
1153
1174
  return (p = e.value) == null ? void 0 : p.calculatedCheapestPrice;
1154
1175
  }), t = c(
1155
1176
  () => {
1156
- var p, Q, w, F, l;
1157
- return (((Q = (p = e.value) == null ? void 0 : p.calculatedPrices) == null ? void 0 : Q.length) ?? 0) > 0 ? (F = (w = e.value) == null ? void 0 : w.calculatedPrices) == null ? void 0 : F[0] : (l = e.value) == null ? void 0 : l.calculatedPrice;
1177
+ var p, Q, A, F, l;
1178
+ return (((Q = (p = e.value) == null ? void 0 : p.calculatedPrices) == null ? void 0 : Q.length) ?? 0) > 0 ? (F = (A = e.value) == null ? void 0 : A.calculatedPrices) == null ? void 0 : F[0] : (l = e.value) == null ? void 0 : l.calculatedPrice;
1158
1179
  }
1159
1180
  ), n = c(() => {
1160
1181
  var p;
@@ -1164,13 +1185,13 @@ function dn(e) {
1164
1185
  return (((Q = (p = e.value) == null ? void 0 : p.calculatedPrices) == null ? void 0 : Q.length) ?? 0) > 1;
1165
1186
  }), a = c(
1166
1187
  () => {
1167
- var p, Q, w, F, l, m;
1168
- return !!((p = e.value) != null && p.parentId) && ((w = (Q = e.value) == null ? void 0 : Q.calculatedCheapestPrice) == null ? void 0 : w.hasRange) && ((F = t == null ? void 0 : t.value) == null ? void 0 : F.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);
1188
+ var p, Q, A, F, l, m;
1189
+ return !!((p = e.value) != null && p.parentId) && ((A = (Q = e.value) == null ? void 0 : Q.calculatedCheapestPrice) == null ? void 0 : A.hasRange) && ((F = t == null ? void 0 : t.value) == null ? void 0 : F.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);
1169
1190
  }
1170
1191
  ), u = c(
1171
1192
  () => {
1172
1193
  var p, Q;
1173
- return r.value && X(e.value).length > 1 ? (Q = (p = e.value) == null ? void 0 : p.calculatedPrices) == null ? void 0 : Q.reduce((w, F) => F.unitPrice < w.unitPrice ? F : w) : t.value;
1194
+ return r.value && X(e.value).length > 1 ? (Q = (p = e.value) == null ? void 0 : p.calculatedPrices) == null ? void 0 : Q.reduce((A, F) => F.unitPrice < A.unitPrice ? F : A) : t.value;
1174
1195
  }
1175
1196
  ), i = c(
1176
1197
  () => {
@@ -1189,8 +1210,8 @@ function dn(e) {
1189
1210
  return !!((Q = (p = u.value) == null ? void 0 : p.listPrice) != null && Q.percentage);
1190
1211
  }), K = c(
1191
1212
  () => {
1192
- var p, Q, w;
1193
- return (w = (Q = (p = e.value) == null ? void 0 : p.calculatedPrice) == null ? void 0 : Q.regulationPrice) == null ? void 0 : w.price;
1213
+ var p, Q, A;
1214
+ return (A = (Q = (p = e.value) == null ? void 0 : p.calculatedPrice) == null ? void 0 : Q.regulationPrice) == null ? void 0 : A.price;
1194
1215
  }
1195
1216
  ), M = c(() => X(e.value));
1196
1217
  return {
@@ -1279,10 +1300,10 @@ function gn(e) {
1279
1300
  }
1280
1301
  export {
1281
1302
  Qt as absolutizeSeoUrl,
1282
- A as addressKeys,
1303
+ R as addressKeys,
1283
1304
  L as cartKeys,
1284
1305
  N as categoryKeys,
1285
- R as contextKeys,
1306
+ w as contextKeys,
1286
1307
  j as countryKeys,
1287
1308
  I as customerKeys,
1288
1309
  mt as getProductVariantForOptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-shopware-composables",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "A collection of composables for the Shopware API",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -1,12 +1,21 @@
1
- import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
- import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
3
- import { unref } from 'vue'
4
- import { useShopwareQueryClient } from '../../inject'
5
- import { addressKeys } from '../../keys'
6
- import { unrefOptions } from '../../util/unrefOptions'
7
- import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
1
+ import {
2
+ useMutation,
3
+ type UseMutationOptions,
4
+ useQueryClient,
5
+ } from "@tanstack/vue-query";
6
+ import { ShopwareApiError } from "@teamnovu/kit-shopware-api-client";
7
+ import { unref } from "vue";
8
+ import { useShopwareQueryClient } from "../../inject";
9
+ import { addressKeys, contextKeys } from "../../keys";
10
+ import { unrefOptions } from "../../util/unrefOptions";
11
+ import type {
12
+ OperationKey,
13
+ OperationOptions,
14
+ OperationResponse,
15
+ } from "../types/query";
8
16
 
9
- const createCustomerAddressOperation = 'createCustomerAddress post /account/address' satisfies OperationKey
17
+ const createCustomerAddressOperation =
18
+ "createCustomerAddress post /account/address" satisfies OperationKey;
10
19
 
11
20
  export function useCreateCustomerAddressMutation(
12
21
  mutationOptions?: UseMutationOptions<
@@ -15,19 +24,31 @@ export function useCreateCustomerAddressMutation(
15
24
  OperationOptions<typeof createCustomerAddressOperation>
16
25
  >,
17
26
  ) {
18
- const client = useShopwareQueryClient()
19
- const queryClient = useQueryClient()
27
+ const client = useShopwareQueryClient();
28
+ const queryClient = useQueryClient();
20
29
 
21
30
  return useMutation({
22
31
  ...mutationOptions,
23
- mutationFn: async (options: OperationOptions<typeof createCustomerAddressOperation>) => {
24
- return client.query(createCustomerAddressOperation, unrefOptions(options))
32
+ mutationFn: async (
33
+ options: OperationOptions<typeof createCustomerAddressOperation>,
34
+ ) => {
35
+ return client.query(
36
+ createCustomerAddressOperation,
37
+ unrefOptions(options),
38
+ );
25
39
  },
26
40
  onSuccess: async (data, variables, context) => {
27
41
  // Invalidate address list queries to refetch data
28
- await queryClient.invalidateQueries({ queryKey: addressKeys.lists() })
42
+ await Promise.all([
43
+ queryClient.invalidateQueries({ queryKey: addressKeys.lists() }),
44
+ queryClient.invalidateQueries({ queryKey: contextKeys.all() }),
45
+ ]);
29
46
 
30
- await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
47
+ await unref(unref(mutationOptions)?.onSuccess)?.(
48
+ data,
49
+ variables,
50
+ context,
51
+ );
31
52
  },
32
- })
53
+ });
33
54
  }
@@ -1,12 +1,21 @@
1
- import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
- import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
3
- import { unref } from 'vue'
4
- import { useShopwareQueryClient } from '../../inject'
5
- import { addressKeys } from '../../keys'
6
- import { unrefOptions } from '../../util/unrefOptions'
7
- import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
1
+ import {
2
+ useMutation,
3
+ type UseMutationOptions,
4
+ useQueryClient,
5
+ } from "@tanstack/vue-query";
6
+ import { ShopwareApiError } from "@teamnovu/kit-shopware-api-client";
7
+ import { unref } from "vue";
8
+ import { useShopwareQueryClient } from "../../inject";
9
+ import { addressKeys, contextKeys } from "../../keys";
10
+ import { unrefOptions } from "../../util/unrefOptions";
11
+ import type {
12
+ OperationKey,
13
+ OperationOptions,
14
+ OperationResponse,
15
+ } from "../types/query";
8
16
 
9
- const deleteCustomerAddressOperation = 'deleteCustomerAddress delete /account/address/{addressId}' satisfies OperationKey
17
+ const deleteCustomerAddressOperation =
18
+ "deleteCustomerAddress delete /account/address/{addressId}" satisfies OperationKey;
10
19
 
11
20
  export function useDeleteCustomerAddressMutation(
12
21
  mutationOptions?: UseMutationOptions<
@@ -15,19 +24,31 @@ export function useDeleteCustomerAddressMutation(
15
24
  OperationOptions<typeof deleteCustomerAddressOperation>
16
25
  >,
17
26
  ) {
18
- const client = useShopwareQueryClient()
19
- const queryClient = useQueryClient()
27
+ const client = useShopwareQueryClient();
28
+ const queryClient = useQueryClient();
20
29
 
21
30
  return useMutation({
22
31
  ...mutationOptions,
23
- mutationFn: async (options: OperationOptions<typeof deleteCustomerAddressOperation>) => {
24
- return client.query(deleteCustomerAddressOperation, unrefOptions(options))
32
+ mutationFn: async (
33
+ options: OperationOptions<typeof deleteCustomerAddressOperation>,
34
+ ) => {
35
+ return client.query(
36
+ deleteCustomerAddressOperation,
37
+ unrefOptions(options),
38
+ );
25
39
  },
26
40
  onSuccess: async (data, variables, context) => {
27
41
  // Invalidate address list queries to refetch data
28
- await queryClient.invalidateQueries({ queryKey: addressKeys.lists() })
42
+ await Promise.all([
43
+ queryClient.invalidateQueries({ queryKey: addressKeys.lists() }),
44
+ queryClient.invalidateQueries({ queryKey: contextKeys.all() }),
45
+ ]);
29
46
 
30
- await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
47
+ await unref(unref(mutationOptions)?.onSuccess)?.(
48
+ data,
49
+ variables,
50
+ context,
51
+ );
31
52
  },
32
- })
53
+ });
33
54
  }
@@ -2,7 +2,7 @@ import { useMutation, type UseMutationOptions, useQueryClient } 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 { addressKeys } from '../../keys'
5
+ import { addressKeys, contextKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
7
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
8
8
 
@@ -29,6 +29,7 @@ export function useUpdateCustomerAddressMutation(
29
29
 
30
30
  // Invalidate address list queries to refetch data
31
31
  await Promise.all([
32
+ queryClient.invalidateQueries({ queryKey: contextKeys.all() }),
32
33
  queryClient.invalidateQueries({ queryKey: addressKeys.lists() }),
33
34
  queryClient.invalidateQueries({
34
35
  queryKey: addressKeys.detail(unrefOptions(variables).params.addressId),