UNPKG

@beincom/dto

Version:

Share dto for all projects of Beincom

65 lines (64 loc) 2.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RecoverCommunityLog = exports.DeleteCommunityLog = exports.DeletedCommunityState = void 0; const activity_log_base_use_case_dto_1 = require("../../activity-log-base-use-case.dto"); const enums_1 = require("../../enums"); var DeletedCommunityState; (function (DeletedCommunityState) { DeletedCommunityState["RESTORED"] = "recoverd"; DeletedCommunityState["TEMPORARY_DELETED"] = "temporary-deleted"; })(DeletedCommunityState = exports.DeletedCommunityState || (exports.DeletedCommunityState = {})); class DeleteRecoverCommunityLog 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, community, state } = data; return { id, mainId, eventTime, useCase: this.useCase, eventType: this.eventType, objectType: this.objectType, actorId: actor ? actor.id : undefined, communityId: community.id, objectId: community.id, groupId: community.id, data: { actor, community, state }, }; } 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] }); } } DeleteRecoverCommunityLog.useCase = enums_1.ACTIVITY_LOG_USE_CASES.DELETE_COMMUNITY; DeleteRecoverCommunityLog.eventType = enums_1.ACTIVITY_EVENT_TYPES.DELETE; DeleteRecoverCommunityLog.objectType = enums_1.ACTIVITY_OBJECT_TYPES.COMMUNITY; class DeleteCommunityLog extends DeleteRecoverCommunityLog { } DeleteCommunityLog.useCase = enums_1.ACTIVITY_LOG_USE_CASES.DELETE_COMMUNITY; DeleteCommunityLog.eventType = enums_1.ACTIVITY_EVENT_TYPES.DELETE; DeleteCommunityLog.objectType = enums_1.ACTIVITY_OBJECT_TYPES.COMMUNITY; exports.DeleteCommunityLog = DeleteCommunityLog; class RecoverCommunityLog extends DeleteRecoverCommunityLog { } RecoverCommunityLog.useCase = enums_1.ACTIVITY_LOG_USE_CASES.RECOVER_COMMUNITY; RecoverCommunityLog.eventType = enums_1.ACTIVITY_EVENT_TYPES.UPDATE; RecoverCommunityLog.objectType = enums_1.ACTIVITY_OBJECT_TYPES.COMMUNITY; exports.RecoverCommunityLog = RecoverCommunityLog;