@malloydata/malloy 0.0.399 → 0.0.401
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 +122 -29
- package/dist/api/foundation/core.js +185 -59
- 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 +29 -25
- 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 +5 -11
- 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
|
@@ -29,7 +29,7 @@ class UserTypeMemberDef extends UserTypeMember {
|
|
|
29
29
|
typeDef: this.typeDef,
|
|
30
30
|
};
|
|
31
31
|
if (this.note) {
|
|
32
|
-
field.
|
|
32
|
+
field.annotations = this.note;
|
|
33
33
|
}
|
|
34
34
|
return field;
|
|
35
35
|
}
|
|
@@ -62,8 +62,8 @@ class UserTypeMemberIndirect extends UserTypeMember {
|
|
|
62
62
|
}
|
|
63
63
|
const fieldsFromReferencedType = modelEntry.entry.fields.map(f => {
|
|
64
64
|
const field = (0, malloy_types_1.mkFieldDef)(f.typeDef, f.name);
|
|
65
|
-
if (f.
|
|
66
|
-
field.
|
|
65
|
+
if (f.annotations) {
|
|
66
|
+
field.annotations = f.annotations;
|
|
67
67
|
}
|
|
68
68
|
return field;
|
|
69
69
|
});
|
|
@@ -76,12 +76,12 @@ class UserTypeMemberIndirect extends UserTypeMember {
|
|
|
76
76
|
}
|
|
77
77
|
const field = { name: this.name, typeDef };
|
|
78
78
|
if (this.note) {
|
|
79
|
-
field.
|
|
80
|
-
? { ...this.note, inherits: modelEntry.entry.
|
|
79
|
+
field.annotations = modelEntry.entry.annotations
|
|
80
|
+
? { ...this.note, inherits: modelEntry.entry.annotations }
|
|
81
81
|
: this.note;
|
|
82
82
|
}
|
|
83
|
-
else if (modelEntry.entry.
|
|
84
|
-
field.
|
|
83
|
+
else if (modelEntry.entry.annotations) {
|
|
84
|
+
field.annotations = { inherits: modelEntry.entry.annotations };
|
|
85
85
|
}
|
|
86
86
|
return field;
|
|
87
87
|
}
|
|
@@ -12,7 +12,7 @@ export declare class ViewFieldDeclaration extends MalloyElement implements Notea
|
|
|
12
12
|
elementType: string;
|
|
13
13
|
readonly isNoteableObj = true;
|
|
14
14
|
extendNote: typeof extendNoteMethod;
|
|
15
|
-
note?: model.
|
|
15
|
+
note?: model.AnnotationsDef;
|
|
16
16
|
constructor(name: string, view: View);
|
|
17
17
|
makeEntry(fs: DynamicSpace): void;
|
|
18
18
|
getName(): string;
|
|
@@ -44,13 +44,13 @@ class ViewFieldDeclaration extends malloy_element_1.MalloyElement {
|
|
|
44
44
|
return this.name;
|
|
45
45
|
}
|
|
46
46
|
getFieldDef(fs) {
|
|
47
|
-
const { pipeline,
|
|
47
|
+
const { pipeline, annotations } = this.view.pipelineComp(fs);
|
|
48
48
|
const checkedPipeline = (0, query_utils_1.detectAndRemovePartialStages)(pipeline, this);
|
|
49
49
|
const def = {
|
|
50
50
|
type: 'turtle',
|
|
51
51
|
name: this.name,
|
|
52
52
|
pipeline: checkedPipeline,
|
|
53
|
-
|
|
53
|
+
annotations: { ...this.note, inherits: annotations },
|
|
54
54
|
location: this.location,
|
|
55
55
|
};
|
|
56
56
|
return def;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MalloyElement } from '../types/malloy-element';
|
|
2
2
|
import type { AccessModifierFieldReference, FieldReference, WildcardFieldReference } from '../query-items/field-references';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AnnotationsDef } from '../../../model';
|
|
4
4
|
import type { Noteable } from '../types/noteable';
|
|
5
5
|
import { extendNoteMethod } from '../types/noteable';
|
|
6
6
|
export declare abstract class IncludeItem extends MalloyElement {
|
|
@@ -12,7 +12,7 @@ export declare class IncludeAccessItem extends IncludeItem implements Noteable {
|
|
|
12
12
|
elementType: string;
|
|
13
13
|
readonly isNoteableObj = true;
|
|
14
14
|
extendNote: typeof extendNoteMethod;
|
|
15
|
-
note?:
|
|
15
|
+
note?: AnnotationsDef;
|
|
16
16
|
constructor(kind: 'private' | 'public' | 'internal' | undefined, fields: IncludeListItem[]);
|
|
17
17
|
}
|
|
18
18
|
export declare class IncludeExceptItem extends IncludeItem {
|
|
@@ -27,6 +27,6 @@ export declare class IncludeListItem extends MalloyElement implements Noteable {
|
|
|
27
27
|
elementType: string;
|
|
28
28
|
readonly isNoteableObj = true;
|
|
29
29
|
extendNote: typeof extendNoteMethod;
|
|
30
|
-
note?:
|
|
30
|
+
note?: AnnotationsDef;
|
|
31
31
|
constructor(name: AccessModifierFieldReference | WildcardFieldReference, as: string | undefined);
|
|
32
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef, GivenTypeDef } from '../../../model/malloy_types';
|
|
2
2
|
import type { ConstantExpression } from '../expressions/constant-expression';
|
|
3
3
|
import type { DocStatement, Document } from '../types/malloy-element';
|
|
4
4
|
import { DocStatementList, MalloyElement } from '../types/malloy-element';
|
|
@@ -11,7 +11,7 @@ export declare class GivenDeclaration extends MalloyElement implements DocStatem
|
|
|
11
11
|
elementType: string;
|
|
12
12
|
readonly isNoteableObj = true;
|
|
13
13
|
extendNote: typeof extendNoteMethod;
|
|
14
|
-
note?:
|
|
14
|
+
note?: AnnotationsDef;
|
|
15
15
|
readonly default?: ConstantExpression;
|
|
16
16
|
constructor(name: string, typeDef: GivenTypeDef, defaultExpr?: ConstantExpression, inline?: boolean);
|
|
17
17
|
protected varInfo(): string;
|
|
@@ -173,7 +173,7 @@ class GivenDeclaration extends malloy_element_1.MalloyElement {
|
|
|
173
173
|
defaultText,
|
|
174
174
|
givenUsage,
|
|
175
175
|
location: this.location,
|
|
176
|
-
|
|
176
|
+
annotations: this.note,
|
|
177
177
|
...(this.inline ? { inline: true } : {}),
|
|
178
178
|
};
|
|
179
179
|
doc.documentGivens.set(id, givenIR);
|
|
@@ -195,7 +195,7 @@ class GivenDeclaration extends malloy_element_1.MalloyElement {
|
|
|
195
195
|
},
|
|
196
196
|
definition: {
|
|
197
197
|
type: (0, utils_1.typeDefToString)(this.typeDef),
|
|
198
|
-
|
|
198
|
+
annotations: this.note,
|
|
199
199
|
location: this.location,
|
|
200
200
|
defaultText,
|
|
201
201
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef } from '../../../model/malloy_types';
|
|
2
2
|
import type { DocStatement, Document } from '../types/malloy-element';
|
|
3
3
|
import { MalloyElement, DocStatementList } from '../types/malloy-element';
|
|
4
4
|
import type { Noteable } from '../types/noteable';
|
|
@@ -11,7 +11,7 @@ export declare class DefineQuery extends MalloyElement implements DocStatement,
|
|
|
11
11
|
constructor(name: string, queryExpr: SourceQueryElement);
|
|
12
12
|
readonly isNoteableObj = true;
|
|
13
13
|
extendNote: typeof extendNoteMethod;
|
|
14
|
-
note?:
|
|
14
|
+
note?: AnnotationsDef;
|
|
15
15
|
execute(doc: Document): void;
|
|
16
16
|
}
|
|
17
17
|
export declare class DefineQueryList extends DocStatementList {
|
|
@@ -52,8 +52,8 @@ class DefineQuery extends malloy_element_1.MalloyElement {
|
|
|
52
52
|
location: this.location,
|
|
53
53
|
};
|
|
54
54
|
if (this.note) {
|
|
55
|
-
entry.
|
|
56
|
-
? { ...this.note, inherits: entry.
|
|
55
|
+
entry.annotations = entry.annotations
|
|
56
|
+
? { ...this.note, inherits: entry.annotations }
|
|
57
57
|
: this.note;
|
|
58
58
|
}
|
|
59
59
|
doc.setEntry(this.name, { entry, exported: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef } from '../../../model/malloy_types';
|
|
2
2
|
import type { HasParameter } from '../parameters/has-parameter';
|
|
3
3
|
import type { DocStatement, Document } from '../types/malloy-element';
|
|
4
4
|
import { MalloyElement, DocStatementList } from '../types/malloy-element';
|
|
@@ -14,7 +14,7 @@ export declare class DefineSource extends MalloyElement implements DocStatement,
|
|
|
14
14
|
constructor(name: string, sourceExpr: SourceQueryElement | undefined, exported: boolean, parameters?: HasParameter[] | undefined);
|
|
15
15
|
readonly isNoteableObj = true;
|
|
16
16
|
extendNote: typeof extendNoteMethod;
|
|
17
|
-
note?:
|
|
17
|
+
note?: AnnotationsDef;
|
|
18
18
|
execute(doc: Document): void;
|
|
19
19
|
private deduplicatedParameters;
|
|
20
20
|
private validateParameterShadowing;
|
|
@@ -69,8 +69,8 @@ class DefineSource extends malloy_element_1.MalloyElement {
|
|
|
69
69
|
location: this.location,
|
|
70
70
|
};
|
|
71
71
|
if (this.note) {
|
|
72
|
-
entry.
|
|
73
|
-
? { ...this.note, inherits: structDef.
|
|
72
|
+
entry.annotations = structDef.annotations
|
|
73
|
+
? { ...this.note, inherits: structDef.annotations }
|
|
74
74
|
: this.note;
|
|
75
75
|
}
|
|
76
76
|
if ((0, malloy_types_1.isPersistableSourceDef)(entry)) {
|
|
@@ -2,7 +2,7 @@ import type { DocStatement, Document } from '../types/malloy-element';
|
|
|
2
2
|
import { MalloyElement, DocStatementList } from '../types/malloy-element';
|
|
3
3
|
import type { Noteable } from '../types/noteable';
|
|
4
4
|
import { extendNoteMethod } from '../types/noteable';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AnnotationsDef, UserTypeFieldDef } from '../../../model/malloy_types';
|
|
6
6
|
import type { UserTypeMember } from '../source-properties/user-type-shape';
|
|
7
7
|
import { UserTypeShape } from '../source-properties/user-type-shape';
|
|
8
8
|
export declare class ExtendedUserTypeShape extends UserTypeShape {
|
|
@@ -19,7 +19,7 @@ export declare class DefineUserType extends MalloyElement implements DocStatemen
|
|
|
19
19
|
constructor(name: string, shapeDef: UserTypeShape, exported: boolean);
|
|
20
20
|
readonly isNoteableObj = true;
|
|
21
21
|
extendNote: typeof extendNoteMethod;
|
|
22
|
-
note?:
|
|
22
|
+
note?: AnnotationsDef;
|
|
23
23
|
execute(doc: Document): void;
|
|
24
24
|
}
|
|
25
25
|
export declare class DefineUserTypeList extends DocStatementList {
|
|
@@ -166,7 +166,7 @@ class ImportStatement extends malloy_element_1.ListOf {
|
|
|
166
166
|
location: importOne.location,
|
|
167
167
|
definition: {
|
|
168
168
|
type: (0, utils_1.typeDefToString)(givenIR.type),
|
|
169
|
-
|
|
169
|
+
annotations: givenIR.annotations,
|
|
170
170
|
location: givenIR.location,
|
|
171
171
|
defaultText: givenIR.defaultText,
|
|
172
172
|
},
|
|
@@ -54,10 +54,10 @@ class ModelAnnotation extends ObjectAnnotation {
|
|
|
54
54
|
this.logError('restricted-construct-forbidden', `\`${line}\` cannot be used in a restricted query — compiler-flag annotations are not permitted.`, { at: note.at });
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
if (doc.
|
|
58
|
-
doc.
|
|
57
|
+
if (doc.annotations.notes === undefined) {
|
|
58
|
+
doc.annotations.notes = [];
|
|
59
59
|
}
|
|
60
|
-
doc.
|
|
60
|
+
doc.annotations.notes.push(...this.notes);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
exports.ModelAnnotation = ModelAnnotation;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef } from '../../../model';
|
|
2
2
|
import type { MalloyElement } from './malloy-element';
|
|
3
3
|
import { ListOf } from './malloy-element';
|
|
4
4
|
import type { Noteable } from '../types/noteable';
|
|
5
5
|
export declare abstract class DefinitionList<DT extends MalloyElement> extends ListOf<DT> implements Noteable {
|
|
6
6
|
readonly isNoteableObj = true;
|
|
7
|
-
note?:
|
|
8
|
-
extendNote(ext: Partial<
|
|
7
|
+
note?: AnnotationsDef;
|
|
8
|
+
extendNote(ext: Partial<AnnotationsDef>): void;
|
|
9
9
|
distributeAnnotation(): void;
|
|
10
10
|
protected newContents(): void;
|
|
11
11
|
}
|
|
@@ -4,4 +4,4 @@ import { LiteralDay, LiteralHour, LiteralMonth, LiteralTimestamp, LiteralYear }
|
|
|
4
4
|
import { ExprNumber } from '../expressions/expr-number';
|
|
5
5
|
import type { ExpressionDef } from './expression-def';
|
|
6
6
|
export type Literal = LiteralTimestamp | LiteralHour | LiteralMonth | LiteralDay | LiteralYear | ExprNumber | ExprString | Boolean;
|
|
7
|
-
export declare function isLiteral(value: ExpressionDef): value is ExprString |
|
|
7
|
+
export declare function isLiteral(value: ExpressionDef): value is ExprString | Boolean | LiteralTimestamp | LiteralHour | LiteralDay | LiteralMonth | LiteralYear | ExprNumber;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnnotationsDef, DocumentLocation, DocumentReference, Given, ModelDef, ModelAnnotationsDef, NamedModelObject, Query, SourceID, SourceRegistryValue, StructDef } from '../../../model/malloy_types';
|
|
2
2
|
import { Tag } from '@malloydata/malloy-tag';
|
|
3
3
|
import type { LogMessageOptions, MessageLogger, MessageParameterType, MessageCode } from '../../parse-log';
|
|
4
4
|
import type { MalloyTranslation } from '../../parse-malloy';
|
|
@@ -101,7 +101,7 @@ export declare class DocStatementList extends ListOf<DocStatement | DocStatement
|
|
|
101
101
|
execCursor: number;
|
|
102
102
|
readonly isNoteableObj = true;
|
|
103
103
|
extendNote: typeof extendNoteMethod;
|
|
104
|
-
note?:
|
|
104
|
+
note?: AnnotationsDef;
|
|
105
105
|
noteCursor: number;
|
|
106
106
|
executeList(doc: Document): ModelDataRequest;
|
|
107
107
|
}
|
|
@@ -116,7 +116,7 @@ export declare class Document extends MalloyElement implements NameSpace {
|
|
|
116
116
|
statements: DocStatementList;
|
|
117
117
|
didInitModel: boolean;
|
|
118
118
|
modelWasModified: boolean;
|
|
119
|
-
|
|
119
|
+
annotations: AnnotationsDef;
|
|
120
120
|
experiments: Tag;
|
|
121
121
|
constructor(statements: (DocStatement | DocStatementList)[]);
|
|
122
122
|
initModelDef(extendingModelDef: ModelDef | undefined): void;
|
|
@@ -126,7 +126,7 @@ export declare class Document extends MalloyElement implements NameSpace {
|
|
|
126
126
|
private checkGivenAliasCollisions;
|
|
127
127
|
private checkQueryGivenSatisfiability;
|
|
128
128
|
hasAnnotation(): boolean;
|
|
129
|
-
currentModelAnnotation():
|
|
129
|
+
currentModelAnnotation(): ModelAnnotationsDef | undefined;
|
|
130
130
|
modelDef(): ModelDef;
|
|
131
131
|
getEntry(str: string): ModelEntry | undefined;
|
|
132
132
|
setEntry(str: string, ent: ModelEntry): void;
|
|
@@ -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;
|