@fastybird/smart-panel-backend 1.1.0-alpha.4 → 1.1.0-alpha.40

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 (404) hide show
  1. package/dist/app.module.js +8 -0
  2. package/dist/app.module.js.map +1 -1
  3. package/dist/dataSource.js +1 -0
  4. package/dist/dataSource.js.map +1 -1
  5. package/dist/migrations/1000000000026-AddHardwareInputCategories.d.ts +7 -0
  6. package/dist/migrations/1000000000026-AddHardwareInputCategories.js +364 -0
  7. package/dist/migrations/1000000000026-AddHardwareInputCategories.js.map +1 -0
  8. package/dist/modules/auth/guards/auth.guard.js +1 -9
  9. package/dist/modules/auth/guards/auth.guard.js.map +1 -1
  10. package/dist/modules/auth/services/tokens.service.d.ts +2 -1
  11. package/dist/modules/auth/services/tokens.service.js +10 -0
  12. package/dist/modules/auth/services/tokens.service.js.map +1 -1
  13. package/dist/modules/devices/controllers/channels.controller.d.ts +5 -1
  14. package/dist/modules/devices/controllers/channels.controller.js +34 -2
  15. package/dist/modules/devices/controllers/channels.controller.js.map +1 -1
  16. package/dist/modules/devices/controllers/channels.properties.controller.js +21 -4
  17. package/dist/modules/devices/controllers/channels.properties.controller.js.map +1 -1
  18. package/dist/modules/devices/controllers/devices.channels.controller.d.ts +5 -1
  19. package/dist/modules/devices/controllers/devices.channels.controller.js +38 -2
  20. package/dist/modules/devices/controllers/devices.channels.controller.js.map +1 -1
  21. package/dist/modules/devices/controllers/devices.channels.properties.controller.js +21 -4
  22. package/dist/modules/devices/controllers/devices.channels.properties.controller.js.map +1 -1
  23. package/dist/modules/devices/devices.constants.d.ts +6 -0
  24. package/dist/modules/devices/devices.constants.js +6 -0
  25. package/dist/modules/devices/devices.constants.js.map +1 -1
  26. package/dist/modules/devices/devices.module.js +20 -0
  27. package/dist/modules/devices/devices.module.js.map +1 -1
  28. package/dist/modules/devices/devices.openapi.d.ts +3 -1
  29. package/dist/modules/devices/devices.openapi.js +7 -0
  30. package/dist/modules/devices/devices.openapi.js.map +1 -1
  31. package/dist/modules/devices/dto/channel-input-occurrence.dto.d.ts +10 -0
  32. package/dist/modules/devices/dto/channel-input-occurrence.dto.js +99 -0
  33. package/dist/modules/devices/dto/channel-input-occurrence.dto.js.map +1 -0
  34. package/dist/modules/devices/models/channel-input-capabilities.model.d.ts +20 -0
  35. package/dist/modules/devices/models/channel-input-capabilities.model.js +111 -0
  36. package/dist/modules/devices/models/channel-input-capabilities.model.js.map +1 -0
  37. package/dist/modules/devices/models/channel-input-occurrence.model.d.ts +22 -0
  38. package/dist/modules/devices/models/channel-input-occurrence.model.js +154 -0
  39. package/dist/modules/devices/models/channel-input-occurrence.model.js.map +1 -0
  40. package/dist/modules/devices/services/channel-input-deduplication.service.d.ts +17 -0
  41. package/dist/modules/devices/services/channel-input-deduplication.service.js +88 -0
  42. package/dist/modules/devices/services/channel-input-deduplication.service.js.map +1 -0
  43. package/dist/modules/devices/services/channel-input-occurrences.service.d.ts +21 -0
  44. package/dist/modules/devices/services/channel-input-occurrences.service.js +163 -0
  45. package/dist/modules/devices/services/channel-input-occurrences.service.js.map +1 -0
  46. package/dist/modules/devices/services/channels.properties.service.d.ts +32 -3
  47. package/dist/modules/devices/services/channels.properties.service.js +360 -51
  48. package/dist/modules/devices/services/channels.properties.service.js.map +1 -1
  49. package/dist/modules/devices/services/channels.service.d.ts +1 -0
  50. package/dist/modules/devices/services/channels.service.js +52 -38
  51. package/dist/modules/devices/services/channels.service.js.map +1 -1
  52. package/dist/modules/devices/services/command-latency-trace-collector.service.d.ts +101 -0
  53. package/dist/modules/devices/services/command-latency-trace-collector.service.js +451 -0
  54. package/dist/modules/devices/services/command-latency-trace-collector.service.js.map +1 -0
  55. package/dist/modules/devices/services/device-structure-lock.service.d.ts +10 -2
  56. package/dist/modules/devices/services/device-structure-lock.service.js +86 -7
  57. package/dist/modules/devices/services/device-structure-lock.service.js.map +1 -1
  58. package/dist/modules/devices/services/devices.service.d.ts +2 -0
  59. package/dist/modules/devices/services/devices.service.js +76 -47
  60. package/dist/modules/devices/services/devices.service.js.map +1 -1
  61. package/dist/modules/devices/services/module-reset.service.d.ts +3 -1
  62. package/dist/modules/devices/services/module-reset.service.js +21 -16
  63. package/dist/modules/devices/services/module-reset.service.js.map +1 -1
  64. package/dist/modules/devices/services/platform.registry.service.d.ts +2 -2
  65. package/dist/modules/devices/services/platform.registry.service.js.map +1 -1
  66. package/dist/modules/devices/services/property-command-dispatch.service.d.ts +45 -0
  67. package/dist/modules/devices/services/property-command-dispatch.service.js +228 -0
  68. package/dist/modules/devices/services/property-command-dispatch.service.js.map +1 -0
  69. package/dist/modules/devices/services/property-command-window.service.d.ts +71 -0
  70. package/dist/modules/devices/services/property-command-window.service.js +206 -0
  71. package/dist/modules/devices/services/property-command-window.service.js.map +1 -0
  72. package/dist/modules/devices/services/property-command.service.d.ts +20 -3
  73. package/dist/modules/devices/services/property-command.service.js +58 -12
  74. package/dist/modules/devices/services/property-command.service.js.map +1 -1
  75. package/dist/modules/devices/services/property-metadata.service.d.ts +31 -0
  76. package/dist/modules/devices/services/property-metadata.service.js +160 -0
  77. package/dist/modules/devices/services/property-metadata.service.js.map +1 -0
  78. package/dist/modules/devices/services/property-state-coordinator.service.d.ts +4 -0
  79. package/dist/modules/devices/services/property-state-coordinator.service.js +35 -0
  80. package/dist/modules/devices/services/property-state-coordinator.service.js.map +1 -0
  81. package/dist/modules/devices/services/property-value-lock.service.d.ts +4 -1
  82. package/dist/modules/devices/services/property-value-lock.service.js +16 -2
  83. package/dist/modules/devices/services/property-value-lock.service.js.map +1 -1
  84. package/dist/modules/devices/services/property-value.service.d.ts +3 -0
  85. package/dist/modules/devices/services/property-value.service.js +29 -5
  86. package/dist/modules/devices/services/property-value.service.js.map +1 -1
  87. package/dist/modules/devices/utils/schema.utils.js +1 -1
  88. package/dist/modules/devices/utils/schema.utils.js.map +1 -1
  89. package/dist/modules/devices/validators/channel-exists-constraint.validator.d.ts +1 -3
  90. package/dist/modules/devices/validators/channel-exists-constraint.validator.js +3 -14
  91. package/dist/modules/devices/validators/channel-exists-constraint.validator.js.map +1 -1
  92. package/dist/modules/devices/validators/channel-property-exists-constraint.validator.d.ts +1 -3
  93. package/dist/modules/devices/validators/channel-property-exists-constraint.validator.js +3 -14
  94. package/dist/modules/devices/validators/channel-property-exists-constraint.validator.js.map +1 -1
  95. package/dist/modules/devices/validators/device-exists-constraint.validator.js +1 -2
  96. package/dist/modules/devices/validators/device-exists-constraint.validator.js.map +1 -1
  97. package/dist/modules/platform/platforms/abstract.platform.d.ts +2 -1
  98. package/dist/modules/platform/platforms/abstract.platform.js +2 -1
  99. package/dist/modules/platform/platforms/abstract.platform.js.map +1 -1
  100. package/dist/modules/platform/platforms/raspberry.platform.js +5 -10
  101. package/dist/modules/platform/platforms/raspberry.platform.js.map +1 -1
  102. package/dist/modules/platform/utils/linux-network-interface.utils.d.ts +3 -0
  103. package/dist/modules/platform/utils/linux-network-interface.utils.js +48 -0
  104. package/dist/modules/platform/utils/linux-network-interface.utils.js.map +1 -0
  105. package/dist/modules/storage/services/storage-write-buffer.d.ts +17 -0
  106. package/dist/modules/storage/services/storage-write-buffer.js +67 -0
  107. package/dist/modules/storage/services/storage-write-buffer.js.map +1 -0
  108. package/dist/modules/storage/services/storage.service.d.ts +9 -2
  109. package/dist/modules/storage/services/storage.service.js +54 -1
  110. package/dist/modules/storage/services/storage.service.js.map +1 -1
  111. package/dist/modules/system/scripts/update-worker.sh +1168 -61
  112. package/dist/modules/system/services/privileged-worker.service.d.ts +3 -0
  113. package/dist/modules/system/services/privileged-worker.service.js +62 -27
  114. package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
  115. package/dist/modules/system/services/system.service.d.ts +2 -0
  116. package/dist/modules/system/services/system.service.js +22 -1
  117. package/dist/modules/system/services/system.service.js.map +1 -1
  118. package/dist/modules/system/services/update-executor.service.d.ts +20 -2
  119. package/dist/modules/system/services/update-executor.service.js +272 -26
  120. package/dist/modules/system/services/update-executor.service.js.map +1 -1
  121. package/dist/modules/websocket/gateway/websocket.gateway.d.ts +4 -1
  122. package/dist/modules/websocket/gateway/websocket.gateway.js +28 -5
  123. package/dist/modules/websocket/gateway/websocket.gateway.js.map +1 -1
  124. package/dist/modules/websocket/services/command-acknowledgement-trace.service.d.ts +143 -0
  125. package/dist/modules/websocket/services/command-acknowledgement-trace.service.js +523 -0
  126. package/dist/modules/websocket/services/command-acknowledgement-trace.service.js.map +1 -0
  127. package/dist/modules/websocket/services/ws-auth.service.js +1 -8
  128. package/dist/modules/websocket/services/ws-auth.service.js.map +1 -1
  129. package/dist/modules/websocket/websocket.module.js +9 -1
  130. package/dist/modules/websocket/websocket.module.js.map +1 -1
  131. package/dist/plugins/devices-home-assistant/devices-home-assistant.openapi.d.ts +2 -2
  132. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.d.ts +6 -1
  133. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js +16 -1
  134. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js.map +1 -1
  135. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.d.ts +1 -0
  136. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js +11 -0
  137. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js.map +1 -1
  138. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.d.ts +19 -0
  139. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js +51 -0
  140. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js.map +1 -0
  141. package/dist/plugins/devices-home-assistant/mappings/definitions/entity-mappings.yaml +56 -7
  142. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.d.ts +1 -0
  143. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js +11 -0
  144. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js.map +1 -1
  145. package/dist/plugins/devices-home-assistant/services/device-adoption.service.js +17 -0
  146. package/dist/plugins/devices-home-assistant/services/device-adoption.service.js.map +1 -1
  147. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.d.ts +27 -0
  148. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js +271 -0
  149. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js.map +1 -0
  150. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.d.ts +2 -2
  151. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +33 -14
  152. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
  153. package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js +24 -4
  154. package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js.map +1 -1
  155. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.d.ts +4 -1
  156. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js +84 -5
  157. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js.map +1 -1
  158. package/dist/plugins/devices-home-assistant/services/wizard.service.js +1 -0
  159. package/dist/plugins/devices-home-assistant/services/wizard.service.js.map +1 -1
  160. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.d.ts +2 -0
  161. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js +50 -0
  162. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js.map +1 -0
  163. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.d.ts +4 -1
  164. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +39 -4
  165. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -1
  166. package/dist/plugins/devices-homekit/mappers/base.mapper.js +30 -6
  167. package/dist/plugins/devices-homekit/mappers/base.mapper.js.map +1 -1
  168. package/dist/plugins/devices-homekit/mappers/button.mapper.d.ts +15 -0
  169. package/dist/plugins/devices-homekit/mappers/button.mapper.js +143 -0
  170. package/dist/plugins/devices-homekit/mappers/button.mapper.js.map +1 -0
  171. package/dist/plugins/devices-homekit/mappers/characteristic-write.d.ts +2 -0
  172. package/dist/plugins/devices-homekit/mappers/characteristic-write.js +17 -0
  173. package/dist/plugins/devices-homekit/mappers/characteristic-write.js.map +1 -0
  174. package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +17 -1
  175. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.d.ts +7 -0
  176. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +96 -84
  177. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js.map +1 -1
  178. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.d.ts +5 -1
  179. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js +42 -0
  180. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js.map +1 -1
  181. package/dist/plugins/devices-homey/mappings/definitions/channels.yaml +50 -0
  182. package/dist/plugins/devices-homey/mappings/definitions/devices.yaml +18 -0
  183. package/dist/plugins/devices-homey/mappings/definitions/properties.yaml +55 -0
  184. package/dist/plugins/devices-homey/mappings/device-support.js +10 -0
  185. package/dist/plugins/devices-homey/mappings/device-support.js.map +1 -1
  186. package/dist/plugins/devices-homey/mappings/mapping-loader.service.d.ts +1 -0
  187. package/dist/plugins/devices-homey/mappings/mapping-loader.service.js +66 -8
  188. package/dist/plugins/devices-homey/mappings/mapping-loader.service.js.map +1 -1
  189. package/dist/plugins/devices-homey/models/inventory.model.d.ts +2 -1
  190. package/dist/plugins/devices-homey/models/inventory.model.js +1 -0
  191. package/dist/plugins/devices-homey/models/inventory.model.js.map +1 -1
  192. package/dist/plugins/devices-homey/models/mapping-preview.model.d.ts +1 -0
  193. package/dist/plugins/devices-homey/models/mapping-preview.model.js +1 -0
  194. package/dist/plugins/devices-homey/models/mapping-preview.model.js.map +1 -1
  195. package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js +7 -0
  196. package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js.map +1 -1
  197. package/dist/plugins/devices-homey/services/homey-synchronizer.service.d.ts +3 -1
  198. package/dist/plugins/devices-homey/services/homey-synchronizer.service.js +37 -6
  199. package/dist/plugins/devices-homey/services/homey-synchronizer.service.js.map +1 -1
  200. package/dist/plugins/devices-reterminal/services/reterminal-button.service.d.ts +7 -3
  201. package/dist/plugins/devices-reterminal/services/reterminal-button.service.js +63 -17
  202. package/dist/plugins/devices-reterminal/services/reterminal-button.service.js.map +1 -1
  203. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +36 -3
  204. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +707 -42
  205. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
  206. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +11 -1
  207. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +100 -10
  208. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
  209. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +3 -2
  210. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
  211. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js +2 -0
  212. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js.map +1 -1
  213. package/dist/plugins/devices-shelly-ng/mappings/definitions/inputs.yaml +80 -0
  214. package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js +7 -1
  215. package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js.map +1 -1
  216. package/dist/plugins/devices-shelly-ng/mappings/mapping.types.d.ts +6 -3
  217. package/dist/plugins/devices-shelly-ng/mappings/schema/mapping-schema.json +5 -0
  218. package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +153 -8
  219. package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
  220. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.d.ts +51 -0
  221. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js +549 -0
  222. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js.map +1 -0
  223. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.d.ts +15 -2
  224. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +140 -35
  225. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js.map +1 -1
  226. package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js +3 -0
  227. package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js.map +1 -1
  228. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.d.ts +1 -0
  229. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +14 -4
  230. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js.map +1 -1
  231. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.d.ts +2 -0
  232. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js +66 -4
  233. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js.map +1 -1
  234. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js +2 -0
  235. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js.map +1 -1
  236. package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js +7 -0
  237. package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js.map +1 -1
  238. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.d.ts +3 -1
  239. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js +20 -2
  240. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js.map +1 -1
  241. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.d.ts +16 -0
  242. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js +107 -0
  243. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js.map +1 -0
  244. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.d.ts +7 -1
  245. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js +98 -3
  246. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js.map +1 -1
  247. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.d.ts +17 -0
  248. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js +205 -0
  249. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js.map +1 -0
  250. package/dist/plugins/devices-third-party/devices-third-party.openapi.d.ts +1 -1
  251. package/dist/plugins/devices-third-party/devices-third-party.plugin.js +2 -1
  252. package/dist/plugins/devices-third-party/devices-third-party.plugin.js.map +1 -1
  253. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.d.ts +5 -0
  254. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js +50 -0
  255. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js.map +1 -0
  256. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.d.ts +8 -0
  257. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js +81 -0
  258. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js.map +1 -0
  259. package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js +19 -4
  260. package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js.map +1 -1
  261. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.d.ts +2 -0
  262. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js +57 -0
  263. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js.map +1 -1
  264. package/dist/plugins/devices-virtual/platforms/virtual-device.platform.js +8 -3
  265. package/dist/plugins/devices-virtual/platforms/virtual-device.platform.js.map +1 -1
  266. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.d.ts +3 -0
  267. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js +41 -5
  268. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js.map +1 -1
  269. package/dist/plugins/devices-zigbee2mqtt/interfaces/zigbee2mqtt.interface.d.ts +7 -1
  270. package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js +16 -15
  271. package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js.map +1 -1
  272. package/dist/plugins/devices-zigbee2mqtt/mappings/definitions/remotes.yaml +505 -74
  273. package/dist/plugins/devices-zigbee2mqtt/mappings/schema/mapping-schema.json +3 -3
  274. package/dist/plugins/devices-zigbee2mqtt/mappings/transformers/transformer.types.d.ts +1 -1
  275. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.d.ts +8 -2
  276. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js +6 -5
  277. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js.map +1 -1
  278. package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js +18 -11
  279. package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js.map +1 -1
  280. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.d.ts +9 -3
  281. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js +166 -3
  282. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js.map +1 -1
  283. package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js +5 -2
  284. package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js.map +1 -1
  285. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.d.ts +1 -0
  286. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js +44 -4
  287. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js.map +1 -1
  288. package/dist/plugins/influx-v1/services/influx-v1-managed.service.js +2 -2
  289. package/dist/plugins/influx-v1/services/influx-v1-managed.service.js.map +1 -1
  290. package/dist/plugins/influx-v2/services/influx-v2-managed.service.js +2 -2
  291. package/dist/plugins/influx-v2/services/influx-v2-managed.service.js.map +1 -1
  292. package/dist/plugins/memory-storage/services/memory-storage-managed.service.js +2 -2
  293. package/dist/plugins/memory-storage/services/memory-storage-managed.service.js.map +1 -1
  294. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.d.ts +17 -0
  295. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js +147 -0
  296. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js.map +1 -0
  297. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.d.ts +15 -0
  298. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js +98 -0
  299. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js.map +1 -0
  300. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.d.ts +9 -0
  301. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js +94 -0
  302. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js.map +1 -0
  303. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.d.ts +9 -0
  304. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js +92 -0
  305. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js.map +1 -0
  306. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.d.ts +7 -0
  307. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js +48 -0
  308. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js.map +1 -0
  309. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.d.ts +42 -0
  310. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js +352 -0
  311. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js.map +1 -0
  312. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.d.ts +24 -0
  313. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js +27 -0
  314. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js.map +1 -0
  315. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.d.ts +8 -0
  316. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js +19 -0
  317. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js.map +1 -0
  318. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.d.ts +4 -0
  319. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js +20 -0
  320. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js.map +1 -0
  321. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.d.ts +21 -0
  322. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js +135 -0
  323. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js.map +1 -0
  324. package/dist/plugins/remote-access-cloudflare-tunnel/scripts/cloudflared-setup.sh +185 -0
  325. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.d.ts +82 -0
  326. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js +507 -0
  327. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js.map +1 -0
  328. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.d.ts +10 -0
  329. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js +37 -0
  330. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js.map +1 -0
  331. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.d.ts +38 -0
  332. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js +147 -0
  333. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js.map +1 -0
  334. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.d.ts +15 -0
  335. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js +67 -0
  336. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js.map +1 -0
  337. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.d.ts +8 -0
  338. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js +46 -0
  339. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js.map +1 -0
  340. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.d.ts +27 -0
  341. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js +139 -0
  342. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js.map +1 -0
  343. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.d.ts +3 -0
  344. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js +4 -1
  345. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js.map +1 -1
  346. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +4 -0
  347. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
  348. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +5 -1
  349. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +76 -6
  350. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
  351. package/dist/plugins/scenes-local/platforms/local-scene.platform.d.ts +3 -1
  352. package/dist/plugins/scenes-local/platforms/local-scene.platform.js +12 -7
  353. package/dist/plugins/scenes-local/platforms/local-scene.platform.js.map +1 -1
  354. package/dist/plugins/simulator/controllers/simulator.controller.d.ts +8 -2
  355. package/dist/plugins/simulator/controllers/simulator.controller.js +102 -2
  356. package/dist/plugins/simulator/controllers/simulator.controller.js.map +1 -1
  357. package/dist/plugins/simulator/dto/simulate-occurrence.dto.d.ts +12 -0
  358. package/dist/plugins/simulator/dto/simulate-occurrence.dto.js +122 -0
  359. package/dist/plugins/simulator/dto/simulate-occurrence.dto.js.map +1 -0
  360. package/dist/plugins/simulator/models/simulator-response.model.d.ts +12 -0
  361. package/dist/plugins/simulator/models/simulator-response.model.js +84 -1
  362. package/dist/plugins/simulator/models/simulator-response.model.js.map +1 -1
  363. package/dist/plugins/simulator/scenarios/definitions/small-apartment.yaml +78 -0
  364. package/dist/plugins/simulator/services/scenario-executor.service.js +3 -1
  365. package/dist/plugins/simulator/services/scenario-executor.service.js.map +1 -1
  366. package/dist/plugins/simulator/services/simulation.service.js +10 -1
  367. package/dist/plugins/simulator/services/simulation.service.js.map +1 -1
  368. package/dist/plugins/simulator/simulator.openapi.d.ts +3 -2
  369. package/dist/plugins/simulator/simulator.openapi.js +5 -0
  370. package/dist/plugins/simulator/simulator.openapi.js.map +1 -1
  371. package/dist/plugins/simulator/simulators/device-simulator.interface.d.ts +2 -0
  372. package/dist/plugins/simulator/simulators/device-simulator.interface.js +83 -0
  373. package/dist/plugins/simulator/simulators/device-simulator.interface.js.map +1 -1
  374. package/dist/plugins/simulator/simulators/index.d.ts +1 -0
  375. package/dist/plugins/simulator/simulators/index.js +1 -0
  376. package/dist/plugins/simulator/simulators/index.js.map +1 -1
  377. package/dist/plugins/simulator/simulators/input-controller.simulator.d.ts +10 -0
  378. package/dist/plugins/simulator/simulators/input-controller.simulator.js +57 -0
  379. package/dist/plugins/simulator/simulators/input-controller.simulator.js.map +1 -0
  380. package/dist/plugins/simulator/simulators/lighting.simulator.js +1 -0
  381. package/dist/plugins/simulator/simulators/lighting.simulator.js.map +1 -1
  382. package/dist/plugins/spaces-home-control/services/climate-intent.service.d.ts +3 -1
  383. package/dist/plugins/spaces-home-control/services/climate-intent.service.js +6 -3
  384. package/dist/plugins/spaces-home-control/services/climate-intent.service.js.map +1 -1
  385. package/dist/plugins/spaces-home-control/services/covers-intent.service.d.ts +3 -1
  386. package/dist/plugins/spaces-home-control/services/covers-intent.service.js +6 -3
  387. package/dist/plugins/spaces-home-control/services/covers-intent.service.js.map +1 -1
  388. package/dist/plugins/spaces-home-control/services/lighting-intent.service.d.ts +3 -1
  389. package/dist/plugins/spaces-home-control/services/lighting-intent.service.js +7 -4
  390. package/dist/plugins/spaces-home-control/services/lighting-intent.service.js.map +1 -1
  391. package/dist/plugins/spaces-home-control/services/space-media-activity.service.d.ts +3 -1
  392. package/dist/plugins/spaces-home-control/services/space-media-activity.service.js +11 -5
  393. package/dist/plugins/spaces-home-control/services/space-media-activity.service.js.map +1 -1
  394. package/dist/plugins/spaces-home-control/services/space-undo-history.service.d.ts +3 -1
  395. package/dist/plugins/spaces-home-control/services/space-undo-history.service.js +8 -5
  396. package/dist/plugins/spaces-home-control/services/space-undo-history.service.js.map +1 -1
  397. package/dist/spec/channels.d.ts +51 -1
  398. package/dist/spec/channels.js +64 -1
  399. package/dist/spec/channels.js.map +1 -1
  400. package/dist/spec/devices.d.ts +155 -2
  401. package/dist/spec/devices.js +161 -2
  402. package/dist/spec/devices.js.map +1 -1
  403. package/dist/tsconfig.build.tsbuildinfo +1 -1
  404. package/package.json +3 -3
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PropertyCommandDispatchService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const devices_constants_1 = require("../devices.constants");
18
+ const property_value_state_model_1 = require("../models/property-value-state.model");
19
+ const property_command_value_utils_1 = require("../utils/property-command-value.utils");
20
+ const channels_properties_service_1 = require("./channels.properties.service");
21
+ const channels_service_1 = require("./channels.service");
22
+ const command_latency_trace_collector_service_1 = require("./command-latency-trace-collector.service");
23
+ const device_structure_lock_service_1 = require("./device-structure-lock.service");
24
+ const devices_service_1 = require("./devices.service");
25
+ const platform_registry_service_1 = require("./platform.registry.service");
26
+ const property_command_window_service_1 = require("./property-command-window.service");
27
+ const property_state_coordinator_service_1 = require("./property-state-coordinator.service");
28
+ const property_value_source_registry_service_1 = require("./property-value-source.registry.service");
29
+ let PropertyCommandDispatchService = class PropertyCommandDispatchService {
30
+ constructor(channelsPropertiesService, channelsService, devicesService, platformRegistryService, valueSourceRegistry, structureLock, propertyStateCoordinator, commandWindowService, commandLatencyTraceCollector = new command_latency_trace_collector_service_1.CommandLatencyTraceCollectorService()) {
31
+ this.channelsPropertiesService = channelsPropertiesService;
32
+ this.channelsService = channelsService;
33
+ this.devicesService = devicesService;
34
+ this.platformRegistryService = platformRegistryService;
35
+ this.valueSourceRegistry = valueSourceRegistry;
36
+ this.structureLock = structureLock;
37
+ this.propertyStateCoordinator = propertyStateCoordinator;
38
+ this.commandWindowService = commandWindowService;
39
+ this.commandLatencyTraceCollector = commandLatencyTraceCollector;
40
+ }
41
+ async dispatchBatch(updates, options = {}) {
42
+ if (updates.length === 0) {
43
+ return { success: true };
44
+ }
45
+ const platform = this.platformRegistryService.get(updates[0].device);
46
+ if (platform === null) {
47
+ return { success: false, reason: 'Unsupported device type' };
48
+ }
49
+ const handles = options.windowHandles ?? (await this.admitWindows(updates, options))?.map(({ handle }) => handle);
50
+ if (handles === undefined) {
51
+ return { success: false, reason: 'Canonical property target is invalid or conflicts within the batch' };
52
+ }
53
+ if (options.windowHandles !== undefined && !(await this.verifyPreopenedWindows(updates, handles))) {
54
+ this.failOwned(handles);
55
+ return { success: false, reason: 'Canonical property target changed before dispatch' };
56
+ }
57
+ try {
58
+ const success = await platform.processBatch([...updates]);
59
+ if (!success) {
60
+ this.failOwned(handles);
61
+ return { success: false, reason: 'Execution failed' };
62
+ }
63
+ return { success: true };
64
+ }
65
+ catch (error) {
66
+ this.failOwned(handles);
67
+ throw error;
68
+ }
69
+ }
70
+ async prepareApiCommand(update, ttlMs) {
71
+ const admitted = await this.admitWindows([update], { ttlMs });
72
+ const first = admitted?.[0];
73
+ if (first === undefined) {
74
+ return null;
75
+ }
76
+ return {
77
+ handle: first.handle,
78
+ canonicalPropertyId: first.admission.canonicalPropertyId,
79
+ baseline: first.admission.baseline,
80
+ optimisticEligible: first.admission.canonicalPropertyId === update.property.id && first.admission.baseline !== null,
81
+ };
82
+ }
83
+ async admitWindows(updates, options) {
84
+ return this.structureLock.runShared(async () => {
85
+ const requestedByCanonical = new Map();
86
+ for (const update of updates) {
87
+ const canonicalPropertyId = this.valueSourceRegistry.resolve(update.property);
88
+ const requested = requestedByCanonical.get(canonicalPropertyId) ?? [];
89
+ requested.push(update);
90
+ requestedByCanonical.set(canonicalPropertyId, requested);
91
+ }
92
+ const admitted = [];
93
+ for (const [canonicalPropertyId, requestedUpdates] of requestedByCanonical) {
94
+ const admission = await this.propertyStateCoordinator.run(canonicalPropertyId, async () => this.createAdmission(canonicalPropertyId, requestedUpdates));
95
+ if (admission === null) {
96
+ this.failOwned(admitted.map(({ handle }) => handle));
97
+ return null;
98
+ }
99
+ if (!admission.eligible) {
100
+ continue;
101
+ }
102
+ const handle = this.commandWindowService.open({
103
+ canonicalTarget: admission.canonicalTarget,
104
+ requestedTargets: admission.requestedTargets,
105
+ intentId: options.intentId,
106
+ commandedValue: admission.commandedValue,
107
+ previousValue: admission.previousValue,
108
+ ttlMs: options.ttlMs ?? 3_000,
109
+ });
110
+ this.commandLatencyTraceCollector.bindWindow(options.intentId, admission.canonicalPropertyId, handle.generation);
111
+ admitted.push({
112
+ handle,
113
+ admission,
114
+ });
115
+ }
116
+ return admitted;
117
+ });
118
+ }
119
+ async createAdmission(canonicalPropertyId, requestedUpdates) {
120
+ const first = requestedUpdates[0];
121
+ if (first === undefined) {
122
+ return null;
123
+ }
124
+ for (const requested of requestedUpdates) {
125
+ const currentRequested = await this.channelsPropertiesService.findOne(requested.property.id);
126
+ if (currentRequested === null || this.valueSourceRegistry.resolve(currentRequested) !== canonicalPropertyId) {
127
+ return null;
128
+ }
129
+ }
130
+ const sourceProperty = await this.channelsPropertiesService.findOne(canonicalPropertyId);
131
+ if (sourceProperty === null || this.valueSourceRegistry.resolve(sourceProperty) !== sourceProperty.id) {
132
+ return null;
133
+ }
134
+ const sourceChannel = typeof sourceProperty.channel === 'string'
135
+ ? await this.channelsService.findOne(sourceProperty.channel)
136
+ : (sourceProperty.channel ?? null);
137
+ const sourceDevice = typeof sourceChannel?.device === 'string'
138
+ ? await this.devicesService.findOne(sourceChannel.device)
139
+ : (sourceChannel?.device ?? null);
140
+ if (sourceChannel === null || sourceDevice === null) {
141
+ return null;
142
+ }
143
+ let commandedValue;
144
+ for (const requested of requestedUpdates) {
145
+ const validation = (0, property_command_value_utils_1.validatePropertyCommandValue)(sourceProperty, requested.value);
146
+ if (!validation.valid || validation.value === undefined) {
147
+ return null;
148
+ }
149
+ if (commandedValue !== undefined && commandedValue !== validation.value) {
150
+ return null;
151
+ }
152
+ commandedValue = validation.value;
153
+ }
154
+ if (commandedValue === undefined) {
155
+ return null;
156
+ }
157
+ const requestedTargets = requestedUpdates.map(toTarget);
158
+ const canonicalTarget = toTarget({ device: sourceDevice, channel: sourceChannel, property: sourceProperty });
159
+ const writable = sourceProperty.permissions.includes(devices_constants_1.PermissionType.READ_WRITE);
160
+ const authoritative = this.platformRegistryService.usesAuthoritativePropertyReadback(sourceDevice, sourceProperty);
161
+ return {
162
+ canonicalPropertyId,
163
+ canonicalTarget,
164
+ requestedTargets,
165
+ commandedValue,
166
+ previousValue: sourceProperty.value?.value ?? null,
167
+ baseline: sourceProperty.value === null
168
+ ? null
169
+ : new property_value_state_model_1.PropertyValueState(sourceProperty.value.value, sourceProperty.value.lastUpdated, sourceProperty.value.trend),
170
+ eligible: writable && !authoritative,
171
+ };
172
+ }
173
+ async verifyPreopenedWindows(updates, handles) {
174
+ return this.structureLock.runShared(async () => {
175
+ const requestedByCanonical = new Map();
176
+ for (const update of updates) {
177
+ const current = await this.channelsPropertiesService.findOne(update.property.id);
178
+ if (current === null) {
179
+ return false;
180
+ }
181
+ const canonicalPropertyId = this.valueSourceRegistry.resolve(current);
182
+ const requested = requestedByCanonical.get(canonicalPropertyId) ?? [];
183
+ requested.push({ ...update, property: current });
184
+ requestedByCanonical.set(canonicalPropertyId, requested);
185
+ }
186
+ if (requestedByCanonical.size !== handles.length) {
187
+ return false;
188
+ }
189
+ for (const [canonicalPropertyId, requestedUpdates] of requestedByCanonical) {
190
+ const handle = handles.find((candidate) => candidate.canonicalPropertyId === canonicalPropertyId);
191
+ if (handle === undefined) {
192
+ return false;
193
+ }
194
+ const admission = await this.propertyStateCoordinator.run(canonicalPropertyId, async () => this.createAdmission(canonicalPropertyId, requestedUpdates));
195
+ const window = this.commandWindowService.get(canonicalPropertyId);
196
+ if (admission === null || !admission.eligible || window === null || window.generation !== handle.generation) {
197
+ return false;
198
+ }
199
+ }
200
+ return true;
201
+ });
202
+ }
203
+ failOwned(handles) {
204
+ for (const handle of handles) {
205
+ this.commandWindowService.fail(handle);
206
+ }
207
+ }
208
+ };
209
+ exports.PropertyCommandDispatchService = PropertyCommandDispatchService;
210
+ exports.PropertyCommandDispatchService = PropertyCommandDispatchService = __decorate([
211
+ (0, common_1.Injectable)(),
212
+ __param(8, (0, common_1.Optional)()),
213
+ __metadata("design:paramtypes", [channels_properties_service_1.ChannelsPropertiesService,
214
+ channels_service_1.ChannelsService,
215
+ devices_service_1.DevicesService,
216
+ platform_registry_service_1.PlatformRegistryService,
217
+ property_value_source_registry_service_1.PropertyValueSourceRegistryService,
218
+ device_structure_lock_service_1.DeviceStructureLockService,
219
+ property_state_coordinator_service_1.PropertyStateCoordinatorService,
220
+ property_command_window_service_1.PropertyCommandWindowService,
221
+ command_latency_trace_collector_service_1.CommandLatencyTraceCollectorService])
222
+ ], PropertyCommandDispatchService);
223
+ const toTarget = ({ device, channel, property, }) => ({
224
+ deviceId: device.id,
225
+ channelId: channel.id,
226
+ propertyId: property.id,
227
+ });
228
+ //# sourceMappingURL=property-command-dispatch.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-command-dispatch.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/property-command-dispatch.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AAEtD,4DAAsD;AACtD,qFAA0E;AAE1E,wFAA2G;AAE3G,+EAA0E;AAC1E,yDAAqD;AACrD,uGAAgG;AAChG,mFAA6E;AAC7E,uDAAmD;AACnD,2EAAsE;AACtE,uFAI2C;AAC3C,6FAAuF;AACvF,qGAA8F;AA6CvF,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC1C,YACkB,yBAAoD,EACpD,eAAgC,EAChC,cAA8B,EAC9B,uBAAgD,EAChD,mBAAuD,EACvD,aAAyC,EACzC,wBAAyD,EACzD,oBAAkD,EAElD,+BAAoE,IAAI,6EAAmC,EAAE;QAT7G,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,oBAAe,GAAf,eAAe,CAAiB;QAChC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,wBAAmB,GAAnB,mBAAmB,CAAoC;QACvD,kBAAa,GAAb,aAAa,CAA4B;QACzC,6BAAwB,GAAxB,wBAAwB,CAAiC;QACzD,yBAAoB,GAApB,oB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AAQ,GACsD,EAA+B,EAAE,CAAC,CAAC;IACjG,QAAQ,EAAE,MAAM,CAAC,EAAE;IACnB,SAAS,EAAE,OAAO,CAAC,EAAE;IACrB,UAAU,EAAE,QAAQ,CAAC,EAAE;CACvB,CAAC,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { PropertyValueState } from '../models/property-value-state.model';
2
+ import { PropertyCommandValue } from '../utils/property-command-value.utils';
3
+ export declare const PROPERTY_COMMAND_CONFIRMATION_GRACE_MS = 1500;
4
+ export type PropertyCommandWindowState = 'pending' | 'confirmed_grace';
5
+ export interface PropertyCommandWindowTarget {
6
+ readonly deviceId: string;
7
+ readonly channelId: string;
8
+ readonly propertyId: string;
9
+ }
10
+ export interface PropertyCommandWindowHandle {
11
+ readonly canonicalPropertyId: string;
12
+ readonly generation: string;
13
+ }
14
+ export interface PropertyCommandReceipt {
15
+ readonly value: PropertyCommandValue;
16
+ readonly receivedAt: number;
17
+ }
18
+ export interface PropertyCommandPatchReceipt {
19
+ readonly baseline: PropertyValueState;
20
+ readonly optimisticState: PropertyValueState;
21
+ }
22
+ export interface PropertyCommandWindow {
23
+ readonly canonicalTarget: PropertyCommandWindowTarget;
24
+ readonly requestedTargets: readonly PropertyCommandWindowTarget[];
25
+ readonly generation: string;
26
+ readonly intentId: string | null;
27
+ readonly commandedValue: PropertyCommandValue;
28
+ readonly previousValue: PropertyCommandValue | null;
29
+ readonly lastReceipt: PropertyCommandReceipt | null;
30
+ readonly heldReceipt: PropertyCommandReceipt | null;
31
+ readonly recoveryReceipt: PropertyCommandReceipt | null;
32
+ readonly rollbackBaseline: PropertyValueState | null;
33
+ readonly patchReceipt: PropertyCommandPatchReceipt | null;
34
+ readonly openedAt: number;
35
+ readonly expiresAt: number;
36
+ readonly state: PropertyCommandWindowState;
37
+ readonly confirmedAt: number | null;
38
+ readonly confirmationExpiresAt: number | null;
39
+ }
40
+ export interface OpenPropertyCommandWindowInput {
41
+ readonly canonicalTarget: PropertyCommandWindowTarget;
42
+ readonly requestedTargets: readonly PropertyCommandWindowTarget[];
43
+ readonly intentId?: string;
44
+ readonly commandedValue: PropertyCommandValue;
45
+ readonly previousValue: PropertyCommandValue | null;
46
+ readonly ttlMs: number;
47
+ }
48
+ export declare class PropertyCommandWindowService {
49
+ private readonly windows;
50
+ private readonly recoveries;
51
+ open(input: OpenPropertyCommandWindowInput): PropertyCommandWindowHandle;
52
+ get(canonicalPropertyId: string): PropertyCommandWindow | null;
53
+ peekGeneration(canonicalPropertyId: string): string | undefined;
54
+ confirm(handle: PropertyCommandWindowHandle, receipt: PropertyCommandReceipt): PropertyCommandWindow | null;
55
+ attachPatchReceipt(handle: PropertyCommandWindowHandle, receipt: PropertyCommandPatchReceipt): boolean;
56
+ hold(handle: PropertyCommandWindowHandle, receipt: PropertyCommandReceipt): PropertyCommandWindow | null;
57
+ close(handle: PropertyCommandWindowHandle): boolean;
58
+ fail(handle: PropertyCommandWindowHandle): boolean;
59
+ sweep(): readonly PropertyCommandWindowHandle[];
60
+ expire(canonicalPropertyId: string): PropertyCommandWindowHandle | null;
61
+ getRecovery(handle: PropertyCommandWindowHandle): PropertyCommandWindow | null;
62
+ completeRecovery(handle: PropertyCommandWindowHandle): boolean;
63
+ cancelRecovery(canonicalPropertyId: string): boolean;
64
+ cancel(canonicalPropertyId: string): void;
65
+ clear(): void;
66
+ private getCurrent;
67
+ private isExpired;
68
+ private detach;
69
+ private pruneRecoveries;
70
+ private toSnapshot;
71
+ }
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PropertyCommandWindowService = exports.PROPERTY_COMMAND_CONFIRMATION_GRACE_MS = void 0;
10
+ const node_crypto_1 = require("node:crypto");
11
+ const common_1 = require("@nestjs/common");
12
+ const property_value_state_model_1 = require("../models/property-value-state.model");
13
+ exports.PROPERTY_COMMAND_CONFIRMATION_GRACE_MS = 1_500;
14
+ let PropertyCommandWindowService = class PropertyCommandWindowService {
15
+ constructor() {
16
+ this.windows = new Map();
17
+ this.recoveries = new Map();
18
+ }
19
+ open(input) {
20
+ const now = Date.now();
21
+ const canonicalPropertyId = input.canonicalTarget.propertyId;
22
+ const current = this.getCurrent(canonicalPropertyId, now);
23
+ const ttlMs = Number.isFinite(input.ttlMs) && input.ttlMs > 0 ? input.ttlMs : 3_000;
24
+ const generation = (0, node_crypto_1.randomUUID)();
25
+ const previousValue = current?.commandedValue ?? input.previousValue;
26
+ this.recoveries.delete(canonicalPropertyId);
27
+ this.windows.set(canonicalPropertyId, {
28
+ canonicalTarget: freezeTarget(input.canonicalTarget),
29
+ requestedTargets: input.requestedTargets.map(freezeTarget),
30
+ generation,
31
+ intentId: input.intentId ?? null,
32
+ commandedValue: input.commandedValue,
33
+ previousValue,
34
+ lastReceipt: null,
35
+ heldReceipt: null,
36
+ recoveryReceipt: null,
37
+ rollbackBaseline: current?.rollbackBaseline ?? current?.patchReceipt?.baseline ?? null,
38
+ patchReceipt: null,
39
+ openedAt: now,
40
+ expiresAt: now + ttlMs,
41
+ state: 'pending',
42
+ confirmedAt: null,
43
+ confirmationExpiresAt: null,
44
+ });
45
+ return Object.freeze({ canonicalPropertyId, generation });
46
+ }
47
+ get(canonicalPropertyId) {
48
+ return this.toSnapshot(this.getCurrent(canonicalPropertyId, Date.now()));
49
+ }
50
+ peekGeneration(canonicalPropertyId) {
51
+ const current = this.windows.get(canonicalPropertyId);
52
+ return current !== undefined && current.expiresAt > Date.now() ? current.generation : undefined;
53
+ }
54
+ confirm(handle, receipt) {
55
+ const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
56
+ if (current === undefined || current.generation !== handle.generation) {
57
+ return null;
58
+ }
59
+ if (current.state === 'pending') {
60
+ current.state = 'confirmed_grace';
61
+ current.confirmedAt = receipt.receivedAt;
62
+ current.confirmationExpiresAt = receipt.receivedAt + exports.PROPERTY_COMMAND_CONFIRMATION_GRACE_MS;
63
+ current.lastReceipt = freezeReceipt(receipt);
64
+ current.heldReceipt = null;
65
+ current.rollbackBaseline = null;
66
+ current.patchReceipt = null;
67
+ }
68
+ return this.toSnapshot(current);
69
+ }
70
+ attachPatchReceipt(handle, receipt) {
71
+ const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
72
+ if (current === undefined || current.generation !== handle.generation || current.state !== 'pending') {
73
+ return false;
74
+ }
75
+ const baseline = current.rollbackBaseline ?? receipt.baseline;
76
+ current.rollbackBaseline = freezeValueState(baseline);
77
+ current.patchReceipt = freezePatchReceipt({
78
+ baseline,
79
+ optimisticState: receipt.optimisticState,
80
+ });
81
+ return true;
82
+ }
83
+ hold(handle, receipt) {
84
+ const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
85
+ if (current === undefined || current.generation !== handle.generation || current.state !== 'pending') {
86
+ return null;
87
+ }
88
+ current.heldReceipt = freezeReceipt(receipt);
89
+ return this.toSnapshot(current);
90
+ }
91
+ close(handle) {
92
+ const current = this.windows.get(handle.canonicalPropertyId);
93
+ if (current !== undefined && current.generation === handle.generation) {
94
+ this.windows.delete(handle.canonicalPropertyId);
95
+ return true;
96
+ }
97
+ return false;
98
+ }
99
+ fail(handle) {
100
+ const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
101
+ if (current === undefined || current.generation !== handle.generation || current.state !== 'pending') {
102
+ return false;
103
+ }
104
+ this.detach(handle.canonicalPropertyId, current);
105
+ return true;
106
+ }
107
+ sweep() {
108
+ const now = Date.now();
109
+ for (const [canonicalPropertyId, window] of this.windows) {
110
+ if (!this.isExpired(window, now)) {
111
+ continue;
112
+ }
113
+ this.detach(canonicalPropertyId, window);
114
+ }
115
+ this.pruneRecoveries(now);
116
+ return Object.freeze([...this.recoveries.entries()].map(([canonicalPropertyId, recovery]) => Object.freeze({ canonicalPropertyId, generation: recovery.window.generation })));
117
+ }
118
+ expire(canonicalPropertyId) {
119
+ const current = this.windows.get(canonicalPropertyId);
120
+ if (current === undefined || !this.isExpired(current, Date.now())) {
121
+ return null;
122
+ }
123
+ this.detach(canonicalPropertyId, current);
124
+ return Object.freeze({ canonicalPropertyId, generation: current.generation });
125
+ }
126
+ getRecovery(handle) {
127
+ this.pruneRecoveries(Date.now());
128
+ const recovery = this.recoveries.get(handle.canonicalPropertyId);
129
+ return recovery?.window.generation === handle.generation ? this.toSnapshot(recovery.window) : null;
130
+ }
131
+ completeRecovery(handle) {
132
+ const recovery = this.recoveries.get(handle.canonicalPropertyId);
133
+ if (recovery === undefined || recovery.window.generation !== handle.generation) {
134
+ return false;
135
+ }
136
+ this.recoveries.delete(handle.canonicalPropertyId);
137
+ return true;
138
+ }
139
+ cancelRecovery(canonicalPropertyId) {
140
+ const recovery = this.recoveries.get(canonicalPropertyId);
141
+ this.recoveries.delete(canonicalPropertyId);
142
+ return recovery !== undefined && recovery.deadlineAt > Date.now();
143
+ }
144
+ cancel(canonicalPropertyId) {
145
+ this.windows.delete(canonicalPropertyId);
146
+ this.recoveries.delete(canonicalPropertyId);
147
+ }
148
+ clear() {
149
+ this.windows.clear();
150
+ this.recoveries.clear();
151
+ }
152
+ getCurrent(canonicalPropertyId, now) {
153
+ const current = this.windows.get(canonicalPropertyId);
154
+ if (current !== undefined && this.isExpired(current, now)) {
155
+ this.detach(canonicalPropertyId, current);
156
+ return undefined;
157
+ }
158
+ return current;
159
+ }
160
+ isExpired(window, now) {
161
+ return now >= (window.confirmationExpiresAt ?? window.expiresAt);
162
+ }
163
+ detach(canonicalPropertyId, window, now = Date.now()) {
164
+ this.windows.delete(canonicalPropertyId);
165
+ if (window.state === 'pending' && (window.heldReceipt !== null || window.patchReceipt !== null)) {
166
+ this.recoveries.set(canonicalPropertyId, {
167
+ window,
168
+ deadlineAt: now + (window.expiresAt - window.openedAt),
169
+ });
170
+ }
171
+ }
172
+ pruneRecoveries(now) {
173
+ for (const [canonicalPropertyId, recovery] of this.recoveries) {
174
+ if (now >= recovery.deadlineAt) {
175
+ this.recoveries.delete(canonicalPropertyId);
176
+ }
177
+ }
178
+ }
179
+ toSnapshot(window) {
180
+ if (window === undefined) {
181
+ return null;
182
+ }
183
+ return Object.freeze({
184
+ ...window,
185
+ canonicalTarget: freezeTarget(window.canonicalTarget),
186
+ requestedTargets: Object.freeze(window.requestedTargets.map(freezeTarget)),
187
+ lastReceipt: window.lastReceipt === null ? null : freezeReceipt(window.lastReceipt),
188
+ heldReceipt: window.heldReceipt === null ? null : freezeReceipt(window.heldReceipt),
189
+ recoveryReceipt: window.recoveryReceipt === null ? null : freezeReceipt(window.recoveryReceipt),
190
+ rollbackBaseline: window.rollbackBaseline === null ? null : freezeValueState(window.rollbackBaseline),
191
+ patchReceipt: window.patchReceipt === null ? null : freezePatchReceipt(window.patchReceipt),
192
+ });
193
+ }
194
+ };
195
+ exports.PropertyCommandWindowService = PropertyCommandWindowService;
196
+ exports.PropertyCommandWindowService = PropertyCommandWindowService = __decorate([
197
+ (0, common_1.Injectable)()
198
+ ], PropertyCommandWindowService);
199
+ const freezeTarget = (target) => Object.freeze({ ...target });
200
+ const freezeReceipt = (receipt) => Object.freeze({ ...receipt });
201
+ const freezePatchReceipt = (receipt) => Object.freeze({
202
+ baseline: freezeValueState(receipt.baseline),
203
+ optimisticState: freezeValueState(receipt.optimisticState),
204
+ });
205
+ const freezeValueState = (state) => Object.freeze(new property_value_state_model_1.PropertyValueState(state.value, state.lastUpdated, state.trend));
206
+ //# sourceMappingURL=property-command-window.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-command-window.service.js","sourceRoot":"","sources":["../../../../src/modules/devices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,+CAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC"}
@@ -2,15 +2,27 @@ import { IntentContext } from '../../intents/models/intent.model';
2
2
  import { IntentsService } from '../../intents/services/intents.service';
3
3
  import { ClientUserDto } from '../../websocket/dto/client-user.dto';
4
4
  import { UpdateChannelPropertyDto } from '../dto/update-channel-property.dto';
5
- import { ChannelPropertyEntity, DeviceEntity } from '../entities/devices.entity';
5
+ import { ChannelEntity, ChannelPropertyEntity, DeviceEntity } from '../entities/devices.entity';
6
+ import { PropertyValueState } from '../models/property-value-state.model';
6
7
  import { PropertyCommandValue } from '../utils/property-command-value.utils';
7
8
  import { ChannelsPropertiesService } from './channels.properties.service';
8
9
  import { ChannelsService } from './channels.service';
10
+ import { CommandLatencyTraceCollectorService } from './command-latency-trace-collector.service';
9
11
  import { DevicesService } from './devices.service';
10
12
  import { PlatformRegistryService } from './platform.registry.service';
13
+ import { PropertyCommandDispatchService } from './property-command-dispatch.service';
14
+ import { PropertyCommandWindowHandle, PropertyCommandWindowService } from './property-command-window.service';
11
15
  export interface PropertyCommandExecutionOptions {
12
16
  requestId?: string;
13
17
  context?: IntentContext;
18
+ apiReceipt?: ApiPropertyCommandReceipt;
19
+ }
20
+ export interface ApiPropertyCommandReceipt {
21
+ readonly handle: PropertyCommandWindowHandle;
22
+ readonly canonicalPropertyId: string;
23
+ readonly baseline: PropertyValueState | null;
24
+ readonly optimisticEligible: boolean;
25
+ readonly ttlMs: number;
14
26
  }
15
27
  export interface DevicePropertyCommandResult {
16
28
  device: string;
@@ -33,8 +45,11 @@ export declare class PropertyCommandService {
33
45
  private readonly channelsPropertiesService;
34
46
  private readonly platformRegistryService;
35
47
  private readonly intentsService;
48
+ private readonly propertyCommandDispatchService;
49
+ private readonly propertyCommandWindowService;
50
+ private readonly commandLatencyTraceCollector;
36
51
  private readonly logger;
37
- constructor(devicesService: DevicesService, channelsService: ChannelsService, channelsPropertiesService: ChannelsPropertiesService, platformRegistryService: PlatformRegistryService, intentsService: IntentsService);
52
+ constructor(devicesService: DevicesService, channelsService: ChannelsService, channelsPropertiesService: ChannelsPropertiesService, platformRegistryService: PlatformRegistryService, intentsService: IntentsService, propertyCommandDispatchService: PropertyCommandDispatchService, propertyCommandWindowService: PropertyCommandWindowService, commandLatencyTraceCollector?: CommandLatencyTraceCollectorService);
38
53
  handleInternal(user: ClientUserDto, payload?: object): Promise<{
39
54
  success: boolean;
40
55
  results: Array<{
@@ -51,6 +66,8 @@ export declare class PropertyCommandService {
51
66
  private executeCommands;
52
67
  private resolveCommandIntentTtlMs;
53
68
  private processDeviceCommands;
54
- processApiPropertyCommand(deviceId: string, channelId: string, propertyId: string, value: string | number | boolean): Promise<void>;
69
+ processApiPropertyCommand(deviceId: string, channelId: string, propertyId: string, value: string | number | boolean, receipt?: ApiPropertyCommandReceipt): Promise<void>;
70
+ prepareApiPropertyCommand(device: DeviceEntity | string, channel: ChannelEntity, property: ChannelPropertyEntity, value: string | number | boolean): Promise<ApiPropertyCommandReceipt | null>;
71
+ failApiPropertyCommandReceipt(receipt: ApiPropertyCommandReceipt): void;
55
72
  usesAuthoritativePropertyReadback(device: DeviceEntity | string, property: ChannelPropertyEntity, update?: UpdateChannelPropertyDto): Promise<boolean>;
56
73
  }