feat: publish HoloLake model-native living system source
This commit is contained in:
parent
6ad10edde1
commit
c395dd3a99
2467 changed files with 615073 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
export interface GuanghuShanghaiNodeStatus {
|
||||
nodeId: 'BS-SH-005'
|
||||
reachability: 'online' | 'unreachable'
|
||||
region: 'shanghai'
|
||||
runtime: 'guanghu_os_native' | 'hosted_maintenance' | 'unknown'
|
||||
ttl: number | null
|
||||
}
|
||||
|
||||
export interface GuanghuShanghaiNodeState {
|
||||
checkedAt: number | null
|
||||
error: string | null
|
||||
phase: 'checking' | 'online' | 'error'
|
||||
status: GuanghuShanghaiNodeStatus | null
|
||||
}
|
||||
|
||||
export const INITIAL_GUANGHU_SHANGHAI_NODE_STATE: GuanghuShanghaiNodeState = {
|
||||
checkedAt: null,
|
||||
error: null,
|
||||
phase: 'checking',
|
||||
status: null,
|
||||
}
|
||||
|
||||
function record(value: unknown): Record<string, unknown> | null {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
? value as Record<string, unknown>
|
||||
: null
|
||||
}
|
||||
|
||||
export function parseGuanghuShanghaiNodeStatus(
|
||||
value: unknown,
|
||||
): GuanghuShanghaiNodeStatus {
|
||||
const status = record(value)
|
||||
const runtime = status?.runtime
|
||||
const reachability = status?.reachability
|
||||
if (
|
||||
status?.node_id !== 'BS-SH-005'
|
||||
|| status.region !== 'shanghai'
|
||||
|| (reachability !== 'online' && reachability !== 'unreachable')
|
||||
|| !['guanghu_os_native', 'hosted_maintenance', 'unknown'].includes(
|
||||
typeof runtime === 'string' ? runtime : '',
|
||||
)
|
||||
) {
|
||||
throw new Error('guanghu_shanghai_node_receipt_invalid')
|
||||
}
|
||||
return {
|
||||
nodeId: 'BS-SH-005',
|
||||
reachability,
|
||||
region: 'shanghai',
|
||||
runtime: runtime as GuanghuShanghaiNodeStatus['runtime'],
|
||||
ttl: typeof status.ttl === 'number' ? status.ttl : null,
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue