Files
nupst/ts/snmp/types.ts
Juergen Kunz 9ccbbbdc37 fix(snmp): resolve TypeScript type errors for Deno strict mode
- Add Buffer import from node:buffer to manager.ts and types.ts
- Fix error handling type assertions (error/retryError/stdError as unknown)
- Add explicit type annotation to byte parameter in isPrintableAscii check
- All tests now passing (3 SNMP tests + 10 logger tests)
2025-10-18 16:17:01 +00:00

94 lines
2.2 KiB
TypeScript

/**
* Type definitions for SNMP module
*/
import { Buffer } from "node:buffer";
/**
* UPS status interface
*/
export interface IUpsStatus {
/** Current power status */
powerStatus: 'online' | 'onBattery' | 'unknown';
/** Battery capacity percentage */
batteryCapacity: number;
/** Remaining runtime in minutes */
batteryRuntime: number;
/** Raw values from SNMP responses */
raw: Record<string, any>;
}
/**
* SNMP OID Sets for different UPS brands
*/
export interface IOidSet {
/** OID for power status */
POWER_STATUS: string;
/** OID for battery capacity */
BATTERY_CAPACITY: string;
/** OID for battery runtime */
BATTERY_RUNTIME: string;
}
/**
* Supported UPS model types
*/
export type TUpsModel = 'cyberpower' | 'apc' | 'eaton' | 'tripplite' | 'liebert' | 'custom';
/**
* SNMP Configuration interface
*/
export interface ISnmpConfig {
/** SNMP server host */
host: string;
/** SNMP server port (default 161) */
port: number;
/** SNMP version (1, 2, or 3) */
version: number;
/** Timeout in milliseconds */
timeout: number;
context?: string;
// SNMPv1/v2c
/** Community string for SNMPv1/v2c */
community?: string;
// SNMPv3
/** Security level for SNMPv3 */
securityLevel?: 'noAuthNoPriv' | 'authNoPriv' | 'authPriv';
/** Username for SNMPv3 authentication */
username?: string;
/** Authentication protocol for SNMPv3 */
authProtocol?: 'MD5' | 'SHA';
/** Authentication key for SNMPv3 */
authKey?: string;
/** Privacy protocol for SNMPv3 */
privProtocol?: 'DES' | 'AES';
/** Privacy key for SNMPv3 */
privKey?: string;
// UPS model and custom OIDs
/** UPS model for OID selection */
upsModel?: TUpsModel;
/** Custom OIDs when using custom UPS model */
customOIDs?: IOidSet;
}
/**
* SNMPv3 security parameters
*/
export interface ISnmpV3SecurityParams {
/** Engine ID for the SNMP server */
msgAuthoritativeEngineID: Buffer;
/** Engine boots counter */
msgAuthoritativeEngineBoots: number;
/** Engine time counter */
msgAuthoritativeEngineTime: number;
/** Username for authentication */
msgUserName: string;
/** Authentication parameters */
msgAuthenticationParameters: Buffer;
/** Privacy parameters */
msgPrivacyParameters: Buffer;
}