@malloydata/malloy 0.0.165-dev240813195925 → 0.0.165-dev240813215606
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/connection/base_connection.d.ts +24 -0
- package/dist/connection/base_connection.js +20 -0
- package/dist/connection/index.d.ts +2 -0
- package/dist/connection/index.js +19 -0
- package/dist/connection/types.d.ts +105 -0
- package/dist/connection/types.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/malloy.d.ts +2 -1
- package/dist/model/malloy_query.d.ts +1 -1
- package/dist/runtime_types.d.ts +0 -105
- package/package.json +6 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MalloyQueryData, QueryRunStats, SQLBlock, StructDef } from '../model/malloy_types';
|
|
2
|
+
import { RunSQLOptions } from '../run_sql_options';
|
|
3
|
+
import { Connection, FetchSchemaOptions, PersistSQLResults, PooledConnection, StreamingConnection } from './types';
|
|
4
|
+
export declare abstract class BaseConnection implements Connection {
|
|
5
|
+
abstract runSQL(sql: string, options?: RunSQLOptions | undefined): Promise<MalloyQueryData>;
|
|
6
|
+
abstract get name(): string;
|
|
7
|
+
abstract get dialectName(): string;
|
|
8
|
+
abstract fetchSchemaForSQLBlock(block: SQLBlock, options: FetchSchemaOptions): Promise<{
|
|
9
|
+
structDef: StructDef;
|
|
10
|
+
error?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
error: string;
|
|
13
|
+
structDef?: undefined;
|
|
14
|
+
}>;
|
|
15
|
+
abstract fetchSchemaForTables(tables: Record<string, string>, options: FetchSchemaOptions): Promise<{
|
|
16
|
+
schemas: Record<string, StructDef>;
|
|
17
|
+
errors: Record<string, string>;
|
|
18
|
+
}>;
|
|
19
|
+
isPool(): this is PooledConnection;
|
|
20
|
+
canPersist(): this is PersistSQLResults;
|
|
21
|
+
canStream(): this is StreamingConnection;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
estimateQueryCost(_sqlCommand: string): Promise<QueryRunStats>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseConnection = void 0;
|
|
4
|
+
class BaseConnection {
|
|
5
|
+
isPool() {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
canPersist() {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
canStream() {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
async close() { }
|
|
15
|
+
async estimateQueryCost(_sqlCommand) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BaseConnection = BaseConnection;
|
|
20
|
+
//# sourceMappingURL=base_connection.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./base_connection"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RunSQLOptions } from '../run_sql_options';
|
|
2
|
+
import { Annotation, MalloyQueryData, QueryDataRow, QueryRunStats, SQLBlock, StructDef } from '../model/malloy_types';
|
|
3
|
+
import { Dialect } from '../dialect';
|
|
4
|
+
/**
|
|
5
|
+
* Options passed to fetchSchema methods.
|
|
6
|
+
*/
|
|
7
|
+
export interface FetchSchemaOptions {
|
|
8
|
+
refreshTimestamp?: number;
|
|
9
|
+
modelAnnotation?: Annotation;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An object capable of reading schemas for given table names.
|
|
13
|
+
*/
|
|
14
|
+
export interface InfoConnection {
|
|
15
|
+
/**
|
|
16
|
+
* Fetch schemas for multiple tables.
|
|
17
|
+
*
|
|
18
|
+
* @param tables The names of tables to fetch schemas for, represented
|
|
19
|
+
* as a map of keys to table names.
|
|
20
|
+
* @return A mapping of table keys to schemas.
|
|
21
|
+
*/
|
|
22
|
+
fetchSchemaForTables(tables: Record<string, string>, options: FetchSchemaOptions): Promise<{
|
|
23
|
+
schemas: Record<string, StructDef>;
|
|
24
|
+
errors: Record<string, string>;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch schemas an SQL blocks
|
|
28
|
+
*
|
|
29
|
+
* @param block The SQL blocks to fetch schemas for.
|
|
30
|
+
* @return A mapping of SQL block names to schemas.
|
|
31
|
+
*/
|
|
32
|
+
fetchSchemaForSQLBlock(block: SQLBlock, options: FetchSchemaOptions): Promise<{
|
|
33
|
+
structDef: StructDef;
|
|
34
|
+
error?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
error: string;
|
|
37
|
+
structDef?: undefined;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* The name of the connection.
|
|
41
|
+
*/
|
|
42
|
+
get name(): string;
|
|
43
|
+
}
|
|
44
|
+
export type ConnectionParameterValue = string | number | boolean | Array<ConnectionParameterValue>;
|
|
45
|
+
export interface ConnectionParameter {
|
|
46
|
+
name: string;
|
|
47
|
+
label: string;
|
|
48
|
+
type: 'string' | 'number' | 'boolean';
|
|
49
|
+
isOptional?: boolean;
|
|
50
|
+
isSecret?: boolean;
|
|
51
|
+
defaultValue?: ConnectionParameterValue;
|
|
52
|
+
}
|
|
53
|
+
export type ConnectionConfigSchema = ConnectionParameter[];
|
|
54
|
+
export interface ConnectionConfig {
|
|
55
|
+
name: string;
|
|
56
|
+
[key: string]: ConnectionParameterValue | undefined;
|
|
57
|
+
}
|
|
58
|
+
export interface ConnectionFactory {
|
|
59
|
+
connectionName: string;
|
|
60
|
+
configSchema: ConnectionConfigSchema;
|
|
61
|
+
createConnection(connectionConfig: ConnectionConfig, dialectRegistrar?: (dialect: Dialect) => void): Connection & TestableConnection;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An object capable of running SQL.
|
|
65
|
+
*/
|
|
66
|
+
export interface Connection extends InfoConnection {
|
|
67
|
+
/**
|
|
68
|
+
* Run some SQL and yield results.
|
|
69
|
+
*
|
|
70
|
+
* @param sql The SQL to run.
|
|
71
|
+
* @param options.pageSize Maximum number of results to return at once.
|
|
72
|
+
* @return The rows of data resulting from running the given SQL query
|
|
73
|
+
* and the total number of rows available.
|
|
74
|
+
*/
|
|
75
|
+
runSQL(sql: string, options?: RunSQLOptions): Promise<MalloyQueryData>;
|
|
76
|
+
isPool(): this is PooledConnection;
|
|
77
|
+
canPersist(): this is PersistSQLResults;
|
|
78
|
+
canStream(): this is StreamingConnection;
|
|
79
|
+
close(): Promise<void>;
|
|
80
|
+
estimateQueryCost(sqlCommand: string): Promise<QueryRunStats>;
|
|
81
|
+
get dialectName(): string;
|
|
82
|
+
}
|
|
83
|
+
export interface TestableConnection extends Connection {
|
|
84
|
+
test(): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
export interface PooledConnection extends Connection {
|
|
87
|
+
drain(): Promise<void>;
|
|
88
|
+
isPool(): true;
|
|
89
|
+
}
|
|
90
|
+
export interface PersistSQLResults extends Connection {
|
|
91
|
+
manifestTemporaryTable(sqlCommand: string): Promise<string>;
|
|
92
|
+
}
|
|
93
|
+
export interface StreamingConnection extends Connection {
|
|
94
|
+
runSQLStream(sqlCommand: string, options?: RunSQLOptions): AsyncIterableIterator<QueryDataRow>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A mapping of connection names to connections.
|
|
98
|
+
*/
|
|
99
|
+
export interface LookupConnection<T extends InfoConnection> {
|
|
100
|
+
/**
|
|
101
|
+
* @param connectionName The name of the connection for which a `Connection` is required.
|
|
102
|
+
* @return A promise to a `Connection` for the connection named `connectionName`.
|
|
103
|
+
*/
|
|
104
|
+
lookupConnection(connectionName?: string): Promise<T>;
|
|
105
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ 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, } from './malloy';
|
|
8
8
|
export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, Loggable, ModelMaterializer, DocumentSymbol, ResultJSON, PreparedResultMaterializer, SQLBlockMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, } from './malloy';
|
|
9
9
|
export type { QueryOptionsReader, RunSQLOptions } from './run_sql_options';
|
|
10
|
-
export type {
|
|
10
|
+
export type { ModelString, ModelURL, QueryString, QueryURL, URLReader, } from './runtime_types';
|
|
11
|
+
export type { Connection, ConnectionConfig, ConnectionFactory, ConnectionParameter, ConnectionParameterValue, ConnectionConfigSchema, FetchSchemaOptions, InfoConnection, LookupConnection, PersistSQLResults, PooledConnection, TestableConnection, StreamingConnection, } from './connection/types';
|
|
11
12
|
export { toAsyncGenerator } from './connection_utils';
|
|
12
13
|
export { type TagParse, Tag, type TagDict } from './tags';
|
package/dist/malloy.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { RunSQLOptions } from './run_sql_options';
|
|
|
3
3
|
import { DocumentCompletion as DocumentCompletionDefinition, DocumentSymbol as DocumentSymbolDefinition, LogMessage, MalloyTranslator } from './lang';
|
|
4
4
|
import { DocumentHelpContext } from './lang/parse-tree-walkers/document-help-context-walker';
|
|
5
5
|
import { CompiledQuery, DocumentLocation, DocumentReference, FieldBooleanDef, FieldDateDef, FieldJSONDef, FieldNumberDef, FieldStringDef, FieldTimestampDef, FieldTypeDef, FilterExpression, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQuery, QueryData, QueryDataRow, QueryResult, SQLBlock, SQLBlockSource, SQLBlockStructDef, SearchIndexResult, SearchValueMapResult, StructDef, TurtleDef, FeldNativeUnsupportedDef, QueryRunStats, ImportLocation, Annotation } from './model';
|
|
6
|
-
import {
|
|
6
|
+
import { ModelString, ModelURL, QueryString, QueryURL, URLReader } from './runtime_types';
|
|
7
|
+
import { Connection, InfoConnection, LookupConnection } from './connection/types';
|
|
7
8
|
import { Tag, TagParse, TagParseSpec, Taggable } from './tags';
|
|
8
9
|
import { Dialect } from './dialect';
|
|
9
10
|
export interface Loggable {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dialect, DialectFieldList } from '../dialect';
|
|
2
2
|
import { AggregateFragment, AggregateFunctionType, Annotation, CompiledQuery, DialectFragment, Expr, FieldDef, FieldFragment, Filtered, FilterExpression, FilterFragment, FunctionCallFragment, FunctionOverloadDef, FunctionParameterDef, JoinRelationship, ModelDef, OrderBy, OutputFieldFragment, Parameter, ParameterFragment, PipeSegment, Query, QueryFieldDef, QuerySegment, ResultMetadataDef, ResultStructMetadataDef, SearchIndexResult, SourceReferenceFragment, SegmentFieldDef, SpreadFragment, SQLExpressionFragment, SqlStringFragment, StructDef, StructRef, TurtleDef, UngroupFragment, FunctionOrderBy, Argument } from './malloy_types';
|
|
3
|
-
import { Connection } from '../
|
|
3
|
+
import { Connection } from '../connection/types';
|
|
4
4
|
import { AndChain } from './utils';
|
|
5
5
|
import { QueryInfo } from '../dialect/dialect';
|
|
6
6
|
interface TurtleDefPlus extends TurtleDef, Filtered {
|
package/dist/runtime_types.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { RunSQLOptions } from './run_sql_options';
|
|
2
|
-
import { Annotation, MalloyQueryData, QueryDataRow, QueryRunStats, SQLBlock, StructDef } from './model/malloy_types';
|
|
3
|
-
import { Dialect } from './dialect';
|
|
4
1
|
/**
|
|
5
2
|
* The contents of a Malloy query document.
|
|
6
3
|
*/
|
|
@@ -29,105 +26,3 @@ export interface URLReader {
|
|
|
29
26
|
*/
|
|
30
27
|
readURL: (url: URL) => Promise<string>;
|
|
31
28
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Options passed to fetchSchema methods.
|
|
34
|
-
*/
|
|
35
|
-
export interface FetchSchemaOptions {
|
|
36
|
-
refreshTimestamp?: number;
|
|
37
|
-
modelAnnotation?: Annotation;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* An object capable of reading schemas for given table names.
|
|
41
|
-
*/
|
|
42
|
-
export interface InfoConnection {
|
|
43
|
-
/**
|
|
44
|
-
* Fetch schemas for multiple tables.
|
|
45
|
-
*
|
|
46
|
-
* @param tables The names of tables to fetch schemas for, represented
|
|
47
|
-
* as a map of keys to table names.
|
|
48
|
-
* @return A mapping of table keys to schemas.
|
|
49
|
-
*/
|
|
50
|
-
fetchSchemaForTables(tables: Record<string, string>, options: FetchSchemaOptions): Promise<{
|
|
51
|
-
schemas: Record<string, StructDef>;
|
|
52
|
-
errors: Record<string, string>;
|
|
53
|
-
}>;
|
|
54
|
-
/**
|
|
55
|
-
* Fetch schemas an SQL blocks
|
|
56
|
-
*
|
|
57
|
-
* @param block The SQL blocks to fetch schemas for.
|
|
58
|
-
* @return A mapping of SQL block names to schemas.
|
|
59
|
-
*/
|
|
60
|
-
fetchSchemaForSQLBlock(block: SQLBlock, options: FetchSchemaOptions): Promise<{
|
|
61
|
-
structDef: StructDef;
|
|
62
|
-
error?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
error: string;
|
|
65
|
-
structDef?: undefined;
|
|
66
|
-
}>;
|
|
67
|
-
/**
|
|
68
|
-
* The name of the connection.
|
|
69
|
-
*/
|
|
70
|
-
get name(): string;
|
|
71
|
-
}
|
|
72
|
-
export type ConnectionParameterValue = string | number | boolean | Array<ConnectionParameterValue>;
|
|
73
|
-
export interface ConnectionParameter {
|
|
74
|
-
name: string;
|
|
75
|
-
label: string;
|
|
76
|
-
type: 'string' | 'number' | 'boolean';
|
|
77
|
-
isOptional?: boolean;
|
|
78
|
-
isSecret?: boolean;
|
|
79
|
-
defaultValue?: ConnectionParameterValue;
|
|
80
|
-
}
|
|
81
|
-
export type ConnectionConfigSchema = ConnectionParameter[];
|
|
82
|
-
export interface ConnectionConfig {
|
|
83
|
-
name: string;
|
|
84
|
-
[key: string]: ConnectionParameterValue | undefined;
|
|
85
|
-
}
|
|
86
|
-
export interface ConnectionFactory {
|
|
87
|
-
connectionName: string;
|
|
88
|
-
configSchema: ConnectionConfigSchema;
|
|
89
|
-
createConnection(connectionConfig: ConnectionConfig, dialectRegistrar?: (dialect: Dialect) => void): Connection & TestableConnection;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* An object capable of running SQL.
|
|
93
|
-
*/
|
|
94
|
-
export interface Connection extends InfoConnection {
|
|
95
|
-
/**
|
|
96
|
-
* Run some SQL and yield results.
|
|
97
|
-
*
|
|
98
|
-
* @param sql The SQL to run.
|
|
99
|
-
* @param options.pageSize Maximum number of results to return at once.
|
|
100
|
-
* @return The rows of data resulting from running the given SQL query
|
|
101
|
-
* and the total number of rows available.
|
|
102
|
-
*/
|
|
103
|
-
runSQL(sql: string, options?: RunSQLOptions): Promise<MalloyQueryData>;
|
|
104
|
-
isPool(): this is PooledConnection;
|
|
105
|
-
canPersist(): this is PersistSQLResults;
|
|
106
|
-
canStream(): this is StreamingConnection;
|
|
107
|
-
close(): Promise<void>;
|
|
108
|
-
estimateQueryCost(sqlCommand: string): Promise<QueryRunStats>;
|
|
109
|
-
get dialectName(): string;
|
|
110
|
-
}
|
|
111
|
-
export interface TestableConnection extends Connection {
|
|
112
|
-
test(): Promise<void>;
|
|
113
|
-
}
|
|
114
|
-
export interface PooledConnection extends Connection {
|
|
115
|
-
drain(): Promise<void>;
|
|
116
|
-
isPool(): true;
|
|
117
|
-
}
|
|
118
|
-
export interface PersistSQLResults extends Connection {
|
|
119
|
-
manifestTemporaryTable(sqlCommand: string): Promise<string>;
|
|
120
|
-
}
|
|
121
|
-
export interface StreamingConnection extends Connection {
|
|
122
|
-
runSQLStream(sqlCommand: string, options?: RunSQLOptions): AsyncIterableIterator<QueryDataRow>;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* A mapping of connection names to connections.
|
|
126
|
-
*/
|
|
127
|
-
export interface LookupConnection<T extends InfoConnection> {
|
|
128
|
-
/**
|
|
129
|
-
* @param connectionName The name of the connection for which a `Connection` is required.
|
|
130
|
-
* @return A promise to a `Connection` for the connection named `connectionName`.
|
|
131
|
-
*/
|
|
132
|
-
lookupConnection(connectionName?: string): Promise<T>;
|
|
133
|
-
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.165-
|
|
3
|
+
"version": "0.0.165-dev240813215606",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
7
|
-
"./test": "./dist/test/index.js"
|
|
7
|
+
"./test": "./dist/test/index.js",
|
|
8
|
+
"./connection": "./dist/connection/index.js"
|
|
8
9
|
},
|
|
9
10
|
"typesVersions": {
|
|
10
11
|
"*": {
|
|
@@ -13,6 +14,9 @@
|
|
|
13
14
|
],
|
|
14
15
|
"test": [
|
|
15
16
|
"./dist/test/index.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"connection": [
|
|
19
|
+
"./dist/connection/index.d.ts"
|
|
16
20
|
]
|
|
17
21
|
}
|
|
18
22
|
},
|