@malloydata/malloy 0.0.240-dev250311202829 → 0.0.240-dev250311214430
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/api/core.d.ts +1 -0
- package/dist/api/core.js +2 -1
- package/dist/lang/malloy-parse-info.d.ts +2 -10
- package/dist/lang/malloy-to-ast.d.ts +1 -0
- package/dist/lang/malloy-to-ast.js +9 -6
- package/dist/lang/malloy-to-stable-query.d.ts +76 -0
- package/dist/lang/malloy-to-stable-query.js +660 -0
- package/dist/lang/parse-log.d.ts +1 -0
- package/dist/lang/parse-malloy.d.ts +2 -9
- package/dist/lang/parse-malloy.js +7 -112
- package/dist/lang/parse-tree-walkers/model-annotation-walker.js +1 -1
- package/dist/lang/run-malloy-parser.d.ts +3 -0
- package/dist/lang/run-malloy-parser.js +53 -0
- package/dist/lang/syntax-errors/malloy-parser-error-listener.d.ts +4 -3
- package/dist/lang/syntax-errors/malloy-parser-error-listener.js +8 -4
- package/dist/lang/utils.d.ts +27 -1
- package/dist/lang/utils.js +78 -1
- package/package.json +3 -3
- package/dist/api/asynchronous.spec.d.ts +0 -1
- package/dist/api/asynchronous.spec.js +0 -240
- package/dist/api/sessioned.spec.d.ts +0 -1
- package/dist/api/sessioned.spec.js +0 -476
- package/dist/api/stateless.spec.d.ts +0 -1
- package/dist/api/stateless.spec.js +0 -400
- package/dist/lang/test/annotation.spec.d.ts +0 -14
- package/dist/lang/test/annotation.spec.js +0 -809
- package/dist/lang/test/composite-field-usage.spec.d.ts +0 -1
- package/dist/lang/test/composite-field-usage.spec.js +0 -261
- package/dist/lang/test/document-help-context-walker.spec.d.ts +0 -1
- package/dist/lang/test/document-help-context-walker.spec.js +0 -55
- package/dist/lang/test/document-symbol-walker.spec.d.ts +0 -1
- package/dist/lang/test/document-symbol-walker.spec.js +0 -209
- package/dist/lang/test/expressions.spec.d.ts +0 -1
- package/dist/lang/test/expressions.spec.js +0 -1181
- package/dist/lang/test/field-symbols.spec.d.ts +0 -1
- package/dist/lang/test/field-symbols.spec.js +0 -194
- package/dist/lang/test/find-table-path-walker.spec.d.ts +0 -1
- package/dist/lang/test/find-table-path-walker.spec.js +0 -50
- package/dist/lang/test/imports.spec.d.ts +0 -1
- package/dist/lang/test/imports.spec.js +0 -283
- package/dist/lang/test/lenses.spec.d.ts +0 -1
- package/dist/lang/test/lenses.spec.js +0 -384
- package/dist/lang/test/literals.spec.d.ts +0 -1
- package/dist/lang/test/literals.spec.js +0 -267
- package/dist/lang/test/locations.spec.d.ts +0 -1
- package/dist/lang/test/locations.spec.js +0 -679
- package/dist/lang/test/model-annotation-walker.spec.d.ts +0 -1
- package/dist/lang/test/model-annotation-walker.spec.js +0 -46
- package/dist/lang/test/model_serialization.spec.d.ts +0 -5
- package/dist/lang/test/model_serialization.spec.js +0 -116
- package/dist/lang/test/parameters.spec.d.ts +0 -1
- package/dist/lang/test/parameters.spec.js +0 -619
- package/dist/lang/test/parse.spec.d.ts +0 -1
- package/dist/lang/test/parse.spec.js +0 -893
- package/dist/lang/test/pretranslate.spec.d.ts +0 -1
- package/dist/lang/test/pretranslate.spec.js +0 -80
- package/dist/lang/test/query.spec.d.ts +0 -1
- package/dist/lang/test/query.spec.js +0 -1149
- package/dist/lang/test/source.spec.d.ts +0 -1
- package/dist/lang/test/source.spec.js +0 -570
- package/dist/lang/test/sql-block.spec.d.ts +0 -1
- package/dist/lang/test/sql-block.spec.js +0 -145
- package/dist/lang/test/syntax-errors.spec.d.ts +0 -1
- package/dist/lang/test/syntax-errors.spec.js +0 -142
- package/dist/model/utils.spec.d.ts +0 -1
- package/dist/model/utils.spec.js +0 -38
|
@@ -1,809 +0,0 @@
|
|
|
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 jest_diff_1 = require("jest-diff");
|
|
28
|
-
expect.extend({
|
|
29
|
-
matchesAnnotation(result, shouldBe) {
|
|
30
|
-
function stripAt(a) {
|
|
31
|
-
const clean = {};
|
|
32
|
-
if (a.inherits) {
|
|
33
|
-
clean.inherits = stripAt(a.inherits);
|
|
34
|
-
}
|
|
35
|
-
if (a.blockNotes) {
|
|
36
|
-
clean.blockNotes = a.blockNotes.map(bn => bn.text);
|
|
37
|
-
}
|
|
38
|
-
if (a.notes) {
|
|
39
|
-
clean.notes = a.notes.map(n => n.text);
|
|
40
|
-
}
|
|
41
|
-
return clean;
|
|
42
|
-
}
|
|
43
|
-
if (result === undefined) {
|
|
44
|
-
return {
|
|
45
|
-
pass: false,
|
|
46
|
-
message: () => 'Annotation was undefined',
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const got = stripAt(result);
|
|
50
|
-
if (!this.equals(got, shouldBe)) {
|
|
51
|
-
return {
|
|
52
|
-
pass: false,
|
|
53
|
-
message: () => (0, jest_diff_1.diff)(shouldBe, got, { expand: true }) || '',
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
pass: true,
|
|
58
|
-
message: () => '',
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
const defaultTags = {
|
|
63
|
-
blockNotes: ['# blockNote\n'],
|
|
64
|
-
notes: ['# note\n', '# b4-is\n', '# after-is\n'],
|
|
65
|
-
};
|
|
66
|
-
const turtleDef = `
|
|
67
|
-
source: na is a extend {
|
|
68
|
-
# blockNote
|
|
69
|
-
view:
|
|
70
|
-
# note
|
|
71
|
-
note_a
|
|
72
|
-
# b4-is
|
|
73
|
-
is
|
|
74
|
-
# after-is
|
|
75
|
-
{select: *}
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
describe('document annotation', () => {
|
|
79
|
-
test('every source annotation point', () => {
|
|
80
|
-
const m = new test_translator_1.TestTranslator(`
|
|
81
|
-
# blockNote
|
|
82
|
-
source:
|
|
83
|
-
# note
|
|
84
|
-
note_a
|
|
85
|
-
# b4-is
|
|
86
|
-
is
|
|
87
|
-
# after-is
|
|
88
|
-
a
|
|
89
|
-
# note1
|
|
90
|
-
note_b is a
|
|
91
|
-
`);
|
|
92
|
-
expect(m).toTranslate();
|
|
93
|
-
const note_a = m.getSourceDef('note_a');
|
|
94
|
-
expect(note_a).toBeDefined();
|
|
95
|
-
if (note_a) {
|
|
96
|
-
expect(note_a.annotation).matchesAnnotation(defaultTags);
|
|
97
|
-
}
|
|
98
|
-
const note_b = m.getSourceDef('note_b');
|
|
99
|
-
expect(note_b).toBeDefined();
|
|
100
|
-
if (note_b) {
|
|
101
|
-
expect(note_b.annotation).matchesAnnotation({
|
|
102
|
-
blockNotes: defaultTags.blockNotes,
|
|
103
|
-
notes: ['# note1\n'],
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
test('multi line source annotation', () => {
|
|
108
|
-
const m = new test_translator_1.TestTranslator(`
|
|
109
|
-
# note1
|
|
110
|
-
# note1.1
|
|
111
|
-
source: note_a is a
|
|
112
|
-
`);
|
|
113
|
-
expect(m).toTranslate();
|
|
114
|
-
const note_a = m.getSourceDef('note_a');
|
|
115
|
-
expect(note_a).toBeDefined();
|
|
116
|
-
if (note_a) {
|
|
117
|
-
expect(note_a.annotation).matchesAnnotation({
|
|
118
|
-
blockNotes: ['# note1\n', '# note1.1\n'],
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
test('inherited annotation source', () => {
|
|
123
|
-
const m = new test_translator_1.TestTranslator(`
|
|
124
|
-
# note0
|
|
125
|
-
source: note_b is a
|
|
126
|
-
# note1
|
|
127
|
-
source: note_a is note_b extend { primary_key: ai }
|
|
128
|
-
`);
|
|
129
|
-
expect(m).toTranslate();
|
|
130
|
-
const note_a = m.getSourceDef('note_a');
|
|
131
|
-
expect(note_a).toBeDefined();
|
|
132
|
-
if (note_a) {
|
|
133
|
-
expect(note_a.annotation).matchesAnnotation({
|
|
134
|
-
inherits: { blockNotes: ['# note0\n'] },
|
|
135
|
-
blockNotes: ['# note1\n'],
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
test('define full query annotation points', () => {
|
|
140
|
-
const m = new test_translator_1.TestTranslator(`
|
|
141
|
-
# blockNote
|
|
142
|
-
query:
|
|
143
|
-
# note
|
|
144
|
-
note_a
|
|
145
|
-
# b4-is
|
|
146
|
-
is
|
|
147
|
-
# after-is
|
|
148
|
-
a -> {select: *}
|
|
149
|
-
`);
|
|
150
|
-
expect(m).toTranslate();
|
|
151
|
-
const note_a = m.getQuery('note_a');
|
|
152
|
-
expect(note_a).toBeDefined();
|
|
153
|
-
if (note_a) {
|
|
154
|
-
expect(note_a.annotation).matchesAnnotation(defaultTags);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
test('run statement annotation points', () => {
|
|
158
|
-
const m = new test_translator_1.TestTranslator(`
|
|
159
|
-
# note1
|
|
160
|
-
run:
|
|
161
|
-
# note2
|
|
162
|
-
a -> {select: *}
|
|
163
|
-
`);
|
|
164
|
-
expect(m).toTranslate();
|
|
165
|
-
const note_a = m.getQuery(0);
|
|
166
|
-
expect(note_a).toBeDefined();
|
|
167
|
-
if (note_a) {
|
|
168
|
-
expect(note_a.annotation).matchesAnnotation({
|
|
169
|
-
blockNotes: ['# note1\n'],
|
|
170
|
-
notes: ['# note2\n'],
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
test('multi line query annotation', () => {
|
|
175
|
-
const m = new test_translator_1.TestTranslator(`
|
|
176
|
-
# note1
|
|
177
|
-
# note2
|
|
178
|
-
query: note_a is a -> {select: *}
|
|
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).matchesAnnotation({
|
|
185
|
-
blockNotes: ['# note1\n', '# note2\n'],
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
test('inherited annotation query', () => {
|
|
190
|
-
const m = new test_translator_1.TestTranslator(`
|
|
191
|
-
# noteb0
|
|
192
|
-
query:
|
|
193
|
-
# noteb1
|
|
194
|
-
note_b is a -> { select: * }
|
|
195
|
-
# note1
|
|
196
|
-
query: note_a is note_b + { where: astr = 'a' }
|
|
197
|
-
`);
|
|
198
|
-
expect(m).toTranslate();
|
|
199
|
-
const note_a = m.getQuery('note_a');
|
|
200
|
-
expect(note_a).toBeDefined();
|
|
201
|
-
if (note_a) {
|
|
202
|
-
expect(note_a.annotation).matchesAnnotation({
|
|
203
|
-
inherits: { blockNotes: ['# noteb0\n'], notes: ['# noteb1\n'] },
|
|
204
|
-
blockNotes: ['# note1\n'],
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
test('query from turtle inherits turtle annotation', () => {
|
|
209
|
-
const m = (0, test_translator_1.model) `
|
|
210
|
-
${turtleDef}
|
|
211
|
-
# run_block
|
|
212
|
-
run: # run_note
|
|
213
|
-
na -> note_a
|
|
214
|
-
`;
|
|
215
|
-
expect(m).toTranslate();
|
|
216
|
-
const note_a = m.translator.getQuery(0);
|
|
217
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toBeDefined();
|
|
218
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation({
|
|
219
|
-
blockNotes: ['# run_block\n'],
|
|
220
|
-
notes: ['# run_note\n'],
|
|
221
|
-
inherits: defaultTags,
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
test('model annotations', () => {
|
|
225
|
-
var _a;
|
|
226
|
-
const m = new test_translator_1.TestTranslator(`
|
|
227
|
-
## model1
|
|
228
|
-
## model2
|
|
229
|
-
`);
|
|
230
|
-
expect(m).toTranslate();
|
|
231
|
-
const model = (_a = m.translate()) === null || _a === void 0 ? void 0 : _a.modelDef;
|
|
232
|
-
expect(model).toBeDefined();
|
|
233
|
-
const notes = model === null || model === void 0 ? void 0 : model.annotation;
|
|
234
|
-
expect(notes).matchesAnnotation({ notes: ['## model1\n', '## model2\n'] });
|
|
235
|
-
});
|
|
236
|
-
test('ignores objectless object annotations', () => {
|
|
237
|
-
const m = new test_translator_1.TestTranslator(`
|
|
238
|
-
# note1
|
|
239
|
-
## model1
|
|
240
|
-
`);
|
|
241
|
-
expect(m).toLog((0, test_translator_1.errorMessage)('Object annotation not connected to any object'));
|
|
242
|
-
});
|
|
243
|
-
test('errors reported from compiler flags', () => {
|
|
244
|
-
expect(`
|
|
245
|
-
##! missingCloseQuote="...
|
|
246
|
-
`).toLog((0, test_translator_1.errorMessage)(/no viable alternative at input/));
|
|
247
|
-
});
|
|
248
|
-
test('checking compiler flags', () => {
|
|
249
|
-
const m = (0, test_translator_1.model) `
|
|
250
|
-
##! flagThis
|
|
251
|
-
`;
|
|
252
|
-
expect(m).toTranslate();
|
|
253
|
-
expect(m.translator.compilerFlags.has('flagThis')).toBeTruthy();
|
|
254
|
-
});
|
|
255
|
-
test('extended models inherit model flags', () => {
|
|
256
|
-
var _a, _b;
|
|
257
|
-
const first = (0, test_translator_1.model) `## from=1\n`;
|
|
258
|
-
expect(first).toTranslate();
|
|
259
|
-
const firstModel = (_a = first.translator.translate()) === null || _a === void 0 ? void 0 : _a.modelDef;
|
|
260
|
-
expect(firstModel).toBeDefined();
|
|
261
|
-
const second = (0, test_translator_1.model) `## from=2\n`;
|
|
262
|
-
second.translator.internalModel = firstModel;
|
|
263
|
-
const secondModel = (_b = second.translator.translate()) === null || _b === void 0 ? void 0 : _b.modelDef;
|
|
264
|
-
expect(secondModel === null || secondModel === void 0 ? void 0 : secondModel.annotation).matchesAnnotation({
|
|
265
|
-
inherits: { notes: ['## from=1\n'] },
|
|
266
|
-
notes: ['## from=2\n'],
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
describe('source definition annotations', () => {
|
|
271
|
-
test('turtle block annotation', () => {
|
|
272
|
-
const m = new test_translator_1.TestTranslator(turtleDef);
|
|
273
|
-
expect(m).toTranslate();
|
|
274
|
-
const na = m.getSourceDef('na');
|
|
275
|
-
expect(na).toBeDefined();
|
|
276
|
-
if (na) {
|
|
277
|
-
const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
|
|
278
|
-
expect(note_a).toBeDefined();
|
|
279
|
-
expect(note_a.annotation).matchesAnnotation(defaultTags);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
test('refined turtle inherits annotation', () => {
|
|
283
|
-
const m = new test_translator_1.TestTranslator(`
|
|
284
|
-
${turtleDef}
|
|
285
|
-
source: new_na is na extend {
|
|
286
|
-
view: new_note_a is note_a
|
|
287
|
-
}
|
|
288
|
-
`);
|
|
289
|
-
expect(m).toTranslate();
|
|
290
|
-
const na = m.getSourceDef('new_na');
|
|
291
|
-
expect(na).toBeDefined();
|
|
292
|
-
if (na) {
|
|
293
|
-
const note_a = (0, test_translator_1.getFieldDef)(na, 'new_note_a');
|
|
294
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).toBeDefined();
|
|
295
|
-
expect(note_a.annotation).matchesAnnotation({ inherits: defaultTags });
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
test('dimension block annotation', () => {
|
|
299
|
-
const m = new test_translator_1.TestTranslator(`
|
|
300
|
-
source: na is a extend {
|
|
301
|
-
# blockNote
|
|
302
|
-
dimension:
|
|
303
|
-
# note
|
|
304
|
-
note_a
|
|
305
|
-
# b4-is
|
|
306
|
-
is
|
|
307
|
-
# after-is
|
|
308
|
-
astr
|
|
309
|
-
}
|
|
310
|
-
`);
|
|
311
|
-
expect(m).toTranslate();
|
|
312
|
-
const na = m.getSourceDef('na');
|
|
313
|
-
expect(na).toBeDefined();
|
|
314
|
-
if (na) {
|
|
315
|
-
const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
|
|
316
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
test('measure block annotation', () => {
|
|
320
|
-
const m = new test_translator_1.TestTranslator(`
|
|
321
|
-
source: na is a extend {
|
|
322
|
-
# blockNote
|
|
323
|
-
measure:
|
|
324
|
-
# note
|
|
325
|
-
note_a
|
|
326
|
-
# b4-is
|
|
327
|
-
is
|
|
328
|
-
# after-is
|
|
329
|
-
max(astr)
|
|
330
|
-
}
|
|
331
|
-
`);
|
|
332
|
-
expect(m).toTranslate();
|
|
333
|
-
const na = m.getSourceDef('na');
|
|
334
|
-
expect(na).toBeDefined();
|
|
335
|
-
if (na) {
|
|
336
|
-
const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
|
|
337
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
test('join_one-with block annotation', () => {
|
|
341
|
-
const m = new test_translator_1.TestTranslator(`
|
|
342
|
-
source: na is a extend {
|
|
343
|
-
# blockNote
|
|
344
|
-
join_one:
|
|
345
|
-
# note
|
|
346
|
-
note_a
|
|
347
|
-
# b4-is
|
|
348
|
-
is
|
|
349
|
-
# after-is
|
|
350
|
-
ab with astr
|
|
351
|
-
}
|
|
352
|
-
`);
|
|
353
|
-
expect(m).toTranslate();
|
|
354
|
-
const na = m.getSourceDef('na');
|
|
355
|
-
expect(na).toBeDefined();
|
|
356
|
-
if (na) {
|
|
357
|
-
const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
|
|
358
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
test('join_many-on block annotation', () => {
|
|
362
|
-
const m = new test_translator_1.TestTranslator(`
|
|
363
|
-
source: na is a extend {
|
|
364
|
-
# blockNote
|
|
365
|
-
join_many:
|
|
366
|
-
# note
|
|
367
|
-
note_a
|
|
368
|
-
# b4-is
|
|
369
|
-
is
|
|
370
|
-
# after-is
|
|
371
|
-
a on note_a.astr = astr
|
|
372
|
-
}
|
|
373
|
-
`);
|
|
374
|
-
expect(m).toTranslate();
|
|
375
|
-
const na = m.getSourceDef('na');
|
|
376
|
-
expect(na).toBeDefined();
|
|
377
|
-
if (na) {
|
|
378
|
-
const note_a = (0, test_translator_1.getFieldDef)(na, 'note_a');
|
|
379
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
test('ignores model annotation', () => {
|
|
383
|
-
const m = new test_translator_1.TestTranslator(`
|
|
384
|
-
source: na is a extend {
|
|
385
|
-
## model1
|
|
386
|
-
}
|
|
387
|
-
`);
|
|
388
|
-
expect(m).toLog((0, test_translator_1.errorMessage)('Model annotations not allowed at this scope'));
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
describe('query operation annotations', () => {
|
|
392
|
-
test('ignores model annotation', () => {
|
|
393
|
-
expect(`
|
|
394
|
-
run: a -> {
|
|
395
|
-
## model1
|
|
396
|
-
select: *
|
|
397
|
-
}
|
|
398
|
-
`).toLog((0, test_translator_1.errorMessage)('Model annotations not allowed at this scope'));
|
|
399
|
-
});
|
|
400
|
-
test('project new definition annotation', () => {
|
|
401
|
-
const m = new test_translator_1.TestTranslator(`
|
|
402
|
-
query: findme is a -> {
|
|
403
|
-
# blockNote
|
|
404
|
-
select:
|
|
405
|
-
# note
|
|
406
|
-
note_a
|
|
407
|
-
# b4-is
|
|
408
|
-
is
|
|
409
|
-
# after-is
|
|
410
|
-
astr
|
|
411
|
-
}
|
|
412
|
-
`);
|
|
413
|
-
expect(m).toTranslate();
|
|
414
|
-
const foundYou = m.getQuery('findme');
|
|
415
|
-
expect(foundYou).toBeDefined();
|
|
416
|
-
if (foundYou) {
|
|
417
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
418
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
test('select: ref inherits annotation', () => {
|
|
422
|
-
const m = new test_translator_1.TestTranslator(`
|
|
423
|
-
run: a extend {
|
|
424
|
-
# blockNote
|
|
425
|
-
dimension:
|
|
426
|
-
# note
|
|
427
|
-
note_a
|
|
428
|
-
# b4-is
|
|
429
|
-
is
|
|
430
|
-
# after-is
|
|
431
|
-
astr
|
|
432
|
-
} -> {
|
|
433
|
-
# note1
|
|
434
|
-
select:
|
|
435
|
-
# note2
|
|
436
|
-
note_a
|
|
437
|
-
}
|
|
438
|
-
`);
|
|
439
|
-
expect(m).toTranslate();
|
|
440
|
-
const foundYou = m.getQuery(0);
|
|
441
|
-
expect(foundYou).toBeDefined();
|
|
442
|
-
if (foundYou) {
|
|
443
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
444
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation({
|
|
445
|
-
inherits: defaultTags,
|
|
446
|
-
blockNotes: ['# note1\n'],
|
|
447
|
-
notes: ['# note2\n'],
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
test('group_by def', () => {
|
|
452
|
-
const m = new test_translator_1.TestTranslator(`
|
|
453
|
-
query: findme is a -> {
|
|
454
|
-
# blockNote
|
|
455
|
-
group_by:
|
|
456
|
-
# note
|
|
457
|
-
note_a
|
|
458
|
-
# b4-is
|
|
459
|
-
is
|
|
460
|
-
# after-is
|
|
461
|
-
astr
|
|
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.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
469
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
test('caculate def', () => {
|
|
473
|
-
const m = new test_translator_1.TestTranslator(`
|
|
474
|
-
query: findme is a -> {
|
|
475
|
-
group_by: astr, ai
|
|
476
|
-
# blockNote
|
|
477
|
-
calculate:
|
|
478
|
-
# note
|
|
479
|
-
note_a
|
|
480
|
-
# b4-is
|
|
481
|
-
is
|
|
482
|
-
# after-is
|
|
483
|
-
lag(ai)
|
|
484
|
-
}
|
|
485
|
-
`);
|
|
486
|
-
expect(m).toTranslate();
|
|
487
|
-
const foundYou = m.getQuery('findme');
|
|
488
|
-
expect(foundYou).toBeDefined();
|
|
489
|
-
if (foundYou) {
|
|
490
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
491
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
test('group_by ref inherits', () => {
|
|
495
|
-
const m = new test_translator_1.TestTranslator(`
|
|
496
|
-
source: aa is a extend {
|
|
497
|
-
# blockNote
|
|
498
|
-
dimension:
|
|
499
|
-
# note
|
|
500
|
-
note_a
|
|
501
|
-
# b4-is
|
|
502
|
-
is
|
|
503
|
-
# after-is
|
|
504
|
-
astr
|
|
505
|
-
}
|
|
506
|
-
query: findme is aa -> {
|
|
507
|
-
# note1
|
|
508
|
-
group_by:
|
|
509
|
-
# note2
|
|
510
|
-
note_a
|
|
511
|
-
}
|
|
512
|
-
`);
|
|
513
|
-
expect(m).toTranslate();
|
|
514
|
-
const foundYou = m.getQuery('findme');
|
|
515
|
-
expect(foundYou).toBeDefined();
|
|
516
|
-
if (foundYou) {
|
|
517
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
518
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation({
|
|
519
|
-
blockNotes: ['# note1\n'],
|
|
520
|
-
inherits: defaultTags,
|
|
521
|
-
notes: ['# note2\n'],
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
test('aggregate def', () => {
|
|
526
|
-
const m = new test_translator_1.TestTranslator(`
|
|
527
|
-
query: findme is a -> {
|
|
528
|
-
# blockNote
|
|
529
|
-
aggregate:
|
|
530
|
-
# note
|
|
531
|
-
note_a
|
|
532
|
-
# b4-is
|
|
533
|
-
is
|
|
534
|
-
# after-is
|
|
535
|
-
max(astr)
|
|
536
|
-
}
|
|
537
|
-
`);
|
|
538
|
-
expect(m).toTranslate();
|
|
539
|
-
const foundYou = m.getQuery('findme');
|
|
540
|
-
expect(foundYou).toBeDefined();
|
|
541
|
-
if (foundYou) {
|
|
542
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
543
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
test('aggregate ref inherits', () => {
|
|
547
|
-
const m = new test_translator_1.TestTranslator(`
|
|
548
|
-
source: aa is a extend {
|
|
549
|
-
# blockNote
|
|
550
|
-
measure:
|
|
551
|
-
# note
|
|
552
|
-
note_a
|
|
553
|
-
# b4-is
|
|
554
|
-
is
|
|
555
|
-
# after-is
|
|
556
|
-
max(astr)
|
|
557
|
-
}
|
|
558
|
-
query: findme is aa -> {
|
|
559
|
-
# note1
|
|
560
|
-
aggregate:
|
|
561
|
-
# note2
|
|
562
|
-
note_a
|
|
563
|
-
}
|
|
564
|
-
`);
|
|
565
|
-
expect(m).toTranslate();
|
|
566
|
-
const foundYou = m.getQuery('findme');
|
|
567
|
-
expect(foundYou).toBeDefined();
|
|
568
|
-
if (foundYou) {
|
|
569
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
570
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation({
|
|
571
|
-
blockNotes: ['# note1\n'],
|
|
572
|
-
inherits: defaultTags,
|
|
573
|
-
notes: ['# note2\n'],
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
test('nest annotation', () => {
|
|
578
|
-
const m = new test_translator_1.TestTranslator(`
|
|
579
|
-
query: findme is ab -> {
|
|
580
|
-
# blockNote
|
|
581
|
-
nest:
|
|
582
|
-
# note
|
|
583
|
-
note_a
|
|
584
|
-
# b4-is
|
|
585
|
-
is
|
|
586
|
-
# after-is
|
|
587
|
-
aturtle
|
|
588
|
-
}
|
|
589
|
-
`);
|
|
590
|
-
expect(m).toTranslate();
|
|
591
|
-
const foundYou = m.getQuery('findme');
|
|
592
|
-
expect(foundYou).toBeDefined();
|
|
593
|
-
if (foundYou) {
|
|
594
|
-
const note_a = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_a');
|
|
595
|
-
expect(note_a === null || note_a === void 0 ? void 0 : note_a.annotation).matchesAnnotation(defaultTags);
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
test('nest from existing inherits annotation', () => {
|
|
599
|
-
const m = new test_translator_1.TestTranslator(`
|
|
600
|
-
${turtleDef}
|
|
601
|
-
run: na -> {
|
|
602
|
-
nest: note_b is note_a
|
|
603
|
-
}
|
|
604
|
-
`);
|
|
605
|
-
expect(m).toTranslate();
|
|
606
|
-
const foundYou = m.getQuery(0);
|
|
607
|
-
expect(foundYou).toBeDefined();
|
|
608
|
-
if (foundYou) {
|
|
609
|
-
const note_b = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'note_b');
|
|
610
|
-
expect(note_b === null || note_b === void 0 ? void 0 : note_b.annotation).matchesAnnotation({ inherits: defaultTags });
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
test('annotations preserved from path references', () => {
|
|
614
|
-
const m = (0, test_translator_1.model) `
|
|
615
|
-
run: a -> {
|
|
616
|
-
extend: {
|
|
617
|
-
join_one: x is
|
|
618
|
-
a extend {
|
|
619
|
-
# blockNote
|
|
620
|
-
dimension:
|
|
621
|
-
# note
|
|
622
|
-
xdim
|
|
623
|
-
# b4-is
|
|
624
|
-
is
|
|
625
|
-
# after-is
|
|
626
|
-
1
|
|
627
|
-
} on x.ai = ai
|
|
628
|
-
}
|
|
629
|
-
group_by: x.xdim
|
|
630
|
-
}`;
|
|
631
|
-
expect(m).toTranslate();
|
|
632
|
-
const foundYou = m.translator.getQuery(0);
|
|
633
|
-
expect(foundYou).toBeDefined();
|
|
634
|
-
if (foundYou) {
|
|
635
|
-
const note_b = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'xdim');
|
|
636
|
-
expect(note_b === null || note_b === void 0 ? void 0 : note_b.annotation).matchesAnnotation({ inherits: defaultTags });
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
test('a reference can have an annotation', () => {
|
|
640
|
-
const m = (0, test_translator_1.model) `run: a extend {
|
|
641
|
-
# noted
|
|
642
|
-
dimension: noted_str is astr
|
|
643
|
-
} -> {
|
|
644
|
-
select:
|
|
645
|
-
# note
|
|
646
|
-
noted_str
|
|
647
|
-
}`;
|
|
648
|
-
expect(m).toTranslate();
|
|
649
|
-
const foundYou = m.translator.getQuery(0);
|
|
650
|
-
expect(foundYou).toBeDefined();
|
|
651
|
-
if (foundYou) {
|
|
652
|
-
const astr = (0, test_translator_1.getQueryFieldDef)(foundYou.pipeline[0], 'noted_str');
|
|
653
|
-
expect(astr === null || astr === void 0 ? void 0 : astr.annotation).matchesAnnotation({
|
|
654
|
-
inherits: { blockNotes: ['# noted\n'] },
|
|
655
|
-
notes: ['# note\n'],
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
describe('include annotations', () => {
|
|
660
|
-
test('inherit: star', () => {
|
|
661
|
-
const m = new test_translator_1.TestTranslator(`
|
|
662
|
-
##! experimental.access_modifiers
|
|
663
|
-
source: na is a include {
|
|
664
|
-
# ai
|
|
665
|
-
*
|
|
666
|
-
}
|
|
667
|
-
`);
|
|
668
|
-
expect(m).toTranslate();
|
|
669
|
-
const na = m.getSourceDef('na');
|
|
670
|
-
expect(na).toBeDefined();
|
|
671
|
-
if (na) {
|
|
672
|
-
const ai = (0, test_translator_1.getFieldDef)(na, 'ai');
|
|
673
|
-
expect(ai === null || ai === void 0 ? void 0 : ai.annotation).matchesAnnotation({
|
|
674
|
-
blockNotes: [],
|
|
675
|
-
notes: ['# ai\n'],
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
test('new tags are inherited, not added', () => {
|
|
680
|
-
const m = new test_translator_1.TestTranslator(`
|
|
681
|
-
##! experimental.access_modifiers
|
|
682
|
-
source: na is a include {
|
|
683
|
-
# ai
|
|
684
|
-
ai
|
|
685
|
-
} include {
|
|
686
|
-
# ai_2
|
|
687
|
-
ai
|
|
688
|
-
}
|
|
689
|
-
`);
|
|
690
|
-
expect(m).toTranslate();
|
|
691
|
-
const na = m.getSourceDef('na');
|
|
692
|
-
expect(na).toBeDefined();
|
|
693
|
-
if (na) {
|
|
694
|
-
const ai = (0, test_translator_1.getFieldDef)(na, 'ai');
|
|
695
|
-
expect(ai === null || ai === void 0 ? void 0 : ai.annotation).matchesAnnotation({
|
|
696
|
-
blockNotes: [],
|
|
697
|
-
notes: ['# ai_2\n'],
|
|
698
|
-
inherits: { notes: ['# ai\n'], blockNotes: [] },
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
test('modifier: star', () => {
|
|
703
|
-
const m = new test_translator_1.TestTranslator(`
|
|
704
|
-
##! experimental.access_modifiers
|
|
705
|
-
source: na is a include {
|
|
706
|
-
# ai_a
|
|
707
|
-
public:
|
|
708
|
-
# ai_b
|
|
709
|
-
*
|
|
710
|
-
}
|
|
711
|
-
`);
|
|
712
|
-
expect(m).toTranslate();
|
|
713
|
-
const na = m.getSourceDef('na');
|
|
714
|
-
expect(na).toBeDefined();
|
|
715
|
-
if (na) {
|
|
716
|
-
const ai = (0, test_translator_1.getFieldDef)(na, 'ai');
|
|
717
|
-
expect(ai === null || ai === void 0 ? void 0 : ai.annotation).matchesAnnotation({
|
|
718
|
-
blockNotes: ['# ai_a\n'],
|
|
719
|
-
notes: ['# ai_b\n'],
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
test('inherit: list', () => {
|
|
724
|
-
const m = new test_translator_1.TestTranslator(`
|
|
725
|
-
##! experimental.access_modifiers
|
|
726
|
-
source: na is a include {
|
|
727
|
-
# ai
|
|
728
|
-
ai
|
|
729
|
-
af
|
|
730
|
-
}
|
|
731
|
-
`);
|
|
732
|
-
expect(m).toTranslate();
|
|
733
|
-
const na = m.getSourceDef('na');
|
|
734
|
-
expect(na).toBeDefined();
|
|
735
|
-
if (na) {
|
|
736
|
-
const ai = (0, test_translator_1.getFieldDef)(na, 'ai');
|
|
737
|
-
expect(ai === null || ai === void 0 ? void 0 : ai.annotation).matchesAnnotation({
|
|
738
|
-
blockNotes: [],
|
|
739
|
-
notes: ['# ai\n'],
|
|
740
|
-
});
|
|
741
|
-
const af = (0, test_translator_1.getFieldDef)(na, 'af');
|
|
742
|
-
expect(af).toBeDefined();
|
|
743
|
-
expect(af === null || af === void 0 ? void 0 : af.annotation).toBeUndefined();
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
test('modifier: list', () => {
|
|
747
|
-
const m = new test_translator_1.TestTranslator(`
|
|
748
|
-
##! experimental.access_modifiers
|
|
749
|
-
source: na is a include {
|
|
750
|
-
# a
|
|
751
|
-
public:
|
|
752
|
-
# ai
|
|
753
|
-
ai
|
|
754
|
-
af
|
|
755
|
-
}
|
|
756
|
-
`);
|
|
757
|
-
expect(m).toTranslate();
|
|
758
|
-
const na = m.getSourceDef('na');
|
|
759
|
-
expect(na).toBeDefined();
|
|
760
|
-
if (na) {
|
|
761
|
-
const ai = (0, test_translator_1.getFieldDef)(na, 'ai');
|
|
762
|
-
expect(ai === null || ai === void 0 ? void 0 : ai.annotation).matchesAnnotation({
|
|
763
|
-
blockNotes: ['# a\n'],
|
|
764
|
-
notes: ['# ai\n'],
|
|
765
|
-
});
|
|
766
|
-
const af = (0, test_translator_1.getFieldDef)(na, 'af');
|
|
767
|
-
expect(af === null || af === void 0 ? void 0 : af.annotation).matchesAnnotation({
|
|
768
|
-
blockNotes: ['# a\n'],
|
|
769
|
-
notes: [],
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
test('tags except: list', () => {
|
|
774
|
-
const m = new test_translator_1.TestTranslator(`
|
|
775
|
-
##! experimental.access_modifiers
|
|
776
|
-
source: na is a include {
|
|
777
|
-
# error_1
|
|
778
|
-
except:
|
|
779
|
-
# error_2
|
|
780
|
-
ai
|
|
781
|
-
}
|
|
782
|
-
`);
|
|
783
|
-
expect(m).toLog((0, test_translator_1.warningMessage)('Tags on `except:` are ignored'), (0, test_translator_1.warningMessage)('Tags on `except:` are ignored'));
|
|
784
|
-
});
|
|
785
|
-
test('tags except: star', () => {
|
|
786
|
-
const m = new test_translator_1.TestTranslator(`
|
|
787
|
-
##! experimental.access_modifiers
|
|
788
|
-
source: na is a include {
|
|
789
|
-
# error_1
|
|
790
|
-
except:
|
|
791
|
-
# error_2
|
|
792
|
-
*
|
|
793
|
-
}
|
|
794
|
-
`);
|
|
795
|
-
expect(m).toLog((0, test_translator_1.warningMessage)('Tags on `except:` are ignored'), (0, test_translator_1.warningMessage)('Tags on `except:` are ignored'), (0, test_translator_1.warningMessage)('`except: *` is implied, unless another clause uses *'));
|
|
796
|
-
});
|
|
797
|
-
test('oprhaned annotation', () => {
|
|
798
|
-
const m = new test_translator_1.TestTranslator(`
|
|
799
|
-
##! experimental.access_modifiers
|
|
800
|
-
source: na is a include {
|
|
801
|
-
ai
|
|
802
|
-
${'# orphaned'}
|
|
803
|
-
}
|
|
804
|
-
`);
|
|
805
|
-
expect(m).toLog((0, test_translator_1.warningMessage)('This tag is not attached to anything'));
|
|
806
|
-
});
|
|
807
|
-
});
|
|
808
|
-
});
|
|
809
|
-
//# sourceMappingURL=annotation.spec.js.map
|