Formatting.
This commit is contained in:
parent
ffc54c3720
commit
aea08af49c
|
@ -1,29 +1,28 @@
|
|||
|
||||
export interface Table {
|
||||
_id: string,
|
||||
_rev?: string,
|
||||
type?: string,
|
||||
views?: {},
|
||||
name?: string,
|
||||
primary?: string[],
|
||||
_id: string
|
||||
_rev?: string
|
||||
type?: string
|
||||
views?: {}
|
||||
name?: string
|
||||
primary?: string[]
|
||||
schema: {
|
||||
[key: string]: {
|
||||
// TODO: replace with field types enum when done
|
||||
type: string,
|
||||
fieldName?: string,
|
||||
name: string,
|
||||
type: string
|
||||
fieldName?: string
|
||||
name: string
|
||||
constraints?: {
|
||||
type?: string,
|
||||
email?: boolean,
|
||||
inclusion?: string[],
|
||||
type?: string
|
||||
email?: boolean
|
||||
inclusion?: string[]
|
||||
length?: {
|
||||
minimum?: string | number,
|
||||
maximum?: string | number,
|
||||
},
|
||||
presence?: boolean,
|
||||
},
|
||||
minimum?: string | number
|
||||
maximum?: string | number
|
||||
}
|
||||
},
|
||||
primaryDisplay?: string,
|
||||
sourceId?: string,
|
||||
presence?: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
primaryDisplay?: string
|
||||
sourceId?: string
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module AirtableModule {
|
||||
const Airtable = require("airtable")
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module ArangoModule {
|
||||
const { Database, aql } = require("arangojs")
|
||||
|
|
|
@ -27,76 +27,76 @@ export enum DatasourceFieldTypes {
|
|||
}
|
||||
|
||||
export interface QueryDefinition {
|
||||
type: QueryTypes,
|
||||
displayName?: string,
|
||||
readable?: boolean,
|
||||
customisable?: boolean,
|
||||
fields?: object,
|
||||
urlDisplay?: boolean,
|
||||
type: QueryTypes
|
||||
displayName?: string
|
||||
readable?: boolean
|
||||
customisable?: boolean
|
||||
fields?: object
|
||||
urlDisplay?: boolean
|
||||
}
|
||||
|
||||
export interface Integration {
|
||||
docs: string,
|
||||
plus?: boolean,
|
||||
description: string,
|
||||
friendlyName: string,
|
||||
datasource: {},
|
||||
docs: string
|
||||
plus?: boolean
|
||||
description: string
|
||||
friendlyName: string
|
||||
datasource: {}
|
||||
query: {
|
||||
[key: string]: QueryDefinition,
|
||||
[key: string]: QueryDefinition
|
||||
}
|
||||
}
|
||||
|
||||
export interface SearchFilters {
|
||||
allOr: boolean,
|
||||
allOr: boolean
|
||||
string?: {
|
||||
[key: string]: string,
|
||||
},
|
||||
[key: string]: string
|
||||
}
|
||||
fuzzy?: {
|
||||
[key: string]: string,
|
||||
},
|
||||
[key: string]: string
|
||||
}
|
||||
range?: {
|
||||
[key: string]: {
|
||||
high: number | string,
|
||||
low: number | string,
|
||||
},
|
||||
},
|
||||
high: number | string
|
||||
low: number | string
|
||||
}
|
||||
}
|
||||
equal?: {
|
||||
[key: string]: any,
|
||||
},
|
||||
[key: string]: any
|
||||
}
|
||||
notEqual?: {
|
||||
[key: string]: any,
|
||||
},
|
||||
[key: string]: any
|
||||
}
|
||||
empty?: {
|
||||
[key: string]: any,
|
||||
},
|
||||
[key: string]: any
|
||||
}
|
||||
notEmpty?: {
|
||||
[key: string]: any,
|
||||
},
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
export interface QueryJson {
|
||||
endpoint: {
|
||||
datasourceId: string,
|
||||
entityId: string,
|
||||
operation: Operation,
|
||||
},
|
||||
datasourceId: string
|
||||
entityId: string
|
||||
operation: Operation
|
||||
}
|
||||
resource: {
|
||||
fields: string[],
|
||||
},
|
||||
filters?: SearchFilters,
|
||||
fields: string[]
|
||||
}
|
||||
filters?: SearchFilters
|
||||
sort?: {
|
||||
[key: string]: SortDirection,
|
||||
},
|
||||
[key: string]: SortDirection
|
||||
}
|
||||
paginate?: {
|
||||
limit: number,
|
||||
page: string | number,
|
||||
},
|
||||
body?: object,
|
||||
limit: number
|
||||
page: string | number
|
||||
}
|
||||
body?: object
|
||||
extra: {
|
||||
idFilter?: SearchFilters,
|
||||
},
|
||||
idFilter?: SearchFilters
|
||||
}
|
||||
}
|
||||
|
||||
export interface QueryOptions {
|
||||
disableReturning?: boolean,
|
||||
disableReturning?: boolean
|
||||
}
|
|
@ -1,10 +1,21 @@
|
|||
import { Knex, knex } from "knex"
|
||||
const BASE_LIMIT = 5000
|
||||
import { QueryJson, SearchFilters, QueryOptions, SortDirection, Operation } from "./definitions"
|
||||
import {
|
||||
QueryJson,
|
||||
SearchFilters,
|
||||
QueryOptions,
|
||||
SortDirection,
|
||||
Operation,
|
||||
} from "./definitions"
|
||||
|
||||
|
||||
function addFilters(query: any, filters: SearchFilters | undefined): Knex.QueryBuilder {
|
||||
function iterate(structure: { [key: string]: any }, fn: (key: string, value: any) => void) {
|
||||
function addFilters(
|
||||
query: any,
|
||||
filters: SearchFilters | undefined
|
||||
): Knex.QueryBuilder {
|
||||
function iterate(
|
||||
structure: { [key: string]: any },
|
||||
fn: (key: string, value: any) => void
|
||||
) {
|
||||
for (let [key, value] of Object.entries(structure)) {
|
||||
fn(key, value)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module CouchDBModule {
|
||||
const PouchDB = require("pouchdb")
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module DynamoModule {
|
||||
const AWS = require("aws-sdk")
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module ElasticsearchModule {
|
||||
const { Client } = require("@elastic/elasticsearch")
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import {Integration, DatasourceFieldTypes, QueryTypes, QueryJson} from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
QueryJson,
|
||||
} from "./base/definitions"
|
||||
|
||||
module MSSQLModule {
|
||||
const sqlServer = require("mssql")
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module MongoDBModule {
|
||||
const { MongoClient } = require("mongodb")
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes, Operation, QueryJson } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
Operation,
|
||||
QueryJson,
|
||||
} from "./base/definitions"
|
||||
|
||||
module MySQLModule {
|
||||
const mysql = require("mysql")
|
||||
|
@ -141,7 +147,9 @@ module MySQLModule {
|
|||
{ sql: "SHOW TABLES;" },
|
||||
false
|
||||
)
|
||||
const tableNames = tablesResp.map((obj: any) => obj[`Tables_in_${database}`])
|
||||
const tableNames = tablesResp.map(
|
||||
(obj: any) => obj[`Tables_in_${database}`]
|
||||
)
|
||||
for (let tableName of tableNames) {
|
||||
const primaryKeys = []
|
||||
const schema: any = {}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes, QueryJson } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
QueryJson,
|
||||
} from "./base/definitions"
|
||||
import { Table } from "../constants/definitions"
|
||||
|
||||
module PostgresModule {
|
||||
|
@ -8,12 +13,12 @@ module PostgresModule {
|
|||
const { buildExternalTableId, convertType } = require("./utils")
|
||||
|
||||
interface PostgresConfig {
|
||||
host: string,
|
||||
port: number,
|
||||
database: string,
|
||||
user: string,
|
||||
password: string,
|
||||
ssl?: boolean,
|
||||
host: string
|
||||
port: number
|
||||
database: string
|
||||
user: string
|
||||
password: string
|
||||
ssl?: boolean
|
||||
}
|
||||
|
||||
const SCHEMA: Integration = {
|
||||
|
@ -83,7 +88,10 @@ module PostgresModule {
|
|||
json: FieldTypes.JSON,
|
||||
}
|
||||
|
||||
async function internalQuery(client: any, query: { sql: string, bindings?: object }) {
|
||||
async function internalQuery(
|
||||
client: any,
|
||||
query: { sql: string; bindings?: object }
|
||||
) {
|
||||
try {
|
||||
return await client.query(query.sql, query.bindings || {})
|
||||
} catch (err) {
|
||||
|
@ -131,7 +139,9 @@ module PostgresModule {
|
|||
async buildSchema(datasourceId: string) {
|
||||
let tableKeys: { [key: string]: string[] } = {}
|
||||
try {
|
||||
const primaryKeysResponse = await this.client.query(this.PRIMARY_KEYS_SQL)
|
||||
const primaryKeysResponse = await this.client.query(
|
||||
this.PRIMARY_KEYS_SQL
|
||||
)
|
||||
for (let table of primaryKeysResponse.rows) {
|
||||
const tableName = table.table_name
|
||||
if (!tableKeys[tableName]) {
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import { Integration, DatasourceFieldTypes, QueryTypes } from "./base/definitions"
|
||||
import {
|
||||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
|
||||
module RestModule {
|
||||
const fetch = require("node-fetch")
|
||||
|
||||
interface RestConfig {
|
||||
url: string,
|
||||
url: string
|
||||
defaultHeaders: {
|
||||
[key: string]: any,
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ module S3Module {
|
|||
const AWS = require("aws-sdk")
|
||||
|
||||
interface S3Config {
|
||||
region: string,
|
||||
accessKeyId: string,
|
||||
secretAccessKey: string,
|
||||
region: string
|
||||
accessKeyId: string
|
||||
secretAccessKey: string
|
||||
}
|
||||
|
||||
const SCHEMA: Integration = {
|
||||
|
|
Loading…
Reference in New Issue