@effect/sql-clickhouse 4.0.0-rc.112 → 4.0.0-rc.114
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 +24 -9
- package/CLAUDE.md +24 -9
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +18 -5
- package/ai-docs/src/01_effect/01_basics/index.md +5 -3
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +2 -2
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +2 -2
- package/ai-docs/src/03_stream/30_encoding.ts +5 -7
- package/ai-docs/src/08_observability/10_logging.ts +1 -1
- package/ai-docs/src/70_cli/10_basics.ts +7 -7
- package/ai-docs/src/71_ai/10_language-model.ts +2 -2
- package/ai-docs/src/71_ai/20_tools.ts +1 -1
- package/ai-docs/src/71_ai/30_chat.ts +1 -1
- package/package.json +5 -5
package/AGENTS.md
CHANGED
|
@@ -11,9 +11,11 @@ purposes. In practice, you would not include these comments in your code.
|
|
|
11
11
|
|
|
12
12
|
## Writing `Effect` code
|
|
13
13
|
|
|
14
|
-
Prefer
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Prefer `Effect.gen` for inline Effect code. For reusable functions, prefer
|
|
15
|
+
`Effect.fn("name")` when tracing is useful and `Effect.fnUntraced` when it is not,
|
|
16
|
+
particularly in library implementations and hot paths. Avoid functions that only
|
|
17
|
+
wrap and return `Effect.gen`. Attach additional behaviour with combinators; this
|
|
18
|
+
style is more readable and easier to maintain than using combinators alone.
|
|
17
19
|
|
|
18
20
|
### Using Effect.gen
|
|
19
21
|
|
|
@@ -46,13 +48,16 @@ export class FileProcessingError extends Schema.TaggedError<FileProcessingError>
|
|
|
46
48
|
}) {}
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
### Using Effect.fn
|
|
51
|
+
### Using Effect.fn and Effect.fnUntraced
|
|
50
52
|
|
|
51
|
-
When writing functions that return an Effect, use `Effect.fn`
|
|
52
|
-
generator syntax.
|
|
53
|
+
When writing reusable functions that return an Effect, use `Effect.fn` or
|
|
54
|
+
`Effect.fnUntraced` to use the generator syntax.
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
Use `Effect.fn("name")` when the function should create a tracing span. Prefer
|
|
57
|
+
`Effect.fnUntraced` when tracing is not needed, particularly for library
|
|
58
|
+
implementations and hot paths.
|
|
59
|
+
|
|
60
|
+
**Avoid creating functions that only wrap and return an `Effect.gen`**.
|
|
56
61
|
|
|
57
62
|
```ts
|
|
58
63
|
import { Effect, Schema } from "effect"
|
|
@@ -80,6 +85,16 @@ export const effectFunction = Effect.fn("effectFunction")(
|
|
|
80
85
|
})
|
|
81
86
|
)
|
|
82
87
|
|
|
88
|
+
// Effect.fnUntraced avoids tracing and stack-frame capture while still reusing
|
|
89
|
+
// the generator body. This is preferred for library functions that do not
|
|
90
|
+
// represent a useful tracing boundary.
|
|
91
|
+
export const validateBatchSize = Effect.fnUntraced(function*(size: number): Effect.fn.Return<number, SomeError> {
|
|
92
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
93
|
+
return yield* new SomeError({ message: "Batch size must be a positive integer" })
|
|
94
|
+
}
|
|
95
|
+
return size
|
|
96
|
+
})
|
|
97
|
+
|
|
83
98
|
// Use Schema.TaggedError to define a custom error
|
|
84
99
|
export class SomeError extends Schema.TaggedError<SomeError>()("SomeError", {
|
|
85
100
|
message: Schema.String
|
|
@@ -247,7 +262,7 @@ They let you model finite or infinite data sources.
|
|
|
247
262
|
- `NodeStream.fromReadable` for Node.js readable streams
|
|
248
263
|
- **[Consuming and transforming streams](./ai-docs/src/03_stream/20_consuming-streams.ts)**: How to transform and consume streams using operators like `map`, `flatMap`, `filter`, `mapEffect`, and various `run*` methods.
|
|
249
264
|
- **[Decoding and encoding streams](./ai-docs/src/03_stream/30_encoding.ts)**:
|
|
250
|
-
Use `Stream.pipeThroughChannel` with the `Ndjson`
|
|
265
|
+
Use `Stream.pipeThroughChannel` with the `Ndjson` and `SchemaBinary` modules to
|
|
251
266
|
decode and encode streams of structured data.
|
|
252
267
|
|
|
253
268
|
## Integrating Effect into existing applications
|
package/CLAUDE.md
CHANGED
|
@@ -11,9 +11,11 @@ purposes. In practice, you would not include these comments in your code.
|
|
|
11
11
|
|
|
12
12
|
## Writing `Effect` code
|
|
13
13
|
|
|
14
|
-
Prefer
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Prefer `Effect.gen` for inline Effect code. For reusable functions, prefer
|
|
15
|
+
`Effect.fn("name")` when tracing is useful and `Effect.fnUntraced` when it is not,
|
|
16
|
+
particularly in library implementations and hot paths. Avoid functions that only
|
|
17
|
+
wrap and return `Effect.gen`. Attach additional behaviour with combinators; this
|
|
18
|
+
style is more readable and easier to maintain than using combinators alone.
|
|
17
19
|
|
|
18
20
|
### Using Effect.gen
|
|
19
21
|
|
|
@@ -46,13 +48,16 @@ export class FileProcessingError extends Schema.TaggedError<FileProcessingError>
|
|
|
46
48
|
}) {}
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
### Using Effect.fn
|
|
51
|
+
### Using Effect.fn and Effect.fnUntraced
|
|
50
52
|
|
|
51
|
-
When writing functions that return an Effect, use `Effect.fn`
|
|
52
|
-
generator syntax.
|
|
53
|
+
When writing reusable functions that return an Effect, use `Effect.fn` or
|
|
54
|
+
`Effect.fnUntraced` to use the generator syntax.
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
Use `Effect.fn("name")` when the function should create a tracing span. Prefer
|
|
57
|
+
`Effect.fnUntraced` when tracing is not needed, particularly for library
|
|
58
|
+
implementations and hot paths.
|
|
59
|
+
|
|
60
|
+
**Avoid creating functions that only wrap and return an `Effect.gen`**.
|
|
56
61
|
|
|
57
62
|
```ts
|
|
58
63
|
import { Effect, Schema } from "effect"
|
|
@@ -80,6 +85,16 @@ export const effectFunction = Effect.fn("effectFunction")(
|
|
|
80
85
|
})
|
|
81
86
|
)
|
|
82
87
|
|
|
88
|
+
// Effect.fnUntraced avoids tracing and stack-frame capture while still reusing
|
|
89
|
+
// the generator body. This is preferred for library functions that do not
|
|
90
|
+
// represent a useful tracing boundary.
|
|
91
|
+
export const validateBatchSize = Effect.fnUntraced(function*(size: number): Effect.fn.Return<number, SomeError> {
|
|
92
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
93
|
+
return yield* new SomeError({ message: "Batch size must be a positive integer" })
|
|
94
|
+
}
|
|
95
|
+
return size
|
|
96
|
+
})
|
|
97
|
+
|
|
83
98
|
// Use Schema.TaggedError to define a custom error
|
|
84
99
|
export class SomeError extends Schema.TaggedError<SomeError>()("SomeError", {
|
|
85
100
|
message: Schema.String
|
|
@@ -247,7 +262,7 @@ They let you model finite or infinite data sources.
|
|
|
247
262
|
- `NodeStream.fromReadable` for Node.js readable streams
|
|
248
263
|
- **[Consuming and transforming streams](./ai-docs/src/03_stream/20_consuming-streams.ts)**: How to transform and consume streams using operators like `map`, `flatMap`, `filter`, `mapEffect`, and various `run*` methods.
|
|
249
264
|
- **[Decoding and encoding streams](./ai-docs/src/03_stream/30_encoding.ts)**:
|
|
250
|
-
Use `Stream.pipeThroughChannel` with the `Ndjson`
|
|
265
|
+
Use `Stream.pipeThroughChannel` with the `Ndjson` and `SchemaBinary` modules to
|
|
251
266
|
decode and encode streams of structured data.
|
|
252
267
|
|
|
253
268
|
## Integrating Effect into existing applications
|
package/ai-docs/package.json
CHANGED
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@effect/sql-sqlite-wasm": "workspace:*",
|
|
28
28
|
"@effect/vitest": "workspace:*",
|
|
29
29
|
"effect": "workspace:*",
|
|
30
|
-
"hono": "^4.13.
|
|
31
|
-
"nodemailer": "^
|
|
30
|
+
"hono": "^4.13.7",
|
|
31
|
+
"nodemailer": "^10.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/nodemailer": "^8.0.1"
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @title Using Effect.fn
|
|
2
|
+
* @title Using Effect.fn and Effect.fnUntraced
|
|
3
3
|
*
|
|
4
|
-
* When writing functions that return an Effect, use `Effect.fn`
|
|
5
|
-
* generator syntax.
|
|
4
|
+
* When writing reusable functions that return an Effect, use `Effect.fn` or
|
|
5
|
+
* `Effect.fnUntraced` to use the generator syntax.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Use `Effect.fn("name")` when the function should create a tracing span. Prefer
|
|
8
|
+
* `Effect.fnUntraced` when tracing is not needed, particularly for library
|
|
9
|
+
* implementations and hot paths.
|
|
10
|
+
*
|
|
11
|
+
* **Avoid creating functions that only wrap and return an `Effect.gen`**.
|
|
9
12
|
*/
|
|
10
13
|
|
|
11
14
|
import { Effect, Schema } from "effect"
|
|
@@ -33,6 +36,16 @@ export const effectFunction = Effect.fn("effectFunction")(
|
|
|
33
36
|
})
|
|
34
37
|
)
|
|
35
38
|
|
|
39
|
+
// Effect.fnUntraced avoids tracing and stack-frame capture while still reusing
|
|
40
|
+
// the generator body. This is preferred for library functions that do not
|
|
41
|
+
// represent a useful tracing boundary.
|
|
42
|
+
export const validateBatchSize = Effect.fnUntraced(function*(size: number): Effect.fn.Return<number, SomeError> {
|
|
43
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
44
|
+
return yield* new SomeError({ message: "Batch size must be a positive integer" })
|
|
45
|
+
}
|
|
46
|
+
return size
|
|
47
|
+
})
|
|
48
|
+
|
|
36
49
|
// Use Schema.TaggedError to define a custom error
|
|
37
50
|
export class SomeError extends Schema.TaggedError<SomeError>()("SomeError", {
|
|
38
51
|
message: Schema.String
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
## Writing `Effect` code
|
|
2
2
|
|
|
3
|
-
Prefer
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Prefer `Effect.gen` for inline Effect code. For reusable functions, prefer
|
|
4
|
+
`Effect.fn("name")` when tracing is useful and `Effect.fnUntraced` when it is not,
|
|
5
|
+
particularly in library implementations and hot paths. Avoid functions that only
|
|
6
|
+
wrap and return `Effect.gen`. Attach additional behaviour with combinators; this
|
|
7
|
+
style is more readable and easier to maintain than using combinators alone.
|
|
@@ -14,7 +14,7 @@ export const SqlClientLayer: Layer.Layer<
|
|
|
14
14
|
PgClient.PgClient | SqlClient.SqlClient,
|
|
15
15
|
Config.ConfigError | SqlError.SqlError
|
|
16
16
|
> = PgClient.layerConfig({
|
|
17
|
-
url: Config.
|
|
17
|
+
url: Config.Redacted("DATABASE_URL")
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
export class UserRespositoryError extends Schema.TaggedError<UserRespositoryError>()("UserRespositoryError", {
|
|
@@ -51,7 +51,7 @@ export class MessageStore extends Context.Service<MessageStore, {
|
|
|
51
51
|
static readonly layer = Layer.unwrap(
|
|
52
52
|
Effect.gen(function*() {
|
|
53
53
|
// Read config inside an Effect, then choose which concrete layer to use.
|
|
54
|
-
const useInMemory = yield* Config.
|
|
54
|
+
const useInMemory = yield* Config.Boolean("MESSAGE_STORE_IN_MEMORY").pipe(
|
|
55
55
|
Config.withDefault(false)
|
|
56
56
|
)
|
|
57
57
|
|
|
@@ -59,7 +59,7 @@ export class MessageStore extends Context.Service<MessageStore, {
|
|
|
59
59
|
return MessageStore.layerInMemory
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const remoteUrl = yield* Config.
|
|
62
|
+
const remoteUrl = yield* Config.URL("MESSAGE_STORE_URL")
|
|
63
63
|
return MessageStore.layerRemote(remoteUrl)
|
|
64
64
|
})
|
|
65
65
|
)
|
|
@@ -22,8 +22,8 @@ export class Smtp extends Context.Service<Smtp, {
|
|
|
22
22
|
static readonly layer = Layer.effect(
|
|
23
23
|
Smtp,
|
|
24
24
|
Effect.gen(function*() {
|
|
25
|
-
const user = yield* Config.
|
|
26
|
-
const pass = yield* Config.
|
|
25
|
+
const user = yield* Config.String("SMTP_USER")
|
|
26
|
+
const pass = yield* Config.Redacted("SMTP_PASS")
|
|
27
27
|
|
|
28
28
|
// Use `Effect.acquireRelease` to manage the lifecycle of the SMTP
|
|
29
29
|
// transporter.
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @title Decoding and encoding streams
|
|
3
3
|
*
|
|
4
|
-
* Use `Stream.pipeThroughChannel` with the `Ndjson`
|
|
4
|
+
* Use `Stream.pipeThroughChannel` with the `Ndjson` and `SchemaBinary` modules to
|
|
5
5
|
* decode and encode streams of structured data.
|
|
6
6
|
*/
|
|
7
7
|
import { DateTime, Schema, Stream } from "effect"
|
|
8
|
-
import {
|
|
8
|
+
import { Ndjson, SchemaBinary } from "effect/unstable/encoding"
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
// `Msgpack.encode()`, etc.).
|
|
13
|
-
export const msgpackDecoder = Msgpack.decodeSchema(Schema.Struct({
|
|
10
|
+
// SchemaBinary derives a framed binary decoder directly from a schema.
|
|
11
|
+
export const schemaBinaryDecoder = SchemaBinary.decode(Schema.Struct({
|
|
14
12
|
id: Schema.Int,
|
|
15
13
|
name: Schema.String
|
|
16
|
-
}))
|
|
14
|
+
}))()
|
|
17
15
|
|
|
18
16
|
// ---------------------------------------------------------------------------
|
|
19
17
|
// Domain
|
|
@@ -41,7 +41,7 @@ export const AppLoggerLayer = Logger.layer([appLogger]).pipe(
|
|
|
41
41
|
// Create a logger layer that uses the default logger for development, and the
|
|
42
42
|
// custom logger for production
|
|
43
43
|
export const LoggerLayer = Layer.unwrap(Effect.gen(function*() {
|
|
44
|
-
const env = yield* Config.
|
|
44
|
+
const env = yield* Config.String("NODE_ENV").pipe(Config.withDefault("development"))
|
|
45
45
|
if (env === "production") {
|
|
46
46
|
return AppLoggerLayer
|
|
47
47
|
}
|
|
@@ -10,7 +10,7 @@ import { Argument, Command, Flag } from "effect/unstable/cli"
|
|
|
10
10
|
|
|
11
11
|
// You can define flags outside of commands and reuse them across multiple
|
|
12
12
|
// commands.
|
|
13
|
-
const workspace = Flag.
|
|
13
|
+
const workspace = Flag.String("workspace").pipe(
|
|
14
14
|
Flag.withAlias("w"),
|
|
15
15
|
Flag.withDescription("Workspace to operate on"),
|
|
16
16
|
Flag.withDefault("personal")
|
|
@@ -21,7 +21,7 @@ const workspace = Flag.string("workspace").pipe(
|
|
|
21
21
|
const tasks = Command.make("tasks").pipe(
|
|
22
22
|
Command.withSharedFlags({
|
|
23
23
|
workspace,
|
|
24
|
-
verbose: Flag.
|
|
24
|
+
verbose: Flag.Boolean("verbose").pipe(
|
|
25
25
|
Flag.withAlias("v"),
|
|
26
26
|
Flag.withDescription("Print diagnostic output"),
|
|
27
27
|
Flag.withDefault(false)
|
|
@@ -41,17 +41,17 @@ const Email = Schema.String.pipe(
|
|
|
41
41
|
const create = Command.make(
|
|
42
42
|
"create",
|
|
43
43
|
{
|
|
44
|
-
title: Argument.
|
|
44
|
+
title: Argument.String("title").pipe(
|
|
45
45
|
Argument.withDescription("Task title"),
|
|
46
46
|
// Reject empty titles at parse time, so the handler only ever sees
|
|
47
47
|
// valid input
|
|
48
48
|
Argument.withSchema(Schema.NonEmptyString)
|
|
49
49
|
),
|
|
50
|
-
priority: Flag.
|
|
50
|
+
priority: Flag.Literals("priority", ["low", "normal", "high"]).pipe(
|
|
51
51
|
Flag.withDescription("Priority for the new task"),
|
|
52
52
|
Flag.withDefault("normal")
|
|
53
53
|
),
|
|
54
|
-
assignee: Flag.
|
|
54
|
+
assignee: Flag.String("assignee").pipe(
|
|
55
55
|
Flag.withDescription("Email address of the person to assign"),
|
|
56
56
|
Flag.withSchema(Email),
|
|
57
57
|
Flag.optional
|
|
@@ -88,11 +88,11 @@ const create = Command.make(
|
|
|
88
88
|
const list = Command.make(
|
|
89
89
|
"list",
|
|
90
90
|
{
|
|
91
|
-
status: Flag.
|
|
91
|
+
status: Flag.Literals("status", ["open", "done", "all"]).pipe(
|
|
92
92
|
Flag.withDescription("Filter tasks by status"),
|
|
93
93
|
Flag.withDefault("open")
|
|
94
94
|
),
|
|
95
|
-
json: Flag.
|
|
95
|
+
json: Flag.Boolean("json").pipe(
|
|
96
96
|
Flag.withDescription("Print machine-readable output"),
|
|
97
97
|
Flag.withDefault(false)
|
|
98
98
|
)
|
|
@@ -13,7 +13,7 @@ import { LaunchPlan } from "./fixtures/domain/LaunchPlan.ts"
|
|
|
13
13
|
|
|
14
14
|
// You can use Config to create ai clients
|
|
15
15
|
const AnthropicClientLayer = AnthropicClient.layerConfig({
|
|
16
|
-
apiKey: Config.
|
|
16
|
+
apiKey: Config.Redacted("ANTHROPIC_API_KEY")
|
|
17
17
|
}).pipe(
|
|
18
18
|
// Providers typically require an HttpClient, but you can choose which one to
|
|
19
19
|
// use.
|
|
@@ -21,7 +21,7 @@ const AnthropicClientLayer = AnthropicClient.layerConfig({
|
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
const OpenAiClientLayer = OpenAiClient.layerConfig({
|
|
24
|
-
apiKey: Config.
|
|
24
|
+
apiKey: Config.Redacted("OPENAI_API_KEY")
|
|
25
25
|
}).pipe(
|
|
26
26
|
Layer.provide(FetchHttpClient.layer)
|
|
27
27
|
)
|
|
@@ -101,7 +101,7 @@ const ProductToolkitLayer = ProductToolkit.toLayer(Effect.gen(function*() {
|
|
|
101
101
|
|
|
102
102
|
// Provider setup (same pattern as the language-model example).
|
|
103
103
|
const OpenAiClientLayer = OpenAiClient.layerConfig({
|
|
104
|
-
apiKey: Config.
|
|
104
|
+
apiKey: Config.Redacted("OPENAI_API_KEY")
|
|
105
105
|
}).pipe(Layer.provide(FetchHttpClient.layer))
|
|
106
106
|
|
|
107
107
|
export class ProductAssistantError extends Schema.TaggedError<ProductAssistantError>()(
|
|
@@ -14,7 +14,7 @@ import { FetchHttpClient } from "effect/unstable/http"
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
const OpenAiClientLayer = OpenAiClient.layerConfig({
|
|
17
|
-
apiKey: Config.
|
|
17
|
+
apiKey: Config.Redacted("OPENAI_API_KEY")
|
|
18
18
|
}).pipe(Layer.provide(FetchHttpClient.layer))
|
|
19
19
|
|
|
20
20
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-clickhouse",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.114",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Clickhouse toolkit for Effect",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"provenance": true
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@effect/platform-node": "^4.0.0-rc.
|
|
51
|
-
"effect": "^4.0.0-rc.
|
|
50
|
+
"@effect/platform-node": "^4.0.0-rc.114",
|
|
51
|
+
"effect": "^4.0.0-rc.114"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@effect/platform-node": "^4.0.0-rc.
|
|
55
|
-
"effect": "^4.0.0-rc.
|
|
54
|
+
"@effect/platform-node": "^4.0.0-rc.114",
|
|
55
|
+
"effect": "^4.0.0-rc.114"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@clickhouse/client": "^1.23.1"
|