metis-desk/modules/resources/src/common/dto/shared/application-reference.dto.ts
David d2bf856c97 feat(global-operating-systems): implement global operating systems management features
- 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.
2026-10-25 20:39:06 +01:00

116 lines
3.5 KiB
TypeScript

import { z } from "zod/v4";
import { ResourceInputSchema, ResourceSpecificationSchema } from "../../inventory";
import { OperatingSystemIdentitySchema } from "../../operating-system-identity";
export const ResourcePurposeSchema = z.enum(["software-installation", "application-configuration"]);
const identity = {
id: z.uuid(),
templateId: z.uuid(),
name: z.string().min(1).max(100),
active: z.boolean(),
};
export const ApplicationReferenceSchema = z.discriminatedUnion("scope", [
z.strictObject({
...identity,
kind: z.literal("application"),
scope: z.literal("global"),
companyId: z.null(),
}),
z.strictObject({
...identity,
kind: z.literal("application"),
scope: z.literal("company"),
companyId: z.uuid(),
}),
]);
export const LocalOsReferenceSchema = z.strictObject({
...identity,
kind: z.literal("os"),
scope: z.literal("company"),
companyId: z.uuid(),
});
export const GlobalOperatingSystemReferenceSchema = z.strictObject({
...identity,
...OperatingSystemIdentitySchema.shape,
kind: z.literal("os"),
scope: z.literal("global"),
companyId: z.null(),
href: z.string().startsWith("/catalogs/global-operating-systems/"),
});
export const GlobalOperatingSystemDetailSchema = GlobalOperatingSystemReferenceSchema.extend({
url: z.string().nullable(),
description: z.string().nullable(),
});
export type GlobalOperatingSystemReference = z.infer<typeof GlobalOperatingSystemReferenceSchema>;
export type GlobalOperatingSystemDetail = z.infer<typeof GlobalOperatingSystemDetailSchema>;
export const SoftwareReferenceSchema = z.union([
GlobalOperatingSystemReferenceSchema,
ApplicationReferenceSchema,
LocalOsReferenceSchema,
]);
export const CompanyApplicationSummarySchema = z.union([
ApplicationReferenceSchema.options[0].extend({ provider: z.string().nullable() }),
ApplicationReferenceSchema.options[1].extend({ provider: z.string().nullable() }),
]);
export type CompanyApplicationSummary = z.infer<typeof CompanyApplicationSummarySchema>;
export const ApplicationCandidateSchema = z.union([
ApplicationReferenceSchema.options[0].extend({
active: z.literal(true),
provider: z.string().nullable(),
}),
ApplicationReferenceSchema.options[1].extend({
active: z.literal(true),
provider: z.string().nullable(),
}),
]);
export const ResourceCandidateSchema = z.union([
GlobalOperatingSystemReferenceSchema.extend({ active: z.literal(true) }),
ApplicationCandidateSchema,
LocalOsReferenceSchema.extend({ active: z.literal(true), provider: z.string().nullable() }),
]);
export const GlobalApplicationSummarySchema = z.strictObject({
...identity,
kind: z.literal("application"),
scope: z.literal("global"),
companyId: z.null(),
provider: z.string().nullable(),
});
export const GlobalApplicationDetailSchema = GlobalApplicationSummarySchema.extend({
url: z.string().nullable(),
description: z.string().nullable(),
});
export const GlobalResourceAdminSchema = z.strictObject({
revisionId: z.uuid(),
id: z.uuid(),
scope: z.literal("global"),
companyId: z.null(),
values: ResourceInputSchema.omit({ integration: true }),
specification: ResourceSpecificationSchema,
});
export type ResourcePurpose = z.infer<typeof ResourcePurposeSchema>;
export type SoftwareReference = z.infer<typeof SoftwareReferenceSchema>;
export type ResourceCandidate = z.infer<typeof ResourceCandidateSchema>;
export type GlobalApplicationSummary = z.infer<typeof GlobalApplicationSummarySchema>;
export type GlobalApplicationDetail = z.infer<typeof GlobalApplicationDetailSchema>;