Skip to content

Commit 35abbb7

Browse files
committed
Add CampaignUpdated event message
1 parent c03cd09 commit 35abbb7

File tree

3 files changed

+45
-20
lines changed

3 files changed

+45
-20
lines changed

src/eventMessage.ts

-18
This file was deleted.

src/events.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {ContactV2, PrivacyV2, Campaign as CampaignFragment, ActionV2, ActionPage, Tracking} from './actionMessage'
2+
3+
export type EmailStatusEvent = {
4+
eventType: 'email_status';
5+
action?: ActionV2;
6+
actionPage?: ActionPage;
7+
campaign?: CampaignFragment;
8+
supporter: {
9+
contact: ContactV2;
10+
privacy: PrivacyV2;
11+
},
12+
tracking?: Tracking;
13+
}
14+
15+
export type EventMessageV2 = {
16+
schema: 'proca:event:2',
17+
timestamp: string,
18+
} & EmailStatusEvent
19+
20+
21+
type Json = Record<string, any>;
22+
23+
type Campaign = {
24+
config: Json; // JSON object with arbitrary structure
25+
contactSchema: string; // e.g., "basic"
26+
externalId: number;
27+
id: number;
28+
name: string;
29+
org: {
30+
name: string;
31+
title: string;
32+
};
33+
title: string;
34+
};
35+
36+
export type CampaignUpdateEvent = {
37+
campaign: Campaign;
38+
campaignId: number;
39+
eventType: string; // e.g., "campaign_updated"
40+
orgId: number;
41+
schema: string; // e.g., "proca:event:2"
42+
timestamp: string; // ISO8601 format
43+
};

src/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { KeyStore } from "@proca/crypto";
22
import { ActionMessage } from "./actionMessage";
3-
import { EventMessageV2 } from "./eventMessage";
3+
import { EventMessageV2, CampaignUpdated } from "./events";
44

55
export type DecryptOpts = {
66
decrypt?: boolean;
@@ -18,7 +18,7 @@ export type SyncResult = {
1818
processed: boolean;
1919
}
2020

21-
export type SyncCallback = (action: ActionMessage | EventMessageV2) => Promise<SyncResult | boolean>;
21+
export type SyncCallback = (action: ActionMessage | EventMessageV2 | CampaignUpdated) => Promise<SyncResult | boolean>;
2222

2323
export type Counters = {
2424
ack: number;

0 commit comments

Comments
 (0)