@malloydata/malloy 0.0.6 → 0.0.7-221110172722

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { QueryDataRow, ModelDef, Fragment, Query, StructDef, StructRelationship, NamedStructDefs, MalloyQueryData, AtomicFieldType as AtomicFieldTypeInner, DateUnit, ExtractUnit, TimestampUnit, TimeFieldType, QueryData, FieldTypeDef, Expr, DialectFragment, TimeValue, FilterExpression, SQLBlock, FieldDef, FilteredAliasedName, PipeSegment, QueryFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, } from "./model";
1
+ export type { QueryDataRow, Fragment, StructDef, StructRelationship, NamedStructDefs, MalloyQueryData, AtomicFieldType as AtomicFieldTypeInner, DateUnit, ExtractUnit, TimestampUnit, TimeFieldType, QueryData, FieldTypeDef, Expr, DialectFragment, TimeValue, FilterExpression, SQLBlock, FieldDef, FilteredAliasedName, PipeSegment, QueryFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, NamedQuery, } from "./model";
2
2
  export { Segment, isFilteredAliasedName, } from "./model";
3
3
  export { HighlightType, MalloyTranslator, } from "./lang";
4
4
  export type { LogMessage, TranslateResponse } from "./lang";
package/dist/malloy.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { InfoConnection } from ".";
3
3
  import { DocumentHighlight as DocumentHighlightDefinition, DocumentSymbol as DocumentSymbolDefinition, DocumentCompletion as DocumentCompletionDefinition, LogMessage, MalloyTranslator } from "./lang";
4
4
  import { DocumentHelpContext } from "./lang/parse-tree-walkers/document-help-context-walker";
5
- import { CompiledQuery, FieldBooleanDef, FieldDateDef, FieldNumberDef, FieldStringDef, FieldTimestampDef, FieldTypeDef, FilterExpression, ModelDef, Query as InternalQuery, QueryData, QueryDataRow, QueryResult, StructDef, TurtleDef, SQLBlock, DocumentReference, DocumentPosition as ModelDocumentPosition, SearchIndexResult, SearchValueMapResult } from "./model";
5
+ import { CompiledQuery, FieldBooleanDef, FieldDateDef, FieldNumberDef, FieldStringDef, FieldTimestampDef, FieldTypeDef, FilterExpression, ModelDef, Query as InternalQuery, QueryData, QueryDataRow, QueryResult, StructDef, TurtleDef, SQLBlock, DocumentReference, DocumentPosition as ModelDocumentPosition, SearchIndexResult, SearchValueMapResult, NamedQuery } from "./model";
6
6
  import { LookupConnection, ModelString, ModelURL, QueryString, QueryURL, URLReader, Connection } from "./runtime_types";
7
7
  export interface Loggable {
8
8
  debug: (message?: any, ...optionalParams: any[]) => void;
@@ -206,9 +206,9 @@ export declare class Model {
206
206
  * A prepared query which has all the necessary information to produce its SQL.
207
207
  */
208
208
  export declare class PreparedQuery {
209
- private _modelDef;
210
- private _query;
211
- private name?;
209
+ _modelDef: ModelDef;
210
+ _query: InternalQuery | NamedQuery;
211
+ name?: string;
212
212
  constructor(query: InternalQuery, model: ModelDef, name?: string);
213
213
  /**
214
214
  * Generate the SQL for this query.
@@ -217,6 +217,10 @@ export declare class PreparedQuery {
217
217
  */
218
218
  get preparedResult(): PreparedResult;
219
219
  get dialect(): string;
220
+ /**
221
+ * Get the flattened version of a query -- one that does not have a `pipeHead`.
222
+ */
223
+ getFlattenedQuery(defaultName: string): PreparedQuery;
220
224
  }
221
225
  export declare function parseTableURI(tableURI: string): {
222
226
  connectionName?: string;
package/dist/malloy.js CHANGED
@@ -435,6 +435,23 @@ class PreparedQuery {
435
435
  }
436
436
  return source.dialect;
437
437
  }
438
+ /**
439
+ * Get the flattened version of a query -- one that does not have a `pipeHead`.
440
+ */
441
+ getFlattenedQuery(defaultName) {
442
+ let structRef = this._query.structRef;
443
+ if (typeof structRef !== "string") {
444
+ structRef = structRef.as || structRef.name;
445
+ }
446
+ const queryModel = new model_1.QueryModel(this._modelDef);
447
+ const queryStruct = queryModel.getStructByName(structRef);
448
+ const turtleDef = queryStruct.flattenTurtleDef({
449
+ name: defaultName,
450
+ ...this._query,
451
+ type: "turtle",
452
+ });
453
+ return new PreparedQuery({ ...turtleDef, structRef, type: "query" }, this._modelDef, this.name || turtleDef.as || turtleDef.name);
454
+ }
438
455
  }
439
456
  exports.PreparedQuery = PreparedQuery;
440
457
  function parseTableURI(tableURI) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.6",
3
+ "version": "0.0.7-221110172722",
4
4
  "license": "GPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",