@malloydata/malloy-interfaces 0.0.239-dev250226010331 → 0.0.239-dev250227145856
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/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/nest_unions.d.ts +1 -0
- package/dist/nest_unions.js +40 -0
- package/dist/nest_unions.spec.d.ts +1 -0
- package/dist/nest_unions.spec.js +67 -0
- package/dist/types.d.ts +97 -1
- package/package.json +1 -1
- package/thrift/malloy.thrift +142 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Malloy from './types';
|
|
2
2
|
export * from './types';
|
|
3
3
|
export { queryToMalloy } from './to_malloy';
|
|
4
|
+
export { nestUnions } from './nest_unions';
|
|
4
5
|
export declare const test: Malloy.ModelInfo;
|
|
5
6
|
export declare const res: Malloy.Result;
|
|
6
7
|
export declare const thingy1: Malloy.Query;
|
package/dist/index.js
CHANGED
|
@@ -20,10 +20,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.thingy4sddfdfsd = exports.thingy4sdfsd = exports.thingy4dfdsfs = exports.thingy4asdfas = exports.thingy4asdfasdf = exports.thingy3dfdf = exports.thingy3 = exports.thingy2asdf = exports.thingyssdfg = exports.thingy123r = exports.thingy1 = exports.res = exports.test = exports.queryToMalloy = void 0;
|
|
23
|
+
exports.thingy4sddfdfsd = exports.thingy4sdfsd = exports.thingy4dfdsfs = exports.thingy4asdfas = exports.thingy4asdfasdf = exports.thingy3dfdf = exports.thingy3 = exports.thingy2asdf = exports.thingyssdfg = exports.thingy123r = exports.thingy1 = exports.res = exports.test = exports.nestUnions = exports.queryToMalloy = void 0;
|
|
24
24
|
__exportStar(require("./types"), exports);
|
|
25
25
|
var to_malloy_1 = require("./to_malloy");
|
|
26
26
|
Object.defineProperty(exports, "queryToMalloy", { enumerable: true, get: function () { return to_malloy_1.queryToMalloy; } });
|
|
27
|
+
var nest_unions_1 = require("./nest_unions");
|
|
28
|
+
Object.defineProperty(exports, "nestUnions", { enumerable: true, get: function () { return nest_unions_1.nestUnions; } });
|
|
27
29
|
exports.test = {
|
|
28
30
|
entries: [
|
|
29
31
|
{
|
|
@@ -146,6 +148,7 @@ exports.test = {
|
|
|
146
148
|
anonymous_queries: [],
|
|
147
149
|
};
|
|
148
150
|
exports.res = {
|
|
151
|
+
connection_name: 'foo',
|
|
149
152
|
data: {
|
|
150
153
|
kind: 'table',
|
|
151
154
|
rows: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nestUnions(obj: unknown): unknown;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
exports.nestUnions = void 0;
|
|
10
|
+
function nestUnions(obj) {
|
|
11
|
+
if (obj === null) {
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
else if (typeof obj === 'string' || typeof obj === 'number') {
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
else if (Array.isArray(obj)) {
|
|
18
|
+
return obj.map(nestUnions);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const result = {};
|
|
22
|
+
let kind = undefined;
|
|
23
|
+
for (const key in obj) {
|
|
24
|
+
if (key === 'kind') {
|
|
25
|
+
kind = obj[key];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
result[key] = nestUnions(obj[key]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (kind === undefined) {
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return { [kind]: result };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.nestUnions = nestUnions;
|
|
40
|
+
//# sourceMappingURL=nest_unions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 nest_unions_1 = require("./nest_unions");
|
|
10
|
+
describe('unnest unions', () => {
|
|
11
|
+
test('works', () => {
|
|
12
|
+
const query = {
|
|
13
|
+
definition: {
|
|
14
|
+
kind: 'arrow',
|
|
15
|
+
source_reference: {
|
|
16
|
+
name: 'flights',
|
|
17
|
+
},
|
|
18
|
+
view: {
|
|
19
|
+
kind: 'segment',
|
|
20
|
+
operations: [
|
|
21
|
+
{
|
|
22
|
+
kind: 'group_by',
|
|
23
|
+
field: {
|
|
24
|
+
expression: {
|
|
25
|
+
kind: 'field_reference',
|
|
26
|
+
name: 'carrier',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
kind: 'limit',
|
|
32
|
+
limit: 10,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
expect((0, nest_unions_1.nestUnions)(query)).toMatchObject({
|
|
39
|
+
definition: {
|
|
40
|
+
arrow: {
|
|
41
|
+
source_reference: {
|
|
42
|
+
name: 'flights',
|
|
43
|
+
},
|
|
44
|
+
view: {
|
|
45
|
+
segment: {
|
|
46
|
+
operations: [
|
|
47
|
+
{
|
|
48
|
+
group_by: {
|
|
49
|
+
field: {
|
|
50
|
+
expression: {
|
|
51
|
+
field_reference: { name: 'carrier' },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
limit: { limit: 10 },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=nest_unions.spec.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -83,6 +83,48 @@ export type CellWithArrayCell = {
|
|
|
83
83
|
export type CellWithTableCell = {
|
|
84
84
|
kind: 'table_cell';
|
|
85
85
|
} & TableCell;
|
|
86
|
+
export type CompileModelRequest = {
|
|
87
|
+
model_url: string;
|
|
88
|
+
extend_model_url?: string;
|
|
89
|
+
compiler_needs?: CompilerNeeds;
|
|
90
|
+
};
|
|
91
|
+
export type CompileModelResponse = {
|
|
92
|
+
model?: ModelInfo;
|
|
93
|
+
logs?: Array<LogMessage>;
|
|
94
|
+
compiler_needs?: CompilerNeeds;
|
|
95
|
+
};
|
|
96
|
+
export type CompileQueryRequest = {
|
|
97
|
+
model_url: string;
|
|
98
|
+
query: Query;
|
|
99
|
+
compiler_needs?: CompilerNeeds;
|
|
100
|
+
};
|
|
101
|
+
export type CompileQueryResponse = {
|
|
102
|
+
result?: Result;
|
|
103
|
+
logs?: Array<LogMessage>;
|
|
104
|
+
compiler_needs?: CompilerNeeds;
|
|
105
|
+
};
|
|
106
|
+
export type CompileSourceRequest = {
|
|
107
|
+
model_url: string;
|
|
108
|
+
name: string;
|
|
109
|
+
extend_model_url?: string;
|
|
110
|
+
compiler_needs?: CompilerNeeds;
|
|
111
|
+
};
|
|
112
|
+
export type CompileSourceResponse = {
|
|
113
|
+
source?: SourceInfo;
|
|
114
|
+
logs?: Array<LogMessage>;
|
|
115
|
+
compiler_needs?: CompilerNeeds;
|
|
116
|
+
};
|
|
117
|
+
export type CompilerNeeds = {
|
|
118
|
+
table_schemas?: Array<SQLTable>;
|
|
119
|
+
sql_schemas?: Array<SQLQuery>;
|
|
120
|
+
files?: Array<File>;
|
|
121
|
+
connections?: Array<Connection>;
|
|
122
|
+
translations?: Array<Translation>;
|
|
123
|
+
};
|
|
124
|
+
export type Connection = {
|
|
125
|
+
name: string;
|
|
126
|
+
dialect?: string;
|
|
127
|
+
};
|
|
86
128
|
export type DataType = 'record' | 'table';
|
|
87
129
|
export type Data = DataWithRecord | DataWithTable;
|
|
88
130
|
export type DataWithRecord = {
|
|
@@ -107,6 +149,14 @@ export type DimensionInfo = {
|
|
|
107
149
|
type: AtomicType;
|
|
108
150
|
annotations?: Array<Annotation>;
|
|
109
151
|
};
|
|
152
|
+
export type DocumentPosition = {
|
|
153
|
+
line: number;
|
|
154
|
+
character: number;
|
|
155
|
+
};
|
|
156
|
+
export type DocumentRange = {
|
|
157
|
+
start: DocumentPosition;
|
|
158
|
+
end: DocumentPosition;
|
|
159
|
+
};
|
|
110
160
|
export type ExpressionType = 'field_reference' | 'time_truncation' | 'filtered_field';
|
|
111
161
|
export type Expression = ExpressionWithFieldReference | ExpressionWithTimeTruncation | ExpressionWithFilteredField;
|
|
112
162
|
export type ExpressionWithFieldReference = {
|
|
@@ -136,6 +186,11 @@ export type FieldInfoWithJoin = {
|
|
|
136
186
|
export type FieldInfoWithView = {
|
|
137
187
|
kind: 'view';
|
|
138
188
|
} & ViewInfo;
|
|
189
|
+
export type File = {
|
|
190
|
+
url: string;
|
|
191
|
+
contents?: string;
|
|
192
|
+
invalidation_key?: string;
|
|
193
|
+
};
|
|
139
194
|
export type FilterType = 'filter_string';
|
|
140
195
|
export type Filter = FilterWithFilterString;
|
|
141
196
|
export type FilterWithFilterString = {
|
|
@@ -190,6 +245,13 @@ export type Location = {
|
|
|
190
245
|
url: string;
|
|
191
246
|
range: Range;
|
|
192
247
|
};
|
|
248
|
+
export type LogMessage = {
|
|
249
|
+
url: string;
|
|
250
|
+
range: DocumentRange;
|
|
251
|
+
severity: LogSeverity;
|
|
252
|
+
message: string;
|
|
253
|
+
};
|
|
254
|
+
export type LogSeverity = 'debug' | 'info' | 'warn' | 'error';
|
|
193
255
|
export type MeasureInfo = {
|
|
194
256
|
name: string;
|
|
195
257
|
type: AtomicType;
|
|
@@ -206,7 +268,7 @@ export type ModelEntryValueWithQuery = {
|
|
|
206
268
|
export type ModelInfo = {
|
|
207
269
|
entries: Array<ModelEntryValue>;
|
|
208
270
|
annotations?: Array<Annotation>;
|
|
209
|
-
anonymous_queries: Array<
|
|
271
|
+
anonymous_queries: Array<AnonymousQueryInfo>;
|
|
210
272
|
};
|
|
211
273
|
export type Nest = {
|
|
212
274
|
name?: string;
|
|
@@ -292,13 +354,43 @@ export type Result = {
|
|
|
292
354
|
data?: Data;
|
|
293
355
|
schema: Schema;
|
|
294
356
|
sql?: string;
|
|
357
|
+
connection_name: string;
|
|
295
358
|
};
|
|
296
359
|
export type Row = {
|
|
297
360
|
cells: Array<Cell>;
|
|
298
361
|
};
|
|
362
|
+
export type RunIndexQueryRequest = {
|
|
363
|
+
model_url: string;
|
|
364
|
+
source_name: string;
|
|
365
|
+
compiler_needs?: CompilerNeeds;
|
|
366
|
+
};
|
|
367
|
+
export type RunIndexQueryResponse = {
|
|
368
|
+
result?: Result;
|
|
369
|
+
compiler_needs?: CompilerNeeds;
|
|
370
|
+
};
|
|
371
|
+
export type RunQueryRequest = {
|
|
372
|
+
model_url: string;
|
|
373
|
+
query: Query;
|
|
374
|
+
compiler_needs?: CompilerNeeds;
|
|
375
|
+
};
|
|
376
|
+
export type RunQueryResponse = {
|
|
377
|
+
result?: Result;
|
|
378
|
+
logs?: Array<LogMessage>;
|
|
379
|
+
compiler_needs?: CompilerNeeds;
|
|
380
|
+
};
|
|
299
381
|
export type SQLNativeType = {
|
|
300
382
|
sql_type?: string;
|
|
301
383
|
};
|
|
384
|
+
export type SQLQuery = {
|
|
385
|
+
sql: string;
|
|
386
|
+
schema?: Schema;
|
|
387
|
+
connection_name: string;
|
|
388
|
+
};
|
|
389
|
+
export type SQLTable = {
|
|
390
|
+
name: string;
|
|
391
|
+
schema?: Schema;
|
|
392
|
+
connection_name: string;
|
|
393
|
+
};
|
|
302
394
|
export type Schema = {
|
|
303
395
|
fields: Array<FieldInfo>;
|
|
304
396
|
};
|
|
@@ -336,6 +428,10 @@ export type TimestampTimeframe = 'year' | 'quarter' | 'month' | 'week' | 'day' |
|
|
|
336
428
|
export type TimestampType = {
|
|
337
429
|
timeframe?: TimestampTimeframe;
|
|
338
430
|
};
|
|
431
|
+
export type Translation = {
|
|
432
|
+
url: string;
|
|
433
|
+
compiled_model_json?: string;
|
|
434
|
+
};
|
|
339
435
|
export type View = {
|
|
340
436
|
definition: ViewDefinition;
|
|
341
437
|
annotations?: Array<Annotation>;
|
package/package.json
CHANGED
package/thrift/malloy.thrift
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
struct ModelInfo {
|
|
9
9
|
1: required list<ModelEntryValue> entries,
|
|
10
10
|
2: optional list<Annotation> annotations,
|
|
11
|
-
3: required list<
|
|
11
|
+
3: required list<AnonymousQueryInfo> anonymous_queries,
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
union ModelEntryValue {
|
|
@@ -479,6 +479,7 @@ struct Result {
|
|
|
479
479
|
1: optional Data data,
|
|
480
480
|
2: required Schema schema,
|
|
481
481
|
3: optional string sql,
|
|
482
|
+
4: required string connection_name,
|
|
482
483
|
}
|
|
483
484
|
|
|
484
485
|
/*
|
|
@@ -523,3 +524,143 @@ TODO
|
|
|
523
524
|
|
|
524
525
|
// concern: shape of FieldInfo and GroupBy (no object for "Field") are funadmentally pretty different,
|
|
525
526
|
// but it might be nice for them to be more similar.
|
|
527
|
+
|
|
528
|
+
struct SQLTable {
|
|
529
|
+
1: required string name,
|
|
530
|
+
2: optional Schema schema,
|
|
531
|
+
3: required string connection_name,
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
struct SQLQuery {
|
|
535
|
+
1: required string sql,
|
|
536
|
+
2: optional Schema schema,
|
|
537
|
+
3: required string connection_name,
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
struct File {
|
|
541
|
+
1: required string url,
|
|
542
|
+
2: optional string contents,
|
|
543
|
+
3: optional string invalidation_key,
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
struct Connection {
|
|
547
|
+
1: required string name,
|
|
548
|
+
2: optional string dialect,
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
struct Translation {
|
|
552
|
+
1: required string url,
|
|
553
|
+
2: optional string compiled_model_json,
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
struct CompilerNeeds {
|
|
557
|
+
1: optional list<SQLTable> table_schemas,
|
|
558
|
+
2: optional list<SQLQuery> sql_schemas,
|
|
559
|
+
3: optional list<File> files,
|
|
560
|
+
4: optional list<Connection> connections,
|
|
561
|
+
5: optional list<Translation> translations,
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
struct DocumentPosition {
|
|
565
|
+
1: required i32 line;
|
|
566
|
+
2: required i32 character;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
struct DocumentRange {
|
|
570
|
+
1: required DocumentPosition start;
|
|
571
|
+
2: required DocumentPosition end;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
enum LogSeverity {
|
|
575
|
+
DEBUG = 1,
|
|
576
|
+
INFO = 2,
|
|
577
|
+
WARN = 3,
|
|
578
|
+
ERROR = 4
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
struct LogMessage {
|
|
582
|
+
1: required string url;
|
|
583
|
+
2: required DocumentRange range;
|
|
584
|
+
3: required LogSeverity severity;
|
|
585
|
+
4: required string message;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// Given the URL to a model, return the StableModelDef for that model
|
|
589
|
+
|
|
590
|
+
struct CompileModelRequest {
|
|
591
|
+
1: required string model_url,
|
|
592
|
+
2: optional string extend_model_url,
|
|
593
|
+
|
|
594
|
+
9: optional CompilerNeeds compiler_needs,
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
struct CompileModelResponse {
|
|
598
|
+
1: optional ModelInfo model,
|
|
599
|
+
|
|
600
|
+
8: optional list<LogMessage> logs,
|
|
601
|
+
9: optional CompilerNeeds compiler_needs,
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// Given the URL to a model and a name of a queryable thing, get a StableSourceDef
|
|
605
|
+
|
|
606
|
+
struct CompileSourceRequest {
|
|
607
|
+
1: required string model_url,
|
|
608
|
+
2: required string name,
|
|
609
|
+
3: optional string extend_model_url,
|
|
610
|
+
|
|
611
|
+
9: optional CompilerNeeds compiler_needs,
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
struct CompileSourceResponse {
|
|
615
|
+
1: optional SourceInfo source,
|
|
616
|
+
|
|
617
|
+
8: optional list<LogMessage> logs,
|
|
618
|
+
9: optional CompilerNeeds compiler_needs,
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// Given a StableQueryDef and the URL to a model, run it and return a StableResult
|
|
622
|
+
|
|
623
|
+
struct RunQueryRequest {
|
|
624
|
+
1: required string model_url,
|
|
625
|
+
2: required Query query,
|
|
626
|
+
|
|
627
|
+
9: optional CompilerNeeds compiler_needs,
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
struct RunQueryResponse {
|
|
631
|
+
1: optional Result result,
|
|
632
|
+
|
|
633
|
+
8: optional list<LogMessage> logs,
|
|
634
|
+
9: optional CompilerNeeds compiler_needs,
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// Given a StableQueryDef and the URL to a model, compile it and return a StableResultDef
|
|
638
|
+
|
|
639
|
+
struct CompileQueryRequest {
|
|
640
|
+
1: required string model_url,
|
|
641
|
+
2: required Query query,
|
|
642
|
+
|
|
643
|
+
9: optional CompilerNeeds compiler_needs,
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
struct CompileQueryResponse {
|
|
647
|
+
1: optional Result result,
|
|
648
|
+
|
|
649
|
+
8: optional list<LogMessage> logs,
|
|
650
|
+
9: optional CompilerNeeds compiler_needs,
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Given a URL to a model and the name of a source, run the indexing query
|
|
654
|
+
|
|
655
|
+
struct RunIndexQueryRequest {
|
|
656
|
+
1: required string model_url,
|
|
657
|
+
2: required string source_name,
|
|
658
|
+
|
|
659
|
+
9: optional CompilerNeeds compiler_needs,
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
struct RunIndexQueryResponse {
|
|
663
|
+
1: optional Result result,
|
|
664
|
+
|
|
665
|
+
9: optional CompilerNeeds compiler_needs,
|
|
666
|
+
}
|