@carto/api-client 0.0.1-1 → 0.0.30
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 +113 -0
- package/build/api-client.cjs +344 -206
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +337 -203
- package/build/api-client.modern.js.map +1 -1
- package/build/client.d.ts +12 -2
- package/build/constants-internal.d.ts +23 -5
- package/build/constants.d.ts +19 -15
- package/build/index.d.ts +0 -1
- package/build/models/common.d.ts +2 -5
- package/build/models/model.d.ts +18 -4
- package/build/sources/types.d.ts +30 -14
- package/build/sources/widget-base-source.d.ts +77 -22
- package/build/sources/widget-query-source.d.ts +25 -3
- package/build/sources/widget-table-source.d.ts +25 -3
- package/build/sources/wrappers.d.ts +21 -14
- package/build/types.d.ts +14 -28
- package/package.json +3 -5
- package/src/client.ts +14 -6
- package/src/constants-internal.ts +26 -5
- package/src/constants.ts +19 -18
- package/src/index.ts +0 -1
- package/src/models/common.ts +8 -18
- package/src/models/model.ts +44 -27
- package/src/sources/types.ts +32 -16
- package/src/sources/widget-base-source.ts +173 -113
- package/src/sources/widget-query-source.ts +30 -7
- package/src/sources/widget-table-source.ts +29 -7
- package/src/sources/wrappers.ts +38 -21
- package/src/types.ts +24 -32
|
@@ -4,20 +4,42 @@ import {
|
|
|
4
4
|
VectorTableSourceOptions,
|
|
5
5
|
} from '@deck.gl/carto';
|
|
6
6
|
import {WidgetBaseSource, WidgetBaseSourceProps} from './widget-base-source.js';
|
|
7
|
-
import {MapType} from '../constants.js';
|
|
8
|
-
import {
|
|
7
|
+
import {MapType} from '../constants-internal.js';
|
|
8
|
+
import {ModelSource} from '../models/model.js';
|
|
9
9
|
|
|
10
10
|
type LayerTableSourceOptions =
|
|
11
|
-
| VectorTableSourceOptions
|
|
12
|
-
| H3TableSourceOptions
|
|
13
|
-
| QuadbinTableSourceOptions
|
|
11
|
+
| Omit<VectorTableSourceOptions, 'filters'>
|
|
12
|
+
| Omit<H3TableSourceOptions, 'filters'>
|
|
13
|
+
| Omit<QuadbinTableSourceOptions, 'filters'>;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Source for Widget API requests on a data source defined as a table.
|
|
17
|
+
*
|
|
18
|
+
* Generally not intended to be constructed directly. Instead, call
|
|
19
|
+
* {@link vectorTableSource}, {@link h3TableSource}, or {@link quadbinTableSource},
|
|
20
|
+
* which can be shared with map layers. Sources contain a `widgetSource` property,
|
|
21
|
+
* for use by widget implementations.
|
|
22
|
+
*
|
|
23
|
+
* Example:
|
|
24
|
+
*
|
|
25
|
+
* ```javascript
|
|
26
|
+
* import { vectorTableSource } from '@carto/api-client';
|
|
27
|
+
*
|
|
28
|
+
* const data = vectorTableSource({
|
|
29
|
+
* accessToken: '••••',
|
|
30
|
+
* connectionName: 'carto_dw',
|
|
31
|
+
* tableName: 'carto-demo-data.demo_tables.retail_stores'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const { widgetSource } = await data;
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
15
37
|
export class WidgetTableSource extends WidgetBaseSource<
|
|
16
38
|
LayerTableSourceOptions & WidgetBaseSourceProps
|
|
17
39
|
> {
|
|
18
|
-
protected override
|
|
40
|
+
protected override getModelSource(owner: string): ModelSource {
|
|
19
41
|
return {
|
|
20
|
-
...super.
|
|
42
|
+
...super._getModelSource(owner),
|
|
21
43
|
type: MapType.TABLE,
|
|
22
44
|
data: this.props.tableName,
|
|
23
45
|
};
|
package/src/sources/wrappers.ts
CHANGED
|
@@ -5,17 +5,19 @@ import {
|
|
|
5
5
|
vectorQuerySource as _vectorQuerySource,
|
|
6
6
|
quadbinTableSource as _quadbinTableSource,
|
|
7
7
|
quadbinQuerySource as _quadbinQuerySource,
|
|
8
|
-
VectorTableSourceOptions,
|
|
9
|
-
VectorQuerySourceOptions,
|
|
10
|
-
H3TableSourceOptions,
|
|
11
|
-
H3QuerySourceOptions,
|
|
12
|
-
|
|
13
|
-
|
|
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
14
|
} from '@deck.gl/carto';
|
|
15
15
|
import {WidgetBaseSourceProps} from './widget-base-source.js';
|
|
16
16
|
import {WidgetQuerySource} from './widget-query-source.js';
|
|
17
17
|
import {WidgetTableSource} from './widget-table-source.js';
|
|
18
18
|
|
|
19
|
+
type WrappedSourceOptions<T> = Omit<T, 'filters'> & WidgetBaseSourceProps;
|
|
20
|
+
|
|
19
21
|
/******************************************************************************
|
|
20
22
|
* RESPONSE OBJECTS
|
|
21
23
|
*/
|
|
@@ -42,23 +44,29 @@ export type QuadbinQuerySourceResponse = WidgetQuerySourceResponse &
|
|
|
42
44
|
* VECTOR SOURCES
|
|
43
45
|
*/
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
export type VectorTableSourceOptions =
|
|
48
|
+
WrappedSourceOptions<_VectorTableSourceOptions>;
|
|
49
|
+
|
|
50
|
+
export type VectorQuerySourceOptions =
|
|
51
|
+
WrappedSourceOptions<_VectorQuerySourceOptions>;
|
|
52
|
+
|
|
53
|
+
/** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
46
54
|
export async function vectorTableSource(
|
|
47
|
-
props: VectorTableSourceOptions
|
|
55
|
+
props: VectorTableSourceOptions
|
|
48
56
|
): Promise<VectorTableSourceResponse> {
|
|
49
|
-
const response = await _vectorTableSource(props);
|
|
57
|
+
const response = await _vectorTableSource(props as _VectorTableSourceOptions);
|
|
50
58
|
return {...response, widgetSource: new WidgetTableSource(props)};
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
/** Wrapper adding
|
|
61
|
+
/** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
54
62
|
export async function vectorQuerySource(
|
|
55
|
-
props: VectorQuerySourceOptions
|
|
63
|
+
props: VectorQuerySourceOptions
|
|
56
64
|
): Promise<VectorQuerySourceResponse> {
|
|
57
|
-
const response = await _vectorQuerySource(props);
|
|
65
|
+
const response = await _vectorQuerySource(props as _VectorQuerySourceOptions);
|
|
58
66
|
return {...response, widgetSource: new WidgetQuerySource(props)};
|
|
59
67
|
}
|
|
60
68
|
|
|
61
|
-
/** Wrapper adding
|
|
69
|
+
/** Wrapper adding Widget API support to [vectorTilesetSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
62
70
|
export async function vectorTilesetSource() {
|
|
63
71
|
throw new Error('not implemented');
|
|
64
72
|
}
|
|
@@ -67,23 +75,26 @@ export async function vectorTilesetSource() {
|
|
|
67
75
|
* H3 SOURCES
|
|
68
76
|
*/
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
export type H3TableSourceOptions = WrappedSourceOptions<_H3TableSourceOptions>;
|
|
79
|
+
export type H3QuerySourceOptions = WrappedSourceOptions<_H3QuerySourceOptions>;
|
|
80
|
+
|
|
81
|
+
/** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
71
82
|
export async function h3TableSource(
|
|
72
|
-
props: H3TableSourceOptions
|
|
83
|
+
props: H3TableSourceOptions
|
|
73
84
|
): Promise<H3TableSourceResponse> {
|
|
74
85
|
const response = await _h3TableSource(props);
|
|
75
86
|
return {...response, widgetSource: new WidgetTableSource(props)};
|
|
76
87
|
}
|
|
77
88
|
|
|
78
|
-
/** Wrapper adding
|
|
89
|
+
/** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
79
90
|
export async function h3QuerySource(
|
|
80
|
-
props: H3QuerySourceOptions
|
|
91
|
+
props: H3QuerySourceOptions
|
|
81
92
|
): Promise<H3QuerySourceResponse> {
|
|
82
93
|
const response = await _h3QuerySource(props);
|
|
83
94
|
return {...response, widgetSource: new WidgetQuerySource(props)};
|
|
84
95
|
}
|
|
85
96
|
|
|
86
|
-
/** Wrapper adding
|
|
97
|
+
/** Wrapper adding Widget API support to [h3TilesetSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
87
98
|
export async function h3TilesetSource() {
|
|
88
99
|
throw new Error('not implemented');
|
|
89
100
|
}
|
|
@@ -92,7 +103,13 @@ export async function h3TilesetSource() {
|
|
|
92
103
|
* QUADBIN SOURCES
|
|
93
104
|
*/
|
|
94
105
|
|
|
95
|
-
|
|
106
|
+
export type QuadbinTableSourceOptions =
|
|
107
|
+
WrappedSourceOptions<_QuadbinTableSourceOptions>;
|
|
108
|
+
|
|
109
|
+
export type QuadbinQuerySourceOptions =
|
|
110
|
+
WrappedSourceOptions<_QuadbinQuerySourceOptions>;
|
|
111
|
+
|
|
112
|
+
/** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
96
113
|
export async function quadbinTableSource(
|
|
97
114
|
props: QuadbinTableSourceOptions & WidgetBaseSourceProps
|
|
98
115
|
): Promise<QuadbinTableSourceResponse> {
|
|
@@ -100,7 +117,7 @@ export async function quadbinTableSource(
|
|
|
100
117
|
return {...response, widgetSource: new WidgetTableSource(props)};
|
|
101
118
|
}
|
|
102
119
|
|
|
103
|
-
/** Wrapper adding
|
|
120
|
+
/** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
104
121
|
export async function quadbinQuerySource(
|
|
105
122
|
props: QuadbinQuerySourceOptions & WidgetBaseSourceProps
|
|
106
123
|
): Promise<QuadbinQuerySourceResponse> {
|
|
@@ -108,7 +125,7 @@ export async function quadbinQuerySource(
|
|
|
108
125
|
return {...response, widgetSource: new WidgetQuerySource(props)};
|
|
109
126
|
}
|
|
110
127
|
|
|
111
|
-
/** Wrapper adding
|
|
128
|
+
/** Wrapper adding Widget API support to [quadbinTilesetSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
112
129
|
export async function quadbinTilesetSource() {
|
|
113
130
|
throw new Error('not implemented');
|
|
114
131
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
/******************************************************************************
|
|
4
|
-
* AUTHENTICATION
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** @internalRemarks Source: @carto/react-api */
|
|
8
|
-
export type Credentials = {
|
|
9
|
-
apiVersion?: ApiVersion;
|
|
10
|
-
apiBaseUrl?: string;
|
|
11
|
-
geoColumn?: string;
|
|
12
|
-
accessToken: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/******************************************************************************
|
|
16
|
-
* SOURCES
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/** @internalRemarks Source: @carto/react-api */
|
|
20
|
-
export type Source = {
|
|
21
|
-
type: MapType;
|
|
22
|
-
connection: string;
|
|
23
|
-
credentials: Credentials;
|
|
24
|
-
data: string;
|
|
25
|
-
geoColumn?: string;
|
|
26
|
-
queryParameters?: unknown[];
|
|
27
|
-
filters?: Record<string, Filter>;
|
|
28
|
-
filtersLogicalOperator?: 'and' | 'or';
|
|
29
|
-
};
|
|
1
|
+
import type {FilterType} from './constants';
|
|
30
2
|
|
|
31
3
|
/******************************************************************************
|
|
32
4
|
* AGGREGATION
|
|
33
5
|
*/
|
|
34
6
|
|
|
35
7
|
/**
|
|
36
|
-
* Enum for the different types of aggregations available for widgets
|
|
37
|
-
*
|
|
38
|
-
* @readonly
|
|
8
|
+
* Enum for the different types of aggregations available for widgets.
|
|
9
|
+
*
|
|
39
10
|
* @internalRemarks Source: @carto/constants
|
|
40
11
|
* @internalRemarks Converted from enum to type union, for improved declarative API.
|
|
41
12
|
*/
|
|
@@ -74,3 +45,24 @@ export type FilterLogicalOperator = 'and' | 'or';
|
|
|
74
45
|
|
|
75
46
|
export type SortDirection = 'asc' | 'desc';
|
|
76
47
|
export type SortColumnType = 'number' | 'string' | 'date';
|
|
48
|
+
|
|
49
|
+
/******************************************************************************
|
|
50
|
+
* SQL QUERY PARAMETERS
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
54
|
+
export type QueryParameterValue =
|
|
55
|
+
| string
|
|
56
|
+
| number
|
|
57
|
+
| boolean
|
|
58
|
+
| Array<QueryParameterValue>
|
|
59
|
+
| object;
|
|
60
|
+
|
|
61
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
62
|
+
export type NamedQueryParameter = Record<string, QueryParameterValue>;
|
|
63
|
+
|
|
64
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
65
|
+
export type PositionalQueryParameter = QueryParameterValue[];
|
|
66
|
+
|
|
67
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
68
|
+
export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
|