@voltro/plugin-clickhouse 0.86.0 → 0.88.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,7 @@
1
1
  import { EVENTS_TABLE_DDL as e, MIRROR_TABLE_DDL as t, assertIdentifier as n, buildClickhouseSink as r, closeClickhouseState as i, makeEventBatcher as a } from "./sink.js";
2
2
  import { createClient as o } from "@clickhouse/client";
3
3
  import { Effect as s } from "effect";
4
- //#region src/index.ts
4
+ // src/index.ts
5
5
  var c = 20, l = 5e3, u = (u) => {
6
6
  let d = (u.mirrorTables ?? []).map((e) => n(e, "mirror table")), f = {
7
7
  client: null,
@@ -19,22 +19,40 @@ var c = 20, l = 5e3, u = (u) => {
19
19
  }
20
20
  return {
21
21
  kind: "clickhouse",
22
- build: (e) => r(f),
22
+ sql: "none",
23
+ build: () => r(f),
23
24
  initialize: () => s.gen(function* () {
24
- let n = yield* s.promise(() => Promise.resolve(o({
25
+ let n = yield* s.sync(() => o({
25
26
  url: u.url,
26
27
  database: f.database,
27
28
  ...u.username === void 0 ? {} : { username: u.username },
28
29
  ...u.password === void 0 ? {} : { password: u.password }
29
- })));
30
- yield* s.promise(() => n.ping()), yield* s.promise(() => n.command({ query: e(f.database, f.table) }));
31
- for (let e of f.mirrorTables) yield* s.promise(() => n.command({ query: t(f.database, e) }));
32
- f.client = n;
33
- }),
30
+ }));
31
+ if (f.client = n, !(yield* s.tryPromise({
32
+ try: (e) => n.ping({
33
+ select: !1,
34
+ abort_signal: e
35
+ }),
36
+ catch: () => /* @__PURE__ */ Error("ClickHouse readiness failed")
37
+ })).success) return yield* s.fail(/* @__PURE__ */ Error("ClickHouse readiness failed"));
38
+ yield* s.tryPromise({
39
+ try: (t) => n.command({
40
+ query: e(f.database, f.table),
41
+ abort_signal: t
42
+ }),
43
+ catch: () => /* @__PURE__ */ Error("ClickHouse schema initialization failed")
44
+ });
45
+ for (let e of f.mirrorTables) yield* s.tryPromise({
46
+ try: (r) => n.command({
47
+ query: t(f.database, e),
48
+ abort_signal: r
49
+ }),
50
+ catch: () => /* @__PURE__ */ Error("ClickHouse mirror initialization failed")
51
+ });
52
+ }).pipe(s.onError(() => i(f))),
34
53
  dispose: () => s.gen(function* () {
35
- f.batcher && (yield* s.promise(() => f.batcher.flush())), yield* i(f);
36
- })
54
+ f.batcher && (yield* s.promise(() => f.batcher.flush()));
55
+ }).pipe(s.ensuring(i(f)))
37
56
  };
38
57
  };
39
- //#endregion
40
58
  export { e as EVENTS_TABLE_DDL, t as MIRROR_TABLE_DDL, u as clickhouseAnalytics };
package/dist/sink.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Effect as e } from "effect";
2
2
  import { createLogger as t } from "@voltro/logger";
3
3
  import { AnalyticsError as n } from "@voltro/runtime";
4
- //#region src/sink.ts
4
+ // src/sink.ts
5
5
  var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) => `voltro_mirror_${e}`, o = (e, t) => `
6
6
  CREATE TABLE IF NOT EXISTS ${e}.${a(t)} (
7
7
  id String,
@@ -255,5 +255,4 @@ var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) =>
255
255
  ...n === void 0 ? {} : { mirror: n }
256
256
  };
257
257
  };
258
- //#endregion
259
258
  export { s as EVENTS_TABLE_DDL, o as MIRROR_TABLE_DDL, d as assertIdentifier, E as buildClickhouseSink, g as closeClickhouseState, v as makeEventBatcher, a as mirrorTableName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-clickhouse",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "description": "ClickHouse AnalyticsSink. Native HTTP ingest into a ClickHouse cluster — self-hosted OR ClickHouse Cloud. Production-grade OLAP for high-cardinality events with millisecond aggregate queries over billions of rows.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -33,12 +33,12 @@
33
33
  "node": ">=24.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@clickhouse/client": "^1.23.1",
37
- "@voltro/logger": "0.86.0",
38
- "@voltro/runtime": "0.86.0"
36
+ "@clickhouse/client": "^1.24.1",
37
+ "@voltro/logger": "0.88.0",
38
+ "@voltro/runtime": "0.88.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "effect": "4.0.1"
41
+ "effect": "4.1.0"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"