@voltro/plugin-clickhouse 0.89.2 → 0.91.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/CHANGELOG.md +1943 -0
- package/THIRD-PARTY-NOTICES.md +23 -647
- package/dist/index.js +2 -1
- package/dist/sink.js +19 -17
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -26,7 +26,8 @@ var c = 20, l = 5e3, u = (u) => {
|
|
|
26
26
|
url: u.url,
|
|
27
27
|
database: f.database,
|
|
28
28
|
...u.username === void 0 ? {} : { username: u.username },
|
|
29
|
-
...u.password === void 0 ? {} : { password: u.password }
|
|
29
|
+
...u.password === void 0 ? {} : { password: u.password },
|
|
30
|
+
clickhouse_settings: { date_time_input_format: "best_effort" }
|
|
30
31
|
}));
|
|
31
32
|
if (f.client = n, !(yield* s.tryPromise({
|
|
32
33
|
try: (e) => n.ping({
|
package/dist/sink.js
CHANGED
|
@@ -102,7 +102,7 @@ var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) =>
|
|
|
102
102
|
event: t,
|
|
103
103
|
from: n.from.toISOString(),
|
|
104
104
|
...n.to === void 0 ? {} : { to: n.to.toISOString() }
|
|
105
|
-
}, o = "name = {event:String} AND occurred_at >= {from:
|
|
105
|
+
}, o = "name = {event:String} AND occurred_at >= parseDateTime64BestEffort({from:String}, 3)" + (n.to === void 0 ? "" : " AND occurred_at < parseDateTime64BestEffort({to:String}, 3)");
|
|
106
106
|
if (i != null && (a.tenant = i, o += " AND tenant_id = {tenant:String}"), r !== void 0) {
|
|
107
107
|
let t = 0;
|
|
108
108
|
for (let [n, i] of Object.entries(r)) {
|
|
@@ -149,10 +149,11 @@ var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) =>
|
|
|
149
149
|
}).pipe(l("mirror.remove")),
|
|
150
150
|
maxVersion: ({ table: n, primaryKeyValue: r }) => e.gen(function* () {
|
|
151
151
|
d(String(n), "mirror table");
|
|
152
|
-
let i = yield* h(t), o = `SELECT max(version) AS v, count() AS n FROM ${t.database}.${a(String(n))} WHERE id = {id: String}
|
|
152
|
+
let i = yield* h(t), o = `SELECT max(version) AS v, count() AS n FROM ${t.database}.${a(String(n))} WHERE id = {id: String}`, s = yield* e.tryPromise({
|
|
153
153
|
try: () => i.query({
|
|
154
154
|
query: o,
|
|
155
|
-
query_params: { id: String(r) }
|
|
155
|
+
query_params: { id: String(r) },
|
|
156
|
+
format: "JSON"
|
|
156
157
|
}),
|
|
157
158
|
catch: (e) => e
|
|
158
159
|
}), { data: c } = yield* e.tryPromise({
|
|
@@ -193,10 +194,11 @@ var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) =>
|
|
|
193
194
|
});
|
|
194
195
|
}).pipe(l("track")),
|
|
195
196
|
aggregate: (n) => e.gen(function* () {
|
|
196
|
-
let r = yield* h(t), i = w("aggregate", n.event, n.range, n.filter, n.tenantId), a = `SELECT ${S("aggregate", n.metric)} AS value FROM ${t.database}.${t.table} WHERE ${i.sql}
|
|
197
|
+
let r = yield* h(t), i = w("aggregate", n.event, n.range, n.filter, n.tenantId), a = `SELECT ${S("aggregate", n.metric)} AS value FROM ${t.database}.${t.table} WHERE ${i.sql}`, o = yield* e.tryPromise({
|
|
197
198
|
try: () => r.query({
|
|
198
199
|
query: a,
|
|
199
|
-
query_params: i.params
|
|
200
|
+
query_params: i.params,
|
|
201
|
+
format: "JSON"
|
|
200
202
|
}),
|
|
201
203
|
catch: (e) => e
|
|
202
204
|
}), { data: s } = yield* e.tryPromise({
|
|
@@ -206,25 +208,25 @@ var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) =>
|
|
|
206
208
|
return typeof c == "number" ? c : Number(c ?? 0);
|
|
207
209
|
}).pipe(l("aggregate")),
|
|
208
210
|
timeseries: (n) => e.gen(function* () {
|
|
209
|
-
let r = yield* h(t), i = w("timeseries", n.event, n.range, n.filter, n.tenantId), a = `
|
|
210
|
-
SELECT ${
|
|
211
|
+
let r = yield* h(t), i = w("timeseries", n.event, n.range, n.filter, n.tenantId), a = `${y(n.bucket)}(occurred_at)`, o = `
|
|
212
|
+
SELECT ${a} AS bucket_start, toUnixTimestamp(${a}) AS bucket_epoch, ${S("timeseries", n.metric)} AS value
|
|
211
213
|
FROM ${t.database}.${t.table}
|
|
212
214
|
WHERE ${i.sql}
|
|
213
215
|
GROUP BY bucket_start
|
|
214
216
|
ORDER BY bucket_start ASC
|
|
215
|
-
|
|
216
|
-
`, o = yield* e.tryPromise({
|
|
217
|
+
`, s = yield* e.tryPromise({
|
|
217
218
|
try: () => r.query({
|
|
218
|
-
query:
|
|
219
|
-
query_params: i.params
|
|
219
|
+
query: o,
|
|
220
|
+
query_params: i.params,
|
|
221
|
+
format: "JSON"
|
|
220
222
|
}),
|
|
221
223
|
catch: (e) => e
|
|
222
|
-
}), { data:
|
|
223
|
-
try: () =>
|
|
224
|
+
}), { data: c } = yield* e.tryPromise({
|
|
225
|
+
try: () => s.json(),
|
|
224
226
|
catch: (e) => e
|
|
225
227
|
});
|
|
226
|
-
return
|
|
227
|
-
bucketStart: new Date(e.
|
|
228
|
+
return c.map((e) => ({
|
|
229
|
+
bucketStart: /* @__PURE__ */ new Date(Number(e.bucket_epoch) * 1e3),
|
|
228
230
|
value: typeof e.value == "number" ? e.value : Number(e.value ?? 0)
|
|
229
231
|
}));
|
|
230
232
|
}).pipe(l("timeseries")),
|
|
@@ -236,11 +238,11 @@ var r = t({ scope: "@voltro/plugin-clickhouse" }), i = "clickhouse", a = (e) =>
|
|
|
236
238
|
GROUP BY ${o}
|
|
237
239
|
ORDER BY value DESC
|
|
238
240
|
LIMIT ${a}
|
|
239
|
-
FORMAT JSON
|
|
240
241
|
`, c = yield* e.tryPromise({
|
|
241
242
|
try: () => r.query({
|
|
242
243
|
query: s,
|
|
243
|
-
query_params: i.params
|
|
244
|
+
query_params: i.params,
|
|
245
|
+
format: "JSON"
|
|
244
246
|
}),
|
|
245
247
|
catch: (e) => e
|
|
246
248
|
}), { data: l } = yield* e.tryPromise({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-clickhouse",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.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.
|
|
37
|
-
"@voltro/logger": "0.
|
|
38
|
-
"@voltro/runtime": "0.
|
|
36
|
+
"@clickhouse/client": "^1.25.0",
|
|
37
|
+
"@voltro/logger": "0.91.0",
|
|
38
|
+
"@voltro/runtime": "0.91.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"effect": "4.1.
|
|
41
|
+
"effect": "4.1.4"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|