@veloxts/events 0.6.58 → 0.6.59
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/manager.js +11 -1
- package/dist/schemas.d.ts +16 -16
- package/dist/types.d.ts +24 -1
- package/package.json +3 -3
package/dist/manager.js
CHANGED
|
@@ -71,7 +71,7 @@ export function createManagerFromDriver(driver) {
|
|
|
71
71
|
data,
|
|
72
72
|
})));
|
|
73
73
|
},
|
|
74
|
-
async
|
|
74
|
+
async broadcastExcept(channel, event, data, except) {
|
|
75
75
|
await driver.broadcast({
|
|
76
76
|
channel,
|
|
77
77
|
event,
|
|
@@ -79,6 +79,16 @@ export function createManagerFromDriver(driver) {
|
|
|
79
79
|
except,
|
|
80
80
|
});
|
|
81
81
|
},
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use `broadcastExcept()` instead. Will be removed in v2.0.
|
|
84
|
+
*/
|
|
85
|
+
async toOthers(channel, event, data, except) {
|
|
86
|
+
// Runtime deprecation warning (development only)
|
|
87
|
+
if (process.env.NODE_ENV === 'development') {
|
|
88
|
+
console.warn('[@veloxts/events] toOthers() is deprecated. Use broadcastExcept() instead.');
|
|
89
|
+
}
|
|
90
|
+
await this.broadcastExcept(channel, event, data, except);
|
|
91
|
+
},
|
|
82
92
|
async subscriberCount(channel) {
|
|
83
93
|
return driver.getConnectionCount(channel);
|
|
84
94
|
},
|
package/dist/schemas.d.ts
CHANGED
|
@@ -35,15 +35,15 @@ export declare const SseSubscribeBodySchema: z.ZodObject<{
|
|
|
35
35
|
info?: Record<string, unknown> | undefined;
|
|
36
36
|
}>>;
|
|
37
37
|
}, "strip", z.ZodTypeAny, {
|
|
38
|
-
connectionId: string;
|
|
39
38
|
channel: string;
|
|
39
|
+
connectionId: string;
|
|
40
40
|
member?: {
|
|
41
41
|
id: string;
|
|
42
42
|
info?: Record<string, unknown> | undefined;
|
|
43
43
|
} | undefined;
|
|
44
44
|
}, {
|
|
45
|
-
connectionId: string;
|
|
46
45
|
channel: string;
|
|
46
|
+
connectionId: string;
|
|
47
47
|
member?: {
|
|
48
48
|
id: string;
|
|
49
49
|
info?: Record<string, unknown> | undefined;
|
|
@@ -58,11 +58,11 @@ export declare const SseUnsubscribeBodySchema: z.ZodObject<{
|
|
|
58
58
|
connectionId: z.ZodString;
|
|
59
59
|
channel: z.ZodString;
|
|
60
60
|
}, "strip", z.ZodTypeAny, {
|
|
61
|
-
connectionId: string;
|
|
62
61
|
channel: string;
|
|
63
|
-
}, {
|
|
64
62
|
connectionId: string;
|
|
63
|
+
}, {
|
|
65
64
|
channel: string;
|
|
65
|
+
connectionId: string;
|
|
66
66
|
}>;
|
|
67
67
|
export type SseUnsubscribeBody = z.infer<typeof SseUnsubscribeBodySchema>;
|
|
68
68
|
/**
|
|
@@ -100,32 +100,32 @@ export declare const ClientMessageSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
100
100
|
info?: Record<string, unknown> | undefined;
|
|
101
101
|
}>>;
|
|
102
102
|
}, "strip", z.ZodTypeAny, {
|
|
103
|
-
channel: string;
|
|
104
103
|
type: "subscribe";
|
|
105
|
-
|
|
106
|
-
channelData?: string | undefined;
|
|
104
|
+
channel: string;
|
|
107
105
|
data?: {
|
|
108
106
|
id: string;
|
|
109
107
|
info?: Record<string, unknown> | undefined;
|
|
110
108
|
} | undefined;
|
|
111
|
-
}, {
|
|
112
|
-
channel: string;
|
|
113
|
-
type: "subscribe";
|
|
114
109
|
auth?: string | undefined;
|
|
115
110
|
channelData?: string | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
type: "subscribe";
|
|
113
|
+
channel: string;
|
|
116
114
|
data?: {
|
|
117
115
|
id: string;
|
|
118
116
|
info?: Record<string, unknown> | undefined;
|
|
119
117
|
} | undefined;
|
|
118
|
+
auth?: string | undefined;
|
|
119
|
+
channelData?: string | undefined;
|
|
120
120
|
}>, z.ZodObject<{
|
|
121
121
|
type: z.ZodLiteral<"unsubscribe">;
|
|
122
122
|
channel: z.ZodString;
|
|
123
123
|
}, "strip", z.ZodTypeAny, {
|
|
124
|
-
channel: string;
|
|
125
124
|
type: "unsubscribe";
|
|
126
|
-
}, {
|
|
127
125
|
channel: string;
|
|
126
|
+
}, {
|
|
128
127
|
type: "unsubscribe";
|
|
128
|
+
channel: string;
|
|
129
129
|
}>, z.ZodObject<{
|
|
130
130
|
type: z.ZodLiteral<"ping">;
|
|
131
131
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -138,14 +138,14 @@ export declare const ClientMessageSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
138
138
|
event: z.ZodString;
|
|
139
139
|
data: z.ZodOptional<z.ZodUnknown>;
|
|
140
140
|
}, "strip", z.ZodTypeAny, {
|
|
141
|
-
channel: string;
|
|
142
|
-
type: "message";
|
|
143
141
|
event: string;
|
|
142
|
+
type: "message";
|
|
143
|
+
channel: string;
|
|
144
144
|
data?: unknown;
|
|
145
145
|
}, {
|
|
146
|
-
channel: string;
|
|
147
|
-
type: "message";
|
|
148
146
|
event: string;
|
|
147
|
+
type: "message";
|
|
148
|
+
channel: string;
|
|
149
149
|
data?: unknown;
|
|
150
150
|
}>]>;
|
|
151
151
|
export type ValidatedClientMessage = z.infer<typeof ClientMessageSchema>;
|
package/dist/types.d.ts
CHANGED
|
@@ -234,13 +234,36 @@ export interface EventsManager {
|
|
|
234
234
|
/**
|
|
235
235
|
* Broadcast to all subscribers except the sender.
|
|
236
236
|
*
|
|
237
|
+
* @param channel - Target channel
|
|
238
|
+
* @param event - Event name
|
|
239
|
+
* @param data - Event payload
|
|
240
|
+
* @param except - Socket ID to exclude from broadcast
|
|
241
|
+
*
|
|
237
242
|
* @example
|
|
238
243
|
* ```typescript
|
|
239
|
-
* await events.
|
|
244
|
+
* await events.broadcastExcept('chat.room-1', 'message.sent', {
|
|
240
245
|
* text: 'Hello!',
|
|
241
246
|
* }, senderSocketId);
|
|
242
247
|
* ```
|
|
243
248
|
*/
|
|
249
|
+
broadcastExcept<T>(channel: string, event: string, data: T, except: string): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Broadcast to all subscribers except the sender.
|
|
252
|
+
*
|
|
253
|
+
* @deprecated Use `broadcastExcept()` instead. Will be removed in v2.0.
|
|
254
|
+
* @param channel - Target channel
|
|
255
|
+
* @param event - Event name
|
|
256
|
+
* @param data - Event payload
|
|
257
|
+
* @param except - Socket ID to exclude from broadcast
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* // Deprecated - migrate to broadcastExcept:
|
|
262
|
+
* await events.toOthers('chat.room-1', 'message.sent', { text: 'Hello!' }, senderId);
|
|
263
|
+
* // New API:
|
|
264
|
+
* await events.broadcastExcept('chat.room-1', 'message.sent', { text: 'Hello!' }, senderId);
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
244
267
|
toOthers<T>(channel: string, event: string, data: T, except: string): Promise<void>;
|
|
245
268
|
/**
|
|
246
269
|
* Get subscriber count for a channel.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veloxts/events",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.59",
|
|
4
4
|
"description": "Real-time event broadcasting for VeloxTS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"superjson": "2.2.2",
|
|
31
31
|
"ws": "8.18.2",
|
|
32
32
|
"zod": "3.24.4",
|
|
33
|
-
"@veloxts/core": "0.6.
|
|
33
|
+
"@veloxts/core": "0.6.59"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"fastify": "^5.0.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"ioredis": "5.6.1",
|
|
50
50
|
"typescript": "5.8.3",
|
|
51
51
|
"vitest": "4.0.16",
|
|
52
|
-
"@veloxts/testing": "0.6.
|
|
52
|
+
"@veloxts/testing": "0.6.59"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|