forked from tsai/budibase
8 changed files with 287 additions and 15 deletions
Binary file not shown.
@ -0,0 +1,109 @@ |
|||
import { Table } from "../documents"; |
|||
export declare 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 declare enum SortDirection { |
|||
ASCENDING = "ASCENDING", |
|||
DESCENDING = "DESCENDING" |
|||
} |
|||
export declare enum QueryType { |
|||
SQL = "sql", |
|||
JSON = "json", |
|||
FIELDS = "fields" |
|||
} |
|||
export declare enum DatasourceFieldType { |
|||
STRING = "string", |
|||
LONGFORM = "longForm", |
|||
BOOLEAN = "boolean", |
|||
NUMBER = "number", |
|||
PASSWORD = "password", |
|||
LIST = "list", |
|||
OBJECT = "object", |
|||
JSON = "json", |
|||
FILE = "file" |
|||
} |
|||
export declare enum SourceName { |
|||
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", |
|||
UNKNOWN = "unknown" |
|||
} |
|||
export declare enum IncludeRelationship { |
|||
INCLUDE = 1, |
|||
EXCLUDE = 0 |
|||
} |
|||
export declare enum FilterType { |
|||
STRING = "string", |
|||
FUZZY = "fuzzy", |
|||
RANGE = "range", |
|||
EQUAL = "equal", |
|||
NOT_EQUAL = "notEqual", |
|||
EMPTY = "empty", |
|||
NOT_EMPTY = "notEmpty", |
|||
ONE_OF = "oneOf" |
|||
} |
|||
export interface QueryDefinition { |
|||
type: QueryType; |
|||
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>; |
|||
getBindingIdentifier(): string; |
|||
getStringConcat(parts: string[]): string; |
|||
buildSchema(datasourceId: string, entities: Record<string, Table>): any; |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
"use strict"; |
|||
Object.defineProperty(exports, "__esModule", { value: true }); |
|||
exports.FilterType = exports.IncludeRelationship = exports.SourceName = exports.DatasourceFieldType = exports.QueryType = exports.SortDirection = exports.Operation = void 0; |
|||
var Operation; |
|||
(function (Operation) { |
|||
Operation["CREATE"] = "CREATE"; |
|||
Operation["READ"] = "READ"; |
|||
Operation["UPDATE"] = "UPDATE"; |
|||
Operation["DELETE"] = "DELETE"; |
|||
Operation["BULK_CREATE"] = "BULK_CREATE"; |
|||
Operation["CREATE_TABLE"] = "CREATE_TABLE"; |
|||
Operation["UPDATE_TABLE"] = "UPDATE_TABLE"; |
|||
Operation["DELETE_TABLE"] = "DELETE_TABLE"; |
|||
})(Operation = exports.Operation || (exports.Operation = {})); |
|||
var SortDirection; |
|||
(function (SortDirection) { |
|||
SortDirection["ASCENDING"] = "ASCENDING"; |
|||
SortDirection["DESCENDING"] = "DESCENDING"; |
|||
})(SortDirection = exports.SortDirection || (exports.SortDirection = {})); |
|||
var QueryType; |
|||
(function (QueryType) { |
|||
QueryType["SQL"] = "sql"; |
|||
QueryType["JSON"] = "json"; |
|||
QueryType["FIELDS"] = "fields"; |
|||
})(QueryType = exports.QueryType || (exports.QueryType = {})); |
|||
var DatasourceFieldType; |
|||
(function (DatasourceFieldType) { |
|||
DatasourceFieldType["STRING"] = "string"; |
|||
DatasourceFieldType["LONGFORM"] = "longForm"; |
|||
DatasourceFieldType["BOOLEAN"] = "boolean"; |
|||
DatasourceFieldType["NUMBER"] = "number"; |
|||
DatasourceFieldType["PASSWORD"] = "password"; |
|||
DatasourceFieldType["LIST"] = "list"; |
|||
DatasourceFieldType["OBJECT"] = "object"; |
|||
DatasourceFieldType["JSON"] = "json"; |
|||
DatasourceFieldType["FILE"] = "file"; |
|||
})(DatasourceFieldType = exports.DatasourceFieldType || (exports.DatasourceFieldType = {})); |
|||
var SourceName; |
|||
(function (SourceName) { |
|||
SourceName["POSTGRES"] = "POSTGRES"; |
|||
SourceName["DYNAMODB"] = "DYNAMODB"; |
|||
SourceName["MONGODB"] = "MONGODB"; |
|||
SourceName["ELASTICSEARCH"] = "ELASTICSEARCH"; |
|||
SourceName["COUCHDB"] = "COUCHDB"; |
|||
SourceName["SQL_SERVER"] = "SQL_SERVER"; |
|||
SourceName["S3"] = "S3"; |
|||
SourceName["AIRTABLE"] = "AIRTABLE"; |
|||
SourceName["MYSQL"] = "MYSQL"; |
|||
SourceName["ARANGODB"] = "ARANGODB"; |
|||
SourceName["REST"] = "REST"; |
|||
SourceName["ORACLE"] = "ORACLE"; |
|||
SourceName["GOOGLE_SHEETS"] = "GOOGLE_SHEETS"; |
|||
SourceName["FIRESTORE"] = "FIRESTORE"; |
|||
SourceName["REDIS"] = "REDIS"; |
|||
SourceName["SNOWFLAKE"] = "SNOWFLAKE"; |
|||
SourceName["UNKNOWN"] = "unknown"; |
|||
})(SourceName = exports.SourceName || (exports.SourceName = {})); |
|||
var IncludeRelationship; |
|||
(function (IncludeRelationship) { |
|||
IncludeRelationship[IncludeRelationship["INCLUDE"] = 1] = "INCLUDE"; |
|||
IncludeRelationship[IncludeRelationship["EXCLUDE"] = 0] = "EXCLUDE"; |
|||
})(IncludeRelationship = exports.IncludeRelationship || (exports.IncludeRelationship = {})); |
|||
var FilterType; |
|||
(function (FilterType) { |
|||
FilterType["STRING"] = "string"; |
|||
FilterType["FUZZY"] = "fuzzy"; |
|||
FilterType["RANGE"] = "range"; |
|||
FilterType["EQUAL"] = "equal"; |
|||
FilterType["NOT_EQUAL"] = "notEqual"; |
|||
FilterType["EMPTY"] = "empty"; |
|||
FilterType["NOT_EMPTY"] = "notEmpty"; |
|||
FilterType["ONE_OF"] = "oneOf"; |
|||
})(FilterType = exports.FilterType || (exports.FilterType = {})); |
|||
//# sourceMappingURL=datasources.js.map
|
|||
@ -0,0 +1 @@ |
|||
{"version":3,"file":"datasources.js","sourceRoot":"","sources":["../../src/sdk/datasources.ts"],"names":[],"mappings":";;;AAEA,IAAY,SASX;AATD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,wCAA2B,CAAA;IAC3B,0CAA6B,CAAA;IAC7B,0CAA6B,CAAA;IAC7B,0CAA6B,CAAA;AAC/B,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,0CAAyB,CAAA;AAC3B,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,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kBAAU,KAAV,kBAAU,QASrB"} |
|||
@ -0,0 +1,84 @@ |
|||
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[]; |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
"use strict"; |
|||
Object.defineProperty(exports, "__esModule", { value: true }); |
|||
//# sourceMappingURL=search.js.map
|
|||
@ -0,0 +1 @@ |
|||
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/sdk/search.ts"],"names":[],"mappings":""} |
|||
Loading…
Reference in new issue