budibase/packages/server/src/integrations/base/definitions.ts

110 lines
1.7 KiB
TypeScript
Raw Normal View History

export enum Operation {
CREATE = "CREATE",
READ = "READ",
UPDATE = "UPDATE",
DELETE = "DELETE",
}
export enum SortDirection {
ASCENDING = "ASCENDING",
DESCENDING = "DESCENDING",
}
export enum QueryTypes {
SQL = "sql",
JSON = "json",
FIELDS = "fields",
}
export enum DatasourceFieldTypes {
STRING = "string",
BOOLEAN = "boolean",
NUMBER = "number",
PASSWORD = "password",
LIST = "list",
OBJECT = "object",
JSON = "json",
}
export interface QueryDefinition {
2021-06-24 19:17:26 +02:00
type: QueryTypes
displayName?: string
readable?: boolean
customisable?: boolean
fields?: object
urlDisplay?: boolean
}
export interface Integration {
2021-06-24 19:17:26 +02:00
docs: string
plus?: boolean
description: string
friendlyName: string
datasource: {}
query: {
2021-06-24 19:17:26 +02:00
[key: string]: QueryDefinition
}
}
export interface SearchFilters {
2021-06-24 19:17:26 +02:00
allOr: boolean
string?: {
2021-06-24 19:17:26 +02:00
[key: string]: string
}
fuzzy?: {
2021-06-24 19:17:26 +02:00
[key: string]: string
}
range?: {
[key: string]: {
2021-06-24 19:17:26 +02:00
high: number | string
low: number | string
}
}
equal?: {
2021-06-24 19:17:26 +02:00
[key: string]: any
}
notEqual?: {
2021-06-24 19:17:26 +02:00
[key: string]: any
}
empty?: {
2021-06-24 19:17:26 +02:00
[key: string]: any
}
notEmpty?: {
2021-06-24 19:17:26 +02:00
[key: string]: any
}
}
export interface QueryJson {
endpoint: {
2021-06-24 19:17:26 +02:00
datasourceId: string
entityId: string
operation: Operation
}
resource: {
2021-06-24 19:17:26 +02:00
fields: string[]
}
filters?: SearchFilters
sort?: {
2021-06-24 19:17:26 +02:00
[key: string]: SortDirection
}
paginate?: {
2021-06-24 19:17:26 +02:00
limit: number
page: string | number
}
body?: object
extra: {
2021-06-24 19:17:26 +02:00
idFilter?: SearchFilters
}
}
export interface SqlQuery {
sql: string
bindings?: {
[key: string]: any
}
}
export interface QueryOptions {
2021-06-24 19:17:26 +02:00
disableReturning?: boolean
}