@faststore/api 1.8.36 → 1.8.39

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.
@@ -21,6 +21,5 @@ export declare const IntelligentSearch: ({ account, environment, hideUnavailable
21
21
  facets: (args: Omit<SearchArgs, 'type'>) => Promise<FacetSearchResult>;
22
22
  products: (args: Omit<SearchArgs, 'type'>) => Promise<ProductSearchResult>;
23
23
  suggestedTerms: (args: Omit<SearchArgs, 'type'>) => Promise<Suggestion>;
24
- suggestedProducts: (args: Omit<SearchArgs, 'type'>) => Promise<ProductSearchResult>;
25
24
  topSearches: () => Promise<Suggestion>;
26
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.8.36",
3
+ "version": "1.8.39",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -45,5 +45,5 @@
45
45
  "peerDependencies": {
46
46
  "graphql": "^15.6.0"
47
47
  },
48
- "gitHead": "5d3f39d424dc7884807d0a7d724736f35ca34f61"
48
+ "gitHead": "5bce52bd4da46c29e2a07cdf1843f2212e29f191"
49
49
  }
@@ -552,11 +552,20 @@ export const enum StoreStatus {
552
552
  Warning = 'WARNING'
553
553
  };
554
554
 
555
+ /** Suggestion term. */
556
+ export type StoreSuggestionTerm = {
557
+ __typename?: 'StoreSuggestionTerm';
558
+ /** Its occurrences count. */
559
+ count: Scalars['Int'];
560
+ /** The term. */
561
+ value: Scalars['String'];
562
+ };
563
+
555
564
  /** Suggestions information. */
556
565
  export type StoreSuggestions = {
557
566
  __typename?: 'StoreSuggestions';
558
567
  /** Array with suggestion products' information. */
559
- products?: Maybe<Array<StoreProduct>>;
568
+ products: Array<StoreProduct>;
560
569
  /** Array with suggestion terms. */
561
- terms?: Maybe<Array<Scalars['String']>>;
570
+ terms: Array<StoreSuggestionTerm>;
562
571
  };
@@ -124,19 +124,6 @@ export const IntelligentSearch = (
124
124
  const products = (args: Omit<SearchArgs, 'type'>) =>
125
125
  search<ProductSearchResult>({ ...args, type: 'product_search' })
126
126
 
127
- const suggestedProducts = (
128
- args: Omit<SearchArgs, 'type'>
129
- ): Promise<ProductSearchResult> => {
130
- const params = new URLSearchParams({
131
- query: args.query?.toString() ?? '',
132
- locale: ctx.storage.locale,
133
- })
134
-
135
- return fetchAPI(
136
- `${base}/_v/api/intelligent-search/product_search?${params.toString()}`
137
- )
138
- }
139
-
140
127
  const suggestedTerms = (
141
128
  args: Omit<SearchArgs, 'type'>
142
129
  ): Promise<Suggestion> => {
@@ -167,7 +154,6 @@ export const IntelligentSearch = (
167
154
  facets,
168
155
  products,
169
156
  suggestedTerms,
170
- suggestedProducts,
171
157
  topSearches,
172
158
  }
173
159
  }
@@ -18,13 +18,16 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
18
18
  const topSearches = await search.topSearches()
19
19
 
20
20
  return {
21
- terms: topSearches.searches.map((item) => item.term),
21
+ terms: topSearches.searches.map((item) => ({
22
+ value: item.term,
23
+ count: item.count,
24
+ })),
22
25
  products: [],
23
26
  }
24
27
  }
25
28
 
26
29
  const terms = await search.suggestedTerms(searchArgs)
27
- const products = await search.suggestedProducts(searchArgs)
30
+ const products = await search.products(searchArgs)
28
31
 
29
32
  const skus = products.products
30
33
  .map((product) => {
@@ -37,7 +40,7 @@ export const StoreSearchResult: Record<string, Resolver<Root>> = {
37
40
  const { searches } = terms
38
41
 
39
42
  return {
40
- terms: searches.map((item) => item.term),
43
+ terms: searches.map((item) => ({ value: item.term, count: item.count })),
41
44
  products: skus,
42
45
  }
43
46
  },
@@ -84,6 +84,20 @@ enum StoreFacetType {
84
84
  RANGE
85
85
  }
86
86
 
87
+ """
88
+ Suggestion term.
89
+ """
90
+ type StoreSuggestionTerm {
91
+ """
92
+ The term.
93
+ """
94
+ value: String!
95
+ """
96
+ Its occurrences count.
97
+ """
98
+ count: Int!
99
+ }
100
+
87
101
  """
88
102
  Suggestions information.
89
103
  """
@@ -91,11 +105,11 @@ type StoreSuggestions {
91
105
  """
92
106
  Array with suggestion terms.
93
107
  """
94
- terms: [String!]
108
+ terms: [StoreSuggestionTerm!]!
95
109
  """
96
110
  Array with suggestion products' information.
97
111
  """
98
- products: [StoreProduct!]
112
+ products: [StoreProduct!]!
99
113
  }
100
114
 
101
115
  """