@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/dist/index.js CHANGED
@@ -1,7 +1,27 @@
1
1
  import {
2
+ ColumnSchema,
3
+ ColumnsPageSchema,
2
4
  ConfigSchema,
3
5
  Connection,
4
6
  ConnectorID,
7
+ CredentialMaterialError,
8
+ DatabasesPageSchema,
9
+ ListColumnsBranch,
10
+ ListColumnsBranchDefect,
11
+ ListColumnsBranchInvalidResponse,
12
+ ListColumnsBranchListed,
13
+ ListColumnsBranchProviderRejected,
14
+ ListColumnsDefinition,
15
+ ListColumnsInputSchema,
16
+ ListColumnsMetadata,
17
+ ListDatabasesBranch,
18
+ ListDatabasesBranchDefect,
19
+ ListDatabasesBranchInvalidResponse,
20
+ ListDatabasesBranchListed,
21
+ ListDatabasesBranchProviderRejected,
22
+ ListDatabasesDefinition,
23
+ ListDatabasesInputSchema,
24
+ ListDatabasesMetadata,
5
25
  ListTablesBranch,
6
26
  ListTablesBranchDefect,
7
27
  ListTablesBranchInvalidResponse,
@@ -13,13 +33,22 @@ import {
13
33
  ProviderID,
14
34
  TablesPageSchema,
15
35
  decodeCredentials,
16
- newConnection,
17
- newConnectionWithOperations,
36
+ isCredentialMaterialError,
18
37
  newProjectConnection
19
- } from "./chunk-F5PUPLRK.js";
38
+ } from "./chunk-23BBEJPR.js";
20
39
 
21
40
  // src/generated/steps.ts
22
41
  import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
42
+ function newListDatabasesStep(configuration) {
43
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
44
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
45
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listDatabases(), connection: connection.reference, branches: [
46
+ goToBranch("listed", listed),
47
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
48
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
49
+ ...defect ? [goToBranch("defect", defect)] : []
50
+ ] });
51
+ }
23
52
  function newListTablesStep(configuration) {
24
53
  const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
25
54
  if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
@@ -30,15 +59,37 @@ function newListTablesStep(configuration) {
30
59
  ...defect ? [goToBranch("defect", defect)] : []
31
60
  ] });
32
61
  }
62
+ function newListColumnsStep(configuration) {
63
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
64
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
65
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listColumns(), connection: connection.reference, branches: [
66
+ goToBranch("listed", listed),
67
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
68
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
69
+ ...defect ? [goToBranch("defect", defect)] : []
70
+ ] });
71
+ }
33
72
 
34
73
  // src/project.ts
35
74
  import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
36
75
  import { z } from "zod";
37
76
 
38
77
  // src/client.ts
39
- import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
40
- import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
78
+ import {
79
+ SecretString,
80
+ newQueryBranch,
81
+ newQueryRetry
82
+ } from "@superdurable/connectors-sdk";
83
+ import {
84
+ BodyTooLargeError,
85
+ isHeaderSafeCredential,
86
+ parseRetryAfter,
87
+ sendProviderRequest,
88
+ validateBaseURL
89
+ } from "@superdurable/connectors-sdk/providerhttp";
41
90
  var listTablesSQL = "SELECT name FROM system.tables WHERE database = {database:String} ORDER BY name LIMIT 101 FORMAT JSON";
91
+ var listDatabasesSQL = "SELECT name FROM system.databases ORDER BY name LIMIT 101 FORMAT JSON";
92
+ var listColumnsSQL = "SELECT name, type FROM system.columns WHERE database = {database:String} AND table = {table:String} ORDER BY position LIMIT 101 FORMAT JSON";
42
93
  var emptyTables = () => ({ database: "", names: [], hasMore: false });
43
94
  var ClickHouseClient = class {
44
95
  /** Validate provider configuration without contacting ClickHouse. */
@@ -61,8 +112,27 @@ var ClickHouseClient = class {
61
112
  listTables() {
62
113
  return new ListTablesOperation(this);
63
114
  }
115
+ /** Bind the database catalog Query. */
116
+ listDatabases() {
117
+ return new ListDatabasesOperation(this);
118
+ }
119
+ /** Bind the ordered column metadata Query. */
120
+ listColumns() {
121
+ return new ListColumnsOperation(this);
122
+ }
123
+ /** Resolve credentials and send one bounded database query. */
124
+ getDatabases(call) {
125
+ return this.readMetadata(call, listDatabasesSQL, {});
126
+ }
127
+ /** Resolve credentials and send one bounded column query. */
128
+ getColumns(call, database, table) {
129
+ return this.readMetadata(call, listColumnsSQL, { param_database: database, param_table: table });
130
+ }
64
131
  /** Resolve credentials and send one bounded table query. */
65
132
  async get(call, database) {
133
+ return this.readMetadata(call, listTablesSQL, { param_database: database });
134
+ }
135
+ async readMetadata(call, sql, parameters) {
66
136
  let username;
67
137
  let password;
68
138
  try {
@@ -72,10 +142,11 @@ var ClickHouseClient = class {
72
142
  } catch {
73
143
  return emptyExchange("credential");
74
144
  }
75
- if (!isHeaderSafeCredential(username) || !isHeaderSafeCredential(password)) return emptyExchange("credential");
145
+ if (!isHeaderSafeCredential(username) || !isHeaderSafeCredential(password))
146
+ return emptyExchange("credential");
76
147
  const url = new URL(`${this.baseURL}/`);
77
- url.searchParams.set("query", listTablesSQL);
78
- url.searchParams.set("param_database", database);
148
+ url.searchParams.set("query", sql);
149
+ for (const [name, value] of Object.entries(parameters)) url.searchParams.set(name, value);
79
150
  const request = {
80
151
  url: url.toString(),
81
152
  method: "GET",
@@ -101,46 +172,120 @@ var ClickHouseClient = class {
101
172
  return { status: response.status, body: response.body, retryAfterMs };
102
173
  }
103
174
  };
175
+ var ListDatabasesOperation = class {
176
+ /** Bind the metadata client. */
177
+ constructor(client) {
178
+ this.client = client;
179
+ }
180
+ client;
181
+ /** Return the manifest-generated definition. */
182
+ definition() {
183
+ return ListDatabasesDefinition;
184
+ }
185
+ /** Read and validate one metadata page. */
186
+ async invoke(call, _input) {
187
+ void _input;
188
+ const empty = { names: [], hasMore: false };
189
+ const exchange = await this.client.getDatabases(call);
190
+ return metadataAttempt(exchange, "listDatabases", empty, (rows) => {
191
+ return { names: rows.slice(0, 100).map((row) => row.name), hasMore: rows.length > 100 };
192
+ });
193
+ }
194
+ };
104
195
  var ListTablesOperation = class {
105
- /** Bind the provider client. */
196
+ /** Bind the metadata client. */
106
197
  constructor(client) {
107
198
  this.client = client;
108
199
  }
109
200
  client;
110
- /** Return the generated Query definition. */
201
+ /** Return the manifest-generated definition. */
111
202
  definition() {
112
203
  return ListTablesDefinition;
113
204
  }
114
- /** Classify provider outcomes consistently with Go. */
205
+ /** Read and validate one metadata page. */
115
206
  async invoke(call, input) {
207
+ const empty = emptyTables();
116
208
  if (!isValidDatabase(input?.database))
117
- return terminal("defect", "VALIDATION", "database must contain 1\u2013128 printable characters");
209
+ return newQueryBranch(
210
+ "defect",
211
+ empty,
212
+ {},
213
+ failure("listTables", "VALIDATION", "Invalid ClickHouse metadata identifier")
214
+ );
118
215
  const exchange = await this.client.get(call, input.database);
119
- if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "ClickHouse credentials are unavailable or invalid");
120
- if (exchange.error === "request") return retry("TRANSPORT", "ClickHouse request failed");
121
- if (exchange.status === 429) return retry("RATE_LIMIT", "ClickHouse rate limited the request", exchange.retryAfterMs);
122
- if (exchange.status === 408 || exchange.status >= 500) return retry("AVAILABILITY", "ClickHouse is temporarily unavailable", exchange.retryAfterMs);
123
- if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `ClickHouse rejected HTTP ${exchange.status}`);
124
- if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "ClickHouse response exceeded the configured limit");
125
- const tables = decodeTables(exchange.body, input.database);
126
- if (!tables) return terminal("invalidResponse", "PROTOCOL", "ClickHouse returned invalid table-list JSON");
127
- return newQueryBranch("listed", tables);
216
+ return metadataAttempt(exchange, "listTables", empty, (rows) => {
217
+ return {
218
+ database: input.database,
219
+ names: rows.slice(0, 100).map((row) => row.name),
220
+ hasMore: rows.length > 100
221
+ };
222
+ });
223
+ }
224
+ };
225
+ var ListColumnsOperation = class {
226
+ /** Bind the metadata client. */
227
+ constructor(client) {
228
+ this.client = client;
229
+ }
230
+ client;
231
+ /** Return the manifest-generated definition. */
232
+ definition() {
233
+ return ListColumnsDefinition;
234
+ }
235
+ /** Read and validate one metadata page. */
236
+ async invoke(call, input) {
237
+ const empty = { database: "", table: "", columns: [], hasMore: false };
238
+ if (!isValidDatabase(input?.database) || !isValidDatabase(input?.table))
239
+ return newQueryBranch(
240
+ "defect",
241
+ empty,
242
+ {},
243
+ failure("listColumns", "VALIDATION", "Invalid ClickHouse metadata identifier")
244
+ );
245
+ const exchange = await this.client.getColumns(call, input.database, input.table);
246
+ return metadataAttempt(exchange, "listColumns", empty, (rows) => {
247
+ const columns = [];
248
+ for (const row of rows) {
249
+ if (typeof row.type !== "string" || !row.type) return void 0;
250
+ if (columns.length < 100) columns.push({ name: row.name, type: row.type });
251
+ }
252
+ return { database: input.database, table: input.table, columns, hasMore: rows.length > 100 };
253
+ });
128
254
  }
129
255
  };
130
256
  function isValidDatabase(value) {
131
- return typeof value === "string" && value.length > 0 && value.trim() === value && new TextEncoder().encode(value).length <= 128 && [...value].every((character) => character.codePointAt(0) >= 32 && character.codePointAt(0) !== 127) && !/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF])/.test(value);
257
+ return typeof value === "string" && value.length > 0 && value.trim() === value && new TextEncoder().encode(value).length <= 128 && [...value].every(
258
+ (character) => character.codePointAt(0) >= 32 && character.codePointAt(0) !== 127
259
+ ) && !/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF])/.test(value);
132
260
  }
133
261
  function emptyExchange(error) {
134
262
  return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
135
263
  }
136
- function failure(kind, message) {
137
- return { provider: "clickhouse", operation: "listTables", kind, message };
264
+ function failure(operation, kind, message) {
265
+ return { provider: "clickhouse", operation, kind, message };
138
266
  }
139
- function terminal(branch, kind, message) {
140
- return newQueryBranch(branch, emptyTables(), {}, failure(kind, message));
141
- }
142
- function retry(kind, message, delay = 0) {
143
- return newQueryRetry(failure(kind, message), delay);
267
+ function metadataAttempt(exchange, operation, empty, project) {
268
+ const terminal = (branch, kind, message) => newQueryBranch(branch, empty, {}, failure(operation, kind, message));
269
+ const retry = (kind, message, delay = 0) => newQueryRetry(failure(operation, kind, message), delay);
270
+ if (exchange.error === "credential")
271
+ return terminal("defect", "AUTHENTICATION", "ClickHouse credentials are unavailable or invalid");
272
+ if (exchange.error === "request") return retry("TRANSPORT", "ClickHouse request failed");
273
+ if (exchange.status === 429)
274
+ return retry("RATE_LIMIT", "ClickHouse rate limited the request", exchange.retryAfterMs);
275
+ if (exchange.status === 408 || exchange.status >= 500)
276
+ return retry("AVAILABILITY", "ClickHouse is temporarily unavailable", exchange.retryAfterMs);
277
+ if (exchange.status !== 200)
278
+ return terminal("providerRejected", "PROVIDER_REJECTION", `ClickHouse rejected HTTP ${exchange.status}`);
279
+ if (exchange.error === "tooLarge")
280
+ return terminal(
281
+ "invalidResponse",
282
+ "RESPONSE_TOO_LARGE",
283
+ "ClickHouse response exceeded the configured limit"
284
+ );
285
+ const rows = decodeRows(exchange.body);
286
+ const page = rows && project(rows);
287
+ if (!page) return terminal("invalidResponse", "PROTOCOL", "ClickHouse returned invalid metadata JSON");
288
+ return newQueryBranch("listed", page);
144
289
  }
145
290
  function header(headers, name) {
146
291
  const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
@@ -149,20 +294,27 @@ function header(headers, name) {
149
294
  function isObject(value) {
150
295
  return typeof value === "object" && value !== null && !Array.isArray(value);
151
296
  }
152
- function decodeTables(body, database) {
297
+ function metadataFields(key, value, context) {
298
+ if (key.toLowerCase() === "rows" && typeof value === "number" && context?.source && !/^-?\d+$/.test(context.source))
299
+ return NaN;
300
+ if (!isObject(value)) return value;
301
+ return Object.fromEntries(Object.entries(value).map(([name, field]) => [name.toLowerCase(), field]));
302
+ }
303
+ function decodeRows(body) {
153
304
  let raw;
154
305
  try {
155
- raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
306
+ raw = JSON.parse(new TextDecoder().decode(body), metadataFields);
156
307
  } catch {
157
308
  return void 0;
158
309
  }
159
- if (!isObject(raw) || !Array.isArray(raw.data) || raw.data.length > 101 || !Number.isSafeInteger(raw.rows) || raw.rows !== raw.data.length) return void 0;
160
- const names = [];
161
- for (const row of raw.data) {
162
- if (!isObject(row) || typeof row.name !== "string" || !row.name) return void 0;
163
- if (names.length < 100) names.push(row.name);
164
- }
165
- return { database, names, hasMore: raw.data.length > 100 };
310
+ if (!isObject(raw) || !Array.isArray(raw.data) || raw.data.length > 101 || (raw.rows ?? 0) !== raw.data.length)
311
+ return void 0;
312
+ const data = raw.data;
313
+ if (!data.every(
314
+ (row) => isObject(row) && typeof row.name === "string" && row.name.length > 0
315
+ ))
316
+ return void 0;
317
+ return data;
166
318
  }
167
319
 
168
320
  // src/project.ts
@@ -200,11 +352,42 @@ function parseDurationMilliseconds(value) {
200
352
  if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("ClickHouse timeout must resolve to positive whole milliseconds");
201
353
  return milliseconds;
202
354
  }
355
+
356
+ // src/index.ts
357
+ var Connection2 = Connection;
358
+ function newConnection(client, reference) {
359
+ return new Connection2(reference, client);
360
+ }
361
+ function newConnectionWithOperations(operations, reference) {
362
+ return newConnection(operations, reference);
363
+ }
203
364
  export {
204
365
  ClickHouseClient,
366
+ ColumnSchema,
367
+ ColumnsPageSchema,
205
368
  ConfigSchema,
206
- Connection,
369
+ Connection2 as Connection,
207
370
  ConnectorID,
371
+ CredentialMaterialError,
372
+ DatabasesPageSchema,
373
+ ListColumnsBranch,
374
+ ListColumnsBranchDefect,
375
+ ListColumnsBranchInvalidResponse,
376
+ ListColumnsBranchListed,
377
+ ListColumnsBranchProviderRejected,
378
+ ListColumnsDefinition,
379
+ ListColumnsInputSchema,
380
+ ListColumnsMetadata,
381
+ ListColumnsOperation,
382
+ ListDatabasesBranch,
383
+ ListDatabasesBranchDefect,
384
+ ListDatabasesBranchInvalidResponse,
385
+ ListDatabasesBranchListed,
386
+ ListDatabasesBranchProviderRejected,
387
+ ListDatabasesDefinition,
388
+ ListDatabasesInputSchema,
389
+ ListDatabasesMetadata,
390
+ ListDatabasesOperation,
208
391
  ListTablesBranch,
209
392
  ListTablesBranchDefect,
210
393
  ListTablesBranchInvalidResponse,
@@ -217,8 +400,11 @@ export {
217
400
  ProviderID,
218
401
  TablesPageSchema,
219
402
  decodeCredentials,
403
+ isCredentialMaterialError,
220
404
  newConnection,
221
405
  newConnectionWithOperations,
406
+ newListColumnsStep,
407
+ newListDatabasesStep,
222
408
  newListTablesStep,
223
409
  newProjectConnection2 as newProjectConnection
224
410
  };
package/dist/mock.d.ts CHANGED
@@ -1,12 +1,36 @@
1
1
  import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
2
2
  import { Failure } from '@superdurable/connectors-sdk';
3
- import { O as Operations, C as Connection, L as ListTablesInput, T as TablesPage } from './connection-zXWJ_3zD.js';
3
+ import { O as Operations, a as Connection, b as ListDatabasesInput, D as DatabasesPage, c as ListTablesInput, T as TablesPage, L as ListColumnsInput, C as ColumnsPage, f as Column } from './connection-IQqDAR8z.js';
4
4
  import 'zod';
5
5
 
6
+ /** Go zero value for ListDatabasesInput in scripted cases. */
7
+ declare const emptyListDatabasesInput: ListDatabasesInput;
8
+ /** Go zero value for DatabasesPage in scripted cases. */
9
+ declare const emptyDatabasesPage: DatabasesPage;
6
10
  /** Go zero value for ListTablesInput in scripted cases. */
7
11
  declare const emptyListTablesInput: ListTablesInput;
8
12
  /** Go zero value for TablesPage in scripted cases. */
9
13
  declare const emptyTablesPage: TablesPage;
14
+ /** Go zero value for ListColumnsInput in scripted cases. */
15
+ declare const emptyListColumnsInput: ListColumnsInput;
16
+ /** Go zero value for Column in scripted cases. */
17
+ declare const emptyColumn: Column;
18
+ /** Go zero value for ColumnsPage in scripted cases. */
19
+ declare const emptyColumnsPage: ColumnsPage;
20
+ /** Script the listed branch. */
21
+ declare function listDatabasesListed(value: DatabasesPage, failure?: Failure): Case<DatabasesPage>;
22
+ /** Script the providerRejected branch. */
23
+ declare function listDatabasesProviderRejected(value: DatabasesPage, failure?: Failure): Case<DatabasesPage>;
24
+ /** Script the invalidResponse branch. */
25
+ declare function listDatabasesInvalidResponse(value: DatabasesPage, failure?: Failure): Case<DatabasesPage>;
26
+ /** Script the defect branch. */
27
+ declare function listDatabasesDefect(value: DatabasesPage, failure?: Failure): Case<DatabasesPage>;
28
+ /** Script a safe retry of listDatabases. */
29
+ declare function listDatabasesRetry(failure: Failure, retryAfterMs?: number): Case<DatabasesPage>;
30
+ /** Manifest scenario listedDefault for listDatabases. */
31
+ declare function listDatabasesListedDefault(): Case<DatabasesPage>;
32
+ /** Default listDatabases scenario. */
33
+ declare function listDatabasesDefault(): Case<DatabasesPage>;
10
34
  /** Script the listed branch. */
11
35
  declare function listTablesListed(value: TablesPage, failure?: Failure): Case<TablesPage>;
12
36
  /** Script the providerRejected branch. */
@@ -21,13 +45,29 @@ declare function listTablesRetry(failure: Failure, retryAfterMs?: number): Case<
21
45
  declare function listTablesListedDefault(): Case<TablesPage>;
22
46
  /** Default listTables scenario. */
23
47
  declare function listTablesDefault(): Case<TablesPage>;
48
+ /** Script the listed branch. */
49
+ declare function listColumnsListed(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
50
+ /** Script the providerRejected branch. */
51
+ declare function listColumnsProviderRejected(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
52
+ /** Script the invalidResponse branch. */
53
+ declare function listColumnsInvalidResponse(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
54
+ /** Script the defect branch. */
55
+ declare function listColumnsDefect(value: ColumnsPage, failure?: Failure): Case<ColumnsPage>;
56
+ /** Script a safe retry of listColumns. */
57
+ declare function listColumnsRetry(failure: Failure, retryAfterMs?: number): Case<ColumnsPage>;
58
+ /** Manifest scenario listedDefault for listColumns. */
59
+ declare function listColumnsListedDefault(): Case<ColumnsPage>;
60
+ /** Default listColumns scenario. */
61
+ declare function listColumnsDefault(): Case<ColumnsPage>;
24
62
  /** Scripted operations and manifest defaults for this connector. */
25
63
  declare class GeneratedMock implements Operations {
26
64
  #private;
27
65
  constructor(connectionName: string);
28
66
  connection(): Connection;
67
+ listDatabases(): MockQuery<ListDatabasesInput, DatabasesPage>;
29
68
  listTables(): MockQuery<ListTablesInput, TablesPage>;
69
+ listColumns(): MockQuery<ListColumnsInput, ColumnsPage>;
30
70
  assertNoFailures(): void;
31
71
  }
32
72
 
33
- export { GeneratedMock, GeneratedMock as Mock, emptyListTablesInput, emptyTablesPage, listTablesDefault, listTablesDefect, listTablesInvalidResponse, listTablesListed, listTablesListedDefault, listTablesProviderRejected, listTablesRetry };
73
+ export { GeneratedMock, GeneratedMock as Mock, emptyColumn, emptyColumnsPage, emptyDatabasesPage, emptyListColumnsInput, emptyListDatabasesInput, emptyListTablesInput, emptyTablesPage, listColumnsDefault, listColumnsDefect, listColumnsInvalidResponse, listColumnsListed, listColumnsListedDefault, listColumnsProviderRejected, listColumnsRetry, listDatabasesDefault, listDatabasesDefect, listDatabasesInvalidResponse, listDatabasesListed, listDatabasesListedDefault, listDatabasesProviderRejected, listDatabasesRetry, listTablesDefault, listTablesDefect, listTablesInvalidResponse, listTablesListed, listTablesListedDefault, listTablesProviderRejected, listTablesRetry };
package/dist/mock.js CHANGED
@@ -1,13 +1,25 @@
1
1
  import {
2
+ ColumnSchema,
3
+ ColumnsPageSchema,
4
+ DatabasesPageSchema,
5
+ ListColumnsDefinition,
6
+ ListColumnsInputSchema,
7
+ ListDatabasesDefinition,
8
+ ListDatabasesInputSchema,
2
9
  ListTablesDefinition,
3
10
  ListTablesInputSchema,
4
11
  ProviderID,
5
12
  TablesPageSchema,
6
13
  newConnectionWithOperations
7
- } from "./chunk-F5PUPLRK.js";
14
+ } from "./chunk-23BBEJPR.js";
8
15
 
9
16
  // src/generated/mock.ts
10
17
  import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
18
+ var emptyListDatabasesInput = ListDatabasesInputSchema.parse({});
19
+ var emptyDatabasesPage = DatabasesPageSchema.parse({
20
+ "names": [],
21
+ "hasMore": false
22
+ });
11
23
  var emptyListTablesInput = ListTablesInputSchema.parse({
12
24
  "database": ""
13
25
  });
@@ -16,6 +28,42 @@ var emptyTablesPage = TablesPageSchema.parse({
16
28
  "names": [],
17
29
  "hasMore": false
18
30
  });
31
+ var emptyListColumnsInput = ListColumnsInputSchema.parse({
32
+ "database": "",
33
+ "table": ""
34
+ });
35
+ var emptyColumn = ColumnSchema.parse({
36
+ "name": "",
37
+ "type": ""
38
+ });
39
+ var emptyColumnsPage = ColumnsPageSchema.parse({
40
+ "database": "",
41
+ "table": "",
42
+ "columns": [],
43
+ "hasMore": false
44
+ });
45
+ function listDatabasesListed(value, failure) {
46
+ return branchCase("listed", value, failure);
47
+ }
48
+ function listDatabasesProviderRejected(value, failure) {
49
+ return branchCase("providerRejected", value, failure);
50
+ }
51
+ function listDatabasesInvalidResponse(value, failure) {
52
+ return branchCase("invalidResponse", value, failure);
53
+ }
54
+ function listDatabasesDefect(value, failure) {
55
+ return branchCase("defect", value, failure);
56
+ }
57
+ function listDatabasesRetry(failure, retryAfterMs = 0) {
58
+ return retryCase(failure, retryAfterMs);
59
+ }
60
+ function listDatabasesListedDefault() {
61
+ const value = DatabasesPageSchema.parse({ "hasMore": false, "names": ["analytics", "default"] });
62
+ return branchCase("listed", value);
63
+ }
64
+ function listDatabasesDefault() {
65
+ return listDatabasesListedDefault();
66
+ }
19
67
  function listTablesListed(value, failure) {
20
68
  return branchCase("listed", value, failure);
21
69
  }
@@ -38,28 +86,81 @@ function listTablesListedDefault() {
38
86
  function listTablesDefault() {
39
87
  return listTablesListedDefault();
40
88
  }
89
+ function listColumnsListed(value, failure) {
90
+ return branchCase("listed", value, failure);
91
+ }
92
+ function listColumnsProviderRejected(value, failure) {
93
+ return branchCase("providerRejected", value, failure);
94
+ }
95
+ function listColumnsInvalidResponse(value, failure) {
96
+ return branchCase("invalidResponse", value, failure);
97
+ }
98
+ function listColumnsDefect(value, failure) {
99
+ return branchCase("defect", value, failure);
100
+ }
101
+ function listColumnsRetry(failure, retryAfterMs = 0) {
102
+ return retryCase(failure, retryAfterMs);
103
+ }
104
+ function listColumnsListedDefault() {
105
+ const value = ColumnsPageSchema.parse({ "columns": [{ "name": "id", "type": "UInt64" }, { "name": "event", "type": "String" }], "database": "analytics", "hasMore": false, "table": "events" });
106
+ return branchCase("listed", value);
107
+ }
108
+ function listColumnsDefault() {
109
+ return listColumnsListedDefault();
110
+ }
41
111
  var GeneratedMock = class {
112
+ #listDatabases;
42
113
  #listTables;
114
+ #listColumns;
43
115
  #connection;
44
116
  constructor(connectionName) {
117
+ this.#listDatabases = newQuery(ListDatabasesDefinition).default(listDatabasesDefault());
45
118
  this.#listTables = newQuery(ListTablesDefinition).default(listTablesDefault());
119
+ this.#listColumns = newQuery(ListColumnsDefinition).default(listColumnsDefault());
46
120
  this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
47
121
  }
48
122
  connection() {
49
123
  return this.#connection;
50
124
  }
125
+ listDatabases() {
126
+ return this.#listDatabases;
127
+ }
51
128
  listTables() {
52
129
  return this.#listTables;
53
130
  }
131
+ listColumns() {
132
+ return this.#listColumns;
133
+ }
54
134
  assertNoFailures() {
135
+ this.#listDatabases.assertNoFailures();
55
136
  this.#listTables.assertNoFailures();
137
+ this.#listColumns.assertNoFailures();
56
138
  }
57
139
  };
58
140
  export {
59
141
  GeneratedMock,
60
142
  GeneratedMock as Mock,
143
+ emptyColumn,
144
+ emptyColumnsPage,
145
+ emptyDatabasesPage,
146
+ emptyListColumnsInput,
147
+ emptyListDatabasesInput,
61
148
  emptyListTablesInput,
62
149
  emptyTablesPage,
150
+ listColumnsDefault,
151
+ listColumnsDefect,
152
+ listColumnsInvalidResponse,
153
+ listColumnsListed,
154
+ listColumnsListedDefault,
155
+ listColumnsProviderRejected,
156
+ listColumnsRetry,
157
+ listDatabasesDefault,
158
+ listDatabasesDefect,
159
+ listDatabasesInvalidResponse,
160
+ listDatabasesListed,
161
+ listDatabasesListedDefault,
162
+ listDatabasesProviderRejected,
163
+ listDatabasesRetry,
63
164
  listTablesDefault,
64
165
  listTablesDefect,
65
166
  listTablesInvalidResponse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-clickhouse",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "ClickHouse connector for Dex TypeScript applications",
6
6
  "repository": {