SYNC: Merge pull request #5 from dbgate/feature/firestore

This commit is contained in:
Jan Prochazka
2025-07-24 10:59:56 +02:00
committed by Diflow
parent 0cf9ddb1cd
commit c171f93c93
22 changed files with 1353 additions and 69 deletions

View File

@@ -108,6 +108,8 @@ export interface CollectionInfo extends DatabaseObjectInfo {
// unique combination of columns (should be contatenation of partitionKey and clusterKey)
uniqueKey?: ColumnReference[];
autoValueColumns?: ColumnReference[];
// partition key columns
partitionKey?: ColumnReference[];

View File

@@ -23,6 +23,28 @@ export interface StreamOptions {
info?: (info) => void;
}
export type CollectionOperationInfo =
| {
type: 'createCollection';
collection: {
name: string;
};
}
| {
type: 'dropCollection';
collection: string;
}
| {
type: 'renameCollection';
collection: string;
newName: string;
}
| {
type: 'cloneCollection';
collection: string;
newName: string;
};
export interface RunScriptOptions {
useTransaction: boolean;
logScriptItems?: boolean;
@@ -120,6 +142,8 @@ export interface DataEditorTypesBehaviour {
parseHexAsBuffer?: boolean;
parseObjectIdAsDollar?: boolean;
parseDateAsDollar?: boolean;
parseGeopointAsDollar?: boolean;
parseFsDocumentRefAsDollar?: boolean;
explicitDataType?: boolean;
supportNumberType?: boolean;
@@ -217,7 +241,7 @@ export interface EngineDriver<TClient = any> extends FilterBehaviourProvider {
defaultSocketPath?: string;
authTypeLabel?: string;
importExportArgs?: any[];
connect({ server, port, user, password, database }): Promise<DatabaseHandle<TClient>>;
connect({ server, port, user, password, database, certificateJson }): Promise<DatabaseHandle<TClient>>;
close(dbhan: DatabaseHandle<TClient>): Promise<any>;
query(dbhan: DatabaseHandle<TClient>, sql: string, options?: QueryOptions): Promise<QueryResult>;
stream(dbhan: DatabaseHandle<TClient>, sql: string, options: StreamOptions);
@@ -264,7 +288,7 @@ export interface EngineDriver<TClient = any> extends FilterBehaviourProvider {
dropDatabase(dbhan: DatabaseHandle<TClient>, name: string): Promise;
getQuerySplitterOptions(usage: 'stream' | 'script' | 'editor' | 'import'): any;
script(dbhan: DatabaseHandle<TClient>, sql: string, options?: RunScriptOptions): Promise;
operation(dbhan: DatabaseHandle<TClient>, operation: {}, options?: RunScriptOptions): Promise;
operation(dbhan: DatabaseHandle<TClient>, operation: CollectionOperationInfo, options?: RunScriptOptions): Promise;
getNewObjectTemplates(): NewObjectTemplate[];
// direct call of dbhan.client method, only some methods could be supported, on only some drivers
callMethod(dbhan: DatabaseHandle<TClient>, method, args);

View File

@@ -9,11 +9,18 @@ export interface FilterBehaviour {
supportExistsTesting?: boolean;
supportBooleanValues?: boolean;
supportSqlCondition?: boolean;
supportArrayTesting?: boolean;
supportEmptyArrayTesting?: boolean;
supportNotEmptyArrayTesting?: boolean;
supportBooleanOrNull?: boolean;
allowStringToken?: boolean;
allowNumberToken?: boolean;
allowHexString?: boolean;
allowNumberDualTesting?: boolean;
allowObjectIdTesting?: boolean;
passBooleans?: boolean;
passNumbers?: boolean;
disableOr?: boolean;
}

View File

@@ -15,3 +15,92 @@ export interface QueryResult {
columns?: QueryResultColumn[];
rowsAffected?: number;
}
export type LeftOperand = {
exprType: 'placeholder' | 'column';
columnName?: string;
};
export type RightOperand = {
exprType: 'value';
value: any;
};
export type BinaryCondition = {
conditionType: 'binary';
operator: '=' | '!=' | '<>' | '<' | '<=' | '>' | '>=';
left: LeftOperand;
right: RightOperand;
};
export type AndCondition = {
conditionType: 'and';
conditions: FilterCondition[];
};
export type OrCondition = {
conditionType: 'or';
conditions: FilterCondition[];
};
export type NullCondition = {
conditionType: 'isNull' | 'isNotNull';
expr: LeftOperand;
};
export type NotCondition = {
conditionType: 'not';
condition: FilterCondition;
};
export type LikeCondition = {
conditionType: 'like';
left: LeftOperand;
right: RightOperand;
};
export type PredicateCondition = {
conditionType: 'specificPredicate';
predicate: 'exists' | 'notExists' | 'emptyArray' | 'notEmptyArray';
expr: LeftOperand;
};
export type InCondition = {
conditionType: 'in';
expr: LeftOperand;
values: any[];
};
export type FilterCondition =
| BinaryCondition
| AndCondition
| OrCondition
| NullCondition
| NotCondition
| LikeCondition
| PredicateCondition
| InCondition;
export type SortItem = {
columnName: string;
direction?: 'ASC' | 'DESC';
};
export type AggregateColumn = {
aggregateFunction: 'count' | 'sum' | 'avg' | 'min' | 'max';
columnArgument?: string;
alias: string;
};
export type CollectionAggregate = {
condition?: FilterCondition;
groupByColumns: string[];
aggregateColumns: AggregateColumn[];
};
export type FullQueryOptions = {
condition?: FilterCondition;
sort?: SortItem[];
limit?: number;
skip?: number;
};