Skip to content

Commit 2b9a35b

Browse files
committed
add types for event-subscriptions
1 parent c33f848 commit 2b9a35b

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
type EventSubscriptionEvent<
2+
Service extends string,
3+
Type extends string,
4+
Source,
5+
Payload = {},
6+
> = {
7+
type: `cf.${Service}.${Type}`;
8+
source: { service: Service } & Source;
9+
payload: Payload;
10+
metadata: {
11+
accountId: string;
12+
eventId: string;
13+
eventSubscriptionId: string;
14+
eventTimestamp: string; // RFC3339 timestamp
15+
eventSchemaVersion: 1;
16+
};
17+
};
18+
19+
// Super Slurper
20+
export type EventMessageSuperSlurper =
21+
| EventSubscriptionEvent<"superSlurper", "jobStarted", { jobId: string }>
22+
| EventSubscriptionEvent<"superSlurper", "jobPaused", { jobId: string }>
23+
| EventSubscriptionEvent<"superSlurper", "jobResumed", { jobId: string }>
24+
| EventSubscriptionEvent<
25+
"superSlurper",
26+
"jobFinished",
27+
{ jobId: string },
28+
{
29+
totalObjectsCount: number;
30+
migratedObjectsCount: number;
31+
failedObjectsCount: number;
32+
}
33+
>
34+
| EventSubscriptionEvent<"superSlurper", "jobAborted", { jobId: string }>;
35+
36+
// Workflows
37+
type SubscriptionEventSourceWorkflows = {
38+
workflowId: string;
39+
workflowName: string;
40+
versionId: string;
41+
instanceId: string;
42+
};
43+
export type EventMessageWorkflows =
44+
| EventSubscriptionEvent<
45+
"workflows",
46+
"instanceQueued",
47+
SubscriptionEventSourceWorkflows
48+
>
49+
| EventSubscriptionEvent<
50+
"workflows",
51+
"instanceStarted",
52+
SubscriptionEventSourceWorkflows
53+
>
54+
| EventSubscriptionEvent<
55+
"workflows",
56+
"instancePaused",
57+
SubscriptionEventSourceWorkflows
58+
>
59+
| EventSubscriptionEvent<
60+
"workflows",
61+
"instanceResumed",
62+
SubscriptionEventSourceWorkflows
63+
>
64+
| EventSubscriptionEvent<
65+
"workflows",
66+
"instanceErrored",
67+
SubscriptionEventSourceWorkflows
68+
>
69+
| EventSubscriptionEvent<
70+
"workflows",
71+
"instanceTerminated",
72+
SubscriptionEventSourceWorkflows
73+
>
74+
| EventSubscriptionEvent<
75+
"workflows",
76+
"instanceFinished",
77+
SubscriptionEventSourceWorkflows
78+
>;
79+
80+
export type EventMessage = EventMessageSuperSlurper | EventMessageWorkflows;

0 commit comments

Comments
 (0)