UNPKG

978 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.IncomingRequestDeserializer = void 0;
4const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5/**
6 * @publicApi
7 */
8class IncomingRequestDeserializer {
9 deserialize(value, options) {
10 return this.isExternal(value) ? this.mapToSchema(value, options) : value;
11 }
12 isExternal(value) {
13 if (!value) {
14 return true;
15 }
16 if (!(0, shared_utils_1.isUndefined)(value.pattern) ||
17 !(0, shared_utils_1.isUndefined)(value.data)) {
18 return false;
19 }
20 return true;
21 }
22 mapToSchema(value, options) {
23 if (!options) {
24 return {
25 pattern: undefined,
26 data: undefined,
27 };
28 }
29 return {
30 pattern: options.channel,
31 data: value,
32 };
33 }
34}
35exports.IncomingRequestDeserializer = IncomingRequestDeserializer;