@malloydata/malloy 0.0.2 → 0.0.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.
Files changed (67) hide show
  1. package/README.md +12 -11
  2. package/dist/dialect/duckdb.d.ts +1 -1
  3. package/dist/dialect/postgres.d.ts +1 -1
  4. package/dist/index.d.ts +4 -4
  5. package/dist/lang/ast/ast-expr.d.ts +0 -1
  6. package/dist/lang/field-space.d.ts +9 -7
  7. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +108 -106
  8. package/dist/lang/lib/Malloy/MalloyLexer.js +1019 -1006
  9. package/dist/lang/lib/Malloy/MalloyParser.d.ts +581 -590
  10. package/dist/lang/lib/Malloy/MalloyParser.js +1141 -1202
  11. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2015 -0
  12. package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
  13. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1269 -0
  14. package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
  15. package/dist/lang/parse-to-ast.d.ts +3 -4
  16. package/dist/lang/parse-to-ast.js +1 -1
  17. package/dist/lang/parse-tree-walkers/document-completion-walker.js +2 -0
  18. package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +2 -2
  19. package/dist/malloy.d.ts +1 -1
  20. package/dist/md5.d.ts +1 -0
  21. package/dist/md5.js +30 -0
  22. package/dist/model/malloy_types.d.ts +3 -1
  23. package/package.json +9 -14
  24. package/dist/connection_utils.js +0 -56
  25. package/dist/dialect/dialect-map.d.ts +0 -3
  26. package/dist/dialect/dialect-map.js +0 -33
  27. package/dist/dialect/dialect.js +0 -77
  28. package/dist/dialect/dialect_map.js +0 -35
  29. package/dist/dialect/duckdb.js +0 -349
  30. package/dist/dialect/index.js +0 -27
  31. package/dist/dialect/postgres.js +0 -308
  32. package/dist/dialect/standardsql.js +0 -361
  33. package/dist/index.js +0 -47
  34. package/dist/lang/ast/apply-expr.js +0 -231
  35. package/dist/lang/ast/ast-expr.js +0 -1051
  36. package/dist/lang/ast/ast-main.js +0 -2086
  37. package/dist/lang/ast/ast-time-expr.js +0 -549
  38. package/dist/lang/ast/ast-types.js +0 -215
  39. package/dist/lang/ast/index.js +0 -34
  40. package/dist/lang/ast/time-utils.js +0 -94
  41. package/dist/lang/field-space.js +0 -629
  42. package/dist/lang/field-utils.js +0 -33
  43. package/dist/lang/index.js +0 -22
  44. package/dist/lang/parse-log.js +0 -41
  45. package/dist/lang/reference-list.js +0 -80
  46. package/dist/lang/space-field.js +0 -346
  47. package/dist/lang/test/document-help-context-walker.spec.js +0 -45
  48. package/dist/lang/test/document-symbol-walker.spec.js +0 -100
  49. package/dist/lang/test/field-symbols.spec.js +0 -172
  50. package/dist/lang/test/parse.spec.js +0 -1936
  51. package/dist/lang/test/test-translator.js +0 -334
  52. package/dist/lang/zone.js +0 -97
  53. package/dist/malloy.js +0 -2354
  54. package/dist/model/index.js +0 -34
  55. package/dist/model/malloy-query.d.ts +0 -313
  56. package/dist/model/malloy-query.js +0 -2603
  57. package/dist/model/malloy-types.d.ts +0 -404
  58. package/dist/model/malloy-types.js +0 -242
  59. package/dist/model/malloy_query.js +0 -2996
  60. package/dist/model/malloy_types.js +0 -283
  61. package/dist/model/sql-block.d.ts +0 -11
  62. package/dist/model/sql-block.js +0 -38
  63. package/dist/model/sql_block.js +0 -41
  64. package/dist/model/utils.js +0 -84
  65. package/dist/runtime-types.d.ts +0 -116
  66. package/dist/runtime-types.js +0 -40
  67. package/dist/runtime_types.js +0 -15
@@ -1,629 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2021 Google LLC
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License
7
- * version 2 as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- */
14
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
- Object.defineProperty(o, "default", { enumerable: true, value: v });
27
- }) : function(o, v) {
28
- o["default"] = v;
29
- });
30
- var __importStar = (this && this.__importStar) || function (mod) {
31
- if (mod && mod.__esModule) return mod;
32
- var result = {};
33
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
34
- __setModuleDefault(result, mod);
35
- return result;
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.DefSpace = exports.IndexFieldSpace = exports.ProjectFieldSpace = exports.ReduceFieldSpace = exports.ResultSpace = exports.QuerySpace = exports.DynamicSpace = exports.StaticSpace = void 0;
39
- /* eslint-disable no-useless-constructor */
40
- const lodash_1 = require("lodash");
41
- const dialect_1 = require("../dialect");
42
- const model = __importStar(require("../model/malloy_types"));
43
- const ast_1 = require("./ast");
44
- const space_field_1 = require("./space-field");
45
- const field_utils_1 = require("./field-utils");
46
- /**
47
- * The father of all FieldSpaces is a wrapper for a StructDef.
48
- */
49
- class StaticSpace {
50
- constructor(sourceStructDef) {
51
- this.type = "fieldSpace";
52
- this.fromStruct = sourceStructDef;
53
- }
54
- whenComplete(step) {
55
- step();
56
- }
57
- dialectObj() {
58
- try {
59
- return (0, dialect_1.getDialect)(this.fromStruct.dialect);
60
- }
61
- catch {
62
- return undefined;
63
- }
64
- }
65
- fromFieldDef(from) {
66
- if (from.type === "struct") {
67
- return new space_field_1.StructSpaceField(from);
68
- }
69
- else if (model.isTurtleDef(from)) {
70
- return new space_field_1.QueryFieldStruct(this, from);
71
- }
72
- // TODO field has a filter and needs to be a filteredalias
73
- return new space_field_1.ColumnSpaceField(from);
74
- }
75
- get map() {
76
- if (this.memoMap === undefined) {
77
- this.memoMap = {};
78
- for (const f of this.fromStruct.fields) {
79
- const name = f.as || f.name;
80
- this.memoMap[name] = this.fromFieldDef(f);
81
- }
82
- if (this.fromStruct.parameters) {
83
- for (const [paramName, paramDef] of Object.entries(this.fromStruct.parameters)) {
84
- if (this.memoMap[paramName]) {
85
- throw new Error(`In struct '${this.fromStruct.as || this.fromStruct.name}': ` +
86
- ` : Field and parameter name conflict '${paramName}`);
87
- }
88
- this.memoMap[paramName] = new space_field_1.DefinedParameter(paramDef);
89
- }
90
- }
91
- }
92
- return this.memoMap;
93
- }
94
- dropEntries() {
95
- this.memoMap = {};
96
- }
97
- dropEntry(name) {
98
- delete this.map[name];
99
- }
100
- entry(name) {
101
- return this.map[name];
102
- }
103
- setEntry(name, value) {
104
- this.map[name] = value;
105
- }
106
- entries() {
107
- return Object.entries(this.map);
108
- }
109
- structDef() {
110
- return this.fromStruct;
111
- }
112
- emptyStructDef() {
113
- return { ...this.fromStruct, fields: [] };
114
- }
115
- lookup(path) {
116
- const head = path[0];
117
- const rest = path.slice(1);
118
- const found = this.entry(head.refString);
119
- if (!found) {
120
- return { error: `'${head}' is not defined`, found };
121
- }
122
- if (found instanceof space_field_1.SpaceField) {
123
- /*
124
- * TODO cache defs, post the addReference call to whenComplete
125
- *
126
- * In the cleanup phase of query space construction, it may check
127
- * the output space for ungrouping variables. However if an
128
- * ungrouping variable is a measure, the field expression value
129
- * needed to get the definition needs to be computed in the
130
- * input space of the query. There is a test which failed which
131
- * caused this code to be here, but this is really a bandaid.
132
- *
133
- * Some re-work of how to get the definition of a SpaceField
134
- * no matter what it is contained in needs to be thought out.
135
- *
136
- * ... or this check would look at the finalized output of
137
- * the namespace and not re-compile ...
138
- */
139
- const definition = found.fieldDef();
140
- if (definition) {
141
- head.addReference({
142
- type: found instanceof space_field_1.StructSpaceField
143
- ? "joinReference"
144
- : "fieldReference",
145
- definition,
146
- location: head.location,
147
- text: head.refString,
148
- });
149
- }
150
- }
151
- if (rest.length) {
152
- if (found instanceof space_field_1.StructSpaceField) {
153
- return found.fieldSpace.lookup(rest);
154
- }
155
- return {
156
- error: `'${head}' cannot contain a '${rest[0]}'`,
157
- found: undefined,
158
- };
159
- }
160
- return { found, error: undefined };
161
- }
162
- }
163
- exports.StaticSpace = StaticSpace;
164
- function isFieldSpace(x) {
165
- return x.type == "fieldSpace";
166
- }
167
- /**
168
- * Based on how things are constructed, the starting field space
169
- * can either be another field space or an existing structdef.
170
- * Using a SourceSpace allows a class to accept either one
171
- * and use either version at some future time.
172
- */
173
- class SourceSpace {
174
- constructor(sourceSpec) {
175
- this.sourceSpec = sourceSpec;
176
- this.spaceSpec = sourceSpec;
177
- }
178
- get structDef() {
179
- if (isFieldSpace(this.spaceSpec)) {
180
- if (!this.asStruct) {
181
- this.asStruct = this.spaceSpec.structDef();
182
- }
183
- return this.asStruct;
184
- }
185
- return this.spaceSpec;
186
- }
187
- get fieldSpace() {
188
- if (isFieldSpace(this.spaceSpec)) {
189
- return this.spaceSpec;
190
- }
191
- if (!this.asFS) {
192
- this.asFS = new StaticSpace(this.spaceSpec);
193
- }
194
- return this.asFS;
195
- }
196
- }
197
- /**
198
- * A FieldSpace which may undergo modification
199
- */
200
- class DynamicSpace extends StaticSpace {
201
- constructor(extending) {
202
- const source = new SourceSpace(extending);
203
- super((0, lodash_1.cloneDeep)(source.structDef));
204
- this.completions = [];
205
- this.complete = false;
206
- this.final = undefined;
207
- this.source = source;
208
- }
209
- /**
210
- * Factory for DynamicSpace when there are accept/except edits
211
- * @param from A structdef which seeds this space
212
- * @param choose A accept/except edit of the "from" fields
213
- */
214
- static filteredFrom(from, choose) {
215
- const edited = new DynamicSpace(from);
216
- if (choose) {
217
- const names = choose.refs.list;
218
- const oldMap = edited.entries();
219
- edited.dropEntries();
220
- for (const [symbol, value] of oldMap) {
221
- const included = !!names.find((f) => f.refString === symbol);
222
- const accepting = choose.edit === "accept";
223
- if (included === accepting) {
224
- edited.setEntry(symbol, value);
225
- }
226
- }
227
- }
228
- return edited;
229
- }
230
- whenComplete(finalizeStep) {
231
- if (this.complete) {
232
- finalizeStep();
233
- }
234
- else {
235
- this.completions.push(finalizeStep);
236
- }
237
- }
238
- isComplete() {
239
- this.complete = true;
240
- for (const step of this.completions) {
241
- step();
242
- }
243
- this.completions = [];
244
- }
245
- setEntry(name, value) {
246
- if (this.final) {
247
- throw new Error("Space already final");
248
- }
249
- super.setEntry(name, value);
250
- }
251
- addParameters(params) {
252
- for (const oneP of params) {
253
- this.setEntry(oneP.name, new space_field_1.AbstractParameter(oneP));
254
- }
255
- return this;
256
- }
257
- newEntry(name, astEl, entry) {
258
- if (this.entry(name)) {
259
- astEl.log(`Cannot redefine '${name}'`);
260
- return;
261
- }
262
- this.setEntry(name, entry);
263
- }
264
- addField(...defs) {
265
- for (const def of defs) {
266
- // TODO express the "three fields kinds" in a typesafe way
267
- // one of three kinds of fields are legal in an explore: expressions ...
268
- const elseLog = def.log;
269
- const elseType = def.elementType;
270
- if (def instanceof ast_1.FieldDeclaration) {
271
- const exprField = new space_field_1.ExpressionFieldFromAst(this, def);
272
- this.newEntry(exprField.name, def, exprField);
273
- // querry (turtle) fields
274
- }
275
- else if (def instanceof ast_1.TurtleDecl) {
276
- const name = def.name;
277
- this.newEntry(name, def, new space_field_1.QueryFieldAST(this, def, name));
278
- }
279
- else if (def instanceof ast_1.RenameField) {
280
- if (def.oldName.refString === def.newName) {
281
- def.log("Can't rename field to itself");
282
- continue;
283
- }
284
- const oldValue = def.oldName.getField(this);
285
- if (oldValue.found) {
286
- if (oldValue.found instanceof space_field_1.SpaceField) {
287
- this.setEntry(def.newName, new space_field_1.RenameSpaceField(oldValue.found, def.newName, def.location));
288
- this.dropEntry(def.oldName.refString);
289
- }
290
- else {
291
- def.log(`'${def.oldName}' cannot be renamed`);
292
- }
293
- }
294
- else {
295
- def.log(`Can't rename '${def.oldName}', no such field`);
296
- }
297
- }
298
- else if (def instanceof ast_1.Join) {
299
- this.newEntry(def.name.refString, def, new space_field_1.JoinSpaceField(this, def));
300
- }
301
- else {
302
- elseLog(`Internal error: Expected expression, query, or rename, got '${elseType}'`);
303
- }
304
- }
305
- }
306
- addFieldDef(fd) {
307
- this.setEntry((0, field_utils_1.nameOf)(fd), this.fromFieldDef(fd));
308
- }
309
- structDef() {
310
- const parameters = this.fromStruct.parameters || {};
311
- if (this.final === undefined) {
312
- this.final = {
313
- ...this.fromStruct,
314
- fields: [],
315
- };
316
- // Need to process the entities in specific order
317
- const fields = [];
318
- const joins = [];
319
- const turtles = [];
320
- const fixupJoins = [];
321
- for (const [name, spaceEntry] of this.entries()) {
322
- if (spaceEntry instanceof space_field_1.StructSpaceField) {
323
- joins.push([name, spaceEntry]);
324
- }
325
- else if (spaceEntry instanceof space_field_1.QueryField) {
326
- turtles.push([name, spaceEntry]);
327
- }
328
- else if (spaceEntry instanceof space_field_1.SpaceField) {
329
- fields.push([name, spaceEntry]);
330
- }
331
- else if (spaceEntry instanceof space_field_1.SpaceParam) {
332
- parameters[name] = spaceEntry.parameter();
333
- }
334
- }
335
- const reorderFields = [...fields, ...joins, ...turtles];
336
- for (const [fieldName, field] of reorderFields) {
337
- if (field instanceof space_field_1.JoinSpaceField) {
338
- const joinStruct = field.join.structDef();
339
- if (!ast_1.ErrorFactory.isErrorStructDef(joinStruct)) {
340
- this.final.fields.push(joinStruct);
341
- fixupJoins.push([field.join, joinStruct]);
342
- }
343
- }
344
- else {
345
- const fieldDef = field.fieldDef();
346
- if (fieldDef) {
347
- this.final.fields.push(fieldDef);
348
- }
349
- else {
350
- throw new Error(`'${fieldName}' doesn't have a FieldDef`);
351
- }
352
- }
353
- }
354
- if (Object.entries(parameters).length > 0) {
355
- this.final.parameters = parameters;
356
- }
357
- // If we have join expressions, we need to now go back and fill them in
358
- for (const [join, missingOn] of fixupJoins) {
359
- join.fixupJoinOn(this, missingOn);
360
- }
361
- }
362
- this.isComplete();
363
- return this.final;
364
- }
365
- }
366
- exports.DynamicSpace = DynamicSpace;
367
- /**
368
- * A namespace for Query operations. The have an input and an
369
- * output set of fields. The InputSpace is the QueryOperationSpace
370
- * which is where all expressions are evaluated, and the output
371
- * space is ResultSpace.
372
- *
373
- */
374
- class QuerySpace extends DynamicSpace {
375
- constructor(input, result) {
376
- const inputSpace = new SourceSpace(input);
377
- super(inputSpace.structDef);
378
- this.result = result;
379
- this.extendList = [];
380
- }
381
- extendSource(extendField) {
382
- this.addField(extendField);
383
- if (extendField instanceof ast_1.Join) {
384
- this.extendList.push(extendField.name.refString);
385
- }
386
- else {
387
- this.extendList.push(extendField.defineName);
388
- }
389
- }
390
- }
391
- exports.QuerySpace = QuerySpace;
392
- class ResultSpace extends DynamicSpace {
393
- constructor(queryInputSpace) {
394
- super(queryInputSpace.emptyStructDef());
395
- this.queryInputSpace = queryInputSpace;
396
- this.exprSpace = new QuerySpace(queryInputSpace, this);
397
- }
398
- log(s) {
399
- if (this.astEl) {
400
- this.astEl.log(s);
401
- }
402
- }
403
- addMembers(members) {
404
- for (const member of members) {
405
- if (member instanceof ast_1.FieldReference) {
406
- this.addReference(member);
407
- }
408
- else if (member instanceof ast_1.WildcardFieldReference) {
409
- this.addWild(member);
410
- }
411
- else {
412
- this.addField(member);
413
- }
414
- }
415
- }
416
- addReference(ref) {
417
- const refName = ref.outputName;
418
- if (this.entry(refName)) {
419
- ref.log(`Output already has a field named '${refName}'`);
420
- }
421
- else {
422
- this.setEntry(refName, new space_field_1.ReferenceField(ref));
423
- }
424
- }
425
- addWild(wild) {
426
- this.setEntry(wild.refString, new space_field_1.WildSpaceField(wild.refString));
427
- }
428
- /**
429
- * Check for the definition of an ungrouping reference in the result space,
430
- * or in the case of an exclude reference, if this query is nested
431
- * in another query, in the result space of a query that this query
432
- * is nested inside of.
433
- */
434
- checkUngroup(fn, isExclude) {
435
- if (!this.entry(fn.refString)) {
436
- if (isExclude && this.exprSpace.nestParent) {
437
- const parent = this.exprSpace.nestParent;
438
- parent.whenComplete(() => {
439
- parent.result.checkUngroup(fn, isExclude);
440
- });
441
- }
442
- else {
443
- const uName = isExclude ? "exclude()" : "all()";
444
- fn.log(`${uName} '${fn.refString}' is missing from query output`);
445
- }
446
- }
447
- }
448
- addQueryItems(...qiList) {
449
- for (const qi of qiList) {
450
- if (qi instanceof ast_1.FieldReference || qi instanceof ast_1.NestReference) {
451
- this.addReference(qi);
452
- }
453
- else if (qi instanceof ast_1.FieldDeclaration) {
454
- this.addField(qi);
455
- }
456
- else if ((0, ast_1.isNestedQuery)(qi)) {
457
- const qf = new space_field_1.QueryFieldAST(this, qi, qi.name);
458
- qf.nestParent = this.exprSpace;
459
- this.setEntry(qi.name, qf);
460
- }
461
- else {
462
- // Compiler will error if we don't handle all cases
463
- const _itemNotHandled = qi;
464
- }
465
- }
466
- }
467
- canContain(_qd) {
468
- return true;
469
- }
470
- queryFieldDefs() {
471
- const fields = [];
472
- for (const [name, field] of this.entries()) {
473
- if (field instanceof space_field_1.SpaceField) {
474
- const fieldQueryDef = field.getQueryFieldDef(this.exprSpace);
475
- if (fieldQueryDef) {
476
- if (this.canContain(fieldQueryDef)) {
477
- fields.push(fieldQueryDef);
478
- }
479
- else {
480
- this.log(`'${name}' not legal in ${this.segmentType}`);
481
- }
482
- }
483
- else {
484
- throw new Error(`'${name}' does not have a QueryFieldDef`);
485
- }
486
- }
487
- }
488
- this.isComplete();
489
- return fields;
490
- }
491
- getQuerySegment(rf) {
492
- const p = this.getPipeSegment(rf);
493
- if (model.isQuerySegment(p)) {
494
- return p;
495
- }
496
- throw new Error("TODO NOT POSSIBLE");
497
- }
498
- getPipeSegment(refineFrom) {
499
- if (this.segmentType == "index") {
500
- // TODO ... should make this go away
501
- throw new Error("INDEX FIELD PIPE SEGMENT MIS HANDLED");
502
- }
503
- if (refineFrom === null || refineFrom === void 0 ? void 0 : refineFrom.extendSource) {
504
- for (const xField of refineFrom.extendSource) {
505
- this.exprSpace.addFieldDef(xField);
506
- }
507
- }
508
- const segment = {
509
- type: this.segmentType,
510
- fields: this.queryFieldDefs(),
511
- };
512
- segment.fields = (0, field_utils_1.mergeFields)(refineFrom === null || refineFrom === void 0 ? void 0 : refineFrom.fields, segment.fields);
513
- if (refineFrom === null || refineFrom === void 0 ? void 0 : refineFrom.extendSource) {
514
- segment.extendSource = refineFrom.extendSource;
515
- }
516
- if (this.exprSpace.extendList.length > 0) {
517
- const newExtends = [];
518
- const extendedStruct = this.exprSpace.structDef();
519
- for (const extendName of this.exprSpace.extendList) {
520
- const extendEnt = extendedStruct.fields.find((f) => (0, field_utils_1.nameOf)(f) == extendName);
521
- if (extendEnt) {
522
- newExtends.push(extendEnt);
523
- }
524
- }
525
- segment.extendSource = (0, field_utils_1.mergeFields)(segment.extendSource, newExtends);
526
- }
527
- this.isComplete();
528
- return segment;
529
- }
530
- }
531
- exports.ResultSpace = ResultSpace;
532
- /**
533
- * Reduce and project queries use a "QuerySpace"
534
- */
535
- class ReduceFieldSpace extends ResultSpace {
536
- constructor() {
537
- super(...arguments);
538
- this.segmentType = "reduce";
539
- }
540
- }
541
- exports.ReduceFieldSpace = ReduceFieldSpace;
542
- class ProjectFieldSpace extends ResultSpace {
543
- constructor() {
544
- super(...arguments);
545
- this.segmentType = "project";
546
- }
547
- canContain(qd) {
548
- if (typeof qd !== "string") {
549
- if (model.isFilteredAliasedName(qd)) {
550
- return true;
551
- }
552
- if (qd.type === "turtle") {
553
- this.log("Cannot nest queries in project");
554
- return false;
555
- }
556
- if (qd.aggregate) {
557
- this.log("Cannot add aggregate measures to project");
558
- return false;
559
- }
560
- }
561
- return true;
562
- }
563
- }
564
- exports.ProjectFieldSpace = ProjectFieldSpace;
565
- class IndexFieldSpace extends ResultSpace {
566
- constructor() {
567
- super(...arguments);
568
- this.segmentType = "index";
569
- this.fieldList = new Set();
570
- }
571
- addReference(ref) {
572
- if (ref.getField(this.exprSpace).found) {
573
- this.fieldList.add(ref.refString);
574
- }
575
- }
576
- addWild(wild) {
577
- this.fieldList.add(wild.refString);
578
- }
579
- getPipeSegment(refineIndex) {
580
- if (refineIndex && refineIndex.fields) {
581
- for (const exists of refineIndex.fields) {
582
- if (typeof exists == "string") {
583
- this.fieldList.add(exists);
584
- }
585
- }
586
- }
587
- this.isComplete();
588
- return {
589
- type: "index",
590
- fields: Array.from(this.fieldList.values()),
591
- };
592
- }
593
- }
594
- exports.IndexFieldSpace = IndexFieldSpace;
595
- /**
596
- * Used to detect references to fields in the statement which defines them
597
- */
598
- class DefSpace {
599
- constructor(realFS, circular) {
600
- this.realFS = realFS;
601
- this.circular = circular;
602
- this.type = "fieldSpace";
603
- this.foundCircle = false;
604
- }
605
- structDef() {
606
- return this.realFS.structDef();
607
- }
608
- emptyStructDef() {
609
- return this.realFS.emptyStructDef();
610
- }
611
- lookup(symbol) {
612
- if (symbol[0] && symbol[0].refString === this.circular.defineName) {
613
- this.foundCircle = true;
614
- return {
615
- error: `Circular reference to '${this.circular.defineName}' in definition`,
616
- found: undefined,
617
- };
618
- }
619
- return this.realFS.lookup(symbol);
620
- }
621
- dialectObj() {
622
- return this.realFS.dialectObj();
623
- }
624
- whenComplete(step) {
625
- this.realFS.whenComplete(step);
626
- }
627
- }
628
- exports.DefSpace = DefSpace;
629
- //# sourceMappingURL=field-space.js.map
@@ -1,33 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2021 Google LLC
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License
7
- * version 2 as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.mergeFields = exports.nameOf = void 0;
16
- function nameOf(qfd) {
17
- if (typeof qfd == "string") {
18
- return qfd;
19
- }
20
- return qfd.as || qfd.name;
21
- }
22
- exports.nameOf = nameOf;
23
- function mergeFields(older, newer) {
24
- if (older == undefined) {
25
- return newer;
26
- }
27
- const redefined = new Set(newer.map((f) => nameOf(f)));
28
- const merged = older.filter((f) => !redefined.has(nameOf(f)));
29
- merged.push(...newer);
30
- return merged;
31
- }
32
- exports.mergeFields = mergeFields;
33
- //# sourceMappingURL=field-utils.js.map
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2021 Google LLC
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License
7
- * version 2 as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.HighlightType = exports.exploreQueryWalkerBuilder = exports.MalloyTranslator = void 0;
16
- var parse_malloy_1 = require("./parse-malloy");
17
- Object.defineProperty(exports, "MalloyTranslator", { enumerable: true, get: function () { return parse_malloy_1.MalloyTranslator; } });
18
- var explore_query_walker_1 = require("./parse-tree-walkers/explore-query-walker");
19
- Object.defineProperty(exports, "exploreQueryWalkerBuilder", { enumerable: true, get: function () { return explore_query_walker_1.exploreQueryWalkerBuilder; } });
20
- var document_highlight_walker_1 = require("./parse-tree-walkers/document-highlight-walker");
21
- Object.defineProperty(exports, "HighlightType", { enumerable: true, get: function () { return document_highlight_walker_1.HighlightType; } });
22
- //# sourceMappingURL=index.js.map