DatasourcePlus deals exclusively in ExternalTables, reflect that in the types.
This commit is contained in:
parent
85b3af2971
commit
1faf920c67
|
@ -14,6 +14,7 @@ import {
|
||||||
CreateDatasourceResponse,
|
CreateDatasourceResponse,
|
||||||
Datasource,
|
Datasource,
|
||||||
DatasourcePlus,
|
DatasourcePlus,
|
||||||
|
ExternalTable,
|
||||||
FetchDatasourceInfoRequest,
|
FetchDatasourceInfoRequest,
|
||||||
FetchDatasourceInfoResponse,
|
FetchDatasourceInfoResponse,
|
||||||
IntegrationBase,
|
IntegrationBase,
|
||||||
|
@ -74,9 +75,12 @@ async function getAndMergeDatasource(datasource: Datasource) {
|
||||||
|
|
||||||
async function buildSchemaHelper(
|
async function buildSchemaHelper(
|
||||||
datasource: Datasource
|
datasource: Datasource
|
||||||
): Promise<Record<string, Table>> {
|
): Promise<Record<string, ExternalTable>> {
|
||||||
const connector = (await getConnector(datasource)) as DatasourcePlus
|
const connector = (await getConnector(datasource)) as DatasourcePlus
|
||||||
return await connector.buildSchema(datasource._id!, datasource.entities!)
|
return await connector.buildSchema(
|
||||||
|
datasource._id!,
|
||||||
|
datasource.entities! as Record<string, ExternalTable>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildFilteredSchema(
|
async function buildFilteredSchema(
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
SortJson,
|
SortJson,
|
||||||
ExternalTable,
|
ExternalTable,
|
||||||
TableRequest,
|
TableRequest,
|
||||||
Table,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { OAuth2Client } from "google-auth-library"
|
import { OAuth2Client } from "google-auth-library"
|
||||||
import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
||||||
|
@ -279,8 +278,8 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
||||||
|
|
||||||
async buildSchema(
|
async buildSchema(
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Promise<Record<string, Table>> {
|
): Promise<Record<string, ExternalTable>> {
|
||||||
// not fully configured yet
|
// not fully configured yet
|
||||||
if (!this.config.auth) {
|
if (!this.config.auth) {
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
DatasourceFeature,
|
DatasourceFeature,
|
||||||
ConnectionInfo,
|
ConnectionInfo,
|
||||||
SourceName,
|
SourceName,
|
||||||
Table,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import {
|
import {
|
||||||
getSqlQuery,
|
getSqlQuery,
|
||||||
|
@ -381,8 +380,8 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
*/
|
*/
|
||||||
async buildSchema(
|
async buildSchema(
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Promise<Record<string, Table>> {
|
): Promise<Record<string, ExternalTable>> {
|
||||||
await this.connect()
|
await this.connect()
|
||||||
let tableInfo: MSSQLTablesResponse[] = await this.runSQL(this.TABLES_SQL)
|
let tableInfo: MSSQLTablesResponse[] = await this.runSQL(this.TABLES_SQL)
|
||||||
if (tableInfo == null || !Array.isArray(tableInfo)) {
|
if (tableInfo == null || !Array.isArray(tableInfo)) {
|
||||||
|
@ -395,7 +394,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
.map((record: any) => record.TABLE_NAME)
|
.map((record: any) => record.TABLE_NAME)
|
||||||
.filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1)
|
.filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1)
|
||||||
|
|
||||||
const tables: Record<string, Table> = {}
|
const tables: Record<string, ExternalTable> = {}
|
||||||
for (let tableName of tableNames) {
|
for (let tableName of tableNames) {
|
||||||
// get the column definition (type)
|
// get the column definition (type)
|
||||||
const definition = await this.runSQL(
|
const definition = await this.runSQL(
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
DatasourceFeature,
|
DatasourceFeature,
|
||||||
ConnectionInfo,
|
ConnectionInfo,
|
||||||
SourceName,
|
SourceName,
|
||||||
Table,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import {
|
import {
|
||||||
getSqlQuery,
|
getSqlQuery,
|
||||||
|
@ -279,9 +278,9 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
|
||||||
|
|
||||||
async buildSchema(
|
async buildSchema(
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Promise<Record<string, Table>> {
|
): Promise<Record<string, ExternalTable>> {
|
||||||
const tables: { [key: string]: Table } = {}
|
const tables: { [key: string]: ExternalTable } = {}
|
||||||
await this.connect()
|
await this.connect()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
DatasourcePlus,
|
DatasourcePlus,
|
||||||
DatasourceFeature,
|
DatasourceFeature,
|
||||||
ConnectionInfo,
|
ConnectionInfo,
|
||||||
Table,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import {
|
import {
|
||||||
buildExternalTableId,
|
buildExternalTableId,
|
||||||
|
@ -265,8 +264,8 @@ class OracleIntegration extends Sql implements DatasourcePlus {
|
||||||
*/
|
*/
|
||||||
async buildSchema(
|
async buildSchema(
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Promise<Record<string, Table>> {
|
): Promise<Record<string, ExternalTable>> {
|
||||||
const columnsResponse = await this.internalQuery<OracleColumnsResponse>({
|
const columnsResponse = await this.internalQuery<OracleColumnsResponse>({
|
||||||
sql: this.COLUMNS_SQL,
|
sql: this.COLUMNS_SQL,
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
DatasourceFeature,
|
DatasourceFeature,
|
||||||
ConnectionInfo,
|
ConnectionInfo,
|
||||||
SourceName,
|
SourceName,
|
||||||
Table,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import {
|
import {
|
||||||
getSqlQuery,
|
getSqlQuery,
|
||||||
|
@ -272,8 +271,8 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
*/
|
*/
|
||||||
async buildSchema(
|
async buildSchema(
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Promise<Record<string, Table>> {
|
): Promise<Record<string, ExternalTable>> {
|
||||||
let tableKeys: { [key: string]: string[] } = {}
|
let tableKeys: { [key: string]: string[] } = {}
|
||||||
await this.openConnection()
|
await this.openConnection()
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -297,9 +297,9 @@ function copyExistingPropsOver(
|
||||||
* @param entities The old list of tables, if there was any to look for definitions in.
|
* @param entities The old list of tables, if there was any to look for definitions in.
|
||||||
*/
|
*/
|
||||||
export function finaliseExternalTables(
|
export function finaliseExternalTables(
|
||||||
tables: Record<string, Table>,
|
tables: Record<string, ExternalTable>,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Record<string, Table> {
|
): Record<string, ExternalTable> {
|
||||||
let finalTables: Record<string, Table> = {}
|
let finalTables: Record<string, Table> = {}
|
||||||
const tableIds = Object.values(tables).map(table => table._id!)
|
const tableIds = Object.values(tables).map(table => table._id!)
|
||||||
for (let [name, table] of Object.entries(tables)) {
|
for (let [name, table] of Object.entries(tables)) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Table } from "../documents"
|
import { ExternalTable, Table } from "../documents"
|
||||||
|
|
||||||
export const PASSWORD_REPLACEMENT = "--secret-value--"
|
export const PASSWORD_REPLACEMENT = "--secret-value--"
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ export interface DatasourcePlus extends IntegrationBase {
|
||||||
getStringConcat(parts: string[]): string
|
getStringConcat(parts: string[]): string
|
||||||
buildSchema(
|
buildSchema(
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
entities: Record<string, Table>
|
entities: Record<string, ExternalTable>
|
||||||
): Promise<Record<string, Table>>
|
): Promise<Record<string, ExternalTable>>
|
||||||
getTableNames(): Promise<string[]>
|
getTableNames(): Promise<string[]>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue