@malloydata/malloy 0.0.398 → 0.0.400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) 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/index.d.ts +1 -0
  30. package/dist/lang/ast/index.js +1 -0
  31. package/dist/lang/ast/query-elements/anonymous-query.d.ts +2 -2
  32. package/dist/lang/ast/query-elements/anonymous-query.js +3 -3
  33. package/dist/lang/ast/query-elements/query-arrow.js +2 -2
  34. package/dist/lang/ast/query-items/field-declaration.d.ts +2 -2
  35. package/dist/lang/ast/query-items/field-declaration.js +1 -1
  36. package/dist/lang/ast/query-items/field-references.d.ts +3 -3
  37. package/dist/lang/ast/query-properties/nest.js +2 -2
  38. package/dist/lang/ast/source-elements/composite-source.d.ts +2 -2
  39. package/dist/lang/ast/source-elements/refined-source.d.ts +2 -2
  40. package/dist/lang/ast/source-elements/sql-source.js +1 -1
  41. package/dist/lang/ast/source-elements/typed-source.js +7 -4
  42. package/dist/lang/ast/source-properties/join.d.ts +2 -2
  43. package/dist/lang/ast/source-properties/join.js +2 -2
  44. package/dist/lang/ast/source-properties/renames.d.ts +2 -2
  45. package/dist/lang/ast/source-properties/user-type-shape.d.ts +2 -2
  46. package/dist/lang/ast/source-properties/user-type-shape.js +7 -7
  47. package/dist/lang/ast/source-properties/view-field-declaration.d.ts +1 -1
  48. package/dist/lang/ast/source-properties/view-field-declaration.js +2 -2
  49. package/dist/lang/ast/source-query-elements/include-item.d.ts +3 -3
  50. package/dist/lang/ast/statements/define-given.d.ts +2 -2
  51. package/dist/lang/ast/statements/define-given.js +2 -2
  52. package/dist/lang/ast/statements/define-query.d.ts +2 -2
  53. package/dist/lang/ast/statements/define-query.js +2 -2
  54. package/dist/lang/ast/statements/define-source.d.ts +2 -2
  55. package/dist/lang/ast/statements/define-source.js +2 -2
  56. package/dist/lang/ast/statements/define-user-type.d.ts +2 -2
  57. package/dist/lang/ast/statements/define-user-type.js +1 -1
  58. package/dist/lang/ast/statements/export-statement.d.ts +12 -0
  59. package/dist/lang/ast/statements/export-statement.js +53 -0
  60. package/dist/lang/ast/statements/import-statement.js +1 -1
  61. package/dist/lang/ast/types/annotation-elements.js +3 -3
  62. package/dist/lang/ast/types/definition-list.d.ts +3 -3
  63. package/dist/lang/ast/types/literal.d.ts +1 -1
  64. package/dist/lang/ast/types/malloy-element.d.ts +5 -4
  65. package/dist/lang/ast/types/malloy-element.js +20 -17
  66. package/dist/lang/ast/types/noteable.d.ts +5 -5
  67. package/dist/lang/ast/types/pipeline-comp.d.ts +2 -2
  68. package/dist/lang/ast/view-elements/reference-view.js +1 -1
  69. package/dist/lang/ast/view-elements/view-refine.js +1 -1
  70. package/dist/lang/composite-source-utils.d.ts +2 -2
  71. package/dist/lang/composite-source-utils.js +6 -6
  72. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +124 -123
  73. package/dist/lang/lib/Malloy/MalloyLexer.js +1418 -1411
  74. package/dist/lang/lib/Malloy/MalloyParser.d.ts +302 -274
  75. package/dist/lang/lib/Malloy/MalloyParser.js +2748 -2557
  76. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +22 -0
  77. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +14 -0
  78. package/dist/lang/malloy-to-ast.d.ts +4 -3
  79. package/dist/lang/malloy-to-ast.js +12 -5
  80. package/dist/lang/malloy-to-stable-query.d.ts +2 -2
  81. package/dist/lang/parse-log.d.ts +3 -0
  82. package/dist/lang/parse-malloy.js +6 -6
  83. package/dist/lang/parse-tree-walkers/model-annotation-walker.d.ts +2 -2
  84. package/dist/lang/parse-tree-walkers/model-annotation-walker.js +2 -2
  85. package/dist/lang/prettify/index.js +1 -1
  86. package/dist/lang/prettify/leaf.js +2 -2
  87. package/dist/lang/translate-response.d.ts +2 -2
  88. package/dist/model/filter_compilers.js +1 -1
  89. package/dist/model/malloy_types.d.ts +28 -24
  90. package/dist/model/persist_utils.js +3 -3
  91. package/dist/model/query_model_impl.js +1 -1
  92. package/dist/model/query_node.js +8 -8
  93. package/dist/model/query_query.js +13 -13
  94. package/dist/model/source_def_utils.js +4 -4
  95. package/dist/run_sql_options.d.ts +6 -4
  96. package/dist/to_stable.d.ts +2 -2
  97. package/dist/to_stable.js +7 -7
  98. package/dist/version.d.ts +1 -1
  99. package/dist/version.js +1 -1
  100. package/package.json +4 -4
  101. package/dist/annotation.d.ts +0 -96
  102. /package/dist/{taggable.js → api/foundation/taggable.js} +0 -0
  103. /package/dist/{prefix.d.ts → lang/annotation-prefix.d.ts} +0 -0
@@ -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.398";
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.398';
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.398",
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.398",
55
- "@malloydata/malloy-interfaces": "0.0.398",
56
- "@malloydata/malloy-tag": "0.0.398",
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
- }