Move query to common definitions and add openapi-types to dev dependencies

This commit is contained in:
Rory Powell 2021-12-08 11:30:09 +00:00
parent 6b7f94a358
commit ee5c8ea449
6 changed files with 32 additions and 27 deletions

View File

@ -111,7 +111,6 @@
"mysql2": "^2.3.1", "mysql2": "^2.3.1",
"node-fetch": "2.6.0", "node-fetch": "2.6.0",
"open": "^8.4.0", "open": "^8.4.0",
"openapi-types": "^9.3.1",
"pg": "8.5.1", "pg": "8.5.1",
"pino-pretty": "4.0.0", "pino-pretty": "4.0.0",
"posthog-node": "^1.1.4", "posthog-node": "^1.1.4",
@ -150,6 +149,7 @@
"eslint": "^6.8.0", "eslint": "^6.8.0",
"jest": "^27.0.5", "jest": "^27.0.5",
"nodemon": "^2.0.4", "nodemon": "^2.0.4",
"openapi-types": "^9.3.1",
"path-to-regexp": "^6.2.0", "path-to-regexp": "^6.2.0",
"prettier": "^2.3.1", "prettier": "^2.3.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",

View File

@ -1,10 +1,10 @@
import CouchDB from "../../../../db" import CouchDB from "../../../../db"
import { queryValidation } from "../validation" import { queryValidation } from "../validation"
import { generateQueryID } from "../../../../db/utils" import { generateQueryID } from "../../../../db/utils"
import { Query, ImportInfo, ImportSource } from "./sources/base" import { ImportInfo, ImportSource } from "./sources/base"
import { OpenAPI2 } from "./sources/openapi2" import { OpenAPI2 } from "./sources/openapi2"
import { Query } from './../../../../definitions/common';
import { Curl } from "./sources/curl" import { Curl } from "./sources/curl"
interface ImportResult { interface ImportResult {
errorQueries: Query[] errorQueries: Query[]
queries: Query[] queries: Query[]

View File

@ -1,30 +1,11 @@
import { Query, QueryParameter } from "../../../../../../definitions/common"
export interface ImportInfo { export interface ImportInfo {
url: string url: string
name: string name: string
} }
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
}
enum MethodToVerb { enum MethodToVerb {
get = "read", get = "read",
post = "create", post = "create",

View File

@ -1,4 +1,5 @@
import { ImportSource, ImportInfo, Query } from "./base" import { ImportSource, ImportInfo } from "./base"
import { Query } from "../../../../../definitions/common"
import { URL } from "url" import { URL } from "url"
const curlconverter = require("curlconverter") const curlconverter = require("curlconverter")

View File

@ -1,4 +1,5 @@
import { ImportInfo, QueryParameter, Query } from "./base" import { ImportInfo } from "./base"
import { Query, QueryParameter } from "../../../../../definitions/common"
import { OpenAPIV2 } from "openapi-types" import { OpenAPIV2 } from "openapi-types"
import { OpenAPISource } from "./base/openapi" import { OpenAPISource } from "./base/openapi"

View File

@ -107,3 +107,25 @@ export interface Datasource extends Base {
[key: string]: Table [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
}