@tsed/socketio 7.83.3 → 8.0.0-alpha.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 (147) hide show
  1. package/lib/esm/SocketIOModule.js +3 -3
  2. package/lib/esm/SocketIOModule.js.map +1 -1
  3. package/lib/esm/class/SocketHandlersBuilder.js +1 -1
  4. package/lib/esm/class/SocketHandlersBuilder.js.map +1 -1
  5. package/lib/esm/class/SocketSessionData.js.map +1 -1
  6. package/lib/esm/decorators/args.js.map +1 -1
  7. package/lib/esm/decorators/io.js.map +1 -1
  8. package/lib/esm/decorators/nsp.js +1 -1
  9. package/lib/esm/decorators/nsp.js.map +1 -1
  10. package/lib/esm/decorators/reason.js +1 -1
  11. package/lib/esm/decorators/reason.js.map +1 -1
  12. package/lib/esm/decorators/socket.js.map +1 -1
  13. package/lib/esm/decorators/socketFilter.js.map +1 -1
  14. package/lib/esm/decorators/socketMiddleware.js +1 -1
  15. package/lib/esm/decorators/socketMiddleware.js.map +1 -1
  16. package/lib/esm/decorators/socketMiddlewareError.js +1 -1
  17. package/lib/esm/decorators/socketMiddlewareError.js.map +1 -1
  18. package/lib/esm/decorators/socketNsp.js.map +1 -1
  19. package/lib/esm/decorators/socketReturns.js.map +1 -1
  20. package/lib/esm/decorators/socketService.js +1 -1
  21. package/lib/esm/decorators/socketService.js.map +1 -1
  22. package/lib/esm/decorators/socketUseAfter.js.map +1 -1
  23. package/lib/esm/decorators/socketUseBefore.js.map +1 -1
  24. package/lib/esm/services/SocketIOService.js.map +1 -1
  25. package/lib/types/SocketIOModule.d.ts +3 -3
  26. package/package.json +29 -27
  27. package/vitest.config.mts +5 -5
  28. package/.nycrc +0 -27
  29. package/lib/cjs/SocketIOModule.js +0 -111
  30. package/lib/cjs/SocketIOModule.js.map +0 -1
  31. package/lib/cjs/class/SocketHandlersBuilder.js +0 -218
  32. package/lib/cjs/class/SocketHandlersBuilder.js.map +0 -1
  33. package/lib/cjs/class/SocketProviderMetadata.js +0 -48
  34. package/lib/cjs/class/SocketProviderMetadata.js.map +0 -1
  35. package/lib/cjs/class/SocketSessionData.js +0 -73
  36. package/lib/cjs/class/SocketSessionData.js.map +0 -1
  37. package/lib/cjs/constants/constants.js +0 -5
  38. package/lib/cjs/constants/constants.js.map +0 -1
  39. package/lib/cjs/decorators/args.js +0 -61
  40. package/lib/cjs/decorators/args.js.map +0 -1
  41. package/lib/cjs/decorators/broadcast.js +0 -32
  42. package/lib/cjs/decorators/broadcast.js.map +0 -1
  43. package/lib/cjs/decorators/broadcastOthers.js +0 -32
  44. package/lib/cjs/decorators/broadcastOthers.js.map +0 -1
  45. package/lib/cjs/decorators/emit.js +0 -32
  46. package/lib/cjs/decorators/emit.js.map +0 -1
  47. package/lib/cjs/decorators/input.js +0 -37
  48. package/lib/cjs/decorators/input.js.map +0 -1
  49. package/lib/cjs/decorators/inputAndBroadcast.js +0 -32
  50. package/lib/cjs/decorators/inputAndBroadcast.js.map +0 -1
  51. package/lib/cjs/decorators/inputAndBroadcastOthers.js +0 -32
  52. package/lib/cjs/decorators/inputAndBroadcastOthers.js.map +0 -1
  53. package/lib/cjs/decorators/inputAndEmit.js +0 -32
  54. package/lib/cjs/decorators/inputAndEmit.js.map +0 -1
  55. package/lib/cjs/decorators/io.js +0 -13
  56. package/lib/cjs/decorators/io.js.map +0 -1
  57. package/lib/cjs/decorators/nsp.js +0 -96
  58. package/lib/cjs/decorators/nsp.js.map +0 -1
  59. package/lib/cjs/decorators/reason.js +0 -34
  60. package/lib/cjs/decorators/reason.js.map +0 -1
  61. package/lib/cjs/decorators/socket.js +0 -32
  62. package/lib/cjs/decorators/socket.js.map +0 -1
  63. package/lib/cjs/decorators/socketErr.js +0 -30
  64. package/lib/cjs/decorators/socketErr.js.map +0 -1
  65. package/lib/cjs/decorators/socketEventName.js +0 -30
  66. package/lib/cjs/decorators/socketEventName.js.map +0 -1
  67. package/lib/cjs/decorators/socketFilter.js +0 -29
  68. package/lib/cjs/decorators/socketFilter.js.map +0 -1
  69. package/lib/cjs/decorators/socketMiddleware.js +0 -74
  70. package/lib/cjs/decorators/socketMiddleware.js.map +0 -1
  71. package/lib/cjs/decorators/socketMiddlewareError.js +0 -71
  72. package/lib/cjs/decorators/socketMiddlewareError.js.map +0 -1
  73. package/lib/cjs/decorators/socketNsp.js +0 -33
  74. package/lib/cjs/decorators/socketNsp.js.map +0 -1
  75. package/lib/cjs/decorators/socketReturns.js +0 -27
  76. package/lib/cjs/decorators/socketReturns.js.map +0 -1
  77. package/lib/cjs/decorators/socketService.js +0 -24
  78. package/lib/cjs/decorators/socketService.js.map +0 -1
  79. package/lib/cjs/decorators/socketSession.js +0 -55
  80. package/lib/cjs/decorators/socketSession.js.map +0 -1
  81. package/lib/cjs/decorators/socketUseAfter.js +0 -74
  82. package/lib/cjs/decorators/socketUseAfter.js.map +0 -1
  83. package/lib/cjs/decorators/socketUseBefore.js +0 -78
  84. package/lib/cjs/decorators/socketUseBefore.js.map +0 -1
  85. package/lib/cjs/index.js +0 -45
  86. package/lib/cjs/index.js.map +0 -1
  87. package/lib/cjs/interfaces/OnNamespaceInit.js +0 -3
  88. package/lib/cjs/interfaces/OnNamespaceInit.js.map +0 -1
  89. package/lib/cjs/interfaces/SocketFilters.js +0 -19
  90. package/lib/cjs/interfaces/SocketFilters.js.map +0 -1
  91. package/lib/cjs/interfaces/SocketHandlerMetadata.js +0 -3
  92. package/lib/cjs/interfaces/SocketHandlerMetadata.js.map +0 -1
  93. package/lib/cjs/interfaces/SocketInjectableNsp.js +0 -3
  94. package/lib/cjs/interfaces/SocketInjectableNsp.js.map +0 -1
  95. package/lib/cjs/interfaces/SocketParamMetadata.js +0 -3
  96. package/lib/cjs/interfaces/SocketParamMetadata.js.map +0 -1
  97. package/lib/cjs/interfaces/SocketProviderTypes.js +0 -12
  98. package/lib/cjs/interfaces/SocketProviderTypes.js.map +0 -1
  99. package/lib/cjs/interfaces/SocketReturnsTypes.js +0 -13
  100. package/lib/cjs/interfaces/SocketReturnsTypes.js.map +0 -1
  101. package/lib/cjs/interfaces/interfaces.js +0 -3
  102. package/lib/cjs/interfaces/interfaces.js.map +0 -1
  103. package/lib/cjs/package.json +0 -3
  104. package/lib/cjs/services/SocketIOServer.js +0 -16
  105. package/lib/cjs/services/SocketIOServer.js.map +0 -1
  106. package/lib/cjs/services/SocketIOService.js +0 -66
  107. package/lib/cjs/services/SocketIOService.js.map +0 -1
  108. package/lib/esm/package.json +0 -3
  109. package/lib/types-esm/SocketIOModule.d.ts +0 -29
  110. package/lib/types-esm/class/SocketHandlersBuilder.d.ts +0 -37
  111. package/lib/types-esm/class/SocketProviderMetadata.d.ts +0 -20
  112. package/lib/types-esm/class/SocketSessionData.d.ts +0 -23
  113. package/lib/types-esm/constants/constants.d.ts +0 -1
  114. package/lib/types-esm/decorators/args.d.ts +0 -28
  115. package/lib/types-esm/decorators/broadcast.d.ts +0 -23
  116. package/lib/types-esm/decorators/broadcastOthers.d.ts +0 -23
  117. package/lib/types-esm/decorators/emit.d.ts +0 -23
  118. package/lib/types-esm/decorators/input.d.ts +0 -20
  119. package/lib/types-esm/decorators/inputAndBroadcast.d.ts +0 -20
  120. package/lib/types-esm/decorators/inputAndBroadcastOthers.d.ts +0 -20
  121. package/lib/types-esm/decorators/inputAndEmit.d.ts +0 -20
  122. package/lib/types-esm/decorators/io.d.ts +0 -20
  123. package/lib/types-esm/decorators/nsp.d.ts +0 -72
  124. package/lib/types-esm/decorators/reason.d.ts +0 -25
  125. package/lib/types-esm/decorators/socket.d.ts +0 -25
  126. package/lib/types-esm/decorators/socketErr.d.ts +0 -21
  127. package/lib/types-esm/decorators/socketEventName.d.ts +0 -21
  128. package/lib/types-esm/decorators/socketFilter.d.ts +0 -9
  129. package/lib/types-esm/decorators/socketMiddleware.d.ts +0 -54
  130. package/lib/types-esm/decorators/socketMiddlewareError.d.ts +0 -50
  131. package/lib/types-esm/decorators/socketNsp.d.ts +0 -26
  132. package/lib/types-esm/decorators/socketReturns.d.ts +0 -9
  133. package/lib/types-esm/decorators/socketService.d.ts +0 -11
  134. package/lib/types-esm/decorators/socketSession.d.ts +0 -44
  135. package/lib/types-esm/decorators/socketUseAfter.d.ts +0 -52
  136. package/lib/types-esm/decorators/socketUseBefore.d.ts +0 -56
  137. package/lib/types-esm/index.d.ts +0 -41
  138. package/lib/types-esm/interfaces/OnNamespaceInit.d.ts +0 -7
  139. package/lib/types-esm/interfaces/SocketFilters.d.ts +0 -14
  140. package/lib/types-esm/interfaces/SocketHandlerMetadata.d.ts +0 -18
  141. package/lib/types-esm/interfaces/SocketInjectableNsp.d.ts +0 -4
  142. package/lib/types-esm/interfaces/SocketParamMetadata.d.ts +0 -7
  143. package/lib/types-esm/interfaces/SocketProviderTypes.d.ts +0 -7
  144. package/lib/types-esm/interfaces/SocketReturnsTypes.d.ts +0 -8
  145. package/lib/types-esm/interfaces/interfaces.d.ts +0 -8
  146. package/lib/types-esm/services/SocketIOServer.d.ts +0 -4
  147. package/lib/types-esm/services/SocketIOService.d.ts +0 -29
@@ -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 | symbol | undefined, descriptor: TypedPropertyDescriptor<Function> | number): any;
@@ -1,72 +0,0 @@
1
- import { Namespace as NamespaceType } from "socket.io";
2
- export type Namespace = NamespaceType;
3
- export type Nsp = NamespaceType;
4
- /**
5
- * Inject the [SocketIO.Namespace](https://socket.io/docs/rooms-and-namespaces/#namespaces) instance in the decorated parameter.
6
- * Note that when using dynamic namespaces, when injecting a parameter, you may want to consider using @SocketNsp instead.
7
- *
8
- * ### Example
9
- *
10
- * ```typescript
11
- * import {Nsp, SocketService, Input} from "@tsed/socketio";
12
- *
13
- * @SocketService("/nsp")
14
- * export class MyWS {
15
- *
16
- * @Nsp
17
- * nsp: SocketIO.Namespace; // will inject SocketIO.Namespace (not available on constructor)
18
- *
19
- * @Nsp("/my-other-namespace")
20
- * nspOther: SocketIO.Namespace; // communication between two namespace
21
- *
22
- * @Nsp(/regexp/)
23
- * nspDynamic: SocketIO.Namespace; // will inject a dynamic namespace (not available on constructor)
24
- *
25
- * @Input("event")
26
- * myMethod(@Nsp namespace: SocketIO.Namespace) {
27
- *
28
- * }
29
- * }
30
- * ```
31
- *
32
- * @param target
33
- * @param {string} propertyKey
34
- * @param {number} index
35
- * @decorator
36
- */
37
- export declare function Nsp(target: any, propertyKey?: string, index?: number): any;
38
- /**
39
- * Inject the [SocketIO.Namespace](https://socket.io/docs/rooms-and-namespaces/#namespaces) instance in the decorated parameter.
40
- * Note that when using dynamic namespaces, when injecting a parameter, you may want to consider using @SocketNsp instead.
41
- *
42
- * ### Example
43
- *
44
- * ```typescript
45
- * import {Namespace, SocketService, Input} from "@tsed/socketio";
46
- *
47
- * @SocketService("/nsp")
48
- * export class MyWS {
49
- *
50
- * @Namespace
51
- * nsp: SocketIO.Namespace; // will inject SocketIO.Namespace (not available on constructor)
52
- *
53
- * @Namespace("/my-other-namespace")
54
- * nspOther: SocketIO.Namespace; // communication between two namespace
55
- *
56
- * @Namespace(/regexp/)
57
- * nspDynamic: SocketIO.Namespace; // will inject a dynamic namespace (not available on constructor)
58
- *
59
- * @Input("event")
60
- * myMethod(@Namespace namespace: Namespace) {
61
- *
62
- * }
63
- * }
64
- * ```
65
- *
66
- * @param target
67
- * @param {string} propertyKey
68
- * @param {number} index
69
- * @alias {Nsp}
70
- * @decorator
71
- */
72
- export declare function Namespace(target: any, propertyKey?: string, index?: number): any;
@@ -1,25 +0,0 @@
1
- /**
2
- * Inject the disconnection reason into the decorated parameter.
3
- *
4
- * This decorator is used in conjunction with the `$onDisconnect` event handler to handle disconnection reasons in SocketIO services.
5
- * It allows you to access the reason for the disconnection in your method implementation. For details please refer to the [Socket.io documentation](https://socket.io/docs/v4/server-api/#event-disconnect).
6
- *
7
- * @example
8
- * ```typescript
9
- * @SocketService("/nsp")
10
- * export class MyWS {
11
- * public async $onDisconnect(
12
- * @Reason reason: string = ''
13
- * ) {
14
- * // your implementation
15
- * }
16
- * }
17
- * ```
18
- *
19
- * @experimental This decorator is experimental and may change or be removed in future versions.
20
- * @param target
21
- * @param {string} propertyKey
22
- * @param {number} index
23
- * @decorator
24
- */
25
- export declare function Reason(target: unknown, propertyKey: string, index: number): void;
@@ -1,25 +0,0 @@
1
- import { Socket as SocketType } from "socket.io";
2
- export 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.js";
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.js";
32
- * import {User} from "../models/User.js";
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.js";
27
- * import {User} from "../models/User.js";
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,26 +0,0 @@
1
- import { Namespace } from "./nsp.js";
2
- export type SocketNsp = Namespace;
3
- /**
4
- * Inject the [SocketIO.Namespace](https://socket.io/docs/rooms-and-namespaces/#namespaces) instance in the decorated parameter.
5
- * This namespace may differ from the default namespace when using dynamic namespaces.
6
- *
7
- * ### Example
8
- *
9
- * ```typescript
10
- * @SocketService(/nsp-.+/)
11
- * export class MyWS {
12
- *
13
- * @Input("event")
14
- * myMethod(@SocketNsp nsp: SocketNsp) {
15
- *
16
- * }
17
- * }
18
- * ```
19
- *
20
- * @experimental
21
- * @param target
22
- * @param {string} propertyKey
23
- * @param {number} index
24
- * @decorator
25
- */
26
- export declare function SocketNsp(target: any, propertyKey: string, index: number): any;
@@ -1,9 +0,0 @@
1
- import { SocketReturnsTypes } from "../interfaces/SocketReturnsTypes.js";
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 namespace
8
- * @returns {Function}
9
- * @decorator
10
- */
11
- export declare function SocketService(namespace?: string | RegExp): any;
@@ -1,44 +0,0 @@
1
- export type SocketSession = Map<string, any>;
2
- /**
3
- * Inject the socket session data 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: SocketSession) {
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): void;
24
- /**
25
- * Inject the raw `socket.data` in the decorated parameter.
26
- *
27
- * @example
28
- * ```typescript
29
- * @SocketService("/nsp")
30
- * export class MyWS {
31
- *
32
- * @Input("event")
33
- * myMethod(@RawSocketSession session: Record<string, unknown>) {
34
- * console.log(session);
35
- * }
36
- * }
37
- * ```
38
- *
39
- * @param target
40
- * @param {string} propertyKey
41
- * @param {number} index
42
- * @constructor
43
- */
44
- export declare function RawSocketSession(target: any, propertyKey: string, index: number): void;
@@ -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.js";
28
- * import {User} from "../models/User.js";
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, descriptor?: PropertyDescriptor) => 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.js";
33
- * import {User} from "../models/User.js";
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, descriptor?: PropertyDescriptor) => void;
@@ -1,41 +0,0 @@
1
- /**
2
- * @file Automatically generated by @tsed/barrels.
3
- */
4
- export * from "./class/SocketHandlersBuilder.js";
5
- export * from "./class/SocketProviderMetadata.js";
6
- export * from "./class/SocketSessionData.js";
7
- export * from "./constants/constants.js";
8
- export * from "./decorators/args.js";
9
- export * from "./decorators/broadcast.js";
10
- export * from "./decorators/broadcastOthers.js";
11
- export * from "./decorators/emit.js";
12
- export * from "./decorators/input.js";
13
- export * from "./decorators/inputAndBroadcast.js";
14
- export * from "./decorators/inputAndBroadcastOthers.js";
15
- export * from "./decorators/inputAndEmit.js";
16
- export * from "./decorators/io.js";
17
- export * from "./decorators/nsp.js";
18
- export * from "./decorators/reason.js";
19
- export * from "./decorators/socket.js";
20
- export * from "./decorators/socketErr.js";
21
- export * from "./decorators/socketEventName.js";
22
- export * from "./decorators/socketFilter.js";
23
- export * from "./decorators/socketMiddleware.js";
24
- export * from "./decorators/socketMiddlewareError.js";
25
- export * from "./decorators/socketNsp.js";
26
- export * from "./decorators/socketReturns.js";
27
- export * from "./decorators/socketService.js";
28
- export * from "./decorators/socketSession.js";
29
- export * from "./decorators/socketUseAfter.js";
30
- export * from "./decorators/socketUseBefore.js";
31
- export * from "./interfaces/interfaces.js";
32
- export * from "./interfaces/OnNamespaceInit.js";
33
- export * from "./interfaces/SocketFilters.js";
34
- export * from "./interfaces/SocketHandlerMetadata.js";
35
- export * from "./interfaces/SocketInjectableNsp.js";
36
- export * from "./interfaces/SocketParamMetadata.js";
37
- export * from "./interfaces/SocketProviderTypes.js";
38
- export * from "./interfaces/SocketReturnsTypes.js";
39
- export * from "./services/SocketIOServer.js";
40
- export * from "./services/SocketIOService.js";
41
- export * from "./SocketIOModule.js";
@@ -1,7 +0,0 @@
1
- import { Namespace } from "socket.io";
2
- /**
3
- *
4
- */
5
- export interface OnNamespaceInit {
6
- $onNamespaceInit(nsp: Namespace): void;
7
- }
@@ -1,14 +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
- RAW_SESSION = "raw_session",
11
- ERR = "error",
12
- SOCKET_NSP = "socket_nsp",
13
- REASON = "reason"
14
- }
@@ -1,18 +0,0 @@
1
- import { SocketParamMetadata } from "./SocketParamMetadata.js";
2
- import { SocketReturnsTypes } from "./SocketReturnsTypes.js";
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
- }