@carto/api-client 0.1.1 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 0.0
3
+ ## 0.2
4
4
 
5
- ### 0.0.1 (UNRELEASED)
5
+ ### 0.2.0
6
6
 
7
7
  - Initial release
package/README.md CHANGED
@@ -17,8 +17,6 @@ npm install --save @carto/api-client
17
17
 
18
18
  ## Documentation
19
19
 
20
- WORK IN PROGRESS.
21
-
22
20
  ### Fetching data
23
21
 
24
22
  Import `vectorTableSource`, `vectorQuerySource`, and other data source functions
@@ -27,25 +25,23 @@ from the `@carto/api-client` package. These are drop-in replacements for the equ
27
25
  ```javascript
28
26
  import { vectorTableSource } from '@carto/api-client';
29
27
 
30
- const data = vectorTableSource({
28
+ const data = await vectorTableSource({
31
29
  accessToken: '••••',
32
30
  connectionName: 'carto_dw',
33
31
  tableName: 'carto-demo-data.demo_tables.retail_stores'
34
32
  });
35
33
 
36
- const { widgetSource } = await data;
37
-
38
34
  // → {name: string; value: number}[]
39
- const categories = await widgetSource.getCategories({
35
+ const categories = await data.widgetSource.getCategories({
40
36
  column: 'store_type',
41
37
  operation: 'count',
42
38
  });
43
39
 
44
40
  // → {value: number}
45
- const formula = await widgetSource.getFormula({operation: 'count'});
41
+ const formula = await data.widgetSource.getFormula({operation: 'count'});
46
42
 
47
43
  // → {totalCount: number; rows: Record<string, number | string>[]}
48
- const table = await widgetSource.getTable({
44
+ const table = await data.widgetSource.getTable({
49
45
  columns: ['a', 'b', 'c'],
50
46
  sortBy: ['a'],
51
47
  rowsPerPage: 20
@@ -62,7 +58,7 @@ property to the source factory function.
62
58
  ```javascript
63
59
  import {vectorTableSource} from '@carto/api-client';
64
60
 
65
- const data = vectorTableSource({
61
+ const data = await vectorTableSource({
66
62
  accessToken: '••••',
67
63
  connectionName: 'carto_dw',
68
64
  tableName: 'carto-demo-data.demo_tables.retail_stores',
@@ -79,7 +75,7 @@ results should not be affected by a filter that the widget itself created.
79
75
 
80
76
  ```javascript
81
77
  // → {name: string; value: number}[]
82
- const categories = await widgetSource.getCategories({
78
+ const categories = await data.widgetSource.getCategories({
83
79
  filterOwner: 'widget-id',
84
80
  column: 'store_type',
85
81
  operation: 'count',
@@ -92,7 +88,7 @@ To filter the widget source to a spatial region, pass a `spatialFilter` paramete
92
88
 
93
89
  ```javascript
94
90
  // → {name: string; value: number}[]
95
- const categories = await widgetSource.getCategories({
91
+ const categories = await data.widgetSource.getCategories({
96
92
  column: 'store_type',
97
93
  operation: 'count',
98
94
  spatialFilter: {
@@ -114,22 +110,10 @@ To create a spatial filter from the current [deck.gl `viewState`](https://deck.g
114
110
 
115
111
  ```javascript
116
112
  import {WebMercatorViewport} from '@deck.gl/core';
113
+ import {createViewportSpatialFilter} from '@carto/api-client';
117
114
 
118
- function createViewStatePolygon(viewState) {
119
- const viewport = new WebMercatorViewport(viewState);
120
- return {
121
- type: 'Polygon',
122
- coordinates: [
123
- [
124
- viewport.unproject([0, 0]),
125
- viewport.unproject([viewport.width, 0]),
126
- viewport.unproject([viewport.width, viewport.height]),
127
- viewport.unproject([0, viewport.height]),
128
- viewport.unproject([0, 0]),
129
- ],
130
- ],
131
- };
132
- }
115
+ const viewport = new WebMercatorViewport(viewState);
116
+ const spatialFilter = createViewportSpatialFilter(viewport.getBounds());
133
117
  ```
134
118
 
135
119
  ### Specifying columns to fetch
@@ -1056,7 +1056,7 @@ function buildSourceUrl({
1056
1056
  */
1057
1057
  const DEFAULT_PARAMETERS = {
1058
1058
  v: V3_MINOR_VERSION,
1059
- deckglVersion: "0.1.1"
1059
+ deckglVersion: "0.2.0"
1060
1060
  };
1061
1061
  const DEFAULT_HEADERS = {
1062
1062
  Accept: 'application/json',
@@ -994,7 +994,7 @@ function buildSourceUrl({
994
994
  */
995
995
  const DEFAULT_PARAMETERS = {
996
996
  v: V3_MINOR_VERSION,
997
- deckglVersion: "0.1.1"
997
+ deckglVersion: "0.2.0"
998
998
  };
999
999
  const DEFAULT_HEADERS = {
1000
1000
  Accept: 'application/json',
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "repository": "github:CartoDB/carto-api-client",
5
5
  "author": "Don McCurdy <donmccurdy@carto.com>",
6
6
  "packageManager": "yarn@4.3.1",
7
- "version": "0.1.1",
7
+ "version": "0.2.0",
8
8
  "license": "MIT",
9
9
  "publishConfig": {
10
10
  "access": "public",