UNPKG

@beincom/dto

Version:

Share dto for all projects of Beincom

47 lines (46 loc) 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateGroupSetLog = void 0; const activity_log_base_use_case_dto_1 = require("../../activity-log-base-use-case.dto"); const enums_1 = require("../../enums"); class CreateGroupSetLog extends activity_log_base_use_case_dto_1.ActivityLogBaseUseCase { static toPayload(data) { return { useCase: this.useCase, eventTime: Date.now(), data, }; } static toDocument({ eventTime, data, }) { const { id, mainId, actor, object } = data; return { id, mainId, eventTime, useCase: this.useCase, eventType: this.eventType, objectType: this.objectType, actorId: actor ? actor.id : undefined, communityId: object.communityId, objectId: object.id, data: { actor: actor ? { id: actor.id } : null, object, }, }; } toObjectIds() { const { actorId } = this.document; return { userIds: [actorId].filter((id) => id), }; } toData(objectData) { const { actorId, data } = this.document; return Object.assign(Object.assign({}, data), { actor: objectData.users[actorId] }); } } CreateGroupSetLog.useCase = enums_1.ACTIVITY_LOG_USE_CASES.CREATE_GROUP_SET; CreateGroupSetLog.eventType = enums_1.ACTIVITY_EVENT_TYPES.CREATE; CreateGroupSetLog.objectType = enums_1.ACTIVITY_OBJECT_TYPES.GROUP_SET; exports.CreateGroupSetLog = CreateGroupSetLog;