@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.
@@ -1,105 +0,0 @@
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
- function decodeCredentials(value) {
10
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
11
- const fields = value;
12
- const allowed = /* @__PURE__ */ new Set(["password", "username"]);
13
- if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
14
- if (fields["password"] != null && !(typeof fields["password"] === "string")) throw new TypeError("credential password has an invalid type");
15
- if (fields["username"] != null && !(typeof fields["username"] === "string")) throw new TypeError("credential username has an invalid type");
16
- const credentials = {};
17
- if (!fields["username"]) throw new TypeError("credential username is required");
18
- credentials.username = fields["username"] ?? "";
19
- if (!fields["password"]) throw new TypeError("credential password is required");
20
- credentials.password = new SecretString(fields["password"] ?? "");
21
- return credentials;
22
- }
23
- var ListTablesInputSchema = z.strictObject({
24
- "database": z.string()
25
- });
26
- var TablesPageSchema = z.strictObject({
27
- "database": z.string(),
28
- "names": z.array(z.string()).nullable(),
29
- "hasMore": z.boolean()
30
- });
31
-
32
- // src/generated/definitions.ts
33
- var ConnectorID = "clickhouse";
34
- var ProviderID = "clickhouse";
35
- var ListTablesBranch = {
36
- Listed: "listed",
37
- ProviderRejected: "providerRejected",
38
- InvalidResponse: "invalidResponse",
39
- Defect: "defect"
40
- };
41
- var ListTablesBranchListed = ListTablesBranch.Listed;
42
- var ListTablesBranchProviderRejected = ListTablesBranch.ProviderRejected;
43
- var ListTablesBranchInvalidResponse = ListTablesBranch.InvalidResponse;
44
- var ListTablesBranchDefect = ListTablesBranch.Defect;
45
- var ListTablesDefinition = {
46
- operation: { connectorId: ConnectorID, operationId: "listTables" },
47
- branches: [
48
- { id: "listed", description: "ClickHouse returned the table names." },
49
- { id: "providerRejected", description: "ClickHouse conclusively rejected the metadata query.", optional: true },
50
- { id: "invalidResponse", description: "ClickHouse returned malformed or oversized JSON.", optional: true },
51
- { id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
52
- ],
53
- stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
54
- };
55
- var ListTablesMetadata = { kind: "query", idempotency: "none", authorization: "required" };
56
-
57
- // src/generated/connection.ts
58
- import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
59
- var Connection = class {
60
- /** Stable provider and connection name. */
61
- reference;
62
- /** Bound provider operations. */
63
- operations;
64
- /** Validate a reference and bind operations. */
65
- constructor(reference, operations) {
66
- this.reference = ConnectionRefSchema.parse(reference);
67
- if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
68
- if (!operations) throw new TypeError("connector operations are required");
69
- this.operations = operations;
70
- }
71
- };
72
- function newConnection(client, reference) {
73
- if (!client) throw new TypeError("connector client is required");
74
- return new Connection(reference, client);
75
- }
76
- function newConnectionWithOperations(operations, reference) {
77
- return new Connection(reference, operations);
78
- }
79
- function newProjectConnection(project, connectionName, createClient) {
80
- if (!project) throw new TypeError("loaded project is required");
81
- const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
82
- const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
83
- if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
84
- return newConnection(createClient(project, connectionName), reference);
85
- }
86
-
87
- export {
88
- ConfigSchema,
89
- decodeCredentials,
90
- ListTablesInputSchema,
91
- TablesPageSchema,
92
- ConnectorID,
93
- ProviderID,
94
- ListTablesBranch,
95
- ListTablesBranchListed,
96
- ListTablesBranchProviderRejected,
97
- ListTablesBranchInvalidResponse,
98
- ListTablesBranchDefect,
99
- ListTablesDefinition,
100
- ListTablesMetadata,
101
- Connection,
102
- newConnection,
103
- newConnectionWithOperations,
104
- newProjectConnection
105
- };
@@ -1,74 +0,0 @@
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 table-list 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.tables; blank prevents calls. Dex sends it in X-ClickHouse-User. */
24
- username: string;
25
- }
26
- /** Decode private credential fields for the connector. */
27
- declare function decodeCredentials(value: unknown): Credentials;
28
- /** Host-owned source of private connector credentials. */
29
- type CredentialSource = CredentialProvider<Credentials>;
30
- /** ListTablesInput selects the non-secret ClickHouse database to inspect. */
31
- interface ListTablesInput {
32
- /** Database is the exact database name shown by SHOW DATABASES. */
33
- "database": string;
34
- }
35
- /** TablesPage contains at most 100 sorted table names. */
36
- interface TablesPage {
37
- /** Database is the database that was inspected. */
38
- "database": string;
39
- /** Names contains the first 100 table names in sorted order. */
40
- "names": Array<string> | null;
41
- /** HasMore reports whether another table was present after the first 100. */
42
- "hasMore": boolean;
43
- }
44
- /** Runtime validator for ListTablesInput. */
45
- declare const ListTablesInputSchema: z.ZodObject<{
46
- database: z.ZodString;
47
- }, z.core.$strict>;
48
- /** Runtime validator for TablesPage. */
49
- declare const TablesPageSchema: z.ZodObject<{
50
- database: z.ZodString;
51
- names: z.ZodNullable<z.ZodArray<z.ZodString>>;
52
- hasMore: z.ZodBoolean;
53
- }, z.core.$strict>;
54
-
55
- /** Typed operations supplied by a client or mock. */
56
- interface Operations {
57
- /** Invoke listTables through this connection. */
58
- listTables(): Query<ListTablesInput, TablesPage>;
59
- }
60
- /** Named connector connection kept outside Flow state. */
61
- declare class Connection<BoundOperations = Operations> {
62
- /** Stable provider and connection name. */
63
- readonly reference: ConnectionRef;
64
- /** Bound provider operations. */
65
- readonly operations: BoundOperations;
66
- /** Validate a reference and bind operations. */
67
- constructor(reference: ConnectionRef, operations: BoundOperations);
68
- }
69
- /** Bind a client to a named connection. */
70
- declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
71
- /** Bind scripted operations to a named connection. */
72
- declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
73
-
74
- export { Connection as C, type ListTablesInput as L, type Operations as O, type TablesPage as T, type Config as a, type Credentials as b, ConfigSchema as c, type CredentialSource as d, ListTablesInputSchema as e, TablesPageSchema as f, decodeCredentials as g, newConnectionWithOperations as h, newConnection as n };