@malloydata/malloy 0.0.399 → 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/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/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 +4 -4
- package/dist/lang/ast/types/malloy-element.js +15 -15
- 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/malloy-to-ast.d.ts +3 -3
- package/dist/lang/malloy-to-ast.js +5 -5
- package/dist/lang/malloy-to-stable-query.d.ts +2 -2
- 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/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
|
@@ -121,7 +121,7 @@ class MalloyElement {
|
|
|
121
121
|
text: key,
|
|
122
122
|
definition: {
|
|
123
123
|
type: result.entry.type,
|
|
124
|
-
|
|
124
|
+
annotations: result.entry.annotations,
|
|
125
125
|
location: result.entry.location,
|
|
126
126
|
},
|
|
127
127
|
location: reference.location,
|
|
@@ -133,7 +133,7 @@ class MalloyElement {
|
|
|
133
133
|
text: key,
|
|
134
134
|
definition: {
|
|
135
135
|
type: result.entry.type,
|
|
136
|
-
|
|
136
|
+
annotations: result.entry.annotations,
|
|
137
137
|
location: result.entry.location,
|
|
138
138
|
},
|
|
139
139
|
location: reference.location,
|
|
@@ -463,7 +463,7 @@ class Document extends MalloyElement {
|
|
|
463
463
|
this.queryList = [];
|
|
464
464
|
this.didInitModel = false;
|
|
465
465
|
this.modelWasModified = false;
|
|
466
|
-
this.
|
|
466
|
+
this.annotations = {};
|
|
467
467
|
this.experiments = new malloy_tag_1.Tag({});
|
|
468
468
|
this.modelAnnotationTodoList = [];
|
|
469
469
|
this.dialectNameSpaces = new Map();
|
|
@@ -480,8 +480,8 @@ class Document extends MalloyElement {
|
|
|
480
480
|
this.explicitExports = undefined;
|
|
481
481
|
this.queryList = [];
|
|
482
482
|
if (extendingModelDef) {
|
|
483
|
-
if (extendingModelDef.
|
|
484
|
-
this.
|
|
483
|
+
if (extendingModelDef.annotations) {
|
|
484
|
+
this.annotations.inherits = extendingModelDef.annotations;
|
|
485
485
|
}
|
|
486
486
|
for (const [nm, orig] of Object.entries(extendingModelDef.contents)) {
|
|
487
487
|
const entry = { ...orig };
|
|
@@ -509,14 +509,14 @@ class Document extends MalloyElement {
|
|
|
509
509
|
this.checkGivenAliasCollisions();
|
|
510
510
|
this.checkQueryGivenSatisfiability();
|
|
511
511
|
for (const q of this.queryList) {
|
|
512
|
-
if (q.
|
|
513
|
-
q.
|
|
512
|
+
if (q.modelAnnotations === undefined && modelDef.annotations) {
|
|
513
|
+
q.modelAnnotations = modelDef.annotations;
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
if (modelDef.
|
|
517
|
+
if (modelDef.annotations) {
|
|
518
518
|
for (const sd of this.modelAnnotationTodoList) {
|
|
519
|
-
sd.
|
|
519
|
+
sd.modelAnnotations || (sd.modelAnnotations = modelDef.annotations);
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
const ret = {
|
|
@@ -609,12 +609,12 @@ class Document extends MalloyElement {
|
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
611
|
hasAnnotation() {
|
|
612
|
-
return ((this.
|
|
613
|
-
this.
|
|
612
|
+
return ((this.annotations.notes && this.annotations.notes.length > 0) ||
|
|
613
|
+
this.annotations.inherits !== undefined);
|
|
614
614
|
}
|
|
615
615
|
currentModelAnnotation() {
|
|
616
616
|
if (this.hasAnnotation()) {
|
|
617
|
-
const ret = { ...this.
|
|
617
|
+
const ret = { ...this.annotations, id: '' };
|
|
618
618
|
ret.id = annotationID(ret);
|
|
619
619
|
return ret;
|
|
620
620
|
}
|
|
@@ -622,7 +622,7 @@ class Document extends MalloyElement {
|
|
|
622
622
|
modelDef() {
|
|
623
623
|
const def = (0, utils_1.mkModelDef)('');
|
|
624
624
|
if (this.hasAnnotation()) {
|
|
625
|
-
def.
|
|
625
|
+
def.annotations = this.currentModelAnnotation();
|
|
626
626
|
}
|
|
627
627
|
const explicit = this.explicitExports;
|
|
628
628
|
const isExported = (name, modelEntry) => explicit ? explicit.has(name) : modelEntry.exported === true;
|
|
@@ -639,8 +639,8 @@ class Document extends MalloyElement {
|
|
|
639
639
|
}
|
|
640
640
|
else {
|
|
641
641
|
const newEntry = { ...entryDef };
|
|
642
|
-
if (newEntry.
|
|
643
|
-
newEntry.
|
|
642
|
+
if (newEntry.modelAnnotations === undefined && def.annotations) {
|
|
643
|
+
newEntry.modelAnnotations = def.annotations;
|
|
644
644
|
}
|
|
645
645
|
def.contents[name] = newEntry;
|
|
646
646
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef } from '../../../model/malloy_types';
|
|
2
2
|
/**
|
|
3
3
|
* An object which can receive annotations is "Noteable"
|
|
4
4
|
*/
|
|
5
5
|
export interface Noteable {
|
|
6
6
|
isNoteableObj: true;
|
|
7
|
-
note?:
|
|
8
|
-
extendNote(ext: Partial<
|
|
7
|
+
note?: AnnotationsDef;
|
|
8
|
+
extendNote(ext: Partial<AnnotationsDef>): void;
|
|
9
9
|
}
|
|
10
10
|
export declare function isNoteable(el: unknown): el is Noteable;
|
|
11
|
-
export declare function extendNoteMethod(this: Noteable, ext: Partial<
|
|
12
|
-
export declare function extendNoteHelper(to: Noteable, ext: Partial<
|
|
11
|
+
export declare function extendNoteMethod(this: Noteable, ext: Partial<AnnotationsDef>): void;
|
|
12
|
+
export declare function extendNoteHelper(to: Noteable, ext: Partial<AnnotationsDef>): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef, PipeSegment, SourceDef } from '../../../model/malloy_types';
|
|
2
2
|
export interface PipelineComp {
|
|
3
3
|
outputStruct: SourceDef;
|
|
4
4
|
pipeline: PipeSegment[];
|
|
5
|
-
|
|
5
|
+
annotations?: AnnotationsDef;
|
|
6
6
|
name?: string;
|
|
7
7
|
}
|
|
@@ -44,7 +44,7 @@ class ViewRefine extends view_1.View {
|
|
|
44
44
|
const resultPipe = this.refinement.refine(fs, query.pipeline, isNestIn);
|
|
45
45
|
return {
|
|
46
46
|
pipeline: resultPipe,
|
|
47
|
-
|
|
47
|
+
annotations: query.annotations,
|
|
48
48
|
outputStruct: resultPipe.length > 0
|
|
49
49
|
? resultPipe[resultPipe.length - 1].outputStruct
|
|
50
50
|
: error_factory_1.ErrorFactory.structDef,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MalloyElement } from './ast';
|
|
2
|
-
import type { FieldUsage, FieldUsageEntry, GivenUsage, PipeSegment, RefSummary, SourceDef, RequiredGroupBy,
|
|
2
|
+
import type { FieldUsage, FieldUsageEntry, GivenUsage, PipeSegment, RefSummary, SourceDef, RequiredGroupBy, AnnotationsDef, PartitionCompositeDesc, StructDef } from '../model/malloy_types';
|
|
3
3
|
type CompositeCouldNotFindFieldError = {
|
|
4
4
|
code: 'could_not_find_field';
|
|
5
5
|
data: {
|
|
@@ -51,7 +51,7 @@ interface CompositeFailure {
|
|
|
51
51
|
issues: CompositeIssue[];
|
|
52
52
|
}
|
|
53
53
|
export declare function getExpandedSegment(segment: PipeSegment, inputSource: SourceDef): PipeSegment;
|
|
54
|
-
export declare function getPartitionCompositeDesc(
|
|
54
|
+
export declare function getPartitionCompositeDesc(annotations: AnnotationsDef | undefined, structDef: StructDef, logTo: MalloyElement): PartitionCompositeDesc | undefined;
|
|
55
55
|
type SingleNarrowedCompositeFieldResolution = {
|
|
56
56
|
source: SourceDef;
|
|
57
57
|
nested?: SingleNarrowedCompositeFieldResolution | undefined;
|
|
@@ -33,7 +33,7 @@ const malloy_filter_1 = require("@malloydata/malloy-filter");
|
|
|
33
33
|
const malloy_types_1 = require("../model/malloy_types");
|
|
34
34
|
const utils_1 = require("./utils");
|
|
35
35
|
const utils_2 = require("../model/utils");
|
|
36
|
-
const annotation_1 = require("../annotation");
|
|
36
|
+
const annotation_1 = require("../api/foundation/annotation");
|
|
37
37
|
function _resolveCompositeSources(path, source, rootFields, nests, fieldUsage,
|
|
38
38
|
// for resolving nested composites; the list of sources to try
|
|
39
39
|
sources) {
|
|
@@ -115,13 +115,13 @@ sources) {
|
|
|
115
115
|
}
|
|
116
116
|
base = {
|
|
117
117
|
...resolveInner.success,
|
|
118
|
-
|
|
118
|
+
annotations: composeAnnotations(base.annotations, resolveInner.success.annotations),
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
122
122
|
base = {
|
|
123
123
|
...inputSource,
|
|
124
|
-
|
|
124
|
+
annotations: composeAnnotations(base.annotations, inputSource.annotations),
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
const fields = [...nonCompositeFields, ...base.fields];
|
|
@@ -544,10 +544,10 @@ function getPartitionCompositeFilter(partitionComposite, fieldUsage) {
|
|
|
544
544
|
};
|
|
545
545
|
return { partitionFilter, issues: undefined };
|
|
546
546
|
}
|
|
547
|
-
function getPartitionCompositeDesc(
|
|
548
|
-
if (
|
|
547
|
+
function getPartitionCompositeDesc(annotations, structDef, logTo) {
|
|
548
|
+
if (annotations === undefined)
|
|
549
549
|
return undefined;
|
|
550
|
-
const compilerFlags = new annotation_1.Annotations(
|
|
550
|
+
const compilerFlags = new annotation_1.Annotations(annotations).parseAsTag('!').tag;
|
|
551
551
|
const partitionCompositeTag = compilerFlags.tag('experimental', 'partition_composite');
|
|
552
552
|
if (partitionCompositeTag === undefined)
|
|
553
553
|
return undefined;
|
|
@@ -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;
|
|
@@ -280,7 +280,7 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
|
|
|
280
280
|
visitSegRefine(pcx: parse.SegRefineContext): ast.ViewRefine;
|
|
281
281
|
visitVArrow(pcx: parse.VArrowContext): ast.ViewArrow;
|
|
282
282
|
visitSQRefinedQuery(pcx: parse.SQRefinedQueryContext): ast.SQRefine;
|
|
283
|
-
visitSQTable(pcx: parse.SQTableContext):
|
|
283
|
+
visitSQTable(pcx: parse.SQTableContext): ast.SQSource | ErrorNode;
|
|
284
284
|
visitSQVirtual(pcx: parse.SQVirtualContext): ast.SQSource;
|
|
285
285
|
visitSQSQL(pcx: parse.SQSQLContext): ast.SQSource;
|
|
286
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
|
|
@@ -1552,7 +1552,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1552
1552
|
for (const a of pcx.docAnnotation()) {
|
|
1553
1553
|
const block = a.docBlockAnnotation();
|
|
1554
1554
|
if (block && !block.BLOCK_ANNOTATION_END()) {
|
|
1555
|
-
this.contextError(pcx, 'unclosed-block-annotation', '
|
|
1555
|
+
this.contextError(pcx, 'unclosed-block-annotation', 'Multi-line annotation is not closed, add correctly indented "|##"');
|
|
1556
1556
|
}
|
|
1557
1557
|
}
|
|
1558
1558
|
const allNotes = pcx.docAnnotation().map(a => {
|
|
@@ -1570,7 +1570,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1570
1570
|
return block && !block.BLOCK_ANNOTATION_END();
|
|
1571
1571
|
});
|
|
1572
1572
|
if (hasUnclosedBlock) {
|
|
1573
|
-
this.contextError(pcx, 'unclosed-block-annotation', '
|
|
1573
|
+
this.contextError(pcx, 'unclosed-block-annotation', 'Multi-line annotation is not closed, add correctly indented "|#"');
|
|
1574
1574
|
}
|
|
1575
1575
|
else {
|
|
1576
1576
|
this.contextError(pcx, 'orphaned-object-annotation', 'Object annotation not connected to any object');
|
|
@@ -1583,7 +1583,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1583
1583
|
return block && !block.BLOCK_ANNOTATION_END();
|
|
1584
1584
|
});
|
|
1585
1585
|
if (hasUnclosedBlock) {
|
|
1586
|
-
this.contextError(pcx, 'unclosed-block-annotation', '
|
|
1586
|
+
this.contextError(pcx, 'unclosed-block-annotation', 'Multi-line annotation is not closed, add correctly indented "|##"');
|
|
1587
1587
|
}
|
|
1588
1588
|
else {
|
|
1589
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;
|
|
@@ -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;
|