@faststore/api 1.8.37 → 1.8.40

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.37",
3
+ "version": "1.8.40",
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": "297531783e1ebb6c2444b8c6586af43d34d28003"
48
+ "gitHead": "9ffcdedb307c45b1f7abe99e3680d04d2fcd21e0"
49
49
  }
@@ -69,6 +69,8 @@ export type IStoreProduct = {
69
69
  export type IStorePropertyValue = {
70
70
  /** Property name. */
71
71
  name: Scalars['String'];
72
+ /** Property id. This propert changes according to the content of the object. */
73
+ propertyID?: Maybe<Scalars['String']>;
72
74
  /** Property value. May hold a string or the string representation of an object. */
73
75
  value: Scalars['ObjectOrString'];
74
76
  /** Specifies the nature of the value */
@@ -552,11 +554,20 @@ export const enum StoreStatus {
552
554
  Warning = 'WARNING'
553
555
  };
554
556
 
557
+ /** Suggestion term. */
558
+ export type StoreSuggestionTerm = {
559
+ __typename?: 'StoreSuggestionTerm';
560
+ /** Its occurrences count. */
561
+ count: Scalars['Int'];
562
+ /** The term. */
563
+ value: Scalars['String'];
564
+ };
565
+
555
566
  /** Suggestions information. */
556
567
  export type StoreSuggestions = {
557
568
  __typename?: 'StoreSuggestions';
558
569
  /** Array with suggestion products' information. */
559
- products?: Maybe<Array<StoreProduct>>;
570
+ products: Array<StoreProduct>;
560
571
  /** Array with suggestion terms. */
561
- terms?: Maybe<Array<Scalars['String']>>;
572
+ terms: Array<StoreSuggestionTerm>;
562
573
  };
@@ -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
  },
@@ -5,6 +5,7 @@ import type {
5
5
  IStoreCart,
6
6
  IStoreOffer,
7
7
  IStoreOrder,
8
+ IStorePropertyValue,
8
9
  } from '../../../__generated__/schema'
9
10
  import type {
10
11
  OrderForm,
@@ -20,17 +21,18 @@ import {
20
21
 
21
22
  type Indexed<T> = T & { index?: number }
22
23
 
23
- const getAttachments = (item: IStoreOffer) =>
24
- item.itemOffered.additionalProperty?.filter(
25
- (i) => i.valueReference === VALUE_REFERENCES.attachment
26
- )
24
+ const isAttachment = (value: IStorePropertyValue) =>
25
+ value.valueReference === VALUE_REFERENCES.attachment
27
26
 
28
27
  const getId = (item: IStoreOffer) =>
29
28
  [
30
29
  item.itemOffered.sku,
31
30
  item.seller.identifier,
32
31
  item.price,
33
- item.itemOffered.additionalProperty?.map(getPropertyId).join('-'),
32
+ item.itemOffered.additionalProperty
33
+ ?.filter(isAttachment)
34
+ .map(getPropertyId)
35
+ .join('-'),
34
36
  ]
35
37
  .filter(Boolean)
36
38
  .join('::')
@@ -59,7 +61,9 @@ const offerToOrderItemInput = (
59
61
  seller: offer.seller.identifier,
60
62
  id: offer.itemOffered.sku,
61
63
  index: offer.index,
62
- attachments: (getAttachments(offer) ?? []).map((attachment) => ({
64
+ attachments: (
65
+ offer.itemOffered.additionalProperty?.filter(isAttachment) ?? []
66
+ ).map((attachment) => ({
63
67
  name: attachment.name,
64
68
  content: attachment.value,
65
69
  })),
@@ -21,6 +21,10 @@ type StorePropertyValue {
21
21
  }
22
22
 
23
23
  input IStorePropertyValue {
24
+ """
25
+ Property id. This propert changes according to the content of the object.
26
+ """
27
+ propertyID: String
24
28
  """
25
29
  Property value. May hold a string or the string representation of an object.
26
30
  """
@@ -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
  """