Continued updating the code to work with entities better

This commit is contained in:
Tiago Ribeiro
2024-10-07 15:49:58 +01:00
parent b5200c88fc
commit 1ef4efcacf
36 changed files with 2489 additions and 3012 deletions

View File

@@ -1,19 +1,28 @@
export interface Entity {
id: string;
label: string;
id: string;
label: string;
}
export interface Role {
id: string;
entityID: string;
permissions: string[];
label: string;
id: string;
entityID: string;
permissions: string[];
label: string;
}
export interface EntityWithRoles extends Entity {
roles: Role[];
}
roles: Role[];
};
export type WithEntity<T> = T extends {entities: {id: string; role: string}[]}
? Omit<T, "entities"> & {entities: {entity?: Entity; role?: Role}[]}
: T;
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;