UNPKG

@upv/ushi-shared

Version:

Shared DTOs, types, and utilities for the USHI platform (LMS, Trials, Social, Wallet).

52 lines (51 loc) 2.67 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const PersonDto_1 = __importDefault(require("./PersonDto")); const LMSPersonProfileDto_1 = __importDefault(require("../lms/LMSPersonProfileDto")); const TrialParticipantProfileDto_1 = __importDefault(require("../trial/TrialParticipantProfileDto")); const WalletProfileDto_1 = __importDefault(require("../wallet/WalletProfileDto")); const SocialProfileDto_1 = __importDefault(require("../social/SocialProfileDto")); const DemographicsProfileDto_1 = __importDefault(require("../demographics/DemographicsProfileDto")); const IdentityProfileDto_1 = __importDefault(require("../identity/IdentityProfileDto")); /** * PersonProfileDto * * Aggregated DTO class that builds a full PersonProfile from raw nested inputs. */ class PersonProfileDto { constructor(input) { this.personDto = new PersonDto_1.default(input.person); if (input.lmsProfile) this.lmsProfileDto = new LMSPersonProfileDto_1.default(input.lmsProfile); if (input.trialProfile) this.trialProfileDto = new TrialParticipantProfileDto_1.default(input.trialProfile); if (input.walletProfile) this.walletProfileDto = new WalletProfileDto_1.default(input.walletProfile); if (input.socialProfile) this.socialProfileDto = new SocialProfileDto_1.default(input.socialProfile); if (input.demographicsProfile) this.demographicsProfileDto = new DemographicsProfileDto_1.default(input.demographicsProfile); if (input.identityProfile) this.identityProfileDto = new IdentityProfileDto_1.default(input.identityProfile); } /** * Serializes the full person profile using sub-DTOs */ async serialize() { return { person: await this.personDto.serialize(), profiles: { lms: this.lmsProfileDto ? await this.lmsProfileDto.serialize() : null, trial: this.trialProfileDto ? await this.trialProfileDto.serialize() : null, wallet: this.walletProfileDto ? await this.walletProfileDto.serialize() : null, social: this.socialProfileDto ? await this.socialProfileDto.serialize() : null, demographics: this.demographicsProfileDto ? await this.demographicsProfileDto.serialize() : null, identity: this.identityProfileDto ? await this.identityProfileDto.serialize() : null, }, }; } } exports.default = PersonProfileDto;