@hasna/domains
Version:
Domain portfolio, registrar, marketplace, and DNS management for AI agents — CLI + MCP + HTTP API + SDK, shared account API and PostgreSQL
54 lines • 2.93 kB
TypeScript
/** Bytes accepted per attempt. Throws an errno-bearing Error on failure. */
export interface SyncWriter {
(chunk: Uint8Array): number;
}
export type WriteOutcome = "complete" | "reader-closed";
/**
* Write every byte in `bytes`, or stop because the reader closed the pipe.
*
* `writer` is injectable so the partial-write, back-pressure and reader-closed
* paths can be exercised without needing a real full pipe, which is not
* reproducible on demand in a unit test.
*/
export declare function writeAllBytesSync(bytes: Uint8Array, writer: SyncWriter): WriteOutcome;
export declare function writeAllSync(text: string, writer: SyncWriter): WriteOutcome;
/** Write `text` to stdout, completing the write before returning. */
export declare function writeStdout(text: string, writer?: SyncWriter): WriteOutcome;
/** Write arbitrary bytes to stdout without text encoding or a trailing newline. */
export declare function writeStdoutBytes(bytes: Uint8Array, writer?: SyncWriter): WriteOutcome;
/**
* Render arguments exactly as `console.log` would, plus the trailing newline.
*
* Exported so the formatting contract can be asserted directly. 739 call sites
* were converted mechanically and many of them pass more than one argument or a
* `%s`/`%d`/`%o` specifier; a replacement that only handled a single string
* would change their output silently, which would be a worse regression than
* the truncation being fixed. Testing that through the real fd would measure
* the writer instead of the formatter, so the seam is here.
*/
export declare function formatLine(...args: unknown[]): string;
/**
* Drop-in replacement for `console.log`, with the write actually completed.
*
* Variadic and `util.format`-based so it matches `console.log` argument for
* argument (`%s`/`%d`/`%o` substitution, space-joined extras, object
* inspection).
*/
export declare function printLine(...args: unknown[]): WriteOutcome;
/** `console.error` equivalent: completed write to stderr. */
export declare function printErrorLine(...args: unknown[]): WriteOutcome;
/**
* Emit a machine-readable JSON document on stdout.
*
* Every `--json` surface is a single write of an unbounded document, so every
* one of them can exceed a pipe buffer once the portfolio grows. Measured on
* an 800-row fixture, before this module existed: `domain list --all --json`
* delivered 65,536 of 822,523 bytes, `domain expiring --json` 65,536 of
* 784,003, and `domain export --format json` 131,072 of 572,803 — one or two
* buffers depending on how fast the reader drained, which is why the cut is not
* a constant anyone can test against.
*/
export declare function printJson(value: unknown, writer?: SyncWriter): WriteOutcome;
/** Single-line JSON, for streams where one record per line is the contract. */
export declare function printJsonLine(value: unknown, writer?: SyncWriter): WriteOutcome;
//# sourceMappingURL=stdout.d.ts.map