@dcupl/common 0.0.72 → 0.0.73
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/dist/lib-cjs/getFacetEntries.d.ts +1 -1
- package/dist/lib-cjs/getFacetEntries.js +69 -37
- package/dist/lib-cjs/getFacetEntries.js.map +1 -1
- package/dist/lib-cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/lib-cjs/types/list.types.d.ts +2 -0
- package/dist/lib-cjs/types/model.types.d.ts +3 -0
- package/dist/lib-esm/getFacetEntries.d.ts +1 -1
- package/dist/lib-esm/getFacetEntries.js +69 -37
- package/dist/lib-esm/getFacetEntries.js.map +1 -1
- package/dist/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib-esm/types/list.types.d.ts +2 -0
- package/dist/lib-esm/types/model.types.d.ts +3 -0
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ export declare type DcuplSectionOptions<T> = DcuplItemsOptions<T> & {
|
|
|
22
22
|
export declare type DcuplFilterOptions = CatalogApiOptions & {
|
|
23
23
|
calculateFacets?: boolean;
|
|
24
24
|
excludeZeros?: boolean;
|
|
25
|
+
excludeUndefineds?: boolean;
|
|
25
26
|
count?: number;
|
|
26
27
|
};
|
|
27
28
|
export declare type DcuplFiltersOptions = DcuplFilterOptions & {
|
|
@@ -42,6 +43,7 @@ export declare type DcuplFacetOptions = {
|
|
|
42
43
|
filterKey?: string;
|
|
43
44
|
count?: number;
|
|
44
45
|
excludeZeros?: boolean;
|
|
46
|
+
excludeUndefineds?: boolean;
|
|
45
47
|
calculateFacets?: boolean;
|
|
46
48
|
};
|
|
47
49
|
export declare type ListMetadata = {
|
|
@@ -44,6 +44,7 @@ declare type PropertyBase = {
|
|
|
44
44
|
separator?: string;
|
|
45
45
|
};
|
|
46
46
|
meta?: ModelMetadata;
|
|
47
|
+
index?: boolean;
|
|
47
48
|
};
|
|
48
49
|
export declare type PropertyInt = PropertyBase & {
|
|
49
50
|
type: 'int' | 'Array<int>';
|
|
@@ -105,6 +106,7 @@ export declare type FilterStringSingle = {
|
|
|
105
106
|
export declare type ReferenceFilterDefinition = {
|
|
106
107
|
calculateFacets?: boolean;
|
|
107
108
|
excludeZeros?: boolean;
|
|
109
|
+
excludeUndefineds?: boolean;
|
|
108
110
|
};
|
|
109
111
|
export declare type ReferenceValidity = 'loose' | 'strict';
|
|
110
112
|
/**
|
|
@@ -135,6 +137,7 @@ export declare type ReferenceBase = {
|
|
|
135
137
|
validity?: ReferenceValidity;
|
|
136
138
|
aggregate?: boolean;
|
|
137
139
|
meta?: ModelMetadata;
|
|
140
|
+
index?: boolean;
|
|
138
141
|
};
|
|
139
142
|
export declare type AggregatedReference = ReferenceBase & {
|
|
140
143
|
aggregate: true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ListItem, FilterConstraint, FilterItemEntry, DcuplFilterOptions, InverseIndexValuesMap } from './types';
|
|
2
|
-
export declare function getFacetEntries<ListType extends ListItem = ListItem>(modelData: Map<string, ListType>, remoteModelData: Map<string, ListType>, options: DcuplFilterOptions, constraints: FilterConstraint[], attributeKey: string, indexMap
|
|
2
|
+
export declare function getFacetEntries<ListType extends ListItem = ListItem>(modelData: Map<string, ListType>, remoteModelData: Map<string, ListType>, options: DcuplFilterOptions, constraints: FilterConstraint[], attributeKey: string, indexMap: InverseIndexValuesMap): FilterItemEntry[];
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
+
};
|
|
1
26
|
var __values = (this && this.__values) || function(o) {
|
|
2
27
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
28
|
if (m) return m.call(o);
|
|
@@ -12,49 +37,56 @@ var __values = (this && this.__values) || function(o) {
|
|
|
12
37
|
import { getFilteredData } from './getFilteredData';
|
|
13
38
|
import { getFilterEntryId } from './helper';
|
|
14
39
|
export function getFacetEntries(modelData, remoteModelData, options, constraints, attributeKey, indexMap) {
|
|
15
|
-
var e_1, _a;
|
|
40
|
+
var e_1, _a, e_2, _b;
|
|
16
41
|
var filterItemEntries = [];
|
|
17
42
|
var constraintsExceptSameFilterKey = constraints.filter(function (c) { return c.filterKey !== attributeKey; });
|
|
18
43
|
var currentFilteredData = getFilteredData(modelData, constraintsExceptSameFilterKey, false);
|
|
19
|
-
var
|
|
44
|
+
var validFacetKeys = new Set(__spreadArray([], __read(remoteModelData.keys()), false));
|
|
45
|
+
if (options.excludeUndefineds === false) {
|
|
46
|
+
try {
|
|
47
|
+
for (var _c = __values(indexMap.keys()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
48
|
+
var key = _d.value;
|
|
49
|
+
validFacetKeys.add(key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
56
|
+
}
|
|
57
|
+
finally { if (e_1) throw e_1.error; }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
var _loop_1 = function (validFacetKey) {
|
|
61
|
+
var e_3, _g;
|
|
20
62
|
var result = new Map();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
var key = keys.find(function (k) { return currentFilteredData.has(k); });
|
|
33
|
-
if (key) {
|
|
34
|
-
result.set(key, currentFilteredData.get(key));
|
|
63
|
+
var indexedValueKeys = indexMap.get(validFacetKey) || [];
|
|
64
|
+
try {
|
|
65
|
+
for (var indexedValueKeys_1 = (e_3 = void 0, __values(indexedValueKeys)), indexedValueKeys_1_1 = indexedValueKeys_1.next(); !indexedValueKeys_1_1.done; indexedValueKeys_1_1 = indexedValueKeys_1.next()) {
|
|
66
|
+
var key = indexedValueKeys_1_1.value;
|
|
67
|
+
var value = currentFilteredData.get(key);
|
|
68
|
+
if (value) {
|
|
69
|
+
result.set(key, value);
|
|
70
|
+
if (!(options === null || options === void 0 ? void 0 : options.calculateFacets)) {
|
|
71
|
+
break;
|
|
35
72
|
}
|
|
36
73
|
}
|
|
37
74
|
}
|
|
38
75
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
type: 'referenceConstraint',
|
|
46
|
-
value: dataEntry.key,
|
|
47
|
-
calculateFacets: !!(options === null || options === void 0 ? void 0 : options.calculateFacets),
|
|
48
|
-
};
|
|
49
|
-
result = getFilteredData(currentFilteredData, [constraintToAdd], !(options === null || options === void 0 ? void 0 : options.calculateFacets));
|
|
76
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
77
|
+
finally {
|
|
78
|
+
try {
|
|
79
|
+
if (indexedValueKeys_1_1 && !indexedValueKeys_1_1.done && (_g = indexedValueKeys_1.return)) _g.call(indexedValueKeys_1);
|
|
80
|
+
}
|
|
81
|
+
finally { if (e_3) throw e_3.error; }
|
|
50
82
|
}
|
|
51
83
|
var facetEntry = {
|
|
52
|
-
key:
|
|
53
|
-
value:
|
|
54
|
-
selected: !!constraints.find(function (constraint) { return constraint.uid === getFilterEntryId(attributeKey,
|
|
84
|
+
key: validFacetKey,
|
|
85
|
+
value: validFacetKey,
|
|
86
|
+
selected: !!constraints.find(function (constraint) { return constraint.uid === getFilterEntryId(attributeKey, validFacetKey); }),
|
|
55
87
|
enabled: result.size > 0,
|
|
56
88
|
size: result.size,
|
|
57
|
-
entry:
|
|
89
|
+
entry: remoteModelData.get(validFacetKey),
|
|
58
90
|
resultKeys: Array.from(result.keys()),
|
|
59
91
|
};
|
|
60
92
|
if ((options === null || options === void 0 ? void 0 : options.excludeZeros) && facetEntry.size === 0) {
|
|
@@ -66,19 +98,19 @@ export function getFacetEntries(modelData, remoteModelData, options, constraints
|
|
|
66
98
|
filterItemEntries.push(facetEntry);
|
|
67
99
|
};
|
|
68
100
|
try {
|
|
69
|
-
for (var
|
|
70
|
-
var
|
|
71
|
-
var state_1 = _loop_1(
|
|
101
|
+
for (var _e = __values(validFacetKeys.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
102
|
+
var validFacetKey = _f.value;
|
|
103
|
+
var state_1 = _loop_1(validFacetKey);
|
|
72
104
|
if (typeof state_1 === "object")
|
|
73
105
|
return state_1.value;
|
|
74
106
|
}
|
|
75
107
|
}
|
|
76
|
-
catch (
|
|
108
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
77
109
|
finally {
|
|
78
110
|
try {
|
|
79
|
-
if (
|
|
111
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
80
112
|
}
|
|
81
|
-
finally { if (
|
|
113
|
+
finally { if (e_2) throw e_2.error; }
|
|
82
114
|
}
|
|
83
115
|
return filterItemEntries;
|
|
84
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFacetEntries.js","sourceRoot":"","sources":["../../src/getFacetEntries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFacetEntries.js","sourceRoot":"","sources":["../../src/getFacetEntries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,UAAU,eAAe,CAC7B,SAAgC,EAChC,eAAsC,EACtC,OAA2B,EAC3B,WAA+B,EAC/B,YAAoB,EACpB,QAA+B;;IAE/B,IAAM,iBAAiB,GAAsB,EAAE,CAAC;IAEhD,IAAM,8BAA8B,GAAG,WAAW,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,SAAS,KAAK,YAAY,EAA5B,CAA4B,CAAC,CAAC;IAE/F,IAAM,mBAAmB,GAAG,eAAe,CAAC,SAAS,EAAE,8BAA8B,EAAE,KAAK,CAAC,CAAC;IAE9F,IAAM,cAAc,GAAgB,IAAI,GAAG,0BAAK,eAAe,CAAC,IAAI,EAAE,UAAE,CAAC;IAEzE,IAAI,OAAO,CAAC,iBAAiB,KAAK,KAAK,EAAE;;YACvC,KAAkB,IAAA,KAAA,SAAA,QAAS,CAAC,IAAI,EAAE,CAAA,gBAAA,4BAAE;gBAA/B,IAAM,GAAG,WAAA;gBACZ,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aACzB;;;;;;;;;KACF;4BAEU,aAAa;;QACtB,IAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;QAE3C,IAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;;YAE3D,KAAkB,IAAA,oCAAA,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