@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,25 @@
1
+ import type { IRetryOptions } from '../interfaces/index.js';
2
+ declare const defaultRetryOptions: Required<IRetryOptions>;
3
+ /**
4
+ * Executes a function with retry logic using exponential backoff
5
+ *
6
+ * @param fn - The async function to execute
7
+ * @param options - Retry configuration options
8
+ * @returns The result of the function
9
+ * @throws The last error if all retries fail
10
+ */
11
+ export declare function withRetry<T>(fn: () => Promise<T>, options?: IRetryOptions): Promise<T>;
12
+ /**
13
+ * Creates a retryable version of an async function
14
+ *
15
+ * @param fn - The async function to wrap
16
+ * @param options - Retry configuration options
17
+ * @returns A wrapped function that retries on failure
18
+ */
19
+ export declare function createRetryable<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: IRetryOptions): (...args: TArgs) => Promise<TResult>;
20
+ /**
21
+ * Retry decorator for class methods
22
+ * Note: Use as a wrapper function since TC39 decorators have different semantics
23
+ */
24
+ export declare function retryMethod<T extends Record<string, unknown>>(target: T, methodName: keyof T & string, options?: IRetryOptions): void;
25
+ export { defaultRetryOptions };
@@ -0,0 +1,69 @@
1
+ import * as plugins from '../plugins.js';
2
+ const defaultRetryOptions = {
3
+ maxRetries: 5,
4
+ baseDelay: 1000,
5
+ maxDelay: 16000,
6
+ multiplier: 2,
7
+ jitter: true,
8
+ };
9
+ /**
10
+ * Calculates the delay for a retry attempt using exponential backoff
11
+ */
12
+ function calculateDelay(attempt, options) {
13
+ const delay = Math.min(options.baseDelay * Math.pow(options.multiplier, attempt), options.maxDelay);
14
+ if (options.jitter) {
15
+ // Add random jitter of +/- 25%
16
+ const jitterRange = delay * 0.25;
17
+ return delay + (Math.random() * jitterRange * 2 - jitterRange);
18
+ }
19
+ return delay;
20
+ }
21
+ /**
22
+ * Executes a function with retry logic using exponential backoff
23
+ *
24
+ * @param fn - The async function to execute
25
+ * @param options - Retry configuration options
26
+ * @returns The result of the function
27
+ * @throws The last error if all retries fail
28
+ */
29
+ export async function withRetry(fn, options) {
30
+ const opts = { ...defaultRetryOptions, ...options };
31
+ let lastError;
32
+ for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
33
+ try {
34
+ return await fn();
35
+ }
36
+ catch (error) {
37
+ lastError = error instanceof Error ? error : new Error(String(error));
38
+ if (attempt === opts.maxRetries) {
39
+ break;
40
+ }
41
+ const delay = calculateDelay(attempt, opts);
42
+ await plugins.smartdelay.delayFor(delay);
43
+ }
44
+ }
45
+ throw lastError ?? new Error('Retry failed with unknown error');
46
+ }
47
+ /**
48
+ * Creates a retryable version of an async function
49
+ *
50
+ * @param fn - The async function to wrap
51
+ * @param options - Retry configuration options
52
+ * @returns A wrapped function that retries on failure
53
+ */
54
+ export function createRetryable(fn, options) {
55
+ return (...args) => withRetry(() => fn(...args), options);
56
+ }
57
+ /**
58
+ * Retry decorator for class methods
59
+ * Note: Use as a wrapper function since TC39 decorators have different semantics
60
+ */
61
+ export function retryMethod(target, methodName, options) {
62
+ const originalMethod = target[methodName];
63
+ if (typeof originalMethod !== 'function') {
64
+ throw new Error(`${methodName} is not a function`);
65
+ }
66
+ target[methodName] = createRetryable(originalMethod.bind(target), options);
67
+ }
68
+ export { defaultRetryOptions };
69
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5yZXRyeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2hlbHBlcnMvaGVscGVycy5yZXRyeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGVBQWUsQ0FBQztBQUd6QyxNQUFNLG1CQUFtQixHQUE0QjtJQUNuRCxVQUFVLEVBQUUsQ0FBQztJQUNiLFNBQVMsRUFBRSxJQUFJO0lBQ2YsUUFBUSxFQUFFLEtBQUs7SUFDZixVQUFVLEVBQUUsQ0FBQztJQUNiLE1BQU0sRUFBRSxJQUFJO0NBQ2IsQ0FBQztBQUVGOztHQUVHO0FBQ0gsU0FBUyxjQUFjLENBQ3JCLE9BQWUsRUFDZixPQUFnQztJQUVoQyxNQUFNLEtBQUssR0FBRyxJQUFJLENBQUMsR0FBRyxDQUNwQixPQUFPLENBQUMsU0FBUyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLFVBQVUsRUFBRSxPQUFPLENBQUMsRUFDekQsT0FBTyxDQUFDLFFBQVEsQ0FDakIsQ0FBQztJQU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QUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDM0MsQ0FBQztJQUNILENBQUM7SUFFRCxNQUFNLFNBQVMsSUFBSSxJQUFJLEtBQUssQ0FBQyxpQ0FBaUMsQ0FBQyxDQUFDO0FBQ2xFLENBQUM7QUFFRDs7Ozs7O0dBTUc7QUFDSCxNQUFNLFVBQVUsZUFBZSxDQUM3QixFQUF3QyxFQUN4QyxPQUF1QjtJQUV2QixPQUFPLENBQUMsR0FBRyxJQUFXLEVBQUUsRUFBRSxDQUFDLFNBQVMsQ0FBQyxHQUFHLEVBQUUsQ0FBQyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQztBQUNuRSxDQUFDO0FBRUQ7OztHQUdHO0FBQ0gsTUFBTSxVQUFVLFdBQVcsQ0FDekIsTUFBUyxFQUNULFVBQTRCLEVBQzVCLE9BQXVCO0lBRXZCLE1BQU0sY0FBYyxHQUFHLE1BQU0sQ0FBQyxVQUFVLENBQUMsQ0FBQztJQUMxQyxJQUFJLE9BQU8sY0FBYyxLQUFLLFVBQVUsRUFBRSxDQUFDO1FBQ3pDLE1BQU0sSUFBSSxLQUFLLENBQUMsR0FBRyxVQUFVLG9CQUFvQixDQUFDLENBQUM7SUFDckQsQ0FBQztJQUVELE1BQU0sQ0FBQyxVQUFVLENBQUMsR0FBRyxlQUFlLENBQ2xDLGNBQWMsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUE2QyxFQUN2RSxPQUFPLENBQ2dCLENBQUM7QUFDNUIsQ0FBQztBQUVELE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxDQUFDIn0=
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @push.rocks/devicemanager
3
+ * A comprehensive device manager for discovering and communicating with network devices
4
+ * Supports: Scanners, Printers, SNMP devices, UPS, DLNA, Sonos, AirPlay, Chromecast
5
+ */
6
+ export { DeviceManager, MdnsDiscovery, NetworkScanner, SsdpDiscovery, SERVICE_TYPES, SSDP_SERVICE_TYPES, } from './devicemanager.classes.devicemanager.js';
7
+ export { UniversalDevice, type IUniversalDeviceInfo, type IDeviceCreateOptions } from './device/device.classes.device.js';
8
+ export { Feature, ScanFeature, PrintFeature, PlaybackFeature, VolumeFeature, PowerFeature, SnmpFeature, SwitchFeature, SensorFeature, LightFeature, CoverFeature, LockFeature, FanFeature, ClimateFeature, CameraFeature, type TDeviceReference, type IScanFeatureOptions, type IPrintFeatureOptions, type IPlaybackFeatureOptions, type IVolumeFeatureOptions, type IVolumeController, type IPowerFeatureOptions, type ISnmpFeatureOptions, type ISwitchFeatureOptions, type ISensorFeatureOptions, type ILightFeatureOptions, type ICoverFeatureOptions, type ILockFeatureOptions, type IFanFeatureOptions, type IClimateFeatureOptions, type ICameraFeatureOptions, } from './features/index.js';
9
+ export { createScanner, createPrinter, createSnmpDevice, createUpsDevice, createSpeaker, createDlnaRenderer, createSmartSwitch, createSmartSensor, createSmartLight, createSmartCover, createSmartLock, createSmartFan, createSmartClimate, createSmartCamera, type IScannerDiscoveryInfo, type IPrinterDiscoveryInfo, type ISnmpDiscoveryInfo, type IUpsDiscoveryInfo, type ISpeakerDiscoveryInfo, type IDlnaRendererDiscoveryInfo, type ISmartSwitchDiscoveryInfo, type ISmartSensorDiscoveryInfo, type ISmartLightDiscoveryInfo, type ISmartCoverDiscoveryInfo, type ISmartLockDiscoveryInfo, type ISmartFanDiscoveryInfo, type ISmartClimateDiscoveryInfo, type ISmartCameraDiscoveryInfo, } from './factories/index.js';
10
+ export { EsclProtocol, SaneProtocol, IppProtocol, SnmpProtocol, SNMP_OIDS, NutProtocol, NUT_COMMANDS, NUT_VARIABLES, UpnpSoapClient, UPNP_SERVICE_TYPES, UPNP_DEVICE_TYPES, UpsSnmpHandler, UPS_SNMP_OIDS, HomeAssistantProtocol, type ISnmpOptions, type ISnmpVarbind, type TSnmpValueType, type TNutStatusFlag, type INutUpsInfo, type INutVariable, type TDlnaTransportState, type TDlnaTransportStatus, type IDlnaPositionInfo, type IDlnaTransportInfo, type IDlnaMediaInfo, type IDlnaContentItem, type IDlnaBrowseResult, type TUpsBatteryStatus, type TUpsOutputSource, type TUpsTestResult, type IUpsSnmpStatus, } from './protocols/index.js';
11
+ export { HomeAssistantDiscovery, HA_SERVICE_TYPE } from './discovery/discovery.classes.homeassistant.js';
12
+ export { withRetry, createRetryable, defaultRetryOptions } from './helpers/helpers.retry.js';
13
+ export { isValidIp, ipToNumber, numberToIp, ipRangeToIps, cidrToIps, getLocalSubnet, countIpsInCidr, } from './helpers/helpers.iprange.js';
14
+ export * from './interfaces/index.js';
15
+ export type { ISsdpDevice, ISsdpDeviceDescription, ISsdpService, ISsdpIcon, } from './discovery/discovery.classes.ssdp.js';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @push.rocks/devicemanager
3
+ * A comprehensive device manager for discovering and communicating with network devices
4
+ * Supports: Scanners, Printers, SNMP devices, UPS, DLNA, Sonos, AirPlay, Chromecast
5
+ */
6
+ // ============================================================================
7
+ // Core Device Manager
8
+ // ============================================================================
9
+ export { DeviceManager, MdnsDiscovery, NetworkScanner, SsdpDiscovery, SERVICE_TYPES, SSDP_SERVICE_TYPES, } from './devicemanager.classes.devicemanager.js';
10
+ // ============================================================================
11
+ // Universal Device & Features
12
+ // ============================================================================
13
+ export { UniversalDevice } from './device/device.classes.device.js';
14
+ export { Feature, ScanFeature, PrintFeature, PlaybackFeature, VolumeFeature, PowerFeature, SnmpFeature,
15
+ // Smart home features
16
+ SwitchFeature, SensorFeature, LightFeature, CoverFeature, LockFeature, FanFeature, ClimateFeature, CameraFeature, } from './features/index.js';
17
+ // ============================================================================
18
+ // Device Factories
19
+ // ============================================================================
20
+ export { createScanner, createPrinter, createSnmpDevice, createUpsDevice, createSpeaker, createDlnaRenderer,
21
+ // Smart home factories
22
+ createSmartSwitch, createSmartSensor, createSmartLight, createSmartCover, createSmartLock, createSmartFan, createSmartClimate, createSmartCamera, } from './factories/index.js';
23
+ // ============================================================================
24
+ // Protocol Implementations
25
+ // ============================================================================
26
+ export { EsclProtocol, SaneProtocol, IppProtocol, SnmpProtocol, SNMP_OIDS, NutProtocol, NUT_COMMANDS, NUT_VARIABLES, UpnpSoapClient, UPNP_SERVICE_TYPES, UPNP_DEVICE_TYPES, UpsSnmpHandler, UPS_SNMP_OIDS,
27
+ // Home Assistant protocol
28
+ HomeAssistantProtocol, } from './protocols/index.js';
29
+ // Home Assistant Discovery
30
+ export { HomeAssistantDiscovery, HA_SERVICE_TYPE } from './discovery/discovery.classes.homeassistant.js';
31
+ // ============================================================================
32
+ // Helpers
33
+ // ============================================================================
34
+ export { withRetry, createRetryable, defaultRetryOptions } from './helpers/helpers.retry.js';
35
+ export { isValidIp, ipToNumber, numberToIp, ipRangeToIps, cidrToIps, getLocalSubnet, countIpsInCidr, } from './helpers/helpers.iprange.js';
36
+ // ============================================================================
37
+ // All Interfaces and Types
38
+ // ============================================================================
39
+ export * from './interfaces/index.js';
40
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7OztHQUlHO0FBRUgsK0VBQStFO0FBQy9FLHNCQUFzQjtBQUN0QiwrRUFBK0U7QUFFL0UsT0FBTyxFQUNMLGFBQWEsRUFDYixhQUFhLEVBQ2IsY0FBYyxFQUNkLGFBQWEsRUFDYixhQUFhLEVBQ2Isa0JBQWtCLEdBQ25CLE1BQU0sMENBQTBDLENBQUM7QUFFbEQsK0VBQStFO0FBQy9FLDhCQUE4QjtBQUM5QiwrRUFBK0U7QUFFL0UsT0FBTyxFQUFFLGVBQWUsRUFBd0QsTUFBTSxtQ0FBbUMsQ0FBQztBQUMxSCxPQUFPLEVBQ0wsT0FBTyxFQUNQLFdBQVcsRUFDWCxZQUFZLEVBQ1osZUF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FtQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFDN0YsT0FBTyxFQUNMLFNBQVMsRUFDVCxVQUFVLEVBQ1YsVUFBVSxFQUNWLFlBQVksRUFDWixTQUFTLEVBQ1QsY0FBYyxFQUNkLGNBQWMsR0FDZixNQUFNLDhCQUE4QixDQUFDO0FBRXRDLCtFQUErRTtBQUMvRSwyQkFBMkI7QUFDM0IsK0VBQStFO0FBRS9FLGNBQWMsdUJBQXVCLENBQUMifQ==
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Feature Type Definitions
3
+ * Features are composable capabilities that can be attached to devices
4
+ */
5
+ import type { IRetryOptions } from './index.js';
6
+ /**
7
+ * All supported feature types
8
+ */
9
+ export type TFeatureType = 'scan' | 'print' | 'fax' | 'copy' | 'playback' | 'volume' | 'power' | 'snmp' | 'dlna-render' | 'dlna-serve' | 'light' | 'climate' | 'sensor' | 'camera' | 'cover' | 'switch' | 'lock' | 'fan';
10
+ /**
11
+ * Feature connection state
12
+ */
13
+ export type TFeatureState = 'disconnected' | 'connecting' | 'connected' | 'error';
14
+ /**
15
+ * Base interface for all features
16
+ */
17
+ export interface IFeature {
18
+ /** Feature type identifier */
19
+ readonly type: TFeatureType;
20
+ /** Protocol used by this feature */
21
+ readonly protocol: string;
22
+ /** Current feature state */
23
+ readonly state: TFeatureState;
24
+ /** Port used by this feature (may differ from device port) */
25
+ readonly port: number;
26
+ /** Connect to the feature endpoint */
27
+ connect(): Promise<void>;
28
+ /** Disconnect from the feature endpoint */
29
+ disconnect(): Promise<void>;
30
+ }
31
+ /**
32
+ * Feature info for serialization
33
+ */
34
+ export interface IFeatureInfo {
35
+ type: TFeatureType;
36
+ protocol: string;
37
+ port: number;
38
+ state: TFeatureState;
39
+ }
40
+ export type TScanProtocol = 'escl' | 'sane' | 'wia';
41
+ export type TScanFormat = 'png' | 'jpeg' | 'pdf' | 'tiff';
42
+ export type TColorMode = 'color' | 'grayscale' | 'blackwhite';
43
+ export type TScanSource = 'flatbed' | 'adf' | 'adf-duplex';
44
+ export interface IScanCapabilities {
45
+ resolutions: number[];
46
+ formats: TScanFormat[];
47
+ colorModes: TColorMode[];
48
+ sources: TScanSource[];
49
+ maxWidth: number;
50
+ maxHeight: number;
51
+ minWidth: number;
52
+ minHeight: number;
53
+ }
54
+ export interface IScanArea {
55
+ x: number;
56
+ y: number;
57
+ width: number;
58
+ height: number;
59
+ }
60
+ export interface IScanOptions {
61
+ resolution?: number;
62
+ format?: TScanFormat;
63
+ colorMode?: TColorMode;
64
+ source?: TScanSource;
65
+ area?: IScanArea;
66
+ intent?: 'document' | 'photo' | 'preview';
67
+ quality?: number;
68
+ }
69
+ export interface IScanResult {
70
+ data: Buffer;
71
+ format: TScanFormat;
72
+ width: number;
73
+ height: number;
74
+ resolution: number;
75
+ colorMode: TColorMode;
76
+ mimeType: string;
77
+ }
78
+ export interface IScanFeatureInfo extends IFeatureInfo {
79
+ type: 'scan';
80
+ protocol: TScanProtocol;
81
+ supportedFormats: TScanFormat[];
82
+ supportedResolutions: number[];
83
+ supportedColorModes: TColorMode[];
84
+ supportedSources: TScanSource[];
85
+ hasAdf: boolean;
86
+ hasDuplex: boolean;
87
+ }
88
+ export type TPrintProtocol = 'ipp' | 'jetdirect' | 'lpd';
89
+ export type TPrintSides = 'one-sided' | 'two-sided-long-edge' | 'two-sided-short-edge';
90
+ export type TPrintQuality = 'draft' | 'normal' | 'high';
91
+ export type TPrintColorMode = 'color' | 'monochrome';
92
+ export interface IPrintCapabilities {
93
+ colorSupported: boolean;
94
+ duplexSupported: boolean;
95
+ mediaSizes: string[];
96
+ mediaTypes: string[];
97
+ resolutions: number[];
98
+ maxCopies: number;
99
+ sidesSupported: TPrintSides[];
100
+ qualitySupported: TPrintQuality[];
101
+ }
102
+ export interface IPrintOptions {
103
+ copies?: number;
104
+ mediaSize?: string;
105
+ mediaType?: string;
106
+ sides?: TPrintSides;
107
+ quality?: TPrintQuality;
108
+ colorMode?: TPrintColorMode;
109
+ jobName?: string;
110
+ }
111
+ export interface IPrintJob {
112
+ id: number;
113
+ name: string;
114
+ state: 'pending' | 'processing' | 'completed' | 'canceled' | 'aborted';
115
+ stateReason?: string;
116
+ createdAt: Date;
117
+ completedAt?: Date;
118
+ pagesPrinted?: number;
119
+ pagesTotal?: number;
120
+ }
121
+ export interface IPrintFeatureInfo extends IFeatureInfo {
122
+ type: 'print';
123
+ protocol: TPrintProtocol;
124
+ supportsColor: boolean;
125
+ supportsDuplex: boolean;
126
+ supportedMediaSizes: string[];
127
+ }
128
+ export type TPlaybackProtocol = 'sonos' | 'airplay' | 'chromecast' | 'dlna';
129
+ export type TPlaybackState = 'playing' | 'paused' | 'stopped' | 'buffering' | 'unknown';
130
+ export interface ITrackInfo {
131
+ title?: string;
132
+ artist?: string;
133
+ album?: string;
134
+ albumArtUri?: string;
135
+ duration?: number;
136
+ uri?: string;
137
+ }
138
+ export interface IPlaybackStatus {
139
+ state: TPlaybackState;
140
+ position: number;
141
+ duration: number;
142
+ track?: ITrackInfo;
143
+ }
144
+ export interface IPlaybackFeatureInfo extends IFeatureInfo {
145
+ type: 'playback';
146
+ protocol: TPlaybackProtocol;
147
+ supportsQueue: boolean;
148
+ supportsSeek: boolean;
149
+ }
150
+ export interface IVolumeFeatureInfo extends IFeatureInfo {
151
+ type: 'volume';
152
+ minVolume: number;
153
+ maxVolume: number;
154
+ volumeStep: number;
155
+ supportsMute: boolean;
156
+ }
157
+ export type TPowerProtocol = 'nut' | 'snmp' | 'smart-plug';
158
+ export type TPowerStatus = 'online' | 'onbattery' | 'lowbattery' | 'charging' | 'discharging' | 'bypass' | 'offline' | 'error' | 'unknown';
159
+ export interface IBatteryInfo {
160
+ charge: number;
161
+ runtime: number;
162
+ voltage?: number;
163
+ temperature?: number;
164
+ health?: 'good' | 'weak' | 'replace';
165
+ }
166
+ export interface IPowerInfo {
167
+ inputVoltage?: number;
168
+ outputVoltage?: number;
169
+ inputFrequency?: number;
170
+ outputFrequency?: number;
171
+ load?: number;
172
+ power?: number;
173
+ }
174
+ export interface IPowerFeatureInfo extends IFeatureInfo {
175
+ type: 'power';
176
+ protocol: TPowerProtocol;
177
+ hasBattery: boolean;
178
+ supportsShutdown: boolean;
179
+ supportsTest: boolean;
180
+ }
181
+ export type TSnmpVersion = 'v1' | 'v2c' | 'v3';
182
+ export interface ISnmpVarbind {
183
+ oid: string;
184
+ type: number;
185
+ value: unknown;
186
+ }
187
+ export interface ISnmpFeatureInfo extends IFeatureInfo {
188
+ type: 'snmp';
189
+ version: TSnmpVersion;
190
+ community?: string;
191
+ sysDescr?: string;
192
+ sysName?: string;
193
+ sysLocation?: string;
194
+ }
195
+ export interface IDlnaTransportInfo {
196
+ state: 'STOPPED' | 'PLAYING' | 'PAUSED' | 'TRANSITIONING' | 'NO_MEDIA_PRESENT';
197
+ status: string;
198
+ speed: string;
199
+ }
200
+ export interface IDlnaPositionInfo {
201
+ track: number;
202
+ trackDuration: string;
203
+ trackMetaData?: string;
204
+ trackUri?: string;
205
+ relTime: string;
206
+ absTime: string;
207
+ }
208
+ export interface IDlnaRenderFeatureInfo extends IFeatureInfo {
209
+ type: 'dlna-render';
210
+ udn: string;
211
+ friendlyName: string;
212
+ supportsVolume: boolean;
213
+ supportedProtocols: string[];
214
+ }
215
+ export interface IDlnaContentItem {
216
+ id: string;
217
+ parentId: string;
218
+ title: string;
219
+ class: string;
220
+ restricted: boolean;
221
+ uri?: string;
222
+ albumArtUri?: string;
223
+ duration?: string;
224
+ size?: number;
225
+ isContainer: boolean;
226
+ childCount?: number;
227
+ }
228
+ export interface IDlnaBrowseResult {
229
+ items: IDlnaContentItem[];
230
+ numberReturned: number;
231
+ totalMatches: number;
232
+ updateId: number;
233
+ }
234
+ export interface IDlnaServeFeatureInfo extends IFeatureInfo {
235
+ type: 'dlna-serve';
236
+ udn: string;
237
+ friendlyName: string;
238
+ contentCount?: number;
239
+ }
240
+ /**
241
+ * Feature discovered during network scan or mDNS/SSDP
242
+ */
243
+ export interface IDiscoveredFeature {
244
+ type: TFeatureType;
245
+ protocol: string;
246
+ port: number;
247
+ metadata: Record<string, unknown>;
248
+ }
249
+ /**
250
+ * Options for creating a feature instance
251
+ */
252
+ export interface IFeatureOptions {
253
+ retryOptions?: IRetryOptions;
254
+ metadata?: Record<string, unknown>;
255
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Feature Type Definitions
3
+ * Features are composable capabilities that can be attached to devices
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVhdHVyZS5pbnRlcmZhY2VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvaW50ZXJmYWNlcy9mZWF0dXJlLmludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHIn0=