node-red-contrib-tplink-tapo-connect-api
Version:
This unofficial node-RED node allows connection to TP-Link Tapo devices. This project has been enhanced with AI support to enable new features. Starting with v0.50, we have added support for the KLAP protocol. To prioritize the operation of this node, we
76 lines (75 loc) • 2.22 kB
TypeScript
/**
* Standardized error classification and handling utilities
*/
export declare enum TapoErrorType {
SESSION_EXPIRED = "session_expired",
DEVICE_BUSY = "device_busy",
NETWORK_ERROR = "network_error",
AUTHENTICATION_FAILED = "authentication_failed",
FEATURE_NOT_SUPPORTED = "feature_not_supported",
INVALID_PARAMETER = "invalid_parameter",
DEVICE_OFFLINE = "device_offline",
PROTOCOL_ERROR = "protocol_error",
TIMEOUT = "timeout",
UNKNOWN = "unknown"
}
export interface ClassifiedError {
type: TapoErrorType;
originalError: Error;
isRetryable: boolean;
retryAfterMs: number | undefined;
suggestedAction: string | undefined;
}
export interface ErrorPatternConfig {
sessionPatterns: string[];
busyPatterns: string[];
networkPatterns: string[];
authPatterns: string[];
featurePatterns: string[];
parameterPatterns: string[];
offlinePatterns: string[];
protocolPatterns: string[];
timeoutPatterns: string[];
}
/**
* Centralized error classification utility
*/
export declare class ErrorClassifier {
private static readonly DEFAULT_PATTERNS;
private patterns;
constructor(customPatterns?: Partial<ErrorPatternConfig>);
/**
* Classify an error into a standard type
*/
classify(error: Error): ClassifiedError;
/**
* Check if error message matches any of the given patterns
*/
private matchesPatterns;
/**
* Create a classified error object
*/
private createClassifiedError;
/**
* Determine if an error is retryable
*/
static isRetryableError(error: Error): boolean;
/**
* Get suggested retry delay for an error
*/
static getRetryDelay(error: Error): number;
/**
* Create a user-friendly error message
*/
static createUserFriendlyMessage(error: Error): string;
}
/**
* Enhanced error class with classification
*/
export declare class ClassifiedTapoError extends Error {
readonly classification: ClassifiedError;
constructor(originalError: Error, classifier?: ErrorClassifier);
isRetryable(): boolean;
getRetryDelay(): number | undefined;
getSuggestedAction(): string | undefined;
}