1type Primitives = string | number | boolean | undefined | null; 2 3type JSONAble = Primitives | Primitives[] | { [k: string]: JSONAble } | JSONAble[]; 4 5type Dict<T extends unknown = unknown> = Record<string, T>; 6 7type Nullable<T> = T | null; 8 9interface Window { 10 /** 11 * Bootstrap Collapse Instance. 12 */ 13 Collapse: typeof import('bootstrap').Collapse; 14 15 /** 16 * Bootstrap Modal Instance. 17 */ 18 Modal: typeof import('bootstrap').Modal; 19 20 /** 21 * Bootstrap Popover Instance. 22 */ 23 Popover: typeof import('bootstrap').Popover; 24 25 /** 26 * Bootstrap Toast Instance. 27 */ 28 Toast: typeof import('bootstrap').Toast; 29 30 /** 31 * Bootstrap Tooltip Instance. 32 */ 33 Tooltip: typeof import('bootstrap').Tooltip; 34} 35 36/** 37 * Enforce string index type (not `number` or `symbol`). 38 */ 39type Index<O extends Dict, K extends keyof O> = K extends string ? K : never; 40 41type APIResponse<T> = T | ErrorBase | APIError; 42 43type APIAnswer<T> = { 44 count: number; 45 next: Nullable<string>; 46 previous: Nullable<string>; 47 results: T[]; 48}; 49 50type APIAnswerWithNext<T> = Exclude<APIAnswer<T>, 'next'> & { next: string }; 51 52type ErrorBase = { 53 error: string; 54}; 55 56type APIError = { 57 exception: string; 58 netbox_version: string; 59 python_version: string; 60} & ErrorBase; 61 62type APIObjectBase = { 63 id: number; 64 display: string; 65 name?: Nullable<string>; 66 url: string; 67 _depth?: number; 68 [k: string]: JSONAble; 69}; 70 71type APIKeyPair = { 72 public_key: string; 73 private_key: string; 74}; 75 76type APIReference = { 77 id: number; 78 name: string; 79 slug: string; 80 url: string; 81 _depth: number; 82}; 83 84type APISecret = { 85 assigned_object: APIObjectBase; 86 assigned_object_id: number; 87 assigned_object_type: string; 88 created: string; 89 custom_fields: Record<string, unknown>; 90 display: string; 91 hash: string; 92 id: number; 93 last_updated: string; 94 name: string; 95 plaintext: Nullable<string>; 96 role: APIObjectBase; 97 tags: number[]; 98 url: string; 99}; 100 101type JobResultLog = { 102 message: string; 103 status: 'success' | 'warning' | 'danger' | 'info'; 104}; 105 106type JobStatus = { 107 label: string; 108 value: 'completed' | 'failed' | 'errored' | 'running'; 109}; 110 111type APIJobResult = { 112 completed: string; 113 created: string; 114 data: { 115 log: JobResultLog[]; 116 output: string; 117 }; 118 display: string; 119 id: number; 120 job_id: string; 121 name: string; 122 obj_type: string; 123 status: JobStatus; 124 url: string; 125 user: { 126 display: string; 127 username: string; 128 id: number; 129 url: string; 130 }; 131}; 132 133type APIUserConfig = { 134 tables: { [k: string]: { columns: string[]; available_columns: string[] } }; 135 [k: string]: unknown; 136}; 137 138type LLDPInterface = { 139 parent_interface: string | null; 140 remote_chassis_id: string | null; 141 remote_port: string | null; 142 remote_port_description: string | null; 143 remote_system_capab: string[]; 144 remote_system_description: string | null; 145 remote_system_enable_capab: string[]; 146 remote_system_name: string | null; 147}; 148 149type LLDPNeighborDetail = { 150 get_lldp_neighbors_detail: { [interface: string]: LLDPInterface[] }; 151}; 152 153type DeviceConfig = { 154 get_config: { 155 candidate: string | Record<string, unknown>; 156 running: string | Record<string, unknown>; 157 startup: string | Record<string, unknown>; 158 error?: string; 159 }; 160}; 161 162type DeviceConfigType = Exclude<keyof DeviceConfig['get_config'], 'error'>; 163 164type DeviceEnvironment = { 165 cpu?: { 166 [core: string]: { '%usage': number }; 167 }; 168 memory?: { 169 available_ram: number; 170 used_ram: number; 171 }; 172 power?: { 173 [psu: string]: { capacity: number; output: number; status: boolean }; 174 }; 175 temperature?: { 176 [sensor: string]: { 177 is_alert: boolean; 178 is_critical: boolean; 179 temperature: number; 180 }; 181 }; 182 fans?: { 183 [fan: string]: { 184 status: boolean; 185 }; 186 }; 187}; 188 189type DeviceFacts = { 190 fqdn: string; 191 hostname: string; 192 interface_list: string[]; 193 model: string; 194 os_version: string; 195 serial_number: string; 196 uptime: number; 197 vendor: string; 198}; 199 200type DeviceStatus = { 201 get_environment: DeviceEnvironment | ErrorBase; 202 get_facts: DeviceFacts | ErrorBase; 203}; 204 205interface ObjectWithGroup extends APIObjectBase { 206 group: Nullable<APIReference>; 207} 208 209declare const messages: string[]; 210 211type FormControls = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; 212 213type ColorMode = 'light' | 'dark'; 214type ColorModePreference = ColorMode | 'none'; 215type ConfigContextFormat = 'json' | 'yaml'; 216 217type UserPreferences = { 218 ui: { 219 colorMode: ColorMode; 220 showRackImages: boolean; 221 }; 222}; 223