import { a as BindingService, c as WorkerConfig, i as BindingNotFoundError, l as WorkerEnv, o as BindingValidationError, s as Binding_d_exports, t as Hyperdrive_d_exports, u as WorkerEnvironment } from "./Hyperdrive-C0vfrPeG.mjs"; import { Cause, Config, Context, Data, DateTime, Duration, Effect, Layer, Option, Redacted, Schema, Scope } from "effect"; import { Headers as Headers$1, HttpClient, HttpClientResponse, HttpServerRequest, HttpServerResponse } from "effect/unstable/http"; import { D1Client } from "@effect/sql-d1"; import { DurableObject, RpcStub, RpcTarget, WorkerEntrypoint, WorkflowEntrypoint, WorkflowEvent, WorkflowSleepDuration, WorkflowStep, WorkflowStepConfig, WorkflowStepContext, WorkflowStepEvent, WorkflowTimeoutDuration } from "cloudflare:workers"; import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"; import * as RpcServer from "effect/unstable/rpc/RpcServer"; import { SqliteClient } from "@effect/sql-sqlite-do"; import * as _$effect_unstable_sql_SqlClient0 from "effect/unstable/sql/SqlClient"; import * as _$effect_Types0 from "effect/Types"; import * as _$effect_Cause0 from "effect/Cause"; import * as _$effect_Layer0 from "effect/Layer"; import * as _$effect_Scope0 from "effect/Scope"; import * as Tracer from "effect/Tracer"; import * as _$effect_Config0 from "effect/Config"; //#region src/WorkersAi.d.ts declare namespace WorkersAi_d_exports { export { LayerOptions$18 as LayerOptions, Tag$17 as Tag, TagClass$16 as TagClass, WorkersAiAsyncBatchResponse, WorkersAiBinding, WorkersAiClient, WorkersAiDefinition, WorkersAiEmbeddingInput, WorkersAiEmbeddingResponse, WorkersAiModelsSearchObject, WorkersAiModelsSearchParams, WorkersAiOperationError, WorkersAiOptions, WorkersAiService, embeddingResponse, isWorkersAiBinding, layer$15 as layer, make$16 as make, makeClient$12 as makeClient }; } declare const WorkersAiOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "WorkersAiOperationError"; } & Readonly; /** Error raised when a Workers AI operation fails. */ declare class WorkersAiOperationError extends WorkersAiOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed Workers AI binding definition. */ interface WorkersAiDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type WorkersAiBinding = CloudflareAi; type WorkersAiOptions = AiOptions; type WorkersAiModelsSearchParams = AiModelsSearchParams; type WorkersAiModelsSearchObject = AiModelsSearchObject; type WorkersAiAsyncBatchResponse = AiAsyncBatchResponse; type WorkersAiEmbeddingInput = AiTextEmbeddingsInput | Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input | Record; interface WorkersAiEmbeddingResponse { readonly data: ReadonlyArray>; readonly shape: ReadonlyArray; } interface WorkersAiClient { readonly aiGatewayLogId: Effect.Effect; readonly run: { (model: Name, input: { readonly requests: ReadonlyArray; }, options: WorkersAiOptions & { readonly queueRequest: true; }): Effect.Effect; (model: Name, input: ModelList[Name]["inputs"], options: WorkersAiOptions & { readonly returnRawResponse: true; }): Effect.Effect; (model: Name, input: ModelList[Name]["inputs"], options: WorkersAiOptions & { readonly websocket: true; }): Effect.Effect; (model: Name, input: ModelList[Name]["inputs"] & { readonly stream: true; }, options?: WorkersAiOptions): Effect.Effect; (model: Name, input: ModelList[Name]["inputs"], options?: WorkersAiOptions): Effect.Effect; , Output = Record>(model: string, input: Input, options?: WorkersAiOptions): Effect.Effect; }; readonly runEmbedding: (model: string, input: Input, options?: WorkersAiOptions) => Effect.Effect; readonly models: (params?: WorkersAiModelsSearchParams) => Effect.Effect, WorkersAiOperationError>; readonly gateway: (gatewayId: string) => Effect.Effect; readonly unsafeRaw: Effect.Effect>; readonly definition: WorkersAiDefinition; } declare const WorkersAiServiceTypeId: unique symbol; /** Nominal service marker for Workers AI services created with {@link make}. */ interface WorkersAiService { readonly [WorkersAiServiceTypeId]: { readonly id: Id; }; } type LayerOptions$18 = { readonly binding: string; }; interface TagClass$16 extends Context.ServiceClass> { readonly id: Id; readonly layer: (options: LayerOptions$18) => Layer.Layer; } declare const isWorkersAiBinding: (value: unknown) => value is WorkersAiBinding; declare const embeddingResponse: (value: { readonly data?: ReadonlyArray>; readonly shape?: ReadonlyArray; }) => WorkersAiEmbeddingResponse; declare const makeClient$12: (definition: WorkersAiDefinition) => (ai: WorkersAiBinding) => WorkersAiClient; declare const layer$15: (tag: Context.Service>, definition: WorkersAiDefinition) => Layer.Layer; declare const make$16: (id: Id) => TagClass$16, Id, AiModels>; declare const Tag$17: () => (id: Id) => TagClass$16; declare namespace AiGateway_d_exports { export { AiGatewayBinding, AiGatewayClient, AiGatewayDefinition, AiGatewayFetchOptions, AiGatewayHeaders, AiGatewayLog, AiGatewayOperationError, AiGatewayPatchLog, AiGatewayProvider, AiGatewayRunOptions, AiGatewayService, AiGatewayUniversalRequest, LayerOptions$17 as LayerOptions, Tag$16 as Tag, TagClass$15 as TagClass, isAiGatewayBinding, layer$14 as layer, make$15 as make, makeClient$11 as makeClient, makeClientFromAi, makeHttpClient }; } declare const AiGatewayOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "AiGatewayOperationError"; } & Readonly; /** Error raised when an AI Gateway operation fails. */ declare class AiGatewayOperationError extends AiGatewayOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed AI Gateway client definition. */ interface AiGatewayDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; /** Gateway id/name passed to `env.AI.gateway(id)`. */ readonly gatewayId: string; /** Optional account id used by the HTTP-only helper. */ readonly accountId?: string; } type AiGatewayBinding = CloudflareAiGateway; type AiGatewayRunData = Parameters[0]; type AiGatewayPatchLog = Parameters[1]; type AiGatewayLog = Awaited>; type AiGatewayProvider = NonNullable[0]>; type AiGatewayUniversalRequest = Exclude>; type AiGatewayHeaders = NonNullable; type AiGatewayRunOptions = Parameters[1]; interface AiGatewayFetchOptions { readonly provider?: AiGatewayProvider; readonly path?: string; readonly init?: RequestInit; } interface AiGatewayClient { readonly run: (data: AiGatewayUniversalRequest | ReadonlyArray, options?: AiGatewayRunOptions) => Effect.Effect; readonly getUrl: (provider?: AiGatewayProvider) => Effect.Effect; readonly fetch: (options: AiGatewayFetchOptions) => Effect.Effect; readonly patchLog: (logId: string, data: AiGatewayPatchLog) => Effect.Effect; readonly getLog: (logId: string) => Effect.Effect; readonly unsafeRaw: Effect.Effect; readonly definition: AiGatewayDefinition; } declare const AiGatewayServiceTypeId: unique symbol; /** Nominal service marker for AI Gateway services created with {@link make}. */ interface AiGatewayService { readonly [AiGatewayServiceTypeId]: { readonly id: Id; }; } type LayerOptions$17 = { readonly binding: string; readonly gatewayId: string; readonly accountId?: string; }; interface TagClass$15 extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions$17) => Layer.Layer; } declare const isAiGatewayBinding: (value: unknown) => value is WorkersAiBinding; declare const makeClient$11: (definition: AiGatewayDefinition, gateway: AiGatewayBinding) => { definition: AiGatewayDefinition; run: (data: _$_cloudflare_workers_types0.AIGatewayUniversalRequest | readonly _$_cloudflare_workers_types0.AIGatewayUniversalRequest[], options: { gateway?: _$_cloudflare_workers_types0.UniversalGatewayOptions; extraHeaders?: object; signal?: _$_cloudflare_workers_types0.AbortSignal; } | undefined) => Effect.Effect<_$_cloudflare_workers_types0.Response, AiGatewayOperationError, never>; getUrl: (provider: string | undefined) => Effect.Effect; fetch: (options: AiGatewayFetchOptions) => Effect.Effect; patchLog: (logId: string, data: _$_cloudflare_workers_types0.AiGatewayPatchLog) => Effect.Effect; getLog: (logId: string) => Effect.Effect<_$_cloudflare_workers_types0.AiGatewayLog, AiGatewayOperationError, never>; unsafeRaw: Effect.Effect; }; declare const makeClientFromAi: (definition: AiGatewayDefinition, ai: WorkersAiBinding) => AiGatewayClient; declare const makeHttpClient: (definition: Omit & { readonly accountId: string; readonly binding?: string; }, request?: typeof fetch) => AiGatewayClient; declare const layer$14: (tag: Context.Service, definition: AiGatewayDefinition) => Layer.Layer; declare const make$15: (id: Id) => TagClass$15, Id>; declare const Tag$16: () => (id: Id) => TagClass$15; declare namespace AnalyticsEngine_d_exports { export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteBatchOptions, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, LayerOptions$16 as LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag$15 as Tag, TagClass$14 as TagClass, isAnalyticsEngineDataset, layer$13 as layer, make$14 as make, makeClient$10 as makeClient, makeQuery, makeQueryClient, queryConfig, queryFetchLayer, queryFetchLayerConfig, queryLayer, queryLayerConfig, writeLimits }; } declare const writeLimits: { readonly maxBlobs: 20; readonly maxDoubles: 20; readonly maxIndexes: 1; readonly maxBlobBytes: number; readonly maxIndexBytes: 96; readonly maxDataPointsPerInvocation: 250; }; declare const queryColumnSchema: Schema.Struct<{ readonly name: Schema.String; readonly type: Schema.String; }>; declare const queryRowSchema: Schema.$Record; declare const AnalyticsEngineFieldValueSchema: Schema.NullOr]>>; declare const AnalyticsEngineDataPointSchema: Schema.Struct<{ readonly indexes: Schema.optional]>>>>; readonly doubles: Schema.optional>; readonly blobs: Schema.optional]>>>>; }>; declare const AnalyticsEngineOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "AnalyticsEngineOperationError"; } & Readonly; /** Error raised when an Analytics Engine operation fails. */ declare class AnalyticsEngineOperationError extends AnalyticsEngineOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} interface AnalyticsEngineWriteViolation { readonly path: string; readonly message: string; readonly limit?: number; readonly actual?: number; } declare const AnalyticsEngineWriteValidationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "AnalyticsEngineWriteValidationError"; } & Readonly; /** Error raised when an Analytics Engine write input violates Cloudflare limits. */ declare class AnalyticsEngineWriteValidationError extends AnalyticsEngineWriteValidationError_base<{ readonly binding: string; readonly operation: string; readonly violations: ReadonlyArray; readonly cause?: unknown; }> {} declare const AnalyticsEngineQueryError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "AnalyticsEngineQueryError"; } & Readonly; /** Error raised when an Analytics Engine SQL API query fails. */ declare class AnalyticsEngineQueryError extends AnalyticsEngineQueryError_base<{ readonly operation: string; readonly accountId: string; readonly message: string; readonly status?: number; readonly body?: string; readonly cause?: unknown; }> {} /** Typed Analytics Engine dataset binding definition. */ interface AnalyticsEngineDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type AnalyticsEngineBinding = CloudflareAnalyticsEngineDataset; type AnalyticsEngineDataPoint = CloudflareAnalyticsEngineDataPoint; type AnalyticsEngineFieldValue = ArrayBuffer | string | null; type AnalyticsEngineWriteError = AnalyticsEngineOperationError | AnalyticsEngineWriteValidationError; type AnalyticsEngineInvalidWritePolicy = "error" | "drop"; type AnalyticsEngineQueryColumn = Schema.Schema.Type; type AnalyticsEngineQueryRow = Schema.Schema.Type; interface AnalyticsEngineWriteOptions { /** * Controls invalid write behavior. The default is `"error"`, which fails with * `AnalyticsEngineWriteValidationError`. `"drop"` skips invalid points. */ readonly onInvalid?: AnalyticsEngineInvalidWritePolicy; } interface AnalyticsEngineWriteBatchOptions extends AnalyticsEngineWriteOptions { /** * Maximum points per native batch call. Values are clamped to Cloudflare's * per-invocation limit. */ readonly batchSize?: number; } type AnalyticsEngineWritePolicy = AnalyticsEngineWriteBatchOptions; interface AnalyticsEngineQueryResult { readonly meta: ReadonlyArray; readonly data: ReadonlyArray; readonly rows: number; } interface AnalyticsEngineQueryDefinition { /** Cloudflare account id that owns the Analytics Engine datasets. */ readonly accountId: string; /** API token with Account Analytics Read permission. */ readonly apiToken: Redacted.Redacted; /** Base Cloudflare API URL. Defaults to `https://api.cloudflare.com/client/v4`. */ readonly apiBaseUrl?: string | URL; } interface AnalyticsEngineQueryOptions { /** Additional request headers. Authorization is always derived from `apiToken`. */ readonly headers?: Headers$1.Input; } interface AnalyticsEngineClient { readonly writeDataPoint: (dataPoint?: AnalyticsEngineDataPoint, options?: AnalyticsEngineWriteOptions) => Effect.Effect; readonly write: (dataPoint?: AnalyticsEngineDataPoint, options?: AnalyticsEngineWriteOptions) => Effect.Effect; readonly writeDataPoints: (dataPoints: ReadonlyArray, options?: AnalyticsEngineWriteBatchOptions) => Effect.Effect; readonly writeBatch: (dataPoints: ReadonlyArray, options?: AnalyticsEngineWriteBatchOptions) => Effect.Effect; readonly unsafeRaw: Effect.Effect; readonly definition: AnalyticsEngineDefinition; } interface AnalyticsEngineQueryClient { readonly query: (sql: string, options?: AnalyticsEngineQueryOptions) => Effect.Effect; readonly queryResult: (row: Schema.Codec, sql: string, options?: AnalyticsEngineQueryOptions) => Effect.Effect, AnalyticsEngineQueryError | Schema.SchemaError>; readonly queryRows: (row: Schema.Codec, sql: string, options?: AnalyticsEngineQueryOptions) => Effect.Effect, AnalyticsEngineQueryError | Schema.SchemaError>; readonly queryOne: (row: Schema.Codec, sql: string, options?: AnalyticsEngineQueryOptions) => Effect.Effect, AnalyticsEngineQueryError | Schema.SchemaError>; readonly queryText: (sql: string, options?: AnalyticsEngineQueryOptions) => Effect.Effect; readonly raw: (sql: string, options?: AnalyticsEngineQueryOptions) => Effect.Effect; readonly definition: AnalyticsEngineQueryDefinition; } declare const AnalyticsEngineServiceTypeId: unique symbol; declare const AnalyticsEngineQueryServiceTypeId: unique symbol; /** Nominal service marker for Analytics Engine services created with {@link make}. */ interface AnalyticsEngineService { readonly [AnalyticsEngineServiceTypeId]: { readonly id: Id; }; } /** Nominal service marker for Analytics Engine query services created with {@link makeQuery}. */ interface AnalyticsEngineQueryService { readonly [AnalyticsEngineQueryServiceTypeId]: { readonly id: Id; }; } type LayerOptions$16 = { readonly binding: string; readonly write?: AnalyticsEngineWritePolicy; }; type QueryConfigOptions = { readonly accountId?: Config.Config; readonly apiToken?: Config.Config>; readonly apiBaseUrl?: Config.Config; }; interface TagClass$14 extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions$16) => Layer.Layer; } interface QueryTagClass extends Context.ServiceClass { readonly id: Id; readonly layer: (definition: AnalyticsEngineQueryDefinition) => Layer.Layer; readonly fetchLayer: (definition: AnalyticsEngineQueryDefinition) => Layer.Layer; readonly layerConfig: (config?: Config.Config) => Layer.Layer; readonly fetchLayerConfig: (config?: Config.Config) => Layer.Layer; } declare const makeQueryClient: (definition: AnalyticsEngineQueryDefinition) => Effect.Effect; declare const isAnalyticsEngineDataset: (value: unknown) => value is AnalyticsEngineBinding; declare const makeClient$10: (definition: AnalyticsEngineDefinition, defaults?: AnalyticsEngineWritePolicy) => (dataset: AnalyticsEngineBinding) => AnalyticsEngineClient; declare const queryConfig: (options?: QueryConfigOptions) => Config.Config<{ accountId: string; apiToken: Redacted.Redacted; apiBaseUrl: string; }>; declare const queryLayer: (tag: Context.Service, definition: AnalyticsEngineQueryDefinition) => Layer.Layer; declare const queryFetchLayer: (tag: Context.Service, definition: AnalyticsEngineQueryDefinition) => Layer.Layer; declare const queryLayerConfig: (tag: Context.Service, config?: Config.Config) => Layer.Layer; declare const queryFetchLayerConfig: (tag: Context.Service, config?: Config.Config) => Layer.Layer; declare const layer$13: (tag: Context.Service, definition: LayerOptions$16) => Layer.Layer; declare const make$14: (id: Id) => TagClass$14, Id>; declare const makeQuery: (id: Id) => QueryTagClass, Id>; declare const Tag$15: () => (id: Id) => TagClass$14; declare const QueryTag: () => (id: Id) => QueryTagClass; declare namespace BrowserRendering_d_exports { export { BrowserRenderingBinding, BrowserRenderingBrowserClient, BrowserRenderingBrowserLike, BrowserRenderingClient, BrowserRenderingConnect, BrowserRenderingDefinition, BrowserRenderingLaunch, BrowserRenderingOperationError, BrowserRenderingPageClient, BrowserRenderingPageLike, BrowserRenderingService, LayerOptions$15 as LayerOptions, Tag$14 as Tag, TagClass$13 as TagClass, isBrowserRenderingBinding, layer$12 as layer, make$13 as make, makeClient$9 as makeClient }; } declare const BrowserRenderingOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "BrowserRenderingOperationError"; } & Readonly; /** Error raised when a Browser Rendering operation fails. */ declare class BrowserRenderingOperationError extends BrowserRenderingOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed Browser Rendering binding definition. */ interface BrowserRenderingDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type BrowserRenderingBinding = object; type BrowserRenderingLaunch = (binding: RawBinding, options?: LaunchOptions) => Promise; type BrowserRenderingConnect = (binding: RawBinding, options?: ConnectOptions) => Promise; interface BrowserRenderingBrowserLike { readonly newPage: () => Promise; readonly close?: () => Promise; readonly disconnect?: () => void; readonly version?: () => Promise; } interface BrowserRenderingPageLike { readonly goto?: (url: string, options?: unknown) => Promise; readonly setContent?: (html: string, options?: unknown) => Promise; readonly content?: () => Promise; readonly screenshot?: (options?: unknown) => Promise; readonly pdf?: (options?: unknown) => Promise; readonly evaluate?: (pageFunction: unknown, ...args: ReadonlyArray) => Promise; readonly close?: (options?: unknown) => Promise; } interface BrowserRenderingPageClient { readonly raw: Page; readonly goto: (url: string, options?: Parameters>[1]) => Effect.Effect>>, BrowserRenderingOperationError>; readonly setContent: (html: string, options?: Parameters>[1]) => Effect.Effect; readonly content: Effect.Effect; readonly screenshot: (options?: Parameters>[0]) => Effect.Effect; readonly pdf: (options?: Parameters>[0]) => Effect.Effect; readonly evaluate: (pageFunction: Parameters>[0], ...args: ReadonlyArray) => Effect.Effect; readonly close: (options?: Parameters>[0]) => Effect.Effect; } interface BrowserRenderingBrowserClient, Page extends BrowserRenderingPageLike> { readonly raw: Browser; readonly newPage: Effect.Effect, BrowserRenderingOperationError>; readonly version: Effect.Effect; readonly close: Effect.Effect; readonly disconnect: Effect.Effect; } interface BrowserRenderingClient { readonly launchWith: , Page extends BrowserRenderingPageLike = BrowserRenderingPageLike, LaunchOptions = unknown>(launch: BrowserRenderingLaunch, options?: LaunchOptions) => Effect.Effect, BrowserRenderingOperationError>; readonly connectWith: , Page extends BrowserRenderingPageLike = BrowserRenderingPageLike, ConnectOptions = unknown>(connect: BrowserRenderingConnect, options?: ConnectOptions) => Effect.Effect, BrowserRenderingOperationError>; readonly unsafeRaw: Effect.Effect; readonly definition: BrowserRenderingDefinition; } declare const BrowserRenderingServiceTypeId: unique symbol; /** Nominal service marker for Browser Rendering services created with {@link make}. */ interface BrowserRenderingService { readonly [BrowserRenderingServiceTypeId]: { readonly id: Id; }; } type LayerOptions$15 = { readonly binding: string; }; interface TagClass$13 extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions$15) => Layer.Layer; } declare const isBrowserRenderingBinding: (value: unknown) => value is BrowserRenderingBinding; declare const makeClient$9: (definition: BrowserRenderingDefinition) => (binding: RawBinding) => BrowserRenderingClient; declare const layer$12: (tag: Context.Service, definition: BrowserRenderingDefinition) => Layer.Layer; declare const make$13: (id: Id) => TagClass$13, Id>; declare const Tag$14: () => (id: Id) => TagClass$13; declare namespace DurableObjectStorage_d_exports { export { DurableObjectStorage, DurableObjectTransaction, SchemaBackedSyncKvStorage, SqlCursor, SqlStorage, SqlStorageValue, StorageOperationError, SyncKvDefinition, SyncKvStorage, fromDurableObjectStorage }; } /** Supported primitive value types for Durable Object SQL APIs. */ type SqlStorageValue = globalThis.SqlStorageValue; declare const StorageOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "StorageOperationError"; } & Readonly; /** Error type used when a storage operation throws or rejects. */ declare class StorageOperationError extends StorageOperationError_base<{ readonly operation: string; readonly cause: unknown; }> {} type StorageEffect = Effect.Effect; /** * Effect wrapper for Cloudflare SQL cursor operations. */ interface SqlCursor> { next(): StorageEffect<{ done?: false; value: T; } | { done: true; value?: never; }>; toArray(): StorageEffect>; one(): StorageEffect; raw>(): StorageEffect>; readonly columnNames: Array; readonly rowsRead: StorageEffect; readonly rowsWritten: StorageEffect; } /** * Effect wrapper for Durable Object SQLite APIs. */ interface SqlStorage { /** Executes a SQL statement and returns a typed cursor. */ exec>(query: string, ...bindings: Array): StorageEffect>; readonly databaseSize: number; } /** * Schema pair used by `SyncKvStorage.schema(...)`. */ interface SyncKvDefinition { readonly key: Schema.Codec; readonly value: Schema.Codec; } /** * Sync KV wrapper that transparently encodes keys/values through Effect Schema. */ interface SchemaBackedSyncKvStorage { get(key: Key): Effect.Effect, unknown>; put(key: Key, value: Value): Effect.Effect; delete(key: Key): Effect.Effect; list(options?: globalThis.SyncKvListOptions): Effect.Effect, unknown>; } /** * Effect wrapper for synchronous KV attached to Durable Object SQLite storage. */ interface SyncKvStorage { get(key: string): StorageEffect; put(key: string, value: T): StorageEffect; delete(key: string): StorageEffect; list(options?: globalThis.SyncKvListOptions): StorageEffect>; schema(definition: SyncKvDefinition): SchemaBackedSyncKvStorage; } /** * Effect wrapper around Cloudflare transaction callbacks. */ interface DurableObjectTransaction { get(key: string, options?: globalThis.DurableObjectGetOptions): StorageEffect; get(keys: Array, options?: globalThis.DurableObjectGetOptions): StorageEffect>; list(options?: globalThis.DurableObjectListOptions): StorageEffect>; put(key: string, value: T, options?: globalThis.DurableObjectPutOptions): StorageEffect; put(entries: Record, options?: globalThis.DurableObjectPutOptions): StorageEffect; delete(key: string, options?: globalThis.DurableObjectPutOptions): StorageEffect; delete(keys: Array, options?: globalThis.DurableObjectPutOptions): StorageEffect; rollback(): StorageEffect; getAlarm(options?: globalThis.DurableObjectGetAlarmOptions): StorageEffect; setAlarm(scheduledTime: number | Date, options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect; deleteAlarm(options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect; } /** * Effect wrapper around Cloudflare Durable Object storage. * * @example * ```ts * const program = Effect.gen(function* () { * const state = yield* DurableObjectState; * yield* state.storage.put("counter", 1); * const value = yield* state.storage.get("counter"); * return value; * }); * ``` */ interface DurableObjectStorage { get(key: string, options?: globalThis.DurableObjectGetOptions): StorageEffect; put(key: string, value: T, options?: globalThis.DurableObjectPutOptions): StorageEffect; delete(key: string, options?: globalThis.DurableObjectPutOptions): StorageEffect; /** * Deletes all stored data. On compatibility dates before 2026-02-24, Cloudflare * documents that active alarms must be deleted separately with `deleteAlarm()`. */ deleteAll(options?: globalThis.DurableObjectPutOptions): StorageEffect; getAlarm(options?: globalThis.DurableObjectGetAlarmOptions): StorageEffect; setAlarm(scheduledTime: number | Date, options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect; deleteAlarm(options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect; /** * SQLite-backed Durable Object storage only. * * The callback Effect must complete synchronously. If it requires asynchronous * work, use `transaction` instead so Cloudflare can run the async transaction * callback under the platform's transaction contract. */ transactionSync(closure: () => Effect.Effect): Effect.Effect; /** * Runs an async transaction and exposes a typed transaction wrapper. */ transaction(closure: (txn: DurableObjectTransaction) => Effect.Effect): Effect.Effect; /** Flushes pending writes to disk. */ sync(): StorageEffect; /** SQLite-backed Durable Object storage point-in-time recovery API only. */ getCurrentBookmark(): StorageEffect; /** SQLite-backed Durable Object storage point-in-time recovery API only. */ onNextSessionRestoreBookmark(bookmark: string): StorageEffect; readonly sql: SqlStorage; readonly kv: SyncKvStorage; } /** * Wraps native Cloudflare storage APIs as Effect-returning helpers. */ declare const fromDurableObjectStorage: (storage: globalThis.DurableObjectStorage) => DurableObjectStorage; declare namespace DurableObjectWebSocket_d_exports { export { AcceptUpgradeOptions, AcceptedUpgrade, AttachmentInvalidPolicy, AttachmentRehydrateOptions, DurableWebSocket, DurableWebSocketAttachment, DurableWebSocketAttachmentError, DurableWebSocketCloseError, DurableWebSocketHandlers, DurableWebSocketSendData, DurableWebSocketSendError, RehydratedDurableWebSocket, acceptUpgrade, attachment, fromWebSocket, handlers }; } /** Data supported by Cloudflare websocket `send`. */ type DurableWebSocketSendData = string | ArrayBuffer | ArrayBufferView; declare const DurableWebSocketSendError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "DurableWebSocketSendError"; } & Readonly; /** Error raised when sending on a Durable Object websocket fails. */ declare class DurableWebSocketSendError extends DurableWebSocketSendError_base<{ readonly cause: unknown; }> {} declare const DurableWebSocketCloseError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "DurableWebSocketCloseError"; } & Readonly; /** Error raised when closing a Durable Object websocket fails. */ declare class DurableWebSocketCloseError extends DurableWebSocketCloseError_base<{ readonly cause: unknown; }> {} declare const DurableWebSocketAttachmentError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "DurableWebSocketAttachmentError"; } & Readonly; /** Error raised when serializing or deserializing a websocket attachment fails. */ declare class DurableWebSocketAttachmentError extends DurableWebSocketAttachmentError_base<{ readonly operation: "serialize" | "deserialize"; readonly cause: unknown; }> {} /** Effect-native wrapper around a hibernatable Durable Object websocket. */ interface DurableWebSocket { /** Underlying Cloudflare websocket. */ readonly raw: WebSocket; /** Sends a message through the socket. */ send(data: DurableWebSocketSendData): Effect.Effect; /** Closes the socket. */ close(code?: number, reason?: string): Effect.Effect; /** Serializes hibernation attachment metadata onto the socket. */ serializeAttachment(value: A): Effect.Effect; /** Deserializes hibernation attachment metadata from the socket. */ readonly deserializeAttachment: Effect.Effect; } /** Wraps a native Cloudflare websocket in the Effect-native Durable Object API. */ declare const fromWebSocket: (raw: WebSocket) => DurableWebSocket; /** * Options for accepting an incoming websocket request in a Durable Object. */ interface AcceptUpgradeOptions { /** Optional websocket tags for Durable Object hibernation filtering. */ readonly tags?: ReadonlyArray | undefined; /** Optional attachment serialized onto the server socket. */ readonly attachment?: Attachment | undefined; } /** * Result of a websocket upgrade accepted by {@link acceptUpgrade}. */ interface AcceptedUpgrade { readonly client: WebSocket; readonly server: DurableWebSocket; readonly response: Response; } /** * Accepts a websocket upgrade and registers the server socket on `DurableObjectState`. * * @example * ```ts * const response = yield* DurableObjectWebSocket.acceptUpgrade({ * tags: ["room:general"], * }); * * return response.response; * ``` */ declare const acceptUpgrade: (options?: AcceptUpgradeOptions) => Effect.Effect, never, DurableObjectState>; type AttachmentInvalidPolicy = "ignore" | "ignore-and-close" | "fail"; interface AttachmentRehydrateOptions { /** Optional Durable Object websocket tag filter. */ readonly tag?: string | undefined; /** Invalid attachment behavior. Defaults to skipping invalid sockets. */ readonly onInvalid?: AttachmentInvalidPolicy | undefined; } interface RehydratedDurableWebSocket { readonly socket: DurableWebSocket; readonly attachment: Attachment; } interface DurableWebSocketAttachment { serialize(socket: DurableWebSocket, value: Attachment): Effect.Effect; deserialize(socket: DurableWebSocket): Effect.Effect, DurableWebSocketAttachmentError>; rehydrate(options?: AttachmentRehydrateOptions): Effect.Effect>, DurableWebSocketAttachmentError, DurableObjectState>; readonly schema: Schema.Codec; } /** Creates typed attachment helpers for accepted and rehydrated sockets. */ declare const attachment: >(schema: AttachmentSchema) => DurableWebSocketAttachment, Schema.Codec.Encoded>; interface DurableWebSocketHandlers { readonly message?: (socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect; readonly close?: (socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect; readonly error?: (socket: DurableWebSocket, error: unknown) => Effect.Effect; } /** Maps compact websocket lifecycle handler names to `DurableObject.make` options. */ declare const handlers: (options: DurableWebSocketHandlers) => { webSocketMessage: ((socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect) | undefined; webSocketClose: ((socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect) | undefined; webSocketError: ((socket: DurableWebSocket, error: unknown) => Effect.Effect) | undefined; }; declare namespace DurableObjectState_d_exports { export { DurableObjectState, DurableObjectStateService, fromDurableObjectState }; } /** * Effect-friendly wrapper around Cloudflare `DurableObjectState`. */ interface DurableObjectStateService { /** Underlying Cloudflare state instance. */ readonly raw: globalThis.DurableObjectState; /** Durable Object id for the current instance. */ readonly id: globalThis.DurableObjectId; /** Wrapped storage API. */ readonly storage: DurableObjectStorage; /** Registers background work with Cloudflare's lifecycle. */ waitUntil(promise: Promise): Effect.Effect; /** * Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate. * * Cloudflare resets a Durable Object if the callback throws/rejects, or if the * callback exceeds the platform timeout (currently documented as 30 seconds). * This safe default resolves the callback with the Effect `Exit` for typed * Effect failures and resumes that `Exit` afterward, so typed failures remain * ordinary Effect failures instead of resetting the Durable Object. Defects * and interruptions still reject the callback. */ blockConcurrencyWhile(effect: Effect.Effect): Effect.Effect; /** * Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate and lets * Effect failures reject the callback. * * Use this only when Cloudflare's reset-on-throw behavior is intentional. The * platform also resets the Durable Object if the callback exceeds the * documented timeout (currently 30 seconds). */ blockConcurrencyWhileOrReset(effect: Effect.Effect): Effect.Effect; /** Accepts a websocket connection for hibernation-capable Durable Objects. */ acceptWebSocket(ws: DurableWebSocket, tags?: Array): Effect.Effect; /** Lists active sockets, optionally filtered by tag. */ getWebSockets(tag?: string): Effect.Effect>; /** Configures automatic request/response handling for sockets. */ setWebSocketAutoResponse(pair?: WebSocketRequestResponsePair): Effect.Effect; /** Gets the configured websocket auto-response pair. */ getWebSocketAutoResponse: Effect.Effect; /** Timestamp of the last automatic websocket response for a socket. */ getWebSocketAutoResponseTimestamp(ws: DurableWebSocket): Effect.Effect; /** Sets the timeout for hibernatable websocket events. */ setHibernatableWebSocketEventTimeout(timeoutMs?: number): Effect.Effect; /** Gets the timeout for hibernatable websocket events. */ getHibernatableWebSocketEventTimeout: Effect.Effect; /** Reads tags attached to a websocket. */ getTags(ws: DurableWebSocket): Effect.Effect>; /** * Forcibly resets the Durable Object. Cloudflare logs an uncaught Error using * the optional reason, and the method is not available in `wrangler dev` local * development according to the Durable Object State docs. */ abort(reason?: string): Effect.Effect; } declare const DurableObjectState_base: Context.ServiceClass; /** * Context tag for accessing the current Durable Object state service. */ declare class DurableObjectState extends DurableObjectState_base {} /** * Wraps a native Cloudflare `DurableObjectState` as a {@link DurableObjectStateService}. */ declare const fromDurableObjectState: (state: globalThis.DurableObjectState) => DurableObjectStateService; declare namespace CloudflareOtlp_d_exports { export { DurableObjectLayerOptions, LayerOptions$14 as LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, durableObjectLayer, layer$11 as layer, layerJson, layerProtobuf, workerLayer }; } /** Telemetry signal groups supported by the Cloudflare OTLP layers. */ type Signal = "logs" | "traces" | "metrics"; /** OTLP payload serialization used by the Effect OTLP exporters. */ type Serialization = "json" | "protobuf"; /** Resource metadata shared by Worker and Durable Object OTLP layers. */ interface ResourceOptions { /** Explicit service name. OTEL resource environment variables take precedence. */ readonly serviceName?: string; /** Explicit service version. OTEL resource environment variables take precedence. */ readonly serviceVersion?: string; /** Additional resource attributes attached to exported telemetry. */ readonly attributes?: Record; } /** Options shared by all Cloudflare OTLP telemetry layers. */ interface LayerOptions$14 { /** * Telemetry signals to export. Defaults to logs, traces, and metrics. * * Each selected signal is still controlled by standard OTEL exporter config, * such as `OTEL_TRACES_EXPORTER=otlp`. */ readonly signals?: ReadonlyArray; /** OTLP payload serialization. Defaults to protobuf. */ readonly serialization?: Serialization; /** Resource metadata forwarded to Effect's OTLP resource resolver. */ readonly resource?: ResourceOptions; /** * Explicit headers for every selected signal. * * When omitted, Effect reads `OTEL_EXPORTER_OTLP_HEADERS` and the * signal-specific `OTEL_EXPORTER_OTLP_*_HEADERS` variables. */ readonly headers?: Headers$1.Input; /** Exclude log records emitted for spans when exporting logs. */ readonly loggerExcludeLogSpans?: boolean; /** Merge the OTLP logger with existing loggers instead of replacing them. */ readonly loggerMergeWithExisting?: boolean; /** Custom trace context lookup used by the Effect OTLP tracer. */ readonly tracerContext?: (primitive: Tracer.EffectPrimitive, span: Tracer.AnySpan) => X; } /** Resource metadata specific to Cloudflare Workers. */ interface WorkerLayerOptions extends LayerOptions$14 { /** Cloudflare Worker name to attach as `cloudflare.worker.name`. */ readonly workerName?: string; } /** Resource metadata specific to Cloudflare Durable Objects. */ interface DurableObjectLayerOptions extends LayerOptions$14 { /** Durable Object class name to attach as `cloudflare.durable_object.class`. */ readonly className?: string; /** * Include the Durable Object id as `cloudflare.durable_object.id`. * * This is disabled by default because object ids can be high-cardinality. */ readonly includeObjectId?: boolean; } /** * Base OTLP telemetry layer for Cloudflare-compatible runtimes. * * Standard OpenTelemetry environment variables are resolved by Effect's OTLP * layers. In Cloudflare Workers and Durable Objects, the current `env` object is * installed as the primary `ConfigProvider`; outside Cloudflare, the ambient * Effect `ConfigProvider` remains the fallback. */ declare const layer$11: (options?: LayerOptions$14) => Layer.Layer; /** Base OTLP telemetry layer forced to JSON serialization. */ declare const layerJson: (options?: Omit) => Layer.Layer; /** Base OTLP telemetry layer forced to protobuf serialization. */ declare const layerProtobuf: (options?: Omit) => Layer.Layer; /** * OTLP layer with Cloudflare Worker resource attributes. * * Provide this layer at runtime scope for long-lived metrics aggregation, or at * handler scope when traces/logs should flush as the Cloudflare event finishes. */ declare const workerLayer: (options?: WorkerLayerOptions) => Layer.Layer; /** * OTLP layer with Cloudflare Durable Object resource attributes. * * The layer reads {@link DurableObjectState} so it can optionally include the * Durable Object id. Prefer leaving `includeObjectId` disabled unless the * backend can tolerate high-cardinality resource attributes. */ declare const durableObjectLayer: (options?: DurableObjectLayerOptions) => Layer.Layer; declare namespace D1_d_exports { export { D1Definition, D1Service, D1SqlLayerOptions, Service$1 as Service, make$12 as make }; } /** Typed D1 binding definition. */ interface D1Definition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } /** Options forwarded to `@effect/sql-d1` when building a SQL client layer. */ type D1SqlLayerOptions = Omit; declare const D1ServiceTypeId: unique symbol; /** Nominal service marker for D1 services created with {@link make}. */ interface D1Service { readonly [D1ServiceTypeId]: { readonly id: Id; }; } /** * Creates a typed D1 service tag plus Effect helpers. */ declare const make$12: (id: Id, definition: D1Definition) => BindingService, Id, D1Database> & { "effect-cf/D1": "effect-cf/D1"; definition: D1Definition; sqlLayer: (options?: D1SqlLayerOptions) => Layer.Layer; }; /** * Builds a D1 service around a Cloudflare D1 database binding. * * The returned service exposes the raw `D1Database` binding and `sqlLayer(...)` * for providing `effect/unstable/sql` via `@effect/sql-d1`. * * @example * ```ts * class TodoDatabase extends D1.Service()("TodoDatabase", { * binding: "TODO_DB", * }) {} * * const SqlLive = TodoDatabase.sqlLayer(); * ``` */ declare const Service$1: () => (id: Id, definition: D1Definition) => BindingService & { "effect-cf/D1": "effect-cf/D1"; definition: D1Definition; sqlLayer: (options?: D1SqlLayerOptions) => Layer.Layer, Self>>; }; declare namespace Rpc_d_exports { export { DisposableValue, MethodArgs, MethodKey, MethodReturn, Provider, Result$1 as Result, RpcStub, RpcTarget, Serializable, Stub, Stubable, Stubify, dispose, isDisposable, resolve, scoped }; } type Stubable = Rpc.Stubable; type Stub = Rpc.Stub; type Provider = Rpc.Provider; type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream | WritableStream | Request | Response | Headers; type Serializable = BaseType | Map ? Serializable : never, T extends Map ? Serializable : never> | Set ? Serializable : never> | ReadonlyArray ? Serializable : never> | { [Key in keyof T]: Key extends number | string ? Serializable : never } | Stub | Stubable; type Stubify = T extends Stubable ? Stub : T extends Map ? Map, Stubify> : T extends Set ? Set> : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends BaseType ? T : T extends { [key: string | number]: unknown; } ? { [Key in keyof T]: Stubify } : T; type MaybeProvider = T extends object ? Provider : unknown; type MaybeDisposable = T extends object ? Disposable : unknown; type Result$1 = T extends Stubable ? Promise> & Provider : T extends Serializable ? Promise & MaybeDisposable> & MaybeProvider : never; type MethodKey = { [Key in keyof Api]-?: Key extends string ? Api[Key] extends ((...args: Array) => unknown) ? Key : never : never }[keyof Api]; type MethodArgs = Api[Method] extends ((...args: infer Args) => unknown) ? Args : never; type MethodReturn = Api[Method] extends ((...args: Array) => infer Return) ? Return : never; type DisposableValue = { [Symbol.dispose](): void; }; declare const isDisposable: (value: unknown) => value is DisposableValue; declare const dispose: (value: unknown) => Effect.Effect; declare const resolve: (value: A) => Effect.Effect, unknown>; declare const scoped: (value: A) => Effect.Effect, unknown, Scope.Scope>; declare namespace RpcDefinition_d_exports { export { Definition$9 as Definition, Method$5 as Method, Methods$4 as Methods, NoReservedMethods$4 as NoReservedMethods, ReservedMethodName$6 as ReservedMethodName, ReservedMethodNameError, RpcArgumentCountError, RpcArgumentDecodeError, RpcArgumentEncodeError, RpcReservedMethodNameError, RpcSuccessDecodeError, RpcSuccessEncodeError, ServiceFreeSchema$4 as ServiceFreeSchema, assertNoReservedMethodNames, assertNoReservedMethods, decodeArgs, decodeSuccess, encodeArgs, encodeSuccess, make$11 as make, method$4 as method, reservedMethodNames }; } declare const RpcReservedMethodNameError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "RpcReservedMethodNameError"; } & Readonly; declare class RpcReservedMethodNameError extends RpcReservedMethodNameError_base<{ readonly definition: string; readonly method: string; }> {} declare const RpcArgumentCountError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "RpcArgumentCountError"; } & Readonly; declare class RpcArgumentCountError extends RpcArgumentCountError_base<{ readonly definition: string; readonly method: string; readonly expected: number; readonly actual: number; }> {} declare const RpcArgumentDecodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "RpcArgumentDecodeError"; } & Readonly; declare class RpcArgumentDecodeError extends RpcArgumentDecodeError_base<{ readonly definition: string; readonly method: string; readonly index: number; readonly cause: unknown; }> {} declare const RpcArgumentEncodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "RpcArgumentEncodeError"; } & Readonly; declare class RpcArgumentEncodeError extends RpcArgumentEncodeError_base<{ readonly definition: string; readonly method: string; readonly index: number; readonly cause: unknown; }> {} declare const RpcSuccessDecodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "RpcSuccessDecodeError"; } & Readonly; declare class RpcSuccessDecodeError extends RpcSuccessDecodeError_base<{ readonly definition: string; readonly method: string; readonly cause: unknown; }> {} declare const RpcSuccessEncodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "RpcSuccessEncodeError"; } & Readonly; declare class RpcSuccessEncodeError extends RpcSuccessEncodeError_base<{ readonly definition: string; readonly method: string; readonly cause: unknown; }> {} declare const reservedMethodNames: Set; type ReservedMethodName$6 = "constructor" | "fetch" | "connect" | "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError" | "then" | "dup" | "dispose" | "serialize" | "deserialize"; type ServiceFreeSchema$4 = Schema.Codec; interface Method$5 = ReadonlyArray, Success extends ServiceFreeSchema$4 = ServiceFreeSchema$4> { readonly args: Args; readonly success: Success; } declare namespace Method$5 { export type Any = Method$5, ServiceFreeSchema$4>; type ArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$4, ...infer Tail extends ReadonlyArray] ? [Schema.Schema.Type, ...ArgsFromSchemas] : Array>; type EncodedArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$4, ...infer Tail extends ReadonlyArray] ? [Schema.Codec.Encoded, ...EncodedArgsFromSchemas] : Array>; export type Args = ArgsFromSchemas; export type EncodedArgs = EncodedArgsFromSchemas; export type Success = Schema.Schema.Type; export type EncodedSuccess = Schema.Codec.Encoded; export {}; } type Methods$4 = Record; type NoReservedMethods$4 = Extract extends never ? MethodsShape : never; interface Definition$9 { readonly id: Id; readonly methods: MethodsShape; } declare namespace Definition$9 { type Any = Definition$9; type ServerApi = { readonly [Key in keyof Self["methods"]]: (...args: Method$5.Args) => Promise> }; type Api = Provider, Reserved>; type MethodNames = Extract; } declare class ReservedMethodNameError extends Error { readonly method: string; readonly target: string; constructor(target: string, method: string); } declare const assertNoReservedMethods: (target: string, methods: Record, reserved: ReadonlySet) => void; declare function method$4(definition: { readonly success: Success; }): Method$5; declare function method$4, Success extends ServiceFreeSchema$4>(definition: { readonly args: Args; readonly success: Success; }): Method$5; declare const assertNoReservedMethodNames: (definition: Definition$9.Any) => Effect.Effect; declare const decodeArgs: >(definition: Self, methodName: MethodName, args: ReadonlyArray) => Effect.Effect, RpcArgumentCountError | RpcArgumentDecodeError>; declare const encodeArgs: >(definition: Self, methodName: MethodName, args: Method$5.Args) => Effect.Effect, RpcArgumentCountError | RpcArgumentEncodeError>; declare const encodeSuccess: >(definition: Self, methodName: MethodName, value: Method$5.Success) => Effect.Effect, RpcSuccessEncodeError>; declare const decodeSuccess: >(definition: Self, methodName: MethodName, value: unknown) => Effect.Effect, RpcSuccessDecodeError>; declare const make$11: (id: Id, methods: MethodsShape) => Definition$9; declare namespace QueueBinding_d_exports { export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$10 as layer, makeClient$8 as makeClient }; } type QueueSendOptions = CloudflareQueueSendOptions; type QueueSendResponse = CloudflareQueueSendResponse; type QueueSendBatchOptions = CloudflareQueueSendBatchOptions; type QueueSendBatchResponse = CloudflareQueueSendBatchResponse; type QueueMetrics = CloudflareQueueMetrics; type MessageSendRequest = CloudflareMessageSendRequest; type QueueProducer = Pick, "send"> & Partial, "sendBatch" | "metrics">>; interface QueueBindingDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; /** Codec used to encode messages before sending them to Cloudflare Queues. */ readonly message: Message; } interface QueueBindingClient { readonly send: (message: Schema.Schema.Type, options?: QueueSendOptions) => Effect.Effect; readonly sendBatch: (messages: Iterable>>, options?: QueueSendBatchOptions) => Effect.Effect; readonly metrics: () => Effect.Effect; readonly unsafeRaw: Effect.Effect>>; } declare const QueueOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "QueueOperationError"; } & Readonly; declare class QueueOperationError extends QueueOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; readonly message: string; }> {} declare const isQueue: (value: unknown) => value is QueueProducer; declare const makeClient$8: (definition: QueueBindingDefinition) => ((queue: QueueProducer>) => QueueBindingClient); declare const layer$10: (tag: Context.Service>, definition: QueueBindingDefinition) => _$effect_Layer0.Layer; declare namespace QueueDefinition_d_exports { export { Definition$8 as Definition, Handler$3 as Handler, LayerOptions$13 as LayerOptions, Options$7 as Options, Queue$1 as Queue, Tag$13 as Tag, TagClass$12 as TagClass, implement$7 as implement, make$10 as make }; } interface Definition$8 { readonly id: Id; readonly message: Message; } declare namespace Definition$8 { type Any = Definition$8; } type Handler$3 = (batch: QueueBatch>) => Effect.Effect; interface Options$7 extends Omit>, "queue" | "rpc"> { readonly queue: Handler$3; readonly rpc?: never; } type LayerOptions$13 = { readonly binding: string; }; interface TagClass$12 extends Context.ServiceClass> { readonly id: Id; readonly message: Message; readonly make: (layer: Layer.Layer, options: Options$7>) => WorkerClass, ROut>; readonly layer: (options: LayerOptions$13) => Layer.Layer; readonly send: (message: Schema.Schema.Type, options?: QueueSendOptions) => Effect.Effect; readonly sendBatch: (messages: Iterable>>, options?: QueueSendBatchOptions) => Effect.Effect; readonly metrics: () => Effect.Effect; readonly unsafeRaw: () => Effect.Effect>, never, Self>; } declare const make$10: (id: Id, definition: { readonly message: Message; }) => TagClass$12, Id, Message>; declare const Tag$13: () => (id: Id, definition: { readonly message: Message; }) => TagClass$12; declare const Queue$1: () => (id: Id, definition: { readonly message: Message; }) => TagClass$12; declare const implement$7: (_definition: Self, handler: Handler$3) => Handler$3; declare namespace Queue_d_exports { export { Definition$7 as Definition, Handler$2 as Handler, LayerOptions$12 as LayerOptions, Options$6 as Options, QueueBatch, QueueHandler, QueueMessage, QueueMessageDecodeError, QueueOptions, Tag$12 as Tag, TagClass$11 as TagClass, decodeBatch, fromMessage, fromMessageBatch, implement$6 as implement }; } interface QueueMessage { readonly raw: globalThis.Message; readonly id: string; readonly timestamp: Date; readonly body: Body; readonly attempts: number; readonly ack: Effect.Effect; readonly retry: (options?: globalThis.QueueRetryOptions) => Effect.Effect; } interface QueueBatch { readonly raw: globalThis.MessageBatch; readonly messages: ReadonlyArray>; readonly queue: string; readonly metadata: globalThis.MessageBatchMetadata; readonly ackAll: Effect.Effect; readonly retryAll: (options?: globalThis.QueueRetryOptions) => Effect.Effect; } declare const QueueMessageDecodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "QueueMessageDecodeError"; } & Readonly; declare class QueueMessageDecodeError extends QueueMessageDecodeError_base<{ readonly queue: string; readonly messageId: string; readonly index: number; readonly cause: unknown; }> {} type RuntimeContext$2 = ExecutionContext | WorkerContext | WorkerEnvironment | ROut; type QueueHandlerContext = RuntimeContext$2 | Scope.Scope; type QueueHandler = (batch: QueueBatch) => Effect.Effect>; interface QueueOptions { readonly queue: QueueHandler; } declare const fromMessage: (message: globalThis.Message, body: Body) => { raw: Message; id: string; timestamp: Date; body: Body; attempts: number; ack: Effect.Effect; retry: (options?: globalThis.QueueRetryOptions) => Effect.Effect; }; declare const fromMessageBatch: (batch: globalThis.MessageBatch, messages: ReadonlyArray>) => QueueBatch; declare const decodeBatch: (batch: globalThis.MessageBatch, decodeBody: (body: unknown) => Effect.Effect) => Effect.Effect, QueueMessageDecodeError>; type Definition$7 = Definition$8; declare namespace Definition$7 { type Any = Definition$8.Any; } type LayerOptions$12 = LayerOptions$13; type TagClass$11 = TagClass$12; declare const Tag$12: () => (id: Id, definition: { readonly message: Message; }) => TagClass$11; declare const implement$6: (_definition: Self, handler: Handler$3) => Handler$3; type Handler$2 = Handler$3; type Options$6 = Options$7; declare namespace WorkerDefinition_d_exports { export { Api$3 as Api, Definition$6 as Definition, HandlerEffect$3 as HandlerEffect, Handlers$3 as Handlers, LayerOptions$11 as LayerOptions, Method$4 as Method, Methods$3 as Methods, NoReservedMethods$3 as NoReservedMethods, Options$5 as Options, ReservedMethodName$5 as ReservedMethodName, ServerApi$4 as ServerApi, ServiceFreeSchema$3 as ServiceFreeSchema, Tag$11 as Tag, TagClass$10 as TagClass, Worker, implement$5 as implement, make$9 as make, method$3 as method }; } type ServiceFreeSchema$3 = Schema.Codec; interface Method$4 = ReadonlyArray, Success extends ServiceFreeSchema$3 = ServiceFreeSchema$3> { readonly args: Args; readonly success: Success; } declare namespace Method$4 { export type Any = Method$4, ServiceFreeSchema$3>; type ArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$3, ...infer Tail extends ReadonlyArray] ? [Schema.Schema.Type, ...ArgsFromSchemas] : Array>; type EncodedArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$3, ...infer Tail extends ReadonlyArray] ? [Schema.Codec.Encoded, ...EncodedArgsFromSchemas] : Array>; export type Args = ArgsFromSchemas; export type EncodedArgs = EncodedArgsFromSchemas; export type Success = Schema.Schema.Type; export type EncodedSuccess = Schema.Codec.Encoded; export {}; } type Methods$3 = Record; /** * RPC contract for a Worker service. * * Create with {@link make} and reuse to type both worker implementations and * service bindings in other workers. */ interface Definition$6 { readonly id: Id; readonly methods: MethodsShape; } declare namespace Definition$6 { type Any = Definition$6; } type ReservedMethodName$5 = ReservedMethodName$3; type NoReservedMethods$3 = Extract extends never ? MethodsShape : never; /** * Promise-based client API derived from a {@link Definition}. */ type ServerApi$4 = { readonly [Key in keyof Self["methods"]]: (...args: Method$4.Args) => Promise> }; type Api$3 = Provider, ReservedMethodName$5>; /** * Effect handlers for each RPC method in a worker definition. */ type Handlers$3 = { readonly [Key in keyof Self["methods"]]: (...args: Method$4.Args) => WorkerRpcHandler> }; /** * Worker constructor options for a specific RPC definition. */ interface Options$5 extends Omit>, "rpc"> { readonly rpc: Handlers$3; } type LayerOptions$11 = { readonly binding: string; }; type TagClass$10 = Context.ServiceClass>, Definition$6>> & ServiceBindingStaticClient>, Definition$6> & { readonly id: Id; readonly methods: MethodsShape; readonly make: (layer: Layer.Layer, options: Options$5, REvent, EventLayerError>) => WorkerClass>, ROut | REvent>; readonly layer: (options: LayerOptions$11) => Layer.Layer; }; /** * Defines a single RPC method schema in a worker definition. */ declare const method$3: { (definition: { readonly success: Success; }): Method$4; (definition: { readonly args: Args; readonly success: Success; }): Method$4; }; declare const make$9: (id: Id, methods: MethodsShape & NoReservedMethods$3) => TagClass$10, Id, MethodsShape>; declare const Tag$11: () => (id: Id, methods: MethodsShape & NoReservedMethods$3) => TagClass$10; declare const Worker: () => (id: Id, methods: MethodsShape & NoReservedMethods$3) => TagClass$10; /** * Helper for implementing handlers with the exact method shape of a definition. */ declare const implement$5: (_definition: Self, handlers: Handlers$3) => Handlers$3; /** * Convenience alias for a single worker RPC handler Effect. */ type HandlerEffect$3 = WorkerRpcHandler>; //#endregion //#region src/internal/RpcInvocation.d.ts type AnyArgs = Array; type AsyncMethodKey = { [Key in keyof Api]-?: Key extends string ? Api[Key] extends ((...args: AnyArgs) => Promise) ? Key : never : never }[keyof Api]; type AsyncMethodArgs = Api[Method] extends ((...args: infer Args) => Promise) ? Args : never; type AsyncMethodSuccess = Api[Method] extends ((...args: AnyArgs) => Promise) ? A : never; type AsyncMethodCloudflareReturn = Result$1>; declare namespace ServiceBinding_d_exports { export { Service, ServiceBindingClient, ServiceBindingDefinition, ServiceBindingEffectClient, ServiceBindingFetchError, ServiceBindingRpcError, ServiceBindingStaticClient, ServiceFetcher, isServiceBindingClient, layer$9 as layer, makeClient$7 as makeClient, makeDirectMethods$1 as makeDirectMethods }; } declare const TypeId$1: "effect-cf/ServiceBinding"; /** * Minimum shape for a Cloudflare service binding. */ interface ServiceFetcher { fetch(input: RequestInfo | URL, init?: RequestInit): Promise; } type RpcClient$1 = { readonly [Key in keyof Api as Key extends string ? Api[Key] extends ((...args: Array) => unknown) ? Key : never : never]: Api[Key] }; type ReservedMethodName$4 = ReservedMethodName$5 | "fetch"; /** * Native Cloudflare service object including optional RPC methods. */ type ServiceBindingClient = ServiceFetcher & RpcClient$1>; type ApiFromDefinition = Definition extends Definition$6.Any ? ServerApi$4 : never; type ApiOrDefinition = [Api] extends [never] ? ApiFromDefinition : Api; /** * Binding metadata used to create an Effect service from a Worker binding. */ interface ServiceBindingDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; /** Optional RPC schema used for argument/result encoding. */ readonly definition?: Definition; } declare const ServiceBindingFetchError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "ServiceBindingFetchError"; } & Readonly; /** * Failure raised when calling `fetch` on a service binding. */ declare class ServiceBindingFetchError extends ServiceBindingFetchError_base<{ readonly binding: string; readonly cause: unknown; }> {} declare const ServiceBindingRpcError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "ServiceBindingRpcError"; } & Readonly; /** * Failure raised when invoking an RPC method on a service binding. */ declare class ServiceBindingRpcError extends ServiceBindingRpcError_base<{ readonly binding: string; readonly method: string; readonly cause: unknown; }> {} type ServiceMethodKey = AsyncMethodKey; type ServiceMethodArgs = AsyncMethodArgs; type ServiceMethodSuccess = AsyncMethodSuccess; type ServiceMethodCloudflareReturn = AsyncMethodCloudflareReturn; type ServiceCall = >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect, ServiceBindingRpcError, R>; type DefinitionDirectMethods = { readonly [Method in Definition$9.MethodNames]: (...args: Method$5.Args) => Effect.Effect, ServiceBindingRpcError, R> }; type DirectMethods$1 = Definition extends Definition$6.Any ? DefinitionDirectMethods : {}; type ServiceBindingEffectClient = DirectMethods$1 & { /** * Forwards an HTTP request to the bound Worker service. * * Use this when the service binding is acting as an HTTP origin rather than a * Cloudflare RPC target. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const api = yield* ApiWorker; * return yield* api.fetch(new Request("https://internal.example/users")); * }); * ``` */ readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; /** * Invokes a Worker RPC method and returns Cloudflare's raw RPC result. * * This preserves Cloudflare RPC behavior such as promise-like pipelining and * transferable / disposable result objects. It does not resolve the returned * promise-like value and it does not decode definition-backed success schemas. * * Most application code should use {@link call} instead. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const counter = yield* CounterService; * * const result = yield* counter.rpc("increment", 41); * const value = yield* Effect.promise(() => result); * * return value; * }); * ``` */ readonly rpc: >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect, ServiceBindingRpcError>; /** * Invokes a Worker RPC method, resolves Cloudflare's RPC result, and decodes * the success value when the binding was created from a definition. * * This is the normal choice when application code wants the final typed value. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const counter = yield* CounterService; * const value = yield* counter.call("increment", 41); * * return value; * }); * ``` */ readonly call: >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect, ServiceBindingRpcError>; /** * Invokes a Worker RPC method in the current `Scope`, resolves Cloudflare's RPC * result, decodes definition-backed success values, and disposes the resolved * result when the scope closes if it implements `Symbol.dispose`. * * Use this for RPC methods that return Cloudflare RPC resources or other * disposable objects whose lifetime should be tied to an Effect scope. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.scoped( * Effect.gen(function* () { * const files = yield* FileService; * const handle = yield* files.scopedCall("open", "report.csv"); * * return yield* handle.read(); * }), * ); * ``` */ readonly scopedCall: >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect>, unknown, Scope.Scope>; }; type ServiceBindingStaticClient = DirectMethods$1 & { readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; readonly rpc: >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect, ServiceBindingRpcError, R>; readonly call: >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect, ServiceBindingRpcError, R>; readonly scopedCall: >(method: Method, ...args: ServiceMethodArgs) => Effect.Effect>, unknown, Scope.Scope | R>; }; declare const isServiceBindingClient: (value: unknown) => value is ServiceBindingClient; declare const makeClient$7: (definition: ServiceBindingDefinition) => ((service: ServiceBindingClient) => ServiceBindingEffectClient); declare const layer$9: (tag: Context.Service>, definition: ServiceBindingDefinition) => _$effect_Layer0.Layer; /** * Creates a typed Effect service for a Worker service binding. * * Returned value includes: * - a Context tag for dependency injection * - `fetch(...)` for raw HTTP forwarding * - `rpc(...)` for raw Cloudflare RPC results * - `call(...)` for resolved and decoded RPC results * - `scopedCall(...)` for scoped and decoded disposable RPC results * - direct RPC methods when `definition` is provided * * @example * ```ts * const Counter = WorkerDefinition.make("Counter", { * increment: WorkerDefinition.method({ * args: [Schema.Number], * success: Schema.Number, * }), * }); * * const CounterLive = Counter.layer({ binding: "COUNTER" }); * * const program = Effect.gen(function* () { * const counter = yield* Counter; * const next = yield* counter.increment(1); * return next; * }); * ``` */ declare const Service: () => (id: Id, definition: ServiceBindingDefinition) => BindingService, Definition>> & DirectMethods$1 & { readonly [TypeId$1]: typeof TypeId$1; readonly definition: ServiceBindingDefinition; readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; readonly rpc: >>(method: Method, ...args: ServiceMethodArgs, Method>) => Effect.Effect, Method>>, ServiceBindingRpcError, Self>; readonly call: >>(method: Method, ...args: ServiceMethodArgs, Method>) => Effect.Effect, Method>, ServiceBindingRpcError, Self>; readonly scopedCall: >>(method: Method, ...args: ServiceMethodArgs, Method>) => Effect.Effect, Method>>, unknown, Self | Scope.Scope>; }; declare const makeDirectMethods$1: (rpcDefinition: Definition | undefined, call: ServiceCall) => DirectMethods$1; declare namespace Worker_d_exports { export { Api$2 as Api, Definition$5 as Definition, ExecutionContext, FetchHandler, FetchWorkerOptions, HandlerEffect$2 as HandlerEffect, Handlers$2 as Handlers, LayerOptions$10 as LayerOptions, Method$3 as Method, Methods$2 as Methods, NativeRequest, NoReservedMethods$2 as NoReservedMethods, Options$4 as Options, ReservedMethodName$3 as ReservedMethodName, RpcHandlers$1 as RpcHandlers, ServerApi$3 as ServerApi, ServiceFreeSchema$2 as ServiceFreeSchema, Tag$10 as Tag, TagClass$9 as TagClass, TagFactory$1 as TagFactory, WorkerClass, WorkerContext, WorkerContextService, WorkerContextWaitUntilOptions, WorkerFetchSuccess, WorkerHandler, WorkerOptions, WorkerRpc, WorkerRpcHandler, WorkerRpcShape, implement$4 as implement, isWebSocketUpgrade, make$8 as make, makeFetchHandler, method$2 as method, renderHttpResponse }; } declare const ExecutionContext_base: Context.ServiceClass>; declare class ExecutionContext extends ExecutionContext_base {} interface WorkerContextWaitUntilOptions { readonly mode?: "observe" | "propagate"; readonly onFailure?: (cause: Cause.Cause) => Effect.Effect; } interface WorkerContextService { readonly raw: globalThis.ExecutionContext; waitUntil(effect: Effect.Effect, options?: WorkerContextWaitUntilOptions): Effect.Effect; waitUntilPropagating(effect: Effect.Effect, options?: Omit, "mode">): Effect.Effect; readonly passThroughOnException: Effect.Effect; } declare const WorkerContext_base: Context.ServiceClass; declare class WorkerContext extends WorkerContext_base {} declare const NativeRequest_base: Context.ServiceClass>>; declare class NativeRequest extends NativeRequest_base {} declare const isWebSocketUpgrade: (request: Request) => boolean; type ReservedMethodName$3 = ReservedMethodName$6 | "fetch" | "connect" | "queue" | "scheduled" | "tail" | "tailStream" | "test" | "trace" | "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"; type WorkerBaseContext = ExecutionContext | WorkerContext | WorkerEnvironment | ROut; type WorkerFetchContext = WorkerBaseContext | NativeRequest | HttpServerRequest.HttpServerRequest | Scope.Scope; type WorkerRpcContext = WorkerBaseContext | Scope.Scope; type WorkerFetchSuccess = Response | HttpServerResponse.HttpServerResponse; type WorkerHandler = Effect.Effect>; type WorkerRpcHandler = Effect.Effect>; type WorkerRpc = Record) => WorkerRpcHandler>; type WorkerRpcShape, ROut> = { readonly [Key in keyof Rpc]: Rpc[Key] extends ((...args: infer Args) => Effect.Effect>) ? (...args: Args) => Promise : never }; type RpcHandlers$1 = { readonly [Key in keyof Api as Key extends keyof WorkerEntrypoint ? never : Key extends string ? Key extends ReservedMethodName$3 ? never : [Api[Key]] extends [never] ? never : Api[Key] extends ((...args: Array) => Promise) ? Key : never : never]: Api[Key] extends ((...args: infer Args) => Promise) ? (...args: Args) => WorkerRpcHandler : never }; interface WorkerOptions = Record> { /** * Layer provided around each Cloudflare event handled by this Worker. * * The layer is built inside the event's Effect scope and finalized when the * event effect completes. Use this for event-scoped resources such as OTLP * trace/log exporters that should flush at event completion. */ readonly eventLayer?: Layer.Layer>; readonly fetch?: Effect.Effect>; readonly queue?: QueueHandler; readonly rpc?: Rpc; } type FetchWorkerOptions = Omit>, "rpc"> & { readonly rpc?: never; }; type WorkerClass, ROut> = new (ctx: globalThis.ExecutionContext, env: WorkerEnv) => WorkerEntrypoint & { fetch(request: Request): Promise; queue(batch: globalThis.MessageBatch): Promise; } & WorkerRpcShape; interface FetchHandler { readonly fetch: (request: Request, env: Env, ctx: globalThis.ExecutionContext) => Promise; } declare const renderHttpResponse: (effect: Effect.Effect) => Effect.Effect; declare function make$8(layer: Layer.Layer, fetch: WorkerHandler): WorkerClass, ROut>; declare function make$8 = Record>(layer: Layer.Layer, options: WorkerOptions): WorkerClass; declare const makeFetchHandler: (layer: Layer.Layer, options: FetchWorkerOptions) => FetchHandler; type ServiceFreeSchema$2 = Schema.Codec; interface Method$3 = ReadonlyArray, Success extends ServiceFreeSchema$2 = ServiceFreeSchema$2> { readonly args: Args; readonly success: Success; } declare namespace Method$3 { export type Any = Method$3, ServiceFreeSchema$2>; type ArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends ReadonlyArray] ? [Schema.Schema.Type, ...ArgsFromSchemas] : Array>; export type Args = ArgsFromSchemas; export type Success = Schema.Schema.Type; export {}; } type Methods$2 = Record; type NoReservedMethods$2 = Extract extends never ? MethodsShape : never; interface Definition$5 { readonly id: Id; readonly methods: MethodsShape; } declare namespace Definition$5 { type Any = Definition$5; } type ServerApi$3 = { readonly [Key in keyof Self["methods"]]: (...args: Method$3.Args) => Promise> }; type Api$2 = Provider, ReservedMethodName$3>; type Handlers$2 = { readonly [Key in keyof Self["methods"]]: (...args: Method$3.Args) => WorkerRpcHandler> }; interface Options$4 extends Omit>, "rpc"> { readonly rpc: Handlers$2; } type LayerOptions$10 = LayerOptions$11; type TagClass$9 = Context.ServiceClass>, Definition$5>> & ServiceBindingStaticClient>, Definition$5> & { readonly id: Id; readonly methods: MethodsShape; readonly make: (layer: Layer.Layer, options: Options$4, REvent, EventLayerError>) => WorkerClass>, ROut | REvent>; readonly layer: (options: LayerOptions$10) => Layer.Layer; }; type TagFactory$1 = () => (id: Id, methods: MethodsShape & NoReservedMethods$2) => TagClass$9; declare const Tag$10: TagFactory$1; declare const method$2: { (definition: { readonly success: Success; }): Method$3; , Success extends ServiceFreeSchema$2>(definition: { readonly args: Args; readonly success: Success; }): Method$3; }; declare const implement$4: (_definition: Self, handlers: Handlers$2) => Handlers$2; type HandlerEffect$2 = WorkerRpcHandler>; declare namespace DurableObjectNamespace_d_exports { export { DurableObjectFetchError, DurableObjectNamespaceBindingDefinition, DurableObjectNamespaceClient, DurableObjectNamespaceDefinition, DurableObjectNamespaceEffectClient, DurableObjectNamespaceStaticClient, DurableObjectRpcError, DurableObjectStubClient, isDurableObjectNamespaceClient, layer$8 as layer, makeClient$6 as makeClient, makeDirectMethods }; } interface DurableObjectFetcher { fetch(input: RequestInfo | URL, init?: RequestInit): Promise; } type RpcClient = { readonly [Key in keyof Api as Key extends string ? Api[Key] extends ((...args: Array) => unknown) ? Key : never : never]: Api[Key] }; type ReservedMethodName$2 = ReservedMethodName$1 | "fetch"; /** * Cloudflare Durable Object stub, optionally enriched with RPC methods. */ type DurableObjectStubClient = DurableObjectFetcher & RpcClient> & { readonly id: globalThis.DurableObjectId; readonly name?: string; }; /** * Native Durable Object namespace binding shape. */ interface DurableObjectNamespaceClient { /** Creates a globally unique Durable Object id. */ newUniqueId(options?: globalThis.DurableObjectNamespaceNewUniqueIdOptions): globalThis.DurableObjectId; /** Deterministically maps a name to a Durable Object id. */ idFromName(name: string): globalThis.DurableObjectId; /** Rehydrates a Durable Object id from its string form. */ idFromString(id: string): globalThis.DurableObjectId; /** Returns a stub for an existing Durable Object id. */ get(id: globalThis.DurableObjectId, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStubClient; /** Returns a stub by deterministic name. */ getByName(name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStubClient; /** Selects a namespace pinned to a specific jurisdiction. */ jurisdiction(jurisdiction: globalThis.DurableObjectJurisdiction): DurableObjectNamespaceClient; } /** * Minimal namespace binding metadata. */ interface DurableObjectNamespaceDefinition { readonly binding: string; } /** * Namespace binding metadata with optional RPC schema. */ interface DurableObjectNamespaceBindingDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; /** Optional RPC schema used for argument/result encoding. */ readonly definition?: Definition; } declare const DurableObjectRpcError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "DurableObjectRpcError"; } & Readonly; /** * Failure raised when invoking an RPC method on a Durable Object stub. */ declare class DurableObjectRpcError extends DurableObjectRpcError_base<{ readonly binding: string; readonly method: string; readonly cause: unknown; }> {} declare const DurableObjectFetchError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "DurableObjectFetchError"; } & Readonly; /** * Failure raised when forwarding a request to a Durable Object stub. */ declare class DurableObjectFetchError extends DurableObjectFetchError_base<{ readonly binding: string; readonly cause: unknown; }> {} type StubMethodKey = AsyncMethodKey; type StubMethodArgs = AsyncMethodArgs; type StubMethodSuccess = AsyncMethodSuccess; type StubMethodCloudflareReturn = AsyncMethodCloudflareReturn; type StubCall = >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect, DurableObjectRpcError, R>; type DefinitionNamespaceDirectMethods = { readonly [Method in Definition$9.MethodNames]: (stub: DurableObjectStubClient, ...args: Method$5.Args) => Effect.Effect, DurableObjectRpcError, R> }; type DefinitionDurableObjectDirectClient = { readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; } & { readonly [Method in Definition$9.MethodNames]: (...args: Method$5.Args) => Effect.Effect, DurableObjectRpcError, R> }; type DefinitionNamespaceDirectClientMethods = { readonly byName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => DefinitionDurableObjectDirectClient; readonly byId: (id: globalThis.DurableObjectId, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => DefinitionDurableObjectDirectClient; }; type DirectMethods = Definition extends Definition$4.Any ? DefinitionNamespaceDirectMethods & DefinitionNamespaceDirectClientMethods : {}; type DurableObjectNamespaceEffectClient = DirectMethods & { /** Creates a globally unique Durable Object id. */readonly newUniqueId: (options?: globalThis.DurableObjectNamespaceNewUniqueIdOptions) => Effect.Effect; /** Deterministically maps a name to a Durable Object id. */ readonly idFromName: (name: string) => Effect.Effect; /** Rehydrates a Durable Object id from its string form. */ readonly idFromString: (id: string) => Effect.Effect; /** Returns a stub for an existing Durable Object id. */ readonly get: (id: globalThis.DurableObjectId, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect>; /** Returns a stub by deterministic name. */ readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect>; /** Selects a namespace pinned to a specific jurisdiction. */ readonly jurisdiction: (jurisdiction: globalThis.DurableObjectJurisdiction) => Effect.Effect>; /** * Forwards an HTTP request to a Durable Object stub. * * Use this for fetch-based Durable Object APIs, including WebSocket upgrade * forwarding where the native response must be preserved. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const rooms = yield* ChatRooms; * const room = yield* rooms.getByName("general"); * * return yield* rooms.fetch(room, new Request("https://worker.example/room")); * }); * ``` */ readonly fetch: (stub: DurableObjectStubClient, input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; /** * Invokes a Durable Object RPC method and returns Cloudflare's raw RPC result. * * This preserves Cloudflare RPC behavior such as promise-like pipelining and * transferable / disposable result objects. It does not resolve the returned * promise-like value and it does not decode definition-backed success schemas. * * Most application code should use {@link call} instead. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const counters = yield* Counters; * const counter = yield* counters.getByName("main"); * * const result = yield* counters.rpc(counter, "get"); * const value = yield* Effect.promise(() => result); * * return value; * }); * ``` */ readonly rpc: >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect, DurableObjectRpcError>; /** * Invokes a Durable Object RPC method, resolves Cloudflare's RPC result, and * decodes the success value when the namespace was created from a definition. * * This is the normal choice when application code wants the final typed value. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.gen(function* () { * const counters = yield* Counters; * const counter = yield* counters.getByName("main"); * * return yield* counters.call(counter, "increment", 1); * }); * ``` */ readonly call: >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect, DurableObjectRpcError>; /** * Invokes a Durable Object RPC method in the current `Scope`, resolves * Cloudflare's RPC result, decodes definition-backed success values, and * disposes the resolved result when the scope closes if it implements * `Symbol.dispose`. * * Use this for RPC methods that return Cloudflare RPC resources or other * disposable objects whose lifetime should be tied to an Effect scope. * * @example * ```ts * import { Effect } from "effect"; * * const program = Effect.scoped( * Effect.gen(function* () { * const rooms = yield* ChatRooms; * const room = yield* rooms.getByName("general"); * const handle = yield* rooms.scopedCall(room, "openStream"); * * return yield* handle.read(); * }), * ); * ``` */ readonly scopedCall: >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect>, unknown, Scope.Scope>; /** * Exposes the underlying native Durable Object namespace binding. * * Prefer the typed helpers above unless Cloudflare exposes a platform feature * that is not wrapped by effect-cf yet. */ readonly unsafeRaw: Effect.Effect>; }; type DurableObjectNamespaceStaticClient = DirectMethods & { readonly newUniqueId: (options?: globalThis.DurableObjectNamespaceNewUniqueIdOptions) => Effect.Effect; readonly idFromName: (name: string) => Effect.Effect; readonly idFromString: (id: string) => Effect.Effect; readonly get: (id: globalThis.DurableObjectId, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect, never, R>; readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect, never, R>; readonly jurisdiction: (jurisdiction: globalThis.DurableObjectJurisdiction) => Effect.Effect, never, R>; readonly fetch: (stub: DurableObjectStubClient, input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; readonly rpc: >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect, DurableObjectRpcError, R>; readonly call: >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect, DurableObjectRpcError, R>; readonly scopedCall: >(stub: DurableObjectStubClient, method: Method, ...args: StubMethodArgs) => Effect.Effect>, unknown, Scope.Scope | R>; readonly unsafeRaw: () => Effect.Effect, never, R>; }; declare const isDurableObjectNamespaceClient: (value: unknown) => value is DurableObjectNamespaceClient; declare const makeClient$6: (definition: DurableObjectNamespaceBindingDefinition) => ((namespace: DurableObjectNamespaceClient) => DurableObjectNamespaceEffectClient); declare const layer$8: (tag: Context.Service>, definition: DurableObjectNamespaceBindingDefinition) => _$effect_Layer0.Layer; declare const makeDirectMethods: (rpcDefinition: Definition | undefined, helpers: { readonly call: StubCall; readonly fetch: (stub: DurableObjectStubClient, input: RequestInfo | URL, init?: RequestInit) => Effect.Effect; readonly get: (id: globalThis.DurableObjectId, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect, never, R>; readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect, never, R>; }) => DirectMethods; declare namespace DurableObjectDefinition_d_exports { export { Api$1 as Api, Definition$4 as Definition, DurableObject$1 as DurableObject, HandlerEffect$1 as HandlerEffect, Handlers$1 as Handlers, LayerOptions$9 as LayerOptions, Method$2 as Method, Methods$1 as Methods, NoReservedMethods$1 as NoReservedMethods, Options$3 as Options, ReservedMethodName$1 as ReservedMethodName, ServerApi$2 as ServerApi, ServiceFreeSchema$1 as ServiceFreeSchema, Tag$9 as Tag, TagClass$8 as TagClass, implement$3 as implement, make$7 as make, method$1 as method }; } type ServiceFreeSchema$1 = Schema.Codec; interface Method$2 = ReadonlyArray, Success extends ServiceFreeSchema$1 = ServiceFreeSchema$1> { readonly args: Args; readonly success: Success; } declare namespace Method$2 { export type Any = Method$2, ServiceFreeSchema$1>; type ArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$1, ...infer Tail extends ReadonlyArray] ? [Schema.Schema.Type, ...ArgsFromSchemas] : Array>; type EncodedArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$1, ...infer Tail extends ReadonlyArray] ? [Schema.Codec.Encoded, ...EncodedArgsFromSchemas] : Array>; export type Args = ArgsFromSchemas; export type EncodedArgs = EncodedArgsFromSchemas; export type Success = Schema.Schema.Type; export type EncodedSuccess = Schema.Codec.Encoded; export {}; } type Methods$1 = Record; /** * RPC contract for a Durable Object class. */ interface Definition$4 { readonly id: Id; readonly methods: MethodsShape; } declare namespace Definition$4 { type Any = Definition$4; } type ReservedMethodName$1 = ReservedMethodName$6 | "fetch" | "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"; type NoReservedMethods$1 = Extract extends never ? MethodsShape : never; /** * Promise-based client API derived from a Durable Object definition. */ type ServerApi$2 = { readonly [Key in keyof Self["methods"]]: (...args: Method$2.Args) => Promise> }; type Api$1 = Provider, ReservedMethodName$1>; /** * Effect handlers for each RPC method in a Durable Object definition. */ type Handlers$1 = { readonly [Key in keyof Self["methods"]]: (...args: Method$2.Args) => DurableObjectHandler> }; /** * Durable Object constructor options for a specific RPC definition. */ interface Options$3 extends Omit>, "rpc"> { readonly rpc: Handlers$1; } type LayerOptions$9 = { readonly binding: string; }; type TagClass$8 = Context.ServiceClass>, Definition$4>> & DurableObjectNamespaceStaticClient>, Definition$4> & { readonly id: Id; readonly methods: MethodsShape; readonly make: (layer: Layer.Layer, options: Options$3, REvent, EventLayerError>) => DurableObjectClass>, ROut | REvent>; readonly layer: (options: LayerOptions$9) => Layer.Layer; }; /** * Defines a single RPC method schema in a Durable Object definition. */ declare const method$1: { (definition: { readonly success: Success; }): Method$2; (definition: { readonly args: Args; readonly success: Success; }): Method$2; }; declare const make$7: (id: Id, methods: MethodsShape & NoReservedMethods$1) => TagClass$8, Id, MethodsShape>; declare const Tag$9: () => (id: Id, methods: MethodsShape & NoReservedMethods$1) => TagClass$8; declare const DurableObject$1: () => (id: Id, methods: MethodsShape & NoReservedMethods$1) => TagClass$8; /** * Helper for implementing handlers with the exact method shape of a definition. */ declare const implement$3: (_definition: Self, handlers: Handlers$1) => Handlers$1; /** * Convenience alias for a single Durable Object RPC handler Effect. */ type HandlerEffect$1 = DurableObjectHandler>; declare namespace DurableObject_d_exports { export { Api, Definition$3 as Definition, DurableObjectClass, DurableObjectHandler, DurableObjectOptions, DurableObjectRpc, DurableObjectRpcShape, HandlerEffect, Handlers, LayerOptions$8 as LayerOptions, Method$1 as Method, Methods, NoReservedMethods, Options$2 as Options, ReservedMethodName, RpcHandlers, ServerApi$1 as ServerApi, ServiceFreeSchema, Tag$8 as Tag, TagClass$7 as TagClass, TagFactory, implement$2 as implement, make$6 as make, method }; } type RuntimeContext$1 = DurableObjectState | WorkerEnvironment | ROut; type HandlerContext = RuntimeContext$1 | Scope.Scope; type FetchContext = HandlerContext | NativeRequest; /** * Effect type for Durable Object lifecycle and RPC handlers. */ type DurableObjectHandler = Effect.Effect>; /** * Shape of Durable Object RPC handlers passed to {@link make}. */ type DurableObjectRpc = Record) => DurableObjectHandler>; type DurableObjectRpcShape, ROut> = { readonly [Key in keyof Rpc]: Rpc[Key] extends ((...args: infer Args) => Effect.Effect>) ? (...args: Args) => Promise : never }; type RpcHandlers = { readonly [Key in keyof Api as Key extends keyof DurableObject ? never : Key extends string ? [Api[Key]] extends [never] ? never : Api[Key] extends ((...args: Array) => Promise) ? Key : never : never]: Api[Key] extends ((...args: infer Args) => Promise) ? (...args: Args) => DurableObjectHandler : never }; /** * Options for creating a Durable Object class backed by Effect handlers. */ interface DurableObjectOptions = Record> { /** * Layer provided around each Cloudflare event handled by this Durable Object. * * The layer is built inside the event's Effect scope and finalized when the * event effect completes. It is not applied to `initialize`, which is an * instance-load lifecycle hook rather than a platform event. */ readonly eventLayer?: Layer.Layer; /** * Effect run when Cloudflare loads this Durable Object instance into memory. * * Use `DurableObjectState.blockConcurrencyWhile` inside this hook when * incoming events should wait for setup to finish. Cloudflare may construct * the same Durable Object id again after eviction or restart; use Durable * Object storage if work must happen only once per id. */ readonly initialize?: Effect.Effect>; /** Optional RPC methods exposed as Durable Object instance methods. */ readonly rpc?: Rpc; /** Optional fetch handler for HTTP/WebSocket requests. */ readonly fetch?: Effect.Effect>; /** * Optional logical alarm processing effect. * * This runs before `alarm` and should be built with helpers such as * `DurableObjectAlarm.processDue(...)` so the reusable scheduler stays inside * the Durable Object's single managed runtime boundary. */ readonly alarms?: Effect.Effect>; readonly alarm?: (alarmInfo?: globalThis.AlarmInvocationInfo) => Effect.Effect>; readonly webSocketMessage?: (socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect>; readonly webSocketClose?: (socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect>; readonly webSocketError?: (socket: DurableWebSocket, error: unknown) => Effect.Effect>; } /** * Cloudflare `DurableObject` constructor produced by {@link make}. */ type DurableObjectClass, ROut> = new (state: globalThis.DurableObjectState, env: WorkerEnv) => DurableObject & DurableObjectRpcShape; /** * Creates a Durable Object class backed by a single managed Effect runtime. */ declare const make$6: = Record>(layer: Layer.Layer, options?: DurableObjectOptions) => DurableObjectClass; type ServiceFreeSchema = Schema.Codec; interface Method$1 = ReadonlyArray, Success extends ServiceFreeSchema = ServiceFreeSchema> { readonly args: Args; readonly success: Success; } declare namespace Method$1 { export type Any = Method$1, ServiceFreeSchema>; type ArgsFromSchemas> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema, ...infer Tail extends ReadonlyArray] ? [Schema.Schema.Type, ...ArgsFromSchemas] : Array>; export type Args = ArgsFromSchemas; export type Success = Schema.Schema.Type; export {}; } type Methods = Record; type ReservedMethodName = ReservedMethodName$1; type NoReservedMethods = Extract extends never ? MethodsShape : never; interface Definition$3 { readonly id: Id; readonly methods: MethodsShape; } declare namespace Definition$3 { type Any = Definition$3; } type LayerOptions$8 = LayerOptions$9; type ServerApi$1 = { readonly [Key in keyof Self["methods"]]: (...args: Method$1.Args) => Promise> }; type Api = Provider, ReservedMethodName>; type Handlers = { readonly [Key in keyof Self["methods"]]: (...args: Method$1.Args) => DurableObjectHandler> }; interface Options$2 extends Omit>, "rpc"> { readonly rpc: Handlers; } type TagClass$7 = Context.ServiceClass>, Definition$3>> & DurableObjectNamespaceStaticClient>, Definition$3> & { readonly id: Id; readonly methods: MethodsShape; readonly make: (layer: Layer.Layer, options: Options$2, REvent, EventLayerError>) => DurableObjectClass>, ROut | REvent>; readonly layer: (options: LayerOptions$8) => Layer.Layer; }; type TagFactory = () => (id: Id, methods: MethodsShape & NoReservedMethods) => TagClass$7; declare const Tag$8: TagFactory; declare const method: { (definition: { readonly success: Success; }): Method$1; (definition: { readonly args: Args; readonly success: Success; }): Method$1; }; declare const implement$2: (_definition: Self, handlers: Handlers) => Handlers; type HandlerEffect = DurableObjectHandler>; declare namespace DurableObjectAlarm_d_exports { export { AlarmDefinitionConfig, AlarmDefinitionEntry, AlarmDefinitionPayload, AlarmDefinitions, AlarmFailurePolicy, AlarmPayload, AlarmPayloadSchema, AlarmRef, AlarmRetryPolicy, AlarmScheduler, DefinedAlarmEvent, DefinedAlarmHandlers, DurableObjectAlarm, DurableObjectAlarmError, DurableObjectAlarmEvent, InvalidAlarmPayloadError, InvalidAlarmRefError, InvalidProcessDueAlarmsOptionsError, InvalidRepeatEveryError, ProcessDueAlarmsFailure, ProcessDueAlarmsFailureAction, ProcessDueAlarmsHandler, ProcessDueAlarmsMode, ProcessDueAlarmsOptions, ProcessDueAlarmsResult, ScheduleAlarmInput, StoredAlarmDecodeError, define, process, processDue }; } /** * JSON-serializable alarm payload stored with each scheduled alarm. * * Payloads are intentionally opaque to `DurableObjectAlarm`. Consumers should use * stable `tag` values to route due alarms and then decode the payload for that * tag in their own domain layer. */ type AlarmPayload = Schema.Json; declare const InvalidAlarmRefError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "InvalidAlarmRefError"; } & Readonly; declare class InvalidAlarmRefError extends InvalidAlarmRefError_base<{ readonly cause: unknown; }> {} declare const InvalidAlarmPayloadError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "InvalidAlarmPayloadError"; } & Readonly; declare class InvalidAlarmPayloadError extends InvalidAlarmPayloadError_base<{ readonly cause: unknown; }> {} declare const InvalidRepeatEveryError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "InvalidRepeatEveryError"; } & Readonly; declare class InvalidRepeatEveryError extends InvalidRepeatEveryError_base<{ readonly cause: unknown; }> {} declare const InvalidProcessDueAlarmsOptionsError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "InvalidProcessDueAlarmsOptionsError"; } & Readonly; declare class InvalidProcessDueAlarmsOptionsError extends InvalidProcessDueAlarmsOptionsError_base<{ readonly cause: unknown; }> {} declare const StoredAlarmDecodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "StoredAlarmDecodeError"; } & Readonly; declare class StoredAlarmDecodeError extends StoredAlarmDecodeError_base<{ readonly cause: unknown; readonly storageId: string; }> {} type DurableObjectAlarmError = InvalidAlarmPayloadError | InvalidAlarmRefError | InvalidProcessDueAlarmsOptionsError | InvalidRepeatEveryError | StorageOperationError | StoredAlarmDecodeError; /** * Events handled by `processDueAlarms`. * * `AlarmDue` represents one durable alarm whose scheduled time is now due. The * `tag` is the consumer-owned routing key, while `id` is the stable alarm id * within that tag. * * `scheduledAt` is the logical due-after timestamp from durable storage. It is * not expected to match the current Durable Object alarm invocation time, * especially during retries. Retries re-scan durable rows with `run_at <= now` * and identify logical events by `{ tag, id }`. * * @example Handling events by tag * ```ts * yield* durableObjectAlarm.processDueAlarms((event) => * event.tag === "heartbeat" * ? heartbeatManager.handleAlarmEvent(event).pipe(Effect.asVoid) * : Effect.void * ); * ``` */ declare const DurableObjectAlarmEvent: Schema.TaggedUnion<{ readonly AlarmDue: Schema.TaggedStruct<"AlarmDue", { readonly id: Schema.NonEmptyString; readonly payload: Schema.Codec; readonly scheduledAt: Schema.DateTimeUtc; readonly tag: Schema.NonEmptyString; }>; }>; type DurableObjectAlarmEvent = typeof DurableObjectAlarmEvent.Type; /** * Stable reference for a scheduled alarm. * * The pair of `tag` and `id` is the durable identity. Scheduling another alarm * with the same pair replaces the previous alarm, and cancellation uses the * same pair. * * @example Cancel an alarm * ```ts * yield* durableObjectAlarm.cancelAlarm({ * tag: "connection-reconnect-grace", * id: "reconnect-grace-check", * }); * ``` */ type AlarmRef = { readonly id: string; readonly tag: Tag; }; /** * Input for scheduling or replacing an alarm. * * `runAt` is the absolute first fire time. `repeatEvery` can be any Effect * `Duration.Input`, including strings like `"5 seconds"`, numbers interpreted * as milliseconds, or `Duration` values. * * @example One-shot alarm * ```ts * const now = yield* DateTime.now; * * yield* durableObjectAlarm.scheduleAlarm({ * tag: "connection-reconnect-grace", * id: "reconnect-grace-check", * runAt: DateTime.add(now, { seconds: 15 }), * payload: { reason: "socket-closed" }, * }); * ``` * * @example Repeating alarm * ```ts * const now = yield* DateTime.now; * * yield* durableObjectAlarm.scheduleAlarm({ * tag: "heartbeat", * id: "heartbeat-check", * runAt: DateTime.add(now, { seconds: 5 }), * repeatEvery: "5 seconds", * payload: null, * }); * ``` */ type ScheduleAlarmInput = AlarmRef & { readonly payload: AlarmPayload; readonly repeatEvery?: Duration.Input; readonly runAt: DateTime.Utc; }; type ProcessDueAlarmsMode = "isolated" | "ordered"; interface ProcessDueAlarmsFailure { readonly cause: unknown; readonly event?: DurableObjectAlarmEvent; readonly id: string; readonly storageId: string; readonly tag: string; } interface ProcessDueAlarmsResult { readonly failed: readonly ProcessDueAlarmsFailure[]; readonly handled: readonly DurableObjectAlarmEvent[]; } type ProcessDueAlarmsFailureAction = "ordered" | "retry" | "skip-and-advance-repeat" | { readonly mode: "ordered"; } | { readonly mode: "retry"; readonly retryFailedAfter?: Duration.Input; } | { readonly mode: "skip-and-advance-repeat"; }; interface ProcessDueAlarmsOptions { /** Maximum due rows to load and process in one invocation. Defaults to 100. */ readonly limit?: number; /** * Failure isolation mode. Defaults to `isolated` so one poison logical alarm * does not block unrelated maintenance work. */ readonly mode?: ProcessDueAlarmsMode; /** * Callback for logical handler/decode failures. Return a failure action to * override the global failure behavior for this row. */ readonly onFailure?: (failure: ProcessDueAlarmsFailure) => Effect.Effect; /** * Delay before retrying a failed logical row in isolated mode. Defaults to 30 * seconds. Ignored by ordered mode unless supplied explicitly. * * Retrying updates only the selected occurrence, so replacements scheduled by * a long-running handler are not clobbered by failure handling. */ readonly retryFailedAfter?: Duration.Input; } /** * Handler invoked for each due alarm before that alarm is acknowledged. * * If the handler fails, `DurableObjectAlarm` leaves the row due and fails the alarm * processing effect. Cloudflare can then retry the Durable Object alarm handler, * and the scheduler will find the same logical row again because `run_at` is * still less than or equal to the retry time. */ type ProcessDueAlarmsHandler = (event: DurableObjectAlarmEvent) => Effect.Effect; /** * Durable alarm scheduler API. * * This service only owns scheduling semantics. It does not publish, subscribe, * or dispatch events to consumers. Durable Object alarm handlers should pass a * domain handler to `processDueAlarms`; rows are acknowledged only after that * handler succeeds. * * This service must be the only code path that owns `storage.setAlarm()` inside * a Durable Object instance. Cloudflare exposes one platform alarm timestamp per * object, so another scheduler in the same object can clobber this service's * reconciled alarm timestamp. * * @example Durable Object alarm handler * ```ts * const onAlarm = Effect.gen(function* () { * const durableObjectAlarm = yield* DurableObjectAlarm; * * yield* durableObjectAlarm.processDueAlarms((event) => * Effect.gen(function* () { * if (event.tag === "heartbeat") { * yield* heartbeatManager.handleAlarmEvent(event); * return; * } * * if (event.tag === "connection-reconnect-grace") { * yield* connectionManager.expireReconnectGracePeriods(); * } * }) * ); * }); * ``` */ type AlarmScheduler = { /** * Cancel a scheduled alarm by `{ tag, id }`. * * This is idempotent. Cancelling a missing alarm is a no-op. The underlying * Durable Object alarm is reconciled afterward. */ readonly cancelAlarm: (input: AlarmRef) => Effect.Effect; /** * Process due alarms according to `Clock.currentTimeMillis`. * * Each row is acknowledged only after `handle` succeeds. One-shot alarms are * then deleted. Repeating alarms are rescheduled to `acknowledgedAt + * repeatEvery`, which intentionally behaves as delay-after-success rather * than fixed-cadence catch-up. Acknowledgements are conditional on the stored * row still matching the selected occurrence, so a handler that reschedules * the same `{ tag, id }` will not have its replacement clobbered by the old * acknowledgement. * * Processing is ordered by `runAt` and stable alarm id. By default, logical * handler/decode failures are isolated to the failing row: the row is retried * after `retryFailedAfter`, later due rows still run, and the result reports * both handled and failed rows. Use `mode: "ordered"` when a workflow * intentionally requires strict head-of-line blocking. * * Handlers must still be idempotent: Cloudflare alarms are at-least-once, and * if a handler succeeds but the acknowledgement write fails, the logical event * can be delivered again. */ readonly processDueAlarms: (handle: ProcessDueAlarmsHandler, options?: ProcessDueAlarmsOptions) => Effect.Effect; /** * Schedule or replace an alarm by `{ tag, id }`. * * The durable row write and underlying platform alarm reconciliation are run * in one Durable Object storage transaction, so a failed `setAlarm` rolls back * the logical schedule instead of leaving a stored-but-unarmed alarm. */ readonly scheduleAlarm: (input: ScheduleAlarmInput) => Effect.Effect; }; declare const processDue: (handle: ProcessDueAlarmsHandler, options?: ProcessDueAlarmsOptions) => Effect.Effect; declare const process: (handle: ProcessDueAlarmsHandler, options?: ProcessDueAlarmsOptions) => Effect.Effect; type AlarmPayloadSchema = Schema.Codec; type AlarmFailurePolicy = "ordered" | "retry" | "skip-and-advance-repeat"; interface AlarmRetryPolicy { readonly initialDelay?: Duration.Input; } interface AlarmDefinitionConfig { readonly failure?: AlarmFailurePolicy; readonly payload: Payload; readonly retry?: AlarmRetryPolicy; } type AlarmDefinitionEntry = AlarmDefinitionConfig | AlarmPayloadSchema; type AlarmDefinitions = Readonly>; type AlarmDefinitionSchema = Definition extends AlarmDefinitionConfig ? Payload : Definition; type AlarmDefinitionPayload = AlarmDefinitionSchema extends Schema.Codec ? A : never; type DefinedAlarmEvent = Omit & { readonly payload: Payload; readonly tag: Tag; }; type DefinedAlarmHandlers = { readonly [Tag in keyof Definitions & string]: (event: DefinedAlarmEvent>) => Effect.Effect }; declare const define: (definitions: Definitions) => { handlers: (handlers: DefinedAlarmHandlers, options?: ProcessDueAlarmsOptions) => Effect.Effect; }; declare const DurableObjectAlarm_base: Context.ServiceClass; /** * SQLite-backed Durable Object alarm scheduler. * * `DurableObjectAlarm` stores alarms in the current Durable Object's SQLite storage * and keeps the platform alarm set to the earliest pending scheduled alarm. The * platform alarm timestamp is only a wake-up hint; logical event identity comes * from persisted `{ tag, id }` rows. * * Retry safety depends on acknowledgement ordering. `processDueAlarms` runs the * caller's handler first and only then conditionally deletes or advances the * same selected row. By default, handler failures are isolated: the failed row * is retried after a delay, later due rows continue, and the platform alarm is * reconciled once at the end. Use `mode: "ordered"` for strict workflows where * one failed logical alarm should block later due alarms. * * Provide `DurableObjectAlarm.layer` anywhere `DurableObjectState` is available. * * @example Providing the service * ```ts * const program = Effect.gen(function* () { * const durableObjectAlarm = yield* DurableObjectAlarm; * const now = yield* DateTime.now; * * yield* durableObjectAlarm.scheduleAlarm({ * tag: "heartbeat", * id: "heartbeat-check", * runAt: DateTime.add(now, { seconds: 5 }), * repeatEvery: Duration.seconds(5), * payload: null, * }); * }).pipe(Effect.provide(DurableObjectAlarm.layer)); * ``` * * @example Processing due alarms * ```ts * const handledEvents = yield* durableObjectAlarm.processDueAlarms((event) => * Effect.gen(function* () { * if (event.tag === "heartbeat") { * yield* heartbeatManager.handleAlarmEvent(event); * } * }) * ); * ``` */ declare class DurableObjectAlarm extends DurableObjectAlarm_base { static readonly layer: Layer.Layer; } declare namespace DurableObjectRpcWebSocket_d_exports { export { DurableObjectRpcWebSocket, DurableObjectRpcWebSocketService, LayerOptions$7 as LayerOptions, NativeWebSocketMessage, layer$7 as layer }; } /** * Configuration for {@link layer}. */ interface LayerOptions$7 { /** Tag used to select hibernated sockets. */ readonly tag?: string | undefined; /** Socket attachment key used to persist client ids across hibernation. */ readonly attachmentKey?: string | undefined; } /** Native websocket event payload accepted by Cloudflare Durable Objects. */ type NativeWebSocketMessage = string | ArrayBuffer; /** * Service API used to wire websocket lifecycle events to Effect RPC server protocol. */ interface DurableObjectRpcWebSocketService { readonly accept: (socket: DurableWebSocket) => Effect.Effect; readonly message: (socket: DurableWebSocket, message: NativeWebSocketMessage) => Effect.Effect; readonly close: (socket: DurableWebSocket) => Effect.Effect; readonly error: (socket: DurableWebSocket, error: unknown) => Effect.Effect; } declare const DurableObjectRpcWebSocket_base: Context.ServiceClass; /** * Context tag for the Durable Object RPC websocket service. */ declare class DurableObjectRpcWebSocket extends DurableObjectRpcWebSocket_base {} /** * Builds a layer that bridges Durable Object websocket events to `RpcServer.Protocol`. */ declare const layer$7: (options?: LayerOptions$7) => Layer.Layer; declare namespace DurableObjectSqlite_d_exports { export { SqliteLayerOptions, layer$6 as layer }; } /** Options forwarded to `@effect/sql-sqlite-do` when building a SQL client layer. */ type SqliteLayerOptions = Omit; /** * Provides `effect/unstable/sql` from the current Durable Object SQLite storage. * * @example * ```ts * const RoomLayer = Layer.mergeAll( * DurableObjectSqlite.layer(), * OtherRoomServices, * ); * ``` */ declare const layer$6: (options?: SqliteLayerOptions) => Layer.Layer<_$effect_unstable_sql_SqlClient0.SqlClient | SqliteClient.SqliteClient, never, DurableObjectState>; declare namespace Email_d_exports { export { EmailAddress, EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailMessage, EmailMessageBuilder, EmailOperationError, EmailSendInput, EmailSendResult, EmailService, LayerOptions$6 as LayerOptions, Tag$7 as Tag, TagClass$6 as TagClass, isEmailBinding, layer$5 as layer, make$5 as make, makeClient$5 as makeClient }; } declare const EmailOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "EmailOperationError"; } & Readonly; /** Error raised when a Cloudflare Send Email operation fails. */ declare class EmailOperationError extends EmailOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed Cloudflare Send Email binding definition. */ interface EmailDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type EmailAddress = CloudflareEmailAddress; type EmailAttachment = CloudflareEmailAttachment; type EmailMessage = CloudflareEmailMessage; type EmailMessageBuilder = Parameters[0]; type EmailSendInput = EmailMessage | EmailMessageBuilder; type EmailSendResult = CloudflareEmailSendResult; type EmailBinding = CloudflareSendEmail; interface EmailClient { readonly send: { (message: EmailMessage): Effect.Effect; (builder: EmailMessageBuilder): Effect.Effect; }; readonly unsafeRaw: Effect.Effect; readonly definition: EmailDefinition; } declare const EmailServiceTypeId: unique symbol; /** Nominal service marker for Send Email services created with {@link make}. */ interface EmailService { readonly [EmailServiceTypeId]: { readonly id: Id; }; } type LayerOptions$6 = { readonly binding: string; }; interface TagClass$6 extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions$6) => Layer.Layer; } declare const isEmailBinding: (value: unknown) => value is EmailBinding; declare const makeClient$5: (definition: EmailDefinition) => (email: EmailBinding) => EmailClient; declare const layer$5: (tag: Context.Service, definition: EmailDefinition) => Layer.Layer; declare const make$5: (id: Id) => TagClass$6, Id>; declare const Tag$7: () => (id: Id) => TagClass$6; declare namespace Images_d_exports { 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$5 as LayerOptions, ProcessOptions, Step, Steps, Tag$6 as Tag, TagClass$5 as TagClass, draw, empty, isImagesBinding, layer$4 as layer, make$4 as make, makeClient$4 as makeClient, transform }; } declare const TypeId: "effect-cf/Images/Steps"; declare const ImagesOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "ImagesOperationError"; } & Readonly; /** Error raised when a Cloudflare Images operation fails. */ declare class ImagesOperationError extends ImagesOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed Cloudflare Images binding definition. */ interface ImagesDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type ImageInfoResponse = CloudflareImageInfoResponse; type ImageTransform = CloudflareImageTransform; type ImageDrawOptions = CloudflareImageDrawOptions; type ImageInputOptions = CloudflareImageInputOptions; type ImageOutputOptions = CloudflareImageOutputOptions; type ImageTransformationOutputOptions = CloudflareImageTransformationOutputOptions; type ImageTransformationResult = CloudflareImageTransformationResult; type ImageUploadOptions = CloudflareImageUploadOptions; type ImageUpdateOptions = CloudflareImageUpdateOptions; type ImageListOptions = CloudflareImageListOptions; type ImageList = CloudflareImageList; type ImageMetadata = CloudflareImageMetadata; type ImageInputValue = ReadableStream | ArrayBuffer; type ImageUploadValue = ReadableStream | ArrayBuffer; interface DrawStepOptions { readonly image: ReadableStream | CloudflareImageTransformer; readonly options?: ImageDrawOptions; } type Step = Data.TaggedEnum<{ readonly Transform: { readonly transform: ImageTransform; }; readonly Draw: DrawStepOptions; }>; interface Steps { readonly [TypeId]: typeof TypeId; readonly steps: ReadonlyArray; } interface ProcessOptions { readonly stream: ImageInputValue; readonly inputOptions?: ImageInputOptions; readonly outputOptions: ImageOutputOptions; } interface ImagesTransformationResultClient { readonly raw: CloudflareImageTransformationResult; readonly response: Effect.Effect; readonly contentType: Effect.Effect; readonly image: (options?: ImageTransformationOutputOptions) => Effect.Effect, ImagesOperationError>; } interface ImageHandleClient { readonly raw: CloudflareImageHandle; readonly details: Effect.Effect, ImagesOperationError>; readonly bytes: Effect.Effect>, ImagesOperationError>; readonly update: (options: ImageUpdateOptions) => Effect.Effect; readonly delete: Effect.Effect; } interface HostedImagesClient { readonly image: (imageId: string) => ImageHandleClient; readonly upload: (image: ImageUploadValue, options?: ImageUploadOptions) => Effect.Effect; readonly list: (options?: ImageListOptions) => Effect.Effect; readonly unsafeRaw: Effect.Effect; } interface ImagesRuntimeBinding { readonly info: (image: ImageInputValue, options?: ImageInputOptions) => Promise; readonly input: (image: ImageInputValue, options?: ImageInputOptions) => CloudflareImageTransformer; readonly hosted?: CloudflareHostedImagesBinding; } interface ImagesClient { readonly info: (image: ImageInputValue, options?: ImageInputOptions) => Effect.Effect; readonly input: (image: ImageInputValue, options?: ImageInputOptions) => Effect.Effect; readonly process: (steps: Steps, options: ProcessOptions) => Effect.Effect; readonly hosted: Option.Option; readonly unsafeRaw: Effect.Effect; readonly definition: ImagesDefinition; } declare const ImagesServiceTypeId: unique symbol; /** Nominal service marker for Images services created with {@link make}. */ interface ImagesService { readonly [ImagesServiceTypeId]: { readonly id: Id; }; } type LayerOptions$5 = { readonly binding: string; }; interface TagClass$5 extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions$5) => Layer.Layer; } /** Empty Images transformation pipeline. */ declare const empty: Steps; declare function transform(transform: ImageTransform): (steps: Steps) => Steps; declare function transform(steps: Steps, transform: ImageTransform): Steps; declare function draw(draw: DrawStepOptions): (steps: Steps) => Steps; declare function draw(steps: Steps, draw: DrawStepOptions): Steps; declare const isImagesBinding: (value: unknown) => value is ImagesRuntimeBinding; declare const makeClient$4: (definition: ImagesDefinition) => (images: ImagesRuntimeBinding) => ImagesClient; declare const layer$4: (tag: Context.Service, definition: ImagesDefinition) => Layer.Layer; declare const make$4: (id: Id) => TagClass$5, Id>; declare const Tag$6: () => (id: Id) => TagClass$5; declare namespace Kv_d_exports { export { Definition$2 as Definition, KvClient, KvDefinition, KvListKey, KvListOptions, KvListResult, KvOperationError, KvPutOptions, KvWithMetadata, LayerOptions$4 as LayerOptions, Tag$5 as Tag, TagClass$4 as TagClass, isKvNamespace, layer$3 as layer, makeClient$3 as makeClient }; } declare const KvOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "KvOperationError"; } & Readonly; /** Error raised when a KV operation fails. */ declare class KvOperationError extends KvOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** `KVNamespace.put` options. */ type KvPutOptions = CloudflareKVNamespacePutOptions; /** `KVNamespace.list` options with optional metadata decoding schema. */ type KvListOptions = CloudflareKVNamespaceListOptions & { readonly metadataSchema?: Schema.Codec; }; /** Successful value returned by `getWithMetadata`. */ interface KvWithMetadata { readonly value: Value; readonly metadata: Option.Option; readonly cacheStatus: Option.Option; } /** Decoded key entry returned by `list`. */ interface KvListKey { readonly name: Key; readonly expiration: Option.Option; readonly metadata: Option.Option; } /** Decoded result returned by `list`. */ interface KvListResult { readonly keys: ReadonlyArray>; readonly listComplete: boolean; readonly cursor: Option.Option; readonly cacheStatus: Option.Option; } /** * Typed KV binding definition. */ interface KvDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; /** Codec used to encode/decode keys. */ readonly key: Schema.Codec; /** Codec used to encode/decode values. */ readonly value: Schema.Codec; } /** * Reusable typed KV resource definition without a concrete Cloudflare binding name. */ interface Definition$2 { readonly id: Id; /** Codec used to encode/decode keys. */ readonly key: Schema.Codec; /** Codec used to encode/decode values. */ readonly value: Schema.Codec; } declare namespace Definition$2 { type Any = Definition$2; } interface KvClient { readonly put: (key: Key, value: Value, options?: KvPutOptions) => Effect.Effect; readonly get: (key: Key) => Effect.Effect, KvOperationError | Schema.SchemaError>; readonly getWithMetadata: (key: Key, metadataSchema: Schema.Codec) => Effect.Effect>, KvOperationError | Schema.SchemaError>; readonly list: (options?: KvListOptions) => Effect.Effect, KvOperationError | Schema.SchemaError>; readonly remove: (key: Key) => Effect.Effect; readonly unsafeRaw: Effect.Effect; readonly definition: KvDefinition; } type LayerOptions$4 = { readonly binding: string; }; interface TagClass$4 extends Context.ServiceClass> { readonly id: Id; readonly keySchema: Schema.Codec; readonly valueSchema: Schema.Codec; readonly layer: (options: LayerOptions$4) => Layer.Layer; } declare const isKvNamespace: (value: unknown) => value is KVNamespace; declare const makeClient$3: (definition: KvDefinition) => ((kv: KVNamespace) => KvClient); declare const layer$3: (tag: Context.Service>, definition: KvDefinition) => Layer.Layer; declare const Tag$5: () => (id: Id, definition: { readonly key: Schema.Codec; readonly value: Schema.Codec; }) => TagClass$4; declare namespace R2_d_exports { export { LayerOptions$3 as LayerOptions, R2Client, R2Definition, R2GetOptions, R2ListOptions, R2MultipartOptions, R2MultipartUploadClient, R2ObjectBodyClient, R2OperationError, R2PutOptions, R2PutValue, R2Service, R2UploadPartOptions, R2UploadPartValue, Tag$4 as Tag, TagClass$3 as TagClass, isR2Bucket, layer$2 as layer, make$3 as make, makeClient$2 as makeClient }; } declare const R2OperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "R2OperationError"; } & Readonly; /** Error raised when an R2 operation fails. */ declare class R2OperationError extends R2OperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed R2 bucket binding definition. */ interface R2Definition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type R2GetOptions = CloudflareR2GetOptions; type R2PutOptions = CloudflareR2PutOptions; type R2ListOptions = CloudflareR2ListOptions; type R2MultipartOptions = CloudflareR2MultipartOptions; type R2UploadPartOptions = CloudflareR2UploadPartOptions; type R2PutValue = ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob; type R2UploadPartValue = ReadableStream | ArrayBuffer | ArrayBufferView | string | Blob; interface R2ObjectBodyClient extends Omit { readonly raw: CloudflareR2ObjectBody; readonly arrayBuffer: Effect.Effect; readonly bytes: Effect.Effect; readonly text: Effect.Effect; readonly json: () => Effect.Effect; readonly blob: Effect.Effect; } interface R2MultipartUploadClient { readonly raw: CloudflareR2MultipartUpload; readonly key: string; readonly uploadId: string; readonly uploadPart: (partNumber: number, value: R2UploadPartValue, options?: R2UploadPartOptions) => Effect.Effect; readonly abort: Effect.Effect; readonly complete: (uploadedParts: ReadonlyArray) => Effect.Effect; } interface R2Client { readonly head: (key: string) => Effect.Effect, R2OperationError>; readonly get: { (key: string, options: R2GetOptions & { readonly onlyIf: CloudflareR2Conditional | Headers; }): Effect.Effect, R2OperationError>; (key: string, options?: R2GetOptions): Effect.Effect, R2OperationError>; }; readonly put: { (key: string, value: R2PutValue, options: R2PutOptions & { readonly onlyIf: CloudflareR2Conditional | Headers; }): Effect.Effect, R2OperationError>; (key: string, value: R2PutValue, options?: R2PutOptions): Effect.Effect; }; readonly createMultipartUpload: (key: string, options?: R2MultipartOptions) => Effect.Effect; readonly resumeMultipartUpload: (key: string, uploadId: string) => Effect.Effect; readonly delete: (keys: string | ReadonlyArray) => Effect.Effect; readonly list: (options?: R2ListOptions) => Effect.Effect; readonly unsafeRaw: Effect.Effect; readonly definition: R2Definition; } declare const R2ServiceTypeId: unique symbol; /** Nominal service marker for R2 services created with {@link make}. */ interface R2Service { readonly [R2ServiceTypeId]: { readonly id: Id; }; } type LayerOptions$3 = { readonly binding: string; }; interface TagClass$3 extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions$3) => Layer.Layer; } declare const isR2Bucket: (value: unknown) => value is CloudflareR2Bucket; declare const makeClient$2: (definition: R2Definition) => ((bucket: CloudflareR2Bucket) => R2Client); declare const layer$2: (tag: Context.Service, definition: R2Definition) => Layer.Layer; declare const make$3: (id: Id) => TagClass$3, Id>; declare const Tag$4: () => (id: Id) => TagClass$3; declare namespace WorkflowBinding_d_exports { export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowInstanceEvent, WorkflowInstanceRestartOptions, WorkflowInstanceStatus, WorkflowInstanceStatusName, WorkflowOperationError, WorkflowResultDecodeError, isWorkflow, layer$1 as layer, makeClient$1 as makeClient }; } type WorkflowInstanceCreateOptions = Omit, "params">; type WorkflowInstanceCreateBatchOptions = ReadonlyArray<{ readonly payload: Payload; } & WorkflowInstanceCreateOptions>; interface WorkflowInstanceRestartOptions { readonly from?: { readonly name?: string; readonly count?: number; readonly type?: string; }; } type WorkflowInstanceStatusName = CloudflareInstanceStatus["status"]; interface WorkflowInstanceStatus { readonly status: WorkflowInstanceStatusName; readonly output: Option.Option; readonly error: Option.Option<{ readonly name: string; readonly message: string; }>; } interface WorkflowInstance { readonly raw: CloudflareWorkflowInstance; readonly id: string; readonly pause: Effect.Effect; readonly resume: Effect.Effect; readonly terminate: Effect.Effect; readonly restart: (options?: WorkflowInstanceRestartOptions) => Effect.Effect; readonly status: Effect.Effect, WorkflowOperationError | WorkflowResultDecodeError>; readonly sendEvent: (event: WorkflowInstanceEvent) => Effect.Effect; } interface WorkflowInstanceEvent { readonly type: string; readonly payload: unknown; } interface WorkflowBindingDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; /** Codec used to encode payloads passed to `Workflow.create`. */ readonly payload: Payload; /** Codec used to decode completed workflow status output. */ readonly result: Result; } interface WorkflowBindingClient { readonly create: (payload: Schema.Schema.Type, options?: WorkflowInstanceCreateOptions>) => Effect.Effect>, WorkflowOperationError | Schema.SchemaError>; readonly createBatch: (batch: WorkflowInstanceCreateBatchOptions, Schema.Codec.Encoded>) => Effect.Effect>>, WorkflowOperationError | Schema.SchemaError>; readonly get: (instanceId: string) => Effect.Effect>, WorkflowOperationError>; readonly unsafeRaw: Effect.Effect>>; } declare const WorkflowOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "WorkflowOperationError"; } & Readonly; declare class WorkflowOperationError extends WorkflowOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} declare const WorkflowResultDecodeError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "WorkflowResultDecodeError"; } & Readonly; declare class WorkflowResultDecodeError extends WorkflowResultDecodeError_base<{ readonly binding: string; readonly instanceId: string; readonly cause: unknown; }> {} declare const isWorkflow: (value: unknown) => value is CloudflareWorkflow; declare const makeClient$1: (definition: WorkflowBindingDefinition) => ((workflow: CloudflareWorkflow>) => WorkflowBindingClient); declare const layer$1: (tag: Context.Service>, definition: WorkflowBindingDefinition) => _$effect_Layer0.Layer; declare namespace WorkflowDefinition_d_exports { export { Definition$1 as Definition, Handler$1 as Handler, LayerOptions$2 as LayerOptions, Options$1 as Options, Tag$3 as Tag, TagClass$2 as TagClass, Workflow, implement$1 as implement, make$2 as make }; } interface Definition$1 { readonly id: Id; readonly payload: Payload; readonly result: Result; } declare namespace Definition$1 { type Any = Definition$1; } type Handler$1 = (payload: Schema.Schema.Type) => Effect.Effect, unknown, WorkflowRunContext>; interface Options$1 { readonly run: Handler$1; } type LayerOptions$2 = { readonly binding: string; }; interface TagClass$2 extends Context.ServiceClass> { readonly id: Id; readonly payload: Payload; readonly result: Result; readonly make: (layer: Layer.Layer, options: Options$1>) => WorkflowClass, Schema.Codec.Encoded, ROut>; readonly layer: (options: LayerOptions$2) => Layer.Layer; readonly create: (payload: Schema.Schema.Type, options?: WorkflowInstanceCreateOptions>) => Effect.Effect>, WorkflowOperationError | Schema.SchemaError, Self>; readonly createBatch: (batch: WorkflowInstanceCreateBatchOptions, Schema.Codec.Encoded>) => Effect.Effect>>, WorkflowOperationError | Schema.SchemaError, Self>; readonly get: (instanceId: string) => Effect.Effect>, WorkflowOperationError, Self>; readonly unsafeRaw: () => Effect.Effect>, never, Self>; } declare const make$2: (id: Id, definition: { readonly payload: Payload; readonly result: Result; }) => TagClass$2, Id, Payload, Result>; declare const Tag$3: () => (id: Id, definition: { readonly payload: Payload; readonly result: Result; }) => TagClass$2; declare const Workflow: () => (id: Id, definition: { readonly payload: Payload; readonly result: Result; }) => TagClass$2; declare const implement$1: (_definition: Self, handler: Handler$1) => Handler$1; declare namespace Workflow_d_exports { export { Definition, Handler, LayerOptions$1 as LayerOptions, Options, Tag$2 as Tag, TagClass$1 as TagClass, WorkflowClass, WorkflowEvent$1 as WorkflowEvent, WorkflowEventService, WorkflowHandler, WorkflowOptions, WorkflowRunContext, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepService, implement, make$1 as make, sleep, sleepUntil, step, waitForEvent }; } interface WorkflowEventService { readonly raw: WorkflowEvent; readonly payload: Payload; readonly timestamp: Date; readonly instanceId: string; readonly workflowName: string; } declare const WorkflowEvent_base: Context.ServiceClass>; declare class WorkflowEvent$1 extends WorkflowEvent_base {} interface WorkflowStepService { readonly raw: WorkflowStep; do(name: string, effect: Effect.Effect, config?: WorkflowStepConfig): Effect.Effect>; readonly sleep: (name: string, duration: WorkflowSleepDuration) => Effect.Effect; readonly sleepUntil: (name: string, timestamp: Date | number) => Effect.Effect; readonly waitForEvent: (name: string, options: { readonly type: string; readonly timeout?: WorkflowTimeoutDuration | number; }) => Effect.Effect, unknown>; } declare const WorkflowStep_base: Context.ServiceClass; declare class WorkflowStep$1 extends WorkflowStep_base {} declare const WorkflowStepContext_base: Context.ServiceClass; declare class WorkflowStepContext$1 extends WorkflowStepContext_base {} type RuntimeContext = ExecutionContext | WorkerContext | WorkerEnvironment | ROut; type WorkflowRunContext = RuntimeContext | WorkflowEvent$1 | WorkflowStep$1 | Scope.Scope; type WorkflowHandler = (payload: Payload) => Effect.Effect>; interface WorkflowOptions { readonly run: WorkflowHandler; } type WorkflowClass = new (ctx: globalThis.ExecutionContext, env: WorkerEnv) => WorkflowEntrypoint & { run(event: Readonly>, step: WorkflowStep): Promise; }; declare const make$1: (layer: Layer.Layer, options: WorkflowOptions) => WorkflowClass; declare const step: (name: string, effect: Effect.Effect, config?: WorkflowStepConfig) => Effect.Effect>; declare const sleep: (name: string, duration: WorkflowSleepDuration) => Effect.Effect; declare const sleepUntil: (name: string, timestamp: Date | number) => Effect.Effect; declare const waitForEvent: (name: string, options: { readonly type: string; readonly timeout?: WorkflowTimeoutDuration | number; }) => Effect.Effect, unknown, WorkflowStep$1>; type Definition = Definition$1; declare namespace Definition { type Any = Definition$1.Any; } type LayerOptions$1 = LayerOptions$2; type TagClass$1 = TagClass$2; declare const Tag$2: () => (id: Id, definition: { readonly payload: Payload; readonly result: Result; }) => TagClass$1; declare const implement: (_definition: Self, handler: Handler$1) => Handler$1; type Handler = Handler$1; type Options = Options$1; declare namespace Vectorize_d_exports { export { LayerOptions, Tag$1 as Tag, TagClass, VectorizeBinding, VectorizeClient, VectorizeDefinition, VectorizeIndexDetails, VectorizeIndexInfo, VectorizeMatch, VectorizeMatches, VectorizeMutation, VectorizeOperationError, VectorizeQueryOptions, VectorizeService, VectorizeValues, VectorizeVector, VectorizeVectorMetadata, VectorizeVectorMetadataFilter, VectorizeVectorMetadataValue, isVectorizeBinding, layer, make, makeClient }; } declare const VectorizeOperationError_base: new = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & { readonly _tag: "VectorizeOperationError"; } & Readonly; /** Error raised when a Vectorize operation fails. */ declare class VectorizeOperationError extends VectorizeOperationError_base<{ readonly binding: string; readonly operation: string; readonly cause: unknown; }> {} /** Typed Vectorize binding definition. */ interface VectorizeDefinition { /** Binding name as configured in `wrangler.jsonc`. */ readonly binding: string; } type VectorizeBinding = CloudflareVectorize | CloudflareVectorizeIndex; type VectorizeVector = CloudflareVectorizeVector; type VectorizeVectorMetadata = CloudflareVectorizeVectorMetadata; type VectorizeVectorMetadataValue = CloudflareVectorizeVectorMetadataValue; type VectorizeVectorMetadataFilter = CloudflareVectorizeVectorMetadataFilter; type VectorizeQueryOptions = CloudflareVectorizeQueryOptions; type VectorizeMatches = CloudflareVectorizeMatches; type VectorizeMatch = CloudflareVectorizeMatch; type VectorizeIndexInfo = CloudflareVectorizeIndexInfo; type VectorizeIndexDetails = CloudflareVectorizeIndexDetails; type VectorizeMutation = CloudflareVectorizeAsyncMutation | CloudflareVectorizeVectorMutation; type VectorizeValues = Float32Array | Float64Array | ReadonlyArray; interface VectorizeClient { readonly describe: Effect.Effect; readonly query: (vector: VectorizeValues, options?: VectorizeQueryOptions) => Effect.Effect; readonly queryById: (vectorId: string, options?: VectorizeQueryOptions) => Effect.Effect; readonly insert: (vectors: ReadonlyArray) => Effect.Effect; readonly upsert: (vectors: ReadonlyArray) => Effect.Effect; readonly deleteByIds: (ids: ReadonlyArray) => Effect.Effect; readonly delete: (ids: ReadonlyArray) => Effect.Effect; readonly getByIds: (ids: ReadonlyArray) => Effect.Effect, VectorizeOperationError>; readonly unsafeRaw: Effect.Effect; readonly definition: VectorizeDefinition; } declare const VectorizeServiceTypeId: unique symbol; /** Nominal service marker for Vectorize services created with {@link make}. */ interface VectorizeService { readonly [VectorizeServiceTypeId]: { readonly id: Id; }; } type LayerOptions = { readonly binding: string; }; interface TagClass extends Context.ServiceClass { readonly id: Id; readonly layer: (options: LayerOptions) => Layer.Layer; } declare const isVectorizeBinding: (value: unknown) => value is VectorizeBinding; declare const makeClient: (definition: VectorizeDefinition) => (index: VectorizeBinding) => VectorizeClient; declare const layer: (tag: Context.Service, definition: VectorizeDefinition) => Layer.Layer; declare const make: (id: Id) => TagClass, Id>; declare const Tag$1: () => (id: Id) => TagClass; //#endregion export { AiGateway_d_exports as AiGateway, AnalyticsEngine_d_exports as AnalyticsEngine, Binding_d_exports as Binding, BrowserRendering_d_exports as BrowserRendering, CloudflareOtlp_d_exports as CloudflareOtlp, 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, Email_d_exports as Email, 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, Vectorize_d_exports as Vectorize, Worker_d_exports as Worker, WorkerConfig, WorkerDefinition_d_exports as WorkerDefinition, type WorkerEnv, WorkerEnvironment, WorkersAi_d_exports as WorkersAi, Workflow_d_exports as Workflow, WorkflowBinding_d_exports as WorkflowBinding, WorkflowDefinition_d_exports as WorkflowDefinition };