@ecobridge.xyz/devicemanager 3.0.2

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.
Files changed (137) hide show
  1. package/.gitea/workflows/default_nottags.yaml +66 -0
  2. package/.gitea/workflows/default_tags.yaml +124 -0
  3. package/.vscode/launch.json +11 -0
  4. package/.vscode/settings.json +26 -0
  5. package/changelog.md +91 -0
  6. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  7. package/dist_ts/00_commitinfo_data.js +9 -0
  8. package/dist_ts/device/device.classes.device.d.ts +205 -0
  9. package/dist_ts/device/device.classes.device.js +344 -0
  10. package/dist_ts/devicemanager.classes.devicemanager.d.ts +210 -0
  11. package/dist_ts/devicemanager.classes.devicemanager.js +835 -0
  12. package/dist_ts/discovery/discovery.classes.homeassistant.d.ts +101 -0
  13. package/dist_ts/discovery/discovery.classes.homeassistant.js +313 -0
  14. package/dist_ts/discovery/discovery.classes.mdns.d.ts +90 -0
  15. package/dist_ts/discovery/discovery.classes.mdns.js +291 -0
  16. package/dist_ts/discovery/discovery.classes.networkscanner.d.ts +64 -0
  17. package/dist_ts/discovery/discovery.classes.networkscanner.js +535 -0
  18. package/dist_ts/discovery/discovery.classes.ssdp.d.ts +112 -0
  19. package/dist_ts/discovery/discovery.classes.ssdp.js +255 -0
  20. package/dist_ts/factories/index.d.ts +190 -0
  21. package/dist_ts/factories/index.js +350 -0
  22. package/dist_ts/features/feature.abstract.d.ts +118 -0
  23. package/dist_ts/features/feature.abstract.js +172 -0
  24. package/dist_ts/features/feature.camera.d.ts +95 -0
  25. package/dist_ts/features/feature.camera.js +162 -0
  26. package/dist_ts/features/feature.climate.d.ts +174 -0
  27. package/dist_ts/features/feature.climate.js +328 -0
  28. package/dist_ts/features/feature.cover.d.ts +121 -0
  29. package/dist_ts/features/feature.cover.js +217 -0
  30. package/dist_ts/features/feature.fan.d.ts +127 -0
  31. package/dist_ts/features/feature.fan.js +235 -0
  32. package/dist_ts/features/feature.light.d.ts +156 -0
  33. package/dist_ts/features/feature.light.js +296 -0
  34. package/dist_ts/features/feature.lock.d.ts +103 -0
  35. package/dist_ts/features/feature.lock.js +170 -0
  36. package/dist_ts/features/feature.playback.d.ts +98 -0
  37. package/dist_ts/features/feature.playback.js +191 -0
  38. package/dist_ts/features/feature.power.d.ts +79 -0
  39. package/dist_ts/features/feature.power.js +173 -0
  40. package/dist_ts/features/feature.print.d.ts +78 -0
  41. package/dist_ts/features/feature.print.js +226 -0
  42. package/dist_ts/features/feature.scan.d.ts +79 -0
  43. package/dist_ts/features/feature.scan.js +315 -0
  44. package/dist_ts/features/feature.sensor.d.ts +95 -0
  45. package/dist_ts/features/feature.sensor.js +147 -0
  46. package/dist_ts/features/feature.snmp.d.ts +88 -0
  47. package/dist_ts/features/feature.snmp.js +175 -0
  48. package/dist_ts/features/feature.switch.d.ts +75 -0
  49. package/dist_ts/features/feature.switch.js +126 -0
  50. package/dist_ts/features/feature.volume.d.ts +104 -0
  51. package/dist_ts/features/feature.volume.js +186 -0
  52. package/dist_ts/features/index.d.ts +19 -0
  53. package/dist_ts/features/index.js +23 -0
  54. package/dist_ts/helpers/helpers.iprange.d.ts +35 -0
  55. package/dist_ts/helpers/helpers.iprange.js +151 -0
  56. package/dist_ts/helpers/helpers.retry.d.ts +25 -0
  57. package/dist_ts/helpers/helpers.retry.js +69 -0
  58. package/dist_ts/index.d.ts +15 -0
  59. package/dist_ts/index.js +40 -0
  60. package/dist_ts/interfaces/feature.interfaces.d.ts +255 -0
  61. package/dist_ts/interfaces/feature.interfaces.js +6 -0
  62. package/dist_ts/interfaces/homeassistant.interfaces.d.ts +550 -0
  63. package/dist_ts/interfaces/homeassistant.interfaces.js +111 -0
  64. package/dist_ts/interfaces/index.d.ts +330 -0
  65. package/dist_ts/interfaces/index.js +16 -0
  66. package/dist_ts/interfaces/smarthome.interfaces.d.ts +282 -0
  67. package/dist_ts/interfaces/smarthome.interfaces.js +7 -0
  68. package/dist_ts/paths.d.ts +1 -0
  69. package/dist_ts/paths.js +3 -0
  70. package/dist_ts/plugins.d.ts +23 -0
  71. package/dist_ts/plugins.js +30 -0
  72. package/dist_ts/protocols/index.d.ts +12 -0
  73. package/dist_ts/protocols/index.js +21 -0
  74. package/dist_ts/protocols/protocol.escl.d.ts +58 -0
  75. package/dist_ts/protocols/protocol.escl.js +364 -0
  76. package/dist_ts/protocols/protocol.homeassistant.d.ts +248 -0
  77. package/dist_ts/protocols/protocol.homeassistant.js +611 -0
  78. package/dist_ts/protocols/protocol.ipp.d.ts +45 -0
  79. package/dist_ts/protocols/protocol.ipp.js +284 -0
  80. package/dist_ts/protocols/protocol.nut.d.ts +160 -0
  81. package/dist_ts/protocols/protocol.nut.js +364 -0
  82. package/dist_ts/protocols/protocol.sane.d.ts +104 -0
  83. package/dist_ts/protocols/protocol.sane.js +597 -0
  84. package/dist_ts/protocols/protocol.snmp.d.ts +133 -0
  85. package/dist_ts/protocols/protocol.snmp.js +333 -0
  86. package/dist_ts/protocols/protocol.upnp.d.ts +207 -0
  87. package/dist_ts/protocols/protocol.upnp.js +442 -0
  88. package/dist_ts/protocols/protocol.upssnmp.d.ts +160 -0
  89. package/dist_ts/protocols/protocol.upssnmp.js +263 -0
  90. package/npmextra.json +24 -0
  91. package/package.json +39 -0
  92. package/readme.hints.md +115 -0
  93. package/readme.md +624 -0
  94. package/test/test.ts +261 -0
  95. package/ts/00_commitinfo_data.ts +8 -0
  96. package/ts/device/device.classes.device.ts +454 -0
  97. package/ts/devicemanager.classes.devicemanager.ts +1219 -0
  98. package/ts/discovery/discovery.classes.homeassistant.ts +376 -0
  99. package/ts/discovery/discovery.classes.mdns.ts +347 -0
  100. package/ts/discovery/discovery.classes.networkscanner.ts +648 -0
  101. package/ts/discovery/discovery.classes.ssdp.ts +357 -0
  102. package/ts/factories/index.ts +696 -0
  103. package/ts/features/feature.abstract.ts +251 -0
  104. package/ts/features/feature.camera.ts +214 -0
  105. package/ts/features/feature.climate.ts +407 -0
  106. package/ts/features/feature.cover.ts +278 -0
  107. package/ts/features/feature.fan.ts +296 -0
  108. package/ts/features/feature.light.ts +369 -0
  109. package/ts/features/feature.lock.ts +223 -0
  110. package/ts/features/feature.playback.ts +246 -0
  111. package/ts/features/feature.power.ts +231 -0
  112. package/ts/features/feature.print.ts +297 -0
  113. package/ts/features/feature.scan.ts +370 -0
  114. package/ts/features/feature.sensor.ts +202 -0
  115. package/ts/features/feature.snmp.ts +235 -0
  116. package/ts/features/feature.switch.ts +170 -0
  117. package/ts/features/feature.volume.ts +256 -0
  118. package/ts/features/index.ts +25 -0
  119. package/ts/helpers/helpers.iprange.ts +172 -0
  120. package/ts/helpers/helpers.retry.ts +100 -0
  121. package/ts/index.ts +165 -0
  122. package/ts/interfaces/feature.interfaces.ts +359 -0
  123. package/ts/interfaces/homeassistant.interfaces.ts +666 -0
  124. package/ts/interfaces/index.ts +421 -0
  125. package/ts/interfaces/smarthome.interfaces.ts +421 -0
  126. package/ts/paths.ts +5 -0
  127. package/ts/plugins.ts +41 -0
  128. package/ts/protocols/index.ts +59 -0
  129. package/ts/protocols/protocol.escl.ts +439 -0
  130. package/ts/protocols/protocol.homeassistant.ts +737 -0
  131. package/ts/protocols/protocol.ipp.ts +329 -0
  132. package/ts/protocols/protocol.nut.ts +471 -0
  133. package/ts/protocols/protocol.sane.ts +694 -0
  134. package/ts/protocols/protocol.snmp.ts +439 -0
  135. package/ts/protocols/protocol.upnp.ts +627 -0
  136. package/ts/protocols/protocol.upssnmp.ts +377 -0
  137. package/tsconfig.json +12 -0
@@ -0,0 +1,421 @@
1
+ /**
2
+ * Device Manager Type Definitions
3
+ */
4
+
5
+ // ============================================================================
6
+ // Device Types
7
+ // ============================================================================
8
+
9
+ export type TDeviceType = 'scanner' | 'printer' | 'snmp' | 'ups' | 'speaker' | 'dlna-renderer' | 'dlna-server';
10
+ export type TDeviceStatus = 'online' | 'offline' | 'busy' | 'error' | 'unknown';
11
+ export type TConnectionState = 'disconnected' | 'connecting' | 'connected' | 'error';
12
+
13
+ // ============================================================================
14
+ // Scanner Types
15
+ // ============================================================================
16
+
17
+ export type TScannerProtocol = 'sane' | 'escl';
18
+ export type TScanFormat = 'png' | 'jpeg' | 'pdf' | 'tiff';
19
+ export type TColorMode = 'color' | 'grayscale' | 'blackwhite';
20
+ export type TScanSource = 'flatbed' | 'adf' | 'adf-duplex';
21
+
22
+ // ============================================================================
23
+ // Base Interfaces
24
+ // ============================================================================
25
+
26
+ export interface IDeviceInfo {
27
+ id: string;
28
+ name: string;
29
+ type: TDeviceType;
30
+ address: string;
31
+ port: number;
32
+ status: TDeviceStatus;
33
+ manufacturer?: string;
34
+ model?: string;
35
+ serialNumber?: string;
36
+ firmwareVersion?: string;
37
+ }
38
+
39
+ export interface IDeviceManagerOptions {
40
+ /** Enable auto-discovery on startup */
41
+ autoDiscovery?: boolean;
42
+ /** Discovery timeout in milliseconds */
43
+ discoveryTimeout?: number;
44
+ /** Enable retry with exponential backoff */
45
+ enableRetry?: boolean;
46
+ /** Maximum retry attempts */
47
+ maxRetries?: number;
48
+ /** Base delay for retry backoff in milliseconds */
49
+ retryBaseDelay?: number;
50
+ }
51
+
52
+ // ============================================================================
53
+ // Scanner Interfaces
54
+ // ============================================================================
55
+
56
+ export interface IScannerInfo extends IDeviceInfo {
57
+ type: 'scanner';
58
+ protocol: TScannerProtocol;
59
+ supportedFormats: TScanFormat[];
60
+ supportedResolutions: number[];
61
+ supportedColorModes: TColorMode[];
62
+ supportedSources: TScanSource[];
63
+ hasAdf: boolean;
64
+ hasDuplex: boolean;
65
+ maxWidth?: number; // in mm
66
+ maxHeight?: number; // in mm
67
+ }
68
+
69
+ export interface IScanArea {
70
+ x: number; // X offset in mm
71
+ y: number; // Y offset in mm
72
+ width: number; // Width in mm
73
+ height: number; // Height in mm
74
+ }
75
+
76
+ export interface IScanOptions {
77
+ /** Resolution in DPI (default: 300) */
78
+ resolution?: number;
79
+ /** Output format (default: 'png') */
80
+ format?: TScanFormat;
81
+ /** Color mode (default: 'color') */
82
+ colorMode?: TColorMode;
83
+ /** Scan source (default: 'flatbed') */
84
+ source?: TScanSource;
85
+ /** Scan area (default: full page) */
86
+ area?: IScanArea;
87
+ /** Document intent for optimization */
88
+ intent?: 'document' | 'photo' | 'preview';
89
+ /** Compression quality for JPEG (1-100) */
90
+ quality?: number;
91
+ }
92
+
93
+ export interface IScanResult {
94
+ /** Scanned image data */
95
+ data: Buffer;
96
+ /** Output format */
97
+ format: TScanFormat;
98
+ /** Image width in pixels */
99
+ width: number;
100
+ /** Image height in pixels */
101
+ height: number;
102
+ /** Scan resolution in DPI */
103
+ resolution: number;
104
+ /** Color mode used */
105
+ colorMode: TColorMode;
106
+ /** MIME type */
107
+ mimeType: string;
108
+ }
109
+
110
+ export interface IScannerCapabilities {
111
+ resolutions: number[];
112
+ formats: TScanFormat[];
113
+ colorModes: TColorMode[];
114
+ sources: TScanSource[];
115
+ maxWidth: number;
116
+ maxHeight: number;
117
+ minWidth: number;
118
+ minHeight: number;
119
+ }
120
+
121
+ // ============================================================================
122
+ // Printer Interfaces
123
+ // ============================================================================
124
+
125
+ export interface IPrinterInfo extends IDeviceInfo {
126
+ type: 'printer';
127
+ uri: string;
128
+ supportsColor: boolean;
129
+ supportsDuplex: boolean;
130
+ supportedMediaTypes: string[];
131
+ supportedMediaSizes: string[];
132
+ maxCopies: number;
133
+ }
134
+
135
+ export interface IPrintOptions {
136
+ /** Number of copies (default: 1) */
137
+ copies?: number;
138
+ /** Media size (e.g., 'iso_a4_210x297mm') */
139
+ mediaSize?: string;
140
+ /** Media type (e.g., 'stationery') */
141
+ mediaType?: string;
142
+ /** Print sides: 'one-sided', 'two-sided-long-edge', 'two-sided-short-edge' */
143
+ sides?: 'one-sided' | 'two-sided-long-edge' | 'two-sided-short-edge';
144
+ /** Print quality */
145
+ quality?: 'draft' | 'normal' | 'high';
146
+ /** Color mode */
147
+ colorMode?: 'color' | 'monochrome';
148
+ /** Job name */
149
+ jobName?: string;
150
+ }
151
+
152
+ export interface IPrintJob {
153
+ id: number;
154
+ name: string;
155
+ state: 'pending' | 'processing' | 'completed' | 'canceled' | 'aborted';
156
+ stateReason?: string;
157
+ createdAt: Date;
158
+ completedAt?: Date;
159
+ pagesPrinted?: number;
160
+ pagesTotal?: number;
161
+ }
162
+
163
+ export interface IPrinterCapabilities {
164
+ colorSupported: boolean;
165
+ duplexSupported: boolean;
166
+ mediaSizes: string[];
167
+ mediaTypes: string[];
168
+ resolutions: number[];
169
+ maxCopies: number;
170
+ sidesSupported: string[];
171
+ qualitySupported: string[];
172
+ }
173
+
174
+ // ============================================================================
175
+ // Discovery Interfaces
176
+ // ============================================================================
177
+
178
+ export interface IDiscoveredDevice {
179
+ id: string;
180
+ name: string;
181
+ type: TDeviceType;
182
+ protocol: string; // 'escl' | 'sane' | 'ipp' | 'airplay' | 'sonos' | 'chromecast' | etc.
183
+ address: string;
184
+ port: number;
185
+ txtRecords: Record<string, string>;
186
+ serviceType: string;
187
+ }
188
+
189
+ export interface IDiscoveryOptions {
190
+ /** Service types to discover */
191
+ serviceTypes?: string[];
192
+ /** Discovery timeout in ms */
193
+ timeout?: number;
194
+ }
195
+
196
+ // ============================================================================
197
+ // Retry Configuration
198
+ // ============================================================================
199
+
200
+ export interface IRetryOptions {
201
+ /** Maximum number of retry attempts */
202
+ maxRetries?: number;
203
+ /** Base delay in milliseconds */
204
+ baseDelay?: number;
205
+ /** Maximum delay in milliseconds */
206
+ maxDelay?: number;
207
+ /** Delay multiplier for exponential backoff */
208
+ multiplier?: number;
209
+ /** Whether to add jitter to delays */
210
+ jitter?: boolean;
211
+ }
212
+
213
+ // ============================================================================
214
+ // Event Types
215
+ // ============================================================================
216
+
217
+ export type TDeviceManagerEvents = {
218
+ 'scanner:found': (scanner: IScannerInfo) => void;
219
+ 'scanner:lost': (scannerId: string) => void;
220
+ 'printer:found': (printer: IPrinterInfo) => void;
221
+ 'printer:lost': (printerId: string) => void;
222
+ 'device:updated': (device: IDeviceInfo) => void;
223
+ 'discovery:started': () => void;
224
+ 'discovery:stopped': () => void;
225
+ 'error': (error: Error) => void;
226
+ };
227
+
228
+ // ============================================================================
229
+ // eSCL Protocol Types
230
+ // ============================================================================
231
+
232
+ export interface IEsclCapabilities {
233
+ version: string;
234
+ makeAndModel: string;
235
+ serialNumber?: string;
236
+ uuid?: string;
237
+ adminUri?: string;
238
+ iconUri?: string;
239
+ platen?: IEsclInputSource;
240
+ adf?: IEsclInputSource;
241
+ adfDuplex?: IEsclInputSource;
242
+ }
243
+
244
+ export interface IEsclInputSource {
245
+ minWidth: number;
246
+ maxWidth: number;
247
+ minHeight: number;
248
+ maxHeight: number;
249
+ maxScanRegions: number;
250
+ supportedResolutions: number[];
251
+ colorModes: string[];
252
+ documentFormats: string[];
253
+ }
254
+
255
+ export interface IEsclScanStatus {
256
+ state: 'Idle' | 'Processing' | 'Stopped' | 'Testing';
257
+ adfState?: 'Empty' | 'Loaded' | 'Jammed' | 'Open' | 'Closed';
258
+ jobs?: IEsclJobInfo[];
259
+ }
260
+
261
+ export interface IEsclJobInfo {
262
+ jobUri: string;
263
+ jobUuid: string;
264
+ age: number;
265
+ imagesCompleted: number;
266
+ imagesToTransfer: number;
267
+ jobState: 'Pending' | 'Processing' | 'Completed' | 'Canceled' | 'Aborted';
268
+ jobStateReason?: string;
269
+ }
270
+
271
+ // ============================================================================
272
+ // SANE Protocol Types
273
+ // ============================================================================
274
+
275
+ export interface ISaneDevice {
276
+ name: string;
277
+ vendor: string;
278
+ model: string;
279
+ type: string;
280
+ }
281
+
282
+ export interface ISaneOption {
283
+ name: string;
284
+ title: string;
285
+ description: string;
286
+ type: 'bool' | 'int' | 'fixed' | 'string' | 'button' | 'group';
287
+ unit: 'none' | 'pixel' | 'bit' | 'mm' | 'dpi' | 'percent' | 'microsecond';
288
+ size: number;
289
+ capabilities: number;
290
+ constraintType: 'none' | 'range' | 'word_list' | 'string_list';
291
+ constraint?: ISaneConstraint;
292
+ }
293
+
294
+ export interface ISaneConstraint {
295
+ range?: { min: number; max: number; quant: number };
296
+ wordList?: number[];
297
+ stringList?: string[];
298
+ }
299
+
300
+ export interface ISaneParameters {
301
+ format: 'gray' | 'rgb' | 'red' | 'green' | 'blue';
302
+ lastFrame: boolean;
303
+ bytesPerLine: number;
304
+ pixelsPerLine: number;
305
+ lines: number;
306
+ depth: number;
307
+ }
308
+
309
+ // ============================================================================
310
+ // Network Scanner Interfaces (IP-based discovery)
311
+ // ============================================================================
312
+
313
+ export interface INetworkScanOptions {
314
+ /** CIDR notation (e.g., "192.168.1.0/24") */
315
+ ipRange?: string;
316
+ /** Start IP address for range scan */
317
+ startIp?: string;
318
+ /** End IP address for range scan */
319
+ endIp?: string;
320
+ /** Maximum concurrent probes (default: 50) */
321
+ concurrency?: number;
322
+ /** Timeout per probe in milliseconds (default: 2000) */
323
+ timeout?: number;
324
+ /** Ports to probe (default: [80, 443, 631, 6566, 9100, 7000, 1400, 8009]) */
325
+ ports?: number[];
326
+ /** Check for eSCL scanners (default: true) */
327
+ probeEscl?: boolean;
328
+ /** Check for IPP printers (default: true) */
329
+ probeIpp?: boolean;
330
+ /** Check for SANE scanners (default: true) */
331
+ probeSane?: boolean;
332
+ /** Check for AirPlay speakers (default: true) */
333
+ probeAirplay?: boolean;
334
+ /** Check for Sonos speakers (default: true) */
335
+ probeSonos?: boolean;
336
+ /** Check for Chromecast devices (default: true) */
337
+ probeChromecast?: boolean;
338
+ }
339
+
340
+ export interface INetworkScanDevice {
341
+ type: 'scanner' | 'printer' | 'speaker';
342
+ protocol: 'escl' | 'sane' | 'ipp' | 'jetdirect' | 'airplay' | 'sonos' | 'chromecast';
343
+ port: number;
344
+ name?: string;
345
+ model?: string;
346
+ }
347
+
348
+ export interface INetworkScanResult {
349
+ address: string;
350
+ devices: INetworkScanDevice[];
351
+ }
352
+
353
+ export interface INetworkScanProgress {
354
+ /** Total IPs to scan */
355
+ total: number;
356
+ /** IPs scanned so far */
357
+ scanned: number;
358
+ /** Percentage complete (0-100) */
359
+ percentage: number;
360
+ /** Current IP being scanned */
361
+ currentIp?: string;
362
+ /** Devices found so far */
363
+ devicesFound: number;
364
+ }
365
+
366
+ export type TNetworkScannerEvents = {
367
+ 'progress': (progress: INetworkScanProgress) => void;
368
+ 'device:found': (result: INetworkScanResult) => void;
369
+ 'complete': (results: INetworkScanResult[]) => void;
370
+ 'error': (error: Error) => void;
371
+ 'cancelled': () => void;
372
+ };
373
+
374
+ // ============================================================================
375
+ // Device Selector Interface
376
+ // ============================================================================
377
+
378
+ import type { TFeatureType } from './feature.interfaces.js';
379
+
380
+ /**
381
+ * Criteria for selecting devices from the manager.
382
+ * Identity selectors (id, address) match exactly.
383
+ * Attribute selectors (name, model, manufacturer) match partially (case-insensitive).
384
+ * Capability selectors filter by feature availability.
385
+ */
386
+ export interface IDeviceSelector {
387
+ /** Exact match on device ID */
388
+ id?: string;
389
+ /** Exact match on IP address */
390
+ address?: string;
391
+ /** Partial match on device name (case-insensitive) */
392
+ name?: string;
393
+ /** Partial match on device model (case-insensitive) */
394
+ model?: string;
395
+ /** Partial match on manufacturer name (case-insensitive) */
396
+ manufacturer?: string;
397
+ /** Device must have this feature */
398
+ hasFeature?: TFeatureType;
399
+ /** Device must have ALL of these features */
400
+ hasFeatures?: TFeatureType[];
401
+ /** Device must have ANY of these features */
402
+ hasAnyFeature?: TFeatureType[];
403
+ }
404
+
405
+ // ============================================================================
406
+ // Feature Types (Universal Device Architecture)
407
+ // ============================================================================
408
+
409
+ export * from './feature.interfaces.js';
410
+
411
+ // ============================================================================
412
+ // Smart Home Types (Generic, Protocol-agnostic)
413
+ // ============================================================================
414
+
415
+ export * from './smarthome.interfaces.js';
416
+
417
+ // ============================================================================
418
+ // Home Assistant Specific Types
419
+ // ============================================================================
420
+
421
+ export * from './homeassistant.interfaces.js';