Skip to content

v0.1.6 — debug logger, branded isInvoiceError, MockProvider fidelity

Latest

Choose a tag to compare

@linyiru linyiru released this 18 Jun 22:13
· 1 commit to main since this release

Minor release across all packages — observability, error-guard robustness, and a higher-fidelity test double. No breaking changes.

Highlights

  • Opt-in request tracing. Set debug on any provider config to receive metadata-only trace events (provider / method / url / status / durationMs / error) for each HTTP call. Every adapter routes its fetch through the new core tracedFetch — a zero-overhead passthrough when debug is unset. Request/response bodies are never logged (encrypted on the wire for ezPay/ECPay, potentially PII for the others; wrap the fetch override to capture those).
  • isInvoiceError is now brand-based. It checks a globally-registered Symbol.for brand instead of instanceof, so it still narrows correctly when two copies of the package are loaded (dual ESM/CJS, transitive version skew).
  • Higher-fidelity MockProvider. Configurable capabilities (a non-TWD currency is rejected with UNSUPPORTED when FOREIGN_CURRENCY is omitted, matching a real domestic adapter), a tighter state machine (allowance on a voided invoice → CONFLICT; voidAllowance checks the allowance exists → NOT_FOUND), validation through the shared parseInput, and failNext(error) to inject a one-shot failure for exercising error paths.

New exports (@paid-tw/einvoice)

tracedFetch, InvoiceDebugEvent, InvoiceDebugLogger; MockProviderOptions.capabilities and MockProvider#failNext; debug on BaseProviderConfig.

Versions

Package Version
@paid-tw/einvoice 0.4.0
@paid-tw/einvoice-amego 0.4.0
@paid-tw/einvoice-ecpay 0.4.0
@paid-tw/einvoice-ezpay 0.4.0
@paid-tw/einvoice-ezpay-crossborder 0.2.0
@paid-tw/einvoice-ezreceipt 0.2.0