@scayle/storefront-nuxt 8.11.0 → 8.11.1
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/CHANGELOG.md +8 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/core/useAvailableShops.d.ts +10 -0
- package/dist/runtime/composables/core/useCurrentShop.d.ts +10 -0
- package/dist/runtime/composables/core/useFormatHelpers.d.ts +57 -6
- package/dist/runtime/composables/core/useIDP.d.ts +17 -0
- package/dist/runtime/composables/core/useLog.d.ts +12 -0
- package/dist/runtime/composables/core/useRpc.d.ts +76 -24
- package/dist/runtime/composables/core/useRpcCall.d.ts +40 -0
- package/dist/runtime/composables/core/useSession.d.ts +10 -0
- package/dist/runtime/composables/core/useUser.d.ts +24 -0
- package/dist/runtime/composables/storefront/useBasket.d.ts +24 -0
- package/dist/runtime/composables/storefront/useBrand.d.ts +21 -0
- package/dist/runtime/composables/storefront/useBrands.d.ts +21 -0
- package/dist/runtime/composables/storefront/useCategories.d.ts +28 -0
- package/dist/runtime/composables/storefront/useCategoryById.d.ts +21 -0
- package/dist/runtime/composables/storefront/useCategoryByPath.d.ts +21 -0
- package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +24 -0
- package/dist/runtime/composables/storefront/useFilters.d.ts +21 -0
- package/dist/runtime/composables/storefront/useNavigationTree.d.ts +42 -0
- package/dist/runtime/composables/storefront/useNavigationTrees.d.ts +21 -0
- package/dist/runtime/composables/storefront/useOrder.d.ts +23 -0
- package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +21 -0
- package/dist/runtime/composables/storefront/useProduct.d.ts +21 -0
- package/dist/runtime/composables/storefront/useProducts.d.ts +21 -0
- package/dist/runtime/composables/storefront/useProductsByIds.d.ts +21 -0
- package/dist/runtime/composables/storefront/useProductsByReferenceKeys.d.ts +21 -0
- package/dist/runtime/composables/storefront/useProductsCount.d.ts +19 -0
- package/dist/runtime/composables/storefront/usePromotions.d.ts +21 -0
- package/dist/runtime/composables/storefront/usePromotionsByIds.d.ts +21 -0
- package/dist/runtime/composables/storefront/useShopConfiguration.d.ts +21 -0
- package/dist/runtime/composables/storefront/useStorefrontSearch.d.ts +11 -1
- package/dist/runtime/composables/storefront/useUserAddresses.d.ts +21 -0
- package/dist/runtime/composables/storefront/useVariant.d.ts +21 -0
- package/dist/runtime/composables/storefront/useWishlist.d.ts +29 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { PublicShopConfig } from '../../../module.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provides a reactive list of available shops.
|
|
4
|
+
*
|
|
5
|
+
* This composable uses [`useState`](https://nuxt.com/docs/api/composables/use-state)
|
|
6
|
+
* to create a reactive state variable that holds an array of `PublicShopConfig` objects.
|
|
7
|
+
* The initial value of the state is an empty array. This state can be used to
|
|
8
|
+
* dynamically display data of the available shops within the application.
|
|
9
|
+
*
|
|
10
|
+
* @returns A reactive `ref` containing an array of available shop configurations.
|
|
11
|
+
*/
|
|
2
12
|
export declare function useAvailableShops(): import("vue").Ref<PublicShopConfig[], PublicShopConfig[]>;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
2
|
import type { PublicShopConfig } from '../../../module.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides a reactive reference to the current shop configuration.
|
|
5
|
+
*
|
|
6
|
+
* This composable retrieves the current shop configuration from the Nuxt app instance.
|
|
7
|
+
* It then uses [`useState`](https://nuxt.com/docs/api/composables/use-state) to
|
|
8
|
+
* create a reactive reference to this configuration, allowing components
|
|
9
|
+
* to reactively update when the current shop changes.
|
|
10
|
+
*
|
|
11
|
+
* @returns A reactive `ref` to the current shop's configuration.
|
|
12
|
+
*/
|
|
3
13
|
export declare const useCurrentShop: () => Ref<PublicShopConfig>;
|
|
@@ -1,20 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Representation of options for formatting currencies.
|
|
3
|
+
*
|
|
4
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
|
|
5
|
+
*/
|
|
1
6
|
type FormatCurrencyOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The locale to use for formatting.
|
|
9
|
+
*/
|
|
2
10
|
locale?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The number of fraction digits to use for the currency.
|
|
13
|
+
*/
|
|
3
14
|
currencyFractionDigits?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The style ('currency' or 'decimal') to use for formatting. Defaults to 'currency'.
|
|
17
|
+
*/
|
|
4
18
|
style?: 'currency';
|
|
19
|
+
/**
|
|
20
|
+
* The currency code (e.g., 'EUR', 'USD') to use for formatting.
|
|
21
|
+
*/
|
|
5
22
|
currency: string;
|
|
6
23
|
} | {
|
|
24
|
+
/**
|
|
25
|
+
* The locale to use for formatting.
|
|
26
|
+
*/
|
|
7
27
|
locale?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The number of fraction digits to use for the currency.
|
|
30
|
+
*/
|
|
8
31
|
currencyFractionDigits?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The style to use for formatting.
|
|
34
|
+
*/
|
|
9
35
|
style: 'decimal';
|
|
10
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Representation of options for formatting percentages.
|
|
39
|
+
*
|
|
40
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
|
|
41
|
+
*/
|
|
42
|
+
type FormatPercentageOptions = {
|
|
43
|
+
/**
|
|
44
|
+
* The locale to use for formatting.
|
|
45
|
+
*/
|
|
46
|
+
locale?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The minimum number of fraction digits to use.
|
|
49
|
+
*/
|
|
50
|
+
minimumFractionDigits?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The maximum number of fraction digits to use.
|
|
53
|
+
*/
|
|
54
|
+
maximumFractionDigits?: number;
|
|
55
|
+
/**
|
|
56
|
+
* How to display the sign for the percentage.
|
|
57
|
+
*/
|
|
58
|
+
signDisplay?: Intl.NumberFormatOptions['signDisplay'];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Provides currency and percentage formatting helpers.
|
|
62
|
+
*
|
|
63
|
+
* It leverages the current shop's locale and currency settings.
|
|
64
|
+
*
|
|
65
|
+
* @returns An object containing the formatCurrency and formatPercentage functions.
|
|
66
|
+
*/
|
|
11
67
|
export declare function useFormatHelpers(): {
|
|
12
68
|
formatCurrency: (value: number, options?: FormatCurrencyOptions) => string;
|
|
13
|
-
formatPercentage: (value: number, options?:
|
|
14
|
-
locale?: string;
|
|
15
|
-
minimumFractionDigits?: number;
|
|
16
|
-
maximumFractionDigits?: number;
|
|
17
|
-
signDisplay?: Intl.NumberFormatOptions["signDisplay"];
|
|
18
|
-
}) => string;
|
|
69
|
+
formatPercentage: (value: number, options?: FormatPercentageOptions) => string;
|
|
19
70
|
};
|
|
20
71
|
export {};
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import type { MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
3
3
|
import { type UseRpcReturn } from '../core/useRpc.js';
|
|
4
|
+
/**
|
|
5
|
+
* The shape of the data returned by the `getExternalIdpRedirect` RPC call.
|
|
6
|
+
*/
|
|
4
7
|
type UseIDPBaseReturn = Pick<Awaited<UseRpcReturn<'getExternalIdpRedirect'>>, 'data' | 'error' | 'status' | 'refresh'>;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves an external IDP redirect URL.
|
|
10
|
+
*
|
|
11
|
+
* This composables uses the `useRpc` composable to call the `getExternalIdpRedirect` RPC method.
|
|
12
|
+
*
|
|
13
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/authentication#redirect-url
|
|
14
|
+
*
|
|
15
|
+
* @param params The parameters for the `getExternalIdpRedirect` RPC call.
|
|
16
|
+
* @param key A unique key for the RPC call. Used for caching and invalidation. Defaults to 'useIDP'.
|
|
17
|
+
|
|
18
|
+
* @returns An object containing the `data` returned from, any `error` encountered within,
|
|
19
|
+
the current `status` and a function to manually `refresh` the RPC call.
|
|
20
|
+
* It also acts as a promise that resolves to the same object.
|
|
21
|
+
*/
|
|
5
22
|
export declare function useIDP(params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>, key?: string): UseIDPBaseReturn & Promise<UseIDPBaseReturn>;
|
|
6
23
|
export {};
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import type { Log } from '@scayle/storefront-core';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves a logging instance.
|
|
4
|
+
*
|
|
5
|
+
* It allows for creating a namespaced logger using the provided `subSpace` argument.
|
|
6
|
+
* If a namespace is specified, the function will return a logger scoped to that subspace.
|
|
7
|
+
* Otherwise, it returns the root logger.
|
|
8
|
+
*
|
|
9
|
+
* @param subSpace The namespace to create the logger for.
|
|
10
|
+
*
|
|
11
|
+
* @returns The log instance, a namespace is specified, a logger scoped to that subspace.
|
|
12
|
+
* Otherwise, it returns the root logger.
|
|
13
|
+
*/
|
|
2
14
|
export declare function useLog(subSpace?: string): Log;
|
|
@@ -1,41 +1,93 @@
|
|
|
1
1
|
import type { RpcContext, RpcMethodName, RpcMethodParameters, RpcMethodReturnType } from '@scayle/storefront-core';
|
|
2
2
|
import { type AsyncDataOptions, useAsyncData } from 'nuxt/app';
|
|
3
3
|
import { type MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts keys from a type `T` as an array of strings.
|
|
6
|
+
*
|
|
7
|
+
* @template T The type from which to extract keys.
|
|
8
|
+
*/
|
|
4
9
|
export type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
|
|
5
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Normalized return type of a RPC method, excluding its `Response` object.
|
|
12
|
+
*
|
|
13
|
+
* @template N The RPC Method Name.
|
|
14
|
+
*/
|
|
6
15
|
export type NormalizedRpcResponse<N extends RpcMethodName> = Exclude<Awaited<RpcMethodReturnType<N>>, Response>;
|
|
16
|
+
/**
|
|
17
|
+
* Representation of options for the `useRpc` composable, extending `AsyncDataOptions`.
|
|
18
|
+
*
|
|
19
|
+
* @template N The RPC Method Name.
|
|
20
|
+
* @template DataT The data type. Defaults to `NormalizedRpcResponse<N>`.
|
|
21
|
+
* @template PickKeys The keys to pick from `DataT`. Defaults to all keys of `DataT`.
|
|
22
|
+
* @template DefaultT The default value type. Defaults to `null`.
|
|
23
|
+
* @template ResponseT The response type. Defaults to `NormalizedRpcResponse<N>`.
|
|
24
|
+
*/
|
|
7
25
|
export type UseRpcOptions<N extends RpcMethodName, DataT = NormalizedRpcResponse<N>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null, ResponseT = NormalizedRpcResponse<N>> = AsyncDataOptions<ResponseT, DataT, PickKeys, DefaultT>;
|
|
8
26
|
/**
|
|
9
|
-
*
|
|
27
|
+
* Return type of the `useRpc` composable, extending `ExtendedAsyncData`.
|
|
28
|
+
*
|
|
29
|
+
* @template N The RPC Method Name.
|
|
30
|
+
* @template DataT The data type. Defaults to `NormalizedRpcResponse<N>`.
|
|
31
|
+
* @template PickKeys The keys to pick from `DataT.` Defaults to all keys of `DataT`.
|
|
32
|
+
* @template DefaultT The default value type. Defaults to `null`.
|
|
33
|
+
* @template ResponseT The response type. Defaults to `NormalizedRpcResponse<N>`.
|
|
10
34
|
*/
|
|
11
35
|
export type UseRpcReturn<N extends RpcMethodName, DataT = NormalizedRpcResponse<N>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null, ResponseT = NormalizedRpcResponse<N>> = ExtendedAsyncData<ResponseT, unknown, DataT, PickKeys, DefaultT>;
|
|
12
36
|
export type Status = 'idle' | 'pending' | 'success' | 'error';
|
|
13
37
|
type AsyncData<ResT, ErrorT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null> = ReturnType<typeof useAsyncData<ResT, ErrorT, DataT, PickKeys, DefaultT>>;
|
|
14
38
|
type AwaitedAsyncData<ResT, ErrorT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null> = Awaited<AsyncData<ResT, ErrorT, DataT, PickKeys, DefaultT>>;
|
|
39
|
+
/**
|
|
40
|
+
* Extended `AsyncData` type, adding a promise to the result.
|
|
41
|
+
*
|
|
42
|
+
* @template ResT The response type.
|
|
43
|
+
* @template ErrorT The error type. Defaults to `unknown`.
|
|
44
|
+
* @template DataT The data type. Defaults to `ResT`.
|
|
45
|
+
* @template PickKeys The keys to pick from `DataT`. Defaults to all keys of `DataT`.
|
|
46
|
+
* @template DefaultT The default value type. Defaults to `null`.
|
|
47
|
+
*/
|
|
15
48
|
export type ExtendedAsyncData<ResT, ErrorT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null> = AwaitedAsyncData<ResT, ErrorT, DataT, PickKeys, DefaultT> & Promise<AwaitedAsyncData<ResT, ErrorT, DataT, PickKeys, DefaultT>>;
|
|
16
49
|
/**
|
|
17
|
-
* `useRpc` is a wrapper around `useAsyncData` for registered RPC methods
|
|
18
|
-
*
|
|
19
|
-
* This
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
50
|
+
* `useRpc` is a wrapper around `useAsyncData` for registered RPC methods.
|
|
51
|
+
*
|
|
52
|
+
* This composable provides a declarative approach to data fetching by wrapping
|
|
53
|
+
* `useAsyncData` for registered RPC methods. It handles the fetch state,
|
|
54
|
+
* automatically executes the RPC method, and returns the result or any errors.
|
|
55
|
+
* Many Storefront composables utilize `useRpc` as lightweight wrappers around provided RPC methods.
|
|
56
|
+
*
|
|
57
|
+
* The parameters for the RPC call can be passed as a raw value, a ref, or a function. If a reactive ref or function is provided,
|
|
58
|
+
* `useRpc` will automatically re-fetch the data when the parameters change.
|
|
59
|
+
*
|
|
60
|
+
* By default, `useRpc` utilizes a shared cache, so all instances called with the same key will share the same data. This behavior can be
|
|
61
|
+
* disabled globally via the `disableDefaultGetCachedDataOverride` option in the public runtime config, or individually per call using the `options` parameter.
|
|
62
|
+
*
|
|
63
|
+
* @see https://nuxt.com/docs/api/composables/use-async-data#params
|
|
64
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/rpc-methods#userpc
|
|
65
|
+
*
|
|
66
|
+
* @param method The name of the RPC method to call (e.g., 'useBrand).
|
|
67
|
+
* @param key A unique key for caching, persisting the data between server and client,
|
|
68
|
+
* and de-duplicating requests (e.g., 'use-brand').
|
|
69
|
+
* @param params The parameters for the RPC method. Can be a value, a `Ref`,
|
|
70
|
+
* or a function. If reactive, changes will trigger a re-fetch.
|
|
71
|
+
* - When passed as a raw value, the parameters are set at the point
|
|
72
|
+
* `useRpc` is called. Subsequent `refresh` calls will use the same params.
|
|
73
|
+
* - When passed as a function, the function will be invoked each
|
|
74
|
+
* time `refresh` is called to get the params.
|
|
75
|
+
* - When passed as a Ref, a watcher wil be added that
|
|
76
|
+
* calls `refresh` each time params change.
|
|
77
|
+
* @param options Options for `useAsyncData`, including `watch`, `getCachedData`,
|
|
78
|
+
* and more. Can be used to control caching behavior. By default,
|
|
79
|
+
* `useRpc` will set `immediate` to `false` and will pass `[params]`
|
|
80
|
+
* to `watch` if `params` is a `Ref`.
|
|
81
|
+
*
|
|
82
|
+
* @returns An object containing the `data`, `status`, and other properties from
|
|
83
|
+
* `useAsyncData`, as well as a promise that resolves to the data.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* import { useRpc } from '#storefront/composables'
|
|
88
|
+
*
|
|
89
|
+
* const { data: shopId, fetching } = useRpc('getShopId', 'current-shop-id')
|
|
90
|
+
* ```
|
|
39
91
|
*/
|
|
40
92
|
export declare function useRpc<N extends RpcMethodName, DataT = NormalizedRpcResponse<N>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null, ResponseT = NormalizedRpcResponse<N>>(method: N, key: string, params?: MaybeRefOrGetter<RpcMethodParameters<N> extends RpcContext ? undefined : RpcMethodParameters<N>>, options?: UseRpcOptions<N, DataT, PickKeys, DefaultT, ResponseT>): ExtendedAsyncData<ResponseT, unknown, DataT, PickKeys, DefaultT>;
|
|
41
93
|
export {};
|
|
@@ -1,2 +1,42 @@
|
|
|
1
1
|
import type { RpcContext, RpcMethodName, RpcMethodParameters, RpcMethodReturnType } from '@scayle/storefront-core';
|
|
2
|
+
/**
|
|
3
|
+
* Provides a function for calling a specified RPC method.
|
|
4
|
+
*
|
|
5
|
+
* This function acts as a factory, returning a function that can be used to
|
|
6
|
+
* call the given RPC method. It's designed for calling RPCs in response to
|
|
7
|
+
* events or user interactions, such as clicking a button or submitting a form.
|
|
8
|
+
* `useRpcCall` accepts the RPC method name and returns a callback function.
|
|
9
|
+
* When invoked, this callback receives the RPC parameters, makes the request,
|
|
10
|
+
* and returns a promise that resolves with the RPC's response.
|
|
11
|
+
*
|
|
12
|
+
* @template N The RPC Method Name.
|
|
13
|
+
* @template P The RPC Method Parameters.
|
|
14
|
+
* @template TResult The result type of the RPC method, excluding its`Response` object.
|
|
15
|
+
* @template TakesParameters A boolean indicating whether the RPC method takes parameters.
|
|
16
|
+
* It's `undefined` if the parameters extend `RpcContext`.
|
|
17
|
+
*
|
|
18
|
+
* @param method The name of the RPC method.
|
|
19
|
+
*
|
|
20
|
+
* @returns A function to call the specified RPC method. This returned function
|
|
21
|
+
* will accept the RPC method parameters (if any) and return a Promise
|
|
22
|
+
* that resolves with the result of the RPC call.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```html
|
|
26
|
+
* <!-- Example of a `subscribeToNewsletter` RPC method, triggered by a form submission -->
|
|
27
|
+
* <script setup lang="ts">
|
|
28
|
+
* import { useRpcCall } from '#storefront/composables'
|
|
29
|
+
* import { ref } from 'vue';
|
|
30
|
+
*
|
|
31
|
+
* const subscribeToNewsletter = useRpcCall('subscribeToNewsletter')
|
|
32
|
+
* const email = ref('hello@scayle.com')
|
|
33
|
+
*
|
|
34
|
+
* const onSubmit = async () => {
|
|
35
|
+
* const res = await subscribeToNewsletter({ email: email.value })
|
|
36
|
+
*
|
|
37
|
+
* console.log(res)
|
|
38
|
+
* }
|
|
39
|
+
* </script>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
2
42
|
export declare function useRpcCall<N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>, TakesParameters = P extends RpcContext ? undefined : boolean>(method: N): TakesParameters extends undefined ? () => Promise<TResult> : (params: P) => Promise<TResult>;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides functions for managing user sessions, including login, registration, guest login, token refresh, revocation, password reset, and IDP login.
|
|
3
|
+
*
|
|
4
|
+
* This composable leverages `useRpcCall` to interact with corresponding RPC methods.
|
|
5
|
+
*
|
|
6
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/sessions
|
|
7
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/authentication
|
|
8
|
+
*
|
|
9
|
+
* @returns An object containing functions for various session management operations.
|
|
10
|
+
*/
|
|
1
11
|
export declare function useSession(): {
|
|
2
12
|
login: (params: import("utility-types").Optional<import("@scayle/storefront-core").LoginRequest, "shop_id">) => Promise<never>;
|
|
3
13
|
register: (params: import("utility-types").Optional<import("@scayle/storefront-core").RegisterRequest, "shop_id">) => Promise<never>;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { ShopUser, UpdatePasswordParams } from '@scayle/storefront-core';
|
|
2
2
|
import { type UseRpcReturn } from './useRpc.js';
|
|
3
3
|
import { type ComputedRef } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Extended parameters for the `useUser` composable.
|
|
6
|
+
*/
|
|
4
7
|
export type ExtendedUseUserParams = {
|
|
8
|
+
/** The key used for caching the user data. Defaults to 'useUser'. */
|
|
5
9
|
key?: string;
|
|
10
|
+
/** Whether to fetch the user data immediately. Defaults to `true`. */
|
|
6
11
|
immediate?: boolean;
|
|
12
|
+
/** Whether to enable lazy loading of user data. Defaults to `false`. */
|
|
7
13
|
lazy?: boolean;
|
|
8
14
|
};
|
|
9
15
|
type UseUserBaseReturn = Pick<Awaited<UseRpcReturn<'getUser'>>, 'error' | 'status' | 'refresh'> & {
|
|
@@ -14,5 +20,23 @@ type UseUserBaseReturn = Pick<Awaited<UseRpcReturn<'getUser'>>, 'error' | 'statu
|
|
|
14
20
|
customerType: ComputedRef<'new' | 'guest' | 'existing'>;
|
|
15
21
|
forceRefresh: () => Promise<void>;
|
|
16
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Provides user information and related actions.
|
|
25
|
+
*
|
|
26
|
+
* This composable retrieves user data via the `getUser` RPC method and offers
|
|
27
|
+
* functionalities to update user details, change passwords, and force-refresh user data.
|
|
28
|
+
* It uses `useRpc` for data fetching and provides computed properties for user status,
|
|
29
|
+
* login status, and customer type.
|
|
30
|
+
*
|
|
31
|
+
* The composable also handles caching of user data and allows for lazy loading
|
|
32
|
+
* and immediate fetching based on the provided options.
|
|
33
|
+
*
|
|
34
|
+
* @param options Options to customize the behavior of the composable,
|
|
35
|
+
* such as caching key, immediate fetching, and lazy loading.
|
|
36
|
+
*
|
|
37
|
+
* @returns A promise that resolves to an object containing user information,
|
|
38
|
+
* update functions, and status properties. It also includes the resolved
|
|
39
|
+
* object directly as properties.
|
|
40
|
+
*/
|
|
17
41
|
export declare function useUser(options?: ExtendedUseUserParams): UseUserBaseReturn & Promise<UseUserBaseReturn>;
|
|
18
42
|
export {};
|
|
@@ -5,6 +5,9 @@ import { type NormalizedRpcResponse, type UseRpcReturn } from '../core/useRpc.js
|
|
|
5
5
|
import { type MaybeRefOrGetter, type ComputedRef, type Ref } from 'vue';
|
|
6
6
|
import type { BasketKey, BasketPackageInformation } from '@scayle/storefront-api';
|
|
7
7
|
import type { BasketItemUpdateData } from '@scayle/storefront-core/dist/rpc/methods/index';
|
|
8
|
+
/**
|
|
9
|
+
* Representation of options for configuring the `useBasket` composable.
|
|
10
|
+
*/
|
|
8
11
|
type UseBasketOptions = Partial<{
|
|
9
12
|
params: MaybeRefOrGetter<Omit<RpcMethodParameters<'getBasket'>, 'orderCustomData'>>;
|
|
10
13
|
key: string;
|
|
@@ -58,5 +61,26 @@ type UseBasketBaseReturn = Omit<Awaited<UseRpcReturn<'getBasket'>>, 'data'> & {
|
|
|
58
61
|
/** @deprecated In a future release `shippingDates` will be removed. Consider using {@link getShippingDates} instead. */
|
|
59
62
|
shippingDates: ComputedRef<(string | null)[] | undefined>;
|
|
60
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Manages basket interactions. Provides functionalities for adding, removing, updating, and clearing
|
|
66
|
+
* basket items, as well as accessing basket information like items, cost, and count.
|
|
67
|
+
*
|
|
68
|
+
* This function acts as a wrapper around the `useRpc` composable for basket data,
|
|
69
|
+
* simplifying the process of fetching brand data. It internally calls `useRpc`
|
|
70
|
+
* with the provided parameters and options. It utilizes the `getCachedData` option
|
|
71
|
+
* within `useRpc` to retrieve cached basket data during hydration or from async data otherwise.
|
|
72
|
+
* This helps avoid unnecessary re-fetches and improves performance. Specifically,
|
|
73
|
+
* it checks `nuxtApp._asyncData` for existing data associated with the provided key.
|
|
74
|
+
* This approach addresses a [Nuxt typing issue](https://github.com/nuxt/nuxt/issues/26093)
|
|
75
|
+
* requiring a type assertion to `WishlistResponseData`.
|
|
76
|
+
*
|
|
77
|
+
* @param options An object containing parameters and options for all basket-related RPC calls.
|
|
78
|
+
* @param options.params Parameters for the 'getBasket' RPC call (excluding `orderCustomData`).
|
|
79
|
+
* @param key A unique key for identifying the basket instance. Defaults to 'useBasket'.
|
|
80
|
+
*
|
|
81
|
+
* @returns A promise resolving to an object with basket data, methods, and reactive properties.
|
|
82
|
+
*
|
|
83
|
+
* @throws {Error} If an item cannot be found during removal or if an item is added with a reduced quantity. Also throws FetchError if RPC calls fail.
|
|
84
|
+
*/
|
|
61
85
|
export declare function useBasket({ params, }?: UseBasketOptions, key?: string): UseBasketBaseReturn & Promise<UseBasketBaseReturn>;
|
|
62
86
|
export {};
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves brand data using the `getBrandById` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching brand data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/brands/get-a-brand
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getBrandById'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getBrandById` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getBrandById` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useBrand<DataT = NormalizedRpcResponse<'getBrandById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getBrandById'>>;
|
|
6
27
|
options: UseRpcOptions<'getBrandById', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves multiple brands data using the 'getBrands' RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching brands data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/brands/list-brands
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getBrands'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getBrands` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getBrands` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. This key is used internally by `useRpc` for caching and managing state.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useBrands<DataT = NormalizedRpcResponse<'getBrands'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getBrands'>>;
|
|
6
27
|
options: UseRpcOptions<'getBrands', DataT, PickKeys, DefaultT>;
|
|
@@ -4,6 +4,34 @@ import type { MaybeRefOrGetter } from 'vue';
|
|
|
4
4
|
type UseCategoriesBaseReturn<DataT, PickKeys extends KeysOf<DataT>, DefaultT> = Pick<Awaited<UseRpcReturn<'getCategoriesByPath', DataT, PickKeys, DefaultT>>, 'data' | 'error' | 'status' | 'refresh'> & {
|
|
5
5
|
getCategoryById: (id: number, includeHidden?: true) => RpcMethodReturnType<'getCategoryById'>;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves categories data using the 'getCategoriesByPath' RPC method and
|
|
9
|
+
* provides a helper for fetching individual categories by ID.
|
|
10
|
+
*
|
|
11
|
+
* This function extends the functionality of `useRpc` by adding a
|
|
12
|
+
* `getCategoryById` method to the returned object. It fetches category data via
|
|
13
|
+
* 'getCategoriesByPath', then constructs and returns a promise enriched with the data,
|
|
14
|
+
* error, status, refresh function from the original promise, along with the
|
|
15
|
+
* added `getCategoryById` function. This approach allows for efficient retrieval
|
|
16
|
+
* of category data and simplifies the process of accessing individual categories.
|
|
17
|
+
*
|
|
18
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
19
|
+
* simplifying the process of fetching brand data. It internally calls `useRpc`
|
|
20
|
+
* with the provided parameters and options.
|
|
21
|
+
*
|
|
22
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCategoriesByPath'>`.
|
|
23
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
24
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
25
|
+
*
|
|
26
|
+
* @param input An object containing parameters and options for the `getCategoriesByPath` RPC call.
|
|
27
|
+
* @param input.params The parameters for the `getCategoriesByPath` RPC method.
|
|
28
|
+
* @param input.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
29
|
+
* @param keyA A unique key for caching and state management within `useRpc`.
|
|
30
|
+
*
|
|
31
|
+
* @returns A promise that resolves to an object containing the category data,
|
|
32
|
+
* error and status information, a refresh function, and a `getCategoryById`
|
|
33
|
+
* function for fetching individual categories.
|
|
34
|
+
*/
|
|
7
35
|
export declare function useCategories<DataT = NormalizedRpcResponse<'getCategoriesByPath'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
8
36
|
params: MaybeRefOrGetter<RpcMethodParameters<'getCategoriesByPath'>>;
|
|
9
37
|
options: UseRpcOptions<'getCategoriesByPath', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data for a single category by its ID using the `getCategoryById` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/categories/get-a-category
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCategoryById'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getCategoryById` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getCategoryById` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useCategoryById<DataT = NormalizedRpcResponse<'getCategoryById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getCategoryById'>>;
|
|
6
27
|
options: UseRpcOptions<'getCategoryById', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data for a single category by its path using the `getCategoryByPath` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/categories/get-a-category
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCategoriesByPath'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getCategoryByPath` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getCategoryByPath` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useCategoryByPath<DataT = NormalizedRpcResponse<'getCategoryByPath'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }: {
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getCategoryByPath'>>;
|
|
6
27
|
options?: UseRpcOptions<'getCategoryByPath', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data of the current active promotion data using the `getCurrentPromotions` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options, and it uses the default shared cache
|
|
10
|
+
* implementation, getting data from Nuxt's payload or static data during hydration
|
|
11
|
+
* or from async data otherwise.
|
|
12
|
+
*
|
|
13
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/promotions/list-promotions
|
|
14
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/rpc-methods#managing-shared-state-with-userpc
|
|
15
|
+
*
|
|
16
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCurrentPromotions'>`.
|
|
17
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
18
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
19
|
+
*
|
|
20
|
+
* @param params An object containing parameters and options for the `getCurrentPromotions` RPC call.
|
|
21
|
+
* @param params.params The parameters for the `getCurrentPromotions` RPC method.
|
|
22
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
23
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
24
|
+
*
|
|
25
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
26
|
+
* loading state, and any error information.
|
|
27
|
+
*/
|
|
4
28
|
export declare function useCurrentPromotions<DataT = NormalizedRpcResponse<'getCurrentPromotions'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
29
|
params: MaybeRefOrGetter<RpcMethodParameters<'getCurrentPromotions'>>;
|
|
6
30
|
options: UseRpcOptions<'getCurrentPromotions', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves filter data using the `getFilters` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/filters/list-filters
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getFilters'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getFilters` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getFilters` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useFilters<DataT = NormalizedRpcResponse<'getFilters'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getFilters'>>;
|
|
6
27
|
options: UseRpcOptions<'getFilters', DataT, PickKeys, DefaultT>;
|
|
@@ -1,10 +1,52 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data of a single navigation tree using the `fetchNavigationTreeById` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/navigation/get-a-navigation
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getBrands'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `fetchNavigationTreeById` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `fetchNavigationTreeById` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useNavigationTreeById<DataT = NormalizedRpcResponse<'fetchNavigationTreeById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'fetchNavigationTreeById'>>;
|
|
6
27
|
options: UseRpcOptions<'fetchNavigationTreeById', DataT, PickKeys, DefaultT>;
|
|
7
28
|
}>, key?: string): UseRpcReturn<'fetchNavigationTreeById', DataT, PickKeys, DefaultT>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves data of a single navigation tree using the `fetchNavigationTreeByName` RPC method.
|
|
31
|
+
*
|
|
32
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
33
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
34
|
+
* with the provided parameters and options.
|
|
35
|
+
*
|
|
36
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/navigation/get-a-navigation
|
|
37
|
+
*
|
|
38
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getBrands'>`.
|
|
39
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
40
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
41
|
+
*
|
|
42
|
+
* @param params An object containing parameters and options for the `fetchNavigationTreeByName` RPC call.
|
|
43
|
+
* @param params.params The parameters for the `fetchNavigationTreeByName` RPC method.
|
|
44
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
45
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
46
|
+
*
|
|
47
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
48
|
+
* loading state, and any error information.
|
|
49
|
+
*/
|
|
8
50
|
export declare function useNavigationTreeByName<DataT = NormalizedRpcResponse<'fetchNavigationTreeById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
9
51
|
params: MaybeRefOrGetter<RpcMethodParameters<'fetchNavigationTreeByName'>>;
|
|
10
52
|
options: UseRpcOptions<'fetchNavigationTreeById', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcReturn, UseRpcOptions, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data of all navigation trees using the `fetchAllNavigationTrees` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/navigation/list-navigations
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getBrands'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `fetchAllNavigationTrees` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `fetchAllNavigationTrees` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useNavigationTrees<DataT = NormalizedRpcResponse<'fetchAllNavigationTrees'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'fetchAllNavigationTrees'>>;
|
|
6
27
|
options: UseRpcOptions<'fetchAllNavigationTrees', DataT, PickKeys, DefaultT>;
|
|
@@ -7,6 +7,29 @@ type NewItemsType<P, V> = Exclude<ItemsType[number], 'product' | 'variant'> & {
|
|
|
7
7
|
product: P;
|
|
8
8
|
variant: V;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves order data by ID using the `getOrderById` RPC method.
|
|
12
|
+
*
|
|
13
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
14
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
15
|
+
* with the provided parameters and options.
|
|
16
|
+
* It allows for flexible typing of the `product` and `variant` properties within the order items.
|
|
17
|
+
*
|
|
18
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/order/get-order
|
|
19
|
+
*
|
|
20
|
+
* @template P The type of the `product` property within the order items. Defaults to an object with any keys.
|
|
21
|
+
* @template V The type of the `variant` property within the order items. Defaults to an object with any keys.
|
|
22
|
+
* @template DataT The type of the transformed data. Defaults to `Order & { items?: NewItemsType<P, V>[] }`.
|
|
23
|
+
* @template PickKeys Keys of the `DataT` type that will be present. This defaults to all keys of DataT.
|
|
24
|
+
* @template DefaultT The default return type. Useful for showing loading skeletons. Defaults to `null`.
|
|
25
|
+
*
|
|
26
|
+
* @param params An object containing parameters and options for the `getOrderById` RPC call.
|
|
27
|
+
* @param params.params The parameters for the `getOrderById` RPC method.
|
|
28
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
29
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
30
|
+
*
|
|
31
|
+
* @returns An extended async data object containing the order data.
|
|
32
|
+
*/
|
|
10
33
|
export declare function useOrder<P = {
|
|
11
34
|
[k: string]: unknown;
|
|
12
35
|
}, V = {
|
|
@@ -7,6 +7,27 @@ type NewItemsType<P, V> = Exclude<ItemsType[number], 'product' | 'variant'> & {
|
|
|
7
7
|
product: P;
|
|
8
8
|
variant: V;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves order data by ID using the `getOrderDataByCbd RPC method.
|
|
12
|
+
*
|
|
13
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
14
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
15
|
+
* with the provided parameters and options.
|
|
16
|
+
* It allows for flexible typing of the `product` and `variant` properties within the order items.
|
|
17
|
+
*
|
|
18
|
+
* @template P The type of the `product` property within the order items. Defaults to an object with any keys.
|
|
19
|
+
* @template V The type of the `variant` property within the order items. Defaults to an object with any keys.
|
|
20
|
+
* @template DataT The type of the transformed data. Defaults to `Order & { items?: NewItemsType<P, V>[] }`.
|
|
21
|
+
* @template PickKeys Keys of the `DataT` type that will be present. This defaults to all keys of DataT.
|
|
22
|
+
* @template DefaultT The default return type. Useful for showing loading skeletons. Defaults to `null`.
|
|
23
|
+
*
|
|
24
|
+
* @param params An object containing parameters and options for the `getOrderDataByCbd RPC call.
|
|
25
|
+
* @param params.params The parameters for the `getOrderDataByCbd RPC method.
|
|
26
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
27
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
28
|
+
*
|
|
29
|
+
* @returns An extended async data object containing the order data.
|
|
30
|
+
*/
|
|
10
31
|
export declare function useOrderConfirmation<P = {
|
|
11
32
|
[k: string]: unknown;
|
|
12
33
|
}, V = {
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data for a single product by its ID using the `getProductById` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/products/get-a-product
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getProductById'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getProductById` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getProductById` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useProduct<DataT = NormalizedRpcResponse<'getProductById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductById'>>;
|
|
6
27
|
options: UseRpcOptions<'getProductById', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves product data by its category using the `getProductById` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/products/list-products
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getProductById'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getProductById` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getProductById` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useProducts<DataT = NormalizedRpcResponse<'getProductsByCategory'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductsByCategory'>>;
|
|
6
27
|
options: UseRpcOptions<'getProductsByCategory', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data of multiple products by their ID using the `getProductsByIds` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/products/list-products
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getProductsByIds'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getProductsByIds` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getProductsByIds` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useProductsByIds<DataT = NormalizedRpcResponse<'getProductsByIds'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductsByIds'>>;
|
|
6
27
|
options: UseRpcOptions<'getProductsByIds', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data of multiple products by their reference keys using the `getProductsByReferenceKeys` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/products/list-products
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getProductsByReferenceKeys'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getProductsByReferenceKeys` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getProductsByReferenceKeys` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useProductsByReferenceKeys<DataT = NormalizedRpcResponse<'getProductsByReferenceKeys'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductsByReferenceKeys'>>;
|
|
6
27
|
options: UseRpcOptions<'getProductsByReferenceKeys', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves product count of a category by its ID using the `getProductsCount` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
* *
|
|
11
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getProductsCount'>`.
|
|
12
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
13
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
14
|
+
*
|
|
15
|
+
* @param params An object containing parameters and options for the `getProductsCount` RPC call.
|
|
16
|
+
* @param params.params The parameters for the `getProductsCount` RPC method.
|
|
17
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
18
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
19
|
+
*
|
|
20
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
21
|
+
* loading state, and any error information.
|
|
22
|
+
*/
|
|
4
23
|
export declare function useProductsCount<DataT = NormalizedRpcResponse<'getProductsCount'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
24
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductsCount'>>;
|
|
6
25
|
options: UseRpcOptions<'getProductsCount', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data for all available promotion using the `getPromotions` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/promotions/list-promotions
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getPromotions'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getPromotions` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getPromotions` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function usePromotions<DataT = NormalizedRpcResponse<'getPromotions'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getPromotions'>>;
|
|
6
27
|
options: UseRpcOptions<'getPromotions', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data for multiple promotions by their IDs using the `getPromotionsByIds` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/promotions/list-promotions
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getPromotionsByIds'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getPromotionsByIds` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getPromotionsByIds` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function usePromotionsByIds<DataT = NormalizedRpcResponse<'getPromotionsByIds'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getPromotionsByIds'>>;
|
|
6
27
|
options: UseRpcOptions<'getPromotionsByIds', DataT, PickKeys, DefaultT>;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves data about the current shop by its shopID using the `getShopConfiguration` RPC method.
|
|
4
|
+
*
|
|
5
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
6
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
7
|
+
* with the provided parameters and options.
|
|
8
|
+
*
|
|
9
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/shop-configuration/get-a-shop-configuration
|
|
10
|
+
*
|
|
11
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getShopConfiguration'>`.
|
|
12
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
13
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
14
|
+
*
|
|
15
|
+
* @param params An object containing parameters and options for the `getShopConfiguration` RPC call.
|
|
16
|
+
* @param params.params The parameters for the `getShopConfiguration` RPC method.
|
|
17
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
18
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
19
|
+
*
|
|
20
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
21
|
+
* loading state, and any error information.
|
|
22
|
+
*/
|
|
2
23
|
export declare function useShopConfiguration<DataT = NormalizedRpcResponse<'getShopConfiguration'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ options, }?: Partial<{
|
|
3
24
|
options: UseRpcOptions<'getShopConfiguration', DataT, PickKeys, DefaultT>;
|
|
4
25
|
}>, key?: string): UseRpcReturn<'getShopConfiguration', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { SearchV2SuggestionsEndpointResponseData, SearchV2With } from '@scayle/storefront-core';
|
|
2
2
|
import type { Status } from '../core/useRpc.js';
|
|
3
3
|
import type { Ref } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Representation of options for the search composable.
|
|
6
|
+
*/
|
|
4
7
|
export type SearchOptions = Partial<{
|
|
5
8
|
params: Partial<{
|
|
6
9
|
categoryId: number;
|
|
@@ -9,7 +12,14 @@ export type SearchOptions = Partial<{
|
|
|
9
12
|
key: string;
|
|
10
13
|
}>;
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
15
|
+
* A composable that provides a way to fetch and manage search suggestions and results.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated `useStorefrontSearch` is deprecated. Consider using `useSearch` of `@scayle/storefront-search` instead.
|
|
18
|
+
*
|
|
19
|
+
* @param option - An object containing options for the search request.
|
|
20
|
+
* @param option.with - An object describing which data the returned suggestions/results should contain.
|
|
21
|
+
*
|
|
22
|
+
* @returns An object containing reactive data and computed properties for managing search results and suggestions.
|
|
13
23
|
*/
|
|
14
24
|
export declare function useStorefrontSearch(searchQuery: Ref<string>, { params }?: SearchOptions, key?: string): {
|
|
15
25
|
data: Ref<SearchV2SuggestionsEndpointResponseData | undefined, SearchV2SuggestionsEndpointResponseData | undefined>;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves address data for a logged-in user using the `getCategoryById` RPC method.
|
|
4
|
+
*
|
|
5
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
6
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
7
|
+
* with the provided parameters and options.
|
|
8
|
+
*
|
|
9
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/address/list-addresses
|
|
10
|
+
*
|
|
11
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCategoryById'>`.
|
|
12
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
13
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
14
|
+
*
|
|
15
|
+
* @param params An object containing parameters and options for the `getCategoryById` RPC call.
|
|
16
|
+
* @param params.params The parameters for the `getCategoryById` RPC method.
|
|
17
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
18
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
19
|
+
*
|
|
20
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
21
|
+
* loading state, and any error information.
|
|
22
|
+
*/
|
|
2
23
|
export declare function useUserAddresses<DataT = NormalizedRpcResponse<'getShopUserAddresses'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ options, }?: Partial<{
|
|
3
24
|
options: UseRpcOptions<'getShopUserAddresses', DataT, PickKeys, DefaultT>;
|
|
4
25
|
}>, key?: string): UseRpcReturn<'getShopUserAddresses', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves data for a single or multiple product variant by its ID using the `getVariantById` RPC method.
|
|
6
|
+
*
|
|
7
|
+
* This function acts as a wrapper around the `useRpc` composable,
|
|
8
|
+
* simplifying the process of fetching data. It internally calls `useRpc`
|
|
9
|
+
* with the provided parameters and options.
|
|
10
|
+
*
|
|
11
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/variants/get-a-variant
|
|
12
|
+
*
|
|
13
|
+
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getVariantById'>`.
|
|
14
|
+
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
15
|
+
* @template DefaultT The default value to use if data is not available. Defaults to `null`.
|
|
16
|
+
*
|
|
17
|
+
* @param params An object containing parameters and options for the `getVariantById` RPC call.
|
|
18
|
+
* @param params.params The parameters for the `getVariantById` RPC method.
|
|
19
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
20
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
21
|
+
*
|
|
22
|
+
* @returns The result of the `useRpc` call, which includes the fetched data,
|
|
23
|
+
* loading state, and any error information.
|
|
24
|
+
*/
|
|
4
25
|
export declare function useVariant<DataT = NormalizedRpcResponse<'getVariantById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
|
|
5
26
|
params: MaybeRefOrGetter<RpcMethodParameters<'getVariantById'>>;
|
|
6
27
|
options: UseRpcOptions<'getVariantById', DataT, PickKeys, DefaultT>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Product, WishlistItem, RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import { type UseRpcReturn } from '../core/useRpc.js';
|
|
3
3
|
import { type MaybeRefOrGetter, type ComputedRef } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Representation of options for configuring the `useWishlist` composable.
|
|
6
|
+
*/
|
|
4
7
|
type Options = Partial<{
|
|
5
8
|
params: MaybeRefOrGetter<RpcMethodParameters<'getWishlist'>>;
|
|
6
9
|
}>;
|
|
@@ -39,5 +42,31 @@ type UseWishlistBaseReturn = Awaited<UseRpcReturn<'getWishlist'>> & {
|
|
|
39
42
|
items: ComputedRef<WishlistItem[] | undefined>;
|
|
40
43
|
products: ComputedRef<Product[]>;
|
|
41
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Manages wishlist interactions. Fetches wishlist data, provides methods for adding, removing,
|
|
47
|
+
* replacing, clearing, finding, and toggling items. It leverages RPC calls for data manipulation
|
|
48
|
+
* and provides reactive properties for count, items, and products.
|
|
49
|
+
*
|
|
50
|
+
* This function acts as a wrapper around the `useRpc` composable for wishlist data,
|
|
51
|
+
* simplifying the process of fetching brand data. It internally calls `useRpc`
|
|
52
|
+
* with the provided parameters and options. It utilizes the `getCachedData` option
|
|
53
|
+
* within `useRpc` to retrieve cached wishlist data during hydration or from async data otherwise.
|
|
54
|
+
* This helps avoid unnecessary re-fetches and improves performance. Specifically,
|
|
55
|
+
* it checks `nuxtApp._asyncData` for existing data associated with the provided key.
|
|
56
|
+
* This approach addresses a [Nuxt typing issue](https://github.com/nuxt/nuxt/issues/26093)
|
|
57
|
+
* requiring a type assertion to `WishlistResponseData`.
|
|
58
|
+
*
|
|
59
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/wishlists/get-a-wishlist
|
|
60
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/rpc-methods#managing-shared-state-with-userpc
|
|
61
|
+
*
|
|
62
|
+
* @param params An object containing parameters and options for all wishlist-related RPC calls.
|
|
63
|
+
* @param params.params The parameters for the `useWishlist` RPC method.
|
|
64
|
+
* @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state.
|
|
65
|
+
* @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management.
|
|
66
|
+
*
|
|
67
|
+
* @returns A promise that resolves to an object containing wishlist data, methods, and reactive properties.
|
|
68
|
+
*
|
|
69
|
+
* @throws {Error} If an item cannot be found during removal or replacement.
|
|
70
|
+
*/
|
|
42
71
|
export declare function useWishlist({ params, }?: Options, key?: string): UseWishlistBaseReturn & Promise<UseWishlistBaseReturn>;
|
|
43
72
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.11.
|
|
4
|
+
"version": "8.11.1",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@opentelemetry/api": "^1.9.0",
|
|
74
74
|
"@scayle/h3-session": "0.6.0",
|
|
75
|
-
"@scayle/storefront-core": "8.
|
|
75
|
+
"@scayle/storefront-core": "8.10.0",
|
|
76
76
|
"@scayle/unstorage-compression-driver": "^0.2.4",
|
|
77
77
|
"@vercel/nft": "0.29.2",
|
|
78
78
|
"@vueuse/core": "12.7.0",
|