diff --git a/docs/api-reference/api.md b/docs/api-reference/api.md index 896639ccc..e6a84ee4c 100644 --- a/docs/api-reference/api.md +++ b/docs/api-reference/api.md @@ -1,63 +1,66 @@ # API -## Functions - -### executeSQL - -Executes a SQL query - -#### Parameters - -##### `credentials` ({ username, apiKey, serverUrlTemplate }) +Functions for working with CARTO REST APIs -Required. CARTO user credentials. +## Functions -##### `query` (String) +
+
buildQueryFiltersstring
+

Returns a SQL query applying a set of filters

+
+
executeSQLObject
+

Execute a SQL query

+
+
getUserDatasetsObject
+

Get the lists of datasets for the user by performing a request to CARTO datasets API

+
+
+ + + +## buildQueryFilters ⇒ string +Returns a SQL query applying a set of filters -Required. SQL query to be executed. +**Kind**: global function +**Returns**: string - SQL query -##### `opts` ({ format }) +| Param | Type | Description | +| --- | --- | --- | +| data | string | Dataset name or SQL query | +| filters | Object | Filters to be applied | -Optional. Additional options for the HTTP request. + -#### Returns +## executeSQL ⇒ Object +Executes a SQL query -{ Object }. Data returned from the SQL query execution. +**Kind**: global function +**Returns**: Object - Data returned from the SQL query execution -If `opts.format` is "geojson", it returns the full object returned by CARTO SQL API; otherwise it returns only the `rows` property. +| Param | Type | Description | +| --- | --- | --- | +| credentials | Object | CARTO user credentials | +| credentials.username | string | CARTO username | +| credentials.apiKey | string | CARTO API Key | +| credentials.serverUrlTemplate | string | CARTO server URL template | +| query | string | SQL query to be executed | +| opts | Object | Additional options for the HTTP request | +| opts.format | string | Output format (i.e. geojson) | -### getUserDatasets + +## getUserDatasets ⇒ Object Get the lists of datasets for the user by performing a request to CARTO datasets API -#### Parameters - -##### `credentials` ({ username, apiKey, serverUrlTemplate }) - -Required. CARTO user credentials. - -##### `opts` ({ Object }) - -Optional. Additional options for the HTTP request. - -#### Returns - -{ Object }. List of datasets owned by the user that are in CARTO canonical form (cartodbfied). - -### buildQueryFilters - -Returns a SQL query applying a set of filters - -#### Parameters - -##### `data` ({ string }) - -Required. Dataset name or SQL query - -##### `filters` ({ Object }) - -Optional. Filters to be applied +**Kind**: global function +**Returns**: Object - List of datasets -#### Returns +| Param | Type | Description | +| --- | --- | --- | +| credentials | Object | CARTO user credentials | +| credentials.username | string | CARTO username | +| credentials.apiKey | string | CARTO API Key | +| credentials.serverUrlTemplate | string | CARTO server URL template | +| opts | Object | Additional options for the HTTP request | +| opts.format | string | Output format (i.e. geojson) | -{ string }. SQL query. \ No newline at end of file diff --git a/docs/api-reference/basemaps.md b/docs/api-reference/basemaps.md index e69de29bb..db233faed 100644 --- a/docs/api-reference/basemaps.md +++ b/docs/api-reference/basemaps.md @@ -0,0 +1,40 @@ +# Basemaps + +Basemaps constants and Google Maps component + +## Constants + +
+
POSITRON : string
+
+
VOYAGER : string
+
+
DARK_MATTER : string
+
+
GOOGLE_ROADMAP : string
+
+
GOOGLE_SATELLITE : string
+
+
GOOGLE_HYBRID : string
+
+
+ +## Functions + +
+
GoogleMap(props)
+

React component for working with Google Maps API and deck.gl

+
+
+ +**Kind**: global function + +| Param | Type | Description | +| --- | --- | --- | +| props | Object | Properties | +| props.basemap | Object | Basemap (see basemaps constants) | +| props.viewState | Object | Viewstate (center, zoom level) | +| props.layers | Array.<Layer> | Layers array | +| props.getTooltip | function | Tooltip handler | +| props.apiKey | string | Google Maps API Key | + diff --git a/docs/api-reference/oauth.md b/docs/api-reference/oauth.md index e69de29bb..a9191374a 100644 --- a/docs/api-reference/oauth.md +++ b/docs/api-reference/oauth.md @@ -0,0 +1,51 @@ +# OAuth + +OAuth functions and hook + +
+
OAuthCallback
+

Component to attend OAuth callbacks on /oauthCallback

+
+
OAuthLogin
+

Shows a login button. +When this button is clicked, the OAuth protocol flow is handled +by the useOAuthLogin hook.

+
+
useOAuthLoginfunction
+

Hook to perform login against CARTO using OAuth implicit flow using a popup

+
+
+ + + +## OAuthCallback +Component to attend OAuth callbacks on /oauthCallback + +**Kind**: global function + + + +## OAuthLogin +Shows a login button. +When this button is clicked, the OAuth protocol flow is handled +by the `useOAuthLogin` hook. + +**Kind**: global function + + + +## useOAuthLogin ⇒ function +Hook to perform login against CARTO using OAuth implicit flow using a popup + +**Kind**: global function +**Returns**: function - Function to trigger oauth with a popup + +| Param | Type | Description | +| --- | --- | --- | +| oauthApp | Object | OAuth parameters | +| oauthApp.clientId | string | Application client ID | +| oauthApp.scopes | Array.<string> | Scopes to request | +| oauthApp.authorizeEndPoint | string | Authorization endpoint | +| onParamsRefreshed | function | Function to call when params are refreshed | + + diff --git a/src/api/SQL.js b/src/api/SQL.js index b63a28bdc..6f8197d58 100644 --- a/src/api/SQL.js +++ b/src/api/SQL.js @@ -6,11 +6,15 @@ import { dealWithApiError, generateApiUrl } from './common'; const API = 'api/v2/sql'; /** - * Execute a SQL query + * Executes a SQL query * - * @param { username, apiKey, serverUrlTemplate } credentials - CARTO user credentials + * @param { Object } credentials - CARTO user credentials + * @param { string } credentials.username - CARTO username + * @param { string } credentials.apiKey - CARTO API Key + * @param { string } credentials.serverUrlTemplate - CARTO server URL template * @param { string } query - SQL query to be executed - * @param { format } opts - Additional options for the HTTP request + * @param { Object } opts - Additional options for the HTTP request + * @param { string } opts.format - Output format (i.e. geojson) * @returns { Object } - Data returned from the SQL query execution */ export const executeSQL = async (credentials, query, opts = {}) => { diff --git a/src/api/UserDatasets.js b/src/api/UserDatasets.js index d0c9433d7..7c59f9eb7 100644 --- a/src/api/UserDatasets.js +++ b/src/api/UserDatasets.js @@ -6,8 +6,12 @@ const API = 'api/v4/datasets'; /** * Get the lists of datasets for the user by performing a request to CARTO datasets API * - * @param { username, apiKey, serverUrlTemplate } credentials - CARTO user credentials + * @param { Object } credentials - CARTO user credentials + * @param { string } credentials.username - CARTO username + * @param { string } credentials.apiKey - CARTO API Key + * @param { string } credentials.serverUrlTemplate - CARTO server URL template * @param { Object } opts - Additional options for the HTTP request + * @param { string } opts.format - Output format (i.e. geojson) * @returns { Object } - List of datasets */ export const getUserDatasets = async (credentials, opts = {}) => { diff --git a/src/basemaps/GoogleMap.js b/src/basemaps/GoogleMap.js index 6cee5fdf0..f2a73264a 100644 --- a/src/basemaps/GoogleMap.js +++ b/src/basemaps/GoogleMap.js @@ -2,6 +2,17 @@ import React, { useEffect, useRef } from 'react'; import { GoogleMapsOverlay } from '@deck.gl/google-maps'; import { debounce } from '../utils'; +/** + * React component for working with Google Maps API and deck.gl + * + * @param { Object } props - Properties + * @param { Object } props.basemap - CARTO username + * @param { Object } props.viewState - Viewstate (center, zoom level) + * @param { Layer[] } props.layers - Layers array + * @param { function } props.getTooltip - Tooltip handler + * @param { string } props.apiKey - Google Maps API Key + * @returns { Object } - Data returned from the SQL query execution + */ export function GoogleMap(props) { const { basemap, viewState, layers, getTooltip, apiKey } = props; // based on https://publiuslogic.com/blog/google-maps+react-hooks/ diff --git a/src/basemaps/basemaps.js b/src/basemaps/basemaps.js index b336eae2d..3c93a402d 100644 --- a/src/basemaps/basemaps.js +++ b/src/basemaps/basemaps.js @@ -1,8 +1,36 @@ +/** @constant + @type {string} + @default +*/ export const POSITRON = 'positron'; +/** @constant + @type {string} + @default +*/ export const VOYAGER = 'voyager'; +/** @constant + @type {string} + @default +*/ +/** @constant + @type {string} + @default +*/ export const DARK_MATTER = 'dark-matter'; +/** @constant + @type {string} + @default +*/ export const GOOGLE_ROADMAP = 'roadmap'; +/** @constant + @type {string} + @default +*/ export const GOOGLE_SATELLITE = 'satellite'; +/** @constant + @type {string} + @default +*/ export const GOOGLE_HYBRID = 'hybrid'; export const BASEMAPS = { diff --git a/src/oauth/OAuthCallback.js b/src/oauth/OAuthCallback.js index e290f63b2..7ead2e7be 100644 --- a/src/oauth/OAuthCallback.js +++ b/src/oauth/OAuthCallback.js @@ -1,5 +1,6 @@ /** * Component to attend OAuth callbacks on /oauthCallback + * @exports OAuthCallback */ export default function OAuthCallback() { return null; diff --git a/src/oauth/OAuthLogin.js b/src/oauth/OAuthLogin.js index 14b597ad2..e5576171d 100644 --- a/src/oauth/OAuthLogin.js +++ b/src/oauth/OAuthLogin.js @@ -11,6 +11,13 @@ const useStyles = makeStyles(() => ({ }, })); +/** + * Shows a login button. + * When this button is clicked, the OAuth protocol flow is handled + * by the `useOAuthLogin` hook. + * + * @exports OAuthLogin + */ export default function OAuthLogin() { const dispatch = useDispatch(); const classes = useStyles(); diff --git a/src/oauth/useOAuthLogin.js b/src/oauth/useOAuthLogin.js index 5da1c7f1c..d52264290 100644 --- a/src/oauth/useOAuthLogin.js +++ b/src/oauth/useOAuthLogin.js @@ -4,8 +4,13 @@ import { createOAuthPopup, getOAuthParamsFromCallback } from './oauthHelper'; /** * Hook to perform login against CARTO using OAuth implicit flow using a popup * - * @param { clientId, scopes, authorizeEndPoint } oauthApp data - * @returns [handleLogin] - function to trigger oauth with a popup + * @param { Object } oauthApp - OAuth parameters + * @param { string } oauthApp.clientId - Application client ID + * @param { string[] } oauthApp.scopes - Scopes to request + * @param { string } oauthApp.authorizeEndPoint - Authorization endpoint + * @param { function } onParamsRefreshed - Function to call when params are refreshed + * @returns { function } - Function to trigger oauth with a popup + * @exports useOAuthLogin */ export default function useOAuthLogin(oauthApp, onParamsRefreshed) { const [oauthParams, setOAuthParams] = useState(null);