@faststore/api 1.7.30 → 1.7.33

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 (48) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/api.cjs.development.js +313 -181
  3. package/dist/api.cjs.development.js.map +1 -1
  4. package/dist/api.cjs.production.min.js +1 -1
  5. package/dist/api.cjs.production.min.js.map +1 -1
  6. package/dist/api.esm.js +313 -181
  7. package/dist/api.esm.js.map +1 -1
  8. package/dist/index.d.ts +27 -13
  9. package/dist/platforms/vtex/clients/index.d.ts +4 -1
  10. package/dist/platforms/vtex/clients/search/index.d.ts +3 -3
  11. package/dist/platforms/vtex/clients/search/types/AttributeSearchResult.d.ts +25 -51
  12. package/dist/platforms/vtex/clients/search/types/FacetSearchResult.d.ts +31 -0
  13. package/dist/platforms/vtex/clients/search/types/ProductSearchResult.d.ts +146 -154
  14. package/dist/platforms/vtex/clients/sp/index.d.ts +13 -0
  15. package/dist/platforms/vtex/index.d.ts +28 -14
  16. package/dist/platforms/vtex/resolvers/aggregateOffer.d.ts +10 -6
  17. package/dist/platforms/vtex/resolvers/facet.d.ts +2 -2
  18. package/dist/platforms/vtex/resolvers/facetValue.d.ts +2 -2
  19. package/dist/platforms/vtex/resolvers/offer.d.ts +7 -6
  20. package/dist/platforms/vtex/resolvers/product.d.ts +11 -2
  21. package/dist/platforms/vtex/resolvers/productGroup.d.ts +5 -2
  22. package/dist/platforms/vtex/utils/enhanceSku.d.ts +3 -3
  23. package/dist/platforms/vtex/utils/price.d.ts +2 -0
  24. package/dist/platforms/vtex/utils/productStock.d.ts +5 -0
  25. package/dist/typings/index.d.ts +2 -0
  26. package/package.json +2 -2
  27. package/src/platforms/vtex/clients/fetch.ts +1 -1
  28. package/src/platforms/vtex/clients/index.ts +3 -0
  29. package/src/platforms/vtex/clients/search/index.ts +6 -6
  30. package/src/platforms/vtex/clients/search/types/AttributeSearchResult.ts +24 -53
  31. package/src/platforms/vtex/clients/search/types/FacetSearchResult.ts +33 -0
  32. package/src/platforms/vtex/clients/search/types/ProductSearchResult.ts +135 -164
  33. package/src/platforms/vtex/clients/sp/index.ts +67 -0
  34. package/src/platforms/vtex/index.ts +2 -2
  35. package/src/platforms/vtex/loaders/sku.ts +2 -2
  36. package/src/platforms/vtex/resolvers/aggregateOffer.ts +17 -35
  37. package/src/platforms/vtex/resolvers/facet.ts +5 -5
  38. package/src/platforms/vtex/resolvers/facetValue.ts +7 -6
  39. package/src/platforms/vtex/resolvers/offer.ts +107 -17
  40. package/src/platforms/vtex/resolvers/product.ts +55 -73
  41. package/src/platforms/vtex/resolvers/productGroup.ts +22 -13
  42. package/src/platforms/vtex/resolvers/query.ts +3 -3
  43. package/src/platforms/vtex/resolvers/searchResult.ts +24 -12
  44. package/src/platforms/vtex/utils/enhanceSku.ts +4 -4
  45. package/src/platforms/vtex/utils/facets.ts +8 -2
  46. package/src/platforms/vtex/utils/price.ts +10 -0
  47. package/src/platforms/vtex/utils/productStock.ts +25 -0
  48. package/src/typings/index.ts +4 -0
@@ -1,56 +1,30 @@
1
- export interface AttributeSearchResult {
2
- total: number;
3
- pagination: Pagination;
4
- sampling: boolean;
5
- translated: boolean;
6
- locale: string;
7
- query: string;
8
- operator: string;
9
- fuzzy: string;
10
- attributes: Attribute[] | null;
1
+ declare type FilterType = 'PRICERANGE' | 'TEXT' | 'NUMBER' | 'CATEGORYTREE';
2
+ export interface FacetSearchResult {
3
+ facets: Facet[];
4
+ breadcrumb: Breadcrumb;
11
5
  }
12
- export interface Attribute {
13
- ids: string[];
14
- visible: boolean;
15
- values: Value[];
16
- active: boolean;
17
- key: string;
18
- originalKey: string;
19
- label: string;
20
- originalLabel: string;
21
- type: string;
22
- minValue?: number;
23
- maxValue?: number;
24
- templateURL?: string;
25
- proxyURL?: string;
6
+ export interface Facet {
7
+ type: FilterType;
8
+ name: string;
9
+ hidden: boolean;
10
+ values: FacetValue[];
11
+ quantity?: number;
26
12
  }
27
- export interface Value {
28
- count: number;
29
- active: boolean;
30
- key?: string;
31
- label?: string;
13
+ interface FacetValue {
14
+ quantity: number;
15
+ name: string;
16
+ key: string;
17
+ value: string;
18
+ selected?: boolean;
19
+ range?: {
20
+ from: number;
21
+ to: number;
22
+ };
23
+ children?: FacetValue[];
32
24
  id?: string;
33
- originalKey?: string;
34
- originalLabel?: string;
35
- proxyURL: string;
36
- from?: string;
37
- to?: string;
38
- }
39
- export interface Pagination {
40
- count: number;
41
- current: Current;
42
- before: any[];
43
- after: any[];
44
- perPage: number;
45
- next: First;
46
- previous: First;
47
- first: First;
48
- last: First;
49
- }
50
- export interface Current {
51
- index: number;
52
- proxyURL: string;
53
25
  }
54
- export interface First {
55
- index: number;
26
+ interface Breadcrumb {
27
+ href: string;
28
+ name: string;
56
29
  }
30
+ export {};
@@ -0,0 +1,31 @@
1
+ declare type FilterType = 'PRICERANGE' | 'TEXT' | 'NUMBER' | 'CATEGORYTREE';
2
+ export interface FacetSearchResult {
3
+ facets: Facet[];
4
+ breadcrumb: Breadcrumb;
5
+ }
6
+ export interface Facet {
7
+ type: FilterType;
8
+ name: string;
9
+ hidden: boolean;
10
+ values: FacetValue[];
11
+ quantity?: number;
12
+ key?: string;
13
+ }
14
+ export interface FacetValue {
15
+ quantity: number;
16
+ name: string;
17
+ key: string;
18
+ value: string;
19
+ selected?: boolean;
20
+ range?: {
21
+ from: number;
22
+ to: number;
23
+ };
24
+ children?: FacetValue[];
25
+ id?: string;
26
+ }
27
+ interface Breadcrumb {
28
+ href: string;
29
+ name: string;
30
+ }
31
+ export {};
@@ -1,5 +1,8 @@
1
1
  export interface ProductSearchResult {
2
- total: number;
2
+ /**
3
+ * @description Total of products.
4
+ */
5
+ recordsFiltered: number;
3
6
  products: Product[];
4
7
  pagination: Pagination;
5
8
  sampling: boolean;
@@ -7,193 +10,182 @@ export interface ProductSearchResult {
7
10
  translated: boolean;
8
11
  locale: string;
9
12
  query: string;
10
- operator: string;
13
+ operator: 'and' | 'or';
11
14
  fuzzy: string;
12
15
  correction: Correction;
13
16
  }
14
- export interface Correction {
17
+ interface Correction {
15
18
  misspelled: boolean;
16
19
  }
17
- export interface Options {
20
+ interface Options {
18
21
  sorts: Sort[];
19
22
  counts: Count[];
20
23
  }
21
- export interface Count {
24
+ interface Count {
22
25
  count: number;
23
26
  proxyURL: string;
24
27
  }
25
- export interface Sort {
28
+ interface Sort {
26
29
  field: string;
27
30
  order: string;
28
31
  active?: boolean;
29
32
  proxyURL: string;
30
33
  }
31
- export interface Pagination {
34
+ interface Pagination {
32
35
  count: number;
33
- current: Current;
34
- before: any[];
35
- after: Current[];
36
+ current: Page;
37
+ before: Page[];
38
+ after: Page[];
36
39
  perPage: number;
37
- next: Current;
38
- previous: First;
39
- first: First;
40
- last: Current;
40
+ next: Page;
41
+ previous: Page;
42
+ first: Page;
43
+ last: Page;
41
44
  }
42
- export interface Current {
45
+ interface Page {
43
46
  index: number;
44
47
  proxyURL: string;
45
48
  }
46
- export interface First {
47
- index: number;
48
- }
49
49
  export interface Product {
50
- unitMultiplier: number;
51
- year: number;
52
- extraData: ExtraDatum[];
53
- release: number;
54
- discount: number;
55
- reference: string;
56
- split: Split;
57
- collections: Collection[];
58
- price: number;
59
- customSort: number;
60
- stickers: Sticker[];
61
- id: string;
62
- stock: number;
50
+ productId: string;
51
+ productName: string;
63
52
  brand: string;
64
- availableTradePolicies: string[];
65
- categoryTrees: CategoryTree[];
66
- images: Image[];
67
- locationAttributes: any[];
68
- tax: number;
69
- productScore: number;
70
- storeSplitAttribute: string;
71
- brandID: string;
72
- installment: Installment;
73
- name: string;
74
- boost: Boost;
75
- skus: Sku[];
53
+ brandId: number;
54
+ cacheId?: string;
55
+ linkText: string;
56
+ productReference: string;
57
+ categoryId: string;
58
+ clusterHighlights: Record<string, any>;
59
+ productClusters: Record<string, string>;
60
+ categories: string[];
61
+ categoriesIds: string[];
76
62
  link: string;
77
- wear: number;
78
63
  description: string;
79
- showIfNotAvailable: boolean;
80
- clusterHighlights: ClusterHighlights;
81
- categories: string[];
82
- timestamp: number;
83
- product: string;
84
- oldPrice: number;
85
- productSpecifications: string[];
86
- url: string;
87
- measurementUnit: string;
88
- categoryIDS: string[];
89
- textAttributes: TextAttribute[];
90
- numberAttributes: NumberAttribute[];
91
- headSku: string;
92
- specificationGroups: string;
93
- extraInfo: ExtraInfo;
94
- oldPriceText: string;
95
- priceText: string;
96
- }
97
- export interface Boost {
98
- newness: number;
99
- image: number;
100
- revenue: number;
101
- discount: number;
102
- productScore: number;
103
- click: number;
104
- availableSpecsCount: number;
105
- promotion: number;
106
- order: number;
107
- }
108
- export interface CategoryTree {
109
- categoryNames: string[];
110
- categoryIDS: string[];
111
- }
112
- export interface ClusterHighlights {
113
- the140: string;
114
- }
115
- export interface Collection {
116
- id: string;
117
- position: number;
118
- }
119
- export interface ExtraDatum {
120
- value: string;
121
- key: string;
122
- }
123
- export interface ExtraInfo {
124
- sellerID: string;
125
- }
126
- export interface Image {
64
+ /**
65
+ * @description Product SKUs.
66
+ */
67
+ items: Item[];
68
+ skuSpecifications?: SkuSpecification[];
69
+ priceRange: PriceRange;
70
+ specificationGroups: SpecificationGroup;
71
+ properties: Array<{
72
+ name: string;
73
+ values: string[];
74
+ }>;
75
+ selectedProperties: Array<{
76
+ key: string;
77
+ value: string;
78
+ }>;
79
+ }
80
+ interface Image {
81
+ imageId: string;
82
+ imageLabel: string | null;
83
+ imageTag: string;
84
+ imageUrl: string;
85
+ imageText: string;
86
+ }
87
+ interface Installment {
88
+ Value: number;
89
+ InterestRate: number;
90
+ TotalValuePlusInterestRate: number;
91
+ NumberOfInstallments: number;
92
+ PaymentSystemName: string;
93
+ PaymentSystemGroupName: string;
94
+ Name: string;
95
+ }
96
+ export interface Item {
97
+ itemId: string;
127
98
  name: string;
128
- value: string;
129
- }
130
- export interface Installment {
131
- interest: boolean;
132
- count: number;
133
- paymentGroupName: string;
134
- value: number;
135
- paymentName: string;
136
- valueText?: string;
137
- }
138
- export interface NumberAttribute {
139
- labelKey: string;
140
- value: number;
141
- key: string;
142
- }
143
- export interface Sku {
144
- images: Image[];
145
99
  nameComplete: string;
146
100
  complementName: string;
147
- policies: Policy[];
148
- videos: any[];
149
- reference: string;
150
- idWithSplit: string;
151
101
  ean: string;
152
- name: string;
153
- attributes: ExtraDatum[];
154
- id: string;
155
- sellers: Seller[];
156
- }
157
- export interface Policy {
158
- id: string;
102
+ referenceId: Array<{
103
+ Key: string;
104
+ Value: string;
105
+ }>;
106
+ measurementUnit: string;
107
+ unitMultiplier: number;
108
+ modalType: any | null;
109
+ images: Image[];
110
+ Videos: string[];
111
+ variations: string[];
159
112
  sellers: Seller[];
113
+ attachments: Array<{
114
+ id: number;
115
+ name: string;
116
+ required: boolean;
117
+ domainValues: string;
118
+ }>;
119
+ isKit: boolean;
120
+ kitItems?: Array<{
121
+ itemId: string;
122
+ amount: number;
123
+ }>;
124
+ }
125
+ export interface CommertialOffer {
126
+ DeliverySlaSamplesPerRegion: Record<string, {
127
+ DeliverySlaPerTypes: any[];
128
+ Region: any | null;
129
+ }>;
130
+ Installments: Installment[];
131
+ DiscountHighLight: any[];
132
+ GiftSkuIds: string[];
133
+ Teasers: Array<Record<string, unknown>>;
134
+ teasers?: Array<Record<string, unknown>>;
135
+ BuyTogether: any[];
136
+ ItemMetadataAttachment: any[];
137
+ Price: number;
138
+ ListPrice: number;
139
+ spotPrice?: number;
140
+ PriceWithoutDiscount: number;
141
+ RewardValue: number;
142
+ PriceValidUntil: string;
143
+ AvailableQuantity: number;
144
+ Tax: number;
145
+ DeliverySlaSamples: Array<{
146
+ DeliverySlaPerTypes: any[];
147
+ Region: any | null;
148
+ }>;
149
+ GetInfoErrorMessage: any | null;
150
+ CacheVersionUsedToCallCheckout: string;
160
151
  }
161
152
  export interface Seller {
162
- default: boolean;
163
- oldPrice?: number;
164
- price?: number;
165
- installment?: Installment;
166
- name: string;
167
- tax: number;
168
- teasers: any[];
169
- id: string;
153
+ sellerId: string;
154
+ sellerName: string;
155
+ addToCartLink: string;
156
+ sellerDefault: boolean;
157
+ commertialOffer: CommertialOffer;
158
+ }
159
+ interface SkuSpecification {
160
+ field: SKUSpecificationField;
161
+ values: SKUSpecificationValue[];
170
162
  }
171
- export interface Split {
172
- labelValue: string;
173
- labelKey: string;
163
+ interface SKUSpecificationValue {
164
+ name: string;
165
+ id?: string;
166
+ fieldId?: string;
167
+ originalName?: string;
174
168
  }
175
- export interface Sticker {
176
- image: string;
169
+ interface SKUSpecificationField {
177
170
  name: string;
178
- location: string;
179
- target: string;
180
- }
181
- export interface TextAttribute {
182
- joinedValue: string;
183
- isSku: boolean;
184
- joinedKey: string;
185
- joinedKeyTranslations: JoinedTranslations;
186
- isFilter: boolean;
187
- labelValue: string;
188
- id: string[];
189
- labelKey: string;
190
- value: string;
191
- key: string;
192
- joinedValueTranslations: JoinedTranslations;
193
- valueID?: string;
194
- }
195
- export interface JoinedTranslations {
196
- spanish: string;
197
- english: string;
198
- italian: string;
171
+ originalName?: string;
172
+ id?: string;
199
173
  }
174
+ interface Price {
175
+ highPrice: number | null;
176
+ lowPrice: number | null;
177
+ }
178
+ interface PriceRange {
179
+ sellingPrice: Price;
180
+ listPrice: Price;
181
+ }
182
+ interface SpecificationGroup {
183
+ name: string;
184
+ originalName: string;
185
+ specifications: {
186
+ name: string;
187
+ originalName: string;
188
+ values: string[];
189
+ };
190
+ }
191
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { Options, Context } from '../../index';
2
+ export declare type SearchEvent = {
3
+ type: 'search.query';
4
+ text: string;
5
+ misspelled: boolean;
6
+ match: number;
7
+ operator: 'and' | 'or';
8
+ session?: string;
9
+ anonymous?: string;
10
+ };
11
+ export declare const SP: ({ account }: Options, _: Context) => {
12
+ sendEvent: (options: SearchEvent) => Promise<any>;
13
+ };
@@ -22,31 +22,45 @@ export interface Context {
22
22
  };
23
23
  headers: Record<string, string>;
24
24
  }
25
- export declare type Resolver<R = unknown, A = unknown> = (root: R, args: A, ctx: Context, info: any) => any;
25
+ export declare type Resolver<R = unknown, A = unknown, Return = any> = (root: R, args: A, ctx: Context, info: any) => Return;
26
26
  export declare const getContextFactory: (options: Options) => (ctx: any) => Context;
27
27
  export declare const getResolvers: (_: Options) => {
28
28
  StoreCollection: Record<string, Resolver<import("./clients/commerce/types/Brand").Brand | import("./clients/commerce/types/Portal").CollectionPageType | (import("./clients/commerce/types/CategoryTree").CategoryTree & {
29
29
  level: number;
30
- }), unknown>>;
31
- StoreAggregateOffer: Record<string, (root: import("./clients/commerce/types/Simulation").Simulation & {
30
+ }), unknown, any>>;
31
+ StoreAggregateOffer: Record<string, Resolver<{
32
+ items: import("./clients/search/types/ProductSearchResult").Item[];
32
33
  product: import("./utils/enhanceSku").EnhancedSku;
33
- }) => unknown>;
34
- StoreProduct: Record<string, Resolver<import("./utils/enhanceSku").EnhancedSku, unknown>>;
34
+ }, unknown, any>> & {
35
+ offers: Resolver<{
36
+ items: import("./clients/search/types/ProductSearchResult").Item[];
37
+ product: import("./utils/enhanceSku").EnhancedSku;
38
+ }, any, (import("./clients/search/types/ProductSearchResult").Item & {
39
+ product: import("./utils/enhanceSku").EnhancedSku;
40
+ })[]>;
41
+ };
42
+ StoreProduct: Record<string, Resolver<import("./utils/enhanceSku").EnhancedSku, unknown, any>> & {
43
+ offers: Resolver<import("./utils/enhanceSku").EnhancedSku, any, {
44
+ items: import("./clients/search/types/ProductSearchResult").Item[];
45
+ product: import("./utils/enhanceSku").EnhancedSku;
46
+ }>;
47
+ isVariantOf: Resolver<import("./utils/enhanceSku").EnhancedSku, any, import("./utils/enhanceSku").EnhancedSku>;
48
+ };
35
49
  StoreSeo: Record<string, Resolver<{
36
50
  title?: string | undefined;
37
51
  description?: string | undefined;
38
- }, unknown>>;
39
- StoreFacet: Record<string, Resolver<import("./clients/search/types/AttributeSearchResult").Attribute, unknown>>;
40
- StoreFacetValue: Record<string, Resolver<import("./clients/search/types/AttributeSearchResult").Value, unknown>>;
41
- StoreOffer: Record<string, Resolver<(import("./clients/commerce/types/Simulation").Item & {
52
+ }, unknown, any>>;
53
+ StoreFacet: Record<string, Resolver<import("./clients/search/types/FacetSearchResult").Facet, unknown, any>>;
54
+ StoreFacetValue: Record<string, Resolver<import("./clients/search/types/FacetSearchResult").FacetValue, unknown, any>>;
55
+ StoreOffer: Record<string, Resolver<(import("./clients/search/types/ProductSearchResult").Item & {
42
56
  product: import("./utils/enhanceSku").EnhancedSku;
43
57
  }) | (import("./clients/commerce/types/OrderForm").OrderFormItem & {
44
58
  product: Promise<import("./utils/enhanceSku").EnhancedSku>;
45
- }), unknown>>;
46
- StoreAggregateRating: Record<string, Resolver<unknown, unknown>>;
47
- StoreReview: Record<string, Resolver<unknown, unknown>>;
48
- StoreProductGroup: Record<string, Resolver<import("./clients/search/types/ProductSearchResult").Product, unknown>>;
49
- StoreSearchResult: Record<string, Resolver<Pick<import("./clients/search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">, unknown>>;
59
+ }), unknown, any>>;
60
+ StoreAggregateRating: Record<string, Resolver<unknown, unknown, any>>;
61
+ StoreReview: Record<string, Resolver<unknown, unknown, any>>;
62
+ StoreProductGroup: Record<string, Resolver<import("./utils/enhanceSku").EnhancedSku, unknown, any>>;
63
+ StoreSearchResult: Record<string, Resolver<Pick<import("./clients/search").SearchArgs, "hideUnavailableItems" | "query" | "page" | "count" | "sort" | "selectedFacets" | "fuzzy">, unknown, any>>;
50
64
  Query: {
51
65
  product: (_: unknown, { locator }: import("../..").QueryProductArgs, ctx: Context) => Promise<import("./utils/enhanceSku").EnhancedSku>;
52
66
  collection: (_: unknown, { slug }: import("../..").QueryCollectionArgs, ctx: Context) => Promise<import("./clients/commerce/types/Portal").CollectionPageType>;
@@ -1,8 +1,12 @@
1
+ import type { Item } from '../clients/search/types/ProductSearchResult';
2
+ import type { StoreProduct } from './product';
3
+ import type { PromiseType } from '../../../typings';
4
+ import type { Resolver } from '..';
1
5
  import type { EnhancedSku } from '../utils/enhanceSku';
2
- import type { Simulation } from '../clients/commerce/types/Simulation';
3
- declare type Resolvers = (root: Simulation & {
4
- product: EnhancedSku;
5
- }) => unknown;
6
- export declare const sortOfferByPrice: (items: Simulation['items']) => Simulation['items'];
7
- export declare const StoreAggregateOffer: Record<string, Resolvers>;
6
+ declare type Root = PromiseType<ReturnType<typeof StoreProduct.offers>>;
7
+ export declare const StoreAggregateOffer: Record<string, Resolver<Root>> & {
8
+ offers: Resolver<Root, any, Array<Item & {
9
+ product: EnhancedSku;
10
+ }>>;
11
+ };
8
12
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Resolver } from '..';
2
- import type { Attribute } from '../clients/search/types/AttributeSearchResult';
3
- declare type Root = Attribute;
2
+ import type { Facet } from '../clients/search/types/FacetSearchResult';
3
+ declare type Root = Facet;
4
4
  export declare const StoreFacet: Record<string, Resolver<Root>>;
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Resolver } from '..';
2
- import type { Value } from '../clients/search/types/AttributeSearchResult';
3
- declare type Root = Value;
2
+ import type { FacetValue } from '../clients/search/types/FacetSearchResult';
3
+ declare type Root = FacetValue;
4
4
  export declare const StoreFacetValue: Record<string, Resolver<Root>>;
5
5
  export {};
@@ -1,11 +1,12 @@
1
- import type { EnhancedSku } from '../utils/enhanceSku';
2
1
  import type { Resolver } from '..';
3
- import type { Item } from '../clients/commerce/types/Simulation';
2
+ import type { StoreAggregateOffer } from './aggregateOffer';
3
+ import type { ArrayElementType } from '../../../typings';
4
+ import type { EnhancedSku } from '../utils/enhanceSku';
4
5
  import type { OrderFormItem } from '../clients/commerce/types/OrderForm';
5
- declare type Root = (Item & {
6
- product: EnhancedSku;
7
- }) | (OrderFormItem & {
6
+ declare type OrderFormProduct = OrderFormItem & {
8
7
  product: Promise<EnhancedSku>;
9
- });
8
+ };
9
+ declare type SearchProduct = ArrayElementType<ReturnType<typeof StoreAggregateOffer.offers>>;
10
+ declare type Root = SearchProduct | OrderFormProduct;
10
11
  export declare const StoreOffer: Record<string, Resolver<Root>>;
11
12
  export {};
@@ -1,5 +1,14 @@
1
1
  import type { Resolver } from '..';
2
+ import type { PromiseType } from '../../../typings';
3
+ import type { Query } from './query';
4
+ import type { Item } from '../clients/search/types/ProductSearchResult';
2
5
  import type { EnhancedSku } from '../utils/enhanceSku';
3
- declare type Root = EnhancedSku;
4
- export declare const StoreProduct: Record<string, Resolver<Root>>;
6
+ declare type Root = PromiseType<ReturnType<typeof Query.product>>;
7
+ export declare const StoreProduct: Record<string, Resolver<Root>> & {
8
+ offers: Resolver<Root, any, {
9
+ items: Item[];
10
+ product: EnhancedSku;
11
+ }>;
12
+ isVariantOf: Resolver<Root, any, Root>;
13
+ };
5
14
  export {};
@@ -1,3 +1,6 @@
1
- import type { Product } from '../clients/search/types/ProductSearchResult';
2
1
  import type { Resolver } from '..';
3
- export declare const StoreProductGroup: Record<string, Resolver<Product>>;
2
+ import type { PromiseType } from '../../../typings';
3
+ import type { StoreProduct } from './product';
4
+ declare type Root = PromiseType<ReturnType<typeof StoreProduct.isVariantOf>>;
5
+ export declare const StoreProductGroup: Record<string, Resolver<Root>>;
6
+ export {};
@@ -1,5 +1,5 @@
1
- import type { Product, Sku } from '../clients/search/types/ProductSearchResult';
2
- export declare type EnhancedSku = Sku & {
1
+ import type { Product, Item } from '../clients/search/types/ProductSearchResult';
2
+ export declare type EnhancedSku = Item & {
3
3
  isVariantOf: Product;
4
4
  };
5
- export declare const enhanceSku: (sku: Sku, product: Product) => EnhancedSku;
5
+ export declare const enhanceSku: (item: Item, product: Product) => EnhancedSku;
@@ -0,0 +1,2 @@
1
+ import type { CommertialOffer, Item } from '../clients/search/types/ProductSearchResult';
2
+ export declare const getItemPriceByKey: (item: Item, key: keyof CommertialOffer) => number;
@@ -0,0 +1,5 @@
1
+ import type { Item, Seller } from '../clients/search/types/ProductSearchResult';
2
+ export declare const inStock: (item: Item) => Seller | undefined;
3
+ export declare const getFirstSeller: (sellers: Seller[]) => Seller | undefined;
4
+ export declare const sortOfferByPrice: (items: Item[]) => Item[];
5
+ export declare const inStockOrderFormItem: (availability: string) => boolean;
@@ -1 +1,3 @@
1
1
  export declare type Platform = 'vtex';
2
+ export declare type PromiseType<T> = T extends Promise<infer U> ? U : T;
3
+ export declare type ArrayElementType<T> = T extends Array<infer U> ? U : T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "1.7.30",
3
+ "version": "1.7.33",
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": "e0f577efbcbde827619bc66e6b3b237fc98c625c"
48
+ "gitHead": "bd144e2b299386767a92897c71d5b07223a5df23"
49
49
  }