@hamelin.sh/compiler 0.3.2 → 0.3.4
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 +31 -1
- package/dist/main.d.ts +55 -41
- package/dist/main.js +31 -1
- package/package.json +3 -2
package/dist/main.d.ts
CHANGED
|
@@ -2,37 +2,38 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
type QueryDatasetsResult = { Ok: string[] } | { Err: ContextualTranslationErrors };
|
|
4
4
|
|
|
5
|
+
type BuildCatalogError = { kind: "catalogInit"; message: string } | { kind: "compilation"; name: string; errors: ContextualTranslationErrors } | { kind: "datasetParse"; name: string; message: string };
|
|
6
|
+
|
|
5
7
|
type CompileQueryResult = { Ok: QueryTranslation } | { Err: ContextualTranslationErrors };
|
|
6
8
|
|
|
7
|
-
interface
|
|
9
|
+
interface CatalogResource {
|
|
8
10
|
name: string;
|
|
9
|
-
|
|
11
|
+
query: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
interface BuildCatalogOutput {
|
|
15
|
+
catalog: Catalog;
|
|
16
|
+
errors: BuildCatalogError[];
|
|
17
|
+
}
|
|
13
18
|
|
|
14
|
-
interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
completions: ContextualCompletion | undefined;
|
|
18
|
-
translation: QueryTranslation | undefined;
|
|
19
|
+
interface Column {
|
|
20
|
+
name: string;
|
|
21
|
+
type: HamelinType;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
type Catalog = Record<string, Column[]>;
|
|
25
|
+
|
|
26
|
+
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[] };
|
|
27
|
+
|
|
28
|
+
interface FunctionDescription {
|
|
29
|
+
name: string;
|
|
30
|
+
parameters: string;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
interface QueryTranslation {
|
|
28
34
|
translation: Translation;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
interface ContextualCompletion {
|
|
32
|
-
pretty: string;
|
|
33
|
-
completion: Completion;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
37
|
interface CompletionItem {
|
|
37
38
|
/**
|
|
38
39
|
* What to show
|
|
@@ -61,48 +62,59 @@ interface CompletionItem {
|
|
|
61
62
|
section: string | undefined;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
interface ContextualResult {
|
|
66
|
+
hamelin: string;
|
|
67
|
+
errors: ContextualTranslationError[];
|
|
68
|
+
completions: ContextualCompletion | undefined;
|
|
69
|
+
translation: QueryTranslation | undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface Completion {
|
|
73
|
+
at: { start: number; end: number };
|
|
74
|
+
filter: boolean | undefined;
|
|
75
|
+
items: CompletionItem[];
|
|
76
|
+
}
|
|
77
|
+
|
|
64
78
|
interface Translation {
|
|
65
79
|
sql: string;
|
|
66
80
|
columns: Column[];
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
hamelin: string;
|
|
71
|
-
errors: ContextualTranslationError[];
|
|
72
|
-
}
|
|
83
|
+
type CompletionItemKind = "Text" | "Variable" | "Function" | "Command" | "Keyword";
|
|
73
84
|
|
|
74
|
-
interface
|
|
75
|
-
error: TranslationError;
|
|
85
|
+
interface ContextualCompletion {
|
|
76
86
|
pretty: string;
|
|
87
|
+
completion: Completion;
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
area: LanguageArea | undefined;
|
|
81
|
-
stage: Stage;
|
|
82
|
-
level: Level;
|
|
83
|
-
primary: Context;
|
|
84
|
-
supporting: Context[] | undefined;
|
|
85
|
-
source_desc: string | undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
type Level = "Error" | "Warning" | "Info";
|
|
90
|
+
type LanguageArea = "FunctionCall" | "Operator" | "Deref" | "IndexAccess" | "Parsing";
|
|
89
91
|
|
|
90
92
|
interface Context {
|
|
91
93
|
interval: { start: number; end: number };
|
|
92
94
|
message: string;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
type
|
|
97
|
+
type Level = "Error" | "Warning" | "Info";
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
interface ContextualTranslationError {
|
|
100
|
+
error: TranslationError;
|
|
101
|
+
pretty: string;
|
|
102
|
+
}
|
|
98
103
|
|
|
99
|
-
|
|
104
|
+
interface ContextualTranslationErrors {
|
|
105
|
+
hamelin: string;
|
|
106
|
+
errors: ContextualTranslationError[];
|
|
107
|
+
}
|
|
100
108
|
|
|
101
|
-
type
|
|
109
|
+
type Stage = "Translation" | "Parsing" | "SemanticAnalysis";
|
|
102
110
|
|
|
103
|
-
interface
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
interface TranslationError {
|
|
112
|
+
area: LanguageArea | undefined;
|
|
113
|
+
stage: Stage;
|
|
114
|
+
level: Level;
|
|
115
|
+
primary: Context;
|
|
116
|
+
supporting: Context[] | undefined;
|
|
117
|
+
source_desc: string | undefined;
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
|
|
@@ -126,6 +138,8 @@ declare class Compiler {
|
|
|
126
138
|
constructor();
|
|
127
139
|
}
|
|
128
140
|
|
|
141
|
+
declare const buildCatalog: (startingCatalog: Catalog, resources: Array<CatalogResource>) => Promise<BuildCatalogOutput>;
|
|
142
|
+
|
|
129
143
|
declare const compileHamelin: (catalog: Catalog, hamelinInput: string, timeRange?: string) => Promise<CompileQueryResult>;
|
|
130
144
|
declare const createCompiler: (catalog: Catalog) => Promise<Compiler>;
|
|
131
145
|
|
|
@@ -180,4 +194,4 @@ declare const sampleCatalog: Catalog;
|
|
|
180
194
|
*/
|
|
181
195
|
declare function getSyntaxCompletions(input: string, pos: number): Completion | null;
|
|
182
196
|
|
|
183
|
-
export { type Catalog, type Column, type CompileQueryResult, type Completion, type CompletionItem, type ContextualResult, type ContextualTranslationError, type ContextualTranslationErrors, type FunctionDescription, type HamelinType, type QuerySort, type QueryTranslation, type Translation, type TranslationError, compileHamelin, createCompiler, getAggregations, getDatasetsFromQuery, getFunctionDescriptions, getLimits, getSelectedFields, getSorts, getSyntaxCompletions, hamelinGrammar, hamelinPrompt, parseTokenValueClass, sampleCatalog };
|
|
197
|
+
export { type BuildCatalogError, type BuildCatalogOutput, type Catalog, type Column, type CompileQueryResult, type Completion, type CompletionItem, type ContextualResult, type ContextualTranslationError, type ContextualTranslationErrors, type FunctionDescription, type HamelinType, type QuerySort, type QueryTranslation, type Translation, type TranslationError, buildCatalog, compileHamelin, createCompiler, getAggregations, getDatasetsFromQuery, getFunctionDescriptions, getLimits, getSelectedFields, getSorts, getSyntaxCompletions, hamelinGrammar, hamelinPrompt, parseTokenValueClass, sampleCatalog };
|