effect-cf 0.14.0 → 0.15.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/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
2
- import { a as WorkerConfig, i as layer$15, n as Binding_exports, o as WorkerEnvironment, r as Service$2, t as Hyperdrive_exports } from "./Hyperdrive-89hg_Fck.mjs";
2
+ import { a as WorkerConfig, i as layer$16, n as Binding_exports, o as WorkerEnvironment, r as Service$2, t as Hyperdrive_exports } from "./Hyperdrive-89hg_Fck.mjs";
3
3
  import { Cause, Clock, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Layer, ManagedRuntime, Option, Queue, Schema } from "effect";
4
4
  import { FetchHttpClient, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
5
5
  import { OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
@@ -11,13 +11,13 @@ import * as RpcServer from "effect/unstable/rpc/RpcServer";
11
11
  import { SqliteClient } from "@effect/sql-sqlite-do";
12
12
  //#region src/WorkersAi.ts
13
13
  var WorkersAi_exports = /* @__PURE__ */ __exportAll({
14
- Tag: () => Tag$14,
14
+ Tag: () => Tag$15,
15
15
  WorkersAiOperationError: () => WorkersAiOperationError,
16
16
  embeddingResponse: () => embeddingResponse,
17
17
  isWorkersAiBinding: () => isWorkersAiBinding,
18
- layer: () => layer$14,
19
- make: () => make$14,
20
- makeClient: () => makeClient$10
18
+ layer: () => layer$15,
19
+ make: () => make$15,
20
+ makeClient: () => makeClient$11
21
21
  });
22
22
  const expectedWorkersAiBinding = "Workers AI binding with run(), gateway(), and models()";
23
23
  /** Error raised when a Workers AI operation fails. */
@@ -41,7 +41,7 @@ const embeddingResponse = (value) => ({
41
41
  data: value.data ?? [],
42
42
  shape: value.shape ?? []
43
43
  });
44
- const makeClient$10 = (definition) => (ai) => {
44
+ const makeClient$11 = (definition) => (ai) => {
45
45
  const run = ((model, input, options) => tryWorkersAiPromise(definition.binding, "run", () => ai.run(model, input, options)));
46
46
  return {
47
47
  definition,
@@ -53,11 +53,11 @@ const makeClient$10 = (definition) => (ai) => {
53
53
  unsafeRaw: Effect.succeed(ai)
54
54
  };
55
55
  };
56
- const layer$14 = (tag, definition) => layer$15(tag, definition.binding, (value) => isWorkersAiBinding(value), makeClient$10(definition), { expected: expectedWorkersAiBinding });
57
- const make$14 = (id) => Tag$14()(id);
58
- const Tag$14 = () => (id) => {
56
+ const layer$15 = (tag, definition) => layer$16(tag, definition.binding, (value) => isWorkersAiBinding(value), makeClient$11(definition), { expected: expectedWorkersAiBinding });
57
+ const make$15 = (id) => Tag$15()(id);
58
+ const Tag$15 = () => (id) => {
59
59
  const tag = Context.Service()(id);
60
- const makeLayer = (definition) => layer$14(tag, definition);
60
+ const makeLayer = (definition) => layer$15(tag, definition);
61
61
  return Object.assign(tag, {
62
62
  id,
63
63
  layer: makeLayer
@@ -67,11 +67,11 @@ const Tag$14 = () => (id) => {
67
67
  //#region src/AiGateway.ts
68
68
  var AiGateway_exports = /* @__PURE__ */ __exportAll({
69
69
  AiGatewayOperationError: () => AiGatewayOperationError,
70
- Tag: () => Tag$13,
70
+ Tag: () => Tag$14,
71
71
  isAiGatewayBinding: () => isAiGatewayBinding,
72
- layer: () => layer$13,
73
- make: () => make$13,
74
- makeClient: () => makeClient$9,
72
+ layer: () => layer$14,
73
+ make: () => make$14,
74
+ makeClient: () => makeClient$10,
75
75
  makeClientFromAi: () => makeClientFromAi,
76
76
  makeHttpClient: () => makeHttpClient
77
77
  });
@@ -98,7 +98,7 @@ const providerUrl = (baseUrl, path = "") => {
98
98
  };
99
99
  const gatewayUrl = (definition) => `https://gateway.ai.cloudflare.com/v1/${definition.accountId}/${definition.gatewayId}/`;
100
100
  const isAiGatewayBinding = (value) => isWorkersAiBinding(value);
101
- const makeClient$9 = (definition, gateway) => ({
101
+ const makeClient$10 = (definition, gateway) => ({
102
102
  definition,
103
103
  run: (data, options) => tryAiGatewayPromise(definition.binding, "run", () => gateway.run(Array.isArray(data) ? [...data] : data, options)),
104
104
  getUrl: (provider) => tryAiGatewayPromise(definition.binding, "getUrl", () => gateway.getUrl(provider)),
@@ -115,11 +115,11 @@ const makeClientFromAi = (definition, ai) => {
115
115
  const withGateway = (operation) => gateway.pipe(Effect.flatMap(operation));
116
116
  return {
117
117
  definition,
118
- run: (data, options) => withGateway((raw) => makeClient$9(definition, raw).run(data, options)),
119
- getUrl: (provider) => withGateway((raw) => makeClient$9(definition, raw).getUrl(provider)),
120
- fetch: (options) => withGateway((raw) => makeClient$9(definition, raw).fetch(options)),
121
- patchLog: (logId, data) => withGateway((raw) => makeClient$9(definition, raw).patchLog(logId, data)),
122
- getLog: (logId) => withGateway((raw) => makeClient$9(definition, raw).getLog(logId)),
118
+ run: (data, options) => withGateway((raw) => makeClient$10(definition, raw).run(data, options)),
119
+ getUrl: (provider) => withGateway((raw) => makeClient$10(definition, raw).getUrl(provider)),
120
+ fetch: (options) => withGateway((raw) => makeClient$10(definition, raw).fetch(options)),
121
+ patchLog: (logId, data) => withGateway((raw) => makeClient$10(definition, raw).patchLog(logId, data)),
122
+ getLog: (logId) => withGateway((raw) => makeClient$10(definition, raw).getLog(logId)),
123
123
  unsafeRaw: gateway
124
124
  };
125
125
  };
@@ -159,11 +159,11 @@ const makeHttpClient = (definition, request = fetch) => {
159
159
  unsafeRaw: Effect.fail(aiGatewayError(binding, "unsafeRaw", /* @__PURE__ */ new TypeError("HTTP AI Gateway clients have no raw binding")))
160
160
  };
161
161
  };
162
- const layer$13 = (tag, definition) => layer$15(tag, definition.binding, isAiGatewayBinding, (ai) => makeClientFromAi(definition, ai), { expected: expectedAiGatewayBinding });
163
- const make$13 = (id) => Tag$13()(id);
164
- const Tag$13 = () => (id) => {
162
+ const layer$14 = (tag, definition) => layer$16(tag, definition.binding, isAiGatewayBinding, (ai) => makeClientFromAi(definition, ai), { expected: expectedAiGatewayBinding });
163
+ const make$14 = (id) => Tag$14()(id);
164
+ const Tag$14 = () => (id) => {
165
165
  const tag = Context.Service()(id);
166
- const makeLayer = (definition) => layer$13(tag, definition);
166
+ const makeLayer = (definition) => layer$14(tag, definition);
167
167
  return Object.assign(tag, {
168
168
  id,
169
169
  layer: makeLayer
@@ -173,11 +173,11 @@ const Tag$13 = () => (id) => {
173
173
  //#region src/BrowserRendering.ts
174
174
  var BrowserRendering_exports = /* @__PURE__ */ __exportAll({
175
175
  BrowserRenderingOperationError: () => BrowserRenderingOperationError,
176
- Tag: () => Tag$12,
176
+ Tag: () => Tag$13,
177
177
  isBrowserRenderingBinding: () => isBrowserRenderingBinding,
178
- layer: () => layer$12,
179
- make: () => make$12,
180
- makeClient: () => makeClient$8
178
+ layer: () => layer$13,
179
+ make: () => make$13,
180
+ makeClient: () => makeClient$9
181
181
  });
182
182
  const expectedBrowserRenderingBinding = "Browser Rendering binding resource";
183
183
  /** Error raised when a Browser Rendering operation fails. */
@@ -214,17 +214,17 @@ const wrapBrowser = (binding, browser) => ({
214
214
  disconnect: browser.disconnect === void 0 ? Effect.void : tryBrowserRenderingSync(binding, "disconnect", () => browser.disconnect())
215
215
  });
216
216
  const isBrowserRenderingBinding = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
217
- const makeClient$8 = (definition) => (binding) => ({
217
+ const makeClient$9 = (definition) => (binding) => ({
218
218
  definition,
219
219
  launchWith: (launch, options) => tryBrowserRenderingPromise(definition.binding, "launch", () => launch(binding, options)).pipe(Effect.map((browser) => wrapBrowser(definition.binding, browser))),
220
220
  connectWith: (connect, options) => tryBrowserRenderingPromise(definition.binding, "connect", () => connect(binding, options)).pipe(Effect.map((browser) => wrapBrowser(definition.binding, browser))),
221
221
  unsafeRaw: Effect.succeed(binding)
222
222
  });
223
- const layer$12 = (tag, definition) => layer$15(tag, definition.binding, isBrowserRenderingBinding, makeClient$8(definition), { expected: expectedBrowserRenderingBinding });
224
- const make$12 = (id) => Tag$12()(id);
225
- const Tag$12 = () => (id) => {
223
+ const layer$13 = (tag, definition) => layer$16(tag, definition.binding, isBrowserRenderingBinding, makeClient$9(definition), { expected: expectedBrowserRenderingBinding });
224
+ const make$13 = (id) => Tag$13()(id);
225
+ const Tag$13 = () => (id) => {
226
226
  const tag = Context.Service()(id);
227
- const makeLayer = (definition) => layer$12(tag, definition);
227
+ const makeLayer = (definition) => layer$13(tag, definition);
228
228
  return Object.assign(tag, {
229
229
  id,
230
230
  layer: makeLayer
@@ -523,7 +523,7 @@ const runPromiseExitPreservingTypedFailures = async (effect) => {
523
523
  //#region src/CloudflareOtlp.ts
524
524
  var CloudflareOtlp_exports = /* @__PURE__ */ __exportAll({
525
525
  durableObjectLayer: () => durableObjectLayer,
526
- layer: () => layer$11,
526
+ layer: () => layer$12,
527
527
  layerJson: () => layerJson,
528
528
  layerProtobuf: () => layerProtobuf,
529
529
  workerLayer: () => workerLayer
@@ -585,14 +585,14 @@ const makeLayer = (options = {}, runtimeAttributes = {}) => {
585
585
  * installed as the primary `ConfigProvider`; outside Cloudflare, the ambient
586
586
  * Effect `ConfigProvider` remains the fallback.
587
587
  */
588
- const layer$11 = (options = {}) => makeLayer(options);
588
+ const layer$12 = (options = {}) => makeLayer(options);
589
589
  /** Base OTLP telemetry layer forced to JSON serialization. */
590
- const layerJson = (options = {}) => layer$11({
590
+ const layerJson = (options = {}) => layer$12({
591
591
  ...options,
592
592
  serialization: "json"
593
593
  });
594
594
  /** Base OTLP telemetry layer forced to protobuf serialization. */
595
- const layerProtobuf = (options = {}) => layer$11({
595
+ const layerProtobuf = (options = {}) => layer$12({
596
596
  ...options,
597
597
  serialization: "protobuf"
598
598
  });
@@ -622,7 +622,7 @@ const durableObjectLayer = (options = {}) => Layer.unwrap(Effect.map(DurableObje
622
622
  //#region src/D1.ts
623
623
  var D1_exports = /* @__PURE__ */ __exportAll({
624
624
  Service: () => Service$1,
625
- make: () => make$11
625
+ make: () => make$12
626
626
  });
627
627
  const TypeId$2 = "effect-cf/D1";
628
628
  const expectedD1Database = "D1 database binding with prepare(), batch(), and exec()";
@@ -634,7 +634,7 @@ const isD1Database = (value) => {
634
634
  /**
635
635
  * Creates a typed D1 service tag plus Effect helpers.
636
636
  */
637
- const make$11 = (id, definition) => Service$1()(id, definition);
637
+ const make$12 = (id, definition) => Service$1()(id, definition);
638
638
  /**
639
639
  * Builds a D1 service around a Cloudflare D1 database binding.
640
640
  *
@@ -670,8 +670,8 @@ const Service$1 = () => (id, definition) => {
670
670
  var QueueBinding_exports = /* @__PURE__ */ __exportAll({
671
671
  QueueOperationError: () => QueueOperationError,
672
672
  isQueue: () => isQueue,
673
- layer: () => layer$10,
674
- makeClient: () => makeClient$7
673
+ layer: () => layer$11,
674
+ makeClient: () => makeClient$8
675
675
  });
676
676
  const expectedQueueProducer = "Queue producer binding with send(); optional sendBatch()/metrics()";
677
677
  var QueueOperationError = class extends Data.TaggedError("QueueOperationError") {};
@@ -688,7 +688,7 @@ const isQueue = (value) => {
688
688
  if (typeof value !== "object" || value === null) return false;
689
689
  return typeof value.send === "function";
690
690
  };
691
- const makeClient$7 = (definition) => {
691
+ const makeClient$8 = (definition) => {
692
692
  const encodeMessage = Schema.encodeEffect(definition.message);
693
693
  return (queue) => ({
694
694
  send: Effect.fnUntraced(function* (message, options) {
@@ -726,30 +726,30 @@ const makeClient$7 = (definition) => {
726
726
  unsafeRaw: Effect.succeed(queue)
727
727
  });
728
728
  };
729
- const layer$10 = (tag, definition) => layer$15(tag, definition.binding, (value) => isQueue(value), makeClient$7(definition), { expected: expectedQueueProducer });
729
+ const layer$11 = (tag, definition) => layer$16(tag, definition.binding, (value) => isQueue(value), makeClient$8(definition), { expected: expectedQueueProducer });
730
730
  //#endregion
731
731
  //#region src/QueueDefinition.ts
732
732
  var QueueDefinition_exports = /* @__PURE__ */ __exportAll({
733
733
  Queue: () => Queue$1,
734
- Tag: () => Tag$11,
734
+ Tag: () => Tag$12,
735
735
  implement: () => implement$7,
736
- make: () => make$10
736
+ make: () => make$11
737
737
  });
738
738
  const makeDefinition$4 = (id, definition) => {
739
739
  const queueDefinition = {
740
740
  id,
741
741
  message: definition.message
742
742
  };
743
- return Object.assign(queueDefinition, { make: (layer, options) => make$7(layer, {
743
+ return Object.assign(queueDefinition, { make: (layer, options) => make$8(layer, {
744
744
  ...options,
745
745
  queue: wrapHandler$1(queueDefinition, options.queue)
746
746
  }) });
747
747
  };
748
- const make$10 = (id, definition) => Tag$11()(id, definition);
749
- const Tag$11 = () => (id, definition) => {
748
+ const make$11 = (id, definition) => Tag$12()(id, definition);
749
+ const Tag$12 = () => (id, definition) => {
750
750
  const queueDefinition = makeDefinition$4(id, definition);
751
751
  const tag = Context.Service()(id);
752
- const layer = (binding) => layer$10(tag, {
752
+ const layer = (binding) => layer$11(tag, {
753
753
  ...binding,
754
754
  message: definition.message
755
755
  });
@@ -776,7 +776,7 @@ const Tag$11 = () => (id, definition) => {
776
776
  unsafeRaw
777
777
  });
778
778
  };
779
- const Queue$1 = Tag$11;
779
+ const Queue$1 = Tag$12;
780
780
  const wrapHandler$1 = (definition, handler) => {
781
781
  const decodeBody = Schema.decodeUnknownEffect(definition.message);
782
782
  return (batch) => Effect.gen(function* () {
@@ -788,7 +788,7 @@ const implement$7 = (_definition, handler) => handler;
788
788
  //#region src/Queue.ts
789
789
  var Queue_exports = /* @__PURE__ */ __exportAll({
790
790
  QueueMessageDecodeError: () => QueueMessageDecodeError,
791
- Tag: () => Tag$10,
791
+ Tag: () => Tag$11,
792
792
  decodeBatch: () => decodeBatch,
793
793
  fromMessage: () => fromMessage,
794
794
  fromMessageBatch: () => fromMessageBatch,
@@ -826,7 +826,7 @@ const decodeBatch = (batch, decodeBody) => Effect.gen(function* () {
826
826
  }
827
827
  return fromMessageBatch(batch, messages);
828
828
  });
829
- const Tag$10 = Tag$11;
829
+ const Tag$11 = Tag$12;
830
830
  const implement$6 = implement$7;
831
831
  //#endregion
832
832
  //#region src/RpcDefinition.ts
@@ -844,7 +844,7 @@ var RpcDefinition_exports = /* @__PURE__ */ __exportAll({
844
844
  decodeSuccess: () => decodeSuccess,
845
845
  encodeArgs: () => encodeArgs,
846
846
  encodeSuccess: () => encodeSuccess,
847
- make: () => make$9,
847
+ make: () => make$10,
848
848
  method: () => method$4,
849
849
  reservedMethodNames: () => reservedMethodNames$4
850
850
  });
@@ -947,7 +947,7 @@ const decodeSuccess = (definition, methodName, value) => {
947
947
  cause
948
948
  })));
949
949
  };
950
- const make$9 = (id, methods) => {
950
+ const make$10 = (id, methods) => {
951
951
  const definition = {
952
952
  id,
953
953
  methods
@@ -1005,8 +1005,8 @@ var ServiceBinding_exports = /* @__PURE__ */ __exportAll({
1005
1005
  ServiceBindingFetchError: () => ServiceBindingFetchError,
1006
1006
  ServiceBindingRpcError: () => ServiceBindingRpcError,
1007
1007
  isServiceBindingClient: () => isServiceBindingClient,
1008
- layer: () => layer$9,
1009
- makeClient: () => makeClient$6,
1008
+ layer: () => layer$10,
1009
+ makeClient: () => makeClient$7,
1010
1010
  makeDirectMethods: () => makeDirectMethods$1
1011
1011
  });
1012
1012
  const TypeId$1 = "effect-cf/ServiceBinding";
@@ -1020,7 +1020,7 @@ var ServiceBindingFetchError = class extends Data.TaggedError("ServiceBindingFet
1020
1020
  */
1021
1021
  var ServiceBindingRpcError = class extends Data.TaggedError("ServiceBindingRpcError") {};
1022
1022
  const isServiceBindingClient = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "fetch") === "function";
1023
- const makeClient$6 = (definition) => {
1023
+ const makeClient$7 = (definition) => {
1024
1024
  return (service) => {
1025
1025
  const fetch = (input, init) => Effect.tryPromise({
1026
1026
  try: () => service.fetch(input, init),
@@ -1069,7 +1069,7 @@ const makeClient$6 = (definition) => {
1069
1069
  });
1070
1070
  };
1071
1071
  };
1072
- const layer$9 = (tag, definition) => layer$15(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$6(definition), { expected: expectedServiceBinding });
1072
+ const layer$10 = (tag, definition) => layer$16(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$7(definition), { expected: expectedServiceBinding });
1073
1073
  /**
1074
1074
  * Creates a typed Effect service for a Worker service binding.
1075
1075
  *
@@ -1100,7 +1100,7 @@ const layer$9 = (tag, definition) => layer$15(tag, definition.binding, (value) =
1100
1100
  * ```
1101
1101
  */
1102
1102
  const Service = () => (id, definition) => {
1103
- const tag = Service$2()(id, definition.binding, (value) => isServiceBindingClient(value), makeClient$6(definition));
1103
+ const tag = Service$2()(id, definition.binding, (value) => isServiceBindingClient(value), makeClient$7(definition));
1104
1104
  const fetch = (input, init) => Effect.gen(function* () {
1105
1105
  return yield* (yield* tag).fetch(input, init);
1106
1106
  });
@@ -1131,10 +1131,10 @@ const makeDirectMethods$1 = (rpcDefinition, call) => {
1131
1131
  //#endregion
1132
1132
  //#region src/WorkerDefinition.ts
1133
1133
  var WorkerDefinition_exports = /* @__PURE__ */ __exportAll({
1134
- Tag: () => Tag$9,
1134
+ Tag: () => Tag$10,
1135
1135
  Worker: () => Worker,
1136
1136
  implement: () => implement$5,
1137
- make: () => make$8,
1137
+ make: () => make$9,
1138
1138
  method: () => method$3
1139
1139
  });
1140
1140
  const reservedMethodNames$3 = new Set([
@@ -1172,21 +1172,21 @@ const method$3 = method$4;
1172
1172
  */
1173
1173
  const makeDefinition$3 = (id, methods) => {
1174
1174
  assertNoReservedMethods("Worker", methods, reservedMethodNames$3);
1175
- const definition = make$9(id, methods);
1176
- return Object.assign(definition, { make: (layer, options) => make$7(layer, {
1175
+ const definition = make$10(id, methods);
1176
+ return Object.assign(definition, { make: (layer, options) => make$8(layer, {
1177
1177
  ...options,
1178
1178
  rpc: wrapHandlers$1(definition, options.rpc)
1179
1179
  }) });
1180
1180
  };
1181
- const make$8 = (id, methods) => Tag$9()(id, methods);
1182
- const Tag$9 = () => (id, methods) => {
1181
+ const make$9 = (id, methods) => Tag$10()(id, methods);
1182
+ const Tag$10 = () => (id, methods) => {
1183
1183
  const definition = makeDefinition$3(id, methods);
1184
1184
  const tag = Context.Service()(id);
1185
1185
  const bindingDefinition = (binding) => ({
1186
1186
  ...binding,
1187
1187
  definition
1188
1188
  });
1189
- const layer = (binding) => layer$9(tag, bindingDefinition(binding));
1189
+ const layer = (binding) => layer$10(tag, bindingDefinition(binding));
1190
1190
  const fetch = (input, init) => Effect.gen(function* () {
1191
1191
  return yield* (yield* tag).fetch(input, init);
1192
1192
  });
@@ -1211,7 +1211,7 @@ const Tag$9 = () => (id, methods) => {
1211
1211
  scopedCall
1212
1212
  });
1213
1213
  };
1214
- const Worker = Tag$9;
1214
+ const Worker = Tag$10;
1215
1215
  const wrapHandlers$1 = (definition, handlers) => {
1216
1216
  const wrapped = {};
1217
1217
  for (const key of Object.keys(definition.methods)) {
@@ -1245,7 +1245,7 @@ const clock = {
1245
1245
  });
1246
1246
  }
1247
1247
  };
1248
- const layer$8 = Layer.effect(Clock.Clock, Effect.succeed(clock));
1248
+ const layer$9 = Layer.effect(Clock.Clock, Effect.succeed(clock));
1249
1249
  //#endregion
1250
1250
  //#region src/internal/Entrypoint.ts
1251
1251
  const provideEntrypointServices = (layer, services) => layer.pipe(Layer.provideMerge(services));
@@ -1287,11 +1287,11 @@ const fromExecutionContext = (ctx, runPromiseExit) => {
1287
1287
  var Worker_exports = /* @__PURE__ */ __exportAll({
1288
1288
  ExecutionContext: () => ExecutionContext,
1289
1289
  NativeRequest: () => NativeRequest,
1290
- Tag: () => Tag$8,
1290
+ Tag: () => Tag$9,
1291
1291
  WorkerContext: () => WorkerContext,
1292
1292
  implement: () => implement$4,
1293
1293
  isWebSocketUpgrade: () => isWebSocketUpgrade,
1294
- make: () => make$7,
1294
+ make: () => make$8,
1295
1295
  makeFetchHandler: () => makeFetchHandler,
1296
1296
  method: () => method$2,
1297
1297
  renderHttpResponse: () => renderHttpResponse
@@ -1320,14 +1320,14 @@ const RunSymbol$1 = Symbol.for("effect-cf/Worker/run");
1320
1320
  const renderHttpResponse = (effect) => Effect.flatMap(effect, (response) => Effect.map(Effect.context(), (context) => HttpServerResponse.toWeb(response, { context })));
1321
1321
  const renderFetchSuccess = (effect) => Effect.flatMap(effect, (response) => response instanceof Response ? Effect.succeed(response) : Effect.map(Effect.context(), (context) => HttpServerResponse.toWeb(response, { context })));
1322
1322
  const isWorkerOptions = (options) => typeof options === "object" && options !== null && ("eventLayer" in options || "fetch" in options || "queue" in options || "rpc" in options);
1323
- function make$7(layer, optionsOrFetch) {
1323
+ function make$8(layer, optionsOrFetch) {
1324
1324
  const options = isWorkerOptions(optionsOrFetch) ? optionsOrFetch : { fetch: optionsOrFetch };
1325
1325
  class EffectWorker extends WorkerEntrypoint {
1326
1326
  runtime;
1327
1327
  constructor(ctx, env) {
1328
1328
  super(ctx, env);
1329
1329
  let runWaitUntilEffect = () => Promise.reject(/* @__PURE__ */ new Error("WorkerContext runtime is not initialized"));
1330
- const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$8, Layer.succeed(ExecutionContext, ctx), ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(WorkerContext, fromExecutionContext(ctx, (effect) => runWaitUntilEffect(effect))), Layer.succeed(WorkerEnvironment, env)));
1330
+ const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$9, Layer.succeed(ExecutionContext, ctx), ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(WorkerContext, fromExecutionContext(ctx, (effect) => runWaitUntilEffect(effect))), Layer.succeed(WorkerEnvironment, env)));
1331
1331
  this.runtime = ManagedRuntime.make(runtimeLayer);
1332
1332
  runWaitUntilEffect = (effect) => this.runtime.runPromiseExit(effect);
1333
1333
  }
@@ -1352,10 +1352,10 @@ function make$7(layer, optionsOrFetch) {
1352
1352
  return assumeEntrypointClass(EffectWorker);
1353
1353
  }
1354
1354
  const makeFetchHandler = (layer, options) => {
1355
- const WorkerClass = make$7(layer, options);
1355
+ const WorkerClass = make$8(layer, options);
1356
1356
  return { fetch: (request, env, ctx) => Promise.resolve(new WorkerClass(ctx, env).fetch(request)) };
1357
1357
  };
1358
- const Tag$8 = Tag$9;
1358
+ const Tag$9 = Tag$10;
1359
1359
  const method$2 = method$3;
1360
1360
  const implement$4 = implement$5;
1361
1361
  //#endregion
@@ -1364,8 +1364,8 @@ var DurableObjectNamespace_exports = /* @__PURE__ */ __exportAll({
1364
1364
  DurableObjectFetchError: () => DurableObjectFetchError,
1365
1365
  DurableObjectRpcError: () => DurableObjectRpcError,
1366
1366
  isDurableObjectNamespaceClient: () => isDurableObjectNamespaceClient,
1367
- layer: () => layer$7,
1368
- makeClient: () => makeClient$5,
1367
+ layer: () => layer$8,
1368
+ makeClient: () => makeClient$6,
1369
1369
  makeDirectMethods: () => makeDirectMethods
1370
1370
  });
1371
1371
  const expectedDurableObjectNamespace = "Durable Object namespace binding with getByName(), get(), idFromName(), idFromString(), newUniqueId(), and jurisdiction()";
@@ -1379,7 +1379,7 @@ var DurableObjectRpcError = class extends Data.TaggedError("DurableObjectRpcErro
1379
1379
  var DurableObjectFetchError = class extends Data.TaggedError("DurableObjectFetchError") {};
1380
1380
  const hasFunction$2 = (value, key) => typeof Reflect.get(value, key) === "function";
1381
1381
  const isDurableObjectNamespaceClient = (value) => typeof value === "object" && value !== null && hasFunction$2(value, "getByName") && hasFunction$2(value, "get") && hasFunction$2(value, "idFromName") && hasFunction$2(value, "idFromString") && hasFunction$2(value, "newUniqueId") && hasFunction$2(value, "jurisdiction");
1382
- const makeClient$5 = (definition) => {
1382
+ const makeClient$6 = (definition) => {
1383
1383
  return (namespace) => {
1384
1384
  const newUniqueId = (options) => Effect.sync(() => namespace.newUniqueId(options));
1385
1385
  const idFromName = (name) => Effect.sync(() => namespace.idFromName(name));
@@ -1446,7 +1446,7 @@ const makeClient$5 = (definition) => {
1446
1446
  });
1447
1447
  };
1448
1448
  };
1449
- const layer$7 = (tag, definition) => layer$15(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$5(definition), { expected: expectedDurableObjectNamespace });
1449
+ const layer$8 = (tag, definition) => layer$16(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$6(definition), { expected: expectedDurableObjectNamespace });
1450
1450
  const makeDirectMethods = (rpcDefinition, helpers) => {
1451
1451
  const methods = {};
1452
1452
  if (rpcDefinition !== void 0) {
@@ -1471,9 +1471,9 @@ const makeDirectMethods = (rpcDefinition, helpers) => {
1471
1471
  //#region src/DurableObjectDefinition.ts
1472
1472
  var DurableObjectDefinition_exports = /* @__PURE__ */ __exportAll({
1473
1473
  DurableObject: () => DurableObject$1,
1474
- Tag: () => Tag$7,
1474
+ Tag: () => Tag$8,
1475
1475
  implement: () => implement$3,
1476
- make: () => make$6,
1476
+ make: () => make$7,
1477
1477
  method: () => method$1
1478
1478
  });
1479
1479
  const reservedMethodNames$1 = new Set([
@@ -1504,21 +1504,21 @@ const method$1 = method$4;
1504
1504
  */
1505
1505
  const makeDefinition$2 = (id, methods) => {
1506
1506
  assertNoReservedMethods("Durable Object", methods, reservedMethodNames$1);
1507
- const definition = make$9(id, methods);
1508
- return Object.assign(definition, { make: (layer, options) => make$5(layer, {
1507
+ const definition = make$10(id, methods);
1508
+ return Object.assign(definition, { make: (layer, options) => make$6(layer, {
1509
1509
  ...options,
1510
1510
  rpc: wrapHandlers(definition, options.rpc)
1511
1511
  }) });
1512
1512
  };
1513
- const make$6 = (id, methods) => Tag$7()(id, methods);
1514
- const Tag$7 = () => (id, methods) => {
1513
+ const make$7 = (id, methods) => Tag$8()(id, methods);
1514
+ const Tag$8 = () => (id, methods) => {
1515
1515
  const definition = makeDefinition$2(id, methods);
1516
1516
  const tag = Context.Service()(id);
1517
1517
  const bindingDefinition = (binding) => ({
1518
1518
  ...binding,
1519
1519
  definition
1520
1520
  });
1521
- const layer = (binding) => layer$7(tag, bindingDefinition(binding));
1521
+ const layer = (binding) => layer$8(tag, bindingDefinition(binding));
1522
1522
  const newUniqueId = Effect.fnUntraced(function* (options) {
1523
1523
  return yield* (yield* tag).newUniqueId(options);
1524
1524
  });
@@ -1576,7 +1576,7 @@ const Tag$7 = () => (id, methods) => {
1576
1576
  unsafeRaw
1577
1577
  });
1578
1578
  };
1579
- const DurableObject$1 = Tag$7;
1579
+ const DurableObject$1 = Tag$8;
1580
1580
  const wrapHandlers = (definition, handlers) => {
1581
1581
  const wrapped = {};
1582
1582
  for (const key of Object.keys(definition.methods)) {
@@ -1594,9 +1594,9 @@ const implement$3 = (_definition, handlers) => handlers;
1594
1594
  //#endregion
1595
1595
  //#region src/DurableObject.ts
1596
1596
  var DurableObject_exports = /* @__PURE__ */ __exportAll({
1597
- Tag: () => Tag$6,
1597
+ Tag: () => Tag$7,
1598
1598
  implement: () => implement$2,
1599
- make: () => make$5,
1599
+ make: () => make$6,
1600
1600
  method: () => method
1601
1601
  });
1602
1602
  const reservedMethodNames = new Set([
@@ -1612,12 +1612,12 @@ const RunSymbol = Symbol.for("effect-cf/DurableObject/run");
1612
1612
  /**
1613
1613
  * Creates a Durable Object class backed by a single managed Effect runtime.
1614
1614
  */
1615
- const make$5 = (layer, options = {}) => {
1615
+ const make$6 = (layer, options = {}) => {
1616
1616
  class EffectDurableObject extends DurableObject {
1617
1617
  runtime;
1618
1618
  constructor(state, env) {
1619
1619
  super(state, env);
1620
- const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$8, ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(DurableObjectState, fromDurableObjectState(state)), Layer.succeed(WorkerEnvironment, env)));
1620
+ const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$9, ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(DurableObjectState, fromDurableObjectState(state)), Layer.succeed(WorkerEnvironment, env)));
1621
1621
  this.runtime = ManagedRuntime.make(runtimeLayer);
1622
1622
  const initialize = options.initialize;
1623
1623
  if (initialize !== void 0) state.waitUntil(this[RunSymbol](initialize, { eventLayer: false }));
@@ -1654,7 +1654,7 @@ const make$5 = (layer, options = {}) => {
1654
1654
  defineEntrypointRpcMethods("Durable Object", EffectDurableObject.prototype, options.rpc, reservedMethodNames, (self, effect) => self[RunSymbol](effect));
1655
1655
  return assumeEntrypointClass(EffectDurableObject);
1656
1656
  };
1657
- const Tag$6 = Tag$7;
1657
+ const Tag$7 = Tag$8;
1658
1658
  const method = method$1;
1659
1659
  const implement$2 = implement$3;
1660
1660
  //#endregion
@@ -1983,7 +1983,7 @@ var DurableObjectAlarm = class DurableObjectAlarm extends Context.Service()("eff
1983
1983
  //#region src/DurableObjectRpcWebSocket.ts
1984
1984
  var DurableObjectRpcWebSocket_exports = /* @__PURE__ */ __exportAll({
1985
1985
  DurableObjectRpcWebSocket: () => DurableObjectRpcWebSocket,
1986
- layer: () => layer$6
1986
+ layer: () => layer$7
1987
1987
  });
1988
1988
  const defaultAttachmentKey = "effectCloudflareRpcClientId";
1989
1989
  const defaultTag = "effect-cf-rpc";
@@ -1994,7 +1994,7 @@ var DurableObjectRpcWebSocket = class extends Context.Service()("effect-cf/Durab
1994
1994
  /**
1995
1995
  * Builds a layer that bridges Durable Object websocket events to `RpcServer.Protocol`.
1996
1996
  */
1997
- const layer$6 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
1997
+ const layer$7 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
1998
1998
  const tag = options.tag ?? defaultTag;
1999
1999
  const attachmentKey = options.attachmentKey ?? defaultAttachmentKey;
2000
2000
  const durableObjectState = yield* DurableObjectState;
@@ -2107,7 +2107,7 @@ const writeAttachment = (socket, key, clientId) => {
2107
2107
  };
2108
2108
  //#endregion
2109
2109
  //#region src/DurableObjectSqlite.ts
2110
- var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$5 });
2110
+ var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$6 });
2111
2111
  /**
2112
2112
  * Provides `effect/unstable/sql` from the current Durable Object SQLite storage.
2113
2113
  *
@@ -2119,7 +2119,7 @@ var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => lay
2119
2119
  * );
2120
2120
  * ```
2121
2121
  */
2122
- const layer$5 = (options) => Layer.unwrap(Effect.gen(function* () {
2122
+ const layer$6 = (options) => Layer.unwrap(Effect.gen(function* () {
2123
2123
  const state = yield* DurableObjectState;
2124
2124
  return SqliteClient.layer({
2125
2125
  ...options,
@@ -2127,6 +2127,51 @@ const layer$5 = (options) => Layer.unwrap(Effect.gen(function* () {
2127
2127
  });
2128
2128
  }));
2129
2129
  //#endregion
2130
+ //#region src/Email.ts
2131
+ var Email_exports = /* @__PURE__ */ __exportAll({
2132
+ EmailOperationError: () => EmailOperationError,
2133
+ Tag: () => Tag$6,
2134
+ isEmailBinding: () => isEmailBinding,
2135
+ layer: () => layer$5,
2136
+ make: () => make$5,
2137
+ makeClient: () => makeClient$5
2138
+ });
2139
+ const expectedSendEmailBinding = "Send Email binding with send()";
2140
+ /** Error raised when a Cloudflare Send Email operation fails. */
2141
+ var EmailOperationError = class extends Data.TaggedError("EmailOperationError") {};
2142
+ const emailError = (binding, operation, cause) => new EmailOperationError({
2143
+ binding,
2144
+ operation,
2145
+ cause
2146
+ });
2147
+ const tryEmailPromise = (binding, operation, evaluate) => Effect.tryPromise({
2148
+ try: evaluate,
2149
+ catch: (cause) => emailError(binding, operation, cause)
2150
+ });
2151
+ const isEmailBinding = (value) => {
2152
+ if (typeof value !== "object" || value === null) return false;
2153
+ return typeof value.send === "function";
2154
+ };
2155
+ const makeClient$5 = (definition) => (email) => {
2156
+ const runtime = email;
2157
+ const send = ((message) => tryEmailPromise(definition.binding, "send", () => runtime.send(message)));
2158
+ return {
2159
+ definition,
2160
+ send,
2161
+ unsafeRaw: Effect.succeed(email)
2162
+ };
2163
+ };
2164
+ const layer$5 = (tag, definition) => layer$16(tag, definition.binding, isEmailBinding, makeClient$5(definition), { expected: expectedSendEmailBinding });
2165
+ const make$5 = (id) => Tag$6()(id);
2166
+ const Tag$6 = () => (id) => {
2167
+ const tag = Context.Service()(id);
2168
+ const makeLayer = (definition) => layer$5(tag, definition);
2169
+ return Object.assign(tag, {
2170
+ id,
2171
+ layer: makeLayer
2172
+ });
2173
+ };
2174
+ //#endregion
2130
2175
  //#region src/Images.ts
2131
2176
  var Images_exports = /* @__PURE__ */ __exportAll({
2132
2177
  ImagesOperationError: () => ImagesOperationError,
@@ -2223,7 +2268,7 @@ const makeClient$4 = (definition) => (images) => {
2223
2268
  unsafeRaw: Effect.succeed(images)
2224
2269
  };
2225
2270
  };
2226
- const layer$4 = (tag, definition) => layer$15(tag, definition.binding, isImagesBinding, makeClient$4(definition), { expected: expectedImagesBinding });
2271
+ const layer$4 = (tag, definition) => layer$16(tag, definition.binding, isImagesBinding, makeClient$4(definition), { expected: expectedImagesBinding });
2227
2272
  const make$4 = (id) => Tag$5()(id);
2228
2273
  const Tag$5 = () => (id) => {
2229
2274
  const tag = Context.Service()(id);
@@ -2318,7 +2363,7 @@ const makeClient$3 = (definition) => {
2318
2363
  unsafeRaw: Effect.succeed(kv)
2319
2364
  });
2320
2365
  };
2321
- const layer$3 = (tag, definition) => layer$15(tag, definition.binding, isKvNamespace, makeClient$3(definition), { expected: expectedKvNamespace });
2366
+ const layer$3 = (tag, definition) => layer$16(tag, definition.binding, isKvNamespace, makeClient$3(definition), { expected: expectedKvNamespace });
2322
2367
  const makeDefinition$1 = (id, definition) => {
2323
2368
  const kvDefinition = {
2324
2369
  id,
@@ -2435,7 +2480,7 @@ const makeClient$2 = (definition) => {
2435
2480
  };
2436
2481
  };
2437
2482
  };
2438
- const layer$2 = (tag, definition) => layer$15(tag, definition.binding, isR2Bucket, makeClient$2(definition), { expected: expectedR2Bucket });
2483
+ const layer$2 = (tag, definition) => layer$16(tag, definition.binding, isR2Bucket, makeClient$2(definition), { expected: expectedR2Bucket });
2439
2484
  const make$3 = (id) => Tag$3()(id);
2440
2485
  const Tag$3 = () => (id) => {
2441
2486
  const tag = Context.Service()(id);
@@ -2521,7 +2566,7 @@ const makeClient$1 = (definition) => {
2521
2566
  unsafeRaw: Effect.succeed(workflow)
2522
2567
  });
2523
2568
  };
2524
- const layer$1 = (tag, definition) => layer$15(tag, definition.binding, (value) => isWorkflow(value), makeClient$1(definition), { expected: expectedWorkflow });
2569
+ const layer$1 = (tag, definition) => layer$16(tag, definition.binding, (value) => isWorkflow(value), makeClient$1(definition), { expected: expectedWorkflow });
2525
2570
  //#endregion
2526
2571
  //#region src/WorkflowDefinition.ts
2527
2572
  var WorkflowDefinition_exports = /* @__PURE__ */ __exportAll({
@@ -2695,7 +2740,7 @@ const makeClient = (definition) => (index) => {
2695
2740
  unsafeRaw: Effect.succeed(index)
2696
2741
  };
2697
2742
  };
2698
- const layer = (tag, definition) => layer$15(tag, definition.binding, isVectorizeBinding, makeClient(definition), { expected: expectedVectorizeBinding });
2743
+ const layer = (tag, definition) => layer$16(tag, definition.binding, isVectorizeBinding, makeClient(definition), { expected: expectedVectorizeBinding });
2699
2744
  const make = (id) => Tag()(id);
2700
2745
  const Tag = () => (id) => {
2701
2746
  const tag = Context.Service()(id);
@@ -2706,4 +2751,4 @@ const Tag = () => (id) => {
2706
2751
  });
2707
2752
  };
2708
2753
  //#endregion
2709
- export { AiGateway_exports as AiGateway, Binding_exports as Binding, BrowserRendering_exports as BrowserRendering, CloudflareOtlp_exports as CloudflareOtlp, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_exports as DurableObjectSqlite, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, ServiceBinding_exports as ServiceBinding, Vectorize_exports as Vectorize, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, WorkersAi_exports as WorkersAi, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
2754
+ export { AiGateway_exports as AiGateway, Binding_exports as Binding, BrowserRendering_exports as BrowserRendering, CloudflareOtlp_exports as CloudflareOtlp, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_exports as DurableObjectSqlite, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Email_exports as Email, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, ServiceBinding_exports as ServiceBinding, Vectorize_exports as Vectorize, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, WorkersAi_exports as WorkersAi, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };