HTTP SDK
createHttpSdkFactory returns a factory that creates typed SDK clients bound to a base URL. Like the local SDK, the factory is parameterized with your Router type for compile-time checks on workflowId and params.
Setup
import { createHttpSdkFactory } from "yieldstar";
import type { Router } from "./shared";
const createSdk = createHttpSdkFactory<Router>();
const sdk = createSdk({ url: "http://localhost:8080" });The factory accepts fetchOptions to pass custom headers or other RequestInit properties to every request:
const sdk = createSdk({
url: "http://localhost:8080",
fetchOptions: {
headers: { Authorization: "Bearer token" },
},
});sdk.trigger
Sends a POST to /trigger. Returns an object with executionId, ack(), and waitForResult().
const exec = await sdk.trigger({
workflowId: "process-order",
params: { orderId: "abc123" },
});exec.ack()
Reads the trigger response body. Returns { executionId }.
const { executionId } = await exec.ack();exec.waitForResult()
Sends a POST to /events with the executionId and blocks until the workflow completes. Returns the result.
const result = await exec.waitForResult();If the workflow threw an error, waitForResult deserializes and re-throws it with the original stack trace.
Trigger event shape
| Field | Type | Required | Description |
|---|---|---|---|
workflowId | string | Yes | ID matching a key in the router |
params | Record<string, any> | Depends on workflow type | Input data accessible via event.params inside the workflow |
executionId | string | No | Custom execution ID. Auto-generated via nanoid if omitted |
context | Record<string, any> | No | Additional context passed through middleware |