diff --git a/packages/server/src/api/controllers/query/import/sources/base/index.ts b/packages/server/src/api/controllers/query/import/sources/base/index.ts index 8f41f4afd7..06e8dcfeff 100644 --- a/packages/server/src/api/controllers/query/import/sources/base/index.ts +++ b/packages/server/src/api/controllers/query/import/sources/base/index.ts @@ -1,5 +1,4 @@ - -import { Query, QueryParameter } from "../../../../../../definitions/common" +import { Query, QueryParameter } from "../../../../../../definitions/datasource" export interface ImportInfo { url: string diff --git a/packages/server/src/api/controllers/query/import/sources/openapi2.ts b/packages/server/src/api/controllers/query/import/sources/openapi2.ts index c13f1e2d2c..35dab163f6 100644 --- a/packages/server/src/api/controllers/query/import/sources/openapi2.ts +++ b/packages/server/src/api/controllers/query/import/sources/openapi2.ts @@ -1,5 +1,5 @@ import { ImportInfo } from "./base" -import { Query, QueryParameter } from "../../../../../definitions/common" +import { Query, QueryParameter } from "../../../../../definitions/datasource" import { OpenAPIV2 } from "openapi-types" import { OpenAPISource } from "./base/openapi" diff --git a/packages/server/src/definitions/common.ts b/packages/server/src/definitions/common.ts index 8181686411..472471855c 100644 --- a/packages/server/src/definitions/common.ts +++ b/packages/server/src/definitions/common.ts @@ -1,6 +1,6 @@ -import { SourceNames } from "./datasource" +export { Query, Datasource } from "./datasource" -interface Base { +export interface Base { _id?: string _rev?: string } @@ -93,39 +93,3 @@ export interface Automation extends Base { trigger?: AutomationStep } } - -export interface Datasource extends Base { - type: string - name: string - source: SourceNames - // the config is defined by the schema - config: { - [key: string]: string | number | boolean - } - plus: boolean - entities?: { - [key: string]: Table - } -} - -export interface QueryParameter { - name: string - default: string -} - -export interface Query { - _id?: string - datasourceId: string - name: string - parameters: QueryParameter[] - fields: { - headers: object - queryString: string | null - path: string - requestBody: string | undefined - } - transformer: string | null - schema: any - readable: boolean - queryVerb: string -} diff --git a/packages/server/src/definitions/datasource.ts b/packages/server/src/definitions/datasource.ts index eb65ac994f..0ca8fdcae9 100644 --- a/packages/server/src/definitions/datasource.ts +++ b/packages/server/src/definitions/datasource.ts @@ -1,4 +1,4 @@ -import { Row, Table } from "./common" +import { Row, Table, Base } from "./common" export enum Operation { CREATE = "CREATE", @@ -181,3 +181,52 @@ export interface SqlQuery { export interface QueryOptions { disableReturning?: boolean } + +export interface Datasource extends Base { + type: string + name: string + source: SourceNames + // the config is defined by the schema + config: { + [key: string]: string | number | boolean + } + plus: boolean + entities?: { + [key: string]: Table + } +} + +export interface QueryParameter { + name: string + default: string +} + +export interface RestQueryFields { + path: string + queryString?: string + headers: { [key: string]: any } + disabledHeaders: { [key: string]: any } + requestBody: any + bodyType: string + json: object + method: string +} + +export interface RestConfig { + url: string + defaultHeaders: { + [key: string]: any + } +} + +export interface Query { + _id?: string + datasourceId: string + name: string + parameters: QueryParameter[] + fields: RestQueryFields | any + transformer: string | null + schema: any + readable: boolean + queryVerb: string +} diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 2f5e2f4f48..10c2c1215b 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -2,6 +2,8 @@ import { Integration, DatasourceFieldTypes, QueryTypes, + RestConfig, + RestQueryFields as RestQuery, } from "../definitions/datasource" import { IntegrationBase } from "./base/IntegrationBase" @@ -41,24 +43,6 @@ module RestModule { const { formatBytes } = require("../utilities") const { performance } = require("perf_hooks") - interface RestQuery { - path: string - queryString?: string - headers: { [key: string]: any } - disabledHeaders: { [key: string]: any } - requestBody: any - bodyType: string - json: object - method: string - } - - interface RestConfig { - url: string - defaultHeaders: { - [key: string]: any - } - } - const SCHEMA: Integration = { docs: "https://github.com/node-fetch/node-fetch", description: