blob: c0a4b721aaa16df6311eea4f9d4917b37c185c9b [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { core as coreType } from '@apache-superset/core';
export class Table implements coreType.Table {
name: string;
columns: coreType.Column[];
constructor(name: string, columns: coreType.Column[]) {
this.name = name;
this.columns = columns;
}
addColumn(column: coreType.Column): void {
this.columns.push(column);
}
}
export class Catalog implements coreType.Catalog {
name: string;
description?: string;
constructor(name: string, description?: string) {
this.name = name;
this.description = description;
}
}
export class Schema implements coreType.Schema {
tables: Table[];
constructor(tables: Table[]) {
this.tables = tables;
}
addTable(table: Table): void {
this.tables.push(table);
}
}
export class Database implements coreType.Database {
id: number;
name: string;
catalogs: Catalog[];
schemas: Schema[];
constructor(
id: number,
name: string,
catalogs: Catalog[],
schemas: Schema[],
) {
this.id = id;
this.name = name;
this.catalogs = catalogs;
this.schemas = schemas;
}
addCatalog(catalog: Catalog): void {
this.catalogs.push(catalog);
}
addSchema(schema: Schema): void {
this.schemas.push(schema);
}
}
export class Disposable implements coreType.Disposable {
static from(
...disposableLikes: {
dispose: () => any;
}[]
): Disposable {
return new Disposable(() => {
disposableLikes.forEach(disposable => {
disposable.dispose();
});
});
}
constructor(callOnDispose: () => any) {
this.dispose = callOnDispose;
}
dispose(): any {
this.dispose();
}
}
export class ExtensionContext implements coreType.ExtensionContext {
disposables: coreType.Disposable[] = [];
}