effect-cf 0.25.0 → 0.25.1
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 +7 -0
- package/dist/{Binding-DI7u3fEY.d.mts → Binding-COCtoJXa.d.mts} +4 -1
- package/dist/{DurableObjectState-B5RCFnRy.mjs → DurableObjectState-CEh0DVw7.mjs} +6 -2
- package/dist/{Hyperdrive-BwYp8Rsz.d.mts → Hyperdrive-6p59yyVk.d.mts} +1 -1
- package/dist/HyperdrivePg.d.mts +2 -2
- package/dist/Vitest.d.mts +2 -2
- package/dist/Vitest.mjs +1 -1
- package/dist/{WorkflowBinding--eMVaixT.d.mts → WorkflowBinding-Bzs5kmoE.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
- package/src/Environment.ts +16 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# effect-cf
|
|
2
2
|
|
|
3
|
+
## 0.25.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#88](https://github.com/danieljvdm/effect-cf/pull/88) [`18941d4`](https://github.com/danieljvdm/effect-cf/commit/18941d418c296c39a36d909516eb22a74778c8e7) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Upgrade to Effect 4 beta.107 and use its explicit environment-record config provider for
|
|
8
|
+
Cloudflare variables.
|
|
9
|
+
|
|
3
10
|
## 0.25.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -59,13 +59,16 @@ declare namespace WorkerConfig {
|
|
|
59
59
|
* Keep empty-string env values as explicit `""` config values.
|
|
60
60
|
*
|
|
61
61
|
* By default (absent or `false`), empty strings are treated as missing
|
|
62
|
-
* config, matching `ConfigProvider.
|
|
62
|
+
* config, matching `ConfigProvider.fromEnvRecord`.
|
|
63
63
|
*/
|
|
64
64
|
readonly preserveEmptyStrings?: boolean;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Build a `ConfigProvider` from a Cloudflare worker `env` object.
|
|
68
68
|
*
|
|
69
|
+
* Scalar vars and secrets use Effect's environment-record semantics;
|
|
70
|
+
* Cloudflare binding objects are ignored.
|
|
71
|
+
*
|
|
69
72
|
* Empty-string values are treated as missing config by default; pass
|
|
70
73
|
* `{ preserveEmptyStrings: true }` to keep them as explicit values.
|
|
71
74
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { Cause, Config, ConfigProvider, Context, Data, Effect, Exit, Option, Result, Schema } from "effect";
|
|
2
|
+
import { Cause, Config, ConfigProvider, Context, Data, Effect, Exit, Option, Predicate, Result, Schema } from "effect";
|
|
3
3
|
//#region src/Environment.ts
|
|
4
4
|
var Environment_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
WorkerConfig: () => WorkerConfig,
|
|
@@ -16,7 +16,11 @@ let WorkerConfig;
|
|
|
16
16
|
_WorkerConfig.number = (name) => Config.number(name);
|
|
17
17
|
_WorkerConfig.integer = (name) => Config.int(name);
|
|
18
18
|
_WorkerConfig.boolean = (name) => Config.boolean(name);
|
|
19
|
-
const providerFromEnv = _WorkerConfig.providerFromEnv = (env, options) =>
|
|
19
|
+
const providerFromEnv = _WorkerConfig.providerFromEnv = (env, options) => {
|
|
20
|
+
const record = {};
|
|
21
|
+
for (const [key, value] of Object.entries(env)) if (Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) record[key] = String(value);
|
|
22
|
+
return ConfigProvider.fromEnvRecord(record, options);
|
|
23
|
+
};
|
|
20
24
|
const providerWith = _WorkerConfig.providerWith = (makeProvider) => Effect.map(WorkerEnvironment, makeProvider);
|
|
21
25
|
const provider = _WorkerConfig.provider = providerWith(providerFromEnv);
|
|
22
26
|
_WorkerConfig.providerLayer = ConfigProvider.layer(provider);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-
|
|
1
|
+
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-COCtoJXa.mjs";
|
|
2
2
|
import { Context, Effect, Layer } from "effect";
|
|
3
3
|
declare namespace Hyperdrive_d_exports {
|
|
4
4
|
export { HyperdriveClient, HyperdriveDefinition, HyperdriveService, LayerOptions, Tag, TagClass, isHyperdrive, layer, make, makeClient };
|
package/dist/HyperdrivePg.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-
|
|
2
|
-
import { n as LayerOptions, r as TagClass } from "./Hyperdrive-
|
|
1
|
+
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-COCtoJXa.mjs";
|
|
2
|
+
import { n as LayerOptions, r as TagClass } from "./Hyperdrive-6p59yyVk.mjs";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
4
|
import { PgClient } from "@effect/sql-pg";
|
|
5
5
|
import { SqlClient, SqlError } from "effect/unstable/sql";
|
package/dist/Vitest.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as WorkerEnvironment, s as WorkerEnv } from "./Binding-
|
|
2
|
-
import { c as DurableObjectState, l as DurableObjectStateService, o as WorkflowInstanceStatusName } from "./WorkflowBinding
|
|
1
|
+
import { c as WorkerEnvironment, s as WorkerEnv } from "./Binding-COCtoJXa.mjs";
|
|
2
|
+
import { c as DurableObjectState, l as DurableObjectStateService, o as WorkflowInstanceStatusName } from "./WorkflowBinding-Bzs5kmoE.mjs";
|
|
3
3
|
import { Effect, Layer } from "effect";
|
|
4
4
|
import { DurableObject } from "cloudflare:workers";
|
|
5
5
|
import { adminSecretsStore as adminSecretsStore$1, getQueueResult, introspectWorkflow as introspectWorkflow$1, introspectWorkflowInstance as introspectWorkflowInstance$1 } from "cloudflare:test";
|
package/dist/Vitest.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as WorkerConfig, f as WorkerEnvironment, r as fromDurableObjectState, t as DurableObjectState } from "./DurableObjectState-
|
|
1
|
+
import { d as WorkerConfig, f as WorkerEnvironment, r as fromDurableObjectState, t as DurableObjectState } from "./DurableObjectState-CEh0DVw7.mjs";
|
|
2
2
|
import { ConfigProvider, Effect, Exit, Layer } from "effect";
|
|
3
3
|
import { env } from "cloudflare:workers";
|
|
4
4
|
import { abortAllDurableObjects as abortAllDurableObjects$1, adminSecretsStore as adminSecretsStore$1, applyD1Migrations as applyD1Migrations$1, createExecutionContext, createMessageBatch, createPagesEventContext, createScheduledController, evictAllDurableObjects as evictAllDurableObjects$1, evictDurableObject as evictDurableObject$1, getQueueResult, introspectWorkflow as introspectWorkflow$1, introspectWorkflowInstance as introspectWorkflowInstance$1, listDurableObjectIds as listDurableObjectIds$1, reset as reset$1, runDurableObjectAlarm as runDurableObjectAlarm$1, runInDurableObject as runInDurableObject$1, waitOnExecutionContext } from "cloudflare:test";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as WorkerEnvironment, n as BindingService, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-
|
|
1
|
+
import { c as WorkerEnvironment, n as BindingService, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-COCtoJXa.mjs";
|
|
2
2
|
import { Cause, Context, Effect, Layer, Option, Schema, Scope } from "effect";
|
|
3
3
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
4
4
|
import { RpcStub, RpcTarget, WorkerEntrypoint } from "cloudflare:workers";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as Environment_d_exports, c as WorkerEnvironment, i as Binding_d_exports, n as BindingService, o as WorkerConfig, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-
|
|
2
|
-
import { t as Hyperdrive_d_exports } from "./Hyperdrive-
|
|
3
|
-
import { A as Rpc_d_exports, C as QueueBinding_d_exports, D as RpcDefinition_d_exports, E as ReservedMethodName$2, M as DurableWebSocket, N as DurableObjectStorage_d_exports, O as ServiceFreeSchema$1, P as StorageOperationError, S as QueueDefinition_d_exports, T as Method$2, _ as AsyncMethodArgs, a as WorkflowInstanceCreateOptions, b as AsyncMethodSuccess, c as DurableObjectState, d as ExecutionContext, f as NativeRequest, g as ServiceBinding_d_exports, h as WorkerDefinition_d_exports, i as WorkflowInstanceCreateBatchOptions, j as DurableObjectWebSocket_d_exports, k as Provider, m as Worker_d_exports, n as WorkflowBinding_d_exports, p as WorkerContext, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient, u as DurableObjectState_d_exports, v as AsyncMethodCloudflareReturn, w as Definition$4, x as Queue_d_exports, y as AsyncMethodKey } from "./WorkflowBinding
|
|
1
|
+
import { a as Environment_d_exports, c as WorkerEnvironment, i as Binding_d_exports, n as BindingService, o as WorkerConfig, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-COCtoJXa.mjs";
|
|
2
|
+
import { t as Hyperdrive_d_exports } from "./Hyperdrive-6p59yyVk.mjs";
|
|
3
|
+
import { A as Rpc_d_exports, C as QueueBinding_d_exports, D as RpcDefinition_d_exports, E as ReservedMethodName$2, M as DurableWebSocket, N as DurableObjectStorage_d_exports, O as ServiceFreeSchema$1, P as StorageOperationError, S as QueueDefinition_d_exports, T as Method$2, _ as AsyncMethodArgs, a as WorkflowInstanceCreateOptions, b as AsyncMethodSuccess, c as DurableObjectState, d as ExecutionContext, f as NativeRequest, g as ServiceBinding_d_exports, h as WorkerDefinition_d_exports, i as WorkflowInstanceCreateBatchOptions, j as DurableObjectWebSocket_d_exports, k as Provider, m as Worker_d_exports, n as WorkflowBinding_d_exports, p as WorkerContext, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient, u as DurableObjectState_d_exports, v as AsyncMethodCloudflareReturn, w as Definition$4, x as Queue_d_exports, y as AsyncMethodKey } from "./WorkflowBinding-Bzs5kmoE.mjs";
|
|
4
4
|
import { Config, Context, Data, DateTime, Duration, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
|
|
5
5
|
import { Headers as Headers$1, HttpClient, HttpClientResponse } from "effect/unstable/http";
|
|
6
6
|
import { OtlpExporter } from "effect/unstable/observability";
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as DurableObjectWebSocket_exports, c as causeMessage, d as WorkerConfig, f as WorkerEnvironment, i as fromExecutionContext, l as violationsMessage, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState, u as Environment_exports } from "./DurableObjectState-
|
|
2
|
+
import { a as DurableObjectWebSocket_exports, c as causeMessage, d as WorkerConfig, f as WorkerEnvironment, i as fromExecutionContext, l as violationsMessage, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState, u as Environment_exports } from "./DurableObjectState-CEh0DVw7.mjs";
|
|
3
3
|
import { Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Function as Function$1, Layer, ManagedRuntime, Option, Predicate, Queue, Result, Schema } from "effect";
|
|
4
4
|
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
5
5
|
import { OtlpExporter, OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-cf",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"description": "Effect-native primitives for Cloudflare Workers and bindings.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@cloudflare/containers": "catalog:",
|
|
49
49
|
"@cloudflare/vitest-pool-workers": "catalog:",
|
|
50
50
|
"@cloudflare/workers-types": "catalog:",
|
|
51
|
-
"@effect/platform-node": "^4.0.0-beta.
|
|
51
|
+
"@effect/platform-node": "^4.0.0-beta.107 <4.0.0-rc.0",
|
|
52
52
|
"@effect/sql-d1": "catalog:",
|
|
53
53
|
"@effect/sql-pg": "catalog:",
|
|
54
54
|
"@effect/sql-sqlite-do": "catalog:",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@cloudflare/vitest-pool-workers": "^0.21.3",
|
|
62
62
|
"@cloudflare/workers-types": "^4.20260611.1",
|
|
63
|
-
"@effect/sql-d1": "^4.0.0-beta.
|
|
64
|
-
"@effect/sql-pg": "^4.0.0-beta.
|
|
65
|
-
"@effect/sql-sqlite-do": "^4.0.0-beta.
|
|
66
|
-
"effect": "^4.0.0-beta.
|
|
63
|
+
"@effect/sql-d1": "^4.0.0-beta.107 <4.0.0-rc.0",
|
|
64
|
+
"@effect/sql-pg": "^4.0.0-beta.107 <4.0.0-rc.0",
|
|
65
|
+
"@effect/sql-sqlite-do": "^4.0.0-beta.107 <4.0.0-rc.0",
|
|
66
|
+
"effect": "^4.0.0-beta.107 <4.0.0-rc.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@cloudflare/vitest-pool-workers": {
|
package/src/Environment.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, ConfigProvider, Context, Effect, type Layer } from "effect";
|
|
1
|
+
import { Config, ConfigProvider, Context, Effect, type Layer, Predicate } from "effect";
|
|
2
2
|
|
|
3
3
|
/** Cloudflare worker environment object (`env`). */
|
|
4
4
|
export type WorkerEnv = Cloudflare.Env;
|
|
@@ -78,7 +78,7 @@ export namespace WorkerConfig {
|
|
|
78
78
|
* Keep empty-string env values as explicit `""` config values.
|
|
79
79
|
*
|
|
80
80
|
* By default (absent or `false`), empty strings are treated as missing
|
|
81
|
-
* config, matching `ConfigProvider.
|
|
81
|
+
* config, matching `ConfigProvider.fromEnvRecord`.
|
|
82
82
|
*/
|
|
83
83
|
readonly preserveEmptyStrings?: boolean;
|
|
84
84
|
}
|
|
@@ -86,11 +86,23 @@ export namespace WorkerConfig {
|
|
|
86
86
|
/**
|
|
87
87
|
* Build a `ConfigProvider` from a Cloudflare worker `env` object.
|
|
88
88
|
*
|
|
89
|
+
* Scalar vars and secrets use Effect's environment-record semantics;
|
|
90
|
+
* Cloudflare binding objects are ignored.
|
|
91
|
+
*
|
|
89
92
|
* Empty-string values are treated as missing config by default; pass
|
|
90
93
|
* `{ preserveEmptyStrings: true }` to keep them as explicit values.
|
|
91
94
|
*/
|
|
92
|
-
export const providerFromEnv = (env: WorkerEnv, options?: ProviderOptions) =>
|
|
93
|
-
|
|
95
|
+
export const providerFromEnv = (env: WorkerEnv, options?: ProviderOptions) => {
|
|
96
|
+
const record: Record<string, string> = {};
|
|
97
|
+
|
|
98
|
+
for (const [key, value] of Object.entries(env)) {
|
|
99
|
+
if (Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) {
|
|
100
|
+
record[key] = String(value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return ConfigProvider.fromEnvRecord(record, options);
|
|
105
|
+
};
|
|
94
106
|
|
|
95
107
|
/**
|
|
96
108
|
* Build a `ConfigProvider` from the current `WorkerEnvironment` with a custom
|