@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.
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 +80 -17
  8. package/dist/api/foundation/core.js +135 -43
  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 +28 -24
  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 +6 -4
  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
@@ -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,13 +1,15 @@
1
- import type { Annotation, NamedObject, SourceComponentInfo } from './model/malloy_types';
1
+ import type { AnnotationsDef, NamedObject, SourceComponentInfo } from './model/malloy_types';
2
2
  type SourceRefWithMetadata = NamedObject & {
3
- annotation?: Annotation;
3
+ annotations?: AnnotationsDef;
4
4
  sourceComponentInfos?: SourceComponentInfo[];
5
5
  };
6
6
  export interface RunSQLOptions {
7
7
  rowLimit?: number;
8
8
  abortSignal?: AbortSignal;
9
- modelAnnotation?: Annotation;
10
- queryAnnotation?: Annotation;
9
+ /** Model annotations forwarded to the adapter (e.g. `##!` dialect flags). */
10
+ modelAnnotations?: AnnotationsDef;
11
+ /** Query annotations forwarded to the adapter. */
12
+ queryAnnotations?: AnnotationsDef;
11
13
  clientMetadata?: {
12
14
  sourceRefWithMetadata?: SourceRefWithMetadata;
13
15
  };
@@ -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.400";
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.400';
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.400",
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.400",
55
+ "@malloydata/malloy-interfaces": "0.0.400",
56
+ "@malloydata/malloy-tag": "0.0.400",
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
- }