metis-desk/modules/resources/src/api/application/resource-global-gates.ts
2026-10-25 01:19:17 +02:00

34 lines
881 B
TypeScript

import { z } from "zod/v4";
import type { ResourcePurpose } from "../../common";
/** R2.5 mantiene gates independientes para software y perfiles. */
export const ResourceGlobalGatesSchema = z.strictObject({
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,
gates = resourceGlobalGates
): boolean {
const consumer = purpose === "software-installation" ? gates.software : gates.profile;
return gates.catalog && consumer;
}
export type ResourceGlobalGates = z.infer<typeof ResourceGlobalGatesSchema>;