@malloydata/malloy 0.0.395 → 0.0.397
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/annotation.d.ts +85 -1
- package/dist/annotation.js +133 -47
- package/dist/api/core.js +2 -7
- package/dist/api/foundation/compile.d.ts +7 -6
- package/dist/api/foundation/compile.js +22 -6
- package/dist/api/foundation/core.d.ts +10 -0
- package/dist/api/foundation/core.js +32 -9
- package/dist/api/foundation/runtime.d.ts +85 -5
- package/dist/api/foundation/runtime.js +184 -14
- package/dist/api/foundation/types.d.ts +2 -0
- package/dist/lang/ast/expressions/expr-func.js +30 -11
- package/dist/lang/ast/expressions/expr-given.js +1 -0
- package/dist/lang/ast/field-space/reference-field.js +1 -1
- package/dist/lang/ast/source-elements/sql-source.js +4 -0
- package/dist/lang/ast/source-elements/table-source.js +4 -0
- package/dist/lang/ast/statements/define-given.d.ts +1 -0
- package/dist/lang/ast/statements/define-given.js +7 -0
- package/dist/lang/ast/statements/import-statement.js +4 -0
- package/dist/lang/ast/types/annotation-elements.d.ts +1 -0
- package/dist/lang/ast/types/annotation-elements.js +10 -3
- package/dist/lang/ast/types/malloy-element.d.ts +1 -0
- package/dist/lang/ast/types/malloy-element.js +4 -0
- package/dist/lang/composite-source-utils.js +1 -1
- package/dist/lang/malloy-to-ast.d.ts +9 -1
- package/dist/lang/malloy-to-ast.js +37 -11
- package/dist/lang/malloy-to-stable-query.js +3 -3
- package/dist/lang/parse-log.d.ts +7 -1
- package/dist/lang/parse-log.js +12 -0
- package/dist/lang/parse-malloy.d.ts +4 -1
- package/dist/lang/parse-malloy.js +26 -4
- package/dist/lang/parse-tree-walkers/model-annotation-walker.js +3 -11
- package/dist/lang/parse-utils.d.ts +10 -2
- package/dist/lang/parse-utils.js +89 -29
- package/dist/lang/test/test-translator.d.ts +19 -5
- package/dist/lang/test/test-translator.js +15 -12
- package/dist/lang/zone.d.ts +2 -0
- package/dist/lang/zone.js +10 -0
- package/dist/model/constant_expression_compiler.js +14 -5
- package/dist/model/expression_compiler.js +19 -17
- package/dist/model/field_instance.js +7 -3
- package/dist/model/given_binding.js +26 -21
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +3 -1
- package/dist/model/malloy_compile_error.d.ts +13 -0
- package/dist/model/malloy_compile_error.js +23 -0
- package/dist/model/malloy_types.d.ts +9 -0
- package/dist/model/persist_utils.js +1 -1
- package/dist/model/query_model_impl.js +2 -1
- package/dist/model/query_node.d.ts +5 -5
- package/dist/model/query_node.js +22 -17
- package/dist/model/query_query.js +23 -11
- package/dist/model/sql_compiled.js +6 -3
- package/dist/prefix.d.ts +51 -0
- package/dist/prefix.js +99 -0
- package/dist/taggable.d.ts +17 -1
- package/dist/test/resultMatchers.js +2 -1
- package/dist/to_stable.d.ts +7 -1
- package/dist/to_stable.js +13 -16
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -13,6 +13,7 @@ const stage_writer_1 = require("./stage_writer");
|
|
|
13
13
|
const field_instance_1 = require("./field_instance");
|
|
14
14
|
const sql_compiled_1 = require("./sql_compiled");
|
|
15
15
|
const source_def_utils_1 = require("./source_def_utils");
|
|
16
|
+
const malloy_compile_error_1 = require("./malloy_compile_error");
|
|
16
17
|
function pathToCol(path) {
|
|
17
18
|
return path.map(el => encodeURIComponent(el)).join('/');
|
|
18
19
|
}
|
|
@@ -142,7 +143,8 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
142
143
|
for (const pathSegment of ungrouping.path) {
|
|
143
144
|
const nextStruct = destResult.allFields.get(pathSegment);
|
|
144
145
|
if (!(nextStruct instanceof field_instance_1.FieldInstanceResult)) {
|
|
145
|
-
throw new
|
|
146
|
+
throw new malloy_compile_error_1.MalloyCompileError(`Ungrouping path '${ungrouping.path.join('.')}' references ` +
|
|
147
|
+
`'${pathSegment}', which is not a nested view at this level.`, 'compiler-ungrouped-invalid-path', this.fieldDef.location);
|
|
146
148
|
}
|
|
147
149
|
destResult = nextStruct;
|
|
148
150
|
}
|
|
@@ -192,7 +194,9 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
192
194
|
const drillExpression = this.getDrillExpression(f);
|
|
193
195
|
if (field instanceof QueryQuery) {
|
|
194
196
|
if (this.firstSegment.type === 'project') {
|
|
195
|
-
throw new
|
|
197
|
+
throw new malloy_compile_error_1.MalloyCompileError(`Cannot include nested view '${field.fieldDef.name}' in a ` +
|
|
198
|
+
"'select:' stage. Nested views require `group_by:` or " +
|
|
199
|
+
'`aggregate:` to be included in output.', 'compiler-nested-view-in-select', field.fieldDef.location);
|
|
196
200
|
}
|
|
197
201
|
const fir = new field_instance_1.FieldInstanceResult(field.fieldDef, resultStruct);
|
|
198
202
|
this.expandFields(fir);
|
|
@@ -212,7 +216,8 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
212
216
|
}
|
|
213
217
|
if ((0, query_node_1.isBasicAggregate)(field)) {
|
|
214
218
|
if (this.firstSegment.type === 'project') {
|
|
215
|
-
throw new
|
|
219
|
+
throw new malloy_compile_error_1.MalloyCompileError(`Cannot include aggregate field '${field.fieldDef.name}' in ` +
|
|
220
|
+
"a 'select:' stage. Use `aggregate:` instead to compute aggregates.", 'compiler-aggregate-in-select', field.fieldDef.location);
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
}
|
|
@@ -523,7 +528,9 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
523
528
|
const virtualMap = (_a = qs.prepareResultOptions) === null || _a === void 0 ? void 0 : _a.virtualMap;
|
|
524
529
|
const tablePath = (_b = virtualMap === null || virtualMap === void 0 ? void 0 : virtualMap.get(qs.structDef.connection)) === null || _b === void 0 ? void 0 : _b.get(qs.structDef.name);
|
|
525
530
|
if (!tablePath) {
|
|
526
|
-
throw new
|
|
531
|
+
throw new malloy_compile_error_1.MalloyCompileError(`No virtual-map entry for virtual source '${qs.structDef.name}' ` +
|
|
532
|
+
`on connection '${qs.structDef.connection}'. ` +
|
|
533
|
+
'Add a virtual-map entry via the `virtualMap` runtime option.', 'runtime-virtual-map-missing', qs.structDef.location);
|
|
527
534
|
}
|
|
528
535
|
// virtualMap entries are application-supplied — assumed already
|
|
529
536
|
// canonical SQL.
|
|
@@ -559,10 +566,12 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
559
566
|
return entry.tableName;
|
|
560
567
|
}
|
|
561
568
|
if (buildManifest.strict) {
|
|
562
|
-
const base = `Persist source '${qs.structDef.sourceID}' not found
|
|
563
|
-
|
|
569
|
+
const base = `Persist source '${qs.structDef.sourceID}' not found ` +
|
|
570
|
+
`in manifest (buildId: ${buildId}); strict manifest mode ` +
|
|
571
|
+
'forbids fallback to live compilation.';
|
|
572
|
+
throw new malloy_compile_error_1.MalloyCompileError(buildManifest.loadError
|
|
564
573
|
? `${base}\n ${buildManifest.loadError}`
|
|
565
|
-
: base);
|
|
574
|
+
: base, 'runtime-manifest-strict-miss', qs.structDef.location);
|
|
566
575
|
}
|
|
567
576
|
}
|
|
568
577
|
}
|
|
@@ -598,7 +607,8 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
598
607
|
if (typeof structRef === 'string') {
|
|
599
608
|
const struct = this.structRefToQueryStruct(structRef);
|
|
600
609
|
if (!struct) {
|
|
601
|
-
throw new
|
|
610
|
+
throw new malloy_compile_error_1.MalloyCompileError(`Query references source '${structRef}', ` +
|
|
611
|
+
'which is not defined in this model.', 'compiler-undefined-source', undefined);
|
|
602
612
|
}
|
|
603
613
|
sourceStruct = struct;
|
|
604
614
|
}
|
|
@@ -858,7 +868,7 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
858
868
|
}
|
|
859
869
|
}
|
|
860
870
|
else {
|
|
861
|
-
throw new
|
|
871
|
+
throw new malloy_compile_error_1.MalloyCompileError(`ORDER BY references unknown field '${f.field}'.`, 'compiler-orderby-field-not-found', queryDef.referencedAt);
|
|
862
872
|
}
|
|
863
873
|
}
|
|
864
874
|
else {
|
|
@@ -1210,7 +1220,9 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
1210
1220
|
this.generateStage0Fields(this.rootResult, f, stageWriter);
|
|
1211
1221
|
if (this.firstSegment.type === 'project' &&
|
|
1212
1222
|
!this.parent.modelCompilerFlags().has('unsafe_complex_select_query')) {
|
|
1213
|
-
throw new
|
|
1223
|
+
throw new malloy_compile_error_1.MalloyCompileError("Cannot use 'select:' in a stage that contains nested views. " +
|
|
1224
|
+
'Use `group_by:` or restructure the pipeline. ' +
|
|
1225
|
+
'Set `##! unsafe_complex_select_query` to bypass at your own risk.', 'compiler-project-with-turtles', this.fieldDef.location);
|
|
1214
1226
|
}
|
|
1215
1227
|
const groupBy = 'GROUP BY ' + f.dimensionIndexes.join(',') + '\n';
|
|
1216
1228
|
from += this.parent.dialect.sqlGroupSetTable(this.maxGroupSet) + '\n';
|
|
@@ -1611,7 +1623,7 @@ class QueryQueryIndexStage extends QueryQuery {
|
|
|
1611
1623
|
}
|
|
1612
1624
|
expandField(f) {
|
|
1613
1625
|
const as = f.path.join('.');
|
|
1614
|
-
const field = this.parent.getQueryFieldByName(f.path);
|
|
1626
|
+
const field = this.parent.getQueryFieldByName(f.path, f.at);
|
|
1615
1627
|
return { as, field };
|
|
1616
1628
|
}
|
|
1617
1629
|
expandFields(resultStruct) {
|
|
@@ -8,6 +8,7 @@ exports.getCompiledSQL = getCompiledSQL;
|
|
|
8
8
|
exports.getSourceSQL = getSourceSQL;
|
|
9
9
|
const malloy_types_1 = require("./malloy_types");
|
|
10
10
|
const source_def_utils_1 = require("./source_def_utils");
|
|
11
|
+
const malloy_compile_error_1 = require("./malloy_compile_error");
|
|
11
12
|
/**
|
|
12
13
|
* Compile a SQLSourceDef to its final SQL string.
|
|
13
14
|
*
|
|
@@ -66,10 +67,12 @@ function expandPersistableSource(source, opts, compileQuery) {
|
|
|
66
67
|
}
|
|
67
68
|
// Not in manifest
|
|
68
69
|
if (buildManifest.strict) {
|
|
69
|
-
const base = `Persist source '${source.sourceID}' not found in manifest
|
|
70
|
-
|
|
70
|
+
const base = `Persist source '${source.sourceID}' not found in manifest ` +
|
|
71
|
+
`(buildId: ${buildId}); strict manifest mode forbids fallback ` +
|
|
72
|
+
'to live compilation.';
|
|
73
|
+
throw new malloy_compile_error_1.MalloyCompileError(buildManifest.loadError
|
|
71
74
|
? `${base}\n ${buildManifest.loadError}`
|
|
72
|
-
: base);
|
|
75
|
+
: base, 'runtime-manifest-strict-miss', source.location);
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
}
|
package/dist/prefix.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result of parsing an annotation's leading prefix.
|
|
3
|
+
*
|
|
4
|
+
* An annotation is `prefix sep content`. `parsePrefix` splits the captured
|
|
5
|
+
* annotation text at the first whitespace, strips the sigil (`#`/`##` plus an
|
|
6
|
+
* optional block `|`), and classifies the routing into one of three forms.
|
|
7
|
+
* `route` is one field; `contentIndex` and `malformation` are equally why this
|
|
8
|
+
* routine exists.
|
|
9
|
+
*/
|
|
10
|
+
export interface ParsedPrefix {
|
|
11
|
+
/** The route the prefix resolves to. `''` is the MOTLY (empty) route. */
|
|
12
|
+
route: string;
|
|
13
|
+
/**
|
|
14
|
+
* Offset into the annotation text where the content begins;
|
|
15
|
+
* `text.slice(contentIndex)` is the content, with the single separator
|
|
16
|
+
* character excluded.
|
|
17
|
+
*/
|
|
18
|
+
contentIndex: number;
|
|
19
|
+
/**
|
|
20
|
+
* Set iff the prefix is not a well-formed route. The annotation is still
|
|
21
|
+
* stored and reachable via the all-routes API; this only drives a warning.
|
|
22
|
+
* - `malformed-route`: not one of the three forms — a bare word, an unclosed
|
|
23
|
+
* or mismatched bracket, an empty bracketed name, or trailing junk.
|
|
24
|
+
* - `reserved-route`: a punct-only (sigil) routing that Malloy has not
|
|
25
|
+
* claimed; the punct-only namespace is reserved for Malloy's own use.
|
|
26
|
+
*/
|
|
27
|
+
malformation?: 'malformed-route' | 'reserved-route';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse the leading prefix of a captured annotation.
|
|
31
|
+
*
|
|
32
|
+
* `text` is the entire annotation as the lexer captured it, marker included: a
|
|
33
|
+
* single line `#... content`, or a block `#|...\n<body>` whose body the lexer
|
|
34
|
+
* has already de-indented and whose closer it has removed. This routine never
|
|
35
|
+
* parses the content — it returns where the content begins.
|
|
36
|
+
*
|
|
37
|
+
* The prefix runs from the marker to the **first whitespace**; that boundary
|
|
38
|
+
* never moves (no bracket or quote changes it, so a route can never contain
|
|
39
|
+
* whitespace). After stripping the sigil (`^##?\|?`), the routing matches one
|
|
40
|
+
* of three forms:
|
|
41
|
+
*
|
|
42
|
+
* 1. empty -> route `''` (MOTLY, the human default)
|
|
43
|
+
* 2. PUNCT+ (no bracket) -> sigil route (reserved; unclaimed warns)
|
|
44
|
+
* 3. OPEN ... CLOSE -> route = bracketed text (opaque app route)
|
|
45
|
+
*
|
|
46
|
+
* Anything else is `malformed-route`. Bracket pairs are `()`, `<>`, `[]`, `{}`;
|
|
47
|
+
* the route is everything up to the matching close (first close wins, no
|
|
48
|
+
* nesting), taken literally — no character classification, so `#(bar-chart)`,
|
|
49
|
+
* `#(https://x/y)`, and `#(v1.2.3)` are all just their bracketed text.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parsePrefix(text: string): ParsedPrefix;
|
package/dist/prefix.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.parsePrefix = parsePrefix;
|
|
8
|
+
/**
|
|
9
|
+
* Punct-only (sigil) routes are reserved for Malloy's own use. This is the
|
|
10
|
+
* closed, enumerated set the compiler claims; any other punct-only routing
|
|
11
|
+
* warns `reserved-route`. The set being closed is what makes the warning
|
|
12
|
+
* possible — the compiler knows its own complete sigil vocabulary.
|
|
13
|
+
*/
|
|
14
|
+
const CLAIMED_SIGILS = new Set(['!', '@', '"', ':']);
|
|
15
|
+
/** Bracket pairs an app route may use, as [open, close] — the single source. */
|
|
16
|
+
const BRACKET_PAIRS = [
|
|
17
|
+
['(', ')'],
|
|
18
|
+
['<', '>'],
|
|
19
|
+
['[', ']'],
|
|
20
|
+
['{', '}'],
|
|
21
|
+
];
|
|
22
|
+
/** Two views of BRACKET_PAIRS: open->close for lookup, all halves for membership. */
|
|
23
|
+
const OPEN_TO_CLOSE = new Map(BRACKET_PAIRS);
|
|
24
|
+
const BRACKETS = new Set(BRACKET_PAIRS.flat());
|
|
25
|
+
/** Letter, number, or underscore — the "word" characters. */
|
|
26
|
+
const WORDISH = /[\p{L}\p{N}_]/u;
|
|
27
|
+
/**
|
|
28
|
+
* Parse the leading prefix of a captured annotation.
|
|
29
|
+
*
|
|
30
|
+
* `text` is the entire annotation as the lexer captured it, marker included: a
|
|
31
|
+
* single line `#... content`, or a block `#|...\n<body>` whose body the lexer
|
|
32
|
+
* has already de-indented and whose closer it has removed. This routine never
|
|
33
|
+
* parses the content — it returns where the content begins.
|
|
34
|
+
*
|
|
35
|
+
* The prefix runs from the marker to the **first whitespace**; that boundary
|
|
36
|
+
* never moves (no bracket or quote changes it, so a route can never contain
|
|
37
|
+
* whitespace). After stripping the sigil (`^##?\|?`), the routing matches one
|
|
38
|
+
* of three forms:
|
|
39
|
+
*
|
|
40
|
+
* 1. empty -> route `''` (MOTLY, the human default)
|
|
41
|
+
* 2. PUNCT+ (no bracket) -> sigil route (reserved; unclaimed warns)
|
|
42
|
+
* 3. OPEN ... CLOSE -> route = bracketed text (opaque app route)
|
|
43
|
+
*
|
|
44
|
+
* Anything else is `malformed-route`. Bracket pairs are `()`, `<>`, `[]`, `{}`;
|
|
45
|
+
* the route is everything up to the matching close (first close wins, no
|
|
46
|
+
* nesting), taken literally — no character classification, so `#(bar-chart)`,
|
|
47
|
+
* `#(https://x/y)`, and `#(v1.2.3)` are all just their bracketed text.
|
|
48
|
+
*/
|
|
49
|
+
function parsePrefix(text) {
|
|
50
|
+
// 1. Split prefix from content at the first whitespace. The single separator
|
|
51
|
+
// character is excluded from the content.
|
|
52
|
+
// `\r` is in the class because Windows line endings put a `\r` right before
|
|
53
|
+
// the `\n` at every line end (the lexer keeps `\r` out of line *content*),
|
|
54
|
+
// so on a content-less prefix like `#(docs)\r\n` the `\r` must not be pulled
|
|
55
|
+
// into the routing. We split on it rather than mutating the text, so source
|
|
56
|
+
// offsets stay intact for error mapping; any line-ending bytes remain in the
|
|
57
|
+
// content, which is faithful to source and harmless to payload parsers.
|
|
58
|
+
const boundary = text.search(/[ \t\r\n]/);
|
|
59
|
+
const prefix = boundary === -1 ? text : text.slice(0, boundary);
|
|
60
|
+
const contentIndex = boundary === -1 ? text.length : boundary + 1;
|
|
61
|
+
// 2. Strip the sigil: one or two '#', then an optional block '|'.
|
|
62
|
+
const sigil = /^(#{1,2})(\|?)/.exec(prefix);
|
|
63
|
+
if (!sigil) {
|
|
64
|
+
// A captured annotation always starts with '#'; if it somehow does not,
|
|
65
|
+
// there is no route to speak of — likely a compiler bug upstream.
|
|
66
|
+
return { route: prefix, contentIndex, malformation: 'malformed-route' };
|
|
67
|
+
}
|
|
68
|
+
const routing = prefix.slice(sigil[0].length);
|
|
69
|
+
// Form 1: empty routing -> the MOTLY namespace.
|
|
70
|
+
if (routing === '') {
|
|
71
|
+
return { route: '', contentIndex };
|
|
72
|
+
}
|
|
73
|
+
// Form 3: opens with a bracket -> route is the text up to the matching close.
|
|
74
|
+
// A non-undefined close both proves routing[0] is an open bracket and gives
|
|
75
|
+
// us its partner in one lookup.
|
|
76
|
+
const close = OPEN_TO_CLOSE.get(routing[0]);
|
|
77
|
+
if (close !== undefined) {
|
|
78
|
+
const closeIdx = routing.indexOf(close, 1);
|
|
79
|
+
const malformed = closeIdx === -1 || // unclosed
|
|
80
|
+
closeIdx !== routing.length - 1 || // trailing junk after the close
|
|
81
|
+
closeIdx === 1; // empty bracketed text: `#()`
|
|
82
|
+
if (malformed) {
|
|
83
|
+
return { route: routing, contentIndex, malformation: 'malformed-route' };
|
|
84
|
+
}
|
|
85
|
+
return { route: routing.slice(1, closeIdx), contentIndex };
|
|
86
|
+
}
|
|
87
|
+
// Form 2: pure punctuation (no word chars, no brackets) -> sigil route.
|
|
88
|
+
const isPurePunct = [...routing].every(c => !WORDISH.test(c) && !BRACKETS.has(c));
|
|
89
|
+
if (isPurePunct) {
|
|
90
|
+
return {
|
|
91
|
+
route: routing,
|
|
92
|
+
contentIndex,
|
|
93
|
+
malformation: CLAIMED_SIGILS.has(routing) ? undefined : 'reserved-route',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Otherwise: a bare word, or mixed text with no brackets.
|
|
97
|
+
return { route: routing, contentIndex, malformation: 'malformed-route' };
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=prefix.js.map
|
package/dist/taggable.d.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import type { TagParseSpec, MalloyTagParse } from './annotation';
|
|
1
|
+
import type { TagParseSpec, MalloyTagParse, Annotations } from './annotation';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for objects that have Malloy tag annotations.
|
|
4
4
|
* This is part of the runtime API - objects returned from the Malloy
|
|
5
5
|
* runtime implement this interface to expose their tag metadata.
|
|
6
6
|
*/
|
|
7
7
|
export interface Taggable {
|
|
8
|
+
/**
|
|
9
|
+
* Route-aware annotation access — read annotations by *route*. See
|
|
10
|
+
* `Annotations` for what a route is and which ones are claimed. Unlike
|
|
11
|
+
* `tagParse`/`getTaglines`, this sees block annotations (`#|`…`|#`).
|
|
12
|
+
*/
|
|
13
|
+
readonly annotations: Annotations;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated The RegExp form cannot see block annotations (`#|`…`|#`) and
|
|
16
|
+
* cannot report content offsets for error mapping. Use
|
|
17
|
+
* `annotations.parseAsTag(route)` instead.
|
|
18
|
+
*/
|
|
8
19
|
tagParse: (spec?: TagParseSpec) => MalloyTagParse;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated The RegExp form cannot see block annotations. Use
|
|
22
|
+
* `annotations.texts(route)` (raw strings) or `annotations.forRoute(route)`
|
|
23
|
+
* (objects with offsets) instead.
|
|
24
|
+
*/
|
|
9
25
|
getTaglines: (prefix?: RegExp) => string[];
|
|
10
26
|
}
|
|
@@ -70,7 +70,8 @@ async function runQueryInternal(tm, src) {
|
|
|
70
70
|
let queryTestTag = undefined;
|
|
71
71
|
try {
|
|
72
72
|
query = tm.model.loadQuery(src);
|
|
73
|
-
const queryTags = (await query.getPreparedQuery()).
|
|
73
|
+
const queryTags = (await query.getPreparedQuery()).annotations.parseAsTag()
|
|
74
|
+
.tag;
|
|
74
75
|
queryTestTag = queryTags.tag('test');
|
|
75
76
|
}
|
|
76
77
|
catch (e) {
|
package/dist/to_stable.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
|
-
import type { FieldDef, ModelDef, ResultStructMetadataDef, SourceDef } from './model';
|
|
2
|
+
import type { Annotation, FieldDef, ModelDef, ResultStructMetadataDef, SourceDef } from './model';
|
|
3
3
|
import { Tag } from '@malloydata/malloy-tag';
|
|
4
4
|
export declare function sourceDefToSourceInfo(sourceDef: SourceDef): Malloy.SourceInfo;
|
|
5
5
|
export declare function modelDefToModelInfo(modelDef: ModelDef): Malloy.ModelInfo;
|
|
6
|
+
/**
|
|
7
|
+
* IR annotation → stable `Malloy.Annotation[]` shape used across `to_stable`
|
|
8
|
+
* and the api surfaces. The stable shape carries the raw annotation strings;
|
|
9
|
+
* routes are derivable at the consumer via `parsePrefix` (`./prefix.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export declare function toStableAnnotations(annot: Annotation | undefined): Malloy.Annotation[];
|
|
6
12
|
export declare function convertFieldInfos(source: SourceDef, fields: FieldDef[]): Malloy.FieldInfo[];
|
|
7
13
|
export declare function writeLiteralToTag(tag: Tag, path: (string | number)[], literal: Malloy.LiteralValue): void;
|
|
8
14
|
export declare function getResultStructMetadataAnnotation(field: SourceDef, resultMetadata: ResultStructMetadataDef): Malloy.Annotation | undefined;
|
package/dist/to_stable.js
CHANGED
|
@@ -41,6 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.sourceDefToSourceInfo = sourceDefToSourceInfo;
|
|
43
43
|
exports.modelDefToModelInfo = modelDefToModelInfo;
|
|
44
|
+
exports.toStableAnnotations = toStableAnnotations;
|
|
44
45
|
exports.convertFieldInfos = convertFieldInfos;
|
|
45
46
|
exports.writeLiteralToTag = writeLiteralToTag;
|
|
46
47
|
exports.getResultStructMetadataAnnotation = getResultStructMetadataAnnotation;
|
|
@@ -77,7 +78,7 @@ function sourceDefToSourceInfo(sourceDef) {
|
|
|
77
78
|
fields: convertFieldInfos(sourceDef, sourceDef.fields),
|
|
78
79
|
},
|
|
79
80
|
parameters,
|
|
80
|
-
annotations:
|
|
81
|
+
annotations: toStableAnnotations(sourceDef.annotation),
|
|
81
82
|
};
|
|
82
83
|
return sourceInfo;
|
|
83
84
|
}
|
|
@@ -98,7 +99,7 @@ function modelDefToModelInfo(modelDef) {
|
|
|
98
99
|
}
|
|
99
100
|
else if (entry.type === 'query') {
|
|
100
101
|
const outputStruct = (0, model_1.getResultStructDefForQuery)(modelDef, entry);
|
|
101
|
-
const annotations =
|
|
102
|
+
const annotations = toStableAnnotations(entry.annotation);
|
|
102
103
|
const resultMetadataAnnotation = outputStruct.resultMetadata
|
|
103
104
|
? getResultStructMetadataAnnotation(outputStruct, outputStruct.resultMetadata)
|
|
104
105
|
: undefined;
|
|
@@ -119,7 +120,7 @@ function modelDefToModelInfo(modelDef) {
|
|
|
119
120
|
}
|
|
120
121
|
for (const query of modelDef.queryList) {
|
|
121
122
|
const outputStruct = (0, model_1.getResultStructDefForQuery)(modelDef, query);
|
|
122
|
-
const annotations =
|
|
123
|
+
const annotations = toStableAnnotations(query.annotation);
|
|
123
124
|
const resultMetadataAnnotation = outputStruct.resultMetadata
|
|
124
125
|
? getResultStructMetadataAnnotation(outputStruct, outputStruct.resultMetadata)
|
|
125
126
|
: undefined;
|
|
@@ -173,11 +174,13 @@ function convertParameterDefaultValue(value) {
|
|
|
173
174
|
throw new Error('Invalid parameter default value');
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
/**
|
|
178
|
+
* IR annotation → stable `Malloy.Annotation[]` shape used across `to_stable`
|
|
179
|
+
* and the api surfaces. The stable shape carries the raw annotation strings;
|
|
180
|
+
* routes are derivable at the consumer via `parsePrefix` (`./prefix.ts`).
|
|
181
|
+
*/
|
|
182
|
+
function toStableAnnotations(annot) {
|
|
183
|
+
return new annotation_1.Annotations(annot).texts().map(value => ({ value }));
|
|
181
184
|
}
|
|
182
185
|
function convertFieldInfos(source, fields) {
|
|
183
186
|
var _a, _b, _c;
|
|
@@ -186,10 +189,7 @@ function convertFieldInfos(source, fields) {
|
|
|
186
189
|
const isPublic = field.accessModifier === undefined;
|
|
187
190
|
if (!isPublic)
|
|
188
191
|
continue;
|
|
189
|
-
const
|
|
190
|
-
const rawAnnotations = taglines.map(tagline => ({
|
|
191
|
-
value: tagline,
|
|
192
|
-
}));
|
|
192
|
+
const rawAnnotations = toStableAnnotations(field.annotation);
|
|
193
193
|
const annotations = rawAnnotations.length > 0 ? rawAnnotations : undefined;
|
|
194
194
|
if ((0, model_1.isTurtle)(field)) {
|
|
195
195
|
const outputStruct = (0, model_1.getResultStructDefForView)(source, field);
|
|
@@ -452,10 +452,7 @@ function convertRecordType(field) {
|
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
if (f.annotation) {
|
|
455
|
-
|
|
456
|
-
annotations.push(...taglines.map(tagline => ({
|
|
457
|
-
value: tagline,
|
|
458
|
-
})));
|
|
455
|
+
annotations.push(...toStableAnnotations(f.annotation));
|
|
459
456
|
}
|
|
460
457
|
if ((0, model_1.isAtomic)(f)) {
|
|
461
458
|
return {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.397";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.397';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.397",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"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"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@malloydata/malloy-filter": "0.0.
|
|
55
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
56
|
-
"@malloydata/malloy-tag": "0.0.
|
|
54
|
+
"@malloydata/malloy-filter": "0.0.397",
|
|
55
|
+
"@malloydata/malloy-interfaces": "0.0.397",
|
|
56
|
+
"@malloydata/malloy-tag": "0.0.397",
|
|
57
57
|
"@noble/hashes": "^1.8.0",
|
|
58
58
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
59
59
|
"assert": "^2.0.0",
|