Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Chore]: Technical: Translate cloud-providers (#1778)

Maksim Suslovec3351b61088
diff --git a/src/cloud-providers/index.d.ts b/src/cloud-providers/index.d.ts
deleted file mode 100644
index 148ef21ec..000000000
--- a/src/cloud-providers/index.d.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import {ComponentType} from 'prop-types';
-import {MapData, ExportFileOptions} from 'actions/provider-actions';
-
-export type Millisecond = number;
-
-export type MapListItem = {
- id: string;
- title: string;
- description: string;
- loadParams: any;
- imageUrl?: string;
- lastModification?: Millisecond;
- privateMap?: boolean;
-};
-
-export type Thumbnail = {
- width: number;
- height: number;
-};
-
-export type ProviderProps = {
- name?: string;
- displayName?: string;
- icon?: ComponentType<IconProps>;
- thumbnail?: Thumbnail;
-};
-
-interface IconProps {
- height?: number | string;
- width?: number | string;
-}
-
-export class Provider {
- constructor(p: ProviderProps);
- name: string;
- displayName: string;
- icon: ComponentType<IconProps>;
- thumbnail: Thumbnail;
- getManagementUrl?: () => string;
- hasPrivateStorage(): boolean;
- hasSharingUrl(): boolean;
- getShareUrl(fullUrl?: boolean): string;
- getMapUrl(fullUrl?: boolean): string;
- getAccessToken(): boolean;
- getUserName(): boolean;
- login(Fn?: any): Promise<any>;
- logout(Fn?: any): Promise<any>;
- uploadMap(p: {mapData: MapData; options: ExportFileOptions}): Promise<any>;
- listMaps(): Promise<MapListItem>;
- downloadMap(param: any): Promose<{map: MapData; format: string}>;
-}
-
-export const FILE_CONFLICT_MSG: string;
diff --git a/src/cloud-providers/index.js b/src/cloud-providers/index.ts
similarity index 93%
rename from src/cloud-providers/index.js
rename to src/cloud-providers/index.ts
index 2eb43e9e5..58f928378 100644
--- a/src/cloud-providers/index.js
+++ b/src/cloud-providers/index.ts
@@ -19,3 +19,4 @@
// THE SOFTWARE.
export {default as Provider, FILE_CONFLICT_MSG} from './provider';
+export type {MapListItem, Millisecond, Thumbnail, ProviderProps} from './provider';
diff --git a/src/cloud-providers/provider.js b/src/cloud-providers/provider.ts
similarity index 82%
rename from src/cloud-providers/provider.js
rename to src/cloud-providers/provider.ts
index 32bbca192..e68a60bc1 100644
--- a/src/cloud-providers/provider.js
+++ b/src/cloud-providers/provider.ts
@@ -19,6 +19,37 @@
// THE SOFTWARE.
import {Upload} from 'components/common/icons';
+import {MapData, ExportFileOptions} from 'actions/provider-actions';
+import {ComponentType} from 'react';
+
+export type Millisecond = number;
+
+export type MapListItem = {
+ id: string;
+ title: string;
+ description: string;
+ loadParams: any;
+ imageUrl?: string;
+ lastModification?: Millisecond;
+ privateMap?: boolean;
+};
+
+export type Thumbnail = {
+ width: number;
+ height: number;
+};
+
+export type ProviderProps = {
+ name?: string;
+ displayName?: string;
+ icon?: ComponentType<IconProps>;
+ thumbnail?: Thumbnail;
+};
+
+interface IconProps {
+ height?: string;
+ width?: string;
+}
const NAME = 'cloud-provider';
const DISPLAY_NAME = 'Cloud Provider';
@@ -45,7 +76,13 @@ export const FILE_CONFLICT_MSG = 'file_conflict';
* })
*/
export default class Provider {
- constructor(props) {
+ name: string;
+ displayName: string;
+ icon: ComponentType<IconProps>;
+ thumbnail: Thumbnail;
+ getManagementUrl?: () => string;
+
+ constructor(props: ProviderProps) {
this.name = props.name || NAME;
this.displayName = props.displayName || DISPLAY_NAME;
this.icon = props.icon || ICON;
@@ -54,57 +91,57 @@ export default class Provider {
/**
* Whether this provider support upload map to a private storage. If truthy, user will be displayed with the storage save icon on the top right of the side bar.
- * @returns {boolean}
+ * @returns
* @public
*/
- hasPrivateStorage() {
+ hasPrivateStorage(): boolean {
return true;
}
/**
* Whether this provider support share map via a public url, if truthy, user will be displayed with a share map via url under the export map option on the top right of the side bar
- * @returns {boolean}
+ * @returns
* @public
*/
- hasSharingUrl() {
+ hasSharingUrl(): boolean {
return true;
}
/**
* This method is called after user share a map, to display the share url.
- * @param {boolean} fullUrl - Whether to return the full url with domain, or just the location
- * @returns {string} shareUrl
+ * @param fullUrl - Whether to return the full url with domain, or just the location
+ * @returns shareUrl
* @public
*/
- getShareUrl(fullUrl = false) {
+ getShareUrl(fullUrl: boolean = false): string {
return '';
}
/**
* This method is called by kepler.gl demo app to pushes a new location to history, becoming the current location.
- * @param {boolean} fullURL - Whether to return the full url with domain, or just the location
- * @returns {string} mapUrl
+ * @param fullURL - Whether to return the full url with domain, or just the location
+ * @returns mapUrl
* @public
*/
- getMapUrl(fullURL = true) {
+ getMapUrl(fullURL: boolean = true): string {
return '';
}
/**
* This method is called to determine whether user already logged in to this provider
* @public
- * @returns {boolean} true if a user already logged in
+ * @returns true if a user already logged in
*/
- getAccessToken() {
+ getAccessToken(): boolean {
return true;
}
/**
* This method is called to get the user name of the current user. It will be displayed in the cloud provider tile.
* @public
- * @returns {string} true if a user already logged in
+ * @returns true if a user already logged in
*/
- getUserName() {
+ getUserName(): string {
return '';
}
@@ -150,7 +187,13 @@ export default class Provider {
* @param {boolean} [param.options.isPublic] - whether user wish to share the map with others. if isPublic is truthy, kepler will call this.getShareUrl() to display an URL they can share with others
* @public
*/
- async uploadMap({mapData, options = {}}) {
+ async uploadMap({
+ mapData,
+ options = {}
+ }: {
+ mapData: MapData;
+ options: ExportFileOptions;
+ }): Promise<any> {
return;
}
@@ -173,7 +216,7 @@ export default class Provider {
* ];
* }
*/
- async listMaps() {
+ async listMaps(): Promise<MapListItem[]> {
return [];
}
@@ -202,7 +245,8 @@ export default class Provider {
* return downloadMap;
* }
*/
- async downloadMap(loadParams) {
+ async downloadMap(loadParams): Promise<{map: MapData; format: string}> {
+ // @ts-expect-error
return;
}