@teamnovu/kit-shopware-composables 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/global.d.ts +8 -0
  2. package/dist/helpers/checkout/index.d.ts +1 -1
  3. package/dist/helpers/checkout/{useAddresses.d.ts → useCheckoutAddresses.d.ts} +9 -51
  4. package/dist/helpers/checkout/useOrderDetails.d.ts +3 -8
  5. package/dist/helpers/checkout/usePaymentMethods.d.ts +11 -49
  6. package/dist/helpers/checkout/useShippingMethods.d.ts +11 -55
  7. package/dist/helpers/general/usePagination.d.ts +3 -1
  8. package/dist/helpers/user/useIsLoggedIn.d.ts +3 -2
  9. package/dist/helpers/user/useUser.d.ts +4 -106
  10. package/dist/index.mjs +808 -640
  11. package/dist/keys.d.ts +42 -1
  12. package/dist/query/address/index.d.ts +1 -0
  13. package/dist/query/address/useCreateCustomerAddressMutation.d.ts +7 -6
  14. package/dist/query/address/useDeleteCustomerAddressMutation.d.ts +2 -1
  15. package/dist/query/address/useListAddressQuery.d.ts +5 -36
  16. package/dist/query/address/useUpdateCustomerAddressMutation.d.ts +167 -0
  17. package/dist/query/cart/useAddLineItemMutation.d.ts +7 -6
  18. package/dist/query/cart/useReadCartQuery.d.ts +5 -100
  19. package/dist/query/cart/useRemoveLineItemMutation.d.ts +7 -6
  20. package/dist/query/cart/useUpdateLineItemMutation.d.ts +7 -6
  21. package/dist/query/checkout/index.d.ts +0 -1
  22. package/dist/query/checkout/useCreateOrderMutation.d.ts +7 -6
  23. package/dist/query/context/useReadContextQuery.d.ts +8 -148
  24. package/dist/query/context/useUpdateContextMutation.d.ts +7 -6
  25. package/dist/query/country/index.d.ts +1 -0
  26. package/dist/query/country/useReadCountryQuery.d.ts +17 -0
  27. package/dist/query/customer/useChangeEmailMutation.d.ts +7 -6
  28. package/dist/query/customer/useChangeProfileMutation.d.ts +7 -6
  29. package/dist/query/customer/useLoginCustomerMutation.d.ts +7 -6
  30. package/dist/query/customer/useLogoutCustomerMutation.d.ts +7 -6
  31. package/dist/query/customer/useReadCustomerQuery.d.ts +10 -213
  32. package/dist/query/customer/useRegisterCustomerMutation.d.ts +7 -6
  33. package/dist/query/index.d.ts +4 -0
  34. package/dist/query/navigation/index.d.ts +1 -0
  35. package/dist/query/navigation/useReadNavigationQuery.d.ts +22 -0
  36. package/dist/query/order/useReadOrderQuery.d.ts +5 -32
  37. package/dist/query/payment/useHandlePaymentMutation.d.ts +7 -6
  38. package/dist/query/payment/useOrderSetPaymentMutation.d.ts +7 -6
  39. package/dist/query/payment/useReadPaymentMethodQuery.d.ts +5 -20
  40. package/dist/query/products/useReadCategoryListQuery.d.ts +5 -36
  41. package/dist/query/products/useReadCompactProductListingQuery.d.ts +5 -20
  42. package/dist/query/products/useReadCustomProductDetailQuery.d.ts +5 -52
  43. package/dist/query/salutation/index.d.ts +1 -0
  44. package/dist/query/salutation/useReadSalutationQuery.d.ts +17 -0
  45. package/dist/query/seoUrl/index.d.ts +1 -0
  46. package/dist/query/seoUrl/useReadSeoUrlQuery.d.ts +17 -0
  47. package/dist/query/shipping/useReadShippingMethodQuery.d.ts +5 -44
  48. package/dist/query/types/index.d.ts +1 -0
  49. package/dist/query/types/operations.d.ts +3 -3
  50. package/dist/query/types/query.d.ts +2 -3
  51. package/dist/query/types/util.d.ts +6 -0
  52. package/dist/util/unrefOptions.d.ts +2 -2
  53. package/docs/index.md +3 -3
  54. package/package.json +6 -4
  55. package/src/global.d.ts +8 -0
  56. package/src/helpers/checkout/index.ts +1 -1
  57. package/src/helpers/checkout/{useAddresses.ts → useCheckoutAddresses.ts} +2 -2
  58. package/src/helpers/checkout/useOrderDetails.ts +1 -1
  59. package/src/helpers/checkout/useOrderPayment.ts +1 -1
  60. package/src/helpers/checkout/usePaymentMethods.ts +5 -2
  61. package/src/helpers/checkout/useShippingMethods.ts +5 -2
  62. package/src/helpers/general/usePagination.ts +10 -5
  63. package/src/helpers/user/useIsLoggedIn.ts +6 -8
  64. package/src/helpers/user/useUser.ts +1 -1
  65. package/src/inject.ts +1 -1
  66. package/src/keys.ts +66 -1
  67. package/src/query/address/index.ts +1 -0
  68. package/src/query/address/useCreateCustomerAddressMutation.ts +7 -6
  69. package/src/query/address/useDeleteCustomerAddressMutation.ts +7 -6
  70. package/src/query/address/useUpdateCustomerAddressMutation.ts +42 -0
  71. package/src/query/cart/useAddLineItemMutation.ts +7 -6
  72. package/src/query/cart/useRemoveLineItemMutation.ts +6 -5
  73. package/src/query/cart/useUpdateLineItemMutation.ts +5 -4
  74. package/src/query/checkout/index.ts +0 -1
  75. package/src/query/checkout/useCreateOrderMutation.ts +11 -8
  76. package/src/query/context/useReadContextQuery.ts +14 -5
  77. package/src/query/context/useUpdateContextMutation.ts +6 -5
  78. package/src/query/country/index.ts +1 -0
  79. package/src/query/country/useReadCountryQuery.ts +31 -0
  80. package/src/query/customer/useChangeEmailMutation.ts +7 -7
  81. package/src/query/customer/useChangeProfileMutation.ts +7 -7
  82. package/src/query/customer/useLoginCustomerMutation.ts +12 -9
  83. package/src/query/customer/useLogoutCustomerMutation.ts +11 -7
  84. package/src/query/customer/useReadCustomerQuery.ts +2 -1
  85. package/src/query/customer/useRegisterCustomerMutation.ts +7 -7
  86. package/src/query/index.ts +4 -0
  87. package/src/query/navigation/index.ts +1 -0
  88. package/src/query/navigation/useReadNavigationQuery.ts +43 -0
  89. package/src/query/order/useReadOrderQuery.ts +0 -2
  90. package/src/query/payment/useHandlePaymentMutation.ts +5 -4
  91. package/src/query/payment/useOrderSetPaymentMutation.ts +6 -5
  92. package/src/query/salutation/index.ts +1 -0
  93. package/src/query/salutation/useReadSalutationQuery.ts +31 -0
  94. package/src/query/seoUrl/index.ts +1 -0
  95. package/src/query/seoUrl/useReadSeoUrlQuery.ts +31 -0
  96. package/src/query/types/index.ts +1 -0
  97. package/src/query/types/operations.ts +5 -5
  98. package/src/query/types/query.ts +4 -6
  99. package/src/query/types/util.ts +19 -0
  100. package/src/util/unrefOptions.ts +4 -4
  101. package/src/util/useOptimistic.ts +2 -1
  102. package/tsconfig.json +4 -2
  103. package/vite.config.js +6 -1
  104. package/dist/query/checkout/useCheckout.d.ts +0 -1
  105. package/src/query/checkout/useCheckout.ts +0 -2
@@ -1,16 +1,17 @@
1
- import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
3
  import { unref } from 'vue'
3
- import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
4
4
  import { useShopwareQueryClient } from '../../inject'
5
5
  import { customerKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
+ import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
7
8
 
8
9
  const changeEmailOperation = 'changeEmail post /account/change-email' satisfies OperationKey
9
10
 
10
11
  export function useChangeEmailMutation(
11
12
  mutationOptions?: UseMutationOptions<
12
13
  OperationResponse<typeof changeEmailOperation>,
13
- unknown,
14
+ ShopwareApiError | Error,
14
15
  OperationOptions<typeof changeEmailOperation>
15
16
  >,
16
17
  ) {
@@ -22,11 +23,10 @@ export function useChangeEmailMutation(
22
23
  mutationFn: async (options: OperationOptions<typeof changeEmailOperation>) => {
23
24
  return client.query(changeEmailOperation, unrefOptions(options))
24
25
  },
25
- onSuccess: (data, variables, context) => {
26
- queryClient.invalidateQueries({ queryKey: customerKeys.get() })
26
+ onSuccess: async (data, variables, context) => {
27
+ await queryClient.invalidateQueries({ queryKey: customerKeys.all() })
27
28
 
28
- unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
+ await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
30
  },
30
31
  })
31
32
  }
32
-
@@ -1,16 +1,17 @@
1
- import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
3
  import { unref } from 'vue'
3
- import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
4
4
  import { useShopwareQueryClient } from '../../inject'
5
5
  import { customerKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
+ import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
7
8
 
8
9
  const changeProfileOperation = 'changeProfile post /account/change-profile' satisfies OperationKey
9
10
 
10
11
  export function useChangeProfileMutation(
11
12
  mutationOptions?: UseMutationOptions<
12
13
  OperationResponse<typeof changeProfileOperation>,
13
- unknown,
14
+ ShopwareApiError | Error,
14
15
  OperationOptions<typeof changeProfileOperation>
15
16
  >,
16
17
  ) {
@@ -22,11 +23,10 @@ export function useChangeProfileMutation(
22
23
  mutationFn: async (options: OperationOptions<typeof changeProfileOperation>) => {
23
24
  return client.query(changeProfileOperation, unrefOptions(options))
24
25
  },
25
- onSuccess: (data, variables, context) => {
26
- queryClient.invalidateQueries({ queryKey: customerKeys.get() })
26
+ onSuccess: async (data, variables, context) => {
27
+ await queryClient.invalidateQueries({ queryKey: customerKeys.all() })
27
28
 
28
- unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
+ await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
30
  },
30
31
  })
31
32
  }
32
-
@@ -1,15 +1,16 @@
1
- import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
3
  import { unref } from 'vue'
3
- import type { OperationBody, OperationKey, OperationResponse } from '../types/query'
4
4
  import { useShopwareQueryClient } from '../../inject'
5
- import { contextKeys, cartKeys, customerKeys } from '../../keys'
5
+ import { cartKeys, contextKeys, customerKeys } from '../../keys'
6
+ import type { OperationBody, OperationKey, OperationResponse } from '../types/query'
6
7
 
7
8
  const loginCustomerOperation = 'loginCustomer post /account/login' satisfies OperationKey
8
9
 
9
10
  export function useLoginCustomerMutation(
10
11
  mutationOptions?: UseMutationOptions<
11
12
  OperationResponse<typeof loginCustomerOperation>,
12
- unknown,
13
+ ShopwareApiError | Error,
13
14
  OperationBody<typeof loginCustomerOperation>
14
15
  >,
15
16
  ) {
@@ -31,12 +32,14 @@ export function useLoginCustomerMutation(
31
32
 
32
33
  return response.json()
33
34
  },
34
- onSuccess: (newCustomer, variables, context) => {
35
- queryClient.invalidateQueries({ queryKey: contextKeys.all() })
36
- queryClient.invalidateQueries({ queryKey: cartKeys.get() })
37
- queryClient.invalidateQueries({ queryKey: customerKeys.get() })
35
+ onSuccess: async (newCustomer, variables, context) => {
36
+ await Promise.all([
37
+ queryClient.removeQueries({ queryKey: contextKeys.all() }),
38
+ queryClient.invalidateQueries({ queryKey: cartKeys.get() }),
39
+ queryClient.invalidateQueries({ queryKey: customerKeys.all() }),
40
+ ])
38
41
 
39
- unref(unref(mutationOptions)?.onSuccess)?.(newCustomer, variables, context)
42
+ await unref(unref(mutationOptions)?.onSuccess)?.(newCustomer, variables, context)
40
43
  },
41
44
  })
42
45
  }
@@ -1,8 +1,9 @@
1
- import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
+ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
3
  import { unref } from 'vue'
3
4
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
4
5
  import { useShopwareQueryClient } from '../../inject'
5
- import { customerKeys } from '../../keys'
6
+ import { cartKeys, contextKeys, customerKeys } from '../../keys'
6
7
  import { unrefOptions } from '../../util/unrefOptions'
7
8
 
8
9
  const logoutOperation = 'logoutCustomer post /account/logout' satisfies OperationKey
@@ -10,7 +11,7 @@ const logoutOperation = 'logoutCustomer post /account/logout' satisfies Operatio
10
11
  export function useLogoutCustomerMutation(
11
12
  mutationOptions?: UseMutationOptions<
12
13
  OperationResponse<typeof logoutOperation>,
13
- unknown,
14
+ ShopwareApiError | Error,
14
15
  OperationOptions<typeof logoutOperation>
15
16
  >,
16
17
  ) {
@@ -22,11 +23,14 @@ export function useLogoutCustomerMutation(
22
23
  mutationFn: async (options?: OperationOptions<typeof logoutOperation>) => {
23
24
  return client.query(logoutOperation, unrefOptions(options))
24
25
  },
25
- onSuccess: (data, variables, context) => {
26
- queryClient.removeQueries({ queryKey: customerKeys.get() })
26
+ onSuccess: async (data, variables, context) => {
27
+ await Promise.all([
28
+ queryClient.removeQueries({ queryKey: contextKeys.all() }),
29
+ queryClient.invalidateQueries({ queryKey: cartKeys.get() }),
30
+ queryClient.invalidateQueries({ queryKey: customerKeys.all() }),
31
+ ])
27
32
 
28
- unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
33
+ await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
34
  },
30
35
  })
31
36
  }
32
-
@@ -3,6 +3,7 @@ import { useShopwareQueryClient } from '../../inject'
3
3
  import { customerKeys } from '../../keys'
4
4
  import { unrefOptions } from '../../util'
5
5
  import type { OperationKey, OperationOptions } from '../types/query'
6
+ import { computed } from 'vue'
6
7
 
7
8
  const readCustomer = 'readCustomer post /account/customer' satisfies OperationKey
8
9
 
@@ -10,7 +11,7 @@ export function useReadCustomerQueryOptions(
10
11
  options?: OperationOptions<typeof readCustomer>,
11
12
  ) {
12
13
  const client = useShopwareQueryClient()
13
- const queryKey = customerKeys.get()
14
+ const queryKey = customerKeys.detail(computed(() => unrefOptions(options).body ?? {}))
14
15
 
15
16
  return queryOptions({
16
17
  queryKey,
@@ -1,16 +1,17 @@
1
- import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
3
  import { unref } from 'vue'
3
- import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
4
4
  import { useShopwareQueryClient } from '../../inject'
5
5
  import { customerKeys } from '../../keys'
6
6
  import { unrefOptions } from '../../util/unrefOptions'
7
+ import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
7
8
 
8
9
  const registerOperation = 'register post /account/register' satisfies OperationKey
9
10
 
10
11
  export function useRegisterCustomerMutation(
11
12
  mutationOptions?: UseMutationOptions<
12
13
  OperationResponse<typeof registerOperation>,
13
- unknown,
14
+ ShopwareApiError | Error,
14
15
  OperationOptions<typeof registerOperation>
15
16
  >,
16
17
  ) {
@@ -22,11 +23,10 @@ export function useRegisterCustomerMutation(
22
23
  mutationFn: async (options: OperationOptions<typeof registerOperation>) => {
23
24
  return client.query(registerOperation, unrefOptions(options))
24
25
  },
25
- onSuccess: (data, variables, context) => {
26
- queryClient.invalidateQueries({ queryKey: customerKeys.get() })
26
+ onSuccess: async (data, variables, context) => {
27
+ await queryClient.invalidateQueries({ queryKey: customerKeys.all() })
27
28
 
28
- unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
+ await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
29
30
  },
30
31
  })
31
32
  }
32
-
@@ -2,9 +2,13 @@ export * from './address'
2
2
  export * from './cart'
3
3
  export * from './checkout'
4
4
  export * from './context'
5
+ export * from './country'
5
6
  export * from './customer'
7
+ export * from './navigation'
6
8
  export * from './order'
7
9
  export * from './payment'
8
10
  export * from './products'
11
+ export * from './salutation'
12
+ export * from './seoUrl'
9
13
  export * from './shipping'
10
14
  export * from './types'
@@ -0,0 +1 @@
1
+ export * from './useReadNavigationQuery'
@@ -0,0 +1,43 @@
1
+ import { queryOptions, useQuery } from '@tanstack/vue-query'
2
+ import { unref, type MaybeRef } from 'vue'
3
+ import { useShopwareQueryClient } from '../../inject'
4
+ import { navigationKeys } from '../../keys'
5
+ import { unrefOptions } from '../../util/unrefOptions'
6
+ import type { OperationKey, OperationOptions } from '../types/query'
7
+
8
+ const readNavigationOperation = 'readNavigation post /navigation/{activeId}/{rootId}' satisfies OperationKey
9
+
10
+ export const useReadNavigationQueryOptions = function useReadNavigationQueryOptions(
11
+ activeId: MaybeRef<string>,
12
+ rootId: MaybeRef<string>,
13
+ options?: OperationOptions<typeof readNavigationOperation>,
14
+ ) {
15
+ const client = useShopwareQueryClient()
16
+ const queryKey = navigationKeys.detail(activeId, rootId, options)
17
+
18
+ return queryOptions({
19
+ queryKey,
20
+ queryFn: async ({ signal }) => {
21
+ const unrefdActiveId = unref(activeId)
22
+ const unrefdRootId = unref(rootId)
23
+ const unrefedOptions = unrefOptions(options)
24
+
25
+ return client.query(readNavigationOperation, {
26
+ ...unrefedOptions,
27
+ params: {
28
+ activeId: unrefdActiveId,
29
+ rootId: unrefdRootId,
30
+ },
31
+ signal,
32
+ })
33
+ },
34
+ })
35
+ }
36
+
37
+ export function useReadNavigationQuery(
38
+ activeId: MaybeRef<string>,
39
+ rootId: MaybeRef<string>,
40
+ options?: OperationOptions<typeof readNavigationOperation>,
41
+ ) {
42
+ return useQuery(useReadNavigationQueryOptions(activeId, rootId, options))
43
+ }
@@ -21,7 +21,6 @@ export function useReadOrderQueryOptions(
21
21
  signal,
22
22
  })
23
23
  },
24
- enabled: !!options,
25
24
  })
26
25
  }
27
26
 
@@ -30,4 +29,3 @@ export function useReadOrderQuery(
30
29
  ) {
31
30
  return useQuery(useReadOrderQueryOptions(options))
32
31
  }
33
-
@@ -1,4 +1,5 @@
1
- import { useMutation, UseMutationOptions } from '@tanstack/vue-query'
1
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
+ import { useMutation, type UseMutationOptions } from '@tanstack/vue-query'
2
3
  import { unref } from 'vue'
3
4
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
4
5
  import { useShopwareQueryClient } from '../../inject'
@@ -9,7 +10,7 @@ const handlePaymentOperation = 'handlePaymentMethod post /handle-payment' satisf
9
10
  export function useHandlePaymentMutation(
10
11
  mutationOptions?: UseMutationOptions<
11
12
  OperationResponse<typeof handlePaymentOperation>,
12
- unknown,
13
+ ShopwareApiError | Error,
13
14
  OperationOptions<typeof handlePaymentOperation>
14
15
  >,
15
16
  ) {
@@ -20,8 +21,8 @@ export function useHandlePaymentMutation(
20
21
  mutationFn: async (options: OperationOptions<typeof handlePaymentOperation>) => {
21
22
  return client.query(handlePaymentOperation, unrefOptions(options))
22
23
  },
23
- onSuccess: (data, variables, context) => {
24
- unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
24
+ onSuccess: async (data, variables, context) => {
25
+ await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
25
26
  },
26
27
  })
27
28
  }
@@ -1,4 +1,5 @@
1
- import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import { ShopwareApiError } from '@teamnovu/kit-shopware-api-client'
2
+ import { useMutation, type UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
2
3
  import { unref } from 'vue'
3
4
  import type { OperationKey, OperationOptions, OperationResponse } from '../types/query'
4
5
  import { useShopwareQueryClient } from '../../inject'
@@ -10,7 +11,7 @@ const orderSetPaymentOperation = 'orderSetPayment post /order/payment' satisfies
10
11
  export function useOrderSetPaymentMutation(
11
12
  mutationOptions?: UseMutationOptions<
12
13
  OperationResponse<typeof orderSetPaymentOperation>,
13
- unknown,
14
+ ShopwareApiError | Error,
14
15
  OperationOptions<typeof orderSetPaymentOperation>
15
16
  >,
16
17
  ) {
@@ -22,11 +23,11 @@ export function useOrderSetPaymentMutation(
22
23
  mutationFn: async (options: OperationOptions<typeof orderSetPaymentOperation>) => {
23
24
  return client.query(orderSetPaymentOperation, unrefOptions(options))
24
25
  },
25
- onSuccess: (data, variables, context) => {
26
+ onSuccess: async (data, variables, context) => {
26
27
  // Invalidate order queries to refetch updated payment information
27
- queryClient.invalidateQueries({ queryKey: orderKeys.all() })
28
+ await queryClient.invalidateQueries({ queryKey: orderKeys.all() })
28
29
 
29
- unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
30
+ await unref(unref(mutationOptions)?.onSuccess)?.(data, variables, context)
30
31
  },
31
32
  })
32
33
  }
@@ -0,0 +1 @@
1
+ export * from './useReadSalutationQuery'
@@ -0,0 +1,31 @@
1
+ import { queryOptions, useQuery } from '@tanstack/vue-query'
2
+ import { useShopwareQueryClient } from '../../inject'
3
+ import { salutationKeys } from '../../keys'
4
+ import { unrefOptions } from '../../util/unrefOptions'
5
+ import type { OperationKey, OperationOptions } from '../types/query'
6
+
7
+ const readSalutationOperation = 'readSalutation post /salutation' satisfies OperationKey
8
+
9
+ export const useReadSalutationQueryOptions = function useReadSalutationQueryOptions(
10
+ options?: OperationOptions<typeof readSalutationOperation>,
11
+ ) {
12
+ const client = useShopwareQueryClient()
13
+ const queryKey = salutationKeys.list(options)
14
+
15
+ return queryOptions({
16
+ queryKey,
17
+ queryFn: async ({ signal }) => {
18
+ const unrefedOptions = unrefOptions(options)
19
+
20
+ return client.query(readSalutationOperation, {
21
+ ...unrefedOptions,
22
+ signal,
23
+ })
24
+ },
25
+ })
26
+ }
27
+
28
+ export function useReadSalutationQuery(options?: OperationOptions<typeof readSalutationOperation>) {
29
+ return useQuery(useReadSalutationQueryOptions(options))
30
+ }
31
+
@@ -0,0 +1 @@
1
+ export * from './useReadSeoUrlQuery'
@@ -0,0 +1,31 @@
1
+ import { queryOptions, useQuery } from '@tanstack/vue-query'
2
+ import { useShopwareQueryClient } from '../../inject'
3
+ import { seoUrlKeys } from '../../keys'
4
+ import { unrefOptions } from '../../util/unrefOptions'
5
+ import type { OperationKey, OperationOptions } from '../types/query'
6
+
7
+ const readSeoUrlOperation = 'readSeoUrl post /seo-url' satisfies OperationKey
8
+
9
+ export const useReadSeoUrlQueryOptions = function useReadSeoUrlQueryOptions(
10
+ options?: OperationOptions<typeof readSeoUrlOperation>,
11
+ ) {
12
+ const client = useShopwareQueryClient()
13
+ const queryKey = seoUrlKeys.list(options)
14
+
15
+ return queryOptions({
16
+ queryKey,
17
+ queryFn: async ({ signal }) => {
18
+ const unrefedOptions = unrefOptions(options)
19
+
20
+ return client.query(readSeoUrlOperation, {
21
+ ...unrefedOptions,
22
+ signal,
23
+ })
24
+ },
25
+ })
26
+ }
27
+
28
+ export function useReadSeoUrlQuery(options?: OperationOptions<typeof readSeoUrlOperation>) {
29
+ return useQuery(useReadSeoUrlQueryOptions(options))
30
+ }
31
+
@@ -1,2 +1,3 @@
1
1
  export * from './operations'
2
2
  export * from './query'
3
+ export * from './util'
@@ -1,6 +1,6 @@
1
- import { operations, Schemas as OriginalSchemas } from '#store-types'
1
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
2
+ import type { operations as OriginalOperations, Schemas as OriginalSchemas } from '#store-types'
3
+
4
+ export interface Operations extends ShopwareApi.Operations, OriginalOperations {}
5
+ export interface Schemas extends ShopwareApi.Schemas, OriginalSchemas {}
2
6
 
3
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
4
- export interface Operations extends operations {}
5
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
6
- export interface Schemas extends OriginalSchemas {}
@@ -1,13 +1,11 @@
1
- import type { operations } from '#store-types'
2
1
  import type { QueryKey, UseQueryOptions } from '@tanstack/vue-query'
3
2
  import type {
4
3
  OperationProp,
5
4
  OperationOptions as RawOperationOptions,
6
5
  } from '@teamnovu/kit-shopware-api-client'
7
- import { MaybeRef, UnwrapRef } from 'vue'
8
- import { Operations } from './operations'
9
-
10
- export type PartialProps<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
6
+ import type { MaybeRef, UnwrapRef } from 'vue'
7
+ import type { Operations } from './operations'
8
+ import type { PartialProps } from './util'
11
9
 
12
10
  export type ShallowMaybeRefs<T> = {
13
11
  [K in keyof T]: MaybeRef<T[K]>
@@ -17,7 +15,7 @@ export type ShallowUnwrapRefs<T> = {
17
15
  [K in keyof T]: UnwrapRef<T[K]>
18
16
  }
19
17
 
20
- export type OperationKey = keyof operations
18
+ export type OperationKey = keyof Operations
21
19
  export type OperationBody<K extends OperationKey> =
22
20
  OperationProp<Operations, K, 'body'>
23
21
  export type OperationResponse<K extends OperationKey> =
@@ -0,0 +1,19 @@
1
+ type DeepOverride<T, U> = {
2
+ [K in keyof U]: K extends keyof T
3
+ ? U[K] extends infer UK
4
+ ? T[K] extends infer TK
5
+ ? TK extends Record<string, unknown>
6
+ ? UK extends Record<string, unknown>
7
+ ? Override<T[K], U[K]>
8
+ : U[K]
9
+ : U[K]
10
+ : U[K]
11
+ : never
12
+ : never
13
+ }
14
+
15
+ export type Override<T, U> = T extends Record<string, unknown>
16
+ ? DeepOverride<T, U> & Omit<T, keyof U>
17
+ : U
18
+
19
+ export type PartialProps<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
@@ -1,7 +1,7 @@
1
- import { unref, UnwrapRef } from 'vue'
2
- import { OperationOptions as RawOperationOptions } from '@teamnovu/kit-shopware-api-client'
3
- import { OperationOptions, PartialProps } from '../query/types/query'
4
- import { Operations } from '../query/types'
1
+ import { unref, type UnwrapRef } from 'vue'
2
+ import type { OperationOptions as RawOperationOptions } from '@teamnovu/kit-shopware-api-client'
3
+ import type { OperationOptions } from '../query/types/query'
4
+ import type { Operations, PartialProps } from '../query/types'
5
5
 
6
6
  export function unrefOptions<
7
7
  K extends keyof Operations,
@@ -1,4 +1,5 @@
1
- import { MutationOptions, QueryKey, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
1
+ import type { MutationOptions, QueryKey, UseMutationOptions } from '@tanstack/vue-query'
2
+ import { useQueryClient } from '@tanstack/vue-query'
2
3
  import { unref } from 'vue'
3
4
 
4
5
  // https://tanstack.com/query/latest/docs/framework/vue/guides/optimistic-updates#via-the-cache
package/tsconfig.json CHANGED
@@ -2,14 +2,16 @@
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "dist",
5
+ "isolatedModules": true,
6
+ "verbatimModuleSyntax": true,
5
7
  "types": [
6
8
  "vue",
7
9
  "vite/client",
8
- "vitest/globals"
10
+ "vitest/globals",
9
11
  ],
10
12
  "paths": {
11
13
  "#types": [
12
- "./src/types.d.ts"
14
+ "./src/types/operations.d.ts"
13
15
  ],
14
16
  "#store-types": [
15
17
  "./api-types/storeApiTypes.d.ts"
package/vite.config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import vue from '@vitejs/plugin-vue'
2
2
  import { resolve } from 'path'
3
3
  import { defineConfig } from 'vite'
4
- import dts from 'vite-plugin-dts'
4
+ import dts from 'unplugin-dts/vite'
5
5
  import pkg from './package.json'
6
6
 
7
7
  export default defineConfig({
@@ -9,6 +9,11 @@ export default defineConfig({
9
9
  vue(),
10
10
  dts({
11
11
  staticImport: true,
12
+ copyDtsFiles: true,
13
+ compilerOptions: {
14
+ declaration: true,
15
+ emitDeclarationOnly: true,
16
+ },
12
17
  }),
13
18
  ],
14
19
  build: {
@@ -1 +0,0 @@
1
- export declare const useCheckout: () => void;
@@ -1,2 +0,0 @@
1
- export const useCheckout = () => {
2
- }