@fastybird/smart-panel-backend 1.1.0-alpha.3 → 1.1.0-alpha.30

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 (412) hide show
  1. package/dist/app.module.js +8 -0
  2. package/dist/app.module.js.map +1 -1
  3. package/dist/common/filters/conflict-exception.filter.d.ts +6 -0
  4. package/dist/common/filters/conflict-exception.filter.js +59 -0
  5. package/dist/common/filters/conflict-exception.filter.js.map +1 -0
  6. package/dist/common/filters/global-error.filter.js +1 -4
  7. package/dist/common/filters/global-error.filter.js.map +1 -1
  8. package/dist/common/filters/global-filters.d.ts +3 -0
  9. package/dist/common/filters/global-filters.js +22 -0
  10. package/dist/common/filters/global-filters.js.map +1 -0
  11. package/dist/common/filters/unprocessable-entity-exception.filter.d.ts +1 -0
  12. package/dist/common/filters/unprocessable-entity-exception.filter.js +15 -3
  13. package/dist/common/filters/unprocessable-entity-exception.filter.js.map +1 -1
  14. package/dist/dataSource.js +1 -0
  15. package/dist/dataSource.js.map +1 -1
  16. package/dist/main.js +2 -7
  17. package/dist/main.js.map +1 -1
  18. package/dist/migrations/1000000000026-AddHardwareInputCategories.d.ts +7 -0
  19. package/dist/migrations/1000000000026-AddHardwareInputCategories.js +364 -0
  20. package/dist/migrations/1000000000026-AddHardwareInputCategories.js.map +1 -0
  21. package/dist/modules/devices/controllers/channels.controller.d.ts +5 -1
  22. package/dist/modules/devices/controllers/channels.controller.js +34 -2
  23. package/dist/modules/devices/controllers/channels.controller.js.map +1 -1
  24. package/dist/modules/devices/controllers/channels.properties.controller.js +21 -4
  25. package/dist/modules/devices/controllers/channels.properties.controller.js.map +1 -1
  26. package/dist/modules/devices/controllers/devices.channels.controller.d.ts +5 -1
  27. package/dist/modules/devices/controllers/devices.channels.controller.js +38 -2
  28. package/dist/modules/devices/controllers/devices.channels.controller.js.map +1 -1
  29. package/dist/modules/devices/controllers/devices.channels.properties.controller.js +21 -4
  30. package/dist/modules/devices/controllers/devices.channels.properties.controller.js.map +1 -1
  31. package/dist/modules/devices/devices.constants.d.ts +6 -0
  32. package/dist/modules/devices/devices.constants.js +6 -0
  33. package/dist/modules/devices/devices.constants.js.map +1 -1
  34. package/dist/modules/devices/devices.module.js +20 -0
  35. package/dist/modules/devices/devices.module.js.map +1 -1
  36. package/dist/modules/devices/devices.openapi.d.ts +3 -1
  37. package/dist/modules/devices/devices.openapi.js +7 -0
  38. package/dist/modules/devices/devices.openapi.js.map +1 -1
  39. package/dist/modules/devices/dto/channel-input-occurrence.dto.d.ts +10 -0
  40. package/dist/modules/devices/dto/channel-input-occurrence.dto.js +99 -0
  41. package/dist/modules/devices/dto/channel-input-occurrence.dto.js.map +1 -0
  42. package/dist/modules/devices/models/channel-input-capabilities.model.d.ts +20 -0
  43. package/dist/modules/devices/models/channel-input-capabilities.model.js +111 -0
  44. package/dist/modules/devices/models/channel-input-capabilities.model.js.map +1 -0
  45. package/dist/modules/devices/models/channel-input-occurrence.model.d.ts +22 -0
  46. package/dist/modules/devices/models/channel-input-occurrence.model.js +154 -0
  47. package/dist/modules/devices/models/channel-input-occurrence.model.js.map +1 -0
  48. package/dist/modules/devices/services/channel-input-deduplication.service.d.ts +17 -0
  49. package/dist/modules/devices/services/channel-input-deduplication.service.js +88 -0
  50. package/dist/modules/devices/services/channel-input-deduplication.service.js.map +1 -0
  51. package/dist/modules/devices/services/channel-input-occurrences.service.d.ts +21 -0
  52. package/dist/modules/devices/services/channel-input-occurrences.service.js +163 -0
  53. package/dist/modules/devices/services/channel-input-occurrences.service.js.map +1 -0
  54. package/dist/modules/devices/services/channels.properties.service.d.ts +31 -3
  55. package/dist/modules/devices/services/channels.properties.service.js +346 -51
  56. package/dist/modules/devices/services/channels.properties.service.js.map +1 -1
  57. package/dist/modules/devices/services/channels.service.js +42 -38
  58. package/dist/modules/devices/services/channels.service.js.map +1 -1
  59. package/dist/modules/devices/services/command-latency-trace-collector.service.d.ts +101 -0
  60. package/dist/modules/devices/services/command-latency-trace-collector.service.js +451 -0
  61. package/dist/modules/devices/services/command-latency-trace-collector.service.js.map +1 -0
  62. package/dist/modules/devices/services/device-structure-lock.service.d.ts +10 -2
  63. package/dist/modules/devices/services/device-structure-lock.service.js +86 -7
  64. package/dist/modules/devices/services/device-structure-lock.service.js.map +1 -1
  65. package/dist/modules/devices/services/devices.service.js +37 -33
  66. package/dist/modules/devices/services/devices.service.js.map +1 -1
  67. package/dist/modules/devices/services/module-reset.service.d.ts +3 -1
  68. package/dist/modules/devices/services/module-reset.service.js +21 -16
  69. package/dist/modules/devices/services/module-reset.service.js.map +1 -1
  70. package/dist/modules/devices/services/property-command-dispatch.service.d.ts +45 -0
  71. package/dist/modules/devices/services/property-command-dispatch.service.js +227 -0
  72. package/dist/modules/devices/services/property-command-dispatch.service.js.map +1 -0
  73. package/dist/modules/devices/services/property-command-window.service.d.ts +71 -0
  74. package/dist/modules/devices/services/property-command-window.service.js +206 -0
  75. package/dist/modules/devices/services/property-command-window.service.js.map +1 -0
  76. package/dist/modules/devices/services/property-command.service.d.ts +20 -3
  77. package/dist/modules/devices/services/property-command.service.js +56 -10
  78. package/dist/modules/devices/services/property-command.service.js.map +1 -1
  79. package/dist/modules/devices/services/property-metadata.service.d.ts +31 -0
  80. package/dist/modules/devices/services/property-metadata.service.js +160 -0
  81. package/dist/modules/devices/services/property-metadata.service.js.map +1 -0
  82. package/dist/modules/devices/services/property-state-coordinator.service.d.ts +4 -0
  83. package/dist/modules/devices/services/property-state-coordinator.service.js +35 -0
  84. package/dist/modules/devices/services/property-state-coordinator.service.js.map +1 -0
  85. package/dist/modules/devices/services/property-value-lock.service.d.ts +3 -1
  86. package/dist/modules/devices/services/property-value-lock.service.js +13 -2
  87. package/dist/modules/devices/services/property-value-lock.service.js.map +1 -1
  88. package/dist/modules/devices/services/property-value.service.d.ts +1 -0
  89. package/dist/modules/devices/services/property-value.service.js +4 -0
  90. package/dist/modules/devices/services/property-value.service.js.map +1 -1
  91. package/dist/modules/devices/utils/schema.utils.js +1 -1
  92. package/dist/modules/devices/utils/schema.utils.js.map +1 -1
  93. package/dist/modules/platform/platforms/raspberry.platform.js +5 -10
  94. package/dist/modules/platform/platforms/raspberry.platform.js.map +1 -1
  95. package/dist/modules/platform/services/platform.service.d.ts +13 -4
  96. package/dist/modules/platform/services/platform.service.js +57 -35
  97. package/dist/modules/platform/services/platform.service.js.map +1 -1
  98. package/dist/modules/remote-access/dto/update-config.dto.js +5 -0
  99. package/dist/modules/remote-access/dto/update-config.dto.js.map +1 -1
  100. package/dist/modules/remote-access/validators/is-remote-access-url.validator.js +5 -2
  101. package/dist/modules/remote-access/validators/is-remote-access-url.validator.js.map +1 -1
  102. package/dist/modules/system/scripts/update-worker.sh +1168 -61
  103. package/dist/modules/system/services/privileged-worker.service.d.ts +13 -0
  104. package/dist/modules/system/services/privileged-worker.service.js +192 -31
  105. package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
  106. package/dist/modules/system/services/system.service.d.ts +2 -0
  107. package/dist/modules/system/services/system.service.js +22 -1
  108. package/dist/modules/system/services/system.service.js.map +1 -1
  109. package/dist/modules/system/services/update-executor.service.d.ts +20 -2
  110. package/dist/modules/system/services/update-executor.service.js +272 -26
  111. package/dist/modules/system/services/update-executor.service.js.map +1 -1
  112. package/dist/modules/websocket/gateway/websocket.gateway.d.ts +4 -1
  113. package/dist/modules/websocket/gateway/websocket.gateway.js +28 -5
  114. package/dist/modules/websocket/gateway/websocket.gateway.js.map +1 -1
  115. package/dist/modules/websocket/services/command-acknowledgement-trace.service.d.ts +143 -0
  116. package/dist/modules/websocket/services/command-acknowledgement-trace.service.js +523 -0
  117. package/dist/modules/websocket/services/command-acknowledgement-trace.service.js.map +1 -0
  118. package/dist/modules/websocket/websocket.module.js +9 -1
  119. package/dist/modules/websocket/websocket.module.js.map +1 -1
  120. package/dist/plugins/devices-home-assistant/devices-home-assistant.openapi.d.ts +2 -2
  121. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.d.ts +6 -1
  122. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js +16 -1
  123. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js.map +1 -1
  124. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.d.ts +1 -0
  125. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js +11 -0
  126. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js.map +1 -1
  127. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.d.ts +19 -0
  128. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js +51 -0
  129. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js.map +1 -0
  130. package/dist/plugins/devices-home-assistant/mappings/definitions/entity-mappings.yaml +56 -7
  131. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.d.ts +1 -0
  132. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js +11 -0
  133. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js.map +1 -1
  134. package/dist/plugins/devices-home-assistant/services/device-adoption.service.js +17 -0
  135. package/dist/plugins/devices-home-assistant/services/device-adoption.service.js.map +1 -1
  136. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.d.ts +27 -0
  137. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js +271 -0
  138. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js.map +1 -0
  139. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.d.ts +2 -2
  140. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +33 -14
  141. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
  142. package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js +24 -4
  143. package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js.map +1 -1
  144. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.d.ts +4 -1
  145. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js +84 -5
  146. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js.map +1 -1
  147. package/dist/plugins/devices-home-assistant/services/wizard.service.js +1 -0
  148. package/dist/plugins/devices-home-assistant/services/wizard.service.js.map +1 -1
  149. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.d.ts +2 -0
  150. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js +50 -0
  151. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js.map +1 -0
  152. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.d.ts +4 -1
  153. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +39 -4
  154. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -1
  155. package/dist/plugins/devices-homekit/mappers/base.mapper.js +30 -6
  156. package/dist/plugins/devices-homekit/mappers/base.mapper.js.map +1 -1
  157. package/dist/plugins/devices-homekit/mappers/button.mapper.d.ts +15 -0
  158. package/dist/plugins/devices-homekit/mappers/button.mapper.js +143 -0
  159. package/dist/plugins/devices-homekit/mappers/button.mapper.js.map +1 -0
  160. package/dist/plugins/devices-homekit/mappers/characteristic-write.d.ts +2 -0
  161. package/dist/plugins/devices-homekit/mappers/characteristic-write.js +17 -0
  162. package/dist/plugins/devices-homekit/mappers/characteristic-write.js.map +1 -0
  163. package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +17 -1
  164. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.d.ts +7 -0
  165. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +96 -84
  166. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js.map +1 -1
  167. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.d.ts +5 -1
  168. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js +42 -0
  169. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js.map +1 -1
  170. package/dist/plugins/devices-homey/mappings/definitions/channels.yaml +50 -0
  171. package/dist/plugins/devices-homey/mappings/definitions/devices.yaml +18 -0
  172. package/dist/plugins/devices-homey/mappings/definitions/properties.yaml +55 -0
  173. package/dist/plugins/devices-homey/mappings/device-support.js +10 -0
  174. package/dist/plugins/devices-homey/mappings/device-support.js.map +1 -1
  175. package/dist/plugins/devices-homey/mappings/mapping-loader.service.d.ts +1 -0
  176. package/dist/plugins/devices-homey/mappings/mapping-loader.service.js +66 -8
  177. package/dist/plugins/devices-homey/mappings/mapping-loader.service.js.map +1 -1
  178. package/dist/plugins/devices-homey/models/inventory.model.d.ts +2 -1
  179. package/dist/plugins/devices-homey/models/inventory.model.js +1 -0
  180. package/dist/plugins/devices-homey/models/inventory.model.js.map +1 -1
  181. package/dist/plugins/devices-homey/models/mapping-preview.model.d.ts +1 -0
  182. package/dist/plugins/devices-homey/models/mapping-preview.model.js +1 -0
  183. package/dist/plugins/devices-homey/models/mapping-preview.model.js.map +1 -1
  184. package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js +7 -0
  185. package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js.map +1 -1
  186. package/dist/plugins/devices-homey/services/homey-synchronizer.service.d.ts +3 -1
  187. package/dist/plugins/devices-homey/services/homey-synchronizer.service.js +37 -6
  188. package/dist/plugins/devices-homey/services/homey-synchronizer.service.js.map +1 -1
  189. package/dist/plugins/devices-reterminal/services/reterminal-button.service.d.ts +7 -3
  190. package/dist/plugins/devices-reterminal/services/reterminal-button.service.js +63 -17
  191. package/dist/plugins/devices-reterminal/services/reterminal-button.service.js.map +1 -1
  192. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +36 -3
  193. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +707 -42
  194. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
  195. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +11 -1
  196. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +100 -10
  197. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
  198. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +9 -11
  199. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
  200. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js +2 -0
  201. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js.map +1 -1
  202. package/dist/plugins/devices-shelly-ng/mappings/definitions/inputs.yaml +80 -0
  203. package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js +7 -1
  204. package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js.map +1 -1
  205. package/dist/plugins/devices-shelly-ng/mappings/mapping.types.d.ts +6 -3
  206. package/dist/plugins/devices-shelly-ng/mappings/schema/mapping-schema.json +5 -0
  207. package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +153 -8
  208. package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
  209. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.d.ts +51 -0
  210. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js +549 -0
  211. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js.map +1 -0
  212. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.d.ts +14 -2
  213. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +134 -35
  214. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js.map +1 -1
  215. package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js +3 -0
  216. package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js.map +1 -1
  217. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.d.ts +1 -0
  218. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +14 -4
  219. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js.map +1 -1
  220. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.d.ts +2 -0
  221. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js +66 -4
  222. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js.map +1 -1
  223. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js +2 -0
  224. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js.map +1 -1
  225. package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js +7 -0
  226. package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js.map +1 -1
  227. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.d.ts +3 -1
  228. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js +20 -2
  229. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js.map +1 -1
  230. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.d.ts +16 -0
  231. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js +107 -0
  232. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js.map +1 -0
  233. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.d.ts +7 -1
  234. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js +98 -3
  235. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js.map +1 -1
  236. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.d.ts +17 -0
  237. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js +205 -0
  238. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js.map +1 -0
  239. package/dist/plugins/devices-third-party/devices-third-party.openapi.d.ts +1 -1
  240. package/dist/plugins/devices-third-party/devices-third-party.plugin.js +2 -1
  241. package/dist/plugins/devices-third-party/devices-third-party.plugin.js.map +1 -1
  242. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.d.ts +5 -0
  243. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js +50 -0
  244. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js.map +1 -0
  245. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.d.ts +8 -0
  246. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js +81 -0
  247. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js.map +1 -0
  248. package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js +19 -4
  249. package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js.map +1 -1
  250. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.d.ts +2 -0
  251. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js +57 -0
  252. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js.map +1 -1
  253. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.d.ts +3 -0
  254. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js +41 -5
  255. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js.map +1 -1
  256. package/dist/plugins/devices-zigbee2mqtt/interfaces/zigbee2mqtt.interface.d.ts +7 -1
  257. package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js +16 -15
  258. package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js.map +1 -1
  259. package/dist/plugins/devices-zigbee2mqtt/mappings/definitions/remotes.yaml +505 -74
  260. package/dist/plugins/devices-zigbee2mqtt/mappings/schema/mapping-schema.json +3 -3
  261. package/dist/plugins/devices-zigbee2mqtt/mappings/transformers/transformer.types.d.ts +1 -1
  262. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.d.ts +8 -2
  263. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js +6 -5
  264. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js.map +1 -1
  265. package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js +18 -11
  266. package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js.map +1 -1
  267. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.d.ts +9 -3
  268. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js +166 -3
  269. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js.map +1 -1
  270. package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js +5 -2
  271. package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js.map +1 -1
  272. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.d.ts +1 -0
  273. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js +44 -4
  274. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js.map +1 -1
  275. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.d.ts +17 -0
  276. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js +147 -0
  277. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js.map +1 -0
  278. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.d.ts +15 -0
  279. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js +98 -0
  280. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js.map +1 -0
  281. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.d.ts +9 -0
  282. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js +94 -0
  283. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js.map +1 -0
  284. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.d.ts +9 -0
  285. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js +92 -0
  286. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js.map +1 -0
  287. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.d.ts +7 -0
  288. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js +48 -0
  289. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js.map +1 -0
  290. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.d.ts +42 -0
  291. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js +352 -0
  292. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js.map +1 -0
  293. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.d.ts +24 -0
  294. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js +27 -0
  295. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js.map +1 -0
  296. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.d.ts +8 -0
  297. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js +19 -0
  298. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js.map +1 -0
  299. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.d.ts +4 -0
  300. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js +20 -0
  301. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js.map +1 -0
  302. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.d.ts +21 -0
  303. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js +135 -0
  304. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js.map +1 -0
  305. package/dist/plugins/remote-access-cloudflare-tunnel/scripts/cloudflared-setup.sh +185 -0
  306. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.d.ts +82 -0
  307. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js +507 -0
  308. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js.map +1 -0
  309. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.d.ts +10 -0
  310. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js +37 -0
  311. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js.map +1 -0
  312. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.d.ts +38 -0
  313. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js +147 -0
  314. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js.map +1 -0
  315. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.d.ts +15 -0
  316. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js +67 -0
  317. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js.map +1 -0
  318. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.d.ts +8 -0
  319. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js +46 -0
  320. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js.map +1 -0
  321. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.d.ts +27 -0
  322. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js +139 -0
  323. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js.map +1 -0
  324. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +1 -0
  325. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +26 -10
  326. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
  327. package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -1
  328. package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +28 -3
  329. package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
  330. package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +19 -0
  331. package/dist/plugins/remote-access-tailscale/models/status.model.js +158 -1
  332. package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
  333. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.d.ts +3 -0
  334. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js +4 -1
  335. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js.map +1 -1
  336. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +13 -0
  337. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +27 -0
  338. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -0
  339. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
  340. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +2 -0
  341. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
  342. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +1 -1
  343. package/dist/plugins/remote-access-tailscale/scripts/tailscale-setup.sh +61 -0
  344. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +9 -0
  345. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +12 -0
  346. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
  347. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +1 -0
  348. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +27 -2
  349. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
  350. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +31 -1
  351. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +316 -30
  352. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
  353. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +8 -3
  354. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +39 -12
  355. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
  356. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +14 -5
  357. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +51 -16
  358. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
  359. package/dist/plugins/scenes-local/platforms/local-scene.platform.d.ts +3 -1
  360. package/dist/plugins/scenes-local/platforms/local-scene.platform.js +12 -7
  361. package/dist/plugins/scenes-local/platforms/local-scene.platform.js.map +1 -1
  362. package/dist/plugins/simulator/controllers/simulator.controller.d.ts +8 -2
  363. package/dist/plugins/simulator/controllers/simulator.controller.js +102 -2
  364. package/dist/plugins/simulator/controllers/simulator.controller.js.map +1 -1
  365. package/dist/plugins/simulator/dto/simulate-occurrence.dto.d.ts +12 -0
  366. package/dist/plugins/simulator/dto/simulate-occurrence.dto.js +122 -0
  367. package/dist/plugins/simulator/dto/simulate-occurrence.dto.js.map +1 -0
  368. package/dist/plugins/simulator/models/simulator-response.model.d.ts +12 -0
  369. package/dist/plugins/simulator/models/simulator-response.model.js +84 -1
  370. package/dist/plugins/simulator/models/simulator-response.model.js.map +1 -1
  371. package/dist/plugins/simulator/scenarios/definitions/small-apartment.yaml +78 -0
  372. package/dist/plugins/simulator/services/scenario-executor.service.js +3 -1
  373. package/dist/plugins/simulator/services/scenario-executor.service.js.map +1 -1
  374. package/dist/plugins/simulator/services/simulation.service.js +10 -1
  375. package/dist/plugins/simulator/services/simulation.service.js.map +1 -1
  376. package/dist/plugins/simulator/simulator.openapi.d.ts +3 -2
  377. package/dist/plugins/simulator/simulator.openapi.js +5 -0
  378. package/dist/plugins/simulator/simulator.openapi.js.map +1 -1
  379. package/dist/plugins/simulator/simulators/device-simulator.interface.d.ts +2 -0
  380. package/dist/plugins/simulator/simulators/device-simulator.interface.js +83 -0
  381. package/dist/plugins/simulator/simulators/device-simulator.interface.js.map +1 -1
  382. package/dist/plugins/simulator/simulators/index.d.ts +1 -0
  383. package/dist/plugins/simulator/simulators/index.js +1 -0
  384. package/dist/plugins/simulator/simulators/index.js.map +1 -1
  385. package/dist/plugins/simulator/simulators/input-controller.simulator.d.ts +10 -0
  386. package/dist/plugins/simulator/simulators/input-controller.simulator.js +57 -0
  387. package/dist/plugins/simulator/simulators/input-controller.simulator.js.map +1 -0
  388. package/dist/plugins/simulator/simulators/lighting.simulator.js +1 -0
  389. package/dist/plugins/simulator/simulators/lighting.simulator.js.map +1 -1
  390. package/dist/plugins/spaces-home-control/services/climate-intent.service.d.ts +3 -1
  391. package/dist/plugins/spaces-home-control/services/climate-intent.service.js +6 -3
  392. package/dist/plugins/spaces-home-control/services/climate-intent.service.js.map +1 -1
  393. package/dist/plugins/spaces-home-control/services/covers-intent.service.d.ts +3 -1
  394. package/dist/plugins/spaces-home-control/services/covers-intent.service.js +6 -3
  395. package/dist/plugins/spaces-home-control/services/covers-intent.service.js.map +1 -1
  396. package/dist/plugins/spaces-home-control/services/lighting-intent.service.d.ts +3 -1
  397. package/dist/plugins/spaces-home-control/services/lighting-intent.service.js +7 -4
  398. package/dist/plugins/spaces-home-control/services/lighting-intent.service.js.map +1 -1
  399. package/dist/plugins/spaces-home-control/services/space-media-activity.service.d.ts +3 -1
  400. package/dist/plugins/spaces-home-control/services/space-media-activity.service.js +11 -5
  401. package/dist/plugins/spaces-home-control/services/space-media-activity.service.js.map +1 -1
  402. package/dist/plugins/spaces-home-control/services/space-undo-history.service.d.ts +3 -1
  403. package/dist/plugins/spaces-home-control/services/space-undo-history.service.js +8 -5
  404. package/dist/plugins/spaces-home-control/services/space-undo-history.service.js.map +1 -1
  405. package/dist/spec/channels.d.ts +51 -1
  406. package/dist/spec/channels.js +64 -1
  407. package/dist/spec/channels.js.map +1 -1
  408. package/dist/spec/devices.d.ts +155 -2
  409. package/dist/spec/devices.js +161 -2
  410. package/dist/spec/devices.js.map +1 -1
  411. package/dist/tsconfig.build.tsbuildinfo +1 -1
  412. package/package.json +3 -3
@@ -0,0 +1,549 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PollPlacementDiagnosticsService = void 0;
13
+ const crypto_1 = require("crypto");
14
+ const fs_1 = require("fs");
15
+ const promises_1 = require("fs/promises");
16
+ const path_1 = require("path");
17
+ const perf_hooks_1 = require("perf_hooks");
18
+ const common_1 = require("@nestjs/common");
19
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
20
+ const DEFAULT_DURATION_MS = 180_000;
21
+ const MAX_DURATION_MS = 360_000;
22
+ const MAX_PREPARATION_MS = 600_000;
23
+ const MAX_RECORDS = 64;
24
+ const MAX_BYTES = 256 * 1024;
25
+ const OWNER_SUFFIX = '.owner.json';
26
+ class ExportOwnershipError extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = 'ExportOwnershipError';
30
+ }
31
+ }
32
+ let PollPlacementDiagnosticsService = class PollPlacementDiagnosticsService {
33
+ constructor() {
34
+ this.processInstanceId = (0, crypto_1.randomUUID)();
35
+ this.observerRuntimeHash = this.computeRuntimeHash();
36
+ this.delegateObservations = new Map();
37
+ this.snapshot = null;
38
+ this.writePending = false;
39
+ this.publishRequested = false;
40
+ this.writePromise = null;
41
+ this.destroyed = false;
42
+ this.ownershipAcquired = false;
43
+ this.expiryTimer = null;
44
+ this.cycleSequence = 0;
45
+ this.attachmentRevision = 0;
46
+ this.config = this.parseConfig(process.env.FB_SHELLY_POLL_PLACEMENT);
47
+ this.ownerPath = this.config ? this.config.exportPath + OWNER_SUFFIX : null;
48
+ if (this.config) {
49
+ const now = this.now();
50
+ const nowUtc = this.utcNow();
51
+ this.snapshot = {
52
+ schemaVersion: this.config.schemaVersion,
53
+ runId: this.config.runId,
54
+ status: this.config.schemaVersion === 2 ? 'preparing' : 'armed',
55
+ candidateStatus: 'invalidated',
56
+ candidateReason: 'awaiting-cycle',
57
+ configFingerprint: (0, crypto_1.createHash)('sha256').update(JSON.stringify(this.config)).digest('hex'),
58
+ processInstanceId: this.processInstanceId,
59
+ processId: process.pid,
60
+ sourceDeviceId: this.config.sourceDeviceId,
61
+ observerRuntimeHash: this.observerRuntimeHash,
62
+ backendClock: 'performance-now-v1',
63
+ armedAtMonotonicMs: this.config.schemaVersion === 2 ? null : now,
64
+ armedAtUtc: this.config.schemaVersion === 2 ? null : nowUtc,
65
+ expiresAtMonotonicMs: this.config.schemaVersion === 2 ? null : now + this.config.durationMs,
66
+ ...(this.config.schemaVersion === 2
67
+ ? {
68
+ preparation: {
69
+ createdAtMonotonicMs: now,
70
+ createdAtUtc: nowUtc,
71
+ deadlineMonotonicMs: now + this.config.preparationMs,
72
+ activationCycles: null,
73
+ },
74
+ }
75
+ : {}),
76
+ sequence: 0,
77
+ observations: [],
78
+ };
79
+ this.scheduleExpiry(this.config.preparationMs ?? this.config.durationMs);
80
+ void this.publish();
81
+ }
82
+ }
83
+ async onModuleDestroy() {
84
+ if (this.expiryTimer) {
85
+ clearTimeout(this.expiryTimer);
86
+ this.expiryTimer = null;
87
+ }
88
+ if (this.snapshot && this.isActive()) {
89
+ this.snapshot.status = 'invalidated';
90
+ this.snapshot.reason = 'process-shutdown';
91
+ await this.publish();
92
+ }
93
+ else {
94
+ const pending = this.writePromise;
95
+ if (pending !== null)
96
+ await pending;
97
+ }
98
+ this.destroyed = true;
99
+ }
100
+ isEnabled() {
101
+ this.expireIfNeeded();
102
+ return this.snapshot !== null && !this.destroyed && this.isActive();
103
+ }
104
+ observeDelegate(observation) {
105
+ if (!this.isEnabled())
106
+ return;
107
+ const previous = this.delegateObservations.get(observation.delegateId);
108
+ this.delegateObservations.set(observation.delegateId, observation);
109
+ if ((previous || this.config?.schemaVersion === 2) &&
110
+ (previous?.sourceDeviceId === this.snapshot.sourceDeviceId ||
111
+ observation.sourceDeviceId === this.snapshot.sourceDeviceId) &&
112
+ (previous?.sourceDeviceId !== observation.sourceDeviceId ||
113
+ previous?.generation !== observation.generation ||
114
+ previous?.connected !== observation.connected ||
115
+ observation.connected !== true)) {
116
+ this.invalidateCandidate('target-delegate-changed');
117
+ }
118
+ }
119
+ removeDelegate(delegateId) {
120
+ const previous = this.delegateObservations.get(delegateId);
121
+ this.delegateObservations.delete(delegateId);
122
+ if (previous?.sourceDeviceId === this.snapshot?.sourceDeviceId)
123
+ this.invalidateCandidate('target-delegate-removed');
124
+ }
125
+ invalidate(reason) {
126
+ if (!this.isEnabled())
127
+ return;
128
+ this.snapshot.status = 'invalidated';
129
+ this.snapshot.reason = reason;
130
+ void this.publish();
131
+ }
132
+ invalidateCandidate(reason) {
133
+ if (!this.isEnabled())
134
+ return;
135
+ this.attachmentRevision++;
136
+ this.snapshot.candidateStatus = 'invalidated';
137
+ this.snapshot.candidateReason = reason;
138
+ this.snapshot.sequence++;
139
+ void this.publish();
140
+ }
141
+ observeCycle(generation, intervalMs, delegates, activePollCount = 0, concurrencyCap = 10, inFlightDelegates = [], schedulerState = 'started') {
142
+ const snapshot = this.snapshot;
143
+ if (!snapshot || !this.isEnabled())
144
+ return null;
145
+ if (!Number.isInteger(generation) ||
146
+ !Number.isInteger(intervalMs) ||
147
+ intervalMs < 1 ||
148
+ (delegates.length === 0 && snapshot.schemaVersion === 1)) {
149
+ return null;
150
+ }
151
+ const cycleEntryMonotonicMs = this.now();
152
+ const cycleEntryUtc = this.utcNow();
153
+ const registrationBeforeMs = this.now();
154
+ const registrationBeforeUtc = this.utcNow();
155
+ const ordered = delegates.slice();
156
+ const targetMatches = ordered.filter((id) => {
157
+ const delegate = this.delegateObservations.get(id);
158
+ return delegate?.sourceDeviceId === snapshot.sourceDeviceId && delegate.connected === true;
159
+ });
160
+ const targetIndex = targetMatches.length === 1 ? ordered.indexOf(targetMatches[0]) : -1;
161
+ const targetId = targetIndex >= 0 ? ordered[targetIndex] : null;
162
+ const target = targetId ? this.delegateObservations.get(targetId) : undefined;
163
+ const cycleSequence = ++this.cycleSequence;
164
+ snapshot.candidateStatus = targetId === null ? 'invalidated' : 'valid';
165
+ snapshot.candidateReason = targetId === null ? 'target-unresolved' : undefined;
166
+ snapshot.observations.push({
167
+ ...(snapshot.schemaVersion === 2
168
+ ? {
169
+ phase: snapshot.status === 'preparing' ? 'preparation' : 'measurement',
170
+ attachmentRevision: this.attachmentRevision,
171
+ }
172
+ : {}),
173
+ cycleSequence,
174
+ generation,
175
+ intervalMs,
176
+ anchorMonotonicMs: cycleEntryMonotonicMs,
177
+ anchorUtc: cycleEntryUtc,
178
+ connectedDelegateCount: ordered.length,
179
+ delegateOrderFingerprint: (0, crypto_1.createHash)('sha256').update(ordered.join('\n')).digest('hex'),
180
+ activePollCount,
181
+ concurrencyCap,
182
+ targetInFlight: targetId !== null && inFlightDelegates.includes(targetId),
183
+ schedulerState,
184
+ target: {
185
+ delegateId: targetId,
186
+ slotIndex: targetId ? targetIndex : null,
187
+ connected: target?.connected === true,
188
+ generation: target?.generation ?? null,
189
+ decision: 'unresolved',
190
+ ...(snapshot.schemaVersion === 2 ? { decisionMonotonicMs: null } : {}),
191
+ skipReason: targetId ? 'slot-pending' : 'target-unresolved',
192
+ delayMs: targetId ? Math.floor((targetIndex * intervalMs) / ordered.length) : null,
193
+ registrationBeforeMs,
194
+ registrationBeforeUtc,
195
+ registrationAfterMs: null,
196
+ registrationAfterUtc: null,
197
+ },
198
+ });
199
+ snapshot.sequence++;
200
+ if (snapshot.status !== 'preparing')
201
+ snapshot.status = 'ready';
202
+ this.enforceBounds();
203
+ void this.publish();
204
+ return cycleSequence;
205
+ }
206
+ completeCycleRegistration(cycleSequence) {
207
+ const snapshot = this.snapshot;
208
+ if (!snapshot || !this.isEnabled())
209
+ return;
210
+ const observation = snapshot.observations.find((candidate) => candidate.cycleSequence === cycleSequence);
211
+ if (!observation || observation.target.registrationAfterMs !== null)
212
+ return;
213
+ observation.target.registrationAfterMs = this.now();
214
+ observation.target.registrationAfterUtc = this.utcNow();
215
+ this.tryActivate();
216
+ snapshot.sequence++;
217
+ void this.publish();
218
+ }
219
+ observeSlot(delegateId, generation, cycleSequence, decision, skipReason) {
220
+ const snapshot = this.snapshot;
221
+ if (!snapshot || !this.isEnabled())
222
+ return;
223
+ const observation = snapshot.observations.find((candidate) => candidate.cycleSequence === cycleSequence);
224
+ if (!observation ||
225
+ observation.generation !== generation ||
226
+ observation.target.delegateId !== delegateId ||
227
+ observation.target.decision !== 'unresolved')
228
+ return;
229
+ observation.target.decision = decision;
230
+ if (snapshot.schemaVersion === 2)
231
+ observation.target.decisionMonotonicMs = this.now();
232
+ observation.target.skipReason = skipReason;
233
+ this.tryActivate();
234
+ snapshot.sequence++;
235
+ void this.publish();
236
+ }
237
+ isActive() {
238
+ return (this.snapshot?.status === 'preparing' || this.snapshot?.status === 'armed' || this.snapshot?.status === 'ready');
239
+ }
240
+ expireIfNeeded() {
241
+ if (!this.snapshot || this.destroyed || !this.isActive())
242
+ return;
243
+ const preparing = this.snapshot.status === 'preparing';
244
+ const deadline = preparing ? this.snapshot.preparation.deadlineMonotonicMs : this.snapshot.expiresAtMonotonicMs;
245
+ if (this.now() < deadline)
246
+ return;
247
+ this.snapshot.status = 'expired';
248
+ this.snapshot.reason = preparing ? 'preparation-expired' : 'diagnostic-expired';
249
+ void this.publish();
250
+ }
251
+ scheduleExpiry(durationMs) {
252
+ if (this.expiryTimer)
253
+ clearTimeout(this.expiryTimer);
254
+ this.expiryTimer = setTimeout(() => this.expireIfNeeded(), durationMs);
255
+ this.expiryTimer.unref?.();
256
+ }
257
+ tryActivate() {
258
+ const snapshot = this.snapshot;
259
+ if (snapshot?.status !== 'preparing' || !this.isEnabled())
260
+ return;
261
+ const pair = snapshot.observations.slice(-2);
262
+ if (pair.length !== 2)
263
+ return;
264
+ const [first, last] = pair;
265
+ if (last.cycleSequence !== first.cycleSequence + 1 || last.anchorMonotonicMs <= first.anchorMonotonicMs)
266
+ return;
267
+ if (pair.some((entry) => entry.generation !== first.generation ||
268
+ entry.intervalMs !== first.intervalMs ||
269
+ entry.delegateOrderFingerprint !== first.delegateOrderFingerprint ||
270
+ entry.attachmentRevision !== this.attachmentRevision ||
271
+ entry.target.delegateId !== first.target.delegateId ||
272
+ entry.target.slotIndex !== first.target.slotIndex ||
273
+ entry.target.generation !== first.target.generation ||
274
+ !entry.target.connected ||
275
+ entry.target.decision !== 'dispatch-attempt' ||
276
+ entry.target.registrationAfterMs === null))
277
+ return;
278
+ const current = this.delegateObservations.get(last.target.delegateId);
279
+ if (!current?.connected ||
280
+ current.sourceDeviceId !== snapshot.sourceDeviceId ||
281
+ current.generation !== last.target.generation)
282
+ return;
283
+ const now = this.now();
284
+ snapshot.armedAtMonotonicMs = now;
285
+ snapshot.armedAtUtc = this.utcNow();
286
+ snapshot.expiresAtMonotonicMs = now + this.config.durationMs;
287
+ snapshot.preparation.activationCycles = pair.map((entry) => entry.cycleSequence);
288
+ snapshot.status = 'ready';
289
+ this.scheduleExpiry(this.config.durationMs);
290
+ }
291
+ enforceBounds() {
292
+ if (!this.snapshot)
293
+ return;
294
+ if (this.snapshot.observations.length <= MAX_RECORDS &&
295
+ Buffer.byteLength(JSON.stringify(this.snapshot)) <= MAX_BYTES)
296
+ return;
297
+ this.snapshot.status = 'overflow';
298
+ this.snapshot.reason = 'observation-bound-exceeded';
299
+ this.snapshot.observations = this.snapshot.observations.slice(0, MAX_RECORDS);
300
+ }
301
+ parseConfig(raw) {
302
+ if (!raw)
303
+ return null;
304
+ try {
305
+ if (Buffer.byteLength(raw, 'utf8') > 8192)
306
+ return null;
307
+ const value = JSON.parse(raw);
308
+ if ((value.schemaVersion !== 1 && value.schemaVersion !== 2) ||
309
+ typeof value.runId !== 'string' ||
310
+ !UUID_RE.test(value.runId))
311
+ return null;
312
+ if (typeof value.sourceDeviceId !== 'string' || !UUID_RE.test(value.sourceDeviceId))
313
+ return null;
314
+ if (typeof value.exportPath !== 'string' || !value.exportPath.startsWith('/') || value.exportPath.includes('\0'))
315
+ return null;
316
+ const durationMs = value.durationMs === undefined ? DEFAULT_DURATION_MS : value.durationMs;
317
+ if (typeof durationMs !== 'number' ||
318
+ !Number.isInteger(durationMs) ||
319
+ durationMs < 1000 ||
320
+ durationMs > MAX_DURATION_MS)
321
+ return null;
322
+ const preparationMs = value.preparationMs === undefined ? MAX_PREPARATION_MS : value.preparationMs;
323
+ if (value.schemaVersion === 2 &&
324
+ (typeof preparationMs !== 'number' ||
325
+ !Number.isInteger(preparationMs) ||
326
+ preparationMs < 1000 ||
327
+ preparationMs > MAX_PREPARATION_MS))
328
+ return null;
329
+ const allowed = new Set([
330
+ 'schemaVersion',
331
+ 'runId',
332
+ 'sourceDeviceId',
333
+ 'exportPath',
334
+ 'durationMs',
335
+ ...(value.schemaVersion === 2 ? ['preparationMs'] : []),
336
+ ]);
337
+ if (Object.keys(value).some((key) => !allowed.has(key)))
338
+ return null;
339
+ return {
340
+ schemaVersion: value.schemaVersion,
341
+ runId: value.runId,
342
+ sourceDeviceId: value.sourceDeviceId,
343
+ exportPath: value.exportPath,
344
+ durationMs,
345
+ ...(value.schemaVersion === 2 ? { preparationMs: preparationMs } : {}),
346
+ };
347
+ }
348
+ catch {
349
+ return null;
350
+ }
351
+ }
352
+ computeRuntimeHash() {
353
+ try {
354
+ return (0, crypto_1.createHash)('sha256').update((0, fs_1.readFileSync)(__filename)).digest('hex');
355
+ }
356
+ catch {
357
+ return (0, crypto_1.createHash)('sha256').update(__filename).digest('hex');
358
+ }
359
+ }
360
+ now() {
361
+ return perf_hooks_1.performance.now();
362
+ }
363
+ utcNow() {
364
+ return new Date().toISOString();
365
+ }
366
+ ownerRecord() {
367
+ return {
368
+ schemaVersion: 1,
369
+ runId: this.snapshot.runId,
370
+ processInstanceId: this.processInstanceId,
371
+ processId: process.pid,
372
+ configFingerprint: this.snapshot.configFingerprint,
373
+ };
374
+ }
375
+ async acquireOwnership() {
376
+ if (this.ownershipAcquired)
377
+ return;
378
+ if (!this.config || !this.ownerPath || !this.snapshot)
379
+ throw new ExportOwnershipError('diagnostic is disabled');
380
+ const directory = (0, path_1.dirname)(this.config.exportPath);
381
+ await (0, promises_1.mkdir)(directory, { recursive: true, mode: 0o700 });
382
+ const directoryStat = await (0, promises_1.lstat)(directory);
383
+ if (!directoryStat.isDirectory())
384
+ throw new ExportOwnershipError('export parent is not a directory');
385
+ if ((directoryStat.mode & 0o077) !== 0)
386
+ throw new ExportOwnershipError('export parent is not owner-only');
387
+ const existingOutput = await this.lstatIfExists(this.config.exportPath);
388
+ if (existingOutput?.isSymbolicLink())
389
+ throw new ExportOwnershipError('export output is a symlink');
390
+ if (existingOutput)
391
+ throw new ExportOwnershipError('export output already exists');
392
+ let ownerHandle;
393
+ try {
394
+ ownerHandle = await (0, promises_1.open)(this.ownerPath, 'wx', 0o600);
395
+ }
396
+ catch (error) {
397
+ if (error.code === 'EEXIST') {
398
+ throw new ExportOwnershipError('owner record already exists');
399
+ }
400
+ throw error;
401
+ }
402
+ try {
403
+ await ownerHandle.writeFile(`${JSON.stringify(this.ownerRecord())}\n`);
404
+ await ownerHandle.sync();
405
+ }
406
+ finally {
407
+ await ownerHandle.close();
408
+ }
409
+ await this.syncDirectory(directory);
410
+ this.ownershipAcquired = true;
411
+ }
412
+ async assertOwnership(requireOutput) {
413
+ if (!this.config || !this.ownerPath || !this.snapshot || !this.ownershipAcquired)
414
+ throw new ExportOwnershipError('export ownership is not acquired');
415
+ const directoryStat = await (0, promises_1.lstat)((0, path_1.dirname)(this.config.exportPath));
416
+ if (!directoryStat.isDirectory())
417
+ throw new ExportOwnershipError('export parent is not a directory');
418
+ if ((directoryStat.mode & 0o077) !== 0)
419
+ throw new ExportOwnershipError('export parent is not owner-only');
420
+ const ownerStat = await (0, promises_1.lstat)(this.ownerPath);
421
+ if (ownerStat.isSymbolicLink())
422
+ throw new ExportOwnershipError('owner record is a symlink');
423
+ if ((ownerStat.mode & 0o177) !== 0)
424
+ throw new ExportOwnershipError('owner record is not owner-only');
425
+ const ownerHandle = await (0, promises_1.open)(this.ownerPath, 'r');
426
+ let owner;
427
+ try {
428
+ owner = JSON.parse(await ownerHandle.readFile('utf8'));
429
+ }
430
+ finally {
431
+ await ownerHandle.close();
432
+ }
433
+ if (JSON.stringify(owner) !== JSON.stringify(this.ownerRecord()))
434
+ throw new ExportOwnershipError('export ownership changed');
435
+ const outputStat = await this.lstatIfExists(this.config.exportPath);
436
+ if (!outputStat) {
437
+ if (requireOutput)
438
+ throw new ExportOwnershipError('export output is missing');
439
+ return;
440
+ }
441
+ if (outputStat.isSymbolicLink())
442
+ throw new ExportOwnershipError('export output is a symlink');
443
+ if ((outputStat.mode & 0o177) !== 0)
444
+ throw new ExportOwnershipError('export output is not owner-only');
445
+ const outputHandle = await (0, promises_1.open)(this.config.exportPath, 'r');
446
+ let current;
447
+ try {
448
+ current = JSON.parse(await outputHandle.readFile('utf8'));
449
+ }
450
+ finally {
451
+ await outputHandle.close();
452
+ }
453
+ const expected = this.ownerRecord();
454
+ if (current.runId !== expected.runId ||
455
+ current.processInstanceId !== expected.processInstanceId ||
456
+ current.configFingerprint !== expected.configFingerprint) {
457
+ throw new ExportOwnershipError('export output belongs to another session');
458
+ }
459
+ }
460
+ async syncDirectory(directory) {
461
+ const handle = await (0, promises_1.open)(directory, 'r');
462
+ try {
463
+ await handle.sync();
464
+ }
465
+ finally {
466
+ await handle.close();
467
+ }
468
+ }
469
+ async lstatIfExists(path) {
470
+ try {
471
+ return await (0, promises_1.lstat)(path);
472
+ }
473
+ catch (error) {
474
+ if (error.code === 'ENOENT')
475
+ return null;
476
+ throw error;
477
+ }
478
+ }
479
+ publish() {
480
+ if (!this.snapshot || !this.config)
481
+ return Promise.resolve();
482
+ this.publishRequested = true;
483
+ if (this.writePending)
484
+ return this.writePromise ?? Promise.resolve();
485
+ this.writePending = true;
486
+ this.writePromise = this.flushPublish();
487
+ return this.writePromise;
488
+ }
489
+ async flushPublish() {
490
+ try {
491
+ do {
492
+ this.publishRequested = false;
493
+ await this.writeSnapshot();
494
+ } while (this.publishRequested && this.snapshot?.status !== 'writer-failure');
495
+ }
496
+ finally {
497
+ this.writePending = false;
498
+ this.writePromise = null;
499
+ }
500
+ }
501
+ async writeSnapshot() {
502
+ if (!this.snapshot || !this.config)
503
+ return;
504
+ let temporary = null;
505
+ let temporaryCreated = false;
506
+ try {
507
+ await this.acquireOwnership();
508
+ await this.assertOwnership(false);
509
+ temporary = this.config.exportPath + '.tmp-' + process.pid + '-' + this.snapshot.sequence;
510
+ await (0, promises_1.writeFile)(temporary, JSON.stringify(this.snapshot) + '\n', { mode: 0o600, flag: 'wx' });
511
+ temporaryCreated = true;
512
+ const handle = await (0, promises_1.open)(temporary, 'r');
513
+ try {
514
+ await handle.sync();
515
+ }
516
+ finally {
517
+ await handle.close();
518
+ }
519
+ const outputExists = (await this.lstatIfExists(this.config.exportPath)) !== null;
520
+ if (outputExists) {
521
+ await this.assertOwnership(true);
522
+ await (0, promises_1.rename)(temporary, this.config.exportPath);
523
+ temporaryCreated = false;
524
+ }
525
+ else {
526
+ await (0, promises_1.link)(temporary, this.config.exportPath);
527
+ await (0, promises_1.unlink)(temporary);
528
+ temporaryCreated = false;
529
+ }
530
+ await this.syncDirectory((0, path_1.dirname)(this.config.exportPath));
531
+ await this.assertOwnership(true);
532
+ }
533
+ catch (error) {
534
+ if (temporaryCreated && temporary !== null)
535
+ await (0, promises_1.unlink)(temporary).catch(() => undefined);
536
+ if (this.snapshot) {
537
+ this.snapshot.status = 'writer-failure';
538
+ this.snapshot.reason =
539
+ error instanceof ExportOwnershipError ? 'export-ownership-failed' : 'export-write-failed';
540
+ }
541
+ }
542
+ }
543
+ };
544
+ exports.PollPlacementDiagnosticsService = PollPlacementDiagnosticsService;
545
+ exports.PollPlacementDiagnosticsService = PollPlacementDiagnosticsService = __decorate([
546
+ (0, common_1.Injectable)(),
547
+ __metadata("design:paramtypes", [])
548
+ ], PollPlacementDiagnosticsService);
549
+ //# sourceMappingURL=poll-placement-diagnostics.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"poll-placement-diagnostics.service.js","sourceRoot":"","sources":["../../../../src/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAgD;AAChD,2BAAkC;AAElC,0CAA8F;AAC9F,+BAA+B;AAC/B,2CAAyC;AAEzC,2CAA6D;AAkF7D,MAAM,OAAO,GAAG,4EAA4E,CAAC;AAC7F,MAAM,mBAAmB,GAAG,OAAO,CAAC;AACpC,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC;AAC7B,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC,MAAM,oBAAqB,SAAQ,KAAK;IACvC,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACpC,CAAC;CACD;AAGM,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAgB3C;QAfiB,sBAAiB,GAAG,IAAA,mBAAU,GAAE,CAAC;QACjC,wBAAmB,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAChD,yBAAoB,GAAG,IAAI,GAAG,EAA+B,CAAC;QAG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B;0CAA/B,+BAA+B;IAD3C,IAAA,mBAAU,GAAE;;GACA,+BAA+B,CA8gB3C"}
@@ -8,6 +8,7 @@ import { ManagedServiceManagerService } from '../../../modules/extensions/servic
8
8
  import { DelegatesManagerService } from '../delegates/delegates-manager.service';
9
9
  import { DatabaseDiscovererService } from './database-discoverer.service';
10
10
  import { DeviceManagerService } from './device-manager.service';
11
+ import { PollPlacementDiagnosticsService } from './poll-placement-diagnostics.service';
11
12
  import { ShellyWsServerService } from './shelly-ws-server.service';
12
13
  export declare class ShellyNgService extends BaseManagedExtensionService {
13
14
  private readonly configService;
@@ -18,6 +19,7 @@ export declare class ShellyNgService extends BaseManagedExtensionService {
18
19
  private readonly deviceConnectivityService;
19
20
  private readonly managedServiceManager;
20
21
  private readonly wsServer;
22
+ private readonly pollPlacementDiagnostics;
21
23
  private readonly logger;
22
24
  readonly owner: {
23
25
  readonly kind: "plugin";
@@ -25,17 +27,24 @@ export declare class ShellyNgService extends BaseManagedExtensionService {
25
27
  };
26
28
  readonly serviceId = "connector";
27
29
  private shellies?;
30
+ private mdnsDiscoverer?;
28
31
  private pluginConfig;
29
32
  private pendingRestart;
30
33
  private restartTimer;
31
34
  private healthCheckTimer;
32
35
  private healthCheckRunning;
33
36
  private statusPollTimer;
34
- private statusPollRunning;
37
+ private readonly statusPollTimers;
38
+ private readonly statusPollInFlight;
39
+ private statusPollGeneration;
40
+ private statusPollActive;
41
+ private static readonly STATUS_POLL_CONCURRENCY;
42
+ private static readonly STATUS_POLL_TIMEOUT_MS;
35
43
  private readonly discoveryQueue;
36
44
  private processingDiscovery;
37
45
  private discoveryGeneration;
38
- constructor(configService: ConfigService, databaseDiscovererService: DatabaseDiscovererService, delegatesRegistryService: DelegatesManagerService, deviceManagerService: DeviceManagerService, devicesService: DevicesService, deviceConnectivityService: DeviceConnectivityService, managedServiceManager: ManagedServiceManagerService, wsServer: ShellyWsServerService);
46
+ private delegateInsertion;
47
+ constructor(configService: ConfigService, databaseDiscovererService: DatabaseDiscovererService, delegatesRegistryService: DelegatesManagerService, deviceManagerService: DeviceManagerService, devicesService: DevicesService, deviceConnectivityService: DeviceConnectivityService, managedServiceManager: ManagedServiceManagerService, wsServer: ShellyWsServerService, pollPlacementDiagnostics?: PollPlacementDiagnosticsService);
39
48
  start(): Promise<void>;
40
49
  stop(): Promise<void>;
41
50
  isHealthy(): Promise<boolean>;
@@ -60,5 +69,8 @@ export declare class ShellyNgService extends BaseManagedExtensionService {
60
69
  private stopHealthCheck;
61
70
  private startStatusPoll;
62
71
  private stopStatusPoll;
72
+ private scheduleStatusPollCycle;
73
+ private scheduleStatusPollTimeout;
74
+ private runStatusPollSlot;
63
75
  private waitUntil;
64
76
  }