fix: Applied fix for name, the oracle team sharing, sentinel client list visibility

This commit is contained in:
Sagnik
2026-04-19 17:07:12 +05:30
parent 269591a3cc
commit d886e4a669
20 changed files with 940 additions and 109 deletions

View File

@@ -7,6 +7,15 @@ export interface VelocityUserProfile {
role: string;
full_name?: string | null;
email?: string | null;
avatar_url?: string | null;
}
export interface VelocityActiveUser {
user_id: string;
role: string;
full_name?: string | null;
email?: string | null;
avatar_url?: string | null;
}
export interface VelocityLoginResponse {
@@ -189,6 +198,39 @@ export function normalizeVelocityRole(role: string | null | undefined): string {
return (role ?? '').trim().toUpperCase();
}
export function resolveVelocityFullName(profile: Pick<VelocityUserProfile, 'full_name' | 'email' | 'user_id'>): string {
const fullName = profile.full_name?.trim();
if (fullName) {
return fullName;
}
const email = profile.email?.trim();
if (email) {
return email;
}
return profile.user_id;
}
export function resolveVelocityFirstName(profile: Pick<VelocityUserProfile, 'full_name' | 'email' | 'user_id'>): string {
const fullName = profile.full_name?.trim();
if (fullName) {
return fullName.split(/\s+/)[0] ?? fullName;
}
const email = profile.email?.trim();
if (email) {
const local = email.split('@')[0]?.trim() ?? '';
if (local) {
const normalized = local.replace(/[._-]+/g, ' ').trim();
const firstToken = normalized.split(/\s+/)[0] ?? normalized;
return firstToken.charAt(0).toUpperCase() + firstToken.slice(1);
}
}
return profile.user_id;
}
export function isAdminRole(role: string | null | undefined): boolean {
const normalized = normalizeVelocityRole(role);
return normalized === 'ADMIN' || normalized === 'SUPERADMIN';
@@ -209,6 +251,36 @@ export async function getVelocityMe(): Promise<VelocityUserProfile> {
});
}
export async function listVelocityUsers(): Promise<VelocityActiveUser[]> {
return platformFetch<VelocityActiveUser[]>('/api/auth/users', {
method: 'GET',
});
}
export async function uploadVelocityAvatar(file: File): Promise<{ avatar_url: string }> {
const form = new FormData();
form.append('file', file);
const response = await fetch(`${API_URL}/api/auth/profile/avatar`, {
method: 'POST',
headers: buildHeaders(undefined, false),
body: form,
});
if (!response.ok) {
const body = await response.json().catch(() => ({}));
throw new Error(
typeof body?.detail === 'string'
? body.detail
: typeof body?.message === 'string'
? body.message
: `Request failed: ${response.status}`,
);
}
return response.json() as Promise<{ avatar_url: string }>;
}
export async function getAdminHealth(): Promise<AdminHealthSnapshot> {
return platformFetch<AdminHealthSnapshot>('/api/admin-surface/health');
}