@malloydata/malloy 0.0.269-dev250423193223 → 0.0.269
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.
|
@@ -445,6 +445,8 @@ class TranslateStep {
|
|
|
445
445
|
modelDef: {
|
|
446
446
|
...that.modelDef,
|
|
447
447
|
dependencies: that.getDependencyTree(),
|
|
448
|
+
references: that.references.toArray(),
|
|
449
|
+
imports: [...that.imports],
|
|
448
450
|
},
|
|
449
451
|
fromSources: that.getDependencies(),
|
|
450
452
|
...that.problemResponse(),
|
|
@@ -548,7 +550,12 @@ class MalloyTranslation {
|
|
|
548
550
|
}
|
|
549
551
|
const result = child.translate();
|
|
550
552
|
if (result.modelDef) {
|
|
551
|
-
|
|
553
|
+
const modelDef = {
|
|
554
|
+
...result.modelDef,
|
|
555
|
+
references: child.references.toArray(),
|
|
556
|
+
imports: [...child.imports],
|
|
557
|
+
};
|
|
558
|
+
newModels.push({ url, modelDef });
|
|
552
559
|
newModels.push(...child.newlyTranslatedDependencies());
|
|
553
560
|
}
|
|
554
561
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { DocumentPosition, DocumentReference } from '../model';
|
|
2
2
|
export declare class ReferenceList {
|
|
3
3
|
private readonly sourceURL;
|
|
4
|
-
constructor(sourceURL: string);
|
|
5
4
|
private readonly references;
|
|
5
|
+
constructor(sourceURL: string, references?: DocumentReference[]);
|
|
6
6
|
private findIndexBefore;
|
|
7
7
|
add(reference: DocumentReference): void;
|
|
8
8
|
private isPositionEqual;
|
|
9
9
|
find(position: DocumentPosition): DocumentReference | undefined;
|
|
10
|
+
toArray(): DocumentReference[];
|
|
10
11
|
}
|
|
@@ -25,10 +25,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.ReferenceList = void 0;
|
|
26
26
|
const utils_1 = require("./utils");
|
|
27
27
|
class ReferenceList {
|
|
28
|
-
constructor(sourceURL
|
|
28
|
+
constructor(sourceURL,
|
|
29
|
+
// These should always be sorted by their end positions
|
|
30
|
+
references = []) {
|
|
29
31
|
this.sourceURL = sourceURL;
|
|
30
|
-
|
|
31
|
-
this.references = [];
|
|
32
|
+
this.references = references;
|
|
32
33
|
}
|
|
33
34
|
findIndexBefore(position) {
|
|
34
35
|
let low = 0;
|
|
@@ -81,6 +82,9 @@ class ReferenceList {
|
|
|
81
82
|
}
|
|
82
83
|
return undefined;
|
|
83
84
|
}
|
|
85
|
+
toArray() {
|
|
86
|
+
return [...this.references];
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
exports.ReferenceList = ReferenceList;
|
|
86
90
|
//# sourceMappingURL=reference-list.js.map
|
package/dist/malloy.d.ts
CHANGED
|
@@ -186,9 +186,8 @@ export declare class Model implements Taggable {
|
|
|
186
186
|
private modelDef;
|
|
187
187
|
readonly problems: LogMessage[];
|
|
188
188
|
readonly fromSources: string[];
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
constructor(modelDef: ModelDef, problems: LogMessage[], fromSources: string[], referenceAt?: (location: ModelDocumentPosition) => DocumentReference | undefined, importAt?: (location: ModelDocumentPosition) => ImportLocation | undefined);
|
|
189
|
+
private readonly references;
|
|
190
|
+
constructor(modelDef: ModelDef, problems: LogMessage[], fromSources: string[]);
|
|
192
191
|
tagParse(spec?: TagParseSpec): MalloyTagParse;
|
|
193
192
|
getTaglines(prefix?: RegExp): string[];
|
|
194
193
|
/**
|
package/dist/malloy.js
CHANGED
|
@@ -31,6 +31,8 @@ const version_1 = require("./version");
|
|
|
31
31
|
const uuid_1 = require("uuid");
|
|
32
32
|
const annotation_1 = require("./annotation");
|
|
33
33
|
const sql_block_1 = require("./model/sql_block");
|
|
34
|
+
const utils_1 = require("./lang/utils");
|
|
35
|
+
const reference_list_1 = require("./lang/reference-list");
|
|
34
36
|
const MALLOY_INTERNAL_URL = 'internal://internal.malloy';
|
|
35
37
|
class Malloy {
|
|
36
38
|
static get version() {
|
|
@@ -104,9 +106,7 @@ class Malloy {
|
|
|
104
106
|
const cached = await cacheManager.getCachedModelDef(urlReader, url.toString());
|
|
105
107
|
if (cached) {
|
|
106
108
|
return new Model(cached.modelDef, [], // TODO when using a model from cache, should we also store the problems??
|
|
107
|
-
[url.toString(), ...flatDeps(cached.modelDef.dependencies)]
|
|
108
|
-
// TODO maybe implement referenceAt and importAt by re-translating the model?
|
|
109
|
-
);
|
|
109
|
+
[url.toString(), ...flatDeps(cached.modelDef.dependencies)]);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
importBaseURL !== null && importBaseURL !== void 0 ? importBaseURL : (importBaseURL = url);
|
|
@@ -146,7 +146,10 @@ class Malloy {
|
|
|
146
146
|
invalidationKeys,
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
|
-
return new Model(result.modelDef, result.problems || [], [
|
|
149
|
+
return new Model(result.modelDef, result.problems || [], [
|
|
150
|
+
...((_b = model === null || model === void 0 ? void 0 : model.fromSources) !== null && _b !== void 0 ? _b : []),
|
|
151
|
+
...((_c = result.fromSources) !== null && _c !== void 0 ? _c : []),
|
|
152
|
+
]);
|
|
150
153
|
}
|
|
151
154
|
else if (noThrowOnError) {
|
|
152
155
|
const emptyModel = {
|
|
@@ -157,7 +160,10 @@ class Malloy {
|
|
|
157
160
|
queryList: [],
|
|
158
161
|
};
|
|
159
162
|
const modelFromCompile = (model === null || model === void 0 ? void 0 : model._modelDef) || emptyModel;
|
|
160
|
-
return new Model(modelFromCompile, result.problems || [], [
|
|
163
|
+
return new Model(modelFromCompile, result.problems || [], [
|
|
164
|
+
...((_d = model === null || model === void 0 ? void 0 : model.fromSources) !== null && _d !== void 0 ? _d : []),
|
|
165
|
+
...((_e = result.fromSources) !== null && _e !== void 0 ? _e : []),
|
|
166
|
+
]);
|
|
161
167
|
}
|
|
162
168
|
else {
|
|
163
169
|
const errors = result.problems || [];
|
|
@@ -404,12 +410,12 @@ exports.MalloyError = MalloyError;
|
|
|
404
410
|
* A compiled Malloy document.
|
|
405
411
|
*/
|
|
406
412
|
class Model {
|
|
407
|
-
constructor(modelDef, problems, fromSources
|
|
413
|
+
constructor(modelDef, problems, fromSources) {
|
|
414
|
+
var _a, _b;
|
|
408
415
|
this.modelDef = modelDef;
|
|
409
416
|
this.problems = problems;
|
|
410
417
|
this.fromSources = fromSources;
|
|
411
|
-
this.
|
|
412
|
-
this._importAt = importAt;
|
|
418
|
+
this.references = new reference_list_1.ReferenceList((_a = fromSources[0]) !== null && _a !== void 0 ? _a : '', (_b = modelDef.references) !== null && _b !== void 0 ? _b : []);
|
|
413
419
|
}
|
|
414
420
|
tagParse(spec) {
|
|
415
421
|
return (0, annotation_1.annotationToTag)(this.modelDef.annotation, spec);
|
|
@@ -425,7 +431,7 @@ class Model {
|
|
|
425
431
|
* @return A `DocumentReference` at that position if one exists.
|
|
426
432
|
*/
|
|
427
433
|
getReference(position) {
|
|
428
|
-
return this.
|
|
434
|
+
return this.references.find(position);
|
|
429
435
|
}
|
|
430
436
|
/**
|
|
431
437
|
* Retrieve an import for the token at the given position within
|
|
@@ -435,7 +441,8 @@ class Model {
|
|
|
435
441
|
* @return An `ImportLocation` at that position if one exists.
|
|
436
442
|
*/
|
|
437
443
|
getImport(position) {
|
|
438
|
-
|
|
444
|
+
var _a;
|
|
445
|
+
return (_a = this.modelDef.imports) === null || _a === void 0 ? void 0 : _a.find(i => (0, utils_1.locationContainsPosition)(i.location, position));
|
|
439
446
|
}
|
|
440
447
|
/**
|
|
441
448
|
* Retrieve a prepared query by the name of a query at the top level of the model.
|
|
@@ -780,6 +780,8 @@ export interface ModelDef {
|
|
|
780
780
|
annotation?: ModelAnnotation;
|
|
781
781
|
queryList: Query[];
|
|
782
782
|
dependencies: DependencyTree;
|
|
783
|
+
references?: DocumentReference[];
|
|
784
|
+
imports?: ImportLocation[];
|
|
783
785
|
}
|
|
784
786
|
/** Very common record type */
|
|
785
787
|
export type NamedSourceDefs = Record<string, SourceDef>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.269
|
|
3
|
+
"version": "0.0.269",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@malloydata/malloy-filter": "^0.0.269
|
|
45
|
-
"@malloydata/malloy-interfaces": "^0.0.269
|
|
46
|
-
"@malloydata/malloy-tag": "^0.0.269
|
|
44
|
+
"@malloydata/malloy-filter": "^0.0.269",
|
|
45
|
+
"@malloydata/malloy-interfaces": "^0.0.269",
|
|
46
|
+
"@malloydata/malloy-tag": "^0.0.269",
|
|
47
47
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
48
48
|
"assert": "^2.0.0",
|
|
49
49
|
"jaro-winkler": "^0.2.8",
|