semanticdb-v2 2.0.0-alpha.6 → 2.0.0-alpha.7
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/README.md +108 -0
- package/dist/executor/connection-registry.d.ts +1 -12
- package/dist/index.d.ts +2 -1
- package/dist/normalizer/core.d.ts +9 -0
- package/dist/physical/clickhouse-provider.d.ts +15 -1
- package/dist/physical/connection-registry.d.ts +13 -0
- package/dist/physical/dameng-provider.d.ts +6 -1
- package/dist/physical/databricks-provider.d.ts +6 -1
- package/dist/physical/db-connector.d.ts +23 -0
- package/dist/physical/index.d.ts +4 -1
- package/dist/physical/maxcompute-provider.d.ts +8 -1
- package/dist/physical/mysql-protocol-provider.d.ts +4 -1
- package/dist/physical/oracle-provider.d.ts +6 -1
- package/dist/physical/postgresql-provider.d.ts +6 -1
- package/dist/physical/provider.d.ts +45 -0
- package/dist/physical/snowflake-provider.d.ts +5 -1
- package/dist/physical/sqlserver-provider.d.ts +5 -1
- package/dist/physical/table-description.d.ts +5 -0
- package/dist/physical/table-discovery.d.ts +10 -0
- package/dist/semanticdb.esm.js +5 -4
- package/dist/semanticdb.js +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,6 +167,114 @@ Providers execute only parameterized `sql + parameters`; SemanticDB never execut
|
|
|
167
167
|
Because `displaySql` contains literal values and may expose sensitive data, use it only in trusted
|
|
168
168
|
debugging and observability channels.
|
|
169
169
|
|
|
170
|
+
### Native SQL and table discovery
|
|
171
|
+
|
|
172
|
+
`DBConnector` provides trusted physical database operations independently of LogicForm execution:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { DBConnector, Logicform } from 'semanticdb-v2';
|
|
176
|
+
import type { DatabaseConnection } from 'semanticdb-v2';
|
|
177
|
+
|
|
178
|
+
const connection = {
|
|
179
|
+
id: 'analytics',
|
|
180
|
+
kind: 'mysql',
|
|
181
|
+
host: 'localhost',
|
|
182
|
+
user: 'analytics',
|
|
183
|
+
password: process.env.MYSQL_PASSWORD ?? '',
|
|
184
|
+
database: 'analytics',
|
|
185
|
+
} satisfies DatabaseConnection;
|
|
186
|
+
|
|
187
|
+
const tables = await DBConnector.getTableList({ connection });
|
|
188
|
+
// [{ name: 'orders', database: 'analytics', type: 'table' }, ...]
|
|
189
|
+
|
|
190
|
+
const description = await DBConnector.describeTable({ connection, table: 'orders' });
|
|
191
|
+
// {
|
|
192
|
+
// columns: [{ name: 'id', type: 'int', comment: 'Order ID', primaryKey: true, exampleValue: 42 }, ...],
|
|
193
|
+
// tableInfo: { name: 'orders', database: 'analytics', type: 'table', comment: 'Orders' },
|
|
194
|
+
// }
|
|
195
|
+
|
|
196
|
+
const { rows } = await DBConnector.runSQL({
|
|
197
|
+
connection,
|
|
198
|
+
sql: 'SELECT * FROM orders WHERE status = ?',
|
|
199
|
+
parameters: ['paid'],
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const updated = await DBConnector.runSQL({
|
|
203
|
+
connection,
|
|
204
|
+
sql: 'UPDATE orders SET status = ? WHERE id = ?',
|
|
205
|
+
parameters: ['shipped', 42],
|
|
206
|
+
});
|
|
207
|
+
// { rows: [], affectedRows: 1 }
|
|
208
|
+
|
|
209
|
+
// The exact same object belongs in Logicform.execute's connections array:
|
|
210
|
+
// await Logicform.execute(logicform, { connections: [connection], schemas, schemaMappings });
|
|
211
|
+
|
|
212
|
+
await Logicform.close(); // DBConnector.close() is the same shutdown operation.
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Both APIs share providers and connection pools by connection ID and `providerRegistry`. An ID must
|
|
216
|
+
retain the same configuration until shutdown. Providers and pools are initialized lazily. Either
|
|
217
|
+
`close()` releases **all** SDK-managed connections, including those used by the other API; it does
|
|
218
|
+
not close just the last connector connection.
|
|
219
|
+
|
|
220
|
+
`runSQL` returns `{ rows: DataRow[], affectedRows?: number }`. Commands without a result set return
|
|
221
|
+
an empty array; affected-row counts are included only when the driver reports them. SQL is passed
|
|
222
|
+
through without automatic LIMIT, dialect translation, Schema mapping, hydration, generated `_id`,
|
|
223
|
+
or query caching. It does **not** enforce `ExecuteOptions.permissions`: use trusted callers and
|
|
224
|
+
appropriately restricted database accounts. Supply values through `parameters` using the native
|
|
225
|
+
provider placeholders: `?` for MySQL-compatible databases, Databricks, Dameng, Snowflake and MaxCompute;
|
|
226
|
+
`$1` for PostgreSQL; `@p0` for SQL Server; `:1` for Oracle; typed `{p0:String}`-style
|
|
227
|
+
placeholders for ClickHouse. ClickHouse uses JSONEachRow output; do not override it with another
|
|
228
|
+
FORMAT. Each call is independent, with Oracle/Dameng command execution automatically committed;
|
|
229
|
+
cross-call transactions and multi-statement/multi-result execution are not supported.
|
|
230
|
+
|
|
231
|
+
`getTableList` returns `{ name, database?, schema?, type: 'table' | 'view' }[]` for accessible tables
|
|
232
|
+
and views, retaining namespaces to distinguish same-name tables. Optional `database` and `schema`
|
|
233
|
+
override only this metadata lookup, never the cached connection configuration:
|
|
234
|
+
|
|
235
|
+
- MySQL, Doris, StarRocks, GBase and ClickHouse: `database`; `schema` is rejected.
|
|
236
|
+
- PostgreSQL, Oracle and Dameng: `schema`; cross-database overrides are rejected. Defaults to the
|
|
237
|
+
current schema (or the configured Dameng schema).
|
|
238
|
+
- SQL Server and Snowflake: `database` and `schema`. SQL Server lists all accessible schemas in
|
|
239
|
+
the database by default; Snowflake defaults to the current schema.
|
|
240
|
+
- Databricks: `database` means catalog, and `schema` means schema. Defaults come from the connection's
|
|
241
|
+
`catalog` and `schema` (`connection.database` remains the existing legacy alias for schema).
|
|
242
|
+
- MaxCompute: the existing injected client handles `SHOW TABLES`, returning rows with `table_name`.
|
|
243
|
+
It may implement `getTableList(request)` for project/schema overrides and view metadata, and
|
|
244
|
+
`runSQL(request)` for affected-row counts. Otherwise commands must return `[]` through `execute`.
|
|
245
|
+
|
|
246
|
+
`describeTable({ connection, table, database?, schema?, includeSample? })` inspects one physical
|
|
247
|
+
table or view. `table` is a literal **unqualified** name; provide its namespace separately, using
|
|
248
|
+
the same scope rules as `getTableList`. A dot inside `table` is part of the identifier, not a separator.
|
|
249
|
+
Do not pass a SQL expression or the legacy semantic Schema/`from` object. SQL Server descriptions
|
|
250
|
+
default to the connection's current default schema; pass `schema` explicitly when describing a
|
|
251
|
+
table returned from another schema. Column order follows the database's definition.
|
|
252
|
+
|
|
253
|
+
The result has `columns: { name, type, comment, primaryKey?, exampleValue? }[]` and
|
|
254
|
+
`tableInfo: { name, database?, schema?, type, comment }`. These are physical names/native types,
|
|
255
|
+
not semantic Properties; no `_id` is added. Comments default to an empty string. Primary-key
|
|
256
|
+
membership includes every column of composite keys; unique-only indexes are not primary keys.
|
|
257
|
+
ClickHouse reports its storage primary key, which does not imply relational uniqueness. If the
|
|
258
|
+
adapter cannot determine primary-key membership (Databricks/Snowflake), `primaryKey` is omitted
|
|
259
|
+
rather than guessed. Example values preserve driver types, including `null`.
|
|
260
|
+
|
|
261
|
+
Like the legacy API, descriptions read one example row by default. Set `includeSample: false`
|
|
262
|
+
for metadata-only inspection, avoiding a data read. Empty tables and failed sample queries still
|
|
263
|
+
return metadata without example values; metadata failures, tables not found in the selected namespace, and
|
|
264
|
+
cancellation reject. All SQL uses bound metadata values and quoted identifiers, bypassing
|
|
265
|
+
LogicForm permissions and caching just like `runSQL`.
|
|
266
|
+
|
|
267
|
+
MaxCompute clients may implement `describeTable(request)` to provide project/schema-aware
|
|
268
|
+
metadata. Otherwise the fallback runs `DESC` and expects structured rows with `column_name`,
|
|
269
|
+
`column_type`, optional `column_comment` and `is_primary_key`. Legacy UDBC ASCII `Info` reports
|
|
270
|
+
must be normalized by the client; unparsed reports are rejected rather than producing empty columns.
|
|
271
|
+
|
|
272
|
+
All operations accept `signal` and the same optional `providerRegistry` as `Logicform.execute`.
|
|
273
|
+
Custom providers opt in through `runSQL(request)`, `getTableList(request)` and `describeTable(request)`; missing capabilities
|
|
274
|
+
fail explicitly without changing the existing provider `execute` contract. Unsupported discovery
|
|
275
|
+
scopes are rejected rather than silently ignored. Cancellation does not guarantee rollback of
|
|
276
|
+
commands that have already reached the database.
|
|
277
|
+
|
|
170
278
|
### Permissions
|
|
171
279
|
|
|
172
280
|
Pass table, row, and column permissions together through `ExecuteOptions.permissions`:
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type ProviderFactory = (connection: DatabaseConnection) => CoreComputeProvider;
|
|
3
|
-
export declare class ConnectionRegistry {
|
|
4
|
-
#private;
|
|
5
|
-
private readonly create;
|
|
6
|
-
constructor(create?: ProviderFactory);
|
|
7
|
-
get(connection: DatabaseConnection): CoreComputeProvider;
|
|
8
|
-
close(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export declare const getConnectionProvider: (connection: DatabaseConnection, providers?: ProviderRegistry) => CoreComputeProvider;
|
|
11
|
-
export declare const closeConnections: () => Promise<void>;
|
|
12
|
-
export {};
|
|
1
|
+
export { ConnectionRegistry, getConnectionProvider, closeConnections } from '../physical/index';
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export type { CalendarAlignment, CalendarComparison, CalendarDateRow, CalendarRe
|
|
|
16
16
|
export type { CalendarRelationStore } from './calendar/index';
|
|
17
17
|
export type { PrimalType, PropertyHierarchyDefinition, PropertySqlDefinition, ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeNormalizeContext, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, SemanticTypeResultContext, SemanticTypeResultProperty, TimeGranularity, TimeWatermarkPolicy, } from './semantic-types/index';
|
|
18
18
|
export type { DataRow, SqlParameters, BuiltinDatabaseConnection, DatabaseConnection, DatabaseConnectionBase, DatabaseConnectionExtensions, ProviderDefinition, ProviderKind, ProviderKindExtensions, } from './physical/index';
|
|
19
|
-
export { ProviderRegistry } from './physical/index';
|
|
19
|
+
export { DBConnector, ProviderRegistry } from './physical/index';
|
|
20
|
+
export type { DBConnectorOptions, RunSQLOptions, GetTableListOptions, DescribeTableOptions, DescribeTableRequest, DatabaseColumn, TableDescription, DatabaseTable, SQLResult, TableListRequest, } from './physical/index';
|
|
20
21
|
export type { OperatorDefinition, OperatorDefaultNameContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorPlanInputContext, OperatorPlannedInput, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, ResultPropertyTemporalMetadataExtensions, } from './operators/index';
|
|
21
22
|
export type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingPredDefinition, SchemaMappingPredMatch, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, YiAskSchemaMappingItem, YiAskSchemaMappingRecord, } from './schema-mappings/index';
|
|
22
23
|
export type { QueryCache, QueryCacheExecutionOptions, QueryCacheIdentity, QueryCacheWriteOptions, } from './cache/index';
|
|
@@ -16,6 +16,15 @@ export interface NormalizeLogicformOptions {
|
|
|
16
16
|
readonly now?: Date;
|
|
17
17
|
readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
|
|
18
18
|
readonly requestTimeWatermark?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty, requestedUpperBound: Date) => Promise<Date | undefined>;
|
|
19
|
+
readonly requestAutoCaseBounds?: (schema: ResolvedSemanticSchema, reference: string, query: LogicformType['query']) => Promise<{
|
|
20
|
+
readonly min: number;
|
|
21
|
+
readonly max: number;
|
|
22
|
+
readonly count: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly empty: true;
|
|
25
|
+
}>;
|
|
26
|
+
/** Internal root query used to resolve automatic `$case` boundaries. */
|
|
27
|
+
readonly autoCaseQuery?: LogicformType['query'];
|
|
19
28
|
readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
|
|
20
29
|
readonly canProjectProperty?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => boolean;
|
|
21
30
|
/** Internal recursion hook installed by normalizeLogicform. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
interface ClickHouseResultLike {
|
|
3
3
|
json<T>(): Promise<T>;
|
|
4
4
|
}
|
|
@@ -9,6 +9,17 @@ export interface ClickHouseClientLike {
|
|
|
9
9
|
query_params: Readonly<Record<string, unknown>>;
|
|
10
10
|
abort_signal?: AbortSignal;
|
|
11
11
|
}): Promise<ClickHouseResultLike>;
|
|
12
|
+
/** Native SDK exec does not append a FORMAT clause to commands. */
|
|
13
|
+
exec?(options: {
|
|
14
|
+
query: string;
|
|
15
|
+
query_params: Readonly<Record<string, unknown>>;
|
|
16
|
+
clickhouse_settings: {
|
|
17
|
+
readonly default_format: 'JSONEachRow';
|
|
18
|
+
};
|
|
19
|
+
abort_signal?: AbortSignal;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
readonly stream: AsyncIterable<string | Buffer>;
|
|
22
|
+
}>;
|
|
12
23
|
close(): Promise<void>;
|
|
13
24
|
}
|
|
14
25
|
export interface ClickHouseProviderOptions {
|
|
@@ -52,6 +63,9 @@ export declare class ClickHouseProvider implements CoreComputeProvider {
|
|
|
52
63
|
valueExpression: string;
|
|
53
64
|
};
|
|
54
65
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
66
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
67
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
68
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
55
69
|
close(): Promise<void>;
|
|
56
70
|
}
|
|
57
71
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DatabaseConnection, ProviderRegistry } from './connection';
|
|
2
|
+
import type { CoreComputeProvider } from './provider';
|
|
3
|
+
type ProviderFactory = (connection: DatabaseConnection) => CoreComputeProvider;
|
|
4
|
+
export declare class ConnectionRegistry {
|
|
5
|
+
#private;
|
|
6
|
+
private readonly create;
|
|
7
|
+
constructor(create?: ProviderFactory);
|
|
8
|
+
get(connection: DatabaseConnection): CoreComputeProvider;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const getConnectionProvider: (connection: DatabaseConnection, providers?: ProviderRegistry) => CoreComputeProvider;
|
|
12
|
+
export declare const closeConnections: () => Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
type DamengBind = string | number | Date | Buffer | null;
|
|
3
3
|
export interface DamengConnectionOptions {
|
|
4
4
|
readonly connectString?: string;
|
|
@@ -15,8 +15,10 @@ export interface DamengConnectionOptions {
|
|
|
15
15
|
export interface DamengConnectionLike {
|
|
16
16
|
execute(sql: string, binds: DamengBind[], options: {
|
|
17
17
|
readonly outFormat: number;
|
|
18
|
+
readonly autoCommit?: boolean;
|
|
18
19
|
}): Promise<{
|
|
19
20
|
readonly rows?: unknown[];
|
|
21
|
+
readonly rowsAffected?: number;
|
|
20
22
|
}>;
|
|
21
23
|
close(): Promise<void>;
|
|
22
24
|
}
|
|
@@ -56,6 +58,9 @@ export declare class DamengProvider implements CoreComputeProvider {
|
|
|
56
58
|
stringLength(expression: string): string;
|
|
57
59
|
regex(expression: string, pattern: string, options?: string): string;
|
|
58
60
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
61
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
62
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
63
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
59
64
|
close(): Promise<void>;
|
|
60
65
|
}
|
|
61
66
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
type DatabricksBind = string | number | boolean | bigint | Date | null;
|
|
3
3
|
export interface DatabricksConnectionBase {
|
|
4
4
|
readonly host: string;
|
|
@@ -29,6 +29,8 @@ export interface DatabricksOAuthAuth {
|
|
|
29
29
|
export type DatabricksConnectionOptions = DatabricksConnectionBase & (DatabricksAccessTokenAuth | DatabricksOAuthAuth);
|
|
30
30
|
export interface DatabricksOperationLike {
|
|
31
31
|
fetchAll(): Promise<unknown>;
|
|
32
|
+
/** The native SDK can finish commands that have no result set to fetch. */
|
|
33
|
+
finished?(): Promise<void>;
|
|
32
34
|
cancel(): Promise<unknown>;
|
|
33
35
|
close(): Promise<unknown>;
|
|
34
36
|
}
|
|
@@ -78,6 +80,9 @@ export declare class DatabricksProvider implements CoreComputeProvider {
|
|
|
78
80
|
valueExpression: string;
|
|
79
81
|
};
|
|
80
82
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
83
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
84
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
85
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
81
86
|
close(): Promise<void>;
|
|
82
87
|
}
|
|
83
88
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DatabaseConnection, ProviderRegistry } from './connection';
|
|
2
|
+
import type { DatabaseTable, SQLResult, SqlParameters, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
3
|
+
export interface DBConnectorOptions {
|
|
4
|
+
/** Exactly the same connection object accepted by Logicform.execute.connections. */
|
|
5
|
+
readonly connection: DatabaseConnection;
|
|
6
|
+
readonly providerRegistry?: ProviderRegistry;
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
export interface RunSQLOptions extends DBConnectorOptions {
|
|
10
|
+
readonly sql: string;
|
|
11
|
+
readonly parameters?: SqlParameters;
|
|
12
|
+
}
|
|
13
|
+
export interface GetTableListOptions extends DBConnectorOptions, TableListRequest {
|
|
14
|
+
}
|
|
15
|
+
export interface DescribeTableOptions extends DBConnectorOptions, DescribeTableRequest {
|
|
16
|
+
}
|
|
17
|
+
/** Trusted physical operations; no LogicForm permissions, rewriting, or caching. */
|
|
18
|
+
export declare const DBConnector: Readonly<{
|
|
19
|
+
runSQL: (options: RunSQLOptions) => Promise<SQLResult>;
|
|
20
|
+
getTableList: (options: GetTableListOptions) => Promise<DatabaseTable[]>;
|
|
21
|
+
describeTable: (options: DescribeTableOptions) => Promise<TableDescription>;
|
|
22
|
+
close: () => Promise<void>;
|
|
23
|
+
}>;
|
package/dist/physical/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** Internal physical adapters selected from the public database connection configuration. */
|
|
2
|
-
export type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, ProviderKind, ProviderKindExtensions, SqlRenderCapabilities, SqlParameters, } from './provider';
|
|
2
|
+
export type { CoreComputeProvider, DatePart, DataRow, DatabaseTable, SQLResult, TableListRequest, DescribeTableRequest, DatabaseColumn, TableDescription, ProviderExecutionRequest, ProviderKind, ProviderKindExtensions, SqlRenderCapabilities, SqlParameters, } from './provider';
|
|
3
|
+
export { ConnectionRegistry, getConnectionProvider, closeConnections } from './connection-registry';
|
|
4
|
+
export { DBConnector } from './db-connector';
|
|
5
|
+
export type { DBConnectorOptions, RunSQLOptions, GetTableListOptions, DescribeTableOptions } from './db-connector';
|
|
3
6
|
export { builtinProviderDefinitions, createProvider, defaultProviderRegistry, ProviderRegistry, } from './connection';
|
|
4
7
|
export type { BuiltinDatabaseConnection, DatabaseConnection, DatabaseConnectionBase, DatabaseConnectionExtensions, ProviderDefinition, } from './connection';
|
|
5
8
|
export { DuckDBCoordinatorProvider } from './duckdb-coordinator-provider';
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DataRow, DatePart, ProviderExecutionRequest, SqlParameters } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DataRow, DatePart, ProviderExecutionRequest, SqlParameters, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
/**
|
|
3
3
|
* Parameterized MaxCompute execution boundary supplied by the application.
|
|
4
4
|
* Implementations must bind `parameters`; they must not interpolate them into `sql`.
|
|
5
5
|
*/
|
|
6
6
|
export interface MaxComputeClientLike {
|
|
7
7
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
8
|
+
/** Optional command metadata and project/schema-aware discovery extensions. */
|
|
9
|
+
runSQL?(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
10
|
+
getTableList?(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
11
|
+
describeTable?(request: DescribeTableRequest): Promise<TableDescription>;
|
|
8
12
|
close(): Promise<void>;
|
|
9
13
|
}
|
|
10
14
|
export interface MaxComputeConnectionOptions {
|
|
@@ -33,5 +37,8 @@ export declare class MaxComputeProvider implements CoreComputeProvider {
|
|
|
33
37
|
stringLength(expression: string): string;
|
|
34
38
|
regex(expression: string, pattern: string, options?: string): string;
|
|
35
39
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
40
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
41
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
36
42
|
close(): Promise<void>;
|
|
43
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
37
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SqlParameters } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SqlParameters, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
export interface MySQLProtocolPoolLike {
|
|
3
3
|
execute(sql: string, values: readonly unknown[]): Promise<readonly [unknown, unknown]>;
|
|
4
4
|
end(): Promise<void>;
|
|
@@ -47,5 +47,8 @@ export declare abstract class MySQLProtocolProvider implements CoreComputeProvid
|
|
|
47
47
|
readonly valueExpression: string;
|
|
48
48
|
};
|
|
49
49
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
50
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
51
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
52
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
50
53
|
close(): Promise<void>;
|
|
51
54
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
type OracleBind = string | number | boolean | Date | Buffer | null;
|
|
3
3
|
export interface OracleConnectionLike {
|
|
4
4
|
execute(sql: string, binds: OracleBind[], options: {
|
|
5
5
|
readonly outFormat: number;
|
|
6
|
+
readonly autoCommit?: boolean;
|
|
6
7
|
}): Promise<{
|
|
7
8
|
readonly rows?: unknown[] | undefined;
|
|
9
|
+
readonly rowsAffected?: number | undefined;
|
|
8
10
|
}>;
|
|
9
11
|
break(): Promise<void>;
|
|
10
12
|
close(): Promise<void>;
|
|
@@ -60,6 +62,9 @@ export declare class OracleProvider implements CoreComputeProvider {
|
|
|
60
62
|
valueExpression: string;
|
|
61
63
|
};
|
|
62
64
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
65
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
66
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
67
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
63
68
|
close(): Promise<void>;
|
|
64
69
|
}
|
|
65
70
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
export interface PostgreSQLPoolLike {
|
|
3
3
|
query(sql: string, values: unknown[]): Promise<{
|
|
4
4
|
readonly rows: unknown;
|
|
5
|
+
readonly rowCount?: number | null;
|
|
6
|
+
readonly command?: string;
|
|
5
7
|
}>;
|
|
6
8
|
end(): Promise<void>;
|
|
7
9
|
}
|
|
@@ -48,5 +50,8 @@ export declare class PostgreSQLProvider implements CoreComputeProvider {
|
|
|
48
50
|
valueExpression: string;
|
|
49
51
|
};
|
|
50
52
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
53
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
54
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
55
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
51
56
|
close(): Promise<void>;
|
|
52
57
|
}
|
|
@@ -10,6 +10,46 @@ export interface ProviderExecutionRequest {
|
|
|
10
10
|
readonly parameters: SqlParameters;
|
|
11
11
|
readonly signal?: AbortSignal;
|
|
12
12
|
}
|
|
13
|
+
/** Native SQL results, without semantic hydration or generated row identities. */
|
|
14
|
+
export interface SQLResult {
|
|
15
|
+
readonly rows: DataRow[];
|
|
16
|
+
/** Omitted when the driver does not report an affected-row count. */
|
|
17
|
+
readonly affectedRows?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface DatabaseTable {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly database?: string;
|
|
22
|
+
readonly schema?: string;
|
|
23
|
+
readonly type: 'table' | 'view';
|
|
24
|
+
}
|
|
25
|
+
export interface TableListRequest {
|
|
26
|
+
/** Database/catalog override; unsupported scopes are rejected, not ignored. */
|
|
27
|
+
readonly database?: string;
|
|
28
|
+
readonly schema?: string;
|
|
29
|
+
readonly signal?: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
export interface DescribeTableRequest extends TableListRequest {
|
|
32
|
+
/** Literal, unqualified physical table name; use database/schema for its namespace. */
|
|
33
|
+
readonly table: string;
|
|
34
|
+
/** Read one example row by default. Disable to inspect metadata only. */
|
|
35
|
+
readonly includeSample?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface DatabaseColumn {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
/** Native database type, including size/precision where available. */
|
|
40
|
+
readonly type: string;
|
|
41
|
+
readonly comment: string;
|
|
42
|
+
/** Omitted if the database/adapter cannot report primary-key membership. */
|
|
43
|
+
readonly primaryKey?: boolean;
|
|
44
|
+
/** Omitted for empty tables, disabled sampling, or a failed sample query. */
|
|
45
|
+
readonly exampleValue?: unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface TableDescription {
|
|
48
|
+
readonly columns: DatabaseColumn[];
|
|
49
|
+
readonly tableInfo: DatabaseTable & {
|
|
50
|
+
readonly comment: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
13
53
|
export interface SqlRenderCapabilities {
|
|
14
54
|
/** Whether HAVING may reference an alias declared in the same SELECT list. */
|
|
15
55
|
readonly supportsHavingAlias?: boolean;
|
|
@@ -53,5 +93,10 @@ export interface CoreComputeProvider extends SqlRenderCapabilities {
|
|
|
53
93
|
/** Render bound parameters for diagnostics only; this SQL is never executed by SemanticDB. */
|
|
54
94
|
displayQuery(sql: string, parameters: SqlParameters): string;
|
|
55
95
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
96
|
+
/** Optional native-SQL capability; execute retains its row-query contract. */
|
|
97
|
+
runSQL?(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
98
|
+
/** Optional physical metadata capability, independent of semantic Schemas. */
|
|
99
|
+
getTableList?(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
100
|
+
describeTable?(request: DescribeTableRequest): Promise<TableDescription>;
|
|
56
101
|
close(): Promise<void>;
|
|
57
102
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
type SnowflakeBind = string | number | boolean | null;
|
|
3
3
|
export interface SnowflakeStatementLike {
|
|
4
4
|
cancel(callback?: (error?: Error) => void): void;
|
|
5
|
+
getNumUpdatedRows?(): number | undefined;
|
|
5
6
|
}
|
|
6
7
|
export interface SnowflakeConnectionLike {
|
|
7
8
|
connect(callback: (error?: Error) => void): unknown;
|
|
@@ -53,6 +54,9 @@ export declare class SnowflakeProvider implements CoreComputeProvider {
|
|
|
53
54
|
valueExpression: string;
|
|
54
55
|
};
|
|
55
56
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
57
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
58
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
59
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
56
60
|
close(): Promise<void>;
|
|
57
61
|
}
|
|
58
62
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DataRow, DatePart, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DataRow, DatePart, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
type SQLServerBind = string | number | boolean | Date | Buffer | null;
|
|
3
3
|
export interface SQLServerRequestLike {
|
|
4
4
|
input(name: string, value: SQLServerBind): this;
|
|
5
5
|
query(sql: string): Promise<{
|
|
6
6
|
readonly recordset?: unknown;
|
|
7
|
+
readonly rowsAffected?: readonly number[];
|
|
7
8
|
}>;
|
|
8
9
|
cancel(): void;
|
|
9
10
|
}
|
|
@@ -60,6 +61,9 @@ export declare class SQLServerProvider implements CoreComputeProvider {
|
|
|
60
61
|
readonly valueExpression: string;
|
|
61
62
|
};
|
|
62
63
|
execute(execution: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
64
|
+
runSQL(execution: ProviderExecutionRequest): Promise<SQLResult>;
|
|
65
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
66
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
63
67
|
close(): Promise<void>;
|
|
64
68
|
}
|
|
65
69
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CoreComputeProvider, DataRow, DescribeTableRequest, TableDescription } from './provider';
|
|
2
|
+
export declare const validateDescribeTable: (request: DescribeTableRequest) => void;
|
|
3
|
+
/** INFORMATION_SCHEMA/Oracle expose size separately; PostgreSQL/MySQL already format native types. */
|
|
4
|
+
export declare const columnType: (row: DataRow) => string;
|
|
5
|
+
export declare const describePhysicalTable: (provider: CoreComputeProvider, request: DescribeTableRequest) => Promise<TableDescription>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CoreComputeProvider, DatabaseTable, DataRow, TableListRequest } from './provider';
|
|
2
|
+
export declare const validateTableScope: (request: TableListRequest) => void;
|
|
3
|
+
export declare const rejectTableScope: (provider: CoreComputeProvider, field: "database" | "schema") => never;
|
|
4
|
+
/** Drivers differ in alias casing; never silently discard malformed metadata rows. */
|
|
5
|
+
export declare const metadataValue: (row: DataRow, field: string) => unknown;
|
|
6
|
+
export declare const metadataString: (row: DataRow, field: string) => string;
|
|
7
|
+
export declare const normalizeTableRow: (row: DataRow) => DatabaseTable;
|
|
8
|
+
export declare const normalizeTableMetadata: (rows: DataRow[]) => DatabaseTable[];
|
|
9
|
+
/** Physical metadata SQL only; no semantic Schema resolution belongs here. */
|
|
10
|
+
export declare const discoverTables: (provider: CoreComputeProvider, request: TableListRequest) => Promise<DatabaseTable[]>;
|