OFX

:= { statements : List(Statement) }

Streaming banking and credit-card OFX 1.x SGML and 2.x XML statements. Amounts, identifiers, and timestamps remain exact strings. Unknown XML transaction elements are preserved in order. Unknown SGML tags are rejected because their omitted-close behaviour is ambiguous. DTDs are unsupported.

decoder : Props -> Decoder(State, Event, [InvalidOfx(Error)])

Configure bounded statement events for the common streaming API.

encoder : WriteProps -> Encoder(WriteState, Event, [InvalidOfx(Error)])

Configure atomic item validation and document finalization.

parse_bytes : List(U8), Props -> Try(OFX, [InvalidOfx(Error)])

Collect a complete encoded document with encounter-order fail-fast errors.

parse_str : Str, Props -> Try(OFX, [InvalidOfx(Error)])

Parse already decoded UTF-8; contradictory encoding headers fail.

parser : Props -> Parser(Bytes, OFX, Problem)

Complete OFX document as a byte combinator.

validate : ValidationProps -> Try(OFX, [InvalidOfx(Error)])

Validate imported or quoted OFX.

encode : OFX, WriteProps -> Try(List(U8), [InvalidOfx(Error), InvalidChunkSize(Diagnostic(ChunkSizeProblem))])

Collect encoded output; event writing remains bounded by record size.

Resource : [HeaderBytes, TokenBytes, FieldBytes, RecordBytes, Depth, Fields, ExtensionDepth]

Resource kinds enforced by bounded OFX readers.

Problem : [LimitExceeded({ resource : Resource, max : U64, observed : Observed }), IncompleteDocument, UnfinishedStatement, TrailingContent, NonAsciiHeader, SyntaxMismatch, SelfClosingEndTag, EmptyTagName, MalformedHeaderField(Str), DuplicateHeaderField(Str), UnsupportedHeader(Str), UnsupportedDataFormat(Str), UnsupportedEncoding(Str), CompressionUnsupported, UnknownHeaderField(Str), InconsistentHeader, EncodingCharsetMismatch, UnsupportedCharset(Str), HeaderEncodingMismatch, NonAsciiByte, UnexpectedText, InvalidCharacterData, InvalidEncoding(EncodingError), DtdUnsupported, PaddedCdataUnsupported, MalformedCommentOrCdata, SgmlCommentUnsupported, CdataPlacementUnsupported, ProcessingInstructionPlacement, PrologueOrder, MalformedXmlDeclaration, XmlDeclarationOrder, DeclarationEncodingMismatch, MalformedProcessingInstruction, UnsupportedXmlHeader, UnknownProcessingInstruction, UnsupportedDeclaration, InvalidTagName(Str), ExpectedRoot, MultipleRoots, InvestmentUnsupported, UnsupportedElement(Str), UnknownSgmlTag(Str), NestedScalar, NestedStatement, InvalidParent({ element : Str, parent : Str }), AccountOrder, DuplicateBalance(Str), NestedRecord, RecordOutsideStatement, MismatchedClosingTag({ actual : Str, expected : Try(Str, [NoOpenElement]) }), MalformedRecord, EmptyStatement, UnexpectedTransactionText, NestedTransactionScalar, InvalidSignon, UnnormalizedContext, InvalidContextCharacter, InvalidUid, InvalidWrapper, InvalidCurrency(Excerpt), MissingAccountId, MissingBankId, InvalidStartTimestamp(Excerpt), InvalidEndTimestamp(Excerpt), UnnormalizedTransaction, ExpectedExtensionElement, DuplicateExtension(Str), ExtensionOrder(Str), InvalidTransactionCharacter, InvalidTransactionType(Str), InvalidPostedTimestamp(Excerpt), InvalidAmount(Excerpt), MissingTransactionId, InvalidBalance(Balance), InvalidExtensionText(Str), InvalidExtensionName(Str), ExtensionAttributesUnsupported, UnknownSgmlExtension(Str), UnrepresentableCharacter(Str), HeaderChanged, TransactionOutsideList, BalanceOutsideStatement, BalanceOrder, StatementEnded, InvalidAggregate, UnsupportedScalarField(Str), FieldAttributesUnsupported, MissingXmlDeclaration, ContextOrder(Str), SignonOrder, UnsuccessfulResponse(Str), DuplicateField(Str)]
Error : Diagnostic(Problem)
Syntax : [Xml203, Sgml102]

Writer wire syntax; readers detect either family.

TextEncoding : [Auto, Utf8, Windows1252]

Auto honours the header and defaults to UTF-8.

Props

:= { syntax : [Auto, Xml, Sgml] ?? Auto, encoding : TextEncoding ?? Auto, max_token_bytes : U64 ?? 65_536, max_record_bytes : U64 ?? 4_194_304, max_depth : U64 ?? 64, max_fields : U64 ?? 1024, errors : RecoveryProps ?? {} }

Bounded parser resources; limits are terminal errors.

WriteProps

:= { syntax : Syntax ?? Xml203, encoding : TextEncoding ?? Utf8, max_record_bytes : U64 ?? 4_194_304, chunk_bytes : U64 ?? 65_536 }

XML 2.03 and UTF-8 are the default output.

Account : { bank_id : Str, branch_id : Str, account_id : Str, account_type : Str, key : Str }

Account identifiers preserve leading zeroes. Empty optional fields are absent.

Status : { code : Str, severity : Str, message : Str }

Statement metadata emitted before its first transaction or balance.

Header : { old_uid : Str, new_uid : Str, server_date : Str, language : Str, org : Str, fid : Str }

Supported response metadata preserved across dialect conversion.

Context : { kind : [Bank, CreditCard], currency : Str, account : Account, start : Str, end : Str, transaction_id : Str, status : Status, header : Header }

Statement wrapper identity and successful response status.

Transaction : { type : Str, posted : Str, amount : Str, id : Str, name : Str, memo : Str, check_number : Str, extensions : List(Node) }

Exact financial values with supported extension elements in source order.

Balance : { amount : Str, as_of : Str }

Exact amount and timestamp.

Event : [StatementStart(Context), Transaction(Transaction), LedgerBalance(Balance), AvailableBalance(Balance), StatementEnd]

Bounded logical reader/writer items.

Statement : { context : Context, transactions : List(Transaction), ledger_balance : Try(Balance, [Missing]), available_balance : Try(Balance, [Missing]) }

Whole-document convenience representation.

ValidationProps

:= { source : Str, name : Str ?? "<literal>", options : Props ?? {} }

Compilation-time validation options.