@effect/sql-d1 4.0.0-rc.112 → 4.0.0-rc.113
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/dist/D1Client.d.ts.map +1 -1
- package/dist/D1Client.js +5 -4
- package/dist/D1Client.js.map +1 -1
- package/package.json +5 -5
- package/src/D1Client.ts +12 -6
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/dist/D1Client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1Client.d.ts","sourceRoot":"","sources":["../src/D1Client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"D1Client.d.ts","sourceRoot":"","sources":["../src/D1Client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,UAAU,EAAiC,MAAM,2BAA2B,CAAA;AAE1F,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAgB,MAAM,8BAA8B,CAAA;AACrE,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAS1D;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,MAAmC,CAAA;AAExD;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,0BAA0B,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,QAAS,SAAQ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K,GAAG,UAAU,CAAC,UAAU,CA4KjE,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,WACd,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAClC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAUrB,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,WACR,cAAc,KACrB,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAMrB,CAAA"}
|
package/dist/D1Client.js
CHANGED
|
@@ -104,21 +104,22 @@ export const make = options => Effect.gen(function* () {
|
|
|
104
104
|
})
|
|
105
105
|
})
|
|
106
106
|
});
|
|
107
|
-
const
|
|
107
|
+
const runStatementRaw = (statement, params = []) => Effect.tryPromise({
|
|
108
108
|
try: async () => {
|
|
109
109
|
const response = await statement.bind(...params).all();
|
|
110
110
|
if (response.error) {
|
|
111
111
|
throw response.error;
|
|
112
112
|
}
|
|
113
|
-
return response
|
|
113
|
+
return response;
|
|
114
114
|
},
|
|
115
115
|
catch: cause => new SqlError({
|
|
116
116
|
reason: classifyError(cause, "Failed to execute statement", "execute")
|
|
117
117
|
})
|
|
118
118
|
});
|
|
119
|
-
const
|
|
119
|
+
const runStatement = (statement, params = []) => Effect.map(runStatementRaw(statement, params), response => response.results || []);
|
|
120
|
+
const runRaw = (sql, params = []) => runStatementRaw(db.prepare(sql), params);
|
|
120
121
|
const runCached = (sql, params = []) => Effect.flatMap(Cache.get(prepareCache, sql), s => runStatement(s, params));
|
|
121
|
-
const runUncached = (sql, params = []) =>
|
|
122
|
+
const runUncached = (sql, params = []) => runStatement(db.prepare(sql), params);
|
|
122
123
|
const runValues = (sql, params) => Effect.flatMap(Cache.get(prepareCache, sql), statement => Effect.tryPromise({
|
|
123
124
|
try: () => {
|
|
124
125
|
return statement.bind(...params).raw();
|
package/dist/D1Client.js.map
C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AAM,CAAC,SAAS,EAAE,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAM,KAAK,GAChB,MAAsB,IAEtB,KAAK,CAAC,aAAa,CACjB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAG,MAAM,IAC9B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,CACjC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CACtC,CAAC,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-d1",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.113",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Cloudflare D1 integration for Effect",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"provenance": true
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"miniflare": "
|
|
55
|
-
"effect": "^4.0.0-rc.
|
|
54
|
+
"miniflare": "5.20260903.0-alpha",
|
|
55
|
+
"effect": "^4.0.0-rc.113"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"effect": "^4.0.0-rc.
|
|
58
|
+
"effect": "^4.0.0-rc.113"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cloudflare/workers-types": "^5.
|
|
61
|
+
"@cloudflare/workers-types": "^5.20260905.1"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"codegen": "effect-utils codegen",
|
package/src/D1Client.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @since 4.0.0
|
|
12
12
|
*/
|
|
13
|
-
import type { D1Database, D1PreparedStatement } from "@cloudflare/workers-types"
|
|
13
|
+
import type { D1Database, D1PreparedStatement, D1Result } from "@cloudflare/workers-types"
|
|
14
14
|
import * as Cache from "effect/Cache"
|
|
15
15
|
import * as Config from "effect/Config"
|
|
16
16
|
import * as Context from "effect/Context"
|
|
@@ -221,25 +221,31 @@ export const make = (
|
|
|
221
221
|
})
|
|
222
222
|
})
|
|
223
223
|
|
|
224
|
-
const
|
|
224
|
+
const runStatementRaw = (
|
|
225
225
|
statement: D1PreparedStatement,
|
|
226
226
|
params: ReadonlyArray<unknown> = []
|
|
227
|
-
): Effect.Effect<
|
|
227
|
+
): Effect.Effect<D1Result, SqlError, never> =>
|
|
228
228
|
Effect.tryPromise({
|
|
229
229
|
try: async () => {
|
|
230
230
|
const response = await statement.bind(...params).all()
|
|
231
231
|
if (response.error) {
|
|
232
232
|
throw response.error
|
|
233
233
|
}
|
|
234
|
-
return response
|
|
234
|
+
return response
|
|
235
235
|
},
|
|
236
236
|
catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
|
|
237
237
|
})
|
|
238
238
|
|
|
239
|
+
const runStatement = (
|
|
240
|
+
statement: D1PreparedStatement,
|
|
241
|
+
params: ReadonlyArray<unknown> = []
|
|
242
|
+
): Effect.Effect<ReadonlyArray<any>, SqlError, never> =>
|
|
243
|
+
Effect.map(runStatementRaw(statement, params), (response) => response.results || [])
|
|
244
|
+
|
|
239
245
|
const runRaw = (
|
|
240
246
|
sql: string,
|
|
241
247
|
params: ReadonlyArray<unknown> = []
|
|
242
|
-
) =>
|
|
248
|
+
) => runStatementRaw(db.prepare(sql), params)
|
|
243
249
|
|
|
244
250
|
const runCached = (
|
|
245
251
|
sql: string,
|
|
@@ -249,7 +255,7 @@ export const make = (
|
|
|
249
255
|
const runUncached = (
|
|
250
256
|
sql: string,
|
|
251
257
|
params: ReadonlyArray<unknown> = []
|
|
252
|
-
) =>
|
|
258
|
+
) => runStatement(db.prepare(sql), params)
|
|
253
259
|
|
|
254
260
|
const runValues = (
|
|
255
261
|
sql: string,
|