@eleven-am/pondsocket 0.1.84 → 0.1.86
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/nest.js +30 -6
- package/package.json +1 -1
- package/types.d.ts +16 -6
package/nest.js
CHANGED
|
@@ -359,8 +359,16 @@ function OnJoinRequest() {
|
|
|
359
359
|
const data = yield originalMethod.apply(instance, resolveJoinParameters(request, response, target, propertyKey));
|
|
360
360
|
if (!response.hasResponded) {
|
|
361
361
|
if (data) {
|
|
362
|
-
const { event } = data, rest = __rest(data, ["event"]);
|
|
363
|
-
|
|
362
|
+
const { event, presence, assigns } = data, rest = __rest(data, ["event", "presence", "assigns"]);
|
|
363
|
+
if (event || rest) {
|
|
364
|
+
response.send(event !== null && event !== void 0 ? event : 'response', rest, assigns);
|
|
365
|
+
}
|
|
366
|
+
else if (assigns) {
|
|
367
|
+
response.accept(assigns);
|
|
368
|
+
}
|
|
369
|
+
if (presence) {
|
|
370
|
+
response.trackPresence(presence);
|
|
371
|
+
}
|
|
364
372
|
}
|
|
365
373
|
else {
|
|
366
374
|
response.accept();
|
|
@@ -383,8 +391,19 @@ function OnEvent(event = '*') {
|
|
|
383
391
|
const data = yield originalMethod.apply(instance, resolveEventParameters(request, response, target, propertyKey));
|
|
384
392
|
if (!response.hasResponded) {
|
|
385
393
|
if (data) {
|
|
386
|
-
const { event } = data, rest = __rest(data, ["event"]);
|
|
387
|
-
|
|
394
|
+
const { event, presence, updatePresence, assigns } = data, rest = __rest(data, ["event", "presence", "updatePresence", "assigns"]);
|
|
395
|
+
if (event || rest) {
|
|
396
|
+
response.send(event !== null && event !== void 0 ? event : 'response', rest, assigns);
|
|
397
|
+
}
|
|
398
|
+
else if (assigns) {
|
|
399
|
+
response.accept(assigns);
|
|
400
|
+
}
|
|
401
|
+
if (presence) {
|
|
402
|
+
response.trackPresence(presence);
|
|
403
|
+
}
|
|
404
|
+
else if (updatePresence) {
|
|
405
|
+
response.updatePresence(updatePresence);
|
|
406
|
+
}
|
|
388
407
|
}
|
|
389
408
|
else {
|
|
390
409
|
response.accept();
|
|
@@ -407,8 +426,13 @@ function OnConnectionRequest() {
|
|
|
407
426
|
const data = yield originalMethod.apply(instance, resolveConnectionParameters(request, response, target, propertyKey));
|
|
408
427
|
if (!response.hasResponded) {
|
|
409
428
|
if (data) {
|
|
410
|
-
const { event } = data, rest = __rest(data, ["event"]);
|
|
411
|
-
|
|
429
|
+
const { event, assigns } = data, rest = __rest(data, ["event", "assigns"]);
|
|
430
|
+
if (event || rest) {
|
|
431
|
+
response.send(event !== null && event !== void 0 ? event : 'response', rest, assigns);
|
|
432
|
+
}
|
|
433
|
+
else if (assigns) {
|
|
434
|
+
response.accept(assigns);
|
|
435
|
+
}
|
|
412
436
|
}
|
|
413
437
|
else {
|
|
414
438
|
response.accept();
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server as HTTPServer, IncomingHttpHeaders } from 'http';
|
|
2
2
|
|
|
3
|
-
import { ModuleMetadata } from '@nestjs/common
|
|
3
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
4
4
|
import type { ModuleRef, HttpAdapterHost } from '@nestjs/core';
|
|
5
5
|
import type { Express } from 'express';
|
|
6
6
|
import { WebSocketServer } from 'ws';
|
|
@@ -20,6 +20,16 @@ type FilteredParams<Path> = Path extends `${infer First}/${infer Second}`
|
|
|
20
20
|
? IsParam<First> | FilteredParams<Second>
|
|
21
21
|
: IsParam<Path>
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @desc The type for the params in a request
|
|
25
|
+
* @typeParam Path - The path to get the params from
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* const params: Params<'/api/:id'> = {
|
|
29
|
+
* id: '123',
|
|
30
|
+
* foo: 'bar', // Error: Type 'string' is not assignable to type 'undefined'
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
23
33
|
type Params<Path> = {
|
|
24
34
|
[Key in FilteredParams<Path>]: string
|
|
25
35
|
}
|
|
@@ -677,13 +687,13 @@ declare function GetEventPayload(): ParameterDecorator;
|
|
|
677
687
|
|
|
678
688
|
/**
|
|
679
689
|
* @desc The Decorator for retrieving the EventRequest Params object from the request in a handler
|
|
680
|
-
* @returns {
|
|
690
|
+
* @returns {Params}
|
|
681
691
|
*/
|
|
682
692
|
declare function GetEventParams(): ParameterDecorator;
|
|
683
693
|
|
|
684
694
|
/**
|
|
685
695
|
* @desc The Decorator for retrieving the EventRequest Query object from the request in a handler
|
|
686
|
-
* @returns {
|
|
696
|
+
* @returns {Record<string, string>}
|
|
687
697
|
*/
|
|
688
698
|
declare function GetEventQuery(): ParameterDecorator;
|
|
689
699
|
|
|
@@ -719,19 +729,19 @@ declare function GetConnectionRequestId(): ParameterDecorator;
|
|
|
719
729
|
|
|
720
730
|
/**
|
|
721
731
|
* @desc The Decorator for retrieving the ConnectionParams in a handler
|
|
722
|
-
* @returns {
|
|
732
|
+
* @returns {Params}
|
|
723
733
|
*/
|
|
724
734
|
declare function GetConnectionParams(): ParameterDecorator;
|
|
725
735
|
|
|
726
736
|
/**
|
|
727
737
|
* @desc The Decorator for retrieving the ConnectionHeaders from the request in a handler
|
|
728
|
-
* @returns {
|
|
738
|
+
* @returns {IncomingHttpHeaders}
|
|
729
739
|
*/
|
|
730
740
|
declare function GetConnectionHeaders(): ParameterDecorator;
|
|
731
741
|
|
|
732
742
|
/**
|
|
733
743
|
* @desc The Decorator for retrieving the ConnectionQuery in a handler
|
|
734
|
-
* @returns {
|
|
744
|
+
* @returns {Record<string, string>}
|
|
735
745
|
*/
|
|
736
746
|
declare function GetConnectionQuery(): ParameterDecorator;
|
|
737
747
|
|