2026-10-24 23:19:17 +00:00
|
|
|
import { z } from "zod/v4";
|
|
|
|
|
|
|
|
|
|
import type { ResourcePurpose } from "../../common";
|
|
|
|
|
|
|
|
|
|
/** R2.5 mantiene gates independientes para software y perfiles. */
|
|
|
|
|
export const ResourceGlobalGatesSchema = z.strictObject({
|
2026-10-25 19:39:06 +00:00
|
|
|
operatingSystemCatalog: z.boolean().optional(),
|
|
|
|
|
operatingSystemSoftware: z.boolean().optional(),
|
2026-10-24 23:19:17 +00:00
|
|
|
catalog: z.boolean(),
|
|
|
|
|
administration: z.boolean(),
|
|
|
|
|
mixedSelection: z.boolean(),
|
|
|
|
|
software: z.boolean(),
|
|
|
|
|
profile: z.boolean(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const resourceGlobalGates = Object.freeze(
|
|
|
|
|
ResourceGlobalGatesSchema.parse({
|
|
|
|
|
catalog: false,
|
|
|
|
|
administration: true,
|
|
|
|
|
mixedSelection: false,
|
|
|
|
|
software: false,
|
|
|
|
|
profile: false,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export function globalResourcePurposeEnabled(
|
|
|
|
|
purpose: ResourcePurpose,
|
2026-10-25 19:39:06 +00:00
|
|
|
gates = resourceGlobalGates,
|
|
|
|
|
kind: "application" | "os" = "application"
|
2026-10-24 23:19:17 +00:00
|
|
|
): boolean {
|
2026-10-25 19:39:06 +00:00
|
|
|
if (kind === "os") {
|
|
|
|
|
return (
|
|
|
|
|
purpose === "software-installation" &&
|
|
|
|
|
Boolean(gates.operatingSystemCatalog && gates.operatingSystemSoftware)
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-10-24 23:19:17 +00:00
|
|
|
const consumer = purpose === "software-installation" ? gates.software : gates.profile;
|
|
|
|
|
|
|
|
|
|
return gates.catalog && consumer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type ResourceGlobalGates = z.infer<typeof ResourceGlobalGatesSchema>;
|