-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathexecutor.ts
More file actions
77 lines (67 loc) · 1.78 KB
/
Copy pathexecutor.ts
File metadata and controls
77 lines (67 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import type { Query, QueryResult } from "./query";
import type { Either } from "./type-utils";
export interface Executor {
execute<T>(
query: Query<T>,
options?: ExecuteOptions,
): Promise<Either<Error, QueryResult<Query<T>>>>;
executeTransaction?(
queries: readonly Query<unknown>[],
options?: ExecuteOptions,
): Promise<Either<Error, QueryResult<Query<unknown>>[]>>;
/**
* Optional SQL lint transport for parse/plan diagnostics.
*
* Executors that do not implement this capability can still be used by
* adapters with fallback lint strategies.
*/
lintSql?(
details: SqlLintDetails,
options?: ExecuteOptions,
): Promise<Either<Error, SqlLintResult>>;
}
export interface SequenceExecutor extends Executor {
executeSequence<T, S>(
sequence: readonly [Query<T>, Query<S>],
options?: ExecuteOptions,
): Promise<
| [[Error]]
| [[null, QueryResult<Query<T>>], Either<Error, QueryResult<Query<S>>>]
>;
}
export interface ExecuteOptions {
abortSignal?: AbortSignal;
/**
* Schema to use as the default namespace for unqualified identifiers.
*/
schema?: string;
}
export interface SqlLintDetails {
/**
* Schema to use as the default namespace for unqualified identifiers.
*/
schema?: string;
schemaVersion?: string;
sql: string;
}
export interface SqlLintDiagnostic {
code?: string;
from: number;
message: string;
severity: "error" | "warning" | "info" | "hint";
source?: string;
to: number;
}
export interface SqlLintResult {
diagnostics: SqlLintDiagnostic[];
schemaVersion?: string;
}
export class AbortError extends Error {
constructor() {
super("This operation was aborted");
this.name = "AbortError";
}
}
export function getAbortResult(): [AbortError] {
return [new AbortError()];
}