@taico/events 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@taico/events",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "private": false,
6
+ "license": "MIT",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.build.json"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "^5.6.3"
22
+ }
23
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './types/task-events.js';
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Task Wire Event Types for WebSocket Communication
3
+ *
4
+ * These types define the structure of events sent between backend and frontend
5
+ * via WebSocket for the Tasks domain. They serve as a contract between the
6
+ * backend gateway and frontend consumers.
7
+ *
8
+ * Import these types in both backend (for emission) and frontend (for reception)
9
+ * to ensure type safety across the wire protocol.
10
+ */
11
+
12
+ /**
13
+ * Wire event names for Tasks domain
14
+ * These are the stable, external event identifiers sent over the wire protocol.
15
+ */
16
+ export const TaskWireEvents = {
17
+ TASK_CREATED: 'task.created',
18
+ TASK_UPDATED: 'task.updated',
19
+ TASK_DELETED: 'task.deleted',
20
+ TASK_ASSIGNED: 'task.assigned',
21
+ TASK_STATUS_CHANGED: 'task.status_changed',
22
+ TASK_COMMENTED: 'task.commented',
23
+ INPUT_REQUEST_ANSWERED: 'input.request.answered',
24
+ TASK_ACTIVITY: 'task.activity',
25
+ TASK_ACTIVITY_POST: 'task.activity.post',
26
+ } as const;
27
+
28
+ export type TaskWireEventName =
29
+ (typeof TaskWireEvents)[keyof typeof TaskWireEvents];
30
+
31
+ /**
32
+ * Base actor structure included in all events
33
+ */
34
+ export interface EventActor {
35
+ id: string;
36
+ type?: string;
37
+ slug?: string;
38
+ displayName?: string;
39
+ avatarUrl?: string | null;
40
+ }
41
+
42
+ /**
43
+ * Actor structure for minimal event payloads
44
+ */
45
+ export interface MinimalEventActor {
46
+ id: string;
47
+ }
48
+
49
+ /**
50
+ * Task structure as sent over the wire
51
+ * Matches TaskResponseDto from backend
52
+ */
53
+ export interface TaskWirePayload {
54
+ id: string;
55
+ name: string;
56
+ description: string;
57
+ status: 'NOT_STARTED' | 'IN_PROGRESS' | 'FOR_REVIEW' | 'DONE';
58
+ assignee: string | null;
59
+ assigneeActor: EventActor | null;
60
+ sessionId: string;
61
+ comments: CommentWirePayload[];
62
+ inputRequests: InputRequestWirePayload[];
63
+ tags: TagWirePayload[];
64
+ createdByActor: EventActor;
65
+ dependsOnIds: string[];
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ }
69
+
70
+ /**
71
+ * Comment structure as sent over the wire
72
+ * Matches CommentResponseDto from backend
73
+ */
74
+ export interface CommentWirePayload {
75
+ id: string;
76
+ taskId: string;
77
+ commenterName: string;
78
+ commenterActor: EventActor | null;
79
+ content: string;
80
+ createdAt: string;
81
+ }
82
+
83
+ /**
84
+ * Input request structure as sent over the wire
85
+ * Matches InputRequestResponseDto from backend
86
+ */
87
+ export interface InputRequestWirePayload {
88
+ id: string;
89
+ taskId: string;
90
+ askedByActorId: string;
91
+ assignedToActorId: string;
92
+ question: string;
93
+ answer: string | null;
94
+ resolvedAt: string | null;
95
+ createdAt: string;
96
+ updatedAt: string;
97
+ }
98
+
99
+ /**
100
+ * Tag structure as sent over the wire
101
+ * Matches TagResponseDto from backend
102
+ */
103
+ export interface TagWirePayload {
104
+ id: string;
105
+ name: string;
106
+ color?: string;
107
+ }
108
+
109
+ /**
110
+ * Task created event
111
+ * Emitted when a new task is created
112
+ */
113
+ export interface TaskCreatedWireEvent {
114
+ payload: TaskWirePayload;
115
+ actor: MinimalEventActor;
116
+ }
117
+
118
+ /**
119
+ * Task updated event
120
+ * Emitted when a task is updated
121
+ */
122
+ export interface TaskUpdatedWireEvent {
123
+ payload: TaskWirePayload;
124
+ actor: MinimalEventActor;
125
+ }
126
+
127
+ /**
128
+ * Task deleted event
129
+ * Emitted when a task is deleted
130
+ */
131
+ export interface TaskDeletedWireEvent {
132
+ payload: {
133
+ taskId: string;
134
+ };
135
+ actor: MinimalEventActor;
136
+ }
137
+
138
+ /**
139
+ * Task assigned event
140
+ * Emitted when a task is assigned to an actor
141
+ */
142
+ export interface TaskAssignedWireEvent {
143
+ payload: TaskWirePayload;
144
+ actor: MinimalEventActor;
145
+ }
146
+
147
+ /**
148
+ * Task status changed event
149
+ * Emitted when a task's status changes
150
+ */
151
+ export interface TaskStatusChangedWireEvent {
152
+ payload: TaskWirePayload;
153
+ actor: MinimalEventActor;
154
+ }
155
+
156
+ /**
157
+ * Comment added event
158
+ * Emitted when a comment is added to a task
159
+ */
160
+ export interface TaskCommentedWireEvent {
161
+ payload: CommentWirePayload;
162
+ actor: MinimalEventActor;
163
+ }
164
+
165
+ /**
166
+ * Input request answered event
167
+ * Emitted when an input request is answered
168
+ */
169
+ export interface InputRequestAnsweredWireEvent {
170
+ payload: InputRequestWirePayload;
171
+ actor: MinimalEventActor;
172
+ }
173
+
174
+ /**
175
+ * Task activity event (ephemeral)
176
+ * Emitted for real-time activity updates (e.g., agent working on task)
177
+ */
178
+ export interface TaskActivityWireEvent {
179
+ taskId: string;
180
+ kind: string;
181
+ message?: string;
182
+ ts: number;
183
+ by?: string;
184
+ }
185
+
186
+ /**
187
+ * Union type of all task wire events
188
+ */
189
+ export type TaskWireEvent =
190
+ | TaskCreatedWireEvent
191
+ | TaskUpdatedWireEvent
192
+ | TaskDeletedWireEvent
193
+ | TaskAssignedWireEvent
194
+ | TaskStatusChangedWireEvent
195
+ | TaskCommentedWireEvent
196
+ | InputRequestAnsweredWireEvent;
197
+
198
+ /**
199
+ * Type guards for event identification
200
+ */
201
+ export function isTaskCreatedEvent(
202
+ event: TaskWireEvent,
203
+ ): event is TaskCreatedWireEvent {
204
+ return 'payload' in event && 'id' in event.payload && 'name' in event.payload;
205
+ }
206
+
207
+ export function isTaskDeletedEvent(
208
+ event: TaskWireEvent,
209
+ ): event is TaskDeletedWireEvent {
210
+ return 'payload' in event && 'taskId' in event.payload;
211
+ }
212
+
213
+ export function isTaskCommentedEvent(
214
+ event: TaskWireEvent,
215
+ ): event is TaskCommentedWireEvent {
216
+ return (
217
+ 'payload' in event && 'taskId' in event.payload && 'content' in event.payload
218
+ );
219
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "declaration": true,
6
+ "emitDeclarationOnly": false,
7
+ "noEmit": false,
8
+ "rootDir": "src",
9
+ },
10
+ "include": [
11
+ "src/**/*",
12
+ ],
13
+ }