Skip to main content

Package

nu_pos_sync_protocol/ — Shared TypeScript package consumed by the hub (@nu/sync-protocol).

Message types

All WebSocket communication uses JSON-encoded messages with a type discriminator field.

Terminal to hub (13 message types)

Hub to terminal (19 message types)

OrderSnapshot

The canonical representation of an order’s state, transmitted in ORDER_SNAPSHOT, ORDER_UPDATED, CONFLICT, and LEASE_REVOKED messages.

OrderLineSnapshot

Voided lines (isVoided: true) are included in snapshots for audit purposes but filtered out before forwarding to Odoo.

FiscalData

Returned in ORDER_FINALIZED messages for Dominican tax (NCF/DGII) integration:

Protocol constants

Defined in nu_pos_sync_protocol/src/constants.ts:

Validation

Every message is validated at runtime using Zod schemas (validators.ts). The hub validates incoming terminal messages before routing; the frontend can optionally validate hub messages.
The schemas use z.discriminatedUnion on the type field for efficient runtime dispatch.

Connection lifecycle