@eleven-am/pondsocket-nest 0.0.133 → 0.0.135
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/constants.d.ts +12 -0
- package/constants.js +2 -1
- package/context/context.d.ts +21 -0
- package/decorators/channel.d.ts +1 -0
- package/decorators/channelInstance.d.ts +1 -0
- package/decorators/endpoint.d.ts +1 -0
- package/decorators/endpointInstance.d.ts +1 -0
- package/decorators/getChannel.d.ts +1 -0
- package/decorators/getChannel.js +2 -8
- package/decorators/getConnectionContext.d.ts +1 -0
- package/decorators/getConnectionContext.js +2 -8
- package/decorators/getConnectionHeaders.d.ts +1 -0
- package/decorators/getConnectionHeaders.js +2 -8
- package/decorators/getContext.d.ts +1 -0
- package/decorators/getEventContext.d.ts +1 -0
- package/decorators/getEventContext.js +2 -8
- package/decorators/getEventParams.d.ts +1 -0
- package/decorators/getEventParams.js +2 -8
- package/decorators/getEventPayload.d.ts +1 -0
- package/decorators/getEventPayload.js +2 -8
- package/decorators/getEventQuery.d.ts +1 -0
- package/decorators/getEventQuery.js +2 -8
- package/decorators/getJoinContext.d.ts +1 -0
- package/decorators/getJoinContext.js +2 -8
- package/decorators/getJoinParams.d.ts +1 -0
- package/decorators/getJoinParams.js +2 -8
- package/decorators/getLeaveEvent.d.ts +1 -0
- package/decorators/getLeaveEvent.js +2 -8
- package/decorators/getUserAssigns.d.ts +1 -0
- package/decorators/getUserAssigns.js +2 -8
- package/decorators/getUserData.d.ts +1 -0
- package/decorators/getUserData.js +2 -8
- package/decorators/getUserPresence.d.ts +1 -0
- package/decorators/getUserPresence.js +2 -8
- package/decorators/index.d.ts +25 -0
- package/decorators/index.js +1 -0
- package/decorators/onConnectionRequest.d.ts +1 -0
- package/decorators/onEvent.d.ts +1 -0
- package/decorators/onJoinRequest.d.ts +1 -0
- package/decorators/onLeave.d.ts +1 -0
- package/decorators/onLeave.js +3 -1
- package/decorators/onOutgoingEvent.d.ts +1 -0
- package/decorators/onOutgoingEvent.js +22 -0
- package/decorators/useGuards.d.ts +2 -0
- package/decorators/usePipes.d.ts +3 -0
- package/helpers/createContextParamDecorator.d.ts +2 -0
- package/helpers/createContextParamDecorator.js +13 -0
- package/helpers/createParamDecorator.d.ts +3 -0
- package/helpers/misc.d.ts +3 -0
- package/helpers/misc.js +2 -1
- package/index.d.ts +5 -287
- package/managers/channel.d.ts +4 -0
- package/managers/channelInstance.d.ts +5 -0
- package/managers/class.d.ts +5 -0
- package/managers/connection.d.ts +5 -0
- package/managers/createMetadataManager.d.ts +8 -0
- package/managers/createMetadataManager.js +36 -0
- package/managers/endpoint.d.ts +4 -0
- package/managers/endpointInstance.d.ts +5 -0
- package/managers/event.d.ts +5 -0
- package/managers/guards.d.ts +6 -0
- package/managers/guards.js +5 -31
- package/managers/handlers.d.ts +5 -0
- package/managers/join.d.ts +5 -0
- package/managers/leave.d.ts +5 -0
- package/managers/method.d.ts +5 -0
- package/managers/outgoingEvent.d.ts +5 -0
- package/managers/outgoingEvent.js +8 -0
- package/managers/parametres.d.ts +9 -0
- package/managers/pipes.d.ts +6 -0
- package/managers/pipes.js +5 -31
- package/managers/property.d.ts +4 -0
- package/modules/pondSocket.d.ts +7 -0
- package/modules/pondSocket.js +2 -3
- package/package.json +26 -12
- package/performers/action.d.ts +5 -0
- package/performers/action.js +7 -4
- package/performers/errors.d.ts +2 -0
- package/performers/errors.js +0 -1
- package/performers/narrow.d.ts +7 -0
- package/performers/response.d.ts +3 -0
- package/performers/response.js +29 -40
- package/services/pondSocket.d.ts +24 -0
- package/services/pondSocket.js +23 -8
- package/types.d.ts +64 -0
package/index.d.ts
CHANGED
|
@@ -1,287 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
JoinContext,
|
|
7
|
-
JoinParams,
|
|
8
|
-
LeaveEvent,
|
|
9
|
-
Params,
|
|
10
|
-
PondAssigns,
|
|
11
|
-
PondEvent,
|
|
12
|
-
PondEventMap,
|
|
13
|
-
PondMessage,
|
|
14
|
-
PondPresence,
|
|
15
|
-
UserData,
|
|
16
|
-
} from '@eleven-am/pondsocket/types';
|
|
17
|
-
import type {DynamicModule, ModuleMetadata, PipeTransform} from '@nestjs/common';
|
|
18
|
-
|
|
19
|
-
type Constructor<T> = new (...args: any[]) => T;
|
|
20
|
-
|
|
21
|
-
type ParamDecoratorCallback<Input, ParamType> = (data: Input, context: Context, type: ParamType) => unknown | Promise<unknown>;
|
|
22
|
-
|
|
23
|
-
interface CanActivate {
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @desc Whether the client can continue with the request
|
|
27
|
-
* @param context - The context of the request
|
|
28
|
-
*/
|
|
29
|
-
canActivate(context: Context): boolean | Promise<boolean>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface Metadata extends Omit<ModuleMetadata, 'controllers'> {
|
|
33
|
-
guards?: Constructor<CanActivate>[];
|
|
34
|
-
pipes?: Constructor<PipeTransform>[];
|
|
35
|
-
isExclusiveSocketServer?: boolean;
|
|
36
|
-
isGlobal?: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface AsyncMetadata extends Omit<Metadata, 'backend'> {
|
|
40
|
-
isGlobal?: boolean;
|
|
41
|
-
inject?: any[];
|
|
42
|
-
imports?: any[];
|
|
43
|
-
useFactory: (...args: any[]) => Promise<IDistributedBackend> | IDistributedBackend;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type NestFuncType<Event extends string, Payload extends PondMessage, Presence extends PondPresence, Assigns extends PondAssigns = PondAssigns> = {
|
|
47
|
-
event?: Event;
|
|
48
|
-
broadcast?: Event;
|
|
49
|
-
broadcastFrom?: Event;
|
|
50
|
-
assigns?: Partial<Assigns>;
|
|
51
|
-
presence?: Presence;
|
|
52
|
-
} & Payload;
|
|
53
|
-
|
|
54
|
-
type PondResponse<EventType extends PondEventMap = PondEventMap, Event extends keyof EventType = string, Presence extends PondPresence = PondPresence, Assigns extends PondAssigns = PondAssigns> =
|
|
55
|
-
Event extends string ?
|
|
56
|
-
EventType[Event] extends [PondMessage, PondMessage] ? NestFuncType<Event, EventType[Event][1], Presence, Assigns> :
|
|
57
|
-
EventType[Event] extends PondMessage ? NestFuncType<Event, EventType[Event], Presence, Assigns> :
|
|
58
|
-
never :
|
|
59
|
-
never;
|
|
60
|
-
|
|
61
|
-
declare class Context<Path extends string = string, Event extends PondEventMap = PondEventMap, Presence extends PondPresence = PondPresence, Assigns extends PondAssigns = PondAssigns> {
|
|
62
|
-
/**
|
|
63
|
-
* @desc The request object, available in onJoin handlers
|
|
64
|
-
*/
|
|
65
|
-
get joinContext (): JoinContext<Path, Event, Presence, Assigns> | null;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @desc The request object, available in onEvent handlers
|
|
69
|
-
*/
|
|
70
|
-
get eventContext (): EventContext<Path, Event, Presence, Assigns> | null;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @desc The request object, available in onConnection handlers
|
|
74
|
-
*/
|
|
75
|
-
get connectionContext (): ConnectionContext<Path> | null;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @desc The request object, available in onLeave handlers
|
|
79
|
-
*/
|
|
80
|
-
get leaveEvent (): LeaveEvent | null;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @desc The presence object, available on the channel
|
|
84
|
-
*/
|
|
85
|
-
get presence (): Presence;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @desc The assigns object, available on the channel
|
|
89
|
-
*/
|
|
90
|
-
get assigns (): Assigns;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @desc The user object, assigned to the current user
|
|
94
|
-
*/
|
|
95
|
-
get user (): UserData<Presence, Assigns> | null;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @desc The channel object handling the request
|
|
99
|
-
*/
|
|
100
|
-
get channel (): PondChannel<Event, Presence, Assigns> | null;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @desc The event object of the current the request
|
|
104
|
-
*/
|
|
105
|
-
get event (): PondEvent<Path> | null;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @desc The class reference of the current context
|
|
109
|
-
*/
|
|
110
|
-
getClass (): any;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @desc The method reference of the current context
|
|
114
|
-
*/
|
|
115
|
-
getHandler (): any;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @desc The instance reference of the current context
|
|
119
|
-
*/
|
|
120
|
-
getInstance(): any;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @desc The path of the current context
|
|
124
|
-
*/
|
|
125
|
-
getMethod(): string;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @desc Saves data to the current context
|
|
129
|
-
*/
|
|
130
|
-
addData <Type> (key: string, value: Type): void;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @desc Retrieves data from the current context
|
|
134
|
-
*/
|
|
135
|
-
getData <Type> (key: string): Type | null;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @desc Decorator that marks a class as a channel
|
|
140
|
-
*/
|
|
141
|
-
declare function Channel(path?: string): ClassDecorator
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* @desc Decorator that marks a property on a class as the channel instance
|
|
145
|
-
* @returns {Channel | PondChannel}
|
|
146
|
-
*/
|
|
147
|
-
declare function ChannelInstance(channel?: string): PropertyDecorator;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* @desc Decorator that marks a class as an endpoint
|
|
151
|
-
*/
|
|
152
|
-
declare function Endpoint(path?: string): ClassDecorator;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @desc Decorator that marks a property on a class as the endpoint instance
|
|
156
|
-
* @returns {Endpoint}
|
|
157
|
-
*/
|
|
158
|
-
declare function EndpointInstance(): PropertyDecorator;
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @desc Parameter decorator that retrieves the current channel
|
|
162
|
-
* @returns {Channel}
|
|
163
|
-
*/
|
|
164
|
-
declare const GetChannel: () => ParameterDecorator;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* @desc Parameter decorator that retrieves the current connection headers
|
|
168
|
-
* @returns {IncomingHttpHeaders}
|
|
169
|
-
*/
|
|
170
|
-
declare const GetConnectionHeaders: () => ParameterDecorator;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @desc Parameter decorator that retrieves the current connection context
|
|
174
|
-
* @returns {ConnectionContext<string>}
|
|
175
|
-
*/
|
|
176
|
-
declare const GetConnectionContext: () => ParameterDecorator;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @desc Parameter decorator that retrieves the current context
|
|
180
|
-
* @returns {Context}
|
|
181
|
-
*/
|
|
182
|
-
declare const GetContext: () => ParameterDecorator;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @desc Parameter decorator that retrieves the current event params
|
|
186
|
-
* @returns {Params}
|
|
187
|
-
*/
|
|
188
|
-
declare const GetEventParams: () => ParameterDecorator;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* @desc Parameter decorator that retrieves the current event payload
|
|
192
|
-
* @returns {PondMessage}
|
|
193
|
-
*/
|
|
194
|
-
declare const GetEventPayload: () => ParameterDecorator;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* @desc Parameter decorator that retrieves the current event query
|
|
198
|
-
* @returns {Record<string, string>}
|
|
199
|
-
*/
|
|
200
|
-
declare const GetEventQuery: () => ParameterDecorator;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* @desc Parameter decorator that retrieves the current event context
|
|
204
|
-
* @returns {EventContext<string>}
|
|
205
|
-
*/
|
|
206
|
-
declare const GetEventContext: () => ParameterDecorator;
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* @desc Parameter decorator that retrieves the current join params
|
|
210
|
-
* @returns {JoinParams}
|
|
211
|
-
*/
|
|
212
|
-
declare const GetJoinParams: () => ParameterDecorator;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* @desc Parameter decorator that retrieves the current join context
|
|
216
|
-
* @returns {JoinContext<string>}
|
|
217
|
-
*/
|
|
218
|
-
declare const GetJoinContext: () => ParameterDecorator;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @desc Parameter decorator that retrieves the current leave event
|
|
222
|
-
* @returns {LeaveEvent}
|
|
223
|
-
*/
|
|
224
|
-
declare const GetLeaveEvent: () => ParameterDecorator;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* @desc Parameter decorator that retrieves the current user
|
|
228
|
-
* @returns {UserData}
|
|
229
|
-
*/
|
|
230
|
-
declare const GetUserData: () => ParameterDecorator;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @desc Parameter decorator that retrieves the current user presences
|
|
234
|
-
* @returns {PondAssigns}
|
|
235
|
-
*/
|
|
236
|
-
declare const GetUserAssigns: () => ParameterDecorator;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* @desc Parameter decorator that retrieves the current user presences
|
|
240
|
-
* @returns {PondPresence}
|
|
241
|
-
*/
|
|
242
|
-
declare const GetUserPresence: () => ParameterDecorator;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* @desc Method decorator that marks a method as an onConnection handler
|
|
246
|
-
*/
|
|
247
|
-
declare function OnConnectionRequest(): MethodDecorator;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* @desc Method decorator that marks a method as an onEvent handler
|
|
251
|
-
*/
|
|
252
|
-
declare function OnEvent<EventType extends PondEvenType = PondEvenType>(path?: keyof EventType): MethodDecorator;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* @desc Method decorator that marks a method as an onJoin handler
|
|
256
|
-
*/
|
|
257
|
-
declare function OnJoinRequest(): MethodDecorator;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* @desc Method decorator that marks a method as an onLeave handler
|
|
261
|
-
*/
|
|
262
|
-
declare function OnLeave(): MethodDecorator;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* @desc Decorator that adds guards to a channel's or endpoint's class or method
|
|
266
|
-
* @param guards - The guards to add. It is important to add the guards to a providers array in any module (only necessary if the guards inject dependencies)
|
|
267
|
-
*/
|
|
268
|
-
declare function UseGuards (...guards: Constructor<CanActivate>[]): ClassDecorator | MethodDecorator;
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* @desc Decorator that adds validators to a channel's or endpoint's class or method
|
|
272
|
-
* @param validators - The validators to add. It is important to add the validators to a providers array in any module (only necessary if the validators inject dependencies)
|
|
273
|
-
*/
|
|
274
|
-
declare function UsePipes (...validators: Constructor<PipeTransform>[]): ClassDecorator | MethodDecorator;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* @desc Helper function that creates a parameter decorator
|
|
278
|
-
* @param callback - The callback to run when the parameter is being retrieved
|
|
279
|
-
*/
|
|
280
|
-
declare function createParamDecorator<Input, ParamType> (callback: ParamDecoratorCallback<Input, ParamType>): (data: Input) => ParameterDecorator;
|
|
281
|
-
|
|
282
|
-
declare class PondSocketModule {
|
|
283
|
-
static forRoot({ guards, providers, imports, exports, isGlobal }: Metadata): DynamicModule;
|
|
284
|
-
|
|
285
|
-
static forRootAsync({ guards, providers, imports, exports, isGlobal, inject, useFactory }: AsyncMetadata): DynamicModule;
|
|
286
|
-
}
|
|
287
|
-
|
|
1
|
+
export * from './decorators';
|
|
2
|
+
export * from './modules/pondSocket';
|
|
3
|
+
export * from './helpers/createParamDecorator';
|
|
4
|
+
export { Context } from './context/context';
|
|
5
|
+
export type { CanActivate, Metadata, AsyncMetadata, AsyncFactoryResult, PondResponse, Constructor, ParamDecoratorCallback, NestContext } from './types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PondChannel } from '@eleven-am/pondsocket/types';
|
|
2
|
+
export declare function manageChannelInstance(target: unknown): {
|
|
3
|
+
build: <T>(propertyKey: string, callback?: ((value: PondChannel) => PondChannel | T | null) | undefined) => void;
|
|
4
|
+
set: (value: PondChannel) => void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ConnectionContext } from '@eleven-am/pondsocket/types';
|
|
2
|
+
export declare function manageConnection(target: unknown): {
|
|
3
|
+
get(): import("../types").HandlerData<ConnectionContext<string>>[];
|
|
4
|
+
set(path: string, value: import("../types").HandlerFunction<ConnectionContext<string>>): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Constructor } from '../types';
|
|
2
|
+
export declare function createMetadataManager<T>(metadataKey: symbol): {
|
|
3
|
+
manage: (target: object, propertyKey?: string) => {
|
|
4
|
+
get: () => Constructor<T>[];
|
|
5
|
+
set: (value: Constructor<T>[]) => void;
|
|
6
|
+
};
|
|
7
|
+
getLocalItems: () => Constructor<T>[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMetadataManager = createMetadataManager;
|
|
4
|
+
const class_1 = require("./class");
|
|
5
|
+
const method_1 = require("./method");
|
|
6
|
+
function createMetadataManager(metadataKey) {
|
|
7
|
+
const localItems = new Set();
|
|
8
|
+
function manage(target, propertyKey) {
|
|
9
|
+
let getter;
|
|
10
|
+
let setter;
|
|
11
|
+
if (propertyKey) {
|
|
12
|
+
const { get, set } = (0, method_1.manageMethod)(metadataKey, target, propertyKey);
|
|
13
|
+
getter = get;
|
|
14
|
+
setter = set;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const { get, set } = (0, class_1.manageClass)(metadataKey, target);
|
|
18
|
+
getter = get;
|
|
19
|
+
setter = set;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
get: () => { var _a; return (_a = getter()) !== null && _a !== void 0 ? _a : []; },
|
|
23
|
+
set: (value) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const current = (_a = getter()) !== null && _a !== void 0 ? _a : [];
|
|
26
|
+
setter([...value, ...current]);
|
|
27
|
+
value.forEach((item) => localItems.add(item));
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function getLocalItems() {
|
|
32
|
+
return Array.from(localItems);
|
|
33
|
+
}
|
|
34
|
+
return { manage,
|
|
35
|
+
getLocalItems };
|
|
36
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Endpoint } from '@eleven-am/pondsocket/types';
|
|
2
|
+
export declare function manageEndpointInstance(target: unknown): {
|
|
3
|
+
build: <T>(propertyKey: string, callback?: ((value: Endpoint) => Endpoint | T | null) | undefined) => void;
|
|
4
|
+
set: (value: Endpoint) => void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EventContext } from '@eleven-am/pondsocket/types';
|
|
2
|
+
export declare function manageEvent(target: unknown): {
|
|
3
|
+
get(): import("../types").HandlerData<EventContext<string>>[];
|
|
4
|
+
set(path: string, value: import("../types").HandlerFunction<EventContext<string>>): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CanActivate } from '../types';
|
|
2
|
+
export declare const manageGuards: (target: object, propertyKey?: string) => {
|
|
3
|
+
get: () => import("../types").Constructor<CanActivate>[];
|
|
4
|
+
set: (value: import("../types").Constructor<CanActivate>[]) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const getLocalGuards: () => import("../types").Constructor<CanActivate>[];
|
package/managers/guards.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.manageGuards =
|
|
4
|
-
exports.getLocalGuards = getLocalGuards;
|
|
5
|
-
const class_1 = require("./class");
|
|
6
|
-
const method_1 = require("./method");
|
|
3
|
+
exports.getLocalGuards = exports.manageGuards = void 0;
|
|
7
4
|
const constants_1 = require("../constants");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (propertyKey) {
|
|
13
|
-
const { get, set } = (0, method_1.manageMethod)(constants_1.pondGuardsKey, target, propertyKey);
|
|
14
|
-
getter = get;
|
|
15
|
-
setter = set;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
const { get, set } = (0, class_1.manageClass)(constants_1.pondGuardsKey, target);
|
|
19
|
-
getter = get;
|
|
20
|
-
setter = set;
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
get: () => { var _a; return (_a = getter()) !== null && _a !== void 0 ? _a : []; },
|
|
24
|
-
set: (value) => {
|
|
25
|
-
var _a;
|
|
26
|
-
const current = (_a = getter()) !== null && _a !== void 0 ? _a : [];
|
|
27
|
-
setter([...value, ...current]);
|
|
28
|
-
value.forEach((guard) => localGuards.add(guard));
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function getLocalGuards() {
|
|
33
|
-
return Array.from(localGuards);
|
|
34
|
-
}
|
|
5
|
+
const createMetadataManager_1 = require("./createMetadataManager");
|
|
6
|
+
const { manage, getLocalItems } = (0, createMetadataManager_1.createMetadataManager)(constants_1.pondGuardsKey);
|
|
7
|
+
exports.manageGuards = manage;
|
|
8
|
+
exports.getLocalGuards = getLocalItems;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JoinContext } from '@eleven-am/pondsocket/types';
|
|
2
|
+
export declare function manageJoin(target: unknown): {
|
|
3
|
+
get(): import("../types").HandlerData<JoinContext<string>>[];
|
|
4
|
+
set(path: string, value: import("../types").HandlerFunction<JoinContext<string>>): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OutgoingContext } from '@eleven-am/pondsocket/types';
|
|
2
|
+
export declare function manageOutgoingEvent(target: unknown): {
|
|
3
|
+
get(): import("../types").HandlerData<OutgoingContext<string>>[];
|
|
4
|
+
set(path: string, value: import("../types").HandlerFunction<OutgoingContext<string>>): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.manageOutgoingEvent = manageOutgoingEvent;
|
|
4
|
+
const handlers_1 = require("./handlers");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function manageOutgoingEvent(target) {
|
|
7
|
+
return (0, handlers_1.manageHandlers)(constants_1.onOutgoingEventHandlerKey, target);
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { PipeTransform } from '@nestjs/common';
|
|
3
|
+
import type { ModuleRef } from '@nestjs/core';
|
|
4
|
+
import { Context } from '../context/context';
|
|
5
|
+
import { ParamDecoratorMetadata, Constructor } from '../types';
|
|
6
|
+
export declare function manageParameters(target: any, propertyKey: string): {
|
|
7
|
+
get(): ParamDecoratorMetadata[];
|
|
8
|
+
set(index: number, callback: (context: Context, globalPipes: Constructor<PipeTransform>[], moduleRef: ModuleRef) => Promise<unknown>): void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PipeTransform } from '@nestjs/common';
|
|
2
|
+
export declare const managePipes: (target: object, propertyKey?: string) => {
|
|
3
|
+
get: () => import("..").Constructor<PipeTransform<any, any>>[];
|
|
4
|
+
set: (value: import("..").Constructor<PipeTransform<any, any>>[]) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const getLocalPipes: () => import("..").Constructor<PipeTransform<any, any>>[];
|
package/managers/pipes.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.managePipes =
|
|
4
|
-
exports.getLocalPipes = getLocalPipes;
|
|
3
|
+
exports.getLocalPipes = exports.managePipes = void 0;
|
|
5
4
|
const constants_1 = require("../constants");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let getter;
|
|
11
|
-
let setter;
|
|
12
|
-
if (propertyKey) {
|
|
13
|
-
const { get, set } = (0, method_1.manageMethod)(constants_1.pondValidatorsKey, target, propertyKey);
|
|
14
|
-
getter = get;
|
|
15
|
-
setter = set;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
const { get, set } = (0, class_1.manageClass)(constants_1.pondValidatorsKey, target);
|
|
19
|
-
getter = get;
|
|
20
|
-
setter = set;
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
get: () => { var _a; return (_a = getter()) !== null && _a !== void 0 ? _a : []; },
|
|
24
|
-
set: (value) => {
|
|
25
|
-
var _a;
|
|
26
|
-
const current = (_a = getter()) !== null && _a !== void 0 ? _a : [];
|
|
27
|
-
setter([...value, ...current]);
|
|
28
|
-
value.forEach((validator) => localValidators.add(validator));
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function getLocalPipes() {
|
|
33
|
-
return Array.from(localValidators);
|
|
34
|
-
}
|
|
5
|
+
const createMetadataManager_1 = require("./createMetadataManager");
|
|
6
|
+
const { manage, getLocalItems } = (0, createMetadataManager_1.createMetadataManager)(constants_1.pondValidatorsKey);
|
|
7
|
+
exports.managePipes = manage;
|
|
8
|
+
exports.getLocalPipes = getLocalItems;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { AsyncMetadata, Metadata } from '../types';
|
|
3
|
+
export declare class PondSocketModule {
|
|
4
|
+
static forRoot(metadata: Metadata): DynamicModule;
|
|
5
|
+
static forRootAsync(metadata: AsyncMetadata): DynamicModule;
|
|
6
|
+
private static buildModule;
|
|
7
|
+
}
|
package/modules/pondSocket.js
CHANGED
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PondSocketModule = void 0;
|
|
13
13
|
const nestjs_discovery_1 = require("@golevelup/nestjs-discovery");
|
|
14
|
-
// eslint-disable-next-line import/no-unresolved
|
|
15
14
|
const core_1 = require("@nestjs/core");
|
|
16
15
|
const guards_1 = require("../managers/guards");
|
|
17
16
|
const pipes_1 = require("../managers/pipes");
|
|
@@ -22,7 +21,7 @@ class PondSocketModule {
|
|
|
22
21
|
provide: pondSocket_1.PondSocketService,
|
|
23
22
|
useFactory: (moduleRef, adapterHost, discovery) => {
|
|
24
23
|
var _a, _b, _c;
|
|
25
|
-
return new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, (_a = metadata.guards) !== null && _a !== void 0 ? _a : [], (_b = metadata.pipes) !== null && _b !== void 0 ? _b : [], (_c = metadata.isExclusiveSocketServer) !== null && _c !== void 0 ? _c : false, metadata.backend);
|
|
24
|
+
return new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, (_a = metadata.guards) !== null && _a !== void 0 ? _a : [], (_b = metadata.pipes) !== null && _b !== void 0 ? _b : [], (_c = metadata.isExclusiveSocketServer) !== null && _c !== void 0 ? _c : false, metadata.backend, metadata.maxMessageSize, metadata.heartbeatInterval);
|
|
26
25
|
},
|
|
27
26
|
inject: [core_1.ModuleRef, core_1.HttpAdapterHost, nestjs_discovery_1.DiscoveryService],
|
|
28
27
|
};
|
|
@@ -34,7 +33,7 @@ class PondSocketModule {
|
|
|
34
33
|
useFactory: (moduleRef, adapterHost, discovery, ...args) => __awaiter(this, void 0, void 0, function* () {
|
|
35
34
|
var _a, _b, _c;
|
|
36
35
|
const resolvedMetadata = yield metadata.useFactory(...args);
|
|
37
|
-
return new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, (_a = metadata.guards) !== null && _a !== void 0 ? _a : [], (_b = metadata.pipes) !== null && _b !== void 0 ? _b : [], (_c = metadata.isExclusiveSocketServer) !== null && _c !== void 0 ? _c : false, resolvedMetadata);
|
|
36
|
+
return new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, (_a = metadata.guards) !== null && _a !== void 0 ? _a : [], (_b = metadata.pipes) !== null && _b !== void 0 ? _b : [], (_c = metadata.isExclusiveSocketServer) !== null && _c !== void 0 ? _c : false, resolvedMetadata.backend, resolvedMetadata.maxMessageSize, resolvedMetadata.heartbeatInterval);
|
|
38
37
|
}),
|
|
39
38
|
inject: [core_1.ModuleRef, core_1.HttpAdapterHost, nestjs_discovery_1.DiscoveryService, ...(metadata.inject || [])],
|
|
40
39
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eleven-am/pondsocket-nest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.135",
|
|
4
4
|
"description": "PondSocket is a fast simple socket server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"socket",
|
|
@@ -23,25 +23,34 @@
|
|
|
23
23
|
"build": "rimraf dist && tsc",
|
|
24
24
|
"lint": "eslint --ext .ts src",
|
|
25
25
|
"lint:fix": "eslint --fix --ext .ts src",
|
|
26
|
-
"copy": "cp package.json dist && cp README.md dist && cp LICENSE dist
|
|
26
|
+
"copy": "cp package.json dist && cp README.md dist && cp LICENSE dist",
|
|
27
27
|
"push": "npm version patch && npm run copy && cd dist && npm publish && cd ..",
|
|
28
28
|
"pipeline": "npm run build && npm run push"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@eleven-am/pondsocket": "^0.1.
|
|
32
|
-
"@golevelup/nestjs-discovery": "^
|
|
31
|
+
"@eleven-am/pondsocket": "^0.1.216",
|
|
32
|
+
"@golevelup/nestjs-discovery": "^6.1.2",
|
|
33
|
+
"reflect-metadata": "^0.2.2"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
36
|
+
"@eslint/compat": "^2.1.0",
|
|
37
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
38
|
+
"@eslint/js": "^9.39.4",
|
|
39
|
+
"@nestjs/common": "^11.1.23",
|
|
40
|
+
"@nestjs/core": "^11.1.23",
|
|
41
|
+
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
37
42
|
"@types/jest": "^30.0.0",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
|
44
|
+
"@typescript-eslint/parser": "^8.59.4",
|
|
45
|
+
"eslint": "^9.39.4",
|
|
39
46
|
"eslint-plugin-file-progress": "^3.0.2",
|
|
40
47
|
"eslint-plugin-import": "^2.32.0",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
48
|
+
"globals": "^17.6.0",
|
|
49
|
+
"jest": "^30.4.2",
|
|
50
|
+
"prettier": "^3.8.3",
|
|
51
|
+
"rxjs": "^7.8.2",
|
|
52
|
+
"ts-jest": "^29.4.11",
|
|
53
|
+
"ts-loader": "^9.5.7",
|
|
45
54
|
"ts-node": "^10.9.2",
|
|
46
55
|
"typescript": "^5.9.3"
|
|
47
56
|
},
|
|
@@ -54,7 +63,12 @@
|
|
|
54
63
|
"rootDir": "src",
|
|
55
64
|
"testRegex": ".*\\.test\\.ts$",
|
|
56
65
|
"transform": {
|
|
57
|
-
"^.+\\.(t|j)s$":
|
|
66
|
+
"^.+\\.(t|j)s$": [
|
|
67
|
+
"ts-jest",
|
|
68
|
+
{
|
|
69
|
+
"tsconfig": "tsconfig.test.json"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
58
72
|
},
|
|
59
73
|
"collectCoverageFrom": [
|
|
60
74
|
"**/*.(t|j)s"
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LeaveEvent, JoinContext, EventContext, ConnectionContext } from '@eleven-am/pondsocket/types';
|
|
2
|
+
import type { PipeTransform } from '@nestjs/common';
|
|
3
|
+
import type { ModuleRef } from '@nestjs/core';
|
|
4
|
+
import { PondResponse, Constructor, CanActivate } from '../types';
|
|
5
|
+
export declare function performAction(instance: any, moduleRef: ModuleRef, globalGuards: Constructor<CanActivate>[], globalPipes: Constructor<PipeTransform>[], originalMethod: (...args: any[]) => Promise<PondResponse | null | undefined>, propertyKey: string, input: LeaveEvent | JoinContext<string> | EventContext<string> | ConnectionContext<string>): Promise<void>;
|