@faststore/api 1.9.9 → 1.9.11
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 +11 -0
- package/dist/__generated__/schema.d.ts +23 -8
- package/dist/api.cjs.development.js +254 -194
- 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 +254 -194
- package/dist/api.esm.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/platforms/vtex/clients/search/index.d.ts +2 -1
- package/dist/platforms/vtex/clients/search/types/FacetSearchResult.d.ts +8 -8
- package/dist/platforms/vtex/index.d.ts +7 -3
- package/dist/platforms/vtex/resolvers/faceValue.d.ts +3 -0
- package/dist/platforms/vtex/resolvers/facet.d.ts +3 -1
- package/dist/platforms/vtex/utils/facets.d.ts +1 -0
- package/package.json +2 -2
- package/src/__generated__/schema.ts +26 -8
- package/src/platforms/vtex/clients/search/index.ts +9 -1
- package/src/platforms/vtex/clients/search/types/FacetSearchResult.ts +9 -8
- package/src/platforms/vtex/index.ts +14 -6
- package/src/platforms/vtex/resolvers/faceValue.ts +12 -0
- package/src/platforms/vtex/resolvers/facet.ts +66 -5
- package/src/platforms/vtex/resolvers/offer.ts +1 -1
- package/src/platforms/vtex/resolvers/searchResult.ts +9 -26
- package/src/platforms/vtex/utils/facets.ts +18 -0
- package/src/typeDefs/facet.graphql +28 -6
- package/dist/platforms/vtex/resolvers/facetValue.d.ts +0 -5
- package/src/platforms/vtex/resolvers/facetValue.ts +0 -12
package/dist/api.esm.js
CHANGED
|
@@ -615,30 +615,199 @@ const StoreCollection = {
|
|
|
615
615
|
}
|
|
616
616
|
};
|
|
617
617
|
|
|
618
|
+
class ChannelMarshal {
|
|
619
|
+
static parse(channelString) {
|
|
620
|
+
try {
|
|
621
|
+
var _parsedChannel$region, _parsedChannel$salesC;
|
|
622
|
+
|
|
623
|
+
const parsedChannel = JSON.parse(channelString);
|
|
624
|
+
return {
|
|
625
|
+
regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
|
|
626
|
+
salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
|
|
627
|
+
};
|
|
628
|
+
} catch (error) {
|
|
629
|
+
console.error(error);
|
|
630
|
+
throw new Error('Malformed channel string');
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
static stringify(channel) {
|
|
635
|
+
return JSON.stringify(channel);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Transform facets from the store to VTEX platform facets.
|
|
642
|
+
* For instance, the channel in Store becomes trade-policy and regionId in VTEX's realm
|
|
643
|
+
* */
|
|
644
|
+
|
|
645
|
+
const transformSelectedFacet = ({
|
|
646
|
+
key,
|
|
647
|
+
value
|
|
648
|
+
}) => {
|
|
649
|
+
switch (key) {
|
|
650
|
+
case 'channel':
|
|
651
|
+
{
|
|
652
|
+
const channel = ChannelMarshal.parse(value);
|
|
653
|
+
const channelFacets = [{
|
|
654
|
+
key: 'trade-policy',
|
|
655
|
+
value: channel.salesChannel
|
|
656
|
+
}];
|
|
657
|
+
|
|
658
|
+
if (channel.regionId) {
|
|
659
|
+
channelFacets.push({
|
|
660
|
+
key: 'region-id',
|
|
661
|
+
value: channel.regionId
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return channelFacets;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
case 'locale':
|
|
669
|
+
{
|
|
670
|
+
return []; // remove this facet from search
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
case 'price':
|
|
674
|
+
{
|
|
675
|
+
return {
|
|
676
|
+
key,
|
|
677
|
+
value: value.replace('-to-', ':')
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
default:
|
|
682
|
+
return {
|
|
683
|
+
key,
|
|
684
|
+
value
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
const parseRange = range => {
|
|
689
|
+
const splitted = range.split(':').map(Number);
|
|
690
|
+
|
|
691
|
+
if (splitted.length !== 2 || Number.isNaN(splitted[0]) || Number.isNaN(splitted[1])) {
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
return splitted;
|
|
696
|
+
};
|
|
697
|
+
const findSlug = facets => {
|
|
698
|
+
var _facets$find$value, _facets$find;
|
|
699
|
+
|
|
700
|
+
return (_facets$find$value = facets == null ? void 0 : (_facets$find = facets.find(x => x.key === 'slug')) == null ? void 0 : _facets$find.value) != null ? _facets$find$value : null;
|
|
701
|
+
};
|
|
702
|
+
const findSkuId = facets => {
|
|
703
|
+
var _facets$find$value2, _facets$find2;
|
|
704
|
+
|
|
705
|
+
return (_facets$find$value2 = facets == null ? void 0 : (_facets$find2 = facets.find(x => x.key === 'id')) == null ? void 0 : _facets$find2.value) != null ? _facets$find$value2 : null;
|
|
706
|
+
};
|
|
707
|
+
const findLocale = facets => {
|
|
708
|
+
var _facets$find$value3, _facets$find3;
|
|
709
|
+
|
|
710
|
+
return (_facets$find$value3 = facets == null ? void 0 : (_facets$find3 = facets.find(x => x.key === 'locale')) == null ? void 0 : _facets$find3.value) != null ? _facets$find$value3 : null;
|
|
711
|
+
};
|
|
712
|
+
const findChannel = facets => {
|
|
713
|
+
var _facets$find$value4, _facets$find4;
|
|
714
|
+
|
|
715
|
+
return (_facets$find$value4 = facets == null ? void 0 : (_facets$find4 = facets.find(facet => facet.key === 'channel')) == null ? void 0 : _facets$find4.value) != null ? _facets$find$value4 : null;
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* More info at: https://en.wikipedia.org/wiki/Order_statistic
|
|
720
|
+
*/
|
|
721
|
+
// O(n) search to find the max of an array
|
|
722
|
+
const min = (array, cmp) => {
|
|
723
|
+
let best = 0;
|
|
724
|
+
|
|
725
|
+
for (let curr = 1; curr < array.length; curr++) {
|
|
726
|
+
if (cmp(array[best], array[curr]) > 0) {
|
|
727
|
+
best = curr;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
return array[best];
|
|
732
|
+
};
|
|
733
|
+
|
|
618
734
|
const StoreFacet = {
|
|
735
|
+
__resolveType: ({
|
|
736
|
+
type
|
|
737
|
+
}) => type === 'TEXT' ? 'StoreFacetBoolean' : 'StoreFacetRange'
|
|
738
|
+
};
|
|
739
|
+
const StoreFacetBoolean = {
|
|
619
740
|
key: ({
|
|
620
741
|
key
|
|
621
|
-
}) => key
|
|
742
|
+
}) => key,
|
|
622
743
|
label: ({
|
|
623
744
|
name
|
|
624
|
-
}) => name
|
|
745
|
+
}) => name,
|
|
625
746
|
values: ({
|
|
626
747
|
values
|
|
627
|
-
}) => values,
|
|
628
|
-
type: ({
|
|
629
|
-
type
|
|
630
|
-
}) => type === 'TEXT' ? 'BOOLEAN' : 'RANGE'
|
|
748
|
+
}) => values.sort((a, b) => a.name.localeCompare(b.name))
|
|
631
749
|
};
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
750
|
+
const StoreFacetRange = {
|
|
751
|
+
key: ({
|
|
752
|
+
key
|
|
753
|
+
}) => key,
|
|
754
|
+
label: ({
|
|
755
|
+
name
|
|
756
|
+
}) => name,
|
|
757
|
+
min: ({
|
|
758
|
+
values,
|
|
759
|
+
key
|
|
760
|
+
}, _, {
|
|
761
|
+
storage: {
|
|
762
|
+
searchArgs
|
|
763
|
+
}
|
|
637
764
|
}) => {
|
|
638
|
-
var
|
|
765
|
+
var _searchArgs$selectedF, _searchArgs$selectedF2, _searchArgs$selectedF3, _facet$range$from, _selectedRange$;
|
|
639
766
|
|
|
640
|
-
|
|
767
|
+
/**
|
|
768
|
+
* Fetch the selected range the user queried.
|
|
769
|
+
*
|
|
770
|
+
* This is necessary because, differently from boolean facets, Search API does
|
|
771
|
+
* not return the selected values, making us have to implement it in here
|
|
772
|
+
*/
|
|
773
|
+
const selectedRange = parseRange((_searchArgs$selectedF = searchArgs == null ? void 0 : (_searchArgs$selectedF2 = searchArgs.selectedFacets) == null ? void 0 : (_searchArgs$selectedF3 = _searchArgs$selectedF2.find(facet => facet.key === key)) == null ? void 0 : _searchArgs$selectedF3.value) != null ? _searchArgs$selectedF : '');
|
|
774
|
+
const facet = min(values, (a, b) => a.range.from - b.range.from);
|
|
775
|
+
const globalMin = (_facet$range$from = facet == null ? void 0 : facet.range.from) != null ? _facet$range$from : 0;
|
|
776
|
+
return {
|
|
777
|
+
selected: (_selectedRange$ = selectedRange == null ? void 0 : selectedRange[0]) != null ? _selectedRange$ : globalMin,
|
|
778
|
+
absolute: globalMin
|
|
779
|
+
};
|
|
641
780
|
},
|
|
781
|
+
max: ({
|
|
782
|
+
values,
|
|
783
|
+
key
|
|
784
|
+
}, _, {
|
|
785
|
+
storage: {
|
|
786
|
+
searchArgs
|
|
787
|
+
}
|
|
788
|
+
}) => {
|
|
789
|
+
var _searchArgs$selectedF4, _searchArgs$selectedF5, _searchArgs$selectedF6, _facet$range$to, _selectedRange$2;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Fetch the selected range the user queried.
|
|
793
|
+
*
|
|
794
|
+
* This is necessary because, differently from boolean facets, Search API does
|
|
795
|
+
* not return the selected values, making us have to implement it in here
|
|
796
|
+
*/
|
|
797
|
+
const selectedRange = parseRange((_searchArgs$selectedF4 = searchArgs == null ? void 0 : (_searchArgs$selectedF5 = searchArgs.selectedFacets) == null ? void 0 : (_searchArgs$selectedF6 = _searchArgs$selectedF5.find(facet => facet.key === key)) == null ? void 0 : _searchArgs$selectedF6.value) != null ? _searchArgs$selectedF4 : '');
|
|
798
|
+
const facet = min(values, (a, b) => b.range.to - a.range.to);
|
|
799
|
+
const globalMax = (_facet$range$to = facet == null ? void 0 : facet.range.to) != null ? _facet$range$to : 0;
|
|
800
|
+
return {
|
|
801
|
+
selected: (_selectedRange$2 = selectedRange == null ? void 0 : selectedRange[1]) != null ? _selectedRange$2 : globalMax,
|
|
802
|
+
absolute: globalMax
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
const StoreFacetValueBoolean = {
|
|
808
|
+
value: ({
|
|
809
|
+
value
|
|
810
|
+
}) => value,
|
|
642
811
|
label: ({
|
|
643
812
|
name
|
|
644
813
|
}) => name || 'unknown',
|
|
@@ -888,28 +1057,6 @@ const validateCart = async (_, {
|
|
|
888
1057
|
return orderFormToCart(updatedOrderForm, skuLoader);
|
|
889
1058
|
};
|
|
890
1059
|
|
|
891
|
-
class ChannelMarshal {
|
|
892
|
-
static parse(channelString) {
|
|
893
|
-
try {
|
|
894
|
-
var _parsedChannel$region, _parsedChannel$salesC;
|
|
895
|
-
|
|
896
|
-
const parsedChannel = JSON.parse(channelString);
|
|
897
|
-
return {
|
|
898
|
-
regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
|
|
899
|
-
salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
|
|
900
|
-
};
|
|
901
|
-
} catch (error) {
|
|
902
|
-
console.error(error);
|
|
903
|
-
throw new Error('Malformed channel string');
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
static stringify(channel) {
|
|
908
|
-
return JSON.stringify(channel);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
|
|
913
1060
|
const validateSession = async (_, {
|
|
914
1061
|
session: oldSession,
|
|
915
1062
|
search
|
|
@@ -959,6 +1106,50 @@ const Mutation = {
|
|
|
959
1106
|
validateSession
|
|
960
1107
|
};
|
|
961
1108
|
|
|
1109
|
+
const ObjectOrString = /*#__PURE__*/new GraphQLScalarType({
|
|
1110
|
+
name: 'ObjectOrString',
|
|
1111
|
+
description: 'A string or the string representation of an object (a stringified object).',
|
|
1112
|
+
parseValue: toObjectOrString,
|
|
1113
|
+
serialize: stringify,
|
|
1114
|
+
|
|
1115
|
+
parseLiteral(ast) {
|
|
1116
|
+
if (ast.kind === Kind.STRING) {
|
|
1117
|
+
return getValueAsObjectOrString(ast.value);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
function toObjectOrString(value) {
|
|
1126
|
+
if (typeof value === 'string') {
|
|
1127
|
+
return getValueAsObjectOrString(value);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function getValueAsObjectOrString(value) {
|
|
1134
|
+
try {
|
|
1135
|
+
return JSON.parse(value);
|
|
1136
|
+
} catch (e) {
|
|
1137
|
+
return value;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function stringify(value) {
|
|
1142
|
+
if (typeof value === 'object') {
|
|
1143
|
+
return JSON.stringify(value);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
if (typeof value === 'string') {
|
|
1147
|
+
return value;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
return null;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
962
1153
|
const isSearchItem = item => 'Price' in item && 'seller' in item && 'product' in item;
|
|
963
1154
|
|
|
964
1155
|
const isOrderFormItem = item => 'skuName' in item;
|
|
@@ -1033,7 +1224,9 @@ const StoreOffer = {
|
|
|
1033
1224
|
},
|
|
1034
1225
|
listPrice: root => {
|
|
1035
1226
|
if (isSearchItem(root)) {
|
|
1036
|
-
|
|
1227
|
+
var _root$ListPrice;
|
|
1228
|
+
|
|
1229
|
+
return (_root$ListPrice = root.ListPrice) != null ? _root$ListPrice : 0;
|
|
1037
1230
|
}
|
|
1038
1231
|
|
|
1039
1232
|
if (isOrderFormItem(root)) {
|
|
@@ -1229,6 +1422,19 @@ const StoreProductGroup = {
|
|
|
1229
1422
|
}))))
|
|
1230
1423
|
};
|
|
1231
1424
|
|
|
1425
|
+
const StorePropertyValue = {
|
|
1426
|
+
propertyID: root => getPropertyId(root),
|
|
1427
|
+
name: ({
|
|
1428
|
+
name
|
|
1429
|
+
}) => name,
|
|
1430
|
+
value: ({
|
|
1431
|
+
value
|
|
1432
|
+
}) => value,
|
|
1433
|
+
valueReference: ({
|
|
1434
|
+
valueReference
|
|
1435
|
+
}) => valueReference
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1232
1438
|
const mutateChannelContext = (ctx, channelString) => {
|
|
1233
1439
|
ctx.storage.channel = ChannelMarshal.parse(channelString);
|
|
1234
1440
|
};
|
|
@@ -1236,67 +1442,6 @@ const mutateLocaleContext = (ctx, locale) => {
|
|
|
1236
1442
|
ctx.storage.locale = locale;
|
|
1237
1443
|
};
|
|
1238
1444
|
|
|
1239
|
-
/**
|
|
1240
|
-
* Transform facets from the store to VTEX platform facets.
|
|
1241
|
-
* For instance, the channel in Store becomes trade-policy and regionId in VTEX's realm
|
|
1242
|
-
* */
|
|
1243
|
-
|
|
1244
|
-
const transformSelectedFacet = ({
|
|
1245
|
-
key,
|
|
1246
|
-
value
|
|
1247
|
-
}) => {
|
|
1248
|
-
switch (key) {
|
|
1249
|
-
case 'channel':
|
|
1250
|
-
{
|
|
1251
|
-
const channel = ChannelMarshal.parse(value);
|
|
1252
|
-
const channelFacets = [{
|
|
1253
|
-
key: 'trade-policy',
|
|
1254
|
-
value: channel.salesChannel
|
|
1255
|
-
}];
|
|
1256
|
-
|
|
1257
|
-
if (channel.regionId) {
|
|
1258
|
-
channelFacets.push({
|
|
1259
|
-
key: 'region-id',
|
|
1260
|
-
value: channel.regionId
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
return channelFacets;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
case 'locale':
|
|
1268
|
-
{
|
|
1269
|
-
return []; // remove this facet from search
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
default:
|
|
1273
|
-
return {
|
|
1274
|
-
key,
|
|
1275
|
-
value
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
const findSlug = facets => {
|
|
1280
|
-
var _facets$find$value, _facets$find;
|
|
1281
|
-
|
|
1282
|
-
return (_facets$find$value = facets == null ? void 0 : (_facets$find = facets.find(x => x.key === 'slug')) == null ? void 0 : _facets$find.value) != null ? _facets$find$value : null;
|
|
1283
|
-
};
|
|
1284
|
-
const findSkuId = facets => {
|
|
1285
|
-
var _facets$find$value2, _facets$find2;
|
|
1286
|
-
|
|
1287
|
-
return (_facets$find$value2 = facets == null ? void 0 : (_facets$find2 = facets.find(x => x.key === 'id')) == null ? void 0 : _facets$find2.value) != null ? _facets$find$value2 : null;
|
|
1288
|
-
};
|
|
1289
|
-
const findLocale = facets => {
|
|
1290
|
-
var _facets$find$value3, _facets$find3;
|
|
1291
|
-
|
|
1292
|
-
return (_facets$find$value3 = facets == null ? void 0 : (_facets$find3 = facets.find(x => x.key === 'locale')) == null ? void 0 : _facets$find3.value) != null ? _facets$find$value3 : null;
|
|
1293
|
-
};
|
|
1294
|
-
const findChannel = facets => {
|
|
1295
|
-
var _facets$find$value4, _facets$find4;
|
|
1296
|
-
|
|
1297
|
-
return (_facets$find$value4 = facets == null ? void 0 : (_facets$find4 = facets.find(facet => facet.key === 'channel')) == null ? void 0 : _facets$find4.value) != null ? _facets$find$value4 : null;
|
|
1298
|
-
};
|
|
1299
|
-
|
|
1300
1445
|
const SORT_MAP = {
|
|
1301
1446
|
price_desc: 'price:desc',
|
|
1302
1447
|
price_asc: 'price:asc',
|
|
@@ -1308,22 +1453,6 @@ const SORT_MAP = {
|
|
|
1308
1453
|
score_desc: ''
|
|
1309
1454
|
};
|
|
1310
1455
|
|
|
1311
|
-
/**
|
|
1312
|
-
* More info at: https://en.wikipedia.org/wiki/Order_statistic
|
|
1313
|
-
*/
|
|
1314
|
-
// O(n) search to find the max of an array
|
|
1315
|
-
const min = (array, cmp) => {
|
|
1316
|
-
let best = 0;
|
|
1317
|
-
|
|
1318
|
-
for (let curr = 1; curr < array.length; curr++) {
|
|
1319
|
-
if (cmp(array[best], array[curr]) > 0) {
|
|
1320
|
-
best = curr;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
return array[best];
|
|
1325
|
-
};
|
|
1326
|
-
|
|
1327
1456
|
/**
|
|
1328
1457
|
* This function implements Portal heuristics for returning the best sku for a product.
|
|
1329
1458
|
*
|
|
@@ -1539,7 +1668,8 @@ const StoreReview = {
|
|
|
1539
1668
|
})
|
|
1540
1669
|
};
|
|
1541
1670
|
|
|
1542
|
-
const
|
|
1671
|
+
const isRootFacet = facet => facet.key === 'category-1';
|
|
1672
|
+
|
|
1543
1673
|
const StoreSearchResult = {
|
|
1544
1674
|
suggestions: async (searchArgs, _, ctx) => {
|
|
1545
1675
|
const {
|
|
@@ -1620,29 +1750,14 @@ const StoreSearchResult = {
|
|
|
1620
1750
|
search: is
|
|
1621
1751
|
}
|
|
1622
1752
|
} = ctx;
|
|
1753
|
+
ctx.storage.searchArgs = searchArgs;
|
|
1623
1754
|
const {
|
|
1624
|
-
facets
|
|
1755
|
+
facets = []
|
|
1625
1756
|
} = await is.facets(searchArgs);
|
|
1626
1757
|
const isCollectionPage = !searchArgs.query;
|
|
1627
|
-
const filteredFacets = facets
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
if (shouldRemoveFacetFromCollectionPage) {
|
|
1632
|
-
return acc;
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
currentFacet.values.sort((a, b) => {
|
|
1636
|
-
var _a$name, _b$name;
|
|
1637
|
-
|
|
1638
|
-
const firstItemLabel = (_a$name = a.name) != null ? _a$name : '';
|
|
1639
|
-
const secondItemLabel = (_b$name = b.name) != null ? _b$name : '';
|
|
1640
|
-
return firstItemLabel.localeCompare(secondItemLabel);
|
|
1641
|
-
});
|
|
1642
|
-
acc.push(currentFacet);
|
|
1643
|
-
return acc;
|
|
1644
|
-
}, []);
|
|
1645
|
-
return filteredFacets != null ? filteredFacets : [];
|
|
1758
|
+
const filteredFacets = facets // Remove root facet on category pages
|
|
1759
|
+
.filter(facet => !isCollectionPage || !isRootFacet(facet));
|
|
1760
|
+
return filteredFacets;
|
|
1646
1761
|
}
|
|
1647
1762
|
};
|
|
1648
1763
|
|
|
@@ -1659,70 +1774,15 @@ const StoreSeo = {
|
|
|
1659
1774
|
titleTemplate: () => ''
|
|
1660
1775
|
};
|
|
1661
1776
|
|
|
1662
|
-
const ObjectOrString = /*#__PURE__*/new GraphQLScalarType({
|
|
1663
|
-
name: 'ObjectOrString',
|
|
1664
|
-
description: 'A string or the string representation of an object (a stringified object).',
|
|
1665
|
-
parseValue: toObjectOrString,
|
|
1666
|
-
serialize: stringify,
|
|
1667
|
-
|
|
1668
|
-
parseLiteral(ast) {
|
|
1669
|
-
if (ast.kind === Kind.STRING) {
|
|
1670
|
-
return getValueAsObjectOrString(ast.value);
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
return null;
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
});
|
|
1677
|
-
|
|
1678
|
-
function toObjectOrString(value) {
|
|
1679
|
-
if (typeof value === 'string') {
|
|
1680
|
-
return getValueAsObjectOrString(value);
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
return null;
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
function getValueAsObjectOrString(value) {
|
|
1687
|
-
try {
|
|
1688
|
-
return JSON.parse(value);
|
|
1689
|
-
} catch (e) {
|
|
1690
|
-
return value;
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
function stringify(value) {
|
|
1695
|
-
if (typeof value === 'object') {
|
|
1696
|
-
return JSON.stringify(value);
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
if (typeof value === 'string') {
|
|
1700
|
-
return value;
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
return null;
|
|
1704
|
-
}
|
|
1705
|
-
|
|
1706
|
-
const StorePropertyValue = {
|
|
1707
|
-
propertyID: root => getPropertyId(root),
|
|
1708
|
-
name: ({
|
|
1709
|
-
name
|
|
1710
|
-
}) => name,
|
|
1711
|
-
value: ({
|
|
1712
|
-
value
|
|
1713
|
-
}) => value,
|
|
1714
|
-
valueReference: ({
|
|
1715
|
-
valueReference
|
|
1716
|
-
}) => valueReference
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
1777
|
const Resolvers = {
|
|
1720
1778
|
StoreCollection,
|
|
1721
1779
|
StoreAggregateOffer,
|
|
1722
1780
|
StoreProduct,
|
|
1723
1781
|
StoreSeo,
|
|
1724
1782
|
StoreFacet,
|
|
1725
|
-
|
|
1783
|
+
StoreFacetBoolean,
|
|
1784
|
+
StoreFacetRange,
|
|
1785
|
+
StoreFacetValueBoolean,
|
|
1726
1786
|
StoreOffer,
|
|
1727
1787
|
StoreAggregateRating,
|
|
1728
1788
|
StoreReview,
|
|
@@ -1765,8 +1825,8 @@ var doc$4 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","de
|
|
|
1765
1825
|
var doc$5 = {"kind":"Document","definitions":[{"kind":"EnumTypeDefinition","description":{"kind":"StringValue","value":"Product collection type. Possible values are `Department`, `Category`, `Brand` or `Cluster`.","block":true},"name":{"kind":"Name","value":"StoreCollectionType"},"directives":[],"values":[{"kind":"EnumValueDefinition","description":{"kind":"StringValue","value":"First level of product categorization.","block":true},"name":{"kind":"Name","value":"Department"},"directives":[]},{"kind":"EnumValueDefinition","description":{"kind":"StringValue","value":"Second level of product categorization.","block":true},"name":{"kind":"Name","value":"Category"},"directives":[]},{"kind":"EnumValueDefinition","description":{"kind":"StringValue","value":"Product brand.","block":true},"name":{"kind":"Name","value":"Brand"},"directives":[]},{"kind":"EnumValueDefinition","description":{"kind":"StringValue","value":"Product cluster.","block":true},"name":{"kind":"Name","value":"Cluster"},"directives":[]}]},{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Product collection facet, used for search.","block":true},"name":{"kind":"Name","value":"StoreCollectionFacet"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet key.","block":true},"name":{"kind":"Name","value":"key"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet value.","block":true},"name":{"kind":"Name","value":"value"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Collection meta information. Used for search.","block":true},"name":{"kind":"Name","value":"StoreCollectionMeta"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"List of selected collection facets.","block":true},"name":{"kind":"Name","value":"selectedFacets"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionFacet"}}}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Product collection information.","block":true},"name":{"kind":"Name","value":"StoreCollection"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Meta tag data.","block":true},"name":{"kind":"Name","value":"seo"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreSeo"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"List of items consisting of chain linked web pages, ending with the current page.","block":true},"name":{"kind":"Name","value":"breadcrumbList"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreBreadcrumbList"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Collection meta information. Used for search.","block":true},"name":{"kind":"Name","value":"meta"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionMeta"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Collection ID.","block":true},"name":{"kind":"Name","value":"id"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Corresponding collection URL slug, with which to retrieve this entity.","block":true},"name":{"kind":"Name","value":"slug"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Collection type.","block":true},"name":{"kind":"Name","value":"type"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreCollectionType"}}},"directives":[]}]}],"loc":{"start":0,"end":1218}};
|
|
1766
1826
|
doc$5.loc.source = {"body":"\"\"\"\nProduct collection type. Possible values are `Department`, `Category`, `Brand` or `Cluster`.\n\"\"\"\nenum StoreCollectionType {\n \"\"\"\n First level of product categorization.\n \"\"\"\n Department\n \"\"\"\n Second level of product categorization.\n \"\"\"\n Category\n \"\"\"\n Product brand.\n \"\"\"\n Brand\n \"\"\"\n Product cluster.\n \"\"\"\n Cluster\n}\n\n\"\"\"\nProduct collection facet, used for search.\n\"\"\"\ntype StoreCollectionFacet {\n \"\"\"\n Facet key.\n \"\"\"\n key: String!\n \"\"\"\n Facet value.\n \"\"\"\n value: String!\n}\n\n\"\"\"\nCollection meta information. Used for search.\n\"\"\"\ntype StoreCollectionMeta {\n \"\"\"\n List of selected collection facets.\n \"\"\"\n selectedFacets: [StoreCollectionFacet!]!\n}\n\n\"\"\"\nProduct collection information.\n\"\"\"\ntype StoreCollection {\n \"\"\"\n Meta tag data.\n \"\"\"\n seo: StoreSeo!\n \"\"\"\n List of items consisting of chain linked web pages, ending with the current page.\n \"\"\"\n breadcrumbList: StoreBreadcrumbList!\n \"\"\"\n Collection meta information. Used for search.\n \"\"\"\n meta: StoreCollectionMeta!\n \"\"\"\n Collection ID.\n \"\"\"\n id: ID!\n \"\"\"\n Corresponding collection URL slug, with which to retrieve this entity.\n \"\"\"\n slug: String!\n \"\"\"\n Collection type.\n \"\"\"\n type: StoreCollectionType!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
1767
1827
|
|
|
1768
|
-
var doc$6 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Search facet information.","block":true},"name":{"kind":"Name","value":"
|
|
1769
|
-
doc$6.loc.source = {"body":"\"\"\"\nSearch facet information.\n\"\"\"\ntype
|
|
1828
|
+
var doc$6 = {"kind":"Document","definitions":[{"kind":"UnionTypeDefinition","name":{"kind":"Name","value":"StoreFacet"},"directives":[],"types":[{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetRange"}},{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetBoolean"}}]},{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Search facet range information.","block":true},"name":{"kind":"Name","value":"StoreFacetRange"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet key.","block":true},"name":{"kind":"Name","value":"key"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet label.","block":true},"name":{"kind":"Name","value":"label"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Array with information on each facet value.","block":true},"name":{"kind":"Name","value":"min"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetValueRange"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"max"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetValueRange"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Search facet boolean information.","block":true},"name":{"kind":"Name","value":"StoreFacetBoolean"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet key.","block":true},"name":{"kind":"Name","value":"key"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet label.","block":true},"name":{"kind":"Name","value":"label"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Array with information on each facet value.","block":true},"name":{"kind":"Name","value":"values"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetValueBoolean"}}}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","name":{"kind":"Name","value":"StoreFacetValueRange"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","name":{"kind":"Name","value":"absolute"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","name":{"kind":"Name","value":"selected"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]}]},{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Information of a specific facet value.","block":true},"name":{"kind":"Name","value":"StoreFacetValueBoolean"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet value.","block":true},"name":{"kind":"Name","value":"value"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Facet value label.","block":true},"name":{"kind":"Name","value":"label"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Indicates whether facet is selected.","block":true},"name":{"kind":"Name","value":"selected"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Number of items with this facet.","block":true},"name":{"kind":"Name","value":"quantity"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},"directives":[]}]}],"loc":{"start":0,"end":949}};
|
|
1829
|
+
doc$6.loc.source = {"body":"union StoreFacet = StoreFacetRange | StoreFacetBoolean\n\n\"\"\"\nSearch facet range information.\n\"\"\"\ntype StoreFacetRange {\n \"\"\"\n Facet key.\n \"\"\"\n key: String!\n \"\"\"\n Facet label.\n \"\"\"\n label: String!\n \"\"\"\n Array with information on each facet value.\n \"\"\"\n min: StoreFacetValueRange!\n max: StoreFacetValueRange!\n}\n\n\"\"\"\nSearch facet boolean information.\n\"\"\"\ntype StoreFacetBoolean {\n \"\"\"\n Facet key.\n \"\"\"\n key: String!\n \"\"\"\n Facet label.\n \"\"\"\n label: String!\n \"\"\"\n Array with information on each facet value.\n \"\"\"\n values: [StoreFacetValueBoolean!]!\n}\n\ntype StoreFacetValueRange {\n absolute: Float!\n selected: Float!\n}\n\n\"\"\"\nInformation of a specific facet value.\n\"\"\"\ntype StoreFacetValueBoolean {\n \"\"\"\n Facet value.\n \"\"\"\n value: String!\n \"\"\"\n Facet value label.\n \"\"\"\n label: String!\n \"\"\"\n Indicates whether facet is selected.\n \"\"\"\n selected: Boolean!\n \"\"\"\n Number of items with this facet.\n \"\"\"\n quantity: Int!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|
|
1770
1830
|
|
|
1771
1831
|
var doc$7 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Image.","block":true},"name":{"kind":"Name","value":"StoreImage"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Image URL.","block":true},"name":{"kind":"Name","value":"url"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Alias for the image.","block":true},"name":{"kind":"Name","value":"alternateName"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]},{"kind":"InputObjectTypeDefinition","description":{"kind":"StringValue","value":"Image input.","block":true},"name":{"kind":"Name","value":"IStoreImage"},"directives":[],"fields":[{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Image input URL.","block":true},"name":{"kind":"Name","value":"url"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]},{"kind":"InputValueDefinition","description":{"kind":"StringValue","value":"Alias for the input image.","block":true},"name":{"kind":"Name","value":"alternateName"},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}]}],"loc":{"start":0,"end":291}};
|
|
1772
1832
|
doc$7.loc.source = {"body":"\"\"\"\nImage.\n\"\"\"\ntype StoreImage {\n \"\"\"\n Image URL.\n \"\"\"\n url: String!\n \"\"\"\n Alias for the image.\n \"\"\"\n alternateName: String!\n}\n\n\"\"\"\nImage input.\n\"\"\"\ninput IStoreImage {\n \"\"\"\n Image input URL.\n \"\"\"\n url: String!\n \"\"\"\n Alias for the input image.\n \"\"\"\n alternateName: String!\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
|