@malloydata/malloy 0.0.43 → 0.0.44-dev230623185845

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 (102) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.js +3 -1
  3. package/dist/lang/ast/elements/define-query.d.ts +7 -1
  4. package/dist/lang/ast/elements/define-query.js +10 -1
  5. package/dist/lang/ast/elements/define-source.d.ts +7 -1
  6. package/dist/lang/ast/elements/define-source.js +16 -9
  7. package/dist/lang/ast/elements/pipeline-desc.d.ts +2 -1
  8. package/dist/lang/ast/elements/pipeline-desc.js +6 -2
  9. package/dist/lang/ast/elements/refined-source.d.ts +5 -4
  10. package/dist/lang/ast/elements/refined-source.js +5 -0
  11. package/dist/lang/ast/expressions/expr-id-reference.js +4 -4
  12. package/dist/lang/ast/field-space/column-space-field.d.ts +1 -1
  13. package/dist/lang/ast/field-space/column-space-field.js +3 -3
  14. package/dist/lang/ast/field-space/field-definition-value.d.ts +1 -1
  15. package/dist/lang/ast/field-space/field-definition-value.js +16 -10
  16. package/dist/lang/ast/field-space/query-field-struct.js +1 -0
  17. package/dist/lang/ast/field-space/query-spaces.js +4 -1
  18. package/dist/lang/ast/field-space/reference-field.d.ts +8 -2
  19. package/dist/lang/ast/field-space/reference-field.js +51 -9
  20. package/dist/lang/ast/index.d.ts +2 -2
  21. package/dist/lang/ast/index.js +2 -2
  22. package/dist/lang/ast/query-elements/anonymous-query.d.ts +6 -1
  23. package/dist/lang/ast/query-elements/anonymous-query.js +8 -0
  24. package/dist/lang/ast/query-elements/existing-query.js +3 -0
  25. package/dist/lang/ast/query-elements/full-query.js +7 -4
  26. package/dist/lang/ast/query-elements/run-query.d.ts +6 -1
  27. package/dist/lang/ast/query-elements/run-query.js +11 -1
  28. package/dist/lang/ast/query-items/field-declaration.d.ts +6 -2
  29. package/dist/lang/ast/query-items/field-declaration.js +6 -0
  30. package/dist/lang/ast/query-items/field-references.d.ts +13 -5
  31. package/dist/lang/ast/query-items/field-references.js +10 -4
  32. package/dist/lang/ast/query-properties/aggregate.d.ts +3 -3
  33. package/dist/lang/ast/query-properties/aggregate.js +5 -4
  34. package/dist/lang/ast/query-properties/calculate.d.ts +3 -3
  35. package/dist/lang/ast/query-properties/calculate.js +5 -4
  36. package/dist/lang/ast/query-properties/declare-fields.d.ts +4 -3
  37. package/dist/lang/ast/query-properties/declare-fields.js +5 -4
  38. package/dist/lang/ast/query-properties/dimensions.d.ts +4 -0
  39. package/dist/lang/ast/query-properties/{dimmensions.js → dimensions.js} +4 -3
  40. package/dist/lang/ast/query-properties/extend.d.ts +1 -1
  41. package/dist/lang/ast/query-properties/extend.js +3 -2
  42. package/dist/lang/ast/query-properties/filters.d.ts +0 -1
  43. package/dist/lang/ast/query-properties/filters.js +2 -2
  44. package/dist/lang/ast/query-properties/group-by.d.ts +3 -3
  45. package/dist/lang/ast/query-properties/group-by.js +5 -4
  46. package/dist/lang/ast/query-properties/joins.d.ts +10 -4
  47. package/dist/lang/ast/query-properties/joins.js +16 -2
  48. package/dist/lang/ast/query-properties/measures.d.ts +1 -2
  49. package/dist/lang/ast/query-properties/measures.js +3 -2
  50. package/dist/lang/ast/query-properties/nest.d.ts +5 -1
  51. package/dist/lang/ast/query-properties/nest.js +11 -1
  52. package/dist/lang/ast/query-properties/nests.d.ts +3 -2
  53. package/dist/lang/ast/query-properties/nests.js +4 -3
  54. package/dist/lang/ast/query-properties/ordering.d.ts +1 -0
  55. package/dist/lang/ast/query-properties/ordering.js +2 -1
  56. package/dist/lang/ast/query-properties/project-statement.d.ts +3 -3
  57. package/dist/lang/ast/query-properties/project-statement.js +5 -4
  58. package/dist/lang/ast/query-properties/qop-desc.d.ts +1 -1
  59. package/dist/lang/ast/query-properties/qop-desc.js +3 -2
  60. package/dist/lang/ast/source-properties/renames.d.ts +1 -1
  61. package/dist/lang/ast/source-properties/renames.js +3 -2
  62. package/dist/lang/ast/source-properties/turtles.d.ts +3 -3
  63. package/dist/lang/ast/source-properties/turtles.js +5 -4
  64. package/dist/lang/ast/types/definition-list.d.ts +10 -0
  65. package/dist/lang/ast/types/definition-list.js +52 -0
  66. package/dist/lang/ast/types/malloy-element.d.ts +21 -6
  67. package/dist/lang/ast/types/malloy-element.js +45 -13
  68. package/dist/lang/ast/types/noteable.d.ts +12 -0
  69. package/dist/lang/ast/types/noteable.js +42 -0
  70. package/dist/lang/ast/types/query-extend-property.d.ts +1 -1
  71. package/dist/lang/ast/types/query-extend-property.js +2 -2
  72. package/dist/lang/ast/types/query-property.d.ts +3 -2
  73. package/dist/lang/ast/types/query-property.js +2 -0
  74. package/dist/lang/ast/types/source-desc.d.ts +5 -0
  75. package/dist/lang/ast/types/{explore-desc.js → source-desc.js} +7 -6
  76. package/dist/lang/ast/types/source-property.d.ts +2 -2
  77. package/dist/lang/ast/types/source-property.js +2 -0
  78. package/dist/lang/ast/types/space-field.d.ts +1 -0
  79. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +56 -54
  80. package/dist/lang/lib/Malloy/MalloyLexer.js +1051 -1042
  81. package/dist/lang/lib/Malloy/MalloyParser.d.ts +326 -182
  82. package/dist/lang/lib/Malloy/MalloyParser.js +2894 -1718
  83. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +133 -19
  84. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +83 -11
  85. package/dist/lang/malloy-to-ast.d.ts +23 -10
  86. package/dist/lang/malloy-to-ast.js +144 -122
  87. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +2 -1
  88. package/dist/lang/test/annotation.spec.d.ts +1 -0
  89. package/dist/lang/test/annotation.spec.js +565 -0
  90. package/dist/lang/test/parse.spec.js +20 -19
  91. package/dist/lang/test/test-translator.d.ts +2 -2
  92. package/dist/lang/test/test-translator.js +27 -15
  93. package/dist/malloy.d.ts +11 -5
  94. package/dist/malloy.js +16 -0
  95. package/dist/model/malloy_query.js +10 -0
  96. package/dist/model/malloy_types.d.ts +19 -2
  97. package/dist/model/malloy_types.js +1 -1
  98. package/dist/tags.d.ts +21 -0
  99. package/dist/tags.js +155 -0
  100. package/package.json +1 -1
  101. package/dist/lang/ast/query-properties/dimmensions.d.ts +0 -5
  102. package/dist/lang/ast/types/explore-desc.d.ts +0 -5
@@ -0,0 +1,565 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const test_translator_1 = require("./test-translator");
26
+ require("./parse-expects");
27
+ const defaultTags = {
28
+ blockNotes: ['# blockNote\n'],
29
+ notes: ['# note\n', '# b4-is\n', '# after-is\n'],
30
+ };
31
+ const turtleDef = `
32
+ source: na is a {
33
+ # blockNote
34
+ query:
35
+ # note
36
+ note_a
37
+ # b4-is
38
+ is
39
+ # after-is
40
+ {project: *}
41
+ }
42
+ `;
43
+ describe('document annotation', () => {
44
+ test('every source annotation point', () => {
45
+ const m = new test_translator_1.TestTranslator(`
46
+ # blockNote
47
+ source:
48
+ # note
49
+ note_a
50
+ # b4-is
51
+ is
52
+ # after-is
53
+ a
54
+ # note1
55
+ note_b is a
56
+ `);
57
+ expect(m).toTranslate();
58
+ const note_a = m.getSourceDef('note_a');
59
+ expect(note_a).toBeDefined();
60
+ if (note_a) {
61
+ expect(note_a.annotation).toEqual(defaultTags);
62
+ }
63
+ const note_b = m.getSourceDef('note_b');
64
+ expect(note_b).toBeDefined();
65
+ if (note_b) {
66
+ expect(note_b.annotation).toEqual({
67
+ blockNotes: defaultTags.blockNotes,
68
+ notes: ['# note1\n'],
69
+ });
70
+ }
71
+ });
72
+ test('multi line source annotation', () => {
73
+ const m = new test_translator_1.TestTranslator(`
74
+ # note1
75
+ # note1.1
76
+ source: note_a is a
77
+ `);
78
+ expect(m).toTranslate();
79
+ const note_a = m.getSourceDef('note_a');
80
+ expect(note_a).toBeDefined();
81
+ if (note_a) {
82
+ expect(note_a.annotation).toEqual({
83
+ blockNotes: ['# note1\n', '# note1.1\n'],
84
+ });
85
+ }
86
+ });
87
+ test('inherited annotation source', () => {
88
+ const m = new test_translator_1.TestTranslator(`
89
+ # note0
90
+ source: note_b is a
91
+ # note1
92
+ source: note_a is note_b { primary_key: ai }
93
+ `);
94
+ expect(m).toTranslate();
95
+ const note_a = m.getSourceDef('note_a');
96
+ expect(note_a).toBeDefined();
97
+ if (note_a) {
98
+ expect(note_a.annotation).toEqual({
99
+ inherits: { blockNotes: ['# note0\n'] },
100
+ blockNotes: ['# note1\n'],
101
+ });
102
+ }
103
+ });
104
+ test('define full query annotation points', () => {
105
+ const m = new test_translator_1.TestTranslator(`
106
+ # blockNote
107
+ query:
108
+ # note
109
+ note_a
110
+ # b4-is
111
+ is
112
+ # after-is
113
+ a -> {project: *}
114
+ `);
115
+ expect(m).toTranslate();
116
+ const note_a = m.getQuery('note_a');
117
+ expect(note_a).toBeDefined();
118
+ if (note_a) {
119
+ expect(note_a.annotation).toEqual(defaultTags);
120
+ }
121
+ });
122
+ test('anonymous query annotation points', () => {
123
+ const m = new test_translator_1.TestTranslator(`
124
+ # note1
125
+ query:
126
+ # note2
127
+ a -> {project: *}
128
+ `);
129
+ expect(m).toTranslate();
130
+ const note_a = m.getQuery(0);
131
+ expect(note_a).toBeDefined();
132
+ if (note_a) {
133
+ expect(note_a.annotation).toEqual({
134
+ blockNotes: ['# note1\n'],
135
+ notes: ['# note2\n'],
136
+ });
137
+ }
138
+ });
139
+ test('run statement annotation points', () => {
140
+ const m = new test_translator_1.TestTranslator(`
141
+ # note1
142
+ run:
143
+ # note2
144
+ a -> {project: *}
145
+ `);
146
+ expect(m).toTranslate();
147
+ const note_a = m.getQuery(0);
148
+ expect(note_a).toBeDefined();
149
+ if (note_a) {
150
+ expect(note_a.annotation).toEqual({
151
+ blockNotes: ['# note1\n'],
152
+ notes: ['# note2\n'],
153
+ });
154
+ }
155
+ });
156
+ test('multi line query annotation', () => {
157
+ const m = new test_translator_1.TestTranslator(`
158
+ # note1
159
+ # note2
160
+ query: note_a is a -> {project: *}
161
+ `);
162
+ expect(m).toTranslate();
163
+ const note_a = m.getQuery('note_a');
164
+ expect(note_a).toBeDefined();
165
+ if (note_a) {
166
+ expect(note_a.annotation).toEqual({
167
+ blockNotes: ['# note1\n', '# note2\n'],
168
+ });
169
+ }
170
+ });
171
+ test('inherited annotation query', () => {
172
+ const m = new test_translator_1.TestTranslator(`
173
+ # noteb0
174
+ query:
175
+ # noteb1
176
+ note_b is a -> { project: * }
177
+ # note1
178
+ query: note_a is -> note_b { where: astr = 'a' }
179
+ `);
180
+ expect(m).toTranslate();
181
+ const note_a = m.getQuery('note_a');
182
+ expect(note_a).toBeDefined();
183
+ if (note_a) {
184
+ expect(note_a.annotation).toEqual({
185
+ inherits: { blockNotes: ['# noteb0\n'], notes: ['# noteb1\n'] },
186
+ blockNotes: ['# note1\n'],
187
+ });
188
+ }
189
+ });
190
+ test('query from turtle inherits turtle annotation', () => {
191
+ const m = new test_translator_1.TestTranslator(`
192
+ ${turtleDef}
193
+ query: na->note_a
194
+ `);
195
+ expect(m).toTranslate();
196
+ const note_a = m.getQuery(0);
197
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toBeDefined();
198
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual({ inherits: defaultTags });
199
+ });
200
+ test('model annotations', () => {
201
+ var _a;
202
+ const m = new test_translator_1.TestTranslator(`
203
+ ## model1
204
+ ## model2
205
+ `);
206
+ expect(m).toTranslate();
207
+ const model = (_a = m.translate()) === null || _a === void 0 ? void 0 : _a.translated;
208
+ expect(model).toBeDefined();
209
+ const notes = model === null || model === void 0 ? void 0 : model.modelDef.annotation;
210
+ expect(notes).toEqual({ notes: ['## model1\n', '## model2\n'] });
211
+ });
212
+ test('ignores objectless object annotations', () => {
213
+ const m = new test_translator_1.TestTranslator(`
214
+ # note1
215
+ ## model1
216
+ `);
217
+ expect(m).toTranslate();
218
+ });
219
+ });
220
+ describe('source definition annotations', () => {
221
+ test('turtle block annotation', () => {
222
+ const m = new test_translator_1.TestTranslator(turtleDef);
223
+ expect(m).toTranslate();
224
+ const na = m.getSourceDef('na');
225
+ expect(na).toBeDefined();
226
+ if (na) {
227
+ const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
228
+ expect(note_a).toBeDefined();
229
+ expect(note_a.annotation).toEqual(defaultTags);
230
+ }
231
+ });
232
+ test('refined turtle inherits annotation', () => {
233
+ const m = new test_translator_1.TestTranslator(`
234
+ ${turtleDef}
235
+ source: new_na is na + {
236
+ query: new_note_a is note_a
237
+ }
238
+ `);
239
+ expect(m).toTranslate();
240
+ const na = m.getSourceDef('new_na');
241
+ expect(na).toBeDefined();
242
+ if (na) {
243
+ const note_a = (0, test_translator_1.getFieldDef)(na, 'new_note_a');
244
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toBeDefined();
245
+ expect(note_a.annotation).toEqual({ inherits: defaultTags });
246
+ }
247
+ });
248
+ test('dimension block annotation', () => {
249
+ const m = new test_translator_1.TestTranslator(`
250
+ source: na is a {
251
+ # blockNote
252
+ dimension:
253
+ # note
254
+ note_a
255
+ # b4-is
256
+ is
257
+ # after-is
258
+ astr
259
+ }
260
+ `);
261
+ expect(m).toTranslate();
262
+ const na = m.getSourceDef('na');
263
+ expect(na).toBeDefined();
264
+ if (na) {
265
+ const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
266
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
267
+ }
268
+ });
269
+ test('measure block annotation', () => {
270
+ const m = new test_translator_1.TestTranslator(`
271
+ source: na is a {
272
+ # blockNote
273
+ measure:
274
+ # note
275
+ note_a
276
+ # b4-is
277
+ is
278
+ # after-is
279
+ max(astr)
280
+ }
281
+ `);
282
+ expect(m).toTranslate();
283
+ const na = m.getSourceDef('na');
284
+ expect(na).toBeDefined();
285
+ if (na) {
286
+ const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
287
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
288
+ }
289
+ });
290
+ test('join_one-with block annotation', () => {
291
+ const m = new test_translator_1.TestTranslator(`
292
+ source: na is a {
293
+ # blockNote
294
+ join_one:
295
+ # note
296
+ note_a
297
+ # b4-is
298
+ is
299
+ # after-is
300
+ ab with astr
301
+ }
302
+ `);
303
+ expect(m).toTranslate();
304
+ const na = m.getSourceDef('na');
305
+ expect(na).toBeDefined();
306
+ if (na) {
307
+ const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
308
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
309
+ }
310
+ });
311
+ test('join_many-on block annotation', () => {
312
+ const m = new test_translator_1.TestTranslator(`
313
+ source: na is a {
314
+ # blockNote
315
+ join_many:
316
+ # note
317
+ note_a
318
+ # b4-is
319
+ is
320
+ # after-is
321
+ a on note_a.astr = astr
322
+ }
323
+ `);
324
+ expect(m).toTranslate();
325
+ const na = m.getSourceDef('na');
326
+ expect(na).toBeDefined();
327
+ if (na) {
328
+ const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
329
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
330
+ }
331
+ });
332
+ test('ignores model annotation', () => {
333
+ const m = new test_translator_1.TestTranslator(`
334
+ source: na is a {
335
+ ## model1
336
+ }
337
+ `);
338
+ expect(m).toTranslate();
339
+ });
340
+ });
341
+ describe('query operation annotations', () => {
342
+ test('ignores model annotation', () => {
343
+ const m = new test_translator_1.TestTranslator(`
344
+ query: a -> {
345
+ ## model1
346
+ project: *
347
+ }
348
+ `);
349
+ expect(m).toTranslate();
350
+ });
351
+ test('project new definition annotation', () => {
352
+ const m = new test_translator_1.TestTranslator(`
353
+ query: findme is a -> {
354
+ # blockNote
355
+ project:
356
+ # note
357
+ note_a
358
+ # b4-is
359
+ is
360
+ # after-is
361
+ astr
362
+ }
363
+ `);
364
+ expect(m).toTranslate();
365
+ const foundYou = m.getQuery('findme');
366
+ expect(foundYou).toBeDefined();
367
+ if (foundYou) {
368
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
369
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
370
+ }
371
+ });
372
+ test('project ref inherits annotation', () => {
373
+ const m = new test_translator_1.TestTranslator(`
374
+ query: a + {
375
+ # blockNote
376
+ dimension:
377
+ # note
378
+ note_a
379
+ # b4-is
380
+ is
381
+ # after-is
382
+ astr
383
+ } -> {
384
+ # note1
385
+ project:
386
+ # note2
387
+ note_a
388
+ }
389
+ `);
390
+ expect(m).toTranslate();
391
+ const foundYou = m.getQuery(0);
392
+ expect(foundYou).toBeDefined();
393
+ if (foundYou) {
394
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
395
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual({
396
+ inherits: defaultTags,
397
+ blockNotes: ['# note1\n'],
398
+ notes: ['# note2\n'],
399
+ });
400
+ }
401
+ });
402
+ test('group_by def', () => {
403
+ const m = new test_translator_1.TestTranslator(`
404
+ query: findme is a -> {
405
+ # blockNote
406
+ group_by:
407
+ # note
408
+ note_a
409
+ # b4-is
410
+ is
411
+ # after-is
412
+ astr
413
+ }
414
+ `);
415
+ expect(m).toTranslate();
416
+ const foundYou = m.getQuery('findme');
417
+ expect(foundYou).toBeDefined();
418
+ if (foundYou) {
419
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
420
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
421
+ }
422
+ });
423
+ test('caculate def', () => {
424
+ const m = new test_translator_1.TestTranslator(`
425
+ query: findme is a -> {
426
+ group_by: astr, ai
427
+ # blockNote
428
+ calculate:
429
+ # note
430
+ note_a
431
+ # b4-is
432
+ is
433
+ # after-is
434
+ lag(ai)
435
+ }
436
+ `);
437
+ expect(m).toTranslate();
438
+ const foundYou = m.getQuery('findme');
439
+ expect(foundYou).toBeDefined();
440
+ if (foundYou) {
441
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
442
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
443
+ }
444
+ });
445
+ test('group_by ref inherits', () => {
446
+ const m = new test_translator_1.TestTranslator(`
447
+ source: aa is a + {
448
+ # blockNote
449
+ dimension:
450
+ # note
451
+ note_a
452
+ # b4-is
453
+ is
454
+ # after-is
455
+ astr
456
+ }
457
+ query: findme is aa -> {
458
+ # note1
459
+ group_by:
460
+ # note2
461
+ note_a
462
+ }
463
+ `);
464
+ expect(m).toTranslate();
465
+ const foundYou = m.getQuery('findme');
466
+ expect(foundYou).toBeDefined();
467
+ if (foundYou) {
468
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
469
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual({
470
+ blockNotes: ['# note1\n'],
471
+ inherits: defaultTags,
472
+ notes: ['# note2\n'],
473
+ });
474
+ }
475
+ });
476
+ test('aggregate def', () => {
477
+ const m = new test_translator_1.TestTranslator(`
478
+ query: findme is a -> {
479
+ # blockNote
480
+ aggregate:
481
+ # note
482
+ note_a
483
+ # b4-is
484
+ is
485
+ # after-is
486
+ max(astr)
487
+ }
488
+ `);
489
+ expect(m).toTranslate();
490
+ const foundYou = m.getQuery('findme');
491
+ expect(foundYou).toBeDefined();
492
+ if (foundYou) {
493
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
494
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
495
+ }
496
+ });
497
+ test('aggregate ref inherits', () => {
498
+ const m = new test_translator_1.TestTranslator(`
499
+ source: aa is a + {
500
+ # blockNote
501
+ measure:
502
+ # note
503
+ note_a
504
+ # b4-is
505
+ is
506
+ # after-is
507
+ max(astr)
508
+ }
509
+ query: findme is aa -> {
510
+ # note1
511
+ aggregate:
512
+ # note2
513
+ note_a
514
+ }
515
+ `);
516
+ expect(m).toTranslate();
517
+ const foundYou = m.getQuery('findme');
518
+ expect(foundYou).toBeDefined();
519
+ if (foundYou) {
520
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
521
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual({
522
+ blockNotes: ['# note1\n'],
523
+ inherits: defaultTags,
524
+ notes: ['# note2\n'],
525
+ });
526
+ }
527
+ });
528
+ test('nest annotation', () => {
529
+ const m = new test_translator_1.TestTranslator(`
530
+ query: findme is ab -> {
531
+ # blockNote
532
+ nest:
533
+ # note
534
+ note_a
535
+ # b4-is
536
+ is
537
+ # after-is
538
+ aturtle
539
+ }
540
+ `);
541
+ expect(m).toTranslate();
542
+ const foundYou = m.getQuery('findme');
543
+ expect(foundYou).toBeDefined();
544
+ if (foundYou) {
545
+ const note_a = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_a');
546
+ expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toEqual(defaultTags);
547
+ }
548
+ });
549
+ test('nest from existing inherits annotation', () => {
550
+ const m = new test_translator_1.TestTranslator(`
551
+ ${turtleDef}
552
+ query: na -> {
553
+ nest: note_b is note_a
554
+ }
555
+ `);
556
+ expect(m).toTranslate();
557
+ const foundYou = m.getQuery(0);
558
+ expect(foundYou).toBeDefined();
559
+ if (foundYou) {
560
+ const note_b = (0, test_translator_1.getFieldDef)(foundYou.pipeline[0], 'note_b');
561
+ expect(note_b === null || note_b === void 0 ? void 0 : note_b.annotation).toEqual({ inherits: defaultTags });
562
+ }
563
+ });
564
+ });
565
+ //# sourceMappingURL=annotation.spec.js.map
@@ -1641,12 +1641,13 @@ describe('error handling', () => {
1641
1641
  expect('}%').translationToFailWith(/extraneous input '}%' expecting/);
1642
1642
  });
1643
1643
  test('bad sql in sql block', () => {
1644
- const badModel = new test_translator_1.TestTranslator('sql: { select: """)""" }');
1645
- expect(badModel).toParse();
1646
- const needSchema = badModel.translate();
1644
+ const badSelect = (0, test_translator_1.model) `sql: someName is { select: """)""" }`;
1645
+ const badTrans = badSelect.translator;
1646
+ expect(badSelect).toParse();
1647
+ const needSchema = badTrans.translate();
1647
1648
  expect(needSchema.compileSQL).toBeDefined();
1648
1649
  if (needSchema.compileSQL) {
1649
- badModel.update({
1650
+ badTrans.update({
1650
1651
  errors: {
1651
1652
  compileSQL: {
1652
1653
  [needSchema.compileSQL.name]: 'ZZZZ',
@@ -1654,7 +1655,7 @@ describe('error handling', () => {
1654
1655
  },
1655
1656
  });
1656
1657
  }
1657
- expect(badModel).translationToFailWith('Invalid SQL, ZZZZ');
1658
+ expect(badTrans).translationToFailWith('Invalid SQL, ZZZZ');
1658
1659
  });
1659
1660
  });
1660
1661
  function getSelectOneStruct(sqlBlock) {
@@ -1697,7 +1698,7 @@ describe('source locations', () => {
1697
1698
  const m = new test_translator_1.TestTranslator(source.code);
1698
1699
  expect(m).toTranslate();
1699
1700
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1700
- const x = (0, test_translator_1.getField)(na, 'x');
1701
+ const x = (0, test_translator_1.getFieldDef)(na, 'x');
1701
1702
  expect(x.location).toMatchObject(source.locations[0]);
1702
1703
  });
1703
1704
  test('location of defined measure', () => {
@@ -1705,7 +1706,7 @@ describe('source locations', () => {
1705
1706
  const m = new test_translator_1.TestTranslator(source.code);
1706
1707
  expect(m).toTranslate();
1707
1708
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1708
- const x = (0, test_translator_1.getField)(na, 'x');
1709
+ const x = (0, test_translator_1.getFieldDef)(na, 'x');
1709
1710
  expect(x.location).toMatchObject(source.locations[0]);
1710
1711
  });
1711
1712
  test('location of defined query', () => {
@@ -1713,7 +1714,7 @@ describe('source locations', () => {
1713
1714
  const m = new test_translator_1.TestTranslator(source.code);
1714
1715
  expect(m).toTranslate();
1715
1716
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1716
- const x = (0, test_translator_1.getField)(na, 'x');
1717
+ const x = (0, test_translator_1.getFieldDef)(na, 'x');
1717
1718
  expect(x.location).toMatchObject(source.locations[0]);
1718
1719
  });
1719
1720
  test('location of defined field inside a query', () => {
@@ -1727,7 +1728,7 @@ describe('source locations', () => {
1727
1728
  expect(m).toTranslate();
1728
1729
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1729
1730
  const x = (0, test_translator_1.getQueryField)(na, 'x');
1730
- const y = (0, test_translator_1.getField)(x.pipeline[0], 'y');
1731
+ const y = (0, test_translator_1.getFieldDef)(x.pipeline[0], 'y');
1731
1732
  expect(y.location).toMatchObject(source.locations[0]);
1732
1733
  });
1733
1734
  test('location of filtered field inside a query', () => {
@@ -1742,7 +1743,7 @@ describe('source locations', () => {
1742
1743
  expect(m).toTranslate();
1743
1744
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1744
1745
  const x = (0, test_translator_1.getQueryField)(na, 'x');
1745
- const z = (0, test_translator_1.getField)(x.pipeline[0], 'z');
1746
+ const z = (0, test_translator_1.getFieldDef)(x.pipeline[0], 'z');
1746
1747
  expect(z.location).toMatchObject(source.locations[0]);
1747
1748
  });
1748
1749
  test('location of field inherited from table', () => {
@@ -1750,7 +1751,7 @@ describe('source locations', () => {
1750
1751
  const m = new test_translator_1.TestTranslator(source.code);
1751
1752
  expect(m).toTranslate();
1752
1753
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1753
- const abool = (0, test_translator_1.getField)(na, 'abool');
1754
+ const abool = (0, test_translator_1.getFieldDef)(na, 'abool');
1754
1755
  expect(abool.location).toMatchObject(source.locations[0]);
1755
1756
  });
1756
1757
  test('location of field inherited from sql block', () => {
@@ -1768,7 +1769,7 @@ describe('source locations', () => {
1768
1769
  });
1769
1770
  expect(m).toTranslate();
1770
1771
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1771
- const one = (0, test_translator_1.getField)(na, 'one');
1772
+ const one = (0, test_translator_1.getFieldDef)(na, 'one');
1772
1773
  expect(one.location).isLocationIn(source.locations[0], source.code);
1773
1774
  }
1774
1775
  });
@@ -1785,9 +1786,9 @@ describe('source locations', () => {
1785
1786
  const m = new test_translator_1.TestTranslator(source.code);
1786
1787
  expect(m).toTranslate();
1787
1788
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1788
- const abool = (0, test_translator_1.getField)(na, 'abool');
1789
+ const abool = (0, test_translator_1.getFieldDef)(na, 'abool');
1789
1790
  expect(abool.location).toMatchObject(source.locations[0]);
1790
- const y = (0, test_translator_1.getField)(na, 'y');
1791
+ const y = (0, test_translator_1.getFieldDef)(na, 'y');
1791
1792
  expect(y.location).toMatchObject(source.locations[1]);
1792
1793
  });
1793
1794
  test('location of named query', () => {
@@ -1802,7 +1803,7 @@ describe('source locations', () => {
1802
1803
  const m = new test_translator_1.TestTranslator(source.code);
1803
1804
  expect(m).toTranslate();
1804
1805
  const q = (0, test_translator_1.getModelQuery)(m.modelDef, 'q');
1805
- const a = (0, test_translator_1.getField)(q.pipeline[0], 'b');
1806
+ const a = (0, test_translator_1.getFieldDef)(q.pipeline[0], 'b');
1806
1807
  expect(a.location).toMatchObject(source.locations[0]);
1807
1808
  });
1808
1809
  test('location of named SQL block', () => {
@@ -1829,7 +1830,7 @@ describe('source locations', () => {
1829
1830
  const m = new test_translator_1.TestTranslator(source.code);
1830
1831
  expect(m).toTranslate();
1831
1832
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1832
- const bbool = (0, test_translator_1.getField)(na, 'bbool');
1833
+ const bbool = (0, test_translator_1.getFieldDef)(na, 'bbool');
1833
1834
  expect(bbool.location).toMatchObject(source.locations[0]);
1834
1835
  });
1835
1836
  test('location of join on', () => {
@@ -1841,7 +1842,7 @@ describe('source locations', () => {
1841
1842
  const m = new test_translator_1.TestTranslator(source.code);
1842
1843
  expect(m).toTranslate();
1843
1844
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1844
- const x = (0, test_translator_1.getField)(na, 'x');
1845
+ const x = (0, test_translator_1.getFieldDef)(na, 'x');
1845
1846
  expect(x.location).toMatchObject(source.locations[0]);
1846
1847
  });
1847
1848
  test('location of join with', () => {
@@ -1853,7 +1854,7 @@ describe('source locations', () => {
1853
1854
  const m = new test_translator_1.TestTranslator(source.code);
1854
1855
  expect(m).toTranslate();
1855
1856
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1856
- const x = (0, test_translator_1.getField)(na, 'x');
1857
+ const x = (0, test_translator_1.getFieldDef)(na, 'x');
1857
1858
  expect(x.location).toMatchObject(source.locations[0]);
1858
1859
  });
1859
1860
  test('location of field in join', () => {
@@ -1869,7 +1870,7 @@ describe('source locations', () => {
1869
1870
  expect(m).toTranslate();
1870
1871
  const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1871
1872
  const x = (0, test_translator_1.getJoinField)(na, 'x');
1872
- const y = (0, test_translator_1.getField)(x, 'y');
1873
+ const y = (0, test_translator_1.getFieldDef)(x, 'y');
1873
1874
  expect(y.location).toMatchObject(source.locations[0]);
1874
1875
  });
1875
1876
  // Since """ strings are not single tokens, I don't know how to do this.