fix: restaurar utilitários de acesso remoto

This commit is contained in:
Esdras Renan 2025-10-28 11:52:27 -03:00
parent 192a5c2909
commit 38e4bbea7f

View file

@ -249,6 +249,15 @@ type MachineRemoteAccessEntry = {
metadata: Record<string, unknown> | null
}
export type MachineRemoteAccess = {
provider: string | null
identifier: string | null
url: string | null
notes: string | null
lastVerifiedAt: number | null
metadata: Record<string, unknown> | null
}
function collectInitials(name: string): string {
const words = name.split(/\s+/).filter(Boolean)
if (words.length === 0) return "?"
@ -309,7 +318,7 @@ function normalizeMachineRemoteAccessEntry(raw: unknown): MachineRemoteAccessEnt
id: null,
clientId: createRemoteAccessClientId(),
provider: null,
identifier: trimmed,
identifier: isUrl ? null : trimmed,
url: isUrl ? trimmed : null,
notes: null,
lastVerifiedAt: null,
@ -341,6 +350,13 @@ function normalizeMachineRemoteAccessEntry(raw: unknown): MachineRemoteAccessEnt
}
}
export function normalizeMachineRemoteAccess(raw: unknown): MachineRemoteAccess | null {
const entry = normalizeMachineRemoteAccessEntry(raw)
if (!entry) return null
const { provider, identifier, url, notes, lastVerifiedAt, metadata } = entry
return { provider, identifier, url, notes, lastVerifiedAt, metadata }
}
export function normalizeMachineRemoteAccessList(raw: unknown): MachineRemoteAccessEntry[] {
if (!raw) return []
const source = Array.isArray(raw) ? raw : [raw]