@carto/api-client 0.5.0-alpha.3 → 0.5.0-alpha.5
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/CHANGELOG.md +4 -0
- package/build/api-client.cjs +3332 -3100
- package/build/api-client.d.cts +1373 -0
- package/build/api-client.d.ts +1373 -0
- package/build/api-client.js +1712 -0
- package/build/chunk-V3E7BKVR.js +2063 -0
- package/build/worker.d.ts +2 -0
- package/build/worker.js +25 -0
- package/package.json +51 -45
- package/src/api/carto-api-error.ts +1 -1
- package/src/api/query.ts +5 -5
- package/src/api/request-with-parameters.ts +6 -6
- package/src/client.ts +3 -3
- package/src/constants-internal.ts +5 -11
- package/src/constants.ts +6 -6
- package/src/deck/get-data-filter-extension-props.ts +146 -0
- package/src/deck/index.ts +1 -0
- package/src/filters/Filter.ts +18 -8
- package/src/filters/FilterTypes.ts +2 -2
- package/src/filters/geosjonFeatures.ts +2 -2
- package/src/filters/tileFeatures.ts +19 -41
- package/src/filters.ts +4 -4
- package/src/geo.ts +12 -14
- package/src/global.d.ts +3 -8
- package/src/index.ts +1 -0
- package/src/models/common.ts +9 -7
- package/src/models/model.ts +3 -4
- package/src/operations/aggregation.ts +5 -5
- package/src/operations/applySorting.ts +4 -4
- package/src/operations/groupBy.ts +4 -4
- package/src/operations/groupByDate.ts +1 -1
- package/src/operations/histogram.ts +4 -4
- package/src/operations/scatterPlot.ts +4 -4
- package/src/sources/base-source.ts +8 -8
- package/src/sources/boundary-query-source.ts +2 -2
- package/src/sources/boundary-table-source.ts +2 -2
- package/src/sources/h3-query-source.ts +7 -5
- package/src/sources/h3-table-source.ts +7 -5
- package/src/sources/h3-tileset-source.ts +12 -5
- package/src/sources/index.ts +26 -26
- package/src/sources/quadbin-query-source.ts +7 -5
- package/src/sources/quadbin-table-source.ts +7 -5
- package/src/sources/quadbin-tileset-source.ts +12 -5
- package/src/sources/raster-source.ts +7 -16
- package/src/sources/types.ts +10 -4
- package/src/sources/vector-query-source.ts +2 -3
- package/src/sources/vector-table-source.ts +2 -3
- package/src/sources/vector-tileset-source.ts +13 -6
- package/src/spatial-index.ts +4 -4
- package/src/types-internal.ts +5 -5
- package/src/types.ts +15 -21
- package/src/utils/makeIntervalComplete.ts +1 -1
- package/src/utils.ts +3 -3
- package/src/widget-sources/index.ts +1 -1
- package/src/widget-sources/types.ts +5 -3
- package/src/widget-sources/widget-query-source.ts +6 -2
- package/src/widget-sources/widget-remote-source.ts +66 -18
- package/src/widget-sources/widget-source.ts +0 -28
- package/src/widget-sources/widget-table-source.ts +6 -2
- package/src/widget-sources/widget-tileset-source.ts +130 -90
- package/src/widget-sources/widget-tileset-worker-source.ts +238 -0
- package/src/workers/constants.ts +13 -0
- package/src/workers/types.ts +20 -0
- package/src/workers/utils.ts +33 -0
- package/src/workers/widget-tileset-worker.ts +36 -0
- package/build/api/carto-api-error.d.ts +0 -26
- package/build/api/endpoints.d.ts +0 -24
- package/build/api/index.d.ts +0 -5
- package/build/api/query.d.ts +0 -3
- package/build/api/request-with-parameters.d.ts +0 -10
- package/build/api-client.cjs.map +0 -1
- package/build/api-client.modern.js +0 -3304
- package/build/api-client.modern.js.map +0 -1
- package/build/client.d.ts +0 -14
- package/build/constants-internal.d.ts +0 -26
- package/build/constants.d.ts +0 -53
- package/build/filters/Filter.d.ts +0 -13
- package/build/filters/FilterTypes.d.ts +0 -3
- package/build/filters/geosjonFeatures.d.ts +0 -8
- package/build/filters/index.d.ts +0 -6
- package/build/filters/tileFeatures.d.ts +0 -21
- package/build/filters/tileFeaturesGeometries.d.ts +0 -13
- package/build/filters/tileFeaturesRaster.d.ts +0 -16
- package/build/filters/tileFeaturesSpatialIndex.d.ts +0 -10
- package/build/filters.d.ts +0 -39
- package/build/geo.d.ts +0 -19
- package/build/index.d.ts +0 -15
- package/build/models/common.d.ts +0 -27
- package/build/models/index.d.ts +0 -3
- package/build/models/model.d.ts +0 -37
- package/build/operations/aggregation.d.ts +0 -8
- package/build/operations/applySorting.d.ts +0 -20
- package/build/operations/groupBy.d.ts +0 -15
- package/build/operations/groupByDate.d.ts +0 -11
- package/build/operations/histogram.d.ts +0 -13
- package/build/operations/index.d.ts +0 -6
- package/build/operations/scatterPlot.d.ts +0 -14
- package/build/sources/base-source.d.ts +0 -4
- package/build/sources/boundary-query-source.d.ts +0 -10
- package/build/sources/boundary-table-source.d.ts +0 -8
- package/build/sources/h3-query-source.d.ts +0 -5
- package/build/sources/h3-table-source.d.ts +0 -5
- package/build/sources/h3-tileset-source.d.ts +0 -5
- package/build/sources/index.d.ts +0 -26
- package/build/sources/quadbin-query-source.d.ts +0 -5
- package/build/sources/quadbin-table-source.d.ts +0 -5
- package/build/sources/quadbin-tileset-source.d.ts +0 -5
- package/build/sources/raster-source.d.ts +0 -5
- package/build/sources/types.d.ts +0 -366
- package/build/sources/vector-query-source.d.ts +0 -5
- package/build/sources/vector-table-source.d.ts +0 -5
- package/build/sources/vector-tileset-source.d.ts +0 -5
- package/build/spatial-index.d.ts +0 -14
- package/build/types-internal.d.ts +0 -56
- package/build/types.d.ts +0 -148
- package/build/utils/dateUtils.d.ts +0 -10
- package/build/utils/getTileFormat.d.ts +0 -3
- package/build/utils/makeIntervalComplete.d.ts +0 -2
- package/build/utils/transformTileCoordsToWGS84.d.ts +0 -8
- package/build/utils/transformToTileCoords.d.ts +0 -9
- package/build/utils.d.ts +0 -32
- package/build/widget-sources/index.d.ts +0 -7
- package/build/widget-sources/types.d.ts +0 -158
- package/build/widget-sources/widget-query-source.d.ts +0 -33
- package/build/widget-sources/widget-raster-source.d.ts +0 -11
- package/build/widget-sources/widget-remote-source.d.ts +0 -18
- package/build/widget-sources/widget-source.d.ts +0 -74
- package/build/widget-sources/widget-table-source.d.ts +0 -33
- package/build/widget-sources/widget-tileset-source.d.ts +0 -77
- package/src/filters/tileFeaturesRaster.ts +0 -111
- package/src/widget-sources/widget-raster-source.ts +0 -14
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WidgetTilesetSource,
|
|
3
|
+
type WidgetTilesetSourceProps,
|
|
4
|
+
} from '../widget-sources/widget-tileset-source.js';
|
|
5
|
+
import {Method} from './constants.js';
|
|
6
|
+
import type {WorkerRequest, WorkerResponse} from './types.js';
|
|
7
|
+
|
|
8
|
+
// TODO: Cannot rely on tableName as unique ID.
|
|
9
|
+
const SOURCES_BY_NAME = new Map<string, WidgetTilesetSource>();
|
|
10
|
+
|
|
11
|
+
addEventListener('message', (e) => {
|
|
12
|
+
const {tableName, method, params, requestId} = e.data as WorkerRequest;
|
|
13
|
+
|
|
14
|
+
if (method === Method.INIT) {
|
|
15
|
+
const props = params[0] as WidgetTilesetSourceProps;
|
|
16
|
+
SOURCES_BY_NAME.set(tableName, new WidgetTilesetSource(props));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const source = SOURCES_BY_NAME.get(tableName);
|
|
21
|
+
|
|
22
|
+
if (!source) {
|
|
23
|
+
const error = `Unknown dataset: ${tableName}`;
|
|
24
|
+
postMessage({ok: false, error, requestId} as WorkerResponse);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// @ts-expect-error No type-checking dynamic method name.
|
|
29
|
+
Promise.resolve(source[method](...params))
|
|
30
|
+
.then((result) => {
|
|
31
|
+
postMessage({ok: true, result, requestId} as WorkerResponse);
|
|
32
|
+
})
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
postMessage({ok: false, error, requestId} as WorkerResponse);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MapType } from '../types';
|
|
2
|
-
export type APIRequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL' | 'Basemap style';
|
|
3
|
-
export type APIErrorContext = {
|
|
4
|
-
requestType: APIRequestType;
|
|
5
|
-
mapId?: string;
|
|
6
|
-
connection?: string;
|
|
7
|
-
source?: string;
|
|
8
|
-
type?: MapType;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Custom error for reported errors in CARTO Maps API.
|
|
13
|
-
* Provides useful debugging information in console and context for applications.
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export declare class CartoAPIError extends Error {
|
|
17
|
-
/** Source error from server */
|
|
18
|
-
error: Error;
|
|
19
|
-
/** Context (API call & parameters) in which error occured */
|
|
20
|
-
errorContext: APIErrorContext;
|
|
21
|
-
/** Response from server */
|
|
22
|
-
response?: Response;
|
|
23
|
-
/** JSON Response from server */
|
|
24
|
-
responseJson?: any;
|
|
25
|
-
constructor(error: Error, errorContext: APIErrorContext, response?: Response, responseJson?: any);
|
|
26
|
-
}
|
package/build/api/endpoints.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MapType } from '../types.js';
|
|
2
|
-
export type V3Endpoint = 'maps' | 'stats' | 'sql';
|
|
3
|
-
/** @internal Required by fetchMap(). */
|
|
4
|
-
export declare function buildPublicMapUrl({ apiBaseUrl, cartoMapId, }: {
|
|
5
|
-
apiBaseUrl: string;
|
|
6
|
-
cartoMapId: string;
|
|
7
|
-
}): string;
|
|
8
|
-
/** @internal Required by fetchMap(). */
|
|
9
|
-
export declare function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source, type, }: {
|
|
10
|
-
attribute: string;
|
|
11
|
-
apiBaseUrl: string;
|
|
12
|
-
connectionName: string;
|
|
13
|
-
source: string;
|
|
14
|
-
type: MapType;
|
|
15
|
-
}): string;
|
|
16
|
-
export declare function buildSourceUrl({ apiBaseUrl, connectionName, endpoint, }: {
|
|
17
|
-
apiBaseUrl: string;
|
|
18
|
-
connectionName: string;
|
|
19
|
-
endpoint: MapType;
|
|
20
|
-
}): string;
|
|
21
|
-
export declare function buildQueryUrl({ apiBaseUrl, connectionName, }: {
|
|
22
|
-
apiBaseUrl: string;
|
|
23
|
-
connectionName: string;
|
|
24
|
-
}): string;
|
package/build/api/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { CartoAPIError, APIErrorContext, APIRequestType, } from './carto-api-error.js';
|
|
2
|
-
export { buildPublicMapUrl, buildStatsUrl } from './endpoints.js';
|
|
3
|
-
export { query } from './query.js';
|
|
4
|
-
export type { QueryOptions } from './query.js';
|
|
5
|
-
export { requestWithParameters } from './request-with-parameters.js';
|
package/build/api/query.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { APIErrorContext } from './carto-api-error';
|
|
2
|
-
import { LocalCacheOptions } from '../sources/types';
|
|
3
|
-
export declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, localCache, }: {
|
|
4
|
-
baseUrl: string;
|
|
5
|
-
parameters?: Record<string, unknown>;
|
|
6
|
-
headers?: Record<string, string>;
|
|
7
|
-
errorContext: APIErrorContext;
|
|
8
|
-
maxLengthURL?: number;
|
|
9
|
-
localCache?: LocalCacheOptions;
|
|
10
|
-
}): Promise<T>;
|