1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.EventPattern = void 0;
|
4 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
5 | const constants_1 = require("../constants");
|
6 | const pattern_handler_enum_1 = require("../enums/pattern-handler.enum");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const EventPattern = (metadata, transportOrExtras, maybeExtras) => {
|
13 | let transport;
|
14 | let extras;
|
15 | if (((0, shared_utils_1.isNumber)(transportOrExtras) || (0, shared_utils_1.isSymbol)(transportOrExtras)) &&
|
16 | (0, shared_utils_1.isNil)(maybeExtras)) {
|
17 | transport = transportOrExtras;
|
18 | }
|
19 | else if ((0, shared_utils_1.isObject)(transportOrExtras) && (0, shared_utils_1.isNil)(maybeExtras)) {
|
20 | extras = transportOrExtras;
|
21 | }
|
22 | else {
|
23 | transport = transportOrExtras;
|
24 | extras = maybeExtras;
|
25 | }
|
26 | return (target, key, descriptor) => {
|
27 | Reflect.defineMetadata(constants_1.PATTERN_METADATA, [].concat(metadata), descriptor.value);
|
28 | Reflect.defineMetadata(constants_1.PATTERN_HANDLER_METADATA, pattern_handler_enum_1.PatternHandler.EVENT, descriptor.value);
|
29 | Reflect.defineMetadata(constants_1.TRANSPORT_METADATA, transport, descriptor.value);
|
30 | Reflect.defineMetadata(constants_1.PATTERN_EXTRAS_METADATA, {
|
31 | ...Reflect.getMetadata(constants_1.PATTERN_EXTRAS_METADATA, descriptor.value),
|
32 | ...extras,
|
33 | }, descriptor.value);
|
34 | return descriptor;
|
35 | };
|
36 | };
|
37 | exports.EventPattern = EventPattern;
|