import { nativeEnum, z } from 'zod';
import { ZLegacyUser } from './users.js';
import { GlobalAdminRoleNames, GlobalRoleNames, ProfileRoleNames, ZUserRoleMapping, ZInnerRoleObj } from '@komi-app/roles';
export * from '@komi-app/roles';
export const ZGlobalRoleRecord = z.record(nativeEnum(GlobalRoleNames), ZInnerRoleObj);
export const ZProfileRoleRecord = z.record(z.record(z.nativeEnum(ProfileRoleNames), ZInnerRoleObj));
export const ZTransformedRoles = z.object({
    globalRoles: ZGlobalRoleRecord,
    profileRoles: ZProfileRoleRecord
});
export const ZReturnedUserRoleMapping = ZUserRoleMapping.omit({
    userId: true,
    userRoleMappingId: true
});
export const ZGetProfileRoleMapping = ZUserRoleMapping.pick({
    profileId: true,
    userId: true
}).required();
export const ZReturnedProfileRoleMapping = ZUserRoleMapping.pick({
    createdAt: true
}).extend({ roleName: z.nativeEnum(ProfileRoleNames) });
export const ZEditUserRoleMapping = ZUserRoleMapping.omit({
    createdAt: true,
    userRoleMappingId: true
});
export const ZReturnedEditUserRoleMapping = ZUserRoleMapping.pick({
    createdAt: true,
    userRoleMappingId: true
});
export const ZAdminRecord = z.object({
    createdAt: z.string().datetime().optional(),
    email: z.string(),
    role: z.nativeEnum(GlobalAdminRoleNames),
    userId: z.string().uuid()
});
export const ZEditLegacyRoleMapping = z
    .object({
    legacyId: ZLegacyUser.shape.id,
    operation: z.enum(['add', 'delete']),
    profileId: ZUserRoleMapping.shape.profileId,
    roleName: z.nativeEnum(ProfileRoleNames)
})
    .required();
export const ZSuperAdminEditUserProfileRole = ZEditUserRoleMapping.required();
