@malloydata/malloy 0.0.62 → 0.0.63-dev230728193024

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
@@ -5,7 +5,7 @@ export type { LogMessage, TranslateResponse } from './lang';
5
5
  export { Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, Result, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, } from './malloy';
6
6
  export type { Model, PreparedQuery, PreparedResult, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, ModelMaterializer, DocumentSymbol, DocumentHighlight, ResultJSON, PreparedResultMaterializer, SQLBlockMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, } from './malloy';
7
7
  export type { RunSQLOptions } from './run_sql_options';
8
- export type { URLReader, InfoConnection, LookupConnection, Connection, QueryString, ModelString, QueryURL, ModelURL, PooledConnection, TestableConnection, PersistSQLResults, StreamingConnection, } from './runtime_types';
8
+ export type { URLReader, InfoConnection, LookupConnection, Connection, DialectProviderConnection, QueryString, ModelString, QueryURL, ModelURL, PooledConnection, TestableConnection, PersistSQLResults, StreamingConnection, } from './runtime_types';
9
9
  export type { Loggable } from './malloy';
10
10
  export { toAsyncGenerator } from './connection_utils';
11
11
  export { Tags, type MalloyTags, type MalloyTagProperties } from './tags';
package/dist/malloy.d.ts CHANGED
@@ -461,6 +461,12 @@ export declare class FixedConnectionMap implements LookupConnection<Connection>
461
461
  * @throws An `Error` if no connection with the given name exists.
462
462
  */
463
463
  getConnection(connectionName?: string): Promise<Connection>;
464
+ /**
465
+ * Gets a list of registered connections.
466
+ *
467
+ * @return The list of registered connections.
468
+ */
469
+ listConnections(): Connection[];
464
470
  lookupConnection(connectionName?: string): Promise<Connection>;
465
471
  static fromArray(connections: Connection[]): FixedConnectionMap;
466
472
  }
package/dist/malloy.js CHANGED
@@ -27,6 +27,7 @@ const lang_1 = require("./lang");
27
27
  const model_1 = require("./model");
28
28
  const luxon_1 = require("luxon");
29
29
  const tags_1 = require("./tags");
30
+ const dialect_1 = require("./dialect");
30
31
  class Malloy {
31
32
  // TODO load from file built during release
32
33
  static get version() {
@@ -825,6 +826,14 @@ class FixedConnectionMap {
825
826
  throw new Error(`No connection found with name ${connectionName}.`);
826
827
  }
827
828
  }
829
+ /**
830
+ * Gets a list of registered connections.
831
+ *
832
+ * @return The list of registered connections.
833
+ */
834
+ listConnections() {
835
+ return Array.from(this.connections.values());
836
+ }
828
837
  async lookupConnection(connectionName) {
829
838
  return this.getConnection(connectionName);
830
839
  }
@@ -1415,6 +1424,7 @@ class Runtime {
1415
1424
  else {
1416
1425
  connections = {
1417
1426
  lookupConnection: () => Promise.resolve(arg),
1427
+ listConnections: () => [arg],
1418
1428
  };
1419
1429
  }
1420
1430
  }
@@ -1426,6 +1436,11 @@ class Runtime {
1426
1436
  }
1427
1437
  this._urlReader = urlReader;
1428
1438
  this._connections = connections;
1439
+ for (const connection of this._connections.listConnections()) {
1440
+ if (connection.providesDialect()) {
1441
+ (0, dialect_1.registerDialect)(connection.dialect());
1442
+ }
1443
+ }
1429
1444
  }
1430
1445
  /**
1431
1446
  * @return The `URLReader` for this runtime instance.
@@ -1,5 +1,6 @@
1
1
  import { RunSQLOptions } from './run_sql_options';
2
2
  import { MalloyQueryData, QueryDataRow, QueryRunStats, SQLBlock, StructDef } from './model/malloy_types';
3
+ import { Dialect } from './dialect';
3
4
  /**
4
5
  * The contents of a Malloy query document.
5
6
  */
@@ -77,6 +78,7 @@ export interface Connection extends InfoConnection {
77
78
  isPool(): this is PooledConnection;
78
79
  canPersist(): this is PersistSQLResults;
79
80
  canStream(): this is StreamingConnection;
81
+ providesDialect(): this is DialectProviderConnection;
80
82
  close(): Promise<void>;
81
83
  estimateQueryCost(sqlCommand: string): Promise<QueryRunStats>;
82
84
  }
@@ -95,6 +97,9 @@ export interface StreamingConnection extends Connection {
95
97
  rowLimit?: number;
96
98
  }): AsyncIterableIterator<QueryDataRow>;
97
99
  }
100
+ export interface DialectProviderConnection extends Connection {
101
+ dialect(): Dialect;
102
+ }
98
103
  /**
99
104
  * A mapping of connection names to connections.
100
105
  */
@@ -104,4 +109,8 @@ export interface LookupConnection<T extends InfoConnection> {
104
109
  * @return A promise to a `Connection` for the connection named `connectionName`.
105
110
  */
106
111
  lookupConnection(connectionName?: string): Promise<T>;
112
+ /**
113
+ * @return A list of registered connections.
114
+ */
115
+ listConnections(): T[];
107
116
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.62",
3
+ "version": "0.0.63-dev230728193024",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",