2021-12-13 14:50:15 +01:00
|
|
|
import { Row, Table, Base } from "./common"
|
2021-09-23 17:17:23 +02:00
|
|
|
|
2021-06-24 19:16:48 +02:00
|
|
|
export enum Operation {
|
|
|
|
CREATE = "CREATE",
|
|
|
|
READ = "READ",
|
|
|
|
UPDATE = "UPDATE",
|
|
|
|
DELETE = "DELETE",
|
2021-11-12 20:24:56 +01:00
|
|
|
BULK_CREATE = "BULK_CREATE",
|
2021-10-28 20:39:42 +02:00
|
|
|
CREATE_TABLE = "CREATE_TABLE",
|
|
|
|
UPDATE_TABLE = "UPDATE_TABLE",
|
|
|
|
DELETE_TABLE = "DELETE_TABLE",
|
2021-06-24 19:16:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum SortDirection {
|
|
|
|
ASCENDING = "ASCENDING",
|
|
|
|
DESCENDING = "DESCENDING",
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum QueryTypes {
|
|
|
|
SQL = "sql",
|
|
|
|
JSON = "json",
|
|
|
|
FIELDS = "fields",
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum DatasourceFieldTypes {
|
|
|
|
STRING = "string",
|
2021-10-12 17:13:54 +02:00
|
|
|
LONGFORM = "longForm",
|
2021-06-24 19:16:48 +02:00
|
|
|
BOOLEAN = "boolean",
|
|
|
|
NUMBER = "number",
|
|
|
|
PASSWORD = "password",
|
|
|
|
LIST = "list",
|
|
|
|
OBJECT = "object",
|
|
|
|
JSON = "json",
|
2021-10-12 17:13:54 +02:00
|
|
|
FILE = "file",
|
2021-06-24 19:16:48 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 12:15:01 +02:00
|
|
|
export enum SourceNames {
|
|
|
|
POSTGRES = "POSTGRES",
|
|
|
|
DYNAMODB = "DYNAMODB",
|
|
|
|
MONGODB = "MONGODB",
|
|
|
|
ELASTICSEARCH = "ELASTICSEARCH",
|
|
|
|
COUCHDB = "COUCHDB",
|
|
|
|
SQL_SERVER = "SQL_SERVER",
|
|
|
|
S3 = "S3",
|
|
|
|
AIRTABLE = "AIRTABLE",
|
|
|
|
MYSQL = "MYSQL",
|
|
|
|
ARANGODB = "ARANGODB",
|
|
|
|
REST = "REST",
|
2021-11-05 14:56:54 +01:00
|
|
|
ORACLE = "ORACLE",
|
2021-11-25 18:12:12 +01:00
|
|
|
GOOGLE_SHEETS = "GOOGLE_SHEETS",
|
2022-03-08 17:31:36 +01:00
|
|
|
FIREBASE = "FIREBASE",
|
2021-07-03 12:15:01 +02:00
|
|
|
}
|
|
|
|
|
2021-09-01 20:40:47 +02:00
|
|
|
export enum IncludeRelationships {
|
|
|
|
INCLUDE = 1,
|
2021-09-06 17:24:51 +02:00
|
|
|
EXCLUDE = 0,
|
2021-09-01 20:40:47 +02:00
|
|
|
}
|
|
|
|
|
2021-11-26 18:08:56 +01:00
|
|
|
export enum FilterTypes {
|
|
|
|
STRING = "string",
|
|
|
|
FUZZY = "fuzzy",
|
|
|
|
RANGE = "range",
|
|
|
|
EQUAL = "equal",
|
|
|
|
NOT_EQUAL = "notEqual",
|
|
|
|
EMPTY = "empty",
|
|
|
|
NOT_EMPTY = "notEmpty",
|
|
|
|
ONE_OF = "oneOf",
|
|
|
|
}
|
|
|
|
|
2021-06-24 19:16:48 +02:00
|
|
|
export interface QueryDefinition {
|
2021-06-25 19:34:21 +02:00
|
|
|
type: QueryTypes
|
|
|
|
displayName?: string
|
|
|
|
readable?: boolean
|
|
|
|
customisable?: boolean
|
|
|
|
fields?: object
|
|
|
|
urlDisplay?: boolean
|
2021-06-24 19:16:48 +02:00
|
|
|
}
|
|
|
|
|
2021-07-08 14:38:49 +02:00
|
|
|
export interface ExtraQueryConfig {
|
|
|
|
[key: string]: {
|
2021-07-29 11:11:52 +02:00
|
|
|
displayName: string
|
|
|
|
type: string
|
2021-07-08 14:38:49 +02:00
|
|
|
required: boolean
|
|
|
|
data?: object
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-24 19:16:48 +02:00
|
|
|
export interface Integration {
|
2021-06-25 19:34:21 +02:00
|
|
|
docs: string
|
|
|
|
plus?: boolean
|
2022-01-18 17:41:38 +01:00
|
|
|
auth?: { type: string }
|
2022-01-26 17:45:28 +01:00
|
|
|
relationships?: boolean
|
2021-06-25 19:34:21 +02:00
|
|
|
description: string
|
|
|
|
friendlyName: string
|
|
|
|
datasource: {}
|
2021-06-24 19:16:48 +02:00
|
|
|
query: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: QueryDefinition
|
|
|
|
}
|
2021-07-08 14:38:49 +02:00
|
|
|
extra?: ExtraQueryConfig
|
2021-06-24 19:16:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchFilters {
|
2021-07-01 20:20:41 +02:00
|
|
|
allOr?: boolean
|
2021-06-24 19:16:48 +02:00
|
|
|
string?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: string
|
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
fuzzy?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: string
|
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
range?: {
|
|
|
|
[key: string]: {
|
2021-06-25 19:34:21 +02:00
|
|
|
high: number | string
|
|
|
|
low: number | string
|
|
|
|
}
|
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
equal?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: any
|
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
notEqual?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: any
|
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
empty?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: any
|
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
notEmpty?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
[key: string]: any
|
|
|
|
}
|
2021-07-01 15:10:44 +02:00
|
|
|
oneOf?: {
|
|
|
|
[key: string]: any[]
|
|
|
|
}
|
2021-06-25 19:13:11 +02:00
|
|
|
}
|
|
|
|
|
2021-07-01 20:20:41 +02:00
|
|
|
export interface SortJson {
|
|
|
|
[key: string]: SortDirection
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PaginationJson {
|
|
|
|
limit: number
|
2021-11-05 19:55:36 +01:00
|
|
|
page?: string | number
|
2021-07-01 20:20:41 +02:00
|
|
|
}
|
|
|
|
|
2022-03-07 17:31:35 +01:00
|
|
|
export interface RenameColumn {
|
|
|
|
old: string
|
|
|
|
updated: string
|
|
|
|
}
|
|
|
|
|
2021-06-25 19:13:11 +02:00
|
|
|
export interface RelationshipsJson {
|
2021-06-28 13:36:05 +02:00
|
|
|
through?: string
|
2021-07-01 20:20:41 +02:00
|
|
|
from?: string
|
|
|
|
to?: string
|
2021-10-01 18:16:43 +02:00
|
|
|
fromPrimary?: string
|
|
|
|
toPrimary?: string
|
2021-06-25 19:34:21 +02:00
|
|
|
tableName: string
|
2021-07-01 20:20:41 +02:00
|
|
|
column: string
|
2021-06-24 19:16:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface QueryJson {
|
|
|
|
endpoint: {
|
2021-06-25 19:34:21 +02:00
|
|
|
datasourceId: string
|
|
|
|
entityId: string
|
|
|
|
operation: Operation
|
2022-03-04 16:12:07 +01:00
|
|
|
schema?: string
|
2021-06-25 19:34:21 +02:00
|
|
|
}
|
2021-06-24 19:16:48 +02:00
|
|
|
resource: {
|
2021-06-25 19:34:21 +02:00
|
|
|
fields: string[]
|
|
|
|
}
|
|
|
|
filters?: SearchFilters
|
2021-07-01 20:20:41 +02:00
|
|
|
sort?: SortJson
|
|
|
|
paginate?: PaginationJson
|
2021-11-12 20:24:56 +01:00
|
|
|
body?: Row | Row[]
|
2021-10-28 20:39:42 +02:00
|
|
|
table?: Table
|
2021-09-23 17:17:23 +02:00
|
|
|
meta?: {
|
2021-09-27 15:57:22 +02:00
|
|
|
table?: Table
|
2021-10-28 20:39:42 +02:00
|
|
|
tables?: Record<string, Table>
|
2022-03-07 17:31:35 +01:00
|
|
|
renamed: RenameColumn
|
2021-09-23 17:17:23 +02:00
|
|
|
}
|
2021-06-25 19:13:11 +02:00
|
|
|
extra?: {
|
2021-06-25 19:34:21 +02:00
|
|
|
idFilter?: SearchFilters
|
|
|
|
}
|
|
|
|
relationships?: RelationshipsJson[]
|
2021-06-24 19:16:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-25 14:46:02 +02:00
|
|
|
export interface SqlQuery {
|
2021-06-25 19:34:21 +02:00
|
|
|
sql: string
|
2022-03-30 15:31:17 +02:00
|
|
|
bindings?: string[]
|
2021-06-25 14:46:02 +02:00
|
|
|
}
|
|
|
|
|
2021-06-24 19:16:48 +02:00
|
|
|
export interface QueryOptions {
|
2021-06-25 19:34:21 +02:00
|
|
|
disableReturning?: boolean
|
2021-06-24 19:17:26 +02:00
|
|
|
}
|
2021-12-13 14:50:15 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-14 10:52:16 +01:00
|
|
|
export enum AuthType {
|
|
|
|
BASIC = "basic",
|
|
|
|
BEARER = "bearer",
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AuthConfig {
|
|
|
|
_id: string
|
|
|
|
name: string
|
|
|
|
type: AuthType
|
|
|
|
config: BasicAuthConfig | BearerAuthConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BasicAuthConfig {
|
|
|
|
username: string
|
|
|
|
password: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface BearerAuthConfig {
|
|
|
|
token: string
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:50:15 +01:00
|
|
|
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
|
2021-12-14 10:52:16 +01:00
|
|
|
authConfigId: string
|
2021-12-17 19:59:24 +01:00
|
|
|
pagination: PaginationConfig | null
|
2022-01-05 10:16:10 +01:00
|
|
|
paginationValues: PaginationValues | null
|
2021-12-13 14:50:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RestConfig {
|
|
|
|
url: string
|
|
|
|
defaultHeaders: {
|
|
|
|
[key: string]: any
|
|
|
|
}
|
2021-12-14 10:52:16 +01:00
|
|
|
authConfigs: AuthConfig[]
|
2022-01-04 19:23:45 +01:00
|
|
|
staticVariables: {
|
|
|
|
[key: string]: string
|
|
|
|
}
|
|
|
|
dynamicVariables: [
|
|
|
|
{
|
|
|
|
name: string
|
|
|
|
queryId: string
|
|
|
|
value: string
|
|
|
|
}
|
|
|
|
]
|
2021-12-13 14:50:15 +01:00
|
|
|
}
|
|
|
|
|
2021-12-17 19:59:24 +01:00
|
|
|
export interface PaginationConfig {
|
|
|
|
type: string
|
2022-01-05 10:16:10 +01:00
|
|
|
location: string
|
2021-12-17 19:59:24 +01:00
|
|
|
pageParam: string
|
|
|
|
sizeParam: string | null
|
|
|
|
responseParam: string | null
|
|
|
|
}
|
|
|
|
|
2022-01-05 10:16:10 +01:00
|
|
|
export interface PaginationValues {
|
|
|
|
page: string | number | null
|
|
|
|
limit: number | null
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:50:15 +01:00
|
|
|
export interface Query {
|
|
|
|
_id?: string
|
|
|
|
datasourceId: string
|
|
|
|
name: string
|
|
|
|
parameters: QueryParameter[]
|
|
|
|
fields: RestQueryFields | any
|
|
|
|
transformer: string | null
|
|
|
|
schema: any
|
|
|
|
readable: boolean
|
|
|
|
queryVerb: string
|
|
|
|
}
|