forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.types.ts
More file actions
47 lines (42 loc) · 1.58 KB
/
Copy pathevents.types.ts
File metadata and controls
47 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Message contract for the campaign WebSocket gateway.
*
* Kept in sync by hand with client/src/lib/websocket/events.types.ts (the
* repo has no shared-package/workspace tooling yet, so this is the
* source-of-truth copy — update both together).
*/
/** Normalized event types broadcast to subscribed rooms. */
export type CampaignEventType =
| 'campaign.escrow_created'
| 'campaign.invested'
| 'campaign.funded'
| 'campaign.tranches_configured'
| 'campaign.tranche_released'
| 'campaign.harvest_reported'
| 'campaign.failed'
| 'campaign.return_claimed'
| 'campaign.refund_claimed'
| 'campaign.dispute_opened'
| 'campaign.dispute_resolved'
| 'campaign.settled'
| 'campaign.created'
| 'campaign.escrow_linked'
| 'campaign.status_updated';
export interface CampaignEventPayload {
type: CampaignEventType;
campaignId: string;
data: Record<string, unknown>;
}
/** Server -> client event name carrying a CampaignEventPayload. */
export const CAMPAIGN_EVENT = 'campaign:event';
/** Client -> server: join the room for one campaign's updates. */
export const SUBSCRIBE_CAMPAIGN = 'subscribe:campaign';
/** Client -> server: leave a campaign room. */
export const UNSUBSCRIBE_CAMPAIGN = 'unsubscribe:campaign';
/** Client -> server: join the platform-wide activity feed room. */
export const SUBSCRIBE_ACTIVITY = 'subscribe:activity';
/** Client -> server: leave the activity feed room. */
export const UNSUBSCRIBE_ACTIVITY = 'unsubscribe:activity';
export const campaignRoom = (campaignId: string): string =>
`campaign:${campaignId}`;
export const ACTIVITY_ROOM = 'activity';