@scayle/storefront-core 7.46.0 → 7.47.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,17 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.47.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `resolveSearch` and `getSearchSuggestions` RPC methods
8
+
9
+ ## 7.46.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Revert breaking change in `handleIDPLoginCallback` signature
14
+
3
15
  ## 7.46.0
4
16
 
5
17
  ### Minor Changes
@@ -1,7 +1,4 @@
1
- import type { BasketWith } from '@aboutyou/backbone/endpoints/basket/getBasket';
2
- import type { ProductWith } from '@aboutyou/backbone/types/ProductWith';
3
- import type { WishlistWith } from '@aboutyou/backbone/endpoints/wishlist/getWishlist';
4
- import { SearchWith } from '../types';
1
+ import type { SearchWith, BasketWith, ProductWith, WishlistWith } from '../types';
5
2
  declare const DEFAULT_WITH_LISTING: {
6
3
  items: {
7
4
  product: {
@@ -40,11 +40,10 @@ const getExternalIdpRedirect = exports.getExternalIdpRedirect = async function g
40
40
  }));
41
41
  return Object.fromEntries(results);
42
42
  };
43
- const handleIDPLoginCallback = exports.handleIDPLoginCallback = async function handleIDPLoginCallback2({
44
- code
45
- }, context) {
43
+ const handleIDPLoginCallback = exports.handleIDPLoginCallback = async function handleIDPLoginCallback2(payload, context) {
46
44
  (0, _types.assertSession)(context);
47
45
  const OAuthClient = (0, _oauth.getOAuthClient)(context);
46
+ const code = typeof payload === "string" ? payload : payload.code;
48
47
  const {
49
48
  access_token: accessToken,
50
49
  refresh_token: refreshToken
@@ -2,7 +2,7 @@ import type { RpcContext } from '../../../types';
2
2
  export declare const getExternalIdpRedirect: (context: RpcContext) => Promise<{
3
3
  [k: string]: string;
4
4
  }>;
5
- export declare const handleIDPLoginCallback: ({ code }: {
5
+ export declare const handleIDPLoginCallback: (payload: string | {
6
6
  code: string;
7
7
  }, context: RpcContext) => Promise<{
8
8
  message: string;
@@ -36,9 +36,10 @@ export const getExternalIdpRedirect = async function getExternalIdpRedirect2(con
36
36
  );
37
37
  return Object.fromEntries(results);
38
38
  };
39
- export const handleIDPLoginCallback = async function handleIDPLoginCallback2({ code }, context) {
39
+ export const handleIDPLoginCallback = async function handleIDPLoginCallback2(payload, context) {
40
40
  assertSession(context);
41
41
  const OAuthClient = getOAuthClient(context);
42
+ const code = typeof payload === "string" ? payload : payload.code;
42
43
  const { access_token: accessToken, refresh_token: refreshToken } = await OAuthClient.generateToken(code);
43
44
  context.updateTokens({
44
45
  accessToken,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.searchProducts = void 0;
6
+ exports.searchProducts = exports.resolveSearch = exports.getSearchSuggestions = void 0;
7
7
  var _constants = require("../../constants/index.cjs");
8
8
  var _stringHelpers = require("../../helpers/stringHelpers.cjs");
9
9
  const searchProducts = exports.searchProducts = async function searchProducts2({
@@ -25,6 +25,39 @@ const searchProducts = exports.searchProducts = async function searchProducts2({
25
25
  with: _with ?? withParams?.search ?? _constants.MIN_WITH_PARAMS_SEARCH
26
26
  });
27
27
  };
28
+ const getSearchSuggestions = exports.getSearchSuggestions = async function getSearchSuggestions2({
29
+ term,
30
+ with: _with,
31
+ categoryId
32
+ }, {
33
+ bapiClient,
34
+ withParams
35
+ }) {
36
+ return await bapiClient.searchv2.suggestions(term, {
37
+ categoryId,
38
+ with: _with ?? withParams?.searchV2
39
+ });
40
+ };
41
+ const resolveSearch = exports.resolveSearch = async function resolveSearch2({
42
+ term,
43
+ with: _with,
44
+ categoryId
45
+ }, {
46
+ cached,
47
+ bapiClient,
48
+ withParams
49
+ }) {
50
+ const resolvedEntity = await cached(bapiClient.searchv2.resolve, {
51
+ cacheKeyPrefix: `resolve-${term}`
52
+ })(term, {
53
+ categoryId,
54
+ with: _with ?? withParams?.searchV2
55
+ });
56
+ if (!resolvedEntity) {
57
+ return null;
58
+ }
59
+ return resolvedEntity;
60
+ };
28
61
  const getCategoryId = async (cached, bapiClient, slug) => {
29
62
  if (!slug) {
30
63
  return;
@@ -1,9 +1,13 @@
1
1
  import type { TypeaheadSuggestionsEndpointRequestParameters, TypeaheadSuggestionsEndpointResponseData } from '@aboutyou/backbone/endpoints/typeahead/typeahead';
2
+ import type { SearchV2ResolveEndpointParameters, SearchV2SuggestionsEndpointResponseData, SearchV2SuggestionsEndpointParameters } from '../../types/bapi/search';
2
3
  type SearchWith = TypeaheadSuggestionsEndpointRequestParameters['with'];
4
+ /** @deprecated `searchProducts` is deprecated. Please, use `getSuggestions` or `resolve` RPC methods */
3
5
  export declare const searchProducts: ({ term, slug, with: _with, productLimit }: {
4
6
  term: string;
5
7
  slug?: string | undefined;
6
8
  with?: SearchWith;
7
9
  productLimit?: number | undefined;
8
10
  }, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<TypeaheadSuggestionsEndpointResponseData>;
11
+ export declare const getSearchSuggestions: ({ term, with: _with, categoryId }: SearchV2SuggestionsEndpointParameters, { bapiClient, withParams }: import("../../types").RpcContext) => Promise<SearchV2SuggestionsEndpointResponseData>;
12
+ export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@aboutyou/backbone/types/Search").SearchEntity | null>;
9
13
  export {};
@@ -10,6 +10,27 @@ export const searchProducts = async function searchProducts2({ term, slug, with:
10
10
  with: _with ?? withParams?.search ?? MIN_WITH_PARAMS_SEARCH
11
11
  });
12
12
  };
13
+ export const getSearchSuggestions = async function getSearchSuggestions2({ term, with: _with, categoryId }, { bapiClient, withParams }) {
14
+ return await bapiClient.searchv2.suggestions(
15
+ term,
16
+ {
17
+ categoryId,
18
+ with: _with ?? withParams?.searchV2
19
+ }
20
+ );
21
+ };
22
+ export const resolveSearch = async function resolveSearch2({ term, with: _with, categoryId }, { cached, bapiClient, withParams }) {
23
+ const resolvedEntity = await cached(bapiClient.searchv2.resolve, {
24
+ cacheKeyPrefix: `resolve-${term}`
25
+ })(term, {
26
+ categoryId,
27
+ with: _with ?? withParams?.searchV2
28
+ });
29
+ if (!resolvedEntity) {
30
+ return null;
31
+ }
32
+ return resolvedEntity;
33
+ };
13
34
  const getCategoryId = async (cached, bapiClient, slug) => {
14
35
  if (!slug) {
15
36
  return;
@@ -2,7 +2,7 @@ import type { BapiClient } from '@aboutyou/backbone';
2
2
  import type { Log } from '../../utils';
3
3
  import type { CachedType } from '../../cache/cached';
4
4
  import type { ShopUser } from '../user';
5
- import type { WishlistWithOptions, BasketWithOptions, ProductWith, VariantWith, SearchWith, CategoryWith, ProductCategoryWith } from '../';
5
+ import type { WishlistWithOptions, BasketWithOptions, ProductWith, VariantWith, SearchWith, SearchV2With, CategoryWith, ProductCategoryWith } from '../';
6
6
  import { OAuthTokens, IDPConfig } from './auth';
7
7
  export type WithParams = Partial<{
8
8
  basket: BasketWithOptions;
@@ -11,6 +11,7 @@ export type WithParams = Partial<{
11
11
  productCategory: ProductCategoryWith;
12
12
  category: CategoryWith;
13
13
  search: SearchWith;
14
+ searchV2: SearchV2With;
14
15
  variant: VariantWith;
15
16
  }>;
16
17
  export interface RuntimeConfiguration {
@@ -2,6 +2,10 @@ import type { ProductWith } from '@aboutyou/backbone/types/ProductWith';
2
2
  import type { TypeaheadSuggestionsEndpointRequestParameters } from '@aboutyou/backbone/endpoints/typeahead/typeahead';
3
3
  import { Query } from '../index';
4
4
  export type { BrandOrCategorySuggestion, ProductSuggestion, TypeaheadSuggestion, TypeaheadBrandOrCategorySuggestion, TypeaheadProductSuggestion, TypeaheadSuggestionsEndpointResponseData, } from '@aboutyou/backbone/endpoints/typeahead/typeahead';
5
+ export type { SearchV2With } from '@aboutyou/backbone/endpoints/searchv2/includes';
6
+ export type { SearchV2SuggestionsEndpointResponseData, SearchV2SuggestionsEndpointParameters, } from '@aboutyou/backbone/endpoints/searchv2/suggestions';
7
+ export type { SearchV2ResolveEndpointResponseData, SearchV2ResolveEndpointParameters, } from '@aboutyou/backbone/endpoints/searchv2/resolve';
8
+ export type * from '@aboutyou/backbone/types/Search';
5
9
  export type SearchInput = {
6
10
  term?: Query;
7
11
  slug?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.46.0",
3
+ "version": "7.47.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -64,26 +64,26 @@
64
64
  "jose": "5.2.3",
65
65
  "radash": "12.1.0",
66
66
  "slugify": "1.6.6",
67
- "ufo": "1.4.0",
67
+ "ufo": "1.5.3",
68
68
  "uncrypto": "0.1.3",
69
69
  "utility-types": "3.11.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@scayle/eslint-config-storefront": "3.2.6",
73
73
  "@types/crypto-js": "4.2.2",
74
- "@types/node": "20.11.28",
74
+ "@types/node": "20.12.3",
75
75
  "@types/webpack-env": "1.18.4",
76
- "@vitest/coverage-v8": "1.3.1",
76
+ "@vitest/coverage-v8": "1.4.0",
77
77
  "dprint": "0.45.0",
78
78
  "eslint": "8.57.0",
79
79
  "eslint-formatter-gitlab": "5.1.0",
80
80
  "publint": "0.2.7",
81
81
  "rimraf": "5.0.5",
82
82
  "ts-node": "10.9.2",
83
- "typescript": "5.4.2",
83
+ "typescript": "5.4.3",
84
84
  "unbuild": "2.0.0",
85
85
  "unstorage": "1.10.2",
86
- "vitest": "1.3.1"
86
+ "vitest": "1.4.0"
87
87
  },
88
88
  "optionalDependencies": {
89
89
  "redis": "4"