@malloydata/malloy 0.0.293 → 0.0.294

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/api/util.js CHANGED
@@ -216,11 +216,15 @@ function wrapResult(result) {
216
216
  .set(['query_name'], result.resultExplore.name)
217
217
  .toString(),
218
218
  });
219
+ const modelAnnotations = (0, annotation_1.annotationToTaglines)(result._modelDef.annotation).map(l => ({
220
+ value: l,
221
+ }));
219
222
  return {
220
223
  schema,
221
224
  data: mapData(result.data.toObject(), schema),
222
225
  connection_name: result.connectionName,
223
226
  annotations: annotations.length > 0 ? annotations : undefined,
227
+ model_annotations: modelAnnotations.length > 0 ? modelAnnotations : undefined,
224
228
  query_timezone: result.data.field.queryTimezone,
225
229
  sql: result.sql,
226
230
  };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, SnowflakeDialect, MySQLDialect, registerDialect, arg, qtz, overload, minScalar, anyExprType, minAggregate, maxScalar, sql, makeParam, param, variadicParam, literal, spread, Dialect, TinyParser, } from './dialect';
2
2
  export type { DialectFieldList, DialectFunctionOverloadDef, QueryInfo, MalloyStandardFunctionImplementations, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint, TinyToken, } from './dialect';
3
- export type { QueryDataRow, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, Argument, Parameter, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryResultDef, QueryRunStats, QueryScalar, NamedQuery, NamedModelObject, ExpressionType, FunctionDef, FunctionOverloadDef, FunctionParameterDef, ExpressionValueType, TypeDesc, FunctionParamTypeDesc, DocumentLocation, DocumentRange, DocumentPosition, Sampling, Annotation, BasicAtomicTypeDef, BasicAtomicDef, AtomicTypeDef, AtomicFieldDef, ArrayDef, ArrayTypeDef, RecordTypeDef, RepeatedRecordTypeDef, RecordDef, RepeatedRecordDef, RecordLiteralNode, StringLiteralNode, ArrayLiteralNode, } from './model';
3
+ export type { QueryDataRow, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, Argument, Parameter, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryResultDef, QueryRunStats, QueryScalar, NamedQuery, NamedModelObject, ExpressionType, FunctionDef, FunctionOverloadDef, FunctionParameterDef, ExpressionValueType, TypeDesc, FunctionParamTypeDesc, DocumentLocation, DocumentRange, DocumentPosition, Sampling, Annotation, BasicAtomicTypeDef, BasicAtomicDef, AtomicTypeDef, AtomicFieldDef, ArrayDef, ArrayTypeDef, RecordTypeDef, RepeatedRecordTypeDef, RecordDef, RepeatedRecordDef, RecordLiteralNode, StringLiteralNode, ArrayLiteralNode, SourceComponentInfo, } from './model';
4
4
  export { isSourceDef, Segment, isBasicAtomic, isJoined, isJoinedSource, isSamplingEnable, isSamplingPercent, isSamplingRows, isRepeatedRecord, isBasicArray, mkArrayDef, mkFieldDef, expressionIsAggregate, expressionIsAnalytic, expressionIsCalculation, expressionIsScalar, expressionIsUngroupedAggregate, indent, composeSQLExpr, isTimestampUnit, isDateUnit, } from './model';
5
5
  export { malloyToQuery, MalloyTranslator, } from './lang';
6
6
  export type { LogMessage, TranslateResponse } from './lang';
7
7
  export { Model, Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, PreparedResult, Result, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, InMemoryModelCache, CacheManager, } from './malloy';
8
- export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, Loggable, ModelMaterializer, DocumentTablePath, DocumentSymbol, ResultJSON, PreparedResultJSON, PreparedResultMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, ModelCache, CachedModel, DateField, TimestampField, SourceComponentInfo, } from './malloy';
8
+ export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, Loggable, ModelMaterializer, DocumentTablePath, DocumentSymbol, ResultJSON, PreparedResultJSON, PreparedResultMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, ModelCache, CachedModel, DateField, TimestampField, } from './malloy';
9
9
  export type { QueryOptionsReader, RunSQLOptions } from './run_sql_options';
10
10
  export type { EventStream, ModelString, ModelURL, QueryString, QueryURL, URLReader, InvalidationKey, } from './runtime_types';
11
11
  export type { Connection, ConnectionConfig, ConnectionFactory, ConnectionParameter, ConnectionParameterValue, ConnectionConfigSchema, FetchSchemaOptions, InfoConnection, LookupConnection, PersistSQLResults, PooledConnection, TestableConnection, StreamingConnection, } from './connection/types';
package/dist/malloy.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { RunSQLOptions } from './run_sql_options';
2
2
  import type { DocumentCompletion as DocumentCompletionDefinition, DocumentSymbol as DocumentSymbolDefinition, LogMessage } from './lang';
3
3
  import { MalloyTranslator } from './lang';
4
4
  import type { DocumentHelpContext } from './lang/parse-tree-walkers/document-help-context-walker';
5
- import type { CompiledQuery, DocumentLocation, DocumentReference, BooleanFieldDef, JSONFieldDef, NumberFieldDef, StringFieldDef, FilterCondition, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQuery, QueryData, QueryDataRow, QueryResult, SearchIndexResult, SearchValueMapResult, StructDef, TurtleDef, NativeUnsupportedFieldDef, QueryRunStats, ImportLocation, Annotation, SQLSourceDef, AtomicFieldDef, DateFieldDef, TimestampFieldDef, SourceDef, QueryToMaterialize, Argument, TableSourceDef } from './model';
5
+ import type { CompiledQuery, DocumentLocation, DocumentReference, BooleanFieldDef, JSONFieldDef, NumberFieldDef, StringFieldDef, FilterCondition, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQuery, QueryData, QueryDataRow, QueryResult, SearchIndexResult, SearchValueMapResult, StructDef, TurtleDef, NativeUnsupportedFieldDef, QueryRunStats, ImportLocation, Annotation, SQLSourceDef, AtomicFieldDef, DateFieldDef, TimestampFieldDef, SourceDef, QueryToMaterialize, Argument, TableSourceDef, SourceComponentInfo } from './model';
6
6
  import type { EventStream, InvalidationKey, ModelString, ModelURL, QueryString, QueryURL, URLReader } from './runtime_types';
7
7
  import type { Connection, FetchSchemaOptions, InfoConnection, LookupConnection } from './connection/types';
8
8
  import type { Tag } from '@malloydata/malloy-tag';
@@ -19,15 +19,6 @@ export interface Loggable {
19
19
  warn: (message?: any, ...optionalParams: any[]) => void;
20
20
  error: (message?: any, ...optionalParams: any[]) => void;
21
21
  }
22
- export type SourceComponentInfo = {
23
- type: 'table';
24
- tableName: string;
25
- sourceID: string;
26
- } | {
27
- type: 'sql';
28
- selectStatement: string;
29
- sourceID: string;
30
- };
31
22
  export interface ParseOptions {
32
23
  importBaseURL?: URL;
33
24
  testEnvironment?: boolean;
@@ -629,7 +620,7 @@ export declare class Explore extends Entity implements Taggable {
629
620
  get location(): DocumentLocation | undefined;
630
621
  private collectSourceComponents;
631
622
  /**
632
- * THIS IS A HIGHLY EXPERIMENTAL API AND MAY VANISH OR CHAGE WITHOUT NOTICE
623
+ * THIS IS A HIGHLY EXPERIMENTAL API AND MAY VANISH OR CHANGE WITHOUT NOTICE
633
624
  */
634
625
  getSourceComponents(): SourceComponentInfo[];
635
626
  }
package/dist/malloy.js CHANGED
@@ -1283,10 +1283,11 @@ class Explore extends Entity {
1283
1283
  }
1284
1284
  if (isSourceComponent(structDef)) {
1285
1285
  if (structDef.type === 'table') {
1286
- // Generate sourceID based on connection and table name
1286
+ // Generate componentID based on connection and table name
1287
1287
  sources.push({
1288
1288
  type: 'table',
1289
1289
  tableName: structDef.tablePath,
1290
+ componentID: `${structDef.connection}:${structDef.tablePath}`,
1290
1291
  sourceID: `${structDef.connection}:${structDef.tablePath}`,
1291
1292
  });
1292
1293
  }
@@ -1294,6 +1295,7 @@ class Explore extends Entity {
1294
1295
  sources.push({
1295
1296
  type: 'sql',
1296
1297
  selectStatement: structDef.selectStr,
1298
+ componentID: `${structDef.connection}:${structDef.selectStr}`,
1297
1299
  sourceID: `${structDef.connection}:${structDef.selectStr}`,
1298
1300
  });
1299
1301
  }
@@ -1314,12 +1316,13 @@ class Explore extends Entity {
1314
1316
  // If we can't compile the query, use a placeholder
1315
1317
  sql = `-- Could not compile SQL for query ${structDef.query.name || 'unnamed query'}: ${error instanceof Error ? error.message : String(error)}`;
1316
1318
  }
1317
- // Generate sourceID based on connection and SQL
1318
- const sourceID = `${structDef.connection}:${sql}`;
1319
+ // Generate componentID based on connection and SQL
1320
+ const componentID = `${structDef.connection}:${sql}`;
1319
1321
  sources.push({
1320
1322
  type: 'sql',
1321
1323
  selectStatement: sql,
1322
- sourceID: sourceID,
1324
+ componentID: componentID,
1325
+ sourceID: componentID,
1323
1326
  });
1324
1327
  }
1325
1328
  }
@@ -1335,15 +1338,20 @@ class Explore extends Entity {
1335
1338
  return sources;
1336
1339
  }
1337
1340
  /**
1338
- * THIS IS A HIGHLY EXPERIMENTAL API AND MAY VANISH OR CHAGE WITHOUT NOTICE
1341
+ * THIS IS A HIGHLY EXPERIMENTAL API AND MAY VANISH OR CHANGE WITHOUT NOTICE
1339
1342
  */
1340
1343
  getSourceComponents() {
1341
1344
  const uniqueSources = {};
1342
1345
  if ((0, model_1.isSourceDef)(this.structDef)) {
1343
1346
  const allSources = this.collectSourceComponents(this.structDef);
1344
- // Deduplicate sources using sourceID as the key
1347
+ // Deduplicate sources using componentID as the key
1345
1348
  for (const source of allSources) {
1346
- uniqueSources[source.sourceID] = source;
1349
+ if (source.componentID) {
1350
+ uniqueSources[source.componentID] = source;
1351
+ }
1352
+ else if (source.sourceID) {
1353
+ uniqueSources[source.sourceID] = source;
1354
+ }
1347
1355
  }
1348
1356
  }
1349
1357
  // Return the deduplicated sources as an array
@@ -665,6 +665,17 @@ export type SourceDef = TableSourceDef | SQLSourceDef | QuerySourceDef | QueryRe
665
665
  /** Is this the "FROM" table of a query tree */
666
666
  export declare function isBaseTable(def: StructDef): def is SourceDef;
667
667
  export type StructDef = SourceDef | RecordDef | ArrayDef;
668
+ export type SourceComponentInfo = {
669
+ type: 'table';
670
+ tableName: string;
671
+ componentID?: string;
672
+ sourceID?: string;
673
+ } | {
674
+ type: 'sql';
675
+ selectStatement: string;
676
+ componentID?: string;
677
+ sourceID?: string;
678
+ };
668
679
  export type NonAtomicType = Exclude<JoinElementType, 'array' | 'record'> | 'turtle' | 'null' | 'duration' | 'regular expression' | 'filter expression';
669
680
  export interface NonAtomicTypeDef {
670
681
  type: NonAtomicType;
@@ -1,9 +1,17 @@
1
- import type { Annotation } from './model/malloy_types';
1
+ import type { Annotation, NamedObject, SourceComponentInfo } from './model/malloy_types';
2
+ type SourceRefWithMetadata = NamedObject & {
3
+ annotation?: Annotation;
4
+ sourceComponentInfos?: SourceComponentInfo[];
5
+ };
2
6
  export interface RunSQLOptions {
3
7
  rowLimit?: number;
4
8
  abortSignal?: AbortSignal;
5
9
  modelAnnotation?: Annotation;
6
10
  queryAnnotation?: Annotation;
7
11
  replaceMaterializedReferences?: boolean;
12
+ clientMetadata?: {
13
+ sourceRefWithMetadata?: SourceRefWithMetadata;
14
+ };
8
15
  }
9
16
  export type QueryOptionsReader = RunSQLOptions | (() => RunSQLOptions);
17
+ export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.293";
1
+ export declare const MALLOY_VERSION = "0.0.294";
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.293';
5
+ exports.MALLOY_VERSION = '0.0.294';
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.293",
3
+ "version": "0.0.294",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -41,9 +41,9 @@
41
41
  "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"
42
42
  },
43
43
  "dependencies": {
44
- "@malloydata/malloy-filter": "0.0.293",
45
- "@malloydata/malloy-interfaces": "0.0.293",
46
- "@malloydata/malloy-tag": "0.0.293",
44
+ "@malloydata/malloy-filter": "0.0.294",
45
+ "@malloydata/malloy-interfaces": "0.0.294",
46
+ "@malloydata/malloy-tag": "0.0.294",
47
47
  "antlr4ts": "^0.5.0-alpha.4",
48
48
  "assert": "^2.0.0",
49
49
  "jaro-winkler": "^0.2.8",