@eleven-am/pondsocket 0.1.101 → 0.1.103
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 +23 -7
- package/package.json +1 -1
package/nest.js
CHANGED
|
@@ -407,12 +407,13 @@ function GetJoinParams() {
|
|
|
407
407
|
}
|
|
408
408
|
exports.GetJoinParams = GetJoinParams;
|
|
409
409
|
function GetEventPayload() {
|
|
410
|
-
return createParamDecorator((_,
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
return createParamDecorator((_, context) => {
|
|
411
|
+
var _a;
|
|
412
|
+
const payload = (_a = context.event) === null || _a === void 0 ? void 0 : _a.payload;
|
|
413
|
+
if (!payload) {
|
|
413
414
|
throw new Error('Invalid decorator usage: GetEventPayload');
|
|
414
415
|
}
|
|
415
|
-
return
|
|
416
|
+
return payload;
|
|
416
417
|
})(null);
|
|
417
418
|
}
|
|
418
419
|
exports.GetEventPayload = GetEventPayload;
|
|
@@ -657,6 +658,16 @@ const getChannels = (target) => {
|
|
|
657
658
|
var _a;
|
|
658
659
|
return (_a = manageClassData(channelsClassKey, target).get()) !== null && _a !== void 0 ? _a : [];
|
|
659
660
|
};
|
|
661
|
+
const getGuards = (target) => {
|
|
662
|
+
var _a;
|
|
663
|
+
const classGuards = (_a = manageClassData(pondGuardsKey, target).get()) !== null && _a !== void 0 ? _a : [];
|
|
664
|
+
const methodGuards = Object.getOwnPropertyNames(target.prototype)
|
|
665
|
+
.map((propertyKey) => {
|
|
666
|
+
var _a;
|
|
667
|
+
return (_a = manageMethodData(pondGuardsKey, target.prototype, propertyKey).get()) !== null && _a !== void 0 ? _a : [];
|
|
668
|
+
});
|
|
669
|
+
return [...classGuards, ...methodGuards.flat()];
|
|
670
|
+
};
|
|
660
671
|
const Endpoint = (metadata) => {
|
|
661
672
|
var _a;
|
|
662
673
|
return (0, common_1.applyDecorators)(setChannels(metadata.channels), setEndpoint(metadata.path), setGuards((_a = metadata.guards) !== null && _a !== void 0 ? _a : []));
|
|
@@ -738,17 +749,22 @@ class PondSocketService {
|
|
|
738
749
|
}
|
|
739
750
|
class PondSocketModule {
|
|
740
751
|
static forRoot({ endpoints, providers = [], imports = [], exports = [], isGlobal = false, }) {
|
|
741
|
-
const
|
|
752
|
+
const endpointsSet = new Set(endpoints);
|
|
753
|
+
const channels = Array.from(endpointsSet).flatMap((endpoint) => getChannels(endpoint));
|
|
754
|
+
const channelsSet = new Set(channels);
|
|
755
|
+
const guards = Array.from(new Set([...endpointsSet, ...channelsSet])).flatMap(((target) => getGuards(target)));
|
|
756
|
+
const guardsSet = new Set(guards);
|
|
742
757
|
const pondSocketProvider = {
|
|
743
758
|
provide: PondSocketService,
|
|
744
759
|
useFactory: (moduleRef, adapterHost) => new PondSocketService(moduleRef, adapterHost, endpoints),
|
|
745
760
|
inject: [core_1.ModuleRef, core_1.HttpAdapterHost],
|
|
746
761
|
};
|
|
762
|
+
const providersSet = new Set([...providers, ...guardsSet, ...channelsSet, ...endpointsSet, pondSocketProvider]);
|
|
747
763
|
return {
|
|
748
764
|
imports,
|
|
749
765
|
module: PondSocketModule,
|
|
750
|
-
providers: [...
|
|
751
|
-
exports: [...exports, ...
|
|
766
|
+
providers: [...providersSet],
|
|
767
|
+
exports: [...exports, ...channelsSet],
|
|
752
768
|
global: isGlobal,
|
|
753
769
|
};
|
|
754
770
|
}
|