Skip to main content
Version: v0.0.3

Function: parseFormat()

parseFormat(format, bytes): Promise<ParseResult>

Parse one record of format into the wrapped library's model + its value-free warnings. The model is emitted verbatim on the data channel; the CLI adds no parsing of its own.

Parameters

format

CosyteFormat

A format for which supportsOp(format, "parse") is true.

bytes

Uint8Array

The single record's bytes (already de-framed for MLLP: callers pass "hl7" there).

Returns

Promise<ParseResult>

The parsed model + value-free warnings.

Throws

CLI_PARSER_UNAVAILABLE if the optional parser is absent; the wrapped parser's own rejection propagates for the command's value-free failure boundary to catch.

Example

import { parseFormat } from "@cosyte/cli";

const bytes = new TextEncoder().encode('{"resourceType":"Patient","id":"x"}');
(await parseFormat("fhir", bytes)).warnings.length; // => 0