38 lines
895 B
TypeScript
38 lines
895 B
TypeScript
import { RolePermission } from "@/resources/entityPermissions";
|
|
|
|
export interface Entity {
|
|
id: string;
|
|
label: string;
|
|
licenses: number;
|
|
expiryDate?: Date | null
|
|
payment?: {
|
|
currency: string
|
|
price: number
|
|
}
|
|
}
|
|
|
|
export interface Role {
|
|
id: string;
|
|
entityID: string;
|
|
permissions: RolePermission[];
|
|
label: string;
|
|
isDefault?: boolean
|
|
}
|
|
|
|
export interface EntityWithRoles extends Entity {
|
|
roles: Role[];
|
|
};
|
|
|
|
export type WithLabeledEntities<T> = T extends { entities: { id: string; role: string }[] }
|
|
? Omit<T, "entities"> & { entities: { id: string; label?: string; role: string, roleLabel?: string }[] }
|
|
: T;
|
|
|
|
|
|
export type WithEntity<T> = T extends { entity?: string }
|
|
? Omit<T, "entity"> & { entity: Entity }
|
|
: T;
|
|
|
|
export type WithEntities<T> = T extends { entities: { id: string; role: string }[] }
|
|
? Omit<T, "entities"> & { entities: { entity?: Entity; role?: Role }[] }
|
|
: T;
|