@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 +30 -0
- package/dist/__generated__/schema.d.ts +2 -0
- package/dist/api.cjs.development.js +39 -24
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +39 -24
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/platforms/vtex/index.d.ts +1 -0
- package/dist/platforms/vtex/resolvers/propertyValue.d.ts +5 -0
- package/dist/platforms/vtex/utils/propertyValue.d.ts +8 -1
- package/package.json +2 -2
- package/src/__generated__/schema.ts +2 -0
- package/src/platforms/vtex/index.ts +2 -0
- package/src/platforms/vtex/resolvers/product.ts +19 -15
- package/src/platforms/vtex/resolvers/propertyValue.ts +12 -0
- package/src/platforms/vtex/resolvers/validateCart.ts +8 -17
- package/src/platforms/vtex/utils/propertyValue.ts +18 -1
- package/src/typeDefs/propertyValue.graphql +4 -0
package/dist/api.esm.js
CHANGED
|
@@ -628,10 +628,19 @@ const StoreFacetValue = {
|
|
|
628
628
|
const md5 = payload => crypto.createHash('md5').update(payload).digest('hex');
|
|
629
629
|
|
|
630
630
|
const VALUE_REFERENCES = {
|
|
631
|
-
variation: 'VARIATION',
|
|
632
631
|
attachment: 'ATTACHMENT',
|
|
633
632
|
specification: 'SPECIFICATION'
|
|
634
633
|
};
|
|
634
|
+
function attachmentToPropertyValue(attachment) {
|
|
635
|
+
return {
|
|
636
|
+
name: attachment.name,
|
|
637
|
+
value: attachment.content,
|
|
638
|
+
valueReference: VALUE_REFERENCES.attachment
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function getPropertyId(item) {
|
|
642
|
+
return md5(`${item.name}:${JSON.stringify(item.value)}:${item.valueReference}`);
|
|
643
|
+
}
|
|
635
644
|
|
|
636
645
|
const getAttachments = item => {
|
|
637
646
|
var _item$itemOffered$add;
|
|
@@ -639,18 +648,12 @@ const getAttachments = item => {
|
|
|
639
648
|
return (_item$itemOffered$add = item.itemOffered.additionalProperty) == null ? void 0 : _item$itemOffered$add.filter(i => i.valueReference === VALUE_REFERENCES.attachment);
|
|
640
649
|
};
|
|
641
650
|
|
|
642
|
-
const
|
|
643
|
-
|
|
651
|
+
const getId = item => {
|
|
652
|
+
var _item$itemOffered$add2;
|
|
644
653
|
|
|
645
|
-
|
|
646
|
-
return null;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
return attachments == null ? void 0 : attachments.map(attachment => `${attachment.name}:${JSON.stringify(attachment.value)}`).join('-');
|
|
654
|
+
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('::');
|
|
650
655
|
};
|
|
651
656
|
|
|
652
|
-
const getId = item => [item.itemOffered.sku, item.seller.identifier, item.price, serializeAttachment(item)].filter(Boolean).join('::');
|
|
653
|
-
|
|
654
657
|
const orderFormItemToOffer = (item, index) => ({
|
|
655
658
|
listPrice: item.listPrice / 100,
|
|
656
659
|
price: item.sellingPrice / 100,
|
|
@@ -661,7 +664,8 @@ const orderFormItemToOffer = (item, index) => ({
|
|
|
661
664
|
itemOffered: {
|
|
662
665
|
sku: item.id,
|
|
663
666
|
image: [],
|
|
664
|
-
name: item.name
|
|
667
|
+
name: item.name,
|
|
668
|
+
additionalProperty: item.attachments.map(attachmentToPropertyValue)
|
|
665
669
|
},
|
|
666
670
|
index
|
|
667
671
|
});
|
|
@@ -674,7 +678,7 @@ const offerToOrderItemInput = offer => {
|
|
|
674
678
|
seller: offer.seller.identifier,
|
|
675
679
|
id: offer.itemOffered.sku,
|
|
676
680
|
index: offer.index,
|
|
677
|
-
attachments: (_getAttachments = getAttachments(offer))
|
|
681
|
+
attachments: ((_getAttachments = getAttachments(offer)) != null ? _getAttachments : []).map(attachment => ({
|
|
678
682
|
name: attachment.name,
|
|
679
683
|
content: attachment.value
|
|
680
684
|
}))
|
|
@@ -1139,23 +1143,20 @@ const StoreProduct = {
|
|
|
1139
1143
|
})).sort(bestOfferFirst),
|
|
1140
1144
|
isVariantOf: root => root,
|
|
1141
1145
|
additionalProperty: ({
|
|
1142
|
-
variations
|
|
1143
|
-
|
|
1146
|
+
// Search uses the name variations for specifications
|
|
1147
|
+
variations: specifications = [],
|
|
1148
|
+
attachmentsValues = []
|
|
1144
1149
|
}) => {
|
|
1145
|
-
const
|
|
1150
|
+
const propertyValueSpecifications = specifications.flatMap(({
|
|
1146
1151
|
name,
|
|
1147
1152
|
values
|
|
1148
1153
|
}) => values.map(value => ({
|
|
1149
1154
|
name,
|
|
1150
1155
|
value,
|
|
1151
|
-
valueReference: VALUE_REFERENCES.
|
|
1156
|
+
valueReference: VALUE_REFERENCES.specification
|
|
1152
1157
|
})));
|
|
1153
|
-
const propertyValueAttachments =
|
|
1154
|
-
|
|
1155
|
-
value: attachment.content,
|
|
1156
|
-
valueReference: VALUE_REFERENCES.attachment
|
|
1157
|
-
}));
|
|
1158
|
-
return [...propertyValueVariations, ...propertyValueAttachments];
|
|
1158
|
+
const propertyValueAttachments = attachmentsValues.map(attachmentToPropertyValue);
|
|
1159
|
+
return [...propertyValueSpecifications, ...propertyValueAttachments];
|
|
1159
1160
|
}
|
|
1160
1161
|
};
|
|
1161
1162
|
|
|
@@ -1553,6 +1554,19 @@ function stringify(value) {
|
|
|
1553
1554
|
return null;
|
|
1554
1555
|
}
|
|
1555
1556
|
|
|
1557
|
+
const StorePropertyValue = {
|
|
1558
|
+
propertyID: root => getPropertyId(root),
|
|
1559
|
+
name: ({
|
|
1560
|
+
name
|
|
1561
|
+
}) => name,
|
|
1562
|
+
value: ({
|
|
1563
|
+
value
|
|
1564
|
+
}) => value,
|
|
1565
|
+
valueReference: ({
|
|
1566
|
+
valueReference
|
|
1567
|
+
}) => valueReference
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1556
1570
|
const Resolvers = {
|
|
1557
1571
|
StoreCollection,
|
|
1558
1572
|
StoreAggregateOffer,
|
|
@@ -1565,6 +1579,7 @@ const Resolvers = {
|
|
|
1565
1579
|
StoreReview,
|
|
1566
1580
|
StoreProductGroup,
|
|
1567
1581
|
StoreSearchResult,
|
|
1582
|
+
StorePropertyValue,
|
|
1568
1583
|
ObjectOrString,
|
|
1569
1584
|
Query,
|
|
1570
1585
|
Mutation
|
|
@@ -1642,8 +1657,8 @@ var doc$i = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","de
|
|
|
1642
1657
|
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}};
|
|
1643
1658
|
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}};
|
|
1644
1659
|
|
|
1645
|
-
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":
|
|
1646
|
-
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}};
|
|
1660
|
+
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}};
|
|
1661
|
+
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}};
|
|
1647
1662
|
|
|
1648
1663
|
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}};
|
|
1649
1664
|
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}};
|