effect-cf 0.10.0 → 0.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # effect-cf
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#35](https://github.com/danieljvdm/effect-cf/pull/35) [`fc02f42`](https://github.com/danieljvdm/effect-cf/commit/fc02f421565451c9925f45841f45012473057966) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Add a Durable Object SQLite layer for providing `effect/unstable/sql` through `@effect/sql-sqlite-do`.
8
+
3
9
  ## 0.10.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -5,6 +5,7 @@ import { DurableObject, RpcStub, RpcTarget, WorkerEntrypoint, WorkflowEntrypoint
5
5
  import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
6
6
  import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
7
7
  import * as RpcServer from "effect/unstable/rpc/RpcServer";
8
+ import { SqliteClient } from "@effect/sql-sqlite-do";
8
9
  import * as _$effect_unstable_sql_SqlClient0 from "effect/unstable/sql/SqlClient";
9
10
  import * as _$effect_Types0 from "effect/Types";
10
11
  import * as _$effect_Cause0 from "effect/Cause";
@@ -184,7 +185,7 @@ declare const encodeSuccess: <const Self extends Definition$9.Any, MethodName ex
184
185
  declare const decodeSuccess: <const Self extends Definition$9.Any, MethodName extends Definition$9.MethodNames<Self>>(definition: Self, methodName: MethodName, value: unknown) => Effect.Effect<Method$5.Success<Self["methods"][MethodName]>, RpcSuccessDecodeError>;
185
186
  declare const make$9: <Id extends string, const MethodsShape extends Methods$4>(id: Id, methods: MethodsShape) => Definition$9<Id, MethodsShape>;
186
187
  declare namespace QueueBinding_d_exports {
187
- export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$7 as layer, makeClient$6 as makeClient };
188
+ export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$8 as layer, makeClient$6 as makeClient };
188
189
  }
189
190
  type QueueSendOptions = globalThis.QueueSendOptions;
190
191
  type QueueSendResponse = globalThis.QueueSendResponse;
@@ -216,7 +217,7 @@ declare class QueueOperationError extends QueueOperationError_base<{
216
217
  }> {}
217
218
  declare const isQueue: <Body>(value: unknown) => value is QueueProducer<Body>;
218
219
  declare const makeClient$6: <Message extends ServiceFreeSchema$4>(definition: QueueBindingDefinition<Message>) => ((queue: QueueProducer<Schema.Codec.Encoded<Message>>) => QueueBindingClient<Message>);
219
- declare const layer$7: <Self, Message extends ServiceFreeSchema$4>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => _$effect_Layer0.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
220
+ declare const layer$8: <Self, Message extends ServiceFreeSchema$4>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => _$effect_Layer0.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
220
221
  declare namespace QueueDefinition_d_exports {
221
222
  export { Definition$8 as Definition, Handler$3 as Handler, LayerOptions$11 as LayerOptions, Options$7 as Options, Queue$1 as Queue, Tag$11 as Tag, TagClass$10 as TagClass, implement$7 as implement, make$8 as make };
222
223
  }
@@ -402,7 +403,7 @@ type AsyncMethodArgs<Api, Method extends keyof Api> = Api[Method] extends ((...a
402
403
  type AsyncMethodSuccess<Api, Method extends keyof Api> = Api[Method] extends ((...args: AnyArgs) => Promise<infer A>) ? A : never;
403
404
  type AsyncMethodCloudflareReturn<Api, Method extends keyof Api> = Result<AsyncMethodSuccess<Api, Method>>;
404
405
  declare namespace ServiceBinding_d_exports {
405
- export { Service, ServiceBindingClient, ServiceBindingDefinition, ServiceBindingEffectClient, ServiceBindingFetchError, ServiceBindingRpcError, ServiceBindingStaticClient, ServiceFetcher, isServiceBindingClient, layer$6 as layer, makeClient$5 as makeClient, makeDirectMethods$1 as makeDirectMethods };
406
+ export { Service, ServiceBindingClient, ServiceBindingDefinition, ServiceBindingEffectClient, ServiceBindingFetchError, ServiceBindingRpcError, ServiceBindingStaticClient, ServiceFetcher, isServiceBindingClient, layer$7 as layer, makeClient$5 as makeClient, makeDirectMethods$1 as makeDirectMethods };
406
407
  }
407
408
  declare const TypeId$1: "effect-cf/ServiceBinding";
408
409
  /**
@@ -549,7 +550,7 @@ type ServiceBindingStaticClient<R, Api extends object, Definition extends Defini
549
550
  };
550
551
  declare const isServiceBindingClient: <Api extends object>(value: unknown) => value is ServiceBindingClient<Api>;
551
552
  declare const makeClient$5: <Api extends object, const Definition extends Definition$6.Any | undefined = undefined>(definition: ServiceBindingDefinition<Definition>) => ((service: ServiceBindingClient<Api>) => ServiceBindingEffectClient<Api, Definition>);
552
- declare const layer$6: <Self, Api extends object, const Definition extends Definition$6.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition>>, definition: ServiceBindingDefinition<Definition>) => _$effect_Layer0.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
553
+ declare const layer$7: <Self, Api extends object, const Definition extends Definition$6.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition>>, definition: ServiceBindingDefinition<Definition>) => _$effect_Layer0.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
553
554
  /**
554
555
  * Creates a typed Effect service for a Worker service binding.
555
556
  *
@@ -986,7 +987,7 @@ declare class DurableObjectState extends DurableObjectState_base {}
986
987
  */
987
988
  declare const fromDurableObjectState: (state: globalThis.DurableObjectState) => DurableObjectStateService;
988
989
  declare namespace DurableObjectNamespace_d_exports {
989
- export { DurableObjectFetchError, DurableObjectNamespaceBindingDefinition, DurableObjectNamespaceClient, DurableObjectNamespaceDefinition, DurableObjectNamespaceEffectClient, DurableObjectNamespaceStaticClient, DurableObjectRpcError, DurableObjectStubClient, isDurableObjectNamespaceClient, layer$5 as layer, makeClient$4 as makeClient, makeDirectMethods };
990
+ export { DurableObjectFetchError, DurableObjectNamespaceBindingDefinition, DurableObjectNamespaceClient, DurableObjectNamespaceDefinition, DurableObjectNamespaceEffectClient, DurableObjectNamespaceStaticClient, DurableObjectRpcError, DurableObjectStubClient, isDurableObjectNamespaceClient, layer$6 as layer, makeClient$4 as makeClient, makeDirectMethods };
990
991
  }
991
992
  interface DurableObjectFetcher {
992
993
  fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
@@ -1185,7 +1186,7 @@ type DurableObjectNamespaceStaticClient<R, Api extends object, Definition extend
1185
1186
  };
1186
1187
  declare const isDurableObjectNamespaceClient: <Api extends object>(value: unknown) => value is DurableObjectNamespaceClient<Api>;
1187
1188
  declare const makeClient$4: <Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(definition: DurableObjectNamespaceBindingDefinition<Definition>) => ((namespace: DurableObjectNamespaceClient<Api>) => DurableObjectNamespaceEffectClient<Api, Definition>);
1188
- declare const layer$5: <Self, Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(tag: Context.Service<Self, DurableObjectNamespaceEffectClient<Api, Definition>>, definition: DurableObjectNamespaceBindingDefinition<Definition>) => _$effect_Layer0.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
1189
+ declare const layer$6: <Self, Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(tag: Context.Service<Self, DurableObjectNamespaceEffectClient<Api, Definition>>, definition: DurableObjectNamespaceBindingDefinition<Definition>) => _$effect_Layer0.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
1189
1190
  declare const makeDirectMethods: <R, Api extends object, Definition extends Definition$4.Any | undefined>(rpcDefinition: Definition | undefined, helpers: {
1190
1191
  readonly call: StubCall<R, Api>;
1191
1192
  readonly fetch: (stub: DurableObjectStubClient<Api>, input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, DurableObjectFetchError, R>;
@@ -1697,7 +1698,7 @@ declare class DurableObjectAlarm extends DurableObjectAlarm_base {
1697
1698
  static readonly layer: Layer.Layer<DurableObjectAlarm, never, DurableObjectState>;
1698
1699
  }
1699
1700
  declare namespace DurableObjectRpcWebSocket_d_exports {
1700
- export { DurableObjectRpcWebSocket, DurableObjectRpcWebSocketService, LayerOptions$5 as LayerOptions, NativeWebSocketMessage, layer$4 as layer };
1701
+ export { DurableObjectRpcWebSocket, DurableObjectRpcWebSocketService, LayerOptions$5 as LayerOptions, NativeWebSocketMessage, layer$5 as layer };
1701
1702
  }
1702
1703
  /**
1703
1704
  * Configuration for {@link layer}.
@@ -1727,7 +1728,24 @@ declare class DurableObjectRpcWebSocket extends DurableObjectRpcWebSocket_base {
1727
1728
  /**
1728
1729
  * Builds a layer that bridges Durable Object websocket events to `RpcServer.Protocol`.
1729
1730
  */
1730
- declare const layer$4: (options?: LayerOptions$5) => Layer.Layer<DurableObjectRpcWebSocket | RpcServer.Protocol, never, DurableObjectState | RpcSerialization.RpcSerialization>;
1731
+ declare const layer$5: (options?: LayerOptions$5) => Layer.Layer<DurableObjectRpcWebSocket | RpcServer.Protocol, never, DurableObjectState | RpcSerialization.RpcSerialization>;
1732
+ declare namespace DurableObjectSqlite_d_exports {
1733
+ export { SqliteLayerOptions, layer$4 as layer };
1734
+ }
1735
+ /** Options forwarded to `@effect/sql-sqlite-do` when building a SQL client layer. */
1736
+ type SqliteLayerOptions = Omit<SqliteClient.SqliteClientConfig, "db">;
1737
+ /**
1738
+ * Provides `effect/unstable/sql` from the current Durable Object SQLite storage.
1739
+ *
1740
+ * @example
1741
+ * ```ts
1742
+ * const RoomLayer = Layer.mergeAll(
1743
+ * DurableObjectSqlite.layer(),
1744
+ * OtherRoomServices,
1745
+ * );
1746
+ * ```
1747
+ */
1748
+ declare const layer$4: (options?: SqliteLayerOptions) => Layer.Layer<_$effect_unstable_sql_SqlClient0.SqlClient | SqliteClient.SqliteClient, never, DurableObjectState>;
1731
1749
  declare namespace Images_d_exports {
1732
1750
  export { DrawStepOptions, HostedImagesClient, ImageDrawOptions, ImageHandleClient, ImageInfoResponse, ImageInputOptions, ImageInputValue, ImageList, ImageListOptions, ImageMetadata, ImageOutputOptions, ImageTransform, ImageTransformationOutputOptions, ImageTransformationResult, ImageUpdateOptions, ImageUploadOptions, ImageUploadValue, ImagesClient, ImagesDefinition, ImagesOperationError, ImagesRuntimeBinding, ImagesService, ImagesTransformationResultClient, LayerOptions$4 as LayerOptions, ProcessOptions, Step, Steps, Tag$5 as Tag, TagClass$4 as TagClass, draw, empty, isImagesBinding, layer$3 as layer, make$3 as make, makeClient$3 as makeClient, transform };
1733
1751
  }
@@ -2170,4 +2188,4 @@ declare const implement: <ROut, const Self extends Definition$1.Any>(_definition
2170
2188
  type Handler<ROut, Self extends Definition$1.Any> = Handler$1<ROut, Self>;
2171
2189
  type Options<ROut, Self extends Definition$1.Any> = Options$1<ROut, Self>;
2172
2190
  //#endregion
2173
- export { Binding_d_exports as Binding, D1_d_exports as D1, DurableObject_d_exports as DurableObject, DurableObjectAlarm_d_exports as DurableObjectAlarm, DurableObjectDefinition_d_exports as DurableObjectDefinition, DurableObjectNamespace_d_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_d_exports as DurableObjectRpcWebSocket, DurableObjectState_d_exports as DurableObjectState, DurableObjectStorage_d_exports as DurableObjectStorage, DurableObjectWebSocket_d_exports as DurableObjectWebSocket, Hyperdrive_d_exports as Hyperdrive, Images_d_exports as Images, Kv_d_exports as Kv, Queue_d_exports as Queue, QueueBinding_d_exports as QueueBinding, QueueDefinition_d_exports as QueueDefinition, R2_d_exports as R2, Rpc_d_exports as Rpc, RpcDefinition_d_exports as RpcDefinition, ServiceBinding_d_exports as ServiceBinding, Worker_d_exports as Worker, WorkerConfig, WorkerDefinition_d_exports as WorkerDefinition, type WorkerEnv, WorkerEnvironment, Workflow_d_exports as Workflow, WorkflowBinding_d_exports as WorkflowBinding, WorkflowDefinition_d_exports as WorkflowDefinition };
2191
+ export { Binding_d_exports as Binding, D1_d_exports as D1, DurableObject_d_exports as DurableObject, DurableObjectAlarm_d_exports as DurableObjectAlarm, DurableObjectDefinition_d_exports as DurableObjectDefinition, DurableObjectNamespace_d_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_d_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_d_exports as DurableObjectSqlite, DurableObjectState_d_exports as DurableObjectState, DurableObjectStorage_d_exports as DurableObjectStorage, DurableObjectWebSocket_d_exports as DurableObjectWebSocket, Hyperdrive_d_exports as Hyperdrive, Images_d_exports as Images, Kv_d_exports as Kv, Queue_d_exports as Queue, QueueBinding_d_exports as QueueBinding, QueueDefinition_d_exports as QueueDefinition, R2_d_exports as R2, Rpc_d_exports as Rpc, RpcDefinition_d_exports as RpcDefinition, ServiceBinding_d_exports as ServiceBinding, Worker_d_exports as Worker, WorkerConfig, WorkerDefinition_d_exports as WorkerDefinition, type WorkerEnv, WorkerEnvironment, Workflow_d_exports as Workflow, WorkflowBinding_d_exports as WorkflowBinding, WorkflowDefinition_d_exports as WorkflowDefinition };
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$8, 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$9, 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 { D1Client } from "@effect/sql-d1";
5
5
  import { DurableObject, RpcStub, RpcTarget, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
@@ -7,6 +7,7 @@ import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
7
7
  import * as RpcMessage from "effect/unstable/rpc/RpcMessage";
8
8
  import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
9
9
  import * as RpcServer from "effect/unstable/rpc/RpcServer";
10
+ import { SqliteClient } from "@effect/sql-sqlite-do";
10
11
  //#region src/D1.ts
11
12
  var D1_exports = /* @__PURE__ */ __exportAll({
12
13
  Service: () => Service$1,
@@ -58,7 +59,7 @@ const Service$1 = () => (id, definition) => {
58
59
  var QueueBinding_exports = /* @__PURE__ */ __exportAll({
59
60
  QueueOperationError: () => QueueOperationError,
60
61
  isQueue: () => isQueue,
61
- layer: () => layer$7,
62
+ layer: () => layer$8,
62
63
  makeClient: () => makeClient$6
63
64
  });
64
65
  const expectedQueueProducer = "Queue producer binding with send(); optional sendBatch()/metrics()";
@@ -114,7 +115,7 @@ const makeClient$6 = (definition) => {
114
115
  unsafeRaw: Effect.succeed(queue)
115
116
  });
116
117
  };
117
- const layer$7 = (tag, definition) => layer$8(tag, definition.binding, (value) => isQueue(value), makeClient$6(definition), { expected: expectedQueueProducer });
118
+ const layer$8 = (tag, definition) => layer$9(tag, definition.binding, (value) => isQueue(value), makeClient$6(definition), { expected: expectedQueueProducer });
118
119
  //#endregion
119
120
  //#region src/QueueDefinition.ts
120
121
  var QueueDefinition_exports = /* @__PURE__ */ __exportAll({
@@ -137,7 +138,7 @@ const make$9 = (id, definition) => Tag$10()(id, definition);
137
138
  const Tag$10 = () => (id, definition) => {
138
139
  const queueDefinition = makeDefinition$4(id, definition);
139
140
  const tag = Context.Service()(id);
140
- const layer = (binding) => layer$7(tag, {
141
+ const layer = (binding) => layer$8(tag, {
141
142
  ...binding,
142
143
  message: definition.message
143
144
  });
@@ -393,7 +394,7 @@ var ServiceBinding_exports = /* @__PURE__ */ __exportAll({
393
394
  ServiceBindingFetchError: () => ServiceBindingFetchError,
394
395
  ServiceBindingRpcError: () => ServiceBindingRpcError,
395
396
  isServiceBindingClient: () => isServiceBindingClient,
396
- layer: () => layer$6,
397
+ layer: () => layer$7,
397
398
  makeClient: () => makeClient$5,
398
399
  makeDirectMethods: () => makeDirectMethods$1
399
400
  });
@@ -457,7 +458,7 @@ const makeClient$5 = (definition) => {
457
458
  });
458
459
  };
459
460
  };
460
- const layer$6 = (tag, definition) => layer$8(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$5(definition), { expected: expectedServiceBinding });
461
+ const layer$7 = (tag, definition) => layer$9(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$5(definition), { expected: expectedServiceBinding });
461
462
  /**
462
463
  * Creates a typed Effect service for a Worker service binding.
463
464
  *
@@ -574,7 +575,7 @@ const Tag$8 = () => (id, methods) => {
574
575
  ...binding,
575
576
  definition
576
577
  });
577
- const layer = (binding) => layer$6(tag, bindingDefinition(binding));
578
+ const layer = (binding) => layer$7(tag, bindingDefinition(binding));
578
579
  const fetch = (input, init) => Effect.gen(function* () {
579
580
  return yield* (yield* tag).fetch(input, init);
580
581
  });
@@ -1020,7 +1021,7 @@ var DurableObjectNamespace_exports = /* @__PURE__ */ __exportAll({
1020
1021
  DurableObjectFetchError: () => DurableObjectFetchError,
1021
1022
  DurableObjectRpcError: () => DurableObjectRpcError,
1022
1023
  isDurableObjectNamespaceClient: () => isDurableObjectNamespaceClient,
1023
- layer: () => layer$5,
1024
+ layer: () => layer$6,
1024
1025
  makeClient: () => makeClient$4,
1025
1026
  makeDirectMethods: () => makeDirectMethods
1026
1027
  });
@@ -1102,7 +1103,7 @@ const makeClient$4 = (definition) => {
1102
1103
  });
1103
1104
  };
1104
1105
  };
1105
- const layer$5 = (tag, definition) => layer$8(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$4(definition), { expected: expectedDurableObjectNamespace });
1106
+ const layer$6 = (tag, definition) => layer$9(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$4(definition), { expected: expectedDurableObjectNamespace });
1106
1107
  const makeDirectMethods = (rpcDefinition, helpers) => {
1107
1108
  const methods = {};
1108
1109
  if (rpcDefinition !== void 0) {
@@ -1174,7 +1175,7 @@ const Tag$6 = () => (id, methods) => {
1174
1175
  ...binding,
1175
1176
  definition
1176
1177
  });
1177
- const layer = (binding) => layer$5(tag, bindingDefinition(binding));
1178
+ const layer = (binding) => layer$6(tag, bindingDefinition(binding));
1178
1179
  const newUniqueId = Effect.fnUntraced(function* (options) {
1179
1180
  return yield* (yield* tag).newUniqueId(options);
1180
1181
  });
@@ -1638,7 +1639,7 @@ var DurableObjectAlarm = class DurableObjectAlarm extends Context.Service()("eff
1638
1639
  //#region src/DurableObjectRpcWebSocket.ts
1639
1640
  var DurableObjectRpcWebSocket_exports = /* @__PURE__ */ __exportAll({
1640
1641
  DurableObjectRpcWebSocket: () => DurableObjectRpcWebSocket,
1641
- layer: () => layer$4
1642
+ layer: () => layer$5
1642
1643
  });
1643
1644
  const defaultAttachmentKey = "effectCloudflareRpcClientId";
1644
1645
  const defaultTag = "effect-cf-rpc";
@@ -1649,7 +1650,7 @@ var DurableObjectRpcWebSocket = class extends Context.Service()("effect-cf/Durab
1649
1650
  /**
1650
1651
  * Builds a layer that bridges Durable Object websocket events to `RpcServer.Protocol`.
1651
1652
  */
1652
- const layer$4 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
1653
+ const layer$5 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
1653
1654
  const tag = options.tag ?? defaultTag;
1654
1655
  const attachmentKey = options.attachmentKey ?? defaultAttachmentKey;
1655
1656
  const durableObjectState = yield* DurableObjectState;
@@ -1761,6 +1762,27 @@ const writeAttachment = (socket, key, clientId) => {
1761
1762
  });
1762
1763
  };
1763
1764
  //#endregion
1765
+ //#region src/DurableObjectSqlite.ts
1766
+ var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$4 });
1767
+ /**
1768
+ * Provides `effect/unstable/sql` from the current Durable Object SQLite storage.
1769
+ *
1770
+ * @example
1771
+ * ```ts
1772
+ * const RoomLayer = Layer.mergeAll(
1773
+ * DurableObjectSqlite.layer(),
1774
+ * OtherRoomServices,
1775
+ * );
1776
+ * ```
1777
+ */
1778
+ const layer$4 = (options) => Layer.unwrap(Effect.gen(function* () {
1779
+ const state = yield* DurableObjectState;
1780
+ return SqliteClient.layer({
1781
+ ...options,
1782
+ db: state.raw.storage.sql
1783
+ });
1784
+ }));
1785
+ //#endregion
1764
1786
  //#region src/Images.ts
1765
1787
  var Images_exports = /* @__PURE__ */ __exportAll({
1766
1788
  ImagesOperationError: () => ImagesOperationError,
@@ -1857,7 +1879,7 @@ const makeClient$3 = (definition) => (images) => {
1857
1879
  unsafeRaw: Effect.succeed(images)
1858
1880
  };
1859
1881
  };
1860
- const layer$3 = (tag, definition) => layer$8(tag, definition.binding, isImagesBinding, makeClient$3(definition), { expected: expectedImagesBinding });
1882
+ const layer$3 = (tag, definition) => layer$9(tag, definition.binding, isImagesBinding, makeClient$3(definition), { expected: expectedImagesBinding });
1861
1883
  const make$3 = (id) => Tag$4()(id);
1862
1884
  const Tag$4 = () => (id) => {
1863
1885
  const tag = Context.Service()(id);
@@ -1952,7 +1974,7 @@ const makeClient$2 = (definition) => {
1952
1974
  unsafeRaw: Effect.succeed(kv)
1953
1975
  });
1954
1976
  };
1955
- const layer$2 = (tag, definition) => layer$8(tag, definition.binding, isKvNamespace, makeClient$2(definition), { expected: expectedKvNamespace });
1977
+ const layer$2 = (tag, definition) => layer$9(tag, definition.binding, isKvNamespace, makeClient$2(definition), { expected: expectedKvNamespace });
1956
1978
  const makeDefinition$1 = (id, definition) => {
1957
1979
  const kvDefinition = {
1958
1980
  id,
@@ -2069,7 +2091,7 @@ const makeClient$1 = (definition) => {
2069
2091
  };
2070
2092
  };
2071
2093
  };
2072
- const layer$1 = (tag, definition) => layer$8(tag, definition.binding, isR2Bucket, makeClient$1(definition), { expected: expectedR2Bucket });
2094
+ const layer$1 = (tag, definition) => layer$9(tag, definition.binding, isR2Bucket, makeClient$1(definition), { expected: expectedR2Bucket });
2073
2095
  const make$2 = (id) => Tag$2()(id);
2074
2096
  const Tag$2 = () => (id) => {
2075
2097
  const tag = Context.Service()(id);
@@ -2155,7 +2177,7 @@ const makeClient = (definition) => {
2155
2177
  unsafeRaw: Effect.succeed(workflow)
2156
2178
  });
2157
2179
  };
2158
- const layer = (tag, definition) => layer$8(tag, definition.binding, (value) => isWorkflow(value), makeClient(definition), { expected: expectedWorkflow });
2180
+ const layer = (tag, definition) => layer$9(tag, definition.binding, (value) => isWorkflow(value), makeClient(definition), { expected: expectedWorkflow });
2159
2181
  //#endregion
2160
2182
  //#region src/WorkflowDefinition.ts
2161
2183
  var WorkflowDefinition_exports = /* @__PURE__ */ __exportAll({
@@ -2176,7 +2198,7 @@ const make$1 = (id, definition) => Tag$1()(id, definition);
2176
2198
  const Tag$1 = () => (id, definition) => {
2177
2199
  const workflowDefinition = makeDefinition(id, definition);
2178
2200
  const tag = Context.Service()(id);
2179
- const layer$9 = (binding) => layer(tag, {
2201
+ const layer$10 = (binding) => layer(tag, {
2180
2202
  ...binding,
2181
2203
  payload: definition.payload,
2182
2204
  result: definition.result
@@ -2198,7 +2220,7 @@ const Tag$1 = () => (id, definition) => {
2198
2220
  payload: workflowDefinition.payload,
2199
2221
  result: workflowDefinition.result,
2200
2222
  make: workflowDefinition.make,
2201
- layer: layer$9,
2223
+ layer: layer$10,
2202
2224
  create,
2203
2225
  createBatch,
2204
2226
  get,
@@ -2289,4 +2311,4 @@ const waitForEvent = (name, options) => Effect.flatMap(WorkflowStep$1, (workflow
2289
2311
  const Tag = Tag$1;
2290
2312
  const implement = implement$1;
2291
2313
  //#endregion
2292
- export { Binding_exports as Binding, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, 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, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
2314
+ export { Binding_exports as Binding, 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, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-cf",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Effect-native primitives for Cloudflare Workers and bindings.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,6 +43,7 @@
43
43
  "@cloudflare/workers-types": "^4.20260421.1",
44
44
  "@effect/sql-d1": "catalog:",
45
45
  "@effect/sql-pg": "catalog:",
46
+ "@effect/sql-sqlite-do": "catalog:",
46
47
  "@effect/vitest": "catalog:",
47
48
  "effect": "catalog:",
48
49
  "typescript": "^6.0.2",
@@ -52,6 +53,7 @@
52
53
  "peerDependencies": {
53
54
  "@effect/sql-d1": "^4.0.0-beta.70",
54
55
  "@effect/sql-pg": "^4.0.0-beta.70",
56
+ "@effect/sql-sqlite-do": "^4.0.0-beta.70",
55
57
  "effect": "^4.0.0-beta.70"
56
58
  },
57
59
  "peerDependenciesMeta": {
@@ -0,0 +1,26 @@
1
+ import { SqliteClient } from "@effect/sql-sqlite-do";
2
+ import { Effect, Layer } from "effect";
3
+
4
+ import { DurableObjectState } from "./DurableObjectState";
5
+
6
+ /** Options forwarded to `@effect/sql-sqlite-do` when building a SQL client layer. */
7
+ export type SqliteLayerOptions = Omit<SqliteClient.SqliteClientConfig, "db">;
8
+
9
+ /**
10
+ * Provides `effect/unstable/sql` from the current Durable Object SQLite storage.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const RoomLayer = Layer.mergeAll(
15
+ * DurableObjectSqlite.layer(),
16
+ * OtherRoomServices,
17
+ * );
18
+ * ```
19
+ */
20
+ export const layer = (options?: SqliteLayerOptions) =>
21
+ Layer.unwrap(
22
+ Effect.gen(function* () {
23
+ const state = yield* DurableObjectState;
24
+ return SqliteClient.layer({ ...options, db: state.raw.storage.sql });
25
+ }),
26
+ );
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * as DurableObjectAlarm from "./DurableObjectAlarm";
5
5
  export * as DurableObjectDefinition from "./DurableObjectDefinition";
6
6
  export * as DurableObjectNamespace from "./DurableObjectNamespace";
7
7
  export * as DurableObjectRpcWebSocket from "./DurableObjectRpcWebSocket";
8
+ export * as DurableObjectSqlite from "./DurableObjectSqlite";
8
9
  export * as DurableObjectState from "./DurableObjectState";
9
10
  export * as DurableObjectWebSocket from "./DurableObjectWebSocket";
10
11
  export * as DurableObjectStorage from "./DurableObjectStorage";