@malloydata/malloy 0.0.101-dev231110211921 → 0.0.101-dev231114015212
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/lang/parse-malloy.js +4 -1
- package/dist/malloy.d.ts +5 -4
- package/dist/malloy.js +22 -7
- package/package.json +1 -1
|
@@ -502,7 +502,10 @@ class TranslateStep {
|
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
if (that.root.logger.hasErrors()) {
|
|
505
|
-
this.response =
|
|
505
|
+
this.response = {
|
|
506
|
+
fromSources: that.getDependencies(),
|
|
507
|
+
...that.fatalResponse(),
|
|
508
|
+
};
|
|
506
509
|
}
|
|
507
510
|
else {
|
|
508
511
|
this.response = {
|
package/dist/malloy.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface ParseOptions {
|
|
|
16
16
|
}
|
|
17
17
|
export interface CompileOptions {
|
|
18
18
|
refreshSchemaCache?: boolean | number;
|
|
19
|
+
noThrowOnError?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare class Malloy {
|
|
21
22
|
static get version(): string;
|
|
@@ -56,13 +57,12 @@ export declare class Malloy {
|
|
|
56
57
|
* @param model A compiled model to build upon (optional).
|
|
57
58
|
* @return A (promise of a) compiled `Model`.
|
|
58
59
|
*/
|
|
59
|
-
static compile({ urlReader, connections, parse, model, refreshSchemaCache, }: {
|
|
60
|
+
static compile({ urlReader, connections, parse, model, refreshSchemaCache, noThrowOnError, }: {
|
|
60
61
|
urlReader: URLReader;
|
|
61
62
|
connections: LookupConnection<InfoConnection>;
|
|
62
63
|
parse: Parse;
|
|
63
64
|
model?: Model;
|
|
64
|
-
|
|
65
|
-
}): Promise<Model>;
|
|
65
|
+
} & CompileOptions): Promise<Model>;
|
|
66
66
|
private static compileSQLBlock;
|
|
67
67
|
/**
|
|
68
68
|
* Run a fully-prepared query.
|
|
@@ -158,9 +158,10 @@ export declare class Model implements Taggable {
|
|
|
158
158
|
private queryList;
|
|
159
159
|
private sqlBlocks;
|
|
160
160
|
readonly problems: LogMessage[];
|
|
161
|
+
readonly fromSources: string[];
|
|
161
162
|
_referenceAt: (location: ModelDocumentPosition) => DocumentReference | undefined;
|
|
162
163
|
_importAt: (location: ModelDocumentPosition) => ImportLocation | undefined;
|
|
163
|
-
constructor(modelDef: ModelDef, queryList: InternalQuery[], sqlBlocks: SQLBlockStructDef[], problems: LogMessage[], referenceAt?: (location: ModelDocumentPosition) => DocumentReference | undefined, importAt?: (location: ModelDocumentPosition) => ImportLocation | undefined);
|
|
164
|
+
constructor(modelDef: ModelDef, queryList: InternalQuery[], sqlBlocks: SQLBlockStructDef[], problems: LogMessage[], fromSources: string[], referenceAt?: (location: ModelDocumentPosition) => DocumentReference | undefined, importAt?: (location: ModelDocumentPosition) => ImportLocation | undefined);
|
|
164
165
|
tagParse(spec?: TagParseSpec): TagParse;
|
|
165
166
|
getTaglines(prefix?: RegExp): string[];
|
|
166
167
|
/**
|
package/dist/malloy.js
CHANGED
|
@@ -77,7 +77,8 @@ class Malloy {
|
|
|
77
77
|
* @param model A compiled model to build upon (optional).
|
|
78
78
|
* @return A (promise of a) compiled `Model`.
|
|
79
79
|
*/
|
|
80
|
-
static async compile({ urlReader, connections, parse, model, refreshSchemaCache, }) {
|
|
80
|
+
static async compile({ urlReader, connections, parse, model, refreshSchemaCache, noThrowOnError, }) {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
81
82
|
let refreshTimestamp;
|
|
82
83
|
if (refreshSchemaCache) {
|
|
83
84
|
refreshTimestamp =
|
|
@@ -91,7 +92,16 @@ class Malloy {
|
|
|
91
92
|
const result = translator.translate(model === null || model === void 0 ? void 0 : model._modelDef);
|
|
92
93
|
if (result.final) {
|
|
93
94
|
if (result.translated) {
|
|
94
|
-
return new Model(result.translated.modelDef, result.translated.queryList, result.translated.sqlBlocks, result.problems || [], (position) => translator.referenceAt(position), (position) => translator.importAt(position));
|
|
95
|
+
return new Model(result.translated.modelDef, result.translated.queryList, result.translated.sqlBlocks, result.problems || [], [...((_a = model === null || model === void 0 ? void 0 : model.fromSources) !== null && _a !== void 0 ? _a : []), ...((_b = result.fromSources) !== null && _b !== void 0 ? _b : [])], (position) => translator.referenceAt(position), (position) => translator.importAt(position));
|
|
96
|
+
}
|
|
97
|
+
else if (noThrowOnError) {
|
|
98
|
+
const emptyModel = {
|
|
99
|
+
name: 'modelDidNotCompile',
|
|
100
|
+
exports: [],
|
|
101
|
+
contents: {},
|
|
102
|
+
};
|
|
103
|
+
const modelFromCompile = (model === null || model === void 0 ? void 0 : model._modelDef) || emptyModel;
|
|
104
|
+
return new Model(modelFromCompile, [], [], result.problems || [], [...((_c = model === null || model === void 0 ? void 0 : model.fromSources) !== null && _c !== void 0 ? _c : []), ...((_d = result.fromSources) !== null && _d !== void 0 ? _d : [])], (position) => translator.referenceAt(position), (position) => translator.importAt(position));
|
|
95
105
|
}
|
|
96
106
|
else {
|
|
97
107
|
const errors = result.problems || [];
|
|
@@ -333,11 +343,12 @@ exports.MalloyError = MalloyError;
|
|
|
333
343
|
* A compiled Malloy document.
|
|
334
344
|
*/
|
|
335
345
|
class Model {
|
|
336
|
-
constructor(modelDef, queryList, sqlBlocks, problems, referenceAt = () => undefined, importAt = () => undefined) {
|
|
346
|
+
constructor(modelDef, queryList, sqlBlocks, problems, fromSources, referenceAt = () => undefined, importAt = () => undefined) {
|
|
337
347
|
this.modelDef = modelDef;
|
|
338
348
|
this.queryList = queryList;
|
|
339
349
|
this.sqlBlocks = sqlBlocks;
|
|
340
350
|
this.problems = problems;
|
|
351
|
+
this.fromSources = fromSources;
|
|
341
352
|
this._referenceAt = referenceAt;
|
|
342
353
|
this._importAt = importAt;
|
|
343
354
|
}
|
|
@@ -967,7 +978,7 @@ class Explore extends Entity {
|
|
|
967
978
|
};
|
|
968
979
|
}
|
|
969
980
|
getSingleExploreModel() {
|
|
970
|
-
return new Model(this.modelDef, [], [], []);
|
|
981
|
+
return new Model(this.modelDef, [], [], [], []);
|
|
971
982
|
}
|
|
972
983
|
get fieldMap() {
|
|
973
984
|
var _a;
|
|
@@ -1519,6 +1530,7 @@ class Runtime {
|
|
|
1519
1530
|
* or loading further related objects.
|
|
1520
1531
|
*/
|
|
1521
1532
|
loadModel(source, options) {
|
|
1533
|
+
const { refreshSchemaCache, noThrowOnError } = options || {};
|
|
1522
1534
|
return new ModelMaterializer(this, async () => {
|
|
1523
1535
|
const parse = source instanceof URL
|
|
1524
1536
|
? await Malloy.parse({
|
|
@@ -1534,7 +1546,8 @@ class Runtime {
|
|
|
1534
1546
|
urlReader: this.urlReader,
|
|
1535
1547
|
connections: this.connections,
|
|
1536
1548
|
parse,
|
|
1537
|
-
refreshSchemaCache
|
|
1549
|
+
refreshSchemaCache,
|
|
1550
|
+
noThrowOnError,
|
|
1538
1551
|
});
|
|
1539
1552
|
});
|
|
1540
1553
|
}
|
|
@@ -1544,7 +1557,7 @@ class Runtime {
|
|
|
1544
1557
|
// be used in tests.
|
|
1545
1558
|
_loadModelFromModelDef(modelDef) {
|
|
1546
1559
|
return new ModelMaterializer(this, async () => {
|
|
1547
|
-
return new Model(modelDef, [], [], []);
|
|
1560
|
+
return new Model(modelDef, [], [], [], []);
|
|
1548
1561
|
});
|
|
1549
1562
|
}
|
|
1550
1563
|
/**
|
|
@@ -1780,6 +1793,7 @@ class ModelMaterializer extends FluentState {
|
|
|
1780
1793
|
* or loading further related objects.
|
|
1781
1794
|
*/
|
|
1782
1795
|
loadQuery(query, options) {
|
|
1796
|
+
const { refreshSchemaCache, noThrowOnError } = options || {};
|
|
1783
1797
|
return this.makeQueryMaterializer(async () => {
|
|
1784
1798
|
const urlReader = this.runtime.urlReader;
|
|
1785
1799
|
const connections = this.runtime.connections;
|
|
@@ -1799,7 +1813,8 @@ class ModelMaterializer extends FluentState {
|
|
|
1799
1813
|
connections,
|
|
1800
1814
|
parse,
|
|
1801
1815
|
model,
|
|
1802
|
-
refreshSchemaCache
|
|
1816
|
+
refreshSchemaCache,
|
|
1817
|
+
noThrowOnError,
|
|
1803
1818
|
});
|
|
1804
1819
|
return queryModel.preparedQuery;
|
|
1805
1820
|
});
|