@kepler.gl/types 3.0.0-alpha.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/actions.d.ts ADDED
@@ -0,0 +1,72 @@
1
+ import {SavedMap, ParsedConfig} from './schemas';
2
+
3
+ /** EXPORT_FILE_TO_CLOUD */
4
+ export type MapData = {
5
+ map: SavedMap;
6
+ thumbnail: Blob | null;
7
+ };
8
+ export type ExportFileOptions = {
9
+ isPublic?: boolean;
10
+ overwrite?: boolean;
11
+ };
12
+ export type OnErrorCallBack = (error: Error) => any;
13
+ export type OnSuccessCallBack = (p: {
14
+ response: any;
15
+ provider: Provider;
16
+ options: ExportFileOptions;
17
+ }) => any;
18
+
19
+ export type ExportFileToCloudPayload = {
20
+ mapData: MapData;
21
+ provider: Provider;
22
+ options: ExportFileOptions;
23
+ onSuccess?: OnSuccessCallBack;
24
+ onError?: OnErrorCallBack;
25
+ closeModal?: boolean;
26
+ };
27
+
28
+ /**
29
+ * Input dataset parsed to addDataToMap
30
+ */
31
+ export type ProtoDataset = {
32
+ info: {
33
+ id?: string;
34
+ label?: string;
35
+ format?: string;
36
+ color?: RGBColor;
37
+ type?: string;
38
+ };
39
+ data: {
40
+ fields: {
41
+ name: string;
42
+ type?: string;
43
+ format?: string;
44
+ displayName?: string;
45
+ id?: string;
46
+ }[];
47
+ rows: any[][];
48
+ };
49
+
50
+ // table-injected metadata
51
+ metadata?: any;
52
+ supportedFilterTypes?: string[] | null;
53
+ disableDataOperation?: boolean;
54
+ };
55
+
56
+ export type AddDataToMapOptions = {
57
+ centerMap?: boolean;
58
+ readOnly?: boolean;
59
+ keepExistingConfig?: boolean;
60
+ autoCreateLayers?: boolean;
61
+ };
62
+
63
+ export type AddDataToMapPayload = {
64
+ // TODO/ib - internally the code calls `toArray` a couple of layers deep
65
+ // so this function can actually accept both an array and an object
66
+ // recommend dropping such "sloppy typing" and enforcing array type
67
+ // as the field is called `datasets`
68
+ datasets: ProtoDataset[] | ProtoDataset;
69
+ options?: AddDataToMapOptions;
70
+ config?: ParsedConfig;
71
+ info?: Partial<MapInfo>;
72
+ };
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './layers';
2
+ export * from './reducers';
3
+ export * from './actions';
4
+ export * from './schemas';
5
+ export * from './types';
package/layers.d.ts ADDED
@@ -0,0 +1,268 @@
1
+ export type LayerBaseConfig = {
2
+ dataId: string | null;
3
+ label: string;
4
+ color: RGBColor;
5
+
6
+ columns: LayerColumns;
7
+ isVisible: boolean;
8
+ isConfigActive: boolean;
9
+ highlightColor: RGBColor | RGBAColor;
10
+ hidden: boolean;
11
+
12
+ visConfig: LayerVisConfig;
13
+ textLabel: LayerTextLabel[];
14
+
15
+ colorUI: {
16
+ color: ColorUI;
17
+ colorRange: ColorUI;
18
+ };
19
+ animation: {
20
+ enabled: boolean;
21
+ domain?: null;
22
+ };
23
+ };
24
+
25
+ export type LayerColorConfig = {
26
+ colorField: VisualChannelField;
27
+ colorDomain: VisualChannelDomain;
28
+ colorScale: VisualChannelScale;
29
+ };
30
+ export type LayerSizeConfig = {
31
+ // color by size, domain is set by filters, field, scale type
32
+ sizeDomain: VisualChannelDomain;
33
+ sizeScale: VisualChannelScale;
34
+ sizeField: VisualChannelField;
35
+ };
36
+ export type LayerHeightConfig = {
37
+ heightField: VisualChannelField;
38
+ heightDomain: VisualChannelDomain;
39
+ heightScale: VisualChannelScale;
40
+ };
41
+ export type LayerStrokeColorConfig = {
42
+ strokeColorField: VisualChannelField;
43
+ strokeColorDomain: VisualChannelDomain;
44
+ strokeColorScale: VisualChannelScale;
45
+ };
46
+ export type LayerCoverageConfig = {
47
+ coverageField: VisualChannelField;
48
+ coverageDomain: VisualChannelDomain;
49
+ coverageScale: VisualChannelScale;
50
+ };
51
+ export type LayerRadiusConfig = {
52
+ radiusField: VisualChannelField;
53
+ radiusDomain: VisualChannelDomain;
54
+ radiusScale: VisualChannelScale;
55
+ };
56
+ export type LayerWeightConfig = {
57
+ weightField: VisualChannelField;
58
+ };
59
+
60
+ export type Field = {
61
+ analyzerType: string;
62
+ id?: string;
63
+ name: string;
64
+ displayName: string;
65
+ format: string;
66
+ type: string;
67
+ fieldIdx: number;
68
+ valueAccessor(v: {index: number}): any;
69
+ filterProps?: any;
70
+ metadata?: any;
71
+ };
72
+
73
+ export type FieldPair = {
74
+ defaultName: string;
75
+ pair: {
76
+ [key: string]: {
77
+ fieldIdx: number;
78
+ value: string;
79
+ };
80
+ };
81
+ suffix: string[];
82
+ };
83
+
84
+ export type LayerTextLabel = {
85
+ field: Field | null;
86
+ color: RGBColor;
87
+ size: number;
88
+ offset: [number, number];
89
+ anchor: string;
90
+ alignment: string;
91
+ };
92
+
93
+ export type ColorUI = {
94
+ // customPalette in edit
95
+ customPalette: ColorRange;
96
+ // show color sketcher modal
97
+ showSketcher: boolean | number;
98
+ // show color range selection panel
99
+ showDropdown: boolean | number;
100
+ // color range selector config
101
+ colorRangeConfig: {
102
+ type: string;
103
+ steps: number;
104
+ reversed: boolean;
105
+ custom: boolean;
106
+ };
107
+ };
108
+
109
+ export type VisConfig = {
110
+ label:
111
+ | string
112
+ | ((
113
+ config: LayerBaseConfig &
114
+ Partial<LayerColorConfig> &
115
+ Partial<LayerHeightConfig> &
116
+ Partial<LayerSizeConfig> &
117
+ Partial<LayerWeightConfig>
118
+ ) => string);
119
+ group: keyof typeof PROPERTY_GROUPS;
120
+ property: string;
121
+ description?: string;
122
+ condition?: (
123
+ config: LayerBaseConfig &
124
+ Partial<LayerColorConfig> &
125
+ Partial<LayerHeightConfig> &
126
+ Partial<LayerSizeConfig> &
127
+ Partial<LayerWeightConfig>
128
+ ) => boolean;
129
+
130
+ allowCustomValue?: boolean;
131
+ };
132
+
133
+ export type VisConfigNumber = VisConfig & {
134
+ type: 'number';
135
+ isRanged: false;
136
+ defaultValue: number;
137
+ range: [number, number];
138
+ step: number;
139
+ };
140
+
141
+ export type VisConfigBoolean = VisConfig & {
142
+ type: 'boolean';
143
+ defaultValue: boolean;
144
+ };
145
+
146
+ export type VisConfigSelection = VisConfig & {
147
+ type: 'select';
148
+ defaultValue: string;
149
+ options: string[];
150
+ };
151
+
152
+ export type VisConfigRange = VisConfig & {
153
+ type: 'number';
154
+ isRanged: boolean;
155
+ range: [number, number];
156
+ defaultValue: [number, number];
157
+ step: number;
158
+ };
159
+
160
+ export type VisConfigColorSelect = VisConfig & {
161
+ type: 'color-select';
162
+ defaultValue: null;
163
+ };
164
+
165
+ export type VisConfigColorRange = VisConfig & {
166
+ type: 'color-range-select';
167
+ defaultValue: ColorRange;
168
+ };
169
+
170
+ export type LayerVisConfigSettings = {
171
+ thickness: VisConfigNumber;
172
+ strokeWidthRange: VisConfigRange;
173
+ trailLength: VisConfigNumber;
174
+ radius: VisConfigNumber;
175
+ fixedRadius: VisConfigBoolean;
176
+ radiusRange: VisConfigRange;
177
+ clusterRadius: VisConfigNumber;
178
+ clusterRadiusRange: VisConfigRange;
179
+ opacity: VisConfigNumber;
180
+ coverage: VisConfigNumber;
181
+ outline: VisConfigBoolean;
182
+ colorRange: VisConfigColorRange;
183
+ strokeColorRange: VisConfigColorRange;
184
+ targetColor: VisConfigColorSelect;
185
+ strokeColor: VisConfigColorSelect;
186
+ colorAggregation: VisConfigSelection;
187
+ sizeAggregation: VisConfigSelection;
188
+ percentile: VisConfigRange;
189
+ elevationPercentile: VisConfigRange;
190
+ resolution: VisConfigNumber;
191
+ sizeScale: VisConfigNumber;
192
+ angle: VisConfigNumber;
193
+ worldUnitSize: VisConfigNumber;
194
+ elevationScale: VisConfigNumber;
195
+ enableElevationZoomFactor: VisConfigBoolean;
196
+ elevationRange: VisConfigRange;
197
+ heightRange: VisConfigRange;
198
+ coverageRange: VisConfigRange;
199
+ 'hi-precision': VisConfigBoolean;
200
+ enable3d: VisConfigBoolean;
201
+ stroked: VisConfigBoolean;
202
+ filled: VisConfigBoolean;
203
+ extruded: VisConfigBoolean;
204
+ wireframe: VisConfigBoolean;
205
+ weight: VisConfigNumber;
206
+ heatmapRadius: VisConfigNumber;
207
+ };
208
+
209
+ // TODO: Move this to individual layers
210
+ export type LayerVisConfig = {
211
+ [key: string]: any;
212
+ // possible visConfigs
213
+
214
+ // thickness: number;
215
+ // sizeRange: number;
216
+ // trailLength: number;
217
+ // radius: number;
218
+ // fixedRadius: boolean;
219
+ // radiusRange: [number, number];
220
+ // clusterRadius: number;
221
+ // opacity: number;
222
+ // coverage: number;
223
+ // outline: boolean;
224
+ // colorRange: ColorRange;
225
+ // strokeColorRange: ColorRange;
226
+ // targetColor: any;
227
+ // strokeColor: any;
228
+ // colorAggregation: keyof typeof AGGREGATION_TYPES;
229
+ // sizeAggregation: keyof typeof AGGREGATION_TYPES;
230
+ // percentile: [number, number];
231
+ // elevationPercentile: [number, number];
232
+ // resolution: number;
233
+ // sizeScale: number;
234
+ // angle: number;
235
+ // worldUnitSize: number;
236
+ // elevationScale: number;
237
+ // enableElevationZoomFactor: boolean;
238
+ // heightRange: [number, number];
239
+ // coverageRange: [number, number];
240
+ // 'hi-precision': boolean;
241
+ // enable3d: boolean;
242
+ // stroked: boolean;
243
+ // filled: boolean;
244
+ // extruded: boolean;
245
+ // wireframe: boolean;
246
+ // weight: number;
247
+ };
248
+
249
+ export type TextConfigSelect = {
250
+ type: 'select';
251
+ options: string[];
252
+ multiSelect: boolean;
253
+ searchable: boolean;
254
+ };
255
+ export type TextConfigNumber = {
256
+ type: 'number';
257
+ range: number[];
258
+ value0: number;
259
+ step: number;
260
+ isRanged: boolean;
261
+ label: string;
262
+ showInput: boolean;
263
+ };
264
+ export type LayerTextConfig = {
265
+ fontSize: TextConfigNumber;
266
+ textAnchor: TextConfigSelect;
267
+ textAlignment: TextConfigSelect;
268
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@kepler.gl/types",
3
+ "author": "Shan He <shan@uber.com>",
4
+ "version": "3.0.0-alpha.0",
5
+ "description": "kepler.gl types used by kepler.gl components, actions and reducers",
6
+ "license": "MIT",
7
+ "types": "index.d.ts",
8
+ "keywords": [
9
+ "babel",
10
+ "es6",
11
+ "react",
12
+ "webgl",
13
+ "visualization",
14
+ "deck.gl"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/keplergl/kepler.gl.git"
19
+ },
20
+ "scripts": {
21
+ "prepublish": " ",
22
+ "stab": " "
23
+ },
24
+ "nyc": {
25
+ "sourceMap": false,
26
+ "instrument": false
27
+ },
28
+ "engines": {
29
+ "node": ">=12.0.0"
30
+ },
31
+ "maintainers": [
32
+ "Shan He <heshan0131@gmail.com>",
33
+ "Giuseppe Macri <gmacri@uber.com>"
34
+ ],
35
+ "volta": {
36
+ "node": "12.22.0",
37
+ "yarn": "1.22.17"
38
+ }
39
+ }
package/reducers.d.ts ADDED
@@ -0,0 +1,411 @@
1
+ import {Field, Millisecond} from './types';
2
+
3
+ export type MapState = {
4
+ pitch: number;
5
+ bearing: number;
6
+ latitude: number;
7
+ longitude: number;
8
+ zoom: number;
9
+ dragRotate: boolean;
10
+ width: number;
11
+ height: number;
12
+ isSplit: boolean;
13
+ initialState?: any;
14
+ scale?: number;
15
+ };
16
+
17
+ export type Bounds = [number, number, number, number];
18
+
19
+ export type HistogramBin = {
20
+ x0: number | undefined;
21
+ x1: number | undefined;
22
+ count: number;
23
+ };
24
+
25
+ export type RangeFieldDomain = {
26
+ domain: [number, number];
27
+ step: number;
28
+ histogram: HistogramBin[];
29
+ enlargedHistogram: HistogramBin[];
30
+ };
31
+
32
+ export type SelectFieldDomain = {
33
+ domain: [true, false];
34
+ };
35
+ export type MultiSelectFieldDomain = {
36
+ domain: string[];
37
+ };
38
+
39
+ export type TimeRangeFieldDomain = {
40
+ domain: [number, number];
41
+ step: number;
42
+ histogram: HistogramBin[];
43
+ enlargedHistogram: HistogramBin[];
44
+ mappedValue: (Millisecond | null)[];
45
+ // auto generated based on time domain
46
+ defaultTimeFormat?: string | null;
47
+ // custom ui input
48
+ timeFormat?: string | null;
49
+ // custom ui input
50
+ timezone?: string | null;
51
+ };
52
+ export type FieldDomain =
53
+ | RangeFieldDomain
54
+ | TimeRangeFieldDomain
55
+ | SelectFieldDomain
56
+ | MultiSelectFieldDomain;
57
+
58
+ export type LineChart = {
59
+ series: {x: number; y: number}[];
60
+ yDomain: [number, number];
61
+ xDomain: [number, number];
62
+ };
63
+
64
+ export type FilterBase<L extends LineChart> = {
65
+ dataId: string[];
66
+ id: string;
67
+
68
+ freeze: boolean;
69
+
70
+ // time range filter specific
71
+ fixedDomain: boolean;
72
+ enlarged: boolean;
73
+ isAnimating: boolean;
74
+ speed: number;
75
+ showTimeDisplay?: boolean;
76
+
77
+ // field specific
78
+ name: string[]; // string
79
+ type: string | null;
80
+ fieldIdx: number[]; // [integer]
81
+ domain: any[] | null;
82
+ value: any;
83
+ mappedValue?: number[];
84
+
85
+ // plot
86
+ yAxis: Field | null;
87
+ plotType: string;
88
+ lineChart?: L;
89
+ // gpu filter
90
+ gpu: boolean;
91
+ gpuChannel?: number[];
92
+ fieldType?: string;
93
+
94
+ // polygon
95
+ layerId?: string[];
96
+ };
97
+
98
+ export type RangeFilter = FilterBase<LineChart> &
99
+ RangeFieldDomain & {
100
+ type: 'range';
101
+ fieldType: 'real' | 'integer';
102
+ value: [number, number];
103
+ fixedDomain: true;
104
+ typeOptions: ['range'];
105
+ };
106
+
107
+ export type SelectFilter = FilterBase<LineChart> &
108
+ SelectFieldDomain & {
109
+ type: 'select';
110
+ fieldType: 'boolean';
111
+ value: boolean;
112
+ };
113
+
114
+ export type MultiSelectFilter = FilterBase<LineChart> &
115
+ MultiSelectFieldDomain & {
116
+ type: 'range';
117
+ fieldType: 'string' | 'date';
118
+ value: string[];
119
+ };
120
+ export type TimeRangeFilter = FilterBase<LineChart> &
121
+ TimeRangeFieldDomain & {
122
+ type: 'timeRange';
123
+ fieldType: 'timestamp';
124
+ fixedDomain: true;
125
+ value: [number, number];
126
+ bins?: Object;
127
+ plotType: {
128
+ [key: string]: any;
129
+ };
130
+ animationWindow: string;
131
+ };
132
+
133
+ export type PolygonFilter = FilterBase<LineChart> & {
134
+ layerId: string[];
135
+ type: 'polygon';
136
+ fixedDomain: true;
137
+ value: Feature;
138
+ };
139
+
140
+ export type Filter =
141
+ | FilterBase<LineChart>
142
+ | RangeFilter
143
+ | TimeRangeFilter
144
+ | SelectFilter
145
+ | MultiSelectFilter
146
+ | PolygonFilter;
147
+
148
+ export type Feature = {
149
+ id: string;
150
+ properties: any;
151
+ geometry: {
152
+ type: string;
153
+ coordinates: any;
154
+ };
155
+ };
156
+ export type FeatureValue = {
157
+ id: string;
158
+ properties: {
159
+ filterId: string;
160
+ };
161
+ geometry: {
162
+ type: string;
163
+ coordinates: any;
164
+ };
165
+ };
166
+ export type Editor = {
167
+ mode: string;
168
+ features: Feature[];
169
+ selectedFeature: any;
170
+ visible: boolean;
171
+ };
172
+
173
+ export type SplitMapLayers = {[key: string]: boolean};
174
+ export type SplitMap = {
175
+ layers: SplitMapLayers;
176
+ };
177
+ export type AnimationConfig = {
178
+ domain: number[] | null;
179
+ currentTime: number | null;
180
+ speed: number;
181
+ isAnimating?: boolean;
182
+ // auto generated based on time domain
183
+ defaultTimeFormat?: string | null;
184
+ // custom ui input
185
+ timeFormat?: string | null;
186
+ // custom ui input
187
+ timezone?: string | null;
188
+ // hide or show control
189
+ hideControl?: boolean;
190
+ };
191
+
192
+ export type BaseInteraction = {
193
+ label: string;
194
+ enabled: boolean;
195
+ };
196
+ export type TooltipField = {
197
+ name: string;
198
+ format: string | null;
199
+ };
200
+ export type CompareType = string | null;
201
+ export type TooltipInfo = BaseInteraction & {
202
+ id: 'tooltip';
203
+ config: {
204
+ fieldsToShow: {
205
+ [key: string]: TooltipField[];
206
+ };
207
+ compareMode: boolean;
208
+ compareType: CompareType;
209
+ };
210
+ };
211
+ export type Geocoder = BaseInteraction & {
212
+ id: 'geocoder';
213
+ position: number[] | null;
214
+ };
215
+ export type Brush = BaseInteraction & {
216
+ id: 'brush';
217
+ config: {
218
+ size: number;
219
+ };
220
+ };
221
+ export type Coordinate = BaseInteraction & {
222
+ id: 'coordinate';
223
+ position: number[] | null;
224
+ };
225
+ export type InteractionConfig = {
226
+ tooltip: TooltipInfo;
227
+ geocoder: Geocoder;
228
+ brush: Brush;
229
+ coordinate: Coordinate;
230
+ };
231
+ export type MapInfo = {
232
+ title: string;
233
+ description: string;
234
+ };
235
+ export type FileLoading = {
236
+ filesToLoad: FileList;
237
+ onFinish: (payload: any) => any;
238
+ fileCache: any[];
239
+ };
240
+ export type FileLoadingProgress = {
241
+ [key: string]: {
242
+ percent: number;
243
+ message: string;
244
+ fileName: string;
245
+ error: any;
246
+ };
247
+ };
248
+
249
+ export type LayerGroup = {
250
+ slug: string;
251
+ filter(layer: {id: string}): boolean;
252
+ defaultVisibility: boolean;
253
+ };
254
+
255
+ export type BaseMapStyle = {
256
+ id: string;
257
+ label: string;
258
+ url: string;
259
+ icon: string;
260
+ style?: Object;
261
+ layerGroups: LayerGroup[];
262
+ accessToken?: string;
263
+ custom?: boolean;
264
+ };
265
+
266
+ export declare type ExportImage = {
267
+ ratio: 'SCREEN' | 'FOUR_BY_THREE' | 'SIXTEEN_BY_NINE' | 'CUSTOM';
268
+ resolution: 'ONE_X' | 'TWO_X';
269
+ legend: boolean;
270
+ mapH: number;
271
+ mapW: number;
272
+ imageSize: {
273
+ zoomOffset: number;
274
+ scale: number;
275
+ imageW: number;
276
+ imageH: number;
277
+ };
278
+ imageDataUri: string;
279
+ exporting: boolean;
280
+ processing: boolean;
281
+ error: Error | false;
282
+ center: boolean;
283
+ };
284
+
285
+ export type ExportData = {
286
+ selectedDataset: string;
287
+ dataType: string;
288
+ filtered: boolean;
289
+ };
290
+
291
+ export type ExportHtml = {
292
+ exportMapboxAccessToken: null | string;
293
+ userMapboxToken: string;
294
+ mode: string;
295
+ };
296
+ export type ExportJson = {
297
+ hasData: boolean;
298
+ };
299
+ export type ExportMap = {
300
+ HTML: ExportHtml;
301
+ JSON: ExportJson;
302
+ format: 'HTML' | 'JSON';
303
+ };
304
+
305
+ export type MapControl = {
306
+ show: boolean;
307
+ active: boolean;
308
+ disableClose?: boolean;
309
+ activeMapIndex?: number;
310
+ };
311
+ export type MapControls = {
312
+ visibleLayers?: MapControl;
313
+ mapLegend?: MapControl;
314
+ toggle3d?: MapControl;
315
+ splitMap?: MapControl;
316
+ mapDraw?: MapControl;
317
+ mapLocale?: MapControl;
318
+ };
319
+
320
+ export type LoadFiles = {
321
+ fileLoading: boolean;
322
+ };
323
+
324
+ export type Notifications = {
325
+ message: string;
326
+ type: string;
327
+ topic: string;
328
+ id: string;
329
+ count: number;
330
+ isExpanded?: boolean;
331
+ };
332
+
333
+ export type Locale = string;
334
+
335
+ export type LayerPanelListView = 'list' | 'sortByDataset';
336
+
337
+ export type UiState = {
338
+ readOnly: boolean;
339
+ activeSidePanel: string;
340
+ currentModal: string | null;
341
+ datasetKeyToRemove: string | null;
342
+ visibleDropdown: string | null;
343
+ // export image modal ui
344
+ exportImage: ExportImage;
345
+ // export data modal ui
346
+ exportData: ExportData;
347
+ // html export
348
+ exportMap: ExportMap;
349
+ // map control panels
350
+ mapControls: MapControls;
351
+ // ui notifications
352
+ notifications: Notifications[];
353
+ // load files
354
+ loadFiles: LoadFiles;
355
+ // Locale of the UI
356
+ locale: Locale;
357
+ layerPanelListView: LayerPanelListView;
358
+ };
359
+
360
+ /** Width of viewport */
361
+ export type Viewport = {
362
+ /** Width of viewport */
363
+ width?: number;
364
+ /** Height of viewport */
365
+ height?: number;
366
+ /** Zoom of viewport */
367
+ zoom?: number;
368
+ /** Camera angle in degrees (0 is straight down) */
369
+ pitch?: number;
370
+ /** Map rotation in degrees (0 means north is up) */
371
+ bearing?: number;
372
+ /** Latitude center of viewport on map in mercator projection */
373
+ latitude?: number;
374
+ /** Longitude Center of viewport on map in mercator projection */
375
+ longitude?: number;
376
+ /** Whether to enable drag and rotate map into perspective viewport */
377
+ dragRotate?: boolean;
378
+ };
379
+
380
+ export type MapStyles = {
381
+ [key: string]: BaseMapStyle;
382
+ };
383
+
384
+ export type VisibleLayerGroups = {
385
+ [key: string]: boolean;
386
+ };
387
+
388
+ export type InputStyle = {
389
+ accessToken: string | null;
390
+ error: boolean;
391
+ isValid: boolean;
392
+ label: string | null;
393
+ style: any | null;
394
+ url: string | null;
395
+ icon: string | null;
396
+ custom: boolean;
397
+ };
398
+
399
+ export type FilterRecord = {
400
+ dynamicDomain: Filter[];
401
+ fixedDomain: Filter[];
402
+ cpu: Filter[];
403
+ gpu: Filter[];
404
+ };
405
+
406
+ export type FilterDatasetOpt = {
407
+ // only allow cpu filtering
408
+ cpuOnly?: boolean;
409
+ // ignore filter for domain calculation
410
+ ignoreDomain?: boolean;
411
+ };
package/schemas.d.ts ADDED
@@ -0,0 +1,189 @@
1
+ import {RGBColor, Merge, RGBAColor} from './types';
2
+
3
+ import {Filter, TooltipInfo, InteractionConfig, AnimationConfig, SplitMap} from './reducers';
4
+
5
+ import {LayerTextLabel} from './layers';
6
+
7
+ export type SavedFilter = {
8
+ dataId: Filter['dataId'];
9
+ id: Filter['id'];
10
+ name: Filter['name'];
11
+ type: Filter['type'];
12
+ value: Filter['value'];
13
+ enlarged: Filter['enlarged'];
14
+ plotType: Filter['plotType'];
15
+ yAxis: {
16
+ name: string;
17
+ type: string;
18
+ } | null;
19
+ speed: Filter['speed'];
20
+ layerId: Filter['layerId'];
21
+ };
22
+
23
+ export type ParsedFilter = Partial<SavedFilter>;
24
+
25
+ export type SavedInteractionConfig = {
26
+ tooltip: TooltipInfo['config'] & {
27
+ enabled: boolean;
28
+ };
29
+ geocoder: TooltipInfo['geocoder'] & {
30
+ enabled: boolean;
31
+ };
32
+ brush: TooltipInfo['brush'] & {
33
+ enabled: boolean;
34
+ };
35
+ coordinate: TooltipInfo['coordinate'] & {
36
+ enabled: boolean;
37
+ };
38
+ };
39
+
40
+ export type SavedScale = string;
41
+ export type SavedVisualChannels = {
42
+ [key: string]: SavedField | SavedScale;
43
+ };
44
+
45
+ export type SavedLayer = {
46
+ id: string;
47
+ type: string;
48
+ config: {
49
+ dataId: string;
50
+ label: string;
51
+ color: RGBColor;
52
+ highlightColor?: RGBColor;
53
+ columns: {
54
+ [key: string]: string;
55
+ };
56
+ isVisible: boolean;
57
+ visConfig: object;
58
+ hidden: boolean;
59
+ textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;
60
+ };
61
+ visualChannels: SavedVisualChannels;
62
+ };
63
+
64
+ export type ParsedLayer = {
65
+ id?: string;
66
+ type?: string;
67
+ config?: Partial<SavedLayer['config']>;
68
+ };
69
+
70
+ export type SavedAnimationConfig = {
71
+ currentTime: AnimationConfig['currentTime'];
72
+ speed: AnimationConfig['speed'];
73
+ };
74
+
75
+ export type SavedVisState = {
76
+ filters: SavedFilter[];
77
+ layers: SavedLayer[];
78
+ interactionConfig: SavedInteractionConfig;
79
+ layerBlending: string;
80
+ splitMaps: SplitMap[];
81
+ animationConfig: SavedAnimationConfig;
82
+ };
83
+
84
+ export type ParsedVisState = {
85
+ layers?: ParsedLayer[];
86
+ filters?: ParsedFilter[];
87
+ interactionConfig?: Partial<SavedInteractionConfig>;
88
+ layerBlending?: string;
89
+ splitMaps?: SplitMap[];
90
+ animationConfig?: Partial<SavedAnimationConfig>;
91
+ };
92
+
93
+ export type SavedMapState = {
94
+ bearing: number;
95
+ dragRotate: boolean;
96
+ latitude: number;
97
+ longitude: number;
98
+ pitch: number;
99
+ zoom: number;
100
+ isSplit: boolean;
101
+ };
102
+
103
+ export type SavedLayerGroups = {
104
+ [key: string]: boolean;
105
+ };
106
+
107
+ export type SavedCustomMapStyle = {
108
+ [key: string]: {
109
+ accessToken: string;
110
+ custom: boolean;
111
+ icon: string;
112
+ id: string;
113
+ label: string;
114
+ url: string;
115
+ };
116
+ };
117
+
118
+ export type SavedMapStyle = {
119
+ styleType: string;
120
+ topLayerGroups: SavedLayerGroups;
121
+ visibleLayerGroups: SavedLayerGroups;
122
+ threeDBuildingColor: RGBColor;
123
+ mapStyles: SavedCustomMapStyle;
124
+ };
125
+
126
+ /** Schema for v1 saved configuration */
127
+ export type SavedConfigV1 = {
128
+ version: 'v1';
129
+ config: {
130
+ visState: SavedVisState;
131
+ mapState: SavedMapState;
132
+ mapStyle: SavedMapStyle;
133
+ };
134
+ };
135
+
136
+ /** Schema for a parsed configuration ("normalized" across versions) */
137
+ export type ParsedConfig = {
138
+ version: string;
139
+ visState?: ParsedVisState;
140
+ mapState?: Partial<SavedMapState>;
141
+ mapStyle?: Partial<SavedMapStyle>;
142
+ };
143
+
144
+ export type SavedField = {
145
+ name: string;
146
+ type: string;
147
+ } | null;
148
+ export type ParsedField = {
149
+ name: string;
150
+ type: string;
151
+ format: string;
152
+ analyzerType: string;
153
+ };
154
+
155
+ export type SavedDatasetV1 = {
156
+ version: 'v1';
157
+ data: {
158
+ id: string;
159
+ label: string;
160
+ color: RGBColor;
161
+ allData: any[][];
162
+ fields: SavedField[];
163
+ };
164
+ };
165
+
166
+ export type ParsedDataset = {
167
+ data: {
168
+ fields: ParsedField[];
169
+ rows: any[][];
170
+ };
171
+ info: {
172
+ id?: string;
173
+ label?: string;
174
+ color?: RGBColor;
175
+ };
176
+ };
177
+
178
+ export type SavedMap = {
179
+ datasets: SavedDatasetV1[];
180
+ config: SavedConfigV1;
181
+ info: {
182
+ app: string;
183
+ created_at: string;
184
+ title: string;
185
+ description: string;
186
+ };
187
+ };
188
+
189
+ export type LoadedMap = {datasets?: ParsedDataset[] | null; config?: ParsedConfig | null};
package/types.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ export type RGBColor = [number, number, number];
2
+ export type RGBAColor = [number, number, number, number];
3
+ export type HexColor = string; // this is the best typescript can do at the moment
4
+ export type Millisecond = number;
5
+
6
+ export type ValueOf<T> = T[keyof T];
7
+
8
+ export type Merge<A, B> = {[K in keyof A]: K extends keyof B ? B[K] : A[K]} & B extends infer O
9
+ ? {[K in keyof O]: O[K]}
10
+ : never;
11
+
12
+ export type Entries<T> = {
13
+ [K in keyof T]: [K, T[K]];
14
+ }[keyof T][];
15
+
16
+ export type NestedPartial<T> = {
17
+ [P in keyof T]?: NestedPartial<T[P]>;
18
+ };
19
+
20
+ export type RowData = {
21
+ [key: string]: string | null;
22
+ }[];
23
+
24
+ export type ProcessorResult = {fields: Field[]; rows: any[][]} | null;