verani 0.5.3 → 0.5.4

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/dist/verani.d.cts CHANGED
@@ -24,6 +24,80 @@ interface RpcBroadcastOptions {
24
24
  /** Only send to specific client IDs */
25
25
  clientIds?: string[];
26
26
  }
27
+ /**
28
+ * Actor stub interface returned by .get() method.
29
+ * Provides RPC access to actor methods that can be called remotely.
30
+ *
31
+ * Note: RPC methods return Promises even if the underlying method is synchronous.
32
+ * Methods that return non-serializable types (like WebSocket[] or DurableObjectStorage)
33
+ * are excluded from this interface.
34
+ */
35
+ interface ActorStub {
36
+ /**
37
+ * Standard fetch method for handling HTTP requests and WebSocket upgrades
38
+ */
39
+ fetch(request: Request): Promise<Response>;
40
+ /**
41
+ * Socket.IO-like emit API: Emit an event to a specific channel via RPC.
42
+ * @param channel - Channel name to emit to
43
+ * @param event - Event name
44
+ * @param data - Event data
45
+ * @returns Promise resolving to the number of connections that received the message
46
+ * @example
47
+ * ```typescript
48
+ * await stub.emitToChannel("default", "announcement", { text: "Hello!" });
49
+ * ```
50
+ */
51
+ emitToChannel(channel: string, event: string, data?: any): Promise<number>;
52
+ /**
53
+ * Socket.IO-like emit API: Emit an event to a specific user (all their sessions) via RPC.
54
+ * @param userId - User ID to emit to
55
+ * @param event - Event name
56
+ * @param data - Event data
57
+ * @returns Promise resolving to the number of sessions that received the message
58
+ * @example
59
+ * ```typescript
60
+ * await stub.emitToUser("alice", "notification", { message: "Hello!" });
61
+ * ```
62
+ */
63
+ emitToUser(userId: string, event: string, data?: any): Promise<number>;
64
+ /**
65
+ * @deprecated Use `emitToUser()` instead for Socket.IO-like API.
66
+ * Sends a message to a specific user (all their sessions) via RPC.
67
+ * @param userId - The user ID to send to
68
+ * @param channel - The channel to send to
69
+ * @param data - Message data
70
+ * @returns Promise resolving to the number of sessions that received the message
71
+ */
72
+ sendToUser(userId: string, channel: string, data?: any): Promise<number>;
73
+ /**
74
+ * @deprecated Use `emitToChannel()` instead for Socket.IO-like API.
75
+ * Broadcasts a message to all connections in a channel via RPC.
76
+ * Note: The `except` option from BroadcastOptions is not available over RPC
77
+ * since WebSocket cannot be serialized.
78
+ * @param channel - The channel to broadcast to
79
+ * @param data - The data to send
80
+ * @param opts - Broadcast options (filtering by userIds or clientIds)
81
+ * @returns Promise resolving to the number of connections that received the message
82
+ */
83
+ broadcast(channel: string, data: any, opts?: RpcBroadcastOptions): Promise<number>;
84
+ /**
85
+ * Gets the total number of active sessions via RPC.
86
+ * @returns Promise resolving to the number of connected WebSockets
87
+ */
88
+ getSessionCount(): Promise<number>;
89
+ /**
90
+ * Gets all unique user IDs currently connected via RPC.
91
+ * @returns Promise resolving to an array of unique user IDs
92
+ */
93
+ getConnectedUserIds(): Promise<string[]>;
94
+ /**
95
+ * Removes all WebSocket sessions that are not in OPEN state via RPC.
96
+ * This prevents stale connections from accumulating in memory.
97
+ * @returns Promise resolving to the number of sessions cleaned up
98
+ */
99
+ cleanupStaleSessions(): Promise<number>;
100
+ }
27
101
  /**
28
102
  * Extended Actor interface with Verani-specific methods
29
103
  */
@@ -278,80 +352,6 @@ interface RoomDefinitionWithHandlers<TMeta extends ConnectionMeta = ConnectionMe
278
352
  declare function defineRoom<TMeta extends ConnectionMeta = ConnectionMeta, E = unknown>(def: RoomDefinition<TMeta, E>): RoomDefinitionWithHandlers<TMeta, E>;
279
353
  //#endregion
280
354
  //#region src/actor/actor-runtime.d.ts
281
- /**
282
- * Actor stub interface returned by .get() method.
283
- * Provides RPC access to actor methods that can be called remotely.
284
- *
285
- * Note: RPC methods return Promises even if the underlying method is synchronous.
286
- * Methods that return non-serializable types (like WebSocket[] or DurableObjectStorage)
287
- * are excluded from this interface.
288
- */
289
- interface ActorStub {
290
- /**
291
- * Standard fetch method for handling HTTP requests and WebSocket upgrades
292
- */
293
- fetch(request: Request): Promise<Response>;
294
- /**
295
- * Socket.IO-like emit API: Emit an event to a specific channel via RPC.
296
- * @param channel - Channel name to emit to
297
- * @param event - Event name
298
- * @param data - Event data
299
- * @returns Promise resolving to the number of connections that received the message
300
- * @example
301
- * ```typescript
302
- * await stub.emitToChannel("default", "announcement", { text: "Hello!" });
303
- * ```
304
- */
305
- emitToChannel(channel: string, event: string, data?: any): Promise<number>;
306
- /**
307
- * Socket.IO-like emit API: Emit an event to a specific user (all their sessions) via RPC.
308
- * @param userId - User ID to emit to
309
- * @param event - Event name
310
- * @param data - Event data
311
- * @returns Promise resolving to the number of sessions that received the message
312
- * @example
313
- * ```typescript
314
- * await stub.emitToUser("alice", "notification", { message: "Hello!" });
315
- * ```
316
- */
317
- emitToUser(userId: string, event: string, data?: any): Promise<number>;
318
- /**
319
- * @deprecated Use `emitToUser()` instead for Socket.IO-like API.
320
- * Sends a message to a specific user (all their sessions) via RPC.
321
- * @param userId - The user ID to send to
322
- * @param channel - The channel to send to
323
- * @param data - Message data
324
- * @returns Promise resolving to the number of sessions that received the message
325
- */
326
- sendToUser(userId: string, channel: string, data?: any): Promise<number>;
327
- /**
328
- * @deprecated Use `emitToChannel()` instead for Socket.IO-like API.
329
- * Broadcasts a message to all connections in a channel via RPC.
330
- * Note: The `except` option from BroadcastOptions is not available over RPC
331
- * since WebSocket cannot be serialized.
332
- * @param channel - The channel to broadcast to
333
- * @param data - The data to send
334
- * @param opts - Broadcast options (filtering by userIds or clientIds)
335
- * @returns Promise resolving to the number of connections that received the message
336
- */
337
- broadcast(channel: string, data: any, opts?: RpcBroadcastOptions): Promise<number>;
338
- /**
339
- * Gets the total number of active sessions via RPC.
340
- * @returns Promise resolving to the number of connected WebSockets
341
- */
342
- getSessionCount(): Promise<number>;
343
- /**
344
- * Gets all unique user IDs currently connected via RPC.
345
- * @returns Promise resolving to an array of unique user IDs
346
- */
347
- getConnectedUserIds(): Promise<string[]>;
348
- /**
349
- * Removes all WebSocket sessions that are not in OPEN state via RPC.
350
- * This prevents stale connections from accumulating in memory.
351
- * @returns Promise resolving to the number of sessions cleaned up
352
- */
353
- cleanupStaleSessions(): Promise<number>;
354
- }
355
355
  /**
356
356
  * Return type for createActorHandler - represents an Actor class constructor
357
357
  */
package/dist/verani.d.mts CHANGED
@@ -24,6 +24,80 @@ interface RpcBroadcastOptions {
24
24
  /** Only send to specific client IDs */
25
25
  clientIds?: string[];
26
26
  }
27
+ /**
28
+ * Actor stub interface returned by .get() method.
29
+ * Provides RPC access to actor methods that can be called remotely.
30
+ *
31
+ * Note: RPC methods return Promises even if the underlying method is synchronous.
32
+ * Methods that return non-serializable types (like WebSocket[] or DurableObjectStorage)
33
+ * are excluded from this interface.
34
+ */
35
+ interface ActorStub {
36
+ /**
37
+ * Standard fetch method for handling HTTP requests and WebSocket upgrades
38
+ */
39
+ fetch(request: Request): Promise<Response>;
40
+ /**
41
+ * Socket.IO-like emit API: Emit an event to a specific channel via RPC.
42
+ * @param channel - Channel name to emit to
43
+ * @param event - Event name
44
+ * @param data - Event data
45
+ * @returns Promise resolving to the number of connections that received the message
46
+ * @example
47
+ * ```typescript
48
+ * await stub.emitToChannel("default", "announcement", { text: "Hello!" });
49
+ * ```
50
+ */
51
+ emitToChannel(channel: string, event: string, data?: any): Promise<number>;
52
+ /**
53
+ * Socket.IO-like emit API: Emit an event to a specific user (all their sessions) via RPC.
54
+ * @param userId - User ID to emit to
55
+ * @param event - Event name
56
+ * @param data - Event data
57
+ * @returns Promise resolving to the number of sessions that received the message
58
+ * @example
59
+ * ```typescript
60
+ * await stub.emitToUser("alice", "notification", { message: "Hello!" });
61
+ * ```
62
+ */
63
+ emitToUser(userId: string, event: string, data?: any): Promise<number>;
64
+ /**
65
+ * @deprecated Use `emitToUser()` instead for Socket.IO-like API.
66
+ * Sends a message to a specific user (all their sessions) via RPC.
67
+ * @param userId - The user ID to send to
68
+ * @param channel - The channel to send to
69
+ * @param data - Message data
70
+ * @returns Promise resolving to the number of sessions that received the message
71
+ */
72
+ sendToUser(userId: string, channel: string, data?: any): Promise<number>;
73
+ /**
74
+ * @deprecated Use `emitToChannel()` instead for Socket.IO-like API.
75
+ * Broadcasts a message to all connections in a channel via RPC.
76
+ * Note: The `except` option from BroadcastOptions is not available over RPC
77
+ * since WebSocket cannot be serialized.
78
+ * @param channel - The channel to broadcast to
79
+ * @param data - The data to send
80
+ * @param opts - Broadcast options (filtering by userIds or clientIds)
81
+ * @returns Promise resolving to the number of connections that received the message
82
+ */
83
+ broadcast(channel: string, data: any, opts?: RpcBroadcastOptions): Promise<number>;
84
+ /**
85
+ * Gets the total number of active sessions via RPC.
86
+ * @returns Promise resolving to the number of connected WebSockets
87
+ */
88
+ getSessionCount(): Promise<number>;
89
+ /**
90
+ * Gets all unique user IDs currently connected via RPC.
91
+ * @returns Promise resolving to an array of unique user IDs
92
+ */
93
+ getConnectedUserIds(): Promise<string[]>;
94
+ /**
95
+ * Removes all WebSocket sessions that are not in OPEN state via RPC.
96
+ * This prevents stale connections from accumulating in memory.
97
+ * @returns Promise resolving to the number of sessions cleaned up
98
+ */
99
+ cleanupStaleSessions(): Promise<number>;
100
+ }
27
101
  /**
28
102
  * Extended Actor interface with Verani-specific methods
29
103
  */
@@ -278,80 +352,6 @@ interface RoomDefinitionWithHandlers<TMeta extends ConnectionMeta = ConnectionMe
278
352
  declare function defineRoom<TMeta extends ConnectionMeta = ConnectionMeta, E = unknown>(def: RoomDefinition<TMeta, E>): RoomDefinitionWithHandlers<TMeta, E>;
279
353
  //#endregion
280
354
  //#region src/actor/actor-runtime.d.ts
281
- /**
282
- * Actor stub interface returned by .get() method.
283
- * Provides RPC access to actor methods that can be called remotely.
284
- *
285
- * Note: RPC methods return Promises even if the underlying method is synchronous.
286
- * Methods that return non-serializable types (like WebSocket[] or DurableObjectStorage)
287
- * are excluded from this interface.
288
- */
289
- interface ActorStub {
290
- /**
291
- * Standard fetch method for handling HTTP requests and WebSocket upgrades
292
- */
293
- fetch(request: Request): Promise<Response>;
294
- /**
295
- * Socket.IO-like emit API: Emit an event to a specific channel via RPC.
296
- * @param channel - Channel name to emit to
297
- * @param event - Event name
298
- * @param data - Event data
299
- * @returns Promise resolving to the number of connections that received the message
300
- * @example
301
- * ```typescript
302
- * await stub.emitToChannel("default", "announcement", { text: "Hello!" });
303
- * ```
304
- */
305
- emitToChannel(channel: string, event: string, data?: any): Promise<number>;
306
- /**
307
- * Socket.IO-like emit API: Emit an event to a specific user (all their sessions) via RPC.
308
- * @param userId - User ID to emit to
309
- * @param event - Event name
310
- * @param data - Event data
311
- * @returns Promise resolving to the number of sessions that received the message
312
- * @example
313
- * ```typescript
314
- * await stub.emitToUser("alice", "notification", { message: "Hello!" });
315
- * ```
316
- */
317
- emitToUser(userId: string, event: string, data?: any): Promise<number>;
318
- /**
319
- * @deprecated Use `emitToUser()` instead for Socket.IO-like API.
320
- * Sends a message to a specific user (all their sessions) via RPC.
321
- * @param userId - The user ID to send to
322
- * @param channel - The channel to send to
323
- * @param data - Message data
324
- * @returns Promise resolving to the number of sessions that received the message
325
- */
326
- sendToUser(userId: string, channel: string, data?: any): Promise<number>;
327
- /**
328
- * @deprecated Use `emitToChannel()` instead for Socket.IO-like API.
329
- * Broadcasts a message to all connections in a channel via RPC.
330
- * Note: The `except` option from BroadcastOptions is not available over RPC
331
- * since WebSocket cannot be serialized.
332
- * @param channel - The channel to broadcast to
333
- * @param data - The data to send
334
- * @param opts - Broadcast options (filtering by userIds or clientIds)
335
- * @returns Promise resolving to the number of connections that received the message
336
- */
337
- broadcast(channel: string, data: any, opts?: RpcBroadcastOptions): Promise<number>;
338
- /**
339
- * Gets the total number of active sessions via RPC.
340
- * @returns Promise resolving to the number of connected WebSockets
341
- */
342
- getSessionCount(): Promise<number>;
343
- /**
344
- * Gets all unique user IDs currently connected via RPC.
345
- * @returns Promise resolving to an array of unique user IDs
346
- */
347
- getConnectedUserIds(): Promise<string[]>;
348
- /**
349
- * Removes all WebSocket sessions that are not in OPEN state via RPC.
350
- * This prevents stale connections from accumulating in memory.
351
- * @returns Promise resolving to the number of sessions cleaned up
352
- */
353
- cleanupStaleSessions(): Promise<number>;
354
- }
355
355
  /**
356
356
  * Return type for createActorHandler - represents an Actor class constructor
357
357
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verani",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "A simple, focused realtime SDK for Cloudflare Actors with Socket.io-like semantics",
5
5
  "license": "ISC",
6
6
  "keywords": [