call
uses tcmts.cli.test.e2e.server.hashOf, which uses node:sqlite
POST to a server function, carrying cookies like a browser would.
import { hashOf } from "#codebase/tcmts/cli/test/e2e/server"; export async function call(dir: string, url: string, name: string, args: unknown[], jar: Map<string, string>, headers: Record<string, string> = {}) { const res = await fetch(new URL(`/__tcm/rpc/${hashOf(dir, name)}`, url), { method: "POST", headers: { "content-type": "application/json", cookie: [...jar].map(([k, v]) => `${k}=${v}`).join("; "), ...headers }, body: JSON.stringify(args), }); for (const c of res.headers.getSetCookie()) { const [kv] = c.split(";"); const [k, v] = kv!.split("="); if (/Max-Age=0/.test(c)) jar.delete(k!); else jar.set(k!, v!); } return { status: res.status, body: await res.text(), setCookie: res.headers.getSetCookie() }; }