@teamnovu/kit-shopware-composables 0.0.3 → 0.0.4

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 (149) hide show
  1. package/api-types/storeApiSchema.localhost.http +1 -1
  2. package/dist/helpers/checkout/index.d.ts +5 -0
  3. package/dist/helpers/checkout/useAddresses.d.ts +210 -0
  4. package/dist/helpers/checkout/useOrderDetails.d.ts +186 -0
  5. package/dist/helpers/checkout/useOrderPayment.d.ts +73 -0
  6. package/dist/helpers/checkout/usePaymentMethods.d.ts +155 -0
  7. package/dist/helpers/checkout/useShippingMethods.d.ts +173 -0
  8. package/dist/helpers/general/index.d.ts +2 -0
  9. package/dist/{usePagination.d.ts → helpers/general/usePagination.d.ts} +1 -1
  10. package/dist/{general → helpers/general}/useSeoUrl.d.ts +1 -1
  11. package/dist/helpers/index.d.ts +4 -0
  12. package/dist/helpers/product/index.d.ts +2 -0
  13. package/dist/helpers/product/useProductPrice.d.ts +61 -0
  14. package/dist/{products → helpers/product}/useProductVariantForOptions.d.ts +1 -1
  15. package/dist/helpers/user/index.d.ts +2 -0
  16. package/dist/helpers/user/useIsLoggedIn.d.ts +2 -0
  17. package/dist/helpers/user/useUser.d.ts +167 -0
  18. package/dist/index.d.ts +3 -221
  19. package/dist/index.mjs +851 -222
  20. package/dist/inject.d.ts +2 -2
  21. package/dist/keys.d.ts +32 -0
  22. package/dist/query/address/index.d.ts +3 -0
  23. package/dist/query/address/useCreateCustomerAddressMutation.d.ts +166 -0
  24. package/dist/query/address/useDeleteCustomerAddressMutation.d.ts +5 -0
  25. package/dist/query/address/useListAddressQuery.d.ts +48 -0
  26. package/dist/query/cart/index.d.ts +4 -0
  27. package/dist/query/cart/useAddLineItemMutation.d.ts +131 -0
  28. package/dist/query/cart/useReadCartQuery.d.ts +108 -0
  29. package/dist/query/cart/useRemoveLineItemMutation.d.ts +136 -0
  30. package/dist/query/cart/useUpdateLineItemMutation.d.ts +131 -0
  31. package/dist/query/checkout/index.d.ts +2 -0
  32. package/dist/query/checkout/useCheckout.d.ts +1 -0
  33. package/dist/query/checkout/useCreateOrderMutation.d.ts +281 -0
  34. package/dist/query/context/index.d.ts +2 -0
  35. package/dist/query/context/useReadContextQuery.d.ts +153 -0
  36. package/dist/query/context/useUpdateContextMutation.d.ts +60 -0
  37. package/dist/query/customer/index.d.ts +6 -0
  38. package/dist/query/customer/useChangeEmailMutation.d.ts +15 -0
  39. package/dist/query/customer/useChangeProfileMutation.d.ts +15 -0
  40. package/dist/query/customer/useLoginCustomerMutation.d.ts +30 -0
  41. package/dist/query/customer/useLogoutCustomerMutation.d.ts +15 -0
  42. package/dist/query/customer/useReadCustomerQuery.d.ts +220 -0
  43. package/dist/query/customer/useRegisterCustomerMutation.d.ts +266 -0
  44. package/dist/query/index.d.ts +10 -0
  45. package/dist/query/order/index.d.ts +1 -0
  46. package/dist/query/order/useReadOrderQuery.d.ts +44 -0
  47. package/dist/query/payment/index.d.ts +3 -0
  48. package/dist/query/payment/useHandlePaymentMutation.d.ts +15 -0
  49. package/dist/query/payment/useOrderSetPaymentMutation.d.ts +15 -0
  50. package/dist/query/payment/useReadPaymentMethodQuery.d.ts +31 -0
  51. package/dist/query/products/index.d.ts +3 -0
  52. package/dist/query/products/useReadCategoryListQuery.d.ts +48 -0
  53. package/dist/query/products/useReadCompactProductListingQuery.d.ts +35 -0
  54. package/dist/query/products/useReadCustomProductDetailQuery.d.ts +67 -0
  55. package/dist/query/shipping/index.d.ts +1 -0
  56. package/dist/query/shipping/useReadShippingMethodQuery.d.ts +55 -0
  57. package/dist/query/types/index.d.ts +2 -0
  58. package/dist/query/types/operations.d.ts +5 -0
  59. package/dist/query/types/query.d.ts +17 -0
  60. package/dist/util/index.d.ts +3 -0
  61. package/dist/util/unrefOptions.d.ts +4 -0
  62. package/dist/util/useOptimistic.d.ts +12 -0
  63. package/docs/index.md +457 -0
  64. package/docs/info.json +3 -0
  65. package/package.json +5 -1
  66. package/src/helpers/checkout/index.ts +5 -0
  67. package/src/helpers/checkout/useAddresses.ts +57 -0
  68. package/src/helpers/checkout/useOrderDetails.ts +94 -0
  69. package/src/helpers/checkout/useOrderPayment.ts +28 -0
  70. package/src/helpers/checkout/usePaymentMethods.ts +35 -0
  71. package/src/helpers/checkout/useShippingMethods.ts +35 -0
  72. package/src/helpers/general/index.ts +2 -0
  73. package/src/helpers/index.ts +4 -0
  74. package/src/helpers/product/index.ts +2 -0
  75. package/src/{products → helpers/product}/useProductPrice.ts +1 -43
  76. package/src/helpers/user/index.ts +2 -0
  77. package/src/helpers/user/useIsLoggedIn.ts +10 -0
  78. package/src/helpers/user/useUser.ts +53 -0
  79. package/src/index.ts +4 -29
  80. package/src/inject.ts +3 -3
  81. package/src/keys.ts +57 -0
  82. package/src/query/address/index.ts +3 -0
  83. package/src/query/address/useCreateCustomerAddressMutation.ts +32 -0
  84. package/src/query/address/useDeleteCustomerAddressMutation.ts +32 -0
  85. package/src/query/address/useListAddressQuery.ts +29 -0
  86. package/src/query/cart/index.ts +4 -0
  87. package/src/query/cart/useAddLineItemMutation.ts +45 -0
  88. package/src/query/cart/useReadCartQuery.ts +28 -0
  89. package/src/query/cart/useRemoveLineItemMutation.ts +32 -0
  90. package/src/query/cart/useUpdateLineItemMutation.ts +45 -0
  91. package/src/query/checkout/index.ts +2 -0
  92. package/src/query/checkout/useCheckout.ts +2 -0
  93. package/src/query/checkout/useCreateOrderMutation.ts +35 -0
  94. package/src/query/context/index.ts +2 -0
  95. package/src/query/context/useReadContextQuery.ts +19 -0
  96. package/src/query/context/useUpdateContextMutation.ts +36 -0
  97. package/src/query/customer/index.ts +6 -0
  98. package/src/query/customer/useChangeEmailMutation.ts +32 -0
  99. package/src/query/customer/useChangeProfileMutation.ts +32 -0
  100. package/src/query/customer/useLoginCustomerMutation.ts +42 -0
  101. package/src/query/customer/useLogoutCustomerMutation.ts +32 -0
  102. package/src/query/customer/useReadCustomerQuery.ts +27 -0
  103. package/src/query/customer/useRegisterCustomerMutation.ts +32 -0
  104. package/src/query/index.ts +10 -0
  105. package/src/query/order/index.ts +1 -0
  106. package/src/query/order/useReadOrderQuery.ts +33 -0
  107. package/src/query/payment/index.ts +3 -0
  108. package/src/query/payment/useHandlePaymentMutation.ts +27 -0
  109. package/src/query/payment/useOrderSetPaymentMutation.ts +32 -0
  110. package/src/query/payment/useReadPaymentMethodQuery.ts +30 -0
  111. package/src/query/products/index.ts +3 -0
  112. package/src/query/products/useReadCategoryListQuery.ts +28 -0
  113. package/src/query/products/useReadCompactProductListingQuery.ts +41 -0
  114. package/src/query/products/useReadCustomProductDetailQuery.ts +41 -0
  115. package/src/query/shipping/index.ts +1 -0
  116. package/src/query/shipping/useReadShippingMethodQuery.ts +29 -0
  117. package/src/query/types/index.ts +2 -0
  118. package/src/query/types/operations.ts +6 -0
  119. package/src/query/types/query.ts +39 -0
  120. package/src/util/index.ts +3 -0
  121. package/src/util/unrefOptions.ts +19 -0
  122. package/src/util/useOptimistic.ts +49 -0
  123. package/tsconfig.json +5 -2
  124. package/dist/cart/useCartAddItemMutation.d.ts +0 -12
  125. package/dist/cart/useCartQueryOptions.d.ts +0 -9
  126. package/dist/cart/useCartRemoveItemMutation.d.ts +0 -7
  127. package/dist/cart/useCartUpdateItemMutation.d.ts +0 -12
  128. package/dist/context/useContextOptions.d.ts +0 -9
  129. package/dist/context/useContextUpdate.d.ts +0 -4
  130. package/dist/products/useCategoryQueryOptions.d.ts +0 -17
  131. package/dist/products/useProductListingQueryOptions.d.ts +0 -19
  132. package/dist/products/useProductListingQueryOptions.test.d.ts +0 -1
  133. package/dist/products/useProductPrice.d.ts +0 -49
  134. package/dist/products/useProductQueryOptions.d.ts +0 -19
  135. package/dist/types/query.d.ts +0 -7
  136. package/src/cart/useCartAddItemMutation.ts +0 -48
  137. package/src/cart/useCartQueryOptions.ts +0 -19
  138. package/src/cart/useCartRemoveItemMutation.ts +0 -32
  139. package/src/cart/useCartUpdateItemMutation.ts +0 -48
  140. package/src/context/useContextOptions.ts +0 -16
  141. package/src/context/useContextUpdate.ts +0 -16
  142. package/src/products/useCategoryQueryOptions.ts +0 -25
  143. package/src/products/useProductListingQueryOptions.test.ts +0 -24
  144. package/src/products/useProductListingQueryOptions.ts +0 -29
  145. package/src/products/useProductQueryOptions.ts +0 -29
  146. package/src/types/query.ts +0 -18
  147. /package/src/{usePagination.ts → helpers/general/usePagination.ts} +0 -0
  148. /package/src/{general → helpers/general}/useSeoUrl.ts +0 -0
  149. /package/src/{products → helpers/product}/useProductVariantForOptions.ts +0 -0
@@ -1,12 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { MutationOptions, UseMutationReturnType, MutationObserverIdleResult, MutationObserverLoadingResult, MutationObserverErrorResult, MutationObserverSuccessResult } from '@tanstack/vue-query';
3
- import { OperationBody, OperationResponse } from '../types/query';
4
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
5
- declare const addCartItemOperation = "addLineItem post /checkout/cart/line-item";
6
- type LineItem<Operations extends operations> = OperationBody<Operations, typeof addCartItemOperation>['items'][number];
7
- type LineItemPayload<Operations extends operations> = Partial<Omit<LineItem<Operations>, 'id' | 'quantity' | 'type'>> & Required<Pick<LineItem<Operations>, 'id' | 'quantity' | 'type'>>;
8
- type Body<Operations extends operations> = Omit<OperationBody<Operations, typeof addCartItemOperation>, 'items'> & {
9
- items: LineItemPayload<Operations>[];
10
- };
11
- export declare function useCartAddItemMutation<Operations extends operations>(mutationOptions: MutationOptions<OperationResponse<Operations, typeof addCartItemOperation>, unknown, Body<Operations>>): UseMutationReturnType<OperationProp<operations & Operations, "addLineItem post /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown, Omit< MutationObserverIdleResult<OperationProp<operations & Operations, "addLineItem post /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset"> | Omit< MutationObserverLoadingResult<OperationProp<operations & Operations, "addLineItem post /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset"> | Omit< MutationObserverErrorResult<OperationProp<operations & Operations, "addLineItem post /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset"> | Omit< MutationObserverSuccessResult<OperationProp<operations & Operations, "addLineItem post /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset">>;
12
- export {};
@@ -1,9 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { UndefinedInitialQueryOptions } from '@tanstack/vue-query';
3
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
4
- export declare function useCartQueryOptions<Operations extends operations>(): UndefinedInitialQueryOptions<OperationProp<operations & Operations, "readCart get /checkout/cart", "response">, Error, OperationProp<operations & Operations, "readCart get /checkout/cart", "response">, readonly ["cart"]> & {
5
- queryKey: readonly ["cart"] & {
6
- [dataTagSymbol]: OperationProp<operations & Operations, "readCart get /checkout/cart", "response">;
7
- [dataTagErrorSymbol]: Error;
8
- };
9
- };
@@ -1,7 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { MutationOptions, UseMutationReturnType, MutationObserverIdleResult, MutationObserverLoadingResult, MutationObserverErrorResult, MutationObserverSuccessResult } from '@tanstack/vue-query';
3
- import { OperationBody, OperationResponse } from '../types/query';
4
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
5
- declare const removeCartItemOperation = "removeLineItem post /checkout/cart/line-item/delete";
6
- export declare function useCartRemoveItemMutation<Operations extends operations>(mutationOptions?: MutationOptions<OperationResponse<Operations, typeof removeCartItemOperation>, unknown, OperationBody<Operations, typeof removeCartItemOperation>>): UseMutationReturnType<OperationProp<operations & Operations, "removeLineItem post /checkout/cart/line-item/delete", "response">, unknown, OperationProp<Operations, "removeLineItem post /checkout/cart/line-item/delete", "body">, unknown, Omit< MutationObserverIdleResult<OperationProp<operations & Operations, "removeLineItem post /checkout/cart/line-item/delete", "response">, unknown, OperationProp<Operations, "removeLineItem post /checkout/cart/line-item/delete", "body">, unknown>, "mutate" | "reset"> | Omit< MutationObserverLoadingResult<OperationProp<operations & Operations, "removeLineItem post /checkout/cart/line-item/delete", "response">, unknown, OperationProp<Operations, "removeLineItem post /checkout/cart/line-item/delete", "body">, unknown>, "mutate" | "reset"> | Omit< MutationObserverErrorResult<OperationProp<operations & Operations, "removeLineItem post /checkout/cart/line-item/delete", "response">, unknown, OperationProp<Operations, "removeLineItem post /checkout/cart/line-item/delete", "body">, unknown>, "mutate" | "reset"> | Omit< MutationObserverSuccessResult<OperationProp<operations & Operations, "removeLineItem post /checkout/cart/line-item/delete", "response">, unknown, OperationProp<Operations, "removeLineItem post /checkout/cart/line-item/delete", "body">, unknown>, "mutate" | "reset">>;
7
- export {};
@@ -1,12 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { MutationOptions, UseMutationReturnType, MutationObserverIdleResult, MutationObserverLoadingResult, MutationObserverErrorResult, MutationObserverSuccessResult } from '@tanstack/vue-query';
3
- import { OperationBody, OperationResponse } from '../types/query';
4
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
5
- declare const updateCartItemOperation = "updateLineItem patch /checkout/cart/line-item";
6
- type LineItem<Operations extends operations> = OperationBody<Operations, typeof updateCartItemOperation>['items'][number];
7
- type LineItemPayload<Operations extends operations> = Partial<Omit<LineItem<Operations>, 'id' | 'quantity' | 'type'>> & Required<Pick<LineItem<Operations>, 'id' | 'quantity' | 'type'>>;
8
- type Body<Operations extends operations> = Omit<OperationBody<Operations, typeof updateCartItemOperation>, 'items'> & {
9
- items: LineItemPayload<Operations>[];
10
- };
11
- export declare function useCartUpdateItemMutation<Operations extends operations>(mutationOptions?: MutationOptions<OperationResponse<Operations, typeof updateCartItemOperation>, unknown, Body<Operations>>): UseMutationReturnType<OperationProp<operations & Operations, "updateLineItem patch /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown, Omit< MutationObserverIdleResult<OperationProp<operations & Operations, "updateLineItem patch /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset"> | Omit< MutationObserverLoadingResult<OperationProp<operations & Operations, "updateLineItem patch /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset"> | Omit< MutationObserverErrorResult<OperationProp<operations & Operations, "updateLineItem patch /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset"> | Omit< MutationObserverSuccessResult<OperationProp<operations & Operations, "updateLineItem patch /checkout/cart/line-item", "response">, unknown, Body<Operations>, unknown>, "mutate" | "reset">>;
12
- export {};
@@ -1,9 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { UndefinedInitialQueryOptions } from '@tanstack/vue-query';
3
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
4
- export declare function useContextOptions<Operations extends operations>(): UndefinedInitialQueryOptions<OperationProp<operations & Operations, "readContext get /context", "response">, Error, OperationProp<operations & Operations, "readContext get /context", "response">, readonly ["context"]> & {
5
- queryKey: readonly ["context"] & {
6
- [dataTagSymbol]: OperationProp<operations & Operations, "readContext get /context", "response">;
7
- [dataTagErrorSymbol]: Error;
8
- };
9
- };
@@ -1,4 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { UseMutationReturnType, MutationObserverIdleResult, MutationObserverLoadingResult, MutationObserverErrorResult, MutationObserverSuccessResult } from '@tanstack/vue-query';
3
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
4
- export declare function useContextUpdate<Operations extends operations>(): UseMutationReturnType<OperationProp<operations & Operations, "updateContext patch /context", "response">, Error, void, unknown, Omit< MutationObserverIdleResult<OperationProp<operations & Operations, "updateContext patch /context", "response">, Error, void, unknown>, "mutate" | "reset"> | Omit< MutationObserverLoadingResult<OperationProp<operations & Operations, "updateContext patch /context", "response">, Error, void, unknown>, "mutate" | "reset"> | Omit< MutationObserverErrorResult<OperationProp<operations & Operations, "updateContext patch /context", "response">, Error, void, unknown>, "mutate" | "reset"> | Omit< MutationObserverSuccessResult<OperationProp<operations & Operations, "updateContext patch /context", "response">, Error, void, unknown>, "mutate" | "reset">>;
@@ -1,17 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { MaybeRef } from 'vue';
3
- import { OperationBody } from '../types/query';
4
- import { UndefinedInitialQueryOptions } from '@tanstack/vue-query';
5
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
6
- declare const readCategoryListOperation = "readCategoryList post /category";
7
- export declare function useCategoryQueryOptions<Operations extends operations>(body?: MaybeRef<OperationBody<Operations, typeof readCategoryListOperation>>): UndefinedInitialQueryOptions<OperationProp<operations & Operations, "readCategoryList post /category", "response">, Error, OperationProp<operations & Operations, "readCategoryList post /category", "response">, readonly ["category", "list", {
8
- readonly body: unknown;
9
- }]> & {
10
- queryKey: readonly ["category", "list", {
11
- readonly body: unknown;
12
- }] & {
13
- [dataTagSymbol]: OperationProp<operations & Operations, "readCategoryList post /category", "response">;
14
- [dataTagErrorSymbol]: Error;
15
- };
16
- };
17
- export {};
@@ -1,19 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { MaybeRef } from 'vue';
3
- import { OperationBody } from '../types/query';
4
- import { UndefinedInitialQueryOptions } from '@tanstack/vue-query';
5
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
6
- declare const readListingOperation = "readCompactProductListing post /novu/headless/product-listing/{seoUrl}";
7
- export declare function useProductListingQueryOptions<Operations extends operations>(seoUrl: MaybeRef<string>, body?: MaybeRef<OperationBody<Operations, typeof readListingOperation>>): UndefinedInitialQueryOptions<OperationProp<operations & Operations, "readCompactProductListing post /novu/headless/product-listing/{seoUrl}", "response">, Error, OperationProp<operations & Operations, "readCompactProductListing post /novu/headless/product-listing/{seoUrl}", "response">, readonly ["product", "list", {
8
- readonly url: MaybeRef<string>;
9
- readonly body: unknown;
10
- }]> & {
11
- queryKey: readonly ["product", "list", {
12
- readonly url: MaybeRef<string>;
13
- readonly body: unknown;
14
- }] & {
15
- [dataTagSymbol]: OperationProp<operations & Operations, "readCompactProductListing post /novu/headless/product-listing/{seoUrl}", "response">;
16
- [dataTagErrorSymbol]: Error;
17
- };
18
- };
19
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- import { Schemas } from '../../api-types/storeApiTypes.d.ts';
2
- import { TierPrice } from '@shopware/helpers';
3
- import { ComputedRef, Ref } from 'vue';
4
- export type UseProductPriceReturn = {
5
- /**
6
- * Whole calculated price object
7
- */
8
- price: ComputedRef<Schemas['CalculatedPrice'] | undefined>;
9
- /**
10
- * Calculated price value for one selling unit
11
- */
12
- totalPrice: ComputedRef<number | undefined>;
13
- /**
14
- * Current unit price value
15
- */
16
- unitPrice: ComputedRef<number | undefined>;
17
- /**
18
- * Can be used if isListPrice is set to true
19
- */
20
- referencePrice: ComputedRef<Schemas['CalculatedPrice']['referencePrice'] | undefined>;
21
- /**
22
- * determines if `price` contains the minimum tier price
23
- */
24
- displayFrom: ComputedRef<boolean>;
25
- /**
26
- * cheapest price value for a variant if exists
27
- */
28
- displayFromVariants: ComputedRef<number | false | undefined>;
29
- /**
30
- * array of TierPrice object
31
- */
32
- tierPrices: ComputedRef<TierPrice[]>;
33
- /**
34
- * determines whether a discount price is set
35
- */
36
- isListPrice: ComputedRef<boolean>;
37
- /**
38
- * price for products with regulation price
39
- */
40
- regulationPrice: ComputedRef<number | undefined>;
41
- };
42
- /**
43
- * The purpose of the `useProductPrice` function is to abstract the logic
44
- * to expose most useful helpers for price displaying.
45
- *
46
- * @public
47
- * @category Product
48
- */
49
- export declare function useProductPrice(product: Ref<Schemas['Product'] | undefined>): UseProductPriceReturn;
@@ -1,19 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { MaybeRef } from 'vue';
3
- import { OperationBody } from '../types/query';
4
- import { UndefinedInitialQueryOptions } from '@tanstack/vue-query';
5
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
6
- declare const readCustomProductDetailOperation = "readCustomProductDetail post /novu/headless/product/{seoUrl}";
7
- export declare function useProductQueryOptions<Operations extends operations>(seoUrl: MaybeRef<string>, body?: MaybeRef<OperationBody<Operations, typeof readCustomProductDetailOperation>>): UndefinedInitialQueryOptions<OperationProp<operations & Operations, "readCustomProductDetail post /novu/headless/product/{seoUrl}", "response">, Error, OperationProp<operations & Operations, "readCustomProductDetail post /novu/headless/product/{seoUrl}", "response">, readonly ["product", "detail", {
8
- readonly url: MaybeRef<string>;
9
- readonly body: unknown;
10
- }]> & {
11
- queryKey: readonly ["product", "detail", {
12
- readonly url: MaybeRef<string>;
13
- readonly body: unknown;
14
- }] & {
15
- [dataTagSymbol]: OperationProp<operations & Operations, "readCustomProductDetail post /novu/headless/product/{seoUrl}", "response">;
16
- [dataTagErrorSymbol]: Error;
17
- };
18
- };
19
- export {};
@@ -1,7 +0,0 @@
1
- import { operations } from '../../api-types/storeApiTypes.d.ts';
2
- import { QueryKey, UseQueryOptions } from '@tanstack/vue-query';
3
- import { OperationProp } from '@teamnovu/kit-shopware-api-client';
4
- export type OperationKey = keyof operations;
5
- export type OperationBody<Operations extends operations, K extends OperationKey> = OperationProp<Operations, K, 'body'>;
6
- export type OperationResponse<Operations extends operations, K extends OperationKey> = OperationProp<Operations, K, 'response'>;
7
- export type Options<Operations extends operations, K extends OperationKey, QK extends QueryKey = QueryKey> = UseQueryOptions<OperationResponse<Operations, K>, Error, OperationResponse<Operations, K>, OperationResponse<Operations, K>, QK>;
@@ -1,48 +0,0 @@
1
- import { operations } from '#store-types'
2
- import { MutationOptions, useMutation, useQueryClient } from '@tanstack/vue-query'
3
- import { useShopwareQueryClient } from '../inject'
4
- import { cartKeys } from '../keys'
5
- import type { OperationBody, OperationKey, OperationResponse } from '../types/query'
6
-
7
- const addCartItemOperation = 'addLineItem post /checkout/cart/line-item' satisfies OperationKey
8
-
9
- type LineItem<Operations extends operations> = OperationBody<
10
- Operations,
11
- typeof addCartItemOperation
12
- >['items'][number]
13
-
14
- type LineItemPayload<Operations extends operations> =
15
- Partial<Omit<LineItem<Operations>, 'id' | 'quantity' | 'type'>> &
16
- Required<Pick<LineItem<Operations>, 'id' | 'quantity' | 'type'>>
17
-
18
- type Body<Operations extends operations> = Omit<
19
- OperationBody<Operations, typeof addCartItemOperation>,
20
- 'items'
21
- > & {
22
- items: LineItemPayload<Operations>[]
23
- }
24
-
25
- export function useCartAddItemMutation<Operations extends operations>(
26
- mutationOptions: MutationOptions<
27
- OperationResponse<Operations, typeof addCartItemOperation>,
28
- unknown,
29
- Body<Operations>
30
- >,
31
- ) {
32
- const client = useShopwareQueryClient<Operations>()
33
- const queryClient = useQueryClient()
34
-
35
- return useMutation({
36
- ...mutationOptions,
37
- mutationFn: async (body: Body<Operations>) => {
38
- return client.query(addCartItemOperation, {
39
- body: body as OperationBody<Operations, typeof addCartItemOperation>,
40
- })
41
- },
42
- onSuccess: (newCart, variables, context) => {
43
- queryClient.setQueryData(cartKeys.get(), newCart)
44
- // queryClient.invalidateQueries({ queryKey: cartKeys.get() })
45
- mutationOptions.onSuccess?.(newCart, variables, context)
46
- },
47
- })
48
- }
@@ -1,19 +0,0 @@
1
- import { operations } from '#store-types'
2
- import { queryOptions } from '@tanstack/vue-query'
3
- import { useShopwareQueryClient } from '../inject'
4
- import { cartKeys } from '../keys'
5
- import type { OperationKey } from '../types/query'
6
-
7
- const readCartOperation = 'readCart get /checkout/cart' satisfies OperationKey
8
-
9
- export function useCartQueryOptions<Operations extends operations>() {
10
- const client = useShopwareQueryClient<Operations>()
11
- const queryKey = cartKeys.get()
12
-
13
- return queryOptions({
14
- queryKey,
15
- queryFn: async () => {
16
- return client.query(readCartOperation)
17
- },
18
- })
19
- }
@@ -1,32 +0,0 @@
1
- import { operations } from '#store-types'
2
- import { MutationOptions, useMutation, useQueryClient } from '@tanstack/vue-query'
3
- import { useShopwareQueryClient } from '../inject'
4
- import { cartKeys } from '../keys'
5
- import type { OperationBody, OperationKey, OperationResponse } from '../types/query'
6
-
7
- const removeCartItemOperation = 'removeLineItem post /checkout/cart/line-item/delete' satisfies OperationKey
8
-
9
- export function useCartRemoveItemMutation<Operations extends operations>(
10
- mutationOptions?: MutationOptions<
11
- OperationResponse<Operations, typeof removeCartItemOperation>,
12
- unknown,
13
- OperationBody<Operations, typeof removeCartItemOperation>
14
- >,
15
- ) {
16
- const client = useShopwareQueryClient<Operations>()
17
- const queryClient = useQueryClient()
18
-
19
- return useMutation({
20
- ...mutationOptions,
21
- mutationFn: async (body: OperationBody<Operations, typeof removeCartItemOperation>) => {
22
- return client.query(removeCartItemOperation, {
23
- body: body as OperationBody<Operations, typeof removeCartItemOperation>,
24
- })
25
- },
26
- onSuccess: (newCart, variables, context) => {
27
- queryClient.setQueryData(cartKeys.get(), newCart)
28
- // queryClient.invalidateQueries({ queryKey: cartKeys.get() })
29
- mutationOptions?.onSuccess?.(newCart, variables, context)
30
- },
31
- })
32
- }
@@ -1,48 +0,0 @@
1
- import { operations } from '#store-types'
2
- import { MutationOptions, useMutation, useQueryClient } from '@tanstack/vue-query'
3
- import { useShopwareQueryClient } from '../inject'
4
- import { cartKeys } from '../keys'
5
- import type { OperationBody, OperationKey, OperationResponse } from '../types/query'
6
-
7
- const updateCartItemOperation = 'updateLineItem patch /checkout/cart/line-item' satisfies OperationKey
8
-
9
- type LineItem<Operations extends operations> = OperationBody<
10
- Operations,
11
- typeof updateCartItemOperation
12
- >['items'][number]
13
-
14
- type LineItemPayload<Operations extends operations> =
15
- Partial<Omit<LineItem<Operations>, 'id' | 'quantity' | 'type'>> &
16
- Required<Pick<LineItem<Operations>, 'id' | 'quantity' | 'type'>>
17
-
18
- type Body<Operations extends operations> = Omit<
19
- OperationBody<Operations, typeof updateCartItemOperation>,
20
- 'items'
21
- > & {
22
- items: LineItemPayload<Operations>[]
23
- }
24
-
25
- export function useCartUpdateItemMutation<Operations extends operations>(
26
- mutationOptions?: MutationOptions<
27
- OperationResponse<Operations, typeof updateCartItemOperation>,
28
- unknown,
29
- Body<Operations>
30
- >,
31
- ) {
32
- const client = useShopwareQueryClient<Operations>()
33
- const queryClient = useQueryClient()
34
-
35
- return useMutation({
36
- ...mutationOptions,
37
- mutationFn: async (body: Body<Operations>) => {
38
- return client.query(updateCartItemOperation, {
39
- body: body as OperationBody<Operations, typeof updateCartItemOperation>,
40
- })
41
- },
42
- onSuccess: (newCart, variables, context) => {
43
- queryClient.setQueryData(cartKeys.get(), newCart)
44
- // queryClient.invalidateQueries({ queryKey: cartKeys.get() })
45
- mutationOptions?.onSuccess?.(newCart, variables, context)
46
- },
47
- })
48
- }
@@ -1,16 +0,0 @@
1
- import type { operations } from '#store-types'
2
- import { queryOptions } from '@tanstack/vue-query'
3
- import { useShopwareQueryClient } from '../inject'
4
- import { contextKeys } from '../keys'
5
- import type { OperationKey } from '../types/query'
6
-
7
- const readContextOperation = 'readContext get /context' satisfies OperationKey
8
-
9
- export function useContextOptions<Operations extends operations>() {
10
- const client = useShopwareQueryClient<Operations>()
11
-
12
- return queryOptions({
13
- queryKey: contextKeys.all(),
14
- queryFn: () => client.query(readContextOperation),
15
- })
16
- }
@@ -1,16 +0,0 @@
1
- import type { operations } from '#store-types'
2
- import { useMutation } from '@tanstack/vue-query'
3
- import { useShopwareQueryClient } from '../inject'
4
- import type { OperationKey } from '../types/query'
5
-
6
- const updateContextOperation = 'updateContext patch /context' satisfies OperationKey
7
-
8
- export function useContextUpdate<Operations extends operations>() {
9
- const client = useShopwareQueryClient<Operations>()
10
-
11
- return useMutation({
12
- mutationFn: async () => {
13
- return client.query(updateContextOperation)
14
- },
15
- })
16
- }
@@ -1,25 +0,0 @@
1
- import type { operations } from '#store-types'
2
- import { queryOptions } from '@tanstack/vue-query'
3
- import type { MaybeRef } from 'vue'
4
- import { unref } from 'vue'
5
- import { useShopwareQueryClient } from '../inject'
6
- import { categoryKeys } from '../keys'
7
- import type { OperationBody, OperationKey } from '../types/query'
8
-
9
- const readCategoryListOperation = 'readCategoryList post /category' satisfies OperationKey
10
-
11
- export function useCategoryQueryOptions<Operations extends operations>(
12
- body?: MaybeRef<OperationBody<Operations, typeof readCategoryListOperation>>,
13
- ) {
14
- const client = useShopwareQueryClient<Operations>()
15
- const queryKey = categoryKeys.list(body)
16
-
17
- return queryOptions({
18
- queryKey,
19
- queryFn: async () => {
20
- return client.query(readCategoryListOperation, {
21
- body: unref(body),
22
- })
23
- },
24
- })
25
- }
@@ -1,24 +0,0 @@
1
- import { useQuery, VueQueryPlugin } from '@tanstack/vue-query'
2
- import { ShopwareClient } from '@teamnovu/kit-shopware-api-client'
3
- import { createApp } from 'vue'
4
- import { shopwareClientKey } from '../inject'
5
- import { useProductListingQueryOptions } from './useProductListingQueryOptions'
6
-
7
- test('useProducts receives products', async () => {
8
- const app = createApp({ template: '' })
9
-
10
- app.provide(shopwareClientKey, new ShopwareClient({
11
- apiKey: import.meta.env.VITE_SHOPWARE_ACCESS_KEY,
12
- baseURL: import.meta.env.VITE_SHOPWARE_URL,
13
- }))
14
-
15
- app.use(VueQueryPlugin)
16
-
17
- await app.runWithContext(async () => {
18
- const { data, suspense } = useQuery(useProductListingQueryOptions('/Food/Bakery-products/'))
19
-
20
- await suspense()
21
-
22
- expect(data).toBeTruthy()
23
- })
24
- })
@@ -1,29 +0,0 @@
1
- import type { operations } from '#store-types'
2
- import { queryOptions } from '@tanstack/vue-query'
3
- import type { MaybeRef } from 'vue'
4
- import { unref } from 'vue'
5
- import { useShopwareQueryClient } from '../inject'
6
- import { productKeys } from '../keys'
7
- import type { OperationBody, OperationKey } from '../types/query'
8
- import { relativizeSeoUrl } from '../util/url'
9
-
10
- // eslint-disable-next-line @stylistic/max-len
11
- const readListingOperation = 'readCompactProductListing post /novu/headless/product-listing/{seoUrl}' satisfies OperationKey
12
-
13
- export function useProductListingQueryOptions<Operations extends operations>(
14
- seoUrl: MaybeRef<string>,
15
- body?: MaybeRef<OperationBody<Operations, typeof readListingOperation>>,
16
- ) {
17
- const client = useShopwareQueryClient<Operations>()
18
- const queryKey = productKeys.list(seoUrl, body)
19
-
20
- return queryOptions({
21
- queryKey,
22
- queryFn: async () => {
23
- return client.query(readListingOperation, {
24
- params: { seoUrl: relativizeSeoUrl(unref(seoUrl)) },
25
- body: unref(body),
26
- })
27
- },
28
- })
29
- }
@@ -1,29 +0,0 @@
1
- import type { operations } from '#store-types'
2
- import { queryOptions } from '@tanstack/vue-query'
3
- import type { MaybeRef } from 'vue'
4
- import { unref } from 'vue'
5
- import { useShopwareQueryClient } from '../inject'
6
- import { productKeys } from '../keys'
7
- import type { OperationBody, OperationKey } from '../types/query'
8
- import { relativizeSeoUrl } from '../util/url'
9
-
10
- // eslint-disable-next-line @stylistic/max-len
11
- const readCustomProductDetailOperation = 'readCustomProductDetail post /novu/headless/product/{seoUrl}' satisfies OperationKey
12
-
13
- export function useProductQueryOptions<Operations extends operations>(
14
- seoUrl: MaybeRef<string>,
15
- body?: MaybeRef<OperationBody<Operations, typeof readCustomProductDetailOperation>>,
16
- ) {
17
- const client = useShopwareQueryClient<Operations>()
18
- const queryKey = productKeys.detail(seoUrl, body)
19
-
20
- return queryOptions({
21
- queryKey,
22
- queryFn: async () => {
23
- return client.query(readCustomProductDetailOperation, {
24
- params: { seoUrl: relativizeSeoUrl(unref(seoUrl)) },
25
- body: unref(body),
26
- })
27
- },
28
- })
29
- }
@@ -1,18 +0,0 @@
1
- import type { operations } from '#store-types'
2
- import type { QueryKey, UseQueryOptions } from '@tanstack/vue-query'
3
- import type { OperationProp } from '@teamnovu/kit-shopware-api-client'
4
-
5
- export type OperationKey = keyof operations
6
- export type OperationBody<Operations extends operations, K extends OperationKey> =
7
- OperationProp<Operations, K, 'body'>
8
- export type OperationResponse<Operations extends operations, K extends OperationKey> =
9
- OperationProp<Operations, K, 'response'>
10
-
11
- export type Options<Operations extends operations, K extends OperationKey, QK extends QueryKey = QueryKey> =
12
- UseQueryOptions<
13
- OperationResponse<Operations, K>,
14
- Error,
15
- OperationResponse<Operations, K>,
16
- OperationResponse<Operations, K>,
17
- QK
18
- >
File without changes