@malloydata/malloy 0.0.80-dev230906223653 → 0.0.80-dev230907131802

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.
@@ -1,6 +1,17 @@
1
1
  import { ModelDataRequest } from '../../translate-response';
2
- import { DocStatement, Document, MalloyElement } from '../types/malloy-element';
3
- export declare class ImportStatement extends MalloyElement implements DocStatement {
2
+ import { DocStatement, Document, ListOf, MalloyElement } from '../types/malloy-element';
3
+ export declare class ImportSourceName extends MalloyElement {
4
+ readonly text: string;
5
+ elementType: string;
6
+ constructor(text: string);
7
+ }
8
+ export declare class ImportSelect extends MalloyElement {
9
+ readonly text: string;
10
+ readonly from: ImportSourceName | undefined;
11
+ elementType: string;
12
+ constructor(text: string, from: ImportSourceName | undefined);
13
+ }
14
+ export declare class ImportStatement extends ListOf<ImportSelect> implements DocStatement {
4
15
  readonly url: string;
5
16
  elementType: string;
6
17
  fullURL?: string;
@@ -22,9 +22,29 @@
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ImportStatement = void 0;
25
+ exports.ImportStatement = exports.ImportSelect = exports.ImportSourceName = void 0;
26
26
  const malloy_element_1 = require("../types/malloy-element");
27
- class ImportStatement extends malloy_element_1.MalloyElement {
27
+ class ImportSourceName extends malloy_element_1.MalloyElement {
28
+ constructor(text) {
29
+ super();
30
+ this.text = text;
31
+ this.elementType = 'importSourceName';
32
+ }
33
+ }
34
+ exports.ImportSourceName = ImportSourceName;
35
+ class ImportSelect extends malloy_element_1.MalloyElement {
36
+ constructor(text, from) {
37
+ super();
38
+ this.text = text;
39
+ this.from = from;
40
+ this.elementType = 'importName';
41
+ if (from) {
42
+ this.has({ from });
43
+ }
44
+ }
45
+ }
46
+ exports.ImportSelect = ImportSelect;
47
+ class ImportStatement extends malloy_element_1.ListOf {
28
48
  /*
29
49
  * At the time of writng this comment, it is guaranteed that if an AST
30
50
  * node for an import statement is created, the translator has already
@@ -34,7 +54,7 @@ class ImportStatement extends malloy_element_1.MalloyElement {
34
54
  * there are other ways to contruct an AST.
35
55
  */
36
56
  constructor(url, baseURL) {
37
- super();
57
+ super([]);
38
58
  this.url = url;
39
59
  this.elementType = 'import statement';
40
60
  try {
@@ -64,12 +84,35 @@ class ImportStatement extends malloy_element_1.MalloyElement {
64
84
  else if (this.fullURL) {
65
85
  const src = trans.root.importZone.getEntry(this.fullURL);
66
86
  if (src.status === 'present') {
67
- for (const [importing, entry] of Object.entries(trans.getChildExports(this.fullURL))) {
68
- if (doc.getEntry(importing)) {
69
- this.log(`Cannot redefine '${importing}'`);
87
+ const importable = trans.getChildExports(this.fullURL);
88
+ if (this.notEmpty()) {
89
+ // just import the named objects
90
+ for (const importOne of this.list) {
91
+ const fetchName = importOne.from || importOne;
92
+ if (doc.getEntry(importOne.text)) {
93
+ importOne.log(`Cannot redefine '${importOne.text}'`);
94
+ }
95
+ else if (importable[fetchName.text]) {
96
+ const importMe = { ...importable[fetchName.text] };
97
+ if (importOne.from) {
98
+ importMe.as = importOne.text;
99
+ }
100
+ doc.setEntry(importOne.text, { entry: importMe, exported: false });
101
+ }
102
+ else {
103
+ fetchName.log(`Cannot find '${fetchName.text}', not imported`);
104
+ }
70
105
  }
71
- else {
72
- doc.setEntry(importing, { entry, exported: false });
106
+ }
107
+ else {
108
+ // import everything
109
+ for (const [importing, entry] of Object.entries(trans.getChildExports(this.fullURL))) {
110
+ if (doc.getEntry(importing)) {
111
+ this.log(`Cannot redefine '${importing}'`);
112
+ }
113
+ else {
114
+ doc.setEntry(importing, { entry, exported: false });
115
+ }
73
116
  }
74
117
  }
75
118
  }
@@ -172,118 +172,120 @@ export declare class MalloyParser extends Parser {
172
172
  static readonly RULE_sqlString = 11;
173
173
  static readonly RULE_sqlInterpolation = 12;
174
174
  static readonly RULE_importStatement = 13;
175
- static readonly RULE_importURL = 14;
176
- static readonly RULE_docAnnotations = 15;
177
- static readonly RULE_ignoredObjectAnnotations = 16;
178
- static readonly RULE_ignoredModelAnnotations = 17;
179
- static readonly RULE_topLevelQueryDefs = 18;
180
- static readonly RULE_topLevelQueryDef = 19;
181
- static readonly RULE_refineOperator = 20;
182
- static readonly RULE_queryRefinement = 21;
183
- static readonly RULE_sourceExtension = 22;
184
- static readonly RULE_query = 23;
185
- static readonly RULE_unrefinableQuery = 24;
186
- static readonly RULE_refinableQuery = 25;
187
- static readonly RULE_unextendableSource = 26;
188
- static readonly RULE_extendableSource = 27;
189
- static readonly RULE_sqlSource = 28;
190
- static readonly RULE_pipelineFromName = 29;
191
- static readonly RULE_firstSegment = 30;
192
- static readonly RULE_pipeElement = 31;
193
- static readonly RULE_exploreTable = 32;
194
- static readonly RULE_connectionId = 33;
195
- static readonly RULE_queryProperties = 34;
196
- static readonly RULE_filterShortcut = 35;
197
- static readonly RULE_exploreQueryName = 36;
198
- static readonly RULE_queryName = 37;
199
- static readonly RULE_sourcePropertyList = 38;
200
- static readonly RULE_sourceDefinition = 39;
201
- static readonly RULE_explore = 40;
202
- static readonly RULE_sourceNameDef = 41;
203
- static readonly RULE_sourceID = 42;
204
- static readonly RULE_exploreProperties = 43;
205
- static readonly RULE_exploreStatement = 44;
206
- static readonly RULE_defMeasures = 45;
207
- static readonly RULE_defDimensions = 46;
208
- static readonly RULE_renameList = 47;
209
- static readonly RULE_exploreRenameDef = 48;
210
- static readonly RULE_defList = 49;
211
- static readonly RULE_fieldDef = 50;
212
- static readonly RULE_fieldNameDef = 51;
213
- static readonly RULE_joinNameDef = 52;
214
- static readonly RULE_declareStatement = 53;
215
- static readonly RULE_joinStatement = 54;
216
- static readonly RULE_queryExtend = 55;
217
- static readonly RULE_queryExtendStatement = 56;
218
- static readonly RULE_queryExtendStatementList = 57;
219
- static readonly RULE_joinList = 58;
220
- static readonly RULE_isExplore = 59;
221
- static readonly RULE_joinDef = 60;
222
- static readonly RULE_joinExpression = 61;
223
- static readonly RULE_filterStatement = 62;
224
- static readonly RULE_filteredBy = 63;
225
- static readonly RULE_filterClauseList = 64;
226
- static readonly RULE_whereStatement = 65;
227
- static readonly RULE_havingStatement = 66;
228
- static readonly RULE_subQueryDefList = 67;
229
- static readonly RULE_exploreQueryNameDef = 68;
230
- static readonly RULE_exploreQueryDef = 69;
231
- static readonly RULE_queryStatement = 70;
232
- static readonly RULE_queryJoinStatement = 71;
233
- static readonly RULE_groupByStatement = 72;
234
- static readonly RULE_queryFieldList = 73;
235
- static readonly RULE_queryFieldEntry = 74;
236
- static readonly RULE_nestStatement = 75;
237
- static readonly RULE_nestedQueryList = 76;
238
- static readonly RULE_nestEntry = 77;
239
- static readonly RULE_aggregateStatement = 78;
240
- static readonly RULE_calculateStatement = 79;
241
- static readonly RULE_projectStatement = 80;
242
- static readonly RULE_orderByStatement = 81;
243
- static readonly RULE_ordering = 82;
244
- static readonly RULE_orderBySpec = 83;
245
- static readonly RULE_limitStatement = 84;
246
- static readonly RULE_bySpec = 85;
247
- static readonly RULE_topStatement = 86;
248
- static readonly RULE_indexElement = 87;
249
- static readonly RULE_indexFields = 88;
250
- static readonly RULE_indexStatement = 89;
251
- static readonly RULE_sampleStatement = 90;
252
- static readonly RULE_timezoneStatement = 91;
253
- static readonly RULE_queryAnnotation = 92;
254
- static readonly RULE_sampleSpec = 93;
255
- static readonly RULE_aggregate = 94;
256
- static readonly RULE_malloyType = 95;
257
- static readonly RULE_compareOp = 96;
258
- static readonly RULE_string = 97;
259
- static readonly RULE_shortString = 98;
260
- static readonly RULE_numericLiteral = 99;
261
- static readonly RULE_literal = 100;
262
- static readonly RULE_dateLiteral = 101;
263
- static readonly RULE_tablePath = 102;
264
- static readonly RULE_tableURI = 103;
265
- static readonly RULE_id = 104;
266
- static readonly RULE_timeframe = 105;
267
- static readonly RULE_ungroup = 106;
268
- static readonly RULE_malloyOrSQLType = 107;
269
- static readonly RULE_fieldExpr = 108;
270
- static readonly RULE_partialAllowedFieldExpr = 109;
271
- static readonly RULE_pickStatement = 110;
272
- static readonly RULE_pick = 111;
273
- static readonly RULE_argumentList = 112;
274
- static readonly RULE_fieldNameList = 113;
275
- static readonly RULE_fieldCollection = 114;
276
- static readonly RULE_collectionWildCard = 115;
277
- static readonly RULE_taggedRef = 116;
278
- static readonly RULE_refExpr = 117;
279
- static readonly RULE_collectionMember = 118;
280
- static readonly RULE_fieldPath = 119;
281
- static readonly RULE_joinName = 120;
282
- static readonly RULE_fieldName = 121;
283
- static readonly RULE_justExpr = 122;
284
- static readonly RULE_sqlExploreNameRef = 123;
285
- static readonly RULE_nameSQLBlock = 124;
286
- static readonly RULE_connectionName = 125;
175
+ static readonly RULE_importSelect = 14;
176
+ static readonly RULE_importItem = 15;
177
+ static readonly RULE_importURL = 16;
178
+ static readonly RULE_docAnnotations = 17;
179
+ static readonly RULE_ignoredObjectAnnotations = 18;
180
+ static readonly RULE_ignoredModelAnnotations = 19;
181
+ static readonly RULE_topLevelQueryDefs = 20;
182
+ static readonly RULE_topLevelQueryDef = 21;
183
+ static readonly RULE_refineOperator = 22;
184
+ static readonly RULE_queryRefinement = 23;
185
+ static readonly RULE_sourceExtension = 24;
186
+ static readonly RULE_query = 25;
187
+ static readonly RULE_unrefinableQuery = 26;
188
+ static readonly RULE_refinableQuery = 27;
189
+ static readonly RULE_unextendableSource = 28;
190
+ static readonly RULE_extendableSource = 29;
191
+ static readonly RULE_sqlSource = 30;
192
+ static readonly RULE_pipelineFromName = 31;
193
+ static readonly RULE_firstSegment = 32;
194
+ static readonly RULE_pipeElement = 33;
195
+ static readonly RULE_exploreTable = 34;
196
+ static readonly RULE_connectionId = 35;
197
+ static readonly RULE_queryProperties = 36;
198
+ static readonly RULE_filterShortcut = 37;
199
+ static readonly RULE_exploreQueryName = 38;
200
+ static readonly RULE_queryName = 39;
201
+ static readonly RULE_sourcePropertyList = 40;
202
+ static readonly RULE_sourceDefinition = 41;
203
+ static readonly RULE_explore = 42;
204
+ static readonly RULE_sourceNameDef = 43;
205
+ static readonly RULE_sourceID = 44;
206
+ static readonly RULE_exploreProperties = 45;
207
+ static readonly RULE_exploreStatement = 46;
208
+ static readonly RULE_defMeasures = 47;
209
+ static readonly RULE_defDimensions = 48;
210
+ static readonly RULE_renameList = 49;
211
+ static readonly RULE_exploreRenameDef = 50;
212
+ static readonly RULE_defList = 51;
213
+ static readonly RULE_fieldDef = 52;
214
+ static readonly RULE_fieldNameDef = 53;
215
+ static readonly RULE_joinNameDef = 54;
216
+ static readonly RULE_declareStatement = 55;
217
+ static readonly RULE_joinStatement = 56;
218
+ static readonly RULE_queryExtend = 57;
219
+ static readonly RULE_queryExtendStatement = 58;
220
+ static readonly RULE_queryExtendStatementList = 59;
221
+ static readonly RULE_joinList = 60;
222
+ static readonly RULE_isExplore = 61;
223
+ static readonly RULE_joinDef = 62;
224
+ static readonly RULE_joinExpression = 63;
225
+ static readonly RULE_filterStatement = 64;
226
+ static readonly RULE_filteredBy = 65;
227
+ static readonly RULE_filterClauseList = 66;
228
+ static readonly RULE_whereStatement = 67;
229
+ static readonly RULE_havingStatement = 68;
230
+ static readonly RULE_subQueryDefList = 69;
231
+ static readonly RULE_exploreQueryNameDef = 70;
232
+ static readonly RULE_exploreQueryDef = 71;
233
+ static readonly RULE_queryStatement = 72;
234
+ static readonly RULE_queryJoinStatement = 73;
235
+ static readonly RULE_groupByStatement = 74;
236
+ static readonly RULE_queryFieldList = 75;
237
+ static readonly RULE_queryFieldEntry = 76;
238
+ static readonly RULE_nestStatement = 77;
239
+ static readonly RULE_nestedQueryList = 78;
240
+ static readonly RULE_nestEntry = 79;
241
+ static readonly RULE_aggregateStatement = 80;
242
+ static readonly RULE_calculateStatement = 81;
243
+ static readonly RULE_projectStatement = 82;
244
+ static readonly RULE_orderByStatement = 83;
245
+ static readonly RULE_ordering = 84;
246
+ static readonly RULE_orderBySpec = 85;
247
+ static readonly RULE_limitStatement = 86;
248
+ static readonly RULE_bySpec = 87;
249
+ static readonly RULE_topStatement = 88;
250
+ static readonly RULE_indexElement = 89;
251
+ static readonly RULE_indexFields = 90;
252
+ static readonly RULE_indexStatement = 91;
253
+ static readonly RULE_sampleStatement = 92;
254
+ static readonly RULE_timezoneStatement = 93;
255
+ static readonly RULE_queryAnnotation = 94;
256
+ static readonly RULE_sampleSpec = 95;
257
+ static readonly RULE_aggregate = 96;
258
+ static readonly RULE_malloyType = 97;
259
+ static readonly RULE_compareOp = 98;
260
+ static readonly RULE_string = 99;
261
+ static readonly RULE_shortString = 100;
262
+ static readonly RULE_numericLiteral = 101;
263
+ static readonly RULE_literal = 102;
264
+ static readonly RULE_dateLiteral = 103;
265
+ static readonly RULE_tablePath = 104;
266
+ static readonly RULE_tableURI = 105;
267
+ static readonly RULE_id = 106;
268
+ static readonly RULE_timeframe = 107;
269
+ static readonly RULE_ungroup = 108;
270
+ static readonly RULE_malloyOrSQLType = 109;
271
+ static readonly RULE_fieldExpr = 110;
272
+ static readonly RULE_partialAllowedFieldExpr = 111;
273
+ static readonly RULE_pickStatement = 112;
274
+ static readonly RULE_pick = 113;
275
+ static readonly RULE_argumentList = 114;
276
+ static readonly RULE_fieldNameList = 115;
277
+ static readonly RULE_fieldCollection = 116;
278
+ static readonly RULE_collectionWildCard = 117;
279
+ static readonly RULE_taggedRef = 118;
280
+ static readonly RULE_refExpr = 119;
281
+ static readonly RULE_collectionMember = 120;
282
+ static readonly RULE_fieldPath = 121;
283
+ static readonly RULE_joinName = 122;
284
+ static readonly RULE_fieldName = 123;
285
+ static readonly RULE_justExpr = 124;
286
+ static readonly RULE_sqlExploreNameRef = 125;
287
+ static readonly RULE_nameSQLBlock = 126;
288
+ static readonly RULE_connectionName = 127;
287
289
  static readonly ruleNames: string[];
288
290
  private static readonly _LITERAL_NAMES;
289
291
  private static readonly _SYMBOLIC_NAMES;
@@ -308,6 +310,8 @@ export declare class MalloyParser extends Parser {
308
310
  sqlString(): SqlStringContext;
309
311
  sqlInterpolation(): SqlInterpolationContext;
310
312
  importStatement(): ImportStatementContext;
313
+ importSelect(): ImportSelectContext;
314
+ importItem(): ImportItemContext;
311
315
  importURL(): ImportURLContext;
312
316
  docAnnotations(): DocAnnotationsContext;
313
317
  ignoredObjectAnnotations(): IgnoredObjectAnnotationsContext;
@@ -589,6 +593,31 @@ export declare class SqlInterpolationContext extends ParserRuleContext {
589
593
  export declare class ImportStatementContext extends ParserRuleContext {
590
594
  IMPORT(): TerminalNode;
591
595
  importURL(): ImportURLContext;
596
+ importSelect(): ImportSelectContext | undefined;
597
+ constructor(parent: ParserRuleContext | undefined, invokingState: number);
598
+ get ruleIndex(): number;
599
+ enterRule(listener: MalloyParserListener): void;
600
+ exitRule(listener: MalloyParserListener): void;
601
+ accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
602
+ }
603
+ export declare class ImportSelectContext extends ParserRuleContext {
604
+ OCURLY(): TerminalNode;
605
+ importItem(): ImportItemContext[];
606
+ importItem(i: number): ImportItemContext;
607
+ CCURLY(): TerminalNode;
608
+ FROM(): TerminalNode;
609
+ COMMA(): TerminalNode[];
610
+ COMMA(i: number): TerminalNode;
611
+ constructor(parent: ParserRuleContext | undefined, invokingState: number);
612
+ get ruleIndex(): number;
613
+ enterRule(listener: MalloyParserListener): void;
614
+ exitRule(listener: MalloyParserListener): void;
615
+ accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
616
+ }
617
+ export declare class ImportItemContext extends ParserRuleContext {
618
+ id(): IdContext[];
619
+ id(i: number): IdContext;
620
+ IS(): TerminalNode | undefined;
592
621
  constructor(parent: ParserRuleContext | undefined, invokingState: number);
593
622
  get ruleIndex(): number;
594
623
  enterRule(listener: MalloyParserListener): void;
@@ -740,8 +769,9 @@ export declare class QueryByNameContext extends RefinableQueryContext {
740
769
  }
741
770
  export declare class QueryByTurtleNameContext extends RefinableQueryContext {
742
771
  unextendableSource(): UnextendableSourceContext;
743
- ARROW(): TerminalNode;
744
772
  id(): IdContext;
773
+ ARROW(): TerminalNode | undefined;
774
+ DOT(): TerminalNode | undefined;
745
775
  constructor(ctx: RefinableQueryContext);
746
776
  enterRule(listener: MalloyParserListener): void;
747
777
  exitRule(listener: MalloyParserListener): void;