effect-cf 0.28.1 → 0.30.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.d.mts CHANGED
@@ -1,8 +1,9 @@
1
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-xJJJPmiD.mjs";
2
2
  import { l as Artifacts_d_exports } from "./Artifacts-DnHQA-Ax.mjs";
3
- import { C as Rpc_d_exports, D as StorageOperationError, E as DurableObjectStorage_d_exports, S as Provider, T as DurableWebSocket, _ as Definition$4, a as NativeRequest, b as RpcDefinition_d_exports, c as WorkerDefinition_d_exports, d as AsyncMethodCloudflareReturn, f as AsyncMethodKey, g as QueueBinding_d_exports, h as QueueDefinition_d_exports, i as ExecutionContext, l as ServiceBinding_d_exports, m as Queue_d_exports, o as WorkerContext, p as AsyncMethodSuccess, r as DurableObjectState_d_exports, s as Worker_d_exports, t as DurableObjectState, u as AsyncMethodArgs, v as Method$2, w as DurableObjectWebSocket_d_exports, x as ServiceFreeSchema$1, y as ReservedMethodName$2 } from "./DurableObjectState-OupNMMUl.mjs";
3
+ import { C as Rpc_d_exports, D as StorageOperationError, E as DurableObjectStorage_d_exports, S as Provider, T as DurableWebSocket, _ as Definition$4, a as NativeRequest, b as RpcDefinition_d_exports, c as WorkerDefinition_d_exports, d as AsyncMethodCloudflareReturn, f as AsyncMethodKey, g as QueueBinding_d_exports, h as QueueDefinition_d_exports, i as ExecutionContext, l as ServiceBinding_d_exports, m as Queue_d_exports, o as WorkerContext, p as AsyncMethodSuccess, r as DurableObjectState_d_exports, s as Worker_d_exports, t as DurableObjectState, u as AsyncMethodArgs, v as Method$2, w as DurableObjectWebSocket_d_exports, x as ServiceFreeSchema$1, y as ReservedMethodName$2 } from "./DurableObjectState-D3k-WRnd.mjs";
4
4
  import { t as Hyperdrive_d_exports } from "./Hyperdrive-z-9fFz15.mjs";
5
- import { a as WorkflowInstanceCreateOptions, i as WorkflowInstanceCreateBatchOptions, n as WorkflowBinding_d_exports, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient } from "./WorkflowBinding-DUZtKCVM.mjs";
5
+ import { t as ContainerNamespace_d_exports } from "./ContainerNamespace-CFjiLw8b.mjs";
6
+ import { a as WorkflowInstanceCreateOptions, i as WorkflowInstanceCreateBatchOptions, n as WorkflowBinding_d_exports, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient } from "./WorkflowBinding-CtrmxfdT.mjs";
6
7
  import { Cause, Config, Context, Data, DateTime, Duration, Effect, Layer, Option, Predicate, Redacted, Schema, Scope } from "effect";
7
8
  import { Headers as Headers$1, HttpClient, HttpClientResponse } from "effect/unstable/http";
8
9
  import { OtlpExporter, OtlpResource } from "effect/unstable/observability";
@@ -14,7 +15,7 @@ import { SqliteClient } from "@effect/sql-sqlite-do";
14
15
  import { SqlClient } from "effect/unstable/sql";
15
16
  import * as Tracer from "effect/Tracer";
16
17
  declare namespace WorkersAi_d_exports {
17
- export { LayerOptions$14 as LayerOptions, Tag$13 as Tag, TagClass$12 as TagClass, WorkersAiAsyncBatchResponse, WorkersAiBinding, WorkersAiClient, WorkersAiDefinition, WorkersAiEmbeddingInput, WorkersAiEmbeddingResponse, WorkersAiModelsSearchObject, WorkersAiModelsSearchParams, WorkersAiOperationError, WorkersAiOptions, WorkersAiService, embeddingResponse, isWorkersAiBinding, layer$14 as layer, make$13 as make, makeClient$11 as makeClient };
18
+ export { LayerOptions$13 as LayerOptions, Tag$12 as Tag, TagClass$11 as TagClass, WorkersAiAsyncBatchResponse, WorkersAiBinding, WorkersAiClient, WorkersAiDefinition, WorkersAiEmbeddingInput, WorkersAiEmbeddingResponse, WorkersAiModelsSearchObject, WorkersAiModelsSearchParams, WorkersAiOperationError, WorkersAiOptions, WorkersAiService, embeddingResponse, isWorkersAiBinding, layer$13 as layer, make$12 as make, makeClient$10 as makeClient };
18
19
  }
19
20
  declare const WorkersAiOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
20
21
  readonly _tag: "WorkersAiOperationError";
@@ -76,12 +77,12 @@ interface WorkersAiService<Id extends string> {
76
77
  readonly id: Id;
77
78
  };
78
79
  }
79
- type LayerOptions$14 = {
80
+ type LayerOptions$13 = {
80
81
  readonly binding: string;
81
82
  };
82
- interface TagClass$12<Self, Id extends string, ModelList extends AiModelListType = AiModels> extends Context.ServiceClass<Self, Id, WorkersAiClient<ModelList>> {
83
+ interface TagClass$11<Self, Id extends string, ModelList extends AiModelListType = AiModels> extends Context.ServiceClass<Self, Id, WorkersAiClient<ModelList>> {
83
84
  readonly id: Id;
84
- readonly layer: (options: LayerOptions$14) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
85
+ readonly layer: (options: LayerOptions$13) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
85
86
  }
86
87
  type WorkersAiBindingValue = Schema.Schema.Type<typeof Schema.Unknown>;
87
88
  declare const isWorkersAiBinding: (value: WorkersAiBindingValue) => value is WorkersAiBinding;
@@ -89,12 +90,12 @@ declare const embeddingResponse: (value: {
89
90
  readonly data?: ReadonlyArray<ReadonlyArray<number>>;
90
91
  readonly [embeddingDimensionsKey]?: ReadonlyArray<number>;
91
92
  }) => WorkersAiEmbeddingResponse;
92
- declare const makeClient$11: <ModelList extends AiModelListType = AiModels>(definition: WorkersAiDefinition) => (ai: WorkersAiBinding<ModelList>) => WorkersAiClient<ModelList>;
93
- declare const layer$14: <Self, ModelList extends AiModelListType = AiModels>(tag: Context.Service<Self, WorkersAiClient<ModelList>>, definition: WorkersAiDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
94
- declare const make$13: <Id extends string>(id: Id) => TagClass$12<WorkersAiService<Id>, Id, AiModels>;
95
- declare const Tag$13: <Self>() => <Id extends string, ModelList extends AiModelListType = AiModels>(id: Id) => TagClass$12<Self, Id, ModelList>;
93
+ declare const makeClient$10: <ModelList extends AiModelListType = AiModels>(definition: WorkersAiDefinition) => (ai: WorkersAiBinding<ModelList>) => WorkersAiClient<ModelList>;
94
+ declare const layer$13: <Self, ModelList extends AiModelListType = AiModels>(tag: Context.Service<Self, WorkersAiClient<ModelList>>, definition: WorkersAiDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
95
+ declare const make$12: <Id extends string>(id: Id) => TagClass$11<WorkersAiService<Id>, Id, AiModels>;
96
+ declare const Tag$12: <Self>() => <Id extends string, ModelList extends AiModelListType = AiModels>(id: Id) => TagClass$11<Self, Id, ModelList>;
96
97
  declare namespace AiGateway_d_exports {
97
- export { AiGatewayBinding, AiGatewayClient, AiGatewayDefinition, AiGatewayFetchOptions, AiGatewayHeaders, AiGatewayLog, AiGatewayOperationError, AiGatewayPatchLog, AiGatewayProvider, AiGatewayRunOptions, AiGatewayService, AiGatewayUniversalRequest, LayerOptions$13 as LayerOptions, Tag$12 as Tag, TagClass$11 as TagClass, isAiGatewayBinding, layer$13 as layer, make$12 as make, makeClient$10 as makeClient, makeClientFromAi, makeHttpClient };
98
+ export { AiGatewayBinding, AiGatewayClient, AiGatewayDefinition, AiGatewayFetchOptions, AiGatewayHeaders, AiGatewayLog, AiGatewayOperationError, AiGatewayPatchLog, AiGatewayProvider, AiGatewayRunOptions, AiGatewayService, AiGatewayUniversalRequest, LayerOptions$12 as LayerOptions, Tag$11 as Tag, TagClass$10 as TagClass, isAiGatewayBinding, layer$12 as layer, make$11 as make, makeClient$9 as makeClient, makeClientFromAi, makeHttpClient };
98
99
  }
99
100
  declare const AiGatewayOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
100
101
  readonly _tag: "AiGatewayOperationError";
@@ -146,17 +147,17 @@ interface AiGatewayService<Id extends string> {
146
147
  readonly id: Id;
147
148
  };
148
149
  }
149
- type LayerOptions$13 = {
150
+ type LayerOptions$12 = {
150
151
  readonly binding: string;
151
152
  readonly gatewayId: string;
152
153
  readonly accountId?: string;
153
154
  };
154
- interface TagClass$11<Self, Id extends string> extends Context.ServiceClass<Self, Id, AiGatewayClient> {
155
+ interface TagClass$10<Self, Id extends string> extends Context.ServiceClass<Self, Id, AiGatewayClient> {
155
156
  readonly id: Id;
156
- readonly layer: (options: LayerOptions$13) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError | AiGatewayOperationError, WorkerEnvironment>;
157
+ readonly layer: (options: LayerOptions$12) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError | AiGatewayOperationError, WorkerEnvironment>;
157
158
  }
158
159
  declare const isAiGatewayBinding: (value: AiGatewayBindingCandidate) => value is WorkersAiBinding;
159
- declare const makeClient$10: (definition: AiGatewayDefinition, gateway: AiGatewayBinding) => {
160
+ declare const makeClient$9: (definition: AiGatewayDefinition, gateway: AiGatewayBinding) => {
160
161
  definition: AiGatewayDefinition;
161
162
  run: (data: import("@cloudflare/workers-types").AIGatewayUniversalRequest | readonly import("@cloudflare/workers-types").AIGatewayUniversalRequest[], options?: {
162
163
  gateway?: import("@cloudflare/workers-types").UniversalGatewayOptions;
@@ -174,11 +175,11 @@ declare const makeHttpClient: (definition: Omit<AiGatewayDefinition, "binding">
174
175
  readonly accountId: string;
175
176
  readonly binding?: string;
176
177
  }, request?: typeof fetch) => AiGatewayClient;
177
- declare const layer$13: <Self>(tag: Context.Service<Self, AiGatewayClient>, definition: AiGatewayDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
178
- declare const make$12: <Id extends string>(id: Id) => TagClass$11<AiGatewayService<Id>, Id>;
179
- declare const Tag$12: <Self>() => <Id extends string>(id: Id) => TagClass$11<Self, Id>;
178
+ declare const layer$12: <Self>(tag: Context.Service<Self, AiGatewayClient>, definition: AiGatewayDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
179
+ declare const make$11: <Id extends string>(id: Id) => TagClass$10<AiGatewayService<Id>, Id>;
180
+ declare const Tag$11: <Self>() => <Id extends string>(id: Id) => TagClass$10<Self, Id>;
180
181
  declare namespace AnalyticsEngine_d_exports {
181
- export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, LayerOptions$12 as LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag$11 as Tag, TagClass$10 as TagClass, isAnalyticsEngineDataset, layer$12 as layer, layerFetch, layerFetchConfig, make$11 as make, makeClient$9 as makeClient, makeQuery, makeQueryClient, queryConfig, queryLayer, queryLayerConfig, writeLimits };
182
+ export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, LayerOptions$11 as LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag$10 as Tag, TagClass$9 as TagClass, isAnalyticsEngineDataset, layer$11 as layer, layerFetch, layerFetchConfig, make$10 as make, makeClient$8 as makeClient, makeQuery, makeQueryClient, queryConfig, queryLayer, queryLayerConfig, writeLimits };
182
183
  }
183
184
  declare const writeLimits: {
184
185
  readonly maxBlobs: 20;
@@ -306,7 +307,7 @@ interface AnalyticsEngineQueryService<Id extends string> {
306
307
  readonly id: Id;
307
308
  };
308
309
  }
309
- type LayerOptions$12 = {
310
+ type LayerOptions$11 = {
310
311
  readonly binding: string;
311
312
  readonly write?: AnalyticsEngineWritePolicy;
312
313
  };
@@ -315,9 +316,9 @@ type QueryConfigOptions = {
315
316
  readonly apiToken?: Config.Config<Redacted.Redacted<string>>;
316
317
  readonly apiBaseUrl?: Config.Config<string>;
317
318
  };
318
- interface TagClass$10<Self, Id extends string> extends Context.ServiceClass<Self, Id, AnalyticsEngineClient> {
319
+ interface TagClass$9<Self, Id extends string> extends Context.ServiceClass<Self, Id, AnalyticsEngineClient> {
319
320
  readonly id: Id;
320
- readonly layer: (options: LayerOptions$12) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
321
+ readonly layer: (options: LayerOptions$11) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
321
322
  }
322
323
  interface QueryTagClass<Self, Id extends string> extends Context.ServiceClass<Self, Id, AnalyticsEngineQueryClient> {
323
324
  readonly id: Id;
@@ -328,7 +329,7 @@ interface QueryTagClass<Self, Id extends string> extends Context.ServiceClass<Se
328
329
  }
329
330
  declare const makeQueryClient: (definition: AnalyticsEngineQueryDefinition) => Effect.Effect<AnalyticsEngineQueryClient, never, HttpClient.HttpClient>;
330
331
  declare const isAnalyticsEngineDataset: <Candidate>(value: Candidate) => value is Candidate & AnalyticsEngineBinding;
331
- declare const makeClient$9: (definition: AnalyticsEngineDefinition, defaults?: AnalyticsEngineWritePolicy) => (dataset: AnalyticsEngineBinding) => AnalyticsEngineClient;
332
+ declare const makeClient$8: (definition: AnalyticsEngineDefinition, defaults?: AnalyticsEngineWritePolicy) => (dataset: AnalyticsEngineBinding) => AnalyticsEngineClient;
332
333
  declare const queryConfig: (options?: QueryConfigOptions) => Config.Config<{
333
334
  accountId: string;
334
335
  apiToken: Redacted.Redacted<string>;
@@ -338,13 +339,13 @@ declare const queryLayer: <Self>(tag: Context.Service<Self, AnalyticsEngineQuery
338
339
  declare const layerFetch: <Self>(tag: Context.Service<Self, AnalyticsEngineQueryClient>, definition: AnalyticsEngineQueryDefinition) => Layer.Layer<Self, never, never>;
339
340
  declare const queryLayerConfig: <Self>(tag: Context.Service<Self, AnalyticsEngineQueryClient>, config?: Config.Config<AnalyticsEngineQueryDefinition>) => Layer.Layer<Self, Config.ConfigError, HttpClient.HttpClient>;
340
341
  declare const layerFetchConfig: <Self>(tag: Context.Service<Self, AnalyticsEngineQueryClient>, config?: Config.Config<AnalyticsEngineQueryDefinition>) => Layer.Layer<Self, Config.ConfigError, never>;
341
- declare const layer$12: <Self>(tag: Context.Service<Self, AnalyticsEngineClient>, definition: LayerOptions$12) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
342
- declare const make$11: <Id extends string>(id: Id) => TagClass$10<AnalyticsEngineService<Id>, Id>;
342
+ declare const layer$11: <Self>(tag: Context.Service<Self, AnalyticsEngineClient>, definition: LayerOptions$11) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
343
+ declare const make$10: <Id extends string>(id: Id) => TagClass$9<AnalyticsEngineService<Id>, Id>;
343
344
  declare const makeQuery: <Id extends string>(id: Id) => QueryTagClass<AnalyticsEngineQueryService<Id>, Id>;
344
- declare const Tag$11: <Self>() => <Id extends string>(id: Id) => TagClass$10<Self, Id>;
345
+ declare const Tag$10: <Self>() => <Id extends string>(id: Id) => TagClass$9<Self, Id>;
345
346
  declare const QueryTag: <Self>() => <Id extends string>(id: Id) => QueryTagClass<Self, Id>;
346
347
  declare namespace BrowserRendering_d_exports {
347
- export { BrowserRenderingBinding, BrowserRenderingBrowserClient, BrowserRenderingBrowserLike, BrowserRenderingClient, BrowserRenderingConnect, BrowserRenderingDefinition, BrowserRenderingExternalResult, BrowserRenderingLaunch, BrowserRenderingMethodOptions, BrowserRenderingOperationError, BrowserRenderingPageClient, BrowserRenderingPageFunction, BrowserRenderingPageLike, BrowserRenderingService, LayerOptions$11 as LayerOptions, Tag$10 as Tag, TagClass$9 as TagClass, isBrowserRenderingBinding, layer$11 as layer, make$10 as make, makeClient$8 as makeClient };
348
+ export { BrowserRenderingBinding, BrowserRenderingBrowserClient, BrowserRenderingBrowserLike, BrowserRenderingClient, BrowserRenderingConnect, BrowserRenderingDefinition, BrowserRenderingExternalResult, BrowserRenderingLaunch, BrowserRenderingMethodOptions, BrowserRenderingOperationError, BrowserRenderingPageClient, BrowserRenderingPageFunction, BrowserRenderingPageLike, BrowserRenderingService, LayerOptions$10 as LayerOptions, Tag$9 as Tag, TagClass$8 as TagClass, isBrowserRenderingBinding, layer$10 as layer, make$9 as make, makeClient$7 as makeClient };
348
349
  }
349
350
  declare const BrowserRenderingOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
350
351
  readonly _tag: "BrowserRenderingOperationError";
@@ -413,20 +414,20 @@ interface BrowserRenderingService<Id extends string> {
413
414
  readonly id: Id;
414
415
  };
415
416
  }
416
- type LayerOptions$11 = {
417
+ type LayerOptions$10 = {
417
418
  readonly binding: string;
418
419
  };
419
- interface TagClass$9<Self, Id extends string> extends Context.ServiceClass<Self, Id, BrowserRenderingClient> {
420
+ interface TagClass$8<Self, Id extends string> extends Context.ServiceClass<Self, Id, BrowserRenderingClient> {
420
421
  readonly id: Id;
421
- readonly layer: (options: LayerOptions$11) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
422
+ readonly layer: (options: LayerOptions$10) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
422
423
  }
423
424
  declare const isBrowserRenderingBinding: <Candidate>(value: Candidate) => value is Candidate & BrowserRenderingBinding;
424
- declare const makeClient$8: <RawBinding extends BrowserRenderingBinding = BrowserRenderingBinding>(definition: BrowserRenderingDefinition) => (binding: RawBinding) => BrowserRenderingClient<RawBinding>;
425
- declare const layer$11: <Self>(tag: Context.Service<Self, BrowserRenderingClient>, definition: BrowserRenderingDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
426
- declare const make$10: <Id extends string>(id: Id) => TagClass$9<BrowserRenderingService<Id>, Id>;
427
- declare const Tag$10: <Self>() => <Id extends string>(id: Id) => TagClass$9<Self, Id>;
425
+ declare const makeClient$7: <RawBinding extends BrowserRenderingBinding = BrowserRenderingBinding>(definition: BrowserRenderingDefinition) => (binding: RawBinding) => BrowserRenderingClient<RawBinding>;
426
+ declare const layer$10: <Self>(tag: Context.Service<Self, BrowserRenderingClient>, definition: BrowserRenderingDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
427
+ declare const make$9: <Id extends string>(id: Id) => TagClass$8<BrowserRenderingService<Id>, Id>;
428
+ declare const Tag$9: <Self>() => <Id extends string>(id: Id) => TagClass$8<Self, Id>;
428
429
  declare namespace Cache_d_exports {
429
- export { CacheClient, CacheOperation, CacheOperationError, CacheQueryOptions, CacheRequest, CacheStorage, CacheStorageClient, layer$10 as layer, layerFrom, makeCacheClient, makeClient$7 as makeClient };
430
+ export { CacheClient, CacheOperation, CacheOperationError, CacheQueryOptions, CacheRequest, CacheStorage, CacheStorageClient, layer$9 as layer, layerFrom, makeCacheClient, makeClient$6 as makeClient };
430
431
  }
431
432
  /** Request key accepted by Cloudflare's Cache API. */
432
433
  type CacheRequest = CloudflareRequestInfo | URL;
@@ -473,13 +474,13 @@ declare class CacheStorage extends CacheStorage_base {}
473
474
  /** Wraps a native Cloudflare `Cache` instance. */
474
475
  declare const makeCacheClient: (cache: CloudflareCache, name?: string) => CacheClient;
475
476
  /** Wraps a native Cloudflare `CacheStorage` instance. */
476
- declare const makeClient$7: (storage: CloudflareCacheStorage) => CacheStorageClient;
477
+ declare const makeClient$6: (storage: CloudflareCacheStorage) => CacheStorageClient;
477
478
  /** Provides Cache API services from an explicit native `CacheStorage` instance. */
478
479
  declare const layerFrom: (storage: CloudflareCacheStorage) => Layer.Layer<CacheStorage>;
479
480
  /** Provides Cache API services from Cloudflare's global `caches` object. */
480
- declare const layer$10: Layer.Layer<CacheStorage>;
481
+ declare const layer$9: Layer.Layer<CacheStorage>;
481
482
  declare namespace CloudflareOtlp_d_exports {
482
- export { DurableObjectLayerOptions, LayerOptions$10 as LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, layer$9 as layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
483
+ export { DurableObjectLayerOptions, LayerOptions$9 as LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, layer$8 as layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
483
484
  }
484
485
  type ResourceAttributes = NonNullable<Parameters<typeof OtlpResource.make>[0]["attributes"]>;
485
486
  /** Telemetry signal groups supported by the Cloudflare OTLP layers. */
@@ -504,7 +505,7 @@ interface ResourceOptions {
504
505
  readonly attributes?: ResourceAttributes;
505
506
  }
506
507
  /** Options shared by all Cloudflare OTLP telemetry layers. */
507
- interface LayerOptions$10 {
508
+ interface LayerOptions$9 {
508
509
  /**
509
510
  * Telemetry signals to export. Defaults to logs, traces, and metrics.
510
511
  *
@@ -531,12 +532,12 @@ interface LayerOptions$10 {
531
532
  readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
532
533
  }
533
534
  /** Resource metadata specific to Cloudflare Workers. */
534
- interface WorkerLayerOptions extends LayerOptions$10 {
535
+ interface WorkerLayerOptions extends LayerOptions$9 {
535
536
  /** Cloudflare Worker name to attach as `cloudflare.worker.name`. */
536
537
  readonly workerName?: string;
537
538
  }
538
539
  /** Resource metadata specific to Cloudflare Durable Objects. */
539
- interface DurableObjectLayerOptions extends LayerOptions$10 {
540
+ interface DurableObjectLayerOptions extends LayerOptions$9 {
540
541
  /** Durable Object class name to attach as `cloudflare.durable_object.class`. */
541
542
  readonly className?: string;
542
543
  /**
@@ -557,11 +558,11 @@ interface DurableObjectLayerOptions extends LayerOptions$10 {
557
558
  * The layer provides {@link OtlpExporter.Flusher} for draining buffered
558
559
  * telemetry before the isolate freezes.
559
560
  */
560
- declare const layer$9: (options?: LayerOptions$10) => Layer.Layer<OtlpExporter.Flusher>;
561
+ declare const layer$8: (options?: LayerOptions$9) => Layer.Layer<OtlpExporter.Flusher>;
561
562
  /** Base OTLP telemetry layer forced to JSON serialization. */
562
- declare const layerJson: (options?: Omit<LayerOptions$10, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
563
+ declare const layerJson: (options?: Omit<LayerOptions$9, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
563
564
  /** Base OTLP telemetry layer forced to protobuf serialization. */
564
- declare const layerProtobuf: (options?: Omit<LayerOptions$10, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
565
+ declare const layerProtobuf: (options?: Omit<LayerOptions$9, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
565
566
  /**
566
567
  * OTLP layer with Cloudflare Worker resource attributes.
567
568
  *
@@ -577,157 +578,6 @@ declare const layerWorker: (options?: WorkerLayerOptions) => Layer.Layer<OtlpExp
577
578
  * backend can tolerate high-cardinality resource attributes.
578
579
  */
579
580
  declare const layerDurableObject: (options?: DurableObjectLayerOptions) => Layer.Layer<OtlpExporter.Flusher, never, DurableObjectState>;
580
- declare namespace ContainerNamespace_d_exports {
581
- export { ContainerInstanceClient, ContainerNamespace, ContainerNamespaceClient, ContainerNamespaceDefinition, ContainerNamespaceResource, ContainerNamespaceService, ContainerNamespaceStaticClient, ContainerOperationError, ContainerReadinessOptions, ContainerSignal, ContainerStartAndWaitForPortsOptions, ContainerStartOptions, ContainerState, ContainerStopSignal, ContainerStub, ContainerStubOf, ContainerWaitOptions, LayerOptions$9 as LayerOptions, Tag$9 as Tag, TagClass$8 as TagClass, isContainerNamespaceResource, layer$8 as layer, make$9 as make, makeClient$6 as makeClient };
582
- }
583
- /** Named signal accepted by Cloudflare Container instances. */
584
- type ContainerSignal = "SIGKILL" | "SIGINT" | "SIGTERM";
585
- /** Named or numeric signal accepted by Container `stop()`. */
586
- type ContainerStopSignal = ContainerSignal | number;
587
- /** Per-instance Container startup configuration. */
588
- interface ContainerStartOptions {
589
- readonly envVars?: Record<string, string>;
590
- readonly entrypoint?: Array<string>;
591
- readonly enableInternet?: boolean;
592
- readonly labels?: Record<string, string>;
593
- }
594
- /** Serializable retry settings used while starting a Container. */
595
- interface ContainerWaitOptions {
596
- readonly portToCheck: number;
597
- readonly retries?: number;
598
- readonly waitInterval?: number;
599
- }
600
- /** Serializable timeout settings used while waiting for Container ports. */
601
- interface ContainerReadinessOptions {
602
- readonly instanceGetTimeoutMS?: number;
603
- readonly portReadyTimeoutMS?: number;
604
- readonly waitInterval?: number;
605
- }
606
- /** Options for starting a Container and waiting for its ports. */
607
- interface ContainerStartAndWaitForPortsOptions {
608
- readonly startOptions?: ContainerStartOptions;
609
- readonly ports?: number | Array<number>;
610
- readonly cancellationOptions?: ContainerReadinessOptions;
611
- }
612
- /** Serializable state reported by a Cloudflare Container instance. */
613
- declare const ContainerState: Schema.Union<readonly [Schema.Struct<{
614
- readonly lastChange: Schema.Finite;
615
- readonly status: Schema.Literals<readonly ["running", "stopping", "stopped", "healthy"]>;
616
- }>, Schema.Struct<{
617
- readonly lastChange: Schema.Finite;
618
- readonly status: Schema.Literal<"stopped_with_code">;
619
- readonly exitCode: Schema.optionalKey<Schema.Int>;
620
- }>]>;
621
- type ContainerState = typeof ContainerState.Type;
622
- /**
623
- * Native Container stub shape exposed by a Container namespace binding.
624
- *
625
- * This is structural so using Container bindings does not make
626
- * `@cloudflare/containers` a runtime dependency of effect-cf.
627
- */
628
- interface ContainerStub {
629
- fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
630
- getState(): Promise<ContainerState>;
631
- start(options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions): Promise<void>;
632
- startAndWaitForPorts(options?: ContainerStartAndWaitForPortsOptions): Promise<void>;
633
- waitForPort(options: ContainerWaitOptions): Promise<number>;
634
- stop(signal?: ContainerStopSignal): Promise<void>;
635
- destroy(): Promise<void>;
636
- setAllowedHosts(hosts: Array<string>): Promise<void>;
637
- setDeniedHosts(hosts: Array<string>): Promise<void>;
638
- allowHost(hostname: string): Promise<void>;
639
- denyHost(hostname: string): Promise<void>;
640
- removeAllowedHost(hostname: string): Promise<void>;
641
- removeDeniedHost(hostname: string): Promise<void>;
642
- }
643
- /** Native Container namespace binding shape. */
644
- interface ContainerNamespaceResource {
645
- getByName(name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions): ContainerStub;
646
- }
647
- /** Exact native stub type produced by a Container namespace binding. */
648
- type ContainerStubOf<Namespace extends ContainerNamespaceResource> = ReturnType<Namespace["getByName"]>;
649
- /** Container namespace binding metadata. */
650
- interface ContainerNamespaceDefinition {
651
- /** Binding name as configured in `wrangler.jsonc`. */
652
- readonly binding: string;
653
- }
654
- declare const ContainerOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
655
- readonly _tag: "ContainerOperationError";
656
- } & Readonly<A>;
657
- /** Failure raised when invoking a named Container operation. */
658
- declare class ContainerOperationError extends ContainerOperationError_base<{
659
- readonly binding: string;
660
- readonly instance: string;
661
- readonly operation: string;
662
- readonly cause: unknown;
663
- }> {
664
- get message(): string;
665
- }
666
- /** Effect-wrapped client for one named Container instance. */
667
- interface ContainerInstanceClient<Stub extends ContainerStub = ContainerStub> {
668
- readonly rawUnsafe: Effect.Effect<Stub, ContainerOperationError>;
669
- readonly state: Effect.Effect<ContainerState, ContainerOperationError>;
670
- readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<Response, ContainerOperationError>;
671
- readonly start: (options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions) => Effect.Effect<void, ContainerOperationError>;
672
- readonly startAndWaitForPorts: (options?: ContainerStartAndWaitForPortsOptions) => Effect.Effect<void, ContainerOperationError>;
673
- readonly waitForPort: (options: ContainerWaitOptions) => Effect.Effect<number, ContainerOperationError>;
674
- readonly stop: (signal?: ContainerStopSignal) => Effect.Effect<void, ContainerOperationError>;
675
- readonly destroy: Effect.Effect<void, ContainerOperationError>;
676
- readonly setAllowedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError>;
677
- readonly setDeniedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError>;
678
- readonly allowHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
679
- readonly denyHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
680
- readonly removeAllowedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
681
- readonly removeDeniedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
682
- }
683
- /** Effect client for a Container namespace binding. */
684
- interface ContainerNamespaceClient<Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> {
685
- readonly definition: ContainerNamespaceDefinition;
686
- readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect<ContainerInstanceClient<ContainerStubOf<Namespace>>, ContainerOperationError>;
687
- readonly byName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => ContainerInstanceClient<ContainerStubOf<Namespace>>;
688
- readonly rawUnsafe: Effect.Effect<Namespace>;
689
- }
690
- type ContainerNamespaceStaticClient<R, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> = {
691
- readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect<ContainerInstanceClient<ContainerStubOf<Namespace>>, ContainerOperationError, R>;
692
- readonly byName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => {
693
- readonly state: Effect.Effect<ContainerState, ContainerOperationError, R>;
694
- readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<Response, ContainerOperationError, R>;
695
- readonly start: (options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions) => Effect.Effect<void, ContainerOperationError, R>;
696
- readonly startAndWaitForPorts: (options?: ContainerStartAndWaitForPortsOptions) => Effect.Effect<void, ContainerOperationError, R>;
697
- readonly waitForPort: (options: ContainerWaitOptions) => Effect.Effect<number, ContainerOperationError, R>;
698
- readonly stop: (signal?: ContainerStopSignal) => Effect.Effect<void, ContainerOperationError, R>;
699
- readonly destroy: Effect.Effect<void, ContainerOperationError, R>;
700
- readonly setAllowedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError, R>;
701
- readonly setDeniedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError, R>;
702
- readonly allowHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
703
- readonly denyHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
704
- readonly removeAllowedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
705
- readonly removeDeniedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
706
- readonly rawUnsafe: Effect.Effect<ContainerStubOf<Namespace>, ContainerOperationError, R>;
707
- };
708
- readonly rawUnsafe: Effect.Effect<Namespace, never, R>;
709
- };
710
- type LayerOptions$9 = {
711
- readonly binding: string;
712
- };
713
- interface TagClass$8<Self, Id extends string, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> extends Context.ServiceClass<Self, `effect-cf/Container/${Id}`, ContainerNamespaceClient<Namespace>>, ContainerNamespaceStaticClient<Self, Namespace> {
714
- readonly id: Id;
715
- readonly layer: (options: LayerOptions$9) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
716
- }
717
- declare const isContainerNamespaceResource: <Candidate>(value: Candidate) => value is Candidate & ContainerNamespaceResource;
718
- declare const makeClient$6: (definition: ContainerNamespaceDefinition) => <Namespace extends ContainerNamespaceResource>(namespace: Namespace) => ContainerNamespaceClient<Namespace>;
719
- declare const layer$8: <Self, Namespace extends ContainerNamespaceResource>(tag: Context.Service<Self, ContainerNamespaceClient<Namespace>>, definition: ContainerNamespaceDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
720
- declare const make$9: <Id extends string>(id: Id) => TagClass$8<ContainerNamespaceService<Id>, Id, ContainerNamespaceResource>;
721
- declare const ContainerNamespaceServiceTypeId: unique symbol;
722
- /** Nominal service marker for Container namespaces created with {@link make}. */
723
- interface ContainerNamespaceService<Id extends string> {
724
- readonly [ContainerNamespaceServiceTypeId]: {
725
- readonly id: Id;
726
- };
727
- }
728
- /** Creates a typed Effect service for a Cloudflare Container namespace. */
729
- declare const Tag$9: <Self, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource>() => <Id extends string>(id: Id) => TagClass$8<Self, Id, Namespace>;
730
- declare const ContainerNamespace: typeof Tag$9;
731
581
  declare namespace D1_d_exports {
732
582
  export { D1Definition, D1Service, D1SqlLayerOptions, Service, TypeId$1 as TypeId, make$8 as make };
733
583
  }
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { a as WorkerEnvironment, i as WorkerConfig, n as violationsMessage, r as Environment_exports, t as causeMessage } from "./ErrorMessage-BM0K-Nik.mjs";
3
- import { a as layer$19, i as Service$2, n as Artifacts_exports, r as Binding_exports } from "./Artifacts-rq3hUKQE.mjs";
4
- import { a as DurableObjectWebSocket_exports, i as fromExecutionContext, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState } from "./DurableObjectState-BjkK2kwH.mjs";
3
+ import { n as Service$2, r as layer$19, t as Binding_exports } from "./Binding-pfilNJmP.mjs";
4
+ import { n as Artifacts_exports } from "./Artifacts-CSIk1Oml.mjs";
5
+ import { a as DurableObjectWebSocket_exports, i as fromExecutionContext, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState } from "./DurableObjectState-CepagPkX.mjs";
5
6
  import { Cause, Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Function as Function$1, Layer, ManagedRuntime, Option, Predicate, Queue, Result, Schema } from "effect";
6
7
  import { FetchHttpClient, HttpClient, HttpClientRequest, HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
7
8
  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.28.1",
3
+ "version": "0.30.0",
4
4
  "description": "Effect-native primitives for Cloudflare Workers and bindings.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,6 +42,11 @@
42
42
  "import": "./dist/ComputerWorkspaceHost.mjs",
43
43
  "default": "./dist/ComputerWorkspaceHost.mjs"
44
44
  },
45
+ "./sandbox": {
46
+ "types": "./dist/Sandbox.d.mts",
47
+ "import": "./dist/Sandbox.mjs",
48
+ "default": "./dist/Sandbox.mjs"
49
+ },
45
50
  "./vitest": {
46
51
  "types": "./dist/Vitest.d.mts",
47
52
  "import": "./dist/Vitest.mjs",
@@ -62,9 +67,10 @@
62
67
  "devDependencies": {
63
68
  "@cloudflare/computer": "0.2.0",
64
69
  "@cloudflare/containers": "catalog:",
70
+ "@cloudflare/sandbox": "0.13.0-next.738.2",
65
71
  "@cloudflare/vitest-pool-workers": "catalog:",
66
72
  "@cloudflare/workers-types": "catalog:",
67
- "@effect/platform-node": "^4.0.0-beta.107 <4.0.0-rc.0",
73
+ "@effect/platform-node": "^4.0.0-rc.110",
68
74
  "@effect/sql-d1": "catalog:",
69
75
  "@effect/sql-pg": "catalog:",
70
76
  "@effect/sql-sqlite-do": "catalog:",
@@ -77,17 +83,21 @@
77
83
  },
78
84
  "peerDependencies": {
79
85
  "@cloudflare/computer": "^0.2.0",
86
+ "@cloudflare/sandbox": "^0.13.0-next.738.2",
80
87
  "@cloudflare/vitest-pool-workers": "^0.21.3",
81
88
  "@cloudflare/workers-types": "^4.20260611.1",
82
- "@effect/sql-d1": "^4.0.0-beta.107 <4.0.0-rc.0",
83
- "@effect/sql-pg": "^4.0.0-beta.107 <4.0.0-rc.0",
84
- "@effect/sql-sqlite-do": "^4.0.0-beta.107 <4.0.0-rc.0",
85
- "effect": "^4.0.0-beta.107 <4.0.0-rc.0"
89
+ "@effect/sql-d1": "^4.0.0-rc.110",
90
+ "@effect/sql-pg": "^4.0.0-rc.110",
91
+ "@effect/sql-sqlite-do": "^4.0.0-rc.110",
92
+ "effect": "^4.0.0-rc.110"
86
93
  },
87
94
  "peerDependenciesMeta": {
88
95
  "@cloudflare/computer": {
89
96
  "optional": true
90
97
  },
98
+ "@cloudflare/sandbox": {
99
+ "optional": true
100
+ },
91
101
  "@cloudflare/vitest-pool-workers": {
92
102
  "optional": true
93
103
  },
@@ -200,6 +200,7 @@ export const make = <
200
200
  // SAFETY: event-layer bypass is used only for initialize; otherwise an absent layer means REvent is never.
201
201
  return Runtime.runEventPromise(
202
202
  this.runtime,
203
+ // @effect-diagnostics-next-line unsafeEffectTypeAssertion:off
203
204
  effect as Effect.Effect<A, E, HandlerContext<ROut>>,
204
205
  );
205
206
  }
@@ -1,4 +1,4 @@
1
- import { Data, Effect, Exit, Option, Predicate, Schema as S } from "effect";
1
+ import { Clock, Data, Duration, Effect, Exit, Option, Predicate, Schema as S } from "effect";
2
2
 
3
3
  import * as ErrorMessage from "./internal/ErrorMessage";
4
4
 
@@ -99,6 +99,11 @@ export interface DurableObjectTransaction {
99
99
  scheduledTime: number | Date,
100
100
  options?: globalThis.DurableObjectSetAlarmOptions,
101
101
  ): StorageEffect<void>;
102
+ /** Schedules the alarm after a delay measured by the Effect clock. */
103
+ setAlarmAfter(
104
+ delay: Duration.Input,
105
+ options?: globalThis.DurableObjectSetAlarmOptions,
106
+ ): StorageEffect<void>;
102
107
  deleteAlarm(options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
103
108
  }
104
109
 
@@ -132,6 +137,11 @@ export interface DurableObjectStorage {
132
137
  scheduledTime: number | Date,
133
138
  options?: globalThis.DurableObjectSetAlarmOptions,
134
139
  ): StorageEffect<void>;
140
+ /** Schedules the alarm after a delay measured by the Effect clock. */
141
+ setAlarmAfter(
142
+ delay: Duration.Input,
143
+ options?: globalThis.DurableObjectSetAlarmOptions,
144
+ ): StorageEffect<void>;
135
145
  deleteAlarm(options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
136
146
  /**
137
147
  * SQLite-backed Durable Object storage only.
@@ -174,6 +184,21 @@ const tryStoragePromise = <A>(operation: string, evaluate: () => Promise<A>): St
174
184
  catch: (cause) => storageError(operation, cause),
175
185
  });
176
186
 
187
+ const setAlarmAfter = Effect.fn("DurableObjectStorage.setAlarmAfter")(function* (
188
+ operation: string,
189
+ setAlarm: (
190
+ scheduledTime: number,
191
+ options?: globalThis.DurableObjectSetAlarmOptions,
192
+ ) => Promise<void>,
193
+ delay: Duration.Input,
194
+ options?: globalThis.DurableObjectSetAlarmOptions,
195
+ ) {
196
+ const now = yield* Clock.currentTimeMillis;
197
+ const delayMillis = Math.ceil(Duration.toMillis(delay));
198
+
199
+ yield* tryStoragePromise(operation, () => setAlarm(now + delayMillis, options));
200
+ });
201
+
177
202
  const fromSqlCursor = <T extends Record<string, SqlStorageValue>>(
178
203
  cursor: globalThis.SqlStorageCursor<T>,
179
204
  ): SqlCursor<T> => ({
@@ -293,6 +318,13 @@ const fromDurableObjectTransaction = (
293
318
  tryStoragePromise("transaction.getAlarm", () => txn.getAlarm(options)),
294
319
  setAlarm: (scheduledTime: number | Date, options?: globalThis.DurableObjectSetAlarmOptions) =>
295
320
  tryStoragePromise("transaction.setAlarm", () => txn.setAlarm(scheduledTime, options)),
321
+ setAlarmAfter: (delay: Duration.Input, options?: globalThis.DurableObjectSetAlarmOptions) =>
322
+ setAlarmAfter(
323
+ "transaction.setAlarm",
324
+ (scheduledTime, options) => txn.setAlarm(scheduledTime, options),
325
+ delay,
326
+ options,
327
+ ),
296
328
  deleteAlarm: (options?: globalThis.DurableObjectSetAlarmOptions) =>
297
329
  tryStoragePromise("transaction.deleteAlarm", () => txn.deleteAlarm(options)),
298
330
  }) as DurableObjectTransaction;
@@ -315,12 +347,24 @@ export const fromDurableObjectStorage = (
315
347
  tryStoragePromise("getAlarm", () => storage.getAlarm(options)),
316
348
  setAlarm: (scheduledTime: number | Date, options?: globalThis.DurableObjectSetAlarmOptions) =>
317
349
  tryStoragePromise("setAlarm", () => storage.setAlarm(scheduledTime, options)),
350
+ setAlarmAfter: (delay: Duration.Input, options?: globalThis.DurableObjectSetAlarmOptions) =>
351
+ setAlarmAfter(
352
+ "setAlarm",
353
+ (scheduledTime, options) => storage.setAlarm(scheduledTime, options),
354
+ delay,
355
+ options,
356
+ ),
318
357
  deleteAlarm: (options?: globalThis.DurableObjectSetAlarmOptions) =>
319
358
  tryStoragePromise("deleteAlarm", () => storage.deleteAlarm(options)),
320
359
  transactionSync: <A, E, R>(closure: () => Effect.Effect<A, E, R>) =>
321
360
  Effect.context<R>().pipe(
322
361
  Effect.flatMap((context) =>
323
- Effect.suspend(() => {
362
+ Effect.suspend((): Effect.Effect<A, E | StorageOperationError> => {
363
+ // Cloudflare rolls the transaction back when the callback throws, so a
364
+ // failed Exit is thrown to abort it. Keep a typed reference to that
365
+ // Exit rather than recovering its type from the untyped catch binding.
366
+ let aborted: Exit.Exit<A, E> | undefined;
367
+
324
368
  try {
325
369
  return Effect.succeed(
326
370
  storage.transactionSync(() => {
@@ -329,18 +373,14 @@ export const fromDurableObjectStorage = (
329
373
  if (Exit.isSuccess(exit)) {
330
374
  return exit.value;
331
375
  }
376
+ aborted = exit;
332
377
 
333
378
  throw exit;
334
379
  }),
335
380
  );
336
381
  } catch (cause) {
337
- if (Exit.isExit(cause) && Exit.isFailure(cause)) {
338
- // SAFETY: Exit.isFailure proves this cause carries the closure's typed E failure.
339
- return Effect.failCause(cause.cause) as Effect.Effect<
340
- A,
341
- E | StorageOperationError,
342
- R
343
- >;
382
+ if (aborted !== undefined && cause === aborted && Exit.isFailure(aborted)) {
383
+ return Effect.failCause(aborted.cause);
344
384
  }
345
385
 
346
386
  return Effect.fail(storageError("transactionSync", cause));
@@ -352,6 +392,10 @@ export const fromDurableObjectStorage = (
352
392
  Effect.context<R>().pipe(
353
393
  Effect.flatMap((context) =>
354
394
  Effect.callback<A, E | StorageOperationError>((resume) => {
395
+ // See `transactionSync`: the thrown Exit aborts Cloudflare's
396
+ // transaction, and holding it here keeps its error type.
397
+ let aborted: Exit.Exit<A, E> | undefined;
398
+
355
399
  void storage
356
400
  .transaction(async (txn) => {
357
401
  const exit = await Effect.runPromiseExitWith(context)(
@@ -361,17 +405,15 @@ export const fromDurableObjectStorage = (
361
405
  if (Exit.isSuccess(exit)) {
362
406
  return exit.value;
363
407
  }
408
+ aborted = exit;
364
409
 
365
410
  throw exit;
366
411
  })
367
412
  .then(
368
413
  (value) => resume(Effect.succeed(value)),
369
414
  (cause) => {
370
- if (Exit.isExit(cause) && Exit.isFailure(cause)) {
371
- // SAFETY: Exit.isFailure proves this cause carries the closure's typed E failure.
372
- resume(
373
- Effect.failCause(cause.cause) as Effect.Effect<A, E | StorageOperationError>,
374
- );
415
+ if (aborted !== undefined && cause === aborted && Exit.isFailure(aborted)) {
416
+ resume(Effect.failCause(aborted.cause));
375
417
  } else {
376
418
  resume(Effect.fail(storageError("transaction", cause)));
377
419
  }