Repository navigation
feat(realtime): Broadcast facade, firebase-database/polling/memory transports and device push - #10
Merged
Merged
Conversation
…y transports and device push - Broadcast facade: channel authorization registry shared by every transport, broadcast() for arbitrary events, handleAuth(), clientConfig(), and routes() registering POST /realtime/auth and GET /realtime/config. - New transports on server and client: firebase-database (Realtime Database channels with time-limited grants and bounded prune), signal-only polling, and memory for tests. - Device push separate from streaming via drivers.realtime.push, with a push_tokens resolver, .push(false), .devices(tokens) and result.push. Unset push keeps device delivery on for the firebase transport. - Self-hosted Pusher-protocol servers (soketi) via host/port and wsHost/wsPort. - Client: onPoll(), deviceToken(), transportName. - Fix UserNotificationCenter.send() broadcasting to push tokens instead of the user channel, db().broadcast() not chaining, and the Pusher auth route returning 201 and registering H3 on the Express package. - Templates, notifications guide and changelog updated.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends
@arkstack/notificationsand@arkstack/realtimeso apps can run all their realtime on Arkstack, not only per-user notifications.Added
Broadcastfacade (@arkstack/notifications)Broadcast.channel('private-team.{teamId}', (user, params) => ...). Placeholders match one dot-free segment, the first matching rule decides, and unmatched channels are denied. The per-user channel stays allowed for its own user.broadcast()for arbitrary events,handleAuth()for custom auth routes (e.g. guest tokens),clientConfig(), androutes()registeringPOST /realtime/authandGET /realtime/config.firebase-database: Realtime Database channels. Per-user grants expire after a TTL and are checked by security rules;prune()deletes old events in bounded batches.polling: signal-only. Clients refetch throughRealtimeClient.onPoll().memory: for tests. Shared onglobalThisso it works across module graphs.drivers.realtime.push: 'firebase'. Tokens come from apush_tokensresolver oruser.pushTokens..push(false)skips the push,.devices(tokens)targets specific devices, and the multicast outcome is onresult.push.deviceToken().transports.pusher.host/porton the server,wsHost/wsPorton the client.Fixed
UserNotificationCenter.send()andNotification.db().broadcast()broadcast on the user's channel. Before, they used push tokens as channel names, so users without tokens got nothing.Notification.db().broadcast()now returns the builder, so the documented chain works.registerAuthRoute():@arkstack/driver-h3;Compatibility
drivers.realtime.pushis unset and the transport isfirebase, notifications still reach users' devices.PUSHER_HOST/PUSHER_PORTare now read from env.RealtimeDriverNameandRealtimeTransportNamegain members, so exhaustive switches over them need new cases.Docs
Test plan
vitest run: 73 files, all passing.tsc --noEmitand eslint clean for both packages; both packages build.deviceToken().