@carto/api-client 0.5.2 → 0.5.4-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/build/api-client.cjs +46 -4
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +25 -27
- package/build/api-client.d.ts +25 -27
- package/build/api-client.js +42 -4
- package/build/api-client.js.map +1 -1
- package/build/worker.js.map +1 -1
- package/package.json +4 -3
- package/src/fetch-map/layer-map.ts +1 -2
- package/src/index.ts +1 -0
- package/src/sources/h3-query-source.ts +6 -1
- package/src/sources/h3-table-source.ts +6 -1
- package/src/sources/quadbin-query-source.ts +6 -1
- package/src/sources/quadbin-table-source.ts +6 -1
- package/src/sources/types.ts +1 -2
- package/src/types-internal.ts +0 -29
- package/src/types.ts +27 -0
- package/src/utils.ts +20 -1
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
9
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
10
10
|
"packageManager": "yarn@4.3.1",
|
|
11
|
-
"version": "0.5.
|
|
11
|
+
"version": "0.5.4-alpha.0",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@types/geojson": "^7946.0.16",
|
|
68
68
|
"d3-format": "^3.1.0",
|
|
69
69
|
"d3-scale": "^4.0.2",
|
|
70
|
-
"h3-js": "4.
|
|
70
|
+
"h3-js": "^4.1.0",
|
|
71
71
|
"quadbin": "^0.4.1-alpha.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
@@ -128,5 +128,6 @@
|
|
|
128
128
|
"resolutions": {
|
|
129
129
|
"@carto/api-client": "portal:./",
|
|
130
130
|
"rollup": "^4.20.0"
|
|
131
|
-
}
|
|
131
|
+
},
|
|
132
|
+
"stableVersion": "0.5.3"
|
|
132
133
|
}
|
|
@@ -35,9 +35,8 @@ import type {
|
|
|
35
35
|
VisualChannelField,
|
|
36
36
|
VisualChannels,
|
|
37
37
|
} from './types.js';
|
|
38
|
-
import type {ProviderType} from '../types.js';
|
|
38
|
+
import type {ProviderType, SchemaField} from '../types.js';
|
|
39
39
|
import {DEFAULT_AGGREGATION_EXP_ALIAS} from '../constants-internal.js';
|
|
40
|
-
import type {SchemaField} from '../types-internal.js';
|
|
41
40
|
|
|
42
41
|
const SCALE_FUNCS: Record<string, () => any> = {
|
|
43
42
|
linear: scaleLinear,
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './client.js';
|
|
|
2
2
|
export * from './constants.js';
|
|
3
3
|
export * from './deck/index.js';
|
|
4
4
|
export * from './fetch-map/index.js';
|
|
5
|
+
export type {LayerDescriptor, LayerType} from './fetch-map/index.js';
|
|
5
6
|
export * from './filters.js';
|
|
6
7
|
export * from './geo.js';
|
|
7
8
|
export * from './sources/index.js';
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants-internal.js';
|
|
6
|
+
import {getWidgetSpatialDataType} from '../utils.js';
|
|
6
7
|
import {
|
|
7
8
|
WidgetQuerySource,
|
|
8
9
|
type WidgetQuerySourceResult,
|
|
@@ -72,7 +73,11 @@ export const h3QuerySource = async function (
|
|
|
72
73
|
...options,
|
|
73
74
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
74
75
|
spatialDataColumn,
|
|
75
|
-
spatialDataType
|
|
76
|
+
spatialDataType: getWidgetSpatialDataType(
|
|
77
|
+
spatialDataType,
|
|
78
|
+
spatialDataColumn,
|
|
79
|
+
result.schema
|
|
80
|
+
),
|
|
76
81
|
}),
|
|
77
82
|
})
|
|
78
83
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants-internal.js';
|
|
6
|
+
import {getWidgetSpatialDataType} from '../utils.js';
|
|
6
7
|
import {
|
|
7
8
|
WidgetTableSource,
|
|
8
9
|
type WidgetTableSourceResult,
|
|
@@ -67,7 +68,11 @@ export const h3TableSource = async function (
|
|
|
67
68
|
...options,
|
|
68
69
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
69
70
|
spatialDataColumn,
|
|
70
|
-
spatialDataType
|
|
71
|
+
spatialDataType: getWidgetSpatialDataType(
|
|
72
|
+
spatialDataType,
|
|
73
|
+
spatialDataColumn,
|
|
74
|
+
result.schema
|
|
75
|
+
),
|
|
71
76
|
}),
|
|
72
77
|
})
|
|
73
78
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants-internal.js';
|
|
6
|
+
import {getWidgetSpatialDataType} from '../utils.js';
|
|
6
7
|
import {
|
|
7
8
|
WidgetQuerySource,
|
|
8
9
|
type WidgetQuerySourceResult,
|
|
@@ -73,7 +74,11 @@ export const quadbinQuerySource = async function (
|
|
|
73
74
|
...options,
|
|
74
75
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
75
76
|
spatialDataColumn,
|
|
76
|
-
spatialDataType
|
|
77
|
+
spatialDataType: getWidgetSpatialDataType(
|
|
78
|
+
spatialDataType,
|
|
79
|
+
spatialDataColumn,
|
|
80
|
+
result.schema
|
|
81
|
+
),
|
|
77
82
|
}),
|
|
78
83
|
})
|
|
79
84
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants-internal.js';
|
|
6
|
+
import {getWidgetSpatialDataType} from '../utils.js';
|
|
6
7
|
import {
|
|
7
8
|
WidgetTableSource,
|
|
8
9
|
type WidgetTableSourceResult,
|
|
@@ -68,7 +69,11 @@ export const quadbinTableSource = async function (
|
|
|
68
69
|
...options,
|
|
69
70
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
70
71
|
spatialDataColumn,
|
|
71
|
-
spatialDataType
|
|
72
|
+
spatialDataType: getWidgetSpatialDataType(
|
|
73
|
+
spatialDataType,
|
|
74
|
+
spatialDataColumn,
|
|
75
|
+
result.schema
|
|
76
|
+
),
|
|
72
77
|
}),
|
|
73
78
|
})
|
|
74
79
|
);
|
package/src/sources/types.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {SchemaField} from '../types
|
|
6
|
-
import type {Filters, QueryParameters} from '../types.js';
|
|
5
|
+
import type {Filters, SchemaField, QueryParameters} from '../types.js';
|
|
7
6
|
|
|
8
7
|
export type SourceRequiredOptions = {
|
|
9
8
|
/** Carto platform access token. */
|
package/src/types-internal.ts
CHANGED
|
@@ -8,35 +8,6 @@ export type $TODO = any;
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
export type $IntentionalAny = any;
|
|
10
10
|
|
|
11
|
-
/******************************************************************************
|
|
12
|
-
* MAP INSTANTIATION
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @privateRemarks Source: @deck.gl/carto
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export enum SchemaFieldType {
|
|
20
|
-
Number = 'number',
|
|
21
|
-
Bigint = 'bigint',
|
|
22
|
-
String = 'string',
|
|
23
|
-
Geometry = 'geometry',
|
|
24
|
-
Timestamp = 'timestamp',
|
|
25
|
-
Object = 'object',
|
|
26
|
-
Boolean = 'boolean',
|
|
27
|
-
Variant = 'variant',
|
|
28
|
-
Unknown = 'unknown',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @privateRemarks Source: @deck.gl/carto
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export interface SchemaField {
|
|
36
|
-
name: string;
|
|
37
|
-
type: SchemaFieldType; // Field type in the CARTO stack, common for all providers
|
|
38
|
-
}
|
|
39
|
-
|
|
40
11
|
/******************************************************************************
|
|
41
12
|
* LOCAL CALCULATIONS
|
|
42
13
|
*/
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,33 @@ import type {FilterType} from './constants.js';
|
|
|
2
2
|
import type {Polygon, MultiPolygon, Feature} from 'geojson';
|
|
3
3
|
import type {BinaryFeature, BinaryFeatureCollection} from '@loaders.gl/schema';
|
|
4
4
|
|
|
5
|
+
/******************************************************************************
|
|
6
|
+
* MAP INSTANTIATION
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
11
|
+
*/
|
|
12
|
+
export enum SchemaFieldType {
|
|
13
|
+
Number = 'number',
|
|
14
|
+
Bigint = 'bigint',
|
|
15
|
+
String = 'string',
|
|
16
|
+
Geometry = 'geometry',
|
|
17
|
+
Timestamp = 'timestamp',
|
|
18
|
+
Object = 'object',
|
|
19
|
+
Boolean = 'boolean',
|
|
20
|
+
Variant = 'variant',
|
|
21
|
+
Unknown = 'unknown',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
26
|
+
*/
|
|
27
|
+
export interface SchemaField {
|
|
28
|
+
name: string;
|
|
29
|
+
type: SchemaFieldType; // Field type in the CARTO stack, common for all providers
|
|
30
|
+
}
|
|
31
|
+
|
|
5
32
|
/******************************************************************************
|
|
6
33
|
* MAPS AND TILES
|
|
7
34
|
*/
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import {SchemaFieldType, type Filter, type SchemaField} from './types.js';
|
|
2
2
|
import {FilterType} from './constants.js';
|
|
3
|
+
import type {SpatialDataType} from './sources/types.js';
|
|
3
4
|
|
|
4
5
|
const FILTER_TYPES = new Set(Object.values(FilterType));
|
|
5
6
|
const isFilterType = (type: string): type is FilterType =>
|
|
@@ -127,3 +128,21 @@ export function assignOptional<T extends object, U>(
|
|
|
127
128
|
}
|
|
128
129
|
return target as T & U;
|
|
129
130
|
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns the spatialDataType expected for widget operations, given layer source props. The
|
|
134
|
+
* spatialDataType used in widget operations may be different from that of the layer. For
|
|
135
|
+
* dynamically aggregated point datasets, widgets use type 'geo', not the aggregation type.
|
|
136
|
+
*/
|
|
137
|
+
export function getWidgetSpatialDataType(
|
|
138
|
+
spatialDataType: SpatialDataType,
|
|
139
|
+
spatialDataColumn: string,
|
|
140
|
+
schema: SchemaField[]
|
|
141
|
+
): SpatialDataType {
|
|
142
|
+
const field = schema.find((field) => field.name === spatialDataColumn);
|
|
143
|
+
if (field && field.type === SchemaFieldType.Geometry) {
|
|
144
|
+
return 'geo';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return spatialDataType;
|
|
148
|
+
}
|