@faststore/api 1.9.9 → 1.9.17
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 +27 -0
- package/dist/__generated__/schema.d.ts +27 -8
- package/dist/api.cjs.development.js +254 -196
- 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 +3 -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 +40 -6
- package/dist/platforms/vtex/resolvers/facetValue.d.ts +0 -5
- package/src/platforms/vtex/resolvers/facetValue.ts +0 -12
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
4
|
|
|
7
5
|
var schema = require('@graphql-tools/schema');
|
|
@@ -621,30 +619,199 @@ const StoreCollection = {
|
|
|
621
619
|
}
|
|
622
620
|
};
|
|
623
621
|
|
|
622
|
+
class ChannelMarshal {
|
|
623
|
+
static parse(channelString) {
|
|
624
|
+
try {
|
|
625
|
+
var _parsedChannel$region, _parsedChannel$salesC;
|
|
626
|
+
|
|
627
|
+
const parsedChannel = JSON.parse(channelString);
|
|
628
|
+
return {
|
|
629
|
+
regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
|
|
630
|
+
salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
|
|
631
|
+
};
|
|
632
|
+
} catch (error) {
|
|
633
|
+
console.error(error);
|
|
634
|
+
throw new Error('Malformed channel string');
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
static stringify(channel) {
|
|
639
|
+
return JSON.stringify(channel);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Transform facets from the store to VTEX platform facets.
|
|
646
|
+
* For instance, the channel in Store becomes trade-policy and regionId in VTEX's realm
|
|
647
|
+
* */
|
|
648
|
+
|
|
649
|
+
const transformSelectedFacet = ({
|
|
650
|
+
key,
|
|
651
|
+
value
|
|
652
|
+
}) => {
|
|
653
|
+
switch (key) {
|
|
654
|
+
case 'channel':
|
|
655
|
+
{
|
|
656
|
+
const channel = ChannelMarshal.parse(value);
|
|
657
|
+
const channelFacets = [{
|
|
658
|
+
key: 'trade-policy',
|
|
659
|
+
value: channel.salesChannel
|
|
660
|
+
}];
|
|
661
|
+
|
|
662
|
+
if (channel.regionId) {
|
|
663
|
+
channelFacets.push({
|
|
664
|
+
key: 'region-id',
|
|
665
|
+
value: channel.regionId
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
return channelFacets;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
case 'locale':
|
|
673
|
+
{
|
|
674
|
+
return []; // remove this facet from search
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
case 'price':
|
|
678
|
+
{
|
|
679
|
+
return {
|
|
680
|
+
key,
|
|
681
|
+
value: value.replace('-to-', ':')
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
default:
|
|
686
|
+
return {
|
|
687
|
+
key,
|
|
688
|
+
value
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
const parseRange = range => {
|
|
693
|
+
const splitted = range.split(':').map(Number);
|
|
694
|
+
|
|
695
|
+
if (splitted.length !== 2 || Number.isNaN(splitted[0]) || Number.isNaN(splitted[1])) {
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return splitted;
|
|
700
|
+
};
|
|
701
|
+
const findSlug = facets => {
|
|
702
|
+
var _facets$find$value, _facets$find;
|
|
703
|
+
|
|
704
|
+
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;
|
|
705
|
+
};
|
|
706
|
+
const findSkuId = facets => {
|
|
707
|
+
var _facets$find$value2, _facets$find2;
|
|
708
|
+
|
|
709
|
+
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;
|
|
710
|
+
};
|
|
711
|
+
const findLocale = facets => {
|
|
712
|
+
var _facets$find$value3, _facets$find3;
|
|
713
|
+
|
|
714
|
+
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;
|
|
715
|
+
};
|
|
716
|
+
const findChannel = facets => {
|
|
717
|
+
var _facets$find$value4, _facets$find4;
|
|
718
|
+
|
|
719
|
+
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;
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* More info at: https://en.wikipedia.org/wiki/Order_statistic
|
|
724
|
+
*/
|
|
725
|
+
// O(n) search to find the max of an array
|
|
726
|
+
const min = (array, cmp) => {
|
|
727
|
+
let best = 0;
|
|
728
|
+
|
|
729
|
+
for (let curr = 1; curr < array.length; curr++) {
|
|
730
|
+
if (cmp(array[best], array[curr]) > 0) {
|
|
731
|
+
best = curr;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
return array[best];
|
|
736
|
+
};
|
|
737
|
+
|
|
624
738
|
const StoreFacet = {
|
|
739
|
+
__resolveType: ({
|
|
740
|
+
type
|
|
741
|
+
}) => type === 'TEXT' ? 'StoreFacetBoolean' : 'StoreFacetRange'
|
|
742
|
+
};
|
|
743
|
+
const StoreFacetBoolean = {
|
|
625
744
|
key: ({
|
|
626
745
|
key
|
|
627
|
-
}) => key
|
|
746
|
+
}) => key,
|
|
628
747
|
label: ({
|
|
629
748
|
name
|
|
630
|
-
}) => name
|
|
749
|
+
}) => name,
|
|
631
750
|
values: ({
|
|
632
751
|
values
|
|
633
|
-
}) => values,
|
|
634
|
-
type: ({
|
|
635
|
-
type
|
|
636
|
-
}) => type === 'TEXT' ? 'BOOLEAN' : 'RANGE'
|
|
752
|
+
}) => values.sort((a, b) => a.name.localeCompare(b.name))
|
|
637
753
|
};
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
754
|
+
const StoreFacetRange = {
|
|
755
|
+
key: ({
|
|
756
|
+
key
|
|
757
|
+
}) => key,
|
|
758
|
+
label: ({
|
|
759
|
+
name
|
|
760
|
+
}) => name,
|
|
761
|
+
min: ({
|
|
762
|
+
values,
|
|
763
|
+
key
|
|
764
|
+
}, _, {
|
|
765
|
+
storage: {
|
|
766
|
+
searchArgs
|
|
767
|
+
}
|
|
643
768
|
}) => {
|
|
644
|
-
var
|
|
769
|
+
var _searchArgs$selectedF, _searchArgs$selectedF2, _searchArgs$selectedF3, _facet$range$from, _selectedRange$;
|
|
645
770
|
|
|
646
|
-
|
|
771
|
+
/**
|
|
772
|
+
* Fetch the selected range the user queried.
|
|
773
|
+
*
|
|
774
|
+
* This is necessary because, differently from boolean facets, Search API does
|
|
775
|
+
* not return the selected values, making us have to implement it in here
|
|
776
|
+
*/
|
|
777
|
+
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 : '');
|
|
778
|
+
const facet = min(values, (a, b) => a.range.from - b.range.from);
|
|
779
|
+
const globalMin = (_facet$range$from = facet == null ? void 0 : facet.range.from) != null ? _facet$range$from : 0;
|
|
780
|
+
return {
|
|
781
|
+
selected: (_selectedRange$ = selectedRange == null ? void 0 : selectedRange[0]) != null ? _selectedRange$ : globalMin,
|
|
782
|
+
absolute: globalMin
|
|
783
|
+
};
|
|
647
784
|
},
|
|
785
|
+
max: ({
|
|
786
|
+
values,
|
|
787
|
+
key
|
|
788
|
+
}, _, {
|
|
789
|
+
storage: {
|
|
790
|
+
searchArgs
|
|
791
|
+
}
|
|
792
|
+
}) => {
|
|
793
|
+
var _searchArgs$selectedF4, _searchArgs$selectedF5, _searchArgs$selectedF6, _facet$range$to, _selectedRange$2;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Fetch the selected range the user queried.
|
|
797
|
+
*
|
|
798
|
+
* This is necessary because, differently from boolean facets, Search API does
|
|
799
|
+
* not return the selected values, making us have to implement it in here
|
|
800
|
+
*/
|
|
801
|
+
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 : '');
|
|
802
|
+
const facet = min(values, (a, b) => b.range.to - a.range.to);
|
|
803
|
+
const globalMax = (_facet$range$to = facet == null ? void 0 : facet.range.to) != null ? _facet$range$to : 0;
|
|
804
|
+
return {
|
|
805
|
+
selected: (_selectedRange$2 = selectedRange == null ? void 0 : selectedRange[1]) != null ? _selectedRange$2 : globalMax,
|
|
806
|
+
absolute: globalMax
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
const StoreFacetValueBoolean = {
|
|
812
|
+
value: ({
|
|
813
|
+
value
|
|
814
|
+
}) => value,
|
|
648
815
|
label: ({
|
|
649
816
|
name
|
|
650
817
|
}) => name || 'unknown',
|
|
@@ -894,28 +1061,6 @@ const validateCart = async (_, {
|
|
|
894
1061
|
return orderFormToCart(updatedOrderForm, skuLoader);
|
|
895
1062
|
};
|
|
896
1063
|
|
|
897
|
-
class ChannelMarshal {
|
|
898
|
-
static parse(channelString) {
|
|
899
|
-
try {
|
|
900
|
-
var _parsedChannel$region, _parsedChannel$salesC;
|
|
901
|
-
|
|
902
|
-
const parsedChannel = JSON.parse(channelString);
|
|
903
|
-
return {
|
|
904
|
-
regionId: (_parsedChannel$region = parsedChannel.regionId) != null ? _parsedChannel$region : '',
|
|
905
|
-
salesChannel: (_parsedChannel$salesC = parsedChannel.salesChannel) != null ? _parsedChannel$salesC : ''
|
|
906
|
-
};
|
|
907
|
-
} catch (error) {
|
|
908
|
-
console.error(error);
|
|
909
|
-
throw new Error('Malformed channel string');
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
static stringify(channel) {
|
|
914
|
-
return JSON.stringify(channel);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
|
|
919
1064
|
const validateSession = async (_, {
|
|
920
1065
|
session: oldSession,
|
|
921
1066
|
search
|
|
@@ -965,6 +1110,50 @@ const Mutation = {
|
|
|
965
1110
|
validateSession
|
|
966
1111
|
};
|
|
967
1112
|
|
|
1113
|
+
const ObjectOrString = /*#__PURE__*/new graphql.GraphQLScalarType({
|
|
1114
|
+
name: 'ObjectOrString',
|
|
1115
|
+
description: 'A string or the string representation of an object (a stringified object).',
|
|
1116
|
+
parseValue: toObjectOrString,
|
|
1117
|
+
serialize: stringify,
|
|
1118
|
+
|
|
1119
|
+
parseLiteral(ast) {
|
|
1120
|
+
if (ast.kind === language.Kind.STRING) {
|
|
1121
|
+
return getValueAsObjectOrString(ast.value);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
function toObjectOrString(value) {
|
|
1130
|
+
if (typeof value === 'string') {
|
|
1131
|
+
return getValueAsObjectOrString(value);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function getValueAsObjectOrString(value) {
|
|
1138
|
+
try {
|
|
1139
|
+
return JSON.parse(value);
|
|
1140
|
+
} catch (e) {
|
|
1141
|
+
return value;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
function stringify(value) {
|
|
1146
|
+
if (typeof value === 'object') {
|
|
1147
|
+
return JSON.stringify(value);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
if (typeof value === 'string') {
|
|
1151
|
+
return value;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
return null;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
968
1157
|
const isSearchItem = item => 'Price' in item && 'seller' in item && 'product' in item;
|
|
969
1158
|
|
|
970
1159
|
const isOrderFormItem = item => 'skuName' in item;
|
|
@@ -1039,7 +1228,9 @@ const StoreOffer = {
|
|
|
1039
1228
|
},
|
|
1040
1229
|
listPrice: root => {
|
|
1041
1230
|
if (isSearchItem(root)) {
|
|
1042
|
-
|
|
1231
|
+
var _root$ListPrice;
|
|
1232
|
+
|
|
1233
|
+
return (_root$ListPrice = root.ListPrice) != null ? _root$ListPrice : 0;
|
|
1043
1234
|
}
|
|
1044
1235
|
|
|
1045
1236
|
if (isOrderFormItem(root)) {
|
|
@@ -1235,6 +1426,19 @@ const StoreProductGroup = {
|
|
|
1235
1426
|
}))))
|
|
1236
1427
|
};
|
|
1237
1428
|
|
|
1429
|
+
const StorePropertyValue = {
|
|
1430
|
+
propertyID: root => getPropertyId(root),
|
|
1431
|
+
name: ({
|
|
1432
|
+
name
|
|
1433
|
+
}) => name,
|
|
1434
|
+
value: ({
|
|
1435
|
+
value
|
|
1436
|
+
}) => value,
|
|
1437
|
+
valueReference: ({
|
|
1438
|
+
valueReference
|
|
1439
|
+
}) => valueReference
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1238
1442
|
const mutateChannelContext = (ctx, channelString) => {
|
|
1239
1443
|
ctx.storage.channel = ChannelMarshal.parse(channelString);
|
|
1240
1444
|
};
|
|
@@ -1242,67 +1446,6 @@ const mutateLocaleContext = (ctx, locale) => {
|
|
|
1242
1446
|
ctx.storage.locale = locale;
|
|
1243
1447
|
};
|
|
1244
1448
|
|
|
1245
|
-
/**
|
|
1246
|
-
* Transform facets from the store to VTEX platform facets.
|
|
1247
|
-
* For instance, the channel in Store becomes trade-policy and regionId in VTEX's realm
|
|
1248
|
-
* */
|
|
1249
|
-
|
|
1250
|
-
const transformSelectedFacet = ({
|
|
1251
|
-
key,
|
|
1252
|
-
value
|
|
1253
|
-
}) => {
|
|
1254
|
-
switch (key) {
|
|
1255
|
-
case 'channel':
|
|
1256
|
-
{
|
|
1257
|
-
const channel = ChannelMarshal.parse(value);
|
|
1258
|
-
const channelFacets = [{
|
|
1259
|
-
key: 'trade-policy',
|
|
1260
|
-
value: channel.salesChannel
|
|
1261
|
-
}];
|
|
1262
|
-
|
|
1263
|
-
if (channel.regionId) {
|
|
1264
|
-
channelFacets.push({
|
|
1265
|
-
key: 'region-id',
|
|
1266
|
-
value: channel.regionId
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
return channelFacets;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
case 'locale':
|
|
1274
|
-
{
|
|
1275
|
-
return []; // remove this facet from search
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
default:
|
|
1279
|
-
return {
|
|
1280
|
-
key,
|
|
1281
|
-
value
|
|
1282
|
-
};
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
const findSlug = facets => {
|
|
1286
|
-
var _facets$find$value, _facets$find;
|
|
1287
|
-
|
|
1288
|
-
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;
|
|
1289
|
-
};
|
|
1290
|
-
const findSkuId = facets => {
|
|
1291
|
-
var _facets$find$value2, _facets$find2;
|
|
1292
|
-
|
|
1293
|
-
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;
|
|
1294
|
-
};
|
|
1295
|
-
const findLocale = facets => {
|
|
1296
|
-
var _facets$find$value3, _facets$find3;
|
|
1297
|
-
|
|
1298
|
-
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;
|
|
1299
|
-
};
|
|
1300
|
-
const findChannel = facets => {
|
|
1301
|
-
var _facets$find$value4, _facets$find4;
|
|
1302
|
-
|
|
1303
|
-
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;
|
|
1304
|
-
};
|
|
1305
|
-
|
|
1306
1449
|
const SORT_MAP = {
|
|
1307
1450
|
price_desc: 'price:desc',
|
|
1308
1451
|
price_asc: 'price:asc',
|
|
@@ -1314,22 +1457,6 @@ const SORT_MAP = {
|
|
|
1314
1457
|
score_desc: ''
|
|
1315
1458
|
};
|
|
1316
1459
|
|
|
1317
|
-
/**
|
|
1318
|
-
* More info at: https://en.wikipedia.org/wiki/Order_statistic
|
|
1319
|
-
*/
|
|
1320
|
-
// O(n) search to find the max of an array
|
|
1321
|
-
const min = (array, cmp) => {
|
|
1322
|
-
let best = 0;
|
|
1323
|
-
|
|
1324
|
-
for (let curr = 1; curr < array.length; curr++) {
|
|
1325
|
-
if (cmp(array[best], array[curr]) > 0) {
|
|
1326
|
-
best = curr;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
return array[best];
|
|
1331
|
-
};
|
|
1332
|
-
|
|
1333
1460
|
/**
|
|
1334
1461
|
* This function implements Portal heuristics for returning the best sku for a product.
|
|
1335
1462
|
*
|
|
@@ -1545,7 +1672,8 @@ const StoreReview = {
|
|
|
1545
1672
|
})
|
|
1546
1673
|
};
|
|
1547
1674
|
|
|
1548
|
-
const
|
|
1675
|
+
const isRootFacet = facet => facet.key === 'category-1';
|
|
1676
|
+
|
|
1549
1677
|
const StoreSearchResult = {
|
|
1550
1678
|
suggestions: async (searchArgs, _, ctx) => {
|
|
1551
1679
|
const {
|
|
@@ -1626,29 +1754,14 @@ const StoreSearchResult = {
|
|
|
1626
1754
|
search: is
|
|
1627
1755
|
}
|
|
1628
1756
|
} = ctx;
|
|
1757
|
+
ctx.storage.searchArgs = searchArgs;
|
|
1629
1758
|
const {
|
|
1630
|
-
facets
|
|
1759
|
+
facets = []
|
|
1631
1760
|
} = await is.facets(searchArgs);
|
|
1632
1761
|
const isCollectionPage = !searchArgs.query;
|
|
1633
|
-
const filteredFacets = facets
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
if (shouldRemoveFacetFromCollectionPage) {
|
|
1638
|
-
return acc;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
currentFacet.values.sort((a, b) => {
|
|
1642
|
-
var _a$name, _b$name;
|
|
1643
|
-
|
|
1644
|
-
const firstItemLabel = (_a$name = a.name) != null ? _a$name : '';
|
|
1645
|
-
const secondItemLabel = (_b$name = b.name) != null ? _b$name : '';
|
|
1646
|
-
return firstItemLabel.localeCompare(secondItemLabel);
|
|
1647
|
-
});
|
|
1648
|
-
acc.push(currentFacet);
|
|
1649
|
-
return acc;
|
|
1650
|
-
}, []);
|
|
1651
|
-
return filteredFacets != null ? filteredFacets : [];
|
|
1762
|
+
const filteredFacets = facets // Remove root facet on category pages
|
|
1763
|
+
.filter(facet => !isCollectionPage || !isRootFacet(facet));
|
|
1764
|
+
return filteredFacets;
|
|
1652
1765
|
}
|
|
1653
1766
|
};
|
|
1654
1767
|
|
|
@@ -1665,70 +1778,15 @@ const StoreSeo = {
|
|
|
1665
1778
|
titleTemplate: () => ''
|
|
1666
1779
|
};
|
|
1667
1780
|
|
|
1668
|
-
const ObjectOrString = /*#__PURE__*/new graphql.GraphQLScalarType({
|
|
1669
|
-
name: 'ObjectOrString',
|
|
1670
|
-
description: 'A string or the string representation of an object (a stringified object).',
|
|
1671
|
-
parseValue: toObjectOrString,
|
|
1672
|
-
serialize: stringify,
|
|
1673
|
-
|
|
1674
|
-
parseLiteral(ast) {
|
|
1675
|
-
if (ast.kind === language.Kind.STRING) {
|
|
1676
|
-
return getValueAsObjectOrString(ast.value);
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
return null;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
});
|
|
1683
|
-
|
|
1684
|
-
function toObjectOrString(value) {
|
|
1685
|
-
if (typeof value === 'string') {
|
|
1686
|
-
return getValueAsObjectOrString(value);
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
return null;
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
function getValueAsObjectOrString(value) {
|
|
1693
|
-
try {
|
|
1694
|
-
return JSON.parse(value);
|
|
1695
|
-
} catch (e) {
|
|
1696
|
-
return value;
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
function stringify(value) {
|
|
1701
|
-
if (typeof value === 'object') {
|
|
1702
|
-
return JSON.stringify(value);
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
if (typeof value === 'string') {
|
|
1706
|
-
return value;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
return null;
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
const StorePropertyValue = {
|
|
1713
|
-
propertyID: root => getPropertyId(root),
|
|
1714
|
-
name: ({
|
|
1715
|
-
name
|
|
1716
|
-
}) => name,
|
|
1717
|
-
value: ({
|
|
1718
|
-
value
|
|
1719
|
-
}) => value,
|
|
1720
|
-
valueReference: ({
|
|
1721
|
-
valueReference
|
|
1722
|
-
}) => valueReference
|
|
1723
|
-
};
|
|
1724
|
-
|
|
1725
1781
|
const Resolvers = {
|
|
1726
1782
|
StoreCollection,
|
|
1727
1783
|
StoreAggregateOffer,
|
|
1728
1784
|
StoreProduct,
|
|
1729
1785
|
StoreSeo,
|
|
1730
1786
|
StoreFacet,
|
|
1731
|
-
|
|
1787
|
+
StoreFacetBoolean,
|
|
1788
|
+
StoreFacetRange,
|
|
1789
|
+
StoreFacetValueBoolean,
|
|
1732
1790
|
StoreOffer,
|
|
1733
1791
|
StoreAggregateRating,
|
|
1734
1792
|
StoreReview,
|
|
@@ -1771,8 +1829,8 @@ var doc$4 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","de
|
|
|
1771
1829
|
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}};
|
|
1772
1830
|
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}};
|
|
1773
1831
|
|
|
1774
|
-
var doc$6 = {"kind":"Document","definitions":[{"kind":"ObjectTypeDefinition","description":{"kind":"StringValue","value":"Search facet information.","block":true},"name":{"kind":"Name","value":"
|
|
1775
|
-
doc$6.loc.source = {"body":"\"\"\"\nSearch facet information.\n\"\"\"\ntype
|
|
1832
|
+
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":"Minimum facet range value.","block":true},"name":{"kind":"Name","value":"min"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StoreFacetValueRange"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Maximum facet range value.","block":true},"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","description":{"kind":"StringValue","value":"Search facet range value information. Used for minimum and maximum range values.","block":true},"name":{"kind":"Name","value":"StoreFacetValueRange"},"interfaces":[],"directives":[],"fields":[{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Search facet range absolute value.","block":true},"name":{"kind":"Name","value":"absolute"},"arguments":[],"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}},"directives":[]},{"kind":"FieldDefinition","description":{"kind":"StringValue","value":"Search facet range selected value.","block":true},"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":1160}};
|
|
1833
|
+
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 Minimum facet range value.\n \"\"\"\n min: StoreFacetValueRange!\n \"\"\"\n Maximum facet range value.\n \"\"\"\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\n\"\"\"\nSearch facet range value information. Used for minimum and maximum range values.\n\"\"\"\ntype StoreFacetValueRange {\n \"\"\"\n Search facet range absolute value.\n \"\"\"\n absolute: Float!\n \"\"\"\n Search facet range selected value.\n \"\"\"\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}};
|
|
1776
1834
|
|
|
1777
1835
|
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}};
|
|
1778
1836
|
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}};
|