firstlightui / chat-protocol
The wire contract for Firstlight Chat: HTTP endpoints, broadcast events and push payloads, with shared PHP DTOs and JSON fixtures.
Requires
- php: ^8.4
Requires (Dev)
- pestphp/pest: ^3.0|^4.0|^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The wire contract between a Firstlight Chat server and its mobile clients.
spec/v1.md: identity, HTTP endpoints, delivery and read receipts, broadcasts, push payloads, sync and errors.fixtures/v1: an example of every request, response, broadcast and push.firstlightui/chat-serverandfirstlightui/chattest their output against these files.
The controls that display a conversation, <firstlight:chat> and
<firstlight:chat-composer>, are part of
Firstlight and work with any
backend. This protocol is one way to feed them.
PHP
composer require firstlightui/chat-protocol
Plain PHP 8.4, no framework. Every object, request, response, broadcast and
push has a readonly class under FirstlightUI\ChatProtocol with
fromArray(), which throws InvalidPayload naming the field that breaks the
spec, and toArray(), which writes exactly the fixture's shape.
Receipts::status() and Receipts::readBy() apply the spec's delivery-status
rule, and ChatPush::fromNotificationData() reads the chat object from an
APNs or FCM payload.
Version 1 is a draft.
License
MIT. See LICENSE.