@tsed/socketio 8.0.0-alpha.5 → 8.0.0-alpha.6

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 (121) hide show
  1. package/lib/types/SocketIOModule.d.ts +2 -2
  2. package/package.json +17 -18
  3. package/lib/cjs/SocketIOModule.js +0 -111
  4. package/lib/cjs/SocketIOModule.js.map +0 -1
  5. package/lib/cjs/class/SocketHandlersBuilder.js +0 -218
  6. package/lib/cjs/class/SocketHandlersBuilder.js.map +0 -1
  7. package/lib/cjs/class/SocketProviderMetadata.js +0 -48
  8. package/lib/cjs/class/SocketProviderMetadata.js.map +0 -1
  9. package/lib/cjs/class/SocketSessionData.js +0 -73
  10. package/lib/cjs/class/SocketSessionData.js.map +0 -1
  11. package/lib/cjs/constants/constants.js +0 -5
  12. package/lib/cjs/constants/constants.js.map +0 -1
  13. package/lib/cjs/decorators/args.js +0 -61
  14. package/lib/cjs/decorators/args.js.map +0 -1
  15. package/lib/cjs/decorators/broadcast.js +0 -32
  16. package/lib/cjs/decorators/broadcast.js.map +0 -1
  17. package/lib/cjs/decorators/broadcastOthers.js +0 -32
  18. package/lib/cjs/decorators/broadcastOthers.js.map +0 -1
  19. package/lib/cjs/decorators/emit.js +0 -32
  20. package/lib/cjs/decorators/emit.js.map +0 -1
  21. package/lib/cjs/decorators/input.js +0 -37
  22. package/lib/cjs/decorators/input.js.map +0 -1
  23. package/lib/cjs/decorators/inputAndBroadcast.js +0 -32
  24. package/lib/cjs/decorators/inputAndBroadcast.js.map +0 -1
  25. package/lib/cjs/decorators/inputAndBroadcastOthers.js +0 -32
  26. package/lib/cjs/decorators/inputAndBroadcastOthers.js.map +0 -1
  27. package/lib/cjs/decorators/inputAndEmit.js +0 -32
  28. package/lib/cjs/decorators/inputAndEmit.js.map +0 -1
  29. package/lib/cjs/decorators/io.js +0 -13
  30. package/lib/cjs/decorators/io.js.map +0 -1
  31. package/lib/cjs/decorators/nsp.js +0 -96
  32. package/lib/cjs/decorators/nsp.js.map +0 -1
  33. package/lib/cjs/decorators/reason.js +0 -34
  34. package/lib/cjs/decorators/reason.js.map +0 -1
  35. package/lib/cjs/decorators/socket.js +0 -32
  36. package/lib/cjs/decorators/socket.js.map +0 -1
  37. package/lib/cjs/decorators/socketErr.js +0 -30
  38. package/lib/cjs/decorators/socketErr.js.map +0 -1
  39. package/lib/cjs/decorators/socketEventName.js +0 -30
  40. package/lib/cjs/decorators/socketEventName.js.map +0 -1
  41. package/lib/cjs/decorators/socketFilter.js +0 -29
  42. package/lib/cjs/decorators/socketFilter.js.map +0 -1
  43. package/lib/cjs/decorators/socketMiddleware.js +0 -74
  44. package/lib/cjs/decorators/socketMiddleware.js.map +0 -1
  45. package/lib/cjs/decorators/socketMiddlewareError.js +0 -71
  46. package/lib/cjs/decorators/socketMiddlewareError.js.map +0 -1
  47. package/lib/cjs/decorators/socketNsp.js +0 -33
  48. package/lib/cjs/decorators/socketNsp.js.map +0 -1
  49. package/lib/cjs/decorators/socketReturns.js +0 -27
  50. package/lib/cjs/decorators/socketReturns.js.map +0 -1
  51. package/lib/cjs/decorators/socketService.js +0 -24
  52. package/lib/cjs/decorators/socketService.js.map +0 -1
  53. package/lib/cjs/decorators/socketSession.js +0 -55
  54. package/lib/cjs/decorators/socketSession.js.map +0 -1
  55. package/lib/cjs/decorators/socketUseAfter.js +0 -74
  56. package/lib/cjs/decorators/socketUseAfter.js.map +0 -1
  57. package/lib/cjs/decorators/socketUseBefore.js +0 -78
  58. package/lib/cjs/decorators/socketUseBefore.js.map +0 -1
  59. package/lib/cjs/index.js +0 -45
  60. package/lib/cjs/index.js.map +0 -1
  61. package/lib/cjs/interfaces/OnNamespaceInit.js +0 -3
  62. package/lib/cjs/interfaces/OnNamespaceInit.js.map +0 -1
  63. package/lib/cjs/interfaces/SocketFilters.js +0 -19
  64. package/lib/cjs/interfaces/SocketFilters.js.map +0 -1
  65. package/lib/cjs/interfaces/SocketHandlerMetadata.js +0 -3
  66. package/lib/cjs/interfaces/SocketHandlerMetadata.js.map +0 -1
  67. package/lib/cjs/interfaces/SocketInjectableNsp.js +0 -3
  68. package/lib/cjs/interfaces/SocketInjectableNsp.js.map +0 -1
  69. package/lib/cjs/interfaces/SocketParamMetadata.js +0 -3
  70. package/lib/cjs/interfaces/SocketParamMetadata.js.map +0 -1
  71. package/lib/cjs/interfaces/SocketProviderTypes.js +0 -12
  72. package/lib/cjs/interfaces/SocketProviderTypes.js.map +0 -1
  73. package/lib/cjs/interfaces/SocketReturnsTypes.js +0 -13
  74. package/lib/cjs/interfaces/SocketReturnsTypes.js.map +0 -1
  75. package/lib/cjs/interfaces/interfaces.js +0 -3
  76. package/lib/cjs/interfaces/interfaces.js.map +0 -1
  77. package/lib/cjs/package.json +0 -3
  78. package/lib/cjs/services/SocketIOServer.js +0 -16
  79. package/lib/cjs/services/SocketIOServer.js.map +0 -1
  80. package/lib/cjs/services/SocketIOService.js +0 -66
  81. package/lib/cjs/services/SocketIOService.js.map +0 -1
  82. package/lib/esm/package.json +0 -3
  83. package/lib/types-esm/SocketIOModule.d.ts +0 -29
  84. package/lib/types-esm/class/SocketHandlersBuilder.d.ts +0 -37
  85. package/lib/types-esm/class/SocketProviderMetadata.d.ts +0 -20
  86. package/lib/types-esm/class/SocketSessionData.d.ts +0 -23
  87. package/lib/types-esm/constants/constants.d.ts +0 -1
  88. package/lib/types-esm/decorators/args.d.ts +0 -28
  89. package/lib/types-esm/decorators/broadcast.d.ts +0 -23
  90. package/lib/types-esm/decorators/broadcastOthers.d.ts +0 -23
  91. package/lib/types-esm/decorators/emit.d.ts +0 -23
  92. package/lib/types-esm/decorators/input.d.ts +0 -20
  93. package/lib/types-esm/decorators/inputAndBroadcast.d.ts +0 -20
  94. package/lib/types-esm/decorators/inputAndBroadcastOthers.d.ts +0 -20
  95. package/lib/types-esm/decorators/inputAndEmit.d.ts +0 -20
  96. package/lib/types-esm/decorators/io.d.ts +0 -20
  97. package/lib/types-esm/decorators/nsp.d.ts +0 -72
  98. package/lib/types-esm/decorators/reason.d.ts +0 -25
  99. package/lib/types-esm/decorators/socket.d.ts +0 -25
  100. package/lib/types-esm/decorators/socketErr.d.ts +0 -21
  101. package/lib/types-esm/decorators/socketEventName.d.ts +0 -21
  102. package/lib/types-esm/decorators/socketFilter.d.ts +0 -9
  103. package/lib/types-esm/decorators/socketMiddleware.d.ts +0 -54
  104. package/lib/types-esm/decorators/socketMiddlewareError.d.ts +0 -50
  105. package/lib/types-esm/decorators/socketNsp.d.ts +0 -26
  106. package/lib/types-esm/decorators/socketReturns.d.ts +0 -9
  107. package/lib/types-esm/decorators/socketService.d.ts +0 -11
  108. package/lib/types-esm/decorators/socketSession.d.ts +0 -44
  109. package/lib/types-esm/decorators/socketUseAfter.d.ts +0 -52
  110. package/lib/types-esm/decorators/socketUseBefore.d.ts +0 -56
  111. package/lib/types-esm/index.d.ts +0 -41
  112. package/lib/types-esm/interfaces/OnNamespaceInit.d.ts +0 -7
  113. package/lib/types-esm/interfaces/SocketFilters.d.ts +0 -14
  114. package/lib/types-esm/interfaces/SocketHandlerMetadata.d.ts +0 -18
  115. package/lib/types-esm/interfaces/SocketInjectableNsp.d.ts +0 -4
  116. package/lib/types-esm/interfaces/SocketParamMetadata.d.ts +0 -7
  117. package/lib/types-esm/interfaces/SocketProviderTypes.d.ts +0 -7
  118. package/lib/types-esm/interfaces/SocketReturnsTypes.d.ts +0 -8
  119. package/lib/types-esm/interfaces/interfaces.d.ts +0 -8
  120. package/lib/types-esm/services/SocketIOServer.d.ts +0 -4
  121. package/lib/types-esm/services/SocketIOService.d.ts +0 -29
@@ -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
- }
@@ -1,4 +0,0 @@
1
- export interface SocketInjectableNsp {
2
- propertyKey: string;
3
- nsp?: string | RegExp;
4
- }
@@ -1,7 +0,0 @@
1
- import { MetadataTypes } from "@tsed/core";
2
- import { SocketFilters } from "./SocketFilters.js";
3
- export interface SocketParamMetadata extends Partial<MetadataTypes> {
4
- filter: SocketFilters;
5
- mapIndex?: number;
6
- useMapper?: 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,8 +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
- }
@@ -1,4 +0,0 @@
1
- import { Server } from "socket.io";
2
- export type SocketIOServer = Server;
3
- export declare const SocketIOServer: typeof Server;
4
- export { Server };
@@ -1,29 +0,0 @@
1
- import { InjectorService, Provider } from "@tsed/common";
2
- import * as SocketIO from "socket.io";
3
- /**
4
- *
5
- */
6
- export declare class SocketIOService {
7
- private injector;
8
- private io;
9
- /**
10
- *
11
- * @type {Map<any, any>}
12
- */
13
- private namespaces;
14
- constructor(injector: InjectorService, io: SocketIO.Server);
15
- /**
16
- *
17
- * @param {string} namespace
18
- * @returns {SocketIO.Namespace}
19
- */
20
- getNsp(namespace?: string | RegExp): {
21
- nsp: SocketIO.Namespace;
22
- instances: any[];
23
- };
24
- /**
25
- *
26
- * @param {Provider<any>} provider
27
- */
28
- addSocketProvider(provider: Provider<any>): void;
29
- }