@carto/api-client 0.4.0-alpha.0 → 0.4.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/build/api/carto-api-error.d.ts +9 -1
  2. package/build/api/endpoints.d.ts +3 -1
  3. package/build/api/index.d.ts +5 -4
  4. package/build/api/request-with-parameters.d.ts +1 -1
  5. package/build/api-client.cjs +293 -158
  6. package/build/api-client.cjs.map +1 -1
  7. package/build/api-client.modern.js +243 -126
  8. package/build/api-client.modern.js.map +1 -1
  9. package/build/constants-internal.d.ts +9 -28
  10. package/build/constants.d.ts +24 -10
  11. package/build/index.d.ts +4 -5
  12. package/build/models/model.d.ts +2 -2
  13. package/build/sources/base-source.d.ts +1 -1
  14. package/build/sources/boundary-query-source.d.ts +1 -1
  15. package/build/sources/h3-query-source.d.ts +2 -1
  16. package/build/sources/h3-table-source.d.ts +2 -1
  17. package/build/sources/index.d.ts +1 -1
  18. package/build/sources/quadbin-query-source.d.ts +2 -1
  19. package/build/sources/quadbin-table-source.d.ts +2 -1
  20. package/build/sources/types.d.ts +2 -1
  21. package/build/sources/vector-query-source.d.ts +2 -1
  22. package/build/sources/vector-table-source.d.ts +2 -1
  23. package/build/types-internal.d.ts +46 -1
  24. package/build/types.d.ts +11 -0
  25. package/build/widget-sources/index.d.ts +0 -1
  26. package/build/widget-sources/widget-base-source.d.ts +1 -1
  27. package/build/widget-sources/widget-query-source.d.ts +3 -0
  28. package/build/widget-sources/widget-table-source.d.ts +3 -0
  29. package/package.json +2 -2
  30. package/src/api/carto-api-error.ts +17 -1
  31. package/src/api/endpoints.ts +3 -1
  32. package/src/api/index.ts +9 -12
  33. package/src/api/query.ts +1 -1
  34. package/src/api/request-with-parameters.ts +4 -8
  35. package/src/constants-internal.ts +9 -30
  36. package/src/constants.ts +32 -16
  37. package/src/index.ts +43 -5
  38. package/src/models/model.ts +4 -6
  39. package/src/sources/base-source.ts +2 -1
  40. package/src/sources/boundary-query-source.ts +1 -1
  41. package/src/sources/h3-query-source.ts +9 -7
  42. package/src/sources/h3-table-source.ts +9 -7
  43. package/src/sources/index.ts +6 -1
  44. package/src/sources/quadbin-query-source.ts +9 -7
  45. package/src/sources/quadbin-table-source.ts +9 -7
  46. package/src/sources/types.ts +2 -6
  47. package/src/sources/vector-query-source.ts +12 -7
  48. package/src/sources/vector-table-source.ts +12 -7
  49. package/src/types-internal.ts +54 -1
  50. package/src/types.ts +16 -0
  51. package/src/widget-sources/index.ts +0 -1
  52. package/src/widget-sources/widget-base-source.ts +5 -5
  53. package/src/widget-sources/widget-query-source.ts +3 -2
  54. package/src/widget-sources/widget-table-source.ts +3 -2
  55. package/build/api/types.d.ts +0 -227
  56. package/build/widget-sources/wrappers.d.ts +0 -48
  57. package/src/api/types.ts +0 -301
  58. package/src/widget-sources/wrappers.ts +0 -121
package/src/api/types.ts DELETED
@@ -1,301 +0,0 @@
1
- // deck.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- export type Format = 'json' | 'geojson' | 'tilejson';
6
- export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
7
- export type RequestType =
8
- | 'Map data'
9
- | 'Map instantiation'
10
- | 'Public map'
11
- | 'Tile stats'
12
- | 'SQL'
13
- | 'Basemap style';
14
- export type ScaleType =
15
- | 'linear'
16
- | 'ordinal'
17
- | 'log'
18
- | 'point'
19
- | 'quantile'
20
- | 'quantize'
21
- | 'sqrt'
22
- | 'custom'
23
- | 'identity';
24
-
25
- export type APIErrorContext = {
26
- requestType: RequestType;
27
- mapId?: string;
28
- connection?: string;
29
- source?: string;
30
- type?: MapType;
31
- };
32
-
33
- export enum SchemaFieldType {
34
- Number = 'number',
35
- Bigint = 'bigint',
36
- String = 'string',
37
- Geometry = 'geometry',
38
- Timestamp = 'timestamp',
39
- Object = 'object',
40
- Boolean = 'boolean',
41
- Variant = 'variant',
42
- Unknown = 'unknown',
43
- }
44
- export interface SchemaField {
45
- name: string;
46
- type: SchemaFieldType; // Field type in the CARTO stack, common for all providers
47
- }
48
-
49
- export interface MapInstantiation extends MapInstantiationFormats {
50
- nrows: number;
51
- size?: number;
52
- schema: SchemaField[];
53
- }
54
-
55
- type MapInstantiationFormats = Record<
56
- Format,
57
- {
58
- url: string[];
59
- error?: any;
60
- }
61
- >;
62
-
63
- export type QueryParameterValue =
64
- | string
65
- | number
66
- | boolean
67
- | Array<QueryParameterValue>
68
- | object;
69
-
70
- export type NamedQueryParameter = Record<string, QueryParameterValue>;
71
-
72
- export type PositionalQueryParameter = QueryParameterValue[];
73
-
74
- export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
75
- export type VisualChannelField = {
76
- name: string;
77
- type: string;
78
- colorColumn?: string;
79
- };
80
-
81
- export interface Filters {
82
- [column: string]: Filter;
83
- }
84
-
85
- interface Filter {
86
- [FilterTypes.In]?: number[];
87
- [FilterTypes.Between]?: number[][];
88
- [FilterTypes.ClosedOpen]?: number[][];
89
- [FilterTypes.Time]?: number[][];
90
- [FilterTypes.StringSearch]?: string[];
91
- }
92
-
93
- export enum FilterTypes {
94
- In = 'in',
95
- Between = 'between', // [a, b] both are included
96
- ClosedOpen = 'closed_open', // [a, b) a is included, b is not
97
- Time = 'time',
98
- StringSearch = 'stringSearch',
99
- }
100
-
101
- export type VisualChannels = {
102
- colorField?: VisualChannelField;
103
- colorScale?: ScaleType;
104
-
105
- customMarkersField?: VisualChannelField;
106
- customMarkersScale?: ScaleType;
107
-
108
- radiusField?: VisualChannelField;
109
- radiusScale?: ScaleType;
110
-
111
- rotationScale?: ScaleType;
112
- rotationField?: VisualChannelField;
113
-
114
- sizeField?: VisualChannelField;
115
- sizeScale?: ScaleType;
116
-
117
- strokeColorField?: VisualChannelField;
118
- strokeColorScale?: ScaleType;
119
-
120
- heightField?: VisualChannelField;
121
- heightScale?: ScaleType;
122
-
123
- weightField?: VisualChannelField;
124
- };
125
-
126
- export type ColorRange = {
127
- category: string;
128
- colors: string[];
129
- colorMap: string[][] | undefined;
130
- name: string;
131
- type: string;
132
- };
133
-
134
- export type CustomMarkersRange = {
135
- markerMap: {
136
- value: string;
137
- markerUrl?: string;
138
- }[];
139
- othersMarker?: string;
140
- };
141
-
142
- export type VisConfig = {
143
- filled?: boolean;
144
- opacity?: number;
145
- enable3d?: boolean;
146
-
147
- colorAggregation?: any;
148
- colorRange: ColorRange;
149
-
150
- customMarkers?: boolean;
151
- customMarkersRange?: CustomMarkersRange | null;
152
- customMarkersUrl?: string | null;
153
-
154
- radius: number;
155
- radiusRange?: number[];
156
-
157
- sizeAggregation?: any;
158
- sizeRange?: any;
159
-
160
- strokeColorAggregation?: any;
161
- strokeOpacity?: number;
162
- strokeColorRange?: ColorRange;
163
-
164
- heightRange?: any;
165
- heightAggregation?: any;
166
-
167
- weightAggregation?: any;
168
- };
169
-
170
- export type TextLabel = {
171
- field: VisualChannelField | null | undefined;
172
- alignment?: 'center' | 'bottom' | 'top';
173
- anchor?: 'middle' | 'start' | 'end';
174
- size: number;
175
- color?: number[];
176
- offset?: [number, number];
177
- outlineColor?: number[];
178
- };
179
-
180
- export type MapLayerConfig = {
181
- columns?: Record<string, any>;
182
- color?: number[];
183
- label?: string;
184
- dataId: string;
185
- textLabel: TextLabel[];
186
- visConfig: VisConfig;
187
- };
188
-
189
- export type MapTextSubLayerConfig = Omit<MapLayerConfig, 'textLabel'> & {
190
- textLabel?: TextLabel;
191
- };
192
-
193
- export type MapConfigLayer = {
194
- type: string;
195
- id: string;
196
- config: MapLayerConfig;
197
- visualChannels: VisualChannels;
198
- };
199
-
200
- export type MapDataset = {
201
- id: string;
202
- data: any;
203
- aggregationExp: string | null;
204
- aggregationResLevel: number | null;
205
- geoColumn: string;
206
- };
207
-
208
- export interface CustomStyle {
209
- url?: string;
210
- style?: any;
211
- customAttribution?: string;
212
- }
213
-
214
- export type KeplerMapConfig = {
215
- mapState: any;
216
- mapStyle: {
217
- styleType: string;
218
- visibleLayerGroups: Record<string, boolean>;
219
- };
220
- visState: {
221
- layers: MapConfigLayer[];
222
- };
223
- layerBlending: any;
224
- interactionConfig: any;
225
- customBaseMaps?: {
226
- customStyle?: CustomStyle;
227
- };
228
- };
229
-
230
- export type BasemapType = 'maplibre' | 'google-maps';
231
-
232
- export type Basemap = MapLibreBasemap | GoogleBasemap;
233
-
234
- export type BasemapCommon = {
235
- /**
236
- * Type of basemap.
237
- */
238
- type: BasemapType;
239
-
240
- /**
241
- * Custom attribution for style data if not provided by style definition.
242
- */
243
- attribution?: string;
244
-
245
- /**
246
- * Properties of the basemap. These properties are specific to the basemap type.
247
- */
248
- props: Record<string, any>;
249
- };
250
-
251
- export type MapLibreBasemap = BasemapCommon & {
252
- type: 'maplibre';
253
-
254
- /**
255
- * MapLibre map properties.
256
- *
257
- * Meant to be passed to directly to `maplibregl.Map` object.
258
- */
259
- props: MapLibreBasemapProps;
260
-
261
- /**
262
- * Layer groups to be displayed in the basemap.
263
- */
264
- visibleLayerGroups?: Record<string, boolean>;
265
-
266
- /**
267
- * If `style` has been filtered by `visibleLayerGroups` then this property contains original style object, so user
268
- * can use `applyLayerGroupFilters` again with new settings.
269
- */
270
- rawStyle?: string | Record<string, any>;
271
- };
272
-
273
- // Cherry-pick of maplibregl Map API props that are supported/provided by fetchMap interface
274
- export type MapLibreBasemapProps = {
275
- style: string | Record<string, any>;
276
- center: [number, number];
277
- zoom: number;
278
- pitch?: number;
279
- bearing?: number;
280
- };
281
-
282
- export type GoogleBasemap = BasemapCommon & {
283
- type: 'google-maps';
284
-
285
- /**
286
- * Google map properties.
287
- *
288
- * Meant to be passed to directly to `google.maps.Map` object.
289
- */
290
- props: GoogleBasemapProps;
291
- };
292
-
293
- // Cherry-pick of Google Map API props that are supported/provided by fetchMap interface
294
- export type GoogleBasemapProps = {
295
- mapTypeId: string;
296
- mapId?: string;
297
- center?: {lat: number; lng: number};
298
- zoom?: number;
299
- tilt?: number;
300
- heading?: number;
301
- };
@@ -1,121 +0,0 @@
1
- import {
2
- h3TableSource as _h3TableSource,
3
- h3QuerySource as _h3QuerySource,
4
- vectorTableSource as _vectorTableSource,
5
- vectorQuerySource as _vectorQuerySource,
6
- quadbinTableSource as _quadbinTableSource,
7
- quadbinQuerySource as _quadbinQuerySource,
8
- VectorTableSourceOptions as _VectorTableSourceOptions,
9
- VectorQuerySourceOptions as _VectorQuerySourceOptions,
10
- H3TableSourceOptions as _H3TableSourceOptions,
11
- H3QuerySourceOptions as _H3QuerySourceOptions,
12
- QuadbinTableSourceOptions as _QuadbinTableSourceOptions,
13
- QuadbinQuerySourceOptions as _QuadbinQuerySourceOptions,
14
- SourceOptions,
15
- } from '../sources/index.js';
16
- import {WidgetBaseSourceProps} from './widget-base-source.js';
17
- import {WidgetQuerySource} from './widget-query-source.js';
18
- import {WidgetTableSource} from './widget-table-source.js';
19
-
20
- type WrappedSourceOptions<T> = Omit<T, 'filters'> & WidgetBaseSourceProps;
21
-
22
- /******************************************************************************
23
- * RESPONSE OBJECTS
24
- */
25
-
26
- type WidgetTableSourceResponse = {widgetSource: WidgetTableSource};
27
- type WidgetQuerySourceResponse = {widgetSource: WidgetQuerySource};
28
-
29
- export type VectorTableSourceResponse = WidgetTableSourceResponse &
30
- Awaited<ReturnType<typeof _vectorTableSource>>;
31
- export type VectorQuerySourceResponse = WidgetQuerySourceResponse &
32
- Awaited<ReturnType<typeof _vectorQuerySource>>;
33
-
34
- export type H3TableSourceResponse = WidgetTableSourceResponse &
35
- Awaited<ReturnType<typeof _h3TableSource>>;
36
- export type H3QuerySourceResponse = WidgetQuerySourceResponse &
37
- Awaited<ReturnType<typeof _h3QuerySource>>;
38
-
39
- export type QuadbinTableSourceResponse = WidgetTableSourceResponse &
40
- Awaited<ReturnType<typeof _quadbinTableSource>>;
41
- export type QuadbinQuerySourceResponse = WidgetQuerySourceResponse &
42
- Awaited<ReturnType<typeof _quadbinQuerySource>>;
43
-
44
- /******************************************************************************
45
- * VECTOR SOURCES
46
- */
47
-
48
- export type VectorTableSourceOptions =
49
- WrappedSourceOptions<_VectorTableSourceOptions>;
50
-
51
- export type VectorQuerySourceOptions =
52
- WrappedSourceOptions<_VectorQuerySourceOptions>;
53
-
54
- /** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
55
- export async function vectorTableSource(
56
- props: VectorTableSourceOptions
57
- ): Promise<VectorTableSourceResponse> {
58
- const response = await _vectorTableSource(props as _VectorTableSourceOptions);
59
- return {...response, widgetSource: new WidgetTableSource(props)};
60
- }
61
-
62
- /** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
63
- export async function vectorQuerySource(
64
- props: VectorQuerySourceOptions
65
- ): Promise<VectorQuerySourceResponse> {
66
- const response = await _vectorQuerySource(props as _VectorQuerySourceOptions);
67
- return {...response, widgetSource: new WidgetQuerySource(props)};
68
- }
69
-
70
- /******************************************************************************
71
- * H3 SOURCES
72
- */
73
-
74
- export type H3TableSourceOptions = WrappedSourceOptions<_H3TableSourceOptions>;
75
- export type H3QuerySourceOptions = WrappedSourceOptions<_H3QuerySourceOptions>;
76
-
77
- /** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
78
- export async function h3TableSource(
79
- props: H3TableSourceOptions
80
- ): Promise<H3TableSourceResponse> {
81
- const response = await _h3TableSource(props as _H3TableSourceOptions);
82
- return {...response, widgetSource: new WidgetTableSource(props)};
83
- }
84
-
85
- /** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
86
- export async function h3QuerySource(
87
- props: H3QuerySourceOptions
88
- ): Promise<H3QuerySourceResponse> {
89
- const response = await _h3QuerySource(props as _H3QuerySourceOptions);
90
- return {...response, widgetSource: new WidgetQuerySource(props)};
91
- }
92
-
93
- /******************************************************************************
94
- * QUADBIN SOURCES
95
- */
96
-
97
- export type QuadbinTableSourceOptions =
98
- WrappedSourceOptions<_QuadbinTableSourceOptions>;
99
-
100
- export type QuadbinQuerySourceOptions =
101
- WrappedSourceOptions<_QuadbinQuerySourceOptions>;
102
-
103
- /** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
104
- export async function quadbinTableSource(
105
- props: QuadbinTableSourceOptions & WidgetBaseSourceProps
106
- ): Promise<QuadbinTableSourceResponse> {
107
- const response = await _quadbinTableSource(
108
- props as _QuadbinTableSourceOptions
109
- );
110
- return {...response, widgetSource: new WidgetTableSource(props)};
111
- }
112
-
113
- /** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
114
- export async function quadbinQuerySource(
115
- props: QuadbinQuerySourceOptions & WidgetBaseSourceProps
116
- ): Promise<QuadbinQuerySourceResponse> {
117
- const response = await _quadbinQuerySource(
118
- props as _QuadbinQuerySourceOptions
119
- );
120
- return {...response, widgetSource: new WidgetQuerySource(props)};
121
- }