forked from tsai/budibase
27 changed files with 374 additions and 378 deletions
@ -1,6 +0,0 @@ |
|||||
export interface IntegrationBase { |
|
||||
create?(query: any): Promise<any[] | any> |
|
||||
read?(query: any): Promise<any[] | any> |
|
||||
update?(query: any): Promise<any[] | any> |
|
||||
delete?(query: any): Promise<any[] | any> |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
import { Table } from "../../definitions/common" |
|
||||
import { IntegrationBase } from "./IntegrationBase" |
|
||||
|
|
||||
export interface DatasourcePlus extends IntegrationBase { |
|
||||
tables: Record<string, Table> |
|
||||
schemaErrors: Record<string, string> |
|
||||
|
|
||||
// if the datasource supports the use of bindings directly (to protect against SQL injection)
|
|
||||
// this returns the format of the identifier
|
|
||||
getBindingIdentifier(): string |
|
||||
getStringConcat(parts: string[]): string |
|
||||
buildSchema(datasourceId: string, entities: Record<string, Table>): any |
|
||||
} |
|
||||
@ -1,5 +1,17 @@ |
|||||
import { Document } from "../document" |
import { Document } from "../document" |
||||
|
import { SourceNames } from "../../sdk" |
||||
|
import { Table } from "./table" |
||||
|
|
||||
export interface Datasource extends Document { |
export interface Datasource extends Document { |
||||
source: string |
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 |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,3 +1,23 @@ |
|||||
import { Document } from "../document" |
import { Document } from "../document" |
||||
|
|
||||
export interface Row extends Document {} |
export enum FieldTypes { |
||||
|
STRING = "string", |
||||
|
LONGFORM = "longform", |
||||
|
OPTIONS = "options", |
||||
|
NUMBER = "number", |
||||
|
BOOLEAN = "boolean", |
||||
|
ARRAY = "array", |
||||
|
DATETIME = "datetime", |
||||
|
ATTACHMENT = "attachment", |
||||
|
LINK = "link", |
||||
|
FORMULA = "formula", |
||||
|
AUTO = "auto", |
||||
|
JSON = "json", |
||||
|
INTERNAL = "internal", |
||||
|
} |
||||
|
|
||||
|
export interface Row extends Document { |
||||
|
type?: string |
||||
|
tableId?: string |
||||
|
[key: string]: any |
||||
|
} |
||||
|
|||||
@ -1,6 +1,52 @@ |
|||||
import { Document } from "../document" |
import { Document } from "../document" |
||||
import { View } from "./view" |
import { View } from "./view" |
||||
|
|
||||
|
export interface FieldSchema { |
||||
|
// TODO: replace with field types enum when done
|
||||
|
type: string |
||||
|
externalType?: string |
||||
|
fieldName?: string |
||||
|
name: string |
||||
|
tableId?: string |
||||
|
relationshipType?: string |
||||
|
through?: string |
||||
|
foreignKey?: string |
||||
|
autocolumn?: boolean |
||||
|
subtype?: string |
||||
|
throughFrom?: string |
||||
|
throughTo?: string |
||||
|
formula?: string |
||||
|
formulaType?: string |
||||
|
main?: boolean |
||||
|
ignoreTimezones?: boolean |
||||
|
meta?: { |
||||
|
toTable: string |
||||
|
toKey: string |
||||
|
} |
||||
|
constraints?: { |
||||
|
type?: string |
||||
|
email?: boolean |
||||
|
inclusion?: string[] |
||||
|
length?: { |
||||
|
minimum?: string | number |
||||
|
maximum?: string | number |
||||
|
} |
||||
|
presence?: boolean |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export interface TableSchema { |
||||
|
[key: string]: FieldSchema |
||||
|
} |
||||
|
|
||||
export interface Table extends Document { |
export interface Table extends Document { |
||||
views: { [key: string]: View } |
type?: string |
||||
|
views?: { [key: string]: View } |
||||
|
name: string |
||||
|
primary?: string[] |
||||
|
schema: TableSchema |
||||
|
primaryDisplay?: string |
||||
|
sourceId?: string |
||||
|
relatedFormula?: string[] |
||||
|
constrained?: string[] |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,121 @@ |
|||||
|
import { Table } from "../documents" |
||||
|
|
||||
|
export enum Operation { |
||||
|
CREATE = "CREATE", |
||||
|
READ = "READ", |
||||
|
UPDATE = "UPDATE", |
||||
|
DELETE = "DELETE", |
||||
|
BULK_CREATE = "BULK_CREATE", |
||||
|
CREATE_TABLE = "CREATE_TABLE", |
||||
|
UPDATE_TABLE = "UPDATE_TABLE", |
||||
|
DELETE_TABLE = "DELETE_TABLE", |
||||
|
} |
||||
|
|
||||
|
export enum SortDirection { |
||||
|
ASCENDING = "ASCENDING", |
||||
|
DESCENDING = "DESCENDING", |
||||
|
} |
||||
|
|
||||
|
export enum QueryTypes { |
||||
|
SQL = "sql", |
||||
|
JSON = "json", |
||||
|
FIELDS = "fields", |
||||
|
} |
||||
|
|
||||
|
export enum DatasourceFieldTypes { |
||||
|
STRING = "string", |
||||
|
LONGFORM = "longForm", |
||||
|
BOOLEAN = "boolean", |
||||
|
NUMBER = "number", |
||||
|
PASSWORD = "password", |
||||
|
LIST = "list", |
||||
|
OBJECT = "object", |
||||
|
JSON = "json", |
||||
|
FILE = "file", |
||||
|
} |
||||
|
|
||||
|
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", |
||||
|
ORACLE = "ORACLE", |
||||
|
GOOGLE_SHEETS = "GOOGLE_SHEETS", |
||||
|
FIRESTORE = "FIRESTORE", |
||||
|
REDIS = "REDIS", |
||||
|
SNOWFLAKE = "SNOWFLAKE", |
||||
|
} |
||||
|
|
||||
|
export enum IncludeRelationships { |
||||
|
INCLUDE = 1, |
||||
|
EXCLUDE = 0, |
||||
|
} |
||||
|
|
||||
|
export enum FilterTypes { |
||||
|
STRING = "string", |
||||
|
FUZZY = "fuzzy", |
||||
|
RANGE = "range", |
||||
|
EQUAL = "equal", |
||||
|
NOT_EQUAL = "notEqual", |
||||
|
EMPTY = "empty", |
||||
|
NOT_EMPTY = "notEmpty", |
||||
|
ONE_OF = "oneOf", |
||||
|
} |
||||
|
|
||||
|
export interface QueryDefinition { |
||||
|
type: QueryTypes |
||||
|
displayName?: string |
||||
|
readable?: boolean |
||||
|
customisable?: boolean |
||||
|
fields?: object |
||||
|
urlDisplay?: boolean |
||||
|
} |
||||
|
|
||||
|
export interface ExtraQueryConfig { |
||||
|
[key: string]: { |
||||
|
displayName: string |
||||
|
type: string |
||||
|
required: boolean |
||||
|
data?: object |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export interface Integration { |
||||
|
docs: string |
||||
|
plus?: boolean |
||||
|
auth?: { type: string } |
||||
|
relationships?: boolean |
||||
|
description: string |
||||
|
friendlyName: string |
||||
|
type?: string |
||||
|
datasource: {} |
||||
|
query: { |
||||
|
[key: string]: QueryDefinition |
||||
|
} |
||||
|
extra?: ExtraQueryConfig |
||||
|
} |
||||
|
|
||||
|
export interface IntegrationBase { |
||||
|
create?(query: any): Promise<any[] | any> |
||||
|
read?(query: any): Promise<any[] | any> |
||||
|
update?(query: any): Promise<any[] | any> |
||||
|
delete?(query: any): Promise<any[] | any> |
||||
|
} |
||||
|
|
||||
|
export interface DatasourcePlus extends IntegrationBase { |
||||
|
tables: Record<string, Table> |
||||
|
schemaErrors: Record<string, string> |
||||
|
|
||||
|
// if the datasource supports the use of bindings directly (to protect against SQL injection)
|
||||
|
// this returns the format of the identifier
|
||||
|
getBindingIdentifier(): string |
||||
|
getStringConcat(parts: string[]): string |
||||
|
buildSchema(datasourceId: string, entities: Record<string, Table>): any |
||||
|
} |
||||
@ -0,0 +1,91 @@ |
|||||
|
import { Operation, SortDirection } from "./datasources" |
||||
|
import { Row, Table } from "../documents" |
||||
|
|
||||
|
export interface SearchFilters { |
||||
|
allOr?: boolean |
||||
|
string?: { |
||||
|
[key: string]: string |
||||
|
} |
||||
|
fuzzy?: { |
||||
|
[key: string]: string |
||||
|
} |
||||
|
range?: { |
||||
|
[key: string]: { |
||||
|
high: number | string |
||||
|
low: number | string |
||||
|
} |
||||
|
} |
||||
|
equal?: { |
||||
|
[key: string]: any |
||||
|
} |
||||
|
notEqual?: { |
||||
|
[key: string]: any |
||||
|
} |
||||
|
empty?: { |
||||
|
[key: string]: any |
||||
|
} |
||||
|
notEmpty?: { |
||||
|
[key: string]: any |
||||
|
} |
||||
|
oneOf?: { |
||||
|
[key: string]: any[] |
||||
|
} |
||||
|
contains?: { |
||||
|
[key: string]: any |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export interface SortJson { |
||||
|
[key: string]: SortDirection |
||||
|
} |
||||
|
|
||||
|
export interface PaginationJson { |
||||
|
limit: number |
||||
|
page?: string | number |
||||
|
} |
||||
|
|
||||
|
export interface RenameColumn { |
||||
|
old: string |
||||
|
updated: string |
||||
|
} |
||||
|
|
||||
|
export interface RelationshipsJson { |
||||
|
through?: string |
||||
|
from?: string |
||||
|
to?: string |
||||
|
fromPrimary?: string |
||||
|
toPrimary?: string |
||||
|
tableName: string |
||||
|
column: string |
||||
|
} |
||||
|
|
||||
|
export interface QueryJson { |
||||
|
endpoint: { |
||||
|
datasourceId: string |
||||
|
entityId: string |
||||
|
operation: Operation |
||||
|
schema?: string |
||||
|
} |
||||
|
resource: { |
||||
|
fields: string[] |
||||
|
} |
||||
|
filters?: SearchFilters |
||||
|
sort?: SortJson |
||||
|
paginate?: PaginationJson |
||||
|
body?: Row | Row[] |
||||
|
table?: Table |
||||
|
meta?: { |
||||
|
table?: Table |
||||
|
tables?: Record<string, Table> |
||||
|
renamed: RenameColumn |
||||
|
} |
||||
|
extra?: { |
||||
|
idFilter?: SearchFilters |
||||
|
} |
||||
|
relationships?: RelationshipsJson[] |
||||
|
} |
||||
|
|
||||
|
export interface SqlQuery { |
||||
|
sql: string |
||||
|
bindings?: string[] |
||||
|
} |
||||
Loading…
Reference in new issue