- Add SoftwareInstallationValues value object for encapsulating software installation data. - Create HTTP routes for managing software installations, including GET, POST, and DELETE operations. - Implement Sequelize repository for software installations, handling database interactions. - Add migration script for creating necessary database tables for software installations. - Create persistence mapper for transforming between domain models and database rows. - Define snapshot schema for software installations to ensure data consistency. - Introduce common schemas for software installations to validate API requests and responses. - Develop UI components for displaying and managing software installations, including history dialogs and forms. - Implement API client for interacting with software installation endpoints. - Write tests for software installations panel and form components to ensure functionality.
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import type { SoftwareInstallationDTO } from "../../common/software-installations";
|
|
import type { SoftwareInstallation } from "../domain/software-installation.aggregate";
|
|
|
|
import type { SoftwareContext } from "./software-installation.repository";
|
|
import { softwareAvailable } from "./software-installation-policy";
|
|
|
|
export function buildSoftwareResponse(
|
|
item: SoftwareInstallation,
|
|
context: SoftwareContext
|
|
): SoftwareInstallationDTO {
|
|
return {
|
|
id: item.id.toPrimitive(),
|
|
companyId: item.companyId.toPrimitive(),
|
|
values: item.values.toPrimitive(),
|
|
needsReview:
|
|
!item.values.closed &&
|
|
(!softwareAvailable(item.values, context) || item.values.state === "removal_pending"),
|
|
history: item.history.map((revision) => ({
|
|
id: revision.id.toPrimitive(),
|
|
actorId: revision.actorId.toPrimitive(),
|
|
actorName:
|
|
context.actors.get(revision.actorId.toPrimitive()) ?? revision.actorId.toPrimitive(),
|
|
recordedAt: revision.recordedAt,
|
|
values: revision.values.toPrimitive(),
|
|
})),
|
|
};
|
|
}
|