@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.
Files changed (91) hide show
  1. package/dist/api/annotation-utils.d.ts +36 -0
  2. package/dist/api/annotation-utils.js +76 -0
  3. package/dist/api/core.js +3 -3
  4. package/dist/api/foundation/annotation.d.ts +115 -0
  5. package/dist/{annotation.js → api/foundation/annotation.js} +87 -42
  6. package/dist/api/foundation/compile.js +3 -3
  7. package/dist/api/foundation/core.d.ts +122 -29
  8. package/dist/api/foundation/core.js +185 -59
  9. package/dist/api/foundation/index.d.ts +1 -1
  10. package/dist/api/foundation/index.js +3 -2
  11. package/dist/api/foundation/runtime.js +2 -2
  12. package/dist/{taggable.d.ts → api/foundation/taggable.d.ts} +4 -4
  13. package/dist/api/foundation/types.d.ts +1 -1
  14. package/dist/connection/types.d.ts +3 -2
  15. package/dist/index.d.ts +9 -2
  16. package/dist/index.js +17 -4
  17. package/dist/{prefix.js → lang/annotation-prefix.js} +1 -1
  18. package/dist/lang/ast/expressions/expr-given.js +1 -1
  19. package/dist/lang/ast/field-space/dynamic-space.d.ts +1 -1
  20. package/dist/lang/ast/field-space/dynamic-space.js +2 -2
  21. package/dist/lang/ast/field-space/include-utils.d.ts +3 -3
  22. package/dist/lang/ast/field-space/query-spaces.js +2 -2
  23. package/dist/lang/ast/field-space/reference-field.js +5 -5
  24. package/dist/lang/ast/field-space/refined-space.d.ts +2 -2
  25. package/dist/lang/ast/field-space/refined-space.js +3 -3
  26. package/dist/lang/ast/field-space/rename-space-field.d.ts +2 -2
  27. package/dist/lang/ast/field-space/rename-space-field.js +4 -4
  28. package/dist/lang/ast/field-space/static-space.js +1 -1
  29. package/dist/lang/ast/query-elements/anonymous-query.d.ts +2 -2
  30. package/dist/lang/ast/query-elements/anonymous-query.js +3 -3
  31. package/dist/lang/ast/query-elements/query-arrow.js +2 -2
  32. package/dist/lang/ast/query-items/field-declaration.d.ts +2 -2
  33. package/dist/lang/ast/query-items/field-declaration.js +1 -1
  34. package/dist/lang/ast/query-items/field-references.d.ts +3 -3
  35. package/dist/lang/ast/query-properties/nest.js +2 -2
  36. package/dist/lang/ast/source-elements/composite-source.d.ts +2 -2
  37. package/dist/lang/ast/source-elements/refined-source.d.ts +2 -2
  38. package/dist/lang/ast/source-elements/sql-source.js +1 -1
  39. package/dist/lang/ast/source-elements/typed-source.js +7 -4
  40. package/dist/lang/ast/source-properties/join.d.ts +2 -2
  41. package/dist/lang/ast/source-properties/join.js +2 -2
  42. package/dist/lang/ast/source-properties/renames.d.ts +2 -2
  43. package/dist/lang/ast/source-properties/user-type-shape.d.ts +2 -2
  44. package/dist/lang/ast/source-properties/user-type-shape.js +7 -7
  45. package/dist/lang/ast/source-properties/view-field-declaration.d.ts +1 -1
  46. package/dist/lang/ast/source-properties/view-field-declaration.js +2 -2
  47. package/dist/lang/ast/source-query-elements/include-item.d.ts +3 -3
  48. package/dist/lang/ast/statements/define-given.d.ts +2 -2
  49. package/dist/lang/ast/statements/define-given.js +2 -2
  50. package/dist/lang/ast/statements/define-query.d.ts +2 -2
  51. package/dist/lang/ast/statements/define-query.js +2 -2
  52. package/dist/lang/ast/statements/define-source.d.ts +2 -2
  53. package/dist/lang/ast/statements/define-source.js +2 -2
  54. package/dist/lang/ast/statements/define-user-type.d.ts +2 -2
  55. package/dist/lang/ast/statements/define-user-type.js +1 -1
  56. package/dist/lang/ast/statements/import-statement.js +1 -1
  57. package/dist/lang/ast/types/annotation-elements.js +3 -3
  58. package/dist/lang/ast/types/definition-list.d.ts +3 -3
  59. package/dist/lang/ast/types/literal.d.ts +1 -1
  60. package/dist/lang/ast/types/malloy-element.d.ts +4 -4
  61. package/dist/lang/ast/types/malloy-element.js +15 -15
  62. package/dist/lang/ast/types/noteable.d.ts +5 -5
  63. package/dist/lang/ast/types/pipeline-comp.d.ts +2 -2
  64. package/dist/lang/ast/view-elements/reference-view.js +1 -1
  65. package/dist/lang/ast/view-elements/view-refine.js +1 -1
  66. package/dist/lang/composite-source-utils.d.ts +2 -2
  67. package/dist/lang/composite-source-utils.js +6 -6
  68. package/dist/lang/malloy-to-ast.d.ts +3 -3
  69. package/dist/lang/malloy-to-ast.js +5 -5
  70. package/dist/lang/malloy-to-stable-query.d.ts +2 -2
  71. package/dist/lang/parse-malloy.js +6 -6
  72. package/dist/lang/parse-tree-walkers/model-annotation-walker.d.ts +2 -2
  73. package/dist/lang/parse-tree-walkers/model-annotation-walker.js +2 -2
  74. package/dist/lang/prettify/index.js +1 -1
  75. package/dist/lang/prettify/leaf.js +2 -2
  76. package/dist/lang/translate-response.d.ts +2 -2
  77. package/dist/model/malloy_types.d.ts +29 -25
  78. package/dist/model/persist_utils.js +3 -3
  79. package/dist/model/query_model_impl.js +1 -1
  80. package/dist/model/query_node.js +8 -8
  81. package/dist/model/query_query.js +13 -13
  82. package/dist/model/source_def_utils.js +4 -4
  83. package/dist/run_sql_options.d.ts +5 -11
  84. package/dist/to_stable.d.ts +2 -2
  85. package/dist/to_stable.js +7 -7
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +4 -4
  89. package/dist/annotation.d.ts +0 -96
  90. /package/dist/{taggable.js → api/foundation/taggable.js} +0 -0
  91. /package/dist/{prefix.d.ts → lang/annotation-prefix.d.ts} +0 -0
@@ -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 annotation() {
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.annotation;
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
- * block annotations (`#" … "`) are emitted verbatim from source. We don't
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 block annotations ----
168
- // We don't own a SQL formatter. Annotation indentation is significant.
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 { Annotation, ModelDef } from '../model/malloy_types';
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
- modelAnnotation: Annotation;
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, HasAnnotation {
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, HasAnnotation {
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 HasAnnotation {
440
- annotation?: Annotation;
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, HasAnnotation {
500
+ export interface FieldBase extends NamedObject, Expression, ResultMetadata, HasAnnotations {
501
501
  accessModifier?: NonDefaultAccessModifierLabel | undefined;
502
502
  requiresGroupBy?: RequiredGroupBy[];
503
503
  ungroupings?: AggregateUngrouping[];
@@ -656,15 +656,15 @@ export interface Filtered {
656
656
  export interface TurtleSegment extends Filtered {
657
657
  name: string;
658
658
  }
659
- export interface Pipeline {
659
+ export interface Pipeline extends HasAnnotations, HasLocation {
660
660
  pipeline: PipeSegment[];
661
661
  }
662
- export interface Query extends Pipeline, Filtered, HasLocation, HasAnnotation {
662
+ export interface Query extends Pipeline, Filtered {
663
663
  type?: 'query';
664
664
  name?: string;
665
665
  structRef: StructRef;
666
666
  sourceArguments?: SafeRecord<Argument>;
667
- modelAnnotation?: Annotation;
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, HasAnnotation {
825
+ export interface TurtleDef extends NamedObject, Pipeline {
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, HasAnnotation {
833
+ interface StructDefBase extends HasLocation, NamedObject, HasAnnotations {
834
834
  type: string;
835
- modelAnnotation?: ModelAnnotation;
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 HasAnnotation {
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 HasAnnotation {
1097
+ export interface UserTypeFieldDef extends HasAnnotations {
1098
1098
  name: string;
1099
1099
  typeDef: AtomicTypeDef;
1100
1100
  }
1101
- export interface UserTypeDef extends NamedObject, HasAnnotation {
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
- annotation?: ModelAnnotation;
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
- /** Malloy source annotations attached to objects */
1133
- export interface Annotation {
1134
- inherits?: Annotation;
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 block annotations: characters of leading whitespace removed from each
1143
- * body line by the dedent pass. Used to map payload-parser error columns
1144
- * back to source (`source_col = indentStripped + parser_col` for body lines).
1145
- * Omitted for single-line notes and blocks with no common indent.
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 ModelAnnotation extends Annotation {
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, HasAnnotation {
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.annotation)
25
+ if (!source.annotations)
26
26
  return { persist: false, log: [] };
27
- const { tag, log } = new annotation_1.Annotations(source.annotation).parseAsTag('@');
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
- annotation: query.annotation,
179
+ annotations: query.annotations,
180
180
  queryTimezone: ret.structs[0].queryTimezone,
181
181
  defaultRowLimitAdded: addedDefaultRowLimit,
182
182
  };
@@ -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.modelAnnotation;
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, annotation, drillExpression } = f;
564
+ const { path, annotations, drillExpression } = f;
565
565
  const field = this.getFieldByName(path, f.at);
566
- if (annotation || drillExpression) {
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, annotation, drillExpression };
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, annotation, drillExpression };
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 annotation = turtleDef.annotation;
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
- annotation,
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.annotation && { annotation: structDef.annotation }),
407
- ...(structDef.modelAnnotation && {
408
- modelAnnotation: structDef.modelAnnotation,
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.annotation && { annotation: structDef.annotation }),
422
- ...(structDef.modelAnnotation && {
423
- modelAnnotation: structDef.modelAnnotation,
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 annotation = fOut.annotation;
454
+ const annotations = fOut.annotations;
455
455
  const common = {
456
456
  resultMetadata,
457
457
  location,
458
- annotation,
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.modelAnnotation) {
517
- outputStruct.modelAnnotation = this.parent.structDef.modelAnnotation;
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.annotation = fi.turtleDef.annotation;
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.modelAnnotation) {
1825
- ret.modelAnnotation = this.parent.structDef.modelAnnotation;
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
- annotation: base.annotation,
48
- modelAnnotation: base.modelAnnotation,
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
- annotation: base.annotation,
87
- modelAnnotation: base.modelAnnotation,
86
+ annotations: base.annotations,
87
+ modelAnnotations: base.modelAnnotations,
88
88
  fields: base.fields,
89
89
  // Filtered
90
90
  filterList: base.filterList,
@@ -1,16 +1,10 @@
1
- import type { Annotation, NamedObject, SourceComponentInfo } from './model/malloy_types';
2
- type SourceRefWithMetadata = NamedObject & {
3
- annotation?: Annotation;
4
- sourceComponentInfos?: SourceComponentInfo[];
5
- };
1
+ import type { AnnotationsDef } from './model/malloy_types';
6
2
  export interface RunSQLOptions {
7
3
  rowLimit?: number;
8
4
  abortSignal?: AbortSignal;
9
- modelAnnotation?: Annotation;
10
- queryAnnotation?: Annotation;
11
- clientMetadata?: {
12
- sourceRefWithMetadata?: SourceRefWithMetadata;
13
- };
5
+ /** Model annotations forwarded to the adapter (e.g. `##!` dialect flags). */
6
+ modelAnnotations?: AnnotationsDef;
7
+ /** Query annotations forwarded to the adapter. */
8
+ queryAnnotations?: AnnotationsDef;
14
9
  }
15
10
  export type QueryOptionsReader = RunSQLOptions | (() => RunSQLOptions);
16
- export {};
@@ -1,5 +1,5 @@
1
1
  import * as Malloy from '@malloydata/malloy-interfaces';
2
- import type { Annotation, FieldDef, ModelDef, ResultStructMetadataDef, SourceDef } from './model';
2
+ import type { AnnotationsDef, FieldDef, ModelDef, ResultStructMetadataDef, SourceDef } from './model';
3
3
  import { Tag } from '@malloydata/malloy-tag';
4
4
  export declare function sourceDefToSourceInfo(sourceDef: SourceDef): Malloy.SourceInfo;
5
5
  export declare function modelDefToModelInfo(modelDef: ModelDef): Malloy.ModelInfo;
@@ -8,7 +8,7 @@ export declare function modelDefToModelInfo(modelDef: ModelDef): Malloy.ModelInf
8
8
  * and the api surfaces. The stable shape carries the raw annotation strings;
9
9
  * routes are derivable at the consumer via `parsePrefix` (`./prefix.ts`).
10
10
  */
11
- export declare function toStableAnnotations(annot: Annotation | undefined): Malloy.Annotation[];
11
+ export declare function toStableAnnotations(annot: AnnotationsDef | undefined): Malloy.Annotation[];
12
12
  export declare function convertFieldInfos(source: SourceDef, fields: FieldDef[]): Malloy.FieldInfo[];
13
13
  export declare function writeLiteralToTag(tag: Tag, path: (string | number)[], literal: Malloy.LiteralValue): void;
14
14
  export declare function getResultStructMetadataAnnotation(field: SourceDef, resultMetadata: ResultStructMetadataDef): Malloy.Annotation | undefined;
package/dist/to_stable.js CHANGED
@@ -47,7 +47,7 @@ exports.writeLiteralToTag = writeLiteralToTag;
47
47
  exports.getResultStructMetadataAnnotation = getResultStructMetadataAnnotation;
48
48
  const Malloy = __importStar(require("@malloydata/malloy-interfaces"));
49
49
  const model_1 = require("./model");
50
- const annotation_1 = require("./annotation");
50
+ const annotation_1 = require("./api/foundation/annotation");
51
51
  const malloy_tag_1 = require("@malloydata/malloy-tag");
52
52
  function sourceDefToSourceInfo(sourceDef) {
53
53
  var _a;
@@ -78,7 +78,7 @@ function sourceDefToSourceInfo(sourceDef) {
78
78
  fields: convertFieldInfos(sourceDef, sourceDef.fields),
79
79
  },
80
80
  parameters,
81
- annotations: toStableAnnotations(sourceDef.annotation),
81
+ annotations: toStableAnnotations(sourceDef.annotations),
82
82
  };
83
83
  return sourceInfo;
84
84
  }
@@ -99,7 +99,7 @@ function modelDefToModelInfo(modelDef) {
99
99
  }
100
100
  else if (entry.type === 'query') {
101
101
  const outputStruct = (0, model_1.getResultStructDefForQuery)(modelDef, entry);
102
- const annotations = toStableAnnotations(entry.annotation);
102
+ const annotations = toStableAnnotations(entry.annotations);
103
103
  const resultMetadataAnnotation = outputStruct.resultMetadata
104
104
  ? getResultStructMetadataAnnotation(outputStruct, outputStruct.resultMetadata)
105
105
  : undefined;
@@ -120,7 +120,7 @@ function modelDefToModelInfo(modelDef) {
120
120
  }
121
121
  for (const query of modelDef.queryList) {
122
122
  const outputStruct = (0, model_1.getResultStructDefForQuery)(modelDef, query);
123
- const annotations = toStableAnnotations(query.annotation);
123
+ const annotations = toStableAnnotations(query.annotations);
124
124
  const resultMetadataAnnotation = outputStruct.resultMetadata
125
125
  ? getResultStructMetadataAnnotation(outputStruct, outputStruct.resultMetadata)
126
126
  : undefined;
@@ -189,7 +189,7 @@ function convertFieldInfos(source, fields) {
189
189
  const isPublic = field.accessModifier === undefined;
190
190
  if (!isPublic)
191
191
  continue;
192
- const rawAnnotations = toStableAnnotations(field.annotation);
192
+ const rawAnnotations = toStableAnnotations(field.annotations);
193
193
  const annotations = rawAnnotations.length > 0 ? rawAnnotations : undefined;
194
194
  if ((0, model_1.isTurtle)(field)) {
195
195
  const outputStruct = (0, model_1.getResultStructDefForView)(source, field);
@@ -451,8 +451,8 @@ function convertRecordType(field) {
451
451
  }
452
452
  }
453
453
  }
454
- if (f.annotation) {
455
- annotations.push(...toStableAnnotations(f.annotation));
454
+ if (f.annotations) {
455
+ annotations.push(...toStableAnnotations(f.annotations));
456
456
  }
457
457
  if ((0, model_1.isAtomic)(f)) {
458
458
  return {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.399";
1
+ export declare const MALLOY_VERSION = "0.0.401";
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MALLOY_VERSION = void 0;
4
4
  // generated with 'generate-version-file' script; do not edit manually
5
- exports.MALLOY_VERSION = '0.0.399';
5
+ exports.MALLOY_VERSION = '0.0.401';
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.399",
3
+ "version": "0.0.401",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  "generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
52
52
  },
53
53
  "dependencies": {
54
- "@malloydata/malloy-filter": "0.0.399",
55
- "@malloydata/malloy-interfaces": "0.0.399",
56
- "@malloydata/malloy-tag": "0.0.399",
54
+ "@malloydata/malloy-filter": "0.0.401",
55
+ "@malloydata/malloy-interfaces": "0.0.401",
56
+ "@malloydata/malloy-tag": "0.0.401",
57
57
  "@noble/hashes": "^1.8.0",
58
58
  "antlr4ts": "^0.5.0-alpha.4",
59
59
  "assert": "^2.0.0",
@@ -1,96 +0,0 @@
1
- import type { Tag } from '@malloydata/malloy-tag';
2
- import type { Annotation, DocumentLocation } from './model';
3
- import type { LogMessage } from './lang';
4
- /**
5
- * @deprecated Argument shape for the deprecated RegExp form of
6
- * {@link annotationToTag}. The RegExp form cannot see block annotations
7
- * (`#|`…`|#`). Pass a route string to `annotationToTag` instead, or use the
8
- * {@link Annotations} view on a tagged entity.
9
- */
10
- export interface TagParseSpec {
11
- prefix?: RegExp;
12
- }
13
- /** One annotation, unparsed — its raw text and where its content begins. */
14
- export interface AnnotationText {
15
- /** The annotation exactly as written — prefix + content. */
16
- rawText: string;
17
- /** Offset where the content begins; `rawText.slice(contentIndex)` is the content. */
18
- contentIndex: number;
19
- /** Where `rawText` begins in the source document. */
20
- at: DocumentLocation;
21
- /**
22
- * For block annotations: characters of leading whitespace removed from
23
- * each body line by the translator's dedent pass. A BYO parser that wants
24
- * source-mapped error columns adds this to the parser's reported column for
25
- * body lines (`source_col = indentStripped + parser_col`).
26
- */
27
- indentStripped?: number;
28
- }
29
- /** An {@link AnnotationText} that also carries its route (`''` is MOTLY). */
30
- export interface RoutedAnnotation extends AnnotationText {
31
- route: string;
32
- }
33
- /**
34
- * Collect annotations, using the shared prefix parser.
35
- * - no `route`: every annotation, each carrying its own `route` (the only way
36
- * to reach one whose prefix is malformed).
37
- * - a `route`: only annotations on that route, `route` omitted from each result
38
- * (you passed it); malformed prefixes excluded.
39
- */
40
- export declare function collectAnnotations(annote: Annotation | undefined): RoutedAnnotation[];
41
- export declare function collectAnnotations(annote: Annotation | undefined, route: string): AnnotationText[];
42
- /**
43
- * @deprecated The RegExp form cannot see block annotations (`#|`…`|#`). Use
44
- * `new Annotations(annote).texts(route)` instead, or the {@link Annotations}
45
- * view on a tagged entity (`entity.annotations.texts(route)`).
46
- */
47
- export declare function annotationToTaglines(annote: Annotation | undefined, prefix?: RegExp): string[];
48
- export interface MalloyTagParse {
49
- tag: Tag;
50
- log: LogMessage[];
51
- }
52
- /** Parse the annotations on `route` (default `''`, the MOTLY tag route) as MOTLY. */
53
- export declare function annotationToTag(annote: Annotation | undefined, route?: string): MalloyTagParse;
54
- /**
55
- * @deprecated The RegExp `prefix` form cannot see block annotations
56
- * (`#|`…`|#`) and cannot report content offsets for error mapping. Pass a route
57
- * string (the other overload), or use {@link Annotations.parseAsTag} on a
58
- * tagged entity.
59
- */
60
- export declare function annotationToTag(annote: Annotation | undefined, spec?: TagParseSpec): MalloyTagParse;
61
- /**
62
- * The route-aware annotation API for a tagged entity.
63
- *
64
- * An annotation has a *prefix* (everything from `#`/`##` up to the first
65
- * whitespace) that resolves to a *route* — a namespace key. Built-in routes:
66
- * `''` (MOTLY tags, the human default), `!` (compiler flags), `@` (persistence
67
- * directives), `"` (doc-string markdown). Apps stake their own routes with
68
- * brackets: `#(myApp) ...` is route `myApp`. The grammar (forms, bracket
69
- * pairs, malformation warnings) lives in `./prefix.ts`.
70
- *
71
- * All annotation reading lives here, written once; each tagged class only has
72
- * to say *where* its annotation is (by handing it to the constructor). Unlike
73
- * the deprecated RegExp readers (`tagParse`/`getTaglines`), this sees block
74
- * annotations.
75
- */
76
- export declare class Annotations {
77
- private readonly annote;
78
- constructor(annote: Annotation | undefined);
79
- /**
80
- * Raw annotation text strings (prefix + content) — all routes if `route` is
81
- * omitted, just that route's otherwise. The route-based successor to the
82
- * deprecated `getTaglines`. For source-mapped offsets (bring-your-own
83
- * parsers), see {@link forRoute}.
84
- */
85
- texts(route?: string): string[];
86
- /**
87
- * Your route's annotations as objects (`rawText` + `contentIndex` + `at`) —
88
- * the bring-your-own-parser door. A non-MOTLY app (e.g. JSON on its own
89
- * route) reads these to slice the content (`rawText.slice(contentIndex)`)
90
- * itself and map its parser's errors back to source via `at`. Malformed-prefix
91
- * annotations are excluded.
92
- */
93
- forRoute(route: string): AnnotationText[];
94
- /** Parse a route's annotations as a MOTLY tag. Default `''` is the tag route. */
95
- parseAsTag(route?: string): MalloyTagParse;
96
- }