@malloydata/malloy 0.0.400 → 0.0.402

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.
@@ -98,18 +98,12 @@ export declare class Annotations {
98
98
  */
99
99
  texts(route?: string): string[];
100
100
  /**
101
- * Your route's notes as {@link RoutedNote}s — for callers that parse the
102
- * payload with their own parser (instead of MOTLY). Read `.content` to
103
- * feed your parser, and `.at` + `.indentStripped` to map your parser's
104
- * errors back to source.
105
- *
106
- * `malformed-route` annotations are excluded (no clean route to resolve
107
- * to). `reserved-route` annotations are included — they parse to a real
108
- * route and the user got a compile-time warning. Route filtering is
109
- * level-blind (`#` and `##` both go to route `''`); the entity hands
110
- * you the annotations that apply at its level.
101
+ * Notes as {@link RoutedNote}s — for callers that parse the payload with
102
+ * their own parser (instead of MOTLY). Pass a route to filter; omit it
103
+ * to enumerate every annotation (the only way to reach malformed-prefix
104
+ * ones). `malformed-route` annotations are excluded when filtering.
111
105
  */
112
- forRoute(route: string): RoutedNote[];
106
+ forRoute(route?: string): RoutedNote[];
113
107
  /** Parse a route's annotations as a MOTLY tag. Default `''` is the tag route. */
114
108
  parseAsTag(route?: string): MalloyTagParse;
115
109
  }
@@ -167,16 +167,10 @@ class Annotations {
167
167
  return collectAnnotations(this.annote, route).map(a => a.text);
168
168
  }
169
169
  /**
170
- * Your route's notes as {@link RoutedNote}s — for callers that parse the
171
- * payload with their own parser (instead of MOTLY). Read `.content` to
172
- * feed your parser, and `.at` + `.indentStripped` to map your parser's
173
- * errors back to source.
174
- *
175
- * `malformed-route` annotations are excluded (no clean route to resolve
176
- * to). `reserved-route` annotations are included — they parse to a real
177
- * route and the user got a compile-time warning. Route filtering is
178
- * level-blind (`#` and `##` both go to route `''`); the entity hands
179
- * you the annotations that apply at its level.
170
+ * Notes as {@link RoutedNote}s — for callers that parse the payload with
171
+ * their own parser (instead of MOTLY). Pass a route to filter; omit it
172
+ * to enumerate every annotation (the only way to reach malformed-prefix
173
+ * ones). `malformed-route` annotations are excluded when filtering.
180
174
  */
181
175
  forRoute(route) {
182
176
  return collectAnnotations(this.annote, route);
@@ -1,5 +1,5 @@
1
1
  import type { LogMessage } from '../../lang';
2
- import type { BuildID, CompiledQuery, ConstantExpr, DocumentLocation, BooleanFieldDef, JSONFieldDef, NumberFieldDef, StringFieldDef, FilterCondition, Given as InternalGiven, GivenID, GivenTypeDef, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQueryDef, StructDef, TurtleDef, NativeUnsupportedFieldDef, ImportLocation, AnnotationsDef, NamedModelObject, AtomicFieldDef, DateFieldDef, ATimestampFieldDef, SourceDef, Argument, SourceComponentInfo, DocumentReference, PersistableSourceDef } from '../../model';
2
+ import type { BuildID, CompiledQuery, ConstantExpr, DocumentLocation, BooleanFieldDef, JSONFieldDef, NumberFieldDef, StringFieldDef, FilterCondition, Given as InternalGiven, GivenID, GivenTypeDef, Query as InternalQuery, Pipeline, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQueryDef, StructDef, TurtleDef, NativeUnsupportedFieldDef, ImportLocation, AnnotationsDef, NamedModelObject, AtomicFieldDef, DateFieldDef, ATimestampFieldDef, SourceDef, Argument, SourceComponentInfo, DocumentReference, PersistableSourceDef } from '../../model';
3
3
  import { QueryModel } from '../../model';
4
4
  import type { Dialect } from '../../dialect';
5
5
  import type { BuildGraph, CompileQueryOptions } from './types';
@@ -90,6 +90,16 @@ export type PreparedResultJSON = {
90
90
  query: CompiledQuery;
91
91
  modelDef: ModelDef;
92
92
  };
93
+ /**
94
+ * Identifier-only enumeration of a model's top-level queries.
95
+ * Internal: returned by `Model.queries()`, not exported. Callers pair
96
+ * the names with `getPreparedQueryByName` and the indices `0..unnamed-1`
97
+ * with `getPreparedQueryByIndex` to load any one of them.
98
+ */
99
+ interface ModelQueries {
100
+ named: string[];
101
+ unnamed: number;
102
+ }
93
103
  export declare class Explore extends Entity implements Taggable {
94
104
  protected readonly _structDef: StructDef;
95
105
  protected readonly _parentExplore?: Explore;
@@ -202,22 +212,22 @@ export declare class StringField extends AtomicField {
202
212
  private fieldStringDef;
203
213
  constructor(fieldStringDef: StringFieldDef, parent: Explore, source?: AtomicField);
204
214
  }
205
- export declare class Query extends Entity {
215
+ export declare class Query extends Entity implements Taggable {
206
216
  protected turtleDef: TurtleDef;
207
217
  private sourceQuery?;
208
218
  constructor(turtleDef: TurtleDef, parent?: Explore, source?: Query);
209
219
  get source(): Query | undefined;
210
220
  isIntrinsic(): boolean;
211
221
  get location(): DocumentLocation | undefined;
212
- }
213
- export declare class QueryField extends Query implements Taggable {
214
- protected parent: Explore;
215
- constructor(turtleDef: TurtleDef, parent: Explore, source?: Query);
216
222
  /** @deprecated Use `.annotations.parseAsTag(route)`. */
217
223
  tagParse(spec?: TagParseSpec): MalloyTagParse;
218
224
  /** @deprecated Use `.annotations.texts(route)`. */
219
225
  getTaglines(prefix?: RegExp): string[];
220
226
  get annotations(): Annotations;
227
+ }
228
+ export declare class QueryField extends Query {
229
+ protected parent: Explore;
230
+ constructor(turtleDef: TurtleDef, parent: Explore, source?: Query);
221
231
  isQueryField(): this is QueryField;
222
232
  isExploreField(): this is ExploreField;
223
233
  isAtomicField(): this is AtomicField;
@@ -392,9 +402,18 @@ export declare class Model implements Taggable {
392
402
  */
393
403
  get explores(): Explore[];
394
404
  /**
395
- * Get an array of `NamedQueryDef`s contained in the model.
405
+ * Enumerate the model's top-level queries by identifier.
396
406
  *
397
- * @return An array of `NamedQueryDef`s contained in the model.
407
+ * Returns the names of named queries (`query: foo is ...`) and the count
408
+ * of unnamed `run:` statements. Pair with {@link getPreparedQueryByName}
409
+ * and {@link getPreparedQueryByIndex} to load any of them — those are the
410
+ * only path to the query itself; this getter exposes only identifiers,
411
+ * not IR.
412
+ */
413
+ queries(): ModelQueries;
414
+ /**
415
+ * @deprecated Leaks IR. Use {@link queries} for enumeration and
416
+ * {@link getPreparedQueryByName} to load a named query.
398
417
  */
399
418
  get namedQueries(): NamedQueryDef[];
400
419
  get exportedExplores(): Explore[];
@@ -541,18 +560,29 @@ export declare class Given implements Taggable {
541
560
  getTaglines(prefix?: RegExp): string[];
542
561
  get annotations(): Annotations;
543
562
  }
544
- export declare class PreparedQuery implements Taggable {
563
+ /**
564
+ * Internal abstract base for Foundation wrappers around an IR `Pipeline`
565
+ * (an IR object that has a pipeline, annotations, and a source location).
566
+ * Owns the four `Taggable` accessors and a `location` getter, all reading
567
+ * from the wrapped IR. Not exported.
568
+ */
569
+ declare abstract class PipelineBase implements Taggable {
570
+ protected pipelineDef: Pipeline;
571
+ constructor(pipelineDef: Pipeline);
572
+ get annotations(): Annotations;
573
+ get location(): DocumentLocation | undefined;
574
+ /** @deprecated Use `.annotations.parseAsTag(route)`. */
575
+ tagParse(spec?: TagParseSpec): MalloyTagParse;
576
+ /** @deprecated Use `.annotations.texts(route)`. */
577
+ getTaglines(prefix?: RegExp): string[];
578
+ }
579
+ export declare class PreparedQuery extends PipelineBase {
545
580
  private _model;
546
581
  problems: LogMessage[];
547
582
  name?: string | undefined;
548
- _query: InternalQuery | NamedQueryDef;
549
583
  constructor(query: InternalQuery, _model: Model, problems: LogMessage[], name?: string | undefined);
584
+ get _query(): InternalQuery | NamedQueryDef;
550
585
  get _modelDef(): ModelDef;
551
- /** @deprecated Use `.annotations.parseAsTag(route)`. */
552
- tagParse(spec?: TagParseSpec): MalloyTagParse;
553
- /** @deprecated Use `.annotations.texts(route)`. */
554
- getTaglines(prefix?: RegExp): string[];
555
- get annotations(): Annotations;
556
586
  /**
557
587
  * Generate the SQL for this query.
558
588
  *
@@ -663,13 +663,6 @@ class Query extends Entity {
663
663
  get location() {
664
664
  return this.turtleDef.location;
665
665
  }
666
- }
667
- exports.Query = Query;
668
- class QueryField extends Query {
669
- constructor(turtleDef, parent, source) {
670
- super(turtleDef, parent, source);
671
- this.parent = parent;
672
- }
673
666
  /** @deprecated Use `.annotations.parseAsTag(route)`. */
674
667
  tagParse(spec) {
675
668
  return (0, annotation_1.annotationToTag)(this.turtleDef.annotations, spec);
@@ -681,6 +674,13 @@ class QueryField extends Query {
681
674
  get annotations() {
682
675
  return new annotation_1.Annotations(this.turtleDef.annotations);
683
676
  }
677
+ }
678
+ exports.Query = Query;
679
+ class QueryField extends Query {
680
+ constructor(turtleDef, parent, source) {
681
+ super(turtleDef, parent, source);
682
+ this.parent = parent;
683
+ }
684
684
  isQueryField() {
685
685
  return true;
686
686
  }
@@ -991,9 +991,26 @@ class Model {
991
991
  .map(structDef => new Explore(structDef));
992
992
  }
993
993
  /**
994
- * Get an array of `NamedQueryDef`s contained in the model.
994
+ * Enumerate the model's top-level queries by identifier.
995
995
  *
996
- * @return An array of `NamedQueryDef`s contained in the model.
996
+ * Returns the names of named queries (`query: foo is ...`) and the count
997
+ * of unnamed `run:` statements. Pair with {@link getPreparedQueryByName}
998
+ * and {@link getPreparedQueryByIndex} to load any of them — those are the
999
+ * only path to the query itself; this getter exposes only identifiers,
1000
+ * not IR.
1001
+ */
1002
+ queries() {
1003
+ const named = [];
1004
+ for (const object of Object.values(this.modelDef.contents)) {
1005
+ if (object.type === 'query') {
1006
+ named.push(object.name);
1007
+ }
1008
+ }
1009
+ return { named, unnamed: this.modelDef.queryList.length };
1010
+ }
1011
+ /**
1012
+ * @deprecated Leaks IR. Use {@link queries} for enumeration and
1013
+ * {@link getPreparedQueryByName} to load a named query.
997
1014
  */
998
1015
  get namedQueries() {
999
1016
  const isNamedQueryDef = (object) => object.type === 'query';
@@ -1259,26 +1276,43 @@ class Given {
1259
1276
  }
1260
1277
  }
1261
1278
  exports.Given = Given;
1262
- class PreparedQuery {
1263
- constructor(query, _model, problems, name) {
1264
- this._model = _model;
1265
- this.problems = problems;
1266
- this.name = name;
1267
- this._query = query;
1279
+ /**
1280
+ * Internal abstract base for Foundation wrappers around an IR `Pipeline`
1281
+ * (an IR object that has a pipeline, annotations, and a source location).
1282
+ * Owns the four `Taggable` accessors and a `location` getter, all reading
1283
+ * from the wrapped IR. Not exported.
1284
+ */
1285
+ class PipelineBase {
1286
+ constructor(pipelineDef) {
1287
+ this.pipelineDef = pipelineDef;
1268
1288
  }
1269
- get _modelDef() {
1270
- return this._model._modelDef;
1289
+ get annotations() {
1290
+ return new annotation_1.Annotations(this.pipelineDef.annotations);
1291
+ }
1292
+ get location() {
1293
+ return this.pipelineDef.location;
1271
1294
  }
1272
1295
  /** @deprecated Use `.annotations.parseAsTag(route)`. */
1273
1296
  tagParse(spec) {
1274
- return (0, annotation_1.annotationToTag)(this._query.annotations, spec);
1297
+ return (0, annotation_1.annotationToTag)(this.pipelineDef.annotations, spec);
1275
1298
  }
1276
1299
  /** @deprecated Use `.annotations.texts(route)`. */
1277
1300
  getTaglines(prefix) {
1278
- return (0, annotation_1.annotationToTaglines)(this._query.annotations, prefix);
1301
+ return (0, annotation_1.annotationToTaglines)(this.pipelineDef.annotations, prefix);
1279
1302
  }
1280
- get annotations() {
1281
- return new annotation_1.Annotations(this._query.annotations);
1303
+ }
1304
+ class PreparedQuery extends PipelineBase {
1305
+ constructor(query, _model, problems, name) {
1306
+ super(query);
1307
+ this._model = _model;
1308
+ this.problems = problems;
1309
+ this.name = name;
1310
+ }
1311
+ get _query() {
1312
+ return this.pipelineDef;
1313
+ }
1314
+ get _modelDef() {
1315
+ return this._model._modelDef;
1282
1316
  }
1283
1317
  /**
1284
1318
  * Generate the SQL for this query.
@@ -656,10 +656,10 @@ 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, HasAnnotations {
662
+ export interface Query extends Pipeline, Filtered {
663
663
  type?: 'query';
664
664
  name?: string;
665
665
  structRef: StructRef;
@@ -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, HasAnnotations {
825
+ export interface TurtleDef extends NamedObject, Pipeline {
826
826
  type: 'turtle';
827
827
  accessModifier?: NonDefaultAccessModifierLabel | undefined;
828
828
  refSummary?: RefSummary;
@@ -1,8 +1,4 @@
1
- import type { AnnotationsDef, NamedObject, SourceComponentInfo } from './model/malloy_types';
2
- type SourceRefWithMetadata = NamedObject & {
3
- annotations?: AnnotationsDef;
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;
@@ -10,9 +6,5 @@ export interface RunSQLOptions {
10
6
  modelAnnotations?: AnnotationsDef;
11
7
  /** Query annotations forwarded to the adapter. */
12
8
  queryAnnotations?: AnnotationsDef;
13
- clientMetadata?: {
14
- sourceRefWithMetadata?: SourceRefWithMetadata;
15
- };
16
9
  }
17
10
  export type QueryOptionsReader = RunSQLOptions | (() => RunSQLOptions);
18
- export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.400";
1
+ export declare const MALLOY_VERSION = "0.0.402";
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.400';
5
+ exports.MALLOY_VERSION = '0.0.402';
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.400",
3
+ "version": "0.0.402",
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.400",
55
- "@malloydata/malloy-interfaces": "0.0.400",
56
- "@malloydata/malloy-tag": "0.0.400",
54
+ "@malloydata/malloy-filter": "0.0.402",
55
+ "@malloydata/malloy-interfaces": "0.0.402",
56
+ "@malloydata/malloy-tag": "0.0.402",
57
57
  "@noble/hashes": "^1.8.0",
58
58
  "antlr4ts": "^0.5.0-alpha.4",
59
59
  "assert": "^2.0.0",