@dcupl/common 0.0.74 → 0.0.76

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.
Files changed (37) hide show
  1. package/dist/lib-cjs/computeSuggestions.js.map +1 -1
  2. package/dist/lib-cjs/getConstraints.d.ts +3 -2
  3. package/dist/lib-cjs/getConstraints.js +19 -3
  4. package/dist/lib-cjs/getConstraints.js.map +1 -1
  5. package/dist/lib-cjs/getFacetEntries.js +9 -3
  6. package/dist/lib-cjs/getFacetEntries.js.map +1 -1
  7. package/dist/lib-cjs/getFilteredData.d.ts +2 -1
  8. package/dist/lib-cjs/getFilteredData.js +129 -26
  9. package/dist/lib-cjs/getFilteredData.js.map +1 -1
  10. package/dist/lib-cjs/helper.js +2 -2
  11. package/dist/lib-cjs/helper.js.map +1 -1
  12. package/dist/lib-cjs/tsconfig-cjs.tsbuildinfo +1 -1
  13. package/dist/lib-cjs/types/filter.types.d.ts +30 -15
  14. package/dist/lib-cjs/types/filter.types.js +2 -0
  15. package/dist/lib-cjs/types/filter.types.js.map +1 -1
  16. package/dist/lib-cjs/types/list.types.d.ts +2 -0
  17. package/dist/lib-cjs/types/model.types.d.ts +11 -2
  18. package/dist/lib-cjs/types/model.types.js.map +1 -1
  19. package/dist/lib-esm/computeSuggestions.js.map +1 -1
  20. package/dist/lib-esm/getConstraints.d.ts +3 -2
  21. package/dist/lib-esm/getConstraints.js +17 -2
  22. package/dist/lib-esm/getConstraints.js.map +1 -1
  23. package/dist/lib-esm/getFacetEntries.js +9 -3
  24. package/dist/lib-esm/getFacetEntries.js.map +1 -1
  25. package/dist/lib-esm/getFilteredData.d.ts +2 -1
  26. package/dist/lib-esm/getFilteredData.js +127 -25
  27. package/dist/lib-esm/getFilteredData.js.map +1 -1
  28. package/dist/lib-esm/helper.js +2 -2
  29. package/dist/lib-esm/helper.js.map +1 -1
  30. package/dist/lib-esm/tsconfig.tsbuildinfo +1 -1
  31. package/dist/lib-esm/types/filter.types.d.ts +30 -15
  32. package/dist/lib-esm/types/filter.types.js +1 -1
  33. package/dist/lib-esm/types/filter.types.js.map +1 -1
  34. package/dist/lib-esm/types/list.types.d.ts +2 -0
  35. package/dist/lib-esm/types/model.types.d.ts +11 -2
  36. package/dist/lib-esm/types/model.types.js.map +1 -1
  37. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { ListItem } from '.';
2
2
  import { CatalogApiOptions } from './list.types';
3
3
  import { FilterComparisonType } from './model.types';
4
- export type ConstraintTypes = 'referenceConstraint' | 'textConstraint' | 'numberConstraint' | 'dateConstraint';
4
+ export type ConstraintTypes = 'referenceConstraint' | 'textConstraint' | 'numberConstraint' | 'dateConstraint' | 'booleanConstraint';
5
5
  export type ConstraintBase = {
6
6
  uid: string;
7
7
  filterKey: string;
@@ -10,13 +10,18 @@ export type ConstraintBase = {
10
10
  };
11
11
  export type ReferenceConstraint = ConstraintBase & {
12
12
  type: 'referenceConstraint';
13
- value: string;
13
+ value: string | undefined | null;
14
14
  calculateFacets: boolean;
15
15
  };
16
16
  export type TextConstraint = ConstraintBase & {
17
17
  type: 'textConstraint';
18
18
  comparisonType: FilterComparisonType;
19
- value: string;
19
+ value: string | undefined | null;
20
+ };
21
+ export type BooleanConstraint = ConstraintBase & {
22
+ type: 'booleanConstraint';
23
+ value: boolean | undefined | null;
24
+ calculateFacets: boolean;
20
25
  };
21
26
  export type NumberConstraint = ConstraintBase & NumberConstraintOperators & {
22
27
  type: 'numberConstraint';
@@ -24,13 +29,14 @@ export type NumberConstraint = ConstraintBase & NumberConstraintOperators & {
24
29
  export type DateConstraint = ConstraintBase & DateConstraintOperators & {
25
30
  type: 'dateConstraint';
26
31
  };
27
- export type FilterConstraint = ReferenceConstraint | TextConstraint | NumberConstraint | DateConstraint;
32
+ export type FilterConstraint = ReferenceConstraint | TextConstraint | NumberConstraint | DateConstraint | BooleanConstraint;
33
+ export declare const NumberOperators: string[];
28
34
  export type NumberConstraintOperators = {
29
35
  gt?: number;
30
36
  lt?: number;
31
37
  gte?: number;
32
38
  lte?: number;
33
- eq?: number | number[];
39
+ eq?: number | number[] | null;
34
40
  ne?: number | number[];
35
41
  };
36
42
  export type DateConstraintOperators = {
@@ -38,7 +44,7 @@ export type DateConstraintOperators = {
38
44
  lt?: Date;
39
45
  gte?: Date;
40
46
  lte?: Date;
41
- eq?: Date | Date[];
47
+ eq?: Date | Date[] | null;
42
48
  ne?: Date | Date[];
43
49
  };
44
50
  export type FilterEntryNumberRange = {
@@ -49,8 +55,8 @@ export type FilterEntryDateRange = {
49
55
  min: Date;
50
56
  max: Date;
51
57
  };
52
- export type FilterItemType = 'reference' | 'number' | 'text' | 'date';
53
- export type FilterItemPropertyType = 'number' | 'text' | 'date';
58
+ export type FilterItemType = 'reference' | 'number' | 'text' | 'date' | 'boolean';
59
+ export type FilterItemPropertyType = 'number' | 'text' | 'date' | 'boolean';
54
60
  export type FilterItemReferenceType = 'reference';
55
61
  export type FilterItemBase = {
56
62
  key: string;
@@ -65,7 +71,7 @@ export type FilterItemBase = {
65
71
  export type TextFilterItem = FilterItemBase & {
66
72
  type: 'text';
67
73
  comparisonType: FilterComparisonType;
68
- text: string;
74
+ text: string | undefined | null;
69
75
  };
70
76
  export type NumberFilterItem = FilterItemBase & {
71
77
  type: 'number';
@@ -75,6 +81,10 @@ export type DateFilterItem = FilterItemBase & {
75
81
  type: 'date';
76
82
  range: FilterItemDateRangeValue;
77
83
  };
84
+ export type BooleanFilterItem = FilterItemBase & {
85
+ type: 'boolean';
86
+ entries: Array<FilterItemEntry>;
87
+ };
78
88
  export type FilterItemNumberRangeValue = {
79
89
  available: FilterEntryNumberRange;
80
90
  initial: FilterEntryNumberRange;
@@ -89,14 +99,14 @@ export type ReferenceFilterItem = FilterItemBase & {
89
99
  type: 'reference';
90
100
  entries: Array<FilterItemEntry>;
91
101
  };
92
- export type PropertyFilterItem = TextFilterItem | NumberFilterItem | DateFilterItem;
102
+ export type PropertyFilterItem = TextFilterItem | NumberFilterItem | DateFilterItem | BooleanFilterItem;
93
103
  export type FilterItem = PropertyFilterItem | ReferenceFilterItem;
94
104
  export type FilterItemEntry = {
95
105
  key: string;
96
106
  enabled: boolean;
97
107
  selected: boolean;
98
108
  size: number;
99
- value: string;
109
+ value: boolean | string | null | undefined;
100
110
  entry: ListItem;
101
111
  resultKeys: string[];
102
112
  children?: Array<FilterItemEntry>;
@@ -111,10 +121,10 @@ export type BaseFilterOptions = {
111
121
  */
112
122
  mode?: FilterMode;
113
123
  } & CatalogApiOptions;
114
- export type FilterType = 'text' | 'number' | 'reference' | 'date';
124
+ export type FilterType = 'text' | 'number' | 'reference' | 'date' | 'boolean';
115
125
  type TextFilterOptionsFull = BaseFilterOptions & {
116
126
  type: 'text';
117
- text: string;
127
+ text: string | undefined | null;
118
128
  };
119
129
  type NumberFilterOptionsFull = BaseFilterOptions & NumberConstraintOperators & {
120
130
  type: 'number';
@@ -124,11 +134,16 @@ type DateFilterOptionsFull = BaseFilterOptions & DateConstraintOperators & {
124
134
  };
125
135
  type ReferenceFilterOptionsFull = BaseFilterOptions & {
126
136
  type: 'reference';
127
- itemKeys: string[];
137
+ itemKeys: Array<string | undefined | null>;
138
+ };
139
+ type BooleanFilterOptionsFull = BaseFilterOptions & {
140
+ type: 'boolean';
141
+ value: boolean | undefined | null;
128
142
  };
129
- export type FilterOptions = TextFilterOptionsFull | NumberFilterOptionsFull | DateFilterOptionsFull | ReferenceFilterOptionsFull;
143
+ export type FilterOptions = TextFilterOptionsFull | NumberFilterOptionsFull | DateFilterOptionsFull | ReferenceFilterOptionsFull | BooleanFilterOptionsFull;
130
144
  export type TextFilterOptions = Omit<TextFilterOptionsFull, 'type'>;
131
145
  export type NumberFilterOptions = Omit<NumberFilterOptionsFull, 'type'>;
132
146
  export type DateFilterOptions = Omit<DateFilterOptionsFull, 'type'>;
133
147
  export type ReferenceFilterOptions = Omit<ReferenceFilterOptionsFull, 'type'>;
148
+ export type BooleanFilterOptions = Omit<BooleanFilterOptionsFull, 'type'>;
134
149
  export {};
@@ -1,3 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NumberOperators = void 0;
4
+ exports.NumberOperators = ['gt', 'lt', 'gte', 'lte', 'eq', 'ne'];
3
5
  //# sourceMappingURL=filter.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.types.js","sourceRoot":"","sources":["../../../src/types/filter.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"filter.types.js","sourceRoot":"","sources":["../../../src/types/filter.types.ts"],"names":[],"mappings":";;;AAoDa,QAAA,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC"}
@@ -23,6 +23,7 @@ export type DcuplFilterOptions = CatalogApiOptions & {
23
23
  calculateFacets?: boolean;
24
24
  excludeZeros?: boolean;
25
25
  excludeUndefineds?: boolean;
26
+ excludeUnresolved?: boolean;
26
27
  count?: number;
27
28
  };
28
29
  export type DcuplFiltersOptions = DcuplFilterOptions & {
@@ -44,6 +45,7 @@ export type DcuplFacetOptions = {
44
45
  count?: number;
45
46
  excludeZeros?: boolean;
46
47
  excludeUndefineds?: boolean;
48
+ excludeUnresolved?: boolean;
47
49
  calculateFacets?: boolean;
48
50
  };
49
51
  export type ListMetadata = {
@@ -1,5 +1,5 @@
1
1
  import { RawItem } from '.';
2
- export type PropertyType = 'string' | 'int' | 'float' | 'json' | 'date' | 'any' | 'Array<string>' | 'Array<int>' | 'Array<float>' | 'Array<date>';
2
+ export type PropertyType = 'string' | 'int' | 'float' | 'json' | 'date' | 'boolean' | 'any' | 'Array<string>' | 'Array<int>' | 'Array<float>' | 'Array<date>';
3
3
  export declare const NumberPropertyTypes: PropertyType[];
4
4
  export declare const DatePropertyTypes: PropertyType[];
5
5
  /**
@@ -46,6 +46,11 @@ type PropertyBase = {
46
46
  meta?: ModelMetadata;
47
47
  index?: boolean;
48
48
  };
49
+ export type PropertyBoolean = PropertyBase & {
50
+ type: 'boolean';
51
+ aggregate?: boolean;
52
+ filter?: boolean;
53
+ };
49
54
  export type PropertyInt = PropertyBase & {
50
55
  type: 'int' | 'Array<int>';
51
56
  aggregate?: boolean;
@@ -83,7 +88,7 @@ export type PropertyExpression = PropertyBase & {
83
88
  filter?: boolean | FilterStringSingle | FilterStringArray[];
84
89
  };
85
90
  export type PropertyNumber = PropertyFloat | PropertyInt;
86
- export type Property = PropertyExpression | PropertyString | PropertyInt | PropertyFloat | PropertyDate | PropertyJson | PropertyAny;
91
+ export type Property = PropertyExpression | PropertyString | PropertyInt | PropertyFloat | PropertyDate | PropertyJson | PropertyBoolean | PropertyAny;
87
92
  export type PropertyDerived = Property & {
88
93
  derive: {
89
94
  localReference: string;
@@ -108,6 +113,10 @@ export type ReferenceFilterDefinition = {
108
113
  excludeZeros?: boolean;
109
114
  excludeUndefineds?: boolean;
110
115
  };
116
+ export type BooleanFilterDefinition = {
117
+ calculateFacets?: boolean;
118
+ excludeUndefineds?: boolean;
119
+ };
111
120
  export type ReferenceValidity = 'loose' | 'strict';
112
121
  /**
113
122
  * A Reference prepresent a list of elements along a explicite dimension.
@@ -1 +1 @@
1
- {"version":3,"file":"model.types.js","sourceRoot":"","sources":["../../../src/types/model.types.ts"],"names":[],"mappings":";;;AAca,QAAA,mBAAmB,GAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AACrF,QAAA,iBAAiB,GAAmB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"model.types.js","sourceRoot":"","sources":["../../../src/types/model.types.ts"],"names":[],"mappings":";;;AAea,QAAA,mBAAmB,GAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AACrF,QAAA,iBAAiB,GAAmB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"computeSuggestions.js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AAC,OAAO,IAAI,qBAAqB,CAAC,SAAmB,EAAE,UAAU,CAAC,EAAE;oBAC3E,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;iBAChC;gBACD,IAAI,eAAe,CAAC,IAAI,KAAK,OAAO,CAAC,GAAG,EAAE;oBACxC,MAAM;iBACP;aACF;;;;;;;;;KACF;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -1,6 +1,7 @@
1
- import { DateConstraint, DateFilterItem, DateFilterOptions, FilterConstraint, FilterOptions, NumberConstraint, NumberFilterItem, NumberFilterOptions, ReferenceConstraint, ReferenceFilterDefinition, ReferenceFilterItem, ReferenceFilterOptions, TextConstraint, TextFilterItem } from './types';
2
- export declare const getTextConstraint: (filterItemId: string, text: string, filterItem?: TextFilterItem) => TextConstraint;
1
+ import { BooleanConstraint, BooleanFilterDefinition, BooleanFilterItem, BooleanFilterOptions, DateConstraint, DateFilterItem, DateFilterOptions, FilterConstraint, FilterOptions, NumberConstraint, NumberFilterItem, NumberFilterOptions, ReferenceConstraint, ReferenceFilterDefinition, ReferenceFilterItem, ReferenceFilterOptions, TextConstraint, TextFilterItem } from './types';
2
+ export declare const getTextConstraint: (filterItemId: string, text: string | undefined | null, filterItem?: TextFilterItem) => TextConstraint;
3
3
  export declare const getNumberConstraint: (filterItemId: string, options: NumberFilterOptions, filterItem?: NumberFilterItem) => NumberConstraint;
4
4
  export declare const getDateConstraint: (filterItemId: string, options: DateFilterOptions, filterItem?: DateFilterItem) => DateConstraint;
5
5
  export declare const getReferenceConstraints: (filterItemId: string, options: ReferenceFilterOptions, filterItem?: ReferenceFilterItem, filterDef?: ReferenceFilterDefinition) => ReferenceConstraint[];
6
+ export declare const getBooleanConstraint: (filterItemId: string, options: BooleanFilterOptions, filterItem?: BooleanFilterItem, filterDef?: BooleanFilterDefinition) => BooleanConstraint;
6
7
  export declare const getMultipleConstraints: (options: FilterOptions[]) => FilterConstraint[];
@@ -5,7 +5,7 @@ export var getTextConstraint = function (filterItemId, text, filterItem) {
5
5
  var entry = {
6
6
  type: 'textConstraint',
7
7
  filterKey: filterItemId,
8
- uid: getFilterEntryId(filterItemId, text),
8
+ uid: getFilterEntryId(filterItemId, String(text)),
9
9
  value: text,
10
10
  comparisonType: comparisonType,
11
11
  attributeKey: attributeKey,
@@ -49,7 +49,7 @@ export var getReferenceConstraints = function (filterItemId, options, filterItem
49
49
  var constraints = options.itemKeys.map(function (key) {
50
50
  var entry = {
51
51
  type: 'referenceConstraint',
52
- uid: getFilterEntryId(filterItemId, key),
52
+ uid: getFilterEntryId(filterItemId, String(key)),
53
53
  filterKey: filterItemId,
54
54
  attributeKey: attributeKey,
55
55
  value: key,
@@ -59,6 +59,18 @@ export var getReferenceConstraints = function (filterItemId, options, filterItem
59
59
  });
60
60
  return constraints;
61
61
  };
62
+ export var getBooleanConstraint = function (filterItemId, options, filterItem, filterDef) {
63
+ var attributeKey = (filterItem === null || filterItem === void 0 ? void 0 : filterItem.attributeKey) || filterItemId;
64
+ var constraint = {
65
+ type: 'booleanConstraint',
66
+ uid: getFilterEntryId(filterItemId, String(options.value)),
67
+ filterKey: filterItemId,
68
+ attributeKey: attributeKey,
69
+ value: options.value,
70
+ calculateFacets: !!(filterDef === null || filterDef === void 0 ? void 0 : filterDef.calculateFacets),
71
+ };
72
+ return constraint;
73
+ };
62
74
  export var getMultipleConstraints = function (options) {
63
75
  var constraints = options.map(function (option) {
64
76
  option.skipProcessing = true;
@@ -78,6 +90,9 @@ export var getMultipleConstraints = function (options) {
78
90
  case 'reference': {
79
91
  return getReferenceConstraints(option.filterKey, option);
80
92
  }
93
+ case 'boolean': {
94
+ return getBooleanConstraint(option.filterKey, option);
95
+ }
81
96
  }
82
97
  });
83
98
  return constraints.flat().filter(function (constraint) { return !!constraint; });
@@ -1 +1 @@
1
- {"version":3,"file":"getConstraints.js","sourceRoot":"","sources":["../../src/get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AAC,IAAI,EAAE,CAAC,MAAM,CAAC,UAAC,UAAU,IAAK,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAuB,CAAC;AACvF,CAAC,CAAC"}
@@ -43,7 +43,7 @@ export function getFacetEntries(modelData, remoteModelData, options, constraints
43
43
  var currentFilteredData = getFilteredData(modelData, constraintsExceptSameFilterKey, false);
44
44
  var remoteModelDataKeys = remoteModelData ? __spreadArray([], __read(remoteModelData === null || remoteModelData === void 0 ? void 0 : remoteModelData.keys()), false) : [];
45
45
  var validFacetKeys = new Set(remoteModelDataKeys);
46
- if (options.excludeUndefineds === false) {
46
+ if (!options.excludeUnresolved) {
47
47
  try {
48
48
  for (var _c = __values(indexMap.keys()), _d = _c.next(); !_d.done; _d = _c.next()) {
49
49
  var key = _d.value;
@@ -58,6 +58,12 @@ export function getFacetEntries(modelData, remoteModelData, options, constraints
58
58
  finally { if (e_1) throw e_1.error; }
59
59
  }
60
60
  }
61
+ if (options.excludeUndefineds) {
62
+ validFacetKeys.delete(undefined);
63
+ }
64
+ else {
65
+ validFacetKeys.add(undefined);
66
+ }
61
67
  var _loop_1 = function (validFacetKey) {
62
68
  var e_3, _g;
63
69
  var result = new Map();
@@ -82,9 +88,9 @@ export function getFacetEntries(modelData, remoteModelData, options, constraints
82
88
  finally { if (e_3) throw e_3.error; }
83
89
  }
84
90
  var facetEntry = {
85
- key: validFacetKey,
91
+ key: String(validFacetKey),
86
92
  value: validFacetKey,
87
- selected: !!constraints.find(function (constraint) { return constraint.uid === getFilterEntryId(attributeKey, validFacetKey); }),
93
+ selected: !!constraints.find(function (constraint) { return constraint.uid === getFilterEntryId(attributeKey, String(validFacetKey)); }),
88
94
  enabled: result.size > 0,
89
95
  size: result.size,
90
96
  entry: remoteModelData.get(validFacetKey),
@@ -1 +1 @@
1
- {"version":3,"file":"getFacetEntries.js","sourceRoot":"","sources":["../../src/getFacetEntries.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,MAAM,EAAE,CAAA,gBAAA;YAA9C,IAAM,aAAa,WAAA;kCAAb,aAAa;;;SAoCvB;;;;;;;;;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
@@ -1,5 +1,6 @@
1
- import { ListItem, FilterConstraint, TextConstraint, NumberConstraint, DateConstraint } from './types';
1
+ import { ListItem, FilterConstraint, TextConstraint, NumberConstraint, DateConstraint, ReferenceConstraint } from './types';
2
2
  export declare function getFilteredData<ListType extends ListItem = ListItem>(initialData: Map<string, ListType>, constraints: FilterConstraint[], earlyReturn: boolean): Map<string, ListType>;
3
3
  export declare const isValidNumberConstraint: (itemValue: number, constraint: NumberConstraint) => boolean;
4
4
  export declare const isValidDateConstraint: (itemValue: Date, constraint: DateConstraint) => boolean;
5
+ export declare const isValidReferenceConstraint: (itemValue: ListItem, constraint: ReferenceConstraint) => boolean;
5
6
  export declare const isValidTextConstraint: (itemValue: string, constraint: TextConstraint) => boolean;
@@ -9,6 +9,7 @@ var __values = (this && this.__values) || function(o) {
9
9
  };
10
10
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
11
  };
12
+ import { NumberOperators, } from './types';
12
13
  import { groupBy } from './helper';
13
14
  import { isAfter, isBefore, isEqual, isValid } from 'date-fns';
14
15
  export function getFilteredData(initialData, constraints, earlyReturn) {
@@ -29,17 +30,44 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
29
30
  continue;
30
31
  }
31
32
  var _loop_1 = function (constraint) {
32
- var e_3, _c, e_4, _d, e_5, _e, e_6, _f;
33
+ var e_3, _c, e_4, _d, e_5, _e, e_6, _f, e_7, _g;
33
34
  try {
34
- for (var _g = (e_3 = void 0, __values(currentDataset.values())), _h = _g.next(); !_h.done; _h = _g.next()) {
35
- var dataEntry = _h.value;
35
+ for (var _h = (e_3 = void 0, __values(currentDataset.values())), _j = _h.next(); !_j.done; _j = _h.next()) {
36
+ var dataEntry = _j.value;
36
37
  var itemValue = dataEntry[constraint.attributeKey];
37
- if (typeof itemValue === 'undefined') {
38
- continue;
39
- }
40
38
  if (constraint.type === 'referenceConstraint') {
41
39
  if (Array.isArray(itemValue)) {
42
- if (itemValue === null || itemValue === void 0 ? void 0 : itemValue.find(function (i) { return i.key === constraint.value; })) {
40
+ try {
41
+ for (var itemValue_1 = (e_4 = void 0, __values(itemValue)), itemValue_1_1 = itemValue_1.next(); !itemValue_1_1.done; itemValue_1_1 = itemValue_1.next()) {
42
+ var arrayItemValue = itemValue_1_1.value;
43
+ if (isValidReferenceConstraint(arrayItemValue, constraint)) {
44
+ filteredData.set(dataEntry.key, dataEntry);
45
+ if (earlyReturn) {
46
+ return { value: filteredData };
47
+ }
48
+ }
49
+ }
50
+ }
51
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
52
+ finally {
53
+ try {
54
+ if (itemValue_1_1 && !itemValue_1_1.done && (_d = itemValue_1.return)) _d.call(itemValue_1);
55
+ }
56
+ finally { if (e_4) throw e_4.error; }
57
+ }
58
+ }
59
+ else {
60
+ if (isValidReferenceConstraint(itemValue, constraint)) {
61
+ filteredData.set(dataEntry.key, dataEntry);
62
+ if (earlyReturn) {
63
+ return { value: filteredData };
64
+ }
65
+ }
66
+ }
67
+ }
68
+ if (constraint.type === 'booleanConstraint') {
69
+ if (Array.isArray(itemValue)) {
70
+ if (itemValue === null || itemValue === void 0 ? void 0 : itemValue.find(function (i) { return i === constraint.value; })) {
43
71
  filteredData.set(dataEntry.key, dataEntry);
44
72
  if (earlyReturn) {
45
73
  return { value: filteredData };
@@ -47,7 +75,7 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
47
75
  }
48
76
  }
49
77
  else {
50
- if (typeof itemValue === 'object' && 'key' in itemValue && itemValue.key === constraint.value) {
78
+ if (itemValue === constraint.value) {
51
79
  filteredData.set(dataEntry.key, dataEntry);
52
80
  if (earlyReturn) {
53
81
  return { value: filteredData };
@@ -58,20 +86,20 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
58
86
  if (constraint.type === 'textConstraint') {
59
87
  if (Array.isArray(itemValue)) {
60
88
  try {
61
- for (var itemValue_1 = (e_4 = void 0, __values(itemValue)), itemValue_1_1 = itemValue_1.next(); !itemValue_1_1.done; itemValue_1_1 = itemValue_1.next()) {
62
- var arrayItemValue = itemValue_1_1.value;
89
+ for (var itemValue_2 = (e_5 = void 0, __values(itemValue)), itemValue_2_1 = itemValue_2.next(); !itemValue_2_1.done; itemValue_2_1 = itemValue_2.next()) {
90
+ var arrayItemValue = itemValue_2_1.value;
63
91
  if (isValidTextConstraint(arrayItemValue, constraint)) {
64
92
  filteredData.set(dataEntry.key, dataEntry);
65
93
  break;
66
94
  }
67
95
  }
68
96
  }
69
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
97
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
70
98
  finally {
71
99
  try {
72
- if (itemValue_1_1 && !itemValue_1_1.done && (_d = itemValue_1.return)) _d.call(itemValue_1);
100
+ if (itemValue_2_1 && !itemValue_2_1.done && (_e = itemValue_2.return)) _e.call(itemValue_2);
73
101
  }
74
- finally { if (e_4) throw e_4.error; }
102
+ finally { if (e_5) throw e_5.error; }
75
103
  }
76
104
  }
77
105
  else {
@@ -83,20 +111,20 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
83
111
  if (constraint.type === 'numberConstraint') {
84
112
  if (Array.isArray(itemValue)) {
85
113
  try {
86
- for (var itemValue_2 = (e_5 = void 0, __values(itemValue)), itemValue_2_1 = itemValue_2.next(); !itemValue_2_1.done; itemValue_2_1 = itemValue_2.next()) {
87
- var arrayItemValue = itemValue_2_1.value;
114
+ for (var itemValue_3 = (e_6 = void 0, __values(itemValue)), itemValue_3_1 = itemValue_3.next(); !itemValue_3_1.done; itemValue_3_1 = itemValue_3.next()) {
115
+ var arrayItemValue = itemValue_3_1.value;
88
116
  if (isValidNumberConstraint(arrayItemValue, constraint)) {
89
117
  filteredData.set(dataEntry.key, dataEntry);
90
118
  break;
91
119
  }
92
120
  }
93
121
  }
94
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
122
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
95
123
  finally {
96
124
  try {
97
- if (itemValue_2_1 && !itemValue_2_1.done && (_e = itemValue_2.return)) _e.call(itemValue_2);
125
+ if (itemValue_3_1 && !itemValue_3_1.done && (_f = itemValue_3.return)) _f.call(itemValue_3);
98
126
  }
99
- finally { if (e_5) throw e_5.error; }
127
+ finally { if (e_6) throw e_6.error; }
100
128
  }
101
129
  }
102
130
  else {
@@ -108,20 +136,20 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
108
136
  if (constraint.type === 'dateConstraint') {
109
137
  if (Array.isArray(itemValue)) {
110
138
  try {
111
- for (var itemValue_3 = (e_6 = void 0, __values(itemValue)), itemValue_3_1 = itemValue_3.next(); !itemValue_3_1.done; itemValue_3_1 = itemValue_3.next()) {
112
- var arrayItemValue = itemValue_3_1.value;
139
+ for (var itemValue_4 = (e_7 = void 0, __values(itemValue)), itemValue_4_1 = itemValue_4.next(); !itemValue_4_1.done; itemValue_4_1 = itemValue_4.next()) {
140
+ var arrayItemValue = itemValue_4_1.value;
113
141
  if (isValidDateConstraint(arrayItemValue, constraint)) {
114
142
  filteredData.set(dataEntry.key, dataEntry);
115
143
  break;
116
144
  }
117
145
  }
118
146
  }
119
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
147
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
120
148
  finally {
121
149
  try {
122
- if (itemValue_3_1 && !itemValue_3_1.done && (_f = itemValue_3.return)) _f.call(itemValue_3);
150
+ if (itemValue_4_1 && !itemValue_4_1.done && (_g = itemValue_4.return)) _g.call(itemValue_4);
123
151
  }
124
- finally { if (e_6) throw e_6.error; }
152
+ finally { if (e_7) throw e_7.error; }
125
153
  }
126
154
  }
127
155
  else {
@@ -135,7 +163,7 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
135
163
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
136
164
  finally {
137
165
  try {
138
- if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
166
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
139
167
  }
140
168
  finally { if (e_3) throw e_3.error; }
141
169
  }
@@ -168,6 +196,24 @@ export function getFilteredData(initialData, constraints, earlyReturn) {
168
196
  return filteredData;
169
197
  }
170
198
  export var isValidNumberConstraint = function (itemValue, constraint) {
199
+ var allUndefined = NumberOperators.every(function (op) { return typeof constraint[op] === 'undefined'; });
200
+ var eqNull = constraint.eq === null;
201
+ if (allUndefined) {
202
+ if (typeof itemValue === 'undefined') {
203
+ return true;
204
+ }
205
+ else {
206
+ return false;
207
+ }
208
+ }
209
+ if (eqNull) {
210
+ if (itemValue === null) {
211
+ return true;
212
+ }
213
+ else {
214
+ return false;
215
+ }
216
+ }
171
217
  if (typeof itemValue !== 'number') {
172
218
  return false;
173
219
  }
@@ -218,6 +264,24 @@ export var isValidNumberConstraint = function (itemValue, constraint) {
218
264
  return true;
219
265
  };
220
266
  export var isValidDateConstraint = function (itemValue, constraint) {
267
+ var allUndefined = NumberOperators.every(function (op) { return typeof constraint[op] === 'undefined'; });
268
+ var eqNull = constraint.eq === null;
269
+ if (allUndefined) {
270
+ if (typeof itemValue === 'undefined') {
271
+ return true;
272
+ }
273
+ else {
274
+ return false;
275
+ }
276
+ }
277
+ if (eqNull) {
278
+ if (itemValue === null) {
279
+ return true;
280
+ }
281
+ else {
282
+ return false;
283
+ }
284
+ }
221
285
  if (!isValid(itemValue)) {
222
286
  return false;
223
287
  }
@@ -267,8 +331,46 @@ export var isValidDateConstraint = function (itemValue, constraint) {
267
331
  }
268
332
  return true;
269
333
  };
334
+ export var isValidReferenceConstraint = function (itemValue, constraint) {
335
+ if (typeof constraint.value === 'undefined') {
336
+ if (typeof itemValue === 'undefined') {
337
+ return true;
338
+ }
339
+ else {
340
+ return false;
341
+ }
342
+ }
343
+ if (constraint.value === null) {
344
+ if (itemValue === null) {
345
+ return true;
346
+ }
347
+ else {
348
+ return false;
349
+ }
350
+ }
351
+ if (typeof itemValue !== 'object') {
352
+ return false;
353
+ }
354
+ return itemValue.key === constraint.value;
355
+ };
270
356
  export var isValidTextConstraint = function (itemValue, constraint) {
271
- if (!itemValue || typeof itemValue !== 'string') {
357
+ if (typeof constraint.value === 'undefined') {
358
+ if (typeof itemValue === 'undefined') {
359
+ return true;
360
+ }
361
+ else {
362
+ return false;
363
+ }
364
+ }
365
+ if (constraint.value === null) {
366
+ if (itemValue === null) {
367
+ return true;
368
+ }
369
+ else {
370
+ return false;
371
+ }
372
+ }
373
+ if (typeof itemValue !== 'string') {
272
374
  return false;
273
375
  }
274
376
  var constraintValue = constraint.value;