@hardwarebridge/client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,187 @@
1
+ export interface DeviceInfo {
2
+ id: string;
3
+ name: string;
4
+ type: 'printer' | 'serial' | 'usbhid';
5
+ status: 'available' | 'connected' | 'error';
6
+ manufacturer: string;
7
+ model: string;
8
+ serialNumber: string;
9
+ properties: Record<string, any>;
10
+ lastSeen: Date;
11
+ isConnected: boolean;
12
+ connectionId?: string;
13
+ }
14
+
15
+ export interface PrinterDevice extends DeviceInfo {
16
+ supportedProtocols: string[];
17
+ maxPrintWidth: number;
18
+ supportsColor: boolean;
19
+ supportsDuplex: boolean;
20
+ maxResolution: number;
21
+ currentStatus: string;
22
+ jobsInQueue: number;
23
+ }
24
+
25
+ export interface SerialPortDevice extends DeviceInfo {
26
+ portName: string;
27
+ baudRate: number;
28
+ parity: string;
29
+ dataBits: number;
30
+ stopBits: string;
31
+ flowControl: string;
32
+ isOpen: boolean;
33
+ bytesToRead: number;
34
+ bytesToWrite: number;
35
+ }
36
+
37
+ export interface UsbHidDevice extends DeviceInfo {
38
+ vendorId: number;
39
+ productId: number;
40
+ version: number;
41
+ devicePath: string;
42
+ inputReportLength: number;
43
+ outputReportLength: number;
44
+ featureReportLength: number;
45
+ isOpen: boolean;
46
+ }
47
+
48
+ export interface ConnectionConfig {
49
+ url: string;
50
+ protocols?: string[];
51
+ reconnectInterval?: number;
52
+ maxReconnectAttempts?: number;
53
+ timeout?: number;
54
+ }
55
+
56
+ export interface JsonRpcRequest {
57
+ jsonrpc: '2.0';
58
+ method: string;
59
+ params?: any;
60
+ id?: string | number | null;
61
+ }
62
+
63
+ export interface JsonRpcResponse {
64
+ jsonrpc: '2.0';
65
+ result?: any;
66
+ error?: JsonRpcError;
67
+ id?: string | number | null;
68
+ }
69
+
70
+ export interface JsonRpcError {
71
+ code: number;
72
+ message: string;
73
+ data?: any;
74
+ }
75
+
76
+ export interface PrintJob {
77
+ id: string;
78
+ deviceId: string;
79
+ data: string;
80
+ format: 'raw' | 'escpos' | 'zpl' | 'epl';
81
+ status: 'pending' | 'processing' | 'completed' | 'failed';
82
+ createdAt: Date;
83
+ startedAt?: Date;
84
+ completedAt?: Date;
85
+ error?: string;
86
+ retryCount: number;
87
+ options?: Record<string, any>;
88
+ }
89
+
90
+ export interface PrintResult {
91
+ success: boolean;
92
+ jobId?: string;
93
+ bytesPrinted?: number;
94
+ error?: string;
95
+ timestamp: Date;
96
+ }
97
+
98
+ export interface SerialPortConfig {
99
+ baudRate: number;
100
+ parity: 'None' | 'Odd' | 'Even' | 'Mark' | 'Space';
101
+ dataBits: 7 | 8;
102
+ stopBits: '1' | '1.5' | '2';
103
+ flowControl: 'None' | 'XOnXOff' | 'RequestToSend' | 'RequestToSendXOnXOff';
104
+ }
105
+
106
+ export interface SerialData {
107
+ deviceId: string;
108
+ data: string;
109
+ timestamp: Date;
110
+ direction: 'send' | 'receive';
111
+ bytesTransferred: number;
112
+ }
113
+
114
+ export interface UsbHidReport {
115
+ deviceId: string;
116
+ reportId: number;
117
+ data: string;
118
+ timestamp: Date;
119
+ reportType: 'input' | 'output' | 'feature';
120
+ }
121
+
122
+ export interface QueueJob {
123
+ id: string;
124
+ deviceId: string;
125
+ deviceType: string;
126
+ operation: string;
127
+ status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
128
+ createdAt: Date;
129
+ startedAt?: Date;
130
+ completedAt?: Date;
131
+ error?: string;
132
+ retryCount: number;
133
+ parameters?: Record<string, any>;
134
+ }
135
+
136
+ export interface QueueStatus {
137
+ totalJobs: number;
138
+ pendingJobs: number;
139
+ processingJobs: number;
140
+ completedJobs: number;
141
+ failedJobs: number;
142
+ lastProcessed: Date;
143
+ averageProcessingTime: number;
144
+ }
145
+
146
+ export interface SystemHealth {
147
+ status: 'healthy' | 'warning' | 'error' | 'no_devices';
148
+ timestamp: Date;
149
+ totalDevices: number;
150
+ connectedDevices: number;
151
+ activeConnections: number;
152
+ jobsInQueue: number;
153
+ cpuUsage: number;
154
+ memoryUsage: number;
155
+ deviceHealth: Record<string, any>;
156
+ }
157
+
158
+ export interface ConnectionState {
159
+ connected: boolean;
160
+ connecting: boolean;
161
+ error?: string;
162
+ reconnectAttempts: number;
163
+ lastConnectionTime?: Date;
164
+ }
165
+
166
+ export interface DeviceEvent {
167
+ eventType: 'connected' | 'disconnected' | 'discovered' | 'removed' | 'status_changed' | 'error' | 'data';
168
+ deviceId: string;
169
+ deviceType: string;
170
+ timestamp: Date;
171
+ data?: Record<string, any>;
172
+ }
173
+
174
+ export interface ClientOptions {
175
+ autoReconnect?: boolean;
176
+ reconnectInterval?: number;
177
+ maxReconnectAttempts?: number;
178
+ timeout?: number;
179
+ debug?: boolean;
180
+ protocols?: string[];
181
+ headers?: Record<string, string>;
182
+ }
183
+
184
+ export type DeviceType = 'printer' | 'serial' | 'usbhid';
185
+ export type PrintFormat = 'raw' | 'escpos' | 'zpl' | 'epl';
186
+ export type JobStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
187
+ export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error' | 'reconnecting';