@scayle/storefront-nuxt 7.62.4 → 7.64.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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.64.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `useStorefrontSearch` composable
8
+
9
+ ## 7.63.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Add support for dynamically adding query parameters to the IDP redirect callback URLs to be read back when the user returns from the IDP.
14
+
15
+ ```ts
16
+ const { data: externalIDPRedirects } = await useIDP({
17
+ queryParams: { redirectTo: '/account' },
18
+ })
19
+ ```
20
+
21
+ Please note that `code` and `state` are not supported as these are used by the SCAYLE Authentication API.
22
+
23
+ ### Patch Changes
24
+
25
+ - Avoid querying for redirects on pages matching the `/__nuxt_error` pattern.
26
+ - Updated dependencies
27
+ - @scayle/storefront-core@7.48.0
28
+
3
29
  ## 7.62.4
4
30
 
5
31
  ### Patch Changes
@@ -650,8 +676,8 @@ There is an `unwrap` function exported by this package (>=7.55.0) that can be us
650
676
 
651
677
  ### Minor Changes
652
678
 
653
- - - Add promotion data to the `addItemToBasket` method
654
- - - Add `usePromotions`, `useCurrentPromotions` & `usePromotionsByIds` composables
679
+ - Add promotion data to the `addItemToBasket` method
680
+ - Add `usePromotions`, `useCurrentPromotions` & `usePromotionsByIds` composables
655
681
 
656
682
  ### Patch Changes
657
683
 
@@ -1150,8 +1176,8 @@ There is an `unwrap` function exported by this package (>=7.55.0) that can be us
1150
1176
 
1151
1177
  ### Minor Changes
1152
1178
 
1153
- - - Add possibility to define the session config on application and store level.
1154
- - Add possibility to configure the `domain` attribute of the session cookie
1179
+ - Add possibility to define the session config on application and store level.
1180
+ - Add possibility to configure the `domain` attribute of the session cookie
1155
1181
 
1156
1182
  ## 7.0.0
1157
1183
 
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.9.0"
6
6
  },
7
- "version": "7.62.3"
7
+ "version": "7.63.0"
8
8
  }
@@ -1,4 +1,4 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<boolean | string[] | import("@scayle/storefront-core").ShopUser | import("@scayle/storefront-core").Product | import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant> | {
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<boolean | void | string[] | import("@scayle/storefront-core").ShopUser | import("@scayle/storefront-core").Product | import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant> | {
2
2
  type: "failure";
3
3
  statusCode: number;
4
4
  basket: import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>;
@@ -37,5 +37,5 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
37
37
  [k: string]: string;
38
38
  } | {
39
39
  message: string;
40
- } | null | undefined>>;
40
+ } | null>>;
41
41
  export default _default;
@@ -1,4 +1,6 @@
1
- export declare const useIDP: () => Promise<{
1
+ import { type MaybeRefOrGetter } from 'vue';
2
+ import type { RpcMethodParameters } from '@scayle/storefront-core';
3
+ export declare const useIDP: (params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>) => Promise<{
2
4
  data: import("vue").Ref<{
3
5
  [k: string]: string;
4
6
  } | undefined>;
@@ -3,12 +3,13 @@ import { useRpc } from "../core/useRpc.mjs";
3
3
  import { rpcCall } from "./../../rpc/rpcCall.mjs";
4
4
  import { useCurrentShop } from "./useCurrentShop.mjs";
5
5
  import { toValue } from "#imports";
6
- export const useIDP = async () => {
6
+ export const useIDP = async (params = {}) => {
7
7
  const nuxtApp = useNuxtApp();
8
8
  const shop = useCurrentShop();
9
9
  const { data, fetching, fetch, error, status } = await useRpc(
10
10
  "getExternalIdpRedirect",
11
- "getExternalIdpRedirect"
11
+ `getExternalIdpRedirect-${JSON.stringify(toValue(params))}`,
12
+ params
12
13
  );
13
14
  const handleIDPLoginCallback = rpcCall(
14
15
  nuxtApp,
@@ -18,7 +18,7 @@ export declare function useBasket({ params, key, }?: UseBasketOptions): Promise<
18
18
  count: import("vue").ComputedRef<number | undefined>;
19
19
  countWithoutSoldOutItems: import("vue").ComputedRef<number | undefined>;
20
20
  addItem: ({ variantId, promotionId, quantity, existingItemHandling, displayData, customData, itemGroup, }: AddOrUpdateItemType & {
21
- existingItemHandling?: 0 | 1 | 2 | 3 | undefined;
21
+ existingItemHandling?: ExistingItemHandling;
22
22
  }) => Promise<void>;
23
23
  addItems: (items: AddOrUpdateItemType[], existingItemHandling?: 1) => Promise<void>;
24
24
  removeItem: (item: {
@@ -1,12 +1,13 @@
1
- import { type SearchInput, type SearchOptions } from '@scayle/storefront-core';
1
+ import { type SearchInput, type SearchOptions, type TypeaheadSuggestionsEndpointResponseData } from '@scayle/storefront-core';
2
2
  type Options = Partial<{
3
3
  params: SearchOptions;
4
4
  key: string;
5
5
  }>;
6
+ /** @deprecated `useSearch` is deprecated. Please, use `useSearchSuggestions` or `useSearchResolve` */
6
7
  export declare const useSearch: ({ params, key }?: Options) => {
7
- data: any;
8
- pending: any;
9
- searchQuery: any;
8
+ data: import("vue").Ref<TypeaheadSuggestionsEndpointResponseData | undefined>;
9
+ pending: import("vue").Ref<boolean>;
10
+ searchQuery: import("vue").Ref<string>;
10
11
  resetSearch: () => void;
11
12
  search: ({ term, slug, productLimit }: SearchInput) => Promise<void>;
12
13
  };
@@ -1,6 +1,7 @@
1
+ import { useState } from "nuxt/app";
1
2
  import { rpcCall } from "../../rpc/rpcCall.mjs";
2
3
  import { useCurrentShop } from "../core/useCurrentShop.mjs";
3
- import { useState, useNuxtApp, toValue } from "#imports";
4
+ import { useNuxtApp, toValue } from "#imports";
4
5
  export const useSearch = ({ params, key = "search" } = {}) => {
5
6
  const data = useState(
6
7
  `${key}-data`,
@@ -0,0 +1,15 @@
1
+ import { type SearchV2SuggestionsEndpointResponseData, type SearchV2With } from '@scayle/storefront-core';
2
+ export type SearchOptions = Partial<{
3
+ params: Partial<{
4
+ categoryId: number;
5
+ with: SearchV2With;
6
+ }>;
7
+ key: string;
8
+ }>;
9
+ export declare const useStorefrontSearch: (searchQuery: Ref<string>, { params, key }?: SearchOptions) => {
10
+ data: import("vue").Ref<SearchV2SuggestionsEndpointResponseData | undefined>;
11
+ pending: import("vue").Ref<boolean>;
12
+ resetSearch: () => void;
13
+ getSearchSuggestions: () => Promise<void>;
14
+ resolveSearch: () => Promise<import("@scayle/storefront-core").SearchEntity | null | undefined>;
15
+ };
@@ -0,0 +1,64 @@
1
+ import { useState } from "nuxt/app";
2
+ import { rpcCall } from "../../rpc/rpcCall.mjs";
3
+ import { useCurrentShop } from "../core/useCurrentShop.mjs";
4
+ import { useNuxtApp, toValue } from "#imports";
5
+ export const useStorefrontSearch = (searchQuery, { params, key = "search" } = {}) => {
6
+ const data = useState(
7
+ `${key}-data`,
8
+ () => void 0
9
+ );
10
+ const nuxtApp = useNuxtApp();
11
+ const pending = useState(`${key}-pending`, () => false);
12
+ const error = useState(
13
+ `${key}-error`,
14
+ () => void 0
15
+ );
16
+ const status = useState(`${key}-error`, () => "idle");
17
+ const shop = useCurrentShop();
18
+ const getSearchSuggestions = async () => {
19
+ pending.value = true;
20
+ status.value = "pending";
21
+ if (!searchQuery.value) {
22
+ return;
23
+ }
24
+ try {
25
+ data.value = await rpcCall(
26
+ nuxtApp,
27
+ "getSearchSuggestions",
28
+ toValue(shop)
29
+ )({
30
+ term: String(searchQuery.value),
31
+ ...params
32
+ });
33
+ } catch (e) {
34
+ error.value = e;
35
+ } finally {
36
+ pending.value = false;
37
+ status.value = error.value ? "error" : "success";
38
+ }
39
+ };
40
+ const resolveSearch = async () => {
41
+ if (!searchQuery.value) {
42
+ return;
43
+ }
44
+ return await rpcCall(
45
+ nuxtApp,
46
+ "resolveSearch",
47
+ toValue(shop)
48
+ )({
49
+ term: searchQuery.value,
50
+ ...params
51
+ });
52
+ };
53
+ const resetSearch = () => {
54
+ searchQuery.value = "";
55
+ data.value = { suggestions: [] };
56
+ };
57
+ return {
58
+ data,
59
+ pending,
60
+ resetSearch,
61
+ getSearchSuggestions,
62
+ resolveSearch
63
+ };
64
+ };
@@ -105,14 +105,12 @@ async function bootstrap(event, $shopConfig, $storefrontConfig, apiBasePath, con
105
105
  }
106
106
  function getBootstrapPath(event) {
107
107
  const url = getRequestURL(event);
108
- if (url.pathname === "/__nuxt_error") {
109
- return url.searchParams.get("url") ?? url.pathname;
110
- }
111
- return url.pathname;
108
+ const path = url.pathname === "/__nuxt_error" ? url.searchParams.get("url") ?? url.pathname : url.pathname;
109
+ return { path, originalPath: url.pathname };
112
110
  }
113
111
  export default defineEventHandler(async (event) => {
114
112
  try {
115
- const path = getBootstrapPath(event);
113
+ const { path, originalPath } = getBootstrapPath(event);
116
114
  if (path.startsWith("/__nuxt")) {
117
115
  return;
118
116
  }
@@ -133,7 +131,7 @@ export default defineEventHandler(async (event) => {
133
131
  config
134
132
  );
135
133
  }
136
- if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath)) {
134
+ if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath) && originalPath !== "/__nuxt_error") {
137
135
  await useRedirects(event);
138
136
  }
139
137
  } catch (e) {
@@ -18,7 +18,9 @@ async function fetchRedirectWithCache(sourceUrl, bapiClient, redirectCache, log)
18
18
  try {
19
19
  bapiResult = await bapiClient.redirects.post(sourceUrl);
20
20
  } catch (error) {
21
- log.error(`Error: Failed to fetch redirects ... ${error}`);
21
+ log.error(
22
+ `Error: Failed to fetch redirects ... ${error} for sourceURL: ${sourceUrl}`
23
+ );
22
24
  return null;
23
25
  }
24
26
  const isValidRedirect = (redirect) => {
@@ -67,17 +69,17 @@ export async function useRedirects(event) {
67
69
  log.info(`There are multiple valid redirects for: ${url.toString()}`);
68
70
  }
69
71
  const redirect = relativeRedirect ?? absoluteRedirect;
72
+ if (!redirect) {
73
+ log.debug(`There are no valid redirects for: ${url.toString()}`);
74
+ return;
75
+ }
70
76
  try {
71
- if (redirect?.target) {
72
- log.debug(`Redirecting to ${redirect.target}`);
73
- await sendRedirect(
74
- event,
75
- getTargetLocation(url, redirect.target, queryParamWhitelist),
76
- redirect.statusCode
77
- );
78
- } else {
79
- log.debug(`No redirect found`);
80
- }
77
+ log.debug(`Redirecting to ${redirect.target}`);
78
+ await sendRedirect(
79
+ event,
80
+ getTargetLocation(url, redirect.target, queryParamWhitelist),
81
+ redirect.statusCode
82
+ );
81
83
  } catch (error) {
82
84
  log.error(`Error: Failed to execute redirect ... ${error}`);
83
85
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.62.4",
4
+ "version": "7.64.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -62,7 +62,7 @@
62
62
  "dependencies": {
63
63
  "@nuxt/kit": "3.11.1",
64
64
  "@scayle/h3-session": "0.3.5",
65
- "@scayle/storefront-core": "7.47.0",
65
+ "@scayle/storefront-core": "7.48.0",
66
66
  "@scayle/unstorage-compression-driver": "0.1.2",
67
67
  "@vueuse/core": "10.9.0",
68
68
  "consola": "3.2.3",
@@ -85,7 +85,7 @@
85
85
  "@scayle/eslint-config-storefront": "3.2.6",
86
86
  "@scayle/eslint-plugin-vue-composable": "0.1.1",
87
87
  "@scayle/prettier-config-storefront": "2.0.2",
88
- "@types/node": "20.12.3",
88
+ "@types/node": "20.12.5",
89
89
  "eslint": "8.57.0",
90
90
  "eslint-formatter-gitlab": "5.1.0",
91
91
  "h3": "1.11.1",
@@ -94,7 +94,7 @@
94
94
  "prettier": "3.0.0",
95
95
  "publint": "0.2.7",
96
96
  "vitest": "1.4.0",
97
- "vue-tsc": "2.0.7"
97
+ "vue-tsc": "2.0.11"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "h3": "^1.10.0",
@@ -109,6 +109,6 @@
109
109
  "@nuxt/schema": "3.11.1"
110
110
  },
111
111
  "volta": {
112
- "node": "20.12.0"
112
+ "node": "20.12.1"
113
113
  }
114
114
  }