26 lines
951 B
TypeScript
26 lines
951 B
TypeScript
|
|
import type { WorkProfileDTO } from "../../common/work-profiles";
|
||
|
|
import type { WorkProfile } from "../domain/work-profile.aggregate";
|
||
|
|
|
||
|
|
import type { WorkProfileContext } from "./work-profile.repository";
|
||
|
|
import { profileReferencesAvailable } from "./work-profile-input.mapper";
|
||
|
|
|
||
|
|
export function buildWorkProfileResponse(
|
||
|
|
item: WorkProfile,
|
||
|
|
context: WorkProfileContext
|
||
|
|
): WorkProfileDTO {
|
||
|
|
return {
|
||
|
|
id: item.id.toPrimitive(),
|
||
|
|
companyId: item.companyId.toPrimitive(),
|
||
|
|
values: item.values.toPrimitive(),
|
||
|
|
needsReview: item.values.active && !profileReferencesAvailable(item.values, context),
|
||
|
|
history: item.history.map((revision) => ({
|
||
|
|
id: revision.id.toPrimitive(),
|
||
|
|
values: revision.values.toPrimitive(),
|
||
|
|
actorId: revision.actorId.toPrimitive(),
|
||
|
|
actorName:
|
||
|
|
context.actors.get(revision.actorId.toPrimitive()) ?? revision.actorId.toPrimitive(),
|
||
|
|
recordedAt: revision.recordedAt,
|
||
|
|
})),
|
||
|
|
};
|
||
|
|
}
|