zklib-ts
Version:
Unofficial zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices
58 lines (57 loc) • 1.46 kB
TypeScript
/**
* Error types for device communication
*/
export declare const ERROR_TYPES: {
readonly ECONNRESET: "ECONNRESET";
readonly ECONNREFUSED: "ECONNREFUSED";
readonly EADDRINUSE: "EADDRINUSE";
readonly ETIMEDOUT: "ETIMEDOUT";
};
type ErrorType = keyof typeof ERROR_TYPES;
interface ErrorInfo {
message: string;
code?: ErrorType | string;
}
interface ZkErrorDetails {
err: {
message: string;
code?: string;
};
ip: string;
command: string | number;
}
/**
* Custom error class for device communication errors
*/
export declare class ZkError {
private err;
private ip;
private command;
/**
* Creates a new ZkError instance
* @param err The error object
* @param command The command that caused the error
* @param ip The IP address of the device
*/
constructor(err: ErrorInfo, command: number | string, ip: string);
/**
* Gets a user-friendly error message
* @returns A formatted error message
*/
toast(): string;
/**
* Gets detailed error information
* @returns An object containing error details
*/
getError(): ZkErrorDetails;
}
declare const _default: {
ZkError: typeof ZkError;
ERROR_TYPES: {
readonly ECONNRESET: "ECONNRESET";
readonly ECONNREFUSED: "ECONNREFUSED";
readonly EADDRINUSE: "EADDRINUSE";
readonly ETIMEDOUT: "ETIMEDOUT";
};
};
export default _default;