Caller
Change arguments, attach context, retry, time out, or decode results.
@repo/do-transforms composes cross-cutting behavior around native Cloudflare RPC calls. A transform can run on the caller, the callee, or both while preserving target compatibility and updating async return types.
It supports:
WorkerEntrypoint service bindings.Caller
Callee
Typed chains
.with(...) checks target, options, context, and transformed return types.Native transport
Add the Vite plugin before Cloudflare’s plugin:
import { cloudflare } from '@cloudflare/vite-plugin';import { doTransforms } from '@repo/do-transforms/vite';import { defineConfig } from 'vite';
export default defineConfig({ plugins: [ doTransforms({ wrangler: './wrangler.jsonc' }), cloudflare(), ],});The plugin reads Durable Object and service bindings from Wrangler, wraps binding access, and generates do-transforms.generated.d.ts.
import { retry, timeout } from '@repo/do-transforms';
const result = await env.MY_DO.get(id) .with(retry, { retries: 3 }) .with(timeout, 5_000) .loadReport();Transforms execute in chain order around the RPC call. Keep retry safety in mind: repeated RPC calls can repeat side effects unless the method is idempotent.