@hamelin.sh/compiler 0.3.3 → 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/main.d.ts CHANGED
@@ -2,11 +2,18 @@
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 FunctionDescription {
9
+ interface CatalogResource {
8
10
  name: string;
9
- parameters: string;
11
+ query: string;
12
+ }
13
+
14
+ interface BuildCatalogOutput {
15
+ catalog: Catalog;
16
+ errors: BuildCatalogError[];
10
17
  }
11
18
 
12
19
  interface Column {
@@ -14,23 +21,15 @@ interface Column {
14
21
  type: HamelinType;
15
22
  }
16
23
 
17
- 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[] };
18
-
19
24
  type Catalog = Record<string, Column[]>;
20
25
 
21
- interface Translation {
22
- sql: string;
23
- columns: Column[];
24
- }
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[] };
25
27
 
26
- interface Completion {
27
- at: { start: number; end: number };
28
- filter: boolean | undefined;
29
- items: CompletionItem[];
28
+ interface FunctionDescription {
29
+ name: string;
30
+ parameters: string;
30
31
  }
31
32
 
32
- type CompletionItemKind = "Text" | "Variable" | "Function" | "Command" | "Keyword";
33
-
34
33
  interface QueryTranslation {
35
34
  translation: Translation;
36
35
  }
@@ -63,11 +62,6 @@ interface CompletionItem {
63
62
  section: string | undefined;
64
63
  }
65
64
 
66
- interface ContextualCompletion {
67
- pretty: string;
68
- completion: Completion;
69
- }
70
-
71
65
  interface ContextualResult {
72
66
  hamelin: string;
73
67
  errors: ContextualTranslationError[];
@@ -75,19 +69,44 @@ interface ContextualResult {
75
69
  translation: QueryTranslation | undefined;
76
70
  }
77
71
 
78
- type Stage = "Translation" | "Parsing" | "SemanticAnalysis";
72
+ interface Completion {
73
+ at: { start: number; end: number };
74
+ filter: boolean | undefined;
75
+ items: CompletionItem[];
76
+ }
79
77
 
80
- interface ContextualTranslationError {
81
- error: TranslationError;
78
+ interface Translation {
79
+ sql: string;
80
+ columns: Column[];
81
+ }
82
+
83
+ type CompletionItemKind = "Text" | "Variable" | "Function" | "Command" | "Keyword";
84
+
85
+ interface ContextualCompletion {
82
86
  pretty: string;
87
+ completion: Completion;
83
88
  }
84
89
 
90
+ type LanguageArea = "FunctionCall" | "Operator" | "Deref" | "IndexAccess" | "Parsing";
91
+
85
92
  interface Context {
86
93
  interval: { start: number; end: number };
87
94
  message: string;
88
95
  }
89
96
 
90
- type LanguageArea = "FunctionCall" | "Operator" | "Deref" | "IndexAccess" | "Parsing";
97
+ type Level = "Error" | "Warning" | "Info";
98
+
99
+ interface ContextualTranslationError {
100
+ error: TranslationError;
101
+ pretty: string;
102
+ }
103
+
104
+ interface ContextualTranslationErrors {
105
+ hamelin: string;
106
+ errors: ContextualTranslationError[];
107
+ }
108
+
109
+ type Stage = "Translation" | "Parsing" | "SemanticAnalysis";
91
110
 
92
111
  interface TranslationError {
93
112
  area: LanguageArea | undefined;
@@ -98,13 +117,6 @@ interface TranslationError {
98
117
  source_desc: string | undefined;
99
118
  }
100
119
 
101
- interface ContextualTranslationErrors {
102
- hamelin: string;
103
- errors: ContextualTranslationError[];
104
- }
105
-
106
- type Level = "Error" | "Warning" | "Info";
107
-
108
120
 
109
121
  declare class CatalogProvider {
110
122
  private constructor();
@@ -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 };