discoverCoders(specifier: string,timeout?: number): Promise<DiscoveryOutcome>
Discovers the coder factories a package exposes, without importing it.
Runs deno doc --json --quiet <specifier> and reads the result with
readDocSurface. Requires permission to spawn deno
(--allow-run=deno); without it the outcome is a permission-denied
ToolFailure and callers should fall back to asking for an
explicit coder name.
A cold lookup pays for building the module graph — on the order of a second
for a JSR package — while a warm one is near-instant. One that answers
nothing at all is killed after TOOL_TIMEOUT and comes back as a
timed-out ToolFailure, so the CLI cannot be left waiting on a
subprocess that never speaks.
The specifier must name a single module; callers refuse a directory first
(./target.ts).
Discover the single coder of a local package
Discover the single coder of a local package
import { assertEquals } from "@std/assert"; import { discoverCoders } from "./discover.ts"; const outcome = await discoverCoders(import.meta.resolve("../arp/mod.ts")); assertEquals(outcome.ok, true); if (outcome.ok) { assertEquals(outcome.coders.map((coder) => coder.name), ["arpData"]); assertEquals(outcome.coders[0].requiredParams, 0); }
Promise<DiscoveryOutcome>
The discovered surface, or why deno doc produced none