Skip to content

WorkflowProxyServer

Server-side layers for workflow proxy APIs.

layerHttpApi connects the HTTP API group created by WorkflowProxy to the supplied workflows. layerRpcHandlers does the same for the generated RPC definitions. Both layers route execute, discard, and resume requests to the matching workflow operation, while the WorkflowEngine and workflow handler services stay on the server side.

3 exports Added in v4.0.0 Source

Layers

layerHttpApi

Added in v4.0.0 Source

Creates handlers for a workflow HTTP API group, wiring execute, discard, and resume endpoints to the supplied workflows.

Signature

declare function layerHttpApi<
  ApiId extends string,
  Groups extends Constraint,
  Identifier extends string,
  Workflows extends readonly [Any, Any],
>(
  api: HttpApi<ApiId, Groups>,
  identifier: Identifier,
  workflows: Workflows,
): Layer<
  Service<ApiId, Identifier>,
  never,
  WorkflowEngine | RequirementsHandler<Workflows[number]>
>;

Creates RPC handlers for the supplied workflows, wiring execute, discard, and resume RPCs to workflow operations.

Signature

declare function layerRpcHandlers<
  Workflows extends readonly [Any, Any],
  Prefix extends string = "",
>(
  workflows: Workflows,
  options?: {
    readonly prefix?: Prefix;
  },
): Layer<
  RpcHandlers<Workflows[number], Prefix>,
  never,
  WorkflowEngine | RequirementsHandler<Workflows[number]>
>;

Services

RpcHandlers type

Added in v4.0.0 Source

Union of RPC handler services required to serve the generated workflow execute, discard, and resume RPCs.

Signature

type RpcHandlers<Workflows extends Workflow.Any, Prefix extends string> =
  Workflows extends Workflow.Workflow<infer _Name, infer _Payload, infer _Success, infer _Error>
    ?
        | Rpc.Handler<`${Prefix}${_Name}`>
        | Rpc.Handler<`${Prefix}${_Name}Discard`>
        | Rpc.Handler<`${Prefix}${_Name}Resume`>
    : never;