@malloydata/malloy 0.0.398 → 0.0.400
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/api/annotation-utils.d.ts +36 -0
- package/dist/api/annotation-utils.js +76 -0
- package/dist/api/core.js +3 -3
- package/dist/api/foundation/annotation.d.ts +115 -0
- package/dist/{annotation.js → api/foundation/annotation.js} +87 -42
- package/dist/api/foundation/compile.js +3 -3
- package/dist/api/foundation/core.d.ts +80 -17
- package/dist/api/foundation/core.js +135 -43
- package/dist/api/foundation/index.d.ts +1 -1
- package/dist/api/foundation/index.js +3 -2
- package/dist/api/foundation/runtime.js +2 -2
- package/dist/{taggable.d.ts → api/foundation/taggable.d.ts} +4 -4
- package/dist/api/foundation/types.d.ts +1 -1
- package/dist/connection/types.d.ts +3 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +17 -4
- package/dist/{prefix.js → lang/annotation-prefix.js} +1 -1
- package/dist/lang/ast/expressions/expr-given.js +1 -1
- package/dist/lang/ast/field-space/dynamic-space.d.ts +1 -1
- package/dist/lang/ast/field-space/dynamic-space.js +2 -2
- package/dist/lang/ast/field-space/include-utils.d.ts +3 -3
- package/dist/lang/ast/field-space/query-spaces.js +2 -2
- package/dist/lang/ast/field-space/reference-field.js +5 -5
- package/dist/lang/ast/field-space/refined-space.d.ts +2 -2
- package/dist/lang/ast/field-space/refined-space.js +3 -3
- package/dist/lang/ast/field-space/rename-space-field.d.ts +2 -2
- package/dist/lang/ast/field-space/rename-space-field.js +4 -4
- package/dist/lang/ast/field-space/static-space.js +1 -1
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +2 -2
- package/dist/lang/ast/query-elements/anonymous-query.js +3 -3
- package/dist/lang/ast/query-elements/query-arrow.js +2 -2
- package/dist/lang/ast/query-items/field-declaration.d.ts +2 -2
- package/dist/lang/ast/query-items/field-declaration.js +1 -1
- package/dist/lang/ast/query-items/field-references.d.ts +3 -3
- package/dist/lang/ast/query-properties/nest.js +2 -2
- package/dist/lang/ast/source-elements/composite-source.d.ts +2 -2
- package/dist/lang/ast/source-elements/refined-source.d.ts +2 -2
- package/dist/lang/ast/source-elements/sql-source.js +1 -1
- package/dist/lang/ast/source-elements/typed-source.js +7 -4
- package/dist/lang/ast/source-properties/join.d.ts +2 -2
- package/dist/lang/ast/source-properties/join.js +2 -2
- package/dist/lang/ast/source-properties/renames.d.ts +2 -2
- package/dist/lang/ast/source-properties/user-type-shape.d.ts +2 -2
- package/dist/lang/ast/source-properties/user-type-shape.js +7 -7
- package/dist/lang/ast/source-properties/view-field-declaration.d.ts +1 -1
- package/dist/lang/ast/source-properties/view-field-declaration.js +2 -2
- package/dist/lang/ast/source-query-elements/include-item.d.ts +3 -3
- package/dist/lang/ast/statements/define-given.d.ts +2 -2
- package/dist/lang/ast/statements/define-given.js +2 -2
- package/dist/lang/ast/statements/define-query.d.ts +2 -2
- package/dist/lang/ast/statements/define-query.js +2 -2
- package/dist/lang/ast/statements/define-source.d.ts +2 -2
- package/dist/lang/ast/statements/define-source.js +2 -2
- package/dist/lang/ast/statements/define-user-type.d.ts +2 -2
- package/dist/lang/ast/statements/define-user-type.js +1 -1
- package/dist/lang/ast/statements/export-statement.d.ts +12 -0
- package/dist/lang/ast/statements/export-statement.js +53 -0
- package/dist/lang/ast/statements/import-statement.js +1 -1
- package/dist/lang/ast/types/annotation-elements.js +3 -3
- package/dist/lang/ast/types/definition-list.d.ts +3 -3
- package/dist/lang/ast/types/literal.d.ts +1 -1
- package/dist/lang/ast/types/malloy-element.d.ts +5 -4
- package/dist/lang/ast/types/malloy-element.js +20 -17
- package/dist/lang/ast/types/noteable.d.ts +5 -5
- package/dist/lang/ast/types/pipeline-comp.d.ts +2 -2
- package/dist/lang/ast/view-elements/reference-view.js +1 -1
- package/dist/lang/ast/view-elements/view-refine.js +1 -1
- package/dist/lang/composite-source-utils.d.ts +2 -2
- package/dist/lang/composite-source-utils.js +6 -6
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +124 -123
- package/dist/lang/lib/Malloy/MalloyLexer.js +1418 -1411
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +302 -274
- package/dist/lang/lib/Malloy/MalloyParser.js +2748 -2557
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +22 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +14 -0
- package/dist/lang/malloy-to-ast.d.ts +4 -3
- package/dist/lang/malloy-to-ast.js +12 -5
- package/dist/lang/malloy-to-stable-query.d.ts +2 -2
- package/dist/lang/parse-log.d.ts +3 -0
- package/dist/lang/parse-malloy.js +6 -6
- package/dist/lang/parse-tree-walkers/model-annotation-walker.d.ts +2 -2
- package/dist/lang/parse-tree-walkers/model-annotation-walker.js +2 -2
- package/dist/lang/prettify/index.js +1 -1
- package/dist/lang/prettify/leaf.js +2 -2
- package/dist/lang/translate-response.d.ts +2 -2
- package/dist/model/filter_compilers.js +1 -1
- package/dist/model/malloy_types.d.ts +28 -24
- package/dist/model/persist_utils.js +3 -3
- package/dist/model/query_model_impl.js +1 -1
- package/dist/model/query_node.js +8 -8
- package/dist/model/query_query.js +13 -13
- package/dist/model/source_def_utils.js +4 -4
- package/dist/run_sql_options.d.ts +6 -4
- package/dist/to_stable.d.ts +2 -2
- package/dist/to_stable.js +7 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/annotation.d.ts +0 -96
- /package/dist/{taggable.js → api/foundation/taggable.js} +0 -0
- /package/dist/{prefix.d.ts → lang/annotation-prefix.d.ts} +0 -0
|
@@ -122,6 +122,8 @@ import { ImportStatementContext } from "./MalloyParser";
|
|
|
122
122
|
import { ImportSelectContext } from "./MalloyParser";
|
|
123
123
|
import { ImportItemContext } from "./MalloyParser";
|
|
124
124
|
import { ImportURLContext } from "./MalloyParser";
|
|
125
|
+
import { ExportStatementContext } from "./MalloyParser";
|
|
126
|
+
import { ExportItemContext } from "./MalloyParser";
|
|
125
127
|
import { DocAnnotationsContext } from "./MalloyParser";
|
|
126
128
|
import { IgnoredObjectAnnotationsContext } from "./MalloyParser";
|
|
127
129
|
import { IgnoredModelAnnotationsContext } from "./MalloyParser";
|
|
@@ -1690,6 +1692,26 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
1690
1692
|
* @param ctx the parse tree
|
|
1691
1693
|
*/
|
|
1692
1694
|
exitImportURL?: (ctx: ImportURLContext) => void;
|
|
1695
|
+
/**
|
|
1696
|
+
* Enter a parse tree produced by `MalloyParser.exportStatement`.
|
|
1697
|
+
* @param ctx the parse tree
|
|
1698
|
+
*/
|
|
1699
|
+
enterExportStatement?: (ctx: ExportStatementContext) => void;
|
|
1700
|
+
/**
|
|
1701
|
+
* Exit a parse tree produced by `MalloyParser.exportStatement`.
|
|
1702
|
+
* @param ctx the parse tree
|
|
1703
|
+
*/
|
|
1704
|
+
exitExportStatement?: (ctx: ExportStatementContext) => void;
|
|
1705
|
+
/**
|
|
1706
|
+
* Enter a parse tree produced by `MalloyParser.exportItem`.
|
|
1707
|
+
* @param ctx the parse tree
|
|
1708
|
+
*/
|
|
1709
|
+
enterExportItem?: (ctx: ExportItemContext) => void;
|
|
1710
|
+
/**
|
|
1711
|
+
* Exit a parse tree produced by `MalloyParser.exportItem`.
|
|
1712
|
+
* @param ctx the parse tree
|
|
1713
|
+
*/
|
|
1714
|
+
exitExportItem?: (ctx: ExportItemContext) => void;
|
|
1693
1715
|
/**
|
|
1694
1716
|
* Enter a parse tree produced by `MalloyParser.docAnnotations`.
|
|
1695
1717
|
* @param ctx the parse tree
|
|
@@ -122,6 +122,8 @@ import { ImportStatementContext } from "./MalloyParser";
|
|
|
122
122
|
import { ImportSelectContext } from "./MalloyParser";
|
|
123
123
|
import { ImportItemContext } from "./MalloyParser";
|
|
124
124
|
import { ImportURLContext } from "./MalloyParser";
|
|
125
|
+
import { ExportStatementContext } from "./MalloyParser";
|
|
126
|
+
import { ExportItemContext } from "./MalloyParser";
|
|
125
127
|
import { DocAnnotationsContext } from "./MalloyParser";
|
|
126
128
|
import { IgnoredObjectAnnotationsContext } from "./MalloyParser";
|
|
127
129
|
import { IgnoredModelAnnotationsContext } from "./MalloyParser";
|
|
@@ -1110,6 +1112,18 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
1110
1112
|
* @return the visitor result
|
|
1111
1113
|
*/
|
|
1112
1114
|
visitImportURL?: (ctx: ImportURLContext) => Result;
|
|
1115
|
+
/**
|
|
1116
|
+
* Visit a parse tree produced by `MalloyParser.exportStatement`.
|
|
1117
|
+
* @param ctx the parse tree
|
|
1118
|
+
* @return the visitor result
|
|
1119
|
+
*/
|
|
1120
|
+
visitExportStatement?: (ctx: ExportStatementContext) => Result;
|
|
1121
|
+
/**
|
|
1122
|
+
* Visit a parse tree produced by `MalloyParser.exportItem`.
|
|
1123
|
+
* @param ctx the parse tree
|
|
1124
|
+
* @return the visitor result
|
|
1125
|
+
*/
|
|
1126
|
+
visitExportItem?: (ctx: ExportItemContext) => Result;
|
|
1113
1127
|
/**
|
|
1114
1128
|
* Visit a parse tree produced by `MalloyParser.docAnnotations`.
|
|
1115
1129
|
* @param ctx the parse tree
|
|
@@ -25,7 +25,7 @@ interface IndirectUserType {
|
|
|
25
25
|
arrayDepth: number;
|
|
26
26
|
}
|
|
27
27
|
type UserTypeFieldTypeResult = AtomicTypeDef | IndirectUserType;
|
|
28
|
-
type
|
|
28
|
+
type AnnotatedCtx = ParserRuleContext & {
|
|
29
29
|
annotation: () => parse.AnnotationContext[];
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
@@ -99,7 +99,7 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
|
|
|
99
99
|
* malformation marker through the IR and are not re-warned by importers.
|
|
100
100
|
*/
|
|
101
101
|
private warnIfMalformedPrefix;
|
|
102
|
-
protected getNotes(cx:
|
|
102
|
+
protected getNotes(cx: AnnotatedCtx): Note[];
|
|
103
103
|
protected getIsNotes(cx: parse.IsDefineContext): Note[];
|
|
104
104
|
visitMalloyDocument(pcx: parse.MalloyDocumentContext): ast.Document;
|
|
105
105
|
visitDefineSourceStatement(pcx: parse.DefineSourceStatementContext): ast.DefineSourceList;
|
|
@@ -249,6 +249,7 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
|
|
|
249
249
|
visitLiteralMonth(pcx: parse.LiteralMonthContext): ast.ExpressionDef;
|
|
250
250
|
visitLiteralQuarter(pcx: parse.LiteralQuarterContext): ast.ExpressionDef;
|
|
251
251
|
visitLiteralYear(pcx: parse.LiteralYearContext): ast.ExpressionDef;
|
|
252
|
+
visitExportStatement(pcx: parse.ExportStatementContext): ast.ExportStatement;
|
|
252
253
|
visitImportStatement(pcx: parse.ImportStatementContext): ast.ImportStatement;
|
|
253
254
|
visitDebugExpr(pcx: parse.DebugExprContext): ast.ExpressionDef;
|
|
254
255
|
visitSampleStatement(pcx: parse.SampleStatementContext): ast.SampleProperty;
|
|
@@ -279,7 +280,7 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
|
|
|
279
280
|
visitSegRefine(pcx: parse.SegRefineContext): ast.ViewRefine;
|
|
280
281
|
visitVArrow(pcx: parse.VArrowContext): ast.ViewArrow;
|
|
281
282
|
visitSQRefinedQuery(pcx: parse.SQRefinedQueryContext): ast.SQRefine;
|
|
282
|
-
visitSQTable(pcx: parse.SQTableContext):
|
|
283
|
+
visitSQTable(pcx: parse.SQTableContext): ast.SQSource | ErrorNode;
|
|
283
284
|
visitSQVirtual(pcx: parse.SQVirtualContext): ast.SQSource;
|
|
284
285
|
visitSQSQL(pcx: parse.SQSQLContext): ast.SQSource;
|
|
285
286
|
visitExperimentalStatementForTesting(pcx: parse.ExperimentalStatementForTestingContext): ast.ExperimentalExperiment;
|
|
@@ -62,7 +62,7 @@ const AbstractParseTreeVisitor_1 = require("antlr4ts/tree/AbstractParseTreeVisit
|
|
|
62
62
|
const ast = __importStar(require("./ast"));
|
|
63
63
|
const parse_log_1 = require("./parse-log");
|
|
64
64
|
const Interval_1 = require("antlr4ts/misc/Interval");
|
|
65
|
-
const
|
|
65
|
+
const annotation_prefix_1 = require("./annotation-prefix");
|
|
66
66
|
const ast_1 = require("./ast");
|
|
67
67
|
const parse_utils_1 = require("./parse-utils");
|
|
68
68
|
const malloy_types_1 = require("../model/malloy_types");
|
|
@@ -283,7 +283,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
283
283
|
* malformation marker through the IR and are not re-warned by importers.
|
|
284
284
|
*/
|
|
285
285
|
warnIfMalformedPrefix(text, cx) {
|
|
286
|
-
const parsed = (0,
|
|
286
|
+
const parsed = (0, annotation_prefix_1.parsePrefix)(text);
|
|
287
287
|
if (parsed.malformation === undefined)
|
|
288
288
|
return;
|
|
289
289
|
// The slice up to contentIndex is "prefix + separator"; trim trailing
|
|
@@ -1482,6 +1482,13 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1482
1482
|
visitLiteralYear(pcx) {
|
|
1483
1483
|
return this.parseTime(pcx, ast.LiteralYear.parse);
|
|
1484
1484
|
}
|
|
1485
|
+
visitExportStatement(pcx) {
|
|
1486
|
+
const items = pcx.exportItem().map(itemCx => {
|
|
1487
|
+
const idCx = itemCx.id();
|
|
1488
|
+
return this.astAt(new ast.ExportItem((0, parse_utils_1.idToStr)(idCx)), idCx);
|
|
1489
|
+
});
|
|
1490
|
+
return this.astAt(new ast.ExportStatement(items), pcx);
|
|
1491
|
+
}
|
|
1485
1492
|
visitImportStatement(pcx) {
|
|
1486
1493
|
const url = this.getPlainStringFrom(pcx.importURL());
|
|
1487
1494
|
const importStmt = this.astAt(new ast.ImportStatement(url, this.parseInfo.importBaseURL), pcx);
|
|
@@ -1545,7 +1552,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1545
1552
|
for (const a of pcx.docAnnotation()) {
|
|
1546
1553
|
const block = a.docBlockAnnotation();
|
|
1547
1554
|
if (block && !block.BLOCK_ANNOTATION_END()) {
|
|
1548
|
-
this.contextError(pcx, 'unclosed-block-annotation', '
|
|
1555
|
+
this.contextError(pcx, 'unclosed-block-annotation', 'Multi-line annotation is not closed, add correctly indented "|##"');
|
|
1549
1556
|
}
|
|
1550
1557
|
}
|
|
1551
1558
|
const allNotes = pcx.docAnnotation().map(a => {
|
|
@@ -1563,7 +1570,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1563
1570
|
return block && !block.BLOCK_ANNOTATION_END();
|
|
1564
1571
|
});
|
|
1565
1572
|
if (hasUnclosedBlock) {
|
|
1566
|
-
this.contextError(pcx, 'unclosed-block-annotation', '
|
|
1573
|
+
this.contextError(pcx, 'unclosed-block-annotation', 'Multi-line annotation is not closed, add correctly indented "|#"');
|
|
1567
1574
|
}
|
|
1568
1575
|
else {
|
|
1569
1576
|
this.contextError(pcx, 'orphaned-object-annotation', 'Object annotation not connected to any object');
|
|
@@ -1576,7 +1583,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1576
1583
|
return block && !block.BLOCK_ANNOTATION_END();
|
|
1577
1584
|
});
|
|
1578
1585
|
if (hasUnclosedBlock) {
|
|
1579
|
-
this.contextError(pcx, 'unclosed-block-annotation', '
|
|
1586
|
+
this.contextError(pcx, 'unclosed-block-annotation', 'Multi-line annotation is not closed, add correctly indented "|##"');
|
|
1580
1587
|
}
|
|
1581
1588
|
else {
|
|
1582
1589
|
this.contextError(pcx, 'misplaced-model-annotation', 'Model annotations not allowed at this scope');
|
|
@@ -8,7 +8,7 @@ import type { LogMessageOptions, MessageCode, MessageLogger, MessageParameterTyp
|
|
|
8
8
|
import type { DocumentLocation } from '../model/malloy_types';
|
|
9
9
|
import type { ParseInfo } from './utils';
|
|
10
10
|
import type { TimeLiteral } from './ast';
|
|
11
|
-
type
|
|
11
|
+
type AnnotatedCtx = ParserRuleContext & {
|
|
12
12
|
annotation: () => parse.AnnotationContext[];
|
|
13
13
|
};
|
|
14
14
|
type Node = Malloy.Query | Malloy.QueryDefinitionWithArrow | Malloy.QueryDefinitionWithQueryReference | Malloy.QueryDefinitionWithRefinement | null;
|
|
@@ -41,7 +41,7 @@ export declare class MalloyToQuery extends AbstractParseTreeVisitor<Node> implem
|
|
|
41
41
|
* @param cx Any parse context which has an annotation* rule
|
|
42
42
|
* @returns Array of texts for the annotations
|
|
43
43
|
*/
|
|
44
|
-
protected getAnnotations(cx:
|
|
44
|
+
protected getAnnotations(cx: AnnotatedCtx): Malloy.Annotation[] | undefined;
|
|
45
45
|
protected getIsAnnotations(cx?: parse.IsDefineContext): Malloy.Annotation[] | undefined;
|
|
46
46
|
protected notAllowed(pcx: ParserRuleContext, what: string): void;
|
|
47
47
|
protected illegal(pcx: ParserRuleContext, what: string): void;
|
package/dist/lang/parse-log.d.ts
CHANGED
|
@@ -281,6 +281,9 @@ type MessageParameterTypes = {
|
|
|
281
281
|
'selective-import-not-found': string;
|
|
282
282
|
'name-conflict-on-indiscriminate-import': string;
|
|
283
283
|
'failed-import': string;
|
|
284
|
+
'export-name-not-defined': string;
|
|
285
|
+
'export-name-not-exportable': string;
|
|
286
|
+
'duplicate-export-name': string;
|
|
284
287
|
'unsatisfied-given-in-query': string;
|
|
285
288
|
'given-alias-collision': string;
|
|
286
289
|
'failed-to-compute-output-schema': string;
|
|
@@ -72,7 +72,7 @@ const utils_2 = require("./utils");
|
|
|
72
72
|
const malloy_tag_1 = require("@malloydata/malloy-tag");
|
|
73
73
|
const model_annotation_walker_1 = require("./parse-tree-walkers/model-annotation-walker");
|
|
74
74
|
const find_table_path_walker_1 = require("./parse-tree-walkers/find-table-path-walker");
|
|
75
|
-
const annotation_1 = require("../annotation");
|
|
75
|
+
const annotation_1 = require("../api/foundation/annotation");
|
|
76
76
|
const run_malloy_parser_1 = require("./run-malloy-parser");
|
|
77
77
|
const timing_1 = require("../timing");
|
|
78
78
|
class ParseStep {
|
|
@@ -420,11 +420,11 @@ class ModelAnnotationStep {
|
|
|
420
420
|
return tryParse;
|
|
421
421
|
}
|
|
422
422
|
else {
|
|
423
|
-
const
|
|
423
|
+
const modelAnnotations = (0, model_annotation_walker_1.walkForModelAnnotation)(that, tryParse.parse.tokenStream, tryParse.parse);
|
|
424
424
|
this.response = {
|
|
425
|
-
|
|
426
|
-
...
|
|
427
|
-
inherits: extendingModel === null || extendingModel === void 0 ? void 0 : extendingModel.
|
|
425
|
+
modelAnnotations: {
|
|
426
|
+
...modelAnnotations,
|
|
427
|
+
inherits: extendingModel === null || extendingModel === void 0 ? void 0 : extendingModel.annotations,
|
|
428
428
|
},
|
|
429
429
|
};
|
|
430
430
|
}
|
|
@@ -478,7 +478,7 @@ class TranslateStep {
|
|
|
478
478
|
// seeding (e.g. TestTranslator's compilerFlags option) survive.
|
|
479
479
|
if (extendingModel && !this.importedAnnotations) {
|
|
480
480
|
const parseCompilerFlagsTimer = new timing_1.Timer('parse_compiler_flags');
|
|
481
|
-
that.compilerFlagSrc.push(...new annotation_1.Annotations(extendingModel.
|
|
481
|
+
that.compilerFlagSrc.push(...new annotation_1.Annotations(extendingModel.annotations).texts('!'));
|
|
482
482
|
stepTimer.contribute([parseCompilerFlagsTimer.stop()]);
|
|
483
483
|
this.importedAnnotations = true;
|
|
484
484
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonTokenStream } from 'antlr4ts';
|
|
2
2
|
import type { MalloyTranslation } from '../parse-malloy';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AnnotationsDef } from '../../model/malloy_types';
|
|
4
4
|
import type { MalloyParseInfo } from '../malloy-parse-info';
|
|
5
|
-
export declare function walkForModelAnnotation(forParse: MalloyTranslation, tokens: CommonTokenStream, parseInfo: MalloyParseInfo):
|
|
5
|
+
export declare function walkForModelAnnotation(forParse: MalloyTranslation, tokens: CommonTokenStream, parseInfo: MalloyParseInfo): AnnotationsDef;
|
|
@@ -37,7 +37,7 @@ class ModelAnnotationWalker {
|
|
|
37
37
|
this.notes.push((0, parse_utils_1.noteFromAnnotation)(a, this.parseInfo));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
get
|
|
40
|
+
get annotations() {
|
|
41
41
|
return { notes: this.notes };
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -45,6 +45,6 @@ function walkForModelAnnotation(forParse, tokens, parseInfo) {
|
|
|
45
45
|
const finder = new ModelAnnotationWalker(forParse, tokens, parseInfo);
|
|
46
46
|
const listener = finder;
|
|
47
47
|
ParseTreeWalker_1.ParseTreeWalker.DEFAULT.walk(listener, parseInfo.root);
|
|
48
|
-
return finder.
|
|
48
|
+
return finder.annotations;
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=model-annotation-walker.js.map
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
* of a comparison reads as one unit; breaking inside is more confusing
|
|
50
50
|
* than the line being long.
|
|
51
51
|
* - SQL strings (`"""…"""`, including `%{…}` malloy interpolations) and
|
|
52
|
-
*
|
|
52
|
+
* multi-line annotations (`#" … "`) are emitted verbatim from source. We don't
|
|
53
53
|
* own a SQL formatter; annotation indentation is significant.
|
|
54
54
|
* - `;` is the compact-inline statement separator. Wrapped form drops it
|
|
55
55
|
* (newlines do the job); inline form keeps it.
|
|
@@ -164,8 +164,8 @@ function emitVisibleToken(f, t, idx) {
|
|
|
164
164
|
return; // already emitted (e.g. SQL block range)
|
|
165
165
|
flushHiddenBefore(f, idx);
|
|
166
166
|
const text = (_a = t.text) !== null && _a !== void 0 ? _a : '';
|
|
167
|
-
// ---- Verbatim regions: SQL strings and
|
|
168
|
-
// We don't own a SQL formatter.
|
|
167
|
+
// ---- Verbatim regions: SQL strings and multi-line annotations ----
|
|
168
|
+
// We don't own a SQL formatter. Multi-line annotation indentation is significant.
|
|
169
169
|
if (t.type === tokens_1.L.SQL_BEGIN) {
|
|
170
170
|
const endIdx = (0, tokens_1.findMatching)(f.tokens, idx, tokens_1.L.SQL_BEGIN, tokens_1.L.SQL_END);
|
|
171
171
|
const stop = f.tokens[endIdx].stopIndex;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnnotationsDef, ModelDef } from '../model/malloy_types';
|
|
3
3
|
import type { MalloyElement } from './ast';
|
|
4
4
|
import type { LogMessage } from './parse-log';
|
|
5
5
|
import type { DocumentSymbol } from './parse-tree-walkers/document-symbol-walker';
|
|
@@ -55,7 +55,7 @@ interface Metadata extends ResponseBase, NeededData, ProblemResponse, FinalRespo
|
|
|
55
55
|
}
|
|
56
56
|
export type MetadataResponse = Partial<Metadata>;
|
|
57
57
|
interface ModelAnnotationData extends ResponseBase, NeededData, ProblemResponse, FinalResponse {
|
|
58
|
-
|
|
58
|
+
modelAnnotations: AnnotationsDef;
|
|
59
59
|
}
|
|
60
60
|
export type ModelAnnotationResponse = Partial<ModelAnnotationData>;
|
|
61
61
|
interface Completions extends ResponseBase, NeededData, ProblemResponse, FinalResponse {
|
|
@@ -335,7 +335,7 @@ export type Argument = Parameter;
|
|
|
335
335
|
* shape here is the conservative "not yet narrowed" version.
|
|
336
336
|
*/
|
|
337
337
|
export type GivenTypeDef = AtomicTypeDef | FilterExpressionParamTypeDef;
|
|
338
|
-
export interface Given extends HasLocation,
|
|
338
|
+
export interface Given extends HasLocation, HasAnnotations {
|
|
339
339
|
/** The name as written at the declaration site. Used by diagnostics
|
|
340
340
|
* that need a readable surface name out of an opaque GivenID. */
|
|
341
341
|
name: string;
|
|
@@ -396,7 +396,7 @@ export interface DocumentLocation {
|
|
|
396
396
|
* the references, and in that case, this should include something like an
|
|
397
397
|
* index or pointer to the full definition elsewhere in the model.
|
|
398
398
|
*/
|
|
399
|
-
export interface LightweightDefinition extends HasLocation,
|
|
399
|
+
export interface LightweightDefinition extends HasLocation, HasAnnotations {
|
|
400
400
|
type: string;
|
|
401
401
|
}
|
|
402
402
|
interface DocumentReferenceBase {
|
|
@@ -436,8 +436,8 @@ export type DocumentReference = DocumentExploreReference | DocumentQueryReferenc
|
|
|
436
436
|
export interface HasLocation {
|
|
437
437
|
location?: DocumentLocation;
|
|
438
438
|
}
|
|
439
|
-
export interface
|
|
440
|
-
|
|
439
|
+
export interface HasAnnotations {
|
|
440
|
+
annotations?: AnnotationsDef;
|
|
441
441
|
}
|
|
442
442
|
/** All names have their source names and how they will appear in the symbol table that owns them */
|
|
443
443
|
export interface AliasedName {
|
|
@@ -497,7 +497,7 @@ export declare function canOrderBy(s: string): boolean;
|
|
|
497
497
|
* value could be an expression, and this is one of the objects
|
|
498
498
|
* which might have an annotation.
|
|
499
499
|
*/
|
|
500
|
-
export interface FieldBase extends NamedObject, Expression, ResultMetadata,
|
|
500
|
+
export interface FieldBase extends NamedObject, Expression, ResultMetadata, HasAnnotations {
|
|
501
501
|
accessModifier?: NonDefaultAccessModifierLabel | undefined;
|
|
502
502
|
requiresGroupBy?: RequiredGroupBy[];
|
|
503
503
|
ungroupings?: AggregateUngrouping[];
|
|
@@ -659,12 +659,12 @@ export interface TurtleSegment extends Filtered {
|
|
|
659
659
|
export interface Pipeline {
|
|
660
660
|
pipeline: PipeSegment[];
|
|
661
661
|
}
|
|
662
|
-
export interface Query extends Pipeline, Filtered, HasLocation,
|
|
662
|
+
export interface Query extends Pipeline, Filtered, HasLocation, HasAnnotations {
|
|
663
663
|
type?: 'query';
|
|
664
664
|
name?: string;
|
|
665
665
|
structRef: StructRef;
|
|
666
666
|
sourceArguments?: SafeRecord<Argument>;
|
|
667
|
-
|
|
667
|
+
modelAnnotations?: AnnotationsDef;
|
|
668
668
|
compositeResolvedSourceDef?: SourceDef;
|
|
669
669
|
givenUsage?: GivenUsage;
|
|
670
670
|
}
|
|
@@ -822,7 +822,7 @@ export interface QuerySegment extends Filtered, Ordered, SegmentUsageSummary {
|
|
|
822
822
|
}
|
|
823
823
|
export type NonDefaultAccessModifierLabel = 'private' | 'internal';
|
|
824
824
|
export type AccessModifierLabel = NonDefaultAccessModifierLabel | 'public';
|
|
825
|
-
export interface TurtleDef extends NamedObject, Pipeline,
|
|
825
|
+
export interface TurtleDef extends NamedObject, Pipeline, HasAnnotations {
|
|
826
826
|
type: 'turtle';
|
|
827
827
|
accessModifier?: NonDefaultAccessModifierLabel | undefined;
|
|
828
828
|
refSummary?: RefSummary;
|
|
@@ -830,9 +830,9 @@ export interface TurtleDef extends NamedObject, Pipeline, HasAnnotation {
|
|
|
830
830
|
}
|
|
831
831
|
export interface TurtleDefPlusFilters extends TurtleDef, Filtered {
|
|
832
832
|
}
|
|
833
|
-
interface StructDefBase extends HasLocation, NamedObject,
|
|
833
|
+
interface StructDefBase extends HasLocation, NamedObject, HasAnnotations {
|
|
834
834
|
type: string;
|
|
835
|
-
|
|
835
|
+
modelAnnotations?: ModelAnnotationsDef;
|
|
836
836
|
fields: FieldDef[];
|
|
837
837
|
/** Marker for error placeholder structs created by ErrorFactory */
|
|
838
838
|
errorFactory?: boolean;
|
|
@@ -1084,7 +1084,7 @@ export type AtomicFieldDef = BasicAtomicDef | BasicArrayDef | RecordDef | Repeat
|
|
|
1084
1084
|
export declare function isBasicAtomic(fd: FieldDef | QueryFieldDef | AtomicTypeDef): fd is BasicAtomicDef;
|
|
1085
1085
|
export type FieldDef = BasicAtomicDef | JoinFieldDef | TurtleDef;
|
|
1086
1086
|
export type FieldDefType = AtomicFieldType | 'turtle' | JoinElementType;
|
|
1087
|
-
export interface RefToField extends
|
|
1087
|
+
export interface RefToField extends HasAnnotations {
|
|
1088
1088
|
type: 'fieldref';
|
|
1089
1089
|
path: string[];
|
|
1090
1090
|
at?: DocumentLocation;
|
|
@@ -1094,11 +1094,11 @@ export type QueryFieldDef = AtomicFieldDef | TurtleDef | RefToField;
|
|
|
1094
1094
|
export type TypedDef = AtomicTypeDef | JoinFieldDef | TurtleDef | RefToField | StructDef;
|
|
1095
1095
|
/** Get the output name for a NamedObject */
|
|
1096
1096
|
export declare function getIdentifier(n: AliasedName): string;
|
|
1097
|
-
export interface UserTypeFieldDef extends
|
|
1097
|
+
export interface UserTypeFieldDef extends HasAnnotations {
|
|
1098
1098
|
name: string;
|
|
1099
1099
|
typeDef: AtomicTypeDef;
|
|
1100
1100
|
}
|
|
1101
|
-
export interface UserTypeDef extends NamedObject,
|
|
1101
|
+
export interface UserTypeDef extends NamedObject, HasAnnotations {
|
|
1102
1102
|
type: 'userType';
|
|
1103
1103
|
fields: UserTypeFieldDef[];
|
|
1104
1104
|
}
|
|
@@ -1120,7 +1120,7 @@ export interface ModelDef {
|
|
|
1120
1120
|
*/
|
|
1121
1121
|
sourceRegistry: Record<SourceID, SourceRegistryValue>;
|
|
1122
1122
|
givens?: Record<GivenID, Given>;
|
|
1123
|
-
|
|
1123
|
+
annotations?: ModelAnnotationsDef;
|
|
1124
1124
|
queryList: Query[];
|
|
1125
1125
|
dependencies: DependencyTree;
|
|
1126
1126
|
references?: DocumentReference[];
|
|
@@ -1129,9 +1129,11 @@ export interface ModelDef {
|
|
|
1129
1129
|
/** Very common record type */
|
|
1130
1130
|
export type NamedSourceDefs = SafeRecord<SourceDef>;
|
|
1131
1131
|
export type NamedModelObjects = SafeRecord<NamedModelObject>;
|
|
1132
|
-
/**
|
|
1133
|
-
|
|
1134
|
-
|
|
1132
|
+
/** Bundle of source annotations attached to one object: the `notes` and
|
|
1133
|
+
* `blockNotes` written on it, plus the bundle from the spiritual parent
|
|
1134
|
+
* via `inherits`. The IR shape paired with the `Annotations` view class. */
|
|
1135
|
+
export interface AnnotationsDef {
|
|
1136
|
+
inherits?: AnnotationsDef;
|
|
1135
1137
|
blockNotes?: Note[];
|
|
1136
1138
|
notes?: Note[];
|
|
1137
1139
|
}
|
|
@@ -1139,15 +1141,17 @@ export interface Note {
|
|
|
1139
1141
|
text: string;
|
|
1140
1142
|
at: DocumentLocation;
|
|
1141
1143
|
/**
|
|
1142
|
-
* For
|
|
1143
|
-
* body line by the dedent pass. Used to map
|
|
1144
|
-
* back to source
|
|
1145
|
-
*
|
|
1144
|
+
* For multi-line annotations (`#|`…`|#`): characters of leading whitespace
|
|
1145
|
+
* removed from each body line by the dedent pass. Used to map
|
|
1146
|
+
* payload-parser error columns back to source
|
|
1147
|
+
* (`source_col = indentStripped + parser_col` for body lines). Omitted for
|
|
1148
|
+
* single-line annotations and for multi-line annotations with no common
|
|
1149
|
+
* indent.
|
|
1146
1150
|
*/
|
|
1147
1151
|
indentStripped?: number;
|
|
1148
1152
|
}
|
|
1149
|
-
/** Annotations with a uuid to make it easier to stream */
|
|
1150
|
-
export interface
|
|
1153
|
+
/** Annotations bundle with a uuid to make it easier to stream. */
|
|
1154
|
+
export interface ModelAnnotationsDef extends AnnotationsDef {
|
|
1151
1155
|
id: string;
|
|
1152
1156
|
}
|
|
1153
1157
|
export type QueryScalar = string | boolean | number | bigint | Date | Buffer | null;
|
|
@@ -1177,7 +1181,7 @@ export interface DrillSource {
|
|
|
1177
1181
|
sourceFilters?: FilterCondition[];
|
|
1178
1182
|
sourceArguments?: SafeRecord<Argument>;
|
|
1179
1183
|
}
|
|
1180
|
-
export interface CompiledQuery extends DrillSource,
|
|
1184
|
+
export interface CompiledQuery extends DrillSource, HasAnnotations {
|
|
1181
1185
|
structs: SourceDef[];
|
|
1182
1186
|
sql: string;
|
|
1183
1187
|
lastStageName: string;
|
|
@@ -9,7 +9,7 @@ exports.findPersistentDependencies = findPersistentDependencies;
|
|
|
9
9
|
exports.minimalBuildGraph = minimalBuildGraph;
|
|
10
10
|
const malloy_types_1 = require("./malloy_types");
|
|
11
11
|
const source_def_utils_1 = require("./source_def_utils");
|
|
12
|
-
const annotation_1 = require("../annotation");
|
|
12
|
+
const annotation_1 = require("../api/foundation/annotation");
|
|
13
13
|
/**
|
|
14
14
|
* Resolve a source name to its definition from model contents.
|
|
15
15
|
*/
|
|
@@ -22,9 +22,9 @@ function resolveSource(modelDef, name) {
|
|
|
22
22
|
* Returns both the persist flag and any tag parse errors.
|
|
23
23
|
*/
|
|
24
24
|
function checkPersistAnnotation(source) {
|
|
25
|
-
if (!source.
|
|
25
|
+
if (!source.annotations)
|
|
26
26
|
return { persist: false, log: [] };
|
|
27
|
-
const { tag, log } = new annotation_1.Annotations(source.
|
|
27
|
+
const { tag, log } = new annotation_1.Annotations(source.annotations).parseAsTag('@');
|
|
28
28
|
return { persist: tag.has('persist'), log };
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -176,7 +176,7 @@ class QueryModelImpl {
|
|
|
176
176
|
sourceArguments,
|
|
177
177
|
queryName: query.name,
|
|
178
178
|
connectionName: ret.connectionName,
|
|
179
|
-
|
|
179
|
+
annotations: query.annotations,
|
|
180
180
|
queryTimezone: ret.structs[0].queryTimezone,
|
|
181
181
|
defaultRowLimitAdded: addedDefaultRowLimit,
|
|
182
182
|
};
|
package/dist/model/query_node.js
CHANGED
|
@@ -14,7 +14,7 @@ exports.isBasicScalar = isBasicScalar;
|
|
|
14
14
|
const uuid_1 = require("uuid");
|
|
15
15
|
const malloy_compile_error_1 = require("./malloy_compile_error");
|
|
16
16
|
const malloy_types_1 = require("./malloy_types");
|
|
17
|
-
const annotation_1 = require("../annotation");
|
|
17
|
+
const annotation_1 = require("../api/foundation/annotation");
|
|
18
18
|
const dialect_1 = require("../dialect");
|
|
19
19
|
const utils_1 = require("./utils");
|
|
20
20
|
class QueryNode {
|
|
@@ -205,7 +205,7 @@ class QueryStruct {
|
|
|
205
205
|
}
|
|
206
206
|
modelCompilerFlags() {
|
|
207
207
|
if (this._modelTag === undefined) {
|
|
208
|
-
const annotation = this.structDef.
|
|
208
|
+
const annotation = this.structDef.modelAnnotations;
|
|
209
209
|
const { tag } = new annotation_1.Annotations(annotation).parseAsTag('!');
|
|
210
210
|
this._modelTag = tag;
|
|
211
211
|
}
|
|
@@ -561,20 +561,20 @@ class QueryStruct {
|
|
|
561
561
|
return field;
|
|
562
562
|
}
|
|
563
563
|
getQueryFieldReference(f) {
|
|
564
|
-
const { path,
|
|
564
|
+
const { path, annotations, drillExpression } = f;
|
|
565
565
|
const field = this.getFieldByName(path, f.at);
|
|
566
|
-
if (
|
|
566
|
+
if (annotations || drillExpression) {
|
|
567
567
|
if (field.parent === undefined) {
|
|
568
568
|
throw new Error('Inconcievable, field reference to orphaned query field');
|
|
569
569
|
}
|
|
570
570
|
// Made a field object from the source, but the annotations were computed by the compiler
|
|
571
571
|
// when it generated the reference, and has both the source and reference annotations included.
|
|
572
572
|
if (field instanceof QueryFieldStruct) {
|
|
573
|
-
const newDef = { ...field.fieldDef,
|
|
573
|
+
const newDef = { ...field.fieldDef, annotations, drillExpression };
|
|
574
574
|
return new QueryFieldStruct(newDef, undefined, field.parent, field.parent.prepareResultOptions, field.referenceId);
|
|
575
575
|
}
|
|
576
576
|
else {
|
|
577
|
-
const newDef = { ...field.fieldDef,
|
|
577
|
+
const newDef = { ...field.fieldDef, annotations, drillExpression };
|
|
578
578
|
return field.parent.makeQueryField(newDef, field.referenceId);
|
|
579
579
|
}
|
|
580
580
|
}
|
|
@@ -619,7 +619,7 @@ class QueryStruct {
|
|
|
619
619
|
}
|
|
620
620
|
applyStructFiltersToTurtleDef(turtleDef) {
|
|
621
621
|
const pipeline = [...turtleDef.pipeline];
|
|
622
|
-
const
|
|
622
|
+
const annotations = turtleDef.annotations;
|
|
623
623
|
const addedFilters = turtleDef.filterList || [];
|
|
624
624
|
pipeline[0] = {
|
|
625
625
|
...pipeline[0],
|
|
@@ -629,7 +629,7 @@ class QueryStruct {
|
|
|
629
629
|
type: 'turtle',
|
|
630
630
|
name: turtleDef.name,
|
|
631
631
|
pipeline,
|
|
632
|
-
|
|
632
|
+
annotations,
|
|
633
633
|
location: turtleDef.location,
|
|
634
634
|
};
|
|
635
635
|
return flatTurtleDef;
|
|
@@ -403,9 +403,9 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
403
403
|
join: 'many',
|
|
404
404
|
name,
|
|
405
405
|
fields: structDef.fields,
|
|
406
|
-
...(structDef.
|
|
407
|
-
...(structDef.
|
|
408
|
-
|
|
406
|
+
...(structDef.annotations && { annotations: structDef.annotations }),
|
|
407
|
+
...(structDef.modelAnnotations && {
|
|
408
|
+
modelAnnotations: structDef.modelAnnotations,
|
|
409
409
|
}),
|
|
410
410
|
resultMetadata,
|
|
411
411
|
...(queryTimezone && { queryTimezone }),
|
|
@@ -418,9 +418,9 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
418
418
|
join: 'one',
|
|
419
419
|
name,
|
|
420
420
|
fields: structDef.fields,
|
|
421
|
-
...(structDef.
|
|
422
|
-
...(structDef.
|
|
423
|
-
|
|
421
|
+
...(structDef.annotations && { annotations: structDef.annotations }),
|
|
422
|
+
...(structDef.modelAnnotations && {
|
|
423
|
+
modelAnnotations: structDef.modelAnnotations,
|
|
424
424
|
}),
|
|
425
425
|
resultMetadata,
|
|
426
426
|
...(queryTimezone && { queryTimezone }),
|
|
@@ -451,11 +451,11 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
451
451
|
delete fOut.expressionType;
|
|
452
452
|
}
|
|
453
453
|
const location = fOut.location;
|
|
454
|
-
const
|
|
454
|
+
const annotations = fOut.annotations;
|
|
455
455
|
const common = {
|
|
456
456
|
resultMetadata,
|
|
457
457
|
location,
|
|
458
|
-
|
|
458
|
+
annotations,
|
|
459
459
|
};
|
|
460
460
|
// build out the result fields...
|
|
461
461
|
switch (fOut.type) {
|
|
@@ -513,8 +513,8 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
513
513
|
resultMetadata: this.getResultMetadata(this.rootResult),
|
|
514
514
|
queryTimezone: resultStruct.getQueryInfo().queryTimezone,
|
|
515
515
|
};
|
|
516
|
-
if (this.parent.structDef.
|
|
517
|
-
outputStruct.
|
|
516
|
+
if (this.parent.structDef.modelAnnotations) {
|
|
517
|
+
outputStruct.modelAnnotations = this.parent.structDef.modelAnnotations;
|
|
518
518
|
}
|
|
519
519
|
return outputStruct;
|
|
520
520
|
}
|
|
@@ -1546,7 +1546,7 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
1546
1546
|
// console.log(stageWriter.generateSQLStages());
|
|
1547
1547
|
structDef = pipeOut.outputStruct;
|
|
1548
1548
|
}
|
|
1549
|
-
structDef.
|
|
1549
|
+
structDef.annotations = fi.turtleDef.annotations;
|
|
1550
1550
|
return {
|
|
1551
1551
|
structDef,
|
|
1552
1552
|
pipeOut,
|
|
@@ -1821,8 +1821,8 @@ class QueryQueryIndex extends QueryQuery {
|
|
|
1821
1821
|
],
|
|
1822
1822
|
connection: this.parent.connectionName,
|
|
1823
1823
|
};
|
|
1824
|
-
if (this.parent.structDef.
|
|
1825
|
-
ret.
|
|
1824
|
+
if (this.parent.structDef.modelAnnotations) {
|
|
1825
|
+
ret.modelAnnotations = this.parent.structDef.modelAnnotations;
|
|
1826
1826
|
}
|
|
1827
1827
|
return ret;
|
|
1828
1828
|
}
|
|
@@ -44,8 +44,8 @@ function mkQuerySourceDef(base, query, name) {
|
|
|
44
44
|
// HasLocation
|
|
45
45
|
location: base.location,
|
|
46
46
|
// StructDefBase
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
annotations: base.annotations,
|
|
48
|
+
modelAnnotations: base.modelAnnotations,
|
|
49
49
|
fields: base.fields,
|
|
50
50
|
// Filtered
|
|
51
51
|
filterList: base.filterList,
|
|
@@ -83,8 +83,8 @@ function mkSQLSourceDef(base, selectStr, selectSegments) {
|
|
|
83
83
|
// HasLocation
|
|
84
84
|
location: base.location,
|
|
85
85
|
// StructDefBase
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
annotations: base.annotations,
|
|
87
|
+
modelAnnotations: base.modelAnnotations,
|
|
88
88
|
fields: base.fields,
|
|
89
89
|
// Filtered
|
|
90
90
|
filterList: base.filterList,
|