@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.
Files changed (66) hide show
  1. package/dist/api/core.d.ts +1 -0
  2. package/dist/api/core.js +2 -1
  3. package/dist/lang/malloy-parse-info.d.ts +2 -10
  4. package/dist/lang/malloy-to-ast.d.ts +1 -0
  5. package/dist/lang/malloy-to-ast.js +9 -6
  6. package/dist/lang/malloy-to-stable-query.d.ts +76 -0
  7. package/dist/lang/malloy-to-stable-query.js +660 -0
  8. package/dist/lang/parse-log.d.ts +1 -0
  9. package/dist/lang/parse-malloy.d.ts +2 -9
  10. package/dist/lang/parse-malloy.js +7 -112
  11. package/dist/lang/parse-tree-walkers/model-annotation-walker.js +1 -1
  12. package/dist/lang/run-malloy-parser.d.ts +3 -0
  13. package/dist/lang/run-malloy-parser.js +53 -0
  14. package/dist/lang/syntax-errors/malloy-parser-error-listener.d.ts +4 -3
  15. package/dist/lang/syntax-errors/malloy-parser-error-listener.js +8 -4
  16. package/dist/lang/utils.d.ts +27 -1
  17. package/dist/lang/utils.js +78 -1
  18. package/package.json +3 -3
  19. package/dist/api/asynchronous.spec.d.ts +0 -1
  20. package/dist/api/asynchronous.spec.js +0 -240
  21. package/dist/api/sessioned.spec.d.ts +0 -1
  22. package/dist/api/sessioned.spec.js +0 -476
  23. package/dist/api/stateless.spec.d.ts +0 -1
  24. package/dist/api/stateless.spec.js +0 -400
  25. package/dist/lang/test/annotation.spec.d.ts +0 -14
  26. package/dist/lang/test/annotation.spec.js +0 -809
  27. package/dist/lang/test/composite-field-usage.spec.d.ts +0 -1
  28. package/dist/lang/test/composite-field-usage.spec.js +0 -261
  29. package/dist/lang/test/document-help-context-walker.spec.d.ts +0 -1
  30. package/dist/lang/test/document-help-context-walker.spec.js +0 -55
  31. package/dist/lang/test/document-symbol-walker.spec.d.ts +0 -1
  32. package/dist/lang/test/document-symbol-walker.spec.js +0 -209
  33. package/dist/lang/test/expressions.spec.d.ts +0 -1
  34. package/dist/lang/test/expressions.spec.js +0 -1181
  35. package/dist/lang/test/field-symbols.spec.d.ts +0 -1
  36. package/dist/lang/test/field-symbols.spec.js +0 -194
  37. package/dist/lang/test/find-table-path-walker.spec.d.ts +0 -1
  38. package/dist/lang/test/find-table-path-walker.spec.js +0 -50
  39. package/dist/lang/test/imports.spec.d.ts +0 -1
  40. package/dist/lang/test/imports.spec.js +0 -283
  41. package/dist/lang/test/lenses.spec.d.ts +0 -1
  42. package/dist/lang/test/lenses.spec.js +0 -384
  43. package/dist/lang/test/literals.spec.d.ts +0 -1
  44. package/dist/lang/test/literals.spec.js +0 -267
  45. package/dist/lang/test/locations.spec.d.ts +0 -1
  46. package/dist/lang/test/locations.spec.js +0 -679
  47. package/dist/lang/test/model-annotation-walker.spec.d.ts +0 -1
  48. package/dist/lang/test/model-annotation-walker.spec.js +0 -46
  49. package/dist/lang/test/model_serialization.spec.d.ts +0 -5
  50. package/dist/lang/test/model_serialization.spec.js +0 -116
  51. package/dist/lang/test/parameters.spec.d.ts +0 -1
  52. package/dist/lang/test/parameters.spec.js +0 -619
  53. package/dist/lang/test/parse.spec.d.ts +0 -1
  54. package/dist/lang/test/parse.spec.js +0 -893
  55. package/dist/lang/test/pretranslate.spec.d.ts +0 -1
  56. package/dist/lang/test/pretranslate.spec.js +0 -80
  57. package/dist/lang/test/query.spec.d.ts +0 -1
  58. package/dist/lang/test/query.spec.js +0 -1149
  59. package/dist/lang/test/source.spec.d.ts +0 -1
  60. package/dist/lang/test/source.spec.js +0 -570
  61. package/dist/lang/test/sql-block.spec.d.ts +0 -1
  62. package/dist/lang/test/sql-block.spec.js +0 -145
  63. package/dist/lang/test/syntax-errors.spec.d.ts +0 -1
  64. package/dist/lang/test/syntax-errors.spec.js +0 -142
  65. package/dist/model/utils.spec.d.ts +0 -1
  66. package/dist/model/utils.spec.js +0 -38
@@ -1,400 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const stateless_1 = require("./stateless");
10
- describe('api', () => {
11
- describe('compile model', () => {
12
- test('compile model with table dependency', () => {
13
- const result = (0, stateless_1.compileModel)({
14
- model_url: 'file://test.malloy',
15
- compiler_needs: {
16
- table_schemas: [
17
- {
18
- connection_name: 'connection',
19
- name: 'flights',
20
- schema: {
21
- fields: [
22
- {
23
- kind: 'dimension',
24
- name: 'carrier',
25
- type: { kind: 'string_type' },
26
- },
27
- ],
28
- },
29
- },
30
- ],
31
- files: [
32
- {
33
- url: 'file://test.malloy',
34
- contents: "source: flights is connection.table('flights')",
35
- },
36
- ],
37
- connections: [{ name: 'connection', dialect: 'duckdb' }],
38
- },
39
- });
40
- const expected = {
41
- model: {
42
- entries: [
43
- {
44
- kind: 'source',
45
- name: 'flights',
46
- schema: {
47
- fields: [
48
- {
49
- kind: 'dimension',
50
- name: 'carrier',
51
- type: { kind: 'string_type' },
52
- },
53
- ],
54
- },
55
- },
56
- ],
57
- anonymous_queries: [],
58
- },
59
- };
60
- expect(result).toMatchObject(expected);
61
- });
62
- test('compile model with model extension', () => {
63
- const result = (0, stateless_1.compileModel)({
64
- model_url: 'file://test.malloy',
65
- extend_model_url: 'file://base.malloy',
66
- compiler_needs: {
67
- table_schemas: [
68
- {
69
- connection_name: 'connection',
70
- name: 'flights',
71
- schema: {
72
- fields: [
73
- {
74
- kind: 'dimension',
75
- name: 'carrier',
76
- type: { kind: 'string_type' },
77
- },
78
- ],
79
- },
80
- },
81
- ],
82
- files: [
83
- {
84
- url: 'file://base.malloy',
85
- contents: "source: flights_base is connection.table('flights')",
86
- },
87
- {
88
- url: 'file://test.malloy',
89
- contents: 'source: flights is flights_base',
90
- },
91
- ],
92
- connections: [{ name: 'connection', dialect: 'duckdb' }],
93
- },
94
- });
95
- const expected = {
96
- model: {
97
- entries: [
98
- {
99
- kind: 'source',
100
- name: 'flights_base',
101
- schema: {
102
- fields: [
103
- {
104
- kind: 'dimension',
105
- name: 'carrier',
106
- type: { kind: 'string_type' },
107
- },
108
- ],
109
- },
110
- },
111
- {
112
- kind: 'source',
113
- name: 'flights',
114
- schema: {
115
- fields: [
116
- {
117
- kind: 'dimension',
118
- name: 'carrier',
119
- type: { kind: 'string_type' },
120
- },
121
- ],
122
- },
123
- },
124
- ],
125
- anonymous_queries: [],
126
- },
127
- };
128
- expect(result).toMatchObject(expected);
129
- });
130
- test('compile model with sql dependency', () => {
131
- const result = (0, stateless_1.compileModel)({
132
- model_url: 'file://test.malloy',
133
- compiler_needs: {
134
- sql_schemas: [
135
- {
136
- connection_name: 'connection',
137
- sql: 'SELECT 1 as one',
138
- schema: {
139
- fields: [
140
- {
141
- kind: 'dimension',
142
- name: 'one',
143
- type: { kind: 'number_type' },
144
- },
145
- ],
146
- },
147
- },
148
- ],
149
- files: [
150
- {
151
- url: 'file://test.malloy',
152
- contents: "source: flights is connection.sql('SELECT 1 as one')",
153
- },
154
- ],
155
- connections: [{ name: 'connection', dialect: 'duckdb' }],
156
- },
157
- });
158
- const expected = {
159
- model: {
160
- entries: [
161
- {
162
- kind: 'source',
163
- name: 'flights',
164
- schema: {
165
- fields: [
166
- {
167
- kind: 'dimension',
168
- name: 'one',
169
- type: { kind: 'number_type' },
170
- },
171
- ],
172
- },
173
- },
174
- ],
175
- anonymous_queries: [],
176
- },
177
- };
178
- expect(result).toMatchObject(expected);
179
- });
180
- });
181
- test('compile model with turducken sql dependency', () => {
182
- const sql = '\n SELECT carrier FROM (SELECT \n base."carrier" as "carrier"\nFROM flights as base\nGROUP BY 1\nORDER BY 1 asc NULLS LAST\n)\n ';
183
- const result = (0, stateless_1.compileModel)({
184
- model_url: 'file://test.malloy',
185
- compiler_needs: {
186
- table_schemas: [
187
- {
188
- connection_name: 'connection',
189
- name: 'flights',
190
- schema: {
191
- fields: [
192
- {
193
- kind: 'dimension',
194
- name: 'carrier',
195
- type: { kind: 'string_type' },
196
- },
197
- ],
198
- },
199
- },
200
- ],
201
- sql_schemas: [
202
- {
203
- connection_name: 'connection',
204
- sql,
205
- schema: {
206
- fields: [
207
- {
208
- kind: 'dimension',
209
- name: 'carrier',
210
- type: { kind: 'string_type' },
211
- },
212
- ],
213
- },
214
- },
215
- ],
216
- files: [
217
- {
218
- url: 'file://test.malloy',
219
- contents: `
220
- source: flights is connection.table('flights')
221
- source: sql_source is connection.sql("""
222
- SELECT carrier FROM (%{
223
- flights -> { group_by: carrier }
224
- })
225
- """)
226
- `,
227
- },
228
- ],
229
- connections: [{ name: 'connection', dialect: 'duckdb' }],
230
- },
231
- });
232
- const expected = {
233
- model: {
234
- entries: [
235
- {
236
- kind: 'source',
237
- name: 'flights',
238
- schema: {
239
- fields: [
240
- {
241
- kind: 'dimension',
242
- name: 'carrier',
243
- type: { kind: 'string_type' },
244
- },
245
- ],
246
- },
247
- },
248
- {
249
- kind: 'source',
250
- name: 'sql_source',
251
- schema: {
252
- fields: [
253
- {
254
- kind: 'dimension',
255
- name: 'carrier',
256
- type: { kind: 'string_type' },
257
- },
258
- ],
259
- },
260
- },
261
- ],
262
- anonymous_queries: [],
263
- },
264
- };
265
- expect(result).toMatchObject(expected);
266
- });
267
- describe('compile query', () => {
268
- test('compile query with table dependency', () => {
269
- const result = (0, stateless_1.compileQuery)({
270
- model_url: 'file://test.malloy',
271
- query: {
272
- annotations: [{ value: '#(test) hello' }],
273
- definition: {
274
- kind: 'arrow',
275
- source_reference: { name: 'flights' },
276
- view: {
277
- kind: 'segment',
278
- operations: [
279
- {
280
- kind: 'group_by',
281
- field: {
282
- expression: { kind: 'field_reference', name: 'carrier' },
283
- },
284
- },
285
- ],
286
- },
287
- },
288
- },
289
- compiler_needs: {
290
- table_schemas: [
291
- {
292
- connection_name: 'connection',
293
- name: 'flights',
294
- schema: {
295
- fields: [
296
- {
297
- kind: 'dimension',
298
- name: 'carrier',
299
- type: { kind: 'string_type' },
300
- },
301
- ],
302
- },
303
- },
304
- ],
305
- files: [
306
- {
307
- url: 'file://test.malloy',
308
- contents: "source: flights is connection.table('flights')",
309
- },
310
- ],
311
- connections: [{ name: 'connection', dialect: 'duckdb' }],
312
- },
313
- });
314
- const expected = {
315
- result: {
316
- connection_name: 'connection',
317
- annotations: [
318
- { value: '#(test) hello\n' },
319
- { value: '#(malloy) ordered_by = [{ carrier = asc }]\n' },
320
- { value: '#(malloy) source_name = flights\n' },
321
- ],
322
- sql: `SELECT \n\
323
- base."carrier" as "carrier"
324
- FROM flights as base
325
- GROUP BY 1
326
- ORDER BY 1 asc NULLS LAST
327
- `,
328
- schema: {
329
- fields: [
330
- {
331
- kind: 'dimension',
332
- name: 'carrier',
333
- type: { kind: 'string_type' },
334
- },
335
- ],
336
- },
337
- },
338
- };
339
- expect(result).toMatchObject(expected);
340
- });
341
- });
342
- describe('compiler errors', () => {
343
- test('parse error should come back as a log', () => {
344
- const result = (0, stateless_1.compileModel)({
345
- model_url: 'file://test.malloy',
346
- compiler_needs: {
347
- files: [
348
- {
349
- url: 'file://test.malloy',
350
- contents: 'run: flights -> { group_by: carrier }',
351
- },
352
- ],
353
- },
354
- });
355
- const expected = {
356
- logs: [
357
- {
358
- url: 'file://test.malloy',
359
- severity: 'error',
360
- message: "Reference to undefined object 'flights'",
361
- range: {
362
- start: { line: 0, character: 5 },
363
- end: { line: 0, character: 12 },
364
- },
365
- },
366
- ],
367
- };
368
- expect(result).toMatchObject(expected);
369
- });
370
- test('missing source should come back as a log', () => {
371
- const result = (0, stateless_1.compileSource)({
372
- model_url: 'file://test.malloy',
373
- name: 'flights',
374
- compiler_needs: {
375
- files: [
376
- {
377
- url: 'file://test.malloy',
378
- contents: '// nothing to see here',
379
- },
380
- ],
381
- },
382
- });
383
- const expected = {
384
- logs: [
385
- {
386
- url: 'file://test.malloy',
387
- severity: 'error',
388
- message: 'Model does not contain a source named flights',
389
- range: {
390
- start: { line: 0, character: 0 },
391
- end: { line: 0, character: 0 },
392
- },
393
- },
394
- ],
395
- };
396
- expect(result).toMatchObject(expected);
397
- });
398
- });
399
- });
400
- //# sourceMappingURL=stateless.spec.js.map
@@ -1,14 +0,0 @@
1
- import './parse-expects';
2
- interface TstAnnotation {
3
- inherits?: TstAnnotation;
4
- blockNotes?: string[];
5
- notes?: string[];
6
- }
7
- declare global {
8
- namespace jest {
9
- interface Matchers<R> {
10
- matchesAnnotation(tt: TstAnnotation): R;
11
- }
12
- }
13
- }
14
- export {};