Caller
Bound wait time, retry idempotent calls, decode values, or attach metadata.
@durability/transforms composes cross-cutting behavior around Cloudflare Durable Object and Worker service-binding RPC. Transforms can run at the caller, callee, or both while preserving target compatibility and transformed async return types.
npm install @durability/transformsCaller
Callee
Typed chains
.with() validates the target, options, context, and resulting method type.Native RPC
The plugin reads validated Wrangler bindings, wraps matching RPC stubs, and generates declarations that add .with() to their types.
import { doTransforms } from '@durability/transforms/vite';import { defineConfig } from 'vite';
export default defineConfig({ plugins: [ doTransforms({ wrangler: './wrangler.jsonc' }), ],});The declaration defaults to do-transforms.generated.d.ts beside the Wrangler main module. Include it in the application’s TypeScript project. When using Cloudflare’s Vite plugin, place doTransforms() before cloudflare().
import { retry, timeout } from '@durability/transforms';
const report = await env.REPORTS.getByName(id) .with(timeout, 5_000) .with(retry, { retries: 3 }) .load();Continue with authoring transforms, built-ins, or the API reference.