@faststore/api 1.8.32 → 1.8.35

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
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.8.35 (2022-05-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add OutOfStock component ([#1314](https://github.com/vtex/faststore/issues/1314)) ([37eac86](https://github.com/vtex/faststore/commit/37eac86ede448ef68aef426f65f2d224694b2cfc))
12
+
13
+
14
+
15
+
16
+
17
+ ## 1.8.34 (2022-05-25)
18
+
19
+ **Note:** Version bump only for package @faststore/api
20
+
21
+
22
+
23
+
24
+
25
+ ## 1.8.33 (2022-05-24)
26
+
27
+
28
+ ### Features
29
+
30
+ * useStorage update onFocus ([#1316](https://github.com/vtex/faststore/issues/1316)) ([c9874d4](https://github.com/vtex/faststore/commit/c9874d46a16a09159e6e1bd4da4e61ec25bd62d2))
31
+
32
+
33
+
34
+
35
+
6
36
  ## 1.8.32 (2022-05-23)
7
37
 
8
38
  **Note:** Version bump only for package @faststore/api
@@ -427,6 +427,8 @@ export declare type StorePropertyValue = {
427
427
  __typename?: 'StorePropertyValue';
428
428
  /** Property name. */
429
429
  name: Scalars['String'];
430
+ /** Property id. This propert changes according to the content of the object. */
431
+ propertyID: Scalars['String'];
430
432
  /** Property value. May hold a string or the string representation of an object. */
431
433
  value: Scalars['ObjectOrString'];
432
434
  /** Specifies the nature of the value */
@@ -634,10 +634,19 @@ const StoreFacetValue = {
634
634
  const md5 = payload => crypto.createHash('md5').update(payload).digest('hex');
635
635
 
636
636
  const VALUE_REFERENCES = {
637
- variation: 'VARIATION',
638
637
  attachment: 'ATTACHMENT',
639
638
  specification: 'SPECIFICATION'
640
639
  };
640
+ function attachmentToPropertyValue(attachment) {
641
+ return {
642
+ name: attachment.name,
643
+ value: attachment.content,
644
+ valueReference: VALUE_REFERENCES.attachment
645
+ };
646
+ }
647
+ function getPropertyId(item) {
648
+ return md5(`${item.name}:${JSON.stringify(item.value)}:${item.valueReference}`);
649
+ }
641
650
 
642
651
  const getAttachments = item => {
643
652
  var _item$itemOffered$add;
@@ -645,18 +654,12 @@ const getAttachments = item => {
645
654
  return (_item$itemOffered$add = item.itemOffered.additionalProperty) == null ? void 0 : _item$itemOffered$add.filter(i => i.valueReference === VALUE_REFERENCES.attachment);
646
655
  };
647
656
 
648
- const serializeAttachment = item => {
649
- const attachments = getAttachments(item);
657
+ const getId = item => {
658
+ var _item$itemOffered$add2;
650
659
 
651
- if ((attachments == null ? void 0 : attachments.length) === 0) {
652
- return null;
653
- }
654
-
655
- return attachments == null ? void 0 : attachments.map(attachment => `${attachment.name}:${JSON.stringify(attachment.value)}`).join('-');
660
+ return [item.itemOffered.sku, item.seller.identifier, item.price, (_item$itemOffered$add2 = item.itemOffered.additionalProperty) == null ? void 0 : _item$itemOffered$add2.map(getPropertyId).join('-')].filter(Boolean).join('::');
656
661
  };
657
662
 
658
- const getId = item => [item.itemOffered.sku, item.seller.identifier, item.price, serializeAttachment(item)].filter(Boolean).join('::');
659
-
660
663
  const orderFormItemToOffer = (item, index) => ({
661
664
  listPrice: item.listPrice / 100,
662
665
  price: item.sellingPrice / 100,
@@ -667,7 +670,8 @@ const orderFormItemToOffer = (item, index) => ({
667
670
  itemOffered: {
668
671
  sku: item.id,
669
672
  image: [],
670
- name: item.name
673
+ name: item.name,
674
+ additionalProperty: item.attachments.map(attachmentToPropertyValue)
671
675
  },
672
676
  index
673
677
  });
@@ -680,7 +684,7 @@ const offerToOrderItemInput = offer => {
680
684
  seller: offer.seller.identifier,
681
685
  id: offer.itemOffered.sku,
682
686
  index: offer.index,
683
- attachments: (_getAttachments = getAttachments(offer)) == null ? void 0 : _getAttachments.map(attachment => ({
687
+ attachments: ((_getAttachments = getAttachments(offer)) != null ? _getAttachments : []).map(attachment => ({
684
688
  name: attachment.name,
685
689
  content: attachment.value
686
690
  }))
@@ -1145,23 +1149,20 @@ const StoreProduct = {
1145
1149
  })).sort(bestOfferFirst),
1146
1150
  isVariantOf: root => root,
1147
1151
  additionalProperty: ({
1148
- variations = [],
1149
- attachmentsValues
1152
+ // Search uses the name variations for specifications
1153
+ variations: specifications = [],
1154
+ attachmentsValues = []
1150
1155
  }) => {
1151
- const propertyValueVariations = variations.flatMap(({
1156
+ const propertyValueSpecifications = specifications.flatMap(({
1152
1157
  name,
1153
1158
  values
1154
1159
  }) => values.map(value => ({
1155
1160
  name,
1156
1161
  value,
1157
- valueReference: VALUE_REFERENCES.variation
1162
+ valueReference: VALUE_REFERENCES.specification
1158
1163
  })));
1159
- const propertyValueAttachments = (attachmentsValues != null ? attachmentsValues : []).map(attachment => ({
1160
- name: attachment.name,
1161
- value: attachment.content,
1162
- valueReference: VALUE_REFERENCES.attachment
1163
- }));
1164
- return [...propertyValueVariations, ...propertyValueAttachments];
1164
+ const propertyValueAttachments = attachmentsValues.map(attachmentToPropertyValue);
1165
+ return [...propertyValueSpecifications, ...propertyValueAttachments];
1165
1166
  }
1166
1167
  };
1167
1168
 
@@ -1559,6 +1560,19 @@ function stringify(value) {
1559
1560
  return null;
1560
1561
  }
1561
1562
 
1563
+ const StorePropertyValue = {
1564
+ propertyID: root => getPropertyId(root),
1565
+ name: ({
1566
+ name
1567
+ }) => name,
1568
+ value: ({
1569
+ value
1570
+ }) => value,
1571
+ valueReference: ({
1572
+ valueReference
1573
+ }) => valueReference
1574
+ };
1575
+
1562
1576
  const Resolvers = {
1563
1577
  StoreCollection,
1564
1578
  StoreAggregateOffer,
@@ -1571,6 +1585,7 @@ const Resolvers = {
1571
1585
  StoreReview,
1572
1586
  StoreProductGroup,
1573
1587
  StoreSearchResult,
1588
+ StorePropertyValue,
1574
1589
  ObjectOrString,
1575
1590
  Query,
1576
1591
  Mutation
@@ -1648,8 +1663,8 @@ var doc$i = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","de
1648
1663
  var doc$j = {"kind":"Document","definitions":[{"kind":"EnumTypeDefinition","description":{"kind":"StringValue","value":"Status used to indicate type of message. For instance, in shopping cart messages.","block":true},"name":{"kind":"Name","value":"StoreStatus"},"directives":[],"values":[{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"INFO"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"WARNING"},"directives":[]},{"kind":"EnumValueDefinition","name":{"kind":"Name","value":"ERROR"},"directives":[]}]}],"loc":{"start":0,"end":136}};
1649
1664
  doc$j.loc.source = {"body":"\"\"\"\nStatus used to indicate type of message. For instance, in shopping cart messages.\n\"\"\"\nenum StoreStatus {\n INFO\n WARNING\n ERROR\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
1650
1665
 
1651
- var doc$k = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Properties that can be associated with products and products groups.","block":true},"name":{"kind":"Name","value":"StorePropertyValue"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Property value. May hold a string or the string representation of an object.","block":true},"name":{"kind":"Name","value":"value"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ObjectOrString"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Property name.","block":true},"name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Specifies the nature of the value","block":true},"name":{"kind":"Name","value":"valueReference"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStorePropertyValue"},"directives":[],"fields":[{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Property value. May hold a string or the string representation of an object.","block":true},"name":{"kind":"Name","value":"value"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ObjectOrString"}}},"directives":[]},{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Property name.","block":true},"name":{"kind":"Name","value":"name"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Specifies the nature of the value","block":true},"name":{"kind":"Name","value":"valueReference"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":606}};
1652
- doc$k.loc.source = {"body":"\"\"\"\nProperties that can be associated with products and products groups.\n\"\"\"\ntype StorePropertyValue {\n \"\"\"\n Property value. May hold a string or the string representation of an object.\n \"\"\"\n value: ObjectOrString!\n \"\"\"\n Property name.\n \"\"\"\n name: String!\n \"\"\"\n Specifies the nature of the value\n \"\"\"\n valueReference: String!\n}\n\ninput IStorePropertyValue {\n \"\"\"\n Property value. May hold a string or the string representation of an object.\n \"\"\"\n value: ObjectOrString!\n \"\"\"\n Property name.\n \"\"\"\n name: String!\n \"\"\"\n Specifies the nature of the value\n \"\"\"\n valueReference: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
1666
+ var doc$k = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Properties that can be associated with products and products groups.","block":true},"name":{"kind":"Name","value":"StorePropertyValue"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Property id. This propert changes according to the content of the object.","block":true},"name":{"kind":"Name","value":"propertyID"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Property value. May hold a string or the string representation of an object.","block":true},"name":{"kind":"Name","value":"value"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ObjectOrString"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Property name.","block":true},"name":{"kind":"Name","value":"name"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Specifies the nature of the value","block":true},"name":{"kind":"Name","value":"valueReference"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","name":{"kind":"Name","value":"IStorePropertyValue"},"directives":[],"fields":[{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Property value. May hold a string or the string representation of an object.","block":true},"name":{"kind":"Name","value":"value"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ObjectOrString"}}},"directives":[]},{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Property name.","block":true},"name":{"kind":"Name","value":"name"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Specifies the nature of the value","block":true},"name":{"kind":"Name","value":"valueReference"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":716}};
1667
+ doc$k.loc.source = {"body":"\"\"\"\nProperties that can be associated with products and products groups.\n\"\"\"\ntype StorePropertyValue {\n \"\"\"\n Property id. This propert changes according to the content of the object.\n \"\"\"\n propertyID: String!\n \"\"\"\n Property value. May hold a string or the string representation of an object.\n \"\"\"\n value: ObjectOrString!\n \"\"\"\n Property name.\n \"\"\"\n name: String!\n \"\"\"\n Specifies the nature of the value\n \"\"\"\n valueReference: String!\n}\n\ninput IStorePropertyValue {\n \"\"\"\n Property value. May hold a string or the string representation of an object.\n \"\"\"\n value: ObjectOrString!\n \"\"\"\n Property name.\n \"\"\"\n name: String!\n \"\"\"\n Specifies the nature of the value\n \"\"\"\n valueReference: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
1653
1668
 
1654
1669
  var doc$l = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Client profile data.","block":true},"name":{"kind":"Name","value":"StorePerson"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Client ID.","block":true},"name":{"kind":"Name","value":"id"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Client email.","block":true},"name":{"kind":"Name","value":"email"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Client first name.","block":true},"name":{"kind":"Name","value":"givenName"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Client last name.","block":true},"name":{"kind":"Name","value":"familyName"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":242}};
1655
1670
  doc$l.loc.source = {"body":"\"\"\"\nClient profile data.\n\"\"\"\ntype StorePerson {\n \"\"\"\n Client ID.\n \"\"\"\n id: String!\n \"\"\"\n Client email.\n \"\"\"\n email: String!\n \"\"\"\n Client first name.\n \"\"\"\n givenName: String!\n \"\"\"\n Client last name.\n \"\"\"\n familyName: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};