BREAKING CHANGE(snmp): refactor: update SNMP type definitions and interface names for consistency

This commit is contained in:
2025-03-25 10:21:21 +00:00
parent 70c16fa0a6
commit ecfd171f97
9 changed files with 41 additions and 35 deletions

View File

@@ -1,13 +1,13 @@
import * as fs from 'fs';
import * as path from 'path';
import { NupstSnmp, type SnmpConfig } from './snmp.js';
import { NupstSnmp, type ISnmpConfig } from './snmp.js';
/**
* Configuration interface for the daemon
*/
export interface NupstConfig {
export interface INupstConfig {
/** SNMP configuration settings */
snmp: SnmpConfig;
snmp: ISnmpConfig;
/** Threshold settings for initiating shutdown */
thresholds: {
/** Shutdown when battery below this percentage */
@@ -28,7 +28,7 @@ export class NupstDaemon {
private readonly CONFIG_PATH = '/etc/nupst/config.json';
/** Default configuration */
private readonly DEFAULT_CONFIG: NupstConfig = {
private readonly DEFAULT_CONFIG: INupstConfig = {
snmp: {
host: '127.0.0.1',
port: 161,
@@ -52,7 +52,7 @@ export class NupstDaemon {
checkInterval: 30000, // Check every 30 seconds
};
private config: NupstConfig;
private config: INupstConfig;
private snmp: NupstSnmp;
private isRunning: boolean = false;
@@ -68,7 +68,7 @@ export class NupstDaemon {
* Load configuration from file
* @throws Error if configuration file doesn't exist
*/
public async loadConfig(): Promise<NupstConfig> {
public async loadConfig(): Promise<INupstConfig> {
try {
// Check if config file exists
const configExists = fs.existsSync(this.CONFIG_PATH);
@@ -95,7 +95,7 @@ export class NupstDaemon {
/**
* Save configuration to file
*/
public async saveConfig(config: NupstConfig): Promise<void> {
public async saveConfig(config: INupstConfig): Promise<void> {
try {
const configDir = path.dirname(this.CONFIG_PATH);
if (!fs.existsSync(configDir)) {
@@ -125,7 +125,7 @@ export class NupstDaemon {
/**
* Get the current configuration
*/
public getConfig(): NupstConfig {
public getConfig(): INupstConfig {
return this.config;
}