@superdurable/connector-clickhouse 0.1.0 → 0.2.0
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 +1 -1
- package/dex-connector.json +97 -2
- package/dist/chunk-23BBEJPR.js +200 -0
- package/dist/connection-IQqDAR8z.d.ts +142 -0
- package/dist/index.d.ts +135 -11
- package/dist/index.js +225 -39
- package/dist/mock.d.ts +42 -2
- package/dist/mock.js +102 -1
- package/package.json +1 -1
- package/dist/chunk-F5PUPLRK.js +0 -105
- package/dist/connection-zXWJ_3zD.d.ts +0 -74
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# ClickHouse TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read databases, tables, and typed columns with the three [metadata Queries](../README.md). Each Query returns the first 100 items and a `hasMore` flag. Run the [example Worker](examples/table-inspection/README.md) to serve all three Flows.
|
package/dex-connector.json
CHANGED
|
@@ -1,12 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"connectorId": "clickhouse",
|
|
3
|
-
"releaseTag": "connectors/clickhouse/go/v0.
|
|
3
|
+
"releaseTag": "connectors/clickhouse/go/v0.2.0",
|
|
4
4
|
"package": {
|
|
5
5
|
"ecosystem": "npm",
|
|
6
6
|
"name": "@superdurable/connector-clickhouse",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.2.0"
|
|
8
8
|
},
|
|
9
9
|
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newListDatabasesStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "listDatabases",
|
|
14
|
+
"inputType": "ListDatabasesInput",
|
|
15
|
+
"description": "Return up to 100 sorted database names and indicate whether more exist.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "listed",
|
|
25
|
+
"field": "listed",
|
|
26
|
+
"optional": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "providerRejected",
|
|
30
|
+
"field": "providerRejected",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "invalidResponse",
|
|
35
|
+
"field": "invalidResponse",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "defect",
|
|
40
|
+
"field": "defect",
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"inputSchema": {
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "ListDatabasesInput requests the first bounded metadata page.",
|
|
47
|
+
"properties": {},
|
|
48
|
+
"type": "object"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
10
51
|
{
|
|
11
52
|
"name": "newListTablesStep",
|
|
12
53
|
"kind": "query",
|
|
@@ -55,6 +96,60 @@
|
|
|
55
96
|
],
|
|
56
97
|
"type": "object"
|
|
57
98
|
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "newListColumnsStep",
|
|
102
|
+
"kind": "query",
|
|
103
|
+
"operationId": "listColumns",
|
|
104
|
+
"inputType": "ListColumnsInput",
|
|
105
|
+
"description": "Return up to 100 ordered column names and types for one table.",
|
|
106
|
+
"fields": {
|
|
107
|
+
"stepType": "stepType",
|
|
108
|
+
"annotations": "annotations",
|
|
109
|
+
"connectionName": "connectionName",
|
|
110
|
+
"resultAttribute": "resultAttribute"
|
|
111
|
+
},
|
|
112
|
+
"branches": [
|
|
113
|
+
{
|
|
114
|
+
"id": "listed",
|
|
115
|
+
"field": "listed",
|
|
116
|
+
"optional": false
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "providerRejected",
|
|
120
|
+
"field": "providerRejected",
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "invalidResponse",
|
|
125
|
+
"field": "invalidResponse",
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "defect",
|
|
130
|
+
"field": "defect",
|
|
131
|
+
"optional": true
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"inputSchema": {
|
|
135
|
+
"additionalProperties": false,
|
|
136
|
+
"description": "ListColumnsInput identifies one ClickHouse table without exposing SQL.",
|
|
137
|
+
"properties": {
|
|
138
|
+
"database": {
|
|
139
|
+
"description": "Database is the exact database name shown by SHOW DATABASES.",
|
|
140
|
+
"type": "string"
|
|
141
|
+
},
|
|
142
|
+
"table": {
|
|
143
|
+
"description": "Table is the exact table name shown by SHOW TABLES.",
|
|
144
|
+
"type": "string"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"required": [
|
|
148
|
+
"database",
|
|
149
|
+
"table"
|
|
150
|
+
],
|
|
151
|
+
"type": "object"
|
|
152
|
+
}
|
|
58
153
|
}
|
|
59
154
|
]
|
|
60
155
|
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"baseUrl": z.string(),
|
|
6
|
+
"timeoutMs": z.number().int().optional(),
|
|
7
|
+
"maxResponseBytes": z.number().int().optional()
|
|
8
|
+
});
|
|
9
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["password", "username"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["password"] != null && !(typeof fields["password"] === "string")) throw new CredentialMaterialError("credential password has an invalid type");
|
|
29
|
+
if (fields["username"] != null && !(typeof fields["username"] === "string")) throw new CredentialMaterialError("credential username has an invalid type");
|
|
30
|
+
const credentials = {};
|
|
31
|
+
if (!fields["username"]) throw new CredentialMaterialError("credential username is required");
|
|
32
|
+
credentials.username = fields["username"] ?? "";
|
|
33
|
+
if (!fields["password"]) throw new CredentialMaterialError("credential password is required");
|
|
34
|
+
credentials.password = new SecretString(fields["password"] ?? "");
|
|
35
|
+
return credentials;
|
|
36
|
+
}
|
|
37
|
+
var ListDatabasesInputSchema = z.strictObject({});
|
|
38
|
+
var DatabasesPageSchema = z.strictObject({
|
|
39
|
+
"names": z.array(z.string()).nullable(),
|
|
40
|
+
"hasMore": z.boolean()
|
|
41
|
+
});
|
|
42
|
+
var ListTablesInputSchema = z.strictObject({
|
|
43
|
+
"database": z.string()
|
|
44
|
+
});
|
|
45
|
+
var TablesPageSchema = z.strictObject({
|
|
46
|
+
"database": z.string(),
|
|
47
|
+
"names": z.array(z.string()).nullable(),
|
|
48
|
+
"hasMore": z.boolean()
|
|
49
|
+
});
|
|
50
|
+
var ListColumnsInputSchema = z.strictObject({
|
|
51
|
+
"database": z.string(),
|
|
52
|
+
"table": z.string()
|
|
53
|
+
});
|
|
54
|
+
var ColumnSchema = z.strictObject({
|
|
55
|
+
"name": z.string(),
|
|
56
|
+
"type": z.string()
|
|
57
|
+
});
|
|
58
|
+
var ColumnsPageSchema = z.strictObject({
|
|
59
|
+
"database": z.string(),
|
|
60
|
+
"table": z.string(),
|
|
61
|
+
"columns": z.array(ColumnSchema).nullable(),
|
|
62
|
+
"hasMore": z.boolean()
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// src/generated/definitions.ts
|
|
66
|
+
var ConnectorID = "clickhouse";
|
|
67
|
+
var ProviderID = "clickhouse";
|
|
68
|
+
var ListDatabasesBranch = {
|
|
69
|
+
Listed: "listed",
|
|
70
|
+
ProviderRejected: "providerRejected",
|
|
71
|
+
InvalidResponse: "invalidResponse",
|
|
72
|
+
Defect: "defect"
|
|
73
|
+
};
|
|
74
|
+
var ListDatabasesBranchListed = ListDatabasesBranch.Listed;
|
|
75
|
+
var ListDatabasesBranchProviderRejected = ListDatabasesBranch.ProviderRejected;
|
|
76
|
+
var ListDatabasesBranchInvalidResponse = ListDatabasesBranch.InvalidResponse;
|
|
77
|
+
var ListDatabasesBranchDefect = ListDatabasesBranch.Defect;
|
|
78
|
+
var ListDatabasesDefinition = {
|
|
79
|
+
operation: { connectorId: ConnectorID, operationId: "listDatabases" },
|
|
80
|
+
branches: [
|
|
81
|
+
{ id: "listed", description: "ClickHouse returned the database names." },
|
|
82
|
+
{ id: "providerRejected", description: "ClickHouse conclusively rejected the metadata query.", optional: true },
|
|
83
|
+
{ id: "invalidResponse", description: "ClickHouse returned malformed or oversized JSON.", optional: true },
|
|
84
|
+
{ id: "defect", description: "Local connection credentials are invalid.", optional: true }
|
|
85
|
+
],
|
|
86
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
87
|
+
};
|
|
88
|
+
var ListDatabasesMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
89
|
+
var ListTablesBranch = {
|
|
90
|
+
Listed: "listed",
|
|
91
|
+
ProviderRejected: "providerRejected",
|
|
92
|
+
InvalidResponse: "invalidResponse",
|
|
93
|
+
Defect: "defect"
|
|
94
|
+
};
|
|
95
|
+
var ListTablesBranchListed = ListTablesBranch.Listed;
|
|
96
|
+
var ListTablesBranchProviderRejected = ListTablesBranch.ProviderRejected;
|
|
97
|
+
var ListTablesBranchInvalidResponse = ListTablesBranch.InvalidResponse;
|
|
98
|
+
var ListTablesBranchDefect = ListTablesBranch.Defect;
|
|
99
|
+
var ListTablesDefinition = {
|
|
100
|
+
operation: { connectorId: ConnectorID, operationId: "listTables" },
|
|
101
|
+
branches: [
|
|
102
|
+
{ id: "listed", description: "ClickHouse returned the table names." },
|
|
103
|
+
{ id: "providerRejected", description: "ClickHouse conclusively rejected the metadata query.", optional: true },
|
|
104
|
+
{ id: "invalidResponse", description: "ClickHouse returned malformed or oversized JSON.", optional: true },
|
|
105
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
106
|
+
],
|
|
107
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
108
|
+
};
|
|
109
|
+
var ListTablesMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
110
|
+
var ListColumnsBranch = {
|
|
111
|
+
Listed: "listed",
|
|
112
|
+
ProviderRejected: "providerRejected",
|
|
113
|
+
InvalidResponse: "invalidResponse",
|
|
114
|
+
Defect: "defect"
|
|
115
|
+
};
|
|
116
|
+
var ListColumnsBranchListed = ListColumnsBranch.Listed;
|
|
117
|
+
var ListColumnsBranchProviderRejected = ListColumnsBranch.ProviderRejected;
|
|
118
|
+
var ListColumnsBranchInvalidResponse = ListColumnsBranch.InvalidResponse;
|
|
119
|
+
var ListColumnsBranchDefect = ListColumnsBranch.Defect;
|
|
120
|
+
var ListColumnsDefinition = {
|
|
121
|
+
operation: { connectorId: ConnectorID, operationId: "listColumns" },
|
|
122
|
+
branches: [
|
|
123
|
+
{ id: "listed", description: "ClickHouse returned the table columns." },
|
|
124
|
+
{ id: "providerRejected", description: "ClickHouse conclusively rejected the metadata query.", optional: true },
|
|
125
|
+
{ id: "invalidResponse", description: "ClickHouse returned malformed or oversized JSON.", optional: true },
|
|
126
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
127
|
+
],
|
|
128
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
129
|
+
};
|
|
130
|
+
var ListColumnsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
131
|
+
|
|
132
|
+
// src/generated/connection.ts
|
|
133
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
134
|
+
var Connection = class {
|
|
135
|
+
/** Stable provider and connection name. */
|
|
136
|
+
reference;
|
|
137
|
+
/** Bound provider operations. */
|
|
138
|
+
operations;
|
|
139
|
+
/** Validate a reference and bind operations. */
|
|
140
|
+
constructor(reference, operations) {
|
|
141
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
142
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
143
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
144
|
+
this.operations = operations;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
function newConnection(client, reference) {
|
|
148
|
+
if (!client) throw new TypeError("connector client is required");
|
|
149
|
+
return new Connection(reference, client);
|
|
150
|
+
}
|
|
151
|
+
function newConnectionWithOperations(operations, reference) {
|
|
152
|
+
return new Connection(reference, operations);
|
|
153
|
+
}
|
|
154
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
155
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
156
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
157
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
158
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
159
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
ConfigSchema,
|
|
164
|
+
CredentialMaterialError,
|
|
165
|
+
isCredentialMaterialError,
|
|
166
|
+
decodeCredentials,
|
|
167
|
+
ListDatabasesInputSchema,
|
|
168
|
+
DatabasesPageSchema,
|
|
169
|
+
ListTablesInputSchema,
|
|
170
|
+
TablesPageSchema,
|
|
171
|
+
ListColumnsInputSchema,
|
|
172
|
+
ColumnSchema,
|
|
173
|
+
ColumnsPageSchema,
|
|
174
|
+
ConnectorID,
|
|
175
|
+
ProviderID,
|
|
176
|
+
ListDatabasesBranch,
|
|
177
|
+
ListDatabasesBranchListed,
|
|
178
|
+
ListDatabasesBranchProviderRejected,
|
|
179
|
+
ListDatabasesBranchInvalidResponse,
|
|
180
|
+
ListDatabasesBranchDefect,
|
|
181
|
+
ListDatabasesDefinition,
|
|
182
|
+
ListDatabasesMetadata,
|
|
183
|
+
ListTablesBranch,
|
|
184
|
+
ListTablesBranchListed,
|
|
185
|
+
ListTablesBranchProviderRejected,
|
|
186
|
+
ListTablesBranchInvalidResponse,
|
|
187
|
+
ListTablesBranchDefect,
|
|
188
|
+
ListTablesDefinition,
|
|
189
|
+
ListTablesMetadata,
|
|
190
|
+
ListColumnsBranch,
|
|
191
|
+
ListColumnsBranchListed,
|
|
192
|
+
ListColumnsBranchProviderRejected,
|
|
193
|
+
ListColumnsBranchInvalidResponse,
|
|
194
|
+
ListColumnsBranchDefect,
|
|
195
|
+
ListColumnsDefinition,
|
|
196
|
+
ListColumnsMetadata,
|
|
197
|
+
Connection,
|
|
198
|
+
newConnectionWithOperations,
|
|
199
|
+
newProjectConnection
|
|
200
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** HTTPS root of the ClickHouse HTTP interface, typically https://your-service.region.aws.clickhouse.cloud:8443; find the host in ClickHouse Cloud > Services > service > Connect > HTTPS or ask your self-hosted administrator. Do not include credentials, query, database, or path. Blank prevents connection creation. */
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
/** Maximum duration of one metadata query as a positive Go duration such as 15s. Blank uses the displayed default; increase for slow catalogs. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum complete metadata JSON response in bytes as a positive integer. Blank uses the displayed default; increase for large catalogs. */
|
|
11
|
+
maxResponseBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
baseUrl: z.ZodString;
|
|
16
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Private connector credentials resolved by the host. */
|
|
20
|
+
interface Credentials {
|
|
21
|
+
/** Secret password for that ClickHouse database user from Cloud > Services > service > Connect > HTTPS, or from your self-hosted administrator. Enter the complete password; blank prevents calls. Dex stores it only as a credential and sends it in X-ClickHouse-Key. Rotate it in the database user settings. */
|
|
22
|
+
password: SecretString;
|
|
23
|
+
/** Non-secret ClickHouse database username from Cloud > Services > service > Connect > HTTPS, or from your self-hosted administrator. Enter the exact user with SELECT access to system.databases, system.tables, and system.columns; blank prevents calls. Dex sends it in X-ClickHouse-User. */
|
|
24
|
+
username: string;
|
|
25
|
+
}
|
|
26
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
27
|
+
declare class CredentialMaterialError extends TypeError {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
31
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
32
|
+
/** Decode private credential fields for the connector. */
|
|
33
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
34
|
+
/** Host-owned source of private connector credentials. */
|
|
35
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
36
|
+
/** ListDatabasesInput requests the first bounded metadata page. */
|
|
37
|
+
interface ListDatabasesInput {
|
|
38
|
+
}
|
|
39
|
+
/** DatabasesPage contains at most 100 sorted database names. */
|
|
40
|
+
interface DatabasesPage {
|
|
41
|
+
/** Names contains the first 100 database names. */
|
|
42
|
+
"names": Array<string> | null;
|
|
43
|
+
/** HasMore indicates that another database exists after this page. */
|
|
44
|
+
"hasMore": boolean;
|
|
45
|
+
}
|
|
46
|
+
/** ListTablesInput selects the non-secret ClickHouse database to inspect. */
|
|
47
|
+
interface ListTablesInput {
|
|
48
|
+
/** Database is the exact database name shown by SHOW DATABASES. */
|
|
49
|
+
"database": string;
|
|
50
|
+
}
|
|
51
|
+
/** TablesPage contains at most 100 sorted table names. */
|
|
52
|
+
interface TablesPage {
|
|
53
|
+
/** Database is the database that was inspected. */
|
|
54
|
+
"database": string;
|
|
55
|
+
/** Names contains the first 100 table names in sorted order. */
|
|
56
|
+
"names": Array<string> | null;
|
|
57
|
+
/** HasMore reports whether another table was present after the first 100. */
|
|
58
|
+
"hasMore": boolean;
|
|
59
|
+
}
|
|
60
|
+
/** ListColumnsInput identifies one ClickHouse table without exposing SQL. */
|
|
61
|
+
interface ListColumnsInput {
|
|
62
|
+
/** Database is the exact database name shown by SHOW DATABASES. */
|
|
63
|
+
"database": string;
|
|
64
|
+
/** Table is the exact table name shown by SHOW TABLES. */
|
|
65
|
+
"table": string;
|
|
66
|
+
}
|
|
67
|
+
/** Column describes one table column. */
|
|
68
|
+
interface Column {
|
|
69
|
+
/** Name is the provider column name. */
|
|
70
|
+
"name": string;
|
|
71
|
+
/** Type is the provider column type expression. */
|
|
72
|
+
"type": string;
|
|
73
|
+
}
|
|
74
|
+
/** ColumnsPage contains at most 100 columns in table position order. */
|
|
75
|
+
interface ColumnsPage {
|
|
76
|
+
/** Database is the inspected database. */
|
|
77
|
+
"database": string;
|
|
78
|
+
/** Table is the inspected table. */
|
|
79
|
+
"table": string;
|
|
80
|
+
/** Columns are the first 100 column definitions. */
|
|
81
|
+
"columns": Array<Column> | null;
|
|
82
|
+
/** HasMore indicates that another column exists after this page. */
|
|
83
|
+
"hasMore": boolean;
|
|
84
|
+
}
|
|
85
|
+
/** Runtime validator for ListDatabasesInput. */
|
|
86
|
+
declare const ListDatabasesInputSchema: z.ZodObject<{}, z.core.$strict>;
|
|
87
|
+
/** Runtime validator for DatabasesPage. */
|
|
88
|
+
declare const DatabasesPageSchema: z.ZodObject<{
|
|
89
|
+
names: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
90
|
+
hasMore: z.ZodBoolean;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
/** Runtime validator for ListTablesInput. */
|
|
93
|
+
declare const ListTablesInputSchema: z.ZodObject<{
|
|
94
|
+
database: z.ZodString;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
/** Runtime validator for TablesPage. */
|
|
97
|
+
declare const TablesPageSchema: z.ZodObject<{
|
|
98
|
+
database: z.ZodString;
|
|
99
|
+
names: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
100
|
+
hasMore: z.ZodBoolean;
|
|
101
|
+
}, z.core.$strict>;
|
|
102
|
+
/** Runtime validator for ListColumnsInput. */
|
|
103
|
+
declare const ListColumnsInputSchema: z.ZodObject<{
|
|
104
|
+
database: z.ZodString;
|
|
105
|
+
table: z.ZodString;
|
|
106
|
+
}, z.core.$strict>;
|
|
107
|
+
/** Runtime validator for Column. */
|
|
108
|
+
declare const ColumnSchema: z.ZodObject<{
|
|
109
|
+
name: z.ZodString;
|
|
110
|
+
type: z.ZodString;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
/** Runtime validator for ColumnsPage. */
|
|
113
|
+
declare const ColumnsPageSchema: z.ZodObject<{
|
|
114
|
+
database: z.ZodString;
|
|
115
|
+
table: z.ZodString;
|
|
116
|
+
columns: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
type: z.ZodString;
|
|
119
|
+
}, z.core.$strict>>>;
|
|
120
|
+
hasMore: z.ZodBoolean;
|
|
121
|
+
}, z.core.$strict>;
|
|
122
|
+
|
|
123
|
+
/** Typed operations supplied by a client or mock. */
|
|
124
|
+
interface Operations {
|
|
125
|
+
/** Invoke listDatabases through this connection. */
|
|
126
|
+
listDatabases(): Query<ListDatabasesInput, DatabasesPage>;
|
|
127
|
+
/** Invoke listTables through this connection. */
|
|
128
|
+
listTables(): Query<ListTablesInput, TablesPage>;
|
|
129
|
+
/** Invoke listColumns through this connection. */
|
|
130
|
+
listColumns(): Query<ListColumnsInput, ColumnsPage>;
|
|
131
|
+
}
|
|
132
|
+
/** Named connector connection kept outside Flow state. */
|
|
133
|
+
declare class Connection<BoundOperations = Operations> {
|
|
134
|
+
/** Stable provider and connection name. */
|
|
135
|
+
readonly reference: ConnectionRef;
|
|
136
|
+
/** Bound provider operations. */
|
|
137
|
+
readonly operations: BoundOperations;
|
|
138
|
+
/** Validate a reference and bind operations. */
|
|
139
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { type ColumnsPage as C, type DatabasesPage as D, type ListColumnsInput as L, type Operations as O, type TablesPage as T, Connection as a, type ListDatabasesInput as b, type ListTablesInput as c, type Config as d, type Credentials as e, type Column as f, ColumnSchema as g, ColumnsPageSchema as h, ConfigSchema as i, CredentialMaterialError as j, type CredentialSource as k, DatabasesPageSchema as l, ListColumnsInputSchema as m, ListDatabasesInputSchema as n, ListTablesInputSchema as o, TablesPageSchema as p, decodeCredentials as q, isCredentialMaterialError as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as
|
|
2
|
-
export {
|
|
3
|
-
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } from '@superdurable/connectors-sdk';
|
|
1
|
+
import { L as ListColumnsInput, C as ColumnsPage, a as Connection$1, b as ListDatabasesInput, D as DatabasesPage, c as ListTablesInput, T as TablesPage, O as Operations, d as Config, e as Credentials } from './connection-IQqDAR8z.js';
|
|
2
|
+
export { f as Column, g as ColumnSchema, h as ColumnsPageSchema, i as ConfigSchema, j as CredentialMaterialError, k as CredentialSource, l as DatabasesPageSchema, m as ListColumnsInputSchema, n as ListDatabasesInputSchema, o as ListTablesInputSchema, p as TablesPageSchema, q as decodeCredentials, r as isCredentialMaterialError } from './connection-IQqDAR8z.js';
|
|
3
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
4
4
|
import { StepTarget } from '@superdurable/dex';
|
|
5
5
|
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
6
6
|
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
@@ -10,6 +10,29 @@ import 'zod';
|
|
|
10
10
|
declare const ConnectorID = "clickhouse";
|
|
11
11
|
/** Provider identity for named connections. */
|
|
12
12
|
declare const ProviderID = "clickhouse";
|
|
13
|
+
/** Branch IDs for listDatabases. */
|
|
14
|
+
declare const ListDatabasesBranch: {
|
|
15
|
+
readonly Listed: "listed";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** ClickHouse returned the database names. */
|
|
21
|
+
declare const ListDatabasesBranchListed: "listed";
|
|
22
|
+
/** ClickHouse conclusively rejected the metadata query. */
|
|
23
|
+
declare const ListDatabasesBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** ClickHouse returned malformed or oversized JSON. */
|
|
25
|
+
declare const ListDatabasesBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** Local connection credentials are invalid. */
|
|
27
|
+
declare const ListDatabasesBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for listDatabases. */
|
|
29
|
+
declare const ListDatabasesDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for listDatabases. */
|
|
31
|
+
declare const ListDatabasesMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
13
36
|
/** Branch IDs for listTables. */
|
|
14
37
|
declare const ListTablesBranch: {
|
|
15
38
|
readonly Listed: "listed";
|
|
@@ -33,11 +56,53 @@ declare const ListTablesMetadata: {
|
|
|
33
56
|
readonly idempotency: "none";
|
|
34
57
|
readonly authorization: "required";
|
|
35
58
|
};
|
|
59
|
+
/** Branch IDs for listColumns. */
|
|
60
|
+
declare const ListColumnsBranch: {
|
|
61
|
+
readonly Listed: "listed";
|
|
62
|
+
readonly ProviderRejected: "providerRejected";
|
|
63
|
+
readonly InvalidResponse: "invalidResponse";
|
|
64
|
+
readonly Defect: "defect";
|
|
65
|
+
};
|
|
66
|
+
/** ClickHouse returned the table columns. */
|
|
67
|
+
declare const ListColumnsBranchListed: "listed";
|
|
68
|
+
/** ClickHouse conclusively rejected the metadata query. */
|
|
69
|
+
declare const ListColumnsBranchProviderRejected: "providerRejected";
|
|
70
|
+
/** ClickHouse returned malformed or oversized JSON. */
|
|
71
|
+
declare const ListColumnsBranchInvalidResponse: "invalidResponse";
|
|
72
|
+
/** Local input or connection credentials are invalid. */
|
|
73
|
+
declare const ListColumnsBranchDefect: "defect";
|
|
74
|
+
/** Manifest definition for listColumns. */
|
|
75
|
+
declare const ListColumnsDefinition: QueryDefinition;
|
|
76
|
+
/** Manifest metadata for listColumns. */
|
|
77
|
+
declare const ListColumnsMetadata: {
|
|
78
|
+
readonly kind: "query";
|
|
79
|
+
readonly idempotency: "none";
|
|
80
|
+
readonly authorization: "required";
|
|
81
|
+
};
|
|
36
82
|
|
|
83
|
+
/** Configuration for the listDatabases connector Step. */
|
|
84
|
+
interface ListDatabasesStepConfig<StepInput, OperationInput = ListDatabasesInput, OperationOutput = DatabasesPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
85
|
+
/** Named connection supplying this operation. */
|
|
86
|
+
connection: Connection$1<{
|
|
87
|
+
listDatabases(): Query<OperationInput, OperationOutput>;
|
|
88
|
+
}>;
|
|
89
|
+
/** Name matching the bound connection. */
|
|
90
|
+
connectionName: string;
|
|
91
|
+
/** ClickHouse returned the database names. */
|
|
92
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
93
|
+
/** ClickHouse conclusively rejected the metadata query. */
|
|
94
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
95
|
+
/** ClickHouse returned malformed or oversized JSON. */
|
|
96
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
97
|
+
/** Local connection credentials are invalid. */
|
|
98
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
99
|
+
}
|
|
100
|
+
/** Build the listDatabases Step from a named connection. */
|
|
101
|
+
declare function newListDatabasesStep<StepInput, OperationInput = ListDatabasesInput, OperationOutput = DatabasesPage>(configuration: ListDatabasesStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
37
102
|
/** Configuration for the listTables connector Step. */
|
|
38
103
|
interface ListTablesStepConfig<StepInput, OperationInput = ListTablesInput, OperationOutput = TablesPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
104
|
/** Named connection supplying this operation. */
|
|
40
|
-
connection: Connection<{
|
|
105
|
+
connection: Connection$1<{
|
|
41
106
|
listTables(): Query<OperationInput, OperationOutput>;
|
|
42
107
|
}>;
|
|
43
108
|
/** Name matching the bound connection. */
|
|
@@ -53,9 +118,28 @@ interface ListTablesStepConfig<StepInput, OperationInput = ListTablesInput, Oper
|
|
|
53
118
|
}
|
|
54
119
|
/** Build the listTables Step from a named connection. */
|
|
55
120
|
declare function newListTablesStep<StepInput, OperationInput = ListTablesInput, OperationOutput = TablesPage>(configuration: ListTablesStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
121
|
+
/** Configuration for the listColumns connector Step. */
|
|
122
|
+
interface ListColumnsStepConfig<StepInput, OperationInput = ListColumnsInput, OperationOutput = ColumnsPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
123
|
+
/** Named connection supplying this operation. */
|
|
124
|
+
connection: Connection$1<{
|
|
125
|
+
listColumns(): Query<OperationInput, OperationOutput>;
|
|
126
|
+
}>;
|
|
127
|
+
/** Name matching the bound connection. */
|
|
128
|
+
connectionName: string;
|
|
129
|
+
/** ClickHouse returned the table columns. */
|
|
130
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
131
|
+
/** ClickHouse conclusively rejected the metadata query. */
|
|
132
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
133
|
+
/** ClickHouse returned malformed or oversized JSON. */
|
|
134
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
135
|
+
/** Local input or connection credentials are invalid. */
|
|
136
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
137
|
+
}
|
|
138
|
+
/** Build the listColumns Step from a named connection. */
|
|
139
|
+
declare function newListColumnsStep<StepInput, OperationInput = ListColumnsInput, OperationOutput = ColumnsPage>(configuration: ListColumnsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
140
|
|
|
57
141
|
/** Open one named ClickHouse connection from Dex project configuration. */
|
|
58
|
-
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
142
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection$1<Operations>;
|
|
59
143
|
|
|
60
144
|
/** Injectable provider sender for tests and local applications. */
|
|
61
145
|
interface ClickHouseClientOptions {
|
|
@@ -67,7 +151,7 @@ interface Exchange {
|
|
|
67
151
|
retryAfterMs: number;
|
|
68
152
|
error?: 'credential' | 'request' | 'tooLarge';
|
|
69
153
|
}
|
|
70
|
-
/** Authenticated ClickHouse HTTP client for table
|
|
154
|
+
/** Authenticated ClickHouse HTTP client for database, table, and column metadata. */
|
|
71
155
|
declare class ClickHouseClient {
|
|
72
156
|
private readonly credentials;
|
|
73
157
|
private readonly baseURL;
|
|
@@ -77,16 +161,56 @@ declare class ClickHouseClient {
|
|
|
77
161
|
/** Validate provider configuration without contacting ClickHouse. */
|
|
78
162
|
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: ClickHouseClientOptions);
|
|
79
163
|
/** Bind the listTables Query. */ listTables(): ListTablesOperation;
|
|
164
|
+
/** Bind the database catalog Query. */
|
|
165
|
+
listDatabases(): ListDatabasesOperation;
|
|
166
|
+
/** Bind the ordered column metadata Query. */
|
|
167
|
+
listColumns(): ListColumnsOperation;
|
|
168
|
+
/** Resolve credentials and send one bounded database query. */
|
|
169
|
+
getDatabases(call: Call): Promise<Exchange>;
|
|
170
|
+
/** Resolve credentials and send one bounded column query. */
|
|
171
|
+
getColumns(call: Call, database: string, table: string): Promise<Exchange>;
|
|
80
172
|
/** Resolve credentials and send one bounded table query. */
|
|
81
173
|
get(call: Call, database: string): Promise<Exchange>;
|
|
174
|
+
private readMetadata;
|
|
175
|
+
}
|
|
176
|
+
/** Read up to 100 databases from ClickHouse system metadata. */
|
|
177
|
+
declare class ListDatabasesOperation implements Query<ListDatabasesInput, DatabasesPage> {
|
|
178
|
+
private readonly client;
|
|
179
|
+
/** Bind the metadata client. */
|
|
180
|
+
constructor(client: ClickHouseClient);
|
|
181
|
+
/** Return the manifest-generated definition. */
|
|
182
|
+
definition(): QueryDefinition;
|
|
183
|
+
/** Read and validate one metadata page. */
|
|
184
|
+
invoke(call: Call, _input: ListDatabasesInput): Promise<QueryAttempt<DatabasesPage>>;
|
|
82
185
|
}
|
|
83
|
-
/**
|
|
186
|
+
/** Read up to 100 tables from ClickHouse system metadata. */
|
|
84
187
|
declare class ListTablesOperation implements Query<ListTablesInput, TablesPage> {
|
|
85
188
|
private readonly client;
|
|
86
|
-
/** Bind the
|
|
87
|
-
|
|
88
|
-
/**
|
|
189
|
+
/** Bind the metadata client. */
|
|
190
|
+
constructor(client: ClickHouseClient);
|
|
191
|
+
/** Return the manifest-generated definition. */
|
|
192
|
+
definition(): QueryDefinition;
|
|
193
|
+
/** Read and validate one metadata page. */
|
|
89
194
|
invoke(call: Call, input: ListTablesInput): Promise<QueryAttempt<TablesPage>>;
|
|
90
195
|
}
|
|
196
|
+
/** Read up to 100 columns from ClickHouse system metadata. */
|
|
197
|
+
declare class ListColumnsOperation implements Query<ListColumnsInput, ColumnsPage> {
|
|
198
|
+
private readonly client;
|
|
199
|
+
/** Bind the metadata client. */
|
|
200
|
+
constructor(client: ClickHouseClient);
|
|
201
|
+
/** Return the manifest-generated definition. */
|
|
202
|
+
definition(): QueryDefinition;
|
|
203
|
+
/** Read and validate one metadata page. */
|
|
204
|
+
invoke(call: Call, input: ListColumnsInput): Promise<QueryAttempt<ColumnsPage>>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** A named binding whose default shape accepts historical table-only clients. */
|
|
208
|
+
type Connection<Bound = Pick<Operations, 'listTables'>> = Connection$1<Bound>;
|
|
209
|
+
/** Construct a named ClickHouse binding with an explicit operation set. */
|
|
210
|
+
declare const Connection: typeof Connection$1;
|
|
211
|
+
/** Bind the supplied operations and retain the concrete client's type for typed Steps. */
|
|
212
|
+
declare function newConnection<Bound extends Pick<Operations, 'listTables'>>(client: Bound, reference: ConnectionRef): Connection<Bound>;
|
|
213
|
+
/** Bind a scripted table query and any additional metadata operations it provides. */
|
|
214
|
+
declare function newConnectionWithOperations<Bound extends Pick<Operations, 'listTables'>>(operations: Bound, reference: ConnectionRef): Connection<Bound>;
|
|
91
215
|
|
|
92
|
-
export { ClickHouseClient, type ClickHouseClientOptions, Config, Connection, ConnectorID, Credentials, ListTablesBranch, ListTablesBranchDefect, ListTablesBranchInvalidResponse, ListTablesBranchListed, ListTablesBranchProviderRejected, ListTablesDefinition, ListTablesInput, ListTablesMetadata, ListTablesOperation, type ListTablesStepConfig, ProviderID, TablesPage, newListTablesStep, newProjectConnection };
|
|
216
|
+
export { ClickHouseClient, type ClickHouseClientOptions, ColumnsPage, Config, Connection, ConnectorID, Credentials, DatabasesPage, ListColumnsBranch, ListColumnsBranchDefect, ListColumnsBranchInvalidResponse, ListColumnsBranchListed, ListColumnsBranchProviderRejected, ListColumnsDefinition, ListColumnsInput, ListColumnsMetadata, ListColumnsOperation, type ListColumnsStepConfig, ListDatabasesBranch, ListDatabasesBranchDefect, ListDatabasesBranchInvalidResponse, ListDatabasesBranchListed, ListDatabasesBranchProviderRejected, ListDatabasesDefinition, ListDatabasesInput, ListDatabasesMetadata, ListDatabasesOperation, type ListDatabasesStepConfig, ListTablesBranch, ListTablesBranchDefect, ListTablesBranchInvalidResponse, ListTablesBranchListed, ListTablesBranchProviderRejected, ListTablesDefinition, ListTablesInput, ListTablesMetadata, ListTablesOperation, type ListTablesStepConfig, Operations, ProviderID, TablesPage, newConnection, newConnectionWithOperations, newListColumnsStep, newListDatabasesStep, newListTablesStep, newProjectConnection };
|