Add network identity diagnostics
Build and Deploy Gateway / build-and-push (push) Successful in 20s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-11 16:19:23 +03:00
parent 3566f4bc0b
commit 6381760b27
8 changed files with 211 additions and 9 deletions
@@ -12,6 +12,14 @@ export interface DiagnosticSiteResult extends Record<string, unknown> {
latencyMs: number | null;
}
export interface DiagnosticNetworkResult extends Record<string, unknown> {
address: string | null;
asn: string | null;
provider: string | null;
city: string | null;
country: string | null;
}
export interface DiagnosticServer extends Record<string, unknown> {
id: string;
label: string;
@@ -26,6 +34,7 @@ export interface DiagnosticPath extends Record<string, unknown> {
};
ipv6: string | null;
ipv6Source: DiagnosticIpResult | null;
network?: DiagnosticNetworkResult | null;
sites: DiagnosticSiteResult[];
server?: DiagnosticServer | null;
}
@@ -59,6 +68,19 @@ function validSiteResult(value: unknown): value is DiagnosticSiteResult {
&& nullableNonnegativeNumber(value.latencyMs);
}
function nullableText(value: unknown): value is string | null {
return value === null || (typeof value === 'string' && value.length > 0);
}
function validNetworkResult(value: unknown): value is DiagnosticNetworkResult {
return record(value)
&& nullableText(value.address)
&& nullableText(value.asn)
&& nullableText(value.provider)
&& nullableText(value.city)
&& nullableText(value.country);
}
function validServer(value: unknown): value is DiagnosticServer | null {
return value === null || (record(value)
&& typeof value.id === 'string'
@@ -76,6 +98,7 @@ function validPath(value: unknown): value is DiagnosticPath {
&& value.ipv4.sources.every(validIpResult)
&& (value.ipv6 === null || (typeof value.ipv6 === 'string' && value.ipv6.length > 0))
&& (value.ipv6Source === null || validIpResult(value.ipv6Source))
&& (!Object.hasOwn(value, 'network') || value.network === null || validNetworkResult(value.network))
&& Array.isArray(value.sites)
&& value.sites.every(validSiteResult);
}