@teamnovu/kit-shopware-composables 0.0.2 → 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.
- package/api-types/storeApiSchema.localhost.http +1 -1
- package/dist/helpers/checkout/index.d.ts +5 -0
- package/dist/helpers/checkout/useAddresses.d.ts +210 -0
- package/dist/helpers/checkout/useOrderDetails.d.ts +186 -0
- package/dist/helpers/checkout/useOrderPayment.d.ts +73 -0
- package/dist/helpers/checkout/usePaymentMethods.d.ts +155 -0
- package/dist/helpers/checkout/useShippingMethods.d.ts +173 -0
- package/dist/helpers/general/index.d.ts +2 -0
- package/dist/{usePagination.d.ts → helpers/general/usePagination.d.ts} +1 -1
- package/dist/{general → helpers/general}/useSeoUrl.d.ts +1 -1
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/product/index.d.ts +2 -0
- package/dist/helpers/product/useProductPrice.d.ts +61 -0
- package/dist/{products → helpers/product}/useProductVariantForOptions.d.ts +1 -1
- package/dist/helpers/user/index.d.ts +2 -0
- package/dist/helpers/user/useIsLoggedIn.d.ts +2 -0
- package/dist/helpers/user/useUser.d.ts +167 -0
- package/dist/index.d.ts +3 -188
- package/dist/index.mjs +871 -185
- package/dist/inject.d.ts +2 -2
- package/dist/keys.d.ts +35 -0
- package/dist/query/address/index.d.ts +3 -0
- package/dist/query/address/useCreateCustomerAddressMutation.d.ts +166 -0
- package/dist/query/address/useDeleteCustomerAddressMutation.d.ts +5 -0
- package/dist/query/address/useListAddressQuery.d.ts +48 -0
- package/dist/query/cart/index.d.ts +4 -0
- package/dist/query/cart/useAddLineItemMutation.d.ts +131 -0
- package/dist/query/cart/useReadCartQuery.d.ts +108 -0
- package/dist/query/cart/useRemoveLineItemMutation.d.ts +136 -0
- package/dist/query/cart/useUpdateLineItemMutation.d.ts +131 -0
- package/dist/query/checkout/index.d.ts +2 -0
- package/dist/query/checkout/useCheckout.d.ts +1 -0
- package/dist/query/checkout/useCreateOrderMutation.d.ts +281 -0
- package/dist/query/context/index.d.ts +2 -0
- package/dist/query/context/useReadContextQuery.d.ts +153 -0
- package/dist/query/context/useUpdateContextMutation.d.ts +60 -0
- package/dist/query/customer/index.d.ts +6 -0
- package/dist/query/customer/useChangeEmailMutation.d.ts +15 -0
- package/dist/query/customer/useChangeProfileMutation.d.ts +15 -0
- package/dist/query/customer/useLoginCustomerMutation.d.ts +30 -0
- package/dist/query/customer/useLogoutCustomerMutation.d.ts +15 -0
- package/dist/query/customer/useReadCustomerQuery.d.ts +220 -0
- package/dist/query/customer/useRegisterCustomerMutation.d.ts +266 -0
- package/dist/query/index.d.ts +10 -0
- package/dist/query/order/index.d.ts +1 -0
- package/dist/query/order/useReadOrderQuery.d.ts +44 -0
- package/dist/query/payment/index.d.ts +3 -0
- package/dist/query/payment/useHandlePaymentMutation.d.ts +15 -0
- package/dist/query/payment/useOrderSetPaymentMutation.d.ts +15 -0
- package/dist/query/payment/useReadPaymentMethodQuery.d.ts +31 -0
- package/dist/query/products/index.d.ts +3 -0
- package/dist/query/products/useReadCategoryListQuery.d.ts +48 -0
- package/dist/query/products/useReadCompactProductListingQuery.d.ts +35 -0
- package/dist/query/products/useReadCustomProductDetailQuery.d.ts +67 -0
- package/dist/query/shipping/index.d.ts +1 -0
- package/dist/query/shipping/useReadShippingMethodQuery.d.ts +55 -0
- package/dist/query/types/index.d.ts +2 -0
- package/dist/query/types/operations.d.ts +5 -0
- package/dist/query/types/query.d.ts +17 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/unrefOptions.d.ts +4 -0
- package/dist/util/useOptimistic.d.ts +12 -0
- package/docs/index.md +457 -0
- package/docs/info.json +3 -0
- package/package.json +6 -2
- package/src/helpers/checkout/index.ts +5 -0
- package/src/helpers/checkout/useAddresses.ts +57 -0
- package/src/helpers/checkout/useOrderDetails.ts +94 -0
- package/src/helpers/checkout/useOrderPayment.ts +28 -0
- package/src/helpers/checkout/usePaymentMethods.ts +35 -0
- package/src/helpers/checkout/useShippingMethods.ts +35 -0
- package/src/helpers/general/index.ts +2 -0
- package/src/helpers/index.ts +4 -0
- package/src/helpers/product/index.ts +2 -0
- package/src/{products → helpers/product}/useProductPrice.ts +4 -45
- package/src/{products → helpers/product}/useProductVariantForOptions.ts +8 -2
- package/src/helpers/user/index.ts +2 -0
- package/src/helpers/user/useIsLoggedIn.ts +10 -0
- package/src/helpers/user/useUser.ts +53 -0
- package/src/index.ts +4 -21
- package/src/inject.ts +3 -3
- package/src/keys.ts +61 -0
- package/src/query/address/index.ts +3 -0
- package/src/query/address/useCreateCustomerAddressMutation.ts +32 -0
- package/src/query/address/useDeleteCustomerAddressMutation.ts +32 -0
- package/src/query/address/useListAddressQuery.ts +29 -0
- package/src/query/cart/index.ts +4 -0
- package/src/query/cart/useAddLineItemMutation.ts +45 -0
- package/src/query/cart/useReadCartQuery.ts +28 -0
- package/src/query/cart/useRemoveLineItemMutation.ts +32 -0
- package/src/query/cart/useUpdateLineItemMutation.ts +45 -0
- package/src/query/checkout/index.ts +2 -0
- package/src/query/checkout/useCheckout.ts +2 -0
- package/src/query/checkout/useCreateOrderMutation.ts +35 -0
- package/src/query/context/index.ts +2 -0
- package/src/query/context/useReadContextQuery.ts +19 -0
- package/src/query/context/useUpdateContextMutation.ts +36 -0
- package/src/query/customer/index.ts +6 -0
- package/src/query/customer/useChangeEmailMutation.ts +32 -0
- package/src/query/customer/useChangeProfileMutation.ts +32 -0
- package/src/query/customer/useLoginCustomerMutation.ts +42 -0
- package/src/query/customer/useLogoutCustomerMutation.ts +32 -0
- package/src/query/customer/useReadCustomerQuery.ts +27 -0
- package/src/query/customer/useRegisterCustomerMutation.ts +32 -0
- package/src/query/index.ts +10 -0
- package/src/query/order/index.ts +1 -0
- package/src/query/order/useReadOrderQuery.ts +33 -0
- package/src/query/payment/index.ts +3 -0
- package/src/query/payment/useHandlePaymentMutation.ts +27 -0
- package/src/query/payment/useOrderSetPaymentMutation.ts +32 -0
- package/src/query/payment/useReadPaymentMethodQuery.ts +30 -0
- package/src/query/products/index.ts +3 -0
- package/src/query/products/useReadCategoryListQuery.ts +28 -0
- package/src/query/products/useReadCompactProductListingQuery.ts +41 -0
- package/src/query/products/useReadCustomProductDetailQuery.ts +41 -0
- package/src/query/shipping/index.ts +1 -0
- package/src/query/shipping/useReadShippingMethodQuery.ts +29 -0
- package/src/query/types/index.ts +2 -0
- package/src/query/types/operations.ts +6 -0
- package/src/query/types/query.ts +39 -0
- package/src/util/index.ts +3 -0
- package/src/util/unrefOptions.ts +19 -0
- package/src/util/useOptimistic.ts +49 -0
- package/tsconfig.json +5 -2
- package/dist/context/useContextOptions.d.ts +0 -9
- package/dist/context/useContextUpdate.d.ts +0 -4
- package/dist/products/useCategoryQueryOptions.d.ts +0 -17
- package/dist/products/useProductListingQueryOptions.d.ts +0 -19
- package/dist/products/useProductListingQueryOptions.test.d.ts +0 -1
- package/dist/products/useProductPrice.d.ts +0 -48
- package/dist/products/useProductQueryOptions.d.ts +0 -19
- package/dist/types/query.d.ts +0 -7
- package/eslint.config.mjs +0 -84
- package/src/context/useContextOptions.ts +0 -16
- package/src/context/useContextUpdate.ts +0 -16
- package/src/products/useCategoryQueryOptions.ts +0 -25
- package/src/products/useProductListingQueryOptions.test.ts +0 -24
- package/src/products/useProductListingQueryOptions.ts +0 -28
- package/src/products/useProductQueryOptions.ts +0 -28
- package/src/types/query.ts +0 -18
- /package/src/{usePagination.ts → helpers/general/usePagination.ts} +0 -0
- /package/src/{general → helpers/general}/useSeoUrl.ts +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { MutationOptions, QueryKey, UseMutationOptions, useQueryClient } from '@tanstack/vue-query'
|
|
2
|
+
import { unref } from 'vue'
|
|
3
|
+
|
|
4
|
+
// https://tanstack.com/query/latest/docs/framework/vue/guides/optimistic-updates#via-the-cache
|
|
5
|
+
export function useOptimistic<CacheValue, UpdateValue>(
|
|
6
|
+
queryKey: QueryKey,
|
|
7
|
+
updateFn: (newValue: UpdateValue, oldValue: CacheValue) => CacheValue,
|
|
8
|
+
options?: UseMutationOptions<unknown, unknown, UpdateValue, unknown>,
|
|
9
|
+
) {
|
|
10
|
+
const queryClient = useQueryClient()
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
onMutate: async (newValue: UpdateValue) => {
|
|
14
|
+
await queryClient.cancelQueries({ queryKey: queryKey })
|
|
15
|
+
|
|
16
|
+
const previousValue = queryClient.getQueryData(queryKey) as CacheValue | undefined
|
|
17
|
+
|
|
18
|
+
queryClient.setQueryData(queryKey, (oldValue: CacheValue) => updateFn(newValue, oldValue))
|
|
19
|
+
|
|
20
|
+
if (options) {
|
|
21
|
+
const opts = unref(options)
|
|
22
|
+
const onMutate = unref(opts.onMutate)
|
|
23
|
+
onMutate?.(newValue)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { previousValue }
|
|
27
|
+
},
|
|
28
|
+
onError: (err, newValue: UpdateValue, context) => {
|
|
29
|
+
if (context) {
|
|
30
|
+
queryClient.setQueryData(queryKey, context.previousValue)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (options) {
|
|
34
|
+
const opts = unref(options)
|
|
35
|
+
const onError = unref(opts.onError)
|
|
36
|
+
onError?.(err, newValue, context)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
onSettled: (...args) => {
|
|
40
|
+
queryClient.invalidateQueries({ queryKey })
|
|
41
|
+
|
|
42
|
+
if (options) {
|
|
43
|
+
const opts = unref(options)
|
|
44
|
+
const onSettled = unref(opts.onSettled)
|
|
45
|
+
onSettled?.(...args)
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
} satisfies MutationOptions<unknown, unknown, UpdateValue, { previousValue?: CacheValue }>
|
|
49
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -8,16 +8,19 @@
|
|
|
8
8
|
"vitest/globals"
|
|
9
9
|
],
|
|
10
10
|
"paths": {
|
|
11
|
+
"#types": [
|
|
12
|
+
"./src/types.d.ts"
|
|
13
|
+
],
|
|
11
14
|
"#store-types": [
|
|
12
15
|
"./api-types/storeApiTypes.d.ts"
|
|
13
16
|
]
|
|
14
17
|
},
|
|
15
18
|
"typeRoots": [
|
|
16
19
|
"./node_modules"
|
|
17
|
-
]
|
|
20
|
+
]
|
|
18
21
|
},
|
|
19
22
|
"include": [
|
|
20
23
|
"src/**/*",
|
|
21
24
|
"../components/src/injects"
|
|
22
25
|
]
|
|
23
|
-
}
|
|
26
|
+
}
|
|
@@ -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,48 +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 to expose most useful helpers for price displaying.
|
|
44
|
-
*
|
|
45
|
-
* @public
|
|
46
|
-
* @category Product
|
|
47
|
-
*/
|
|
48
|
-
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 {};
|
package/dist/types/query.d.ts
DELETED
|
@@ -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>;
|
package/eslint.config.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import js from '@eslint/js'
|
|
2
|
-
import pluginStylistic from '@stylistic/eslint-plugin'
|
|
3
|
-
import tseslint from 'typescript-eslint'
|
|
4
|
-
|
|
5
|
-
export default tseslint.config(
|
|
6
|
-
js.configs.recommended,
|
|
7
|
-
tseslint.configs.recommended,
|
|
8
|
-
pluginStylistic.configs['recommended'],
|
|
9
|
-
{
|
|
10
|
-
rules: {
|
|
11
|
-
// stylistic
|
|
12
|
-
// ********************
|
|
13
|
-
'@stylistic/newline-per-chained-call': [
|
|
14
|
-
'error',
|
|
15
|
-
{ ignoreChainWithDepth: 2 },
|
|
16
|
-
],
|
|
17
|
-
'@stylistic/nonblock-statement-body-position': 'error',
|
|
18
|
-
'@stylistic/one-var-declaration-per-line': 'error',
|
|
19
|
-
'@stylistic/operator-linebreak': [
|
|
20
|
-
'error',
|
|
21
|
-
'before',
|
|
22
|
-
{ overrides: { '=': 'none' } },
|
|
23
|
-
],
|
|
24
|
-
'@stylistic/function-paren-newline': ['error', 'multiline-arguments'],
|
|
25
|
-
'@stylistic/dot-location': ['error', 'property'],
|
|
26
|
-
'@stylistic/no-mixed-operators': ['error', { allowSamePrecedence: true }],
|
|
27
|
-
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
28
|
-
'@stylistic/array-bracket-newline': ['error', { multiline: true }],
|
|
29
|
-
'@stylistic/array-element-newline': [
|
|
30
|
-
'error',
|
|
31
|
-
{
|
|
32
|
-
multiline: true,
|
|
33
|
-
consistent: true,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
'@stylistic/max-len': [
|
|
37
|
-
'warn',
|
|
38
|
-
{
|
|
39
|
-
code: 150,
|
|
40
|
-
tabWidth: 2,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
'@stylistic/object-curly-newline': [
|
|
44
|
-
'error',
|
|
45
|
-
{
|
|
46
|
-
multiline: true,
|
|
47
|
-
consistent: true,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
'@stylistic/object-property-newline': [
|
|
51
|
-
'error',
|
|
52
|
-
{ allowAllPropertiesOnSameLine: false },
|
|
53
|
-
],
|
|
54
|
-
|
|
55
|
-
// common
|
|
56
|
-
// ********************
|
|
57
|
-
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
58
|
-
'prefer-destructuring': [
|
|
59
|
-
'error',
|
|
60
|
-
{
|
|
61
|
-
array: false,
|
|
62
|
-
object: true,
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
'no-unused-vars': 'off',
|
|
66
|
-
'eqeqeq': ['error', 'smart'],
|
|
67
|
-
'no-undef': 'off', // done by typescript
|
|
68
|
-
'@typescript-eslint/consistent-type-imports': 'error',
|
|
69
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
70
|
-
'@typescript-eslint/no-unused-vars': [
|
|
71
|
-
'error',
|
|
72
|
-
{
|
|
73
|
-
args: 'all',
|
|
74
|
-
argsIgnorePattern: '^_',
|
|
75
|
-
caughtErrors: 'all',
|
|
76
|
-
caughtErrorsIgnorePattern: '^_',
|
|
77
|
-
destructuredArrayIgnorePattern: '^_',
|
|
78
|
-
varsIgnorePattern: '^_',
|
|
79
|
-
ignoreRestSiblings: true,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
)
|
|
@@ -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,28 +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
|
-
const readListingOperation = 'readCompactProductListing post /novu/headless/product-listing/{seoUrl}' satisfies OperationKey
|
|
11
|
-
|
|
12
|
-
export function useProductListingQueryOptions<Operations extends operations>(
|
|
13
|
-
seoUrl: MaybeRef<string>,
|
|
14
|
-
body?: MaybeRef<OperationBody<Operations, typeof readListingOperation>>,
|
|
15
|
-
) {
|
|
16
|
-
const client = useShopwareQueryClient<Operations>()
|
|
17
|
-
const queryKey = productKeys.list(seoUrl, body)
|
|
18
|
-
|
|
19
|
-
return queryOptions({
|
|
20
|
-
queryKey,
|
|
21
|
-
queryFn: async () => {
|
|
22
|
-
return client.query(readListingOperation, {
|
|
23
|
-
params: { seoUrl: relativizeSeoUrl(unref(seoUrl)) },
|
|
24
|
-
body: unref(body),
|
|
25
|
-
})
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
}
|
|
@@ -1,28 +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
|
-
const readCustomProductDetailOperation = 'readCustomProductDetail post /novu/headless/product/{seoUrl}' satisfies OperationKey
|
|
11
|
-
|
|
12
|
-
export function useProductQueryOptions<Operations extends operations>(
|
|
13
|
-
seoUrl: MaybeRef<string>,
|
|
14
|
-
body?: MaybeRef<OperationBody<Operations, typeof readCustomProductDetailOperation>>,
|
|
15
|
-
) {
|
|
16
|
-
const client = useShopwareQueryClient<Operations>()
|
|
17
|
-
const queryKey = productKeys.detail(seoUrl, body)
|
|
18
|
-
|
|
19
|
-
return queryOptions({
|
|
20
|
-
queryKey,
|
|
21
|
-
queryFn: async () => {
|
|
22
|
-
return client.query(readCustomProductDetailOperation, {
|
|
23
|
-
params: { seoUrl: relativizeSeoUrl(unref(seoUrl)) },
|
|
24
|
-
body: unref(body),
|
|
25
|
-
})
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
}
|
package/src/types/query.ts
DELETED
|
@@ -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
|
|
File without changes
|