@carto/api-client 0.0.44 → 0.1.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 +5 -20
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +6 -21
- package/build/api-client.modern.js.map +1 -1
- package/build/constants.d.ts +0 -14
- package/build/sources/types.d.ts +10 -11
- package/build/types.d.ts +10 -1
- package/package.json +1 -1
- package/src/constants.ts +0 -15
- package/src/sources/types.ts +10 -11
- package/src/sources/widget-base-source.ts +3 -3
- package/src/types.ts +19 -1
package/src/sources/types.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {GroupDateType} from '../constants';
|
|
2
1
|
import {
|
|
3
|
-
|
|
2
|
+
GroupDateType,
|
|
4
3
|
SortColumnType,
|
|
5
4
|
SortDirection,
|
|
6
5
|
SpatialFilter,
|
|
@@ -20,14 +19,14 @@ interface BaseRequestOptions {
|
|
|
20
19
|
/** Options for {@link WidgetBaseSource#getCategories}. */
|
|
21
20
|
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
22
21
|
column: string;
|
|
23
|
-
operation?:
|
|
22
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
24
23
|
operationColumn?: string;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
/** Options for {@link WidgetBaseSource#getFormula}. */
|
|
28
27
|
export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
29
28
|
column: string;
|
|
30
|
-
operation?:
|
|
29
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
31
30
|
operationExp?: string;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -35,7 +34,7 @@ export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
|
35
34
|
export interface HistogramRequestOptions extends BaseRequestOptions {
|
|
36
35
|
column: string;
|
|
37
36
|
ticks: number[];
|
|
38
|
-
operation?:
|
|
37
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
/** Options for {@link WidgetBaseSource#getRange}. */
|
|
@@ -46,9 +45,9 @@ export interface RangeRequestOptions extends BaseRequestOptions {
|
|
|
46
45
|
/** Options for {@link WidgetBaseSource#getScatter}. */
|
|
47
46
|
export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
48
47
|
xAxisColumn: string;
|
|
49
|
-
xAxisJoinOperation?:
|
|
48
|
+
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
50
49
|
yAxisColumn: string;
|
|
51
|
-
yAxisJoinOperation?:
|
|
50
|
+
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
/** Options for {@link WidgetBaseSource#getTable}. */
|
|
@@ -57,8 +56,8 @@ export interface TableRequestOptions extends BaseRequestOptions {
|
|
|
57
56
|
sortBy?: string;
|
|
58
57
|
sortDirection?: SortDirection;
|
|
59
58
|
sortByColumnType?: SortColumnType;
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
offset?: number;
|
|
60
|
+
limit?: number;
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
/** Options for {@link WidgetBaseSource#getTimeSeries}. */
|
|
@@ -66,9 +65,9 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
|
66
65
|
column: string;
|
|
67
66
|
stepSize?: GroupDateType;
|
|
68
67
|
stepMultiplier?: number;
|
|
69
|
-
operation?:
|
|
68
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
70
69
|
operationColumn?: string;
|
|
71
|
-
joinOperation?:
|
|
70
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
72
71
|
splitByCategory?: string;
|
|
73
72
|
splitByCategoryLimit?: number;
|
|
74
73
|
splitByCategoryValues?: string[];
|
|
@@ -239,7 +239,7 @@ export abstract class WidgetBaseSource<Props extends WidgetBaseSourceProps> {
|
|
|
239
239
|
*/
|
|
240
240
|
async getTable(options: TableRequestOptions): Promise<TableResponse> {
|
|
241
241
|
const {filterOwner, spatialFilter, abortController, ...params} = options;
|
|
242
|
-
const {columns, sortBy, sortDirection,
|
|
242
|
+
const {columns, sortBy, sortDirection, offset = 0, limit = 10} = params;
|
|
243
243
|
|
|
244
244
|
type TableModelResponse = {
|
|
245
245
|
rows: Record<string, number | string>[];
|
|
@@ -253,8 +253,8 @@ export abstract class WidgetBaseSource<Props extends WidgetBaseSourceProps> {
|
|
|
253
253
|
column: columns,
|
|
254
254
|
sortBy,
|
|
255
255
|
sortDirection,
|
|
256
|
-
limit
|
|
257
|
-
offset
|
|
256
|
+
limit,
|
|
257
|
+
offset,
|
|
258
258
|
},
|
|
259
259
|
opts: {abortController},
|
|
260
260
|
}).then((res: TableModelResponse) => ({
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {FilterType} from './constants';
|
|
1
|
+
import type {FilterType} from './constants.js';
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
* AGGREGATION
|
|
@@ -39,6 +39,24 @@ export interface Filter {
|
|
|
39
39
|
/** @internalRemarks Source: @carto/react-core */
|
|
40
40
|
export type FilterLogicalOperator = 'and' | 'or';
|
|
41
41
|
|
|
42
|
+
/******************************************************************************
|
|
43
|
+
* GROUPING
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
|
|
48
|
+
*
|
|
49
|
+
* @internalRemarks Source: @carto/react-core
|
|
50
|
+
*/
|
|
51
|
+
export type GroupDateType =
|
|
52
|
+
| 'year'
|
|
53
|
+
| 'month'
|
|
54
|
+
| 'week'
|
|
55
|
+
| 'day'
|
|
56
|
+
| 'hour'
|
|
57
|
+
| 'minute'
|
|
58
|
+
| 'second';
|
|
59
|
+
|
|
42
60
|
/******************************************************************************
|
|
43
61
|
* SORTING
|
|
44
62
|
*/
|