alepha 0.15.0 → 0.15.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/README.md +43 -98
- package/dist/api/audits/index.d.ts +240 -240
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +2 -2
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +185 -185
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +2 -2
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +245 -245
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.browser.js +4 -4
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +74 -74
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +4 -4
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +221 -221
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.d.ts +1632 -1631
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +26 -34
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +132 -132
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.d.ts +122 -122
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/bucket/index.d.ts +163 -163
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/cache/core/index.d.ts +46 -46
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js +2 -2
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/cli/index.d.ts +5933 -201
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +609 -169
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +296 -296
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +19 -19
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +268 -79
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +768 -694
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +268 -79
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +268 -79
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +44 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/email/index.d.ts +25 -25
- package/dist/email/index.d.ts.map +1 -1
- package/dist/fake/index.d.ts +5409 -5409
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +22 -22
- package/dist/fake/index.js.map +1 -1
- package/dist/file/index.d.ts +435 -435
- package/dist/file/index.d.ts.map +1 -1
- package/dist/lock/core/index.d.ts +208 -208
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +24 -24
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +1 -5
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +216 -198
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +28 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +9 -9
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +83 -76
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +961 -960
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +88 -81
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +244 -244
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/redis/index.d.ts +105 -105
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/retry/index.d.ts +69 -69
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +108 -26
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +393 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +532 -209
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1422 -11
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1296 -271
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +1249 -18
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +56 -56
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/compress/index.d.ts +3 -3
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/cookies/index.d.ts +6 -6
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/core/index.d.ts +196 -186
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +43 -27
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -11
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/helmet/index.d.ts +2 -2
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/links/index.browser.js +9 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +83 -83
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +13 -5
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +514 -1
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4462 -4
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts +6 -6
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/proxy/index.d.ts +102 -102
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.d.ts +16 -16
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/static/index.d.ts +44 -44
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/swagger/index.d.ts +47 -47
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/sms/index.d.ts +11 -11
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +3 -3
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +71 -71
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/thread/index.js +2 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.d.ts +318 -318
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +2324 -1719
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +123 -475
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +275 -275
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +3 -3
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -9
- package/src/api/users/services/SessionService.ts +0 -10
- package/src/cli/apps/AlephaCli.ts +2 -2
- package/src/cli/apps/AlephaPackageBuilderCli.ts +9 -1
- package/src/cli/assets/apiHelloControllerTs.ts +2 -1
- package/src/cli/assets/biomeJson.ts +2 -1
- package/src/cli/assets/claudeMd.ts +9 -4
- package/src/cli/assets/dummySpecTs.ts +2 -1
- package/src/cli/assets/editorconfig.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +2 -1
- package/src/cli/assets/mainCss.ts +24 -0
- package/src/cli/assets/tsconfigJson.ts +2 -1
- package/src/cli/assets/webAppRouterTs.ts +2 -1
- package/src/cli/assets/webHelloComponentTsx.ts +6 -2
- package/src/cli/atoms/appEntryOptions.ts +13 -0
- package/src/cli/atoms/buildOptions.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +1 -1
- package/src/cli/commands/build.ts +63 -47
- package/src/cli/commands/dev.ts +16 -33
- package/src/cli/commands/gen/env.ts +1 -1
- package/src/cli/commands/init.ts +17 -8
- package/src/cli/commands/lint.ts +1 -1
- package/src/cli/defineConfig.ts +9 -0
- package/src/cli/index.ts +2 -1
- package/src/cli/providers/AppEntryProvider.ts +131 -0
- package/src/cli/providers/ViteBuildProvider.ts +82 -0
- package/src/cli/providers/ViteDevServerProvider.ts +350 -0
- package/src/cli/providers/ViteTemplateProvider.ts +27 -0
- package/src/cli/services/AlephaCliUtils.ts +33 -2
- package/src/cli/services/PackageManagerUtils.ts +13 -6
- package/src/cli/services/ProjectScaffolder.ts +72 -49
- package/src/core/Alepha.ts +2 -8
- package/src/core/primitives/$module.ts +12 -0
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
- package/src/core/providers/SchemaValidator.spec.ts +236 -0
- package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
- package/src/mcp/errors/McpError.ts +30 -0
- package/src/mcp/index.ts +3 -0
- package/src/mcp/transports/SseMcpTransport.ts +16 -6
- package/src/orm/providers/DrizzleKitProvider.ts +3 -5
- package/src/orm/services/Repository.ts +11 -0
- package/src/server/core/index.ts +1 -1
- package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
- package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
- package/src/server/core/providers/NodeHttpServerProvider.ts +71 -22
- package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
- package/src/server/core/providers/ServerProvider.ts +9 -12
- package/src/server/links/atoms/apiLinksAtom.ts +7 -0
- package/src/server/links/index.browser.ts +2 -0
- package/src/server/links/index.ts +2 -0
- package/src/vite/index.ts +3 -2
- package/src/vite/tasks/buildClient.ts +0 -1
- package/src/vite/tasks/buildServer.ts +68 -21
- package/src/vite/tasks/copyAssets.ts +5 -4
- package/src/vite/tasks/generateSitemap.ts +64 -23
- package/src/vite/tasks/index.ts +0 -2
- package/src/vite/tasks/prerenderPages.ts +49 -24
- package/src/cli/assets/indexHtml.ts +0 -15
- package/src/cli/commands/format.ts +0 -23
- package/src/vite/helpers/boot.ts +0 -117
- package/src/vite/plugins/viteAlephaDev.ts +0 -177
- package/src/vite/tasks/devServer.ts +0 -71
- package/src/vite/tasks/runAlepha.ts +0 -270
- /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as alepha6 from "alepha";
|
|
2
2
|
import { Alepha, KIND, Primitive, Static, TObject, TString, TUnion } from "alepha";
|
|
3
3
|
import * as alepha_topic0 from "alepha/topic";
|
|
4
|
-
import * as
|
|
4
|
+
import * as alepha_logger1 from "alepha/logger";
|
|
5
5
|
import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
6
6
|
import { IncomingMessage } from "node:http";
|
|
7
7
|
|
|
@@ -33,32 +33,32 @@ type TWSObject = TObject | TUnion;
|
|
|
33
33
|
*/
|
|
34
34
|
interface ChannelPrimitiveOptions<TClient extends TWSObject, TServer extends TWSObject> {
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* WebSocket endpoint path (e.g., "/ws/chat")
|
|
37
|
+
*/
|
|
38
38
|
path: string;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Optional description for documentation
|
|
41
|
+
*/
|
|
42
42
|
description?: string;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* Message schemas for bidirectional communication
|
|
45
|
+
*/
|
|
46
46
|
schema: {
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
* Optional room ID schema validation
|
|
49
|
+
* Default: t.text() (any string)
|
|
50
|
+
* Can be enforced at application level: t.uuid(), t.regex(/^[a-f0-9\-]{36}$/)
|
|
51
|
+
*/
|
|
52
52
|
roomId?: TString;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
* Messages from server to client
|
|
55
|
+
* This is what clients will receive
|
|
56
|
+
*/
|
|
57
57
|
in: TClient;
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
* Messages from client to server
|
|
60
|
+
* This is what the server will receive
|
|
61
|
+
*/
|
|
62
62
|
out: TServer;
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -136,32 +136,32 @@ declare class ChannelPrimitive<TClient extends TWSObject, TServer extends TWSObj
|
|
|
136
136
|
*/
|
|
137
137
|
interface WebSocketConnection {
|
|
138
138
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
* Unique connection ID
|
|
140
|
+
*/
|
|
141
141
|
id: string;
|
|
142
142
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
* User ID (if authenticated and security module is used)
|
|
144
|
+
*/
|
|
145
145
|
userId?: string;
|
|
146
146
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
* Room IDs that this connection is currently in
|
|
148
|
+
*/
|
|
149
149
|
roomIds: string[];
|
|
150
150
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
* Send a message to this connection
|
|
152
|
+
*/
|
|
153
153
|
send(message: any): Promise<void>;
|
|
154
154
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
* Close this connection
|
|
156
|
+
*/
|
|
157
157
|
close(code?: number, reason?: string): Promise<void>;
|
|
158
158
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
* Connection metadata (custom data)
|
|
160
|
+
*/
|
|
161
161
|
metadata?: Record<string, any>;
|
|
162
162
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
* Connection state
|
|
164
|
+
*/
|
|
165
165
|
readyState: WebSocketState;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -171,66 +171,66 @@ declare enum WebSocketState {
|
|
|
171
171
|
CONNECTING = 0,
|
|
172
172
|
OPEN = 1,
|
|
173
173
|
CLOSING = 2,
|
|
174
|
-
CLOSED = 3
|
|
174
|
+
CLOSED = 3
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* WebSocket endpoint configuration (server-side)
|
|
178
178
|
*/
|
|
179
179
|
interface WebSocketPrimitiveOptions<TClient extends TWSObject, TServer extends TWSObject> {
|
|
180
180
|
/**
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
* Channel definition with schema and path
|
|
182
|
+
*/
|
|
183
183
|
channel: ChannelPrimitive<TClient, TServer>;
|
|
184
184
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
* Handler for incoming messages from clients
|
|
186
|
+
*/
|
|
187
187
|
handler: WebSocketHandler<TClient, TServer>;
|
|
188
188
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
* Optional connection handler (called when a client connects)
|
|
190
|
+
*/
|
|
191
191
|
onConnect?: (params: {
|
|
192
192
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
* Unique connection ID of the client
|
|
194
|
+
*/
|
|
195
195
|
connectionId: string;
|
|
196
196
|
/**
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
* User ID of the connected client (if authenticated and security module is used)
|
|
198
|
+
*/
|
|
199
199
|
userId?: string;
|
|
200
200
|
/**
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
* Room IDs that the client is connecting to
|
|
202
|
+
*/
|
|
203
203
|
roomIds: string[];
|
|
204
204
|
}) => Promise<void> | void;
|
|
205
205
|
/**
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
* Optional disconnection handler (called when a client disconnects)
|
|
207
|
+
*/
|
|
208
208
|
onDisconnect?: (params: {
|
|
209
209
|
/**
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
* Unique connection ID of the client
|
|
211
|
+
*/
|
|
212
212
|
connectionId: string;
|
|
213
213
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
* User ID of the connected client (if authenticated and security module is used)
|
|
215
|
+
*/
|
|
216
216
|
userId?: string;
|
|
217
217
|
/**
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
* Room IDs that the client was connected to
|
|
219
|
+
*/
|
|
220
220
|
roomIds: string[];
|
|
221
221
|
}) => Promise<void> | void;
|
|
222
222
|
/**
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
* Change WebSocket server provider (for custom implementations)
|
|
224
|
+
*/
|
|
225
225
|
provider?: any;
|
|
226
226
|
/**
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
* Whether to enforce security (authentication, authorization) on this WebSocket endpoint
|
|
228
|
+
* Requires alepha/security integration
|
|
229
|
+
*/
|
|
230
230
|
secure?: boolean;
|
|
231
231
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
* Limit number of connections per user (if authenticated)
|
|
233
|
+
*/
|
|
234
234
|
maxConnectionsPerUser?: number;
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
@@ -242,46 +242,46 @@ type WebSocketHandler<TClient extends TWSObject, TServer extends TWSObject> = (c
|
|
|
242
242
|
*/
|
|
243
243
|
interface WebSocketHandlerContext<TClient extends TWSObject, TServer extends TWSObject> {
|
|
244
244
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
* Unique connection ID of the client
|
|
246
|
+
*/
|
|
247
247
|
connectionId: string;
|
|
248
248
|
/**
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
* User ID of the connected client (if authenticated and security module is used)
|
|
250
|
+
*/
|
|
251
251
|
userId?: string;
|
|
252
252
|
/**
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
* Room ID that the client sent the message from
|
|
254
|
+
*/
|
|
255
255
|
roomId: string;
|
|
256
256
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
* The parsed and validated message from the client
|
|
258
|
+
*/
|
|
259
259
|
message: Static<TServer>;
|
|
260
260
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
* Reply function tailored to current context (connectionId, roomId)
|
|
262
|
+
*/
|
|
263
263
|
reply: (options: {
|
|
264
264
|
/**
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
* Message to send
|
|
266
|
+
*/
|
|
267
267
|
message: Static<TClient>;
|
|
268
268
|
/**
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
* Optional: specify room ID to send to (defaults to sender's room ID)
|
|
270
|
+
*/
|
|
271
271
|
roomId?: string;
|
|
272
272
|
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
* Optional: exclude the sender connection from receiving the message
|
|
274
|
+
* Will populate exceptConnectionIds with sender connection ID behind the scenes
|
|
275
|
+
*/
|
|
276
276
|
exceptSelf?: boolean;
|
|
277
277
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
* Optional: exclude specific connection IDs from receiving the message
|
|
279
|
+
*/
|
|
280
280
|
exceptConnectionIds?: string[];
|
|
281
281
|
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
* Optional: exclude specific user IDs from receiving the message
|
|
283
|
+
* Requires alepha/security integration
|
|
284
|
+
*/
|
|
285
285
|
exceptUserIds?: string[];
|
|
286
286
|
}) => Promise<void>;
|
|
287
287
|
}
|
|
@@ -290,41 +290,41 @@ interface WebSocketHandlerContext<TClient extends TWSObject, TServer extends TWS
|
|
|
290
290
|
*/
|
|
291
291
|
interface EmitOptions<TClient extends TWSObject> {
|
|
292
292
|
/**
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
* Message to send to clients
|
|
294
|
+
*/
|
|
295
295
|
message: Static<TClient>;
|
|
296
296
|
/**
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
* Room ID to send the message to
|
|
298
|
+
*/
|
|
299
299
|
roomId?: string;
|
|
300
300
|
/**
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
* Room IDs to send the message to
|
|
302
|
+
*/
|
|
303
303
|
roomIds?: string[];
|
|
304
304
|
/**
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
* User ID to send the message to (if authenticated)
|
|
306
|
+
*/
|
|
307
307
|
userId?: string;
|
|
308
308
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
* User IDs to send the message to (if authenticated)
|
|
310
|
+
*/
|
|
311
311
|
userIds?: string[];
|
|
312
312
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
* Connection ID to send the message to
|
|
314
|
+
*/
|
|
315
315
|
connectionId?: string;
|
|
316
316
|
/**
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
* Connection IDs to send the message to
|
|
318
|
+
*/
|
|
319
319
|
connectionIds?: string[];
|
|
320
320
|
/**
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
* Optional: exclude specific connection IDs from receiving the message
|
|
322
|
+
*/
|
|
323
323
|
exceptConnectionIds?: string[];
|
|
324
324
|
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
* Optional: exclude specific user IDs from receiving the message
|
|
326
|
+
* Requires alepha/security integration
|
|
327
|
+
*/
|
|
328
328
|
exceptUserIds?: string[];
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
@@ -337,30 +337,30 @@ interface EmitOptions<TClient extends TWSObject> {
|
|
|
337
337
|
*/
|
|
338
338
|
declare abstract class WebSocketServerProvider {
|
|
339
339
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
* Register a WebSocket endpoint with its channel configuration
|
|
341
|
+
*/
|
|
342
342
|
abstract registerEndpoint<TClient extends TWSObject, TServer extends TWSObject>(config: WebSocketPrimitiveOptions<TClient, TServer>): void;
|
|
343
343
|
/**
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
* Emit a message to clients based on targeting criteria
|
|
345
|
+
*
|
|
346
|
+
* This method distributes messages across all server instances via pub/sub.
|
|
347
|
+
*/
|
|
348
348
|
abstract emit<TClient extends TWSObject>(channelPath: string, options: EmitOptions<TClient>): Promise<void>;
|
|
349
349
|
/**
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
* Get all active connections (local to this server instance)
|
|
351
|
+
*/
|
|
352
352
|
abstract getConnections(): WebSocketConnection[];
|
|
353
353
|
/**
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
* Get connections in a specific room (local to this server instance)
|
|
355
|
+
*/
|
|
356
356
|
abstract getRoomConnections(roomId: string): WebSocketConnection[];
|
|
357
357
|
/**
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
* Get connections for a specific user (local to this server instance)
|
|
359
|
+
*/
|
|
360
360
|
abstract getUserConnections(userId: string): WebSocketConnection[];
|
|
361
361
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
* Close a specific connection
|
|
363
|
+
*/
|
|
364
364
|
abstract closeConnection(connectionId: string, code?: number, reason?: string): Promise<void>;
|
|
365
365
|
}
|
|
366
366
|
//#endregion
|
|
@@ -414,33 +414,33 @@ declare class WebSocketPrimitive<TClient extends TWSObject, TServer extends TWSO
|
|
|
414
414
|
protected readonly webSocketServerProvider: WebSocketServerProvider;
|
|
415
415
|
protected onInit(): void;
|
|
416
416
|
/**
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
417
|
+
* Emit message to clients
|
|
418
|
+
*
|
|
419
|
+
* Send messages from the server to connected clients based on targeting criteria.
|
|
420
|
+
* Messages are distributed across all server instances via pub/sub.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```typescript
|
|
424
|
+
* // Send to specific room
|
|
425
|
+
* await websocket.emit({
|
|
426
|
+
* roomId: "room-123",
|
|
427
|
+
* message: { type: "update", data: {...} }
|
|
428
|
+
* });
|
|
429
|
+
*
|
|
430
|
+
* // Send to specific user (all their connections)
|
|
431
|
+
* await websocket.emit({
|
|
432
|
+
* userId: "user-456",
|
|
433
|
+
* message: { type: "notification", text: "Hello!" }
|
|
434
|
+
* });
|
|
435
|
+
*
|
|
436
|
+
* // Send to multiple rooms, except certain users
|
|
437
|
+
* await websocket.emit({
|
|
438
|
+
* roomIds: ["room-1", "room-2"],
|
|
439
|
+
* exceptUserIds: ["user-123"],
|
|
440
|
+
* message: { type: "broadcast", content: "System announcement" }
|
|
441
|
+
* });
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
444
|
emit(options: EmitOptions<TClient>): Promise<void>;
|
|
445
445
|
}
|
|
446
446
|
//#endregion
|
|
@@ -452,55 +452,55 @@ declare class WebSocketPrimitive<TClient extends TWSObject, TServer extends TWSO
|
|
|
452
452
|
* and messages can be targeted to specific rooms.
|
|
453
453
|
*/
|
|
454
454
|
declare class RoomManager {
|
|
455
|
-
protected readonly log:
|
|
455
|
+
protected readonly log: alepha_logger1.Logger;
|
|
456
456
|
/**
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
* Maps roomId → Set<connectionId>
|
|
458
|
+
*/
|
|
459
459
|
protected readonly rooms: Map<string, Set<string>>;
|
|
460
460
|
/**
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
461
|
+
* Maps connectionId → Set<roomId>
|
|
462
|
+
* Inverse index for fast lookup of connection's rooms
|
|
463
|
+
*/
|
|
464
464
|
protected readonly connectionRooms: Map<string, Set<string>>;
|
|
465
465
|
/**
|
|
466
|
-
|
|
467
|
-
|
|
466
|
+
* Join a connection to one or more rooms
|
|
467
|
+
*/
|
|
468
468
|
joinRooms(connectionId: string, roomIds: string[]): void;
|
|
469
469
|
/**
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
* Join a connection to a room
|
|
471
|
+
*/
|
|
472
472
|
joinRoom(connectionId: string, roomId: string): void;
|
|
473
473
|
/**
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
* Leave a connection from a room
|
|
475
|
+
*/
|
|
476
476
|
leaveRoom(connectionId: string, roomId: string): void;
|
|
477
477
|
/**
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
* Remove a connection from all rooms
|
|
479
|
+
*/
|
|
480
480
|
leaveAllRooms(connectionId: string): void;
|
|
481
481
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
482
|
+
* Get all connection IDs in a room
|
|
483
|
+
*/
|
|
484
484
|
getRoomConnections(roomId: string): string[];
|
|
485
485
|
/**
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
* Get all room IDs for a connection
|
|
487
|
+
*/
|
|
488
488
|
getConnectionRooms(connectionId: string): string[];
|
|
489
489
|
/**
|
|
490
|
-
|
|
491
|
-
|
|
490
|
+
* Check if a connection is in a room
|
|
491
|
+
*/
|
|
492
492
|
isInRoom(connectionId: string, roomId: string): boolean;
|
|
493
493
|
/**
|
|
494
|
-
|
|
495
|
-
|
|
494
|
+
* Get all active rooms
|
|
495
|
+
*/
|
|
496
496
|
getAllRooms(): string[];
|
|
497
497
|
/**
|
|
498
|
-
|
|
499
|
-
|
|
498
|
+
* Get total number of connections across all rooms
|
|
499
|
+
*/
|
|
500
500
|
getTotalConnections(): number;
|
|
501
501
|
/**
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
* Get room statistics
|
|
503
|
+
*/
|
|
504
504
|
getStats(): {
|
|
505
505
|
totalRooms: number;
|
|
506
506
|
totalConnections: number;
|
|
@@ -509,10 +509,10 @@ declare class RoomManager {
|
|
|
509
509
|
}
|
|
510
510
|
//#endregion
|
|
511
511
|
//#region ../../src/websocket/services/WebSocketClient.d.ts
|
|
512
|
-
declare const envSchema$1:
|
|
513
|
-
WEBSOCKET_URL:
|
|
514
|
-
WEBSOCKET_RECONNECT_INTERVAL:
|
|
515
|
-
WEBSOCKET_MAX_RECONNECT_ATTEMPTS:
|
|
512
|
+
declare const envSchema$1: alepha6.TObject<{
|
|
513
|
+
WEBSOCKET_URL: alepha6.TString;
|
|
514
|
+
WEBSOCKET_RECONNECT_INTERVAL: alepha6.TInteger;
|
|
515
|
+
WEBSOCKET_MAX_RECONNECT_ATTEMPTS: alepha6.TInteger;
|
|
516
516
|
}>;
|
|
517
517
|
declare module "alepha" {
|
|
518
518
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
@@ -533,7 +533,7 @@ declare class WebSocketChannelConnection<TClient extends TWSObject, TServer exte
|
|
|
533
533
|
};
|
|
534
534
|
protected readonly env: Static<typeof envSchema$1>;
|
|
535
535
|
protected readonly alepha: Alepha;
|
|
536
|
-
protected readonly log:
|
|
536
|
+
protected readonly log: alepha_logger1.Logger;
|
|
537
537
|
protected ws?: WebSocket;
|
|
538
538
|
protected reconnectAttempts: number;
|
|
539
539
|
protected reconnectTimer?: number;
|
|
@@ -556,48 +556,48 @@ declare class WebSocketChannelConnection<TClient extends TWSObject, TServer exte
|
|
|
556
556
|
maxReconnectAttempts?: number;
|
|
557
557
|
}, env: Static<typeof envSchema$1>);
|
|
558
558
|
/**
|
|
559
|
-
|
|
560
|
-
|
|
559
|
+
* Build WebSocket URL
|
|
560
|
+
*/
|
|
561
561
|
protected buildUrl(): string;
|
|
562
562
|
/**
|
|
563
|
-
|
|
564
|
-
|
|
563
|
+
* Subscribe to a room on this channel
|
|
564
|
+
*/
|
|
565
565
|
subscribe(roomId: string, handler: (message: Static<TClient>) => void, callbacks?: {
|
|
566
566
|
onConnect?: () => void;
|
|
567
567
|
onDisconnect?: () => void;
|
|
568
568
|
onError?: (error: Error) => void;
|
|
569
569
|
}): () => void;
|
|
570
570
|
/**
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
* Connect to WebSocket server
|
|
572
|
+
*/
|
|
573
573
|
protected connect(): Promise<void>;
|
|
574
574
|
/**
|
|
575
|
-
|
|
576
|
-
|
|
575
|
+
* Handle incoming message
|
|
576
|
+
*/
|
|
577
577
|
protected handleMessage(data: string): void;
|
|
578
578
|
/**
|
|
579
|
-
|
|
580
|
-
|
|
579
|
+
* Send message to a specific room
|
|
580
|
+
*/
|
|
581
581
|
send(roomId: string, message: Static<TServer>): Promise<void>;
|
|
582
582
|
/**
|
|
583
|
-
|
|
584
|
-
|
|
583
|
+
* Schedule reconnection
|
|
584
|
+
*/
|
|
585
585
|
protected scheduleReconnect(): void;
|
|
586
586
|
/**
|
|
587
|
-
|
|
588
|
-
|
|
587
|
+
* Disconnect from server
|
|
588
|
+
*/
|
|
589
589
|
disconnect(): void;
|
|
590
590
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
591
|
+
* Reconnect manually
|
|
592
|
+
*/
|
|
593
593
|
reconnect(): void;
|
|
594
594
|
/**
|
|
595
|
-
|
|
596
|
-
|
|
595
|
+
* Check if subscribed to a room
|
|
596
|
+
*/
|
|
597
597
|
hasRoom(roomId: string): boolean;
|
|
598
598
|
/**
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
* Get all subscribed rooms
|
|
600
|
+
*/
|
|
601
601
|
getRooms(): string[];
|
|
602
602
|
}
|
|
603
603
|
/**
|
|
@@ -607,7 +607,7 @@ declare class WebSocketChannelConnection<TClient extends TWSObject, TServer exte
|
|
|
607
607
|
* One connection per channel, multiple rooms per connection.
|
|
608
608
|
*/
|
|
609
609
|
declare class WebSocketClient {
|
|
610
|
-
protected readonly log:
|
|
610
|
+
protected readonly log: alepha_logger1.Logger;
|
|
611
611
|
protected readonly alepha: Alepha;
|
|
612
612
|
protected readonly env: {
|
|
613
613
|
WEBSOCKET_URL: string;
|
|
@@ -616,8 +616,8 @@ declare class WebSocketClient {
|
|
|
616
616
|
};
|
|
617
617
|
protected connections: Map<string, WebSocketChannelConnection<any, any>>;
|
|
618
618
|
/**
|
|
619
|
-
|
|
620
|
-
|
|
619
|
+
* Subscribe to a room on a channel
|
|
620
|
+
*/
|
|
621
621
|
subscribe<TClient extends TWSObject, TServer extends TWSObject>(roomId: string, channel: ChannelPrimitive<TClient, TServer>, handler: (message: Static<TClient>) => void, options?: {
|
|
622
622
|
url?: string;
|
|
623
623
|
autoReconnect?: boolean;
|
|
@@ -628,16 +628,16 @@ declare class WebSocketClient {
|
|
|
628
628
|
onError?: (error: Error) => void;
|
|
629
629
|
}): () => void;
|
|
630
630
|
/**
|
|
631
|
-
|
|
632
|
-
|
|
631
|
+
* Send message to a room on a channel
|
|
632
|
+
*/
|
|
633
633
|
send<TClient extends TWSObject, TServer extends TWSObject>(roomId: string, channel: ChannelPrimitive<TClient, TServer>, message: Static<TServer>): Promise<void>;
|
|
634
634
|
/**
|
|
635
|
-
|
|
636
|
-
|
|
635
|
+
* Get connection for a channel
|
|
636
|
+
*/
|
|
637
637
|
getConnection<TClient extends TWSObject, TServer extends TWSObject>(channel: ChannelPrimitive<TClient, TServer>): WebSocketChannelConnection<TClient, TServer> | undefined;
|
|
638
638
|
/**
|
|
639
|
-
|
|
640
|
-
|
|
639
|
+
* Disconnect all connections
|
|
640
|
+
*/
|
|
641
641
|
disconnectAll(): void;
|
|
642
642
|
}
|
|
643
643
|
//#endregion
|
|
@@ -646,35 +646,35 @@ declare class WebSocketClient {
|
|
|
646
646
|
* WebSocket message distribution event
|
|
647
647
|
*/
|
|
648
648
|
declare const webSocketMessageSchema: {
|
|
649
|
-
payload:
|
|
649
|
+
payload: alepha6.TObject<{
|
|
650
650
|
/**
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
channelPath:
|
|
651
|
+
* Channel path (e.g., "/ws/chat")
|
|
652
|
+
*/
|
|
653
|
+
channelPath: alepha6.TString;
|
|
654
654
|
/**
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
roomIds:
|
|
655
|
+
* Target room ID(s)
|
|
656
|
+
*/
|
|
657
|
+
roomIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
658
658
|
/**
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
userIds:
|
|
659
|
+
* Target user ID(s)
|
|
660
|
+
*/
|
|
661
|
+
userIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
662
662
|
/**
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
connectionIds:
|
|
663
|
+
* Target connection ID(s)
|
|
664
|
+
*/
|
|
665
|
+
connectionIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
666
666
|
/**
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
exceptConnectionIds:
|
|
667
|
+
* Exclude connection ID(s) from receiving the message
|
|
668
|
+
*/
|
|
669
|
+
exceptConnectionIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
670
670
|
/**
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
exceptUserIds:
|
|
671
|
+
* Exclude user ID(s) from receiving the message
|
|
672
|
+
*/
|
|
673
|
+
exceptUserIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
674
674
|
/**
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
message:
|
|
675
|
+
* The message payload to send
|
|
676
|
+
*/
|
|
677
|
+
message: alepha6.TAny;
|
|
678
678
|
}>;
|
|
679
679
|
};
|
|
680
680
|
/**
|
|
@@ -694,60 +694,60 @@ declare const webSocketMessageSchema: {
|
|
|
694
694
|
* - Horizontal scaling without losing messages
|
|
695
695
|
*/
|
|
696
696
|
declare class WebSocketTopicService {
|
|
697
|
-
protected readonly log:
|
|
697
|
+
protected readonly log: alepha_logger1.Logger;
|
|
698
698
|
/**
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
699
|
+
* Handler function to be called when a message is received from the topic
|
|
700
|
+
* This is set by the WebSocket provider during initialization
|
|
701
|
+
*/
|
|
702
702
|
messageHandler?: (event: Static<(typeof webSocketMessageSchema)["payload"]>) => Promise<void>;
|
|
703
703
|
/**
|
|
704
|
-
|
|
705
|
-
|
|
704
|
+
* Topic for distributing WebSocket messages across server instances
|
|
705
|
+
*/
|
|
706
706
|
readonly topic: alepha_topic0.TopicPrimitive<{
|
|
707
|
-
payload:
|
|
707
|
+
payload: alepha6.TObject<{
|
|
708
708
|
/**
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
channelPath:
|
|
709
|
+
* Channel path (e.g., "/ws/chat")
|
|
710
|
+
*/
|
|
711
|
+
channelPath: alepha6.TString;
|
|
712
712
|
/**
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
roomIds:
|
|
713
|
+
* Target room ID(s)
|
|
714
|
+
*/
|
|
715
|
+
roomIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
716
716
|
/**
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
userIds:
|
|
717
|
+
* Target user ID(s)
|
|
718
|
+
*/
|
|
719
|
+
userIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
720
720
|
/**
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
connectionIds:
|
|
721
|
+
* Target connection ID(s)
|
|
722
|
+
*/
|
|
723
|
+
connectionIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
724
724
|
/**
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
exceptConnectionIds:
|
|
725
|
+
* Exclude connection ID(s) from receiving the message
|
|
726
|
+
*/
|
|
727
|
+
exceptConnectionIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
728
728
|
/**
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
exceptUserIds:
|
|
729
|
+
* Exclude user ID(s) from receiving the message
|
|
730
|
+
*/
|
|
731
|
+
exceptUserIds: alepha6.TOptional<alepha6.TArray<alepha6.TString>>;
|
|
732
732
|
/**
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
message:
|
|
733
|
+
* The message payload to send
|
|
734
|
+
*/
|
|
735
|
+
message: alepha6.TAny;
|
|
736
736
|
}>;
|
|
737
737
|
}>;
|
|
738
738
|
/**
|
|
739
|
-
|
|
740
|
-
|
|
739
|
+
* Publish a message to be distributed across all server instances
|
|
740
|
+
*/
|
|
741
741
|
publish(event: Static<(typeof webSocketMessageSchema)["payload"]>): Promise<void>;
|
|
742
742
|
/**
|
|
743
|
-
|
|
744
|
-
|
|
743
|
+
* Set the handler for incoming messages
|
|
744
|
+
*/
|
|
745
745
|
setMessageHandler(handler: (event: Static<(typeof webSocketMessageSchema)["payload"]>) => Promise<void>): void;
|
|
746
746
|
}
|
|
747
747
|
//#endregion
|
|
748
748
|
//#region ../../src/websocket/providers/NodeWebSocketServerProvider.d.ts
|
|
749
|
-
declare const envSchema:
|
|
750
|
-
WEBSOCKET_PATH:
|
|
749
|
+
declare const envSchema: alepha6.TObject<{
|
|
750
|
+
WEBSOCKET_PATH: alepha6.TString;
|
|
751
751
|
}>;
|
|
752
752
|
declare module "alepha" {
|
|
753
753
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -756,7 +756,7 @@ declare class NodeWebSocketServerProvider extends WebSocketServerProvider {
|
|
|
756
756
|
protected readonly alepha: Alepha;
|
|
757
757
|
protected readonly roomManager: RoomManager;
|
|
758
758
|
protected readonly topicService: WebSocketTopicService;
|
|
759
|
-
protected readonly log:
|
|
759
|
+
protected readonly log: alepha_logger1.Logger;
|
|
760
760
|
protected readonly env: {
|
|
761
761
|
WEBSOCKET_PATH: string;
|
|
762
762
|
};
|
|
@@ -775,9 +775,9 @@ declare class NodeWebSocketServerProvider extends WebSocketServerProvider {
|
|
|
775
775
|
protected handleConnection<TClient extends TWSObject, TServer extends TWSObject>(ws: WebSocket$1, endpoint: WebSocketPrimitiveOptions<TClient, TServer>, request: IncomingMessage): void;
|
|
776
776
|
protected extractRoomIds(url: URL): string[];
|
|
777
777
|
/**
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
778
|
+
* Send message to local connections based on targeting criteria
|
|
779
|
+
* This is called by the topic service when a message is received
|
|
780
|
+
*/
|
|
781
781
|
protected sendToLocalConnections(channelPath: string, message: any, criteria: {
|
|
782
782
|
roomIds?: string[];
|
|
783
783
|
userIds?: string[];
|
|
@@ -785,9 +785,9 @@ declare class NodeWebSocketServerProvider extends WebSocketServerProvider {
|
|
|
785
785
|
exceptConnectionIds?: string[];
|
|
786
786
|
exceptUserIds?: string[];
|
|
787
787
|
}): Promise<void>;
|
|
788
|
-
protected readonly start:
|
|
789
|
-
protected readonly ready:
|
|
790
|
-
protected readonly stop:
|
|
788
|
+
protected readonly start: alepha6.HookPrimitive<"start">;
|
|
789
|
+
protected readonly ready: alepha6.HookPrimitive<"ready">;
|
|
790
|
+
protected readonly stop: alepha6.HookPrimitive<"stop">;
|
|
791
791
|
}
|
|
792
792
|
declare class NodeWebSocketConnection implements WebSocketConnection {
|
|
793
793
|
readonly id: string;
|
|
@@ -796,7 +796,7 @@ declare class NodeWebSocketConnection implements WebSocketConnection {
|
|
|
796
796
|
protected readonly ws: WebSocket$1;
|
|
797
797
|
protected readonly provider: NodeWebSocketServerProvider;
|
|
798
798
|
protected readonly endpoint: WebSocketPrimitiveOptions<any, any>;
|
|
799
|
-
protected readonly log:
|
|
799
|
+
protected readonly log: alepha_logger1.Logger;
|
|
800
800
|
metadata?: Record<string, any>;
|
|
801
801
|
constructor(id: string, userId: string | undefined, roomIds: string[], ws: WebSocket$1, provider: NodeWebSocketServerProvider, endpoint: WebSocketPrimitiveOptions<any, any>);
|
|
802
802
|
get readyState(): WebSocketState;
|
|
@@ -809,15 +809,15 @@ declare class NodeWebSocketConnection implements WebSocketConnection {
|
|
|
809
809
|
declare module "alepha" {
|
|
810
810
|
interface Hooks {
|
|
811
811
|
/**
|
|
812
|
-
|
|
813
|
-
|
|
812
|
+
* Fires when a WebSocket connection is established
|
|
813
|
+
*/
|
|
814
814
|
"websocket:connect": {
|
|
815
815
|
connectionId: string;
|
|
816
816
|
path: string;
|
|
817
817
|
};
|
|
818
818
|
/**
|
|
819
|
-
|
|
820
|
-
|
|
819
|
+
* Fires when a WebSocket connection is closed
|
|
820
|
+
*/
|
|
821
821
|
"websocket:disconnect": {
|
|
822
822
|
connectionId: string;
|
|
823
823
|
path: string;
|
|
@@ -825,16 +825,16 @@ declare module "alepha" {
|
|
|
825
825
|
reason?: string;
|
|
826
826
|
};
|
|
827
827
|
/**
|
|
828
|
-
|
|
829
|
-
|
|
828
|
+
* Fires when a WebSocket message is received
|
|
829
|
+
*/
|
|
830
830
|
"websocket:message": {
|
|
831
831
|
connectionId: string;
|
|
832
832
|
path: string;
|
|
833
833
|
message: any;
|
|
834
834
|
};
|
|
835
835
|
/**
|
|
836
|
-
|
|
837
|
-
|
|
836
|
+
* Fires when a WebSocket error occurs
|
|
837
|
+
*/
|
|
838
838
|
"websocket:error": {
|
|
839
839
|
connectionId: string;
|
|
840
840
|
path: string;
|
|
@@ -855,7 +855,7 @@ declare module "alepha" {
|
|
|
855
855
|
* @see {@link $websocket}
|
|
856
856
|
* @module alepha.websockets
|
|
857
857
|
*/
|
|
858
|
-
declare const AlephaWebSocket:
|
|
858
|
+
declare const AlephaWebSocket: alepha6.Service<alepha6.Module>;
|
|
859
859
|
//#endregion
|
|
860
860
|
export { $channel, $websocket, AlephaWebSocket, ChannelPrimitive, ChannelPrimitiveOptions, EmitOptions, NodeWebSocketConnection, NodeWebSocketServerProvider, RoomManager, TWSObject, WebSocketChannelConnection, WebSocketClient, WebSocketConnection, WebSocketConnectionError, WebSocketError, WebSocketHandler, WebSocketHandlerContext, WebSocketPrimitive, WebSocketPrimitiveOptions, WebSocketServerProvider, WebSocketState, WebSocketTopicService, WebSocketValidationError };
|
|
861
861
|
//# sourceMappingURL=index.d.ts.map
|