- Add softwareReferenceHref helper function for generating resource links. - Create useGlobalResourceEditor hook for managing global application resources. - Implement useGlobalResourceForm hook for handling global resource forms. - Introduce GlobalSoftwareCatalogProvider for context management of global applications. - Develop GlobalOperatingSystemsPage to render global operating systems using the existing GlobalApplicationsPage. - Add operating system form identity helpers for managing OS-specific fields. - Create operating system specification labels for better localization. - Implement OperatingSystemIdentityReview component for reviewing OS identities. - Add OperatingSystemProductFields component for displaying OS product details. - Write tests for resource characteristic control to ensure proper translation and value handling. - Create a Python script for auditing global operating systems UI interactions. - Add tests for expanded workstation profiles to ensure proper functionality and responsiveness.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { Maybe } from "@repo/rdx-utils";
|
|
|
|
import type { ResourceCatalog } from "./resource-catalog.aggregate";
|
|
import { ResourceDefinitionValues } from "./value-objects/resource-definition-values.vo";
|
|
|
|
/** Evolución de bindings stock: conserva nombres, orden, secciones y campos personalizados. */
|
|
export function evolveOperatingSystemTemplate(catalog: ResourceCatalog) {
|
|
let current = catalog;
|
|
const template = current.definitions.find(
|
|
(item) => item.stockKey.getOrUndefined() === "template:os"
|
|
);
|
|
const data = template?.values.data;
|
|
|
|
if (template && data?.kind === "template") {
|
|
const fields = [...data.fields];
|
|
|
|
for (const key of ["os_family", "os_product_version", "os_edition_state"]) {
|
|
const field = current.definitions.find(
|
|
(item) => item.stockKey.getOrUndefined() === `field:${key}`
|
|
);
|
|
|
|
if (field && !fields.some((entry) => entry.fieldId === field.id.toPrimitive())) {
|
|
fields.push({ fieldId: field.id.toPrimitive(), required: false });
|
|
}
|
|
}
|
|
const values = ResourceDefinitionValues.create({ ...data, fields });
|
|
|
|
if (!values.isSuccess) {
|
|
throw new Error("Evolución de plantilla SO inválida.");
|
|
}
|
|
const updated = current.save(template.companyId, Maybe.some(template.id), values.data);
|
|
|
|
if (!updated.isSuccess) {
|
|
throw new Error("Evolución de plantilla SO rechazada.");
|
|
}
|
|
current = updated.data;
|
|
}
|
|
|
|
return current;
|
|
}
|