UNPKG

@mcdevsl/superset-ui

Version:
25 lines (19 loc) 527 B
import { DatasourceType } from './types/Datasource'; export default class DatasourceKey { readonly id: number; readonly type: DatasourceType; constructor(key: string) { const [idStr, typeStr] = key.split('__'); this.id = parseInt(idStr, 10); this.type = typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid; } public toString() { return `${this.id}__${this.type}`; } public toObject() { return { id: this.id, type: this.type, }; } }