@scayle/storefront-nuxt 8.10.3 → 8.11.0
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 +19 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/api/cacheAuth.d.ts +20 -5
- package/dist/runtime/api/purgeAll.d.ts +12 -0
- package/dist/runtime/api/purgeTags.d.ts +14 -0
- package/dist/runtime/api/rpcHandler.d.ts +17 -22
- package/dist/runtime/api/up.d.ts +8 -0
- package/dist/runtime/cached.d.ts +13 -0
- package/dist/runtime/campaignKey.d.ts +18 -0
- package/dist/runtime/composables/useCoreLog.d.ts +13 -0
- package/dist/runtime/context.d.ts +25 -0
- package/dist/runtime/context.js +25 -1
- package/dist/runtime/createLog.d.ts +16 -0
- package/dist/runtime/handler.d.ts +18 -4
- package/dist/runtime/rpc/rpcCall.d.ts +15 -3
- package/dist/runtime/server/middleware/bootstrap-utils.d.ts +1 -1
- package/dist/runtime/utils/promise.d.ts +30 -6
- package/dist/runtime/utils/route.d.ts +11 -0
- package/dist/runtime/utils/seo.d.ts +13 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Include `rpcCall` when building the context. This utility function can be used within RPC methods to invoke another RPC method.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
**Dependencies**
|
|
12
|
+
|
|
13
|
+
- Updated dependency to @scayle/unstorage-compression-driver@0.2.4
|
|
14
|
+
- Updated dependency to @scayle/storefront-core@8.9.0
|
|
15
|
+
|
|
16
|
+
## 8.10.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependency `@vercel/nft@0.29.1` to `@vercel/nft@0.29.2`
|
|
21
|
+
|
|
3
22
|
## 8.10.3
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import type { EventHandler } from 'h3';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Wraps an event handler with cache authentication.
|
|
4
|
+
*
|
|
5
|
+
* It takes an event handler and returns a new handler that is protected by
|
|
6
|
+
* basic authentication if cache authentication is configured in the runtime config (`cache.auth`).
|
|
7
|
+
* If cache authentication is not configured, the original handler is returned.
|
|
8
|
+
*
|
|
9
|
+
* @param handler The event handler to wrap.
|
|
10
|
+
*
|
|
11
|
+
* @returns The wrapped event handler.
|
|
5
12
|
*/
|
|
6
13
|
export declare const eventHandlerWithCacheAuth: (handler: EventHandler) => EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
7
14
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
15
|
+
* Wraps an event handler with basic authentication.
|
|
16
|
+
*
|
|
17
|
+
* This function enhances a given event handler with basic authentication functionality.
|
|
18
|
+
* It checks for an Authorization header in the request and compares the decoded
|
|
19
|
+
* credentials with the provided authentication string. If the credentials match,
|
|
20
|
+
* the original handler is executed.
|
|
21
|
+
*
|
|
22
|
+
* @param handler The event handler to be wrapped.
|
|
23
|
+
* @param auth The authentication string in the format 'username:password'.
|
|
24
|
+
*
|
|
25
|
+
* @returns The wrapped and awaited event handler, else an authentication failure response is returned.
|
|
11
26
|
*/
|
|
12
27
|
export declare const eventHandlerWithBasicAuth: (handler: EventHandler, auth: string) => EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Purges the entire cache.
|
|
3
|
+
*
|
|
4
|
+
* This event handler purges all entries from the configured cache.
|
|
5
|
+
* It requires both `$rpcContext` and `$cache` to be present in the event context.
|
|
6
|
+
* If either is missing, it returns a 500 Internal Server Error.
|
|
7
|
+
* If the purge operation is successful, it returns a 200 OK with `{ success: true }`.
|
|
8
|
+
* If an error occurs during purging, it returns a 500 Internal Server Error with `{ success: false }`
|
|
9
|
+
* and logs the error using the logger provided by `$rpcContext`.
|
|
10
|
+
*
|
|
11
|
+
* @returns A promise that resolves to either an object indicating success or a `Response` object indicating an error.
|
|
12
|
+
*/
|
|
1
13
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
2
14
|
export default _default;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Purges cache entries by tags.
|
|
3
|
+
*
|
|
4
|
+
* This event handler purges cache entries associated with the provided tags.
|
|
5
|
+
* It requires both `$rpcContext` and `$cache` to be present in the event context.
|
|
6
|
+
* If either is missing, it returns a 500 Internal Server Error.
|
|
7
|
+
* It reads an array of tags from the request body.
|
|
8
|
+
* If the body is empty or no tags are provided, it returns a 400 Bad Request.
|
|
9
|
+
* If the purge operation is successful, it returns 200 OK with `{ success: true }`.
|
|
10
|
+
* If an error occurs during the purge, it returns a 500 Internal Server Error with `{ success: false }`
|
|
11
|
+
* and logs the error using the logger provided by the `$rpcContext`.
|
|
12
|
+
*
|
|
13
|
+
* @returns A promise resolving to an object indicating success or a `Response` object with an error status.
|
|
14
|
+
*/
|
|
1
15
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
2
16
|
export default _default;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
} | {
|
|
1
|
+
/**
|
|
2
|
+
* Generic event handler for RPC methods.
|
|
3
|
+
*
|
|
4
|
+
* It retrieves the RPC method name from the request path,
|
|
5
|
+
* reads the payload from the request body.
|
|
6
|
+
* It utilizes hooks provided by Nitro to allow for custom logic before,
|
|
7
|
+
* after, and in case of errors during RPC calls.
|
|
8
|
+
*
|
|
9
|
+
* @param event The H3 event object.
|
|
10
|
+
*
|
|
11
|
+
* @returns The result of the RPC call or a `Response` object with an error status.
|
|
12
|
+
*/
|
|
13
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | true | string[] | import("@scayle/storefront-core").ShopUser | Response | import("@scayle/storefront-api").Product | import("@scayle/storefront-api").Product[] | import("@scayle/storefront-core").FetchProductsCountResponse | import("@scayle/storefront-core").FetchFiltersResponse | import("@scayle/storefront-core").FetchProductsByCategoryResponse | import("@scayle/storefront-api").Wishlist | {
|
|
14
|
+
accessToken: string;
|
|
15
|
+
checkoutJwt: string;
|
|
16
|
+
} | import("@scayle/storefront-api").VariantDetail[] | {
|
|
19
17
|
basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
|
|
20
18
|
} | {
|
|
21
19
|
readonly type: "success";
|
|
@@ -32,10 +30,7 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
32
30
|
activeNode: import("@scayle/storefront-api").Category;
|
|
33
31
|
} | import("@scayle/storefront-core").Order | import("@scayle/storefront-api").SearchV2SuggestionsEndpointResponseData | import("@scayle/storefront-api").SearchEntity | import("@scayle/storefront-api").ShopConfiguration | {
|
|
34
32
|
user: import("@scayle/storefront-core").ShopUser | undefined;
|
|
35
|
-
} | import("@scayle/storefront-api").
|
|
36
|
-
accessToken: string;
|
|
37
|
-
checkoutJwt: string;
|
|
38
|
-
} | import("@scayle/storefront-api").VariantDetail[] | import("@scayle/storefront-api").NavigationAllEndpointResponseData | import("@scayle/storefront-api").NavigationTree | {
|
|
33
|
+
} | import("@scayle/storefront-core").ShopUserAddress[] | import("@scayle/storefront-api").NavigationAllEndpointResponseData | import("@scayle/storefront-api").NavigationTree | {
|
|
39
34
|
success: true;
|
|
40
35
|
} | {
|
|
41
36
|
success: false;
|
package/dist/runtime/api/up.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health check endpoint.
|
|
3
|
+
*
|
|
4
|
+
* This simple endpoint returns a JSON object indicating that the service is up.
|
|
5
|
+
* It is typically used for monitoring and health checks.
|
|
6
|
+
*
|
|
7
|
+
* @returns An object with a status property set to 'up'.
|
|
8
|
+
*/
|
|
1
9
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, {
|
|
2
10
|
status: string;
|
|
3
11
|
}>;
|
package/dist/runtime/cached.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
import { type Log, type CacheInterface } from '@scayle/storefront-core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates and returns a bound cached function.
|
|
4
|
+
*
|
|
5
|
+
* It initializes a new `Cached` instance with provided parameters and
|
|
6
|
+
* returns its `execute` method bound to the instance.
|
|
7
|
+
* This allows for easy use of the caching functionality provided by `@scayle/storefront-core`.
|
|
8
|
+
*
|
|
9
|
+
* @param $cache The cache interface instance.
|
|
10
|
+
* @param $log The logging instance.
|
|
11
|
+
* @param enabled Whether caching is enabled or not. Defaults to true if undefined.
|
|
12
|
+
*
|
|
13
|
+
* @returns A bound function that can be used to execute cached operations.
|
|
14
|
+
*/
|
|
2
15
|
export declare function getCachedFunction($cache: CacheInterface, $log: Log, enabled: boolean | undefined): <TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: import("@scayle/storefront-core").CacheOptions) => Awaited<(...args: TArgs) => Promise<TResult>>;
|
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
import type { StorefrontAPIClient, CachedType, Log } from '@scayle/storefront-core';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the key of the first active campaign.
|
|
4
|
+
*
|
|
5
|
+
* Retrieves campaigns from the Storefront API, filters for non-ended campaigns,
|
|
6
|
+
* sorts them, and returns the key of the first active one.
|
|
7
|
+
* The retrieved campaigns are cached for a specified duration.
|
|
8
|
+
*
|
|
9
|
+
* @see https://scayle.dev/en/user-guide/shops/promotions/discounts-and-offers/price-campaigns
|
|
10
|
+
* @see https://scayle.dev/en/api-guides/storefront-api/resources/campaigns/list-campaigns
|
|
11
|
+
*
|
|
12
|
+
* @param sapiClient The Storefront API client.
|
|
13
|
+
* @param cached The caching function.
|
|
14
|
+
* @param log The logging instance.
|
|
15
|
+
*
|
|
16
|
+
* @throws {Error} If fetching or processing campaigns fails.
|
|
17
|
+
*
|
|
18
|
+
* @returns The key of the first active campaign, or undefined if no active campaign is found or an error occurs.
|
|
19
|
+
*/
|
|
2
20
|
export declare const fetchCampaignKey: (sapiClient: StorefrontAPIClient, cached: CachedType, log: Log) => Promise<string | undefined>;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a logger instance with an `sfc` prefix.
|
|
3
|
+
*
|
|
4
|
+
* This composable provides a logging function specifically for storefront-nuxt internal operations.
|
|
5
|
+
* It wraps the generic `useLog` function and prefixes the provided subspace with `sfc` to distinguish
|
|
6
|
+
* storefront-nuxt logs from application logs. This aids in debugging and troubleshooting by clearly
|
|
7
|
+
* identifying the origin of log messages.
|
|
8
|
+
*
|
|
9
|
+
* @param subSpace The subspace for the logger. If provided, it will be prefixed with `sfc.`.
|
|
10
|
+
* If not provided, the subspace will be just `sfc`.
|
|
11
|
+
*
|
|
12
|
+
* @returns A logger instance.
|
|
13
|
+
*/
|
|
1
14
|
export declare function useCoreLog(subSpace: string): import("@scayle/storefront-core").Log;
|
|
@@ -4,6 +4,9 @@ import { type H3Event } from 'h3';
|
|
|
4
4
|
import type { Log, RpcContext, Cache as CacheInterface } from '@scayle/storefront-core';
|
|
5
5
|
import { StorefrontAPIClient } from '@scayle/storefront-core';
|
|
6
6
|
import type { ShopConfig, StorefrontConfig } from '../module.js';
|
|
7
|
+
/**
|
|
8
|
+
* Interface defining the options for the context builder.
|
|
9
|
+
*/
|
|
7
10
|
export interface ContextBuilderOptions {
|
|
8
11
|
$cache: CacheInterface;
|
|
9
12
|
$shopConfig: ShopConfig;
|
|
@@ -14,6 +17,28 @@ export interface ContextBuilderOptions {
|
|
|
14
17
|
config: RuntimeConfig;
|
|
15
18
|
event: H3Event;
|
|
16
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds the RPC context.
|
|
22
|
+
*
|
|
23
|
+
* It builds the RPC context by gathering data from different sources like
|
|
24
|
+
* shop config, storefront config, session, etc.
|
|
25
|
+
* It initializes the SAPI client, caching function, and various context properties.
|
|
26
|
+
* It also sets up getters for IP, headers, user, access tokens,
|
|
27
|
+
* and functions for session management and user updates.
|
|
28
|
+
*
|
|
29
|
+
* @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/rpc-methods#rpc-context
|
|
30
|
+
*
|
|
31
|
+
* @param context The context builder options.
|
|
32
|
+
* @param context.$cache The cache instance.
|
|
33
|
+
* @param context.$shopConfig The shop configuration.
|
|
34
|
+
* @param context.$storefront The storefront configuration.
|
|
35
|
+
* @param context.$log The log instance.
|
|
36
|
+
* @param context.config The runtime configuration.
|
|
37
|
+
* @param context.event The H3 event.
|
|
38
|
+
* @param context.session The session object.
|
|
39
|
+
*
|
|
40
|
+
* @returns The built RPC context.
|
|
41
|
+
*/
|
|
17
42
|
export declare const buildContext: (context: ContextBuilderOptions) => Promise<RpcContext>;
|
|
18
43
|
declare module '@scayle/storefront-core' {
|
|
19
44
|
interface AdditionalRpcContext {
|
package/dist/runtime/context.js
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from "@scayle/storefront-core/dist/utils/keys";
|
|
10
10
|
import { useNitroApp } from "nitropack/runtime";
|
|
11
11
|
import { getCachedFunction } from "./cached.js";
|
|
12
|
+
import { getApiBasePath } from "./server/middleware/bootstrap-utils.js";
|
|
13
|
+
import { unwrap } from "@scayle/storefront-core/dist/utils/response";
|
|
12
14
|
import { fetchCampaignKey } from "./campaignKey.js";
|
|
13
15
|
async function getWishlistKey(appKeys, session, $log, $shopConfig) {
|
|
14
16
|
return session.data.user ? await generateWishlistKey({
|
|
@@ -28,6 +30,22 @@ async function getBasketKey(appKeys, session, $log, $shopConfig) {
|
|
|
28
30
|
log: $log
|
|
29
31
|
}) : session?.id;
|
|
30
32
|
}
|
|
33
|
+
function buildRpcCall(event, shopConfig, apiBasePath) {
|
|
34
|
+
const fetch = event.$fetch;
|
|
35
|
+
return async function rpcCall(method, params = void 0) {
|
|
36
|
+
const data = await fetch(`${apiBasePath}/rpc/${method}`, {
|
|
37
|
+
// @ts-expect-error Type '"POST"' is not assignable to type 'AvailableRouterMethod<`${string}/rpc/${N}`> | Uppercase<AvailableRouterMethod<`${string}/rpc/${N}`>> | undefined'.ts(2322)
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: {
|
|
40
|
+
payload: params
|
|
41
|
+
},
|
|
42
|
+
headers: {
|
|
43
|
+
"x-shop-id": shopConfig.shopId.toString()
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return await unwrap(data);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
31
49
|
export const buildContext = async (context) => {
|
|
32
50
|
const { $cache, $shopConfig, $storefront, $log, config, event, session } = context;
|
|
33
51
|
const sapiConfig = $shopConfig.sapi ?? $storefront.sapi;
|
|
@@ -50,6 +68,11 @@ export const buildContext = async (context) => {
|
|
|
50
68
|
$storefront.cache?.enabled
|
|
51
69
|
);
|
|
52
70
|
const { hooks } = useNitroApp();
|
|
71
|
+
const callRpc = buildRpcCall(
|
|
72
|
+
context.event,
|
|
73
|
+
$shopConfig,
|
|
74
|
+
getApiBasePath($storefront, "/")
|
|
75
|
+
);
|
|
53
76
|
const rpcContext = {
|
|
54
77
|
cached,
|
|
55
78
|
sapiClient,
|
|
@@ -135,7 +158,8 @@ export const buildContext = async (context) => {
|
|
|
135
158
|
updateTokens: session ? async (tokens) => {
|
|
136
159
|
Object.assign(session.data, tokens);
|
|
137
160
|
await session.save();
|
|
138
|
-
} : void 0
|
|
161
|
+
} : void 0,
|
|
162
|
+
callRpc
|
|
139
163
|
};
|
|
140
164
|
await hooks?.callHook("storefront:context:created", rpcContext);
|
|
141
165
|
return rpcContext;
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { ConsolaInstance, ConsolaOptions } from 'consola';
|
|
2
2
|
import type { LogLevel } from '../index.js';
|
|
3
3
|
import { Log } from '@scayle/storefront-core';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Consola log instance.
|
|
6
|
+
*
|
|
7
|
+
* It creates a new log instance using the provided `createConsola` function.
|
|
8
|
+
* It sets up a handler that formats log entries with the `space` and logs them
|
|
9
|
+
* using the consola instance.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/unjs/consola?tab=readme-ov-file#creating-a-new-instance
|
|
12
|
+
*
|
|
13
|
+
* @param createConsola Function to create a consola instance.
|
|
14
|
+
* @param createConsola.options Options for the consola instance.
|
|
15
|
+
* @param space The space for the log. Defaults to 'default-storefront'.
|
|
16
|
+
* @param level The log level.
|
|
17
|
+
*
|
|
18
|
+
* @returns The created Consola log instance.
|
|
19
|
+
*/
|
|
4
20
|
export default function createLog(createConsola: (options?: Partial<ConsolaOptions>) => ConsolaInstance, space: string | undefined, level: LogLevel): Log;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import type { RpcContext, RpcMethodName, RpcMethodParameters, RpcMethodReturnType } from '@scayle/storefront-core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Handles RPC method calls, combining core RPC methods with custom Storefront RPC methods.
|
|
4
|
+
* This function acts as a central dispatcher for invoking RPC methods, determining
|
|
5
|
+
* whether the method takes parameters or not, and executing it accordingly.
|
|
6
|
+
* It additionally logs the execution time of each RPC call.
|
|
7
|
+
*
|
|
8
|
+
* @template N The RPC method name.
|
|
9
|
+
* @template P The RPC method parameters.
|
|
10
|
+
* @template TResult The awaited return type of the RPC method. This can include a `Response` object.
|
|
11
|
+
* @template TakesParameters A boolean indicating whether the method takes parameters (undefined if it doesn't).
|
|
12
|
+
* @template TParams The type of the parameters if the method takes any, otherwise null.
|
|
13
|
+
*
|
|
14
|
+
* @param method The name of the RPC method to call.
|
|
15
|
+
* @param payload The parameters for the RPC method (if any).
|
|
16
|
+
* @param rpcContext The RPC context object.
|
|
17
|
+
*
|
|
18
|
+
* @returns A Promise resolving to the result of the RPC call, which can be any valid return type or a `Response` object.
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} If the specified RPC method is not found.
|
|
7
21
|
*/
|
|
8
22
|
export declare const handler: <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Awaited<RpcMethodReturnType<N>>, TakesParameters = P extends RpcContext ? undefined : boolean, TParams = TakesParameters extends undefined ? null : P>(method: N, payload: TParams, rpcContext: RpcContext) => Promise<TResult | Response>;
|
|
@@ -2,8 +2,20 @@ import type { RpcContext, RpcMethodName, RpcMethodParameters, RpcMethodReturnTyp
|
|
|
2
2
|
import type { NuxtApp } from 'nuxt/app';
|
|
3
3
|
import type { PublicShopConfig } from '../../index.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Invokes an RPC method on the client or server.
|
|
6
|
+
* Uses an HTTP request on the client and a direct call on the server via `$fetch`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://nuxt.com/docs/api/utils/dollarfetch
|
|
9
|
+
*
|
|
10
|
+
* @template N The RPC method name.
|
|
11
|
+
* @template P The RPC method parameters.
|
|
12
|
+
* @template TResult The unwrapped return type of the RPC method, excluding the Response type.
|
|
13
|
+
* @template TakesParameters A boolean indicating whether the method takes parameters (undefined if it doesn't).
|
|
14
|
+
*
|
|
15
|
+
* @param nuxtApp The Nuxt app instance.
|
|
16
|
+
* @param method The name of the RPC method to call.
|
|
17
|
+
* @param shop The public shop configuration.
|
|
18
|
+
*
|
|
19
|
+
* @returns A function that takes parameters (if required) and returns a Promise resolving to the result.
|
|
8
20
|
*/
|
|
9
21
|
export declare const rpcCall: <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>, TakesParameters = P extends RpcContext ? undefined : boolean>(nuxtApp: NuxtApp, method: N, shop: PublicShopConfig) => TakesParameters extends undefined ? () => Promise<TResult> : (params: P) => Promise<TResult>;
|
|
@@ -48,7 +48,7 @@ export declare const convertShopsToList: (shops: ShopConfig[] | ShopConfigIndexe
|
|
|
48
48
|
*
|
|
49
49
|
* @returns The API base path.
|
|
50
50
|
*/
|
|
51
|
-
export declare function getApiBasePath(storefrontConfig: ModuleBaseOptions, baseUrl: string): string;
|
|
51
|
+
export declare function getApiBasePath(storefrontConfig: Pick<ModuleBaseOptions, 'apiBasePath'>, baseUrl: string): string;
|
|
52
52
|
/**
|
|
53
53
|
* Retrieves the current shop configuration for a given request.
|
|
54
54
|
*
|
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Extends a Promise and its resolved value with properties from a source object.
|
|
3
|
+
*
|
|
4
|
+
* This effectively allows to treat a Promise as a regular object and
|
|
5
|
+
* extend it with custom properties, while maintaining its asynchronous behavior.
|
|
6
|
+
* These added properties are then available on the Promise itself as well as on its resolved value.
|
|
7
|
+
*
|
|
8
|
+
* @template T The type of the `Promise` and its resolved value. This should be an object type.
|
|
9
|
+
* @template U The type of the source object.
|
|
10
|
+
*
|
|
11
|
+
* @param promise The original Promise. The Promise's resolved value must have the same interface as the Promise itself.
|
|
12
|
+
* @param source The source object to merge with the Promise and its resolved value.
|
|
13
|
+
*
|
|
14
|
+
* @returns A new Promise with the properties of both the original Promise and the `source` object.
|
|
15
|
+
* The resolved value of the new Promise also includes the merged properties.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const originalPromise = Promise.resolve({ initial: 'value' }) as { initial: string } & Promise<{ initial: string }>
|
|
20
|
+
* const sourceObject = { added: 'objectProperty' }
|
|
21
|
+
* const extendedPromise = extendPromise(originalPromise, sourceObject)
|
|
22
|
+
*
|
|
23
|
+
* // Access `added` property directly on the Promise:
|
|
24
|
+
* console.log(extendedPromise.added) // 'objectProperty'
|
|
25
|
+
*
|
|
26
|
+
* extendedPromise.then(result => {
|
|
27
|
+
* // Access added property on the resolved value:
|
|
28
|
+
* console.log(result.initial) // 'value'
|
|
29
|
+
* console.log(result.added) // 'objectProperty'
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
8
32
|
*/
|
|
9
33
|
export declare function extendPromise<T extends object, U>(promise: T & Promise<T>, source: U): T & U & Promise<T & U>;
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import type { LocationQuery } from 'vue-router';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the current page number from the Vue Router query object.
|
|
4
|
+
*
|
|
5
|
+
* This function attempts to extract the 'page' parameter from the provided `query` object.
|
|
6
|
+
* It handles cases where the 'page' parameter is a string and parses it as an integer.
|
|
7
|
+
* If the 'page' parameter is not a string or not present, it returns undefined.
|
|
8
|
+
*
|
|
9
|
+
* @param query The Vue Router query object.
|
|
10
|
+
*
|
|
11
|
+
* @returns The current page number as a number, or undefined if not found or invalid.
|
|
12
|
+
*/
|
|
2
13
|
export declare const getCurrentPage: (query: LocationQuery) => number | undefined;
|
|
@@ -12,4 +12,17 @@ import type { BreadcrumbItem } from '@scayle/storefront-core';
|
|
|
12
12
|
* @returns The sanitized URL.
|
|
13
13
|
*/
|
|
14
14
|
export declare const sanitizeCanonicalURL: (url: string, whitelistParams?: string[]) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a BreadcrumbList schema for structured data based on an array of BreadcrumbItems.
|
|
17
|
+
*
|
|
18
|
+
* This function iterates through the provided `breadcrumbs` array and creates a
|
|
19
|
+
* `BreadcrumbList` object conforming to the schema.org specification.
|
|
20
|
+
* Each breadcrumb item is transformed into a `ListItem` with its position, name, and URL.
|
|
21
|
+
*
|
|
22
|
+
* @see https://schema.org/BreadcrumbList
|
|
23
|
+
*
|
|
24
|
+
* @param breadcrumbs An array of breadcrumb items used to generate the schema.
|
|
25
|
+
*
|
|
26
|
+
* @returns A BreadcrumbList schema object ready to be included in structured data.
|
|
27
|
+
*/
|
|
15
28
|
export declare const generateCategoryBreadcrumbSchema: (breadcrumbs: BreadcrumbItem[]) => WithContext<BreadcrumbList>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.11.0",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@opentelemetry/api": "^1.9.0",
|
|
74
74
|
"@scayle/h3-session": "0.6.0",
|
|
75
|
-
"@scayle/storefront-core": "8.
|
|
76
|
-
"@scayle/unstorage-compression-driver": "^0.2.
|
|
77
|
-
"@vercel/nft": "0.29.
|
|
75
|
+
"@scayle/storefront-core": "8.9.0",
|
|
76
|
+
"@scayle/unstorage-compression-driver": "^0.2.4",
|
|
77
|
+
"@vercel/nft": "0.29.2",
|
|
78
78
|
"@vueuse/core": "12.7.0",
|
|
79
79
|
"consola": "^3.2.3",
|
|
80
80
|
"core-js": "^3.37.1",
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
"@nuxt/kit": "3.14.1592",
|
|
96
96
|
"@nuxt/module-builder": "0.8.4",
|
|
97
97
|
"@nuxt/schema": "3.14.1592",
|
|
98
|
-
"@nuxt/test-utils": "3.
|
|
98
|
+
"@nuxt/test-utils": "3.17.0",
|
|
99
99
|
"@scayle/eslint-config-storefront": "4.4.1",
|
|
100
100
|
"@scayle/eslint-plugin-vue-composable": "0.2.1",
|
|
101
|
-
"@types/node": "22.13.
|
|
101
|
+
"@types/node": "22.13.5",
|
|
102
102
|
"dprint": "0.49.0",
|
|
103
|
-
"eslint": "9.
|
|
103
|
+
"eslint": "9.21.0",
|
|
104
104
|
"eslint-formatter-gitlab": "5.1.0",
|
|
105
105
|
"fishery": "2.2.3",
|
|
106
106
|
"h3": "1.15.0",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"nuxt": "3.14.1592",
|
|
111
111
|
"publint": "0.2.12",
|
|
112
112
|
"typescript": "5.7.3",
|
|
113
|
-
"vue-tsc": "2.2.
|
|
113
|
+
"vue-tsc": "2.2.4",
|
|
114
114
|
"vitest": "2.1.9"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|