polymatica-widget 2.0.0 → 2.0.6
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/README.md +3 -0
- package/__internal__/widget-options.d.ts +8 -6
- package/__internal__/widget-options.js +8 -2
- package/package.json +1 -1
- package/widget-config.d.ts +37 -88
- package/widget-config.js +23 -100
- package/__internal__/widget-config.d.ts +0 -25
- package/__internal__/widget-config.js +0 -43
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
# Polymatica Widget SDK
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
3
6
|
> Pre-Alpha
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Text } from '../locale';
|
|
2
2
|
export declare enum WidgetOptionType {
|
|
3
|
+
Title = "title",
|
|
4
|
+
Label = "label",
|
|
5
|
+
Spacer = "spacer",
|
|
3
6
|
Text = "text",
|
|
4
7
|
Number = "number",
|
|
5
8
|
Integer = "integer",
|
|
@@ -8,18 +11,17 @@ export declare enum WidgetOptionType {
|
|
|
8
11
|
Date = "date",
|
|
9
12
|
Time = "time",
|
|
10
13
|
DateTime = "datetime",
|
|
11
|
-
DateInterval = "
|
|
14
|
+
DateInterval = "date-interval",
|
|
12
15
|
Checkbox = "checkbox",
|
|
13
16
|
Radio = "radio",
|
|
17
|
+
RadioButtons = "radio-buttons",
|
|
14
18
|
Select = "select",
|
|
15
|
-
ColorPicker = "color-picker"
|
|
16
|
-
Title = "title"
|
|
19
|
+
ColorPicker = "color-picker"
|
|
17
20
|
}
|
|
18
21
|
export interface WidgetOptionConfig {
|
|
19
22
|
type: WidgetOptionType;
|
|
20
|
-
key
|
|
21
|
-
label
|
|
22
|
-
defaultValue?: any;
|
|
23
|
+
key?: string;
|
|
24
|
+
label?: Text;
|
|
23
25
|
options?: {
|
|
24
26
|
label: Text;
|
|
25
27
|
value: string | number | boolean;
|
|
@@ -4,6 +4,11 @@ exports.getSpan = exports.valueConversion = exports.WidgetOptionType = void 0;
|
|
|
4
4
|
const widget_config_1 = require("../widget-config");
|
|
5
5
|
var WidgetOptionType;
|
|
6
6
|
(function (WidgetOptionType) {
|
|
7
|
+
// Layout
|
|
8
|
+
WidgetOptionType["Title"] = "title";
|
|
9
|
+
WidgetOptionType["Label"] = "label";
|
|
10
|
+
WidgetOptionType["Spacer"] = "spacer";
|
|
11
|
+
// Controls
|
|
7
12
|
WidgetOptionType["Text"] = "text";
|
|
8
13
|
WidgetOptionType["Number"] = "number";
|
|
9
14
|
WidgetOptionType["Integer"] = "integer";
|
|
@@ -12,16 +17,17 @@ var WidgetOptionType;
|
|
|
12
17
|
WidgetOptionType["Date"] = "date";
|
|
13
18
|
WidgetOptionType["Time"] = "time";
|
|
14
19
|
WidgetOptionType["DateTime"] = "datetime";
|
|
15
|
-
WidgetOptionType["DateInterval"] = "
|
|
20
|
+
WidgetOptionType["DateInterval"] = "date-interval";
|
|
16
21
|
WidgetOptionType["Checkbox"] = "checkbox";
|
|
17
22
|
WidgetOptionType["Radio"] = "radio";
|
|
23
|
+
WidgetOptionType["RadioButtons"] = "radio-buttons";
|
|
18
24
|
WidgetOptionType["Select"] = "select";
|
|
19
25
|
WidgetOptionType["ColorPicker"] = "color-picker";
|
|
20
|
-
WidgetOptionType["Title"] = "title";
|
|
21
26
|
})(WidgetOptionType = exports.WidgetOptionType || (exports.WidgetOptionType = {}));
|
|
22
27
|
function valueConversion(type, source) {
|
|
23
28
|
switch (type) {
|
|
24
29
|
case WidgetOptionType.Text:
|
|
30
|
+
case WidgetOptionType.Title:
|
|
25
31
|
return source ? String(source) : '';
|
|
26
32
|
case WidgetOptionType.Number:
|
|
27
33
|
case WidgetOptionType.Range:
|
package/package.json
CHANGED
package/widget-config.d.ts
CHANGED
|
@@ -1,157 +1,101 @@
|
|
|
1
|
-
import { ColumnType } from './dataset';
|
|
2
1
|
import { Text } from './locale';
|
|
3
2
|
import { Options } from './widget';
|
|
4
|
-
import { Block } from './__internal__/widget-config';
|
|
5
3
|
import { WidgetOptionConfig } from './__internal__/widget-options';
|
|
6
4
|
export declare enum DataQueryMethod {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare enum AggregateFunction {
|
|
11
|
-
Group = "group",
|
|
12
|
-
Sum = "sum",
|
|
13
|
-
Average = "avg",
|
|
14
|
-
Min = "min",
|
|
15
|
-
Max = "max",
|
|
16
|
-
First = "first",
|
|
17
|
-
Last = "last"
|
|
18
|
-
}
|
|
19
|
-
export declare enum Icon {
|
|
20
|
-
AxisX = "ico://axis-x",
|
|
21
|
-
AxisY = "ico://axis-y",
|
|
22
|
-
Value = "ico://value-column",
|
|
23
|
-
Filter = "ico://filter",
|
|
24
|
-
Sort = "ico://sort",
|
|
25
|
-
Heatmap = "ico://heatmap",
|
|
26
|
-
Drilldown = "ico://drilldown"
|
|
5
|
+
Aggregate = "aggregate",
|
|
6
|
+
Pivot = "pivot",
|
|
7
|
+
Table = "table"
|
|
27
8
|
}
|
|
28
9
|
export interface WidgetConfig {
|
|
29
10
|
data?: {
|
|
30
|
-
|
|
31
|
-
request?: DataRequest;
|
|
11
|
+
config: DataConfig | (DataConfig & WithKey)[];
|
|
32
12
|
};
|
|
33
13
|
options?: {
|
|
34
|
-
|
|
14
|
+
provider: GetWidgetOptionsConfig;
|
|
35
15
|
default: Options;
|
|
36
|
-
|
|
16
|
+
validators?: OptionsValidation;
|
|
37
17
|
};
|
|
38
18
|
}
|
|
39
|
-
export interface
|
|
40
|
-
|
|
19
|
+
export interface DataConfig {
|
|
20
|
+
label: Text;
|
|
41
21
|
method: DataQueryMethod;
|
|
42
|
-
|
|
22
|
+
blocks: Block[];
|
|
43
23
|
validation?: {
|
|
44
24
|
requiredSome?: string[];
|
|
45
25
|
requiredEvery?: string[];
|
|
46
26
|
};
|
|
47
|
-
repeatable?: boolean
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
27
|
+
repeatable?: boolean | {
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
};
|
|
31
|
+
drilldown?: {
|
|
32
|
+
source: string;
|
|
33
|
+
};
|
|
34
|
+
heatmap?: boolean | {
|
|
35
|
+
targets: string[];
|
|
36
|
+
};
|
|
51
37
|
}
|
|
52
38
|
export interface WithKey {
|
|
53
39
|
key: string;
|
|
54
40
|
}
|
|
55
|
-
export interface
|
|
56
|
-
blocks: Block[];
|
|
57
|
-
method: DataQueryMethod;
|
|
58
|
-
rowsLimit: number;
|
|
59
|
-
pagination?: boolean;
|
|
60
|
-
}
|
|
61
|
-
export declare type DataConfig = DataConfigItem | DataConfigItem[] | {
|
|
62
|
-
[key: string]: DataConfigItem | DataConfigItem[];
|
|
63
|
-
};
|
|
64
|
-
export interface DataRequest {
|
|
65
|
-
(viewConfig: DataConfig, options: Options): DataConfig;
|
|
66
|
-
}
|
|
67
|
-
export declare function data(params: {
|
|
41
|
+
export interface Block {
|
|
68
42
|
key: string;
|
|
69
43
|
label: Text;
|
|
70
44
|
icon?: string;
|
|
71
|
-
|
|
72
|
-
columnTypes?: ColumnType[];
|
|
73
|
-
max?: number;
|
|
74
|
-
}): Block;
|
|
75
|
-
export declare function filter(params?: {
|
|
76
|
-
label?: Text;
|
|
77
|
-
icon?: Icon | string;
|
|
78
|
-
}): Block;
|
|
79
|
-
export declare function sort(params?: {
|
|
80
|
-
label?: Text;
|
|
81
|
-
icon?: Icon | string;
|
|
82
|
-
}): Block;
|
|
83
|
-
export declare function heatmap(params?: {
|
|
84
|
-
label?: Text;
|
|
85
|
-
icon?: Icon | string;
|
|
86
|
-
max?: number;
|
|
87
|
-
}): Block;
|
|
88
|
-
export declare function drilldown(params: {
|
|
89
|
-
source: string;
|
|
90
|
-
additionalFilterSources?: string[];
|
|
91
|
-
label?: Text;
|
|
92
|
-
icon?: Icon | string;
|
|
45
|
+
aggregation?: boolean;
|
|
93
46
|
max?: number;
|
|
94
|
-
}): Block;
|
|
95
|
-
export declare function rowsLimit(params?: {
|
|
96
|
-
label?: Text;
|
|
97
|
-
}): Block;
|
|
98
|
-
export declare const STEP = 48;
|
|
99
|
-
export interface GetWidgetOptionsView {
|
|
100
|
-
(options: Options, dataConfig?: DataConfig): WidgetOptionConfig[];
|
|
101
47
|
}
|
|
48
|
+
export declare const STEP = 24;
|
|
49
|
+
export interface GetWidgetOptionsConfig {
|
|
50
|
+
(options: Options): WidgetOptionConfig[];
|
|
51
|
+
}
|
|
52
|
+
export declare function title(label: Text): WidgetOptionConfig;
|
|
53
|
+
export declare function label(label: Text): WidgetOptionConfig;
|
|
54
|
+
export declare function spacer(span: number): WidgetOptionConfig;
|
|
102
55
|
export declare function text(params: {
|
|
103
56
|
key: string;
|
|
104
57
|
label: Text;
|
|
105
58
|
span?: number;
|
|
106
|
-
defaultValue?: string;
|
|
107
59
|
}): WidgetOptionConfig;
|
|
108
60
|
export declare function number(params: {
|
|
109
61
|
key: string;
|
|
110
62
|
label: Text;
|
|
111
63
|
span?: number;
|
|
112
|
-
defaultValue?: string;
|
|
113
64
|
}): WidgetOptionConfig;
|
|
114
65
|
export declare function integer(params: {
|
|
115
66
|
key: string;
|
|
116
67
|
label: Text;
|
|
117
68
|
span?: number;
|
|
118
|
-
defaultValue?: string;
|
|
119
69
|
}): WidgetOptionConfig;
|
|
120
70
|
export declare function range(params: {
|
|
121
71
|
key: string;
|
|
122
72
|
label: Text;
|
|
123
73
|
span?: number;
|
|
124
|
-
defaultValue?: string;
|
|
125
74
|
}): WidgetOptionConfig;
|
|
126
75
|
export declare function interval(params: {
|
|
127
76
|
key: string;
|
|
128
77
|
label: Text;
|
|
129
78
|
span?: number;
|
|
130
|
-
defaultValue?: string;
|
|
131
79
|
}): WidgetOptionConfig;
|
|
132
80
|
export declare function date(params: {
|
|
133
81
|
key: string;
|
|
134
82
|
label: Text;
|
|
135
83
|
span?: number;
|
|
136
|
-
defaultValue?: string;
|
|
137
84
|
}): WidgetOptionConfig;
|
|
138
85
|
export declare function time(params: {
|
|
139
86
|
key: string;
|
|
140
87
|
label: Text;
|
|
141
88
|
span?: number;
|
|
142
|
-
defaultValue?: string;
|
|
143
89
|
}): WidgetOptionConfig;
|
|
144
90
|
export declare function dateTime(params: {
|
|
145
91
|
key: string;
|
|
146
92
|
label: Text;
|
|
147
93
|
span?: number;
|
|
148
|
-
defaultValue?: string;
|
|
149
94
|
}): WidgetOptionConfig;
|
|
150
95
|
export declare function checkbox(params: {
|
|
151
96
|
key: string;
|
|
152
97
|
label: Text;
|
|
153
98
|
span?: number;
|
|
154
|
-
defaultValue?: boolean;
|
|
155
99
|
}): WidgetOptionConfig;
|
|
156
100
|
export declare function radio(params: {
|
|
157
101
|
key: string;
|
|
@@ -161,7 +105,15 @@ export declare function radio(params: {
|
|
|
161
105
|
value: string;
|
|
162
106
|
}[];
|
|
163
107
|
span?: number;
|
|
164
|
-
|
|
108
|
+
}): WidgetOptionConfig;
|
|
109
|
+
export declare function radioButton(params: {
|
|
110
|
+
key: string;
|
|
111
|
+
label: Text;
|
|
112
|
+
options: {
|
|
113
|
+
label: Text;
|
|
114
|
+
value: string;
|
|
115
|
+
}[];
|
|
116
|
+
span?: number;
|
|
165
117
|
}): WidgetOptionConfig;
|
|
166
118
|
export declare function select(params: {
|
|
167
119
|
key: string;
|
|
@@ -171,15 +123,12 @@ export declare function select(params: {
|
|
|
171
123
|
value: string;
|
|
172
124
|
}[];
|
|
173
125
|
span?: number;
|
|
174
|
-
defaultValue?: string;
|
|
175
126
|
}): WidgetOptionConfig;
|
|
176
127
|
export declare function colorPicker(params: {
|
|
177
128
|
key: string;
|
|
178
129
|
label: Text;
|
|
179
130
|
span?: number;
|
|
180
|
-
defaultValue?: string;
|
|
181
131
|
}): WidgetOptionConfig;
|
|
182
|
-
export declare function title(label: Text, description?: Text): WidgetOptionConfig;
|
|
183
132
|
export interface OptionsValidation {
|
|
184
133
|
[key: string]: OptionsValidator;
|
|
185
134
|
}
|
package/widget-config.js
CHANGED
|
@@ -1,102 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const widget_config_1 = require("./__internal__/widget-config");
|
|
3
|
+
exports.colorPicker = exports.select = exports.radioButton = exports.radio = exports.checkbox = exports.dateTime = exports.time = exports.date = exports.interval = exports.range = exports.integer = exports.number = exports.text = exports.spacer = exports.label = exports.title = exports.STEP = exports.DataQueryMethod = void 0;
|
|
5
4
|
const widget_options_1 = require("./__internal__/widget-options");
|
|
6
5
|
// enums
|
|
7
6
|
var DataQueryMethod;
|
|
8
7
|
(function (DataQueryMethod) {
|
|
9
|
-
DataQueryMethod["Table"] = "table";
|
|
10
8
|
DataQueryMethod["Aggregate"] = "aggregate";
|
|
9
|
+
DataQueryMethod["Pivot"] = "pivot";
|
|
10
|
+
DataQueryMethod["Table"] = "table";
|
|
11
11
|
})(DataQueryMethod = exports.DataQueryMethod || (exports.DataQueryMethod = {}));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Icon["Sort"] = "ico://sort";
|
|
29
|
-
Icon["Heatmap"] = "ico://heatmap";
|
|
30
|
-
Icon["Drilldown"] = "ico://drilldown";
|
|
31
|
-
})(Icon = exports.Icon || (exports.Icon = {}));
|
|
32
|
-
// blocks
|
|
33
|
-
function data(params) {
|
|
34
|
-
return Object.assign({ type: widget_config_1.BlockType.Data }, params);
|
|
35
|
-
}
|
|
36
|
-
exports.data = data;
|
|
37
|
-
function filter(params = {}) {
|
|
38
|
-
return {
|
|
39
|
-
type: widget_config_1.BlockType.Filter,
|
|
40
|
-
label: params.label || {
|
|
41
|
-
ru: 'Фильтры',
|
|
42
|
-
en: 'Filters',
|
|
43
|
-
},
|
|
44
|
-
icon: params.icon || Icon.Filter,
|
|
45
|
-
key: '',
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.filter = filter;
|
|
49
|
-
function sort(params = {}) {
|
|
50
|
-
return {
|
|
51
|
-
type: widget_config_1.BlockType.Sort,
|
|
52
|
-
label: params.label || {
|
|
53
|
-
ru: 'Сортировка',
|
|
54
|
-
en: 'Sort',
|
|
55
|
-
},
|
|
56
|
-
icon: params.icon || Icon.Sort,
|
|
57
|
-
key: '',
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
exports.sort = sort;
|
|
61
|
-
function heatmap(params = {}) {
|
|
62
|
-
return {
|
|
63
|
-
type: widget_config_1.BlockType.Heatmap,
|
|
64
|
-
label: params.label || {
|
|
65
|
-
ru: 'Тепловая карта',
|
|
66
|
-
en: 'Heatmap',
|
|
67
|
-
},
|
|
68
|
-
icon: params.icon || Icon.Heatmap,
|
|
69
|
-
max: params.max || 0,
|
|
70
|
-
key: '',
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
exports.heatmap = heatmap;
|
|
74
|
-
function drilldown(params) {
|
|
75
|
-
return {
|
|
76
|
-
type: widget_config_1.BlockType.Drilldown,
|
|
77
|
-
key: (0, widget_config_1.decodeDrilldownData)(params.source, params.additionalFilterSources || []),
|
|
78
|
-
label: params.label || {
|
|
79
|
-
ru: 'Drilldown',
|
|
80
|
-
en: 'Drilldown',
|
|
81
|
-
},
|
|
82
|
-
icon: params.icon || Icon.Drilldown,
|
|
83
|
-
max: params.max || 4,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
exports.drilldown = drilldown;
|
|
87
|
-
function rowsLimit(params = {}) {
|
|
88
|
-
return {
|
|
89
|
-
type: widget_config_1.BlockType.RowsLimit,
|
|
90
|
-
label: params.label || {
|
|
91
|
-
ru: 'Количество записей на странице',
|
|
92
|
-
en: 'Rows limit',
|
|
93
|
-
},
|
|
94
|
-
key: '',
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
exports.rowsLimit = rowsLimit;
|
|
98
|
-
// widget optiosn
|
|
99
|
-
exports.STEP = 48;
|
|
12
|
+
// widget options
|
|
13
|
+
exports.STEP = 24;
|
|
14
|
+
// layout
|
|
15
|
+
function title(label) {
|
|
16
|
+
return { type: widget_options_1.WidgetOptionType.Title, label };
|
|
17
|
+
}
|
|
18
|
+
exports.title = title;
|
|
19
|
+
function label(label) {
|
|
20
|
+
return { type: widget_options_1.WidgetOptionType.Label, label };
|
|
21
|
+
}
|
|
22
|
+
exports.label = label;
|
|
23
|
+
function spacer(span) {
|
|
24
|
+
return { type: widget_options_1.WidgetOptionType.Spacer, span };
|
|
25
|
+
}
|
|
26
|
+
exports.spacer = spacer;
|
|
27
|
+
// controls
|
|
100
28
|
function text(params) {
|
|
101
29
|
return Object.assign({ type: widget_options_1.WidgetOptionType.Text }, params);
|
|
102
30
|
}
|
|
@@ -137,6 +65,10 @@ function radio(params) {
|
|
|
137
65
|
return Object.assign({ type: widget_options_1.WidgetOptionType.Radio }, params);
|
|
138
66
|
}
|
|
139
67
|
exports.radio = radio;
|
|
68
|
+
function radioButton(params) {
|
|
69
|
+
return Object.assign({ type: widget_options_1.WidgetOptionType.RadioButtons }, params);
|
|
70
|
+
}
|
|
71
|
+
exports.radioButton = radioButton;
|
|
140
72
|
function select(params) {
|
|
141
73
|
return Object.assign({ type: widget_options_1.WidgetOptionType.Select }, params);
|
|
142
74
|
}
|
|
@@ -145,12 +77,3 @@ function colorPicker(params) {
|
|
|
145
77
|
return Object.assign({ type: widget_options_1.WidgetOptionType.ColorPicker }, params);
|
|
146
78
|
}
|
|
147
79
|
exports.colorPicker = colorPicker;
|
|
148
|
-
function title(label, description) {
|
|
149
|
-
return {
|
|
150
|
-
type: widget_options_1.WidgetOptionType.Title,
|
|
151
|
-
label,
|
|
152
|
-
defaultValue: description,
|
|
153
|
-
key: '',
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
exports.title = title;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Text } from '../locale';
|
|
2
|
-
import { ColumnType } from '../dataset';
|
|
3
|
-
import { AggregateFunction } from '../widget-config';
|
|
4
|
-
export declare enum BlockType {
|
|
5
|
-
Data = "data",
|
|
6
|
-
Filter = "filter",
|
|
7
|
-
Sort = "sort",
|
|
8
|
-
Heatmap = "heatmap",
|
|
9
|
-
Drilldown = "drilldown",
|
|
10
|
-
RowsLimit = "rows-limit"
|
|
11
|
-
}
|
|
12
|
-
export interface Block {
|
|
13
|
-
type: BlockType;
|
|
14
|
-
key: string;
|
|
15
|
-
label: Text;
|
|
16
|
-
icon?: string;
|
|
17
|
-
aggregateFunction?: AggregateFunction;
|
|
18
|
-
columnTypes?: ColumnType[];
|
|
19
|
-
max?: number;
|
|
20
|
-
}
|
|
21
|
-
export declare function decodeDrilldownData(source: string, additionalFilterSources: string[]): string;
|
|
22
|
-
export declare function encodeDrilldownData(key: string): {
|
|
23
|
-
source: string;
|
|
24
|
-
additionalFilterSources: string[];
|
|
25
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeDrilldownData = exports.decodeDrilldownData = exports.BlockType = void 0;
|
|
4
|
-
// enums
|
|
5
|
-
var BlockType;
|
|
6
|
-
(function (BlockType) {
|
|
7
|
-
BlockType["Data"] = "data";
|
|
8
|
-
BlockType["Filter"] = "filter";
|
|
9
|
-
BlockType["Sort"] = "sort";
|
|
10
|
-
BlockType["Heatmap"] = "heatmap";
|
|
11
|
-
BlockType["Drilldown"] = "drilldown";
|
|
12
|
-
BlockType["RowsLimit"] = "rows-limit";
|
|
13
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
|
14
|
-
function decodeDrilldownData(source, additionalFilterSources) {
|
|
15
|
-
const keyParts = [length(source.length), source];
|
|
16
|
-
additionalFilterSources.forEach(item => keyParts.push(length(item.length), item));
|
|
17
|
-
return keyParts.join('');
|
|
18
|
-
function length(value) {
|
|
19
|
-
if (value > 0xff)
|
|
20
|
-
throw new RangeError();
|
|
21
|
-
return value > 0xf
|
|
22
|
-
? `0x${value.toString(16)}`
|
|
23
|
-
: `0x0${value.toString(16)}`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.decodeDrilldownData = decodeDrilldownData;
|
|
27
|
-
function encodeDrilldownData(key) {
|
|
28
|
-
const parts = [];
|
|
29
|
-
parse();
|
|
30
|
-
const [source, ...additionalFilterSources] = parts;
|
|
31
|
-
return {
|
|
32
|
-
source,
|
|
33
|
-
additionalFilterSources,
|
|
34
|
-
};
|
|
35
|
-
function parse(offset = 0) {
|
|
36
|
-
const start = offset + 4;
|
|
37
|
-
const end = start + parseInt(key.slice(offset, start));
|
|
38
|
-
parts.push(key.slice(start, end));
|
|
39
|
-
if (end < key.length)
|
|
40
|
-
parse(end);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.encodeDrilldownData = encodeDrilldownData;
|