@dcupl/common 0.0.81-beta.6 → 1.0.0-beta.0
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/computeSuggestionsNew.d.ts +2 -0
- package/dist/lib-cjs/computeSuggestionsNew.js +75 -0
- package/dist/lib-cjs/computeSuggestionsNew.js.map +1 -0
- package/dist/lib-cjs/getFacets.d.ts +2 -2
- package/dist/lib-cjs/getFacets.js.map +1 -1
- package/dist/lib-cjs/index.d.ts +1 -1
- package/dist/lib-cjs/index.js +1 -1
- package/dist/lib-cjs/index.js.map +1 -1
- package/dist/lib-cjs/query-builder.d.ts +9 -9
- package/dist/lib-cjs/query-builder.js.map +1 -1
- package/dist/lib-cjs/queryData.d.ts +3 -1
- package/dist/lib-cjs/queryData.js +7 -5
- package/dist/lib-cjs/queryData.js.map +1 -1
- package/dist/lib-cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/lib-cjs/types/aggregation.types.d.ts +47 -0
- package/dist/lib-cjs/types/aggregation.types.js +6 -0
- package/dist/lib-cjs/types/aggregation.types.js.map +1 -0
- package/dist/lib-cjs/types/data.types.d.ts +5 -0
- package/dist/lib-cjs/types/facets.types.d.ts +20 -0
- package/dist/lib-cjs/types/facets.types.js +3 -0
- package/dist/lib-cjs/types/facets.types.js.map +1 -0
- package/dist/lib-cjs/types/group-by.types.d.ts +13 -0
- package/dist/lib-cjs/types/group-by.types.js +3 -0
- package/dist/lib-cjs/types/group-by.types.js.map +1 -0
- package/dist/lib-cjs/types/index.d.ts +4 -1
- package/dist/lib-cjs/types/index.js +4 -1
- package/dist/lib-cjs/types/index.js.map +1 -1
- package/dist/lib-cjs/types/list.types.d.ts +5 -56
- package/dist/lib-cjs/types/model.types.d.ts +2 -2
- package/dist/lib-cjs/types/query.types.d.ts +7 -2
- package/dist/lib-cjs/types/section.types.d.ts +1 -1
- package/dist/lib-cjs/types/suggestion.types.d.ts +8 -11
- package/dist/lib-esm/computeSuggestionsNew.d.ts +2 -0
- package/dist/lib-esm/computeSuggestionsNew.js +71 -0
- package/dist/lib-esm/computeSuggestionsNew.js.map +1 -0
- package/dist/lib-esm/getFacets.d.ts +2 -2
- package/dist/lib-esm/getFacets.js.map +1 -1
- package/dist/lib-esm/index.d.ts +1 -1
- package/dist/lib-esm/index.js +1 -1
- package/dist/lib-esm/index.js.map +1 -1
- package/dist/lib-esm/query-builder.d.ts +9 -9
- package/dist/lib-esm/query-builder.js.map +1 -1
- package/dist/lib-esm/queryData.d.ts +3 -1
- package/dist/lib-esm/queryData.js +2 -2
- package/dist/lib-esm/queryData.js.map +1 -1
- package/dist/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib-esm/types/aggregation.types.d.ts +47 -0
- package/dist/lib-esm/types/aggregation.types.js +5 -0
- package/dist/lib-esm/types/aggregation.types.js.map +1 -0
- package/dist/lib-esm/types/data.types.d.ts +5 -0
- package/dist/lib-esm/types/facets.types.d.ts +20 -0
- package/dist/lib-esm/types/facets.types.js +2 -0
- package/dist/lib-esm/types/facets.types.js.map +1 -0
- package/dist/lib-esm/types/group-by.types.d.ts +13 -0
- package/dist/lib-esm/types/group-by.types.js +2 -0
- package/dist/lib-esm/types/group-by.types.js.map +1 -0
- package/dist/lib-esm/types/index.d.ts +4 -1
- package/dist/lib-esm/types/index.js +4 -1
- package/dist/lib-esm/types/index.js.map +1 -1
- package/dist/lib-esm/types/list.types.d.ts +5 -56
- package/dist/lib-esm/types/model.types.d.ts +2 -2
- package/dist/lib-esm/types/query.types.d.ts +7 -2
- package/dist/lib-esm/types/section.types.d.ts +1 -1
- package/dist/lib-esm/types/suggestion.types.d.ts +8 -11
- package/package.json +1 -1
- package/dist/lib-cjs/computeSuggestions.d.ts +0 -2
- package/dist/lib-cjs/computeSuggestions.js +0 -128
- package/dist/lib-cjs/computeSuggestions.js.map +0 -1
- package/dist/lib-esm/computeSuggestions.d.ts +0 -2
- package/dist/lib-esm/computeSuggestions.js +0 -124
- package/dist/lib-esm/computeSuggestions.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type NumberAggregationValue = {
|
|
2
|
+
average: number;
|
|
3
|
+
count: number;
|
|
4
|
+
sum: number;
|
|
5
|
+
};
|
|
6
|
+
export type AggregationType = 'sum' | 'avg' | 'count' | 'min' | 'max' | 'distinct' | 'group';
|
|
7
|
+
export type AggregationOptions = {
|
|
8
|
+
attribute: string;
|
|
9
|
+
types: AggregationType[];
|
|
10
|
+
distinctOptions?: {
|
|
11
|
+
limit?: number;
|
|
12
|
+
};
|
|
13
|
+
groupOptions?: {
|
|
14
|
+
limit?: number;
|
|
15
|
+
calculateNotFound?: boolean;
|
|
16
|
+
groups?: AggregationGroupOption[];
|
|
17
|
+
};
|
|
18
|
+
excludeZeros?: boolean;
|
|
19
|
+
excludeUndefineds?: boolean;
|
|
20
|
+
excludeUnresolved?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type AggregationGroupOption = {
|
|
23
|
+
from?: any;
|
|
24
|
+
to?: any;
|
|
25
|
+
value?: any[];
|
|
26
|
+
};
|
|
27
|
+
export type AggregationDistinctValue = {
|
|
28
|
+
value: string;
|
|
29
|
+
count: number;
|
|
30
|
+
keys: string[];
|
|
31
|
+
};
|
|
32
|
+
export type AggregationGroupValue = {
|
|
33
|
+
option: AggregationGroupOption;
|
|
34
|
+
count: number;
|
|
35
|
+
keys: string[];
|
|
36
|
+
};
|
|
37
|
+
export type Aggregation = {
|
|
38
|
+
attribute: string;
|
|
39
|
+
types: AggregationType[];
|
|
40
|
+
sum?: number;
|
|
41
|
+
avg?: number;
|
|
42
|
+
count?: number;
|
|
43
|
+
min?: number;
|
|
44
|
+
max?: number;
|
|
45
|
+
distinct?: AggregationDistinctValue[];
|
|
46
|
+
group?: AggregationGroupValue[];
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregation.types.js","sourceRoot":"","sources":["../../../src/types/aggregation.types.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,6BAA6B;AAC7B,KAAK"}
|
|
@@ -12,3 +12,8 @@ export type DataContainer<ListType extends RawItem | ListItem = ListItem, ModelN
|
|
|
12
12
|
};
|
|
13
13
|
export type DataContainerType = 'upsert' | 'update' | 'set' | 'delete';
|
|
14
14
|
export type ReferenceDataTypes<ListType extends ListItem = ListItem> = string | string[] | ListType | ListType[];
|
|
15
|
+
export type DataOptions<ModelNames extends string = string> = {
|
|
16
|
+
model: ModelNames;
|
|
17
|
+
keyProperty?: string;
|
|
18
|
+
autoGenerateKey?: boolean;
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ListItem } from './data.types';
|
|
2
|
+
export type DcuplFacetOptions = {
|
|
3
|
+
attributeKey: string;
|
|
4
|
+
filterKey?: string;
|
|
5
|
+
count?: number;
|
|
6
|
+
excludeZeros?: boolean;
|
|
7
|
+
excludeUndefineds?: boolean;
|
|
8
|
+
excludeUnresolved?: boolean;
|
|
9
|
+
calculateResults?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type DcuplFacet = {
|
|
12
|
+
key: string;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
selected: boolean;
|
|
15
|
+
size: number;
|
|
16
|
+
value: boolean | string | null | undefined;
|
|
17
|
+
entry: ListItem;
|
|
18
|
+
resultKeys: string[];
|
|
19
|
+
children?: Array<DcuplFacet>;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facets.types.js","sourceRoot":"","sources":["../../../src/types/facets.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AggregationOptions } from './aggregation.types';
|
|
2
|
+
import { DcuplItemsOptions } from './list.types';
|
|
3
|
+
export type DcuplSectionItemOption<T> = DcuplItemsOptions<T> & {
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
6
|
+
export type DcuplGroupByOptions<T> = DcuplItemsOptions<T> & {
|
|
7
|
+
attribute: string;
|
|
8
|
+
aggregates?: AggregationOptions[];
|
|
9
|
+
items?: DcuplSectionItemOption<T>[];
|
|
10
|
+
excludeZeros?: boolean;
|
|
11
|
+
excludeUndefineds?: boolean;
|
|
12
|
+
excludeUnresolved?: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-by.types.js","sourceRoot":"","sources":["../../../src/types/group-by.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
export * from './aggregation.types';
|
|
1
2
|
export * from './data.types';
|
|
2
3
|
export * from './dcupl.types';
|
|
4
|
+
export * from './facets.types';
|
|
3
5
|
export * from './filter.types';
|
|
4
6
|
export * from './global.types';
|
|
7
|
+
export * from './group-by.types';
|
|
5
8
|
export * from './internal.types';
|
|
6
9
|
export * from './list.types';
|
|
7
10
|
export * from './model.types';
|
|
8
11
|
export * from './projection.types';
|
|
9
12
|
export * from './query.types';
|
|
10
|
-
export * from './selection.types';
|
|
11
13
|
export * from './section.types';
|
|
14
|
+
export * from './selection.types';
|
|
12
15
|
export * from './suggestion.types';
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
export * from './aggregation.types';
|
|
1
2
|
export * from './data.types';
|
|
2
3
|
export * from './dcupl.types';
|
|
4
|
+
export * from './facets.types';
|
|
3
5
|
export * from './filter.types';
|
|
4
6
|
export * from './global.types';
|
|
7
|
+
export * from './group-by.types';
|
|
5
8
|
export * from './internal.types';
|
|
6
9
|
export * from './list.types';
|
|
7
10
|
export * from './model.types';
|
|
8
11
|
export * from './projection.types';
|
|
9
12
|
export * from './query.types';
|
|
10
|
-
export * from './selection.types';
|
|
11
13
|
export * from './section.types';
|
|
14
|
+
export * from './selection.types';
|
|
12
15
|
export * from './suggestion.types';
|
|
13
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DcuplGlobalQueryOptions } from './query.types';
|
|
2
2
|
import { ViewDefinition, ModelAttribute } from './model.types';
|
|
3
3
|
import { Projection, SortingProjection } from './projection.types';
|
|
4
4
|
export type DcuplItemsOptions<T> = {
|
|
@@ -11,13 +11,9 @@ export type DcuplItemOptions<T> = {
|
|
|
11
11
|
projection?: Projection<T>;
|
|
12
12
|
itemKey: string;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type DcuplSectionOptions<T> = DcuplItemsOptions<T> & {
|
|
18
|
-
primaryAttribute: string;
|
|
19
|
-
aggregates?: string[];
|
|
20
|
-
items?: DcuplSectionItemOption<T>[];
|
|
14
|
+
export type DcuplManyItemsOptions<T> = {
|
|
15
|
+
projection?: Projection<T>;
|
|
16
|
+
itemKeys: string[];
|
|
21
17
|
};
|
|
22
18
|
export type DcuplFilterOptions = CatalogApiOptions & {
|
|
23
19
|
calculateFacets?: boolean;
|
|
@@ -39,20 +35,11 @@ export type DcuplRangeOptions = {
|
|
|
39
35
|
propertyKey: string;
|
|
40
36
|
filterKey?: string;
|
|
41
37
|
};
|
|
42
|
-
export type DcuplFacetOptions = {
|
|
43
|
-
attributeKey: string;
|
|
44
|
-
filterKey?: string;
|
|
45
|
-
count?: number;
|
|
46
|
-
excludeZeros?: boolean;
|
|
47
|
-
excludeUndefineds?: boolean;
|
|
48
|
-
excludeUnresolved?: boolean;
|
|
49
|
-
calculateFacets?: boolean;
|
|
50
|
-
};
|
|
51
38
|
export type ListMetadata = {
|
|
52
39
|
key: string;
|
|
53
40
|
currentSize: number;
|
|
54
41
|
initialSize: number;
|
|
55
|
-
appliedQuery:
|
|
42
|
+
appliedQuery: DcuplGlobalQueryOptions<any>;
|
|
56
43
|
attributes: ModelAttribute[];
|
|
57
44
|
views: ViewDefinition[];
|
|
58
45
|
};
|
|
@@ -61,44 +48,6 @@ export type ViewMetadata = {
|
|
|
61
48
|
currentSize: number;
|
|
62
49
|
initialSize: number;
|
|
63
50
|
};
|
|
64
|
-
export type AggregationOptions = {
|
|
65
|
-
attributeKeys: string[];
|
|
66
|
-
};
|
|
67
|
-
export type AggregateType = 'number' | 'reference' | 'string';
|
|
68
|
-
export type AggregateBase = {
|
|
69
|
-
attribute: string;
|
|
70
|
-
type: AggregateType;
|
|
71
|
-
};
|
|
72
|
-
export type NumberAggregation = AggregateBase & {
|
|
73
|
-
attribute: string;
|
|
74
|
-
type: 'number';
|
|
75
|
-
value: NumberAggregationValue;
|
|
76
|
-
};
|
|
77
|
-
export type ReferenceAggregation = AggregateBase & {
|
|
78
|
-
attribute: string;
|
|
79
|
-
type: 'reference';
|
|
80
|
-
value: ReferenceAggregationValue[];
|
|
81
|
-
};
|
|
82
|
-
export type StringAggregation = AggregateBase & {
|
|
83
|
-
attribute: string;
|
|
84
|
-
type: 'string';
|
|
85
|
-
value: StringAggregationValue[];
|
|
86
|
-
};
|
|
87
|
-
export type Aggregation = NumberAggregation | StringAggregation | ReferenceAggregation;
|
|
88
|
-
export type NumberAggregationValue = {
|
|
89
|
-
average: number;
|
|
90
|
-
count: number;
|
|
91
|
-
sum: number;
|
|
92
|
-
};
|
|
93
|
-
export type ReferenceAggregationValue = {
|
|
94
|
-
value: string;
|
|
95
|
-
count: number;
|
|
96
|
-
itemKeys: string[];
|
|
97
|
-
};
|
|
98
|
-
export type StringAggregationValue = {
|
|
99
|
-
value: string;
|
|
100
|
-
count: number;
|
|
101
|
-
};
|
|
102
51
|
export type CatalogApiOptions = {
|
|
103
52
|
skipProcessing?: boolean;
|
|
104
53
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RawItem } from '.';
|
|
1
|
+
import { AggregationOptions, RawItem } from '.';
|
|
2
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[];
|
|
@@ -278,7 +278,7 @@ export type ViewDefinition = {
|
|
|
278
278
|
* @minLength 1
|
|
279
279
|
*/
|
|
280
280
|
primaryAttribute: string;
|
|
281
|
-
aggregates:
|
|
281
|
+
aggregates: AggregationOptions[];
|
|
282
282
|
meta?: ModelMetadata;
|
|
283
283
|
};
|
|
284
284
|
/**
|
|
@@ -49,7 +49,6 @@ export type DcuplQueryGroup<ChildQuery extends DcuplQuery | DcuplQueryGroup = an
|
|
|
49
49
|
queries: Array<ChildQuery>;
|
|
50
50
|
options?: DcuplQueryOptions;
|
|
51
51
|
};
|
|
52
|
-
export type DcuplGlobalQueryOptionsNew<T> = DcuplGlobalQueryOptions<T>;
|
|
53
52
|
type DcuplItemOptions<T> = {
|
|
54
53
|
start?: number;
|
|
55
54
|
count?: number;
|
|
@@ -62,7 +61,13 @@ export type DcuplGlobalQueryOptions<T> = {
|
|
|
62
61
|
export type DcuplGlobalItemOptions<T> = {
|
|
63
62
|
modelKey: string;
|
|
64
63
|
itemKey: string;
|
|
65
|
-
|
|
64
|
+
projection?: Projection<T>;
|
|
65
|
+
};
|
|
66
|
+
export type DcuplGlobalManyItemOptions<T> = {
|
|
67
|
+
modelKey: string;
|
|
68
|
+
itemKeys: string[];
|
|
69
|
+
projection?: Projection<T>;
|
|
70
|
+
};
|
|
66
71
|
export type DcuplListQueryOptions<T> = DcuplItemOptions<T> & DcuplQueryGroup;
|
|
67
72
|
export type DcuplListItemOptions<T> = DcuplItemOptions<T> & {
|
|
68
73
|
itemKey: string;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { CatalogApiOptions } from './list.types';
|
|
2
|
-
import {
|
|
3
|
-
export type SuggestionValueEntry = {
|
|
4
|
-
key: string;
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
export type Suggestion<T extends string | SuggestionValueEntry = string> = {
|
|
8
|
-
value: T;
|
|
9
|
-
filterKey: string;
|
|
10
|
-
};
|
|
2
|
+
import { DcuplQueryTransformOptions } from './query.types';
|
|
11
3
|
export type SuggestionOptions = CatalogApiOptions & {
|
|
12
|
-
|
|
4
|
+
attribute: string;
|
|
13
5
|
searchTerm: string;
|
|
14
6
|
max?: number;
|
|
15
|
-
|
|
7
|
+
calculateResultKeys?: boolean;
|
|
8
|
+
transform?: DcuplQueryTransformOptions[];
|
|
9
|
+
};
|
|
10
|
+
export type Suggestion = {
|
|
11
|
+
value: string;
|
|
12
|
+
keys: string[];
|
|
16
13
|
};
|
package/package.json
CHANGED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.computeSuggestionsForSearchTerm = void 0;
|
|
15
|
-
var _1 = require(".");
|
|
16
|
-
function computeSuggestionsForSearchTerm(data, filterItem, options) {
|
|
17
|
-
var e_1, _a;
|
|
18
|
-
if (!options.max) {
|
|
19
|
-
options.max = 20;
|
|
20
|
-
}
|
|
21
|
-
var suggestions = [];
|
|
22
|
-
if (filterItem) {
|
|
23
|
-
var relevantEntries = getRelevantEntries(filterItem, Array.from(data.values()), options);
|
|
24
|
-
try {
|
|
25
|
-
for (var relevantEntries_1 = __values(relevantEntries), relevantEntries_1_1 = relevantEntries_1.next(); !relevantEntries_1_1.done; relevantEntries_1_1 = relevantEntries_1.next()) {
|
|
26
|
-
var entry = relevantEntries_1_1.value;
|
|
27
|
-
var suggestion = {
|
|
28
|
-
filterKey: options.filterKey,
|
|
29
|
-
value: entry,
|
|
30
|
-
};
|
|
31
|
-
suggestions.push(suggestion);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (relevantEntries_1_1 && !relevantEntries_1_1.done && (_a = relevantEntries_1.return)) _a.call(relevantEntries_1);
|
|
38
|
-
}
|
|
39
|
-
finally { if (e_1) throw e_1.error; }
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return suggestions;
|
|
43
|
-
}
|
|
44
|
-
exports.computeSuggestionsForSearchTerm = computeSuggestionsForSearchTerm;
|
|
45
|
-
var getRelevantEntries = function (filterItem, dataEntries, options) {
|
|
46
|
-
var e_2, _a, e_3, _b, e_4, _c;
|
|
47
|
-
var relevantEntries = new Set();
|
|
48
|
-
if (filterItem.type === 'text') {
|
|
49
|
-
var constraint = {
|
|
50
|
-
comparisonType: options.comparisonType || filterItem.comparisonType || 'containsIgnoreCase',
|
|
51
|
-
type: 'textConstraint',
|
|
52
|
-
filterKey: filterItem.key,
|
|
53
|
-
attributeKey: filterItem.attributeKey,
|
|
54
|
-
uid: '',
|
|
55
|
-
value: options.searchTerm,
|
|
56
|
-
};
|
|
57
|
-
try {
|
|
58
|
-
for (var dataEntries_1 = __values(dataEntries), dataEntries_1_1 = dataEntries_1.next(); !dataEntries_1_1.done; dataEntries_1_1 = dataEntries_1.next()) {
|
|
59
|
-
var entry = dataEntries_1_1.value;
|
|
60
|
-
var itemValue = entry[filterItem.attributeKey];
|
|
61
|
-
if (Array.isArray(itemValue)) {
|
|
62
|
-
try {
|
|
63
|
-
for (var itemValue_1 = (e_3 = void 0, __values(itemValue)), itemValue_1_1 = itemValue_1.next(); !itemValue_1_1.done; itemValue_1_1 = itemValue_1.next()) {
|
|
64
|
-
var arrayValue = itemValue_1_1.value;
|
|
65
|
-
if ((0, _1.isValidTextConstraint)(arrayValue, constraint)) {
|
|
66
|
-
relevantEntries.add(arrayValue);
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
72
|
-
finally {
|
|
73
|
-
try {
|
|
74
|
-
if (itemValue_1_1 && !itemValue_1_1.done && (_b = itemValue_1.return)) _b.call(itemValue_1);
|
|
75
|
-
}
|
|
76
|
-
finally { if (e_3) throw e_3.error; }
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
if ((0, _1.isValidTextConstraint)(itemValue, constraint)) {
|
|
81
|
-
relevantEntries.add(itemValue);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (relevantEntries.size === options.max) {
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
90
|
-
finally {
|
|
91
|
-
try {
|
|
92
|
-
if (dataEntries_1_1 && !dataEntries_1_1.done && (_a = dataEntries_1.return)) _a.call(dataEntries_1);
|
|
93
|
-
}
|
|
94
|
-
finally { if (e_2) throw e_2.error; }
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else if (filterItem.type === 'reference') {
|
|
98
|
-
var constraint = {
|
|
99
|
-
comparisonType: options.comparisonType || 'containsIgnoreCase',
|
|
100
|
-
type: 'textConstraint',
|
|
101
|
-
filterKey: filterItem.attributeKey,
|
|
102
|
-
attributeKey: filterItem.attributeKey,
|
|
103
|
-
uid: '',
|
|
104
|
-
value: options.searchTerm,
|
|
105
|
-
};
|
|
106
|
-
try {
|
|
107
|
-
for (var _d = __values(filterItem.entries), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
108
|
-
var entry = _e.value;
|
|
109
|
-
var itemValue = entry.value;
|
|
110
|
-
if (entry.enabled && (0, _1.isValidTextConstraint)(itemValue, constraint)) {
|
|
111
|
-
relevantEntries.add(entry.key);
|
|
112
|
-
}
|
|
113
|
-
if (relevantEntries.size === options.max) {
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
119
|
-
finally {
|
|
120
|
-
try {
|
|
121
|
-
if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
|
|
122
|
-
}
|
|
123
|
-
finally { if (e_4) throw e_4.error; }
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return Array.from(relevantEntries.values());
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=computeSuggestions.js.map
|
|
@@ -1 +0,0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G,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,124 +0,0 @@
|
|
|
1
|
-
var __values = (this && this.__values) || function(o) {
|
|
2
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
-
if (m) return m.call(o);
|
|
4
|
-
if (o && typeof o.length === "number") return {
|
|
5
|
-
next: function () {
|
|
6
|
-
if (o && i >= o.length) o = void 0;
|
|
7
|
-
return { value: o && o[i++], done: !o };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
|
-
import { isValidTextConstraint } from '.';
|
|
13
|
-
export function computeSuggestionsForSearchTerm(data, filterItem, options) {
|
|
14
|
-
var e_1, _a;
|
|
15
|
-
if (!options.max) {
|
|
16
|
-
options.max = 20;
|
|
17
|
-
}
|
|
18
|
-
var suggestions = [];
|
|
19
|
-
if (filterItem) {
|
|
20
|
-
var relevantEntries = getRelevantEntries(filterItem, Array.from(data.values()), options);
|
|
21
|
-
try {
|
|
22
|
-
for (var relevantEntries_1 = __values(relevantEntries), relevantEntries_1_1 = relevantEntries_1.next(); !relevantEntries_1_1.done; relevantEntries_1_1 = relevantEntries_1.next()) {
|
|
23
|
-
var entry = relevantEntries_1_1.value;
|
|
24
|
-
var suggestion = {
|
|
25
|
-
filterKey: options.filterKey,
|
|
26
|
-
value: entry,
|
|
27
|
-
};
|
|
28
|
-
suggestions.push(suggestion);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32
|
-
finally {
|
|
33
|
-
try {
|
|
34
|
-
if (relevantEntries_1_1 && !relevantEntries_1_1.done && (_a = relevantEntries_1.return)) _a.call(relevantEntries_1);
|
|
35
|
-
}
|
|
36
|
-
finally { if (e_1) throw e_1.error; }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return suggestions;
|
|
40
|
-
}
|
|
41
|
-
var getRelevantEntries = function (filterItem, dataEntries, options) {
|
|
42
|
-
var e_2, _a, e_3, _b, e_4, _c;
|
|
43
|
-
var relevantEntries = new Set();
|
|
44
|
-
if (filterItem.type === 'text') {
|
|
45
|
-
var constraint = {
|
|
46
|
-
comparisonType: options.comparisonType || filterItem.comparisonType || 'containsIgnoreCase',
|
|
47
|
-
type: 'textConstraint',
|
|
48
|
-
filterKey: filterItem.key,
|
|
49
|
-
attributeKey: filterItem.attributeKey,
|
|
50
|
-
uid: '',
|
|
51
|
-
value: options.searchTerm,
|
|
52
|
-
};
|
|
53
|
-
try {
|
|
54
|
-
for (var dataEntries_1 = __values(dataEntries), dataEntries_1_1 = dataEntries_1.next(); !dataEntries_1_1.done; dataEntries_1_1 = dataEntries_1.next()) {
|
|
55
|
-
var entry = dataEntries_1_1.value;
|
|
56
|
-
var itemValue = entry[filterItem.attributeKey];
|
|
57
|
-
if (Array.isArray(itemValue)) {
|
|
58
|
-
try {
|
|
59
|
-
for (var itemValue_1 = (e_3 = void 0, __values(itemValue)), itemValue_1_1 = itemValue_1.next(); !itemValue_1_1.done; itemValue_1_1 = itemValue_1.next()) {
|
|
60
|
-
var arrayValue = itemValue_1_1.value;
|
|
61
|
-
if (isValidTextConstraint(arrayValue, constraint)) {
|
|
62
|
-
relevantEntries.add(arrayValue);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
68
|
-
finally {
|
|
69
|
-
try {
|
|
70
|
-
if (itemValue_1_1 && !itemValue_1_1.done && (_b = itemValue_1.return)) _b.call(itemValue_1);
|
|
71
|
-
}
|
|
72
|
-
finally { if (e_3) throw e_3.error; }
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
if (isValidTextConstraint(itemValue, constraint)) {
|
|
77
|
-
relevantEntries.add(itemValue);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (relevantEntries.size === options.max) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
86
|
-
finally {
|
|
87
|
-
try {
|
|
88
|
-
if (dataEntries_1_1 && !dataEntries_1_1.done && (_a = dataEntries_1.return)) _a.call(dataEntries_1);
|
|
89
|
-
}
|
|
90
|
-
finally { if (e_2) throw e_2.error; }
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else if (filterItem.type === 'reference') {
|
|
94
|
-
var constraint = {
|
|
95
|
-
comparisonType: options.comparisonType || 'containsIgnoreCase',
|
|
96
|
-
type: 'textConstraint',
|
|
97
|
-
filterKey: filterItem.attributeKey,
|
|
98
|
-
attributeKey: filterItem.attributeKey,
|
|
99
|
-
uid: '',
|
|
100
|
-
value: options.searchTerm,
|
|
101
|
-
};
|
|
102
|
-
try {
|
|
103
|
-
for (var _d = __values(filterItem.entries), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
104
|
-
var entry = _e.value;
|
|
105
|
-
var itemValue = entry.value;
|
|
106
|
-
if (entry.enabled && isValidTextConstraint(itemValue, constraint)) {
|
|
107
|
-
relevantEntries.add(entry.key);
|
|
108
|
-
}
|
|
109
|
-
if (relevantEntries.size === options.max) {
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
115
|
-
finally {
|
|
116
|
-
try {
|
|
117
|
-
if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
|
|
118
|
-
}
|
|
119
|
-
finally { if (e_4) throw e_4.error; }
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return Array.from(relevantEntries.values());
|
|
123
|
-
};
|
|
124
|
-
//# sourceMappingURL=computeSuggestions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computeSuggestions.js","sourceRoot":"","sources":["../../src/computeSuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAE1C,MAAM,UAAU,+BAA+B,CAC7C,IAA2B,EAC3B,UAAsB,EACtB,OAA0B;;IAE1B,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAChB,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;KAClB;IACD,IAAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,IAAI,UAAU,EAAE;QACd,IAAM,eAAe,GAAG,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAE,CAAC;;YAE5F,KAAoB,IAAA,oBAAA,SAAA,eAAe,CAAA,gDAAA,6EAAE;gBAAhC,IAAM,KAAK,4BAAA;gBACd,IAAM,UAAU,GAAe;oBAC7B,SAAS,EAAE,OAAO,CAAC,SAAS;oBAC5B,KAAK,EAAE,KAAK;iBACb,CAAC;gBACF,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aAC9B;;;;;;;;;KACF;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,IAAM,kBAAkB,GAAG,UAAC,UAAsB,EAAE,WAAuB,EAAE,OAA0B;;IACrG,IAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,IAAI,UAAU,CAAC,IAAI,KAAK,MAAM,EAAE;QAC9B,IAAM,UAAU,GAAmB;YACjC,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,UAAU,CAAC,cAAc,IAAI,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