@tsed/socketio 6.95.9 → 6.95.10

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.
Files changed (38) hide show
  1. package/package.json +13 -13
  2. package/lib/cjs/SocketIOModule.d.ts +0 -28
  3. package/lib/cjs/class/SocketHandlersBuilder.d.ts +0 -47
  4. package/lib/cjs/class/SocketProviderMetadata.d.ts +0 -19
  5. package/lib/cjs/constants/index.d.ts +0 -1
  6. package/lib/cjs/decorators/args.d.ts +0 -28
  7. package/lib/cjs/decorators/broadcast.d.ts +0 -23
  8. package/lib/cjs/decorators/broadcastOthers.d.ts +0 -23
  9. package/lib/cjs/decorators/emit.d.ts +0 -23
  10. package/lib/cjs/decorators/input.d.ts +0 -20
  11. package/lib/cjs/decorators/inputAndBroadcast.d.ts +0 -20
  12. package/lib/cjs/decorators/inputAndBroadcastOthers.d.ts +0 -20
  13. package/lib/cjs/decorators/inputAndEmit.d.ts +0 -20
  14. package/lib/cjs/decorators/io.d.ts +0 -20
  15. package/lib/cjs/decorators/nsp.d.ts +0 -64
  16. package/lib/cjs/decorators/socket.d.ts +0 -25
  17. package/lib/cjs/decorators/socketErr.d.ts +0 -21
  18. package/lib/cjs/decorators/socketEventName.d.ts +0 -21
  19. package/lib/cjs/decorators/socketFilter.d.ts +0 -9
  20. package/lib/cjs/decorators/socketMiddleware.d.ts +0 -54
  21. package/lib/cjs/decorators/socketMiddlewareError.d.ts +0 -50
  22. package/lib/cjs/decorators/socketReturns.d.ts +0 -9
  23. package/lib/cjs/decorators/socketService.d.ts +0 -11
  24. package/lib/cjs/decorators/socketSession.d.ts +0 -23
  25. package/lib/cjs/decorators/socketUseAfter.d.ts +0 -52
  26. package/lib/cjs/decorators/socketUseBefore.d.ts +0 -56
  27. package/lib/cjs/index.d.ts +0 -25
  28. package/lib/cjs/interfaces/OnNamespaceInit.d.ts +0 -7
  29. package/lib/cjs/interfaces/SocketFilters.d.ts +0 -11
  30. package/lib/cjs/interfaces/SocketHandlerMetadata.d.ts +0 -18
  31. package/lib/cjs/interfaces/SocketInjectableNsp.d.ts +0 -4
  32. package/lib/cjs/interfaces/SocketParamMetadata.d.ts +0 -7
  33. package/lib/cjs/interfaces/SocketProviderTypes.d.ts +0 -7
  34. package/lib/cjs/interfaces/SocketReturnsTypes.d.ts +0 -8
  35. package/lib/cjs/interfaces/index.d.ts +0 -15
  36. package/lib/cjs/registries/NspSessionRegistry.d.ts +0 -1
  37. package/lib/cjs/services/SocketIOServer.d.ts +0 -4
  38. package/lib/cjs/services/SocketIOService.d.ts +0 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/socketio",
3
- "version": "6.95.9",
3
+ "version": "6.95.10",
4
4
  "description": "Socket.io package for Ts.ED framework",
5
5
  "private": false,
6
6
  "keywords": [
@@ -30,24 +30,24 @@
30
30
  "tslib": "2.2.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@tsed/common": "6.95.9",
34
- "@tsed/core": "6.95.9",
35
- "@tsed/di": "6.95.9",
36
- "@tsed/json-mapper": "6.95.9",
37
- "@tsed/openspec": "6.95.9",
38
- "@tsed/schema": "6.95.9",
33
+ "@tsed/common": "6.95.10",
34
+ "@tsed/core": "6.95.10",
35
+ "@tsed/di": "6.95.10",
36
+ "@tsed/json-mapper": "6.95.10",
37
+ "@tsed/openspec": "6.95.10",
38
+ "@tsed/schema": "6.95.10",
39
39
  "express": "^4.17.1",
40
40
  "socket.io": "4.1.2",
41
41
  "socket.io-client": "^4.1.2"
42
42
  },
43
43
  "peerDependencies": {
44
- "@tsed/common": "^6.95.9",
45
- "@tsed/core": "^6.95.9",
46
- "@tsed/di": "^6.95.9",
47
- "@tsed/json-mapper": "^6.95.9",
44
+ "@tsed/common": "^6.95.10",
45
+ "@tsed/core": "^6.95.10",
46
+ "@tsed/di": "^6.95.10",
47
+ "@tsed/json-mapper": "^6.95.10",
48
48
  "@tsed/logger": ">=6.0.0",
49
- "@tsed/openspec": "^6.95.9",
50
- "@tsed/schema": "^6.95.9",
49
+ "@tsed/openspec": "^6.95.10",
50
+ "@tsed/schema": "^6.95.10",
51
51
  "socket.io": ">=4.0.0"
52
52
  },
53
53
  "repository": "https://github.com/tsedio/tsed",
@@ -1,28 +0,0 @@
1
- /// <reference types="node" />
2
- import { AfterListen, InjectorService, OnDestroy, Provider } from "@tsed/common";
3
- import { ServerOptions } from "socket.io";
4
- import Http from "http";
5
- import Https from "https";
6
- /**
7
- * @ignore
8
- */
9
- export declare class SocketIOModule implements AfterListen, OnDestroy {
10
- protected disableRoutesSummary: boolean;
11
- protected settings: Partial<ServerOptions>;
12
- protected injector: InjectorService;
13
- protected httpServer: Http.Server | null;
14
- protected httpsServer: Https.Server | null;
15
- private io;
16
- private socketIOService;
17
- $afterListen(): Promise<void>;
18
- $onDestroy(): void;
19
- /**
20
- *
21
- * @returns {Provider<any>[]}
22
- */
23
- protected getWebsocketServices(): Provider<any>[];
24
- /**
25
- *
26
- */
27
- protected printSocketEvents(): void;
28
- }
@@ -1,47 +0,0 @@
1
- import { ConverterService, InjectorService, Provider } from "@tsed/common";
2
- import { Namespace, Socket } from "socket.io";
3
- /**
4
- * @ignore
5
- */
6
- export declare class SocketHandlersBuilder {
7
- private provider;
8
- private converterService;
9
- private injector;
10
- private socketProviderMetadata;
11
- constructor(provider: Provider<any>, converterService: ConverterService, injector: InjectorService);
12
- /**
13
- *
14
- * @param {SocketHandlerMetadata} handlerMetadata
15
- * @param scope
16
- * @returns {(data) => void}
17
- */
18
- private static bindResponseMiddleware;
19
- /**
20
- *
21
- * @returns {any}
22
- */
23
- build(nsps: Map<string, Namespace>): this;
24
- /**
25
- *
26
- * @param {Socket} socket
27
- * @param {Namespace} nsp
28
- */
29
- onConnection(socket: Socket, nsp: Namespace): void;
30
- onDisconnect(socket: Socket, nsp: Namespace): void;
31
- /**
32
- *
33
- * @param {Socket} socket
34
- */
35
- private createSession;
36
- /**
37
- *
38
- * @param {Socket} socket
39
- */
40
- private destroySession;
41
- private buildHandlers;
42
- private runQueue;
43
- private deserialize;
44
- private bindMiddleware;
45
- private invoke;
46
- private buildParameters;
47
- }
@@ -1,19 +0,0 @@
1
- import { SocketHandlerMetadata, SocketInjectableNsp } from "../interfaces";
2
- import { SocketProviderTypes } from "../interfaces/SocketProviderTypes";
3
- export declare class SocketProviderMetadata {
4
- type: SocketProviderTypes;
5
- namespace: string;
6
- error: boolean;
7
- injectNamespaces: SocketInjectableNsp[];
8
- useBefore: any[];
9
- useAfter: any[];
10
- handlers: Record<string, SocketHandlerMetadata>;
11
- constructor(options?: Partial<SocketProviderMetadata>);
12
- get useHandler(): SocketHandlerMetadata;
13
- get $onConnection(): SocketHandlerMetadata;
14
- get $onDisconnect(): SocketHandlerMetadata;
15
- get(key: string): SocketHandlerMetadata;
16
- set(key: string, metadata: SocketHandlerMetadata): void;
17
- getHandlers(): SocketHandlerMetadata[];
18
- createHook(hook: string, eventName: string): void;
19
- }
@@ -1 +0,0 @@
1
- export declare const PROVIDER_TYPE_SOCKET_SERVICE = "socketService";
@@ -1,28 +0,0 @@
1
- /**
2
- * Inject the list of arguments in the decorated parameter.
3
- *
4
- * `@Args` accept an index parameter to pick up directly the item in the arguments list.
5
- *
6
- * ### Example
7
- *
8
- * ```typescript
9
- * @SocketService("/nsp")
10
- * export class MyWS {
11
- *
12
- * @Input("event")
13
- * myMethod(@Args() arguments: any[]) {
14
- *
15
- * }
16
- *
17
- * @Input("event2")
18
- * myMethod2(@Args(0) data: any) {
19
- *
20
- * }
21
- * }
22
- * ```
23
- *
24
- * @decorator
25
- * @param mapIndex
26
- * @param useType
27
- */
28
- export declare function Args(mapIndex?: number, useType?: any): any;
@@ -1,23 +0,0 @@
1
- /**
2
- * Broadcast the response for all client registered in the same namespace.
3
- *
4
- * With the `@Broadcast` decorator, the method will accept a return type (Promise or not).
5
- *
6
- * ### Example
7
- *
8
- * ```typescript
9
- * @SocketService("/nsp")
10
- * export class MyWS {
11
- *
12
- * @Input("event")
13
- * @Broadcast("returnEvent")
14
- * async myMethod(@Args(0) data: any, @Nsp socket): Promise<any> {
15
- * return Promise.resolve({data})
16
- * }
17
- * }
18
- * ```
19
- *
20
- * @decorator
21
- * @param eventName
22
- */
23
- export declare function Broadcast(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,23 +0,0 @@
1
- /**
2
- * Broadcast the response for all client registered in the same namespace except to the current client.
3
- *
4
- * With the `@BroadcastOthers` decorator, the method will accept a return type (Promise or not).
5
- *
6
- * ### Example
7
- *
8
- * ```typescript
9
- * @SocketService("/nsp")
10
- * export class MyWS {
11
- *
12
- * @Input("event")
13
- * @BroadcastOthers("returnEvent")
14
- * async myMethod(@Args(0) data: any, @Nsp socket): Promise<any> {
15
- * return Promise.resolve({data})
16
- * }
17
- * }
18
- * ```
19
- *
20
- * @decorator
21
- * @param eventName
22
- */
23
- export declare function BroadcastOthers(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,23 +0,0 @@
1
- /**
2
- * Emit the response to the client.
3
- *
4
- * With the `@Emit` decorator, the method will accept a return type (Promise or not).
5
- *
6
- * ### Example
7
- *
8
- * ```typescript
9
- * @SocketService("/nsp")
10
- * export class MyWS {
11
- *
12
- * @Input("event")
13
- * @Emit("returnEvent")
14
- * async myMethod(@Args(0) data: any, @Nsp socket): Promise<any> {
15
- * return Promise.resolve({data})
16
- * }
17
- * }
18
- * ```
19
- *
20
- * @decorator
21
- * @param eventName
22
- */
23
- export declare function Emit(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,20 +0,0 @@
1
- /**
2
- * Attach the decorated method to the socket event.
3
- *
4
- * ### Example
5
- *
6
- * ```typescript
7
- * @SocketService("/nsp")
8
- * export class MyWS {
9
- *
10
- * @Input("event")
11
- * myMethod(@Args(0) data: any, @Nsp socket) {
12
- *
13
- * }
14
- * }
15
- * ```
16
- *
17
- * @decorator
18
- * @param eventName
19
- */
20
- export declare function Input(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,20 +0,0 @@
1
- /**
2
- * Attach the decorated method to the socket event and broadcast the response to all clients.
3
- *
4
- * ### Example
5
- *
6
- * ```typescript
7
- * @SocketService("/nsp")
8
- * export class MyWS {
9
- *
10
- * @InputAndBroadcast("event")
11
- * async myMethod(@Args(0) data: any, @Nsp socket) {
12
- * return {data: "data"};
13
- * }
14
- * }
15
- * ```
16
- *
17
- * @decorator
18
- * @param eventName
19
- */
20
- export declare function InputAndBroadcast(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,20 +0,0 @@
1
- /**
2
- * Attach the decorated method to the socket event and broadcast the response to all clients with the exception of the connected customer.
3
- *
4
- * ### Example
5
- *
6
- * ```typescript
7
- * @SocketService("/nsp")
8
- * export class MyWS {
9
- *
10
- * @InputAndBroadcastOthers("event")
11
- * async myMethod(@Args(0) data: any, @Nsp socket) {
12
- * return {data: "data"};
13
- * }
14
- * }
15
- * ```
16
- *
17
- * @decorator
18
- * @param eventName
19
- */
20
- export declare function InputAndBroadcastOthers(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,20 +0,0 @@
1
- /**
2
- * Attach the decorated method to the socket event and emit the response to the client.
3
- *
4
- * ### Example
5
- *
6
- * ```typescript
7
- * @SocketService("/nsp")
8
- * export class MyWS {
9
- *
10
- * @InputAndEmit("event")
11
- * async myMethod(@Args(0) data: any, @Nsp socket) {
12
- * return {data: "data"};
13
- * }
14
- * }
15
- * ```
16
- *
17
- * @decorator
18
- * @param eventName
19
- */
20
- export declare function InputAndEmit(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,20 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- /**
3
- * Inject the [SocketIO.Server](https://socket.io/docs/server-api/) instance in the decorated parameter.
4
- *
5
- * ### Example
6
- *
7
- * ```typescript
8
- * @SocketService("/nsp")
9
- * export class MyWS {
10
- * constructor(@IO private io: Server) {}
11
- * }
12
- * ```
13
- *
14
- * @param target
15
- * @param targetKey
16
- * @param descriptor
17
- * @decorator
18
- */
19
- export declare function IO(): (...args: any[]) => any;
20
- export declare function IO(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any;
@@ -1,64 +0,0 @@
1
- import { Namespace as NamespaceType } from "socket.io";
2
- export declare type Namespace = NamespaceType;
3
- export declare type Nsp = NamespaceType;
4
- /**
5
- * Inject the [SocketIO.Namespace](https://socket.io/docs/rooms-and-namespaces/#namespaces) instance in the decorated parameter.
6
- *
7
- * ### Example
8
- *
9
- * ```typescript
10
- * import {Nsp, SocketService, Input} from "@tsed/socketio";
11
- *
12
- * @SocketService("/nsp")
13
- * export class MyWS {
14
- *
15
- * @Nsp
16
- * nsp: SocketIO.Namespace; // will inject SocketIO.Namespace (not available on constructor)
17
- *
18
- * @Nsp("/my-other-namespace")
19
- * nspOther: SocketIO.Namespace; // communication between two namespace
20
- *
21
- * @Input("event")
22
- * myMethod(@Nsp namespace: SocketIO.Namespace) {
23
- *
24
- * }
25
- * }
26
- * ```
27
- *
28
- * @param target
29
- * @param {string} propertyKey
30
- * @param {number} index
31
- * @decorator
32
- */
33
- export declare function Nsp(target: any, propertyKey?: string, index?: number): any;
34
- /**
35
- * Inject the [SocketIO.Namespace](https://socket.io/docs/rooms-and-namespaces/#namespaces) instance in the decorated parameter.
36
- *
37
- * ### Example
38
- *
39
- * ```typescript
40
- * import {Namespace, SocketService, Input} from "@tsed/socketio";
41
- *
42
- * @SocketService("/nsp")
43
- * export class MyWS {
44
- *
45
- * @Nsp
46
- * nsp: Namespace; // will inject SocketIO.Namespace (not available on constructor)
47
- *
48
- * @Nsp("/my-other-namespace")
49
- * nspOther: Namespace; // communication between two namespace
50
- *
51
- * @Input("event")
52
- * myMethod(@Namespace namespace: Namespace) {
53
- *
54
- * }
55
- * }
56
- * ```
57
- *
58
- * @param target
59
- * @param {string} propertyKey
60
- * @param {number} index
61
- * @alias {Nsp}
62
- * @decorator
63
- */
64
- export declare function Namespace(target: any, propertyKey?: string, index?: number): any;
@@ -1,25 +0,0 @@
1
- import { Socket as SocketType } from "socket.io";
2
- export declare type Socket = SocketType;
3
- /**
4
- * Inject the Socket instance in the decorated parameter.
5
- *
6
- * ### Example
7
- *
8
- * ```typescript
9
- * @SocketService("/nsp")
10
- * export class MyWS {
11
- *
12
- * @Input("event")
13
- * myMethod(@Socket socket) {
14
- *
15
- * }
16
- * }
17
- * ```
18
- *
19
- * @experimental
20
- * @param target
21
- * @param {string} propertyKey
22
- * @param {number} index
23
- * @decorator
24
- */
25
- export declare function Socket(target: any, propertyKey: string, index: number): any;
@@ -1,21 +0,0 @@
1
- /**
2
- * Inject the error in the parameters
3
- *
4
- * ### Example
5
- *
6
- * ```typescript
7
- * @SocketMiddlewareError()
8
- * export class MyMiddleware {
9
- *
10
- * myMethod(@SocketErr err: any, @Args() arguments: any[]) {
11
- *
12
- * }
13
- * }
14
- * ```
15
- *
16
- * @decorator
17
- * @param target
18
- * @param propertyKey
19
- * @param index
20
- */
21
- export declare function SocketErr(target: any, propertyKey: string, index: number): any;
@@ -1,21 +0,0 @@
1
- /**
2
- * Inject the Socket instance in the decorated parameter.
3
- *
4
- * ### Example
5
- *
6
- * ```typescript
7
- * @SocketMiddleware("/nsp")
8
- * export class MyMiddleware {
9
- * use(@SocketEventName eventName: string) {
10
- *
11
- * }
12
- * }
13
- * ```
14
- *
15
- * @experimental
16
- * @param target
17
- * @param {string} propertyKey
18
- * @param {number} index
19
- * @decorator
20
- */
21
- export declare function SocketEventName(target: any, propertyKey: string, index: number): any;
@@ -1,9 +0,0 @@
1
- import { SocketFilters } from "../interfaces/SocketFilters";
2
- /**
3
- *
4
- * @param {SocketFilters} filter
5
- * @param {number} mapIndex
6
- * @returns {(target: any, propertyKey: string, index: number) => Store}
7
- * @decorator
8
- */
9
- export declare function SocketFilter(filter: SocketFilters, mapIndex?: number): (target: any, propertyKey: string, index: number) => void;
@@ -1,54 +0,0 @@
1
- /**
2
- * Declare a new SocketMiddleware.
3
- *
4
- * ### Example
5
- *
6
- * A middleware can be also used on a `SocketService` either on a class or on a method.
7
- *
8
- * Here an example of a middleware:
9
- *
10
- * ```typescript
11
- * @SocketMiddleware()
12
- * export class UserConverterSocketMiddleware {
13
- * constructor(private converterService: ConverterService) {
14
- * }
15
- * async use(@Args() args: any[]) {
16
- *
17
- * let [user] = args;
18
- * // update Arguments
19
- * user = this.converterService.deserialize(user, User);
20
- *
21
- * return [user];
22
- * }
23
- * }
24
- * ```
25
- * > The user instance will be forwarded to the next middleware and to your decorated method.
26
- *
27
- * Then:
28
- *
29
- * ```typescript
30
- * import {SocketService, SocketUseAfter, SocketUseBefore, Emit, Input, Args} from "@tsed/socketio";
31
- * import {UserConverterSocketMiddleware} from "../middlewares";
32
- * import {User} from "../models/User";
33
- *
34
- * @SocketService("/my-namespace")
35
- * @SocketUseBefore(UserConverterSocketMiddleware) // global version
36
- * export class MySocketService {
37
- *
38
- * @Input("eventName")
39
- * @Emit("responseEventName") // or Broadcast or BroadcastOthers
40
- * @SocketUseBefore(UserConverterSocketMiddleware)
41
- * async myMethod(@Args(0) user: User) {
42
- *
43
- * console.log(user);
44
- *
45
- * return user;
46
- * }
47
- * }
48
- * ```
49
- *
50
- * @returns {Function}
51
- * @decorator
52
- * @experimental
53
- */
54
- export declare function SocketMiddleware(): Function;
@@ -1,50 +0,0 @@
1
- /**
2
- * Declare a new SocketMiddlewareError.
3
- *
4
- * ### Example
5
- *
6
- * A middleware can be also used on a `SocketService` either on a class or on a method.
7
- *
8
- * Here an example of a middleware:
9
- *
10
- * ```typescript
11
- * import {SocketMiddlewareError, SocketErr, Socket, Args} from "@tsed/socketio";
12
- *
13
- * @SocketMiddlewareError()
14
- * export class ErrorHandlerSocketMiddleware {
15
- * async use(@SocketEventName, @SocketErr err: any, @Socket socket: SocketIO.Socket) {
16
- * console.error(err);
17
- * socket.emit("error", {message: "An error has occured"})
18
- * }
19
- * }
20
- * ```
21
- *
22
- * Then:
23
- *
24
- * ```typescript
25
- * import {SocketService, SocketUseAfter, SocketUseBefore, Emit, Input, Args} from "@tsed/socketio";
26
- * import {ErrorHandlerSocketMiddleware} from "../middlewares";
27
- * import {User} from "../models/User";
28
- *
29
- * @SocketService("/my-namespace")
30
- * @SocketUseAfter(ErrorHandlerSocketMiddleware) // global version
31
- * export class MySocketService {
32
- *
33
- * @Input("eventName")
34
- * @Emit("responseEventName") // or Broadcast or BroadcastOthers
35
- * @SocketUseAfter(ErrorHandlerSocketMiddleware)
36
- * async myMethod(@Args(0) userName: User) {
37
- *
38
- * console.log(user);
39
- * throw new Error("Error");
40
- *
41
- * return user;
42
- * }
43
- * }
44
- * ```
45
- *
46
- * @returns {Function}
47
- * @decorator
48
- * @experimental
49
- */
50
- export declare function SocketMiddlewareError(): Function;
@@ -1,9 +0,0 @@
1
- import { SocketReturnsTypes } from "../interfaces/SocketReturnsTypes";
2
- /**
3
- *
4
- * @param {string} eventName
5
- * @param {SocketReturnsTypes} type
6
- * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => void}
7
- * @decorator
8
- */
9
- export declare function SocketReturns(eventName: string, type: SocketReturnsTypes): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,11 +0,0 @@
1
- /**
2
- * The decorators `@SocketService()` declare a new socket service (and service) can be injected in other service or controller on there `constructor`.
3
- * All services annotated with `@SocketService()` are constructed one time.
4
- *
5
- * > `@SocketService()` use the `reflect-metadata` to collect and inject service on controllers or other services.
6
- *
7
- * @param {string} namespace
8
- * @returns {Function}
9
- * @decorator
10
- */
11
- export declare function SocketService(namespace?: string): any;
@@ -1,23 +0,0 @@
1
- export declare type SocketSession = Map<string, any>;
2
- /**
3
- * Inject the Socket instance in the decorated parameter.
4
- *
5
- * ### Example
6
- *
7
- * ```typescript
8
- * @SocketService("/nsp")
9
- * export class MyWS {
10
- *
11
- * @Input("event")
12
- * myMethod(@SocketSession session: Map) {
13
- * console.log(session);
14
- * }
15
- * }
16
- * ```
17
- *
18
- * @param target
19
- * @param {string} propertyKey
20
- * @param {number} index
21
- * @decorator
22
- */
23
- export declare function SocketSession(target: any, propertyKey: string, index: number): any;
@@ -1,52 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- /**
3
- * Attach a Socket Middleware to a method or a class.
4
- *
5
- * ### Example
6
- *
7
- * A middleware can be also used on a `SocketService` either on a class or on a method.
8
- *
9
- * Here an example of a middleware:
10
- *
11
- * ```typescript
12
- * import {SocketMiddlewareError, SocketErr, Socket, Args} from "@tsed/socketio";
13
- *
14
- * @SocketMiddlewareError()
15
- * export class ErrorHandlerSocketMiddleware {
16
- * async use(@SocketErr() err: any, @Socket socket: SocketIO.Socket) {
17
- * console.error(err);
18
- * socket.emit("error", {message: "An error has occured"})
19
- * }
20
- * }
21
- * ```
22
- *
23
- * Then:
24
- *
25
- * ```typescript
26
- * import {SocketService, SocketUseAfter, SocketUseBefore, Emit, Input, Args} from "@tsed/socketio";
27
- * import {ErrorHandlerSocketMiddleware} from "../middlewares";
28
- * import {User} from "../models/User";
29
- *
30
- * @SocketService("/my-namespace")
31
- * @SocketUseAfter(ErrorHandlerSocketMiddleware) // global version
32
- * export class MySocketService {
33
- *
34
- * @Input("eventName")
35
- * @Emit("responseEventName") // or Broadcast or BroadcastOthers
36
- * @SocketUseAfter(ErrorHandlerSocketMiddleware)
37
- * async myMethod(@Args(0) userName: User) {
38
- *
39
- * console.log(user);
40
- * throw new Error("Error");
41
- *
42
- * return user;
43
- * }
44
- * }
45
- * ```
46
- *
47
- * @returns {(target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void}
48
- * @decorator
49
- * @experimental
50
- * @param middlewares
51
- */
52
- export declare function SocketUseAfter(...middlewares: Type<any>[]): (target: any, propertyKey?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void;
@@ -1,56 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- /**
3
- * Attach a Socket Middleware to a method or a class.
4
- *
5
- * ### Example
6
- *
7
- * A middleware can be also used on a `SocketService` either on a class or on a method.
8
- *
9
- * Here an example of a middleware:
10
- *
11
- * ```typescript
12
- * @SocketMiddleware()
13
- * export class UserConverterSocketMiddleware {
14
- * constructor(private converterService: ConverterService) {
15
- * }
16
- * async use(@Args() args: any[]) {
17
- *
18
- * let [user] = args;
19
- * // update Arguments
20
- * user = ConverterService.deserialize(user, User);
21
- *
22
- * return [user];
23
- * }
24
- * }
25
- * ```
26
- * > The user instance will be forwarded to the next middleware and to your decorated method.
27
- *
28
- * Then:
29
- *
30
- * ```typescript
31
- * import {SocketService, SocketUseAfter, SocketUseBefore, Emit, Input, Args} from "@tsed/socketio";
32
- * import {UserConverterSocketMiddleware} from "../middlewares";
33
- * import {User} from "../models/User";
34
- *
35
- * @SocketService("/my-namespace")
36
- * @SocketUseBefore(UserConverterSocketMiddleware) // global version
37
- * export class MySocketService {
38
- *
39
- * @Input("eventName")
40
- * @Emit("responseEventName") // or Broadcast or BroadcastOthers
41
- * @SocketUseBefore(UserConverterSocketMiddleware)
42
- * async myMethod(@Args(0) user: User) {
43
- *
44
- * console.log(user);
45
- *
46
- * return user;
47
- * }
48
- * }
49
- * ```
50
- *
51
- * @returns {(target: any, propertyKey?: string, descriptor?: PropertyDescriptor) => void}
52
- * @decorator
53
- * @experimental
54
- * @param middlewares
55
- */
56
- export declare function SocketUseBefore(...middlewares: Type<any>[]): (target: any, propertyKey?: string | undefined, descriptor?: PropertyDescriptor | undefined) => void;
@@ -1,25 +0,0 @@
1
- export * from "./SocketIOModule";
2
- export * from "./interfaces";
3
- export * from "./class/SocketProviderMetadata";
4
- export * from "./decorators/input";
5
- export * from "./decorators/args";
6
- export * from "./decorators/io";
7
- export * from "./decorators/nsp";
8
- export * from "./decorators/emit";
9
- export * from "./decorators/broadcast";
10
- export * from "./decorators/broadcastOthers";
11
- export * from "./decorators/inputAndEmit";
12
- export * from "./decorators/inputAndBroadcast";
13
- export * from "./decorators/inputAndBroadcastOthers";
14
- export * from "./decorators/socket";
15
- export * from "./decorators/socketErr";
16
- export * from "./decorators/socketFilter";
17
- export * from "./decorators/socketMiddleware";
18
- export * from "./decorators/socketMiddlewareError";
19
- export * from "./decorators/socketService";
20
- export * from "./decorators/socketSession";
21
- export * from "./decorators/socketUseAfter";
22
- export * from "./decorators/socketUseBefore";
23
- export * from "./decorators/socketEventName";
24
- export * from "./services/SocketIOServer";
25
- export * from "./services/SocketIOService";
@@ -1,7 +0,0 @@
1
- import { Namespace } from "socket.io";
2
- /**
3
- *
4
- */
5
- export interface OnNamespaceInit {
6
- $onNamespaceInit(nsp: Namespace): void;
7
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export declare enum SocketFilters {
5
- ARGS = "args",
6
- SOCKET = "socket",
7
- EVENT_NAME = "eventName",
8
- NSP = "nsp",
9
- SESSION = "session",
10
- ERR = "error"
11
- }
@@ -1,18 +0,0 @@
1
- import { SocketParamMetadata } from "./SocketParamMetadata";
2
- import { SocketReturnsTypes } from "./SocketReturnsTypes";
3
- /**
4
- *
5
- */
6
- export interface SocketHandlerMetadata {
7
- eventName?: string;
8
- methodClassName: string;
9
- useBefore?: any[];
10
- useAfter?: any[];
11
- parameters?: {
12
- [key: number]: SocketParamMetadata;
13
- };
14
- returns?: {
15
- type: SocketReturnsTypes;
16
- eventName: string;
17
- };
18
- }
@@ -1,4 +0,0 @@
1
- export interface SocketInjectableNsp {
2
- propertyKey: string;
3
- nsp?: string;
4
- }
@@ -1,7 +0,0 @@
1
- import { MetadataTypes } from "@tsed/core";
2
- import { SocketFilters } from "./SocketFilters";
3
- export interface SocketParamMetadata extends Partial<MetadataTypes> {
4
- filter: SocketFilters;
5
- mapIndex?: number;
6
- useConverter?: boolean;
7
- }
@@ -1,7 +0,0 @@
1
- /**
2
- *
3
- */
4
- export declare enum SocketProviderTypes {
5
- SERVICE = "service",
6
- MIDDLEWARE = "middleware"
7
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export declare enum SocketReturnsTypes {
5
- BROADCAST = "broadcast",
6
- BROADCAST_OTHERS = "broadcastOthers",
7
- EMIT = "emit"
8
- }
@@ -1,15 +0,0 @@
1
- import SocketIO from "socket.io";
2
- declare global {
3
- namespace TsED {
4
- interface Configuration {
5
- socketIO: Partial<SocketIO.ServerOptions>;
6
- }
7
- }
8
- }
9
- export * from "./SocketHandlerMetadata";
10
- export * from "./SocketParamMetadata";
11
- export * from "./SocketProviderTypes";
12
- export * from "./OnNamespaceInit";
13
- export * from "./SocketFilters";
14
- export * from "./SocketReturnsTypes";
15
- export * from "./SocketInjectableNsp";
@@ -1 +0,0 @@
1
- export declare function getNspSession(namespace?: string): Map<string, any> | undefined;
@@ -1,4 +0,0 @@
1
- import { Server } from "socket.io";
2
- export declare type SocketIOServer = Server;
3
- export declare const SocketIOServer: typeof Server;
4
- export { Server };
@@ -1,30 +0,0 @@
1
- import { ConverterService, InjectorService, Provider } from "@tsed/common";
2
- import SocketIO from "socket.io";
3
- /**
4
- *
5
- */
6
- export declare class SocketIOService {
7
- private injector;
8
- private io;
9
- private converterService;
10
- /**
11
- *
12
- * @type {Map<any, any>}
13
- */
14
- private namespaces;
15
- constructor(injector: InjectorService, io: SocketIO.Server, converterService: ConverterService);
16
- /**
17
- *
18
- * @param {string} namespace
19
- * @returns {SocketIO.Namespace}
20
- */
21
- getNsp(namespace?: string): {
22
- nsp: SocketIO.Namespace;
23
- instances: any[];
24
- };
25
- /**
26
- *
27
- * @param {Provider<any>} provider
28
- */
29
- addSocketProvider(provider: Provider<any>): void;
30
- }