@hamelin.sh/compiler 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iife.js +391 -389
- package/dist/main.d.ts +67 -67
- package/dist/main.js +391 -389
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -1,49 +1,24 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
type BuildCatalogError = { kind: "catalogInit"; message: string } | { kind: "compilation"; name: string; errors: ContextualTranslationErrors } | { kind: "datasetParse"; name: string; message: string };
|
|
4
|
-
|
|
5
|
-
type CompileQueryResult = { Ok: QueryTranslation } | { Err: ContextualTranslationErrors };
|
|
6
|
-
|
|
7
|
-
interface CatalogResource {
|
|
8
|
-
name: string;
|
|
9
|
-
query: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
3
|
interface BuildCatalogOutput {
|
|
13
4
|
catalog: Catalog;
|
|
14
5
|
errors: BuildCatalogError[];
|
|
15
6
|
}
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
interface ContextualTranslationErrors {
|
|
22
|
-
hamelin: string;
|
|
23
|
-
errors: ContextualTranslationError[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface TranslationError {
|
|
27
|
-
area: LanguageArea | undefined;
|
|
28
|
-
stage: Stage;
|
|
29
|
-
level: Level;
|
|
30
|
-
primary: Context;
|
|
31
|
-
supporting: Context[] | undefined;
|
|
32
|
-
source_desc: string | undefined;
|
|
8
|
+
interface CatalogResource {
|
|
9
|
+
name: string;
|
|
10
|
+
query: string;
|
|
33
11
|
}
|
|
34
12
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
error: TranslationError;
|
|
39
|
-
pretty: string;
|
|
13
|
+
interface Column {
|
|
14
|
+
name: string;
|
|
15
|
+
type: HamelinType;
|
|
40
16
|
}
|
|
41
17
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
message: string;
|
|
18
|
+
interface Completion {
|
|
19
|
+
at: { start: number; end: number };
|
|
20
|
+
filter: boolean | undefined;
|
|
21
|
+
items: CompletionItem[];
|
|
47
22
|
}
|
|
48
23
|
|
|
49
24
|
interface CompletionItem {
|
|
@@ -74,8 +49,14 @@ interface CompletionItem {
|
|
|
74
49
|
section: string | undefined;
|
|
75
50
|
}
|
|
76
51
|
|
|
77
|
-
interface
|
|
78
|
-
|
|
52
|
+
interface Context {
|
|
53
|
+
interval: { start: number; end: number };
|
|
54
|
+
message: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ContextualCompletion {
|
|
58
|
+
pretty: string;
|
|
59
|
+
completion: Completion;
|
|
79
60
|
}
|
|
80
61
|
|
|
81
62
|
interface ContextualResult {
|
|
@@ -85,57 +66,76 @@ interface ContextualResult {
|
|
|
85
66
|
translation: QueryTranslation | undefined;
|
|
86
67
|
}
|
|
87
68
|
|
|
88
|
-
interface
|
|
69
|
+
interface ContextualTranslationError {
|
|
70
|
+
error: TranslationError;
|
|
89
71
|
pretty: string;
|
|
90
|
-
completion: Completion;
|
|
91
72
|
}
|
|
92
73
|
|
|
93
|
-
interface
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
items: CompletionItem[];
|
|
74
|
+
interface ContextualTranslationErrors {
|
|
75
|
+
hamelin: string;
|
|
76
|
+
errors: ContextualTranslationError[];
|
|
97
77
|
}
|
|
98
78
|
|
|
99
|
-
|
|
79
|
+
interface FunctionDescription {
|
|
80
|
+
name: string;
|
|
81
|
+
parameters: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface QueryTranslation {
|
|
85
|
+
translation: Translation;
|
|
86
|
+
}
|
|
100
87
|
|
|
101
88
|
interface Translation {
|
|
102
89
|
sql: string;
|
|
103
90
|
columns: Column[];
|
|
104
91
|
}
|
|
105
92
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
93
|
+
interface TranslationError {
|
|
94
|
+
area: LanguageArea | undefined;
|
|
95
|
+
stage: Stage;
|
|
96
|
+
level: Level;
|
|
97
|
+
primary: Context;
|
|
98
|
+
supporting: Context[] | undefined;
|
|
99
|
+
source_desc: string | undefined;
|
|
111
100
|
}
|
|
112
101
|
|
|
102
|
+
type BuildCatalogError = { kind: "catalogInit"; message: string } | { kind: "compilation"; name: string; errors: ContextualTranslationErrors } | { kind: "datasetParse"; name: string; message: string };
|
|
103
|
+
|
|
113
104
|
type Catalog = Record<string, Column[]>;
|
|
114
105
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
type CompileQueryResult = { Ok: QueryTranslation } | { Err: ContextualTranslationErrors };
|
|
107
|
+
|
|
108
|
+
type CompletionItemKind = "Text" | "Variable" | "Function" | "Command" | "Keyword";
|
|
109
|
+
|
|
110
|
+
type HamelinType = "binary" | "boolean" | "interval" | "calendar_interval" | "int" | "double" | "rows" | "string" | "timestamp" | "unknown" | { decimal: { precision: number; scale: number } } | { array: { element_type: HamelinType } } | { map: { key_type: HamelinType; value_type: HamelinType } } | { tuple: { elements: HamelinType[] } } | "variant" | { range: { of: HamelinType } } | { struct: Column[] };
|
|
111
|
+
|
|
112
|
+
type LanguageArea = "FunctionCall" | "Operator" | "Deref" | "IndexAccess" | "Parsing";
|
|
113
|
+
|
|
114
|
+
type Level = "Error" | "Warning" | "Info";
|
|
115
|
+
|
|
116
|
+
type QueryDatasetsResult = { Ok: string[] } | { Err: ContextualTranslationErrors };
|
|
117
|
+
|
|
118
|
+
type Stage = "Translation" | "Parsing" | "SemanticAnalysis";
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
declare class CatalogProvider {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
private constructor();
|
|
123
|
+
free(): void;
|
|
124
|
+
[Symbol.dispose](): void;
|
|
125
|
+
static try_from_catalog(catalog: Catalog): CatalogProvider;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
declare class Compiler {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
free(): void;
|
|
130
|
+
[Symbol.dispose](): void;
|
|
131
|
+
compile_query(query: string): CompileQueryResult;
|
|
132
|
+
compile_query_at(query: string, at?: number | null): ContextualResult;
|
|
133
|
+
get_function_descriptions(): FunctionDescription[];
|
|
134
|
+
get_statement_datasets(query: string): QueryDatasetsResult;
|
|
135
|
+
constructor();
|
|
136
|
+
set_catalog_provider(provider: CatalogProvider): void;
|
|
137
|
+
set_time_range(start?: Date | null, end?: Date | null): void;
|
|
138
|
+
set_time_range_expression(expression: string): ContextualTranslationErrors | undefined;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
declare const buildCatalog: (startingCatalog: Catalog, resources: Array<CatalogResource>) => Promise<BuildCatalogOutput>;
|