@faststore/api 3.73.0 → 3.78.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.
Files changed (43) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/__generated__/schema.d.ts +42 -1
  3. package/dist/cjs/src/__generated__/schema.d.ts.map +1 -1
  4. package/dist/cjs/src/__generated__/schema.js.map +1 -1
  5. package/dist/cjs/src/index.d.ts +1 -0
  6. package/dist/cjs/src/index.d.ts.map +1 -1
  7. package/dist/cjs/src/platforms/vtex/index.d.ts +1 -0
  8. package/dist/cjs/src/platforms/vtex/index.d.ts.map +1 -1
  9. package/dist/cjs/src/platforms/vtex/resolvers/product.d.ts.map +1 -1
  10. package/dist/cjs/src/platforms/vtex/resolvers/product.js +3 -0
  11. package/dist/cjs/src/platforms/vtex/resolvers/product.js.map +1 -1
  12. package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts +2 -1
  13. package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
  14. package/dist/cjs/src/platforms/vtex/resolvers/query.js +15 -0
  15. package/dist/cjs/src/platforms/vtex/resolvers/query.js.map +1 -1
  16. package/dist/cjs/src/typeDefs/product.graphql +42 -0
  17. package/dist/cjs/src/typeDefs/query.graphql +6 -0
  18. package/dist/cjs/src/typeDefs/skuVariants.graphql +1 -1
  19. package/dist/esm/package.json +1 -1
  20. package/dist/esm/src/__generated__/schema.d.ts +42 -1
  21. package/dist/esm/src/__generated__/schema.d.ts.map +1 -1
  22. package/dist/esm/src/__generated__/schema.js.map +1 -1
  23. package/dist/esm/src/index.d.ts +1 -0
  24. package/dist/esm/src/index.d.ts.map +1 -1
  25. package/dist/esm/src/platforms/vtex/index.d.ts +1 -0
  26. package/dist/esm/src/platforms/vtex/index.d.ts.map +1 -1
  27. package/dist/esm/src/platforms/vtex/resolvers/product.d.ts.map +1 -1
  28. package/dist/esm/src/platforms/vtex/resolvers/product.js +3 -0
  29. package/dist/esm/src/platforms/vtex/resolvers/product.js.map +1 -1
  30. package/dist/esm/src/platforms/vtex/resolvers/query.d.ts +2 -1
  31. package/dist/esm/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
  32. package/dist/esm/src/platforms/vtex/resolvers/query.js +15 -0
  33. package/dist/esm/src/platforms/vtex/resolvers/query.js.map +1 -1
  34. package/dist/esm/src/typeDefs/product.graphql +42 -0
  35. package/dist/esm/src/typeDefs/query.graphql +6 -0
  36. package/dist/esm/src/typeDefs/skuVariants.graphql +1 -1
  37. package/package.json +2 -2
  38. package/src/__generated__/schema.ts +49 -1
  39. package/src/platforms/vtex/resolvers/product.ts +6 -0
  40. package/src/platforms/vtex/resolvers/query.ts +29 -0
  41. package/src/typeDefs/product.graphql +42 -0
  42. package/src/typeDefs/query.graphql +6 -0
  43. package/src/typeDefs/skuVariants.graphql +1 -1
@@ -74,6 +74,48 @@ type StoreProduct {
74
74
  Advertisement information about the product.
75
75
  """
76
76
  advertisement: Advertisement
77
+ """
78
+ Indicates whether the product has specifications.
79
+ """
80
+ hasSpecifications: Boolean
81
+ """
82
+ Indicate the specifications of a product.
83
+ """
84
+ skuSpecifications: [SkuSpecification!]!
85
+ """
86
+ Indicate the specifications of a group of SKUs.
87
+ """
88
+ specificationGroups: [SpecificationGroup!]!
89
+ }
90
+
91
+ type SkuSpecification {
92
+ field: SKUSpecificationField!
93
+ values: [SKUSpecificationValue!]!
94
+ }
95
+
96
+ type SKUSpecificationValue {
97
+ name: String!
98
+ id: String
99
+ fieldId: String
100
+ originalName: String
101
+ }
102
+
103
+ type SKUSpecificationField {
104
+ name: String!
105
+ originalName: String
106
+ id: String
107
+ }
108
+
109
+ type SpecificationGroup {
110
+ name: String!
111
+ originalName: String!
112
+ specifications: [Specification!]!
113
+ }
114
+
115
+ type Specification {
116
+ name: String!
117
+ originalName: String!
118
+ values: [String!]!
77
119
  }
78
120
 
79
121
  """
@@ -275,6 +275,12 @@ type Query {
275
275
  ): StoreProductConnection!
276
276
  @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
277
277
 
278
+ """
279
+ Returns information about selected products.
280
+ """
281
+ products(productIds: [String!]!): [StoreProduct!]!
282
+ @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
283
+
278
284
  """
279
285
  Returns information about all collections.
280
286
  """
@@ -26,7 +26,7 @@ type SkuVariants {
26
26
  availableVariations(dominantVariantName: String): FormattedVariants
27
27
 
28
28
  """
29
- All possible variant combinations of the current product. It also includes the data for each variant.
29
+ All available options for each SKU variant property, indexed by their name.
30
30
  """
31
31
  allVariantProducts: [StoreProduct!]
32
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/api",
3
- "version": "3.73.0",
3
+ "version": "3.78.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/src/index.js",
6
6
  "typings": "dist/esm/src/index.d.ts",
@@ -73,5 +73,5 @@
73
73
  "volta": {
74
74
  "extends": "../../package.json"
75
75
  },
76
- "gitHead": "f24d4ea67a2b356ec12a4fe51e30119c5d84d4f0"
76
+ "gitHead": "e4853a8c962f5ba4527694ea4b60984fa21e1208"
77
77
  }
@@ -861,6 +861,8 @@ export type Query = {
861
861
  product: StoreProduct;
862
862
  /** Returns the total product count information based on a specific location accessible through the VTEX segment cookie. */
863
863
  productCount?: Maybe<ProductCountResult>;
864
+ /** Returns information about selected products. */
865
+ products: Array<StoreProduct>;
864
866
  /** Returns information about the profile. */
865
867
  profile?: Maybe<Profile>;
866
868
  /** Returns if there's a redirect for a search. */
@@ -923,6 +925,11 @@ export type QueryProductCountArgs = {
923
925
  };
924
926
 
925
927
 
928
+ export type QueryProductsArgs = {
929
+ productIds: Array<Scalars['String']>;
930
+ };
931
+
932
+
926
933
  export type QueryProfileArgs = {
927
934
  id: Scalars['String'];
928
935
  };
@@ -963,6 +970,21 @@ export type QueryUserOrderArgs = {
963
970
  orderId: Scalars['String'];
964
971
  };
965
972
 
973
+ export type SkuSpecificationField = {
974
+ __typename?: 'SKUSpecificationField';
975
+ id?: Maybe<Scalars['String']>;
976
+ name: Scalars['String'];
977
+ originalName?: Maybe<Scalars['String']>;
978
+ };
979
+
980
+ export type SkuSpecificationValue = {
981
+ __typename?: 'SKUSpecificationValue';
982
+ fieldId?: Maybe<Scalars['String']>;
983
+ id?: Maybe<Scalars['String']>;
984
+ name: Scalars['String'];
985
+ originalName?: Maybe<Scalars['String']>;
986
+ };
987
+
966
988
  /** Search result. */
967
989
  export type SearchMetadata = {
968
990
  __typename?: 'SearchMetadata';
@@ -1051,11 +1073,17 @@ export type ShippingSla = {
1051
1073
  shippingEstimateDate?: Maybe<Scalars['String']>;
1052
1074
  };
1053
1075
 
1076
+ export type SkuSpecification = {
1077
+ __typename?: 'SkuSpecification';
1078
+ field: SkuSpecificationField;
1079
+ values: Array<SkuSpecificationValue>;
1080
+ };
1081
+
1054
1082
  export type SkuVariants = {
1055
1083
  __typename?: 'SkuVariants';
1056
1084
  /** SKU property values for the current SKU. */
1057
1085
  activeVariations?: Maybe<Scalars['ActiveVariations']>;
1058
- /** All possible variant combinations of the current product. It also includes the data for each variant. */
1086
+ /** All available options for each SKU variant property, indexed by their name. */
1059
1087
  allVariantProducts?: Maybe<Array<StoreProduct>>;
1060
1088
  /** All available options for each SKU variant property, indexed by their name. */
1061
1089
  allVariantsByName?: Maybe<Scalars['VariantsByName']>;
@@ -1088,6 +1116,20 @@ export type SkuVariantsSlugsMapArgs = {
1088
1116
  dominantVariantName?: Maybe<Scalars['String']>;
1089
1117
  };
1090
1118
 
1119
+ export type Specification = {
1120
+ __typename?: 'Specification';
1121
+ name: Scalars['String'];
1122
+ originalName: Scalars['String'];
1123
+ values: Array<Scalars['String']>;
1124
+ };
1125
+
1126
+ export type SpecificationGroup = {
1127
+ __typename?: 'SpecificationGroup';
1128
+ name: Scalars['String'];
1129
+ originalName: Scalars['String'];
1130
+ specifications: Array<Specification>;
1131
+ };
1132
+
1091
1133
  /** Account profile information. */
1092
1134
  export type StoreAccountProfile = {
1093
1135
  __typename?: 'StoreAccountProfile';
@@ -1460,6 +1502,8 @@ export type StoreProduct = {
1460
1502
  description: Scalars['String'];
1461
1503
  /** Global Trade Item Number. */
1462
1504
  gtin: Scalars['String'];
1505
+ /** Indicates whether the product has specifications. */
1506
+ hasSpecifications?: Maybe<Scalars['Boolean']>;
1463
1507
  /** Array of images. */
1464
1508
  image: Array<StoreImage>;
1465
1509
  /** Indicates product group related to this product. */
@@ -1478,8 +1522,12 @@ export type StoreProduct = {
1478
1522
  seo: StoreSeo;
1479
1523
  /** Stock Keeping Unit. Merchant-specific ID for the product. */
1480
1524
  sku: Scalars['String'];
1525
+ /** Indicate the specifications of a product. */
1526
+ skuSpecifications: Array<SkuSpecification>;
1481
1527
  /** Corresponding collection URL slug, with which to retrieve this entity. */
1482
1528
  slug: Scalars['String'];
1529
+ /** Indicate the specifications of a group of SKUs. */
1530
+ specificationGroups: Array<SpecificationGroup>;
1483
1531
  /** Sku Unit Multiplier */
1484
1532
  unitMultiplier?: Maybe<Scalars['Float']>;
1485
1533
  };
@@ -188,6 +188,12 @@ export const StoreProduct: Record<string, Resolver<Root>> & {
188
188
  ...propertyValueAttributes,
189
189
  ]
190
190
  },
191
+ hasSpecifications: ({ isVariantOf }) =>
192
+ Boolean(isVariantOf.skuSpecifications?.length),
193
+ skuSpecifications: ({ isVariantOf: { skuSpecifications } }) =>
194
+ skuSpecifications ?? [],
195
+ specificationGroups: ({ isVariantOf: { specificationGroups } }) =>
196
+ specificationGroups,
191
197
  releaseDate: ({ isVariantOf: { releaseDate } }) => releaseDate ?? '',
192
198
  advertisement: ({ isVariantOf: { advertisement } }) => advertisement,
193
199
  }
@@ -14,6 +14,7 @@ import type {
14
14
  QueryShippingArgs,
15
15
  QueryUserOrderArgs,
16
16
  UserOrderFromList,
17
+ QueryProductsArgs,
17
18
  } from '../../../__generated__/schema'
18
19
  import { BadRequestError, ForbiddenError, NotFoundError } from '../../errors'
19
20
  import type { CategoryTree } from '../clients/commerce/types/CategoryTree'
@@ -222,6 +223,34 @@ export const Query = {
222
223
  })),
223
224
  }
224
225
  },
226
+ products: async (
227
+ _: unknown,
228
+ { productIds }: QueryProductsArgs,
229
+ ctx: Context
230
+ ) => {
231
+ const {
232
+ clients: { search },
233
+ } = ctx
234
+
235
+ if (!productIds.length) {
236
+ return []
237
+ }
238
+
239
+ const query = `id:${productIds.join(';')}`
240
+ const products = await search.products({
241
+ page: 0,
242
+ count: productIds.length,
243
+ query,
244
+ })
245
+
246
+ return products.products
247
+ .flatMap((product) =>
248
+ product.items.map((sku) => enhanceSku(sku, product))
249
+ )
250
+ .filter(
251
+ (sku) => productIds.includes(sku.itemId) && sku.sellers.length > 0
252
+ )
253
+ },
225
254
  allCollections: async (
226
255
  _: unknown,
227
256
  { first, after: maybeAfter }: QueryAllCollectionsArgs,
@@ -74,6 +74,48 @@ type StoreProduct {
74
74
  Advertisement information about the product.
75
75
  """
76
76
  advertisement: Advertisement
77
+ """
78
+ Indicates whether the product has specifications.
79
+ """
80
+ hasSpecifications: Boolean
81
+ """
82
+ Indicate the specifications of a product.
83
+ """
84
+ skuSpecifications: [SkuSpecification!]!
85
+ """
86
+ Indicate the specifications of a group of SKUs.
87
+ """
88
+ specificationGroups: [SpecificationGroup!]!
89
+ }
90
+
91
+ type SkuSpecification {
92
+ field: SKUSpecificationField!
93
+ values: [SKUSpecificationValue!]!
94
+ }
95
+
96
+ type SKUSpecificationValue {
97
+ name: String!
98
+ id: String
99
+ fieldId: String
100
+ originalName: String
101
+ }
102
+
103
+ type SKUSpecificationField {
104
+ name: String!
105
+ originalName: String
106
+ id: String
107
+ }
108
+
109
+ type SpecificationGroup {
110
+ name: String!
111
+ originalName: String!
112
+ specifications: [Specification!]!
113
+ }
114
+
115
+ type Specification {
116
+ name: String!
117
+ originalName: String!
118
+ values: [String!]!
77
119
  }
78
120
 
79
121
  """
@@ -275,6 +275,12 @@ type Query {
275
275
  ): StoreProductConnection!
276
276
  @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
277
277
 
278
+ """
279
+ Returns information about selected products.
280
+ """
281
+ products(productIds: [String!]!): [StoreProduct!]!
282
+ @cacheControl(scope: "public", sMaxAge: 120, staleWhileRevalidate: 3600)
283
+
278
284
  """
279
285
  Returns information about all collections.
280
286
  """
@@ -26,7 +26,7 @@ type SkuVariants {
26
26
  availableVariations(dominantVariantName: String): FormattedVariants
27
27
 
28
28
  """
29
- All possible variant combinations of the current product. It also includes the data for each variant.
29
+ All available options for each SKU variant property, indexed by their name.
30
30
  """
31
31
  allVariantProducts: [StoreProduct!]
32
32
  }