@effect/sql-clickhouse 4.0.0-beta.99 → 4.0.0-rc.108
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/AGENTS.md +381 -0
- package/CLAUDE.md +381 -0
- package/README.md +10 -3
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +5 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +165 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +116 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +136 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +24 -0
- package/dist/ClickhouseClient.d.ts +8 -8
- package/dist/ClickhouseClient.d.ts.map +1 -1
- package/dist/ClickhouseClient.js +22 -11
- package/dist/ClickhouseClient.js.map +1 -1
- package/dist/ClickhouseMigrator.d.ts +1 -1
- package/dist/ClickhouseMigrator.js +1 -1
- package/dist/ClickhouseMigrator.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- package/src/ClickhouseClient.ts +35 -26
- package/src/ClickhouseMigrator.ts +1 -1
package/src/ClickhouseClient.ts
CHANGED
|
@@ -104,7 +104,7 @@ export type TypeId = "~@effect/sql-clickhouse/ClickhouseClient"
|
|
|
104
104
|
* typed parameter fragments, command-mode execution, insert queries, and
|
|
105
105
|
* per-effect query ID and ClickHouse settings.
|
|
106
106
|
*
|
|
107
|
-
* @category
|
|
107
|
+
* @category services
|
|
108
108
|
* @since 4.0.0
|
|
109
109
|
*/
|
|
110
110
|
export interface ClickhouseClient extends Client.SqlClient {
|
|
@@ -149,7 +149,7 @@ export const ClickhouseClient = Context.Service<ClickhouseClient>("@effect/sql-c
|
|
|
149
149
|
* `@clickhouse/client` options with optional span attributes and query/result
|
|
150
150
|
* name transforms.
|
|
151
151
|
*
|
|
152
|
-
* @category
|
|
152
|
+
* @category models
|
|
153
153
|
* @since 4.0.0
|
|
154
154
|
*/
|
|
155
155
|
export interface ClickhouseClientConfig extends Clickhouse.ClickHouseClientConfigOptions {
|
|
@@ -175,16 +175,16 @@ export const make = (
|
|
|
175
175
|
? Statement.defaultTransforms(options.transformResultNames).array
|
|
176
176
|
: undefined
|
|
177
177
|
|
|
178
|
-
const client =
|
|
178
|
+
const client = yield* Effect.acquireRelease(
|
|
179
|
+
Effect.sync(() => Clickhouse.createClient(options)),
|
|
180
|
+
(client) => Effect.promise(() => client.close())
|
|
181
|
+
)
|
|
179
182
|
|
|
180
|
-
yield* Effect.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}),
|
|
186
|
-
() => Effect.promise(() => client.close())
|
|
187
|
-
).pipe(
|
|
183
|
+
yield* Effect.tryPromise({
|
|
184
|
+
try: () => client.exec({ query: "SELECT 1" }),
|
|
185
|
+
catch: (cause) =>
|
|
186
|
+
new SqlError({ reason: classifyError(cause, "ClickhouseClient: Failed to connect", "connect", "connection") })
|
|
187
|
+
}).pipe(
|
|
188
188
|
Effect.timeoutOrElse({
|
|
189
189
|
duration: Duration.seconds(5),
|
|
190
190
|
orElse: () =>
|
|
@@ -253,7 +253,12 @@ export const make = (
|
|
|
253
253
|
}
|
|
254
254
|
return Effect.suspend(() => {
|
|
255
255
|
controller.abort()
|
|
256
|
-
return Effect.promise(() =>
|
|
256
|
+
return Effect.promise(() =>
|
|
257
|
+
this.conn.command({
|
|
258
|
+
query: "KILL QUERY WHERE query_id = {queryId:String}",
|
|
259
|
+
query_params: { queryId }
|
|
260
|
+
})
|
|
261
|
+
)
|
|
257
262
|
})
|
|
258
263
|
})
|
|
259
264
|
})
|
|
@@ -263,12 +268,11 @@ export const make = (
|
|
|
263
268
|
return this.runRaw(sql, params, format).pipe(
|
|
264
269
|
Effect.flatMap((result) => {
|
|
265
270
|
if ("json" in result) {
|
|
266
|
-
return Effect.
|
|
267
|
-
result.json().then(
|
|
268
|
-
|
|
269
|
-
()
|
|
270
|
-
|
|
271
|
-
)
|
|
271
|
+
return Effect.tryPromise({
|
|
272
|
+
try: () => result.json().then((result) => "data" in result ? result.data : result as any),
|
|
273
|
+
catch: (cause) =>
|
|
274
|
+
new SqlError({ reason: classifyError(cause, "Failed to parse result", "parseResult") })
|
|
275
|
+
})
|
|
272
276
|
}
|
|
273
277
|
return Effect.succeed([])
|
|
274
278
|
})
|
|
@@ -376,7 +380,12 @@ export const make = (
|
|
|
376
380
|
)
|
|
377
381
|
return Effect.suspend(() => {
|
|
378
382
|
controller.abort()
|
|
379
|
-
return Effect.promise(() =>
|
|
383
|
+
return Effect.promise(() =>
|
|
384
|
+
client.command({
|
|
385
|
+
query: "KILL QUERY WHERE query_id = {queryId:String}",
|
|
386
|
+
query_params: { queryId }
|
|
387
|
+
})
|
|
388
|
+
)
|
|
380
389
|
})
|
|
381
390
|
})
|
|
382
391
|
},
|
|
@@ -399,7 +408,7 @@ export const make = (
|
|
|
399
408
|
* Fiber reference read by the low-level ClickHouse connection to choose query
|
|
400
409
|
* or command execution for statements; defaults to `query`.
|
|
401
410
|
*
|
|
402
|
-
* @category
|
|
411
|
+
* @category services
|
|
403
412
|
* @since 4.0.0
|
|
404
413
|
*/
|
|
405
414
|
export const ClientMethod = Context.Reference<"query" | "command" | "insert">(
|
|
@@ -413,7 +422,7 @@ export const ClientMethod = Context.Reference<"query" | "command" | "insert">(
|
|
|
413
422
|
* Fiber reference for the ClickHouse `query_id` applied to queries and
|
|
414
423
|
* inserts; a random UUID is generated when no query ID is set.
|
|
415
424
|
*
|
|
416
|
-
* @category
|
|
425
|
+
* @category services
|
|
417
426
|
* @since 4.0.0
|
|
418
427
|
*/
|
|
419
428
|
export const QueryId = Context.Reference<string | undefined>(
|
|
@@ -425,7 +434,7 @@ export const QueryId = Context.Reference<string | undefined>(
|
|
|
425
434
|
* Fiber reference containing ClickHouse settings to attach to queries,
|
|
426
435
|
* commands, and inserts.
|
|
427
436
|
*
|
|
428
|
-
* @category
|
|
437
|
+
* @category services
|
|
429
438
|
* @since 4.0.0
|
|
430
439
|
*/
|
|
431
440
|
export const ClickhouseSettings: Context.Reference<
|
|
@@ -484,7 +493,7 @@ const typeFromUnknown = (value: unknown): string => {
|
|
|
484
493
|
}
|
|
485
494
|
switch (typeof value) {
|
|
486
495
|
case "number":
|
|
487
|
-
return "
|
|
496
|
+
return "Float64"
|
|
488
497
|
case "bigint":
|
|
489
498
|
return "Int64"
|
|
490
499
|
case "boolean":
|
|
@@ -504,7 +513,7 @@ const typeFromUnknown = (value: unknown): string => {
|
|
|
504
513
|
* `{pN: Type}` placeholders and escaping identifiers with an optional query
|
|
505
514
|
* name transform.
|
|
506
515
|
*
|
|
507
|
-
* @category
|
|
516
|
+
* @category constructors
|
|
508
517
|
* @since 4.0.0
|
|
509
518
|
*/
|
|
510
519
|
export const makeCompiler = (transform?: (_: string) => string) =>
|
|
@@ -534,13 +543,13 @@ const escape = Statement.defaultEscape("\"")
|
|
|
534
543
|
* Custom SQL fragment type used for ClickHouse typed parameters created by
|
|
535
544
|
* `ClickhouseClient.param`.
|
|
536
545
|
*
|
|
537
|
-
* @category
|
|
546
|
+
* @category models
|
|
538
547
|
* @since 4.0.0
|
|
539
548
|
*/
|
|
540
549
|
export type ClickhouseCustom = ClickhouseParam
|
|
541
550
|
|
|
542
551
|
/**
|
|
543
|
-
* @category
|
|
552
|
+
* @category models
|
|
544
553
|
* @since 4.0.0
|
|
545
554
|
*/
|
|
546
555
|
interface ClickhouseParam extends Statement.Custom<"ClickhouseParam", string, unknown> {}
|
|
@@ -24,7 +24,7 @@ export * from "effect/unstable/sql/Migrator"
|
|
|
24
24
|
* Runs SQL migrations for ClickHouse using the supplied migrator options and
|
|
25
25
|
* returns the applied migration IDs and names.
|
|
26
26
|
*
|
|
27
|
-
* @category
|
|
27
|
+
* @category running
|
|
28
28
|
* @since 4.0.0
|
|
29
29
|
*/
|
|
30
30
|
export const run: <R2 = never>(
|