@carto/api-client 0.3.1 → 0.4.0-alpha.1
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/build/api/carto-api-error.d.ts +26 -0
- package/build/api/endpoints.d.ts +24 -0
- package/build/api/index.d.ts +5 -0
- package/build/api/query.d.ts +3 -0
- package/build/api/request-with-parameters.d.ts +8 -0
- package/build/api-client.cjs +724 -65
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +607 -59
- package/build/api-client.modern.js.map +1 -1
- package/build/constants-internal.d.ts +9 -28
- package/build/constants.d.ts +24 -2
- package/build/index.d.ts +5 -1
- package/build/models/model.d.ts +2 -2
- package/build/sources/base-source.d.ts +4 -0
- package/build/sources/boundary-query-source.d.ts +9 -0
- package/build/sources/boundary-table-source.d.ts +7 -0
- package/build/sources/h3-query-source.d.ts +3 -0
- package/build/sources/h3-table-source.d.ts +3 -0
- package/build/sources/h3-tileset-source.d.ts +3 -0
- package/build/sources/index.d.ts +27 -5
- package/build/sources/quadbin-query-source.d.ts +3 -0
- package/build/sources/quadbin-table-source.d.ts +3 -0
- package/build/sources/quadbin-tileset-source.d.ts +3 -0
- package/build/sources/raster-source.d.ts +3 -0
- package/build/sources/types.d.ts +209 -85
- package/build/sources/vector-query-source.d.ts +3 -0
- package/build/sources/vector-table-source.d.ts +3 -0
- package/build/sources/vector-tileset-source.d.ts +3 -0
- package/build/types-internal.d.ts +46 -1
- package/build/types.d.ts +11 -0
- package/build/utils.d.ts +4 -0
- package/build/widget-sources/index.d.ts +5 -0
- package/build/widget-sources/types.d.ts +95 -0
- package/build/{sources → widget-sources}/widget-base-source.d.ts +2 -2
- package/build/{sources → widget-sources}/widget-query-source.d.ts +1 -1
- package/build/{sources → widget-sources}/widget-table-source.d.ts +1 -1
- package/build/{sources → widget-sources}/wrappers.d.ts +1 -1
- package/package.json +4 -3
- package/src/api/carto-api-error.ts +88 -0
- package/src/api/endpoints.ts +84 -0
- package/src/api/index.ts +14 -0
- package/src/api/query.ts +56 -0
- package/src/api/request-with-parameters.ts +135 -0
- package/src/constants-internal.ts +9 -30
- package/src/constants.ts +32 -3
- package/src/global.d.ts +3 -0
- package/src/index.ts +38 -1
- package/src/models/model.ts +4 -6
- package/src/sources/base-source.ts +101 -0
- package/src/sources/boundary-query-source.ts +53 -0
- package/src/sources/boundary-table-source.ts +41 -0
- package/src/sources/h3-query-source.ts +63 -0
- package/src/sources/h3-table-source.ts +59 -0
- package/src/sources/h3-tileset-source.ts +26 -0
- package/src/sources/index.ts +54 -5
- package/src/sources/quadbin-query-source.ts +64 -0
- package/src/sources/quadbin-table-source.ts +60 -0
- package/src/sources/quadbin-tileset-source.ts +26 -0
- package/src/sources/raster-source.ts +34 -0
- package/src/sources/types.ts +221 -89
- package/src/sources/vector-query-source.ts +65 -0
- package/src/sources/vector-table-source.ts +59 -0
- package/src/sources/vector-tileset-source.ts +26 -0
- package/src/types-internal.ts +54 -1
- package/src/types.ts +16 -0
- package/src/utils.ts +8 -0
- package/src/widget-sources/index.ts +5 -0
- package/src/widget-sources/types.ts +105 -0
- package/src/{sources → widget-sources}/widget-base-source.ts +5 -5
- package/src/{sources → widget-sources}/widget-query-source.ts +2 -3
- package/src/{sources → widget-sources}/widget-table-source.ts +2 -3
- package/src/{sources → widget-sources}/wrappers.ts +1 -22
package/src/sources/types.ts
CHANGED
|
@@ -1,105 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
SortDirection,
|
|
5
|
-
SpatialFilter,
|
|
6
|
-
} from '../types';
|
|
7
|
-
|
|
8
|
-
/******************************************************************************
|
|
9
|
-
* WIDGET API REQUESTS
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/** Common options for {@link WidgetBaseSource} requests. */
|
|
13
|
-
interface BaseRequestOptions {
|
|
14
|
-
spatialFilter?: SpatialFilter;
|
|
15
|
-
abortController?: AbortController;
|
|
16
|
-
filterOwner?: string;
|
|
17
|
-
}
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
18
4
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
23
|
-
operationColumn?: string;
|
|
24
|
-
}
|
|
5
|
+
import type {Feature} from 'geojson';
|
|
6
|
+
import {Filters, Format, QueryParameters} from '../types';
|
|
7
|
+
import {MapInstantiation} from '../types-internal';
|
|
25
8
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
30
|
-
operationExp?: string;
|
|
31
|
-
}
|
|
9
|
+
export type SourceRequiredOptions = {
|
|
10
|
+
/** Carto platform access token. */
|
|
11
|
+
accessToken: string;
|
|
32
12
|
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ticks: number[];
|
|
37
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
38
|
-
}
|
|
13
|
+
/** Data warehouse connection name in Carto platform. */
|
|
14
|
+
connectionName: string;
|
|
15
|
+
};
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
17
|
+
export type SourceOptionalOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Base URL of the CARTO Maps API.
|
|
20
|
+
*
|
|
21
|
+
* Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com`
|
|
22
|
+
*
|
|
23
|
+
* @default https://gcp-us-east1.api.carto.com
|
|
24
|
+
*/
|
|
25
|
+
apiBaseUrl: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Custom HTTP headers added to map instantiation and data requests.
|
|
29
|
+
*/
|
|
30
|
+
headers: Record<string, string>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Cache buster value returned by map instantiation.
|
|
34
|
+
*
|
|
35
|
+
* Carto source saves `cache` value of map instantiation response in `cache.value`, so it can be used to
|
|
36
|
+
* check if underlying map data has changed between distinct source requests.
|
|
37
|
+
*/
|
|
38
|
+
cache?: {value?: number};
|
|
39
|
+
|
|
40
|
+
clientId: string;
|
|
41
|
+
/** @deprecated use `query` instead **/
|
|
42
|
+
format: Format;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Maximum URL character length. Above this limit, requests use POST.
|
|
46
|
+
* Used to avoid browser and CDN limits.
|
|
47
|
+
* @default {@link DEFAULT_MAX_LENGTH_URL}
|
|
48
|
+
*/
|
|
49
|
+
maxLengthURL?: number;
|
|
50
|
+
};
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
export type SourceOptions = SourceRequiredOptions &
|
|
53
|
+
Partial<SourceOptionalOptions>;
|
|
54
|
+
|
|
55
|
+
export type AggregationOptions = {
|
|
56
|
+
/**
|
|
57
|
+
* Defines the aggregation expressions that will be calculated from the resulting columns on each grid cell.
|
|
58
|
+
*
|
|
59
|
+
* Example:
|
|
60
|
+
*
|
|
61
|
+
* sum(pop) as total_population, avg(rev) as average_revenue
|
|
62
|
+
*/
|
|
63
|
+
aggregationExp: string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Defines the tile aggregation resolution.
|
|
67
|
+
*
|
|
68
|
+
* @default 6 for quadbin and 4 for h3 sources
|
|
69
|
+
*/
|
|
70
|
+
aggregationResLevel?: number;
|
|
71
|
+
};
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
offset?: number;
|
|
60
|
-
limit?: number;
|
|
61
|
-
}
|
|
73
|
+
export type FilterOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* Filters to apply to the data source on the server
|
|
76
|
+
*/
|
|
77
|
+
filters?: Filters;
|
|
78
|
+
};
|
|
62
79
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
export type QuerySourceOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* The column name and the type of geospatial support.
|
|
83
|
+
*
|
|
84
|
+
* If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
85
|
+
*/
|
|
86
|
+
spatialDataColumn?: string;
|
|
87
|
+
|
|
88
|
+
/** SQL query. */
|
|
89
|
+
sqlQuery: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
93
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
94
|
+
* the quantization grid proportionately.
|
|
95
|
+
*
|
|
96
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
97
|
+
*
|
|
98
|
+
* - 0.25: 256x256
|
|
99
|
+
* - 0.5: 512x512
|
|
100
|
+
* - 1: 1024x1024
|
|
101
|
+
* - 2: 2048x2048
|
|
102
|
+
* - 4: 4096x4096
|
|
103
|
+
*/
|
|
104
|
+
tileResolution?: TileResolution;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Values for named or positional paramteres in the query.
|
|
108
|
+
*
|
|
109
|
+
* The way query parameters are determined by data warehouse.
|
|
110
|
+
*
|
|
111
|
+
* * BigQuery has named query parameters, specified with a dictionary, and referenced by key (`@key`)
|
|
112
|
+
*
|
|
113
|
+
* ```
|
|
114
|
+
* sqlQuery: "SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = @type AND revenue > @minRevenue"
|
|
115
|
+
* queryParameters: { type: 'Supermarket', minRevenue: 1000000 }
|
|
116
|
+
* ```
|
|
117
|
+
* * Snowflake supports positional parameters, in the form `:1`, `:2`, etc.
|
|
118
|
+
*
|
|
119
|
+
* ```
|
|
120
|
+
* sqlQuery: "SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1
|
|
121
|
+
* queryParameters: [100000, "Supermarket"]
|
|
122
|
+
* ```
|
|
123
|
+
* * Postgres and Redhisft supports positional parameters, but in the form `$1`, `$2`, etc.
|
|
124
|
+
*
|
|
125
|
+
* ```
|
|
126
|
+
* sqlQuery: "SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1
|
|
127
|
+
* queryParameters: [100000, "Supermarket"]
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
queryParameters?: QueryParameters;
|
|
131
|
+
};
|
|
75
132
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
133
|
+
export type TableSourceOptions = {
|
|
134
|
+
/**
|
|
135
|
+
* Fully qualified name of table.
|
|
136
|
+
*/
|
|
137
|
+
tableName: string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The column name and the type of geospatial support.
|
|
141
|
+
*
|
|
142
|
+
* If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
|
|
143
|
+
*/
|
|
144
|
+
spatialDataColumn?: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
|
|
148
|
+
* quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
|
|
149
|
+
* the quantization grid proportionately.
|
|
150
|
+
*
|
|
151
|
+
* Supported `tileResolution` values, with corresponding grid sizes:
|
|
152
|
+
*
|
|
153
|
+
* - 0.25: 256x256
|
|
154
|
+
* - 0.5: 512x512
|
|
155
|
+
* - 1: 1024x1024
|
|
156
|
+
* - 2: 2048x2048
|
|
157
|
+
* - 4: 4096x4096
|
|
158
|
+
*/
|
|
159
|
+
tileResolution?: TileResolution;
|
|
160
|
+
};
|
|
79
161
|
|
|
80
|
-
|
|
81
|
-
|
|
162
|
+
export type TilesetSourceOptions = {
|
|
163
|
+
/**
|
|
164
|
+
* Fully qualified name of tileset.
|
|
165
|
+
*/
|
|
166
|
+
tableName: string;
|
|
167
|
+
};
|
|
82
168
|
|
|
83
|
-
|
|
84
|
-
|
|
169
|
+
export type ColumnsOption = {
|
|
170
|
+
/**
|
|
171
|
+
* Columns to retrieve from the table.
|
|
172
|
+
*
|
|
173
|
+
* If not present, all columns are returned.
|
|
174
|
+
*/
|
|
175
|
+
columns?: string[];
|
|
176
|
+
};
|
|
85
177
|
|
|
86
|
-
|
|
87
|
-
export type RangeResponse = {min: number; max: number};
|
|
178
|
+
export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
|
|
88
179
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
totalCount: number;
|
|
92
|
-
rows: Record<string, number | string>[];
|
|
180
|
+
export type TilejsonMapInstantiation = MapInstantiation & {
|
|
181
|
+
tilejson: {url: string[]};
|
|
93
182
|
};
|
|
94
183
|
|
|
95
|
-
|
|
96
|
-
|
|
184
|
+
export type TileResolution = 0.25 | 0.5 | 1 | 2 | 4;
|
|
185
|
+
|
|
186
|
+
export interface Tilejson {
|
|
187
|
+
tilejson: string;
|
|
188
|
+
name: string;
|
|
189
|
+
description: string;
|
|
190
|
+
version: string;
|
|
191
|
+
attribution: string;
|
|
192
|
+
scheme: string;
|
|
193
|
+
tiles: string[];
|
|
194
|
+
properties_tiles: string[];
|
|
195
|
+
minresolution: number;
|
|
196
|
+
maxresolution: number;
|
|
197
|
+
minzoom: number;
|
|
198
|
+
maxzoom: number;
|
|
199
|
+
bounds: [number, number, number, number];
|
|
200
|
+
center: [number, number, number];
|
|
201
|
+
vector_layers: VectorLayer[];
|
|
202
|
+
tilestats: Tilestats;
|
|
203
|
+
tileResolution?: TileResolution;
|
|
204
|
+
}
|
|
97
205
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
206
|
+
export interface Tilestats {
|
|
207
|
+
layerCount: number;
|
|
208
|
+
layers: Layer[];
|
|
209
|
+
}
|
|
103
210
|
|
|
104
|
-
|
|
105
|
-
|
|
211
|
+
export interface Layer {
|
|
212
|
+
layer: string;
|
|
213
|
+
count: number;
|
|
214
|
+
attributeCount: number;
|
|
215
|
+
attributes: Attribute[];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface Attribute {
|
|
219
|
+
attribute: string;
|
|
220
|
+
type: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface VectorLayer {
|
|
224
|
+
id: string;
|
|
225
|
+
minzoom: number;
|
|
226
|
+
maxzoom: number;
|
|
227
|
+
fields: Record<string, string>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type TilejsonResult = Tilejson & {accessToken: string};
|
|
231
|
+
export type GeojsonResult = {type: 'FeatureCollection'; features: Feature[]};
|
|
232
|
+
export type JsonResult = any[];
|
|
233
|
+
export type QueryResult = {
|
|
234
|
+
meta: {cacheHit: boolean; location: string; totalBytesProcessed: string};
|
|
235
|
+
rows: Record<string, any>[];
|
|
236
|
+
schema: {name: string; type: string}[];
|
|
237
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/* eslint-disable camelcase */
|
|
6
|
+
import {DEFAULT_TILE_RESOLUTION} from '../constants.js';
|
|
7
|
+
import {baseSource} from './base-source';
|
|
8
|
+
import type {
|
|
9
|
+
FilterOptions,
|
|
10
|
+
SourceOptions,
|
|
11
|
+
QuerySourceOptions,
|
|
12
|
+
SpatialDataType,
|
|
13
|
+
TilejsonResult,
|
|
14
|
+
ColumnsOption,
|
|
15
|
+
} from './types';
|
|
16
|
+
|
|
17
|
+
export type VectorQuerySourceOptions = SourceOptions &
|
|
18
|
+
QuerySourceOptions &
|
|
19
|
+
FilterOptions &
|
|
20
|
+
ColumnsOption;
|
|
21
|
+
|
|
22
|
+
type UrlParameters = {
|
|
23
|
+
columns?: string;
|
|
24
|
+
filters?: Record<string, unknown>;
|
|
25
|
+
spatialDataType: SpatialDataType;
|
|
26
|
+
spatialDataColumn?: string;
|
|
27
|
+
tileResolution?: string;
|
|
28
|
+
q: string;
|
|
29
|
+
queryParameters?: Record<string, unknown> | unknown[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const vectorQuerySource = async function (
|
|
33
|
+
options: VectorQuerySourceOptions
|
|
34
|
+
): Promise<TilejsonResult> {
|
|
35
|
+
const {
|
|
36
|
+
columns,
|
|
37
|
+
filters,
|
|
38
|
+
spatialDataColumn = 'geom',
|
|
39
|
+
sqlQuery,
|
|
40
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
41
|
+
queryParameters,
|
|
42
|
+
} = options;
|
|
43
|
+
|
|
44
|
+
const urlParameters: UrlParameters = {
|
|
45
|
+
spatialDataColumn,
|
|
46
|
+
spatialDataType: 'geo',
|
|
47
|
+
tileResolution: tileResolution.toString(),
|
|
48
|
+
q: sqlQuery,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (columns) {
|
|
52
|
+
urlParameters.columns = columns.join(',');
|
|
53
|
+
}
|
|
54
|
+
if (filters) {
|
|
55
|
+
urlParameters.filters = filters;
|
|
56
|
+
}
|
|
57
|
+
if (queryParameters) {
|
|
58
|
+
urlParameters.queryParameters = queryParameters;
|
|
59
|
+
}
|
|
60
|
+
return baseSource<UrlParameters>(
|
|
61
|
+
'query',
|
|
62
|
+
options,
|
|
63
|
+
urlParameters
|
|
64
|
+
) as Promise<TilejsonResult>;
|
|
65
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/* eslint-disable camelcase */
|
|
6
|
+
import {DEFAULT_TILE_RESOLUTION} from '../constants.js';
|
|
7
|
+
import {baseSource} from './base-source';
|
|
8
|
+
import type {
|
|
9
|
+
FilterOptions,
|
|
10
|
+
ColumnsOption,
|
|
11
|
+
SourceOptions,
|
|
12
|
+
SpatialDataType,
|
|
13
|
+
TableSourceOptions,
|
|
14
|
+
TilejsonResult,
|
|
15
|
+
} from './types';
|
|
16
|
+
|
|
17
|
+
export type VectorTableSourceOptions = SourceOptions &
|
|
18
|
+
TableSourceOptions &
|
|
19
|
+
FilterOptions &
|
|
20
|
+
ColumnsOption;
|
|
21
|
+
type UrlParameters = {
|
|
22
|
+
columns?: string;
|
|
23
|
+
filters?: Record<string, unknown>;
|
|
24
|
+
spatialDataType: SpatialDataType;
|
|
25
|
+
spatialDataColumn?: string;
|
|
26
|
+
tileResolution?: string;
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const vectorTableSource = async function (
|
|
31
|
+
options: VectorTableSourceOptions
|
|
32
|
+
): Promise<TilejsonResult> {
|
|
33
|
+
const {
|
|
34
|
+
columns,
|
|
35
|
+
filters,
|
|
36
|
+
spatialDataColumn = 'geom',
|
|
37
|
+
tableName,
|
|
38
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
39
|
+
} = options;
|
|
40
|
+
|
|
41
|
+
const urlParameters: UrlParameters = {
|
|
42
|
+
name: tableName,
|
|
43
|
+
spatialDataColumn,
|
|
44
|
+
spatialDataType: 'geo',
|
|
45
|
+
tileResolution: tileResolution.toString(),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (columns) {
|
|
49
|
+
urlParameters.columns = columns.join(',');
|
|
50
|
+
}
|
|
51
|
+
if (filters) {
|
|
52
|
+
urlParameters.filters = filters;
|
|
53
|
+
}
|
|
54
|
+
return baseSource<UrlParameters>(
|
|
55
|
+
'table',
|
|
56
|
+
options,
|
|
57
|
+
urlParameters
|
|
58
|
+
) as Promise<TilejsonResult>;
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {baseSource} from './base-source';
|
|
6
|
+
import type {
|
|
7
|
+
SourceOptions,
|
|
8
|
+
TilesetSourceOptions,
|
|
9
|
+
TilejsonResult,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
13
|
+
type UrlParameters = {name: string};
|
|
14
|
+
|
|
15
|
+
export const vectorTilesetSource = async function (
|
|
16
|
+
options: VectorTilesetSourceOptions
|
|
17
|
+
): Promise<TilejsonResult> {
|
|
18
|
+
const {tableName} = options;
|
|
19
|
+
const urlParameters: UrlParameters = {name: tableName};
|
|
20
|
+
|
|
21
|
+
return baseSource<UrlParameters>(
|
|
22
|
+
'tileset',
|
|
23
|
+
options,
|
|
24
|
+
urlParameters
|
|
25
|
+
) as Promise<TilejsonResult>;
|
|
26
|
+
};
|
package/src/types-internal.ts
CHANGED
|
@@ -1,9 +1,62 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
|
-
*
|
|
2
|
+
* COMMON
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import {Format} from './types';
|
|
6
|
+
|
|
5
7
|
/** @internal */
|
|
6
8
|
export type $TODO = any;
|
|
7
9
|
|
|
8
10
|
/** @internal */
|
|
9
11
|
export type $IntentionalAny = any;
|
|
12
|
+
|
|
13
|
+
/******************************************************************************
|
|
14
|
+
* MAP INSTANTIATION
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export enum SchemaFieldType {
|
|
22
|
+
Number = 'number',
|
|
23
|
+
Bigint = 'bigint',
|
|
24
|
+
String = 'string',
|
|
25
|
+
Geometry = 'geometry',
|
|
26
|
+
Timestamp = 'timestamp',
|
|
27
|
+
Object = 'object',
|
|
28
|
+
Boolean = 'boolean',
|
|
29
|
+
Variant = 'variant',
|
|
30
|
+
Unknown = 'unknown',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export interface SchemaField {
|
|
38
|
+
name: string;
|
|
39
|
+
type: SchemaFieldType; // Field type in the CARTO stack, common for all providers
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export interface MapInstantiation extends MapInstantiationFormats {
|
|
47
|
+
nrows: number;
|
|
48
|
+
size?: number;
|
|
49
|
+
schema: SchemaField[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
type MapInstantiationFormats = Record<
|
|
57
|
+
Format,
|
|
58
|
+
{
|
|
59
|
+
url: string[];
|
|
60
|
+
error?: any;
|
|
61
|
+
}
|
|
62
|
+
>;
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type {FilterType} from './constants.js';
|
|
2
2
|
import type {Polygon, MultiPolygon} from 'geojson';
|
|
3
3
|
|
|
4
|
+
/******************************************************************************
|
|
5
|
+
* MAPS AND TILES
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
9
|
+
export type Format = 'json' | 'geojson' | 'tilejson';
|
|
10
|
+
|
|
11
|
+
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
12
|
+
export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
|
|
13
|
+
|
|
4
14
|
/******************************************************************************
|
|
5
15
|
* AGGREGATION
|
|
6
16
|
*/
|
|
@@ -26,6 +36,12 @@ export type AggregationType =
|
|
|
26
36
|
/** @internalRemarks Source: @carto/react-api */
|
|
27
37
|
export type SpatialFilter = Polygon | MultiPolygon;
|
|
28
38
|
|
|
39
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
40
|
+
export interface Filters {
|
|
41
|
+
[column: string]: Filter;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// TODO: Would `{[FilterType.IN]?: number[] | string[]}` also be valid?
|
|
29
45
|
/** @internalRemarks Source: @carto/react-api, @deck.gl/carto */
|
|
30
46
|
export interface Filter {
|
|
31
47
|
[FilterType.IN]?: {owner?: string; values: number[] | string[]};
|
package/src/utils.ts
CHANGED
|
@@ -90,3 +90,11 @@ export function isEmptyObject(object: object): boolean {
|
|
|
90
90
|
}
|
|
91
91
|
return true;
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
/** @internal */
|
|
95
|
+
export const isObject: (x: unknown) => boolean = (x) =>
|
|
96
|
+
x !== null && typeof x === 'object';
|
|
97
|
+
|
|
98
|
+
/** @internal */
|
|
99
|
+
export const isPureObject: (x: any) => boolean = (x) =>
|
|
100
|
+
isObject(x) && x.constructor === {}.constructor;
|