Browse Source

Moving Typescript definitions around a bit.

pull/4434/head
mike12345567 5 years ago
parent
commit
b11e4bd2df
  1. 3
      packages/server/src/api/controllers/query/import/sources/base/index.ts
  2. 2
      packages/server/src/api/controllers/query/import/sources/openapi2.ts
  3. 40
      packages/server/src/definitions/common.ts
  4. 51
      packages/server/src/definitions/datasource.ts
  5. 20
      packages/server/src/integrations/rest.ts

3
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

2
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"

40
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
}

51
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
}

20
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:

Loading…
Cancel
Save