@pixerate/schemas 1.26.0 → 1.27.0

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.
@@ -0,0 +1,275 @@
1
+ // src/realtime.ts
2
+ import { z } from "zod";
3
+ var PresenceColorSchema = z.enum([
4
+ "slate",
5
+ "gray",
6
+ "zinc",
7
+ "neutral",
8
+ "stone",
9
+ "red",
10
+ "orange",
11
+ "amber",
12
+ "yellow",
13
+ "lime",
14
+ "green",
15
+ "emerald",
16
+ "teal",
17
+ "cyan",
18
+ "sky",
19
+ "blue",
20
+ "indigo",
21
+ "violet",
22
+ "purple",
23
+ "fuchsia",
24
+ "pink",
25
+ "rose"
26
+ ]);
27
+ var PresenceStatusSchema = z.enum([
28
+ "online",
29
+ "idle",
30
+ "away",
31
+ "busy",
32
+ "offline",
33
+ "planning",
34
+ "thinking",
35
+ "executing_tool",
36
+ "waiting_for_input",
37
+ "waiting_for_agent",
38
+ "streaming",
39
+ "paused",
40
+ "error"
41
+ ]);
42
+ var ActorTypeSchema = z.enum(["human", "agent", "system"]);
43
+ var AgentActorMetadataSchema = z.object({
44
+ role: z.string().optional(),
45
+ parentAgentId: z.string().optional(),
46
+ runId: z.string().optional(),
47
+ currentTask: z.string().optional()
48
+ });
49
+ var PresenceUserSchema = z.object({
50
+ id: z.string(),
51
+ username: z.string().optional(),
52
+ email: z.string().optional(),
53
+ avatarUrl: z.string().optional(),
54
+ actorType: ActorTypeSchema.optional(),
55
+ color: PresenceColorSchema.optional().default("blue"),
56
+ status: PresenceStatusSchema.optional().default("online"),
57
+ agent: AgentActorMetadataSchema.optional(),
58
+ lastSeen: z.number().int().positive().optional().default(() => Date.now()),
59
+ metadata: z.record(z.unknown()).optional().default({})
60
+ });
61
+ var ViewportTransformSchema = z.object({
62
+ zoom: z.number().default(1),
63
+ panX: z.number().default(0),
64
+ panY: z.number().default(0)
65
+ });
66
+ var CursorPositionSchema = z.object({
67
+ userId: z.string(),
68
+ x: z.number(),
69
+ y: z.number(),
70
+ lastUpdate: z.number().int().positive().default(() => Date.now()),
71
+ username: z.string().optional(),
72
+ avatarUrl: z.string().optional(),
73
+ color: PresenceColorSchema.optional(),
74
+ viewport: ViewportTransformSchema.optional()
75
+ });
76
+ var PresenceStateSchema = z.object({
77
+ roomId: z.string(),
78
+ presences: z.record(PresenceUserSchema).default({}),
79
+ cursors: z.record(CursorPositionSchema).default({})
80
+ });
81
+ var ViewingIndicatorSchema = z.object({
82
+ userId: z.string(),
83
+ resourceId: z.string(),
84
+ resourceType: z.enum(["board", "document", "item", "node", "canvas", "page", "field"]).default("board"),
85
+ username: z.string().optional(),
86
+ avatarUrl: z.string().optional(),
87
+ color: PresenceColorSchema.optional(),
88
+ lastSeen: z.number().int().positive().default(() => Date.now())
89
+ });
90
+ var TypingIndicatorSchema = z.object({
91
+ userId: z.string(),
92
+ resourceId: z.string(),
93
+ fieldName: z.string().optional(),
94
+ username: z.string().optional(),
95
+ avatarUrl: z.string().optional(),
96
+ color: PresenceColorSchema.optional(),
97
+ isTyping: z.boolean().default(true),
98
+ timestamp: z.number().int().positive().default(() => Date.now())
99
+ });
100
+ var FieldPresenceSchema = z.object({
101
+ fieldId: z.string(),
102
+ focusedBy: z.array(PresenceUserSchema).default([]),
103
+ typingUsers: z.array(TypingIndicatorSchema).default([])
104
+ });
105
+ var LockStatusSchema = z.enum(["unlocked", "locked", "expired", "claimed"]);
106
+ var RecordLockInfoSchema = z.object({
107
+ userId: z.string(),
108
+ username: z.string().optional(),
109
+ clientId: z.string().optional(),
110
+ avatarUrl: z.string().optional()
111
+ });
112
+ var RecordLockSchema = z.object({
113
+ id: z.string(),
114
+ resourceId: z.string(),
115
+ resourceType: z.string().default("record"),
116
+ lockedBy: RecordLockInfoSchema,
117
+ lockedAt: z.number().int().positive(),
118
+ expiresAt: z.number().int().positive(),
119
+ leaseDurationSeconds: z.number().int().positive().default(60),
120
+ status: LockStatusSchema.default("locked"),
121
+ metadata: z.record(z.unknown()).optional().default({})
122
+ });
123
+ var LockClaimRequestSchema = z.object({
124
+ resourceId: z.string(),
125
+ resourceType: z.string().default("record"),
126
+ userId: z.string(),
127
+ username: z.string().optional(),
128
+ clientId: z.string().optional(),
129
+ avatarUrl: z.string().optional(),
130
+ leaseDurationSeconds: z.number().int().positive().optional().default(60),
131
+ force: z.boolean().optional().default(false),
132
+ metadata: z.record(z.unknown()).optional().default({})
133
+ });
134
+ var LockReleaseRequestSchema = z.object({
135
+ resourceId: z.string(),
136
+ resourceType: z.string().default("record"),
137
+ userId: z.string(),
138
+ clientId: z.string().optional(),
139
+ force: z.boolean().optional().default(false)
140
+ });
141
+ var LockHeartbeatRequestSchema = z.object({
142
+ resourceId: z.string(),
143
+ resourceType: z.string().default("record"),
144
+ userId: z.string(),
145
+ clientId: z.string().optional(),
146
+ leaseDurationSeconds: z.number().int().positive().optional().default(60)
147
+ });
148
+ var ActivityActionTypeSchema = z.enum([
149
+ "join",
150
+ "leave",
151
+ "create",
152
+ "update",
153
+ "delete",
154
+ "lock",
155
+ "unlock",
156
+ "claim",
157
+ "comment",
158
+ "generate",
159
+ "star",
160
+ "unstar",
161
+ "custom",
162
+ "agent:thought",
163
+ "agent:plan_updated",
164
+ "agent:tool_start",
165
+ "agent:tool_end",
166
+ "agent:approval_requested",
167
+ "agent:approval_resolved",
168
+ "agent:error"
169
+ ]);
170
+ var ActivityActorSchema = z.object({
171
+ userId: z.string(),
172
+ username: z.string().optional(),
173
+ avatarUrl: z.string().optional(),
174
+ actorType: ActorTypeSchema.optional(),
175
+ role: z.string().optional(),
176
+ color: PresenceColorSchema.optional()
177
+ });
178
+ var ActivityEventSchema = z.object({
179
+ id: z.string(),
180
+ roomId: z.string().optional(),
181
+ entityId: z.string().optional(),
182
+ entityType: z.string().optional(),
183
+ action: ActivityActionTypeSchema,
184
+ actor: ActivityActorSchema,
185
+ title: z.string().optional(),
186
+ description: z.string().optional(),
187
+ payload: z.record(z.unknown()).optional(),
188
+ timestamp: z.number().int().positive().default(() => Date.now()),
189
+ metadata: z.record(z.unknown()).optional()
190
+ });
191
+ var ActivityStreamFilterSchema = z.object({
192
+ roomId: z.string().optional(),
193
+ entityId: z.string().optional(),
194
+ entityType: z.string().optional(),
195
+ actorId: z.string().optional(),
196
+ action: z.union([ActivityActionTypeSchema, z.array(ActivityActionTypeSchema)]).optional(),
197
+ since: z.number().int().positive().optional(),
198
+ limit: z.number().int().positive().optional().default(50)
199
+ });
200
+ var OTTextOpTypeSchema = z.enum(["retain", "insert", "delete"]);
201
+ var OTTextOpSchema = z.object({
202
+ type: OTTextOpTypeSchema,
203
+ count: z.number().int().nonnegative().optional(),
204
+ text: z.string().optional(),
205
+ attributes: z.record(z.unknown()).optional()
206
+ });
207
+ var OTJsonOpTypeSchema = z.enum(["set", "delete", "insert", "move", "replace"]);
208
+ var OTJsonOpSchema = z.object({
209
+ path: z.array(z.union([z.string(), z.number()])),
210
+ type: OTJsonOpTypeSchema,
211
+ value: z.unknown().optional(),
212
+ prevValue: z.unknown().optional()
213
+ });
214
+ var OTOperationSchema = z.object({
215
+ id: z.string(),
216
+ docId: z.string(),
217
+ revision: z.number().int().nonnegative(),
218
+ authorId: z.string(),
219
+ textOps: z.array(OTTextOpSchema).optional(),
220
+ jsonOps: z.array(OTJsonOpSchema).optional(),
221
+ timestamp: z.number().int().positive().default(() => Date.now()),
222
+ metadata: z.record(z.unknown()).optional().default({})
223
+ });
224
+ var OTRevisionSchema = z.object({
225
+ docId: z.string(),
226
+ revision: z.number().int().nonnegative(),
227
+ snapshot: z.unknown(),
228
+ appliedOps: z.array(OTOperationSchema).default([]),
229
+ updatedAt: z.number().int().positive().default(() => Date.now())
230
+ });
231
+ var CRDTSnapshotSchema = z.object({
232
+ docId: z.string(),
233
+ vectorClock: z.record(z.number().int().nonnegative()).default({}),
234
+ state: z.record(z.unknown()).default({}),
235
+ updatedAt: z.number().int().positive().default(() => Date.now())
236
+ });
237
+ var REALTIME_SUBSCRIBE_STATES = /* @__PURE__ */ ((REALTIME_SUBSCRIBE_STATES2) => {
238
+ REALTIME_SUBSCRIBE_STATES2["SUBSCRIBED"] = "SUBSCRIBED";
239
+ REALTIME_SUBSCRIBE_STATES2["CLOSED"] = "CLOSED";
240
+ REALTIME_SUBSCRIBE_STATES2["TIMED_OUT"] = "TIMED_OUT";
241
+ REALTIME_SUBSCRIBE_STATES2["CHANNEL_ERROR"] = "CHANNEL_ERROR";
242
+ return REALTIME_SUBSCRIBE_STATES2;
243
+ })(REALTIME_SUBSCRIBE_STATES || {});
244
+
245
+ export {
246
+ PresenceColorSchema,
247
+ PresenceStatusSchema,
248
+ ActorTypeSchema,
249
+ AgentActorMetadataSchema,
250
+ PresenceUserSchema,
251
+ ViewportTransformSchema,
252
+ CursorPositionSchema,
253
+ PresenceStateSchema,
254
+ ViewingIndicatorSchema,
255
+ TypingIndicatorSchema,
256
+ FieldPresenceSchema,
257
+ LockStatusSchema,
258
+ RecordLockInfoSchema,
259
+ RecordLockSchema,
260
+ LockClaimRequestSchema,
261
+ LockReleaseRequestSchema,
262
+ LockHeartbeatRequestSchema,
263
+ ActivityActionTypeSchema,
264
+ ActivityActorSchema,
265
+ ActivityEventSchema,
266
+ ActivityStreamFilterSchema,
267
+ OTTextOpTypeSchema,
268
+ OTTextOpSchema,
269
+ OTJsonOpTypeSchema,
270
+ OTJsonOpSchema,
271
+ OTOperationSchema,
272
+ OTRevisionSchema,
273
+ CRDTSnapshotSchema,
274
+ REALTIME_SUBSCRIBE_STATES
275
+ };