@scayle/storefront-nuxt 8.10.1 → 8.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/index.d.mts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/module.d.mts +32 -2
  5. package/dist/module.d.ts +32 -2
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +6 -1
  8. package/dist/runtime/campaignKey.d.ts +1 -4
  9. package/dist/runtime/campaignKey.js +5 -17
  10. package/dist/runtime/context.js +1 -1
  11. package/dist/runtime/error/handler.d.ts +7 -0
  12. package/dist/runtime/nitro/plugins/cacheRuntimeConfig.d.ts +12 -0
  13. package/dist/runtime/nitro/plugins/configValidation.d.ts +39 -0
  14. package/dist/runtime/nitro/plugins/nitroLogger.d.ts +8 -0
  15. package/dist/runtime/nitro/plugins/nitroRuntimeStorageConfig.d.ts +10 -0
  16. package/dist/runtime/nitro/plugins/nitroSetXPoweredByHeader.d.ts +7 -0
  17. package/dist/runtime/plugin/log.client.d.ts +12 -0
  18. package/dist/runtime/plugin/log.server.d.ts +12 -0
  19. package/dist/runtime/plugin/shop.d.ts +15 -0
  20. package/dist/runtime/server/middleware/bootstrap-utils.d.ts +62 -0
  21. package/dist/runtime/server/middleware/bootstrap.d.ts +33 -0
  22. package/dist/runtime/server/middleware/redirects.d.ts +13 -0
  23. package/dist/runtime/server/middleware/redirects.utils.d.ts +19 -9
  24. package/dist/runtime/server/utils/cacheStorage.d.ts +14 -8
  25. package/dist/runtime/utils/seo.d.ts +11 -0
  26. package/dist/shared/storefront-nuxt.b72fefd0.d.mts +267 -0
  27. package/dist/shared/storefront-nuxt.b72fefd0.d.ts +267 -0
  28. package/dist/test/factories.d.mts +1 -1
  29. package/dist/test/factories.d.ts +1 -1
  30. package/package.json +4 -4
  31. package/dist/shared/storefront-nuxt.a816664e.d.mts +0 -81
  32. package/dist/shared/storefront-nuxt.a816664e.d.ts +0 -81
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 8.10.3
4
+
5
+ ### Patch Changes
6
+
7
+ **Dependencies**
8
+
9
+ - Updated dependency to @scayle/storefront-core@8.8.0
10
+
11
+ ## 8.10.2
12
+
13
+ ### Patch Changes
14
+
15
+ **Dependencies**
16
+
17
+ - Updated dependency to @scayle/storefront-core@8.7.1
18
+
3
19
  ## 8.10.1
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.mjs';
1
+ export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.b72fefd0.mjs';
2
2
  export { ModuleHooks } from './module.mjs';
3
3
  export { rpcCall } from '../dist/runtime/rpc/rpcCall.js';
4
4
  export { extendPromise } from '../dist/runtime/utils/promise.js';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.js';
1
+ export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.b72fefd0.js';
2
2
  export { ModuleHooks } from './module.js';
3
3
  export { rpcCall } from '../dist/runtime/rpc/rpcCall.js';
4
4
  export { extendPromise } from '../dist/runtime/utils/promise.js';
package/dist/module.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HookResult } from '@nuxt/schema';
3
- import { M as ModuleBaseOptions } from './shared/storefront-nuxt.a816664e.mjs';
4
- export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.mjs';
3
+ import { M as ModuleBaseOptions } from './shared/storefront-nuxt.b72fefd0.mjs';
4
+ export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.b72fefd0.mjs';
5
5
  export { LogLevel } from '@scayle/storefront-core';
6
6
  import '@scayle/unstorage-compression-driver';
7
7
  import 'unstorage';
@@ -26,6 +26,36 @@ declare module '@nuxt/schema' {
26
26
  interface NuxtHooks extends ModuleHooks {
27
27
  }
28
28
  }
29
+ /**
30
+ * Defines the Storefront Nuxt module (`@scayle/storefront-nuxt`).
31
+ *
32
+ * @param options Module base options.
33
+ * @param options.session The session configuration.
34
+ * @param options.session.cookieName The name of the session cookie.
35
+ * @param options.session.sameSite The SameSite attribute for the session cookie.
36
+ * @param options.shopSelector The shop selector.
37
+ * @param options.oauth The OAuth configuration.
38
+ * @param options.oauth.apiHost The API host.
39
+ * @param options.oauth.clientId The client ID.
40
+ * @param options.oauth.clientSecret The client secret.
41
+ * @param options.idp The IDP configuration.
42
+ * @param options.idp.enabled Whether IDP is enabled.
43
+ * @param options.idp.idpKeys The IDP keys.
44
+ * @param options.idp.idpRedirectURL The IDP redirect URL.
45
+ * @param options.appKeys The application keys configuration.
46
+ * @param options.appKeys.wishlistKey The wishlist key.
47
+ * @param options.appKeys.basketKey The basket key.
48
+ * @param options.appKeys.hashAlgorithm The hash algorithm.
49
+ * @param options.legacy The legacy configuration.
50
+ * @param options.legacy.enableSessionMigration Whether session migration is enabled.
51
+ * @param options.rpcMethodNames The RPC method names.
52
+ * @param options.rpcDir The RPC directory.
53
+ * @param options.rpcMethodOverrides RPC method overrides.
54
+ * @param options.shops The shops configuration.
55
+ * @param options.storage The storage configuration.
56
+ *
57
+ * @returns The Nuxt module.
58
+ */
29
59
  declare const _default: _nuxt_schema.NuxtModule<ModuleBaseOptions, ModuleBaseOptions, false>;
30
60
 
31
61
  export { ModuleBaseOptions, type ModuleHooks, _default as default };
package/dist/module.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HookResult } from '@nuxt/schema';
3
- import { M as ModuleBaseOptions } from './shared/storefront-nuxt.a816664e.js';
4
- export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.js';
3
+ import { M as ModuleBaseOptions } from './shared/storefront-nuxt.b72fefd0.js';
4
+ export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.b72fefd0.js';
5
5
  export { LogLevel } from '@scayle/storefront-core';
6
6
  import '@scayle/unstorage-compression-driver';
7
7
  import 'unstorage';
@@ -26,6 +26,36 @@ declare module '@nuxt/schema' {
26
26
  interface NuxtHooks extends ModuleHooks {
27
27
  }
28
28
  }
29
+ /**
30
+ * Defines the Storefront Nuxt module (`@scayle/storefront-nuxt`).
31
+ *
32
+ * @param options Module base options.
33
+ * @param options.session The session configuration.
34
+ * @param options.session.cookieName The name of the session cookie.
35
+ * @param options.session.sameSite The SameSite attribute for the session cookie.
36
+ * @param options.shopSelector The shop selector.
37
+ * @param options.oauth The OAuth configuration.
38
+ * @param options.oauth.apiHost The API host.
39
+ * @param options.oauth.clientId The client ID.
40
+ * @param options.oauth.clientSecret The client secret.
41
+ * @param options.idp The IDP configuration.
42
+ * @param options.idp.enabled Whether IDP is enabled.
43
+ * @param options.idp.idpKeys The IDP keys.
44
+ * @param options.idp.idpRedirectURL The IDP redirect URL.
45
+ * @param options.appKeys The application keys configuration.
46
+ * @param options.appKeys.wishlistKey The wishlist key.
47
+ * @param options.appKeys.basketKey The basket key.
48
+ * @param options.appKeys.hashAlgorithm The hash algorithm.
49
+ * @param options.legacy The legacy configuration.
50
+ * @param options.legacy.enableSessionMigration Whether session migration is enabled.
51
+ * @param options.rpcMethodNames The RPC method names.
52
+ * @param options.rpcDir The RPC directory.
53
+ * @param options.rpcMethodOverrides RPC method overrides.
54
+ * @param options.shops The shops configuration.
55
+ * @param options.storage The storage configuration.
56
+ *
57
+ * @returns The Nuxt module.
58
+ */
29
59
  declare const _default: _nuxt_schema.NuxtModule<ModuleBaseOptions, ModuleBaseOptions, false>;
30
60
 
31
61
  export { ModuleBaseOptions, type ModuleHooks, _default as default };
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "8.10.1",
3
+ "version": "8.10.3",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -46,7 +46,7 @@ export default {
46
46
  }`;
47
47
  }
48
48
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
49
- const PACKAGE_VERSION = "8.10.1";
49
+ const PACKAGE_VERSION = "8.10.3";
50
50
  const logger = createConsola({
51
51
  fancy: true,
52
52
  formatOptions: {
@@ -232,6 +232,11 @@ const module = defineNuxtModule({
232
232
  legacy: {
233
233
  enableSessionMigration: false
234
234
  },
235
+ /**
236
+ * The internal access header.
237
+ *
238
+ * @hidden
239
+ */
235
240
  internalAccessHeader: ""
236
241
  },
237
242
  async setup(options, nuxt) {
@@ -1,5 +1,2 @@
1
- import type { StorefrontAPIClient, CachedType, Campaign, Log } from '@scayle/storefront-core';
2
- export declare const isCampaignActive: (campaign?: Campaign) => boolean;
3
- export declare const campaignHasNotEnded: (campaign: Campaign) => boolean;
4
- export declare const sortCampaignsByDateAscending: (a: Campaign, b: Campaign) => number;
1
+ import type { StorefrontAPIClient, CachedType, Log } from '@scayle/storefront-core';
5
2
  export declare const fetchCampaignKey: (sapiClient: StorefrontAPIClient, cached: CachedType, log: Log) => Promise<string | undefined>;
@@ -1,20 +1,8 @@
1
- export const isCampaignActive = (campaign) => {
2
- if (!campaign) {
3
- return false;
4
- }
5
- const timeNow = Date.now();
6
- const campaignStart = new Date(campaign.start_at).getTime();
7
- const hasStarted = timeNow >= campaignStart;
8
- const campaignEnd = new Date(campaign.end_at).getTime();
9
- const hasEnded = timeNow >= campaignEnd;
10
- return hasStarted && !hasEnded;
11
- };
12
- export const campaignHasNotEnded = (campaign) => {
13
- return new Date(campaign.end_at).getTime() > Date.now();
14
- };
15
- export const sortCampaignsByDateAscending = (a, b) => {
16
- return new Date(a.start_at).getTime() - new Date(b.start_at).getTime();
17
- };
1
+ import {
2
+ isCampaignActive,
3
+ campaignHasNotEnded,
4
+ sortCampaignsByDateAscending
5
+ } from "@scayle/storefront-core";
18
6
  export const fetchCampaignKey = async (sapiClient, cached, log) => {
19
7
  try {
20
8
  const { campaigns } = await cached(async () => {
@@ -8,8 +8,8 @@ import {
8
8
  generateWishlistKey
9
9
  } from "@scayle/storefront-core/dist/utils/keys";
10
10
  import { useNitroApp } from "nitropack/runtime";
11
- import { fetchCampaignKey } from "./campaignKey.js";
12
11
  import { getCachedFunction } from "./cached.js";
12
+ import { fetchCampaignKey } from "./campaignKey.js";
13
13
  async function getWishlistKey(appKeys, session, $log, $shopConfig) {
14
14
  return session.data.user ? await generateWishlistKey({
15
15
  keyTemplate: appKeys.wishlistKey,
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Resolves an error, providing a standardized error object with status code, message, and name.
3
+ *
4
+ * @param error The error to resolve. Can be a generic `Error` or an unknown error type.
5
+ *
6
+ * @returns A standardized error object with statusCode, statusMessage, and name.
7
+ */
1
8
  declare const resolveError: (error: Error | unknown) => {
2
9
  statusCode: 100 | 101 | 102 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 506 | 507 | 508 | 510 | 511 | 306 | 505;
3
10
  statusMessage: string;
@@ -1,2 +1,14 @@
1
+ /**
2
+ * Nitro plugin to cache the runtime config.
3
+ *
4
+ * Caches the runtime config at startup to avoid reading it for every request.
5
+ *
6
+ * @see https://nitro.build/guide/configuration#runtime-configuration
7
+ * @see https://nitro.build/guide/plugins
8
+ *
9
+ * @param nitroApp The nitro app instance.
10
+ *
11
+ * @returns Nitro plugin function
12
+ */
1
13
  declare const _default: import("nitropack").NitroAppPlugin;
2
14
  export default _default;
@@ -1,12 +1,51 @@
1
1
  import type { RuntimeConfig } from '@nuxt/schema';
2
2
  import type { ZodIssue } from 'zod';
3
+ /**
4
+ * List of keys considered sensitive.
5
+ * These keys will have their values redacted in logs.
6
+ */
3
7
  export declare const sensitiveKeys: string[];
8
+ /**
9
+ * Gets a value from a nested object using a path array.
10
+ *
11
+ * @param object The object to traverse.
12
+ * @param pathArray The array of keys representing the path to the value.
13
+ *
14
+ * @returns The value at the specified path, stringified.
15
+ */
4
16
  export declare const getValue: (object: Record<string | number, unknown>, pathArray: (string | number)[]) => string;
17
+ /**
18
+ * Formats Zod errors for display, redacting sensitive values.
19
+ *
20
+ * @see https://zod.dev/ERROR_HANDLING?id=zodissue
21
+ *
22
+ * @param issues An array of Zod issues.
23
+ * @param issues[].code The error code.
24
+ * @param issues[].path The path to the error in the object.
25
+ * @param issues[].message The error message.
26
+ * @param issues[].unionErrors Errors from union types.
27
+ * @param runtimeConfig The runtime config object.
28
+ *
29
+ * @returns An array of formatted error messages.
30
+ */
5
31
  export declare const formatZodError: (issues: Array<ZodIssue>, runtimeConfig: RuntimeConfig) => (ZodIssue | {
6
32
  code: string;
7
33
  path: string;
8
34
  message: string;
9
35
  value?: string;
10
36
  })[];
37
+ /**
38
+ * Nitro plugin to validate the runtime config against a Zod schema.
39
+ *
40
+ * Validates the runtime configuration using the `RuntimeConfigSchema` and logs
41
+ * success or failure messages to the console. Throws an error if the
42
+ * validation fails.
43
+ *
44
+ * @see https://nitro.build/guide/plugins
45
+ *
46
+ * @returns Nitro plugin function
47
+ *
48
+ * @throws {Error} If runtimeConfig validations fails.
49
+ */
11
50
  declare const _default: import("nitropack").NitroAppPlugin;
12
51
  export default _default;
@@ -4,5 +4,13 @@ declare module 'h3' {
4
4
  $log: Log;
5
5
  }
6
6
  }
7
+ /**
8
+ * Nitro plugin to initialize and inject a logger instance into the request context.
9
+ *
10
+ * @param nitroApp The nitro app instance.
11
+ *
12
+ * @see https://nitro.build/guide/configuration#runtime-configuration
13
+ * @see https://nitro.build/guide/plugins
14
+ */
7
15
  declare const _default: import("nitropack").NitroAppPlugin;
8
16
  export default _default;
@@ -1,2 +1,12 @@
1
+ /**
2
+ * Nitro plugin to mount an [unstorage](https://unstorage.unjs.io/) storage.
3
+ *
4
+ * This plugin mounts the necessary storage instances based on the
5
+ * provided configuration for cache and session storage.
6
+ * It iterates through the shops and mounts their individual storage as well.
7
+ *
8
+ * @see https://nitro.build/guide/configuration#runtime-configuration
9
+ * @see https://nitro.build/guide/plugins
10
+ */
1
11
  declare const _default: import("nitropack").NitroAppPlugin;
2
12
  export default _default;
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Nitro plugin to set the `x-powered-by` header.
3
+ *
4
+ * @see https://nitro.build/guide/plugins
5
+ *
6
+ * @param nitroApp The nitro app instance.
7
+ */
1
8
  declare const _default: import("nitropack").NitroAppPlugin;
2
9
  export default _default;
@@ -1,4 +1,16 @@
1
1
  import type { Log } from '@scayle/storefront-core';
2
+ /**
3
+ * Nuxt plugin to provide logging functionality for the client-environment (VueApp).
4
+ *
5
+ * This plugin initializes a client-side logger using `consola` and adds error handling to the Vue app.
6
+ * It provides `log` and `coreLog` instances.
7
+ *
8
+ * @see https://nuxt.com/docs/guide/directory-structure/plugins#providing-helpers
9
+ *
10
+ * @param nuxtApp The Nuxt app instance.
11
+ *
12
+ * @returns helper on the `NuxtApp` containing the 'log' and 'coreLog' instances.
13
+ */
2
14
  declare const _default: import("#app/nuxt").Plugin<{
3
15
  log: Log;
4
16
  coreLog: Log;
@@ -1,3 +1,15 @@
1
+ /**
2
+ * Nuxt plugin to provide logging functionality for the server-environment (NuxtApp).
3
+ *
4
+ * This plugin makes logging functions available through the Nuxt app instance.
5
+ * It retrieves the log instance from the server context during server-side rendering.
6
+ * If `ssrContext` is missing, it logs a warning.
7
+ *
8
+ * @see https://nuxt.com/docs/guide/directory-structure/plugins#providing-helpers
9
+ *
10
+ * @returns A helper on the `NuxtApp` containing the `log` and
11
+ * `coreLog`instances, or undefined if ssrContext is missing.
12
+ */
1
13
  declare const _default: import("#app/nuxt").Plugin<{
2
14
  log: import("@scayle/storefront-core").Log;
3
15
  coreLog: import("@scayle/storefront-core").Log;
@@ -1,3 +1,18 @@
1
+ /**
2
+ * Nuxt plugin to provide the current shop and available shops.
3
+ *
4
+ * This plugin makes the current shop and available shops accessible through the Nuxt app instance.
5
+ * It retrieves the shop data from the server context during server-side rendering and provides it to the client.
6
+ *
7
+ * @see https://nuxt.com/docs/guide/directory-structure/plugins#providing-helpers
8
+ *
9
+ * @returns A helper on the `NuxtApp` containing the `currentShop` and `availableShops`.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const { currentShop, availableShop } = useNuxtApp()
14
+ * ```
15
+ */
1
16
  declare const _default: import("#app/nuxt").Plugin<{
2
17
  currentShop: import("../..").PublicShopConfig;
3
18
  availableShops: import("../..").PublicShopConfig[];
@@ -1,15 +1,77 @@
1
1
  import { type H3Event } from 'h3';
2
2
  import type { ModuleBaseOptions, PublicShopConfig, ShopConfig, ShopConfigIndexed } from '../../../module.js';
3
3
  import type { NitroRuntimeConfigApp } from 'nitropack';
4
+ /**
5
+ * Represents the bootstrapped path information.
6
+ */
4
7
  type BootstrapPath = {
8
+ /** The bootstrapped path. */
5
9
  path: string;
10
+ /** The original request path. */
6
11
  originalPath: string;
7
12
  };
13
+ /**
14
+ * Gets the bootstrap path from the URL.
15
+ *
16
+ * Handles the special case of Nuxt error pages to extract the correct path for bootstrapping.
17
+ *
18
+ * @param url The request URL.
19
+ * @param baseUrl The base URL of the application.
20
+ *
21
+ * @returns A `BootstrapPath` object containing the resolved path and original path.
22
+ */
8
23
  export declare function getBootstrapPath(url: URL, baseUrl: string): BootstrapPath;
24
+ /**
25
+ * Gets the shop configuration based on the request path.
26
+ *
27
+ * @param event The H3 event object.
28
+ * @param shops An array of shop configurations.
29
+ * @param appBasePath The base path of the application.
30
+ *
31
+ * @returns The matching shop configuration, or undefined if not found.
32
+ */
9
33
  export declare const getShopByPath: (event: H3Event, shops: ShopConfig[], appBasePath: string) => ShopConfig | undefined;
34
+ /**
35
+ * Converts the shops configuration to a list.
36
+ * Handles cases where shops are provided as an array or an indexed object.
37
+ *
38
+ * @param shops The shops configuration, either as an array or an indexed object.
39
+ *
40
+ * @returns The shops as an array.
41
+ */
10
42
  export declare const convertShopsToList: (shops: ShopConfig[] | ShopConfigIndexed) => ShopConfig[];
43
+ /**
44
+ * Gets the API base path.
45
+ *
46
+ * @param storefrontConfig The storefront module configuration.
47
+ * @param baseUrl The base URL.
48
+ *
49
+ * @returns The API base path.
50
+ */
11
51
  export declare function getApiBasePath(storefrontConfig: ModuleBaseOptions, baseUrl: string): string;
52
+ /**
53
+ * Retrieves the current shop configuration for a given request.
54
+ *
55
+ * @param event The H3 event object.
56
+ * @param storefrontConfig The storefront configuration containing shop details and selector.
57
+ * @param runtimeConfig The Nitro runtime configuration.
58
+ *
59
+ * @returns The shop config for the current request if found or undefined.
60
+ */
12
61
  export declare function getCurrentShopConfigForRequest(event: H3Event, storefrontConfig: Pick<ModuleBaseOptions, 'shops' | 'shopSelector'>, runtimeConfig: NitroRuntimeConfigApp): ShopConfig | undefined;
62
+ /**
63
+ * Transforms shop configuration data into a public representation, including active status.
64
+ *
65
+ * Selects specific properties from the provided shop configuration (`data`) to create a public version suitable
66
+ * for client-side use. Also determines if the shop is currently active based on the `currentShopId`.
67
+ *
68
+ * @param data The shop configuration data.
69
+ * @param currentShopId The ID of the currently active shop.
70
+ * @param apiBasePath The base path for the API.
71
+ * @param publicShopData An optional array of additional shop configuration keys to include in the public data.
72
+ *
73
+ * @returns A public representation of the shop configuration, including an `isActive` flag.
74
+ */
13
75
  export declare function getPublicShopData(data: ShopConfig, currentShopId: number, apiBasePath: string, publicShopData?: (keyof ShopConfig)[]): PublicShopConfig & {
14
76
  isActive: boolean;
15
77
  };
@@ -1,7 +1,26 @@
1
1
  import type { ShopUser } from '@scayle/storefront-core';
2
+ /**
3
+ * Interface for shop session data.
4
+ *
5
+ * user: The shop user.
6
+ * accessToken: The access token.
7
+ * refreshToken: The refresh token.
8
+ * shopId: The shop ID.
9
+ */
2
10
  export interface ShopSessionData {
11
+ /**
12
+ * The shop user object containing detailed information about the current user.
13
+ */
3
14
  user?: ShopUser;
15
+ /**
16
+ * The OAuth 2.0 access token.
17
+ * @see https://www.rfc-editor.org/rfc/rfc6749#section-1.4
18
+ */
4
19
  accessToken?: string;
20
+ /**
21
+ * The OAuth 2.0 refresh token.
22
+ * @see https://www.rfc-editor.org/rfc/rfc6749#section-1.5
23
+ */
5
24
  refreshToken?: string;
6
25
  shopId?: number;
7
26
  }
@@ -9,5 +28,19 @@ declare module '@scayle/h3-session' {
9
28
  interface SessionDataT extends ShopSessionData {
10
29
  }
11
30
  }
31
+ /**
32
+ * Middleware handler for bootstrapping the application.
33
+ *
34
+ * This sets up the necessary context for incoming requests,
35
+ * including session management, caching, and routing.
36
+ * It handles redirects when enabled and logs errors encountered during the process.
37
+ * Internal Nuxt URLs, favicon requests, and the /api/up endpoint are skipped.
38
+ *
39
+ * @see https://h3.unjs.io/guide/event-handler
40
+ *
41
+ * @param event The [H3 event object](https://h3.unjs.io/guide/event).
42
+ *
43
+ * @throws {Error} If something went wrong.
44
+ */
12
45
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
13
46
  export default _default;
@@ -1,2 +1,15 @@
1
1
  import type { H3Event } from 'h3';
2
+ /**
3
+ * Handles redirects based on the provided event.
4
+ *
5
+ * This middleware function checks for redirects configured in the SCAYLE Panel
6
+ * by checking with the Storefront API and performs a redirect if a match is found.
7
+ * It utilizes a cache to store redirect results and falls back to the
8
+ * Storefront API if no cached redirect is available.
9
+ *
10
+ * @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/redirects#overview
11
+ * @see https://scayle.dev/en/user-guide/shops/storefront/redirects
12
+ *
13
+ * @param event The H3 event object.
14
+ */
2
15
  export declare function useRedirects(event: H3Event): Promise<void>;
@@ -1,18 +1,28 @@
1
1
  /**
2
- * Get a normalized URL in absolute and relative forms for redirect lookup
3
- * @param url
4
- * @param queryParamWhitelist
2
+ * Gets normalized URLs (absolute and relative) for redirect lookup.
3
+ *
4
+ * Normalizes the provided URL by removing trailing slashes and optionally filtering query parameters
5
+ * based on a whitelist. This prepares the URL for use in redirect lookups.
6
+ *
7
+ * @param url The incoming URL.
8
+ * @param queryParamWhitelist A set of query parameters to include in the lookup URL. Other parameters will be removed.
9
+ *
10
+ * @returns An object containing the relative and absolute normalized URLs.
5
11
  */
6
12
  export declare function getRedirectLookupUrls(url: URL, queryParamWhitelist?: Set<string>): {
7
13
  relativeSourceUrl: string;
8
14
  absoluteSourceUrl: string;
9
15
  };
10
16
  /**
11
- * Construct a URL string given a source URL and target redirect
12
- * Query params are copied from source to target (if the params are not whitelisted)
13
- * and source is used as the base URL if target is a relative redirect.
14
- * @param source
15
- * @param target
16
- * @param queryParamWhitelist
17
+ * Constructs a target URL for redirection, handling relative and absolute URLs and query parameters.
18
+ *
19
+ * Copies query parameters from the source URL to the target URL, unless they are present in the
20
+ * `queryParamWhitelist`. If the target is a relative URL, it uses the source URL as the base.
21
+ *
22
+ * @param source The source URL.
23
+ * @param target The target redirect URL (can be relative or absolute).
24
+ * @param queryParamWhitelist A set of query parameters to exclude from the final redirect URL.
25
+ *
26
+ * @returns The decoded target URL string.
17
27
  */
18
28
  export declare function getTargetLocation(source: URL, target: string, queryParamWhitelist?: Set<string>): string;
@@ -6,16 +6,22 @@ export declare const STORAGE_MOUNT_BASE = "storefront";
6
6
  export declare const STORAGE_MOUNT_CACHE = "storefront-cache";
7
7
  export declare const STORAGE_MOUNT_SESSION = "storefront-session";
8
8
  /**
9
- * Create an unstorage-backed cache interface
10
- * @param prefix
11
- * @param shopId
12
- * @param log
9
+ * Creates an Unstorage-backed cache interface.
10
+ *
11
+ * @param prefix The cache key prefix.
12
+ * @param shopId The shop ID.
13
+ * @param log The logger instance.
14
+ *
15
+ * @returns An UnstorageCache instance.
13
16
  */
14
17
  export declare function useCacheStorage(prefix: string, shopId: number, log: Log): UnstorageCache;
15
18
  /**
16
- * Create an unstorage-backed session cache interface
17
- * @param sessionConfig
18
- * @param shopId
19
- * @param log
19
+ * Creates an Unstorage-backed session store interface.
20
+ *
21
+ * @param sessionConfig The session configuration.
22
+ * @param shopId The shop ID.
23
+ * @param log The logger instance.
24
+ *
25
+ * @returns A session store instance.
20
26
  */
21
27
  export declare function useSessionStorage(sessionConfig: SessionConfig, shopId: number, log: Log): SessionStore;
@@ -1,4 +1,15 @@
1
1
  import type { WithContext, BreadcrumbList } from 'schema-dts';
2
2
  import type { BreadcrumbItem } from '@scayle/storefront-core';
3
+ /**
4
+ * Sanitizes a canonical URL by removing query parameters not present in the whitelist.
5
+ *
6
+ * This function parses the URL, filters the query parameters based on the provided whitelist,
7
+ * and then reconstructs the URL with only the allowed parameters.
8
+ *
9
+ * @param url The URL to sanitize.
10
+ * @param whitelistParams An array of query parameters to keep. Defaults to `CANONICAL_PARAMS_WHITELIST`.
11
+ *
12
+ * @returns The sanitized URL.
13
+ */
3
14
  export declare const sanitizeCanonicalURL: (url: string, whitelistParams?: string[]) => string;
4
15
  export declare const generateCategoryBreadcrumbSchema: (breadcrumbs: BreadcrumbItem[]) => WithContext<BreadcrumbList>;