import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import type * as Scope from "effect/Scope"; import { WorkflowEngine } from "effect/workflow"; import type { RuntimeContext } from "../RuntimeContext.ts"; import type { DurableObjectStorage } from "./Workerd/DurableObjectStorage.ts"; /** What a provider supplies to host the engine's Durable Objects. */ export interface DurableObjectEngineHost { /** Declare a Durable Object class on the host Worker, during its init. */ readonly declare: (name: string, impl: ObjectImpl) => Effect.Effect; /** The provider's per-instance Durable Object state. */ readonly state: Context.Key; } /** The part of a provider's Durable Object state the engine uses: SQL storage. */ type StateService = { readonly storage: { readonly sql: Pick; readonly transaction: DurableObjectStorage["transaction"]; }; }; /** * Effect's `WorkflowEngine` on Durable Objects, for any Workers runtime that * hosts them (Cloudflare today). Each workflow gets its own Durable Object * class on the host Worker, and each execution is one instance of it, named * by its execution id, with its journal in that instance's SQLite. * * A run replays the workflow from the top: finished activities return their * stored results, and the first unfinished one runs and is stored. A run that * waits on a `DurableClock` or `DurableDeferred` that isn't ready suspends, * and the clock firing or the deferred being completed runs it again. Every * run happens in one durable callback per execution, so runs never overlap, * and a run that fails or is cut short is retried. * * Providers supply how to declare a Durable Object class on their Worker and * the tag of their per-instance state. * * @internal */ export declare const makeDurableObjectEngine: (host: DurableObjectEngineHost) => Layer.Layer; interface Stub { readonly [method: string]: (...args: ReadonlyArray) => Effect.Effect; } /** A declared Durable Object class: stubs by instance name. */ export interface Namespace { readonly getByName: (name: string) => Stub; } /** The two-stage implementation of an execution object. */ export type ObjectImpl = Effect.Effect, never, State | RuntimeContext | Scope.Scope>, never, State>; export {}; //# sourceMappingURL=DurableObjectEngine.d.ts.map