@malloydata/malloy 0.0.30 → 0.0.31-dev230414150450
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
CHANGED
|
@@ -2,8 +2,8 @@ export type { QueryDataRow, Fragment, StructDef, StructRelationship, NamedStruct
|
|
|
2
2
|
export { Segment, isFilteredAliasedName, flattenQuery, expressionIsCalculation, } from './model';
|
|
3
3
|
export { HighlightType, MalloyTranslator, } from './lang';
|
|
4
4
|
export type { LogMessage, TranslateResponse } from './lang';
|
|
5
|
-
export { Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, Result, parseTableURI, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, } from './malloy';
|
|
6
|
-
export type {
|
|
5
|
+
export { Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, Result, parseTableURI, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, } from './malloy';
|
|
6
|
+
export type { Model, PreparedQuery, PreparedResult, Field, AtomicField, ExploreField, QueryField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, ModelMaterializer, DocumentSymbol, DocumentHighlight, ResultJSON, PreparedResultMaterializer, SQLBlockMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, } from './malloy';
|
|
7
7
|
export type { RunSQLOptions } from './run_sql_options';
|
|
8
8
|
export type { URLReader, InfoConnection, LookupConnection, Connection, QueryString, ModelString, QueryURL, ModelURL, PooledConnection, TestableConnection, PersistSQLResults, StreamingConnection, } from './runtime_types';
|
|
9
9
|
export type { Loggable } from './malloy';
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.toAsyncGenerator = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.parseTableURI = exports.Result = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = exports.Malloy = exports.MalloyTranslator = exports.HighlightType = exports.expressionIsCalculation = exports.flattenQuery = exports.isFilteredAliasedName = exports.Segment = void 0;
|
|
25
|
+
exports.toAsyncGenerator = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.parseTableURI = exports.Result = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = exports.Malloy = exports.MalloyTranslator = exports.HighlightType = exports.expressionIsCalculation = exports.flattenQuery = exports.isFilteredAliasedName = exports.Segment = void 0;
|
|
26
26
|
var model_1 = require("./model");
|
|
27
27
|
// Used in Composer Demo
|
|
28
28
|
Object.defineProperty(exports, "Segment", { enumerable: true, get: function () { return model_1.Segment; } });
|
|
@@ -55,6 +55,7 @@ Object.defineProperty(exports, "CSVWriter", { enumerable: true, get: function ()
|
|
|
55
55
|
Object.defineProperty(exports, "JSONWriter", { enumerable: true, get: function () { return malloy_1.JSONWriter; } });
|
|
56
56
|
Object.defineProperty(exports, "Parse", { enumerable: true, get: function () { return malloy_1.Parse; } });
|
|
57
57
|
Object.defineProperty(exports, "DataWriter", { enumerable: true, get: function () { return malloy_1.DataWriter; } });
|
|
58
|
+
Object.defineProperty(exports, "Explore", { enumerable: true, get: function () { return malloy_1.Explore; } });
|
|
58
59
|
var connection_utils_1 = require("./connection_utils");
|
|
59
60
|
Object.defineProperty(exports, "toAsyncGenerator", { enumerable: true, get: function () { return connection_utils_1.toAsyncGenerator; } });
|
|
60
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
exports.SOURCE_EXPLORE = exports.GRADPARENT_EXPLORE = exports.PARENT_EXPLORE = exports.CHILD_EXPLORE = void 0;
|
|
26
|
+
const malloy_1 = require("../../malloy");
|
|
27
|
+
exports.CHILD_EXPLORE = {
|
|
28
|
+
type: 'struct',
|
|
29
|
+
name: 'some_ns.child',
|
|
30
|
+
as: 'child',
|
|
31
|
+
dialect: 'standardsql',
|
|
32
|
+
structSource: {
|
|
33
|
+
type: 'table',
|
|
34
|
+
tablePath: 'some_ns.child',
|
|
35
|
+
},
|
|
36
|
+
structRelationship: { type: 'basetable', connectionName: 'bigquery' },
|
|
37
|
+
primaryKey: 'id1',
|
|
38
|
+
fields: [
|
|
39
|
+
{ type: 'string', name: 'carrier' },
|
|
40
|
+
{
|
|
41
|
+
type: 'number',
|
|
42
|
+
name: 'flight_count',
|
|
43
|
+
expressionType: 'aggregate',
|
|
44
|
+
e: [{ type: 'aggregate', function: 'count', e: [] }],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
exports.PARENT_EXPLORE = {
|
|
49
|
+
type: 'struct',
|
|
50
|
+
name: 'some_ns.parent',
|
|
51
|
+
as: 'parent',
|
|
52
|
+
dialect: 'standardsql',
|
|
53
|
+
structSource: {
|
|
54
|
+
type: 'table',
|
|
55
|
+
tablePath: 'some_ns.parent',
|
|
56
|
+
},
|
|
57
|
+
structRelationship: { type: 'basetable', connectionName: 'bigquery' },
|
|
58
|
+
primaryKey: 'id2',
|
|
59
|
+
fields: [
|
|
60
|
+
{ type: 'string', name: 'name' },
|
|
61
|
+
{
|
|
62
|
+
type: 'number',
|
|
63
|
+
name: 'some_parent_count',
|
|
64
|
+
expressionType: 'aggregate',
|
|
65
|
+
e: [{ type: 'aggregate', function: 'count', e: [] }],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
exports.GRADPARENT_EXPLORE = {
|
|
70
|
+
type: 'struct',
|
|
71
|
+
name: 'some_ns.gradparent',
|
|
72
|
+
as: 'parent',
|
|
73
|
+
dialect: 'standardsql',
|
|
74
|
+
structSource: {
|
|
75
|
+
type: 'table',
|
|
76
|
+
tablePath: 'some_ns.gradparent',
|
|
77
|
+
},
|
|
78
|
+
structRelationship: { type: 'basetable', connectionName: 'bigquery' },
|
|
79
|
+
primaryKey: 'id3',
|
|
80
|
+
fields: [
|
|
81
|
+
{ type: 'string', name: 'name' },
|
|
82
|
+
{
|
|
83
|
+
type: 'number',
|
|
84
|
+
name: 'some_gradparent_count',
|
|
85
|
+
expressionType: 'aggregate',
|
|
86
|
+
e: [{ type: 'aggregate', function: 'count', e: [] }],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
exports.SOURCE_EXPLORE = {
|
|
91
|
+
type: 'struct',
|
|
92
|
+
name: 'some_ns.source',
|
|
93
|
+
as: 'source',
|
|
94
|
+
dialect: 'standardsql',
|
|
95
|
+
structSource: {
|
|
96
|
+
type: 'table',
|
|
97
|
+
tablePath: 'some_ns.source',
|
|
98
|
+
},
|
|
99
|
+
structRelationship: { type: 'basetable', connectionName: 'bigquery' },
|
|
100
|
+
primaryKey: 'id4',
|
|
101
|
+
fields: [
|
|
102
|
+
{ type: 'string', name: 'name' },
|
|
103
|
+
{
|
|
104
|
+
type: 'number',
|
|
105
|
+
name: 'some_child_count',
|
|
106
|
+
expressionType: 'aggregate',
|
|
107
|
+
e: [{ type: 'aggregate', function: 'count', e: [] }],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
describe('serializeModel', () => {
|
|
112
|
+
test('Stringify on an `explore` with no parent nor source explore', async () => {
|
|
113
|
+
const parent_explore = new malloy_1.Explore(exports.PARENT_EXPLORE);
|
|
114
|
+
expect(JSON.stringify(parent_explore)).toStrictEqual('{"_structDef":{"type":"struct","name":"some_ns.parent","as":"parent","dialect":"standardsql","structSource":{"type":"table","tablePath":"some_ns.parent"},"structRelationship":{"type":"basetable","connectionName":"bigquery"},"primaryKey":"id2","fields":[{"type":"string","name":"name"},{"type":"number","name":"some_parent_count","expressionType":"aggregate","e":[{"type":"aggregate","function":"count","e":[]}]}]}}');
|
|
115
|
+
});
|
|
116
|
+
test('No parent nor source explore', async () => {
|
|
117
|
+
const parent_explore = new malloy_1.Explore(exports.PARENT_EXPLORE);
|
|
118
|
+
expect(malloy_1.Explore.fromJSON(parent_explore.toJSON())).toStrictEqual(parent_explore);
|
|
119
|
+
});
|
|
120
|
+
test('Having parent and source explores', async () => {
|
|
121
|
+
const gradparent_explore = new malloy_1.Explore(exports.GRADPARENT_EXPLORE);
|
|
122
|
+
const parent_explore = new malloy_1.Explore(exports.PARENT_EXPLORE, gradparent_explore);
|
|
123
|
+
const source_explore = new malloy_1.Explore(exports.SOURCE_EXPLORE);
|
|
124
|
+
const child_explore = new malloy_1.Explore(exports.CHILD_EXPLORE, parent_explore, source_explore);
|
|
125
|
+
expect(malloy_1.Explore.fromJSON(child_explore.toJSON())).toStrictEqual(child_explore);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=model_serialization.spec.js.map
|
package/dist/malloy.d.ts
CHANGED
|
@@ -460,6 +460,11 @@ declare abstract class Entity {
|
|
|
460
460
|
abstract isIntrinsic(): boolean;
|
|
461
461
|
}
|
|
462
462
|
export declare type Field = AtomicField | QueryField | ExploreField;
|
|
463
|
+
export declare type SerializedExplore = {
|
|
464
|
+
_structDef: StructDef;
|
|
465
|
+
sourceExplore?: SerializedExplore;
|
|
466
|
+
_parentExplore?: SerializedExplore;
|
|
467
|
+
};
|
|
463
468
|
export declare class Explore extends Entity {
|
|
464
469
|
protected readonly _structDef: StructDef;
|
|
465
470
|
protected readonly _parentExplore?: Explore;
|
|
@@ -487,6 +492,8 @@ export declare class Explore extends Entity {
|
|
|
487
492
|
get filters(): FilterExpression[];
|
|
488
493
|
get limit(): number | undefined;
|
|
489
494
|
get structDef(): StructDef;
|
|
495
|
+
toJSON(): SerializedExplore;
|
|
496
|
+
static fromJSON(main_explore: SerializedExplore): Explore;
|
|
490
497
|
}
|
|
491
498
|
export declare enum AtomicFieldType {
|
|
492
499
|
String = "string",
|
package/dist/malloy.js
CHANGED
|
@@ -979,6 +979,23 @@ class Explore extends Entity {
|
|
|
979
979
|
get structDef() {
|
|
980
980
|
return this._structDef;
|
|
981
981
|
}
|
|
982
|
+
toJSON() {
|
|
983
|
+
var _a, _b;
|
|
984
|
+
return {
|
|
985
|
+
_structDef: this._structDef,
|
|
986
|
+
sourceExplore: (_a = this.sourceExplore) === null || _a === void 0 ? void 0 : _a.toJSON(),
|
|
987
|
+
_parentExplore: (_b = this._parentExplore) === null || _b === void 0 ? void 0 : _b.toJSON(),
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
static fromJSON(main_explore) {
|
|
991
|
+
const parentExplore = main_explore._parentExplore !== undefined
|
|
992
|
+
? Explore.fromJSON(main_explore._parentExplore)
|
|
993
|
+
: undefined;
|
|
994
|
+
const sourceExplore = main_explore.sourceExplore !== undefined
|
|
995
|
+
? Explore.fromJSON(main_explore.sourceExplore)
|
|
996
|
+
: undefined;
|
|
997
|
+
return new Explore(main_explore._structDef, parentExplore, sourceExplore);
|
|
998
|
+
}
|
|
982
999
|
}
|
|
983
1000
|
exports.Explore = Explore;
|
|
984
1001
|
var AtomicFieldType;
|