Moving definitions to central location and adding a few more definitions.
This commit is contained in:
parent
f23f61c89a
commit
5389878801
|
@ -1,28 +0,0 @@
|
|||
export interface Table {
|
||||
_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
|
||||
constraints?: {
|
||||
type?: string
|
||||
email?: boolean
|
||||
inclusion?: string[]
|
||||
length?: {
|
||||
minimum?: string | number
|
||||
maximum?: string | number
|
||||
}
|
||||
presence?: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
primaryDisplay?: string
|
||||
sourceId?: string
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
interface Base {
|
||||
_id?: string,
|
||||
_rev?: string,
|
||||
}
|
||||
|
||||
export interface TableSchema {
|
||||
[key: string]: {
|
||||
// TODO: replace with field types enum when done
|
||||
type: string,
|
||||
fieldName?: string,
|
||||
name: string,
|
||||
constraints?: {
|
||||
type?: string,
|
||||
email?: boolean,
|
||||
inclusion?: string[],
|
||||
length?: {
|
||||
minimum?: string | number,
|
||||
maximum?: string | number,
|
||||
},
|
||||
presence?: boolean,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export interface Table extends Base {
|
||||
type?: string,
|
||||
views?: {},
|
||||
name?: string,
|
||||
primary?: string[],
|
||||
schema: TableSchema,
|
||||
primaryDisplay?: string,
|
||||
sourceId?: string,
|
||||
}
|
||||
|
||||
export interface Row extends Base {
|
||||
type?: string,
|
||||
tableId: string,
|
||||
[key: string]: any,
|
||||
}
|
||||
|
||||
interface JsonSchemaField {
|
||||
properties: {
|
||||
[key: string]: {
|
||||
type: string,
|
||||
title: string,
|
||||
customType?: string,
|
||||
},
|
||||
},
|
||||
required?: string[],
|
||||
}
|
||||
|
||||
export interface AutomationStep {
|
||||
description: string,
|
||||
event?: string,
|
||||
icon: string,
|
||||
id: string,
|
||||
inputs: {
|
||||
[key: string]: any,
|
||||
},
|
||||
name: string,
|
||||
schema: {
|
||||
inputs: JsonSchemaField,
|
||||
outputs: JsonSchemaField,
|
||||
},
|
||||
stepId: string,
|
||||
tagline: string,
|
||||
type: string,
|
||||
}
|
||||
|
||||
export interface Automation extends Base {
|
||||
name: string,
|
||||
type: string,
|
||||
appId?: string,
|
||||
definition: {
|
||||
steps: AutomationStep[],
|
||||
trigger?: AutomationStep,
|
||||
},
|
||||
}
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module AirtableModule {
|
||||
const Airtable = require("airtable")
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module ArangoModule {
|
||||
const { Database, aql } = require("arangojs")
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
SortDirection,
|
||||
Operation,
|
||||
RelationshipsJson,
|
||||
} from "./definitions"
|
||||
} from "../../definitions/datasource"
|
||||
|
||||
type KnexQuery = Knex.QueryBuilder | Knex
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module CouchDBModule {
|
||||
const PouchDB = require("pouchdb")
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module DynamoModule {
|
||||
const AWS = require("aws-sdk")
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module ElasticsearchModule {
|
||||
const { Client } = require("@elastic/elasticsearch")
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
QueryTypes,
|
||||
QueryJson,
|
||||
SqlQuery,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
import { getSqlQuery } from "./utils"
|
||||
|
||||
module MSSQLModule {
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module MongoDBModule {
|
||||
const { MongoClient } = require("mongodb")
|
||||
|
|
|
@ -5,7 +5,11 @@ import {
|
|||
Operation,
|
||||
QueryJson,
|
||||
SqlQuery,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
import {
|
||||
Table,
|
||||
TableSchema,
|
||||
} from "../definitions/common"
|
||||
import { getSqlQuery } from "./utils"
|
||||
|
||||
module MySQLModule {
|
||||
|
@ -139,7 +143,7 @@ module MySQLModule {
|
|||
}
|
||||
|
||||
async buildSchema(datasourceId: string) {
|
||||
const tables: any = {}
|
||||
const tables: { [key: string]: Table } = {}
|
||||
const database = this.config.database
|
||||
this.client.connect()
|
||||
|
||||
|
@ -154,7 +158,7 @@ module MySQLModule {
|
|||
)
|
||||
for (let tableName of tableNames) {
|
||||
const primaryKeys = []
|
||||
const schema: any = {}
|
||||
const schema: TableSchema = {}
|
||||
const descResp = await internalQuery(
|
||||
this.client,
|
||||
{ sql: `DESCRIBE ${tableName};` },
|
||||
|
@ -166,7 +170,7 @@ module MySQLModule {
|
|||
primaryKeys.push(columnName)
|
||||
}
|
||||
const constraints = {
|
||||
required: column.Null !== "YES",
|
||||
presence: column.Null !== "YES",
|
||||
}
|
||||
schema[columnName] = {
|
||||
name: columnName,
|
||||
|
@ -212,7 +216,7 @@ module MySQLModule {
|
|||
}
|
||||
|
||||
async getReturningRow(json: QueryJson) {
|
||||
if (!json.extra.idFilter) {
|
||||
if (!json.extra || !json.extra.idFilter) {
|
||||
return {}
|
||||
}
|
||||
const input = this._query({
|
||||
|
|
|
@ -4,8 +4,8 @@ import {
|
|||
QueryTypes,
|
||||
QueryJson,
|
||||
SqlQuery,
|
||||
} from "./base/definitions"
|
||||
import { Table } from "../constants/definitions"
|
||||
} from "../definitions/datasource"
|
||||
import { Table } from "../definitions/common"
|
||||
import { getSqlQuery } from "./utils"
|
||||
|
||||
module PostgresModule {
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
Integration,
|
||||
DatasourceFieldTypes,
|
||||
QueryTypes,
|
||||
} from "./base/definitions"
|
||||
} from "../definitions/datasource"
|
||||
|
||||
module RestModule {
|
||||
const fetch = require("node-fetch")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Integration, QueryTypes } from "./base/definitions"
|
||||
import { Integration, QueryTypes } from "../definitions/datasource"
|
||||
|
||||
module S3Module {
|
||||
const AWS = require("aws-sdk")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { SqlQuery } from "./base/definitions"
|
||||
import { SqlQuery } from "../definitions/datasource"
|
||||
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
||||
const { FieldTypes } = require("../constants")
|
||||
|
||||
|
|
Loading…
Reference in New Issue